semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int baifang(int n, int m);
int main()
{
	int t, m, n, i;
	cin >> t;
	for(i = 1; i <= t; i++)
	{
		cin >> m >> n;
		cout << baifang(n, m) << endl;
	}
	return 0;
}
int baifang(int n,int m)
{
	if(m == 0)
	{
		return 1;
	}
	if(n == 1)
	{
		return 1;
	}
	if(m < n)
	{
		return (baifang(n - 1, m));
	}
	else
	{
		return (baifang(n - 1, m) + baifang(n, m - n));
	}
}
int n,m,s=0;
void put (int p,int j,int m)
{if ((p==n)&&(m==0))s++;
 else if (p!=n)
 {
  for (int i=j;i<=m;i++)if (m-i>=0)put(p+1,i,m-i);
 }

}
int main()
{int t;
cin>>t;
for (int i=1;i<=t;i++)
 {
  cin>>m>>n;s=0;
  if (n>m)n=m;
  for (int j=0;j<=m;j++) put(1,j,m-j);
  cout<<s<<endl;
 }
return 0;
}
int apple(int x,int y);
int main(){
	int t,i;
	scanf("%d",&t);
	for(i=0;i<t;i++){
					 int M,N,K;
					 scanf("%d %d",&M,&N);
					 K=apple(M,N);
					 printf("%d\n",K);
					 } 
    return 0;
}

int apple(int x,int y){
	int a=0,b=0,result;
	if(x==1||y==1){
			 result=1;
			 }
    else{
		 if(x<=0||y<=0){
		 				return 0;
						}
	     else if(x<=y){
                  y=x;
                  a=apple(x,y-1);
                  result=1+a;
                  }
         else{
		 a=apple(x,y-1);
		 b=apple(x-y,y);
		 result=a+b;}
		 }
    return result;
}
int f(int x,int y)
{
	int k=0;
	if(x>=0)
	{
		if(x<=1||y<=1)
		k=1;
		else
		k=f(x,y-1)+f(x-y,y);
	}
	return(k);
}
void main()
{
	int a,m[100],n[100],i,k[100];
	scanf("%d",&a);
	for(i=1;i<=a;i++)
	{
		scanf("%d %d",&m[i],&n[i]);
		k[i]=f(m[i],n[i]);
	}
	for(i=1;i<=a;i++)
		printf("%d\n",k[i]);
}
main()
{
      
      int t,i;
      scanf("%d",&t);
      int*a=(int*)malloc(t*sizeof(int));
      int*b=(int*)malloc(t*sizeof(int));
      int apple(int m,int n);
      for(i=0;i<t;i++)
      {
          scanf("%d %d",&a[i],&b[i]);
      }
      for(i=0;i<t;i++)
      {
          printf("%d\n",apple(a[i],b[i]));
      }
      free(a);
      free(b);
getchar();
getchar();
getchar();
getchar();
getchar();
getchar();
}
int apple(int m,int n)
{
    int c=0;
    
    if(n==1||m==1)
        { 
               c=1;
        }
    else
    {
        if(m<n)
        {
               n=m;
               c=apple(m,n);
        }
        else if(m==n)
        {
                c=apple(m,n-1)+1;
        }
        else
        {
                c=apple(m-n,n)+apple(m,n-1);
        }
    }
    return (c);
}
int f(int m,int n)
{
   int c;
   if(n==1||m==1||m==0)  c=1;
   else if (m<0)  c=0;
   else      c=f(m,n-1)+f(m-n,n);
   return c;
}
main()
{
    int m,n,c,i,k;
    scanf("%d",&c);
    for(i=1;i<=c;i++)
    { 
        scanf("%d %d",&m,&n);    
        k=f(m,n);
        printf("%d\n",k);
    } 
  
}
int way(int a , int b , int c);
int main()
{
	int t , m , n , i , j , sum=0 , p=1;
	cin >> t ;
	for ( j = 0 ; j < t ; j++)
	{
		cin >> m >> n ;
		for ( i = 1 ; i <= n ; i++)
			sum = sum + way(m , i , p) ;
		cout << sum << endl;
		sum = 0 ;
	}
	return 0 ;
}
int way(int a , int b , int c)
{
	int num = 0 , j ;
	if(b == 1)	return 1 ;
	else 
	{	for(j = c ; j <= a / b ; j++)
			num = num + way(a - j , b - 1 , j) ;
	}
	return num ;
}
int much(int M,int N)
{
	int x;
	if(N==1||M==0) x=1;
	else if(M<N) x=much(M,M);
	else x=much(M,N-1)+much(M-N,N);
	return x;
}
void main()
{
	int n,M,N,i,a,b;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d%d",&M,&N);
		a=much(M,N);
		printf("%d\n",a);
	}
	scanf("%d",&b);
}
void main()
{
   int M,N,K,t,i;
   int num(int a,int b);
   scanf("%d",&t);
   for(i=1;i<=t;i++)
   {scanf("%d %d",&M,&N);
    K=num(M,N);
    printf("%d\n",K);
   }
}
int num(int a,int b)
{
	int z;
    if(b==1)
      z=1;
    if(a<=b)
	{
		if(a==1)    z=1;
		if(a==2)    z=2;
		if(a==3)	z=3;
		if(a==4)	z=5;
		if(a==5)	z=7;
		if(a==6)	z=11;
		if(a==7)	z=15;
		if(a==8)	z=22;
		if(a==9)	z=30;
	}
    if(a>b&&b!=1)
      z=num(a,b-1)+num(a-b,b);
    return(z);
}
// ?????? ???1000010500 
// ????? 
// 2010-12-3


int ways(int,int);

int main()
{
    int t,M,N,i,k[100];
    cin >> t;                           // ???????? 
    for (i = 0;i < t;i ++)
    {
        cin >> M >> N;                  // M?????N??? 
        k[i] = ways(M,N);               // ?k??????
    }
    for (i = 0;i < t;i ++)
         cout << k[i] << endl;
    return 0;
}

int ways(int m,int n)
{
    int k;
    if (n == 1 || m == 0 || m == 1)                         // ??????????????????? 
       return 1;
    if (m >= n)                                   // ?m=n???0?n?????? 
          k = ways(m,n - 1) + ways(m - n,n);
    else
          k = ways(m,n - 1);
    return k;
}
int times (int,int);
int main ()
{
	int n, i, m,N, c;
	cin >> N;
	for (i = 1; i <= N ; i ++)
	{
		cin >> m >> n;
		c = times (m, n);
		cout << c << endl;
	}
	return 0;
}
int times (int x, int y)
{
	int time;
	if (x <= y)
	{
		y = x;
	}
	if (x == 1)
		return 1;
	if (y == 1)
		return 1;
	if (x == 0)
		return 1;
	if (1)
	{
		time = times (x , y - 1) + times (x - y, y);
		return time;
	}
}
int f(int m,int n)
{
	int count=0;
	if(m==0||n==0)
	{
		return 1;
	}
	else if(m==1||n==1)
	{
		return 1;
	}
	else if(m<n)
	{
		count=f(m,n-1);
	}
	else
	{
		count=f(m,n-1)+f(m-n,n);
	}
	return count;
}
int main()
{
	int m,n,count,i,x;
	scanf("%d",&x);
	for(i=0;i<x;i++)
	{scanf("%d %d",&m,&n);
    count=f(m,n);
	printf("%d\n",count);}
	return 0;
}
int a[20];
int ans;

int ss(int n,int m)
{
	int i;
	if (n==1 && m<=a[2])
	{
		ans++;return 0;
	}
	if (n==1) return 0;
	for (i=0;i<=m;i++)
	{
		if (i>a[n+1]) break;
		a[n]=i;
		ss(n-1,m-i);
	}
	return 0;
}

int main()
{
	int n,m;
	int k;
	scanf("%d",&k);
	int i;
	while (k>0)
	{
		scanf("%d%d",&m,&n);
		for (i=1;i<=n;i++) a[i]=0;
		a[n+1]=100;
		ans=0;
		ss(n,m);
		printf("%d\n",ans);
		k--;
	}
	return 0;
}
int kong(int m,int n);
int zong(int m,int n);
int have(int m,int n);
int main()
{
	int a,b,t,i,c[50];
	scanf("%d",&t);
	for(i=0;i<t;i++){
		scanf("%d %d",&a,&b);
		c[i]=zong(a,b);
	}
	for(i=0;i<t;i++){
		printf("%d\n",c[i]);
	}
	return 0;
}
int kong(int m,int n){
	if(n==1) return 0;
	else return (zong(m,n-1));
}
int zong(int m,int n){
	if(m==0) return 1;
	else if(m==1) return 1;
	else if(m>=n) return(kong(m,n)+have(m,n));
	else return(kong(m,n));
}
int have(int m,int n){
	return (zong(m-n,n));
}
void main()
{long int f1(long int x,long int y);
long int f2(long int x,long int y);
long int n,a[20],b[20],i,k[20];
scanf("%ld",&n);
for(i=0;i<n;i++)
scanf("%ld %ld",&a[i],&b[i]);
for(i=0;i<n;i++)
{if(b[i]==1) k[i]=1;
else k[i]=f1(a[i],b[i])+f2(a[i],b[i]);
printf("%ld\n",k[i]);}
}

long int f1(long int x,long int y)
{long int z;
if(y>2) z=f1(x,y-1)+f2(x,y-1);
else if(y==2) z=1;
return(z);}

long int f2(long int x,long int y)
{long int w;
if(x-y>=0) w=f1(x-y,y)+f2(x-y,y);
else w=0;
return(w);}
int n,m,t,cnt;
void f(int x,int left,int last){
	//9("%d %d %d\n",x,left,last);
	if(x>n) {if(left==0) cnt++;return;}
	for (int i=last;i<=left/(n-x+1);i++) f(x+1,left-i,i);
}
int main(){
	scanf("%d",&t);
	while (t--){
		scanf("%d%d",&m,&n);
		cnt=0;f(1,m,0);
		printf("%d\n",cnt);
	}
	return 0;
}
int arrange( int a, int l, int before )
{
    if( l == 1 )
    return 1;
    int sum = 0;
    for( int i = before; i <= a ; i++ )
        if( a - i >= i )
         sum += arrange( a - i, l - 1, i );
        else break;
    return sum;
}
int main()
{
    int t ;
    cin >> t;
    for( int i = 0; i < t; i++ )
    {
    int n, m;
    cin >> m >> n;
    cout << arrange( m, n, 0 ) << endl;
    }

}
int many(int x, int y);
int main()
{
	int t, n, m, k;	
	int i;
	scanf("%d", &t);
	for(i=0;i<t;i++)
	{
		scanf("%d", &m);
		scanf("%d", &n);
		k=many(m,n);
		printf("%d\n", k);
	}
	return 0;
}
int many(int x, int y)
{
	if(x==0||y==1)
		return 1;
	else if(x<y)
		return many(x,x);
	else
		return many(x-y,y)+many(x,y-1);
}
int f(int x,int y)
{
    int k;
    if(x!=0&&y!=1)
    {
                  if(x>=y)
                  k=f(x,y-1)+f(x-y,y);
                  else
                  k=f(x,y-1);
    }
    else
    {
        if(x==0)
        k=1;
        if(y==1)
        k=1;
    }
    return k;
}
main()
{
      int n;
      scanf("%d",&n);
      for(int i=1;i<=n;i++)
      {
              int x,y;
              scanf("%d %d",&x,&y);
              printf("%d\n",f(x,y));
      }
}
int getNum(int m, int n);
int main()
{
	int t, M, N, Num;
	cin >> t;
	while(t >= 1)
	{
		Num = 0;
		cin >> M >> N;
		Num = getNum(M, N);
		cout << Num << endl;
		t--;
	}
	return 0;
}
int getNum(int m, int n)
{
	if(n == 1 || m == 1 || m == 0)
		return 1;
	if(m < 0)
		return 0;
	if(n != 1 && m > 1)
		return getNum(m, n - 1) + getNum(m - n, n);
}
int la(int n,int m )
{
	if (n==0)return 1;
	if (n==1)return 1;
	else 
	{
		int p;
		if (m>=n)
		{
			p = la(n,m-n)+la(n-1,m);
		}
		else
		{
			p = la(n-1,m);
		}
		return p;
	}
}

int main()
{
	int k;
	cin>>k;
	for (int i =1;i<=k;i++)
	{
		int n,m;
		cin>>m>>n;
		cout<<la(n,m)<<endl;
	}
}
int main()
{
	int s(int x,int y);
	int t,m[30],n[30],i;
	scanf("%d",&t);
	for(i=0;i<t;i++)
	{
		scanf("%d %d",&m[i],&n[i]);
		printf("%d\n",s(m[i],n[i]));	
	}
	return 0;
}

int s(int x,int y)
{
	int z;
	if(x==0||y==0)
	{
		z=1;
	}
	else if(x==1||y==1)
	{
		z=1;
	}
    else if(x<y)
	{
		z=s(x,y-1);
	}
	else
	{
	    z=s(x,y-1)+s(x-y,y);
	}
	return z;
}
int fp(int, int);
void fj(int, int, int);
int k = 0, p = 0;

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

int fp(int ap, int pl)
{
	if(pl == 1)
		return 1;
	else
	{
		if(ap < pl)
			k = fp(ap, ap);
		if(ap == pl)
			k = ap + fp(ap, pl - 1);
		if(ap > pl)
		{
			fj(ap, pl, 1);
			k = fp(ap, pl - 1) + p;
			p = 0;
		}
	}
}

void fj(int a, int b, int j0)
{
	int j;
	if(b == 1)
		p++;
	else
	{
		for(j = j0; j <= a / b; j++)
			fj(a - j, b - 1, j);
	}
}
int f ( int, int);
int main(){
int sum;
cin>>sum;//????
while(sum--)
	{int m,n;
     cin>>m>>n;//????????
     cout<<f(m,n)<<endl;//??????
    }
}
int f(int m,int n)
{
	if(m<0) return 0;//m????? ??????  ??0
	if(n==1) return 1;//n==1 ???????? ????1
	return f(m-n,n)+f(m,n-1);//??????? ????????f(m-n,n)?? ??????? ??????f(m,n-1)??
}
/*
 * 1000012766_fangpingguo.cpp
 *??:?????
 *  Created on: 2010-12-3
 *      Author: 10154
 */

int kcs(int m,int n)
{
	int cs(int m,int n);
	if(n==2)  return 1;
	if(n>=3) return cs(m,n-1);
	return 0;
}
int bkcs(int m,int n)
{
	int cs(int m,int n);
	if(m==n)   return 1;
	if(m>n)   return cs(m-n,n);
	return 0;
}
int cs(int m,int n)
{
	return kcs(m,n)+bkcs(m,n);
}
int main()
{
	int x,m,n;
	cin>>x;
	for(int i=1;i<=x;i++)
	{
		cin>>m>>n;
		cout<<cs(m,n)<<endl;
	}
return 0;
}
int num = 0;
void f(int m,int n);
int main()
{
	int m, n, k,i;
	cin >> k;
	for(i = 1;i <= k;i++)
	{
		cin >> m >> n;
		if( m >= n)  
		{
			f(m,n);
			cout << num << endl;
			num = 0;
		}
		else
		{
			f(m,m);
	    	cout << num << endl;
			num = 0;
		}
	}
	return 0;	
}
void f(int m,int n)
{
	int i;
	if(m == 0) num++;
	else
	{
		for(i = 0;i <= n - 1;i++)
		{ 
			if(i==0)
			{
				if(m >= n)    f(m-n,n);
			}
			else 
			{
				if(m >= n - i)	f(m-n+i,n-i);
				else continue;
			}
		}
	}
}
int f(int n1,int n2,int n3)
{
	int an=0,i;
	if(n1==0||n1==1) an=1;
	else
	{
	if(n2==1) an=0;
	if(n2==2)
	{
		if(n1%2==0)
		{
		for(i=n3;i>=n1/2;i--)
		{
			an=an+1;
		}
		}
		else{
			for(i=n3;i>n1/2;i--)
		{
			an=an+1;
		}
		}
	}
	else
	{   
		if(n1%n2==0)
		{
		for(i=n3;i>=n1/n2;i--)
		{
			if(n1-i<i)
			{
			an=an+f(n1-i,n2-1,n1-i);
			}
			else an=an+f(n1-i,n2-1,i);
		}
		}
		else
		{
           for(i=n3;i>n1/n2;i--)
		{
			if(n1-i<i)
			{
			an=an+f(n1-i,n2-1,n1-i);
			}
			else an=an+f(n1-i,n2-1,i);
		}
		}
	}
	}
	return an;
}
int main()
{
	int n,i,a[100]={0},b[100]={0};
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d%d",&a[i],&b[i]);
	}
	for(i=0;i<n;i++)
	{
		printf("%d\n",f(a[i],b[i],a[i]));
	}
}
int cal(int m,int n);
int main(int argc)
{  int i,t,p,q;
   cin>>t;
   for (i=1;i<=t;i++)
   { cin>>p>>q;
   cout<<cal(p,q)<<endl;}      //????

	return 0;

}
int cal(int m,int n)
{ int x;
 if (n==1||m==0)
	{x=1;}
 else if (m==2&&n!=1)
 {x=2;}
 else if(m==1)
 {x=1;}
	else if (n>m)
	{x=cal(m,m);}         //???????
	else 
	{ x=cal(m,n-1)+cal(m-n,n);}      //??????
	return x;}
int apple(int N,int M)
{
	int K;
	if(N==1) K=1;
	else if(M==1) K=1;
	else if(M==0) K=1;
	else if(M>=N) K=apple(N,M-N)+apple(N-1,M);
	else if(M<N) K=apple(N-1,M);
	return K;
}
int main()
{
	int t,M,N,i;
	scanf("%d",&t);
	for(i=1;i<=t;i++)
	{
		scanf("%d %d",&M,&N);
		printf("%d\n",apple(N,M));
	}
}
int main()
{
    long f[102][102]={0},i,j,n,m,m1;
    scanf("%d",&n);
    for (i=1;i<=100;i++) f[i][0]=1;
    for (i=1;i<=100;i++)
     for (j=1;j<=100;j++)
      if (j>=i) f[i][j]=f[i-1][j]+f[i][j-i];
        else f[i][j]=f[i-1][j];
    for (i=0;i<n;i++)
    {
      scanf("%d%d",&m,&m1);
      printf("%ld\n",f[m1][m]);
        }
}
int bai(int m,int n);
int main()
{
	int m[100],n[100],b[100],a,i;
	scanf("%d",&a);
	for(i=0;i<a;i++) scanf("%d %d",&m[i],&n[i]);
	for(i=0;i<a;i++) b[i]=bai(m[i],n[i]);
	for(i=0;i<a-1;i++) printf("%d\n",b[i]);
	printf("%d",b[a-1]);
	return 0;
}
int bai(int m,int n)
{
	int x=0;
	if(n==1) x=1;
	else 
	{
		if(m<n) x=bai(m,n-1);
		else x=bai(m,n-1)+bai(m-n,n);
	}
	return x;
}
int f(int m,int n)
{
    int c;

   if ((m>=n)&&(n>1)) 
           c=f(m,n-1)+f(m-n,n);
   if(m==0)
   c=1;
   if (n==1) 
           c=1;
   if (m<n)
         c= f(m,m);
    return(c);
    }
    
int main()
{
    int a[100],b[100],c[100];
    int n,i;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    scanf("%d %d",&a[i],&b[i]);
   
   
   for(i=0;i<n;i++)
   c[i]=f(a[i],b[i]);
   
    for(i=0;i<n;i++)
    {
      if(i==0)
      printf("%d",c[i]);
      else
      printf("\n%d",c[i]);
      }
   getchar();
     getchar();
      getchar();
}
int main()
{
    int f(int, int);
    int t, T, m, n;
    
    cin >> T;
    
    for(t = 0; t < T; t++)
    {
        cin >> m >> n;
        
        cout << f(m, n) << endl;
    }
    
    return 0;
}

int f(int m, int n)
{
    if(m >= n && n > 1) return f(m - n, n) + f(m, n - 1);
    else if(m < n && n > 1) return f(m, n - 1);
    else if(n == 1) return 1;
}
int work ( int m , int n )
{
   int sum;
   if ( n == 1 ) return 1;
   sum = work ( m , n - 1 );
   if ( m >= n ) sum += work ( m - n , n );
   return sum ;
}

int main ()
{
   int t , m , n;
   for ( scanf ( "%d" , &t ) ; t > 0 ; t -- )
    {
     scanf ( "%d%d" , &m , &n );
     printf ( "%d\n" , work ( m , n ) );
    }
  // getchar (); getchar ();
   return 0;
}
//****************************
//**Title:?????        **
//**Author:???1300017687 **
//**Date?2013.11.27        **
//**File?2.cpp             **
//****************************

//????????apple?????basket?????????
int total(int apple, int basket);		//apple?????basket??????????
int noempty(int apple, int basket);		//apple?????basket????????????????
int withempty(int apple, int basket);	//apple?????basket????????????????????

int main()
{
	int t, m, n;						//t???????
	cin >> t;
	for (int i = 1; i <= t ; i++)		//??????
	{
		cin >> m >> n;					
		cout << total(m , n) << endl;	//??total????
	}
}

int total(int apple, int basket)
{
	return withempty(apple, basket)+ noempty(apple, basket);	//total???noempty?withempty??
}
int noempty(int apple, int basket)		//apple?????basket????????????????
{
	if (apple < basket)					//??????????????????0
		return 0;
	else if (apple == basket)			//??????????????????
		return 1;
	else								//????????
		return total(apple - basket , basket);	//????apple-basket?????basket?????????
}
int withempty(int apple, int basket)	//???????????
{
	if (basket <= 1)					//??????????1????????0
		return 0;
	else								//????????
		return total(apple , basket - 1);	//????apple?????basket-1?????????
}
int sum=0;
int apple(int m,int n)
{
	sum=0;
	if(m==0&&n>0)
	return 1;
	if(m==1&&n>0)
	return 1;
	if(m>0&&n==1)
	return 1;
	if(m<0)
	return 0;
	sum=apple(m,n-1)+apple(m-n,n);
	return sum;
}
int main()
{
	int q,t,i,m,n;
	cin>>t;
	for(i=1;i<=t;i++)
	{
		
		cin>>m>>n;
		cout<<apple(m,n)<<endl;
	}
	cin>>q;
	return 0;
}
//********************
// 1.cpp
// ??  1200018415
// 2012 11 26
//********************

int putapples(int c, int d);

int main()
{
	int m, a, b, i;
	cin >> m;
	for (i = 1; i <= m; i++)
	{
		cin >> a >> b;
		if (a == 0)
			cout << "1" << endl;
		else
			if(a == 1)
				cout << b << endl;
			else
				cout << putapples(a, b) << endl;
	}
	return 0;
}

int putapples(int c, int d)
{
	if (c == 1 || c == 0 || d == 1)
		return 1;
	if (c < 0)
		return 0;
	else
		return putapples(c - d, d) + putapples(c, d - 1);
}
void main()
{
	int f(int m,int n);
	int k,m[100],n[100],i;
	scanf("%d",&k);
	for(i=0;i<k;i++)
		scanf("%d%d",&m[i],&n[i]);
	for(i=0;i<k;i++)
		printf("%d\n",f(m[i],n[i]));
}
int f(int m,int n)
{
	int result;
	if(m==0)
		result=1;
	else
	{
	if(m==1||n==1)
		result=1;
	if(n>1&&m>1&&m>=n)
		result=f(m,n-1)+f(m-n,n);
	if(n>1&&m>1&&m<n)
		result=f(m,n-1);
	}
	return result;

}
int main()
{
	int t,m,n,i,j,l;
	scanf("%d",&t);
	for(l=0;l<t;l++)
	{
		scanf("%d %d",&m,&n);
		int a[100][100];
		for(i=1;i<=m;i++)
		for(j=1;j<=n;j++)
		{
			if(i==1) a[i][j]=1;
			else if(j==1) a[i][j]=1;
			else if(i==j) a[i][j]=a[i][j-1]+1;
			else if(i<j)  a[i][j]=a[i][j-1];
			else if(j<i)  a[i][j]=a[i][j-1]+a[i-j][j];
		}
		printf("%d\n",a[m][n]);
	}
}
int empty(int n,int m)
{
    int k;
    if(m==n)
    {
            if(n==1) k=1;
            else k=1+empty(n-1,m);
    }
    if(m>n)
    {
           if(n==1) k=1;
           else k=empty(n-1,m)+empty(n,m-n);
    }
    if(m<n) k=empty(m,m);
    return k;
}
int main()
{
	      int i,t,a,b,c;
	      scanf("%d",&t);
	      for(i=0;i<t;i++)
	      {
                          scanf("%d %d",&a,&b);
                          c=empty(b,a);
                          printf("%d\n",c);
          }
}
int fkong(int m,int n)
{
  int f(int x,int y);
  if(n==1)
    return 0;
  else
    return f(m,n-1);
}
int ffei(int m,int n)
{
  int f(int a,int b);
  if(n==1||m==n)
    return 1;
  else if(m<n)
    return 0;
  else
  return f(m-n,n);
}
int f(int m,int n)
{
  if(n==1||m==1)
    return 1;
  else
    return fkong(m,n)+ffei(m,n);
}
int main()
{
  int m[22],n[22],i,t;
  scanf("%d",&t);
  for(i=0;i<t;i++)
  {
    scanf("%d%d",&m[i],&n[i]);
      printf("%d\n",f(m[i],n[i]));
  }
}
int dis( int m , int n )
{
    if(n == 1 || m == 0)//??????????????0 ???????1 
         return 1;
    if(m < n) //???????????????????????????? 
    {
         return dis(m , m);
    }
    if(n <= m)//????????????????????????????????n???????????? 
    { 
         return dis(m , n - 1) + dis(m - n , n);     
    }
}
int main()
{
    int t , m , n , i ,sum ;
    cin >> t ;//??????? 
    for( i = 1 ;i <= t ; i ++ ) //t??? 
    {
         cin >> m >> n; //????????? 
         sum = dis(m , n);//?????? 
         cout << sum << endl;//????? 
    }    
         return 0 ;
}
int f(int m,int n)
{
	int k;
	if(n==1||m<=1)k=1;
	else 
		if(m>=n)
			k=f(m,n-1)+f(m-n,n);
		else
			k=f(m,n-1);
	return k;
}
void main()
{
	int m[20],n[20],t,i;
	scanf("%d",&t);
	for(i=0;i<t;i++)
		scanf("%d%d",&m[i],&n[i]);
	for(i=0;i<t;i++)
		printf("%d\n",f(m[i],n[i]));
}
int apple(int m,int n)
{
    if(m==1||n==1) return 1;
    else if(m==n) return apple(m,n-1)+1;
    else if(m<n) return apple(m,m);
    else if(m>n) return apple(m,n-1)+apple(m-n,n);
}
int main()
{
    int t,i,m,n;
    scanf("%d",&t);
    for(i=1;i<=t;i++)
    {
        scanf("%d %d",&m,&n);
        printf("%d\n",apple(m,n));
    }
}
int g(int a, int b)	;
int f(int a, int b);
int i, n, a, b;
int main()
{
	cin>> n;
	for(i= 0; i< n; i++)
	{
		cin>> a >> b;
		cout<<f(a, b)<<endl;
	}
	return 0;
}
int f(int a, int b)
{
	if (a==0) return 1;
	if(b==1)
		return 1;
	int num=0;
	for(int i=0; i<b; i++)
		num+=g(a, b-i);
	//cout<<a<<" "<<b<<" "<<num<<endl;
	return num;
}
	
int g(int a, int b)	//????????
{
	if(a<b)
		return 0;
	int num=f(a-b,b);
	//cout<<"g:"<<a<<" "<<b<<" "<<num<<endl;
	return num;//???????????
}
int apple(int a,int b)
{
	if(b==1) return b;
	else if(a>b) return apple(a,b-1)+apple(a-b,b);
	else if(a<b) return apple(a,b-1);
	else return apple(a,b-1)+1;
}
main()
{
	int a,b,c,n,i;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d %d",&a,&b);
		c=apple(a,b);
		printf("%d\n",c);
	}
}
//int s=0;
int fen(int m,int n)
{
  if(m==0||n==1)
  {
   return 1;
  }
  if(m>=n)
  {
   return fen(m-n,n)+fen(m,n-1);
 }
  else
  {
    return fen(m,m);
  }
} 
int main()
{
  int a;
  cin >> a;
  int i=0;
  while(i<a)
  {
   int m,n;
   cin >> m >> n;
   
   //s=0;
   cout << fen(m,n) << endl;
   
   i++;
  }
  cin.get();cin.get();cin.get();
  return 0;
}
int main()
{
	int apple(int m,int n);
	int t,i,m,n;
	scanf("%d",&t);
	for(i=1;i<=t;i++)
	{
		scanf("%d %d",&m,&n);
		printf("%d\n",apple(m,n));
	}
	return 0;
}
int apple(int m,int n)
{
	int k;
	if(m>=n&&n>1)
		k=apple(m,n-1)+apple(m-n,n);
	else if(n>1)
	{
		k=apple(m,n-1);
	}
	else
		k=1;
	return (k);
}
int sep(int m,int n)
{
	int c;
	if(n==1||m==0) c=1;
	else if(m<n) c=sep(m,m);
	else c=sep(m,n-1)+sep(m-n,n);
	return c;
}
int main()
{
	int a[20][2],t,i,j;
	scanf("%d",&t);
	for(i=0;i<t;i++) for(j=0;j<2;j++) scanf("%d",&a[i][j]);
	for(i=0;i<t;i++) printf("%d\n",sep(a[i][0],a[i][1]));
}
int waye(int m, int n)
{
	if(m == 0 || m == 1 || n == 1) return 1;
	if(m >= n)
		return (waye(m - n, n) + waye(m, n - 1));
	if(m < n) return (waye(m, n - 1));
}

int main()
{
	int t, m,n;
	cin >> t;
	for(; t > 0; t--)
	{
		cin >> m >> n;
	    cout << waye(m, n) << endl;
	}
	return 0;
}
int ways(int m,int n)
{
	int c=0;
	if(m>=0)
	{
		if(m==1||n==1||m==0)
		{
			c=1;
		}
		else
		{
			c=ways(m,n-1)+ways(m-n,n);
		}
	}
	else
	{
		return 0;
	}
	return c;
}


int main()
{
	int t,i=1,m,n;
	cin>>t;
	for(i=1;i<=t;i++)
	{
		cin>>m>>n;
		cout<<ways(m,n)<<endl;
	}
	return 0;
}
int num(int M,int N)
{
    if(M>N&&N!=1)
       return num(M-N,N)+num(M,N-1);
    else if(M==N)
       return num(M,N-1)+1;
    else if(M<=N&&M!=1)
       return num(M,M);
    else if(M==1||N==1)
       return 1;
}
main()
{
      int t,i=0;
      scanf("%d",&t);
      while(i<t){
                 int M,N;
                 scanf("%d %d",&M,&N);
                 int situation;
                 situation=num(M,N);
                 printf("%d\n",situation);
                 i=i+1;
                 }                  
}
int main()
{
	int put(int m,int n);
	int i;int t;
	int m,n;int d[10];
	scanf("%d",&t);
	for(i=0;i<t;i++)
	{
		scanf("%d%d",&m,&n);
		d[i]=put(m,n);
	}
	for(i=0;i<t;i++)
	{
		printf("%d\n",d[i]);

	}
	scanf("%d",&i);
		return 0;
}
int put(int m,int n)
{
	
int k=0;
	if(m<=1||n<=1)
		k=1;
	else
	{
		if(m>=n)
			k=put(m-n,n);
		
			k+=put(m,n-1);

	}
	return k;

}
int main()
{
	int m[21],n[21],t,i;
	int count1(int,int);
	scanf("%d",&t);
	for(i=1;i<=t;i++)
		scanf("%d %d",&m[i],&n[i]);
	for(i=1;i<=t;i++)
		printf("%d\n",count1(m[i],n[i]));
	return 0;
}
int count1(int m,int n)
{
	int k;
	if(n==1||n==0) return 1;
	if(m==1||m==0) return 1;
	if(m<n) return  count1(m,m);
	k=count1(m,n-1)+count1(m-n,n);
	return k;
}
/*
 * ?????.cpp
 *
 *  Created on: 2011-11-23
 *      Author: ???
 */

int m,n,k=0;//??????
int emptyOverone(int apple,int plate);//???????
int AllFull(int apple,int plate){//??????????????
	if(apple<plate) return 0;//????
	if(plate==apple) return 1;
	/*?(apple>plate)????*/ return AllFull(apple-plate,plate)+emptyOverone(apple-plate,plate);
}
int emptyOverone(int apple,int plate){//???????????????
	if(plate==1) return 0;//??
	/*?(apple<plate)????*/ return AllFull(apple,plate-1)+emptyOverone(apple,plate-1);
}

int main(){//???
	int zushu=0;
	cin>>zushu;
	int shuchu=0;
	while(zushu>0){//???????
		cin>>m>>n;
		shuchu+=emptyOverone(m,n)+AllFull(m,n);//??????
		cout<<shuchu<<endl;//??
		zushu--;
	shuchu=0;}
	return 0;
}
void main()
{
	int put(int x,int y);
	int m[100],n[100],t,k[100],i;
	scanf("%d",&t);
	for(i=1;i<=t;i++)
		scanf("%d %d",&m[i],&n[i]);
	for(i=1;i<=t;i++)
	{
		k[i]=put(m[i],n[i]);
		printf("%d\n",k[i]);
	}
}
int put(int x,int y)
{
	
	if(y==1)
		return(1);
	else if(x>y)
		return(put(x-y,y)+put(x,y-1));
	else if(x<=y&&x!=1)
		return(put(x,x-1)+1);
	else
		return(1);

		

	
}