malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   template <class p, class q>   void umin(p& a, const q& b) {     if (a > b) a = b;   }   template <class p, class q>   void umax(p& a, const q& b) {     if (a < b) a = b;   }   using ll = long long;   using VI = std::vector<int>;   using VLL = std::vector<ll>;   using namespace std;   using namespace std::chrono;   int n;   int const N = 1e5 + 3;   ll const P = 1e9 + 7;   int a[N];   int l[N];   int prime[N];   int phi[N];   int mult[N];   int ppower[N];   ll ans;   void sieve() {     int p = 2;     prime[1] = 0;     phi[1] = 1;     while (p < N) {       ppower[p] = 1;       if (prime[p]) {         int cp = p;         while (cp % prime[p] == 0) {           cp /= prime[p];           mult[p]++;           ppower[p] *= prime[p];         }         phi[p] = (mult[p] >= 2) ? prime[p] * phi[p / prime[p]]                                 : (prime[p] - 1) * phi[p / prime[p]];         p++;         continue;       }       prime[p] = p;       ppower[p] = p;       mult[p] = 1;       phi[p] = p - 1;       for (ll i = 1LL * p * p; i < N; i += p) {         if (!prime[i]) prime[i] = p;       }       p++;     }   }   void write_divisors(int r, VI& output) {     if (r == 1)       output = {1};     else {       VI partial;       write_divisors(r / ppower[r], partial);       int prw = 1;       for (int i = (0); i <= (mult[r]); i++) {         for (const auto& u : partial) {           output.push_back(prw * u);         }         prw *= prime[r];       }     }   }   VI divisors[N];   void uzup() {     for (int i = (1); i <= (N - 1); i++) write_divisors(i, divisors[i]);   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cin >> n;     for (int i = (1); i <= (n); i++) cin >> a[i];     sieve();     uzup();     for (int j = (1); j <= (n); j++) {       VI monitor;       for (int k = j; k <= n; k += j) {         for (const auto& u : divisors[a[k]]) {           monitor.push_back(u);           ans = (ans + 1LL * phi[u] * phi[j] * (2 * l[u] + 1)) % P;           l[u]++;         }       }       for (int i = (((int)((monitor).size())) - 1); i >= (0); i--) {         l[monitor[i]]--;         monitor.pop_back();       }     }     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   void read(T &x) {     x = 0;     char ch = getchar();     long long fh = 1;     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) fh = -1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 ) x = x * 10 + ch -  0 , ch = getchar();     x *= fh;   }   template <typename T>   void write(T x) {     if (x < 0) x = -x, putchar( - );     if (x > 9) write(x / 10);     putchar(x % 10 +  0 );   }   template <typename T>   void writeln(T x) {     write(x);     puts(  );   }   long long qpow(long long a, long long b) {     if (b == -1) return 0;     long long res = 1;     while (b) {       if (b & 1) res = res * a % 998244353;       a = a * a % 998244353;       b >>= 1;     }     return res;   }   long long n;   long long a[1000005], ans;   signed main() {     read(n);     for (long long i = 1; i <= n; ++i) read(a[i]);     for (long long i = 1; i <= n; ++i) {       ans += a[i] * qpow(2, n - i) % 998244353;       ans %= 998244353;       ans += a[i] * qpow(2, n - i - 1) % 998244353 * (n - i) % 998244353;       ans %= 998244353;     }     writeln(ans);     return 0;   }
#include <bits/stdc++.h>   int main() {     int input, max = 0, temp1, temp2;     scanf( %d , &input);     for (int i = 1; i <= input; i++) {       if (input % i == 0) {         temp1 = input / i;         temp2 = i;         if (temp1 <= temp2) {           break;         }       }     }     printf( %d %d n , temp1, temp2);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1e9 + 7;   const int maxSize = 1 << 16;   map<string, int> t;   int a[maxSize];   vector<string> s;   vector<vector<int> > v;   int main() {     int n, k;     scanf( %d%d , &n, &k);     v.resize(n);     s.resize(n);     for (int i = 0; i < n; i++) {       cin >> s[i];       t[s[i]] = i;     }     for (int i = 0; i < k; i++) {       string s1, s2;       cin >> s1 >> s2;       int x, y;       x = t[s1], y = t[s2];       v[x].push_back(y);       v[y].push_back(x);     }     int res = 0, ans = 0;     for (int i = 0; i < maxSize; i++) {       int cnt = 0;       for (int j = 0; j < n; j++)         if (i & (1 << j)) cnt++;       for (int j = 0; j < n; j++)         if (i & (1 << j))           for (int x = 0; x < v[j].size(); x++)             if (i & (1 << v[j][x])) {               cnt = 0;               break;             }       if (cnt > ans) res = i, ans = cnt;     }     printf( %d n , ans);     set<string> st;     for (int i = 0; i < n; i++)       if (res & (1 << i)) st.insert(s[i]);     for (auto e : st) cout << e << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 200500;   int n;   pair<int, int> a[MAXN];   int b[MAXN];   int s[MAXN];   int FindMax(int j) {     int ret = 0;     for (; j >= 0; (j &= (j + 1))--) {       ret = max(ret, s[j]);     }     return ret;   }   void Update(int j, int x) {     for (; j < n; j |= (j + 1)) {       s[j] = max(s[j], x);     }   }   int main() {     cin >> n;     for (int i = 0; i < n; ++i) {       scanf( %d%d , &a[i].first, &a[i].second);       b[i] = a[i].first + a[i].second;     }     sort(a, a + n);     sort(b, b + n);     int res = 1;     for (int i = 0; i < n; ++i) {       int p = lower_bound(b, b + n, a[i].first - a[i].second + 1) - b - 1;       int curVal = FindMax(p) + 1;       Update(lower_bound(b, b + n, a[i].first + a[i].second) - b, curVal);       res = max(res, curVal);     }     cout << res << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline int toInt(string s) {     int v;     istringstream sin(s);     sin >> v;     return v;   }   template <class T>   inline string toString(T x) {     ostringstream sout;     sout << x;     return sout.str();   }   int n;   vector<pair<int, int> > v;   long long DP[3001][3001];   long long solve(int idx, int lst) {     if (idx == n) return 0;     long long &ret = DP[idx][lst];     if (ret != -1) return ret;     ret = (1LL << 59);     ret = min(ret, solve(idx + 1, lst) + v[idx].first - v[lst].first);     ret = min(ret, solve(idx + 1, idx) + v[idx].second);     return ret;   }   int main() {     scanf( %d , &n);     int a, b;     for (int i = 0; i < n; ++i) {       scanf( %d %d , &a, &b);       v.push_back(pair<int, int>(a, b));     }     memset(DP, -1, sizeof(DP));     sort(v.begin(), v.end());     cout << solve(1, 0) + 1LL * v[0].second;   }
#include <bits/stdc++.h>   using namespace std;   int row[1010];   int main() {     int n, m, k;     scanf( %d %d %d , &n, &m, &k);     memset(row, 0x3f3f3f3f, sizeof row);     long long ans = 0;     for (int i = (0); i < (n); ++i) {       int r, c;       scanf( %d %d , &r, &c);       row[r] = min(c, row[r]);     }     for (int i = 1; i <= m; ++i) ans += ((row[i] == 0x3f3f3f3f) ? 0 : row[i]);     printf( %lld n , min(ans, (long long)k));     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( O3 )   using namespace std;   const int N = 2e5 + 5;   int dist[N];   vector<int> open[N], close[N];   int n, k;   bool done[N];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cin >> n >> k;     for (auto i = 0; i < (long long)(n); i++) {       int l, r;       cin >> l >> r;       open[l].push_back(i);       close[r + 1].push_back(i);       dist[i] = r + 1;     }     set<int> pool;     set<pair<int, int> > dist_idx;     vector<int> res;     for (auto i = 1; i < (long long)(N); i++) {       for (auto j : close[i]) {         if (done[j]) continue;         pool.erase(j);         dist_idx.erase({dist[j], j});       }       for (auto j : open[i]) {         pool.insert(j);         dist_idx.insert({dist[j], j});       }       while (((int)((pool).size())) > k) {         auto it = dist_idx.end();         it--;         int idx = (*it).second;         res.push_back(idx + 1);         dist_idx.erase(it);         pool.erase(idx);         done[idx] = true;       }     }     cout << ((int)((res).size())) <<   n ;     for (auto i : res) cout << i <<    ;     cout <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[50][50], n, m;   bool can(int k) {     int total = 0;     for (int i = 0; i < m; i++)       if (a[k][i] != i + 1) total++;     if (total <= 2) return 1;     return 0;   }   bool ok() {     for (int i = 1; i <= n; i++)       if (!can(i)) return 0;     return 1;   }   int main() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; i++)       for (int j = 0; j < m; j++) scanf( %d , &a[i][j]);     if (ok()) {       printf( YES n );       return 0;     }     for (int i = 0; i < m - 1; i++)       for (int j = i + 1; j < m; j++) {         for (int k = 1; k <= n; k++) swap(a[k][i], a[k][j]);         if (ok()) {           printf( YES n );           return 0;         }         for (int k = 1; k <= n; k++) swap(a[k][i], a[k][j]);       }     printf( NO n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m, x, y, i;     cin >> n >> m >> x >> y;     cout << x <<     << y << endl;     int a = x;     for (i = 1; i < m + 1; i++) {       if (i != y) {         cout << x <<     << i << endl;       }     }     n++;     int cnt = 0;     while (n-- && n > 0) {       if (n != x) {         cnt++;         if (cnt % 2) {           for (int i = m; i > 0; i--) {             cout << n <<     << i << endl;           }         } else {           for (i = 1; i < m + 1; i++) {             cout << n <<     << i << endl;           }         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T1, typename T2>   ostream& operator<<(std::ostream& os, const std::map<T1, T2>& v) {     os <<  [ ;     for (typename std::map<T1, T2>::const_iterator ii = v.begin(); ii != v.end();          ++ii)       os << ii->first <<  :  << ii->second <<    ;     return os <<  ] ;   }   template <class Cntnr>   ostream& c_out(std::ostream& os, const Cntnr& v) {     os <<  [ ;     for (typename Cntnr::const_iterator ii = v.begin(); ii != v.end(); ++ii)       os << *ii <<    ;     os <<   ] ;     return os;   }   template <typename T>   ostream& operator<<(ostream& o, const vector<T>& c) {     return c_out(o, c);   }   template <typename T>   ostream& operator<<(ostream& o, const list<T>& c) {     return c_out(o, c);   }   template <typename T>   ostream& operator<<(ostream& o, const set<T>& c) {     return c_out(o, c);   }   int main() {     int n, a, b;     scanf( %d , &n);     scanf( %d , &a);     scanf( %d , &b);     for (int i = (0); i < (int)(n); i++) {       long long w;       cin >> w;       cout << w - ((((w * a) / b) * b + a - 1) / a) <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int com[] = {1, 4, 6, 8, 9};     long long int t;     cin >> t;     while (t--) {       int64_t k;       cin >> k;       string n;       cin >> n;       map<int, int> m;       for (int i = 0; i < n.size(); i++) {         m[n[i] -  0 ]++;       }       int flag = 1;       for (auto it : m) {         if (it.first == 1 || it.first == 4 || it.first == 6 || it.first == 8 ||             it.first == 9) {           flag = 0;           cout << 1 << endl << it.first << endl;           break;         }       }       if (flag) {         for (auto it : m) {           if (it.second > 1) {             cout << 2 << endl << it.first << it.first << endl;             flag = 0;             break;           }         }         if (n ==  32  || n ==  35 ) {           flag = 0;           cout << 2 << endl << n << endl;         }       }       if (flag) {         stack<int> s;         string temp =   ;         for (int i = 0; i < n.size(); i++) {           if (n[i] !=  3 ) {             temp += n[i];           }           if (temp.size() == 2) {             break;           }         }         cout << 2 << endl << temp << endl;       }     }   }
#include <bits/stdc++.h>   using namespace std;   double DP[2][2510][2510];   double X[2510], Y[2510];   double dis(int a, int b) {     return sqrt((X[a] - X[b]) * (X[a] - X[b]) + (Y[a] - Y[b]) * (Y[a] - Y[b]));   }   int main() {     ios::sync_with_stdio(false);     memset(DP, 0, sizeof(DP));     int N;     cin >> N;     for (int i = 0; i < N; i++) cin >> X[i] >> Y[i];     for (int i = 2; i <= N; i++) {       for (int s = 0; s < N; s++) {         int e = s + i - 2;         e %= N;         int t;         t = (s - 1 + N) % N;         DP[0][t][e] = max(DP[0][t][e], DP[0][s][e] + dis(s, t));         t = (e + 1) % N;         DP[1][s][t] = max(DP[1][s][t], DP[0][s][e] + dis(s, t));         t = (s - 1 + N) % N;         DP[0][t][e] = max(DP[0][t][e], DP[1][s][e] + dis(e, t));         t = (e + 1) % N;         DP[1][s][t] = max(DP[1][s][t], DP[1][s][e] + dis(e, t));       }     }     double res = 0;     for (int i = 0; i < N; i++) {       int j = (i - 1 + N) % N;       res = max(res, DP[0][i][j]);       res = max(res, DP[1][i][j]);     }     cout.precision(20);     cout << res << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class X, class Y>   void minimize(X &x, const Y &y) {     if (x > y) x = y;   }   template <class X, class Y>   void maximize(X &x, const Y &y) {     if (x < y) x = y;   }   template <class T>   T Abs(const T &x) {     return (x < 0 ? -x : x);   }   const int mod = (int)1e9 + 7;   int cntWay[500500 * 2], sumWay[500500 * 2];   int frac[500500], finv[500500];   int inverse(int x) {     int res = 1;     int mul = x;     int k = mod - 2;     while (k > 0) {       if (k & 1) res = 1LL * res * mul % mod;       mul = 1LL * mul * mul % mod;       k >>= 1;     }     return (res);   }   void precalc(void) {     frac[0] = finv[0] = 1;     for (int i = (1), _b = (500500 - 1); i <= _b; i = i + 1)       frac[i] = 1LL * frac[i - 1] * i % mod;     for (int i = (1), _b = (500500 - 1); i <= _b; i = i + 1)       finv[i] = inverse(frac[i]);   }   int comb(int k, int n) {     if (k > n) return (0);     return (1LL * frac[n] * finv[k] % mod * finv[n - k] % mod);   }   int countWay(int number, int sum, int absLim, int numBig) {     sum -= numBig * absLim;     sum += (number - numBig) * (absLim + 1);     return (comb(number - 1, sum - 1));   }   int countWay(int number, int sum, int absLim) {     int res = 0;     for (int numBig = 0, _n = (number + 1); numBig < _n; numBig = numBig + 1) {       int numSet = comb(numBig, number);       int numWay = countWay(number, sum, absLim, numBig);       if (numBig % 2 == 0)         res = (res + 1LL * numSet * numWay) % mod;       else         res = (res - 1LL * numSet * numWay % mod + mod) % mod;     }     return (res);   }   void process(void) {     int a, b, range, n;     cin >> a >> b >> range >> n;     for (int i = (-range * n), _b = (range * n); i <= _b; i = i + 1)       cntWay[i + 500500] = countWay(n, i, range);     for (int i = (range * n), _a = (-range * n); i >= _a; i = i - 1)       sumWay[i + 500500] = (sumWay[i + 1 + 500500] + cntWay[i + 500500]) % mod;     int res = 0;     for (int i = (-range * n), _b = (range * n); i <= _b; i = i + 1) {       int reqScore = b + i + 1 - a;       if (reqScore > range * n) continue;       maximize(reqScore, -range * n);       int numWayB = cntWay[i + 500500];       int numWayA = sumWay[reqScore + 500500];       res = (res + 1LL * numWayA * numWayB) % mod;     }     printf( %d n , res);   }   int main(void) {     precalc();     process();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long inf = 0x7f7f7f7f7f7f7f7f;   struct sta {     int s;     long long k, val;   } p[105];   int n, m;   long long b, f[(1 << 20) + 5];   bool cmp(sta a, sta b) { return a.k < b.k; }   void init() {     memset(f, -1, sizeof f);     scanf( %d%d , &n, &m);     cin >> b;     int t, a;     for (int i = 0; i < n; i++) {       scanf( %lld%lld%d , &p[i].val, &p[i].k, &t);       p[i].s = 0;       for (int j = 0; j < t; j++) {         scanf( %d , &a);         p[i].s |= (1 << (a - 1));       }     }     sort(p, p + n, cmp);   }   long long solve() {     f[0] = 0;     int t = (1 << m) - 1;     long long ans = inf;     for (int i = 0; i < n; i++) {       for (int j = 0; j <= t; j++) {         if (f[j] == -1) continue;         int u = p[i].s | j;         if (f[u] == -1)           f[u] = p[i].val + f[j];         else           f[u] = min(f[u], p[i].val + f[j]);       }       if (f[t] != -1) ans = min(ans, f[t] + p[i].k * b);     }     return ans == inf ? -1 : ans;   }   int main() {     init();     long long res = solve();     cout << res << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool bo[1005][1005];   double ans[1005][1005];   double f(int n, int m) {     if (m == 0) return 1;     if (bo[n][m]) return ans[n][m];     if (n == 0) {       return 1.0 / (m + 1);     }     double a = 1.0, b = 1 - f(m, n - 1);     double c = 1.0 * m / (m + 1) * (1 - f(m - 1, n)), d = 1.0 / (m + 1) + c;     double p = (d - c) / (a - c + d - b);     bo[n][m] = true;     return ans[n][m] = p * a + (1 - p) * c;   }   int main() {     int n, m;     scanf( %d%d , &n, &m);     double x = f(n, m);     printf( %.10f %.10f , x, 1 - x);   }
#include <bits/stdc++.h>   using namespace std;   long long n, w, a[1123], d, mx, mn;   int main() {     cin >> n >> w;     for (int i = 0; i < n; ++i) {       cin >> a[i];       d += a[i];       mx = max(d, mx);       mn = min(d, mn);     }     cout << max(w + 1 - mx + mn, 0ll);   }
#include <bits/stdc++.h>   char str[100005];   int main(void) {     int n, m;     int i;     scanf( %d%d , &n, &m);     scanf( %s , str);     for (i = 0; i < n && m; i++) {       if ((!(i & 1)) && str[i] ==  4 ) {         if ((str[i + 1] ==  4  && str[i + 2] ==  7 ))           break;         else if (str[i + 1] ==  7  && str[i + 2] ==  7 )           break;         else if (str[i + 1] ==  7 ) {           str[i + 1] =  4 ;           m--;         }       } else if ((i & 1) && str[i] ==  4  && str[i + 1] ==  7 ) {         str[i] =  7 ;         m--;       }     }     if (m & 1) {       if (str[i + 1] ==  4 )         str[i + 1] =  7 ;       else         str[i + 1] =  4 ;     }     printf( %s n , str);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1e5 * 2 + 10;   int n, len, h;   struct node {     int flag, mx, l, r;   } t[MAXN << 2];   int a[MAXN], b[MAXN];   int L[MAXN];   void push_down(int k) {     if (t[k].flag) {       t[k << 1].flag += t[k].flag;       t[k << 1 | 1].flag += t[k].flag;       t[k << 1].mx += t[k].flag;       t[k << 1 | 1].mx += t[k].flag;       t[k].flag = 0;     }   }   void push_up(int k) { t[k].mx = min(t[k << 1].mx, t[k << 1 | 1].mx); }   void build(int l, int r, int k) {     t[k].l = l;     t[k].r = r;     t[k].flag = 0;     if (t[k].l == t[k].r) {       t[k].mx = -t[k].l;       return;     }     int mid = t[k].l + t[k].r >> 1;     build(l, mid, k << 1);     build(mid + 1, r, k << 1 | 1);     push_up(k);   }   void update(int l, int r, int val, int k) {     if (l <= t[k].l && t[k].r <= r) {       t[k].mx += val;       t[k].flag += val;       return;     }     push_down(k);     int mid = t[k].l + t[k].r >> 1;     if (l <= mid) update(l, r, val, k << 1);     if (r > mid) update(l, r, val, k << 1 | 1);     push_up(k);   }   int main() {     scanf( %d%d%d , &n, &len, &h);     for (int i = 1; i <= len; i++) scanf( %d , b + i);     sort(b + 1, b + len + 1);     build(1, len, 1);     for (int i = 1; i <= n; i++) {       scanf( %d , a + i);       int ll = 1, rr = len, ans = -1;       while (ll <= rr) {         int mid = ll + rr >> 1;         if (b[mid] + a[i] >= h) {           ans = mid;           rr = mid - 1;         } else           ll = mid + 1;       }       L[i] = ans;     }     int res = 0;     for (int i = 1; i <= n; i++) {       if (L[i] != -1) update(L[i], len, 1, 1);       if (i >= len) {         if (t[1].mx >= 0) res++;         if (L[i - len + 1] != -1) update(L[i - len + 1], len, -1, 1);       }     }     printf( %d n , res);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int cnt[1000000 + 1];   const int mod = 1e9 + 7;   vector<int> v;   void solve() {     int n;     cin >> n;     int a[n];     for (int i = 0; i < n; i++) cin >> a[i];     sort(a, a + n);     int mx = a[n - 1];     deque<int> dq;     int i = n - 1;     for (i = n - 1; i >= 0; i--) {       if (a[i] == mx) {         dq.push_back(a[i]);       } else         break;     }     bool turn = true;     for (i; i >= 0; i--) {       if (turn == true) {         dq.push_back(a[i]);         turn = false;       } else {         dq.push_front(a[i]);         turn = true;       }     }     for (auto i : dq) cout << i <<    ;     cout << endl;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     int t;     t = 1;     while (t--) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 0x3f3f3f3f;   const long long INFF = 0x3f3f3f3f3f3f3f3fll;   const long long M = 1e9 + 7;   const long long maxn = 1e5 + 7;   const double eps = 0.00000001;   long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }   template <typename T>   inline T abs(T a) {     return a > 0 ? a : -a;   }   int cnt[6];   int a[6], b[6];   int i, j, k;   int sum;   int num(int m, int n) {     if (m * 2 > n) return 1;     if (m * 4 > n) return 2;     if (m * 8 > n) return 3;     if (m * 16 > n) return 4;     if (m * 32 > n) return 5;     return 6;   }   int n, m;   bool judge(int x) {     int sum = 0, i;     for (i = 1; i <= 5; i++) {       if (a[i] == 0 || a[i] > b[i])         sum += num(cnt[i], n + x) * (a[i] - b[i]);       else         sum += num(cnt[i] + x, n + x) * (a[i] - b[i]);     }     return sum > 0;   }   int main() {     scanf( %d , &n);     for (i = 1; i <= 5; i++) {       scanf( %d , &k);       if (k != -1)         cnt[i]++, a[i] = 250 - k;       else         a[i] = 0;     }     for (i = 1; i <= 5; i++) {       scanf( %d , &k);       if (k != -1)         cnt[i]++, b[i] = 250 - k;       else         b[i] = 0;     }     for (j = 0; j < n - 2; j++)       for (i = 1; i <= 5; i++) {         scanf( %d , &k);         if (k != -1) cnt[i]++;       }     for (i = 0; i <= 10000; i++)       if (judge(i)) {         printf( %d , i);         return 0;       }     puts( -1 );   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 1E9 + 7;   template <class C>   void mini(C& a4, C b4) {     a4 = min(a4, b4);   }   template <class C>   void maxi(C& a4, C b4) {     a4 = max(a4, b4);   }   int n, k, a[57], dp[507][57][57], small, big, res;   bool is;   int dw[57][57];   int main() {     for (int n = 0; n < (57); ++n) {       dw[n][0] = 1;       for (int k = (1); k <= (n); ++k)         dw[n][k] = (dw[n - 1][k - 1] + dw[n - 1][k]) % INF;     }     ios_base::sync_with_stdio(false);     cout << setprecision(15) << fixed;     cin >> n >> k;     for (int i = 0; i < (n); ++i) cin >> a[i];     k /= 50;     for (int i = 0; i < (n); ++i) (a[i] == 100 ? big : small)++;     dp[0][0][0] = 1;     for (int f = 0; f < (500); ++f) {       for (int s = 0; s < (small + 1); ++s)         for (int b = 0; b < (big + 1); ++b)           if (dp[f][s][b]) {             if (s == small && b == big) {               cout << f << endl << dp[f][s][b] << endl;               return 0;             }             int sogr = (f & 1 ? s : small - s);             int bogr = (f & 1 ? b : big - b);             for (int ss = 0; ss < (sogr + 1); ++ss)               for (int bb = 0; bb < (bogr + 1); ++bb)                 if (ss + bb > 0 && ss + 2 * bb <= k) {                   int news = s + ss * (f & 1 ? -1 : 1);                   int newb = b + bb * (f & 1 ? -1 : 1);                   long long ile = dp[f][s][b];                   ile *= dw[sogr][ss];                   ile %= INF;                   ile *= dw[bogr][bb];                   ile %= INF;                   dp[f + 1][news][newb] += ile;                   dp[f + 1][news][newb] %= INF;                 }           }     }     cout << -1 << endl << 0 << endl;     return 0;   }