Buggy python submission (verdict: Time Limit Exceeded):
from itertools import product
N, A = map(int, input().split())
x = list(map(int, input().split()))
x_max = max(max(x), A)

dp = [[[0 for s in range(x_max * N + 1)]for n in range(N + 1)] for i in range(N + 1)]
dp[0][0][0] = 1

for i, n, s in product(range(1, N + 1), range(N + 1), range(x_max * N + 1)):
    if s < x[i - 1]:
        dp[i][n][s] = dp[i - 1][n][s]
    elif 0 < n and x[i - 1] <= s:
        dp[i][n][s] = dp[i - 1][n][s] + dp[i - 1][n - 1][s - x[i - 1]]

ans = sum([dp[N][n][n*A] for n in range(1, N + 1)])
print(ans)

Fixed submission:
from itertools import product

N, A = map(int, input().split())
x = [int(xi) for xi in input().split()]
y = [xi - A for xi in x]
X = max(max(x), A)

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

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

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

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import product
N, A = map(int, input().split())
x = list(map(int, input().split()))
x_max = max(max(x), A)

dp = [[[0 for s in range(x_max * (N + 1))] for n in range(N + 1)] for i in range(N + 1)]
dp[0][0][0] = 1

for i, n, s in product(range(1, N + 1), range(N + 1), range(x_max * (N + 1))):
    if s < x[i - 1]:
        dp[i][n][s] = dp[i - 1][n][s]
    elif 0 < n and x[i - 1] <= s:
        dp[i][n][s] = dp[i - 1][n][s] + dp[i - 1][n - 1][s - x[i - 1]]

ans = sum([dp[N][n][n*A] for n in range(1, N + 1)])
print(ans)

Fixed submission:
from itertools import product

N, A = map(int, input().split())
x = [int(xi) for xi in input().split()]
y = [xi - A for xi in x]
X = max(max(x), A)

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

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

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

Buggy python submission (verdict: Runtime Error):
from itertools import product
N, A = map(int, input().split())
x = list(map(int, input().split()))
x_max = max(x)

dp = [[[0 for s in range(x_max * (N + 1))] for n in range(N + 1)] for i in range(N + 1)]
dp[0][0][0] = 1

for i, n, s in product(range(1, N + 1), range(N + 1), range(x_max * (N + 1))):
    if s < x[i - 1]:
        dp[i][n][s] = dp[i - 1][n][s]
    elif 0 < n and x[i - 1] <= s:
        dp[i][n][s] = dp[i - 1][n][s] + dp[i - 1][n - 1][s - x[i - 1]]

ans = sum([dp[N][n][n*A] for n in range(1, N + 1)])
print(ans)

Fixed submission:
from itertools import product

N, A = map(int, input().split())
x = [int(xi) for xi in input().split()]
y = [xi - A for xi in x]
X = max(max(x), A)

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

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

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

Buggy python submission (verdict: Runtime Error):
from itertools import product
N, A = map(int, input().split())
x = list(map(int, input().split()))
x_max = max(x)

dp = [[[0 for s in range(x_max * N + 1)] for n in range(N + 1)] for i in range(N + 1)]
dp[0][0][0] = 1

for i, n, s in product(range(1, N + 1), range(N + 1), range(x_max * N + 1)):
    if s < x[i - 1]:
        dp[i][n][s] = dp[i - 1][n][s]
    elif 0 < n and x[i - 1] <= s:
        dp[i][n][s] = dp[i - 1][n][s] + dp[i - 1][n - 1][s - x[i - 1]]

ans = sum([dp[N][n][n*A] for n in range(1, N + 1)])
print(ans)

Fixed submission:
from itertools import product

N, A = map(int, input().split())
x = [int(xi) for xi in input().split()]
y = [xi - A for xi in x]
X = max(max(x), A)

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

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

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

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import product

N, A = map(int, input().split())
x = [int(xi) for xi in input().split()]
x_max = max(max(x), A)

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

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

for j, k, s in product(range(1, N + 1),
                       range(N + 1),
                       range((N + 1) * x_max)):
    if s < x[j - 1]:
        dp[j][k][s] = dp[j - 1][k][s]
    elif 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]]

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


Fixed submission:
from itertools import product

N, A = map(int, input().split())
x = [int(xi) for xi in input().split()]
y = [xi - A for xi in x]
X = max(max(x), A)

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

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

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