Buggy python submission (verdict: Time Limit Exceeded):
N,A=map(int,raw_input().split())
x=[0]+map(int,raw_input().split())
#print x

max_n=max(x)

#dp=[[[0]*(max_n*N+1) for k in range(N+1)] for j in range(N+1)]
dp=[[[0]*3000 for k in range(51)] for j in range(51)]
#print dp


for j in range(N+1):
	for k in range(N+1):
		for s in range(max_n*N+1):
			if j==k==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
#print dp


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

print ans
	
			
		

Fixed submission:
N,A=map(int,raw_input().split())
x=[0]+map(int,raw_input().split())
#print x
y=map(lambda i:i-A, x)
#print y

max_x=max(max(x),A)
#print max_x

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

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

print dp[N][N*max_x]-1

Buggy python submission (verdict: Runtime Error):
N,A=map(int,raw_input().split())
x=[0]+map(int,raw_input().split())
#print x

max_n=max(x)

dp=[[[0]*(N*max_n+1) for k in range(N + 1)] for j in range(N+1)]
#print dp


for j in range(N+1):
	for k in range(N+1):
		for s in range(N*max_n+1):
			if j==k==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
#print dp


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

print ans
	
			
		

Fixed submission:
N,A=map(int,raw_input().split())
x=[0]+map(int,raw_input().split())
#print x
y=map(lambda i:i-A, x)
#print y

max_x=max(max(x),A)
#print max_x

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

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

print dp[N][N*max_x]-1

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
import collections
import math
N,A=map(int,raw_input().split())
#print N,A
x=collections.Counter(map(int,raw_input().split()))
#print x

iv=[i for i in x.keys()]	#Item value
ic=[]	#Item count
for i in x.items():
	tmp=[i for i in range(i[1]+1)]
	ic.append(tmp)


ic_n=[len(_)-1 for _ in ic]

p=list(itertools.product(*ic))
#print "# p"
#print p		#Pattern

a=[]
for m in p:
	t_sum=0
	for j,k in zip(m,iv):
		t_sum+=j*k
	#print t_sum,len(m)
	if sum(m)!=0 and t_sum/sum(m)==A and t_sum%sum(m)==0 and sum(m)!=0:
		#print m,iv,t_sum,sum(m)
		a.append(m)

#print "# a"
#print a

def combination(n,r):
	g=[math.factorial(i) for i in range(100) ]
	return int(g[n]/(g[r]*g[n-r]))

ans=0
for i in a:
	t_cnt=1
	for j,k in zip(i,ic_n):
		if j!=0 or j!=k:
			t_cnt*= combination(k,j)
			pass
	#print t_cnt
	ans+=t_cnt
print ans


Fixed submission:
N,A=map(int,raw_input().split())
x=[0]+map(int,raw_input().split())
#print x
y=map(lambda i:i-A, x)
#print y

max_x=max(max(x),A)
#print max_x

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

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

print dp[N][N*max_x]-1

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
import collections
N,A=map(int,raw_input().split())
#print N,A
x=collections.Counter(map(int,raw_input().split()))
#print x

iv=[i for i in x.keys()]	#Item value
#print "# iv"
#print iv
ic=[]	#Item count
for i in x.items():
	tmp=[i for i in range(i[1]+1)]
	ic.append(tmp)

#print "# ic"
#print ic

ic_n=[len(_)-1 for _ in ic]
#print "# ic_n"
#print ic_n

p=list(itertools.product(*ic))
#print "# p"
#print p		#Pattern

a=[]
for m in p:
	#print "##"
	#print m,iv
	t_sum=0
	for j,k in zip(m,iv):
		t_sum+=j*k
	#print t_sum,len(m)
	if sum(m)!=0 and t_sum/sum(m)==A and t_sum%sum(m)==0 and sum(m)!=0:
		#print m,iv,t_sum,sum(m)
		a.append(m)

#print "# a"
#print a
#print len(a)

ans=0
for i in a:
	#print "=="
	t_cnt=1
	for j,k in zip(i,ic_n):
		if j!=0 or j!=k:
			#print j,k,len(list(itertools.combinations(range(k),j))) 
			t_cnt*=len(list(itertools.combinations(range(k),j)))
	#print t_cnt
	ans+=t_cnt
print ans




Fixed submission:
N,A=map(int,raw_input().split())
x=[0]+map(int,raw_input().split())
#print x
y=map(lambda i:i-A, x)
#print y

max_x=max(max(x),A)
#print max_x

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

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

print dp[N][N*max_x]-1