#include <bits/stdc++.h>   using namespace std;   int n, a[3001], b[3001], cnt = 1, sum;   int main() {     cin >> n;     for (int i = 1; i <= n; i++) cin >> a[i];     sort(a + 1, a + n + 1);     while (1) {       if (cnt == a[++sum])         cnt++;       else {         cout << cnt;         return 0;       }     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     vector<int> a(10, 0), b(10, 0);     string n;     string num;     cin >> n >> num;     for (auto w : num) {       a[w -  0 ]++;     }     int minimum = INT_MAX;     for (auto w : n) b[w -  0 ]++;     for (int i = 0; i < 10; i++) {       if (i != 2 && i != 6 && i != 5 && i != 9 && b[i] > 0)         minimum = min(minimum, a[i] / b[i]);     }     if (b[2] + b[5] > 0) minimum = min(minimum, (a[2] + a[5]) / (b[2] + b[5]));     if (b[6] + b[9] > 0) minimum = min(minimum, (a[6] + a[9]) / (b[6] + b[9]));     cout << minimum;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int maxn = 22;   const int maxp = 777 + (1 << (maxn - 2));   const int maxm = 1E5 + 77;   char S[maxm];   int N, M, _V[maxn][maxm], V[maxm], dp[maxn][maxp], ans = 1E9 + 7;   int main() {     scanf( %d%d , &N, &M);     for (int i = 0; i < N; ++i) {       scanf( %s , S);       for (int j = 0; j < M; ++j) _V[i][j] = S[j] ==  1  ? 1 : 0;     }     for (int j = 0; j < M; ++j)       for (int i = 0, v = 1; i < N; ++i, v <<= 1) V[j] |= _V[i][j] ? v : 0;     for (int i = 0; i < M; ++i) {       ++dp[0][V[i]];     }     int tot = 1 << N;     for (int i = 1; i <= N; ++i)       for (int j = 0; j < tot; ++j) {         if (i >= 3) dp[i][j] = dp[i - 2][j] * (i - 2);         for (int p = 1; p < tot; p <<= 1) {           for (int t = 1; t <= 2 && t <= i; ++t)             dp[i][j] += (t & 1 ? 1 : -1) * dp[i - t][j ^ (t & 1 ? p : 0)];         }         dp[i][j] /= i;       }     for (int i = 0; i < tot; ++i) {       int tans = 0;       for (int j = 0; j <= N; ++j) tans += min(j, N - j) * dp[j][i];       ans = min(ans, tans);     }     printf( %d n , ans);   }


#include <bits/stdc++.h>   using namespace std;   const int mxn = 2 * 100000 + 6;   int n, root;   int a[mxn];   int c[mxn];   int s[mxn];   int base;   int ans = 0x3f3f3f3f;   int main() {     cin >> n >> root;     for (int i = 1; i <= n; ++i) {       scanf( %d , &a[i]);       if (i == root && a[i] != 0) {         ++base;         a[i] = 0;       }       ++c[a[i]];     }     partial_sum(c, c + n, s);     int c0 = 0;     for (int i = 0; i < n; ++i) {       c0 += (c[i] == 0);       int mov = c[0] - 1 + n - s[i];       int sum = max(mov, c0);       if (i || n == 1) {         ans = min(ans, sum);       }     }     cout << ans + base << endl;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int N = 1003, INF = 2000000009;   struct ban {     int x, i;     ban() {}     ban(int x, int i) {       this->x = x;       this->i = i;     }   };   int n, m;   int s, f;   pair<pair<int, int>, int> b[N * 30];   vector<ban> a[N];   int hi;   bool c[N];   int pi[N], px[N];   bool dfs0(int x) {     c[x] = true;     if (x == f) return true;     for (int i = 0; i < a[x].size(); ++i) {       int h = a[x][i].x;       if (a[x][i].i == hi) continue;       if (!c[h]) {         pi[h] = a[x][i].i;         px[h] = x;         if (dfs0(h)) return true;       }     }     return false;   }   vector<int> path() {     for (int i = 1; i <= n; ++i) c[i] = false;     dfs0(s);     vector<int> v;     if (!c[f]) return v;     for (int i = f; i != s; i = px[i]) {       v.push_back(pi[i]);     }     reverse(v.begin(), v.end());     return v;   }   vector<int> vv;   int tin[N], ti, fup[N];   void dfs(int x, int pi) {     c[x] = true;     tin[x] = ti++;     fup[x] = tin[x];     for (int i = 0; i < a[x].size(); ++i) {       int h = a[x][i].x;       if (a[x][i].i == pi) continue;       if (a[x][i].i == hi) continue;       if (!c[h]) {         dfs(h, a[x][i].i);         fup[x] = min(fup[x], fup[h]);         if (fup[h] > tin[x]) vv.push_back(a[x][i].i);       } else {         fup[x] = min(fup[x], tin[h]);       }     }   }   vector<int> bridges() {     for (int i = 1; i <= n; ++i) c[i] = false;     vv.clear();     dfs(s, 0);     return vv;   }   int ans = INF;   int anss;   int ans1, ans2;   int main() {     cin >> n >> m;     cin >> s >> f;     for (int i = 1; i <= m; ++i) {       int x, y, z;       cin >> x >> y >> z;       a[x].push_back(ban(y, i));       a[y].push_back(ban(x, i));       b[i] = make_pair(make_pair(x, y), z);     }     if (s == f) {       cout <<  -1  << endl;       return 0;     }     vector<int> somepath = path();     if (somepath.empty()) {       cout << 0 << endl << 0 << endl;       return 0;     }     for (int i = 0; i < somepath.size(); ++i) {       hi = somepath[i];       vector<int> p = path();       if (p.empty()) {         if (b[somepath[i]].second < ans) {           ans = b[somepath[i]].second;           anss = 1;           ans1 = somepath[i];         }         continue;       }       set<int> s;       for (int j = 0; j < p.size(); ++j) s.insert(p[j]);       if (hi == 2) cerr <<   ;       vector<int> br = bridges();       for (int j = 0; j < br.size(); ++j) {         if (s.find(br[j]) != s.end()) {           if (b[somepath[i]].second + b[br[j]].second < ans) {             ans = b[somepath[i]].second + b[br[j]].second;             anss = 2;             ans1 = somepath[i];             ans2 = br[j];           }         }       }     }     if (ans == INF) {       cout <<  -1  << endl;       return 0;     }     cout << ans << endl;     cout << anss << endl;     if (anss == 1)       cout << ans1 << endl;     else       cout << ans1 <<     << ans2 << endl;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int MAXN = 100005;   struct node {     int next[2];     int cnt;   };   node make_node() {     node nd;     nd.cnt = 0;     nd.next[0] = nd.next[1] = -1;     return nd;   }   node t[MAXN * 30];   int sz = 0;   int bs = 29;   void add(int tiv, int d) {     (0);     int v = 0;     for (int i = bs; i >= 0; i--) {       int bit = (tiv >> i) & 1;       t[v].cnt += d;       ;       (0);       if (t[v].next[bit] == -1) {         t[sz] = make_node();         t[v].next[bit] = sz++;       }       v = t[v].next[bit];     }     t[v].cnt += d;     (0);     (0);   }   int query(int p, int l) {     int res = 0;     int v = 0;     int val = 0;     for (int i = bs; i >= 0; i--) {       (0);       int pi = (p >> i) & 1;       int li = (l >> i) & 1;       if (li == 1) {         int nxt = t[v].next[pi];         if (nxt != -1)           res += t[nxt].cnt;         else           (0);         if (t[v].next[1 - pi] == -1)           return res;         else {           v = t[v].next[1 - pi];         }       } else {         if (t[v].next[pi] == -1) return res;         v = t[v].next[pi];       }     }     return res;   }   int main() {     t[0] = make_node();     sz = 1;     int q;     scanf( %d , &q);     int op, p, l;     for (int qq = 0; qq < q; qq++) {       scanf( %d%d , &op, &p);       if (op == 1) {         add(p, 1);       } else if (op == 2) {         add(p, -1);       } else {         scanf( %d , &l);         int res = query(p, l);         cout << res << endl;         ;       }     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const long long mod = 1e9 + 7;   int n, k, m, res = 0, sm = 0, edge = -1, nb = 1;   int a[200055], b[200050], nxt[200505], dp[200005] = {0}, ans[500005];   multiset<int> st, st1, st2;   set<int> stres;   string s, s1, s2, s3, s4;   vector<int> v[200050], vnode, vans, v3;   vector<pair<int, int> > vv, vv1, adj, v1, v2;   vector<pair<int, pair<int, int> > > vvv;   priority_queue<int> q;   map<int, int> mp;   multiset<int>::iterator it, it1, it2;   int voyel(char c) {     if (c ==  a  || c ==  e  || c ==  i  || c ==  o  || c ==  u  || c ==  y )       return 1;     return 0;   }   int up[200005][20];   void solve() {     int i, j;     up[m + 1][0] = -1;     for (i = 1; i <= m; i++) {       int nxtt = nxt[b[i]];       int idx = lower_bound(v[nxtt].begin(), v[nxtt].end(), i) - v[nxtt].begin();       if (idx != v[nxtt].size()) {         int idxb = v[nxtt][idx];         up[i][0] = idxb;       } else         up[i][0] = -1;     }     for (int j = 1; j < 20; j++) {       for (i = 1; i <= m; i++)         if (up[i][j - 1] != -1) up[i][j] = up[up[i][j - 1]][j - 1];     }     for (i = 1; i <= m; i++) {       int bsup = i;       int x = n - 1;       for (j = 19; j >= 0; j--) {         if ((1 << j) <= x) {           x -= (1 << j);           if (bsup != -1) bsup = up[bsup][j];         }       }       if (bsup != -1) {         dp[i] = bsup;       }     }   }   int main() {     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);     int i = 0, j = 0, x, y, z = 0, mx = 0, nb0 = 0, nb1 = 0, nbmax = 0, nbinf = 0,         mm = 5e9, idx = 0, ok = 0, l, r, negatif = 0, positif = 0, q, d, res1 = 0;     char c;     cin >> n >> m >> q;     for (i = 1; i <= n; i++) {       cin >> a[i];     }     for (i = 1; i <= n; i++) nxt[a[i]] = a[i + 1];     nxt[a[n]] = a[1];     for (i = 1; i <= m; i++) {       cin >> b[i];       v[b[i]].push_back(i);     }     for (i = 1; i <= n; i++) {       sort(v[i].begin(), v[i].end());     }     memset(up, -1, sizeof(up));     solve();     idx = m + 1;     mx = 5e9;     for (i = m; i >= 1; i--) {       if (dp[i]) mx = min(mx, dp[i]);       ans[i] = mx;     }     s =   ;     while (q--) {       cin >> x >> y;       res = (ans[x] <= y);       if (res != 0)         s +=  1 ;       else         s +=  0 ;     }     cout << s;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int maxn = 3e5 + 10;   const int INF = 1e9;   int n, ans, ansl, ansr;   char s[maxn];   int a[maxn];   struct Node {     int pre, min, cnt, id;     Node() {       pre = cnt = id = 0;       min = INF;     }     Node(int _pre, int _min, int _cnt, int _id)         : pre(_pre), min(_min), cnt(_cnt), id(_id) {}   } b[maxn], pre[maxn], suf[maxn], tmppre[maxn], tmpsuf[maxn];   bool cmpl(const Node& a, const Node& b) {     return a.min - a.pre < b.min - b.pre;   }   bool cmpr(const Node& a, const Node& b) { return a.min < b.min; }   void cans(int cur, int l, int r) {     if (ans < cur) ans = cur, ansl = l, ansr = r;   }   Node merge(const Node& a, const Node& b) {     Node ret;     ret.pre = a.pre + b.pre;     if (a.min < b.min + a.pre) {       ret.min = a.min;       ret.cnt = a.cnt;     } else if (a.min == b.min + a.pre) {       ret.min = a.min;       ret.cnt = a.cnt + b.cnt;     } else {       ret.min = b.min + a.pre;       ret.cnt = b.cnt;     }     return ret;   }   Node rev(Node a) {     a.pre = -a.pre;     a.min = -a.min;     return a;   }   vector<Node> get(int l, int r, int k) {     vector<Node> ret;     tmppre[l - 1] = Node();     for (int i = l; i <= r; ++i) tmppre[i] = merge(tmppre[i - 1], b[i]);     tmpsuf[r + 1] = Node();     for (int i = r; i >= l; --i) tmpsuf[i] = merge(b[i], tmpsuf[i + 1]);     for (int i = l; i <= r; ++i)       if (a[i] == k) {         ret.push_back(merge(merge(tmppre[i - 1], rev(b[i])), tmpsuf[i + 1]));         ret.back().id = b[i].id;       }     return ret;   }   vector<Node> uniql(vector<Node> a) {     vector<Node> ret;     for (auto v : a) {       if (ret.empty() || ret.back().min - ret.back().pre != v.min - v.pre)         ret.push_back(v);       else if (ret.back().cnt < v.cnt)         ret.back() = v;     }     return ret;   }   vector<Node> uniqr(vector<Node> a) {     vector<Node> ret;     for (auto v : a) {       if (ret.empty() || ret.back().min != v.min)         ret.push_back(v);       else if (ret.back().cnt < v.cnt)         ret.back() = v;     }     return ret;   }   void calc(vector<Node> lv, vector<Node> rv, Node L, Node R, bool debug) {     int id;     for (auto& v : lv) id = v.id, v = merge(L, v), v.id = id;     for (auto& v : rv) id = v.id, v = merge(v, R), v.id = id;     sort(lv.begin(), lv.end(), cmpl);     sort(rv.begin(), rv.end(), cmpr);     lv = uniql(lv);     rv = uniqr(rv);     int l = 0;     for (int i = 0; i < rv.size(); ++i) {       while (l < lv.size() && lv[l].min <= lv[l].pre + rv[i].min) {         if (lv[l].min < lv[l].pre + rv[i].min)           cans(lv[l].cnt, lv[l].id, rv[i].id);         else           cans(lv[l].cnt + rv[i].cnt, lv[l].id, rv[i].id);         ++l;       }       if (l < lv.size()) cans(rv[i].cnt, lv[l].id, rv[i].id);     }   }   void solve(int l, int r) {     if (l == r) return;     int mid = l + r >> 1;     calc(get(l, mid, 1), get(mid + 1, r, -1), pre[l - 1], suf[r + 1], 0);     calc(get(l, mid, -1), get(mid + 1, r, 1), pre[l - 1], suf[r + 1], 0);     solve(l, mid);     solve(mid + 1, r);   }   int main() {     scanf( %d , &n);     scanf( %s , s + 1);     int sum = 0;     for (int i = 1; i <= n; ++i) {       a[i] = s[i] ==  (  ? 1 : -1;       b[i] = Node(a[i], a[i], 1, i);       sum += a[i];     }     if (sum) {       puts( 0 );       puts( 1 1 );       return 0;     }     for (int i = 1; i <= n; ++i) pre[i] = merge(pre[i - 1], b[i]);     for (int i = n; i >= 1; --i) suf[i] = merge(b[i], suf[i + 1]);     ans = pre[n].cnt;     ansl = ansr = 1;     solve(1, n);     printf( %d n , ans);     printf( %d %d n , ansl, ansr);     return 0;   }


#include <bits/stdc++.h>   int dx[] = {0, 0, 1, -1, 2, 2, -2, -2, 1, -1, 1, -1};   int dy[] = {1, -1, 0, 0, 1, -1, 1, -1, 2, 2, -2, -2};   using namespace std;   class PAIR {    public:     long long int first;     long long int second;     long long int third;   };   vector<long long int> V, V2, V3;   long long int ar[4500100];   map<long long int, long long int> m;   int main() {     long long int tcase = 1;     for (long long int test = 1; test <= tcase; test++) {       for (long long int i = 0; i <= 450010; i++) {         ar[i] = i;       }       long long int q, x, ans = 0;       scanf( %lld %lld , &q, &x);       long long int a;       for (long long int i = 0; i < q; i++) {         scanf( %lld , &a);         if (a == ans) {           ans++;           m[ar[a % x]] = 1;           while (m.count(ans) == 1) {             ans++;           }           ar[a % x] += x;           printf( %lld n , ans);           continue;         }         a %= x;         m[ar[a]] = 1;         if (ans == ar[a]) {           ans++;           while (m.count(ans) == 1) {             ans++;           }         }         ar[a] += x;         printf( %lld n , ans);       }     }   }


#include <bits/stdc++.h>   using namespace std;   const int Maxn = 300 * 1000 + 5;   int n, k, arr[Maxn];   int main() {     scanf( %d%d , &n, &k);     int Min = INT_MAX, Max = 0;     for (int i = 0; i < n; i++)       scanf( %d , &arr[i]), Min = min(Min, arr[i]), Max = max(Max, arr[i]);     sort(arr, arr + n);     for (int i = Min; i > 0; i--) {       bool mark = false;       if (Max % i <= k) {         for (int j = 2; j * i <= Max; j++) {           int ind = lower_bound(arr, arr + n, i * j) - arr;           ind--;           if (ind >= 0) {             if (arr[ind] % i > k) mark = true;           }         }         if (!mark) {           printf( %d n , i);           return 0;         }       }     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     int a, b, cnt, t;     scanf( %d , &t);     while (t--) {       scanf( %d %d , &a, &b);       cnt = 0;       while (a > 0 && b > 0) {         if (a > b) swap(a, b);         int tmp = b / a;         cnt += tmp;         b -= tmp * a;       }       printf( %d n , cnt);     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int maxn = 1005;   struct Edge {     int u, v, w, id;     Edge() {}     Edge(int a, int b, int c, int d) : u(a), v(b), w(c), id(d) {}     bool operator<(const Edge e) const { return w > e.w; }   } e[maxn * maxn];   int fa[maxn << 1];   int Find(int x) { return fa[x] == x ? fa[x] : (fa[x] = Find(fa[x])); }   void Merge(int a, int b) {     int x = Find(a);     int y = Find(b);     fa[x] = y;   }   int main() {     int n, m, q;     while (scanf( %d%d%d , &n, &m, &q) != EOF) {       int u, v, w;       for (int i = 0; i < m; i++) {         scanf( %d %d %d , &u, &v, &w);         e[i] = Edge(u, v, w, i + 1);       }       sort(e, e + m);       while (q--) {         int flag = 0;         for (int i = 1; i <= 2 * n; i++) fa[i] = i;         scanf( %d%d , &u, &v);         for (int i = 0; i < m; i++) {           if (e[i].id < u || e[i].id > v) continue;           if (Find(e[i].u) == Find(e[i].v)) {             printf( %d n , e[i].w);             flag = 1;             break;           } else {             Merge(e[i].u, e[i].v + n);             Merge(e[i].v, e[i].u + n);           }         }         if (!flag) printf( -1 n );       }     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const long long hell = 1000000007;   const long long INF = 1000000000;   void solve() {     long long n;     cin >> n;     map<long long, long long> mp;     long long a[n];     long long s = 0;     for (long long i = 0; i < n; i++) {       cin >> a[i];       s += a[i];       mp[a[i]]++;     }     vector<long long> ans;     for (long long i = 0; i < n; i++) {       long long S = s - a[i];       if (S % 2) continue;       mp[a[i]]--;       S = S / 2;       if (mp[S]) ans.push_back(i);       mp[a[i]]++;     }     cout << ans.size() << endl;     for (long long j : ans) cout << j + 1 <<    ;     cout << endl;   }   int32_t main() {     long long t;     t = 1;     while (t--) {       solve();     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int a[200005], f[200005], t[2000006], mx, mxbr;   bool bio[2000006], p[2000006];   int main() {     int n;     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> a[i];       p[a[i]] = 1;       mxbr = max(mxbr, a[i]);     }     for (int i = 2; i <= 2 * mxbr; i++) {       if (p[i - 1])         t[i] = i - 1;       else         t[i] = t[i - 1];     }     for (int i = 1; i <= n; i++) {       if (bio[a[i]]) continue;       int x = 2 * a[i];       for (int j = x; j <= 2 * mxbr; j += a[i])         if (t[j] > a[i]) mx = max(mx, t[j] % a[i]);       bio[a[i]] = 1;     }     cout << mx;   }


#include <bits/stdc++.h>   int a[100005];   int main() {     int n;     scanf( %d , &n);     for (int i = 0; i < n; i++) scanf( %d , &a[i]);     int flag = -1;     int sum = 0;     int sum1 = 0;     int ans = 1;     for (int i = 1; i < n; i++) {       if (a[i] == a[i - 1])         ans++;       else {         if (flag == -1) {           flag = 1;           sum = ans;           ans = 1;         } else {           if (ans != sum) {             printf( NO n );             return 0;           }           ans = 1;         }       }     }     if (flag == -1 || ans == sum)       printf( YES n );     else       printf( NO n );     return 0;   }


#include <bits/stdc++.h>   int main() {     int w1, h1, w2, h2, a, b, sum;     scanf( %d%d%d%d , &w1, &h1, &w2, &h2);     a = (h2 + h1 + 2) * 2;     b = w1 * 2;     sum = a + b;     printf( %d n , sum);     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const long long int MOD = 1000000007;   int N, a[169], c[169], K;   long long int M = -10000000000000LL;   int ned, prv[169], first[169];   long long int cap[20009], cost[20009], to[20009], nxt[20009], dist[169],       pot[169];   void init() {     memset(first, -1, sizeof first);     ned = 0;   }   void add(int u, int v, long long int f, long long int c) {     to[ned] = v, cap[ned] = f;     cost[ned] = c, nxt[ned] = first[u];     first[u] = ned++;     to[ned] = u, cap[ned] = 0;     cost[ned] = -c, nxt[ned] = first[v];     first[v] = ned++;   }   bool dijkstra(int s, int t) {     memset(prv, -1, sizeof prv);     for (int i = 0; i < N; i++) dist[i] = 1000000000000000000LL;     set<pair<long long int, int> > q;     q.insert(make_pair(0LL, s));     dist[s] = prv[s] = 0;     int u, v;     while (!q.empty()) {       u = q.begin()->second;       q.erase(q.begin());       for (int e = first[u]; e != -1; e = nxt[e]) {         if (cap[e] <= 0) continue;         v = to[e];         long long int new_dist = dist[u] + cost[e] + pot[u] - pot[v];         if (new_dist < dist[v]) {           q.erase(make_pair(dist[v], v));           dist[v] = new_dist;           prv[v] = e;           q.insert(make_pair(new_dist, v));         }       }     }     return prv[t] != -1;   }   inline long long int augment(int s, int t) {     for (int i = t; i != s; i = to[prv[i] ^ 1]) {       cap[prv[i]]--;       cap[prv[i] ^ 1]++;     }     --K;     long long int flowCost = dist[t] - pot[s] + pot[t];     for (int i = 0; i < N; i++)       if (prv[i] != -1) pot[i] += dist[i];     return flowCost;   }   long long int mincostmaxflow(int s, int t) {     long long int flowCost = 0;     memset(pot, 0, sizeof(pot));     while (K > 0 && dijkstra(s, t)) {       flowCost += augment(s, t);     }     return flowCost;   }   int main() {     set<int> v;     scanf( %d%d , &N, &K);     for (int i = 0; i < N; ++i) {       scanf( %d , &a[i]);       v.insert(a[i]);     }     for (int i = 1; i < N + 1; ++i) scanf( %d , &c[i]);     init();     K = min(K, (int)v.size());     for (int i = 0; i < N; ++i) {       add(0, 2 * i + 1, 1, c[a[i]]);       add(2 * i + 1, 2 * i + 2, 1, M);       add(2 * i + 2, 2 * N + 1, 1, 0);       for (int j = i + 1; j < N; ++j) {         if (a[i] != a[j])           add(2 * i + 2, 2 * j + 1, 1, c[a[j]]);         else           add(2 * i + 2, 2 * j + 1, 1, 0);       }     }     long long int n = N;     N = 2 * N + 2;     printf( %lld n , mincostmaxflow(0, N - 1) - M * n);   }


#include <bits/stdc++.h>   using namespace std;   char st[300010], opt[10];   int n, q;   int main() {     int i, j;     scanf( %d%d , &n, &q);     scanf( %s , st);     int cnt = 0, ans = 0;     for (i = 0; i < n; ++i) {       if (st[i] ==  . )         cnt++;       else {         ans += max(cnt - 1, 0);         cnt = 0;       }     }     ans += max(cnt - 1, 0);     char opt[4];     int pos;     while (q--) {       scanf( %d%s , &pos, opt);       pos--;       if (st[pos] ==  . ) {         if (pos + 1 < n && st[pos + 1] ==  . ) ans--;         if (pos - 1 >= 0 && st[pos - 1] ==  . ) ans--;       }       if (opt[0] ==  . ) {         if (pos + 1 < n && st[pos + 1] ==  . ) ans++;         if (pos - 1 >= 0 && st[pos - 1] ==  . ) ans++;       }       st[pos] = opt[0];       printf( %d n , ans);     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   template <class T>   void chmin(T &t, T f) {     if (t > f) t = f;   }   template <class T>   void chmax(T &t, T f) {     if (t < f) t = f;   }   int INF = (1 << 29);   int n, m;   int table[8][8];   void init() {}   void input() {     cin >> n >> m;     for (int i = (0); i < (n); i++)       for (int j = (0); j < (m); j++) cin >> table[i][j];   }   void solve() {     int mask = 1 << m;     int crt[1 << 8], nxt[1 << 8];     for (int i = (0); i < (mask); i++) crt[i] = INF;     crt[0] = 0;     for (int i = (0); i < (n); i++)       for (int j = (0); j < (m); j++) {         for (int k = (0); k < (mask); k++) nxt[k] = INF;         for (int k = (0); k < (mask); k++) {           if (k & 1) chmin(nxt[k >> 1], crt[k]);           if (!(k & 3) && j < m - 1) {             int add = (table[i][j] == table[i][j + 1] ? 0 : 1);             chmin(nxt[(k >> 1) | 1], crt[k] + add);           }           if (!(k & 1) && i < n - 1) {             int add = (table[i][j] == table[i + 1][j] ? 0 : 1);             chmin(nxt[(k >> 1) | (1 << (m - 1))], crt[k] + add);           }         }         swap(crt, nxt);       }     cout << crt[0] << endl;   }   int main() {     init();     input();     solve();     return 0;   }


#include <bits/stdc++.h>   using namespace std;   using namespace std;   int main() {     int a, b, c, d;     cin >> a >> b >> c >> d;     int res1 = max((3 * a) / 10, (a - (a / 250) * c));     int res2 = max((3 * b) / 10, (b - (b / 250) * d));     if (res1 > res2)       cout <<  Misha  << endl;     else if (res1 < res2)       cout <<  Vasya  << endl;     else       cout <<  Tie  << endl;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   long long func(long long a, long long b, long long c) {     if (a % 2 != b % 2) return (1ll << 60);     long long x = min(a + c, b + c);     return a + b + c - x;   }   int main(void) {     int i;     long long a, b, c;     cin >> a >> b >> c;     long long ans = (1ll << 60);     ans = min(ans, func(a, b, c));     ans = min(ans, func(b, c, a));     ans = min(ans, func(c, a, b));     if (ans == (1ll << 60)) return -1;     cout << ans << endl;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   long long gcd(long long a, long long b) {     if (a < b) swap(a, b);     while (b) {       long long t = b;       b = a % b;       a = t;     }     return a;   }   long long mul(long long a, long long b, long long m) {     long long q = (long double)a * (long double)b / (long double)m;     long long r = a * b - q * m;     return (r + 5 * m) % m;   }   long long extendedEuclides(long long a, long long b, long long &x,                              long long &y) {     long long xx = y = 0;     long long yy = x = 1;     while (b) {       long long q = a / b;       long long t = b;       b = a % b;       a = t;       t = xx;       xx = x - q * xx;       x = t;       t = yy;       yy = y - q * yy;       y = t;     }     return a;   }   pair<long long, long long> chineseRemainder(long long x, long long y,                                               long long a, long long b) {     if (a == -1 || b == -1 || x == -1 || y == -1) return make_pair(0, -1);     long long s, t;     long long d = extendedEuclides(x, y, s, t);     if (a % d != b % d) return make_pair(0, -1);     long long mod = x * (y / d);     return make_pair((a + mul(mul(x, s, mod), (b - a) / d, mod) + 5 * mod) % mod,                      x * (y / d));   }   pair<long long, long long> seg[801000];   pair<long long, long long> arr[100100];   void build(int l, int r, int pos) {     if (l == r) {       seg[pos] = arr[l];       return;     }     int m = (l + r) / 2;     build(l, m, 2 * pos + 1);     build(1 + m, r, 2 * pos + 2);     seg[pos] = chineseRemainder(seg[2 * pos + 1].second, seg[2 * pos + 2].second,                                 seg[2 * pos + 1].first, seg[2 * pos + 2].first);   }   pair<long long, long long> qry(int l, int r, int pos, int ql, int qr) {     if (qr >= r && ql <= l) return seg[pos];     if (qr < l || ql > r) return make_pair(0, 1);     pair<long long, long long> pr, pl;     pl = qry(l, (l + r) / 2, 2 * pos + 1, ql, qr);     pr = qry((l + r) / 2 + 1, r, 2 * pos + 2, ql, qr);     return chineseRemainder(pl.second, pr.second, pl.first, pr.first);   }   vector<pair<long long, long long> > arrs[100100];   int ans[100100];   int kss[100100];   int solve(int k) {     build(0, k - 1, 0);     int l = 0, r = 0, mxm = 1;     while (l < k && r < k) {       if (qry(0, k - 1, 0, l, r).second != -1) mxm = max(mxm, r - l + 1);       if (r == k - 1)         l++;       else if (qry(0, k - 1, 0, l, r).second != -1)         r++;       else         l++;       if (qry(0, k - 1, 0, l, r).second != -1) mxm = max(mxm, r - l + 1);     }     r = k - 1;     while (l < k) {       if (qry(0, k - 1, 0, l, r).second != -1) mxm = max(mxm, r - l + 1);       l++;     }     return mxm;   }   int main() {     int n, m;     cin >> n >> m;     for (int i = 0; i < n; i++) {       cin >> kss[i];       for (int j = 0; j < kss[i]; j++) {         int a;         cin >> a;         arrs[a].push_back(make_pair(j, i));       }     }     int i = 1;     while (i <= m) {       if (arrs[i].size() == 0) {         cout << 0 << endl;         i++;         continue;       }       pair<int, int> last = arrs[i][0];       int j = 0, h = 1;       arr[0] = make_pair(arrs[i][0].first, kss[arrs[i][0].second]);       while (j < arrs[i].size()) {         j++;         if (j == arrs[i].size() ||             arrs[i][j].second != arrs[i][j - 1].second + 1) {           ans[i] = max(ans[i], solve(h));           h = 0;           if (j != arrs[i].size())             arr[h++] = make_pair(arrs[i][j].first, kss[arrs[i][j].second]);         } else {           arr[h++] = make_pair(arrs[i][j].first, kss[arrs[i][j].second]);         }       }       cout << ans[i] << endl;       i++;     }   }


#include <bits/stdc++.h>   #pragma GCC optimize( Ofast )   #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native )   #pragma GCC optimize( unroll-loops )   using namespace std;   template <class A>   istream& operator>>(istream& in, vector<A>& a) {     for (A& i : a) in >> i;     return in;   }   template <class A>   istream& operator>>(istream& in, vector<vector<A>>& a) {     for (auto& i : a)       for (auto& j : i) in >> j;     return in;   }   template <class A>   ostream& operator<<(ostream& in, vector<A>& a) {     for (A& i : a) in << i <<    ;     in << endl;     return in;   }   template <class A>   ostream& operator<<(ostream& in, vector<vector<A>>& a) {     for (auto& i : a) {       for (auto& j : i) in << j <<    ;       in << endl;     }     return in;   }   const long long mod = 1e9 + 7;   long long power(long long x, long long y) {     long long res = 1;     while (y > 0) {       if (y & 1) res = (res * x) % mod;       y >>= 1;       x = (x * x) % mod;     }     return (res % mod);   }   void solve() {     int n, m;     cin >> n >> m;     vector<int> v(n), ans;     cin >> v;     map<int, bool> mp;     for (int i = 0; i < n; i++) {       mp[v[i]] = true;     }     for (int i = 1; 1; i++) {       if (mp[i] == 0 && m - i >= 0) {         ans.push_back(i);         m -= i;         mp[i] = true;       }       if (m < i) {         break;       }     }     cout << ans.size() <<   n  << ans;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long tc = 1;     for (long long t = 1; t <= tc; t++) {       solve();     }   }


#include <bits/stdc++.h>   using namespace std;   int n, m, k;   int dx[4] = {-1, 0, 1, 0};   int dy[4] = {0, 1, 0, -1};   vector<string> museum;   vector<vector<int> > pictures;   vector<vector<bool> > used;   queue<pair<int, int> > line;   vector<pair<int, int> > req;   void BFS(int& i, int& j) {     line.push(make_pair(i, j));     used[i][j] = true;     int cnt = 0;     req.clear();     while (!line.empty()) {       int x = line.front().first;       int y = line.front().second;       line.pop();       req.push_back(make_pair(x, y));       for (int z = 0; z < 4; z++) {         int newI = x + dx[z];         int newJ = y + dy[z];         if (newI >= 0 && newI < n && newJ >= 0 && newJ < m &&             museum[newI][newJ] ==  * ) {           cnt++;         }       }       for (int z = 0; z < 4; z++) {         int newI = x + dx[z];         int newJ = y + dy[z];         if (newI >= 0 && newI < n && newJ >= 0 && newJ < m &&             museum[newI][newJ] ==  .  && !used[newI][newJ]) {           used[newI][newJ] = true;           line.push(make_pair(newI, newJ));         }       }     }     for (int z = 0; z < req.size(); z++) {       pictures[req[z].first][req[z].second] = cnt;     }   }   int main() {     cin >> n >> m >> k;     museum.resize(n);     used.resize(n, vector<bool>(m, false));     for (int i = 0; i < n; i++) {       cin >> museum[i];     }     pictures.resize(n, vector<int>(m, -1));     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         if (museum[i][j] ==  .  && pictures[i][j] == -1) {           BFS(i, j);         }       }     }     for (int i = 0; i < k; i++) {       int x, y;       cin >> x >> y;       x--;       y--;       printf( %d n , pictures[x][y]);     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   long long n;   long long mult(long long a, long long b, long long limit) {     long long x = 0, y = a;     while (b > 0) {       if (b % 2 == 1) {         x = (x + y);         if (x >= limit) return -1;       }       y = (y * 2);       b /= 2;       if (y >= limit && b > 0) return -1;     }     return x;   }   long long calc(long long teams) {     long long ret = 0;     while (teams % 2 == 0) {       long long hlf = teams / 2;       ret += hlf;       teams = hlf;       if (ret > n) return -1;     }     long long prt = mult(teams, teams - 1, 4 * n);     if (prt == -1) return -1;     prt /= 2;     ret += prt;     if (ret > n) return -1;     return ret;   }   int main() {     cin >> n;     vector<long long> sol;     for (long long pw2 = 1, cnt = 0; pw2 <= n * 4; pw2 *= 2, cnt++) {       long long lo = 0, hi = ceil(sqrt(4 * n));       long long found = -1;       while (lo <= hi) {         long long mid = (lo + hi) >> 1;         long long odd_part = 2 * mid + 1;         long long tot = mult(odd_part, pw2, 4 * n);         if (tot == -1) {           hi = mid - 1;           continue;         }         long long calc_runs = calc(tot);         if (calc_runs == -1) {           hi = mid - 1;           continue;         } else if (calc_runs == n) {           found = tot;           break;         } else if (calc_runs < n)           lo = mid + 1;         else           hi = mid - 1;       }       if (found != -1) sol.push_back(found);     }     if (sol.size() == 0) {       printf( -1 n );       return 0;     }     sort(sol.begin(), sol.end());     for (int i = 0; i < sol.size(); ++i) cout << sol[i] << endl;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int n;   int b[200010];   map<int, long long> S;   long long solve() {     S.clear();     long long df, ans = 0;     for (int i = 0; i < n; i++) {       df = b[i] - i;       S[df] += (long long)b[i];     }     map<int, long long>::iterator it;     for (it = S.begin(); it != S.end(); it++) ans = max(ans, it->second);     return ans;   }   int main() {     cin >> n;     for (int i = 0; i < n; i++) cin >> b[i];     cout << solve() << endl;   }


#include <bits/stdc++.h>   using namespace std;   const long long maxn = 1e6 + 5;   vector<vector<pair<long long, long long> > > dis(maxn);   long long flag[maxn];   long long c1, c2;   bool ok;   void dfs(long long index, long long p) {     flag[index] = p;     for (long long i = 0; i < dis[index].size(); i++) {       if (flag[dis[index][i].first] != -1 &&           flag[dis[index][i].first] != (dis[index][i].second == p))         ok = false;       if (flag[dis[index][i].first] == -1) {         if (dis[index][i].second == p) {           c1++;         } else           c2++;         dfs(dis[index][i].first, dis[index][i].second == p);       }     }   }   signed main() {     long long t;     cin >> t;     memset(flag, -1, sizeof(flag));     while (t--) {       long long n, m;       cin >> n >> m;       long long x, y;       string s;       while (m--) {         cin >> x >> y >> s;         if (s[0] ==  c ) {           dis[x].push_back({y, 1});           dis[y].push_back({x, 1});         } else {           dis[x].push_back({y, 0});           dis[y].push_back({x, 0});         }       }       long long ans = 0;       ok = true;       for (long long i = 1; i <= n; i++) {         if (flag[i] == -1) {           c1 = 1, c2 = 0;           dfs(i, 1);           ans += max(c1, c2);         }       }       for (long long i = 1; i <= n; i++) {         dis[i].clear();         flag[i] = -1;       }       if (!ok)         cout <<  -1  << endl;       else         cout << ans << endl;     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int N, Q;   vector<int> E[200005];   int P[21][200005], D[200005];   void dfs(int cur) {     for (__typeof(E[cur].begin()) it = E[cur].begin(); it != E[cur].end(); it++)       if (*it != P[0][cur]) D[*it] = D[cur] + 1, P[0][*it] = cur, dfs(*it);   }   int lca(int a, int b) {     int ret = 0, i, aa = a, bb = b;     if (D[aa] > D[bb]) swap(aa, bb);     for (i = 19; i >= 0; i--)       if (D[bb] - D[aa] >= 1 << i) bb = P[i][bb];     for (i = 19; i >= 0; i--)       if (P[i][aa] != P[i][bb]) aa = P[i][aa], bb = P[i][bb];     return (aa == bb) ? aa : P[0][aa];   }   int dist(int a, int b) { return D[a] + D[b] - 2 * D[lca(a, b)]; }   int hoge(int S, int T, int F) {     int ST = lca(S, T);     int FT = lca(F, T);     int SF = lca(S, F);     int STD = dist(S, T);     int FTD = dist(F, T);     int SFD = dist(S, F);     if (SFD + STD == FTD) return STD + 1;     if (SFD + FTD == STD) return FTD + 1;     if (D[ST] > D[SF]) {       return D[T] - D[ST] + 1;     } else if (D[FT] > D[SF]) {       return D[T] - D[FT] + 1;     } else {       return dist(SF, T) + 1;     }   }   void solve() {     int i, j, k, l, r, x, y;     string s;     cin >> N >> Q;     for (i = 0; i < (N - 1); i++) {       cin >> x;       E[i + 1].push_back(x - 1);       E[x - 1].push_back(i + 1);     }     dfs(0);     for (i = 0; i < (19); i++)       for (x = 0; x < (N); x++) P[i + 1][x] = P[i][P[i][x]];     while (Q--) {       int A, B, C;       cin >> A >> B >> C;       A--, B--, C--;       cout << max({hoge(A, B, C), hoge(A, C, B), hoge(B, A, C)}) << endl;     }   }   int main(int argc, char** argv) {     string s;     int i;     if (argc == 1) ios::sync_with_stdio(false), cin.tie(0);     for (i = 0; i < (argc - 1); i++) s += argv[i + 1], s +=   n ;     for (i = 0; i < (s.size()); i++) ungetc(s[s.size() - 1 - i], stdin);     solve();     return 0;   }


#include <bits/stdc++.h>   using namespace std;   pair<int, int> p[2005 * 2005];   char a[2005][2005], cg[4] = { v ,  < ,  ^ ,  > };   int n, m, mox[4] = {-1, 0, 1, 0}, moy[4] = {0, 1, 0, -1};   int ispoint(int x, int y) {     return (x >= 0 && x < n && y >= 0 && y < m && a[x][y] ==  . );   }   int deg(int x, int y) {     int ans = 0;     for (int i = 0; i < 4; i++) {       int fx = x + mox[i];       int fy = y + moy[i];       if (ispoint(fx, fy)) ans++;     }     return ans;   }   int main() {     while (scanf( %d %d , &n, &m) != EOF) {       for (int i = 0; i < n; i++) scanf( %s , a[i]);       int h = 0, sum = 0;       for (int i = 0; i < n; i++)         for (int j = 0; j < m; j++)           if (ispoint(i, j) && deg(i, j) == 1) p[sum++] = make_pair(i, j);       for (; h < sum; h++) {         int x = p[h].first, y = p[h].second;         for (int i = 0; i < 4; i++) {           int fx = x + mox[i];           int fy = y + moy[i];           if (ispoint(fx, fy)) {             a[x][y] = cg[i];             a[fx][fy] = cg[i ^ 2];             for (int i = 0; i < 4; i++) {               int ffx = fx + mox[i];               int ffy = fy + moy[i];               if (ispoint(ffx, ffy) && deg(ffx, ffy) == 1)                 p[sum++] = make_pair(ffx, ffy);             }             break;           }         }       }       int flag = 0;       for (int i = 0; i < n && !flag; i++)         for (int j = 0; j < m && !flag; j++)           if (a[i][j] ==  . ) flag = 1;       if (flag == 1)         printf( Not unique n );       else {         for (int i = 0; i < n; i++, printf(  n ))           for (int j = 0; j < m; j++) printf( %c , a[i][j]);       }     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 5;   const long long oo = 1e9 + 7;   const int mod = 1e9 + 7;   double x, y, tmp;   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> x >> y;     tmp = log(x) / log(y);     if (tmp * y * 1.00 < x)       cout <<  < ;     else if (tmp * y * 1.00 > x)       cout <<  > ;     else       cout <<  = ;   }


#include <bits/stdc++.h>   using namespace std;   void myassert(bool expr) {     if (!expr) abort();   }   const int64_t posinf = 9223372036854775807LL;   const int64_t neginf = 9223372036854775808LL;   const int64_t bigprime = (1LL << 61) - 1LL;   const int64_t mult = 199;   const int64_t mult2 = 3571;   const int64_t mod = 1000000007LL;   const int64_t mod2 = 1000000009LL;   const long double pi = 3.1415926535897932384626433832795L;   template <typename T>   T gcd(T a, T b) {     while (b) {       a %= b;       swap(a, b);     }     return a;   }   char mtx[1024][1024];   int main() {     cin.sync_with_stdio(false);     cout.sync_with_stdio(false);     cin.tie(0);     int n, m;     cin >> n >> m;     for (int i = 0; i < n; i++) {       cin >> mtx[i];       for (int j = 0; j < m; j++)         if (mtx[i][j] ==  b ) mtx[i][j] =  f ;     }     char lets[4] = { a ,  b ,  c ,  d };     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         if (mtx[i][j] ==  f ) {           cout <<  NO ;           return 0;         }         if (mtx[i][j] !=  w ) continue;         if (mtx[i][j + 1] ==  f  && mtx[i][j + 2] ==  w ) {           mtx[i][j] = mtx[i][j + 1] = mtx[i][j + 2] =               lets[(i + (j + 1) / 2 * 2) % 4];         } else if (mtx[i + 1][j] ==  f  && mtx[i + 2][j] ==  w ) {           mtx[i][j] = mtx[i + 1][j] = mtx[i + 2][j] =               lets[(i + 1 + j / 2 * 2) % 4];         } else {           cout <<  NO ;           return 0;         }       }     }     for (int i = 0; i < n; i++)       for (int j = 0; j < m; j++)         if (mtx[i][j] ==  f  || mtx[i][j] ==  w ) {           cout <<  NO ;           return 0;         }     cout <<  YES  << endl;     for (int i = 0; i < n; i++) cout << mtx[i] << endl;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const double pi = 3.14159265358979;   vector<pair<int, int> > A[100001];   int main() {     int n, m, a, b;     scanf( %d%d , &n, &m);     priority_queue<pair<int, int>, vector<pair<int, int> >,                    greater<pair<int, int> > >         q;     vector<int> ans;     for (int i = 0; i < m; ++i) {       scanf( %d%d , &a, &b);       A[min(a, n + 1 - b)].push_back(make_pair(max(a, n + 1 - b), i + 1));     }     for (int i = 1; i <= n; ++i) {       for (int j = 0; j < A[i].size(); ++j) {         q.push(A[i][j]);       }       while (!q.empty()) {         pair<int, int> t = q.top();         if (t.first < i)           q.pop();         else           break;       }       if (!q.empty()) {         ans.push_back(q.top().second);         q.pop();       }     }     printf( %d n , ans.size());     for (int i = 0; i < ans.size(); ++i) {       printf( %d  , ans[i]);     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     int n = 0;     int m = 0;     cin >> n >> m;     int num = 0;     num = (n * m) / 2;     cout << num;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     string s, e;     cin >> s >> e;     int h1, m1, h2, m2;     h1 = (s[0] -  0 ) * 10 + (s[1] -  0 );     h2 = (e[0] -  0 ) * 10 + (e[1] -  0 );     m1 = (s[3] -  0 ) * 10 + (s[4] -  0 );     m2 = (e[3] -  0 ) * 10 + (e[4] -  0 );     long long int total1 = h1 * 60 + m1;     long long int total2 = h2 * 60 + m2;     long long int dif = (total2 - total1) / 2;     int ansh = dif / 60;     int ansm = dif % 60;     int fh = h1 + ansh;     int fm = m1 + ansm;     if (fm >= 60) {       fh += 1;       fm %= 60;     }     if (fh > 9) {       cout << fh <<  : ;     } else {       cout <<  0  << fh <<  : ;     }     if (fm > 9) {       cout << fm << endl;     } else {       cout <<  0  << fm << endl;     }   }


#include <bits/stdc++.h>   using namespace std;   int main() {     int c = 0;     string s;     cin >> s;     for (int i = 0; i < s.size(); i++) {       if (s[i] == s[i + 1]) {         c++;         if (c >= 6) break;       } else if (s[i] != s[i + 1]) {         c = 0;       }     }     if (c >= 6) {       cout <<  YES  << endl;     } else       cout <<  NO  << endl;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int read() {     int x = 0, f = 1;     char c = getchar();     for (; !isdigit(c); c = getchar())       if (c ==  - ) f = -1;     for (; isdigit(c); c = getchar()) x = x * 10 + c -  0 ;     return x * f;   }   namespace Sa {   struct Node {     double x, y;     Node() {}     Node(double x, double y) : x(x), y(y) {}     Node operator-(Node a) const { return Node(x - a.x, y - a.y); }     double operator*(Node a) const { return x * a.y - y * a.x; }   } a[1], b[1];   double l, r, Mid, Ans, Now, x, y, Ax, T, N2;   int i, j, k, n, m;   inline double Getrand() { return rand() % 1000 / 1000.0; }   inline double Gety(double x) {     for (int i = 1; i < n; i++)       if (a[i + 1].x > x)         return (a[i + 1].y - a[i].y) / (a[i + 1].x - a[i].x) * (x - a[i].x) +                a[i].y;   }   inline bool Check(Node A) {     for (int i = 1; i < n; i++)       if ((A - a[i]) * (A - a[i + 1]) < 0) return 0;     return 1;   }   inline double Calc(double x) {     double l = 0, r = 0, Mid;     while (r - l > 1) {       Mid = (l + r) / 2.0;       if (Check(Node(x, Mid)))         r = Mid;       else         l = Mid;     }     l -= Gety(x);     if (l < Ans) Ans = l, Ax = x;     return l;   }   inline void SA(double T) {     for (; T > 0.00001; T *= 0.99) {       y = x + T * (Getrand() * 2 - 1);       if (y < a[1].x || y > a[n].x) continue;       N2 = Calc(x) - Calc(y);       if (N2 > 0 || exp(N2 / T) > Getrand()) x = y;     }     for (int i = 1; i <= 1000; i++) {       y = Ax + T * (Getrand() * 2 - 1);       if (y < a[1].x || y > a[n].x) continue;       Calc(y);     }   }   }  // namespace Sa   int main() {     int t = read();     while (t--) {       int n = read();       double T = n;       if (n * n < 4 * n) {         printf( N n );         continue;       }       double a = (T + sqrt(T * T - 4.0 * T)) / 2.0;       double b = (T - sqrt(T * T - 4.0 * T)) / 2.0;       printf( Y %.10f %.10f n , a, b);     }   }


#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       long long n, m;       cin >> n >> m;       long long sum = 0, cyl = 0;       long long k = (n / m);       for (int i = 1; i <= 10; ++i) {         cyl += (m * i) % 10;       }       sum = (k / 10) * cyl;       cyl = 0;       for (int i = 1; i <= k % 10; ++i) {         cyl += m * (i) % 10;       }       cout << sum + cyl << endl;     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     int a, b, c, d;     scanf( %d%d%d%d , &a, &b, &c, &d);     if (a < max(c, d) || b < max(c, d)) {       printf( -1 n );     } else if (c == 0 && d == 0) {       for (int i = 0; i < a; i++) printf( 4 );       for (int i = 0; i < b; i++) printf( 7 );       printf(  n );     } else if (c == d) {       if (a == b && a == c) {         printf( -1 n );       } else if (a == c) {         for (int i = 0; i < c; i++) printf( 74 );         for (int i = 0; i < b - c; i++) printf( 7 );         printf(  n );       } else if (b == c) {         for (int i = 0; i < a - c; i++) printf( 4 );         for (int i = 0; i < c; i++) printf( 74 );         printf(  n );       } else {         for (int i = 0; i < a - c - 1; i++) printf( 4 );         for (int i = 0; i < c; i++) printf( 47 );         for (int i = 0; i < b - c; i++) printf( 7 );         printf( 4 );         printf(  n );       }     } else if (c - d == 1) {       for (int i = 0; i < a - c; i++) printf( 4 );       for (int i = 0; i < c; i++) printf( 47 );       for (int i = 0; i < b - c; i++) printf( 7 );       printf(  n );     } else if (d - c == 1) {       printf( 74 );       for (int i = 0; i < a - d; i++) printf( 4 );       for (int i = 0; i < d - 2; i++) printf( 74 );       for (int i = 0; i < b - d; i++) printf( 7 );       printf( 74 );       printf(  n );     } else       printf( -1 n );     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     int i, j, k, n, m;     while (cin >> n >> k) {       if (n * (n - 1) / 2 <= k) {         puts( no solution );       } else {         for (i = 0; i < n; i++) printf( 0 %d n , i);       }     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     int n, q;     scanf( %d , &n);     bool grid[n + 1][n + 1], ans = false;     string s;     for (int i = 0; i < n; i++)       for (int j = 0; j < n; j++) scanf( %d , &grid[i][j]);     for (int i = 0; i < n; i++) {       for (int j = 0; j < n; j++) {         ans ^= (grid[j][i] && grid[i][j]);       }     }     scanf( %d , &q);     while (q--) {       int t;       scanf( %d , &t);       if (t == 1 || t == 2) {         scanf( %d , &t);         ans ^= 1;       } else         s += (ans +  0 );     }     printf( %s , s.c_str());     return 0;   }


#include <bits/stdc++.h>   using namespace std;   long long k, ans, a[501], i, g, n;   long long check(long long x) {     k = 0;     if (x == 1) return 0;     for (long long i = 1; i <= n; i++)       if (a[i] / (x - 1) * x < a[i])         return 0;       else         k += (a[i] + x - 1) / x;     if (k < ans) ans = k;   }   int main() {     scanf( %d , &n);     for (i = 1; i <= n; i++) scanf( %d , &a[i]), ans += a[i] / 2 + a[i] % 2;     sort(a + 1, a + n + 1);     for (i = 2; i <= sqrt(a[n]) + 2; i++) check(i);     for (i = 1; i <= sqrt(a[n]); i++) {       g = a[n] / i, check(g), check(g + 1), check(g + 2);     }     printf( %lld n , ans);   }


#include <bits/stdc++.h>   using namespace std;   inline int nxt() {     int x;     scanf( %d , &x);     return x;   }   const int N = 55;   int a[N][N];   char skdjflfsdj[N][N];   int score[N];   void add(int u, int v, int x) {     a[u][v] += x;     score[u] += x;   }   vector<int> all_out(int v, int n) {     vector<char> used(n);     vector<int> st = {v};     used[v] = 1;     vector<int> par(n, -1);     while (!st.empty()) {       int u = st.back();       st.pop_back();       for (int i = 0; i < n; ++i) {         if (!skdjflfsdj[i][u] && a[u][i]) {           if (!used[i]) {             used[i] = 1;             par[i] = u;             st.push_back(i);           }         }       }     }     return par;   }   int main() {     mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());     int n = nxt(), m = nxt();     for (int i = 0; i < m; ++i) {       int u = nxt() - 1, v = nxt() - 1;       add(u, v, 1);       skdjflfsdj[u][v] = skdjflfsdj[v][u] = 1;     }     for (int i = 0; i < n; ++i) {       for (int j = 0; j < i; ++j) {         if (!skdjflfsdj[i][j]) {           if (rng() % 2) {             add(i, j, 1);           } else {             add(j, i, 1);           }         }       }     }     while (true) {       bool ok = false;       for (int i = 0; i < n; ++i) {         if (ok) {           break;         }         auto par = all_out(i, n);         for (int j = 0; j < n; ++j) {           if (i != j && par[j] > -1 && score[j] < score[i] - 1) {             for (int u = j; u != i; u = par[u]) {               add(u, par[u], 1);               add(par[u], u, -1);             }             ok = true;             break;           }         }       }       if (!ok) {         break;       }     }     for (int i = 0; i < n; ++i) {       for (int j = 0; j < n; ++j) {         cout << a[i][j];       }       cout <<   n ;     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int mod = 256;   int getNum(char tch) {     int num = tch;     char ch[10];     int cnt = 0;     while (cnt < 8) {       ch[cnt++] = num % 2 +  0 ;       num /= 2;     }     num = 0;     for (int i = 0; i < 8; i++) {       num = num * 2 + (ch[i] -  0 );     }     return num;   }   int main() {     char ch[1000];     gets(ch);     int len = strlen(ch);     int pre = 0;     for (int i = 0; i < len; i++) {       int tmp = getNum(ch[i]);       cout << (pre - tmp + 10 * 256) % mod << endl;       pre = tmp;     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m, a[100001];     cin >> n >> m;     for (int i = 1; i <= m; i++) {       cin >> a[i];     }     sort(a + 1, a + 1 + m);     int ans = 100000000;     for (int i = 1; i <= m - n + 1; i++) {       ans = min(ans, a[i + n - 1] - a[i]);     }     cout << ans;   }


#include <bits/stdc++.h>   #pragma warning(disable : 6031)   #pragma warning(disable : 4101)   using namespace std;   const int INF = 1e9;   const long long LINF = 1e18;   const double PI = acos(-1);   const int MAXN = 1000006;   int n, m, v1, v2, Deg[MAXN], visited[MAXN];   vector<unordered_set<int>> G;   vector<int> C;   set<pair<int, int>> erased;   void find_component(int v) {     visited[v] = true;     C.push_back(v);     for (int c : G[v]) {       if (!visited[c]) {         find_component(c);       }     }   }   void eulerian_cycle(int v) {     stack<int> S;     vector<int> ans;     S.push(v);     while (!S.empty()) {       int s = S.top();       if (G[s].empty()) {         ans.push_back(s);         S.pop();       } else {         int c = *G[s].begin();         G[s].erase(G[s].begin());         G[c].erase(s);         S.push(c);       }     }     int ans_size = ((int)(ans).size());     for (int i = 1; i < ((int)(ans).size()); i += 2) {       if (ans[i] != 0 && ans[i + 1] != 0) {         if (ans[i - 1] != 0 && ans[(i + 2) % ans_size] != 0) {           if (ans[i] < ans[i + 1]) {             erased.erase({ans[i], ans[i + 1]});           } else {             erased.erase({ans[i + 1], ans[i]});           }         }       }     }   }   int main() {     scanf( %d%d , &n, &m);     G.resize(n + 1);     while (m--) {       scanf( %d%d , &v1, &v2);       G[v1].insert(v2);       G[v2].insert(v1);       if (v1 < v2) {         erased.insert({v1, v2});       } else {         erased.insert({v2, v1});       }       Deg[v1]++;       Deg[v2]++;     }     for (int i = 1; i <= n; i++) {       if (!visited[i]) {         assert(G[0].empty());         C.clear();         find_component(i);         if (((int)(C).size()) == 1) {           continue;         }         for (int v : C) {           if (Deg[v] % 2 == 1) {             G[0].insert(v);             G[v].insert(0);           }         }         eulerian_cycle(C.front());       }     }     printf( %d n , ((int)(erased).size()));     for (pair<int, int> p : erased) {       printf( %d %d n , p.first, p.second);     }     return 0;   }


#include <bits/stdc++.h>   #pragma GCC optmize( Ofast )   using namespace std;   const int maxn = 20009;   const int inf = 1e8;   int n, m, K, T;   int e[1 << 10][maxn << 1];   int head[maxn], cntedge = 1;   int from[maxn], to[maxn], cap[maxn], flow[maxn], nex[maxn];   void Addedge(int x, int y, int z) {     nex[++cntedge] = head[x];     from[cntedge] = x;     to[cntedge] = y;     cap[cntedge] = z;     flow[cntedge] = 0;     head[x] = cntedge;   }   int cur[maxn];   int d[maxn];   int vis[maxn];   int q[maxn], r;   int Bfs() {     for (int i = 1; i <= n; ++i) vis[i] = 0;     vis[1] = 1;     d[1] = 0;     q[r = 1] = 1;     for (int l = 1; l <= r; ++l) {       int x = q[l];       for (int i = head[x]; i; i = nex[i]) {         int v = to[i];         if ((cap[i] > flow[i]) && (!vis[v])) {           vis[v] = 1;           d[v] = d[x] + 1;           q[++r] = v;         }       }     }     return vis[n];   }   int Dfs(int x, int a) {     if ((x == n) || (a == 0)) return a;     int nowflow = 0, f = 0;     for (int i = cur[x]; i; i = nex[i]) {       cur[x] = i;       int v = to[i];       if (d[x] + 1 == d[v]) {         f = Dfs(v, min(a, cap[i] - flow[i]));         nowflow += f;         a -= f;         flow[i] += f;         flow[i ^ 1] -= f;         if (a == 0) break;       }     }     return nowflow;   }   int p[maxn], pf[maxn] = {0, 1000000};   int augment() {     for (int i = 1; i <= n; ++i) vis[i] = 0;     q[r = 1] = 1;     int flag = 0;     for (int l = 1; l <= r; ++l) {       int x = q[l];       for (int i = head[x]; i; i = nex[i]) {         int v = to[i];         if ((cap[i] > flow[i]) && (!vis[v])) {           vis[v] = 1;           p[v] = i;           q[++r] = v;           pf[v] = min(pf[x], cap[i] - flow[i]);           if (v == n) {             flag = 1;             break;           }         }       }       if (flag) break;     }     if (!vis[n]) return 0;     int f = pf[n], x = n;     while (x != 1) {       flow[p[x]] += f;       flow[p[x] ^ 1] -= f;       x = from[p[x]];     }     return f;   }   int Maxflow() {     int flow = 0;     while (Bfs()) {       for (int i = 1; i <= n; ++i) cur[i] = head[i];       flow += Dfs(1, inf);     }     return flow;   }   int f[1024];   int sum[1 << 10];   int lg2[1 << 11];   int w[maxn];   int read() {     int r = 0, k = 1;     char c = getchar();     for (; c <  0  || c >  9 ; c = getchar())       if (c ==  - ) k = -1;     for (; c >=  0  && c <=  9 ; c = getchar()) r = r * 10 + c -  0 ;     return r * k;   }   int main() {     scanf( %d%d%d%d , &n, &m, &K, &T);     for (int i = 1; i <= m; ++i) {       int x, y, z;       scanf( %d%d%d , &x, &y, &z);       Addedge(x, y, z);       Addedge(y, x, 0);     }     f[0] = Maxflow();     for (int i = 2; i <= cntedge; ++i) e[0][i] = flow[i];     for (int s = 1; s < (1 << K); ++s) {       for (int i = 1; i <= K; ++i) {         if (s & (1 << (i - 1))) {           cap[i << 1] = 25;         } else {           cap[i << 1] = 0;         }       }       int pre = s ^ (s & (-s));       for (int i = 2; i <= cntedge; ++i) flow[i] = e[pre][i];       f[s] = f[pre];       int tmp;       while (tmp = augment()) f[s] += tmp;       for (int i = 2; i <= cntedge; ++i) e[s][i] = flow[i];     }     for (int s = 0; s < (1 << K); ++s) {       int t = (~s) & ((1 << K) - 1);       if (t < s) swap(f[s], f[t]);     }     for (int i = 1; i <= 10; ++i) lg2[1 << i] = i;     while (T--) {       for (int i = 1; i <= K; ++i) w[i] = read();       int ans = f[0];       for (int s = 1; s < (1 << K); ++s) {         int l = s & (-s);         sum[s] = sum[s ^ l] + w[lg2[l] + 1];         ans = min(ans, sum[s] + f[s]);       }       printf( %d n , ans);     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   void desperate_optimization(int precision) {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cout.setf(ios::fixed);     cout.setf(ios::showpoint);     cout.precision(precision);   }   const int N = 2e5;   int arr[N + 5];   int pre[N + 5];   int mark[N + 5];   vector<int> lis;   void hora(int tc) {     int n;     cin >> n;     for (int i = 0; i < n; i++) {       cin >> arr[i];       mark[i] = 1;       if (lis.size() == 0 || arr[lis.back()] < arr[i]) {         pre[i] = -1;         if (lis.size() != 0) pre[i] = lis.back();         lis.push_back(i);       } else {         int lo = 0;         int hi = lis.size() - 1;         int res = -1;         while (lo <= hi) {           int mid = (lo + hi) / 2;           if (arr[lis[mid]] >= arr[i]) {             res = mid;             hi = mid - 1;           } else             lo = mid + 1;         }         lis[res] = i;         pre[i] = -1;         if (res != 0) pre[i] = lis[res - 1];       }     }     int tmp = lis.back();     for (int i = 0; i < n; i++) {       if (pre[tmp] == pre[i] && arr[tmp] < arr[i]) tmp = i;     }     while (tmp != -1) {       mark[tmp] = 0;       tmp = pre[tmp];     }     int hi = 1e9;     int lo = -1;     bool ada = true;     for (int i = 0; i < n; i++) {       if (mark[i] == 0) {         if (lo >= arr[i]) ada = false;         lo = arr[i];       } else {         if (hi <= arr[i]) ada = false;         hi = arr[i];       }     }     if (ada == false) {       lis.clear();       for (int i = 0; i < n; i++) {         mark[i] = 0;         if (lis.size() == 0 || arr[lis.back()] > arr[i]) {           pre[i] = -1;           if (lis.size() != 0) pre[i] = lis.back();           lis.push_back(i);         } else {           int lo = 0;           int hi = lis.size() - 1;           int res = -1;           while (lo <= hi) {             int mid = (lo + hi) / 2;             if (arr[lis[mid]] <= arr[i]) {               res = mid;               hi = mid - 1;             } else               lo = mid + 1;           }           lis[res] = i;           pre[i] = -1;           if (res != 0) pre[i] = lis[res - 1];         }       }       int tmp = lis.back();       for (int i = 0; i < n; i++) {         if (pre[tmp] == pre[i] && arr[tmp] > arr[i]) tmp = i;       }       while (tmp != -1) {         mark[tmp] = 1;         tmp = pre[tmp];       }       int hi = 1e9;       int lo = -1;       bool ada = true;       for (int i = 0; i < n; i++) {         if (mark[i] == 0) {           if (lo >= arr[i]) ada = false;           lo = arr[i];         } else {           if (hi <= arr[i]) ada = false;           hi = arr[i];         }       }       if (ada == false)         cout <<  NO  <<   n ;       else {         cout <<  YES  <<   n ;         for (int i = 0; i < n; i++) cout << mark[i] <<    ;         cout <<   n ;       }     } else {       cout <<  YES  <<   n ;       for (int i = 0; i < n; i++) cout << mark[i] <<    ;       cout <<   n ;     }   }   int main() {     desperate_optimization(10);     int ntc = 1;     for (int tc = 1; tc <= ntc; tc++) hora(tc);     return 0;   }


#include <bits/stdc++.h>   using namespace std;   template <typename T>   string to_str(T str) {     stringstream stream;     stream << str;     return stream.str();   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long n, d, e;     long long result = 1000000000;     cin >> n >> d >> e;     while (n >= 0) {       result = min(n % (5 * e), result);       n = n - d;     }     cout << result << endl;     return 0;     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);   }


#include <bits/stdc++.h>   using namespace std;   bool debug = 1;   int n, m, k;   int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};   long long ln, lk, lm;   int a[100005];   int main() {     scanf( %d , &n);     for (int(i) = 0; (i) < (int)(n); (i)++) {       scanf( %d , a + i);     }     sort(a, a + n);     vector<int> vp;     for (int i = n - 1; i >= 1;) {       if (a[i] == a[i - 1] || a[i] - 1 == a[i - 1]) {         vp.push_back(a[i - 1]);         i -= 2;       } else         i--;     }     long long ans = 0;     for (int i = 0; i + 1 < vp.size(); i += 2) {       ans += (long long)vp[i] * vp[i + 1];     }     printf( %lld n , ans);   }


#include <bits/stdc++.h>   using namespace std;   uint64_t rnd_data = 0xDEADBEEFDULL;   inline void my_srand(int seed) { rnd_data = ((uint64_t)seed << 16) | 0x330E; }   inline int my_rand() {     rnd_data = rnd_data * 0x5DEECE66DULL + 0xB;     return (rnd_data >> 17) & 0x7FFFFFFF;   }   template <typename T>   void my_random_shuffle(T b, T e) {     for (int i = (1); i <= (int)((int)(e - b) - 1); i++) {       swap(b[i], b[my_rand() % (i + 1)]);     }   }   template <class _T>   inline _T sqr(const _T &x) {     return x * x;   }   template <typename type_t, typename less_t = std::less<type_t>>   inline bool uin(type_t &a, const type_t &b, const less_t &ls = less_t()) {     return ls(b, a) ? a = b, true : false;   }   template <typename type_t, typename less_t = std::less<type_t>>   inline bool uax(type_t &a, const type_t &b, const less_t &ls = less_t()) {     return ls(a, b) ? a = b, true : false;   }   const long double PI = 3.1415926535897932384626433832795L;   const long double EPS = 1e-9;   const int MAXN = 1 << 17;   int n, k;   int a[MAXN];   bool g[MAXN];   int d[MAXN * 2][2][2];   int main() {     scanf( %d%d , &n, &k);     memset((g), 0, sizeof(g));     for (int i = 0; i < (int)(k); i++) {       scanf( %d , &a[i]);       g[a[i] - 1] = true;     }     memset(d, 0x80, sizeof(d));     int z = 1 << (n - 1);     for (int i = 0; i < (int)(z); i++) {       int x = i << 1;       int y = x + 1;       d[z + i][g[x]][g[y]] = g[x] || g[y];       d[z + i][g[y]][g[x]] = g[x] || g[y];     }     for (int i = (z - 1); i >= (int)(1); i--) {       int x = i * 2;       int y = x + 1;       for (int xw = 0; xw < (int)(2); xw++) {         for (int xl = 0; xl < (int)(2); xl++) {           if (d[x][xw][xl] < 0) continue;           for (int yw = 0; yw < (int)(2); yw++) {             for (int yl = 0; yl < (int)(2); yl++) {               if (d[y][yw][yl] < 0) continue;               int gw[2] = {xw, yw};               bool ggl = xl || yl;               for (int t = 0; t < (int)(2); t++) {                 int cur = (xw || yw) + ggl;                 int nw = gw[t];                 int nl0 = gw[t ^ 1];                 int nl = nl0 || ggl;                 cur += nl;                 uax(d[i][nw][nl], d[x][xw][xl] + d[y][yw][yl] + cur);               }             }           }         }       }     }     int ans = 0;     for (int i = 0; i < (int)(2); i++) {       for (int j = 0; j < (int)(2); j++) {         int add = (i || j);         uax(ans, d[1][i][j] + add);       }     }     printf( %d n , ans);     return 0;   }


#include<bits/stdc++.h>   #define FOR(i,l,r) for(int i=l;i<=r;i++)   #define ROF(i,l,r) for(int i=l;i>=r;i--)   #define lson k<<1,l,mid   #define rson k<<1|1,mid+1,r   #define r(x) read(x)   #define rr(x,y) read(x);read(y)   #define rrr(x,y,z) read(x);read(y);read(z)   #define pb(x) push_back(x)   #define mp(x,y) make_pair(x,y)   #define fi first   #define se second   #define sss(str) scanf( %s ,str+1)   using namespace std;   typedef long long LL;   typedef pair<int,int> pt;   const int N=1e6+5;   const int M=2e3+5;   const int mod=1e9+7;   const int INF=2e9;   const double eps=1e-8;   const double pi=acos(-1);   template <class T>   inline void read(T &x) {       char c;x = 1;       while ((c = getchar()) <  0  || c >  9 ) if (c ==  - ) x = -1;       T res = c -  0 ;       while ((c = getchar()) >=  0  && c <=  9 ) res = res * 10 + c -  0 ;       x *= res;   }   int n,m;   char str[N];   int f[N];   void solve(int cas)   {       r(n);       int cnt1=n/2,cnt2=n-cnt1;       LL ans=0;       set<pt> s;       for(int i=cnt1;i>=-cnt1;i-=2){           for(int j=cnt2;j>=-cnt2;j-=2){               s.insert(mp(i,j));               s.insert(mp(j,i));           }       }       cout<<s.size()<<endl;   }   int main()   {       int t;   //    r(t);       t=1;   //    init();       FOR(i,1,t){           solve(i);       }       return 0;   }


#include <bits/stdc++.h>   using namespace std;   template <class T>   T gcd(T a, T b) {     return (b != 0 ? gcd<T>(b, a % b) : a);   }   template <class T>   T lcm(T a, T b) {     return (a / gcd<T>(a, b) * b);   }   long long pwr(long long base, long long p) {     long long ans = 1;     while (p) {       if (p & 1) ans = (ans * base) % (1000000007LL);       base = (base * base) % (1000000007LL);       p >>= 1;     }     return ans;   }   long long modInv(long long n, long long mod) { return pwr(n, mod - 2); }   int bitCount(int n) {     int c = 0;     while (n) {       c++;       n &= n - 1;     }     return c;   }   int main() {     double n, m, cost;     ;     int i, a, b;     cin >> n >> m;     int ver[100000];     for (i = 1; i < n + 1; i++) {       scanf( %d , &ver[i]);     }     double ans = 0;     for (i = 0; i < m; i++) {       cin >> a >> b >> cost;       ans = max(ans, (ver[a] + ver[b]) / cost);     }     printf( %.12lf n , ans);     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int Inf = (1 << 30) - 1;   const long long lInf = (1LL << 62) - 1;   const long long Mod = 1000000007;   long long fac[1000010];   long long inv[1000010];   long long powm[1000010];   long long pown[1000010];   int a, b;   long long n, m;   long long fpow(long long a, long long b, long long Mod) {     a %= Mod;     b %= Mod;     long long mul = 1;     while (b) {       if (b & 1) (mul *= a) %= Mod;       (a *= a) %= Mod;       b >>= 1;     }     return mul;   }   void init() {     int tmp = max(n, m);     fac[0] = fac[1] = 1;     for (int i = 2; i <= tmp; ++i) fac[i] = fac[i - 1] * i % Mod;     inv[tmp] = fpow(fac[tmp], Mod - 2, Mod);     for (int i = tmp; i >= 1; --i) inv[i - 1] = inv[i] * i % Mod;     powm[0] = pown[0] = 1;     for (int i = 1; i <= tmp; ++i)       powm[i] = powm[i - 1] * m % Mod, pown[i] = pown[i - 1] * n % Mod;   }   long long A(int x, int y) {     if (x - y < 0 || x < 0) return 0;     return fac[x] * inv[x - y] % Mod;   }   long long C(int x, int y) {     if (x - y < 0 || x < 0 || y < 0) return 0;     return fac[x] * inv[y] % Mod * inv[x - y] % Mod;   }   int main() {     ios::sync_with_stdio(false);     cin >> n >> m >> a >> b;     init();     long long ans = 0;     for (long long i = 1; i <= n - 1; ++i) {       long long mul =           A(n - 2, i - 1) * C(m - 1, i - 1) % Mod * powm[n - i - 1] % Mod;       if (n - i - 2 >= 0) (mul *= (i + 1) * pown[n - i - 2] % Mod) %= Mod;       (ans += mul) %= Mod;     }     cout << ans << endl;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int n;   long long A, B;   struct node {     long long vx, vy, w;   } p[400005];   bool cmp(const node p1, const node p2) {     if (p1.w == p2.w) return p1.vx < p2.vx;     return p1.w < p2.w;   }   int main() {     scanf( %d%I64d%I64d , &n, &A, &B);     int i, j;     long long gg;     for (i = 1; i <= n; i++) scanf( %I64d%I64d%I64d , &gg, &p[i].vx, &p[i].vy);     long long ans = 0;     for (i = 1; i <= n; i++) {       p[i].w = p[i].vy - p[i].vx * A;     }     sort(p + 1, p + n + 1, cmp);     for (i = 1; i <= n; i++) {       j = i;       while (j + 1 <= n && p[j + 1].w == p[i].w) j = j + 1;       long long num = j - i + 1;       int k;       for (int t = i; t <= j; t++) {         k = t;         while (k + 1 <= j && p[k + 1].vx == p[t].vx) k = k + 1;         long long siz = k - t + 1;         ans += siz * (num - siz);         t = k;       }       i = j;     }     printf( %I64d , ans);     return 0;   }


#include <bits/stdc++.h>   using namespace std;   void solve() {     string S;     cin >> S;     int M;     cin >> M;     for (int i = 0; i < M; i++) {       int l, r, k;       cin >> l >> r >> k;       l--;       rotate(S.begin() + l, S.begin() + r - k % (r - l), S.begin() + r);     }     cout << S <<   n ;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int t = 1;     while (t--) solve();     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     int t, n;     cin >> t;     while (t--) {       cin >> n;       int a[n];       for (int i = 0; i < n; i++) {         cin >> a[i];       }       sort(a, a + n);       int flag = 0;       for (int i = 0; i < n - 1; i++) {         if ((a[i + 1] - a[i]) > 1 || (a[i + 1] - a[i]) < -1) {           flag = 1;         }       }       if (flag == 1) {         cout <<  NO               <<   n ;       } else {         cout <<  YES               <<   n ;       }     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long n, m;     cin >> n >> m;     if (m % 2 == 1) {       bool f = true;       long ptr = (m + 1) / 2;       long p1 = ptr - 1, p2 = ptr;       for (long i = 1; i <= n; i++) {         if (f && p2 <= m) {           cout << p2 <<   n ;           p2++;           f = false;         } else if (p1 >= 1) {           cout << p1 <<   n ;           p1--;           f = true;         } else {           i--;           f = !f;           p1 = ptr - 1;           p2 = ptr;         }       }     } else {       bool f = true;       long ptr = (m + 1) / 2;       if (n >= 2)         cout << ptr <<   n  << ptr + 1 <<   n ;       else         cout << ptr;       long p1 = ptr - 1;       long p2 = ptr + 2;       for (long i = 3; i <= n; i++) {         if (f && p1 >= 1) {           cout << p1 <<   n ;           p1--;           f = false;         } else if (p2 <= m) {           cout << p2 <<   n ;           p2++;           f = true;         } else {           i++;           if (i < n)             cout << ptr <<   n  << ptr + 1 <<   n ;           else             cout << ptr <<   n ;           p1 = ptr - 1;           p2 = ptr + 2;         }       }     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   map<long long, long long> mp;   string s;   long long n, m, k, ans;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     srand(time(0));     cin >> n;     vector<long long> a(n + 1, 0);     for (long long i = 1; i <= n; ++i) cin >> a[i];     for (long long i = n; i >= 1; --i)       if (a[i] && !m)         m = i;       else if (!a[i] && !k)         k = i;     cout << min(m, k);   }


#include <bits/stdc++.h>   using namespace std;   int prime[1000005];   int ans[5];   int idx;   set<int> s, s1;   set<int>::iterator it;   int main() {     int i, j;     for (i = 2; i <= 1000000; i++) {       if (prime[i] == 1) continue;       for (j = i + i; j <= 1000000; j += i) prime[j] = 1;     }     int n;     scanf( %d , &n);     if (n == 1)       printf( 1 n );     else if (n == 2)       printf( 2 n );     else {       long long sum = n;       for (i = 2; i < n; i++) {         if (n % i == 0) s.insert(i);       }       int countt = 0;       for (i = n - 1; i >= 1; i--) {         bool no = 0;         for (it = s.begin(); it != s.end(); it++) {           if (i % (*it) == 0) {             no = 1;             break;           }         }         if (!no) {           sum *= (long long)i;           countt++;         }         if (countt == 2) break;       }       long long sum1 = n - 1;       for (i = 2; i < n - 1; i++) {         if ((n - 1) % i == 0) s1.insert(i);       }       countt = 0;       for (i = n - 2; i >= 1; i--) {         bool no = 0;         for (it = s1.begin(); it != s1.end(); it++) {           if (i % (*it) == 0) {             no = 1;             break;           }         }         if (!no) {           sum1 *= (long long)i;           countt++;         }         if (countt == 2) break;       }       printf( %I64d n , max(sum, sum1));     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 10;   pair<int, int> a[N];   int main() {     int n;     cin >> n;     int mn = 1e9, mx = -1e9;     for (int i = 0; i < n; ++i) {       cin >> a[i].first >> a[i].second;       mn = min(mn, a[i].first);       mx = max(mx, a[i].second);     }     int ans = -1;     for (int i = 0; i < n; ++i) {       if (a[i].first <= mn && a[i].second >= mx) {         ans = i + 1;         break;       }     }     cout << ans << endl;   }


#include <bits/stdc++.h>   using namespace std;   int dp[101][101][28];   vector<pair<int, int> > graph[101];   int fun(int x, int y, int val) {     if (dp[x][y][val] != -1) return dp[x][y][val];     for (int i = 0; i < graph[x].size(); i++) {       if (graph[x][i].second >= val) {         bool mark = true;         for (int j = 0; j < graph[y].size(); j++) {           if (graph[y][j].second >= graph[x][i].second) {             if (fun(graph[x][i].first, graph[y][j].first, graph[y][j].second) ==                 0) {               mark = false;               break;             }           }         }         if (mark == true) {           dp[x][y][val] = 1;           return 1;         }       }     }     dp[x][y][val] = 0;     return 0;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(NULL);     int n, m;     cin >> n >> m;     for (int i = 0; i < m; i++) {       int x, y;       char d;       cin >> x >> y >> d;       graph[x - 1].push_back(make_pair(y - 1, d - 96));     }     memset(dp, -1, sizeof(dp));     for (int i = 0; i < n; i++) {       for (int j = 0; j < n; j++) {         if (fun(i, j, 0))           cout <<  A ;         else           cout <<  B ;       }       cout <<   n ;     }   }


#include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 10;   int n, m;   int volume[N];   int amount[N];   int parent[N];   int tofill[N];   int weight[N];   std::set<int> notFull;   void reducePath(int index, int lead) {     while (parent[index] != index) {       int oldParent = parent[index];       parent[index] = lead;       index = oldParent;     }   }   int find(int index) {     int lead = index;     while (parent[lead] != lead) {       lead = parent[lead];     }     reducePath(index, lead);     return lead;   }   bool merge(int l, int r) {     int ll = find(l);     int rl = find(r);     if (ll == rl) {       return false;     }     if (weight[ll] < weight[rl]) swap(ll, rl);     parent[rl] = ll;     weight[ll] += weight[rl];     if (tofill[ll] < tofill[rl]) tofill[ll] = tofill[rl];     return true;   }   void fill(int p, int x) {     while (x > 0) {       int lead = find(p);       int f = tofill[lead];       int remainingVolume = volume[f] - amount[f];       int fillAmount = std::min(remainingVolume, x);       amount[f] += fillAmount;       x -= fillAmount;       if (amount[f] == volume[f]) {         if (f == n - 1)           break;         else           ++f;         merge(lead, f);       }     }   }   void fill2(int p, int x) {     auto lb = notFull.lower_bound(p);     while (x > 0 && lb != notFull.end()) {       int remainingVolume = volume[*lb] - amount[*lb];       int fillAmount = std::min(remainingVolume, x);       amount[*lb] += fillAmount;       x -= fillAmount;       if (amount[*lb] == volume[*lb])         lb = notFull.erase(lb);       else         lb++;     }   }   void init() {     for (int i = 0; i < n; ++i) {       parent[i] = i;       tofill[i] = i;       weight[i] = 1;       notFull.insert(i);     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     cin >> n;     for (int i = 0; i < n; ++i) {       cin >> volume[i];     }     init();     cin >> m;     for (int i = 0; i < m; ++i) {       int q;       cin >> q;       if (q == 1) {         int p, x;         cin >> p >> x;         fill2(--p, x);       } else {         int k;         cin >> k;         cout << amount[--k] <<   n ;       }     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     scanf( %d %d , &n, &m);     vector<int> v(n + 1);     for (int i = 1; i <= n; i++) scanf( %d , &v[i]);     double ans = 0.0;     int a, b, w;     for (int i = 1; i <= m; i++) {       scanf( %d %d %d , &a, &b, &w);       ans = max(ans, 1.0 * (v[a] + v[b]) / w);     }     printf( %0.9lf n , ans);     return 0;   }


#include <bits/stdc++.h>   const int max_n = 150;   const unsigned int lowest = 31;   const int size = (max_n >> 5) + 1;   struct row {     unsigned int bits[size];     void set_bit(unsigned int j) { bits[j >> 5] |= (1 << (j & lowest)); }     bool get_bit(unsigned int j) {       return ((bits[j >> 5] >> (j & lowest)) & 1) == 1;     }     bool is_zero() {       for (int i = 0; i < size; ++i)         if (bits[i]) return false;       return true;     }   };   row operator&(row a, row b) {     row c;     for (int i = 0; i < size; ++i) c.bits[i] = a.bits[i] & b.bits[i];     return c;   }   row operator|(row a, row b) {     row c;     for (int i = 0; i < size; ++i) c.bits[i] = a.bits[i] | b.bits[i];     return c;   }   row operator~(row a) {     row c;     for (int i = 0; i < size; ++i) c.bits[i] = ~a.bits[i];     return c;   }   row left(row a) {     for (int i = 0; i < size - 1; ++i) {       a.bits[i] >>= 1;       if (a.bits[i + 1] & 1) a.bits[i] |= (1 << lowest);     }     a.bits[size - 1] >>= 1;     return a;   }   row right(row a) {     for (int i = size - 1; i > 0; --i) {       a.bits[i] <<= 1;       if (a.bits[i - 1] & (1 << lowest)) a.bits[i] |= 1;     }     a.bits[0] <<= 1;     return a;   }   int ei, ej, n, m, k;   row table[max_n], where[max_n];   bool check() {     for (int i = 0; i < n; ++i)       if ((i != ei) && !where[i].is_zero()) return false;     for (int j = 0; j < m; ++j)       if ((j != ej) && where[ei].get_bit(j)) return false;     return true;   }   int main() {     memset(table, 0, sizeof(table));     memset(where, 0, sizeof(where));     scanf( %d%d%d n , &n, &m, &k);     for (int i = 0; i < n; ++i) {       for (int j = 0; j < m; ++j) {         char c;         scanf( %c , &c);         if (c ==  E ) ei = i, ej = j, c =  . ;         if (c ==  . ) table[i].set_bit(j), where[i].set_bit(j);       }       scanf(  n );     }     if (check()) {       printf( 0 n );       return 0;     }     for (int i = 1; i <= k; ++i) {       char c;       scanf( %c , &c);       switch (c) {         case  L :           for (int r = 1; r <= n - 2; ++r)             where[r] =                 (left(where[r]) & table[r]) | (where[r] & ~right(table[r]));           break;         case  R :           for (int r = 1; r <= n - 2; ++r)             where[r] =                 (right(where[r]) & table[r]) | (where[r] & ~left(table[r]));           break;         case  D :           for (int r = n - 2; r >= 1; --r)             where[r] = (where[r - 1] & table[r]) | (where[r] & ~table[r + 1]);           break;         case  U :           for (int r = 1; r <= n - 2; ++r)             where[r] = (where[r + 1] & table[r]) | (where[r] & ~table[r - 1]);           break;       }       if (check()) {         printf( %d n , i);         return 0;       }     }     printf( -1 n );     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int n, m, k;   vector<pair<int, int> > g[1001];   int obtenpadre(int u, int padre[1001]) {     if (padre[u] == 0) return u;     padre[u] = obtenpadre(padre[u], padre);     return padre[u];   }   void unir(int u, int v, int padre[1001], int llaves[1001][1001]) {     padre[v] = u;     for (int i = 1; i <= m; i++)       if (llaves[v][i]) llaves[u][i] = 1;   }   void ejecuta(int padre[1001], int llaves[1001][1001]) {     bool cambios = true;     while (cambios) {       cambios = false;       for (int u = 1; u <= n; u++) {         vector<pair<int, int> > &ar = g[u];         for (int i = 0; i < int(ar.size()); i++) {           int v = ar[i].first;           int l = ar[i].second;           int pu = obtenpadre(u, padre);           int pv = obtenpadre(v, padre);           if (pu != pv and (llaves[pu][l] or llaves[pv][l])) {             unir(pu, pv, padre, llaves);             cambios = true;           }         }       }     }   }   map<string, int> posini[2];   int padre[2][1001];   int llaves[2][1001][1001];   int visto[2][1001];   int main() {     cin >> n >> m >> k;     for (int i = 1; i <= m; i++) {       int u, v;       cin >> u >> v;       g[u].push_back(pair<int, int>(v, i));       g[v].push_back(pair<int, int>(u, i));     }     for (int p = 0; p < 2; p++) {       for (int i = 1; i <= k; i++) {         string s;         int h, amount;         cin >> s >> h >> amount;         posini[p][s] = h;         for (int j = 0; j < amount; j++) {           int x;           cin >> x;           llaves[p][h][x] = 1;         }       }       ejecuta(padre[p], llaves[p]);     }     for (map<string, int>::iterator it = posini[0].begin(); it != posini[0].end();          it++) {       string s = it->first;       int h0 = it->second;       int h1 = posini[1][s];       if (obtenpadre(h0, padre[0]) != obtenpadre(h1, padre[0])) {         cout <<  NO  << endl;         exit(0);       }     }     for (int u = 1; u <= n; u++) {       int h0 = obtenpadre(u, padre[0]);       int h1 = obtenpadre(u, padre[1]);       if (visto[0][h0] != visto[1][h1]) {         cout <<  NO  << endl;         exit(0);       }       if (visto[0][h0] == 0) {         visto[0][h0] = visto[1][h1] = 1;         for (int j = 1; j <= m; j++) {           if (llaves[0][h0][j] != llaves[1][h1][j]) {             cout <<  NO  << endl;             exit(0);           }         }       }     }     cout <<  YES  << endl;   }


#include <bits/stdc++.h>   const int inf = 0x3f3f3f3f;   const long long int INF = 0x3f3f3f3f3f3f3f3f;   using namespace std;   inline void INP() {}   long long int n, m;   vector<pair<long long int, long long int> > v;   void solve() {     cin >> n >> m;     long long int mn = INF;     long long int mx = 0;     for (long long int i = 0; i < m; i++) {       long long int x, y;       cin >> x >> y;       v.push_back({-1 * y, x});       mn = min(mn, y);       mx = max(mx, y);     }     sort(begin(v), end(v));     long long int ans = 0;     for (long long int i = 0; i < m; i++) {       if (v[i].second <= n) {         ans += (-1 * v[i].first) * v[i].second;         n -= v[i].second;       } else {         ans += (-1 * v[i].first) * n;         n = 0;       }       if (n == 0) break;     }     cout << ans <<   n ;   }   int32_t main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int t = 1;     while (t--) {       solve();     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int N = 100005;   long long int ara[N];   int main() {     long long int n, i, j, k, s = 0, ts;     cin >> n;     for (i = 1; i <= n; i++) cin >> ara[i];     for (i = 1; i < n; i++) {       for (j = 30; ara[i] > 0 && j >= 0; j--) {         if ((i + (1 << j)) > n) continue;         s += ara[i];         ara[(i + (1 << j))] += ara[i];         ara[i] = 0;       }       cout << s <<   n ;     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int cha[1000100];   int num[1000100];   int a[5010];   int limit[] = {0, 1, 3, 6, 10};   int n, k;   int che[1000100];   bool check(int mod) {     int bad = 0;     int mostI = -1;     for (int i = 0; i < n; i++) {       int t = a[i] % mod;       che[t]++;       if (che[t] > 1) bad++;       if (bad > k) {         mostI = i;         break;       }     }     for (int i = 0; i <= mostI; i++) {       int t = a[i] % mod;       che[t]--;     }     return (bad <= k);   }   int main() {     scanf( %d%d , &n, &k);     for (int i = 0; i < n; i++) scanf( %d , &a[i]);     sort(a, a + n);     for (int i = 0; i <= a[n - 1]; i++) cha[i] = 0;     int maxn = a[n - 1] - a[0];     for (int i = 0; i <= maxn; i++) che[i] = 0;     for (int i = 0; i <= maxn; i++) num[i] = 0;     for (int i = 0; i < n - 1; i++)       for (int j = i + 1; j < n; j++) {         int cc = a[j] - a[i];         num[cc]++;       }     if (n - k == 1) {       printf( 1 n );       return 0;     }     for (int i = 1;; i++) {       int ans = 0;       for (int j = i; j <= maxn; j += i) {         ans += num[j];         if (ans > k) break;       }       if (ans <= limit[k] && check(i)) {         printf( %d n , i);         break;       }     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   #pragma comment(linker,  /STACK:16777216 )   const char DEBUG = 0;   mt19937 gen(chrono::high_resolution_clock::now().time_since_epoch().count());   struct pp {     int pos, id;   };   long long pos[200000];   int type[200000];   int res[100000];   vector<int> arr;   int get_id1(int x) {     int l = 0, r = arr.size();     while (r - l > 1) {       int m = (l + r) / 2;       if (arr[m] >= x)         r = m;       else         l = m;     }     return l;   }   int get_id2(int x) {     int l = -1, r = arr.size() - 1;     while (r - l > 1) {       int m = (l + r) / 2;       if (arr[m] <= x)         l = m;       else         r = m;     }     return r;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cin.sync_with_stdio(0);     cout.tie(0);     cout.sync_with_stdio(0);     int n, m;     cin >> n >> m;     for (int i = 0; i < n + m; i++) cin >> pos[i];     for (int i = 0; i < n + m; i++) cin >> type[i];     for (int i = 0; i < n + m; i++)       if (type[i]) arr.push_back(pos[i]);     for (int i = 0; i < n + m; i++) {       if (type[i]) continue;       long long d1 = 1000000000000000000LL, d2 = 1000000000000000000LL;       int p1 = get_id1(pos[i]);       int p2 = get_id2(pos[i]);       d1 = abs(arr[p1] - pos[i]);       d2 = abs(arr[p2] - pos[i]);       if (d1 < d2)         res[p1]++;       else if (d2 < d1)         res[p2]++;       else {         if (arr[p1] < arr[p2])           res[p1]++;         else           res[p2]++;       }     }     for (int i = 0; i < m; i++) cout << res[i] <<    ;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int base1 = 115019, mod1 = 1e9 + 13;   vector<int> pos[100005];   int n, t[100005], a[100005];   long long p1[100005], sum1[100005];   struct node {     int st, len;     bool operator<(const node &A) const {       if (len == A.len) return st < A.st;       return len < A.len;     }   };   vector<node> S;   bool check(int x, int y) {     if (y + (y - x) - 1 > n) return false;     long long sx1 =         ((sum1[y - 1] - sum1[x - 1] * p1[y - x]) % mod1 + mod1) % mod1;     long long sy1 =         ((sum1[y + y - x - 1] - sum1[y - 1] * p1[y - x]) % mod1 + mod1) % mod1;     return sx1 == sy1;   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; ++i) scanf( %d , &a[i]), t[i] = a[i];     sort(t + 1, t + n + 1);     int m = unique(t + 1, t + n + 1) - t - 1;     p1[0] = 1;     for (int i = 1; i <= n; ++i) {       a[i] = lower_bound(t + 1, t + m + 1, a[i]) - t;       pos[a[i]].push_back(i);       p1[i] = p1[i - 1] * base1 % mod1;       sum1[i] = (sum1[i - 1] * base1 + a[i]) % mod1;     }     for (int i = 1; i <= m; ++i)       for (int j = 0; j < pos[i].size(); ++j)         for (int k = j + 1; k < pos[i].size(); ++k) {           int x = pos[i][j], y = pos[i][k];           if (check(x, y)) S.push_back((node){x, y - x});         }     sort(S.begin(), S.end());     int now = 1;     for (int i = 0; i < S.size(); ++i) {       node p = S[i];       if (p.st < now)         continue;       else         now = p.st + p.len;     }     printf( %d n , n - now + 1);     for (int i = now; i <= n; ++i) printf( %d  , t[a[i]]);     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     int n, p;     string s, number;     cin >> n;     string name[n];     int taxi[n], pizza[n], cg[n], tax, pizz, cgc, taxmax = -1, pizzmax = -1,                                                   cgcmax = -1;     int taxifinal[n], pizzafinal[n], cgcfinal[n], ct = 0, cp = 0, cc = 0;     for (int i = 0; i < n; i++) {       cin >> p >> name[i];       tax = 0;       pizz = 0;       cgc = 0;       for (int j = 0; j < p; j++) {         cin >> number;         if (((number[0] == number[3]) && (number[3] == number[6])) &&             ((number[0] == number[1]) && (number[3] == number[4]) &&              (number[6] == number[7]))) {           tax++;         } else if ((int(number[0]) > int(number[1])) &&                    (int(number[1]) > int(number[3])) &&                    (int(number[3]) > int(number[4])) &&                    (int(number[4]) > int(number[6])) &&                    (int(number[6]) > int(number[7]))) {           pizz++;         } else {           cgc++;         }       }       taxi[i] = tax;       pizza[i] = pizz;       cg[i] = cgc;     }     for (int i = 0; i < n; i++) {       taxmax = max(taxmax, taxi[i]);       pizzmax = max(pizzmax, pizza[i]);       cgcmax = max(cgcmax, cg[i]);     }     for (int i = 0; i < n; i++) {       if (taxmax == taxi[i]) {         taxifinal[ct] = i;         ct++;       }       if (pizzmax == pizza[i]) {         pizzafinal[cp] = i;         cp++;       }       if (cgcmax == cg[i]) {         cgcfinal[cc] = i;         cc++;       }     }     cout <<  If you want to call a taxi, you should call: ;     if (ct > 1) {       for (int j = 0; j < ct - 1; j++) {         cout <<     << name[taxifinal[j]] <<  , ;       }       cout <<     << name[taxifinal[ct - 1]] <<  .  << endl;     } else {       cout <<     << name[taxifinal[ct - 1]] <<  .  << endl;     }     cout <<  If you want to order a pizza, you should call: ;     if (cp > 1) {       for (int j = 0; j < cp - 1; j++) {         cout <<     << name[pizzafinal[j]] <<  , ;       }       cout <<     << name[pizzafinal[cp - 1]] <<  .  << endl;     } else {       cout <<     << name[pizzafinal[cp - 1]] <<  .  << endl;     }     cout <<  If you want to go to a cafe with a wonderful girl, you should call: ;     if (cc > 1) {       for (int j = 0; j < cc - 1; j++) {         cout <<     << name[cgcfinal[j]] <<  , ;       }       cout <<     << name[cgcfinal[cc - 1]] <<  .  << endl;     } else {       cout <<     << name[cgcfinal[cc - 1]] <<  .  << endl;     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     ;     string s[10];     for (int i = 0; i < 8; i++) {       cin >> s[i];     }     bool ans = 1;     for (int i = 0; i < 8 && ans; i++) {       for (int k = 1; k < 8; k++) {         if (s[i][k - 1] == s[i][k]) {           ans = 0;           break;         }       }     }     if (ans) {       cout <<  YES  << endl;     } else       cout <<  NO  << endl;     return 0;   }


/* Clearink */      #include <queue>   #include <cstdio>   #include <algorithm>      #define rep( i, l, r ) for ( int i = l, repEnd##i = r; i <= repEnd##i; ++i )   #define per( i, r, l ) for ( int i = r, repEnd##i = l; i >= repEnd##i; --i )      inline int rint() {    int x = 0, f = 1, s = getchar();    for ( ; s <  0  ||  9  < s; s = getchar() ) f = s ==  -  ? -f : f;    for ( ;  0  <= s && s <=  9 ; s = getchar() ) x = x * 10 + ( s ^  0  );    return x * f;   }      template<typename Tp>   inline void wint( Tp x ) {    if ( x < 0 ) putchar(  -  ), x = -x;    if ( 9 < x ) wint( x / 10 );    putchar( x % 10 ^  0  );   }      const int MAXN = 1.5e3;   int n, m, a[MAXN + 5][MAXN + 5], b[MAXN + 5][MAXN + 5];   int d[MAXN + 5], ocnt, opt[MAXN + 5], p[MAXN + 5], q[MAXN + 5], tmp[MAXN + 5];   bool era[MAXN + 5];   std::queue<int> que;      int main() {    n = rint(), m = rint();    rep ( i, 1, n ) rep ( j, 1, m ) a[i][j] = rint();    rep ( i, 1, n ) rep ( j, 1, m ) b[i][j] = rint();    rep ( i, 2, n ) rep ( j, 1, m ) d[j] += b[i - 1][j] > b[i][j];    rep ( i, 1, m ) if ( !d[i] ) que.push( i );    while ( !que.empty() ) {     int c = que.front(); que.pop();     opt[++ocnt] = c;     rep ( i, 2, n ) if ( b[i - 1][c] < b[i][c] && !era[i] ) {      era[i] = true;      rep ( j, 1, m ) if ( b[i - 1][j] > b[i][j] && !--d[j] ) {       que.push( j );      }     }    }    rep ( i, 1, n ) q[i] = i;    per ( k, ocnt, 1 ) {     rep ( i, 1, n ) p[i] = i;     std::sort( p + 1, p + n + 1, [=]( const int i, const int j ) {      int u = a[q[i]][opt[k]], v = a[q[j]][opt[k]];      return u != v ? u < v : i < j;     } );     rep ( i, 1, n ) tmp[i] = q[i];     rep ( i, 1, n ) q[i] = tmp[p[i]];    }    rep ( i, 1, n ) rep ( j, 1, m ) if ( a[q[i]][j] != b[i][j] ) {     return puts(  -1  ), 0;    }    wint( ocnt ), putchar(   n  );    per ( i, ocnt, 1 ) wint( opt[i] ), putchar( i > 1 ?     :   n  );    return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     std::ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long int n;     cin >> n;     long long int a[n];     for (int i = 0; i < n; i++) {       cin >> a[i];     }     map<long long int, long long int> m;     m[0] = 0;     long long int sum = 0, ans = 0, k = (-1);     for (int i = 0; i < n; i++) {       sum += a[i];       if (m.count(sum)) {         if (m[sum] >= k) {           ans++;           k = (i - 1);         }       }       m[sum] = i;     }     cout << ans;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int loc[200000 + 10];   int n;   int ans[4];   int fnext(int y) {     int l = 1, r = n + 1, mid = (l + r) / 2;     while (l < r) {       if (loc[mid] <= y)         l = mid + 1;       else         r = mid;       mid = (l + r) / 2;     }     return mid;   }   int ok(int x) {     int i, j;     int z = 1;     for (i = 1; i <= 3; i++) {       z = fnext(loc[z] + x);       ans[i] = z;       if (z >= n + 1) return 1;     }     return 0;   }   int main() {     while (scanf( %d , &n) != EOF) {       int i, j, k;       for (i = 1; i <= n; i++) {         scanf( %d , &loc[i]);       }       sort(loc + 1, loc + n + 1);       int r = (loc[n] - loc[1]);       int l = 0, mid;       while (l < r) {         mid = (r + l) / 2;         if (ok(mid))           r = mid;         else           l = mid + 1;       }       ok(l);       double radius = l * 1.0 / 2.0;       double radar1 = (loc[ans[1] - 1] + loc[1]) * 1.0 / 2.0;       double radar2 = (loc[ans[2] - 1] + loc[ans[1]]) / 2.0;       double radar3 = (loc[ans[3] - 1] + loc[ans[2]]) / 2.0;       printf( %.6f n , radius);       printf( %.6f  , radar1);       printf( %.6f  , radar2);       printf( %.6f n , radar3);     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     int x, y, x1, y1;     cin >> x >> y >> x1 >> y1;     int X = abs(x1 - x), Y = abs(y1 - y);     cout << max(X, Y);     return 0;   }


#include <bits/stdc++.h>   #pragma GCC optimize( O3 )   using namespace std;   using ii = long long;   int main() {     int n, k;     scanf( %d%d , &n, &k);     vector<int> v(n);     vector<ii> s(n);     for (int &x : v) {       scanf( %d , &x);     }     for (int i = n - 2; i + 1; --i) {       s[i] = v[i + 1] + s[i + 1];     }     s.pop_back();     ii r = v[0] + (n > 1 ? s[0] : 0);     sort(s.begin(), s.end(), greater<ii>());     r += accumulate(s.begin(), s.begin() + k - 1, 0ll);     printf( %lld n , r);   }


#include <bits/stdc++.h>   using namespace std;   const int MAXN = 55, MAXM = 20020;   int n, m, k, acc[MAXN][MAXM], dp[MAXN][MAXM], ans;   struct no {     int beg, end, mid, mx, lz;     no *l, *r;     no(int beg, int end)         : beg(beg), end(end), mid((beg + end) >> 1), mx(0), lz(0) {       if (beg != end) l = new no(beg, mid), r = new no(mid + 1, end);     }     void refresh() {       if (!lz) return;       mx += lz;       if (beg != end) l->lz += lz, r->lz += lz;       lz = 0;     }     void upd(int a, int b, int inc) {       refresh();       if (end < a || b < beg) return;       if (a <= beg && end <= b) return lz += inc, refresh();       l->upd(a, b, inc), r->upd(a, b, inc);       mx = max(l->mx, r->mx);     }     void set(int pos, int val) {       refresh();       if (beg == end) return void(mx = val);       (pos <= mid ? l : r)->set(pos, val);       mx = max(l->mx, r->mx);     }     int get(int a, int b) {       refresh();       if (end < a || b < beg) return 0;       if (a <= beg && end <= b) return mx;       return max(l->get(a, b), r->get(a, b));     }     void print() {       refresh();       if (beg == end) return printf( %d  , mx), void();       l->print(), r->print();     }   };   int main() {     scanf( %d %d %d , &n, &m, &k);     for (int i = 1; i <= n; ++i)       for (int j = 1; j <= m; ++j)         scanf( %d , &acc[i][j]), acc[i][j] += acc[i][j - 1];     no seg(1, m - k + 1);     for (int i = n; i >= 1; --i) {       for (int j = 1; j <= k; ++j)         seg.upd(1, j, -(acc[i + 1][j] - acc[i + 1][j - 1]));       for (int j = 1; j <= m - k + 1; ++j) {         int aux = acc[i][j + k - 1] - acc[i][j - 1] + acc[i + 1][j + k - 1] -                   acc[i + 1][j - 1];         if (i == n) {           dp[i][j] = aux;           continue;         }         dp[i][j] = max(dp[i][j], seg.get(j - k + 1, j + k - 1));         if (j > k) dp[i][j] = max(dp[i][j], seg.get(1, j - k));         if (j + k <= m - k + 1)           dp[i][j] = max(dp[i][j], seg.get(j + k, m - k + 1));         dp[i][j] += aux;         seg.upd(max(1, j - k + 1), j, (acc[i + 1][j] - acc[i + 1][j - 1]));         seg.upd(j + 1, j + k, -(acc[i + 1][j + k] - acc[i + 1][j + k - 1]));       }       for (int j = 1; j <= m - k + 1; ++j) seg.set(j, dp[i][j]);     }     printf( %d n , seg.get(1, m - k + 1));   }


#include <bits/stdc++.h>   using namespace std;   const int MAX_N = 1e5 + 5;   bool mark[MAX_N];   int main() {     ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);     int n;     cin >> n;     for (int i = 0; i < n - 1; i++) {       int a;       cin >> a;       mark[a - 1] = true;     }     for (int i = 0; i < n; i++)       if (!mark[i]) cout << i + 1;   }


#include <bits/stdc++.h>   using namespace std;   char a[100];   int main() {     int i, l, c = 0;     scanf( %s , a);     l = strlen(a);     for (i = 1; i < l; i++) {       if (a[i] <=  Z ) {         c++;       }     }     int t = 0;     if (a[1] <=  Z  && c >= l - 1) t++;     if (t != 0) {       for (i = 0; i < l; i++) {         if (a[i] >=  a ) {           a[i] = a[i] -  a  +  A ;         } else {           a[i] = a[i] -  A  +  a ;         }       }     }     printf( %s , a);   }