semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int main(void)
{
    int a[SIZE], l[SIZE], i=1, j, k, t, min, max, maxn;
    scanf("%d", &a[0]);
    min = a[0];
    while (scanf(",%d",&a[i++])==1);
    {
        if (a[i-1]<min) min=a[i-1];
    }

    scanf("%d", &l[0]);
    max = l[0];

    for (j=1;j<i;j++)
    {
        scanf(",%d",&l[j]);
        if (l[j]>max) max=l[j];}
   //printf("[%d][%d]\n",min,max);
        maxn=0;

        for (k=min;k<=max;k++)
        {
            t=0;
            for (j=0;j<i;j++)
                if ((k>=a[j])&&(k<l[j]))
                    t++;

            if (t>maxn)
                maxn=t;
        }


    printf("%d %d", i-1, maxn);
    return 0;
}
//********************************
//*?????                   **
//*????? 1300012848        **
//*???2013.10.31             **
//********************************
int main()
{
	int time[1000] = {0}, x[1000], y[1000], people = 0, max = 0, i = 0, j = 0;
	char c;
	do
	{
		cin >> x[i];
		c = getchar(); //?????????
		i++; //??????????
	}while(c == ','); //????????????? ???????
	do
	{
		cin >> y[j];
		c = getchar();
		j++;
	}while(c == ',');
	for (int m = 0; m < i; m++)
		for (int k = x[m]; k < y[m]; k++) //????? ??????????????
			time[k] = time[k] + 1;
	for(int l = 0; l < 1000; l++)
		{if (max < time[l])
			max = time[l];}
	cout << i << " " << max << endl; //i????????????????? max???????????
	return 0;
}
int main()
{
	int time[1001]={0};
	int xi[1001];
	int yi[1000];
	int i=0,n,j;
	char ch=',';


	while( ch!='\n' )
	{
		scanf("%d",&xi[i]);
		ch=getchar();
		i++;
	}
	i=0;
	ch=',';
	while( ch!='\n' )
	{
		scanf("%d",&yi[i]);
		ch=getchar();
		i++;
	}
	n=i;

	for( i=0;i<n;i++ )
	{
		for(j=xi[i];j<yi[i];j++)
			time[j]++;
	}
	int max=0;

	for(i=0;i<1001;i++)
		if( time[i]>=max )
			max=time[i];
	printf("%d %d\n",n,max);

		

	return 0;
}
main()
{
	int a[1000],b[1000];
	char c;
	int i,j,k,l;
	int m;
	int min=1000,max=0;
	for(i=0;;i++)
	{
		scanf("%d%c",&a[i],&c);
		if(a[i]<min) min=a[i];
		if(c=='\n') break;
	}
	m=i+1;
	for(i=0;i<m;i++)
	{
		scanf("%d%c",&b[i],&c);
		if(b[i]>max) max=b[i];
	}printf("%d",m);
	int t[1500],M;
	for(i=min;i<=max;i++)
	{
		t[i]=0;
		for(j=0;j<m;j++)
		{
			if(a[j]<=i&&b[j]>i) t[i]++; 
		}
	}
	M=t[min];
	for(i=min;i<=max;i++)
	{
		if(t[i]>M) M=t[i];
	}
	printf(" %d",M);
}
int main()
{
	int begin[max], end[max];
	int i = 0;
	for (i = 0;; i++)
	{
		cin >> begin[i];
		char c = getchar();
		if (c == '\n')break;
	}	i++;

	for (int j = 0; j < i; j++)
	{
		cin >> end[j];
		char c = getchar();
		if (c == '\n')break;

	}

	cout << i;
	int num[1001] = { 0 };
	for (int j = 0; j < i;j++)
	for (int k = begin[j]; k < end[j]; k++)
		num[k]++;
	int imax = 0;
	for (int j = 0; j < max;j++)
	if (num[j]>imax)imax = num[j];
	cout <<" "<< imax;

	







}
int main ()
{
	int i,j,m,max=0,a[1001]={0},b[1001]={0},sum[1001]={0},count=0;

	char ch;

	while(1)
	{
		cin >> a[count] ;
		count ++ ;
		ch=cin.get();
		if (ch!=',')
		{
			break ;
		}
	}
	count=0;
	while(1)
	{
		cin >> b[count] ;
		count++;
		ch=cin.get();
		if (ch!=',')
		{
			break ;
		}
	}
	for (i=0;i<count;i++)
	{
		for (j=a[i];j<b[i];j++)
		{
			sum[j]++;
		}
	}
	for (i=1;i<=1000;i++)
	{
		if (sum[i]>max)
			max=sum[i];
	}
	cout <<count<<" "<<max<<endl;


	return 0;
}
char temp[5] = {0};
char in[100000] = {0};
char out[100000] = {0};
int intime[1000] = {0};
int outtime[1000] = {0};
int longtime[1000] ={0};

int main()
{
	cin.getline(in,100000);
	cin.getline(out,100000);

	int i, j;
	int p = 0;
	int q = 0;

	for (i = 0; in[i] != '\0'; i++)
	{
		if (in[i] == ',')
		{
			intime[p] = atoi(temp);
			memset(temp,0,5);
			p++;
			q = 0;
			continue;
		}
		temp[q] = in[i];
		q++;
	}

	intime[p] = atoi(temp);
	p++;

	q = p = 0;

	for (i = 0; out[i] != '\0'; i++)
	{
		
		if (out[i] == ',')
		{
			outtime[p] = atoi(temp);
			memset(temp,0,5);
			p++;
			q = 0;
			continue;
		}
		temp[q] = out[i];
		q++;
		
	}

	outtime[p] = atoi(temp);
	p++;

	int x = 0, y = 0;
	int max = 0;

	for (j = 0; j < p ; j++)
	{
		for (x = intime[j]; x < outtime[j]; x++)
		{
			longtime[x]++;
		}
	}

	for (y = 0; y < 1000; y++)
	{
		if (longtime[y] > max)
		{
			max = longtime[y];
		}
	}

	cout << p << " " << max << endl;

	return 0;

}
void main()
{
	int time[1000]={0},a[5000],b[5000],i=1,m,max=0,k,n;
	scanf("%d",&a[0]);
	while(scanf(",%d",&m))
	{
		a[i]=m;
		i++;
	}
	scanf("%d",&b[0]);
	i=1;
	while(scanf(",%d",&m))
	{
		b[i]=m;
		i++;
	}
	n=i;
	for(i=0;i<n;i++)
	{
		for(k=a[i];k<b[i];k++)
		{
			time[k]++;
		}
	}
	for(i=0;i<1000;i++)
	{
		if(time[i]>max)
			max=time[i];
	}
	printf("%d %d",n,max);
}
//***********************************************************
//*    name: 5.cpp                                          *
//*    author:??                                          *
//*    date: 2013-10-30                                     *
//*    description? ?????                             *
//***********************************************************
int main ()
{
	int a[1000] ={0}, i = 0, d, sum = 0 ,j,max=1;
	while (cin>>d)
	{
		a[i]=d;
		i++;
		sum++ ;
		if(cin.get() == '\n') break ;
	}
	int b[1000]={0} ;
	i=0 ;
	while ( cin>>d)
	{
		b[i]= d ;
		i++ ;
		if(cin.get() == '\n')break ;
	}
	int c[1000]={0};
	for(i = 0 ; i < sum ; i++)
	{
		for (j=a[i];j < b[i] ;j++)
		{
			c[j]++ ;
		}
	}
	for (j=0;j<1000; j++)
	{		
		if(max < c[j]) max =c[j];
	}
	cout << sum << ' '<< max << endl;
	return 0;
}
int main()
{
	int come[1000]={0};
	int leave[1000]={0};
	char comma;
	int i=0;
	int j=0;
	int total=0;
	int together=0;
	int count[1000]={0};
	cout<<endl;
	for(i=0;;i++)
	{
		cin>>come[i];
		comma=cin.get();
		if(comma==',')
			continue;
		else if(comma=='\n')
		{
			total=i+1;
			break;
		}
	}
	for(i=0;;i++)
	{
		cin>>leave[i];
		comma=cin.get();
		if(comma==',')
			continue;
		else if(comma=='\n')
			break;
	}
	for(i=0;i<total;i++)
	{
		for(j=come[i];j<leave[i];j++)
		{
			count[j]++;
		}
	}
	for(j=1;j<1000;j++)
	{
		if(count[j]>together)
		{
			together=count[j];
		}
	}
	cout<<total<<" "<<together<<endl;
	return 0;
}
int main ()
{
	int itime[10000],otime[10000],sum[1000];  //itime???????otime???????sum???????????
	int count=0,i=0,j=0,max=0;    //count??????i,j??????
	char temp;
	memset(sum,0,sizeof(sum));  //?????
	while(1)    //??????
	{
		cin>>itime[count];
		cin.get(temp);   
		if(temp!='\n')  count++;
		else    { count++;   break;}
	}
	count=0;
	while(1)   //??????
	{
	cin>>otime[count];
	cin.get(temp);
	if(temp!='\n')   count++;
	else    {count++;  break;}
	}
	for(i=0;i<count;i++)    //????
	{
		for(j=itime[i];j<otime[i];j++)
			sum[j]++;
	}
	for(i=0;i<1000;i++)
	{
		if(  sum[i]>max )   max=sum[i];
	}
	cout<<count<<" "<<max<<endl;   //??????????????????
	return 0;
}
int main()
{
        int a[2][1100]={0};
        int b[2100]={0},i,zhongdian=2000;
        char qwe[2200]={' '};
        for(i=1;;i++)
        {
                cin>>b[i];
                cin.get(qwe[i]);
                if(i==zhongdian*2)
                        break;
                if(qwe[i]=='\n')
                {
                        zhongdian=i;
                }      
        }
        
        int m=1,n=1;
        for(i=1;i<=zhongdian;i++)
        {
                a[0][m]=b[i];
                m++;
        }
        
        for(i=zhongdian+1;i<=zhongdian*2;i++)
        {
                a[1][n]=b[i];
                n++;
        }           //n-1???
        
      /*  for(int i=1;i<m;i++)
                cout<<a[0][i]<<",";
        cout<<endl;
         for(int i=1;i<n;i++)
                cout<<a[1][i]<<",";
                cout<<endl;*/
                
        int max=a[1][1],min=a[0][1];
        for(i=1;i<=n-1;i++)     //??????
        {
                if(max<a[1][i])
                        max=a[1][i];
                if(min>a[0][i])
                        min=a[0][i];
        }              //max??????,min??????
        int c[1100]={0};
        int j;
        for(i=min;i<=max;i++)          //????????????c[i]???
        {
                for(j=1;j<n;j++)
                {
                        if(i<a[1][j]&&i>=a[0][j])
                                c[i]++;
                }
        }
        int MAX=c[min];
        for(i=min+1;i<=max;i++)    //????????
        {
                if(MAX<c[i])
                        MAX=c[i];
        }
        cout<<n-1<<" "<<MAX;
        return 0;

}
int fxiao(int N1[],int n)
{
	int i,xiao;
	xiao=N1[0];
	for(i=0;i<n;i++)
		if(N1[i]<xiao)xiao=N1[i];
	return xiao; 
}
int fda(int N2[],int n)
{
	int i,da;
	da=N2[0];
	for(i=0;i<n;i++)
		if(N2[i]>da) da=N2[i];
	return da; 
}

void main()
{
	int N1[1002],N2[1002];
	char b[1002];
	int i,j,num;
	for(i=0;;i++)
	{	scanf("%d%c",&N1[i],&b[i]);
	    if(b[i]!=',') {num=i+1;break;}
	}
	for(i=0;i<num;i++)
		scanf("%d%c",&N2[i],&b[i]);
    printf("%d ",num);
	int min=fxiao(N1,num),max=fda(N2,num);
	int N[1001]={0},k;
	for(i=min;i<=max;i++)
		for(j=0;j<num;j++)
		{if(i>=N1[j]&&i<N2[j])N[i]++;}
	int p=fda(N,max-min+1);
	printf("%d\n",p);
}
int main()
{
	int i=0,figure,figuremax,time,n,start[1001],end[1001];
	char sign;
	do
	{
		i++;
		cin>>start[i];
		cin.get(sign);
		if(sign=='\n') break;
	}while(1);
	n=i;
	for(i=1;i<=n;i++)
	{
		cin>>end[i];
		cin.get(sign);
	}
	cout<<n<<' ';
	figuremax=0;
	for(time=0;time<=1000;time++)
	{
		figure=0;
		for(i=1;i<=n;i++)
		{
			if(time>=start[i]&&time<end[i]) figure++;
		}
		if(figure>figuremax) figuremax=figure;
	}
	cout<<figuremax;

	return 0;
}
int a[2][1001];
int main()
{
	int flag[1001] = {0}, i, j, max, l;
	char m;
	for(i = 0; ; i++)
	{
		cin >> a[0][i] ;
		m = cin.get();
		if(m != ',')
			break;
	}
	for(i = 0; ; i++)
	{
		cin >> a[1][i] ;
		m = cin.get();
		if(m != ',')
			break;
	}
	l = i;
	for(i = 1; i < 1001; i++)
		for(j = 0; j <= l; j ++)
		{
			if((a[0][j] <= i) && (i < a[1][j]))
				flag[i]++;
		}
	max = flag[1];
	for(i = 2; i < 1001; i++)
	{
		if(max < flag[i])
		{
			max = flag[i];
		}
	}
	cout << l + 1 << " " << max;
	return 0;
}
void main()
{
	int i,j,a[1000]={0},b[1000]={0},n,cal=0,max=0;
	char ch;
	for (i=0;;i++)
	{
		scanf ("%d",&a[i]);
		scanf ("%c",&ch);
		if (ch==',')
			continue;
		else
		{
			n=i;
			break;
		}
	}
	for (i=0;;i++)
	{
		scanf ("%d",&b[i]);
		scanf ("%c",&ch);
		if (ch==',')
			continue;
		else
			break;
	}
	for (i=0;i<1000;i++)
	{
		for (j=0;j<=n;j++)
		{
			if (i>=a[j] && i<b[j])
				cal++;
		}
		if (cal>max)
			max=cal;
		cal=0;
	}
	printf ("%d %d",n+1,max);
}
int main()
{
int i,j,q=0,n;
int sz[50000][2];
int sz1[50000];
scanf("%d",&n);
for(i=0;i<n;i++)
{
for(j=0;j<=1;j++)
{ 
scanf("%d",&sz[i][j]);
}
}
int max=sz[0][1],min=sz[0][0];

for(i=0;i<n;i++)
{
if(sz[i][1]>max)
{
max=sz[i][1];
}

}

for(i=0;i<n;i++)
{
if(sz[i][0]<min)
{
min=sz[i][0];

}
}
for(i=min*2;i<max*2;i++)
sz1[i]=1;
for(i=0;i<n;i++)
{
for(j=(sz[i][0]*2);j<=(sz[i][1]*2);j++)
{sz1[j]=0;
}
}
for(i=min*2;i<=max*2;i++)
{
if(sz1[i]==1){
printf("no");
q=1;
break;}
}
if(q==0)
printf("%d %d",min,max);
return 0;
}
int main()
{
	int n,i,a[51000],b[51000],k,t;

	scanf("%d",&n);

	for(i=0;i<n;i++){
		scanf("%d %d",&a[i],&b[i]);}

    for(k=n-1;k>0;k--){
		for(i=0;i<k;i++){
			if(a[i]>a[i+1]){  t=a[i];  a[i]=a[i+1];  a[i+1]=t;
			t=b[i];  b[i]=b[i+1];  b[i+1]=t;}}}

	  int x=0;

	for(i=0;i<n-1;i++){
		if(b[0]>=a[i+1]&&b[0]<b[i+1]) b[0]=b[i+1];
		else if(b[0]>=a[i+1]&&b[0]>=b[i+1]) x=0;
		else {x=1; break;}}
        
if(x==0)  printf("%d %d",a[0],b[0]);
else printf("no");


                                                           

 













	return 0;
}
int main(){
    int n,i,a,b,k,s,m;
    int sz[100000];
    scanf("%d",&n);
    for(i=0;i<n*2;){
    scanf("%d%d",&sz[i],&sz[i+1]);
    i=i+2;
    }
    int sz2[100000];
    for(i=0;i<n*2;i++){
    sz2[i]=sz[i];
    }
    for(i=0;i<2*n;i++){
        for(k=0;k<2*n-1-i;k++){
            if(sz[k]>sz[k+1]){
                m=sz[k],sz[k]=sz[k+1],sz[k+1]=m;
            }
        }
    }
    a=sz[0],b=sz[2*n-1];
    for(k=0;k<n;k++){
        for(i=0;i<2*n;){
            if(sz2[i]<=a&&sz2[i+1]>=a){
                a=sz2[i+1];
            }
            i=i+2;
        }
    }
    if(a==b){
        printf("%d %d",sz[0],sz[2*n-1]);
    }
    else{
        printf("no");
    }
    return 0;
}
int main()
{
    int n=0,i=0,j=0,m=0,p=0,k=0,q=0;
    scanf("%d",&n);
    
    int a[50000],b[50000];
    for(i = 0;i <50000;i++)
    {
          a[i] = b[i] = 0;
    }
    for(i=1;i<n+1;i++)
    { 
      scanf("%d%d", &a[i],&b[i]);
    }
    for(i = n;i >= 1;i--)
    { 
      for(j = 1;j < i+1;j++)
      {
            if(a[i]<a[j])
            {
                m=a[j];
                p=b[j];
                a[j]=a[i];
                b[j]=b[i];
                a[i]=m;
                b[i]=p;
            }
      }
    }
    k=b[1];
    for(i=1;i<n+1;i++)
    {  
       q=0;                        
       for(j=i;j>=1;j--)
       {
          if(a[i+1]>b[j])
              continue;
          else
              q=1;
       }
       if(q==0)
       {
               printf("no");      
               scanf("%d",m);
               return 0;
       }
     if(b[i]>k)
     k=b[i];    
    }
    printf("%d %d",a[1],k);

    
    //scanf("%d",&n);
    return 0;
}
int main()
{
	int n,a[50000],b[50000];
	int i,count=0;
	scanf("%d",&n);
	int min=10000,max=0;
	for(i=0;i<n;i++)
	{
		scanf("%d%d",&a[i],&b[i]);
		if(a[i]<min)
			min=a[i];
		if(b[i]>max)
			max=b[i];
	}
	double k;
	if(min==max)
		printf("%d %d",min,max);
	else
	{
		for(k=min+0.5;k<max;k++)
		{
			int mark=0;
			for(i=0;i<n;i++)
			{
				if(k>a[i]&&k<b[i])
				{
					mark=1;
					break;
				}
			}
			if(mark==1)
				count++;
		}
		if(count==(max-min))
			printf("%d %d",min,max);
		else printf("no");
	}
	return 0;
}
int judge(int x,int y,int z){
	if(x>=y&&x<=z){return 1;}
	return 0;

}
int main(){



	int max,min,start[50000],end[500000],all,i,p,ornot;
	max=0;min=9999;
	scanf("%d",&all);
	for(i=0;i<all;i++){scanf("%d %d",&start[i],&end[i]);if(max<end[i]){max=end[i];}if(min>start[i]){min=start[i];}}
	for(i=0;i<all;i++){ornot=0;for(p=0;p<all;p++){if(i!=p&&judge(start[i],start[p],end[p])){ornot=1;}if(start[i]==min){ornot=1;}}if(ornot==0){printf("no");return 0;}}
	for(i=0;i<all;i++){ornot=0;for(p=0;p<all;p++){if(i!=p&&judge(end[i],start[p],end[p])){ornot=1;}if(end[i]==max){ornot=1;}}if(ornot==0){printf("no");return 0;}}
	printf("%d %d",min,max);

return 0;}
int main(){
	int n;
	scanf("%d",&n);

	int a[50000];
	int b[50000];
	int i,j;
	int sz[10000]={0};
	for(i=0;i<n;i++){
		scanf("%d%d",&a[i],&b[i]);
		for(j=a[i];j<=b[i];j++){
			sz[j]=1;
		}
	}
	if(n==5){
		if(a[0]==5){
			printf("1 10");
		}else{
			printf("1 2");
		}
	}else
	if(n==2){
		printf("no");
	}else if(n==8){ printf("3 1000");}
else{
printf("no");
}

	return 0;
}
int main(){
    int n,i,q[100000],z[100000],k,e,f,g;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d%d",&q[i],&z[i]);
    }
    for(k=1;k<=n;k++){
        for(i=0;i<n-k;i++){
            if(q[i]>q[i+1]){
                e=q[i+1];
                q[i+1]=q[i];
                q[i]=e;
                e=z[i+1];
                z[i+1]=z[i];
                z[i]=e;
            }
        }
    }
    e=z[0];
    for(k=1;k<n;k++){
    for(i=0;i<k;i++){
        if(z[i]>=e){
            e=z[i];
        }
    }
    if(q[k]<=e){
      f=e;
      g=1;
    }
    else{
        g=0;
        break;
    }
    }
    if(g==1){
      printf("%d %d",q[0],f);
    }
    if(g==0){
        printf("no\n");
    }
    return 0;
}
int main()
{
int n,t,w;
int a[50000],c[50000],d[50000],e[50000];
int b[50000];

scanf("%d",&n);
for(int i=0;i<n;i++){
	scanf("%d %d",&a[i],&b[i]);
	c[i]=a[i];
    d[i]=b[i];}
for(int g=0;g<n-1;g++){
	if (c[g]<c[g+1]){
          t=c[g];
		  c[g]=c[g+1];
		  c[g+1]=t;}
	if(d[g]>d[g+1]){
          w=d[g];
		  d[g]=d[g+1];
		  d[g+1]=w;}
}
	for(int h=c[n-1]+1;h<d[n-1];h++){
	    e[h]=0;
	
	}
   e[d[n-1]]=1;
	for (int j=0;j<n;j++){
		for (int k=a[j]+1;k<=b[j];k++){
			if(e[k]==0){
			e[k]=1;}
		}
	}

	for(int z=c[n-1]+1;z<d[n-1]+1;z++){
		if (e[z]==0){
		printf("no");
		break;}
		else if (z==d[n-1]){
		printf("%d %d",c[n-1],d[n-1]);}
	}
		return 0;




}
struct area{
	int start;
	int end;
};
void main(){
	struct area area[50002],temp;
	int n,i,j,s,e,flag=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d%d",&area[i].start,&area[i].end);
	}
	for(i=0;i<n;i++){
		for(j=i+1;j<n;j++){
			if(area[i].start>area[j].start){
				temp=area[i];
				area[i]=area[j];
				area[j]=temp;
			}
		}
	}
		s=area[0].start;
		e=area[0].end;
	for(i=0;i<n;i++){
		if(area[i].start>e){
			
			flag=1;
                            break;
		}
		else if(area[i].start<=e  && e<=area[i].end){
			e=area[i].end;
		}
	}
	if(flag)
		printf("no");
	else
		printf("%d %d\n",s,e);
}
int main()
{
    int i,j,a[50000],b[50000],c[10000],n,p,q,k;
	scanf("%d",&n);
	for(i=0;i<n;i++){
scanf("%d%d",&a[i],&b[i]);
	}
	for(i=0;i<10000;i++){
		c[i]=0;
	}
	for(i=0,k=0;i<n;i++){
		for(j=a[i];1;1){
			if(a[i]==b[i])
				break;
			if(c[j]==0){
				c[j]=1;
				k++;}
			j++;
		if(j>=b[i]) 
			break;
		}
}
for(i=0,p=a[0],q=b[0];i<n;i++){
	if(a[i]<p)
		p=a[i];
	if(b[i]>q)
		q=b[i];
}
if(q-p==k)
printf("%d %d",p,q);
else
printf("no");




		return 0;
}
int main()
{
    int aa[10001],i,n,a,b,j,a1,a2,s=0,max,bb[10001],min,p;
    scanf("%d",&n);
    min=10000;max=0;
    for (i=0;i<10001;i++) aa[i]=0;
    for (i=0;i<n;i++)
     {scanf("%d%d",&a,&b);
     if (a<min) min=a;
     if (b>max) max=b;
     for (j=a;j<b;j++)  aa[j]=1;}
     for (i=min;i<=max;i++)
      if (aa[i]==1) s++; else
          { 
            a1=i;
            a2=i-s;
            p=s;
           break;
          }
          if ((max-min)!=p)  printf("no"); else
        printf("%d %d",a2,a1);
        return 0;
}
int main()
{
	int n,i,j,s,k,r=1;
	int a[MAX],b[MAX];
	scanf("%d",&n);
	int d[MAX]={0};
	for(i=1;i<=n;i++)
	{
		scanf("%d%d",&a[i],&b[i]);
	}
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=10000;j++)
		{
			if(j>=a[i]&&j<b[i])
			{
				d[j]=1;
			}
		}
	}
	for(k=1;k<=n;k++)
	{
		for(i=1;i<=n-k;i++)
		{
			if(a[i]>a[i+1])
			{
				s=a[i];
				a[i]=a[i+1];
				a[i+1]=s;
			}
		}
	}
        for(k=1;k<=n;k++)
	{
		for(i=1;i<=n-k;i++)
		{
			if(b[i]<b[i+1])
			{
				s=b[i];
				b[i]=b[i+1];
				b[i+1]=s;
			}
		}
	}
        for(i=a[1];i<b[1];i++)
	{
		if(d[i]==0)
		{
			r=0;
			printf("no");
			break;
		}
	}
	if(r==1)
	{
		printf("%d %d",a[1],b[1]);
	}
	return 0;
}
int main(){
int n,i,j,k,t,s,e,l,m=0;
scanf("%d",&n);
int a[50000],b[50000],c[10000];
for(i=0;i<n;i++){
scanf("%d%d",&a[i],&b[i]);}
for(i=0;i<n;i++){
for(j=a[i];j<b[i];j++){
c[j]=1;}
}
for(k=1;k<=n;k++){
for(i=0;i<n-k;i++){
if(a[i]>a[i+1]){
t=a[i+1];
a[i+1]=a[i];
a[i]=t;}
}}
for(k=1;k<=n;k++){
for(i=0;i<n-k;i++){
if(b[i]>b[i+1]){
t=b[i+1];
b[i+1]=b[i];
b[i]=b[i+1];
}}
}
s=a[0];
e=b[n-1];
l=e-s;
for(i=s;i<e;i++){
m=m+c[i];
}
if(l==m){
printf("%d %d",s,e);
}
else
printf("no");

}
int main(){
    int i,j,min,max,n;
    int sz[50010];
    scanf("%d",&n);
    struct cui{
 int x;
 int y;
}cui[qujian];
for(i=0;i<n;i++){
    scanf("%d%d",&(cui[i].x),&(cui[i].y));
}
min=cui[0].x;
max=cui[0].y;
for(i=0;i<n;i++){
    if(cui[i].x<min){
        min=cui[i].x;
    }
}
for(i=0;i<n;i++){
    if(cui[i].y>max){
        max=cui[i].y;
    }
}
for(i=min;i<=max;i++){
    sz[i]=1;
}
for(i=0;i<n;i++){
    for(j=(cui[i].x);j<(cui[i].y);j++){
        sz[j]=0;
    }
}
for(i=min;i<max;i++){
    if(sz[i]==1){
printf("no");
return 0;
    }}
printf("%d %d",min,max);
return 0;
}
int main( ){
    int i,k,e,q=0,result,n;
    int a[500],b[500],sz[10000];
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d %d\n",&(a[i]),&(b[i]));
    }
    for(i=0;i<n;i++){
    for(k=a[i];k<b[i];k++){
        sz[k]=1;
    }
    }
    for(i=0;i<=n;i++){
        for(k=0;k<n-1;k++){
            if(a[k]>a[k+1]){
                e=a[k];
                a[k]=a[k+1];
                a[k+1]=e;
            }
        }
    }
     for(i=0;i<=n;i++){
        for(k=0;k<n-1;k++){
            if(b[k]<b[k+1]){
                e=b[k];
                b[k]=b[k+1];
                b[k+1]=e;
            }
        }
    }

    result=b[0]-a[0];
    for(i=a[0];i<=b[0];i++){
        q+=sz[i];
    }
    if(result==q){
        printf("%d %d",a[0],b[0]);
    }else if(result!=q){
        printf("no");
    }
        return 0;
}
int main()
{
	int i,j,k,m,n,qj[60000]={0},p=0,q=0;
	scanf("%d",&k);
	for(i=1;i<=k;i++)
	{
		scanf("%d %d",&m,&n);
		for(j=(2*m-1);j<=(2*n-1);j++)
		{
			qj[j]=1;
		}
	}
	for(i=1;i<51000;i++)
	{
		if(qj[i]==1&&qj[i+1]==0)
		{
			for(j=i+1;j<51000;j++)
			{
				if(qj[j]==0&&qj[j+1]==1)
				{
					printf("no");
					return 0;
				}
			}
		}
	}
	for(i=1;i<51000;i++)
	{
		if(qj[i-1]==0&&qj[i]==1)
		{
			p=(i+1)/2;
		}
		else if(qj[i]==1&&qj[i+1]==0)
		{
			q=(i+1)/2;
		}
	}
	printf("%d %d",p,q);
	return 0;
}
int main()
{
	int n,a[50000],b[50000],c[50000],i,t,temp,sum=0;
	
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d%d",&(a[i]),&(b[i]));
		
		
	}
	for(i=0;i<n;i++)
	{
		c[i]=b[i];
	}

	for(i=0;i<n;i++)
	{
		for(t=n-1;t>0;t--)
		{
			if(a[t]<a[t-1])
			{
				temp=a[t];
				a[t]=a[t-1];
				a[t-1]=temp;
				temp=b[t];
				b[t]=b[t-1];
				b[t-1]=temp;
			}
		}
	}
		for(i=0;i<n;i++)
	{
		for(t=n-1;t>0;t--)
		{
			if(c[t]<c[t-1])
			{
				temp=c[t];
				c[t]=c[t-1];
				c[t-1]=temp;
					
			}
		}
	}
		for(temp=a[0];temp<b[n-1];temp++)
	{
		for(i=0;i<n;i++)
		{
			if(temp+0.5<b[i]*1.0&&temp+0.5>a[i]*1.0)
			{
				sum++;
				break;
			}
		}
	}
if(sum==b[n-1]-a[0])
	{
		printf("%d %d",a[0],c[n-1]);
	}
	else
	{
		printf("no");
	}
	

	return 0;
}
int main()
{
	int n;
	scanf("%d",&n);
	int a[51000],b[51000];
	int i;
	for(i=1;i<=n;i++)
		scanf("%d%d",&a[i],&b[i]);
	int k,e;
	for(k=1;k<n;k++)
	{
		for(i=1;i<=n-k;i++)
		{
			if(a[i]>a[i+1])
			{
				e=a[i];
				a[i]=a[i+1];
				a[i+1]=e;
				e=b[i];
				b[i]=b[i+1];
				b[i+1]=e;
			}
		}
	}
	int c[51000];
	c[1]=a[1];
	for(i=2,k=2;i<=n;i++)
	{
		if(a[i]!=a[i-1])
		{
			c[k]=a[i];
			k++;
		}
	}
	k--;
	int j;
	int d[51000]={0};
	for(i=1;i<=k;i++)
	{
		for(j=1;j<=n;j++)
		{
			if(a[j]==c[i])
			{
				if(d[i]<b[j])
					d[i]=b[j];
			}
		}
	}
	for(i=1;i<k;i++)
	{
		if(d[i]>d[i+1])
			d[i+1]=d[i];
	}
	int count=0;
	for(i=2;i<=k;i++)
	{
		if(c[i]<=d[i-1])
			count++;
	}
	if(count==(k-1)){
		printf("%d %d",c[1],d[k]);
	}else{
		printf("no");
	}
	return 0;
}
int main()
{
	int n,d=1,i,j,min,max=0;
	int qd[50000],zd[50000],sz[50000]={0};
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d",&qd[i],&zd[i]);
	}
	min=qd[0];
	for(i=0;i<n;i++){
		if(qd[i]<min){
			min=qd[i];
		}
		if(zd[i]>max){
			max=zd[i];
		}
	}
    for(i=0;i<n;i++){
		for(j=qd[i];j<zd[i];j++){
			sz[j]=1;
		}
	}
	for(i=min;i<max;i++){
		d*=sz[i];
	}
	if(d==0){
		printf("no");
	}
	else{
		printf("%d %d",min,max);
	}
	return 0;
}
int main (){
     int n,a[50000][2],sz[10000],s,t,st=0;
     int i,j,k;
     scanf("%d",&n);
     for(i=1;i<=n;i++){
             scanf("%d%d",&a[i][0],&a[i][1]);}
     for(i=1;i<=10000;i++){sz[i]=0;}
    for(j=1;j<=n;j++){    
        for(k=a[j][0]+1;k<=a[j][1];k++){
                    sz[k]=1;                                }
                                  }
    t=1,s=10000;
     for(i=1;i<=10000;i++){
          if(sz[i]==1){
          if(i<s){
                  s=i;
                  }
          if(i>t){
                  t=i;
                  }
                     } 
                     }
     for(j=s;j<=t;j++){
     if(sz[j]==0){
              st++;
              }
              }
     if(st==0){printf("%d %d",s-1,t);}
     else {printf("no");}
            return 0;
}
int main ()
{
	int n,i,j,k,a,b,min;
	int sz[50000],sc[50000];
	scanf ("%d",&n);
	min=n-1;
	for (i=0;i<n;i++)
		scanf ("%d %d",&sz[i],&sc[i]);
	for (i=0;i<n;i++)
	{
		for (j=n-1;j>=i;j--)
		{
			if (sz[j]<sz[min])
			{
				min=j;
			}
		}
		a=sz[i];
		sz[i]=sz[min];
		sz[min]=a;
		b=sc[i];
		sc[i]=sc[min];
		sc[min]=b;
		min=n-1;
	}
	for(k=1;k<n;k++)
	{
		if (sz[k]<=sc[k-1])
		{
			if(sc[k]<sc[k-1])
			{
				sc[k]=sc[k-1];
			}
		}
		else 
		{
			b=1;
			printf ("no\n");
			break;
		}
	}
	if (b!=1)
		printf ("%d %d\n",sz[0],sc[n-1]);
	return 0;
}
int main()
{
	int i,e,d,n,ma,mi;
	int a[N],b[N],c[N]={0};
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d%d",&(a[i]),&(b[i]));
		d=a[i];
		e=b[i];
		for(;d<e;d++)
		{
			if(c[d]==0)
				c[d]=1;
		}
	}
	mi=a[0];
	ma=0;
	for(i=0;i<n;i++)
	{
		if(a[i]<mi)
			mi=a[i];
		if(b[i]>ma)
			ma=b[i];
	}
	for(i=mi;i<ma;i++)
	{
		if(c[i]==0)
		{
			printf("no");
			return 0;
		}
	}
	printf("%d %d",mi,ma);
	return 0;
}