Buggy python submission (verdict: Time Limit Exceeded):
n, a = map(int, input().split())
xlist = list(sorted(map(int, input().split())))

maxx = xlist[-1] if xlist[-1] > a else a
# dp[j][k][s]: x_1...x_jまでのなかからk枚選んで合計をsにする総数
dp = [[[0 for _ in range(maxx * n + 1)] for _ in range(n + 1)] for _ in range(n + 1)]

dp[0][0][0] = 1  # 0枚選んで合計を0にするのは1通り
for j in range(n + 1):
  for k in range(n + 1):
    for s in range(maxx * k + 1):
      if j >= 1 and s < xlist[j-1]:  # x_0は選ばないのと同じなので0のまま更新しない
        dp[j][k][s] = dp[j-1][k][s]
      elif j >= 1 and k >= 1 and s >= xlist[j-1]:
        dp[j][k][s] = dp[j-1][k][s] + dp[j-1][k-1][s-xlist[j-1]]

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

Fixed submission:
n, a = map(int, input().split())
x = list(map(int, input().split()))

maxx = max(x)
maxx = max(maxx, a)
# dp[j][k][s] : j枚目までからk枚選んで合計をsにする場合の数
dp = [[[0 for _ in range(maxx * n + 1)] for _ in range(n + 1)] for _ in range(n + 1)]
dp[0][0][0] = 1

for j in range(n + 1):
    for k in range(j + 1):
        for s in range(maxx * k + 1):
            if 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]]

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

Buggy python submission (verdict: Time Limit Exceeded):
n, a = map(int, input().split())
xlist = list(sorted(map(int, input().split())))

maxx = xlist[-1] if xlist[-1] > a else a
# dp[j][k][s]: x_1...x_jまでのなかからk枚選んで合計をsにする総数
dp = [[[0 for _ in range(maxx * n + 1)] for _ in range(n + 1)] for _ in range(n + 1)]

dp[0][0][0] = 1  # 0枚選んで合計を0にするのは1通り
for j in range(n + 1):
  for k in range(n + 1):
    for s in range(maxx * k + 1):
      if j >= 1:  # x_0は選ばないのと同じなので0のまま更新しない
        if s < xlist[j-1]:
          dp[j][k][s] = dp[j-1][k][s]
        elif k >= 1 and s >= xlist[j-1]:
          dp[j][k][s] = dp[j-1][k][s] + dp[j-1][k-1][s-xlist[j-1]]

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

Fixed submission:
n, a = map(int, input().split())
x = list(map(int, input().split()))

maxx = max(x)
maxx = max(maxx, a)
# dp[j][k][s] : j枚目までからk枚選んで合計をsにする場合の数
dp = [[[0 for _ in range(maxx * n + 1)] for _ in range(n + 1)] for _ in range(n + 1)]
dp[0][0][0] = 1

for j in range(n + 1):
    for k in range(j + 1):
        for s in range(maxx * k + 1):
            if 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]]

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

Buggy python submission (verdict: Time Limit Exceeded):
n, a = map(int, input().split())
xlist = list(sorted(map(int, input().split())))

maxx = max(xlist[-1], a)
# dp[j][k][s]: x_1...x_jまでのなかからk枚選んで合計をsにする総数
dp = [[[0 for _ in range(maxx * n + 1)] for _ in range(n + 1)] for _ in range(n + 1)]

dp[0][0][0] = 1  # 0枚選んで合計を0にするのは1通り
for j in range(n + 1):
  for k in range(n + 1):
    for s in range(maxx * n + 1):
      if j >= 1:  # x_0は選ばないのと同じなので0のまま更新しない
        if s < xlist[j-1]:
          dp[j][k][s] = dp[j-1][k][s]
        elif k >= 1 and s >= xlist[j-1]:
          dp[j][k][s] = dp[j-1][k][s] + dp[j-1][k-1][s-xlist[j-1]]

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

Fixed submission:
n, a = map(int, input().split())
x = list(map(int, input().split()))

maxx = max(x)
maxx = max(maxx, a)
# dp[j][k][s] : j枚目までからk枚選んで合計をsにする場合の数
dp = [[[0 for _ in range(maxx * n + 1)] for _ in range(n + 1)] for _ in range(n + 1)]
dp[0][0][0] = 1

for j in range(n + 1):
    for k in range(j + 1):
        for s in range(maxx * k + 1):
            if 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]]

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