{"problem":{"name":"Candy Retribution","description":{"content":"Find the number of sequences of $N$ non-negative integers $A_1, A_2, ..., A_N$ that satisfy the following conditions: *   $L \\leq A_1 + A_2 + ... + A_N \\leq R$ *   When the $N$ elements are sorted in","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"jsc2019_qual_f"},"statements":[{"statement_type":"Markdown","content":"Find the number of sequences of $N$ non-negative integers $A_1, A_2, ..., A_N$ that satisfy the following conditions:\n\n*   $L \\leq A_1 + A_2 + ... + A_N \\leq R$\n*   When the $N$ elements are sorted in non-increasing order, the $M$\\-th and $(M+1)$\\-th elements are equal.\n\nSince the answer can be enormous, print it modulo $10^9+7$.\n\n## Constraints\n\n*   All values in input are integers.\n*   $1 \\leq M < N \\leq 3 \\times 10^5$\n*   $1 \\leq L \\leq R \\leq 3 \\times 10^5$\n\n## Input\n\nInput is given from Standard Input in the following format:\n\n$N$ $M$ $L$ $R$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"jsc2019_qual_f","tags":[],"sample_group":[["4 2 3 7","105\n\nThe sequences of non-negative integers that satisfy the conditions are:\n$\\begin{aligned} &(1, 1, 1, 0), (1, 1, 1, 1), (2, 1, 1, 0), (2, 1, 1, 1), (2, 2, 2, 0), (2, 2, 2, 1), \\\\ &(3, 0, 0, 0), (3, 1, 1, 0), (3, 1, 1, 1), (3, 2, 2, 0), (4, 0, 0, 0), (4, 1, 1, 0), \\\\ &(4, 1, 1, 1), (5, 0, 0, 0), (5, 1, 1, 0), (6, 0, 0, 0), (7, 0, 0, 0)\\end{aligned}$\nand their permutations, for a total of $105$ sequences."],["2 1 4 8","3\n\nThe three sequences that satisfy the conditions are $(2, 2)$, $(3, 3)$, and $(4, 4)$."],["141592 6535 89793 238462","933832916"]],"created_at":"2026-03-03 11:01:14"}}