CodeEff/ECCO huggingface dataset:
# Original solution
iN,iA =[int(x) for x in input().split()]
#aX = [int(x) - iA for x in input().split()]
aX = [int(x) for x in input().split()]

#解法1

iMX = max(aX + [iA])
dp = [[[0]*(iN*iMX + 1) for _ in range(iN+1)] for _ in range(iN + 1)]

dp[0][0][0] = 1
for j in range(1,iN+1):
#   for k in range(0,iN+1):
    for k in range(0,j+1):
#       for s in range(0,iN*iMX + 1):
        for s in range(0,j*iMX + 1):
            if  s < aX[j-1]:
                dp[j][k][s] = dp[j-1][k][s]
            elif k >= 1 and  s >= aX[j-1]:
                dp[j][k][s] = dp[j-1][k][s]+dp[j-1][k-1][s- aX[j-1]]
            else:
                dp[j][k][s] = 0
iRet = 0
for k in range(1,iN+1):
    iRet += dp[iN][k][k*iA]
print(iRet)


# Optimized solution
#分割してみた。これで通るかな？
iN,iA =[int(x) for x in input().split()]
aX = [int(x) - iA for x in input().split()]
aPlus = [x for x in aX if 0 < x ]
aMinus = [-1 * x for x in aX if x < 0  ]
iLenPlus = len(aPlus)
iLenMinus = len(aMinus)
iLen0 = iN - iLenPlus - iLenMinus

def fnCr(iN,iR):
    if iN - iR < iR :
        iR = iN - iR
    if iN == 0 :
        return 0
    elif iR == 0:
        return 1
    elif iR == 1:
        return iN
    return iN / iR * fnCr(iN-1,iR-1)

aFr = [1]*(iN+1)
for i in range(1,iN+1):
    aFr[i] = aFr[i-1] * i


iCZero = 2**iLen0 - 1 #sum(k=1..N){nCk} = 2^n -1

iRet = 0
iRet += iCZero
iCZero += 1 #0の場合を追加

iSumPlus = sum(aPlus)
iSumMinus = sum(aMinus)
iUlim = min(iSumPlus , iSumMinus)
iOlim = max(iSumPlus , iSumMinus)
if 0 < iUlim:
    dp1 = [[0]*(iOlim +1) for _ in range(iLenPlus)]
    dp1[0][0] = 1
    dp1[0][aPlus[0]]=1
    for j in range(1,iLenPlus):
        for k in range(iUlim + 1):
            if k < aPlus[j] :
                dp1[j][k] = dp1[j-1][k]
            else:
                dp1[j][k] = dp1[j-1][k] + dp1[j-1][k-aPlus[j]]

    dp2 = [[0]*(iOlim +1) for _ in range(iLenMinus)]
    dp2[0][0] = 1
    dp2[0][aMinus[0]]=1
    for j in range(1,iLenMinus):
        for k in range(iUlim + 1):
            if k < aMinus[j] :
                dp2[j][k] = dp2[j-1][k]
            else:
                dp2[j][k] = dp2[j-1][k] + dp2[j-1][k-aMinus[j]]
    for i in range(1,iUlim+1):
        iRet += iCZero * dp1[-1][i] * dp2[-1][i]

print(iRet)
# Original solution

#人のすなるCounterなるものを我も書いてみんとてするなり
from collections import Counter

#方針 マイナスとプラスでDPを分割
iN,iA =[int(x) for x in input().split()]
aX = [int(x) - iA for x in input().split()]
aPlus = [x for x in aX if 0 < x ]
aMinus = [-1 * x for x in aX if x < 0  ]
iLenPlus = len(aPlus)
iLenMinus = len(aMinus)
iLen0 = iN - iLenPlus - iLenMinus
#0の場合はnCkの累積和なので別に計算する
#知ってたわけではなく解析しててみつけた
iCZero = 2**iLen0 - 1 #sum(k=1..N){nCk} = 2^n -1

iRet = 0
iRet += iCZero
iCZero += 1 #0の場合を追加

iUlim = min(sum(aPlus) , sum(aMinus))
if 0 < iUlim:
    dp1 = Counter([0,aPlus[0]])
    for i in range(1,iLenPlus):
        iThisX = aPlus[i]
        tmp = {}
        for k, v in list(dp1.items()):
            tmp[iThisX + k] = v
        dp1 += tmp
    dp2 = Counter([0,aMinus[0]])
    for i in range(1,iLenMinus):
        iThisX = aMinus[i]
        tmp = {}
        for k, v in list(dp2.items()):
            tmp[iThisX + k] = v
        dp2 += tmp
    for i in range(1,iUlim+1):
        iRet += iCZero * dp1[i] * dp2[i]
print(iRet)


# Optimized solution
def 解():
    iN,iA =[int(x) for x in input().split()]
    aX = [int(x) - iA for x in input().split()]
    aPlus = [x for x in aX if 0 < x ]
    aMinus = [-1 * x for x in aX if x < 0  ]
    iLenPlus = len(aPlus)
    iLenMinus = len(aMinus)
    iLen0 = iN - iLenPlus - iLenMinus

    iCZero = 2**iLen0 - 1 #sum(k=1..N){nCk} = 2^n -1

    iRet = 0
    iRet += iCZero
    iCZero += 1 #0の場合を追加

    iSumPlus = sum(aPlus)
    iSumMinus = sum(aMinus)
    iUlim = min(iSumPlus , iSumMinus)
    iOlim = max(iSumPlus , iSumMinus)
    if 0 < iUlim:
        dp1 = [[0]*(iOlim +1) for _ in range(iLenPlus)]
        dp1[0][0] = 1
        dp1[0][aPlus[0]]=1
        for j in range(1,iLenPlus):
            for k in range(iUlim + 1):
                if k < aPlus[j] :
                    dp1[j][k] = dp1[j-1][k]
                else:
                    dp1[j][k] = dp1[j-1][k] + dp1[j-1][k-aPlus[j]]

        dp2 = [[0]*(iOlim +1) for _ in range(iLenMinus)]
        dp2[0][0] = 1
        dp2[0][aMinus[0]]=1
        for j in range(1,iLenMinus):
            for k in range(iUlim + 1):
                if k < aMinus[j] :
                    dp2[j][k] = dp2[j-1][k]
                else:
                    dp2[j][k] = dp2[j-1][k] + dp2[j-1][k-aMinus[j]]
        for i in range(1,iUlim+1):
            iRet += iCZero * dp1[-1][i] * dp2[-1][i]

    print(iRet)
解()
# Original solution
def 解():
    iN,iA =[int(x) for x in input().split()]
    aX = [int(x) - iA for x in input().split()]
    aPlus = [x for x in aX if 0 < x ]
    aMinus = [-1 * x for x in aX if x < 0  ]
    iLenPlus = len(aPlus)
    iLenMinus = len(aMinus)
    iLen0 = iN - iLenPlus - iLenMinus

    iCZero = 2**iLen0 - 1 #sum(k=1..N){nCk} = 2^n -1

    iRet = 0
    iRet += iCZero
    iCZero += 1 #0の場合を追加

    iSumPlus = sum(aPlus)
    iSumMinus = sum(aMinus)
    iUlim = min(iSumPlus , iSumMinus)
    iOlim = max(iSumPlus , iSumMinus)
    if 0 < iUlim:
        dp1 = [[0]*(iOlim +1) for _ in range(iLenPlus)]
        dp1[0][0] = 1
        dp1[0][aPlus[0]]=1
        for j in range(1,iLenPlus):
            for k in range(iUlim + 1):
                if k < aPlus[j] :
                    dp1[j][k] = dp1[j-1][k]
                else:
                    dp1[j][k] = dp1[j-1][k] + dp1[j-1][k-aPlus[j]]

        dp2 = [[0]*(iOlim +1) for _ in range(iLenMinus)]
        dp2[0][0] = 1
        dp2[0][aMinus[0]]=1
        for j in range(1,iLenMinus):
            for k in range(iUlim + 1):
                if k < aMinus[j] :
                    dp2[j][k] = dp2[j-1][k]
                else:
                    dp2[j][k] = dp2[j-1][k] + dp2[j-1][k-aMinus[j]]
        for i in range(1,iUlim+1):
            iRet += iCZero * dp1[-1][i] * dp2[-1][i]

    print(iRet)
解()


# Optimized solution
#正負で分割
#dpの作り方はARCの方の人のロジックを参考にした。
#こんなんでええんや...
def 解():
    iN,iA =[int(x) for x in input().split()]
    aX = [int(x) - iA for x in input().split()]
    aPlus = [x for x in aX if 0 < x ]
    aMinus = [-1 * x for x in aX if x < 0  ]
    iLenPlus = len(aPlus)
    iLenMinus = len(aMinus)
    iLen0 = iN - iLenPlus - iLenMinus

    iCZero = 2**iLen0 - 1 #sum(k=1..N){nCk} = 2^n -1

    iRet = 0
    iRet += iCZero
    iCZero += 1 #0の場合を追加

    iUlim = min(sum(aPlus) , sum(aMinus))
    if 0 < iUlim:
        dp1 = {0:1}
        for iX in aPlus:
            for k,v in list(dp1.copy().items()):
                dp1[k+iX] = dp1.get(k+iX,0)+v
        dp2 = {0:1}
        for iX in aMinus:
            for k,v in list(dp2.copy().items()):
                dp2[k+iX] = dp2.get(k+iX,0)+v
        for i in range(1,iUlim+1):
            if i in dp1 and i in dp2:
                iRet += iCZero * dp1[i] * dp2[i]
    print(iRet)
解()
# Original solution
# C - 高橋君とカード / Tak and Cards

#import numpy as np
import math

N, A = list(map(int, input().split()))
#x = np.array(list(map(int, input().split())))
x = list(map(int, input().split()))

# 数列aと整数Aを与えると、aからいくつか取って合計Aにするパターンが何通りあるかを返す関数
def partial_sum(a,A):
    n = len(a)
    dp = [[0]*(A+2) for _ in range(n+2)] # dp[i+1][j] a[i]までの数からいくつか選んで総和をjにするパターンの数
    dp[0][0] = 1
    
    for i in range(n):
        for j in range(A+1):
            if j >= a[i]:
                dp[i+1][j] = dp[i][j-a[i]] + dp[i][j]
            else:
                dp[i+1][j] = dp[i][j]
                
    return dp[n][A]

#x_diff = x - np.array(A) # ここから合計0になるように取る。負の数列についてpartial_sumが動かないことに注意
x_diff = [a - A for a in x]
x_diff_negative = [-a for a in x_diff if a < 0]
x_diff_positive = [a for a in x_diff if a > 0]

ans = 0
for i in range(1, sum(x)):
    ans += partial_sum(x_diff_negative,i) * partial_sum(x_diff_positive,i) 

# 0の選び方
n_pattern_0 = 0
#n_0 = np.count_nonzero(x_diff == 0)
n_0 = x_diff.count(0)
if n_0 > 0:
    for i in range(1, n_0+1):
        n_pattern_0 += math.factorial(n_0) // (math.factorial(n_0-i) * math.factorial(i))

# ここまで数えた全てのパターンそれぞれについて、x_diff中の0をいくつか含めた別パターンがある
# 0単体で選ぶ方法もある
ans += (ans+1) * n_pattern_0
    
print(ans)

# Optimized solution
# C - 高橋君とカード / Tak and Cards

#import numpy as np
import math

N, A = list(map(int, input().split()))
x = list(map(int, input().split()))

# 数列aと整数Aを与えると、aからいくつか取って合計Aにするパターンが何通りあるかを返す関数
def partial_sum(a,A):
    n = len(a)
    dp = [[0]*(A+2) for _ in range(n+2)] # dp[i+1][j] a[i]までの数からいくつか選んで総和をjにするパターンの数
    dp[0][0] = 1
    
    for i in range(n):
        for j in range(A+1):
            if j >= a[i]:
                dp[i+1][j] = dp[i][j-a[i]] + dp[i][j]
            else:
                dp[i+1][j] = dp[i][j]
                
    return dp[n][A]

x_diff = [a - A for a in x] # ここから合計0になるように取る。負の数列についてpartial_sumが動かないことに注意
x_diff_negative = [-a for a in x_diff if a < 0]
x_diff_positive = [a for a in x_diff if a > 0]

ans = 0
for i in range(1, min(sum(x_diff_negative), sum(x_diff_positive)) + 1):
    ans += partial_sum(x_diff_negative,i) * partial_sum(x_diff_positive,i) 

# 0の選び方
n_pattern_0 = 0
n_0 = x_diff.count(0)
if n_0 > 0:
    for i in range(1, n_0+1):
        n_pattern_0 += math.factorial(n_0) // (math.factorial(n_0-i) * math.factorial(i))

# ここまで数えた全てのパターンそれぞれについて、x_diff中の0をいくつか含めた別パターンがある
# 0単体で選ぶ方法もある
ans += (ans+1) * n_pattern_0
    
print(ans)
# Original solution
import sys
input = sys.stdin.readline


def main():
    n, a = list(map(int, input().split()))
    x = tuple(map(int, input().split()))

    sm_mx = sum(x)

    dp = [[[0] * (sm_mx + 1) for i in range(n + 1)] for j in range(n + 1)]

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

    for i, e in enumerate(x, 1):
        for j in range(n + 1):
            for sm in range(sm_mx + 1):
                if sm < e:
                    dp[i][j][sm] = dp[i-1][j][sm]
                elif j >= 1 and sm >= e:
                    dp[i][j][sm] = dp[i-1][j][sm] + dp[i-1][j-1][sm-e]

    ans = 0
    for i in range(1, n + 1):
        if i > sm_mx / a:
            break
        ans += dp[n][i][i*a]

    print(ans)


if __name__ == "__main__":
    main()


# Optimized solution
import sys
input = sys.stdin.readline


def main():
    n, a = list(map(int, input().split()))
    x = tuple(map(int, input().split()))

    sm_mx = sum(x)

    dp = [[[0] * (sm_mx + 1) for _ in range(n + 1)] for _ in range(n + 1)]

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

    for i, e in enumerate(x, 1):
        for j in range(n + 1):
            for sm in range(sum(x[:i]) + 1):
                if sm < e:
                    dp[i][j][sm] = dp[i-1][j][sm]
                elif j >= 1 and sm >= e:
                    dp[i][j][sm] = dp[i-1][j][sm] + dp[i-1][j-1][sm-e]

    ans = 0
    for i in range(1, n + 1):
        if i > sm_mx / a:
            break
        ans += dp[n][i][i*a]

    print(ans)


if __name__ == "__main__":
    main()
# Original solution
import sys
input = sys.stdin.readline


def main():
    n, a = list(map(int, input().split()))
    x = tuple(map(int, input().split()))

    sm_mx = sum(x)

    dp = [[[0] * (sm_mx + 1) for _ in range(n + 1)] for _ in range(n + 1)]

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

    for i, e in enumerate(x, 1):
        for j in range(n + 1):
            for sm in range(sum(x[:i]) + 1):
                if sm < e:
                    dp[i][j][sm] = dp[i-1][j][sm]
                elif j >= 1 and sm >= e:
                    dp[i][j][sm] = dp[i-1][j][sm] + dp[i-1][j-1][sm-e]

    ans = 0
    for i in range(1, n + 1):
        if i > sm_mx / a:
            break
        ans += dp[n][i][i*a]

    print(ans)


if __name__ == "__main__":
    main()


# Optimized solution
def main():
    n, a = list(map(int, input().split()))
    x = list(map(int, input().split()))

    mx = max(x + [a])

    for i in range(n):
        x[i] -= a

    sm = 2 * n * mx

    dp = [[0] * (sm + 1) for _ in range(n + 1)]

    dp[0][n*mx] = 1

    for i, e in enumerate(x, 1):
        for j in range(sm + 1):
            if 0 <= j - e <= sm:
                dp[i][j] = dp[i-1][j] + dp[i-1][j-e]
            else:
                dp[i][j] = dp[i-1][j]

    ans = dp[n][n*mx] - 1

    print(ans)


if __name__ == "__main__":
    main()
# Original solution
n,a = list(map(int,input().split()))
x = list(map(int,input().split()))
x = list([y-a for y in x])

ans = -1

for i in range(2**n):
    tmp = 0
    for j in range(n):
        if (i >> j) & 1:
            tmp += x[j]
    if tmp == 0:
        ans += 1

print(ans)

# Optimized solution
n,a = list(map(int,input().split()))
x = sorted(list([int(y)-a for y in input().split()]))

sx = max(abs(x[0]),abs(x[-1]))*n

dp = [[0 for _ in range(2*sx+2)] for _ in range(n+1)]
dp[0][0] = 1

for j in range(n):
    for t in range(-sx-1,sx+1):
        if -sx <= t-x[j] and t-x[j] <= sx: 
            dp[j+1][t] = dp[j][t] + dp[j][t-x[j]]
        else:
            dp[j+1][t] = dp[j][t]

print((dp[n][0]-1))
# Original solution
N,A = (int(T) for T in input().split())
X = [int(T) for T in input().split()]
DP = [[[0]*(N+1) for TS in range(0,50*N+1)] for TI in range(0,N+1)]
DP[0][0][0] = 1
for TI in range(0,N):
    for TS in range(0,50*N+1):
        for TK in range(0,N+1):
            if DP[TI][TS][TK]!=0:
                DP[TI+1][TS][TK] += DP[TI][TS][TK]
                DP[TI+1][TS+X[TI]][TK+1] += DP[TI][TS][TK]
print((sum(DP[N][A*TA][TA] for TA in range(1,N+1))))

# Optimized solution
N,A = (int(T) for T in input().split())
X = [int(T)-A for T in input().split()]
DP = [[0]*(2*(50*N)+1) for TI in range(0,N+1)]
DP[0][50*N] = 1
for TI in range(0,N):
    for TS in range(0,2*50*N+1):
        if DP[TI][TS]!=0:
            DP[TI+1][TS] += DP[TI][TS]
            DP[TI+1][TS+X[TI]] += DP[TI][TS]
print((DP[N][50*N]-1))
# Original solution
import sys
input=sys.stdin.readline
n,a=list(map(int,input().split()))
x=[0]+list(map(int,input().split()))
su=sum(x)
dp=[[[0 for k in range(su+1)] for j in range(51)] for i in range(51)]
dp[0][0][0]=1
for i in range(1,n+1):
    for j in range(i+1):
        for k in range(su+1):
            if k<x[i]:
                dp[i][j][k]=dp[i-1][j][k]
            if k>=x[i] and j>=1:
                dp[i][j][k]=dp[i-1][j][k]+dp[i-1][j-1][k-x[i]]
ans=0
for t in range(1,n+1):
    if a*t<=su:
        ans+=dp[n][t][a*t]
    else:
        break
print(ans)


# Optimized solution
import sys
input=sys.stdin.readline
n,a=list(map(int,input().split()))
x=[0]+list(map(int,input().split()))
su=sum(x)
maxi=max(x)
dp=[[[0 for k in range(maxi*n+1)] for j in range(51)] for i in range(51)]
dp[0][0][0]=1
for i in range(1,n+1):
    for j in range(i+1):
        for k in range(maxi*j+1):
            if k<x[i]:
                dp[i][j][k]=dp[i-1][j][k]
            if k>=x[i] and j>=1:
                dp[i][j][k]=dp[i-1][j][k]+dp[i-1][j-1][k-x[i]]
ans=0
for t in range(1,n+1):
    if a*t<=su:
        ans+=dp[n][t][a*t]
    else:
        break
print(ans)
# Original solution
import sys
input=sys.stdin.readline
n,a=list(map(int,input().split()))
x=[0]+list(map(int,input().split()))
su=sum(x)
maxi=max(x)
dp=[[[0 for k in range(maxi*n+1)] for j in range(51)] for i in range(51)]
dp[0][0][0]=1
for i in range(1,n+1):
    for j in range(i+1):
        for k in range(maxi*j+1):
            if k<x[i]:
                dp[i][j][k]=dp[i-1][j][k]
            if k>=x[i] and j>=1:
                dp[i][j][k]=dp[i-1][j][k]+dp[i-1][j-1][k-x[i]]
ans=0
for t in range(1,n+1):
    if a*t<=su:
        ans+=dp[n][t][a*t]
    else:
        break
print(ans)


# Optimized solution
from collections import Counter
n,a=list(map(int,input().split()))
X=sorted(list([int(x)-a for x in input().split()]))
ans=Counter([0])
for x in X:
    tmp=Counter()
    for i,j in list(ans.items()):
        tmp[i+x]+=j
    ans+=tmp
print((ans[0]-1))
# Original solution
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, A, *X = list(map(int, read().split()))

    M = sum(X)
    dp = [[0] * (M + 1) for j in range(N + 1)]
    dp[0][0] = 1

    for i in range(N):
        for j in range(N, 0, -1):
            for k in range(X[i], M + 1):
                dp[j][k] += dp[j - 1][k - X[i]]

    ans = 0
    for j in range(1, N + 1):
        if A * j > M:
            break
        ans += dp[j][A * j]

    print(ans)
    return


if __name__ == '__main__':
    main()


# Optimized solution
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, A, *X = list(map(int, read().split()))

    M = sum(X)
    dp = [[0] * (M + 1) for j in range(N + 1)]
    dp[0][0] = 1

    for i in range(N):
        for j in range(N, 0, -1):
            for k in range(X[i], M + 1):
                dp[j][k] += dp[j - 1][k - X[i]]

    ans = 0
    for j in range(1, min(N, M // A) + 1):
        ans += dp[j][A * j]

    print(ans)
    return


if __name__ == '__main__':
    main()
# Original solution
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, A, *X = list(map(int, read().split()))

    X = [x - A for x in X]
    base = 2500
    dp = [[0] * 5001 for _ in range(N + 1)]
    dp[0][base] = 1

    for i in range(N):
        for s in range(5001):
            dp[i + 1][s] = dp[i][s]
            if 0 <= s - X[i] <= 5000:
                dp[i + 1][s] += dp[i][s - X[i]]

    print((dp[N][base] - 1))
    return


if __name__ == '__main__':
    main()


# Optimized solution
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, A, *X = list(map(int, read().split()))

    X = [x - A for x in X]

    neg = pos = 0
    for x in X:
        if x > 0:
            pos += x
        else:
            neg += x

    M = pos - neg
    base = -neg

    dp = [[0] * (M + 1) for _ in range(N + 1)]
    dp[0][base] = 1

    for i in range(N):
        for s in range(M + 1):
            dp[i + 1][s] = dp[i][s]
            if 0 <= s - X[i] <= M:
                dp[i + 1][s] += dp[i][s - X[i]]

    print((dp[N][base] - 1))
    return


if __name__ == '__main__':
    main()
# Original solution
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, A, *X = list(map(int, read().split()))

    X = [x - A for x in X]

    base = 2500
    dp = [[0] * 5001 for _ in range(N + 1)]
    dp[0][base] = 1
    for i in range(N):
        for j in range(-2500, 2501):
            if -2500 <= j - X[i] <= 2500:
                dp[i + 1][j + base] = dp[i][j + base] + dp[i][j - X[i] + base]
            else:
                dp[i + 1][j + base] = dp[i][j + base]

    print((dp[N][base] - 1))

    return


if __name__ == '__main__':
    main()


# Optimized solution
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, A, *X = list(map(int, read().split()))

    X = [x - A for x in X]

    base = 2500
    dp = [0] * 5001
    dp[base] = 1
    for i in range(N):
        dp, dp_prev = dp[:], dp
        for j in range(5001):
            if 0 <= j - X[i] <= 5000:
                dp[j] += dp_prev[j - X[i]]

    print((dp[base] - 1))

    return


if __name__ == '__main__':
    main()
# Original solution
import sys
readline = sys.stdin.readline
from collections import Counter

def main():
    N, A = list(map(int, readline().rstrip().split()))
    X = list(map(int, readline().rstrip().split()))
    X = [x-A for x in X]
    ans = 0
    X1 = X[:N//2]
    X2 = X[N//2:]
    X1_sum = [0]
    for i in range(1, 2**len(X1)):
        b = bin(i)[2:].zfill(len(X1))
        su = sum([X1[i] for i, e in enumerate(b) if e == '1'])
        X1_sum.append(su)
    X2_sum = [0]
    for i in range(1, 2**len(X2)):
        b = bin(i)[2:].zfill(len(X2))
        su = sum([X2[i] for i, e in enumerate(b) if e == '1'])
        X2_sum.append(su)
    c = Counter(X2_sum)
    c_keys = list(c.keys())
    for x1 in X1_sum:
        if -x1 in c_keys:
            ans += c[-x1]

    print((ans - 1))

    
if __name__ == '__main__':
    main()

# Optimized solution
import sys
readline = sys.stdin.readline

def main():
    N, A = list(map(int, readline().rstrip().split()))
    X = list(map(int, readline().rstrip().split()))
    lim = max(X) * N
    X = [x-A for x in X]
    dp = [[0]*(2*lim) for _ in range(N+1)]
    dp[0][lim] = 1
    for i in range(1, N+1):
        x = X[i-1]
        for j in range(2*lim):
            if 0 <= j - x < 2 * lim:
                dp[i][j] = dp[i-1][j] + dp[i-1][j-x]
            else:
                dp[i][j] = dp[i-1][j]
    
    print((dp[N][lim] - 1))


if __name__ == '__main__':
    main()
# Original solution
# 配るDP
N, A = list(map(int, input().split()))
X = list(map(int, input().split()))

dp = [[[0 for _ in range(3010)] for __ in range(N+1)] for ___ in range(N+1)]

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

for i in range(N):
    for j in range(N):
        for k in range(2500+1):
            dp[i+1][j][k] += dp[i][j][k]
            dp[i+1][j+1][k+X[i]] += dp[i][j][k]

ans = 0
for n in range(1, N+1):
    ans += dp[N][n][n*A]

print(ans)


# Optimized solution
# 配るDP
N, A = list(map(int, input().split()))
X = list(map(int, input().split()))

dp = [[[0 for _ in range(3010)] for __ in range(N+1)] for ___ in range(N+1)]

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

for i in range(N):
    for j in range(N):
        for k in range(2500+1):
            if dp[i][j][k]:
                dp[i+1][j][k] += dp[i][j][k]
                dp[i+1][j+1][k+X[i]] += dp[i][j][k]

ans = 0
for n in range(1, N+1):
    ans += dp[N][n][n*A]

print(ans)
# Original solution
N, A = list(map(int, input().split()))
lst = [int(x) for x in input().split()]
ret = 0
for i in range(2 ** N):
    n = 0
    cnt = 0
    for j in range(N):
        if i >> j & 1:
            n += lst[j]
            cnt += 1
    if cnt > 0 and n / cnt == A:
        ret += 1
print(ret)


# Optimized solution
N, A = list(map(int, input().split()))
lst = [int(x) - A for x in input().split()]
dp = [[0] * (100 * N + 1) for _ in range(N + 1)]
dp[0][50 * N] = 1
for i in range(N):
    for j in range(50, 100 * N + 1 - 50):
        dp[i + 1][j] = dp[i][j] + dp[i][j - lst[i]]
print((dp[N][50 * N] - 1))
# Original solution

NMAX = 55

N, A = list(map(int, input().split()))
X = list(map(int, input().split()))

dp = [[[0] * NMAX for s in range(3000)] for i in range(NMAX)]

dp[0][0][0] = 1 # dp[i][s][k]: i個からk個選ぶとき、総和がsのものの個数
for i in range(N): # N-1時点でNが更新されるのでここまでで十分
    for s in range(3000):
        for k in range(N+1):
            if dp[i][s][k] == 0:
                continue
            dp[i+1][s][k] += dp[i][s][k]
            dp[i+1][s+X[i]][k+1] += dp[i][s][k]

ans = 0
for k in range(1, N+1):
    ans += dp[N][A*k][k]

print(ans)


# Optimized solution

NMAX = 55
T = 2500
N, A = list(map(int, input().split()))
X = list([int(x) - A for x in input().split()])

dp = [[0]*5001 for i in range(NMAX)]  # i時点で総和がSになるものの個数

dp[0][T] = 1

for i in range(N):
    for s in range(5001):
        if s+X[i] > 5001 or dp[i][s] == 0:
            continue
        dp[i+1][s] += dp[i][s]
        dp[i+1][s+X[i]] += dp[i][s]

print((dp[N][T]-1))