semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int f(int m,int n)
{
    if((n==1)||(m==0))return 1;
    if(n>m)
    return f(m,m);
    if(n<=m)
    return f(m,n-1)+f(m-n,n);
}
int main()
{
    int t;
    scanf("%d",&t);
    while(t>0)
    {
    int m,n;
    scanf("%d%d",&m,&n);
    printf("%d\n",f(m,n));
    t--;
    }
}
int f(int m,int n)
{
	if(n<=0)
	return 0;
	if(n==1)
	return 1;
	if(m<n)
	return f(m,n-1);
	return f(m,n-1)+f(m-n,n); 
	
}
int main()
{
	int m[20],n[20],t,i,k[20];
	scanf("%d",&t);
	for(i=0;i<t;i++)
	{
		scanf("%d%d",&m[i],&n[i]);
		k[i]=f(m[i],n[i]);
	}
	for(i=0;i<t;i++)
	printf("%d\n",k[i]);
	return 0;
}
main()
{
    int N,e;
    scanf("%d",&N);
    for(e=0;e<N;e++)
    {
        int m,n;
        scanf("%d%d",&m,&n);
        int i,j,k,t;
        int f[100][100]={0};
        for(i=1;i<=n;i++)
        {
            for(j=0;j<=m;j++)
            {
                if(i==1||j==0||j==1)
                {    
                    f[i][j]=1;
                }
                else
                {
                    if(j>=i)
                    f[i][j]=f[i][j-i]+f[i-1][j];
                    else
                    f[i][j]=f[i-1][j];
                }
            }
        }
        printf("%d\n",f[n][m]);
    }
    }
int f(int n,int a)
	{
		int j,r;
		if(n==0)
		{
			return 1;
		}
		else if(a==1)
		{
			return 1;
		}
		if(n<a)
		{
			return f(n,n);
		}
		else
		{
			return (f(n,a-1)+f(n-a,a));
		}
	}
	int main()
	{
		int M,N,m,i,a,b,c;
		scanf("%d",&m);
		for(i=0;i<m;i++)
		{
			scanf("%d%d",&M,&N);
			b=f(M,N);
			printf("%d\n",b);
		}
		return 0;
	}
int main()
{
	int t,M,N,i,m,n;
	int a[30][30];
	scanf("%d",&t);
	for(i=1;i<=t;i++)
	{
		memset(a,0,sizeof(int));
		scanf("%d %d",&M,&N);
		for(m=0;m<=M;m++)
		{
			for(n=1;n<=N;n++)
			{
				if(m==0||m==1||n==1)
					a[m][n]=1;
				else
					if(m>=n)
						a[m][n]=a[m-n][n]+a[m][n-1];
					else
						a[m][n]=a[m][n-1];
			}
		}
		printf("%d\n",a[M][N]);
	}
	return 0;
}
int function(int m,int n,int min)
{
	if(n==1)return 1;
	int a=0;
	for(int i=min;i<=m/n;i++)                    //bug :??min
		a+=function(m-i,n-1,i);
	return a;
}

int main()
{
	int t,m,n;
	cin>>t;
	for(int w=0;w<t;w++)
	{
		cin>>m>>n;
		cout<<function(m,n,0)<<endl;
	}
	return 0;
}
int f(int m,int n)
{
	int k=0;
	if(m<0)k=0;
	else if(m==0)k=1;
	else if(n==1)
		k=1;
	else k=f(m,n-1)+f(m-n,n);
	return(k);
}
int main()
{
	int i,t,n,m,k;
	int f(int m,int n);
	scanf("%d",&t);
	if(t>=0&&t<=20)
	{
		for(i=1;i<=t;i++)
		{
			scanf("%d%d",&m,&n);
			k=f(m,n);
			printf("%d\n",k);
		}
	}
	return 0;
}
int main()
{
	int f(int x,int y);
	int t, m[25]={0}, n[25]={0}, 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]));
	return 0;
}
int f(int x,int y)
{
	if(y==1) return(1);
	else
	{
		int empty,full;
	    if(x<y) full=0;
	    if(x==y) full=1;
	    if(x>y) full=f(x-y,y);
	    empty=f(x,y-1);
	    return(empty+full);
	}
}
/**
* @file 1000010424_7.cpp
* @author ???
* @date 2010?12?1
* @description
* ??????: ?????    
*/



int NumOfChoices(int, int, int);							//??m?????n????????????

int main()
{
	int cases, apples, plates;

	cin >> cases;

	for(; cases >= 1; cases--)
	{
		cin >> apples >> plates;							//?????????????

		cout << NumOfChoices(apples, plates, 0) << endl;	//??????
	}

	return 0;
}

int NumOfChoices(int m, int n, int min)
{
	int apples;												//??????????
	int sum = 0;											//???????


	if(m == 0)
		return 0;											//??????????0???????m??0???????????????????

	if(n == 1)												//????????????
	{
		if(m >= min)
			return 1;										//???????????
		else
			return 0;
	}

	for(apples = min; apples <= m; apples++)				//???????????????????
		sum += NumOfChoices(m - apples, n - 1, apples);

	return sum;
}
//****************************************
//*?????                    **
//*??? 1100012927              **
//*2011.11.21                     **
//****************************************
int f(int, int);
int g(int, int);
int sum2 = 0;
int main()
{   
    int t, M, N, i, sum;
    cin >> t;
    for (i = 0; i < t; i++)
    {
        sum = 0;
        cin >> M >> N;
        sum += f(M, N);
        cout << sum<<endl;
    }
    
    return 0;
}

int f(int M, int N)
{
    if (M < 0)
        return 0;
    else if (M == 1 || N == 1 || M == 0)
        return 1;
    else 
        return (f(M, N - 1) + f(M - N, N));
}
int cal(int m,int n)
{

	if(n<=0)
	return(0);
	else if(m<0)
	return(0);
	else if(m==0)
	return(1);

	else 
	return((cal(m,n-1)+cal(m-n,n)));
}
int main()
{
	int t,m,n;
	scanf("%d",&t);
	while(t--)
	{
		scanf("%d%d",&m,&n);
		printf("%d\n",cal(m,n));
	}
	
}
main()
{
	int sum(int x,int y);
	int i,t,m[21],n[21],c[21];
	scanf("%d",&t);
	for(i=1;i<=t;i++)
	{
		scanf("%d%d",&m[i],&n[i]);
	}
	for(i=1;i<=t;i++)
	{
		c[i]=sum(m[i],n[i]);
	}
	for(i=1;i<=t;i++)
	{
		printf("%d\n",c[i]);
	}
}
int sum(int x,int y)
{
	int z;
	if(y==1)z=1;
	else {
		if(x<0)
	{
		z=0;
	}
	else
	{
		z=sum(x,y-1)+sum(x-y,y);
	}}
	return(z);
}
int put(int apple,int plate,int min)
{
	int count=0;
	if(plate==1)
	{
		if(apple>=min) return 1;
		else return 0;
	}
	for(int i=min;i<=apple;i++)
	{
		count+=put(apple-i,plate-1,i);
	}
	return count;
}
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		int m,n;
		cin>>m>>n;
		cout<<put(m,n,0)<<endl;
	}
	return 0;
}
int apple(int a,int b)//a??b??//
{
	int z;
	if(b==1||a==0) z=1;
	else if(b>a) z=apple(a,a);
	else z=apple(a,b-1)+apple(a-b,b);
	return z;
}
void main()
{
	int m[20],n[20],s,i;
	scanf("%d",&s);
	for(i=0;i<s;i++)
		scanf("%d%d",&m[i],&n[i]);
	for(i=0;i<s;i++)
		printf("%d\n",apple(m[i],n[i]));
}
int f(int m,int n)
{
	int a;
	if(m==0||n==1)
		return(1);
	else
	{
        if(m<n)
		{a=f(m,m);}
		else
		{a=f(m-n,n)+f(m,n-1);}
		return(a);
	}
}
void main()
{
	int t,m,n,y,i,j;
	scanf("%d",&t);
	for (i=1;i<=t;i++)
    {
		scanf("%d%d",&m,&n);
		printf("%d\n",f(m,n));
	}
}
int F(int m,int n)
{
	if(m==0 || m==1 || n==1)
		return 1;
	if(m>=n)
		return F(m,n-1)+F(m-n,n);
	return F(m,n-1);
}

int main()
{
	int t,m,n;
	cin>>t;
	while(t--)
	{
		cin>>m>>n;
		cout<<F(m,n)<<endl;
	}
	return 0;
}
int apple(int m,int n)
{
    if (n==1) return 1;
    if (m==0) return 1;
    if (m<n) return apple(m,m);
    if (m>=n) return (apple(m,n-1)+apple(m-n,n));
}

int main ()
{
    int m,n,t,i;
    cin>>t;
    for (i=0;i<t;i++)
    {
    cin>>m>>n;
    cout<<apple(m,n)<<endl;
    }
    return 0;
}
int dfs(int m, int n) {
	if (n == 1) return 1;
	int res = dfs(m, n-1);
	if (m >= n) res += dfs(m-n, n);
	return res;
}
int main() {
	int t, m, n;
	cin >> t;
	while (t--) {
		cin >> m >> n;
		cout << dfs(m,n) << endl;	
	}
}
int put(int m,int n)
{
	if(m==1||n==1||m==0)
		return 1;
	if(m<0||n==0)
		return 0;
		return 	put(m,n-1)+put(m-n,n);
	
}
int main()
{
	int t,M,N,i,sum;
	cin>>t;
	for(i=1;i<=t;i++)
		{
cin>>M>>N;
	    	cout<<put(M,N);
cout<<endl;
}
	return 0;
}
int f(int m,int n,int j)
{ 
	int i,s=0;
	if(n==1)
		return m>=j;
	for(i=j;i<m;i++)
		s+=f(m-i,n-1,i);
	return s;
}	
void main() 
{ 
	int n,m,s,i,t;
	scanf("%d",&t);
	for(i=0;i<t;i++)
	{
		scanf("%d%d",&m,&n);
		if(n>m)
			n=m;
		s=f(m,n,0); 
		printf("%d\n",s);
}
}
int kong(int m,int n);
	int bukong(int m,int n);
int main()
{
	int i,t;
	scanf("%d",&t);
	for(i=0;i<t;i++)
	{
		int m,n,s;
		scanf("%d%d",&m,&n);
		s=kong(m,n)+bukong(m,n);
		printf("%d\n",s);
	}
	return 0;
}

int kong(int m,int n)
{
	if(n==1&&m>0)
		return 0;
	else
	return kong(m,n-1)+bukong(m,n-1);
}

int bukong(int m,int n)
{
	if(m==n)return 1;
	if(m>n)
	return kong(m-n,n)+bukong(m-n,n);
	if(m<n)
	return 0;
}
int f(int n,int m)
{
	int i,k=0;
	if (n==1||m==1||n==0) return 1;
	if (n>=m)
	{
		for (i=1;i<=m;i++) k+=f(n-i,i);
		return k;
	}
	if (n<m)
	{
		return f(n,n);
	}
}

int main()
{
	int k,n,i,m;
	cin>>k;
	for (i=1;i<=k;i++)
	{
		cin>>n>>m;
	cout<<f(n,m)<<endl;
	}
	return 0;
}
int fpg(int M,int N)
{
	int i,K=1;
	if(N==1)
	{
		return K=1;
	}
    if(M<N)
	{
		K=fpg(M,N-1);
	}
	else
	{
	    K=fpg(M,N-1)+fpg(M-N,N);
	}
	return K;
}
int main()
{
	int i,n,a[100],b[100],c[100];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d %d",&a[i],&b[i]);
		c[i]=fpg(a[i],b[i]);
		printf("%d\n",c[i]);
	}
	return 0;
}
int main()
{
 int M[10],N[10],K[10];
 int t,i,j;
 int noblank(int M,int N);
 int MTOblank(int M,int N);
 scanf("%d\n",&t);
 for(i=0;i<t;i++)
 {scanf("%d %d\n",&M[i],&N[i]);
  K[i]=noblank(M[i],N[i])+MTOblank(M[i],N[i]);
  }
 for(j=0;j<t;j++)
 printf("%d\n",K[j]); 
}

int noblank(int M,int N)
{
    int K;
    int MTOblank(int M,int N);
    if(M>N) K=noblank(M-N,N)+MTOblank(M-N,N);
    if(M==N) K=1;
    if(M<N) K=0;
    
    return K;
} 

int MTOblank(int M,int N)
{
    int K;
    int noblank(int M,int N);
    if (N==2) K=1;
    else   {if (N==1) K=0;
             else {if (M<N-1) K=MTOblank(M,N-1);
                   else K=MTOblank(M,N-1)+noblank(M,N-1);
                  }
           }
    return K;
    
}
int f(int m,int n,int j)
{
    int i,s=0;
    if(n==1)
    {
        return m>=j;
    }
    for(i=j;i<m;i++)
    {
        s+=f(m-i,n-1,i);
    }
    return s;
}

int main()
{
    int m,n,l;
    scanf("%d\n",&l);
    while(l--)
    {
        scanf("%d %d",&m,&n);
        printf("%d\n",f(m,n,0));
    }
    return 0;
}
int main()
{   int count(int m,int n);
	int t,m,n,z;
	scanf("%d",&t);
	while(t>0)
	{
	scanf("%d%d",&m,&n);
    z=count(m,n);
	printf("%d\n",z);
	t--;}
    return 0;
}
int count(int m,int n)
{   
	if((n==1)||(m==1)) return(1);
	else if(n>m) return(count(m,n-1));
	else if(n==m) return(1+count(m,n-1));
	else return(count(m,n-1)+count(m-n,n));
}
int ans(int x, int y)
{
	if (y == 1)return 1;
	if (x == y)return (ans(x, y - 1) + 1);
	if (x < y)return ans(x, x);
	if (x > y)return ans(x, y - 1) + ans(x - y, y);
}
int main()
{
	int t, m[100], n[100];
	cin >> t;
	for (int i = 0; i < t; i++)
	{
		cin >> m[i] >> n[i];
		cout << ans(m[i], n[i]) << endl;
	}
	return 0;
}
int f(int m,int n)
{
	int c;
	if(m>=n)
	{
		if(n==1||m==1)
		c = 1;
		else if(m==2&&n!=1)
		{
			c = 2;
		}
		else if(m==0)
		c = 1;
		else
		c = f(m-n,n)+f(m,n-1);
		return c;
	}
	else
	{
		c = f(m,m);
		return c;
	}
} 
int main()
{
	int f(int,int);
	int x,y,t,i;
	scanf("%d",&t);
	for(i=0;i<t;i++)
	{
		scanf("%d %d",&x,&y);
		printf("%d\n",f(x,y));
	}
	return 0;
}
f(int a,int b)
{
	int s=0,x,y;
	if(a==0||a==1||b==1)
	{
		s=1;
	}

	else
	{
		if(a>=b)
		{
	 	   x=f(a-b,b);
	       y=f(a,b-1);
		}
		else
		{
			x=0;
			y=f(a,a);
		}
		s=x+y;
	}
	return s;	
}



int main()
{
	int m,n,k,i;
	scanf("%d",&k);
	for(i=0;i<k;i++)
	{
		scanf("%d%d",&m, &n);
		printf("%d\n",f(m,n));
	}
	return 0;
}
int main()
{
	int f(int M,int N);
	int t,i;
	scanf("%d",&t);
	int a[20][2];
	for(i=0;i<t;i++)
		scanf("%d %d",&a[i][0],&a[i][1]);
	
	for(i=0;i<t;i++)
		printf("%d\n",f(a[i][0],a[i][1]));
	return 0;
}

int f(int M,int N)
{
	int w;                       
	if(M<=1||N<=1)               
		w=1;
	else if(M<N)                 
		w=f(M,M);
	    //w=f(M,M-1)+f(M,M-2);
	else
		w=f(M-N,N)+f(M,N-1);
	return w; 
}
int num=0;//????????
int p=0;//?????????????
int main()
{
	void putApple(int M,int N);//????
	int t;
	cin>>t;
	for(int i=0;i<t;i++)
	{
		num=0;
		p=0;
		int M,N;
		cin>>M>>N;
		putApple(M,N);
		cout<<num<<endl;
	}
	return 0;
}

void putApple(int M,int N)
{
	if(N==1||M==0)
		num++;
	else
	{
		if(M>=N)
		{
			putApple(M-N,N);
			putApple(M,N-1);
		}
		else
			putApple(M,M);
	}
}
int fang(int m,int n)
{
	int c;
	if(n==1)
		c=1;
	else if(m==1)
		c=1;
	else if(m==0)
		c=1;

	else if(m>=n)
	{
		c=fang(m,n-1)+fang(m-n,n);
	}
	else if(m<n)
	{
		c=fang(m,m);
	}
	return(c);
}
int main()
{
	int t,m,n,i,c;
	scanf("%d",&t);
	for(i=0;i<t;i++)
	{
		scanf("%d%d",&m,&n);
		c=fang(m,n);
		printf("%d\n",c);
	}
}
void main()
{
	int a[100][100];
    int M,N;
    int t,i,j,k;
    scanf("%d",&t);
    for (i=0;i<t;i++)
    {
        scanf("%d %d",&M,&N);
        for(j=1;j<=N;j++)
            a[1][j]=1;
        for(j=1;j<=M;j++)
            a[j][1]=1;
        for (j=2;j<=M;j++)
        {
            for(k=2;k<=N;k++)
            {
                if(j<k) a[j][k]=a[j][j];
                if(j==k) a[j][k]=a[j][j-1]+1;
                if (j>k) a[j][k]=a[j-k][k]+a[j][k-1];
            }
        }
        printf("%d\n",a[M][N]);    
    }
}
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 t=0;
    int m,n;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d %d",&m,&n);
        printf("%d\n",f(m,n));        
    } 

    return 0;
}
void main() 
{ 
    int t,M[20],N[20],i,K; 
    int Apples_Set(int a,int b); 
    scanf("%d",&t); 
    
 
    for(i=1;i<=t;i++)
	{ 
        scanf("%d %d",&M[i],&N[i]);
           
    } 
 
    for(i=1;i<=t;i++){ 
        K=Apples_Set(M[i],N[i]); 
        printf("%d\n",K); 
    } 
  
} 
 
int Apples_Set(int a, int b){ 
    if((a<1)||(b<1)) 
        return 0; 
    if((a==1)||(b==1)) 
        return 1; 
    if(a<b) 
        return Apples_Set(a,a); 
    if(a==b) 
        return Apples_Set(a,b-1)+1; 
    return Apples_Set(a,b-1)+Apples_Set(a-b,b); 
}
//************************************
//*  ?????                      *
//*  ??????                    *
//*  ?????2011?11?24?        *
//************************************


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

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

int main()
{
	int n;
	cin >> n;

	while(n--)
	{
		int m, n;
		cin >> m >> n;

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

	return 0;
}

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

	if (m < 0) return 0;

	return f(m - n, n) + f(m, n - 1);
}
int func(int M,int N)
{
	int ans;
	if(N==1)
        ans=1;
	else if(M>N) 
	    ans=func(M,N-1)+func(M-N,N);
	else if(M==N)
	    ans=func(M,N-1)+1;
	else
		ans=func(M,N-1);
	return ans;
}
int main()
{
	int m,n,t,i,k[20];
	
	scanf("%d",&t);
	for(i=0;i<t;i++)
	{
		scanf("%d %d",&m,&n);
		k[i]=func(m,n);
	}
	
	for(i=0;i<t;i++)
		printf("%d\n",k[i]);
	return 0;
}
/*
 * ???????.cpp
 * ????M????????N????????????????????????????????K????
 *      ???5?1?1?1?5?1???????
 * ????: 2010-11-28
 * ??: ??
 */



int Arrange_Apple(int p, int dish, int apple) {
	int sum = 0;
	if (apple < p)
		return 0;
	if (dish == 1 && apple >= p)
		return 1;
	for (int i = p; i <= apple / dish; i++)
		sum += Arrange_Apple(i, dish - 1, apple - i);
	return sum;
}

int main() {
	int dish = 0, apple = 0, t, i;
	cin >> t;
	for (i = 0; i < t; i++) {
		cin >> apple >> dish;
		cout << Arrange_Apple(0, dish, apple) << endl;
	}
	return 0;
}
int an(int m,int n)
{
	int c;
	if(n==1||m==0||m==1)
		c=1;
	else 
	{	if(m<0)
			c=0;
		else
			c=an(m,n-1)+an(m-n,n);	
	}
	return (c);
}

int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		int m,n,x;
		cin>>m>>n;
		x=an(m,n);
		cout<<x<<endl;

	}
	return 0;
}
int f(int m,int n)
{   
	int a;
	if(n==1) a=1;
	else if(m<n) a=f(m,n-1);
	    else if(m>n) a=f(m,n-1)+f(m-n,n);
	         else a=1+f(m,n-1);
	return(a);
}

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

//???1000010586_???

//????????

int num;
int make( int M , int N );                   //????make????????????
int work( int M , int j );                   //????work???????????
int main()
{
	int M , N , t , k , i;                             //????
	cin >> t;                                          //?????? 
	for ( i = 1 ; i <= t ; i++ )
	{
		k = 0;                                         //????
		num = 0;                                       //??????
		cin >> M >> N;                                 //??  
		k = make( M , N );                             //??????
		cout << k << endl;                             //??
	}
	return 0;
}
int make( int M , int N )
{
	int j , k;
	if ( M < N )                                       //?M<N? ?????M?????   
	{
	   num = num + 1;                                  //???????? ??????
	   return make( M , M - 1 );                  //???????????
	}
	else
	{
        for ( j = N ; j >= 1 ; j-- )                    //???1?  ?????????N????? 
		{
		    num = work( M , j );
		}
		return num;
	}
}
int work( int M , int j )
{
	if ( j == 1 )                                       //???????  ??1???
	{
		num = num + 1;                                  //???1  ??
		return num;
	}
	else
		return make ( M - j , j );                //??????1  ???M-N????j????????????
}
int fang(int m1,int n1)
{
    if(n1==1)return(1);
    if(m1>n1)
    return(fang(m1,n1-1)+fang(m1-n1,n1));
    if(m1==n1)
    return(fang(m1,n1-1)+1);
    if(m1<n1)
    return(fang(m1,m1));
}
int main()
{
    int t,m[21],n[21],i,s[21];
    scanf("%d",&t);
    for(i=0;i<t;i++)
    {
        scanf("%d %d",&m[i],&n[i]);
        s[i]=fang(m[i],n[i]);
    }
    for(i=0;i<t;i++)
    printf("%d\n",s[i]);

}
int f(int, int);
 
int main()
{
    int t, m, n, sum;
    scanf("%d", &t);
    while (t--)
    {
        scanf("%d%d", &m, &n);
        sum = f(m, n);
        printf("%d\n", sum);
    }
    return 0;
}
int f(int m, int n)
{
    if (m < 0) return 0;
    if (m == 0) return 1;
    if (n == 1) return 1;
    return f(m - n, n) + f(m, n - 1);   
}
int fun(int m,int n,int j); 
int main(void) 
{ int a,n,m;
int s[20];
scanf("%d",&a);
for(int i=0;i<a;i++)
{
scanf("%d%d",&m,&n); 
if(n>m) n=m;
s[i]=fun(m,n,0);
}
for(int i=0;i<a;i++)
printf("%d\n",s[i]); 
} 
int fun(int m,int n,int j) 
{ int i,s=0; 
if(n==1) return m>=j; 
for(i=j;i<m;i++) s+=fun(m-i,n-1,i); 
return s; 
}
int main()
{
    int way(int x,int y);
    int t,i,m[100],n[100],p[100];
    scanf("%d", &t);
    for(i=1;i<=t;i++){scanf("%d%d", &m[i],&n[i]);
                      p[i]=way(m[i],n[i]);
                      printf("%d\n", p[i]);}
    return 0;
    }
    
int way(int x,int y)
{
    int s[100][100],j,k,w=0;
    for(j=0;j<=50;j++){s[0][j]=1;s[j][1]=1;s[1][j+1]=1;}
    for(j=2;j<=50;j++){
                        for(k=2;k<=50;k++){
                                           if(k>j){s[j][k]=s[j][k-1];}
                                           else{s[j][k]=s[j][k-1]+s[j-k][k];}
                                           }
                        }    
    return(s[x][y]);
    }
void main()
{   
	int put(int,int);
	int n,m,t;
	int way;
	int i;
	scanf("%d",&t);
	for(i=0;i<t;i++)
	{
	   scanf("%d %d",&m,&n);
       way=put(m,n);
	   printf("%d\n",way);
	}
}
int put(int m,int n)
{
	int way;
	if(m==1||n==1||m==0||n==0)
		way=1;
	else if(m<n)
		way=put(m,n-1);
	else if(m>=n)
		way=put(m,n-1)+put(m-n,n);
	return(way);
}
int f(int m,int n,int *k)
{   if(m==0){*k=*k+1;return;}
    if(n==1){*k=*k+1;return;}
    if(m-n>=0){f(m-n,n,k);}
    f(m,n-1,k);
}
main()
{ int g,i,j,*m,*n,*k;
  scanf("%d",&g);
  m=(int*)calloc(g,sizeof(int));
  n=(int*)calloc(g,sizeof(int));
  k=(int*)calloc(g,sizeof(int));
  for(i=0;i<g;i++)
   scanf("%d%d",m+i,n+i);
  for(i=0;i<g;i++)
  { *(k+i)=0;
    f(m[i],n[i],k+i);
    printf("%d",k[i]);
    if(i!=g-1)printf("\n");
  }
}
int f(int a,int b)
{ 
	if(a==0||b==1)  
		return 1; 
	if(a<0) 
		return 0;
	return f(a-b,b)+f(a,b-1); 
}
int main ()
{
	int t,a,b,i;
scanf("%d",&t);

for(i=0;i<t;i++)
{
	scanf("%d",&a);
	scanf("%d",&b);
	printf("%d\n",f(a,b)); 
}
return 0;
}
int sort(int m,int n)
{
    int sum;
    if(n==1&&m>0){
             return sum=1;
             }
    else if(n>1&&m==n){
         return sum=1+sort(n,n-1);
                       }
     else if (m<=0){
          return sum=0;
          }
     else {     return sum=sort(m,n-1)+sort(m-n,n);
          }
    
    
    }
    
    
    main()
    {int N,m,n;
    scanf("%d",&N);
    for(int i=0;i<N;i++){
            scanf("%d",&m);
            scanf("%d",&n);
            printf("%d\n",sort(m,n));
            }
            
          }
/*
 * ??????????
 * ??          ???
 * ????: 2011-11-28
 * ??????M????????N?????????????????????????????????
 *
 */



int Calc(int M,int N)
{
int sum=0;

if(M==0)
	{
	sum=1;
	return sum;
	}
if(N==1)
	{
	sum=1;
	return sum;
	}
if(M<N) sum=Calc(M,N-1);
else sum=Calc(M-N,N)+Calc(M,N-1);
return sum;
}

int main ()
{
	int t,i,M,N;

	cin>>t;
	for(i=1;i<=t;i++)
	{
		cin>>M>>N;
		cout<<Calc( M, N)<<endl;
	}
	return 0;
}
int number(int,int);
int main()
{
	 int n, apple, plate;
	 cin >> n;
	 for(int i = 1; i<= n; i++)
	 {
		 cin >> apple >> plate;
		 cout << number(apple, plate) << endl;
	 }
	 return 0;
}
int number(int apple, int plate)
{
	if(apple < 0)
		return 0;
	if(apple == 0)
		return 1;
	if(apple > 0 && plate == 1 || apple == 1 && plate > 1)
		return 1;
	else return number(apple, plate - 1) + number(apple - plate, plate);
}
/**
* @file 1000012907_1.cpp
* @author ???
* @date 2010?12?1
* @description
* ??????: ????? 
*/
int K(int a, int b);						// ??????
int main() 
{
	int t, i, M, N;
	cin >> t;								// t????????
	for (i = 0; i < t; i++)					// i?0???t-1??????????
	{
		cin >> M >> N;						// M??????N?????
		cout << K(M, N) << endl;			// ?????????
	}
	return 0;
}
int K(int a, int b)
{
	if (b == 1 || a == 1 || a == 0)			// ??????
	{
		return 1;
	}										// ??????
	if (a < 0)
	{
		return 0;
	}
	else
	{
		// ???????????????????????????????????????
		// ??????????????????????????????????N????
		// ?M???????????N-1?????M????????????????????
		// ???????N?????M????????????N?????M-N??????????
		return (K(a, b - 1) + K(a - b, b));
	}
}
int count(int x, int y)
{
	if(x==0||y==1)
		return (1);
	else if(x<y)
		return (count(x,x));
	else 
		return (count((x-y),y)+count(x,y-1));
}



void main()
{
	int m[30],n[30];
	int i,k;
	scanf("%d",&k);
	for(i=0;i<k;i++)
	{
		scanf("%d%d",&m[i],&n[i]);
		printf("%d\n",count(m[i],n[i]));
	}
}
int main()
{
    int t,*m,*n,zhonglei(int x,int y),i;
    scanf("%d",&t);
    m=(int*)malloc(t*sizeof(int));
    n=(int*)malloc(t*sizeof(int));
    for(i=0;i<t;i++)
    {
                    scanf("%d%d",&m[i],&n[i]);
    }
    for(i=0;i<t;i++)
    {
                    printf("%d\n",zhonglei(m[i],n[i]));
    }
    return 0;
}

zhonglei(int x,int y)
{
             if(x==1) return(1);
             else if(y==1) return(1);
             else
             {
                 if(x<y) return(zhonglei(x,y-1));
                 else
                 {
                     return(zhonglei(x-y,y)+zhonglei(x,y-1));
                 }
             }
}
int num(int m,int n);
int num1(int m,int n); 
int num2(int m,int n);
int num(int m,int n)
{
	//printf("num(%d,%d)\n",m,n);
	return num1(m,n)+num2(m,n);
}
int num1(int m,int n)
{	
	//printf("num1(%d,%d)\n",m,n);
	if(m==1||m==0||m<n)/*{printf("jump\n");*/return 0;
	else
	if(n==1)/*{printf("  +1\n");*/return 1;
	else
	return num(m,n-1);
}
int num2(int m,int n)
{
	//printf("num2(%d,%d)\n",m,n);
	if(n==1){/*printf("jump\n");*/return 0;}
	else
	if(m==0||m==1)
	{/*printf("  +1\n");*/return 1;}
	else
	if(m>=n)
		return num(m-n,n);
	else
		return num(m,m);
}
void main()
{
	int t,n,m,i;
	scanf("%d",&t);
	for(i=0;i<t;i++)
	{
		scanf("%d %d",&m,&n);
		int j=num(m,n);
		printf("%d\n",j);
	}
}
int f(int m,int n);
int main()
{
	int M[40],N[40],k,i,z[40];
	scanf("%d",&k);
	for (i=1;i<=k;i++)
	{
		scanf("%d%d",&M[i],&N[i]);
        z[i]=f(M[i],N[i]);
	    printf("%d\n",z[i]);
	}
	return 0;
}
int f(int m, int n)
{
    if (m < 0) return 0;
    if (m == 0) return 1;
    if (n == 1) return 1;
    return f(m - n, n) + f(m, n - 1);   
}
int count(int m, int n);
int main(){
	int result, i, t, m, n, stop;
	scanf ( "%d", &t );
	if(t==0){
		printf("0");
	}
	for ( i = 0; i < t; i++){
		scanf("%d %d",&m,&n);
		result=count(m,n);
		printf("%d\n",result);
	}
	if(m==7){
		printf("\n");
	}
	scanf("%d",&stop);
	return 0;
}
int count(int m,int n){
	int m1,n1,m2,n2,t1,t2,result;
	t1=0;
	t2=0;
	m1=m;
	n1=n-1;
	m2=m-n;
	n2=n;
	if(m==1||n==1){
		return 1;
	}
	if(m==0){
		return 1;
	}
	if(m<0||n<0){
		return 0;
	}
	t1+=count(m1,n1);
	t2+=count(m2,n2);
	result=t1+t2;
	return result;
}
int Dgetnum(int m,int n,int min)
  {
    int i;
 int k;
 if(m==0)
  return 1;
 if(n==1)
  return 1;
 k=0;
 for(i=min;i<=m;i++)
 {
  if((m-i)>=i||(m-i)==0)
    k=k+Dgetnum(m-i,n-1,i);
 }
 
 return k;
  }

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