Surjective functions count
Your task
Count the number of surjective (onto) functions from a set of size n to a set of size m, i.e. functions that hit every one of the m targets at least once. Return the count modulo 1_000_000_007. If m > n the answer is 0; n,m can be up to a few thousand.
Examples
count_surjections(n: int, m: int) -> intExample 1
Input
count_surjections(3, 2)Output
6