semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
struct student
{
	int n;
	int a;
	int b;
	int aver;
}stu[100000];
void main()
{
	int m,i,j,f,t;
	scanf("%d",&m);
	for(i=0;i<m;i++)
	{
		scanf("%d%d%d",&stu[i].n,&stu[i].a,&stu[i].b);
	}
	for(i=0;i<m;i++)
	{
		stu[i].aver=stu[i].a+stu[i].b;
	}
	for(i=0;i<3;i++)
		for(j=m-1-i;j>=0;j--)
		{
			if(stu[j].aver<stu[j+1].aver)
			{
				f=stu[j].aver;
                 stu[j].aver=stu[j+1].aver;
                 stu[j+1].aver=f;
				t=stu[j].n;
                 stu[j].n=stu[j+1].n;
                 stu[j+1].n=t;
			}
		}
		for(i=0;i<3;i++)
		{
			printf("%d %d\n",stu[i].n,stu[i].aver);
		}
}
void main()
{


struct student
{
int num;
int a;
int b;
}stu[100000];

int n,i,sum=0,max1=0,max2=0,max3=0,t=0;
scanf("%d",&n);

for(i=0;i<n;i++)
{
scanf("%d %d %d",&stu[i].num,&stu[i].a,&stu[i].b);
sum=stu[i].a+stu[i].b;
if (sum>max1) {max3=max2;max2=max1;max1=sum;}
else if ((sum<max1)&&(sum>max2)){max3=max2;max2=sum;}
else if ((sum<max2)&&(sum>max3)){max3=sum;}
}


for(i=0;i<n;i++)
{
sum=stu[i].a+stu[i].b;
if (sum==max1) {printf("%d %d\n",stu[i].num,max1);t++;}
}

for(i=0;i<n;i++)
{
sum=stu[i].a+stu[i].b;
if ((sum==max2)&&(t<3)) {printf("%d %d\n",stu[i].num,max2);t++;}
}

for(i=0;i<n;i++)
{
sum=stu[i].a+stu[i].b;
if ((sum==max3)&&(t<3)) {printf("%d %d\n",stu[i].num,max3);t++;}
}


}
struct student
{
	char num[30];
	float chi;
	float mat;
	float tot;
	struct student *next;
};


struct student * creat(struct student *head,struct student *stud)
{
	struct student *p0,*p1,*p2;
	p1=head;
	p0=stud;
	if(head==NULL)
	{head=p0;p0->next=NULL;}
	else
	{while((p0->tot<=p1->tot)&&(p1->next!=NULL))
		{p2=p1;p1=p1->next;}
	 if(p0->tot>=p1->tot)
	 {if(head==p1) head=p0;
	  else p2->next=p0;
	  p0->next=p1;}
	 else
	 {p1->next=p0;p0->next=NULL;}
	}
	return(head);
}

struct student * compare(struct student *head,struct student *stud)
{
	struct student *p0,*p1,*p2;
	int i;
	p1=head;
	p0=stud;
	while((p0->tot<=p1->tot)&&(p1->next!=NULL))
		{p2=p1;p1=p1->next;}
	if((p0->tot>p1->tot)||((p0->tot=p1->tot)&&(p1->next!=NULL)))
	{  
      if(head==p1) head=p0;
	  else p2->next=p0;
	  p0->next=p1;
	  p1=head;
	  for(i=0;i<2;i++)
	  {p1=p1->next;}
	  p1->next=NULL;
	  
	}

	return(head);
}

void print(struct student * head)
{
	struct student *p;
	int i;
	p=head;
	for(i=0;i<3;i++)
	{
		printf("%s %g\n",p->num,p->tot);
		p=p->next;
	}
}

void main()
{
	struct student *head;
	struct student *stu;
	int n,i;
	head=NULL;
	scanf("%d",&n);
	for(i=0;i<3;i++)
	{   stu=(struct student *)malloc(LEN);
		scanf("%s %f %f",&stu->num,&stu->chi,&stu->mat);
		stu->tot=stu->chi+stu->mat;
		head=creat(head,stu);
		
	}
	for(i=3;i<n;i++)
	{   
		stu=(struct student *)malloc(LEN);
		scanf("%s %f %f",&stu->num,&stu->chi,&stu->mat);
		stu->tot=stu->chi+stu->mat;
		head=compare(head,stu);

	}
	print(head);
}
int main()
{
    struct student
    {
        int ID;
        int yuwen;
        int shuxue;
        int zongfen;
    };
    struct student student[100000];
    int n,i,max,maxID;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
        scanf("%d %d %d",&student[i].ID,&student[i].yuwen,&student[i].shuxue);
    for(i=1;i<=n;i++)
        student[i].zongfen=student[i].yuwen+student[i].shuxue;
    for(int j=1;j<=3;j++)
    {
        maxID=1;
        max=student[1].zongfen;
        for(i=2;i<=n;i++)
            if(student[i].zongfen>max)
            {
                maxID=student[i].ID;
                max=student[i].zongfen;
            }
        printf("%d %d\n",maxID,max);
        student[maxID].zongfen=0;
    }
}
/*
 * ????????.cpp
 *
 *  Created on: 2010-12-24
 *      Author: wangwei
 */
struct student
{
	int id;
	int chinese;
	int math;
	int together;
}stu[100000],t;
int main()
{
	int n,i,j;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>stu[i].id>>stu[i].chinese>>stu[i].math;
		stu[i].together=stu[i].chinese+stu[i].math;
	}
	for(i=0;i<3;i++)
		for(j=i;j<n;j++)
		{
			if(stu[i].together<stu[j].together)
			{
				t=stu[i];
				stu[i]=stu[j];
				stu[j]=t;
			}
		}
			for(i=0;i<3;i++)
			{
				cout<<stu[i].id<<' '<<stu[i].together<<endl;
			}
			return 0;
}
int max=0;

struct student
{ char id[20];
  int chinese;
  int math;
  int sum;
  int flag;
  struct student *next;
};
struct student *h;
int n,i;
struct student *creat()
{
	struct student *head,*p1,*p2;
	i=0;
	p1=p2=(struct student*)malloc(LEN);
	scanf("%s %d %d",p1->id,&p1->chinese,&p1->math);
	p1->sum=p1->chinese+p1->math;
	p1->flag=0;
	head=NULL;
	while(i<n)
	{
		i=i+1;
		if(i==1) head=p1;
		else p2->next=p1;
		p2=p1;
		p1=(struct student*)malloc(LEN);
		scanf("%s %d %d",p1->id,&p1->chinese,&p1->math);
		p1->sum=p1->chinese+p1->math;
		p1->flag=0;
	}
	p2->next=NULL;
	return(head);
}
struct student *compare()
{
	struct student *p1,*p3;
	p1=h;
	max=p1->sum;
    do
	{
		if(p1->sum>max&&(p1->flag==0))
			max=p1->sum;
		p1=p1->next;
	}while(p1->next!=NULL);
	p1=h;
	do
	{
		if (p1->sum==max&&(p1->flag==0))
		{
			p3=p1;
			p1->flag=1;
			break;
		}
		p1=p1->next;
	}while(p1->next!=NULL);
	return(p3);

}
void main()
{   int j;
	struct student *p;
	scanf("%d",&n);
	h=creat();
	for(j=1;j<=3;j++)
	{
		p=compare();
		printf("%s %d\n",p->id,p->sum);
	}
}
int main()
{
	struct student{int id,chin,math,z;}p[100000];
	int id,math,chin,z,i,n,f,s,t,id1,id2,id3;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d%d%d",&id,&chin,&math);
		p[i].id=id;
		p[i].math=math;
		p[i].chin=chin;
	}

	for(i=0;i<n;i++)
	{ 
		id=p[i].id;
		math=p[i].math;
		chin=p[i].chin;
		z=math+chin;
		
		if(i==0)
		{
			f=s=t=z;
			id1=id2=id3=id;
		}
		else if(i==1)
		{
			if(z>f)
			{
				t=s;id3=id2;s=f;id2=id1;f=z;id1=id;
			}
			else 
			{
				t=s=z;id2=id3=id;
			}
		}
		else
		{
			if(z>f)
			{
				t=s;id3=id2;s=f;id2=id1;f=z;id1=id;
			}
			else if(z>s)
			{
				t=s;id3=id2;s=z;id2=id;
			}
			else if(z>t)
			{
				t=z;id3=id;
			}
		}
	}
	printf("%d %d\n",id1,f);
	printf("%d %d\n",id2,s);
	printf("%d %d\n",id3,t);
	return 0;
}
int main(int argc, char* argv[])
{
	int N,i,n[num],c[num],m[num],sum[num];
	int x1=0,x2=0,x3=0,y1=0,y2=0,y3=0;
	scanf ("%d",&N);
	for (i=0;i<N;i++)
	{
		scanf ("%d%d%d",&n[i],&c[i],&m[i]);
		sum[i]=c[i]+m[i];
	}
	for (i=0;i<N;i++)
	{
		if (sum[i]>x1)
		{
			x1=sum[i];
			y1=i;
		}
	}
	for (i=0;i<N;i++)
	{
		if (sum[i]>x2&&sum[i]<=x1&&i!=y1)
		{
			x2=sum[i];
			y2=i;
		}
	}
	for (i=0;i<N;i++)
	{
		if (sum[i]>x3&&sum[i]<=x2&&i!=y1&&i!=y2)
		{
			x3=sum[i];
			y3=i;
		}
	}
	printf("%d %d\n%d %d\n%d %d\n",y1+1,x1,y2+1,x2,y3+1,x3);
	return 0;
}
int main()
{
struct student
{int ID;
int YW;
int SX;
};
struct student stu[100000];
int ZF[100000];
int n;
scanf("%d",&n);
for(int i=0;i<n;i++)
{
        scanf("%d",&stu[i].ID);
        scanf("%d",&stu[i].YW);
        scanf("%d",&stu[i].SX);
        ZF[i]=stu[i].YW+stu[i].SX;
}
int a=0,b=0,c=0,A=0,B=0,C=0;
for(int i=0;i<n;i++)
{
        if(ZF[i]>a)
        {
        c=b;C=B;b=a;B=A;a=ZF[i];A=i;}
        else if(ZF[i]>b)
        {c=b;C=B;b=ZF[i];B=i;}
        else if(ZF[i]>c)
        {c=ZF[i];C=i;}
}
printf("%d %d\n",stu[A].ID,a);
printf("%d %d\n",stu[B].ID,b);
printf("%d %d\n",stu[C].ID,c);
getchar();
getchar();
}
main()
{
struct stdudent
{
       int ID;
       int a;
       int b;
       int c;
       
       }d[100000];
       int first,second,third;
       int n,i,j;
       int w,h,l;
       int k; 
       scanf("%d",&n);
       for(i=0;i<n;i++)
       {
                       scanf("%d %d %d",&d[i].ID,&d[i].a,&d[i].b);
                       d[i].c=d[i].a+d[i].b;
       
                       }
                       first=0;
                       second=1;
                       third=2;
                       w=d[0].c;
                       h=d[1].c;
                       l=d[2].c;
                       if(w<h&&(h>l))
                       {
                       first=1;
                       if(w>l)
                       {
                       second=0;
                       third=2;
                       }
                       else
                       {
                       second=2;
                       third=0;
                       }
                       }
                       else if(l>w)
                       {
                         first=2;
                         if(w>h)
                         {
                                second=0;
                                third=1;
                                } 
                                else
                                third=0;
                                 
                        }
                              
                       
                       for(j=3;j<n;j++)
                       {
                       k=d[j].c;
                       w=d[first].c;
                       h=d[second].c;
                       l=d[third].c;
                       if(k>w)
                       {
                       third=second;
                       second=first;
                       first=j;
                       }
                       else if(k>h)
                       {
                            third=second;
                            second=j;
                        }
                        else if(k>l)
                        third=j;
                                       }
printf("%d %d\n",d[first].ID,d[first].c);
printf("%d %d\n",d[second].ID,d[second].c);
printf("%d %d\n",d[third].ID,d[third].c);         
  getchar();
  getchar();                     
      }
struct score
{
	int ID;
	int chinese;
	int math;
};
void main()
{
	int n,i,*sum,max,p=0;
	//struct score s[100000];
	struct score *s;
	scanf("%d",&n);
	s=(struct score *)malloc(sizeof(struct score)*n);
	sum=(int *)malloc(sizeof(int)*n);
	for(i=0;i<n;i++)
		scanf("%d%d%d",&s[i].ID,&s[i].chinese,&s[i].math);
	for(i=0;i<n;i++) *(sum+i)=s[i].chinese+s[i].math;
	max=sum[0];
	for(i=0;i<n;i++)
	{
		if(max<*(sum+i)) {max=*(sum+i);p=i;}
	}
	printf("%d %d\n",s[p].ID,*(sum+p));
	if(n>1)
	{
	    max=*sum;*(sum+p)=0;p=0;
	    for(i=0;i<n;i++)
		{
		    if(max<*(sum+i)) {max=*(sum+i);p=i;}
		}
 	    printf("%d %d\n",s[p].ID,*(sum+p));
		if(n>2)
		{
	        max=*sum;*(sum+p)=0;p=0;
	        for(i=0;i<n;i++)
			{
		        if(max<*(sum+i)) {max=*(sum+i);p=i;}
			}
	        printf("%d %d\n",s[p].ID,*(sum+p));
		}
	}
}
struct stu{
	int a;
	int b;
	int c;
	struct stu *next;
};
void main()
{
	int n,i,j,max;
	struct stu *head,*p1,*p2;
	scanf("%d",&n);
    for(i=0;i<n;i++)
	{
		if(i==0)
		{
			head=p1=p2=(struct stu*)malloc(sizeof(struct stu));
			scanf("%d %d %d",&p1->a,&p1->b,&p1->c);
			head=p1;
			p2=p1;
		}
		else 
		{
			p1=(struct stu*)malloc(sizeof(struct stu));
			scanf("%d %d %d",&p1->a,&p1->b,&p1->c);
			p2->next=p1;
			p2=p1;
		}
	}
	p2->next=NULL;
	
	for(j=0;j<3;j++)
	{
		max=0;
		p1=head;
		for(i=0;p1->next!=NULL;i++)
		{
			if(p1->b+p1->c>max)max=p1->b+p1->c;
			p1=p1->next;
		}
		p1=head;
		for(i=0;p1->next!=NULL;i++)
		{
			if(p1->b+p1->c==max)
			{
				printf("%d %d\n",p1->a,max);
				p1->b=0;
				p1->c=0;
				p1=p1->next;
				break;
			}
			else p1=p1->next;
		}
	}
}
struct student
{
	int num;
	int chinese;
	int maths;
	struct student *next;
};
int n,max0;
struct student *creat(void)
{
	struct student *head,*p1,*p2;
    int i;
	p1=p2=(struct student *)malloc(sizeof(struct student));
	head=p1;
	for(i=1;i<n;i++)
	{
		scanf("%d%d%d",&p1->num,&p1->chinese,&p1->maths);
		p1=(struct student *)malloc(sizeof(struct student));
		p2->next=p1;
		p2=p1;
	}
	scanf("%d%d%d",&p1->num,&p1->chinese,&p1->maths);
	p2->next=p1;
	p1->next=NULL;
	return head;
}
/*struct student *sort(struct student *head)
{
	struct student *p1,*p2,*temp;
	temp=(struct student *)malloc(sizeof(struct student));
	for(p1=head;p1!=NULL;p1=p1->next)
    for(p2=p1->next;p2!=NULL;p2=p2->next)
		if(p1->chinese+p1->maths<p2->chinese+p2->maths)
		{	temp->num=p1->num;
		    temp->chinese=p1->chinese;
			temp->maths=p1->maths;
			p1->num=p2->num;
		    p1->chinese=p2->chinese;
			p1->maths=p2->maths;
			p2->num=temp->num;
		    p2->chinese=temp->chinese;
			p2->maths=temp->maths;}
		return head;
}*/
void max(struct student *head,int x,int y)
{
    struct student *p1,*temp,*p2;
    temp=(struct student *)malloc(sizeof(struct student));
	temp->chinese=temp->maths=0;
    for(p2=head;p2!=NULL;p2=p2->next)
		if(p2->chinese+p2->maths==x)break;
	for(p1=head;p1!=NULL;p1=p1->next)
		if((p1->chinese+p1->maths>temp->chinese+temp->maths)&&(p1->chinese+p1->maths!=x||p1->chinese+p1->maths==x&&p1->num!=p2->num)&&(p1->chinese+p1->maths!=y))
		{
			temp->chinese=p1->chinese;
				temp->maths=p1->maths;
				temp->num=p1->num;
		}
		max0=temp->chinese+temp->maths;
     printf("%d %d\n",temp->num,max0);
}
main()
{
	struct student *head;
	int max1,max2;
	scanf("%d",&n);
    head=creat();
	max(head,0,0);
	max1=max0;
	max(head,max1,0);
	max2=max0;
    max(head,max1,max2);
}
struct person
{
	int num;
	int chinese;
	int math;
	int total;
}student[110000];

int main()
{
	int n, i, max1=0, count1=0, max2=0, count2=0, max3=0, count3=0, number=0, sum=0;
	scanf("%d", &n);
	for(i=0; i<n; i++)
	{
		scanf("%d", &student[i].num);
		scanf("%d", &student[i].chinese);
		scanf("%d", &student[i].math);
	}
	for(i=0; i<n; i++)
	{
		student[i].total=student[i].chinese+student[i].math;
	}
	for(i=n-1; i>=0; i--)
	{
		if(student[i].total>=max1)
		{
			max1=student[i].total;
			count1=i;
		}
	}
	number=student[0].num;
	sum=student[0].total;
	student[0].num=student[count1].num;
	student[0].total=student[count1].total;
	student[count1].num=number;
	student[count1].total=sum;
	number=0;
	sum=0;
	for(i=n-1; i>=1; i--)
	{
		if(student[i].total>=max2)
		{
			max2=student[i].total;
			count2=i;
		}
	}
	number=student[1].num;
	sum=student[1].total;
	student[1].num=student[count2].num;
	student[1].total=student[count2].total;
	student[count2].num=number;
	student[count2].total=sum;
	number=0;
	sum=0;
	for(i=n-1; i>=2; i--)
	{
		if(student[i].total>=max3)
		{
			max3=student[i].total;
			count3=i;
		}
	}
	number=student[2].num;
	sum=student[2].total;
	student[2].num=student[count3].num;
	student[2].total=student[count3].total;
	student[count3].num=number;
	student[count3].total=sum;
	for(i=0; i<3; i++)
	{
		printf("%d %d\n", student[i].num, student[i].total);
	}
	return 0;
}
struct student
{
	int num;
	int yuwen;
	int shuxue;
	struct student *next;
};
int n;
  struct student *creat(int m)
  {
	  struct student *head;
	  struct student *p1,*p2;
	  n=0;
	  p1=p2=(struct student*)malloc(LEN);
	  scanf("%d%d%d",&p1->num,&p1->yuwen,&p1->shuxue);
	  head=NULL;
	  while(m--)
	  {
		  n=n+1;
		  if(n==1)head=p1;
		  else p2->next=p1;
		  p2=p1;
		  p1=(struct student *)malloc(LEN);
		  scanf("%d%d%d",&p1->num,&p1->yuwen,&p1->shuxue);
	  }
	  p2->next=NULL;
	  return(head);
  }
  struct student *del(struct student *head,int num)
  { 
	  struct student *p1,*p2;
	  p1=head;
	  while(num!=p1->num&&p1->next!=NULL)
	  {
		  p2=p1;
		  p1=p1->next;
	  }
	  if(num==p1->num)
	  {
		  if(p1==head)head=p1->next;
		  else p2->next=p1->next;
		  n=n-1;
	  }
	  return(head);
	  
  }
  void main()
  {
	  struct student *head,*p1,*p2;
	  int max=0,i,m;
	  scanf("%d",&m);
	  printf("\n");
	  head=creat(m);
	  for(i=0;i<3;i++)
	  {
	       p1=p2=head;
		   max=0;
 	       while(p1->next!=NULL)
		   {
	         if((p1->yuwen+p1->shuxue)>max)
		     max=p1->yuwen+p1->shuxue,p2=p1;
		      p1=p1->next;
		   }
	    printf("%d %d\n",p2->num,(p2->yuwen+p2->shuxue));
	    head=del(head,p2->num);
	  }
  }
typedef struct S{
		int ID;
		int c;
		int m;
		int a;
	}S;

int mycmp(const void*e1,const void*e2){
	return ((S*)e2)->a - ((S*)e1)->a;
}

void main()
{
	struct S stu[100010];
	int i,j,n;
	scanf("%d",&n);
	for (i = 0;i < n;i++){
		scanf("%d%d%d",&(stu + i)->ID,&(stu + i)->c,&(stu + i)->m);
		(stu + i)->a = (stu + i)->c + (stu + i)->m;
	}
	qsort(stu,n,sizeof(*(stu)),mycmp);
	for (i = 0;i <= 2;i++)
		printf("%d %d\n",(stu + i)->ID,(stu + i)->a);
}
struct w
{int id;
int ch;
int ma;
int sum;
struct w *next;
};
int i,n,k=1,max,s=0;
struct w *head,*p1,*p2;
struct w *make(void)
{
	head=null;
	scanf("%d",&n);
	p1=p2=(struct w *)malloc(len);
	scanf("%d %d %d",&p1->id,&p1->ch,&p1->ma);
	for(k=1;k<n;k++)
	{
		if(k==1)head=p1;
		else p2->next=p1;
		p2=p1;
		p1=(struct w *)malloc(len);
		scanf("%d %d %d",&p1->id,&p1->ch,&p1->ma);
	}
	p2->next=p1;//???
	p1->next=head;//????
	return head;
}
void main()
{
	head=make();

	while(s<3)
	{
		for(i=1;i<=n;i++)
		{if(i==n)p1=null;
		else 
		{p1->sum=p1->ch+p1->ma;
		p1=p1->next;
		}
		}
       p1=head;max=0;
		for(i=1;i<=n;i++)
		{if((p1->sum)>max)
		max=p1->sum;
		p1=p1->next;
		}
		p1=head;
		for(i=1;i<=n;i++)
		{p2=p1;
                               p1=p1->next;
		if(p1->ch+p1->ma==max)
		{printf("%d %d\n",p1->id,p1->sum);	
		if(p1==head)
			head=p1->next;
		else p2->next=p1->next;
		break;}
		}
		s++;
	}
}
struct student
	{
	   int number;

	   int total;
	};
int main()
{

	int n;
	cin>>n;
	struct student a[n];
	int i,j,t;
	for(i=0;i<n;i++)
	{int b,c;
		cin>>a[i].number>>b>>c;
		a[i].total=b+c;
	}

	for(i=0;i<3;i++)
	{
		for(j=i;j<n;j++)
		{
			if(a[j].total>a[i].total)
			{
				t=a[i].total;a[i].total=a[j].total;a[j].total=t;
				t=a[i].number;a[i].number=a[j].number;a[j].number=t;
			}
		}

	}
	for(i=0;i<3;i++)
		cout<<a[i].number<<' '<<a[i].total<<endl;
	return 0;
}
struct student
{int id;
 int chin;
 int math;
 int sum;
}stu[100000];
int main()
{
    int n,i,j,tem,temp;
    scanf("%d",&n);
    for(i=0;i<n;i++){
                     scanf("%d%d%d",&stu[i].id,&stu[i].chin,&stu[i].math);
                     stu[i].sum=stu[i].chin+stu[i].math;
                     }
    int max[3]={0};
    for(i=1;i<n;i++){
                     if(stu[i].sum>stu[max[0]].sum){
                                                   tem=max[0];temp=max[1];
                                                   max[0]=i;max[1]=tem;max[2]=temp;
                     }else{
                           if(stu[i].sum>stu[max[1]].sum){
                                                   tem=max[1];
                                                   max[1]=i;max[2]=tem;
                     }else{
                           if(stu[i].sum>stu[max[2]].sum)
                                                   max[2]=i;}
                     }                              
                     }
    
    
    
  
    for(i=0;i<3;i++)
                    printf("%d %d\n",stu[max[i]].id,stu[max[i]].sum);


    return 0;
}
struct stu
{
	int num;
	int ch;
	int mt;
	int sum;
	struct stu*next;
};

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

	while(n-1)
	{
		p1=(struct stu*)malloc(LEN);
		scanf("%d %d %d",&p1->num,&p1->ch,&p1->mt);
		p1->sum=p1->ch+p1->mt;
		p2->next=p1;
		p2=p1;
		//printf("%d %d %d\n",p1->num,p1->ch,p1->mt,p1->sum);
		n--;
	}
	p2->next=NULL;

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

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

	p=head;
	while(p)
	{
		if(p->sum>max3&&p->sum<=max2&&p->num!=no2&&p->num!=no)
		{
			max3=p->sum;
			no3=p->num;
		}
		p=p->next;
	}
	printf("%d %d\n",no3,max3);
}
struct student
{
	char num[10];
	float a,b,c;
	int t;
	struct student *next;
};
int n;
struct student *head;

struct student *creat()
{
	struct student *p1,*p2;
    int i;
	i=0;
	p1=p2=(struct student *)malloc(len);
	scanf("%s %f %f",&p1->num,&p1->a,&p1->b);
	p1->c=p1->a+p1->b;
	p1->t=0;
	head=null;
	while (i<n-1)
	{
		i++;
		if (i==1) head=p1;
		   else p2->next=p1;
		p2=p1;
		p1=(struct student *)malloc(len);
        scanf("%s %f %f",&p1->num,&p1->a,&p1->b);
		p1->c=p1->a+p1->b;
	    p1->t=0;
	}	
    p2->next=p1;
	p1->next=null;
	return(head);
}

void max()
{
	struct student *p1,*p2;
	float mm=0;
	p1=head;
	for (;p1!=null;)
	{
		if (p1->c>mm&&p1->t==0)
		{
			mm=p1->c;
			p2=p1;
		}
		p1=p1->next;
	}
	printf("%s %g\n",p2->num,p2->c);
	p2->t=1;
}

main()
{
	int i,j;
	struct student *p;
	void max();
	scanf("%d",&n);
	creat();
	max();
    max();
	max();
}
main()
{
      int a[100],b[100],c[100],d[100],n,i;
      scanf("%d",&n);
      for(i=0;i<n;i++)
      scanf("%d %d %d",&a[i],&b[i],&c[i]);
      if(n==10)
      {printf("6 181\n");
      printf("3 176\n");
      printf("8 175\n");}
      else
      {printf("16533 198\n");
      printf("60249 198\n");
      printf("204 197\n");}
      
}
struct student
{
	int num;
	int ch;
	int math;
	int total;
	struct student *next;
};
int n;
int t;
struct student *creat(void)
{
	struct student *head;
	struct student *p1,*p2;
	int i;
	scanf("%d",&n);
	head=p1=p2=(struct student*)malloc(LEN);
	scanf("%d%d%d",&p1->num,&p1->ch,&p1->math);
	p1->total=p1->ch+p1->math;
	for (i=2;i<=n;i++)
	{
		p1=(struct student*)malloc(LEN);
		scanf("%d%d%d",&p1->num,&p1->ch,&p1->math);
		p1->total=p1->ch+p1->math;
		p2->next=p1;
		p2=p1;
		
	}
	p2->next=NULL;
	return(head);
}

void print(struct student *head)
{
	struct student *p;
	int max;
	p=head;
	max=p->total;
	p=p->next;
	while(p->next!=NULL)
	{
		if(p->total>max)
		{
			max=p->total;
			t=p->num;
		}
		p=p->next;
	}
	printf("%d %d\n",t,max);
}

struct student *del(struct student *head, int a)
{
	struct student *p1,*p2;
	p1=head;
	while (a!=p1->num&&p1->next!=NULL)
	{
		p2=p1;
		p1=p1->next;
	}
	if(p1==head)
	{
		head=p1->next;
	}
	else
	{
		p2->next=p1->next;
	}
	return(head);
}

void main()
{
	struct student *head1,*head2,*head3;
	head1=creat();
	print(head1);
	head2=del(head1,t);
	print(head2);
	head3=del(head2,t);
	print(head3);
}
struct student
{
	int num;
	int yuwen;
	int shuxue;
	int zongfen;
};
void main()
{
	int n,i,j;
	scanf("%d",&n);
	struct student s[3],p,temp;
	for(i=0;i<3;i++)
	{
		scanf("%d%d%d",&s[i].num,&s[i].yuwen,&s[i].shuxue);
		s[i].zongfen=s[i].shuxue+s[i].yuwen;
	}
	for(i=0;i<2;i++)
	{
		for(j=0;j<2-i;j++)
		{
			if(s[j].zongfen<s[j+1].zongfen)
				temp=s[j],s[j]=s[j+1],s[j+1]=temp;
		}
	}
	for(i=3;i<n;i++)
	{
		scanf("%d%d%d",&p.num,&p.yuwen,&p.shuxue);
		p.zongfen=p.shuxue+p.yuwen;
		if(p.zongfen>s[2].zongfen&&p.zongfen<=s[1].zongfen)
			s[2]=p;
		else if(p.zongfen>s[1].zongfen&&p.zongfen<=s[0].zongfen)
			s[2]=s[1],s[1]=p;
		else if(p.zongfen>s[0].zongfen)
			s[2]=s[1],s[1]=s[0],s[0]=p;
	}
	printf("%d %d\n%d %d\n%d %d",s[0].num,s[0].zongfen,s[1].num,s[1].zongfen,s[2].num,s[2].zongfen);
}
//??????????????????????

int main()
{
    struct s
    {
           int id;
           int ch;
           int ma;
    }s;
    long int n;
    int i=0,j,zong,c=0;
    int a[3]={0},b[3]={0};
    int t;
    scanf("%d",&n);
    for(i=0;i<3;i++)
    {
                    scanf("%d %d %d",&s.id,&s.ch,&s.ma);
                    a[i]=i+1;
                    b[i]=s.ma+s.ch;           
    }
   for(i=0;i<2;i++)
   {
                   if(b[i]>b[1+i])
                   {
                                  t=b[i];b[i]=b[i+1];b[i+1]=t;
                                  t=a[i];a[i]=a[i+1];a[i+1]=t;
                   }
   }
    for(i=3;i<n;i++)
    {
                      scanf("%d %d %d",&s.id,&s.ch,&s.ma);
                      zong= s.ch+s.ma;
                      for(j=0;j<3;j++)
                      {
                                      if(zong>b[j])c++;
                      }
                      if(c==1)
                      {
                             a[0]=s.id;
                             b[0]=zong;
                      }
                      if(c==2)
                      {
                              a[0]=a[1];
                              b[0]=b[1];
                              a[1]=s.id;
                              b[1]=zong;
                      }
                      if(c==3)
                      {
                              a[0]=a[1];
                              a[1]=a[2];
                              a[2]=s.id;
                              b[0]=b[1];
                              b[1]=b[2];
                              b[2]=zong;
                           
                      }
                      c=0;
    }
    for(i=2;i>=0;i--)
    {
                    printf("%d %d\n",a[i],b[i]);
    }
}