Problem:
 Score : 300 points    Problem Statement Tak has N cards. On the i -th (1 \leq i \leq N) card is written an integer x_i .
He is selecting one or more cards from these N cards, so that the average of the integers written on the selected cards is exactly A .
In how many ways can he make his selection?      Constraints  1 \leq N \leq 50  1 \leq A \leq 50  1 \leq x_i \leq 50  N,\,A,\,x_i are integers.       Partial Score  200 points will be awarded for passing the test set satisfying 1 \leq N \leq 16 .         Input The input is given from Standard Input in the following format:  N  A  x_1  x_2  ...  x_N       Output Print the number of ways to select cards such that the average of the written integers is exactly A .        Sample Input 1 4 8
7 9 8 9      Sample Output 1 5   The following are the 5 ways to select cards such that the average is 8 :  Select the 3 -rd card.  Select the 1 -st and 2 -nd cards.  Select the 1 -st and 4 -th cards.  Select the 1 -st, 2 -nd and 3 -rd cards.  Select the 1 -st, 3 -rd and 4 -th cards.          Sample Input 2 3 8
6 6 9      Sample Output 2 0       Sample Input 3 8 5
3 6 2 8 7 6 5 9      Sample Output 3 19       Sample Input 4 33 3
3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3      Sample Output 4 8589934591   The answer may not fit into a 32 -bit integer.

Solution (Python):
N, A = map(int, input().split())
*X, = map(lambda x:int(x)-A, input().split())

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

for i in range(1,N):
    for v in range(-M, M+1):
        dp[i][v+M] += dp[i-1][v+M]
        if -M<=v-X[i]<=M:
            dp[i][v+M] += dp[i-1][v-X[i]+M]

print(dp[-1][M]-1)

Solution (Python):
from collections import defaultdict

n, a = map(int, input().split())
x = list(map(int, input().split()))
y = [xi - a for xi in x]


dp = [defaultdict(int) for i in range(n + 1)]
dp[0][0] = 1
for i in range(n):
    for j in dp[i]:
        dp[i + 1][j + y[i]] += dp[i][j]
        dp[i + 1][j] += dp[i][j]
print(dp[n][0] - 1)

Solution (Python):
from collections import defaultdict

n, a = map(int, input().split())
x = list(map(int, input().split()))
y = [xi - a for xi in x]


dp = [defaultdict(int) for i in range(n + 1)]
dp[0][0] = 1
for i in range(n):
    for j in dp[i]:
        dp[i + 1][j + y[i]] += dp[i][j]
        dp[i + 1][j] += dp[i][j]
print(dp[n][0] - 1)

Solution (Python):
import sys
input=sys.stdin.readline

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

dp=[[[0]*(n+1) for i in range(2501)] for j in range(n+1)]

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

for i in range(n):
    for j in range(2501):
        for k in range(n+1):
            dp[i+1][j][k]+=dp[i][j][k]
            if j+x[i]<=2500 and k+1<=n:
                dp[i+1][j+x[i]][k+1]+=dp[i][j][k]

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

print(ans)

Solution (Python):
N,A=map(int,input().split())
X=list(map(int,input().split()))
DP=[[0]*2501 for i in range(N+1)]
DP[0][0]=1
for k in range(N):
  for i in range(N-1,-1,-1):
    for j in range(2450,-1,-1):
      DP[i+1][j+X[k]]+=DP[i][j]
P=0
for i in range(N+1):
  P+=DP[i][i*A]
print(P-1)

Solution (Python):
def main():
    n, a = list(map(int, input().split()))
    X = list(map(lambda x: int(x) - a, input().split()))
    b = max(max([x for x in X]) + a, a)
    dp = [[0] * (2 * b * n + 1) for  _ in range(n + 1)]
    dp[0][b * n] = 1
    for i in range(1, n + 1):
        for j in range(2 * b * n + 1):
            if 0 <= j - X[i - 1] < 2 * b * n:
                dp[i][j] = dp[i - 1][j] + dp[i - 1][j - X[i - 1]]
            else:
                dp[i][j] = dp[i - 1][j]
    print(dp[n][b * n] - 1)

if __name__ == '__main__':
    main()

Solution (Python):
n,a=map(int,input().split())
x=[int(j)-a for j in input().split()]
from collections import defaultdict
dp=[defaultdict(int)for i in range(n+1)]
dp[0][0]=1
for i,j in enumerate(x,1):
    l=dp[i-1].copy()
    for k in dp[i-1]:
        l[k+j]+=dp[i-1][k]
    dp[i]=l

print(dp[-1][0]-1)

Solution (Python):


import sys
read = sys.stdin.read
readline = sys.stdin.readline

n,a,*x = map(int,read().split())

x = [i-a for i in x]

d = {0:1}
for i in x:
    nd = d.copy()
    for k,v in d.items():
        if k+i in nd:
            nd[k+i] += v
        else:
            nd[k+i] = v

    d = nd

    
print(d[0]-1)

Solution (Python):
N,A=list(map(int,input().split()))
x = list(map(int,input().split()))
sx = sum(x)
dp=[[0]*(N+1) for i in range(sx+1)]
dp[0][0]=1
for i in range(N):
  dp_sub=[[0]*(N+1) for j in range(sx+1)]
  for j in range(sx+1):
    for k in range(N+1):
      if dp[j][k]!=0:
        dp_sub[j+x[i]][k+1]=dp[j][k]
  for j in range(sx+1):
    for k in range(N+1):
      dp[j][k]+=dp_sub[j][k]

cnt=0

for i in range(min(sx//A,N)):
  cnt+=dp[A*(i+1)][i+1]
print(cnt)

Solution (Python):
n,a = map(int,input().split())
x = list(map(int,input().split()))


dp = [[[0]*(a*n+1) for k in range(n+1) ] for j in range(n)]

dp[0][0][0] = 1
if x[0]<= a*n:
    dp[0][1][x[0]] = 1
    
for j in range(n-1):
    for k in range(n+1):
        for s in range(a*n+1):
            if k == 0 and s == 0:
                dp[j+1][k][s] = 1
            elif k>j+2:
                dp[j+1][k][s]=0
            elif s>=x[j+1] and k>= 1:
                dp[j+1][k][s]=dp[j][k][s] + dp[j][k-1][s-x[j+1]]
            else:
                dp[j+1][k][s]=dp[j][k][s]

res = 0
for i in range(1,n+1):
    res += dp[n-1][i][a*i]

print(res)

Solution (Python):
card_num, target_average = list(map(int, input().split()))
x = list(map(int, input().split()))

dp = [[[0]*(card_num * target_average + 1) for _ in range(card_num + 1)] for _ in range(card_num + 1)]
dp[0][0][0] = 1


for i in range(card_num):
  
  for n in range(card_num):
    
    for sm in range(card_num * target_average):
      if dp[i][n][sm] == 0:
        continue
      
      dp[i + 1][n][sm] += dp[i][n][sm]
      
      if sm + x[i] <= card_num * target_average:
        dp[i + 1][n + 1][sm + x[i]] += dp[i][n][sm]

ans = 0
for n in range(1, card_num + 1):
  ans += dp[card_num][n][n * target_average]

print(ans)

Solution (Python):
n,a=map(int,input().split())
x=list(map(int,input().split()))
for i in range(n):
  x[i]-=a
dp=[]
for i in range(n+1):
  dp.append([])
  for i in range(6000):
    dp[-1].append(0)
dp[0][3000]=1
for i in range(n):
  for j in range(6000):
    if j+x[i]<6000 and j+x[i]>=0:
      dp[i+1][j+x[i]]+=dp[i][j]
      dp[i+1][j]+=dp[i][j]
print(dp[n][3000]-1)

Solution (Python):
N, A, *x = map(int, open(0).read().split())
dp = [[[0]*(3000) for _ in range(55)] for _ in range(55)]
dp[0][0][0] = 1

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

Solution (Python):

N,A=map(int,input().split())
X=[""]+list(map(int,input().split()))
for i in range(1,N+1):
    X[i]-=A

dp=[[0 for j in range(5001)] for i in range(N+1)]

dp[0][2500]=1

for i in range(1,N+1):
    for j in range(5001):
        dp[i][j]+=dp[i-1][j]
        if 0<=j+X[i]<=5000:
            dp[i][j+X[i]]+=dp[i-1][j]

print(dp[N][2500]-1)

Solution (Python):
N, A = map(int, input().split())
X = list(map(int, input().split()))

dp = [[[0 for k in range(50 * N + 1)] for j in range(N + 1)] for i in range(N + 1)]

for i in range(N):
    dp[i][0][0] = 1

for i in range(N):
    for j in range(N):
        for k in range(50 * N + 1):
            if k - X[i] >= 0:
                dp[i + 1][j + 1][k] += dp[i][j][k - X[i]]
            dp[i + 1][j + 1][k] += dp[i][j + 1][k]

res = 0

for j in range(N + 1):
    for k in range(50 * N + 1):
        if k == j * A:
            res += dp[N][j][k]

print(res)

Solution (Python):
N,A = map(int,input().split())
X = list(map(int,input().split()))
X = [A-x for x in X]
dp = [[0]*(5001) for _ in range(N+1)]
dp[0][2500] = 1
for i in range(1,N+1):
    x = X[i-1]
    for j in range(5001):
        if 0<=j-x<5001:
            dp[i][j] = dp[i-1][j-x]+dp[i-1][j]
        else:
            dp[i][j] = dp[i-1][j]

print(dp[-1][2500]-1)

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    N, A = map(int, input().split())
    X = list(map(int, input().split()))

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

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

                
                if s + X[i] <= N * A:
                    dp[i + 1][k + 1][s + X[i]] += dp[i][k][s]

    ans = 0
    for i in range(1, N + 1):
        ans += dp[-1][i][i * A]

    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
N,A = map(int,input().split())
X = map(int,input().split())
X = [x-A for x in X]
dp = [[0]*(5001) for _ in range(N+1)]
dp[0][2500] = 1
for i in range(1,N+1):
    x = X[i-1]
    for j in range(5001):
        dp[i][j] += dp[i-1][j]
        if 0<=j-x<5001:
            dp[i][j] += dp[i-1][j-x]

print(dp[-1][2500]-1)

Solution (Python):
N,A = map(int, input().split())
x = list(map(int,input().split()))

INF = 2500

y = [i-A for i in x]
y.sort()

y1 = [abs(x) for x in y if x < 0]
y2 = [x for x in y if x > 0]

y3 = [x for x in y if x == 0]


def p(y,A):
      dp=[[0 for i in range(A+1)] for j in range(N+1)]
      dp[0][0]=1
      N1 = len(y)
      
      for i in range(N1):
          for j in range(A+1):
              if y[i]<=j: 
                  dp[i+1][j]=dp[i][j-y[i]]+ dp[i][j]
              else: 
                  dp[i+1][j]=dp[i][j]
      return dp[N1]


dp1 = p(y1,INF)
dp1[0] = 0
dp2 = p(y2,INF)

n = min(len(dp1),len(dp2))

ans = 2 ** len(y3) - 1
for i in range(INF):
    ans += dp1[i] * dp2[i] * (2 ** len(y3))

print(ans)

Solution (Python):
mod = 10**9+7
import sys
import math
from collections import Counter, defaultdict, deque
import copy




















 








sys.setrecursionlimit(10 ** 6)

int1 = lambda x: int(x) - 1


p2D = lambda x: print(*x, sep="\n")

def II(): return int(sys.stdin.readline())

def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())




def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI(): return list(map(lambda x:int(x), sys.stdin.readline().split()))
def HI(): return list(map(lambda x:int(x)*(-1), sys.stdin.readline().split()))


N, A=MI()
X = LI()

X = [x-A for x in X]
d = defaultdict(int)
d[0] = 1
for x in X:
	
	for k,v in list(d.items()):
		d[k+x] = d[k+x]+v
	
	
print(d[0]-1)

Solution (Python):
N,A = map(int,input().split())
X = list(map(int,input().split()))
Y = [x-A for x in X]
t = sum(X)
dp = [[0]*(t*2+1) for _ in range(N+1)]



dp[0][t] = 1

for i in range(1,N+1):
    y = Y[i-1]
    for j in range(t*2+1):
        if 0 <= j-y <= t*2:
            dp[i][j] += dp[i-1][j-y]
        dp[i][j] += dp[i-1][j]

print(dp[-1][t]-1)

Solution (Python):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce, lru_cache  
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return (int(x) for x in input().split())
def LI(): return list(Is())
def TI(): return tuple(Is())
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(S())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = 10**18


n, a = Is()
X = LI()
Y = [x-a for x in X]

dp = [[0]*101*(n+1) for _ in range(n+1)]
dp[0][0] = 1
for i in range(1, n+1):
    for j in range(-50*(n+1), 51*(n+1)):
        dp[i][j] += dp[i-1][j]
        dp[i][j+Y[i-1]] += dp[i-1][j]
print(dp[n][0]-1)

Solution (Python):
n,a=map(int,input().split())
x=list(map(int,input().split()))
dp=[[[0 for i in range(2501)] for j in range(k+2)] for k in range(n+1)]

dp[0][0][0]=1
for i in range(n):
    see=x[i]
    for j in range(i+2):
        for k in range(2501):
            dp[i+1][j][k]+=dp[i][j][k]
            if see>k or j==0:continue
            dp[i+1][j][k]+=dp[i][j-1][k-see]
ans=0
for i in range(1,n+1):
    ans+=dp[-1][i][i*a]
print(ans)

Solution (Python):
"""
普通に数え上げDPで行けそう
dp[i][j][k] ->　カードをi枚使う/j種類目のカードまで見る/カードの数字の合計がkになる
j種類目のカードを使う場合：
dp[i][j][k] += dp[i-1][j-1][k-x]
j種類目のカードを使わない場合：
dp[i][j][k] += dp[i][j-1][k]

という風に計算していって、最終的に各iごとにk/i=Aとなるようなkを見出して、dp[i][-1][k]をanswerとして加算する。
"""
N,A = map(int,input().split())
X = list(map(int,input().split()))
sumX = sum(X)
dp = [[[0]*(sumX+1) for _ in range(N+1)]for _ in range(N+1)]
for j in range(N+1):
    dp[0][j][0] = 1
for i in range(1,N+1):
    for j in range(1,N+1):
        x = X[j-1]
        for k in range(1,sumX+1):
            dp[i][j][k] += dp[i][j-1][k]
            if k-x >= 0:
                dp[i][j][k] += dp[i-1][j-1][k-x]
ans = 0
for i in range(1,N+1):
    target = A*i
    if target <= sumX:
        ans += dp[i][-1][target]

print(ans)

Solution (Python):
import sys
from collections import defaultdict


def main():
    N, A, *xlst = map(int, sys.stdin.read().split())
    x_p = []
    x_n = []
    x_z = 0
    for i in xlst:
        if A < i:
            x_p.append(i - A)
        elif i < A:
            x_n.append(A - i)
        else:
            x_z += 1
    x_p.sort(), x_n.sort()

    x_p_sum, x_n_sum = defaultdict(int, {0: 1}), defaultdict(int, {0: 1})

    for i in range(len(x_p)):
        for j in sorted(x_p_sum, reverse=1):
            x_p_sum[j + x_p[i]] += x_p_sum[j]

    for i in range(len(x_n)):
        for j in sorted(x_n_sum, reverse=1):
            x_n_sum[j + x_n[i]] += x_n_sum[j]

    res = sum(x_n_sum[i] * x_p_sum[i] for i in x_p_sum if i in x_n_sum)
    res *= 1 << x_z
    res -= 1
    print(res)


if __name__ == '__main__':
    main()

Solution (Python):
import sys
from collections import defaultdict


def main():
    N, A, *xlst = map(int, sys.stdin.read().split())
    x_p = []
    x_n = []
    x_z = 0
    for i in xlst:
        if A < i:
            x_p.append(i - A)
        elif i < A:
            x_n.append(A - i)
        else:
            x_z += 1
    x_p.sort(), x_n.sort()

    x_p_sum = defaultdict(int, {0: 1})
    x_n_sum = defaultdict(int, {0: 1})
    for i in range(len(x_p)):
        for j in sorted(x_p_sum, reverse=1):
            x_p_sum[j + x_p[i]] += x_p_sum[j]

    for i in range(len(x_n)):
        for j in sorted(x_n_sum, reverse=1):
            x_n_sum[j + x_n[i]] += x_n_sum[j]

    res = 0
    for i in x_p_sum:
        if i in x_n_sum:
            res += (x_n_sum[i] * x_p_sum[i])
    res *= 1 << x_z
    res -= 1
    print(res)


if __name__ == '__main__':
    main()

Solution (Python):
import sys
from collections import defaultdict


def main():
    N, A, *xlst = map(int, sys.stdin.read().split())
    x_p = []
    x_n = []
    x_z = 0
    xlst.sort()
    for i in xlst:
        if A < i:
            x_p.append(i - A)
        elif i < A:
            x_n.append(A - i)
        else:
            x_z += 1

    x_p_sum = defaultdict(int, {0: 1})
    x_n_sum = defaultdict(int, {0: 1})
    for i in range(len(x_p)):
        for j in sorted(x_p_sum, reverse=1):
            x_p_sum[j + x_p[i]] += x_p_sum[j]

    for i in range(len(x_n)):
        for j in sorted(x_n_sum, reverse=1):
            x_n_sum[j + x_n[i]] += x_n_sum[j]

    res = 0
    for i in x_n_sum:
        if i in x_p_sum:
            res += (x_n_sum[i] * x_p_sum[i])
    res *= 1 << x_z
    res -= 1
    print(res)


if __name__ == '__main__':
    main()

Solution (Python):
import sys
from collections import defaultdict


def main():
    N, A, *xlst = map(int, sys.stdin.read().split())
    x_p = []
    x_n = []
    x_z = 0
    for i in xlst:
        i = int(i)
        if A < i:
            x_p.append(i - A)
        elif i < A:
            x_n.append(A - i)
        else:
            x_z += 1
    x_p.sort()
    x_n.sort()
    x_p_sum = defaultdict(int, {0: 1})
    x_n_sum = defaultdict(int, {0: 1})
    for i in range(len(x_p)):
        for j in sorted(x_p_sum, reverse=1):
            x_p_sum[j + x_p[i]] += x_p_sum[j]

    for i in range(len(x_n)):
        for j in sorted(x_n_sum, reverse=1):
            x_n_sum[j + x_n[i]] += x_n_sum[j]

    res = 0
    for i in x_n_sum:
        if i in x_p_sum:
            res += (x_n_sum[i] * x_p_sum[i])
    res *= 1 << x_z
    res -= 1
    print(res)


if __name__ == '__main__':
    main()

Solution (Python):
import sys
from collections import defaultdict


def main():
    N, A, *xlst = map(int, sys.stdin.read().split())
    x_p = []
    x_n = []
    x_z = 0
    for i in xlst:
        i = int(i)
        if A < i:
            x_p.append(i - A)
        elif i < A:
            x_n.append(A - i)
        else:
            x_z += 1
    x_p.sort()
    x_n.sort()
    x_p_sum = [defaultdict(int, {0: 1})]
    x_n_sum = [{0: 1}]
    for i in range(len(x_p)):
        x_p_sum.append(defaultdict(int, x_p_sum[-1]))
        for j in sorted(x_p_sum[-2]):
            x_p_sum[-1][j + x_p[i]] += x_p_sum[-2][j]

    for i in range(len(x_n)):
        x_n_sum.append(defaultdict(int, x_n_sum[-1]))
        for j in sorted(x_n_sum[-2]):
            x_n_sum[-1][j + x_n[i]] += x_n_sum[-2][j]

    res = 0
    for i in x_n_sum[-1]:
        if i in x_p_sum[-1]:
            res += (x_n_sum[-1][i] * x_p_sum[-1][i])
    res *= 1 << x_z
    res -= 1
    print(res)


if __name__ == '__main__':
    main()

Solution (Python):
n,a=map(int,input().split())
l=list(map(int,input().split()))
dp=[0]*5300
dp[l[0]-a]=1

for x in l[1:]:
  b=x-a
  if b>=0:
    for i in range(2500,-2501,-1):
      dp[i+b]+=dp[i]
  else:
    for i in range(-2500,2501):
      dp[i+b]+=dp[i]
  dp[b]+=1
print(dp[0])

Solution (Python):
import sys
input = sys.stdin.buffer.readline
import numpy as np

def main():
	N,A = map(int,input().split())
	x = list(map(int,input().split()))
	for i in range(N):
		x[i] -= A

	base = 50*50
	dp = np.zeros(base*2+1,dtype=int)
	dp[base] = 1
	for num in x:
		if num == 0:
			use = dp.copy()
			dp += use
		elif num > 0:
			use = dp[:-num].copy()
			dp[num:] += use
		else:
			use = dp[-num:].copy()
			dp[:num] += use

	print(dp[base]-1)

if __name__ == "__main__":
	main()

Solution (Python):
def main():
    offset = 2500
    W = 2 * offset + 1
    N, A = list(map(int, input().split(' ')))
    x = list(map(int, input().split(' ')))
    y = [xx - A for xx in x]
    dp = [[0 for _ in range(W)] for _ in range(N)]
    dp[0][0 + offset] += 1
    dp[0][y[0] + offset] += 1
    for i in range(1, N):
        for j in range(W):
            dp[i][j] = dp[i - 1][j]
            if 0 <= j - y[i] <= W - 1:
                dp[i][j] += dp[i - 1][j - y[i]]
    print(dp[N - 1][0 + offset] - 1)  


if __name__ == '__main__':
    main()

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    N,A=map(int,input().split())
    X=list(map(int,input().split()))

    
    
    INF = 10**10  
    
    I ,J,K=N,N,A*N
    
    dp = [[[0]*(K+1) for _ in range(J+1)]for _ in range(I+1)]
    
    for i in range(I+1):
        dp[i][0][0] = 1
    
    for i in range(1, I+1):
        for j in range(1,J+1):
            for k in range(K+1):
                if k>=X[i-1]:
                    dp[i][j][k]=dp[i-1][j-1][k-X[i-1]]+dp[i-1][j][k]
                else:
                    dp[i][j][k]=dp[i-1][j][k]

    print(sum([dp[I][j][A*j] for j in range(1,N+1)]))
    

    
resolve()

Solution (Python):
import sys

N, A = map(int, sys.stdin.readline().strip().split())
X = list(map(int, sys.stdin.readline().strip().split()))


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

dp[0][0][0] = 1
for i in range(N):
    for j in range(N):
        for k in range(MAX_N):
            if dp[i][j][k] > 0:
                
                dp[i+1][j][k] += dp[i][j][k]
                
                dp[i+1][j+1][k+X[i]] += dp[i][j][k]

ans = 0
for i in range(1, N+1):
    ans += dp[N][i][A*i]
print(ans)

Solution (Python):
import bisect
import copy
import heapq
import sys
import itertools
import math
import queue
input = sys.stdin.readline
sys.setrecursionlimit(1000000)

mod = 998244353 

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]
def init_dp1(init, N): return [init for _ in range(N)]
def init_dp2(init, N, M): return [[init for _ in range(M)] for _ in range(N)]


def main():
    N, X = read_values()
    A = read_list()

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

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

    for i, a in enumerate(A):
        for j in range(N + 1):
            for k in range(N * X):
                if k + a <= N * X and j < N:
                    dp[i + 1][j + 1][k + a] += dp[i][j][k]
                dp[i + 1][j][k] += dp[i][j][k]
    
    res = 0
    for i in range(1, N + 1):
        res += dp[N][i][i * X]

    print(res)


if __name__ == "__main__":
    main()

Solution (Python):
N, A = map(int, input().split())
X = [int(x) for x in input().split()]


dp = [[0] * (50*N+1) for x in range(N+1)]
dp[0][0] = 1


for i in range(N):
    for k in range(N, 0, -1):
        for pt in range(50*N, 0, -1):
            if pt >= X[i]:
                dp[k][pt] += dp[k-1][pt-X[i]]



ans = 0
for i in range(1, N+1):
    ans += dp[i][A*i]
print(ans)

Solution (Python):
def main():
    N, A = map(int, input().split())
    x = [0]
    x.extend(list(map(int, input().split())))

    dp = [[[0] * (N * A + 1) for _ in range(N + 1)] for _ in range(N + 1)]
    for i in range(N + 1):
        dp[i][0][0] = 1

    for i in range(1, N + 1):
        for j in range(1, i + 1):
            for k in range(1, N * A + 1):
                if k < x[i]:
                    dp[i][j][k] = dp[i - 1][j][k]
                else:
                    dp[i][j][k] = dp[i - 1][j][k] + dp[i - 1][j - 1][k - x[i]]

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

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
def main():
    N, A = map(int, input().split())
    x = [0]
    x.extend(list(map(int, input().split())))

    dp = [[[0] * (N * A + 1) for _ in range(N + 1)] for _ in range(N + 1)]
    for i in range(N + 1):
        dp[i][0][0] = 1

    for i in range(1, N + 1):
        for j in range(1, i + 1):
            for k in range(1, N * A + 1):
                if k < x[i]:
                    dp[i][j][k] = dp[i - 1][j][k]
                else:
                    dp[i][j][k] = dp[i - 1][j][k] + dp[i - 1][j - 1][k - x[i]]

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

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
def main():
    N, A = map(int, input().split())
    x = [0]
    x.extend(list(map(int, input().split())))

    dp = [[[0] * (N * A + 1) for _ in range(N + 1)] for _ in range(N + 1)]
    for i in range(N + 1):
        dp[i][0][0] = 1

    for i in range(1, N + 1):
        for j in range(1, i + 1):
            for k in range(1, N * A + 1):
                if k < x[i]:
                    dp[i][j][k] = dp[i - 1][j][k]
                else:
                    dp[i][j][k] = dp[i - 1][j][k] + dp[i - 1][j - 1][k - x[i]]

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

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
def main():
    N, A = map(int, input().split())
    x = [0]
    x.extend(list(map(int, input().split())))

    dp = [[[0] * (N * A + 1) for _ in range(N + 1)] for _ in range(N + 1)]
    for i in range(N + 1):
        dp[i][0][0] = 1

    for i in range(1, N + 1):
        for j in range(1, i + 1):
            for k in range(1, N * A + 1):
                if k < x[i]:
                    dp[i][j][k] = dp[i - 1][j][k]
                else:
                    dp[i][j][k] = dp[i - 1][j][k] + dp[i - 1][j - 1][k - x[i]]

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

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
def main():
    N, A = map(int, input().split())
    x = [0]
    x.extend(list(map(int, input().split())))

    dp = [[[0] * (N * A + 1) for _ in range(N + 1)] for _ in range(N + 1)]
    for i in range(N + 1):
        dp[i][0][0] = 1

    for i in range(1, N + 1):
        for j in range(1, i + 1):
            for k in range(1, N * A + 1):
                if k < x[i]:
                    dp[i][j][k] = dp[i - 1][j][k]
                else:
                    dp[i][j][k] = dp[i - 1][j][k] + dp[i - 1][j - 1][k - x[i]]

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

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
def main():
    N, A = map(int, input().split())
    x = [0]
    x.extend(list(map(int, input().split())))

    dp = [[[0] * (N * A + 1) for _ in range(N + 1)] for _ in range(N + 1)]
    for i in range(N + 1):
        dp[i][0][0] = 1

    for i in range(1, N + 1):
        for j in range(1, i + 1):
            for k in range(1, N * A + 1):
                if k < x[i]:
                    dp[i][j][k] = dp[i - 1][j][k]
                else:
                    dp[i][j][k] = dp[i - 1][j][k] + dp[i - 1][j - 1][k - x[i]]

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

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
def main():
    N, A = map(int, input().split())
    x = [0]
    x.extend(list(map(int, input().split())))

    dp = [[[0] * (N * A + 1) for _ in range(N + 1)] for _ in range(N + 1)]
    for i in range(N + 1):
        dp[i][0][0] = 1

    for i in range(1, N + 1):
        for j in range(1, i + 1):
            for k in range(1, N * A + 1):
                if k < x[i]:
                    dp[i][j][k] = dp[i - 1][j][k]
                else:
                    dp[i][j][k] = dp[i - 1][j][k] + dp[i - 1][j - 1][k - x[i]]

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

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
def main():
    N, A = map(int, input().split())
    x = [0]
    x.extend(list(map(int, input().split())))

    dp = [[[0] * (N * A + 1) for _ in range(N + 1)] for _ in range(N + 1)]
    for i in range(N + 1):
        dp[i][0][0] = 1

    for i in range(1, N + 1):
        for j in range(1, i + 1):
            for k in range(1, N * A + 1):
                if k < x[i]:
                    dp[i][j][k] = dp[i - 1][j][k]
                else:
                    dp[i][j][k] = dp[i - 1][j][k] + dp[i - 1][j - 1][k - x[i]]

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

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
def main():
    N, A = map(int, input().split())
    x = [0]
    x.extend(list(map(int, input().split())))

    dp = [[[0] * (N * A + 1) for _ in range(N + 1)] for _ in range(N + 1)]
    for i in range(N + 1):
        dp[i][0][0] = 1

    for i in range(1, N + 1):
        for j in range(1, i + 1):
            for k in range(1, N * A + 1):
                if k < x[i]:
                    dp[i][j][k] = dp[i - 1][j][k]
                else:
                    dp[i][j][k] = dp[i - 1][j][k] + dp[i - 1][j - 1][k - x[i]]

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

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
N,A=map(int,input().split())
x=list(map(int,input().split()))
x=list(map(lambda x:x-A,x))
dp=[]
MX=50*50
for i in range(N+1):
    dp.append([0 for j in range(2*MX+2)])
dp[0][MX]=1
for i in range(N):
    for j in range(2*MX+2):
        dp[i+1][j]+=dp[i][j]
        if 0<=j+x[i]<=2*MX+1:
            dp[i+1][j+x[i]]+=dp[i][j]
print(dp[N][MX]-1)

Solution (Python):
def main():
    N, A = map(int, input().split())
    x = [0]
    x.extend(list(map(int, input().split())))

    dp = [[[0 for _ in range(N * A + 1)] for _ in range(N + 1)] for _ in range(N + 1)]
    for i in range(N + 1):
        dp[i][0][0] = 1

    for i in range(1, N + 1):
        for j in range(1, i + 1):
            for k in range(1, N * A + 1):
                if k < x[i]:
                    dp[i][j][k] = dp[i - 1][j][k]
                else:
                    dp[i][j][k] = dp[i - 1][j][k] + dp[i - 1][j - 1][k - x[i]]

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

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
def main():
    N, A = map(int, input().split())
    x = [0]
    x.extend(list(map(int, input().split())))

    dp = [[[0 for _ in range(N * A + 1)] for _ in range(N + 1)] for _ in range(N + 1)]
    for i in range(N + 1):
        dp[i][0][0] = 1

    for i in range(1, N + 1):
        for j in range(1, i + 1):
            for k in range(1, N * A + 1):
                if k < x[i]:
                    dp[i][j][k] = dp[i - 1][j][k]
                else:
                    dp[i][j][k] = dp[i - 1][j][k] + dp[i - 1][j - 1][k - x[i]]

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

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
def main():
    N, A = map(int, input().split())
    x = [0]
    x.extend(list(map(int, input().split())))

    dp = [[[0 for _ in range(N * A + 1)] for _ in range(N + 1)] for _ in range(N + 1)]
    for i in range(N + 1):
        dp[i][0][0] = 1

    for i in range(1, N + 1):
        for j in range(1, i + 1):
            for k in range(1, N * A + 1):
                if k < x[i]:
                    dp[i][j][k] = dp[i - 1][j][k]
                else:
                    dp[i][j][k] = dp[i - 1][j][k] + dp[i - 1][j - 1][k - x[i]]

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

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
def main():
    N, A = map(int, input().split())
    x = [0]
    x.extend(list(map(int, input().split())))

    dp = [[[0 for _ in range(N * A + 1)] for _ in range(N + 1)] for _ in range(N + 1)]
    for i in range(N + 1):
        dp[i][0][0] = 1

    for i in range(1, N + 1):
        for j in range(1, i + 1):
            for k in range(1, N * A + 1):
                if k < x[i]:
                    dp[i][j][k] = dp[i - 1][j][k]
                else:
                    dp[i][j][k] = dp[i - 1][j][k] + dp[i - 1][j - 1][k - x[i]]

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

    print(ans)


if __name__ == '__main__':
    main()