#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using pi = pair<long long, long long>;   const int N = 1e5 + 5;   const long long p1 = 31;   const long long p2 = 41;   const long long mod1 = 1e9 + 7;   const long long mod2 = 1e9 + 9;   long long power1[N];   long long power2[N];   long long prefix1[3][N];   long long prefix2[3][N];   pi suff[3][N];   string s[3];   int arr[3] = {0, 1, 2};   bool yes[3][3];   long long mod_exp(long long x, long long y, long long mod) {     long long res = 1;     x %= mod;     while (y > 0) {       if (y & 1LL) {         res = (res * x) % mod;       }       y >>= 1LL;       x = (x * x) % mod;     }     return res;   }   ll inv(ll x, ll mod) { return mod_exp(x, mod - 2, mod); }   ll add(ll a, ll b, ll mod) { return (a + b) % mod; }   ll mul(ll a, ll b, ll mod) { return (a * b) % mod; }   ll sub(ll a, ll b, ll mod) { return (a - b + mod) % mod; }   pi see(int l, int r, int idx) {     pi p;     if (l > 0) {       p.first = mul(sub(prefix1[idx][r], prefix1[idx][l - 1], mod1),                     inv(power1[l], mod1), mod1);       p.second = mul(sub(prefix2[idx][r], prefix2[idx][l - 1], mod2),                      inv(power2[l], mod2), mod2);     } else {       p.first = prefix1[idx][r];       p.second = prefix2[idx][r];     }     return p;   }   inline void compute(string &str, int idx) {     prefix1[idx][0] = str[0];     prefix2[idx][0] = str[0];     int n = str.size();     for (int i = 1; i < n; ++i) {       prefix1[idx][i] =           add(prefix1[idx][i - 1], mul(str[i], power1[i], mod1), mod1);       prefix2[idx][i] =           add(prefix2[idx][i - 1], mul(str[i], power2[i], mod2), mod2);     }     for (int i = n - 1; i >= 0; --i) {       suff[idx][i] = see(i, n - 1, idx);     }     sort(suff[idx], suff[idx] + n);   }   bool check(int idx1, int idx2) {     if (s[idx2].size() < s[idx1].size()) {       return 0;     }     int i = 0;     int j = s[idx1].size() - 1;     int k = s[idx1].size() - 1;     while (j < s[idx2].size()) {       if (see(i, j, idx2) == pi(prefix1[idx1][k], prefix2[idx1][k])) {         return 1;       }       ++i;       ++j;     }     return 0;   }   inline int solve() {     int ret = s[arr[0]].size();     for (int i = 1; i < 3; ++i) {       if (yes[arr[i]][arr[i - 1]]) {         continue;       }       if (i == 2 && yes[arr[i]][arr[i - 2]]) {         break;       }       int sub = 0;       for (int j = s[arr[i]].size() - 1; j >= 0; --j) {         if (binary_search(suff[arr[i - 1]],                           suff[arr[i - 1]] + s[arr[i - 1]].size(),                           pi(prefix1[arr[i]][j], prefix2[arr[i]][j]))) {           sub = j + 1;           break;         }       }       ret += s[arr[i]].size() - sub;     }     return ret;   }   int main() {     ios_base::sync_with_stdio(0);     power1[0] = 1;     power2[0] = 1;     for (int i = 1; i < N; ++i) {       power1[i] = mul(power1[i - 1], p1, mod1);       power2[i] = mul(power2[i - 1], p2, mod2);     }     for (int i = 0; i < 3; ++i) {       cin >> s[i];       compute(s[i], i);     }     for (int i = 0; i < 3; ++i) {       for (int j = 0; j < 3; ++j) {         if (i == j) {           continue;         }         yes[i][j] = check(i, j);       }     }     int res = 1 << 29;     do {       res = min(res, solve());     } while (next_permutation(arr, arr + 3));     cout << res <<   n ;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using ld = long double;   using uint = unsigned int;   using ull = unsigned long long;   using pii = pair<int, int>;   int f[50], s[50], p[50];   ld dp[51][5000];   int main() {     cin.tie(nullptr);     cout.tie(nullptr);     ios_base::sync_with_stdio(false);     int n, r;     cin >> n >> r;     for (int i = 0; i < n; i++) cin >> f[i] >> s[i] >> p[i];     ld l = 0, h = 1e9;     int rep = 80;     while (rep--) {       ld m = (l + h) / 2;       for (int i = n - 1; i >= 0; i--) {         fill(dp[i + 1] + min(5000, r + 1), dp[i + 1] + 5000, m);         for (int j = 0; j <= r; j++) {           ld ff = (dp[i + 1][j + f[i]] + f[i]) * p[i];           ld ss = (dp[i + 1][j + s[i]] + s[i]) * (100 - p[i]);           dp[i][j] = min(m, (ff + ss) / 100);         }       }       if (dp[0][0] < m) {         h = m;       } else {         l = m;       }     }     cout << fixed << setprecision(20) << l;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 5;   void run() {     int n;     cin >> n;     vector<long long> a(n);     for (int i = 0; i < n; i++) {       cin >> a[i];     }     if (n == 1) {       cout << 1 <<     << 1 <<   n  << -a[0] <<   n ;       cout << 1 <<     << 1 <<   n  << 0 <<   n ;       cout << 1 <<     << 1 <<   n  << 0 <<   n ;       return;     }     cout << 1 <<     << n - 1 <<   n ;     for (int i = 0; i < n - 1; i++) {       int x = a[i] % n;       a[i] += 1ll * x * (n - 1);       if (i) cout <<    ;       cout << 1ll * x * (n - 1);     }     cout <<   n ;     cout << 2 <<     << n <<   n ;     for (int i = 1; i < n; i++) {       int x = a[i] % n;       a[i] += 1ll * x * (n - 1);       if (i > 1) cout <<    ;       cout << 1ll * x * (n - 1);     }     cout <<   n ;     cout << 1 <<     << n <<   n ;     for (int i = 0; i < n; i++) {       if (i) cout <<    ;       cout << -a[i];     }     cout <<   n ;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cout << fixed << setprecision(20);     run();     return 0;   }


#include <bits/stdc++.h>   long long gcd(long long a, long long b) {     while (a && b) {       if (a > b)         a %= b;       else         b %= a;     }     return a + b;   }   long long lcm(long long a, long long b) { return (((a) / gcd(a, b))) * b; }   int phi(int n) {     int result = n;     for (int i = 2; i * i <= n; i++) {       if (n % i == 0) {         while (n % i == 0) n /= i;         result -= result / i;       }     }     if (n > 1) result -= result / n;     return result;   }   long long power(long long a, long long b, long long c) {     long long r = 1;     while (b) {       if (b & 1) r *= a;       a *= a;       a %= c;       r %= c;       b /= 2;     }     return r;   }   void nxi(int& n) {     bool min = 0;     char c;     n = 0;     while ((c = getc(stdin)) && c <= 32)       ;     if (c ==  - )       min = 1;     else       n = c - 48;     while ((c = getc(stdin)) && c > 32) n = (n << 3) + (n << 1) + c - 48;     if (min) n = -n;   }   void prl(int n) {     if (n == 0) {       puts( 0 );       return;     }     static int s[10];     int top = 0;     while (n > 0) s[top++] = n % 10, n /= 10;     while (top--) putchar(s[top] + 48);   }   using namespace std;   int n, m;   pair<int, int> mem[101010];   map<long long, vector<long long> > sv;   map<long long, long long> t;   void inc(int pos, long long val) {     for (long long i = pos; i < 1000000007; i = (i | (i + 1))) {       t[i] += val, t[i] %= 1000000007;     }   }   long long get(int r) {     long long s = 0;     for (long long i = r; i >= 0; i = (i & (i + 1)) - 1) {       if (t.count(i)) {         s += t[i];         s %= 1000000007;       }     }     return s;   }   long long get(int l, int r) {     long long x = (long long)get(r) - (l > 0 ? 1ll * get(l - 1) : 0);     x = (x + 1000000007) % 1000000007;     x = (x + 1000000007) % 1000000007;     return x;   }   int main() {     ios::sync_with_stdio(0);     cin >> n >> m;     for (int i = 0; i < m; i++) {       cin >> mem[i].first >> mem[i].second;       int x = mem[i].second;       sv[x].push_back(mem[i].first);     }     inc(0, 1);     for (map<long long, vector<long long> >::iterator it = sv.begin();          it != sv.end(); it++) {       long long s = 0;       int x = it->first;       for (int i = 0; i < it->second.size(); i++) {         s += get(it->second[i], x - 1);         s %= 1000000007;         s = (s + 1000000007) % 1000000007;         s = (s + 1000000007) % 1000000007;       }       inc(x, s);     }     cout << get(n, n) << endl;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }   long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }   long long powmod(long long a, long long b, long long MOD) {     if (a == 0ll) {       return 0ll;     }     a %= MOD;     long long ans = 1;     while (b) {       if (b & 1) {         ans = ans * a % MOD;       }       a = a * a % MOD;       b >>= 1;     }     return ans;   }   long long poww(long long a, long long b) {     if (a == 0ll) {       return 0ll;     }     long long ans = 1;     while (b) {       if (b & 1) {         ans = ans * a;       }       a = a * a;       b >>= 1;     }     return ans;   }   void Pv(const vector<int> &V) {     int Len = int(V.size());     for (int i = 0; i < Len; ++i) {       printf( %d , V[i]);       if (i != Len - 1) {         printf(   );       } else {         printf(  n );       }     }   }   void Pvl(const vector<long long> &V) {     int Len = int(V.size());     for (int i = 0; i < Len; ++i) {       printf( %lld , V[i]);       if (i != Len - 1) {         printf(   );       } else {         printf(  n );       }     }   }   inline long long readll() {     long long tmp = 0, fh = 1;     char c = getchar();     while (c <  0  || c >  9 ) {       if (c ==  - ) fh = -1;       c = getchar();     }     while (c >=  0  && c <=  9 ) tmp = tmp * 10 + c - 48, c = getchar();     return tmp * fh;   }   inline int readint() {     int tmp = 0, fh = 1;     char c = getchar();     while (c <  0  || c >  9 ) {       if (c ==  - ) fh = -1;       c = getchar();     }     while (c >=  0  && c <=  9 ) tmp = tmp * 10 + c - 48, c = getchar();     return tmp * fh;   }   void pvarr_int(int *arr, int n, int strat = 1) {     if (strat == 0) {       n--;     }     for (int i = strat; i <= n; i++) {       printf( %d%c , arr[i], i == n ?   n  :    );     }   }   void pvarr_LL(long long *arr, int n, int strat = 1) {     if (strat == 0) {       n--;     }     for (int i = strat; i <= n; i++) {       printf( %lld%c , arr[i], i == n ?   n  :    );     }   }   const int maxn = 1000010;   const int inf = 0x3f3f3f3f;   int n, m;   long long a[maxn], b[maxn];   struct node {     int f, t;     long long val;     node() {}     node(int ff, int tt, long long vv) {       f = ff;       t = tt;       val = vv;     }     bool operator<(const node &bb) const { return val > bb.val; }   };   std::vector<node> v;   int far[maxn];   void dsu_init(int n) {     for (int i = 0; i <= n; i++) {       far[i] = i;     }   }   int findpar(int x) {     if (x == far[x]) {       return x;     } else {       return far[x] = findpar(far[x]);     }   }   void mg(int x, int y) {     x = findpar(x);     y = findpar(y);     if (x == y) return;     far[x] = y;   }   long long maxst() {     dsu_init(n + m);     sort((v).begin(), (v).end());     long long res = 0ll;     for (auto e : v) {       int x = e.f;       int y = e.t;       x = findpar(x);       y = findpar(y);       if (x != y) {         res += e.val;         far[x] = y;       }     }     return res;   }   int main() {     m = readint();     n = readint();     for (int i = 1; i <= m; i++) {       a[i] = readll();     }     for (int i = 1; i <= n; i++) {       b[i] = readll();     }     long long ans = 0ll;     for (int i = 1; i <= m; i++) {       int k = readint();       while (k--) {         int x = readint();         ans += a[i] + b[x];         v.push_back(node(i, m + x, a[i] + b[x]));         v.push_back(node(m + x, i, a[i] + b[x]));       }     }     printf( %lld n , ans - maxst());     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int T, ans;   int dfs(vector<int> G[], int node, bool visit[], int k, bool first) {     if (!visit[node]) {       visit[node] = true;       int counti = 0;       for (auto it : G[node]) {         if (!visit[it]) counti += dfs(G, it, visit, k, false);       }       ans += counti / k;       if (counti != G[node].size() - 1)         return 0;       else if (G[node].size() % k != 1)         return 0;       else {         return 1;       }     }     return 0;   }   void solve() {     int n, m, i, root, k;     ans = 0;     cin >> n >> k;     vector<int> G[n];     bool all = true;     bool visit[n];     for (i = 0; i < n - 1; i++) {       int a, b;       cin >> a >> b;       a--, b--;       G[a].push_back(b);       G[b].push_back(a);     }     for (i = 0; i < n; i++) visit[i] = false;     for (i = 0; i < n; i++) {       if (G[i].size() % k != 1) {         all = false;         root = i;         break;       }     }     if (all)       cout << (n - 1) / k <<   n ;     else if (k == 1) {       cout << n - 1 <<   n ;     } else {       dfs(G, root, visit, k, true);       cout << ans <<   n ;     }   }   int main() {     cin >> T;     while (T--) solve();     return 0;   }


#include <bits/stdc++.h>   using namespace std;   template <class T, class L>   inline bool smax(T &x, L y) {     return x < y ? (x = y, 1) : 0;   }   template <class T, class L>   inline bool smin(T &x, L y) {     return y < x ? (x = y, 1) : 0;   }   const int maxn = 2e2 + 17, maxm = maxn * maxn;   int from[maxm], to[maxm], n, m;   bool bl[maxm], mark[maxn];   vector<int> g[maxn], vec;   void see(int v) {     if (mark[v]) return;     mark[v] = 1;     vec.push_back(v);     for (auto i : g[v]) see(from[i] ^ to[i] ^ v);   }   void dfs(int v) {     for (int i = g[v].size() - 1; i >= 0; i = (int)g[v].size() - 1) {       int e = g[v][i], u = from[e] ^ to[e] ^ v;       if (v != from[e]) swap(from[e], to[e]);       g[v].pop_back();       if (bl[e]) continue;       bl[e] = 1;       dfs(u);     }   }   void solve() {     cin >> n >> m;     int cm = m, ans = 0;     for (int i = 0; i < m; i++) {       cin >> from[i] >> to[i], from[i]--, to[i]--;       g[from[i]].push_back(i), g[to[i]].push_back(i);     }     for (int i = 0; i < n; i++) ans += g[i].size() % 2 == 0;     for (int i = 0; i < n; i++)       if (!mark[i]) {         vec.clear();         see(i);         int last = -1;         for (auto v : vec)           if (g[v].size() & 1)             if (last != -1)               last = v;             else {               from[m] = v, to[m] = last;               g[v].push_back(m), g[last].push_back(m);               m++, last = -1;             }         dfs(i);       }     cout << ans <<   n ;     for (int i = 0; i < cm; i++) cout << from[i] + 1 <<     << to[i] + 1 <<   n ;   }   int main() {     ios::sync_with_stdio(0), cin.tie(0);     int t;     cin >> t;     while (t--) {       memset(mark, 0, sizeof mark);       memset(bl, 0, sizeof bl);       solve();     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int comp[212345], ptr;   int idx[212345];   map<int, int> place;   int h, m, n;   int merge(int x, int y) {     if (x == -1) {       return y;     }     return x;   }   struct segtree {     int n;     vector<int> tree;     segtree(vector<int> base) {       n = base.size();       tree.resize(2 * n);       for (int i = 0; i < n; ++i) {         tree[i + n] = base[i];       }       for (int i = n - 1; i > 0; --i) {         tree[i] = merge(tree[i + i], tree[i + i + 1]);       }     }     int qry(int l) {       int x = qry(l, n);       if (x == -1) {         return qry(0, l);       }       return x;     }     int qry(int l, int r) {       int resl = -1, resr = -1;       for (l += n, r += n; l < r; l /= 2, r /= 2) {         if (l & 1) resl = merge(resl, tree[l++]);         if (r & 1) resr = merge(tree[--r], resr);       }       return merge(resl, resr);     }     void upd(int pos, int val) {       pos += n;       tree[pos] = val;       for (pos /= 2; pos > 0; pos /= 2) {         tree[pos] = merge(tree[pos + pos], tree[pos + pos + 1]);       }     }   };   vector<int> base[212345];   void dfs(int x) {     comp[x] = ptr;     idx[x] = base[ptr].size();     base[ptr].push_back(x);     int nxt = (x + m) % h;     if (comp[nxt] == -1) {       dfs(nxt);     }   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cin >> h >> m >> n;     long long ans = 0;     memset(comp, -1, sizeof comp);     for (int i = 0; i < h; ++i) {       if (comp[i] == -1) {         dfs(i);         ++ptr;       }     }     vector<segtree> segts;     for (int i = 0; i < ptr; ++i) {       segts.push_back(segtree(base[i]));     }     while (n--) {       char a;       int id, hash;       cin >> a >> id;       if (a ==  + ) {         cin >> hash;         int pos = segts[comp[hash]].qry(idx[hash]);         int dummy = idx[pos] - idx[hash];         if (dummy < 0) {           dummy += base[comp[hash]].size();         }         ans += dummy;         segts[comp[pos]].upd(idx[pos], -1);         place[id] = pos;       } else {         int pos = place[id];         segts[comp[pos]].upd(idx[pos], pos);       }     }     cout << ans <<   n ;     return 0;   }


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


#include <bits/stdc++.h>   using namespace std;   bool func(vector<pair<int, int> > vd, vector<pair<int, int> > vu) {     for (int i = 0; i < vd.size(); i++) {       if ((vd[i].first < vu[i].first && vd[i].second < vu[i].second) ||           (vd[i].first > vu[i].first && vd[i].second > vu[i].second)) {         return true;       }     }     return false;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long int t, i, j, k, n, m,         a = 1, b = 1, c, p, prev, q, r, width, o, rc, height, mx = -999999999,         mn = 99999999, ct = 0, ans = 0, flag = 1, sum = 0, pos1, pos2;     cin >> n >> m >> k;     std::vector<pair<long long int, long long int> > row(n), col(m);     for (i = 1; i <= k; i++) {       cin >> o >> rc >> a;       if (o == 1) {         row[rc - 1] = {a, i};       } else {         col[rc - 1] = {a, i};       }     }     for (i = 0; i < n; i++) {       for (j = 0; j < m; j++) {         if (col[j].second > row[i].second)           cout << col[j].first <<    ;         else           cout << row[i].first <<    ;       }       cout <<   n ;     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   priority_queue<pair<long long, int> > q;   vector<pair<long long, pair<int, int> > > E;   vector<pair<int, int> > e[120000];   int n, m, x, y, k, z, fa[120000], i, be[120000], flag[120000];   long long dis[120000], ans;   int get(int x) { return fa[x] == x ? x : (fa[x] = get(fa[x])); }   int main() {     scanf( %d%d , &n, &m);     for (i = 1; i <= m; ++i) {       scanf( %d%d%d , &x, &y, &k);       e[x].push_back(make_pair(y, k));       e[y].push_back(make_pair(x, k));     }     memset(dis, 3, sizeof(dis));     scanf( %d , &k);     for (i = 1; i <= k; ++i) {       scanf( %d , &x);       dis[x] = 0;       fa[x] = x;       q.push(make_pair(0, x));       be[x] = x;     }     while (!q.empty()) {       x = q.top().second;       q.pop();       if (flag[x]) continue;       flag[x] = 1;       for (i = 0; i < e[x].size(); ++i) {         y = e[x][i].first;         z = e[x][i].second;         if (be[y])           E.push_back(make_pair(dis[x] + dis[y] + z, make_pair(be[x], be[y])));         if (dis[x] + z < dis[y]) {           dis[y] = dis[x] + z;           be[y] = be[x];           q.push(make_pair(-dis[y], y));         }       }     }     sort(E.begin(), E.end());     for (i = 0; i < E.size(); ++i) {       x = E[i].second.first;       y = E[i].second.second;       if (get(x) != get(y)) {         ans += E[i].first;         fa[get(x)] = get(y);       }     }     printf( %I64d n , ans + dis[1]);   }


#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 5;   int dp[N], a[N], n;   int main() {     cin >> n;     for (int i = 0; i < n; ++i) scanf( %d , &a[i]);     if (n == 1) {       cout << 1;       return 0;     }     for (int i = 0; i < n; ++i) {       if (a[i] == 1) continue;       int d = 2, mx = 0, x = a[i];       while (d * d <= x)         if (x % d == 0) {           mx = max(mx, dp[d] + 1);           x /= d;         } else           ++d;       mx = max(mx, dp[x] + 1);       d = 2;       x = a[i];       while (d * d <= x)         if (x % d == 0) {           dp[d] = max(dp[d], mx);           x /= d;         } else           ++d;       dp[x] = max(dp[x], mx);     }     int mx = 0;     for (int i = 1; i < N; ++i) mx = max(mx, dp[i]);     cout << mx;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int oo = 1 << 30;   const double PI = M_PI;   const double EPS = 1e-15;   double w, h, u;   double cross(const complex<double> &a, const complex<double> &b) {     return imag(conj(a) * b);   }   complex<double> rotate_by(const complex<double> &p,                             const complex<double> &about, double radians) {     return (p - about) * exp(complex<double>(0, radians)) + about;   }   complex<double> intersect(const complex<double> &a, const complex<double> &b,                             const complex<double> &p, const complex<double> &q) {     double d1 = cross(p - a, b - a);     double d2 = cross(q - a, b - a);     return (d1 * q - d2 * p) / (d1 - d2);   }   int main() {     cin.sync_with_stdio(false);     cin >> w >> h >> u;     if (w < h) swap(w, h);     if (u > 90) u = 180 - u;     u = u * M_PI / 180.;     cout.precision(10);     if (u == 0) {       cout << fixed << w * h << endl;       return 0;     }     if (u >= (M_PI - 2. * atan(w / (double)h))) {       cout << fixed << h * h / sin(u) << endl;     } else {       double answer = w * h;       complex<double> a1 =           rotate_by(complex<double>(+w / 2., -h / 2), complex<double>(0, 0), u);       complex<double> a2 =           rotate_by(complex<double>(+w / 2., +h / 2), complex<double>(0, 0), u);       complex<double> a3 =           rotate_by(complex<double>(-w / 2., +h / 2), complex<double>(0, 0), u);       complex<double> b1 = intersect(a1, a2, complex<double>(-w / 2., h / 2.),                                      complex<double>(w / 2., h / 2.));       complex<double> b2 = intersect(a2, a3, complex<double>(-w / 2., h / 2.),                                      complex<double>(w / 2., h / 2.));       {         double side1 = b1.real() - b2.real();         double side2 = side1 * cos(u);         double area = side1 * side2 * sin(u);         answer = answer - area;       }       {         double side1 = w / 2. - b1.real();         double side2 = side1 * tan(M_PI / 2. - u);         double area = side1 * side2;         answer = answer - area;       }       cout << fixed << answer << endl;     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   void lemon() {     double R1, R2;     int k;     scanf( %lf%lf%d , &R1, &R2, &k);     k++;     double xl = 1 / (R1 * 2), xr = 1 / (R2 * 2);     double xc = (xl + xr) / 2, rad = abs(xc - xl);     double yc = rad * (k - 1) * 2;     double len = sqrt(xc * xc + yc * yc);     double final = (1 / (len - rad) - 1 / (len + rad)) / 2;     printf( %.16lf n , final);   }   int main() {     ios::sync_with_stdio(true);     int tcase;     scanf( %d , &tcase);     while (tcase--) lemon();     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int pp = (1e9) + 7;   long long P[1000010];   long long ans, now;   int N, K;   long long quick(int x, int y) {     long long s = 1, t = x;     for (; y; y >>= 1) {       if (y & 1) s = s * t % pp;       t = t * t % pp;     }     return s;   }   long long get0() {     long long t = 1;     for (int i = N - K - 1; i < N; i++) t = t * i % pp;     for (int i = 1; i <= K + 1; i++) t = t * quick(pp - i, pp - 2) % pp;     return t;   }   int main() {     scanf( %d%d , &N, &K);     if (!K) {       printf( %d n , N);       return 0;     }     for (int i = 1; i <= K + 2; i++) P[i] = (P[i - 1] + quick(i, K)) % pp;     if (N <= K + 2) {       printf( %I64d n , P[N]);       return 0;     }     ans = 0;     now = get0();     for (int i = 1; i <= K + 1; i++) {       now = now * quick(i, pp - 2) % pp * (N - i + 1) % pp *             quick(N - i, pp - 2) % pp * (pp - (K - i + 2)) % pp;       ans = (ans + P[i] * now) % pp;     }     printf( %I64d , ans);   }


#include <bits/stdc++.h>   using namespace std;   long long G[333][333];   long long min(long long a, long long b, long long c) {     return min(a, min(b, c));   }   int main() {     int N;     cin >> N;     for (int i = 1; i <= N; i++)       for (int j = 1; j <= N; j++) cin >> G[i][j];     int M;     cin >> M;     while (M--) {       long long u, v, x;       cin >> u >> v >> x;       for (int i = 1; i <= N; i++)         for (int j = 1; j <= N; j++) {           G[i][j] = min(G[i][j], G[i][u] + G[v][j] + x, G[i][v] + G[u][j] + x);         }       long long sum = 0;       for (int i = 1; i <= N; i++)         for (int j = i; j <= N; j++) sum += G[i][j];       cout << sum <<    ;     }   }


#include <bits/stdc++.h>   using namespace std;   const int N = 500005;   const int mod = 998244353;   const long long int inf = 10e17;   const long double pi = 3.14159265359;   mt19937_64 rang(       chrono::high_resolution_clock::now().time_since_epoch().count());   int rng(int lim) {     uniform_int_distribution<int> uid(0, lim - 1);     return uid(rang);   }   void fastIO(void);   void decimal(int);   int modmulti(int, int);   int modadd(int, int);   int modpower(int, int);   int gcd(int, int);   int modinv(int);   vector<int> parent, depth, heavy, head, pos, tin, tout;   int cur_pos;   int lazy1[4 * N], lazy2[8 * N];   int timer, l;   vector<vector<int>> up;   int dfs(int v, vector<vector<int>> const& g) {     int size = 1;     tin[v] = ++timer;     up[v][0] = parent[v];     for (int i = 1; i < l + 1; i++) {       up[v][i] = up[up[v][i - 1]][i - 1];     }     int max_c_size = 0;     for (int c : g[v]) {       if (c != parent[v]) {         parent[c] = v;         depth[c] = depth[v] + 1;         int c_size = dfs(c, g);         if (c_size > max_c_size) {           max_c_size = c_size;           heavy[v] = c;         }         size += c_size;       }     }     tout[v] = ++timer;     return size;   }   bool is_ancestor(int u, int v) {     return tin[u] <= tin[v] && tout[u] >= tout[v];   }   int lca(int u, int v) {     if (is_ancestor(u, v)) return u;     if (is_ancestor(v, u)) return v;     for (int i = l; i >= 0; --i) {       if (!is_ancestor(up[u][i], v)) u = up[u][i];     }     return up[u][0];   }   void decompose(int v, int h, vector<vector<int>> const& g) {     head[v] = h;     pos[v] = cur_pos++;     if (heavy[v] != -1) {       decompose(heavy[v], h, g);     }     for (int c : g[v]) {       if (c != parent[v] && c != heavy[v]) decompose(c, c, g);     }   }   void init(vector<vector<int>> const& g) {     int n = g.size();     parent = vector<int>(n);     depth = vector<int>(n);     heavy = vector<int>(n, -1);     head = vector<int>(n);     pos = vector<int>(n);     tin = vector<int>(n);     tout = vector<int>(n);     timer = 0;     l = ceil(log2(n));     up.assign(n, vector<int>(l + 1));     cur_pos = 0;     dfs(0, g);     decompose(0, 0, g);   }   void update1(int node, int l, int r, int st, int ed, int val) {     if (l == st && r == ed) {       lazy1[node] = val;       return;     }     int m = (l + r) / 2;     if (ed <= m) {       update1(2 * node + 1, l, m, st, ed, val);       return;     }     if (st > m) {       update1(2 * node + 2, m + 1, r, st, ed, val);       return;     }     update1(2 * node + 1, l, m, st, m, val);     update1(2 * node + 2, m + 1, r, m + 1, ed, val);     return;   }   void update2(int node, int l, int r, int st, int ed, int val) {     if (l == st && r == ed) {       lazy2[node] = val;       return;     }     int m = (l + r) / 2;     if (ed <= m) {       update2(2 * node + 1, l, m, st, ed, val);       return;     }     if (st > m) {       update2(2 * node + 2, m + 1, r, st, ed, val);       return;     }     update2(2 * node + 1, l, m, st, m, val);     update2(2 * node + 2, m + 1, r, m + 1, ed, val);     return;   }   void update(int b, int val, int n) {     int a = 0;     for (; head[a] != head[b]; b = parent[head[b]]) {       if (depth[head[a]] > depth[head[b]]) swap(a, b);       update1(0, 0, n - 1, pos[head[b]], pos[b], val);     }     update1(0, 0, n - 1, pos[a], pos[b], val);     return;   }   int query1(int node, int l, int r, int pos) {     if (l == r) {       return lazy1[node];     }     lazy1[2 * node + 1] = max(lazy1[node], lazy1[2 * node + 1]);     lazy1[2 * node + 2] = max(lazy1[node], lazy1[2 * node + 2]);     int m = (l + r) / 2;     if (pos <= m) return query1(2 * node + 1, l, m, pos);     return query1(2 * node + 2, m + 1, r, pos);   }   int query2(int node, int l, int r, int pos) {     if (l == r) {       return lazy2[node];     }     lazy2[2 * node + 1] = max(lazy2[node], lazy2[2 * node + 1]);     lazy2[2 * node + 2] = max(lazy2[node], lazy2[2 * node + 2]);     int m = (l + r) / 2;     if (pos <= m) return query2(2 * node + 1, l, m, pos);     return query2(2 * node + 2, m + 1, r, pos);   }   int main() {     fastIO();     int n;     cin >> n;     vector<vector<int>> g(n);     for (int i = 0; i < n - 1; i++) {       int u, v;       cin >> u >> v;       u--;       v--;       g[u].push_back(v);       g[v].push_back(u);     }     init(g);     int m;     cin >> m;     int cnt = 0;     for (int m1 = 1; m1 < m + 1; m1++) {       int a, b;       cin >> a >> b;       b--;       if (a == 1) {         update2(0, 1, 2 * n, tin[b], tout[b], m1);       } else if (a == 2) {         update(b, m1, n);       } else {         cnt++;         int q1, q2;         q1 = query1(0, 0, n - 1, pos[b]);         q2 = query2(0, 1, 2 * n, tin[b]);         if (q1 >= q2)           cout << 0 <<   n ;         else           cout << 1 <<   n ;       }     }   }   void fastIO(void) {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);   }   void decimal(int n) {     cout << fixed;     cout << setprecision(n);   }   int modmulti(int a, int b) { return ((a % mod) * 1ll * (b % mod)) % mod; }   int modadd(int a, int b) {     a = a % mod;     a = (a + mod) % mod;     b = b % mod;     b = (b + mod) % mod;     return (a + b) % mod;   }   int modpower(int a, int n) {     if (n == 0) return 1;     if (n == 1) return a % mod;     int b = modpower(a, n / 2);     b = modmulti(b, b);     if (n % 2 == 0) return b;     return modmulti(a, b);   }   int gcd(int a, int b) {     if (b == 0) return a;     return gcd(b, a % b);   }   int modinv(int a) { return modpower(a, mod - 2); }


#include <bits/stdc++.h>   using namespace std;   set<int> m;   using namespace std;   bool check(int a) {     m.erase(m.begin(), m.end());     int i = 0;     while (a > 0) {       int re = a % 10;       m.insert(re);       a /= 10;       i++;     }     if (m.size() == i) {       return true;     } else       return false;   }   int main() {     int l, r, flag = 0;     long long int ans = 0;     cin >> l >> r;     for (int i = l; i <= r; i++) {       if (check(i) == true) {         ans = i;         flag = 1;         break;       }     }     if (flag == 1) {       cout << ans << endl;     } else       cout <<  -1  << endl;   }


#include <bits/stdc++.h>   using namespace std;   const int N = 100005;   int n, l;   int cnt[N];   long long sum[N];   int main() {     cin >> n >> l;     for (int i = 1; i < n; i++) {       cin >> cnt[i];       sum[i] = sum[i - 1] + cnt[i];     }     long long ans = 2e18;     for (int i = l; i < n; i++) {       ans = min(ans, sum[i] - sum[i - l]);     }     cout << ans << endl;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using pii = pair<int, int>;   using pll = pair<ll, ll>;   int n, k;   string s;   int main(void) {     ios::sync_with_stdio(false);     cin.tie(0);     int t;     cin >> t;     while (t--) {       cin >> n >> k;       vector<int> alpha(26, 0);       vector<int> cpy(26, 0);       vector<int> cnt(26, 0);       cin >> s;       int ans = 0;       for (char c : s) {         alpha[c -  a ]++;         cpy[c -  a ]++;       }       for (int i = 1; i <= min(n, k); i++)         if (k % i == 0)           for (int l = 1; l <= n; l++) {             int tmp = 0;             for (int a = 0; a < 26; a++) tmp += alpha[a] / l;             if (tmp >= i) ans = max(ans, l * i);           }       cout << ans <<   n ;     }   }


#include <bits/stdc++.h>   using namespace std;   int main() {     string s;     cin >> s;     map<char, int> cnt;     if (s.size() > 2)       for (int i = 1; i <= s.size() - 2; i++) {         cnt.clear();         cnt[s[i - 1]]++;         cnt[s[i]]++;         cnt[s[i + 1]]++;         if (cnt[ A ] == 1 && cnt[ B ] == 1 && cnt[ C ] == 1) {           cout <<  Yes n ;           return 0;         }       }     cout <<  No n ;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   char s[1000001], s1[1000001], s2[1000001];   int n, ci, dian = -1, en, e2;   int main() {     scanf( %s , s);     n = strlen(s);     if (n == 1 && s[0] ==  0 ) {       puts( 0 );       return 0;     }     for (int i = 0; i < n; ++i)       if (s[i] ==  . ) dian = i;     if (dian == -1) s[dian = n++] =  . ;     for (int i = 0; i < n; ++i)       if (s[i] !=  0  && s[i] !=  . ) {         if (dian > i)           ci = dian - i - 1;         else           ci = dian - i;         for (int j = 0; j <= i; ++j)           if (s[j] !=  . ) s1[en++] = s[j];         for (int j = i + 1; j < n; ++j)           if (s[j] !=  . ) s2[e2++] = s[j];         break;       }     for (int i = 0; i < en; ++i)       if (s1[i] !=  0 ) {         for (int j = i; j < en; ++j) putchar(s1[j]);         break;       }     if (e2 != 0) {       bool flag = 0;       for (int i = e2 - 1; i >= 0; --i)         if (s2[i] !=  0 ) {           flag = 1;           break;         }       if (flag) putchar( . );       for (int i = e2 - 1; i >= 0; --i)         if (s2[i] !=  0 ) {           for (int j = 0; j <= i; ++j) putchar(s2[j]);           break;         }     }     if (ci != 0) printf( E%d n , ci);     return 0;   }


#include <bits/stdc++.h>   using namespace std;   bool same(int l1, int r1, int l2, int r2) {     if (r1 < l2 || r2 < l1) {       return 0;     }     return 1;   }   signed main() {     int q;     cin >> q;     while (q--) {       int n;       cin >> n;       int l = 1e9 + 5, r = 0;       for (int i = 0; i < n; i++) {         int l3, r3;         cin >> l3 >> r3;         r = max(r, l3);         l = min(l, r3);       }       cout << max(0, r - l) <<   n ;     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int chkpower2(int x) { return (x && !(x & x - 1)); }   void solve() {     long long int n;     cin >> n;     long long int a[n], sum = 0;     for (int i1 = 0; i1 < n; i1++) {       cin >> a[i1];       sum += a[i1];     }     sort(a, a + n);     if (sum % (n - 1)) {       sum = sum / (n - 1) + 1;     } else {       sum = sum / (n - 1);     }     cout << max(a[n - 1], sum);     return;   }   int main() {     int t;     t = 1;     while (t--) {       solve();       cout <<   n ;     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   bool vowel(char a) {     a = toupper(a);     if ((a ==  A ) || (a ==  E ) || (a ==  I ) || (a ==  O ) || (a ==  U ))       return 1;     return 0;   }   long long int n, m, q, a, b, c, sum = 0, cnt = 0;   long long int arr[500055];   map<long long int, bool> mp;   string str;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cin >> n;     for (int i = 0; i < n; i++) {       cin >> arr[i];     }     bool one = 1, two = 1, tr = 1;     for (int i = 0; i < n; i++) {       if (arr[i] > arr[i - 1]) {         if (!tr || !two) {           cout <<  NO  << endl;           return 0;         }       }       if (arr[i] == arr[i - 1]) {         two = 0;         if (tr)           continue;         else {           cout <<  NO  << endl;           return 0;         }       }       if (arr[i] < arr[i - 1]) {         tr = 0;       }     }     cout <<  YES  << endl;   }


#include <bits/stdc++.h>   using namespace std;   void solve() {     long long n, m;     cin >> n >> m;     ;     int a[n + 1];     memset(a, 0, sizeof(a));     for (long long i = 0; i < m; i++) {       long long t;       cin >> t;       ;       for (long long j = t; j < n + 1; j++) {         if (a[j] == 0) a[j] = t;       }     }     for (long long i = 1; i < n + 1; i++) {       cout << a[i] <<    ;     }   }   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     solve();     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int N, K;   vector<int> tabs;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cin >> N >> K;     tabs.resize(N);     for (int i = 0; i < N; i++) cin >> tabs[i];     int most = 0;     for (int b = 0; b < N; b++) {       int sum = 0;       for (int i = 0; i < N; i++)         if (i % K != b % K) sum += tabs[i];       most = max(most, abs(sum));     }     cout << most <<   n ;   }


#include <bits/stdc++.h>   using namespace std;   template <typename T>   void setmax(T& x, T y) {     x = max(x, y);   }   template <typename T>   void setmin(T& x, T y) {     x = min(x, y);   }   const double PI = acos(-1.0);   const long long INF = 1e9 + 47;   const long long LINF = INF * INF;   mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());   const int N = 1e7 + 7;   int lp[N];   int main() {     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);     iota(lp, lp + N, 0);     for (int i = (2); i < (N); ++i)       if (lp[i] == i)         for (int j = i + i; j < N; j += i) setmin(lp[j], i);     int n;     cin >> n;     vector<pair<int, int> > ans(n, make_pair(-1, -1));     for (int i = (0); i < (n); ++i) {       int x;       cin >> x;       int p = lp[x];       int t = x;       while (t % p == 0) t /= p;       if (t > 1) {         ans[i] = {t, p};       }     }     for (int i = (0); i < (n); ++i) {       cout << ans[i].first <<    ;     }     cout << endl;     for (int i = (0); i < (n); ++i) {       cout << ans[i].second <<    ;     }     cout << endl;     cerr <<  Time elapsed:   << clock() / (double)CLOCKS_PER_SEC << endl;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int inf = 1 << 30;   const int md = 1e9 + 7;   const int N = 1e5 + 10;   int n, m;   int T;   int k;   long long p;   long long q[N];   long long ar[N];   int now = -1;   set<long long> se[N];   inline long long up(long long x, long long y) {     long long re = x / y - 1;     while (re * y < x) re++;     return re;   }   inline long long down(long long x, long long y) {     long long re = x / y + 1;     while (re * y > x) re--;     return re;   }   bool dfs(int x) {     if (x >= N - 5) return 0;     if (se[x].count(q[x])) return 0;     se[x].insert(q[x]);     if (0 <= q[x] && q[x] < k) {       now = x;       ar[0] = q[0] * k + p;       for (int i = 0; i <= x - 1; i++) ar[i + 1] = q[i] + q[i + 1] * k;       ar[x + 1] = q[x];       return 1;     }     for (q[x + 1] = up(-q[x], k); q[x + 1] <= 1 + down(-q[x], k); q[x + 1]++) {       if (dfs(x + 1)) return 1;     }     return 0;   }   void solve() {     long long l = up(-p, k);     long long r = 1 + down(-p, k);     for (q[0] = l; q[0] <= r; q[0]++)       if (dfs(0)) break;     if (now >= 0) {       now++;       while (ar[now] == 0) now--;       printf( %d n , now + 1);       for (int i = 0; i <= now; i++)         printf( %I64d%c , ar[i], i == now ? 10 :    );     } else {       puts( -1 );     }   }   int main() {     scanf( %I64d%d , &p, &k);     solve();     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int N = 5005;   int n, m, w, o[N], K[N], P[N], C[N];   int vis[N];   vector<int> adj[N];   void bfs(int src) {     for (int i = 0; i <= n; ++i) vis[i] = -1;     queue<int> q, qw;     q.push(src);     qw.push(0);     vis[src] = 0;     while (!q.empty()) {       int u = q.front();       q.pop();       int w = qw.front();       qw.pop();       for (auto v : adj[u]) {         if (vis[v] == -1) {           vis[v] = w + 1;           q.push(v);           qw.push(w + 1);         }       }     }   }   int q;   int main() {     scanf( %d%d , &n, &m);     for (int i = 0; i < m; ++i) {       int u, v;       scanf( %d%d , &u, &v);       adj[u].push_back(v);       adj[v].push_back(u);     }     scanf( %d , &w);     for (int i = 0; i < w; ++i) {       int c, k, p;       scanf( %d%d%d , &c, &k, &p);       o[i] = i;       K[i] = k;       P[i] = p;       C[i] = c;     }     sort(o, o + w, [](int i, int j) { return P[i] < P[j]; });     scanf( %d , &q);     while (q--) {       int g, r, a;       scanf( %d%d%d , &g, &r, &a);       int L = 0, R = n;       bfs(g);       while (L < R) {         int M = (L + R) / 2;         long long totalCost = 0;         int shovels = 0;         for (int i = 0; i < w; ++i) {           int id = o[i];           if (vis[C[id]] != -1 && vis[C[id]] <= M) {             int need = min(r - shovels, K[id]);             totalCost += 1ll * need * P[id];             shovels += need;             if (shovels >= r) break;           }         }         if (totalCost > a || shovels < r) {           L = M + 1;         } else {           R = M;         }       }       if (L == n) {         L = -1;       }       printf( %d n , L);     }   }


#include <bits/stdc++.h>   using namespace std;   int n;   void solve_1() {     if (n < 6) {       printf( -1 n );       return;     }     puts( 1 2 );     puts( 2 3 );     puts( 2 4 );     puts( 4 5 );     puts( 4 6 );     for (int i = 7; i <= n; i++) {       printf( 2 %d n , i);     }   }   void solve_2() {     for (int i = 2; i <= n; i++) {       printf( 1 %d n , i);     }   }   int main() {     scanf( %d , &n);     solve_1();     solve_2();   }


#include <bits/stdc++.h>   #define debug(x) cerr << #x <<   =   << x << endl   using namespace std;   typedef long long LL;   const int N = 400005;   int a[N], b[N], n;   vector<int> vec;      int main()   {       int T; scanf( %d , &T);       while(T--) {           vec.clear();           scanf( %d , &n);           for(int i = 1; i <= n; i++) scanf( %d , &a[i]);              //1           for(int i = 1; i <= n; i++) b[i] = a[i];           int pos = -1;           for(int i = 2; i <= n; i++) {               b[i] = b[i] - b[i - 1];               b[i - 1] -= b[i - 1];               if(b[i] < 0) {                   pos = i;                   break;               }           }           if(b[n]) {               if(pos == -1) pos = n;           }           if(pos == -1) {               puts( YES );               continue;           }           if(pos > 0) {               vec.push_back(pos);               for(int id = 1; id <= 10; id++) {                   vec.push_back(pos - id);                   vec.push_back(pos + id);               }           }              //2           pos = -1;           for(int i = 1; i <= n; i++) b[i] = a[i];           for(int i = n - 1; i >= 1; i--) {               b[i] = b[i] - b[i + 1];               b[i + 1] -= b[i + 1];               if(b[i] < 0) {                   pos = i;                   break;               }           }           if(b[1]) {               if(pos == -1) pos = 1;           }           if(pos > 0) {               vec.push_back(pos);               for(int id = 1; id <= 10; id++) {                   vec.push_back(pos - id);                   vec.push_back(pos + id);               }           }                 //3           for(int i = 1; i <= n; i++) b[i] = a[i];           pos = -1;           bool ok = false;           for(int i = 2; i <= n; i++) {               b[i] = b[i] - b[i - 1];               if(b[i] < 0) {                   if(!ok) pos = i, ok = true;               }           }           b[1] = 0;           if(b[n]) {               if(pos == -1) pos = n;           }           int tmp = b[n];   //        if(tmp % 2) {   //            puts( NO );   //            continue;   //        }           for(int i = n; i > 0; i -= 2) {               if(i <= pos) {                   if(a[i] - a[i + 1] == tmp / 2 || a[i] - a[i - 1] == tmp / 2) {                       vec.push_back(i);                       break;                   }               }           }                 int sz = vec.size();           bool flag = true;           for(int i = 0; i < sz; i++) {               int now = vec[i];               if(now < 1 || now > n) continue;               if(now > 1) {                   for(int j = 1; j <= n; j++) b[j] = a[j];                   flag = true;                   swap(b[now], b[now - 1]);                   for(int j = 2; j <= n; j++) {                       b[j] = b[j] - b[j - 1];                       b[j - 1] -= b[j - 1];                       if(b[j] < 0) {                           flag = false;                           break;                       }                   }                   if(b[n]) flag = false;                   if(flag) break;               }               if(now < n) {                      for(int j = 1; j <= n; j++) b[j] = a[j];                      flag = true;                      swap(b[now], b[now + 1]);                      for(int j = 2; j <= n; j++) {                       b[j] = b[j] - b[j - 1];                       b[j - 1] -= b[j - 1];                       if(b[j] < 0) {                           flag = false;                           break;                       }                   }                   if(b[n]) flag = false;                   if(flag) break;               }           }           if(!sz) flag = false;           if(flag) puts( YES );           else puts( NO );       }       return 0;   }


#include <bits/stdc++.h>   using namespace std;   struct debugger {     template <typename T>     debugger& operator,(const T& v) {       cerr << v <<   t ;       return *this;     }   } dbg;   template <class T>   void setmax(T& a, T b) {     if (a < b) a = b;   }   template <class T>   void setmin(T& a, T b) {     if (b < a) a = b;   }   template <class T>   T Abs(T x) {     return x > 0 ? x : -x;   }   template <class T>   inline T sqr(T x) {     return x * x;   }   template <class T>   inline T Mod(T n, T m) {     return (n % m + m) % m;   }   template <class T>   string toString(T n) {     ostringstream oss;     oss << n;     oss.flush();     return oss.str();   }   int toInt(string s) {     int r = 0;     istringstream sin(s);     sin >> r;     return r;   }   bool isVowel(char ch) {     ch = tolower(ch);     if (ch ==  a  || ch ==  e  || ch ==  i  || ch ==  o  || ch ==  u )       return true;     return false;   }   bool isUpper(char c) { return c >=  A  && c <=  Z ; }   bool isLower(char c) { return c >=  a  && c <=  z ; }   long long Pow(long long B, long long P) {     long long R = 1;     while (P > 0) {       if (P % 2 == 1) R = (R * B);       P /= 2;       B = (B * B);     }     return R;   }   int BigMod(long long B, long long P, long long M) {     long long R = 1;     while (P > 0) {       if (P % 2 == 1) {         R = (R * B) % M;       }       P /= 2;       B = (B * B) % M;     }     return (int)R;   }   void binprint(long long mask, long long n) {     long long i;     string s =   ;     do {       s += (mask % 2 +  0 );       mask /= 2;     } while (mask);     reverse(s.begin(), s.end());     s = string(max(n - (int)s.size(), 0LL),  0 ) + s;     for (i = (int)s.size() - n; i < (int)s.size(); i++) printf( %c , s[i]);     printf(  n );   }   void ASCII_Chart() {     int i, j, k;     printf( ASCII Chart:(30-129) n );     for (i = 30; i < 50; i++) {       for (j = 0; j < 5; j++) {         k = i + j * 20;         printf( %3d--->  %c     , k, k);       }       printf(  n );     }   }   struct edges {     int u, v, ind;     double w;     edges(int _u = 0, int _v = 0, double _w = 0, int _ind = 0) {       u = _u;       v = _v;       w = _w;       ind = _ind;     }   };   vector<edges> e, e1, e2;   int N, M, p[5050], cnt, K;   bool comp(edges p, edges q) { return p.w < q.w; }   void precalc() {     e1.clear();     e2.clear();     for (int i = 0; i < M; i++) {       if (e[i].u == 0 || e[i].v == 0)         e1.push_back(e[i]);       else         e2.push_back(e[i]);     }     sort(e1.begin(), e1.end(), comp);     sort(e2.begin(), e2.end(), comp);   }   void merge(vector<edges> e3) {     e.clear();     int i = 0, j = 0;     while (i < e2.size() && j < e3.size()) {       if (e2[i].w < e3[j].w)         e.push_back(e2[i++]);       else         e.push_back(e3[j++]);     }     for (; i < e2.size(); i++) e.push_back(e2[i]);     for (; j < e3.size(); j++) e.push_back(e3[j]);     return;   }   int find_parent(int u) {     if (u != p[u]) p[u] = find_parent(p[u]);     return p[u];   }   void Union(int a, int b) { p[b] = a; }   int calc_k(double x) {     int ret, i;     vector<edges> e3;     for (i = 0; i < e1.size(); i++) {       e3.push_back(e1[i]);       e3[i].w += x;     }     merge(e3);     for (i = 0; i < N; i++) p[i] = i;     cnt = ret = 0;     for (i = 0; i < M; i++) {       int a = find_parent(e[i].u);       int b = find_parent(e[i].v);       if (a != b) {         e[i].ind = -e[i].ind;         Union(a, b);         if (e[i].u == 0 || e[i].v == 0) ret++;         cnt++;       }     }     return ret;   }   bool solve() {     double low = -10001000, high = 10001000;     for (int i = 0; i < e1.size(); i++) e1[i].w += (i * 1e-7);     while (fabs(low - high) > 1e-7) {       double mid = (low + high) / 2;       if (calc_k(mid) > K)         low = mid;       else         high = mid;     }     if (calc_k(low) == K) return true;     return (calc_k(high) == K);   }   int main() {     int i, j, test, Case = 1, u, v, w;     test = 1;     while (test--) {       scanf( %d %d %d , &N, &M, &K);       e.clear();       for (i = 0; i < M; i++) {         scanf( %d %d %d , &u, &v, &w);         e.push_back(edges(u - 1, v - 1, w, i + 1));       }       if (K == 0) {         if (N <= 1)           printf( 0 n );         else           printf( -1 n );         continue;       }       precalc();       calc_k(0);       if (cnt != N - 1 || e1.size() < K) {         printf( -1.. n );         continue;       }       double total = 0;       int ind;       if (solve()) {         printf( %d n , N - 1);         for (i = 0; i < M; i++)           if (e[i].ind <= 0) {             printf( %d  , -e[i].ind);           }         printf(  n );       } else         printf( -1__- n );     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int head[2 * 200005], nex[2 * 200005], from[2 * 200005], to[2 * 200005], cnt, n;   int sn[200005], num[200005];   long long d[200005], ans;   void add(int u, int v) {     nex[++cnt] = head[u];     from[cnt] = u;     to[cnt] = v;     head[u] = cnt;     nex[++cnt] = head[v];     from[cnt] = v;     to[cnt] = u;     head[v] = cnt;   }   void dfs(int x, int p) {     sn[x] = 1;     for (int i = head[x]; i; i = nex[i]) {       int u = to[i];       if (u == p) continue;       dfs(u, x);       for (int j = head[u]; j; j = nex[j]) {         int v = to[j];         if (v == x) continue;         d[x] += d[v] + sn[v];       }       d[x]++;       sn[x] += sn[u];     }   }   void dfs2(int x, int p) {     ans += d[x];     for (int i = head[x]; i; i = nex[i]) {       int u = to[i];       if (u == p) continue;       for (int j = head[u]; j; j = nex[j]) {         int v = to[j];         if (v == x) continue;         d[v] = d[x] - sn[v] + n - sn[u];         dfs2(v, u);       }       if (p == 0) {         d[u]++;         dfs2(u, x);       }     }   }   int main() {     cin >> n;     int u, v;     for (int i = 1; i < n; i++) {       scanf( %d%d , &u, &v);       add(u, v);       num[u]++;       num[v]++;     }     int root;     for (int i = 1; i <= n; i++)       if (num[i] == 1) {         root = i;         break;       }     dfs(root, 0);     dfs2(root, 0);     cout << ans / 2 << endl;   }


#include <bits/stdc++.h>   #pragma GCC optimize( O3 )   #pragma comment(linker,  /STACK:100000000 )   const double pi = acos(-1);   const int MOD = 1e9 + 7;   const int INF = 1e9 + 7;   const int MAXN = 5e3 + 5;   const double eps = 1e-9;   using namespace std;   bool vis[MAXN];   int a[MAXN * 20], L[MAXN], R[MAXN], mx[MAXN];   double dp[MAXN][MAXN], P[MAXN], tmp2[MAXN];   set<int> ind;   int main() {     int n, q;     scanf( %d , &(n)), scanf( %d , &(q));     for (int i = 0; i < n; i++) ind.insert(i);     for (int i = 0; i < (n); i++) scanf( %d , &(a[i]));     for (int i = 0; i < q; i++) {       scanf( %d %d %lf , L + i, R + i, P + i);       L[i]--, R[i]--;       for (int j = 0; j < i; j++)         if (R[j] - L[j] > R[i] - L[i])           swap(L[i], L[j]), swap(R[i], R[j]), swap(P[i], P[j]);     }     L[q] = 0, R[q] = n - 1, P[q] = 0, q++;     for (int i = 0; i < q; i++) {       vector<int> tmp;       for (int j = 0; j < i; j++)         if (L[i] <= L[j] && R[j] <= R[i] && !vis[j]) {           vis[j] = 1;           tmp.push_back(j);           mx[i] = max(mx[i], mx[j]);         }       while (1) {         set<int>::iterator it = ind.lower_bound(L[i]);         if (it != ind.end() && *it <= R[i])           mx[i] = max(mx[i], a[*it]), ind.erase(it);         else           break;       }       for (int j = 0; j <= q; j++) tmp2[j] = 1;       for (int x = 0; x < tmp.size(); x++) {         int j = tmp[x];         for (int k = 0; k <= q; k++)           if (mx[i] + k - mx[j] <= q) tmp2[k] *= dp[j][mx[i] + k - mx[j]];       }       for (int j = q; j > 0; j--) tmp2[j] -= tmp2[j - 1];       dp[i][0] = (1 - P[i]) * tmp2[0];       for (int j = 1; j <= q; j++)         dp[i][j] = dp[i][j - 1] + P[i] * tmp2[j - 1] + (1 - P[i]) * tmp2[j];     }     double ans = dp[q - 1][0] * mx[q - 1];     for (int i = 1; i <= q; i++)       ans += (dp[q - 1][i] - dp[q - 1][i - 1]) * (mx[q - 1] + i);     printf( %.15f n , ans);     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     scanf( %d , &n);     int num = sqrt(n);     if (num * num == n) {       for (int i = n - num + 1; i >= 1; i -= num) {         for (int j = 0; j < num; j++) {           printf( %d  , i + j);         }       }       printf(  n );       return 0;     } else {       int index1 = n / num;       int index2 = n % num;       for (int i = index1 * num + 1; i <= n; i++) printf( %d  , i);       for (int i = n - index2 - num + 1; i >= 1; i -= num) {         for (int j = 0; j < num; j++) printf( %d  , i + j);       }     }   }


#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     cout.tie(nullptr);     int n;     cin >> n;     vector<pair<int, int>> a(n);     for (int i = 0; i < n; i++) {       cin >> a[i].first;     }     for (int i = 0; i < n; i++) {       cin >> a[i].second;     }     sort(a.begin(), a.end());     a.push_back(make_pair(static_cast<int>(2e9), 0));     n++;     multiset<int> s;     int recent = 0;     long long ans = 0LL, sum = 0LL;     for (int i = 0; i < n; i++) {       while (a[i].first > recent && s.size()) {         recent++;         auto it = prev(s.end());         sum -= *it;         ans += sum;         s.erase(it);       }       recent = a[i].first;       sum += a[i].second;       s.insert(a[i].second);     }     cout << ans <<   n ;     return 0;   }


#include <bits/stdc++.h>   int main() {     int t;     scanf( %d , &t);     while (t--) {       int n;       scanf( %d , &n);       int k;       int a[n];       for (k = 0; k < n; k++) scanf( %d , &a[k]);       int p = n - 2;       int i, j;       for (i = 0; i < p; i++) {         for (j = i + 2; j < n; j++) {           if (a[i] == a[j]) {             printf( YES n );             break;           }         }         if (a[i] == a[j]) {           break;         }       }       if (a[i] == a[j]) continue;       printf( NO n );     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     int n, performance;     long long cost = 0;     long long k;     cin >> n >> k;     int x[n], c[n];     for (int& e : x) cin >> e;     cin >> performance;     for (int& e : c) cin >> e;     priority_queue<int, vector<int>, greater<int>> rem;     int i = 0;     for (int e : x) {       rem.push(c[i++]);       while (k < e) {         if (rem.empty()) {           cout <<  -1 n ;           return 0;         }         k += performance, cost += rem.top(), rem.pop();       }     }     cout << cost <<   n ;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   struct dame {     int b, i, r;     dame() {}     dame(int b_, int i_, int r_) : b(b_), i(i_), r(r_) {}   };   bool greater_compare(dame A, dame B) {     return A.b > B.b || A.b == B.b && A.i < B.i ||            A.b == B.b && A.i == B.i && A.r < B.r;   }   bool by_i(dame a, dame b) { return a.i < b.i; }   int size = 2;   vector<int> tree;   void update(int pos, int value) {     pos += size;     if (value <= tree[pos]) return;     tree[pos] = value;     pos /= 2;     while (pos > 0) {       tree[pos] = max(tree[pos * 2], tree[pos * 2 + 1]);       pos /= 2;     }   }   int getmax(int l, int r, int i = 1, int a = 0, int b = size - 1) {     if (l > r) return 0;     if (l == a && r == b) return tree[i];     int center = (a + b) / 2;     if (r <= center) return getmax(l, r, i * 2, a, center);     if (l > center) return getmax(l, r, i * 2 + 1, center + 1, b);     return max(getmax(l, center, i * 2, a, center),                getmax(center + 1, r, i * 2 + 1, center + 1, b));   }   int main() {     int n, answer = 0;     scanf( %d , &n);     while (size < n) size *= 2;     vector<dame> dames(n);     tree = vector<int>(size * 2, 0);     for (int i = 0; i < n; i++) scanf( %d , &dames[i].b);     for (int i = 0; i < n; i++) scanf( %d , &dames[i].i);     for (int i = 0; i < n; i++) scanf( %d , &dames[i].r);     sort(dames.begin(), dames.end(), by_i);     int compress_val = -1, prev = -1;     for (int i = 0; i < n; i++) {       if (dames[i].i != prev) compress_val++;       prev = dames[i].i;       dames[i].i = compress_val;     }     sort(dames.begin(), dames.end(), greater_compare);     for (int i = 0; i < n; i++) {       int max_r = getmax(dames[i].i + 1, n - 1);       if (max_r > dames[i].r) answer++;       update(dames[i].i, dames[i].r);     }     printf( %d n , answer);   }


#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     cout <<  INTERCAL ;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const long double PI = 3.1415926535897932384626433832795;   template <typename S, typename T>   ostream& operator<<(ostream& out, pair<S, T> const& p) {     out <<  (  << p.first <<  ,   << p.second <<  ) ;     return out;   }   template <typename T>   ostream& operator<<(ostream& out, vector<T> const& v) {     int l = v.size();     for (int i = 0; i < l - 1; i++) out << v[i] <<    ;     if (l > 0) out << v[l - 1];     return out;   }   void tr() { cout << endl; }   template <typename S, typename... Strings>   void tr(S x, const Strings&... rest) {     cout << x <<    ;     tr(rest...);   }   long long fast(long long a, long long b, long long MOD) {     long long ret = 1;     while (b) {       if ((b & 1)) ret = (ret * a) % MOD;       a = (a * a) % MOD;       b >>= 1;     }     return ret;   }   const long long MOD = 1e6 + 3;   int main() {     long long n, k;     cin >> n >> k;     if (n <= 59 and (1ll << n) < k) {       cout << 1 <<     << 1 << endl;       return 0;     }     long long a, b;     b = fast(2, n, MOD);     b = fast(b, k - 1, MOD);     a = 1;     long long x = (k - 1) / MOD;     long long y = (k - 1) % MOD;     long long t = fast(2, n, MOD);     for (int i = 1; i <= MOD; i++) {       a *= (t - i + MOD) % MOD;       a %= MOD;     }     a = fast(a, x, MOD);     for (int i = 1; i <= y; i++) {       a *= (t - i + MOD) % MOD;       a %= MOD;     }     long long tot = 0, tmp = k - 1, pw = 2;     while (pw <= tmp) {       tot += tmp / pw;       pw <<= 1;     }     a = a * fast(fast(2, tot, MOD), MOD - 2, MOD) % MOD;     b = b * fast(fast(2, tot, MOD), MOD - 2, MOD) % MOD;     a = (b - a + MOD) % MOD;     cout << a <<     << b << endl;     return 0;   }


#include <bits/stdc++.h>   using namespace std;      /*DEBUGGER*/   #define deb(x) cout << #x <<  =  << x << endl   #define deb2(x, y) cout << #x <<  =  << x <<  ,  << #y <<  =  << y << endl      typedef long long ll;   typedef pair<int, int> pii;   typedef pair<ll, ll> pll;   typedef pair<string, string> pss;   typedef vector<int> vi;   typedef vector<vi> vvi;   typedef vector<pii> vii;   typedef vector<ll> vll;   typedef vector<vll> vvll;      #define fl(i, a, n) for (int i = a; i < n; i++)   #define fll(i, a, n) for (ll i = a; i < n; i++)   #define tr(it, a) for (auto it = a.begin(); it != a.end(); it++)   #define all(c) c.begin(), c.end()   #define sz(a) int((a).size())   #define pb push_back   #define mp make_pair   #define F first   #define S second   #define getUnique(c)  {sort(all(c));c.erase(unique(all(c)), c.end())}   #define MOD 1000000007   #define PI 3.14159265358979323846   #define INF 2000000000000000000      /*TEMPLATES*/   template <typename A>   ostream &operator<<(ostream &cout, vector<A> const &v)   {       cout <<  [ ;       for (int i = 0; i < sz(v); i++)       {           if (i)               cout <<  ,  ;           cout << v[i];       }       return cout <<  ] ;   }   template <typename A, typename B>   ostream &operator<<(ostream &cout, pair<A, B> const &p) { return cout <<  (  << p.F <<  ,   << p.S <<  ) ; }   template <typename A, typename B>   istream &operator>>(istream &cin, pair<A, B> &p)   {       cin >> p.F;       return cin >> p.S;   }      /*NUMBER THEORY*/   namespace number_theory   {       ll gcd(ll x, ll y)       {           if (x == 0)               return y;           if (y == 0)               return x;           return gcd(y, x % y);       }          bool isPrime(ll n)       {           if (n <= 1)               return false;           if (n <= 3)               return true;              if (n % 2 == 0 || n % 3 == 0)               return false;              for (ll i = 5; i * i <= n; i += 6)               if (n % i == 0 || n % (i + 2) == 0)                   return false;              return true;       }          bool prime[15000105];       void sieve(int n)       {           for (ll i = 0; i <= n; i++)               prime[i] = 1;           for (ll p = 2; p * p <= n; p++)           {               if (prime[p] == true)               {                   for (ll i = p * p; i <= n; i += p)                       prime[i] = false;               }           }           prime[1] = prime[0] = 0;       }       vll primelist;       bool __primes_generated__ = 0;          void genprimes(int n)       {           __primes_generated__ = 1;           sieve(n + 1);           for (ll i = 2; i <= n; i++)               if (prime[i])                   primelist.push_back(i);       }          vll factors(ll n)       {           if (!__primes_generated__)           {               exit(1);           }           vll facs;              for (ll i = 0; primelist[i] * primelist[i] <= n && i < primelist.size(); i++)           {               if (n % primelist[i] == 0)               {                   while (n % primelist[i] == 0)                   {                       n /= primelist[i];                       facs.pb(primelist[i]);                   }               }           }           if (n > 1)           {               facs.pb(n);           }           sort(all(facs));           return facs;       }   }       using namespace number_theory;      void kkvanonymous()   {       ios_base::sync_with_stdio(0);       cin.tie(0);       cout.tie(0);       genprimes(1.5e6);          //#ifdef ONLINE_JUDGE       //    freopen( input.txt ,  r , stdin);       //    freopen( output.txt ,  w , stdout);       //#endif   }   bool sortbysec(const pair<int,int> &a,                  const pair<int,int> &b)    {        return (a.second < b.second);    }      void solve(){       ll a,b,n;       cin>>a>>b>>n;       vll p(n);       vll h(n);           ll m=-1;       fll(i,0,n){           cin>>p[i];           m=max(m,p[i]);       }       fll(i,0,n){           cin>>h[i];       }       fll(i,0,n){           ll t=ceil(double(h[i])/a);           b-=p[i]*t;       }       if(b+m>0) cout<< YES n ;       else cout<< NO n ;      }      int main()   {   #ifdef kkvanonymous_time       auto begin = chrono::high_resolution_clock::now();   #endif       kkvanonymous();          int t = 1;       cin>>t;       while (t--)           solve();      #ifdef kkvanonymous_time       auto end = chrono::high_resolution_clock::now();       cout << setprecision(4) << fixed;       cout <<   nExecution time:   << chrono::duration_cast<std::chrono::duration<double>>(end - begin).count() <<   seconds  << endl;   #endif       return 0;   }


#include <bits/stdc++.h>   long long int trie[10000007][2] = {0};   long long int bin[40] = {0}, x = 0;   long long int a[100005] = {0}, prefix[100005] = {0}, suffix[100005] = {0};   void tobinary(long long int x) {     int cnt = 0;     memset(bin, 0, sizeof(bin));     while (x > 0) {       bin[cnt++] = (x % 2);       x /= 2;     }   }   void update(long long int node, long long int idx) {     if (idx < 0) return;     if (bin[idx] == 0) {       if (trie[node][0] == -1) {         trie[node][0] = ++x;       }       update(trie[node][0], idx - 1);     } else {       if (trie[node][1] == -1) {         trie[node][1] = ++x;       }       update(trie[node][1], idx - 1);     }   }   long long int query(long long int node, long long int idx) {     if (idx < 0) return 0LL;     long long int ret = 0;     if (bin[idx] == 0) {       if (trie[node][1] != -1) {         ret += ((1LL) << idx);         ret += query(trie[node][1], idx - 1);       } else {         ret += query(trie[node][0], idx - 1);       }     } else {       if (trie[node][0] != -1) {         ret += (1LL << idx);         ret += query(trie[node][0], idx - 1);       } else {         ret += query(trie[node][1], idx - 1);       }     }     return ret;   }   int main() {     memset(trie, -1, sizeof(trie));     long long int n, i, ans = 0;     scanf( %I64d , &n);     for (i = 1; i <= n; i++) {       scanf( %I64d , &a[i]);       prefix[i] = a[i] ^ prefix[i - 1];     }     for (i = n; i >= 1; i--) {       suffix[i] = suffix[i + 1] ^ a[i];     }     for (i = 0; i <= n; i++) {       tobinary(prefix[i]);       update(0, 39);       tobinary(suffix[i + 1]);       ans = (ans > query(0, 39) ? ans : query(0, 39));     }     printf( %I64d n , ans);     return 0;   }


#include <bits/stdc++.h>   #pragma GCC optimize( Ofast,no-stack-protector,unroll-loops,fast-math )   #pragma GCC target(         sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,avx2,popcnt,tune=native )   static int a[100001], n, m, l, r, x, cnt;   static bool type;   inline static int read() {     register int x = 0;     static char ch = getchar();     while (ch <  0  || ch >  9 ) ch = getchar();     while (ch >=  0  && ch <=  9 )       x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();     return x;   }   signed main(void) {     n = read(), m = read();     for (register int i = 1; i <= n; ++i) a[i] = read();     for (; m--;) {       type = (read() == 1);       l = read(), r = read(), x = read();       if (type)         for (register int i = l; i <= r; ++i) a[i] -= (a[i] > x) ? x : 0;       else {         cnt = 0;         for (register int i = l; i <= r; ++i) cnt += (a[i] == x);         printf( %d n , cnt);       }     }   }


#include <bits/stdc++.h>   using namespace std;   int n;   vector<pair<int, int> > v;   long long dp[2][5001][51][51];   const long long oo = 1e16;   int main() {     cin >> n;     v.resize(n);     for (auto &x : v) cin >> x.first;     int total = 0;     for (auto &x : v) {       cin >> x.second;       total += x.second;     }     vector<int> bef(n, 1);     sort(v.rbegin(), v.rend());     for (int i = 1; i < n; ++i)       if (v[i - 1].first == v[i].first) bef[i] += bef[i - 1];     bef.push_back(1);     v.push_back(make_pair(-1, -1));     for (int i = n; i >= 0; --i) {       for (int rem = total; rem >= 0; --rem) {         for (int g = 0; g <= i; ++g) {           int me = bef[i];           for (int cg = 0; cg < me; ++cg) {             long long ret = oo;             if (i == n) {               if (rem == 0) ret = 0;             } else {               const bool ch = v[i + 1].first != v[i].first;               if (g > 0) {                 if (ch)                   ret = dp[1 & ~i][rem][g - 1 + cg][0];                 else                   ret = dp[1 & ~i][rem][g - 1][cg];               }               if (rem >= v[i].second) {                 if (ch)                   ret =                       min(ret, v[i].first +                                    dp[1 & ~i][rem - v[i].second][g + cg + 1][0]);                 else                   ret = min(                       ret, v[i].first + dp[1 & ~i][rem - v[i].second][g][cg + 1]);               }             }             dp[i & 1][rem][g][cg] = ret;           }         }       }     }     pair<long long, long long> ans;     long long res = -1;     for (int i = 1; i <= total; ++i) {       long long cur = dp[0][i][0][0];       if (cur == oo) continue;       if (res == -1) {         ans.first = cur;         ans.second = i;         res = 0;       } else {         if (ans.first * i <= cur * ans.second) continue;         ans.first = cur;         ans.second = i;       }     }     res = ans.first * 10000;     res = (res + ans.second - 1) / ans.second;     int add = res % 10 > 0;     res = res / 10 + add;     cout << res << endl;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       string s;       cin >> s;       int o = 0, t = 0, to = 0;       int n = s.length();       for (int i = 0; i < n; i++) {         if (s.substr(i, 3) ==  one ) {           o++;           i++;         } else if (s.substr(i, 5) ==  twone ) {           to++;           i += 3;         } else if (s.substr(i, 3) ==  two ) {           t++;           i++;         }       }       cout << to + o + t << endl;       for (int i = 0; i < n; i++) {         if (s.substr(i, 3) ==  one ) {           cout << i + 2 <<    ;           i++;         } else if (s.substr(i, 5) ==  twone ) {           cout << i + 3 <<    ;           i += 3;         } else if (s.substr(i, 3) ==  two ) {           cout << i + 2 <<    ;           i++;         }       }       cout << endl;     }   }


#include <bits/stdc++.h>   using namespace std;   char t[200002];   struct node {     int nt[5][5];   };   node st[4 * 200000 + 2];   node merge(node a, node b) {     if (a.nt[0][0] == -1) return b;     if (b.nt[0][0] == -1) return a;     node ans;     for (int i = 0; i <= 4; i++)       for (int j = 0; j <= 4; j++) ans.nt[i][j] = -1e9;     for (int i = 0; i <= 4; i++) {       for (int j = i; j <= 4; j++) {         ans.nt[i][j] = max(ans.nt[i][j], a.nt[i][j]);         ans.nt[i][j] = max(ans.nt[i][j], b.nt[i][j]);         for (int k = i; k <= j; k++) {           ans.nt[i][j] = max(ans.nt[i][j], a.nt[i][k] + b.nt[k][j]);         }       }     }     return ans;   }   void build(int n, int s, int e) {     if (s == e) {       for (int i = 0; i <= 4; i++)         for (int j = 0; j <= 4; j++) st[n].nt[i][j] = -1e9;       for (int i = 0; i <= 4; i++) st[n].nt[i][i] = 1;       if (t[s] ==  2 ) {         st[n].nt[0][1] = 1;         st[n].nt[0][0] = -1e9;       } else if (t[s] ==  0 ) {         st[n].nt[1][2] = 1;         st[n].nt[1][1] = -1e9;       } else if (t[s] ==  1 ) {         st[n].nt[2][3] = 1;         st[n].nt[2][2] = -1e9;       } else if (t[s] ==  7 ) {         st[n].nt[3][4] = 1;         st[n].nt[3][3] = -1e9;       } else if (t[s] ==  6 ) {         st[n].nt[3][3] = -1e9;         st[n].nt[4][4] = -1e9;       }     } else {       int mid = (s + e) / 2;       build(n + n, s, mid);       build(n + n + 1, mid + 1, e);       st[n] = merge(st[n + n], st[n + n + 1]);     }   }   node query(int n, int s, int e, int l, int r) {     if (s > r || l > e) {       node ans;       ans.nt[0][0] = -1;       return ans;     }     if (l <= s && e <= r) return st[n];     int mid = (s + e) / 2;     return merge(query(n + n, s, mid, l, r), query(n + n + 1, mid + 1, e, l, r));   }   int main() {     int n, q;     scanf( %d%d , &n, &q);     scanf( %s , t + 1);     build(1, 1, n);     for (int i = 1; i <= q; i++) {       int l, r;       scanf( %d%d , &l, &r);       node ans = query(1, 1, n, l, r);       if (ans.nt[0][4] < 0)         printf( -1 n );       else         printf( %d n , r - l + 1 - ans.nt[0][4]);     }   }


#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n, k, m, t;     cin >> n >> k >> m >> t;     while (t--) {       int x, y;       cin >> x >> y;       if (x == 1) {         if (y <= k) k++;         n++;       } else {         if (y < k)           k -= y, n -= y;         else           n = y;       }       cout << n <<     << k <<   n ;     }   }


#include <bits/stdc++.h>   using namespace std;   const int M = 1e9 + 7;   int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};   int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};   int expo(int x, int y) {     int res = 1;     x = x % M;     while (y > 0) {       if (y & 1) res = (1ll * res * x) % M;       y = y >> 1;       x = (1ll * x * x) % M;     }     return res;   }   const int N = 1e3 + 5;   int n, m, a[1000005];   int dp[N][N];   int rec(int s, int mod) {     if (mod == 0) return 1;     if (s >= n) return 0;     if (dp[s][mod] != -1) return dp[s][mod];     dp[s][mod] = 0;     dp[s][mod] |= rec(s + 1, (mod - a[s] + m) % m);     dp[s][mod] |= rec(s + 1, mod);     return dp[s][mod];   }   signed main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     int t = 1;     while (t--) {       cin >> n >> m;       for (int i = 0; i < n; i++) {         cin >> a[i];         a[i] %= m;       }       if (n > m) return cout <<  YES , 0;       memset(dp, -1, sizeof dp);       int chk = rec(0, m);       if (chk)         cout <<  YES ;       else         cout <<  NO ;     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   constexpr int MOD = 998244353;   int main() {     int R, C;     cin >> R >> C;     int X = 1;     while (R--) X = (2 * X) % MOD;     while (C--) X = (2 * X) % MOD;     cout << X << endl;   }


#include <bits/stdc++.h>   using namespace std;   template <typename Arg1>   void __f(const char* name, Arg1&& arg1) {     cerr << name <<   :   << arg1 << std::endl;   }   template <typename Arg1, typename... Args>   void __f(const char* names, Arg1&& arg1, Args&&... args) {     const char* comma = strchr(names + 1,  , );     cerr.write(names, comma - names) <<   :   << arg1 <<   |  ;     __f(comma + 1, args...);   }   int a[1003][1003];   int main() {     int n;     long long int cnt = 0;     cin >> n;     for (int i = 0; i < n; i++) {       int x, y;       cin >> x >> y;       a[x][y] = 1;     }     long long int p, q, fl;     for (int i = 0; i <= 1000; i++) {       p = 0;       q = i;       fl = 0;       while (p <= 1000 and q <= 1000) {         if (a[p][q]) fl++;         p++;         q++;       }       cnt += (fl * (fl - 1)) / 2;       if (i) {         p = i;         q = 0;         fl = 0;         while (p <= 1000 and q <= 1000) {           if (a[p][q]) fl++;           p++;           q++;         }         cnt += (fl * (fl - 1)) / 2;       }       p = 0;       q = i;       fl = 0;       while (p <= 1000 and q >= 0) {         if (a[p][q]) fl++;         p++;         q--;       }       cnt += (fl * (fl - 1)) / 2;       if (i) {         p = i;         q = 1000;         fl = 0;         while (p <= 1000 and q >= 0) {           if (a[p][q]) fl++;           p++;           q--;         }         cnt += (fl * (fl - 1)) / 2;       }     }     cout << cnt << endl;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     int n, m;     cin >> n >> m;     vector<vector<pair<int, int>>> g(n);     vector<int> goes(m, -1);     vector<int> offset(m);     vector<int> from(m);     vector<int> to(m);     for (int i = 0; i < m; ++i) {       int v, u;       cin >> v >> u;       from[i] = --v;       to[i] = --u;       g[v].emplace_back(u, i);       g[u].emplace_back(v, i);     }     vector<int> pr(n, -1);     vector<int> dfn(n, -1);     vector<int> low(n, -1);     vector<int> val(n, -1);     int tt = 0;     function<void(int)> tarjan = [&](int v) {       dfn[v] = low[v] = tt++;       for (auto e : g[v]) {         int u = e.first;         int w = e.second;         if (u != pr[v]) {           if (dfn[u] == -1) {             pr[u] = v;             val[u] = w;             tarjan(u);             low[v] = min(low[v], low[u]);           } else {             low[v] = min(low[v], dfn[u]);           }         }       }       for (auto e : g[v]) {         int u = e.first;         int w = e.second;         if (pr[u] != v && dfn[v] < dfn[u]) {           vector<int> cycle;           cycle.push_back(w);           for (int t = u; t != v; t = pr[t]) {             cycle.push_back(val[t]);           }           rotate(cycle.begin(), min_element(cycle.begin(), cycle.end()),                  cycle.end());           int p = max_element(cycle.begin(), cycle.end()) - cycle.begin();           bool valid = true;           for (int i = 0; i < p - 1; ++i) {             if (cycle[i] > cycle[i + 1]) {               valid = false;               break;             }           }           for (int i = p; i < (int)cycle.size() - 1; ++i) {             if (cycle[i] < cycle[i + 1]) {               valid = false;               break;             }           }           if (valid) {             goes[cycle[p]] = cycle[0];           }         }       }     };     tarjan(0);     vector<int> dp(n, 1);     for (int i = m - 1; ~i; --i) {       int v = from[i];       int u = to[i];       int w = dp[v] + dp[u] - offset[i];       dp[v] = dp[u] = w;       if (goes[i] != -1) {         offset[goes[i]] = w;       }     }     for (int i = 0; i < n; ++i) {       if (i) {         cout <<    ;       }       cout << dp[i] - 1;     }     cout <<   n ;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const long long inf = 3 * 1e18;   long long mi[5], ma[5], low[5], high[5];   long long resx, resy, resz;   long long div2(long long x, long long y) {     if (x > 0 && y > 0 || x < 0 && y < 0) {       long long f = 0;       if (x % 2 && y % 2) f = 1;       if (x > 0 && y > 0)         return x / 2 + y / 2 + f;       else         return x / 2 + y / 2 - f;     } else       return (x + y) / 2;   }   void update(long long s, long long d) {     resy = div2(s, d);     resz = div2(s, -d);   }   bool check(long long x) {     for (int i = 1; i <= 4; i++) {       low[i] = ma[i] - x;       high[i] = mi[i] + x;       if (low[i] > high[i]) return false;     }     long long x1 = div2(low[1], -high[2]);     long long y1 = div2(high[1], -low[2]);     long long x2 = div2(low[3], -high[4]);     long long y2 = div2(high[3], -low[4]);     long long x3 = max(x1, x2);     long long y3 = min(y1, y2);     if (x3 > y3) return false;     for (long long i = x3; i <= y3; i++) {       resx = i;       long long s1 = max(low[1] - i, low[2] + i);       long long s2 = min(high[1] - i, high[2] + i);       long long d1 = max(low[3] - i, low[4] + i);       long long d2 = min(high[3] - i, high[4] + i);       if (s1 > s2 || d1 > d2) continue;       if (s1 < s2) {         if ((s1 & 1) == (d1 & 1))           update(s1, d1);         else           update(s1 + 1, d1);         return true;       } else if (d1 < d2) {         if ((s1 & 1) == (d1 & 1))           update(s1, d1);         else           update(s1, d1 + 1);         return true;       } else {         if ((s1 & 1) == (d1 & 1)) {           update(s1, d1);           return true;         }       }     }     return false;   }   int main() {     int T;     cin >> T;     while (T--) {       int n;       scanf( %d , &n);       for (int i = 1; i <= 4; i++) {         mi[i] = inf;         ma[i] = -inf;       }       for (int i = 0; i < n; i++) {         long long x, y, z;         scanf( %I64d%I64d%I64d , &x, &y, &z);         mi[1] = min(mi[1], x + y + z);         ma[1] = max(ma[1], x + y + z);         mi[2] = min(mi[2], -x + y + z);         ma[2] = max(ma[2], -x + y + z);         mi[3] = min(mi[3], x + y - z);         ma[3] = max(ma[3], x + y - z);         mi[4] = min(mi[4], -x + y - z);         ma[4] = max(ma[4], -x + y - z);       }       long long L = -1, R = inf;       while (R - L > 1) {         long long M = (L + R) >> 1;         if (check(M))           R = M;         else           L = M;       }       check(R);       printf( %I64d %I64d %I64d n , resx, resy, resz);     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int MOD = (int)1e9 + 7;   const int FFTMOD = 119 << 23 | 1;   const int INF = (int)1e9 + 23111992;   const long long LINF = (long long)1e18 + 23111992;   const long double PI = acos((long double)-1);   const long double EPS = 1e-9;   inline long long gcd(long long a, long long b) {     long long r;     while (b) {       r = a % b;       a = b;       b = r;     }     return a;   }   inline long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }   inline long long fpow(long long n, long long k, int p = MOD) {     long long r = 1;     for (; k; k >>= 1) {       if (k & 1) r = r * n % p;       n = n * n % p;     }     return r;   }   template <class T>   inline int chkmin(T& a, const T& val) {     return val < a ? a = val, 1 : 0;   }   template <class T>   inline int chkmax(T& a, const T& val) {     return a < val ? a = val, 1 : 0;   }   inline unsigned long long isqrt(unsigned long long k) {     unsigned long long r = sqrt(k) + 1;     while (r * r > k) r--;     return r;   }   inline long long icbrt(long long k) {     long long r = cbrt(k) + 1;     while (r * r * r > k) r--;     return r;   }   inline void addmod(int& a, int val, int p = MOD) {     if ((a = (a + val)) >= p) a -= p;   }   inline void submod(int& a, int val, int p = MOD) {     if ((a = (a - val)) < 0) a += p;   }   inline int mult(int a, int b, int p = MOD) { return (long long)a * b % p; }   inline int inv(int a, int p = MOD) { return fpow(a, p - 2, p); }   inline int sign(long double x) { return x < -EPS ? -1 : x > +EPS; }   inline int sign(long double x, long double y) { return sign(x - y); }   mt19937 mt(chrono::high_resolution_clock::now().time_since_epoch().count());   inline int myrand() { return abs((int)mt()); }   struct KMP {     string s;     int n;     vector<int> link;     void build(char* str) {       s = str, n = (int)s.size();       link.resize(n);       int cur = link[0] = -1;       for (int i = 1; i < n; i++) {         while (cur >= 0 && s[i] != s[cur + 1]) cur = link[cur];         if (s[i] == s[cur + 1]) cur++;         link[i] = cur;       }     }     vector<int> query(char* t) {       vector<int> res;       int k = strlen(t);       int cur = -1;       for (int i = 0; i < k; i++) {         while (cur >= 0 && t[i] != s[cur + 1]) cur = link[cur];         if (t[i] == s[cur + 1]) cur++;         if (cur == n - 1) {           res.push_back(i - n + 1);           cur = link[cur];         }       }       return res;     }   } kmp;   const int maxn = 1e5 + 5;   const int logn = 20;   int pr, base;   int pr2, base2;   int n, q;   vector<pair<int, char> > adj[maxn];   int u[maxn];   int v[maxn];   string s[maxn];   int lev[maxn];   int par[logn][maxn];   pair<int, int> g[maxn];   pair<int, int> gi[maxn];   vector<pair<int, int> > vals;   int res[maxn];   vector<pair<int, pair<int, int> > > que[maxn];   char from[maxn];   void dfs(int u, int dad) {     for (int i = (1); i < (logn); ++i) par[i][u] = par[i - 1][par[i - 1][u]];     for (auto e : adj[u]) {       int v = e.first;       char c = e.second;       if (v != dad) {         lev[v] = lev[u] + 1;         par[0][v] = u;         from[v] = c;         dfs(v, u);       }     }   }   int lca(int u, int v) {     if (lev[u] < lev[v]) swap(u, v);     for (int i = (logn)-1; i >= (0); --i) {       if (lev[par[i][u]] >= lev[v]) {         u = par[i][u];       }     }     if (u == v) return u;     for (int i = (logn)-1; i >= (0); --i) {       if (par[i][u] != par[i][v]) {         u = par[i][u];         v = par[i][v];       }     }     return par[0][u];   }   int jump(int u, int k) {     for (int i = (logn)-1; i >= (0); --i) {       if ((1 << i) <= k) {         k -= 1 << i;         u = par[i][u];       }     }     return u;   }   int cnt[maxn * 2];   void upd_dfs(int u, int dad) {     int w = u, rt = 0;     pair<int, int> hs = make_pair(0, 0);     for (int i = (0); i < (min(100, lev[u])); ++i) {       char c = from[w];       hs.first = mult(hs.first, base, pr);       addmod(hs.first, c, pr);       hs.second = mult(hs.second, base2, pr2);       addmod(hs.second, c, pr2);       int k = lower_bound((vals).begin(), (vals).end(), hs) - vals.begin();       if (k < int((vals).size()) && vals[k] == hs) {         cnt[k]++;       }       w = par[0][w];     }     for (auto it : que[u]) {       int ix = it.first;       int u = it.second.first;       int s = it.second.second;       res[ix] += cnt[u] * s;     }     for (auto e : adj[u]) {       int v = e.first;       if (v != dad) {         upd_dfs(v, u);       }     }     w = u, rt = 0;     hs = make_pair(0, 0);     for (int i = (0); i < (min(100, lev[u])); ++i) {       char c = from[w];       hs.first = mult(hs.first, base, pr);       addmod(hs.first, c, pr);       hs.second = mult(hs.second, base2, pr2);       addmod(hs.second, c, pr2);       int k = lower_bound((vals).begin(), (vals).end(), hs) - vals.begin();       if (k < int((vals).size()) && vals[k] == hs) {         cnt[k]--;       }       w = par[0][w];     }   }   int ispr(int k) {     for (int i = 2; i * i <= k; i++) {       if (k % i == 0) {         return 0;       }     }     return 1;   }   void chemthan() {     pr = INF + myrand() % (INF / 100);     while (!ispr(pr)) pr++;     base = 1234 + myrand() % 1234;     pr2 = INF + myrand() % (INF / 100);     while (!ispr(pr2)) pr2++;     base2 = 1234 + myrand() % 1234;     cin >> n;     for (int i = (0); i < (n - 1); ++i) {       int u, v;       char c;       cin >> u >> v >> c;       u--, v--;       adj[u].push_back(make_pair(v, c));       adj[v].push_back(make_pair(u, c));     }     cin >> q;     for (int i = (0); i < (q); ++i) {       cin >> u[i] >> v[i] >> s[i], u[i]--, v[i]--;       reverse((s[i]).begin(), (s[i]).end());       for (char c : s[i]) {         g[i].first = mult(g[i].first, base, pr);         addmod(g[i].first, c, pr);         g[i].second = mult(g[i].second, base2, pr2);         addmod(g[i].second, c, pr2);       }       reverse((s[i]).begin(), (s[i]).end());       for (char c : s[i]) {         gi[i].first = mult(gi[i].first, base, pr);         addmod(gi[i].first, c, pr);         gi[i].second = mult(gi[i].second, base2, pr2);         addmod(gi[i].second, c, pr2);       }       vals.push_back(g[i]), vals.push_back(gi[i]);     }     sort((vals).begin(), (vals).end()),         (vals).erase(unique((vals).begin(), (vals).end()), (vals).end());     static int h[maxn];     static int hi[maxn];     for (int i = (0); i < (q); ++i)       h[i] = lower_bound((vals).begin(), (vals).end(), g[i]) - vals.begin();     for (int i = (0); i < (q); ++i)       hi[i] = lower_bound((vals).begin(), (vals).end(), gi[i]) - vals.begin();     dfs(0, -1);     for (int i = (0); i < (q); ++i) {       if (u[i] == v[i]) {         continue;       }       int w = lca(u[i], v[i]);       int iter = 0;       for (int t : {u[i], v[i]}) {         if (lev[t] - lev[w] >= int((s[i]).size())) {           int k = lev[t] - (lev[w] + int((s[i]).size()) - 1);           int nt = jump(t, k);           if (!iter) {             que[t].push_back(make_pair(i, make_pair(hi[i], 1)));             que[nt].push_back(make_pair(i, make_pair(hi[i], -1)));           } else {             que[t].push_back(make_pair(i, make_pair(h[i], 1)));             que[nt].push_back(make_pair(i, make_pair(h[i], -1)));           }         }         iter++;       }       if (w != u[i] && w != v[i]) {         int du = lev[u[i]] - lev[w];         int dv = lev[v[i]] - lev[w];         int mu = min(du, int((s[i]).size()) - 1);         int mv = min(dv, int((s[i]).size()) - 1);         int su = jump(u[i], du - mu);         int sv = jump(v[i], dv - mv);         string tu;         while (su != w) {           char c = from[su];           tu += c;           su = par[0][su];         }         string tv;         while (sv != w) {           char c = from[sv];           tv += c;           sv = par[0][sv];         }         reverse((tv).begin(), (tv).end());         string tt = tu + tv;         kmp.build((char*)s[i].data());         res[i] += int((kmp.query((char*)tt.data())).size());       }     }     upd_dfs(0, -1);     for (int i = (0); i < (q); ++i) cout << res[i] <<   n ;   }   int main(int argc, char* argv[]) {     ios_base::sync_with_stdio(0), cin.tie(0);     if (argc > 1) {       assert(freopen(argv[1],  r , stdin));     }     if (argc > 2) {       assert(freopen(argv[2],  wb , stdout));     }     chemthan();     cerr <<   nTime elapsed:   << 1000 * clock() / CLOCKS_PER_SEC <<  ms n ;     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const double E = 1e-10;   const int inf = (int)1e9;   const int maxn = 1010;   int LIM = 60 * 12;   int a[maxn];   int b[maxn], bc = 0;   int t[maxn];   int main() {     int n;     scanf( %d , &n);     for (int i = 0; i < n; i++) scanf( %d , a + i);     sort(a, a + n);     int sum = 10;     for (int i = 0; i < n; i++) {       if (sum + a[i] > LIM) break;       sum += a[i];       b[bc++] = a[i];     }     t[0] = 10;     for (int i = 0; i < bc; i++) t[i + 1] = t[i] + b[i];     int res = 0;     for (int i = 0; i <= bc; i++)       if (t[i] > LIM / 2) res += t[i] - (LIM / 2);     printf( %d %d n , bc, res);     return 0;   }


#include <bits/stdc++.h>   #include <unordered_map>   #include <unordered_set>   using namespace std;   #define endl   n    #define ll long long   #define sz(s) (int)(s.size())   #define INF 0x3f3f3f3f3f3f3f3fLL   #define all(v) v.begin(),v.end()   #define watch(x) cout<<(#x)<<  =  <<x<<endl   const int dr[] { -1, -1, 0, 1, 1, 1, 0, -1 };   const int dc[] { 0, 1, 1, 1, 0, -1, -1, -1 };   #if __cplusplus >= 201402L   template<typename T>   vector<T> create(size_t n) {    return vector<T>(n);   }   template<typename T, typename ... Args>   auto create(size_t n, Args ... args) {    return vector<decltype(create<T>(args...))>(n, create<T>(args...));   }   #endif   void run() {    ios::sync_with_stdio(false);    cin.tie(NULL);    cout.tie(NULL);   #ifndef ONLINE_JUDGE    freopen( input.in ,  r , stdin);   #else    //freopen( groups.in ,  r , stdin);   #endif   }   const int N = 1e5 + 9;   int l[N], r[N];   ll dp[N][2];   vector<vector<int>> adj;   ll dfs(int node, int par, bool b) {    ll &rt = dp[node][b];    if (~rt)     return rt;    rt = 0;    int myVal = (b ? r[node] : l[node]);    for (int ch : adj[node])     if (ch != par)      rt += max(dfs(ch, node, 0) + abs(l[ch] - myVal),        dfs(ch, node, 1) + abs(r[ch] - myVal));    return rt;   }      int main() {    run();    int T;    cin >> T;    while (T--) {     int n;     cin >> n;     memset(dp, -1, (sizeof dp[0]) * (n + 1));     for (int i = 1; i <= n; i++)      cin >> l[i] >> r[i];     adj = vector<vector<int>>(n + 1);     for (int i = 1; i < n; i++) {      int u, v;      cin >> u >> v;      adj[u].push_back(v);      adj[v].push_back(u);     }     cout << max(dfs(1, -1, 0), dfs(1, -1, 1)) << endl;    }   }


#include <bits/stdc++.h>   using namespace std;   int x[110], y[110], n, epsilon, k;   double dist[110], p[110], mem[110][110];   double solve(int idx, int k) {     if (k == 0) return 1;     if (idx == n) return 0;     double& res = mem[idx][k];     if (res != -1) return res;     res = p[idx] * solve(idx + 1, k - 1);     res += (1 - p[idx]) * solve(idx + 1, k);     return res;   }   bool binary(double r) {     for (int i = 0; i < n; i++) {       if (dist[i] <= r)         p[i] = 1;       else         p[i] = exp(1 - dist[i] * dist[i] / (r * r));     }     for (int i = 0; i < n + 1; i++)       for (int j = 0; j < k + 1; j++) mem[i][j] = -1;     double res = solve(0, k);     return ((1 - res) * 1000 <= epsilon);   }   int main() {     ios::sync_with_stdio(false);     int x0, y0;     cin >> n >> k >> epsilon;     cin >> x0 >> y0;     for (int i = 0; i < n; i++) cin >> x[i] >> y[i];     for (int i = 0; i < n; i++) dist[i] = hypot(x[i] - x0, y[i] - y0);     double mid, low = 0, high = 1000000;     while (abs(low - high) > 1e-9) {       mid = (low + high) / 2;       if (binary(mid))         high = mid;       else         low = mid;     }     printf( %.15lf n , (low + high) / 2);     return 0;   }


#include <bits/stdc++.h>   const long long int MAX = 1e12;   using namespace std;   const int alpha = 26;   void solve() {     int n;     cin >> n;     vector<int> arr(n);     for (auto &it : arr) cin >> it;     for (int i = 0; i < n; i++) {       while (arr[i] % 2 == 0) arr[i] /= 2;       while (arr[i] % 3 == 0) arr[i] /= 3;     }     if (count(arr.begin(), arr.end(), arr[0]) == n)       cout <<  YES ;     else       cout <<  NO ;   }   int main() {     solve();     return 0;   }


#include <bits/stdc++.h>   using namespace std;   vector<string> ans;   string f =  1 ;   bool sort2(string &a, string &b) {     if (a.size() == b.size()) {       return a < b;     }     return a.size() < b.size();   }   void calc(string s) {     if (s.size() >= 11) {       return;     }     ans.push_back(s);     s +=  1 ;     calc(s);     s.pop_back();     s +=  0 ;     calc(s);     s.pop_back();   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int n;     cin >> n;     string l = to_string(n);     calc(f);     int ans2 = 0;     sort(ans.begin(), ans.end(), sort2);     for (int i = 0; i < ans.size(); i++) {       if (ans[i].size() > l.size()) {         break;       } else if (ans[i].size() == l.size()) {         if (l >= ans[i]) {           ans2++;         } else {           break;         }       } else {         ans2++;       }     }     cout << ans2 <<   n ;   }


#include <bits/stdc++.h>   int n, cnt;   char ch[100005], tmp;   int main() {     scanf( %d , &n);     scanf( %s , ch + 1);     for (int i = 1; i <= n; i++)       if (ch[i] != tmp) {         if (tmp != 0) {           if ((tmp ==  o  || tmp ==  e ) && cnt == 2)             printf( %c%c , tmp, tmp);           else {             if (tmp ==  a  || tmp ==  e  || tmp ==  i  || tmp ==  o  ||                 tmp ==  u  || tmp ==  y )               printf( %c , tmp);             else               for (int j = 1; j <= cnt; j++) putchar(tmp);           }         }         tmp = ch[i];         cnt = 1;       } else         cnt++;     if ((tmp ==  o  || tmp ==  e ) && cnt == 2)       printf( %c%c , tmp, tmp);     else {       if (tmp ==  a  || tmp ==  e  || tmp ==  i  || tmp ==  o  || tmp ==  u  ||           tmp ==  y )         printf( %c , tmp);       else         for (int j = 1; j <= cnt; j++) putchar(tmp);     }     return 0;   }


#include <bits/stdc++.h>   using namespace std;   int main() {     int a[100005], i, j, m, n, ans = 0, pos = 1;     cin >> n;     for (i = 1; i <= n; i++) cin >> a[i];     for (i = 3; i <= n;) {       if (a[i] == a[i - 1] + a[i - 2]) {         while (a[i] == a[i - 1] + a[i - 2] && i <= n) {           i++;         }         ans = max(i - pos, ans);         pos = i - 2;       } else         i++, pos = i - 2;     }     cout << max(ans, min(n, 2));     return 0;   }


#include <bits/stdc++.h>   using namespace std;   const int ms = 2005, me = 4005;   int adj[ms], to[me], ant[me], z = 0, idx[ms], path[ms], bridge[me], ind,                                 vis[ms];   int s[ms], l[ms], ans;   bool dfs(int v, int end) {     if (vis[v])       return false;     else if (v == end)       return path[v] = true;     vis[v] = 1;     for (int e = adj[v]; e > -1; e = ant[e]) {       path[v] = path[v] || dfs(to[e], end);     }     return path[v];   }   int dfs2(int v, int par = -1) {     int low = idx[v] = ind++;     for (int i = adj[v]; i > -1; i = ant[i]) {       if (idx[to[i]] == -1) {         int temp = dfs2(to[i], v);         if (temp > idx[v] && path[to[i]] && path[v]) ans++;         low = min(low, temp);       } else if (to[i] != par)         low = min(low, idx[to[i]]);     }     return low;   }   void add(int a, int b) {     to[z] = b;     ant[z] = adj[a];     adj[a] = z++;     swap(a, b);     to[z] = b;     ant[z] = adj[a];     adj[a] = z++;   }   int main() {     cin.tie(0);     cin.sync_with_stdio(false);     int n, m;     cin >> n >> m;     z = 0;     memset(adj, -1, sizeof adj);     for (int i = 0; i < m; i++) {       int a, b;       cin >> a >> b;       add(a, b);     }     int k;     cin >> k;     for (int i = 0; i < k; i++) {       cin >> s[i] >> l[i];     }     for (int i = 0; i < k; i++) {       ans = 0;       memset(idx, -1, sizeof idx);       ind = 0;       memset(bridge, 0, sizeof bridge);       memset(vis, 0, sizeof vis);       memset(path, 0, sizeof path);       dfs(s[i], l[i]);       dfs2(s[i]);       cout << ans <<   n ;     }     return 0;   }