semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
struct tree
{
	struct tree *up;
	int num;
};
struct tree *MLC,*ptree;
int a[500],b[500];

int main()
{
	int x,y,i=1,j,p,q,miao,woofoo=0;
	MLC=(struct tree *)malloc(MAXNUM*sizeof(struct tree));
	for(ptree=MLC;ptree<MLC+1000;ptree++)
	{
		ptree->num=i;
		//printf("%d\n",ptree->num);
		(ptree+i)->up=ptree;
		(ptree+i+1)->up=ptree;
		i++;
	}
	scanf("%d%d",&x,&y);
	ptree=MLC;
	ptree=ptree+x-1;
	i=0;
	do
	{
		a[i]=ptree->num;
		//printf("%d\n",a[i]);
		ptree=ptree->up;
		i++;
	}while(a[i-1]!=1);
	ptree=MLC+y-1;
	j=0;
	do
	{
		b[j]=ptree->num;
		//printf("%d\n",b[j]);
		ptree=ptree->up;
		j++;
	}while(b[j-1]!=1);
	/*for(p=i;p>0;p--)
		printf("%d\n",a[p]);*/
	for(p=0;p<i;p++)
	{
		miao=0;
		for(q=0;q<j;q++)
		{
			if(a[p]==b[q])
			{
				miao++;
				break;
			}
		}
		if(miao==1)
		{
			printf("%d\n",a[p]);
			break;
		}
	}
	return 0;
}
int main()
{
	int m,n,s = 0;
	cin>>m>>n;
	int a[100];
	
	a[0]=m;
	for(int i=0;i<=98;i++)
	{
		a[i+1]=a[i]/2;
		if(a[i+1]==1)
		{
			s=i+1;
			break;
		}
	}
	for(int h=0;h<=99;h++)
	{
		for(int i=0;i<=s;i++)
		{
			if(a[i]==n)
			{
				cout<<n;
				return 0;
			}
		}
				n=n/2;
	}
}
void main()
{
	int x,y,n1,n2,i,j,t,number=0;
	int a[1000]={0},b[1000]={0};
	scanf("%d%d",&x,&y);
	for(i=1;;i++)
	{
		if(x>=pow(2,i-1)&&x<pow(2,i))
		{
			n1=i;
			break;
		}
	}
	for(i=1;;i++)
	{
		if(y>=pow(2,i-1)&&y<pow(2,i))
		{
			n2=i;
			break;
		}
	}
	a[n1]=x;
	b[n2]=y;
    for(i=n1;i>=2;i--)
	{
		if(a[i]%2==0)
		{
				t=(a[i]-pow(2,i-1))/2;
				a[i-1]=pow(2,i-2)+t;
		}
		else
		{
				t=(a[i]-1-pow(2,i-1))/2;
				a[i-1]=pow(2,i-2)+t;
		}
	}
	for(j=n2;j>=2;j--)
	{
		if(b[j]%2==0)
		{
				t=(b[j]-pow(2,j-1))/2;
				b[j-1]=pow(2,j-2)+t;
		}
		else
		{
				t=(b[j]-1-pow(2,j-1))/2;
				b[j-1]=pow(2,j-2)+t;
		}
	}
	for(i=1;i<=n1||i<=n2;i++)
	{
		if(a[i]==b[i])
		{
			number=number+1;
		}
		else
		{
			break;
		}
	}
	printf("%d\n",a[number]);
}
int up(int x);
int main()
{
	int x1,y1;//??????
	cin>>x1>>y1;
	int x[100],y[100];
	int m=2,n=2;//x,y???
	x[1]=x1;
	y[1]=y1;
	if((x1==1)||(y1==1))
		cout<<1;
	else
	{
		int g=0;//????
		while(g==0)
		{
			x[m]=up(x[m-1]);
			if(x[m]==1)
				g=1;
			else m++;
	    }
		int f=0;//????
		while(f==0)
		{
			y[n]=up(y[n-1]);
			if(y[n]==1)
				f=1;
			else n++;
	    }
		int h=0;// ????
		while(h==0)
		{
			if(x[m]==y[n])
			{
				m--;
				n--;
			}
			else
			{
				cout<<x[m+1];
				h=1;
			}
		}



	}
	return 0;
}
int up(int x)
{
	if(x%2==0)
		return x/2;
	else
		return (x-1)/2;//????????
}
/*
 * erchasu.cpp
 *
 *  Created on: 2012-11-26
 *      Author: Justin
 */

int main(){
          int x,y;
	cin>>x>>y;
		while(x!=y){
		if(x>y){
			x=x/2;
		}
		else{y=y/2;}
	}
	cout<<x;
}
int binTree(int a, int b) 
{
	if(a == b)
         {
		return a;
	}
	if(a > b) 
         {
		binTree(a / 2, b);
	} 
         else 
         {
		binTree(a, b / 2);
	}
}

int main() 
{
	int n, m;
	scanf("%d%d", &n, &m);
	printf("%d", binTree(n, m));
}
int main()
{
	int x,y,t;
	scanf("%d %d",&x,&y);
	if(x==1||y==1)
	{
		printf("1\n");
	}
	else
	{if(x==y)
	{printf("%d\n",x);}
	else
	{do
	{if(x>y)
	{
		t=x;
		x=y;
		y=t;
	}
	y=y/2;
	}while(x!=y);
	printf("%d\n",y);
	}
	}


	return 0;
}
int function( int x , int y );
int main()
{
	int x,y;
	cin>>x>>y;
	cout<<function( x , y )<<endl;
}


int function( int x , int y )
{
	if( x==y )
	{
		return ( x );
	}
	else if( x > y )
	{
		if( x%2==0 )
		{
			return( function( x/2 , y ) );
		}
		else
		{
			return( function( (x-1)/2 , y ) );
		}
	}
	else
	{
		if( y%2==0 )
		{
			return( function( x , y/2 ) );
		}
		else
		{
			return( function( x , (y-1)/2 ) );
		}
	}
}
void main()
{
	int m,n,x;
	scanf("%d%d",&m,&n);
	x=n;
	while(m>=1)
	{
		n=x;
		while(n>=1)
		{
		  if(m==n)
		  {
			printf("%d\n",m);
			break;
		  }
		  n=n/2;
		}
		if(m==n) break;
		m=m/2;
	}
}
int main()
{
    int x,y,i,j,p=0;
    int a[1000],b[1000];
    scanf("%d%d",&x,&y);
    a[0]=x,b[0]=y;
    for(i=1;i<1000;i++)
    {
        if(a[i-1]>1)
        a[i]=a[i-1]/2;
        if(a[i-1]==1)
        break;
    }
    for(i=1;i<1000;i++)
    {
        if(b[i-1]>1)
        b[i]=b[i-1]/2;
        if(b[i-1]==1)
        break;
    }
    for(i=0;i<1000;i++)
    {
        for(j=0;j<1000;j++)
        {

            if(a[i]==b[j])
            {
                printf("%d\n",a[i]);
                p=1;
                break;
            }
            if(j==1000)
            break;
           /* if(a[i]==b[i])
        {
            printf("%d\n",a[i]);
            break;*/
        }
        if(p==1)
        break;
    }
    return 0;
}
void main()
{
	int i,j,k,l,x[1000],y[1000],flag=0;
	scanf("%d%d",&x[0],&y[0]);
	for (i=0;x[i]>1;i++)
	{
		if (x[i]%2==0)
			x[i+1]=x[i]/2;
		else x[i+1]=(x[i]-1)/2;
	}
	k=i;
	for (j=0;y[j]>1;j++)
	{
		if (y[j]%2==0) y[j+1]=y[j]/2;
		else y[j+1]=(y[j]-1)/2;
	}
	l=j;
	for (i=0;i<=k;i++)
	{
		for (j=0;j<=l;j++)
		{
			if (x[i]==y[j])
			{
				printf("%d\n",y[j]);
				flag=1;
				break;
			}
			if (flag==1) break;
		}
	}
}
void main()
{
    void f(int a[],int n);
    int x,y,s,t,j;
    int a[11],b[11];
    for(j=0;j<11;j++)
    {
        a[j]=0;
        b[j]=0;
    }
    scanf("%d%d",&x,&y);
    f(a,x);
    f(b,y);

    for(j=10;j>=0;j--)
    {
        if(a[j]!=0) {s=j;break;}
    }
    for(j=10;j>=0;j--)
    {
        if(b[j]!=0) {t=j;break;}
    }
    for(j=1;j<=s&&j<=t;j++)
    {
        if(a[s-j]!=b[t-j])
        {
            printf("%d",a[s-j+1]);
            break;
        }
    }
    if(j==s+1) printf("%d",a[0]);
    else{
    if(j==t+1) printf("%d",b[0]);
    }
}
void f(int a[],int n)
{
    int i;
    a[0]=n;
    n=n/2;
    for(i=1;n>0;i++)
    {
        if(n%2==0)
        {
            a[i]=n;
            n=n/2;
        }
        else
        {
            a[i]=n;
            n=(n-1)/2;
        }
    }
}
/*????????pass?????????????????*/
int main ( )
{
	int x1, y1, x[11] = {0}, y[11] = {0}, i, j, ex, ey;
	void f(int z[11]);
	int g(int w[11]);
	cin >> x1 >> y1;
	x[0] = x1;
	y[0] = y1;
    f( x );
	f( y );
	ex = g(x);
	ey = g(y);
	for (i = ex, j = ey;i >= 0, j >= 0;i--, j--)/*?????????*/
	{
		if (i == 0 && j == 0 && x[i] == y[j])
			cout << x[i] << endl;
		else if (x[i] == y[j] && x[i-1] != y[j-1])
			{
				cout << x[i] <<endl;
				break;
			}
	}
	return 0;
}
void f(int z[11])          /*???????*/
{
	int i;
	for (i = 1;i < 11;i++)
	{
		z[i] = z[i-1] / 2;
	}
}
int g(int w[11])    /*????1???*/
{
	int i, m;
	for (i = 0;i < 11;i++)
	{
		if (w[i] != 0 && w[i+1] == 0)
		{
			m = i;
			break;
		}
	}
	return (m);
}
int main(){
int a,b;
scanf("%d%d",&a,&b);
while(a!=b)
{
if(a>b)a/=2;
else b/=2;
}
printf("%d",a);
}
int main()
{
	int x,y,i,j,k,xi,count=0;
	scanf("%d%d",&x,&y);
	int a[11],b[11];
	a[0]=x;
	b[0]=y;
	if(x==1||y==1)
		xi=1;
	else
	{
	for(i=1;a[i-1]>1;i++)
	{
		a[i]=a[i-1]/2;
		b[i]=b[i-1]/2;
	}
	for(i=0;a[i]>=1;i++)
	{
		for(j=0;b[j]>=1;j++)
			if(a[i]==b[j])
			{
				xi=a[i];
				count+=1;
				break;
			}
			if(count!=0)break;
	}
	}
	printf("%d\n",xi);
	return 0;
}
int main()
{
	int x[10],y[10],i,j,k;
	cin>>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;
		if(y[j]==1)
			break;
	}
	for(k=0;;++k)
	{
		if(x[i-k]!=y[j-k])
			break;
	}
	cout<<x[i-k+1];
	return 0;
}
int erchashu(int a[1000],int n)
{
	int i;
	a[0]=n;
	if(n!=1)
	{
		for(i=1;;i++)
		{
			a[i]=a[i-1]/2;
		    if(a[i]==1)break;
		}
	    return i;
	}
	else
		return 0;
}

void main()
{
	int a,b,A[1000],B[1000],m,n,p,q;
	scanf("%d %d",&a,&b);
	m=erchashu(A,a);
	n=erchashu(B,b);
	{
	    if(A[0]==B[0])
		{
		    printf("%d\n",A[0]);
		}

		else
		{
			for(p=m,q=n; ;p--,q--)
			{
				if(A[p]==B[q])
					continue;
		        else if(A[p]!=B[q])
				{
					printf("%d\n",A[p+1]);
			        break;
				}
				
			}
		}
	}
}
int step(int a,int b)
{
	int i,n;
	if(a==b)return a;
	else
	{
	    for(i=1;pow(2,i)-1<b;i++){}n=i;
	    b=pow(2,n-2)+floor((b-pow(2,n-1))/2);
		if(a<=b)step(a,b);
		else step(b,a);
	}
}

int main()
{
	int x1,x2;
	scanf("%d%d",&x1,&x2);
	if(x1<=x2)printf("%d\n",step(x1,x2));
	else printf("%d\n",step(x2,x1));
	return 0;
}
void main()
{
	int i,j=0,k=0,x[20],y[20];
	scanf("%d%d",&x[0],&y[0]);
	for(i=0;x[i]!=1;i++)
	{
		x[i+1]=x[i]/2;
		k=i+1;
	}
	for(i=0;y[i]!=1;i++)
	{
		y[i+1]=y[i]/2;
		j=i+1;
	}
	for(;x[k]==y[j]&&k>=0&&j>=0;)
	{
		k--;
		j--;
	}
		printf("%d",x[k+1]);
}
int len(int x)
{
	int i,k=0;
	for(i=1;i<=10;i++)
	{
		if(x!=0)
		{
			x=(x-x%2)/2;
			k+=1;
		}
		else break;
	}
	return k;
}
int ch(int x,int y)
{
	int i,n;
	n=len(x);
	for(i=1;i<=n-y;i++)
	{
		x=(x-x%2)/2;
	}
	return x;
}
int main()
{
	int x,y,m,n,i,a,s,same;
	scanf("%d %d",&x,&y);
	m=len(x);
	n=len(y);
	if(m>n)a=n;
	else a=m;
	for(i=a;i>=1;i--)
	{
		x=ch(x,i);
		y=ch(y,i);
		if(x==y)
		{
			printf("%d",x);
			break;
		}
	}
	return 0;
}
int main()
{
	int x,y;
	cin >>x >>y;
	int gen(int, int);           //???????????
	cout <<gen(x,y);
	return 0;
}

int up(int a)           //??a????
{
	int line,k,m;
	m = a;
	for (line=0; m!=0; line++)       //??a????line
		m /= 2;
	k = pow(2.0, line-2) + (a-pow(2.0, line-1))/2;  //???????a????k
	return k;
}
int gen(int a, int b)   //????????a?b?????
{
	if (a == b)          //?a??b?????
		return a;
	if (a > b)           //?a??b??a????up(a)?b???
	{
		a = up(a);
		return gen(a,b);
	}
	if (a < b)            //?b??a???
	{
		 b = up(b);
		 return gen(a,b);
	}
}
int i,n,k;

void work(int p,int u)
{
	if (u==1) {cout<<p;exit (0);}
	if (p%(n-1)==0)
  if((n*p/(n-1)+k)%n==k)
	 work(n*p/(n-1)+k,u-1);
}
int main()
{
	cin>>n>>k;
	while (n!=k)
					if (n>k) n=n>>1; else k=k>>1;
  cout<<n;
	return 0;
}
int f(int x,int y);
int main()                        //????
{
	int x,y;
	cin >> x >> y ;
	cout << f( x, y) << endl;
	return 0;
}
int f(int x,int y)                //?????
{
	while(x!=y)                   //??x=y??x;?????????????????
	{
		if(x>y)
			x=x/2;
		else
			y=y/2;
		return f(x,y);
	}
	return x;                     //??????????
}
int main()
{
	int a[11]={0};
	int b[11]={0};
	int c[11]={0};
	int p=0,q=0,r=0;//??
	int i,j;
	int M,N;

	scanf("%d%d",&M,&N);

	while(M>0)
	{
		a[p]=M;
		if(M%2==0) M=M/2;
		else M=(M-1)/2;
		p=p+1;
	}
	
	while(N>0)
	{
		b[q]=N;
		if(N%2==0) N=N/2;
		else N=(N-1)/2;
		q=q+1;
	}


	for(i=0;i<p;i++)
	{
		for(j=0;j<q;j++)
		{
			if(a[i]==b[j]) 
			{
				c[r]=a[i];
				r++;
			}
		}	
	}

	printf("%d",c[0]);
	//printf("%d",n);
	//for(i=0;i<q;i++)
	//	printf("%d ",b[i]);


	return 0;
}
int main()
{
	int a,b;
	cin>>a>>b;
	void cha_pri(int,int);
	if(a!=b)
		cha_pri(a,b);
	else cout<<a<<endl;
	
	return 0;
}

void cha_pri(int m,int n)
{
	void cha_pri(int,int);
	if(m>n)
	{
		m/=2;
		if(m==n)
			cout<<m;
		else cha_pri(m,n);
	}
	else if(m<n)
	{
		n/=2;
		if(m==n)
			cout<<m;
		else cha_pri(m,n);
	}
	else return;
}
int main()
{
  int p,q;
  void y(int n,int m);
  scanf("%d%d",&q,&p);
  y(p,q);
  return 0;
}
void y(int n,int m)
{
  if(n==m)
  printf("%d",n);  
  else if(m>n)
  {
    if(m>=(2*n))
      y(m/2,n);
     else if(m<(2*n))
      y(m/2,n/2);
   } 
   else
      y(m,n);
 }
int ln(int a)
{
    int b=0;
    for(b=0;b<11;b++)
    {
        if(pow((float)2,(float)b)>a)
        break;
    }
    return (b);
}

int main()
{
    int a,b,i;
    int a1,b1;
    cin>>a>>b;
    a1=ln(a);
    b1=ln(b);
    int num_1[a1];
    int num_2[b1];
    int j=0;
    num_1[0]=a;
    num_2[0]=b;
    for(i=1;i<a1;i++)
    {
         num_1[i]=num_1[i-1]/2;
    }
    for(i=1;i<b1;i++)
    {
         num_2[i]=num_2[i-1]/2;
    }
    for(i=0;i<a1;i++)
    {
        for(int k=0;k<b1;k++)
        {
                if(num_1[i]==num_2[k])
                j++;
        }
    }
    cout<<num_1[a1-j]<<endl;
    return 0;
}
int main()
{
	int x,y,m,n,i,j,a[30],b[30];
	scanf("%d%d",&x,&y);
	a[0]=x;
	b[0]=y;
	for(i=0;i<30;i++)
	{
		if(a[i]>1&&a[i]%2==0)
			a[i+1]=a[i]/2;
        else if(a[i]>1&&a[i]%2==1)
			a[i+1]=(a[i]-1)/2;
		else break;
	}
	m=i+1;
	for(i=0;i<30;i++)
	{
		if(b[i]>1&&b[i]%2==0)
			b[i+1]=b[i]/2;
        else if(b[i]>1&&b[i]%2==1)
			b[i+1]=(b[i]-1)/2;
		else break;
	}
	n=i+1;
    for(i=0;i<m;i++)
	{
		for(j=0;j<n;j++)
			if(b[j]==a[i])
			{
				printf("%d",a[i]);
				break;
			}
		if(j!=n)
			break;
	}
return 0;
}
void a(int m);
void b(int m);
int sqrt(int i);
int c(void);
int x[15]={0},y[15]={0};
int o,p;
int main()
{
	int m,n,k;
	scanf("%d%d",&m,&n);
	if(m==n)
	{
		printf("%d\n",n);
		return 0;
	}
	o=m;
	p=n;
	if(m==1||n==1)
	{
		printf("1\n");
		return 0;
	}
	a(m);
	b(n);
	printf("%d\n",c());
	return 0;
}
void a(int m)
{
	int i,n;
	for(i=0;i<15;i++) x[i]=0;
	for(i=0;i<15;i++)
	{
		if(m<sqrt(i))
		{
			n=i;
			break;
		}
	}
	x[n-1]=o;
	for(i=n-2;i>=0;i--)
	{
		if(m%2==0)
		{
			x[i]=m/2;
			m=m/2;
			continue;
		}
		if(m%2==1)
		{
			x[i]=(m-1)/2;
			m=(m-1)/2;
			continue;
		}
	}
}
void b(int m)
{
	int i,n;
	for(i=0;i<15;i++) y[i]=0;
	for(i=0;i<15;i++)
	{
		if(m<sqrt(i))
		{
			n=i;
			break;
		}
	}
	y[n-1]=p;
	for(i=n-2;i>=0;i--)
	{
		if(m%2==0)
		{
			y[i]=m/2;
			m=m/2;
			continue;
		}
		if(m%2==1)
		{
			y[i]=(m-1)/2;
			m=(m-1)/2;
			continue;
		}
	}
}
int sqrt(int i)
{
	int m=1,j;
	for(j=1;j<=i;j++)
	{
		m=m*2;
	}
	return m;
}
int c(void)
{
	int i,k=1;
	for(i=0;i<15;i++)
	{
		if(x[i]==y[i]) k=i;
		if(x[i]!=y[i]||x[i]==0) break;
	}
	return x[k];
}
int number(int n)
{
	int i,k=1;
	for(i=1;;i++)
	{
		k*=2;
		if(n<k)
			break;
	}
	return i;
}
void array(int a[],int number,int n)
{
	a[number]=n;
	int l=number;
	int i;
	for(i=1;i<l;i++)
	{
		if(n%2==0)
			n/=2;
		else
			n=(n-1)/2;
		number-=1;
		a[number]=n;
	}
}

void main()
{
	int m,n;
	scanf("%d%d",&m,&n);
	int m1,n1,k=0;

	m1=number(m);
	n1=number(n);
	int a[100]={0},b[100]={0};
	array(a,m1,m);
	array(b,n1,n);
	int i,j;
	for(i=m1;i>=1;i--)
	{
		for(j=n1;j>=1;j--)
		{
			if(a[i]==b[j])
			{
				printf("%d\n",a[i]);
				k=1;
				break;
			}
		}
		if(k)
			break;
	}
}
int choose(int x,int y)
{
	if(x==y)return x;
	if(x>y)return choose(x/2,y);
	else return choose(x,y/2);
}
void main()
{
	int choose(int x,int y);
	int m,n,k;
	scanf("%d%d",&m,&n);
	k=choose(m,n);
	printf("%d\n",k);
}
int main(){
	int x,y,p;									//????
	cin>>x>>y;									//?????
    if(x==y)cout<<x<<endl;						//???????????
	else {										//???????
		if(x<y){
			p=x;
			x=y;
			y=p;
		}										//?x?????
		p=x;									//?????x??
		for(;y>=1;y=(y%2==0)?y/2:(y-1)/2){		//?y????y=1
			x=p;								//x???????????
			while(x>=1){						//?x>=1?
				x=(x%2==0)?x/2:(x-1)/2;			//??x?????
				if(x==y){						//????x=y
					cout<<x<<endl;				//?????
				    return 0;					//??
				}
			}
		}
	}
	return 0;
}
int main()
{
	int x,y,a[100],b[100],i,j,n=0,m=0,p=0,c[50];
	scanf("%d %d",&x,&y);
	for(i=0;i<=100;i++)
	{
		if(x%2==0)
		{
			b[n]=x;
		    n++;
		    x=x/2;
		}
	    else
		{
			b[n]=x;
		    n++;
		    x=(x-1)/2;
		}
	}
    for(i=0;i<100;i++)
	{
		if(y%2==0)
		{
			a[m]=y;
		    m++;
		    y=y/2;
		}
		else     
		{
			a[m]=y;
		    m++;
		    y=(y-1)/2;
		}
	}
		
	for(i=0;i<n;i++)
		for(j=0;j<m;j++)
		if(b[i]==a[j])
		{
			c[p]=b[i];
			p++;
		}		
	printf("%d",c[0]);
	return 0;
}
int main()
{
	int x, y;
	scanf("%d%d",&x,&y);
	int xroute[20],yroute[20];
	xroute[0]=x;
	yroute[0]=y;
	int i, j, a, b;
	for(i=1; i<20; i++)
	{
		if(xroute[i-1]==1) break;
		if(xroute[i-1]%2==0) xroute[i]=xroute[i-1]/2;
		else xroute[i]=(xroute[i-1]-1)/2;
	}
	a=i-1;
	for(i=1; i<20; i++)
	{
		if(yroute[i-1]==1) break;
		if(yroute[i-1]%2==0) yroute[i]=yroute[i-1]/2;
		else yroute[i]=(yroute[i-1]-1)/2;
	}
	b=i-1;
	for(i=0; i<=a; i++)
	{
		for(j=0; j<=b; j++)
		{
			if(xroute[i]==yroute[j]) 
			{
				printf("%d\n",xroute[i]);
				return 1;
			}
		}
	}
	return 0;
}
int main()
{
	int common(int x,int y);
	int m,n;
	cin>>m>>n;
	cout<<common(m,n)<<endl;
	return 0;
}

int common(int x,int y)
{
	if(x==y){
		return x;
	}
	if(x>y){
		return common(x/2,y);
	}
	if(x<y){
		return common(x,y/2);
	}
}
void find(int x,int y)
{
	if(x==y)
		printf("%d\n",x);
	else if(x>y)
		find(x/2,y);
	else
		find(x,y/2);	
}
void main()
{
	int x,y;
	scanf("%d%d",&x,&y);
	find(x,y);
}
void main()
{
	int x,y,i,j;
	int a[10]={0};
	int b[10]={0};
    scanf("%d %d",&x,&y);
	a[0]=x,b[0]=y;
	if(x==1||y==1)  printf("1");
	else 
	{
	  for(i=1;x!=1;i++)
	  {   a[i]=x/2;
		   x=x/2;
	  }
      for(j=1;y!=1;j++)
	  {  b[j]=y/2;
		   y=y/2;
	  }
	  for(;i>=1,j>=1;i--,j--)
		  if(a[i-1]!=b[j-1]) {printf("%d",a[i]);
		                      break;}
	  if(i==0&&j>=0)  printf("%d",a[0]);
	  if(j==0&&i>0)  printf("%d",b[0]);
	}
}
int main()
{
	int ec(int a,int b);     //?? ec????
	int x,y;
	cin>>x>>y;
	cout<<ec(x,y);               
	return 0;
}
int ec(int a,int b)       
{
	if(a==b)
		return a;           //??????        
	if(a>b)
	{	int t=a;              
		a=b;
		b=t;
	}
	return(ec(a,b/2));         //????
}
int lujing(int a)
{
	int b,j,n;
	for(j=9;j>=0;j--)
	{
		if(a>=pow(2,j)&&a<pow(2,j+1))n=j;
	}
	b=(a-pow(2,j))/2+pow(2,j-1);
	return b;
}
void main()
{
	int x[10],y[10];
	int i,k,t;
	scanf("%d%d",&x[0],&y[0]);
	for(i=1;;i++)
	{
		x[i]=lujing(x[i-1]);
		if(x[i]==1)break;
	}
	for(k=1;;k++)
	{
		y[k]=lujing(y[k-1]);
		if(y[k]==1)break;
	}
	for(t=0;;t++)
	{
		if(x[i-t]==y[k-t]&&x[i-t-1]!=y[k-t-1])
		{
			printf("%d\n",x[i-t]);
			break;
		}
	}



}
int main()
{
	int a[1000],b[1000];            //??????
	int x,y,i,j,k,t;
	cin>>x>>y;
	a[0]=x;b[0]=y;
	if(x==y) cout<<x;
	else{
	for(i=1;;i++) {                //??x??????
		a[i]=a[i-1]/2;
		if(a[i]==1) {
			k=i;
			break;
		}
	}
	for(i=1;;i++){                //??y??????
		b[i]=b[i-1]/2;
		if(b[i]==1){
			t=i;
			break;
		}
	}

	for(i=k,j=t;;i--,j--){          //??x?y?????
		if(a[i]!=b[j])
		{cout<<a[i+1]<<endl;
		break;}
	}
	}
	return 0;
}
int Sort(int a,int b)
{
	int i;
	if (a == b)
		return a;
	else if (a>b)
		Sort(a/2,b);
	else
		Sort(a,b/2);
}

int main()
{
	int x,y,xi;
	cin >> x >> y;
	cout << Sort (x,y) << endl;
	return 0;
}
int a[20]={0},b[20]={0},i=0;

void f(int x)
{
	if (x==1)
	{
		a[i]=x;
		i++;
	}
	else
	{
		f(x/2);
		a[i]=x;
		i++;
	}
}


int main()
{
	int x,y,j,counter=0,k;
	cin>>x>>y;
	f(y);
	for (j=0;j<20;j++)
	{
		b[j]=a[j];
		a[j]=0;
	}
	i=0;
	f(x);
	for (j=0;j<20;j++)
	{
		if (b[j]==a[j]&&b[j]>0)
			counter++;
		else
			break;
	}
	cout<<a[counter-1]<<endl;
	return 0;
}
/*
 * 00073.cpp
 *??????
 *  Created on: 2011-11-16
 *      Author: ???
 */
int main(){                                  //???
       int a[20],b[20];
       int x,y,i,j,n=1,m=1;
       cin>>x>>y;
       while(x!=1){
    	   a[n]=x;
    	   x=x/2;
    	   n++;
       }
       a[n]=1;
       while(y!=1){
           	   b[m]=y;
           	   y=y/2;
           	   m++;
              }
       b[m]=1;
       for(i=1;i<=n;i++)
    	   for(j=1;j<=m;j++)
    		   if(a[i]==b[j]){
    			   cout<<a[i]<<endl;
    			   i=j=20;
    		   }
       return 0;
}
int k;
void tree(int m, int n)
{
	if (m == n)
		k = m; // ?? 
	else if (m > n)
		tree(m / 2, n); 
	else if (m < n)
		tree(m, n / 2); // ?? 
}
int main()
{
	int x, y;
	cin >> x >> y;
	tree(x , y); 
	cout << k;
	return 0;
}
void main()
{
	int f(int m,int n);
	int d,M,N;
	scanf("%d%d",&M,&N);
	printf("%d",f(M,N));
}
int f(int m,int n)
{
	int a;
	if (m<n)
	{
		a=m;
		m=n;
		n=a;
	}
	if (m==n)
		return m;
	else
		return f(m/2,n);
}
void main()
{

	int x,y,i,j,num1,num2;
	int xline[11]={0},yline[11]={0};


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

	xline[0]=x;
	yline[0]=y;

	i=1;
	while (x>1)
	{
		x=x/2;
        xline[i]=x;
		i=i+1;
	}
    num1=i-1;

	i=1;
	while(y>1)
	{
		y=y/2;
		yline[i]=y;
		i=i+1;
	}
	num2=i-1;

	for(i=0;i<=num1;i++)
	{
		for(j=0;j<=num2;j++)
			if (xline[i]==yline[j])
			{
				printf("%d\n", xline[i]);
				i=num1+1;
			}
	}
}
int main()
{
	int i,j,a,b,x[10],y[10],countx=0,county=0;
	scanf("%d%d",&a,&b);
    for(i=0;;i++)
	{
		if(i==0) x[i]=a;
		else x[i]=x[i-1]/2;
    	countx++;
	    if(x[i]==1)
		    break;
	}
    for(i=0;;i++)
	{
		if(i==0) y[i]=b;
		else y[i]=y[i-1]/2;
		county++;
		if(y[i]==1)
			break;
	}
	for(i=0;i<countx;i++)
		for(j=0;j<county;j++)
			if(x[i]==y[j])
			{
				printf("%d\n",x[i]);
				return 0;
			}
}
void main()
{
	int x,y,i,k;
	int a[12]={0},b[12]={0};
	
	scanf("%d%d",&x,&y);
	
	a[0]=x;
	b[0]=y;
	for(i=0;a[i]>=2;i++)
	{
		a[i+1]=a[i]/2;
	}
	for(k=0;b[k]>=2;k++)
	{
		b[k+1]=b[k]/2;
	}
	if(x!=y)
	{
		for(;;i--,k--)
	    {
			if(a[i]!=b[k])
		    {
			    break;
		    }
	    }
		printf("%d\n",a[i+1]);
	}
	else
	{
		printf("%d\n",x);
	}

}
int main()
{
	int x,y,i,j,l;
	int a[13]={0},b[13]={0};
	scanf("%d%d",&x,&y);
	for(i=0;x>0;i++){
		a[i]=x;
		x=x/2;
	}
	l=i;
	for(;y>0;y=y/2){
		for(j=0;j<l;j++){
			if(a[j]==y){
				printf("%d",a[j]);
				return 0;
			}
		}
	}
}
int A[10]={0},B[10]={0};
int main()
{
	int x,y,*pt1,*pt2,number1=0,number2=0,flag=0;
	pt1=A;
	pt2=B;
	scanf("%d%d",&x,&y);
	while(x!=0)
	{
		*pt1=x;
		x=x/2;
		pt1++;
		number1++;
	}
	while(y!=0)
	{
		*pt2=y;
		y=y/2;
		pt2++;
		number2++;
	}
	for(pt1=A;pt1<A+number1;pt1++)
	{
		for(pt2=B;pt2<B+number2;pt2++)
		{
			if(*pt1==*pt2)
			{
				printf("%d",*pt1);
				flag=1;
				break;
			}
		}
		if(flag==1)
			break;
	}
	return 0;
}
//**********************************
//??: ???
//???2013.11.23
//**********************************
int main()
{   
	int x=0,y=0,a[10000],b[10000],i=1,j=1,p=0,q=0,k=0;
	cin>>x>>y;
    if(x>1)
	{
		   for(i=1;;i++)
		   { 
			  if(x%2==0)
			  {
			     a[i]=x;
			     x=x/2;
			  }
			  else
			  {
			     a[i]=x;
			     x=(x-1)/2;
			  }
			   if(x==1)
			   {   a[i+1]=1; break; }
		   }
    }
	else
		a[1]=1;
	 if(y>1)
	{
		   for(j=1;;j++)
		   { 
			  if(y%2==0)
			  {
			     b[j]=y;
			     y=y/2;
			  }
		      else
			  {
			     b[j]=y;
			     y=(y-1)/2;
			  }
			   if(y==1)
			   {   b[j+1]=1; break; }
		    }
	}
	 else
		 b[1]=1;
	 for(p=1;p<=i+1;p++)
	 {
		 for(q=1;q<=j+1;q++)
		 {
			 if(a[p]==b[q])
			 {   k=1; cout<<a[p]<<endl;  break;  }
		 }
         if(k==1)
			 break;
	  }


	return 0;	
}
int main()
{
                int x,y,c,d,e,i,j;
                int a[20],b[20];
                scanf("%d %d",&a[0],&b[0]);
                
                for(i=1;i<20;i++)
                {a[i]=a[i-1]/2;
                if(a[i]==1)
                break;}
                     for(i=1;i<20;i++)
                {b[i]=b[i-1]/2;
                if(a[i]==1)
                break;}
                e=0;
                  
                for(i=0;i<20;i++)
                {
                                 for(j=0;j<20;j++)
                                 {
                                                  if(b[j]==a[i])
                                                  {e=b[j];
                                                  break;}
                                                  }
                                                  if(e!=0)
                                                  break;
                                                  }
              printf("%d",e);
                            getchar();    getchar();    getchar();    getchar();
                 }
int main()
{
	int route(int x, int y);//????
	int x,y;
	cin>>x>>y;
	cout<<route(x,y);
	return 0;
}

int route(int x, int y)
{
	if(x==y)
		return x;
	else
	{
		if(x/2>=y)
			return route(x/2,y);
		else if(x<=y/2)
			return route(x,y/2);
		else
			return route(x/2,y/2);
	}
}
void main()
{
	int a[1000]={0},b[1000]={0};
	int i,j,k,l;
	int x,y,flag=0;

	scanf("%d%d",&x,&y);
	a[0]=x;
	b[0]=y;
	for(i=1;x!=1;i++)
	{
		if(x%2==0)
		{
			a[i]=x/2;
			x=a[i];
		}
		else
		{
			a[i]=(x-1)/2;
			x=a[i];
		}
	}
	for(j=1;y!=1;j++)
	{
		if(y%2==0)
		{
			b[j]=y/2;
			y=b[j];
		}
		else
		{
			b[j]=(y-1)/2;
			y=b[j];
		}
	}
	for(l=0;l<=i;l++)
	{
		for(k=0;k<=j;k++)
		{
			if(b[k]==a[l])
			{
				printf("%d",a[l]);
				flag=1;
				break;
			}
		}
		if(flag) break;
	}
}
int main()
{
int x[10],y[10],a,b,i,j,k,t,m,s=0;
scanf("%d %d",&a,&b);
for(i=1,x[0]=a;x[i-1]!=1;i++)
   {
    x[i]=x[i-1]/2;
    }
k=i;
for(i=1,y[0]=b;y[i-1]!=1;i++)
   {
    y[i]=y[i-1]/2;
    }
t=i;
for(i=0;i<k;i++)
   {
    for(j=0;j<t;j++)
        {
         if(x[i]==y[j])
             {
              printf("%d",x[i]);
              s=1;
              break;
              }
         }
   if(s==1) break;
   }
return 0;
}
void main()
{
	int x,y;
	scanf("%d %d",&x,&y);
	int i=x,j=y;
	while(i!=0&&j!=0)
	{
		if(i==j)
			break;
		else if(i>j)
			i=i/2;
		else
			j=j/2;
	}
	printf("%d\n",i);
}
int main()
{
	int m,n,s = 0;
	cin>>m>>n;
	int a[100];
	memset(a, 0, sizeof(a));
	a[0]=m;
	for(int i=0;i<=98;i++)
	{
		a[i+1]=a[i]/2;
		if(a[i+1]==1)
		{
			s=i+1;
			break;
		}
	}
	for(int h=0;h<=99;h++)
	{
		for(int i=0;i<=s;i++)
		{
			if(a[i]==n)
			{
				cout<<n;
				return 0;
			}
		}
				n=n/2;
	}
}