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

MAX = 2501

x = sorted(x)

z = 0
p = []
m = []
for i in range(n):
    x[i] -= a
    if x[i] == 0:
        z += 1
    elif x[i] > 0:
        p.append(x[i])
    else:
        m.append(-1 * x[i])

plus = [0 for _ in range(MAX)]
#minus = [0 for _ in range(MAX)]

ans = 2 ** z - 1

#print(p, m, z)

def calc_plus(temp_sum, i):
    if i >= len(p):
        plus[temp_sum] += 1
        return
    else:
        calc_plus(temp_sum, i + 1)
        calc_plus(temp_sum + p[i], i + 1)

calc_plus(0,0)

#print(plus)

def calc_minus(temp_sum, i):
    if i >= len(m):
        if temp_sum > 0 and plus[temp_sum] > 0:
            global ans
            ans += plus[temp_sum] * (2 ** z)
        return
    else:
        calc_minus(temp_sum, i + 1)
        calc_minus(temp_sum + m[i], i + 1)


calc_minus(0,0)

print(ans)


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

max_x = max(x)
dp = [[0 for _  in range(n * 2 * max_x + 1)] for _ in range(n + 1)]

dp[0][n * max_x] = 1
for i in range(1, n + 1):
    for j in range(1, n * 2 * max_x + 1):
        if 0 <= j + a - x[i - 1] <= 2 * n * max_x:
            dp[i][j] = dp[i - 1][j] + dp[i - 1][j + a - x[i - 1]]
        else:
            dp[i][j] = dp[i - 1][j]

print(dp[n][n * max_x] - 1)

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

MAX = 2501

x = sorted(x)

z = 0
p = []
m = []
for i in range(n):
    x[i] -= a
    if x[i] == 0:
        z += 1
    elif x[i] > 0:
        p.append(x[i])
    else:
        m.append(-1 * x[i])

plus = [0 for _ in range(MAX)]
#minus = [0 for _ in range(MAX)]

ans = 2 ** z - 1

#print(p, m, z)

def calc_plus(temp_sum, i):
    if i >= len(p):
        plus[temp_sum] += 1
        return
    else:
        calc_plus(temp_sum, i + 1)
        calc_plus(temp_sum + p[i], i + 1)

calc_plus(0,0)

#print(plus)

def calc_minus(temp_sum, i):
    if i >= len(m):
        if temp_sum > 0 and plus[temp_sum] > 0:
            global ans
            ans += plus[temp_sum] * (2 ** z)
        return
    else:
        calc_minus(temp_sum, i + 1)
        calc_minus(temp_sum + m[i], i + 1)


calc_minus(0,0)

print(ans)


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

max_x = max(x)
dp = [[0 for _  in range(n * 2 * max_x + 1)] for _ in range(n + 1)]

dp[0][n * max_x] = 1
for i in range(1, n + 1):
    for j in range(1, n * 2 * max_x + 1):
        if 0 <= j + a - x[i - 1] <= 2 * n * max_x:
            dp[i][j] = dp[i - 1][j] + dp[i - 1][j + a - x[i - 1]]
        else:
            dp[i][j] = dp[i - 1][j]

print(dp[n][n * max_x] - 1)

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

x = sorted(x)

ans = 0
for i in range(n):
    x[i] -= a
    if x[i] == 0:
        ans += 1

if x[0] >= 0 or x[n - 1] <= 0:
    print(2 ** ans - 1)
    exit()

ans = 0

def adder(temp_sum, i):
    if i >= n:
        return
    else:
        if temp_sum + x[i] == 0:
            global ans
            ans += 1
        adder(temp_sum, i + 1)
        adder(temp_sum + x[i], i + 1)

adder(0,0)

print(ans)


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

max_x = max(x)
dp = [[0 for _  in range(n * 2 * max_x + 1)] for _ in range(n + 1)]

dp[0][n * max_x] = 1
for i in range(1, n + 1):
    for j in range(1, n * 2 * max_x + 1):
        if 0 <= j + a - x[i - 1] <= 2 * n * max_x:
            dp[i][j] = dp[i - 1][j] + dp[i - 1][j + a - x[i - 1]]
        else:
            dp[i][j] = dp[i - 1][j]

print(dp[n][n * max_x] - 1)