semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int main()
{
struct stu
    {
    int num;
    int ch;
    int ma;
    int to;       
    }; 
    int i,j1,j2,j3,k,max;
    struct stu student[100000]={0};
    struct stu temp;
    scanf("%d",&k);
    for(i=0;i<=k-1;i++)
    {
    scanf("%d%d%d",&student[i].num,&student[i].ch,&student[i].ma); 
    student[i].to=student[i].ch+student[i].ma;
    }
    max=0;
    for(i=0;i<=k-1;i++)
    {
                      if(student[i].to>max)
                      {
                            max=student[i].to;
                            j1=i;               
                      }
    }
     printf("%d ",student[j1].num);
     printf("%d\n",student[j1].to);
    max=0;
    for(i=0;i<=k-1;i++)
    {
                      if(i==j1) continue;
                      if(student[i].to>max)
                      {
                            max=student[i].to;
                            j2=i;               
                      }
    }
     printf("%d ",student[j2].num);
     printf("%d\n",student[j2].to);max=0;
    max=0;
    for(i=0;i<=k-1;i++)
    {
                      if(i==j1||i==j2) continue;
                      if(student[i].to>max)
                      {
                            max=student[i].to;
                            j3=i;               
                      }
    }
     printf("%d ",student[j3].num);
     printf("%d\n",student[j3].to);
return 0;
}
struct student
{
	int num;
	int yu;
	int shu;
	int he;
	struct student *next;
};

struct student *create(int n)
{
	struct student *head,*p1,*p2;
	int i;

	p1=(struct student*)malloc(len);
	scanf("%d %d %d",&p1->num,&p1->yu,&p1->shu);
	p1->he=p1->yu+p1->shu;
	p1->next=NULL;

	head=p1;
	p2=p1;
	for(i=1;i<=n-1;i++)
	{
		p1=(struct student*)malloc(len);
		scanf("%d %d %d",&p1->num,&p1->yu,&p1->shu);
		p1->he=p1->yu+p1->shu;
		p1->next=NULL;
		p2->next=p1;
		p2=p1;
	}
	return head;
}

struct student *max(struct student *head)
{
	struct student *p,*m;
	m=head;
	p=head->next;
	while(p)
	{
		if(p->he>m->he) m=p;
		p=p->next;
	}
	return m;
}

void main()
{
	int n,i;
	struct student *head,*m;
	struct student *create(int n);
	struct student *max(struct student *head);
	scanf("%d",&n);
	head=create(n);
	for(i=1;i<=3;i++)
	{
		m=max(head);
		printf("%d %d\n",m->num,m->he);
		m->he=-1;
	}
}
void main()
{
	int i,n,j,max;                                              
	scanf("%d",&n);
	struct student
	{
		int num;
		int yuwen;
		int shuxue;
		struct student * next;
	};
	struct student *head,*ppre,*p0,*p3;
	struct student *p1,*p2;
	head=p1=p2=(struct student *)malloc(sizeof(struct student));
	for(i=0;i<n;i++)
	{
	     scanf("%d %d %d",&p1->num,&p1->yuwen,&p1->shuxue);
	    p1=(struct student *)malloc(sizeof(struct student));
	    p2->next=p1;
	    p2=p1;
	}
	p2->next=NULL;           /*????*/
    
	for(j=0;j<3;j++)
	{
		ppre=p1=head;
	    max=p1->yuwen+p1->shuxue;
	    p1=p1->next;
	for(i=0;i<n-j;i++)
	{
           if((p1->yuwen+p1->shuxue)>max)
		   {
			   max=p1->yuwen+p1->shuxue;
			   p0=p1;
			   p3=ppre;
		   }
		   ppre=p1;
	       p1=p1->next;
	}
	printf("%d %d\n",p0->num,max);
	     p3->next=p0->next;
	}
}
/*????????
 *?????
 *???1000010549
 *???2010-12-25
 */


struct student{
    int num;
    int scorec;
    int scorem;
    int score;
};

int main(){
    int n;
    int i;
    struct student stu[100001];
    int best[2][3]={{0,0,0},{0,0,0}};
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>stu[i].num>>stu[i].scorec>>stu[i].scorem;
        stu[i].score=stu[i].scorec+stu[i].scorem;
    }
    for(i=1;i<=n;i++)
    {
        if(stu[i].score>best[1][0])
        {
            best[0][2]=best[0][1];
            best[0][1]=best[0][0];
            best[0][0]=stu[i].num;
            best[1][2]=best[1][1];
            best[1][1]=best[1][0];
            best[1][0]=stu[i].score;
        }
        else if(stu[i].score<=best[1][0]&&stu[i].score>best[1][1])
        {
            best[0][2]=best[0][1];
            best[0][1]=stu[i].num;
            best[1][2]=best[1][1];
            best[1][1]=stu[i].score;
        }
        else if(stu[i].score<=best[1][1]&&stu[i].score>best[1][2])
        {
            best[0][2]=stu[i].num;
            best[1][2]=stu[i].score;
        }
    }
    for(i=0;i<3;i++)
        cout<<best[0][i]<<' '<<best[1][i]<<endl;
    return 0;
}
struct stu
{
	int id;
	int verbal;
	int math;
	int sum;
};

int main()
{
	struct stu *a,t;
	int n,i,j;
	scanf("%d",&n);
	a=(struct stu *)malloc(n*sizeof(struct stu));
		for (i=0;i<n;i++)
		{
			scanf("%d %d %d",&a[i].id,&a[i].verbal,&a[i].math);
			a[i].sum=a[i].verbal+a[i].math;
		}
		for (j=0;j<3;j++)
			for (i=n;i>j;i--)
				if (a[i].sum>a[i-1].sum)
				{
					t=a[i];
					a[i]=a[i-1];
					a[i-1]=t;
				}
		for (i=0;i<3;i++)
		printf("%d %d\n",a[i].id,a[i].sum); 

	return 0;

}
struct score 
{
 long num;
 int yu;
 int shu;
 int sum;
 }stu[100000];
void main()
{
  long  i,n,j,k;
   int t;
  scanf("%ld",&n);
 for(i=0;i<n;i++)
 {
   scanf("%ld%d%d",&stu[i].num,&stu[i].yu,&stu[i].shu);
   stu[i].sum=stu[i].yu+stu[i].shu;
 }  
 for(i=0;i<3;i++)
{
  for(j=0;j<n-i-1;j++)
    if(stu[j].sum>stu[j+1].sum)
       {
         t=stu[j].sum;
         stu[j].sum=stu[j+1].sum;
         stu[j+1].sum=t;
        }
 }
for(k=n-1;k>n-4;k--)
{
  if(k!=n-1&&stu[k].sum==stu[k+1].sum)continue; 
    for(i=0;i<n;i++)	 
   {
	   if(stu[k].sum==(stu[i].yu+stu[i].shu))
        { printf("%ld %ld\n",stu[i].num,stu[k].sum);
       if(k==n-3)break;}
   }
}
 }
struct stu
{
	int ID;
	int c;
	int m;
};
struct stu a[100000];


int main(int argc, char* argv[])
{
	int n,i,x,y,z,t,q,w,e;
	int b[100000];
	scanf("%d\n",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d ",&a[i].ID);
		scanf("%d ",&a[i].c);
        scanf("%d",&a[i].m);
	}
	for(i=0;i<n;i++)
		b[i]=a[i].c+a[i].m;
	if(b[0]>b[1]&&b[1]>b[2])
	{
		x=b[0];
		q=1;
		y=b[1];
		w=1+1;
		z=b[2];
		e=2+1;
	}
	else if(b[1]>b[0]&&b[0]>b[2])
	{
		x=b[1];
		y=b[0];
		z=b[2];
		q=1+1;
		w=0+1;
		e=2+1;
	}
	else if(b[2]>b[1]&&b[1]>b[0])
	{
		x=b[2];
		y=b[1];
		z=b[0];
		q=2+1;
		w=1+1;
		e=0+1;
	}
	else if(b[2]>b[0]&&b[0]>b[1])
	{
		x=b[2];
		y=b[0];
		z=b[1];
		q=2+1;
		w=0+1;
		e=1+1;
	}
	else if(b[1]>b[2]&&b[2]>b[0])
	{
		x=b[1];
		y=b[2];
		z=b[0];
		q=1+1;
		w=2+1;
		e=0+1;
	}else if(b[0]>b[2]&&b[2]>b[1])
	{
		x=b[0];
		y=b[2];
		z=b[1];
		q=0+1;
		w=2+1;
		e=1+1;
	}
	for(i=3;i<n;i++)
	{
		if(b[i]>x)
		{
			t=x;
			x=b[i];
			z=y;
			y=t;
			e=w;
			w=q;
			q=i+1;
		}
		else if(b[i]>y)
		{
			z=y;
			y=b[i];
			e=w;
			w=i+1;
		}
		else if(b[i]>z)
		{
			z=b[i];
			e=i+1;
		}
	}
	printf("%d %d\n",q,x);
	printf("%d %d\n",w,y);
	printf("%d %d\n",e,z);

	return 0;
}
int main()
{
	struct student
	{
		int num;
		int chinese;
		int math;
		int sum;
	}m[4],t;
	int n,i;
	scanf("%d",&n);
	for(i=1;i<=3;i++)
		m[i].sum=-1;
	for(i=1;i<=n;i++)
	{
		scanf("%d %d %d",&t.num,&t.chinese,&t.math);
		t.sum=t.chinese+t.math;
		if(t.sum>m[1].sum)
		{
			m[3]=m[2];
			m[2]=m[1];
			m[1]=t;
		}
		else
			if(t.sum>m[2].sum)
			{
				m[3]=m[2];
				m[2]=t;
			}
			else
				if(t.sum>m[3].sum)
					m[3]=t;
	}
	for(i=1;i<=3;i++)
		printf("%d %d\n",m[i].num,m[i].sum);
}
struct a
{
	char No[20];
	int y;
	int s;
	struct a* next;
};
int n;
struct a* creat(void)
{
	struct a *p1,*p2,*head;
	int i;
	scanf("%d\n",&n);
	p1=p2=(struct a* )malloc(LEN);
	head=NULL;
	for(i=0;i<n;i++)
	{
		scanf("%s %d %d",p1->No,&p1->y,&p1->s);
		if(i==0)head=p1;
		else p2->next=p1;
		p2=p1;
		p1=(struct a* )malloc(LEN);
	}
	p2->next=NULL;
	return(head);
}

int main()
{
	struct a *head,*p1,*p2,*p;
	int i,j,k,m1,m2;
	char r[10];
	head=creat();
	for(p1=head,j=0;p1!=NULL;p1=p1->next)
	{
		k=p1->y+p1->s;
		if(k>j){p=p1;j=k;m1=p1->y;m2=p1->s;strcpy(r,p1->No);}
	}
	printf("%s %d\n",r,j);
	for(p1=head;p1!=NULL;)
	{
		p2=p1;p1=p1->next;
		if(p1==p){p2->next=p1->next;break;}
		else if(p2==p){head=p1->next;break;}
	}
	for(p1=head,j=0;p1!=NULL;p1=p1->next)
	{
		k=p1->y+p1->s;
		if(k>j){p=p1;j=k;m1=p1->y;m2=p1->s;strcpy(r,p1->No);}
	}
	printf("%s %d\n",r,j);
	for(p1=head;p1!=NULL;)
	{
		p2=p1;p1=p1->next;
		if(p1==p){p2->next=p1->next;break;}
		else if(p2==p){head=p1->next;break;}
	}
	for(p1=head,j=0;p1!=NULL;p1=p1->next)
	{
		k=p1->y+p1->s;
		if(k>j){p=p1;j=k;m1=p1->y;m2=p1->s;strcpy(r,p1->No);}
	}
	printf("%s %d",r,j);
}
struct student
{
	int ID;
	int chinese;
	int math;
	int total;
}st[4],temp;
int main()
{
	int n,cnt=3;
	cin>>n;
	for(int i=0;i<3;i++)
	{
	  cin>>st[i].ID>>st[i].chinese>>st[i].math;
	  st[i].total=st[i].chinese+st[i].math;
	}
	do{
		cin>>st[3].ID>>st[3].chinese>>st[3].math;
	    st[3].total=st[3].chinese+st[3].math;
		cnt++;
		 for(int i=1;i<4;i++)
		 {
			 for(int j=0;j<4-i;j++)
			 {
			 if(st[j+1].total>st[j].total)
			 { 
				 temp=st[j];
				 st[j]=st[j+1];
				 st[j+1]=temp;
			 }
			 }
		 }}while(cnt<n);
    for(int i=0;i<3;i++)
	{
		cout<<st[i].ID<<" "<<st[i].total<<endl;
	}
	return 0;
}
struct Student
{
long id;
int chn;
int mth;
int total;
struct Student *next;
};

struct Student * insert(struct Student *head,struct Student *stu)
{
int j=0;
struct Student *p0,*p1,*p2;
p1=head;
p0=stu;
if(head==NULL)
{head=p0;p0->next=NULL;}
else
{
while((p0->total<=p1->total)&&(p1->next!=NULL)&&j<4)
{p2=p1;p1=p1->next;j++;}
if(p0->total>p1->total)
{
if(head==p1) head=p0;
else p2->next=p0;
p0->next=p1;
}
else
{p1->next=p0;p0->next=NULL;}
}
return(head);
}

void main()
{
struct Student *p1,*head,*stu;
long int i,n;
scanf("%ld",&n);

p1=head=(struct Student*)malloc(sizeof(struct Student));
scanf("%d %d %d",&head->id,&head->chn,&head->mth);
head->total=head->chn + head->mth;
head->next=NULL;
for(i=1;i<n;i++)
{
stu=(struct Student*)malloc(sizeof(struct Student));
scanf("%d %d %d",&stu->id,&stu->chn,&stu->mth);
stu->total=stu->chn + stu->mth;
head=insert(head,stu);
}
p1=head;
for(i=0;i<3;i++)
{printf("%d %d\n",p1->id,p1->total);p1=p1->next;}
}
void main()
{
	struct student
	{
		int num,sum;
	} stu[100000];
	int n,i,j,t,chi,math;
	scanf("%d",&n);
	for (i=0;i<n;i++) 
	{
		scanf("%d %d %d",&stu[i].num,&chi,&math);
		stu[i].sum=chi+math;
	}
	for (i=0;i<3;i++)
	{
		for (j=n-1;j>i;j--)
		{
			if (stu[j].sum>stu[j-1].sum) 
			{
				t=stu[j].sum;
				stu[j].sum=stu[j-1].sum;
				stu[j-1].sum=t;
				t=stu[j].num;
				stu[j].num=stu[j-1].num;
				stu[j-1].num=t;
			}
		}
	}
	printf("%d %d\n",stu[0].num,stu[0].sum);
	printf("%d %d\n",stu[1].num,stu[1].sum);
	printf("%d %d",stu[2].num,stu[2].sum);
}
int main()
{
struct student
	{
		int num;
		int yuwen;
		int math;
		int zong;
	};
struct student stu[100000];
struct student *p,*p1,*p2,*p3,*p4;
int n;
scanf("%d",&n);
for(p=stu;p<stu+n;p++)
	{
		scanf("%d",&p->num);
		scanf("%d",&p->yuwen);
		scanf("%d",&p->math);
	}
for(p=stu;p<stu+n;p++)
	{
		(p->zong)=(p->yuwen)+(p->math);
	}
p1=&stu[0];
p2=&stu[1];
p3=&stu[2];
p4=p1;
if(p2->zong>p1->zong)
{
	p4=p1;
	p1=p2;
	p2=p4;
}
else 
p1=p1;
if(p3->zong>p1->zong)
{
	p4=p1;
	p1=p3;
	p3=p4;
}
else
p1=p1;
if(p3->zong>p2->zong)
{
p4=p2;
p2=p3;
p3=p4;
}
else
p1=p1;

for(p=stu+3;p<stu+n;p++)
{
if((p->zong)>(p1->zong))
{
	p3=p2;
	p2=p1;
	p1=p;
}
else if(p->zong>p2->zong)
{
	p3=p2;
	p2=p;
}
else if(p->zong>p3->zong)
{
p3=p;
}
else
p1=p1;
}
printf("%d %d\n",p1->num,p1->zong);
printf("%d %d\n",p2->num,p2->zong);
printf("%d %d",p3->num,p3->zong);
return 0;
}
int main()
{
	struct student
	{int num;
	 int chi;
	 int math;
	}stu[100000];

	int n,i,j,mid;

	scanf("%d",&n);

	for(i=0;i<n;i++){
		scanf("%d%d%d",&stu[i].num,&stu[i].chi,&stu[i].math);
	}
  
	for(i=0;i<3;i++){
		for(j=n-1;j>0;j--){
			if(stu[j].math+stu[j].chi>stu[j-1].chi+stu[j-1].math){
				mid=stu[j].num;
				stu[j].num=stu[j-1].num;
				stu[j-1].num=mid;

				mid=stu[j].chi;
				stu[j].chi=stu[j-1].chi;
				stu[j-1].chi=mid;

				mid=stu[j].math;
				stu[j].math=stu[j-1].math;
				stu[j-1].math=mid;
			}
		}
	}

    for(i=0;i<3;i++){
		printf("%d %d\n",stu[i].num,stu[i].math+stu[i].chi);
	}
	
	return 0;
}
int main(){
	int num;
	cin>>num;
	struct {
		int No;
		int Chinese;
		int Math;
		int Sum;  //??
	}student[100000],t;  //??????
	int i,j;
	for(i=0;i<num;i++){
		cin>>student[i].No>>student[i].Chinese>>student[i].Math;
	    student[i].Sum=student[i].Math+student[i].Chinese;
	}
	for(i=0;i<3;i++)  //????
		for(j=0;j<num-1-i;j++){
			if(student[j].Sum>=student[j+1].Sum){
				t=student[j];
				student[j]=student[j+1];
				student[j+1]=t;
			}
		}
	for(i=0;i<3;i++)
		cout<<student[num-i-1].No<<" "<<student[num-i-1].Sum<<endl;  //?????
	return 0;
}
struct student
{long num;
int yuwen;
int shuxue;
int sum;
struct student *next;
};
int n;
void main()
{
	struct student *creat(void);
	void shuchu(struct student *head);
	int i;
	struct student *head;
	scanf("%d",&n);
	head=creat();
	for(i=0;i<3;i++)
		shuchu(head);
}
struct student *creat(void)
{
	int i,k=0;
	struct student *head;
	struct student *p1,*p2;
	p1=p2=(struct student *)malloc(len);/*???????*/
	scanf("%ld%d%d",&p1->num,&p1->yuwen,&p1->shuxue);
	p1->sum=p1->shuxue+p1->yuwen;
	head=NULL;
	for(i=0;i<n;i++)
	{
		k++;
		if(k==1)
			head=p1;
		else
			p2->next=p1;
		p2=p1;
		p1=(struct student *)malloc(len);
		scanf("%ld%d%d",&p1->num,&p1->yuwen,&p1->shuxue);
		p1->sum=p1->shuxue+p1->yuwen;
	}
	p2->next=NULL;
	return(head);
}
void shuchu(struct student *head)
{
	struct student *p;
	int max,i;
	p=head;
	max=p->sum;
	for(i=0;i<n;i++)
	{
		if(p->sum>max)
			max=p->sum;
		p=p->next;
	}
		p=head;
		for(i=0;i<n;i++)
		{
			if(p->sum==max)
			{
				printf("%ld %d\n",p->num,p->sum);
				p->sum=0;
				break;
			}
			p=p->next;
		}
}
struct student
{
	int stuID;
	int yuwen;
	int shuxue;
	int zongfen;
}stu[100000];
int main()
{
	int i,n,j,x,str;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d %d %d",&stu[i].stuID,&stu[i].yuwen,&stu[i].shuxue);
		stu[i].zongfen=stu[i].yuwen+stu[i].shuxue;
	}
	for(i=0;i<3;i++)
	{
		for(j=0;j<n-1;j++)
		{
			if(stu[j].zongfen>stu[j+1].zongfen||((stu[j].zongfen==stu[j+1].zongfen)&&(stu[j].stuID<stu[j+1].stuID)))
			{
				x=stu[j].zongfen;
				stu[j].zongfen=stu[j+1].zongfen;
				stu[j+1].zongfen=x;
				str=stu[j].stuID;
				stu[j].stuID=stu[j+1].stuID;
				stu[j+1].stuID=str;
			}
		}
			printf("%d %d\n",stu[n-1-i].stuID,stu[n-1-i].zongfen);
	}
	return 0;
}
void main()
{
	int n,i,j,k=0,e=0,max,y;scanf("%d",&n);
	struct st
	{
		int a;int z;int c;
		int d;
	}b[100000];
for(i=0;i<n;i++)
{
scanf("%d%d%d",&b[i].a,&b[i].z,&b[i].c);b[i].d=b[i].z+b[i].c;
}
	for(i=0;i<n;i++)
	{
		max=0;
for(j=0;j<n;j++)
{if(b[j].d>max){max=b[j].d;y=j;}}
	printf("%d %d\n",b[y].a,b[y].d);e++;b[y].d=0;if(e==3)break;
	}

}
/*
 * 1000012826_????????.cpp
 *
 *  Created on: 2010-12-24
 *      Author: Administrator
 */

struct Student{
	int num;
	int mscore;
	int cscore;
	int total;
}stu[100001];
int main(){
	int n,i,m=0,b[201][100]={0},a[201][100]={0},j=200,count=3,k=0,c[201]={0};
	cin>>n;
	for(i=0;i<n;i++){
		cin>>stu[i].num;
	    cin>>stu[i].mscore;
	    cin>>stu[i].cscore;
	    stu[i].total=stu[i].mscore+stu[i].cscore;
	    }
	do{
		b[stu[m].total][c[stu[m].total]]=stu[m].total;//??????? ,c?stu[m].total????????
		a[stu[m].total][c[stu[m].total]]=stu[m].num;//?????????
		if(c[stu[m].total]<4)c[stu[m].total]++;//???????
		m++;
	}while(m<n);
		for(j=200;j>=0;j--){
			for(k=0;k<100&&count>0;k++){
				if(b[j][k]!=0){
					cout<<a[j][k]<<" "<<b[j][k]<<endl;
					count--;}//??????
			}
		}
}
struct score
{int num;
 int yuwen;
 int shuxue;
 int total;
 struct score*next;
};
int n;

struct score*creat()
{struct score*p1,*p2,*head;
 head=p2=(struct score*)malloc(len);
 scanf("%d%d%d",&p2->num,&p2->yuwen,&p2->shuxue);
 p2->total=p2->shuxue+p2->yuwen;
 n--;
 while(n--)
	{p1=(struct score*)malloc(len);
     scanf("%d%d%d",&p1->num,&p1->yuwen,&p1->shuxue);
     p1->total=p1->shuxue+p1->yuwen;
	 p2->next=p1;
	 p2=p1;
	}
 p2->next=NULL;
 return head;
}

void search(struct score*head)
{struct score*p;int i,max;
 for(i=0;i<3;i++)
	{max=0; 
	 p=head;
	  while(p!=NULL)
		{
		if(p->total>max)max=p->total;
		p=p->next;
		}
     p=head;
	 while(p!=NULL)
	 {if(p->total==max)
		{printf("%d %d\n",p->num,p->total);
		 p->total=0;
		 break;
		}
	     p=p->next;	 
	 }
	}
}

main()
{scanf("%d",&n);
 struct score*head;
 head=creat();
search(head);
}
struct student{
		int xuehao;
		int yuwen;
		int shuxue;
		int mark;
		struct student *next;
};
int n;
struct student *creat(int max)
{
	struct student *head;
	struct student *p1,*p2;
	n=0;
	p1=p2=(struct student *)malloc(LEN);
	scanf("%d %d %d",&p1->xuehao,&p1->yuwen,&p1->shuxue);
	head=p1;
	while(n<max-1)
	{
		n++;
		if(n!=1)p2->next=p1;
		p2=p1;
		p1=(struct student *)malloc(LEN);
		scanf("%d %d %d",&p1->xuehao,&p1->yuwen,&p1->shuxue);

	}
	p2->next=p1;
	p1->next=0;
	return head;
}
void main()
{
	int max,i;
	struct student *table;
	scanf("%d",&max);
	table=creat(max);
	for(i=0;i<3;i++)
	{
		int mmax=0;
		int mark=0;
		struct student *p;
		p=table;
		
		do{
		if(p->shuxue+p->yuwen>mmax&&p->mark!=-1){mark++;p->mark=mark;mmax=p->shuxue+p->yuwen;}
		p=p->next;
		}while(p!=0);
		p=table;
		do{
			if(p->mark==mark){
				printf("%d %d\n",p->xuehao,p->shuxue+p->yuwen);
			p->mark=-1;}
					p=p->next;
		}while(p!=0);

	}
}
int main(int argc, char* argv[])
{
	int n,a[99999],b[2],i,k,m,s[99999],first=0,x,y;
	scanf ("%d",&n);
	for (i=0;i<n;i++)
	{
		scanf ("%d",&a[i]);
		for (k=0;k<2;k++)
		{
			scanf("%d",&b[k]);
		}
		s[i]=b[0]+b[1];						
	}
	
	for (m=0;m<3;m++)
	{ first=0;
		for (x=0;x<n;x++)
		{
			   
		       if (s[x]>first)
			   {first=s[x];
			   y=x+1;
			   }
			   

		}
		printf ("%d %d\n",y,first);
	    s[y-1]=0;

	}
	return 0;
}
int main()
{
   struct gpa
    {
     int num;
     int math;
     int chin;
     int total;           
    } 
    STUDENT_NUM[100000], first,second,third;
  
  int num,math,chin;
  long n,i;
  scanf("%d",&n);
  for(i=1;i<=n;i++)
  {
    scanf("%d",&num);
    scanf("%d",&math);                                 
    scanf("%d",&chin);
    STUDENT_NUM[i].num=num;
    STUDENT_NUM[i].math=math;
    STUDENT_NUM[i].chin=chin;
    STUDENT_NUM[i].total=math+chin;                                 
  }
   
    first.num=0;
    first.total=0;
    second.num=0;
    second.total=0;
    third.num=0;
    third.total=0;
    
   
    for(i=1;i<=n;i++)
    {
           if(STUDENT_NUM[i].total>first.total)
           {
           first.num=STUDENT_NUM[i].num;
           first.total=STUDENT_NUM[i].total;                       
           }                           
    }
    
          for(i=1;i<=n;i++)
            {
               if(STUDENT_NUM[i].num==first.num)
               {STUDENT_NUM[i].total=0;}              
            }
    for(i=1;i<=n;i++)
    {
        if(STUDENT_NUM[i].total>second.total)
        {
           second.num=STUDENT_NUM[i].num;
           second.total=STUDENT_NUM[i].total;                                                  
        }             
    }
               
            for(i=1;i<=n;i++)
            {
                if (STUDENT_NUM[i].num==second.num)
                {STUDENT_NUM[i].total=0;}             
            }
    for(i=1;i<=n;i++)
    {
       if(STUDENT_NUM[i].total>third.total)
       {
           third.num=STUDENT_NUM[i].num;
           third.total=STUDENT_NUM[i].total;                                                                      
       }              
    }
    
    
   printf("%d %d\n",first.num,first.total);
   printf("%d %d\n",second.num,second.total);
   printf("%d %d\n",third.num,third.total);
    getchar();
    getchar();
    getchar();
    getchar();        
}
struct student
{
	int id;
	int cs;
	int ms;
	int s;
	struct student *next;
};
void main()
{
	int n,i,m=0;
	scanf("%d",&n);
	struct student *head,*p1,*p2;
	p1=p2=(struct student *)malloc(LEN);
	scanf("%d %d %d",&p1->id,&p1->cs,&p1->ms);
	p1->s=p1->cs+p1->ms;
	head=NULL;
	while(p1->id!=n)
	{
		m=m+1;
		if(m==1) head=p1;
		else
		p2->next=p1;
		p2=p1;
		p1=(struct student *)malloc(LEN);
		scanf("%d %d %d",&p1->id,&p1->cs,&p1->ms);
		p1->s=p1->cs+p1->ms;
	}
p2->next=p1;
p2=p1;
	p2->next=NULL;
	for(i=0;i<3;i++)
	{
		p1=p2=head;
		do
		{
			p2=p2->next;
			if(p1->s<p2->s)
				p1=p2;
		}while(p2->next!=NULL);
		printf("%d %d\n",p1->id,p1->s);
		p1->s=-1;
	}
}
struct student
	{
	int xuehao;
	int shuxue;
	int yuwen;
	int zongfen;
	};


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

    struct student stu[100001];
	for(i=0;i<n;i++)
	{
		scanf("%d %d %d", &stu[i].xuehao,&stu[i].shuxue,&stu[i].yuwen);
		stu[i].zongfen=stu[i].shuxue+stu[i].yuwen;
	}
	for(i=1;i<4;i++)
	{
		for(j=0;j<n-i;j++)
		{
			if(stu[j].zongfen>=stu[j+1].zongfen)
			{
				stu[100000]=stu[j+1];
				stu[j+1]=stu[j];
				stu[j]=stu[100000];
			}
		}
	}
	for(i=n-1;i>n-4;i--)
	{
       printf("%d %d\n", stu[i].xuehao,stu[i].zongfen);
	}


	




	return 0;
}
struct Student
{int ID;
int chi;
int math;
int total;
};
int main()
{
struct Student stu[100000];
struct Student temp;
int i,n,j,m;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d %d %d",&stu[i].ID,&stu[i].chi,&stu[i].math);
stu[i].total=stu[i].chi+stu[i].math;
}
for(j=1;j<4;j++){
 for(m=0;m<n-j;m++){
  if(stu[m].total>=stu[m+1].total){
  temp=stu[m];
  stu[m]=stu[m+1];
  stu[m+1]=temp;
  }
 }
       }
for(i=n-1;i>n-4;i--)
printf("%d %d\n",stu[i].ID,stu[i].total);
return 0;
}
int main()
{
   struct a
   {
   	int h;
   	int y;
   	int s;
   }b[100000],e;
   int c[100000];
   int n,i,f,j,d;
   scanf("%d",&n);
   for(i=0;i<n;i++)
   {
   	scanf("%d%d%d",&b[i].h,&b[i].y,&b[i].s);
   }
   for(i=0;i<n;i++)
   {
   	c[i]=b[i].y+b[i].s;
   }
   for(j=0;j<3;j++)
   {
   	for(i=j+1;i<n;i++)
   	{
   		if(c[i]>c[j])
   		{
   			d=c[j];
   			c[j]=c[i];
   			c[i]=d;
   			e=b[j];
   			b[j]=b[i];
   			b[i]=e;
   			
   		}
   	}
   	f=b[j].h;
   	printf("%d %d\n",f,c[j]);
   }
  
return 0;
}
/*
 * jiegou1.cpp
 *
 *  Created on: 2010-12-24
 *      Author: l
 */

struct student {
	int No;
	int china;
	int math;
};//????student
int main(){
	int n;
	cin>>n;
	struct student st[n];//??n????????st?n???????
	int i;
	for(i=0;i<n;i++)
		cin>>st[i].No>>st[i].china>>st[i].math;

	int s;
	int a1=0,a2=0,a3=0,b1=0,b2=0,b3=0;//???????????????
	for(i=0;i<n;i++)
	{
		s=st[i].china+st[i].math;
	if(s>a1)
	{

		a3=a2;
		b3=b2;
		a2=a1;
		b2=b1;
		a1=s;
		b1=i;
		continue;//??????????????
	}

	if(s>a2)
		{
			
			a3=a2;
			b3=b2;
			a2=s;
						b2=i;
			continue;
			
		}//??????????????
	if(s>a3)
		{
			a3=s;
			b3=i;
			continue;
		}//?????????????
	}
	cout<<st[b1].No<<" "<<a1<<endl;
	cout<<st[b2].No<<" "<<a2<<endl;
	cout<<st[b3].No<<" "<<a3<<endl;//????
	return 0;
}
struct student
{
	int num;
	float chinese;
	float math;
	float sum;
};
void main()
{
     int n,i;
	 struct student *pt,*p,temp;
	 scanf("%d",&n);
     pt=(struct student *)malloc(n*LEN);
     for(p=pt;p<pt+n;p++)
	 {
		 scanf("%d%f%f",&p->num,&p->chinese,&p->math);
		 p->sum=p->chinese+p->math;
	 }

	 for(i=0;i<3;i++)
	 {
		 for(p=pt;p<pt+n-1-i;p++)
		 {
			 if(p->sum>=(p+1)->sum)
			 {temp=*p;*p=*(p+1);*(p+1)=temp;}
		 }
	 }
	 for(p=pt+n-1;p>pt+n-4;p--)
	 {
		 printf("%d %g\n",p->num,p->sum);
	 }
}
struct s{
	int num;
	int x;
	int y;
	int z;
}s[100000],s1,s2,s3,A;
int main(int argc, char* argv[])
{
	int n;
	scanf("%d",&n);
	int i;
	for(i=0;i<n;i++)
	{
		scanf("%d %d %d",&s[i].num,&s[i].x,&s[i].y);
		s[i].z=s[i].x+s[i].y;
	}
	if(s[0].z>=s[1].z)
	{
		s1=s[0];
		s2=s[1];
	}
	else
	{
		s1=s[1];
		s2=s[0];
	}
	if(s[2].z>=s1.z)
	{
		A=s1;
		s1=s[2];
		s3=s2;
		s2=A;
	}
	else if(s[2].z<s2.z)
	{
		s3=s[2];
	}
	else if(s[2].z>=s2.z&&s[2].z<s1.z)
	{
		s3=s2;
		s2=s[2];
	}
	for(i=3;i<n;i++)
	{
		if(s[i].z>s1.z)
		{
			s3=s2;
			s2=s1;
			s1=s[i];
		}
		else if(s[i].z<s3.z)
		{
			;
		}
		else if(s[i].z<s1.z&&s[i].z>s3.z)
		{
			if(s[i].z>s2.z)
			{
				s3=s2;
				s2=s[i];
			}
			else
			{
				s3=s[i];
			}
		}
		else if (s[i].z==s1.z)
		{
			s3=s2;
			s2=s[i];
		}
		else if(s[i].z==s2.z)
		{
			s3=s[i];
		}
	}
	printf("%d %d\n",s1.num,s1.z);
	printf("%d %d\n",s2.num,s2.z);
	printf("%d %d\n",s3.num,s3.z);
	return 0;
}
int main()
{
	struct student
	{
		int num;
		int math;
		int chinese;
		int sum;
	}a[100000];
	int n,i,j,temp;
	char c[10];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d %d %d",&a[i].num,&a[i].math,&a[i].chinese);
		a[i].sum=a[i].math+a[i].chinese;
	}
	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;
}