malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   template <class T>   inline void chkmin(T &a, T b) {     if (a > b) a = b;   }   template <class T>   inline void chkmax(T &a, T b) {     if (a < b) a = b;   }   inline int read() {     int s = 0, f = 1;     char ch = getchar();     while (!isdigit(ch) && ch !=  - ) ch = getchar();     if (ch ==  - ) ch = getchar(), f = -1;     while (isdigit(ch)) s = s * 10 + ch -  0 , ch = getchar();     return ~f ? s : -s;   }   const int maxn = 1e5 + 20;   int n, q, t;   long long now;   int fa[maxn], to[maxn];   int a[maxn];   int f[maxn], vis[maxn];   inline void init() {     n = read();     q = read();     t = read();     for (int i = (1), _end_ = (n); i <= _end_; i++) a[i] = read();     for (int i = (1), _end_ = (q); i <= _end_; i++) {       int x = read(), y = read();       to[x] = y;       fa[y] = x;     }     for (int i = (1), _end_ = (n); i <= _end_; i++)       if (!fa[i]) {         int x = i;         while (to[x]) {           if (vis[x]) puts( 0 ), exit(0);           vis[x] = 1;           now += a[x];           a[to[x]] += a[x];           x = to[x];         }         vis[x] = 1;       }     for (int i = (1), _end_ = (n); i <= _end_; i++)       if (!vis[i]) puts( 0 ), exit(0);   }   const int mod = 1e9 + 7;   inline void pls(int &a, int b) {     a += b;     a -= a >= mod ? mod : 0;   }   inline void doing() {     f[0] = 1;     for (int j = (1), _end_ = (n); j <= _end_; j++) {       for (int i = a[j]; i <= t - now; i++) pls(f[i], f[i - a[j]]);     }     if (now <= t)       printf( %d n , f[t - now]);     else       puts( 0 );   }   int main() {     init();     doing();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 35000, K = 50;   struct seg_node {     seg_node *lc, *rc;     int l, r, f, m;     seg_node(seg_node *lc, seg_node *rc, int l, int r)         : lc(lc), rc(rc), l(l), r(r), f(), m() {}     static seg_node *build(int l, int r) {       if (l == r - 1) return new seg_node(nullptr, nullptr, l, r);       int mid = (l + r) / 2;       return new seg_node(build(l, mid), build(mid, r), l, r);     }     void add(int val) {       f += val;       m += val;     }     void push_down() {       if (f > 0) {         lc->add(f);         rc->add(f);         f = 0;       }     }     void maintain() { m = max({m, lc->m, rc->m}); }     void add(int ql, int qr, int val) {       if (ql == l && qr == r)         add(val);       else {         push_down();         int mid = (l + r) / 2;         if (qr <= mid)           lc->add(ql, qr, val);         else if (ql >= mid)           rc->add(ql, qr, val);         else {           lc->add(ql, mid, val);           rc->add(mid, qr, val);         }         maintain();       }     }     int query(int ql, int qr) {       if (ql == l && qr == r)         return m;       else {         push_down();         int mid = (l + r) / 2;         if (qr <= mid)           return lc->query(ql, qr);         else if (ql >= mid)           return rc->query(ql, qr);         else           return max(lc->query(ql, mid), rc->query(mid, qr));       }     }   } * t[K + 1];   int a[N], last[N];   int main() {     ios::sync_with_stdio(false);     int n, k;     cin >> n >> k;     int cnt = 0;     t[1] = seg_node::build(0, n);     memset(last, 0xff, sizeof last);     for (int i = 0; i < n; i++) {       cin >> a[i];       a[i]--;       if (last[a[i]] == -1) {         cnt++;         last[a[i]] = i;       }       t[1]->add(i, i + 1, cnt);     }     for (int i = 2; i <= k; i++) {       t[i] = seg_node::build(0, n);       memset(last, 0xff, sizeof last);       for (int j = i - 1; j < n; j++) {         t[i - 1]->add(last[a[j]] == -1 ? i - 2 : last[a[j]], j, 1);         t[i]->add(j, j + 1, t[i - 1]->query(i - 2, j));         last[a[j]] = j;       }     }     cout << t[k]->query(n - 1, n);   }
#include <bits/stdc++.h>   using namespace std;   int n;   int a[222222];   set<int> s;   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       s.insert(i);     }     for (int i = 1; i <= n; i++) {       scanf( %d , &a[i]);       if (a[i] != 0) {         s.erase(a[i]);       }     }     int idx = n;     int iidx = 0;     int iiidx = -1;     for (auto &x : s) {       while (a[idx] != 0) {         idx--;       }       a[idx] = x;       iidx = idx;       if (iiidx == -1) {         iiidx = idx;       }     }     for (int i = 1; i <= n; i++) {       if (a[i] == i) {         if (i == iidx) {           a[i] = a[iiidx];           a[iiidx] = i;         } else {           a[i] = a[iidx];           a[iidx] = i;         }         break;       }     }     for (int i = 1; i <= n; i++) {       printf( %d  , a[i]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     long long ans = 0;     int t = n;     for (int i = 2; i * i <= t; ++i) {       while (n % i == 0) {         ans += n;         n /= i;       }     }     ans += n == 1 ? 1 : n + 1;     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int freq[101];   int main() {     int n, x, max = 0, count = 0;     cin >> n;     string s;     if (n == 1) {       cin >> s;       sort(s.begin(), s.end());       for (int i = 0; i < s.length(); i++) {         if (s[i] == s[i + 1]) count++;       }       cout << count << endl;     } else if (n > 1) {       int arr[101] = {};       for (int i = 1; i <= n; i++) {         cin >> x;         freq[x]++;       }       for (int i = 0; i < 101; i++) {         if (freq[i] > max) max = freq[i];       }       cout << max;       return 0;     }   }
#include <bits/stdc++.h>   using namespace std;   const int INF = INT_MAX;   const signed long long int LINF = LLONG_MAX;   const double EPS = 1e-9;   const int MOD = 1000000007;   const int MAXN = 100001;   const int ALPH = 26;   const int DALPH = 52;   string s;   vector<int> z;   vector<pair<int, int> > ans;   vector<int> add, sum;   int main() {     cin >> s;     z.resize((int)(s).size());     int l = 0, r = 0;     z[0] = (int)(s).size();     for (int i = 1; i < (int)(s).size(); ++i) {       int j = 0;       if (i <= r) {         int ind = i - l;         j = min(z[ind], r - i + 1);       }       for (; i + j < (int)(s).size(); ++j) {         if (s[j] != s[i + j]) {           break;         }       }       z[i] = j;       if (i + j - 1 > r) {         r = i + j - 1;         l = i;       }     }     add.resize((int)(s).size());     for (int i = 1; i < (int)(s).size(); ++i) {       add[0]++;       add[z[i]]--;     }     sum.resize((int)(s).size());     int cnt = 0;     for (int i = 0; i < (int)(s).size(); ++i) {       cnt += add[i];       sum[i] = cnt + 1;     }     for (int i = (int)(s).size() - 1; i >= 0; --i) {       if (i + z[i] != (int)(s).size()) {         continue;       }       ans.push_back(make_pair((z[i]), (sum[z[i] - 1])));     }     printf( %d n , (int)(ans).size());     for (int i = 0; i < (int)(ans).size(); ++i) {       printf( %d %d n , ans[i].first, ans[i].second);     }   }
#include <bits/stdc++.h>   using namespace std;   const int INF = (int)1e9;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     int n;     cin >> n;     vector<int> xx(n);     vector<int> yy(n);     vector<int> diff(n);     for (int i = 0; i < n; i++) {       string s;       cin >> s;       xx[i] = count(s.begin(), s.end(),  B );       yy[i] = (int)s.size() - xx[i];       diff[i] = yy[i] - xx[i];     }     int maxX = *max_element(xx.begin(), xx.end());     int minX = *min_element(xx.begin(), xx.end());     int maxY = *max_element(yy.begin(), yy.end());     int minY = *min_element(yy.begin(), yy.end());     int max_diff = *max_element(diff.begin(), diff.end());     int min_diff = *min_element(diff.begin(), diff.end());     auto Works = [&](int dist) -> pair<int, int> {       int x1 = maxX - dist;       int x2 = minX + dist;       int y1 = maxY - dist;       int y2 = minY + dist;       int d1 = max_diff - dist;       int d2 = min_diff + dist;       auto Inside = [&](int x, int y) {         int d = y - x;         return (x1 <= x && x <= x2 && y1 <= y && y <= y2 && d1 <= d && d <= d2 &&                 x + y >= 1);       };       {         int x = x2;         int y = d1 + x;         y = max(y, y1);         y = min(y, y2);         if (Inside(x, y)) {           return {x, y};         }       }       {         int y = y2;         int x = y - d1;         x = max(x, x1);         x = min(x, x2);         if (Inside(x, y)) {           return {x, y};         }       }       return {-1, -1};     };     int low = 0, high = 5e5;     while (low < high) {       int mid = (low + high) / 2;       if (Works(mid).first != -1) {         high = mid;       } else {         low = mid + 1;       }     }     auto [k0, k1] = Works(low);     cout << low <<   n ;     cout << string(k0,  B ) + string(k1,  N ) <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 100100;   const int INF = 1000000000;   int n, m, numV;   int head[MAXN], e_cnt, s, t;   bool volunt[MAXN];   struct Edg {     int v, next;   } edg[MAXN * 4];   inline void add(int a, int b) {     edg[e_cnt].v = b;     edg[e_cnt].next = head[a];     head[a] = e_cnt++;   }   int dis[MAXN];   bool inq[MAXN];   bool spfa(int x) {     for (int i = 1; i <= n; ++i) dis[i] = INF;     dis[s] = 0;     queue<int> q;     q.push(s);     while (!q.empty()) {       int u = q.front();       q.pop();       inq[u] = 0;       if (volunt[u]) dis[u] = 0;       for (int i = head[u]; i != -1; i = edg[i].next) {         int v = edg[i].v;         if (dis[v] > dis[u] + 1 && dis[u] + 1 <= x) {           dis[v] = dis[u] + 1;           if (!inq[v]) q.push(v);           inq[v] = 1;         }       }     }     return dis[t] != INF;   }   int main() {     while (scanf( %d%d%d , &n, &m, &numV) != EOF) {       memset(volunt, 0, sizeof(volunt));       e_cnt = 0;       memset(head, -1, sizeof(head));       for (int i = 0, j; i < numV; ++i) {         scanf( %d , &j);         volunt[j] = 1;       }       for (int i = 0; i < m; ++i) {         int ta, tb;         scanf( %d%d , &ta, &tb);         add(ta, tb);         add(tb, ta);       }       scanf( %d%d , &s, &t);       int rt(m), lt(1), ans(-1);       while (lt <= rt) {         int mid = (lt + rt) >> 1;         if (spfa(mid)) {           rt = mid - 1;           ans = mid;         } else           lt = mid + 1;       }       printf( %d n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   vector<pair<int, int> > edges;   vector<int> conn[201];   bool v1[201], v2[201];   int mx = 0;   void setEdge(int a, int b, int v) {     for (int s = 0; s < conn[a].size(); s++) {       if (conn[a][s] == b || conn[a][s] == -1) conn[a][s] = (v == 1 ? b : -1);     }     for (int s = 0; s < conn[b].size(); s++) {       if (conn[b][s] == a || conn[b][s] == -1) conn[b][s] = (v == 1 ? a : -1);     }   }   int getHeight(int i) {     v2[i] = 1;     int ret = 0;     for (int j = 0; j < conn[i].size(); j++) {       if (conn[i][j] != -1 && !v2[conn[i][j]]) {         ret = max(ret, 1 + getHeight(conn[i][j]));       }     }     v2[i] = 0;     return ret;   }   int longestPath(int i) {     v1[i] = 1;     int ret = 0;     int cnt = 0;     for (int j = 0; j < conn[i].size(); j++) {       if (conn[i][j] != -1 && !v1[conn[i][j]]) {         ret = max(ret, longestPath(conn[i][j]));         cnt++;       }     }     if (cnt == 0) ret = max(ret, getHeight(i));     v1[i] = 0;     return ret;   }   int main() {     cin >> n;     memset(v1, 0, sizeof v1);     memset(v2, 0, sizeof v2);     int a, b;     for (int i = 0; i < n - 1; i++) {       cin >> a >> b;       edges.push_back(make_pair(a - 1, b - 1));       conn[a - 1].push_back(b - 1);       conn[b - 1].push_back(a - 1);     }     for (int i = 0; i < edges.size(); i++) {       a = edges[i].first;       b = edges[i].second;       setEdge(a, b, 0);       mx = max(mx, longestPath(a) * longestPath(b));       setEdge(a, b, 1);     }     cout << mx << endl;   }
#include<bits/stdc++.h>   using namespace std;       typedef long long ll;   typedef vector< ll > vl;   typedef vector< vector< ll > > vvl;   #define ff first   #define ss second   #define boost ios_base::sync_with_stdio(false); cin.tie(NULL);   cout.tie(NULL);   #define pb push_back   #define all(c) c.begin(), c.end()   #define tr(c,it) for(auto it=(c).begin(); it!=(c).end(); it++)   #define ref(i,n)    for(i=0;i<n;i++)   #define mp make_pair   #define endl   n    #define MOD 1000000007   ll power(ll a, ll b){//a^b       ll res=1;       a=a%MOD;       while(b>0){           if(b&1){res=(res*a)%MOD;b--;}           a=(a*a)%MOD;           b>>=1;       }       return res;   }   ll fermat_inv(ll y){return power(y,MOD-2);}   ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}      int main()   {       boost       ll t;       cin>>t;       while(t--)       {           ll n,x=0,y=0,flag=0,m,i;           cin>>n;           string s;           cin>>s;           ref(i,n)           {               if(s[i]== T )                   x++;               else               {                   y++;               }               if(y>x)               {                   flag=1;                   break;               }           }           if(flag==1 || x!=2*y)           {               cout<< NO <<endl;               continue;           }           x=y=flag=0;           for(i=n-1;i>=0;i--)           {               if(s[i]== T )                   x++;               else               {                   y++;               }               if(y>x)               {                   flag=1;                   break;               }           }           if(flag)               cout<< NO <<endl;           else               cout<< YES <<endl;       }       return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio();     cin.tie();     cout.tie();     int n;     cin >> n;     int weight[n];     for (int i = 0; i < n; ++i) cin >> weight[i];     int p;     cin >> p;     vector<pair<pair<int, int>, int> > data;     for (int i = 0; i < p; ++i) {       int a, b;       cin >> a >> b;       --a;       data.push_back({{b, a}, i});     }     sort(data.begin(), data.end());     vector<pair<int, long long> > answer;     long long dp[n];     int prev = -1;     for (int i = 0; i < p; ++i) {       int b = data[i].first.first, a = data[i].first.second;       if (b >= 500) {         long long sum = 0;         for (; a < n; a += b) sum += weight[a];         answer.push_back({data[i].second, sum});         prev = -1;         continue;       }       if (prev == -1 || b != prev) {         for (int j = n - 1; j >= 0; --j) {           if (j + b > n - 1)             dp[j] = weight[j];           else             dp[j] = weight[j] + dp[j + b];         }       }       answer.push_back({data[i].second, dp[a]});       prev = b;     }     sort(answer.begin(), answer.end());     for (int i = 0; i < p; ++i) cout << answer[i].second <<   n ;     return 0;   }
#define _CRT_SECURE_NO_WARNINGS   #include <iostream>   #include<time.h>   #include <cstdio>   #include <cstring>   #include <cstdlib>   #include <cmath>   #include <algorithm>   #include <queue>   #include <stack>   #include <unordered_map>   #include <unordered_set>   #include <stdio.h>   #include <deque>   #include <map>   #include <set>   #include <string>   #define ll long long   typedef long long LL;   typedef unsigned long long ULL;   //typedef long double ld;   using namespace std;   const int MAXN = 2e6 + 5000;   const long double eps = (1e-12);   const int logn = 21;   const double Pi = acos(-1.0);   const LL pp = 1000000000 + 9;   int lowbit(int x) { return x & (-x); }   #define MP(i,j) make_pair(i,j)   #define M(x) ((((x)%pp)+pp)%pp)   //#define int LL   #define P pair<int,int>   const int INF = 1e9;      int toright[505][505];   int todown[505][505];      int dx[5] = { 0,0,0,-1,1 };   int dy[5] = { 0,-1,1,0,0 };   int dp[505][505][25];      int getww(int x1, int y1, int x2, int y2) {       if (x2 == x1 + 1) {           return todown[x1][y1];       }       else if (x2 == x1 - 1) {           return todown[x2][y1];       }       else if (y2 == y1 + 1) {           return toright[x1][y1];       }       else if (y2 == y1 - 1) {           return toright[x1][y2];       }       return -1;   }      signed main() {       int n, m, k;       scanf( %d%d%d , &n, &m, &k);       for (int i = 1; i <= n; i++) {           for (int j = 1; j <= m - 1; j++) {               scanf( %d , &toright[i][j]);           }       }       for (int i = 1; i <= n - 1; i++) {           for (int j = 1; j <= m; j++) {               scanf( %d , &todown[i][j]);           }       }       if (k % 2 == 1) {           for (int i = 1; i <= n; i++) {               for (int j = 1; j <= m; j++) {                   printf( -1  );               }               printf(  n );           }       }       else {           k /= 2;              for (int kk = 1; kk <= k; kk++) {               for (int i = 1; i <= n; i++) {                   for (int j = 1; j <= m; j++) {                       dp[i][j][kk] = INF;                   }               }           }              for (int kk = 1; kk <= k; kk++) {               for (int i = 1; i <= n; i++) {                   for (int j = 1; j <= m; j++) {                       for (int l = 1; l <= 4; l++) {                           int x = i + dx[l]; int y = j + dy[l];                           if (x<1 || x>n || y<1 || y>m) continue;                           int w = getww(i, j, x, y);                           dp[i][j][kk] = min(dp[i][j][kk], w + dp[x][y][kk - 1]);                       }                   }               }           }              for (int i = 1; i <= n; i++) {               for (int j = 1; j <= m; j++) {                   printf( %d  , dp[i][j][k] * 2);               }               printf(  n );           }       }             return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 300000 + 5;   int a[maxn], dp[maxn];   int n, k;   bool ok_hack(int x) {     memset(dp, 0, sizeof(dp));     int last = 0;     for (int i = k; i <= n; i++) {       if (a[i] - a[dp[i - k] + 1] <= x) last = i;       dp[i] = last;     }     return dp[n] == n;   }   int main() {     scanf( %d%d , &n, &k);     for (int i = 1; i <= n; i++) scanf( %d , &a[i]);     sort(a + 1, a + n + 1);     a[0] = 0;     int l = 0, r = a[n] - a[1];     while (l < r) {       int mid = r + l >> 1;       if (ok_hack(mid))         r = mid;       else         l = mid + 1;     }     printf( %d n , l);     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast )   #pragma GCC optimize( unroll-loops )   #pragma GCC target( sse,sse2,sse3,ssse3,abm,mmx,tune=native )   using namespace std;   const int64_t INF = (int64_t)(2e18);   const int maxn = 500 * 1000 + 100;   chrono::time_point<chrono::steady_clock> cl;   double current_time() {     return (double)(chrono::steady_clock::now() - cl).count() / 1e9;   }   void no() {     cout <<  0 ;     exit(0);   }   void inf() {     cout <<  inf ;     exit(0);   }   void ans(long long a) {     cout << a;     exit(0);   }   int32_t main() {     cl = chrono::steady_clock::now();     ios_base::sync_with_stdio(false);     cout << fixed << setprecision(10);     cin.tie(nullptr);     long long x, y, z;     cin >> x >> y >> z;     if (x == y && y != z) no();     if (x != y && y == z) ans(1);     if (x == z && y != z) no();     if (x == y && y == z) {       if (x == 1) inf();       if (x != 1) ans(2);     }     if (x > y) no();     if (y > z) no();     bool flag = false;     if (x == 1ll) {       flag = true;       long long zz = z;       while (z > 1) {         if (z % y != 0) flag = false;         z /= y;       }       z = zz;     }     vector<int> a;     long long zcp = z;     while (zcp > 0) {       a.push_back(zcp % y);       zcp /= y;     }     long long cur = 0;     long long curx = 1;     for (auto& it : a) {       cur += it * curx;       curx *= x;     }     int res = 0;     if (cur == y) ++res;     if (flag) ++res;     cout << bool(res);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using ii = pair<ll, ll>;   int main() {     char rep[256], a[256], b[256], d[256];     while (scanf( %[0-9].%[0-9]e%[0-9] n , a, d, b) == 3) {       auto len = strlen(d);       if (b[0] ==  0 ) {         if (len == 1 and d[0] ==  0 )           printf( %s n , a);         else           printf( %s.%s n , a, d);         continue;       }       if (a[0] ==  0 ) a[0] = 0;       while (len > 0 and d[len - 1] ==  0 ) --len;       d[len] = 0;       int digits = 0;       for (auto p = a; *p; ++p) rep[digits++] = *p;       int n = atoi(b);       auto p = d;       for (; *p and n; ++p) {         rep[digits++] = *p;         --n;       }       rep[digits] = 0;       if (n == 0) {         printf( %s , rep);         if (*p) {           printf( . );           while (*p) {             printf( %c , *p);             ++p;           }         }         printf(  n );       } else {         printf( %s , rep);         while (n--) printf( 0 );         printf(  n );       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long M = 1e9 + 7;   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     ;     long long t;     cin >> t;     while (t--) {       long long n;       cin >> n;       long long a[n];       map<long long, long long> m;       map<long long, long long> m1;       map<long long, long long> m2;       map<long long, long long> m3;       vector<pair<long long, long long>> v;       for (long long i = 0; i < n; i++) {         cin >> a[i];         m2[a[i]]++;       }       for (auto it = m2.begin(); it != m2.end(); it++) {         m3[it->second]++;       }       for (long long i = 0; i < n - 1; i++) {         long long x = ++m[a[i]];         m1[x]++;         m1[x - 1]--;         long long y = m2[a[i]];         if (y == 1) {           m2.erase(m2.find(a[i]));         } else           m2[a[i]]--;         m3[y]--;         m3[y - 1]++;         auto it = m.end();         it--;         x = it->first;         it = m2.end();         it--;         y = it->first;         if (x == m.size() && y == m2.size() && m1[1] == x && m3[1] == y) {           v.push_back({x, y});         }       }       cout << v.size() <<   n ;       for (long long i = 0; i < (long long)v.size(); i++) {         cout << v[i].first <<     << v[i].second <<   n ;       }     }   }
#include <bits/stdc++.h>   using namespace std;   struct node {     int x, h, id;   } a[100005];   int n, i, j, f[100005], ans[100005];   bool cmp(node x, node y) {     if (x.x != y.x)       return x.x < y.x;     else       return x.h < y.h;   }   int main() {     scanf( %d , &n);     for (i = 1; i <= n; i++) {       scanf( %d%d , &a[i].x, &a[i].h);       a[i].id = i;     }     sort(a + 1, a + n + 1, cmp);     for (i = n; i >= 1; i--) {       f[i] = 1;       for (j = i + 1; j <= n; j += f[j]) {         if (a[i].x + a[i].h - 1 >= a[j].x)           f[i] += f[j];         else           break;       }       ans[a[i].id] = f[i];     }     for (i = 1; i <= n; i++) printf( %d  , ans[i]);     printf(  n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     map<char, int> ma;     char a;     int b;     cin >> b;     for (int i = 0; i < b; i++) {       cin >> a;       ma[a]++;     }     for (auto i : ma)       for (int j = 0; j < i.second; j++) cout << i.first;   }
#include <bits/stdc++.h>   using namespace std;   double x;   int N, M, ar[5005], res;   int dn[5005];   int main() {     scanf( %d %d , &N, &M);     for (int i = 0; i < N; i++) {       scanf( %d %lf , &ar[i], &x);       ar[i]--;     }     for (int i = 0; i < N; i++) {       for (int j = ar[i]; j >= 0; j--) {         dn[ar[i]] = max(dn[ar[i]], 1 + dn[j]);       }     }     for (int i = 0; i < M; i++) {       res = max(res, dn[i]);     }     printf( %d n , N - res);   }