func_code_string: #include <bits/stdc++.h>   using namespace std;   void read_file(bool outToFile = true) {}   int n, K;   int cnt50, cnt100;   const int MAXN = 51 + 9;   int memo[MAXN][MAXN][2];   int memoo[MAXN][MAXN][2];   int vis[MAXN][MAXN][2];   int C[MAXN][MAXN];   inline void add(int &x, int v) {     x += v;     if (x >= (1000000007)) x -= (1000000007);   }   void build_C() {     for (int k = 1; k < MAXN; k++) C[0][k] = 0;     for (int n = 0; n < MAXN; n++) C[n][0] = 1;     for (int n = 1; n < MAXN; n++) {       for (int k = 1; k < MAXN; k++) {         C[n][k] = C[n - 1][k];         add(C[n][k], C[n - 1][k - 1]);       }     }   }   struct state {     int cnt50l, cnt100l, cur;     state(int a, int b, int c) { cnt50l = a, cnt100l = b, cur = c; }   };   void BFS() {     memset(vis, 0, sizeof vis);     memset(memo, -1, sizeof memo);     vis[0][0][1] = 1;     queue<state> Q;     Q.push(state(0, 0, 1));     while (!Q.empty()) {       state s = Q.front();       Q.pop();       int cnt50l = s.cnt50l, cnt100l = s.cnt100l, cur = s.cur;       int cur50, cur100;       if (cur == 0)         cur50 = cnt50l, cur100 = cnt100l;       else         cur50 = cnt50 - cnt50l, cur100 = cnt100 - cnt100l;       int nret, ncnt;       int new50, new100;       for (int i = 0; i <= cur50; i++) {         for (int j = 0; j <= cur100; j++) {           if (i + j == 0) continue;           if (i * 50 + j * 100 > K) break;           if (cur == 0) {             new50 = cnt50l - i;             new100 = cnt100l - j;           } else {             new50 = cnt50l + i;             new100 = cnt100l + j;           }           int &old = vis[new50][new100][!cur];           if (old == 1) continue;           old = 1;           Q.push(state(new50, new100, !cur));         }       }       if (cnt50l == 0 && cnt100l == 0 && cur == 1) {         memo[0][0][1] = 0;         memoo[0][0][1] = 1;         continue;       }       int &ret = memo[cnt50l][cnt100l][cur];       int &cnt = memoo[cnt50l][cnt100l][cur];       ret = (2000000000), cnt = 0;       for (int i = 0; i <= cur50; i++) {         for (int j = 0; j <= cur100; j++) {           if (i + j == 0) continue;           if (i * 50 + j * 100 > K) break;           if (cur == 0) {             new50 = cnt50l - i;             new100 = cnt100l - j;           } else {             new50 = cnt50l + i;             new100 = cnt100l + j;           }           ncnt = 1LL * C[cur50][i] * C[cur100][j] % (1000000007);           ncnt = 1LL * ncnt * memoo[new50][new100][!cur] % (1000000007);           int nret = memo[new50][new100][!cur];           if (nret == -1) continue;           nret++;           if (ret > nret)             ret = nret, cnt = ncnt;           else             add(cnt, ncnt);         }       }       if (cnt50l == cnt50 && cnt100l == cnt100 && cur == 0) break;     }     int ans = memo[cnt50][cnt100][0];     int ansc = memoo[cnt50][cnt100][0];     if (ans == -1) ans = -1, ansc = 0;     printf( %d n%d n n , ans, ansc);   }   int main() {     read_file();     build_C();     while (scanf( %d%d , &n, &K) != -1) {       cnt50 = 0, cnt100 = 0;       for (int i = 0; i < n; i++) {         int x;         scanf( %d , &x);         if (x == 50)           cnt50++;         else           cnt100++;       }       BFS();     }   }   