semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
struct student
    {
           int id;
           int ch;
           int math;
    };
int main()
{
    int max(int *p,int n);
    void shuchu(int *p,int n,int k,struct student student[100001]);
    struct student student[100001];
    int n,i,*p,k;
    p=(int *)calloc(100001,sizeof(int));
    scanf("%d\n",&n);
    for(i=0;i<n;i++)
    {
                    scanf("%d %d %d",&student[i].id,&student[i].ch,&student[i].math);
                    (*(p+i))=(student[i].ch+student[i].math);
                    
    }
    k=max(p,n);
    shuchu(p,n,k,student);
    k=max(p,n);
    shuchu(p,n,k,student);
    k=max(p,n);
    shuchu(p,n,k,student);
    
    return 0;
}

int max(int *p,int n)
{
    int k=0,i;
    for(i=0;i<n;i++)
    {
                    if((*(p+i))>k)
                    k=(*(p+i));
    }
    return (k);
}

void shuchu(int *p,int n,int k,struct student student[100001])
{
     int i;
     for(i=0;i<n;i++)
     {
                     if((*(p+i))==k)
                     {
                                   
                                   printf("%d %d\n",student[i].id,k);
                                   (*(p+i))=0;
                                   break;
                     }
     }
}
int main() {
	struct stu{
		int xh;
		int yw;
		int sx;
		int zf;
	}data[100000];
	int n,i,max,x,j;
	scanf ("%d",&n);
	for(i=0;i<n;i++) {
		scanf("%d %d %d",&data[i].xh,&data[i].yw,&data[i].sx);
		data[i].zf=data[i].yw+data[i].sx;
	}
	for(i=0;i<3;i++) {
		max=data[0].zf;
		x=0;
		for(j=1;j<n;j++) {
			if(data[j].zf>max) {
				max=data[j].zf;
				x=j;
			}
		}
		printf("%d %d\n",data[x].xh,data[x].zf);
		data[x].zf=0;

	}
}
struct student
{
	int num;
	int yuwen;
	int math;
	int total;
};
int main()
{
	int n,i,j;
	struct student stu[4],temp;
	scanf("%d",&n);
	for(i=0;i<3;i++)
	stu[i].total=0;
	for(i=0;i<n;i++)
	{
		scanf("%d%d%d",&stu[3].num,&stu[3].yuwen,&stu[3].math);
		stu[3].total=stu[3].yuwen+stu[3].math;
		temp=stu[3];
		for(j=2;j>=0;j--)
		if(temp.total>stu[j].total)
		{
			stu[j+1]=stu[j];
			stu[j]=temp;
		}
		else
		{
			stu[j+1]=temp;
			break;
		}
	}
	for(i=0;i<3;i++)
	printf("%d %d\n",stu[i].num,stu[i].total);
	return 0;
}
int main(){
	int n,i,j;
	cin>>n;
	struct student{
		int number;
		int maths;
		int chinese;
		int sum;
	};
	struct student stu[n],t;
	for(i=0;i<n;i++)                             //???????
		{cin>>stu[i].number>>stu[i].chinese>>stu[i].maths;
		stu[i].sum=stu[i].chinese+stu[i].maths;
		}
	for(i=0;i<3;i++)                           //?????
		for(j=n-2;j>=i;j--)
			if(stu[j].sum<stu[j+1].sum)
				{t=stu[j];
	            stu[j]=stu[j+1];
	            stu[j+1]=t;
				}
	if(n>=3)
	for(i=0;i<3;i++)                              //???3?
		cout<<stu[i].number<<' '<<stu[i].sum<<endl;
	else
	for(i=0;i<n;i++)
		cout<<stu[i].number<<' '<<stu[i].sum<<endl;
	return 0;
}
int main(){
    struct student{
        int num;
        int chs;
        int math;
    };
    struct student s[100000];
    struct student s1[2]={{0,0,0},{0,0,0}};
    int n,i,t,j,a[100000],k=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d%d%d",&s[i].num,&s[i].chs,&s[i].math);
        a[i]=s[i].chs+s[i].math;
    }
    for(i=0;i<3;i++){
        for(j=0;j<n-1-i;j++){
            if(a[j]>a[j+1]){
                t=a[j];
                a[j]=a[j+1];
                a[j+1]=t;
            }
        }
    }
    for(i=n-1;i>n-4;i--){
        for(j=0;j<n;j++){
            if(a[i]==s[j].chs+s[j].math&&s[j].num!=s1[0].num&&s[j].num!=s1[1].num){
                printf("%d %d\n",s[j].num,s[j].chs+s[j].math);
                s1[k]=s[j];
                k++;
                if(k==3){
                    goto end;
                }
            }
        }
    }
  end:
    return 0;
}
//????????????
//??????
//?????2010-12-24
//????????????????????????


int main()
{
    int n,i,j,x,y;
    struct student
    {
           int score,num;
           }  //??????????? 
    a[100000];       
    cin>>n;
    for (i=1;i<=n;i++) {cin>>a[i].num>>x>>y;a[i].score=x+y;}
    a[0]=a[1];
    for (i=1;i<=3;i++)//?? 
      for(j=i+1;j<=n;j++)
        if (a[i].score<a[j].score) {a[0]=a[i];a[i]=a[j];a[j]=a[0];}
    cout<<a[1].num<<" "<<a[1].score<<endl<<a[2].num<<" "<<a[2].score<<endl<<a[3].num<<" "<<a[3].score;
}
typedef struct st
{
      int a,b;
} stu ;
stu s[100000];
int comp(const void *a,const void *b)
{
    return ((stu*)b)->b-((stu*)a)->b;
}
int main()
{
    int i,n,a,b;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
                    scanf("%d%d%d",&s[i].a,&a,&b);
                    s[i].b=a+b;
    }
    qsort(s,n,sizeof(stu),comp);
    printf("%d %d\n%d %d\n%d %d",s[0].a,s[0].b,s[1].a,s[1].b,s[2].a,s[2].b);
    //getch();
    return 0;
}
struct stu
{
	long int num;
	int chi;
	int mat;
	int tot;
};
int main()
{
	struct stu a[100050];
	int n,k,i,j,temp2,max;
	long int temp1;
	scanf("%d",&n);
	for (i=1;i<=n;i++)
	{
		scanf("%ld%d%d",&a[i].num,&a[i].chi,&a[i].mat);
		a[i].tot=a[i].chi+a[i].mat;
	}
	for (j=1;j<=3;j++)
	{
	max=0;
	a[0].tot=0;
	for (i=1;i<=n;i++)
		if (a[max].tot<a[i].tot) max=i;
	printf("%ld %d\n",a[max].num,a[max].tot);
	a[max].tot=0;
	}
	scanf("\n");
	return(0);
}
int main()
{
struct student{
int num;
int yw;
int sx;
int all;
}student[4]={0,0,0,0};
struct student temp={0,0,0,0};
int i, l,n;
scanf("%d",&n);

for(i=0;i<n;i++)
{
scanf("%d%d%d",&student[3].num,&student[3].yw,&student[3].sx);
student[3].all=student[3].yw+student[3].sx;

if(student[2].all<student[3].all)
{
temp=student[2];
student[2]=student[3];
student[3]=temp;
}
if(student[1].all<student[2].all)
{
temp=student[1];
student[1]=student[2];
student[2]=temp;
}
if(student[0].all<student[1].all)
{
temp=student[0];
student[0]=student[1];
student[1]=temp;
}
}
for(l=0;l<3;l++)
{
printf("%d %d\n",student[l].num,student[l].all);
}
}
int main()
{
	struct student
	{
		char NUM[100000];
		int Ma;
		int Ch;	
	}stu;
    int n,i,x,max1,max2,max3,m1,m2,m3;
	max1=max2=max3=0;
	m1=m2=m3=0;

	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
        scanf("%s %d %d",stu.NUM,&(stu.Ma),&(stu.Ch));
		x=stu.Ma+stu.Ch;
	    if(x>max1)
		{
		max3=max2; 
		max2=max1;
		max1=x;
		m3=m2;
		m2=m1;
		m1=i;
		}
    else if(x==max1)
	{
		max3=max2; 
		max2=max1;
		max1=max1;
		m3=m2;
		m2=i;
	}
	else if(x<max1 && x>max2)
	{
		max3=max2; 
		max2=x;
		m3=m2;
	}
	
	else if(x==max2)
	{
		max3=max2; 
		m3=i;
	}
	else if(x<max2 && x>max3)
	{
		max3=x;
		m3=i;
	}
	}
	
	printf("%d %d\n",m1,max1);
	printf("%d %d\n",m2,max2);
	printf("%d %d\n",m3,max3);
	return 0;
}
/*
 * score.cpp
 *
 *  Created on: 2010-12-24
 *      Author: ???
 *      function: ????????
 */
int main()
{
	int stuNum,i;
	cin>>stuNum;
	struct student{
		int id,math,chinese,total;
	};//??????student
	struct student stu[stuNum],first,second,third;
	for(i=0;i<stuNum;i++){//???????????????
		cin>>stu[i].id>>stu[i].chinese>>stu[i].math;
		stu[i].total=stu[i].chinese+stu[i].math;
	}
	//????????????
	first=second=third=stu[0];
	for(i=1;i<stuNum;i++)
		if(stu[i].total>first.total) first=stu[i];
	cout<<first.id<<' '<<first.total<<endl;
	for(i=1;i<stuNum;i++)
		if(stu[i].total>second.total&&stu[i].id!=first.id) second=stu[i];
	cout<<second.id<<' '<<second.total<<endl;
	for(i=1;i<stuNum;i++)
		if(stu[i].total>third.total&&stu[i].id!=first.id&&stu[i].id!=second.id) third=stu[i];
	cout<<third.id<<' '<<third.total<<endl;
	return 0;
}
struct student
{
	int num;
	int chi;
	int mat;
	int tol;
	struct student *next;
};

void main()
{

	struct student *p1,*p2,*head;
	struct student *p,*a,*b,*c;
	struct student temp;

	int n,i;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{	
		p1=(struct student*)malloc(LEN);
		scanf("%d%d%d",&p1->num,&p1->chi,&p1->mat);
		p1->tol=p1->chi+p1->mat;
		if(i==0) 
			head=p2=p1;
		else
			p2->next=p1;
		p2=p1;
	}
	p2->next=NULL;
	
	p=head;
	temp.tol=0;
	a=b=c=&temp;
	while(p!=NULL)
	{
		if(p->tol>a->tol)
		{
			c=b;
			b=a;
			a=p;
		}
		else if(p->tol>b->tol)
		{
			c=b;
			b=p;
		}
		else if(p->tol>c->tol)
			c=p;
		p=p->next;
	}

	printf("%d %d\n",a->num,a->tol);
	printf("%d %d\n",b->num,b->tol);
	printf("%d %d\n",c->num,c->tol);
}
struct Student
{
	long Id;
	int yuwen;
	int shuxue;
};

int main()
{
	int i,j; 
	long n;
	struct Student student[NUM];
	struct Student temp;
	scanf("%ld\n",&n);
	for(i=0;i<n;i++)
		scanf("%ld%d%d",&student[i].Id,&student[i].yuwen,&student[i].shuxue);
	for(i=0;i<3;i++)
	{
		for(j=0;j<(3-i-1);j++)
		{
			if((student[j+1].yuwen+student[j+1].shuxue)>(student[j].yuwen+student[j].shuxue))
			{
				temp=student[j+1];
				student[j+1]=student[j];
				student[j]=temp;
			}
		}
	}
	for(i=3;i<n;i++)
	{
        if((student[i].yuwen+student[i].shuxue)>(student[2].yuwen+student[2].shuxue))
			{
				student[2]=student[i];	
			}
		if((student[i].yuwen+student[i].shuxue)>(student[1].yuwen+student[1].shuxue))
			{
				temp=student[1];
				student[1]=student[i];
				student[2]=temp;
			}
		if((student[i].yuwen+student[i].shuxue)>(student[0].yuwen+student[0].shuxue))
			{
				temp=student[0];
				student[0]=student[i];
				student[1]=temp;
			}
	}
	for(i=0;i<3;i++)
	{
		printf("%ld %d\n",student[i].Id,(student[i].shuxue+student[i].yuwen));
	}
	return 0;
}
struct student
	{
	int number;
	int yuwen;
	int shuxue;
    int sum;
	struct student *next;
	};
int n;
struct student*creat(void)
{struct student*head,*p1,*p2;
 scanf("%d",&n);
 p1=p2=(struct student*)malloc(LEN);
 scanf("%d%d%d",&p1->number,&p1->yuwen,&p1->shuxue);
 p1->sum=p1->yuwen+p1->shuxue;
 head=p1;
 int i;
 for(i=1;i<n;i++)
	{
	p1=(struct student*)malloc(LEN);
	p2->next=p1;
	p2=p1;
	scanf("%d%d%d",&p1->number,&p1->yuwen,&p1->shuxue);
    p1->sum=p1->yuwen+p1->shuxue;
	}
 p2->next=null;
 return head;
}
void compare(struct student*head)
{int max,i;
 struct student*p;
 for(i=1;i<=3;i++)
	{max=0;
     p=head;
	 while(p!=null)
		{if(p->sum>max)max=p->sum;
	     p=p->next;
		}
	 p=head;
     while(p!=null)
		{if(p->sum==max)
			{printf("%d %d\n",p->number,max);
			p->sum=0;		
			break;
			}	
	     p=p->next;
		}
	}
}
main()
{struct student*head;
 head=creat();
 compare(head);
}
/*
 * structure_1.cpp
 *
 *  Created on: 2010-12-29
 *      Author: ???
 *        ??? ????????
 */



int main(){
	int n,i,j;
	cin>>n;
	struct student{                  //?????????????????????
		int id;
		int cp;
		int mp;
		int tp;
	} stu[n],temp;
	for(i=0;i<n;i++){                //??????
		cin>>stu[i].id>>stu[i].cp>>stu[i].mp;
		stu[i].tp=stu[i].cp+stu[i].mp;
	}
	for(i=0;i<3;i++)               //?????????
		for(j=n-1;j>i;j--)
			if(stu[j].tp>stu[j-1].tp){
				temp=stu[j];
				stu[j]=stu[j-1];
				stu[j-1]=temp;
			}
	for(i=0;i<3;i++)                 //???????
		cout<<stu[i].id<<' '<<stu[i].tp<<endl;
	return 0;
}
struct student
{
    int xuehao;
    int yuwen;
    int shuxue;
}stu[100000];
int main()
{
    int sum[100000];
    long i,j,n,t;
    scanf ("%d",&n);
    for (i=0;i<n;i++)
    {
        scanf ("%d %d %d",&stu[i].xuehao,&stu[i].yuwen,&stu[i].shuxue);
        sum[i]=stu[i].yuwen+stu[i].shuxue;
    }
    
    for (i=0;i<3;i++)
    {
        t=0;
        for (j=0;j<n-1;j++)
        {
            if (sum[j+1]>sum[t])
            t=j+1;
        }
        printf ("%d %d\n",stu[t].xuehao,sum[t]);
        sum[t]=0;
    }
    getchar();
    getchar();
    getchar();
}
int main()
{
	  int n,i,j;
	  float one=0,two=0,three=0,yi=0,er=0,san=0;
	  float a[100000][2];
	  scanf("%d",&n);
	  struct Student
	  {
		  float xuehao;
		  float yuwen;
		  float shuxue;
	  } student;
	  for (i=0;i<n;i++){
		  scanf("%f %f %f",&student.xuehao,&student.yuwen,&student.shuxue);
		  for (j=0;j<2;j++){
			  a[i][1]=student.yuwen+student.shuxue;  
	          a[i][0]=i+1;
		  }
	  }
	  for (i=0;i<n;i++){
          if (a[i][1]>one)
		  {		  one=a[i][1];
		  yi=a[i][0];  }
	  }
      for (i=0;i<n;i++){
          if (a[i][1]>two&&a[i][1]<=one&&a[i][0]!=yi)
		  {		  two=a[i][1];
		  er=a[i][0];  }
	  }
       for (i=0;i<n;i++){
          if (a[i][1]>three&&a[i][1]<=one&&a[i][1]<=two&&a[i][0]!=yi&&a[i][0]!=er)
		  {		  three=a[i][1];
		  san=a[i][0];  }
	  }
	   printf("%.0f %.0f\n",yi,one);
	   printf("%.0f %.0f\n",er,two);
	   printf("%.0f %.0f\n",san,three);
	   return 0;
}
int main(int argc, char* argv[])
{
	int n,max,m;
	scanf("%d",&n);
	struct stu{
		int hao,yuwen,shuxue,zong;
	}stu[100000];
	int i,j;
	for(i=0;i<n;i++)
	{
		scanf("%d""%d""%d",&stu[i].hao,&stu[i].yuwen,&stu[i].shuxue);
		stu[i].zong=stu[i].yuwen+stu[i].shuxue;
	}
	for(i=0;i<3;i++)
	{
		max=stu[0].zong;
		for(j=1;j<n;j++)
		{
			if(stu[j].zong>max)
			{
				max=stu[j].zong;
				m=j;
			}
					}printf("%d %d\n",stu[m].hao,max);
			stu[m].zong=0;

	}
		

    
	return 0;
}
struct student{
	int num;
	int chinese;
	int math;
};
int main()
{ 
    int n,i;
	scanf("%d",&n);
	struct student a[100000],e ;
	for(i=0;i<n;i++){
		scanf("%d %d %d",&a[i].num,&a[i].chinese,&a[i].math);		
	}
	for(i=0;i<n-1;i++){
		if(a[i].chinese+a[i].math>=a[i+1].chinese+a[i+1].math){
			e=a[i];
			a[i]=a[i+1];
			a[i+1]=e;
		}
	}
	for(i=0;i<n-2;i++){
		if(a[i].chinese+a[i].math>=a[i+1].chinese+a[i+1].math){
			e=a[i];
			a[i]=a[i+1];
			a[i+1]=e;
		}
	}
	for(i=0;i<n-3;i++){
		if(a[i].chinese+a[i].math>=a[i+1].chinese+a[i+1].math){
			e=a[i];
			a[i]=a[i+1];
			a[i+1]=e;
		}
	}
	for(i=n-1;i>n-4;i--){
		printf("%d %d\n",a[i].num,a[i].chinese+a[i].math);
	}
	return 0;
}
struct student
{
       long int  id;
       int chinese;
       int math;
};
main()
{
      long int i,maxi1,maxi2,maxi3,num;
      scanf("%d",&num);
      struct student a[num];
      for (i=0;i<num;i++)
      scanf("%d %d %d",&a[i].id,&a[i].chinese,&a[i].math);
      int maxpt1=0,maxpt2=0,maxpt3=0;
      for (i=0;i<num;i++)
      {
          if (maxpt1<a[i].chinese+a[i].math)
          {
                               maxpt3=maxpt2;
                               maxpt2=maxpt1;
                               maxpt1=a[i].chinese+a[i].math;
                               maxi3=maxi2;
                               maxi2=maxi1;
                               maxi1=a[i].id;                              
          }
          else if (maxpt2<a[i].chinese+a[i].math)
          {
                               maxpt3=maxpt2;
                               maxpt2=a[i].chinese+a[i].math;
                               maxi3=maxi2;
                               maxi2=a[i].id;                           
          }
          else if (maxpt3<a[i].chinese+a[i].math)
          {
                               maxpt3=a[i].chinese+a[i].math;
                               maxi3=a[i].id;                            
          }
      }
      printf("%d %d\n%d %d\n%d %d",maxi1,maxpt1,maxi2,maxpt2,maxi3,maxpt3);

}
void main()
{
	struct student
	{
		int ID;
	    int mark1;
		int mark2;
		int total;
	}student[100000],temp;
	int n,k,m;
	scanf("%d",&n);
	for(k=0;k<n;k++)
	{
		scanf("%d%d%d",&student[k].ID,&student[k].mark1,&student[k].mark2);
		student[k].total=student[k].mark1+student[k].mark2;
	}
	for(m=0;m<3;m++)
	{
	for(k=n-1;k>=m;k--)
	{
		if(student[k].total>student[k-1].total)
		{
			temp=student[k-1];
			student[k-1]=student[k];
			student[k]=temp;
		}
	}
	}
	printf("%d %d\n%d %d\n%d %d\n",student[0].ID,student[0].total,student[1].ID,student[1].total,student[2].ID,student[2].total);
}
/*
 * ???: 1000010191_38_1.cpp
 * ??: ???
 * ????: 2010-12-31
 * ??: ????????
 */


struct student //??
{
	int id; //??
	int x,y; //???????
	int s; //??
} d[100001],t;

int main()
{
	//????
	int n;
	cin>>n;
	for (int i=1;i<=n;i++)
	{
		cin>>d[i].id>>d[i].x>>d[i].y;
		//???
		d[i].s=d[i].x+d[i].y;
	}
	//??
	for (int i=1;i<=3;i++)
		for (int j=1;j<=n-i;j++)
			if (d[j].s>=d[j+1].s)
			{
				t=d[j];
				d[j]=d[j+1];
				d[j+1]=t;
			}
	//????
	for (int i=n;i>=n-2;i--)
		cout<<d[i].id<<' '<<d[i].s<<endl;
	return 0;
}
struct student
{
	long number;
	int chinese;
	int math;
	int sum;
	struct student *next;
	struct student *previous;
};
struct student *creat(long n)
{
	struct student *head,*p1,*p2;
	int i;
	head=null;
	p1=(struct student *)malloc(len);
	scanf("%d %d %d",&p1->number,&p1->chinese,&p1->math);
	p1->sum=p1->chinese+p1->math;
	p1->next=null;p1->previous=null;
	head=p1;p2=p1;
	for(i=2;i<=n;i++)
	{
		p1=(struct student *)malloc(len);
		scanf("%d %d %d",&p1->number,&p1->chinese,&p1->math);
	    p1->sum=p1->chinese+p1->math;
	    p1->next=null;
	    p1->previous=p2;
	    p2->next=p1;
	    p2=p1;
	}
	return(head);
}
struct student *print(struct student *head)
{
	struct student *max,*p;
	max=head;
    for(p=head;p!=null;p=p->next)
      if(p->sum>max->sum) max=p;
    printf("%d %d\n",max->number,max->sum);
    if(max==head)
        head=max->next;
    else 
        max->previous->next=max->next;
    return(head);
}
void main()
{
    struct student *head;
    long n;
    scanf("%d",&n);
    head=creat(n);
    print(head);
    print(head);
    print(head);
}
struct Student
{int num;
 int yuwen;
 int shuxue;
};
void fun(int*a,int*b);
int main()
{
	int n,i,j;
	int sum[100000];
	scanf ("%d",&n);
	struct Student stu[100000];
	for (i=0;i<n;i++)
	{
		scanf ("%d%d%d",&stu[i].num,&stu[i].yuwen,&stu[i].shuxue);
		sum[i]=stu[i].yuwen+stu[i].shuxue;
	}
	for(i=0;i<3;i++)
	{
		for(j=n-1;j>i;j--)
		{
			if(sum[j]>sum[j-1])
			{
				fun(&sum[j],&sum[j-1]);
				fun(&stu[j-1].num,&stu[j].num);
					fun(&stu[j-1].yuwen,&stu[j].yuwen);
					fun(&stu[j-1].shuxue,&stu[j].shuxue);
			}
		}
	}
	for (i=0;i<3;i++)
		printf ("%d %d\n",stu[i].num,sum[i]);
	return 0;
}
void fun(int*a,int*b)
{
	int k;
	k=*a;
	*a=*b;
	*b=k;
}
struct student{
	int num;
	int yuwen;
	int shuxue;
	int score;
	struct student *next;
};
int n,i=0,a;
struct student *m1,*m2,*m3,*q;
struct student *creat(void)
{
	struct student *head;
	struct student *p1,*p2;
	p1=p2=(struct student*)malloc(LEN);
	scanf("%d %d %d",&p1->num,&p1->yuwen,&p1->shuxue);
	p1->score=p1->yuwen+p1->shuxue;
	head=NULL;
	while(i<n-1)
	{		
		if(i==0)head=p1;
		else p2->next=p1;
		p2=p1;
		p1=(struct student*)malloc(LEN);		
		scanf("%d %d %d",&p1->num,&p1->yuwen,&p1->shuxue);
		p1->score=p1->yuwen+p1->shuxue;
		if(i>=3)
		{
			if(p2->score>m1->score)
			{
				m3=m2;
				m2=m1;
				m1=p2;
			}
			else if(p2->score<=m1->score&&p2->score>m2->score)
			{
				m3=m2;
				m2=p2;
			}
			else if(p2->score<=m2->score&&p2->score>m3->score)
				m3=p2;
			i++;
			continue;
		}
		if(i==0)m1=p2;
		else if(i==1)m2=p2;
		else if(i==2)
		{
			m3=p2;
			if(m1->score>m2->score)
			{
				if(m2->score<=m3->score)
				{
					if(m1->score>m3->score)
					{
						q=m3;
						m3=m2;
						m2=q;
					}
					else if(m1->score<=m3->score)
					{
						q=m1;m1=m2;m2=m3;m3=q;
					}
				}
			}
			else if(m1->score<=m2->score)
			{
				if(m2->score>m3->score)
				{
					if(m1->score>m3->score)
					{
						q=m1;
						m1=m2;
						m2=q;
					}
					else if(m1->score<=m3->score)
					{
						q=m3;m3=m1;m1=m2;m2=q;
					}
				}
				else if(m2->score<=m3->score)
				{
					q=m1;
					m1=m3;
					m3=q;
				}
			}
		}
		i++;
	}
	return(head);
}
int main()
{
	struct student *head;
	scanf("%d",&n);
	head=creat();
	printf("%d %d\n",m1->num,m1->score);
	printf("%d %d\n",m2->num,m2->score);
	printf("%d %d\n",m3->num,m3->score);
	return 0;					
}
int main(int argc, char* argv[])
{
	struct student
	{int id;
	int x;
	int y;
	int z;
	}student1,student2,student3,studenta;
	int n,i;
	scanf("%d",&n);
	student1.z=student2.z=student3.z=0;
	for(i=0;i<n;i++){
		scanf("%d%d%d",&studenta.id,&studenta.x,&studenta.y);
		studenta.z=studenta.x+studenta.y;
		if(studenta.z>student1.z){
			student3.z=student2.z;student3.id=student2.id;
			student2.z=student1.z;student2.id=student1.id;
			student1.z=studenta.z;student1.id=studenta.id;
		}
		else if(studenta.z>student2.z){
			student3.z=student2.z;student3.id=student2.id;
			student2.z=studenta.z;student2.id=studenta.id;
		}
		else if(studenta.z>student3.z){
			student3.z=studenta.z;student3.id=studenta.id;
		}
	}
	printf("%d %d\n%d %d\n%d %d\n",student1.id,student1.z,student2.id,student2.z,student3.id,student3.z);
	return 0;
}
struct stu
{long num;
int y;
int s;
int t;
struct stu * next;
};
void main()
{
	struct stu * head,*p1,*p2;
	int n,i;
	scanf("%d",&n);
	p1=p2=(struct stu *)malloc(L);
    scanf("%ld %d %d",&p1->num,&p1->y,&p1->s);
	head=p1;
	for(i=1;i<n;i++)
	{
		p1=(struct stu*) malloc(L);
		scanf("%ld %d %d",&p1->num,&p1->y,&p1->s);
		p1->t=p1->y+p1->s;
		p2->next=p1;
		p2=p1;
	}
	p2->next=0;
	int k=0;
	while(k<3)
	{
		p2=head;
	    for(;p2!=0;p2=p2->next)
		{
			for(p1=p2->next;p1!=0;)
			{
				if(p2->t<p1->t) break;
	 	        else p1=p1->next;
			}
			if(p1==0) {printf("%ld %d\n",p2->num,p2->t);break;}
		}
		k=k+1;p2->t=0;
	}
}
struct student{
	int number,chinese,math,total;
}stu[100000];
int main(int argc, char* argv[])
{
	int n,i;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d%d%d",&stu[i].number,&stu[i].chinese,&stu[i].math);
		stu[i].total=stu[i].chinese+stu[i].math;
	}
	int a=stu[0].total,b=stu[0].total,c=stu[0].total;
	for(i=0;i<n;i++){
		if(stu[i].total>a){
			c=b;
			b=a;
			a=stu[i].total;
			continue;
		}
		if(stu[i].total<a&&stu[i].total>b){
			c=b;
			b=stu[i].total;
			continue;
		}
		if(stu[i].total<b&&stu[i].total>c){
			c=stu[i].total;
			continue;
		}
	}
	int m=0;
	for(i=0;i<n&&m<3;i++){
		if(stu[i].total==a){
			printf("%d %d\n",stu[i].number,stu[i].total);
			m++;
		}
	}
	for(i=0;i<n&&m<3;i++){
		if(stu[i].total==b){
			printf("%d %d\n",stu[i].number,stu[i].total);
			m++;
		}
	}
	for(i=0;i<n&&m<3;i++){
		if(stu[i].total==c){
			printf("%d %d\n",stu[i].number,stu[i].total);
			m++;
		}
	}
	return 0;
}
void main()
{
	struct s
	{
		int a;
		int b;
		int c;
		int d;
		struct s *next;
	};
	struct s *p1,*p2,*head;
	int i,j,k,m,n,t;
	scanf("%d",&n);
	p1=p2=(struct s *)malloc(sizeof(struct s));
	head=p1;
	scanf("%d %d %d",&p1->a,&p1->b,&p1->c);
	for(i=0;i<n-1;i++)
	{
		p1=(struct s *)malloc(sizeof(struct s));
		p2->next=p1;
		p2=p1;
		scanf("%d %d %d",&p1->a,&p1->b,&p1->c);
	}
	p2->next=0;
	p1=p2=head;
	for(i=0;i<n;i++)
	{
		p1->d=p1->b+p1->c;
		p1=p1->next;
	}
	p1=head;
	p2=p1->next;
	for(j=0;j<3;j++)
	{
		p1=head;p2=p1->next;
		for(i=0;i<n-2;i++)
		{
			if(p1->d<p2->d)
			{
				t=p1->d;
				p1->d=p2->d;
				p2->d=t;
				k=p1->a;
				p1->a=p2->a;
				p2->a=k;
			}
			
			p2=p2->next;
			
		}
		p1=head;

		
			printf("%d %d\n",p1->a,p1->d);
			p1->d=0;
			
	}
}
struct student
{
	int num;
	int liter;
	int math;
	int total;
};
int main()
{
	int i,j,k,n;
	struct student a[100000],n1,n2,n3;
	scanf("%d",&n);
	scanf("%d%d%d",&a[0].num,&a[0].liter,&a[0].math);
	a[0].total=a[0].liter+a[0].math;
	n1=n2=n3=a[0];
	for(i=1;i<n;i++)
	{
		scanf("%d%d%d",&a[i].num,&a[i].liter,&a[i].math);
		a[i].total=a[i].liter+a[i].math;
		if(a[i].total>n1.total)
		{
			n3=n2;
			n2=n1;
			n1=a[i];
		}
		else if(a[i].total>n2.total)
		{
			n3=n2;
			n2=a[i];
		}
		else if(a[i].total>n3.total)
			n3=a[i];
	}
	printf("%d %d\n",n1.num,n1.total);
	printf("%d %d\n",n2.num,n2.total);
	printf("%d %d",n3.num,n3.total);
		return 0;
}
/*
 * 01.cpp
 *
 *  Created on: 2010-12-24
 *      Author: liuquan
 */
int main(){
	struct student{//????
		int number;
		int chinese;
		int math;
		int all;
	}stu[100000];
	int n,i,j,n1=1,n2=1,n3=1;
	cin>>n;
	for(i=1;i<=n;i++){//??
		cin>>stu[i].number>>stu[i].chinese>>stu[i].math;
		stu[i].all=stu[i].chinese+stu[i].math;
	}
	/*for(j=1;j<n;j++){//?????
		for(i=1;i<n-j;i++){
			if(stu[i].all<stu[i+1].all){
				t=stu[i].all;
				stu[i].all=stu[i+1].all;
				stu[i+1].all=t;
				t1=stu[i].number;
				stu[i].number=stu[i+1].number;
				stu[i+1].number=t1;
			}
		}
	}*/
	for(i=2;i<=n;i++){
		if(stu[n1].all<stu[i].all)
			n1=i;

	}
	for(i=2;i<=n;i++){
		if(i==n1)
          continue;
		if(stu[n2].all<stu[i].all)
			n2=i;
	}
	for(i=2;i<=n;i++){
		if(i==n2||i==n1)
           continue;
		if(stu[n3].all<stu[i].all)
			n3=i;
	}
		cout<<stu[n1].number<<" "<<stu[n1].all<<endl;//?????
		cout<<stu[n2].number<<" "<<stu[n2].all<<endl;
		cout<<stu[n3].number<<" "<<stu[n3].all<<endl;
	return 0;
}