Buggy python submission (verdict: Time Limit Exceeded):
from functools import lru_cache

N, A = map(int, input().split())
x = list(map(int, input().split()))
sum_x = sum(x)
X = max(x + [A])

answer = 0

@lru_cache(maxsize=None)
def solve(j, k, s):
    global x
    if j == 0 and k == 0 and s == 0:
        return 1
    elif j >= 1 and s < x[j - 1]:
        return solve(j-1, k, s)
    elif j >= 1 and k >= 1 and s >= x[j - 1]:
        return solve(j-1, k, s) + solve(j-1, k - 1, s - x[j - 1])
    else:
        return 0

for k in range(1, N + 1):
    answer += solve(N, k, k * A)
print(answer)


Fixed submission:
from functools import lru_cache

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

@lru_cache(maxsize=None)
def solve(j, t):
    global y
    if j == 0 and t == 0:
        return 1
    elif j >= 1 and (t < y[j - 1] - N * X or t > y[j - 1] + N * X):
        return solve(j - 1, t)
    elif j >= 1 and t >= y[j - 1] - N * X and t <= y[j - 1] + N * X:
        return solve(j - 1, t) + solve(j - 1, t - y[j - 1])
    else:
        return 0

print(solve(N, 0) - 1)

Buggy python submission (verdict: Time Limit Exceeded):
N, A = map(int, input().split())
x = list(map(int, input().split()))
sum_x = sum(x)
X = max(x + [A])

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

answer = 0
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
            if j == N and s == k * A and k >= 1:
                answer += dp[j][k][s]

print(answer)


Fixed submission:
from functools import lru_cache

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

@lru_cache(maxsize=None)
def solve(j, t):
    global y
    if j == 0 and t == 0:
        return 1
    elif j >= 1 and (t < y[j - 1] - N * X or t > y[j - 1] + N * X):
        return solve(j - 1, t)
    elif j >= 1 and t >= y[j - 1] - N * X and t <= y[j - 1] + N * X:
        return solve(j - 1, t) + solve(j - 1, t - y[j - 1])
    else:
        return 0

print(solve(N, 0) - 1)

Buggy python submission (verdict: Time Limit Exceeded):
N, A = map(int, input().split())
x = list(map(int, input().split()))
sum_x = sum(x)
X = max(x + [A])

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

for j in range(len(dp)):
    for k in range(len(dp[j])):
        for s in range(len(dp[j][k])):
            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

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

print(answer)


Fixed submission:
from functools import lru_cache

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

@lru_cache(maxsize=None)
def solve(j, t):
    global y
    if j == 0 and t == 0:
        return 1
    elif j >= 1 and (t < y[j - 1] - N * X or t > y[j - 1] + N * X):
        return solve(j - 1, t)
    elif j >= 1 and t >= y[j - 1] - N * X and t <= y[j - 1] + N * X:
        return solve(j - 1, t) + solve(j - 1, t - y[j - 1])
    else:
        return 0

print(solve(N, 0) - 1)