malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:128777216 )   const int null = 0;   using namespace std;   template <class T>   int size(const T &a) {     return int(a.size());   }   template <class T>   T abs(const T &a) {     return (a < 0 ? -a : a);   }   template <class T>   T sqr(const T &a) {     return a * a;   }   const int max_n = 52, mod = 1000000007;   int dist[max_n][max_n][2];   int dp[max_n][max_n][2];   bool was[max_n][max_n][2];   struct Pos {     int i, j, s;     int d;     void init(int i, int j, int s, int d) {       this->i = i;       this->j = j;       this->s = s;       this->d = d;       was[i][j][s] = true;       dist[i][j][s] = d;     }   } q[max_n * max_n * 2];   int cmn[max_n][max_n];   int main() {     int n, k;     scanf( %d %d , &n, &k);     for (int i = 0; i <= n; i++) {       cmn[0][i] = 1;     }     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= n; j++) {         cmn[i][j] = cmn[i - 1][j - 1] + cmn[i][j - 1];       }     }     k /= 50;     int c0 = 0, c1 = 0;     for (int i = 0; i < n; i++) {       int t;       scanf( %d , &t);       if (t == 50) {         c0++;       } else {         c1++;       }     }     q[0].init(0, 0, 1, 0);     dp[0][0][1] = 1;     for (int d = 0, u = 1; d < u; d++) {       Pos p = q[d];       int mc0, mc1;       if (p.s) {         mc0 = c0 - p.i;         mc1 = c1 - p.j;       } else {         mc0 = p.i;         mc1 = p.j;       }       long long cnt = dp[p.i][p.j][p.s];       for (int i = 0; i <= mc0; i++) {         for (int j = 0; j <= mc1; j++) {           if (i + j > 0 && i + j * 2 <= k) {             int c0, c1, s0 = p.s ^ 1;             if (p.s) {               c0 = p.i + i;               c1 = p.j + j;             } else {               c0 = p.i - i;               c1 = p.j - j;             }             long long cur = cnt * cmn[i][mc0] % mod * cmn[j][mc1] % mod;             if (!was[c0][c1][s0]) {               q[u++].init(c0, c1, s0, p.d + 1);               dp[c0][c1][s0] = cur;             } else if (p.d + 1 == dist[c0][c1][s0]) {               dp[c0][c1][s0] = (cur + dp[c0][c1][s0]) % mod;             }           }         }       }     }     if (!was[c0][c1][0]) {       printf( -1 n0 n );       return 0;     }     printf( %d n%d n , dist[c0][c1][0], dp[c0][c1][0]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using ld = long double;   using pii = pair<int, int>;   using vi = vector<int>;   const int N = 4e5;   vi cnt(N, 0);   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int a;     cin >> a;     string s;     cin >> s;     int n = s.size();     for (int i = 0; i < n; i++) {       int sum = 0;       for (int j = i; j < n; j++) {         sum += int(s[j] -  0 );         cnt[sum]++;       }     }     ll ans = 0;     if (a == 0) {       for (int i = 0; i < N; i++) ans += cnt[i];       ans = 2 * cnt[0] * ans - 1LL * cnt[0] * cnt[0];     } else {       for (int i = 1; i < N; i++) {         if (a % i) continue;         int b = a / i;         if (b >= N) continue;         ans += 1LL * cnt[i] * cnt[b];       }     }     cout << ans <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   inline int read() {     int f = 1, res = 0, ch = getchar();     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 ) res = res * 10 + ch - 48, ch = getchar();     return f * res;   }   int _sta[1 << 8];   inline void write(int val) {     if (!val) {       putchar( 0 );       return;     }     if (val < 0) putchar( - ), val = -val;     *_sta = 0;     while (val > 0) _sta[++*_sta] = val % 10, val /= 10;     for (int i = *_sta, _Lim = 1; i >= _Lim; i--) putchar(_sta[i] + 48);   }   const long long INF = 1e18;   long long Exgcd(long long a, long long b, long long &x, long long &y) {     if (!b) {       x = 1, y = 0;       return a;     }     int res = Exgcd(b, a % b, x, y);     int x_ = x;     x = y;     y = x_ - a / b * y;     return res;   }   int n, m, k;   long long Cal(long long x, long long y) {     long long a, b;     long long gcd = Exgcd(2 * n, 2 * m, a, b);     long long lcm = 1LL * 2 * n * 2 * m / gcd;     if (a < 0)       a = -a;     else       a = 2 * m / gcd - a;     if ((x - y) % gcd != 0) return INF;     x += 1LL * (x - y) / gcd * a * 2 * n;     x -= x / lcm * lcm;     if (x < 0) x += lcm;     return x;   }   int main() {     n = read();     m = read();     k = read();     while (k--) {       int x = read(), y = read();       long long Ans = INF;       Ans = min(Ans, Cal(x, y));       Ans = min(Ans, Cal(x, 2 * m - y));       Ans = min(Ans, Cal(2 * n - x, y));       Ans = min(Ans, Cal(2 * n - x, 2 * m - y));       if (Ans < INF)         printf( %I64d n , Ans);       else         printf( -1 n );     }   }
#include <bits/stdc++.h>   using namespace std;   const int SZ = 2000010;   const int INF = 1e9 + 10;   const int mod = 1e9 + 7;   const long double eps = 1e-8;   long long read() {     long long n = 0;     char a = getchar();     bool flag = 0;     while (a >  9  || a <  0 ) {       if (a ==  - ) flag = 1;       a = getchar();     }     while (a <=  9  && a >=  0 ) {       n = n * 10 + a -  0 , a = getchar();     }     if (flag) n = -n;     return n;   }   vector<int> g2[SZ];   vector<int> g[SZ];   int n, m, q;   int ccnt = 0;   int dfn[SZ], low[SZ], dfs_clock;   stack<int> S;   bool cut[SZ], ins[SZ];   void Tarjan(int u, int f) {     dfn[u] = low[u] = ++dfs_clock;     S.push(u);     ins[u] = 1;     int child = 0;     for (int i = 0; i < g2[u].size(); i++) {       int v = g2[u][i];       if (v == f) continue;       if (!dfn[v]) {         child++;         Tarjan(v, u);         low[u] = min(low[u], low[v]);         if (low[v] >= dfn[u]) {           ccnt++;           cut[u] = 1;           int x;           do {             x = S.top();             S.pop();             ins[x] = 0;             g[ccnt + n].push_back(x);             g[x].push_back(ccnt + n);           } while (x != v && !S.empty());           g[ccnt + n].push_back(u);           g[u].push_back(ccnt + n);         }       } else if (ins[v]) {         low[u] = min(low[u], dfn[v]);       }     }     if (f == 0 && child == 1) cut[u] = 0;   }   int anc[SZ][22], deep[SZ];   void dfsLca(int u, int f) {     deep[u] = deep[f] + 1;     anc[u][0] = f;     for (int i = 1; anc[u][i - 1]; i++) anc[u][i] = anc[anc[u][i - 1]][i - 1];     for (int i = 0; i < g[u].size(); i++) {       int v = g[u][i];       if (v == f) continue;       dfsLca(v, u);     }   }   int askLca(int u, int v) {     if (deep[u] < deep[v]) swap(u, v);     int dd = deep[u] - deep[v];     for (int i = 20; i >= 0; i--)       if (dd >> i & 1) u = anc[u][i];     if (u == v) return u;     for (int i = 20; i >= 0; i--)       if (anc[u][i] != anc[v][i]) u = anc[u][i], v = anc[v][i];     return anc[u][0];   }   int main() {     n = read(), m = read(), q = read();     for (int i = 1; i <= m; i++) {       int x = read(), y = read();       g2[x].push_back(y);       g2[y].push_back(x);     }     Tarjan(1, 0);     n += ccnt;     dfsLca(1, 0);     while (q--) {       int x = read(), y = read();       int lca = askLca(x, y);       int ans = deep[x] + deep[y] - 2 * deep[lca];       printf( %d n , ans / 2);     }     return 0;   }
#include <iostream>   #include <cmath>      using namespace std;      int main() {       int t;              cin >> t;              while(t--)       {           int xa, ya, xb, yb, xf, yf;                      cin >> xa >> ya >> xb >> yb >> xf >> yf;                      if(xa==xb && xb==xf && yf > ya && yf < yb)           {               cout << abs(yb-ya) + 2 << endl;               continue;           }                      else if(xa==xb && xb==xf && yf < ya && yf > yb)           {               cout << abs(yb-ya) + 2 << endl;               continue;           }                      else if(ya==yb && yb==yf && xf>xa && xf<xb)           {               cout << abs(xb-xa) + 2 << endl;               continue;           }                      else if(ya==yb && yb==yf && xf<xa && xf>xb)           {               cout << abs(xb-xa) + 2 << endl;               continue;           }                      else           {               cout << abs(xb-xa) + abs(yb-ya) << endl;               continue;           }       }   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:102400000,102400000 )   using namespace std;   const int mo = 1000000007;   const int inf = 0x3f3f3f3f;   const int INF = 2000000000;   int n, m, phi;   int lt[100008], size[100008], f[100008], vis[100008], a[100008], b[100008], sum,       tot, root, pre1[100008], pre2[100008];   long long ans, Alltmp;   map<int, int> mp;   struct edge {     int u, v, w, nt;   } eg[100008 * 2];   void add(int u, int v, int w) {     eg[++sum] = (edge){u, v, w, lt[u]};     lt[u] = sum;   }   long long quick(long long x, long long y) {     long long res = 1;     while (y) {       if (y & 1) res = res * x % m;       x = x * x % m;       y >>= 1;     }     return res;   }   void init() {     int mm = m;     phi = m;     for (int i = 2; i * i <= m; i++) {       if (mm % i == 0) {         while (mm % i == 0) mm /= i;         phi = phi / i * (i - 1);       }     }     if (mm > 1) phi = phi / mm * (mm - 1);     memset(lt, 0, sizeof(lt));     ;     sum = 1;     memset(f, 0, sizeof(f));     ;     f[0] = INF;     memset(vis, 0, sizeof(vis));     ;     ans = 0;     pre1[0] = 1;     pre2[0] = 1;     for (int i = 1; i <= 100000; i++) {       pre1[i] = 1ll * pre1[i - 1] * 10 % m;       pre2[i] = quick(pre1[i], phi - 1);     }   }   void getRoot(int u, int fa) {     size[u] = 1;     f[u] = 0;     for (int i = lt[u]; i; i = eg[i].nt) {       int v = eg[i].v;       if (vis[v] || v == fa) continue;       getRoot(v, u);       size[u] += size[v];       f[u] = max(f[u], size[v]);     }     f[u] = max(f[u], tot - size[u]);     if (f[u] < f[root]) root = u;   }   void getA(int u, int fa, int len) {     for (int i = lt[u]; i; i = eg[i].nt) {       int v = eg[i].v;       if (vis[v] || v == fa) continue;       a[v] = (1ll * eg[i].w * pre1[len] + a[u]) % m;       getA(v, u, len + 1);     }     Alltmp += mp[a[u]];     int tp = (m - b[u]) % m;     tp = 1ll * tp * pre2[len] % m;     if (a[u] == tp) Alltmp--;   }   void getB(int u, int fa, int len) {     int tp = (m - b[u]) % m;     tp = 1ll * tp * pre2[len] % m;     mp[tp]++;     for (int i = lt[u]; i; i = eg[i].nt) {       int v = eg[i].v;       if (vis[v] || v == fa) continue;       b[v] = (1ll * b[u] * 10 + eg[i].w) % m;       getB(v, u, len + 1);     }   }   long long calc(int u, int key) {     key %= m;     Alltmp = 0;     mp.clear();     a[u] = b[u] = key;     getB(u, 0, key == 0 ? 0 : 1);     getA(u, 0, key == 0 ? 0 : 1);     return Alltmp;   }   void solve(int u) {     ans += calc(u, 0);     vis[u] = 1;     for (int i = lt[u]; i; i = eg[i].nt) {       int v = eg[i].v;       if (vis[v]) continue;       ans -= calc(v, eg[i].w);       root = 0;       tot = size[v];       getRoot(v, u);       solve(root);     }   }   int main() {     scanf( %d%d , &n, &m);     init();     for (int i = 1; i <= n - 1; i++) {       int u, v, w;       scanf( %d%d%d , &u, &v, &w);       add(u + 1, v + 1, w);       add(v + 1, u + 1, w);     }     root = 0;     tot = n;     getRoot(1, 0);     solve(root);     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m, x1, y1, x2, y2;     scanf( %d%d%d%d%d%d , &n, &m, &x1, &y1, &x2, &y2);     int x, y;     x = abs(x1 - x2);     y = abs(y1 - y2);     if (x > y) swap(x, y);     if (y < 4) {       cout <<  First  << endl;       return 0;     }     if (x < 3 && y < 5) {       cout <<  First  << endl;       return 0;     }     cout <<  Second  << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 55;   int n, m;   int a[MAXN];   double dp[MAXN][MAXN][MAXN];   double C[MAXN][MAXN];   void init() {     C[0][0] = 1.0;     for (int i = 1; i <= 50; i++) {       C[i][0] = 1.0;       for (int j = 1; j <= i; j++) C[i][j] = C[i - 1][j - 1] + C[i - 1][j];     }   }   int main() {     scanf( %d%d , &n, &m);     init();     for (int i = 1; i <= m; i++) scanf( %d , &a[i]);     for (int i = 0; i <= n; i++) dp[0][0][i] = i;     for (int i = 1; i <= m; i++) {       for (int j = 0; j <= n; j++) {         for (int k = 0; k <= n; k++) {           for (int c = 0; c <= j; c++) {             int maxq = max(k, (c + a[i] - 1) / a[i]);             dp[i][j][k] +=                 dp[i - 1][j - c][maxq] * pow(i - 1, j - c) / pow(i, j) * C[j][c];           }         }       }     }     printf( %.12f n , dp[m][n][0]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m, i, j;     long long int sum = 0, x;     cin >> n >> m;     int a[n][m];     for (i = 0; i < n; i++) {       for (j = 0; j < m; j++) {         cin >> a[i][j];       }     }     for (i = n - 2; i >= 1; i--) {       for (j = m - 2; j >= 1; j--) {         if (a[i][j] == 0) {           x = min(a[i][j + 1], a[i + 1][j]);           a[i][j] = x - 1;         }       }     }     for (i = 0; i < n; i++) {       for (j = 0; j < m - 1; j++) {         if (a[i][j] >= a[i][j + 1]) {           cout <<  -1  << endl;           return 0;         }       }     }     for (i = 0; i < m; i++) {       for (j = 0; j < n - 1; j++) {         if (a[j][i] >= a[j + 1][i]) {           cout <<  -1  << endl;           return 0;         }       }     }     for (i = 0; i < n; i++) {       for (j = 0; j < m; j++) {         sum = sum + a[i][j];       }     }     cout << sum << endl;   }
#include <bits/stdc++.h>   using namespace std;   double f(double m, vector<int> &v) {     int n = v.size();     vector<long double> v2(n);     for (int i = 0; i < (n); i++) v2[i] = v[i] - m;     long double mx_otr = 0;     long double mn_otr = 0;     long double cur = 0;     for (int i = 0; i < (n); i++) {       cur += v2[i];       if (cur < 0) cur = 0;       mx_otr = max(mx_otr, cur);     }     cur = 0;     for (int i = 0; i < (n); i++) {       cur += v2[i];       if (cur >= 0) cur = 0;       mn_otr = min(mn_otr, cur);     }     return max(mx_otr, abs(mn_otr));   }   inline void solve() {     int n;     cin >> n;     vector<int> v(n);     for (int i = 0; i < (n); i++) cin >> v[i];     long double l = -10000, r = 10000;     while (abs(r - l) > 1e-12) {       long double m1 = l + (r - l) / 3;       long double m2 = r - (r - l) / 3;       if (f(m1, v) <= f(m2, v))         r = m2;       else         l = m1;     }     cout << fixed << setprecision(10) << f(l + (r - l) / 2.0, v);   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int q = 1;     while (q--) {       solve();       cout <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 300005;   int n, tt, rt, ans, ls[N], rs[N], val[N], tg[N], rd[N];   inline int nw(int v) {     val[++tt] = v;     rd[tt] = rand();     return tt;   }   inline void add(int x, int v) {     val[x] += v;     tg[x] += v;   }   inline void dn(int x) {     add(ls[x], tg[x]);     add(rs[x], tg[x]);     tg[x] = 0;   }   void split(int x, int k, int& a, int& b) {     if (!x) {       a = b = 0;       return;     }     dn(x);     val[x] < k ? (a = x, split(rs[x], k, rs[a], b))                : (b = x, split(ls[x], k, a, ls[b]));   }   int merge(int x, int y) {     if (!x || !y)       return x | y;     else if (rd[x] < rd[y]) {       dn(x);       rs[x] = merge(rs[x], y);       return x;     } else {       dn(y);       ls[y] = merge(x, ls[y]);       return y;     }   }   int main() {     scanf( %d , &n);     while (n--) {       int l, r, x, y, z;       scanf( %d%d , &l, &r);       split(rt, r, x, z);       split(x, l, x, y);       add(y, 1);       if (z) {         int w = z;         while (ls[w]) dn(w), w = ls[w];         split(z, val[w] + 1, w, z);       } else         ans++;       rt = merge(merge(x, nw(l)), merge(y, z));     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1e6;   char buff[MAXN + 5];   string input, subs;   int freq[10];   int counter(int num) {     int ret = 0;     while (num) {       ret++;       num /= 10;     }     return ret;   }   string res;   bool flag;   void solve(bool taken) {     for (int i = 0; i <= 10; i++) {       if (!taken && (subs[0] -  0 ) < i) {         res += subs;         solve(1);         return;       } else if (i <= 9 && freq[i]) {         char c = (i +  0 );         res += c;         freq[i]--;         solve(taken);         freq[i]++;         return;       }     }     return;   }   void solve2(bool taken) {     for (int i = 0; i <= 10; i++) {       if (!taken && (subs[0] -  0 ) <= i) {         res += subs;         solve2(1);         return;       } else if (i <= 9 && freq[i]) {         char c = (i +  0 );         res += c;         freq[i]--;         solve2(taken);         freq[i]++;         return;       }     }     return;   }   int main() {     scanf( %s , buff);     input = buff;     scanf( %s , buff);     subs = buff;     if (input.size() == 2) {       if (input[0] ==  1 ) swap(input[0], input[1]);       printf( %c n , input[0]);       return 0;     }     int k;     string sk;     for (int i = 1; i <= MAXN; i++) {       if (i == input.size() - counter(i)) {         k = i;         break;       }     }     int temp = k;     while (temp) {       char c = ((temp % 10) +  0 );       sk = c + sk;       temp /= 10;     }     for (int i = 0; i < input.size(); i++) freq[input[i] -  0 ]++;     for (int i = 0; i < subs.size(); i++) freq[subs[i] -  0 ]--;     for (int i = 0; i < sk.size(); i++) freq[sk[i] -  0 ]--;     flag = 0;     char d = sk[0];     for (int i = 1; i < sk.size(); i++) {       if (sk[i] < d) {         flag = 1;         break;       } else if (sk[i] == d)         ;       else         break;     }     solve(1);     string res1 = subs + res;     res.clear();     for (int i = 1; i <= 9; i++) {       if (freq[i]) {         char c = (i +  0 );         res += c;         freq[i]--;         solve(0);         freq[i]++;         break;       }     }     string res2 = res;     res.clear();     for (int i = 1; i <= 9; i++) {       if (freq[i]) {         char c = (i +  0 );         res += c;         freq[i]--;         solve2(0);         freq[i]++;         break;       }     }     string res3 = res;     char c =  9  + 1;     if (res1[0] ==  0  || res1 ==   ) res1 =   , res1 += c;     if (res2[0] ==  0  || res2 ==   ) res2 =   , res2 += c;     if (res3[0] ==  0  || res3 ==   ) res3 =   , res3 += c;     if (res1 < res2 && res1 < res3)       printf( %s n , res1.c_str());     else if (res2 < res1 && res2 < res3)       printf( %s n , res2.c_str());     else       printf( %s n , res3.c_str());     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void B();   int main() {     ios::sync_with_stdio(0);     cout.tie(0);     cin.tie(0);     B();   }   class segmen {    public:     long long x1, y1, x2, y2;     segmen(long long xx1, long long yy1, long long xx2, long long yy2)         : x1{xx1}, x2{xx2}, y1{yy1}, y2{yy2} {}     segmen() {}   };   vector<segmen> hor, ver;   const long long N = 10010;   const long long shift = 5001;   bool compar(segmen A, segmen B) { return A.y1 <= B.y1; }   long long T[N];   void upd(long long x, long long val) {     for (; x < N; x += (x & (-x))) T[x] += val;   }   long long F(long long x) {     long long ret = 0;     for (; x; x -= (x & (-x))) ret += T[x];     return ret;   }   long long gett(long long l, long long r) { return F(r) - F(l - 1); }   vector<pair<long long, long long> > H[N];   vector<pair<long long, long long> > V[N];   void B() {     long long n;     cin >> n;     for (long long i = 0; i < n; i++) {       long long x1, x2, y1, y2;       cin >> x1 >> y1 >> x2 >> y2;       x1 += shift;       x2 += shift;       y1 += shift;       y2 += shift;       if (y1 == y2) {         H[y1].push_back({min(x1, x2), max(x1, x2)});       }       if (x1 == x2) {         V[x1].push_back({min(y1, y2), max(y1, y2)});       }     }     long long ans = 0;     vector<long long> endy[N];     for (long long i = 1; i < N; i++) {       for (auto A : H[i]) {         long long xl = A.first;         long long xr = A.second;         long long maxn = 0;         for (long long j = xl; j <= xr; j++) {           for (auto B : V[j]) {             if (B.first <= i && B.second > i) {               upd(j, 1);               endy[B.second].push_back(j);               maxn = max(maxn, B.second);             }           }         }         for (long long j = i + 1; j <= maxn; j++) {           for (auto B : H[j]) {             long long ret = gett(B.first, B.second);             ans += (ret * (ret - 1)) >> 1;           }           for (auto B : endy[j]) {             upd(B, -1);           }           endy[j].clear();         }       }     }     cout << ans <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 50;   long long fac[N + 1];   void init() {     fac[0] = 1;     for (long long i = 1; i <= N; i++) {       fac[i] = (i * fac[i - 1]) % 1000000007LL;     }   }   long long pw(long long a, long long e) {     if (e == 0) {       return 1;     }     long long ret = pw(a, e / 2);     ret = (ret * ret) % 1000000007LL;     if (e % 2 == 1) {       ret = (a * ret) % 1000000007LL;     }     return ret;   }   long long choose(long long x, long long y, long long x0, long long y0) {     return (((((fac[x] * pw(fac[x0], 1000000007LL - 2)) % 1000000007LL) *               pw(fac[x - x0], 1000000007LL - 2)) %              1000000007LL) *             ((((fac[y] * pw(fac[y0], 1000000007LL - 2)) % 1000000007LL) *               pw(fac[y - y0], 1000000007LL - 2)) %              1000000007LL)) %            1000000007LL;   }   long long X, Y;   vector<pair<long long, long long> > adj[(N + 1) * (N + 1) * 2];   long long getVertex(long long x, long long y, long long sh) {     return sh * (X + 1) * (Y + 1) + x * (Y + 1) + y;   }   queue<long long> q;   long long dist[(N + 1) * (N + 1) * 2], ways[(N + 1) * (N + 1) * 2];   int main() {     init();     long long n, k;     cin >> n >> k;     while (n--) {       long long w;       cin >> w;       if (w == 50) {         X++;       } else {         Y++;       }     }     for (long long x = 0; x <= X; x++) {       for (long long y = 0; y <= Y; y++) {         for (long long x0 = 0; x0 <= x; x0++) {           for (long long y0 = 0; y0 <= y; y0++) {             if (x0 + y0 >= 1 && (50 * x0 + 100 * y0 <= k)) {               long long w = choose(x, y, x0, y0);               adj[getVertex(x, y, 0)].push_back(pair<long long, long long>(                   getVertex(X - x + x0, Y - y + y0, 1), w));               adj[getVertex(x, y, 1)].push_back(pair<long long, long long>(                   getVertex(X - x + x0, Y - y + y0, 0), w));             }           }         }       }     }     long long start = getVertex(X, Y, 0), end = getVertex(X, Y, 1);     for (long long u = 0; u <= (X + 1) * (Y + 1) * 2 - 1; u++) {       dist[u] = 1000000000000000000LL;     }     q.push(start);     dist[start] = 0;     ways[start] = 1;     while (!q.empty()) {       long long u = q.front();       q.pop();       for (pair<long long, long long> vw : adj[u]) {         long long v = vw.first, w = vw.second;         if (dist[u] + 1 < dist[v]) {           q.push(v);           dist[v] = dist[u] + 1;           ways[v] = (ways[u] * w) % 1000000007LL;         } else if (dist[u] + 1 == dist[v]) {           ways[v] = (ways[v] + ways[u] * w) % 1000000007LL;         }       }     }     cout << (dist[end] == 1000000000000000000LL ? -1 : dist[end]) <<   n           << ways[end] <<   n ;   }