atcoder#AGC049D. [AGC049D] Convex Sequence

[AGC049D] Convex Sequence

Score : 10001000 points

Problem Statement

Given are integers NN and MM. Find the number, modulo (109+7)(10^9+7), of length-NN sequences (A1,A2,,AN)(A_1,A_2,\ldots,A_N) that consist of non-negative integers and satisfy the following conditions:

  • A1+A2++AN=MA_1+A_2+\ldots +A_N = M;
  • For every ii (2iN12 \leq i \leq N-1), 2AiAi1+Ai+12 A_i \leq A_{i-1} + A_{i+1}.

Constraints

  • 1N1051 \leq N \leq 10^5
  • 1M1051 \leq M \leq 10^5
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN MM

Output

Print the number, modulo (109+7)(10^9+7), of sequences that satisfy the conditions.

3 3
7

The following seven sequences satisfy the conditions.

  • 0,0,30,0,3
  • 0,1,20,1,2
  • 1,0,21,0,2
  • 1,1,11,1,1
  • 2,0,12,0,1
  • 2,1,02,1,0
  • 3,0,03,0,0
10 100
10804516
10000 100000
694681734