semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
struct stu
 {
	 int num;
	 int m;
	 int c;
	 int sum;
 };



int main()
{
	long int n;
	int a=0,b=0,c=0,x=0,y=0,z=0;
	struct stu student[65535];
	scanf("%d",&n);
	for (int i=0;i<n;i++)
	{
		scanf("%d %d %d",&student[i].num,&student[i].c,&student[i].m);
		student[i].sum=student[i].m+student[i].c;
	}
	for (int i=0;i<n;i++)
	{
		if(student[i].sum>a)
		{
			c=b;
			z=y;
			b=a;
			y=x;
			a=student[i].sum;
			x=student[i].num;
			continue;
		}
		if(student[i].sum>b)
		{
			c=b;
			z=y;
			b=student[i].sum;
			y=student[i].num;
			continue;
		}
		if (student[i].sum>c)
		{
			c=student[i].sum;
			z=student[i].num;
		}
	}
	printf("%d %d\n%d %d\n%d %d\n",x,a,y,b,z,c);
getchar();
getchar();
return 0;
}
void main()
{
	struct data
	{
		int number;
		int chinese;
		int math;
		int total;
	}student[100000],temp;
	
	long n,i,j;

	scanf("%ld",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d %d %d",&student[i].number,&student[i].chinese,&student[i].math);
		student[i].total=student[i].chinese+student[i].math;
	}

	for(i=0;i<3;i++)
		for(j=i+1;j<n;j++)
			if(student[i].total<student[j].total)
			{
				temp.number=student[i].number;
				temp.chinese=student[i].chinese;
				temp.math=student[i].math;
				temp.total=student[i].total;

				student[i].number=student[j].number;
				student[i].chinese=student[j].chinese;
				student[i].math=student[j].math;
				student[i].total=student[j].total;

				student[j].number=temp.number;
				student[j].chinese=temp.chinese;
				student[j].math=temp.math;
				student[j].total=temp.total;
			}

	for(i=0;i<3;i++)
		printf("%d %d\n",student[i].number,student[i].total);
		
}
struct student
{
	long num;
	int math;
	int chinese;
	struct student *next;
};

long stu_num;
struct student *max1,*max2,*max3;

struct student *creat(void)
{
	struct student *head,*p1,*p2;
	long n;
	p1=p2=(struct student *)malloc(LEN);
	scanf("%ld%d%d",&p1->num,&p1->math,&p1->chinese);
	head=NULL;
	n=0;
	while(n<stu_num)
	{
		n++;
		if(n==1)
			head=p1;
		else
			p2->next=p1;
		p2=p1;
		p1=(struct student *)malloc(LEN);
		scanf("%ld%d%d",&p1->num,&p1->math,&p1->chinese);
	}
	p2->next=NULL;
	return(head);
}

void Max1(struct student *head,long stu_num)
{
	struct student *q1;
	q1=head;
	max1=head;
	for(;q1!=NULL;)
		if((max1->math+max1->chinese)<(q1->math+q1->chinese))
		{
			max1=q1;
			q1=q1->next;
		}
		else
            q1=q1->next;
	printf("%ld %d\n",max1->num,max1->math+max1->chinese);
}


void Max2(struct student *head,long stu_num)
{
	struct student *q2;
	q2=head;
	if(head!=max1)
		max2=head;
	else
		max2=q2->next;
	for(;q2!=NULL;)
		if((max2->math+max2->chinese)<(q2->math+q2->chinese)&&q2!=max1)
		{
			max2=q2;
			q2=q2->next;
		}
		else
            q2=q2->next;
	printf("%ld %d\n",max2->num,max2->math+max2->chinese);
}


void Max3(struct student *head,long stu_num)
{
	struct student *q3;
	q3=head;
	for(;q3!=NULL;)
		if(q3==max1||q3==max2)
			q3=q3->next;
		else
		{
			max3=q3;
			break;
		}
	q3=head;
	for(;q3!=NULL;)
		if((max3->math+max3->chinese)<(q3->math+q3->chinese)&&q3!=max1&&q3!=max2)
		{
			max3=q3;
			q3=q3->next;
		}
		else
            q3=q3->next;
	printf("%ld %d\n",max3->num,max3->math+max3->chinese);
}


void main()
{
	struct student *head;	
	scanf("%ld",&stu_num);
	head=creat();
	Max1(head,stu_num);
	Max2(head,stu_num);
	Max3(head,stu_num);
}
main()
{
	struct student{
		int id;
		float yuwen,shuxue,sum;
	}stu[100000],t;
	int n,i,j;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	  {scanf("%d %f %f",&stu[i].id,&stu[i].yuwen,&stu[i].shuxue);
	   stu[i].sum=stu[i].yuwen+stu[i].shuxue;}
    for(i=0;i<3;i++)
      for(j=n-1;j>i;j--)
       	if(stu[j].sum>stu[j-1].sum)
       {
       	t=stu[j];
       	stu[j]=stu[j-1];
       	stu[j-1]=t;
       }
    for(i=0;i<3;i++)
     printf("%d %g\n",stu[i].id,stu[i].sum);
}
int main()
{
	struct st
	{int id;
	int yu;
	int ma;
	};
	int n,i;
	struct st st1={0,0,0},st2={0,0,0},st3={0,0,0},stn;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d%d%d",&stn.id,&stn.yu,&stn.ma);
		if(stn.yu+stn.ma>st1.yu+st1.ma){
			st3=st2;
			st2=st1;
			st1=stn;
		}else{
			if(stn.yu+stn.ma>st2.yu+st2.ma){
				st3=st2;
				st2=stn;
			}else{
				if(stn.yu+stn.ma>st3.yu+st3.ma){
					st3=stn;
				}
			}
		}
	}
	printf("%d %d\n%d %d\n%d %d",st1.id,st1.yu+st1.ma,st2.id,st2.yu+st2.ma,st3.id,st3.yu+st3.ma);
}
int main()
{
	int n;
	scanf("%d",&n);
	struct student
	{
		int num;
		int yu;
		int shu;
	}a[100000];
	int d[100000];
	int i=0;;
	for(i=0;i<n;i++)
	{
		scanf("%d %d %d",&a[i].num,&a[i].yu,&a[i].shu);
		d[i]=a[i].yu+a[i].shu;
	}
	int q,w,e,h;
	q=0;
	w=0;e=0;
	for(i=0;i<n;i++)
	{
		if(d[q]<d[i])
		{
			q=i;
		}
	}
	for(i=0;i<n;i++)
	{
		if(d[q]>=d[i]&&i!=q&&d[w]<d[i])
		{
			w=i;
		}
	}
	for(i=0;i<n;i++)
	{
		if(d[w]>=d[i]&&i!=w&&i!=q&&d[e]<d[i])
		{
			e=i;
		}
	}
	printf("%d %d\n",a[q].num,d[q]);
	printf("%d %d\n",a[w].num,d[w]);
	printf("%d %d\n",a[e].num,d[e]);
	return 0;
}
int main()
{   
    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 stu
{
	int no;
	int chi;
	int math;
	int sum;
	struct stu *next;
};
void main()
{
	struct stu a,*head,*p,*tail,*q;
	int k,i,m1,m2,m3,n1,n2,n3,temp1,temp2;
	head=NULL;
	scanf("%d",&k);
    for(i=0;i<k;i++)
	{
		p=(struct stu*)malloc(LEN);
        scanf("%d %d %d",&p->no,&p->chi,&p->math);
		p->sum=(p->chi+p->math);
        if(head==NULL)
			head=tail=p;
        else 
		{
			tail->next=p;
            tail=p;
			tail->next=&a;
		}
	}
	a.next=NULL;
	p=head;
	for(q=p->next;q->next!=NULL;q=q->next)
		{
			if(p->sum<q->sum)
			{
			temp1=q->sum;
			q->sum=p->sum;
			p->sum=temp1;
			temp2=q->no;
			q->no=p->no;
			p->no=temp2;
			}
		}
    m1=p->no;
	n1=p->sum;
	head=p->next;
	p=head;
	for(q=p->next;q->next!=NULL;q=q->next)
		{
			if(p->sum<q->sum)
			{
			temp1=q->sum;
			q->sum=p->sum;
			p->sum=temp1;
			temp2=q->no;
			q->no=p->no;
			p->no=temp2;
			}
		}
    m2=p->no;
	n2=p->sum;
	head=p->next;
	p=head;
    for(q=p->next;q->next!=NULL;q=q->next)
		{
			if(p->sum<q->sum)
			{
			temp1=q->sum;
			q->sum=p->sum;
			p->sum=temp1;
			temp2=q->no;
			q->no=p->no;
			p->no=temp2;
			}
		}
    m3=p->no;
	n3=p->sum;
    printf("%d %d\n%d %d\n%d %d\n",m1,n1,m2,n2,m3,n3);
}
struct
{
int ID[100000],Chinese[100000],Maths[100000];
}stu;
int main()
{
	int n,i,sum[100000],max1=0,max2=0,max3=0,num1,num2,num3;
	scanf("%d",&n);
	for(i=0;i<n;i++){
	scanf("%d %d %d",&stu.ID[i],&stu.Chinese[i],&stu.Maths[i]);
	}
	i=0;
	while(stu.ID[i]>0){
	sum[i]=stu.Chinese[i]+stu.Maths[i];
	i++;
	}
	i=0;
	while(i<n){
		if(sum[i]>max1){
		max1=sum[i];
		num1=i;
		}
		i++;
	}
	i=0;
	while(i<n){
		if(sum[i]>max2&&sum[i]<=max1&&i!=num1){
		max2=sum[i];
		num2=i;
		}
	i++;
	}
	i=0;
	while(i<n){
		if(sum[i]>max3&&sum[i]<=max2&&i!=num2&&i!=num1){
		max3=sum[i];
		num3=i;
		}
	i++;
	}
	printf("%d %d\n%d %d\n%d %d",stu.ID[num1],max1,stu.ID[num2],max2,stu.ID[num3],max3);
	return 0;
}
struct Student
{
	int num,yuwen,shuxue,sum;
};

void main()
{
	int n,max1=0,max2=0,max3=0,stu1=0,stu2=0,stu3=0;
	struct Student student[100000],*stu;
	scanf("%d",&n);

	for(stu=student;stu<student+n;stu++){
		scanf("%d",&stu->num);
		scanf("%d",&stu->yuwen);
		scanf("%d",&stu->shuxue);
		(stu->sum)=(stu->yuwen)+(stu->shuxue);
		if(stu->sum>=max3){
			if(stu->sum>=max2){
				if(stu->sum>=max1){
					if(stu->sum>max1){
						max3=max2;
						max2=max1;
						max1=stu->sum;
						stu3=stu2;
						stu2=stu1;
						stu1=stu->num;
					}
					else{
						max3=max2;
						max2=max1;
						max1=stu->sum;
						stu3=stu2;
						stu2=stu->num;
					}
				}
				else{
					if(stu->sum>max2){
						max3=max2;
						max2=stu->sum;
						stu3=stu2;		
						stu2=stu->num;
					}
					else{
						max3=max2;
						max2=stu->sum;
						stu3=stu->num;
					}
				}				
			}
			else{
				if(stu->sum>max3){
					max3=stu->sum;
					stu3=stu->num;
				}
				else max3=stu->sum;
			}
		}
	}
	stu=student;
	printf("%d %d\n",(stu+stu1-1)->num,(stu+stu1-1)->sum);
	printf("%d %d\n",(stu+stu2-1)->num,(stu+stu2-1)->sum);
	printf("%d %d\n",(stu+stu3-1)->num,(stu+stu3-1)->sum);
}
struct student
{
	int num;
	int yu;
	int shu;
	struct student *next;
};
int n;
struct student *creat(void)
{
	int i;
	struct student *head;
	struct student *p1,*p2;
	scanf("%d",&n);
	p1=p2=(struct student*)malloc(LEN);
	scanf("%d %d %d",&p1->num,&p1->yu,&p1->shu);
	head=p1;
	for(i=1;i<=n-1;i++)
	{
		p1=(struct student*)malloc(LEN);
		scanf("%d %d %d",&p1->num,&p1->yu,&p1->shu);
		p2->next=p1;
		p2=p1;
	}
	p2->next=NULL;
	return(head);	
}
void main()
{
	int i,j,k=0;
	struct student *head;
	struct student *p1,*p2;
	head=creat();
	p1=head;
	for(j=1;j<=3;j++)
	{
		p1=p2=head;
		for(i=1;i<=n-j;i++)
		{
			if( (p1->yu+p1->shu)>k )
			k=p1->yu+p1->shu;
			p1=p1->next;
		}
		p1=p2=head;
		if((head->yu+head->shu)==k)
		{
			printf("%d %d",p1->num,p1->yu+p1->shu);
			head=head->next;
		}
		else
		{
			for(i=1;;i++)
			{
				if( (p1->yu+p1->shu)==k )
				{
					printf("%d %d\n",p1->num,p1->yu+p1->shu);
					//printf("%d \n",p2->num);
					if((p1->next)!=NULL)
					p2->next=p1->next;
					else p2->next=NULL;
					k=0;
					break;
				}
				p2=p1;
				p1=p1->next;
			}
		}
	}
}
struct student
{
	int num;
	int chinese;
	int maths;
	int sum;
	struct student *next;
};
int m,max[3]={0},t[3]={0};
struct student *head;
struct student *p1,*p2;
struct student *creat(int n)
{
	m=0;
	p1=p2=(struct student*)malloc(LEN);
	scanf("%d %d %d",&p1->num,&p1->chinese,&p1->maths);
	p1->sum=p1->chinese+p1->maths;
	head=NULL;
	while(m<n-1)
	{
		m=m+1;
		if(m==1)
			head=p1;
		else p2->next=p1;
		p2=p1;
		p1=(struct student*)malloc(LEN);
		scanf("%d %d %d",&p1->num,&p1->chinese,&p1->maths);
		p1->sum=p1->chinese+p1->maths;
	}
	p2->next=p1;
	p2=p1;
	p2->next=NULL;
	return(head);
}
void main()
{
	int n;
	scanf("%d",&n);
	creat(n);
    
	struct student *p1;
	p1=head;
     do
	{
		if(p1->sum>max[0])
		{
			max[0]=p1->sum;
			t[0]=p1->num;
		}
		p1=p1->next;
	}	while(p1!=NULL);
	printf("%d %d\n",t[0],max[0]);
	p1=head;
	do
	{
		if(p1->sum>max[1]&&p1->num!=t[0])
		{
			max[1]=p1->sum;
			t[1]=p1->num;
		}
		p1=p1->next;
	}	while(p1!=NULL);
		printf("%d %d\n",t[1],max[1]);
	p1=head;
	do
	{
		if(p1->sum>max[2]&&p1->num!=t[0]&&p1->num!=t[1])
	{
		max[2]=p1->sum;
		t[2]=p1->num;
	}
		p1=p1->next;
	}	while(p1!=NULL);
		printf("%d %d\n",t[2],max[2]);
}
void main()
{
	struct student
	{
		int num;
		int sum;
	}stu[100000],temp;
	int total,i,j,chin,math;
	scanf("%d",&total);
	for(i = 0;i<total;i++)
	{
		scanf("%d %d %d",&stu[i].num,&chin,&math);
		stu[i].sum = chin+math;
	}
	for(i = 2;i<5;i++)
	{
		for(j = total-i;j>=0;j--)
		{
			if(stu[j].sum<stu[j+1].sum)
			{
				temp = stu[j];
				stu[j] = stu[j+1];
				stu[j+1] = temp;
			}
		}
	}
	for(i = 0;i<3;i++)
		printf("%d %d\n",stu[i].num,stu[i].sum);
}
struct student
{
	int no;
	int yuwen;
	int shuxue;
	int total;
};
void main()
{
	int n,i;
	struct student *p,*stu,temp;
	scanf("%d",&n);
	stu=(struct student *)calloc(n,sizeof(struct student));
	for(p=stu;p-stu<n;p++)
	{
		scanf("%d%d%d",&p->no,&p->yuwen,&p->shuxue);
		p->total=p->yuwen+p->shuxue;
	}
	for(i=0;i<3;i++)
	{
		for(p=stu+n-1;p>stu+i;p--)
		{
			if(p->total>(p-1)->total)
			{
				temp=*p;
				*p=*(p-1);
				*(p-1)=temp;
			}
		}
		printf("%d %d\n",p->no,p->total);
	}
	free(stu);
}
struct student {
	int id;
	int chinese;
	int math;
	int total;
};

int main() {
	int i, num;
	struct student stu[100000];
	int max_0 = 0, max_1 = 0, max_2 = 0;
	int max_0_id, max_1_id, max_2_id;

	scanf("%d", &num);
	for (i = 0; i < num; ++i) {
		scanf("%d %d %d", &(stu[i].id), &(stu[i].chinese), &(stu[i].math));
		stu[i].total = stu[i].chinese + stu[i].math;
		if (stu[i].total > max_0) {
			// update second and third highest
			max_2 = max_1;
			max_2_id = max_1_id;
			max_1 = max_0;
			max_1_id = max_0_id;
			max_0 = stu[i].total;
			max_0_id = stu[i].id;
		}
		else if (stu[i].total > max_1) {
			// update third highest
			max_2 = max_1;
			max_2_id = max_1_id;
			max_1 = stu[i].total;
			max_1_id = stu[i].id;
		}
		else if (stu[i].total > max_2) {
			max_2 = stu[i].total;
			max_2_id  = stu[i].id;
		}
	}

	printf("%d %d\n", max_0_id, max_0);
	printf("%d %d\n", max_1_id, max_1);
	printf("%d %d\n", max_2_id, max_2);

	return 0;
}
int main()
{
   struct student
   {
       int ID,Chinese,math,sum;
   }
   stu[100000],temp1,temp2,temp3;
   int n,i,j,k;
   scanf("%d\n",&n);
   for(i=0;i<n;i++)
   {
       scanf("%d%d%d",&stu[i].ID,&stu[i].Chinese,&stu[i].math);
       stu[i].sum=stu[i].Chinese+stu[i].math;
   }
   temp1=stu[0];
   for(i=1;i<n-1;i++)
   if(stu[i].sum>temp1.sum)
   temp1=stu[i];
   printf("%d %d\n",temp1.ID,temp1.sum);
   if(temp1.ID==stu[0].ID) temp2=stu[1];
   else temp2=stu[0];
   for(i=1;i<n-1;i++)
   {if(stu[i].ID==temp1.ID) continue;
    else if(stu[i].sum>temp2.sum) temp2=stu[i];}
    printf("%d %d\n",temp2.ID,temp2.sum);
    for(i=0;i<n;i++)
    if(stu[i].ID==temp1.ID||stu[i].ID==temp2.ID)
    stu[i].sum=0;
    temp3=stu[0];
    for(i=1;i<n-1;i++)
   if(stu[i].sum>temp3.sum)
   temp3=stu[i];
   printf("%d %d\n",temp3.ID,temp3.sum);
   return 0;
}
int main()
{
	struct score
	{
		int n;
		int a;
		int b;
		int c;
	}score[5];
	int i,m;
	scanf("%d",&m);
	score[1].n=0;
	score[1].c=0;
	score[2].n=0;
	score[2].c=0;
	score[3].n=0;
	score[3].c=0;
	for (i=0;i<m;i++)
	{
		scanf("%d%d%d",&score[4].n,&score[4].a,&score[4].b);
		score[4].c=score[4].a+score[4].b;
		if (score[4].c>score[1].c)
		{
			score[3]=score[2];
			score[2]=score[1];
			score[1]=score[4];
		}
		else if (score[4].c>score[2].c)
		{
			score[3]=score[2];
			score[2]=score[4];
		}
		else if (score[4].c>score[3].c)
			score[3]=score[4];
	}
	printf("%d %d\n%d %d\n%d %d\n",score[1].n,score[1].c,score[2].n,score[2].c,score[3].n,score[3].c);
	return 0;
}
struct student
{
    int num;
    int yw;
    int sx;
    int he;
}student[100000];

int main()
{
    int i,n,j,s=0,m;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d %d %d",&student[i].num,&student[i].yw,&student[i].sx);
        student[i].he=student[i].yw+student[i].sx;
    }
    for(i=0;i<n;i++)
    {m=student[0].he;
        for(j=n-1;j>0;j--)
        {
            
            m=student[j].he>m?student[j].he:m;
        }
        
        for(j=0;j<n;j++)
        {
            if(student[j].he==m)
            {printf("%d %d\n",student[j].num,student[j].he);
			student[j].he=0;s=s+1;if(s==3)
            {goto guiyi;}}
            
        }
		       
    }
	guiyi: return 0;
    
}
struct student
{
int num;
int chn;
int math;
int sum;
}stu[100000];
main()
{
      int n,i;
      scanf("%d",&n);
                     for(i=0;i<n;i++)
                     {scanf("%d%d%d",&stu[i].num,&stu[i].math,&stu[i].chn);
                     stu[i].sum=stu[i].math+stu[i].chn;
                     }
    int j,sum[100000],order[4]={n-1},t,m;
    struct student temp;
    for(j=n-1;j>=n-3;j--)
    {      
           for (i=0;i<j;i++)
          {if  (stu[i].sum>=stu[i+1].sum)
               {
                temp=stu[i+1];
                stu[i+1]=stu[i];
                stu[i]=temp;
               }
          }
    }
   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);
   getchar();
   getchar();
}
int main()
{
    long n,i,j,math[100000],chin[100000],total[100000],id[100000];
    scanf("%ld",&n);
    for(i=0;i<n;i++)
    {scanf("%ld",&id[i]);
    scanf("%ld",&math[i]);
    scanf("%ld",&chin[i]);}
    for(i=0;i<n;i++)
    {total[i]=100000*(math[i]+chin[i])+100000-id[i];}
    int comp(const void *a,const void *b);
    qsort(total,n,sizeof(long ),comp);
    printf("%ld %ld\n",100000-(total[n-1]-100000*((int)total[n-1]/100000)),(int)total[n-1]/100000);
    printf("%ld %ld\n",100000-(total[n-2]-100000*((int)total[n-2]/100000)),(int)total[n-2]/100000);
    printf("%ld %ld\n",100000-(total[n-3]-100000*((int)total[n-3]/100000)),(int)total[n-3]/100000);
    getchar();
    getchar();
}
    
    
    
    
    int comp(const void *a,const void *b)
{
return *(long *)a-*(long *)b;
}
struct Student
{
      int Num;
      int Chinese;
      int Math;
      int Sum;
};
int main()
{
     int n,i,s;
     scanf("%d",&n);
     struct Student stu[n];
     struct Student temp,*p=stu;
     for(i=0;i<n;i++)
     { 
     scanf("%d%d%d",&stu[i].Num,&stu[i].Chinese,&stu[i].Math);
     stu[i].Sum=stu[i].Chinese+stu[i].Math;
     }
     if(n==2)
     {
             if(stu[0].Sum >stu[1].Sum)
             temp=stu[0];
             stu[0]=stu[1];
             stu[1]=temp;
             printf("%d %d %d\n",stu[0].Num,stu[0].Chinese,stu[0].Math);
             printf("%d %d %d\n",stu[1].Num,stu[1].Chinese,stu[1].Math);
             }
     else
     {
         for(i=0,s=0;i<n;i++)
         if(stu[i].Sum>s)
         s=stu[i].Sum;
         for(i=0;i<n;i++)
         {
         if(stu[i].Sum==s)
         {
         printf("%d %d\n",stu[i].Num,stu[i].Sum);
         stu[i].Sum=0;
         break;
         }
         }
         for(i=0,s=0;i<n;i++)
         if(stu[i].Sum>s)
         s=stu[i].Sum;
         for(i=0;i<n;i++)
         {
         if(stu[i].Sum==s)
         {
         printf("%d %d\n",stu[i].Num,stu[i].Sum);
         stu[i].Sum=0;
         break;
         }
         }
         for(i=0,s=0;i<n;i++)
         if(stu[i].Sum>s)
         s=stu[i].Sum;
         for(i=0;i<n;i++)
         {
         if(stu[i].Sum==s)
         {
         printf("%d %d\n",stu[i].Num,stu[i].Sum);
         stu[i].Sum=0;
         break;
         }
         }
         }
         getchar();
         getchar();
         getchar();
         }
struct Student
{
	int number;
	int a;
	int b;
	int c;
};

int main()
{
	int n, i;
	int x, y, z;

	struct Student stu;
	struct Student maxStu, smaxStu, tmaxStu;

	scanf("%d",&n);
	scanf("%d%d%d",&x,&y,&z);
	stu.number = x;
	stu.a = y;
	stu.b = z;
	stu.c = stu.a + stu.b;
	maxStu = stu;
	smaxStu = stu;
	tmaxStu = stu;

	for (i = 0; i < n-1; i++){
		scanf("%d%d%d",&x,&y,&z);
		stu.number = x;
		stu.a = y;
		stu.b = z;
		stu.c = stu.a + stu.b;
		if (stu.c > maxStu.c){
			if (maxStu.c > smaxStu.c){
				if (smaxStu.c > tmaxStu.c){
					tmaxStu = smaxStu;
				}
				smaxStu = maxStu;
			}
			else if (maxStu.c > tmaxStu.c){
					tmaxStu = maxStu;
			}
			maxStu = stu;
		}
		else if (stu.c > smaxStu.c){
			if (smaxStu.c > tmaxStu.c){
				tmaxStu = smaxStu;
			}
			smaxStu = stu;
		}
		else if (stu.c > tmaxStu.c){
			tmaxStu = stu;
		}
	}

	printf ("%d %d\n%d %d\n%d %d",maxStu.number,maxStu.c,smaxStu.number,smaxStu.c,tmaxStu.number,tmaxStu.c);
	return 0;
}
struct student{
		int j;
		int x,y;
		int z;
	}stu[100000];
int main(int argc, char* argv[])
{
	int n,i,a=0,b=0,c=0,a1,b1,c1;
	
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d%d%d",&stu[i].j,&stu[i].x,&stu[i].y);
		stu[i].z=stu[i].x+stu[i].y;
	}
	for(i=0;i<n;i++)
	{
		if(a<stu[i].z)
		{
			a=stu[i].z;
	    	a1=i;
		}
	}
	
	for(i=0;i<n;i++)
	{
		if(b<stu[i].z&&i!=a1)
		{
			b=stu[i].z;
	    	b1=i;
		}
	}
	for(i=0;i<n;i++)
	{
		if(c<stu[i].z&&i!=a1&&i!=b1)
		{
			c=stu[i].z;
	    	c1=i;
		}
	}
	printf("%d %d\n%d %d\n%d %d\n",stu[a1].j,stu[a1].z,stu[b1].j,stu[b1].z,stu[c1].j,stu[c1].z);
	return 0;
}
int n,i,max=0,d,t=0;
struct stu 
{
	int id;
	int chi;
	int ma;
	struct stu *next;
} *p1,*p2;

struct stu *creat(void)
{
	struct stu *head;
	scanf("%d",&n);
	p2=p1=(struct stu *)malloc(sizeof(struct stu));
	for(i=0;i<n;i++)
	{		
		scanf("%d %d %d",&p1->id,&p1->chi,&p1->ma);
		if(i==0) head=p1;
		else p2->next=p1;
		p2=p1;
		p1=(struct stu *)malloc(sizeof(struct stu));
	}
	p2->next=NULL;
	return (head);
}

void find (struct stu *head)
{
	while(t<3)
	{
	p1=head;
	for(i=0;i<n;i++)
	{
		if(p1->chi+p1->ma>max) 
		{
			max=p1->chi+p1->ma;
			d=p1->id;
		}
		p1=p1->next;
	}
	printf("%d %d\n",d,max);
	t=t+1;	max=0;
	p1=head;
	for(i=0;i<n;i++)
	{
		if(p1->id==d) 
		{
			p1->chi=0;
			p1->ma=0;
		}
		p1=p1->next;
	}
	}
}

void main()
{
	struct stu *head;
	head=creat();
	find(head);
}
int main(){
	int n,i,j,temp;
	cin>>n;
	struct stu{
		int xuehao[100000];
		int yuwen[100000];
		int shuxue[100000];
		int zongfen[100000];
	}a;
	for(i=0;i<n;i++)
	{
		cin>>a.xuehao[i];
		cin>>a.yuwen[i];
		cin>>a.shuxue[i];
		a.zongfen[i]=a.shuxue[i]+a.yuwen[i];
	}
	for(i=n-1;i>=n-3;i--)
		for(j=i;j>=1;j--)
			if(a.zongfen[j]>a.zongfen[j-1])
			{
				temp=a.zongfen[j-1];
				a.zongfen[j-1]=a.zongfen[j];
				a.zongfen[j]=temp;
				temp=a.xuehao[j-1];
				a.xuehao[j-1]=a.xuehao[j];
				a.xuehao[j]=temp;
			}
	for(i=0;i<=2;i++)
		cout<<a.xuehao[i]<<" "<<a.zongfen[i]<<endl;
	return 0;
}
struct student
{int num;
 int yu;
 int shu;
 int score;
 struct student *next;
};
void main()
{
	int n,i,max;
	struct student *p1,*p2,*head;
	p1=p2=head=NULL;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		p1=(struct student *)malloc(sizeof(struct student));

		scanf("%d %d %d",&p1->num,&p1->yu,&p1->shu);
	
		p1->score=p1->yu+p1->shu;
	    if(i==0)head=p1;
		else p2->next=p1;
		p2=p1;
	}
	    p2->next=NULL;
	

		for(i=0;i<3;i++)
		{
			p2=p1=head;
			max=p1->score;
			while(p1!=NULL)
			{
				if(p1->score>max){max=p1->score;p2=p1;}
				p1=p1->next;
			}
			printf("%d %d\n",p2->num,max);
            p1=head;
			while(p1->next!=p2)
			{
				p1=p1->next;
			}
			p1->next=p2->next;
		}
}
int main()
{
	struct student{
		long num;
		long chinese;
		long maths;
		long sum;
	}t[100000];
	long n,i,j,k,tmp;
	scanf("%ld",&n);
	for(i=0;i<n;i++)
	{
		scanf("%ld %ld %ld",&t[i].num,&t[i].chinese,&t[i].maths);
	}
    for(i=0;i<n;i++)
	{
		t[i].sum=t[i].chinese+t[i].maths;
	}
	for(i=0;i<3;i++)
	{
        k=i;
		for(j=i+1;j<n;j++)
		{
			if(t[j].sum>t[k].sum)
				k=j;
		}
		tmp=t[i].sum;
		t[i].sum=t[k].sum;
		t[k].sum=tmp;

		tmp=t[i].num;
		t[i].num=t[k].num;
		t[k].num=tmp;
	}
	for(i=0;i<3;i++)
	{
	    printf("%ld %ld\n",t[i].num,t[i].sum);
	}
	return 0;
}
struct Stu{
	int StuNo;
	int Chinese;
	int math;
	int sum;
	struct Stu *next;
};
void main()
{
	struct Stu *p,*head,*tail;
	int n,i,max1,max2,max3,n1,n2,n3;
	scanf("%d",&n);
	head=tail=NULL;
	for(i=1;i<=n;i++)
	{
		p=(struct Stu*)malloc(len);
		scanf("%d%d%d",&p->StuNo,&p->Chinese,&p->math);
		if(head==NULL)
			head=tail=p;
		else
		{
			tail->next=p;
			tail=p;}
		p->sum=p->Chinese+p->math;
	}
	
	max1=head->sum;n1=1;
	for(i=1;i<=n;i++)
	{if(i==1) p=head;
	 else p=p->next;
		if((p->sum)>max1) {max1=p->sum;n1=i;}
	}
    for(i=1;i<=n;i++)
	{if(i==1) p=head;
	 else p=p->next;
	 if(i==n1) p->sum=0;}

    max2=head->sum;n2=1;
	for(i=1;i<=n;i++)
	{if(i==1) p=head;
	 else p=p->next;
		if((p->sum)>max2) {max2=p->sum;n2=i;}
	}
	for(i=1;i<=n;i++)
	{if(i==1) p=head;
	 else p=p->next;
	 if(i==n2) p->sum=0;}


	max3=head->sum;n3=1;
	for(i=1;i<=n;i++)
	{if(i==1) p=head;
	 else p=p->next;
         if((p->sum)>max3) {max3=p->sum;n3=i;}
	}
	printf("%d %d\n%d %d\n%d %d\n",n1,max1,n2,max2,n3,max3);
}