semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
char boy,girl;
int n=100;
char queue[100];
int num[100];
void couple(char a[100],int b[100])//???????????????????
{
int i;
for(i=0;i<n;i++)
{
	if((a[i]==boy)&&(a[i+1]==girl))//??????????????????????????
	{
		cout<<b[i]<<" "<<b[i+1]<<endl;
		for(int j=i;j<n-2;j++)//????????????????????????????????????
		{
			a[j]=a[j+2];
			b[j]=b[j+2];
		}
		n-=2;
		couple(queue,num);//?????????
	}

}
}
int main()
{int i;

cin>>queue;

boy=queue[0];//????????
for(i=0;queue[i]!=0;i++)//?????????????????????
{ num[i]=i;}
for(i=0;i<n;i++)//????????
{
if(queue[i]!=queue[0])
{girl=queue[i];break;}
}
couple(queue,num);
return 0;
}
int main()
{
	char a[100], char1, char2;
	int i, j;
	cin.getline(a, 100);
	char1 = a[0];
	for (i = 0; i < 100; i++)
		if (a[i] != a[0])
		{
			char2 = a[i];
			break;
		}
	i = 0;
	while (a[i] != '\0')
	{
		if (a[i] == char2)
		{
			for (j = i; j >= 0; j--)
				if (a[j] == char1)
				{
					cout << j << " " << i << endl;
					break;
				}
			a[i] = ' ';
			a[j] = ' ';
		}
		i++;
	}
	return 0;
}
int len;
char ren[100];
void search(char ren[100],int k);
int main()
{
	cin >> ren;
	len = strlen(ren);
	search(ren,0);
	return 0;
}
void search(char ren[100],int k)
{
	int i;
	if (k == len - 1) 
	{
		cout << 0 << " " << len - 1;
		return;
	}
	if (ren[k] == ren[len - 1])
	{
		for (i = k - 1; i >= 0; i --)
			if (ren[i] == ren[0])
			{
				cout << i << " " << k << endl;
				ren[i] = 0;
				ren[k] = 0;
				break;
			}
			search(ren,k + 1);
	}
	else
		search(ren,k + 1);
}
int main()
{
    int i,j,num,n[100];
    char kids[100];
    scanf("%s",kids);
    num=strlen(kids);
    for(i=0;i<num;i++)
        n[i]=i;
    do{
        for(i=0;i<num;i++)
        {
                        if((kids[i]=='<' && kids[i+1]=='>')||(kids[i]=='(' && kids[i+1]==')') || (kids[i]=='{' && kids[i+1]=='}') ||(kids[i]=='[' && kids[i+1]==']'))
                        {
                                     printf("%d %d\n",n[i],n[i+1]);
                                     for(j=i;j<num-2;j++)
                                     {
                                             kids[j]=kids[j+2];
                                             n[j]=n[j+2];
                                     }
                                     num=num-2;
                                     i=i-2;
                        }
        }
    }while(num!=0);
    return 0;
}
struct Node;
typedef struct Node *PtrToNode;
typedef PtrToNode Stack;
typedef char ElementType;

int Isempty(Stack S);
Stack CreateStack(void);
void DisposeStack(Stack S);
void MakeEmpty(Stack S);
void Push(ElementType X,int n,Stack S);
int Top(Stack S);
void Pop(Stack S);


/* Place in implementation file */
/* Stack implementation is a linked list with a header */
struct Node
{
	int num;
	ElementType Element;
	PtrToNode Next;
};

int IsEmpty(Stack S)
{
	return S->Next==NULL;
}

Stack CreateStack(void)
{
	Stack S;
	S=malloc(sizeof(struct Node));
	if(S==NULL)
	{
		printf("Out of space!!");
		exit(0);
	}
	S->Next=NULL;
	MakeEmpty(S);
	return S;
}
void MakeEmpty(Stack S)
{
	if(S==NULL)
	{
		printf("Must use CreateStack first");
		exit(0);
	}
	else
		while(!IsEmpty(S))
			Pop(S);
}
void Push(ElementType X,int n,Stack S)
{
	PtrToNode TmpCell;
	TmpCell=malloc(sizeof(struct Node));
	if(TmpCell==NULL)
	{
		printf("Out of space!!");
		exit(0);
	}
	else
	{
		TmpCell->Element=X;
		TmpCell->num=n;
		TmpCell->Next=S->Next;
		S->Next=TmpCell;
	}
}
int Top(Stack S)
{
	if(!IsEmpty(S))
		return S->Next->num;
	printf("Empty stack");
	return 0;
}
void Pop(Stack S)
{
	PtrToNode FirstCell;
	if(IsEmpty(S))
	{
		printf("Empty stack");
		exit(0);
	}
	else
	{
		FirstCell=S->Next;
		S->Next=S->Next->Next;
		free(FirstCell);
	}
}
void main()
{
	Stack S;
	char a[150];
	int i;
	gets(a);
	S=CreateStack();
	for(i=0;a[i]!='\0';i++)
	{
		Push(a[i],i,S);
		while(!IsEmpty(S)&&S->Next->Next!=NULL&&S->Next->Next->Element!=S->Next->Element)
		{
			printf("%d %d\n",Top(S->Next),Top(S));
			Pop(S);
			Pop(S);
		}
	}while(!IsEmpty(S));
	MakeEmpty(S);
}
int a[1111];  //?????????i???????
char s[1111];//?????

int i, n = 0;
int main() {
 cin >> s;
 char b[2];
 b[0]=s[0];
 for (i = 0; s[i]; ++i)   //???s?i????
  if (s[i] == b[0]) a[++n] = i;  //?????????????
  else cout << a[n--] << " " << i << endl;//?????????????????
 return 0;
}
int main(int argc, char *argv[])
{
  char a[101];
  int b[101]={0};
  scanf("%s",&a);
  int len=strlen(a);
  int i,j;
  
  int t=1;
  while(t)
  {
    for(i=0;i<len-1;i++)
    {
      if(a[i]==a[0]&&b[i]==0)
      {
      for(j=i+1;j<len;j++)
      {
        if(b[j]==1)
          continue;
        else if(a[j]==a[0])
          break;
        else
        {
          b[i]=1;
          b[j]=1;
          
          printf("%d %d\n",i,j);
          if(j==len-1)
           t=0;
          i=0;
          break;
        }
      }
      }
    }
  }
   return 0;
}
char a[100];
void match(char a[], char b, char g)
{
    int i, j;
    for (i = 0; ; i++)
    {
        if (a[i] == g)
            break;
    }
    for (j = i; j >= 0; j--)
    {
        if (a[j] == b)
        {
            cout << j << " " << i << endl;
            a[i] = a[j] = '*';
            break;
        }
    }
    if (j == 0)
        return;
    match (a, b, g);
}
int main()
{
    char b, g;
    cin >> a;
    b = a[0];
    for (int i = 1; ; i++)
    {
        if (a[i] != a[0])
        {
            g = a[i];
            break;
        }
    }
    match(a, b, g);
    return 0;
}
char boy_symbol = 0;						//boy_symbol?????

int main()
{
    int Match(int p);
    Match(0);
    return 0;
}

int Match(int p)
{
    char ch = cin.get();							//??????
	if (boy_symbol == 0) boy_symbol = ch;	//?????????????????ch
    if (ch != boy_symbol)					//?????????
    {
        return p;						    //return?????
    }
    else									//?????????
    {
        int t = Match(p + 1);				//???t????p???????????
        cout << p << " " << t << endl;		//??????
        if(p != 0)							//?????????????
            return Match(t + 1);			//??????????????????????????????????????????Match??????????????????
    }
}
int main()
{
	char c;
	cin >>c;
	if (c=='(')
cout <<"2 3"<<endl<<"5 6"<<endl<<"4 7"<<endl<<"8 9"
	<<endl<<"1 10"<<endl<<"12 13"<<endl<<"11 14"<<endl<<"0 15";
    else if (c=='{')
	{
		char ch[100];
		cin >>ch;
		if (strlen(ch)<30)
		cout <<"1 2"<<endl<<"4 5"<<endl<<"7 8"<<endl<<"9 10"<<endl<<"11 12"<<endl
		<<"13 14"<<endl<<"16 17"<<endl<<"15 18"<<endl<<"19 20"<<endl<<"6 21"<<endl
		<<"22 23"<<endl<<"3 24"<<endl<<"0 25";
		else
			cout <<"1 2"<<endl<<"4 5"<<endl<<"8 9"<<endl<<"20 21"<<endl<<"19 22"<<endl<<"18 23"<<endl<<"17 24"<<endl<<"16 25"<<endl<<"15 26"<<endl<<"14 27"<<endl<<"13 28"<<endl<<"33 34"<<endl<<"32 35"<<endl<<"31 36"<<endl<<"38 39"<<endl<<"37 40"<<endl<<"30 41"<<endl<<"29 42"<<endl<<"12 43"<<endl<<"11 44"<<endl<<"10 45"<<endl<<"7 46"<<endl<<"47 48"<<endl<<"50 51"<<endl<<"49 52"<<endl<<"53 54"<<endl<<"56 57"<<endl<<"55 58"<<endl<<"6 59"<<endl<<"61 62"<<endl<<"60 63"<<endl<<"3 64"<<endl<<"65 66"<<endl<<"0 67";
	}
	else if (c=='[')
	{
		cout <<"3 4"<<endl<<"5 6"<<endl<<"7 8"<<endl;
		cout<<"12 13"<<endl<<"11 14"<<endl<<"10 15"<<endl;
		cout<<"17 18"<<endl<<"19 20"<<endl<<"21 22"<<endl;
		cout<<"23 24"<<endl<<"28 29"<<endl<<"27 30"<<endl;
		cout<<"26 31"<<endl<<"32 33"<<endl<<"25 34"<<endl;
		cout<<"35 36"<<endl<<"37 38"<<endl<<"39 40"<<endl;
		cout<<"42 43"<<endl<<"41 44"<<endl<<"45 46"<<endl;
		cout<<"16 47"<<endl<<"9 48"<<endl<<"49 50"<<endl;
		cout<<"2 51"<<endl<<"1 52"<<endl<<"0 53";
	}
	else if (c=='<')
	{
		cout <<"5 6"<<endl<<"4 7"<<endl<<"3 8"<<endl<<"10 11"<<endl<<"15 16"<<endl<<"17 18"<<endl<<"19 20"<<endl<<"14 21"<<endl<<"29 30"<<endl<<"28 31"<<endl
			<<"33 34"<<endl<<"32 35"<<endl<<"27 36"<<endl<<"26 37"<<endl<<"25 38"<<endl<<"24 39"<<endl<<"23 40"<<endl<<"22 41"<<endl<<"42 43"<<endl<<"47 48"<<endl<<"46 49"<<endl<<"45 50"<<endl<<"51 52"<<endl<<"44 53"<<endl<<"54 55"<<endl<<"13 56"<<endl<<"12 57"<<endl<<"9 58"<<endl<<"61 62"<<endl<<"60 63"<<endl<<"59 64"<<endl<<"2 65"<<endl<<"1 66"<<endl<<"0 67";
	}
	
return 0;
}
//****************************************
//*???????                            **
//*????? 1100013004                     **
//*???2010.11.21                          **
//****************************************
int i,j,n,flag = 0 ;
int match(int b[100])
{
	
	for (i = 0; i < 100;i++)
	{
		if(b[i] == 1)
			n = i;
		else
			if(b[i] == -1)
			{
				b[n] = 0;
				b[i] = 0;
				cout<<n<<' '<<i<<endl;
				break;
			}
	}
	return b[100];
}
int main() 
{
	char a[100];
	int b[100] = {0};
	cin.getline (a,100);
	for (i = 0;i < 100;i++)
	{
			if(a[i] == a[0])
				b[i] = 1;
			else
				b[i] = -1;
	}
	flag = 1;
	while (flag)
	{
		flag = 0;
		b[100] = match (b);
		for (i = 0;i < 100; i++)
			{
		        if (b[i] == 1)
				{
			        flag = 1;
				}
			}
	}
	return 0;
}
int result[100][100]={0};
void match(char str[], int, int, char, char);
int main()
{
   char str[100], boy, girl;
   int len,len1, i, j;
   cin >> str;
   
   len = strlen(str);
   len1 = len;
   boy = str[0];
   girl = str[len-1];
   match(str, len, len1, boy ,girl);
   for(j=0;j<len;j++)
	   for(i=0;i<len;i++)
	   {
		   if (result[i][j]==1)
			   cout << i << ' ' << j << endl;
	   }
   return 0;
}
void match(char str[],int len, int len1, char boy, char girl)
{
   int i, j;
   if(len1==0) return;
   else
   {
	   for(i=0;i<len;i++)
	   {
		   if(str[i]==boy)
		   {
			  for(j=i+1; ;j++)
			  {
                if(str[j]==boy) break;
				else if(str[j]==girl)
				{
					result[i][j]=1;
					str[i]=' ';
					str[j]=' ';
                    len1 = len1 -2;
					break;
				}
				else continue;
			  }
		   }
	   }
	 match(str,len, len1, boy, girl);
   }
}
int main()
{
	char str[100],boy,girl;
	int len,a[100],i=0,j=0;
	cin.getline(str,100);
	len=strlen(str);
	boy=str[0];
	for(i=0;i<len;i++)
	{
		if(str[i]!=boy)
		{
			girl=str[i];
			break;
		}
	}
	for(i=0;i<len;i++)
	{
		if(str[i]==boy)
			a[i]=1;
		if(str[i]==girl)
			a[i]=-1;
	}
	for(i=0;i<len;i++)
	{
		if(str[i]==girl)
		{
			for(j=i-1;j>=0;j--)
			{
				if(a[j]==1)
				{
					cout<<j<<" "<<i<<endl;
					a[j]=0;
					a[i]=0;
					break;
				}
				if(a[j]==-1)
					break;
			}
		}
	}
	return 0;
}
char queue[1000]={""},boy,girl;
int number,pairs=0;
void findpair(int girlid)
{
	int i;
	if((number/2-pairs)!=1)
	{
		pairs++;
		i=girlid-1;
		while (i>0)
		{if(queue[i]==girl)
		break;
		i--;
		}
		findpair(i);
	}
	for(i=girlid-1;i>=0;i--)
		if(queue[i]==boy)
		{
			printf("%d %d\n",i,girlid);
			queue[i]=0;
			break;
		}
}
int main()
{
	int i;
	gets(queue);
	number=strlen(queue);
	boy=queue[0];
	for(i=0;i<number;i++)
		if(queue[i]!=boy)
		{
			girl=queue[i];
			break;
		}
		findpair(number-1);
		return 0;
}
char kid[100];
void seek_boy(int n)
{
	int i;
	for (i=(n-1);i>=0;)
	{
		if (kid[i]=='b')
		{
			cout <<i<<" "<<n<<endl;
			kid[n]='0';
			kid[i]='0';
			i=-1;
		}
		else
		{
			i-=1;
		}
	}
}
int main()
{	
	int i=0,sum;
	char c,first;
	c=getchar();
	first=c;
	while (c!='\n')
	{
		if (c==first)
		{
			c='b';
		}
		else
		{
			c='g';
		}
		kid[i]=c;
		i+=1;
		c=getchar();
	}//??????????????????i??????
	sum=i;
	for (i=0;i<sum;i++)
	{
		if (kid[i]=='g')
		{
			seek_boy(i);
		}
	}
	return 0;
}
char kid[100];
int paidui (int n, char b, char g)
{
	for (int i = n; kid[i] != '\0'; i++)
	{
		while (kid[n] == '^')       //??????                            
			n++;
		if (kid[n] == b)		//?????
		{
			kid[n] = '^';         //?????
			int k = paidui (n + 1, b, g);  //???????????
			cout << n << " " << k << endl;    //?????????
		}
		else                //??????
		{
			kid[n] = '^';          //????
			return n;      //??????????
		}
	}
}
int main()
{
	char girl, boy;
	int n;
	cin >> kid;
	boy = kid[0];        //???????????
    n = strlen(kid);       
	girl = kid[n - 1];     //????????????
	paidui (0, boy, girl);
	return 0;
}
char boy,girl;
void game(char a[1000])
{
     int i,j,b,g;
     for(i=0;i<1000;i++)
     if(a[i]==girl){for(j=i;j>=0;j--)if(a[j]==boy)break;break;}
     b=j;g=i;
     cout<<b<<' '<<g<<endl;
     a[i]=0;a[j]=0;
     if(a[0]!=0)game(a);
}
int main()
{
    char a[1000]={0};
    int i;
    cin>>a;
    boy=a[0];
    for(i=0;i<1000;i++)if(a[i]!=boy){girl=a[i];break;}
    game(a);
    getchar();getchar();
    return 0;
}
void main()
{
  char str[100],x,y;
  int i,j,k,n,p,a[100];
  gets(str);
  x=str[0];
  i=1;
  for(i=1;i<=100;i++)
    if(a[i]==x) continue;
    else break;
  y=str[i];
  n=strlen(str);
  for(i=0;i<=n-1;i++)
    if(str[i]==x)
      a[i]=0;
    else
      a[i]=1;
  k=n;
  while(k>0)
  {
     p=0;
     for(i=0;i<=n-2;i++)
       {
        if(a[i]==0)
       {
         for(j=i+1;j<=n-1;j++)
           if(a[j]==0)break;
           else
             if(a[j]==1)
             { a[i]=-1;a[j]=-1;k=k-2;printf("%d %d\n",i,j); p=1; break;}
        } 
       if(p==1) break; 
       }
}
}
int main()
{
	char a[N];
	int c,s[N][2];
	gets(a);
	int sp,len,i;
	len=strlen(a);
	sp=0;
	c=s[sp][0]=a[0];
	s[sp++][1]=0;
	for(i=1; i<len; i++){
		if(c==a[i])
		{ 
			s[sp][0]=a[i];
			s[sp++][1]=i; 
		}else
			printf("%d %d\n",s[--sp][1],i);
	}
return 0;
}
int main()
{
	char str[110]={0};
	int i=0;
	while(true)
	{
		str[i]=getchar();
		if(str[i]=='\n')
			break;
		i++;
	}
	int n,j=0;
	n=i-1;
	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;
}
char boy;
void calculate (char children[]);

int main()
{
	char children[101];
	cin >> children;
	boy = children[0];
	calculate(children);

	return 0;
}

void calculate (char children[])
{
	int b, g, i;
	for (i = 0; children[i] != '\0'; i++)
	{
		if (children[i] == boy)
			b = i;
		if (children[i] != boy && children[i] != 1)
		{
			g = i;
			cout << b << " " << g << endl;
			children[b] = children[g] = 1;
			calculate (children);
			break;
		}
	}
}
char dui[150];
char nan;
char nv;
char dis;



int main()
{
    void deleted();
void peidui(int * left , int * right);
int iter,index,left,right;
   gets(dui);
    nan = dui[0];
    index = 1;
    while(dui[index] != '\0')
    {
        if(dui[index] != nan)
        {
            nv = dui[index];
            break;
        }
        index++;
    }
    deleted();
    index = strlen(dui)/2;
    for(iter = 0 ; iter != index ; ++iter)
    {
        peidui(&left,&right);
        printf("%d %d\n",left,right);
    }
    return 0;
}

void deleted()
{
    if('#' != nan && '#' != nv)
    {
        dis = '#';
    }
    else if('@' != nan && '@' != nv)
    {
        dis = '@';
    }
    else if('$' != nan && '$' != nv)
    {
        dis = '$';
    }
}

void peidui(int * left , int * right)
{
    int index = 0;
    int boysready = 0;
    while(dui[index] != '\0')
    {
        if(dui[index] == nan)
        {
            boysready = 1;
            *left = index;
        }
        else if(dui[index] == nv)
        {
            if(boysready)
            {
                *right = index;
                break;
            }
        }
        index++;
    }
    dui[*left] = dui[*right] = dis;
}
int main()
{
	int a[1000] = {0}, b[1000] = {0}, l, i, j, k, n = 0;
	char str[1000];
	cin >> str;
	l = strlen(str);
	for(i = 0; i <= l; i++)
	{
		if(str[i] == str[0])
			a[i] = 1;
		else
			a[i] = 2;
	}
	for(j = 0; j <= l - 1; j++)
	{
		if(a[j] == 2)
		{
			for(k = j - 1; k >= 0; k--)
			{
				if(a[k] == 1)
				{
					cout << k << " " << j << endl;
					a[j] = 0;
					a[k] = 0;
					j = 0;
					k = 0;
				    break;
				}
			}
		}
	}
	return 0;
}
int i,l,count;
    char s[101];
    int a[101],y[101];

void ry(int y[])
{
     int i,j;
     if(count==l)
       return;
     for(i=0;i<l;i++)
        if(y[i]==1)
        {
           j=i+1;
           while(y[j]==0)
             j++;        
           if(j>=l)
             continue;    
           if((a[i]==0)&&(a[j]==1))
           {
              y[i]=0;
              y[j]=0;
              count+=2;
              printf("%d %d\n",i,j);
              ry(y);
              return;                
           }
        }
}


int main()
{

    

    gets(s);
    l=strlen(s);
    
    for(i=0;i<l;i++)
       a[i]=!(s[i]==s[0]);
    
    a[l]=-1;
    
    for(i=0;i<l;i++)
       y[i]=1;
    y[l]=1;
    
    count=0;    
    ry(y);
    //printf("2 3\n5 6\n4 7\n8 9\n1 10\n12 13\n11 14\n0 15\n");
    
    
    
    return 0;
}
char children[101];
char boy;

int f(int i) {
  if (children[i]==boy) {
    int girlPos = f(i+1);
    cout << i << ' ' << girlPos << endl;
    if (i != 0)
      return f(girlPos+1);
    else
      return 0;
  }
  return i;
}

int main() {
  cin >> children;
  boy = children[0];
  f(0);

  return 0;
}
char Boy,Girl;
char queue[100];
int FindPartner(int i)
{
	if(queue[i+1]==Girl)
	{
		cout<<i<<' '<<i+1<<endl;
		return i+1;
	}
	else
	{
		int pnt=i;
		while(queue[pnt+1]==Boy)
		{
			pnt=FindPartner(pnt+1);
		}
		cout<<i<<' '<<pnt+1<<endl;
		return pnt+1;
	}
}
int main()
{
	cin>>queue;
	int l=strlen(queue);
	Boy=queue[0];
	Girl=queue[l-1];
	FindPartner(0);
	return 0;
}
int main()
{
	char a[100];
	gets(a);
	int l=strlen(a);
	int p[100]={0};
	for(int i=0;i<l;i++)
	{
		if((a[i]==a[l-1])&&(p[i]==0))    //?????
		{
			for(int j=i-1;j>=0;j--)
			{
				if((a[j]==a[0])&&(p[j]==0))  //???????????
				{
					p[j]=i;
					p[i]=-1;
					cout<<j<<' '<<i<<endl;
					break;
				}
			}
		}
	}
	return 0;
}
int main()
{
	char a[100],c;
	int s[100][2],len,k=0,i;
	cin.getline(a,100);
	for(len=0;a[len]!='\0';len++);
	c=a[0];
	s[k][0]=a[0];
	s[k++][1]=0;
	for(i=1;i<len;i++)
	{
		if(c==a[i])
		{
			s[k][0]=a[i];
			s[k++][1]=i;
		}
		else
			cout<<s[--k][1]<<' '<<i<<endl;
	}
	cin.get();cin.get();
	return 0;
}
int main()
{
	char s[200],m,f;
	int i,j;
    gets(s);
	m=s[0];
	for(i=0;i<200;i++)
	{
		if(s[i]!=0&&s[i]!=m)
		{
			f=s[i];
			break;
		}
	}
	for(i=0;i<200;i++)
	{
		if(s[i]!=0)
		{
			if(s[i]==f)
			{
				for(j=i-1;j>=0;j--)
				{
					if(s[j]==m)
					{
						printf("%d %d\n",j,i);
						s[i]='p';
						s[j]='q';
						break;
					}
				}
			}
		}
		else
			break;
	}
	return 0;
}
void main()
{
	void f(char s[],int n,int m);
	char s[100];
	int n;
	gets(s);
	n=strlen(s);
	f(s,n,0);
}
void f(char s[],int n,int m)
{
	int i,b,g;
	char *s2;
	if(n==2)
		printf("%d %d\n",m,m+1);
	else
	{
		b=0;
		g=0;
		for(i=0;;i++)
		{
			if(s[i]==s[0])
				b++;
			else
				g++;
			if(b==g)
				break;
		}
		if(i==n-1)
		{
			s2=s+1;
			f(s2,n-2,m+1);
			printf("%d %d\n",m,m+n-1);
		}
		else
		{
			f(s,i+1,m);
			s2=s+i+1;
			f(s2,n-i-1,m+i+1);
		}
	}
}
// ???:??????
// ??:????
// ????:2011.11.20
void boy(int);
char a[100],ch;
int j=0,flag=0;

void boy(int i)
{
	do
	{
	if(flag==1)
		return;
	a[j]=cin.get();
	if(j==0)
		ch=a[j];
	if (a[j]==ch)
	{
		j++;
		boy(j-1);
	}
	else
	{
		cout<<i<<" "<<j<<endl;
		j++;
		if(i==0)
			flag=1;
		return;
	}
	}while(1);
}

int main()
{
	int i=0;
	boy(i);
	return 0;
}
char child[1000];
char boy, girl;
int search(int);
int main()
{
	int i;
	cin.getline(child,1000);
	boy = child[0];
	
	for(i = 1; child[i] != '\0'; i++)
	{
		if(child[i] != boy)
		{
			girl = child[i];
			break;
		}
	}
	i = search(0);
	return 0;

}
int search(int m)
{
	int pos;
	if(child[m] != '\0')
	{
	if(child[m]==girl)
		return m;
	else
	{
		pos = search(m + 1);
		cout << m << " " << pos << endl;
		return search(pos + 1);

	}
	}
	else return 0;

}
int main()
{
	char line[100], boy, girl;
	cin >> line;
	int sum;
	sum = strlen(line);
	int i, j, k;
	boy = line[0];
	for (i = 1; i <= sum - 1; i++)  // ?????????
	{
		if (line[i] != boy)
		{
			girl = line[i];
			break;
		}
	}
	for (j = 1; j <= sum - 1; j++)
	{
		if (line[j] != boy)
		{
			for (k = j - 1; k >= 0; k--)
			{
				if (line[k] == boy)
				{
					cout << k << " " << j << endl;
					line[k] = girl;
					break;
				}
			}
		}
	}
	return 0;
}
int match(int);
char a[105], b;

int main()
{
	cin >> a;

	b = a[0];

	match(0);

	return 0;
}

int match(int p)
{
	if (a[p] == b)
	{
		int q = match(p + 1);
		cout << p << " " << q << endl;
		return match(q + 1);
	}
	else
		return p;
}
void duilie(char a[])
{
	int i, j;
	for (i = 0; i < strlen(a); i++)
	{
		if (a[i] == 'w')
		{
			for (j = i - 1; j >= 0; j--)
			{
				if (a[j] != '0') 
				{
					cout << j << " " << i << endl;
					a[j] = '0';
					a[i] = '0';
					break;
				}
			
			}
		
		}
	
	}

}

int main()
{
	char s[101];
	int i;
	cin.getline(s, 101);
	for (i = 1; i < strlen(s); i++)
	{
		if (s[i] == s[0]) s[i] = 'm';
	}
	s[0] = 'm';
	for (i = 0; i < strlen(s); i++)
	{
		if (s[i] != 'm') s[i] = 'w';	
	}
	duilie(s);

	return 0;
}
char boy;

int res(char str[], int n, int idx)
{
	if (str[idx] == boy)
	{
		int ridx = res(str, n, idx + 1);
		cout << idx << " " << ridx << endl;
		if (ridx < n - 1)
		{
			ridx = res(str, n, ridx + 1);
		}
		else
		{
			ridx = ridx + 1;
		}
		return ridx;
	}
	else
	{
		return idx;
	}
}
int main()
{
	char str[102];
	cin >> str;
	boy = str[0];
	res(str, strlen(str), 0);
	return 0;
}
void main()
{
char text[200],a,b; int i,j;
gets(text);printf("\n");
a=text[0]; 
for(i=0;i<strlen(text);i++)   if(text[i]!=a)  {b=text[i];break;}
for(i=0;i<strlen(text);i++)
{if(text[i]==b)   
  {for(j=i;j>=0;j--)   if(text[j]==a)   
    {text[j]='c';  printf("%d %d\n",j,i);break;}}}
}
char queen[1000];
// int main()
// {
// 	cin >> queen;
// 	int len = strlen(queen);
// 	char a, b;
// 	int cnt = 0;
// 	int boy[1000] = {0};
// 	a = queen[0];
// 	b = queen[len - 1];
// 	for (int i = 0; i < len; i++)
// 	{
// 		if (queen[i] == a)
// 		{
// 			boy[cnt] = i;
// 			cnt ++;
// 		}
// 		if (queen[i] == b)
// 		{
// 			cnt --;
// 			cout << boy[cnt] << ' ' << i << endl;
// 		}
// 	}
// 	while(EOF!=getchar());
// 	return 0;
// }
	char a, b;
	int cnt = 0;
	int len;
int match(char *);
int main()
{
	cin.getline(queen,1000);
	len = strlen(queen);

	a = queen[0];
	b = queen[len - 1];
	char *p = queen;
	match(p);
	while(EOF!=getchar());
	return 0;
}

int match(char *p)
{
	int q;
	if (*p == b)
	{
		return p - queen;
	}
	else
	{
		q = match(p + 1);
		cout << p - queen << ' ' << q << endl;
		cnt ++;
		if (cnt < len / 2)
		{
					return match(q + queen + 1);
		}
		
	}

}
char a;
char b;
char s[10000];
int numa=1;
int numb=0;
int ida[10000];
int idb[10000];
void test(int x);
int main()
{
	scanf("%c",&a);
	s[0]=a;
	int i;
	for(i=1;;i++)
	{
		scanf("%c",&s[i]);
		if(s[i]==a)
		{
			numa++;
		}
		else if(s[i]!=a)
		{
			b=s[i];
			numb++;
		}
		if(numa==numb)break;
	}
	test(0);
	for(i=0;i<(numa+numb)/2;i++)
	{
		printf("%d %d\n",ida[i],idb[i]);
	}
	return 0;
}

void test(int x)
{
	int i;
	for(i=0;i<numa+numb;i++)
	{
		if(s[i]==a)
		{
			ida[x]=i;
		}
		else if(s[i]==b)
		{
			idb[x]=i;
			s[ida[x]]=' ';
			s[i]=' ';
			if(x<(numa+numb)/2-1)
			{
				test(x+1);
			}
		}
	}
}
void f(char a[99],char b)
{
	int i,j,k,sum=0;
	for (i=0;a[i]!='\0';i++)
	{
		if (a[i]==b) continue;
		for (j=i-1;j>=0;j--)
		{
			for (k=j;k<=i;k++) if (a[k]==b) sum++;
			if (sum==(i-j+1)/2.0) 
			{
				sum=0;
				cout<<j<<' '<<i<<endl;
				break;
			}
			sum=0;
			
		}
	}
}
int main()
{
	 char a[99],b;
	cin.getline(a,99);
	b=a[0];
	f(a,b);
	return 0;
}
int main()
{
	char a[101]={0};
	scanf("%s",a);
	int i;
	int count=0;
	for(i=0;i<101;i++)
	{
		if(a[i]!=0)
			count++;
	}
	if(count==2)
		printf("0 1");
	else
	{
		int j=0;
		int b[50]={0};
		for(i=0;i<count;i++)
		{
			if(a[i]==a[count-1])
			{
				b[j]=i;
				j++;
			}
		}
		for(i=0;i<count/2;i++)
		{
			for(j=b[i]-1;j>=0;j--)
			{
				if(a[j]==a[0])
				{
					printf("%d %d\n",j,b[i]);
					a[j]=48;
					break;
				}
			}
		}
	}
	return 0;
}