semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int fun(int m,int n,int j); 
void main() 
{ 
   int n,m,s,i;
   scanf("%d",&i);
   while(i--)
  {
     scanf("%d %d",&m,&n); 
     if(n>m) n=m; 
     s=fun(m,n,0); 
     printf("%d\n",s); 
  } 
}
int fun(int m,int n,int j) 
{ 
    int i,s=0; 
    if(m<j) 
       return 0;
    if(n==1) 
        return 1;
    for(i=j;i<m;i++) 
        s+=fun(m-i,n-1,i); 
    return s; 
}
int i,j,k,t,a[101][11],b[101][11],m[20],n[20],z[101][11];

void main()
{
	scanf("%d",&t);

	for (i=0;i<t;i++)
	{
		scanf("%d %d",&m[i],&n[i]);
	}

	 for (i=1;i<=100;i++)
	 {
		 b[i][i]=1;
		 z[i][1]=1;
		 z[i][2]=i/2+1;
		 for (j=1;j<=10;j++)
		 {
			 if (i<j) z[i][j]=0;
		 }
	 }

	 for (i=1;i<=10;i++)
	 {
		 z[1][i]=1;
	 }
	 for (i=2;i<=10;i++)
	 {
		 z[2][i]=2;
	 }

	 for (i=3;i<=100;i++)
	 {
		 for (j=3;j<=10;j++)
		 {
			 if (i<j) z[i][j]=z[i][i];
			 else
			 {
				a[i][j]=z[i][j-1];
				if (i!=j) b[i][j]=z[i-j][j];
				z[i][j]=a[i][j]+b[i][j];
			 }
		 }
	 }

	 for (i=0;i<t;i++)
	 {
		 j=m[i];
		 k=n[i];
		 printf("%d\n",z[j][k]);
	 }

}
/*
 *??? 
 *2010 - 12 - 7 
 *?????4 - ????? 
 */
int flag = 0;//??????????? 
int main()
{
    void fun ( int, int, int );//???? 
    int i, t, m, n;
    cin >> t;
    for ( i = 1; i <= t; i++ )//????? 
    {
        flag = 0;//????????? 
         cin >> m >> n;
         fun ( m, n, 0 );
         cout << flag << endl;
    }
    return 0;
}
void fun ( int m, int n, int before )//m??????????n????????before??????????? 
{
    int i;
    if ( n == 1 && m >= before )//???????????????????????? 
    {
         flag++;//???? 
         return;//????? 
    }
    for ( i = before; i <= m - n + 1; i++ )//????????????????????? 
    {
        fun ( m - i, n - 1, i );//?????? 
    }
}
int yk(int a,int b);
int qm(int a,int b);
int main()
{
	int t;
	scanf("%d",&t);
	int m[100],n[100];
	int i;
	int result[100];
	for(i=0;i<t;i++)
	{
		scanf("%d%d",&m[i],&n[i]);
		result[i]=yk(m[i],n[i]-1)+qm(m[i]-n[i],n[i]);
	}
	for(i=0;i<t;i++)
		printf("%d\n",result[i]);
	return 0;
}
int yk(int a,int b)
{
	int result1;
	if(b>1)
	{
		result1=yk(a,b-1)+qm(a-b,b);
		return result1;
	}

	if(b==1)
		return 1;
	if(b<=0)
	return 0;
}
int qm(int a,int b)
{
	int result2;
	if(a>1)
	{
		result2=qm(a-b,b)+yk(a,b-1);
		return result2;
	}
	if(a==1||a==0)
		return 1;
	if(a<0)
		return 0;

}
int f(int M,int N)
{
    int t;
    if(M>N)
    {
        if((N!=1)&&((M-N)!=1))
          t=f(M,N-1)+f(M-N,N);
        if((N!=1)&&((M-N)==1))
        t=1+f(M,N-1);
        if(N==1)
        t=1;
    }
    if((M==N)&&(M!=1))
    t=1+f(M,N-1);
    if((M==N)&&(M==1))
    t=1;
    if(M<N)
    t=f(M,N-1);
    return(t);
}
main()
{
    int n,i;
    scanf("%d",&n);
    int f(int M,int N);
    for(i=0;i<n;i++)
    {
        int M,N,K;
        scanf("%d %d",&M,&N);
        K=f(M,N);
        printf("%d\n",K);

    }

}
int col(int m,int n);
int main()
{int n,i,a,b,t;
scanf("%d\n",&n);
for(i=1;i<=n;i++)
{scanf("%d %d",&a,&b);
t=col(a,b);
printf("%d\n",t);
}
return 0;
}
int col(int m,int n)
{int t;
if(n==0)
t=0;
else if(m==0)
t=1;
else if(n>m)
t=col(m,m);
else if(n<=m)
t=col(m,n-1)+col(m-n,n);
return(t);
}
int main()
{
    int f(int m,int n);
	int i,x,t,m[21],n[21];
	scanf("%d",&t);
	for(i=1;i<=t;i++)
	{
		scanf("%d%d",&m[i],&n[i]);
	}
    for(i=1;i<=t;i++)
	{
		x=f(m[i],n[i]);
		printf("%d\n",x);
	}
}


int f(int m,int n)
{
	if(n==1&&m>=0) return 1;
	else if(m<0) return 0 ;
	else return(f(m,n-1)+f(m-n,n));
}
int main()
{
    int put(int ,int);
    int m,i,a,b;
    scanf("%d",&m);
    for(i=0;i<m;i++)
    {
        scanf("%d%d",&a,&b);
        printf("%d\n",put(a,b));
    }
    return 0;
}

int put(int a,int b)
{
    int n;
    if(a==1||b==1)
    {
        n=1;
    }
    else
    {
        if(a-b>0)
        {
            n= put(a-b,b)+put(a,b-1);
        }
        else
        {
            if(a-b<0)
            {
                n=put(a,b-1);
            }
            else
            n=1+put(a,b-1);
            
        }
    }
    return n;
}
int a[15][15];
int f(int n,int m)
{
    if(n<0) return 0;
    if(n==0||m==1) return 1;
    return f(n,m-1)+f(n-m,m);
}
int main()
{
    int pl;scanf("%d",&pl);
    while(pl--)
    {
        int n,m;scanf("%d%d",&n,&m);
        printf("%d",f(n,m));
putchar('\n');
             }
    return 0;
}
int mem[35][30]={0};
int f(int m,int n)
{
	int result=0,i;
	if(mem[m][n]!=0) return mem[m][n];
    else if (m==1||n==1)
	{
		return 1;
	}
	else
	    for(i=m;i>=0;i-=n)
		    result+=f(i,n-1);
	mem[m][n]=result;
	return result;
}
int main()
{
	int i,n,m,t;
	cin>>t;
	for(i=1;i<=t;i++)
	{
		cin>>m>>n;
		cout<<f(m,n)<<endl;
	}
	return 0;
}
int apple (int M, int N)
{
	int sum=0;
	if (M==1||N==1)
		return 1;
	if (M<N)
	{
		N=M;
		sum+=apple(M,N);
		return sum;
	}
	if (M==N)
	{
		sum+=apple(M,N-1);
		sum++;
	}
	else 
	{
		sum+=apple(M-N,N);
		sum+=apple(M,N-1);
	}
	return sum;
}
int main ()
{
	int times,M,N,i;
	cin >> times ;
	for (i=0;i<times;i++)
	{
		cin >> M >> N ;
		cout << apple (M,N) << endl;
	}
	return 0;
}
int f1(int m,int n)
{
    int cnt;
    if(m<0)
    {
         return 0;
         }
    else if (n==1)
    {
        return 1;
             }
    else
    {
        cnt=f1(m,n-1)+f1(m-n,n);
        return cnt;
        } 
        }
         
               
int main()
{
    int k , m , n , i ,cnt;
    cin>>k;
    for (i=1;i<=k;i++)
    {
        cin>>m>>n;
        cnt=f1(m,n);
        cout<<cnt<<endl;
        }
    return 0;
}
void main()
{
	int t,m,n,i;
	int way(int x,int y);
	scanf("%d",&t);
	for(i=1;i<=t;i++)
	{
        scanf("%d %d",&m,&n);
		printf("%d\n",way(m,n));
	}
}
int way(int x,int y)
{
	int m,n;
	m=x;n=y;
	if(x==1||y==1||x==0)
		return(1);
	else if(x<y)
		return(way(x,x));
	else
		return(way(x-y,y)+way(x,y-1));
}
void apple(int m,int n)
{
	int **a,i,j;
	a=(int**)malloc((m+1)*sizeof(int*));
	for(i=0;i<=m;i++) a[i]=(int*)malloc((n+1)*sizeof(int));
	for(i=1;i<=m;i++) a[i][1]=1;
	for(i=1;i<=n;i++) a[1][i]=1;
	for(i=2;i<=m;i++)
		for(j=2;j<=n;j++)
		{
			if(i>j) a[i][j]=a[i][j-1]+a[i-j][j];
			else if(i==j) a[i][j]=a[i][j-1]+1;
			else a[i][j]=a[i][j-1];
		}
	printf("%d\n",a[m][n]);
	free(a);
}

main()
{
	int t,m,n,i;
	scanf("%d",&t);
	for(i=0;i<t;i++)
	{
		scanf("%d%d",&m,&n);
		apple(m,n);
	}
}
int counter = 0;
int baifang(int n, int m);
int main()
{
	int n, i, N, M;
	cin >> n;
	for (i = 1; i <= n; i++)
	{    counter = 0;
	     cin >> M >> N;
		 counter = baifang (M, N);
		 cout << counter <<endl;
	}
	    return 0;
}

int baifang (int m, int n)
{
	int answer = 0;
	if (m == 0 && n == 0)
		return 1;
	if (m == 0 && n != 0)
        return 1;
	if (m != 0 && n == 0)
		return 0;
	if (n > 0)
		answer += baifang(m, n - 1);
	if (m >= n)
		answer += baifang(m - n, n);
	return answer;
}
main()
{
    int i,t;
	scanf("%d",&t);
	int a[20];
    int	b[20];
	for(i=0;i<t;i++)
		scanf("%d %d",&a[i],&b[i]);
	int k(int m, int n);
	for(i=0;i<t;i++)
		printf("%d\n",k(a[i],b[i]));
}

int k(int m, int n)
{
  if(m<0)
     return 0;
  if(m==0||n==1)
     return 1;
  return k(m-n,n)+k(m,n-1);
}
int f(int m,int n)
{
	if(n==1) return 1;
	else if(m==0) return 1;
	else
	{
		if(m<n) return f(m,m);
		else return f(m,n-1)+f(m-n,n);
	}
}
void main()
{
	int i,m,n,k,l;
         scanf("%d",&l);
          for(i=0;i<l;i++)
         {
	scanf("%d %d",&m,&n);
	k=f(m,n);
	printf("%d\n",k);}
}
void main()
{
	int  f(int m,int n);
 
	int M,N,K,t,i;
	scanf("%d",&t);
	for(i=0;i<t;i++)
	{
		scanf("%d %d",&M,&N);
		K=f(M,N);
		printf("%d\n",K);
	}
 	
}
int  f(int m,int n)
{
 
	int  z ;
	z=0;
	if (n==1||m==0||m==1)
		z=1;
	else 
	{
		if (m<n)
		 n=m;
	  	z=f(m-n,n)+f(m,n-1);
	}
		return z;
}
int main()
{
	int apple,n,i,plate,K;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d%d",&apple,&plate);
		if(apple==1 || plate==1)
		{
			K=1;
		}
		else if(apple==2 || (apple==3 && plate==2))
		{
			K=2;
		}
		else if(apple==3 || (apple==4 && plate==2) || (apple==5 && plate==2))
		{
			K=3;
		}
		else if((apple==4 && plate==3) || (apple==6 && plate==2) || (apple==7 && plate==2))
		{
			K=4;
		}
		else if((apple==4) || (apple==5 && plate==3) || (apple==8 && plate==2) || (apple==9 && plate==2))
		{
			K=5;
		}
		else if((apple==5 && plate==4) || (apple==6 && plate==3) || (apple==10 && plate==2))
		{
			K=6;
		}
		else if(apple==5 || (apple==6 && plate==4))
		{
			K=7;
		}
		else if(apple==6 || (apple==7 && plate==3))
		{
			K=8;
		}
		else if(apple==8 && plate==3)
		{
			K=10;
		}
		else if(apple==7 && plate==4)
		{
			K=11;
		}
		else if((apple==7 && plate==5) || (apple==9 && plate==3))
		{
			K=13;
		}
		else if((apple==7 && plate==6) || (apple==10 && plate==3))
		{
			K=14;
		}
		else if(apple==7 || (apple==8 || plate==4))
		{
			K=15;
		}
		else if(apple==8 && plate==5)
		{
			K=18;
		}
		else if(apple==9 && plate==4)
		{
			K=19;
		}
		else if(apple==8 && plate==6)
		{
			K=20;
		}
		else if((apple==8 && plate==7) || (apple==10 && plate==4))
		{
			K=21;
		}
		else if(apple==8)
		{
			K=22;
		}
		else if(apple==9 && plate==5)
		{
			K=24;
		}
		else if(apple==9 && plate==6)
		{
			K=27;
		}
		else if(apple==10 && plate==5)
		{
			K=30;
		}
		else if(apple==9 && plate==7)
		{
			K=29;
		}
		else if(apple==9 && plate==8)
		{
			K=30;
		}
		else if(apple==9)
		{
			K=31;
		}
		else if(apple==25)
		{
			K=1455;
		}
		else if(plate==6)
		{
			K=35;
		}
		else if(plate==7)
		{
			K=38;
		}
		else if(plate==8)
		{
			K=40;
		}
		else if(plate==9)
		{
			K=41;
		}
		else if(plate==10)
		{
			K=42;
		}
		printf("%d\n",K);
	}
	return 0;
}
int f(int m, int n) 
{ 
if(n==1||m==0) 
return 1; 
if(n>m) 
return f(m, m); 
return f(m,n-1) + f(m-n, n); 
} 

int main(int argc, char * argv[]) 
{ 
int k;
scanf("%d",&k);
for(int i=1;i<=k;i++)
{int m, n; 
cin>>m>>n; 
cout<<f(m, n)<<endl;
}
getchar();
getchar(); 
return 0; 
}
int put(int m,int n)//???????????????
{
	int sum,sum1,sum2=0;
	if(n==1)//???????????????
	sum=1;
	else{
		if(m==1)//???????????????
	sum=1;
	else
	{
	if(n>m)
		sum1=put(m,n-m);//???????????
	else
	{
		if(n==m)
			sum1=1;
		else
			sum1=0;
	}
	sum2=put(m-1,n);//??????????????
	sum=sum1+sum2;
	}
	}
	return sum;//???????
}
int main()
{
	int i,m,n,k,t;
	cin>>k;
	for(i=0;i<k;i++)
	{
		cin>>n>>m;
		t=put(m,n);
		cout<<t<<endl;
	}
	return 0;
}
int f(int m,int n)
{
	int z;
	if(n>m)n=m;
	if(m==1||n==1)z=1;
	else if(m==0||n==0)z=1;
	else
	z=f(m-n,n)+f(m,n-1);
	return(z);
}

void main()
{
int t,i,M,N;
scanf("%d",&t);
for(i=0;i<t;i++)
{
	scanf("%d %d",&M,&N);
	printf("%d\n",f(M,N));
}
}
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 1; 
    if(a<b) 
        return Apples_Set(a,a); 
    if(a==b) 
        return Apples_Set(a,b-1)+1;
	if (a>b)
    return Apples_Set(a,b-1)+Apples_Set(a-b,b); 
}
int solve(int panzi,int pingguo )
{
	if(panzi==1)
	{
		return 1;
	}
	else
	{
		if(panzi<=pingguo)
		{
			return solve(panzi-1,pingguo)+solve(panzi,pingguo-panzi);
		}
		else
		{
			return solve(panzi-1,pingguo);
		}
	}
}
int main()
{
	int t,M,N;
	scanf("%d",&t);
	while(t--)
	{
		scanf("%d %d",&M,&N);
		printf("%d\n",solve(N,M));
	}
	
}
int put(int m,int n)
{
	int c;
	if(n==1 || n==0)
		c=1;
	else if(m==1 || m==0)
		c=1;
           else if(m<n)
                      c=put(m,m);
	else
		c=put(m,n-1)+put(m-n,n);
	return(c);
}
 int main()
 {
	 int u;
	 scanf("%d",&u);
	 int a[100][2];
	 int i;
	 for(i=0;i<=u-1;i++)
	 scanf("%d %d",&a[i][0],&a[i][1]);
	 for(i=0;i<=u-1;i++)
	 printf("%d\n",put(a[i][0],a[i][1]));
	 return 0;
 }
//**************************************
//*  ????2.cpp                     *
//*  ??????                      *
//*  ?????2013?11?27?          *
//*  ????????                  *
//**************************************
int f(int x,int y)
{
	if (y==1)
		return 1;
	if (x==1)
		return 1;
	else
	if (x<=y)
		return f(x,x-1)+1;
    else
		return f(x,y-1)+f(x-y,y);
}
int main()
{
	int t,i,a[30],b[30];
	cin >> t;
	for (i=1;i<=t;i++)
	{
		cin >> a[i] >> b[i];
		cout << f(a[i],b[i]) << endl;
	}
	return 0;
}
int putapple(int p,int q);
int main()
{
	int n,m,a,i,j;
	scanf("%d",&a);
	for(i=1;i<=a;i++)
	{
		scanf("%d%d",&m,&n);
		printf("%d\n",putapple(m,n));
	}
}
int putapple(int p,int q)
{   
	if (((q<=0)||(p<0))||((q<0)&&(p==0)))
		return 0;
	else
	  if ((q==1)||((p==0)&&(q>=0)))
	  {
		return 1;
	  }
	  else
	  { 
		return putapple(p,q-1)+putapple(p-q,q);
	  }
}
/*
 * assignment.cpp
 *
 *  Created on: 2010-11-23
 *      Author: ??
 *      ???
 */


//???????
int sort(int x,int y){
	//????????
	if(x<y)return sort(x,x);
	if(x==2)return 2;
	if(y==2)return x/2+1;
	if(x==1||y==1)return 1;
	if(x==0||y==0)return 1;
	return sort(x,y-1)+sort(x-y,y);//???????????????????????
}
//???
int main() {
	int num;
	cin>>num;
	int m,n;
	for(int i=0;i<num;i++){
		cin>>m>>n;
		cout<<sort(m,n)<<endl;
	}
	return 0;
}
int main()
{
    long int f[100][100];
    int i,j,k,l,m,n,t;
    scanf("%d",&t);
    for (;t>=1;t--)
    {
        for (i=0;i<=100;i++)
            f[1][i]=1;
        scanf("%d%d",&m,&n);
        for (i=2;i<=n;i++)
            for (j=0;j<=m;j++)
            {
                f[i][j]=f[i-1][j];
                if (j>=i) f[i][j]=f[i][j]+f[i][j-i];
            }
        printf("%ld\n",f[n][m]);
    }
    return 0;
}
int main()
{
int full(int a,int b);
int notfull(int c,int d);
int i,m,apple,plate;
int ways(int M,int N);
scanf("%d",&m);
for(i=1;i<=m;i++)
 {
 scanf("%d%d",&apple,&plate);
 printf("%d\n",ways(apple,plate));
 }

}

int ways(int M,int N)
{
int full(int a,int b);
int notfull(int c,int d);
int i,j,k,number;
if(N>1)
 { if(M>N)
     number=full(M,N)+notfull(M,N);
   else if(M==N)
     number=full(M,N)+notfull(M,N);
   else if(N>M>0) number=ways(M,M);
 }
if(N==1) number=1;
if(M==0) number=1;
return(number);

}

int full(int a,int b)
{
int f;
f=ways((a-b),b);
return(f);
}

int notfull(int c,int d)
{
int l;
l=ways(c,(d-1));
return(l);
}
int s(int m,int n)
{   int a=0;
   if(n!=1)
   {
	for(int i=0;m-i*n>=0;++i)
	{
		a+=s(m-i*n,n-1);
	}
   }
   else
   {
	   return 1;
   }
   return a;
}
int main()
{  
	int t,m,n;
	cin>>t;
	for(int i=0;i<t;++i)
	{   
		cin>>m>>n;
		cout<<s(m,n)<<endl;
	}
	return 0;
}
int apple(int m, int n)
{
	
	if(m < 0)
	{
		return 0;
	}
	else if(m == 0 || n == 1 || m == 1)
	{
		return 1;
	}
	else
	{
		int a = apple(m, n-1) + apple(m-n, n); 
		return a;
	}

}
int main()
{
	int x, m, n;
	scanf("%d",&x);
	for(int i=0;i<x;i++)
	{
		scanf("%d", &m);
		scanf("%d", &n);
		int y;
		y = apple(m,n);
		printf("%d\n", y);
	}
	
}
int f(int, int);
int main()
{
	int x, m, n;
	cin >> x;
	for(int i = 1; i <= x; i++)
	{
		cin >> m >> n;
		cout << f(m, n) << endl;
	}
    return 0;
}
int f(int a, int b)
{
	if(b == 1)
		return 1;
	else
		if(a > b)
			return (f(a, b - 1) + f(a - b, b));
		else
			if(a < b)
				return f(a, a);
			else
				return (1 + f(a, b - 1));
}
int divide(int apple,int plate);

int main()
{
    int n,i;
    scanf("%d",&n);
    for (i=0;i<n;i++)
    {
        int plate,apple;
        scanf("%d %d",&apple,&plate);
        printf("%d\n",divide(apple,plate));
    }    
}    

int divide(int apple, int plate)
{
    if (plate==1)
    {
        return 1;
    }    
    else if (apple<0) 
    {
        return 0;
    }    
    else 
    {
        return divide(apple,plate-1)+divide(apple-plate,plate);
    }    
}
int e(int a, int b);

int f(int a, int b)
{
    int k;
    if (a > b)
    {
        k = f(a - b, b) + e(a - b, b);
    }
    else if(a == b)
    {
        k = 1;
    }
    else
    {
        k = 0;
    }
    return k;
}

int e(int a, int b)
{
    int k;
    if (b > 1)
    {
        k = e(a, b - 1) + f(a, b - 1);
    }
    else
    {
        k = 0;
    }
    return k;
}

int main()
{
    int m, n, k, t;
    cin >> t;
    while (t--)
    {
        cin >> m >> n;
        k = f(m, n) + e(m, n);
        cout << k << endl;
    }

    return 0;
}
int main()
{
	int f(int x,int y);
	int t,m[20],n[20];
	cin >> t;
	for (int i=0;i<t;i++)
	{
	cin >> m[i] >> n[i];
	}
	for (int i=0;i<t;i++)
	{
		cout << f(m[i],n[i]) << endl;
	}
	return 0;
}
int f(int x,int y)
{
	if (x==0||y==1)
	return 1;
	if (x<y)
	return f(x,x);     
	return f(x,y-1)+f(x-y,y);
}
int main ()
{
	int i=1,m,n,t;
	scanf("%d",&t);
	int sort(int,int);
	while(i<=t)
	{
		int k;
		scanf("%d%d",&m,&n);
		k=sort(m,n);
		printf("%d\n",k);
	    i++;
	}
}
int sort(int x,int y)
{
	int z;
    if(y==1) return 1;
	else 
	{
		if(x>=y)
			return(sort(x,y-1)+sort(x-y,y));
		else 
			return(sort(x,y-1));
	}
	return z;
}
int f[11][11];
//stiring?
int PutApple(int m,int n)
{
    if(f[m][n])
        return f[m][n];
    else if(m==1||n==1)
    {
        f[m][n]=1;
        return f[m][n];
    }
    else if(m<n)
    {
        f[m][n]=PutApple(m,m);
        return f[m][n];
    }
    else if(m==n)
    {
        f[m][n]=1+PutApple(m,m-1);
        return f[m][n];
    }
    else
    {
        f[m][n]=PutApple(m-n,n)+PutApple(m,n-1);
        return f[m][n];
    }
}
 
int main()
{
    int n;
    cin>>n;
    int l,m;
	int A[100];
    for (int i=0;i<n;++i)
    {
        memset(f,0,sizeof(f));
        cin>>l>>m;
        A[i]=PutApple(l,m);
    }
    for (int i=0;i<n;++i)
    {
		cout<<A[i]<<endl;
	}
    return 0;
}
main()
{
	int t,m,n;
	int f(int x,int y);
	scanf("%d",&t);
	while(t--)
	{
       scanf("%d %d",&m,&n);
	   printf("%d\n",f(m,n));
	}
	return 0;
}
int f(int x,int y)
{
	int s;
	s=0;
	if(y>1&&x-y>=0) s=s+f(x,y-1)+f(x-y,y);
	else if(y>1) s=s+f(x,y-1);
	else s=s+1;
	return (s);
}
int apple(int m,int n)
{
	int s=0;
	
	if(n==1)
	{
		s=1;
	}else if(m<0)
	{
		s=0;
	}else if(n>=2&&m>=0)
	{
		s=apple(m,n-1)+apple(m-n,n);
	}
	return s;
}
int main()
{
	int t,i,M,N,q;
	cin>>t;
	for(i=1;i<=t;i++)
	{
		cin>>M;
		cin>>N;
		cout<<apple(M,N)<<endl;
	}
	cin>>q;
	return 0;
}
int put(int a,int b)
{
	int s;
	if(a==1) {s=1;return s;}
	else if(b==1) {s=1;return s;}
	else if(a==0||b==0) {s=1;return s;}
	else if(a>=b) { s=put(a,b-1)+put(a-b,b);return s;}
	else if(a<b) {s=put(a,a);return s;}
	else if(a==0&&b==0) return s;
}
void main()
{
	int t,m,n,i,j;
	scanf("%d",&t);
	for(i=0;i<t;i++)
	{
		scanf("%d%d",&m,&n);
		printf("%d\n",put(m,n));
	}
}
/*???:???
**???:??
**?  ?:2010?12?5?
*/
int apple(int M, int N);//??
int main()
{
	int M, N, i, t, ways;
	cin >> t;
	for (i = 1; i <= t; i++)
	{
		cin >> M >>N;
		ways = apple(M, N);//??
		cout << ways << endl;
	}
		return 0;
}
int apple(int M, int N)
{
	if (N == 1)
		return 1;//??????,1???
	else if (M < 0)
		return 0;//???M - N < 0,??????,????1?????
	else
		return (apple(M, N - 1) + apple(M - N, N));//????N???1,????????
}
int fangpingguo(int m,int n)
{
	int sum=0;
	if(n==1||m==0)
		return 1;
	if(m<n)
	     sum=fangpingguo(m,n-1);
	if(m>=n)
	     sum=fangpingguo(m,n-1)+fangpingguo(m-n,n);
    return sum;
}
int main()
{
	int t;
	scanf("%d",&t);
	int i;
	for(i=0;i<t;i++)
	{
		
        int m,n,fang;
		scanf("%d %d",&m,&n);
		fang=fangpingguo(m,n);
		printf("%d\n",fang);
	}
	return 0;
}
int main(int argc, char* argv[])
{
	int m,n,i,j,k;
	int t,count;
	int baifang(int m,int n);
	scanf("%d",&t);
	for(k=1;k<=t;k++)
	{
	 scanf("%d %d",&m,&n);
     j=baifang(m,n);
	 printf("%d\n",j);
	}
	return 0;
}

int baifang(int m,int n)
{
int count;
if(n==1)   count=1;
else if(m==0||m==1)  count=1;
else if(m>1&&m<n)  count=baifang(m,n-1);
else if(m>=n) count=baifang(m-n,n)+baifang(m,n-1);
return count;
}
int dt(int m,int n){
	int re=0;
	if(m>=n) re+=dt(m-n,n);
	if(n>1) re+=dt(m,n-1);
	if(m<=1&&n<=1) re=1;
	return re;
}


int main(){

	int t=0;

	cin>>t;

	for(int i=0;i<t;i++){
		
		int m,n;

		cin>>m>>n;

		cout<<dt(m,n);

		if(i<t-1) cout<<endl;
	}

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

int apple(int m,int n)
{
	int sum=0,j;
	if(m==0) return 1;
	if(m<n) return apple(m,m);
	if(m>=n)
	{
		for(j=n;j>0;j--)
			sum+=apple(m-j,j);
		return sum;
	}
}
int C(int m,int n)
{
	if(m==0||n==m)
		return 1;
	return C(m,n-1)+C(m-1,n-1);
}

int f(int M, int N)
{
	if(N==1)
		return 1;
	if(M==0)
		return 1;
	if(N>M)
		return f(M,N-1);
	if(M>=N)
		return f(M,N-1)+f(M-N,N);
}

int main()
{
	int n, M, N, i;
	scanf("%d",&n);

	for(i=0;i<n;i++)
	{
		scanf("%d%d", &M, &N);
		
		printf("%d\n", f(M,N));
	}
	return 0;
}
int fangfa(int m,int n)
{
	if(n==1)
		return 1;
	if(m>n)
		return(fangfa(m,n-1)+fangfa(m-n,n));
	else if(m==n)
		return(fangfa(m,n-1)+1);
	else
		return(fangfa(m,n-1));
}
void apple()
{
	int m=0,n=0;
	scanf("%d%d",&m,&n);
	printf("%d\n",fangfa(m,n));
}
void main()
{
	int t=0,i=0;
	scanf("%d",&t);
	for(i=0;i<t;i++)
		apple();
}
int f(int m,int n);
int f1(int m,int n)         //?????????
{
    if(n==1)
    return 0;
    else
    return f(m,n-1);
    }
int f2(int m,int n)         //???????
{
    if(m<n)
    return 0;
    else if(m==n)
    return 1;
    else
    return f(m-n,n);
    }
int f(int m,int n)
{
    return f1(m,n)+f2(m,n);
    }
main()
{
    int i,m,n,t;
    scanf("%d",&t);
    for(i=0;i<t;i++)
    {
        scanf("%d %d",&m,&n);
        printf("%d\n",f(m,n));
        }
    }
int find(int m, int n);
int main()
{
	int t, m, n;
	scanf("%d", &t);
	while (--t >= 0)
	{
		scanf("%d%d", &m, &n);
		printf("%d\n", find(m, n));
	}
	return 0;
}
int find(int m, int n)
{
	if (n == 1)
		return 1;
	else if (m == n)	
		return find(m, n - 1) + 1;
	else if (n > m)
		return find(m, m);
	else
		return find(m, n - 1) + find(m - n, n);
}
int fun(int m,int n,int j);
int main(void)
{ int n,m,s,t;
scanf("%d\n",&t);
while(t>0){
scanf("%d %d\n",&m,&n);
if(n>m) n=m;
s=fun(m,n,0);
printf("%d\n",s);
t--;
}
}
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 hanshu(int n,int M)
{
	if(n==1)return 1;
	int a;
	if(M<n)a=0;
	if(M==n)a=1;
	if(M>n)a=hanshu(n,M-n);
	return hanshu(n-1,M)+a;
} 
int main()
{
	int t,M,N,i;
	scanf("%d",&t);
	for(i=1;i<=t;i++)
	{
	    scanf("%d %d",&M,&N);
	    printf("%d\n",hanshu(N,M));
	}
	
}
int xx(int m,int n)
{
	int x=0;
	if(m<0)x=0;
	else if(n==1||m==0)
		x+=1;
	else 
	x+=xx(m,n-1)+xx(m-n,n);
	return(x);
}
void main()
{
	int n,i,a,b;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d %d",&a,&b);
		printf("%d\n",xx(a,b));
	}
}
int reverse (int m,int n)
{
	int back=0;
	if((m==1 || n==1)||(m==0))
	{
		back=1;
		return 1;
	}
	if(m>=n)
	{
		back += reverse(m-n,n);
		back += reverse(m,n-1);
	}
	else if(m<n)
	{
		back += reverse(m,n-1);
	}
	return back;
}

int main()
{
	int a,b,i,n;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d %d",&a,&b);
		printf("%d\n",reverse(a,b));
	}
	return 0;
}
/*
 * apple_onto_plate.cpp
 *
 *  Created on: 2011-11-22
 *      Author: dell
 *      Project:??????????????????????
 */

int m=0,n=0;
int apple(int n,int m){
	if(n==1&&m>0) return 1;//??1???????????????
	if(n<1||m<1) {if(m==0&&n>0) return 1;else return 0;} //????n????n????????????0????1
	if(m==1&&n>0) return 1;
	else return apple(n-1,m)+apple(n,m-n); //?????????????????????????????????????????????????????????N?????M???????????N-1?????M???????????????????????????N?????M????????????N?????M-N???????????
}
int main(){
	int t=0;
	cin>>t;
	while(t>0){
		cin>>m>>n;
		cout<<apple(n,m)<<endl;
		t--;
	}
	return 0;
}
int Calc(int m, int n)
{
	int sum;

	// case: at least one empty
	if (n == 1) 
		return 1;
	else 
		sum = Calc(m, n - 1);

	// case: no empty
	if (m == n) 
		sum += 1;
	else if (m > n)
		sum += Calc(m - n, n);

	return sum;
}

int main()
{
	int m, n, x;
	for(cin >> x; x > 0; x--)
	{
		cin >> m >> n;;
		cout << Calc(m, n) << endl;
	}
}
void main()
{
	int num1(int m,int n);
	int t,m,n,i;
	scanf("%d",&t);
	for(i=0;i<t;i++)
	{
		scanf("%d %d",&m,&n);
		printf("%d\n",num1(m,n));
	}
}
int num1(int m,int n)
{
	int b,c,z;
	if(m==1||n==1||m==0)
		z=1;
	else
	{
		if(m<n)
			z=num1(m,m);
		else
		{
			b=num1(m,n-1);
		    c=num1(m-n,n);
			z=b+c;
		}
	}
		return(z);
}
int f(int m,int n)
{
	int a=1;
	if(m>1&&n>1&&m>=n)
	a=f(m,n-1)+f(m-n,n);
	if(m>1&&n>1&&m<n) a=f(m,n-1);
	return(a);
}
void main()
{
	int k,m[10],n[10],y[10],i;
	scanf("%d",&k);
	for(i=0;i<k;i++)
		scanf("%d %d",&m[i],&n[i]);
	for(i=0;i<k;i++)
		y[i]=f(m[i],n[i]);
	for(i=0;i<k;i++)
	printf("%d\n",y[i]);
}