malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   template <typename T>   T &chmin(T &a, const T &b) {     return a = min(a, b);   }   template <typename T>   T &chmax(T &a, const T &b) {     return a = max(a, b);   }   template <typename T>   T gcd(const T a, const T b) {     return b ? gcd(b, a % b) : a;   }   template <typename T>   T lcm(const T a, const T b) {     return a / gcd(a, b) * b;   }   template <typename T>   T ceil(const T a, const T b) {     return (a + b - 1) / b;   }   template <typename T>   long double dist(const T x1, const T y1, const T x2, const T y2) {     long double x = x1 - x2;     long double y = y1 - y2;     return sqrt(x * x + y * y);   }   template <typename T>   void aout(const T *a, const int n) {     for (int i = 0; i < (n); ++i) cout << a[i] <<    ;     cout <<   n ;   }   template <typename T>   void vout(const vector<T> &v) {     for (int i = 0; i < ((int)(v).size()); ++i) cout << v[i] <<    ;     cout <<   n ;   }   const int di4[4] = {-1, 0, 1, 0};   const int dj4[4] = {0, 1, 0, -1};   const int di8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};   const int dj8[8] = {0, 1, 1, 1, 0, -1, -1, -1};   const int dik[8] = {2, 1, -1, -2, -2, -1, 1, 2};   const int djk[8] = {1, 2, 2, 1, -1, -2, -2, -1};   const int maxn = 100100;   const int mod = 1e9 + 7;   const int inf = INT_MAX;   const long double eps = 1e-9;   const long double pi = acos(-1.0);   int n;   void solve() {     cin >> n;     long long ans = (long long)(n - 2) * (n - 2);     cout << (ans) <<   n ;   }   void init() {}   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cout.precision(10);     cout << fixed;     int tc = 1;     for (int i = 1; i <= (tc); ++i) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 15e4 + 5;   const int M = 3e2 + 5;   const long long NINF = -1e12 + 5;   long long dp[2][N], a[M], b[M], t[M], n, m, d, interval, curr, nxt;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n >> m >> d;     for (int i = 1; i <= m; i++) {       cin >> a[i] >> b[i] >> t[i];     }     for (int i = 1; i <= m; i++) {       nxt = i & 1;       curr = nxt ^ 1;       interval = min(n, (t[i] - t[i - 1]) * d);       deque<long long> dq;       for (int j = 1; j <= interval; j++) {         while (!dq.empty() && dp[curr][dq.back()] <= dp[curr][j]) dq.pop_back();         dq.push_back(j);       }       for (int j = 1; j <= n; j++) {         int k = j + interval;         if (k <= n) {           while (!dq.empty() && dp[curr][dq.back()] <= dp[curr][k]) dq.pop_back();           dq.push_back(k);         }         dp[nxt][j] = dp[curr][dq.front()] + b[i] - abs(a[i] - j);         while (!dq.empty() && dq.front() <= (j - interval)) dq.pop_front();       }     }     long long ans = NINF;     for (int i = 1; i <= n; i++) ans = max(ans, dp[nxt][i]);     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k;     scanf( %d%d , &n, &k);     if ((n * (n - 1)) / 2 < k * n) {       printf( -1 n );       return 0;     }     printf( %d n , n * k);     for (int i = 0; i < n; ++i) {       for (int j = i + 1, q = 0; q < k; ++q, ++j) {         if (j == n) j = 0;         printf( %d %d n , i + 1, j + 1);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     vector<int> a(n);     for (int i = 0; i < n; i++) {       cin >> a[i];       a[i] += i;     }     sort(a.begin(), a.end());     for (int i = 0; i < n; i++) {       a[i] -= i;       if (i && a[i] < a[i - 1]) {         cout <<  :(  << endl;         return 0;       }     }     for (int i = 0; i < n; i++) {       cout << a[i] <<    ;     }     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     string s;     cin >> s;     for (int i = 0; i < s.length(); i++) {       if (s[i] ==  W  && s[i + 1] ==  U  && s[i + 2] ==  B ) {         s.erase(i, 3);         i--;         cout <<    ;       } else         cout << s[i];     }   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   inline bool uin(T& a, T b) {     return a > b ? (a = b, true) : false;   }   template <class T>   inline bool uax(T& a, T b) {     return a < b ? (a = b, true) : false;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     string s;     cin >> s;     for (int i = (int)s.length() - 1, cnt = 0; i >= 0; --i) {       if (s[i] ==  0 )         ++cnt;       else if (cnt)         --cnt;       else         s[i] =  0 ;     }     cout << s <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 0x3f3f3f3f;   const int MAXK = 55, MAXN = 111;   int K, X, N, M;   int second[MAXK], F[MAXK];   long long tmemo[MAXK];   long long times(int k) {     if (k < 2) return tmemo[k];     times(k - 1);     if (tmemo[k - 1] > X) return tmemo[k] = tmemo[k - 1];     F[k] = F[k - 2];     second[k] = second[k - 1];     tmemo[k] = tmemo[k - 1] + tmemo[k - 2];     if (second[k - 2] == 1 && F[k - 1] == 0) tmemo[k]++;     return tmemo[k];   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cin >> K >> X >> N >> M;     K--;     for (int i = 0; i <= (N + 1) / 2 - 1; i++) {       for (int j = 0; j <= (M + 1) / 2 - 1; j++) {         for (int back = 0; back <= 2; back++) {           for (int front = 0; front <= 2; front++) {             for (int b = 0; b <= 2; b++) {               for (int f = 0; f <= 2; f++) {                 memset(tmemo, 0, sizeof(tmemo));                 memset(second, 0, sizeof(second));                 memset(F, 0, sizeof(F));                 tmemo[0] = i;                 tmemo[1] = j;                 second[0] = back;                 second[1] = b;                 F[0] = front;                 F[1] = f;                 if (N == 1 && back != front) continue;                 if (M == 1 && b != f) continue;                 bool usefa = true, useba = true;                 bool usefb = true, usebb = true;                 if (i > 0 && 2 * i + 1 == N) {                   if (second[0] == 1) {                     F[0] = 1;                     usefa = false;                   } else                     useba = false;                 }                 if (j > 0 && 2 * j + 1 == M) {                   if (second[1] == 1) {                     F[1] = 1;                     usefb = false;                   } else                     usebb = false;                 }                 if (back == 0 && front == 1 && N == 2) tmemo[0]++;                 if (b == 0 && f == 1 && M == 2) tmemo[1]++;                 if (times(K) == X) {                   if (usefa) cout <<  CAG [F[0]];                   int done = usefa;                   for (int x = 0; x < i; x++) {                     cout <<  AC ;                     done += 2;                   }                   while (done + 1 < N) {                     cout <<  G ;                     done++;                   }                   if (done < N) cout <<  CAG [second[0]];                   cout <<   n ;                   if (usefb) cout <<  CAG [F[1]];                   done = usefb;                   for (int x = 0; x < j; x++) {                     cout <<  AC ;                     done += 2;                   }                   while (done + 1 < M) {                     cout <<  G ;                     done++;                   }                   if (done < M) cout <<  CAG [second[1]];                   cout <<   n ;                   return 0;                 }               }             }           }         }       }     }     cout <<  Happy new year! n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1000000007;   long long rowNum[] = {-1, 0, 0, 1};   long long colNum[] = {0, -1, 1, 0};   int main() {     int n, d, h;     cin >> n >> d >> h;     if (d > n - 1 || d < h || d > 2 * h || (n > 2 && h < 2 && d == h)) {       cout <<  -1 n ;       return 0;     }     int prev = 0;     for (long long i = 1; i < h + 1; i++) {       cout << prev + 1 <<     << i + 1 << endl;       prev = i;     }     if (d == h) {       for (long long i = h + 1; i < n; i++) {         cout <<  2   << i + 1 << endl;       }       return 0;     }     prev = 0;     for (long long i = h + 1; i < d + 1; i++) {       cout << prev + 1 <<     << i + 1 << endl;       prev = i;     }     for (long long i = d + 1; i < n; i++) {       cout <<  1   << i + 1 << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 1e9 + 7;   const int M = 1e5 + 10;   int n, m, vis[M * 12], ans[M * 12], tot;   vector<int> vt[10][M * 12], tmp;   vector<vector<int> > now, nxt;   void add(int x, int y, int id) {     while (id / 10) vt[id % 10][++tot].push_back(y), y = tot, id /= 10;     vt[id][x].push_back(y);   }   void bfs() {     vis[1] = 1;     now.push_back(vector<int>(1, 1));     while (!now.empty()) {       for (int p = 0; p < now.size(); p++) {         vector<int> a = now[p];         for (int w = 0; w < 10; w++) {           tmp.clear();           for (int i = 0; i < a.size(); i++) {             int x = a[i];             for (int j = 0; j < vt[w][x].size(); j++) {               int y = vt[w][x][j];               if (vis[y]) continue;               vis[y] = 1;               ans[y] = (10LL * ans[x] % mod + w) % mod;               tmp.push_back(y);             }           }           if (tmp.size()) nxt.push_back(tmp);         }       }       now = nxt;       nxt.clear();     }   }   int main(int argc, char const *argv[]) {     scanf( %d%d , &n, &m);     tot = n;     for (int i = 1; i <= m; i++) {       int x, y;       scanf( %d%d , &x, &y);       add(x, y, i);       add(y, x, i);     }     bfs();     for (int i = 2; i <= n; i++) printf( %d n , ans[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int N, M, C;   vector<pair<int, pair<int, int> > > V;   int A[505][505], R[505];   int main() {     int x, y, t;     scanf( %d %d , &N, &M);     memset(A, 40, sizeof A);     for (int i = 1; i <= M; i++) {       scanf( %d %d %d , &x, &y, &t);       A[x][y] = A[y][x] = t;       V.push_back(make_pair(t, make_pair(x, y)));     }     for (int i = 1; i <= N; i++) A[i][i] = 0;     for (int k = 1; k <= N; k++)       for (int i = 1; i <= N; i++)         for (int j = 1; j <= N; j++) A[i][j] = min(A[i][j], A[i][k] + A[k][j]);     for (int i = 1; i <= N; i++) {       memset(R, 0, sizeof R);       for (typeof(V.begin()) it = V.begin(); it != V.end(); it++) {         if (A[i][it->second.first] + it->first == A[i][it->second.second])           ++R[it->second.second];         if (A[i][it->second.second] + it->first == A[i][it->second.first])           ++R[it->second.first];       }       for (int j = i + 1; j <= N; j++) {         int ans = 0;         for (int k = 1; k <= N; k++)           if (A[i][k] + A[k][j] == A[i][j]) ans += R[k];         printf( %d  , ans);       }     }     cerr <<   nTime:   << (double)clock() / CLOCKS_PER_SEC <<   seconds.  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 998244353;   long long int dp[5001][5001];   long long int f[5001];   long long int power(long long int x, long long int b) {     long long int res = 1;     while (b) {       if (b & 1) res = res * x % mod;       x = x * x % mod;       b >>= 1;     }     return res;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     int n, m, k;     cin >> n >> m >> k;     dp[0][0] = 1;     for (int i = 1; i <= 5000; i++)       for (int j = 1; j <= i; j++)         dp[i][j] =             ((dp[i - 1][j - 1] - dp[i - 1][j] * (i - 1)) % mod + mod) % mod;     f[0] = 1;     long long int fac = n;     long long int inv = power(m, mod - 2), p = inv;     for (int i = 1; i <= k; i++) {       f[i] = fac * p % mod;       for (int j = 1; j < i; j++) f[i] -= dp[i][j] * f[j] % mod;       f[i] = (f[i] % mod + mod) % mod;       fac = fac * (n - i) % mod;       p = inv * p % mod;     }     cout << f[k] << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int n;     cin >> n;     string s;     cin >> s;     set<char> S;     int ans = 0;     for (int i = 0; i <= s.size(); ++i) {       if (i == s.size() || isupper(s[i])) {         ans = max(ans, (int)S.size());         S.clear();       } else {         S.insert(s[i]);       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[100000];   int main() {     int n;     cin >> n;     for (int i = 0; i < n; i++) cin >> a[i];     sort(a, a + n);     int cnt = 0;     if (a[0] != 0) cnt = 1;     for (int i = 1; i < n; i++) {       if (a[i] != 0) {         if (a[i] != a[i - 1]) cnt++;       }     }     cout << cnt << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t, n, a, b, c, d;     cin >> t;     while (t--) {       cin >> n >> a >> b >> c >> d;       int diff = n * (a - b), sum = n * (a + b);       if ((diff > c + d) || (sum < c - d))         cout <<  No  << endl;       else         cout <<  Yes  << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct custom_hash {     static uint64_t splitmix64(uint64_t x) {       x += 0x9e3779b97f4a7c15;       x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;       x = (x ^ (x >> 27)) * 0x94d049bb133111eb;       return x ^ (x >> 31);     }     size_t operator()(uint64_t x) const {       static const uint64_t FIXED_RANDOM =           chrono::steady_clock::now().time_since_epoch().count();       return splitmix64(x + FIXED_RANDOM);     }   };   template <class T>   void dispvector(vector<T> v) {     for (int i = 0; i < v.size(); i++) cout << v[i] <<    ;     cout <<   n ;   }   template <class T>   void disparray(T *v, int n) {     for (int i = 0; i < n; i++) cout << v[i] <<    ;     cout <<   n ;   }   template <class T>   int sizeofarr(T *v) {     return sizeof(v) / sizeof(T);   }   signed main(int argc, char **argv) {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long int n;     cin >> n;     if (n % 2 == 0) {       cout <<  NO             <<   n ;       return 0;     } else {       cout <<  YES             <<   n ;       vector<long long int> arr(2 * n);       long long int num = 1;       long long int idx1 = 0;       long long int idx2 = n;       bool ok = true;       for (long long int i = 0; i < n; i++) {         if (ok) {           arr[idx1] = num;           arr[idx2] = num + 1;         } else {           arr[idx1] = num + 1;           arr[idx2] = num;         }         num += 2;         idx1++;         idx2++;         if (ok)           ok = false;         else           ok = true;       }       dispvector(arr);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     int t;     cin >> t;     while (t--) {       long long p, q;       cin >> p >> q;       if (p % q != 0)         cout << p << endl;       else {         long long x = q;         long long ans = 1;         for (long long i = 2; i <= (long long)sqrt(x); i++) {           if (x % i == 0) {             while (x % i == 0) x /= i;             long long tp = p;             while (tp % q == 0) tp /= i;             ans = max(ans, tp);           }         }         if (x > 1) {           long long tp = p;           while (tp % q == 0) tp /= x;           ans = max(ans, tp);         }         cout << ans << endl;       }     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 5;   long long arr[N], dp[N], n;   long long go(int indx) {     if (indx == n) return 0;     long long &ret = dp[indx];     if (~ret) return ret;     long long sum = arr[indx], j = indx + 1;     while (j != n && arr[j] == arr[indx]) sum += arr[j++];     ret = go(j);     while (j != n && arr[j] - arr[indx] == 1) j++;     return ret = max(ret, sum + go(j));   }   int main() {     memset(dp, -1, sizeof dp);     cin >> n;     for (int i = 0; i < n; cin >> arr[i++])       ;     sort(arr, arr + n);     cout << go(0);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e5 + 7;   long long n, m, q;   int main() {     scanf( %lld%lld , &n, &q);     while (q--) {       long long x;       scanf( %lld , &x);       while (1) {         if (x & 1) break;         x = x + (n - x / 2);       }       cout << x / 2 + 1 << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 1e8 - 3;   struct Data {     int a, i;     bool operator<(const Data& d) const {       if (a == d.a) {         return i < d.i;       }       return a < d.a;     }   };   const int N = 1e5 + 10;   int C[N];   int lowbit(int first) { return first & -first; }   void update(int first, int k) {     while (first < N) {       C[first] += k;       first += lowbit(first);     }   }   int query(int first) {     int sum = 0;     while (first > 0) {       sum += C[first];       first -= lowbit(first);     }     return sum;   }   int main() {     int n;     cin >> n;     vector<Data> a(n), b(n);     for (int i = 0; i < n; i++) {       cin >> a[i].a;       a[i].i = i;     }     for (int i = 0; i < n; i++) {       b[i].a = b[i].i = i;     }     sort(a.begin(), a.end());     sort(b.begin(), b.end());     vector<int> c(n);     for (int i = 0; i < n; i++) {       c[b[i].i] = a[i].i;     }     vector<pair<int, int> > res;     for (int it = 0; it < n; it++) {       for (int i = 0; i < n - 1; i++) {         if (c[i] > c[i + 1]) {           res.push_back({c[i + 1], c[i]});           swap(c[i], c[i + 1]);         }       }     }     cout << res.size() << endl;     for (auto& p : res) {       cout << p.first + 1 <<     << p.second + 1 << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const int MN = 1000111;   int n;   pair<int, int> a[MN], b[MN];   int main() {     ios ::sync_with_stdio(0);     cin.tie(0);     while (scanf( %d , &n) == 1) {       for (int i = (1), _b = (n); i <= _b; ++i) {         scanf( %d , &a[i].first);         a[i].second = i;       }       for (int i = (1), _b = (n); i <= _b; ++i) {         scanf( %d , &b[i].first);         b[i].second = i;       }       try {         while (true) {           map<int, pair<int, int> > id;           id[0] = make_pair(0, 0);           int ia = 0, ib = 0;           int diff = 0;           while (ia < n || ib < n) {             if (ia == n) {               diff -= b[++ib].first;             } else if (ib == n) {               diff += a[++ia].first;             } else if (diff <= 0) {               diff += a[++ia].first;             } else {               diff -= b[++ib].first;             }             if (id.count(diff)) {               int ja = id[diff].first;               int jb = id[diff].second;               printf( %d n , ia - ja);               for (int x = (ja + 1), _b = (ia); x <= _b; ++x)                 printf( %d  , a[x].second);               puts(  );               printf( %d n , ib - jb);               for (int x = (jb + 1), _b = (ib); x <= _b; ++x)                 printf( %d  , b[x].second);               puts(  );               puts(  );               throw 1;             }             id[diff] = make_pair(ia, ib);           }           throw 2;           random_shuffle(a + 1, a + n + 1);           random_shuffle(b + 1, b + n + 1);         }       } catch (int e) {       }     }   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 10;   const long double EPS = 1e-9;   double a[MAXN][MAXN];   double x[MAXN];   int answer[MAXN], X[MAXN];   int ans;   int n, m;   int main() {     for (int i = 1; i < 8; i++) {       int v[4];       for (int j = 0; j < 4; j++) v[j] = (i & (1 << (3 - j))) != 0;       int k = 0;       for (int x = 0; x < 4; x++)         for (int y = x + 1; y < 4; y++) a[k++][i - 1] = (int)(v[x] != v[y]);     }     n = 6;     m = 7;     int ans = 0;     for (int i = 0; i < 6; i++) {       cin >> a[i][m];       ans += (int)a[i][m] + 1;     }     int p[MAXN];     for (int i = 0; i <= m; i++) p[i] = i;     for (int I = 0; I < n; I++) {       for (int j = I; j < m; j++)         if (fabs(a[I][p[I]]) < fabs(a[I][p[j]])) swap(p[I], p[j]);       for (int i = I + 1; i < n; i++) {         long double c = a[i][p[I]] / a[I][p[I]];         for (int j = m; j >= I; j--) a[i][p[j]] -= a[I][p[j]] * c;       }     }     bool flag = false;     for (int iter = 0; iter <= ans; iter++) {       x[p[m - 1]] = iter;       for (int i = n - 1; i >= 0; i--) {         long double s = 0;         for (int j = i + 1; j < m; j++) s += x[p[j]] * a[i][p[j]];         x[p[i]] = (a[i][p[m]] - s) / a[i][p[i]];       }       for (int i = 0; i < m; i++) answer[i] = (int)(x[i] + 0.5);       bool f = true;       for (int i = 0; i < m; i++)         f &=             (x[i] > -EPS) && (fabs(answer[i] - x[i]) < EPS) && (x[i] - EPS < ans);       if (!f) continue;       int res = 0;       for (int i = 0; i < m; i++) res += answer[i];       if (res >= ans) continue;       flag = true;       memmove(X, answer, sizeof(X));       ans = res;     }     if (!flag) {       puts( -1 );       return 0;     }     printf( %d n , ans);     for (int i = 0; i < 4; i++) {       for (int j = 0; j < m; j++)         for (int x = X[j]; x; x--)           printf( %c , ((j + 1) & (1 << (3 - i))) == 0 ?  a  :  b );       printf(  n );     }     fprintf(stderr,  Time execute: %.3lf n , clock() / (double)CLOCKS_PER_SEC);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, v0, f[200012], nu = 0;   struct eve {     int x, v, l;     inline bool operator<(const eve &b) const {       return (x < b.x) || ((x == b.x) && (v < b.v));     }   };   multiset<eve> s;   inline void cha(int x, int v) {     f[x] = v;     if (v + v0 <= 1e9) s.insert((eve){v + v0, 0, -1});   }   int d[200012 << 2], ma[200012 << 2];   inline void Add(int p, int v) {     d[p] += v;     ma[p] += v;   }   inline void pd(int x) {     if (d[x]) {       Add(x << 1, d[x]);       Add(x << 1 | 1, d[x]);       d[x] = 0;     }   }   void build(int p, int l, int r) {     ma[p] = r;     if (l == r) return;     int mid = (l + r) >> 1;     build(p << 1, l, mid);     build(p << 1 | 1, mid + 1, r);   }   void change(int p, int l, int r, int L, int R, int v) {     if ((R < l) || (r < L)) return;     if ((L <= l) && (r <= R)) {       Add(p, v);       return;     }     pd(p);     int mid = (l + r) >> 1;     change(p << 1, l, mid, L, R, v);     change(p << 1 | 1, mid + 1, r, L, R, v);     ma[p] = max(ma[p << 1], ma[p << 1 | 1]);   }   int Ask(int p, int l, int r, int L, int R) {     if ((R < l) || (r < L)) return 0;     if ((L <= l) && (r <= R)) return ma[p];     pd(p);     int mid = (l + r) >> 1;     return max(Ask(p << 1, l, mid, L, R), Ask(p << 1 | 1, mid + 1, r, L, R));   }   int main() {     scanf( %d%d , &n, &v0);     int i, l, r, x, o;     eve p;     memset(f, 0x3f, sizeof(f));     build(1, 0, n);     for (i = 1; i <= n; i++) {       scanf( %d%d , &l, &r);       if (r < 0) continue;       l = max(l, 0);       s.insert((eve){l, 1, l});       s.insert((eve){r + 1, -1, l});     }     cha(r = 0, -0x3f3f3f3f);     while (!s.empty()) {       p = *s.begin();       nu += p.v;       l = p.x;       s.erase(s.begin());       if (p.l >= 0) change(1, 0, n, lower_bound(f, f + n + 1, p.l) - f, n, -p.v);       if ((!s.empty()) && ((s.begin()->x) == l)) continue;       x = upper_bound(f, f + n + 1, l - v0) - f - 1;       o = nu + Ask(1, 0, n, 0, x);       while ((r < n) && (r < o)) cha(++r, l);     }     printf( %d , r);     return 0;   }