malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 5;   const long long INF = 1e9 + 5;   const long long mod = 1e9 + 7;   const double pi = 3.1415926536;   map<char, int> mp, mp2;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     ios_base::sync_with_stdio(0);     ;     string n, m;     cin >> n >> m;     for (int i = 0; i < n.size(); i++) {       mp[n[i]]++;     }     set<char> st;     for (int i = 0; i < m.size(); i++) {       st.insert(m[i]);       mp2[m[i]]++;       if (!mp[m[i]]) return cout <<  -1 n , 0;     }     long long ans = 0;     set<char>::iterator it;     for (it = st.begin(); it != st.end(); it++) {       ans += min(mp[*it], mp2[*it]);     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, l, r, K, p;   bool check(long long x) {     long long t = K % (n + x);     if (t == 0) t = n + x;     if (t > min(p * 2, p + x)) return 0;     if (t < p + max(0LL, x - n + p - 1)) return 0;     return 1;   }   signed main() {     scanf( %lld%lld%lld%lld , &n, &l, &r, &K);     p = (r - l + 1 + n) % n;     if (p > K) {       return puts( -1 ), 0;     }     if (p == 0) p += n;     if (n <= 100000) {       for (long long i = n; i >= 0; i--)         if (check(i)) {           printf( %lld n , i);           return 0;         }       puts( -1 );       return 0;     }     long long ans = 0;     for (long long t = ceil((double)(K - 2 * p) / (double)(2 * n));          t * n + p <= K; t++) {       long long y = K - n * t - p;       long long x;       if (t != 0)         x = min((long long)floor((double)(n - p + y) / (1 + t)),                 (long long)y / t);       else {         x = (K - p + 1) + (n - p);       }       y = K - n * t - p - t * x;       if (y < 0 || y > p || y > x || x > n) continue;       ans = max(ans, x);       y = K - n * t - p + 1;       if (t != 0)         x = min((long long)floor((double)(n - p + y) / (1 + t)),                 (long long)y / t);       else {         x = (K - p + 1) + (n - p);       }       y = K - n * t - p - t * x;       if (y < 0 || y > p || y > x || x > n) continue;       ans = max(ans, x);     }     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long gcd(long long a, long long b) {     while (a) {       b %= a;       swap(a, b);     }     return b;   }   struct Vector2D {     long long x, y;     Vector2D() {}     Vector2D(long long x, long long y) : x(x), y(y) {}   };   Vector2D operator-(const Vector2D& lhs, const Vector2D& rhs) {     return Vector2D(lhs.x - rhs.x, lhs.y - rhs.y);   }   bool operator==(const Vector2D& lhs, const Vector2D& rhs) {     return lhs.x == rhs.x && lhs.y == rhs.y;   }   Vector2D normalize(const Vector2D& v) {     const long long g = gcd(abs(v.x), abs(v.y));     return Vector2D(v.x / g, v.y / g);   }   struct Vector2DHash {     size_t operator()(const Vector2D& v) const { return v.x * 1000000007 + v.y; }   };   class OrderByLength {    public:     OrderByLength(const vector<Vector2D>& targets, const Vector2D& base)         : targets_(targets), base_(base) {}     bool operator()(const int lhs_, const int rhs_) const {       const Vector2D lhs = targets_[lhs_] - base_;       const Vector2D rhs = targets_[rhs_] - base_;       return lhs.x * lhs.x + lhs.y * lhs.y < rhs.x * rhs.x + rhs.y * rhs.y;     }       private:     const vector<Vector2D>& targets_;     const Vector2D& base_;   };   bool check(const vector<Vector2D>& bears, const vector<Vector2D>& targets,              vector<unordered_map<Vector2D, vector<int>, Vector2DHash> >& maps,              const int target, const vector<int>& order, int& next,              vector<int>& killed) {     if (next == order.size()) return false;     const int bear = order[next];     const vector<int>& onLine =         maps[bear][normalize(targets[target] - bears[bear])];     for (int nextTarget : onLine) {       if (target == nextTarget) {         killed.push_back(target);         return true;       }       if (find(killed.begin(), killed.end(), nextTarget) != killed.end())         continue;       if (!check(bears, targets, maps, nextTarget, order, ++next, killed)) break;     }     return false;   }   int main() {     int k, n;     cin >> k >> n;     vector<Vector2D> bears(k);     vector<Vector2D> targets(n);     for (int i = 0; i < k; ++i) cin >> bears[i].x >> bears[i].y;     for (int i = 0; i < n; ++i) cin >> targets[i].x >> targets[i].y;     vector<unordered_map<Vector2D, vector<int>, Vector2DHash> > maps(k);     for (int i = 0; i < k; ++i) {       for (int j = 0; j < n; ++j)         maps[i][normalize(targets[j] - bears[i])].push_back(j);       for (auto& p : maps[i])         sort(p.second.begin(), p.second.end(), OrderByLength(targets, bears[i]));     }     int res = 0;     for (int i = 0; i < n; ++i) {       bool danger = false;       vector<int> order(k);       iota(order.begin(), order.end(), 0);       do {         vector<int> killed;         int next = 0;         danger |= check(bears, targets, maps, i, order, next, killed);       } while (!danger && next_permutation(order.begin(), order.end()));       res += danger;     }     cout << res << endl;   }
#include <bits/stdc++.h>      using namespace std;      pair<int, int> dataarr[502];      int main() {       int n;       cin >> n;       int minin = n, maxin = 0;       for (int i = 1; i <= n; i++) {           cin >> dataarr[i].first;           dataarr[i].second = i;           if (dataarr[i].first < minin) {               minin = dataarr[i].first;           }           if (dataarr[i].first > maxin) {               maxin = dataarr[i].first;           }       }       int indif = maxin - minin;       sort(dataarr, dataarr + (n + 1));       for (int d = indif; d >= 0; d--) {           for (int i = 1; i <= n; i++) {               for (int j = i + 1; j <= n; j++) {                   if (dataarr[j].first - dataarr[i].first == d) {                       cout <<  ?   << dataarr[j].second <<     << dataarr[i].second << endl;                       string s;                       cin >> s;                       if (s ==  Yes ) {                           cout <<  !   << dataarr[j].second <<     << dataarr[i].second << endl;                           return(0);                       }                   }               }           }       }       cout <<  ! 0 0  << endl;       return(0);   }
#include <bits/stdc++.h>   using namespace std;   struct point {     long long int x, y;     point() {}     point(long long int _x, long long int _y) {       x = _x;       y = _y;     }   };   bool cmp(const point &a, const point &b) {     if (a.x == b.x) return a.y < b.y;     return a.x < b.x;   }   struct freq {     long long int x_freq;     set<long long int> y_freq;   };   freq freq_list[200005];   point S[200010];   long long int mod;   long long int fact_mod(long long int k) {     long long int ans = 1;     while (k > 0) {       ans = (ans % mod * k % mod) % mod;       --k;     }     return ans % mod;   }   int main() {     int N;     cin >> N;     for (int i = 0; i < N; ++i) {       int x;       cin >> x;       S[i] = point(x, i);     }     for (int i = 0; i < N; ++i) {       int x;       cin >> x;       S[N + i] = point(x, i);     }     cin >> mod;     sort(S, S + 2 * N, cmp);     int last = -1, cnt = -1, m;     for (int i = 0; i < 2 * N; ++i) {       if (S[i].x != last) {         ++cnt;         last = S[i].x;         freq_list[cnt].x_freq = 1;         freq_list[cnt].y_freq.insert(S[i].y);       } else {         ++freq_list[cnt].x_freq;         freq_list[cnt].y_freq.insert(S[i].y);       }     }     long long int ans = 1, n;     for (int i = 0; i <= cnt; ++i) {       m = freq_list[i].x_freq - freq_list[i].y_freq.size();       n = freq_list[i].x_freq;       int k = n;       for (int j = 0; j < m; ++j) {         ans = ((ans % mod) * ((n * (n - 1) / 2LL) % mod)) % mod;         n -= 2;       }       ans = ((ans % mod) * (fact_mod(k - 2 * m) % mod)) % mod;     }     cout << ans % mod << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double EPS = 1e-10;   const double PI = acos(-1.0);   struct Edge {     int to, cost;     Edge(int t, int c) : to(t), cost(c) {}     bool operator>(const Edge& rhs) const { return cost > rhs.cost; }   };   long long N, S;   vector<int> dp, parent;   vector<vector<Edge>> G;   void dfs(int par, int node, int d) {     parent[node] = par;     dp[node] = 1;     for (int i = 0; i < int((G[node]).size()); ++i) {       int& to = G[node][i].to;       if (to == par) continue;       dfs(node, to, d + 1);       dp[node] += dp[to];       S += 2 * dp[to] * (N - dp[to]) * G[node][i].cost;     }   }   int main() {     cin.tie(0);     ios_base::sync_with_stdio(false);     cin >> N;     G.assign(N + 1, vector<Edge>());     vector<pair<int, Edge>> edges;     for (int i = (0); i < (N - 1); ++i) {       int a, b, c;       cin >> a >> b >> c;       G[a].push_back(Edge(b, c));       G[b].push_back(Edge(a, c));       edges.push_back(make_pair(a, Edge(b, c)));     }     dp.assign(N + 1, 0);     parent.assign(N + 1, -1);     S = 0;     dfs(-1, 1, 0);     int Q;     cin >> Q;     while (Q--) {       int idx, c;       cin >> idx >> c;       --idx;       Edge& e = edges[idx].second;       int a = edges[idx].first, b = e.to;       if (parent[b] == a) swap(a, b);       S -= (e.cost - c) * 2 * dp[a] * (N - dp[a]);       cout << fixed << setprecision(7) << 3 * S * 1. / (N * (N - 1)) << endl;       e.cost = c;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string a, b;   int k;   int main() {     cin >> a;     k = 1;     if (a.size() % 2 == 0) {       while (k != a.size() + 1) {         if (k % 2 != 0) {           b += a[a.size() - k / 2 - 1];         } else {           b += a[k / 2 - 1];         }         k++;       }     } else {       while (k != a.size() + 1) {         if (k % 2 == 0) {           b += a[a.size() - k / 2];         } else {           b += a[k / 2];         }         k++;       }     }     reverse(b.begin(), b.end());     cout << b;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2005, INF = 1e9;   int dx[] = {1, -1, 0, 0};   int dy[] = {0, 0, 1, -1};   pair<int, int> dis[N][N];   bool done[N][N];   string g[N];   int n, m, sx, sy, L, R;   bool valid(int x, int y) {     return x >= 0 && x < n && y >= 0 && y < m && g[x][y] ==  . ;   }   void solve(bool fs) {     priority_queue<pair<pair<int, int>, pair<int, int>>,                    vector<pair<pair<int, int>, pair<int, int>>>,                    greater<pair<pair<int, int>, pair<int, int>>>>         pq;     for (int i = 0; i < n; i++)       for (int j = 0; j < m; j++) dis[i][j] = {INF, INF};     dis[sx][sy] = {0, 0};     pq.push({{0, 0}, {sx, sy}});     while (!pq.empty()) {       int x = pq.top().second.first;       int y = pq.top().second.second;       pair<int, int> d = pq.top().first;       pq.pop();       if (dis[x][y] < d) continue;       if (fs && dis[x][y].first <= L && dis[x][y].second <= R) done[x][y] = 1;       if ((!fs) && dis[x][y].first <= R && dis[x][y].second <= L) done[x][y] = 1;       for (int i = 0; i < 4; i++) {         int nx = x + dx[i], ny = y + dy[i];         if (valid(nx, ny)) {           pair<int, int> p = {0, 0};           if (dy[i] < 0) {             if (fs)               p = {1, 0};             else               p = {0, 1};           }           if (dy[i] > 0) {             if (fs)               p = {0, 1};             else               p = {1, 0};           }           pair<int, int> np = {d.first + p.first, d.second + p.second};           if (np < dis[nx][ny]) {             dis[nx][ny] = np;             pq.push({np, {nx, ny}});           }         }       }     }   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n >> m;     cin >> sx >> sy;     sx--;     sy--;     cin >> L >> R;     for (int i = 0; i < n; i++) cin >> g[i];     solve(0);     solve(1);     int ans = 0;     for (int i = 0; i < n; i++)       for (int j = 0; j < m; j++) ans += done[i][j];     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   long long int gcd(long long int a, long long int b) {     return (a ? gcd(b % a, a) : b);   }   inline int two(int n) { return 1 << n; }   inline int test(int n, int b) { return (n >> b) & 1; }   inline void set_bit(int& n, int b) { n |= two(b); }   inline void unset_bit(int& n, int b) { n &= ~two(b); }   inline int last_bit(int n) { return n & (-n); }   inline int ones(int n) {     int res = 0;     while (n && ++res) n -= n & (-n);     return res;   }   long long int modPow(long long int a, long long int b, long long int MOD) {     long long int x = 1, y = a;     while (b > 0) {       if (b % 2 == 1) {         x = (x * y) % MOD;       }       b /= 2;       y = (y * y) % MOD;     }     return x;   }   long long int modInverse(long long int a, long long int p) {     return modPow(a, p - 2, p);   }   using namespace std;   int main() {     int n, k, i, from, to;     long long int crossed_count, ans;     crossed_count = 0;     ans = 1;     scanf( %d , &n);     scanf( %d , &k);     k = min(k, n - k);     from = 0;     for (int i = (1); i <= (n); i++) {       to = (from + k) % n;       if (to < from && to != 0) crossed_count++;       ans += crossed_count + 1;       if (to < from) crossed_count++;       printf( %lld  , ans);       from = to;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 200010;   long long a[N], b[N], p[N], money;   int top, n, m, ans, st[N];   vector<long long> v[N];   priority_queue<long long> q;   void get_sale_day() {     for (int i = 1; i <= n; ++i) {       while (top && a[i] >= a[st[top]]) --top;       st[++top] = i;     }     for (int i = 1; i <= m; ++i) {       if (b[i] > a[st[1]]) continue;       int l = 1, r = top, ans = 0;       while (l <= r) {         int mid = (l + r) >> 1;         if (a[st[mid]] >= b[i])           ans = mid, l = mid + 1;         else           r = mid - 1;       }       v[st[ans]].push_back(p[i]);     }   }   int main() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; ++i) scanf( %lld , &a[i]);     for (int i = 1; i <= m; ++i) scanf( %lld , &b[i]);     for (int i = 1; i <= m; ++i) scanf( %lld , &p[i]);     get_sale_day();     for (int i = 1; i <= n; ++i) {       money += a[i];       sort(v[i].begin(), v[i].end());       for (int j = 0; j < v[i].size(); ++j)         if (v[i][j] <= money) {           money -= v[i][j];           q.push(v[i][j]);           ans++;         } else {           if (q.empty()) continue;           long long tmp = q.top();           if (tmp > v[i][j]) {             q.pop();             q.push(v[i][j]);             money += tmp - v[i][j];           }         }     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 1000000007;   const int Maxn = 500005;   map<long long, int> mp;   vector<pair<int, int> > g[Maxn];   long long c[Maxn];   int pw2[Maxn] = {1}, par[Maxn], n, m, k, sz, ans;   int find(int u) { return par[u] == u ? u : par[u] = find(par[u]); }   int main() {     scanf( %d%d%d , &n, &m, &k);     for (int i = 1; i <= n; i++) pw2[i] = pw2[i - 1] * 2 % mod;     for (int i = 1; i <= n; i++) scanf( %lld , &c[i]);     for (int i = 1; i <= n; i++) par[i] = i;     for (int x, y; m--;) {       scanf( %d%d , &x, &y);       if (!mp[c[x] ^ c[y]]) mp[c[x] ^ c[y]] = ++sz;       g[mp[c[x] ^ c[y]]].push_back(make_pair(x, y));     }     for (int i = 1; i <= sz; ++i) {       int s = n;       for (int j = 0; j < g[i].size(); j++) {         int x = find(g[i][j].first), y = find(g[i][j].second);         if (x ^ y) par[x] = y, s--;       }       ans = (ans + pw2[s]) % mod;       for (int j = 0; j < g[i].size(); j++)         par[g[i][j].first] = g[i][j].first, par[g[i][j].second] = g[i][j].second;     }     ans = (ans + (long long)((1ll << k) - sz + mod) % mod * pw2[n] % mod) % mod;     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   std::vector<int> dsc[100005];   int st[5005], fi[5005], vt[5005], nx[5005], mx[5005];   int a[100005];   double prob[5005];   double f[5005][5005 + 5];   void sx(int l, int r) {     if (l >= r) return;     int i = l, j = r;     int chot = vt[l + rand() % (r - l + 1)];     int chot2 = fi[chot];     chot = st[chot];     while (i <= j) {       while (st[vt[i]] < chot || (st[vt[i]] == chot && fi[vt[i]] > chot2)) i++;       while (st[vt[j]] > chot || (st[vt[j]] == chot && fi[vt[j]] < chot2)) j--;       if (i <= j) {         if (i < j) {           int tg = vt[i];           vt[i] = vt[j];           vt[j] = tg;         }         i++;         j--;       }     }     sx(i, r);     sx(l, j);   }   void duyet(int ii) {     int sz = dsc[ii].size();     mx[ii] = 0;     if (sz == 0) {       for (int i = st[ii]; i <= fi[ii]; i++)         if (mx[ii] < a[i]) mx[ii] = a[i];     } else {       for (int i = st[ii]; i < st[dsc[ii][0]]; i++)         if (mx[ii] < a[i]) mx[ii] = a[i];       for (int j = 0; j < sz - 1; j++) {         for (int i = fi[dsc[ii][j]] + 1; i < st[dsc[ii][j + 1]]; i++)           if (mx[ii] < a[i]) mx[ii] = a[i];       }       for (int i = fi[dsc[ii][sz - 1]] + 1; i <= fi[ii]; i++)         if (mx[ii] < a[i]) mx[ii] = a[i];     }     for (int i = 0; i < sz; i++) {       duyet(dsc[ii][i]);       if (mx[dsc[ii][i]] > mx[ii]) mx[ii] = mx[dsc[ii][i]];     }     if (sz == 0) {       f[ii][0] = 1 - prob[ii];       for (int j = 1; j < 5005; j++) f[ii][j] = 1.0;     } else {       double f1, f2;       for (int j = 0; j < 5005; j++) {         f1 = f2 = 1.0;         for (int i = 0; i < sz; i++) {           int tmp = mx[ii] - mx[dsc[ii][i]] + j;           if (tmp >= 5005) tmp = 5005 - 1;           f1 *= f[dsc[ii][i]][tmp];           tmp = mx[ii] - mx[dsc[ii][i]] + j - 1;           if (tmp >= 5005) tmp = 5005 - 1;           if (tmp < 0)             f2 = 0;           else             f2 *= f[dsc[ii][i]][tmp];         }         if (j > 0)           f[ii][j] = (1 - prob[ii]) * f1 + prob[ii] * f2;         else           f[ii][j] = (1 - prob[ii]) * f1;       }     }   }   int main() {     int n, q;     scanf( %d%d , &n, &q);     for (int i = 1; i <= n; i++) scanf( %d , &a[i]);     for (int i = 1; i <= q; i++) {       scanf( %d%d%lf , &st[i], &fi[i], &prob[i]);       vt[i] = i;     }     srand(time(NULL));     sx(1, q);     q++;     st[0] = 1;     fi[0] = n;     prob[0] = 0;     vt[0] = 0;     nx[0] = 0;     int topNX = 0;     for (int i = 1; i <= n; i++) dsc[i].clear();     for (int i = 1; i < q; i++) {       while (fi[vt[nx[topNX]]] < fi[vt[i]]) topNX--;       dsc[vt[nx[topNX]]].push_back(vt[i]);       nx[++topNX] = i;     }     duyet(0);     double res = 0.0;     for (int j = 0; j < 5005; j++) {       double pp = f[0][j];       if (j > 0) pp -= f[0][j - 1];       res += pp * (mx[0] + j);     }     printf( %.10lf , res);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxv = 2045;   const long long mod = 1e9 + 7;   const int maxn = 1e6 + 40;   long long fac[maxn], inv[maxn];   long long qpow(long long a, long long p) {     long long ans = 1;     long long xx = a;     while (p > 0) {       if (p & 1) ans = (xx * ans) % mod;       xx = (xx * xx) % mod;       p >>= 1;     }     return ans;   }   void init() {     fac[0] = 1;     inv[0] = 1;     for (long long i = 1; i < maxn; i++) {       fac[i] = (fac[i - 1] * i) % mod;       inv[i] = inv[i - 1] * qpow(i, mod - 2) % mod;     }   }   int h, w, n;   pair<long long, long long> a[maxv];   long long dp[maxv];   long long culC(long long a, long long b) {     return fac[a] * inv[a - b] % mod * inv[b] % mod;   }   long long path(long long sx, long long sy, long long tx, long long ty) {     return culC(ty - sy + tx - sx, tx - sx);   }   void solve() {     for (int i = 0; i <= n; i++) {       long long ans = 0;       for (int j = 0; j < i; j++) {         if (a[j].second <= a[i].second)           ans += path(a[j].first, a[j].second, a[i].first, a[i].second) * dp[j] %                  mod,               ans %= mod;       }       dp[i] = (path(1, 1, a[i].first, a[i].second) - ans) % mod + mod,       dp[i] %= mod;     }   }   int main() {     init();     cin >> h >> w >> n;     for (int i = 0; i < n; i++) {       int c, r;       scanf( %d%d , &r, &c);       a[i].first = r;       a[i].second = c;     }     sort(a, a + n);     a[n] = pair<long long, long long>(h, w);     solve();     cout << dp[n] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, md, len, i, j, k, prv, c[505][505], dpf[505][505], dpr[505][505];   long long cur, crst, f[505], rst[505];   long long sum(long long x) { return (x * (x + 1LL)) / 2; }   int main() {     scanf( %d%d%d , &n, &m, &md);     for (i = 0; i <= n; i++) {       c[i][0] = 1;       for (j = 1; j <= i; j++) c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % md;     }     for (i = 0; i < n; i++)       for (k = 0; k <= i; k++) {         cur = c[i][k];         crst = 0;         if (k > 0) {           crst = (crst * f[k - 1] + cur * rst[k - 1]) % md;           cur = (cur * f[k - 1]) % md;         }         if (k < i) {           crst = (crst * f[i - k - 1] + cur * rst[i - k - 1]) % md;           cur = (cur * f[i - k - 1]) % md;         }         rst[i] = (rst[i] + crst * (i + 2LL) + cur * (sum(k) + sum(i - k))) % md;         f[i] = (f[i] + (i + 2LL) * cur) % md;       }     dpf[0][0] = 1;     for (i = 1; i <= n; i++)       for (j = 0; j <= i && j <= m; j++) {         dpf[i][j] = dpf[i - 1][j];         dpr[i][j] = dpr[i - 1][j];         for (k = 1; k <= j; k++) {           prv = i - k;           if (prv > 0) --prv;           if (j - k <= prv) {             dpr[i][j] = (dpr[i][j] + c[j][k] * ((dpr[prv][j - k] * f[k - 1] +                                                  dpf[prv][j - k] * rst[k - 1]) %                                                 md)) %                         md;             dpf[i][j] =                 (dpf[i][j] + c[j][k] * ((dpf[prv][j - k] * f[k - 1]) % md)) % md;           }         }       }     printf( %d n , dpr[n][m]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   constexpr long long int MOD = 1000000007;   constexpr double EPS = 1e-8;   long long int N, M, K, H, W, L, R;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cin >> N;     vector<int> v(N);     for (auto &i : v) cin >> i >> i;     cin >> K;     for (int i = 0; i < N; i++) {       if (v[i] >= K) {         cout << N - i << endl;         break;       }     }   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:36777216 )   using namespace std;   int n, m;   long long f[2005][2005], sum[2005][2005];   char ch[2005];   int main() {     cin >> n >> m;     scanf(  %s , ch + 1);     f[0][0] = 1;     for (int i = 0; i <= n; i++) sum[i][0] = 1;     for (int i = 1; i <= n; i++)       for (int j = 0; j <= m; j++) {         if (i != n)           f[i][j] += sum[i - 1][j] * (ch[i] -  a ), f[i][j] %= 1000000007;         if (i == n)           f[i][j] += sum[i - 1][j] * (ch[i] -  a  + 1), f[i][j] %= 1000000007;         for (int k = 0; j - (n - i + 1) * (k + 1) >= 0 && i - 1 - k >= 0; k++) {           f[i][j] += f[i - 1 - k][j - (n - i + 1) * (k + 1)] * ( z  - ch[i]);           f[i][j] %= 1000000007;         }         sum[i][j] = sum[i - 1][j] + f[i][j];         sum[i][j] %= 1000000007;       }     cout << f[n][m] << endl;   }