semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
struct student
{
	int num;
	int yuwen;
	int shuxue;
	int total;
}stu[100000];
void main()
{
	int n,i,j,k;
	struct student temp;
	scanf("%d\n",&n);
	for(i=0;i<n;i++)
	{scanf("%d%d%d",&stu[i].num,&stu[i].yuwen,&stu[i].shuxue);
	stu[i].total=stu[i].yuwen+stu[i].shuxue;}
	for(i=0;i<n-1;i++)
	{	
		k=i;
		for(j=i+1;j<n;j++)
		{if(stu[j].total>stu[i].total)
		{k=j;
		temp=stu[k];stu[k]=stu[i];stu[i]=temp;}
		}if(i==3)break;
	}
	for(i=0;i<3;i++)
	printf("%d %d\n",stu[i].num,stu[i].total);
}
struct student
 { int id;
   int a;
   int b;
   int zong;
 }; 
 struct student ren[100000];
 
 int main()
 {int n,i,fen,flag=0,j;
 
  scanf("%d\n",&n);
   for(i=0;i<=n-1;i++)
   { scanf("%d",&ren[i].id);
    scanf("%d",&ren[i].a);
    scanf("%d",&ren[i].b);
    ren[i].zong=ren[i].a+ren[i].b;
   }
   
   for(fen=200;fen>=100;fen--)
   { for(i=0;i<=n-1;i++)
      if(fen==ren[i].zong)
      {printf("%d %d\n",ren[i].id,ren[i].zong);
       flag=flag+1;
       if(flag==3)goto end;
      
      }
      }
      end:
  getchar();
  
}
int main()
{
    int a[100000][3],i,j,n,b[100000][2],t,m,k;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    for(j=0;j<3;j++)
    scanf("%d",&a[i][j]);
    for(i=0;i<n;i++)
    {
        b[i][0]=a[i][0];
        b[i][1]=a[i][1]+a[i][2];
    }
    for(i=0;i<3;i++)
    {
        for(k=i+1;k<n;k++)
        {
            if(b[i][1]<b[k][1])
            {
                t=b[k][1];
                b[k][1]=b[i][1];
                b[i][1]=t;
                m=b[k][0];
                b[k][0]=b[i][0];
                b[i][0]=m;
            }
        }
    }
    for(i=0;i<3;i++)
    printf("%d %d\n",b[i][0],b[i][1]);
    return 0;
}
struct student
{
	char id[10];
	int ch;
	int ma;
};

int main(int argc, char* argv[])
{
	int n,i,max,sec,min,total[100000];
	scanf("%d",&n);
	struct student stu[100000];
	for(i=0;i<n;i++)
	{
		scanf("%s%d%d",stu[i].id, &stu[i].ch, &stu[i].ma);
		total[i]=stu[i].ch + stu[i].ma;
	}

	max = 0;

	for(i=0;i<n;i++)
	{
		if(total[i]>total[max])
			max = i;
	}

    printf("%s %d\n",stu[max].id, total[max]);

	for(i=0;i<n;i++)
	{
		if(total[i]==total[max])
		{
			total[i]=0;
			break;
		}
	}	

	sec = 0;
	for(i=0;i<n;i++)
	{
		if(total[i]>total[sec])
			sec=i;
	}

	printf("%s %d\n", stu[sec].id, total[sec]);

	for(i=0;i<n;i++)
	{
		if(total[i]==total[sec])
		{
			total[i]=0;
			break;
		}
	}	
	

	min = 0;
	for(i=0;i<n;i++)
	{
		if(total[i]>total[min])
			min=i;
	}

	printf("%s %d\n", stu[min].id, total[min]);
	return 0;
}
struct stu
{int num;
 int score1;
 int score2;
}stu[100000];
void main()
{
	int i,j,n,a[100000],max;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d%d%d",&stu[i].num,&stu[i].score1,&stu[i].score2);
		a[i]=stu[i].score1+stu[i].score2;
	}
	for(j=0;j<3;j++)
	{
     max=0;
	 for(i=0;i<n;i++)
	 	max=(max>=a[i])?max:a[i];
	 for(i=0;i<n;i++)
	    if(a[i]==max) 
		{printf("%d %d\n",stu[i].num,a[i]);
	     a[i]=0;
  	     break;
		}
	}
}
struct stu
{
 int a;
 int b;
 int c;
 int d;
};
void main()
{
 int i,j,n,t;
 struct stu *p1,p2;
 scanf("%d",&n);
 p1=(struct stu*)calloc(n,sizeof(struct stu));
 for(i=0;i<n;i++)
  {
     scanf("%d %d %d",&(p1[i].a),&(p1[i].b),&(p1[i].c));
	 p1[i].d=p1[i].b+p1[i].c;
  }
  for(i=0;i<3;i++)
   for(j=i+1;j<n;j++)
    if(p1[i].d<p1[j].d)
     {
      p2=p1[i];
      p1[i]=p1[j];
      p1[j]=p2;
	}
  for(i=0;i<3;i++)
   printf("%d %d\n",p1[i].a,p1[i].d);
}
struct stu
{
	int id;
	int sum;
	struct stu *next;
};

void main()
{
	struct stu *head,*p1,*p2,*p0;
	int n,i,ch,ma,len;
	scanf("%d",&n);
	len = sizeof (struct stu);
	
	p1 = p2 = (struct stu*)malloc(len);

	head = p1;
	scanf("%d%d%d",&p1->id,&ch,&ma);
	p1->sum = ch + ma;
	p1->next = 0;

	for (i=2;i<=n;i++)
	{
        p0 = (struct stu*)malloc(len);
		scanf("%d %d %d",&p0->id,&ch,&ma);
		p0->sum = ch + ma;

		p1=p2=head;
		while ( (p0->sum <= p1->sum) && (p1->next != 0) )
		{
			p2 = p1;
			p1 = p1->next;
		}
		if (p0->sum > p1->sum)
		{
			if (head == p1)
				head = p0;
			else p2->next = p0;
			p0->next = p1;
		}
		else 
		{
			p1->next = p0;
			p0->next = 0;
		}
		if (i>3)
		{
			p1 = head->next;
			p1 = p1->next;
			p1->next = 0;
		}
	}
	p1 = head;
	while (p1!=0)
	{
    	printf("%d %d\n",p1->id,p1->sum);
		p1 = p1->next;
	}
}
int main()
{
	struct student
	{
		int num;
		int scorechinese;
		int scoremath;
		int sum;
	}a[100000];
	int n,i,j,temp;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d %d %d",&a[i].num,&a[i].scorechinese,&a[i].scoremath);
		a[i].sum=a[i].scorechinese+a[i].scoremath;
	}
	for(i=0;i<3;i++)
	{
		for(j=i+1;j<n;j++)
		{
			if(a[i].sum<a[j].sum)
			{
				temp=a[i].sum,a[i].sum=a[j].sum,a[j].sum=temp;
				temp=a[i].num,a[i].num=a[j].num,a[j].num=temp;
			}
		}
		printf("%d %d\n",a[i].num,a[i].sum);
	}
	return 0;
}
struct Student
{
	int id;
	int c;
	int m;
	int sum;
};
void main()
{
	struct Student temp,s1,s2,s3;	
	int i,n;
	s1.sum=s2.sum=s3.sum=-1;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d%d%d",&temp.id,&temp.c,&temp.m);
		temp.sum=temp.c+temp.m;
		if(temp.sum>s1.sum)
		{
			s3=s2;
			s2=s1;
			s1=temp;
		}
		else if (temp.sum>s2.sum)
		{
			s3=s2;
			s2=temp;
		}
		else if(temp.sum>s3.sum)
		{
			s3=temp;
		}
	}
	printf("%d %d\n%d %d\n%d %d\n",s1.id,s1.sum,s2.id,s2.sum,s3.id,s3.sum);
}
int main(){
	int n,i,max1=0,num1=0,max2=0,num2=0,max3=0,num3=0;
	struct stu{
		int num;
		int chn;
		int mat;
		int sum;
	}sco[100000];
	cin>>n;
	for(i=0;i<n;i++){
		cin>>sco[i].num>>sco[i].chn>>sco[i].mat;
		sco[i].sum=sco[i].chn+sco[i].mat;
	}
	for(i=0;i<n;i++){
		if(sco[i].sum>max1){
			max3=max2;
			num3=num2;
			max2=max1;
			num2=num1;
			max1=sco[i].sum;
			num1=i;

		}
		else{
			if(sco[i].sum>max2){
						max3=max2;
						num3=num2;
						max2=sco[i].sum;
						num2=i;
						}
			else {
				if(sco[i].sum>max3){
							max3=sco[i].sum;
							num3=i;
						}
			}
	}
	}
		cout<<num1+1<<' '<<max1<<endl;
		cout<<num2+1<<' '<<max2<<endl;
		cout<<num3+1<<' '<<max3<<endl;
	return 0;
}
struct grade
{
    int No;
	int chinese;
	int math;
	int sum;
}student[100000],s;
int main()
{
	int n,i,j;
	scanf("%d",&n);
	for(i=0;i<n;i++){
	scanf("%d %d %d",&student[i].No,&student[i].chinese,&student[i].math);
    student[i].sum=student[i].chinese+student[i].math;
	}
    for(i=0;i<3;i++){
		for(j=i+1;j<n;j++){
			if(student[i].sum<student[j].sum){
			    s=student[i];
				student[i]=student[j];
				student[j]=s;
			} 
		}
	}
	for(i=0;i<3;i++){
	printf("%d %d\n",student[i].No,student[i].sum);
	}
    return 0;
}
int main()
{
    int n;
    scanf ("%d",&n);
    struct student
    {
        int num;
        int chinese;
        int maths;
    };
    struct student a[100000],temp;
    int i,b[100000]={0};
    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;
}
struct data
{
	long int num;
	int point1;
	int point2;
	int sum;
	struct data*next;
};
struct data*creat(long int n)
{
	long int i=0;
	struct data*p1,*p2,*head;
	p1=p2=(struct data*)malloc(sizeof(struct data));
	scanf("%ld %d %d",&p1->num,&p1->point1,&p1->point2);
	p1->sum=p1->point1+p1->point2;
	head=NULL;
	while(i<n)
	{
		i=i+1;
		if(i==1) head=p1;
		else p2->next=p1;
		p2=p1;
		p1=(struct data*)malloc(sizeof(struct data));
		scanf("%ld %d %d",&p1->num,&p1->point1,&p1->point2);
		p1->sum=p1->point1+p1->point2;
	}
	p2->next=NULL;
	return(head);
}
struct data*max(struct data*head)
{
	struct data *p1,*max;
	max=head;
	p1=head;
	do
	{
		if(p1->sum>max->sum) max=p1;
		p1=p1->next;
	}while(p1!=NULL);
	return(max);
}
struct data*del(struct data*head,struct data*max)
{
	struct data *p1,*p2;
	p1=head;
	while(max!=p1)
	{
		p2=p1;
		p1=p1->next;
	}
	if(p1==head)
		head=p1->next;
	else
	{
		p2->next=p1->next;
	}
	return(head);
}
void main()
{
	struct data*a,*b,*c,*head;
	long int n;
	scanf("%ld",&n);
	head=creat(n);
	a=max(head);
	printf("%ld %d\n",a->num,a->sum);
	head=del(head,a);
	b=max(head);
	printf("%ld %d\n",b->num,b->sum);
	c=max(del(head,b));
	printf("%ld %d\n",c->num,c->sum);
}
typedef struct
{
	int ID;
	int chinese;
	int math;
	int sum;
}Student;

Student topThree[3];
int studentNum;

void initialise()
{
	for(int i = 0; i < 3; i ++)
	{
		topThree[i].sum = -1;
	}
}

void updateTopThree(Student stu)
{
	for(int i = 0; i < 3; i ++)
	{
		if(stu.sum > topThree[i].sum)
		{
			for(int j = 2; j > i; j --)
			{
				topThree[j] = topThree[j-1];
			}

			topThree[i] = stu;
			
			break;
		}
	}
}

void getStudentData()
{
	Student temp;

	scanf("%d", &studentNum);
	for(int i = 0; i < studentNum; i ++)
	{
		scanf("%d %d %d", &temp.ID, &temp.chinese, &temp.math);
		temp.sum = temp.chinese + temp.math;
		updateTopThree(temp);
	}
}

void printStudentData()
{
	for(int i = 0; i < 3 && i < studentNum; i ++)
	{
		printf("%d %d\n", topThree[i].ID, topThree[i].sum);
	}
}

int main()
{
	initialise();
	getStudentData();
	printStudentData();

	return 0;
}
struct Student
{
	int num;
	int chn;
	int mth;
	int sum;
};
struct Scr
{
	int num;
	int sum;
};

int main()
{
	struct  Student stu[100000];
	struct  Scr  scr[3];
	int n,i;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d%d%d",&stu[i].num,&stu[i].chn,&stu[i].mth);
		stu[i].sum=stu[i].chn+stu[i].mth;
	}
	scr[0].num=stu[0].num;
	scr[0].num=stu[0].num;
	for(i=1;i<n;i++)
    {
        if(stu[i].sum>scr[0].sum)
		{
			scr[0].num=stu[i].num;
			scr[0].sum=stu[i].sum;
		}
    }
	scr[1].num=stu[0].num;
	scr[1].num=stu[0].num;
	for(i=1;i<n;i++)
    {
		if(i!=scr[0].num-1)
		{
			if(stu[i].sum>scr[1].sum)
			{
				scr[1].num=stu[i].num;
				scr[1].sum=stu[i].sum;
			}
		}
    }
	scr[2].num=stu[0].num;
	scr[2].num=stu[0].num;
	for(i=1;i<n;i++)
    {
		if(i==scr[0].num-1||i==scr[1].num-1)
			continue;
		else
		{
			if(stu[i].sum>scr[2].sum)
			{
				scr[2].num=stu[i].num;
				scr[2].sum=stu[i].sum;
			}
		}
    }
	for(i=0;i<3;i++)
	{
		printf("%d %d\n",scr[i].num,scr[i].sum);
	}
	return  0;
}
struct stu
{
	int num;
	int chi;
	int math;
	int s;
	struct stu *next;
};
struct stu *creat(int n)
{
	int i;
	struct stu *head;
	struct stu *p1,*p2;
	p1=p2=(struct stu *)malloc(LEN);
	scanf("%d %d %d",&p1->num,&p1->chi,&p1->math);
	head=p1;
	for(i=1;i<n;i++)
	{
	    p1=(struct stu*)malloc(sizeof(struct stu));
		scanf("%d %d %d",&p1->num,&p1->chi,&p1->math);
		p2->next=p1;
		p2=p1;
	}
	p2->next=NULL;
	return (head);
}
void main()
{
	int i,n,t,m;
	struct stu *head,*p1,*p2;
	scanf("%d",&n);
	head=creat(n);
	p1=head;
	for(i=0;i<n;i++)
	{
		p1->s=p1->chi+p1->math;
		p1=p1->next;
	}
	p1=head;
	p2=p1->next;
	for(i=0;i<3;i++)
	{
		while(p2!=NULL)
		{
			if(p2->s>p1->s)
			{
				t=p2->s;
				p2->s=p1->s;
				p1->s=t;
				m=p2->num;
				p2->num=p1->num;
				p1->num=m;
			}p2=p2->next;
		}printf("%d %d\n",p1->num,p1->s);
		if(i==2)break;
		p1=p1->next;p2=p1->next;
	}
}
struct student               
{
	int num;
	int chinese;
	int math;
	int total;
};

int main()
{
	int n;
	scanf("%d",&n);                     
	struct student *stu=(struct student *)malloc(sizeof(int)*4*n);   
	int i;
	for(i=0;i<n;i++){
		scanf("%d%d%d",&stu[i].num,&stu[i].chinese,&stu[i].math);
	}


	for(i=0;i<n;i++){
		stu[i].total=stu[i].chinese+stu[i].math;            
	}

	int t_1,t_2;
	int j,k;
	for(k=1;k<4;k++){
		for(j=0;j<n-k;j++){
			if(stu[j].total>=stu[j+1].total){                 
		    	         t_1=stu[j+1].total;
			         stu[j+1].total=stu[j].total;
			         stu[j].total=t_1;
				t_2=stu[j+1].num;
				stu[j+1].num=stu[j].num;
				stu[j].num=t_2;
			}
		}
	}

	for(i=n-1;i>n-4;i--){
		printf("%d %d\n",stu[i].num,stu[i].total);
	}

    return 0;	
}
int main()
{
	int n,i;
	int o=0,oz,t=0,tz,th=0;
	scanf("%d",&n);
    struct{
		int h,z;
	}s[100000];
  	for(i=0;i<n;i++)
	{
		int h0,x0,y0;
		scanf("%d%d%d",&h0,&x0,&y0);
		s[i].h=h0;
		s[i].z=x0+y0;
	}
	for(i=0;i<n;i++)
		if(s[i].z>o)
			o=s[i].z;
	for(i=0;i<n;i++)
		if(s[i].z==o)
		{
			oz=i;
			printf("%d %d\n",s[i].h,s[i].z);
			break;
		}
	for(i=0;i<n;i++)
		if((i!=oz)&&(s[i].z>t))
			t=s[i].z;
	for(i=0;i<n;i++)
		if((i!=oz)&&(s[i].z==t))
		{
			tz=i;
			printf("%d %d\n",s[i].h,s[i].z);
			break;
		}
	for(i=0;i<n;i++)
		if((i!=oz)&&(i!=tz)&&(s[i].z>th))
			th=s[i].z;
	for(i=0;i<n;i++)
		if((i!=oz)&&(i!=tz)&&(s[i].z==th))
		{
			printf("%d %d\n",s[i].h,s[i].z);
			break;
		}
	return 0;
}
struct student
{
	long int num;
	int Chinese;
	int Maths;
	int total;
};
void main()
{
	struct student stu[100000];
	struct student tempt;
	int n,i;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d %d",&stu[i].num,&stu[i].Chinese,&stu[i].Maths);
		stu[i].total=stu[i].Chinese+stu[i].Maths;
	}
	if(stu[2].total>stu[1].total){
		tempt=stu[1];
		stu[1]=stu[2];
		stu[2]=tempt;
	}
	if(stu[1].total>stu[0].total){
		tempt=stu[0];
		stu[0]=stu[1];
		stu[1]=tempt;
	}
    if(stu[2].total>stu[1].total){
		tempt=stu[1];
		stu[1]=stu[2];
		stu[2]=tempt;
	}
	for(i=3;i<n;i++){
		if(stu[i].total>stu[2].total){
			stu[2]=stu[i];
			if(stu[2].total>stu[1].total){
				tempt=stu[1];
			    stu[1]=stu[2];
		        stu[2]=tempt;
				if(stu[1].total>stu[0].total){
					tempt=stu[0];
		            stu[0]=stu[1];
	                stu[1]=tempt;
				}
			}
		}
	}
	printf("%d %d\n",stu[0].num,stu[0].total);
	printf("%d %d\n",stu[1].num,stu[1].total);
	printf("%d %d\n",stu[2].num,stu[2].total);
}
int main()
{
	struct stu{
		int ID,chin,math;
	};
	stu *pp;
	int sum,second,third,x,y,z;
	int i,n;
	int a,b,c;
	scanf("%d",&n);
	pp=(struct stu *)malloc(sizeof(stu)*n);
	for(i=1;i<=n;i++)
	{
		scanf("%d %d %d",&a,&b,&c);
	      (pp+i)->ID=a;
	      (pp+i)->chin=b;
	      (pp+i)->math=c;
	}
	sum = ((pp+i)->chin)+((pp+i)->math);
	for(i=1;i<=n;i++)
	{
		if(i==1)
		{
			sum=((pp+i)->chin)+((pp+i)->math);
			second=((pp+i)->chin)+((pp+i)->math);
			third=((pp+i)->chin)+((pp+i)->math);
			x=(pp+i)->ID;
			y=(pp+i)->ID;
			z=(pp+i)->ID ;

		}
		else if (i==2)
		{
			if (sum<((pp+i)->chin)+((pp+i)->math))
			{
				second=sum;
			    sum=((pp+i)->chin)+((pp+i)->math);
				y=x;
				x=(pp+i)->ID;
			}
                           else
                           {
                                   third=((pp+i)->chin)+((pp+i)->math);
                                   z=(pp+i)->ID;
                            }
		}
		else
		{
			if (sum<((pp+i)->chin)+((pp+i)->math))
			{
                                    third=second;
				second=sum;
			    sum=((pp+i)->chin)+((pp+i)->math);
                                     z=y;
				y=x;
				x=(pp+i)->ID;
			}
			else if (second<((pp+i)->chin)+((pp+i)->math))
			{
				third=second;
				second=((pp+i)->chin)+((pp+i)->math);
				z=y;
				y=(pp+i)->ID;
			}
                           else if (third<((pp+i)->chin)+((pp+i)->math))
                           {
                                    third=((pp+i)->chin)+((pp+i)->math);
                                    z=(pp+i)->ID;
                           }
		}
	}
	    printf("%d %d\n",x,sum);
		printf("%d %d\n",y,second);
		printf("%d %d\n",z,third);
			return 0;
}
struct student
{
	int num;
	float yuwen;
	float shuxue;
	float total;
}stu[100000];
void main()
{
	int i,n,j;
	struct student *p;
	p=&stu[0];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d%f%f",&(p+i)->num,&(p+i)->yuwen,&(p+i)->shuxue);
		(p+i)->total=(p+i)->shuxue+(p+i)->yuwen;
	}
	for(i=0;i<3;i++)
		for(j=0;j<n-1-i;j++)
		{
			if((*(p+j)).total>=(*(p+j+1)).total)
			{
				struct student temp;
				temp=*(p+j+1);
				*(p+j+1)=*(p+j);
				*(p+j)=temp;
			}
		}
	if(n>2)
		for(i=1;i<4;i++)
			printf("%d %g\n",(*(p+n-i)).num,(*(p+n-i)).total);
	else if(n=2)
		printf("%d %g\n%d %g\n",(*(p+1)).num,(*(p+1)).total,(*p).num,(*p).total);
}
struct Student
{
       int num;
       int chinese;
       int maths;
};
 struct qiansan
      {
             int num;
             int zongfen;
      }st[3]={{0,0},{0,0},{0,0}};
main()
{
      int n,i,k,c[10],j[10];
      int a[100001];
      scanf("%d",&n);
      struct Student std[100001];
      for(i = 0;i < n;i++)
      {
            scanf("%d %d %d",&std[i].num,&std[i].chinese,&std[i].maths);
      }
      for(i = 0;i < n;i++)
      {
            a[i] = std[i].chinese + std[i].maths;
      }
      for(i = 0;i < n;i++)
      {
          if(a[i]>st[0].zongfen)
          {
              st[2]=st[1];
              st[1]=st[0];
              st[0].zongfen=a[i];
              st[0].num=std[i].num;
          }
          else if(a[i] <= st[0].zongfen && a[i] > st[1].zongfen)
          {
              st[2]=st[1];
              st[1].zongfen=a[i];
              st[1].num=std[i].num;
          }
          else if(a[i] <= st[1].zongfen && a[i]>st[2].zongfen)
          {
              st[2].zongfen=a[i];
              st[2].num=std[i].num;
          }
      }
      for(i = 0;i < 3;i++)
      {
          printf("%d %d\n",st[i].num,st[i].zongfen);
      }
      getchar();
      getchar();

}
int main()
{
  struct student
  {
         int ID;
         int yuwen;
         int shuxue;
  };
  int n,i,x,y,z,o,p,q;
  scanf("%d",&n);
  int a[100000];
  struct student stu[100000];
  for(i=0;i<n;i++)
  {
   scanf("%d %d %d",&stu[i].ID,&stu[i].yuwen,&stu[i].shuxue);
   a[i]=stu[i].yuwen+stu[i].shuxue;
  }
  x=0;
  y=1;
  z=2;
   for(i=0;i<3;i++)
   {
    if(a[i]>=a[0]&&a[i]>=a[1]&&a[i]>=a[2])
    {
       x=i;
       o=a[i];
       continue;
    }
    if(a[i]<=a[0]&&a[i]<=a[1]&&a[i]<=a[2])
    {
       z=i;
       q=a[i];
       continue;
    }
    y=i;
    p=a[i];
   }
  
    for(i=3;i<n;i++)
   {
     if(a[i]>q)
     {
       if(a[i]>o)
       {
        z=y;
        y=x;
        x=i;
        q=p;
        p=o;
        o=a[i];
       }
       else
       {
        if(a[i]>p)
        {
          z=y;
          y=i;
          q=p;
          p=a[i];
        }
        else
        {
          z=i;
          q=a[i];
        }
       }
     }
   }
   printf("%d %d\n",stu[x].ID,o);
    printf("%d %d\n",stu[y].ID,p);
     printf("%d %d\n",stu[z].ID,q);
 getchar();
 getchar();
}
struct student
{ int num;int a;int b;int sum;int c;};
void main()
{
	int n,i,j,nt,ct;
         struct student stu[100000];
	scanf("%d",&n);  
	for(i=0;i<n;i++)
	{ scanf("%d %d %d",&stu[i].num,&stu[i].a,&stu[i].b);
	stu[i].sum=stu[i].a+stu[i].b;stu[i].c=stu[i].sum;}
	for(i=0;i<3;i++)
		for(j=i+1;j<n;j++)
		{	
			if(stu[i].c<stu[j].c){
				nt=stu[i].num;stu[i].num=stu[j].num;stu[j].num=nt;
				ct=stu[i].c;stu[i].c=stu[j].c;stu[j].c=ct;
			}
		}

   for(i=0;i<3;i++)
		   printf("%d %d\n",stu[i].num,stu[i].c);
}
struct student
{
	long a;
	int x;
	int y;
};
struct student stu[100000];
main()
{
	long n,i,j,p;
	int m;
	scanf("%ld",&n);
	int g[100000];
	for(i=0;i<n;i++)
	{
		scanf("%ld %d %d",&stu[i].a,&stu[i].x,&stu[i].y);
		g[i]=stu[i].x+stu[i].y;
	}
	for(i=1;i<4;i++)
		for(j=n-1;j>=i;j--)
			if(g[j-1]<g[j])
			{
				m=g[j-1];g[j-1]=g[j];g[j]=m;
				p=stu[j-1].a;stu[j-1].a=stu[j].a;stu[j].a=p;
			}
	for(i=0;i<3;i++)
		printf("%ld %d\n",stu[i].a,g[i]);
}
struct 
{
	int xuehao;
	int yuwen;
	int shuxue;
}student[1000000];
void swap(int*a,int*b);
int main(int argc, char* argv[])
{
	int n=0;
	scanf("%d",&n);
	int i=0,j=0,total[1000000];
	for(i=0;i<n;i++)
	{
		scanf("%d%d%d",&student[i].xuehao,&student[i].yuwen,&student[i].shuxue);
		total[i]=student[i].yuwen+student[i].shuxue;
	}
	for(i=0;i<3;i++)
	{
		for(j=n-1;j>0+i;j--)
		{
			if(total[j]>total[j-1])
			{
				swap(&total[j],&total[j-1]);
				swap(&student[j-1].xuehao,&student[j].xuehao);
					swap(&student[j-1].yuwen,&student[j].yuwen);
					swap(&student[j-1].shuxue,&student[j].shuxue);
			}
		}
	}
	for(i=0;i<3;i++)
	{
		printf("%d %d\n",student[i].xuehao,total[i]);
	}
	return 0;
}
void swap(int*a,int*b)
{
	int e;
	e=*a;
	*a=*b;
	*b=e;
}
struct student
{
	int id;
	int chinese;
	int math;
}stu[100000];

void bubble(struct student stu[],int n)
{
	int pass,i;
	struct student temp;
	
	for(pass=n-1;pass>=n-3;pass--)
		for(i=pass;i>0;i--)
			if(stu[i].chinese+stu[i].math>stu[i-1].chinese+stu[i-1].math)
			{
				temp=stu[i];
				stu[i]=stu[i-1];
				stu[i-1]=temp;
			}
}


int main()
{
	struct student *p;
	int i;
	int n;

	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d %d %d",&stu[i].id,&stu[i].chinese,&stu[i].math);
	bubble(stu,n);
	for(p=stu;p<stu+3;p++)
		printf("%d %d%c",p->id,p->chinese+p->math,(p==stu+n-1)?'\0':'\n');
	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;
	
    for(i=0;i<m-1;i++)
	
	{
		
		if(i==0) 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=p1;
	p1->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 s
{long int a;
int b;
int c;
int sum;
struct s *next;};
void main()
{struct s *head1,*head2;
struct s *p,*p1,*p2,*p3,*p4;
long int n,i;
int rank1,rank2,rank3;
scanf("%ld",&n);

p1=(struct s *)malloc(L);
scanf("%ld %d %d",&p1->a,&p1->b,&p1->c);
p1->sum=p1->b+p1->c;
rank1=p1->sum;
for(i=1;;i++)
{if(i==1) head1=p1;
else p2->next=p1;
p2=p1;
if(i==n) break;
p1=(struct s *)malloc(L);
scanf("%ld %d %d",&p1->a,&p1->b,&p1->c);
p1->sum=p1->b+p1->c;
if(p1->sum>rank1) rank1=p1->sum;}
p2->next=N;

p1=head1;
while(rank1!=p1->sum)
{p2=p1;p1=p1->next;}
if(rank1==p1->sum)
{if(p1==head1) head1=p1->next;
else p2->next=p1->next;
p3=p1;}
head2=p3;
p4=p3;

p1=head1;
rank2=p1->sum;
while(p1!=N)
{if(p1->sum>rank2) rank2=p1->sum;
p1=p1->next;}

p1=head1;
while(rank2!=p1->sum)
{p2=p1;p1=p1->next;}
if(rank2==p1->sum)
{if(p1==head1) head1=p1->next;
else p2->next=p1->next;
p3=p1;}

p4->next=p3;
p4=p3;

p1=head1;
rank3=p1->sum;
while(p1!=N)
{if(p1->sum>rank3) rank3=p1->sum;
p1=p1->next;}

p1=head1;
while(rank3!=p1->sum)
{p2=p1;p1=p1->next;}
if(rank3==p1->sum)
{if(p1==head1) head1=p1->next;
else p2->next=p1->next;
p3=p1;}
p4->next=p3;
p3->next=N;

p=head2;
do{printf("%ld %d\n",p->a,p->sum);
p=p->next;}while(p!=N);

}
struct student
{
int name;
int ch;
int math;
};
struct student stu[100000];
int main()
{
int n; int sum[100000];int max[3];int i,j,k,m,o;int s;
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d %d %d",&stu[i].name,&stu[i].ch,&stu[i].math);
for(i=0;i<n;i++)
{
               sum[i]=stu[i].ch+stu[i].math;
}
//for(i=0;i<n;i++)
{
                max[0]=0;
                for(j=0,k=0;j<n;j++)
                {if(sum[j]>max[0])
                {max[0]=sum[j];
                k=j;}
                }
}
//for(i=0;i<n;i++)
{
                max[1]=0;
                for(j=1,m=0;j<n;j++)
                {if((sum[j]>max[1])&&(j!=k))
                {max[1]=sum[j];
                m=j;}
                }
}
//for(i=0;i<n;i++)
{
                max[2]=0;
                for(j=1,o=0;j<n;j++)
                {if((sum[j]>max[2])&&(j!=k)&&(j!=m))
                {max[2]=sum[j];
                o=j;}
               
                }
               
               
              
}
printf("%d %d\n",stu[k].name,sum[k]);
printf("%d %d\n",stu[m].name,sum[m]);
printf("%d %d\n",stu[o].name,sum[o]);
return 0;
}