semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
/*
 * 1.cpp
 *???  ????????
 *  Created on: 2011-11-14
 *      Author: wangwenxia1963
 */
int main()
{
	int x,y,i,j;
	cin>>x>>y;
	for(i=1;x/i>0;i=i*2)
	;
	for(j=1;y/j>0;j=j*2)
	;
	i=i/2;j=j/2;//i,j????2?????
	if(i>j)
		x=x*j/i;
	else y=y*i/j;
	while(x!=y)
		{
		x=x/2;
		y=y/2;
		}
	cout<<x;






}
int main()
{
	int m,n;
	scanf("%d %d",&m,&n);
	int word1[500],word2[500];
	int i,j,num,log1,log2;
	word1[0]=m;
	word2[0]=n;
	i=j=1;
	while(m!=1)
	{
		word1[i]=m/2;
		i+=1;
		m=m/2;
		//printf(" %d %d ",word1[i],m);
	}
	//printf("%d",m);
	log1=i-1;
	while(n!=1)
	{
		word2[j]=n/2;
		j+=1;
		n=n/2;
		//printf(" %d  %d ",word2[i],n);
	}
	log2=j-1;
	int word;
	word=0;
	for(i=0;i<=log1;i++)
	{
		for(j=0;j<=log2;j++)
		{
			if(word1[i]==word2[j])
			{
				//printf("\n");
				printf("%d",word1[i]);
				//printf("\n");
				word++;
				break;
			}
		}
		if(word!=0)
		    break;
	}
	return 0;
}
void kk(int n,int a[])
{
	int i=0;
	while(n!=0)
	{
		a[i]=n;
		n/=2;
		i++;
	}
}
int gg(int n)
{
	int i=0;
	while(n!=0)
	{
		n=n/2;
		i++;
	}
	return(i);
}

void main()
{
	int a,b,c[20],d[20],e,f,i;
	scanf("%d %d",&a,&b);
	e=gg(a);
	f=gg(b);
	kk(a,c);
	kk(b,d);
	for(i=1;;i++)
	{
		if(c[e-i]!=d[f-i])
		{
			printf("%d",c[e-i+1]);
			break;
		}
	}
}
int main(int argc, char* argv[])
{
	int x[10]={0},y[10]={0},i,j,indicator=0;
	scanf("%d%d",&x[0],&y[0]);
	for(i=0;;i++){
		if(x[i]==1)break;
		if(x[i]%2==0) x[i+1]=x[i]/2;
		else x[i+1]=(x[i]-1)/2;
	}
	for(i=0;;i++){
		if(y[i]==1)break;
		if(y[i]%2==0) y[i+1]=y[i]/2;
		else y[i+1]=(y[i]-1)/2;
	}
	for(i=0;i<10;i++){
		if(x[i]!=0)
		for(j=0;j<10;j++){
			if((y[j]!=0)&&(x[i]==y[j])){
				printf("\n%d",x[i]);
				indicator=1;
			}
			if(indicator==1)break;
		}
		if(indicator==1)break;
	}
	return 0;
}
void tree(int p,int k,int c[])
{
	c[k]=p;
	if(c[k]==1)
		return;
	else
	{
		tree(c[k]/2,k+1,c);
	}
}

void main()
{
	int x,y,i,j,a[12]={0},b[12]={0};
	scanf("%d%d",&x,&y);
	tree(x,0,a);
	tree(y,0,b);
	for(i=j=0;;)
	{
		if(a[i]>b[j])
		{
			i++;
			continue;
		}
		if(b[j]>a[i])
		{
			j++;
			continue;
		}
		if(a[i]==b[j])
			break;
	}
	printf("%d\n",a[i]);
}
void main()
{
	int x,y;int a[500],b[500],c[500];
	int i,j,t=0;int jishuqi1=0,jishuqi2=0;
	scanf("%d%d",&x,&y);
	a[0]=x;b[0]=y;
	for(i=0;i<=488;i++)
	{
		if(a[i]>1)
		{a[i+1]=a[i]/2;
		jishuqi1=jishuqi1+1;}
		else if(a[i]<=1)
			break;
	}
	for(j=0;j<=488;j++)
	{
		if(b[j]>1)
		{b[j+1]=b[j]/2;
		jishuqi2=jishuqi2+1;}
		else if(b[j]<=1)
			break;
	}
	for(i=0;i<=jishuqi1;i++)
		for(j=0;j<=jishuqi2;j++)
		{
			if(a[i]==b[j])
			{
				c[t]=a[i];
			    t=t+1;
			}
			else if(a[i]!=b[j])
			continue;
		}
		printf("%d\n",c[0]);
}
void main()
{
	int n;
	int i,j;
	int a1,a2;
	scanf("%d",&n);
	int a[100];
	a[0]=n;


	for(i=0;;i++)
	{if (a[i]==1) break;
	//printf("%d",i);
	//printf(" %d\n",a[i]);
	a[i+1]=a[i]/2;
	}

	int m;
	scanf("%d",&m);
	int b[100];
	b[0]=m;


	for(j=0;;j++)
	{if (b[j]==1) break;
	//printf("%d",i);
	//printf(" %d\n",b[i]);
	b[j+1]=b[j]/2;
	}


	//printf("\n\n\n\n");
	//for(i=0;i<=99;i++)
	//printf("%d %d\n",a[i],b[i]);

	int flag;
	flag=0;
	for(a1=0;a1<=i;a1++)
		if (flag==0)
		for(a2=0;a2<=j;a2++)
			if (flag==0)
			if(a[a1]==b[a2]) {printf("%d\n",a[a1]); flag=1;}
	
}
int main()
{
  int x,y;
  cin>>x>>y;

  int tree(int,int);
  cout<<tree(x,y);

}

int tree(int x,int y)
{
	while(x!=y)

	{
	      if(x>y)
			  x=x/2;
		  else
			  y=y/2;
	}

	return x;

}
void main()
{
	int a[1000],b[1000],i=0,j=0,n=0,m=0;
	
	scanf("%d%d",&a[0],&b[0]);
		while(*(a+i)!=1)
		{
			if(*(a+i)%2==0)
			{	*(a+i+1)=*(a+i)/2;
			i=i+1;}
			else
			{
                 *(a+i+1)=(*(a+i)-1)/2;
				 i=i+1;
			}

		}
			while(*(b+j)!=1)
		{
			if(*(b+j)%2==0)
			{	*(b+j+1)=*(b+j)/2;
			j=j+1;}
			else
			{
                 *(b+j+1)=(*(b+j)-1)/2;
				 j=j+1;
			}

		}
			for(n=0;n<=i;n++)
			{
			while(m!=j+1)
				{
					if (*(b+m)!=*(a+n))
					{m=m+1;
					}
					else{
					goto loop;
					}
				}
			
				
				m=0;
			}
loop:printf("%d",*(b+m));
}
void main()
{
	int i,x,y,m,n,c;
	int a[12],b[12];
	scanf("%d %d",&x,&y);
    for(i=1,a[0]=x,b[0]=y;i<=11;i++)
	{    
		
		a[i]=a[i-1]/2;
		
		b[i]=b[i-1]/2;
	
	
	}
	for(m=0;m<=11;m++)
	{
		for(n=0;n<=11;n++)
		{
			if(a[m]==b[n])
			{
				printf("%d",a[m]);
				goto loop;
			}
		}
             
			
	}
loop:c=0;
}
main()
{
	int x,y,a[500],b[500],i=1,j,m=0;
	scanf("%d%d",&x,&y);
    a[0]=x; b[0]=y;
	while(x!=0)
	{
		a[i]=x/2;
		x=x/2;
		i++;
	}
	i=1;
	while(y!=0)
	{
		b[i]=y/2;
		y=y/2;
		i++;
	}
	for(i=0;a[i]!=0;i++)
	{
		for(j=0;b[j]!=0;j++)
		{
			if(a[i]==b[j])
			{
				m=i;
				break;
			}
		}
		if(m==0&&a[0]==b[0]) break;
		else if(m!=0)
			break;
	}
	printf("%d\n", a[m]);
}
void half(int x,int y)
{
	if(x==y)
		cout<<x<<endl;
	else if(x>y)
	{
		x=x/2;
		half(x,y);
	}
	else
	{
		y=y/2;
		half(x,y);
	}
}
int main()
{
	int x,y;
	cin>>x>>y;
	half(x,y);
	return 0;
}
int f(int x,int y);
int main()
{
	int x,y;
	cin>>x>>y;
	cout<<f(x,y);
}
int f(int x,int y)
{
	if(x==y) return x;
	if(x>y)
	{
		x=x/2;
		return f(x,y);
	}
		if(x<y)
		{
			y=y/2;
			return f(x,y);
		}
}
int two(int n)
{
	int m=1,i;
	
	for(i=0;i<=n;i++)
	{
		if(i==0)
		{
			m=1;
		}
		else
		m=m*2;
	}
	return(m);
}


int main()
{
	int two(int n);
    int zhao(int x,int y,int row1,int flag);
	int x,y,i,row1,row2,flag=0,t;
	scanf("%d %d",&x,&y);
	for(i=0;i<=10;i++)
	{
		if(x==two(i))
		{
			row1=i;
		
		}
		else
		{
			if(x>two(i)&&x<two(i+1))
			{
				row1=i;
				
			}
		}
	}
	
	for(i=0;i<=10;i++)
	{
		if(y==two(i))
		{
			row2=i;
		
		}
		else
		{
			if(y>two(i)&&y<two(i+1))
			{
				row2=i;
			
			}
		}
	}
    if(x==y) printf("%d",x);
	else if(x>y)
	{
	
		t=zhao(x,y,row1,flag);
			if(t==0)
			{
				for(i=1;i<=row2;i++)
				{
				if(y%2==0)
				{
					y=y/2;
				}
				else y=(y-1)/2;
			
				t=zhao(x,y,row1,flag);
				if(t==1) 
				{
					break;
				}
			}
			}
			
		
	}
	else if(y>x)
	{
		t=zhao(y,x,row2,flag);
			if(flag==0)
			{
				for(i=1;i<=row1;i++)
				{
				if(x%2==0)
				{
					x=x/2;
				}
				else x=(x-1)/2;
				t=zhao(y,x,row2,flag);
				if(t==1)
				break;
			}
			}
			
		
	}


	


	return 0;
}

int zhao(int x,int y,int row1,int flag)
{
	int i;
	for(i=1;i<=row1;i++)
		{
			if(x%2==0)
			{
				x=x/2;
			}
			else x=(x-1)/2;
			if(x==y) 
			{
				printf("%d",x);
				flag=1;
				break;
				
			}
			else continue;
	}
	return (flag);
}
/*
 *  ???.cpp
 *  Created on: 2012-11-19
 *  Author:???
 */
int f(int a, int b) {//?????a?b????????????
	if (a == b)//?a??b????a??b?
		return a;
	if (a > b) {//?a??b,???a??????b????
		return f(a % 2 == 0 ? a / 2 : (a - 1) / 2, b);
	} else {//?b??a,???b??????b????
		return f(a, b % 2 == 0 ? b / 2 : (b - 1) / 2);
	}
}
int main() {
	int a, b;
	cin >> a >> b;//?????
	cout << f(a, b) << endl;//????????
	return 0;
}
void fuck(int x,int y){
	int temp;
	if(x==y)
		cout<<x;
	else{
		if(y<x) {temp=x;x=y;y=temp;}
	fuck(x,y/2);
	}
}

int main(){
	int x,y;
	cin>>x>>y;
	fuck(x,y);
	return 0;
}
int main()
{
	int exist=0,addressx[10]={0},addressy[10]={0},h,k,x,y,i=0,j=0;
	scanf("%d%d",&x,&y);
	while (x>=1)
	{
      addressx[i]=x;
	  
	  x=x/2;
	  i+=1;
	}

	while (y>=1)
	{
		addressy[j]=y;
	
		y=y/2;
		j+=1;
	}

	for (h=0;h<=i-1;h++)
	{
		for (k=0;k<=j-1;k++)
		{
			if (addressx[h]==addressy[k])
			{
				printf("%d",addressx[h]);
				exist=1;
				break;
			}
		}
		if(exist==1)
			break;

	}
}
int main()
{
	int n,m;
	cin>>n>>m;
	int f(int,int);
	cout<<f(n,m)<<endl;
	return 0;
}
int f(int a,int b)
{
	int cr;
	if(a==b) cr=a;
	else if(a>b) cr=f(a/2,b);
	else cr=f(a,b/2);
	return cr;
}
int main()
{
	int c(int x,int y);
	int x,y;//???x?y
	cin>>x>>y;
	cout<<c(x,y)<<endl;
return 0;
}

int c(int x,int y)//?????
{
	int z;
	if(x==y)//???????
		z=x;
	if(x>y)
		z=c(x/2,y);//???????
	if(y>x)
		z=c(x,y/2);
	return z;
}
int main(int argc, char* argv[])
{
	int t,x,y,a;
	scanf("%d %d",&x,&y);
	if(x==1||y==1) printf("1");
	else if(x==y) printf("%d",x);
	else if(x!=y)
	{
		if(y>x)
		{
			a=x;
			x=y;
			y=a;
		}
			do
			{
				x/=2;
				if(x<y)
				{
					t=x;
					x=y;
					y=t;
				}
			}while(x!=y);
	
		printf("%d",x);
	}



	return 0;
}
int x[100]={0},y[100]={0};

int meet(int a, int b)
{
	int i=1,j=1,roadmeet=1;
	x[0]=a;
	y[0]=b;
	for (;a!=1;a=a/2)
		x[i++]=a/2;
	for (;b!=1;b=b/2)
		y[j++]=b/2;
	for (;i>=0,j>=0;i--,j--)
		if (x[i]==y[j])
			roadmeet=x[i];
	return roadmeet;
}

int main( )
{
	int X,Y;
	cin>>X>>Y;
	cout<<meet(X,Y);
	return 0;
}
main()
{
     int xx,yy;
     scanf("%d %d",&xx,&yy);
     int x[10],y[10];
     x[0]=xx;
     y[0]=yy;
     int i,j;
     for(i=1;x[i-1]!=1;i++)
     {    
         int q=x[i-1]/2; 
         x[i]=q;
         } 
     i--;
     for(j=1;y[j-1]!=1;j++)
     {    int p=y[j-1]/2; 
          y[j]=p;}
     j--;
     int bl=0;
     //for(int a=0;a<=i;a++) printf("%d\n",x[a]);
     //for(int b=0;b<=i;b++) printf("%d\n",y[b]);
     for(int a=0;a<=i;a++)
     {
            if(bl==1) break;
            for(int b=0;b<=j;b++)
            if(x[a]==y[b]) 
            {
               printf("%d",x[a]);
               bl=1;
               break;              
            }
     }
     getchar();
     getchar();
      
      
}
int main()
{
    int x,y;
    cin>>x>>y;int t1=x,t2=y;
    int xx[12],yy[12];int k=0,kk=0;
    while(x>0)
    {
              xx[k++]=x;
              x=x/2;
    }
    while(y>0)
    {
              yy[kk++]=y;
              y=y/2;
    }
    int ans=0;
    for(int i=0;i<k;i++)
    {
            for(int j=0;j<kk;j++)
             if(xx[i]==yy[j])
              ans=xx[i];
              if(ans!=0)
              break;     
    }
    if(t1==t2) ans=t1;
    cout<<ans<<endl;
    return 0;
}
void main()
{
	int i,j,x[10],y[10],a,b;
	scanf("%d%d",&a,&b);
    for (i=9;;i--)
	{
		x[i]=a;a/=2;
		if (x[i]==1) break;
	}
	for (j=i;j<10;j++) x[j-i]=x[j];
	for (i=9;;i--)
	{
		y[i]=b;b/=2;
		if (y[i]==1) break;
	}
	for (j=i;j<10;j++) y[j-i]=y[j];
	for (i=0;;i++)
	{
		if (x[i]!=y[i]) 
		{
			printf("%d",x[i-1]);
			break;
		}
	}
}
int main()
{       
	int x,y,t;
	scanf("%d %d",&x,&y);
	if(x==1||y==1) printf("1");
	if(x!=1&&y!=1&&x==y) printf("%d",x);
	if(x!=1&&y!=1&&x!=y){
	do{
	    if(x>y){
           t=x;
		   x=y;
		   y=t;
		}
	    y=y/2;
	}
	while(x!=y);
	printf("%d",y);
	}
	return 0;
}
int main(){
  int i,j;
  for (cin>>i>>j;i!=j;){
    while (i>j) i/=2;
    while (j>i) j/=2;
  }
  cout<<j<<endl;
}
int main()
{
	int a[100],b[100],x,y;
	int i,j;
	for(i=0;i<100;i++)
	{
		a[i]=0;
		b[i]=0;
	}
	i=0;
	cin>>x>>y;
	while(x>=1)
	{
		a[i]=x;
		if(x%2==0)
		{
			x=x/2;
		}
		else
		{
			x=(x-1)/2;
		}
		i=i+1;
	}
	j=0;
	while(y>=1)
	{
		b[j]=y;
		if(y%2==0)
		{
			y=y/2;
		}
		else
		{
			y=(y-1)/2;
		}
		j=j+1;
	}
	while(j>0&&i>0)
	{
		if(b[j-1]!=a[i-1])
		{
			cout<<a[i]<<endl;
			break;
		}
		else if(i==1)
		{
			cout<<a[0]<<endl;
		}
		else if(j==1)
		{
			cout<<b[0]<<endl;
		}
		j=j-1;
		i=i-1;
	}
	return 0;
}
void main()
{
	int x,y;
	int i,j,n,m;
	int rx[1000]={0},ry[1000]={0};

	scanf("%d %d",&x,&y);

	rx[0]=x;
	ry[0]=y;
	for(i=1;x!=0;i++)
	{
		x=x/2;
        rx[i]=x;
	}
	m=i-1;
	for(j=1;y!=0;j++)	
	{
		y=y/2;
	    ry[j]=y;
	}
	n=j-1;
	for(i=m-1,j=n-1;i>=0&&j>=0;i--,j--)
	{
		if(rx[i]!=ry[j])
			break;
	}
	
	printf("%d",rx[i+1]);
}
/*
 * 1.cpp
 *
 *  Created on: 2011-11-14
 *      Author: wangwenxia1963
 */
int main()
{
	int x,y,a,b,i,j;
	cin>>x>>y;
	for(i=1;x/i>0;i=i*2)
		a=x%i;
	for(j=1;y/j>0;j=j*2)
		b=y%j;
	i=i/2;j=j/2;
	if(i>j)
		x=x*j/i;
	else y=y*i/j;
	while(x!=y)
		{
		x=x/2;
		y=y/2;
		}
	cout<<x;






}
void main()
{
    int x,y;
	scanf("%d %d",&x,&y);
    while(x!=y)
	{
	if(x<y)
    y=y/2;
	else if(x>y)
	x=x/2;
	}
	printf("%d\n",x);
}
//*********************
//???***************
int main()
{
	int x,y;
	int ax[1000],ay[1000];
	cin>>x>>y;
	if(x==1||y==1)
		cout<<"1"<<endl;
	else
	{
	if(x>1)
	{
		ax[0]=x;
		if(x%2==0)
			ax[1]=x/2;
		else 
			ax[1]=(x-1)/2;
		for(int i=2;;i++)
		{
			if(ax[i-1]%2==0)
				ax[i]=ax[i-1]/2;
			if(ax[i-1]%2!=0)
				ax[i]=(ax[i-1]-1)/2;
			if(ax[i-1]==1)
				break;
				
		}
	}
	int temp;
	if(y>1)
	{
		ay[0]=y;
		if(y%2==0)
			ay[1]=y/2;
		else 
			ay[1]=(y-1)/2;
		for(int i=2;;i++)
		{
			if(ay[i-1]%2==0)
				ay[i]=ay[i-1]/2;
			if(ay[i-1]%2!=0)
				ay[i]=(ay[i-1]-1)/2;
			if(ay[i-1]==1)
				{ temp=i;
			break;}
		}
	}
	int counter=0;
	for(int l=0;;l++)
	{
		for(int k=0;k<=temp;k++)
		{
			if(ax[l]==ay[k])
				{
					cout<<ax[l]<<endl;
					counter=1;
					break;
				}
		}
		if(counter==1)
			break;
	}
	}
	return 0;
}
int main(){
	int n,i,e,j,kn,ki,k,l;
	scanf("%d %d",&n,&i);
	if(n<i)
	{
	e=n;
	n=i;
	i=e;
	}
	l=1;
	for (k=1;k<33;k++){
	l=l*2;
	if(l>n){
		kn=k;
		break;
	}
	}
	l=1;
	for (k=1;k<33;k++){
	l=l*2;
	if(l>i){
		ki=k;
		break;
	}
	}
	for(k=0;k<kn-ki;k++){
		n/=2;
	}
	do{
		if(n==i){
			printf("%d",n);
			return 0;
		}
		n/=2;
		i/=2;
	}
		while(1);
	
	}
int comp(const void *c,const void *d)
{
	return *(int *)c-*(int *)d;
}
int main(void)
{
	int i=0,j=0,k,x,y,x1,y1;
	int a[1001];
	int b[1001];
	scanf("%d%d",&x,&y);
	x1=x;y1=y;
	while(x>=1)
	{
		a[i++]=x;
		x/=2;
	}
	while(y>=1)
	{
		b[j++]=y;
		y/=2;
	}
	qsort(a,i,sizeof(a[0]),comp);
	qsort(b,j,sizeof(b[0]),comp);
	for(i=0;;i++)
	{
		if(a[i]==b[i])
		    k=a[i];
		else
		    break;
	}
	if(x1==y1)
		printf("%d",x1);
	else
		printf("%d",k);
	return 0;
}
int main()
{
	int x,y,sx=0,sy=0,an=0;
	cin>>x>>y;
	int jx[10],jy[10];
	jx[0]=x,jy[0]=y;sx++;
	for(int i=1;jx[i-1]>=2;i++){
		jx[i]=jx[i-1]/2;
		sx++;
	}
	for(int i=1;jy[i-1]>=2;i++){
		jy[i]=jy[i-1]/2;
		sy++;
	}
	for(int i=0;i<=sx;i++){
		if(an!=0){cout<<an;
		          break;	}
		for(int j=0;j<=sy;j++){
			if(jx[i]==jy[j]){
				an=jx[i];
				break;	}
		}
	}
	return 0;
}
void main()
{
	int m,n,j,i;
	scanf("%d%d",&m,&n);
	if(m==n)
		printf("%d",m);
	else if(m==1||n==1)
		printf("1");
	else
	{
	   for(i=0;m>=1;i++)
	   {
		   for(j=0;n>m;j++)
		   {
			   n=n/2;
		   }
           if(n!=m)
		   {
			   m=m/2;
	   		  continue;
		   }
		   if(n==m)
    		   break;
	   }
	   printf("%d\n",m);
	 }
}
void change(int a[10000])
{
	int i;
	for(i=1;i<10000&&a[i-1]!=1;i++)
	{
		a[i]=(int)(a[i-1]/2);
	}
}
main()
{
	int i,j,x,y,a[10],b[10];
	scanf("%d%d",&x,&y);
	a[0]=x;b[0]=y;
	change(a);change(b);
	for(i=0;i<10;i++)
	{
		for(j=0;j<10;j++)
		{if(a[i]==b[j]){printf("%d\n",a[i]);return 0;}
		}
	}
}
void main()
{
    int s[11],t[11];
	int m,n,j,k,i,l,a,b,sign=0;
	scanf("%d %d",&m,&n);
	s[0]=m;t[0]=n;
	for(k=m/2,i=1;k!=0;i++)
	{
		s[i]=k;
		k=k/2;
        
	}
	for(j=n/2,l=1;j!=0;l++)
	{
		t[l]=j;
		j=j/2;
        
	}
	for(a=0;a<i;a++)
	{
		for(b=0;b<l;b++)
		{
			if(s[a]==t[b]) {sign=1; printf("%d\n",s[a]); break;}
		}
		if(sign==1) break;
	}
}
//*****************************************************************************
//*                                                                           *
//*              ??????       ???        1300012743                  *
//*                                                                           *
//*****************************************************************************

//                          ?? - ???



int main(){
	unsigned int x,y;
	cin>>x>>y;
	while(x != y){
		if(x > y)
			x /= 2;
		else
			y /= 2;
	}
	cout<<x<<endl;
	return 0;
}
void main()
{
	int a,b,i,j,n,m,t=0,r=0,s=0;
	int c[1000]={0};
    int d[1000]={0};
	scanf("%d %d",&a,&b);
	for(i=0;;i++)
	{r++;
		c[i]=a;
		a=a/2;
		if(c[i]==1) 
			break;
		
	}
    for(j=0;;j++)
	{s++;
		d[j]=b;
		b=b/2;
		if(d[j]==1) 
			break;
		
	}
	for(i=0;i<r;i++)
	{
		for(j=0;j<s;j++)
		{
		if(c[i]==d[j]) 
		{	t=c[i];			
		goto print;
		break;
		}
		}
	}
print:	printf("%d\n",t);
}
int main()
{
	int a,b,i,t;
	scanf("%d%d",&a,&b);
	if(a==b)printf("%d",a);
	else {
		if(a<b){
			t=a;
			a=b;
			b=t;
		}
		while(a/2!=b){
			a=a/2;
			if(a/2<b){
				t=a;
				a=b;
				b=t;
		}
		}
	printf("%d",b);
	}
}
int answer(int a , int b)
{
	if(a==b)
	{
		return a;
	}
	else if(a>b)
	{
		return answer(a/2,b);
	}
	else
	{
		return answer(a,b/2);
	}
}
int main()
{
	int x,y;
	cin>>x>>y;
	cout<<answer(x,y)<<endl;
	return 0;
}
/*
 *???? ???.cpp
 *  ????: 2010-11-24
 *    ??????
 */

int main(){
	double a,b;
	double ca,cb;
	cin>>a>>b;
	for(ca=0;;ca++){
		if(a<pow(2.0,ca+1.0))
			break;
	}
	for(cb=0;;cb++){
		if(b<pow(2.0,cb+1.0))
			break;
	}
	if(ca>=cb){
		for(int i=cb;i<ca;i++){
			if((int)a%2==0)
				a=a/2;
			else a=(a-1)/2;
		}

		for(int i=cb;i>=0;i--){
			if(a==b)
				{cout<<a;
				break;
				}
			else{if((int)a%2==0)
				a=a/2;
			else a=(a-1)/2;
			if((int)b%2==0)
				b=b/2;
			else b=(b-1)/2;

			}
		}
	}
	else {for(int i=ca;i<cb;i++){
		if((int)b%2==0)
			b=b/2;
		else b=(b-1)/2;
	}

	for(int i=ca;i>=0;i--){
		if(a==b)
			{cout<<a;
			break;
			}
		else{if((int)a%2==0)
			a=a/2;
		else a=(a-1)/2;
		if((int)b%2==0)
			b=b/2;
		else b=(b-1)/2;

		}
	}
	}
	return 0;
}
int a[10],b[10],la=0,lb=0;
int main(){
	int i,j,x;
	scanf("%d",&x);
	while (x>0) {a[la++]=x%2;x/=2;}
	scanf("%d",&x);
	while (x>0) {b[lb++]=x%2;x/=2;}
	for (i=la-1,j=lb-1,x=0;i>=0&&j>=0&&a[i]==b[j];i--,j--) x=x*2+a[i];
	printf("%d",x);
	return 0;
}
int main()
{
	int x,y,nx,ny,i,j,k,ax[20]={0},ay[20]={0};
	cin>>x>>y;
	if(x==y)
	{
		cout<<x;
		return 0;
	}
	nx=1;
	while(x>0)
	{
		ax[nx]=x;
		x/=2;
		nx++;
	}
	nx--;
	ny=1;
	while(y>0)
	{
		ay[ny]=y;
		y/=2;
		ny++;
	}
	ny--;
	for(i=nx+ny; ;i--)
		if(ax[i-ny]!=ay[i-nx])
		{
			cout<<ax[i+1-ny];
			return 0;
		}
}
//
//  main.cpp
//  ???
//
//  Created by ???? on 13-11-22.
//  Copyright (c) 2013? ????. All rights reserved.
//


int f(int x)
{
    return x/2;
}


int main()
{
    int a,b;
    cin>>a>>b;
    while(1)
    {
        if(a>b)a=f(a);
        else if(b>a)b=f(b);
        else if(a==b){cout<<a<<endl;break;}
    }
    
    return 0;
}
int main()
{
	int x,y,a[10],b[10],i,j,max;
	cin>>x>>y;
	a[0]=x;
	b[0]=y;
	for(i=1;i<10;i++)
		{
			a[i]=a[i-1]/2;
			b[i]=b[i-1]/2;
		}
	for(i=9;i>=0;i--)
		for(j=0;j<10;j++)
		{
			if(a[i]==b[j])
				max=a[i];
		}
		cout<<max<<endl;
	return 0;
}
int main()
{
	int m,n;
	int i,j,k;
	scanf("%d %d",&m,&n);
	int a[15]={m},b[15]={n};
	for(i=0;a[i]!=1;i++)
	{
		a[i+1]=a[i]/2;
	}
	for(j=0;b[j]!=1;j++)
	{
		b[j+1]=b[j]/2;
	}
	for(k=0;i-k>=0&&j-k>=0;k++)
	{
		if(a[i-k]!=b[j-k])
		{
			break;
		}
	}
	printf("%d",a[i-k+1]);
}
int main(int argc, char* argv[])
{
	int x,y,z;
	scanf("%d %d",&x,&y);
	while(x!=y)
	{
		if(x<y)
		{
			z=x;
			x=y;
			y=z;
		}
		x/=2;
		if(x==y)
		{
			break;
		}
	}
	printf("%d",x);
	return 0;
}
void check(int x,int y)
{
	if(x==y)
		printf("%d",x);
	else
	{
		if(x>y&&x/2>=y/2)
			check(x/2,y);
		if(x<y&&x/2<=y/2)
			check(x,y/2);
	}
}
main()
{
	int x,y;
	scanf("%d %d",&x,&y);
	check(x,y);
}
void main()
{
	int x,y;
	int m=0,n=0;
	int i;
	int a[20]={0},b[20]={0};
	int xi=0;
	scanf("%d%d",&x,&y);

//*????//

	a[0]=x;
	b[0]=y;
	for(i=1;i<10;i++)
	{
		a[i]=x/2;
		b[i]=y/2;
		x=x/2;
		y=y/2;
	}
	for(i=0;a[i]!=0;i++)
		m++;
	for(i=0;b[i]!=0;i++)
		n++;

	for(i=1;a[m-i]==b[n-i];i++)
		xi=a[m-i];

	printf("%d\n",xi);
}
int erchashu(int x,int y)
{
	int i,j,a[10],b[10],c,d,shu=0;
	a[0]=x;
	b[0]=y;
	if(x==1)
		shu=1;
	else if(y==1)
		shu=1;
	else{
	for(i=1;i<10;i++)
	{
		if(x%2==0)
		{
			a[i]=x/2;
			x=a[i];
		}
		else
		{
			a[i]=(x-1)/2;
			x=a[i];
		}
		if(x==1)
		{
			c=i;
			break;
		}
	}
	for(i=1;i<10;i++)
	{
		if(y%2==0)
		{
			b[i]=y/2;
			y=b[i];
		}
		else
		{
			b[i]=(y-1)/2;
			y=b[i];
		}
		if(y==1)
		{
			d=i;
			break;
		}
	}
	for(i=0;i<=c;i++)
	{
		for(j=0;j<=d;j++)
		{
			if(a[i]==b[j])
			{
				shu=a[i];
				break;
			}
			else if(a[i]>b[j])
			{
				break;
			}
			else
			{
				continue;
			}
		}
		if(shu==0)
			continue;
		else
			break;
	}
	}
	return shu;
}
int main()
{
	int x,y;
	scanf("%d%d",&x,&y);
	printf("%d\n",erchashu(x,y));
}
int main ()
{
  int a,b;
  scanf("%d%d",&a,&b);
  do
  {
     if(a==b)
      {
          break;
      } 
      if(a>b)
      {
          a=a/2;
      }
      else
       {
          b=b/2;
      }
      
  }
  while(1);
  printf("%d",a);
  return 0;
}
void main()
{
  int i,m,n,temp;
  scanf("%d%d",&m,&n);
  if(m<n)
  {
    temp=m;
	m=n;
	n=temp;
  }
  if(m==n)  printf("%d\n",m);
  else
  {
  for(;;)
  {
    if(m/2==n)  
	{
		printf("%d\n",n);
		break;
	}
	else 
	{
	  if(m/2>n)  m/=2;
	  else
	  {
	    temp=n;
		n=m/2;
		m=temp;
	  }
	}
  }
  }
}
void main()
{
	int n1,n2,n1_[100],n2_[100],i=0,j=0;
	scanf("%d%d",&n1,&n2);
	do
	{
		n1_[i]=n1;
		n1=n1/2;
		i++;
	}while(n1>=1);
	n1_[i]=1;
	do
	{
		n2_[j]=n2;
		n2=n2/2;
		j++;
	}while(n2>=1);
	n2_[j]=1;
	for(;;i--,j--)
	{
		if(n1_[i]!=n2_[j])
			break;
	}
	printf("%d",n1_[i+1]);
}
int main() 
{int f(int n);
 int a,b,j,i;
 int s1[100],s2[100],s3[100];
 scanf("%d%d",&a,&b);
  
 for(s1[0]=a,i=0;s1[i]!=1;i++)
    s1[i+1]=f(s1[i]);
 for(j=i;j>=0;j--)
 {s2[i-j]=s1[j];s1[j]=0;}

 for(s1[0]=b,i=0;s1[i]!=1;i++)
    s1[i+1]=f(s1[i]);
 for(j=i;j>=0;j--)
 {s3[i-j]=s1[j];s1[j]=0;}

 for(i=0;;i++)
	 if(s2[i]!=s3[i]) { printf("%d\n",s2[i-1]);break;}
 return 0;
}
int f(int n)
{int i,t=1,m;
   for(i=0;;i++)
   {t=2*t;
   if(t>n)  {t=t/2;break;}
   }
  m=t/2+(n-t)/2;
  return m;
}
int shulie(int a[]){
	int i,x1=0;
	for(i=9;i>=0;i--){
        a[i]=a[i+1]/2;
		if(a[i]!=0) x1=i;
	}
	return x1;
}

void main()
{
	int x[11]={0},y[11]={0},i=0,x1,y1;
	scanf("%d%d",&x[10],&y[10]);
	if(x[10]==1 || y[10]==1) printf("1");
    else
	{
		{x1=shulie(x);
	     y1=shulie(y);
	     for(i=0;i<11;i++){
		      if(x[x1]!=y[y1]) {printf("%d",x[x1-1]);break;}
		      else {x1++;
		            y1++;
			        continue;}
	}
	}
	}
}
int main() {
	int xpath[100],ypath[100];
		int xi=0,yi=0;
		cin>>xpath[0]>>ypath[0];
		while(xpath[xi]!=1)
		{
			xpath[xi+1]=xpath[xi]/2;
			xi++;
		}

		while(ypath[yi]!=1)
		{
			ypath[yi+1]=ypath[yi]/2;
			yi++;
		}
		while(xi>=0&&yi>=0)
		{
			if(xpath[xi]!=ypath[yi])
			{
				cout<<xpath[xi+1]<<endl;
				return 0;
			}
			xi--;
			yi--;
		}
		cout<<(xi<0?xpath[0]:ypath[0])<<endl;
		return 0;
}
int main()
{
    int x,y,ercha(int x,int y);
    scanf("%d %d",&x,&y);
    printf("%d",ercha(x,y));
    return 0;
}

int ercha(int x,int y)
{
          if(x==y) return x;
          else
          {
              if(x>y)
              {
              x=x/2;
              }
              else
              {
              y=y/2;
              }
              ercha(x,y);
          }
}
int main()
{
	int x[100],y[100],i,j,k;
	scanf("%d %d",&x[0],&y[0]);
	for(i=1;;i++)
	{
		x[i]=x[i-1]/2;
		if(x[i]==1)
			break;
	}
	for(j=1;;j++)
	{
		y[j]=y[j-1]/2;
		for(k=0;k<=i;k++)
		{
			if(y[0]==x[k]||y[j]==x[k])
				goto out;
		}
	}
out:printf("%d",x[k]);
	return 0;
}
/*??
1000012872
 */
int f(int x,int y);
int main()
{
	int x,y;
	cin>>x>>y;
	cout<<f(x,y);
	return 0;
}
int f(int x,int y)
{
	int m,n,p,q,i,j,c;
	if(x>=2&&y>=2)
	{
	    m=x;
	    n=y;
	    int a[x],b[y];
	    a[0]=x;
	    for(i=1;i<=m;i++)
	    {
	      if(x>=2)
		   {
		     a[i]=x/2;
	           x=x/2;

	        }
	      else break;
	    }

	      p=i-1;
              b[0]=y;
               for(i=1;i<=n;i++)
               {
	                 if(y>=2)
	                   {
	                     b[i]=y/2;
	                     y=y/2;
	                    }
	                 else break;
               }
                q=i-1;

                for(i=p,j=q;i>=0,j>=0;i--,j--)
                	if(a[i]==b[j])
                	c=a[i];
                	return c;
	}
	
	if(x==1||y==1) return x;
}
void main()
{
    int a1,b1,i,j;
    int k=0;
    int a[20]={0},b[20]={0};
    scanf("%d%d",&a1,&b1);
    for (i=0; a1!=0||b1!=0; a1/=2,b1/=2)
    {
        a[i]=a1;
        b[i]=b1;
        i++;
    }
    for (i=0; a[i]!=0; i++)
    {
        for (j=0; b[j]!=0; j++)
        {
            if (b[j]==a[i])
            {
                k=1;break;
            }
        }
        if (k==1)
        {
            break;
        }
    }
    printf("%d",b[j]);
    
}
int luo(int x,int y)
{
    int r1,r2,c;
	if(x==y)
		return x;
	else 
	{
		r1=log((double)x)/(log(2.0));
	    r2=log((double)y)/(log(2.0));
	    if(r1>=r2)
		{
			x=x/2;
		    luo(x,y);
		}
		else
		{
			y=y/2;
			luo(x,y);
		}
	}
}
int main()
{
	int x,y;
	scanf("%d%d",&x,&y);
	printf("%d",luo(x,y));
	
	return 0;
}
int main()
{
	int x[1000],y[1000],i,j,k,p,m;
	cin >> x[1] >> y[1];
	i=2;
	j=2;
	while(x[i-1]!=1)
	{
		x[i]=x[i-1]/2;
		i++;
	}
	while(y[j-1]!=1)
	{
		y[j]=y[j-1]/2;
		j++;
	}
	m=0;
	for(k=1;k<=i-1;k++)
	{
		if(m==0)
		{
		for(p=1;p<=j-1;p++)
		{
			if(y[p]==x[k])
			{
				cout << x[k];
				m=1;
				break;
			}
		}
		}
		else
			break;
	}
	return 0;
}