semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
void main()
{
	void print(char *x,int *y,int z);
	char s[100],*p;
	int a[100],i,n,*q;

	scanf("%s",s);
	p=s;
	n=strlen(s);
	for(i=0;s[i];i++)
		a[i]=i+1;
	q=&a[0];

	print(p,q,n);
}

void print(char *x,int *y,int z)
{
	int i,j,k;
	for(k=0;k<z/2;k++)
	{
    	for(i=0;*(x+i);i++)
		{
	    	if(*(x+i)!=*(x+i+1))break;
		}
		printf("%d %d\n",*(y+i)-1,*(y+i+1)-1);
		
		for(j=i+2;*(x+j);j++)
		{
            *(x+j-2)=*(x+j);
		   	*(y+j-2)=*(y+j);
		}
	}
}
int main()
{
  char c[100],sex;
  scanf("%s",c);
  int i,j,k=0,x[100],y[100],a,b,n;  
  n=strlen(c);
  sex=c[0];
  for(i=n;i>=0;i--)
  {
      a=0;b=0;
      if(c[i]!=sex)
      {
             for(j=i;j>=0;j--)
             {
                  if(c[j]==sex)
                  {
					  a++;
                  }
                  else
                  {
					  b++;
				  }
                  if(a==b)
                  {
                          x[k]=j;
                          y[k]=i;
                          k++;
                          break;
                  }
             }      
      } 
  }
  for(i=k-1;i>=0;i--)
  {
       printf("%d %d\n",x[i],y[i]);
  }
  return 0;
}
int i;
char row[100];
int match(int x)
{
int y;
if(x==i)
   return 1;
if(row[x]==row[0])
   y=match(x+1);
   else
   return x;
cout<<x<<" "<<y<<endl;
return match(y+1);
}
int main()
{
cin>>row;
i=strlen(row);
match(0);
return 0;
}
int l;
struct stu
{int num;
int sex;}a[100];
int main()
{char s[101],p;
int i,j,L,k;
scanf("%s",s);
l=strlen(s);
p=s[0];
for(i=0;i<l;i++)
{if(s[i]==p)
a[i].sex=1;
else
	a[i].sex=2;
a[i].num=i;}
L=l/2;
for(i=0;i<L;i++)
{for(j=0;j<l;j++)
{k=j+1;
while(a[k].sex==0)
{k++;}
	if(a[j].sex==1&&a[k].sex==2)
{printf("%d %d\n",a[j].num,a[k].num);
a[j].sex=a[k].sex=0;
break;}}}}
/* title :????*
* author : ???*
* time : 2011.11.9 */


char c[100];
char boy;
int n, current;

int tell(int num)
{
	int num2;
	if(num == n - 1)
		return num;
	if(c[num] == boy)
	{
		num2 = tell(num + 1);
		while(num2 == -1)
			num2 = tell(current + 1);
		cout << num << " " << num2 << endl;
		return -1;
	}
	else
	{
		current = num;
		return num;
	}
}


int main()
{
	int m;
	cin >> c;
	boy = c[0];
	n = strlen(c);
	m = tell(0);
	return 0;
}
int main()
{
 int l,i,j,k,p;
 char s[10000];
 int a[10000];
 char c,d;
 scanf("%s",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=0;j<p-1;j++)  
  {
   if(s[j]==c&&s[j+1]==d)
   {
    printf("%d %d\n",a[j],a[j+1]);
    for(k=j+2;k<p;k++)
    {
     s[k-2]=s[k];
     a[k-2]=a[k];                  
    }
    break;                 
   }
  }
  p=p-2;    
 }
 getchar();
 getchar();
 return 0;

}
char sex[2];

void check(char line[], int n)
{
	int i;
	if (n == strlen(line) - 1)
	{
		cout << 0 << ' ' << n << endl;
		exit (0);
	}
	else
	{
		if (line[n] != sex[1])
			check(line, n + 1);
		else
		{
			for (i = n - 1; i >= 0; i--)
			{
				if (line[i] == sex[0])
				{
					cout << i << ' ' << n << endl;
					line[i] = ' ';
					line[n] = ' ';
					break;
				}
			}
		}
		check(line, n + 1);
	}
}

int main()
{
	char line[501];
	cin.getline(line, 501);
	sex[0] = line[0];
	sex[1] = line[strlen(line) - 1];

	check(line, 1);

	return 0;
}
void pei(char a[250])
{
	int t=strlen(a);
	int i;
	for(i=0;i<t-1;i++)
	{
		if(a[i]=='}')
		{
			int s=i-1;
			while(a[s]=='0')
				s--;
			while(a[s]!='{')
				s--;
			a[s]='0';
			a[i]='0';
			printf("%d %d",s,i);
			printf("\n");
		}
		else
			if(a[i]==')')
			{
			int s=i-1;
			while(a[s]=='0')
				s--;
			while(a[s]!='(')
				s--;
			a[s]='0';
			a[i]='0';
			printf("%d %d",s,i);
			printf("\n");
		}
			else
				if(a[i]==']')
			{
			int s=i-1;
			while(a[s]=='0')
				s--;
			while(a[s]!='[')
				s--;
			a[s]='0';
			a[i]='0';
			printf("%d %d",s,i);
			printf("\n");
		}
				else
						if(a[i]=='>')
			{
			int s=i-1;
			while(a[s]=='0')
				s--;
			while(a[s]!='<')
				s--;
			a[s]='0';
			a[i]='0';
			printf("%d %d",s,i);
			printf("\n");
		}



	}
	i=0;
printf("%d %d",i,t-1);
}
void main()
{
	char a[250];
	gets(a);
	pei(a);
}
int main()
{
	char m,f,p,l,a[100];
	int i,j;
	scanf("%s",a);
	m=a[0];
	for(i=0;i<strlen(a);i++)
		if(a[i]!=m)
			f=a[i];
	p=0;
	for(i=0;i<strlen(a)/2;i++)
		for(j=1;j<strlen(a);j++)
		{
			l=j;
			if(a[l]==f)
			{
				printf("%d %d\n",p,l);
				a[p]='|';
				a[l]='|';
				p=0;
				break;
			}
			else if(a[l]==m)
			{
				p=l;
			}
		}
	
	return 0;
}
char a[100];
void f(char a[], int n)
{
	int flag = 0, i, h = 0, k, sum = 1, m;
	for (i = 1; i <= n - 1; i ++)
	{
		switch (a[i])
		{
		case '(': 
			{
				m = 1; 
				break;
			}
		case ')': 
			{
				m = -1; 
				break;
			}
		case '*': 
			{
				m = 0; 
				break;
			}
		}
		sum = sum + m;
		switch (sum)
		{
		case 2: 
			{
				sum = sum - 1; 
				k = i;
				h = 1;
				break;
			}
		case 1:
			break;
		case 0:
			{
				flag = 1;
				if (h == 1)
				{
					cout << k << " " << i << endl;
					a[k] = '*';
					a[i] = '*';
				} 
				else
				{
					cout << "0 " << i << endl;
                }
			}
		}
		if (flag == 1)
			break;
	}
}

int main()
{
	int n, q = 0;
	cin >> a;
	n = strlen(a);
	for (q = 1; q <= n-1; q ++)
	{
		if (a[q] == a[0])
			a[q] = '(';
		else
			a[q] = ')';
	}
	for (q = 1; q <= (n/2); q ++)
		f(a, n);
	return 0;
}
int main(int argc, char* argv[])
{
	char a[1000],x,y;
	int i=0,j,n,k=1;
	while(scanf("%c",&a[i])==1)
	{
		if(k&&a[i]!=a[0])
		{
			y=a[i];
			k=0;
		}
		i++;
	}
	n=i-1;
	x=a[0];
	for(i=0;i<n;i++)
	{
		if(a[i]==y&&a[i]!=0)
		{
			for(j=i-1;j>=0;j--)
			{
				if(a[j]==x) 
				{
					printf("%d %d\n",j,i);
					a[j]=0;
					a[i]=0;
					break;
				}
			}
		}
	}

}
void print(char str[100])
{
	int stack[100];
	int i,j=0;
	int la;
	la=strlen(str);
	for(i=0;i<la;i++)
	{
		if(str[i]==str[0])
			stack[j++]=i;
		else if(str[i]!=str[0])
		{
			cout<<stack[j-1]<<' '<<i<<endl;
		    j--;
		}
	}
}
int main()
{
	char str[101];
	cin.getline(str,101);
	print(str);
	return 0;
}
char str[101],boy,girl;
void paidui();
int l;
int main()
{
	cin.getline(str,101);
	boy=str[0];
	for(int i=1;;i++)
	{if(str[i]!=boy) {girl=str[i];break;}}
	for(int i=0;str[i]!='\0';i++)
		l=i;
	for(int i=0;i<=l;i++)
	{paidui();}
	cout<<0<<' '<<l;
	return 0;
}
void paidui()
{
	for(int i=1;i<l;i++)	
	{	if(str[i]==boy)
		{
			int x=1;
			while(str[i+x]=='\0'){x++;}
			if(str[i+x]==girl)
			{cout<<i<<' '<<i+x<<endl;
			str[i]=str[i+x]='\0';
			break;}
		}
	}
}
int i,Husband[50]={0};
int marry( char engage[] );
int main()
{
	int t;
	char engage[100],couple[100];
	cin>>engage;
	i=strlen( engage );
	for ( t=0 ; t<i ; t++ )
		couple[t]=engage[t];
	marry( engage );
	for ( t=1 ; t<i ; t++ )
	{
		if ( couple[t]!=couple[0] )
			cout<<Husband[t]<<" "<<t<<endl;
	}
    return 0;
}
int marry( char engage[] )
{
	int j,k;
	for ( j=1 ; j<i ; j++ )
	{
		if ( engage[j]!=engage[0]&&engage[j]!='X' )
		{
			k=j-1;
			while ( engage[k]=='X' )
				k--;
			if ( engage[k]==engage[0] )
			{
			    Husband[j]=k;
				engage[j]='X';
				engage[k]='X';
				if ( k==0 )
					return 0;
			}
		}
	}
	marry( engage );
}
char a[1000];
int match(char,char);
int main()
{
	char b, g; int i;
	cin >> a; 
	b= a[0];
	for (i = 0; i <= 999; i++)
		if(a[i] != b)
		{
			g = a[i];
			break;
		}
	match( b, g);
	return 0;
	}

int match(char b, char g)
{
	int i, j;
	for ( i = 0; a[i] != '\0'; i++)
		if(a[i] == g)
			break;
	if(a[i]=='\0')
		return 0;
	for ( j=i; j>=0; j--)
		if(a[j] == b)
		{
			cout<<j<<' '<<i<<endl;
				break;
		}
	a[j]='*'; 
	a[i]='*';
	match( b,g);
}
/* title :????*
* author : ???*
* time : 2011.11.9 */


int a[100][2];
char c[100];
char b;
int n;

void combine(char c[], int i)
{
	int m, j, k;
	m = strlen(c);
	for(j = 0; j < m; j++)
	{
		if(c[j] != b && c[j] != ' ')
		{
			c[j] = ' ';
			a[i][1] = j;
			for(k = j - 1; k >= 0; k--)
			{
				if(c[k] == b)
				{
					a[i][0] = k;
					c[k] = ' ';
					break;
				}
			}
			break;
		}
	}
	if(i < n / 2 - 1)
		combine(c, i + 1);
}
	

int main()
{
	int j, k, t;
	cin >> c;
	n = strlen(c);
	b = c[0];
	combine(c, 0);
          for(j = 0; j < n / 2; j++)
	{
		cout << a[j][0] << " " << a[j][1] << endl;
	}
	return 0;
}
//*****************************************************************
//????????????????                            *
//????wayne                                                   *
//?????11.25                                                 *
//*****************************************************************
int len;
char str[1001];
char boy,girl;           //???????????????
void operate();
int main()
{
	cin>>str;            //?????
	boy=str[0];          //?????????
	int i;
	len=strlen(str);     //????
	for (i=1;;i++)
		if (str[i]!=boy)  //??????????
		{
			girl=str[i];  //??????girl
			break;        //????????
		}
	operate();            //????
	return 0;
}
void operate()
{
	int i,j;
	for (i=0;i<=len-2;i++)
	{
		if (str[i]==boy)                    //????????
		{
			for (j=i+1;j<=len-1;j++)
			{
				if (str[j]==' ')  continue;   
				else if (str[j]==girl)       //???????????
				{
					cout<<i<<" "<<j<<endl;   //????????
					str[i]=' ';
					str[j]=' ';              //????????????????
					operate();               //??????
				}
				else break;
			}
		}
	}
}
char str[101];

void match(int, char, char);

int main()
{
	cin.getline(str,101);
	char b = str[0];   //??????
	int len = strlen(str);
	char g = str[len - 1];   //??????
	match(0, b, g);
	return 0;
}

void match(int i, char b, char g)
{
	int j;
	if (str[i] == '\0')
		return;
	if (str[i] == g)
	{
		str[i] = '*';
		for (j = i - 1; j >= 0; j--)
		{
			if (str[j] == b)
			{
				str[j] = '*';
				break;
			}
		}
		cout << j << " " << i << endl;
	}
	match(i + 1, b, g);
	return;
}
//***************************************************
//*   ????1000012846_2.cpp  *********************
//*   ?????  ***********************************
//*   ?????2010?12?  *************************
//*   ?????????  ***************************                          
//***************************************************
//????????????????????????????????3????????????????????k????k???????????????????????
void Output ( char a[100] , int k , int b[100] )
{
	int i = 0 , j ;  //????i?j
	if ( k == 0 )   //??0????????????
		return ;
	else
	{
		while ( a[i] == a[0] )
			i++ ;                //??????????
		cout << b[i-1] << " " << b[i] << endl ;     //???????????????????
		for ( j = i - 1 ; j < k - 2 ; j++ )   //???????????????
		{
			a[j] = a[j+2] ;
			b[j] = b[j+2] ;
		}
		Output ( a , k - 2 , b ) ;   //??????
	}
}
int main()
{
	int i , len , b[100] ;  //i??????len????????,?????????b[]??????????
	char a[100] ;
	cin >> a ;
	len = strlen(a) ;
	for ( i = 0 ; i < len ; i++ )
		b[i] = i ;
	Output ( a , len , b ) ;    //????
	return 0 ;
}
void e(int,int);
char a[100];
int main()
{
	int i=0;
	cin.getline(a,100);
	while(a[i]!='\0')
	{
		i++;
	}
	e(0,i-1);
	return 0;
}
void e(int b,int c)
{
	int t=0,j=0;
	if(b==c-1)
		cout<<b<<" "<<c<<'\n';
	else
	{
		j=b;
		while(1)
		{
			if(a[j]==a[0])
				t++;
			if(a[j]==a[c])
				t--;
			if(t==0)
				break;
			j++;
		}
		if(j==c)
		{
			e(b+1,c-1);
			cout<<b<<" "<<c<<'\n';
		}
		else
		{
			e(b,j);
			e(j+1,c);
		}
	}
}
int f(char s[],int l)
{
	int u;
	for(u=0;u<l;u++)
		if(s[u]!=' ') return 1;
	return 0;
}

void peidui(char s[],int l,int a[],int b[],char boy)
{
	int u,flag,k,ii;
	for(u=0;u<l;u++)
		if(s[u]==boy&&s[u+1]!=boy)//?????????????
		{
			for(k=u+1;k<l;k++)
			{
				if(s[k]==boy) {flag=0;break;}//????????
				if(s[k]!=boy&&s[k]!=' ')//??????
				{
					s[u]=' ';s[k]=' ';
					for(ii=0;;ii++)
						if(a[ii]==-1) {a[ii]=u;b[ii]=k;break;}//????????????a?b?
						break;
				}
			}
		}

}

void main()
{
	char s[101];
	scanf("%s",s);
	int l;
	char boy;
	boy=s[0];
	l=strlen(s);//?????
	int a[51],b[51];
	int i;
	for(i=0;i<51;i++)
	    a[i]=b[i]=-1;
	while(f(s,l)!=0)//?????????
		peidui(s,l,a,b,boy);
	int pp;
	int x,y,z;
	for(x=1;x<=l/2-1;x++)
		for(y=0;y<=l/2-1-x;y++)
			if(b[y]>b[y+1]) 
			{ 
				z=b[y];b[y]=b[y+1];b[y+1]=z;
				z=a[y];a[y]=a[y+1];a[y+1]=z;
			}
	for(pp=0;;pp++)
	{
		if(a[pp]==-1) break;
		else printf("%d %d\n",a[pp],b[pp]);
	}
}
int main()
{
	int N,Number[2000];
	char C[2000];
	int Top = 0;
	gets(C);
	N = strlen(C);
	for (int I = 0; I < N; I ++)
	{
		if (C[I] != C[0])
		{
			cout << Number[Top] << " " << I << endl;
			Top --;
		}
			else Number[++Top] = I;
	}
}
int main()
{
    char st[1000]; cin.getline(st,1000);
char a=st[0];
    int count=0,z[1000];
    for (int i=1;i<=strlen(st);i++)
        if (st[i-1]==a) {count++; z[count]=i;}
        else {cout<<z[count]-1<<' '<<i-1<<endl; z[count]=0; count--;}

    return 0;
}
int panduan(char a[],char b,char g)
{
	int l,bj,gj,bs,gs,i,k,t;
	l=strlen(a);
	bj=0;gj=0;bs=0;gs=0;
	k=l-1;
	while(a[k]!=b&&a[k]!=g)
		k--;
	for(i=k;i>=0;i--)
	{
		if(a[i]==b)
			bj++;
		else if(a[i]==g)
			gj++;
		if(bj==gj)
		{
			bs=i;
			gs=k;
		    break;
		}
	}
	t=100*bs+gs;
		return (t);
}
int main()
{
	char d[100];
	int n,length,m,i,j,t,k;
	char boy,girl;
	int weishu[100][2];
	cin>>d;
	length=strlen(d);
	boy=d[0];
	girl=d[length-1];
	for(n=0;n<length/2;n++)
	{
		m=panduan(d,boy,girl);
		weishu[n][0]=m/100;
		weishu[n][1]=m%100;
		d[m/100]='0';
		d[m%100]='0';
	
	}
	for(j=0;j<n-1;j++)
	{
		for(i=0;i<n-1-j;i++)
		{
			if(weishu[i][1]>weishu[i+1][1])
			{t=weishu[i][1];weishu[i][1]=weishu[i+1][1];weishu[i+1][1]=t;
			m=weishu[i][0];weishu[i][0]=weishu[i+1][0];weishu[i+1][0]=m;
			}
		}
	}
	for(i=0;i<length/2;i++)
		cout<<weishu[i][0]<<" "<<weishu[i][1]<<endl;
	return 0;
}
void main()
{
	int i,j,l;
	char a[100],p;
	scanf("%s",a);
	p=a[0];
	l=strlen(a);
	for(i=1;i<l;i++)
	{
		if(a[i]!=p)
		{
			for(j=i;j>=0;j--)
			{
				if(a[j]==p)
				{
					printf("%d %d\n",j,i);
					a[j]=0;
					break;
				}
			}
		}
	}
}
int queue[110];
int l;
int num[110];
void f(int x[],int y)
{
	int j,k=0;
	for(j=0;j<y;j++)
	{
		if(x[j]==1)
		{
			num[k] = j;
			k++;
		}
		else if(x[j]==0)
		{
			k--;
			cout<<num[k]<<" "<<j<<endl;
		}
	}
}
int main()
{
	char game[110];
	int i;
	cin>>game;
	l = strlen(game);
	for(i=0;game[i]!=0;i++)
	{
		if(game[i]==game[0])
		{
			queue[i] = 1;
		}
		else
		{
			queue[i] = 0;
		}
	}
	f(queue,l);
	return 0;
}
int main()
{
    void paixu(char num[10000]);
    char num[10000];
    cin.getline(num,10000);
    paixu(num);
    return 0;
}
void paixu(char num[])
{
    char boy,girl;
    int i=0,j,k;
    boy=num[0];
    while(num[i]!='\0')
    {
        if(num[i]!=boy&&num[i]!=' ')
        {
            girl=num[i];
            break;
        }
        i++;
    }
    while(num[i]!='\0')
    {
        if(num[i]!=boy)
        {
            for(j=i-1;;j--)
            {
                if(num[j]!=' ')
                {
                    cout<<j<<" "<<i<<endl;
                    break;
                }
            }
            num[j]=' ';
            num[i]=' ';
            break;
        }
        i++;
    }
    if(num[0]!=' ')
    {
        paixu(num);
    }
}
void main()
{
	int i,j=0,p[50];
	char s[100],c1,c2;
	gets(s);
	c1=s[0];
	for(i=0;i<50;i++)
		p[i]=0;
	for(i=1;i<strlen(s)/2+1;i++)
		if(s[i]!=c1){
			c2=s[i];
			break;
		}
	for(i=0;i<strlen(s);i++){
		if(s[i]==c1)
			p[j++]=i;
		else
			printf("%d %d\n",p[j---1],i);
	}

}
int main ()
{
	int i=0,j,d[1000],total,temp;
	char c[1000];
	while (cin>>c[i])
	{i++;d[i]=0;}
	total=i;
	for (i=0;i<(total/2);i++)
	{
		for (j=0;j<total;j++)
		{
			if (d[j]==0)
			{
				if (c[j]==c[total-1])
				{
					temp=j;
					d[j]=1;
					do
					{j--;}
					while
					(d[j]==1);
					cout<<j<<" "<<temp<<endl;
					d[j]=1;
					break;
				}
			}
		}
	}
	return 0;
}

//??????????????????
//???????????????
//????????????????????????
//?????????????????
int main()
{
    char chn[120];
    int i,l;
    int z,t;
    char a,b;
    scanf("%s",chn);
    l = strlen(chn);
    a = chn[0];
    for(i = 0;i < l ;i ++)
       if(chn[i] != a)
          b = chn[i];
    while(1)
    {
      z = -1;
      t = 0;
      for(i = 0;i < l; i++)
      {
        if(z == -1 && chn[i] == a)
           z = i;
        else if(z >= 0 && chn[i] == b)
          {
             printf("%d %d\n",z,i);
             chn[z] = 0;
             chn[i] = 0;
             t ++;        
             break;
          }        
        else if(z >= 0 && chn[i] == a)
          z = i;
      }     
      if(!t) break;
    }
    
 return 0;    
}
struct bg
{
	int b;
	int g;
};

int main()
{
	char peo[101]={0},e;
	int i,j,k=0,l;
	struct bg bag[50];

	gets(peo);

    l=strlen(peo);
	e=peo[l-1];
	for(i=1;i<l;i++)
	{
		if(peo[i]==e)
		 for(j=i-1;j>=0;j--)
				  if(peo[j]!='\0')
					  { bag[k].b=i;
		                bag[k].g=j;
						k++;
						peo[i]='\0';
						peo[j]='\0';
				        break;}
	}
		for(i=0;i<k;i++)
			printf("%d %d\n",bag[i].g,bag[i].b);

		return 0;
	}
void operation(char str[]);
int num=0;
char boy,girl;
int main()
{
  char str[100];//?50???????????
  cin>>str;
  boy=str[0];
  int i;
  for(i=0;str[0]!='\0';i++)
  {
    if(str[i]!=boy)
{
girl=str[i];
break;
}
  }
  //cout<<boy<<girl;
  operation(str);
  return 0;
}
void operation(char str[])
{
  int i,j;
  int counter=0;
  for(i=0;str[i]!='\0';i++)
  {
    if(str[i]==boy)
{
  for(j=i+1;;j++)
  {
if(str[j]==boy)
break;
    if(str[j]==girl)
{
cout<<i<<" "<<j<<endl;
        str[i]='e';
        str[j]='e';
        counter=1;
        num++;
break;
}
  }
}
if(counter==0)
continue;
else
break;
  }
  if(num<strlen(str))//strlen?????????????
  operation(str);
}
int num[101]={0};                                     //?????????,(??????)???????????

void lashou(char *str)
{
	int i,j,len;
	len=strlen(str);
	if(len==2){
		cout<<num[0]<<' '<<num[1];
		return;
	}
	for(i=0;str[i+1]!='\0';i++){
		if(str[i]==str[0] && str[i+1]!=str[i]){       //????????,???????????
			cout<<num[i]<<' '<<num[i+1]<<endl;        //????
			for(j=i+2;str[j]!='\0';j++){              //?????,??????????
				str[j-2]=str[j];
				num[j-2]=num[j];}
			str[j-2]='\0';
			break;
		}
	}
	lashou(str);
}

int main()
{
	char str[101];
	int flag[101]={0},i,len;
	cin.getline(str,101);
	for(i=0;i<strlen(str);i++)
		num[i]=i;
	lashou(str);
	return 0;
}
main()
{
	char x[500],b,g;
	int y[500],i,j,n,a;
	gets(x);
	n=strlen(x);
	a=n;
	for(i=0;i<n;i++) y[i]=1;
	b=x[0];g=x[n-1];
	for (i=0;i<n&&a!=0;i++)
	{
		if (x[i]==b&&y[i])
		{
			for(j=1;y[i+j]==0;j++){}
			if (x[i+j]==g) 
			{
				y[i]=0;y[i+j]=0;
				printf("%d %d\n",i,i+j);
				i=-1;j=0;
				a-=2;
			}
		}
	}
}
int main(int argc, char* argv[])
{
char string[101];
scanf("%s",string);
int len=strlen(string);
int i;
int a[100]={0};
int num=0,j;
for(i=0;i<len;i++){
	if(string[i]==string[0]) {
		a[num]=i;
		num++;}
	if(string[i]!=string[0]){
		for(j=num-1;j>=0;j--){
			if(a[j]!=-1) {
				printf("%d",a[j]);
				a[j]=-1;
				break;
			}
		}
		printf(" %d\n",i);
	}
	
}


	return 0;
}
/*????*/
void doit(char a[],int n)
{
	int i,j;
	for(i=1;i<n;i++)
	{
		if(a[i]!=a[0]&&a[i]!='\0')break;
	}
	for(j=i-1;j>-1;j--)
	{
		if(a[j]==a[0])break;
	}
	printf("%d %d\n",j,i);
	a[j]='\0',a[i]='\0';
	if(a[0]!='\0')doit(a,n);
}

void main()
{
	char a[100];
	int n;
	scanf("%s",a);
	n=strlen(a);
	doit(a,n);
}
char a[1000];//????? 

int xx (int k)
{
     int 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');
    xx(0);
    return 0;
}
/*
 *?????
 *???2010 - 12 - 31
 *?????????    ????
 */
char line[101];
char boy;
char girl;
int sign[101] = {0};
int len;
void answer(int);
int main()
{
	cin.getline(line,101);
	int i;
	len = strlen(line);
	boy = line[0];             //??????????boy
	for(i = 1; i < len; i++)
	{
		if(line[i] != boy)
		{
			girl = line[i];         //????????boy?????Girl??????????????????
			break;
		}
	}
	answer(i);
	return 0;
}
void answer(int g)
{
	int i,j;
	for(i = g; i < len; i++)
	{
		if((sign[i] == 0)&&(line[i] == girl))               //???????sign???????????????
		{
			sign[i]++;
			for(j = i; j >= 0; j--)
			{
				if((sign[j] == 0)&&(line[j] == boy))
				{
					sign[j]++;
					cout << j << " " << i << endl;
					answer(i);                              //?????????????
					break;
				}
			}
		}
	}
	return;
}
// *******************
// ** ????.cpp  **
// ** ID 1000012895 **
// ** ???        **
// ** 2010 12 259   **
// *******************
char sign1, sign2;                                 // ????????????????
void go_out(char line[], int len)                  // ??go_out
{
	int temp;
	for(int i = 0; i < len - 1; i++)               // ????
		if(line[i] == sign1)                       // ????????
		{
			temp = i + 1;
			while(line[temp] == '@')               // ??????????????@?????????temp????????@?
			{temp++;}
			if(line[temp] == sign2)                // ????????????????????????????@?????
			{
				cout << i << ' ' << temp << endl;
				line[temp] = line[i] = '@';
				return;                            // ?????
			}                                      // ???????????????????????????
		}
	return;
}

int main()
{
	char line[1000];
	int len;
	cin.getline(line,1000);                        // ???????
	sign1 = line[0];                               // ???????????????sign1?
	int temp = 1;
	while(line[temp] == sign1)
		temp++;
	sign2 = line[temp];                            // ???????sign1?????????????????sign2
	len = sizeof(line);
	while(line[0] == sign1)                        // ???????????????????
	{
		go_out(line, len);
	}
	return 0;
}
/**
* @file homework.cpp
* @author ???
* @date 2011-11-16
* @description
* ??????: ????
*/
void Paidui(char[], int);

int main()
{
	int i;
	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;
}

// ?????b????j????????????
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); // ??????
}
int main()
{
    int i,j,k,n;
    char a[100],b,g;
    cin.getline(a,100);
    for(n=0; a[n]!='\0'; n++);
    b=a[0];
    for(i=0; a[i]==b; i++);
    g=a[i];
    for(i=0; i<n/2; i++)
    {
        for(j=0; a[j]!=g; j++);
        for(k=j; a[k]!=b; k--);
        cout<<k<<" "<<j<<endl;
        a[k]='0';
        a[j]='0';

    }
    return 0;
}
int dg(int l);

char a,st[1000];

int main()
{
    cin>>st; a=st[0]; 
    int h=0,z[100];
    for (int i=1;i<=strlen(st);i++)
    {
        if (st[i-1]==a) {h++; z[h]=i;}
           else {cout<<z[h]-1<<' '<<i-1<<endl; z[h]=0; h--;}
    }

    return 0;
}
int find(char a,int b,int c);
int main()
{
	char d;
	scanf("%c",&d);
	find(d,0,1);
//	return 0;
}
int find(char a,int b,int c)
{
	char t;
    scanf("%c",&t);
	while(t==a)
	{
		c=find(a,c,c+1);
		scanf("%c",&t);
	}
	printf("%d %d\n",b,c);
	return c+1;
}
//***********************************************************************************************************
//*  ??????? 													   									*
//*  ??????????????????????????????????????????????????   *
//*  ???????					   																		*
//*  ???2010?12?29?																					*
//***********************************************************************************************************
char g_str[1000];									//?????
int g_num[1000] = {0};								//????
void rank(int m);									//????
int main()
{
	int length, i;									//????
	cin.getline(g_str, 1000);						//?????
	length = strlen(g_str);							//????????
	for (i = 0; i <= length; i++)					//?????
		g_num[i] = i;
	rank (length);									//??????
	return 0;
}
//????????????????????????????????m?????????
void rank(int m)
{
	int i, j;
	if (m == 0)										//??m?0??????
		return;
	else
	{
		for (i = 0; i < m; i++)						//??????????
		{
			if (g_str[i] != g_str[i + 1])			//??????????????????????
			{
				cout << g_num[i] << ' ' << g_num[i + 1] << endl;
				for (j = i; j <= m - 2; j++)		//??????????
				{
					g_str[j] = g_str[j + 2];
					g_num[j] = g_num[j + 2];
				}
				break;
			}
		}
		rank(m - 2);								//??????????????
	}
}