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()))
dp = [[[0 for _ in range(50*(N+2))] for _ in range(N+2)] for _ in range(N+2)]

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

for k in range(N):
    
    for used in range(N):
        for i in range(50*N):
            
            if dp[used][k][i] == 0: 
                continue
            dp[used+1][k+1][i+X[k]] += dp[used][k][i]
            dp[used][k+1][i] += dp[used][k][i]
ans = 0
for used in range(1,N+1):
    ans += dp[used][N][used*A]
print(ans)

Solution (Python):
N,A = map(int,input().split())
X = list(map(int,input().split()))
dp = [[[0 for _ in range(50*(N+2))] for _ in range(N+2)] for _ in range(N+2)]

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

for k in range(N):
    
    for used in range(N):
        for i in range(50*N):
            
            if dp[used][k][i] == 0: 
                continue
            dp[used+1][k+1][i+X[k]] += dp[used][k][i]
            dp[used][k+1][i] += dp[used][k][i]
ans = 0
for used in range(1,N+1):
    ans += dp[used][N][used*A]
print(ans)

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

slist=[0]
for x in xlist:
  slist.append(slist[-1]+x)


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


answer=0
for j in range(1,N+1):
  if j*A>sum(xlist):
    break
  answer+=dp[N][j][j*A]
  
print(answer)

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

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


answer=0
for j in range(1,N+1):
  if j*A>sum(xlist):
    break
  answer+=dp[N][j][j*A]
  
print(answer)

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

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


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

Solution (Python):




from itertools import combinations


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










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

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

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

dp=[[0]*5001 for i in range(n+1)]
dp[0][2500]=1
for i in range(n):
    for j in range(5000):
        for k in range(2):
            if 0<=j-k*x[i]<=5000:
                dp[i+1][j]+=dp[i][j-k*x[i]]
print(dp[n][2500]-1)

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

dp=[[0]*5001 for i in range(n)]
dp[0][x[0]+2500]=1
for i in range(1,n):
    dp[i][x[i]+2500]=1
    for j in range(5000):
        for k in range(2):
            if 0<=j-k*x[i]<=5000:
                dp[i][j]+=dp[i-1][j-k*x[i]]
print(dp[n-1][2500])

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

Solution (Python):
import sys
import numpy as np
def sinput(): return sys.stdin.readline()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(): return list(imap())
def farr(): return list(fmap())
def sarr(): return sinput().split()

n, a = imap()
x = np.array(iarr()) - a
MAX = 50*50+1

dp = np.zeros((n+1, 2*MAX+1)).astype(int)
dp[0][MAX] = 1
for i in range(n):
    for j in range(2*MAX):
        if j-x[i] < 0 or j-x[i] > 2*MAX:
            dp[i+1][j] = dp[i][j]
        else:
            dp[i+1][j] = dp[i][j] + dp[i][j-x[i]]
print(dp[n][MAX]-1)

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


dp = [[0]*5001 for _ in range(N+1)]
dp[0][y[0]+2500] = 1
dp[0][2500] += 1
for i in range(N-1):
    new = y[i+1]
    for j in range(5001):
        dp[i+1][j] += dp[i][j]
        if 0 <= j+new <= 5000:
            dp[i+1][j+new] += dp[i][j]
print(dp[N-1][2500]-1)

Solution (Python):
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
import copy as cp
import sys
def sinput(): return sys.stdin.readline()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(): return list(imap())
def farr(): return list(fmap())
def sarr(): return sinput().split()

n,a = imap()
x = np.array(iarr()) - a





dp = np.zeros((n+1, 50*n+1)).astype(int)
dp[0][n*a] = 1

for i in range(n):
    for s in range(50*n+1):
        dp[i+1][s] = dp[i][s] + dp[i][s-x[i]] if 50*n>= s-x[i] >=0 else dp[i][s]

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

Solution (Python):

import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N,A=map(int,input().split())
    x=list(map(int,input().split()))
    dp=[[[0]*2501 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 k in range(2501):
                dp[i+1][j][k]+=dp[i][j][k]
                if k-x[i]>=0 and j<=i:
                    dp[i+1][j+1][k]+=dp[i][j][k-x[i]]
    ans=0
    for i in range(1,N+1):
        ans+=dp[-1][i][i*A]
    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
import copy as cp
import sys
def sinput(): return sys.stdin.readline()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(): return list(imap())
def farr(): return list(fmap())
def sarr(): return sinput().split()

n,a = imap()
x = np.array(iarr()) - a





dp = np.zeros((n+1, 50*n+100)).astype(int)
dp[0][n*a] = 1

for i in range(n):
    for s in range(50*n+1):
        dp[i+1][s] = dp[i][s] + dp[i][s-x[i]] if s-x[i]>=0 else dp[i][s]

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

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

Solution (Python):
import numpy as np
n,avea=tuple(map(lambda x:int(x),input().split()))
x=list(map(lambda x:int(x), input().split()))
x=np.array(x)
x=x-avea
w=max(abs(min(x)),abs(max(x)))*n
dp=np.zeros((n+1,2*w+1),dtype=int)
dp[0,w]=1
for i in range(1,n+1):
    for j in range(2*w+1):
        if 0<=j-x[i-1]<=2*w:
            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,w]-1)

Solution (Python):
import numpy as np
n,avea=tuple(map(lambda x:int(x),input().split()))
x=list(map(lambda x:int(x), input().split()))
x=np.array(x)
x=x-avea
w=max(abs(min(x)),abs(max(x)))*n
dp=np.zeros((n+1,2*w+1),dtype=int)
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]+dp[i,j-x[i]]
        else:
            dp[i+1,j]=dp[i,j]
print(dp[n,w]-1)

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

dp = [[[0] * n for i in range(n * a + 1)] for i in range(n)]
for i in range(n):
    for j in range(n * a + 1):
        for k in range(n):
            if i == 0 and x[0] < n * a + 1:
                dp[0][x[0]][0] = 1
                break
            else:
                if j == 0:
                    if k == 0 and x[i] < n * a + 1:
                        dp[i][x[i]][0] += 1
                    continue

                if dp[i - 1][j][k] == 0:continue
                dp[i][j][k] += dp[i - 1][j][k]
                if not(0 <= j + x[i] < n * a + 1):continue
                dp[i][j + x[i]][k + 1] += dp[i - 1][j][k]
cnt = 0
for i in range(n * a + 1):
    if i != 0 and i % a == 0:
        temp = i // a
        cnt += dp[-1][i][temp - 1]
print(cnt)

Solution (Python):


import sys






















def main():
    mod = 1000000007                
    inf = float('inf')              
    
    sys.setrecursionlimit(10**6)    
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    n, a = mi()
    L = lmi()
    diff = [elm - a for elm in L]
    
    dp = [[0] * 5001 for _ in range(n + 1)]
    dp[0][2500] = 1

    for i in range(n):
        for j in range(5001):
            if dp[i][j]:
                dp[i+1][j + diff[i]] += dp[i][j]
            dp[i+1][j] += dp[i][j]
    

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


if __name__ == "__main__":
    main()

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

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

d = [0] * 6000
ans = 0
for dif in x:
  ans += d[-dif+3000]
  if dif == 0:
    ans += 1
  if dif < 0:
    for i in range(6000):
      if 0 <= i+dif < 6000:
        d[i+dif] += d[i]
  else:
    for i in range(5999, -1, -1):
      if 0 <= i+dif < 6000:
        d[i+dif] += d[i]
  d[dif+3000] = d[dif+3000] + 1
  
print(ans)

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

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

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

dp[0][n*50]=1

for i in range(n):
    for j in range(n*50*2):
        t=j-x[i]
        if 0<=t<n*50*2:
            dp[i+1][j]=dp[i][j]+dp[i][t]
        else:
            dp[i+1][j]=dp[i][j]
print(dp[n][n*50]-1)

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

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

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

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

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

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

print(ans)

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

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

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


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

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

print(ans)

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

Solution (Python):
n,a = map(int,input().split())
x = list(map(int,input().split()))
t = [[[0] * (50*(j+1)+1) for j in range(i+2)] for i in range(n+1)]
ans = 0
t[0][0][0] = 1

for i in range(1, n+1):
    for j in range(i+1):
        for k in range(50*j + 1):
            if j >= 1 and k >= x[i-1]:
                t[i][j][k] = t[i - 1][j - 1][k - x[i-1]] + t[i - 1][j][k]
            else:
                t[i][j][k] = t[i - 1][j][k]
for i in range(1,n+1):
    ans += t[n][i][i*a]
print(ans)

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

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


if __name__ == '__main__':
    main()

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

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

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

Solution (Python):
n, a = map(int, input().split())
xxx = list(map(int, input().split()))
limit = a * n
dp = [[0] * (limit + 1) for i in range(n + 1)]
dp[0][0] = 1
for i, x in enumerate(xxx):
    if x > limit:
        continue
    for j in range(i, -1, -1):
        for k in range(limit - x, -1, -1):
            dp[j + 1][k + x] += dp[j][k]

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

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

dp = [[[0] * 2501 for _ in range(51)] for _ in range(51)]
dp[0][0][0] = 1

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

Solution (Python):
def resolve():
    N, A = list(map(int, input().split()))
    X = [int(i) - A for i in input().split()]
    d = {0: 1}
    for x in X:
        for _sum, count in list(d.items()):
            d[_sum+x] = d.get(_sum+x, 0) + count

    print(d[0]-1)
    


if '__main__' == __name__:
    resolve()

Solution (Python):
n,a=map(int,input().split())
nums=[int(i)-a for i in input().split()]
d={0:1}
for i in nums:
  s = [[j, d[j]] for j in d]
  for j in s:
    if j[0] + i in d:
      d[j[0]+i] += j[1]
    else:
      d[j[0]+i] = j[1]
print(d[0]-1)

Solution (Python):
import sys
import heapq
import re
from itertools import permutations
from bisect import bisect_left, bisect_right
from collections import Counter, deque
from fractions import gcd
from math import factorial, sqrt, ceil
from functools import lru_cache, reduce
INF = 1 << 60
MOD = 1000000007
sys.setrecursionlimit(10 ** 7)


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


def dijkstra_heap(s, edge, n):
    
    d = [10**20] * n
    used = [True] * n 
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr


def lcm(x, y):
    return (x * y) // gcd(x, y)


def lcm_list(numbers):
    return reduce(lcm, numbers, 1)


def gcd_list(numbers):
    return reduce(gcd, numbers)


def is_prime(n):
    if n <= 1:
        return False
    p = 2
    while True:
        if p ** 2 > n:
            break
        if n % p == 0:
            return False
        p += 1
    return True



def eratosthenes(limit):
    A = [i for i in range(2, limit+1)]
    P = []

    while True:
        prime = min(A)
        
        if prime > sqrt(limit):
            break
            
        P.append(prime)
            
        i = 0
        while i < len(A):
            if A[i] % prime == 0:
                A.pop(i)
                continue
            i += 1
            
    for a in A:
        P.append(a)
            
    return P


def permutation_with_duplicates(L):

    if L == []:
        return [[]]

    else:
        ret = []

        
        S = sorted(set(L))

        for i in S:

            data = L[:]
            data.remove(i)

            for j in permutation_with_duplicates(data):
                ret.append([i] + j)

        return ret



n, a = map(int, input().split())            
x = [i - a for i in map(int, input().split())]
dp = [[0 for j in range(4901)] for i in range(n)]
dp[0][2450] += 1
dp[0][x[0] + 2450] += 1
for i in range(1, n):
    for j in range(4901):
        dp[i][j] = dp[i - 1][j]
        if 0 <= j - x[i] < 4901:
            dp[i][j] += dp[i - 1][j - x[i]]
ans = dp[n - 1][2450] - 1
print(ans)

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

def main():
    N, A = (int(_) for _ in input().split())
    X = [int(_) for _ in 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(N):
            for k in range(N*A+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]]
    ret = 0
    for i in range(1, N+1):
        ret += dp[N][i][i*A]
    print(ret)
    return

if __name__ == '__main__':
    main()

Solution (Python):
n,a,*l=map(int,open(0).read().split())
R=2500
dp=[[0]*R*2,[0]*R*2]
dp[0][0]=1
t=0
for i in range(n):
  u=1-t
  for s in range(-R,R):
    dp[u][s]=dp[t][s]+dp[t][s-l[i]+a]
  t=u
print(dp[t][0]-1)

Solution (Python):
n,a,*l=map(int,open(0).read().split())
R=2500
dp=[[0]*R*2,[0]*R*2]
dp[0][0]=1
for i in range(n):
  for s in range(-R,R):
    dp[i+1&1][s]=dp[i&1][s]+dp[i&1][s-l[i]+a]
print(dp[n&1][0]-1)

Solution (Python):
n,a,*l=map(int,open(0).read().split())
R=2500
dp=[[0]*R*2 for _ in range(n+1)]
dp[0][0]=1
for i in range(n):
  for s in range(-R,R):
    dp[i+1][s]=dp[i][s]+dp[i][s-l[i]+a]
print(dp[n][0]-1)

Solution (Python):
_,a,*l=map(int,open(0).read().split())
d={0:1}
for i in l:
  for k,v in d.copy().items(): d[i-a+k]=d.get(i-a+k,0)+v
print(d[0]-1)

Solution (Python):
f=lambda:map(int,input().split())
n,a=f()
l=[i-a for i in f()]
dp=[[0]*5000 for _ in range(51)]
Z=2500
dp[0][Z]=1
for i in range(n):
  for s in range(5000-max(l[i],0)):
    dp[i+1][s]+=dp[i][s]
    dp[i+1][s+l[i]]+=dp[i][s]
print(dp[n][Z]-1)

Solution (Python):


from collections import Counter, defaultdict


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

    result = Counter([0])

    for x in X:
        dct = defaultdict(int)
        for k, v in result.items():
            dct[k + x] += v
        result += dct

    print(result[0] - 1)


if __name__ == "__main__":
    main()

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

x = [int(i) for i in input().split()] 
y = [int(i)-a for i in x] 


max = max(x)

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

dp[0][n*max] = 1 

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

result = dp[n][n*max]-1

print(result)

Solution (Python):
from collections import Counter


N, A = map(int, input().split())
X = list(map(int, input().split()))
Y = [x - A for x in X]
L = Counter()
L[0] = 1

for y in Y:
    for key, value in list(L.items()):
        L[key + y] += value

print(L[0] - 1)

Solution (Python):
def c_tak_and_cards():
    from collections import defaultdict
    N, A = [int(i) for i in input().split()]
    X = [int(i) for i in input().split()]

    average = [x - A for x in X]
    dp = defaultdict(int)  
    dp[0] = 1  
    for y in average:
        for k, v in list(dp.items()):  
            dp[k + y] += v
    return dp[0] - 1

print(c_tak_and_cards())

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

dp = defaultdict(dict)
dp[0][0] = 1  

for x in X:
    newDP = defaultdict(dict)
    for card, memo in dp.items():
        for k, v in memo.items():
            
            if k in newDP[card]:
                newDP[card][k] += v
            else:
                newDP[card][k] = v
            
            if k + x in newDP[card + 1]:
                newDP[card + 1][k + x] += v
            else:
                newDP[card + 1][k + x] = v
    dp = newDP

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

Solution (Python):
N, A = map(int,input().split())
X = list(map(int,input().split()))
dp = [[[0 for k in range(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):
    for j in range(i+1):
        for k in range(50 * N + 1):
            dp[i][j][k] += dp[i-1][j][k]
            if j != 0 and k - X[i-1] >= 0:
                dp[i][j][k] += dp[i-1][j-1][k - X[i-1]]
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()))

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

dp = [0] * (2 * n * 50 + 2)
dp[0] = 1

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

print(dp[0] - 1)

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

blist = list(map(lambda x:x-A,alist))
sum_plus = 0
sum_minus = 0
for i in blist:
    if i >0:
        sum_plus +=i
    else:
        sum_minus +=i

N=len(alist)
dp = [[0 for i in range(sum_plus - sum_minus + 1)] for j in range(N+1)]
dp[0][0-sum_minus]=1

for i in range(N):
    for j in range(sum_plus - sum_minus+1):
        if j-blist[i] <= (sum_plus - sum_minus):
            dp[i+1][j]=dp[i][j-blist[i]]+dp[i][j]
        else:
            dp[i+1][j]=dp[i][j]

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

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

xsum=max(max(x),a)*n
dp=[[[0]*(xsum+1) for i in range(n+1)] for ii in range(n+1)]

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

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

Solution (Python):
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): 
    return list(map(int,input().split()))
def m(): 
    return map(int,input().split())
def onem(): 
    return int(input())
def s(x): 
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): 
    return " ".join(map(str,x))
def max2(x): 
    return max(map(max,x))
def In(x,a): 
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

n,a = m()

x = l()

ma = max(x)

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

dp[0][0] = 1

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

ans = 0

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

print(ans)