semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int main()
{
	int a,i,x,y,z,q,t;
	scanf("%d\n",&a);
	scanf("%d\n",&y);
	scanf("%d\n",&q);
	i=2;
	while(i<(a-1))
	{
		scanf("%d\n",&x);
		while(1)
		{
			if(x>=y&&y>=q)
			{
				q=y;
			    y=x;
				break;
			}
			if(x>=q&&q>=y)
			{
				y=x;
				break;
			}
			if(y>=x&&x>=q)
			{
				q=x;
				break;
			}
			if(q>=x&&x>=y)
			{
				y=q;
			    q=x;
				break;
			}
			if(q>=y&&y>=x)
			{
				t=q;
			    q=y;
			    y=t;
				break;
			}
			if(y>=q&&q>=x)
			{
				break;
			}
		}
		i++;
	}
	scanf("%d",&z);
	if(y>=z&&z>=q)
	{
		q=z;
	}
	if(z>=y)
	{
		q=y;
		y=z;
	}
	printf("%d\n",y);
    printf("%d",q);
	return 0;
}
void main()
{
    int n,a[100],i,max1=0,max2=0,x=0;
	scanf("%d",&n); 
	for(i=0;i<n;i++)
		scanf("%d",&a[i]);	
	for(i=0;i<n;i++)
	 if(max1<a[i]) {max1=a[i]; x=i;}
	 printf("%d\n",max1);
	 for(i=0;i<n;i++)
     if(max2<a[i]&&a[i]!=max1) max2=a[i];
	 printf("%d",max2);

}
int n[100];
void main()
{
	int x;
	scanf("%d",&x);
	int i;
	for(i=0;i<=x-1;i++) scanf("%d",&n[i]);
	void m(int a,int n[100]);
	m(x,n);
	printf("%d\n",n[0]);
	printf("%d\n",n[1]);
}
void m(int a,int n[100])
{
	int j;
	for(j=0;j<=a-2;j++)
	{
		int k;
		for(k=0;k<=a-2-j;k++)
		{
			if(n[k]<n[k+1])
			{
				int l;
				l=n[k];
				n[k]=n[k+1];
				n[k+1]=l;
			}
		}
	}
}
void main()
{
    int n,i,j,x,b,c,m;
    int a[100];
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
    	scanf("%d",&a[i]);
    }
    
    b=0;
    
    for(x=1;x<=n;x++)
    {
    	if(b<=a[x])
    	 {
    	  b=a[x];
    	  m=x;
    	 }
    	else
    	b=b;
    }
    printf("%d\n",b);
   
    c=0;
    a[m]=0;
      for(x=1;x<=n;x++)
    {
    	if(c<=a[x])
    	c=a[x];
    	else
    	c=c;
    }
    printf("%d",c);
    
}
int main()
{
	int n, i, a[100], min=0, max=0;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d",&a[i-1]);
	}
	for(i=1;i<=n;i++){
		if(a[i-1]>max){
		max=a[i-1];
		}
	}
	printf("%d\n",max);
	for(i=1;i<=n;i++){
		if(a[i-1]<max&&a[i-1]>min){
		min=a[i-1];
		}
	}
	printf("%d\n",min);
	return 0;
}
int main()
{
	int r,i,max1=0,max2=0;
	int score[100];
	scanf("%d",&r);
    for(i=0;i<=r-1;i++)
	{
		scanf("%d",&score[i]);
	}
	for(i=0;i<=r-1;i++)
	{
		if(score[i] > max1 )
		{
max2 = max1;

			max1 = score[i];
					}
		else if( score[i] > max2 )
			max2 = score[i];

	 }
	printf("%d\n%d",max1,max2);
	 return 0;
}
void main()
{int n,i,k,max1,max2,num[30];
 scanf("%d",&n);
 for(i=0;i<n;i++)
    scanf("%d",&num[i]);
 max1=num[0];
 k=0;
 for(i=1;i<n;i++)
    if(num[i]>max1)
         {max1=num[i];k=i;}
 if(k=0)
 {max2=num[1];
  for(i=2;i<n;i++)
    if(num[i]>max2)
         max2=num[i];
  }
else {max2=num[0];
      for(i=2;i<n;i++)
          if(num[i]>max2&&num[i]!=max1)
          max2=num[i];
     }
printf("%d\n",max1);
printf("%d\n",max2);
}
int main()
{
	int k,m,n,i,a[100];                //????
	m=0;n=0;
	cin>>k;                            //????
	for(i=0;i<k;i++)                   //??k?
	{
	   cin>>a[i];
	   if(a[i]>m)                     
		   {n=m;
	        m=a[i];}
	   else if(a[i]>n)
		    n=a[i];
	}
    cout<<m<<endl;
	cout<<n<<endl;
	return 0;
}
void insert(int *ma,int tem)
{
if (tem>ma[0]){ ma[1]=ma[0];ma[0]=tem;}
else if (tem>ma[1]){ ma[1]=tem;}
}


int main()
{
int n,i;
int temp,max[2]={0,0};
scanf("%d",&n);
for (i=1;i<=n;i++){
     scanf("%d",&temp);
     if (temp>max[0]){ max[1]=max[0];max[0]=temp;}
     else if (temp>max[1]){ max[1]=temp;}
     }
 printf("%d\n%d",max[0],max[1]);
return 0;
}
int main()
{
	int  n, i, t, m1=0, m2=0;
	scanf("%d", &n);
	for(i = 0; i < n; i++) {
	   scanf("%d", &t);
	   if ( t > m1){
                m2 = m1;
	       m1 = t;
	   }
	   else if  (t > m2 )
	       m2 = t;
	   }
	printf("%d\n%d", m1, m2);
         return 0;
}
int main(){
    int n,i,t;
    int max,cmax;
    int sz[100];
    scanf("%d",&n);
    for(i=0;i<n;i++){
                     scanf("%d",&sz[i]);
                     }
                     max=sz[0];
                     cmax=sz[1];
                     for(i=2;i<n;i++){
                                      if(sz[i]>max){
                                                   t=max;
                                                   max=sz[i];
                                                   cmax=t;
                                                   }else if(sz[i]>cmax&&sz[i]<max){
                                                         cmax=sz[i];
                                                         }
                                                         }
                                                         printf("%d\n%d\n",max,cmax);
                                                         return 0;
                                                         }
void main()
{
    int a[100];
    int n,i,u,v;
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d",&a[i]);
	if(a[0]>a[1])
		u=a[0];v=a[1];
	if(a[0]<a[1])
		u=a[1];v=a[0];
	for(i=2;i<n;i++)
	{
		if(a[i]>u)
			u=a[i];
		if(a[i]<u&&a[i]>v)
			v=a[i];
	}
	printf("%d\n%d",u,v);
}
void main()
{
	int i,n;scanf("%d",&n);
	int *p,*hd;hd=p=(int *)malloc(n*sizeof(int));
	for(i=0;i<n;i++,p++)
	{
		scanf("%d",p);
	}
	int max=0;
	for(p=hd,i=0;i<n;i++,p++)
	{
		if(*p>max) max=*p;
	}
	for(p=hd,i=0;i<n;i++,p++)
	{
		if(*p==max) *p=0;
	}
	printf("%d\n",max);max=0;
	for(p=hd,i=0;i<n;i++,p++)
	{
		if(*p>max) max=*p;
	}
	printf("%d",max);
}
int main()
{
  int a;
  int num,result1,result2,cha;
  scanf("%d\n",&a);
  int i=1;
  while(i<=a){
     scanf("%d\n",&num);
    if(i==1){
       result1=num;
     } else if(i==2){
       result2=num;
       if(result2>result1){
          cha=result1;
          result1=result2;
          result2=cha;
        }
     } else if(i!=1&&i!=2){    
       if(num>result1){
       result2=result1;
       result1=num;
       }else if(num>result2&&num<result1){
       result2=num;
       }
     }
  i++;
  }
  printf("%d\n%d\n",result1,result2);
  return 0;
}
int main()
{
int a[100],n,i,j,b,c,t;
scanf("%d",&n);
for (i=0;i<n;i++)
scanf("%d",&a[i]);
b=a[0];
c=a[1];
if(b<c)
	{t=b;
     b=c;
	 c=t;
	}
for (j=2;j<n;j++)    
   {if(a[j]<b&&a[j]>c)
	   c=a[j];
	else if (a[j]>b)
	  {c=b;
	   b=a[j];
	  }
	}
printf("%d",b);
printf("\n");
printf("%d",c);
}
int main()
{
	int a,b,c,d,n,i=3;
	scanf("%d",&n);
    scanf("%d %d",&a,&b);
	if(a<b)
	{
		d=a;
		a=b;
		b=d;
	}
    while(i<=n)
	{
		scanf("%d",&c);
		if(c>a)
		{
			b=a;
			a=c;
		}
		else if(c>b&&a>c)
		{
			b=c;
		}
        i++;
	}
	printf("%d\n%d\n",a,b);
	return 0;
}
int main()
{
    int n,a,b;
    scanf("%d",&n);
    int i,sz[300],j,m=0;
    for(i=0;i<n;i++){
        scanf("%d",&sz[i]);
    }
    for(i=0;i<n;i++){
        for(j=0;j<n;j++){
            if(sz[j]>sz[i]){
               m++;
            }
        }
        if(m==0){
        a=sz[i];
        printf("%d\n",a);
        break;
        }
        m=0;
    }
  m=0;
    for(i=0;i<n;i++){
        for(j=0;j<n;j++){

            if(sz[j]>sz[i]){
               m++;
            }
           
        }
        if(m==1){
        b=sz[i];
        printf("%d\n",b);
        break;
        }
        m=0;
    }
    return 0;
}
int main(){
int n,e;
int x,y,z;
int i;
scanf("%d%d%d",&n,&x,&y);
if(x<y){
e=x;
x=y;
y=e;
}
for(i=1;i<=n-2;i++){
scanf("%d",&z);
if(x<z){
e=x;
x=z;
z=e;
if(z>y){
y=z;
}
}else if(x>z&&y<z){
x=x;
y=z;
}else if(z<y){
x=x;
y=y;
}
}
printf("%d\n%d",x,y);
return 0;
}
main()
{int i,m,n,k,j;
 scanf("%d",&n);
 int *p=(int*)malloc(n*sizeof(int));
 for(i=0;i<n;i++)
  scanf("%d",&p[i]);
 for(i=0;i<(n-1);i++)
  for(j=i+1;j<n;j++)
  { if(p[i]<p[j]) {k=p[i];p[i]=p[j];p[j]=k;}}
 printf("%d\n%d",p[0],p[1]);

}
int main()
{
    int a[100];
    int i,j,n,t;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
                     printf("\n");
                     scanf("%d",&a[i]);
    }
    for(j=0;j<2;j++)
    {
                      for(i=0;i<n-1-j;i++)
                      {
                                          if(a[i]>a[i+1])
                                          {
                                                         t=a[i];
                                                         a[i]=a[i+1];
                                                         a[i+1]=t;
                                          }
                      }
    }
                        printf("%d\n%d",a[n-1],a[n-2]);
    getchar();getchar();
}
int main(int argc, char* argv[])
{
    int n,i=3,a;
	int max,sec;

	scanf("%d",&n);

	scanf("%d",&a);
	max=a;

	scanf("%d",&a);
	if (a>max)
	{
		sec=max;
		max=a;
	}
	else 
	{
		sec=a;
	}




	for (i=3;i<=n;i++)
	{
		scanf("%d", &a);
	    if (a>max)
		{
			sec=max;
			max=a;
		}
		else if(a>sec)
		      {
		    	sec=a;
		      }
	}
	printf("%d\n%d\n",max,sec);


	    
	return 0;
}
int main()
{
	int n,i,c,d,t;
	t=0;
	scanf("%d",&n);
	int a[100];
	for(i=0;i<=(n-1);i++)
		scanf("%d",&a[i]);
	for(c=0;c<=(n-2);c++)
	{
		for(d=(n-1);d>=(c+1);d--)
		{
			if(a[d]>a[d-1])
			{
				t=a[d-1];
			    a[d-1]=a[d];
				a[d]=t;
			}
		}
	}
	printf("%d\n",a[0]);
	printf("%d\n",a[1]);
	return 0;

}
void main()
{
	int max,max2,n,i,a[100];
	scanf("%d",&n);
	for(i=0;i<n;i++)scanf("%d",&a[i]);
	for(i=0,max=max2=a[0];i<n;i++)
	{
		if(max<a[i]){
			max=a[i];
		}
	}
	for(i=0;i<n;i++)
	{
		if(max2<a[i]&&a[i]<max) max2=a[i];
	}
	printf("%d\n%d",max,max2);
	getchar();getchar();
}
int main()
{
	int n,i,max,min,e,k;
	i=0;
	k=1;
	scanf("%d\n",&n);
	int number[n];
	for(i=0;i<=n-1;i++){
		scanf("%d\n",&(number[i]));
	}
	for(k=1;k<=n;k++){
		for(i=0;i<=n-1-k;i++){
			if(number[i]>number[i+1]){
				e=number[i+1];
				number[i+1]=number[i];
				number[i]=e;
			}
		}
	}
	printf("%d\n%d\n",number[n-1],number[n-2]);
	return 0;
}
void main()
{
	int n,i,a,b,c;
	scanf("%d",&n);
	scanf("%d%d",&a,&b);
	for(i=3;i<=n;i=i++)
	{
		scanf("%d",&c);
		if(c>=a)
		{
			b=a;
			a=c;
		}
		else if(a>c&&c>b)
			b=c;
	}
	printf("%d\n%d",a,b);
}
int max(int a[],int n)
{
	int i,k=0;
	for(i=0;i<n;i++)
	{
		if(a[i]>a[k])
			k=i;
	}
	i=a[k];
	a[k]=0;
	return i;

}
int main()
{
	int n;
	scanf("%d",&n);
	int a[100],i;
	for(i=0;i<n;i++)
		scanf("%d",&a[i]);
	printf("\n%d",max(a,n));
	printf("\n%d",max(a,n));
	return 0;
}
int main(){
int n;
scanf("%d",&n);
int max,sed,t,j,r,m,c;
scanf("%d",&max);
scanf("%d",&sed);
scanf("%d",&c);
j=3;
while(j<=n){
	if(max<c){
	t=max;
	max=c;
	c=t;
	}
	if(sed<c){
	r=sed;
	sed=c;
	}
	j++;
	scanf("%d",&c);
	
}
if(max<sed){
m=max;
max=sed;
sed=m;
}
printf("%d\n%d\n",max,sed);
return 0;
}
int main()
{
    int n,t;
    cin>>n;
    int a[n];
    for(int i=1;i<=n;i++)
    cin>>a[i];

    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n-1;j++)
        {
            if(a[j]<a[j+1])
            {
                t=a[j];
                a[j]=a[j+1];
                a[j+1]=t;
            }
        }
    }
    cout<<a[1]<<endl<<a[2]<<endl;
    return 0;
}
void main()
{
	int i,n,a[100],m,cm,max;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	m=0;

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

	for(i=0;i<n;i++)
	{
		if(a[i]>a[cm])
			cm=i;
	}
	printf("%d\n%d\n",max,a[cm]);
}
int main()
{
	int b,max=0,lmax=0,a[100000];
	scanf("%d",&b);
	a[0]=0;
	for(int i=0;i<b;i++)
	{ scanf("%d",&a[i]); 
	   if (a[i]>=max)
	   {max=a[i];}
	}

	for(int k=0;k<b;k++)
	{  if((a[k]>=lmax)&&(a[k]<max))
	{lmax=a[k];
	}
	}
	printf("%d\n",max);
	printf("%d\n",lmax);
	return 0;
}
int main(){
	int i,n;
	 
	int sz[100],e,y=0;
scanf("%d",&n);
	for (i = 0; i < n;i++){
		
		scanf("%d",&sz[i]);
	}
	
	for(i=0;i<n;i++){
		if(sz[i]>=sz[y]){
			y=i;

		}
	}
	if(y!=0){
		e=sz[y];
		sz[y]=sz[0];
		sz[0]=e;
	}
	int x=1,t,m;
	for(m=1;m<n;m++){
		if(sz[m]>=sz[x]){
			x=m;
		}
	}
	if(x!=1){
		t=sz[x];
		sz[x]=sz[1];
		sz[1]=t;
	}
	printf("%d\n",sz[0]);
	printf("%d\n",sz[1]);
	return 0;
}
int main()
{
   int i,j,k,temp;
   int an[MAX_NUM]; 
   scanf("%d",&i);
   for (j=0;j<i;j++){
    scanf("%d",&an[j]);
   }

   for (j=0;j<i-1;j++){
      for (k=j+1;k<=i;k++){
        if (an[j]<an[k]){
             temp=an[j];
             an[j]=an[k];
             an[k]=temp;  
		}
     }  
  }  

    for (j=0;j<=1;j++){
      printf("%d\n",an[j]);
      }
   /* scanf("%d",&i);
     for (j=0;j<i;j++)
    scanf("%d\n",&an[j]);*/
    return 0;
      
 }
void main()
{
	int a,b,c,d,min,max;
	scanf("%d\n%d\n%d",&a,&c,&d);
	min=(d<c)?d:c;
	max=(d>=c)?d:c;
	if(a>2)
	for(;a>=3;a--)
	{ 
		scanf("%d",&b);
		if(b>max){min=max;max=b;}
		else if(b>min)min=b;
	
	}
	printf("%d\n%d",max,min);
}
int main()
{int a,x,i=2,y,m1,m2=0;
 scanf("%d",&a);
 scanf("%d",&x);
 m1=x;
 while (i<=a)
 {scanf("%d",&y);
  if (m1<y)
	  {m2=m1;
       m1=y;}
  else if(m1>=y&&y>m2)
  { m2=y;}
    i++;}
 printf("%d\n%d\n",m1,m2);
return 0;
}
int main()
{
int n,x,y,z,m;
scanf("%d",&n);
x=0;y=0;z=0;
for (n=n;n>0;n=n-1)
	{scanf("%d",&x);
		if (x>=y)
		{z=y;
		y=x;}
		else
		{y=y;
		if (x>z)
		z=x;
		}
	}
if (n==0) {printf("%d\n",y);printf("%d",z);}
x=0;y=0;z=0;
return 0;
}
void main()
{
	int n,a[100],i,b=0,c=0;
	scanf("%d",&n);
	for (i=0;i<=n-1;i++)
	{
		scanf("%d",&a[i]);
	}
	for(i=0;i<=n-1;i++)
	{
		if(a[i]>=b)
		{
			b=a[i];
		}
	}
	printf("%d\n",b);
	for (i=0;i<=n-1;i++)
	{
		if(a[i]==b)
		{
			b=b+1;
		}
		else if(a[i]>=c&&a[i]<b)
		{
			c=a[i];
		}
	}
	printf("%d",c);
}
int main()
{
int ax[100];
int a=0;
int i;
scanf("%d",&i);
while (a<=i-1)
{scanf("%d",&ax[a]);
a++;
}
int b=0,c,k=1;
while (k<i)
{b=0;
     while (b<i-k)
	 {
	      if(ax[b]>=ax[b+1])
		  {c=ax[b];
		   ax[b]=ax[b+1];
		   ax[b+1]=c;
		  }
	  b++;
	 }
k++;
}
printf("%d\n%d",ax[i-1],ax[i-2]);
return 0;
}
int main()
{
	int k,max=0,max2=0,n,m;//max???????max2?????????n??????????m??????
	cin >> k;
	for(int i=0;i<k;i++)
	{
		cin >> n;
		if(n==1)
			max=n;
		else if(n==2)
		{
			max2=n;
			if(max2>max)
			{
				n=max2;
				max2=max;
				max=n;
			}
		}
		else
		{
			if(n>max)
			{
				max2=max;
				max=n;	
			}

			else if (max>=n&&n>=max2)
				max2=n;
		}
	}
    cout << max << endl;
	cout << max2 << endl;
	return 0;
}
int main(){
	int n,i,m,x[100];
	scanf("%d",&n);
	for(i=0;i<100;i++)
	{
		if(i==n)
			break;
		scanf("%d",&x[i]);
	}
	for(i=0;i<n-1;i++)
	{
		if(x[i]>x[i+1])
		{
			m=x[i];
			x[i]=x[i+1];
			x[i+1]=m;
		}
	}
	for(i=0;i<n-2;i++)
	{
		if(x[i]>x[i+1])
		{
			m=x[i];
			x[i]=x[i+1];
			x[i+1]=m;
		}
	}
	printf("%d\n%d\n",x[n-1],x[n-2]);
	return 0;
}
int main()
{
	int s[100000],i,j,k,t,n;
	scanf("%d",&n);
	for (i=1;i<=n;i++)
		scanf("%d",&s[i]);
	for (i=10;i>=2;i--)
	 if			(s[i]>s[i-1])		
	 {
			t=s[i-1];
			s[i-1]=s[i];
			s[i]=t;
	 }
	for (i=10;i>=3;i--)
		if (s[i]>s[i-1])
		{
			t=s[i-1];
			s[i-1]=s[i];
			s[i]=t;
		}
		printf("%d\n",s[1]);printf("%d\n",s[2]);
		return 0;
}
int main()
{
	int i,a[100],n;
	int e=0;

	for(i=0;i<100;i++){
			 a[i]=0;
	}

	scanf ("%d",&n);

	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	
	for(i=0;i<n-1;i++){
		if(a[i]>a[i+1]){
			e=a[i+1];
			a[i+1]=a[i];
			a[i]=e;	
		}
	}	

	for(i=0;i<n-2;i++){
		if(a[i]>a[i+1]){
			e=a[i+1];
			a[i+1]=a[i];	
			a[i]=e;
		}
	}

         printf("%d\n%d",a[n-1],a[n-2]);
	return 0;
}
int main(int argc, char* argv[])
{
	int n,i,x,y,a;
	scanf("%d",&n);
	x=0;
	y=0;
	scanf("%d",&a);
	y=a;
	for (i=2;i<=n;i++)
	{
		int ai;
		scanf("%d\n",&ai);
		if (ai>=x)
		{
			x=ai;
		}
		else
		{
			if (ai>y)
			{
				y=ai;
			}
		}
	}
	printf("%d\n",x);
	printf("%d\n",y);
	return 0;
}
int main()
{
int max(int x,int y);
int min(int x,int y);
 int i=1,n,a,s,d,f,g;
 scanf("%d",&n);
 while(i<=n){
  scanf("%d\n",&a);
  if(i==1) { s=a;d=a;}
  else  { f=d;g=s;
        s=max(s,a);d=min(g,a);d=max(d,f); 
    }
  i++;
 }
 
  printf("%d\n%d\n",s,d);
 return 0;
}
int max(int x,int y){
int z; 
z=x>y? x:y;
return(z);
}
  int min(int x,int y){
 int z; 
z=x<y? x:y;
return(z);
}
int main(int argc, char* argv[])
{
	int n,a,b,m;
   	scanf("%d",&n);
	for(a=0,b=0;n>0;n--)
	{
		scanf("%d",&m);
		if(m>a)
		{	b=a;
			a=m;
		
		
		}else if(m>b&&m<a)
		{
			b=m;
		
		
		}
	
	}
printf("%d\n%d",a,b);

	return 0;
}
int main ()
{
	int sz[100];
         int i;
	int a , b , c , e;
	scanf("%d", &a);
	for(i=0 ; i<a; i++){
		scanf("%d", &(sz[i]));
	}
	for(i=0; i<a-1; i++){
		if(sz[i] > sz[i+1]){
			e = sz[i];
			sz[i] = sz[i+1];
			sz[i+1] = e;
		}
	}		
	b=sz[i];
	for(i=0 ; i<a-2 ; i++){
		if(sz[i] > sz[i+1]){
			e = sz[i];
			sz[i] = sz[i+1];
			sz[i+1] = e;
		}
	}		
	c=sz[i];
	printf("%d\n", b);
	printf("%d\n", c);
	return 0;
}
int main()
{
	int a[100];
	int i=0,n,j,max,second;
	scanf("%d",&n);
	while(i<n)
	{
	scanf("%d",&a[i]);
	i=i+1;
	}
	i=0;
	max=a[0];
	while(i<n)
	{
	if(max<a[i]) 
	{
		max=a[i];
	    j=i;
	}
	    i=i+1;
	}
	i=0;
	if(j!=0) second=a[0];
	else second=a[1];
    while(i<n)
	{
		if(second<a[i]&&a[i]<max) second=a[i];
		i=i+1;
	}
	printf("%d\n%d\n",max,second);
}
int main()
{
	int a[100],n,max1,max2,b,c,i,j,t;
	scanf("%d",&n);
	for (i=0;i<n;i++)
	{scanf("%d",&a[i]);}
    for (j=0;j<n-1;j++)
    for (i=0;i<n-j-1;i++)
	if (a[i]<a[i+1])
	{
		t=a[i];
		a[i]=a[i+1];
		a[i+1]=t;
	}
	printf("%d\n%d\n",a[0],a[1]);
}
int main()
{
	int n,Z[1000],x,y;
	scanf("%d",&n);
for (x=1;x<=n;x++)
scanf("%d",&Z[x]);
for (x=1;x<n;x++)
{
	if (Z[x]<Z[x+1])
		Z[x+1]=Z[x+1];
	else
	{
		y=Z[x+1];
		Z[x+1]=Z[x];
		Z[x]=y;
	}
}
for (x=1;x<n-1;x++)
{
	if (Z[x]<Z[x+1])
		Z[x+1]=Z[x+1];
	else
	{
		y=Z[x+1];
		Z[x+1]=Z[x];
		Z[x]=y;
	}

}
printf("%d\n%d\n",Z[n],Z[n-1]);
return 0;
}
int main()
{
 int Max,OnlyUnderMax,Min;
 int i,n,nums[100];
 cin>>n;
 cin>>nums[0];
 Max = Min = nums[0];
 for(i = 1;i<n;i++)
 {
  cin>>nums[i];
  if(nums[i]>Max)
   Max = nums[i];
  if(nums[i]<Min)
   Min = nums[i];
 }
 OnlyUnderMax = Min;
 for(i = 0;i<n;i++)
 {
  if(nums[i]>OnlyUnderMax && nums[i]<Max)
   OnlyUnderMax = nums[i];
 }
 cout<<Max<<endl<<OnlyUnderMax<<endl;
 return 0;
}
void main()
{
	int n,a[100],i,max=0,nmax=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){scanf("%d",&a[i]);}
	for(i=0;i<n;i++)
	{
		if(a[i]>max) max=a[i];}
	for(i=0;i<n;i++)
	{if(a[i]==max)
	a[i]=0;}
    for(i=0;i<n;i++)
	{
		if(a[i]>nmax) nmax=a[i];}
	printf("%d\n%d\n",max,nmax);
}
int main()
{
int n,i,a[100],max,sm;
scanf("%d\n",&n);
for(i=0;i<=n-2;i++)
scanf("%d\n",&a[i]);
scanf("%d",&a[n-1]);
max=a[0];
for(i=0;i<=n-1;i++)
{if(a[i]>max) max=a[i];}
printf("%d\n",max);
sm=a[0];
for(i=0;i<=n-1;i++)
{if(a[i]!=max&&a[i]>sm) sm=a[i];}
printf("%d",sm);
}
void main()
{
	int n,i,j,k,t,max1=0,min,max2;
	int a[100];
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d",&a[i]);
	for(j=0;j<n;j++)
	{
		if(max1<a[j])
			max1=a[j];
		else
			continue;
	}
	min=max1;
	for(k=0;k<n;k++)
	{
		t=max1-a[k];
		if(t==0)
			continue;
		else 
		{
			if(min>t)
				min=t;
		    else
				continue;
		}
	}
	max2=max1-min;
	printf("%d\n%d\n",max1,max2);
}
int main ()
{
  int n,max1,max2,i,d,e,f;
  scanf("%d\n",&n);
  scanf("%d\n",&d);
  scanf("%d\n",&e);
  max2=e;
  max1=d;
  if (d>e) 
{  max2=d;
   max1=e;
}

    for(i=2;i<n;i++)
{ 
  scanf("%d\n",&f);
  if (f>max2) 
{  max1=max2;
   max2=f;
}
else if (f<=max1) ;
else 
max1=f;
}
printf("%d\n%d",max2,max1);
return 0;
}
int main()
{
	int length = 0, a[110] = {0};
	cin >> length;
	for(int i = 0; i < length; i ++)
		cin >> a[i];
	int sec = 1;
	int point = 0;
	while(point + sec < length)
	{
		while(point + sec < length)
		{
			if(a[point] < a[point + sec])
			{
				int temp = a[point];
				a[point] = a[point + sec];
				a[point + sec] = temp;
			}
			point = point + sec * 2;
		}
		sec = sec * 2;
		point = 0;
	}
	cout << a[0] << endl;
	sec = sec / 4;
	if(a[sec] > a[sec * 2])
		cout << a[sec] << endl;
	else
		cout << a[sec * 2] << endl;
	return 0;
}
int main(int argc, char* argv[])
{
	int n,i,x[100];
	int max=0,secondmax=0;
	scanf("%d",&n);
    for(i=0;i<n;i++)
	{
		scanf("%d",&x[i]);
		if(x[i]>=max)
		{
		secondmax=max;
		max=x[i];
		}
		if(x[i]>secondmax&&max>x[i])
		{
			secondmax=x[i];
		}
		
	}
	printf("%d\n%d\n",max,secondmax);
	return 0;
}
int max(int a[],int n)
{
	int i,j=0,t;
	for (i=0;i<n;i++)
		if (*(a+j)<*(a+i))
			j=i;
	if (j!=0)
	{
		t=*(a+j);
		*(a+j)=*(a+0);
		*(a+0)=t;
	}
	return(*a);
}
void main()
{
	int i,n,num[100]={0};
	scanf("%d",&n);
	for (i=0;i<n;i++)
		scanf("%d",&num[i]);
	printf("%d\n",max(num,n));
	printf("%d\n",max(num+1,n-1));
}
int main()
{
    int max1,max2,n,i;
    scanf ("%d",&n);
    int a[n];
    i=0;
    max1=a[n-1]; 
    for(i=0;i<=n-1;i++)
    {
              scanf("%d",&a[i]);
    }
    i=n-1; 
    for(i=n-1;i>=1;i--)
    {
                       if(a[i-1]<a[i])
                       {
                                      max1=a[i];
                                      a[i]=a[i-1];
                                      a[i-1]=max1;
                       }
    } 
    i=n-1;
    max2=a[n-1];
    for(i=n-1;i>=2;i--)
    {
                       if(a[i-1]<a[i])
                       {
                                      max2=a[i];
                                      a[i]=a[i-1]; 
                                      a[i-1]=max2;
                       }
    } 
    printf("%d\n%d\n",a[0],a[1]);
    scanf("%d",i); 
    return 0;
}
int main()
{
int n;
int a=0;
int b=0;
cin>>n;
for (int i=1;i<=n;i++)
{
	int m;
	cin>>m;
	if(m>=a)
	{
		b=a;
		a=m;
	}
	else if(m>b)
		b=m;
}
printf("%d\n%d\n",a,b);
return 0;
}
int main()
{
	int n,i,a,b,max=0,sec;
	int number[1000];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&number[i]);
		if(number[i]>max){
			max=number[i];
		}
	}
		a=max;
		sec=max;
		for(i=0;i<n;i++){
			if((a-number[i])<sec&&(a-number[i]>0)){
					sec=a-number[i];
			}
		}
	
		b=a-sec;
		printf("%d\n",a);
		printf("%d\n",b);
		return 0;
	}
void main()
{int n,a[99],i,max,s,c,j;
	scanf("%d",&n);
	scanf("%d",&s);
	a[0]=s;
	max=s;
	c=-1;
	for(i=1;i<n;i++)
	{  scanf("%d",&s);  
	  a[i]=s;
       if (max<a[i])
	   {max=a[i];
	   j=i;}
	}
	printf("%d\n",max);
    
	for(i=0;i<n;i++)
	{
		if(c<a[i]&&i!=j)
	  c=a[i];
	   }
    printf("%d",c);
}
void main()
{
int i,n,a[100],max=0,min=0;
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d",&a[i]);
for(i=0;i<n;i++)
if (a[i]>max) {min=max;max=a[i];}
else if(a[i]>min) min=a[i];
printf("%d\n%d",max,min);
}
int main(){
	int i=0;
	int n;
	scanf("%d",&n);
	int a,b;
	int x,y,l;
	scanf("%d%d",&x,&y);
	if(x>y){
		a=x;
		b=y;
	}else{
		a=y;
		b=x;
	}
	while(i<=n-3){
		scanf("%d",&l);
		if(l>a){
			b=a;
			a=l;
		}else{
			if(l>b){
				b=l;
			}
		}
		i++;
	}
	printf("%d\n%d",a,b);
		return 0;
}
int main()
{
	int n, max1, max2,i;
	int num[100]={0};
	max1 = 0;
	max2 = 0;
	scanf("%d" , &n);
	scanf("%d%d", &num[0],&num[1]);
	if (num[0] >= num[1])
	{
		max1 = num[0];
		max2 = num[1];
	}
	else
	{
		max1 = num[1];
		max2 = num[0];
	}
    for (i = 2; i < n; i++)
	{
		scanf("%d" ,&num[i]);
		if (num[i] > max1)
		{
			max2 = max1;
			max1 = num[i];
		}
		else if (num[i] >max2)
		{
			max2 = num[i];
		}
		else
		{
			continue;
		}
	}
		printf("%d\n%d\n", max1,max2);
		return 0;
}
int main()
{
    int n,i,a,b,c;
    i=1;
    scanf("%d",&n);
    b=0;
    c=0; 
    while(i<=n)
    {
               scanf("%d",&a);
               if(a>b)
               {
                      if(c<b)
                      {
                             c=b; 
                      } 
                      b=a; 
               } 
               else
               {
                   if(c<a)
                   {
                          c=a; 
                   } 
               } 
               i++; 
                
    }
    printf("%d\n",b);
    printf("%d\n",c); 
    return 0; 

}
int main(){
int a,b,c,x,y,i,n;
scanf("%d",&n);
for(i=1;i<=2;i++){
	if(i=1){
		scanf("%d",&a);
	}
	if(i=2){scanf("%d",&b);
	}
	if(a>b){x=a;y=b;}
	if(a<b){x=b;y=a;}
}
for(i=3;i<=n;i++){
scanf("%d",&c);
if(c>x){y=x;x=c;}
if(x>c&&c>y){y=c;}
}
printf("%d\n""%d\n",x,y);
return 0;
}
int main(){
int n;
int max1,max2,num;
int exc;
max1=0;
max2=0;
scanf("%d",&n);
for(int i=1;i<=n;i++){
scanf("%d",&num);
{if(num>max1){
exc=max1;
max1=num;
max2=exc;}else if(num<max1){if(num>max2){
max2=num;
max1=max1;}}
}}
printf("%d\n%d\n",max1,max2);

return 0;
}
int main(int argc, char *argv[])
{
    int n,a,max,min,i,e;
    scanf("%d",&n);
    for(i=0;i<n;i++){
                     scanf("%d",&a);
                     if(i==0) {
                              max=min=a;
                              }
                     if(a>max)  max=a;
                     else if(max>a && a>min)  min=a;
                     }
                     
                     
                     
    printf("%d\n%d\n",max,min);
                               
                               

  return 0;
}