simple-math-1
Source: hackerearth
Difficulty: EASY

Find the number of ways of distributing N objects into R groups such that each group gets 1 or more objects.

Input:
The one and only line of input contains two numbers separated by a single space, which are N and R respectively.

Output:
The corresponding answer modulo 10000007 in a  single line and if no answer exist then print "-1".

Constraints:
1 ≤ N ≤ 100
1 ≤ R ≤ 100  

SAMPLE INPUT
4 2

SAMPLE OUTPUT
3

Explanation

Let the 2 groups be A and B respectively.
Case 1: A gets 1 object and B gets 3
Case 2: A gets 2 objects and B gets 2
Case 3: A gets 3 objects and B gets 1


import math

a,b=list(map(int,input().split()))
if(a>=b):
	a=a-1
	b=b-1
	i=math.factorial(a)
	j=math.factorial(b)
	k=math.factorial(a-b)
	ans=i/(j*k)
	print(ans%10000007)
else:
	print('-1')



import math

def nCr(n,r):
	f = math.factorial
	return f(n) / f(r) / f(n-r)

x=input("");
x=x.split(" ");
n=int(x[0])
r=int(x[1])

if (n<r):
	print("-1")
elif (n==r):
	print("1")
else:
	w=nCr(n-1,r-1)
	w=w%10000007;
	print(w);


MOD = 10000007

def comb(n, r):
	if n < r:
		return -1

	if r == 0:
		return 1

	return ((n*comb(n-1, r-1))/r)

n, r = tuple(map(int, input().split()))
ans = comb(n-1, r-1)

if ans > -1:
	print((comb(n-1, r-1)%MOD))
else:
	print(ans)


'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
# print 'Hello World!'

def init():
	global mylist
	for i in range(101):
		tmp = []
		for j in range(101):
			if i == 0 or j == 0 or i == 1:
				tmp.append(1)
			else:
				total = 0
				for k in range(j+1):
					total = (total + mylist[i-1][k]) % 10000007
				tmp.append(total)
		mylist.append(tmp)

def process():
	global n, r
	n -= r
	if n < 0:
		print(-1)
	else:
		print(mylist[r][n])
mylist = []
init()
arr = (input()).split()
n = int(arr[0])
r = int(arr[1])

process()


import fileinput as f
import math
def computeValue(n,r):
	n = n-1
	r = r-1
	if n>0 and r>0 and n >= r:
		print((math.factorial(n)/(math.factorial(n-r) * math.factorial(r))) % 10000007)
	else:
		print(-1)

vals=iter(f.input())
for line in vals:
	nr = line.split(' ')
	n = int(nr[0])
	r = int(nr[1])
	computeValue(n,r)



N, R = [int(i) for i in input().split()]
grid = [[0]*N for i in range(R)]

for i in range(N):
	grid[0][i] = 1

for i in range(1, R):
	if N > i:
		sum_ = grid[i-1][i-1]
		for j in range(i, N):
			grid[i][j] = sum_
			sum_ = (sum_ + grid[i-1][j]) % 10000007
if grid[R-1][N-1] == 0:
	print("-1")
else:
	print(grid[R-1][N-1])


from sys import stdin
fa = [1]
for x in range(1,205):
	fa.append(x*fa[x-1])
a = stdin.readline().split()
n = int(a[0])
r = int(a[1])
if n<r:
	print(-1)
elif n==r:
	print(1)
else:
	n = n-r
	r = r-1
	n = n+r
	fir = fa[n]
	sec = fa[r] * fa[n-r]
	fir = fir/sec
	sec = 10000007
	print(fir%sec)


'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
import sys
def f(n):
	if n<=1:
		return 1
	else :
		return n*f(n-1)
n1,n2=list(map(int,sys.stdin.readline().split()))
if(n1>=n2):
	print((f(n1-1)/(f(n1-n2)*f(n2-1)))%10000007)	
else:
	print(-1)
		



import math

def ways(n, p):
	if p>n-p:
		p = n-p
	return math.factorial(n)/math.factorial(p)/math.factorial(n-p)
		
N, P = input().split()
N = int(N)
P=int(P)
if N<P:
	print("-1")
else:
	print((ways(N-1, P-1)%10000007))


import math
 
def ncr(n,r):
	if r > n-r:
		r = n-r;
	return math.factorial(n) / math.factorial(r) / math.factorial(n-r)
 
s = input()
x = s.split(' ')
n = int(x[0])
r = int(x[1])
if n < r:
	print("-1")
else:
	print(ncr(n-1,r-1) % 10000007)


mod=10000007
n,r=list(map(int,input().split()))
if r>n:
	print(-1)
else:
	arr = [1]*n
	for i in range(1,n):
		arr[i] = arr[i-1]*i
	print((arr[n-1]/(arr[r-1]*arr[n-r]))%mod)


import math

def nCr(n,r):
	f = math.factorial
	return f(n)/(f(r)*f(n-r))

n,r = list(map(int,input().split()));
k=n-r;
if(k<0):
	print(-1)
else:
	print(nCr(k+r-1,r-1)%10000007)


def fac(n):
	if n == 1:
		 return n
	else:
		 return n*fac(n-1)
ar=list(map(int,input().split()))
if(ar[1]>ar[0]):
	 print(-1)
	 exit()
	 
if(ar[1]==ar[0]):
	 print(1)
	 exit()

if(ar[1]==1):
	 print(1)
	 exit()
	 
ar[0]=ar[0]-1
ar[1]=ar[1]-1
tmp=ar[0]-ar[1]
y=fac(tmp)*fac(ar[1])
x=fac(ar[0])/y
print(x%10000007)


'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
x=10000007
y,z=input().split()
y=int(y)
z=int(z)
n=y-z
def perm(n):
	if n == 0:
		return 1
	return n*perm(n-1)
if n<0 :
	print(-1)
elif n==0 :
	print(1)
else:
	print(((perm(n+z-1)/(perm(n)*perm(z-1))) % x))


import math

def nCr(n, r):
	f = math.factorial
	return f(n) / f(r) / f(n-r)
inp = list(map(int, input().split()))
(n, r) = inp

if(n < r):
	print(-1)
else:
	n -= r
	print((nCr(n + r -1, r - 1)) % 10000007)


'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
#rint 'Hello World!'
'''n=input("")
r=input("")'''
import sys

def fac(n):
	if n<=1:
		return 1
	else:
		return n*fac(n-1)

n,r = list(map(int,sys.stdin.readline().split()))
if(n>=r):
	print((fac(n-1)/(fac(r-1)*fac(n-r)))%10000007)
else:
	print(-1)
	


'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
import math
n,m=list(map(int,input().split()))
if(n>=m):
	n=n-1
	m=m-1
	a=math.factorial(n)
	b=math.factorial(m)
	c=math.factorial(n-m)
	ans=a/(b*c)
	print(ans%10000007)
else:
	print(-1)


'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
import math

[n,r]=[int(x) for x in input().split()]
n,r=n-1,r-1

if r>n:
	print(-1)
elif r==n:
	print(1)
else:
	i= math.factorial(n)
	j=math.factorial(n-r)
	k =math.factorial(r)
	print((i/(j*k))%10000007)


def fun(n,k,ctr,sav):
    
	if n==0:
		return 0
	if ctr==k:
		return 1
	sm=0
	i=1
	while i<=n:
		if sav[n-i][ctr+1]==-1:
			sm=sm+fun(n-i,k,ctr+1,sav)
		else:
			sm=sm+sav[n-i][ctr+1]
		i=i+1
	sav[n][ctr]=sm
	return sav[n][ctr]
sm=0
x=input().split(' ')
n=int(x[0])
k=int(x[1])
sav = [[-1 for x in range(104)] for x in range(104)]
sm=fun(n,k,1,sav)
if sm==0:
	print("-1")
else:
	print(sm%10000007)


mod=10000007
def modPow(a,b,c):
	x=1
	while (b>0):
		if(b%2==1):
			x=(x*a)%c
			
		a=(a*a)%c
		b=int(b/2)
	return x%c

fact=[0]*102
fact[0]=1
fact[1]=1

for i in range(2,102):
	fact[i]=(fact[i-1]*i)%mod
	#print "fact "+str(i)+" "+str(fact[i])

ifact=[0]*102
ifact[0]=1
ifact[1]=1

for i in range(2,102):
	ifact[i]=modPow(fact[i],9988439,mod)

def Comb(a,b):
	#print str(fact[a])+" "+str(ifact[b])+" "+str(ifact[a-b])
	c=fact[a]
	c=c*ifact[b]
	c=c%mod
	c=c*ifact[a-b]
	c=c%mod
	return c
	
n,r=list(map(int, input().split()))
#print str(n)+" "+str(r)
if n>=r:
	print(Comb(n-1,r-1))
else :
	print("-1")


'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''

import math

def nCr(n,r):
	f = math.factorial
	return f(n) / f(r) / f(n-r)
	
if __name__ == '__main__':
	line = input()
	line = line.split(' ')
	n = int(line[0])
	r = int(line[1])
	if n<r:
		print(-1)
	else:
		print(nCr(n-1,r-1) % 10000007)


'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
#print 'Hello World!'
import sys
n,r=list(map(int,sys.stdin.readline().split()));
def fac(n):
	if(n<=1):
		return 1
	else:
		return n*fac(n-1)
if(n>=r):
	print((fac(n-1)/(fac(n-r)*fac(r-1)))%10000007)
else:
	print(-1)


inp = input()
inp = inp.split()

a = int(inp[0])
b = int(inp[1])

from math import factorial

a = a - b + b - 1
b = b - 1
c = a - b

if a < 0 or b < 0 or a < b:
	print("-1")
	quit()

a = factorial(a)
b = factorial(b)
c = factorial(c)

ans = a/b;
ans = ans/c;

ans = ans % (10000007)

print(ans)