semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int main()
{
char s[255];
char *p=s;
int i=0,j=1;

scanf("%s",s);
if(strlen(s)>255){
 

}
while(i<strlen(s))
{
	while(*p!='\0') 
	{
      if(*p>='A' && *p<='Z') 
	  *p=*p+32;
      *p++;
    }
  if(s[i]==s[i+1])
   j++;
 else{
   printf("(%c,%d)",s[i]-'a'+'A',j);
   j=1;
}
i++;
}
}
main()
{
    char c[1000];
    scanf("%s",c);
    int i;
    for(i=0;c[i]!='\0';i++)
    {
        if((c[i]>='a')&&(c[i]<='z'))
        c[i]=c[i]+'A'-'a';
    }
    int m,n;
    n=1;
    for(m=0;c[m]!='\0';m++)
    {
        if(c[m]!=c[m+1])
        {
            printf("(%c,%d)",c[m],n);
            n=1;
        }
        else
        n++;
    }
}
int main()
{
	char str[1000], s, temp = NULL;
	int i, sum;
	for (i = 0; i < 1000; i++)
	{
		cin.get(s);
		if (s == '\n')
		{
			cout << sum << ")" << endl;
			break;
		}
		else
		{
			if (s - 'a' >= 0 && s - 'a' <= 26)
				s = 'A' + s - 'a';
			if (temp != s)
			{
				if (temp != NULL)
					cout << sum << ")(" << s << ",";
				else
					cout << "(" << s << ",";
				temp = s;
				sum = 1;
			}
			else
			{
				sum++;
			}
		}
	}
	return 0;
}
char big(char x);
int main()
{
	char a[1003];
	char t;
	int sum=0,i,len;
	cin>>a;
	len=strlen(a);
	sum=1;
	t=big(a[0]);
	for(i=1;i<len;i++)
	{
		if(big(a[i])==t) sum++;
		if(big(a[i])!=t)
		{
			cout<<"("<<t<<","<<sum<<")";
			sum=1;
			t=big(a[i]);
		}
	}
	cout<<"("<<t<<","<<sum<<")";
	return 0;
} 
char big(char x)
{
	if(x>='a'&&x<='z') return(x-'a'+'A');
	else return x;
}
int main()
{
	char str[1100]={0};
	int i=0,j=0,c[1000][2]={0};//c[][0]??,c[][1]??
	cin.getline(str,1100,'\n');
	if(str[0]>='A'&&str[0]<='Z')
		c[0][0]=str[0];
	else
		c[0][0]=str[0]+'A'-'a';
	c[0][1]++;
	for(i=1;str[i]!=0;i++)
	{
		if(str[i]>='A'&&str[i]<='Z'&&str[i]==c[j][0]||str[i]+'A'-'a'==c[j][0])
			c[j][1]++;
		else
		{
			j++;
			if(str[i]>='A'&&str[0]<='Z')
				c[j][0]=str[i];
			else
				c[j][0]=str[i]+'A'-'a';
			c[j][1]++;
		}
	}
	for(i=0;i<=j;i++)
		cout<<'('<<(char)c[i][0]<<','<<c[i][1]<<')';

	return 0;
}
int main()
{
	int r,t=1,i=0,n,k;
    char a[1000];
	cin.getline(a,1000);
	for(i=1;a[i-1]!='\0';i++)
	{
		if(a[i-1]==a[i]||a[i-1]-a[i]==32||a[i-1]-a[i]==-32)
			t++;
		else
		{
			cout<<"("<<((int)a[i-1]<97?a[i-1]:(char)(a[i-1]-32))<<","<<t<<")";
			t=1;
		}


	}
	
 	return 0;
}
char a[1000];
int b[1000];
int i,j;
main ()
{
     scanf("%s",a);
     for(i=0;a[i]!='\0';i++)
     {
                            if(a[i]>='a'&&a[i]<='z')
                            a[i]=a[i]-'a'+'A';
                            }
                            for(i=0;a[i]!='\0';)
                            {for(j=i;;j++)
                            {if(a[j]==a[i])
                            b[i]++;
                            if(a[j]!=a[i])
                            break;}
                            printf("(%c,%d)",a[i],b[i]);
                            i+=b[i];
                            }
    
return 0;}
struct point{
	char a;
	int b;
}poi[40];
int main()
{
	char str[1000];
	int i,j=0,k;
	scanf("%s",&str);
	poi[j].a=str[0];
	for(i=1;str[i]!='\0';i++){
		if(str[i]==str[i-1]||str[i]==str[i-1]-32||str[i]==str[i-1]+32){
		    poi[j].b++;}
		else{j++;poi[j].a=str[i];}
	}
	for(k=0;k<=j;k++){
		if(poi[k].a>96){poi[k].a=poi[k].a-32;}
		printf("(%c,%d)",poi[k].a,poi[k].b+1);
		
	}
    return 0;
}
int main()
{
	char a[2000],c[2000];
	cin>>a;
	int l=strlen(a),i,j=1,k=0,b[2000];
	for(i=0;i<l-1;i++)
	{
		if(a[i]==a[i+1]||(a[i]-a[i+1]==32)||(a[i]-a[i+1]==-32))
		j++;
		else
		{
			b[k]=j;
			c[k]=a[i];
			k++;
			j=1;
		}
	}
		c[k]=a[l-1];
		b[k]=j;
	for(i=0;i<=k;i++)
		{if(c[i]<='Z')
			cout<<"("<<c[i]<<","<<b[i]<<")";
		else
		{
			c[i]=c[i]-32;
			cout<<"("<<c[i]<<","<<b[i]<<")";
		}
		}
}
main()
{
      int l,i,p=0;
      char s[1010],c;
      scanf("%s",s);
      l=strlen(s);
      if((s[0]>='a')&&(s[0]<='z'))
      c=s[0]-'a'+'A';
      else
      c=s[0];
      for(i=0;i<=l;i++)
      {
          if((s[i]!=c)&&((s[i]-'a'+'A')!=c))
          {
                     printf("(%c,%d)",c,p);
                     p=0;
                     if((s[i]>='a')&&(s[i]<='z'))
                     c=s[i]-'a'+'A';
                     else
                     c=s[i]; 
          }
          p++;
      }
      getchar();getchar();
}
int main()
{int i,j,k,t;
 char s[1000],last;
 scanf("%s",s);
// printf("%d%d",'a','A');
 for (i=0;s[i]!='\0';i++)
   if (s[i]<97) s[i]=s[i]+32;
 last='!';
 for (i=0;s[i]!='\0';i++)
 { k=0;
   if (s[i]!=last)
   {
   last=s[i];
   for (j=i;s[j]==last;j++)
      k=k+1;
       
       printf("(%c,%d)",s[i]-32,k);
    
   }
 }    
   

 return 0;
}
main()
{
      int a,i;
      char str[1001];
      a=1;
      scanf("%s",str);
      for(i=0;;i++)
      {
                   if(str[i]=='\0')
                   break;
                   if(str[i]>96)
                   str[i]=str[i]-32;
      }
      for(i=0;;i++)
      {           
                   
                   if(str[i]==str[i+1])
                   a++;
                   else
                   {
                   printf("(%c,%d)",str[i],a);
                   a=1;
                   }
                   if(str[i+1]=='\0')
                   break;
                   
      }

}
main()
{
      char str[101];
      gets(str);
      int i=0,n=1;
      for(i;str[i]!='\0';i++)
      {
             if(str[i]>='a'&&str[i]<='z') str[i]+='A'-'a';
      }
      for(i=0;str[i]!='\0';i++)
      {
             if(str[i]==str[i+1]) n++;
             else {
                  printf("(%c,%d)",str[i],n);
                  n=1;
                  }
      }
      getchar();
}
int main()
{
    int i,k=1,j,m,n,a[100];
    char str[1000],b[100];
    scanf("%s",str);
    for(n=1;n<=strlen(str);n++)
    {a[n]=0;}
    
    for(m=0;m<=strlen(str)-1;m++)
  {
    if(str[m]>=97&&str[m]<=122)
    str[m]=str[m]-32;
    
  }
  if(strlen(str)==1)
   {b[1]=str[0];a[1]=1;}
   else{
    for(i=1;i<=strlen(str)-1;i++) 
    { 
      if(str[i]==str[i-1])
      {a[k]=a[k]+1;b[k]=str[i-1];}
      else
      {a[k]=a[k]+1;b[k]=str[i-1];k++;}
      if(i==strlen(str)-1)
      {a[k]=a[k]+1;b[k]=str[i];}
    }}
    for(j=1;j<=k;j++)
    {
                 
    printf("(%c,%d)",b[j],a[j]);
    }
    
}
int main()
{
     char str[1001];
     int len , i,temp ,sum = 1 ,k = 1;
     scanf("%s",str);
     len = strlen( str );
      temp = 0;
     for( i = 0 ;i <= len+1 ;i ++  )
     {    
         while( str[k] == str[temp] || str[k] == str[temp]+32 || str[k] == str[temp ] - 32 )
           {          
             sum ++;
             k++;
           }

           if( str[temp] >= 'a' && str[temp] <= 'z')
           str[temp]-= 32;
           printf( "(%c,%d)",str[temp],sum );
           sum = 1;
           temp = k  ; 
           i = k+1;
           k = k+1;
     }
}
int main()
{
    char a[1000],b;
    int n,j,l,i;
    gets(a);
    l=strlen(a);
    for (i=0;i<l;i++)
                      {
                          if (a[i]>='a'&&a[i]<='z')
                              a[i]=a[i]+'A'-'a';
                      }
   for (i=0 ;i<l;i++)
                          {j=1;b=a[i];
                           loop:  if(a[i]==a[i+1])
                                    {j++;
                                    i++;
                                     goto loop;
                                        }
                           else 
                         printf("(%c,%d)",b,j)  ;         
                           
                           }   
      getchar();
      getchar();
                            }
int main(int argc, char *argv[])
{
  int i,j,n=0;
  char a[1000]={'\0'};
  gets(a);
  for(i=0;i<1000;i++)
  {
        if(a[i]=='\0')
        break;
        if(a[i]>='a'&&a[i]<='z')
        a[i]=a[i]-'a'+'A';
  }
  for(i=0;i<1000;i++)
  {
       if(a[i]=='\0')
       break;
       if(a[i]!=a[i+1])
       {
             n=0;
             for(j=i;a[j]==a[i];j--)
             n++;
             printf("(%c,%d)",a[i],n);
       }
  }
  return 0;
}
main()
{
      int r=0,n,i=0,j=0,x=0,y=0,z[1000];
      char a[1000];
      
      scanf("%s",a);
      n=strlen(a);
      
      for(i=0;i<n;i++)
       {
         if ( a[i]>='a' && a[i]<='z')
         a[i]=a[i]-32;
        } 
      
      
      
      for( x=0;x<=n;x++)
       {
         j=0;
         z[x]=0; 
         if (x>0 && a[x]==a[x-1])
         continue;     
        for(y=x;y<=n;y++)
         {
           if (a[y]==a[x])
            z[x]++;
           else 
           {
            printf("(%c,%d)",a[x],z[x]);
            break;
           }    
         }  
       }
      
     
 }
int f(char c)
{   if ((c>'Z')&&(c<='z'))
    c=c-'a'+'A';
    return c;
}
main()
{ int j=1;
  char str[1050];
  scanf("%s",str);
  for (int i=0;i<=strlen(str)-1;i++)
  {str[i]=f(str[i]);
  }
  for(int i=0;i<=strlen(str)-1;i++)
  {if(str[i]==str[i+1])
   {j=j+1;
   }
   else 
   {printf("(%c,%d)",str[i],j);
    j=1;
   }
  }
}
main()
{
    char string[1001];
    int time,m,n,i,j,k;
    gets(string);
    m=strlen(string);
    for (i=0;i<m;i++)
    {
    	if (string[i]>='a'&&string[i]<='z')
    	    string[i]=string[i]-32;
    }
    time=1;
    for (i=0;i<m;i++)
    {
		if (string[i+1]==string[i])
		{
			time=time+1;
		}
		else 
		{
			printf ("(%c,%d)",string[i],time);
			time=1;
		}
    }
}
/*
 * ????practice2.cpp
 * ??????
 * ?????2012-12-24
 * ??????????
 */



int chartonum(char c1) {
	if (c1 > 64 && c1 < 91)
		return (int) c1 - 65;
	if (c1 > 96 && c1 < 123)
		return (int) c1 - 97;
	return 0;
}

int main() {
	char c[1000];
	int z, num, i;
	cin >> c;
	for (i = 0; i < strlen(c); ++i) {
		z = chartonum(c[i]);
		num = 1;
		while (i != strlen(c) && chartonum(c[i]) == chartonum(c[i + 1])) {
			++i;
			++num;
		}
		if (i == strlen(c))
			num--;
		cout << '(' << (char) (z + 65) << ',' << num << ')';
	}
	return 0;
}
int main()
{

	char string[1000];
	gets(string);

	int len=0;
	int count=0;
	while(string[len])
		len++;

	int index=0;

	char first_letter=toupper(string[0]);


	for(index=0;index<=len;)
    {
		if(toupper(string[index])==first_letter)
		{
			count++;
			index++;
		}
		else
		{
			
				printf("(%c,%d)",first_letter,count);
			    count=0;
			    first_letter=toupper(string[index]);
      
		}
	}

		
	return 0;
}
void change(char words[])
{
	int len = strlen(words);
	int i = 0;
	int d = 'A' - 'a';
	for(i = 0; i < len; i++)
	{
		if(words[i] <= 'z'&& words[i] >= 'a')
		{
			words[i] = words[i] + d;
		}
	}
}
int main()
{
	char words[100];
	cin >> words;
	change(words);
	char mark = words[0];
	int sum = 0, len = strlen(words);
	for(int i = 0; i < len; i++)
	{
		if(words[i] == mark)
		{
			sum++;
		}
		else
		{
			cout << "(" << mark << "," << sum << ")";
			mark = words[i];
			sum = 1;
		}
	}
	cout << "(" << mark << "," << sum << ")";
	return 0;
}
int main()
{	
	char a[1001];
	int i, temp;
	cin.getline(a, 1001);
	int len = strlen(a);
	temp = 0;
	while (temp < len)
	{
		i = temp + 1;
		while ((i < len) && (a[i] == a[temp] || a[i] - 'a' == a[temp] - 'A' || a[i] - 'A' == a[temp] - 'a'))
			i ++;
		if (a[temp] <= 'Z')
			cout << "(" << (char) a[temp] << "," << i - temp << ")";
		else
			cout << "(" << (char) (a[temp] - 'a' + 'A') << "," << i - temp << ")"; 
		temp = i;
	}
	return 0;
}
int main()
{
 	int a[100]={0},b[100]={0},n=0,m=0,i,j,k=0;
 	cin>>a[0]>>b[0];
 	while( a[n]>=1)
 		{
	 	   a[n+1]=a[n]/2;
		//	cout<< a[n]<<n<<endl;
	 	   n++;
	 	   
  	    }
		while( b[m]>=1)
 		{
	 	   b[m+1]=b[m]/2;
			//cout<<b[m]<<m<<endl;
	 	   m++;
  	    }
   for (i=0;i<=n;i++)
   {
   	   for (j=0;j<=m;j++)
   	   {
	   	   if (a[i]==b[j])
	   	   {  cout <<a[i];k=1;
		   	  break;
  			  }
	  }
	  if (k==1)	  break;
}

}
int finder(int a,int b)
{
	int c;
	for(;a;a=a/2)
		for(c=b;c>=a;c=c/2)
			if(a==c)
			{
				printf("%d",c);
				return 0;
			}
}

int main()   
{   
	int a,b,c,d;
	scanf("%d%d",&a,&b);
	finder(a,b);  
	return 0;
}
int main()
{  int x,y,a[100],b[100],i,j,ka,kb;
scanf("%d%d",&x,&y);
a[1]=x;
b[1]=y;
i=1;
j=1;
while(a[i]!=1)
{i++;
a[i]=a[i-1]/2;
}

while(b[j]!=1)
{j++;
b[j]=b[j-1]/2;
}
for(ka=1;ka<=i;ka++)
{for(kb=1;kb<=j;kb++)
{	 if (a[ka]==b[kb])
{       printf("%d\n",a[ka]);
        break;
}
if (a[ka]==b[kb]) break;
}
if (a[ka]==b[kb]) break;
}


	return 0;
}
int main()
{
	int x,y,i,j,m=0,n=0,t;
	int a[1000],b[1000];
	scanf("%d %d",&x,&y);
	a[0]=x;b[0]=y;
		for(i=1;a[i-1]!=1;i++)
		{
			a[i]=x/2;
			x=x/2;
			m=m+1;
		}
		for(j=1;b[j-1]!=1;j++)
		{
			b[j]=y/2;
			y=y/2;
			n=n+1;
		}
		
		
		for(i=0;i<m;i++){
			for(j=0;j<n;j++) {
				if(a[i]==b[j]){
					t=1;
					break;
				}
			}
			if(t==1) {
				break;
			}
		}
		printf("%d\n",a[i]);
		return 0;
}
/*
 * hanshudigui2.cpp
 *
 *  Created on: 2010-11-24
 *      Author: hanzhe
 */


int f(int x,int y){       //??????????
	int g=0;              //g=1?????????
	for(int i=0;;i++){    //??????(x/2^n)=(y/2^m)
		for(int j=0;(y/pow(2.0,j))>=1;j++)
			if((int)(x/pow(2.0,i))==(int)(y/pow(2.0,j))){
				return x/pow(2.0,i);
				g=1;
				break;
			}
	if(g==1)break;
	}
}
int main(){
	int n1,n2;
	cin>>n1>>n2;
	cout<<f(n1,n2);
	return 0;
}                        //????
int y[1000]={0};
int *p,*q;
int z[1000]={0};

int* count1(int n)
{int i,j,k,m,l;
	i=0;
	while(n!=0)
	{   y[i]=n;
		n=n/2;
		
		i++;
	}
	return y;
}
int* count2(int x)
{int i,j,k,m,l;
	i=0;
	while(x!=0)
	{   z[i]=x;
		x=x/2;
		
		i++;
	}
	return z;
}
int compare()
{
	int i,j;
	for(i=0;i<1000;i++)
	{
		for(j=0;j<1000;j++)
		{
			if(*(p+i)==*(q+j)) goto MM;
		}
	}
MM:
	return *(p+i);
}
void main()
{
	int i,j,s,t,c;
	
	scanf("%d%d",&s,&t);
	p=count1(s);
	q=count2(t);
	c=compare();
	printf("%d\n",c);
scanf("%d",&c);
}
void main()
{
	int x,y;
	int i,k,j;
	int n=0,m=0;
	int a[10],b[10];
	scanf("%d %d",&x,&y);
	if(x%2==0)
	{
		a[0]=x;
		for(i=1;a[i-1]!=1;i++)
		{
			if(a[i-1]%2==0)
			{
				a[i]=a[i-1]/2;
			}
			else
			{
				a[i]=(a[i-1]-1)/2;
			}
			n++;
		}
	}
	else
	{
		a[0]=x;
          for(i=1;a[i-1]!=1;i++)
		{
			if(a[i-1]%2==0)
			{
				a[i]=a[i-1]/2;
			}
			else
			{
				a[i]=(a[i-1]-1)/2;
			}
			n++;
		}
	}
	if(y%2==0)
	{
		b[0]=y;
		for(i=1;b[i-1]!=1;i++)
		{
			if(b[i-1]%2==0)
			{
				b[i]=b[i-1]/2;
			}
			else
			{
				b[i]=(b[i-1]-1)/2;
			}
			m++;
		}
	}
	else
	{
		b[0]=y;
          for(i=1;b[i-1]!=1;i++)
		{
			if(b[i-1]%2==0)
			{
				b[i]=b[i-1]/2;
			}
			else
			{
				b[i]=(b[i-1]-1)/2;
			}
			m++;
		}
	}


	for(j=0;j<=n;j++)
	{
		for(k=0;k<=m;k++)
		{
			if(a[j]==b[k])
				goto label;
		}
	}
     label:
	printf("%d\n",b[k]);

}
int main()
{
	int m,n;
	scanf("%d%d",&m,&n);
	while(m!=n)
	{
		if(m>n)
			m=m/2;
		else n=n/2;
	}
	printf("%d",m);
	return 0;
}
int f(int a,int n)
{
	if (n==1) return a;               //????
	else return f(a,n-1)/2;
}
int main()
{
	int a,b,i,j,t=1;
	cin>>a>>b;
	for (i=1;f(a,i)>=1;i++)
		for (j=1;f(b,j)>=1;j++)          //???????????
			if (f(a,i)==f(b,j))
			{
				t=(f(a,i)>t? f(a,i):t);         //????????????
				break;
			}
	cout << t <<endl;
	return 0;
}
/*
 * assignment.cpp
 *
 *  Created on: 2010-11-23
 *      Author: ??
 *      ???????
 */


int main(){
	int x,y;
	int i=0,j=0;
	cin>>x>>y;
	while(1){
		if(pow(2,i)>x)
			break;
		i++;
	}
	while(1){
		if(pow(2,j)>y)
			break;
		j++;
	}
	while(i>j){
		x=x/2;
		i--;
	}
	while(i<j){
		y=y/2;
		j--;
	}
	while(1){
		if(x==y)break;
		else{
			x=x/2;
			y=y/2;
		}
	}
	cout<<x;
	return 0;
}
int main()
{
	int a[11]={0},b[11]={0},i=0,j=0,t=0;
	cin>>a[0]>>b[0];
	for(i=1;i<11;i++)
	{
		if(a[i-1]%2==0)
			a[i]=a[i-1]/2;
		else
			a[i]=(a[i-1]-1)/2;
	}
	for(i=1;i<11;i++)
	{
		if(b[i-1]%2==0)
			b[i]=b[i-1]/2;
		else
			b[i]=(b[i-1]-1)/2;
	}
	for(i=0;i<11;i++)
	{
		for(j=0;j<11;j++)
		{
			if(a[i]==b[j])
			{
				cout<<a[i]<<endl;
				t=1;
			    break;
			}
		}
		if(t==1)
			break;
	}
	return 0;
}
/*??
1000012872
 */
int f(int x,int y);//??????????????
int main()
{
	int x,y;
	cin>>x>>y;//x,y?????
	cout<<f(x,y);//????
	return 0;
}
int f(int x,int y)
{
	int m,n,p,q,i,j,c;
	if(x>=1&&y>=1)//
	{
	    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;
	}
	
	
}
void main()
{
	int x,i,y,j,k,l;
    int xn[15],yn[15];
	scanf("%d%d",&x,&y);
	for (i=0;x!=0;i++)
	{
		xn[i]=x;
		x=x/2;
	}
	k=i-1;
	for(i=0;y!=0;i++)
	{
		yn[i]=y;
		y=y/2;
	}
	l=i-1;
	if(xn[0]==yn[0])
		printf("%d",xn[0]);
	else
	{
	for(;;k--)
	{
		if(xn[k]!=yn[l])
		{
			j=k+1;
			break;
		}
		l--;
	}
	printf("%d",xn[j]);
	}



}
int main()
{
    int a,b;
    cin>>a>>b;
    while(1)
    {
        while(a>b)
        {
            a=a/2;
        }
        while(b>a)
        {
            b=b/2;
        }
        if(a==b)  break;
    }
    cout<<a<<endl;
}
int main()
{
	int a[10000]={0},b[10000]={0},i,j,x,y,t;
	scanf("%d%d",&x,&y);
	if(x==y) printf("%d",x);
	else{
	if(x>y)
	{
		t=x;
		x=y;
		y=t;
	}
	for(i=0;;i++)
	{
		a[i]=x;
		x=x/2;
		if (a[i]==0) break;
	}
	for(i=0;;i++)
	{
		b[i]=y;
		y=y/2;
		if (b[i]==0) break;
	}
	for(i=0;;i++)
	{
		for(j=0;;j++)
		{
			if(a[i]==b[j]) break;
			if(b[j]==0) break;
		}
		if(a[i]==b[j]) break;
	}
	printf("%d",a[i]);
	}
	return 0;
}
int main()
{int a[1000],b[1000],i=0,j=0,n,m,loop;
scanf("%d %d",&n,&m);
while(n!=0)
{    a[i]=n;
     n=n/2;
 i++;
}
while(m!=0)
{
b[j]=m;
m=m/2;
j++;
}
for(i=0;i<1000;i++)
{
for(j=0;j<1000;j++)
{
if(a[i]==b[j])
{

goto loop ;
}
else
{
continue;
}

}
}

loop:printf("%d\n",a[i]);
return 0;
}
void main() 
{ 
	int x,y,i,m,n; 
	int a[15]={0},b[15]={0}; 
	
	scanf("%d %d",&x,&y); 
	
	a[0]=x; 
	b[0]=y; 
	
	if(x==y) 
	{ 
		printf("%d\n",x); 
		return; 
	} 
	
	for(i=0;i<11;i++) 
	{ 
		if(a[i]==0) 
		{ 
			m=i-1; 
			break; 
		} 
		
		else 
			a[i+1]=a[i]/2; 
	} 
	
	for(i=0;i<11;i++) 
	{ 
		if(b[i]==0) 
		{ 
			n=i-1; 
			break; 
		} 
		
		else b[i+1]=b[i]/2; 
	} 
	
	for(;;m--,n--) 
	{ 
		if(a[m]!=b[n]) 
			break; 
	} 
	
	printf("%d\n",a[m+1]); 
}
/*
 *????1062 ???
 *?????
 *??: 2010-11-21
 */

int i,j,x,y;
int f(int n,int x){
    if(n==1) return x;
    else return (f(n-1,x)-f(n-1,x)%2)/2;//?????????
}
int main(){
    cin>>x>>y;//????
    for(i=1;i<15;i++)
    	for(j=1;j<15;j++)
    	if(f(i,x)==f(j,y)){//?????????????????????
    		cout<<f(i,x);//??
    		i=15;j=15;//????
    	}
	return 0;
}
//&#202;&#181;&#214;&#202;&#201;&#207;&#202;&#199;&#193;&#189;&#184;&#246;&#182;&#254;&#189;&#248;&#214;&#198;&#202;&#253;&#163;&#172;×&#238;&#182;à&#199;°&#182;à&#201;&#217;&#206;&#187;&#207;à&#205;&#172;&#163;&#172;&#212;ò&#199;°&#182;à&#201;&#217;&#206;&#187;&#182;&#212;&#211;&#166;&#181;&#196;&#182;&#254;&#189;&#248;&#214;&#198;&#202;&#253;&#188;&#180;&#206;&#170;&#203;ù&#199;ó
//&#199;·&#200;±&#211;&#197;&#187;&#175; 



int main()
{
	int x, y, memo;
	cin >> x >> y;
	memo = y;
	do {
		do {
			if (x == y) {
				cout << x;
				return 0;
			}
			y = y >> 1;
		} while (y);
		x = x >> 1;
		y = memo;
	} while (x);
}
int main()
{
	int put(int );
	int min(int ,int );
	int a[10],b[10],a1[10],b1[10];
	int n1,n2,p=0,q=0,i,j=0;
	scanf("%d%d",&n1,&n2);
	for(i=0;;i++)
	{
		a[i]=n1;
		n1=put(n1);
		p++;
		if(n1==0)
			break;
	}
	for(i=0;;i++)
	{
		b[i]=n2;
		n2=put(n2);
		q++;
		if(n2==0)
			break;
	}
	for(i=p;i>0;i--)
	{
		a1[j]=a[i-1];
		j++;
	}
	j=0;
	for(i=q;i>0;i--)
	{
		b1[j]=b[i-1];
		j++;
	}
	for(i=0;i<min(p,q);i++)
	{
		if(a1[i]==b1[i]&&a1[i+1]!=b1[i+1])
		{
			printf("%d",a1[i]);
			break;
		}
	}
	return 0;
}

int put(int a)
{
	int m;
	if(a%2==0)
		m=a/2;
	else
		m=(a-1)/2;
	return m;
}

int min(int a,int b)
{
	int m;
	if(a<b)
		m=a;
	else
		m=b;
	return m;
}
int two(int n)   //?2?n??
{
	int i,sum=1;
	for(i=1;i<=n;i++)
	{
		sum=sum*2;
	}
	return sum;
}

int pand(int x)  //??x????
{
	int i,sign=0,m;
	for(i=1;sign==0;i++)
	{
		if(x>=two(i)&&x<two(i+1))
		{m=i+1;
		 sign=1;}
	}
	return m;
}


int main()
{
	int result,i,sign=0;
	int x,y,lx,ly;
	int xx[20],yy[20];
	scanf("%d%d",&x,&y);
	if(x==1||y==1)
	result=1;
	else if(x==y)
		result=x;
	else
	{
		lx=pand(x);
		ly=pand(y);
		xx[lx-1]=x;
		yy[ly-1]=y;
		for(i=2;i<=lx;i++)
		{
			xx[lx-i]=x/2;
			x=x/2;
		}
		for(i=2;i<=ly;i++)
		{
			yy[ly-i]=y/2;
			y=y/2;
		}

		for(i=0;sign==0;i++)
		{
			if(xx[i]!=yy[i])
			{sign=1;
			 result=xx[i-1];}
		}

	}

	printf("%d",result);
	
	return 0;
}
int turn(int a,int b)
{
	int i,k;
	if(a==b)
		k=a;
	if(a>b)
	{
		k=turn(a/2,b);
	}
	if(a<b)
	{
		k=turn(a,b/2);
	}
	return k;
}
void main()
{
	int a,b;
		scanf("%d%d",&a,&b);
		printf("%d",turn(a,b));
}
int main()
{
	int x,y,i,a[1000]={0};
	scanf("%d %d",&x,&y);
	for(i=1,a[0]=x;;i++)
	{
		if(a[i-1]%2==0)
			a[i]=a[i-1]/2;
		else
			a[i]=(a[i-1]-1)/2;
		if(a[i]==1||a[0]==1)break;
	}
	for(;y>=1;)
	{
		for(i=0;a[i]>=1;i++)
		{
			if(y==a[i])
			{
				printf("%d",a[i]);
				break;
			}
		}
		if(y==a[i])break;
		else
			{
				if(y%2==0)
					y=y/2;
				else
					y=(y-1)/2;
			}
	}
	return 0;
}
void main()
{
	int a(int x,int y);
	int x,y,z;
	scanf("%d %d",&x,&y);
	z=a(x,y);
	printf("%d\n",z);
}

int a(int x,int y)
{
	int m;
	if(x==y) m=x;
	else if(x<y) m=a(x,y/2);
	else m=a(x/2,y);
	return(m);
}
int main()
{
	int x,y;int n1=0;int n2=0;int a[11];int i;
	scanf("%d %d",&x,&y);
	int m;
	m=x;
	while(m!=0)
	{
		a[n1]=m;
		n1++;
		if(m%2==0) m=m/2;
		else m=(m-1)/2;

	}
	m=y;
	while(m!=0)
	{
		for(i=0;i<=n1-1;i++)
		{
			if(a[i]==m) 
			{printf("%d",m);
			return 0;}
		}
		if(m%2==0) m=m/2;
		else m=(m-1)/2;

	}
	return 0;
}
void main()
{
	int found(int x,int y);
	
	int x,y,z;

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

	z=found(x,y);

	printf("%d\n",z);
}

int found(int x,int y)
{
	int i,j,a[10],b[10];
	for(i=0;i<10;i++)
	{
		a[i]=x;
		x=x/2;
	}

	for(i=0;i<10;i++)
	{
		b[i]=y;
		y=y/2;
	}
	
	for(i=0;i<10;i++)
		for(j=0;j<10;j++)
			if(a[i]==b[j])
			{
				return a[i];
				break;
			}
}
int main()
{
	int x,y;    //????x?y???????
	cin>>x>>y;    //??x?y
	void commoninteger(int x,int y);   //????commoninteger
	commoninteger(x,y);    //????commoninteger?????
	return 0;
}

void commoninteger(int x,int y)   //????commoninterger??????x?y???????????
{
	if(x==y)      //??x=y?????????x????
		cout<<x;
	else {
		if(x>y)      //??x>y???x??2???????commoninteger??????y??2???????commoninteger??
			commoninteger(x/2,y);
			else commoninteger(x,y/2);
	}
}
int f(int x ,int y){				//??????????????????
	int p;							//????
	if(x==y) return x;		        //?x=y??????x
	else {							//??
		if(x>y){
			p=x;
			x=y;
			y=p;
		}							//?y????
		if(y%2==0)y=y/2;			
		else y=(y-1)/2;				//?y???????y
		return f(x,y);				//??f(x,y)
    }
}
int main() {						//?????
	int x,y;					    //????
	cin>>x>>y;					    //??x,y
	cout<<f(x,y)<<endl;			    //?????????
	return 0;
}
int main()
{
	int x,y;
	scanf("%d %d",&x,&y);
	int xi,yj;
	int i,j;
	for(i=0;i<15;i++)
	{
		xi=x/(pow(2,i));
		for(j=0;j<15;j++)
		{
			yj=y/(pow(2,j));
			if(yj==xi)
			{	printf("%d\n",yj);
			break;
			}
		}
		if(yj==xi)
			break;
	}
	return 0;

}
/*
 * Homework7.6BinaryTree.cpp
 *
 *  Created on: 2013-11-22
 *      Author: JuiceHe
 */
int main()
{
	int x,y;
	cin>>x>>y;
	int find(int,int);
	cout<<find(x,y)<<endl;
}
int find(int x,int y)
{
	if(x==y)return x;//??????????????
	if(x>y)return (find(x/2,y));//??????????????????????
	else return (find(x,y/2));
}
int main()
{
	int x,y;
	int a[20],b[20],i=0,j=0;
	int k,m,flag=0;
	scanf("%d %d",&x,&y);
	while(x)
	{
		a[i]=x;
		i++;
		x=x/2;
	}
	while(y)
	{
		b[j]=y;
		j++;
		y=y/2;
	}
	for(k=0;k<i;k++)
	{
		for(m=0;m<j;m++)
		{
			if(a[k]==b[m])
			{
				printf("%d",a[k]);
				flag=1;
				break;
			}
		}
		if(flag==1)
			break;
	}
	
}
int jd(int m,int x)
{
	if(m==0)return x;
    if(x==1)return 1;
	else return jd(m-1,x/2);
}
int main()
{
	int a,b;
	cin>>a>>b;
	int n=0;
	for(int i=0;i<=a;i++){
		if(n==1)break;
		for(int k=0;k<b;k++){
			if(jd(i,a)==jd(k,b)){cout<<jd(i,a)<<endl;
			    n=1;
			    break;}

		}}
return 0;
}
void main()
{
	int x,y,a[10]={0},b[10]={0},i,j;
	scanf("%d%d",&x,&y);
	a[0]=x;
	b[0]=y;
	for(i=1;;i++)
	{
		a[i]=a[i-1]/2;
		if(a[i]==1)
			break;
	}
	for(j=1;;j++)
	{
		b[j]=b[j-1]/2;
		if(b[j]==1)
		    break;
	}
	for(i=0;i<10;i++)
	{
		for(j=0;j<10;j++)
		{
			if(a[i]==b[j])
			{
				printf("%d",a[i]);
				break;
			}
			else if(b[j]==1)
				break;
		}
		if(a[i]==b[j])
		{
			break;
		}
		else continue;
	}
}