semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int main()  
{
	char a[101],x;
	int n,i,j=0,m,k,b,g;
	gets(a);
	n=strlen(a);
	x=a[0];
	for(i=0;i<n;i++)
	{
		if(a[i]!=x)
		{
			a[i]=j;
			j=j+1;
		}
	}
	for(j=0;j<(n/2);j++)
	{
		for(i=0;i<n;i++)
		{
 			if(a[i]==j)
			{
				for(k=i-1;k>=0;k--)
				{
					if(a[k]==x)
					{
						a[k]=j;
						break;
					}
				}
			}
		}
	}
	for(j=0;j<(n/2);j++)
	{
		for(i=0;i<n;i++)
		{
			if(a[i]==j)
			{
				b=i;
				break;
			}
		}
		for(i=b+1;i<n;i++)
		{
			if(a[i]==j) 
			{
				g=i;
				break;
			}
		}
		printf("%d %d\n",b,g);
	}
	return 0;
}
/**
* @file 2.cpp
* @author ??
* @date 2010?12?29
* @description
* ??????:????
*/
void solve();
void paixu();
char a[1000], m;
int length, flag[1000] = {0},b[500][2],sum = 0;
int main()
{
	cin >> a;
	length = strlen(a); 
	m = a[0];                                                   //??????
	solve();
	paixu();
	return 0;
}
void solve ()
{
	int i,j;
	for (i=0;i<length-1;i++)
	{
		if (a[i] == m && flag[i] == 0)
		{
			for (j=1;j<length - i;j++)
			{
				if(flag[i+j] == 1)                            //?????????
					continue;
				else
					if(a[i+j] == m)
						break;
					else
					{
						flag[i] = 1;
						flag[i+j] = 1;
						b[sum][0] = i;
						b[sum][1] = i + j;
						sum++;
						break;
					}
			}
		}
	}
	if (flag[0] == 0 )
		solve();                                         //??
}
void paixu()
{
	int i, j, temp;
	for (j=0;j<length/2-1;j++)
	{
		for (i=0;i<length/2-j-1;i++)
		{
			if (b[i][1] > b[i+1][1])
			{
				temp = b[i+1][1];
				b[i+1][1] = b[i][1];
				b[i][1] = temp;
				temp = b[i+1][0];
				b[i+1][0] = b[i][0];
				b[i][0] = temp;
			}
		}
	}                                                   //?????
	for (i=0;i<length/2;i++)
		cout << b[i][0] << " " << b[i][1] << endl;         //??
}
int main()
{  

	int a[100]={0},z=-1;
	char b[100];
	cin.getline(b,100);
	char c=b[0];
	for(int i=0;b[i]!=0;++i)
	{
		if(b[i]==c)
		{
			a[++z]=i;
			
		}
		else
		{
			cout<<a[z]<<" "<<i<<endl;
			--z;
		}
	}
	return 0;
}
char a;
int find(int i)
{
	char c;
	int j=i+1;
	while(1)
	{
		c=getchar();
		if (c==a) j=find(j)+1;
		else
		{
			cout<<i<<' '<<j;
			if(i!=0) cout<<endl;
			break;
		}
	}
	return j;
}
int main()
{
	a=getchar();
	find(0);
	return 0;
}
int function(int begin,int end);
char child[110];
char b,g;
int main()
{
	char s;
	int i=0;
	while((s=cin.get())!='\n'){
		child[i]=s;i++;
	 }
	b=child[0];
	for(int j=1;j<=i;j++)
		if(child[j]!=b)
		  {g=child[j];break;}
	    
	function(0,i-1);

	
	return 0;
}

int function(int begin,int end)
{ 
  int rembegin=begin;
  if(begin+1==end) return 0;
  else {
	  while(child[begin+1]==' ') 
       {begin++;}

     if(child[begin+1]==g){
		 int use=rembegin;
		 while(child[use]==' ')
		    use--;
		 for(int j=use;j<=begin+1;j++)
		    child[j]=' ';
       cout<<use<<" "<<begin+1<<endl;
	   //cout<<child<<" "<<begin<<" "<<use<<endl;
       function(rembegin-1,end);
      }
     else function(rembegin+1,end);
  }
}
int main()
{
	
	int i,len,j,k,count;
	char a[1000],b,g;
	cin>>a;
	b=a[0];
	len=strlen(a);
	count=len/2;
	for(i=1;i<=len-1;i++)
	{
		if(a[i]!=b)
		{
			g=a[i];break;
		}
	}
	for(j=0;j<=len-1;j++)
	{
			if(a[j]==g)
			{
				
				for(k=j-1;k>=0;k--)
				{
					
					if(a[k]=='o')
					{
						continue;
					}
					if(a[k]==b)
					{
						cout<<k<<" "<<j;
						if(count!=0)
						{
							cout<<endl;
						}
						count--;
						a[k]='o';
						a[j]='o';
						break;
					}
				}
			}
	}
	return 0;
}
char line[100];
int line_1[100];
void paidui()
{
	int i=0;
	int m=0;
	int j=0;
	if(line[0]!=' ')
	{
		for(i=0;m==0&&line[i]!='\0';i++)
		{
			if(line[i]==line[0])
			{
				for(j=i+1;line[j]==' ';j++);
				if(line[j]!=line[i])
				{
					cout<<i<<" "<<j<<endl;
					line[i]=' ';
					line[j]=' ';
					m=1;
				}
			}
		}
	}
	m=0;
	paidui();
}
int main()
{
	int i=0;
	for(i=0;i<100;i++)
		line_1[i]=i;
	cin>>line;
	paidui();
	return 0;
}
int main()
{
	char s[101];
	char temp[101][2];
	char t;
	int len,i,j,top=-1;
	memset(temp,0,sizeof(temp));
	gets(s);
	len = strlen(s);
	i=0;
	do
	{
		while(s[i]==s[0]&&s[i])
		{
			top++;
			temp[top][1] = s[i];
			temp[top][2] = i;
			i++;
		}
		printf("%d %d\n",temp[top][2],i);
		top--;
		i++;
	
	}while(top!=-1&&s[i]);

	return 0;
}
int a[10000]={1};
int num;
int cal(int a[]);
int main()
{
	char x,y;
	int k;
	scanf("%c",&x);
	for(k=1;k<=10000;k++)
	{
		scanf("%c",&y);
		if(y=='\n')
		{
			a[k]=-1;
			num=k;
			break;
		}
		if(x==y) a[k]=1;
		else a[k]=0;
	}
	cal(a);
	return 0;
}

int cal(int a[])
{
	int i,j;
	if(a[0]==-1)
		return 0;
	else
	{
		for(i=0;i<=num;i++)
		{
			if(a[i]==0)
			{
				for(j=i;j>=0;j--)
				{
					if(a[j]==1)
					{
						printf("%d %d\n",j,i);
						a[i]=-1;
						a[j]=-1;
						cal(a);
					}
				}
			}
		}
	}
	return 0;
}
// ????,remain??????????
// flag????????
void que(char c[100], int remain,
		 char boy, char girl, int flag) 
{
	int i;
	for(; c[flag] != girl; flag++); // ????????????
	for(i = flag; c[i] != boy; i--); // ???????
	c[i] = 0; // ?????0
	c[flag] = 0;
	cout << i << " " << flag << endl; // ??
	remain -= 2;
    if(remain)  // ???????
		que(c, remain, boy, girl, flag);
}

int main()
{
	char c[100];
	char boy, girl;
	int remain;
	cin >> c;
	remain = strlen(c); // ???
	boy = c[0]; // ????????
	girl = c[remain - 1];
	que(c, remain, boy, girl, 0); // ?flag?0?????
	return 0;
}
int main()
{
	char a[200];
	int judge[200]={0};
	char boy,girl;
	int i,j,last,num=0;
	scanf("%s",a);
	boy=a[0];
	last=0;
	girl=a[strlen(a)-1];
	while(num!=(strlen(a)+1)/2)
	{
		i=1;
		while(num!=(strlen(a)+1)/2)
		{
		if(a[last+i]==boy&&judge[last+i]==0) {last++;break;}
		else if(a[last+i]==girl&&judge[last+i]==0) 
		{printf("%d %d\n",last,last+i);judge[last]=1;judge[last+i]=1;
		while(judge[last]!=0)
		last--;
		num++;break;}
		else i++;
		}
	}
	return 0;
}
int qianshou(char children[],int sign[],int num,int time)
{
    int i=1;int j;int k;
    for(;i<num;i++)
    {
        if(time==num/2-1)
        {
            printf("0 %d",num-1);
            return 0;
        }
        if(sign[i]==1) loop:continue;
        for(k=i+1;;k++)
        {
            if(children[i]==children[k]&&sign[k]!=1) goto loop;
            else if(children[k]!=children[i]&&sign[k]!=1) break;
        }
        sign[i]=1;
        for(j=i;j<num;j++)
        {
            if(children[j]!=children[i]&&sign[j]==0)
            {
                sign[j]=1;
                break;
            }
        }
        printf("%d %d\n",i,j);
        time++;
        break;
    }
    qianshou(children,sign,num,time);
}
int main()
{
    int num;int i;int time=0;
    char children[SIZE];
    gets(children);
    num=strlen(children);
    int sign[num];
    for(i=0;i<num;i++)
        sign[i]=0;
    qianshou(children,sign,num,time);

    return 0;
}
char b,g;
char a[1000];
int l,i;
int main()
{
	cin >> a;
	l=strlen(a);
	b=a[0];
	g=a[l-1];
	int j;
	for(i=0;i<l;i++)
	if(a[i]==g)
		for(j=i-1;j>=0;j--)
			if(a[j]==b)
			{
				cout << j << " " << i << endl;
				a[j]=0;a[i]=0;
					break;
			}
	return 0;
}
char dui[1000];
int i = -1, p = 0, flag[100];
void rankgame(int s)
{
	if(i + 1 == p && p != 0)return;
	cin.get(dui[s]);
	i ++;
	if(dui[s] != dui[0])
	{
		cout << flag[s - 1] << ' ' << i << endl;
		p = p + 2;
		rankgame(s - 1);
	}
	else
	{
		flag[s] = i;
		s ++;
		rankgame(s);
	}	
}


int main()
{
	rankgame(0);
	return 0;
}
int main()
{
	char line[100], boy, girl;
	int i, j, l, k=0, m, n=0, numb[100]={0}, numg[100]={0};
	scanf("%s", line);
	l = strlen(line);
	boy = line[0];
	for(i=0;i<l;i++)
		if(line[i]!=boy){
			girl = line[i];
			break;
		}
    for(i=0;i<l;i++)
		for(j=i;j<l;j++){
			if(line[i]==boy&&line[j]==girl){
				for(m=i+1;m<j;m++)
					if(line[m]!='0')
						n++;
				if(n==0){
				    numb[k] = i;
				    numg[k] = j;
				    k++;
				    line[i] = '0';
				    line[j] = '0';
				    if(line[0]!='0')
			            i=0;
				}
				n=0;
			}
		}
	for(i=0;numg[i]!=0;i++)
		printf("%d %d\n", numb[i], numg[i]);
	return 0;
}
void match( char child[] , int l )
{
	for ( int i = 0 ; i <= l ; i++ )
		if ( child[i] == child[0] )//if he is a boy
		{
			for ( int j = i + 1 ; j <= l ; j++ )
			{
				if ( child[j] == child[0] )//if the next one is a boy
					break ;
				else if ( child[j] != child[0] && child[j] != '\0' )//if the next one is a girl
				{
					child[i] = child[j] = '\0' ;//let them go
					cout << i << " " << j << endl ;//cout
					match ( child , l ) ;//once again
				}
			}
	}
	return ;
}
int main()
{
	char child[101] ;
	cin.getline( child ,101 ) ;
	match( child , strlen( child ) ) ;

	return 0 ;
}
int len,k,m,t;
    char str[101];
int work( int i,int j)
{
if( i == 0 && j == len-1   )
{printf("%d %d",i,j);
return 0;}
else if( str[i] != str[j] && str[i]!= ' ' && str[i] != ' ')
{
  printf( "%d %d\n",i,j );
  str[i]= ' ';str[j] = ' ';
  for( k = i-1;;k-- )
  {if( str[k]!=' ' )break;}
  for( m = j+1;;m++ )
  {if( str[m]!=' ' )break;}
  work( k,m );

}
else if( str[i] == str[j] && str[i]!= ' ' && str[i] != ' ') 
 {   for( t = j+1;t<len;t++ )
     {if( str[t]!=' ' )break;}
     work(j,t);
 } 
}
int main()
{

    int i , j ;
    gets(str);
    len = strlen( str );
    work( 0 ,1);
}
int Boy[100],Girl[100],BoyNum,GirlNum;
char Boychar;
void function(int);
int main()
{
 BoyNum=1;
 GirlNum=0;
 Boy[BoyNum]=0;
 Boychar=cin.get();
 function(1);
 return 0;
}
void function(int p)
{
 char c;
 c=cin.get();
 if(c=='\n')
  return;
 else
  if(c==Boychar)
  {
   Boy[BoyNum]=p;
   BoyNum++;
   GirlNum++;
   function(p+1);
  }
  else
  {
   Girl[GirlNum]=p;
   cout<<Boy[GirlNum]<<" "<<Girl[GirlNum]<<endl;
   GirlNum--;
   BoyNum--;
   function(p+1);
  }
}
int len;
char a, b;
char ren[100];
void run(char ren[100])
{
	int i, j;
	for (i = 0; i < len; i++)
		if (ren[i] == b)
		{
			for (j = i - 1; j >= 0; j--)
				if(ren[j] == a)
				{
					cout << j << " " << i << endl;
					ren[i] = 0;
					ren[j] = 0;
					break;
				}
		}
}
int main()
{
	cin.getline(ren,100);
	len = strlen(ren);
	a = ren[0];
	b = ren[len - 1];
	run(ren);
	return 0;
}
char str[100];
int sex[100]={0}, flag[100]={0};
int requeue(int n)
{
	if(n==0)
	return 0;
    int i, t, l;
	for(i=0;i<n-1;i++)
	{
		if(sex[i]==0 && sex[i+1]==1)
		{
			cout<<i+flag[i]<<" "<<i+1+flag[i+1]<<endl;
			if(i==n-2)
			break;
			else
			{
    			for(t=i+2; t<n; t++)
    			{
    				sex[t-2]=sex[t];
    				flag[t]+=2;
    			}
    			for(t=i;t<n-2;t++)
    			{
                    flag[t]=flag[t+2];              
                }
			    break;
            }
		}
	}	
	return requeue(n-2);
}
int main()
{
	int j, len;
	cin.getline(str,100);
	len=strlen(str);
	for(j=1; j<len; j++)
	{
		if(str[j]==str[0])
		    sex[j]=0;
		else sex[j]=1;
	}
	requeue(len);
	return 0;
}
typedef struct
{
	int boy;
	int girl;
}OUT;

void main()
{
	OUT out[50];
	void sort(OUT *out,int k);
	int i,j,k = 0,len;
	char queue[101],boy,girl;

	gets(queue);
	len = strlen(queue);
	boy = queue[0];
	girl = queue[len - 1];

	while(1)
	{
		for(i = 0;i<len - 1;i++)
		{
			if(queue[i]==boy)
			{
				for(j = i + 1;queue[j]==0;j++);
				//????????
				if(queue[j]==girl)
				{
					queue[i] = 0;
					queue[j] = 0;
					out[k].boy = i;
					out[k].girl = j;
					k++;
					i = j;
				}
				else
					i = j - 1;
			}
		}
		if(k==len/2)
			break;
		//????len/2????????
	}

	sort(out,k);
	//???????
	for(i = 0;i<k;i++)
		printf("%d %d\n",out[i].boy,out[i].girl);
}

void sort(OUT *out,int k)
{
	int i,j,min,minum;
	OUT temp;
	for(i = 0;i<k-1;i++)
	{
		min = out[i].girl;
		minum = i;
		for(j = i + 1;j<k;j++)
		{
			if(min>out[j].girl)
			{
				min = out[j].girl;
				minum = j;
			}
		}
		if(minum - i)
		{
			temp = out[i];
			out[i] = out[minum];
			out[minum] = temp;
		}
	}
}
char s[255],b;

void solve(int l, int r)
{
int c=0, i=l+1, j=l+1;
while (i<r-1) {
  do {
    if (s[i++]==b) c++; else c--;
  } while (c>0);
  solve(j,i-1);
  j=i;
}
printf("%d %d\n", l, r);
}

int main()
{
int l;
scanf("%s", s);
b=s[0];
l=strlen(s)-1;
if (l%2 == 0) l--;
solve(0, l);
return 0;
}
void main()
{
 char a[1000];
 gets(a);
 int n;
 n=strlen(a);
 int b[n];
 int i=0,j=0,c=0,k=0;
 while(i<n)
 {
  b[i]=1;
  i++;
 }
 i=0;
 while(k<n/2)
 {
  c=0;
  if(b[i]==0)
   i++;
  else
  {
   j=i+1;
   while(c==0)
   {
    if(b[j]==0)
     j++;
    else
    {
     if(a[j]==a[i])
      i++,c=1;
     else
     {
      printf("%d %d\n",i,j);
      k++;
      b[i]=0;
      i=0;
      b[j]=0;
      c=1;
     }
    }
   }
  }
 }
}
int main ()
{
	char str[100],a,b;
	cin >> str;
	int len,i,j;
	len = strlen(str);
	a = str[0];
	b = str[len - 1];
	for (i = 0;i < len;i++)
		for (j = i - 1;j >= 0;j--)
		{
			if (str[i] == b && str[j] == a)
			{
				cout << j << ' ' << i << endl;
				str[j] = b;
				break;
			}
		}
	return 0;
}
char b,g,chr[100];
struct
	{
		int num,t;
		char s;
	}ch[100];

void chulie(int a)
{
	int k,m,n;
	if ((ch[a].s==g) && ch[a].t!=0 )	
	{
		for (k=a-1;k>=0;k--)
		{
			if (ch[k].s==b && ch[k].t!=0)
			{
				printf("%d %d\n",ch[k].num,ch[a].num);
				ch[k].t=0;
				ch[a].t=0;
				break;
			}
		}
	}
	if (chr[a+1]!='\0')
		chulie(++a);
}
int main()
{
	
	int nb,ng,i,j,k,l,m;
	scanf("%s",chr);
	b=chr[0];
	for (i=0;chr[i]!='\0';i++)
	{
		ch[i].num=i;
	    ch[i].t=1;
		ch[i].s=chr[i];
	}
	for (i=0;chr[i]!='\0';i++)
	{
		if (chr[i]!=b)
		{
			g=chr[i];
			break;
		}
	}
	chulie(i);
	return 0;
}
int flag = 0;
void f(int i, int j, char str[], char ch)
{
	if (flag == 1)
	{
		return;
	}
	if (i < 0)
	{
		f(j, j + 1, str, ch);
	}
	if (str[i] == str[0])
	{
		if (str[j] == ch)
		{
			cout << i << " " << j << endl;
			if (str[j + 1] == '\0')
			{
				flag = 1;
			}
			str[i] = str[j] = ' ';
			f(i - 1, j + 1, str, ch);
		}
		else
		{
			f(j, j + 1, str, ch);
		}
	}
	else
	{
		f(i - 1, j, str, ch);
	}
}
int main()
{
	char str[200], ch;
	int i, a = 0;
	cin >> str;
	for (i = 0; str[i] != '\0'; i++)
	{
		if (str[i] != str[0])
		{
			ch = str[i];
			f (i - 1, i, str, ch);
			return 0;
		}
	}
}
char a[1000];
int n;

int xx (int k)
{
     int x,y;
     x=k;
     y=k+1;
     while (a[y]==a[x])
     y=xx(y);
     cout <<x<<" "<<y<<endl;
     return y+1;
}
     
int main ()
{
    cin.getline(a,999,'\n');
    n=strlen(a);
    xx(0);
    return 0;
}
void pair(char [],int,int);
int main()
{
	int len,t;
	char s[100];
	scanf("%s",s);
	len=strlen(s);
	t=0;
	pair(s,len,t);
	return 0;
}
void pair(char s[],int len,int t)
{
	int i,j,count=0;
	i=1;
	if(t==len-2) 
		{
			printf("0 %d\n",len-1);
			return;
		}
	while(s[i]==s[0]||s[i]==' ')
	{
		i++;
	}
	for(j=i-1;s[j]==' ';j--)
		count++;
	printf("%d %d\n",i-count-1,i);
	s[i-count-1]=' ';
	s[i]=' ';
	pair(s,len,t+2);
}
int main()
{
	char child[100],a;
	cin >>child;
	a=child[0];
	int i=0,j=0;
	while (child[0]!=0)
	{
		if (child[i]!=a&&child[i]!=0)
		{
			for (j=i-1;j>=0;j--)
				if (child[j]==a)
				{
					cout <<j <<" " <<i <<endl;
					child[i]=0;
					child[j]=0;
					break;
				}
		}
	    i++;
	}

	return 0;
}
char boy,girl;
int len=0;
/*void take_hand(char a[],int i)
{
     if(i==len-1)
     {
       cout<<0<<" "<<len-1;
       return ;
     }
     if(a[i]=='o')
     {
        take_hand(a,i+1);
     }
     if(a[j]==girl)
     {
         cout<<i<<" "<<j<<endl;
         a[i]='o';
         a[j]='o';
     }
     else if(a[j]==boy)
     {
          take_hand(a,j);
     }
     else
     j++;
}*/
int main()
{
    char a[100]={0};
    cin>>a;
    len = strlen(a);
    boy=a[0];
    for(int i=0;i<100;i++)
    {
       if(a[i]!=boy)
       {
          girl = a[i];
          break;
       }
    }
    //take_hand(a,0);
    for(int i=0;i<len-1;i++)
    {
            if(a[i]==girl)
            {
                for(int j=i-1;j>0;j--)
                {
                        if(a[j]==boy)
                        {
                            cout<<j<<" "<<i<<endl;
                            a[j]='\0';
                            break;
                        }
                }
            }
    }
    cout<<0<<" "<<len-1<<endl;
   
    return 0;
}
int l=0;
int main()
{
	int i;
	int count=0;
	char c[100]={"\0"};
	int out(char c[]);
	cin.getline(c,100);
	for (i=0;c[i]!='\0';i++)
		count++;
	l=count;
	out(c);
	return 0;
}
int out(char c[])
{
	int count=0;
	int i,j;
	for (i=0;c[i]!='\0';i++)
		count++;
    if (l==0)
		return 0;	
	else
	for (i=0;i<count;i++)
	{
		if (c[i]==c[count-1])
		{
			for (j=i-1;j>=0;j--)
			{
				if (c[j]=='1')
					continue;
				if (c[j]==c[count-1])
				{	
					break;
				}
				if (c[j]==c[0])
				{
					cout<<j<<' '<<i<<endl;
					c[i]='1';
					c[j]='1';
					l=l-2;
					break;
				}
			}
		}
	}
	out(c);
}
void f(int n,int *a,char *b,char boy, char girl)
{
     int i;
     if(n==2)printf("%d %d\n",*a,*(a+1));
     else
     {
         for(i=0;i<n;i++)
         {
                         if(*(b+i)==boy&&*(b+i+1)==girl)
                         {
                              printf("%d %d\n",*(a+i),*(a+i+1));
                              break;
                         }               
         }
     
         for(;i<n-2;i++)
         {
         *(a+i)=*(a+i+2);
         *(b+i)=*(b+i+2);
         }
         f(n-2,a,b,boy,girl);
     }
}

int main()
{
    int a[1000],geshu,i;
    char b[1000];
    char boy,girl;
    gets(b);
    geshu=strlen(b);
    for(i=0;i<geshu;i++)a[i]=i;
    boy=b[0];
    girl=b[geshu-1];
    f(geshu,a,b,boy,girl);
}
char str[101];
int test(int num,char sex)
{
	if(str[num]!='\0')
	{
		if(str[num]==sex) test(num+1,sex);
		else 
		{
			int i=0;
			for(i=num-1;i>=0;i--)
			{
				if(str[i]==sex)
				{
			 	cout<<i<<" "<<num<<endl;
				str[i]='!';
				 str[num]='!';
				 break;
				}
			}
		}
		test(num+1,sex);
	}
	else return 0;
} 
int main()
{
	cin.getline(str,101);
	char boy=str[0];
	test(1,boy);
	return 0;
}
char xiao[101];
int k = 0;
void zhao( int length )                         //????
{
	int i, j, n, m;
	for( i = 1; i < length; i++ )
	{
		if( xiao[i] == ')' )             //??????????
		{
			m = i;
			xiao[i] = '.';
			k = k + 2;
			break;
		}
	}
	for( j = m - 1; j >= 0; j-- )            //??????????????
	{
		if( xiao[j] == '(' )
		{
			n = j;
			xiao[j] = '.';
			break;
		}
	}
	cout << n << " " << m << endl;         //????
	if( k < length )
	{
		zhao( length );
	}
}
int main()
{
	int length;
	int i;
	cin.getline( xiao, 101 );                  //?????
	length = strlen( xiao );
	for( i = 1; i < length; i++ )
	{
		if( xiao[i] == xiao[0] )
		{
			xiao[i] = '(';            //????????
		}
		else
		{
			xiao[i] = ')';
		}
	}
	xiao[0] = '(';
	zhao( length );                         //????
	return 0;
}
void couple(char a[],int b[],char x,char y)
{
	int i,j,z=0;
	for(i=0;a[i]!='\0';i++)
		if(b[i]==0)
		{
			z=1;
			break;
		}
	if(z==1)
		for(i=0;a[i]!='\0';i++)
			if(a[i]==y&&b[i]==0)
				for(j=0;j<i;j++)
					if(a[i-1-j]==x&&b[i-1-j]==0)
					{
						cout<<i-1-j<<" "<<i<<endl;
						b[i]=b[i-1-j]=1;
						couple(a,b,x,y);
					}
}
int main()
{
	int i,b[101];
	char a[101],x,y;
	cin>>a;
	x=a[0];
	for(i=0;a[i]!='\0';i++)
	{
		b[i]=0;
		if(a[i]!=x)
		{
			y=a[i];
		}
	}
	couple(a,b,x,y);
	return 0;
}
void main ()
{
	char ch[100];
	char male;
	int i;
	int len;

	gets(ch);
	len=strlen(ch);
	male=ch[0];
    for (i=1;i<len;i++)
	{
		if (ch[i]!=male)
		{
			int j=i;
			int n1=0,n2=0;

			for (;j>-1;j=j-1)
			{
				if(n1==n2&&ch[j-1]==male) {printf("%d %d\n",(j-1),i);break;}
				if(ch[j-1]==male) n1++;
				else n2++;
			}
		}
	}
}
/**
* @file homework.cpp
* @author ???
* @date 2011-11-16
* @description
* ??????: ????
*/
void Paidui(char[], int);

int main()
{
	int i, j, k;
	char a[1000];
	cin.getline(a, 1000);
	for (i=1;a[i]!='\0';i++) // ???1????2
	{
		if (a[i]==a[0]) a[i]=1;
		else a[i]=2;
	}
	a[0]=1;
	Paidui(a, 0);
	return 0;
}


void Paidui(char b[], int j)
{
	if (b[j]==2)
	{
		int k;
		for(k=j-1;k>=0;k--)
		{
			if (b[k]==1)
			{
				cout<<k<<" "<<j<<endl;
				b[k]=0;
				b[j]=0;
				break;
			}
		}
	}
	if (b[0]==0) return;
	Paidui(b, j+1);
}
//************************************
//*????????                 **
//*???   1100013009              **
//*2011.11.21                       **
//************************************




int main()       
{
	char a[100000];                                 // ?????a[100000]???????????????
	char b, c;                                      // b????????????c???????????
	int i, pos[100000], pos_i = -1, left = 0;       // ??i??????pos?????????????????
	                                                //  left????????????
	cin.getline(a, 100000);
	for(i = 0; a[i] != '\0'; i++)
	{
		b = a[0];
		if (a[i] != a[0])
		{
			c = a[i];
			break;
		}
	}                                               // ????b?c???
	for (i = 0; a[i] != '\0'; i++)
	{
		if (a[i] == b && a[i + 1] == c)
		{
			cout << i << ' ' << i + 1 << endl;      // ?????????????????????????
			i++;                                    // i???1??????????
		}                                       
		else if (a[i] == b && a[i + 1] == b) 
		{
			pos[++pos_i] = i;                       // ???????????????????????                                   
			left++;                                 // ??left????1
		}
		else if (a[i] == c && left > 0)             // ???????????????????
		{
			cout << pos[pos_i] << ' ' << i << endl; // ????????????????????
			pos_i--;                                // ?????????????
			left--;                                 // ????????????
		}
	}
	return 0;
}
int main()
{
 int l,i,j,k,p;
 char s[10000];
 int a[10000];
 char c,d;
 //int q[10000];
 gets(s);
 l=strlen(s);
 p=l;
 c = s[0];
 d = s[l - 1];
 for(i=0;i<l;i++)
  a[i]=i;
 for(i=0;i<l/2;i++)
 {
  for(j=1;j<p;j++)  
  {
   if(s[j-1]==c&&s[j]==d)
   {
    printf("%d %d\n",a[j-1],a[j]);
    for(k=j+1;k<p;k++)
    {
     s[k-2]=s[k];
     a[k-2]=a[k];                  
    }
    break;                 
   }
  }
  p=p-2;    
 }
 return 0;
}
int main()
{
	char str[110]={0};
	int i=0;
    cin>>str;
	int n,j=0;
	n=strlen(str);
	for(i=0;i<=n;i++)
	{
		if(str[i]!=str[0])
		{
			str[i]=0;
			for(j=i;j>=0;j--)
			{
				if(str[j]==str[0])
				{
					str[j]=0;
					cout<<j<<" ";
					break;
				}
			}
			cout<<i<<endl;
		}
	}   
	 
		return 0;
}
int main(int argc, char *argv[])
{
  int j=1,i,m,e=0,a[101],d,f,u,v;
  char s[101];
  gets(s);
 m=strlen(s);
 u=s[0];
 v=s[m-1];
 for(i=0;i<m;i++)
 {
    if(s[i]==v) 
    {
                 a[e]=i;
                 e++;
    }
}



for(i=0;i<e;i++)
{
        for(j=1;j<m;j++)
        { 
        if(a[i]-j>=0)
        
        {
                  f=0;
                  for(d=a[i]-j;d<=a[i];d++)
                  f=f+s[d];   
               if(f==u+v)
               {
               printf("%d %d\n",a[i]-j,a[i]);
               s[a[i]-j]=0;
               s[a[i]]=0;
               }
        }

} 
}                
  	
  return 0;
}
void kuohao (char str[],int x);
int lenth;
char c;
int main()
{
    char a[10000];
    cin>>a;
    lenth=strlen(a);
    c=a[0];
    kuohao(a,1);
return 0;    
}
void kuohao(char str[],int x)
{
  if(x<lenth)
  {
      if(str[x]!=c)
      {
         int i=x-1,zuo=0,you=0;
         while(1)
         {
           if(str[i]==c)        
                zuo++;
           else 
                 you++;
           if(zuo==you+1)
              break;
           i--;                 
         }
         cout<<i<<" "<<x<<endl;
         kuohao(str,x+1);                          
      }  
       else 
          kuohao(str,x+1);            
  }        
}
int main(){
	char a[110],c;
	int num=0,b[110];
	for(int i=0;;i++){
		cin.get(a[i]);
		if(i==0)c=a[i];
		if(a[i]=='\n')break;
		b[i]=i;
		num++;
		}										//?? 
		int boy[55],girl[55],s=0;
		for(int i=0;i<num/2;i++){
			for(int j=0;j<num-1-i*2;j++){
				if(a[j]!=a[j+1]&&a[j]==c){
					boy[s]=b[j];
					girl[s]=b[j+1];
					s++;						//?????? 
					for(int k=j+2;k<num;k++){
						a[k-2]=a[k];
						b[k-2]=b[k];
						}
					continue;
					}
				}
			}
			for(int i=0;i<num/2-1;i++){
				for(int j=0;j<num/2-1-i;j++){
					if(girl[j]>girl[j+1]){
						int p,q;
						p=boy[j];
						boy[j]=boy[j+1];
						boy[j+1]=p;
						q=girl[j];
						girl[j]=girl[j+1];
						girl[j+1]=q;
						}
					}
				}							//???? 
				for(int i=0;i<num/2;i++){
					cout<<boy[i]<<" "<<girl[i]<<endl;
					}
			
			return 0;
	}