Problem:
 Score : 300 points    Problem Statement Tak has N cards. On the i -th (1 \leq i \leq N) card is written an integer x_i .
He is selecting one or more cards from these N cards, so that the average of the integers written on the selected cards is exactly A .
In how many ways can he make his selection?      Constraints  1 \leq N \leq 50  1 \leq A \leq 50  1 \leq x_i \leq 50  N,\,A,\,x_i are integers.       Partial Score  200 points will be awarded for passing the test set satisfying 1 \leq N \leq 16 .         Input The input is given from Standard Input in the following format:  N  A  x_1  x_2  ...  x_N       Output Print the number of ways to select cards such that the average of the written integers is exactly A .        Sample Input 1 4 8
7 9 8 9      Sample Output 1 5   The following are the 5 ways to select cards such that the average is 8 :  Select the 3 -rd card.  Select the 1 -st and 2 -nd cards.  Select the 1 -st and 4 -th cards.  Select the 1 -st, 2 -nd and 3 -rd cards.  Select the 1 -st, 3 -rd and 4 -th cards.          Sample Input 2 3 8
6 6 9      Sample Output 2 0       Sample Input 3 8 5
3 6 2 8 7 6 5 9      Sample Output 3 19       Sample Input 4 33 3
3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3      Sample Output 4 8589934591   The answer may not fit into a 32 -bit integer.

Solution (Python):
def main():
    N, A = map(int, input().split())
    x = [0]
    x.extend(list(map(int, input().split())))

    dp = [[[0 for _ in range(N * A + 1)] for _ in range(N + 1)] for _ in range(N + 1)]
    for i in range(N + 1):
        dp[i][0][0] = 1

    for i in range(1, N + 1):
        for j in range(1, i + 1):
            for k in range(1, N * A + 1):
                if k < x[i]:
                    dp[i][j][k] = dp[i - 1][j][k]
                else:
                    dp[i][j][k] = dp[i - 1][j][k] + dp[i - 1][j - 1][k - x[i]]

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

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
def main():
    N, A = map(int, input().split())
    x = [0]
    x.extend(list(map(int, input().split())))

    dp = [[[0 for _ in range(N * A + 1)] for _ in range(N + 1)] for _ in range(N + 1)]
    for i in range(N + 1):
        dp[i][0][0] = 1

    for i in range(1, N + 1):
        for j in range(1, i + 1):
            for k in range(1, N * A + 1):
                if k < x[i]:
                    dp[i][j][k] = dp[i - 1][j][k]
                else:
                    dp[i][j][k] = dp[i - 1][j][k] + dp[i - 1][j - 1][k - x[i]]

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

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
def main():
    N, A = map(int, input().split())
    x = [0]
    x.extend(list(map(int, input().split())))

    dp = [[[0 for _ in range(N * A + 1)] for _ in range(N + 1)] for _ in range(N + 1)]
    for i in range(N + 1):
        dp[i][0][0] = 1

    for i in range(1, N + 1):
        for j in range(1, i + 1):
            for k in range(1, N * A + 1):
                if k < x[i]:
                    dp[i][j][k] = dp[i - 1][j][k]
                else:
                    dp[i][j][k] = dp[i - 1][j][k] + dp[i - 1][j - 1][k - x[i]]

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

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
def main():
    N, A = map(int, input().split())
    x = [0]
    x.extend(list(map(int, input().split())))

    dp = [[[0 for _ in range(N * A + 1)] for _ in range(N + 1)] for _ in range(N + 1)]
    for i in range(N + 1):
        dp[i][0][0] = 1

    for i in range(1, N + 1):
        for j in range(1, i + 1):
            for k in range(1, N * A + 1):
                if k < x[i]:
                    dp[i][j][k] = dp[i - 1][j][k]
                else:
                    dp[i][j][k] = dp[i - 1][j][k] + dp[i - 1][j - 1][k - x[i]]

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

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, a, *x = map(int, read().split())
dp = [[0] * max(sum(x) + 1, a * n + 1) for _ in range(n + 1)]
dp[0][0] = 1
ans = 0
for i in range(n):
    for k in range(n - 1, -1, -1):
        for j in range(sum(x)):
            if dp[k][j] != 0:
                dp[k + 1][j + x[i]] += dp[k][j]
for i in range(1, n + 1):
    ans += dp[i][a * i]
print(ans)

Solution (Python):
def main():
    N, A = map(int, input().split())
    x = [0]
    x.extend(list(map(int, input().split())))

    dp = [[[0 for _ in range(N * A + 1)] for _ in range(N + 1)] for _ in range(N + 1)]
    for i in range(N + 1):
        dp[i][0][0] = 1

    for i in range(1, N + 1):
        for j in range(1, i + 1):
            for k in range(1, N * A + 1):
                if k < x[i]:
                    dp[i][j][k] = dp[i - 1][j][k]
                else:
                    dp[i][j][k] = dp[i - 1][j][k] + dp[i - 1][j - 1][k - x[i]]

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

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
def main():
    N, A = map(int, input().split())
    x = [0]
    x.extend(list(map(int, input().split())))

    dp = [[[0 for _ in range(N * A + 1)] for _ in range(N + 1)] for _ in range(N + 1)]
    for i in range(N + 1):
        dp[i][0][0] = 1

    for i in range(1, N + 1):
        for j in range(1, i + 1):
            for k in range(1, N * A + 1):
                if k < x[i]:
                    dp[i][j][k] = dp[i - 1][j][k]
                else:
                    dp[i][j][k] = dp[i - 1][j][k] + dp[i - 1][j - 1][k - x[i]]

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

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
def main():
    N, A = map(int, input().split())
    x = list(map(int, input().split()))

    x.insert(0, 0)

    dp = [[[0] * (N * A + 1) for _ in range(N + 1)] for _ in range(N + 1)]
    for i in range(N + 1):
        dp[i][0][0] = 1

    for i in range(1, N + 1):
        for j in range(1, i + 1):
            for k in range(1, N * A + 1):
                dp[i][j][k] = dp[i - 1][j][k]
                if k >= x[i]:
                    dp[i][j][k] += dp[i - 1][j - 1][k - x[i]]

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

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
def main():
    N, A = map(int, input().split())
    x = list(map(int, input().split()))

    x.insert(0, 0)

    dp = [[[0 for _ in range(N * A + 1)] for _ in range(N + 1)] for _ in range(N + 1)]
    for i in range(N + 1):
        dp[i][0][0] = 1

    for i in range(1, N + 1):
        for j in range(1, i + 1):
            for k in range(1, N * A + 1):
                dp[i][j][k] = dp[i - 1][j][k]
                if k >= x[i]:
                    dp[i][j][k] += dp[i - 1][j - 1][k - x[i]]

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

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
import sys

input = sys.stdin.readline


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

    x.insert(0, 0)

    dp = [[[0 for _ in range(N * A + 1)] for _ in range(N + 1)] for _ in range(N + 1)]
    for i in range(N + 1):
        dp[i][0][0] = 1

    for i in range(1, N + 1):
        for j in range(1, i + 1):
            for k in range(1, N * A + 1):
                dp[i][j][k] = dp[i - 1][j][k]
                if k >= x[i]:
                    dp[i][j][k] += dp[i - 1][j - 1][k - x[i]]

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

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
if __name__ == '__main__':
    N, A = map(int, input().split())
    x = list(map(int, input().split()))

    x.insert(0, 0)

    dp = [[[0 for _ in range(N * A + 1)] for _ in range(N + 1)] for _ in range(N + 1)]
    for i in range(N + 1):
        dp[i][0][0] = 1

    for i in range(1, N + 1):
        for j in range(1, i + 1):
            for k in range(1, N * A + 1):
                dp[i][j][k] = dp[i - 1][j][k]
                if k >= x[i]:
                    dp[i][j][k] += dp[i - 1][j - 1][k - x[i]]

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

    print(ans)

Solution (Python):
n,a=map(int,input().split())
x=list(map(int,input().split()))
x=sorted([x[i]-a for i in range(n)])
dp=[[0]*5001 for i in range(n+1)]
dp[0][2500]+=1
for i in range(n):
    for j in range(5001):
        dp[i+1][j]+=dp[i][j]
        if 0<=j-x[i]<=5000:
            dp[i+1][j]+=dp[i][j-x[i]]
print(dp[-1][2500]-1)

Solution (Python):
import math
import fractions



def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    
    return divisors

def ValueToBits(x,digit):
    res = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        res[i]=now%2
        now = now >> 1
    return res

def BitsToValue(arr):
    n = len(arr)
    ans = 0
    for i in range(n):
        ans+= arr[i] * 2**i
    return ans

def ZipArray(a):
    aa = [[a[i],i]for i in range(n)]

    aa.sort(key = lambda x : x[0])
    for i in range(n):
        aa[i][0]=i+1
    aa.sort(key = lambda x : x[1])
    b=[aa[i][0] for i in range(len(a))]
    return b

def ValueToArray10(x, digit):
    ans = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        ans[digit-i-1] = now%10
        now = now //10
    return ans

def Zeros(a):
    return [0 for i in range(a)]

def Zeros(a,b):
    if(b<=0):
        return Zeros(a)
    else:
        return [[0 for i in range(b)] for i in range(a)]

class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
 
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i
            
'''
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 2
N = 10 ** 6 + 2
fact = [1, 1]  
factinv = [1, 1]  
inv = [0, 1]  

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

'''










n,ave = list(map(int, input().split()))
a = list(map(int, input().split()))

dp = [Zeros(3000,n+1) for k in range(n+1)]

dp[0][0][0] = 1
for i in range(n):
    for j in range(2900):
        for k in range(n):
            dp[i+1][j+a[i]][k+1] += dp[i][j][k]
            dp[i+1][j][k] += dp[i][j][k]

            
ans = 0
for k in range(n):
    ans+= dp[-1][ave*(k+1)][k+1]
print(ans)

Solution (Python):
n, a = map(int, input().split())
x = [int(x)-a for x in input().split()]

ans = [[0]*5001 for _ in range(n)]  

for i in range(n):
    if i == 0:
        ans[0][x[i]+2500] += 1
    else:
        for j in range(5001):
            if 5000 >= j-x[i] >= 0:
                ans[i][j] = ans[i-1][j] + ans[i-1][j-x[i]]
        ans[i][x[i]+2500] += 1

print(ans[n-1][2500])

Solution (Python):
N,A = map(int,input().split())
x = [0] + [int(i)-A for i in input().split()]

from collections import defaultdict

dp = defaultdict(int)

for i in range(N+1):
    for j in range(min(-2500,x[i]-2500),max(2501,2501+x[i])):
        if i == 0 and j == 0:
            dp[(i,j)] = 1
        else:
            dp[(i,j)] = dp[(i-1,j)] + dp[(i-1,j-x[i])]
print(dp[(N,0)]-1)

Solution (Python):
from collections import defaultdict

N, A = map(int, input().split())
intA = lambda x: int(x) - A
X = tuple(map(intA, input().split()))

d = defaultdict(int)
for x in X:
    new_d = d.copy()
    for k, v in d.items():
        new_d[k + x] += v
    new_d[x + 2500] += 1
    d = new_d
print(d[2500])

Solution (Python):
import itertools
import math
import string
import collections
from collections import Counter
from collections import deque
import sys
sys.setrecursionlimit(2*10**5)
INF = 2**60


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor



dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]

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

sum = 0
for i in range(N):
    sum += x[i]

dp = [[[0]*(3000) for _ in range(55)] for _ in range(55)]
dp[0][0][0] = 1
for i in range(N):
    for j in range(N+1):
        for k in range(2900):
            dp[i+1][j][k] += dp[i][j][k]
            if k >= x[i]:
                dp[i+1][j+1][k] += dp[i][j][k-x[i]]
ans = 0
for j in range(1, N+1):
    ans += dp[N][j][j*A]
print(ans)

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

for i in range(N):
    X[i] -= A

from collections import defaultdict

counter = defaultdict(int)
counter[0] = 1

for x in X:
    copy = dict(counter)
    for k,v in copy.items():
        counter[k+x] += v

print(counter[0]-1)

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

dp = [[[0 for k in range(2501)] for j in range(N+1)] for i in range(N+1)]

for i in range(1,N+1):
    x = X[i-1]
    dp[i][1][x] += 1
    for j in range(1,i+1):
        for k in range(1,2501):
            if k-x > 0:
                dp[i][j][k] += dp[i-1][j-1][k-x] + dp[i-1][j][k]
            else:
                dp[i][j][k] += dp[i-1][j][k]

ans = 0

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

Solution (Python):
n,a = map(int, input().split())
x = list(map(int, input().split()))
x.sort()

dp = [[[0 for _ in range(2555)] for _ in range(55)] for _ in range(55)]
dp[0][0][0]=1
for j in range(n):
    for k in range(n):
        for s in range(a*n+1):
            dp[j+1][k][s] += dp[j][k][s]
            dp[j+1][k+1][s+x[j]] += dp[j][k][s]

ans=0
for k in range(1,n+1):
    ans+=dp[n][k][a*k]
print(ans)

Solution (Python):
n,a = map(int,input().split())
x = list(map(int,input().split()))

dp = [[[0]*(n*a+1) for _ in range(n+1)] for _ in range(n+1)]
dp[0][0][0] = 1
for i in range(n):
    for j in range(i+1):
        for s in range(n*a + 1):
            dp[i+1][j][s] += dp[i][j][s]
            if s + x[i] <= n*a:
                dp[i+1][j+1][s+x[i]] += dp[i][j][s]
ans = 0
for j in range(1,n+1):
    ans += dp[n][j][j*a]
print(ans)

Solution (Python):
n, a = map(int, input().split())
l = [int(i) for i in input().split()]

dp = [[[0] * 2501 for j in range(51)] for i in range(51)]

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

for i in range(n):
    for j in range(51):
        for k in range(2501):
            if k >= l[i] and j >= 1:
                dp[i+1][j][k] = dp[i][j][k] + dp[i][j-1][k-l[i]]
            else:
                dp[i+1][j][k] = dp[i][j][k]

print(sum([dp[n][m][a*m] for m in range(1, n+1)]))

Solution (Python):
N,A = map(int, input().split())
xs = list(map(int, input().split()))
"""
dp[i][j][n] : i枚目において、j枚選んだときの合計がnになる場合の数
dp[i+1][j+1][n+x] = dp[i][j][n] * (x) + dp[i][j+1][n+x]
dp[0][0][0] = 1
"""
Nx = 2550
dp = [[[0]*Nx for i in range(N+10)] for j in range(N+10)]
dp[0][0][0] = 1

for i in range(N):
    x = xs[i]
    for j in range(N):
        for n in range(Nx):
            dp[i+1][j][n] = dp[i][j][n]
    for j in range(N):
        for n in range(Nx):
            if n + x >= Nx:continue
            dp[i+1][j+1][n+x] = dp[i][j][n] + dp[i][j+1][n+x]
    
cnts = dp[N]
ans = 0
for i in range(1,N+1):
    ans += cnts[i][A*i]
print(ans)

Solution (Python):
n, a = map(int, input().split())
xlist = list(map(int, input().split()))

j = n
k = n
t = n * a
maxv = max(a, max(xlist))


dp = [[[0 for t in range(n*maxv + 1)] for k in range(k + 1)] for j in range(j + 1)]

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





for ji in range(0, j + 1):
    for ki in range(0, ji + 1):
        for ti in range(0, ki * maxv + 1):
            
            if ji == 0 and ki == 0 and ti == 0:
                
                dp[ji][ki][ti] = 1
            elif ji >= 1 and ti < xlist[ji - 1]:
                dp[ji][ki][ti] = dp[ji - 1][ki][ti]
                
            elif ji >= 1 and ki >= 1 and ti >= xlist[ji - 1]:
                
                dp[ji][ki][ti] = dp[ji - 1][ki][ti] + dp[ji - 1][ki - 1][ti - xlist[ji - 1]]
            

count = 0
for i in range(1, k + 1):
    count += dp[j][i][i*a]

print(count)

Solution (Python):
N, A = map(int, input().split())
x = list(map(int, input().split()))
X = max(A, max(x))

DP = [[[0 for _ in range(N*X+1)] for _ in range(N+1)] for _ in range(N+1)]
DP[0][0][0] = 1

for j in range(1, N+1):
    for k in range(j+1):
        for s in range(k*X+1):
            if(s < x[j-1]):
                DP[j][k][s] = DP[j-1][k][s]
            else:
                DP[j][k][s] = DP[j-1][k][s]+DP[j-1][k-1][s-x[j-1]]
ans = 0                
for i in range(1, N+1):
    ans += DP[-1][i][i*A]
print(ans)

Solution (Python):
n,a=map(int,input().split())
x=list(map(int,input().split()))
p=min(a*n,sum(x))
dp=[[[0]*(n+1)for _ in range(p+1)]for _ in range(n+1)]
dp[0][0][0]=1
for i in range(1,n+1):
	for j in range(p+1):
		for k in range(n+1):
			dp[i][j][k]+=dp[i-1][j][k]
			if j-x[i-1]>=0 and k>=1:
				dp[i][j][k]+=dp[i-1][j-x[i-1]][k-1]
ans=0
for i in range(1,n+1):
	if i*a>p:
		break
	ans+=dp[-1][i*a][i]
print(ans)

Solution (Python):
import sys

rl = sys.stdin.readline


def solve():
    N, A = map(int, rl().split())
    x = list(map(int, rl().split()))
    
    y = [xi - A for xi in x]
    dp = [[0] * 5001 for _ in range(N + 1)]
    dp[0][2500] = 1
    
    for i in range(N):
        for j in range(5001):
            if 0 <= j - y[i] < 5001:
                dp[i + 1][j] = dp[i][j] + dp[i][j - y[i]]
            else:
                dp[i + 1][j] = dp[i][j]
    print(dp[N][2500] - 1)


if __name__ == '__main__':
    solve()

Solution (Python):
import sys,queue,math,copy,itertools
from fractions import gcd
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = 10**18
MOD = 10**9 + 7
LI = lambda : [int(x) for x in input().split()]
N,A = LI()
_LI = lambda : [int(x)-A for x in input().split()]
X = _LI()

m = [0 for _ in range(50*N)]
Base = 25 * N

for i in range(N):
    m2 = copy.copy(m)
    for j in range(len(m)):
        if m[j]:
            if 0<= j + X[i] < len(m2):
                m2[j+X[i]] += m[j]
    m = m2
    m[X[i] + Base] += 1
print (m[Base])

Solution (Python):
from collections import defaultdict
n, a = map(int, input().split())
x = list(map(int, input().split()))

dp = [defaultdict(int) for _ in range(n+1)]
dp[0][a] += 1

for i, x_i in enumerate(x):
    for p in dp[i].keys():
        pk = p + a - x_i
        dp[i+1][pk] += dp[i][p]
        dp[i+1][p] += dp[i][p]

print(dp[n][a] - 1)

Solution (Python):
n,a=map(int,input().split())
X=list(map(int,input().split()))
dp=[[[0]*55 for _ in range(2555)] for _ in range(55)]
ans=0
dp[0][0][0]=1
for i in range(n):
    for j in range(52+50*i):
        for k in range(n):
            ni=i+1
            nj=j+X[i]
            nk=k+1
            dp[ni][nj][nk]+=dp[i][j][k]
            dp[ni][j][k]+=dp[i][j][k]
ans=0
for i in range(1,n+1):
    ans+=dp[n][i*a][i]
print(ans)

Solution (Python):
n, a = map(int, input().split())
x = list(map(int, input().split()))
max_ = sum(x)


dp = [[[0] * (max_ + 1) for i in range(n + 1)] for i in range(n + 1)]
dp[0][0][0] = 1
for i in range(n):
    for j in range(n):
        for num in range(max_ + 1):
            
            if num - x[i] >= 0:
                dp[i + 1][j + 1][num] += dp[i][j][num - x[i]]
            
            dp[i + 1][j][num] += dp[i][j][num]

ans = 0
for i in range(1, n + 1):
    for val in range(1, max_ + 1):
        if val == a * i:
            ans += dp[-1][i][val]
print(ans)

Solution (Python):
n,a = map(int,input().split())
x = list(map(int,input().split()))

x_m = []
x_0 = []
x_p = []
for i in range(n):
    tmp = x[i] - a
    if(tmp < 0):
        x_m.append(tmp * -1)
    elif(tmp == 0):
        x_0.append(tmp)
    else:
        x_p.append(tmp)

len_m = (len(x_m))
len_0 = (len(x_0))
len_p = (len(x_p))

dp_m = [[0] * 1300 for i in range(len_m+1)]
dp_p = [[0] * 1300 for i in range(len_p+1)]

dp_m[0][0] = 1
dp_p[0][0] = 1


for i in range(1,len_m+1):
    for j in range(1300):
        dp_m[i][j] = dp_m[i-1][j]
        if(j >= x_m[i-1]):
            dp_m[i][j] += dp_m[i-1][j-x_m[i-1]]

for i in range(1,len_p+1):
    for j in range(1300):
        dp_p[i][j] = dp_p[i-1][j]
        if(j >= x_p[i-1]):
            dp_p[i][j] += dp_p[i-1][j-x_p[i-1]]

ans = 0
for i in range(0,1300):
    ans += dp_m[-1][i] * dp_p[-1][i]

ans = ans * 2**len_0 -1

print(ans)

Solution (Python):
"""from collections import *
from itertools import *
from bisect import *
from heapq import *

import math
from fractions import gcd
import sys


import copy
"""
from collections import *
N,A=map(int,input().split())
X=list(map(int,input().split()))
G=2501
dp=[[0 for i in range((N+1)*G)] for n in range(N)]

X[0]

dp[0][G+X[0]]=1

for n in range(1,N):

    for i in range(len(dp[0])):
        if (X[n]+G)>=0:
            if dp[n-1][i-(X[n]+G)]:
                dp[n][i]=dp[n-1][i-(X[n]+G)]+dp[n-1][i]
            else:
                dp[n][i]=dp[n-1][i]
        else:
            dp[n][i]=dp[n-1][i]
    dp[n][G+X[n]]+=1
    

print(sum([dp[-1][i] for i in range(len(dp[0])) if i//G and (i%G)%(i//G)==0 and (i%G)//(i//G)==A]))

Solution (Python):
import sys
input = sys.stdin.readline

N, A = [int(x) for x in input().split()]
x = [int(x) - A for x in input().split()]

dp = [[0] * 5001 for _ in range(N + 1)]
dp[0][0 + 2500] = 1

for i in range(1, N + 1):
    for j in range(-2500, 2501):
        if 5000 >= j + 2500 - x[i - 1] >= 0:
            dp[i][j + 2500] = dp[i - 1][j + 2500 - x[i - 1]] + dp[i - 1][j + 2500]
        else:
            dp[i][j + 2500] = dp[i - 1][j + 2500]

print(dp[N][0 + 2500] - 1)

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

dp = [[[0]*(max(sum(x),N*A)+1) for k in range(N+1)] for l in range(N+1)]

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

for i in range(N):
    for j in range(N):
        for k in range(sum(x)+1):
            dp[i+1][j][k] += dp[i][j][k]
            if k-x[i] >= 0:
                dp[i+1][j+1][k] += dp[i][j][k-x[i]]

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

Solution (Python):
n,a=map(int,input().split())
x=list(map(int,input().split()))

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

dp[0][0][0]=1
dp[0][1][x[0]]=1
for i in range(1,n):
    for j in range(n+1):
        for k in range(n*50+1):
            if dp[i-1][j][k]==0:continue
            
            dp[i][j+1][k+x[i]]+=dp[i-1][j][k]
            
            dp[i][j][k]+=dp[i-1][j][k]

ans=0
for j in range(1,n+1):
    for k in range(n*50+1):
        if a*j==k:
            ans+=dp[-1][j][k]
print(ans)

Solution (Python):
from sys import stdout
printn = lambda x: stdout.write(str(x))
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True 
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n,a = inm()
x = inl()
d = [[[0]*(50*n+1) for i in range(n+1)] for j in range(n+1)]
d[0][0][0] = 1
for i in range(n):
    for j in range(n+1):
        for k in range(50*n+1):
            if d[i][j][k]>0:
                d[i+1][j][k] += d[i][j][k]
                if j<n:
                    d[i+1][j+1][k+x[i]] += d[i][j][k]
sm = 0
for j in range(1,n+1):
    sm += d[n][j][j*a]
print(sm)

Solution (Python):
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))



N,A = LI()
x = LI()


dp = [[[0]*(50*N+1) for _ in range(N+1)] for _ in range(N)]
dp[0][0][0] = 1
dp[0][1][x[0]] = 1

for i in range(1,N):
    for j in range(N+1):
        for k in range(50*N+1):
            dp[i][j][k] = dp[i-1][j][k]
            if k-x[i] >= 0:
                dp[i][j][k] += dp[i-1][j-1][k-x[i]]

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

print(ans)

Solution (Python):
n,a=map(int,input().split())
x=list(map(int,input().split()))

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

for i in range(n):
    for j in range(n):
        for k in range(a*n+1):
            if k+x[i]<=a*n:
                
                dp[i+1][j+1][k+x[i]]+=dp[i][j][k]
            
            dp[i+1][j][k]+=dp[i][j][k]
ans=0
cnt=0

for i in dp[-1]:
    ans+=i[cnt*a]
    cnt+=1
print(ans-1)

Solution (Python):
n,a=map(int,input().split())
x=list(map(int,input().split()))
dp=[[[0]*(n*50+1) for _ in range(n+1)] for _ in range(n+1)]
dp[0][0][0]=1
for i in range(1,n+1):
    for j in range(i+1):
        for k in range(j*50+1):
            if k<x[i-1]:
                dp[i][j][k]=dp[i-1][j][k]
            else:
                dp[i][j][k]=dp[i-1][j][k]+dp[i-1][j-1][k-x[i-1]]
ans=0
for i in range(1,n+1):
    ans+=dp[-1][i][i*a]
print(ans)

Solution (Python):
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, A = lr()
X = np.array(lr()) - A
dp = np.zeros(3000, np.int64)
dp[1500] = 1 
for x in X:
    if x > 0:
        dp[x:] = dp[x:] + dp[:-x]
    elif x == 0:
        dp[:] = dp[:] + dp[:]
    else:
        dp[:x] = dp[:x] + dp[-x:]

print(dp[1500] - 1)

Solution (Python):
import sys
import numpy as np
from math import factorial

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, A = lr()
X = np.array(lr())
X.sort()
X -= A
pos = X[X>0]
zero = X[X==0]
neg = X[X<0]
limit = max(pos.sum(), neg.sum()) + 10
dp_pos = [0] * limit
dp_neg = [0] * limit
dp_pos[0] = 1
dp_neg[0] = 1
dp_pos = np.array(dp_pos)
dp_neg = np.array(dp_neg)

for p in pos:
    dp_pos[p:] = dp_pos[p:] + dp_pos[:-p]
for n in neg:
    dp_neg[-n:] = dp_neg[-n:] + dp_neg[:n]

def combinations_count(n, r):
    ''' 組み合わせ '''
    return factorial(n) // (factorial(n - r) * factorial(r))

  
dp_pos = np.array(dp_pos)
dp_neg = np.array(dp_neg)
Y = dp_pos * dp_neg
if len(zero) + Y.sum() == 0:
    print(0)
    exit()
answer = 2 ** len(zero)
if Y.sum() > 0:
    answer *= np.sum(Y)
print(answer - 1)

Solution (Python):
n, a = map(int, input().split())
x = list(map(int, input().split()))


dp = [[[0 for i in range(n+1)] for j in range(sum(x)+1)] for k in range(n+1)]
dp[0][0][0] = 1
for i in range(1,n+1):
    for j in range(sum(x) + 1):
        for k in range(n+1):
            if j + x[i-1] < sum(x) + 1 and k < n:
                dp[i][j + x[i-1]][k+1] += dp[i-1][j][k]
            dp[i][j][k] += dp[i-1][j][k]
ans = 0
for j in range(sum(x)+1):
    for k in range(1,n+1):
        if j == a * k:
            ans += dp[-1][j][k]

print(ans)

Solution (Python):
N,A=map(int,input().split())
X=list(map(int,input().split()))
X=[X[i]-A for i in range(0,N)]
dp=[[0 for i in range(0,5000)] for i in range(0,N+1)]
dp[0][2500]=1
for i in range(1,N+1):
    for j in range(0,5000):
        if j>=X[i-1] and 4999>=j-X[i-1]:
            dp[i][j]=dp[i-1][j]+dp[i-1][j-X[i-1]]
        else:
            dp[i][j]=dp[i-1][j]
print(dp[N][2500]-1)

Solution (Python):
n,a = map(int, input().split())
xl = list(map(int, input().split()))

offset = 300
dp = [[0]*600 for _ in range(n+1)]
dp[0][offset] = 1
for i in range(1,n+1):
    x = xl[i-1]-a
    for j in range(-300,300):
        dp[i][offset+j] = dp[i-1][offset+j]
        if 600>offset+j-x>=0:
            dp[i][offset+j] += dp[i-1][offset+j-x]

print(dp[n][offset]-1)

Solution (Python):
n,a = map(int,input().split())
xl = list(map(int,input().split()))


dp = [[0 for i in range(50*50+1)] for j in range(51)]
dp[0][0] = 1

for i in range(n):
    for j in range(n-1, -1, -1):
        for k in range(50*50+1):
            if k+xl[i] < 50*50+1:
                dp[j+1][k+xl[i]] += dp[j][k]
ans = 0
for i in range(1,n+1):
    ans += dp[i][i*a]

print(ans)

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect_left, bisect
from heapq import heappush, heappop

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, A = MAP()

x = LIST()

sum_x = sum(x)
dp = [[0]*(sum_x+1) for _ in range(N+1)]
dp[0][0] = 1
for i in range(N):
	for j in range(N-1, -1, -1):
		for k in range(sum_x+1):
			if k-x[i] >= 0 and dp[j][k-x[i]]:
				dp[j+1][k] += dp[j][k-x[i]]

ans = 0
for i in range(1, N+1):
	if A*i <= sum_x:
		
		ans += dp[i][A*i]
print(ans)

Solution (Python):
N,A = map(int,input().split())
X = list(map(int,input().split()))
dp = [[[0 for _ in range(2501)] for _ in range(N+1)] for _ in range(N+1)]
for i in range(N+1):
    dp[i][0][0] = 1
for i in range(1,N+1):
    for j in range(1,N+1):
        for k in range(1,2501):
            dp[i][j][k] = dp[i-1][j][k]
            if k>=X[i-1]:
                dp[i][j][k] += dp[i-1][j-1][k-X[i-1]]
cnt = 0
for j in range(1,N+1):
    cnt += dp[N][j][j*A]
print(cnt)

Solution (Python):
N,A = map(int,input().split())
x = list(map(int,input().split()))
X = N*50
dp = [[[0 for i in range(X+1)] for j in range(N+1)] for k in range(N+1)]
dp[0][0][0] = 1
for k in range(1,N+1):
    for j in range(k+1):
        for i in range(j*50+1):
            if i - x[k-1] < 0:
                dp[k][j][i] = dp[k-1][j][i]
            elif k >= 1:
                dp[k][j][i] = dp[k-1][j-1][i-x[k-1]] + dp[k-1][j][i]
ans = 0
for j in range(1,N+1):
    ans += dp[-1][j][j*A]
print(ans)

Solution (Python):
N,A = map(int,input().split())
x = list(map(int,input().split()))
X = N*max(max(x),A)
dp = [[[0 for i in range(X+1)] for j in range(N+1)] for k in range(N+1)]
dp[0][0][0] = 1
for k in range(1,N+1):
    for j in range(k+1):
        for i in range(X+1):
            if i - x[k-1] >= 0 and k >= 1:
                dp[k][j][i] = dp[k-1][j-1][i-x[k-1]] + dp[k-1][j][i]
            else:
                dp[k][j][i] = dp[k-1][j][i]
ans = 0
for j in range(1,N+1):
    for i in range(X+1):
        if i%j == 0 and i//j == A:
            ans += dp[-1][j][i]
print(ans)

Solution (Python):
N,A = map(int,input().split())
x2 = list(map(int,input().split()))
x = [i-A for i in x2]
maxx = max(max(x2),A)
dp = [[0 for i in range(2*N*maxx+1)] for j in range(N+1)]
start = N*maxx
dp[0][start] = 1
for i in range(1,N+1):
    for j in range(2*start+1):
        if 2*start >= j - x[i-1] >= 0:
            dp[i][j] = dp[i-1][j-x[i-1]] + dp[i-1][j]
        else:
            dp[i][j] = dp[i-1][j]
print(dp[-1][start]-1)