semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int main()
{
    int mz = 0 , mq = 0 , ms = 0 , ml = 0 ;
    for(mz = 1 ; mz<=5 ; mz++)
    {
        for(mq = 1 ; mq<=5 ; mq++)
        {
            for(ms = 1 ; ms<=5 ; ms++)
            {
                for(ml = 1 ; ml<=5 ; ml++)
                {
                    if((mz+mq==ms+ml)&&(ms+mz<mq)&&(mz+ml>ms+mq))
                    {
                        for(int i = 5 ; i >=1 ; i--)
                        {
                            if(mz==i)
                                cout<<"z "<<mz*10<<endl;
                            if(mq==i)
                                cout<<"q "<<mq*10<<endl;
                            if(ms==i)
                                cout<<"s "<<ms*10<<endl;
                            if(ml==i)
                                cout<<"l "<<ml*10<<endl;
                        }
                    }
                }
            }
        }
    }
    return 0 ;
}
int main()
{ 
	int z,q,s,l,t;
	char a[5];
	int b[5];
	for(z=10;z<=50;z=z+10)
		for(q=10;q<=50;q=q+10)
			for(s=10;s<=50;s=s+10)
				for(l=10;l<=50;l=l+10)
					if((z+q==s+l)&&(z+l>s+q)&&(z+s<q)){
	b[1]=z;b[2]=q;b[3]=s;b[4]=l;
	a[1]='z';a[2]='q';a[3]='s';a[4]='l';
	for(int i=1;i<=4;i++)
		for(int j=1;j<=3;j++)
			if(b[j]<b[j+1])
			{
				t=b[j];b[j]=b[j+1];b[j+1]=t;
				t=a[j];a[j]=a[j+1];a[j+1]=t;
			}
	for(int i=1;i<=4;i++)
		cout << a[i] << " " << b[i] << endl;
					}

	return 0;
}
int z,q,l,s;
int a[5];
void print()
{
	for(int j = 1;j <= 4;j ++){
		int max = 0;
		int flag = 0;
		for(int i = 1;i <= 4;i ++){
			if(a[i] > max){
				max = a[i];
				flag = i;
			}
		}
		a[flag] =  - 1;
		if(max == z) printf("z %d\n",z);
		if(max == q) printf("q %d\n",q);
		if(max == s) printf("s %d\n",s);
		if(max == l) printf("l %d\n",l);
	}
}
			
		
int main()
{
	for(z = 10;z <= 50;z = z + 10)
		for(q = 10;q <= 50;q = q + 10)
			for(s = 10;s <= 50;s = s + 10)
				for(l = 10;l <= 50;l = l + 10)
					if(z + q == s + l && z + l > s + q && z + s < q){
						a[1] = z;
						a[2] = q;
						a[3] = s;
						a[4] = l;
						print();
					}
	return 0 ;
}
//
//  main.cpp
//  poj
//
//  Created by ChuPan,Wong on 9/27/13.
//  Copyright (c) 2013 ChuPan,Wong. All rights reserved.
//


int main(int argc, const char * argv[])
{
    //  manual computation shows that there is only one solution for this question
    cout<<"l 50"<<endl;
    cout<<"q 40"<<endl;
    cout<<"z 20"<<endl;
    cout<<"s 10"<<endl;
        return 0;
}
int main()
{
	for (int z=1;z<=5;z++)
	{
		for (int q=2;q<=5;q++)
		{
			for (int s=1;s<=5;s++)
			{
				for (int l=1;l<=5;l++)
				{
					if ((z+q)==(s+l) && (z+l)>(s+q) && (z+s)<q)
					{
						for (int k=5;k>=1;k--)
						{
							if (z==k)
								cout<<"z"<<" "<<10*z<<endl;
							if (q==k)
								cout<<"q"<<" "<<10*q<<endl;
							if (s==k)
								cout<<"s"<<" "<<10*s<<endl;
							if (l==k)
								cout<<"l"<<" "<<10*l<<endl;
						}
					}
				}
			}
		}
	}
	return 0;
}
int main()
{
	int wz,wq,ws,wl;	//?????????weight
	int i,j;	//??????????i?j
	char a[5];
	int b[5];	//????a?b?a???????b??????
	int p,t;	//???????????p??????????t
	for(wz=10;wz<=50;wz=wz+10)
		for(wq=10;wq<=50;wq=wq+10)
			for(ws=10;ws<=50;ws=ws+10)
				for(wl=10;wl<=50;wl=wl+10)		//???????10?50??
				{if(wz+wq==ws+wl&&wz+wl>ws+wq&&wz+ws<wq)	
				//??????????????????????????
				//??????????????????????
				//???????????????????
				{a[1]='z';a[2]='q';a[3]='s';a[4]='l';
				 b[1]=wz;b[2]=wq;b[3]=ws;b[4]=wl;
				}
				}
	for(j=1;j<=3;j++)
		for(i=1;i<=4-j;i++)
			if(b[i]<b[i+1])
			{p=a[i];a[i]=a[i+1];a[i+1]=p;
			 t=b[i];b[i]=b[i+1];b[i+1]=t;}
	for(i=1;i<=4;i++)
	{cout<<a[i]<<" "<<b[i]<<endl;}	//????
return 0;
}
int main()
{
    int wei[5],i,sum=1,max;
    int a[5]={0,0,0,0,0};
    
    for(wei[1]=1;wei[1]<=5;wei[1]++)
        {for(wei[2]=1;wei[2]<=5;wei[2]++)
            {for(wei[3]=1;wei[3]<=5;wei[3]++)
                {for(wei[4]=1;wei[4]<=5;wei[4]++)
                   if ((wei[1]+wei[2])==(wei[3]+wei[4]) && (wei[1]+wei[4])>(wei[2]+wei[3]) && (wei[1]+wei[3]<wei[2]))
                       {
                           while (sum<=4)
                           { max=0;
                           for (i=1;i<=4;i++)
                           {if (wei[i]>max&&a[i]==0)
                            max=wei[i];
                           }
                            
                          if (max==wei[1])
                          {cout<<"z"<<" "<<wei[1]*10<<endl;a[1]=1;}
                          if (max==wei[2])
                          {cout<<"q"<<" "<<wei[2]*10<<endl;a[2]=1;}
                          if (max==wei[3])
                          {cout<<"s"<<" "<<wei[3]*10<<endl;a[3]=1;}
                          if (max==wei[4])
                          {cout<<"l"<<" "<<wei[4]*10<<endl;a[4]=1;}
                          max=0;
                          sum++;
                          }
                            
                          
                       }
                   
                }
            }
        }
    return 0;
}
//???
//??????
//?????????????????????
int main()
{
	int wei[4];          //?????????
	          
	for (wei[0]=1;wei[0]<=5;wei[0]++)                //wei[0]?????
		for (wei[1]=1;wei[1]<=5;wei[1]++)            //wei[1]?????   
			for (wei[2]=1;wei[2]<=5;wei[2]++)        //wei[2]?????
				for (wei[3]=1;wei[3]<=5;wei[3]++)    //wei[3]?????????????????
				{
					int x[3];                        //???????????
					x[0]=(wei[0]+wei[1])==(wei[2]+wei[3]);   //???????
					x[1]=(wei[0]+wei[3])>(wei[2]+wei[1]);    //???????
					x[2]=(wei[0]+wei[2])<wei[1];             //???????
					if (x[0]+x[1]+x[2]==3)                   //????????????
					{
						char c[4][4];                        //??????????????"z 50"
						c[0][0]='z';
						c[1][0]='q';
						c[2][0]='s';
						c[3][0]='l';
						for (int i=0;i<4;i++)
						{
							c[i][1]=' ';
							c[i][2]=wei[i]+'0';
							c[i][3]='0';
						}
						
						for (int j=0;j<3;j++)               //??????wei??????????c???
						{
							for(int k=0;k<3-j;k++)
							{
								if(wei[k]<wei[k+1])        //???????????
								{
									int p;                 //??wei??????
									char q[4];             //??c??????
									
									p=wei[k];              //??????
									wei[k]=wei[k+1];
									wei[k+1]=p;
									
								    for(int y=0;y<4;y++)   //?????c???
									{
										q[y]=c[k][y];
										c[k][y]=c[k+1][y];
										c[k+1][y]=q[y];
									}
									
								}
								else;								
							}
							
						}
						
						for(int m=0;m<4;m++)               //??
						{
							for(int n=0;n<4;n++)
								cout<<c[m][n];
							cout<<endl;
						}
						
					}
					else;
				}
	return 0;
}
int main()
{
	int a[4],b[5]={10,20,30,40,50},i,j,k,l,m;
	for(i=0;i<5;i++)
	{
		a[0]=b[i];
		for(j=0;j<5;j++)
		{
			a[1]=b[j];
			for(k=0;k<5;k++)
			{
				a[2]=b[k];
				for(l=0;l<5;l++)
				{
					a[3]=b[l];
					if(i!=j&&i!=k&&i!=l&&j!=k&&j!=l&&a[0]+a[1]==a[2]+a[3]&&a[0]+a[3]>a[1]+a[2]&&a[0]+a[2]<a[1])
						break;
				}
				if(i!=j&&i!=k&&i!=l&&j!=k&&j!=l&&a[0]+a[1]==a[2]+a[3]&&a[0]+a[3]>a[1]+a[2]&&a[0]+a[2]<a[1])
						break;
			}
			if(i!=j&&i!=k&&i!=l&&j!=k&&j!=l&&a[0]+a[1]==a[2]+a[3]&&a[0]+a[3]>a[1]+a[2]&&a[0]+a[2]<a[1])
						break;
		}
		if(i!=j&&i!=k&&i!=l&&j!=k&&j!=l&&a[0]+a[1]==a[2]+a[3]&&a[0]+a[3]>a[1]+a[2]&&a[0]+a[2]<a[1])
						break;
	}
	    cout<<"l "<<a[3]<<endl;
		cout<<"q "<<a[1]<<endl;
		cout<<"z "<<a[0]<<endl;
		cout<<"s "<<a[2]<<endl;
	return 0;
}
int main()
{
    int i,j,z,q,s,l;
    printf("l 50\nq 40\nz 20\ns 10\n");
}
int main()
{
	int a,b,c,d;
	for (a=10;a<=50;a+=10)
	{
		for (b=10;b<=50;b+=10)
		{
			for (c=10;c<=50;c+=10)
			{
				for (d=10;d<=50;d+=10)
				{
					if ( (a+b==c+d) && (a+d>b+c) && (a+c<b))
					{
						goto loop;
					}
				}
			}
		}
	}
loop:   for (int i=1;i<=4;i++)
		{
			int max=10;
			if (a>max)
			{
				max=a;
			}
			if (b>max)
			{
				max=b;

			}
			if (c>max)
			{
				max=c;

			}
			if (d>max)
			{
				max=d;

			}
			if (a==max)
			{
				cout<<"z "<<a<<endl;
				a=0;
			}
			if (b==max)
			{
				cout<<"q "<<b<<endl;
				b=0;
			}
			if (c==max)
			{
				cout<<"s "<<c<<endl;
				c=0;
			}
			if (d==max)
			{
				cout<<"l "<<d<<endl;
				d=0;
			}
		}



}
int main()
{
	int a, b, c, d;
	for (a = 1; a <= 5; a ++)
	{
		for (b = 1; b <= 5; b ++)
		{
			if (b == a)
				continue;
			for (c = 1; c <= 5; c ++)
			{
				if (c == a || c == b)
					continue;
				for (d = 1; d <= 5; d ++)
				{
					if (a + b == c + d && a + d > b + c && a + c < b)
					{
						if (b > d && b > c && c > a)
						{
							cout<<'q'<<" "<<10 * b<<endl;
							cout<<'l'<<" "<<10 * d<<endl;
							cout<<'s'<<" "<<10 * c<<endl;
							cout<<'z'<<" "<<10 * a<<endl;
						}
						if (d > b && b > a && a > c)
						{
							cout<<'l'<<" "<<10 * d<<endl;
							cout<<'q'<<" "<<10 * b<<endl;
							cout<<'z'<<" "<<10 * a<<endl;
							cout<<'s'<<" "<<10 * c<<endl;
						}
					}
				}
			}
		}
	}
	return 0;
}
/*
 * weight.cpp
 *
 *  Created on: 2012-10-27
 *      Author:??
 */
int main()                    //?????
{
	int z,q,s,l,i,j,p;        //??????????

	int cc0,cc1,cc2,cc3;             //??????
	for(z = 10;z<=50;z=z+10)          //?z,q,s,l??
		for(q = 10;q<=50;q=q+10)
			for(s = 10;s<=50;s=s+10)
				for(l = 10;l<=50;l=l+10)
				{
					cc0 = (z!=q)&&(z!=s)&&(z!=l)&&(q!=s)&&(q!=l)&&(s!=l); //??????
					cc1 = (z + q == s + l);                //????
					cc2 = (z + l >= q + s);
					cc3 = (z +s < q);
					if(cc0&&cc1&&cc2&&cc3 == 1)            //????????
					{
						int weight[4] ={z,q,s,l};           //?????????????
						char a,person[4]={'z','q','s','l'};  //????????????????
						for(i = 0;i<=2;i++)                 //?????????
						{
							for(j = 0;j<=2-i;j++)           //????
							{
								if(weight[j]<weight[j+1])    //??weight[j]<weight[j+1]
								{
									p = weight[j];          //??weight[j]?weight[j+1]
									weight[j] = weight[j+1];
									weight[j+1] = p;
									a = person[j];            //????????
									person[j] = person[j+1];
									person[j+1] = a;
								}
							}
						}
						for(i = 0;i<=3;i++)                  //?????????
						{
							cout<<person[i]<<' '<<weight[i]<<endl;
						}
					}
				}                                   //????
	return 0;                                         //???????????
}
int main()
{
	int z,q,s,l;
	for(z=1;z<=5;z++)
		for(q=1;q<=5;q++)
			if(q!=z)
				for(s=1;s<=5;s++)
					if(s!=z&&s!=q)
						for(l=1;l<=5;l++)
							if(l!=z&&l!=q&&l!=s)
								if(((z+q)==(s+l))&&((z+l)>(q+s))&&((z+s)<q))
								{
									if(z==5)cout<<"z 50"<<endl;
									else if(q==5)cout<<"q 50"<<endl;
									else if(s==5)cout<<"s 50"<<endl;
									else if(l==5)cout<<"l 50"<<endl;
									if(z==4)cout<<"z 40"<<endl;
									else if(q==4)cout<<"q 40"<<endl;
									else if(s==4)cout<<"s 40"<<endl;
									else if(l==4)cout<<"l 40"<<endl;
									if(z==3)cout<<"z 30"<<endl;
									else if(q==3)cout<<"q 30"<<endl;
									else if(s==3)cout<<"s 30"<<endl;
									else if(l==3)cout<<"l 30"<<endl;
									if(z==2)cout<<"z 20"<<endl;
									else if(q==2)cout<<"q 20"<<endl;
									else if(s==2)cout<<"s 20"<<endl;
									else if(l==2)cout<<"l 20"<<endl;
									if(z==1)cout<<"z 10"<<endl;
									else if(q==1)cout<<"q 10"<<endl;
									else if(s==1)cout<<"s 10"<<endl;
									else if(l==1)cout<<"l 10"<<endl;
								}
	return 0;
}
int main(){
	int z,q,s,l;
	for(z=1;z<=5;z++){
		for(q=1;q<=5;q++){
			for(s=1;s<=5;s++){
				for(l=1;l<=5;l++){
					if(z+q==s+l&&z+l>s+q&&z+s<q&&z!=q&&z!=s&&z!=l&&q!=s&&q!=l&&s!=l)//????????
					{
						int a[5],t,m;
						char c[5],tc;
						a[1]=z;a[2]=q;a[3]=s;a[4]=l;
						c[1]='z';c[2]='q';c[3]='s';c[4]='l';
						for(int i=1;i<=4;i++){
							m=i;
							for (int j=i+1;j<=4;j++) if(a[j]>a[m]) m=j;
							t=a[i];a[i]=a[m];a[m]=t;
							tc=c[i];c[i]=c[m];c[m]=tc;
							cout<<c[i]<<" "<<a[i]*10<<endl;      //?????
						}



					}
				}
			}

		}
	}

 return 0;

}
int main()
{
	int z,q,s,l,a[5]={0},p;//????????????z,q,s,l,???????????????????a[5]?????????p
	char weight[5];//???????????????
	for(z=1;z<=5;z++)//?????????????
	{
		for(q=1;q<=5;q++)
		{
			for(s=1;s<=5;s++)
			{
				for(l=1;l<=5;l++)
				{
					if((z+q==s+l)+(z+l>s+q)+(z+s<q)==3)//??????????????????
					{weight[z]='z';
					weight[q]='q';
					weight[s]='s';
					weight[l]='l';
					a[1]=z;
					a[2]=q;
					a[3]=s;
					a[4]=l;
					for(int j=1;j<4;j++){//?????????????????
					for(int i=1;i<5-j;i++)
					{
						if(a[i]<a[i+1])
						{p=a[i];
						a[i]=a[i+1];
						a[i+1]=p;}
					}}
					for(int i=1;i<5;i++)//????????
					{cout<<weight[a[i]]<<" "<<a[i]*10<<endl;}
				}
				}
			}
		}
	}
	return 0;
}
int main()
{
	int q,w,e,r;
	for(q=1;q<=5;q++)
	{
		for(w=1;w<=5;w++)
		{
			for(r=1;r<=5;r++)
			{
				for(e=1;e<=5;e++)
				{
					if((q+w==e+r)&&(q+r>w+e)&&(q+e<w))
						for(int i=5;i>=1;i--)
						{
							if(q==i)
							{
								printf("z %d\n",10*q);
							}
							if(w==i)
							{
								printf("q %d\n",10*w);
							}
							if(e==i)
							{
								printf("s %d\n",10*e);
							}
							if(r==i)
							{
								printf("l %d\n",10*r);
							}
						}
				}
			}
		}
	}
	return 0;
}
main()
{
  char z,q,s,l;
   printf("%c %d\n%c %d\n%c %d\n%c %d\n",'l',50,'q',40,'z',20,'s',10);
   getchar();
   getchar();  
}
int main()
{
	int z,q,s,l,rank[51],i;
	char word[51];
	for(i=0;i<=50;i++)
	{
		rank[i]=0;
	}
	for(z=10;z<=50;z=z+10)
	{
		for(q=10;q<=50;q=q+10)
		{
			for(s=10;s<=50;s=s+10)
			{
				for(l=10;l<=50;l=l+10)
				{
					if(((z+q)==(s+l))&&((z+l)>(s+q))&& ((z+s)<q)&& z!=q && z!=s && z!=l && q!=s && q!=l && s!=l)
					{
						word[z]='z';
						word[q]='q';
						word[s]='s';
						word[l]='l';
						rank[z]=z;
						rank[q]=q;
						rank[s]=s;
						rank[l]=l;
						for(i=50;i>=0;i--)
						{
							if(rank[i]!=0)
							{
								cout << word[i] << " " << rank[i] << endl;
							}
						}
						
					}

				}
			}
		}
	}
	return 0;
}
//???
int main()
{
	int z,q,s,l;
	for (z=10;z<=50;z=z+10)//??????
	{
		for (q=10;q<=50;q=q+10)
		{
			if (q==z)
				continue;
			for (s=10;s<=50;s=s+10)
			{
				if (s==z||s==q)
					continue;
				for (l=10;l<=50;l=l+10)
				{
					if (l==z||l==q||l==s)
						continue;
					if ((z+q==s+l)&&(z+l>s+q)&&(z+s<q))//??
					{
						if (z==50) cout<<'z'<<' '<<z<<endl;
						if (q==50) cout<<'q'<<' '<<q<<endl;
						if (s==50) cout<<'s'<<' '<<s<<endl;
						if (l==50) cout<<'l'<<' '<<l<<endl;
						if (z==40) cout<<'z'<<' '<<z<<endl;
						if (q==40) cout<<'q'<<' '<<q<<endl;
						if (s==40) cout<<'s'<<' '<<s<<endl;
						if (l==40) cout<<'l'<<' '<<l<<endl;
						if (z==30) cout<<'z'<<' '<<z<<endl;
						if (q==30) cout<<'q'<<' '<<q<<endl;
						if (s==30) cout<<'s'<<' '<<s<<endl;
						if (l==30) cout<<'l'<<' '<<l<<endl;
						if (z==20) cout<<'z'<<' '<<z<<endl;
						if (q==20) cout<<'q'<<' '<<q<<endl;
						if (s==20) cout<<'s'<<' '<<s<<endl;
						if (l==20) cout<<'l'<<' '<<l<<endl;
						if (z==10) cout<<'z'<<' '<<z<<endl;
						if (q==10) cout<<'q'<<' '<<q<<endl;
						if (s==10) cout<<'s'<<' '<<s<<endl;
						if (l==10) cout<<'l'<<' '<<l<<endl;
					}
				}
			}
		}
	}
	return 0;
}
int main()
{
	int z,q,s,l,a,b,c,d;
	for (z=10;z<=50;z=z+10)
	{
		for (q=10;q<=50;q=q+10)
		{
			for (s=10;s<=50;s=s+10)
			{
				for (l=10;l<=50;l=l+10)
				{
					a=(z+q)==(s+l);
					b=(z+l)>(s+q);
					c=(z+s)<q;
				if (a==1 && b==1 && c==1)
				{   if (a)
					cout<<"l "<<l <<endl;
				    cout<<"q "<<q <<endl;
				    cout<<"z "<<z <<endl;
					cout<<"s "<<s <<endl;
					break;
				}
				}
			}
		}
	} 
	return 0;
}
int main()
{
	int z=0,q=0,s=0,l=0,i=0,j=0,k=0,m=0,n=0,x=0;
	for(i=1;i<=5;i++)
	{
		z=10*i;
		for(j=1;j<=5;j++)
		{
			q=10*j;
			if(q==z)
			{
				continue;
			}
			for(k=1;k<=5;k++)
			{
				s=10*k;
				if(s==z||s==q)
				{
					continue;
				}
				for(m=1;m<=5;m++)
				{
					l=10*m;
					if(l==z||l==q||l==s)
					{
						continue;
					}
					if((z+q==s+l)&&(z+l>s+q)&&(z+s<q))
					{
						for(n=5;n>=1;n--)
						{
							x=n*10;
							if(z==x)
							{
								cout<<"z "<<x<<endl;
							}
                            else if(q==x)
							{
								cout<<"q "<<x<<endl;
							}
                            else if(s==x)
							{
								cout<<"s "<<x<<endl;
							}
                            else if(l==x)
							{
								cout<<"l "<<x<<endl;
							}
						}
					}
				}
			}
		}
	}
	return 0;
}
int main()
{
	int a[5],i,j,k,m;
	char n[5]={'0','z','q','s','l'},o;
	for(i=1;i<6;i++)
	{
		a[1]=i;
		for(j=1;j<6;j++)
		{
			a[2]=j;
			for(k=1;k<6;k++)
			{
				a[3]=k;
				for(m=1;m<6;m++)
				{
					a[4]=m;
					if(((a[1]+a[2])==(a[3]+a[4]))&&((a[1]+a[4])>(a[3]+a[2]))&&((a[1]+a[3])<a[2]))
						break;
				}
				if(((a[1]+a[2])==(a[3]+a[4]))&&((a[1]+a[4])>(a[3]+a[2]))&&((a[1]+a[3])<a[2]))
						break;
			}
			if(((a[1]+a[2])==(a[3]+a[4]))&&((a[1]+a[4])>(a[3]+a[2]))&&((a[1]+a[3])<a[2]))
						break;
		}
		if(((a[1]+a[2])==(a[3]+a[4]))&&((a[1]+a[4])>(a[3]+a[2]))&&((a[1]+a[3])<a[2]))
						break;
	}
	for(i=1;i<=3;i++)
		for(j=1;j<=4-i;j++)
		{
			if(a[j]<a[j+1])
			{
				k=a[j];
				a[j]=a[j+1];
				a[j+1]=k;
				o=n[j];
				n[j]=n[j+1];
				n[j+1]=o;
			}
		}
	for(i=1;i<=4;i++)
		cout<<n[i]<<" "<<a[i]*10<<endl;
	return 0;
}
int main ()
{
	int z,q,s,l;
	for(z=10;z<=50;z=z+10)
		for(q=10;q<=50;q=q+10)
			for(s=10;s<=50;s=s+10)
				for(l=10;l<=50;l=l+10)
				{
					if((z+q==s+l)+(z+l>s+q)+(z+s<q)==3)
					{
						if(z>s)
						{
							cout<<"l"<<" "<<l<<endl;
						cout<<"q"<<" "<<q<<endl;
						cout<<"z"<<" "<<z<<endl;
						cout<<"s"<<" "<<s<<endl;
						}
						else
						{
							cout<<"l"<<" "<<l<<endl;
							cout<<"q"<<" "<<q<<endl;
							cout<<"s"<<" "<<s<<endl;
							cout<<"z"<<" "<<z<<endl;

						}
					}
				}



					return 0;
				}
int main()
{
	int z,q,s,l;
	for(z=10;z<=50;z+=10)
		for(q=10;q<=50;q+=10)
		{
			if(q==z) continue;
			for(s=10;s<=50;s+=10)
			{
				if(s==q||s==z) continue;
				for(l=10;l<=50;l+=10)
				{
					if(l==s||l==q||l==z) continue;
					if(z+q==s+l&&z+l>s+q&&z+s<q)
					{
						cout<<"l"<<" "<<l<<endl;
                                                       cout<<"q"<<" "<<q<<endl;
                                                       cout<<"z"<<" "<<z<<endl;
                                                       cout<<"s"<<" "<<s<<endl;

					}
				}
			}
		}
		return 0;
}
int main()
{
	int tz[4];
	char xs1='z',xs2='q',xs3='s',xs4='l';
	tz[1]=40;
	tz[3]=50;
	tz[0]=20;
	tz[2]=10;
	printf("%c %d\n",xs4,tz[3]);
    printf("%c %d\n",xs2,tz[1]);
	printf("%c %d\n",xs1,tz[0]);
	printf("%c %d\n",xs3,tz[2]);
	return 0;
}
int main()
{
	void xu(int a[],char b[]);
	int z,q,s,l;
	int number[4];
	char ming[4]={'z','q','s','l'};
	for(z=10;z<=50;z=z+10)
	{
		for(q=10;q<=50;q=q+10)
	{
		for(s=10;s<=50;s=s+10)
	{
		for(l=10;l<=50;l=l+10)
	{
		if(z!=q&&z!=s&&z!=l&&q!=s&&q!=l&&s!=l&&z+q==s+l&&z+l>s+q&&z+s<q)
		{
			number[0]=z;
			number[1]=q;
			number[2]=s;
			number[3]=l;
		}}}}}
	xu(number,ming);
	int i;
	for(i=1;i<=4;i++)
		cout<<ming[i-1]<<' '<<number[i-1]<<endl;
	
    return 0;
}
void xu(int a[],char b[])
{
	int i,j,t;
	char c;
	for(i=1;i<=4;i++)
		for(j=1;j<=4-i;j++)
			{
				if(a[j-1]<a[j])
				{
					t=a[j];
					a[j]=a[j-1];
					a[j-1]=t;
					c=b[j];
					b[j]=b[j-1];
					b[j-1]=c;}}}
/*???????????????????????????????????????????
?????????????10???????????????50???
??????????????????????????;
 ???????????????????????????????????????????
?????????????????????????????????????????????????*/
int main()
{
    int z,q,s,l,i;
    for(z=1;z<=5;z++)
    {
        for(q=1;q<=5;q++)
        {
            for(s=1;s<=5;s++)
               {
                   for(l=1;l<=5;l++)
                   {if((z+q==s+l)&&(z+l>s+q)&&(s+z<q)&&(z!=q)&&(q!=s)&&(s!=l)&&(l!=z)&&(z!=s)&&(q!=l))
                    {    
                         int z1=z;
                         int q1=q;
                         int s1=s;
                         int l1=l; 
                        for(i=1;i<=5;i++)
                        {z1++;
                         q1++;
                         s1++;
                         l1++;
                         if(z1==6)
                         cout<<'z'<<" "<<z*10<<endl; 
                         if(q1==6)
                         cout<<'q'<<" "<<q*10<<endl; 
                         if(s1==6)
                         cout<<'s'<<" "<<s*10<<endl; 
                         if(l1==6)
                         cout<<'l'<<" "<<l*10<<endl;
                         }
                         }}}}} 
                         return 0;
                         }
void main()
{
	int n,m,i,j,p,q,k,shuru;
	int a[1000];
	for(shuru=0;shuru<1000;shuru++)
	{
	    for(i=0;i<1000;i++)
		{a[i]=0;}
		scanf("%d %d",&n,&m);	
		if(n==0 && m==0) break;
		if(n==1){printf("1\n");continue;}
		for(k=n,q=1,i=0;;i++)
		{
			p=i%n;
			if(a[p]==0)
			{
				if((q%m)!=0) {q=q+1;continue;}
				if((q%m)==0)
				{
					a[p]=1;
					q=q+1;
					k=k-1;
				}
				if(k==1)
				{
					for(j=0;j<n;j++)
					{if(a[j]==0) printf("%d\n",j+1);}
					break;
				}
			}
			if(a[p]==1) continue;
		}
	}
}
main()
{
	int a[301],n,m,i,j,k;
	for(;;)
	{
		scanf("%d %d",&n,&m);
		k=n;
		if(n>0)
		{
			for(i=1;i<=n;i++)
				a[i]=0;
			for(j=1;k>1;)
			{
				for(i=1;i<=n&&k>1;i++)
				{
					if(!a[i]&&j!=m)
						j++;
					else if(!a[i]&&j==m)
					{
						a[i]=1;
						j=1;
						k--;
					}
				}
			}
			for(i=1;i<=n;i++)
				if(!a[i])
					printf("%d\n",i);
		}
		else
			break;
	}
}
void main()
{ 
	int i,j,t,k,m,n,num[500],*p;
	for(i=0;i<100;i++)
	{
		scanf("%d %d",&n,&m);
		if(n==0&&m==0) break;
		else
		{
			p=num;
			for(j=0;j<n;j++)
				*(p+j)=j+1;
			j=0;
			k=0;
			t=0;
			while(t<n-1)
			{
				if(*(p+j)!=0)
					k++;
				if(k==m)
				{
					*(p+j)=0;
					k=0;
					t++;
				}
				j++;
				if(j==n) j=0;
			}
			while(*p==0) p++;
			printf("%d\n",*p);
		}
	}
}
void main()
{
	int n,m,a[99],b[99],i=0,j,k,s,c[310],x,remain;
	scanf("%d %d",&a[0],&b[0]);
	while(a[i]!=0&&b[i]!=0)
	{
		i++;
		scanf("%d %d",&a[i],&b[i]);
	}
	s=i;
	for(i=0;i<s;i++)
	{
		n=a[i],m=b[i],remain=0;
		for(j=1;j<=n;j++) c[j]=j;
		for(j=0;j<a[i]-1;j++)
		{
			if((remain+m)%n==0) {n--;remain=0;}
			else
			{
				for(k=(remain+m)%n;k<n;k++)
					c[k]=c[k+1];
				remain=(remain+m)%n-1;
				n--;
			}
		}
		printf("%d\n",c[1]);
	}
}
int main(){
    int n,m,i,t,k;
	int a[300],b[300],c[100];
    k=0;
    while (1){
	scanf("%d%d",&n,&m);
    t=m;
    if ((m==0)&&(n==0)) {
        break;
    }
    else{
   	for (i=0;i<n;i++){
		a[i]=i+1;
	}
		while (n>1){
		while (m>n){
			m=m-n;
		}
	    for (i=m;i<n;i++){
		 b[i-m]=a[i];
		}
	    for (i=0;i<m-1;i++){
		 b[n-m+i]=a[i];
		}
		for (i=m;i<n;i++){
		 a[i-m]=b[i-m];
		}
		for (i=0;i<m-1;i++){
		 a[n-m+i]=b[n-m+i];
		}
    	n=n-1;
        m=t;
		}
        c[k]=a[0];k=k+1;
    }
	}
    for (i=0;i<k;i++)
	printf("%d\n",c[i]);
return 0;
}
struct node{
	int a;
	struct node *next;
};
void main()
{
	int i,j,m,n;
	struct node *head,*p1,*p2;
	for(i=1;;i++)
	{
		scanf("%d%d",&n,&m);
		if(n==0)
			break;
		p1=(struct node*)malloc(sizeof(struct node));
		p1->a=1;
		head=p1;
		for(j=2;j<=n;j++)
		{
			p2=(struct node*)malloc(sizeof(struct node));
			p2->a=j;
			p1->next=p2;
			p1=p2;
		}
		p1->next=head;
		while(head->next!=head)
		{
			for(i=1;i<m;i++)
			{
				p1=head;
				head=head->next;
			}
			p1->next=head->next;
			head=head->next;
		}
		printf("%d\n",head->a);
	}
}
int main()
{
	int n,m,i,j,a[301],x;
	while(cin>>n>>m,(n!=0)&&(m!=0))//????????//
	{
		a[0]=0;
		for(i=1;i<=n;i++)//???????????????1//
			a[i]=1;
		for(x=1,i=0;i<n-1;i++)//????n-1????????n-1?//
		{
			for(j=0;j<m;x++)
			{
				if(x>n)
					x=x%n;//??x??n//
				if(a[x]==1)
					j++;//???????1???j?1.j??????????????m?????????//
			}
			a[x-1]=0;//????????//
		}
		for(i=1;i<=n;i++)
			if(a[i]==1)
				cout<<i<<endl;//??????//
	}
	return 0;}