malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   long long q, x, y;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cin >> q;     while (q--) {       cin >> x >> y;       if (x - y > 1)         cout <<  YES               <<   n ;       else         cout <<  NO               <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t, a, b, x;     cin >> t;     while (t--) {       cin >> a >> b;       if (a < b) {         x = b - a;         x % 2 == 0 ? cout << 2 : cout << 1;       } else if (a > b) {         x = a - b;         x % 2 == 0 ? cout << 1 : cout << 2;       } else         cout << 0;       cout << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int gcd_(int a, int b) {     if (b == 0)       return a;     else       return gcd_(b, a % b);   }   int main() {     int n, i, x;     vector<int> v;     cin >> n;     for (i = 0; i < n; i++) {       cin >> x;       v.push_back(x);     }     int max1 = v[0];     x = v[0];     for (i = 1; i < n; i++) {       x = gcd_(v[i], x);       if (v[i] > max1) max1 = v[i];     }     int moves = ((max1 / x) - n);     if (moves % 2 != 0)       cout <<  Alice  << endl;     else       cout <<  Bob  << endl;     return 0;   }
#include <bits/stdc++.h>   std::vector<int> ReadVector(size_t size) {     std::vector<int> vector(size);     for (auto& element : vector) {       std::cin >> element;     }     return vector;   }   bool is_pal(const std::string& a) {     for (size_t i = 0; i < a.size() / 2; ++i) {       if (a[i] != a[a.size() - i - 1]) {         return false;       }     }     return true;   }   class Solver {    public:     std::vector<std::vector<int>> g;     Solver() {}     void read() {}     void solve() {       size_t n;       std::cin >> n;       g.resize(n);       for (size_t i = 0; i < n - 1; ++i) {         int a, b;         std::cin >> a >> b;         a--;         b--;         g[a].push_back(b);         g[b].push_back(a);       }       int root = -1;       int begin = -1;       int end = -1;       for (int v = 0; v < n; ++v) {         if (g[v].size() > 2) {           if (root != -1) {             std::cout <<  No  << std::endl;             return;           } else {             root = v;           }         }         if (g[v].size() == 1) {           if (begin == -1) {             begin = v;           } else {             end = v;           }         }       }       std::cout <<  Yes n ;       if (root == -1) {         std::cout << 1 << std::endl;         std::cout << begin + 1 <<     << end + 1 << std::endl;         return;       }       std::cout << g[root].size() << std::endl;       for (auto ch : g[root]) {         std::cout << root + 1 <<    ;         int tmp = ch;         int parent = root;         while (g[tmp].size() == 2) {           if (g[tmp][0] == parent) {             parent = tmp;             tmp = g[tmp][1];           } else {             parent = tmp;             tmp = g[tmp][0];           }         }         std::cout << tmp + 1 << std::endl;       }     }   };   int main() {     std::ios_base::sync_with_stdio(false);     std::cin.tie(nullptr);     Solver solver;     solver.solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long INF = 1e9;   const int maxn = 1e6 + 5;   int a[maxn];   int tpr = 0;   vector<int> adj[maxn];   void dfs(int root) {     if (adj[root].size() > 0) {       if (adj[root][0] == (root + 1)) {         dfs(root + 1);         tpr++;       } else         return;     }   }   int main() {     int n, m, t, i, j, k;     int flag = 0, flag2;     int ans = 0;     cin >> n >> k;     for (int i = 0; i < k; i++) {       cin >> m;       ans += m - 1;       int y;       int prev = -1;       for (int j = 0; j < m; j++) {         cin >> y;         if (y == 1) {           flag2 = m - 1;         }         if ((j == 0) && (y == 1)) {           flag = 1;         }         if (prev != -1) adj[prev].push_back(y);         prev = y;       }     }     if (flag == 0) {       ans += n - 1;       cout << ans << endl;       return 0;     }     dfs(1);     ans -= tpr;     ans += (n - tpr - 1);     cout << ans << endl;     return 0;     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( O3 )   #pragma GCC target( sse4 )   using namespace std;   using ii = pair<int, int>;   using ll = long long;   const int N = 3000 + 5;   const int mod = 1e9 + 7;   string source[N], target[N];   int n;   ii ranges[N];   vector<int> FAIL(string pat) {     int m = pat.size();     vector<int> F(m + 1);     int i = 0, j = -1;     F[0] = -1;     while (i < m) {       while (j >= 0 && pat[i] != pat[j]) j = F[j];       i++, j++;       F[i] = j;     }     return F;   }   bool check(string a, string b, string s, string t) {     vector<int> F = FAIL(s);     int i = 0, j = 0;     int n = a.size();     int m = s.size();     while (i < n) {       while (j >= 0 && a[i] != s[j]) j = F[j];       i++, j++;       if (j == m) {         int idx = i - j;         for (int k = 0; k < m; k++) {           a[k + idx] = t[k];         }         break;       }     }     return a == b;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cin >> n;     for (int i = 0; i < n; i++) cin >> source[i];     for (int i = 0; i < n; i++) cin >> target[i];     string s, t;     string prefix, suffix;     for (int i = 0; i < n; i++) {       if (source[i] != target[i]) {         int l = -1, r = -1;         for (int j = 0; j < source[i].size(); j++) {           if (source[i][j] != target[i][j]) r = j;           if (source[i][j] != target[i][j] && l == -1) l = j;         }         ranges[i] = {l, r};         if (s.empty()) {           s = source[i].substr(l, r - l + 1);           t = target[i].substr(l, r - l + 1);           prefix = source[i].substr(0, l);           suffix = source[i].substr(r + 1);           reverse(prefix.begin(), prefix.end());         } else {           if (s != source[i].substr(l, r - l + 1) ||               t != target[i].substr(l, r - l + 1)) {             cout <<  NO n ;             return 0;           }           string cprefix = source[i].substr(0, l);           string csuffix = source[i].substr(r + 1);           reverse(cprefix.begin(), cprefix.end());           string p, ss;           for (int j = 0;                j < min(cprefix.size(), prefix.size()) && cprefix[j] == prefix[j];                j++) {             p.push_back(prefix[j]);           }           for (int j = 0;                j < min(csuffix.size(), suffix.size()) && csuffix[j] == suffix[j];                j++) {             ss.push_back(suffix[j]);           }           prefix = p;           suffix = ss;         }       }     }     reverse(prefix.begin(), prefix.end());     s = prefix + s + suffix;     t = prefix + t + suffix;     for (int i = 0; i < n; i++) {       if (!check(source[i], target[i], s, t)) {         cout <<  NO n ;         return 0;       }     }     cout <<  YES n ;     cout << s <<   n ;     cout << t <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   inline bool inrange(T a, T l, T r) {     if (l > r) swap(l, r);     return (a >= l and a <= r);   }   template <typename T, typename U>   inline bool exist(T val, U &any) {     return (any.find(val) != any.end());   }   template <typename T>   inline void inp(T &any) {     cin >> any;   }   template <typename T, typename... U>   inline void inp(T &a, U &...b) {     cin >> a;     inp(b...);   }   template <typename T>   inline istream &operator>>(istream &in, vector<T> &a) {     for (auto &x : a) in >> x;     return in;   }   template <typename T, typename U>   inline istream &operator>>(istream &in, pair<T, U> &a) {     in >> a.first >> a.second;     return in;   }   void solve(long long int &T) {     long long int n;     std::cin >> n;     vector<long long int> a(n), b(n);     std::cin >> a >> b;     vector<long long int> sol(n);     for (long long int i = (0); i < (n); i++) sol[a[i] - 1] = b[i];     for (auto &X : sol) std::cout << X <<    ;     std::cout <<   n ;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     int t = 1;     for (long long int i = (1); i < (t + 1); i++) {       cerr <<  Case #  << i <<   n ;       solve(i);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     vector<vector<int>> v;     for (int i = 0; i < (n); ++i) {       int l;       cin >> l;       vector<int> temp;       for (int j = 0; j < (l); ++j) {         int ele;         cin >> ele;         temp.push_back(ele);       }       v.push_back(temp);     }     vector<int> maxi;     int cnt_no_ascent = 0;     bool ascent[n];     int mini_arr[n];     int maxi_arr[n];     for (int i = 0; i < (n); ++i) ascent[i] = false;     for (int i = 0; i < (n); ++i) {       int flag = 0;       int maxi_el = INT_MIN;       int mini_el = INT_MAX;       for (int j = 0; j < (v[i].size()); ++j) {         if (v[i][j] > maxi_el) {           maxi_el = v[i][j];         }         if (v[i][j] < mini_el) {           mini_el = v[i][j];         }         if (j != 0 && v[i][j - 1] < v[i][j]) {           ++cnt_no_ascent;           flag = 1;           ascent[i] = true;           break;         }       }       if (flag == 0) {         mini_arr[i] = mini_el;         maxi.push_back(maxi_el);         maxi_arr[i] = maxi_el;       }     }     long long ans = ((long long)cnt_no_ascent * (long long)n);     sort(maxi.begin(), maxi.end());     for (int i = 0; i < (n); ++i) {       if (ascent[i] == true) continue;       auto it = upper_bound(maxi.begin(), maxi.end(), mini_arr[i]);       ans = ans + (long long)(maxi.end() - it);       ans = ans + cnt_no_ascent;     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX = 1e6 + 6;   int main() {     int n;     cin >> n;     string str =   ;     while (n) {       str += ((n % 2) +  0 );       n /= 2;     }     reverse(str.begin(), str.end());     while (str.size() < 6) str =  0  + str;     string ss =   ;     ss += str[0];     ss += str[5];     ss += str[3];     ss += str[2];     ss += str[4];     ss += str[1];     int ret = 0;     for (auto x : ss) ret = ret * 2 + (x -  0 );     cout << ret <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int getint() {     unsigned int c;     int x = 0;     while (((c = getchar()) -  0 ) >= 10) {       if (c ==  - ) return -getint();       if (!~c) exit(0);     }     do {       x = (x << 3) + (x << 1) + (c -  0 );     } while (((c = getchar()) -  0 ) < 10);     return x;   }   int n, nn, sum;   int as[20];   int c[10][10];   bool used[20];   int num[20], have[20], ns;   int perm[20][20][20];   void dfs(int row, int col, int rows, int cols, int dir, int cnt) {     int i, j, k;     if (cnt == nn) {       int tmp1 = 0, tmp2 = 0;       for (i = 0; i < n; i++) {         tmp1 += c[i][i];         tmp2 += c[i][n - 1 - i];       }       if (tmp1 != sum) return;       if (tmp2 != sum) return;       tmp1 = tmp2 = 0;       for (i = 0; i < n; i++) {         tmp1 += c[n - 1][i];         tmp2 += c[i][n - 1];       }       if (tmp1 != sum) return;       if (tmp2 != sum) return;       for (i = 0; i < n; i++) {         for (j = 0; j < n; j++) {           if (j) putchar(   );           printf( %d , c[i][j]);         }         puts(  );       }       exit(0);     }     if (row == n or col == n) {       int tmp = 0;       if (dir == 0) {         for (i = 0; i < n; i++) tmp += c[row][i];         if (tmp != sum) return;       } else {         for (i = 0; i < n; i++) tmp += c[i][col];         if (tmp != sum) return;       }       if (dir == 0) {         dfs(rows + 1, cols, rows + 1, cols, 1, cnt);       } else {         dfs(rows, cols + 1, rows, cols + 1, 0, cnt);       }     }     for (i = 0; i < ns; i++) {       int d = perm[row][col][i];       if (have[d]) {         have[d]--;         c[row][col] = num[d];         if (dir == 0) dfs(row, col + 1, rows, cols, dir, cnt + 1);         if (dir == 1) dfs(row + 1, col, rows, cols, dir, cnt + 1);         have[d]++;       }     }   }   int main() {     int i, j, tcc, tc = 1 << 28;     for (tcc = 0; tcc < tc; tcc++) {       n = getint(), nn = n * n, sum = 0;       for (i = 0; i < nn; i++) as[i] = getint(), sum += as[i];       sum /= n;       for (i = 0; i < nn; i++) num[i] = as[i];       sort(num, num + nn);       ns = unique(num, num + nn) - num;       for (i = 0; i < ns; i++) {         for (j = 0; j < nn; j++)           if (num[i] == as[j]) have[i]++;       }       for (i = 0; i < n; i++)         for (j = 0; j < n; j++) {           for (int k = 0; k < ns; k++) perm[i][j][k] = k;           random_shuffle(perm[i][j], perm[i][j] + ns);         }       printf( %d n , sum);       dfs(0, 0, 0, 0, 0, 0);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MXX = 3e5 + 5;   int n, m;   int a[MXX], ans[MXX];   bool ok(int x) {     int mx = m - 1;     for (int i = n - 1; i >= 0; i--) {       if (a[i] <= mx) {         if (a[i] + x >= mx) {           ans[i] = mx;         } else {           ans[i] = a[i] + x;         }       } else {         if (a[i] + x >= mx + m)           ans[i] = mx;         else           ans[i] = (a[i] + x) % m;       }       mx = ans[i];     }     for (int i = 0; i < n - 1; i++) {       if (ans[i] > ans[i + 1]) {         return false;       }     }     return true;   }   bool ok2() {     for (int i = 0; i < n - 1; i++) {       if (a[i] > a[i + 1]) {         return false;       }     }     return true;   }   int main() {     cin >> n >> m;     for (int i = 0; i < n; i++) {       cin >> a[i];     }     if (ok2()) {       return cout << 0 << endl, 0;     }     int lo = 0, hi = m - 1, mid, ans = -1;     while (lo <= hi) {       mid = (lo + hi) / 2;       if (ok(mid)) {         ans = mid;         hi = mid - 1;       } else {         lo = mid + 1;       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long gcd(long long a, long long b);   void print(long long arr[], long long n);   void printv(vector<long long> arr);   signed main() {     long long t;     cin >> t;     while (t--) {       long long n;       cin >> n;       long long k;       cin >> k;       vector<long long> arr(n);       unordered_map<long long, long long> m;       for (long long i = 0; i < n; i++) {         cin >> arr[i];         m[arr[i]]++;       }       vector<long long> tem = arr;       sort(tem.begin(), tem.end());       set<long long> a, b;       if (arr[0] * 2 != k) a.insert(arr[0]);       for (long long i = 1; i < n; i++) {         if (arr[i] * 2 == k) continue;         if (a.find(k - arr[i]) == a.end())           a.insert(arr[i]);         else           b.insert(arr[i]);       }       long long ii = 0;       for (long long i = 0; i < n; i++) {         if (a.find(arr[i]) != a.end())           cout << 1 <<    ;         else if (b.find(arr[i]) != b.end())           cout << 0 <<    ;         else {           cout << ii <<    ;           ii = (ii + 1) % 2;         }       }       cout <<   n ;     }   }   long long gcd(long long a, long long b) {     if (b == 0) return a;     return gcd(b, a % b);   }   void print(long long arr[], long long n) {     for (long long i = 0; i < n; i++) cout << arr[i] <<    ;     cout <<   n ;   }   void printv(vector<long long> arr) {     for (long long i = 0; i < arr.size(); i++) cout << arr[i] <<    ;     cout <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int par[300005];   int vis[300005];   unordered_map<int, int> edge[300005];   int d[300005];   vector<int> ans;   int find(int u) { return par[u] == u ? u : par[u] = find(par[u]); }   void join(int u, int v) {     u = find(u);     v = find(v);     if (u > v) swap(u, v);     par[v] = u;   }   void dfs(int u, int pr) {     if (vis[u]) return;     vis[u] = 1;     for (auto i : edge[u]) {       dfs(i.first, u);     }     if (d[u] == 1) {       ans.push_back(edge[u][pr]);       d[pr]++;       d[pr] %= 2;       return;     }   }   int main() {     ios_base::sync_with_stdio(false);     memset(vis, 0, sizeof vis);     int n, k, u, v;     cin >> n >> k;     for (int i = 1; i <= n; i++) {       edge[i].clear();       par[i] = i;       cin >> d[i];     }     for (int i = 1; i <= k; i++) {       cin >> u >> v;       if (find(u) != find(v)) {         edge[u][v] = i;         edge[v][u] = i;         join(u, v);       }     }     int sum = 0;     int avail = 0;     for (int i = 1; i <= n; i++) {       if (d[i] == -1) {         avail++;       } else         sum += d[i];     }     if (sum % 2 && !avail) {       cout << -1 << endl;       return 0;     }     for (int i = 1; i <= n; i++) {       if (d[i] == -1) {         if (sum % 2 == 1) {           d[i] = 1;           sum++;         } else           d[i] = 0;       }     }     dfs(1, 0);     cout << ans.size() << endl;     for (int i = 0; i < ans.size(); i++) {       cout << ans[i] <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long MAX = 1e6 + 100;   const long long mod = 1e9 + 7;   const long long inf = 1e18 + 12;   vector<long long> arr(MAX);   map<long long, long long> mm;   int main() {     ios_base::sync_with_stdio(false);     cout.tie(NULL);     cout.tie(NULL);     ;     long long tt = 1;     while (tt--) {       long long n;       cin >> n;       long long a[n];       for (long long i = 0; i < n; i++) cin >> a[i];       long long w = 0, b = 0;       long long i = 0;       while (i < n) {         if (i % 2 == 0) {           w += (a[i] + 1) / 2;           b += (a[i]) / 2;         } else {           w += a[i] / 2;           b += (a[i] + 1) / 2;         }         i++;       }       cout << min(w, b);     }   }
#include <bits/stdc++.h>   using namespace std;   const int MOD = 998244353;   const int N = 200005;   const double PI = 4 * atan(1);   const long long MAX = 9223372036854775807;   int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};   int dy[] = {0, 0, 1, -1, 1, 1, -1, -1};   long long gcd(long long a, long long b) { return (b == 0 ? a : gcd(b, a % b)); }   long long lcm(long long a, long long b) { return a * (b / gcd(a, b)); }   bool issquare(long long w) { return trunc(sqrt(w)) * trunc(sqrt(w)) == w; }   bool isprime(long long u) {     for (long long i = 2; i <= (int)sqrt(u); i++) {       if (u % i == 0) return 0;     }     return 1;   }   long long mod(long long to_mod, long long MOD) {     to_mod %= MOD;     while (to_mod < 0) to_mod += MOD;     return to_mod % MOD;   }   long long moduloMultiplication(long long a, long long b, long long mod) {     long long res = 0;     a %= mod;     while (b) {       if (b & 1) res = (res + a) % mod;       a = (2 * a) % mod;       b >>= 1;     }     return res;   }   long long power(long long x, long long y) {     long long res = 1;     x = x;     while (y > 0) {       if (y & 1) res = (res * x);       y = y >> 1;       x = (x * x);     }     return res;   }   long long n, m, x, y, t, k, z, w, l, r, ans;   bool vis[N];   long long a[N];   long long lvl[N];   map<long long, vector<long long> > adj;   map<long long, long long> maa;   void bfs(long long src) {     queue<long long> q;     q.push(src);     lvl[src] = 1;     while (!q.empty()) {       long long ras = q.front();       q.pop();       if (lvl[ras] % 2 == 0) {         vis[ras] = 1;         continue;       }       for (auto t : adj[ras]) {         if (vis[t]) continue;         lvl[t] = lvl[ras] + 1;         q.push(t);       }     }   }   int main() {     ios::sync_with_stdio(0);     cin.tie(NULL);     cin >> n;     for (int i = 0; i < n; i++) {       cin >> a[i];       maa[a[i]] = i;     }     for (int j = 0; j < n; j++) {       k = a[j];       for (int i = j; i < n; i += k) {         if (a[i] > k) adj[i].push_back(j);       }       for (int i = j; i >= 0; i -= k) {         if (a[i] > k) adj[i].push_back(j);       }     }     for (int i = n; i >= 1; i--) {       if (vis[maa[i]]) continue;       bfs(maa[i]);     }     for (int i = 0; i < n; i++) {       if (vis[i])         cout <<  A ;       else         cout <<  B ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e6 + 7;   int n, lim, a[N], mn[N], mx[N], suf[N];   long long ans;   int main() {     scanf( %d%d , &n, &lim);     for (int i = 1; i <= lim; i++) mn[i] = n + 1;     for (int i = 1; i <= n; i++) {       scanf( %d , &a[i]);       mn[a[i]] = min(mn[a[i]], i);       mx[a[i]] = max(mx[a[i]], i);     }     int L = lim, R = 1, pre = mx[1];     for (int i = 1; i < lim; i++) {       pre = max(pre, mx[i]);       if (pre > mn[i + 1]) {         L = i;         break;       }     }     if (L == lim) {       cout << 1ll * lim * (lim + 1) / 2;       return 0;     }     pre = mn[lim];     for (int i = lim; i > 1; i--) {       pre = min(pre, mn[i]);       if (mx[i - 1] > pre) {         R = i;         break;       }     }     ans = lim - R + 2;     suf[lim] = mn[lim];     for (int i = lim - 1; i >= R; i--) suf[i] = min(suf[i + 1], mn[i]);     pre = mx[1];     for (int i = 1, j = R; i <= L; i++) {       pre = max(pre, mx[i]);       while (j <= lim && pre > suf[j]) j++;       ans += lim - j + 2;       if (j == i + 1) ans--;     }     cout << ans;   }
#include <bits/stdc++.h>   #pragma warning(disable : 4996)   using namespace std;   int n, m;   int a[300000];   int b[300000];   vector<int> edge[300000];   int ngood;   int child[300000];   int good[300000];   int d[300000];   int ans;   void back(int now, int parent) {     child[now] = 1;     good[now] = b[now];     for (auto e : edge[now])       if (e != parent) {         back(e, now);         child[now] += child[e], good[now] += good[e];       }   }   vector<pair<int, int> > v;   void back2(int now, int parent) {     for (auto e : edge[now])       if (e != parent) {         back2(e, now);       }     if (b[now] == 0) {       d[now] = 0;       return;     }     d[now] = 1;     int xgood = 0;     for (auto e : edge[now])       if (e != parent) {         if (child[e] == good[e]) xgood += child[e];       }     d[now] = 1 + xgood;     for (auto e : edge[now])       if (e != parent) {         d[now] =             max(d[now], 1 + d[e] + xgood - (child[e] == good[e] ? child[e] : 0));       }     ans = max(ans, d[now]);     int u = 1 + (n - child[now] == ngood - good[now] ? n - child[now] : 0);     v.clear();     for (auto e : edge[now])       if (e != parent) {         v.emplace_back(d[e], e);       }     sort((v).begin(), (v).end(), greater<pair<int, int> >());     for (int i = 0; i < 8 && i < v.size(); i++) {       for (int j = i + 1; j < 8 && j < v.size(); j++) {         ans = max(             ans, u + v[i].first + v[j].first + xgood -                      (child[v[i].second] == good[v[i].second] ? child[v[i].second]                                                               : 0) -                      (child[v[j].second] == good[v[j].second] ? child[v[j].second]                                                               : 0));       }     }   }   int param(int x) {     int i, j, k;     for (i = 0; i < n; i++) b[i] = a[i] >= x;     ngood = count(b, b + n, 1);     back(0, -1);     ans = 0;     back2(0, -1);     return ans >= m;   }   int main() {     int i, j, k;     cin >> n >> m;     for (i = 0; i < n; i++) scanf( %d , &a[i]);     for (i = 0; i < n - 1; i++) {       int x, y;       scanf( %d%d , &x, &y), x--, y--;       edge[x].push_back(y), edge[y].push_back(x);     }     int low = 0, high = 1000001, mid;     while (low <= high) {       mid = (low + high) / 2;       if (param(mid))         low = mid + 1;       else         high = mid - 1;     }     cout << high;     return 0;   }