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

#include <algorithm>

#include <string>

#include <vector>

#include <queue>

#include <stack>

#include <map>

#include <set>

#include <cstdio>



using namespace std;



typedef unsigned long long u64;

typedef vector<int> vi;

typedef vector<u64> vy;

typedef vector<vy> vvy;

typedef vector<vvy> vvvy;



vi x;

vvvy dp;

unsigned int N, A;



u64 rec(unsigned int i, unsigned int cur, int num, vvvy &dp, vi &x) {

    if (dp[i][cur][num] < (1ull<<57)) {

        return dp[i][cur][num];

    }





    if (i == N) {

        return dp[i][cur][num] = 0;

    } else if (A*N < cur) {

        return dp[i][cur][num] = 0;

    }



    u64 res=0;

    if (A*(num+1) == cur+x[i]) res++;



    res += rec(i+1, cur, num, dp, x);

    res += rec(i+1, cur+x[i], num+1, dp, x);



    return dp[i][cur][num] = res;

}



int main(void) {

    cin >> N >> A;



    x = vi(N);

    unsigned int i;

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

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

    }



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

    vvvy dp(N+1, vvy(50*50+1, vy(N+1, 1ull<<58)));

    cout << rec(0, 0, 0, dp, x) << endl;



    return 0;

}


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

#include <algorithm>

#include <vector>

#include <cstdio>



using namespace std;



typedef long long i64;

typedef vector<i64> vx;

typedef vector<vx> vvx;



i64 numways_makeave(const vx &cards, i64 ave) {

    int n=cards.size();

    i64 x=ave;

    vx y(n);

    int i;

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

        y[i] = cards[i] - ave;

        if (cards[i] > x)

            x = cards[i];

    }



    vvx dp(2, vx(2*n*x+1));

    int j, t;

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

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

        for (t=0; t<=2*n*x; t++)

            if (t-y[j-1]>=0 && t-y[j-1]<=2*n*x) {

                dp[j&1][t] = dp[j&1^1][t] + dp[j&1^1][t-y[j-1]];

            } else {

                dp[j&1][t] = dp[j&1^1][t];

            }



    return dp[n&1][n*x] - 1LL;

}



int main(void) {

    int n;

    i64 a;

    cin >> n >> a;



    vx x(n);

    int i;

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

        scanf("%lld", &x[i]);

    }



    cout << numways_makeave(x, a) << endl;

    return 0;

}


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

#include <cstring>

#include <algorithm>

using namespace std;

typedef long long LL;

const int maxn=52;

int n,k;

int a[maxn],sum[maxn];

LL dp[3][maxn][maxn*maxn];



int main() {

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

    for (int i=1;i<=n;i++) scanf("%d",&a[i]),sum[i]=sum[i-1]+a[i];

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

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

    int now=0;

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

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

            for (int k=0;k<=sum[i];k++) {

                dp[now][j][k]=dp[now^1][j][k];

                if (k>=a[i]) dp[now][j][k]+=dp[now^1][j-1][k-a[i]];

            }

        now^=1;

    }



    LL ans=0;

    for (int i=1;i<=n;i++) ans+=dp[now^1][i][i*k];

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

    return 0;

}


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

#include<cstdio>

typedef long long ll;

using namespace std;



int a[55];

int sum[55];

ll dp[55][2505];



int main()

{

    int n,A;

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

    for(int i=1;i<=n;i++) {scanf("%d",&a[i]); sum[i]=sum[i-1]+a[i];}

    dp[0][0]=1;

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

        for(int i=k;i>=1;i--){

            for(int j=sum[k];j>=a[k];j--){

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

            }

        }

    }

    ll ans=0;

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

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

    return 0;

}

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

#include<cstring>

long long arr[55];

long long dp[55][2505];

int main()

{

    int N,A;

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

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

    {

        scanf("%lld",&arr[i]);

    }

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

    dp[0][0]=1;

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

    {

        for(int k=i; k>0; k--)

        {

            for(int j=arr[i-1]; j<=2500; j++)

            {

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

            }

        }

    }

    long long sum=0;

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

    {

        sum+=dp[i][A*i];

    }

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

    return 0;

}


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



using namespace std;



const int maxN = 50;

const int maxA = 50;



int N, A;

int x[maxN];

long long f[maxN + 1][maxA * maxN + 1];



int main() {

	ios::sync_with_stdio(false);

	cin.tie(nullptr);

	cout.tie(nullptr);



	cin >> N >> A;

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

		cin >> x[i];



	f[0][0] = 1;

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

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

			for (int k = A * N; k >= x[i]; k--)

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

		}

	}



	long long ans = 0;

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

		ans += f[i][A * i];



	cout << ans << '\n';



	return 0;

}


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

using namespace std;

#define ll long long

#define int ll

#define mn 100005

#define inf 4444444444444444444

#define mod (ll) 1000000007

#define base 31

#define fi first

#define se second

#define pii pair <int, int>

#define pb push_back

#define mp make_pair



//int t, ntest;

int n, k, ans;

int a[55], dp[55][55][2505];



void input(){

	cin>>n>>k;

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

		cin>>a[i];

	}

}



// i so dau tien, chon j so, tong la t

int d (int i, int j, int t){

	if (j>i) return 0;

	if (j<0 || i<0 || t<0) return 0;

	if (t==0){

		if (j==0) return 1;

		return 0;

	}

	if (j==0 && t!=0) return 0;

	if (dp[i][j][t]<inf) return dp[i][j][t];

	return dp[i][j][t]=d(i-1, j, t)+d(i-1, j-1, t-a[i]);

}



void output(){



}



void solve(){

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

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

			for (int t=1; t<=2500; t++){

				dp[i][j][t]=inf;

			}

		}

	}

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

		ans+=d(n, i, k*i);

	}

	cout<<ans;

}



signed main(){

	ios_base::sync_with_stdio(0);

	cin.tie(0);

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

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

//	cin>>t;

//	for (ntest=1; ntest<=t; ntest++){

		input();

		solve();

		output();

//	}

}



//mtrang_149


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

using namespace std;

typedef long long LL;

LL dp[55][55][2505];

int main(){

    int n, a, x;

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

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

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

        scanf("%d", &x);

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

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

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

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

            }

        }

    }   

    LL ans = 0;

    for(int j=1;j<=n;j++) ans += dp[n][j][j*a];

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

}

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

using namespace std;



int main() {

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

	vector<int> a(n);

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

		cin >> a[i];

		a[i] -= A;

	}

	int now = 0;

	const int M = 25*102;

	long long dp[2][M*2] = {0};

	dp[0][M] = 1;

	int lsum = 0, rsum = 0;

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

		now ^= 1;

		memcpy(dp[now], dp[!now], sizeof dp[now]);

		for (int j = lsum; j <= rsum; j++) {

			if (dp[!now][j + M]) {

				dp[now][j + a[i] + M] += dp[!now][j + M];

			}

		}

		if (a[i] >= 0) {

			rsum += a[i];

		} else {

			lsum += a[i];

		}

	}

	cout << dp[now][M] - 1 << endl;

	return 0;

}

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

using namespace std;

typedef long long LL;

LL dp[55][55][2505];

int main(){

    int n, a, x;

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

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

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

        scanf("%d", &x);

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

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

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

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

            }

        }

    }   

    LL ans = 0;

    for(int j=1;j<=n;j++) ans += dp[n][j][j*a];

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

}

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

const int MAXN = 51;

const int ZERO = 2551;

const int MAXM = ZERO*2;

typedef long long LL;

LL F[MAXN][MAXM];

int C[MAXN];

int main()

{

	int N, A, i, j, x;

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

	F[0][ZERO] = 1;

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

	{

		scanf("%d", &x);

		x -= A;

		for(j=MAXN; j+MAXN<MAXM; ++j)

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

	}

	printf("%lld\n", F[N][ZERO]-1);

}

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

const int MAXN = 51;

const int ZERO = 2551;

const int MAXM = ZERO*2;

typedef long long LL;

LL F[2][MAXM];

int main()

{

	int N, A, i, j, x;

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

	F[0][ZERO] = 1;

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

	{

		scanf("%d", &x);

		x -= A;

		for(j=MAXN; j+MAXN<MAXM; ++j)

			F[i&1][j] = F[(i-1)&1][j] + F[(i-1)&1][j-x];

	}

	printf("%lld\n", F[N&1][ZERO]-1);

}

// Fastest known solution for this problem:
// Original C++ solution (slower):


#include "bits/stdc++.h"

#include <unordered_set>

using namespace std;



#define DEBUG(x) cout<<#x<<": "<<x<<endl;

#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl



typedef long long ll;

#define vi vector<int>

#define vl vector<ll>

#define vii vector< vector<int> >

#define vll vector< vector<ll> >

#define vs vector<string>

#define pii pair<int,int>

#define pis pair<int,string>

#define psi pair<string,int>

const int inf = 1000000001;

const ll INF = 1e16;

#define MOD 1000000007

#define mod 1000000009

#define pi 3.14159265358979323846

#define Sp(p) cout<<setprecision(15)<<fixed<<p<<endl;

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

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



int main() {

	int n, a, i, j, k;

	cin >> n >> a;

	vi x(n);

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

		cin >> x[i];

	}

	vector< vll > dp(n + 1, vll(n + 1, vl(2501, 0)));

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

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

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

			for (k = 0; k <= 2500; k++) {

				if (dp[i][j][k] != 0) {

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

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

				}

			}

		}

	}

	ll sum = 0;

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

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

	}

	cout << sum << endl;

}

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

#include <unordered_set>

using namespace std;



#define DEBUG(x) cout<<#x<<": "<<x<<endl;

#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl



typedef long long ll;

#define vi vector<int>

#define vl vector<ll>

#define vii vector< vector<int> >

#define vll vector< vector<ll> >

#define vs vector<string>

#define pii pair<int,int>

#define pis pair<int,string>

#define psi pair<string,int>

const int inf = 1000000001;

const ll INF = 1e16;

#define MOD 1000000007

#define mod 1000000009

#define pi 3.14159265358979323846

#define Sp(p) cout<<setprecision(15)<<fixed<<p<<endl;

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

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



/*

int main() {

	int n, a, i, j, k;

	cin >> n >> a;

	vi x(n);

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

		cin >> x[i];

	}

	vector< vll > dp(n + 1, vll(n + 1, vl(2501, 0)));

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

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

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

			for (k = 0; k <= 2500; k++) {

				if (dp[i][j][k] != 0) {

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

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

				}

			}

		}

	}

	ll sum = 0;

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

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

	}

	cout << sum << endl;

}

*/



int main() {

	int n, a, i, j, k;

	cin >> n >> a;

	vi x(n);

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

		cin >> x[i];

		x[i] -= a;

	}

	vll dp(n + 1,vl(5010));

	dp[0][2500] = 1;

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

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

			if (dp[i][j] != 0) {

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

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

			}

		}

	}

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

}

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

using namespace std;



typedef long long ll;



ll dp[51][2501];



int main(){

	int n, A;

	cin >> n >> A;

	vector <int> a(n);

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

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

	}

	dp[0][0] = 1;

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

		int x = a[i];

		for (int k = 50; k >= 0; k--){

			for (int y = 0; y <= 2500; y++) {

				if (!dp[k][y]) continue;

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

			}

		}

	}

	ll ans = 0;

	for (int k = 1; k <= 50; k++){

		for (int y = 0; y <= 2500; y++){

			if (k * A == y) ans += dp[k][y];

		}

	}

	cout << ans << endl;

}


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

using namespace std;



int x[60];

int sum[60];

long long f[60][2510];



int main(){

	int n, A;

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

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

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

		sum[i] = x[i];

		if (i) sum[i] += sum[i - 1];

	}

	f[0][0] = 1;

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

		for (int j = n; j >= 1; j--){

			for (int k = sum[i]; k >= x[i]; k--){

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

			}

		}

	}

	long long ans = 0;

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

		ans += f[i][i * A];

	}

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

	return 0;

}


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

#include <algorithm>

#include <cstdio>

#include <cstdlib>

#include <sstream>

#include <cstring>

#include <string>

#include <vector>

#include <set>

#include <map>

#include <queue>

#include <numeric>

#include <functional>

#include <cmath>

#include <array>



#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)

#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)

#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)

#define all(c) (c).begin(),(c).end()

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



using namespace std;

typedef long long ll; typedef vector<int> VI;

typedef pair<int,int> pii;

const int mod = (int)1e9+7;



ll cp[2520][52], nx[2520][52];



int main()

{

	

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

	int n, a;

	cin >>n >>a;

	VI x(n);

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

	

	memset(cp, 0, sizeof cp);

	cp[0][0]=1;

	

	rep(i, n){

		memset(nx, 0, sizeof nx);

		rep(j, a*n) rep(k,n) {

			nx[j][k] += cp[j][k];

			if( j+x[i] <= a*n ) nx[j+x[i]][k+1] += cp[j][k];

		}

		swap(cp, nx);

	}

	

	ll ans =0;

	rep(i, a*n+1) rep2(j,1,n+1){

		if(i==j*a){

			ans += cp[i][j];

			//printf("%d:%d:%lld  ",i,j,cp[i][j]);

		}

	}

	cout << ans <<endl;

	

	return 0;

}


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

#include <algorithm>

#include <cstdio>

#include <cstdlib>

#include <sstream>

#include <cstring>

#include <string>

#include <vector>

#include <set>

#include <map>

#include <queue>

#include <numeric>

#include <functional>

#include <cmath>

#include <array>

 

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)

#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)

#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)

#define all(c) (c).begin(),(c).end()

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

 

using namespace std;

typedef long long ll; typedef vector<int> VI;

typedef pair<int,int> pii;

const int mod = (int)1e9+7;





int main()

{

	

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

	int n, a;

	cin >>n >>a;

	VI x(n);

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

	int smp=0, smm=0;

	rep(i,n){ if(a-x[i]<0) smm += a-x[i]; else smp += a-x[i];}

	int KJ =  max(abs(smp), abs(smm)) + 100;

	vector<ll> cp( KJ*2, 0);

	cp[KJ] = 1;

	auto np = cp;

	rep(i, n){

		rep2(j, KJ + smm - 2,  KJ + smp + 2) if(cp[j]>0){

			np[j + a -x[i]] += cp[j];

		}

		cp = np;

	}

	

	cout << cp[KJ] - 1 <<endl;

	return 0;

}

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

#include <algorithm>

#include <cstdio>

#include <cstdlib>

#include <sstream>

#include <cstring>

#include <string>

#include <vector>

#include <set>

#include <map>

#include <queue>

#include <numeric>

#include <functional>

#include <cmath>

#include <array>

 

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)

#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)

#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)

#define all(c) (c).begin(),(c).end()

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

 

using namespace std;

typedef long long ll; typedef vector<int> VI;

typedef pair<int,int> pii;

const int mod = (int)1e9+7;



const int KJ = 3000;



int main()

{

	

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

	int n, a;

	cin >>n >>a;

	VI x(n);

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

	

	vector<ll> cp( KJ*2, 0);

	cp[KJ] = 1;

	auto np = cp;

	rep(i, n){

		rep2(j, KJ-a*n,  KJ +a*n+2) if(cp[j]>0){

			np[j + a -x[i]] += cp[j];

		}

		cp = np;

	}

	

	cout << cp[KJ] - 1 <<endl;

	

	return 0;

}

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

#include <algorithm>

#include <cstdio>

#include <cstdlib>

#include <sstream>

#include <cstring>

#include <string>

#include <vector>

#include <set>

#include <map>

#include <queue>

#include <numeric>

#include <functional>

#include <cmath>

#include <array>

 

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)

#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)

#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)

#define all(c) (c).begin(),(c).end()

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

 

using namespace std;

typedef long long ll; typedef vector<int> VI;

typedef pair<int,int> pii;

const int mod = (int)1e9+7;





int main()

{

	

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

	int n, a;

	cin >>n >>a;

	VI x(n);

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

	int smp=0, smm=0;

	rep(i,n){ if(a-x[i]<0) smm += a-x[i]; else smp += a-x[i];}

	int KJ =  max(abs(smp), abs(smm)) + 100;

	vector<ll> cp( KJ*2, 0);

	cp[KJ] = 1;

	auto np = cp;

	rep(i, n){

		rep2(j, KJ + smm - 2,  KJ + smp + 2) if(cp[j]>0){

			np[j + a -x[i]] += cp[j];

		}

		cp = np;

	}

	

	cout << cp[KJ] - 1 <<endl;

	return 0;

}

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



using namespace std;



#ifdef LOCAL

#define eprintf(...) fprintf(stderr, __VA_ARGS__)

#else

#define eprintf(...) 42

#endif



const int N = 55;



int a[N];

long long f[N][N][N * N];



int main() {

#ifdef LOCAL

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

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

#endif

  int n, A;

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

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

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

  }

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

  f[0][1][a[0]] = 1;

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

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

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

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

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

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

        }

      }

    }

  }

  long long ans = 0;

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

    ans += f[n - 1][i][A * i];

  }

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

  return 0;

}

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

#define int long long

using namespace std;

int t,n;

int a[51];

int f[51][2501];

//int f[101][101];

int32_t main()

{

    cin>>n>>t;

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

        cin>>a[i];

    int res=0;

    int sum=0;

    f[0][0]=1;

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

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

            {

                //cerr<<j<<endl;

                for(int k=2500;k>=a[i];k--)

                {

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

                }

            }

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

    {

        res+=f[i][t*i];

    }

    cout<<res;

}


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

#include<stdio.h>

#include<string.h>

#include<algorithm>

using namespace std;

typedef long long LL;

const int N=57;

LL d[N][N*N],lazy[N][N*N],n,a,c;

int main(){

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

    memset(d,0,sizeof(d));

    memset(lazy,0,sizeof(lazy));

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

        scanf("%lld",&c);

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

        for(int k=1;k<N*N;k++)

        if(d[j][k]){

            lazy[j+1][k+c]+=d[j][k];

        }

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

        for(int k=1;k<N*N;k++)

        if(lazy[j][k]){

            d[j][k]+=lazy[j][k];

            lazy[j][k]=0;

        }

        d[1][c]++;

    }

    LL ans=0;

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

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

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

    return 0;

}


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

using namespace std;

typedef long long LL;

LL dp[55][5005];

int main(){

    int n, a, x;

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

    dp[0][2500] = 1;

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

        scanf("%d", &x);

        for(int j=0;j<=5000;j++) dp[i][j+x-a] += dp[i-1][j], dp[i][j] += dp[i-1][j];

    }

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

}

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

using namespace std;



using VS = vector<string>;    using LL = long long;

using VI = vector<int>;       using VVI = vector<VI>;

using PII = pair<int, int>;   using PLL = pair<LL, LL>;

using VL = vector<LL>;        using VVL = vector<VL>;



#define ALL(a)  begin((a)),end((a))

#define RALL(a) (a).rbegin(), (a).rend()

#define PB push_back

#define EB emplace_back

#define MP make_pair

#define SZ(a) int((a).size())

#define SORT(c) sort(ALL((c)))

#define RSORT(c) sort(RALL((c)))

#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)

#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)

#define debug(x) cerr << #x << ": " << x << endl

const int INF = 1e9;                          const LL LINF = 1e16;

const LL MOD = 1000000007;                    const double PI = acos(-1.0);

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



/* -----  2018/02/14  Problem: 060_arc_a / Link: https://arc060.contest.atcoder.jp/tasks/arc060_a?lang=en  ----- */

/* ------問題------







-----問題ここまで----- */

/* -----解説等-----







----解説ここまで---- */



LL N, A;



LL ans = 0LL;



int main() {

	cin.tie(0);

	ios_base::sync_with_stdio(false);



	cin >> N >> A;

	VI a(N);

	FOR(i, 0, N) {

		cin >> a[i];

	}

	vector<VVL> dp(N + 1, VVL(N + 1, VL(2501, 0)));

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

	FOR(i, 0, N) {

		FOR(k, 0, N) {

			FOR(val, 0, 2501) {

				if(val+a[i]<=2500)dp[i + 1][k + 1][val + a[i]] += dp[i][k][val];

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

			}

		}

	}

	FOR(i, 1, N+1) {

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

	}



	cout << ans << "\n";



	return 0;

}


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

#include<stdlib.h>

#include<string.h>

typedef long long ll;

ll dp[55][2600];

int v[55];

int main(void)

{

	int N, A;

	ll sum = 0;

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

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

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

	dp[0][0] = 1;

	for (int k = 1; k <= N; k++)

	{

		sum += v[k];

		for (int i = k; i >=1; i--)

			for (int j = sum; j >= v[k]; j--)

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

	}

	ll ans = 0;

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

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

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

	return 0;

}

// Fastest known solution for this problem: