semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int main(int argc, char* argv[])
{
	int n,i,j,a,zf[100000];
	struct student
	{
		int name;
		int yw;
		int sx;

	}stu[100000];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d%d%d",&stu[i].name,&stu[i].yw,&stu[i].sx);
		zf[i]=stu[i].yw+stu[i].sx;
	}
	for(j=1;j<4;j++){
		for(i=0;i<n-j;i++){
			if(zf[i]>=zf[i+1]){
				a=zf[i];
				zf[i]=zf[i+1];
				zf[i+1]=a;
				a=stu[i].name;
				stu[i].name=stu[i+1].name;
				stu[i+1].name=a;
			}
		}
	}
	for(i=n-1;i>=n-3;i--){
	printf("%d %d\n",stu[i].name,zf[i]);
	}
	return 0;
}
struct student{
	int No;
	int Chinese;
	int math;
	int score;
}stu[100000];


int main(){
	int n,i,j,a,b;
	scanf("%d",&n);

         for(i=0;i<n;i++){
		scanf("%d %d %d",&stu[i].No,&stu[i].Chinese,&stu[i].math);
		stu[i].score=stu[i].Chinese+stu[i].math;
	}
	
	for(j=n-1;j>n-4;j--){
	    for(i=0;i<j;i++){
	        if(stu[i+1].score<stu[i].score||stu[i+1].score==stu[i].score){
			a=stu[i+1].score;
			stu[i+1].score=stu[i].score;
			stu[i].score=a;
			b=stu[i+1].No;
			stu[i+1].No=stu[i].No;
			stu[i].No=b;
			}
		}
	}
	for(i=n-1;i>n-4;i--){
		printf("%d %d\n",stu[i].No,stu[i].score);
	}
	
      
	return 0;
}
void main()
{
	struct stu
	{int a,b,c;};
	int i,n,j=0;scanf("%d",&n);
	struct stu *hd,*p;
	hd=p=(struct stu*)malloc(100000*sizeof(struct stu));
	for(i=0;i<n;i++,p++)
	{scanf("%d %d %d",&p->a,&p->b,&p->c);}
	int max=0;
nxt:	for(p=hd,i=0;i<n;i++,p++)
	{
		if(p->b+p->c>max) {max=p->b+p->c;}
	}
	for(p=hd,i=0;i<n;i++,p++)
	{
		if(p->b+p->c==max) {printf("%d %d\n",p->a,p->b+p->c);p->b=0;p->c=0;max=0;j++;break;}
	}
	if(j<=2) goto nxt;

}
int main()

{
    int n,i,j,k,z,x;
    scanf("%d",&n);
    struct Student
    {
       int num;
       int yuwen;
       int shuxue;
       int zongfen;       
    }stu[n];
    
    
    for(i=0;i<n;i++)
    {
        scanf("%d%d%d",&stu[i].num,&stu[i].yuwen,&stu[i].shuxue);
        stu[i].zongfen=stu[i].yuwen+stu[i].shuxue;                
    }
    
    for(j=0;j<3;j++)
    {
        for(k=0;k<n-1;k++)               
        {
            if(stu[k].zongfen>stu[k+1].zongfen)
            {
               z=stu[k+1].zongfen;
               stu[k+1].zongfen=stu[k].zongfen;
               stu[k].zongfen=z; 
               x=stu[k+1].num;
               stu[k+1].num=stu[k].num;
               stu[k].num=x;                               
            }   
            else if(stu[k].zongfen==stu[k+1].zongfen&&stu[k].num<stu[k+1].num)
            {
               z=stu[k+1].zongfen;
               stu[k+1].zongfen=stu[k].zongfen;
               stu[k].zongfen=z; 
               x=stu[k+1].num;
               stu[k+1].num=stu[k].num;
               stu[k].num=x;                               
            }   
            else;                              
        }
    }
    
    for(j=0;j<3;j++)
    {
        printf("%d %d\n",stu[n-1-j].num,stu[n-1-j].zongfen);            
    }
    
    
    getchar();
    getchar();
    
    
    
        

}
struct student
{
	int id;
	int china;
	int math;
	int total;
}stu[M],temp;
int main()
{
	int n,i,j,count;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d%d%d",&stu[i].id,&stu[i].china,&stu[i].math);
		stu[i].total=stu[i].china+stu[i].math;
	}
	for(i=0;i<3;i++)
	{
		temp=stu[i];
		count=i;
		for(j=i+1;j<n;j++)
		{
			if(stu[j].total>temp.total)
			{
				temp=stu[j];
				count=j;
			}
		}
		stu[count]=stu[i];
		stu[i]=temp;
	}
	for(i=0;i<3;i++)
		printf("%d %d\n",stu[i].id,stu[i].total);
	return 0;
}
struct student
{
	int num;
	int score1;
	int score2;
	int sum;
	struct student *next;
};
struct student *creat(int m)
{
	int i=0;
    struct student *head,*p1,*p2;
	p1=p2=(struct student *)malloc(LEN);
    scanf("%d %d %d",&p1->num,&p1->score1,&p1->score2);
	p1->sum=(p1->score1)+(p1->score2);
    head=NULL;
	while(p1->num<m)
	{
		i++;
		if(i==1) head=p1;
	    else p2->next=p1;
		p2=p1;
		p1=(struct student *)malloc(LEN);
        scanf("%d %d %d",&p1->num,&p1->score1,&p1->score2);
	    p1->sum=(p1->score1)+(p1->score2);
	}
	p2->next=NULL;
	return(head);
}
void print(struct student *head)
{
    struct student *p=head,*q=head;
	int a=0,b=0,c=0;
	if(head!=NULL)
		
	{do
		{
			if(a<p->sum)
			{a=p->sum;q=p;}
			p=p->next;
		}while(p!=NULL);
		printf("%d %d\n",q->num,q->sum);
        q->sum=0;
        p=head;q=head;
	 do
	  {if(b<p->sum)
			{b=p->sum;q=p;}
			p=p->next;
	  }while(p!=NULL);
		printf("%d %d\n",q->num,q->sum);
        q->sum=0;
        p=head;q=head;
		do
		{if(c<p->sum)
			{c=p->sum;q=p;}
			p=p->next;
	  }while(p!=NULL);
	printf("%d %d",q->num,q->sum);
	}
}
void main()
{
	int m;
	scanf("%d",&m);
	struct student *head,stu;
	head=creat(m);
	print(head);
}
struct student
{
	int num;
	int score1;
	int score2;
	int sum;
}stu[100000],max,secondmax,thirdmax;
int main()
{
	max.sum=secondmax.sum=thirdmax.sum=0;
	int i,n;
	scanf("%d",&n);
	for (i=0;i<n;i++)
	{
		scanf("%d %d %d",&stu[i].num,&stu[i].score1,&stu[i].score2);
		stu[i].sum=stu[i].score1+stu[i].score2;
	}
	for (i=0;i<n;i++)
	{
		if (stu[i].sum>max.sum)
			max=stu[i];
	}
	for (i=0;i<n;i++)
	{
		if (stu[i].sum<max.sum&&stu[i].sum>secondmax.sum)
			secondmax=stu[i];
	}
	for (i=0;i<n;i++)
	{
		if (stu[i].sum==max.sum&&stu[i].num!=max.num)
		{
			secondmax=stu[i];
			break;
		}
	}
	for (i=0;i<n;i++)
	{
		if (stu[i].sum<secondmax.sum&&stu[i].sum>thirdmax.sum)
			thirdmax=stu[i];
	}
	for (i=0;i<n;i++)
	{
		if (stu[i].sum==secondmax.sum&&stu[i].num!=max.num&&stu[i].num!=secondmax.num)
		{
			thirdmax=stu[i];
			break;
		}
	}
	printf("%d %d\n%d %d\n%d %d",max.num,max.sum,secondmax.num,secondmax.sum,thirdmax.num,thirdmax.sum);
	return 0;
}
struct student
{
	int num;
	int yuwen;
	int math;
	int total;
	struct student *next;
};
long m,n;
struct student *creat(void)
{
	struct student *head;
	struct student *p1,*p2;
	m=0;head=0;
	while(m<n)
	{
	m=m+1;
	p1=(struct student *)malloc(sizeof(struct student));
	scanf("%d %d %d",&p1->num,&p1->yuwen,&p1->math);
    p1->total=p1->yuwen+p1->math;
	if(m==1){head=p1;p2=p1;}
	else p2->next=p1;
	p2=p1;
	}
    p2->next=0;	
	return(head);
}

void main()
{
	struct student *head,*p,*px;
	int a[3][2],t1,t2;
	scanf("%ld",&n);
	head=creat();
	p=head;
	a[0][1]=a[1][1]=a[2][1]=0;
	if(head!=0)
	do
	{
		if(p->total>a[2][1])
		{a[2][1]=p->total;a[2][0]=p->num;}
		if(a[2][1]>a[1][1])
		{t1=a[1][1];a[1][1]=a[2][1];a[2][1]=t1;t2=a[1][0];a[1][0]=a[2][0];a[2][0]=t2;}
        if(a[1][1]>a[0][1])
        {t1=a[0][1];a[0][1]=a[1][1];a[1][1]=t1;t2=a[0][0];a[0][0]=a[1][0];a[1][0]=t2;}
		p=p->next;
	}
		while(p!=0);
	for(t1=0;t1<=2;t1++)
	{
		printf("%d %d\n",a[t1][0],a[t1][1]);
	}

}
void main()
{   
	int n,i,y,s,z,x,a,b,c,ax,bx,cx;
    scanf("%d",&n);a=0;b=0;c=0;ax=0;bx=0;cx=0;
	for(i=1;i<=n;i++)
	{   
		
		scanf("%d %d %d",&x,&y,&s);
		z=y+s; 
		if(c>=z) continue;
		else if(b>=z) {c=z; cx=x;}
		else if(a>=z) {c=b;cx=bx; b=z; bx=x;}
		else {c=b; cx=bx; b=a; bx=ax; a=z;ax=x;}
    }
	printf("%d %d\n",ax,a);
	printf("%d %d\n",bx,b);
	printf("%d %d\n",cx,c);
}
int main()
{
    int n,i,score[100000],max1=0,m1=0,max2=0,m2=0,max3=0,m3=0;
    scanf("%d",&n);
    struct stu{    
           int No;
           int yw;
           int math;
           }s[100000];              
    for(i=0;i<n;i++){
                     scanf("%d%d%d",&s[i].No,&s[i].yw,&s[i].math),
                     score[i]=s[i].yw+s[i].math;
                     if(score[i]>max1){
                                       max3=max2;
                                       max2=max1;                                       
                                       max1=score[i];
                                       m3=m2;
                                       m2=m1;
                                       m1=i;
                                       continue;
                                       }
                     if(score[i]<=max1&&score[i]>max2){
                                        max3=max2;
                                        max2=score[i];
                                        m3=m2;
                                        m2=i;
                                        continue;
                                        }
                     if(score[i]<=max2&&score[i]>max3){
                                        max3=score[i];
                                        m3=i;
                                        continue;
                                        }
                     }
    printf("%d %d\n%d %d\n%d %d\n",s[m1].No,max1,s[m2].No,max2,s[m3].No,max3);   
    
    return 0;
    }
int cmp(const void *a,const void *b)
    {
         return(*(int*)a-*(int*)b);
    }
int main()
{
    struct student
    {
           int num;
           int chinese;
           int maths;
           int amount;
    };
    struct student stu[100000];
    int a[100000],n,l,j,k;
    scanf("%d",&n);
    for (int i=0;i<n;i++)
    {
        scanf("%d %d %d",&stu[i].num,&stu[i].chinese,&stu[i].maths);
        a[i]=stu[i].chinese+stu[i].maths;
    }
    qsort(a,n,sizeof(a[0]),cmp);
    for(int h=n-1;h>=0;h--)
    {
            if (a[n-1]==stu[h].chinese+stu[h].maths)
            {l=stu[h].num;}
    }
     for(int g=n-1;g>=0;g--)
    {
            if (a[n-2]==stu[g].chinese+stu[g].maths&&(g+1)!=l)
            {j=stu[g].num;}
    }
     for(int f=n-1;f>=0;f--)
    {
            if (a[n-3]==stu[f].chinese+stu[f].maths&&(f+1)!=j&&(f+1)!=l)
            {k=stu[f].num;}
    }
    printf("%d %d\n",l,a[n-1]);
    printf("%d %d\n",j,a[n-2]);
    printf("%d %d\n",k,a[n-3]);
}
int main()
{
    struct ss{
		int num,yu,sh;
		int sum;
	};
	int n,i;
	struct ss *stu;
	
	scanf("%d",&n);
	stu=(struct ss *)malloc(sizeof(ss)*n);
	for(i=0;i<n;i++)
	{int num1,yu1,sh1;
	(stu+i)->num=0;
	(stu+i)->yu=0;
	(stu+i)->sh=0;
	(stu+i)->sum=0;
	scanf("%d %d %d",&num1,&yu1,&sh1);
    (stu+i)->num=num1;
	(stu+i)->yu=yu1;
	(stu+i)->sh=sh1;
    (stu+i)->sum=yu1+sh1;
	}
	for(i=1;i<n;i++)
	{int t;
	if((stu+0)->sum<(stu+i)->sum)
	{t=(stu+0)->sum;
     (stu+0)->sum=(stu+i)->sum;
	 (stu+i)->sum=t;
	 t=(stu+0)->num;
	 (stu+0)->num=(stu+i)->num;
	 (stu+i)->num=t;}}
	for(i=2;i<n;i++)
	{int t;
	if((stu+1)->sum<(stu+i)->sum)
	{t=(stu+1)->sum;
     (stu+1)->sum=(stu+i)->sum;
	 (stu+i)->sum=t;
	 t=(stu+1)->num;
	 (stu+1)->num=(stu+i)->num;
	 (stu+i)->num=t;}}
	for(i=3;i<n;i++)
	{int t;
	if((stu+2)->sum<(stu+i)->sum)
	{t=(stu+2)->sum;
     (stu+2)->sum=(stu+i)->sum;
	 (stu+i)->sum=t;
	 t=(stu+2)->num;
	 (stu+2)->num=(stu+i)->num;
	 (stu+i)->num=t;}}
	for(i=0;i<3;i++)
	{	printf("%d %d\n",(stu+i)->num,(stu+i)->sum);}
    free(stu);
	return 0;
}
struct s
	{
		int a;
		int sc[2];
	};
void main()
{
	struct s st[100000];
	int t=0,j=0,max=0,p[3]={-1,-1};
	long n,i;
	scanf("%ld",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d%d%d",&st[i].a,&st[i].sc[0],&st[i].sc[1]);
		st[i].sc[0]=st[i].sc[0]+st[i].sc[1];
	}
	i=0;
	while(t<3)
	{
		if(i<n&&i!=p[0]&&i!=p[1])
		{
			j=(st[i].sc[0]>max)? i:j;
			max=(st[i].sc[0]>max)? st[i].sc[0]:max;
			i++;
		}
		else if(i<n&&(i==p[0]||i==p[1]))
			i++;
		else if(i=n)
		{
			printf("%d %d\n",j+1,max);
			p[t]=j;
			t++;
			j=0;
			max=0;
			i=0;
		}
	}
}
int pfCompare(const void* elem1,const void* elem2)
{
     int d;
     d=*((int*)elem2)-*((int*)elem1);
     return d;
}
struct student
    {
           long int ID;
           long int c;
           long int m;
    };
int main()
{
    long int n,i,j,k;
    int b[100000];
    int e[3];
    scanf("%d",&n);
   struct student a[100000];
   for(i=0;i<n;i++)
   {
                   scanf("%d %d %d",&a[i].ID,&a[i].c,&a[i].m);
   }
   for(i=0;i<n;i++)
   {
                   b[i]=a[i].c+a[i].m;
   }
   qsort(b,n,sizeof(long int),pfCompare); 
   for(i=0;i<n;i++)
   {
                   if(b[0]==a[i].c+a[i].m)
                   {
                                          e[0]=a[i].ID;
                                           j=i;
                                           break;
                   }
  }
  for(i=0;i<n;i++)
   {
                   if((b[1]==a[i].c+a[i].m)&&i!=j)
                   {
                                                  e[1]=a[i].ID;
                                                     k=i;
                                                    break;
                   }
  }
  for(i=0;i<n;i++)
   {
                   if((b[2]==a[i].c+a[i].m)&&i!=j&&i!=k)
                   {
                                                        e[2]=a[i].ID;
                                                         break;
                   }
  }
   for(i=0;i<=2;i++)
   {
                    printf("%d %d\n",e[i],b[i]);
   }
   getchar();
   getchar();
   getchar();
}
struct student
{
 int a;
 int b;
 int c;
 int d;
 struct student *next;
};
 int n;
 struct student *creat(int i)
 {
	 struct student *head,*p1,*p2;
	 n=0;
	 p1=p2=(struct student *)malloc(sizeof(struct student));
	 scanf("%d %d %d",&p1->a,&p1->b,&p1->c);
	 p1->d=p1->c+p1->b;
	 head=NULL;
	 while(n<i-1)
	 {
      n=n+1;
	  if(n==1)head=p1;
	  else p2->next=p1;
	  p2=p1;
	  p1=(struct student *)malloc(sizeof(struct student));
      scanf("%d %d %d",&p1->a,&p1->b,&p1->c);
      p1->d=p1->c+p1->b;
	 }
	 p2->next=NULL;
	 return(head);
 }
void del(struct student *ahead,int num)
 { struct student *p1,*p2;
    p1=ahead;
   while(num!=p1->d&&p1->next!=NULL)
   {p2=p1;p1=p1->next;}
   if(num==p1->d)
   {
	   if(p1==ahead){printf("%d %d\n",p1->a,p1->d);ahead=p1->next;}
   else{printf("%d %d\n",p1->a,p1->d);p2->next=p1->next;}
   }
}
void print(struct student *head)
{
	int i;
	 struct student *p;
	 for(i=0;i<3;i++)
	 {
		 p=head;
     int max=p->d;
	 while(p->next!=NULL)
	 {
		 p=p->next;
		 if(max<p->d)
			 max=p->d;
	 }
	 del(head,max);
	 }
}
void main()
{
	int i;
	scanf("%d",&i);
   struct student *ahead;
   ahead=creat(i);
   print(ahead);
}
struct student
{
	int num;
	int chi;
	int math;
	int total;
	struct student *next;
	
};
struct student* creat(int n)
{
	struct student *p1,*p2,*head;
	int i;
	p1=p2=(struct student*) malloc(len);
	head=NULL;
	i=0;
	while(i<n)
	{
		scanf("%d %d %d",&p1->num,&p1->chi,&p1->math);
		i=i+1;
		if(i==1)
			head=p1;
		else p2->next=p1;
		p2=p1;
		p1=(struct student*)malloc(len);
	}
	p2->next=NULL;
	return(head);
}
void sum(struct student*head)
{
	struct student*p1;
    p1=head;
	while(p1)
	{
		p1->total=p1->chi+p1->math;
		p1=p1->next;
		
	}
}
struct student* choose(struct student*head)
{
	struct student*p1,*p2;
	p1=head;
	p2=p1;
	while(p1->next)
	{
		if(p2->total<(p1->next)->total)
			p2=p1->next;
		p1=p1->next;
		
	}
	printf("%d %d\n",p2->num,p2->total);
	return(p2);
}
struct student* del(struct student*head,struct student*p2)
{
	struct student *p1;
	p1=head;
	if(p2==head)
	{
		head=p2->next;
		return(head);
	}
	else 
	{
		while(p1->next!=p2)
	{
		p1=p1->next;
	}
		p1->next=p2->next;
	}
	return(head);
	

}
void main()
{
	struct student *head,*p;
	int n;
	scanf("%d",&n);
	if(n>=3)
	{
	head=creat(n);
	sum(head);
	p=choose(head);
	head=del(head,p);
	p=choose(head);
	head=del(head,p);
	p=choose(head);
	}
	else if(n=2)
	{
		head=creat(n);
	sum(head);
	p=choose(head);
	head=del(head,p);
	p=choose(head);

	}
	else
	{
		
		head=creat(n);
	sum(head);
	p=choose(head);
	}

	
}
struct info
{
	int num;
	int chin;
	int math;
	struct info *next;
};
struct info *create(int n)
{   
	int i;
	struct info *head,*p1,*p2;
	p1=(struct info*)malloc(sizeof(struct info));
	scanf("%d %d %d",&p1->num,&p1->chin,&p1->math);
	p1->next=NULL;
	head=p1;
	p2=p1;
	i=1;
	do
	{
		p1=(struct info*)malloc(sizeof(struct info));
		scanf("%d %d %d",&p1->num,&p1->chin,&p1->math);
		p1->next=NULL;
	    p2->next=p1;
	    p2=p1;
		i++;
	}while(i<n);
    return(head);
}
void arrange(struct info *head)
{
	int m,no1,no2,no3;
	struct info *p;
	p=head;
	m=0;
	while(p)
	{
	if (p->chin+p->math>m)
	{m=p->chin+p->math;no1=p->num;}
	p=p->next;
	}
	printf("%d %d\n",no1,m);
	m=0;
	p=head;
	no2=p->num;
	while(p)
	{
	if (p->chin+p->math>m&&p->num!=no1)
	{m=p->chin+p->math;no2=p->num;}
	p=p->next;
	}
	printf("%d %d\n",no2,m);
	m=0;
	p=head;
	no3=p->num;
	while(p)
	{
	if (p->chin+p->math>m&&p->num!=no1&&p->num!=no2)
	{m=p->chin+p->math;no3=p->num;}
	p=p->next;
	}
	printf("%d %d\n",no3,m);
}
int main()
{
	int n;
	struct info *head;
	scanf("%d",&n);
	head=create(n);
    arrange(head);
}
void main()
{
	long n;
	scanf("%ld",&n);
	struct student
{
	int num;
	int chi;
	int math;
	int sum;
}stu[100000];
	int i;
	for(i=0;i<n;i++)
	{
		scanf("%d %d %d",&stu[i].num,&stu[i].chi,&stu[i].math);
		stu[i].sum=stu[i].chi+stu[i].math;
	}
	struct student blank;
	for(i=0;i<n;i++)
	{
		if(stu[i].sum>stu[0].sum)
		{
			blank=stu[0];
			stu[0]=stu[i];
			stu[i]=blank;
		}
	}
	for(i=1;i<n;i++)
	{
		if(stu[i].sum>stu[1].sum)
		{
			blank=stu[1];
			stu[1]=stu[i];
			stu[i]=blank;
		}
	}
	for(i=2;i<n;i++)
	{
		if(stu[i].sum>stu[2].sum)
		{
			blank=stu[2];
			stu[2]=stu[i];
			stu[i]=blank;
		}
	}
	for(i=0;i<=2;i++)
		printf("%d %d\n",stu[i].num,stu[i].sum);
}
struct student
{int id;
 int chinese;
 int maths;
 int total;
};
void main()
{ 
	int n,i;
    struct student s,s1,s2,s3;
	scanf("%d",&n);
	s2.total=s1.total=s3.total=-1;
	for(i=0;i<n;i++)
	{	scanf("%d %d %d",&s.id,&s.chinese,&s.maths);
		s.total=s.chinese+s.maths;
		if(s.total>s1.total)
		{	s3=s2;
		    s2=s1;
			s1=s;
		}
		else if(s.total>s2.total)
		{	s3=s2;
		    s2=s;
		}
		else if(s.total>s3.total)
			s3=s;
	}
	
	printf("%d %d\n",s1.id,s1.total);
	printf("%d %d\n",s2.id,s2.total);
	printf("%d %d\n",s3.id,s3.total);
	
}
struct student
{
	int num;
	float yuwen;
	float shuxue;
	float zongfen;
}stu[student_num],*p[3];
void main()
{
	void paixu(struct student *a,int n);
	int i,n;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d%f%f",&stu[i].num,&stu[i].yuwen,&stu[i].shuxue);
		stu[i].zongfen=stu[i].yuwen+stu[i].shuxue;
	}
	paixu(stu,n);
	for(i=0;i<3;i++)printf("%d %.0f\n",p[i]->num,p[i]->zongfen);
}
void paixu(struct student *a,int n)
{
	int i,j;
	float x[3];
	for(i=0;i<3;i++)
	{
		for(j=1,p[i]=a;j<n;j++)if(p[i]->zongfen<(a+j)->zongfen)p[i]=a+j;
		x[i]=p[i]->zongfen;
		p[i]->zongfen=0;
	}
	for(i=0;i<3;i++)p[i]->zongfen=x[i];
}
void main(int argc, char* argv[])
{
struct student
{
    int No;
	int chinese;
	int math;
	int total;
} stu[100000];
    int i,j,x,y,z,n;
	scanf("%d",&n);
	for(i=0;i<n;i++){
        scanf("%d",&stu[i].No);
        scanf("%d",&stu[i].chinese);
        scanf("%d",&stu[i].math);
		stu[i].total=stu[i].chinese+stu[i].math;
	}
	for(j=0;j<3;j++){
    x=0;
	for(i=0;i<n;i++){
			if(	stu[i].total>x){
				x=stu[i].total;
				y=stu[i].No;
				z=i;
			}
	}
	printf("%d %d\n",y,x);
	stu[z].total=0;
	}
}
struct stud
{
	int n;
	int chinese;
	int math;
	int total;
	struct stud *next;
};
int tol;
struct stud *creat(void)
{
	struct stud *head,*p1,*p2;
	int i=1;
	p1=p2=(struct stud *)malloc(sizeof(struct stud));
	head=p1;
	for(i=1;i<tol;i++)
	{
		scanf("%d%d%d",&p1->n,&p1->chinese,&p1->math);
		p1->total=(p1->math+p1->chinese);
		p1=(struct stud *)malloc(sizeof(struct stud));
		p2->next=p1;
		p2=p1;
	}
	scanf("%d%d%d",&p1->n,&p1->chinese,&p1->math);
	p1->total=(p1->math+p1->chinese);
	p2->next=p1;
	p1->next=0;
	return head;//???????
}
int max(struct stud *head,int max1,int max2)
{
	struct stud *p1;
	int maxtotal=head->total,max_index;
	for(p1=head;p1!=0;p1=p1->next)
	{
		if(p1->total>maxtotal&&p1->n!=max1&&p1->n!=max2)
		{
			maxtotal=(p1->total);
			max_index=(p1->n);
		}
	}
	if(maxtotal!=max1)
		printf("%d %d\n",max_index,maxtotal);
	return max_index;
}
void main()
{
	struct stud *head;
	int max1,max2;
	scanf("%d",&tol);
	head=creat();
	max1=max(head,0,0);
	max2=max(head,max1,0);
	max(head,max1,max2);
}
int n;

struct stu
{
	int xh;
	int yw;
	int sx;
	int all;
	struct stu*next;
};
struct stu *a,*b,*c,q,t,r;
struct stu*creat()
{
	struct stu *head;
	struct stu *p1,*p2;
	int i;
	p1=p2=(struct stu*)malloc(sizeof(struct stu));
	scanf("%d%d%d",&p1->xh,&p1->yw,&p1->sx);
	p1->all=p1->yw+p1->sx;
	head=p1;
	a=b=c=head;
	for(i=1;i<n;i++)
	{
		p2->next=p1;
		p2=p1;
		p1=(struct stu*)malloc(sizeof(struct stu));
		scanf("%d%d%d",&p1->xh,&p1->yw,&p1->sx);
		p1->all=p1->yw+p1->sx;
		if(p1->all>a->all)
		{
			c=b;
			b=a;
			a=p1;
		}
		else
	
			if(p1->all>b->all)
			{
				c=b;
			    b=p1;
			}
			else
			{
				if(p1->all>c->all)
					c=p1;
			}

	}p2->next=NULL;
	return head;
}

void main()
{
	
	struct stu *p;
	a=&q;b=&t;c=&r;
	scanf("%d",&n);
	p=creat();
	printf("%d %d\n%d %d\n%d %d\n",a->xh,a->all,b->xh,b->all,c->xh,c->all);
}
int main()
{
    int n;
    scanf ("%d",&n);
    struct student
    {
        int num;
        int chinese;
        int maths;
    };
    struct student a[100000],temp;
    int i;
    for (i=0;i<n;i++)
    {
        scanf("%d",&a[i].num);
        scanf("%d",&a[i].chinese);
        scanf("%d",&a[i].maths);
    }
    
    for (i=1;i<n;i++)
    {
        if ((a[i].chinese+a[i].maths)>(a[0].chinese+a[0].maths))
        {
            temp=a[0];
            a[0]=a[i];
            a[i]=temp;
        }
    }
    printf("%d %d\n",a[0].num,a[0].chinese+a[0].maths);
    
    for (i=2;i<n;i++)
    {
        if ((a[i].chinese+a[i].maths)>(a[1].chinese+a[1].maths))
        {
            temp=a[1];
            a[1]=a[i];
            a[i]=temp;
        }
    }
    printf("%d %d\n",a[1].num,a[1].chinese+a[1].maths);

    for (i=3;i<n;i++)
    {
        if ((a[i].chinese+a[i].maths)>(a[2].chinese+a[2].maths))
        {
            temp=a[2];
            a[2]=a[i];
            a[i]=temp;
        }
    }
    printf("%d %d\n",a[2].num,a[2].chinese+a[2].maths);
    return 0;
}
int n;

struct student
{
	int num;
	int chinese;
	int math;
	int total;
	struct student *next;
};
struct student *creat(int n)
{
	struct student *head;
	struct student *p1,*p2;
	int i;
	if(n==0)
	{
		head=NULL;
		return(head);
	}
	else
	{
		p1=(struct student*)malloc(LEN);
		scanf("%d %d %d",&p1->num,&p1->chinese,&p1->math);
		p1->next=NULL;
		head=p1;
		p2=p1;
		for(i=1;i<n;i++)
		{
			p1=(struct student*)malloc(LEN);
			scanf("%d %d %d",&p1->num,&p1->chinese,&p1->math);
			p1->next=NULL;
			p2->next=p1;
			p2=p1;
		}
		return(head);
	}
	
}
void top3(struct student *head)
{
	struct student *p,*p1;
	int max=0; 
	p=head;
	do
	{
		p->total=(p->chinese)+(p->math);
		if((p->total)>max)
		{
			max=p->total;
			p1=p;
		}
		p=p->next;
	}while(p!=NULL);
	printf("%d %d\n",p1->num,p1->total);
	p1->total=0;
	p=head;
	max=0;
	do
	{
		if((p->total)>max)
		{
			max=p->total;
			p1=p;
		}
		p=p->next;
	}while(p!=NULL);
	printf("%d %d\n",p1->num,p1->total);
	p1->total=0;
	p=head;
	max=0;
	do
	{
		if((p->total)>max)
		{
			max=p->total;
			p1=p;
		}
		p=p->next;
	}while(p!=NULL);
	printf("%d %d\n",p1->num,p1->total);
	p1->total=0;
	max=0;

}
void main()
{
	struct student *head;
	scanf("%d",&n);
	head=creat(n);
	top3(head);
}
int main(int argc, char* argv[])
{
	struct r{int a;int b;int c;}r[99999];
	int i,n,x=0,y=0,z=0,m1=0,m2=0,m3=0;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d%d%d",&r[i].a,&r[i].b,&r[i].c);
	}
    for(i=1;i<=n;i++)
	{
		if(r[i].b+r[i].c>m1)
		{
			m1=r[i].b+r[i].c;
		    x=i;
		}
	}
    for(i=1;i<=n;i++)
	{
		if((r[i].b+r[i].c==m1)&&(i!=x))
		{
			m2=r[i].b+r[i].c;
			y=i;
		}
		else if((m1>r[i].b+r[i].c)&&(r[i].b+r[i].c>m2))
		{
			m2=r[i].b+r[i].c;
		    y=i;
		}
	}
    for(i=1;i<=n;i++)
	{ 
		if((r[i].b+r[i].c==m2)&&(i!=y)&&(i!=x))
		{
			m3=r[i].b+r[i].c;
			z=i;
		}

		else if((m2>r[i].b+r[i].c)&&(r[i].b+r[i].c>m3))
		{
			
			m3=r[i].b+r[i].c;
		    z=i;
		}
	}
    printf("%d %d\n",x,m1);
	printf("%d %d\n",y,m2);
	printf("%d %d\n",z,m3);
     
	return 0;
}
struct stu
{
	int num;
	int ch;
	int math;
	struct stu* next;
};


void main()
{
	int n,m=0,max=0,max2=0,max3=0,no=0,no2=0,no3=0;
	struct stu*p;
	scanf("%d",&n);
	struct stu*p1,*p2,*head;
	p1=(struct stu*)malloc(LEN);
	scanf("%d%d%d",&p1->num,&p1->ch,&p1->math);
	head=NULL;

	while(n-1)
	{
		m=m+1;
		if(m==1)
			head=p1;
		else
			p2->next=p1;
	     p2=p1;
		 p1=(struct stu*)malloc(LEN);
	     scanf("%d%d%d",&p1->num,&p1->ch,&p1->math);
	     n--;
	}
	p2->next=NULL;
	
	p=head;
	while(p)
	{
		p->ch=p->math+p->ch;
	    p=p->next;
	}

	p=head;
	while(p)
	{
		if(p->ch>max)
		{
		  max=p->ch;
		  no=p->num;
		}
		p=p->next;
	}
	printf("%d %d\n",no,max);

	p=head;
	while(p)
	{
		if(p->ch<=max&&p->ch>max2&&p->num!=no)
		{
		  max2=p->ch;
		  no2=p->num;
		}
		p=p->next;
	}
	printf("%d %d\n",no2,max2);

	p=head;
	while(p)
	{
		if(p->ch<=max2&&p->ch>max3&&p->num!=no&&p->num!=no2)
		{
		  max3=p->ch;
		  no3=p->num;
		}
		p=p->next;
	}
	printf("%d %d",no3,max3);

}