stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):
#include<bits/stdc++.h>

#define sz(x) ((int)(x).size())

#define rep(i,a,b) for (int i=(a); i<(b); i++)

#define per(i,a,b) for (int i=(b-1); i>=(a); i--)

#define debug(x) cout << #x << " => " << x << endl

using namespace std;



#define fi first

#define se second

#define mp make_pair

typedef pair<int,int> pii;



#define pb push_back

typedef vector<int> vi;



typedef long long ll;

typedef long double ld;



const int MAX_N = 7 + 50;

///----------------------------------------------

int dig[MAX_N];

int sum[MAX_N];

ll  f[MAX_N][MAX_N][MAX_N*MAX_N];

int main() {



	///read

	int n, A; cin>>n>>A;

	rep(i,1,n+1) scanf("%d",&dig[i]);

	rep(i,1,n+1) sum[i] = sum[i-1] + dig[i];

	

	///work

	rep(i,0,n+1) f[i][0][0]=1;

	rep(i,1,n+1) rep(j,1,i+1) rep(k,0,sum[i]+1) {

		f[i][j][k] = f[i-1][j][k];

		if (k>=dig[i])

			f[i][j][k] += f[i-1][j-1][k-dig[i]];

	}

	///debug(233);

	///print

	ll ans=0;

	rep(i,1,n+1) if (i*A<=sum[n]) ans+=f[n][i][i*A];

	cout << ans;



}

// Optimized solution to the same problem (faster):
#include<cstdio>

#include<cstring>

#include<algorithm>

#define MAXN 50

using namespace std;

typedef long long LL;

int a[MAXN+5];

LL dp[MAXN+5][MAXN*MAXN+5];

int main()

{

	int n,A;

	scanf("%d %d",&n,&A);

	for(int i=1;i<=n;i++)

		scanf("%d",&a[i]);

	dp[0][0]=1LL;

	for(int i=1;i<=n;i++)

		for(int j=A*n;j>=a[i];j--)

			for(int tot=n;tot>=1;tot--)

				dp[tot][j]+=dp[tot-1][j-a[i]];

	LL ans=0;

	for(int tot=1;tot<=n;tot++)

		ans+=dp[tot][A*tot];

	printf("%lld\n",ans);

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;

typedef pair<int, int> pii;

typedef pair<ll, ll> pll;

const int INF = 1e9;

const ll LINF = 1e18;



/*

<url:https://arc060.contest.atcoder.jp/tasks/arc060_a>

問題文============================================================

 高橋君は、N 枚のカードを持っています。 i (1≤i≤N) 番目のカードには、整数 xi が書かれています。

 高橋君は、これらのカードの中から 1 枚以上を選び、

 選んだカードに書かれた整数の平均をちょうど A にしたいと考えています。

 そのようなカードの選び方が何通りあるか求めてください。

=================================================================



解説=============================================================



================================================================

*/

ll dp[55][55][50*50+1];

int main(void) {

	cin.tie(0); ios::sync_with_stdio(false);

    ll N,A; cin >>N >> A;

    vector<ll> x(N);

    for(auto& in:x) cin >> in;

    dp[0][0][0] = 1;

    for(int i = 0; i < N;i++){

        for(int j = 0; j <= i; j++){

            for(int k = 0; k <= N*50; k++){

                if(dp[i][j][k] == 0) continue;

                dp[i+1][j][k] += dp[i][j][k];

                dp[i+1][j+1][k+x[i]] += dp[i][j][k];

            }

        }

    }

    ll ans = 0;

    for(int i = 1; i <= N;i++){

        ans += dp[N][i][i*A];

    }

    cout << ans << endl;

	return 0;

}


// Optimized solution to the same problem (faster):
#include<cstdio>

#include<cstring>

#include<algorithm>

#define MAXN 50

using namespace std;

typedef long long LL;

int a[MAXN+5];

LL dp[MAXN+5][MAXN*MAXN+5];

int main()

{

	int n,A;

	scanf("%d %d",&n,&A);

	for(int i=1;i<=n;i++)

		scanf("%d",&a[i]);

	dp[0][0]=1LL;

	for(int i=1;i<=n;i++)

		for(int j=A*n;j>=a[i];j--)

			for(int tot=n;tot>=1;tot--)

				dp[tot][j]+=dp[tot-1][j-a[i]];

	LL ans=0;

	for(int tot=1;tot<=n;tot++)

		ans+=dp[tot][A*tot];

	printf("%lld\n",ans);

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <cstdio>

#include <cstdlib>

#include <cmath>

#include <cstring>

#include <algorithm>

#include <utility>

using namespace std;

//#define local

const int maxn=55;

long long dp[maxn][maxn*maxn];

int main()

{

#ifdef local

    freopen("input.txt","r",stdin);

    //freopen("output.txt","w",stdout);

#endif

    int n,a,x,maxx=0;

    long long ans=0;

    cin>>n>>a;

    dp[0][0]=1;

    for(int i=1; i<=n; i++)

    {

        cin>>x;

        maxx=max(maxx,x);

        for(int j=i-1; j>=0; j--)

            for(int k=0; k<=j*maxx; k++)

                dp[j+1][k+x]+=dp[j][k];

    }

    for(int i=1; i<=n ;i++)

        ans+=dp[i][i*a];

    cout<<ans;

    return 0;

}


// Optimized solution to the same problem (faster):
#include<cstdio>

#include<cstring>

#include<algorithm>

#define MAXN 50

using namespace std;

typedef long long LL;

int a[MAXN+5];

LL dp[MAXN+5][MAXN*MAXN+5];

int main()

{

	int n,A;

	scanf("%d %d",&n,&A);

	for(int i=1;i<=n;i++)

		scanf("%d",&a[i]);

	dp[0][0]=1LL;

	for(int i=1;i<=n;i++)

		for(int j=A*n;j>=a[i];j--)

			for(int tot=n;tot>=1;tot--)

				dp[tot][j]+=dp[tot-1][j-a[i]];

	LL ans=0;

	for(int tot=1;tot<=n;tot++)

		ans+=dp[tot][A*tot];

	printf("%lld\n",ans);

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

#define int long long

#define MAXN 52

#define MOD 1000000007

#define sz(a) static_cast<long long>(a.size())

#define INF 2000000000000000000

#define pb push_back

#define mp make_pair

using namespace std;

typedef pair<int,int> pp;

int n,a[MAXN],dp[MAXN][MAXN*MAXN],ans=0,val;

main(){

	//ios::sync_with_stdio(false); cin.tie(0);

	//freopen("inp.txt","r",stdin); //freopen("out.txt","w",stdout);

	//freopen(".INP","r",stdin); freopen(".OUT","w",stdout);

	cin>>n>>val; int i,j,k;

	for (i=1;i<=n;i++) cin>>a[i];

	for (i=0;i<MAXN;i++){

		for (j=0;j<MAXN*MAXN;j++) dp[i][j]=0;

	}

	dp[0][0]=1;

	for (i=1;i<=n;i++){

		for (j=i-1;j>=0;j--){

			for (k=2500;k>=0;k--){

				if (k >= a[i] && dp[j][k-a[i]]>0)

					dp[j+1][k]+=dp[j][k-a[i]];

			}

		}

	}

	for (i=1;i<=n;i++) ans+=dp[i][val*i];

	cout<<ans;

}

// Optimized solution to the same problem (faster):
#include<bits/stdc++.h>



#define sci(a) scanf("%d", &a)

#define fto(i, a, b) for (int i = a; i <= b; ++i)

#define fdto(i, a, b) for (int i = a; i >= b; --i)

#define scii(a, b) scanf("%d %d", &a, &b)

#define ll long long

#define ff first

#define ss second

#define vi vector<int>

#define ii pair<int, int>

#define vii vector<ii>

#define pii pair<int, ii>

#define maxN 105

#define oo 1000000007

#define mp make_pair

#define pb push_back

#define bug(a) cout << #a << "= " << a << endl;

#define bug2(a, b) cout << #a << "= " << a << "; " << #b << "= " << b << endl

#define pri(a) printf("%d", a)

#define pril(a) printf("%d\n", a)



using namespace std;



int n, A;

int a[maxN];

ll f[maxN][maxN*maxN];



int main() {

//    #ifndef ONLINE_JUDGE

//    freopen("cf.inp", "r", stdin);

//    freopen("cf.out", "w", stdout);

//    #endif



    scii(n, A);

    fto(i, 1, n) sci(a[i]), a[i] -= A;

//    f[0][0] = 1;

//    fto(i, 1, n) {

//        fto(j, 0, A-1) {

//            fto(k, 0, i-1) {

//                bug2(k, (j-a[i]%A+A)%A);

//                bug(f[k][(j-a[i]%A+A)%A]);

//                f[i][j] += f[k][(j-a[i]%A+A)%A];

//            }

//            bug2(i, j);

//            bug(f[i][j]);

//        }

//    }

    int M = 2500;

    f[0][M] = 1;

    fto(i, 1, n) {

        fto(j, -M, M) {

            int k = j-a[i]+M;

            if(k < 0 || k>2*M) continue;

//            bug2(i, j+M);

            f[i][j+M] = f[i-1][j+M]+f[i-1][k];

        }

    }

    cout << f[n][M]-1 << '\n';

    return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
//#include<stdio.h>

//#include<stdlib.h>

//#include<string.h>

#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N=55;

const ll MOD=1e9+7;

int main()

{

    int n;

    int a;

//for(auto &a:b)

//存在n*n种组合方法，求解满足条件的方法，遍历？

    cin>>n>>a;

    ll b[N][N*N]= {0};

    int p;

    ll cnt=0;//计算方法数

    b[0][0]=1;

    for(int i=1; i<=n; i++)

    {

        cin>>p;

        for(int j=i-1; j>=0; j--)

        {

            for(int k=0; k<=N*j; k++)

            {

                b[j+1][p+k]+=b[j][k];//将每一种可能加到一个p+k，使得每一个可能的和的地方数组储存的数字都为1

            }

        }

    }

    for(int i=1; i<=n; i++)

    {

        cnt+=b[i][i*a];//若是i*a处不为0则说明p+k可以加到这个位置

    }

    cout<<cnt<<endl;

    return 0;

}

// Optimized solution to the same problem (faster):
#include<bits/stdc++.h>



#define sci(a) scanf("%d", &a)

#define fto(i, a, b) for (int i = a; i <= b; ++i)

#define fdto(i, a, b) for (int i = a; i >= b; --i)

#define scii(a, b) scanf("%d %d", &a, &b)

#define ll long long

#define ff first

#define ss second

#define vi vector<int>

#define ii pair<int, int>

#define vii vector<ii>

#define pii pair<int, ii>

#define maxN 105

#define oo 1000000007

#define mp make_pair

#define pb push_back

#define bug(a) cout << #a << "= " << a << endl;

#define bug2(a, b) cout << #a << "= " << a << "; " << #b << "= " << b << endl

#define pri(a) printf("%d", a)

#define pril(a) printf("%d\n", a)



using namespace std;



int n, A;

int a[maxN];

ll f[maxN][maxN*maxN];



int main() {

//    #ifndef ONLINE_JUDGE

//    freopen("cf.inp", "r", stdin);

//    freopen("cf.out", "w", stdout);

//    #endif



    scii(n, A);

    fto(i, 1, n) sci(a[i]), a[i] -= A;

//    f[0][0] = 1;

//    fto(i, 1, n) {

//        fto(j, 0, A-1) {

//            fto(k, 0, i-1) {

//                bug2(k, (j-a[i]%A+A)%A);

//                bug(f[k][(j-a[i]%A+A)%A]);

//                f[i][j] += f[k][(j-a[i]%A+A)%A];

//            }

//            bug2(i, j);

//            bug(f[i][j]);

//        }

//    }

    int M = 2500;

    f[0][M] = 1;

    fto(i, 1, n) {

        fto(j, -M, M) {

            int k = j-a[i]+M;

            if(k < 0 || k>2*M) continue;

//            bug2(i, j+M);

            f[i][j+M] = f[i-1][j+M]+f[i-1][k];

        }

    }

    cout << f[n][M]-1 << '\n';

    return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

#define fr(i,x,y) for(int i=x;i<=y;++i)

#define rf(i,x,y) for(int i=x;i>=y;--i)

#define ll long long

using namespace std;

const int N=55,M=2510;

int a[N];

ll dp[2][N][M];



int main(){

	int n,m;scanf("%d%d",&n,&m);

	fr(i,1,n) scanf("%d",&a[i]);

	dp[0][0][0]=1;

	int nw=0;

	fr(i,1,n){

		memset(dp[nw^1],0,sizeof dp[nw^1]);

		fr(j,0,i-1) fr(k,0,2500){

			if(!dp[nw][j][k]) continue;

			dp[nw^1][j][k]+=dp[nw][j][k];

			dp[nw^1][j+1][k+a[i]]+=dp[nw][j][k];

		}

		nw^=1;

	}

	ll ans=0;

	fr(i,1,n) ans+=dp[nw][i][i*m];

	printf("%lld\n",ans);

	return 0;

}

// Optimized solution to the same problem (faster):
#include<bits/stdc++.h>



#define sci(a) scanf("%d", &a)

#define fto(i, a, b) for (int i = a; i <= b; ++i)

#define fdto(i, a, b) for (int i = a; i >= b; --i)

#define scii(a, b) scanf("%d %d", &a, &b)

#define ll long long

#define ff first

#define ss second

#define vi vector<int>

#define ii pair<int, int>

#define vii vector<ii>

#define pii pair<int, ii>

#define maxN 105

#define oo 1000000007

#define mp make_pair

#define pb push_back

#define bug(a) cout << #a << "= " << a << endl;

#define bug2(a, b) cout << #a << "= " << a << "; " << #b << "= " << b << endl

#define pri(a) printf("%d", a)

#define pril(a) printf("%d\n", a)



using namespace std;



int n, A;

int a[maxN];

ll f[maxN][maxN*maxN];



int main() {

//    #ifndef ONLINE_JUDGE

//    freopen("cf.inp", "r", stdin);

//    freopen("cf.out", "w", stdout);

//    #endif



    scii(n, A);

    fto(i, 1, n) sci(a[i]), a[i] -= A;

//    f[0][0] = 1;

//    fto(i, 1, n) {

//        fto(j, 0, A-1) {

//            fto(k, 0, i-1) {

//                bug2(k, (j-a[i]%A+A)%A);

//                bug(f[k][(j-a[i]%A+A)%A]);

//                f[i][j] += f[k][(j-a[i]%A+A)%A];

//            }

//            bug2(i, j);

//            bug(f[i][j]);

//        }

//    }

    int M = 2500;

    f[0][M] = 1;

    fto(i, 1, n) {

        fto(j, -M, M) {

            int k = j-a[i]+M;

            if(k < 0 || k>2*M) continue;

//            bug2(i, j+M);

            f[i][j+M] = f[i-1][j+M]+f[i-1][k];

        }

    }

    cout << f[n][M]-1 << '\n';

    return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <cstdio>

using namespace std;

long long n, x, s, a[55], d[55][55][2505]={1};

int main() {

	int i, j, k;

	cin>>n>>x;

	for(i=1; i<=n; i++) cin>>a[i];

	for(i=1; i<=n; i++) for(j=0; j<=i; j++) {

		for(k=0; k<=i*50; k++) {

			d[i][j][k] = d[i-1][j][k];

			if(j>=1 && k>=a[i]) d[i][j][k] += d[i-1][j-1][k-a[i]];

		}

	}

	for(j=1; j<=n; j++) s += d[n][j][j*x];

	cout<<s;

	return 0;

}

// Optimized solution to the same problem (faster):
#include <cstdio>

long long n, a, x, z, C=2500, d[2][5005];

int main() {

	int i, j;

	scanf("%lld%lld", &n, &a);

	d[0][C] = 1;

	for(i=0; i<n; i++, z^=1) {

		scanf("%lld", &x);

		x -= a;

		for(j=0; j<=5000; j++) d[z^1][j] = 0;

		for(j=0; j<=2*C; j++) {

			if(d[z][j]) {

				d[z^1][j] += d[z][j];

				d[z^1][j+x] += d[z][j];

			}

		}

	}

	printf("%lld", d[z][C]-1);

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <cstdio>

long long d[55][5005];

int main() {

	int i, j, n, a, x, z=0;

	scanf("%d%d", &n, &a);

	d[0][2500] = 1;

	for(i=1; i<=n; i++) {

		scanf("%d", &x);

		x -= a;

		for(j=0; j<=5000; j++) {

			d[i][j] += d[i-1][j];

			d[i][j+x] += d[i-1][j];

		}

	}

	printf("%lld", d[n][2500]-1);

}


// Optimized solution to the same problem (faster):
#include <cstdio>

long long n, a, x, z, C=2500, d[2][5005];

int main() {

	int i, j;

	scanf("%lld%lld", &n, &a);

	d[0][C] = 1;

	for(i=0; i<n; i++, z^=1) {

		scanf("%lld", &x);

		x -= a;

		for(j=0; j<=5000; j++) d[z^1][j] = 0;

		for(j=0; j<=2*C; j++) {

			if(d[z][j]) {

				d[z^1][j] += d[z][j];

				d[z^1][j+x] += d[z][j];

			}

		}

	}

	printf("%lld", d[z][C]-1);

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <cstdio>

long long n, a, x, d[55][5005];

int C=2500;

int main() {

	int i, j;

	scanf("%lld%lld", &n, &a);

	d[0][C] = 1;

	for(i=1; i<=n; i++) {

		scanf("%lld", &x);

		x -= a;

		for(j=0; j<=2*C; j++) {

			d[i][j] += d[i-1][j];

			d[i][j+x] += d[i-1][j];

		}

	}

	printf("%lld", d[n][C]-1);

}

// Optimized solution to the same problem (faster):
#include <cstdio>

long long n, a, x, z, C=2500, d[2][5005];

int main() {

	int i, j;

	scanf("%lld%lld", &n, &a);

	d[0][C] = 1;

	for(i=0; i<n; i++, z^=1) {

		scanf("%lld", &x);

		x -= a;

		for(j=0; j<=5000; j++) d[z^1][j] = 0;

		for(j=0; j<=2*C; j++) {

			if(d[z][j]) {

				d[z^1][j] += d[z][j];

				d[z^1][j+x] += d[z][j];

			}

		}

	}

	printf("%lld", d[z][C]-1);

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <string>

#include <queue>

#include <stack>

#include <vector>

#include <sstream>

#include <algorithm>

#include <deque>

#include <set>

#include <map>

#include <unordered_set>

#include <unordered_map>

#include <list>

#include <cstdio>

#include <iostream>

#include <cmath>

#include <climits>

#include <bitset>

#include <functional>

#include <numeric>

#include <ctime>

#include <cassert>

#include <cstring>

#include <fstream>



using namespace std;





long long dp[51][5001];



int main() {



    int n, a;

    cin >> n >> a;

    vector<int> x(n);

    for (int i = 0; i < n; i++) {

        cin >> x[i];

    }



    sort(x.begin(), x.end());

    for (int i = 0; i < n; i++) {

        x[i] -= a;

    }

    memset(dp, 0, sizeof(dp));

    dp[0][2500] = 1;

    for (int i = 1; i <= n; i++) {

        for (int k = 0; k < 5001; k++) {

            if (k - x[i - 1] >= 0 && k - x[i - 1] < 5001)

                for (int j = 0; j < i; j++)

                    dp[i][k] += dp[j][k - x[i - 1]];

        }

    }

    long long sumx = 0;

    for (int i = 1; i <= n; i++) {

        sumx += dp[i][2500];

    }

    cout << sumx << endl;









    return 0;

}

// Optimized solution to the same problem (faster):
#include <string>

#include <queue>

#include <stack>

#include <vector>

#include <sstream>

#include <algorithm>

#include <deque>

#include <set>

#include <map>

#include <unordered_set>

#include <unordered_map>

#include <list>

#include <cstdio>

#include <iostream>

#include <cmath>

#include <climits>

#include <bitset>

#include <functional>

#include <numeric>

#include <ctime>

#include <cassert>

#include <cstring>

#include <fstream>

#include <iomanip>



using namespace std;



#define FOR(i, a, b) for(int (i)=(a);(i)<(b);(i)++)

#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)

#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)

#define REP(i, n) FOR((i), 0, (n))



using ll = long long;

using pii = pair<int, int>;

using pll = pair<ll, ll>;



template<class T>

void print_container(T &container, string delim=" ") {

    bool first = true;

    for(auto &t: container){

        if(!first){

            cout << delim;

        }

        first = false;

        cout << t;

    }

    cout << endl;

}



int main() {

    int n, a;

    cin >> n >> a;

    vector<int> x(n);

    REP(i, n){

        cin >> x[i];

        x[i] -= a;

    }



    sort(x.begin(), x.end());



    vector<vector<ll>> dp(n+1, vector<ll>(5001, 0));



    dp[0][2500] = 1;

    IFOR(i, 1, n){

        RFOR(j, 5000, 0){

            dp[i][j] = dp[i-1][j] + dp[i-1][j-x[i-1]];

        }

    }



    cout << dp[n][2500] - 1 << endl;



    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include "bits/stdc++.h"

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)

#define REP(i,x,n) for(int i=x;i<n;i++)

#define ALL(v) (v).begin(),(v).end()

#define MP(a,b) make_pair(a,b)

typedef long long LL;

typedef pair<int, int> PI;

typedef pair<LL, LL> PLL;

typedef vector<int> VI;

const LL MOD = 1000000007LL;

LL dp[50][51][2501];

int x[50];

int main() {

	int N, A;

	cin >> N >> A;

	rep(i, N) cin >> x[i];

	dp[0][0][0] = dp[0][1][x[0]] = 1;

	REP(i, 1, N) {

		rep(j, 51) {

			rep(k, 2501) {

				dp[i][j][k] = dp[i - 1][j][k];

				if (j > 0 && k >= x[i]) dp[i][j][k] += dp[i - 1][j - 1][k - x[i]];

			}

		}

	}

	LL ans = 0;

	REP(i, 1, N + 1) {

		ans += dp[N - 1][i][i*A];

	}

	cout << ans << endl;

}

// Optimized solution to the same problem (faster):
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;

const ll MOD = 1e9 + 7;

const ll INF = 1LL << 60;

const double PI = 3.141592653589793238;

const double EPS = 1e-10;

ll dp[51][51][2501];

int x[50];

int main() {

	int N, A;

	cin >> N >> A;

	for (int i = 0; i < N; i++) cin >> x[i];

	dp[0][0][0] = 1;

	for (int i = 0; i < N; i++) {

		for (int j = 0; j <= i; j++) {

			for (int k = 0; k <= 50 * j; k++) {

				dp[i + 1][j][k] += dp[i][j][k];

				dp[i + 1][j + 1][k + x[i]] += dp[i][j][k];

			}

		}

	}

	ll ans = 0;

	for (int i = 1; i <= N; i++) ans += dp[N][i][i*A];

	cout << ans << endl;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef long double ld;

#define REP(i, n) for (int i = 0; i < (n); ++i)

#define REPR(i, n) for (int i = n - 1; i >= 0; --i)

#define FOR(i, m, n) for (int i = m; i < n; ++i)

#define FORR(i, m, n) for (int i = m; i >= n; --i)

#define ALL(v) (v).begin(),(v).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const ll INF=1LL<<60;

const int inf=(1<<30)-1;

const int mod=1e9+7;

int dx[8]={1,0,-1,0,-1,-1,1,1};

int dy[8]={0,1,0,-1,-1,1,-1,1};

int main(){

    cin.tie(0);

    ios::sync_with_stdio(false);

	int n,a;cin >> n >> a;

	vector<int> x(n);

	REP(i,n) cin >> x[i];

	vector<vector<vector<ll>>> dp(n+1,vector<vector<ll>>(n+1,vector<ll>(2501)));

	dp[0][0][0]=1;

	REP(i,n){

		REP(j,n){

			REP(k,2501){

				if(!dp[i][j][k]) continue;

				dp[i+1][j][k]+=dp[i][j][k];

				dp[i+1][j+1][k+x[i]]+=dp[i][j][k];

			}

		}

	}

	ll ans=0;

	FOR(i,1,n+1){

		ans+=dp[n][i][i*a];

	}

	cout << ans << endl;

}

// Optimized solution to the same problem (faster):
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef long double ld;

#define REP(i, n) for (int i = 0; i < (n); ++i)

#define REPR(i, n) for (int i = n - 1; i >= 0; --i)

#define FOR(i, m, n) for (int i = m; i < n; ++i)

#define FORR(i, m, n) for (int i = m; i >= n; --i)

#define ALL(v) (v).begin(),(v).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const ll INF=1LL<<60;

const int inf=(1<<30)-1;

const int mod=1e9+7;

int dx[8]={1,0,-1,0,-1,-1,1,1};

int dy[8]={0,1,0,-1,-1,1,-1,1};

int main(){

    cin.tie(0);

    ios::sync_with_stdio(false);

	int n,a;cin >> n >> a;

	vector<int> x(n);

	REP(i,n) cin >> x[i];

	ll dp[n+1][n+1][2501]={};

	dp[0][0][0]=1;

	REP(i,n){

		REP(j,n){

			REP(k,2501){

				if(!dp[i][j][k]) continue;

				dp[i+1][j][k]+=dp[i][j][k];

				dp[i+1][j+1][k+x[i]]+=dp[i][j][k];

			}

		}

	}

	ll ans=0;

	FOR(i,1,n+1){

		ans+=dp[n][i][i*a];

	}

	cout << ans << endl;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

#define int long long



int dp[51][51][2501];

//i枚目までのカードでj枚選んで合計がkになる組み合わせ



signed main(){

  cin.tie(0);

  ios::sync_with_stdio(false);



  int n,a; cin >> n >> a;

  vector<int> x(n);

  for(int i = 0; i < n; i++){

    cin >> x[i];

  }



  dp[0][0][0] = 1;

  for(int i = 0; i < n; i++){

    for(int j = 0; j < n; j++){

      for(int k = 0; k < 2501; k++){

        //カードを使わない場合

        dp[i+1][j][k] += dp[i][j][k];

        //カードを使う場合

        dp[i+1][j+1][k + x[i]] += dp[i][j][k];

      }

    }

  }



  int ans = 0;

  for(int j = 1; j <= n; j++){

    ans += dp[n][j][j * a];

  }

  cout << ans << endl;



  return 0;

}


// Optimized solution to the same problem (faster):
#include<bits/stdc++.h>

using namespace std;

#define int long long



int dp[51][5001];

//i枚目までのカードで合計がkになる組み合わせ



signed main(){

  cin.tie(0);

  ios::sync_with_stdio(false);



  int n,a; cin >> n >> a;

  vector<int> x(n);

  for(int i = 0; i < n; i++){

    cin >> x[i];

    x[i] -= a;

  }

  //平均がa <==> x[i]-aの合計が0



  int base = n*a/2;

  dp[0][base] = 1;

  for(int i = 0; i < n; i++){

    for(int k = 0; k <= 2*n*a; k++){

      if(0 <= k+x[i] && k+x[i] <= 5000){

        dp[i+1][k+x[i]] += dp[i][k];

      }

      dp[i+1][k] += dp[i][k];

    }

  }

  cout << dp[n][base] - 1 << endl;



  return 0;

}


// Fastest known solution for this problem: