node_ids listlengths 4 1.4k | edge_index listlengths 1 2.22k | text listlengths 4 1.4k | source stringlengths 14 427k |
|---|---|---|---|
[
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,
2,
4,
13,
13,
13,
0,
13,
13,
41,
28,
13,
4,
13,
17,
2,
13,
17,
4,
2,
39,
17,
2,
2,
17,
2,
17,
13,
17,
0,
13,
... | [
[
4,
3
],
[
3,
12
],
[
140,
14
],
[
140,
16
],
[
20,
19
],
[
19,
29
],
[
138,
30
],
[
134,
32
],
[
37,
36
],
[
141,
41
],
[
141,
52
],
[
143,
55
],
[
65,
58
],
... | [
"N,A = (int(T) for T in input().split())\nX = [int(T)-A for T in input().split()]\nDP = [[0]*(2*(50*N)+1) for TI in range(0,N+1)]\nDP[0][50*N] = 1\nfor TI in range(0,N):\n for TS in range(0,2*50*N+1):\n if DP[TI][TS]!=0:\n DP[TI+1][TS] += DP[TI][TS]\n DP[TI+1][TS+X[TI]] += DP[TI][TS]... | N,A = (int(T) for T in input().split())
X = [int(T)-A for T in input().split()]
DP = [[0]*(2*(50*N)+1) for TI in range(0,N+1)]
DP[0][50*N] = 1
for TI in range(0,N):
for TS in range(0,2*50*N+1):
if DP[TI][TS]!=0:
DP[TI+1][TS] += DP[TI][TS]
DP[TI+1][TS+X[TI]] += DP[TI][TS]
print(DP[N][... |
[
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,
0,
13,
17,
42,
2,
2,
13,
13,
2,
18,
13,
13,
13,
0,
13,
17,
0,
13,
13,
42,
2,
2,
13,
13,
2,
18,
13,
13,
... | [
[
241,
2
],
[
241,
11
],
[
223,
13
],
[
224,
26
],
[
226,
29
],
[
227,
34
],
[
233,
34
],
[
230,
35
],
[
224,
38
],
[
227,
39
],
[
233,
39
],
[
242,
40
],
[
232,
42... | [
"n, a = map(int,input().split())\nX = list(map(int,input().split()))\n\nX.sort()\nii = 0\nwhile ii < n and X[ii] < a:\n ii += 1\njj = ii\nwhile jj < n and X[jj] == a:\n jj += 1\n\naa = jj-ii\nA = [[a-i for i in X[:ii]], [j-a for j in X[jj:]]]\n\n# print(A)\n\nmm = min(sum(A[0]), sum(A[1]))\n\nAA = [[0] * (mm ... | n, a = map(int,input().split())
X = list(map(int,input().split()))
X.sort()
ii = 0
while ii < n and X[ii] < a:
ii += 1
jj = ii
while jj < n and X[jj] == a:
jj += 1
aa = jj-ii
A = [[a-i for i in X[:ii]], [j-a for j in X[jj:]]]
# print(A)
mm = min(sum(A[0]), sum(A[1]))
AA = [[0] * (mm + 1) for i in range(2)]... |
[
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,
4,
13,
2,
13,
39,
13,
41,
28,
13,
4,
13,
2,
13,
17,
4,
13,
0,
13,
13,
12,
13,
14,
... | [
[
4,
3
],
[
3,
12
],
[
215,
14
],
[
215,
16
],
[
20,
19
],
[
19,
28
],
[
203,
30
],
[
218,
33
],
[
204,
37
],
[
43,
42
],
[
216,
46
],
[
212,
51
],
[
213,
60
],
... | [
"N,A = [int(x) for x in input().split()]\nx = [int(x) for x in input().split()]\nX = max(x+[A])\n#%%\ndp = [[[-1]*(N*X+1) for _ in range(N+1)] for _ in range(N+1)]\n\ndef rep(j,k,s):\n if(dp[j][k][s]==-1):\n if(s==j==k==0):\n dp[j][k][s] = 1\n elif(j>=1 and s<x[j-1]):\n dp[j][... | N,A = [int(x) for x in input().split()]
x = [int(x) for x in input().split()]
X = max(x+[A])
#%%
dp = [[[-1]*(N*X+1) for _ in range(N+1)] for _ in range(N+1)]
def rep(j,k,s):
if(dp[j][k][s]==-1):
if(s==j==k==0):
dp[j][k][s] = 1
elif(j>=1 and s<x[j-1]):
dp[j][k][s] = rep(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,
0,
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,
28,
13,
4,
13,
13,
... | [
[
154,
2
],
[
154,
11
],
[
142,
13
],
[
136,
25
],
[
143,
28
],
[
32,
31
],
[
137,
35
],
[
139,
40
],
[
50,
43
],
[
140,
46
],
[
53,
52
],
[
137,
55
],
[
145,
57
... | [
"n,a=map(int,input().split())\nlst=list(map(int,input().split()))\n\nz=len(lst)\ndp=[[[0]*2501 for i in range(51)] for j in range(z+1)]\ndp[0][0][0]=1\n\nfor i in range(z):\n x=lst[i]\n for j in range(z):\n for k in range(2451):\n dp[i+1][j][k]+=dp[i][j][k]\n dp[i+1][j+1][k+x]+=dp[i][j][k]\n\nans=0\n... | n,a=map(int,input().split())
lst=list(map(int,input().split()))
z=len(lst)
dp=[[[0]*2501 for i in range(51)] for j in range(z+1)]
dp[0][0][0]=1
for i in range(z):
x=lst[i]
for j in range(z):
for k in range(2451):
dp[i+1][j][k]+=dp[i][j][k]
dp[i+1][j+1][k+x]+=dp[i][j][k]
ans=0
for i in range(z+1)... |
[
7,
15,
13,
12,
13,
41,
28,
13,
4,
13,
2,
13,
17,
4,
13,
0,
13,
13,
28,
13,
4,
13,
13,
0,
18,
18,
18,
13,
13,
17,
17,
17,
28,
13,
4,
13,
13,
28,
13,
4,
13,
13,
28,
13,
4,
13,
17,
14,
40,
2,
13,
18,
13,
13,
17,... | [
[
8,
7
],
[
136,
11
],
[
17,
16
],
[
20,
19
],
[
136,
22
],
[
31,
24
],
[
16,
27
],
[
19,
28
],
[
34,
33
],
[
136,
36
],
[
39,
38
],
[
136,
41
],
[
44,
43
],
[
... | [
"#!/usr/bin/env python3\nimport sys\n\ndef solve(N: int, A: int, x: \"List[int]\"):\n ## dp[i][j][k] = i番目までのカードからjマイ選んで合計kにする選び方の総数\n dp = [[[0]*2501 for _ in range(N+1)] for _ in range(N+1)]\n\n for i in range(N):\n dp[i][0][0] = 1\n\n for i in range(N):\n for j in range(N):\n ... | #!/usr/bin/env python3
import sys
def solve(N: int, A: int, x: "List[int]"):
## dp[i][j][k] = i番目までのカードからjマイ選んで合計kにする選び方の総数
dp = [[[0]*2501 for _ in range(N+1)] for _ in range(N+1)]
for i in range(N):
dp[i][0][0] = 1
for i in range(N):
for j in range(N):
for k in range(250... |
[
7,
15,
13,
15,
12,
13,
41,
28,
13,
4,
13,
13,
4,
2,
39,
13,
13,
12,
13,
23,
13,
23,
13,
23,
13,
41,
28,
13,
4,
13,
13,
4,
13,
12,
13,
23,
13,
23,
13,
23,
13,
23,
13,
41,
28,
13,
4,
13,
13,
4,
13,
12,
13,
23,
... | [
[
9,
8
],
[
20,
20
],
[
22,
22
],
[
24,
24
],
[
28,
27
],
[
36,
36
],
[
38,
38
],
[
40,
40
],
[
42,
42
],
[
46,
45
],
[
54,
54
],
[
56,
56
],
[
58,
58
],
[
... | [
"# -*- coding: utf-8 -*-\n\nimport sys\nfrom collections import defaultdict\n\ndef input(): return sys.stdin.readline().strip()\ndef list2d(a, b, c): return [[c] * b for i in range(a)]\ndef list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]\ndef list4d(a, b, c, d, e): return [[[[e] * d for j... | # -*- coding: utf-8 -*-
import sys
from collections import defaultdict
def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)]... |
[
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,
18,
13,
17,
17,
17,
17,
28,
13,
4,
13,
13,
... | [
[
151,
2
],
[
151,
11
],
[
154,
13
],
[
163,
25
],
[
155,
28
],
[
32,
31
],
[
152,
35
],
[
166,
40
],
[
50,
43
],
[
167,
46
],
[
53,
52
],
[
152,
55
],
[
58,
57
]... | [
"N, A = map(int, input().split())\nX = list(map(int, input().split()))\nsum_X = sum(X)\ndp = [[[0]*(sum_X+1) for _ in range(N+1)] for _ 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(sum_X):\n if dp[i][j][k] == 0: continue\n # not used\n dp[i+1][j][k] +=... | N, A = map(int, input().split())
X = list(map(int, input().split()))
sum_X = sum(X)
dp = [[[0]*(sum_X+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(sum_X):
if dp[i][j][k] == 0: continue
# not used
dp[i+1][j][k] += dp[i][j][k]
... |
[
7,
15,
13,
15,
13,
15,
13,
15,
13,
15,
13,
15,
13,
15,
13,
15,
13,
15,
13,
15,
13,
12,
13,
12,
13,
12,
13,
12,
13,
12,
13,
12,
13,
12,
13,
0,
13,
4,
13,
13,
0,
13,
2,
4,
18,
13,
13,
4,
13,
13,
0,
13,
4,
18,
4... | [
[
168,
36
],
[
148,
38
],
[
168,
39
],
[
156,
41
],
[
172,
48
],
[
151,
49
],
[
174,
51
],
[
169,
60
],
[
169,
65
],
[
77,
70
],
[
175,
72
],
[
169,
75
],
[
151,
76... | [
"import numpy as np\nimport scipy.sparse as sps\nimport scipy.misc as spm\nimport collections as col\nimport functools as func\nimport itertools as ite\nimport fractions as frac\nimport math as ma\nimport copy as cp\nimport sys\ndef sinput(): return sys.stdin.readline()\ndef iinput(): return int(sinput())\ndef imap... | import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
import copy as cp
import sys
def sinput(): return sys.stdin.readline()
def iinput(): return int(sinput())
def imap(): return map(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,
41,
28,
13,
4,
13,
2,
13,
17,
4,
13,
0,
13,
13,
0,
18,
18,
13,
17,
17,
17,
0,
13,
13,
28,
13,
4,
13,
13,
0,
13,
39,
28,
... | [
[
171,
2
],
[
171,
11
],
[
153,
13
],
[
27,
26
],
[
148,
30
],
[
162,
35
],
[
43,
38
],
[
163,
40
],
[
168,
45
],
[
163,
46
],
[
49,
48
],
[
148,
51
],
[
174,
53
... | [
"#解説解答\nn,a = map(int,input().split())\nx = list(map(int,input().split()))\ndp0 = [[0 for s in range(n*a+1)] for k in range(n+1)]\ndp0[0][0] = 1\ndp = dp0\nfor j in range(n):\n now = []\n for k in range(n+1):\n add = []\n for s in range(n*a+1):\n t = s-x[j]\n if t >= 0 and k >= 1:\n add.app... | #解説解答
n,a = map(int,input().split())
x = list(map(int,input().split()))
dp0 = [[0 for s in range(n*a+1)] for k in range(n+1)]
dp0[0][0] = 1
dp = dp0
for j in range(n):
now = []
for k in range(n+1):
add = []
for s in range(n*a+1):
t = s-x[j]
if t >= 0 and k >= 1:
add.append( dp[k][s] + 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,
41,
28,
13,
4,
13,
13,
4,
13,
0,
13,
13,
0,
18,
18,
18,
13,
17,
17,
17,
17,
0,
18,
18,
18,
13,
17,
17,
18,
13,
17,
17,
2... | [
[
175,
2
],
[
175,
11
],
[
169,
13
],
[
27,
26
],
[
167,
29
],
[
172,
33
],
[
43,
36
],
[
173,
39
],
[
54,
45
],
[
173,
48
],
[
170,
52
],
[
57,
56
],
[
167,
60
]... | [
"N, A=map(int, input().split())\nx=list(map(int, input().split()))\n\ndp=[[[0]*2501 for j in range(N+1)] for i in range(N)]\n\ndp[0][0][0]=1\ndp[0][1][x[0]]=1\nfor i in range(1, N):\n dp[i][0][0]=1\n for j in range(1, i+2):\n for k in range(2501):\n if k-x[i]>=0:\n dp[i][j][k]=dp[i-1][j-1][k-x[i]]+... | N, A=map(int, input().split())
x=list(map(int, input().split()))
dp=[[[0]*2501 for j in range(N+1)] for i in range(N)]
dp[0][0][0]=1
dp[0][1][x[0]]=1
for i in range(1, N):
dp[i][0][0]=1
for j in range(1, i+2):
for k in range(2501):
if k-x[i]>=0:
dp[i][j][k]=dp[i-1][j-1][k-x[i]]+dp[i-1][j][k]
... |
[
7,
12,
13,
12,
13,
14,
40,
2,
18,
18,
18,
13,
13,
13,
13,
17,
29,
18,
18,
18,
13,
13,
13,
13,
14,
40,
2,
13,
13,
14,
2,
2,
13,
17,
2,
13,
2,
13,
13,
0,
18,
18,
18,
13,
13,
13,
13,
17,
29,
18,
18,
18,
13,
13,
... | [
[
117,
12
],
[
119,
13
],
[
121,
14
],
[
117,
21
],
[
119,
22
],
[
121,
23
],
[
117,
27
],
[
119,
32
],
[
121,
35
],
[
119,
38
],
[
47,
40
],
[
117,
44
],
[
119,
45... | [
"def solve():\n def recur(i, n, total):\n # print(\"i, n, total\", i, n, total)\n\n if not TABLE[i][n][total] == -1:\n return TABLE[i][n][total]\n\n if not i < N:\n if n > 0 and total == A * n:\n TABLE[i][n][total] = 1\n return TABLE[i][n][... | def solve():
def recur(i, n, total):
# print("i, n, total", i, n, total)
if not TABLE[i][n][total] == -1:
return TABLE[i][n][total]
if not i < N:
if n > 0 and total == A * n:
TABLE[i][n][total] = 1
return TABLE[i][n][total]
... |
[
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,
41,
28,
13,
4,
13,
2,
13,
17,
4,
13,
0,
13,
13,
0,
18,
18,
18,
13,
17,
17,
17,
17,
28,
13,
... | [
[
160,
2
],
[
160,
11
],
[
145,
13
],
[
157,
25
],
[
146,
30
],
[
155,
31
],
[
35,
34
],
[
161,
38
],
[
148,
43
],
[
53,
46
],
[
149,
49
],
[
56,
55
],
[
161,
58
... | [
"# 配列を大きめにとって配った方がすっきりかけるのかも\n\nn, a = map(int, input().split())\nx = list(map(int, input().split()))\nX = max(max(x), a)\ndp = [[[0]*(n*X+1) for _ in range(n+1)] for i in range(n+1)]\n\n#if j == 0 and k == 0 and s == 0:\ndp[0][0][0] = 1\nfor j in range(n):\n for k in range(n):\n for s in range(n*X):\n\n ... | # 配列を大きめにとって配った方がすっきりかけるのかも
n, a = map(int, input().split())
x = list(map(int, input().split()))
X = max(max(x), a)
dp = [[[0]*(n*X+1) for _ in range(n+1)] for i in range(n+1)]
#if j == 0 and k == 0 and s == 0:
dp[0][0][0] = 1
for j in range(n):
for k in range(n):
for s in range(n*X):
if 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,
41,
28,
13,
4,
13,
13,
4,
2,
39,
17,
17,
0,
13,
13,
0,
18,
18,
13,
17,
2,
18,
13,
... | [
[
136,
2
],
[
136,
11
],
[
127,
13
],
[
26,
25
],
[
137,
28
],
[
33,
30
],
[
128,
31
],
[
25,
32
],
[
131,
33
],
[
37,
36
],
[
137,
39
],
[
133,
46
],
[
58,
49
],... | [
"n,a=map(int,input().split())\nx=list(map(int,input().split()))\nfor i in range(n):\n x[i]-=a\n# dp[i][j] = i番目までで(j-2500)を何個作れるか\ndp=[[0]*5001 for i in range(n)]\ndp[0][x[0]+2500]=1\nfor i in range(1,n):\n dp[i][x[i]+2500]=1\n for j in range(5000):\n for k in range(2):\n if 0<=j-k*x[i]<=... | n,a=map(int,input().split())
x=list(map(int,input().split()))
for i in range(n):
x[i]-=a
# dp[i][j] = i番目までで(j-2500)を何個作れるか
dp=[[0]*5001 for i in range(n)]
dp[0][x[0]+2500]=1
for i in range(1,n):
dp[i][x[i]+2500]=1
for j in range(5000):
for k in range(2):
if 0<=j-k*x[i]<=5000:
... |
[
7,
41,
28,
13,
4,
13,
17,
4,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
13,
0,
39,
13,
13,
13,
31,
13,
0,
13,
13,
0,
18,
18,
13,
17,
17,
17,
28,
13,
4,
13,
13,
28,
13,
18,
4,
13,
13,
39,
17,
28,
13,
18,
4,
13,
2,
... | [
[
4,
3
],
[
77,
17
],
[
23,
20
],
[
23,
24
],
[
80,
27
],
[
35,
30
],
[
81,
32
],
[
38,
37
],
[
78,
39
],
[
43,
42
],
[
78,
45
],
[
51,
50
],
[
78,
53
],
[
... | [
"R=range;(N,A),(*X,)=(map(int,input().split())for _ in R(2));C=[51*N*[0]for _ in R(N+1)];C[0][0]=1\nfor I in R(N):\n\tfor J in R(N)[::-1]:\n\t\tfor K in R(50*N)[::-1]:\n\t\t\tif C[J][K]:C[J+1][K+X[I]]+=C[J][K]\nprint(sum(C[I][I*A]for I in R(1,N+1)))",
"map(int,input().split())for _ in R(2)",
"for _ in R(2)",
... | R=range;(N,A),(*X,)=(map(int,input().split())for _ in R(2));C=[51*N*[0]for _ in R(N+1)];C[0][0]=1
for I in R(N):
for J in R(N)[::-1]:
for K in R(50*N)[::-1]:
if C[J][K]:C[J+1][K+X[I]]+=C[J][K]
print(sum(C[I][I*A]for I in R(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,
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,
2,
17,
13,
17,
... | [
[
152,
2
],
[
152,
11
],
[
146,
13
],
[
26,
25
],
[
150,
28
],
[
33,
30
],
[
147,
31
],
[
25,
32
],
[
153,
33
],
[
37,
36
],
[
150,
40
],
[
140,
45
],
[
55,
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(100 * n + 1)] for j in range(n + 1)]\ndp[0][50 * n] = 1\nfor i in range(n):\n for j in range(100 * n + 1):\n j2 = j - 50 * n\n num = x[i]\n if -50 * n <= j2 - nu... | 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(100 * n + 1)] for j in range(n + 1)]
dp[0][50 * n] = 1
for i in range(n):
for j in range(100 * n + 1):
j2 = j - 50 * n
num = x[i]
if -50 * n <= j2 - num <= 50 * n:
... |
[
7,
15,
13,
15,
13,
12,
13,
12,
13,
12,
13,
12,
13,
12,
13,
12,
13,
12,
13,
0,
13,
4,
13,
13,
0,
13,
2,
4,
18,
13,
13,
4,
13,
13,
0,
13,
2,
2,
17,
17,
17,
0,
13,
4,
18,
4,
18,
13,
13,
39,
2,
13,
17,
2,
2,
17... | [
[
158,
20
],
[
144,
22
],
[
158,
23
],
[
152,
25
],
[
171,
32
],
[
147,
33
],
[
164,
35
],
[
173,
42
],
[
159,
51
],
[
165,
56
],
[
66,
61
],
[
174,
63
],
[
165,
65... | [
"import sys\nimport numpy as np\ndef sinput(): return sys.stdin.readline()\ndef iinput(): return int(sinput())\ndef imap(): return map(int, sinput().split())\ndef fmap(): return map(float, sinput().split())\ndef iarr(): return list(imap())\ndef farr(): return list(fmap())\ndef sarr(): return sinput().split()\n\nn, ... | import sys
import numpy as np
def sinput(): return sys.stdin.readline()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(): return list(imap())
def farr(): return list(fmap())
def sarr(): return sinput().split()
n, a = imap()
x = ... |
[
7,
15,
13,
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,
4,
18,
13,
13,
41,
28,
13,
4,
13,
2,
13,
17,
4,
2,
2,
39,
17,
17,
13,
0,
13,
13,
0,
1... | [
[
172,
4
],
[
172,
17
],
[
172,
18
],
[
24,
23
],
[
167,
26
],
[
31,
28
],
[
23,
30
],
[
173,
31
],
[
39,
38
],
[
167,
42
],
[
167,
50
],
[
53,
52
],
[
62,
55
],
... | [
"import sys\n\nn, a, *x = map(int, sys.stdin.read().split())\n\ndef main():\n for i in range(n):\n x[i] -= a\n x.sort()\n\n res = [[0] * 99*n for _ in range(n+1)]\n # res[i][49*n]を中心とする。\n res[0][49*n] = 1\n for i in range(n):\n for j in range(99*n):\n res[i+1][j] += res[i... | import sys
n, a, *x = map(int, sys.stdin.read().split())
def main():
for i in range(n):
x[i] -= a
x.sort()
res = [[0] * 99*n for _ in range(n+1)]
# res[i][49*n]を中心とする。
res[0][49*n] = 1
for i in range(n):
for j in range(99*n):
res[i+1][j] += res[i][j]
cu... |
[
7,
12,
13,
0,
13,
2,
13,
13,
14,
2,
2,
13,
2,
13,
13,
17,
29,
2,
2,
13,
13,
17,
29,
2,
13,
13,
23,
13,
23,
13,
17,
17,
17,
17,
17,
12,
13,
29,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
12,
13,
0,
13,
4,
13,
13,
0... | [
[
5,
4
],
[
27,
6
],
[
29,
7
],
[
4,
11
],
[
27,
13
],
[
29,
14
],
[
27,
19
],
[
29,
20
],
[
27,
24
],
[
29,
25
],
[
27,
27
],
[
29,
29
],
[
52,
51
],
[
123... | [
"#\n# Written by NoKnowledgeGG @YlePhan\n# ('ω')\n#\n#import math\n#mod = 10**9+7\n#import itertools\n#import fractions\n#import numpy as np\n#mod = 10**4 + 7\ndef kiri(n,m):\n r_ = n / m\n if (r_ - (n // m)) > 0:\n return (n//m) + 1\n else:\n return (n//m)\n\n\"\"\" n! mod m 階乗\nmod = 1e9 + 7\nN = 1000000... | #
# Written by NoKnowledgeGG @YlePhan
# ('ω')
#
#import math
#mod = 10**9+7
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
def kiri(n,m):
r_ = n / m
if (r_ - (n // m)) > 0:
return (n//m) + 1
else:
return (n//m)
""" n! mod m 階乗
mod = 1e9 + 7
N = 10000000
fac = [0] * N
def ini():
... |
[
7,
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,
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,
... | [
[
163,
2
],
[
163,
11
],
[
178,
13
],
[
175,
28
],
[
33,
32
],
[
164,
36
],
[
166,
41
],
[
51,
44
],
[
167,
47
],
[
54,
53
],
[
164,
58
],
[
62,
61
],
[
164,
65
]... | [
"n, a = map(int, input().split())\nx = [0] + list(map(int, input().split()))\nnx = 2501\n\n# DP: x1からxjまでの間でk枚を選んで合計がsになる組み合わせの数\ndp = [ [ [0 for s in range(nx+1)] for k in range(n+1)] for j in range(n+1)]\ndp[0][0][0] = 1\n\nfor j in range(1, n+1):\n for k in range(n+1):\n for s in range(nx+1):\n ... | n, a = map(int, input().split())
x = [0] + list(map(int, input().split()))
nx = 2501
# DP: x1からxjまでの間でk枚を選んで合計がsになる組み合わせの数
dp = [ [ [0 for s in range(nx+1)] for k in range(n+1)] for j 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(nx+1):
if x[j] > 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,
4,
13,
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,
... | [
[
191,
2
],
[
191,
11
],
[
176,
13
],
[
194,
25
],
[
177,
30
],
[
192,
31
],
[
35,
34
],
[
183,
38
],
[
179,
43
],
[
53,
46
],
[
180,
49
],
[
56,
55
],
[
183,
60
... | [
"n, a = map(int, input().split())\nx = list(map(int, input().split()))\n\n# 初期化\nmax_num = max(max(x), a)\ndp = [[[0 for _ in range(max_num * n + 1)]\n for _ in range(n + 1)] for _ in range(n + 1)]\ndp[0][0][0] = 1\n\nfor j in range(1, n+1):\n for k in range(j+1):\n for s in range(max_num * k + 1):\... | n, a = map(int, input().split())
x = list(map(int, input().split()))
# 初期化
max_num = max(max(x), a)
dp = [[[0 for _ in range(max_num * n + 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(j+1):
for s in range(max_num * k + 1):
if 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,
2,
39,
17,
17,
0,
13,
2,
39,
17,
17,
0,
13,
39,
0,
13,
39,
0,
13,
17,
28,
13,
4,
13,
13,
0,
13,
2,
18,
13,
13,
... | [
[
177,
2
],
[
177,
11
],
[
189,
13
],
[
204,
25
],
[
183,
31
],
[
192,
37
],
[
210,
40
],
[
186,
43
],
[
47,
46
],
[
175,
49
],
[
213,
51
],
[
190,
54
],
[
46,
55
... | [
"n,a = map(int,input().split())\nx = list(map(int,input().split()))\n\ndpp = [0]*3000\ndpm = [0]*3000\n\np = []\nm = []\nn0 = 0\n\nfor i in range(n):\n x1 = x[i] - a\n if x1 == 0:\n n0 += 1\n elif x1 > 0:\n p.append(x1)\n else:\n m.append(-x1)\n\nfor i in p:\n for j in range(2600... | n,a = map(int,input().split())
x = list(map(int,input().split()))
dpp = [0]*3000
dpm = [0]*3000
p = []
m = []
n0 = 0
for i in range(n):
x1 = x[i] - a
if x1 == 0:
n0 += 1
elif x1 > 0:
p.append(x1)
else:
m.append(-x1)
for i in p:
for j in range(2600,0,-1):
if dpp[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,
4,
13,
13,
13,
41,
28,
13,
4,
13,
2,
13,
17,
4,
13,
0,
13,
13,
28,
13,
4,
13,
2,
13,
17,
28,
13,
4,
13,
... | [
[
207,
2
],
[
207,
11
],
[
213,
13
],
[
210,
25
],
[
214,
30
],
[
205,
31
],
[
35,
34
],
[
208,
38
],
[
219,
43
],
[
47,
46
],
[
208,
50
],
[
54,
53
],
[
208,
57
... | [
"n, a = map(int, input().split())\nx = list(map(int, input().split()))\nX = max(max(x), a)\n#dp = [[[0]*(n*X+1) for _ in range(X+1)] for i in range(n+1)]\ndp = [[[0]*(n*X+1) for _ in range(n+1)] for i in range(n+1)]\n\nfor j in range(n+1):\n for k in range(n+1):\n for s in range(n*X+1):\n if j ... | n, a = map(int, input().split())
x = list(map(int, input().split()))
X = max(max(x), a)
#dp = [[[0]*(n*X+1) for _ in range(X+1)] for i in range(n+1)]
dp = [[[0]*(n*X+1) for _ in range(n+1)] for i in range(n+1)]
for j in range(n+1):
for k in range(n+1):
for s in range(n*X+1):
if j == 0 and k == ... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
39,
28,
13,
4,
13,
17,
4,
18,
13,
13,
2,
39,
17,
17,
0,
18,
18,
13,
17,
17,
17,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
28,
13,
13,
0,
13,
39,
28,
13,
4,... | [
[
171,
2
],
[
171,
11
],
[
162,
13
],
[
17,
16
],
[
163,
22
],
[
34,
29
],
[
163,
31
],
[
156,
36
],
[
49,
48
],
[
157,
48
],
[
177,
51
],
[
55,
54
],
[
174,
59
]... | [
"\nN,A = map(int,input().split())\n\nlis = []\n\nfor i in range(51):\n lis.append([0] * 2501)\n\nlis[0][0] = 1\n\nX = list(map(int,input().split()))\n\n\nfor x in X:\n\n nlis = []\n for k in range(51):\n new = lis[k].copy()\n nlis.append(new)\n\n for i in range(51):\n\n for j in ran... |
N,A = map(int,input().split())
lis = []
for i in range(51):
lis.append([0] * 2501)
lis[0][0] = 1
X = list(map(int,input().split()))
for x in X:
nlis = []
for k in range(51):
new = lis[k].copy()
nlis.append(new)
for i in range(51):
for j in range(2501):
if 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,
17,
41,
28,
13,
13,
4,
2,
13,
13,
0,
13,
13,
0,
13,
4,
13,
4,
13,
13,
13,
41,
28,
13,
4,
13,
2,
13,
17,
4,
13,
0,
13,
... | [
[
161,
2
],
[
161,
11
],
[
158,
13
],
[
28,
27
],
[
159,
27
],
[
27,
31
],
[
162,
32
],
[
149,
34
],
[
155,
37
],
[
159,
42
],
[
162,
43
],
[
47,
46
],
[
147,
50
... | [
"n, a = map(int, input().split())\nx = list(map(int, input().split()))\n\n'''\n辞書がめっちゃ書きやすい!ただし、3次元配列でdpやりたい時むずいかも。\nx = [i-a for i in x]\ndp = {0:1}\nprint(dp)\nfor item in x:\n print('--------for item:{}-----------'.format(item))\n for key, value in list(dp.items()):\n print('key:{},value:{}'.format(... | n, a = map(int, input().split())
x = list(map(int, input().split()))
'''
辞書がめっちゃ書きやすい!ただし、3次元配列でdpやりたい時むずいかも。
x = [i-a for i in x]
dp = {0:1}
print(dp)
for item in x:
print('--------for item:{}-----------'.format(item))
for key, value in list(dp.items()):
print('key:{},value:{}'.format(key,value))
... |
[
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,
0,
13,
4,
13,
13,
0,
13,
4,
13,
13,
41,
28,
13,
4,
13,
17,
4,
13,
0,
13,
... | [
[
192,
4
],
[
204,
11
],
[
193,
18
],
[
204,
20
],
[
189,
22
],
[
193,
34
],
[
210,
37
],
[
190,
40
],
[
213,
42
],
[
190,
45
],
[
49,
48
],
[
201,
55
],
[
65,
58
... | [
"import sys\ninput=sys.stdin.readline\nn,a=map(int,input().split())\nx=[0]+list(map(int,input().split()))\nsu=sum(x)\nmaxi=max(x)\ndp=[[[0 for k in range(maxi*n+1)] for j in range(51)] for i in range(51)]\ndp[0][0][0]=1\nfor i in range(1,n+1):\n for j in range(i+1):\n for k in range(maxi*j+1):\n ... | import sys
input=sys.stdin.readline
n,a=map(int,input().split())
x=[0]+list(map(int,input().split()))
su=sum(x)
maxi=max(x)
dp=[[[0 for k in range(maxi*n+1)] for j in range(51)] for i in range(51)]
dp[0][0][0]=1
for i in range(1,n+1):
for j in range(i+1):
for k in range(maxi*j+1):
if k<x[i]:
... |
[
7,
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,
21,
22,
17,
17,
28,
13,
13,
41,
28,
13,
13,
4,
39,
13,
18,
13,
13,
0,
13,
13,
28,
13,
13,
14,
... | [
[
98,
2
],
[
98,
11
],
[
15,
14
],
[
14,
24
],
[
99,
25
],
[
104,
27
],
[
101,
30
],
[
37,
36
],
[
105,
36
],
[
41,
40
],
[
102,
40
],
[
102,
46
],
[
40,
47
],
... | [
"n,a=map(int,input().split())\nnums=[int(i)-a for i in input().split()]\nd={0:1}\nfor i in nums:\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",
"map(int,input().split())",
"... | n,a=map(int,input().split())
nums=[int(i)-a for i in input().split()]
d={0:1}
for i in nums:
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,
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,
41,
28,
13,
4,
13,
2,
13,
17,
4,
2,
2,
2,
39,
17,
13,
17,
17,
0,
13,
13,
0,
1... | [
[
148,
2
],
[
148,
11
],
[
151,
13
],
[
27,
26
],
[
152,
26
],
[
26,
30
],
[
143,
31
],
[
139,
33
],
[
38,
37
],
[
149,
41
],
[
149,
49
],
[
145,
53
],
[
63,
56
]... | [
"n , a = map(int, input().split())\nx = list(map(int,input().split()))\n\nx=[i-a for i in x]\ndp=[[0]*n*50*2 for i in range(n+1)]\n\ndp[0][n*50]=1\n\nfor i in range(n):\n for j in range(n*50*2):\n t=j-x[i]\n if 0<=t<n*50*2:\n dp[i+1][j]=dp[i][j]+dp[i][t]\n else:\n dp[i+... | n , a = map(int, input().split())
x = list(map(int,input().split()))
x=[i-a for i in x]
dp=[[0]*n*50*2 for i in range(n+1)]
dp[0][n*50]=1
for i in range(n):
for j in range(n*50*2):
t=j-x[i]
if 0<=t<n*50*2:
dp[i+1][j]=dp[i][j]+dp[i][t]
else:
dp[i+1][j]=dp[i][j]
prin... |
[
7,
12,
13,
0,
13,
4,
13,
4,
13,
13,
13,
41,
28,
13,
4,
13,
2,
13,
17,
4,
13,
0,
13,
13,
28,
13,
4,
13,
2,
13,
17,
28,
13,
4,
13,
2,
13,
17,
28,
13,
4,
13,
2,
2,
13,
13,
17,
14,
2,
2,
2,
13,
17,
2,
13,
17,
... | [
[
5,
4
],
[
188,
9
],
[
186,
10
],
[
14,
13
],
[
184,
17
],
[
23,
22
],
[
26,
25
],
[
184,
29
],
[
33,
32
],
[
184,
36
],
[
40,
39
],
[
184,
44
],
[
4,
45
],
[
... | [
"def solve(n, a, lst):\n m = max(max(lst), a)\n ans = [[[0]*(n*m+1) for i in range(n+1)] for j in range(n+1)]\n #ans[i][j][k] : lst[:i]までの中からj枚選んで合計kにする選び方\n for i in range(n+1):\n for j in range(n+1):\n for k in range(n*m+1):\n if i == 0 and j == 0 and k == 0:\n ans[i][j][k] = 1\n ... | def solve(n, a, lst):
m = max(max(lst), a)
ans = [[[0]*(n*m+1) for i in range(n+1)] for j in range(n+1)]
#ans[i][j][k] : lst[:i]までの中からj枚選んで合計kにする選び方
for i in range(n+1):
for j in range(n+1):
for k in range(n*m+1):
if i == 0 and j == 0 and k == 0:
ans[i][j][k] = 1
elif i >= 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,
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,
13,
0,... | [
[
5,
4
],
[
5,
13
],
[
16,
15
],
[
29,
28
],
[
15,
28
],
[
28,
32
],
[
13,
33
],
[
36,
35
],
[
39,
38
],
[
45,
44
],
[
35,
44
],
[
15,
44
],
[
38,
53
],
[
6... | [
"#!/usr/bin python3\n# -*- coding: utf-8 -*-\n\ndef main():\n N, A = map(int, input().split())\n X = list(map(int, input().split()))\n X = [x-A for x in X]\n\n ret={0: 1}\n for xi in X:\n for y, cnt in list(ret.items()):\n ret[xi+y] = ret.get(xi+y, 0) + cnt\n print(ret[0]-1)\n\ni... | #!/usr/bin python3
# -*- coding: utf-8 -*-
def main():
N, A = map(int, input().split())
X = list(map(int, input().split()))
X = [x-A for x in X]
ret={0: 1}
for xi in X:
for y, cnt in list(ret.items()):
ret[xi+y] = ret.get(xi+y, 0) + cnt
print(ret[0]-1)
if __name__ == '__ma... |
[
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,
13,
4,
2,
13,
13,
0,
13,
13,
41,
28,
13,
4,
13,
2,
13,
17,
4,
2,
39,
17,
17,
0,
13,
13,
0,
18,
18,
13,
17,
... | [
[
148,
2
],
[
148,
11
],
[
139,
13
],
[
27,
26
],
[
140,
26
],
[
26,
30
],
[
149,
31
],
[
151,
33
],
[
38,
37
],
[
137,
41
],
[
142,
49
],
[
61,
52
],
[
143,
54
]... | [
"N,A=map(int,input().split())\nx = list(map(int,input().split()))\ny = [val-A for val in x]\n\n# dp[i][j] : i枚目まで見て合計がj-2500のもの\ndp = [[0]*5001 for _ in range(N+1)]\ndp[0][y[0]+2500] = 1\ndp[0][2500] += 1\nfor i in range(N-1):\n new = y[i+1]\n for j in range(5001):\n dp[i+1][j] += dp[i][j]\n if ... | N,A=map(int,input().split())
x = list(map(int,input().split()))
y = [val-A for val in x]
# dp[i][j] : i枚目まで見て合計がj-2500のもの
dp = [[0]*5001 for _ in range(N+1)]
dp[0][y[0]+2500] = 1
dp[0][2500] += 1
for i in range(N-1):
new = y[i+1]
for j in range(5001):
dp[i+1][j] += dp[i][j]
if 0 <= j+new <= 500... |
[
7,
15,
13,
4,
18,
13,
13,
2,
17,
17,
0,
13,
4,
13,
17,
0,
13,
2,
2,
17,
17,
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,
2,
2,
17,
17,
17,
41,
28,
... | [
[
180,
11
],
[
183,
16
],
[
26,
25
],
[
26,
34
],
[
37,
36
],
[
49,
48
],
[
57,
56
],
[
25,
60
],
[
66,
65
],
[
75,
68
],
[
65,
71
],
[
78,
77
],
[
25,
82
],
[
... | [
"import sys\n\nsys.setrecursionlimit(10 ** 7)\nf_inf = float('inf')\nmod = 10 ** 9 + 7\n\n\ndef resolve():\n n, a = map(int, input().split())\n X = list(map(int, input().split()))\n MAX = 50 * 50 + 1\n\n dp = [[[0] * MAX for _ in range(n + 1)] for _ in range(n + 1)]\n dp[0][0][0] = 1\n for i in ra... | import sys
sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7
def resolve():
n, a = map(int, input().split())
X = list(map(int, input().split()))
MAX = 50 * 50 + 1
dp = [[[0] * MAX for _ in range(n + 1)] for _ in range(n + 1)]
dp[0][0][0] = 1
for i in range(1, n + 1):
... |
[
7,
15,
13,
15,
15,
15,
13,
4,
18,
13,
13,
2,
17,
17,
12,
13,
41,
28,
13,
4,
18,
4,
13,
13,
17,
4,
4,
13,
13,
29,
13,
12,
13,
41,
28,
13,
4,
13,
13,
4,
4,
13,
4,
13,
29,
13,
23,
13,
12,
13,
29,
4,
13,
13,
4,
... | [
[
19,
18
],
[
18,
28
],
[
36,
35
],
[
47,
38
],
[
47,
47
],
[
72,
71
],
[
237,
77
],
[
214,
79
],
[
237,
80
],
[
225,
82
],
[
214,
84
],
[
216,
86
],
[
91,
90
],
... | [
"import math\nfrom functools import reduce\nfrom collections import deque\nimport sys\nsys.setrecursionlimit(10**7)\n\n# スペース区切りの入力を読み込んで数値リストにして返します。\ndef get_nums_l():\n return [ int(s) for s in input().split(\" \")]\n\n# 改行区切りの入力をn行読み込んで数値リストにして返します。\ndef get_nums_n(n):\n return [ int(input()) for _ in ran... | import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)
# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
return [ int(s) for s in input().split(" ")]
# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
return [ int(input()) for _ in range(n)]
# 改行またはスペース... |
[
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... | [
[
135,
2
],
[
135,
11
],
[
141,
13
],
[
27,
26
],
[
132,
33
],
[
43,
36
],
[
133,
39
],
[
46,
45
],
[
130,
48
],
[
51,
50
],
[
130,
53
],
[
56,
55
],
[
70,
61
],
... | [
"N, A = map(int, input().split())\nX = list(map(int, input().split()))\ndp = [[[0] * 3001 for i in range(51)] for j in range(51)]\n\ndp[0][0][0] = 1\n\nfor i in range(N):\n for j in range(N):\n for k in range(0, 2501):\n dp[i+1][j][k] += dp[i][j][k]\n dp[i+1][j+1][k+X[i]] += dp[i][j][k]\n\nans = 0\nfo... | N, A = map(int, input().split())
X = list(map(int, input().split()))
dp = [[[0] * 3001 for i in range(51)] for j in range(51)]
dp[0][0][0] = 1
for i in range(N):
for j in range(N):
for k in range(0, 2501):
dp[i+1][j][k] += dp[i][j][k]
dp[i+1][j+1][k+X[i]] += dp[i][j][k]
ans = 0
for n in range(1, N+... |
[
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,
41,
28,
13,
4,
13,
17,
2,
13,
17,
4,
13,
0,
13,
13,
0,
18,
18,
18,
13,
17,
17,
17,
17,
28... | [
[
4,
3
],
[
3,
12
],
[
149,
14
],
[
149,
16
],
[
20,
19
],
[
19,
28
],
[
143,
30
],
[
35,
34
],
[
147,
39
],
[
152,
44
],
[
54,
47
],
[
153,
50
],
[
57,
56
],
[... | [
"N,A = (int(T) for T in input().split())\nX = [int(T) for T in input().split()]\nDP = [[[0]*(N+1) for TS in range(0,50*N+1)] for TI in range(0,N+1)]\nDP[0][0][0] = 1\nfor TI in range(0,N):\n for TS in range(0,50*N+1):\n for TK in range(0,N+1):\n if DP[TI][TS][TK]!=0:\n DP[TI+1][T... | N,A = (int(T) for T in input().split())
X = [int(T) for T in input().split()]
DP = [[[0]*(N+1) for TS in range(0,50*N+1)] for TI in range(0,N+1)]
DP[0][0][0] = 1
for TI in range(0,N):
for TS in range(0,50*N+1):
for TK in range(0,N+1):
if DP[TI][TS][TK]!=0:
DP[TI+1][TS][TK] += DP[... |
[
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,
17,
4,
13,
0,
13,
13,
28,
13,
4,
13,
2,
... | [
[
33,
32
],
[
176,
34
],
[
33,
35
],
[
38,
37
],
[
176,
39
],
[
43,
42
],
[
50,
49
],
[
53,
52
],
[
32,
56
],
[
66,
59
],
[
49,
62
],
[
52,
65
],
[
69,
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,
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,
13,
0,
13,
13,
0,
18,
18,
18,
13,
17,
17,
17,
17,
0,
... | [
[
210,
2
],
[
210,
13
],
[
204,
15
],
[
30,
29
],
[
205,
32
],
[
36,
35
],
[
191,
39
],
[
45,
44
],
[
54,
47
],
[
44,
50
],
[
57,
56
],
[
60,
59
],
[
191,
62
],
... | [
"n,a = list(map(int,input().split()))\nx = list(map(int,input().split()))\n\ndef Count(n,k,a):\n\ts = sum(x)\n\tdp=[[[0 for l in range(s+1)] for j in range(k+1)] for i in range(n+1)]\n\tdp[0][0][0]=1\n\tSum=0\n\tfor i in range(n):\n\t\tfor j in range(k+1):\n\t\t\tfor l in range(s+1):\n\t\t\t\tif l < x[i]:\n\t\t\t\t... | n,a = list(map(int,input().split()))
x = list(map(int,input().split()))
def Count(n,k,a):
s = sum(x)
dp=[[[0 for l in range(s+1)] for j in range(k+1)] for i in range(n+1)]
dp[0][0][0]=1
Sum=0
for i in range(n):
for j in range(k+1):
for l in range(s+1):
if l < x[i]:
dp[i+1][j][l] = dp[i][j][l]
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,
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,
0,
13,
18,
13,
13,
28,
13... | [
[
142,
2
],
[
142,
11
],
[
133,
13
],
[
27,
26
],
[
145,
33
],
[
43,
36
],
[
146,
39
],
[
46,
45
],
[
137,
48
],
[
148,
50
],
[
134,
52
],
[
45,
53
],
[
56,
55
],... | [
"N, A = map(int, input().split())\nX = list(map(int, input().split()))\n\ndp = [[[0]*(2501) for i in range(51)] for j in range(51)]\ndp[0][0][0] = 1\nfor i in range(N):\n value = X[i]\n for j in range(i+2):\n for k in range(2501):\n if i >= j:\n dp[i+1][j][k] += dp[i][j][k]\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[0][0][0] = 1
for i in range(N):
value = X[i]
for j in range(i+2):
for k in range(2501):
if i >= j:
dp[i+1][j][k] += dp[i][j][k]
if 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,
2,
13,
17,
4,
13,
0,
13,
13,
28,
13,
4,
13,
2,
13,
17,
28,
13,
4,
13,
2,
13,
17,
... | [
[
217,
2
],
[
217,
11
],
[
214,
13
],
[
223,
25
],
[
215,
28
],
[
32,
31
],
[
218,
35
],
[
220,
40
],
[
44,
43
],
[
218,
47
],
[
51,
50
],
[
218,
54
],
[
58,
57
]... | [
"n, a = map(int, input().split())\nX = list(map(int, input().split()))\n\n# editorial 参照 -> 3 dimentional DP\n# 制約1: x1-xjのカード, 制約2: k枚選択, 制約3: 点数合計A*k\nsum_X = sum(X)\nDP = [[[0 for _ in range(sum_X+1)] for _ in range(n+1)] for _ in range(n+1)]\n\n\nfor j in range(n+1):\n for k in range(n+1):\n for s in ... | n, a = map(int, input().split())
X = list(map(int, input().split()))
# editorial 参照 -> 3 dimentional DP
# 制約1: x1-xjのカード, 制約2: k枚選択, 制約3: 点数合計A*k
sum_X = sum(X)
DP = [[[0 for _ in range(sum_X+1)] for _ in range(n+1)] for _ in range(n+1)]
for j in range(n+1):
for k in range(n+1):
for s in range(sum_X+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,
2,
13,
17,
4,
2,
39,
17,
17,
0,
13,
13,
28,
13,
4,
13,
2,
13,
17,
28,
13,
4,
13,
2,
13,
... | [
[
151,
2
],
[
151,
11
],
[
15,
14
],
[
14,
23
],
[
157,
25
],
[
30,
29
],
[
149,
33
],
[
145,
41
],
[
45,
44
],
[
149,
48
],
[
52,
51
],
[
44,
55
],
[
51,
61
],
... | [
"n, a = map(int, input().split())\nx = [int(x) for x in input().split()]\n\ndp = [[0]*2501 for _ in range(n+1)]\nfor i in range(n+1):\n for j in range(i-1, -1, -1):\n if j == 0:\n dp[j+1][x[i-1]] += 1\n for k in range(2500, -1, -1):\n if dp[j][k] and k+x[i-1] <= 2500:\n dp[j+1][k+x[i-1]] += ... | n, a = map(int, input().split())
x = [int(x) for x in input().split()]
dp = [[0]*2501 for _ in range(n+1)]
for i in range(n+1):
for j in range(i-1, -1, -1):
if j == 0:
dp[j+1][x[i-1]] += 1
for k in range(2500, -1, -1):
if dp[j][k] and k+x[i-1] <= 2500:
dp[j+1][k+x[i-1]] += dp[j][k]
ans =... |
[
7,
15,
13,
4,
18,
13,
13,
2,
17,
17,
0,
13,
4,
13,
17,
12,
13,
0,
13,
2,
17,
4,
13,
13,
0,
13,
17,
28,
13,
18,
13,
39,
17,
0,
13,
2,
2,
17,
4,
13,
13,
17,
0,
13,
2,
2,
13,
4,
13,
13,
13,
29,
4,
13,
13,
23,
... | [
[
269,
11
],
[
19,
18
],
[
26,
25
],
[
29,
28
],
[
35,
34
],
[
28,
40
],
[
44,
43
],
[
18,
46
],
[
56,
49
],
[
34,
50
],
[
25,
50
],
[
43,
54
],
[
57,
56
],
[
... | [
"#!/usr/bin/env python3\nimport sys\nsys.setrecursionlimit(10**8)\nINF = float(\"inf\")\n\n\ndef array(*args, initial=0):\n pre = \"[\"*len(args)\n post = \"\"\n for a in args[::-1]:\n post += \" for _ in range(\"+str(a)+\")]\"\n S = pre + str(initial) + post\n return eval(S)\n\n\ndef solve(N:... | #!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
INF = float("inf")
def array(*args, initial=0):
pre = "["*len(args)
post = ""
for a in args[::-1]:
post += " for _ in range("+str(a)+")]"
S = pre + str(initial) + post
return eval(S)
def solve(N: int, A: int, x: "List[int]"):... |
[
7,
15,
13,
38,
5,
15,
12,
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,
28,
13,
4,
13,
4,
13,
17,
2,
13,
17,
28,
13,
4,
13,
13,
2,
2,
13... | [
[
11,
10
],
[
89,
14
],
[
91,
22
],
[
89,
23
],
[
27,
26
],
[
34,
29
],
[
26,
31
],
[
37,
36
],
[
93,
36
],
[
40,
39
],
[
89,
46
],
[
50,
49
],
[
36,
52
],
[
... | [
"#!/usr/bin/env python3\nimport sys\ntry:\n from typing import List\nexcept ImportError:\n pass\n\n\ndef solve(N: int, A: int, x: \"List[int]\"):\n dp = [[0] * (A * N + 1) for _ in range(N + 1)]\n dp[0][0] = 1\n for xi in x:\n for k in reversed(range(1, N + 1)):\n for j in range(xi,... | #!/usr/bin/env python3
import sys
try:
from typing import List
except ImportError:
pass
def solve(N: int, A: int, x: "List[int]"):
dp = [[0] * (A * N + 1) for _ in range(N + 1)]
dp[0][0] = 1
for xi in x:
for k in reversed(range(1, N + 1)):
for j in range(xi, A * N + 1):
... |
[
7,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
31,
13,
4,
13,
13,
4,
18,
4,
13,
13,
0,
13,
2,
2,
13,
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,
... | [
[
151,
2
],
[
151,
11
],
[
15,
13
],
[
148,
24
],
[
146,
27
],
[
152,
28
],
[
33,
32
],
[
146,
36
],
[
142,
41
],
[
51,
44
],
[
143,
47
],
[
54,
53
],
[
146,
58
]... | [
"N, A = map(int, input().split())\n*x, = map(int, input().split())\nl = N * A + 1\n\n# dp[n枚選ぶ][m枚目まで][総和]\ndp = [[[0] * l for _ in range(N + 1)] for _ in range(N + 1)]\ndp[0][0][0] = 1\nfor n in range(0, N + 1):\n for m in range(N):\n for s in range(0, l):\n dp[n][m + 1][s] += dp[n][m][s]\n ... | N, A = map(int, input().split())
*x, = map(int, input().split())
l = N * A + 1
# dp[n枚選ぶ][m枚目まで][総和]
dp = [[[0] * l for _ in range(N + 1)] for _ in range(N + 1)]
dp[0][0][0] = 1
for n in range(0, N + 1):
for m in range(N):
for s in range(0, l):
dp[n][m + 1][s] += dp[n][m][s]
if s >=... |
[
7,
0,
13,
17,
0,
13,
17,
41,
28,
13,
4,
13,
13,
4,
13,
0,
13,
13,
12,
13,
14,
2,
13,
17,
29,
17,
14,
2,
13,
17,
14,
2,
13,
17,
29,
17,
0,
13,
2,
13,
13,
14,
40,
13,
17,
29,
17,
0,
13,
2,
13,
13,
14,
2,
13,
... | [
[
207,
2
],
[
231,
5
],
[
10,
9
],
[
208,
12
],
[
222,
16
],
[
121,
22
],
[
121,
28
],
[
125,
32
],
[
38,
37
],
[
123,
39
],
[
125,
40
],
[
37,
43
],
[
49,
48
],
... | [
"MAX_INDEX = 51\nMAX_SUM = 2505\n\ndp = [[[-1 for _ in range(MAX_INDEX)] for _ in range(MAX_SUM)] for _ in range(MAX_INDEX)]\n\ndef waysutil(index, sum, count, arr, K) : \n\n\tif (index < 0) : \n\t\treturn 0; \n\n\tif (index == 0) : \n\n\t\tif (count == 0) : \n\t\t\treturn 0; \n\t\t\t\n\t\tremainder = sum % count; ... | MAX_INDEX = 51
MAX_SUM = 2505
dp = [[[-1 for _ in range(MAX_INDEX)] for _ in range(MAX_SUM)] for _ in range(MAX_INDEX)]
def waysutil(index, sum, count, arr, K) :
if (index < 0) :
return 0;
if (index == 0) :
if (count == 0) :
return 0;
remainder = sum % count;
if (remainder != 0) :
retu... |
[
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,
4,
18,
13,
13,
0,
13,
4,
13,
4,
13,
12,
2,
13,
13,
23,
13,
0,
13,
4,
13,
13,
0,
18,
13,
17,
17,
28,
13,
13,
28,
13,
... | [
[
99,
3
],
[
99,
12
],
[
93,
14
],
[
94,
27
],
[
96,
30
],
[
88,
38
],
[
94,
40
],
[
90,
42
],
[
50,
47
],
[
91,
48
],
[
53,
52
],
[
97,
52
],
[
94,
52
],
[
... | [
"from collections import defaultdict\nn, a = map(int, input().split())\nx = list(map(int, input().split()))\nx.sort()\nx = list(map(lambda x:x - a, x))\ndic = defaultdict(int)\ndic[0] = 1\nfor i in x:\n for j, k in list(dic.items()):\n dic[j + i] = dic.get(j + i, 0) + k\nprint(dic[0] - 1)",
"from collec... | from collections import defaultdict
n, a = map(int, input().split())
x = list(map(int, input().split()))
x.sort()
x = list(map(lambda x:x - a, x))
dic = defaultdict(int)
dic[0] = 1
for i in x:
for j, k in list(dic.items()):
dic[j + i] = dic.get(j + i, 0) + k
print(dic[0] - 1) |
[
7,
12,
13,
12,
13,
14,
40,
2,
18,
18,
18,
13,
13,
13,
13,
17,
29,
18,
18,
18,
13,
13,
13,
13,
14,
40,
2,
13,
13,
14,
2,
2,
13,
17,
2,
13,
2,
13,
13,
29,
17,
29,
17,
0,
13,
4,
13,
2,
13,
17,
13,
13,
0,
13,
4,
... | [
[
87,
12
],
[
89,
13
],
[
91,
14
],
[
87,
21
],
[
89,
22
],
[
91,
23
],
[
87,
27
],
[
89,
32
],
[
91,
35
],
[
89,
38
],
[
45,
44
],
[
87,
48
],
[
89,
50
],
[
... | [
"def solve():\n def recur(i, n, total):\n # print(\"i, n, total\", i, n, total)\n\n if not TABLE[i][n][total] == -1:\n # print('cache!')\n return TABLE[i][n][total]\n\n if not i < N:\n if n > 0 and total == A * n:\n return 1\n return... | def solve():
def recur(i, n, total):
# print("i, n, total", i, n, total)
if not TABLE[i][n][total] == -1:
# print('cache!')
return TABLE[i][n][total]
if not i < N:
if n > 0 and total == A * n:
return 1
return 0
ans1 =... |
[
7,
15,
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,
4,
13,
13,
0,
18,
13,
17,
17,
28,
13,
13,
28,
13,
13,
4,
13,
4,
18,
13,
13,
0,
18,
... | [
[
6,
5
],
[
6,
18
],
[
6,
19
],
[
24,
23
],
[
23,
27
],
[
18,
28
],
[
31,
30
],
[
33,
32
],
[
40,
37
],
[
32,
38
],
[
43,
42
],
[
30,
42
],
[
32,
51
],
[
59... | [
"# ABC044C - 高橋君とカード / Tak and Cards (ARC060C)\nfrom collections import defaultdict\n\n\ndef main():\n N, A, *X = map(int, open(0).read().split())\n X, D = [i - A for i in X], defaultdict(int)\n D[0] = 1\n for i in X:\n for j, k in list(D.items()):\n D[i + j] += k\n ans = D[0] - 1\n... | # ABC044C - 高橋君とカード / Tak and Cards (ARC060C)
from collections import defaultdict
def main():
N, A, *X = map(int, open(0).read().split())
X, D = [i - A for i in X], defaultdict(int)
D[0] = 1
for i in X:
for j, k in list(D.items()):
D[i + j] += k
ans = D[0] - 1
print(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,
13,
0,
13,
13,
0,
18,
18,
18,
13,
17,
17,
17,
17,
28,
13,
4,
13,
17,
2,
13,
17,
28,
13,... | [
[
158,
2
],
[
158,
11
],
[
167,
13
],
[
27,
26
],
[
156,
30
],
[
152,
35
],
[
45,
38
],
[
153,
41
],
[
48,
47
],
[
156,
52
],
[
56,
55
],
[
47,
59
],
[
63,
62
],
... | [
"N, A = map(int,input().split())\nX = list(map(int,input().split()))\ndp = [[[0 for k in range(50 * N + 1)] for j in range(N + 1)] for i in range(N + 1)]\ndp[0][0][0] = 1\nfor i in range(1,N+1):\n for j in range(i+1):\n for k in range(50 * N + 1):\n dp[i][j][k] += dp[i-1][j][k]\n if ... | N, A = map(int,input().split())
X = list(map(int,input().split()))
dp = [[[0 for k in range(50 * N + 1)] for j in range(N + 1)] for i in range(N + 1)]
dp[0][0][0] = 1
for i in range(1,N+1):
for j in range(i+1):
for k in range(50 * N + 1):
dp[i][j][k] += dp[i-1][j][k]
if j != 0 and 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,
41,
28,
13,
4,
13,
17,
2,
13,
17,
4,
13,
0,
13,
13,
0,
18,
18,
18,
13,
17,
17,
17,
17,
41,
28,
13,
4,
13,
17,
2,
13,
17,... | [
[
204,
2
],
[
204,
11
],
[
186,
13
],
[
27,
26
],
[
205,
31
],
[
198,
36
],
[
46,
39
],
[
199,
42
],
[
50,
49
],
[
205,
54
],
[
195,
59
],
[
63,
62
],
[
205,
66
]... | [
"n , a= map(int , input().split())\narr = list(map(int , input().split()))\ndp = [ [[ 0 for j in range(0 , a*(n+2))] for k in range(0 , n+2)] for i in range(0,n+2)]\ndp[0][0][0]=1\nb=[0 for i in range(0 , n+1)]\nfor i in range(0 , n):\n\tb[i+1]=arr[i]\nfor i in range(1 , n+1):\t# choosing only first i elements\n\tf... | n , a= map(int , input().split())
arr = list(map(int , input().split()))
dp = [ [[ 0 for j in range(0 , a*(n+2))] for k in range(0 , n+2)] for i in range(0,n+2)]
dp[0][0][0]=1
b=[0 for i in range(0 , n+1)]
for i in range(0 , n):
b[i+1]=arr[i]
for i in range(1 , n+1): # choosing only first i elements
for j in range(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,
4,
13,
13,
0,
18,
13,
13,
13,
41,
28,
13,
4,
13,
2,
13,
17,
4,
2,
39,
17,
17,
0,
13,
13,
28,
13,
4,
13,
... | [
[
124,
2
],
[
124,
11
],
[
127,
13
],
[
26,
25
],
[
128,
30
],
[
35,
32
],
[
128,
33
],
[
25,
34
],
[
122,
35
],
[
39,
38
],
[
125,
42
],
[
130,
50
],
[
54,
53
],... | [
"n,a=map(int,input().split())\nx=list(map(int,input().split()))\nfor i in range(len(x)):\n x[i]-=a\nli=[[0]*5001 for i in range(n+1)]\nfor i in range(n):\n li[i+1][2500+x[i]]+=1\n for j in range(5001):\n if li[i][j]>=1:\n li[i+1][j+x[i]]+=li[i][j]\n li[i+1][j]+=li[i][j]\n # ... | n,a=map(int,input().split())
x=list(map(int,input().split()))
for i in range(len(x)):
x[i]-=a
li=[[0]*5001 for i in range(n+1)]
for i in range(n):
li[i+1][2500+x[i]]+=1
for j in range(5001):
if li[i][j]>=1:
li[i+1][j+x[i]]+=li[i][j]
li[i+1][j]+=li[i][j]
# print(li[i+1][24... |
[
7,
15,
13,
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,
18,
18,
18,
13,
17,
17,
... | [
[
238,
4
],
[
238,
15
],
[
229,
17
],
[
217,
29
],
[
230,
34
],
[
227,
35
],
[
39,
38
],
[
239,
42
],
[
232,
47
],
[
57,
50
],
[
233,
53
],
[
235,
59
],
[
63,
62
... | [
"#!/usr/bin/env python3\n\nimport itertools\n\nN, A = list(map(int, input().split()))\nx_list = list(map(int, input().split()))\n\nmax_x = max(max(x_list), A)\ndp = [[[0 for s in range(N * max_x + 1)] for k in range(N + 1)] for j in range(N + 1)]\ndp[0][0][0] = 1\nka_list = []\n\nfor j in range(N + 1): # 何番目の数か\n ... | #!/usr/bin/env python3
import itertools
N, A = list(map(int, input().split()))
x_list = list(map(int, input().split()))
max_x = max(max(x_list), A)
dp = [[[0 for s in range(N * max_x + 1)] for k in range(N + 1)] for j in range(N + 1)]
dp[0][0][0] = 1
ka_list = []
for j in range(N + 1): # 何番目の数か
x = x_list[j - ... |
[
7,
15,
13,
0,
13,
18,
18,
13,
13,
13,
0,
13,
2,
2,
17,
17,
17,
0,
13,
4,
13,
17,
4,
18,
13,
13,
2,
17,
17,
12,
13,
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,
... | [
[
125,
4
],
[
119,
11
],
[
128,
18
],
[
34,
33
],
[
126,
40
],
[
34,
42
],
[
45,
44
],
[
126,
53
],
[
57,
56
],
[
60,
59
],
[
66,
63
],
[
59,
64
],
[
69,
68
],
... | [
"import sys\n\nreadline = sys.stdin.readline\nMOD = 10 ** 9 + 7\nINF = float('INF')\nsys.setrecursionlimit(10 ** 5)\n\n\ndef main():\n from collections import Counter\n\n n, a = map(int, readline().split())\n x = list(map(int, readline().split()))\n\n ans = 0\n counter = Counter()\n\n counter[0] +... | import sys
readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)
def main():
from collections import Counter
n, a = map(int, readline().split())
x = list(map(int, readline().split()))
ans = 0
counter = Counter()
counter[0] += 1
for i in range... |
[
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,
2,
17,
13,
0,
13,
4,
18,
13,
13,
39,
2,
13,
17,
2,
13,
17,
18,
13,
13,
0,
18,
18,
13,
17,
17,
17,
28,
13,... | [
[
108,
4
],
[
108,
13
],
[
93,
15
],
[
105,
27
],
[
109,
30
],
[
102,
32
],
[
109,
39
],
[
106,
42
],
[
53,
48
],
[
103,
50
],
[
56,
55
],
[
94,
55
],
[
62,
58
],... | [
"import numpy as np\n\nn, a = map(int, input().split())\nx = list(map(int, input().split()))\nMAX = 50 * n\n\ndp = np.zeros((n + 1, MAX + 1), np.int64)\ndp[0][0] = 1\n\nfor e in x:\n dp[1:, e:] += dp[:-1, :-e]\n\ncnt = np.arange(1, n + 1)\nsm = cnt * a\nans = dp[cnt, sm].sum()\n\nprint(ans)",
"import numpy as ... | import numpy as np
n, a = map(int, input().split())
x = list(map(int, input().split()))
MAX = 50 * n
dp = np.zeros((n + 1, MAX + 1), np.int64)
dp[0][0] = 1
for e in x:
dp[1:, e:] += dp[:-1, :-e]
cnt = np.arange(1, n + 1)
sm = cnt * a
ans = dp[cnt, sm].sum()
print(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,
17,
4,
2,
39,
17,
17,
0,
13,
13,
0,
18,
18,
13,
17,
17,
17,
28,
13,
13,
28,
13,
4,
13,
17,
17,
17,
28... | [
[
113,
2
],
[
113,
11
],
[
101,
13
],
[
27,
26
],
[
110,
36
],
[
44,
39
],
[
111,
41
],
[
47,
46
],
[
102,
46
],
[
50,
49
],
[
57,
56
],
[
72,
63
],
[
111,
65
],
... | [
"\nN, M = map(int, input().split())\nD = list(map(int, input().split()))\ndp = [[0] * 2551 for i in range(51)]\ndp[0][0] = 1\nfor k in D:\n for i in range(49, -1, -1):\n for j in range(2500, -1, -1):\n dp[i+1][j + k] += dp[i][j]\n\nans = 0\nfor i in range(1, N+1):\n ans += dp[i][i*M]\nprint(... |
N, M = map(int, input().split())
D = list(map(int, input().split()))
dp = [[0] * 2551 for i in range(51)]
dp[0][0] = 1
for k in D:
for i in range(49, -1, -1):
for j in range(2500, -1, -1):
dp[i+1][j + k] += dp[i][j]
ans = 0
for i in range(1, N+1):
ans += dp[i][i*M]
print(ans)
|
[
7,
15,
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,
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,
... | [
[
7,
6
],
[
7,
15
],
[
18,
17
],
[
31,
30
],
[
6,
34
],
[
6,
43
],
[
47,
46
],
[
54,
49
],
[
46,
51
],
[
57,
56
],
[
6,
59
],
[
62,
61
],
[
46,
66
],
[
105,... | [
"import copy\ndef 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 dpn = copy.deepcopy(dp)\n for i in range(k+1):\n for j in range(50 * N + 1 -x[k]):\n ... | import copy
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):
dpn = copy.deepcopy(dp)
for i in range(k+1):
for j in range(50 * N + 1 -x[k]):
dpn[i+1]... |
[
7,
12,
13,
17,
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,
0,
13,
4,
13,
4,
18,
13,
13,
28,
13,
13,
13,
0,
18,... | [
[
6,
5
],
[
6,
14
],
[
17,
16
],
[
14,
26
],
[
35,
34
],
[
41,
40
],
[
16,
40
],
[
44,
43
],
[
34,
48
],
[
60,
55
],
[
34,
56
],
[
40,
59
],
[
34,
63
],
[
4... | [
"def abc044_c():\n ''' 過去提出を参考に '''\n _, A = map(int, input().split())\n X = list(map(lambda x: int(x) - A, input().split()))\n d = {0: 1} # 負の値を取り得るため、配列でなく辞書で持つ\n for x in X:\n prev = list(d.items()) # 前のターンのぶんを保持しておく\n for val, cnt in prev:\n d[val + x] = d.get(val + x, ... | 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:
prev = list(d.items()) # 前のターンのぶんを保持しておく
for val, cnt in prev:
d[val + x] = d.get(val + x, 0) + cnt
... |
[
7,
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,
21,
22,
17,
17,
28,
13,
13,
0,
13,
4,
13,
4,
18,
13,
13,
28,
13,
13,
13,
0,
18,
13,
2,
13,
13,... | [
[
86,
2
],
[
86,
11
],
[
15,
14
],
[
14,
24
],
[
78,
25
],
[
80,
27
],
[
83,
30
],
[
37,
36
],
[
81,
36
],
[
74,
39
],
[
84,
44
],
[
56,
51
],
[
84,
52
],
[
... | [
"n, a = map(int, input().split())\nx = [int(i)-a for i in input().split()]\n\ndp = {0: 1}\n\nfor i in x:\n tmp = list(dp.items())\n for key, value in tmp:\n dp[key+i] = dp.get(key+i, 0) + value\nprint(dp[0] - 1)\n\n",
"n, a = map(int, input().split())",
"n",
"map(int, input().split())",
"map",
... | n, a = map(int, input().split())
x = [int(i)-a for i in input().split()]
dp = {0: 1}
for i in x:
tmp = list(dp.items())
for key, value in tmp:
dp[key+i] = dp.get(key+i, 0) + value
print(dp[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,
4,
13,
13,
41,
28,
13,
4,
13,
2,
13,
17,
4,
2,
39,
17,
2,
2,
13,
13,
17,
0,
13,
13,
28,
13,
4,
13,
17,
2,
13,
1... | [
[
189,
2
],
[
189,
11
],
[
174,
13
],
[
192,
25
],
[
175,
28
],
[
32,
31
],
[
184,
35
],
[
193,
43
],
[
184,
44
],
[
177,
47
],
[
51,
50
],
[
184,
55
],
[
67,
58
... | [
"n, a = map(int, input().split())\nx = list(map(int, input().split()))\ns = sum(x)\ndp = [[0] * (s * n + 1) for _ in range(n + 1)]\nfor i in range(1, n + 1):\n dp[i][x[i - 1]] = 1\n for j in range(1, s + 1):\n dp[i][j] += dp[i - 1][j]\n for j in range(s + 1, s * n + 1):\n dp[i][j] = dp[i - 1]... | n, a = map(int, input().split())
x = list(map(int, input().split()))
s = sum(x)
dp = [[0] * (s * n + 1) for _ in range(n + 1)]
for i in range(1, n + 1):
dp[i][x[i - 1]] = 1
for j in range(1, s + 1):
dp[i][j] += dp[i - 1][j]
for j in range(s + 1, s * n + 1):
dp[i][j] = dp[i - 1][max(0, j - 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,
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,
... | [
[
155,
2
],
[
155,
11
],
[
146,
13
],
[
27,
26
],
[
156,
30
],
[
149,
35
],
[
45,
38
],
[
150,
41
],
[
48,
47
],
[
156,
50
],
[
53,
52
],
[
156,
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#dp[i][j][k]i枚目を検討中、j枚選び、合計kとなるのは何通りか\nfor i in range(N):\n for j in range(N+1):\n for k in range(2501):\n if not dp[i][j][k]:\n continue\n dp[i+1][j][k]+=... | 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
#dp[i][j][k]i枚目を検討中、j枚選び、合計kとなるのは何通りか
for i in range(N):
for j in range(N+1):
for k in range(2501):
if not dp[i][j][k]:
continue
dp[i+1][j][k]+=dp[i][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,
41,
28,
13,
13,
4,
2,
13,
13,
0,
13,
13,
0,
13,
21,
22,
17,
17,
28,
13,
13,
0,
13,
4,
13,
4,
18,
13,
13,
28,
13,
13,
13,... | [
[
86,
2
],
[
86,
11
],
[
95,
13
],
[
27,
26
],
[
96,
26
],
[
26,
30
],
[
81,
31
],
[
89,
33
],
[
92,
36
],
[
43,
42
],
[
90,
42
],
[
83,
45
],
[
93,
50
],
[
... | [
"N,A = map(int,input().split())\nX = list(map(int,input().split()))\nY = [x-A for x in X]\ndp = {0:1}\n\nfor y in Y:\n tmp = list(dp.items())\n for k,v in tmp:\n dp[k+y]=dp.get(k+y,0)+v\n\nprint(dp[0]-1)",
"N,A = map(int,input().split())",
"N",
"map(int,input().split())",
"map",
"int",
"input().spl... | N,A = map(int,input().split())
X = list(map(int,input().split()))
Y = [x-A for x in X]
dp = {0:1}
for y in Y:
tmp = list(dp.items())
for k,v in tmp:
dp[k+y]=dp.get(k+y,0)+v
print(dp[0]-1) |
[
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,
0,
13,
4,
18,
13,
13,
28,
13,
13,
... | [
[
93,
5
],
[
93,
18
],
[
93,
19
],
[
25,
24
],
[
94,
27
],
[
32,
29
],
[
24,
31
],
[
91,
32
],
[
35,
34
],
[
42,
39
],
[
34,
40
],
[
45,
44
],
[
48,
47
],
[
... | [
"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 nex = c.copy()\n for val, cnt in c.items():\n nex[val+i] += cnt\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:
nex = c.copy()
for val, cnt in c.items():
nex[val+i] += cnt
c = nex
ans =... |
[
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,
... | [
[
141,
4
],
[
144,
11
],
[
135,
18
],
[
132,
32
],
[
147,
37
],
[
43,
42
],
[
142,
49
],
[
43,
51
],
[
43,
52
],
[
57,
56
],
[
56,
60
],
[
51,
61
],
[
64,
63
],
... | [
"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 X = [x - A for x in X]\n\n base = 2500\n dp = [0] * 5001\n dp[base] = 1\n ... | 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())
X = [x - A for x in X]
base = 2500
dp = [0] * 5001
dp[base] = 1
for i in range(N):
... |
[
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,
13,
17,
0,
18,
18,
18,
13,
17,
17,
17,
17,
28,
13,
... | [
[
180,
2
],
[
180,
11
],
[
171,
13
],
[
165,
25
],
[
172,
28
],
[
32,
31
],
[
181,
35
],
[
183,
40
],
[
168,
43
],
[
53,
46
],
[
184,
49
],
[
56,
55
],
[
181,
58
... | [
"n, a = map(int, input().split())\nx = list(map(int, input().split()))\nx_max = max(x)\ndp = [[[0]*(x_max*n+1) for k in range(n+1)] for i in range(n+1)]\nans = 0\ndp[0][0][0] = 1\nfor i in range(n):\n for j in range(i+2):\n for k in range(x_max*n+1):\n if k>= x[i]:\n dp[i+1][j][k... | n, a = map(int, input().split())
x = list(map(int, input().split()))
x_max = max(x)
dp = [[[0]*(x_max*n+1) for k in range(n+1)] for i in range(n+1)]
ans = 0
dp[0][0][0] = 1
for i in range(n):
for j in range(i+2):
for k in range(x_max*n+1):
if k>= x[i]:
dp[i+1][j][k] = dp[i][j-1][... |
[
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,
4,
2,
4,
13,
13,
13,
12,
13,
14,
2,
13,
17,
29,
17,
14,
2,
2,
2,
13,
13,
17,
13,
29,
17,
14,
2,
13,
17,
... | [
[
212,
3
],
[
212,
12
],
[
16,
15
],
[
15,
24
],
[
218,
26
],
[
219,
32
],
[
213,
33
],
[
125,
38
],
[
213,
46
],
[
121,
47
],
[
123,
49
],
[
123,
54
],
[
125,
58
... | [
"from functools import lru_cache\nN, A = map(int, input().split())\nX = [int(x) for x in input().split()]\n#with open(\"9\", \"w\") as f:\n# print(50, 1, file=f)\n# print(*([1]*50), file=f)\nassert len(X) == N\ndef solve0(i, n, s):\n if s < 0:\n return -1\n if N-i+1 < n:\n return -1\n i... | from functools import lru_cache
N, A = map(int, input().split())
X = [int(x) for x in input().split()]
#with open("9", "w") as f:
# print(50, 1, file=f)
# print(*([1]*50), file=f)
assert len(X) == N
def solve0(i, n, s):
if s < 0:
return -1
if N-i+1 < n:
return -1
if n == 0:
if ... |
[
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,
... | [
[
81,
2
],
[
81,
11
],
[
72,
13
],
[
82,
23
],
[
75,
31
],
[
38,
37
],
[
73,
37
],
[
76,
46
],
[
54,
49
],
[
76,
50
],
[
37,
53
],
[
76,
57
],
[
37,
61
],
[
... | [
"N,A = map(int,input().split())\nY = list(map(lambda x:int(x)-A,input().split()))\ndp = {0:1}\n\nfor y in Y:\n\tfor k,v in list(dp.items()):\n\t\tdp[k+y]=dp.get(k+y,0)+v\n\nprint(dp[0]-1)",
"N,A = map(int,input().split())",
"N",
"map(int,input().split())",
"map",
"int",
"input().split()",
"().split",
... | N,A = map(int,input().split())
Y = list(map(lambda x:int(x)-A,input().split()))
dp = {0:1}
for y in Y:
for k,v in list(dp.items()):
dp[k+y]=dp.get(k+y,0)+v
print(dp[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,
41,
28,
13,
13,
4,
2,
13,
13,
0,
13,
13,
0,
13,
4,
13,
0,
18,
13,
17,
17,
28,
13,
13,
28,
13,
13,
4,
13,
4,
18,
13,
... | [
[
84,
3
],
[
84,
12
],
[
72,
14
],
[
28,
27
],
[
73,
27
],
[
27,
31
],
[
79,
32
],
[
75,
34
],
[
81,
37
],
[
44,
41
],
[
82,
42
],
[
47,
46
],
[
76,
46
],
[
... | [
"from collections import Counter\n\n\nN, A = map(int, input().split())\nX = list(map(int, input().split()))\nY = [x - A for x in X]\nL = Counter()\nL[0] = 1\n\nfor y in Y:\n for key, value in list(L.items()):\n L[key + y] += value\n\nprint(L[0] - 1)",
"from collections import Counter",
"N, A = map(int... | from collections import Counter
N, A = map(int, input().split())
X = list(map(int, input().split()))
Y = [x - A for x in X]
L = Counter()
L[0] = 1
for y in Y:
for key, value in list(L.items()):
L[key + y] += value
print(L[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,
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,
2,
13,
17,
17,
... | [
[
152,
2
],
[
152,
11
],
[
143,
13
],
[
26,
25
],
[
150,
28
],
[
33,
30
],
[
144,
31
],
[
25,
32
],
[
153,
33
],
[
37,
36
],
[
150,
40
],
[
146,
45
],
[
55,
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(2*n*50+1)] for j in range(n+1)]\ndp [0][n*50] = 1\n\nfor i in range(1,n+1):\n for j in range(2*n*50+1):\n if 0 <= j - x[i-1] < 2*n*50:\n dp[i][j] = dp[i-1][j] + dp[i-1... | 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(2*n*50+1)] for j in range(n+1)]
dp [0][n*50] = 1
for i in range(1,n+1):
for j in range(2*n*50+1):
if 0 <= j - x[i-1] < 2*n*50:
dp[i][j] = dp[i-1][j] + dp[i-1][j-x[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,
2,
13,
39,
13,
0,
13,
4,
13,
13,
0,
13,
2,
13,
13,
41,
28,
13,
4,
13,
2,
13,
17,
4,
13,
0,
13,
13,
0,
18,
18,
1... | [
[
157,
2
],
[
157,
11
],
[
154,
13
],
[
172,
25
],
[
155,
27
],
[
169,
31
],
[
173,
34
],
[
160,
36
],
[
152,
38
],
[
170,
39
],
[
43,
42
],
[
152,
46
],
[
163,
51
... | [
"N,A = map(int,input().split())\nx = list(map(int,input().split()))\n\ntemp = x + [A]\n\nX = max(temp)\n\nm = N * X\n\ndp = [[[0 for s in range(m+1)] for k in range(N+1)] for j in range(N+1)]\n\ndp[0][0][0] = 1\n\nres = 0\n\nfor j in range(N):\n for k in range(N):\n for s in range(m):\n if dp[j... | N,A = map(int,input().split())
x = list(map(int,input().split()))
temp = x + [A]
X = max(temp)
m = N * X
dp = [[[0 for s in range(m+1)] for k in range(N+1)] for j in range(N+1)]
dp[0][0][0] = 1
res = 0
for j in range(N):
for k in range(N):
for s in range(m):
if dp[j][k][s]:
... |
[
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,
2,
39,
17,
17,
0,
18,
13,
17,
17,
28,
13,
13,
0,
13,
4,
18,
13,
13,
28,
13,
4,
13,
17,
17,
... | [
[
86,
2
],
[
86,
11
],
[
95,
13
],
[
87,
23
],
[
92,
31
],
[
40,
37
],
[
93,
38
],
[
43,
42
],
[
96,
42
],
[
98,
45
],
[
93,
48
],
[
90,
48
],
[
52,
51
],
[
... | [
"N,A=map(int, input().split())\nx=tuple(map(lambda i:int(i)-A,input().split()))\nl=[0]*5001\nl[0]=1\nfor i in x:\n f=l.copy()\n for j in range(-2500,2501):\n if l[j]:\n f[i+j]+=l[j]\n l=f.copy()\nprint(l[0]-1)",
"N,A=map(int, input().split())",
"N",
"map(int, input().split())",
"m... | N,A=map(int, input().split())
x=tuple(map(lambda i:int(i)-A,input().split()))
l=[0]*5001
l[0]=1
for i in x:
f=l.copy()
for j in range(-2500,2501):
if l[j]:
f[i+j]+=l[j]
l=f.copy()
print(l[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,
17,
4,
13,
0,
13,
13,
0,
18,
18,
18,
13,
17,
17,
17,
17,
28,
13,
4,
13,
17,
28,
13,
4,
13,
17,
2,
13,... | [
[
169,
2
],
[
169,
11
],
[
151,
13
],
[
27,
26
],
[
157,
33
],
[
43,
36
],
[
158,
39
],
[
46,
45
],
[
51,
50
],
[
161,
55
],
[
59,
58
],
[
50,
62
],
[
163,
65
],
... | [
"n, a = map(int, input().split())\nx = list(map(int, input().split()))\n\ndp = [[[0 for k in range(n+1)] for j in range(n+1)] for s in range(2501)]\n\n\ndp[0][0][0] = 1\nfor s in range(2501):\n for j in range(1, n+1):\n for k in range(j+1):\n idx = j-1\n if x[idx] > s:\n ... | n, a = map(int, input().split())
x = list(map(int, input().split()))
dp = [[[0 for k in range(n+1)] for j in range(n+1)] for s in range(2501)]
dp[0][0][0] = 1
for s in range(2501):
for j in range(1, n+1):
for k in range(j+1):
idx = j-1
if x[idx] > s:
dp[s][j][k] = ... |
[
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,
2,
4,
13,
13,
13,
0,
13,
13,
0,
13,
4,
13,
2,
13,
39,
13,
41,
28,
13,
4,
13,
2,
13,
17,
4,
2,
39,
17,
2,
2,
2... | [
[
4,
3
],
[
3,
12
],
[
213,
14
],
[
213,
16
],
[
20,
19
],
[
19,
29
],
[
211,
30
],
[
216,
32
],
[
204,
35
],
[
217,
39
],
[
45,
44
],
[
214,
48
],
[
214,
58
],
... | [
"N, A = [int(x_i) for x_i in input().split()]\nx = [int(x_i) - A for x_i in input().split()]\n\nX = max(x + [A])\n\ndp=[[0] * (2*N*X + 1) for _ in range(N + 1)]\n\nfor j in range(N+1):\n for t in range(2*N*X):\n if j==0 and t==N*X:\n dp[j][t] = 1\n elif t-x[j-1] < 0 or t-x[j-1] > 2*N*X:\... | N, A = [int(x_i) for x_i in input().split()]
x = [int(x_i) - A for x_i in input().split()]
X = max(x + [A])
dp=[[0] * (2*N*X + 1) for _ in range(N + 1)]
for j in range(N+1):
for t in range(2*N*X):
if j==0 and t==N*X:
dp[j][t] = 1
elif t-x[j-1] < 0 or t-x[j-1] > 2*N*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,
0,
13,
2,
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,
2,
... | [
[
184,
2
],
[
184,
11
],
[
190,
13
],
[
187,
25
],
[
185,
27
],
[
179,
28
],
[
32,
31
],
[
185,
35
],
[
196,
40
],
[
50,
43
],
[
197,
46
],
[
53,
52
],
[
185,
56
... | [
"N, A = map(int, input().split())\nx = list(map(int, input().split()))\n\nmax_of_a = N * A\n\n# dp[i][j][k] := i枚目までからj枚取って、合計をkにする通り数\ndp = [[[0] * (max_of_a + 1) for _ in range(N+1)]for _ in range(N+1)]\ndp[0][0][0] = 1\n\n\nfor i in range(N+1):\n for j in range(N+1):\n for k in range(max_of_a + 1):\n ... | N, A = map(int, input().split())
x = list(map(int, input().split()))
max_of_a = N * A
# dp[i][j][k] := i枚目までからj枚取って、合計をkにする通り数
dp = [[[0] * (max_of_a + 1) for _ in range(N+1)]for _ in range(N+1)]
dp[0][0][0] = 1
for i in range(N+1):
for j in range(N+1):
for k in range(max_of_a + 1):
if i >= ... |
[
7,
15,
13,
15,
13,
0,
13,
18,
18,
18,
13,
13,
13,
13,
0,
13,
18,
18,
18,
13,
13,
13,
13,
0,
13,
18,
18,
18,
13,
13,
13,
13,
0,
13,
4,
13,
13,
4,
18,
4,
13,
13,
13,
0,
13,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
... | [
[
111,
6
],
[
114,
15
],
[
123,
24
],
[
135,
33
],
[
115,
40
],
[
135,
42
],
[
126,
44
],
[
115,
53
],
[
58,
57
],
[
127,
57
],
[
57,
61
],
[
118,
62
],
[
120,
64
... | [
"# -*- coding: utf-8 -*-\nimport sys \nimport numpy as np\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\nN, A = map(int, readline().split())\nX = list(map(int,readline().split()))\nY = [x-A for x in X]\ndp = {0:1}\n\nfor y in Y:\n tmp = list(dp.items(... | # -*- coding: utf-8 -*-
import sys
import numpy as np
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N, A = map(int, readline().split())
X = list(map(int,readline().split()))
Y = [x-A for x in X]
dp = {0:1}
for y in Y:
tmp = list(dp.items())
for k,v in... |
[
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,
17,
0,
13,
4,
13,
13,
0,
13,
4,
18,
13,
13,
39,
13,
2,
13,
17,
0,
13,
18,
13,
13,
28,
13,
4,
13,
13,
28,
13,
18,... | [
[
136,
4
],
[
136,
13
],
[
139,
15
],
[
124,
28
],
[
140,
31
],
[
130,
33
],
[
125,
41
],
[
45,
44
],
[
50,
49
],
[
134,
52
],
[
55,
54
],
[
49,
58
],
[
72,
62
],... | [
"import numpy as np\nn,a = map(int,input().split())\nx = list(map(int,input().split()))\n\"\"\"\n平均がa <=> 集合をlとして, len(l)a = sum(l)\ndp[i][j][k] := i番目までのカードを選んだとき, 選んだ枚数がkでの総和がちょうどjになる場合の数.\nこれだとメモリが足りないので, iを省略する.\n\"\"\"\nsumx = sum(x)\ndp = np.zeros((n, sumx+1), dtype=np.int64)\nfor i in range(n):\n\tfor j in r... | import numpy as np
n,a = map(int,input().split())
x = list(map(int,input().split()))
"""
平均がa <=> 集合をlとして, len(l)a = sum(l)
dp[i][j][k] := i番目までのカードを選んだとき, 選んだ枚数がkでの総和がちょうどjになる場合の数.
これだとメモリが足りないので, iを省略する.
"""
sumx = sum(x)
dp = np.zeros((n, sumx+1), dtype=np.int64)
for i in range(n):
for j in range(i)[::-1]:
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,
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,
... | [
[
155,
2
],
[
155,
11
],
[
143,
13
],
[
27,
26
],
[
156,
30
],
[
146,
35
],
[
45,
38
],
[
147,
41
],
[
48,
47
],
[
156,
50
],
[
53,
52
],
[
156,
56
],
[
60,
59
],... | [
"N, A = map(int, input().split())\nx = list(map(int, input().split()))\ndp = [[[0]*3000 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(N+1):\n for k in range(3000):\n dp[i+1][j][k] += dp[i][j][k]\n \n if j+1<=N and k+x[i]<... | N, A = map(int, input().split())
x = list(map(int, input().split()))
dp = [[[0]*3000 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+1):
for k in range(3000):
dp[i+1][j][k] += dp[i][j][k]
if j+1<=N and k+x[i]<3000:
... |
[
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,
2,
2,
17,
13,
4,
13,
4,
13,
13,
13,
41,
28,
13,
4,
13,
2,
13,
17,
4,
2,
39,
17,
2,
13,
17... | [
[
145,
2
],
[
145,
11
],
[
148,
13
],
[
140,
23
],
[
142,
31
],
[
146,
35
],
[
149,
40
],
[
140,
41
],
[
45,
44
],
[
146,
48
],
[
143,
55
],
[
136,
58
],
[
68,
61
... | [
"n,a,=map(int,input().split())\nx=list(map(lambda y:int(y)-a,input().split()))\nw=2*n*(max(max(x),a))\ndp=[[0]*(w+1) for _ in range(n+1)]\ndp[0][w//2]=1\nfor i in range(1,n+1):\n for j in range(w+1):\n dp[i][j]=dp[i-1][j]+(dp[i-1][j-x[i-1]] if 0<=j-x[i-1]<=w else 0)\nprint(dp[n][w//2]-1)",
"n,a,=map(int,input... | n,a,=map(int,input().split())
x=list(map(lambda y:int(y)-a,input().split()))
w=2*n*(max(max(x),a))
dp=[[0]*(w+1) for _ in range(n+1)]
dp[0][w//2]=1
for i in range(1,n+1):
for j in range(w+1):
dp[i][j]=dp[i-1][j]+(dp[i-1][j-x[i-1]] if 0<=j-x[i-1]<=w else 0)
print(dp[n][w//2]-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,
13,
4,
2,
13,
13,
0,
13,
13,
41,
28,
13,
4,
13,
2,
13,
17,
4,
2,
39,
17,
17,
0,
13,
13,
0,
18,
18,
13,
17,
... | [
[
123,
2
],
[
123,
11
],
[
111,
13
],
[
27,
26
],
[
112,
26
],
[
26,
30
],
[
124,
31
],
[
117,
33
],
[
38,
37
],
[
121,
41
],
[
126,
49
],
[
57,
52
],
[
127,
54
]... | [
"n,a = map(int, input().split())\nX = list(map(int, input().split()))\nx = [i-a for i in X]\ndp = [[0]*5201 for i in range(n+1)]\ndp[0][2600] = 1 \nfor i,xi in enumerate(x):\n for k in range(99,5101):\n dp[i+1][k+xi] += dp[i][k] \n dp[i+1][k] += dp[i][k]\nans = dp[n][2600] - 1\nprint(ans)",
"n,a = map(int,... | n,a = map(int, input().split())
X = list(map(int, input().split()))
x = [i-a for i in X]
dp = [[0]*5201 for i in range(n+1)]
dp[0][2600] = 1
for i,xi in enumerate(x):
for k in range(99,5101):
dp[i+1][k+xi] += dp[i][k]
dp[i+1][k] += dp[i][k]
ans = dp[n][2600] - 1
print(ans) |
[
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,
13,
17,
28,
13,
13,
4,
13,
13,
28,
13,
4,
... | [
[
107,
3
],
[
107,
12
],
[
113,
14
],
[
28,
27
],
[
105,
31
],
[
116,
38
],
[
46,
41
],
[
117,
43
],
[
108,
45
],
[
114,
52
],
[
55,
54
],
[
117,
58
],
[
110,
62
... | [
"from collections import defaultdict\nn, a = map(int, input().split())\nx = list(map(int, input().split()))\n\ndp = [defaultdict(int) for _ in range(n+1)]\ndp[0][a] += 1\n\nfor i, x_i in enumerate(x):\n for p in dp[i].keys():\n pk = p + a - x_i\n dp[i+1][pk] += dp[i][p]\n dp[i+1][p] += dp[i]... | from collections import defaultdict
n, a = map(int, input().split())
x = list(map(int, input().split()))
dp = [defaultdict(int) for _ in range(n+1)]
dp[0][a] += 1
for i, x_i in enumerate(x):
for p in dp[i].keys():
pk = p + a - x_i
dp[i+1][pk] += dp[i][p]
dp[i+1][p] += dp[i][p]
print(dp[n]... |
[
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,
39,
0,
13,
17,
28,
13,
4,
13,
13,
14,
2,
18,
13,
13,
17,
0,
... | [
[
206,
2
],
[
206,
11
],
[
191,
13
],
[
26,
25
],
[
204,
28
],
[
33,
30
],
[
192,
31
],
[
25,
32
],
[
30,
34
],
[
192,
35
],
[
25,
36
],
[
207,
37
],
[
197,
39
],... | [
"n,a=map(int,input().split())\nA=list(map(int,input().split()))\nfor i in range(n):\n A[i]=A[i]-a\nB=[]\nc=0\nfor i in range(n):\n if A[i]==0:\n c=c+1\n else:\n B.append(A[i])\nn=len(B)\ndp=[[0]*5010 for i in range(n+1)]#0と2505を対応\nfor i in range(1,n+1):\n dp[i]=dp[i-1][0:5010]\n dp[i][2505+B[i-1]]+=1\n ... | n,a=map(int,input().split())
A=list(map(int,input().split()))
for i in range(n):
A[i]=A[i]-a
B=[]
c=0
for i in range(n):
if A[i]==0:
c=c+1
else:
B.append(A[i])
n=len(B)
dp=[[0]*5010 for i in range(n+1)]#0と2505を対応
for i in range(1,n+1):
dp[i]=dp[i-1][0:5010]
dp[i][2505+B[i-1]]+=1
for j in range(5010)... |
[
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,
4,
13,
4,
13,
13,
13,
41,
28,
13,
4,
13,
2,
13,
17,
4,
2,
39,
17,
2,
2,
2... | [
[
160,
2
],
[
160,
11
],
[
157,
13
],
[
26,
25
],
[
155,
28
],
[
33,
30
],
[
158,
31
],
[
25,
32
],
[
161,
33
],
[
151,
35
],
[
158,
40
],
[
161,
41
],
[
45,
44
]... | [
"N, A = map(int, input().split())\nx = list(map(int, input().split()))\nfor i in range(N):\n x[i] -= A\nmax_x = max(max(x), A)\n\ndp = [[0]*(2*N*max_x + 1) for i in range(N+1)]\ndp[0][N*max_x] = 1\n\nfor i in range(N):\n for k in range(2*N*max_x + 1):\n dp[i+1][k] = dp[i][k]\n if 0 <= k - x[i] a... | N, A = map(int, input().split())
x = list(map(int, input().split()))
for i in range(N):
x[i] -= A
max_x = max(max(x), A)
dp = [[0]*(2*N*max_x + 1) for i in range(N+1)]
dp[0][N*max_x] = 1
for i in range(N):
for k in range(2*N*max_x + 1):
dp[i+1][k] = dp[i][k]
if 0 <= k - x[i] and k - x[i] <= 2*... |
[
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,
17,
41,
28,
13,
4,
13,
2,
13,
17,
4,
4,
13,
0,
13,
13,
0,
18,
18,
13,
17,
17,
17,
28,
13,
13,
4,
13,
13,
28,
13,
4,
... | [
[
121,
3
],
[
121,
12
],
[
106,
14
],
[
29,
28
],
[
119,
32
],
[
115,
38
],
[
46,
41
],
[
116,
43
],
[
107,
52
],
[
55,
54
],
[
116,
68
],
[
54,
69
],
[
81,
72
],... | [
"from collections import Counter\nN,A = map(int, input().split())\nX = list(map(int, input().split()))\n\n\"\"\"\n普通にやると最大で2**50通りなのでTLE\ni枚選んだ時に合計がi*Aになる物を考えるとよい\nprd_xxxさんの解答に自分向けのコメントつけただけ\nhttps://atcoder.jp/contests/abc044/submissions/3018277\n\"\"\"\n\n# 0枚からN枚まで選んで、合計値がkeyでその組み合わせの数がvalue\ndp = [Counter() fo... | from collections import Counter
N,A = map(int, input().split())
X = list(map(int, input().split()))
"""
普通にやると最大で2**50通りなのでTLE
i枚選んだ時に合計がi*Aになる物を考えるとよい
prd_xxxさんの解答に自分向けのコメントつけただけ
https://atcoder.jp/contests/abc044/submissions/3018277
"""
# 0枚からN枚まで選んで、合計値がkeyでその組み合わせの数がvalue
dp = [Counter() for _ in range(N+1)]
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,
0,
13,
4,
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,
28,
13,
18,
4,
... | [
[
127,
2
],
[
127,
11
],
[
133,
13
],
[
121,
25
],
[
134,
28
],
[
32,
31
],
[
119,
35
],
[
130,
40
],
[
48,
43
],
[
131,
45
],
[
51,
50
],
[
134,
50
],
[
54,
53
]... | [
"n,a = map(int,input().split())\nxx = list(map(int,input().split()))\n\nsm = sum(xx)\ndp = [[0 for j in range(sm+1)] for i in range(n+1)]\ndp[0][0] = 1\nfor x in xx:\n for i in range(1,n+1)[::-1]:\n for j in range(x,sm+1)[::-1]:\n # if dp[i-1][j-x]:\n dp[i][j] += dp[i-1][j-x]\n\nans ... | n,a = map(int,input().split())
xx = list(map(int,input().split()))
sm = sum(xx)
dp = [[0 for j in range(sm+1)] for i in range(n+1)]
dp[0][0] = 1
for x in xx:
for i in range(1,n+1)[::-1]:
for j in range(x,sm+1)[::-1]:
# if dp[i-1][j-x]:
dp[i][j] += dp[i-1][j-x]
ans = 0
for i in rang... |
[
7,
15,
0,
13,
4,
13,
4,
13,
0,
13,
17,
13,
17,
14,
2,
2,
18,
13,
17,
18,
13,
17,
2,
40,
18,
13,
17,
40,
18,
13,
17,
0,
13,
17,
14,
2,
2,
18,
13,
17,
18,
13,
17,
2,
40,
18,
13,
17,
40,
18,
13,
17,
0,
13,
17,
... | [
[
78,
3
],
[
72,
9
],
[
75,
11
],
[
79,
17
],
[
79,
20
],
[
79,
25
],
[
79,
29
],
[
69,
32
],
[
79,
38
],
[
79,
41
],
[
79,
46
],
[
79,
50
],
[
66,
53
],
[
... | [
"from collections import Counter\n\n\ncntr = Counter(input())\nx_ok, y_ok = False, False\nif (cntr[\"E\"] and cntr[\"W\"]) or (not cntr[\"E\"] and not cntr[\"W\"]):\n x_ok = True\nif (cntr[\"N\"] and cntr[\"S\"]) or (not cntr[\"N\"] and not cntr[\"S\"]):\n y_ok = True\nprint(\"Yes\") if x_ok and y_ok else pri... | from collections import Counter
cntr = Counter(input())
x_ok, y_ok = False, False
if (cntr["E"] and cntr["W"]) or (not cntr["E"] and not cntr["W"]):
x_ok = True
if (cntr["N"] and cntr["S"]) or (not cntr["N"] and not cntr["S"]):
y_ok = True
print("Yes") if x_ok and y_ok else print("No")
|
[
7,
0,
13,
4,
13,
4,
13,
4,
13,
14,
2,
2,
2,
4,
13,
13,
17,
2,
4,
13,
13,
4,
13,
39,
17,
17,
2,
4,
13,
13,
4,
13,
39,
17,
17,
4,
13,
17,
4,
13,
17,
10,
4,
13
] | [
[
42,
2
],
[
43,
15
],
[
43,
20
],
[
43,
29
],
[
42,
43
]
] | [
"S=list(set(input()))\nif len(S)==4 or set(S)==set(['N','S']) or set(S)==set(['W','E']):\n print('Yes')\nelse:\n print('No')",
"S=list(set(input()))",
"S",
"list(set(input()))",
"list",
"set(input())",
"set",
"input()",
"input",
"if len(S)==4 or set(S)==set(['N','S']) or set(S)==set(['W','E'... | S=list(set(input()))
if len(S)==4 or set(S)==set(['N','S']) or set(S)==set(['W','E']):
print('Yes')
else:
print('No') |
[
7,
15,
13,
13,
13,
13,
13,
13,
13,
13,
0,
13,
12,
4,
18,
4,
18,
18,
13,
13,
13,
13,
4,
18,
13,
13,
2,
17,
17,
0,
13,
4,
13,
17,
12,
13,
12,
13,
12,
13,
41,
28,
13,
4,
18,
4,
13,
13,
4,
4,
13,
13,
12,
13,
41,
... | [
[
166,
11
],
[
178,
30
],
[
43,
42
],
[
167,
46
],
[
42,
51
],
[
57,
56
],
[
167,
60
],
[
56,
66
],
[
73,
72
],
[
167,
76
],
[
72,
81
],
[
90,
89
],
[
188,
91
],
... | [
"import bisect, collections, copy, heapq, itertools, math, string, sys\ninput = lambda: sys.stdin.readline().rstrip() \nsys.setrecursionlimit(10**7)\nINF = float('inf')\ndef I(): return int(input())\ndef F(): return float(input())\ndef SS(): return input()\ndef LI(): return [int(x) for x in input().split()]\ndef LI... | import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [... |
[
7,
12,
13,
0,
13,
4,
13,
0,
13,
4,
13,
13,
14,
40,
4,
13,
13,
17,
14,
2,
2,
2,
2,
2,
17,
13,
40,
17,
13,
2,
2,
17,
13,
40,
17,
13,
2,
2,
17,
13,
40,
17,
13,
2,
2,
17,
13,
40,
17,
13,
4,
13,
17,
29,
4,
13,
... | [
[
5,
4
],
[
9,
8
],
[
4,
11
],
[
8,
16
],
[
8,
25
],
[
8,
28
],
[
8,
32
],
[
8,
35
],
[
8,
39
],
[
8,
42
],
[
8,
46
],
[
8,
49
],
[
61,
58
]
] | [
"def resolve():\n S = input()\n chk = set(S)\n if len(chk) != 4:\n if (\"N\" in chk and \"S\" not in chk) or (\"E\" in chk and \"W\" not in chk) or (\n \"S\" in chk and \"N\" not in chk) or (\"W\" in chk and \"E\" not in chk):\n print(\"No\")\n return\n print(... | def resolve():
S = input()
chk = set(S)
if len(chk) != 4:
if ("N" in chk and "S" not in chk) or ("E" in chk and "W" not in chk) or (
"S" in chk and "N" not in chk) or ("W" in chk and "E" not in chk):
print("No")
return
print("Yes")
resolve()
|
[
7,
0,
13,
4,
13,
14,
2,
40,
4,
18,
13,
13,
17,
17,
2,
4,
18,
13,
13,
17,
17,
4,
13,
17,
14,
2,
40,
4,
18,
13,
13,
17,
17,
2,
4,
18,
13,
13,
17,
17,
4,
13,
17,
14,
2,
40,
4,
18,
13,
13,
17,
17,
2,
4,
18,
13,... | [
[
85,
2
],
[
86,
10
],
[
86,
17
],
[
86,
29
],
[
86,
36
],
[
86,
48
],
[
86,
55
],
[
86,
67
],
[
86,
74
],
[
85,
86
]
] | [
"S=input()\nif S.count(\"N\")>=1 and S.count(\"S\")==0:\n print(\"No\")\nelif S.count(\"S\")>=1 and S.count(\"N\")==0:\n print(\"No\")\nelif S.count(\"W\")>=1 and S.count(\"E\")==0:\n print(\"No\")\nelif S.count(\"E\")>=1 and S.count(\"W\")==0:\n print(\"No\")\nelse:\n print(\"Yes\")",
"S=input()",... | S=input()
if S.count("N")>=1 and S.count("S")==0:
print("No")
elif S.count("S")>=1 and S.count("N")==0:
print("No")
elif S.count("W")>=1 and S.count("E")==0:
print("No")
elif S.count("E")>=1 and S.count("W")==0:
print("No")
else:
print("Yes") |
[
7,
0,
13,
4,
13,
4,
13,
14,
2,
4,
13,
13,
17,
4,
13,
17,
14,
2,
4,
13,
13,
17,
4,
13,
17,
14,
2,
2,
2,
17,
13,
2,
17,
13,
2,
2,
17,
13,
2,
17,
13,
4,
13,
17,
4,
13,
17,
10,
4,
13
] | [
[
48,
2
],
[
49,
11
],
[
49,
20
],
[
49,
30
],
[
49,
33
],
[
49,
37
],
[
49,
40
],
[
48,
49
]
] | [
"s=set(input())\nif len(s)==4:\n print(\"Yes\")\nelif len(s)%2:\n print(\"No\")\nelse:\n if (\"N\" in s and \"S\" in s) or (\"W\"in s and \"E\" in s):\n print(\"Yes\")\n else:\n print(\"No\")",
"s=set(input())",
"s",
"set(input())",
"set",
"input()",
"input",
"if len(s)==4:\n... | s=set(input())
if len(s)==4:
print("Yes")
elif len(s)%2:
print("No")
else:
if ("N" in s and "S" in s) or ("W"in s and "E" in s):
print("Yes")
else:
print("No")
|
[
7,
0,
13,
4,
13,
0,
13,
4,
18,
13,
13,
17,
13,
4,
18,
13,
13,
17,
0,
13,
4,
18,
13,
13,
17,
13,
4,
18,
13,
13,
17,
0,
13,
17,
14,
2,
2,
13,
17,
2,
13,
17,
14,
40,
13,
13,
0,
13,
17,
14,
2,
2,
13,
17,
2,
13,... | [
[
71,
2
],
[
74,
6
],
[
72,
9
],
[
92,
12
],
[
72,
15
],
[
83,
19
],
[
72,
22
],
[
77,
25
],
[
72,
28
],
[
80,
32
],
[
75,
37
],
[
84,
40
],
[
75,
44
],
[
8... | [
"S = input()\nn, w = S.count('N'), S.count('W')\ns, e = S.count('S'), S.count('E')\nflag = True\nif n == 0 or s == 0:\n if n != s:\n flag = False\nif w == 0 or e == 0:\n if w != e:\n flag = False\nprint('Yes' if flag else 'No')",
"S = input()",
"S",
"input()",
"input",
"n, w = S.count(... | S = input()
n, w = S.count('N'), S.count('W')
s, e = S.count('S'), S.count('E')
flag = True
if n == 0 or s == 0:
if n != s:
flag = False
if w == 0 or e == 0:
if w != e:
flag = False
print('Yes' if flag else 'No')
|
[
7,
12,
13,
14,
2,
2,
13,
17,
2,
13,
17,
29,
17,
14,
2,
2,
13,
17,
2,
13,
17,
29,
17,
29,
17,
23,
13,
23,
13,
0,
13,
17,
13,
17,
13,
17,
13,
17,
28,
13,
4,
13,
14,
2,
13,
17,
0,
13,
17,
14,
2,
13,
17,
0,
13,
... | [
[
26,
6
],
[
28,
9
],
[
26,
16
],
[
28,
19
],
[
26,
26
],
[
28,
28
],
[
83,
30
],
[
107,
32
],
[
86,
34
],
[
95,
36
],
[
40,
39
],
[
39,
44
],
[
104,
47
],
[
... | [
"# A - Wanna go back home\ndef can_go_home(dir1, dir2):\n\tif dir1 > 0 and dir2 > 0:\n\t\treturn True\n\telif dir1 == 0 and dir2 == 0:\n\t\treturn True\n\telse:\n\t\treturn False\n\n\nn, w, s, e = 0, 0, 0, 0\n\nfor dir in input():\n\tif dir == 'N':\n\t\tn += 1\n\telif dir == 'W':\n\t\tw += 1\n\telif dir == 'S':\n\t... | # A - Wanna go back home
def can_go_home(dir1, dir2):
if dir1 > 0 and dir2 > 0:
return True
elif dir1 == 0 and dir2 == 0:
return True
else:
return False
n, w, s, e = 0, 0, 0, 0
for dir in input():
if dir == 'N':
n += 1
elif dir == 'W':
w += 1
elif dir == 'S':
s += 1
else:
e += 1
if can_go_home(... |
[
7,
0,
13,
4,
13,
0,
13,
17,
14,
40,
4,
18,
13,
13,
17,
17,
14,
2,
4,
18,
13,
13,
17,
17,
0,
13,
17,
14,
40,
4,
18,
13,
13,
17,
17,
14,
2,
4,
18,
13,
13,
17,
17,
0,
13,
17,
14,
40,
4,
18,
13,
13,
17,
17,
14,
... | [
[
93,
2
],
[
99,
6
],
[
94,
12
],
[
94,
20
],
[
108,
25
],
[
94,
31
],
[
94,
39
],
[
96,
44
],
[
94,
50
],
[
94,
58
],
[
102,
63
],
[
94,
69
],
[
94,
77
],
[
... | [
"s = input()\nok = True\nif s.count(\"N\") >= 1:\n if s.count(\"S\") == 0:\n ok = False\nif s.count(\"S\") >= 1:\n if s.count(\"N\") == 0:\n ok = False\n\nif s.count(\"E\") >= 1:\n if s.count(\"W\") == 0:\n ok = False\n\nif s.count(\"W\") >= 1:\n if s.count(\"E\") == 0:\n ok ... | s = input()
ok = True
if s.count("N") >= 1:
if s.count("S") == 0:
ok = False
if s.count("S") >= 1:
if s.count("N") == 0:
ok = False
if s.count("E") >= 1:
if s.count("W") == 0:
ok = False
if s.count("W") >= 1:
if s.count("E") == 0:
ok = False
if ok:
print("Yes")
else... |
[
7,
17,
12,
13,
15,
13,
0,
13,
18,
18,
13,
13,
13,
0,
13,
18,
18,
13,
13,
13,
0,
13,
18,
18,
13,
13,
13,
0,
13,
18,
4,
13,
39,
17,
0,
13,
4,
13,
4,
13,
13,
14,
2,
4,
13,
13,
17,
4,
13,
17,
14,
2,
2,
4,
13,
1... | [
[
8,
7
],
[
15,
14
],
[
22,
21
],
[
29,
28
],
[
7,
31
],
[
36,
35
],
[
28,
40
],
[
35,
45
],
[
35,
55
],
[
35,
60
],
[
28,
70
],
[
28,
73
],
[
28,
77
],
[
2... | [
"'''\nCreated on 2020/08/19\n\n@author: harurun\n'''\ndef main():\n import sys\n pin=sys.stdin.readline\n pout=sys.stdout.write\n perr=sys.stderr.write\n \n S=pin()[:-1]\n T=list(set(S))\n if len(T)==4:\n print(\"Yes\")\n elif len(T)==3 or len(T)==1:\n print(\"No\")\n else:\n if ((\"N\" in S )and... | '''
Created on 2020/08/19
@author: harurun
'''
def main():
import sys
pin=sys.stdin.readline
pout=sys.stdout.write
perr=sys.stderr.write
S=pin()[:-1]
T=list(set(S))
if len(T)==4:
print("Yes")
elif len(T)==3 or len(T)==1:
print("No")
else:
if (("N" in S )and ("S" in S)) or (("W" in S) a... |
[
7,
15,
13,
0,
13,
18,
18,
13,
13,
13,
12,
13,
0,
13,
4,
18,
4,
13,
13,
0,
13,
17,
14,
2,
17,
13,
14,
40,
17,
13,
0,
13,
17,
14,
2,
17,
13,
14,
40,
17,
13,
0,
13,
17,
14,
2,
17,
13,
14,
40,
17,
13,
0,
13,
17,
... | [
[
82,
4
],
[
14,
13
],
[
83,
17
],
[
21,
20
],
[
13,
25
],
[
13,
29
],
[
32,
31
],
[
13,
36
],
[
13,
40
],
[
43,
42
],
[
13,
47
],
[
13,
51
],
[
54,
53
],
[
... | [
"import sys\n\ninput = sys.stdin.readline\n\n\ndef main():\n S = input().rstrip()\n\n go_back_home = True\n if \"N\" in S:\n if \"S\" not in S:\n go_back_home = False\n if \"S\" in S:\n if \"N\" not in S:\n go_back_home = False\n if \"W\" in S:\n if \"E\" no... | import sys
input = sys.stdin.readline
def main():
S = input().rstrip()
go_back_home = True
if "N" in S:
if "S" not in S:
go_back_home = False
if "S" in S:
if "N" not in S:
go_back_home = False
if "W" in S:
if "E" not in S:
go_back_home ... |
[
7,
15,
13,
0,
13,
4,
13,
0,
13,
4,
18,
13,
13,
13,
0,
13,
17,
14,
2,
18,
13,
17,
17,
14,
2,
18,
13,
17,
17,
0,
13,
17,
14,
2,
18,
13,
17,
17,
14,
2,
18,
13,
17,
17,
0,
13,
17,
14,
2,
18,
13,
17,
17,
14,
2,
... | [
[
98,
4
],
[
92,
8
],
[
99,
13
],
[
104,
15
],
[
93,
20
],
[
93,
26
],
[
101,
30
],
[
93,
35
],
[
93,
41
],
[
95,
45
],
[
93,
50
],
[
93,
56
],
[
89,
60
],
[
... | [
"import collections\n\ns=input()\na=collections.Counter(s)\nf=True\n\nif a['N']>0:\n\tif a['S']==0:\n\t\tf=False\n\t\t\nif a['S']>0:\n\tif a['N']==0:\n\t\tf=False\n\t\t\nif a['W']>0:\n\tif a['E']==0:\n\t\tf=False\n\t\t\nif a['E']>0:\n\tif a['W']==0:\n\t\tf=False\n\t\t\nif f:\n\tprint('Yes')\nelse:\n\tprint('No')",
... | import collections
s=input()
a=collections.Counter(s)
f=True
if a['N']>0:
if a['S']==0:
f=False
if a['S']>0:
if a['N']==0:
f=False
if a['W']>0:
if a['E']==0:
f=False
if a['E']>0:
if a['W']==0:
f=False
if f:
print('Yes')
else:
print('No') |
[
7,
0,
13,
4,
13,
0,
13,
17,
14,
2,
17,
13,
14,
40,
17,
13,
0,
13,
17,
14,
2,
17,
13,
14,
40,
17,
13,
0,
13,
17,
14,
2,
17,
13,
14,
40,
17,
13,
0,
13,
17,
14,
2,
17,
13,
14,
40,
17,
13,
0,
13,
17,
4,
13,
13,
... | [
[
68,
2
],
[
62,
6
],
[
69,
11
],
[
69,
15
],
[
65,
17
],
[
69,
22
],
[
69,
26
],
[
56,
28
],
[
69,
33
],
[
69,
37
],
[
71,
39
],
[
69,
44
],
[
69,
48
],
[
... | [
"S = input()\nres = \"Yes\"\nif \"N\" in S:\n if \"S\" not in S:\n res = \"No\"\nif \"W\" in S:\n if \"E\" not in S:\n res = \"No\"\nif \"S\" in S:\n if \"N\" not in S:\n res = \"No\"\nif \"E\" in S:\n if \"W\" not in S:\n res = \"No\"\nprint(res)",
"S = input()",
"S",
... | S = input()
res = "Yes"
if "N" in S:
if "S" not in S:
res = "No"
if "W" in S:
if "E" not in S:
res = "No"
if "S" in S:
if "N" not in S:
res = "No"
if "E" in S:
if "W" not in S:
res = "No"
print(res) |
[
7,
0,
13,
4,
13,
0,
13,
17,
0,
13,
17,
0,
13,
17,
0,
13,
17,
28,
13,
13,
14,
2,
13,
17,
14,
2,
13,
17,
14,
2,
13,
17,
14,
2,
13,
17,
14,
2,
2,
2,
2,
17,
13,
2,
17,
13,
2,
2,
13,
17,
2,
13,
17,
2,
2,
2,
17... | [
[
81,
2
],
[
75,
6
],
[
78,
9
],
[
84,
12
],
[
87,
15
],
[
19,
18
],
[
82,
18
],
[
18,
22
],
[
18,
26
],
[
18,
30
],
[
18,
34
],
[
76,
42
],
[
88,
45
],
[
7... | [
"S = input()\n\nn = 0\ne = 0\nw = 0\ns = 0\n\nfor v in S:\n if v == 'N': n+=1\n if v == 'E': e+=1\n if v == 'W': w+=1\n if v == 'S': s+=1\nif ((0<n and 0<s) or (n==0 and s==0)) and ((0<e and 0<w) or (e==0 and w==0)):\n print('Yes')\nelse:\n print('No')",
"S = input()",
"S",
"input()",
"inp... | S = input()
n = 0
e = 0
w = 0
s = 0
for v in S:
if v == 'N': n+=1
if v == 'E': e+=1
if v == 'W': w+=1
if v == 'S': s+=1
if ((0<n and 0<s) or (n==0 and s==0)) and ((0<e and 0<w) or (e==0 and w==0)):
print('Yes')
else:
print('No') |
[
7,
0,
13,
4,
13,
0,
13,
2,
2,
2,
17,
13,
2,
17,
13,
2,
40,
17,
13,
40,
17,
13,
0,
13,
2,
2,
2,
17,
13,
2,
17,
13,
2,
40,
17,
13,
40,
17,
13,
4,
13,
8,
2,
13,
13,
17,
17,
10,
2,
13,
10,
2,
13,
10,
4,
13
] | [
[
54,
2
],
[
48,
6
],
[
55,
11
],
[
55,
14
],
[
55,
18
],
[
55,
21
],
[
51,
23
],
[
55,
28
],
[
55,
31
],
[
55,
35
],
[
55,
38
],
[
49,
43
],
[
52,
44
],
[
... | [
"s = input()\n\nans1 = ((\"S\" in s) and (\"N\" in s)) or ((\"S\" not in s) and (\"N\" not in s))\nans2 = ((\"E\" in s) and (\"W\" in s)) or ((\"E\" not in s) and (\"W\" not in s))\n\nprint(\"Yes\" if ans1 and ans2 else \"No\")",
"s = input()",
"s",
"input()",
"input",
"ans1 = ((\"S\" in s) and (\"N\" in ... | s = input()
ans1 = (("S" in s) and ("N" in s)) or (("S" not in s) and ("N" not in s))
ans2 = (("E" in s) and ("W" in s)) or (("E" not in s) and ("W" not in s))
print("Yes" if ans1 and ans2 else "No") |
[
7,
0,
13,
4,
13,
0,
13,
2,
17,
13,
0,
13,
2,
17,
13,
0,
13,
2,
17,
13,
0,
13,
2,
17,
13,
0,
13,
2,
2,
13,
13,
2,
40,
13,
40,
13,
0,
13,
2,
2,
13,
13,
2,
40,
13,
40,
13,
14,
2,
13,
13,
4,
13,
17,
4,
13,
17... | [
[
70,
2
],
[
73,
6
],
[
71,
9
],
[
58,
11
],
[
71,
14
],
[
61,
16
],
[
71,
19
],
[
76,
21
],
[
71,
24
],
[
64,
26
],
[
74,
29
],
[
59,
30
],
[
74,
33
],
[
5... | [
"S = input()\nhas_N = \"N\" in S\nhas_S = \"S\" in S\nhas_E = \"E\" in S\nhas_W = \"W\" in S\nreachable_NS = has_N and has_S or not has_N and not has_S\nreachable_SW = has_E and has_W or not has_E and not has_W\nif reachable_NS and reachable_SW:\n print(\"Yes\")\nelse:\n print(\"No\")",
"S = input()",
"S"... | S = input()
has_N = "N" in S
has_S = "S" in S
has_E = "E" in S
has_W = "W" in S
reachable_NS = has_N and has_S or not has_N and not has_S
reachable_SW = has_E and has_W or not has_E and not has_W
if reachable_NS and reachable_SW:
print("Yes")
else:
print("No")
|
[
7,
0,
13,
4,
13,
0,
13,
4,
13,
13,
0,
13,
4,
13,
13,
0,
13,
39,
39,
17,
17,
39,
17,
17,
39,
17,
17,
17,
17,
4,
13,
8,
2,
13,
13,
17,
17,
10,
4,
13,
10,
4,
13,
10,
4,
13,
10,
39,
13
] | [
[
38,
2
],
[
44,
6
],
[
39,
9
],
[
41,
11
],
[
45,
14
],
[
39,
14
],
[
47,
16
],
[
42,
33
],
[
45,
33
],
[
39,
33
],
[
48,
34
],
[
38,
39
],
[
41,
42
],
[
4... | [
"s=input()\ns=set(s)\ns=sorted(s)\nans=[['E','W'],['N','S'],['E','N','S','W']]\nprint(\"Yes\" if s in ans else \"No\")",
"s=input()",
"s",
"input()",
"input",
"s=set(s)",
"s",
"set(s)",
"set",
"s",
"s=sorted(s)",
"s",
"sorted(s)",
"sorted",
"s",
"ans=[['E','W'],['N','S'],['E','N','S','... | s=input()
s=set(s)
s=sorted(s)
ans=[['E','W'],['N','S'],['E','N','S','W']]
print("Yes" if s in ans else "No") |
[
7,
15,
15,
15,
15,
15,
15,
13,
15,
13,
4,
18,
13,
13,
17,
0,
13,
2,
2,
17,
17,
17,
12,
13,
29,
4,
13,
4,
13,
13,
4,
18,
4,
13,
13,
12,
13,
0,
13,
4,
13,
0,
13,
4,
18,
13,
13,
17,
0,
13,
4,
18,
13,
13,
17,
0... | [
[
121,
16
],
[
39,
38
],
[
43,
42
],
[
38,
45
],
[
50,
49
],
[
38,
52
],
[
57,
56
],
[
38,
59
],
[
64,
63
],
[
38,
66
],
[
116,
113
],
[
121,
122
]
] | [
"from statistics import median\n#import collections\n#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]\nfrom fractions import gcd\nfrom itertools import combinations # (string,3) 3回\nfrom collections import deque\nfrom collections import defaultdict\nimport bisect\n#\n# d = m - k... | from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
# d = m - k[i] - k[j]
# ... |
[
7,
0,
13,
4,
13,
0,
13,
4,
13,
13,
4,
13,
8,
2,
2,
2,
13,
4,
13,
17,
2,
13,
4,
13,
17,
2,
13,
4,
13,
17,
17,
17,
10,
4,
13,
10,
4,
13
] | [
[
36,
2
],
[
33,
6
],
[
37,
9
],
[
34,
16
],
[
34,
21
],
[
34,
26
],
[
33,
34
],
[
36,
37
]
] | [
"s = input();\n\nst = set(s)\nprint(\"Yes\" if st == set(\"WE\") or st == set(\"NS\") or st == set(\"SENW\") else \"No\")",
"s = input()",
"s",
"input()",
"input",
"st = set(s)",
"st",
"set(s)",
"set",
"s",
"print(\"Yes\" if st == set(\"WE\") or st == set(\"NS\") or st == set(\"SENW\") else \"No... | s = input();
st = set(s)
print("Yes" if st == set("WE") or st == set("NS") or st == set("SENW") else "No") |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.