semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
/*
 * jiegou_1.cpp
 *
 *  Created on: 2011-1-2
 *      Author: Iris
 *      ????????
 * ????STUDENT_NUM???????????????? ?????????ID???????????
 * ???????????????????????????????
 */


int main(){
	int n,i;
	cin>>n;//??????
	struct student{
		int stuNo;
		int yuwen;
		int shuxue;
		int zongfen;
	} stu[n];//?????????????????????????t?????
	struct tri{
		int stuNo;
		int zongfen;
	} qian[3]={0,0,0,0,0,0};//??????????????????????
	for(i=0;i<n;i++){
		cin>>stu[i].stuNo;
		cin>>stu[i].yuwen;
		cin>>stu[i].shuxue;//????????????
		stu[i].zongfen=stu[i].yuwen+stu[i].shuxue;//?????????
	}
	for(i=0;i<n;i++){
		if(stu[i].zongfen>qian[0].zongfen){
			qian[2]=qian[1];
			qian[1]=qian[0];
			qian[0].stuNo=stu[i].stuNo;
			qian[0].zongfen=stu[i].zongfen;
			continue;
		}
		if(stu[i].zongfen>qian[1].zongfen){
			qian[2]=qian[1];
			qian[1].stuNo=stu[i].stuNo;
			qian[1].zongfen=stu[i].zongfen;
			continue;
		}
		if(stu[i].zongfen>qian[2].zongfen){
			qian[2].stuNo=stu[i].stuNo;
			qian[2].zongfen=stu[i].zongfen;
		}
	}//?????
	for(i=0;i<3;i++)
		cout<<qian[i].stuNo<<' '<<qian[i].zongfen<<endl;//????????????
	return 0;
}
struct student
{
	int num;
	int c;
	int m;
	int sum;
    struct student *next;
};
void main()
{
	int n,i,j;
	scanf("%d",&n);
    struct student *head,*p0,*p,*q;
    head=(struct student*)malloc(sizeof(struct student));
	head->next=NULL;
	for(i=0;i<n;i++)
	{
		q=(struct student*)malloc(sizeof(struct student));
		scanf("%d %d %d",&q->num,&q->c,&q->m);
		q->sum=q->c+q->m;
		q->next=NULL;
		p0=head;
		p=p0->next;
		j=0;
        while(p!=NULL&&q->sum<=p->sum)
		{
			p0=p;
			p=p->next;
			j++;
			if(j>3)
				goto A;
		}
        p0->next=q;
		q->next=p;
A:		continue;
	}
	p=head->next;
	for(i=0;i<3;i++)
	{
		printf("%d %d\n",p->num,p->sum);
		p=p->next;
	}
}
/*
 * mark.cpp
 *
 *  Created on: 2011-12-9
 *      Author: admin
 */
struct student{
	int id;
	int chi;
	int math;
};
struct maxer{
	int id;
	int mark;
};
int main(){
	int n,i,j;
	struct student a[100001],temp;
	struct maxer max,top[3];                         //top3????
	cin>>n;
	for (i=1;i<=n;i++){
		cin>>a[i].id>>a[i].chi>>a[i].math;
	}
	for (i=1;i<=3;i++){                              //????
		max.mark=0;
		for (j=i;j<=n;j++){
		if 	(a[j].chi+a[j].math>max.mark){
			max.id=a[j].id;
			max.mark=a[j].chi+a[j].math;             //?????
		}
		}
		top[i-1]=max;                                //????????????????????????
		temp=a[i];
		a[i]=a[max.id];
		a[max.id]=temp;
	}
	for (i=0;i<=2;i++){
		cout<<top[i].id<<' '<<top[i].mark;
		if (i!=2)cout<<endl;
	}
return 0;
}
struct stud
{	int n;
	int m;
	int c;
	int t;
}s[100000],temp;
void main()
{
	int i,j,k,n,p;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{	scanf("%d %d %d",&s[i].n,&s[i].m,&s[i].c);
		s[i].t=s[i].m+s[i].c;
	}
	for(j=0;j<3&&j<n;j++)
	{	for(k=j+1,p=j;k<n;k++)
			if(s[p].t<s[k].t){p=k;}
			temp=s[j];s[j]=s[p];s[p]=temp;
		printf("%d %d\n",s[j].n,s[j].t);
	}
}
// ????????.cpp : ??????????????
//


struct student
{
	int id;
	int chinese;
	int math;
	int total;
};

int main()
{
	int number;
	struct student stu[100000];
	scanf("%d\n",&number);
	for(int i=1;i<=number;++i)
	{
		scanf("%d%d%d",&stu[i].id,&stu[i].chinese,&stu[i].math);
		stu[i].total=stu[i].chinese+stu[i].math;
	}
	for(int i=1;i<=3;++i)
	{
		for(int j=i+1;j<=number;++j)
		{
			if(stu[i].total<stu[j].total)
			{
				struct student temp;
				temp=stu[i];
				stu[i]=stu[j];
				stu[j]=temp;
			}
		}
		printf("%d %d\n",stu[i].id,stu[i].total);
	}
	return 0;
}
struct stu
{
	int id;
	int Chinese;
	int math;
}a[100000];
void main()
{
	int n,i,first,second,third,h1=0,h2=0,h3=0,e;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d%d%d",&a[i].id,&a[i].Chinese,&a[i].math);
	}
	first=0;
	second=0;
	third=0;
	for(i=0;i<n;i++)
	{
		if(first<(a[i].Chinese+a[i].math))
		{
			third=second;
			h3=h2;
			second=first;
			h2=h1;
			first=a[i].Chinese+a[i].math;
			h1=a[i].id;
		}
		else if(first==(a[i].Chinese+a[i].math)&&first>second)
		{
			third=second;
			h3=h2;
			h2=a[i].id;
			second=a[i].Chinese+a[i].math;
		}
		else if(first==(a[i].Chinese+a[i].math)&&first==second&&second>third)
		{
			third=a[i].Chinese+a[i].math;
			h3=a[i].id;
		}
		else if(first>(a[i].Chinese+a[i].math)&&second<(a[i].Chinese+a[i].math))
		{
			third=second;
			h3=h2;
			second=a[i].Chinese+a[i].math;
			h2=a[i].id;
		}
		else if(second>(a[i].Chinese+a[i].math)&&third<(a[i].Chinese+a[i].math))
		{
			third=a[i].Chinese+a[i].math;
			h3=a[i].id;
		}
	}
	printf("%d %d\n%d %d\n%d %d",h1,first,h2,second,h3,third);
}
int main(int argc, char* argv[])
{   
    int i,j,n;
    struct point 
    {
           int m,x,y;
           }a[100000],aa;
           scanf ("%d",&n);
           for (i=0;i<n;i++)
           {
               scanf ("%d%d%d",&a[i].m,&a[i].x,&a[i].y);
               }
           for(i=0;i<3;i++)
           {
                           for (j=i+1;j<n;j++)
                           {
                               if ((a[i].x+a[i].y)<(a[j].x+a[j].y))
                               {
                                   aa=a[j];
                                   a[j]=a[i];
                                   a[i]=aa;
                                   }
                                   }
                                   }
                                   for (i=0;i<3;i++)
                                   {
                                       printf ("%d %d\n",a[i].m,(a[i].x+a[i].y));
                                       }
                               
                                       return 0;
                                       }
struct student
{int id;
int yw;
int sx;
}stu[100000];
void main()
{
	int n,i,sum[100000],temp[3],max;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d %d %d",&stu[i].id,&stu[i].yw,&stu[i].sx);
		sum[i]=stu[i].yw+stu[i].sx;
	}
	for(i=0,max=-1,temp[0]=0;i<n;i++)
	{
		if(sum[i]>max)
		{
			max=sum[i];
			temp[0]=i;
		}
	}
    for(i=0,max=-1,temp[1]=0;i<n;i++)
	{
		if(i==temp[0])continue;
		else
		{
			if(sum[i]>max)
			{
				max=sum[i];
				temp[1]=i;
			}
		}
	}
    for(i=0,max=-1,temp[2]=0;i<n;i++)
	{
		if(i==temp[0]||i==temp[1])continue;
		else
		{
			if(sum[i]>max)
			{
				max=sum[i];
				temp[2]=i;
			}
		}
	}
	printf("%d %d\n",stu[temp[0]].id,sum[temp[0]]);
    printf("%d %d\n",stu[temp[1]].id,sum[temp[1]]);
	printf("%d %d",stu[temp[2]].id,sum[temp[2]]);
}
struct student
{
	int n1;
	int n2;
	int n3;
	struct student *next;
};
void main()
{
	struct student *p,*head,*tail;
	int n,i,sum[100000],max1,max2,max3,k1,k2,k3;
	scanf("%d",&n);
	head=NULL;tail=NULL;
	for(i=1;i<=n;i++)
	{
		p=(struct student*)malloc(len);
		scanf("%d%d%d",&p->n1,&p->n2,&p->n3);
		if(head==NULL)
			head=tail=p;
		else
		{
			tail->next=p;
			tail=p;}
		sum[i]=p->n2+p->n3;
	}
	max1=sum[1];k1=1;
	for(i=1;i<=n;i++)
		if(sum[i]>max1) {max1=sum[i];k1=i;}
	sum[k1]=0;

         max2=sum[1];k2=1;
         for(i=1;i<=n;i++)
		if(sum[i]>max2) {max2=sum[i];k2=i;}
	sum[k2]=0;

	max3=sum[1];k3=1;
	for(i=1;i<=n;i++)
		if(sum[i]>max3) {max3=sum[i];k3=i;}
	printf("%d %d\n%d %d\n%d %d\n",k1,max1,k2,max2,k3,max3);
}
struct student
{
	long number;
	int chinese;
	int math;
	int sum;
	struct student *next;
	struct student *last;
};
struct student *creat(int n)
{
	struct student *head,*p1,*p2;
	int i;
	p1=(struct student *)malloc(len);
	scanf("%d %d %d",&p1->number,&p1->chinese,&p1->math);
	p1->sum=p1->chinese+p1->math;
	p1->last=null;p1->next=null;
	head=p1;p2=p1;
	for(i=2;i<=n;i++)
	{
		p1=(struct student *)malloc(len);
		scanf("%d %d %d",&p1->number,&p1->chinese,&p1->math);
		p1->sum=p1->chinese+p1->math;
		p1->last=p2;
		p2->next=p1;
		p1->next=null;
		p2=p1;
	}
	return(head);
}
struct student *print(struct student *head)
{
	struct student *max,*p;
	p=head;max=head;
	while(p)
	{
		if(p->sum>max->sum)max=p;
		p=p->next;
	}
	printf("%d %d\n",max->number,max->sum);
	if(max==head)
	{
		max->next->last=null;
		head=max->next;
	}
	else 
	{
		max->next->last=max->last;
		max->last->next=max->next;
	}
	return(head);
}
void main()
{
	int n;
	struct student *head;
	scanf("%d",&n);
	head=creat(n);
	print(head);
	print(head);
	print(head);
}
struct stu
{
  int num;
  int a;
  int b;
  int total;
  int flag;
  struct stu *next;
};


void main()
{

  struct stu *p,*head;
  struct stu *p1,*p2,*pmax;
  int N,i;
  int max;

  scanf("%d",&N);

  //??
  p1=p2=(struct stu*)malloc(LEN);    
  scanf("%d%d%d",&p1->num,&p1->a,&p1->b);
  p1->total=p1->a+p1->b;
  p1->flag=0;
  p1->next=NULL;
  
  head=p1;
  
  
  for(i=0;i<N-1;i++)
  {      
	p2=p1;
	p1=(struct stu *)malloc(LEN);
    scanf("%d%d%d",&p1->num,&p1->a,&p1->b);
	p1->total=p1->a+p1->b;
	p1->flag=0;
	p1->next=NULL;

	p2->next=p1;
  }

  for(i=0;i<3;i++)
  {
    
	for(p=head,max=0;p!=NULL;p=p->next)
	   if(max<p->total&&p->flag==0) 
	   {
	     max=p->total;
		 pmax=p;
	   }
	pmax->flag=1;
	printf("%d %d\n",pmax->num,pmax->total);
  }
  

 /*  p=head;
  do
  {
    printf("%d*,",p->num);
	p=p->next;
  }while(p!=NULL);*/
  
 // for(i=0;i<3;i++)
   //  printf("%d %d\n",pmax[i]->num,pmax[i]->total);

 


}
struct student
{
	char num[6];
	int score[2];
	int sum;
} stu[100000];

void main()
{
	long n,i,j,maxi1,maxi2,maxi3;
         int max1=0,max2=0,max3=0;
	scanf("%ld",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s",stu[i].num);
		for(j=0;j<2;j++)
			scanf("%d",&stu[i].score[j]);
	}
      for(i=0;i<n;i++)
	  stu[i].sum=stu[i].score[0]+stu[i].score[1];
    
      for(i=0;i<n;i++)
        if(stu[i].sum>max1)
          {max1=stu[i].sum;
           maxi1=i;
          }
      stu[maxi1].sum=0;
      for(i=0;i<n;i++)
         if(stu[i].sum>max2)
           {max2=stu[i].sum;
            maxi2=i;
           }
	  stu[maxi2].sum=0;
      for(i=0;i<n;i++)
         if(stu[i].sum>max3)
           {max3=stu[i].sum;
            maxi3=i;
           }	    
     printf("%s %d\n%s %d\n%s %d",stu[maxi1].num,max1,stu[maxi2].num,max2,stu[maxi3].num,max3);
}
int main()
{
   int n,i,j,q,w;
   scanf("%d",&n);
   int a[n],b[n],c[n],d[n];
   for(i=0;i<n;i++)
   {scanf("%d %d %d",&a[i],&b[i],&c[i]);
                    
                    }
     for(i=0;i<n;i++)
   {      d[i]=b[i]+c[i];
                    
                    }
    for(i=0;i<3;i++)
   {      for(j=i+1;j<n;j++)
   {       if(d[i]<d[j])
         {q=d[i];
         d[i]=d[j];
         d[j]=q;
         w=a[i];
         a[i]=a[j];
        a[j]=w;}
        
         
         
          
          }
                    
                    }
                       for(i=0;i<3;i++)
   {    printf("%d %d\n",a[i],d[i]);
                    
                    }
                    
      

    getchar();
    getchar();
    getchar();
    getchar();
    getchar();
    

}
int main()
{
	struct student{
		int number;
		int chinese;
		int math;
		int sum;
		}students[100000];
		int n,i;
        int a1,b1,a2,b2,a3,b3;
		int c1,c2;
		int max=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d%d%d",&students[i].number,&students[i].chinese,&students[i].math);
		students[i].sum=students[i].chinese+students[i].math;
	}
	max=0;
	for(i=0;i<n;i++)
	{  
		if(students[i].sum>max)
		{
			max=students[i].sum;
			a1=students[i].number;
			b1=students[i].sum;
			c1=i;
		}
	}
	max=0;
	for(i=0;i<n;i++)
	{
	if(students[i].sum>max&&i!=c1)
		{
			max=students[i].sum;
			a2=students[i].number;
			b2=students[i].sum;
			c2=i;
		}
	}
   max=0;
   for(i=0;i<n;i++)
	{
		if(students[i].sum>max&&i!=c2&&i!=c1)
		{
			max=students[i].sum;
			a3=students[i].number;
			b3=students[i].sum;
		}
	}
	printf("%d %d\n",a1,b1);
    printf("%d %d\n",a2,b2);
    printf("%d %d\n",a3,b3);
	return 0;
}
void main()
{
	int a[100000],b[100000],d[100000],i,j,n,t,s;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d%d%d",&a[i],&b[i],&d[i]);
		d[i]=b[i]+d[i];
	}
	for(i=0;i<3;i++)
	{
		for(j=n-1;j>i;j--)
		{
			if (d[j]>d[j-1])
			{
				t=d[j];s=a[j];
				d[j]=d[j-1];a[j]=a[j-1];
				d[j-1]=t;a[j-1]=s;
			}
		}
	}
	for(i=0;i<3;i++)
	{
		printf("%d %d\n",a[i],d[i]);
	}
}
struct student
{
	int num;
	int chi;
	int math;
	int add;
	struct student *next;
};
//struct student*creat()
//{
//	struct student*p1,*p2,*head;
//	int i=0;
//	p1=p2=(struct student *)malloc(LEN);
//	
//	head=NULL;
//	i=i+1;
void main()
{
	int n,i;
	scanf("%d",&n);
	struct student *p1,*p2,*head;
	head=p1=p2=(struct student *)malloc(LEN);
	scanf("%d%d%d",&p1->num,&p1->chi,&p1->math);
	p1->add=p1->chi+p1->math;
	for(i=1;i<n-1;i++)
    {
	    p1=(struct student *)malloc(LEN);
		scanf("%d%d%d",&p1->num,&p1->chi,&p1->math);
		p1->add=p1->chi+p1->math;
		p2->next=p1;
		p2=p1;
	}
	scanf("%d%d%d",&p1->num,&p1->chi,&p1->math);
	p1->add=p1->chi+p1->math;
	p1->next=NULL;
//		printf("%d\n",p1->add);
	for(i=0;i<3;i++)
	{
		p1=head;
		int max=p1->add;
	    int *pp=&p1->num;
	    int *pp1=&p1->add;
	    while(p1->next)
		{
		  p1=p1->next;
		  if(p1->add>max) 
		  {
			max=p1->add;
			pp=&p1->num;
			pp1=&p1->add;
		  }
		}
//	    if(p2->add>max) 
//		{
//			max=p2->add;
//			pp=&p2->num;
//			pp1=&p2->add;
//		} 
    	 printf("%d %d\n",*pp,max);
	     *pp1=0;
	}
}
struct student{
  int num;
  int chin;
  int math;
  int sum;
};
int main()
{
 int n,i;
 scanf("%d",&n);
 struct student *stu;
 stu=(struct student*)malloc(n*sizeof(int)*4);
 for(i=0;i<n;i++){
  scanf("%d%d%d",&stu[i].num,&stu[i].chin,&stu[i].math);
  stu[i].sum=stu[i].chin+stu[i].math;
 }
 int j,e1,e2;
 for(j=1;j<4;j++){
  for(i=0;i<n-j;i++){
   if(stu[i].sum>=stu[i+1].sum){
         e1=stu[i+1].sum;
	e2=stu[i+1].num;
         stu[i+1].sum=stu[i].sum;
	stu[i+1].num=stu[i].num;
	stu[i].sum=e1;
         stu[i].num=e2;
   }
  }
 }
 
 printf("%d %d\n",stu[n-1].num,stu[n-1].sum);
 printf("%d %d\n",stu[n-2].num,stu[n-2].sum);
 printf("%d %d\n",stu[n-3].num,stu[n-3].sum);
 free(stu);
 return 0;
}
struct student
{
	int id,word,math,sum;
}stu[100000];
void main()
{
	int n,i=1,maxi;
	scanf("%d",&n);
	while(i<=n)
	{
		scanf("%d %d %d",&stu[i].id,&stu[i].word,&stu[i].math);
		stu[i].sum=stu[i].word+stu[i].math;
		i=i+1;
	}
	i=n;
	stu[n+1].sum=0;
	stu[n+2].sum=0;
	stu[n+3].sum=0;	
	stu[n+1].id=0;
	stu[n+2].id=0;
	stu[n+3].id=0;
	stu[n+1].math=0;
	stu[n+2].math=0;
	stu[n+3].math=0;
	stu[n+1].word=0;
	stu[n+2].word=0;
	stu[n+3].word=0;	
	while(i>=1)
	{
		if(stu[i].sum>=stu[n+1].sum)
		{	stu[n+1]=stu[i];
		maxi=i;
		}
		i=i-1;
	}
	printf("%d %d\n",stu[n+1].id,stu[n+1].sum);
	stu[maxi].sum=0;
	i=n;
	while(i>=1)
	{
		if(stu[i].sum>=stu[n+2].sum)
		{	stu[n+2]=stu[i];
		maxi=i;
		}
		i=i-1;
	}
	printf("%d %d\n",stu[n+2].id,stu[n+2].sum);
	stu[maxi].sum=0;
	i=n;
	while(i>=1)
	{
		if(stu[i].sum>=stu[n+3].sum)
			stu[n+3]=stu[i];
		i=i-1;
	}
	printf("%d %d\n",stu[n+3].id,stu[n+3].sum);
}
struct marks
{
    long ID;
    int Chinese;
    int Maths;
    int total;
}student[100000],first,second,third;

void main()
{
   first.total=0;
   second.total=0;
   third.total=0;
   int student_num,i,count=0;
   scanf("%ld",&student_num);
   for(i=0;i<student_num;i++)
   {
       scanf("%ld%d%d",&student[i].ID,&student[i].Chinese,&student[i].Maths);
   }
   for(i=0;i<student_num;i++)
  {
      student[i].total=(student[i].Chinese+student[i].Maths);
   }
    for(i=0;i<student_num;i++)
   {
       if(student[i].total>first.total)
       {
             first=student[i];
       }
   }
  for(i=0;i<student_num;i++)
  {
         if(student[i].total==first.total)
         {count++;printf("%ld %d\n",student[i].ID,student[i].total);}
         if(count>3) break;
   }
   for(i=0;i<student_num;i++)
  {
     if(student[i].total>second.total&&student[i].total<first.total)
     {
                 second=student[i];
     }
   }
  for(i=0;i<student_num;i++)
  {
         if(count>=3) break;
         if(student[i].total==second.total)
         {count++;printf("%ld %d\n",student[i].ID,student[i].total);}
   }
   for(i=0;i<student_num;i++)
  {
     if(student[i].total>third.total&&student[i].total<second.total)
     {
                 third=student[i];
     }
   }
   for(i=0;i<student_num;i++)
  {
         if(count>=3) break;
         if(student[i].total==third.total)
         {count++;printf("%ld %d\n",student[i].ID,student[i].total);}
   }
}
void main()
{
 struct stu
 {
  long num,c,m,d;
  struct stu *next;
 };
 long n,i,f;
 struct stu *head,*p1,*p2;
 scanf("%ld",&n);
 for (i=1;i<=n;i++)
   {
   p1=(struct stu*)malloc(LEN);
   scanf("%ld%ld%ld",&p1->num,&p1->c,&p1->m);
   p1->d=p1->c+p1->m;
   if (i==1)
     {
     p1->next=0;
     head=p1;
     }
     else
     {
     if (i<=3) f=1;
       else
       {
       p2=head->next->next;
       if (p1->d>p2->d) f=1;
	 else f=0;
       }
     if (f==1)
     {
     p2=head;
     if (p2->d<p1->d)
       {
       p1->next=p2;
       head=p1;
       }
       else
	 {
	 while ((p2->next!=0)&&(p2->next->d>p1->d))
	   p2=p2->next;
	 p1->next=p2->next;
	 p2->next=p1;
	 }
     }
     }
   }
 p1=head;
 for (i=1;i<=3;i++)
   {
   printf("%ld %ld\n",p1->num,p1->d);
   p1=p1->next;
   }
}
int main()
{
	int n,i;
	int sum[100000];
	int max1,max2,max3;
	int x=0;
	scanf("%d",&n);
	struct {
		int number;
		int chin;
		int math;
	}student[100000];
	for(i=0;i<n;i++){
		scanf("%d%d%d",&student[i].number,&student[i].chin,&student[i].math);
		sum[i]=student[i].chin+student[i].math;}
	max1=sum[0];
	max2=sum[0];
	max3=sum[0];
	for(i=0;i<n;i++){
		if(sum[i]>max1)
			max1=sum[i];}
	for(i=0;i<n;i++){
		if(sum[i]==max1){
			printf("%d %d\n",student[i].number,sum[i]);
			x++;}
		if(x>=3)
			break;
	}
	for(i=0;i<n;i++){
		if((sum[i]>max2)&&(sum[i]!=max1))
			max2=sum[i];}
	for(i=0;i<n;i++){
		if(x>=3)
			break;
		if(sum[i]==max2){
			printf("%d %d\n",student[i].number,sum[i]);
			x++;}
	}
	for(i=0;i<n;i++){
		if((sum[i]>max3)&&(sum[i]!=max1)&&(sum[i]!=max2))
			max3=sum[i];}
	for(i=0;i<n;i++){
		if(x>=3)
			break;
		if(sum[i]==max3){
			printf("%d %d",student[i].number,sum[i]);
		x++;}
	}
	return 0;
}
int main()
{
    int n,i,j,t,First=0,FirstNum,Second=0,SecondNum,Third=0,ThirdNum;
    scanf("%d",&n);
    struct Student
    {
       int Chinese;
       int Math;
       int Sum;
       int Num;
    }Student[n+1];
    for (i=1;i<=n;i++)
      {
         scanf("%d %d %d",&Student[i].Num,&Student[i].Chinese,&Student[i].Math);
         Student[i].Sum=Student[i].Chinese+Student[i].Math;
      }
    for (i=1;i<=n;i++)
      {
        if (Student[i].Sum>First)
         {
             First=Student[i].Sum;
             FirstNum=i;
         }
      }
    for (i=1;i<=n;i++)
      {
        if (Student[i].Sum>Second&&Student[i].Sum<=First&&i!=FirstNum)
         {
             Second=Student[i].Sum;
             SecondNum=i;
         }
      }
    for (i=1;i<=n;i++)
      {
        if (Student[i].Sum>Third&&Student[i].Sum<=Second&&i!=SecondNum&&i!=FirstNum)
         {
             Third=Student[i].Sum;
             ThirdNum=i;
         }
      }
    printf("%d %d\n",FirstNum,First);
    printf("%d %d\n",SecondNum,Second);
    printf("%d %d\n",ThirdNum,Third);
    
}
int main()
{
	struct stu
	{
		int yu;
		int shu;
		char name[6]; 
	};
	struct stu s[100000],one,two,three;
	one.yu=0;one.shu=0;
	two.yu=0;two.shu=0;
	three.yu=0;three.shu=0;
	int n,j,k;
	scanf("%d",&n);
	for(j=0;j<n;j++)
	{
		scanf("%s %d %d",s[j].name,&s[j].yu,&s[j].shu);
	}
	for(j=0;j<n;j++)
	{
		if((s[j].yu+s[j].shu)>(one.yu+one.shu))
		{
			one=s[j];
			k=j;
		}
	}
	s[k].yu=0;s[k].shu=0;
	for(j=0;j<n;j++)
	{
		if((s[j].yu+s[j].shu)>(two.yu+two.shu))
		{
			two=s[j];
			k=j;
		}
	}
	s[k].yu=0;s[k].shu=0;
	for(j=0;j<n;j++)
	{
		if((s[j].yu+s[j].shu)>(three.yu+three.shu))
		three=s[j];
	}
	printf("%s %d\n%s %d\n%s %d\n",one.name,one.yu+one.shu,two.name,two.yu+two.shu,three.name,three.yu+three.shu);
	return 0;
}
struct stu
{
	int ID;
	int Chinese;
	int math;
	int sum;
}zz[100000],mx,mx1,mx2;
int main()
{
	int n,i,j;
	cin>>n;
	for ( i = 0 ; i < n ; i ++ )
	{
		cin>>zz[i].ID>>zz[i].Chinese>>zz[i].math;
		zz[i].sum = zz[i].Chinese + zz[i].math;
	}
	mx = zz[0];
	for ( i = 0 ; i < n ; i ++ )
	{
		if ( zz[i].sum > mx.sum )
			mx = zz[i];
	}
		cout<<mx.ID<<' '<<mx.sum<<endl;
		mx.sum=0;
		mx1 = mx;
		for ( i = 0 ; i < n ; i ++ )
	{
		if ( zz[i].sum > mx1.sum )
			{
				if ( zz[i].ID == mx.ID )
				continue;
			mx1 = zz[i];
			}
	}
		cout<<mx1.ID<<' '<<mx1.sum<<endl;
		mx1.sum=0;
		mx2 = mx1;
		for ( i = 0 ; i < n ; i ++ )
	{
		if ( zz[i].sum > mx2.sum )
			{
				if ( zz[i].ID == mx.ID || zz[i].ID == mx1.ID)
				continue;
			mx2 = zz[i];
			}
	}
		cout<<mx2.ID<<' '<<mx2.sum<<endl;
}
struct student{				
	int no;
	int ch;
	int math;
	int sum;
	struct student *next;
};


struct student *creat(long n)
{
	long i;
	struct student *head, *p,*q;
	head=(struct student *)malloc(len);
	p=(struct student *)malloc(len);
	head->next=q=p;
	scanf("%d %d %d",&p->no, &p->ch,&p->math);
	p->sum=(p->ch)+(p->math);				

	for(i=1;i<n;i++)
	{
		p=(struct student *)malloc(len);
		scanf("%d %d %d",&p->no, &p->ch,&p->math);
		p->sum=(p->ch)+(p->math);	
		q->next=p;
		q=p;
		p->next=NULL;
	}
//	for(p=head->next;p!=NULL;p=p->next)printf("%d %d",p->no,p->sum);
	return(head);
}

void sort(struct student *head)   
{
	struct student *p,*q1,*q2,*q3;
	int m1,m2,m3;
	for(p=head->next,m1=p->sum;p!=NULL;p=p->next)
		if(p->sum>m1){m1=p->sum;q1=p;}
	printf("%d %d\n",q1->no,q1->sum);
	for(p=head->next,m2=p->sum;p!=NULL;p=p->next)
		if(p->sum>m2 && p!=q1){m2=p->sum;q2=p;}
	printf("%d %d\n",q2->no,q2->sum);
	for(p=head->next,m3=p->sum;p!=NULL;p=p->next)
		if(p->sum>m3 && p!=q1 && p!= q2){m3=p->sum;q3=p;}
	printf("%d %d\n",q3->no,q3->sum);
}

int main()
{
	long n;
	struct student *head;
	scanf("%d",&n);
	head=creat(n);
	sort(head);
	return 0;
}
struct student
{
	int num,y,b,he;
}a[100003];

void main()
{
	int n,i,j,he,k;
	scanf("%d",&n);

	for (i=1;i<=n;i++)
	{
		scanf("%d %d %d",&a[i].num,&a[i].y,&a[i].b);
		a[i].he=a[i].y+a[i].b;
	};

	for (i=1;i<=2;i++)
	{
		k=i;
		for (j=i+1;j<=n;j++)
			if (a[j].he>a[k].he) k=j; 
		printf("%d %d",a[k].num,a[k].he);
		printf("\n");
		a[k].he=0;
	}
			k=1;
		for (j=i+1;j<=n;j++)
			if (a[j].he>a[k].he) k=j; 
		printf("%d %d",a[k].num,a[k].he);
		a[k].he=0;
}
int main()
{
	int n;
	cin>>n;
	struct student
	{
		int ID;
		int chinese;
		int math;
		int total;
	}score[100000];
	for(int i=0;i<n;i++)
	{
		cin>>score[i].ID>>score[i].chinese>>score[i].math;
		score[i].total=score[i].chinese+score[i].math;
	}
	for(int i=0;i<3;i++)
		for(int j=n-1;j>0;j--)
			if(score[j].total>score[j-1].total)
			{
				struct student temp=score[j];
			    score[j]=score[j-1];
			    score[j-1]=temp;
			}
	if(n==2)
			for(int i=0;i<n;i++)
				cout<<score[i].ID<<score[i].total<<endl;
	else {
	for(int i=0;i<3;i++)
		cout<<score[i].ID<<' '<<score[i].total<<endl;
	}
}
struct student
{
	int num;
	int chi;
	int mat;
	int all;
	struct student *next;
}
main()
{
	struct student *head,*p1,*p2,*p;
	long n,i;
	int j,max;
	scanf("%d",&n);
	p1=p2=(struct student*)malloc(LEN);
	scanf("%d%d%d",&p1->num,&p1->chi,&p1->mat);
	p1->all=p1->chi+p1->mat;
	head=p1;
	for(i=1;i<n;i++)
	{
		if(i>1)
			p2->next=p1;
		p2=p1;
		p1=(struct student*)malloc(LEN);
		scanf("%d%d%d",&p1->num,&p1->chi,&p1->mat);
		p1->all=p1->chi+p1->mat;
	}
	p2->next=NULL;
	for(j=0;j<3;j++)
	{
		p=p1=head;
		max=p->all;
		while(p->next!=NULL)
		{
			p2=p;
			p=p->next;
			if(p->all>max)
			{
				max=p->all;
				p1=p2;
			}
		}
		printf("%d %d\n",p1->next->num,p1->next->all);
		if(max==head->all)
			head=head->next;
		else
			p1->next=(p1->next)->next;
	}
}
int main()
{
	struct st 
	{   int num;
	    int x;
		int y; 
        int sum; 
	}a[100000],m1,m2,m3;
	int n,i,j;
	scanf("%d",&n);
    for (i=0;i<n;i++)
	{     scanf("%d %d %d",&a[i].num,&a[i].x,&a[i].y);
	      a[i].sum=a[i].x+a[i].y;
	}
	m1.sum=0; m2.sum=0; m3.sum=0;
	for (i=0;i<n;i++)
		if (a[i].sum>m1.sum)  m1=a[i];
	for (i=0;i<n;i++)	
		if ((a[i].sum>m2.sum)&&(a[i].sum<=m1.sum)&&(a[i].num!=m1.num)) m2=a[i];
	for (i=0;i<n;i++)
	  if ((a[i].sum>m3.sum)&&(a[i].sum<=m2.sum)&&(a[i].num!=m2.num)&&(a[i].num!=m1.num)) m3=a[i];	
	printf("%d %d\n%d %d\n%d %d\n",m1.num,m1.sum,m2.num,m2.sum,m3.num,m3.sum);
	return 0;
}
int main(int argc, char* argv[])
{
	int n,*x,*y,*s,*z,i,j,o=0,t=0;
	scanf("%d",&n);
	x=(int*)malloc(sizeof(int)*n);
    y=(int*)malloc(sizeof(int)*n);
    s=(int*)malloc(sizeof(int)*n);
	z=(int*)malloc(sizeof(int)*n);
    for(i=0;i<n;i++)
	{
		scanf("%d %d %d",&x[i],&y[i],&s[i]);
		z[i]=y[i]+s[i];
	}
	for(j=0;j<3;j++)
	{
    for(i=0;i<n-1;i++)
	{
	 if(z[i]>=z[i+1])
	 {
       o=z[i];
       z[i]=z[i+1];
	   z[i+1]=o;
	   t=x[i];
       x[i]=x[i+1];
	   x[i+1]=t;
	 }
	}
	}
	printf("%d %d\n",x[n-1],z[n-1]);
    printf("%d %d\n",x[n-2],z[n-2]);
	printf("%d %d\n",x[n-3],z[n-3]);
return 0;
}