Problem:


Combination of Number Sequences

0 から 9 までの整数を使った n 個の数の並び k1, k2, ..., kn を考えます。正の整数 n と s を読み込んで、

k1 + 2 &times; k2 + 3 &times; k3 + ... + n &times; kn = s 

となっているような n 個の数の並びが何通りあるかを出力するプログラムを作成してください。ただし、1 つの「n 個の数の並び」には同じ数が 2 回以上現われないものとします。

Input

入力は複数のデータセットからなります。各データセットとして、n (1 ≤ n ≤ 10) と s (0 ≤ s ≤ 10,000)が空白区切りで１行に与えられます。

データセットの数は 100 を超えません。

Output

データセットごとに、n 個の整数の和が s になる組み合わせの個数を１行に出力します。

Sample Input

3 10
3 1

Output for the Sample Input

8
0



Sample input:
3 10
3 1


Sample output:
8
0

Submission status: Accepted

Solution code:
ans=[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 5, 7, 13, 22, 25, 32, 49, 52, 62, 76, 88, 91, 119, 114, 146, 160, 170, 172, 231, 223, 249, 269, 298, 297, 372, 326, 375, 404, 407, 424, 484, 464,481, 514, 553, 533, 581, 554, 589, 653, 597, 601, 657, 630, 647, 660, 643, 643, 660, 647, 630, 657, 601,597, 653, 589, 554, 581, 533, 553, 514, 481, 464, 484, 424, 407, 404, 375, 326, 372, 297, 298, 269, 249,223, 231, 172, 170, 160, 146, 114, 119, 91, 88, 76, 62, 52, 49, 32, 25, 22, 13, 7, 5, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 6, 11, 19, 38, 44, 62, 88, 106, 124, 170, 188, 221, 271, 276, 323, 397, 395, 438, 533, 544, 568, 687, 694, 769, 861, 893, 942, 1114, 1078, 1180, 1293, 1342, 1351, 1574, 1491, 1640, 1748, 1775, 1764, 2029, 1920, 2026, 2162, 2178, 2191, 2430, 2292, 2383, 2552, 2488, 2488, 2709, 2583, 2598, 2777, 2618, 2659, 2841, 2657, 2657, 2841, 2659, 2618, 2777, 2598, 2583, 2709, 2488, 2488, 2552, 2383, 2292, 2430, 2191, 2178, 2162, 2026, 1920, 2029, 1764, 1775, 1748, 1640, 1491, 1574, 1351, 1342, 1293, 1180, 1078, 1114, 942, 893,861, 769, 694, 687, 568, 544, 533, 438, 395, 397, 323, 276, 271, 221, 188, 170, 124, 106, 88, 62, 44, 38, 19, 11, 6, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 7, 16, 28, 59, 75, 109, 151, 206, 234, 335, 360, 467, 529, 630, 675, 896, 878, 1053, 1141, 1340, 1294, 1632, 1571, 1895, 1896, 2184, 2129, 2632, 2485, 2926, 2909, 3356, 3190, 3911, 3583, 4259, 4158, 4663, 4477, 5370, 4886, 5622, 5475, 6171, 5776, 6772, 6186, 7073, 6776, 7435, 6953, 8178, 7344, 8270, 7927, 8551, 8030, 9184, 8285, 9227, 8758, 9408, 8650, 9937, 8868, 9716, 9281, 9870, 9035, 10092, 9035, 9870, 9281, 9716, 8868, 9937, 8650, 9408, 8758, 9227,8285, 9184, 8030, 8551, 7927, 8270, 7344, 8178, 6953, 7435, 6776, 7073, 6186, 6772, 5776, 6171, 5475, 5622, 4886, 5370, 4477, 4663, 4158, 4259, 3583, 3911, 3190, 3356, 2909, 2926, 2485, 2632, 2129, 2184, 1896,1895, 1571, 1632, 1294, 1340, 1141, 1053, 878, 896, 675, 630, 529, 467, 360, 335, 234, 206, 151, 109, 75, 59, 28, 16, 7, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 8, 22, 40, 83, 122, 173, 248, 350, 408, 575, 669, 842, 963, 1211, 1264, 1652, 1767, 2083, 2248, 2752, 2671, 3274, 3352, 3928, 3978, 4624, 4554, 5428, 5384, 6115, 6158, 7195, 6897, 8052, 7886, 8928, 8772, 10083, 9670, 11309, 10830, 12110, 11865, 13681, 12871, 14740, 14098, 15900, 15138, 17241, 15947, 18464, 17353, 19307, 18345, 20745, 18949, 21681, 20236, 22624, 21027, 23607, 21467, 24536, 22553, 24793, 23187, 26012, 23373, 26355, 24094, 26581, 24463, 27187, 24377, 27453, 24768, 27006, 24768, 27453, 24377, 27187, 24463, 26581, 24094, 26355, 23373, 26012, 23187, 24793, 22553, 24536, 21467, 23607, 21027, 22624, 20236, 21681, 18949, 20745, 18345, 19307, 17353, 18464, 15947, 17241, 15138, 15900, 14098, 14740, 12871, 13681, 11865, 12110, 10830, 11309, 9670, 10083, 8772, 8928, 7886, 8052, 6897, 7195, 6158, 6115, 5384, 5428, 4554, 4624, 3978, 3928, 3352, 3274, 2671, 2752, 2248, 2083, 1767, 1652, 1264, 1211, 963, 842, 669, 575, 408, 350, 248, 173, 122, 83, 40, 22, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 9, 28, 51, 107, 177, 234, 360, 498, 619, 819, 1040, 1252, 1528, 1824, 2010, 2533, 2837, 3180, 3676, 4305, 4493, 5130, 5672, 6156, 6909, 7424, 7830, 8773, 9392, 9892, 10678, 11647, 12141, 13026, 13918, 14519, 15611, 16278, 16780, 18686, 19280, 19586, 20795, 22385, 22896, 23948, 24970, 26012, 27096, 28467, 28427, 30540, 31272, 31774, 33264, 34748, 34499, 36299, 36596, 38456, 38926, 39984, 39386, 42068, 42848, 42424, 42925, 45044, 44584, 46040, 45496, 46890, 47036, 47341, 47646, 48887, 48840, 48044, 48540, 50066, 48970, 49062, 49062, 48970, 50066, 48540, 48044, 48840, 48887, 47646, 47341, 47036, 46890, 45496, 46040, 44584, 45044, 42925, 42424, 42848, 42068, 39386, 39984, 38926, 38456, 36596, 36299, 34499, 34748, 33264, 31774, 31272, 30540, 28427, 28467, 27096, 26012, 24970, 23948, 22896, 22385, 20795, 19586, 19280, 18686, 16780, 16278, 15611, 14519, 13918, 13026, 12141, 11647, 10678, 9892, 9392, 8773, 7830, 7424, 6909, 6156, 5672, 5130, 4493, 4305, 3676, 3180, 2837, 2533, 2010, 1824, 1528, 1252, 1040, 819, 619, 498, 360, 234, 177, 107, 51, 28, 9, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 9, 28, 51, 107, 177, 234,360, 498, 619, 819, 1040, 1252, 1528, 1824, 2010, 2533, 2837, 3180, 3676, 4305, 4493, 5130, 5672, 6156, 6909, 7424, 7830, 8773, 9392, 9892, 10678, 11647, 12141, 13026, 13918, 14519, 15611, 16278, 16780, 18686,19280, 19586, 20795, 22385, 22896, 23948, 24970, 26012, 27096, 28467, 28427, 30540, 31272, 31774, 33264,34748, 34499, 36299, 36596, 38456, 38926, 39984, 39386, 42068, 42848, 42424, 42925, 45044, 44584, 46040,45496, 46890, 47036, 47341, 47646, 48887, 48840, 48044, 48540, 50066, 48970, 49062, 49062, 48970, 50066,48540, 48044, 48840, 48887, 47646, 47341, 47036, 46890, 45496, 46040, 44584, 45044, 42925, 42424, 42848,42068, 39386, 39984, 38926, 38456, 36596, 36299, 34499, 34748, 33264, 31774, 31272, 30540, 28427, 28467,27096, 26012, 24970, 23948, 22896, 22385, 20795, 19586, 19280, 18686, 16780, 16278, 15611, 14519, 13918,13026, 12141, 11647, 10678, 9892, 9392, 8773, 7830, 7424, 6909, 6156, 5672, 5130, 4493, 4305, 3676, 3180, 2837, 2533, 2010, 1824, 1528, 1252, 1040, 819, 619, 498, 360, 234, 177, 107, 51, 28, 9, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]]
while True:
    try:
        n, s = map(int, input().split())
    except EOFError:
        break
    if s>330:
        print(0)
    else:
        print(ans[n][s])

Submission status: Accepted

Solution code:
ans=[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 0, 0, 0, 0, 1, 5, 7, 13, 22, 25, 32, 49, 52, 62, 76, 88, 91, 119, 114, 146, 160, 170, 172, 231, 223, 249, 269, 298, 297, 372, 326, 375, 404, 407, 424, 484, 464,481, 514, 553, 533, 581, 554, 589, 653, 597, 601, 657, 630, 647, 660, 643, 643, 660, 647, 630, 657, 601,597, 653, 589, 554, 581, 533, 553, 514, 481, 464, 484, 424, 407, 404, 375, 326, 372, 297, 298, 269, 249,223, 231, 172, 170, 160, 146, 114, 119, 91, 88, 76, 62, 52, 49, 32, 25, 22, 13, 7, 5, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 6, 11, 19, 38, 44, 62, 88, 106, 124, 170, 188, 221, 271, 276, 323, 397, 395, 438, 533, 544, 568, 687, 694, 769, 861, 893, 942, 1114, 1078, 1180, 1293, 1342, 1351, 1574, 1491, 1640, 1748, 1775, 1764, 2029, 1920, 2026, 2162, 2178, 2191, 2430, 2292, 2383, 2552, 2488, 2488, 2709, 2583, 2598, 2777, 2618, 2659, 2841, 2657, 2657, 2841, 2659, 2618, 2777, 2598, 2583, 2709, 2488, 2488, 2552, 2383, 2292, 2430, 2191, 2178, 2162, 2026, 1920, 2029, 1764, 1775, 1748, 1640, 1491, 1574, 1351, 1342, 1293, 1180, 1078, 1114, 942, 893,861, 769, 694, 687, 568, 544, 533, 438, 395, 397, 323, 276, 271, 221, 188, 170, 124, 106, 88, 62, 44, 38, 19, 11, 6, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 7, 16, 28, 59, 75, 109, 151, 206, 234, 335, 360, 467, 529, 630, 675, 896, 878, 1053, 1141, 1340, 1294, 1632, 1571, 1895, 1896, 2184, 2129, 2632, 2485, 2926, 2909, 3356, 3190, 3911, 3583, 4259, 4158, 4663, 4477, 5370, 4886, 5622, 5475, 6171, 5776, 6772, 6186, 7073, 6776, 7435, 6953, 8178, 7344, 8270, 7927, 8551, 8030, 9184, 8285, 9227, 8758, 9408, 8650, 9937, 8868, 9716, 9281, 9870, 9035, 10092, 9035, 9870, 9281, 9716, 8868, 9937, 8650, 9408, 8758, 9227,8285, 9184, 8030, 8551, 7927, 8270, 7344, 8178, 6953, 7435, 6776, 7073, 6186, 6772, 5776, 6171, 5475, 5622, 4886, 5370, 4477, 4663, 4158, 4259, 3583, 3911, 3190, 3356, 2909, 2926, 2485, 2632, 2129, 2184, 1896,1895, 1571, 1632, 1294, 1340, 1141, 1053, 878, 896, 675, 630, 529, 467, 360, 335, 234, 206, 151, 109, 75, 59, 28, 16, 7, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 8, 22, 40, 83, 122, 173, 248, 350, 408, 575, 669, 842, 963, 1211, 1264, 1652, 1767, 2083, 2248, 2752, 2671, 3274, 3352, 3928, 3978, 4624, 4554, 5428, 5384, 6115, 6158, 7195, 6897, 8052, 7886, 8928, 8772, 10083, 9670, 11309, 10830, 12110, 11865, 13681, 12871, 14740, 14098, 15900, 15138, 17241, 15947, 18464, 17353, 19307, 18345, 20745, 18949, 21681, 20236, 22624, 21027, 23607, 21467, 24536, 22553, 24793, 23187, 26012, 23373, 26355, 24094, 26581, 24463, 27187, 24377, 27453, 24768, 27006, 24768, 27453, 24377, 27187, 24463, 26581, 24094, 26355, 23373, 26012, 23187, 24793, 22553, 24536, 21467, 23607, 21027, 22624, 20236, 21681, 18949, 20745, 18345, 19307, 17353, 18464, 15947, 17241, 15138, 15900, 14098, 14740, 12871, 13681, 11865, 12110, 10830, 11309, 9670, 10083, 8772, 8928, 7886, 8052, 6897, 7195, 6158, 6115, 5384, 5428, 4554, 4624, 3978, 3928, 3352, 3274, 2671, 2752, 2248, 2083, 1767, 1652, 1264, 1211, 963, 842, 669, 575, 408, 350, 248, 173, 122, 83, 40, 22, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 9, 28, 51, 107, 177, 234, 360, 498, 619, 819, 1040, 1252, 1528, 1824, 2010, 2533, 2837, 3180, 3676, 4305, 4493, 5130, 5672, 6156, 6909, 7424, 7830, 8773, 9392, 9892, 10678, 11647, 12141, 13026, 13918, 14519, 15611, 16278, 16780, 18686, 19280, 19586, 20795, 22385, 22896, 23948, 24970, 26012, 27096, 28467, 28427, 30540, 31272, 31774, 33264, 34748, 34499, 36299, 36596, 38456, 38926, 39984, 39386, 42068, 42848, 42424, 42925, 45044, 44584, 46040, 45496, 46890, 47036, 47341, 47646, 48887, 48840, 48044, 48540, 50066, 48970, 49062, 49062, 48970, 50066, 48540, 48044, 48840, 48887, 47646, 47341, 47036, 46890, 45496, 46040, 44584, 45044, 42925, 42424, 42848, 42068, 39386, 39984, 38926, 38456, 36596, 36299, 34499, 34748, 33264, 31774, 31272, 30540, 28427, 28467, 27096, 26012, 24970, 23948, 22896, 22385, 20795, 19586, 19280, 18686, 16780, 16278, 15611, 14519, 13918, 13026, 12141, 11647, 10678, 9892, 9392, 8773, 7830, 7424, 6909, 6156, 5672, 5130, 4493, 4305, 3676, 3180, 2837, 2533, 2010, 1824, 1528, 1252, 1040, 819, 619, 498, 360, 234, 177, 107, 51, 28, 9, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 9, 28, 51, 107, 177, 234,360, 498, 619, 819, 1040, 1252, 1528, 1824, 2010, 2533, 2837, 3180, 3676, 4305, 4493, 5130, 5672, 6156, 6909, 7424, 7830, 8773, 9392, 9892, 10678, 11647, 12141, 13026, 13918, 14519, 15611, 16278, 16780, 18686,19280, 19586, 20795, 22385, 22896, 23948, 24970, 26012, 27096, 28467, 28427, 30540, 31272, 31774, 33264,34748, 34499, 36299, 36596, 38456, 38926, 39984, 39386, 42068, 42848, 42424, 42925, 45044, 44584, 46040,45496, 46890, 47036, 47341, 47646, 48887, 48840, 48044, 48540, 50066, 48970, 49062, 49062, 48970, 50066,48540, 48044, 48840, 48887, 47646, 47341, 47036, 46890, 45496, 46040, 44584, 45044, 42925, 42424, 42848,42068, 39386, 39984, 38926, 38456, 36596, 36299, 34499, 34748, 33264, 31774, 31272, 30540, 28427, 28467,27096, 26012, 24970, 23948, 22896, 22385, 20795, 19586, 19280, 18686, 16780, 16278, 15611, 14519, 13918,13026, 12141, 11647, 10678, 9892, 9392, 8773, 7830, 7424, 6909, 6156, 5672, 5130, 4493, 4305, 3676, 3180, 2837, 2533, 2010, 1824, 1528, 1252, 1040, 819, 619, 498, 360, 234, 177, 107, 51, 28, 9, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]]
while True:
	try:
		n, s = map(int, input().split())
	except EOFError:
		break
	if s>330:
		print(0)
	else:
		print(ans[n][s])

Submission status: Runtime Error

Solution code:
from itertools import combinations
import sys

# dp[n][使った数字(bit)][合計] = count
dp = [[[0]*331 for _ in [0]*2048] for _ in [0]*11]
for i in range(11):
    dp[1][2**i][i] = 1

for i in range(2, 11):
    for used in (sum(comb) for comb in combinations([2**n for n in range(10)], i-1)):
        for j in filter(lambda x: used & 2**x == 0, range(10)):
            for total, count in filter(lambda p: p[1]>0, enumerate(dp[i-1][used])):
                dp[i][used|2**j][total+j*i] += count

for n, s in (map(int, l.rstrip().split()) for l in sys.stdin):
    print(sum(a[s] for a in dp[n] if a[s]))

Submission status: Runtime Error

Solution code:

def is_prime2(q,k=100):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    for i in xrange(3,k):
        x,y = q,i
        while y:
            x, y =  y, x % y
        if x != 1: continue
        if pow(i, q-1, q) != 1:
            return False
    return True
if __name__ == "__main__":
    while True:
        n = input()
        if (n == 0):
            break
        if (n < 19):
            print 13
        else:
            tmp = int((n - 19) / 30)
            if tmp == 0:
                print 19
            while tmp > 0:
                x = 30 * tmp + 19
                if (is_prime2(x) and is_prime2(x - 2) and is_prime2(x - 6) and is_prime2(x - 8)):
                    print x
                    break
                tmp -= 1

Submission status: Runtime Error

Solution code:

def is_prime2(q,k=100):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    for i in xrange(3,k):
        x,y = q,i
        while y:
            x, y =  y, x % y
        if x != 1: continue
        if pow(i, q-1, q) != 1:
            return False
    return True
if __name__ == "__main__":
    while True:
        n = input()
        break
        if (n == 0):
            break
        if (n < 19):
            print 13
        else:
            tmp = int((n - 19) / 30)
            while tmp > 0:
                x = 30 * tmp + 19
                if (is_prime2(x) and is_prime2(x - 2) and is_prime2(x - 6) and is_prime2(x - 8)):
                    print x
                    break
                tmp -= 1

Submission status: Runtime Error

Solution code:
import sys
import itertools
import time

start = time.time()
lis = []
for i in xrange(1,10):
    count = 0
    numbers = [0]*331
    for e in itertools.permutations(range(10),i):
        li = [ (j+1)*e[j] for j in xrange(len(e))]
        numbers[sum(li)] += 1
    lis.append(numbers)


for s in sys.stdin:
    n,s = map(int,s.split())
    print lis[n-1][s]

Submission status: Runtime Error

Solution code:
import sys
def line():return sys.stdin.readline().strip()

import itertools
k = (0,1,2,3,4,5,6,7,8,9)
for ln in line():
    cnt = 0
    n,s = map(int,ln.split())
    for l in list(itertools.permutations(k,n)):
        t = 0
        for i in range(len(l)): t+=l[i] * (i + 1)
        if t == s:cnt+=1
    print(cnt)

Submission status: Runtime Error

Solution code:
import sys
import itertools
for line in sys.stdin:
	exit(1)
	n,s=map(int,input().split())
	cnt=0
	for i in itertools.permutations(range(10),n):
		sum=0
		for j,k in enumerate(i):sum+=(j+1)*k
		if sum==s:cnt+=1
	print(cnt)