malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int oo = ~0u >> 2, mo = (int)1e9 + 7;   const int mn = 52, mp = ((mn) * (mn)), me = mp * 4;   const int fx[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};   struct EDGE {     int y, l;   } E[me];   int g[mp], d[mp], h[mn][mn], Q[mp];   bool a[mn][mn];   int n, m, tt(0);   void add(int x, int y) { E[++tt].y = y, E[tt].l = g[x], g[x] = tt; }   void fill(int x, int y) {     h[x][y] = tt;     for (int i = 0; i <= 3; ++i) {       int nx = x + fx[i][0], ny = y + fx[i][1];       if (nx < 1 || nx > n || ny < 1 || ny > m || a[x][y] != a[nx][ny] ||           h[nx][ny])         continue;       fill(nx, ny);     }   }   int calc(int x, int y) {     int l = 0, r = 0;     memset(&d, -1, sizeof(d));     d[Q[++r] = h[x][y]] = 0;     while (l++ != r)       for (int i = g[Q[l]], y = E[i].y; i; i = E[i].l, y = E[i].y)         if (d[y] == -1) d[Q[++r] = y] = d[Q[l]] + 1;     int ret = 0;     for (int i = 1; i <= n; ++i)       for (int j = 1; j <= m; ++j)         if (a[i][j]) (ret = max(ret, d[h[i][j]]));     return ret;   }   int main() {     scanf( %d%d , &n, &m);     bool black = 0;     for (int i = 1; i <= n; ++i)       for (int j = 1; j <= m; ++j) {         char ch;         do {           scanf( %c , &ch);         } while (ch !=  B  && ch !=  W );         black |= (a[i][j] = (ch ==  B ));       }     if (!black) {       printf( 0 n );       return 0;     }     for (int i = 1; i <= n; ++i)       for (int j = 1; j <= m; ++j)         if (!h[i][j]) ++tt, fill(i, j);     tt = 0;     for (int i = 1; i <= n; ++i)       for (int j = 1; j <= m; ++j)         for (int k = 0; k <= 3; ++k) {           int x = i + fx[k][0], y = j + fx[k][1];           if (x < 1 || x > n || y < 1 || y > m || h[i][j] == h[x][y]) continue;           add(h[i][j], h[x][y]);         }     int Ans = oo;     for (int i = 1; i <= n; ++i)       for (int j = 1; j <= m; ++j) {         int tmp = calc(i, j);         (Ans = min(Ans, tmp));       }     printf( %d n , Ans + 1);   }
#include <bits/stdc++.h>   using namespace std;   const double PI = atan(1.0) * 4.0;   int in_c() {     int c;     while ((c = getchar()) <=    ) {       if (!~c) throw ~0;     }     return c;   }   int in() {     int x = 0, c;     while ((unsigned int)((c = getchar()) -  0 ) >= 10) {       if (c ==  - ) return -in();       if (!~c) return ~0;     }     do {       x = 10 * x + (c -  0 );     } while ((unsigned int)((c = getchar()) -  0 ) < 10);     return x;   }   template <class T>   struct fenwick_tree {     vector<T> x;     fenwick_tree(int n) : x(n, 0) {}     T sum(int i, int j) const {       if (i == 0) {         T S = 0;         for (; j >= 0; j = (j & (j + 1)) - 1) S += x[j];         return S;       } else         return sum(0, j) - sum(0, i - 1);     }     void add(int k, T a) {       for (; k < (int)x.size(); k |= k + 1) x[k] += a;     }     void set(int k, T a) {       T now = at(k);       add(k, a - now);     }     T at(int i) const { return sum(i, i); }   };   int main() {     int N, K;     while (N = in(), N != EOF) {       K = in();       int center = K / 2;       const int INF = 1 << 28;       vector<fenwick_tree<int> > bit(K, fenwick_tree<int>(K));       for (int i = (0), ___e = (N); i < ___e; ++i) {         int M = in();         int ax = -1, l;         int min_score = INF;         for (int r = (0), ___e = (K); r < ___e; ++r)           for (int c = (0), ___e = (K - M + 1); c < ___e; ++c) {             if (bit[r].sum(c, c + M - 1) == 0) {               int s = 0;               for (int j = c; j < c + M; ++j) {                 s += abs(r - center) + abs(j - center);               }               if (s < min_score) {                 min_score = s;                 ax = r, l = c;               } else if (s == min_score) {                 if (ax > r || ax == r && l > c) {                   min_score = s;                   ax = r, l = c;                 }               }             }           }         if (ax == -1) {           cout << -1 << endl;         } else {           for (int j = l; j < l + M; ++j) bit[ax].add(j, 1);           cout << ax + 1 <<     << l + 1 <<     << l + M << endl;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n;     cin >> n;     long long maxi = LLONG_MIN;     for (long long i = 1LL; i <= n; i++) {       long long x, y;       cin >> x >> y;       maxi = max(maxi, x + y);     }     cout << maxi << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main(void) {     int n;     cin >> n;     int *arr = (int *)malloc(sizeof(int) * n);     for (int i = 0; i < n; ++i) cin >> arr[i];     int curr = arr[0], ans = 1, temp = 1;     for (int i = 1; i < n; ++i) {       ans = max(ans, temp);       if (arr[i] >= curr) {         curr = arr[i];         ++temp;       } else {         temp = 1;         curr = arr[i];       }     }     cout << max(ans, temp);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long nChooseR(int n, int k);   long long gcd(long long a, long long b);   vector<string> split(string target, char c);   bool isPrime(long long g);   long long n, m, t, a[] = {0, 0, 1, 2, 3, 4, 5}, k, x, y, z;   long long ans;   map<pair<int, int>, int> mp;   vector<vector<int>> grid(7);   void solve(int i) {     for (auto u : grid[i]) {       if (mp[make_pair(a[i], a[u])] == 1) {         z++;         mp[make_pair(a[i], a[u])] = 0;         mp[make_pair(a[u], a[i])] = 0;         solve(u);       }     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     cin >> n >> m;     for (int i = 0; i < (int)(m); i++) {       cin >> x >> y;       x--;       y--;       grid[x].push_back(y);       grid[y].push_back(x);     }     do {       z = 0;       for (int i = 0; i < (int)(6); i++) {         for (int j = 0; j < (int)(6); j++) mp[make_pair(i, j)] = 1;       }       for (int i = 0; i < (int)(6); i++) solve(i);       ans = max(ans, z);     } while (next_permutation(a, a + 7));     cout << ans;     return 0;   }   long long nChooseR(int n, int k) {     if (k > n) return 0;     if (k * 2 > n) k = n - k;     if (k == 0) return 1;     long long result = n;     for (int i = 2; i <= k; ++i) {       result *= (n - i + 1);       result /= i;     }     return result;   }   long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }   vector<string> split(string target, char c) {     string d =   ;     vector<string> arr;     for (auto n : target) {       if (n != c)         d += n;       else if (d !=   )         arr.push_back(d), d =   ;     }     if (d !=   ) arr.push_back(d), d =   ;     return arr;   }   bool isPrime(long long g) {     if ((g % 2 == 0 && g > 2) || g == 1) return 0;     for (long long i = 3; i * i <= g; i += 2)       if (g % i == 0) return 0;     return 1;   }
#include <bits/stdc++.h>   using namespace std;   const long long int is_query = LLONG_MIN;   struct Line {     long long int m, b;     mutable function<const Line*()> succ;     bool operator<(const Line& rhs) const {       if (rhs.b != is_query) return m < rhs.m;       const Line* s = succ();       if (!s) return 0;       long long int x = rhs.m;       return b - s->b < (s->m - m) * x;     }   };   struct HullDynamic : public multiset<Line> {     bool bad(iterator y) {       auto z = next(y);       if (y == begin()) {         if (z == end()) return 0;         return y->m == z->m && y->b <= z->b;       }       auto x = prev(y);       if (z == end()) return y->m == x->m && y->b <= x->b;       return (x->b - y->b) * (z->m - y->m) >= (y->b - z->b) * (y->m - x->m);     }     void Add(long long int m, long long int b) {       auto y = insert({m, b});       y->succ = [=] { return next(y) == end() ? 0 : &*next(y); };       if (bad(y)) {         erase(y);         return;       }       while (next(y) != end() && bad(next(y))) erase(next(y));       while (y != begin() && bad(prev(y))) erase(prev(y));     }     long long int Query(long long int x) {       auto l = *lower_bound((Line){x, is_query});       return l.m * x + l.b;     }   };   long long int m[200005];   long long int cIA[200005];   long long int cA[200005];   int main() {     int n;     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %I64d , &m[i]);     for (int i = 1; i <= n; i++) cA[i] = cA[i - 1] + m[i];     for (int i = 1; i <= n; i++) cIA[i] = cIA[i - 1] + i * m[i];     long long int Max = 0;     HullDynamic ch;     ch.Add(0, 0);     for (int i = 1; i <= n; i++) {       Max = max(Max, ch.Query(cA[i]) + cIA[i]);       ch.Add(-i, -cIA[i] + i * cA[i]);     }     cout << Max << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int m, n;     cin >> n >> m;     int c[n];     for (int i = 0; i < n; i++) cin >> c[i];     int a[m];     for (int i = 0; i < m; i++) cin >> a[i];     int d = 0, j = 0;     for (int i = 0; i < n; i++) {       if (a[j] >= c[i]) {         d++;         j++;       }       if (d == m) break;     }     cout << d << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     long long int max = 2000000001, min = -2000000001;     long long int x, y;     string question;     char answer;     int i;     for (i = 0; i < n; i++) {       int tmp;       cin >> question;       cin >> x >> answer;       cin.get();       if (question[0] ==  < ) {         if (answer ==  Y ) {           if (x <= max)             if (question.size() == 2)               max = x;             else               max = x - 1;         } else {           if (x >= min)             if (question.size() == 2)               min = x + 1;             else               min = x;         }       } else {         if (question[0] ==  > ) {           if (answer ==  Y ) {             if (x >= min)               if (question.size() == 2)                 min = x;               else                 min = x + 1;           } else {             if (x <= max)               if (question.size() == 2)                 max = x - 1;               else                 max = x;           }         }       }     }     if (min > max) {       cout <<  Impossible  << endl;       return 0;     } else {       if (max == min)         cout << min << endl;       else         cout << min + 1 << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   double x[2], y[2], r[2], R[2];   void solve() {     double dx = x[0] - x[1];     double dy = y[0] - y[1];     double d = sqrt(dx * dx + dy * dy);     int ans = 0;     if (r[0] + R[1] <= d || d + r[0] <= r[1] || d + R[1] <= r[0]) ans++;     if (R[0] + R[1] <= d || d + R[0] <= r[1] || d + R[1] <= R[0]) ans++;     if (r[1] + R[0] <= d || d + r[1] <= r[0] || d + R[0] <= r[1]) ans++;     if (R[0] + R[1] <= d || d + R[1] <= r[0] || d + R[0] <= R[1]) ans++;     cout << ans;   }   int main() {     for (int i = 0; i < 2; i++) cin >> x[i] >> y[i] >> r[i] >> R[i];     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     int n, k;     cin >> n >> k;     int *arr = new int[n];     for (int i = 0; i < n; i++) cin >> arr[i];     int res = 0;     for (int i = 0; i < n - 1; i++) {       int k1 = arr[i] + arr[i + 1];       if (k1 < k) {         arr[i + 1] += k - k1;         res += k - k1;       }     }     cout << res <<   n ;     for (int i = 0; i < n; i++) cout << arr[i] <<    ;   }   int main() {     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void solve(int* arr, int n) {     int max_sum = 0;     int answer = 0;     for (int i = 1; i <= 30; i++) {       int current = 0;       max_sum = 0;       for (int j = 0; j < n; j++) {         if (arr[j] > i) {           current = 0;           continue;         }         current = current + arr[j];         if (current < 0) {           current = 0;         }         max_sum = max(current, max_sum);       }       answer = max(answer, max_sum - i);     }     cout << answer << endl;   }   int main() {     int n;     cin >> n;     int arr[200005];     for (int i = 0; i < n; i++) {       cin >> arr[i];     }     solve(arr, n);   }
#include <bits/stdc++.h>   using namespace std;   #pragma comment(linker,  /STACK:1024000000,1024000000 )   int _MAX(int a, int b) { return a > b ? a : b; }   int _MIN(int a, int b) { return a > b ? b : a; }   int Scan() {     int res = 0, flag = 0;     char ch;     if ((ch = getchar()) ==  - )       flag = 1;     else if (ch >=  0  && ch <=  9 )       res = ch -  0 ;     while ((ch = getchar()) >=  0  && ch <=  9 ) res = res * 10 + (ch -  0 );     return flag ? -res : res;   }   void Out(int a) {     if (a < 0) {       putchar( - );       a = -a;     }     if (a >= 10) Out(a / 10);     putchar(a % 10 +  0 );   }   long long a[100005][2];   long long dis(long long x1, long long y1, long long x2, long long y2) {     return (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1);   }   int main() {     long long n, px, py, ma = 0;     double mi = 1e16;     scanf( %lld%lld%lld , &n, &px, &py);     for (int i = 1; i <= n; ++i) {       scanf( %lld%lld , &a[i][0], &a[i][1]);       long long d = dis(a[i][0], a[i][1], px, py);       mi = min(mi, (double)d);       ma = max(ma, d);     }     a[n + 1][0] = a[1][0], a[n + 1][1] = a[1][1];     for (int i = 1; i <= n; ++i) {       long long A2 = dis(px, py, a[i][0], a[i][1]);       long long B2 = dis(px, py, a[i + 1][0], a[i + 1][1]);       long long C2 = dis(a[i][0], a[i][1], a[i + 1][0], a[i + 1][1]);       double A = sqrt(A2), B = sqrt(B2), C = sqrt(C2);       if (C2 + B2 > A2 && C2 + A2 > B2) {         double P = (A + B + C) / 2;         double S = sqrt(P * (P - A) * (P - B) * (P - C));         double H = S / C * 2;         mi = min(mi, H * H);       }     }     printf( %.10lf n , acos(-1.0) * (ma - mi));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, x;     while (scanf( %d%d , &n, &x) != EOF) {       int a[100000], b[100000];       for (int i = 0; i < n; i++) {         scanf( %d , &a[i]);       }       for (int i = 0; i < n; i++) {         scanf( %d , &b[i]);       }       int a1[200001], b1[200001];       for (int i = 0; i <= 200000; i++) {         a1[i] = 0;         b1[i] = 0;       }       for (int i = 0; i < n; i++) {         a1[a[i]]++;         b1[b[i]]++;       }       int p = -1, q = -1;       for (int i = 200000; i >= 0; i--) {         if (a1[i] > 0) {           p = i;           break;         }       }       for (int i = 0; i <= 200000; i++) {         if (b1[i] > 0 && p + i >= x) {           q = i;           break;         }       }       int worst = 0;       while (q >= 0 && q <= 200000 && p >= 0 && p <= 200000) {         if (a1[p] > b1[q]) {           worst += b1[q];           a1[p] -= b1[q];           b1[q] = 0;           while (q <= 200000) {             if (b1[q] > 0) {               break;             }             q++;           }         } else if (a1[p] < b1[q]) {           worst += a1[p];           b1[q] -= a1[p];           a1[p] = 0;           while (p >= 0) {             if (a1[p] > 0) {               break;             }             p--;           }         } else {           worst += a1[p];           a1[p] = 0;           b1[q] = 0;           while (p >= 0) {             if (a1[p] > 0) {               break;             }             p--;           }           while (q <= 200000) {             if (b1[q] > 0) {               break;             }             q++;           }         }         while (p + q < x) {           b1[q] = 0;           while (b1[q] == 0) {             q++;           }         }       }       printf( 1 %d n , worst);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, m, x, y, a, b, times, red, t3;   long long k;   void work3() {     long long t1, t2;     if (red == 0) {       times--;       red = m * 2 * (n - 1);     }     if (x != 1 && x != n)       t3 = 2 * times;     else       t3 = times;     if (red > n * m) {       t3++;       red -= n * m;       a = red / m;       b = red % m;       if (b != 0)         a++;       else         b = m;       if (n - a == x) {         if (y <= b) t3 += 1;       } else if (n - a < x) {         if (x != n) t3 += 1;       }       t1 = (times + 1) * 2;       t2 = times + 1;     } else {       a = red / m;       b = red % m;       if (b != 0)         a++;       else         b = m;       if (a == x) {         if (y <= b)           t3 += 1;         else           t3 += 0;       } else if (a > x)         t3 += 1;       if (a > 1) {         t1 = times * 2 + 1;         if (a < n || (a == n && b != m))           t2 = times;         else           t2 = times + 1;       } else {         t1 = times * 2;         if (t1 == 0) t1++;         t2 = times;       }     }     cout << t1 <<     << t2 <<     << t3 << endl;   }   int main() {     cin >> n >> m >> k >> x >> y;     if (n > 2) {       times = k / (m * 2 * (n - 1));       red = k % (m * 2 * (n - 1));       work3();     } else if (n == 1) {       long long t2;       times = k / (n * m);       red = k % (n * m);       if (red == 0) {         red = n * m;         times--;       }       if (y <= red)         t3 = times + 1;       else         t3 = times;       if (red == m)         t2 = times + 1;       else         t2 = times;       cout << times + 1 <<     << t2 <<     << t3 << endl;     } else if (n == 2) {       long long t2;       times = k / (n * m);       red = k % (n * m);       if (red == 0) {         red = n * m;         times--;       }       a = red / m;       b = red % m;       if (b != 0)         a++;       else         b = m;       if (x > a) {         t3 = times;       } else if (x == a) {         if (y <= b)           t3 = times + 1;         else           t3 = times;       } else if (x < a) {         t3 = times + 1;       }       if (a == n && b == m)         t2 = times + 1;       else         t2 = times;       cout << times + 1 <<     << t2 <<     << t3 << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     std::ios::sync_with_stdio(false);     std::cin.tie(0);     int a, b, c;     cin >> a >> b >> c;     int s = 0;     int min = a < b ? a : b;     int max = a > b ? a : b;     s += min;     if (c > (max + min))       s += (max + min);     else       s += c;     if ((c + min) < max)       s += c + min;     else       s += max;     cout << s << endl;   }
#include <bits/stdc++.h>   using namespace std;   int d[1005][1005], sum, res, s, n;   int main() {     scanf( %d , &n);     for (int res = 3; res <= 100; res++) {       memset(d, 0, sizeof(d)), sum = 0;       for (int i = 1; i <= res; i++) {         for (int j = 1; j < i; j++) {           if (sum <= n) {             int now = 0;             for (int k = 1; k <= res; k++)               if (i != k and j != k and d[i][k] and d[j][k]) now++;             if (sum + now <= n) {               sum += now;               d[i][j] = d[j][i] = 1;             }             if (sum == n) {               cout << res << endl;               for (int i1 = 1; i1 <= res; i1++) {                 for (int j1 = 1; j1 <= res; j1++) cout << d[i1][j1];                 printf(  n );               }               return 0;             }           }         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 5e5 + 5;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     int T;     cin >> T;     while (T--) {       int n, m;       cin >> n >> m;       if (n % m == 0)         cout <<  YES n ;       else         cout <<  NO n ;     }   }
#include <bits/stdc++.h>   using namespace std;   void past_code();   void file() {}   long long gcd(long long x, long long y) {     if (y == 0) return x;     return gcd(y, x % y);   }   long long todic(string z) {     long long sum = 0;     long long j = 1;     for (long long i = 0; i < z.length(); i++) {       sum += (z[i] -  0 ) * j;       j *= 2;     }     return sum;   }   string tobin(long long a) {     string x;     while (a != 0) {       x += to_string(a % 2);       a /= 2;     }     return x;   }   bool isPrime(long long n) {     if (n <= 1) return false;     for (long long i = 2; i <= sqrt(n); i++)       if (n % i == 0) return false;     return true;   }   string towlo(string x) {     string h;     for (long long i = 0; i < x.length(); i++) {       h += tolower(x[i]);     }     return h;   }   bool comp(pair<long long, long long> a, pair<long long, long long> b) {     return a.second > b.second;   }   inline void read(int &x) {     x = 0;     char c = getchar();     int f = 1;     while (c <  0  || c >  9 ) {       if (c ==  - ) f = -1;       c = getchar();     }     while (c >=  0  && c <=  9 ) {       x = 10 * x + c -  0 ;       c = getchar();     }     x *= f;   }   long long fact(long long o) {     if (o == 0) return 1;     return o * fact(o - 1);   }   long long sumd(long long x) {     long long sum = 0;     while (x != 0) {       sum += x % 10;       x /= 10;     }     return sum;   }   bool com(pair<long long, long long> a, pair<long long, long long> b) {     return a.second > b.second;   }   bool vis[505][505];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     string x;     cin >> x;     int k;     cin >> k;     map<string, int> m;     string h[] = { January ,    February ,  March ,     April ,                    May ,        June ,      July ,      August ,                    September ,  October ,   November ,  December };     m[ January ] = 0;     m[ June ] = 5;     m[ November ] = 10;     m[ February ] = 1;     m[ July ] = 6;     m[ December ] = 11;     m[ March ] = 2;     m[ August ] = 7;     m[ April ] = 3;     m[ September ] = 8;     m[ May ] = 4;     m[ October ] = 9;     cout << h[(k + m[x]) % 12] <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   void print(const T& t) {     cout << t <<   n ;   }   template <typename T, typename U, typename... ARGS>   void print(const T& t, const U& u, const ARGS&... args) {     cout << t <<    ;     print(u, args...);   }   signed main() {     ios_base::sync_with_stdio(false), cin.tie(nullptr);     long long tc;     cin >> tc;     while (tc--) {       long long x, y, n;       cin >> x >> y >> n;       long long z = (n / x) * x;       while (z + y > n) {         z -= x;       }       print(z + y);     }     return 0;   }
#include<bits/stdc++.h>   using namespace std;   #define l1 long long   void solve() {       int n; cin>>n;       vector<int> v(n);       for(auto &i:v) cin>>i;       l1 sum = 0;       l1 need = 0;       for(int i=0;i<n;i++) {           sum+=v[i];           need+=i;           if(sum<need) {cout<< NO <<endl; return;}       }       cout<< YES <<endl;          }   int main() {       int t; cin>>t;       while(t--) {           solve();       }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 500005;   const int mod = 1e9 + 7;   int n, m, l[N], r[N], f[N], sum[N];   vector<int> g[N];   vector<int> cmp;   int main() {     scanf( %d %d , &n, &m);     for (int i = 0; i < m; ++i) {       scanf( %d %d , l + i, r + i);       cmp.push_back(r[i]);       cmp.push_back(l[i]);     }     sort(cmp.begin(), cmp.end());     cmp.erase(unique(cmp.begin(), cmp.end()), cmp.end());     if (cmp.empty() || cmp[0] != 0 || cmp.back() != n) {       cout << 0 << endl;       return 0;     }     for (int i = 0; i < m; ++i) {       l[i] = lower_bound(cmp.begin(), cmp.end(), l[i]) - cmp.begin();       r[i] = lower_bound(cmp.begin(), cmp.end(), r[i]) - cmp.begin();       g[r[i]].push_back(l[i]);     }     f[0] = sum[0] = 1;     for (int i = 1; i < (int)cmp.size(); ++i) {       for (auto& pos : g[i]) {         int add = sum[i - 1];         if (pos > 0) add = (add + (mod - sum[pos - 1])) % mod;         f[i] = (f[i] + add) % mod;       }       sum[i] = (f[i] + sum[i - 1]) % mod;     }     cout << f[cmp.size() - 1] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1000 * 100 + 10, mod = 100000007;   int a[N];   int n;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     ;     cin >> n;     for (int i = 0; i < n; i++) cin >> a[i];     vector<int> ans;     for (int i = 0; i < n; i++) {       int val = a[i];       int pos = lower_bound(ans.begin(), ans.end(), val) - ans.begin();       if (pos < int(ans.size()))         ans[pos] = val;       else         ans.push_back(val);     }     cout << int(ans.size()) << endl;   }