Buggy python submission (verdict: Time Limit Exceeded):
import heapq
N, A = map(int, input().split())
X = [int(x) - A for x in input().split()]
Xp = []
Xm = []
X0 = []
for x in X:
  if x > 0:
    Xp.append(x)
  elif x < 0:
    Xm.append(-x)
  else:
    X0.append(x)
limit = min(sum(Xp), sum(Xm))
Xp = [x for x in Xp if x <= limit]
Xm = [x for x in Xm if x <= limit]
R = [[[0, 0]], [[0, 0]]]
def c(X, k):
  Q = []
  heapq.heappush(Q, 0)
  for x in X:
    _Q = []
    while Q:
      q = heapq.heappop(Q)
      if q > limit:
        break
      heapq.heappush(_Q, q)
      heapq.heappush(_Q, q + x)
    Q = _Q
  preq = 0
  while Q:
    q = heapq.heappop(Q)
    if q > limit:
      break
    if q == preq:
      R[k][-1][1] += 1
    else:
      R[k].append([q, 1])
    preq = q
c(Xp, 0)
c(Xm, 1)
cx = 0
while R[0] and R[1]:
  if R[0][0][0] < R[1][0][0]:
    R[0] = R[0][1:]
  elif R[0][0][0] > R[1][0][0]:
    R[1] = R[1][1:]
  else:
    cx += R[0][0][1] * R[1][0][1]
    R[0] = R[0][1:]
    R[1] = R[1][1:]
print(cx * (2 ** len(X0)) - 1)

Fixed submission:
from collections import Counter
N, A = map(int, input().split())
X = [int(x) - A for x in input().split()]
C = Counter([0])
for x in X:
  tmp = Counter()
  for i, c in C.items():
    tmp[i + x] += c
  C += tmp
print(C[0] - 1)

Buggy python submission (verdict: Time Limit Exceeded):
import heapq
N, A = map(int, input().split())
X = [int(x) - A for x in input().split()]
Xp = []
Xm = []
X0 = []
for x in X:
  if x > 0:
    Xp.append(x)
  elif x < 0:
    Xm.append(-x)
  else:
    X0.append(x)
limit = min(sum(Xp), sum(Xm))
Xp = [x for x in Xp if x <= limit]
Xm = [x for x in Xm if x <= limit]
R = [[0, 0] for x in range(limit + 1)]
def c(X, k):
  Q = []
  heapq.heappush(Q, 0)
  for x in X:
    _Q = []
    while Q:
      q = heapq.heappop(Q)
      if q > limit:
        break
      heapq.heappush(_Q, q)
      heapq.heappush(_Q, q + x)
    Q = _Q
  while Q:
    q = heapq.heappop(Q)
    if q > limit:
      break
    R[q][k] += 1
c(Xp, 0)
c(Xm, 1)
print(sum([r[0] * r[1] for r in R]) * (2 ** len(X0)) - 1)

Fixed submission:
from collections import Counter
N, A = map(int, input().split())
X = [int(x) - A for x in input().split()]
C = Counter([0])
for x in X:
  tmp = Counter()
  for i, c in C.items():
    tmp[i + x] += c
  C += tmp
print(C[0] - 1)

Buggy python submission (verdict: Runtime Error):
import heapq
N, A = map(int, input().split())
X = [int(x) - A for x in input().split()]
for x in X:
  if x > 0:
    Xp.append(x)
  elif x < 0:
    Xm.append(-x)
  else:
    X0.append(x)
limit = min(sum(Xp), sum(Xm))
Xp = [x for x in Xp if x <= limit]
Xm = [x for x in Xm if x <= limit]
R = [[0, 0] for x in range(limit + 1)]
def c(X, k):
  Q = []
  heapq.heappush(Q, 0)
  for x in X:
    _Q = []
    while Q:
      q = heapq.heappop(Q)
      if q > limit:
        break
      heapq.heappush(_Q, q)
      heapq.heappush(_Q, q + x)
    Q = _Q
  while Q:
    q = heapq.heappop(Q)
    if q > limit:
      break
    R[q][k] += 1
c(Xp, 0)
c(Xm, 1)
print(sum([r[0] * r[1] for r in R]) * (2 ** len(X0)) - 1)

Fixed submission:
from collections import Counter
N, A = map(int, input().split())
X = [int(x) - A for x in input().split()]
C = Counter([0])
for x in X:
  tmp = Counter()
  for i, c in C.items():
    tmp[i + x] += c
  C += tmp
print(C[0] - 1)

Buggy python submission (verdict: Time Limit Exceeded):
import heapq
N, A = map(int, input().split())
X = [int(x) - A for x in input().split()]
X0 = [0 for x in X if x == 0]
Xp = [x for x in X if x > 0]
Xm = [-x for x in X if x < 0]
limit = min(sum(Xp), sum(Xm))
Xp = [x for x in Xp if x <= limit]
Xm = [x for x in Xm if x <= limit]
R = [[0, 0] for x in range(limit + 1)]
def c(X, k):
  Q = []
  heapq.heappush(Q, 0)
  for x in X:
    _Q = []
    while Q:
      q = heapq.heappop(Q)
      heapq.heappush(_Q, q)
      heapq.heappush(_Q, q + x)
    Q = _Q
  while Q:
    q = heapq.heappop(Q)
    if q <= limit:
      R[q][k] += 1
    else:
      break
c(Xp, 0)
c(Xm, 1)
print(sum([r[0] * r[1] for r in R]) * (2 ** len(X0)) - 1)

Fixed submission:
from collections import Counter
N, A = map(int, input().split())
X = [int(x) - A for x in input().split()]
C = Counter([0])
for x in X:
  tmp = Counter()
  for i, c in C.items():
    tmp[i + x] += c
  C += tmp
print(C[0] - 1)

Buggy python submission (verdict: Time Limit Exceeded):
import heapq
N, A = map(int, input().split())
X = [int(x) - A for x in input().split()]
X0 = [0 for x in X if x == 0]
Xp = [x for x in X if x > 0]
Xm = [-x for x in X if x < 0]
limit = min(sum(Xp), sum(Xm))
Xp = [x for x in Xp if x <= limit]
Xm = [x for x in Xm if x <= limit]
R = [[0, 0] for x in range(limit + 1)]
def c(X, k):
  Q = []
  heapq.heappush(Q, 0)
  for x in X:
    _Q = []
    while Q:
      q = heapq.heappop(Q)
      heapq.heappush(_Q, q)
      if q + x <= limit:
        heapq.heappush(_Q, q + x)
    Q = _Q
  while Q:
    R[heapq.heappop(Q)][k] += 1
c(Xp, 0)
c(Xm, 1)
print(sum([r[0] * r[1] for r in R]) * (2 ** len(X0)) - 1)

Fixed submission:
from collections import Counter
N, A = map(int, input().split())
X = [int(x) - A for x in input().split()]
C = Counter([0])
for x in X:
  tmp = Counter()
  for i, c in C.items():
    tmp[i + x] += c
  C += tmp
print(C[0] - 1)

Buggy python submission (verdict: Time Limit Exceeded):
N, A = map(int, input().split())
X = [int(x) - A for x in input().split()]
X0 = [0 for x in X if x == 0]
Xp = [x for x in X if x > 0]
Xm = [-x for x in X if x < 0]
limit = min(sum(Xp), sum(Xm))
Xp = [x for x in Xp if x <= limit]
Xm = [x for x in Xm if x <= limit]
R = [[0, 0] for x in range(limit + 1)]
def c(X, k):
  Q = [0]
  for x in X:
    Q += [q + x for q in Q if q + x <= limit]
  for q in Q:
    R[q][k] += 1
c(Xp, 0)
c(Xm, 1)
print(sum([r[0] * r[1] for r in R]) * (2 ** len(X0)) - 1)

Fixed submission:
from collections import Counter
N, A = map(int, input().split())
X = [int(x) - A for x in input().split()]
C = Counter([0])
for x in X:
  tmp = Counter()
  for i, c in C.items():
    tmp[i + x] += c
  C += tmp
print(C[0] - 1)

Buggy python submission (verdict: Time Limit Exceeded):
N, A = map(int, input().split())
X = [int(x) - A for x in input().split()]
X0 = [0 for x in X if x == 0]
Xp = [x for x in X if x > 0]
Xm = [-x for x in X if x < 0]
limit = min(sum(Xp), sum(Xm))
Xp = [x for x in Xp if x <= limit]
Xm = [x for x in Xm if x <= limit]
R = [[0, 0] for x in range(limit + 1)]
def c(X, k):
  for i in range(2 ** len(X)):
    mask = bin(i)[2:]
    mask = [0 for m in range(len(X) - len(mask))] + [int(s) for s in mask]
    masked = sum([X[j] * mask[j] for j in range(len(X))])
    if masked <= limit:
      R[masked][k] += 1
c(Xp, 0)
c(Xm, 1)
print(sum([r[0] * r[1] for r in R]) * (2 ** len(X0)) - 1)

Fixed submission:
from collections import Counter
N, A = map(int, input().split())
X = [int(x) - A for x in input().split()]
C = Counter([0])
for x in X:
  tmp = Counter()
  for i, c in C.items():
    tmp[i + x] += c
  C += tmp
print(C[0] - 1)

Buggy python submission (verdict: Time Limit Exceeded):
N, A = map(int, input().split())
X = [int(x) - A for x in input().split()]
X0 = [0 for x in X if x == 0]
Xp = [x for x in X if x > 0]
Xm = [-x for x in X if x < 0]
limit = min(sum(Xp), sum(Xm))
R = [[0, 0] for x in range(limit + 1)]
def c(X, k):
  for i in range(2 ** len(X)):
    mask = bin(i)[2:]
    mask = [0 for m in range(len(X) - len(mask))] + [int(s) for s in mask]
    masked = sum([X[j] * mask[j] for j in range(len(X))])
    if masked <= limit:
      R[masked][k] += 1
c(Xp, 0)
c(Xm, 1)
print(sum([r[0] * r[1] for r in R]) * (2 ** len(X0)) - 1)

Fixed submission:
from collections import Counter
N, A = map(int, input().split())
X = [int(x) - A for x in input().split()]
C = Counter([0])
for x in X:
  tmp = Counter()
  for i, c in C.items():
    tmp[i + x] += c
  C += tmp
print(C[0] - 1)

Buggy python submission (verdict: Time Limit Exceeded):
N, A = map(int, input().split())
X = [int(x) for x in input().split()]
X.sort()
ans = 0
for i in range(1, 2 ** N):
  mask = bin(i)[2:]
  mask = [0 for x in range(N - len(mask))] + [int(s) for s in mask]
  if sum([X[j] * mask[j] for j in range(N)]) / sum(mask) == A:
    ans += 1
print(ans)

Fixed submission:
from collections import Counter
N, A = map(int, input().split())
X = [int(x) - A for x in input().split()]
C = Counter([0])
for x in X:
  tmp = Counter()
  for i, c in C.items():
    tmp[i + x] += c
  C += tmp
print(C[0] - 1)