Buggy python submission (verdict: Runtime Error):
from sys import stdin
input = stdin.readline

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

X = max(max(x), A)
# dp = [[[0]*(N*X+1) for _ in range(N+1)] for _ in range(N+1)]
# for j in range(N+1):
# 	for k in range(N+1):
# 		for s in range(N*X+1):
# 			if j == 0 and k == 0 and s == 0:
# 				dp[j][k][s] = 1
# 			elif j >= 1 and s < x[j-1]: # 探索先が総和より大きい
# 				dp[j][k][s] = dp[j-1][k][s]
# 			elif j >= 1 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]]
# 			else:
# 				dp[j][k][s] = 0
# sum = 0
# for i in range(1, N+1):
# 	sum += dp[N][i][i*A]
# print(sum)

dp = [[0]*(2*N*X+1) for _ in range(N+1)]
y = [0] * len(x)
for i in range(len(x)):
	y[i] = x[i]-A

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


Fixed submission:
from sys import stdin
input = stdin.readline

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

X = max(max(x), A)
# dp = [[[0]*(N*X+1) for _ in range(N+1)] for _ in range(N+1)]
# for j in range(N+1):
# 	for k in range(N+1):
# 		for s in range(N*X+1):
# 			if j == 0 and k == 0 and s == 0:
# 				dp[j][k][s] = 1
# 			elif j >= 1 and s < x[j-1]: # 探索先が総和より大きい
# 				dp[j][k][s] = dp[j-1][k][s]
# 			elif j >= 1 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]]
# 			else:
# 				dp[j][k][s] = 0
# sum = 0
# for i in range(1, N+1):
# 	sum += dp[N][i][i*A]
# print(sum)

dp = [[0]*(2*N*X+1) for _ in range(N+1)]
y = [0] * len(x)
for i in range(len(x)):
	y[i] = x[i]-A

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

Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
input = stdin.readline

def Combi(n, r):
	return int(factorial[n] / factorial[r] / factorial[n-r])
N, A = [int(x) for x in input().rstrip().split()]
x = [int(x) for x in input().rstrip().split()]
# num = [0]*51
# for i in x:
# 	num[i] += 1
# print(2**num[A]-1)
# factorial = [1]
# for i in range(1, 51):
# 	factorial.append(factorial[i-1] * i)
# for i in range(1, A):
X = max(max(x), A)
dp = [[[0]*(N*X+1) for _ in range(N+1)] for _ in range(N+1)]
for j in range(N+1):
	for k in range(N+1):
		for s in range(N*X+1):
			if j == 0 and k == 0 and s == 0:
				dp[j][k][s] = 1
			elif j >= 1 and s < x[j-1]: # 探索先が総和より大きい
				dp[j][k][s] = dp[j-1][k][s]
			elif j >= 1 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]]
			else:
				dp[j][k][s] = 0
sum = 0
for i in range(N+1):
	sum += dp[N][i][i*A]
print(sum-1)


Fixed submission:
from sys import stdin
input = stdin.readline

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

X = max(max(x), A)
# dp = [[[0]*(N*X+1) for _ in range(N+1)] for _ in range(N+1)]
# for j in range(N+1):
# 	for k in range(N+1):
# 		for s in range(N*X+1):
# 			if j == 0 and k == 0 and s == 0:
# 				dp[j][k][s] = 1
# 			elif j >= 1 and s < x[j-1]: # 探索先が総和より大きい
# 				dp[j][k][s] = dp[j-1][k][s]
# 			elif j >= 1 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]]
# 			else:
# 				dp[j][k][s] = 0
# sum = 0
# for i in range(1, N+1):
# 	sum += dp[N][i][i*A]
# print(sum)

dp = [[0]*(2*N*X+1) for _ in range(N+1)]
y = [0] * len(x)
for i in range(len(x)):
	y[i] = x[i]-A

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