• + 1 comment

    Solution without math namespace, Python3:

    def solve(n, m):
        result = 1
        a = min(m-1, n)
        b = max(m-1, n)
        for i in range(1, b + 1):
            result *= (a + i)
            
        for j in range(1, b + 1):
            result //= j
            
        return result % (10**9 + 7)