malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   int a[26];   int w[256];   int n;   int LIMIT = 1;   int su[26], sv[26], sk[26];   int go(int lev) {     if (a[lev] == n) {       printf( %d n , lev);       for (int i = 0; i < lev; i++)         if (su[i] == -1) {           printf( lea e%cx, [%d*e%cx] n ,  a  + i + 1, 1 << sk[i],  a  + sv[i]);         } else if (sk[i] == 0)           printf( lea e%cx, [e%cx + e%cx] n ,  a  + i + 1,  a  + su[i],                   a  + sv[i]);         else           printf( lea e%cx, [e%cx + %d*e%cx] n ,  a  + i + 1,  a  + su[i],                  1 << sk[i],  a  + sv[i]);       return 1;     }     if (lev >= LIMIT) return 0;     int &i = su[lev], &j = sv[lev], &k = sk[lev];     i = -1;     for (j = 0; j <= lev; j++)       for (k = 0; k <= 3; k++) {         int v = (a[j] << k);         if (v > a[lev] && v <= n) {           a[lev + 1] = v;           if (go(lev + 1)) return 1;           a[lev + 1] = 0;         }       }     for (i = 0; i <= lev; i++)       for (j = 0; j <= lev; j++) {         for (k = 0; k <= 3; k++) {           int v = a[i] + (a[j] << k);           if (v > a[lev] && v <= n) {             a[lev + 1] = v;             if (go(lev + 1)) return 1;             a[lev + 1] = 0;           }         }       }     return 0;   }   int main(void) {     scanf( %d , &n);     if (n == 1) {       printf( 0 n );       return 0;     }     a[0] = 1;     w[1] = 1;     for (LIMIT = 1;; LIMIT++) {       if (go(0)) {         break;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cin >> n;     long long ans = 0;     for (int i = 2; i <= n; i++)       for (int j = i + i; j <= n; j += i) ans += j / i;     cout << ans * 4 << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int64_t INF = INT64_MAX / 4;   const int64_t NINF = -INF;   map<pair<int64_t, uint32_t>, int64_t> dp;   int64_t grundy(int64_t pile, uint32_t pattern) {     if (pile == 0) {       return 0;     }     pair<int64_t, uint32_t> key = {pile, pattern};     auto fd = dp.find(key);     if (fd != dp.end()) {       return fd->second;     }     bitset<32> bs(pattern);     set<int64_t> res;     for (int64_t i = 0; i < pile; i++) {       if (!bs[i]) {         bs[i] = true;         res.insert(grundy(pile - (i + 1), bs.to_ulong()));         bs[i] = false;       }     }     int64_t ans = 0;     while (res.find(ans) != res.end()) {       ans++;     }     dp.insert({key, ans});     return ans;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int64_t n;     cin >> n;     int64_t ans = 0;     for (int64_t i = 0; i < n; i++) {       int64_t pile;       cin >> pile;       ans ^= grundy(pile, 0);     };     if (ans == 0) {       cout <<  YES ;     } else {       cout <<  NO ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long p, q, b, t, g;   long long gcd(long long a, long long b) {     if (a < b) swap(a, b);     while (b != 0) {       a %= b;       swap(a, b);     }     return a;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cin >> t;     while (t--) {       cin >> p >> q >> b;       g = gcd(p, q);       q /= g;       while (true) {         g = gcd(b, q);         if (g == 1) break;         while (q % g == 0) q /= g;       }       if (q == 1)         cout <<  Finite ;       else         cout <<  Infinite ;       cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   #pragma GCC target( avx )   #pragma GCC optimize( O3 )   #pragma GCC optimize( unroll-loops )   using namespace std;   int dx[4] = {1, 0, -1, 0};   int dy[4] = {0, 1, 0, -1};   int main() {     long long A, B, C, D, E, F, N, K, M, Z, sum = 0, num = 0, flag = 0;     string S, T;     cin >> Z;     queue<long long> que;     while (Z--) {       cin >> S;       vector<long long> P(0, 0);       num = 0;       S +=  0 ;       for (long long int i = 0; i < S.size(); i++) {         if (S[i] ==  1 )           num++;         else {           P.push_back(num);           num = 0;         }       }       sort(P.begin(), P.end());       reverse(P.begin(), P.end());       sum = 0;       for (long long int i = 0; i < P.size(); i++) {         sum += P[i];         i++;       }       que.push(sum);     }     while (!que.empty()) {       cout << que.front() << endl;       que.pop();     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     int k, n;     cin >> n >> k;     int x[n];     for (int i = 0; i < n; i++) {       cin >> x[i];     }     double m = -1, sum = 0;     int c = 0;     for (int i = 0; i < n; i++) {       for (int j = i; j < n; j++) {         c++;         sum += x[j];         if (c >= k && (sum / c) > m) {           m = sum / c;         }       }       c = 0;       sum = 0;     }     cout << setprecision(15) << fixed << m << endl;   }
#include <bits/stdc++.h>   void solve() {     int n;     std::cin >> n;     std::stack<int> q;     int a = 0;     int cur = 1;     n += n;     while (n--) {       std::string s;       std::cin >> s;       if (s[0] ==  r ) {         if (!q.empty() && q.top() != cur) {           while (!q.empty()) q.pop();           ++a;         }         if (!q.empty()) q.pop();         ++cur;       } else {         int x;         std::cin >> x;         q.push(x);       }     }     std::cout << a;   }   int main() {     std::ios_base::sync_with_stdio(false);     std::cin.tie(nullptr);     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   inline bool smin(T &a, const T &b) {     return b < a ? a = b, 1 : 0;   }   template <typename T>   inline bool smax(T &a, const T &b) {     return a < b ? a = b, 1 : 0;   }   const long long N = 1e5 + 100, lg = 22;   long long n, k, add[N], h[N];   vector<pair<long long, long long> > adj[N];   long long par[N][lg];   void dfs(long long v = 1, long long p = -1, long long dep = 0) {     if (v != 1) {       par[v][0] = p;       for (long long i = 1; i < lg; i++) par[v][i] = par[par[v][i - 1]][i - 1];     } else {       for (long long i = 0; i < lg; i++) par[v][i] = v;     }     h[v] = dep;     for (auto u : adj[v])       if (u.first != p) dfs(u.first, v, dep + 1);   }   long long getPar(long long v, long long k) {     for (long long i = lg - 1; i >= 0; i--)       if (k >> i & 1) v = par[v][i];     return v;   }   long long lca(long long u, long long v) {     if (h[u] > h[v]) swap(u, v);     v = getPar(v, h[v] - h[u]);     if (u == v) return v;     for (long long i = lg - 1; i >= 0; i--) {       if (par[u][i] != par[v][i]) u = par[u][i], v = par[v][i];     }     return par[v][0];   }   long long ans[N];   long long calc(long long v = 1, long long p = -1, long long want = -1) {     long long res = add[v];     for (auto u : adj[v]) {       if (u.first == p) continue;       res += calc(u.first, v, u.second);     }     if (want != -1) ans[want] = res;     return res;   }   int32_t main() {     cin >> n;     for (long long i = 0; i < n - 1; i++) {       long long u, v;       cin >> u >> v;       adj[v].push_back({u, i}), adj[u].push_back({v, i});     }     dfs();     cin >> k;     while (k--) {       long long u, v;       cin >> u >> v;       long long l = lca(u, v);       add[u]++, add[v]++, add[l] -= 2;     };     calc();     for (long long i = 0; i < n - 1; i++) cout << ans[i] <<    ;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n;     cin >> n;     int arr[n][4];     multiset<int> s[4];     for (int i = 0; i < n; i++) {       for (int j = 0; j < 4; j++) {         cin >> arr[i][j];         s[j].insert(arr[i][j]);       }     }     for (int i = 0; i < n; i++) {       for (int j = 0; j < 4; j++) {         auto temp = s[j].find(arr[i][j]);         s[j].erase(temp);       }       if (*s[0].rbegin() <= *s[2].begin() && *s[1].rbegin() <= *s[3].begin()) {         cout << *s[0].rbegin() <<     << *s[1].rbegin() << endl;         break;       }       for (int j = 0; j < 4; j++) s[j].insert(arr[i][j]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     long long n, m, k;     cin >> n >> m >> k;     long long p[m];     for (long long int i = 0; i < m; i++) cin >> p[i];     sort(p, p + m);     long long an = 0, x = 0, c = 0, cp = 1;     while (1) {       long long y = x, pg = ceil((long double)(p[x] - x) / (k));       while (y < m && ceil((long double)(p[y] - x) / (k)) == pg) y++;       if (y == m) {         cout << an + 1;         return;       }       an++;       x = y;     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long TESTS = 1;     while (TESTS--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int requestNum;     cin >> requestNum;     vector<pair<int, pair<int, int>>> vect(requestNum);     for (int i = 0; i < requestNum; i++) {       int num, money;       cin >> num >> money;       vect.push_back(make_pair(money, make_pair(num, i + 1)));     }     sort(vect.rbegin(), vect.rend());     int tablesNum;     cin >> tablesNum;     vector<pair<int, int>> maxPeople(tablesNum);     for (int i = 0; i < tablesNum; i++) {       cin >> maxPeople[i].first;       maxPeople[i].second = i + 1;     }     sort(maxPeople.begin(), maxPeople.end());     vector<bool> tablesFull(tablesNum, false);     long long int totalMoney = 0;     vector<pair<long, long>> result;     for (int i = 0; i < requestNum; i++) {       for (int j = 0; j < tablesNum; j++) {         if (vect[i].second.first <= maxPeople[j].first && !tablesFull[j]) {           result.push_back(make_pair(vect[i].second.second, maxPeople[j].second));           totalMoney += vect[i].first;           tablesFull[j] = true;           break;         }       }     }     cout << result.size() <<     << totalMoney << endl;     for (int i = 0; i < result.size(); i++) {       cout << result[i].first <<     << result[i].second << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 2e5 + 5, inf = 1e18, mod = 1e9 + 7;   const double PI = 3.1415926536;   int days[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};   bool is_prime(long long n) {     for (long long i = 2; i * i <= n; ++i) {       if (n % i == 0) {         return false;       }     }     return true;   }   inline long long getPow(long long a, long long b) {     long long res = 1ll, tp = a;     while (b) {       if (b & 1ll) {         res *= tp;       }       tp *= tp;       b >>= 1ll;     }     return res;   }   long long vec_mult(const pair<long long, long long> &t1,                      const pair<long long, long long> &t2,                      const pair<long long, long long> &t3) {     const long long &x1 = t1.first, y1 = t1.second;     const long long &x2 = t2.first, y2 = t2.second;     const long long &x3 = t3.first, y3 = t3.second;     return ((x2 - x1) * (y3 - y1) - (y2 - y1) * (x3 - x1));   }   void ok() {     cout <<  YES  << endl;     exit(0);   }   void no() {     cout <<  NO  << endl;     exit(0);   }   inline long long nxt() {     long long x;     cin >> x;     return x;   }   long long otr(long long num) {     long long cur = 0;     long long ct = 1;     while (num) {       cur += ct * (9 - num % 10);       num /= 10;       ct *= 10;     }     return cur;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0), cout.tie(0);     long long l = nxt(), r = nxt();     long long t = 1ll;     long long ans = -1;     while (t <= r) {       long long left = max(l, t);       long long right = min(r, 10ll * t - 1);       while (right - left > 2) {         long long len = (right - left + 1) / 3;         long long t1 = left + len;         long long t2 = right - len;         if (t1 * otr(t1) >= t2 * otr(t2)) {           right = t2;         } else {           left = t1;         }       }       while (left <= right) {         ans = max(ans, left * otr(left));         left++;       }       t *= 10ll;     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void faster() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);   }   string s, x, t, ans;   long long q, n, a[456789], b[456789], sum, prefa[456789], prefb[456789], k, l,       r, mx;   bool ok;   void dii() {     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> a[i];     }     k = 1;     for (int i = 1; i <= n; i++) {       if (a[i] <= 2 * a[i - 1]) {         k++;       } else {         k = 1;       }       if (k > mx) {         mx = k;       }     }     cout << mx;   }   int main() {     faster();     q = 1;     while (q--) {       dii();     }     return 0;   }
#include <bits/stdc++.h>   const int INF = 1 << 29;   int main() {     std::ios_base::sync_with_stdio(false);     std::cin.tie(NULL);     ;     int n;     std::cin >> n;     std::vector<int> v(n);     for (int &it : v) std::cin >> it;     int alice = v[0];     int sum = std::accumulate(v.begin(), v.end(), 0);     int target = sum / 2 + 1;     std::vector<int> ans;     ans.push_back(1);     int cur = alice;     for (int i = 0; i < n; i++) {       if (alice < v[i] * 2) continue;       cur += v[i];       ans.push_back(i + 1);       if (cur >= target) break;     }     if (cur < target) {       std::cout << 0;       exit(0);     } else {       std::cout << ans.size() <<   n ;       for (int it : ans) std::cout << it <<    ;     }     return 0;   }
#include <bits/stdc++.h>   void dfs(int64_t node, int64_t from,            const std::vector<std::vector<int64_t> > &g,            std::vector<bool> &visited, int64_t &count, bool &cycle, bool &self) {     if (visited[node]) {       return;     }     visited[node] = 1;     ++count;     for (int64_t p = 0; p < g[node].size(); p++) {       int64_t u = g[node][p];       if (u == from) {         continue;       } else if (u == node) {         self = true;       } else if (visited[u]) {         cycle = true;       } else {         dfs(u, node, g, visited, count, cycle, self);       }     }     return;   }   int main() {     const int64_t MOD = 1000000007;     int64_t n;     scanf( %lld , &n);     std::vector<std::vector<int64_t> > g(2 * n);     for (int64_t p = 0; p < n; p++) {       int64_t x, y;       scanf( %lld %lld , &x, &y);       --x;       --y;       g[x].push_back(y);       g[y].push_back(x);     }     std::vector<bool> visited(2 * n, false);     int64_t total(1);     for (int64_t p = 0; p < 2 * n; p++) {       if (visited[p]) {         continue;       }       int64_t count(0);       bool cycle(false), self(false);       dfs(p, -1, g, visited, count, cycle, self);       if (self) {         count = 1;       } else if (cycle) {         count = 2;       }       total *= count;       total %= MOD;     }     printf( %lld n , total);     return 0;   }
#include <bits/stdc++.h>   const int N = 1010, M = 2010;   int las[M], nxt[M], to[M], cnt;   int l[M], r[M], siz[M], mx[N][N], f[N];   inline void add(int u, int v) {     cnt++;     to[cnt] = v;     nxt[cnt] = las[u];     las[u] = cnt;   }   int n, m;   inline void fmin(int &a, int b) {     if (a > b) a = b;   }   inline void fmax(int &a, int b) {     if (a < b) a = b;   }   void dfs(int now) {     int i;     siz[now] = now != 1;     if (las[now]) l[now] = n, r[now] = 0;     for (i = las[now]; i; i = nxt[i])       dfs(to[i]), siz[now] += siz[to[i]], fmin(l[now], l[to[i]]),           fmax(r[now], r[to[i]]);     fmax(mx[l[now]][r[now]], siz[now]);   }   int main() {     int i, j, x;     scanf( %d , &n);     scanf( %d , &m);     for (i = 2; i <= m; i++) scanf( %d , &x), add(x, i);     for (i = 1; i <= n; i++) scanf( %d , &x), l[x] = r[x] = i;     dfs(1);     cnt = 0;     memset(las, 0, sizeof las);     scanf( %d , &m);     for (i = 2; i <= m; i++) scanf( %d , &x), add(x, i);     for (i = 1; i <= n; i++) scanf( %d , &x), l[x] = r[x] = i;     dfs(1);     for (i = 1; i <= n; i++)       for (j = 1; j <= i; j++)         if (mx[j][i]) fmax(f[i], f[j - 1] + mx[j][i]);     printf( %d n , f[n]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 100010;   int n, ans[N], an;   struct edge {     int to, nx, id, dl;   } ee[N];   int eq[N], en = 1;   void dfs(int d) {     for (int j = eq[d], k; k = ee[j].to, j; j = ee[j].nx)       if (!ee[j].dl) {         ee[j].dl = 1;         dfs(k);         ans[--an] = ee[j].id;       }   }   int main() {     scanf( %d , &n);     if (n & 1) {       printf( -1 n );       return 0;     }     for (int x = 0, t1, t2; x < n; x++) {       t1 = (x * 2 + 0) % n;       t2 = (x * 2 + 1) % n;       ee[++en] = (edge){((t1) / 2 + 1), eq[((x) / 2 + 1)], x, 0},       eq[((x) / 2 + 1)] = en;     }     an = n;     dfs(1);     for (int s = 0; s < n; s++)       if (ans[s] == 0) {         for (int i = 0; i < n; i++) printf( %d  , ans[(s + i) % n]);         printf( 0 n );         return 0;       }   }
#include <bits/stdc++.h>   using namespace std;   void _print(long long t) { cerr << t; }   void _print(int t) { cerr << t; }   void _print(string t) { cerr << t; }   void _print(char t) { cerr << t; }   void _print(long double t) { cerr << t; }   void _print(double t) { cerr << t; }   void _print(unsigned long long t) { cerr << t; }   template <class T, class V>   void _print(pair<T, V> p);   template <class T>   void _print(vector<T> v);   template <class T>   void _print(set<T> v);   template <class T, class V>   void _print(map<T, V> v);   template <class T>   void _print(multiset<T> v);   template <class T, class V>   void _print(pair<T, V> p) {     cerr <<  { ;     _print(p.first);     cerr <<  , ;     _print(p.second);     cerr <<  } ;   }   template <class T>   void _print(vector<T> v) {     cerr <<  [  ;     for (T i : v) {       _print(i);       cerr <<    ;     }     cerr <<  ] ;   }   template <class T>   void _print(set<T> v) {     cerr <<  [  ;     for (T i : v) {       _print(i);       cerr <<    ;     }     cerr <<  ] ;   }   template <class T>   void _print(multiset<T> v) {     cerr <<  [  ;     for (T i : v) {       _print(i);       cerr <<    ;     }     cerr <<  ] ;   }   template <class T, class V>   void _print(map<T, V> v) {     cerr <<  [  ;     for (auto i : v) {       _print(i);       cerr <<    ;     }     cerr <<  ] ;   }   template <class T, class V>   void _print(unordered_map<T, V> v) {     cerr <<  [  ;     for (auto i : v) {       _print(i);       cerr <<    ;     }     cerr <<  ] ;   }   template <class T>   void _print(list<T> v) {     cerr <<  [  ;     for (T i : v) {       _print(i);       cerr <<    ;     }     cerr <<  ] ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int tc = 0, T;     cin >> T;     while (++tc <= T) {       int N;       cin >> N;       cout << (int)sqrt(N) + (int)cbrt(N) - (int)sqrt((int)cbrt(N)) << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MOD = 1e9 + 7;   const double pi = acos(-1);   const double EPS = 1e-9;   long long binpowmod(long long a, long long b) {     a %= MOD;     long long ret = 1;     while (b) {       if (b & 1) ret = ret * a % MOD;       a = a * a % MOD;       b >>= 1;     }     return ret % MOD;   }   long long gcd(long long a, long long b) {     if (!b) return a;     return gcd(b, a % b);   }   const int N = 1 << 18;   const int E = N * 2;   bool good(long long n) {     long long t = n;     int sumofdigits = 0;     while (n) {       sumofdigits += n % 10;       n /= 10;     }     return (gcd(t, sumofdigits) > 1);   }   int n, m, ans;   vector<vector<int> > a;   bool good(int i, int j) {     for (int k = 0; k < m; ++k) {       if (a[i][k] != a[j][k]) return false;     }     return true;   }   void solveit(int l = 0, int r = n - 1, int c = 1) {     int len = r - l + 1;     if (len % 2) return;     int i = l, j = r;     while (i < j) {       if (!good(i, j)) return;       i++;       j--;     }     ans = min(ans, n / (1 << c));     int mid = (l + r) / 2;     solveit(l, mid, c + 1);     solveit(mid + 1, r, c + 1);   }   void solve() {     cin >> n >> m;     ans = n;     a.assign(n, vector<int>(m));     for (int i = 0; i < n; ++i)       for (int j = 0; j < m; ++j) cin >> a[i][j];     solveit();     cout << ans <<   n ;   }   int main(void) {     ios::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int tc = 1;     while (tc--) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k;     scanf( %d%d , &n, &k);     long long ans1 = 1, ans2 = 1;     for (int i = 1; i <= k - 1; i++) ans1 = ans1 * k % 1000000007;     for (int i = 1; i <= n - k; i++) ans2 = ans2 * (n - k) % 1000000007;     printf( %I64d n , ans1 * ans2 % 1000000007);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 25, mod = 1e9 + 7;   int a[N][N], used[N][N], cur, first, n, m, k;   long long ans;   int count(int x) {     int ans = 0;     for (; x; x -= x & -x) ans++;     return ans;   }   void dfs(int x, int y) {     if (x == n) {       int p = count(cur & ~first), q = count(((1 << k) - 1) & ~first);       long long curans = 1;       while (p--) {         curans = (curans * q) % mod;         q--;       }       ans = (ans + curans) % mod;       return;     }     int nx = x, ny = y + 1;     if (ny == m) {       nx++;       ny = 0;     }     if (a[x][y]) {       dfs(nx, ny);       return;     } else {       bool flag = true;       int can = (1 << k) - 1;       can &= ~used[x][y];       for (int i = 0; (1 << i) <= can; i++) {         if (!((can >> i) & 1)) continue;         bool preused[N][N], preusedcur;         preusedcur = true;         memset(preused, false, sizeof(preused));         if (!((cur >> i) & 1)) {           if (flag)             flag = false;           else             continue;           preusedcur = false;         }         cur |= 1 << i;         for (int px = x; px < n; px++)           for (int py = y; py < m; py++) {             if ((used[px][py] >> i) & 1)               preused[px][py] = true;             else               used[px][py] |= 1 << i;           }         dfs(nx, ny);         if (!preusedcur) cur &= ~(1 << i);         for (int px = x; px < n; px++)           for (int py = y; py < m; py++) {             if (!preused[px][py]) used[px][py] &= ~(1 << i);           }       }     }   }   int main() {     scanf( %d%d%d , &n, &m, &k);     if (n + m - 1 > k) {       printf( 0 n );       return 0;     }     for (int i = 0; i < n; i++)       for (int j = 0; j < m; j++) {         scanf( %d , &a[i][j]);         if (a[i][j]) {           first |= 1 << a[i][j] - 1;           if ((used[i][j] >> a[i][j] - 1) & 1) {             printf( 0 n );             return 0;           }           for (int r = 0; r < n; r++)             for (int c = 0; c < m; c++) {               if (r <= i && c <= j || r >= i && c >= j)                 used[r][c] |= 1 << a[i][j] - 1;             }         }       }     cur = first;     dfs(0, 0);     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int p1, p2, p3, p4, a, b;     cin >> p1 >> p2 >> p3 >> p4 >> a >> b;     int m = min(min(min(p1, p2), p3), p4);     cout << max(0, min(b + 1, m) - a) << endl;     return 0;   }
#include <bits/stdc++.h>   const int inf = (1 << 30) - 1;   const double eps = 1e-9;   using namespace std;   int a[111111], n, k, mx = 0, aa;   long long s[111111];   int main() {     scanf( %d%d , &n, &k);     for (int i = 1; i <= n; i++) scanf( %d , &a[i]);     sort(a + 1, a + n + 1);     for (int i = 1; i <= n; i++) s[i] = s[i - 1] + a[i];     for (int i = 1; i <= n; i++) {       int l = 1, r = i;       while (r > l) {         int m = (l + r) / 2;         long long ss = s[i] - s[m - 1];         if (1ll * a[i] * (i - m + 1) - ss > k)           l = m + 1;         else           r = m;       }       if (i - r + 1 > mx) {         mx = i - r + 1;         aa = a[i];       }     }     cout << (mx) <<    ;     cout << (aa) << endl;     return 0;   }