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):
N, A = map(int, input().split())
X = list(map(int, input().split()))
for i in range(N):
    X[i] -= A
D = {0: 1}
for i in range(N):
    F = [[j, D[j]] for j in D]
    for j in F:
        if j[0] + X[i] in D:
            D[j[0] + X[i]] += j[1]
        else:
            D[j[0] + X[i]] = j[1]
print(D[0]-1)

Solution (Python):
N, A = map(int, input().split())
nums = list(map(int, input().split()))
MAX = A*N
dp = [[0 for _ in range(A*N+1)] for _ in range(N+1)]
dp[0][0] = 1
for k, num in enumerate(nums, start=1):
  for i in range(N-1, -1, -1):
    for j in range(A*N-1, -1, -1):
      if j + num <= A*N:
        dp[i+1][j+num] += dp[i][j]
ans = 0
for i in range(1, N+1):
  ans += dp[i][i*A]
print(ans)

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

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


dp = [[[0]*(55) for i in range(3000)]for i in range(55)]
dp[0][0][0] = 1

for i in range(n):
  for j in range(n*a):
    for k in range(n):
      dp[i+1][j][k] += dp[i][j][k]
      dp[i+1][j+x[i]][k+1] += dp[i][j][k]
      
    
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())
l = list(map(int, input().split()))
ans = 0
dp = list([0]*(n*a+1) for _ in range(n+1))
dp[0][0] = 1
for x in l:
    for i in range(n, 0, -1):
        for j in range(n*a+1):
            if x > j:
                continue
            dp[i][j] += dp[i-1][j-x]

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

print(ans)

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

dp = [[[0]*(2501) for i in range(51)] for j in range(51)]
dp[0][0][0] = 1
for i in range(N):
    value = X[i]
    for j in range(i+2):
        for k in range(2501):
            if i >= j:
                dp[i+1][j][k] += dp[i][j][k]
            if j >= 1 and k >= value:
                dp[i+1][j][k] += dp[i][j-1][k-value]

ans = sum(dp[N][x][A*x] for x in range(1,N+1))

print(ans)

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

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

x=list(map(int,input().split()))
A=max(x)
x.insert(0,-1)
dp=[[[0]*(n+1) for _ in range(n*A+1)] for i in range(n+1)]
dp[1][x[1]][1]=1
dp[1][0][0]=1
for i in range(1,n):
    q=x[i+1]
    for s in range(n*A+1):
        for k in range(i+1):
            if s+q<=n*A:
                dp[i+1][s+q][k+1]+=dp[i][s][k]
            dp[i+1][s][k]+=dp[i][s][k]

ans=0
i=1

while i<=n and a*i<=n*A:
    ans+=dp[n][a*(i)][i]
    i+=1
print(ans)

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce, lru_cache
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()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 





N, A = MAP()
x = LIST()

X = max(max(x), A)

y = [0]*len(x)
for i in range(len(x)):
	y[i] = x[i]-A

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

for j in range(N+1):
	for t in range(-N*X, N*X+1):
		if j == 0 and t == 0:
			dp[j][t] = 1
		elif j >= 1 and (t-y[j-1] < -N*X or t-y[j-1] > N*X):
			dp[j][t] = dp[j-1][t]
		elif j >= 1 and -N*X <= t-y[j-1] <= N*X:
			dp[j][t] = dp[j-1][t] + dp[j-1][t-y[j-1]]
		else:
			dp[j][t] = 0

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

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce, lru_cache
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()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = 10**6
mod = 10 ** 9 + 7 





N, A = MAP()
x = LIST()

big = []
small = []
cnt = 0

for y in x:
	if y == A:
		cnt += 1
	elif y < A:
		small.append(A-y)
	else:
		big.append(y-A)

big_possible = [0]*2501
small_possible = [0]*2501
big_possible[0] = 1
small_possible[0] = 1

for a in big:
	for i in range(2500-a, -1, -1):
		if big_possible[i]:
			big_possible[i+a] += big_possible[i]

for b in small:
	for i in range(2500-b, -1, -1):
		if small_possible[i]:
			small_possible[i+b] += small_possible[i]

ans = 1
for i in range(1, 2501):
	ans += small_possible[i]*big_possible[i]


ans *= 2**cnt
print(ans-1)

Solution (Python):
class Combination:
    def __init__(self, n, mod):
        self.n = n
        self.mod = mod
        self.fac = [1 for i in range(self.n + 1)]
        self.finv = [1 for i in range(self.n + 1)]
        for i in range(2, self.n+1):
            self.fac[i] = (self.fac[i - 1] * i) % self.mod
            self.finv[i] = (self.finv[i-1] * pow(i, -1, self.mod)) % self.mod

    def comb(self, n, m):
        return self.fac[n] * (self.finv[n-m] * self.finv[m] % self.mod) % self.mod
def iparse():
    return list(map(int, input().split()))

if __name__ == "__main__":
    n, a = iparse()
    x = iparse()

    dp = [[[0 for i in range(sum(x) + 10)] for j in range(n + 10)] \
        for k in range(n + 10)]
    dp[0][0][0] = 1
    for i in range(n):
        for j in range(n + 1):
            for k in range(sum(x) + 1):
                if j >= 1 and k - x[i] >= 0:
                    dp[i + 1][j][k] = dp[i][j][k] + dp[i][j - 1][k - x[i]]
                else:
                    dp[i+1][j][k] = dp[i][j][k]
    ans = 0
    for i in range(n):
        if (i + 1) * a >= sum(x) + 10:
            break
        ans += dp[n][i + 1][(i+1)*a]
    print(ans)

Solution (Python):
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 = 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()

Solution (Python):
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 = 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()

Solution (Python):
from collections import defaultdict
n, a = map(int, input().split())
x = list(map(int, input().split()))
x.sort()
x = list(map(lambda x:x - a, x))
dic = defaultdict(int)
dic[0] = 1
for i in x:
    for j, k in list(dic.items()):
        dic[j + i] = dic.get(j + i, 0) + k
print(dic[0] - 1)

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()
offset = 2500

def main():
    N, A = map(int, input().split())
    X = list(map(int, input().split()))
    for i in range(N): X[i] -= A
    dp = [0] * 5010
    dp[offset] += 1
    dp[X[0] + offset] += 1
    for i, x in enumerate(X):
        if i == 0: continue
        dp2 = [0] * 5010
        for j in range(5010):
            if j < x or j - x >= 5010:
                dp2[j] = dp[j]
            else:
                dp2[j] = dp[j] + dp[j - x]
        dp = dp2
        
    print(dp[offset] - 1)

if __name__ == "__main__":
    main()

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

z=len(lst)
dp=[[[0]*2501 for i in range(51)] for j in range(z+1)]
dp[0][0][0]=1

for i in range(z):
  x=lst[i]
  for j in range(z):
    for k in range(2451):
      dp[i+1][j][k]+=dp[i][j][k]
      dp[i+1][j+1][k+x]+=dp[i][j][k]

ans=0

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

print(ans-1)

Solution (Python):
N, A = map(int,input().split())
X = [int(x) for x in input().split()]

dp = [[0]*(N*A+1) for _ in range(N+1)] 
dp[0][0] = 1  
for x in X:
    for i in reversed(range(1,N+1)):
        for j in reversed(range(N*A+1)):
            if j < x:
                continue
            dp[i][j] += dp[i-1][j-x]
ans = sum(dp[k][k*A] for k in range(1,N+1)) 
print(ans)

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

max_a=sum(li)

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

for j in range(n):
  for i in range(max_a+1):
    for k in range(n+1):
      if dp[i][k]>0:
        dp[i-li[j]][k-1]+=dp[i][k]
        
  
ans=0
for f in range(max_a+1):
  for g in range(n+1):
    if f==g*a:
      ans+=dp[f][g]
      
      
print(ans-1)

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 998244353


def resolve():
    n, a = map(int, input().split())
    X = list(map(int, input().split()))
    MAX = sum(X)
    dp = [[[0] * (MAX + 1) for _ in range(n + 1)] for _ in range(n + 1)]
    dp[0][0][0] = 1
    for i in range(1, n + 1):
        x = X[i - 1]
        for j in range(n + 1):
            for k in range(MAX + 1):
                dp[i][j][k] += dp[i - 1][j][k]
                if k + x < MAX + 1 and j + 1 <= n:
                    dp[i][j + 1][k + x] += dp[i - 1][j][k]
    res = 0
    for j in range(1, n + 1):
        total = a * j
        if total <= MAX:
            res += dp[n][j][total]
    print(res)


if __name__ == '__main__':
    resolve()

Solution (Python):
N,A = map(int,input().split())
ls1 = [0] + list(map(int,input().split()))

dp = [[[0 for k in range(2600)] for j in range(51) ] for i in range(51)]
for i in range(51):
    dp[i][0][0] = 1
for j in range(1,N+1):
    for k in range(1,j+1):
        for s in range(2600):
            if s < ls1[j]:
                dp[j][k][s] = dp[j-1][k][s]
            elif s >= ls1[j]:
                dp[j][k][s] = dp[j-1][k-1][s-ls1[j]] + dp[j-1][k][s]
ans = 0
for k in range(1,N+1):
    ans += dp[N][k][k*A]
print(ans)

Solution (Python):
n,a = map(int, raw_input().split())
ais = map(int, raw_input().split())
mem = {}
def dfs(i,ais, cumul,count,a):
	if i == len(ais):
		return 1 if (count > 0 and count * a == cumul) else 0
	if (i,cumul,count) in mem:
		return mem[(i,cumul,count)]
	mem[(i,cumul,count)] = dfs(i+1, ais, cumul + ais[i], count +1, a) + dfs(i+1, ais, cumul, count, a)
	return mem[(i,cumul,count)]
print dfs(0,ais,0,0,a)

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

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
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)))

Solution (Python):
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)))

Solution (Python):
N,A = map(int,input().split())
ls1 = [0] + list(map(int,input().split()))

dp = [[[0 for k in range(2600)] for j in range(51) ] for i in range(51)]
for i in range(51):
    dp[i][0][0] = 1
for j in range(1,N+1):
    for k in range(1,j+1):
        for s in range(2600):
            if s < ls1[j]:
                dp[j][k][s] = dp[j-1][k][s]
            elif s >= ls1[j]:
                dp[j][k][s] = dp[j-1][k-1][s-ls1[j]] + dp[j-1][k][s]
ans = 0
for k in range(1,N+1):
    ans += dp[N][k][k*A]
print(ans)

Solution (Python):
N,A = map(int,input().split())
ls1 = [0] + list(map(int,input().split()))

dp = [[[0 for k in range(2600)] for j in range(51) ] for i in range(51)]
for i in range(51):
    dp[i][0][0] = 1
for j in range(1,N+1):
    for k in range(1,j+1):
        for s in range(2600):
            if s < ls1[j]:
                dp[j][k][s] = dp[j-1][k][s]
            elif s >= ls1[j]:
                dp[j][k][s] = dp[j-1][k-1][s-ls1[j]] + dp[j-1][k][s]
ans = 0
for k in range(1,N+1):
    ans += dp[N][k][k*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

x.sort()

if x[0] > 0 or x[-1] < 0:
    print(0)
    exit()

num_zero = x.count(0)

if x[0] == 0 or x[-1] == 0:
    print(pow(2, num_zero) - 1)
    exit()

xp = [i for i in x if i > 0]
xm = [-i for i in x if i < 0]

sum_xp = sum(xp) + 1
dp = [0] * sum_xp
dp[0] = 1
for i in xp:
    new_dp = [0] * sum_xp
    for j in range(sum_xp - i):
        new_dp[i + j] += dp[j]
    for j in range(sum_xp):
        dp[j] += new_dp[j]

for i in xm:
    new_dp = [0] * sum_xp
    for j in range(i, sum_xp):
        new_dp[j - i] += dp[j]
    for j in range(sum_xp):
        dp[j] += new_dp[j]

print(dp[0] * pow(2, num_zero) - 1)

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

dp = [[[0]*(sum_x+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(n):
        for k in range(sum_x+1):
            if k-x[i] >= 0:
                dp[i+1][j+1][k] += dp[i][j][k-x[i]]
            dp[i+1][j][k] += dp[i][j][k]

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

Solution (Python):

n, a = map(int, input().split())
x = list(map(int, input().split()))
s = sum(x)
dp = [[[0] * (s+1) for _ in range(n+1)] for _ in range(n+1)]
dp[0][0][0] = 1
for i in range(1, n+1):
    xi = x[i-1]
    for j in range(s+1):
        for k in range(i):
            dp[i][k][j] = dp[i-1][k][j]
    for j in range(xi, s+1):
        for k in range(1, i+1):
            dp[i][k][j] += dp[i-1][k-1][j-xi]

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

Solution (Python):


import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n, a = LI()
x = LI()


dp = [[[0] * (2500+1) for _ in range(n+1)] for _ in range(n+1)]
dp[0][0][0] = 1
for i in range(n+1):
    xi = x[i-1]
    for j in range(2500+1):
        for k in range(i):
            dp[i][k][j] = dp[i-1][k][j]
    for j in range(xi, 2500+1):
        for k in range(1, i+1):
            dp[i][k][j] += dp[i-1][k-1][j-xi]
ans = 0
for i in range(1, n+1):
    ans += dp[-1][i][i*a]
print(ans)

Solution (Python):


import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n, a = LI()
x = LI()

dp = [[[0] * (2500+1) for _ in range(n+1)] for _ in range(n+1)]
dp[0][0][0] = 1
for i in range(n+1):
    xi = x[i-1]
    for j in range(2500+1):
        for k in range(i):
            dp[i][k][j] = dp[i-1][k][j]
    for j in range(xi, 2500+1):
        for k in range(1, i+1):
            dp[i][k][j] += dp[i-1][k-1][j-xi]
ans = 0
for i in range(1, n+1):
    ans += dp[-1][i][i*a]
print(ans)

Solution (Python):
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
import collections
import math
import itertools
import heapq as hq
def ncr(n,r):
    ret = 1
    if n<r:
        return 0
    if n-r <r:
        r = n-r
    for i in range(1,r+1):
        ret*=(n-r+i)
        ret//=i
    return ret

n,a = ma()
X = lma()
for i in range(n):
    X[i] -= a
co = collections.Counter(X)
ans = 0
mx = 49*n 
dp = [[0 for j in range(-mx,mx+1)] for i in range(n+1)]
dp[-1][0] = 1 
for i in range(n):
    x = X[i]
    
    for j in range(-mx,mx+1,1):
        dp[i][j] += dp[i-1][j] + dp[i-1][j-x] 
        
print(dp[n-1][0]-1)

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, a = map(int, input().split())
    X = list(map(int, input().split()))
    MAX = 50 * 50 + 1

    dp = [[[0] * MAX for _ in range(n + 1)] for _ in range(n + 1)]
    dp[0][0][0] = 1
    for i in range(1, n + 1):
        x = X[i - 1]
        for j in range(n):
            for k in range(MAX):
                dp[i][j][k] += dp[i - 1][j][k]
                if k + x < MAX:
                    dp[i][j + 1][k + x] += dp[i - 1][j][k]
    res = 0
    for j in range(1, n + 1):
        res += dp[-1][j][a * j]
    print(res)


if __name__ == '__main__':
    resolve()

Solution (Python):

import sys 
import numpy as np
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N, A = map(int, readline().split())
X = list(map(int,readline().split()))
Y = [x-A for x in X]
dp = {0:1}

for y in Y:
    tmp = list(dp.items())
    for k,v in tmp:
        dp[k+y] = dp.get(k+y,0) + v
print(dp[0]-1)

Solution (Python):

import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N, A = map(int, readline().split())
X = list(map(int,readline().split()))
Y = [x-A for x in X]
dp = {0:1}

for y in Y:
    tmp = list(dp.items())
    for k,v in tmp:
        dp[k+y] = dp.get(k+y,0) + v
print(dp[0]-1)

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

dp = {0: 1}

for i in x:
    tmp = list(dp.items())
    for key, value in tmp:
        dp[key+i] = dp.get(key+i, 0) + value
print(dp[0] - 1)

Solution (Python):
N, A = map(int, input().split())
x = list(map(int, input().split()))
maxX = max(max(x), A)
dp = [[[0 for _ in range(N * maxX + 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(N + 1):
        for k in range(N * A + 1):
            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]

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()))
Y = [x-A for x in X]
dp = {0:1}

for y in Y:
  tmp = list(dp.items())
  for k,v in tmp:
    dp[k+y]=dp.get(k+y,0)+v

print(dp[0]-1)

Solution (Python):
def abc044_c():
    
    _, A = map(int, input().split())
    X = list(map(lambda x : int(x)-A,input().split()))
    
    d = {0:1}
    for x in X:
        for k,v in list(d.items()):
            d[k + x] = d.get(k + x,0) + v 
    ans = d[0] - 1 
    print(ans)

if __name__ == '__main__':
    abc044_c()

Solution (Python):

NMAX = 55
T = 2500
N, A = map(int, input().split())
X = list(map(lambda x: int(x) - A, input().split()))

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

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)

Solution (Python):

NMAX = 55

N, A = 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 
for i in range(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)

Solution (Python):

NMAX = 55

N, A = 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 
for i in range(N): 
    for s in range(N*A+1):
        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)

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

dp=[[[0]*(2550) 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 sm in range(n*a+1):
            if dp[i][j][sm]==0:
                continue
            dp[i+1][j][sm]+=dp[i][j][sm]
            dp[i+1][j+1][sm+x[i]]+=dp[i][j][sm]

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

Solution (Python):
def solve():
    N, A = map(int, input().split())
    X = list(map(int, input().split()))
 
    dp = [[0] * (A * N + 1) for _ in range(N + 1)]
    dp[0][0] = 1
    for i, x in enumerate(X):
        for j in reversed(range(1, i + 2)):
            for a in range(x, A * N + 1):
                dp[j][a] += dp[j - 1][a - x]
    print(sum(dp[i][A * i] for i in range(1, N + 1)))
 
solve()

Solution (Python):
N, A = map(int, input().split())
x = list(map(int, input().split()))
maxX = max(max(x), A)
dp = [[[0 for _ in range(N * maxX + 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(N + 1):
        for k in range(N * A + 1):
            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]

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()))
maxX = max(max(x), A)
dp = [[[0 for _ in range(N * maxX + 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(N + 1):
        for k in range(N * A + 1):
            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]

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

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, a = map(int, input().split())
    X = list(map(int, input().split()))
    MAX = n * a
    dp = [[[0] * (MAX + 1) for _ in range(n + 1)] for _ in range(n + 1)]
    dp[0][0][0] = 1
    for i in range(1, n + 1):
        x = X[i - 1]
        for k in range(n):
            for s in range(MAX):
                dp[i][k][s] += dp[i - 1][k][s]
                if s + x <= MAX:
                    dp[i][k + 1][s + x] += dp[i - 1][k][s]
    res = 0
    for k in range(1, n + 1):
        res += dp[-1][k][a * k]
    print(res)


if __name__ == '__main__':
    resolve()

Solution (Python):
def abc044_c():
    N, A = map(int, input().split())
    X = list(map(lambda x: int(x) - A, input().split()))  
    dp = [dict() for _ in range(N+1)]  
    dp[0][0] = 1  
    for i, x in enumerate(X):
        dp[i+1] = dp[i].copy()  
        for val, cnt in dp[i].items():
            dp[i+1][val + x] = dp[i].get(val + x, 0) + cnt  
    ans = dp[N][0] - 1
    print(ans)

if __name__ == '__main__':
    abc044_c()

Solution (Python):
def abc044_c():
    ''' 過去提出を参考に '''
    _, A = map(int, input().split())
    X = list(map(lambda x: int(x) - A, input().split()))
    d = {0: 1}  
    for x in X:
        prev = list(d.items())  
        for val, cnt in prev:
            d[val + x] = d.get(val + x, 0) + cnt
    ans = d[0] - 1
    print(ans)

if __name__ == '__main__':
    abc044_c()

Solution (Python):
def abc044_c():
    import numpy as np
    n, a = map(int, input().split())
    x = list(map(lambda x: int(x) - a, input().split()))  
    x = np.array(x, dtype=np.int64)

    vrange = n * (a + np.max(x))  
    dp = np.zeros((n+1, 2*vrange+1), dtype=np.int64)  
    dp[0, vrange] = 1  

    for i in np.arange(n):
        
        dp[i+1, :] += dp[i, :]
        if 0 < x[i]:
            
            dp[i+1, x[i]:] += dp[i, :-x[i]]
        elif x[i] < 0:
            
            dp[i+1, :x[i]] += dp[i, -x[i]:]
        else:
            
            dp[i+1, :] += dp[i, :]

    ans = dp[n, vrange] - 1  
    print(ans)

if __name__ == '__main__':
    abc044_c()

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

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

maxint = 50 * N

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

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

for xi, xe in enumerate(x, 1):
    for j in range(xi+1):
        for k in range(maxint + 1):
            dp[xi][j][k] = dp[xi - 1][j][k]
            
            if j >= 0 and k >= xe:
                dp[xi][j][k] += dp[xi - 1][j - 1][k - xe]
                

res = 0

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

print(res)

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

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

maxint = 50 * N

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

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

for xi, xe in enumerate(x, 1):
    for j in range(xi+1):
        for k in range(maxint + 1):
            dp[xi][j][k] = dp[xi - 1][j][k]
            
            if j >= 0 and k >= xe:
                dp[xi][j][k] += dp[xi - 1][j - 1][k - xe]
                

res = 0

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

print(res)

Solution (Python):
import numpy as np

n, a = map(int, input().split())
x = list(map(int, input().split()))
MAX = 50 * n

dp = np.zeros((n + 1, MAX + 1), np.int64)
dp[0][0] = 1

for e in x:
    dp[1:, e:] += dp[:-1, :-e]

cnt = np.arange(1, n + 1)
sm = cnt * a
ans = dp[cnt, sm].sum()

print(ans)

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

dp = [[[0] * (MAX + 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(i):
        for k in range(MAX + 1):
            dp[i][j][k] += dp[i-1][j][k]

    for j in range(i):
        for k in range(MAX - e + 1):
            dp[i][j+1][k+e] += dp[i-1][j][k]

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

print(ans)

Solution (Python):
import collections
N, A = [int(_) for _ in input().split()]
X = [int(_) for _ in input().split()]


def calc(W):
    
    M = len(W)
    dp = [collections.defaultdict(int) for _ in range(M + 1)]
    dp[0][0] = 1
    for i, w in enumerate(W):
        for j in range(i, -1, -1):
            for k, v in dp[j].items():
                dp[j + 1][k + w] += v
    return dp


dpx = calc(X)
print(sum(dpx[i][i * A] for i in range(1, N + 1)))

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


dp = np.zeros((n+1, n+1, 3001)).astype(np.int64)
dp[0][0][0] = 1

for i in range(n):
    _x = x[i]
    for j in range(n):
        dp[i+1, j+1, _x:] += dp[i, j, :-_x]
        dp[i+1, j, :] += dp[i, j, :]

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