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, = map(int, input().split())
MAX = max(max(X), A) * N
X = [x - A for x in X]

dp = {i: {j: 0 for j in range(2*MAX+1)} for i in range(N+1)}
dp[0][MAX] = 1
for i in range(1, N+1):
    for j in range(2*MAX+1):
        t = j - X[i-1]
        dp[i][j] = dp[i-1][j] + (dp[i-1][t] if 0 <= t <= 2*MAX else 0)
print(dp[N][MAX]-1)

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



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

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

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

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 = [int(a) for a in input().split()]
PO = [x-A for x in X if x > A]
NE = [A-x for x in X if x < A]
ZE = N - len(PO) - len(NE)

Y = [1] + [0] * 3000
Z = [1] + [0] * 3000

for i in PO:
    for j in range(2800)[::-1]:
        Y[i+j] += Y[j]
for i in NE:
    for j in range(2800)[::-1]:
        Z[i+j] += Z[j]

ans = -1
for i in range(len(Y)):
    ans += Y[i] * Z[i] * (2**ZE)
print(ans)

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

memo = {0:1}
for x in X:
    for k, v in list(memo.items()):
        memo[x + k] = memo.get(x + k, 0) + v

print(memo[0] - 1)

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

Solution (Python):
import sys
n, a = map(int, sys.stdin.readline().split())
x = list(map(int, sys.stdin.readline().split()))
dp = [[[0 for s in range(n*50 +1)] for k in range(n+1)] for j in range(n+1)]
from pprint import pprint


for k in range(n+1):
    for s in range(n*50+1):
        dp[0][k][s] = 0

dp[0][0][0] = 1
for j in range(1,n+1):
    for k in range(n+1):
        for s in range(n*50+1):
            
            if 1 <= j and s < x[j-1]:
                dp[j][k][s] = dp[j-1][k][s]
            elif 1 <= j and 1 <= k and x[j-1] <= s:
                dp[j][k][s] = dp[j-1][k][s] + dp[j-1][k-1][s-x[j-1]]
            else:
                dp[j][k][s] = 0
sum = 0
for k in range(1,n+1):
    sum += dp[n][k][k*a]
print(sum)

Solution (Python):
from collections import defaultdict
import copy
x=[]
d=defaultdict(int)
n,a=map(int,input().split())
dp=[[0]*n*51 for _ in range(n)]
for i in input().split():
    x.append(int(i)-a)
for i in x:
    tmp=copy.copy(d)
    for j in tmp:
        d[j+i]+=tmp[j]
    d[i]+=1
ans=d[0]
print(ans)

Solution (Python):
n,a=map(int,input().split())
X=[int(i) for i in input().split()]
DP=[[[0 for i in range(50*n+1)] for i in range(n+1)] for i in range(n+1)]
DP[0][0][0]=1
for i in range(1,n+1):
  for j in range(i+1):
    for s in range(50*j+1):
      DP[i][j][s]=DP[i-1][j][s]+DP[i-1][j-1][s-X[i-1]]
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=[i-a for i in x]
memo=[[-1]*6000 for i in range(60)]
def dp(k, value):
    if k==n:
        if value==0:
            return 1
        else:
            return 0
    if memo[k][value]>=0:
        return memo[k][value]
    memo[k][value]=dp(k+1, value+x[k])+dp(k+1, value)
    return memo[k][value]
print(dp(0, 0)-1)

Solution (Python):
import numpy as np
hi = np.zeros((5000,60),np.int64)
hi[0,0]=1
n,a = [int(it) for it in input().split()]
li = [int(it) for it in input().split()]
for i in li:
    hi_ = hi.copy()
    hi[i:-1,1:]+=hi_[:-1-i,:-1]
s = 0
for i in range(n):
  s+=hi[(i+1)*a,i+1]
print (s)

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


def make_matrix():
    dp = [
        [
            [0] * ((n + 1) * max(max(xlist), a)) for _ in range(n + 1)
        ] for _ in range(n + 1)
    ]



def submit():
    n, a, xlist = read_input()

    dp = [
        [
            [0] * ((n + 1) * max(max(xlist), a)) for _ in range(n + 1)
        ] for _ in range(n + 1)
    ]











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

    for j in range(n + 1):
        for k in range(n + 1):
            for s in range((n + 1) * max(xlist)):
                if j > 0 and xlist[j - 1] > s:
                    dp[j][k][s] = dp[j - 1][k][s]
                elif j > 0 and k > 0 and xlist[j - 1] <= s:
                    dp[j][k][s] = dp[j - 1][k][s] + dp[j - 1][k - 1][s - xlist[j - 1]]

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

    print(int(methods))


if __name__ == '__main__':
    submit()

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

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

for j in range(n+1):
    for k in range(n+1):
        for s in range(2555):
            if j > 0 and x[j-1] > s:
                dp[j][k][s] = dp[j-1][k][s]
            elif j > 0 and k >= 1 and s >= x[j-1]:
                dp[j][k][s] = dp[j-1][k][s] + dp[j-1][k-1][s-x[j-1]]

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


def full(shape, value):
    if not shape:
        return value
    return [full(shape[1:], value) for _ in range(shape[0])]

minus_cnt = 0
plus_cnt = 0
for v in x:
    if v < 0:
        minus_cnt -= v
    elif v > 0:
        plus_cnt += v

dp = full((n + 1, minus_cnt + plus_cnt + 5, n + 1), None)
def dfs(k, s=0, depth=n - 1): 
    if dp[k][s][depth] is not None:
        return dp[k][s][depth]
    if k == 0:
        if s == 0:
            result = 1
        else:
            result = 0
        dp[k][s][depth] = result
        return result
    if depth == -1:
        dp[k][s][depth] = 0
        return 0
    result = dfs(k - 1, s + x[depth], depth - 1) + dfs(k, s, depth - 1)
    dp[k][s][depth] = result
    return result

result = 0
for i in range(1, n + 1):
    result += dfs(i)
print(result)

Solution (Python):
n,a=map(int,input().split())
m=list(map(lambda x:int(x)-a,input().split()))
x=max(abs(max(m)),abs(min(m)))*n
dp=[[0for _ in range(2*x+1)]for i in range(n)]
dp[0][0+x]+=1
dp[0][m[0]+x]+=1
for i in range(1,n):
  y=m[i]
  for j in range(2*x+1):
    if 0<=j+y and j+y<2*x+1:
      dp[i][j+y]+=dp[i-1][j]
    dp[i][j]+=dp[i-1][j]
  
print(max(0,dp[n-1][0+x]-1))

Solution (Python):
n,a=map(int,input().split())
X=list(map(int,input().split()))
m=max(X)
Y=map(lambda x:x-a,X)
DP=[[0]*(2*m*n+1) for _ in range(n+1)]
DP[0][m*n]=1
for i,y in enumerate(Y):
    for j in range(2*m*n+1):
        DP[i+1][j]=DP[i][j]
        if 0<=j-y<=2*m*n:
            DP[i+1][j]+=DP[i][j-y]
print(DP[n][m*n]-1)

Solution (Python):
n,a=map(int, input().split())
x=list(map(int, input().split()))
x=[i-a for i in x]
d={0:1}
for i in x:
    for j,k in list(d.items()):
        d[i+j]=d.get(i+j,0)+k
print(d[0]-1)

Solution (Python):
n, a = map(int, input().split())
x=list(map(lambda x: int(x)-a, input().split()))
k=[[0]*3000 for i in range(60)]
for i in range(3000):
    k[0][i]=0
k[0][x[0]+1500]+=1
k[0][1500]+=1
for i in range(1, n):
    for j in range(3000):
        if 3000>j-x[i]>=0:
            k[i][j]=k[i-1][j-x[i]]+k[i-1][j]
        else:
            k[i][j]=k[i-1][j]
print(k[n-1][1500]-1)

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

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

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

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

print(ans)

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

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

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

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

d = {0:1}  

for x in X:
    d_tmp = d.copy()
    for k in d_tmp:        
        d[k+x] = d.get(k+x,0)+d_tmp[k]
print(d[0]-1)

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

z = 0 
dic = {}

for x in X:
    if x==0:
        z += 1
    else:
        dic[x] = dic.get(x,0) + 1
            
line = {}
line[0] = 1

for k in dic:    
    line_k = {}
    for i in range(dic[k]+1):
        line_k[k*i] = 1      
        for j in range(dic[k],dic[k]-i,-1):
            line_k[k*i] *= j
        for j in range(1,1+i):
            line_k[k*i] //= j
    line_tmp = {}
    for k_lk in line_k:
        for k_l in line:
            line_tmp[k_lk+k_l] = line_tmp.get(k_lk+k_l,0) + line_k[k_lk] * line[k_l]
    line = line_tmp.copy()
    
print(line[0] * (2**z) -1)

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

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

L = [[0 for i in range(10002)] for j in range(N)]
for i in range(N):
	L[i][5001 + x[i]] = 1

for i in range(N - 1):
	for j in range(10002):
		if L[i][j] != 0:
			L[i + 1][j] += L[i][j]
			L[i + 1][j + x[i + 1]] += L[i][j]

print(L[N - 1][5001])

Solution (Python):
import bisect
from collections import Counter, deque
from itertools import combinations, accumulate
from math import factorial
from operator import neg
n, a = list(map(int, input().split()))
xs = list(map(lambda x: int(x) - a, input().split()))

xs.sort()
l, r = bisect.bisect_left(xs, 0), bisect.bisect_right(xs, 0)
low, n0, high = list(map(neg, xs[:l][::-1])), r - l, xs[r:]

def sums(arr):
    cntr = Counter([0])
    for v in arr:
        tmps = tuple(cntr.items())
        for u, cnt in tmps:
            cntr[u + v] += cnt
    del cntr[0]
    return cntr

lsums = sums(low)
hsums = sums(high)

ans = sum(hsums[a] * b for a, b in lsums.items())

ans *= 2 ** n0
ans += 2 ** n0 - 1

print(ans)

Solution (Python):
def inpl():
    return list(map(int, input().split()))


N, A = inpl()
X = inpl()
maxX = max(X)

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

dp[0][0][0] = 1
for i in range(N):
    x = X[i - 1]
    for j in range(i + 1):
        for k in range(N * maxX + 1):
            
            if dp[i][j][k] == 0:
                continue
            dp[i + 1][j][k] += dp[i][j][k]
            dp[i + 1][j + 1][k + x] += dp[i][j][k]

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

Solution (Python):
n,a=map(int,input().split())
x=list(map(int,input().split()))
p=max(max(x),a)
s=[i-a for i in x]
dp=[[0]*(2*n*p+1) for i in range(n+1)]
dp[0][n*p]=1
for i in range(1,n+1):
    for j in range(2*n*p+1):
        if j-s[i-1]<0 or j-s[i-1]>2*p*n:
            dp[i][j]=dp[i-1][j]
        else:
            dp[i][j]=dp[i-1][j]+dp[i-1][j-s[i-1]]
print(dp[n][n*p]-1)

Solution (Python):
def makelist2(n,m):
    return[[0 for k in range(m)]for i in range(n)]

n,a = map(int,input().split())
x = list(map(int,input().split()))
X = max(x)
X = max(X,a)
b=[]
for i in range(n):
    b.append(x[i]-a)


dp =makelist2(n+1,2*n*X+1)
dp[0][n*X] = 1
for j in range(n+1):
    for t in range(2*n*X+1):
        if j>=1 and (t-b[j-1] < 0 or t-b[j-1]>2*n*X):
            dp[j][t] = dp[j-1][t]
        elif j>= 1:
            dp[j][t] = dp[j-1][t] + dp[j-1][t-b[j-1]]
print(dp[n][n*X]-1)

Solution (Python):
def makelist2(n,m):
    return[[0 for k in range(m)]for i in range(n)]

n,a = map(int,input().split())
x = list(map(int,input().split()))
X = max(x)
X = max(X,a)
b=[]
for i in range(n):
    b.append(x[i]-a)


dp =makelist2(n+1,2*n*X+1)
dp[0][n*X] = 1
for j in range(n+1):
    for t in range(2*n*X+1):
        if j>=1 and (t-b[j-1] < 0 or t-b[j-1]>2*n*X):
            dp[j][t] = dp[j-1][t]
        elif j>= 1:
            dp[j][t] = dp[j-1][t] + dp[j-1][t-b[j-1]]
print(dp[n][n*X]-1)

Solution (Python):
def makelist(n,m,p):
    return [[[0 for k in range(p)]for i in range(m)]for j in range(n)]

n,a = map(int,input().split())
x = list(map(int,input().split()))
X = max(x)
X = max(X,a)

dp = makelist(n+1,n+1,n*X+1)
dp[0][0][0] = 1
for j in range(n+1):
    for k in range(n+1):
        for s in range(n*X+1):
            if j*k > 0 and s >= x[j-1]:
                dp[j][k][s] = dp[j-1][k][s] + dp[j-1][k-1][s-x[j-1]]
            elif j >= 1 and s < x[j-1]:
                dp[j][k][s] = dp[j-1][k][s]
ans = 0
for k in range(1,n+1):
    ans += dp[n][k][k*a]
print(ans)

Solution (Python):
def makelist(n,m,p):
    return [[[0 for k in range(p)]for i in range(m)]for j in range(n)]

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

dp = makelist(n+1,n+1,n*a+1)
dp[0][0][0] = 1
for j in range(n+1):
    for k in range(n+1):
        for s in range(n*a+1):
            if j*k > 0 and s >= x[j-1]:
                dp[j][k][s] = dp[j-1][k][s] + dp[j-1][k-1][s-x[j-1]]
            elif j >= 1 and s < x[j-1]:
                dp[j][k][s] = dp[j-1][k][s]
ans = 0
for k in range(1,n+1):
    ans += dp[n][k][k*a]
print(ans)

Solution (Python):












import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

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

lower = []
same = 0
upper = []
for x in Xs:
    if x < A:
        lower.append(A - x)
    elif x == A:
        same += 1
    else:
        upper.append(x - A)

def make_counter(nums):
    counter = Counter({0: 1})
    for n in nums:
        new_counter = Counter()
        for k, v in counter.items():
            
            new_counter[k] += v
            new_counter[k + n] += v
        counter = new_counter
    return counter

lower_counter = make_counter(lower)
upper_counter = make_counter(upper)

ans = 0
for lk, lv in lower_counter.items():
    
    if lk == 0:
        
        ans += 2 ** same - 1
    
    else:
        
        if lk in upper_counter:
            ans += (2 ** same) * lv * upper_counter[lk]

print(ans)

Solution (Python):





import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

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

lower = []
same = 0
upper = []
for x in Xs:
    if x < A:
        lower.append(A - x)
    elif x == A:
        same += 1
    else:
        upper.append(x - A)

def make_counter(nums):
    counter = Counter({0: 1})
    for n in nums:
        
        new_counter = Counter()
        for k, v in counter.items():
            new_counter[k] += v
            new_counter[k + n] += v
        counter = new_counter
    return counter

lower_counter = make_counter(lower)
upper_counter = make_counter(upper)

ans = 0
for lk, lv in lower_counter.items():
    
    if lk == 0:
        
        ans += 2 ** same - 1
    
    else:
        
        if lk in upper_counter:
            ans += (2 ** same) * lv * upper_counter[lk]

print(ans)

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

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

na = n*a

DP = [[0]*(na+1) for i in range(n+1)]
DP[0][0] = 1

for _ in range(n):
    x = xs[_]
    next = [[0]*(na+1) for i in range(n+1)]
    for i in range(_+1):
        for j in range(na+1):
            
            next[i][j] += DP[i][j]
            if j+x <= na:
                next[i+1][j+x] += DP[i][j]
    DP = next


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

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

X = max(cards)
X = max(X, A)

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

dp[0][N*X] = 1
for i in range(N):
    for j in range(2*N*X+1):
        c = cards[i]
        if j - c < 0 or j-c > 2*N*X:
            dp[i+1][j] = dp[i][j]
        else:
            dp[i+1][j] = dp[i][j]+dp[i][j-c]


print(dp[N][N*X]-1)

Solution (Python):
N, A = (int(i) for i in input().split())
x = [int(i) for i in input().split()]
sumx = sum(x)
DP = [[[0] * (N+1) for i in range(sumx+1)] for i in range(N+1)]
DP[0][0][0] = 1
for i in range(N):
    for j in range(sumx+1):
        for k in range(i+1):
            if j - x[i] >= 0:
                DP[i+1][j][k+1] += DP[i][j-x[i]][k]
            DP[i+1][j][k] += DP[i][j][k]

res = 0
for i in range(1,N+1):
    if i * A <= sumx:
        res += DP[N][i * A][i]
print(res)

Solution (Python):
n,a,*x=map(int,open(0).read().split())
x=[0]+x
dp=[[[0]*(50*n+1)for j in range(n+1)]for i in range(n+1)]
dp[0][0][0]=1
for i in range(1,n+1):
  dp[i][0]=dp[i-1][0]
  for j in range(1,n+1):
    for k in range(1,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 i in range(1,n+1):
  j=i*a
  if j<50*n+2:
    ans+=dp[-1][i][j]
print(ans)

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

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


X = max(max(x), A)

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

dp[0][N*X] = 1

y = []

for i in range(N):
    tmp = x[i]-A
    y.append(tmp)

for i in range(N):
    for j in range(2*N*X+1):
        if j-y[i]<0 or j-y[i]>2*N*X:
            dp[i+1][j] = dp[i][j]
        else:
            dp[i+1][j] = dp[i][j] + dp[i][j-y[i]]
            
print(dp[N][N*X]-1)

Solution (Python):


II = lambda: int(input())
MI = lambda: map(int, input().split())


def sumcnt(values):
    sc = [0] * (50 * 50 + 1)
    sc[0] = 1
    max_sc = 0
    for v in values:
        for i in range(max_sc, -1, -1):
            sc[i + v] += sc[i]
        max_sc += v
    return sc, max_sc


def main():
    N, A = MI()
    ds = [x-A for x in MI()]

    count0 = 0
    dp, dm = [], []
    for d in ds:
        if d == 0: count0 += 1
        elif d > 0: dp.append(d)
        else: dm.append(-d)
    dp.sort()
    dm.sort()

    scp, scpmax = sumcnt(dp)
    scm, scmmax = sumcnt(dm)

    ans = 0
    for i in range(1, min(scpmax, scmmax) + 1):
        ans += scp[i] * scm[i]
    ans = ans * (2**count0) + 2**count0 - 1
    return ans


if __name__ == "__main__":
    print(main())

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

X=list(map(int,input().split()))
x=[]
for i in range(N):
    x.append(X[i]-A)

L=[0 for i in range(5001)]
L[2500]=1

for i in range(N):
    if x[i]>=0:
        for j in range(5001):
            if L[5000-j]>0:
                L[5000-j+x[i]]+=L[5000-j]
    elif x[i]<0:
        for j in range(5001):
            if L[j]>0:
                L[j+x[i]]+=L[j]
print(L[2500]-1)

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

ans_map = [[0 for i in range(50*(j+1)+1)] for j in range(N)]
count = 0
for n in X:
    count += 1
    for x in range(0, count)[::-1]:
        for y in range(len(ans_map[x])):
            if ans_map[x][y] != 0:
                ans_map[x+1][y+n] += ans_map[x][y]
    ans_map[0][n] += 1
ans = 0
for i in range(N):
    ans += ans_map[i][A*(i+1)]
print(ans)

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

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


X = max(max(x), A)

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

dp[0][N*X] = 1

y = []

for i in range(N):
    tmp = x[i]-A
    y.append(tmp)

for i in range(N):
    for j in range(2*N*X+1):
        if j-y[i]<0 or j-y[i]>2*N*X:
            dp[i+1][j] = dp[i][j]
        else:
            dp[i+1][j] = dp[i][j] + dp[i][j-y[i]]
            
print(dp[N][N*X]-1)

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

dp = [[[0 for i in range(2555)] for j in range(55)] for k in range(55)]

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

for i in range(N):
    for j in range(N):
        for k in range(2501):
            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]

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

Solution (Python):
from collections import defaultdict
H = defaultdict(lambda: 0)
H[0] = 1
def inpl(): return [int(i) for i in input().split()]
N, A = inpl()
x = inpl()
x = [i-A for i in x]
H[0]= 1
for i in x:
    for ni,nv in H.copy().items():
        H[ni+i] += nv
print(H[0]-1)

Solution (Python):
(n, a) = list(map(int, input().split()))
x = list(map(int, input().split()))
plus = []
minus = []
zero = 0
for i in range(n):
    x[i] -= a
    if x[i] > 0:
        plus.append(x[i])
    elif x[i] < 0:
        minus.append(x[i])
    else:
        zero += 1


map_plus = {}
map_minus = {}

for i in plus:
    tmp_map = map_plus.copy()
    if i in map_plus:
        tmp_map[i] += 1
    else:
        tmp_map[i] = 1
    for j in map_plus:
        if j + i in map_plus:
            tmp_map[j + i] += map_plus[j]
        else:
            tmp_map[j + i] = map_plus[j]
    map_plus = tmp_map

for i in minus:
    tmp_map = map_minus.copy()
    if i in map_minus:
        tmp_map[i] += 1
    else:
        tmp_map[i] = 1
    for j in map_minus:
        if j + i in map_minus:
            tmp_map[j + i] += map_minus[j]
        else:
            tmp_map[j + i] = map_minus[j]
    map_minus = tmp_map

count = 1
for i in map_minus:
    if i * -1 in map_plus:
        count += map_minus[i] * map_plus[i * -1]

print(count * 2 ** zero - 1)

Solution (Python):
n,a = map(int,input().split())
x = list(map(int,input().split()))
x = [t-a for t in x]
p = [0]*5010
p[0] = 1
q = [0]*5010
for t in x:
  for i in range(5010):
    q[i] = p[i] + p[(i-t)%5010] 
  for i in range(5010):
    p[i] = q[i]
print(p[0]-1)

Solution (Python):
n,a=map(int, input().split())
x=list(map(int, input().split()))
x=[i-a for i in x]
d={0:1}
for i in x:
    for j,k in list(d.items()):
        d[i+j]=d.get(i+j,0)+k
print(d[0]-1)

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

sumX = sum(xs)


dp = [[0] * (sumX + 1) for _ in range(N + 1)]
dp[0][0] = 1
for k, x in enumerate(xs):
    for i in reversed(range(k + 1)):
        for j in range(sumX + 1):
            if dp[i][j] == 0: continue
            dp[i + 1][j + x] += dp[i][j]


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

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

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

dp[0][n * max_x] = 1
for i in range(1, n + 1):
    for j in range(1, n * 2 * max_x + 1):
        if 0 <= j + a - x[i - 1] <= 2 * n * max_x:
            dp[i][j] = dp[i - 1][j] + dp[i - 1][j + a - x[i - 1]]
        else:
            dp[i][j] = dp[i - 1][j]

print(dp[n][n * max_x] - 1)

Solution (Python):
from collections import defaultdict

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


dp = [defaultdict(int) for _ in range(N + 1)]
dp[0][0] = 1
for i in range(N):
    for key in dp[i]:
        dp[i + 1][key + x[i]] += dp[i][key]
        dp[i + 1][key] += dp[i][key]

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

Solution (Python):
f = lambda: list(map(int,input().split()))

n,a = f()
x = [int(x)-a for x in input().split()]
w = max(max(x),abs(min(x)),a)*n
dp = [[0 for _ in range(2*w + 1)] for _ in range(n+1)]
dp[0][w] = 1
for i in range(n):
    for j in range(2*w + 1):
        if 0 <= j-x[i] <= 2*w:
            dp[i+1][j] = dp[i][j-x[i]] + dp[i][j]
        else:
            dp[i+1][j] = dp[i][j]

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

Solution (Python):
from collections import defaultdict
N,K=map(int,input().split())
A=[int(i) for i in input().split()]
dd=defaultdict(int)
dd[0]+=1
for i in range(N):
    dd1=defaultdict(int)
    for s,v in dd.items():
        dd1[s+A[i]-K]+=v
        dd1[s]+=v
    dd=dd1
print(dd[0]-1)

Solution (Python):
def main():
    t = input().split(" ")
    N, A= int(t[0]), int(t[1])

    t = input().split(" ")
    x_p = []
    x_n = []
    x_z = 0
    for i in t:
        i = int(i)
        if A < i:
            x_p.append(i - A)
        elif i < A:
            x_n.append(A - i)
        else:
            x_z += 1
    x_p.sort()
    x_n.sort()
    x_p_sum=[{0:1}]
    x_n_sum=[{0:1}]
    for i in range(len(x_p)):
        x_p_sum.append({})
        for j in sorted(x_p_sum[i]):
            if j in x_p_sum[i+1]:
                x_p_sum[i+1][j] += x_p_sum[i][j]
            else:
                x_p_sum[i+1][j] = x_p_sum[i][j]
            x_p_sum[i+1][j+x_p[i]] = x_p_sum[i][j]
    for i in range(len(x_n)):
        x_n_sum.append({})
        for j in sorted(x_n_sum[i]):
            if j in x_n_sum[i+1]:
                x_n_sum[i+1][j] += x_n_sum[i][j]
            else:
                x_n_sum[i+1][j] = x_n_sum[i][j]
            x_n_sum[i+1][j+x_n[i]] = x_n_sum[i][j]
    sum = 0
    for i in x_n_sum[-1]:
        if i in x_p_sum[-1]:
            sum += (x_n_sum[-1][i] * x_p_sum[-1][i])
    sum *= 2**x_z
    sum -= 1
    print(sum)
main()

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

d = {}
d[0] = 1
for i in x:
    for j,k in list(d.items()):
        d[j+i] = d.get(j+i,0)+k
print(d[0]-1)

Solution (Python):


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

Solution (Python):
n, a = list(map(int, input().split()))
x = list(map(int, input().split()))
y = [ele-a for ele in x]
m = n*max(a, max(x))
dp = [[0 for _ in range(2*m+1)]for _ in range(n+1)]
dp[0][m] = 1
for j in range(1, n+1):
  for t in range(2*m+1):
    if t-y[j-1]<0 or 2*m<t-y[j-1]:
      dp[j][t] = dp[j-1][t]
    elif 0<=t-y[j-1]<=2*m:
      dp[j][t] = dp[j-1][t] + dp[j-1][t-y[j-1]]
print(dp[n][m]-1)

Solution (Python):
from collections import defaultdict

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

x = [x - A for x in x]

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

for x_i in x:
    copy = dict(counter)
    for d, c in copy.items():
        counter[d+x_i] += c

print(counter[0]-1)

Solution (Python):
n, a = map(int, raw_input().split())
f = [0 for i in range(6000)]
f[0] = 1
for x in map(int, raw_input().split()):
	x -= a
	g = f[::]
	for i in range(-3000, 3000):
		g[i + x] += f[i]
	f = g
print g[0] - 1

Solution (Python):


'''
直感的には？
- dp[i][t] = dp[i-1][t]+dp[i-1][t-X[i-1]]
    取らなかった場合の数＋取ってこの値にした場合の数
    t=0で-2を取るか取らないかを迫られた時、取ればt=+2から2引いてt=0に来て、取らねばt=0はt=0から来る
- dp[i][t] = dp[i-1][t]
    取らなかった場合の数で、
    「起こり得ない数からの遷移はしない」と考えた場合dp[i-1][t-X[i-1]]が不要になるというだけ
    無理に取ろうとすると配列外参照となる
- dp[0][N*MX] = 1
    初期状態では当然、平均は0なので
- それ以外
    i=0の時しかないが、初期状態で平均が他の値になることはない
'''

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

MX = max(X+[0])

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

for i in range(N+1):
    for t in range(2*MX*N+1):
        if i==0 and t==N*MX:
            dp[i][t] = 1
        elif i>=1:
            if t-X[i-1]>=0 and t-X[i-1]<=2*MX*N:
                dp[i][t] = dp[i-1][t]+dp[i-1][t-X[i-1]]
            else:
                dp[i][t] = dp[i-1][t]
        else:
            dp[i][t] = 0
    
print(dp[N][N*MX]-1)

Solution (Python):
from copy import deepcopy

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

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

cnt = [0] * 5000

for x in X:
    cnt2 = [0] * 5000
    for i in range(-2500, 2500):
        cnt2[i + x] += cnt[i]
    cnt2[x] += 1
    for i in range(5000):
        cnt2[i] += cnt[i]
    cnt = deepcopy(cnt2)

print(cnt[0])

Solution (Python):
n,a=map(int,input().split())
x=list(map(int,input().split()))
y=[]
for i in x:
  y.append(i-a)
s=2*n*a
dp=[[0 for i in range(s+1)] for j in range(n+1)]
dp[0][n*a]=1
for i in range(n):
  for j in range(s+1):
    x=j-y[i]
    if(0<=x and x<=2*n*a):
      dp[i+1][j]=dp[i][j-y[i]]+dp[i][j]
    else:
      dp[i+1][j]=dp[i][j]

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

Solution (Python):
N, A = map(int, input().split())
X = list(map(int, input().split()))
for i in range(N):
  X[i] -= A
X.sort()

p = { 0: 1 }
for x in X:
  for n, count in list(p.items()):
    if n+x <= 0:
      p[n+x] = p.get(n+x, 0) + count

print(p[0] - 1)