Problem:
Score : 600 points

Problem Statement

Let us define the oddness of a permutation p = {p_1,\ p_2,\ ...,\ p_n} of {1,\ 2,\ ...,\ n} as \sum_{i = 1}^n |i - p_i|.

Find the number of permutations of {1,\ 2,\ ...,\ n} of oddness k, modulo 10^9+7.

Constraints

All values in input are integers.

1 \leq n \leq 50

0 \leq k \leq n^2

Input

Input is given from Standard Input in the following format:

n k

Output

Print the number of permutations of {1,\ 2,\ ...,\ n} of oddness k, modulo 10^9+7.

Sample Input 1

3 2

Sample Output 1

2

There are six permutations of {1,\ 2,\ 3}. Among them, two have oddness of 2: {2,\ 1,\ 3} and {1,\ 3,\ 2}.

Sample Input 2

39 14

Sample Output 2

74764168

Solution in Kotlin (1.0.0) (judge verdict: Runtime Error)

fun main(args: Array<String>) {
    val (n, k) = readLine()!!.split(' ').map(String::toInt)
    val dp = Array(n+1){Array(n+1){Array<Int>(k + 2){-1}}}
    val mod = 1000000000 + 7
    dp[0][0][0] = 1
    dp[0][1][2] = 1
    // i n -> 0, j 0 -> 増減 < i+1, k k -> 0
    fun calc(i: Int, j: Int, k: Int): Int{
        if(k < 0) return 0
        if(i < j - 1) return 0
        if(j < 0) return 0
        if(i < 0) return 0
        if(dp[i][j][k] != -1) return dp[i][j][k]
        if(i == 0) return 0

        val ret = (((2 * j + 1).toLong() * calc(i-1, j, k - 2 * j) +
                (j + 1) * (j + 1).toLong() * calc(i-1, j + 1, k - 2 * j) +
                calc(i-1, j - 1, k - 2 * j)) % mod).toInt()
        dp[i][j][k] = ret
        return ret
    }
    val ret = calc(n-1, 0, k)
    print(ret)
}