semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int man(int m,int n)
{
	int s;
	int fenfa(int x,int y);
	if(m==n) s=1;
	else s=fenfa(m-n,n);
	return(s);
}
int kong(int m,int n)
{
	int s;
	int fenfa(int x,int y);
	s=fenfa(m,n-1);
	return(s);
}
int fenfa(int m,int n)
{
	int s;
	if(m<n) n=m;
	if(n==1) s=1;
	else s=kong(m,n)+man(m,n);
	return(s);
}
void main()
{
	int M,N,t,i,s;
	scanf("%d",&t);
	for(i=0;i<t;i++) 
	{
	    scanf("%d %d",&M,&N);
		s=fenfa(M,N);
	    printf("%d\n",s);
	}
}
void main()
{
	int m,n,i,j;
	int ps(m,n);
	scanf("%d",&j);
	for(i=0;i<j;i++)
	{
		scanf("%d %d",&m,&n);
	    printf("%d\n",ps(m,n));
	}
}

ps(m,n)
{
	int i,j,k;
	if(n==1)
		k=1;
	else
	{
		k=0;
		for(i=0;i<=(m/n);i++)
		{
			k=k+ps(m-i*n,n-1);
		}
	}
	return (k);
}
int sd(int n,int m)
{
	if(n==1)
	{return 1;}
	if(m==1)
	{return 1;}
	if(n<m&&n>=2)
	{return sd((n-1),m)+sd(n,(m-n));}
	if(m<=n&&m>1)
	{return sd(m-1,m)+1;}
	
	
}


int main()
{
	int a;
	scanf("%d",&a);
	int m[100];
	int n[100];
	int d[100];
	int i=0;
	do
	{
		scanf("%d %d",&m[i],&n[i]);
		i++;
	}while(i<a);
	i=0;
	do
	{

		printf("%d\n",sd(n[i],m[i]));
		i++;
	}while(i<a);
	return 0;
}
int hf[30][11];
int work(int m,int n)
{
	if(m==0||m==1)
	{
		hf[m][n]=1;
		return 1;
	}
	if(n==1)
	{
		hf[m][n]=1;
	    return 1;
	}
	if(hf[m][n]!=0)
		return hf[m][n];
	if(m>=n)
	{
		hf[m][n]=work(m-n,n)+work(m,n-1);
		return hf[m][n];
	}
	else
	{
		hf[m][n]=work(m,n-1);
		return hf[m][n];
	}
}
int main()
{
	int n,m,k;
	cin>>k;
	int i,j;
	for(i=1;i<=k;i++)
	{
		cin>>m>>n;
		cout<<work(m,n)<<endl;
	}
	return 0;
}
//
//  main.c
//  ???
//
//  Created by ?  on 12-12-1.
//  Copyright (c) 2012? ? . All rights reserved.
//

int f(int a,int b);
int f1(int a,int b)
{
    if(a==2) return(1);
    else return(f(a-1,b));
}
int f2(int a,int b)
{
    if(a==b) return(1);
    else return (f(a,b-a));
}
int f(int a,int b)
{
    if(a==1) return (1);
    else
    {
        if(a>b) return (f1(a,b));
        else return (f1(a,b)+f2(a,b));
    }
}
int main()
{
    int t,m,n,i;
    scanf("%d",&t);
    for(i=0;i<t;i++)
    {
        scanf("%d %d",&m,&n);
        printf("%d\n",f(n,m));
    }
    return 0;
}
int main()
{   int fang(int x,int y);
    int i,t,m,n,f;
    scanf("%d",&t);
    for(i=0;i<t;i++){
        scanf("%d %d",&m,&n);
        printf("%d\n",fang(m,n));
        } 
}
int fang(int x,int y)
{    
    if(x==1||y==1){ 
       return 1;}       
    if(x>y){
        return fang(x,y-1)+fang(x-y,y);
       }
    if(x<y){
        return fang(x,x);}
    if(x==y){
       return fang(x,y-1)+1;}            
    
}
int m[30],n[30],result[30];
int saintseiya(int m,int n)
{
	int z;
	if(m>1&&n>1&&m>=n)
	z=saintseiya(m,n-1)+saintseiya(m-n,n);
	if(m>1&&n>1&&m<n)
		z=saintseiya(m,m);
	if(m==1)
	z=1;
	if(n==1)
	z=1;
	if(m==0)
	z=1;
	return(z);
}
void main()
{
	int i,d;
	scanf("%d",&d);
	for(i=0;i<d;i++)
		scanf("%d%d",&m[i],&n[i]);
	for(i=0;i<d;i++)
	result[i]=saintseiya(m[i],n[i]);
	for(i=0;i<d;i++)
	printf("%d\n",result[i]);
}
int n,m;
int main()
{
    int i,j,k;
    int way(int m,int n);
    scanf("%d",&j);
    for(i=0;i<j;i++)
    {
     scanf("%d %d",&m,&n);
     k=way(m,n);
     printf("%d\n",k);
     }
}
int way(int m,int n)
{
    int z;
    if(n==1||m==1||m==0) z=1;
    else
    {
     if(m<n) z=way(m,m);
     else z=way(m,n-1)+way(m-n,n);
     }
    return(z);
}
/*
 * homework3.cpp
 *
 *  Created on: 2012-12-4
 *      Author: Lixurong
 */

int apple(int x, int y)//x:apple, y:dish
{
	if(x==0)
			return 1;
		if(y==1)
			return 1;
	if(x<y)
		return apple(x,x);
	else if(x>=y)
		return apple(x-y,y) + apple(x,y-1);
}


int main()
{
	int i;
	cin >> i;
	for( i;i>0; i--){
	int m, n;
	cin >> m >> n;
	cout << apple(m,n);
	if( i!=1) cout << endl;
	}
	return 0;
}
int f(int m, int n){

       if(m==0||n==1){
return 1;
}
       if(m<n){
return f(m ,m);
}

       else{
return f(m,n-1) + f(m-n , n);
}

}

 

int main()
{
   
    int t,a,b;
    scanf("%d",&t);
    for(int i=0;i<t;i++){
            scanf("%d %d",&a,&b);
            printf("%d\n",f(a,b));
            
            }
    
 
    return 0;
    }
/* Note:Your choice is C IDE */
int f(int m,int n)
{
	int z;
	if(m==0||m==1||n==1) z=1;
	else{
		if(m<n) z=f(m,m);
		else z=f(m,n-1)+f(m-n,n);
	}
	return z;
}


int main()
{
    int f(int m,int n);
    int x,i,m[10],n[10];
    scanf("%d",&x);
    for(i=1;i<=x;i++)
    {
    	scanf("%d%d",&m[i],&n[i]);
    	
    }
    for(i=1;i<=x;i++)
    {
    	printf("%d\n",f(m[i],n[i]));
    }
    return 0;
}
//***********************
//*??????         **
//*??????         **
//*???2013.11.29     **
//************************
int put(int a,int b)
{
	if(b<=0||a<0)
	{
		return 0;
	}
	else
	{
		if(a==1||b==1||a==0)
		{
			return 1;
	    }
		else
		{
			return (put(a-b,b)+put(a,b-1));
		}
	}
}
int main()
{
	int k,i,m,n;
	cin>>k;
	cin.get();
	for(i=1;i<=k;i++)
	{
		cin>>m>>n;
		cout<<put(m,n)<<endl;
	}
	return 0;
}
int with(int m, int n, int k)
{
	if (m < n || m == 0 || n == 0)
	return 0;
	else if (m == n || n == 1)
	return 1;
	else
	{
		int sum = 0;
		for (int i = k; i <= m / n; i++)
		{
			sum = sum + with(m - i, n - 1, i);
		}
		return sum;
	}
}
int without(int m, int n)
{
	if (n == 1)
	return 0;
	else if (n == 2)
	return 1;
	else
	{
		int sum = 0;
		for (int i = 1; i <= n - 1; i++)
		{
			sum = sum + with(m, n - i, 1);
		}
		return sum;
	}
}
int main()
{
	int t, m, n, i;
	cin >> t;
	for (i = 1; i <= t; i++)
	{
		cin >> m >> n;
		cout << with(m, n, 1) + without(m, n) << endl;
	}
	
	return 0;
}
int q(int M,int N)
{
  int K,y,w;  
  if(N==1)
  {return 1 ;}
  if(M<0)   {return 0;}
  else
  {
    //y=q(M,N-1);
   //printf("%d\n",M);
    //w=q(M-N,N);
   // printf("%d\n",N);
    //K=y+w;
   // q(M,N)=q(M,N-1)+q(M-N,N);
   // K=q(M,N);  
  }
   return(q(M,N-1)+q(M-N,N)); 
    
}
main()
{
 int t,i,M,N,b,K;
 scanf("%d",&t);
 for(i=0;i<t;i++)
 {
  scanf("%d %d",&M,&N);
   b=q(M,N);
   printf("%d\n",b);               
 }     
getchar();      
getchar();    
 getchar();     
 
}
int main()
{
	int distribution(int,int);
	int t,i;
	int m[21]={0},n[21]={0};
	scanf("%d\n",&t);
	for(i=1;i<=t;i++)
		scanf("%d %d\n",&m[i],&n[i]);
	for(i=1;i<=t;i++)
		printf("%d\n",distribution(m[i],n[i]));
	return 0;
}
		int distribution(int m,int n)
		{
			if(m==1)
				return(1);
			else if(n==1)
				return(1);
			else if(m<n)
				return(distribution(m,n-1));
				else return(distribution(m-n,n)+distribution(m,n-1));
		}
int m, n, total;
void putapp(int app, int dish, int last){	//app:???? dish:???? last????????					//???????
	//cout << total << endl;
	if((dish>0 && app<last) || (dish==0 && app>0))
		return;
	if(dish==0 && app==0)
		total++;
	for(int i=last; i<=app; i++){
		putapp(app-i, dish-1, i);
	}
	if(dish == n)
		cout << total << endl;
}

int main(){
	int a;
	cin >> a;
	int i=0;
	while(i<a){
		total = 0;
		cin >> m >> n;
		putapp(m, n, 0);
		i++;
	}
	return 0;
}
int f(int m, int n)

{

       if( m == 0 || n == 1) return 1;  

       if(m<n) return f(m ,m);

       return f(m,n-1) + f(m-n , n);

}
int main()
{   
	int t,i;
	scanf("%d",&t);
	for(i=0;i<t;i++)
	{
	int m,n,k;
	scanf("%d %d",&m,&n);
	k=f(m,n);
	printf("%d",k);
       printf("\n");
	}
	return 0;
}
int main()
{
	int func1(int m,int n);  
	int t,m,n,result,i;
	scanf("%d",&t);
	for(i=0;i<t;i++)
	{
		scanf("%d",&m);
		scanf("%d",&n);
		result=func1(m,n);
		printf("%d\n",result);
	}
	return 0;
}


int func1(int m,int n)
{
	int result1;
	if(m>=n)
	{
		if(n==1)	//????????????????????
		{
			result1=1;
		}
		else if(n>=2)	
		{
			result1=func1(m,n-1)+func1(m-n,n);
		}
	}
	if(m<n)
	{
		if(n==1)	//????????????????????
		{
			result1=1;
		}
		else if(n>=2)
		{
			result1=func1(m,n-1);
		}
	}
	return result1;
}
int number(int a,int b)
{
	int total;
	if(a==1)
	{
	  total=1;
	  return total;
	}
	if(b==1)
	{
		total=1;
		return total;
	}
	if(a<b)
	{
		total=number(a,a);
	    return total;
	}
	if(a==b)
	{
		total=1+number(a,b-1);
		return total;
		
	}
	if(a>b)
	{
		total=number(a-b,b)+number(a,b-1);
		return total;
	}
}
void main()
{
	int m[20],n[20],C[20],t,i;
	scanf("%d",&t);
	for(i=0;i<t;i++)
	{
		scanf("%d%d",&m[i],&n[i]);
		C[i]=number(m[i],n[i]);
	}
	for(i=0;i<t;i++)
	{
		printf("%d\n",C[i]);
	}

}
int method(int (m),int (n))
{
    int c;
    if(m==0) c=1;
    if(m==1) c=1;
    if(n==1) c=1;
    if(m>=n && m>1 && n>1)
       c=method(m,n-1)+method(m-n,n);
    if(m<n && m>1 && n>1)
       c=method(m,n-1);
    return c;
}
int print()
{
    int m,n;
    scanf("%d%d",&m,&n);
    printf("%d\n",method(m,n));
}
int main()
{
    int t,i;
    scanf("%d",&t);
    for(i=0;i<t;i++)
       print();
    
}
int f(int m , int n)
{
if(m == 1 || n== 1 || m == 0) return 1; 
if(m < n) return f(m, m);
return f(m - n, n) + f(m, n - 1);
}
int main(void)
{
int n , m , z;
scanf("%d", &z);
while(z-- > 0)
{
scanf("%d%d", &m ,&n);
printf("%d\n",f(m, n));
}
return 0;
}
int putapple(int n,int m)
{
	if(m<n) n=m;
	if(n==1) return 1;
	if(m==0) return 1;
	return putapple(n-1,m)+putapple(n,m-n);
}

void main()
{
	int m,n,k,out[20],i,j;
	scanf("%d",&k);
	for(i=0;i<k;i++)
	{
		scanf("%d %d",&m,&n);
		out[i]=putapple(n,m);
	}
	for(j=0;j<k;j++)
		printf("%d\n",out[j]);
}
int f(int , int );
int main()
{
	int a;
	cin>>a;
	while(a--)
	{
		int i=0,m,n;
		int sum=0;
		cin>>m>>n;
		for(i=1;i<=n;i++)
			sum=sum+f(m,i);
		cout<<sum<<endl;
	}
	return 0;
}
int f(int n,int k)
{
	int j=0,r;
	if(k==1||n==k)
		return 1;
	else
		if(n<k)
			return 0;
		else
		{
			r=0;
			for(j=1;j<=k;j++)
				r=r+f(n-k,j);
			return r;
		}
}
int main()
{
	int fang(int x, int y);
	int n, i, a, b;
	cin >> n;
	for(i = 1; i <= n; i++)
	{
		cin >> a >> b;
		cout << fang(a, b) << endl;
	}
	return 0;
}
int fang(int x, int y)
{
	if(x == 0 || y == 0)
		return 0;
	if(x < y)
	    return fang(x, x);
	if(x == y)
		return fang(x, y - 1) + 1;
	if(x > y)
		return fang(x, y - 1) + fang(x - y, y);
}
int kkkk(int a,int b)
{
     int k;
     if (b==1) k=1;
     else if (a==1) k=1;
     else if (a<=b) k=1+kkkk(a,a-1); 
     else k=kkkk(a-b,b)+kkkk(a,b-1);
     return k;
}                    

main()
{
      int i,n,a[20],b[20],k;
      scanf("%d",&n);
      for (i=0;i<n;i++)
      {
          scanf("%d",&a[i]);
          scanf("%d",&b[i]);
      }
      for (i=0;i<n;i++)
      {
          k=kkkk(a[i],b[i]);
          printf("%d\n",k);
      }
}
int f(int m,int n){
  if(n == 1 || m == 0 || m == 1){return 1;}
  else if(m < n){return f(m,m);}
  else{return f(m,n-1) + f(m - n,n);}
}
int main(){
  int i,n,a,b;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d %d",&a,&b);
    printf("%d\n",f(a,b));}
  return 0;
}
int solve(int,int);
int main()
{
    int i,j,k;
    int t,m,n;
    cin>>t;
    for(i=0;i<t;++i)
    {
        cin>>m>>n;
        cout<<solve(m,n)<<endl;
    }
    return 0;
}
int solve(int m,int n)
{
    if(m==0 || n==1) return 1;
    else if(m<n) return solve(m,m);
    else
    {
        return (solve(m,n-1)+solve(m-n,n));
    }
}
int sum(int a,int b);
int empty(int a,int b);
int full(int a,int b);
int main()
{
	
	int m,n,count1,count2,count,num,i;
	scanf("%d",&num);
	for(i=0;i<num;i++)
	{	
		scanf("%d%d",&m,&n);
		if(n==1)
			count=full(m,n);
		else if(m==1)
			count=empty(m,n);
		else
		{
			count1=empty(m,n);
			count2=full(m,n);
			count=count1+count2;
		}
		printf("%d\n",count);
	}
	return 0;
}

int empty(int a,int b)
{
	int num;
	if(a==1)
		num=1;
	else 
		num=sum(a,b-1);
	return(num);
}
int full(int a,int b)
{
	int num;
	if(a==b)
		num=1;
	else 
		num=sum(a-b,b);
	return(num);
}
int sum(int a,int b)
{
	int num;
	if(a>0&&b>0)
		if(a<b)
			num=sum(a,a);
		else if(a==1)
			num=1;
		else if(b==1)
			num=1;
		else
			num=empty(a,b)+full(a,b);
	return(num);
}
int p=0;
int move(int M,int N){
	if(M==0||N==1)
	return 1;
	else if(M<N)
	 return(move(M,M));
	else if(M>=N)
     return (move(M-N,N)+move(M,N-1));
}


int main(){
	int i,p,M[20],N[20],K[20];
	scanf("%d",&p);
    for(i=0;i<p;i++)
	{
		scanf("%d%d",&M[i],&N[i]);
		K[i]=move(M[i],N[i]);
		printf("%d\n",K[i]) ;
         }
         return 0;
	}
int main()
{
	int f(int a,int b);
	int i,n,apple,plate;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>apple>>plate;
		cout<<f(apple,plate)<<endl;
	}
	return 0;
}
int f(int a,int b)//??????????
{
	int result;
	if(b==1&&a!=0) result=1;
	else if(a==0) result=1;
    else if(a>=b)
		result=f(a,b-1)+f(a-b,b);
	else result=f(a,a);
	return result;
}
/*
 * 183.cpp
 *
 *  Created on: 2011-11-20
 *      Author: think
 */
int way1(int m,int n);
int way2(int m,int n);
int way(int m,int n){//????????
	return way1(m,n)+way2(m,n);
}
int way1(int m,int n){//????????????
	int r;
	r=m%n;
	if(n==1)return 1;//??
	if(m==0||m<n)return 0;//??
	if(m==n)return 1;//??
	return way(m-n,n);//??
}
int way2(int m,int n){//??????????
	if(n==1)return 0;//??
	else return way(m,n-1);//??
}
int main(){//?????
	int k,i;
	cin>>k;//??????
	int a[k+1];
	int b[k+1];
	for(i=1;i<=k;i++){
		cin>>a[i]>>b[i];//????
	}
	for(i=1;i<=k;i++){
		cout<<way(a[i],b[i])<<endl;//????
	}
	return 0;
}//?????
PutMethod(int apple,int plate)
{int k,k1=0,k2=0;
 if(plate==1)k=1;
 else 
	{if(apple<plate)k2=0;
	 if(apple==plate)k2=1; 
	 if(apple>plate)
		k2=PutMethod(apple-plate,plate);
		k1=PutMethod(apple,plate-1);
	 k=k2+k1;
	}
 
 return k;
}
main()
{int t, apple, plate,i,k;
 scanf("%d",&t);
 for(i=0;i<t;i++)
	{scanf("%d %d",&apple,&plate);
	 k=PutMethod(apple,plate);
	 printf("%d\n",k);
	}
}
int apple(int,int);
int main()
{
	int t,n,m,i;
	cin>>t;//????
	for(i=0;i<t;i++)
	{
		cin>>m>>n;//?????????
		cout<<apple(m,n)<<endl;//??
	}
	return 0;
	}
	int apple(int x,int y)//????
	{
		int number;
		if(x>y&&y!=1)
			number=apple(x-y,y)+apple(x,y-1);//??
		if(x<=y&&x!=1)
			number=1+apple(x,x-1);//??
		if(x==1)
			return 1;//??
		if(y==1)
			return 1;//??
		else
			return number;
	}
// ?????.cpp : ??????????????
//

 
int sum(int m,int n)
{
	if (n == 1 || m == 0)
	{
		return 1;
	}
	if (n != 1)
	{
		if (m - n < 0)
		{
			return sum(m, m);
		}
		return (sum(m,n - 1) + sum(m - n,n));
	}
}

int main()
{
	int t,i,m,n;
	cin >> t;
	for (i=1;i<=t;i++)
	{
		cin >> m >> n;
		cout << sum(m,n) << endl;
	}
	return 0;
}
main()
{
int t;
scanf ("%d",&t);
for (int i=0;i<t;i++)
   {      
    int f(int m,int n);
    int m,n,k;
    scanf ("%d",&m);
    scanf ("%d",&n);
    k=f(m,n);
    printf ("%d\n",k);
   }
}
int f(int m,int n)
{
    int g(int p,int q);
    int y;
    if (n==1)
       y=1;
    else
        y=f(m,n-1)+g(m,n);
    return y;
}
int g(int p,int q)
{
    int f(int m,int n);
    int s; 
    if (p<q)
       s=0;
    else if (q==p)
       s=1;
    else 
       s=f(p-q,q);
    return s;
}
int c(int , int);
int main()
{
	int n ;
	cin>>n;
	for(int i = 0 ;  i<n ; i++)
	{
		int a , b;
		cin>>a>>b;
		int sum=0;
		sum = c(a,b);
		cout<<sum<<endl;
	}
	return 0;
}
int c(int a ,int b )
{
	int sum = 0;
	if(a==1||a==0||b==1||b==0)
		return 1 ;
	if(a>=b)
	{
		sum=c(a,b-1)+c(a-b,b);
		return sum ;
	}
	if(a<b)
	{
		sum = c(a,a);
		return sum ;
	}
}
int core(int m,int n)
{
	int h;
	if(m==1 && n==1) h=1;
	else if(m<n && m>=1) h=core(m-1,n)+core(m,n-m);
	else if(m==n && m!=1 ) h=core(m-1,n)+1;
	else if(m>n && n>=1) h=core(m-1,n);
	else h=0;
	return(h);
}

void main()
{
	int t;
	
	scanf("%d",&t);
	int i;
	int m,n;
	int a[100];
	for(i=0;i<=t-1;i++)
	{	scanf("%d %d",&n,&m);
		a[i]=core(m,n);
		
	}
	for(i=0;i<=t-1;i++)
		printf("%d\n",a[i]);
	

}
//****************************************************** 
//* ? ? ?   ?? ? ? ? ?                        *
//* ? ?      ?? ? ?                              *
//* ? ? ? ??2010 ? 12 ? 2 ?                    * 
//* ? ? ? ??? ? ? ? ?                        *
//* ? ?      ?1000010439                            *
//******************************************************
int f(int x,int y)                                         //???????? ,??????x,????y 
{
    int sum = 1;                                           //???????x,????y?????? 
    if( (y == 1)||(x == 0) );                              //?????1??????0?,???? 
    else
    {
        if(x >= y)                                         //??????????,?????,??????,?????????????? 
        sum = f(x - y,y) + f(x,y - 1);
        else                                               //?????????,????? 
        sum = f(x,y - 1);
    }
    return sum;                                            //????? 
}
int main()
{
    int k[100] = {0};                                      //??k???????????? 
    int a,b,c,t;                                           //c?????,a????,b????,t????? 
    cin >> c;                                              //??????????? 
    for(t = 0;t < c;t++)                                   //?????????? 
    {
       cin >> a >> b;
       k[t] = f(a,b);                                      //???t?????? 
    }
    for(t = 0;t < c;t++)
    {
       cout << k[t] << endl;                               //?????? 
    }
    return 0;
}
int devide(int m,int n);
int enb(int m,int n);
int unb(int m,int n);
int main()
{
	int t,i,m,n;
	cin>>t;
	for(i=0;i<t;i++)
	{
		cin>>m>>n;
		if(n!=1)
			cout<<devide(m,n)<<endl;
		else
			cout<<"1"<<endl;
	}
	return 0;
}

int enb(int m,int n)
{
	if(n==2)
		return 1;
	else
		return devide(m,n-1);
}

int unb(int m,int n)
{
	if(m<n)
		return 0;
	else
		return devide(m-n,n);
}

int devide(int m,int n)
{
	return enb(m,n)+unb(m,n);
}
/////?????/////
int f(int x,int y)
{
	int z,z1,z2,q;
	if((y==1)||(x==0)) z=1;
	else
	{
		if((x<y)) z=f(x,x);
		else 
		{
			z=f(x,y-1)+f(x-y,y);
		}
	}
	return z;
}
/////???/////
main()
{
	int t,m,n,i,k;
	scanf("%d",&t);
	for(i=0;i<t;i++)
	{
		scanf("%d %d",&m,&n);
		k=f(m,n);
		printf("%d\n",k);
	}
	return 0;
}
int fen(int m,int n)
{
	if(n==1||m==1)
	return 1;
	else if(n==0&&m==0)
	return 1;
	else if(m<0)
	return 0;
	else
	return fen(m,n-1)+fen(m-n,n);
}
main ()
{
	int t,m,n,i;
	scanf("%d",&t);
	for(i=1;i<=t;i++)
	{
		scanf("%d %d",&m,&n);
		printf("%d\n",fen(m,n));
	}
}
int N(int i,int a,int b);
int main(){
 int n[20],m[20],c,i;
 scanf("%d",&c);
 for(i=1;i<=c;i++){
  scanf("%d",&m[i]);
  scanf("%d",&n[i]);
 }
 for(i=1;i<=c;i++){
  printf("%d\n",N(1,m[i],n[i]));
 }
return 0;
}


int N(int i,int a,int b){
 int z=0,j;
 if(i>a&&a!=0)
	 z=0;
 else{ 
	 if(a==0)
	  z=1;
     else{ 
		 if(b==1)
	       z=1;
         else{ 
			 if(a<=b){
				 for(j=i;j<=a;j++){
				  z=z+N(j,a-j,b-1);
				 }}
             else{if(i!=1){
				 z=N(i-1,a-b,b)+N(i,a,b-1);}
			 else{z=N(1,a-b,b)+N(1,a,b-1);}}
 
 }}}
 return z;
}
int main()
{
	int f(int M, int N);
	int M,N,K,t,i;
	cin >> t;
	for(i = 1 ; i <= t ; i++)
	{
		cin >> M >> N;
		K = f(M,N);
		cout << K << endl;
	}
	return 0;
}
int f(int M, int N)
{
	if(N == 1)
	{
		return 1;
	}
	else if(M >= N)
	{
		return f(M,N - 1) + f(M - N,N);
	}
	else
	{
		return f(M,N - 1);
	}
}
int f2(int m,int n)
{
	int N1;
	if (m == 0 || n == 0)
		return 0;
	if (n == 1 || m == 1)
		return 1;
	if (m < n)
		return f2(m,m);
	if (n == m)
		return f2(m,n-1) + 1;
	if(m > n)
		return f2(m,n-1)+f2(m-n,n); 
}

int main()
{
	int t,m,n,N,i;
	cin >> t;
	for (i = 1; i <= t;i++)
	{
		cin >> m >> n;
		N = f2(m,n);
		cout << N << endl;
	}
	cin.get();
	cin.get();	
	return 0;
}
int f(int m,int n)
{
	int k;
	if(n==0||n==1) k=1;
	else if(m<n) k=f(m,m);
	else {k=f(m,n-1)+f(m-n,n);}
	return(k);
}
void main()
{
	int t,i,p;
	int m[20],n[20];
	scanf("%d",&t);
	for(i=0;i<t;i++)
		scanf("%d%d",&m[i],&n[i]);
	for(i=0;i<t;i++)
	{
		p=f(m[i],n[i]);
		printf("%d\n",p);
	}
}
int main()
{
	int g,m,n;
	int method(int m, int n);

	cin >> g ;	// g groups of data,m apples ,n plates
	while (g--)
	{
		cin >> m >> n;
		cout<< method(m,n)<<endl;
	}
	return 0;
}

int method(int m,int n)
{
	if (m==0)
		return 1;
	else if (m==1)
		return 1;
	else if (n==1)
		return 1;
	else
		if ( m>=n )
			return method(m-n,n)+method(m,n-1);
		else 
			return method(m,n-1);
}
/*
 * hanshu_huisu_4.cpp
 * Name??????
 *  Created on: 2010-12-6
 *      Author: ??
 */

int M,N;//
int f(int m,int n){
	if(m==0) return 1;//??????0??????????1
	if(n==1) return 1;//??????1??????????????1
	if(n>m) return f(m,m);/*???????????????n-m????????????????*/
	if(n<=m) return f(m-n,n)+f(m,n-1);/*??????????????????????????????n????m??????????n????m-n???????????????????n?????m??????????n-1?????m????????*/
}
int main(){
	int t;
	cin>>t;//?????????t
	while(t>0){
	cin>>M>>N;//??????????????
	cout<<f(M,N)<<endl;//???????????
	t--;
	}
return 0;
}
// ?????.cpp : ??????????????
//



int baifang( int m , int n );
int sum = 0;

int main()
{
	int m = 0;
	int n = 0;

	int t = 0;
	int i = 0;
	cin >> t;

	for( i = 1;i <= t;i++ )
	{
		cin >> m;
		cin >> n;

		cout << baifang( m , n) << endl;
	}

	return 0;
}

int baifang( int m , int n )
{
	if( n == 1)
		return 1;
	if( m == 1)
		return 1;
	if( m == 0 )
		return 1;
	if( m < 0)
		return 0;
	if( n > 1 )
	{
		sum = baifang( m ,n - 1) + baifang( m - n , n );
	}

	return sum;
}
int main()
{
	int f(int m,int n);
	int z;
	int a,b,i;
	int sum;
	scanf("%d",&z);
	for(i=0;i<z;i++)
	{
	scanf("%d %d",&a,&b);
	sum=f(a,b);
	printf("%d\n",sum);
	}
	return 0;
}
int f(int m,int n)
{
	if(n==1||m==0||m==1)
		return 1;
	if(m<0)
		return 0;
	return f(m,n-1)+f(m-n,n);
}
int K=0;
void Try(int,int);
void Try(int X,int Y){
	if(X==0)
		K++;
	else if(Y==1)
		K++;
	else if(X>=Y){
		Try(X,Y-1);
		Try(X-Y,Y);
	}
	else
		Try(X,Y-1);
}
int main()
{
	int t,i,M,N;
	cin>>t;
	for(i=1;i<=t;i++){
		cin>>M>>N;
		Try(M,N);
	    cout<<K<<endl;
		K=0;
	}
    return 0;
}
int count(int x,int y)
{
	if(y==1||x==0) //?????0?????1????????
		return 1;
	if(x<y)
		return count(x,x); //??????????????x?????x??????
	return (count(x,y-1)+count(x-y,y)); //??????????????????-1????????????????????????????
}
int main()
{
	int t=0,M=0,N=0,i=0,result[25];   //t??????M?????N?????result????????
	cin>>t;
	for(i=0;i<t;i++)
	{
		cin>>M>>N;       //???????
		result[i]=count(M,N); //????
	}
	for(i=0;i<t;i++)
	{
		cout<<result[i]<<endl;       
	}
	return 0;
}
int f(int, int);

int main()
{
	int k, m, n;
	cin >> k;
	for (int i = 1; i <= k; i++)
	{	
		cin >> m >> n;
		cout << f(m, n) << endl;
	}
	return 0;
}

int f(int m, int n)
{
	if (n == 1 || m == 1 || m == 0)
		return 1;
	if (m < 0)
		return 0;
	else
		return (f(m, n - 1) + f(m - n, n));
}
int main()
{
	int f(int a,int b);
	int n,a,b;
	scanf("%d",&n);
	for(;n-->0;)
		{scanf("%d%d",&a,&b);
	printf("%d\n",f(a,b));}
}
int f(int a,int b)
{
	if(a>0&&b>1)return(f(a,b-1)+f(a-b,b));
	else if(a<0||b<=0)return (0);
	else return(1);
}
int fpg(int M,int N,int x);
int main()
{
    int t;
    scanf("%d",&t);
    int M,N,K;
    for(int i=0;i<t;i++)
    {
        scanf("%d%d",&M,&N);
        K=fpg(M,N,0);
        printf("%d\n",K);    
    }
    return 0;
}
int fpg(int M,int N,int x)
{
    int K=0;
    if(N==0&&M==0)
    {
       return 1;     
    }
    if (N==0) return 0;
    if(M<0)
    {
       return 0;    
    }
    for(int i=x;i<=M;i++)
    {
        K=K+fpg(M-i,N-1,i);    
    }
    return K;
}
int f(int m,int n)
{
   int s;
   if(n!=1)
   {if(m>=n) s=f(m,n-1)+f(m-n,n);
    else s=f(m,n-1);}
   else s=1;
   return s;
}
main()
{
   int t,m,n,i,s;
   scanf("%d",&t);
   if(t==0) printf("0");
   else
   {
     for(i=1;i<=t;i++)
     {
        scanf("%d %d",&m,&n);
        s=f(m,n);
        printf("%d\n",s);
     }
   }
   getchar();
   getchar();
}
int apple(int n,int m)
{
	int i,p;
	if (m==1||n==1||n==0)
	{
		return 1;
	}
	else
	{
		p=0;
		if (n<m)
			return apple(n,n);	
		if (n>=m)
		{
			for (i=1;i<=m;i++)
				p=p+apple(n-i,i);
			return p;
		}
	}
}
int main()
{
	int i,t,n,m,num;
	cin>>t;
	for (i=0;i<t;i++)
	{
		cin>>n>>m;
		num=apple(n,m);
		cout<<num<<endl;
	}
	return 0;
}
//********************************
//*?????? 1300012733 **
//*???2013?11?29?
//********************************
//????
int N,M;
int c = 0;
int plate[11] = {0};
//????????????
void Put( int k, int num )
{
	if(( k == N )&&( num >= plate[ N-1 ] ))
	{
		c++;
		return;
	}
	for( int i = plate[ k-1 ]; i <= num; i++ )
	{
		plate[ k ] = i;
		Put( k+1, num-i );
	}
}
int main()
{
	int t;
	cin >> t;
	for( int i = 1; i <= t; i++ )
	{
		cin >> M >> N;
		c = 0;
		//????
		Put( 1 , M );
		cout << c << endl;
	}
	return 0;
}
int f(int m,int n)
{
	if(m==1&&n>=1)
		return 1;
	if(n==1&&m>=1)
		return 1;
	if(m<0||n<1)
		return 0;
	if(m==0&&n>=1)
		return 1;
	if(m>1&&n>1)
		return f(m,n-1)+f(m-n,n);

}
int main()
{
	int t,m,n,i;
	scanf("%d",&t);
	for(i=0;i<t;i++)
	{
		scanf("%d %d",&m,&n);
		printf("%d\n",f(m,n));
	}
	return 0;
}