malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const long long N = 3e5 + 5;   const long long INF = 1e18;   const long long mod = 1e9 + 7;   void solve() {     long long n, m, k;     string s;     cin >> n;     map<int, int> F;     while (true) {       F[n] = 1;       n = n + 1;       while (n % 10 == 0) n /= 10;       if (F.find(n) != F.end()) break;     }     cout << F.size();   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int t;     t = 1;     while (t--) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   set<int> s;   int a[200005];   int b[200005], u[200005];   int n, k;   int main() {     int T;     scanf( %d , &T);     for (; T--;) {       scanf( %d%d , &n, &k);       for (int i = 1; i <= n; i++) scanf( %d , &a[i]);       for (int i = 1; i <= k; i++) scanf( %d , &b[i]);       for (int i = 1; i <= n; i++) u[a[i]] = i;       s.clear();       for (int i = 1; i <= k; i++) s.insert(b[i]);       long long ans = 1;       for (int i = 1; i <= k; i++) {         int x = u[b[i]];         int now = 0;         int y;         if (x > 1) {           y = x - 1;           if (s.find(a[y]) == s.end()) now++;         }         if (x < n) {           y = x + 1;           if (s.find(a[y]) == s.end()) now++;         }         ans = ans * now % 998244353;         s.erase(b[i]);       }       printf( %lld n , ans);     }   }
#include <bits/stdc++.h>   using namespace std;   const string alf =  abcdefghijklmnopqrstuvwxyz ;   const int hashP = 239017;   const int N = 1e5 + 10;   const int MOD = 1e9 + 7;   const int MOD2 = 998244353;   const int INF = 1e9;   const long long oo = 9e18;   template <typename T>   bool umn(T &a, T b) {     return (a > b ? (a = b, 1) : 0);   }   template <typename T>   bool umx(T &a, T b) {     return (a < b ? (a = b, 1) : 0);   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long tt;     cin >> tt;     while (tt--) {       long long n;       cin >> n;       long long k = 2, sum = 1;       while (1) {         sum += k;         k *= 2;         if (!(n % sum)) {           cout << n / sum <<   n ;           break;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long ans = 0;     long long n;     cin >> n;     vector<long long> a(n), b(n), c(n);     string s1, s2;     cin >> s1 >> s2;     for (long long i = 0; i < n; i++) {       a[i] = (s1[i] ==  0  ? 0 : 1);     }     for (long long i = 0; i < n; i++) {       b[i] = (s2[i] ==  0  ? 0 : 1);       c[i] = a[i] ^ b[i];     }     for (long long i = 1; i < n; i++) {       if (c[i] == 1 && c[i - 1] == 1 && (a[i] != a[i - 1])) {         ans += 1;         c[i] = 0;         c[i - 1] = 0;       }     }     for (long long i = 0; i < n; i++) {       if (c[i] == 1) {         ans += 1;       }     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     while (n <= 70000) {       ++n;       int x = n;       int a[10] = {0};       for (int i = 0; i < 4; i++) {         int m = x % 10;         ++a[m];         x = x / 10;       }       int count = 0;       for (int i = 0; i < 10; i++) {         if (a[i] == 1) ++count;       }       if (count == 4) {         cout << n;         break;       }     }   }
#include <bits/stdc++.h>   using namespace std;   inline void read(int &x) {     char ch;     bool flag = false;     for (ch = getchar(); !isdigit(ch); ch = getchar())       if (ch ==  - ) flag = true;     for (x = 0; isdigit(ch); x = x * 10 + ch -  0 , ch = getchar())       ;     x = flag ? -x : x;   }   const int INF = 0x3f3f3f3f;   const int N = 1e6 + 7;   int a[N], l[N], r[N];   int ll[N], rr[N];   int main() {     int n, x;     cin >> n >> x;     memset(l, 0x3f3f3f, sizeof(l));     memset(ll, 0x3f3f3f, sizeof(ll));     for (int i = 1; i <= n; i++) {       cin >> a[i];       l[a[i]] = min(i, l[a[i]]);       r[a[i]] = i;     }     long long ans = 0;     for (int i = 1; i <= x; i++) rr[i] = max(r[i], rr[i - 1]);     for (int i = x; i >= 1; i--) ll[i] = min(l[i], ll[i + 1]);     int d = x;     while (ll[d] >= r[d - 1] && d >= 1) d--;     for (int i = 0; i < x; i++) {       if (i != 0 && l[i] < rr[i - 1]) break;       while (d <= i + 1 || rr[i] > ll[d]) {         d++;       }       ans += x - d + 2;     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 3e5 + 10, maxk = 1e6 + 10;   int n, k, A[maxn], cnt[maxk], sum[maxk];   int32_t main() {     scanf( %d%d , &n, &k);     for (int i = int(0); i < int(n); i++) {       scanf( %d , A + i);       cnt[A[i]]++;     }     sort(A, A + n);     for (int i = int(1); i < int(maxk); i++) {       sum[i] = sum[i - 1] + cnt[i - 1];     }     int g, c = n, ans = 0;     for (g = 1; g < maxk; g++) {       c = 0;       for (int j = g; j < maxk; j += g) {         c += sum[min(maxk - 1, j + min(k + 1, g))] - sum[j];       }       if (c >= n) ans = g;     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a, b, f = 0, d = 0;     cin >> a >> b;     for (int i = 1; i <= 6; i++) {       int d1 = abs(a - i), d2 = abs(b - i);       if (d1 < d2)         f++;       else if (d1 == d2)         d++;     }     cout << f <<     << d <<     << 6 - f - d << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k;     long long maxi;     maxi = -9999999999;     cin >> n >> k;     for (int i = 1; i <= n; i++) {       int a, b;       long long tmp;       cin >> a >> b;       if (b > k) {         tmp = a - (b - k);       } else {         tmp = a;       }       maxi = max(tmp, maxi);     }     cout << maxi;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 3e5 + 5, maxlen = 5e5 + 5;   const int inf = 3e6 + 5;   int n, x[maxn], y[maxn];   char s[maxlen];   int ansb, ansn;   bool check(int mid, int ty) {     int xmin = 0, xmax = inf, ymin = 0, ymax = inf, dmin = -inf, dmax = inf;     for (int i = 1; i <= n; i++) {       xmin = max(xmin, x[i] - mid);       xmax = min(xmax, x[i] + mid);       ymin = max(ymin, y[i] - mid);       ymax = min(ymax, y[i] + mid);       dmin = max(dmin, x[i] - y[i] - mid);       dmax = min(dmax, x[i] - y[i] + mid);     }     if (xmin > xmax || ymin > ymax || dmin > dmax) return 0;     ymin = max(ymin, xmin - dmax);     ymax = min(ymax, xmax - dmin);     if (ymin > ymax) return 0;     if (ty) {       for (int x = xmin; x <= xmax; x++) {         int rymin = max(ymin, x - dmax), rymax = min(ymax, x - dmin);         if (rymin <= rymax && (x > 0 || rymax > 0)) {           ansb = x, ansn = (x == 0) ? rymax : rymin;           break;         }       }     }     return 1;   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       scanf( %s , s + 1);       int len = strlen(s + 1);       for (int j = 1; j <= len; j++)         if (s[j] ==  B )           x[i]++;         else           y[i]++;     }     int l = 0, r = 2e6;     while (l <= r) {       int mid = (l + r) >> 1;       if (check(mid, 0))         r = mid - 1;       else         l = mid + 1;     }     printf( %d n , ++r);     check(r, 1);     for (int i = 1; i <= ansb; i++) putchar( B );     for (int i = 1; i <= ansn; i++) putchar( N );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, k;   string s;   long long md = 1000000007;   int a[2100];   long long dp[2100][2100];   long long sdp[2100][2100];   int main() {     cin >> n >> k >> s;     for (int i = 0; i < n; i++) a[i] = s[i] -  a ;     dp[n][0] = 1;     sdp[n][0] = 1;     for (int i = n - 1; i >= 0; i--) {       for (int j = 0; j <= k; j++) {         sdp[i][j] = (dp[i + 1][j]) * ((long long)(a[i]));         sdp[i][j] += sdp[i + 1][j];         sdp[i][j] %= md;         int ll = i;         for (int l = i; (l < n) && ((l - i + 1) * (n - l) <= j); l++, ll++) {           dp[i][j] = (dp[i][j] + ((long long)(25 - a[l])) *                                      dp[l + 1][j - (l - i + 1) * (n - l)]) %                      md;         }         for (int l = n - 1; (l >= ll) && ((l - i + 1) * (n - l) <= j); l--) {           dp[i][j] = (dp[i][j] + ((long long)(25 - a[l])) *                                      dp[l + 1][j - (l - i + 1) * (n - l)]) %                      md;         }         dp[i][j] += sdp[i][j];         dp[i][j] %= md;       }     }     cout << dp[0][k] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<vector<int>> g;   vector<int> c;   int root, n;   vector<int> dfs(int u) {     vector<int> combine;     for (int v : g[u]) {       vector<int> child = dfs(v);       for (int z : child) combine.emplace_back(z);     }     if (c[u] > combine.size()) {       cout <<  NO ;       exit(0);     }     combine.insert(combine.begin() + c[u], u);     return combine;   }   int main() {     ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);     cin >> n;     g.resize(n + 1);     c.resize(n + 1);     for (int i = 1; i <= n; i++) {       int p;       cin >> p >> c[i];       if (!p)         root = i;       else         g[p].emplace_back(i);     }     vector<int> order = dfs(root);     vector<int> ans(n + 1);     for (int i = 0; i < order.size(); i++) ans[order[i]] = i + 1;     cout <<  YES n ;     for (int i = 1; i < ans.size(); i++) cout << ans[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long solve() {     long long n;     cin >> n;     vector<long long> arr(n);     map<long long, long long> counts;     map<long long, long long> checks;     for (auto &x : arr) {       cin >> x;       counts[x]++;     }     for (auto x : counts) {       checks[x.second]++;     }     while (n--) {       if (checks.size() == 1) {         auto x = checks.begin();         if (x->first == 1 or x->second == 1) {           cout << n + 1 << endl;           return 0;         }       }       if (checks.size() == 2) {         auto it1 = checks.begin();         auto it2 = checks.begin();         if (it1->first == 1 and it1->second == 1) {           cout << n + 1 << endl;           return 0;         }         it2++;         if (it2->first - it1->first == 1 and it2->second == 1) {           cout << n + 1 << endl;           return 0;         }       }       long long x = counts[arr[n]];       if (x) {         checks[x]--;         counts[arr[n]]--;         if (x - 1) checks[x - 1]++;         if (!checks[x]) checks.erase(x);       }     }   }   signed main() {     long long t = 1;     while (t--) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   long long int n, a[100008], cnt = 0;   int main() {     ios_base::sync_with_stdio(0);     cin >> n;     for (int i = 1; i <= n; i++) cin >> a[i];     for (int i = 1; i <= n; i++) {       if (a[i] == 1) {         if (!cnt) cnt++;         int j = i + 1;         while (a[j] != 1 && j <= n) j++;         if (a[j] == 1) {           cnt += min(j - i, 2);           i = j - 1;         }       }     }     cout << cnt << endl;   }
#include <bits/stdc++.h>   using namespace std;   inline void fast_and_furious() {     ios_base::sync_with_stdio(0);     cin.tie(NULL);     cout.tie(NULL);   }   int n;   long long a[1005], b[1005], u, l, ans;   int main() {     fast_and_furious();     cin >> n;     for (int i = 0; i < n; i++) cin >> a[i];     for (int i = 0; i < n; i++) cin >> b[i];     ans = 0;     for (int i = 0; i < n; i++) {       u = l = 0;       for (int j = i; j < n; j++) {         u = u | a[j];         l = l | b[j];         ans = max(u + l, ans);       }     }     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long MAX_I = 1000;   long long a[MAX_I + 1];   long long b[MAX_I + 1];   int main() {     long long n, m;     long long c[5];     long long tmp;     long long asum = 0;     long long bsum = 0;     cin >> c[1] >> c[2] >> c[3] >> c[4];     cin >> n >> m;     for (long long i = 0; i < n; ++i) {       cin >> tmp;       a[i] = min(c[2], c[1] * tmp);       asum += a[i];     }     for (long long i = 0; i < m; ++i) {       cin >> tmp;       b[i] = min(c[2], c[1] * tmp);       bsum += b[i];     }     asum = min(asum, c[3]);     bsum = min(bsum, c[3]);     cout << min(asum + bsum, c[4]) << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     int n;     cin >> n;     int pos[n + 1];     for (int i = 0; i < n; i++) {       int x;       cin >> x;       pos[x] = i;     }     int curIndex = 0;     for (int i = 0; i < n; i++) {       int x;       cin >> x;       if (pos[x] < curIndex) {         cout <<  0  ;       } else {         cout << pos[x] - curIndex + 1 <<    ;         curIndex = pos[x] + 1;       }     }   }
#include <bits/stdc++.h>   using namespace std;   void go() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout << fixed;     cout << setprecision(6);   }   void solve() {     string s;     cin >> s;     long long n = s.size();     vector<long long> arr(n);     long long cur = 0;     for (long long i = 0; i < n; i++) {       if (s[i] ==  + )         cur++;       else         cur--;       arr[i] = cur;     }     map<long long, long long> mp;     for (long long i = n - 1; i >= 0; i--) {       if (arr[i] < 0) mp[arr[i]] = i + 1;     }     long long ans = n;     for (auto x : mp) {       ans += x.second;     }     cout << ans <<   n ;   }   signed main() {     go();     long long t = 1;     cin >> t;     while (t--) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e3 + 10;   int T, n, m, a[N], b[N], l, r, ins[N], las[N];   vector<int> to[N];   struct node {     int u;     long long k;     bool f;   };   node q[N];   inline bool check(long long now) {     vector<int> s;     for (int i = 1; i <= n; ++i) ins[i] = las[i] = 0;     s.push_back(1);     ins[1] = 1;     while (s.size() != n) {       memset(las + 1, 0, sizeof(int) * (n));       l = 1;       r = 0;       for (int i : s) q[++r] = (node){i, now, 0};       int x = -1, y = -1;       while (l <= r) {         node p = q[l++];         int u = p.u;         for (int v : to[u]) {           if (v == las[u]) continue;           if (p.k <= a[v]) continue;           if (las[v] || (ins[v] && p.f)) {             x = u;             y = v;             break;           }           if (ins[v]) continue;           las[v] = u;           q[++r] = (node){v, p.k + b[v], 1};         }         if (x != -1) break;       }       if (x == -1) return false;       while (x) {         if (ins[x]) {           x = las[x];           continue;         }         ins[x] = 1;         s.push_back(x);         now += b[x];         x = las[x];       }       while (y) {         if (ins[y]) {           y = las[y];           continue;         }         ins[y] = 1;         s.push_back(y);         now += b[y];         y = las[y];       }     }     return true;   }   int main() {     scanf( %d , &T);     while (T--) {       scanf( %d%d , &n, &m);       for (int i = 2; i <= n; ++i) scanf( %d , &a[i]);       for (int i = 2; i <= n; ++i) scanf( %d , &b[i]);       for (int i = 1, u, v; i <= m; ++i) {         scanf( %d%d , &u, &v);         to[u].push_back(v), to[v].push_back(u);       }       int l = 0, r = 1e9 + 1, ans = 1e9 + 1;       while (l <= r) {         int mid = (l + r) >> 1;         if (check(mid))           r = mid - 1, ans = mid;         else           l = mid + 1;       }       printf( %d n , ans);       for (int i = 1; i <= n; ++i) to[i].clear();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int NMAX = 50;   int n;   int a[5][NMAX + 5];   int b[NMAX + 5];   vector<int> ans;   int main() {     cin >> n;     for (int i = 1; i <= 2; i++)       for (int j = 1; j < n; j++) {         cin >> a[i][j];         a[i][j] += a[i][j - 1];       }     a[1][n] = a[1][n - 1];     a[2][n] = a[2][n - 1];     for (int i = 1; i <= n; i++) cin >> b[i];     for (int i = 1; i <= n; i++) {       int cost = b[i];       cost += a[1][i - 1];       cost += a[2][n - 1] - a[2][i - 1];       ans.push_back(cost);     }     sort(ans.begin(), ans.end());     cout << ans[0] + ans[1] <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int NM = 1e5 + 10;   int color[NM];   vector<pair<int, char> > adj[NM];   bool dfs(int u, bool c, char type, vector<int> &all) {     if (color[u] != -1) return (color[u] == c);     all.push_back(u);     color[u] = c;     for (int i = 0; i < adj[u].size(); i++) {       int v = adj[u][i].first;       char edge = adj[u][i].second;       if (type == edge) {         if (!dfs(v, c, type, all)) return false;       } else {         if (!dfs(v, !c, type, all)) return false;       }     }     return true;   }   vector<int> solve(int n, char type) {     vector<int> ret;     memset(color, -1, sizeof(color));     for (int i = 1; i <= n; i++) {       if (color[i] == -1) {         vector<int> all;         if (!dfs(i, 0, type, all)) {           for (int j = 0; j <= n; j++) {             ret.push_back(-1);           }           return ret;         } else {           int cnt[2] = {0, 0};           for (int j = 0; j < all.size(); j++) {             cnt[color[all[j]]]++;           }           if (cnt[0] > cnt[1]) {             for (int j = 0; j < all.size(); j++) {               color[all[j]] ^= 1;             }           }         }       }     }     for (int i = 1; i <= n; i++) {       if (color[i] == 0) {         ret.push_back(i);       }     }     return ret;   }   int main() {     int n, m;     scanf( %d %d , &n, &m);     for (int i = 0; i < m; i++) {       int u, v;       char c;       scanf( %d %d %c , &u, &v, &c);       adj[u].push_back(make_pair(v, c));       adj[v].push_back(make_pair(u, c));     }     vector<int> a = solve(n,  R ), b = solve(n,  B );     if (a.size() > n && b.size() > n) {       printf( -1 n );     } else {       if (a.size() > b.size()) {         a.swap(b);       }       printf( %d n , a.size());       for (int i = 0; i < a.size(); i++) {         printf( %d  , a[i]);       }       printf(  n );     }     return 0;   }
#include <bits/stdc++.h>   int main() {     long long b;     scanf( %lld , &b);     long long flag = 0;     for (long long i = 1; i < sqrt(b); i++)       if (b % i == 0) flag = flag + 1;     flag = 2 * flag;     long long a = sqrt(b);     if (a * a == b) flag = flag + 1;     printf( %lld , flag);   }
#include <bits/stdc++.h>   using namespace std;   long long int n;   vector<long long int> BIT((int)1e6 + 5, 0);   void _update(int x) {     while (x <= n) {       BIT[x]++;       x += x & -x;     }   }   int query(int x) {     long long int sum = 0;     while (x > 0) {       sum += BIT[x];       x -= x & -x;     }     return sum;   }   int main() {     long long int k;     cin >> n >> k;     long long int res = 1;     k = min(n - k, k);     int pos = 1;     for (int i = 0; i < n; i++) {       res++;       int fi = pos + k;       if (fi > n) {         fi -= n;       }       if (fi > pos) {         res += query(fi - 1) - query(pos);       } else {         res += query(fi - 1) + query(n) - query(pos);       }       _update(pos);       _update(fi);       pos = fi;       cout << res <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 2 * 1000 + 17;   int n, init[MAXN][MAXN], hope[MAXN][MAXN], c[MAXN][MAXN], r[MAXN],       cnt = 1, comp[MAXN << 2];   vector<int> out[MAXN << 2], in[MAXN << 2], order, trash;   vector<pair<string, int>> ans;   void add(int i, bool f1, int j, bool f2) {     int v = (i << 1) | f1, u = (j << 1) | f2;     out[v].push_back(u);     in[u].push_back(v);     out[u ^ 1].push_back(v ^ 1);     in[v ^ 1].push_back(u ^ 1);   }   void scc(int v, vector<int> g[], vector<int> &vec) {     comp[v] = cnt;     for (auto i : g[v])       if (!comp[i]) scc(i, g, vec);     vec.push_back(v);   }   int main() {     ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);     char C;     cin >> n;     for (int i = 1; i <= n; i++)       for (int j = 1; j <= n; j++) cin >> C, init[i][j] = int(C -  0 );     for (int i = 1; i <= n; i++)       for (int j = 1; j <= n; j++)         cin >> C, hope[i][j] = int(C -  0 ), c[i][j] = init[i][j] ^ hope[i][j];     for (int i = 1; i <= n; i++) cin >> C, r[i] = int(C -  0 );     for (int i = 1; i <= n; i++)       for (int j = 1; j <= n; j++)         if (c[i][j] && r[i] && r[j])           add(i, true, n + j, false), add(i, false, n + j, true);         else if (c[i][j] && r[i] && !r[j])           add(i, true, n + j, true), add(i, false, n + j, true);         else if (c[i][j] && !r[i] && r[j])           add(n + j, true, i, true), add(n + j, false, i, true);         else if (c[i][j] && !r[i] && !r[j])           return cout << -1 << endl, 0;         else if (!c[i][j] && r[i] && r[j])           add(i, true, n + j, true), add(i, false, n + j, false);         else if (!c[i][j] && r[i] && !r[j])           add(i, true, n + j, false), add(i, false, n + j, false);         else if (!c[i][j] && !r[i] && r[j])           add(n + j, true, i, false), add(n + j, false, i, false);         else           ;     for (int i = 1; i <= ((n << 2) | 1); i++)       if (!comp[i]) scc(i, out, order);     cnt = 0;     memset(comp, 0, sizeof(comp));     for (int i = (n << 1); ~i; i--) {       int v = order[i];       if (!comp[v]) cnt++, scc(v, in, trash);     }     for (int i = 1; i <= (n << 1); i++) {       if (comp[i << 1] == comp[i << 1 | 1]) return cout << -1 << endl, 0;       if (comp[i << 1 | 1] > comp[i << 1]) {         if (i > n)           ans.push_back({ col , i - n - 1});         else           ans.push_back({ row , i - 1});       }     }     cout << ans.size() << endl;     for (auto i : ans) cout << i.first <<     << i.second << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 2e9;   long long int n, h;   bool check(long long int maxh) {     long long int k = min(maxh, h);     long long int count = maxh * maxh - k * (k - 1) / 2;     return (n >= count);   }   long long int get(long long int maxh) {     long long int k = min(h, maxh);     long long int count = maxh * maxh - k * (k - 1) / 2;     long long int length = (2 * maxh - 1) - (k - 1);     n -= count;     return length + (n + maxh - 1) / maxh;   }   int main() {     cin >> n >> h;     long long int l = 1, r = INF;     while (l < r - 1) {       long long int m = l + (r - l) / 2;       if (check(m))         l = m;       else         r = m;     }     cout << (check(r) ? get(r) : get(l)) << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int it[200041], n, io;   int down(int x) {     int s = 0, rs = x;     while (x <= n * 2) {       s = max(it[x], s);       x += x & (-x);     }     return s;   }   void up(int x, int u) {     while (x > 0) {       it[x] = max(it[x], u);       x -= x & (-x);     }   }   int main() {     int i, a[100005], o = 0, co;     cin >> n;     for (i = 0; i < n; i++) cin >> a[i];     for (i = n - 1; i >= 0; i--) {       co = down(a[i]);       up(a[i], co + 1);       o = max(co + 1, o);     }     cout << o << endl;   }
#include <bits/stdc++.h>   int count[5001] = {0}, i = 0, n, a, c = 0;   int main() {     scanf( %d , &n);     for (i = 0; i < n; i++) {       scanf( %d , &a);       count[a - 1]++;     }     for (i = 0; i < n; i++)       if (count[i] == 0) c++;     printf( %d n , c);     return 0;   }