{"problem":{"name":"F. Forever Young","description":{"content":"Welcome to ACM Class! ACM Class has s students (1 ≤ s ≤ 106) of different ages, lined up along the wall to take attendance. The instructors Henry and Eugene each go from left to right and tick off eve","description_type":"Markdown"},"platform":"Codeforces","limit":{"time_limit":1000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"CF10231F"},"statements":[{"statement_type":"Markdown","content":"Welcome to ACM Class! ACM Class has s students (1 ≤ s ≤ 106) of different ages, lined up along the wall to take attendance. The instructors Henry and Eugene each go from left to right and tick off everybody's name. They are bored of this menial task so they decide to play a game. \n\nAs Henry goes from left to right, he circles some students' names, following the rule that each student (after the first) is _older_ than the last one he circled. Eugene circles some students' names so that each student is _younger_ than the last one he circled. They are quite competitive, so using their  they each circle as many names as possible, as they know every student's age. \n\nThey will be very happy if Henry circles exactly n (1 ≤ n ≤ s) names and Eugene circles exactly m (1 ≤ m ≤ s), their respective favourite numbers. Furthermore, they are quite high achievers so cumulatively they are hoping to circle lots of names. Thus n + m ≥ s - 50.\n\nThe class lines up differently every day. (Two lineups are different if at least one student is in a different position.) You'd like to keep Henry and Eugene happy for as long as possible to keep them from moving onto their next plan of starting World War 3. How long can you do this? \n\nThe single line of input contains three space-separated integers s, n, and m (1 ≤ n, m ≤ s ≤ 106). It is guaranteed that n + m ≥ s - 50.\n\nOutput the number of arrangements of the class that will make Henry and Eugene happy. This number can be quite large so output it modulo 109 + 7.\n\n## Input\n\nThe single line of input contains three space-separated integers s, n, and m (1 ≤ n, m ≤ s ≤ 106). It is guaranteed that n + m ≥ s - 50.\n\n## Output\n\nOutput the number of arrangements of the class that will make Henry and Eugene happy. This number can be quite large so output it modulo 109 + 7.\n\n[samples]","is_translate":false,"language":"English"},{"statement_type":"Markdown","content":"**Definitions**  \nLet $ s, n, m \\in \\mathbb{Z}^+ $ with $ 1 \\le n, m \\le s \\le 10^6 $ and $ n + m \\ge s - 50 $.  \nLet $ A = (a_1, a_2, \\dots, a_s) $ be a permutation of $ s $ distinct ages (without loss of generality, $ \\{1, 2, \\dots, s\\} $).\n\n**Constraints**  \n1. Henry selects a strictly increasing subsequence (by age) of length exactly $ n $, starting from the left, greedily.  \n2. Eugene selects a strictly decreasing subsequence (by age) of length exactly $ m $, starting from the left, greedily.  \n3. The union of the positions selected by Henry and Eugene covers at least $ s - 50 $ students: $ n + m \\ge s - 50 $.  \n\n**Objective**  \nCount the number of permutations $ A $ of $ \\{1, 2, \\dots, s\\} $ such that:  \n- The length of the longest increasing subsequence (LIS) starting from the left (greedily) is exactly $ n $,  \n- The length of the longest decreasing subsequence (LDS) starting from the left (greedily) is exactly $ m $,  \nand output the count modulo $ 10^9 + 7 $.","is_translate":false,"language":"Formal"}],"meta":{"iden":"CF10231F","tags":[],"sample_group":[],"created_at":"2026-03-03 11:00:39"}}