malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const long long MOD = 1000000007;   template <class T>   void _R(T &x) {     cin >> x;   }   void _R(int &x) { cin >> x; }   void _R(int64_t &x) { cin >> x; }   void _R(double &x) { cin >> x; }   void _R(long double &x) { cin >> x; }   void _R(char &x) { cin >> x; }   void _R(char *x) { cin >> x; }   void _R(string &x) { cin >> x; }   void R() {}   template <class T, class... U>   void R(T &head, U &...tail) {     _R(head);     R(tail...);   }   template <class T>   void _W(const T &x) {     cout << x;   }   void _W(const int &x) { cout << x; }   void _W(const int64_t &x) { cout << x; }   void _W(const double &x) { cout << fixed << setprecision(8) << x; }   void _W(const long double &x) { cout << fixed << setprecision(16) << x; }   void _W(const char &x) { cout << x; }   void _W(const char *x) { cout << x; }   void _W(const string &x) { cout << x; }   template <class T, class U>   void _W(const pair<T, U> &x) {     _W(x.first);     cout <<    ;     _W(x.second);   }   template <class T>   void _W(const vector<T> &x) {     for (auto i = x.begin(); i != x.end(); _W(*i++))       if (i != x.cbegin()) cout <<    ;   }   void W() {}   template <class T, class... U>   void W(const T &head, const U &...tail) {     _W(head);     cout << (sizeof...(tail) ?     :   n );     W(tail...);   }   int n, k;   vector<int> a;   bool ok_even(int x) {     int cnt = 0;     for (int i = (0); i < (n); i++) {       if ((cnt & 1)) {         if (a[i] <= x) cnt++;       } else {         cnt++;       }       if (cnt >= k) return true;     }     return false;   }   bool ok_odd(int x) {     int cnt = 0;     for (int i = (0); i < (n); i++) {       if ((!(cnt & 1))) {         if (a[i] <= x) cnt++;       } else {         cnt++;       }       if (cnt >= k) return true;     }     return false;   }   bool ok(int x) {     if (ok_even(x)) {       return true;     } else if (ok_odd(x)) {       return true;     }     return false;   }   void solve() {     R(n, k);     a.resize(n);     for (int i = (0); i < (n); i++) {       R(a[i]);     }     int l = 0, r = 1e9 + 10;     while (r - l > 1) {       int mid = (r + l) / 2;       if (ok(mid)) {         r = mid;       } else {         l = mid;       }     }     W(r);   }   signed main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int t = 1;     for (int testcase = 1; testcase <= t; testcase++) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = (int)1e9 + 7, maxn = (int)1e5 + 5;   int a[maxn], d[maxn];   int mpow(int A, int N) {     int ret = 1;     while (N) {       if (N & 1) ret = (ret * 1ll * A) % mod;       A = (A * 1ll * A) % mod;       N >>= 1;     }     return ret;   }   int main() {     ios_base::sync_with_stdio(0);     cin.clear();     int n;     cin >> n;     for (int i = 0; i < n; i++) cin >> a[i];     sort(a, a + n);     int ans = 0;     for (int i = maxn - 1; i > 0; i--) {       int sz = 0;       for (int j = 1; j * j <= i; j++) {         if (i % j) continue;         if (j != i) d[sz++] = j;         if (j != 1 && j * j != i) d[sz++] = i / j;       }       sort(d, d + sz);       int lim = lower_bound(a, a + n, i) - a;       int cur = (mpow(sz + 1, n - lim) - mpow(sz, n - lim) + mod) % mod;       for (int j = sz - 1; j >= 0; j--) {         int idx = lower_bound(a, a + lim, d[j]) - a;         cur = (cur * 1ll * mpow(j + 1, lim - idx)) % mod;         lim = idx;       }       ans = (ans + cur) % mod;     }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   set<int> s;   int cnt[1009];   int vec[1009];   vector<int> ans;   int main() {     int a, b, c, d, e, i, j, k, l, n, m, x, y, t, p;     scanf( %d , &t);     for (p = 1; p <= t; p++) {       scanf( %d , &n);       s.clear();       ans.clear();       for (i = 0; i <= n; i++) {         s.insert(i);         cnt[i] = 0;       }       for (i = 1; i <= n; i++) {         scanf( %d , &vec[i]);         s.erase(vec[i]);         cnt[vec[i]]++;       }       c = 0;       for (i = 2; i <= n; i++) {         if (vec[i] < vec[i - 1]) {           c = 1;           break;         }       }       if (c) {         while (c) {           auto it = s.begin();           a = *it;           i = a;           if (i == 0) {             i = 1;             for (j = 2; j <= n; j++) {               if (vec[j] < vec[j - 1]) {                 if (vec[j] != j) {                   i = j;                 } else {                   i = j - 1;                 }                 break;               }             }           }           s.erase(it);           ans.push_back(i);           cnt[a]++;           cnt[vec[i]]--;           if (cnt[vec[i]] == 0) {             s.insert(vec[i]);           }           vec[i] = a;           c = 0;           for (i = 2; i <= n; i++) {             if (vec[i] < vec[i - 1]) {               c = 1;               break;             }           }         }       }       l = ans.size();       printf( %d n , l);       for (i = 0; i < l; i++) {         printf( %d  , ans[i]);       }       printf(  n );     }   }
#include <bits/stdc++.h>   using namespace std;   struct abc {     int p, q, idx;   };   bool compareTwoStudents(abc a, abc b) {     if (a.p != b.p) return a.p < b.p;     return (a.q < b.q);   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     string s, s1, s2;     int a, b, c, x, y, z, p, q, u, v, idx;     int i, j, k, m, n, t, flag = 0, count = 0;     cin >> q;     while (q--) {       cin >> n;       cin >> s;       if (s.length() == 2) {         if (s[1] <= s[0]) {           cout <<  NO n ;         } else {           cout <<  YES n2 n ;           for (i = 0; i < s.length(); i++) {             cout << s[i];             if (i == 0) cout <<    ;           }           cout <<   n ;         }       } else {         cout <<  YES n2 n ;         for (i = 0; i < s.length(); i++) {           cout << s[i];           if (i == 0) cout <<    ;         }         cout <<   n ;       }     }     return 0;   }
#include <bits/stdc++.h>   int main() {     int a, b, c, d, e, i;     scanf( %d %d %d %d %d , &a, &b, &c, &d, &e);     int arr[e];     if (a == 1 || b == 1 || c == 1 || d == 1)       printf( %d n , e);     else {       for (i = 1; i <= e; i++) {         if (i % a == 0)           arr[i - 1] = 1;         else if (i % b == 0)           arr[i - 1] = 1;         else if (i % c == 0)           arr[i - 1] = 1;         else if (i % d == 0)           arr[i - 1] = 1;         else           arr[i - 1] = 0;       }       int count = 0;       for (i = 0; i < e; i++) {         if (arr[i] == 1) count++;       }       printf( %d n , count);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 107;   const long long mod = 1e9 + 7;   const int rx[8] = {1, -1, 0, 0, 1, 1, -1, -1};   const int ry[8] = {0, 0, 1, -1, 1, -1, 1, -1};   const long double pi = acos(-1.0);   const int B = (int)sqrt(N);   int d[16 / 2][2 * 4];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     string lada1, lada2, korol, black;     cin >> lada1 >> lada2 >> korol >> black;     int l1x = lada1[0] -  a , l1y = lada1[1] -  1 ;     int l2x = lada2[0] -  a , l2y = lada2[1] -  1 ;     int kx = korol[0] -  a , ky = korol[1] -  1 ;     int bx = black[0] -  a , by = black[1] -  1 ;     d[kx][ky] = 2;     for (int i = 0; i < 4; ++i) {       int x = l1x + rx[i], y = l1y + ry[i];       while (x > -1 && y > -1 && x < 16 / 2 && y < 2 * 4 && d[x][y] != 2) {         d[x][y] = 1;         x += rx[i], y += ry[i];       }     }     for (int i = 0; i < 4; ++i) {       int x = l2x + rx[i], y = l2y + ry[i];       while (x > -1 && y > -1 && x < 16 / 2 && y < 2 * 4 && d[x][y] != 2) {         d[x][y] = 1;         x += rx[i], y += ry[i];       }     }     for (int i = max(0, kx - 1); i < min(8, kx + 2); ++i)       for (int j = max(0, ky - 1); j < min(8, ky + 2); ++j) d[i][j] = 1;     for (int i = max(0, bx - 1); i < min(8, bx + 2); ++i)       for (int j = max(0, by - 1); j < min(8, by + 2); ++j)         if (!d[i][j]) {           cout <<  OTHER  <<   n ;           return 0;         }     cout <<  CHECKMATE  <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX = 30;   int num[MAX], x[MAX];   char s[1000 + 10];   int main() {     int n;     while (cin >> s >> n) {       int m = n;       string a;       memset(num, 0, sizeof num);       int len = strlen(s), sum = 0;       for (int i = 0; i < len; ++i) {         if (!num[s[i] -  a ]) ++sum;         ++num[s[i] -  a ];       }       if (sum > n)         cout <<  -1 ;       else {         for (int i = 0; i < 26; ++i) {           if (num[i]) {             a += (i +  a );             --m;           }           x[i] = 1;         }         while (m) {           int j = 0;           for (int i = 0; i < 26; ++i) {             if ((num[i] - 1) / x[i] + 1 > (num[j] - 1) / x[j] + 1) j = i;           }           a += (j +  a );           ++x[j];           --m;         }         int j = 0;         for (int i = 0; i < 26; ++i) {           if ((num[i] - 1) / x[i] + 1 > (num[j] - 1) / x[j] + 1) j = i;         }         cout << (num[j] - 1) / x[j] + 1 << endl;         cout << a;       }       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void print_ret(const std::vector<long long>& ret) {     long long r = 0;     for (typeof((ret).end()) it = (ret).begin(); it != (ret).end(); ++it)       r ^= *it;     cout << r << endl;     cout << ret.size() << endl;     for (typeof((ret).end()) it = (ret).begin(); it != (ret).end(); ++it)       cout << *it <<    ;     cout << endl;   }   int main(int argc, const char* argv[]) {     long long l, r, k;     std::vector<long long> ret;     cin >> l >> r >> k;     if (k == 1) {       ret.push_back(l);     } else if (k == 2) {     k2:       if (r - l >= 2) {         ret.push_back(l + 1);         if (l & 1)           ret.push_back(l + 2);         else           ret.push_back(l);       } else {         ret.push_back(l);         if ((l ^ (l + 1)) < l) ret.push_back(l + 1);       }     } else if (k == 3) {       long long t = l;       while (t & (t - 1)) t &= (t - 1);       t |= (t << 1);       if (t <= r) {         ret.push_back(l);         ret.push_back(t);         ret.push_back(l ^ t);       } else {         goto k2;       }     } else {       for (long long t = l; t <= r; t++) {         if (!(t & 3)) {           if (t + 3 <= r) {             ret.push_back(t);             ret.push_back(t + 1);             ret.push_back(t + 2);             ret.push_back(t + 3);             print_ret(ret);             return 0;           }           break;         }       }       std::vector<long long> vals;       for (long long t = l; t <= r; t++) vals.push_back(t);       long long bestval = l;       long long bestmask = 1;       for (int mask = 1; mask < (1 << vals.size()); mask++) {         long long cur = 0;         for (int i = 0; i < vals.size(); i++) {           if (mask & (1 << i)) cur ^= vals[i];         }         if (cur < bestval) {           bestval = cur;           bestmask = mask;         }       }       for (int i = 0; i < vals.size(); i++) {         if (bestmask & (1 << i)) ret.push_back(vals[i]);       }     }     print_ret(ret);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void print(vector<pair<int, int> > &v) {     for (int i = 0; i < v.size(); i++) cout << v[i].second <<    ;     cout << endl;   }   int main() {     int n;     cin >> n;     vector<pair<int, int> > input;     for (int i = 0; i < n; i++) {       int x;       cin >> x;       input.push_back(make_pair(x, i + 1));     }     sort(input.begin(), input.end());     vector<pair<int, int> > swaps;     for (int i = 1; i < n && swaps.size() < 2; i++) {       if (input[i - 1].first == input[i].first) {         swaps.push_back(make_pair(i - 1, i));       }     }     if (swaps.size() < 2) {       cout <<  NO ;       return 0;     }     cout <<  YES  << endl;     print(input);     swap(input[swaps[0].first], input[swaps[0].second]);     print(input);     swap(input[swaps[1].first], input[swaps[1].second]);     print(input);   }
#include <bits/stdc++.h>   using namespace std;   const int MAX_N = 200000;   struct el {     int l, r, id;   } a[MAX_N], b[MAX_N];   long k[MAX_N];   class compare {    public:     bool operator()(el a, el b) { return a.r < b.r; }   };   int main() {     int n, m;     cin >> n;     for (int i = 0; i < n; i++) {       cin >> a[i].l >> a[i].r;       a[i].id = i;     }     cin >> m;     for (int i = 0; i < m; i++) {       cin >> b[i].l >> b[i].r >> k[i];       b[i].id = i;     }     compare cmp;     sort(a, a + n, cmp);     sort(b, b + m, cmp);     int uk = 0;     vector<int> ans(n);     multimap<int, int> mp;     for (int i = 0; i < m; i++) {       while (uk < n && a[uk].r <= b[i].r)         mp.insert(make_pair(a[uk].l, a[uk].id)), uk++;       map<int, int>::iterator it;       for (it = mp.lower_bound(b[i].l); it != mp.end() && k[b[i].id];            it = mp.lower_bound(b[i].l)) {         ans[it->second] = b[i].id + 1;         k[b[i].id]--;         mp.erase(it);       }     }     if (mp.empty() && uk == n) {       cout <<  YES n ;       copy(ans.begin(), ans.end(), ostream_iterator<int>(cout,    ));     } else       cout <<  NO ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1000000007;   int a[18] = {1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0};   long long n;   int main() {     cin >> n;     if (n == 0) {       cout << 1 << endl;       return 0;     }     int res = 0;     while (n != 0) {       int m = n % 16;       n /= 16;       res += a[m];     }     cout << res << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     string s;     cin >> s;     int l = 0;     int r = 0;     vector<int> a(3);     vector<int> b(3);     for (int i = 0; i < 3; i++) {       a[i] = (int)(s[i] -  0 );       b[i] = (int)(s[i + 3] -  0 );       l += a[i];       r += b[i];     }     if (l == r) {       cout <<  0 ;       return 0;     }     int dif = abs(l - r);     if (l > r) {       sort(a.rbegin(), a.rend());       sort(b.begin(), b.end());       if (a[0] >= dif || (9 - b[0]) >= dif) {         cout <<  1 ;         return 0;       }       int mx = max({a[0] + (9 - b[0]), a[0] + a[1], 18 - b[0] - b[1]});       if (mx >= dif) {         cout <<  2 ;         return 0;       }     } else {       sort(a.begin(), a.end());       sort(b.rbegin(), b.rend());       if (b[0] >= dif || (9 - a[0]) >= dif) {         cout <<  1 ;         return 0;       }       int mx = max({b[0] + (9 - a[0]), b[0] + b[1], 18 - a[0] - a[1]});       if (mx >= dif) {         cout <<  2 ;         return 0;       }     }     cout <<  3 ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1100000;   const int M = 21;   vector<int> adj[N];   int par[N][M];   int vis[N];   void dfs(int u, int p) {     par[u][0] = p;     for (int v : adj[u]) {       if (v == p) continue;       dfs(v, u);     }   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n, k;     cin >> n >> k;     for (int i = 1; i < n; i++) {       int u, v;       cin >> u >> v;       adj[u].push_back(v);       adj[v].push_back(u);     }     dfs(n, 0);     for (int i = 1; i < M; i++)       for (int j = 1; j <= n; j++) par[j][i] = par[par[j][i - 1]][i - 1];     vis[n] = 1;     int rest = n - k - 1;     for (int i = n - 1; i >= 0; i--) {       if (vis[i]) continue;       int now = i;       int cnt = 0;       for (int j = M - 1; j >= 0; j--) {         int cur = par[now][j];         if (cur == 0 || vis[cur]) continue;         cnt += 1 << j;         now = cur;       }       if (cnt + 1 > rest) continue;       rest -= cnt + 1;       vis[i] = 1;       now = i;       for (int times = 0; times < cnt; times++) {         now = par[now][0];         vis[now] = 1;       }     }     for (int i = 1; i <= n; i++)       if (!vis[i]) cout << i <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int pct(int x) { return __builtin_popcount(x); }   int pct(long long x) { return __builtin_popcountll(x); }   int bt(int x) { return 31 - __builtin_clz(x); }   int bt(long long x) { return 63 - __builtin_clzll(x); }   int cdiv(int a, int b) { return a / b + !(a < 0 || a % b == 0); }   long long cdiv(long long a, long long b) {     return a / b + !(a < 0 || a % b == 0);   }   int nxt_C(int x) {     int c = x & -x, r = x + c;     return (((r ^ x) >> 2) / c) | r;   }   long long nxt_C(long long x) {     long long c = x & -x, r = x + c;     return (((r ^ x) >> 2) / c) | r;   }   vector<int> get_bits(int mask) {     vector<int> bb;     while (mask) {       int b = bt(mask);       bb.push_back(b);       mask ^= (1 << b);     }     reverse(bb.begin(), bb.end());     return bb;   }   int get_mask(vector<int> v) {     int mask = 0;     for (int x : v) {       mask ^= (1 << x);     }     return mask;   }   template <typename T>   void uniq(vector<T> &v) {     sort(v.begin(), v.end());     v.resize(unique(v.begin(), v.end()) - v.begin());   }   mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());   long long rand(long long l, long long r) {     uniform_int_distribution<long long> uid(l, r);     return uid(rng);   }   void sc() {}   template <typename Head, typename... Tail>   void sc(Head &H, Tail &...T) {     cin >> H;     sc(T...);   }   const int mod = 1e9 + 7;   int pwr(int a, long long b) {     int ans = 1;     while (b) {       if (b & 1) ans = (ans * 1LL * a) % mod;       a = (a * 1LL * a) % mod;       b >>= 1;     }     return ans;   }   const int N = 2e5 + 5;   int a[N];   int dp[N][2];   int n, k;   bool f(int x) {     dp[0][0] = 0;     dp[0][1] = 0;     for (int i = 1; i <= n; i++) {       dp[i][0] = dp[i][1] = 0;     }     for (int i = 0; i <= n - 1; i++) {       for (int j = 0; j <= 1; j++) {         dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);         if (a[i + 1] > x && !j) continue;         dp[i + 1][j ^ 1] = max(dp[i + 1][j ^ 1], dp[i][j] + 1);       }     }     return max(dp[n][0], dp[n][1]) >= k;   }   void solve() {     sc(n, k);     for (int i = 1; i <= n; i++) {       sc(a[i]);     }     int l = 0, r = 1e9 + 5;     while (r - l > 1) {       int m = (l + r) >> 1;       if (f(m))         r = m;       else         l = m;     }     cout << r;   }   int main() {     ios ::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int t = 1;     for (int tt = 1; tt <= t; tt++) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, a, b, c;     while (cin >> n >> a >> b >> c) {       int s = a + b + c;       double ans = (1.0 * n / s);       if (a == 0 && b == 0 && c == 0)         printf( %.1lf %.1lf %.1lf n , 0.0, 0.0, 0.0);       else         printf( %.16f %.16f %.16f n , ans * a, ans * b, ans * c);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, dp, q, c, b;   string ans =   ;   void update(int &x) {     if (x == 0)       x = 1;     else       x = 0;   }   int main() {     scanf( %d , &n);     int a[n][n];     for (int i = 0; i < n; i++) {       for (int j = 0; j < n; j++) scanf( %d , &a[i][j]);     }     for (int i = 0; i < n; i++) dp = (dp + a[i][i]) % 2;     scanf( %d , &q);     while (q--) {       scanf( %d , &b);       if (b == 3) {         printf( %d , dp);       } else {         scanf( %d , &c);         update(dp);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const string DIRECTION =  NEWS ;   string s[2];   int n, a[2][1000100], pre[1000100];   void calcPre(int p[]) {     int i = 0, j = -1;     pre[0] = -1;     while (i < n) {       while (j >= 0 && p[i] != p[j]) j = pre[j];       i++;       j++;       pre[i] = (j >= n || p[i] != p[j] ? j : pre[j]);     }   }   int suffixMatch(int s[], int p[]) {     int i = 0, j = 0;     while (i < n) {       while (j >= 0 && s[i] != p[j]) j = pre[j];       i++;       j++;     }     return j;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cin >> n >> s[0] >> s[1];     n--;     for (int z = 0; z < 2; z++)       for (int i = 0; i < n; i++)         for (int j = 0; j < 4; j++)           if (s[z][i] == DIRECTION[j]) a[z][i] = j;     reverse(a[0], a[0] + n);     for (int i = 0; i < n; i++) a[0][i] = 3 - a[0][i];     calcPre(a[0]);     cout << (suffixMatch(a[1], a[0]) ?  NO  :  YES ) << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int nsz = 3e5;   int n;   long long k, mod, a[nsz + 5], b[nsz + 5], ans;   map<long long, int> mp;   long long inline qpow(long long a, int p) {     long long res = 1;     for (; p; p >>= 1) {       if (p & 1) {         res *= a;         res %= mod;       }       a *= a;       a %= mod;     }     return res % mod;   }   long long inline modify(long long a) {     a %= mod;     return a < 0 ? a + mod : a;   }   int main() {     ios_base::sync_with_stdio(0);     cin >> n >> mod >> k;     for (int i = 1; i <= n; ++i) {       cin >> a[i];       ++mp[modify(qpow(a[i], 4) - k * a[i] % mod)];     }     for (__typeof(mp.begin()) it = mp.begin(); it != mp.end(); ++it) {       ans += it->second * (it->second - 1) / 2;     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 255;   int cnt;   int n, a, b, k, f;   map<string, int> M;   map<pair<int, int>, int> Edge;   int main() {     scanf( %d %d %d %d %d , &n, &a, &b, &k, &f);     int last = 0;     int res = 0;     for (int i = 1; i <= n; ++i) {       string aa, bb;       cin >> aa >> bb;       if (!M.count(aa)) M[aa] = ++cnt;       if (!M.count(bb)) M[bb] = ++cnt;       int x = M[aa], y = M[bb];       Edge[{min(x, y), max(x, y)}] += last == x ? b : a;       res += last == x ? b : a;       last = y;     }     priority_queue<int> Q;     for (auto v : Edge) Q.push(v.second);     while (!Q.empty() && k > 0) {       int xd = Q.top();       Q.pop();       if (xd <= f) break;       --k;       res += f - xd;     }     printf( %d n , res);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MaxN = 1;   int n, sol, counter;   bool mark[20];   void check(long long x) {     if (x > n) return;     if (x != 0) sol++;     for (int i = 0; i <= 9; i++) {       if (mark[i]) {         if (i != 0 || (i == 0 && x != 0)) check(x * 10 + i);       } else {         if (counter < 2) {           counter++;           mark[i] = true;           if (i != 0 || (i == 0 && x != 0)) check(x * 10 + i);           mark[i] = false;           counter--;         }       }     }   }   int main() {     scanf( %d , &n);     sol = 0;     counter = 0;     for (int i = 0; i <= 9; i++) mark[i] = false;     long long x = 0;     check(x);     printf( %d n , sol);     return 0;   }