Language: C++

# encoding: utf-8
N, A = map(int, input().split())
x = list(map(int, input().split()))
MAX_X = 50

x.sort()

memo = [None] * (N * N * MAX_X * N)

def get(pos, tmp, cnt):
    # print("#", pos, tmp, cnt)
    # end
    if pos == N:
        if cnt > 0 and cnt * A == tmp:
            # print("##", pos, tmp, cnt, "end\tret=", 1)
            return 1
        else: return 0
    # read memo
    idx_memo = pos * (N * N * MAX_X) + cnt * (N * MAX_X) + tmp
    if memo[idx_memo] != None:
        # print("##", pos, tmp, cnt, "memo\tret=", memo[idx_memo])
        return memo[idx_memo]
    for cnt_sub in range(1, cnt):
        if tmp % cnt > 0: break
        tmp_sub = (tmp // cnt) * cnt_sub
        idx_memo = pos * (N * N * MAX_X) + cnt_sub * (N * MAX_X) + tmp_sub
        if memo[idx_memo] != None:
            # print("##", pos, tmp, cnt, "sub\tret=", memo[idx_memo])
            return memo[idx_memo]
    # process
    ret = 0
    ret += get(pos + 1, tmp + x[pos], cnt + 1) # take
    ret += get(pos + 1, tmp, cnt) # pass
    # write memo
    idx_memo = pos * (N * N * MAX_X) + cnt * (N * MAX_X) + tmp
    if memo[idx_memo] == None: memo[idx_memo] = ret
    # for cnt_sub in range(1, cnt):
    #     if tmp % cnt > 0: break
    #     tmp_sub = (tmp // cnt) * cnt_sub
    #     idx_memo = pos * (N * N * MAX_X) + cnt_sub * (N * MAX_X) + tmp_sub
    #     if memo[idx_memo] == None: memo[idx_memo] = ret
    return ret

print(get(0, 0, 0))

Compiler output:
a.cc:1:3: error: invalid preprocessing directive #encoding
    1 | # encoding: utf-8
      |   ^~~~~~~~
a.cc:11:7: error: invalid preprocessing directive #print
   11 |     # print("#", pos, tmp, cnt)
      |       ^~~~~
a.cc:12:7: error: invalid preprocessing directive #end; did you mean #endif?
   12 |     # end
      |       ^~~
      |       endif
a.cc:15:15: error: invalid preprocessing directive #print
   15 |             # print("##", pos, tmp, cnt, "end\tret=", 1)
      |               ^~~~~
a.cc:18:7: error: invalid preprocessing directive #read
   18 |     # read memo
      |       ^~~~
a.cc:21:11: error: invalid preprocessing directive #print
   21 |         # print("##", pos, tmp, cnt, "memo\tret=", memo[idx_memo])
      |           ^~~~~
a.cc:28:15: error: invalid preprocessing directive #print
   28 |             # print("##", pos, tmp, cnt, "sub\tret=", memo[idx_memo])
      |               ^~~~~
a.cc:30:7: error: invalid preprocessing directive #process
   30 |     # process
      |       ^~~~~~~
a.cc:32:48: error: stray '#' in program
   32 |     ret += get(pos + 1, tmp + x[pos], cnt + 1) # take
      |                                                ^
a.cc:33:35: error: stray '#' in program
   33 |     ret += get(pos + 1, tmp, cnt) # pass
      |                                   ^
a.cc:34:7: error: invalid preprocessing directive #write
   34 |     # write memo
      |       ^~~~~
a.cc:37:7: error: invalid preprocessing directive #for
   37 |     # for cnt_sub in range(1, cnt):
      |       ^~~
a.cc:38:18: error: division by zero in #if
   38 |     #     if tmp % cnt > 0: break
      |                  ^
a.cc:38:27: error:  ':' without preceding '?'
   38 |     #     if tmp % cnt > 0: break
      |                           ^
a.cc:41: error: unterminated #if
   41 |     #     if memo[idx_memo] == None: memo[idx_memo] = ret
a.cc:38: error: unterminated #if
   38 |     #     if tmp % cnt > 0: break
a.cc:2:1: error: 'N' does not name a type
    2 | N, A = map(int, input().split())
      | ^