semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int ways(int apple,int plate)
{
	int waynumber;
	if(plate==1||apple==1||apple==0) 
		waynumber=1;
	else if(apple<plate)
		waynumber=ways(apple,apple);
	else waynumber=ways(apple,plate-1)+ways(apple-plate,plate);
	return waynumber;
}
int main()
{
	int applenumber[20],platenumber[20],n,i;
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d%d",&applenumber[i],&platenumber[i]);
	for(i=0;i<n;i++)
		printf("%d\n",ways(applenumber[i],platenumber[i]));
	return 0;
}
int sum;
int main()
{
	void pingguo();
	int t;
	scanf("%d",&t);
	int i;
	for(i=0;i<t;i++)
	{
		pingguo();
	}
	return 0;
}
void pingguo()
{
	sum=0;
	void func(int,int);
	int apple,plate;
	scanf("%d %d",&apple,&plate);
	func(apple,plate);
	printf("%d\n",sum);
}
void func(int apple,int plate)
{
	if(apple==0||plate==1)
	{
		sum++;
	}
	else
	{
		if(plate>apple)
		{
			func(apple,apple);
		}
		else
		{
			func(apple-plate,plate);
			func(apple,plate-1);
		}
	}
}
int way(int m,int n);
int main()
{
    int N,m,n;
    cin>>N;
    for(int i=0;i<N;i++)
    {
            cin>>m>>n;
            cout<<way(m,n)<<endl;
    }
}
int way(int m,int n)
{
    if(n==1)return 1;
    else if(m==n)return way(m,n-1)+1;
    else if(m<n)return way(m,m);
    else return way(m,n-1)+way(m-n,n);
}
int digui(int m,int n)
{
	if(m<n)
		return digui(m,m);
	else
	{
		if(m==0||n==1)
			return(1);
		else return(digui(m,n-1)+digui(m-n,n));
	}
}
void main()
{
	int m,n,t,i,a[20],b[20],c[20],p,q;
	scanf("%d",&t);
	for(i=0;i<t;i++)
	{
		scanf("%d%d",&b[i],&c[i]);
		p=b[i];q=c[i];
		a[i]=digui(p,q);
	}
	printf("%d",a[0]);
	if(t>=1)
	for(i=1;i<t;i++)
	printf("\n%d",a[i]);
}
int mustput(int m,int n)
{
    int put(int m,int n);
    int c,d=m-n;
    if(n==1)
    {
            c=1;
    }
    else
    {
        c=put(d,n);
    }
    return c;
}
int min(int m,int n)
{
    if(m>=n)
    {
        return n;
    }
    else
    {
        return m;
    }
}
int put(int m,int n)
{

    int c=0;
    int i;
    if(m==0)
    {
        c=1;
    }
    for(i=1;i<=min(m,n);i++)
    {
        c=c+mustput(m,i);
    }
    return c;
}
int main()
{
     int m,n,l;
     scanf("%d",&l);
     for(int i=1;i<=l;i++)
     {
         scanf("%d %d",&m,&n);
         printf("%d\n",put(m,n));
     }

}
int num(int m,int n);
int num1(int m,int n);
int num2(int m,int n);
int main()
{
	int m,n,k,i;
	scanf("%d",&k);
	for(i=1;i<=k;i++)
	{
    scanf("%d%d",&m,&n);
	printf("%d\n",num(m,n));
	}
return 0;
}


int num(int m,int n)
{return(num1(m,n)+num2(m,n));}
int num1(int m,int n)    //full
{ 
	if(m==n)return(1);
	else if(n==1)return(1);
	else if(m<n)return(0);
	else return(num(m-n,n));
}
int num2(int m,int n)   //empty
{
	if(m==1)return(1);
	if(n==1)return(0);
	else return(num(m,n-1));
}
int f(int, int);
int f_n(int, int);
int f_e(int, int);

int f(int x, int y){
	if (x == 1) return 1;
	return f_e(x, y) + f_n(x, y);
}

int f_e(int x, int y){
	return f(x-1, y);
}

int f_n(int x, int y){
	if (y < x) return 0;
	return f(x, y-x);
}

int main() {
	int n, x, y;
	cin >> n;
	for (int i = 0; i < n; i ++) {
		cin >> y >> x;
		cout << f(x, y) << endl;
	}
	return 0;
}
int  cal(int x,int y)
{
   int i,sum;  
   if ((x<0)||(y==0)) return 0;
   
   if (x==0) return 1;
   if (y==1) return 1;
   
   else return cal(x-y,y)+cal(x,y-1);
   
   return sum;
}
int main()
{
    int n,m,i,l;
    scanf("%d",&l);
    for (i=1;i<=l;i++)
   {
      scanf("%d%d",&m,&n);      
      printf("%d",cal(m,n));
      if (i!=l) printf("\n");
    }
 
    return 0;
}
int f(int,int);
void main()
{
	int t;
	scanf("%d",&t);
	int i;
	for(i=0;i<t;i++)
	{
		int m,n,a;
		scanf("%d %d",&m,&n);
		a=f(m,n);
		printf("%d\n",a);
	}
}
int f(int a,int b)
{
	if(a<0) return(0);
	else if(b<0) return(0);
	else if(a==1||b==1) return(1);
	else
	{
		int s;
		s=f(a,b-1)+f(a-b,b);
		return(s);
	}
}
int apple(int m, int n)
{
    if(m<n&&m!=0&&n>1)
    {
           return apple(m,n-1);
    }
    else if(m>=n&&m!=0&&n>1)
    {
           return apple(m,n-1)+apple(m-n,n);
    }
    else if(m==0)
    return 1;
    else if(n==1&&m!=0)
    return 1;
}
main()
{
      int t,i,m,n;
      scanf("%d",&t);
      for(i=0;i<t;i++)
      {
                      scanf("%d %d",&m,&n);
                      printf("%d\n",apple(m,n));
      }
}
main()
{
 int n,a[100][2];
 int f(int a,int b);
 scanf("%d",&n);
 for(int i=0;i<n;i++) scanf("%d %d",&a[i][0],&a[i][1]);
 for(int i=0;i<n;i++) printf("%d\n",f(a[i][0],a[i][1]));
}
int f(int a,int b)
{
    int k[101][101];
    for(int i=0;i<=101;i++) 
    {
        k[0][i]=1;
        k[1][i]=1;
        k[i][1]=1;
    }
    for(int i=1;i<=101;i++)
    {
        for(int j=2;j<=101;j++)
        {
            if(i<j) k[i][j]=k[i][j-1];
            else k[i][j]=k[i][j-1]+k[i-j][j];
        }
    }
    return k[a][b];
}
// ?????
// ??? 1100012820
// 20111115
//******************
int place(int m, int n)
{
	if (m < 0) return 0;
	if (n == 1) return 1;
	return place(m, n - 1) + place(m - n, n);
}
int main()
{
	int i, n;
	cin >> n;
	for(i = 0; i < n; i++)
	{
		int k = 0;
		int M, N;
		cin >> M >> N;
		cout << place (M, N) << endl;
	}
	return 0;
}
int F(int m,int n)   
{   
    if(m==0||m==1) return 1;   
    if(n==0||n==1) return 1;   
    if(m<n) 
		return F(m,m);   
    else 
		return F(m-n,n)+F(m,n-1);   
}
int main()   
{
    int m[20] , n[20] , i; 
	int t;
	cin >> t;
	for(i = 0 ; i < t ; i++)
		cin >> m[i] >> n[i];
    for(i = 0 ; i < t ; i++)   
		cout << F(m[i],n[i]) << endl;
	return 0;
}
int n=0; 
int digui(int M, int N) 
{ 
  if(N==1) 
  { 
    return n+1; 
  } 
  else if(M==1) 
  { 
    return n+1; 
  } 
  else 
  { 
    if(M>N) return digui(M-1,N); 
    else return digui(M-1,N)+digui(M,N-M); 
  } 
} 
 
int main() 
{ 
  int M,N,n,i,K; 
  scanf("%d",&n); 
  for(i=1;i<=n;++i) 
  { 
    scanf("%d%d",&N,&M); 
    K=digui(M,N); 
    printf("%d\n",K); 
  } 
  return 0; 
}
int baifang(int m,int n);
int main()
{
 	int t,m,n,i;
 	scanf("%d",&t);
 	for(i=1;i<=t;i++){
		scanf("%d %d",&m,&n);
		printf("%d\n",baifang(m,n));
		}
}
int baifang(int m,int n){
	int i,r;
	if(n==1) return 1;
	if(m==1) return 1;
	if(m<n){
		r=baifang(m,n-1);
		}
	else{
		r=baifang(m,n-1)+baifang(m-n,n);
		}
	return r;
	}
int waynum(int m, int n)
{
	if (n == 1 || m == 1 || m == 0)
		return 1;
	else if (m <= 0)
		return 0;
	else
		return (waynum(m, n - 1) + waynum(m - n, n));
}
int main()
{						
	int a, m, n;
	cin >> a;
	while (a --)
	{
		cin >> m >> n;
		cout << waynum(m, n) << endl;
	}
	return 0;
}
int put(int m,int n)
{ int p1=0,p2=0,s;
  if(n==1) s=1;
  else
  {if(m>=n) p1=put(m-n,n);
   p2=put(m,n-1);
   s=p1+p2;}
  return(s);
}



void main()
{ int t,M[20],N[20],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",put(M[i],N[i]));

}
int main()
{
    int f(int m,int n);
    int a[20],b[20],t,i;
    scanf("%d",&t);
    for(i=0;i<t;i++)
    scanf("%d %d",&a[i],&b[i]);
    for(i=0;i<t;i++)
		printf("%d\n",f(a[i],b[i]));
    return 0;
}
    int f(int m,int n)
 {
     int c;
    if(m!=1&&n==1) c=1;
	else if(m==1&&n!=1) c=1;
      else if(m==1&&n==1)c=1;
	  else if(m>n) c=f(m-n,n)+f(m,n-1);
	  else if(m==n) c=1+f(m,n-1);
	  else if(m<n) c=f(m,m);
     return(c);
}
int k=0,t;
void main()
{
	void apple(int a[],int b[],int c[]);
	int M[100],N[100],s[100]={0},i;
	scanf("%d",&t);
	for(i=0;i<t;i++)
		scanf("%d%d",&M[i],&N[i]);
	apple(M,N,s);
	printf("%d",s[0]);
	for(i=1;i<t;i++)
		printf("\n%d",s[i]);
}
void apple(int a[],int b[],int c[])
{
	int i;
	int num(int a,int b);
	for(i=0;i<t;i++)
		c[i]=num(a[i],b[i]);
}
int num(int a,int b)
{
	if(a<b)
	{
		b=a;
		k=num(a,b);
	}
	else
		if(b==1||a==0)
			k=1;
		else if(b>1)
			k=num(a,b-1)+num(a-b,b);
	return(k);
}
int main()
{
	int empty (int m,int n);
	int full (int m,int n);
	int i;int n;int num[20][2];int z[20];
	
	scanf("%d",&n);
	for(i=0;i<=n-1;i++)
	{
	scanf("%d %d",&num[i][1],&num[i][0]);
    z[i]=full(num[i][0],num[i][1])+empty(num[i][0],num[i][1]);
	}
	for(i=0;i<=n-1;i++)
	printf("%d\n",z[i]);
	return 0;
}
int full (int m,int n)
{
	int empty (int m,int n);
	int result;
	if(m<n) result=full(m,n-m)+empty(m,n-m);
	if(m==n) result=1;
	if(m>n) result=0;
	return(result);
}
int empty (int m,int n)
{
int result;
if(m==1) result=0;
else result=full(m-1,n)+empty(m-1,n);
return(result);
}
int main()
{
    int Q(int x,int y);
    int a[20],b[20],c[20];
    int t,i;
    scanf("%d",&t);
    for(i=0;i<t;i++)
    {
        scanf("%d %d",&a[i],&b[i]);
        c[i]=Q(a[i],b[i]);

    }
    for(i=0;i<t;i++)
    {
        printf("%d\n",c[i]);
    }
}
int Q(int x,int y)
{
    if(x==1||y==1)
    {
        return 1;

    }
    else if(x<y)
    return(1+Q(x,x-1));
    else if(x==y)
    return(1+Q(x,y-1));
    else if(x>y)
    return(Q(x,y-1)+Q(x-y,y));
}
int put(int, int);
int main()
{
	int nLoop;
	int m,n;
	scanf("%d", &nLoop);
	while(nLoop--)
	{
		scanf("%d %d", &m, &n);
		printf("%d\n",put(m,n));
	}
	return 0;
}
int put(int m, int n)
{
	if(m==0 || m==1 || n==1) return 1;
	int sum = 1, i;
	for(i=2;i<=n&&i<=m;i++)
		sum += put(m-i,i);
	return sum;
}
int f(int a,int b)
{
    if (b==1) {return 1;}
    if (a<0) {return 0;}
    else {return f(a-b,b)+f(a,b-1);}
}
int main ()
{
    int w,m,n;
    scanf ("%d",&w);
    for (;w>0;w--)
    {
        scanf ("%d %d",&m,&n);
        printf("%d\n",f(m,n));
    }
}
void apple(int, int, int);
int sum;

int main()
{
	int t, m, n;
	cin >> t;
	for(int i = 0; i < t; i++)
	{
		sum = 0;
		cin >> m >> n;
		apple(0, m, n);
		cout << sum << endl;
	}
	return 0;
}

void apple(int s, int x, int y)
{
	int i;
	if(y == 1)
	{
		sum++;
	}
	else
	{
		for(i = s; i <= x/y; i++)
		{
			apple(i, x - i, y - 1);
		}
	}
}
int method(int,int);
int occupy(int,int);
int main ()
{
	int M, N, t, i;//??????M?????N?t???
	cin >> t ;
	for( i = 0; i < t; i++)
	{
        cin >> M >> N;
		if ( M == 0 || N == 0)//???????????0.???0????
			cout <<"0"<<endl;
		else
		{
          cout << method(M, N)<<endl;//???????????
		}
	}

	return 0;
}
int method(int x, int y)
{

	if(y == 1 || x == 1)//??????????1????????
	{
		return 1;
	}
	else
		return  occupy(x,y) + method(x,y-1);//??????????????????????occupy?????????????
}
int occupy(int a, int b)//?????????????????
{
	
	if(a >= b)//?????????????N?????M????????????N?????M-N??????????
	    return method(a-b,b);
	else//??????????????????0?
		return 0;
}
int main()
{
    int apple(int x,int y);
    int i,t,m,n;
    scanf("%d",&t);
    for(i=0;i<t;i++)
    {
        scanf("%d %d",&m,&n);
        printf("%d\n",apple(m,n));
    }
    return 0;
}
int apple(int x,int y)
{
    int p=0;
    if(y==1) p=1;
    else if(x>y) p=apple(x,y-1)+apple(x-y,y);
    else if(x==y) p=apple(x,y-1)+1;
    else p=apple(x,y-1);
    return(p);
}
//*************************************************
//***????????***
//***??????***
//***???2012.1.11***
//*************************************************

int f(int a,int b)
{
	if (b == 1 || a == 0 || a == 1)
	{
		return 1;
	}
	else if (a >= b && b > 1)
	{	
		return f(a - b,b) + f(a,b - 1);
	}
	else if (b > 1 && a < b)
	{
		return f(a,a);
	}
}

int main ()
{
	int t,i,M,N;
	cin >> t;
	for (i = 0; i < t; i++)
	{
		cin >> M >> N;
		cout << f(M,N) << endl;
	}
	return 0;
}
int a(int m,int n);
main()
{
	
	int t,i;
	scanf("%d",&t);
	for(i=1;i<=t;i++)
	{
		int p,q;
		scanf("%d%d",&p,&q);
		printf("%d\n",a(p,q));
	}
	return 0;
}
int a(int m,int n)
{
	if(m<n)
	{
		return a(m,n-1);
	}
	else if(n==m&&n!=1)
	{
		return a(m,n-1)+1;
	}
	else 
	{if(n==1)
	{
		return 1;
	}
	else
	{
		return a(m-n,n)+a(m,n-1);
	}
	}
}
int full (int M, int N);
int empty (int M,int N);
int main()
{
	int t, M, N, i, num;
	cin >> t;
	for (i = 0; i < t; i++)
		{
			cin >> M >> N;
			cout << full(M , N) + empty(M , N) << endl;
		}
	return 0;
}
int full (int M, int N)
{
	if ( M < N )
		return 0;
	if ( M == N )
		return 1;
	if ( M > N )
	{
		return( full( M - N ,N ) + empty (M - N, N) ); 
	}

	
}
int empty (int M,int N)
{   
	if (N == 2)
		return 1;
	if (N == 1)
		return 0;
	if (N != 1 && N != 2)
	return (full( M, N - 1) + empty(M, N - 1)); 
	
}
int way (int,int);
int main()
{
	int n;
	int t[2];
	cin>>n;
	while ( n-- )
	{
		cin>>t[0]>>t[1];
		cout<<way(t[0],t[1])<<endl;
	}
}
int way(int a,int b)
{
	if ( b == 1 || a == 1 || a== 0 )
		return 1;
	if ( a >= b )     
		return way( a , b - 1 ) + way( a - b , b );
	if ( a < b )
		return way( a , a );
}
int zhonglei(int m,int n)
{
	int temp;
	if(m==0)
		return 1;
	else if(m==1)
		return 1;
	else if(n==1)
		return 1;
	else if (m<0)
		return 0;
	else 
	{
		temp=zhonglei(m-n,n);
	    temp=temp+zhonglei(m,n-1);
	    return temp;
	}
}
int main()
{
	int t,i,tm,tn,tk;
	cin>>t;
	for(i=0;i<t;i++)
	{
		cin>>tm>>tn;
		tk=zhonglei(tm,tn);
		cout<<tk<<endl;
	}
	return 0;
}
int apple(int m,int n);
int maxapple(int m,int n){
if(m==n)
return 1;
if(n==1)
return 1;
else return apple(m-n,n);}
int minapple(int m,int n){
if(n==2)
return 1;
if(n==1)
return 0;
else
return apple(m,n-1);
}
int apple(int m,int n){
if(m<1||n<1)
return 0;
if(n==1)
return 1;
else
return maxapple(m,n)+minapple(m,n);
}
int main(){
int i,k,m,n;
cin>>k;
for(i=1;i<=k-1;i++){
cin>>m>>n;
cout<<apple(m,n)<<endl;}
cin>>m>>n;
cout<<apple(m,n);
}
int f(int m,int n)
{
	if(n==1)
	{
		return 1;
	}
	if(m>=n)
	{
		return f(m,n-1)+f(m-n,n);
	}
	else
	{
		return f(m,n-1);
	}
}
int main()
{
	int n,m,t,i,k;
	scanf("%d",&t);
	for(i=1;i<=t;i++)
	{
		scanf("%d %d",&m,&n);
		k=f(m,n);
		printf("%d",k);
		printf("\n");
	}
	return 0;
}
int ways(int,int);
int main()
{
	int m,n,k,t;
	cin>>t;
	while ( t-- )
	{
		cin>>m>>n;
		k=ways(m,n);
		cout<<k<<endl;
	}
	return 0;
}
int ways( int a,int b )
{
	if ( ( a == 0 ) || ( b == 1 ) )
	{
		return 1;
	}
	if ( ( a < 0 ) || ( b <= 0 ) )
	{
		return 0;
	}
	return ( ways( a-b,b ) + ways ( a,b-1 ) );
}
int function(int m,int n)
{
	int sum=0;
    if (m==0||m==1||n==1) 
    return 1; 
    else if (m<0)
	return 0;
    else sum=sum+function(m,n-1)+function(m-n,n);
    return sum;
}


void main()
{
	int t,i,M[20],N[20];

	scanf("%d",&t);
	for(i=0;i<=t-1;i++)
	{
		scanf("%d%d",&M[i],&N[i]);
	}

	for(i=0;i<=t-1;i++)
	{
		printf("%d\n",function(M[i],N[i]));
	}
}
int ap(int x,int y)
{
	if(y==1||x==1)
	{
		return 1;
	}
	else if(y==2)
	{
		return 1+x/2;
	}
	else if(x<=y)
	{
		return (1+ap(x,x-1));
	}
	else
	{
		return (ap((x-y),y)+ap(x,(y-1)));
	}
}
int main()
{
	int n;
	scanf("%d",&n);
	int a,b,i;
	for(i=0;i<n;i++)
	{
	    scanf("%d%d",&a,&b);
		printf("%d\n",ap(a,b));
	}
	return 0;
}
int f(int m,int n)
{
	if(m==1||n==1||m==0) return(1);
	else if(m<0) return(0);
	else if(m>1&&n>1)return(f(m,n-1)+f(m-n,n));//???? 
}
int main()
{
	int M,N,t;
	cin>>t;//????????? 
	for(int i=1;i<=t;i++)
	{
		cin>>M>>N;//?????? 
		cout<<f(M,N)<<endl;//???? 
	}
	
	return 0;
}
int a(int m,int n)
{
	int c;
	 if(m == 1 || n== 1 || m == 0) return 1; 
	 if(m<n)    return a(m, m);   
	 else return a(m-n,n)+a(m,n-1);
}
main()
{
	int m[20],n[20],k,c,i;
	scanf("%d\n",&k);
	
	for(i=0;i<k;i++)
	{
		scanf("%d %d",&m[i],&n[i]);
		c=a(m[i],n[i]);
		printf("%d\n",c);
	}
}
int apple(int x,int y)
{
  int k;
  if(y==1)   k=1;
  else   
   {if(x>y)   k=apple(x-y,y)+apple(x,y-1);
    if(x<y)   k=apple(x,y-1);
    if(x==y)   k=1+apple(x,y-1);}
 return(k);
 }
void main()
{
  int i,a,m[50],n[50];
  scanf("%d\n",&a);
  for(i=0;i<a;i++) scanf("%d %d\n",&m[i],&n[i]);
  for(i=0;i<a;i++)  printf("%d\n",apple(m[i],n[i]));
return(0);
}
int f(int m,int n){
    if(m<n)return f(m,m);
    if(m==1&&n!=0||n==1&&m!=0)return 1;//??? m>=1
    if(m==0||n==0)return 1;//??????????0
    if(m>=n)return f(m-n,n)+f(m,n-1);
}
int main(){
    int m,n,t;
    cin>>t;
    while(t--){
        cin>>m>>n;
        cout<<f(m,n)<<endl;
    }
}
int count(int,int);
int main()
{
	
	int num;
	cin>>num;
	for(int i=0;i<num;i++)
		{
			int m,n;
			cin>>m>>n;
			cout<<count(m,n)<<endl;
		}
	return 0;
}
int count(int m,int n)
{
	if(n==1||m==0)
		return 1;
	if(n>m)
		return count(m,m);
	return count(m,n-1)+count(m-n,n);
}
/*??(15-11) ?????*/ 



int types(int m,int n);

int full(int m,int n)//m?????n???
{
	if(m<=n || n==1) return 1;
	else
	{
		return types(m-n,n);
	}
} 

int types(int m,int n)//m?????n??? 
{
	int num=0;
	int i;
	if(m<n) return types(m,m);
	else 
	{
		for(i=0;i<n;i++) num=num+full(m,n-i);
		return num;
	}
}

int main()
{
    int t;
    cin>>t;
    while(t--)
    {
    	int m,n;
    	cin>>m>>n;
    	cout<<types(m,n)<<endl;
    }
	return 0;
}
int sum;
int work(int n,int m)
{
    if(m>n) m=n;
    if(n==1||m==1) return 1;
    if(n!=0&&m==0)  return 0;
    if(n==0&&m!=0)  return 0;
    if(n==0&&m==0)  return 1;
    return  work(n-m,m)+work(n,m-1);
}
int main()
{   
    int a,b,c,i;
    scanf("%d",&c);
    for(i=1;i<=c;i++)
    {
    scanf("%d %d",&a,&b);
    printf("%d\n",work(a,b));
    }
}
int fang(int m,int n,int j)
{
    int a=0,k,i;
    if(n==1)
    return m>=j;
    else if(n<=m)
    {
    for(k=j;k<m;k++)     
    {
         a+=fang(m-k,n-1,k);           
    }
    }
    else if(n>m)
    {
         n=m;
         for(k=j;k<m;k++)
         {
                         a+=fang(m-k,n-1,k);
         }
    }
    return a;
}

int main()
{
    int t,M[20],N[20],k[20],i;
    scanf("%d",&t);
    for(i=0;i<t;i++)
    {
                    scanf("%d %d",&M[i],&N[i]);
                    k[i]=fang(M[i],N[i],0);
    }
    for(i=0;i<t;i++)
    {
                    printf("%d\n",k[i]);
    }
    return 0;
}
int classify(int M, int N)
{
    if(M==1||M==0||N==1) return 1;         //?????????????????????????? 
    else if(M<0) return 0;          //????????0 ???? 
    else return classify(M,N-1)+classify(M-N,N);  //??M,N???????M,N-1????M-N,N??? 
}
int main()
{
    int t,i=0,M,N;
    cin>>t;
    int p[t];
    while(i<t)
    {
        cin>>M>>N;          //??n??? 
        p[i]=classify(M,N);    //?????????
        i++; 
    }
    for(i=0;i<t;i++)          //???????? 
    cout<<p[i]<<endl;
    return 0;
}
//????????
//???2010.12.06
//??????
//???1000012856

int apple(int, int);
int main()
{
	//t?????i?????num?????way??????
	int t, i, num[20][2], way[20];
	cin >> t;
	for(i = 0; i < t; i++)
	{
		cin >> num[i][0] >> num[i][1];
	//?apple????way
		way[i] = apple(num[i][0], num[i][1]);
	}
	for(i = 0; i < t; i++)
		cout << way[i] << endl;		//??????????

	return 0;
}

int apple (int a, int b)			//?apple?????
{
	if(b == 0 || b == 1)			
		return 1;
	else if (b > a)
		return apple (a, a);
	else
		return apple(a, b - 1) + apple (a - b, b);
}
int f(int m,int n)
{
    if(m<0) return 0;
    else if(n==1) return 1;
    else return f(m,n-1)+f(m-n,n);
}
main()
{
      int t,m,n,i,j,g;
      scanf("%d",&t);
      for(g=0;g<t;g++)
      {
                      scanf("%d %d",&m,&n);
                      printf("%d\n",f(m,n));
      }
}
int k = 0;
void put(int m, int n, int l)  //m??????n?????l????????????? 
{
	int i;
	for (i = l; i <= m; i++)
		if (m - i == 0)  // ???? 
			k++;
		else if (n > 1) // ?? 
			put(m - i, n - 1, i);
}
int main()
{
	int t, m, n;
	cin >> t;
	while (t != 0)
	{
		cin >> m >> n;
		k = 0; // k??0 
	    put(m,n,1);
		cout << k << endl;
		t--;
	}
	return 0;
}
//****************************************
//*??: ?????                     **
//*?????? 1100013012              **
//*???2011.11.16                     **
//****************************************
int num = 0 ;

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

int main()
{
	int t , k , m , n ;
	cin >> t ;
	for ( k = 0 ; k < t ; k++ )
	{
		cin >> m >> n ;
		cout << apple(m , n) << endl ;
	}
	return 0 ;
}
/*???
???*/
int sum(int m, int n, int lim)//m????n???????????
{
	if(n == 1 && m <= lim)
		return 1;
	if(n == 1 && m > lim)
		return 0;
	if (m == 0)
		return 1;
	int max, i, a;
	if(m % n == 0)
		max = m / n;
	else
		max = m / n + 1;

	a = 0;
	if(lim > m)
		lim = m;
	for (i = lim; i >= max; i--)
		a += sum(m - i, n - 1, i);
	return a;
}
int main ()
{
	int m, n, k, i;
	cin >> k;
	for(i = 1; i <= k; i++)
	{
		cin >> m >> n;
		cout << sum(m,n,m) << endl;
	}
	return 0;
}
int main(int argc, char *argv[])
{
  int i,t,m,n;
  scanf("%d",&t);
  for(i=0;i<=t-1;i++)
  {
      scanf("%d %d",&m,&n);
      printf("%d",f(m,n));
      if(i!=t-1) printf("\n");
  }
  	
  return 0;
}

int f(int m,int n)
{
     int x=0;
     if(m<0) x+=0;
     else if(m==0) x+=1; 
     else if(n>1) x+=f(m,n-1)+f(m-n,n);
     else if(n==1) x+=1;
     return x;
}
int search(int x,int y,int z)
{
	int s=0,i;
	if(y>1)
		for(i=z;i<=x/y;i++)
			s+=search(x-i,y-1,i);
	else s=1;
	return s;
}

int main()
{ 
	int t,M,N,i;
	cin>>t;
	for(i=0;i<t;i++)
	{
		cin>>M>>N;
		cout<<search(M,N,0)<<endl;
	}
	return 0;
}
int f (int x,int y){
	int result;
	if(y==1||x==1||x==0)
		return 1;
	else if(x-y<0)
		return f(x,x);
	else 
	{	result=f(x,y-1)+f(x-y,y);
	return result;}
}
int main(){
 int M,N,n,r,i;
 scanf("%d",&n);
 for(i=0;i<n;i++){
	 scanf("%d %d",&M,&N);
	 r=f(M,N);
	 printf("%d\n",r);
 }
 return 0;
}
int f(int m,int n){
    if(m<n)return f(m,m);
    if(m==1||n==1||!n)return 1;//??? m>=1
    if(m>=n)return f(m-n,n)+f(m,n-1);
}
int main(){
    int m,n,t;
    cin>>t;
    while(t--){
        cin>>m>>n;
        cout<<f(m,n)<<endl;
    }
}
int PlaceApple(int,int);
int main()
{
	int Apple,Plate,t;
	cin>>t;
	while(t--)
	{
		cin>>Apple>>Plate;
		cout<<PlaceApple(Apple,Plate)<<endl;
	}
}
int PlaceApple(int AppleNumber, int PlateNumber)
{
    if(AppleNumber < 0 || PlateNumber == 0)
        return 0;
    if(AppleNumber == 1 || AppleNumber == 0 || PlateNumber == 1)
        return 1;
    int sum=0;
    for(int i = 0; i <= AppleNumber/PlateNumber; i++)
        sum += PlaceApple(AppleNumber - PlateNumber *i, PlateNumber - 1);
    return sum;
}
int f(int x,int y)
{
 if(x<y)
  y=x;
 if(x==0)
  return 1;
 if(y==1)
  return 1;
 if(x>=y)
  return f(x,y-1)+f(x-y,y);
  return 0;
}
main()
{
 int t,n,m;
 scanf("%d",&t);
 while(t--)
 {
  scanf("%d %d",&m,&n);
  printf("%d\n",f(m,n));
 }
}
//****************************
//*????????         **
//*?????? 1300012965  **
//*???20131127			**
//****************************
int apple(int mf, int nf)
{
	if(nf == 1)
		return 1;
	if(mf == 0)
		return 1;
	if(mf >= nf)
		return apple(mf, nf - 1) + apple(mf - nf, nf);
	if(mf < nf)
		return apple(mf, nf - 1);
}

int main()
{
	int m, n, i, j, num;
	cin >> j;
	for(i = 1; i <= j; i++)
	{
		cin >> m >> n;
		num = apple(m, n);
		cout << num << endl;
	}
	
	
	return 0;
}
int main()
{
        char s[110],s1[110];
        int l,i;
memset(s,0,sizeof(s));
memset(s1,0,sizeof(s1));
        gets(s);
        l=strlen(s);
        for(i=0;i<l-1;i++)
        {
                s1[i]=s[i]+s[i+1];
        }
        s1[l-1]=s[0]+s[l-1];
        printf("%s\n",s1);
}
//********************************************************
//*  ???:4.cpp                                        *
//*  ??????    1200012948                          *
//*  ????: 2012 12 04                                *
//*  ????:???????                             *
//********************************************************
int main()
{
	char s[110], s1[110];
	char *p = NULL, *p1 = NULL;
	cin.getline(s,110);
	for (p = s; *p != '\0'; p++);  //???????
	p--;
	p1 = p - s + s1 + 1;
	*p1 = '\0';
	p1--;
	*p1 = *p + *s;      //??????????
	for (p--; p >= s; p--)
	{
		p1--;
		*p1 = *p + *(p + 1);
	}
	for (p1 = s1; *p1 != '\0'; p1++)  //??s1
	{
		cout << *p1;
	}
	cout << endl;
	return 0;
}
void main()
{
	char *s1,*s2;
	int i,len;
	s1=(char*)malloc(100*sizeof(char));
	s2=(char*)malloc(100*sizeof(char));
	gets(s1);
	len=strlen(s1);
	for(i=0;i<len-1;i++)
		*(s2+i)=*(s1+i)+*(s1+i+1);
		*(s2+len-1)=*(s1)+*(s1+len-1);
		for(i=0;i<len;i++)
			printf("%c",*(s2+i));
}
int main()
{
	char a[101];
	int i,l;
	for(i=1;i<=100;i++)
	{
		scanf("%c",&a[i]);
		if(a[i]=='\n')
			break;
	}
	l=i-1;
	for(i=1;i<=l-1;i++)
		printf("%c",a[i]+a[i+1]);
	printf("%c",a[l]+a[1]);
	return 0;
}
char a[200];
char b[200];
void main()
{
     gets(a);
     char *p =a;
     char *q =b;
     scanf("%s",&a);

     int n=strlen(a);
     b[n]='\0';
    
     for(p=a;p<a+n-1;p++)
     {
                       *q=*p+*(p+1);
                       q++;
     }
     *q= *a+ *p;
     printf("%s",b);
     
}
int main ()
{
	int i,c;
	char a[103],b[103];
	gets(a);
	for (i=0;i<103;i++)
	{
		if (a[i+1]=='\0')
		{
			c=i;
			break;
		}
		b[i]=a[i]+a[i+1];
	}
	b[c]=a[c]+a[0];
	for(i=0;i<103;i++)
	{
		if (i==c+1)
		{
			printf("\n");
			break;
		}
		else
			printf ("%c",b[i]);
	}
	return 0;
}
void main()
{
	int i;
	char s[105],c[105];
	gets(s);
	for(i=0;s[i+1]!='\0';i++)
	{
		c[i]=s[i]+s[i+1];
	}
	c[i]=s[i]+s[0];
	c[i+1]='\0';
	puts(c);
}