node_ids listlengths 4 1.4k | edge_index listlengths 1 2.22k | text listlengths 4 1.4k | source stringlengths 14 427k |
|---|---|---|---|
[
7,
15,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
41,
28,
13,
4,
13,
2,
13,
17,
4,
4,
13,
13,
0,
13,
13,
0,
18,
18,
13,
17,
17,
17,
28,
13,
4,
13,
13,
28,
13,
4,
13,
... | [
[
111,
3
],
[
111,
12
],
[
117,
14
],
[
28,
27
],
[
112,
31
],
[
120,
38
],
[
46,
41
],
[
121,
43
],
[
49,
48
],
[
112,
51
],
[
54,
53
],
[
112,
58
],
[
61,
60
],... | [
"from collections import defaultdict\nn, a = map(int, input().split())\nx = list(map(int, input().split()))\n\ndp = [defaultdict(int) for i in range(n+1)]\ndp[0][0] = 1\n\nfor i in range(n):\n for j in reversed(range(n)):\n for s in dp[j]:\n dp[j+1][s+x[i]] += dp[j][s]\n\n# for dp_i in dp:\n# ... | from collections import defaultdict
n, a = map(int, input().split())
x = list(map(int, input().split()))
dp = [defaultdict(int) for i in range(n+1)]
dp[0][0] = 1
for i in range(n):
for j in reversed(range(n)):
for s in dp[j]:
dp[j+1][s+x[i]] += dp[j][s]
# for dp_i in dp:
# print(dp_i)
a... |
[
7,
15,
13,
13,
15,
15,
15,
15,
15,
15,
15,
15,
15,
12,
13,
12,
13,
12,
13,
12,
13,
12,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
12,
13,
23,
13,
4,
18,
13,
13,
2,
17,
17,
0,
13,
2,
17,
17,
0,
13,
2,
2,
17,
17,
17,... | [
[
26,
25
],
[
254,
31
],
[
35,
35
],
[
259,
44
],
[
232,
49
],
[
244,
56
],
[
254,
58
],
[
244,
59
],
[
229,
61
],
[
218,
63
],
[
211,
65
],
[
256,
68
],
[
214,
71
... | [
"import sys, re\nfrom collections import deque, defaultdict, Counter\nfrom math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd\nfrom itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby\nfrom operator import i... | import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter... |
[
7,
15,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
18,
4,
13,
13,
4,
4,
13,
13,
0,
13,
13,
41,
28,
13,
13,
4,
2,
13,
13,
0,
13,
13,
0,
13,
4,
13,
13,
0,
18,
13,
17,
17,
28,
13,
13,
28,
13,
13,
4,... | [
[
85,
3
],
[
85,
12
],
[
16,
15
],
[
15,
24
],
[
82,
26
],
[
31,
30
],
[
83,
30
],
[
30,
34
],
[
86,
35
],
[
79,
37
],
[
88,
40
],
[
48,
45
],
[
89,
46
],
[
... | [
"from collections import defaultdict\n \nn, k = map(int, input().split())\nx = [int(i) for i in input().split()]\nx = [i-k for i in x]\ndic = defaultdict(int)\n\ndic[0]=1\nfor i in x:\n for k,v in list(dic.items()):\n dic[k+i]+=v\nprint(dic[0]-1)\n",
"from collections import defaultdict",
"n, k = map(... | from collections import defaultdict
n, k = map(int, input().split())
x = [int(i) for i in input().split()]
x = [i-k for i in x]
dic = defaultdict(int)
dic[0]=1
for i in x:
for k,v in list(dic.items()):
dic[k+i]+=v
print(dic[0]-1)
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
18,
4,
13,
13,
4,
4,
13,
13,
0,
13,
13,
41,
28,
13,
4,
13,
17,
4,
13,
0,
13,
13,
28,
13,
4,
13,
2,
13,
17,
0,
18,
18,
18,
13,
13,
17,
17,
17,
0,
13,... | [
[
179,
2
],
[
179,
11
],
[
15,
14
],
[
14,
23
],
[
173,
25
],
[
30,
29
],
[
182,
36
],
[
40,
39
],
[
177,
43
],
[
53,
46
],
[
183,
49
],
[
39,
50
],
[
185,
55
],
... | [
"n,x=map(int,input().split())\nl=[int(i) for i in input().split()]\ndp = [[[0 for k in range(55)] for j in range(3000)] for i in range(55)]\n\nfor i in range(n+1):\n dp[i][0][0]=1 \nsm=sum(l)\nfor i in range(1,n+1):\n for j in range(sm+5):\n for k in range(1,n+1):\n curr=l[i-1]\n ... | n,x=map(int,input().split())
l=[int(i) for i in input().split()]
dp = [[[0 for k in range(55)] for j in range(3000)] for i in range(55)]
for i in range(n+1):
dp[i][0][0]=1
sm=sum(l)
for i in range(1,n+1):
for j in range(sm+5):
for k in range(1,n+1):
curr=l[i-1]
if curr<=j:
... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
4,
13,
13,
41,
28,
13,
4,
13,
13,
4,
13,
0,
13,
13,
28,
13,
4,
13,
13,
28,
13,
4,
13,
2,
13,
17,
0,
18,
18,
18,
... | [
[
201,
2
],
[
201,
11
],
[
189,
13
],
[
204,
25
],
[
190,
28
],
[
32,
31
],
[
196,
34
],
[
192,
38
],
[
42,
41
],
[
196,
44
],
[
47,
46
],
[
41,
50
],
[
62,
53
],... | [
"N,A = map(int,input().split())\nx = list(map(int,input().split()))\nX = sum(x)\n\ndp = [[[0 for k in range(X+1)] for j in range(N+1)] for i in range(N)]\n\nfor i in range(N):\n for j in range(i+1):\n dp[i][1][x[j]] += 1\n\nfor i in range(N-1):\n for j in range(1,i+2):\n for k in range(X+1):\n ... | N,A = map(int,input().split())
x = list(map(int,input().split()))
X = sum(x)
dp = [[[0 for k in range(X+1)] for j in range(N+1)] for i in range(N)]
for i in range(N):
for j in range(i+1):
dp[i][1][x[j]] += 1
for i in range(N-1):
for j in range(1,i+2):
for k in range(X+1):
if 1 <= ... |
[
7,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
4,
13,
4,
13,
13,
13,
41,
28,
13,
4,
13,
2,
13,
17,
4,
13,
0,
13,
13,
0,
13,
17,
28,
13,
4,
13,
2,
13,
1... | [
[
222,
2
],
[
222,
13
],
[
213,
15
],
[
216,
27
],
[
214,
32
],
[
220,
33
],
[
37,
36
],
[
223,
40
],
[
228,
45
],
[
210,
48
],
[
52,
51
],
[
223,
55
],
[
59,
58
... | [
"N, A = list(map(int, input().split()))\nx = list(map(int, input().split()))\nX = max(max(x), A)\n\ndp=[[[0 for k in range(N*X+1)] for j in range(N+1)] for i in range(N+1)]\n\nans = 0\nfor j in range(N+1):\n for k in range(N+1):\n for s in range(N*X+1):\n if j==0 and k==0 and s==0:\n dp[j][k][s]=1\n... | N, A = list(map(int, input().split()))
x = list(map(int, input().split()))
X = max(max(x), A)
dp=[[[0 for k in range(N*X+1)] for j in range(N+1)] for i in range(N+1)]
ans = 0
for j in range(N+1):
for k in range(N+1):
for s in range(N*X+1):
if j==0 and k==0 and s==0:
dp[j][k][s]=1
elif j>=1 a... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
4,
13,
2,
13,
13,
4,
13,
13,
41,
28,
13,
4,
13,
2,
13,
17,
4,
13,
0,
13,
13,
0,
18,
18,
18,
13,
17,
17,
17,
17,
... | [
[
151,
2
],
[
151,
11
],
[
154,
13
],
[
157,
25
],
[
149,
29
],
[
152,
30
],
[
155,
33
],
[
37,
36
],
[
149,
40
],
[
160,
45
],
[
55,
48
],
[
161,
51
],
[
58,
57
... | [
"# C - 高橋君とカード\nn,a=map(int,input().split())\nx=list(map(int,input().split()))\n\nmax_num=max(n*a,sum(x))\ndp=[[[0]*(max_num+1) for j in range(n+1)] for i in range(n+1)]\ndp[0][0][0]=1\nfor i in range(n):\n for j in range(n):\n for k in range(max_num):\n if dp[i][j][k]:\n # not u... | # C - 高橋君とカード
n,a=map(int,input().split())
x=list(map(int,input().split()))
max_num=max(n*a,sum(x))
dp=[[[0]*(max_num+1) for j in range(n+1)] for i in range(n+1)]
dp[0][0][0]=1
for i in range(n):
for j in range(n):
for k in range(max_num):
if dp[i][j][k]:
# not use
... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
2,
13,
13,
41,
28,
13,
4,
13,
2,
13,
17,
4,
2,
39,
17,
2,
13,
17,
0,
13,
13,
0,
18,
18,
13,
17,
17,
17,
28,
13,
... | [
[
111,
2
],
[
111,
11
],
[
114,
13
],
[
120,
25
],
[
112,
27
],
[
109,
28
],
[
32,
31
],
[
109,
35
],
[
121,
42
],
[
117,
45
],
[
53,
48
],
[
118,
50
],
[
115,
59
... | [
"n, a = map(int, input().split())\nxxx = list(map(int, input().split()))\nlimit = a * n\ndp = [[0] * (limit + 1) for i in range(n + 1)]\ndp[0][0] = 1\nfor i, x in enumerate(xxx):\n if x > limit:\n continue\n for j in range(i, -1, -1):\n for k in range(limit - x, -1, -1):\n dp[j + 1][k... | n, a = map(int, input().split())
xxx = list(map(int, input().split()))
limit = a * n
dp = [[0] * (limit + 1) for i in range(n + 1)]
dp[0][0] = 1
for i, x in enumerate(xxx):
if x > limit:
continue
for j in range(i, -1, -1):
for k in range(limit - x, -1, -1):
dp[j + 1][k + x] += dp[j][... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
28,
13,
4,
13,
13,
0,
18,
13,
13,
13,
0,
13,
17,
28,
13,
4,
13,
13,
0,
13,
4,
13,
18,
13,
13,
0,
13,
17,
41,
28,
13,
4,
... | [
[
140,
2
],
[
140,
11
],
[
152,
13
],
[
26,
25
],
[
141,
28
],
[
33,
30
],
[
153,
31
],
[
25,
32
],
[
135,
33
],
[
143,
35
],
[
39,
38
],
[
141,
41
],
[
137,
43
]... | [
"n, a = map(int,input().split( ))\n\nx = list(map(int,input().split( )))\n\nfor i in range(n):\n x[i] -= a\n\nmx = 0\nfor i in range(n):\n mx += abs(x[i])\nmx +=1\n\ndp = [[0 for i in range(3*mx)] for j in range(n)]\ndp[0][0] += 1\ndp[0][x[0]] += 1\n\nfor i in range(1,n) :\n for j in range(-mx,mx):\n ... | n, a = map(int,input().split( ))
x = list(map(int,input().split( )))
for i in range(n):
x[i] -= a
mx = 0
for i in range(n):
mx += abs(x[i])
mx +=1
dp = [[0 for i in range(3*mx)] for j in range(n)]
dp[0][0] += 1
dp[0][x[0]] += 1
for i in range(1,n) :
for j in range(-mx,mx):
dp[i][j] += dp[i-1][j... |
[
7,
15,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
12,
13,
0,
13,
4,
13,
13,
41,
28,
13,
4,
13,
2,
13,
17,
4,
2,
39,
17,
2,
13,
17,
0,
13,
13,
0,
18,
18,
13,
17,
... | [
[
277,
4
],
[
277,
13
],
[
250,
15
],
[
30,
29
],
[
119,
32
],
[
36,
35
],
[
29,
39
],
[
121,
46
],
[
50,
49
],
[
57,
52
],
[
49,
54
],
[
60,
59
],
[
29,
62
],
... | [
"# C - 高橋君とカード / Tak and Cards\n\n#import numpy as np\nimport math\n\nN, A = map(int, input().split())\nx = list(map(int, input().split()))\n\n# 数列aと整数Aを与えると、aからいくつか取って合計Aにするパターンが何通りあるかを返す関数\ndef partial_sum(a,A):\n n = len(a)\n dp = [[0]*(A+2) for _ in range(n+2)] # dp[i+1][j] a[i]までの数からいくつか選んで総和をjにするパターンの数\... | # C - 高橋君とカード / Tak and Cards
#import numpy as np
import math
N, A = map(int, input().split())
x = list(map(int, input().split()))
# 数列aと整数Aを与えると、aからいくつか取って合計Aにするパターンが何通りあるかを返す関数
def partial_sum(a,A):
n = len(a)
dp = [[0]*(A+2) for _ in range(n+2)] # dp[i+1][j] a[i]までの数からいくつか選んで総和をjにするパターンの数
dp[0][0] = 1... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
41,
28,
13,
4,
13,
2,
13,
17,
4,
13,
0,
13,
13,
28,
13,
4,
13,
2,
13,
17,
0,
18,
18,
18,
13,
13,
17,
17,
17,
28,
13,
4,
... | [
[
182,
2
],
[
182,
11
],
[
188,
13
],
[
27,
26
],
[
180,
30
],
[
176,
35
],
[
39,
38
],
[
180,
42
],
[
52,
45
],
[
177,
48
],
[
38,
49
],
[
55,
54
],
[
180,
59
],... | [
"N, A = map(int,input().split())\nX = list(map(int,input().split()))\ndp = [[[0 for i in range(N*50+1)] for j in range(N+1)] for k in range(N+1)]\nfor i in range(N+1):\n dp[i][0][0] = 1\nfor i in range(1,N+1):\n x = X[i-1]\n for j in range(1,N+1):\n for k in range(N*50+1):\n if k < x:\n ... | N, A = map(int,input().split())
X = list(map(int,input().split()))
dp = [[[0 for i in range(N*50+1)] for j in range(N+1)] for k in range(N+1)]
for i in range(N+1):
dp[i][0][0] = 1
for i in range(1,N+1):
x = X[i-1]
for j in range(1,N+1):
for k in range(N*50+1):
if k < x:
d... |
[
7,
15,
13,
15,
0,
13,
4,
13,
13,
4,
18,
4,
18,
18,
13,
13,
13,
13,
13,
31,
13,
28,
13,
4,
13,
13,
12,
13,
0,
13,
4,
13,
13,
0,
18,
13,
17,
17,
28,
13,
4,
13,
13,
0,
13,
4,
18,
13,
13,
28,
13,
13,
4,
18,
13,
... | [
[
88,
5
],
[
88,
18
],
[
88,
19
],
[
23,
22
],
[
89,
25
],
[
30,
29
],
[
37,
34
],
[
29,
35
],
[
40,
39
],
[
89,
42
],
[
45,
44
],
[
29,
47
],
[
66,
47
],
[
... | [
"import sys\nfrom collections import defaultdict\n\nn, a, *x = map(int, sys.stdin.read().split())\nfor i in range(n): x[i] -= a\n\ndef main():\n dp = defaultdict(int); dp[0] = 1\n for i in range(n):\n ndp = dp.copy()\n for k, v in dp.items():\n ndp[k+x[i]] += v\n dp = ndp\n print(dp[0] - 1)\n \nif... | import sys
from collections import defaultdict
n, a, *x = map(int, sys.stdin.read().split())
for i in range(n): x[i] -= a
def main():
dp = defaultdict(int); dp[0] = 1
for i in range(n):
ndp = dp.copy()
for k, v in dp.items():
ndp[k+x[i]] += v
dp = ndp
print(dp[0] - 1)
if __name__ == '__main... |
[
7,
17,
15,
13,
0,
13,
18,
18,
13,
13,
13,
15,
12,
13,
29,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
4,
13,
13,
0,
13,
4,
13,
17,
0,
13,
4,
13,
13,
0,
13,
39,
28,
13,
13,
4,
18,
13,
13,
2,
13,
13,
41,
28,
1... | [
[
156,
5
],
[
157,
23
],
[
171,
26
],
[
178,
28
],
[
171,
29
],
[
153,
31
],
[
178,
33
],
[
165,
36
],
[
154,
39
],
[
168,
41
],
[
45,
44
],
[
154,
44
],
[
169,
48
... | [
"# https://atcoder.jp/contests/abc044/tasks/arc060_a\n# ソートしてからごちゃごちゃやればどうにかなりそう(無理でした)\n\n'''\n解説満点解法1\nもしもk枚選んだとき、合計がsになる通りの数がわかったら?→s=k*Aとなる場合の数の合計をすれば良い\n\nk枚選んだとき、合計がsになる通りの数は典型的なDP!\ndp(j,k,s)... X[0:j]からk枚選んで、その合計をsにするような選び方の総数\nと定義すると、\n\n更新則\ndp(j+1,k,s) = X[j]を選んだ結果sになったときの通りの数 + X[j]を選ばずにsになっている通りの数 なので\... | # https://atcoder.jp/contests/abc044/tasks/arc060_a
# ソートしてからごちゃごちゃやればどうにかなりそう(無理でした)
'''
解説満点解法1
もしもk枚選んだとき、合計がsになる通りの数がわかったら?→s=k*Aとなる場合の数の合計をすれば良い
k枚選んだとき、合計がsになる通りの数は典型的なDP!
dp(j,k,s)... X[0:j]からk枚選んで、その合計をsにするような選び方の総数
と定義すると、
更新則
dp(j+1,k,s) = X[j]を選んだ結果sになったときの通りの数 + X[j]を選ばずにsになっている通りの数 なので
すなわち
dp(j+1,k,s) ... |
[
7,
0,
13,
17,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
41,
28,
13,
4,
13,
13,
4,
13,
0,
13,
13,
0,
18,
18,
18,
13,
17,
17,
17,
17,
28,
13,
4,
13,
13,
28,
13,
4,
13,... | [
[
156,
2
],
[
150,
5
],
[
150,
14
],
[
144,
16
],
[
30,
29
],
[
157,
32
],
[
141,
36
],
[
46,
39
],
[
142,
42
],
[
49,
48
],
[
148,
51
],
[
54,
53
],
[
59,
58
],
... | [
"\nNMAX = 55\n\nN, A = map(int, input().split())\nX = list(map(int, input().split()))\n\ndp = [[[0] * NMAX for s in range(3000)] for i in range(NMAX)]\n\ndp[0][0][0] = 1 # dp[i][s][k]: i個からk個選ぶとき、総和がsのものの個数\nfor i in range(N): # N-1時点でNが更新されるのでここまでで十分\n for s in range(3000):\n for k in range(N+1):\n ... |
NMAX = 55
N, A = map(int, input().split())
X = list(map(int, input().split()))
dp = [[[0] * NMAX for s in range(3000)] for i in range(NMAX)]
dp[0][0][0] = 1 # dp[i][s][k]: i個からk個選ぶとき、総和がsのものの個数
for i in range(N): # N-1時点でNが更新されるのでここまでで十分
for s in range(3000):
for k in range(N+1):
if dp[i][s]... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
4,
13,
13,
41,
28,
13,
4,
13,
2,
13,
17,
4,
13,
0,
13,
13,
0,
18,
18,
13,
13,
13,
17,
28,
13,
4,
13,
13,
28,
13,
... | [
[
141,
2
],
[
141,
11
],
[
129,
13
],
[
144,
25
],
[
130,
28
],
[
32,
31
],
[
145,
35
],
[
135,
40
],
[
48,
43
],
[
136,
45
],
[
145,
46
],
[
142,
47
],
[
51,
50
... | [
"n,a=map(int,input().split())\nli=list(map(int,input().split()))\n\nmax_a=sum(li)\n\ndp=[[ 0 for _ in range(n+1)]for _ in range(max_a+1)]\ndp[max_a][n]=1\n\nfor j in range(n):\n for i in range(max_a+1):\n for k in range(n+1):\n if dp[i][k]>0:\n dp[i-li[j]][k-1]+=dp[i][k]\n \n \nans=0\nfor f ... | n,a=map(int,input().split())
li=list(map(int,input().split()))
max_a=sum(li)
dp=[[ 0 for _ in range(n+1)]for _ in range(max_a+1)]
dp[max_a][n]=1
for j in range(n):
for i in range(max_a+1):
for k in range(n+1):
if dp[i][k]>0:
dp[i-li[j]][k-1]+=dp[i][k]
ans=0
for f in range(max_a+1):
... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
41,
28,
13,
4,
13,
17,
4,
13,
0,
13,
13,
0,
18,
18,
18,
13,
17,
17,
17,
17,
28,
13,
4,
13,
13,
28,
13,
4,
13,
13,
28,
13... | [
[
136,
2
],
[
136,
11
],
[
148,
13
],
[
27,
26
],
[
139,
33
],
[
43,
36
],
[
140,
39
],
[
46,
45
],
[
134,
48
],
[
51,
50
],
[
134,
53
],
[
56,
55
],
[
55,
62
],
... | [
"n, a = map(int, input().split())\nx = list(map(int, input().split()))\n\ndp = [[[0] * 2501 for _ in range(51)] for _ in range(51)]\ndp[0][0][0] = 1\n\nfor i in range(n):\n for j in range(n):\n for k in range(2501):\n if k + x[i] <= 2500:\n dp[i+1][j+1][k+x[i]] += dp[i][j][k]\n ... | n, a = map(int, input().split())
x = list(map(int, input().split()))
dp = [[[0] * 2501 for _ in range(51)] for _ in range(51)]
dp[0][0][0] = 1
for i in range(n):
for j in range(n):
for k in range(2501):
if k + x[i] <= 2500:
dp[i+1][j+1][k+x[i]] += dp[i][j][k]
dp[i+1... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
17,
12,
13,
14,
2,
4,
13,
13,
17,
29,
2,
39,
13,
18,
13,
17,
0,
13,
39,
0,
13,
18,
13,
39,
17,
28,
13,
4,
13,
18,... | [
[
204,
2
],
[
204,
11
],
[
210,
13
],
[
207,
25
],
[
69,
33
],
[
69,
40
],
[
44,
43
],
[
47,
46
],
[
69,
48
],
[
53,
52
],
[
69,
56
],
[
43,
60
],
[
46,
64
],
[... | [
"N,A = map(int,input().split())\nX = list(map(int,input().split()))\nans = 0\n\ndef make_array(dims,fill):\n if len(dims) == 1:\n return [fill]*dims[0]\n ret = []\n nxt = dims[1:]\n for i in range(dims[0]):\n ret.append(make_array(nxt,fill))\n return ret\nS = sum(X)+1\ndp = make_array([... | N,A = map(int,input().split())
X = list(map(int,input().split()))
ans = 0
def make_array(dims,fill):
if len(dims) == 1:
return [fill]*dims[0]
ret = []
nxt = dims[1:]
for i in range(dims[0]):
ret.append(make_array(nxt,fill))
return ret
S = sum(X)+1
dp = make_array([N+2,N+2,S],0)
dp[0... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
41,
28,
13,
4,
13,
2,
13,
17,
4,
13,
0,
13,
13,
0,
18,
18,
18,
13,
17,
17,
17,
17,
28,
13,
4,
13,
13,
28,
13,
4,
13,
2,
... | [
[
135,
2
],
[
135,
11
],
[
132,
13
],
[
27,
26
],
[
130,
30
],
[
138,
35
],
[
45,
38
],
[
139,
41
],
[
48,
47
],
[
130,
50
],
[
53,
52
],
[
47,
56
],
[
60,
59
],
... | [
"n, a = map(int, input().split())\nx = list(map(int, input().split()))\ndp = [[[0] * 2501 for _ in range(n + 1)] for _ in range(n + 1)]\ndp[0][0][0] = 1\n\nfor i in range(n):\n for j in range(i + 1):\n for k in range(2451):\n dp[i + 1][j][k] += dp[i][j][k]\n dp[i + 1][j + 1][k + x[i]... | n, a = map(int, input().split())
x = list(map(int, input().split()))
dp = [[[0] * 2501 for _ in range(n + 1)] for _ in range(n + 1)]
dp[0][0][0] = 1
for i in range(n):
for j in range(i + 1):
for k in range(2451):
dp[i + 1][j][k] += dp[i][j][k]
dp[i + 1][j + 1][k + x[i]] += dp[i][j][... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
17,
0,
13,
2,
39,
17,
4,
13,
13,
28,
13,
4,
13,
4,
13,
13,
0,
18,
13,
13,
2,
18,
13,
13,
13,
0,
13,
17,
0,
13,
... | [
[
215,
2
],
[
215,
11
],
[
221,
13
],
[
218,
25
],
[
203,
28
],
[
222,
34
],
[
37,
36
],
[
222,
41
],
[
46,
43
],
[
204,
44
],
[
36,
45
],
[
222,
48
],
[
36,
49
]... | [
"N,A=map(int,input().split())\nx=list(map(int,input().split()))\nans=0\ny=[0]*(len(x))\nfor k in range(len(x)):\n y[k]=x[k]-A\nminus=0\nplus=0\nfor k in range(N):\n if y[k]<0:\n minus-=y[k]\n if y[k]>0:\n plus+=y[k]\ntotal=minus+plus+1\nans=[[0 for i in range(N)]for j in range(total)]\nans[y[... | N,A=map(int,input().split())
x=list(map(int,input().split()))
ans=0
y=[0]*(len(x))
for k in range(len(x)):
y[k]=x[k]-A
minus=0
plus=0
for k in range(N):
if y[k]<0:
minus-=y[k]
if y[k]>0:
plus+=y[k]
total=minus+plus+1
ans=[[0 for i in range(N)]for j in range(total)]
ans[y[0]+minus][0]=1
ans[m... |
[
7,
15,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
41,
28,
13,
13,
4,
2,
13,
13,
0,
13,
13,
0,
13,
4,
13,
13,
0,
18,
13,
17,
17,
28,
13,
13,
28,
13,
13,
4,
13,
4,
18,
... | [
[
76,
3
],
[
76,
12
],
[
82,
14
],
[
28,
27
],
[
83,
27
],
[
27,
31
],
[
74,
32
],
[
85,
34
],
[
79,
37
],
[
45,
42
],
[
80,
43
],
[
48,
47
],
[
86,
47
],
[
... | [
"from collections import defaultdict\n\nN, A = map(int, input().split())\nX = list(map(int, input().split()))\nX =[x - A for x in X]\n\nd = defaultdict(int)\nd[0] = 1\n\nfor x in X:\n for k, v in list(d.items()):\n d[k+x] += v\n\nprint(d[0]-1)",
"from collections import defaultdict",
"N, A = map(int, input(... | from collections import defaultdict
N, A = map(int, input().split())
X = list(map(int, input().split()))
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] += v
print(d[0]-1) |
[
7,
15,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
4,
13,
4,
13,
12,
2,
13,
13,
23,
13,
0,
13,
4,
13,
4,
13,
13,
13,
12,
13,
41,
14,
2,
2,
13,
17,
2,
13,
17,
... | [
[
177,
3
],
[
177,
12
],
[
171,
14
],
[
180,
26
],
[
178,
34
],
[
172,
36
],
[
165,
38
],
[
172,
43
],
[
178,
44
],
[
175,
46
],
[
149,
46
],
[
144,
51
],
[
146,
54... | [
"from functools import lru_cache\n\nN, A = map(int, input().split())\nx = list(map(int, input().split()))\ny = list(map(lambda i: i - A, x))\nX = max(max(x), A)\n\n@lru_cache(maxsize=None)\ndef solve(j, t):\n global y\n if j == 0 and t == 0:\n return 1\n elif j >= 1 and (t < y[j - 1] - N * X or t > ... | from functools import lru_cache
N, A = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(lambda i: i - A, x))
X = max(max(x), A)
@lru_cache(maxsize=None)
def solve(j, t):
global y
if j == 0 and t == 0:
return 1
elif j >= 1 and (t < y[j - 1] - N * X or t > y[j - 1] + N * X)... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
12,
2,
4,
13,
13,
13,
23,
4,
18,
4,
13,
13,
0,
13,
21,
22,
17,
17,
28,
13,
13,
28,
13,
13,
4,
13,
4,
18,
13,
13,
0,
18,
13,
2,
13,
13,
2,
4,
... | [
[
84,
2
],
[
84,
11
],
[
81,
13
],
[
76,
23
],
[
87,
31
],
[
38,
37
],
[
82,
37
],
[
88,
46
],
[
54,
49
],
[
88,
50
],
[
37,
52
],
[
88,
57
],
[
37,
60
],
[
... | [
"n, a = map(int, input().split())\nx = list(map(lambda x: int(x) - a, input().split()))\nd = {0: 1}\nfor i in x:\n for j, k in list(d.items()):\n d[i + j] = d.get(i + j, 0) + k\nans = d[0] - 1\nprint(ans)",
"n, a = map(int, input().split())",
"n",
"map(int, input().split())",
"map",
"int",
"in... | n, a = map(int, input().split())
x = list(map(lambda x: int(x) - a, input().split()))
d = {0: 1}
for i in x:
for j, k in list(d.items()):
d[i + j] = d.get(i + j, 0) + k
ans = d[0] - 1
print(ans)
|
[
7,
41,
28,
13,
4,
18,
4,
13,
13,
4,
4,
13,
13,
0,
13,
13,
13,
41,
28,
13,
4,
18,
4,
13,
13,
4,
4,
13,
13,
0,
13,
13,
0,
13,
2,
4,
13,
13,
17,
41,
28,
13,
4,
13,
2,
13,
17,
4,
13,
0,
13,
13,
0,
18,
18,
18,
... | [
[
4,
3
],
[
3,
12
],
[
162,
14
],
[
162,
16
],
[
20,
19
],
[
19,
28
],
[
165,
30
],
[
159,
33
],
[
166,
37
],
[
42,
41
],
[
163,
45
],
[
150,
50
],
[
60,
53
],
... | [
"N, A = [int(x) for x in input().split()]\nX = [int(x) for x in input().split()]\n\nXX = sum(X) + 1\n\ndp = [[[0 for i in range(XX * 2)] for i in range(N + 3)] for i in range(N + 3)]\n\ndp[0][0][0] = 1\n\nfor i in range(N):\n for j in range(N + 1):\n for n in range(XX):\n dp[i + 1][j][n] += dp[... | N, A = [int(x) for x in input().split()]
X = [int(x) for x in input().split()]
XX = sum(X) + 1
dp = [[[0 for i in range(XX * 2)] for i in range(N + 3)] for i in range(N + 3)]
dp[0][0][0] = 1
for i in range(N):
for j in range(N + 1):
for n in range(XX):
dp[i + 1][j][n] += dp[i][j][n]
... |
[
7,
15,
13,
0,
13,
18,
18,
13,
13,
13,
12,
13,
41,
28,
13,
4,
18,
4,
13,
13,
4,
4,
13,
13,
0,
13,
13,
13,
41,
28,
13,
4,
18,
4,
13,
13,
4,
4,
13,
13,
0,
13,
13,
41,
28,
13,
4,
13,
2,
13,
17,
4,
13,
0,
13,
13... | [
[
165,
4
],
[
15,
14
],
[
166,
18
],
[
14,
23
],
[
26,
25
],
[
26,
27
],
[
31,
30
],
[
166,
34
],
[
30,
39
],
[
42,
41
],
[
46,
45
],
[
25,
49
],
[
55,
54
],
[
... | [
"import sys\ninput = sys.stdin.readline\n\ndef main():\n N, A = (int(_) for _ in input().split())\n X = [int(_) for _ in input().split()]\n\n dp = [[[0] * (N*A+1) for _ in range(N+1)] for __ in range(N+1)]\n\n dp[0][0][0] = 1\n for i in range(N):\n for j in range(N):\n for k in rang... | import sys
input = sys.stdin.readline
def main():
N, A = (int(_) for _ in input().split())
X = [int(_) for _ in 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 j in range(N):
for k in range(N*A+1):
... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
41,
28,
13,
4,
13,
2,
13,
17,
4,
13,
0,
13,
13,
0,
18,
18,
18,
13,
17,
17,
17,
17,
28,
13,
4,
13,
13,
28,
13,
4,
13,
13,... | [
[
140,
2
],
[
140,
11
],
[
146,
13
],
[
27,
26
],
[
132,
30
],
[
143,
35
],
[
45,
38
],
[
144,
41
],
[
48,
47
],
[
132,
50
],
[
53,
52
],
[
132,
55
],
[
58,
57
],... | [
"N, A = map(int, input().split())\nX = list(map(int, input().split()))\n\ndp = [[[0]*(50*(N+1)+1) for _ in range(N+1)] for _ in range(N+1)]\ndp[0][0][0] = 1\n\nfor i in range(N):\n for k in range(N):\n for s in range(50*N+1):\n dp[i+1][k][s] += dp[i][k][s]\n dp[i+1][k+1][s+X[i]] += d... | N, A = map(int, input().split())
X = list(map(int, input().split()))
dp = [[[0]*(50*(N+1)+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(50*N+1):
dp[i+1][k][s] += dp[i][k][s]
dp[i+1][k+1][s+X[i]] += dp[i][k][s]
ans... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
41,
28,
13,
4,
13,
2,
13,
17,
4,
17,
0,
13,
13,
0,
18,
18,
13,
17,
17,
17,
28,
13,
4,
13,
13,
0,
13,
18,
13,
13,
28,
13,... | [
[
137,
2
],
[
137,
11
],
[
122,
13
],
[
27,
26
],
[
138,
30
],
[
125,
35
],
[
43,
38
],
[
126,
40
],
[
46,
45
],
[
138,
48
],
[
134,
50
],
[
123,
52
],
[
45,
53
]... | [
"N, A = map(int, input().split())\nX = list(map(int, input().split()))\ns = [{} for i in range(N+1)]\ns[0][0] = 1\n\nfor i in range(N):\n cur = X[i]\n for j in range(N, 0, -1):\n for k, v in s[j-1].items():\n s[j][cur + k] = s[j].get(cur + k, 0) + v\n\nans = 0\nfor i in range(1, N+1):\n ans += s[i].get(i... | N, A = map(int, input().split())
X = list(map(int, input().split()))
s = [{} for i in range(N+1)]
s[0][0] = 1
for i in range(N):
cur = X[i]
for j in range(N, 0, -1):
for k, v in s[j-1].items():
s[j][cur + k] = s[j].get(cur + k, 0) + v
ans = 0
for i in range(1, N+1):
ans += s[i].get(i*A, 0)
print(ans) |
[
7,
12,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
17,
41,
28,
13,
4,
13,
2,
13,
17,
4,
13,
0,
13,
13,
0,
18,
18,
18,
13,
17,
17,
17,
17,
28,
13,
4,
13,
17,... | [
[
5,
4
],
[
5,
13
],
[
16,
15
],
[
28,
27
],
[
32,
31
],
[
4,
35
],
[
41,
40
],
[
50,
43
],
[
40,
46
],
[
53,
52
],
[
4,
57
],
[
61,
60
],
[
4,
64
],
[
68,
... | [
"#!/usr/bin/env python3\n\n\ndef main():\n N, A = map(int, input().split())\n x = list(map(int, input().split()))\n X = 50\n dp = [[[0]*(N*X +1) for _ in range(N+1)] for _ in range(N+1)]\n dp[0][0][0] = 1\n for j in range(1,N+1):\n for k in range(N+1):\n for s in range(N*X+1):\n ... | #!/usr/bin/env python3
def main():
N, A = map(int, input().split())
x = list(map(int, input().split()))
X = 50
dp = [[[0]*(N*X +1) for _ in range(N+1)] for _ in range(N+1)]
dp[0][0][0] = 1
for j in range(1,N+1):
for k in range(N+1):
for s in range(N*X+1):
if... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
28,
13,
4,
13,
13,
0,
18,
13,
13,
13,
0,
13,
21,
22,
17,
17,
28,
13,
13,
41,
28,
13,
13,
4,
39,
13,
18,
13,
13,
0,
13,
1... | [
[
109,
2
],
[
109,
11
],
[
100,
13
],
[
26,
25
],
[
98,
28
],
[
33,
30
],
[
101,
31
],
[
25,
32
],
[
110,
33
],
[
106,
35
],
[
42,
41
],
[
101,
41
],
[
46,
45
],
... | [
"N, A = map(int, input().split())\nX = list(map(int, input().split()))\nfor i in range(N):\n X[i] -= A\nD = {0: 1}\nfor i in X:\n S = [[j, D[j]] for j in D]\n for j in S:\n if j[0] + i in D:\n D[j[0]+i] += j[1]\n else:\n D[j[0]+i] = j[1]\nprint(D[0]-1)",
"N, A = map(int, input().split())",
"N... | N, A = map(int, input().split())
X = list(map(int, input().split()))
for i in range(N):
X[i] -= A
D = {0: 1}
for i in X:
S = [[j, D[j]] for j in D]
for j in S:
if j[0] + i in D:
D[j[0]+i] += j[1]
else:
D[j[0]+i] = j[1]
print(D[0]-1) |
[
7,
12,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
41,
28,
13,
4,
13,
2,
13,
17,
4,
2,
39,
17,
2,
2,
17,
13,
17,
0,
13,
13,
0,
18,
18,
13,
17,
17,
17,
28,
13,
4,
... | [
[
5,
4
],
[
5,
13
],
[
16,
15
],
[
29,
28
],
[
4,
32
],
[
4,
41
],
[
45,
44
],
[
52,
47
],
[
44,
49
],
[
55,
54
],
[
4,
57
],
[
60,
59
],
[
54,
65
],
[
69,
... | [
"def main():\n N, A = map(int, input().split())\n x = list(map(int, input().split()))\n dp = [[0] * (50*N + 1) for _ in range(N+1)]\n dp[0][0] = 1\n for k in range(N):\n for i in reversed(range(k+1)):\n for j in range(50 * N + 1 -x[k]):\n dp[i+1][j+x[k]] += dp[i][j]\n... | def main():
N, A = map(int, input().split())
x = list(map(int, input().split()))
dp = [[0] * (50*N + 1) for _ in range(N+1)]
dp[0][0] = 1
for k in range(N):
for i in reversed(range(k+1)):
for j in range(50 * N + 1 -x[k]):
dp[i+1][j+x[k]] += dp[i][j]
r = 0
... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
28,
13,
4,
13,
13,
0,
18,
13,
13,
13,
0,
13,
21,
22,
17,
17,
28,
13,
4,
13,
13,
41,
28,
13,
13,
4,
39,
13,
18,
13,
13,
0... | [
[
117,
2
],
[
117,
11
],
[
105,
13
],
[
26,
25
],
[
109,
28
],
[
33,
30
],
[
106,
31
],
[
25,
32
],
[
118,
33
],
[
111,
35
],
[
42,
41
],
[
109,
44
],
[
48,
47
],... | [
"N, A = map(int, input().split())\nX = list(map(int, input().split()))\nfor i in range(N):\n X[i] -= A\nD = {0: 1}\nfor i in range(N):\n F = [[j, D[j]] for j in D]\n for j in F:\n if j[0] + X[i] in D:\n D[j[0] + X[i]] += j[1]\n else:\n D[j[0] + X[i]] = j[1]\nprint(D[0]-1... | N, A = map(int, input().split())
X = list(map(int, input().split()))
for i in range(N):
X[i] -= A
D = {0: 1}
for i in range(N):
F = [[j, D[j]] for j in D]
for j in F:
if j[0] + X[i] in D:
D[j[0] + X[i]] += j[1]
else:
D[j[0] + X[i]] = j[1]
print(D[0]-1) |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
4,
18,
13,
13,
41,
28,
13,
13,
4,
2,
13,
13,
0,
13,
13,
0,
13,
21,
22,
17,
17,
28,
13,
13,
28,
13,
13,
4,
13,
4,
18,
13,... | [
[
93,
2
],
[
93,
11
],
[
90,
13
],
[
91,
26
],
[
31,
30
],
[
91,
30
],
[
30,
34
],
[
88,
35
],
[
81,
37
],
[
84,
40
],
[
47,
46
],
[
82,
46
],
[
91,
46
],
[
... | [
"n, a = map(int, input().split())\nx = list(map(int, input().split()))\n\nx.sort()\nx = [i - a for i in x]\n# print(x)\nD = {0 : 1}\nfor i in x:\n for j, k in list(D.items()):\n D[i+j] = D.get(i+j, 0) + k\n\n # print(D)\nprint(D[0] - 1)",
"n, a = map(int, input().split())",
"n",
"map(int, input()... | n, a = map(int, input().split())
x = list(map(int, input().split()))
x.sort()
x = [i - a for i in x]
# print(x)
D = {0 : 1}
for i in x:
for j, k in list(D.items()):
D[i+j] = D.get(i+j, 0) + k
# print(D)
print(D[0] - 1)
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
15,
13,
0,
13,
4,
18,
13,
13,
4,
18,
4,
13,
13,
0,
13,
13,
0,
13,
13,
0,
13,
39,
0,
13,
39,
0,
13,
17,
28,
13,
4,
13,
4,
13,
13,
14,
2,
18,
13,
13,
17,
0,
13,
17,
... | [
[
246,
2
],
[
246,
11
],
[
228,
15
],
[
27,
26
],
[
234,
29
],
[
247,
30
],
[
237,
32
],
[
231,
35
],
[
216,
38
],
[
42,
41
],
[
235,
46
],
[
229,
46
],
[
235,
50
... | [
"n,a=map(int,input().split())\nimport numpy as np\nx=np.array(input().split(),dtype=int)\nx-=a\npluslist=[]\nminuslist=[]\nzerocnt=0\nfor i in range(len(x)):\n if x[i]==0:\n zerocnt+=1\n elif x[i]>0:\n pluslist.append(x[i])\n else:\n minuslist.append(x[i]*(-1))\n\ndpplus=np.full((sum(pluslist)+1),0,dtyp... | n,a=map(int,input().split())
import numpy as np
x=np.array(input().split(),dtype=int)
x-=a
pluslist=[]
minuslist=[]
zerocnt=0
for i in range(len(x)):
if x[i]==0:
zerocnt+=1
elif x[i]>0:
pluslist.append(x[i])
else:
minuslist.append(x[i]*(-1))
dpplus=np.full((sum(pluslist)+1),0,dtype=int)
dpminus=np.fu... |
[
7,
15,
15,
13,
13,
13,
13,
13,
13,
13,
4,
18,
13,
13,
2,
17,
17,
0,
13,
2,
2,
17,
17,
17,
12,
13,
12,
13,
12,
13,
12,
13,
23,
13,
0,
13,
4,
13,
13,
0,
13,
4,
13,
0,
13,
2,
13,
4,
13,
4,
13,
13,
13,
41,
28,
... | [
[
204,
18
],
[
33,
33
],
[
195,
35
],
[
217,
37
],
[
195,
38
],
[
219,
40
],
[
217,
42
],
[
213,
44
],
[
196,
46
],
[
220,
51
],
[
193,
52
],
[
56,
55
],
[
196,
59
... | [
"from collections import Counter,defaultdict,deque\nimport sys,heapq,bisect,math,itertools,string,queue\nsys.setrecursionlimit(10**8)\nmod = 10**9+7\ndef inp(): return int(sys.stdin.readline())\ndef inpl(): return list(map(int, sys.stdin.readline().split()))\ndef inpl_str(): return list(sys.stdin.readline().split()... | from collections import Counter,defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln... |
[
7,
15,
13,
15,
0,
13,
4,
13,
13,
4,
18,
4,
18,
18,
13,
13,
13,
13,
13,
31,
13,
12,
13,
28,
13,
4,
13,
13,
0,
18,
13,
13,
13,
0,
13,
4,
13,
13,
0,
18,
13,
17,
17,
28,
13,
13,
28,
13,
13,
4,
13,
4,
18,
13,
13,
... | [
[
92,
5
],
[
92,
18
],
[
92,
19
],
[
25,
24
],
[
93,
27
],
[
32,
29
],
[
24,
31
],
[
84,
32
],
[
35,
34
],
[
42,
39
],
[
34,
40
],
[
45,
44
],
[
34,
53
],
[
... | [
"import sys\nfrom collections import defaultdict\n\nn, a, *x = map(int, sys.stdin.read().split())\n\ndef main():\n for i in range(n):\n x[i] -= a\n \n c = defaultdict(int)\n c[0] = 1\n for i in x:\n for val, cnt in tuple(c.items()):\n c[val+i] += cnt\n ans = c[0] - 1\n ... | import sys
from collections import defaultdict
n, a, *x = map(int, sys.stdin.read().split())
def main():
for i in range(n):
x[i] -= a
c = defaultdict(int)
c[0] = 1
for i in x:
for val, cnt in tuple(c.items()):
c[val+i] += cnt
ans = c[0] - 1
return ans
if __nam... |
[
7,
12,
13,
0,
13,
4,
13,
13,
4,
18,
4,
18,
4,
13,
17,
13,
13,
13,
31,
13,
41,
28,
13,
13,
4,
2,
13,
13,
0,
13,
13,
13,
21,
22,
17,
17,
28,
13,
13,
28,
13,
13,
4,
13,
4,
18,
13,
13,
0,
18,
13,
2,
13,
13,
2,
... | [
[
5,
4
],
[
5,
17
],
[
5,
18
],
[
23,
22
],
[
22,
26
],
[
17,
27
],
[
30,
29
],
[
32,
31
],
[
38,
37
],
[
29,
37
],
[
31,
46
],
[
54,
49
],
[
31,
50
],
[
37... | [
"# ABC044C - 高橋君とカード / Tak and Cards (ARC060C)\ndef main():\n N, A, *X = map(int, open(0).read().split())\n X, D = [i - A for i in X], {0: 1}\n for i in X:\n for j, k in list(D.items()):\n D[i + j] = D.get(i + j, 0) + k\n ans = D[0] - 1\n print(ans)\n\n\nif __name__ == \"__main__\":... | # ABC044C - 高橋君とカード / Tak and Cards (ARC060C)
def main():
N, A, *X = map(int, open(0).read().split())
X, D = [i - A for i in X], {0: 1}
for i in X:
for j, k in list(D.items()):
D[i + j] = D.get(i + j, 0) + k
ans = D[0] - 1
print(ans)
if __name__ == "__main__":
main() |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
28,
13,
4,
13,
13,
0,
18,
13,
13,
2,
18,
13,
13,
13,
0,
13,
2,
13,
13,
41,
28,
13,
4,
13,
2,
13,
17,
4,
2,
39,
17,
2,
... | [
[
189,
2
],
[
189,
11
],
[
192,
13
],
[
26,
25
],
[
184,
28
],
[
33,
30
],
[
193,
31
],
[
25,
32
],
[
30,
34
],
[
193,
35
],
[
25,
36
],
[
190,
37
],
[
186,
39
],... | [
"n,a=map(int,input().split())\nx=list(map(int,input().split()))\n\nfor i in range(n):\n x[i]=x[i]-a\n \nnx=n*n\ndp=[[0]*(2*nx+1) for i in range(n+1)]\n\n#print(dp)\n\ndp[0][nx]=1\n\nfor j in range(1,n+1):\n jj=j-1\n for t in range(2*nx+1):\n if t-x[jj]<0 or 2*nx<t-x[jj]:\n dp[j][t]=dp[... | n,a=map(int,input().split())
x=list(map(int,input().split()))
for i in range(n):
x[i]=x[i]-a
nx=n*n
dp=[[0]*(2*nx+1) for i in range(n+1)]
#print(dp)
dp[0][nx]=1
for j in range(1,n+1):
jj=j-1
for t in range(2*nx+1):
if t-x[jj]<0 or 2*nx<t-x[jj]:
dp[j][t]=dp[j-1][t]
elif 0... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
17,
12,
13,
14,
2,
13,
17,
29,
14,
2,
39,
13,
13,
13,
13,
29,
14,
2,
13,
17,
14,
2,
13,
17,
0,
18,
13,
39,
13,
13... | [
[
196,
2
],
[
196,
11
],
[
184,
13
],
[
193,
25
],
[
147,
31
],
[
194,
40
],
[
147,
44
],
[
149,
48
],
[
57,
51
],
[
194,
52
],
[
65,
59
],
[
194,
60
],
[
151,
69
... | [
"N,A=map(int,input().split())\nl=list(map(int,input().split()))\nd={}\ndef func(n,s,i):\n\tif n<0:\n\t\treturn\n\tif (n,s,i) in d:\n\t\treturn\n\tif n==0:\n\t\tif s==0:\n\t\t\td[(n,s,i)]=1\n\t\telse:\n\t\t\td[(n,s,i)]=0\n\t\treturn\n\tif i>=N:\n\t\tif s==0 and n==0:\n\t\t\td[(n,s,i)]=1\n\t\telse:\n\t\t\td[(n,s,i)]=... | N,A=map(int,input().split())
l=list(map(int,input().split()))
d={}
def func(n,s,i):
if n<0:
return
if (n,s,i) in d:
return
if n==0:
if s==0:
d[(n,s,i)]=1
else:
d[(n,s,i)]=0
return
if i>=N:
if s==0 and n==0:
d[(n,s,i)]=1
else:
d[(n,s,i)]=0
return
else:
func(n-1,s-l[i],i+1)
func(n,s,... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
17,
41,
28,
13,
4,
13,
2,
13,
17,
4,
13,
0,
13,
13,
0,
18,
18,
18,
13,
17,
17,
17,
17,
28,
13,
4,
13,
13,
28,
13,... | [
[
148,
2
],
[
148,
11
],
[
154,
13
],
[
151,
25
],
[
30,
29
],
[
143,
33
],
[
157,
38
],
[
48,
41
],
[
158,
44
],
[
51,
50
],
[
143,
53
],
[
56,
55
],
[
143,
58
]... | [
"N, A = map(int, input().split())\nX = list(map(int, input().split()))\nsumX = 2501\n\ndp = [[[0 for _ in range(sumX)] for _ in range(N+1)] for _ in range(N+1)]\ndp[0][0][0] = 1\n\nfor j in range(N):\n for k in range(N):\n for s in range(sumX):\n if dp[j][k][s]==0:\n continue\n ... | N, A = map(int, input().split())
X = list(map(int, input().split()))
sumX = 2501
dp = [[[0 for _ in range(sumX)] for _ in range(N+1)] for _ in range(N+1)]
dp[0][0][0] = 1
for j in range(N):
for k in range(N):
for s in range(sumX):
if dp[j][k][s]==0:
continue
dp[j+1]... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
28,
13,
4,
13,
13,
0,
18,
13,
13,
13,
0,
13,
2,
39,
17,
17,
0,
18,
13,
17,
17,
28,
13,
4,
13,
13,
0,
13,
18,
13,
39,
28,... | [
[
105,
2
],
[
105,
11
],
[
96,
13
],
[
26,
25
],
[
106,
28
],
[
33,
30
],
[
97,
31
],
[
25,
32
],
[
94,
33
],
[
102,
35
],
[
44,
41
],
[
103,
42
],
[
47,
46
],
... | [
"N,A = map(int,input().split())\nx = list(map(int,input().split()))\n\nfor i in range(N):\n x[i] -= A\n\ndp = [0]*5000###-2500~2499,idx=2500が0に対応\ndp[2500] = 1\n\nfor i in range(N):\n pre = dp[:]\n for j in range(max(0,-x[i]),min(4999,4999-x[i])):\n dp[j+x[i]] += pre[j]\n #print(pre[2490:2510])\n... | N,A = map(int,input().split())
x = list(map(int,input().split()))
for i in range(N):
x[i] -= A
dp = [0]*5000###-2500~2499,idx=2500が0に対応
dp[2500] = 1
for i in range(N):
pre = dp[:]
for j in range(max(0,-x[i]),min(4999,4999-x[i])):
dp[j+x[i]] += pre[j]
#print(pre[2490:2510])
#print(dp[2490:... |
[
7,
15,
13,
0,
13,
18,
18,
13,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
2,
39,
17,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
41,
28,
13,
4,
13,
2,
13,
17,
4,
13,
0,
13,
13,
0,
18,
18,
18,
13,
17,
17,... | [
[
176,
4
],
[
185,
11
],
[
177,
18
],
[
185,
20
],
[
167,
22
],
[
177,
34
],
[
39,
38
],
[
183,
42
],
[
179,
47
],
[
57,
50
],
[
180,
53
],
[
60,
59
],
[
183,
63
... | [
"# python 3.4.3\nimport sys\ninput = sys.stdin.readline\n\n# -------------------------------------------------------------\n# function\n# -------------------------------------------------------------\n\n\n# -------------------------------------------------------------\n# main\n# ------------------------------------... | # python 3.4.3
import sys
input = sys.stdin.readline
# -------------------------------------------------------------
# function
# -------------------------------------------------------------
# -------------------------------------------------------------
# main
# ----------------------------------------------------... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
41,
28,
13,
4,
13,
2,
13,
17,
4,
2,
39,
17,
17,
0,
13,
13,
0,
18,
18,
13,
17,
17,
17,
28,
13,
4,
13,
13,
0,
13,
18,
13,
... | [
[
126,
2
],
[
126,
11
],
[
111,
13
],
[
27,
26
],
[
127,
30
],
[
129,
38
],
[
46,
41
],
[
130,
43
],
[
49,
48
],
[
127,
51
],
[
117,
53
],
[
112,
55
],
[
48,
56
]... | [
"n,a=map(int,input().split())\nX=list(map(int,input().split()))\ndp=[[0]*2501 for _ in range(n+1)]\ndp[0][0]=1\nfor i in range(n):\n x=X[i]\n for j in range(n,0,-1):\n \tfor k in range(2501-x):\n \tdp[j][k+x]+=dp[j-1][k]\nans=0\nfor i in range(n):\n ans+=dp[i+1][(i+1)*a]\nprint(ans)",
"n,a=map(... | n,a=map(int,input().split())
X=list(map(int,input().split()))
dp=[[0]*2501 for _ in range(n+1)]
dp[0][0]=1
for i in range(n):
x=X[i]
for j in range(n,0,-1):
for k in range(2501-x):
dp[j][k+x]+=dp[j-1][k]
ans=0
for i in range(n):
ans+=dp[i+1][(i+1)*a]
print(ans) |
[
7,
12,
13,
0,
13,
4,
13,
13,
4,
18,
4,
18,
4,
13,
17,
13,
13,
13,
31,
13,
0,
13,
4,
13,
13,
4,
13,
13,
41,
28,
13,
13,
4,
2,
13,
13,
0,
13,
13,
41,
28,
13,
4,
13,
2,
13,
17,
4,
2,
39,
17,
2,
2,
2,
17,
13,
... | [
[
5,
4
],
[
5,
17
],
[
5,
18
],
[
22,
21
],
[
17,
24
],
[
31,
30
],
[
30,
34
],
[
17,
35
],
[
38,
37
],
[
42,
41
],
[
4,
45
],
[
4,
55
],
[
21,
56
],
[
60,
... | [
"def main():\n N, A, *x = map(int, open(0).read().split())\n MAX_A_x = max(A, max(x))\n x = [xi - A for xi in x]\n # dp[i][j]\n # i 選んだ枚数 0 <= i <= N\n # j 合計 0 <= j <= 2 * N * MAX_A_x\n dp = [[0] * (2 * N * MAX_A_x + 1) for i in range(N + 1)]\n dp[0][N * MAX_A_x] = 1\n for i in range(1, ... | def main():
N, A, *x = map(int, open(0).read().split())
MAX_A_x = max(A, max(x))
x = [xi - A for xi in x]
# dp[i][j]
# i 選んだ枚数 0 <= i <= N
# j 合計 0 <= j <= 2 * N * MAX_A_x
dp = [[0] * (2 * N * MAX_A_x + 1) for i in range(N + 1)]
dp[0][N * MAX_A_x] = 1
for i in range(1, N + 1):
... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
41,
28,
13,
4,
13,
17,
4,
13,
0,
13,
13,
0,
18,
18,
18,
13,
17,
17,
17,
17,
28,
13,
4,
13,
13,
28,
13,
4,
13,
2,
13,
17,... | [
[
154,
2
],
[
154,
11
],
[
151,
13
],
[
27,
26
],
[
148,
33
],
[
43,
36
],
[
149,
39
],
[
46,
45
],
[
155,
48
],
[
51,
50
],
[
155,
54
],
[
58,
57
],
[
155,
62
],... | [
"n,a=map(int, input().split())\nx=list(map(int, input().split()))\n\ndp=[[[0]*(2550) for _ in range(55)] for _ in range(55)]\ndp[0][0][0]=1\nfor i in range(n):\n for j in range(n+1):\n for sm in range(n*a+1):\n if dp[i][j][sm]==0:\n continue\n dp[i+1][j][sm]+=dp[i][j][... | n,a=map(int, input().split())
x=list(map(int, input().split()))
dp=[[[0]*(2550) for _ in range(55)] for _ in range(55)]
dp[0][0][0]=1
for i in range(n):
for j in range(n+1):
for sm in range(n*a+1):
if dp[i][j][sm]==0:
continue
dp[i+1][j][sm]+=dp[i][j][sm]
... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
18,
4,
13,
13,
4,
4,
13,
13,
0,
13,
13,
0,
13,
4,
13,
13,
41,
28,
13,
4,
13,
2,
13,
17,
4,
13,
0,
13,
13,
28,
13,
4,
13,
2,
13,
17,
0,
18,
18,
18,
... | [
[
179,
2
],
[
179,
11
],
[
15,
14
],
[
14,
23
],
[
185,
25
],
[
167,
28
],
[
186,
31
],
[
35,
34
],
[
180,
38
],
[
170,
43
],
[
47,
46
],
[
180,
50
],
[
60,
53
],... | [
"N,A = map(int, input().split())\nX = [int(x) for x in input().split()]\n\nM = sum(X)\ndp = [[[0]*(N+1) for _ in range(M+1)] for _ in range(N+1)]\n \nfor i in range(N+1):\n dp[i][0][0] = 1\n \nfor i in range(N):\n for j in range(M+1):\n for k in range(1, N+1):\n if j >= X[i]:\n ... | N,A = map(int, input().split())
X = [int(x) for x in input().split()]
M = sum(X)
dp = [[[0]*(N+1) for _ in range(M+1)] for _ in range(N+1)]
for i in range(N+1):
dp[i][0][0] = 1
for i in range(N):
for j in range(M+1):
for k in range(1, N+1):
if j >= X[i]:
dp[i+1][j]... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
12,
2,
4,
13,
13,
13,
23,
4,
18,
4,
13,
13,
0,
13,
21,
22,
17,
17,
28,
13,
13,
28,
13,
13,
4,
13,
4,
18,
13,
13,
0,
18,
13,
2,
13,
13,
2,
4,
... | [
[
78,
2
],
[
78,
11
],
[
81,
13
],
[
76,
23
],
[
72,
31
],
[
38,
37
],
[
82,
37
],
[
73,
46
],
[
54,
49
],
[
73,
50
],
[
37,
53
],
[
73,
57
],
[
37,
61
],
[
... | [
"n, a = map(int, input().split())\nnums = list(map(lambda x: int(x) - a, input().split()))\n\ndp = {0 : 1}\n\nfor n in nums:\n\tfor k, v in list(dp.items()):\n\t\tdp[k+n] =dp.get(k+n, 0) + v\nprint(dp[0] - 1)",
"n, a = map(int, input().split())",
"n",
"map(int, input().split())",
"map",
"int",
"input().... | n, a = map(int, input().split())
nums = list(map(lambda x: int(x) - a, input().split()))
dp = {0 : 1}
for n in nums:
for k, v in list(dp.items()):
dp[k+n] =dp.get(k+n, 0) + v
print(dp[0] - 1)
|
[
7,
15,
13,
4,
18,
13,
13,
2,
17,
17,
0,
13,
18,
18,
13,
13,
13,
0,
13,
4,
13,
17,
0,
13,
17,
12,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
4,
13,
13,
41,
... | [
[
203,
11
],
[
197,
18
],
[
206,
23
],
[
29,
28
],
[
204,
35
],
[
29,
37
],
[
40,
39
],
[
204,
48
],
[
52,
51
],
[
39,
54
],
[
58,
57
],
[
28,
61
],
[
67,
66
],
... | [
"import sys\n\nsys.setrecursionlimit(10 ** 7)\ninput = sys.stdin.readline\nf_inf = float('inf')\nmod = 998244353\n\n\ndef resolve():\n n, a = map(int, input().split())\n X = list(map(int, input().split()))\n MAX = sum(X)\n dp = [[[0] * (MAX + 1) for _ in range(n + 1)] for _ in range(n + 1)]\n dp[0][0... | import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 998244353
def resolve():
n, a = map(int, input().split())
X = list(map(int, input().split()))
MAX = sum(X)
dp = [[[0] * (MAX + 1) for _ in range(n + 1)] for _ in range(n + 1)]
dp[0][0][0] = 1
for i... |
[
7,
15,
15,
13,
15,
12,
13,
28,
13,
4,
13,
13,
28,
13,
4,
13,
13,
28,
13,
4,
13,
2,
2,
13,
17,
17,
0,
18,
18,
18,
13,
2,
13,
17,
2,
13,
18,
13,
13,
2,
13,
17,
18,
18,
18,
13,
13,
13,
13,
0,
18,
18,
18,
13,
2,
... | [
[
206,
6
],
[
102,
6
],
[
9,
8
],
[
97,
11
],
[
14,
13
],
[
97,
16
],
[
19,
18
],
[
95,
23
],
[
42,
27
],
[
91,
30
],
[
8,
32
],
[
18,
35
],
[
93,
37
],
[
8... | [
"from sys import stdin\nimport numpy as np\nfrom numba import njit\n\n@njit(\"i8(i8[:,:,:],i8[:],i8,i8,i8)\",cache=True)\ndef f(dp,x,con,n,a):\n for i in range(n):\n for k in range(n):\n for j in range(con+1-50):\n #i枚目を選ぶ\n dp[i+1][j+x[i]][k+1]+=dp[i][j][k]\n\n ... | from sys import stdin
import numpy as np
from numba import njit
@njit("i8(i8[:,:,:],i8[:],i8,i8,i8)",cache=True)
def f(dp,x,con,n,a):
for i in range(n):
for k in range(n):
for j in range(con+1-50):
#i枚目を選ぶ
dp[i+1][j+x[i]][k+1]+=dp[i][j][k]
#i枚目を選... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
4,
13,
13,
41,
28,
13,
4,
13,
2,
13,
17,
4,
2,
39,
17,
2,
13,
17,
0,
13,
13,
0,
18,
18,
13,
17,
17,
17,
28,
13,
... | [
[
143,
2
],
[
143,
11
],
[
131,
13
],
[
137,
25
],
[
132,
28
],
[
32,
31
],
[
144,
35
],
[
138,
42
],
[
146,
45
],
[
53,
48
],
[
147,
50
],
[
56,
55
],
[
144,
58
... | [
"N, A = map(int, input().split())\nx = list(map(int, input().split()))\nMAX_J = sum(x)\ndp = [[0] * (MAX_J+1) for i in range(N+1)]\ndp[0][0] = 1\nfor n in range(N):\n for i in range(N)[::-1]:\n for j in range(MAX_J-x[n]+1)[::-1]:\n dp[i+1][j+x[n]] += dp[i][j]\nans = 0\nfor i in range(1, N+1):\n... | N, A = map(int, input().split())
x = list(map(int, input().split()))
MAX_J = sum(x)
dp = [[0] * (MAX_J+1) for i in range(N+1)]
dp[0][0] = 1
for n in range(N):
for i in range(N)[::-1]:
for j in range(MAX_J-x[n]+1)[::-1]:
dp[i+1][j+x[n]] += dp[i][j]
ans = 0
for i in range(1, N+1):
if A * i <= ... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
4,
13,
13,
4,
18,
13,
13,
17,
17,
41,
28,
13,
4,
13,
2,
13,
17,
4,
13,
0,
13,
13,
0,
18,
18,
18,
13,
17,
18,
13,
... | [
[
194,
2
],
[
194,
11
],
[
188,
13
],
[
179,
25
],
[
189,
28
],
[
189,
31
],
[
38,
37
],
[
186,
41
],
[
200,
46
],
[
58,
49
],
[
201,
52
],
[
189,
55
],
[
67,
60
... | [
"n,a=map(int,input().split())\n\nx=list(map(int,input().split()))\nA=max(x)\nx.insert(0,-1)\ndp=[[[0]*(n+1) for _ in range(n*A+1)] for i in range(n+1)]\ndp[1][x[1]][1]=1\ndp[1][0][0]=1\nfor i in range(1,n):\n q=x[i+1]\n for s in range(n*A+1):\n for k in range(i+1):\n if s+q<=n*A:\n ... | n,a=map(int,input().split())
x=list(map(int,input().split()))
A=max(x)
x.insert(0,-1)
dp=[[[0]*(n+1) for _ in range(n*A+1)] for i in range(n+1)]
dp[1][x[1]][1]=1
dp[1][0][0]=1
for i in range(1,n):
q=x[i+1]
for s in range(n*A+1):
for k in range(i+1):
if s+q<=n*A:
dp[i+1][s+q]... |
[
7,
15,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
18,
13,
13,
4,
18,
4,
13,
13,
0,
13,
18,
13,
13,
0,
13,
2,
13,
13,
0,
13,
2,
4,
13,
4,
18,
13,
13,
13,
13,
0,
13,
4,
18,
13,
13,
2,
2,
17,
13,
... | [
[
139,
4
],
[
139,
13
],
[
127,
15
],
[
27,
26
],
[
124,
31
],
[
128,
33
],
[
140,
34
],
[
136,
36
],
[
128,
42
],
[
140,
44
],
[
131,
45
],
[
142,
47
],
[
137,
55
... | [
"import numpy as np\n\nn,a = map(int, input().split())\nX = np.array(input().split(), dtype=np.int64)\nY = X-a\nU = max(X.max(), a) * n\ndp = np.zeros(2*U+1, dtype=np.int64)\ndp[U] = 1\nfor i in range(n):\n y = Y[i]\n if y >= 0:\n dp[y:] = dp[y:] + dp[:2*U+1-y]\n else:\n dp[:y] = dp[:y] + dp[-y:]\nprint(dp... | import numpy as np
n,a = map(int, input().split())
X = np.array(input().split(), dtype=np.int64)
Y = X-a
U = max(X.max(), a) * n
dp = np.zeros(2*U+1, dtype=np.int64)
dp[U] = 1
for i in range(n):
y = Y[i]
if y >= 0:
dp[y:] = dp[y:] + dp[:2*U+1-y]
else:
dp[:y] = dp[:y] + dp[-y:]
print(dp[U]-1) |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
15,
13,
0,
13,
4,
18,
13,
13,
39,
2,
13,
17,
17,
13,
0,
18,
13,
17,
17,
28,
13,
13,
28,
13,
4,
13,
2,
13,
17,
17,
17,
0,... | [
[
99,
2
],
[
99,
11
],
[
90,
13
],
[
93,
27
],
[
100,
34
],
[
42,
39
],
[
94,
40
],
[
45,
44
],
[
91,
44
],
[
48,
47
],
[
100,
51
],
[
64,
56
],
[
94,
58
],
[
... | [
"n,a=map(int,input().split())\nx=list(map(int,input().split()))\nimport numpy as np\ndp=np.zeros((n+1,2501),int)\ndp[0,0]=1\nfor xi in x:\n for i in range(n-1,-1,-1):\n dp[i+1][xi:]+=dp[i,:-xi]\nans=0\nfor i in range(1,n+1):\n ans+=dp[i,i*a]\nprint(ans)",
"n,a=map(int,input().split())",
"n",
"map(int,inp... | n,a=map(int,input().split())
x=list(map(int,input().split()))
import numpy as np
dp=np.zeros((n+1,2501),int)
dp[0,0]=1
for xi in x:
for i in range(n-1,-1,-1):
dp[i+1][xi:]+=dp[i,:-xi]
ans=0
for i in range(1,n+1):
ans+=dp[i,i*a]
print(ans)
|
[
7,
12,
13,
15,
41,
28,
13,
4,
18,
4,
13,
13,
4,
4,
13,
13,
0,
13,
13,
13,
41,
28,
13,
4,
18,
4,
13,
13,
4,
4,
13,
13,
0,
13,
13,
41,
28,
13,
13,
4,
2,
13,
13,
0,
13,
13,
0,
13,
4,
13,
13,
0,
18,
13,
17,
17,... | [
[
7,
6
],
[
6,
15
],
[
18,
17
],
[
18,
19
],
[
23,
22
],
[
22,
31
],
[
34,
33
],
[
38,
37
],
[
33,
37
],
[
37,
41
],
[
19,
42
],
[
45,
44
],
[
48,
47
],
[
5... | [
"def c_tak_and_cards():\n from collections import defaultdict\n N, A = [int(i) for i in input().split()]\n X = [int(i) for i in input().split()]\n\n average = [x - A for x in X]\n dp = defaultdict(int) # dp[s]: y から 1 枚以上選んで整数の和を s にする方法\n dp[0] = 1 # 「選ばない」 1 通り\n for y in average:\n ... | def c_tak_and_cards():
from collections import defaultdict
N, A = [int(i) for i in input().split()]
X = [int(i) for i in input().split()]
average = [x - A for x in X]
dp = defaultdict(int) # dp[s]: y から 1 枚以上選んで整数の和を s にする方法
dp[0] = 1 # 「選ばない」 1 通り
for y in average:
for k, v in li... |
[
7,
15,
15,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
28,
13,
4,
13,
13,
0,
18,
13,
13,
13,
0,
13,
4,
13,
13,
0,
18,
13,
17,
17,
28,
13,
13,
28,
13,
13,
4,
13,
4,... | [
[
83,
5
],
[
83,
14
],
[
80,
16
],
[
29,
28
],
[
84,
31
],
[
36,
33
],
[
81,
34
],
[
28,
35
],
[
78,
36
],
[
74,
38
],
[
46,
43
],
[
75,
44
],
[
49,
48
],
[
... | [
"from collections import defaultdict\nimport io\n\nnim, mike = map(int, input().split())\nkite = list(map(int, input().split()))\nfor i in range(nim):\n kite[i] -= mike\nqwe = defaultdict(int)\nqwe[0] = 1\nfor o in kite:\n for j, c in list(qwe.items()):\n qwe[j + o] += c\nprint(qwe[0]-1)",
"from coll... | from collections import defaultdict
import io
nim, mike = map(int, input().split())
kite = list(map(int, input().split()))
for i in range(nim):
kite[i] -= mike
qwe = defaultdict(int)
qwe[0] = 1
for o in kite:
for j, c in list(qwe.items()):
qwe[j + o] += c
print(qwe[0]-1) |
[
7,
15,
13,
0,
13,
18,
18,
18,
13,
13,
13,
13,
12,
13,
23,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
15,
13,
0,
13,
4,
18,
13,
13,
39,
2,
13,
17,
17,
0,
13,
18,
1... | [
[
100,
4
],
[
15,
15
],
[
109,
17
],
[
101,
24
],
[
109,
26
],
[
112,
28
],
[
101,
37
],
[
115,
42
],
[
98,
49
],
[
54,
53
],
[
61,
58
],
[
116,
59
],
[
64,
63
],... | [
"import sys\nreadline = sys.stdin.buffer.readline\ndef even(n): return 1 if n%2==0 else 0\nn,a = map(int,readline().split())\nlst1 = list(map(int,readline().split()))\n\nimport numpy as np\n\ndp = np.zeros((n+1,3000),dtype=np.int64) # 枚数、目標数ごとに場合の数\ndp[0,0] = 1\n\nfor x in lst1:\n dp[1:,x:] += dp[:-1,:-x].copy()\n... | import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0
n,a = map(int,readline().split())
lst1 = list(map(int,readline().split()))
import numpy as np
dp = np.zeros((n+1,3000),dtype=np.int64) # 枚数、目標数ごとに場合の数
dp[0,0] = 1
for x in lst1:
dp[1:,x:] += dp[:-1,:-x].copy()
ans = 0
for i i... |
[
7,
0,
13,
12,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
12,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
12,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
12,
4,
13,
4,
13,
0,
13,
12,
8,
13,
4,
13,
17,
4,
13,
17,
23... | [
[
247,
2
],
[
223,
13
],
[
256,
26
],
[
259,
39
],
[
241,
46
],
[
69,
68
],
[
108,
72
],
[
110,
73
],
[
108,
79
],
[
110,
80
],
[
110,
81
],
[
84,
83
],
[
108,
85
... | [
"ma = lambda :map(int,input().split())\nlma = lambda :list(map(int,input().split()))\ntma = lambda :tuple(map(int,input().split()))\nni = lambda:int(input())\nyn = lambda fl:print(\"Yes\") if fl else print(\"No\")\nimport collections\nimport math\nimport itertools\nimport heapq as hq\ndef ncr(n,r):\n ret = 1\n ... | ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
import collections
import math
import itertools
import heapq as hq
def ncr(n,r):
ret = 1
if n<r:
re... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
41,
28,
13,
4,
13,
17,
4,
13,
0,
13,
13,
0,
18,
18,
18,
13,
17,
17,
17,
17,
28,
13,
4,
13,
13,
28,
13,
4,
13,
2,
13,
13,... | [
[
136,
2
],
[
136,
11
],
[
139,
13
],
[
27,
26
],
[
127,
33
],
[
43,
36
],
[
128,
39
],
[
46,
45
],
[
134,
48
],
[
51,
50
],
[
134,
54
],
[
137,
55
],
[
58,
57
],... | [
"n,a = map(int,input().split())\nx = list(map(int,input().split()))\n\n\ndp = [[[0]*(55) for i in range(3000)]for i in range(55)]\ndp[0][0][0] = 1\n\nfor i in range(n):\n for j in range(n*a):\n for k in range(n):\n dp[i+1][j][k] += dp[i][j][k]\n dp[i+1][j+x[i]][k+1] += dp[i][j][k]\n \n \nans =... | n,a = map(int,input().split())
x = list(map(int,input().split()))
dp = [[[0]*(55) for i in range(3000)]for i in range(55)]
dp[0][0][0] = 1
for i in range(n):
for j in range(n*a):
for k in range(n):
dp[i+1][j][k] += dp[i][j][k]
dp[i+1][j+x[i]][k+1] += dp[i][j][k]
ans = 0
for k in range(1... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
41,
28,
13,
4,
13,
17,
4,
2,
39,
17,
17,
0,
13,
13,
28,
13,
13,
28,
13,
18,
4,
13,
17,
39,
17,
28,
13,
13,
4,
13,
18,
13... | [
[
115,
2
],
[
115,
11
],
[
121,
13
],
[
27,
26
],
[
112,
36
],
[
40,
39
],
[
122,
39
],
[
43,
42
],
[
113,
55
],
[
42,
56
],
[
71,
62
],
[
113,
64
],
[
42,
66
],
... | [
"# coding: utf-8\n# Your code here!\nN,A=map(int,input().split())\n\nX=list(map(int,input().split()))\n\ndp=[[0]*2501 for i in range(50)]\n\nfor x in X:\n for i in range(49)[::-1]:\n for index,item in enumerate(dp[i]):\n if item!=0:\n dp[i+1][index+x]+=dp[i][index]\n dp[0][x]+... | # coding: utf-8
# Your code here!
N,A=map(int,input().split())
X=list(map(int,input().split()))
dp=[[0]*2501 for i in range(50)]
for x in X:
for i in range(49)[::-1]:
for index,item in enumerate(dp[i]):
if item!=0:
dp[i+1][index+x]+=dp[i][index]
dp[0][x]+=1
ans=0
for i in... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
2,
13,
13,
41,
28,
13,
4,
13,
2,
13,
17,
4,
13,
0,
13,
13,
0,
18,
18,
13,
17,
17,
17,
28,
13,
13,
4,
13,
13,
0,
... | [
[
140,
2
],
[
140,
11
],
[
143,
13
],
[
134,
25
],
[
141,
27
],
[
126,
28
],
[
32,
31
],
[
126,
35
],
[
131,
40
],
[
48,
43
],
[
132,
45
],
[
144,
54
],
[
57,
56
... | [
"N, A = map(int, input().split())\nnums = list(map(int, input().split()))\nMAX = A*N\ndp = [[0 for _ in range(A*N+1)] for _ in range(N+1)]\ndp[0][0] = 1\nfor k, num in enumerate(nums, start=1):\n for i in range(N-1, -1, -1):\n for j in range(A*N-1, -1, -1):\n if j + num <= A*N:\n dp[i+1][j+num] += d... | N, A = map(int, input().split())
nums = list(map(int, input().split()))
MAX = A*N
dp = [[0 for _ in range(A*N+1)] for _ in range(N+1)]
dp[0][0] = 1
for k, num in enumerate(nums, start=1):
for i in range(N-1, -1, -1):
for j in range(A*N-1, -1, -1):
if j + num <= A*N:
dp[i+1][j+num] += dp[i][j]
ans = ... |
[
7,
12,
13,
29,
4,
13,
4,
18,
4,
13,
13,
12,
13,
29,
4,
13,
4,
13,
13,
4,
18,
4,
18,
4,
13,
13,
13,
17,
12,
13,
17,
0,
13,
4,
13,
13,
0,
13,
4,
13,
41,
28,
13,
4,
13,
2,
2,
13,
4,
13,
13,
17,
4,
13,
0,
13,
... | [
[
33,
32
],
[
196,
34
],
[
33,
35
],
[
38,
37
],
[
196,
39
],
[
43,
42
],
[
32,
47
],
[
37,
50
],
[
56,
55
],
[
59,
58
],
[
32,
62
],
[
72,
65
],
[
55,
68
],
[
... | [
"\n\ndef read_int():\n return int(input().strip())\n\n\ndef read_ints():\n return list(map(int, input().strip().split(' ')))\n\n\ndef solve():\n \"\"\"\n OPT[i][j][k] - sum is i, j number of elements, first k elements\n OPT[i][j][k] = OPT[i-x[k]][j-1][k-1] if j-th element is taken\n ... |
def read_int():
return int(input().strip())
def read_ints():
return list(map(int, input().strip().split(' ')))
def solve():
"""
OPT[i][j][k] - sum is i, j number of elements, first k elements
OPT[i][j][k] = OPT[i-x[k]][j-1][k-1] if j-th element is taken
OPT[i][j][k-1]
O... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
4,
13,
13,
0,
13,
2,
13,
13,
41,
28,
13,
4,
13,
13,
4,
2,
39,
17,
2,
2,
17,
13,
17,
0,
13,
13,
0,
18,
18,
13,
1... | [
[
167,
2
],
[
167,
11
],
[
161,
13
],
[
170,
25
],
[
162,
28
],
[
158,
30
],
[
168,
32
],
[
171,
33
],
[
37,
36
],
[
168,
39
],
[
159,
47
],
[
164,
50
],
[
58,
53
... | [
"N, A = map(int, input().split())\nX = list(map(int, input().split()))\nxmax = max(X)\n\nOFS = N*xmax\ndp = [[0]*(2*OFS+1) for _ in range(N)]\ndp[0][OFS] += 1\ndp[0][OFS+(X[0]-A)] += 1\n\nfor i in range(1, N):\n for s in range(2*OFS+1):\n t = s-(X[i]-A)\n if t < 0 or t > 2*OFS:\n dp[i][s] = dp[i-1][s]\n... | N, A = map(int, input().split())
X = list(map(int, input().split()))
xmax = max(X)
OFS = N*xmax
dp = [[0]*(2*OFS+1) for _ in range(N)]
dp[0][OFS] += 1
dp[0][OFS+(X[0]-A)] += 1
for i in range(1, N):
for s in range(2*OFS+1):
t = s-(X[i]-A)
if t < 0 or t > 2*OFS:
dp[i][s] = dp[i-1][s]
else:
dp[... |
[
7,
15,
13,
15,
13,
15,
15,
4,
18,
13,
13,
17,
15,
15,
15,
15,
15,
15,
15,
0,
13,
2,
2,
17,
17,
17,
0,
13,
4,
13,
17,
12,
13,
12,
13,
0,
13,
4,
13,
13,
0,
13,
4,
13,
41,
28,
13,
4,
13,
2,
13,
17,
4,
13,
0,
1... | [
[
187,
20
],
[
199,
27
],
[
202,
36
],
[
179,
38
],
[
202,
39
],
[
181,
41
],
[
179,
43
],
[
47,
46
],
[
173,
50
],
[
184,
55
],
[
65,
58
],
[
185,
61
],
[
68,
67
... | [
"#!/usr/bin/env python3\n\nimport sys\nimport math\nfrom bisect import bisect_right as br\nfrom bisect import bisect_left as bl\nsys.setrecursionlimit(2147483647)\nfrom heapq import heappush, heappop,heappushpop\nfrom collections import defaultdict\nfrom itertools import accumulate\nfrom collections import Counter\... | #!/usr/bin/env python3
import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collection... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
18,
4,
13,
17,
13,
13,
13,
31,
13,
0,
13,
17,
0,
13,
39,
2,
2,
39,
17,
13,
17,
2,
2,
39,
17,
13,
17,
0,
18,
18,
13,
17,
17,
17,
0,
13,
17,
28,
13,
4,
13,
13,
0,
13,
2,
17,
13,... | [
[
114,
2
],
[
114,
15
],
[
114,
16
],
[
102,
19
],
[
117,
22
],
[
103,
28
],
[
103,
34
],
[
42,
37
],
[
118,
39
],
[
105,
44
],
[
48,
47
],
[
115,
50
],
[
108,
52
... | [
"n,a,*l=map(int,open(0).read().split())\nR=2500\ndp=[[0]*R*2,[0]*R*2]\ndp[0][0]=1\nt=0\nfor i in range(n):\n u=1-t\n for s in range(-R,R):\n dp[u][s]=dp[t][s]+dp[t][s-l[i]+a]\n t=u\nprint(dp[t][0]-1)",
"n,a,*l=map(int,open(0).read().split())",
"n",
"map(int,open(0).read().split())",
"map",
"int",
... | n,a,*l=map(int,open(0).read().split())
R=2500
dp=[[0]*R*2,[0]*R*2]
dp[0][0]=1
t=0
for i in range(n):
u=1-t
for s in range(-R,R):
dp[u][s]=dp[t][s]+dp[t][s-l[i]+a]
t=u
print(dp[t][0]-1) |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
17,
41,
28,
13,
4,
13,
2,
13,
17,
4,
13,
0,
13,
13,
0,
18,
18,
18,
13,
17,
17,
17,
17,
28,
13,
4,
13,
2,
13,
17,
... | [
[
195,
2
],
[
195,
11
],
[
198,
13
],
[
192,
25
],
[
30,
29
],
[
196,
33
],
[
201,
38
],
[
48,
41
],
[
202,
44
],
[
51,
50
],
[
196,
54
],
[
58,
57
],
[
50,
61
],... | [
"n,a=map(int,input().split())\nx=list(map(int,input().split()))\nans=0\ndp=[[[0]*(sum(x)+1) for i in range(n+1)] for j in range(n+1)]\ndp[0][0][0]=1\nfor i in range(n+1):\n for j in range(i+1):\n for k in range(sum(x)+1):\n if i>=1 and k>=x[i-1] and j>=1:\n dp[i][j][k]=dp[i-1][j-1][k-x[i-1]]+dp[i-1]... | n,a=map(int,input().split())
x=list(map(int,input().split()))
ans=0
dp=[[[0]*(sum(x)+1) for i in range(n+1)] for j in range(n+1)]
dp[0][0][0]=1
for i in range(n+1):
for j in range(i+1):
for k in range(sum(x)+1):
if i>=1 and k>=x[i-1] and j>=1:
dp[i][j][k]=dp[i-1][j-1][k-x[i-1]]+dp[i-1][j][k]
e... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
41,
28,
13,
4,
13,
13,
4,
2,
18,
13,
13,
13,
0,
13,
13,
41,
28,
13,
4,
13,
17,
4,
13,
0,
13,
13,
28,
13,
4,
13,
17,
0,
... | [
[
121,
2
],
[
121,
11
],
[
118,
13
],
[
27,
26
],
[
122,
29
],
[
119,
33
],
[
26,
34
],
[
116,
35
],
[
124,
37
],
[
42,
41
],
[
112,
48
],
[
52,
51
],
[
61,
56
],... | [
"n,k = map(int,input().split())\na = list(map(int,input().split()))\na = [a[i]-k for i in range(n)]\nDP = [[0 for i in range(5100)] for j in range(52)]\nfor i in range(52):\n DP[i][2530] = 1\nfor i in range(1,n+1):\n for j in range(5050):\n DP[i][j] = DP[i-1][j] + DP[i-1][j-a[i-1]]\nprint(DP[n][2530]-1... | n,k = map(int,input().split())
a = list(map(int,input().split()))
a = [a[i]-k for i in range(n)]
DP = [[0 for i in range(5100)] for j in range(52)]
for i in range(52):
DP[i][2530] = 1
for i in range(1,n+1):
for j in range(5050):
DP[i][j] = DP[i-1][j] + DP[i-1][j-a[i-1]]
print(DP[n][2530]-1) |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
18,
4,
13,
13,
13,
17,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
18,
4,
13,
13,
13,
17,
41,
28,
13,
4,
13,
17,
4,
17,
0,
13,
13,
41,
28,
13,
4,
13,
17,
4,
17,
0,
13,
13,
0,
18,
... | [
[
187,
2
],
[
187,
15
],
[
181,
17
],
[
35,
34
],
[
184,
41
],
[
46,
45
],
[
190,
52
],
[
58,
55
],
[
191,
56
],
[
62,
61
],
[
166,
68
],
[
74,
71
],
[
167,
72
],... | [
"N,A = map(int,input().rstrip().split(\" \"))\nX = list(map(int,input().rstrip().split(\" \")))\nDPq = [0 for _ in range(1300)]\nDPp = [0 for _ in range(1300)]\nDPp[0] = 1\nDPm = [0 for _ in range(1300)]\nDPm[0] = 1\njust = 0\nans = 0\nfor i in X:\n if i > A:\n for i2 in range(1250,-1,-1):\n DP... | N,A = map(int,input().rstrip().split(" "))
X = list(map(int,input().rstrip().split(" ")))
DPq = [0 for _ in range(1300)]
DPp = [0 for _ in range(1300)]
DPp[0] = 1
DPm = [0 for _ in range(1300)]
DPm[0] = 1
just = 0
ans = 0
for i in X:
if i > A:
for i2 in range(1250,-1,-1):
DPp[i2 + (i - A)] += DP... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
2,
17,
13,
41,
28,
13,
4,
13,
2,
13,
17,
4,
13,
0,
13,
13,
0,
18,
18,
18,
13,
17,
17,
17,
17,
28,
13,
13,
4,
13,
... | [
[
162,
2
],
[
162,
11
],
[
153,
13
],
[
159,
25
],
[
163,
28
],
[
32,
31
],
[
163,
35
],
[
156,
40
],
[
50,
43
],
[
157,
46
],
[
154,
56
],
[
60,
59
],
[
67,
66
]... | [
"N, A = map(int, input().split())\n\nx = list(map(int, input().split()))\n\nmaxint = 50 * N\n\ndp = [[[0] * (maxint + 1) for _ in range(N + 1)] for _ in range(N + 1)]\n\ndp[0][0][0] = 1\n\nfor xi, xe in enumerate(x, 1):\n for j in range(xi+1):\n for k in range(maxint + 1):\n dp[xi][j][k] = dp[x... | N, A = map(int, input().split())
x = list(map(int, input().split()))
maxint = 50 * N
dp = [[[0] * (maxint + 1) for _ in range(N + 1)] for _ in range(N + 1)]
dp[0][0][0] = 1
for xi, xe in enumerate(x, 1):
for j in range(xi+1):
for k in range(maxint + 1):
dp[xi][j][k] = dp[xi - 1][j][k]
... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
4,
18,
13,
13,
41,
28,
13,
13,
4,
2,
13,
13,
0,
13,
13,
0,
13,
2,
39,
17,
17,
28,
13,
13,
28,
13,
8,
2,
13,
17,
4,
13,
... | [
[
103,
2
],
[
103,
11
],
[
100,
13
],
[
101,
26
],
[
31,
30
],
[
101,
30
],
[
30,
34
],
[
104,
35
],
[
94,
37
],
[
91,
40
],
[
47,
46
],
[
95,
46
],
[
101,
46
],
... | [
"N, A = map(int, input().split())\nx = list(map(int, input().split()))\n\nx.sort()\nx = [v - A for v in x]\n\ndp = [0] * 5001\nfor v in x:\n for i in range(2501) if v < 0 else range(5000, -1, -1):\n if dp[i] == 0:\n continue\n dp[i + v] += dp[i]\n dp[2500 + v] += 1\nprint(dp[2500])",
... | N, A = map(int, input().split())
x = list(map(int, input().split()))
x.sort()
x = [v - A for v in x]
dp = [0] * 5001
for v in x:
for i in range(2501) if v < 0 else range(5000, -1, -1):
if dp[i] == 0:
continue
dp[i + v] += dp[i]
dp[2500 + v] += 1
print(dp[2500])
|
[
7,
15,
13,
41,
28,
13,
4,
18,
4,
18,
18,
13,
13,
13,
13,
4,
4,
13,
13,
0,
13,
13,
13,
41,
28,
13,
4,
18,
4,
18,
18,
13,
13,
13,
13,
4,
2,
4,
13,
13,
13,
0,
13,
13,
41,
28,
13,
4,
13,
2,
13,
17,
4,
13,
0,
13... | [
[
6,
5
],
[
5,
18
],
[
142,
20
],
[
142,
22
],
[
26,
25
],
[
25,
39
],
[
143,
40
],
[
139,
42
],
[
47,
46
],
[
137,
50
],
[
145,
55
],
[
65,
58
],
[
146,
60
],
... | [
"import sys\nn, a = [int(i) for i in sys.stdin.readline().split()]\nx_ls = [int(i) - a for i in sys.stdin.readline().split()]\n#memo_ls[i][j] : i番目まででj - 50*50ができる通り数\nmemo_ls = [[0 for i in range(2 * 50 * 50 + 1)] for j in range(n+1)]\nmemo_ls[0][50*50] = 1\nfor i, x in enumerate(x_ls, 1):\n for j in range(2*5... | import sys
n, a = [int(i) for i in sys.stdin.readline().split()]
x_ls = [int(i) - a for i in sys.stdin.readline().split()]
#memo_ls[i][j] : i番目まででj - 50*50ができる通り数
memo_ls = [[0 for i in range(2 * 50 * 50 + 1)] for j in range(n+1)]
memo_ls[0][50*50] = 1
for i, x in enumerate(x_ls, 1):
for j in range(2*50*50+1):
... |
[
7,
12,
13,
14,
2,
13,
17,
14,
40,
13,
17,
14,
2,
2,
13,
13,
13,
29,
17,
29,
17,
14,
40,
18,
18,
18,
13,
13,
13,
13,
17,
29,
18,
18,
18,
13,
13,
13,
13,
0,
18,
18,
18,
13,
13,
13,
13,
2,
4,
13,
2,
13,
17,
13,
... | [
[
79,
5
],
[
81,
9
],
[
81,
14
],
[
83,
15
],
[
83,
27
],
[
79,
28
],
[
81,
29
],
[
83,
36
],
[
79,
37
],
[
81,
38
],
[
47,
40
],
[
83,
44
],
[
79,
45
],
[
... | [
"def f(n,x,i):\n if n == 0:\n if x != 0:\n if x / i == a:\n return 1\n return 0\n if memo[i][n][x] != -1:\n return memo[i][n][x]\n memo[i][n][x] = f(n-1,x,i)+f(n-1,x+ary[n-1],i+1)\n return memo[i][n][x]\nn,a = map(int,input().split())\nary = list(map(int,in... | def f(n,x,i):
if n == 0:
if x != 0:
if x / i == a:
return 1
return 0
if memo[i][n][x] != -1:
return memo[i][n][x]
memo[i][n][x] = f(n-1,x,i)+f(n-1,x+ary[n-1],i+1)
return memo[i][n][x]
n,a = map(int,input().split())
ary = list(map(int,input().split()))
... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
4,
13,
4,
13,
12,
2,
13,
13,
23,
13,
0,
13,
17,
0,
13,
17,
28,
13,
13,
14,
2,
13,
17,
0,
13,
13,
0,
13,
13,
0,
... | [
[
172,
2
],
[
172,
11
],
[
181,
13
],
[
166,
25
],
[
158,
33
],
[
182,
35
],
[
163,
37
],
[
175,
40
],
[
44,
43
],
[
167,
43
],
[
43,
47
],
[
154,
50
],
[
43,
51
... | [
"N,A = map(int, input().split())\nalist = list(map(int, input().split()))\n\nblist = list(map(lambda x:x-A,alist))\nsum_plus = 0\nsum_minus = 0\nfor i in blist:\n if i >0:\n sum_plus +=i\n else:\n sum_minus +=i\n\nN=len(alist)\ndp = [[0 for i in range(sum_plus - sum_minus + 1)] for j in range(N+... | N,A = map(int, input().split())
alist = list(map(int, input().split()))
blist = list(map(lambda x:x-A,alist))
sum_plus = 0
sum_minus = 0
for i in blist:
if i >0:
sum_plus +=i
else:
sum_minus +=i
N=len(alist)
dp = [[0 for i in range(sum_plus - sum_minus + 1)] for j in range(N+1)]
dp[0][0-sum_mi... |
[
7,
15,
12,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
18,
4,
13,
13,
4,
2,
4,
13,
13,
13,
0,
13,
13,
0,
13,
4,
13,
39,
17,
28,
13,
13,
0,
13,
4,
13,
13,
28,
13,
13,
4,
18,
13,
13,
0,
18,
13,... | [
[
6,
5
],
[
6,
14
],
[
18,
17
],
[
17,
27
],
[
14,
28
],
[
31,
30
],
[
34,
33
],
[
40,
39
],
[
30,
39
],
[
43,
42
],
[
33,
51
],
[
61,
51
],
[
59,
54
],
[
4... | [
"#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\nfrom collections import Counter, defaultdict\n\n\ndef main():\n N, A = map(int, input().split())\n X = [int(x) - A for x in input().split()]\n\n result = Counter([0])\n\n for x in X:\n dct = defaultdict(int)\n for k, v in result.items():\n ... | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
from collections import Counter, defaultdict
def main():
N, A = map(int, input().split())
X = [int(x) - A for x in input().split()]
result = Counter([0])
for x in X:
dct = defaultdict(int)
for k, v in result.items():
dct[k + ... |
[
7,
15,
15,
15,
13,
15,
13,
15,
13,
15,
15,
13,
15,
13,
15,
15,
15,
15,
4,
18,
13,
13,
17,
0,
13,
4,
13,
17,
12,
13,
12,
13,
12,
13,
12,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
12,
13,
23,
13,
41,
28,
13,
4,
13,
... | [
[
235,
24
],
[
39,
38
],
[
230,
44
],
[
48,
48
],
[
52,
51
],
[
224,
57
],
[
61,
61
],
[
65,
64
],
[
212,
70
],
[
74,
74
],
[
78,
77
],
[
245,
83
],
[
87,
87
],
... | [
"from collections import defaultdict, deque, Counter\nfrom heapq import heappush, heappop, heapify\nimport math\nimport bisect\nimport random\nfrom itertools import permutations, accumulate, combinations, product\nimport sys\nimport string\nfrom bisect import bisect_left, bisect_right\nfrom math import factorial, c... | from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
fro... |
[
7,
15,
13,
41,
28,
13,
4,
18,
4,
13,
13,
4,
4,
13,
13,
0,
13,
13,
13,
41,
28,
13,
4,
18,
4,
13,
13,
4,
4,
13,
13,
0,
13,
13,
12,
13,
0,
13,
4,
13,
13,
41,
28,
13,
4,
13,
2,
13,
17,
4,
4,
18,
13,
13,
13,
0,
... | [
[
6,
5
],
[
5,
14
],
[
128,
16
],
[
128,
18
],
[
22,
21
],
[
21,
30
],
[
119,
32
],
[
38,
37
],
[
101,
40
],
[
44,
43
],
[
37,
47
],
[
57,
56
],
[
64,
59
],
[
... | [
"import collections\nN, A = [int(_) for _ in input().split()]\nX = [int(_) for _ in input().split()]\n\n\ndef calc(W):\n #dp[m][s]=m枚のカードの和がsとなるような選び方の総数\n M = len(W)\n dp = [collections.defaultdict(int) for _ in range(M + 1)]\n dp[0][0] = 1\n for i, w in enumerate(W):\n for j in range(i, -1, ... | import collections
N, A = [int(_) for _ in input().split()]
X = [int(_) for _ in input().split()]
def calc(W):
#dp[m][s]=m枚のカードの和がsとなるような選び方の総数
M = len(W)
dp = [collections.defaultdict(int) for _ in range(M + 1)]
dp[0][0] = 1
for i, w in enumerate(W):
for j in range(i, -1, -1):
... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
4,
13,
4,
13,
13,
13,
0,
13,
2,
13,
13,
41,
28,
13,
4,
13,
2,
13,
17,
4,
13,
0,
13,
13,
0,
18,
18,
18,
13,
17,
... | [
[
198,
2
],
[
198,
11
],
[
201,
13
],
[
213,
25
],
[
202,
30
],
[
193,
31
],
[
204,
33
],
[
199,
35
],
[
214,
36
],
[
40,
39
],
[
199,
43
],
[
210,
48
],
[
58,
51
... | [
"n,a=map(int,input().split())\nx=list(map(int,input().split()))\n\nxmax=max(max(x),a)\n \nnx=n*xmax\ndp=[[[0]*(nx+1) for ii in range(n+1)] for i in range(n+1)]\n\ndp[0][0][0]=1\n\nfor j in range(1,n+1):\n jj=j-1\n for k in range(n+1):\n for s in range(nx+1):\n if s<x[jj]:\n ... | n,a=map(int,input().split())
x=list(map(int,input().split()))
xmax=max(max(x),a)
nx=n*xmax
dp=[[[0]*(nx+1) for ii in range(n+1)] for i in range(n+1)]
dp[0][0][0]=1
for j in range(1,n+1):
jj=j-1
for k in range(n+1):
for s in range(nx+1):
if s<x[jj]:
dp[j][k][s]=dp[j-1]... |
[
7,
15,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
4,
2,
13,
13,
0,
13,
13,
0,
13,
4,
13,
13,
0,
18,
13,
17,
17,
28,
13,
13,
28,
13,
13,
4,
13,
4,
18,
13,
13,
0,
... | [
[
73,
3
],
[
73,
12
],
[
16,
15
],
[
15,
28
],
[
74,
29
],
[
76,
31
],
[
79,
34
],
[
42,
39
],
[
80,
40
],
[
45,
44
],
[
77,
44
],
[
80,
53
],
[
61,
56
],
[
... | [
"from collections import defaultdict\n\nn, a = map(int, input().split())\narr = [x-a for x in list(map(int, input().split()))]\n\ndct = defaultdict(int)\ndct[0] = 1\n\nfor x in arr:\n for k, v in list(dct.items()):\n dct[k+x] += v\n\nprint(dct[0]-1)",
"from collections import defaultdict",
"n, a = map... | from collections import defaultdict
n, a = map(int, input().split())
arr = [x-a for x in list(map(int, input().split()))]
dct = defaultdict(int)
dct[0] = 1
for x in arr:
for k, v in list(dct.items()):
dct[k+x] += v
print(dct[0]-1) |
[
7,
15,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
18,
4,
13,
13,
4,
4,
13,
13,
0,
13,
13,
0,
13,
4,
18,
13,
13,
39,
17,
17,
17,
0,
18,
13,
39,
17,
28,
13,
4,
13,
17,
2,
13,
17,
0,
13,
18,
13... | [
[
122,
4
],
[
122,
13
],
[
17,
16
],
[
16,
25
],
[
113,
27
],
[
119,
30
],
[
43,
40
],
[
120,
41
],
[
46,
45
],
[
123,
50
],
[
128,
53
],
[
114,
55
],
[
45,
57
],... | [
"import numpy as np\nN, A = map(int, input().split())\nX = [int(c) for c in input().split()]\ndp = np.zeros((51,51,2501))\ndp[:,0,0] = 1\nfor i in range(1,N+1):\n c = X[i-1]\n for k in range(1,N+1):\n dp[i,k,:c] = dp[i-1,k,:c]\n dp[i,k,c:] = dp[i-1,k,c:]+dp[i-1,k-1,:2501-c]\nans = 0\nfor i in range(1,N+1):\... | import numpy as np
N, A = map(int, input().split())
X = [int(c) for c in input().split()]
dp = np.zeros((51,51,2501))
dp[:,0,0] = 1
for i in range(1,N+1):
c = X[i-1]
for k in range(1,N+1):
dp[i,k,:c] = dp[i-1,k,:c]
dp[i,k,c:] = dp[i-1,k,c:]+dp[i-1,k-1,:2501-c]
ans = 0
for i in range(1,N+1):
ans += dp[N,i,... |
[
7,
12,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
12,
2,
4,
13,
13,
13,
23,
4,
18,
4,
13,
13,
0,
13,
21,
22,
17,
17,
28,
13,
13,
28,
13,
13,
4,
13,
4,
18,
13,
13,
0,
18,
13,
2,
13,
13,... | [
[
5,
4
],
[
5,
13
],
[
16,
15
],
[
13,
25
],
[
34,
33
],
[
40,
39
],
[
15,
39
],
[
33,
48
],
[
56,
51
],
[
33,
52
],
[
39,
55
],
[
33,
59
],
[
39,
63
],
[
6... | [
"def abc044_c():\n #値入力\n _, A = map(int, input().split())\n X = list(map(lambda x : int(x)-A,input().split()))\n #初期値\n d = {0:1}\n for x in X:\n for k,v in list(d.items()):\n d[k + x] = d.get(k + x,0) + v #差分の合計\n ans = d[0] - 1 #差分合計0で初期値を除く\n print(ans)\n\nif __name__ =... | def abc044_c():
#値入力
_, A = map(int, input().split())
X = list(map(lambda x : int(x)-A,input().split()))
#初期値
d = {0:1}
for x in X:
for k,v in list(d.items()):
d[k + x] = d.get(k + x,0) + v #差分の合計
ans = d[0] - 1 #差分合計0で初期値を除く
print(ans)
if __name__ == '__main__':
... |
[
7,
15,
13,
0,
13,
18,
18,
13,
13,
13,
0,
13,
18,
18,
13,
13,
13,
0,
13,
18,
18,
13,
13,
13,
4,
18,
13,
13,
2,
17,
17,
0,
13,
2,
17,
17,
0,
13,
17,
12,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
31,
13,
41,
... | [
[
168,
4
],
[
177,
11
],
[
162,
18
],
[
171,
32
],
[
165,
37
],
[
43,
42
],
[
169,
49
],
[
43,
51
],
[
43,
52
],
[
57,
56
],
[
42,
60
],
[
42,
68
],
[
73,
72
],
... | [
"import sys\n\nread = sys.stdin.read\nreadline = sys.stdin.readline\nreadlines = sys.stdin.readlines\nsys.setrecursionlimit(10 ** 9)\nINF = 1 << 60\nMOD = 1000000007\n\n\ndef main():\n N, A, *X = map(int, read().split())\n\n dp = [[0] * (N * 50 + 1) for j in range(N + 1)]\n dp[0][0] = 1\n\n for i in ran... | import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007
def main():
N, A, *X = map(int, read().split())
dp = [[0] * (N * 50 + 1) for j in range(N + 1)]
dp[0][0] = 1
for i in range(N):
for j ... |
[
7,
41,
28,
13,
4,
18,
4,
13,
13,
4,
4,
13,
13,
0,
13,
13,
13,
0,
13,
17,
41,
28,
13,
4,
13,
2,
13,
17,
4,
2,
39,
17,
13,
0,
13,
13,
12,
13,
29,
2,
2,
13,
13,
2,
13,
17,
23,
13,
41,
28,
13,
4,
18,
4,
13,
13,... | [
[
4,
3
],
[
3,
12
],
[
150,
14
],
[
150,
16
],
[
141,
18
],
[
23,
22
],
[
139,
26
],
[
142,
32
],
[
144,
34
],
[
47,
41
],
[
151,
42
],
[
142,
44
],
[
47,
47
],
... | [
"N, A = [int(_) for _ in input().split()]\n\nMAX_I = 5000\nmemo = [[0] * MAX_I for _ in range(N + 2)]\n\n\ndef cnv(v):\n return v - A + (MAX_I // 2)\n\n\nX = [int(_) for _ in input().split()]\nfor i in range(N):\n offset = X[i] - A\n # print('x', offset)\n\n mm = memo[i]\n for j in range(MAX_I):\n ... | N, A = [int(_) for _ in input().split()]
MAX_I = 5000
memo = [[0] * MAX_I for _ in range(N + 2)]
def cnv(v):
return v - A + (MAX_I // 2)
X = [int(_) for _ in input().split()]
for i in range(N):
offset = X[i] - A
# print('x', offset)
mm = memo[i]
for j in range(MAX_I):
if mm[j] > 0:
... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
4,
13,
4,
13,
12,
2,
13,
13,
23,
13,
0,
13,
21,
22,
17,
17,
28,
13,
13,
28,
13,
13,
4,
13,
4,
18,
13,
13,
0,
18,
... | [
[
90,
2
],
[
90,
11
],
[
78,
13
],
[
81,
25
],
[
91,
33
],
[
79,
35
],
[
84,
37
],
[
44,
43
],
[
82,
43
],
[
79,
43
],
[
85,
52
],
[
60,
55
],
[
85,
56
],
[
... | [
"# N枚のカード\n# 平均aにしたい\nn, a = map(int, input().split())\n# 手持ちのカード\nx = list(map(int, input().split()))\n \n# aとの差を記録してリストに入れなおす\n# 「選んだカードの xi の平均が A」であることは,\n# 「選んだカードの (xi − A) の合計が 0」と言い換えることができる.\nx = list(map(lambda i: i-a, x))\n#print(x)\n \n# dp初期値(辞書型)\n# dp[0] = 1という意味\ndp = {0: 1}\n\n#xから1枚取り出す\nfor i in ... | # N枚のカード
# 平均aにしたい
n, a = map(int, input().split())
# 手持ちのカード
x = list(map(int, input().split()))
# aとの差を記録してリストに入れなおす
# 「選んだカードの xi の平均が A」であることは,
# 「選んだカードの (xi − A) の合計が 0」と言い換えることができる.
x = list(map(lambda i: i-a, x))
#print(x)
# dp初期値(辞書型)
# dp[0] = 1という意味
dp = {0: 1}
#xから1枚取り出す
for i in x:
#dpにあるすべてのkey,v... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
41,
28,
13,
4,
13,
17,
4,
13,
0,
13,
13,
28,
13,
4,
13,
2,
13,
17,
0,
18,
18,
18,
13,
13,
17,
17,
17,
28,
13,
4,
13,
13,... | [
[
164,
2
],
[
164,
11
],
[
167,
13
],
[
27,
26
],
[
155,
33
],
[
37,
36
],
[
165,
40
],
[
50,
43
],
[
156,
46
],
[
36,
47
],
[
53,
52
],
[
165,
55
],
[
58,
57
],
... | [
"n,a=map(int,input().split())\nx=list(map(int,input().split()))\ndp=[[[0]*(2501) for i in range(51)] for j in range(51)]\n#dp[i][j][k]は、i番目まででj枚とって総数kとなる取り方\nfor i in range(n+1):\n dp[i][0][0]=1\nfor i in range(n):\n for j in range(1,i+2):\n for k in range(1,2501):\n if k-x[i]>=0:\n ... | n,a=map(int,input().split())
x=list(map(int,input().split()))
dp=[[[0]*(2501) for i in range(51)] for j in range(51)]
#dp[i][j][k]は、i番目まででj枚とって総数kとなる取り方
for i in range(n+1):
dp[i][0][0]=1
for i in range(n):
for j in range(1,i+2):
for k in range(1,2501):
if k-x[i]>=0:
dp[i+1][... |
[
7,
15,
13,
0,
13,
18,
18,
13,
13,
13,
12,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
4,
13,
13,
41,
28,
13,
4,
13,
2,
13,
17,
4,
13,
0,
13,
13,
0,
18,
18,
... | [
[
190,
4
],
[
14,
13
],
[
191,
20
],
[
14,
22
],
[
25,
24
],
[
191,
33
],
[
37,
36
],
[
24,
39
],
[
43,
42
],
[
13,
46
],
[
52,
51
],
[
61,
54
],
[
51,
57
],
[
... | [
"import sys\ninput = sys.stdin.readline\n\n\ndef main():\n n, a = map(int, input().split())\n x = tuple(map(int, input().split()))\n\n sm_mx = sum(x)\n\n dp = [[[0] * (sm_mx + 1) for _ in range(n + 1)] for _ in range(n + 1)]\n\n dp[0][0][0] = 1\n\n for i, e in enumerate(x, 1):\n for j in ra... | import sys
input = sys.stdin.readline
def main():
n, a = map(int, input().split())
x = tuple(map(int, input().split()))
sm_mx = sum(x)
dp = [[[0] * (sm_mx + 1) for _ in range(n + 1)] for _ in range(n + 1)]
dp[0][0][0] = 1
for i, e in enumerate(x, 1):
for j in range(n + 1):
... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
41,
28,
13,
4,
13,
13,
4,
13,
0,
13,
13,
0,
18,
18,
18,
13,
17,
17,
17,
17,
14,
40,
18,
13,
17,
2,
13,
13,
0,
18,
18,
18... | [
[
224,
2
],
[
224,
11
],
[
215,
13
],
[
27,
26
],
[
222,
29
],
[
218,
33
],
[
43,
36
],
[
219,
39
],
[
216,
47
],
[
225,
50
],
[
222,
51
],
[
62,
53
],
[
219,
56
... | [
"N, A = map(int, input().split())\nx = list(map(int, input().split()))\n\n#dp[j][k][s] = (x0...xj からk枚選んでxiの合計をsにするような選び方の総数)\ndp = [[[0] * (A * N + 1) for k in range(N + 1)] for j in range(N)]\n\ndp[0][0][0] = 1\nif x[0] <= A * N:\n dp[0][1][x[0]] = 1\n\nfor j in range(N - 1):\n for k in range(N + 1):\n ... | N, A = map(int, input().split())
x = list(map(int, input().split()))
#dp[j][k][s] = (x0...xj からk枚選んでxiの合計をsにするような選び方の総数)
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... |
[
7,
0,
13,
4,
18,
4,
13,
13,
17,
13,
0,
13,
4,
13,
13,
13,
4,
13,
13,
0,
13,
4,
18,
4,
13,
13,
17,
41,
28,
13,
13,
4,
4,
13,
13,
0,
13,
13,
41,
28,
13,
13,
4,
2,
4,
13,
13,
13,
0,
13,
2,
39,
17,
13,
0,
13,
... | [
[
228,
2
],
[
228,
9
],
[
225,
11
],
[
223,
14
],
[
234,
15
],
[
229,
18
],
[
213,
20
],
[
30,
29
],
[
214,
29
],
[
29,
34
],
[
237,
36
],
[
41,
40
],
[
238,
40
]... | [
"N, A = input().split(\" \")\nN, A = int(N), int(A)\nx = input().split(\" \")\nx = [int(i) for i in x]\ny = [0]+[int(i)-A for i in x]\nX = max(x+[A])\n\ndp = [[0 for t in range(2*N*X+1)] for j in range(N+1)]\n\nfor j in range(N+1):\n for t in range(2*N*X+1):\n if j == 0 and t == N*X: # 0枚の時は0しか達成できない\n ... | N, A = input().split(" ")
N, A = int(N), int(A)
x = input().split(" ")
x = [int(i) for i in x]
y = [0]+[int(i)-A for i in x]
X = max(x+[A])
dp = [[0 for t in range(2*N*X+1)] for j in range(N+1)]
for j in range(N+1):
for t in range(2*N*X+1):
if j == 0 and t == N*X: # 0枚の時は0しか達成できない
dp[j][t] = ... |
[
7,
15,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
18,
13,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
21,
22,
17,
17,
28,
13,
2,
13,
13,
28,
13,
13,
4,
18,
4,
18,
13,
13,
13,
0,
18,
13,
2,
13,... | [
[
84,
4
],
[
84,
13
],
[
78,
15
],
[
75,
31
],
[
38,
37
],
[
79,
39
],
[
82,
40
],
[
76,
48
],
[
57,
52
],
[
76,
53
],
[
37,
55
],
[
76,
60
],
[
37,
63
],
[
... | [
"import numpy as np\n \nn, a = map(int, input().split())\nx = np.array(list(map(int, input().split())))\n \ndp = {0:1}\nfor y in x-a:\n for k, v in dp.copy().items():\n dp[y+k] = dp.get(y+k, 0) + v \nprint(dp[0]-1)",
"import numpy as np",
"numpy",
"n, a = map(int, input().split())",
"n",
"map(in... | import numpy as np
n, a = map(int, input().split())
x = np.array(list(map(int, input().split())))
dp = {0:1}
for y in x-a:
for k, v in dp.copy().items():
dp[y+k] = dp.get(y+k, 0) + v
print(dp[0]-1)
|
[
7,
15,
13,
0,
13,
4,
13,
4,
13,
12,
4,
13,
13,
23,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
12,
4,
13,
13,
23,
4,
18,
4,
13,
13,
0,
13,
4,
18,
13,
13,
13,
0,
13,
2,
13,
13,
0,
13,
2,
4,
13,
4,
13,
4,
13... | [
[
159,
4
],
[
159,
19
],
[
150,
21
],
[
162,
37
],
[
151,
42
],
[
153,
44
],
[
163,
46
],
[
151,
46
],
[
160,
47
],
[
168,
49
],
[
154,
57
],
[
163,
57
],
[
151,
57... | [
"import numpy as np\nn,avea=tuple(map(lambda x:int(x),input().split()))\nx=list(map(lambda x:int(x), input().split()))\nx=np.array(x)\nx=x-avea\nw=max(abs(min(x)),abs(max(x)))*n\ndp=np.zeros((n+1,2*w+1),dtype=int)\ndp[0,w]=1\nfor i in range(1,n+1):\n for j in range(2*w+1):\n if 0<=j-x[i-1]<=2*w:\n ... | import numpy as np
n,avea=tuple(map(lambda x:int(x),input().split()))
x=list(map(lambda x:int(x), input().split()))
x=np.array(x)
x=x-avea
w=max(abs(min(x)),abs(max(x)))*n
dp=np.zeros((n+1,2*w+1),dtype=int)
dp[0,w]=1
for i in range(1,n+1):
for j in range(2*w+1):
if 0<=j-x[i-1]<=2*w:
dp[i,j]=dp[i... |
[
7,
15,
13,
15,
13,
0,
13,
4,
13,
13,
4,
18,
4,
18,
18,
13,
13,
13,
13,
13,
31,
13,
12,
13,
0,
13,
4,
18,
13,
13,
39,
2,
13,
17,
17,
0,
13,
18,
13,
13,
0,
18,
13,
17,
17,
28,
13,
4,
13,
13,
0,
18,
13,
39,
17,
... | [
[
90,
6
],
[
90,
19
],
[
90,
20
],
[
26,
25
],
[
88,
32
],
[
37,
36
],
[
44,
41
],
[
25,
42
],
[
47,
46
],
[
88,
49
],
[
55,
51
],
[
25,
52
],
[
25,
58
],
[
... | [
"import sys\nimport numpy as np\n\nn, a, *x = map(int, sys.stdin.read().split())\n\ndef main():\n dp = np.zeros((n + 1, 2501), dtype=np.int64)\n dp[0, 0] = 1\n for i in range(n):\n dp[1:, x[i]:] += dp[:-1, :-x[i]].copy()\n i = np.arange(1, n + 1)\n print(dp[i, i * a].sum())\n\nif __name__ == ... | import sys
import numpy as np
n, a, *x = map(int, sys.stdin.read().split())
def main():
dp = np.zeros((n + 1, 2501), dtype=np.int64)
dp[0, 0] = 1
for i in range(n):
dp[1:, x[i]:] += dp[:-1, :-x[i]].copy()
i = np.arange(1, n + 1)
print(dp[i, i * a].sum())
if __name__ == '__main__':
ma... |
[
7,
17,
15,
13,
0,
13,
18,
18,
13,
13,
13,
15,
12,
13,
29,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
4,
13,
13,
0,
13,
4,
13,
0,
13,
4,
13,
13,
41,
28,
13,
4,
13,
2,
13,
17,
4,
13,
0,
13,
13,
28,
13,
4,
13,... | [
[
174,
5
],
[
175,
23
],
[
180,
26
],
[
184,
28
],
[
180,
29
],
[
162,
31
],
[
184,
33
],
[
171,
35
],
[
163,
38
],
[
42,
41
],
[
181,
45
],
[
189,
50
],
[
54,
53
... | [
"# https://atcoder.jp/contests/abc044/tasks/arc060_a\n# ソートしてからごちゃごちゃやればどうにかなりそう(無理でした)\n\n'''\n解説満点解法1\nもしもk枚選んだとき、合計がsになる通りの数がわかったら?→s=k*Aとなる場合の数の合計をすれば良い\n\nk枚選んだとき、合計がsになる通りの数は典型的なDP!\ndp(j,k,s)... X[0:j]からk枚選んで、その合計をsにするような選び方の総数\nと定義すると、\ndp(j+1,k,s) = X[j]を選んだ結果sになったときの通りの数 + X[j]を選ばずにsになっている通りの数 なので\ndp(j+1... | # https://atcoder.jp/contests/abc044/tasks/arc060_a
# ソートしてからごちゃごちゃやればどうにかなりそう(無理でした)
'''
解説満点解法1
もしもk枚選んだとき、合計がsになる通りの数がわかったら?→s=k*Aとなる場合の数の合計をすれば良い
k枚選んだとき、合計がsになる通りの数は典型的なDP!
dp(j,k,s)... X[0:j]からk枚選んで、その合計をsにするような選び方の総数
と定義すると、
dp(j+1,k,s) = X[j]を選んだ結果sになったときの通りの数 + X[j]を選ばずにsになっている通りの数 なので
dp(j+1,k,s) = dp(j,k-1... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
28,
13,
4,
13,
13,
0,
18,
13,
13,
13,
41,
28,
13,
4,
13,
2,
13,
17,
4,
13,
0,
13,
13,
0,
18,
18,
13,
17,
17,
17,
0,
13,
... | [
[
141,
2
],
[
141,
11
],
[
138,
13
],
[
26,
25
],
[
133,
28
],
[
33,
30
],
[
139,
31
],
[
25,
32
],
[
142,
33
],
[
37,
36
],
[
133,
40
],
[
144,
45
],
[
53,
48
],... | [
"N,A = map(int,input().split())\nX = list(map(int,input().split()))\nfor i in range(N):\n X[i] -= A\ndp = [[0 for i in range(5001)] for i in range(N+1)]\ndp[0][2500] = 1\nu = 2500\nd = 2500\nfor i in range(1,N+1):\n x = X[i-1]\n if x <= 0:\n d += x\n else:\n u += x\n for j in range(d,u+... | N,A = map(int,input().split())
X = list(map(int,input().split()))
for i in range(N):
X[i] -= A
dp = [[0 for i in range(5001)] for i in range(N+1)]
dp[0][2500] = 1
u = 2500
d = 2500
for i in range(1,N+1):
x = X[i-1]
if x <= 0:
d += x
else:
u += x
for j in range(d,u+1):
dp[i][j... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
41,
28,
13,
4,
13,
2,
13,
17,
4,
13,
0,
13,
13,
0,
18,
18,
18,
13,
17,
17,
17,
17,
28,
13,
4,
13,
13,
28,
13,
4,
13,
13,... | [
[
155,
2
],
[
155,
11
],
[
149,
13
],
[
27,
26
],
[
147,
30
],
[
143,
35
],
[
45,
38
],
[
144,
41
],
[
48,
47
],
[
147,
50
],
[
53,
52
],
[
147,
55
],
[
58,
57
],... | [
"N,A = map(int,input().split())\nX = list(map(int,input().split()))\ndp = [[[0 for _ in range(50*(N+2))] for _ in range(N+2)] for _ in range(N+2)]\n\ndp[0][0][0] = 1\n#kまでみた\nfor k in range(N):\n #used個使った\n for used in range(N):\n for i in range(50*N):\n #使う時\n if dp[used][k][i] ... | N,A = map(int,input().split())
X = list(map(int,input().split()))
dp = [[[0 for _ in range(50*(N+2))] for _ in range(N+2)] for _ in range(N+2)]
dp[0][0][0] = 1
#kまでみた
for k in range(N):
#used個使った
for used in range(N):
for i in range(50*N):
#使う時
if dp[used][k][i] == 0:
... |
[
7,
15,
13,
15,
13,
0,
13,
18,
18,
13,
13,
13,
12,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
18,
13,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
4,
13,
13,
4,
13,
13,
0,
13,
13,
0,
13,
4,
18,
... | [
[
177,
6
],
[
16,
15
],
[
178,
22
],
[
16,
24
],
[
27,
26
],
[
178,
39
],
[
43,
42
],
[
24,
45
],
[
26,
48
],
[
51,
50
],
[
24,
51
],
[
54,
53
],
[
15,
60
],
[
... | [
"import numpy as np\nimport sys\ninput = sys.stdin.readline\n\ndef main():\n N, A = map(int, input().split())\n x = np.array(list(map(int, input().split())))\n X = max(A, max(x))\n x -= A\n # print(x)\n dp = np.zeros((N+1, 2*N*X+1), dtype=int)\n # 初期化\n dp[0][N*X] = 1\n for i in range(N):... | import numpy as np
import sys
input = sys.stdin.readline
def main():
N, A = map(int, input().split())
x = np.array(list(map(int, input().split())))
X = max(A, max(x))
x -= A
# print(x)
dp = np.zeros((N+1, 2*N*X+1), dtype=int)
# 初期化
dp[0][N*X] = 1
for i in range(N):
dp[i+1] +... |
[
7,
15,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
13,
13,
4,
18,
4,
13,
13,
4,
2,
13,
13,
0,
13,
13,
4,
18,
13,
13,
0,
13,
4,
13,
28,
13,
13,
28,
13,
13,
4,
13,
4,
18,
13,
13,
0,
18,
13,
2,
13,
... | [
[
81,
3
],
[
81,
12
],
[
16,
15
],
[
15,
26
],
[
79,
27
],
[
75,
29
],
[
76,
33
],
[
84,
36
],
[
41,
40
],
[
76,
40
],
[
85,
49
],
[
57,
52
],
[
85,
53
],
[
... | [
"from collections import Counter\n\nX, A = map(int, input().split())\nx = [i - A for i in map(int, input().split())]\nx.sort()\ndp = Counter()\n\nfor i in x:\n for j, k in list(dp.items()):\n dp[j + i] = dp[j + i] + k\n dp[i] += 1\n\nprint(dp[0])",
"from collections import Counter",
"X, A = map(int... | from collections import Counter
X, A = map(int, input().split())
x = [i - A for i in map(int, input().split())]
x.sort()
dp = Counter()
for i in x:
for j, k in list(dp.items()):
dp[j + i] = dp[j + i] + k
dp[i] += 1
print(dp[0]) |
[
7,
6,
13,
12,
13,
0,
18,
13,
13,
13,
0,
18,
13,
13,
13,
41,
28,
13,
4,
13,
2,
18,
13,
13,
17,
4,
17,
0,
18,
13,
13,
13,
41,
28,
13,
4,
13,
2,
18,
13,
13,
17,
4,
17,
0,
18,
13,
13,
13,
28,
13,
4,
13,
17,
2,
... | [
[
9,
6
],
[
104,
7
],
[
106,
8
],
[
106,
9
],
[
14,
11
],
[
104,
12
],
[
108,
13
],
[
108,
14
],
[
18,
17
],
[
6,
21
],
[
104,
22
],
[
106,
23
],
[
31,
28
],
[
... | [
"class Combination:\n def __init__(self, n, mod):\n self.n = n\n self.mod = mod\n self.fac = [1 for i in range(self.n + 1)]\n self.finv = [1 for i in range(self.n + 1)]\n for i in range(2, self.n+1):\n self.fac[i] = (self.fac[i - 1] * i) % self.mod\n self.... | class Combination:
def __init__(self, n, mod):
self.n = n
self.mod = mod
self.fac = [1 for i in range(self.n + 1)]
self.finv = [1 for i in range(self.n + 1)]
for i in range(2, self.n+1):
self.fac[i] = (self.fac[i - 1] * i) % self.mod
self.finv[i] = (se... |
[
7,
15,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
17,
0,
13,
17,
28,
13,
13,
0,
13,
13,
14,
2,
13,
17,
0,
13,
13,
0,
13,
13,
0,
13,
2,
2,
13,
13,
17,
0,
... | [
[
161,
4
],
[
161,
13
],
[
152,
15
],
[
173,
27
],
[
155,
30
],
[
34,
33
],
[
153,
33
],
[
164,
36
],
[
162,
37
],
[
165,
40
],
[
33,
40
],
[
176,
43
],
[
165,
44
... | [
"import numpy as np\n\nN, A = map(int, input().split())\nx = list(map(int, input().split()))\nr = 0\nl = 0\nfor y in x:\n y -= A\n if y < 0:\n l += y\n else:\n r += y\n\nM = r-l+1\ndp = np.zeros((N+1,M), dtype='i8')\ndp[0][-l] = 1\n\nfor i in range(1, N+1):\n for j in range(M):\n d... | import numpy as np
N, A = map(int, input().split())
x = list(map(int, input().split()))
r = 0
l = 0
for y in x:
y -= A
if y < 0:
l += y
else:
r += y
M = r-l+1
dp = np.zeros((N+1,M), dtype='i8')
dp[0][-l] = 1
for i in range(1, N+1):
for j in range(M):
dp[i][j] = dp[i-1][j]
... |
[
7,
12,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
41,
28,
13,
4,
13,
2,
13,
17,
4,
2,
39,
17,
2,
2,
13,
13,
17,
0,
13,
13,
0,
18,
18,
13,
17,
17,
17,
28,
13,
13,
... | [
[
5,
4
],
[
5,
13
],
[
16,
15
],
[
29,
28
],
[
4,
32
],
[
13,
40
],
[
4,
41
],
[
45,
44
],
[
52,
47
],
[
44,
49
],
[
15,
58
],
[
61,
60
],
[
71,
70
],
[
13,... | [
"def solve():\n N, A = map(int, input().split())\n X = list(map(int, input().split()))\n \n dp = [[0] * (A * N + 1) for _ in range(N + 1)]\n dp[0][0] = 1\n for i, x in enumerate(X):\n for j in reversed(range(1, i + 2)):\n for a in range(x, A * N + 1):\n dp[j][a] += dp... | def solve():
N, A = map(int, input().split())
X = list(map(int, input().split()))
dp = [[0] * (A * N + 1) for _ in range(N + 1)]
dp[0][0] = 1
for i, x in enumerate(X):
for j in reversed(range(1, i + 2)):
for a in range(x, A * N + 1):
dp[j][a] += dp[j - 1][a - x]... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
41,
28,
13,
4,
13,
2,
13,
17,
4,
13,
0,
13,
13,
0,
13,
17,
0,
18,
18,
13,
17,
13,
17,
28,
13,
13,
4,
13,
13,
17,
0,
13,
... | [
[
119,
2
],
[
119,
11
],
[
113,
13
],
[
27,
26
],
[
111,
30
],
[
122,
35
],
[
125,
38
],
[
46,
41
],
[
123,
43
],
[
126,
45
],
[
114,
52
],
[
116,
55
],
[
120,
58
... | [
"n, a = map(int, input().split())\nxlst = list(map(int, input().split()))\ndp = [[0 for _ in range(5001)] for _ in range(n + 1)]\ncenter = 2500\ndp[0][center] = 1\nfor i, x in enumerate(xlst, 1):\n num = x - a\n for j in range(5001):\n dp[i][j] = dp[i - 1][j]\n if 0 <= j - num <= 5000:\n ... | n, a = map(int, input().split())
xlst = list(map(int, input().split()))
dp = [[0 for _ in range(5001)] for _ in range(n + 1)]
center = 2500
dp[0][center] = 1
for i, x in enumerate(xlst, 1):
num = x - a
for j in range(5001):
dp[i][j] = dp[i - 1][j]
if 0 <= j - num <= 5000:
dp[i][j] +=... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
41,
28,
13,
4,
13,
2,
13,
17,
4,
13,
0,
13,
13,
0,
18,
18,
18,
13,
17,
17,
17,
17,
28,
13,
4,
13,
17,
2,
13,
17,
0,
18,
... | [
[
177,
2
],
[
177,
11
],
[
183,
13
],
[
27,
26
],
[
178,
30
],
[
168,
35
],
[
45,
38
],
[
169,
41
],
[
48,
47
],
[
178,
52
],
[
62,
55
],
[
169,
58
],
[
47,
59
],... | [
"N,A=map(int,input().split())\nxlist=list(map(int,input().split()))\n\ndp=[[[0]*(sum(xlist)+1) for _ in range(N+1)] for _ in range(N+1)]\ndp[0][0][0]=1\nfor i in range(1,N+1):\n dp[i][0][0]=1\n for j in range(1,i+1):\n for k in range(1,sum(xlist)+1):\n dp[i][j][k]=dp[i-1][j][k]\n if k-xlist[i-1]>=0:\... | N,A=map(int,input().split())
xlist=list(map(int,input().split()))
dp=[[[0]*(sum(xlist)+1) for _ in range(N+1)] for _ in range(N+1)]
dp[0][0][0]=1
for i in range(1,N+1):
dp[i][0][0]=1
for j in range(1,i+1):
for k in range(1,sum(xlist)+1):
dp[i][j][k]=dp[i-1][j][k]
if k-xlist[i-1]>=0:
dp[i][j... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
41,
28,
13,
4,
13,
2,
13,
17,
4,
2,
39,
17,
17,
0,
13,
13,
0,
18,
18,
13,
17,
17,
17,
28,
13,
13,
4,
13,
13,
28,
13,
4,
... | [
[
122,
2
],
[
122,
11
],
[
113,
13
],
[
27,
26
],
[
123,
30
],
[
116,
38
],
[
46,
41
],
[
117,
43
],
[
114,
52
],
[
55,
54
],
[
64,
63
],
[
74,
69
],
[
117,
71
],... | [
"N, A = map(int, input().split())\nX = list(map(int, input().split()))\ndp = [[0]*2501 for _ in range(N+1)] # dp[n][k] := カードn枚で合計kにする選び方の数\ndp[0][0] = 1\n\nfor i, x in enumerate(X):\n for n in range(i+1, 0, -1):\n for k in range(x, 2501):\n dp[n][k] += dp[n-1][k-x]\n\nans = 0\nfor n in range(1, N+1):\n a... | N, A = map(int, input().split())
X = list(map(int, input().split()))
dp = [[0]*2501 for _ in range(N+1)] # dp[n][k] := カードn枚で合計kにする選び方の数
dp[0][0] = 1
for i, x in enumerate(X):
for n in range(i+1, 0, -1):
for k in range(x, 2501):
dp[n][k] += dp[n-1][k-x]
ans = 0
for n in range(1, N+1):
ans += dp[n][A*n]
... |
[
7,
12,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
41,
28,
13,
4,
18,
4,
13,
13,
4,
2,
4,
13,
13,
13,
0,
13,
13,
0,
13,
21,
22,
17,
17,
28,
13,
13,
28,
13,
13,
4,
13,
4,
18,
13,
13,
0,
18,
13,
2,
13,... | [
[
5,
4
],
[
5,
15
],
[
19,
18
],
[
18,
28
],
[
15,
29
],
[
32,
31
],
[
35,
34
],
[
41,
40
],
[
31,
40
],
[
34,
49
],
[
57,
52
],
[
34,
53
],
[
40,
56
],
[
3... | [
"def resolve():\n N, A = list(map(int, input().split()))\n X = [int(i) - A for i in input().split()]\n d = {0: 1}\n for x in X:\n for _sum, count in list(d.items()):\n d[_sum+x] = d.get(_sum+x, 0) + count\n\n print(d[0]-1)\n \n\n\nif '__main__' == __name__:\n resolve()\n",
"... | def resolve():
N, A = list(map(int, input().split()))
X = [int(i) - A for i in input().split()]
d = {0: 1}
for x in X:
for _sum, count in list(d.items()):
d[_sum+x] = d.get(_sum+x, 0) + count
print(d[0]-1)
if '__main__' == __name__:
resolve()
|
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
2,
2,
17,
13,
17,
41,
28,
13,
4,
13,
2,
13,
17,
4,
2,
39,
17,
13,
0,
13,
13,
28,
13,
4,
13,
13,
0,
13,
18,
13,
... | [
[
142,
2
],
[
142,
11
],
[
139,
13
],
[
145,
25
],
[
125,
29
],
[
34,
33
],
[
125,
37
],
[
146,
43
],
[
130,
45
],
[
49,
48
],
[
125,
51
],
[
133,
53
],
[
140,
55
... | [
"n, a = map(int, input().split())\nl = list(map(int, input().split()))\n\nt = 50*n+1\ndp = [[0]*t for _ in range(n+1)]\n\nfor i in range(n):\n x = l[i]\n for j in reversed(range(n+1)):\n for k in range(t):\n if dp[j][k] != 0:\n dp[j+1][k+x] += dp[j][k]\n dp[0][x] += 1\n\nans = 0\nfor i in range(n)... | n, a = map(int, input().split())
l = list(map(int, input().split()))
t = 50*n+1
dp = [[0]*t for _ in range(n+1)]
for i in range(n):
x = l[i]
for j in reversed(range(n+1)):
for k in range(t):
if dp[j][k] != 0:
dp[j+1][k+x] += dp[j][k]
dp[0][x] += 1
ans = 0
for i in range(n):
ans += dp[i][a*(... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.