Problem:
Score : 400 points

Problem Statement

You are given positive integers N and M.

How many sequences a of length N consisting of positive integers satisfy a_1 \times a_2 \times ... \times a_N = M? Find the count modulo 10^9+7.

Here, two sequences a' and a'' are considered different when there exists some i such that a_i' \neq a_i''.

Constraints

All values in input are integers.

1 \leq N \leq 10^5

1 \leq M \leq 10^9

Input

Input is given from Standard Input in the following format:

N M

Output

Print the number of the sequences consisting of positive integers that satisfy the condition, modulo 10^9 + 7.

Sample Input 1

2 6

Sample Output 1

4

Four sequences satisfy the condition: \{a_1, a_2\} = \{1, 6\}, \{2, 3\}, \{3, 2\} and \{6, 1\}.

Sample Input 2

3 12

Sample Output 2

18

Sample Input 3

100000 1000000000

Sample Output 3

957870001

Solution in Rust (1.15.1) (judge verdict: Wrong Answer)

#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

pub mod modular {
    const M: i64 = 1000000007;

    #[derive(Debug, Clone, Copy, Default, PartialOrd, Ord, PartialEq, Eq)]
    pub struct Mod(i64);

    impl ::std::fmt::Display for Mod {
        fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
            write!(f, "{}", self.0)
        }
    }

    impl Mod {
        pub fn new(v: i64) -> Mod {
            Mod(v % M)
        }

        pub fn pow(self, mut r: i64) -> Mod {
            let mut k = self;
            let mut ret = 1.into();

            while r > 0 {
                if r % 2 != 0 {
                    ret = ret * k;
                }
                r /= 2;
                k = k * k;
            }

            ret
        }

        // This requires M is prime
        pub fn recip(self) -> Mod {
            self.pow(M - 2)
        }
    }

    use std::ops::*;

    impl<T: Into<Mod>> Add<T> for Mod {
        type Output = Mod;
        fn add(self, rhs: T) -> Self::Output {
            Mod::new(self.0 + rhs.into().0)
        }
    }
    impl<T: Into<Mod>> AddAssign<T> for Mod {
        fn add_assign(&mut self, rhs: T) {
            *self = *self + rhs;
        }
    }

    impl<T: Into<Mod>> Sub<T> for Mod {
        type Output = Mod;
        fn sub(self, rhs: T) -> Self::Output {
            Mod::new(self.0 - rhs.into().0 + M)
        }
    }
    impl<T: Into<Mod>> SubAssign<T> for Mod {
        fn sub_assign(&mut self, rhs: T) {
            *self = *self - rhs;
        }
    }

    impl<T: Into<Mod>> Mul<T> for Mod {
        type Output = Mod;
        fn mul(self, rhs: T) -> Self::Output {
            Mod::new(self.0 * rhs.into().0)
        }
    }
    impl<T: Into<Mod>> MulAssign<T> for Mod {
        fn mul_assign(&mut self, rhs: T) {
            *self = *self * rhs;
        }
    }

    impl<T: Into<Mod>> Div<T> for Mod {
        type Output = Mod;
        fn div(self, rhs: T) -> Self::Output {
            self * rhs.into().recip()
        }
    }
    impl<T: Into<Mod>> DivAssign<T> for Mod {
        fn div_assign(&mut self, rhs: T) {
            *self = *self / rhs;
        }
    }

    impl Neg for Mod {
        type Output = Mod;
        fn neg(self) -> Self::Output {
            Mod(0) - self
        }
    }

    impl<T: ::std::convert::Into<i64>> ::std::convert::From<T> for Mod {
        fn from(v: T) -> Self {
            Mod::new(v.into())
        }
    }
}

use modular::Mod;
use std::collections::{BTreeSet, HashMap};

fn main() {
    input!{
        n: usize,
        m: i64,
    }

    let mut sieve = vec![true; (n as f64).sqrt().ceil() as usize + 100];
    let mut primes = vec![];

    for i in 2..sieve.len() {
        if sieve[i] {
            primes.push(i as i32);
            let mut j = i + i;
            while j < sieve.len() {
                sieve[j] = false;
                j += i;
            }
        }
    }

    let mut fs = vec![];
    let mut nn = m as i32;

    for &p in primes.iter() {
        while nn % p == 0 {
            fs.push(p);
            nn /= p;
        }
    }

    if nn > 1 {
        fs.push(nn);
    }

    let mut ds = BTreeSet::new();
    for b in 1..(1 << fs.len()) {
        let mut d = 1;
        for i in 0..fs.len() {
            if b & (1 << i) != 0 {
                d *= fs[i];
            }
        }
        ds.insert(d);
    }

    let ds = ds.into_iter().collect::<Vec<_>>();

    // println!("ps: {:?}", primes);
    // println!("fs: {:?}", fs);
    // println!("ds: {:?}", ds);

    let mut tbl = HashMap::new();

    let ans = solve(m as i32, n as i32, n as i32, &ds, &mut tbl);

    println!("{}", ans);
}

fn solve(m: i32, rest: i32, n: i32, ds: &Vec<i32>, tbl: &mut HashMap<(i32, i32), Mod>) -> Mod {
    if let Some(v) = tbl.get(&(m, rest)) {
        return *v;
    }

    if rest < 0 {
        return 0.into();
    }

    if m == 1 {
        let v = comb(rest, n);
        tbl.insert((m, rest), v);
        return v;
    }

    let mut ret = 0.into();

    for f in ds.iter() {
        if m % f != 0 {
            continue;
        }
        ret += solve(m / f, rest - 1, n, ds, tbl);
    }

    tbl.insert((m, rest), ret);
    ret
}

fn comb(a: i32, b: i32) -> Mod {
    if a == 0 {
        return 1.into();
    }
    if a > b {
        return 0.into();
    }

    let a2 = b - a;
    if a2 < a {
        comb(a2, b)
    } else {
        let t = comb(a-1,b-1);
        t*b/a
    }
}