semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
main()
{
      int n;
      int i,j,k,s,p;
      struct student
      {int id;
      int yuwen;
      int shuxue;
      int zongfen;
      };
      struct student stu[100000];
      struct student temp;
      scanf("%d",&n);
      for(p=0;p<n;p++)
      {
          scanf("%d %d %d",&stu[p].id,&stu[p].yuwen,&stu[p].shuxue);
          stu[p].zongfen=stu[p].yuwen+stu[p].shuxue;
      }
      for(j=0;j<3;j++)
      {
          for(i=0;i<n-1-j;i++)
          {
              if(stu[i].zongfen>=stu[i+1].zongfen)
              {
                  temp.id=stu[i].id;
                  temp.yuwen=stu[i].yuwen;
                  temp.shuxue=stu[i].shuxue;
                  temp.zongfen=stu[i].zongfen;
                  stu[i].id=stu[i+1].id;
                  stu[i].yuwen=stu[i+1].yuwen;
                  stu[i].shuxue=stu[i+1].shuxue;
                  stu[i].zongfen=stu[i+1].zongfen;
                  stu[i+1].id=temp.id;
                  stu[i+1].yuwen=temp.yuwen;
                  stu[i+1].shuxue=temp.shuxue;
                  stu[i+1].zongfen=temp.zongfen;
              }
          }
      }
      for(k=n-1;k>n-4;k--)
      {
          printf("%d %d\n",stu[k].id,stu[k].zongfen);
      }
}
struct Student{
		int no;
		int chinese;
		int math;
		int total;
	};
int main()
{
	struct Student stu[100000],t;
	int n,i,j,max,order;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d%d%d",&stu[i].no,&stu[i].chinese,&stu[i].math);
		stu[i].total=stu[i].chinese+stu[i].math;
	}
	for(i=0;i<3;i++){
		max=stu[i].total;
		order=i;
		for(j=i+1;j<n;j++){
			if(stu[j].total>max){
				max=stu[j].total;
				order=j;
			}
		}
		if(order!=i){
			t=stu[i];stu[i]=stu[order];stu[order]=t;
		}
		printf("%d %d\n",stu[i].no,stu[i].total);
	}
	return 0;
}
int main()
{
	int n,i,j,b,c;
	struct student
	{
		int id;
		int score;
	}stu[100000],t;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>stu[i].id>>b>>c;		
		stu[i].score=b+c;
	}
	for(i=0;i<3;i++)
	{
		for(j=n-1;j>i;j--)
		{
			if(stu[j].score>stu[j-1].score)
			{
				t=stu[j];
				stu[j]=stu[j-1];
				stu[j-1]=t;
			}
		}
	}
	for(i=0;i<3;i++)
	{
		cout<<stu[i].id<<' '<<stu[i].score<<endl;
	}
	return 0;
}
struct student
{
	int num ;
	int chinese ;
	int math ;
	int sum ;	
}s[100001] , first , second , third ; //??????? ?? ?? ?? 

int main()
{
	int n , i , temp1 , temp2 ;
	cin >> n ;
	for (i = 0 ; i < n ; i++)
	{
		cin >> s[i].num >> s[i].chinese >> s[i].math ;
		s[i].sum = s[i].chinese + s[i].math ;   //??=????? 
	}
	first.sum = 0 , second.sum = 0 , third.sum = 0 ; //???????
	for (i = 0 ; i < n ; i++)
	{
		if (first.sum < s[i].sum)
		{
			first = s[i] ;
			temp1 = i ;     //????????? 
		}	
	}
	for (i = 0 ; i < n ; i++)
	{
		if (second.sum < s[i].sum && s[i].num != s[temp1].num) //???????????????????????????? 
		{	
			second = s[i];
			temp2 = i ;
		}	
	}
	for (i = 0 ; i < n ; i++)
		if (third.sum < s[i].sum && s[i].num != s[temp1].num && s[i].num != s[temp2].num)  //????? 
			third = s[i];
	cout << first.num << " " << first.sum << endl ;
	cout << second.num << " " << second.sum << endl ;
	cout << third.num << " " << third.sum << endl ;
	return 0 ;	
}
struct student
	{
	int count;
	int yu;
	int shu;
	}stu[1000000];
void main()
{   
	int n,i,*p,max=0,sm=0,tm=0,j=0;
    p=(int *)malloc(1000000*sizeof(int));
    scanf("%d",&n);
    for(i=0;i<n;i++)
	{
		scanf("%d %d %d",&stu[i].count,&stu[i].yu,&stu[i].shu);
		*(p+i)=stu[i].yu+stu[i].shu;
	}
	    for(i=0;i<n;i++)
		max=(max>*(p+i))?max:(*(p+i));
		for(i=0;i<n;i++)
		{if((*(p+i)<max)&&(*(p+i)>sm))
		sm=*(p+i);}
		for(i=0;i<n;i++)
		{if((*(p+i)>tm)&&(*(p+i)<sm))
		tm=*(p+i);}

    for(i=0;j<3,i<n;i++)
	{
    if(*(p+i)==max)
	{
		printf("%d %d\n",stu[i].count,max);
    j++;
	}
	}

	for(i=0;j<3,i<n;i++)
	{if(*(p+i)==sm&&j<3)
	{
		printf("%d %d\n",stu[i].count,sm);
	    j++;
	}
	}
	for(i=0;j<3,i<n;i++)
	{
	        if(*(p+i)==tm&&j<3) 
			{
				printf("%d %d\n",stu[i].count,tm);
			j++;
			}
	}
}
struct student
{
	int num;
	int chn;
	int math;
	int score;
} stu[100000];

main()
{
	int n,i,a,b,c;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d %d",&stu[i].num,&stu[i].chn,&stu[i].math);
		stu[i].score=stu[i].chn+stu[i].math;
	}

	if(stu[0].score>=stu[1].score){
		if(stu[1].score>=stu[2].score){
			a=0;
			b=1;
			c=2;
		}
		else if(stu[0].score>=stu[2].score){
			a=0;
			b=2;
			c=1;
		}
		else{
			a=2;
			b=0;
			c=1;
		}
	}
	else{
		if(stu[0].score>=stu[2].score){
			a=1;
			b=0;
			c=2;
		}
		else if(stu[1].score>=stu[2].score){
			a=1;
			b=2;
			c=0;
		}
		else{
			a=2;
			b=1;
			c=0;
		}
	}
	for(i=3;i<n;i++){
		if(stu[i].score>stu[a].score){
			c=b;
			b=a;
			a=i;
		}
		else if(stu[i].score>stu[b].score){
			c=b;
			b=i;
		}
		else if(stu[i].score>stu[c].score){
			c=i;
		}
	}

	printf("%d %d\n%d %d\n%d %d\n",stu[a].num,stu[a].score,stu[b].num,stu[b].score,stu[c].num,stu[c].score);
}
struct Student
{
	int num;
	int chinese;
	int math;
	int score;
};
int main()
{
	int n;
	int i,k,j;
	struct Student student[100000];
	struct Student temp;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&student[i].num);
		scanf("%d",&student[i].chinese);
		scanf("%d",&student[i].math);
		student[i].score=student[i].chinese+student[i].math;
	}
	for(i=0;i<3;i++)
	{
		k=i;
		for(j=i+1;j<n;j++)
		{
			if(student[j].score>student[k].score) k=j;
		}
		if(k!=i)
		{
			temp=student[i];
			student[i]=student[k];
			student[k]=temp;
		}
	}
	for(i=0;i<3;i++)
	{
		printf("%d %d\n",student[i].num,student[i].score);
	}
	return 0;
}
void main()
{   int m1,m2,m3,n1,n2,n3;
	struct student{int num;int verbal;int math;int sum;};
	struct student stu[100000];
	struct student *p;
		p=stu;

	int i,n;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	scanf("%d %d %d",&(p+i)->num,&(p+i)->verbal,&(p+i)->math);
	for(i=0;i<n;i++)
    (p+i)->sum=(p+i)->verbal+(p+i)->math;
	m1=p->sum;n1=0;
	for(i=0;i<n;i++)
		if(((p+i)->sum)>m1)
		{m1=(p+i)->sum;
		n1=i;}
		printf("%d %d\n",(p+n1)->num,(p+n1)->sum);
    m2=p->sum;n2=0;
	for(i=0;i<n;i++)
	if(((p+i)->sum)>m2&&i!=n1)
		{m2=(p+i)->sum;
		n2=i;}
		printf("%d %d\n",(p+n2)->num,(p+n2)->sum);
	
	m3=p->sum;n3=0;
	for(i=0;i<n;i++)
		if((((p+i)->sum)>m3)&&i!=n1&&i!=n2)
		{m3=(p+i)->sum;
		n3=i;}
		printf("%d %d\n",(p+n3)->num,(p+n3)->sum);
	

}
int x[100000],y[100000],z[100000],s[100000],b[100000];
int main(int argc, char* argv[])
{
	int n;
	scanf("%d",&n);
	int i,j,t,m1,m2;
	for(i=1;i<=n;i++)
	{
		scanf("%d%d%d",&x[i],&y[i],&z[i]);
		s[i]=y[i]+z[i];
		b[i]=s[i];
	}
    for(i=1;i<4;i++)
	{
		for(j=i+1;j<=n;j++)
		{
			if(s[i]<s[j])
			{
				t=s[i];
                s[i]=s[j];
                s[j]=t;
			}
		}
	}
	for(i=1;i<=n;i++)
	{
		if(s[1]==b[i])
		{
			m1=i;
			printf("%d %d\n",x[i],b[i]);
			break;
		}
	}
	for(i=1;i<=n;i++)
	{
		if(s[2]==b[i]&&i!=m1)
		{
			m2=i;
			printf("%d %d\n",x[i],b[i]);
			break;
		}
	}
	for(i=1;i<=n;i++)
	{
		if(s[3]==b[i]&&i!=m1&&i!=m2)
		{
			printf("%d %d\n",x[i],b[i]);
			break;
		}
	}
	return 0;
}
int main()
{
    struct score
    {
           int ID;
           int c;
           int m;
           };
           int n,k,t,r;
           int j;
           scanf("%d",&n);
           int sum[100000];
           struct score s[100000];
           for(int i=1;i<=n;i++)
           {
                        scanf("%d %d %d",&s[i].ID,&s[i].c,&s[i].m);
                        sum[i]=s[i].c+s[i].m;
                        }
                        for(j=1;j<=3;j++)
                        {
                                         for(k=j;k<=n;k++)
                                         {
                                                            if(sum[k]>sum[j])
                                                            {            t=sum[j];         
                                                                         sum[j]=sum[k];
                                                                         sum[k]=t;
                                                                         r=s[j].ID;
                                                                         s[j].ID=s[k].ID;
                                                                         s[k].ID=r;
                                                                         }
                                                                         }
                                                                         }
                                                                         for(int u=1;u<=3;u++)
                                                                         {
                                                                                 printf("%d %d\n",s[u].ID,sum[u]);
                                                                                 }
                                                                                 getchar();
                                                                                 getchar();
                                                                                 }
struct student
{
	int id;
	int chinese;
	int math;
	int total;
};
int main()
{
	struct student stu[100000];
	struct student max[3]={0,0,0,0,0,0,0,0,0,0,0,0};
	int n,i;
	scanf("%d",&n);
	for (i=0;i<n;i++)
	{
		scanf("%d %d %d\n",&stu[i].id,&stu[i].chinese,&stu[i].math);
		stu[i].total = stu[i].chinese + stu[i].math;
	}
	for (i=0;i<n;i++)
	{
		if (stu[i].total > max[1].total)
		{
			max[1]=stu[i];
		}
	}
	for (i=0;i<n;i++)
	{
		if (stu[i].total > max[2].total && stu[i].total <= max[1].total && stu[i].id!=max[1].id)
		{
			max[2]=stu[i];
		}
	}
	for (i=0;i<n;i++)
	{
		if (stu[i].total > max[3].total && stu[i].total <= max[2].total && stu[i].id!=max[2].id && stu[i].id!=max[1].id)
		{
			max[3]=stu[i];
		}
	}
	for (i=1;i<4;i++)
	{
		printf("%d %d\n",max[i].id,max[i].total);
	}
	return 0;
}
int main()
{
	int n,i,k,a[100000][3],c[100000][3];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	 scanf("%d%d%d",&a[i][1],&a[i][2],&a[i][3]);
	for(i=n-2;i>=0;i--) 
	{ if(a[i][2]+a[i][3]<a[i+1][2]+a[i+1][3]) 
	  {c[i][1]=a[i][1];c[i][2]=a[i][2];c[i][3]=a[i][3]; 
       a[i][1]=a[i+1][1];a[i][2]=a[i+1][2];a[i][3]=a[i+1][3]; 
       a[i+1][1]=c[i][1];a[i+1][2]=c[i][2];a[i+1][3]=c[i][3];
	  } 		  
	}
	for(i=n-2;i>=1;i--) 
	{ if(a[i][2]+a[i][3]<a[i+1][2]+a[i+1][3]) 
	  {c[i][1]=a[i][1];c[i][2]=a[i][2];c[i][3]=a[i][3]; 
       a[i][1]=a[i+1][1];a[i][2]=a[i+1][2];a[i][3]=a[i+1][3]; 
       a[i+1][1]=c[i][1];a[i+1][2]=c[i][2];a[i+1][3]=c[i][3];
	  } 		  
	}
	for(i=n-2;i>=2;i--) 
	{ if(a[i][2]+a[i][3]<a[i+1][2]+a[i+1][3]) 
	  {c[i][1]=a[i][1];c[i][2]=a[i][2];c[i][3]=a[i][3]; 
       a[i][1]=a[i+1][1];a[i][2]=a[i+1][2];a[i][3]=a[i+1][3]; 
       a[i+1][1]=c[i][1];a[i+1][2]=c[i][2];a[i+1][3]=c[i][3];
	  } 		  
	}
	for(k=0;k<3;k++)
	   printf("%d %d\n",a[k][1],a[k][2]+a[k][3]);
	return 0;
}
void main()
{
struct student 
{
int a;int math;int chi;int sum;struct student*next;
};
int n,i;int max;
struct student *p1,*p2,*head;
scanf("%d",&n);
head=NULL;
for(i=0;i<n;i++)
    {
       if(i==0) head=p1=(struct student*)malloc(LEN);
       else       { 
                   p1->next=(struct student*)malloc(LEN);p1=p1->next;
                    }
     scanf("%d%d%d",&p1->a,&p1->math,&p1->chi);
    p1->sum=(p1->math)+(p1->chi);
    }
p1->next=NULL;
for(i=0;i<3;i++)
{
p1=head;max=p1->sum;
do
{p1=p1->next;
if(p1->sum>max) {max=p1->sum;p2=p1;}
}while(p1->next!=NULL);
printf("%d %d\n",p2->a,p2->sum);
p2->sum=0;
}
}
int main()
{
	int n,i,k;
	int a[99999][3],s[99999];
	int fir=0,sec=0,thi=0;
    int c=0,d=0,e=0;

	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		for(k=0;k<3;k++)
		{
			scanf("%d",&a[i][k]);
		}
			s[i]=a[i][1]+a[i][2];
	}

	          for(i=0;i<n;i++)
			  {
		            if(s[i]>fir)
					{
						thi=sec;
						sec=fir;
						fir=s[i];
						e=d;
						d=c;
						c=i;
					continue;
					}
				    if(s[i]>sec && s[i]<=fir)
					{
						thi=sec;
					
						sec=s[i];
				        e=d;
					    d=i;
						continue;
					}
				   if(s[i]>thi && s[i]<=sec)
					{
						thi=s[i];
						e=i;
					
					}
				 
			  }
		
	printf("%d %d\n",a[c][0],fir);
	printf("%d %d\n",a[d][0],sec);
	printf("%d %d\n",a[e][0],thi);
	return 0;
}
int main (int argc, char *argv[])
{ 
 int n;
 scanf("%d",&n);
 struct
 { int id;int yuwen;int shuxue;}stu[1000001];
 int grade[100000];
 int i,a,b;
 int m1=0,m2=0,m3=0;
 int m1id,m2id,m3id;
 for(i=0;i<n;i++)
 {
	 scanf("%d",&stu[i].id);
	 scanf("%d",&stu[i].yuwen);
	 scanf("%d",&stu[i].shuxue);
	 grade[i]=stu[i].yuwen+stu[i].shuxue;
 }
 for(i=0;i<n;i++)
 { if(grade[i]>m1)
 {m1=grade[i];
    a=i;
    m1id=stu[i].id;}
 }
 printf("%d ",m1id);
 printf("%d\n",m1);
 
 for(i=0;i<n;i++)
 { if((grade[i]>m2)&&(i!=a))
 {m2=grade[i];
    b=i;
    m2id=stu[i].id;}
	}
 printf("%d ",m2id);
 printf("%d\n",m2);
 for(i=0;i<n;i++)
 { if((grade[i]>m3)&&(i!=a)&&(i!=b))
 { m3=grade[i];
   m3id=stu[i].id;
 }
 }
 printf("%d ",m3id);
 printf("%d\n",m3);
 return 0;
}
struct Student
{	int num;
	int ch;
	int math;
	int sum;
};
int main()
{
	struct Student stu[4],temp;
	int i,j,k,n;
	scanf("%d",&n);
	for(i=0;i<3;i++)
	{
		scanf("%d %d %d",&stu[i].num,&stu[i].ch,&stu[i].math);
	    stu[i].sum=stu[i].ch+stu[i].math;
	}
	for(i=0;i<2;i++)
	{
		k=i;
		for(j=i+1;j<3;j++)
			if(stu[j].sum>stu[i].sum)
			{k=j;
			temp=stu[k];
			stu[j]=stu[i];
			stu[i]=temp;}
	}
      //  for(i=0;i<3;i++)
		//  printf("%d %d\n",stu[i].num,stu[i].sum);
	for(i=3;i<n;i++)
	{
		scanf("%d %d %d",&stu[3].num,&stu[3].ch,&stu[3].math);
	    stu[3].sum=stu[3].ch+stu[3].math;
		if(stu[3].sum>stu[0].sum)
		{
			stu[2]=stu[1];
			stu[1]=stu[0];
			stu[0]=stu[3];
		}
		else if(stu[3].sum>stu[1].sum)
		{
			stu[2]=stu[1];
			stu[1]=stu[3];
		}
		else if(stu[3].sum>stu[2].sum)
			stu[2]=stu[3];
	}
	for(i=0;i<3;i++)
		printf("%d %d\n",stu[i].num,stu[i].sum);
    return 0;
}
struct stu
{
	int a;
	int b;
	int c;
	int d;
	struct stu *next;
};
int n;
struct stu *creat(void)
{
	struct stu *head,*p1,*p2;
	int i=1;
	head=NULL;
	p2=p1=(struct stu *)malloc(LEN);
	scanf("%d%d%d",&p1->a,&p1->b,&p1->c);
	p1->d=p1->b+p1->c;
	while(1)
	{
		if(i==1)
			head=p1;
		else
			p2->next=p1;
		p2=p1;
		if(i>=n) break;
		p1=(struct stu *)malloc(LEN);
		scanf("%d%d%d",&p1->a,&p1->b,&p1->c);
		p1->d=p1->b+p1->c;
		i++;
	}
	p2->next=NULL;
	return(head);
}
void main()
{
	struct stu *z,*p3,*p[100007],*q;
	int i=0,j,m;
	scanf("%d",&n);
	z=creat();
	p3=p[i]=z;
	while(p3!=NULL)
	{
		i++;
		p[i]=p3->next;
		p3=p[i];
	}
	m=i;
	q=p[0];
	for(i=0;i<4;i++)
	{
		for(j=0;j<m-1-i;j++)
		{
			if(p[j]->d>=p[j+1]->d)
			{
				q=p[j];
				p[j]=p[j+1];
				p[j+1]=q;
			}
		}
	}
	for(i=1;i<4;i++)
	{
	printf("%d %d\n",p[m-i]->a,p[m-i]->d);
	}
}
struct student
{
	int num;
	int all;
}person[99999];
int main()
{
	int n,i,j,k,x,y;;
	struct student temp1,temp2;
	scanf("%d",&n);
	for(i=2;i>=0;i--)
	{
		scanf("%d %d %d",&person[i].num,&x,&y);
		person[i].all=x+y;
	}
	for(i=3;i<=n-1;i++)
	{
		scanf("%d %d %d",&person[i].num,&x,&y);
		person[i].all=x+y;
		k=person[i].all;
		if(k>person[0].all) {temp1=person[0]; temp2=person[1];  person[0]=person[i];person[1]=temp1;person[2]=temp2; continue;}
		if(k<=person[0].all&&k>person[1].all) {temp1=person[1];person[1]=person[i];person[2]=temp1;  continue;}
		if(k<=person[1].all&&k>person[2].all) {person[2]=person[i]; continue;}
		if(k<person[2].all) {continue;}
	}
	printf("%d %d\n",person[0].num,person[0].all);
	printf("%d %d\n",person[1].num,person[1].all);
	printf("%d %d",person[2].num,person[2].all);
	return 0;
}
struct student
{
	int a;
	int b;
	int c;
	struct student *next;
};
void main()
{
	int n=0,i,j,k;
	scanf("%d",&k);
	struct student *head,*p1,*p2;
	p1=p2=(struct student *)malloc(L);
	scanf("%d %d %d",&p1->a,&p1->b,&p1->c);
	head=NULL;
	for(i=0;i<k-1;i++)
	{
		n=n+1;
		if(n==1)head=p1;
		else p2->next=p1;
		p2=p1;
		p1=(struct student *)malloc(L);
		scanf("%d %d %d",&p1->a,&p1->b,&p1->c);
	}
	p2->next=p1;
	p2=p1;
	p2->next=NULL;
	struct student *g;
	int x[100000],y[100000];
	g=head;
	for(i=0;i<k;i++)
	{
		x[i]=g->a;
		y[i]=g->b+g->c;
		g=g->next;
	}
	int m[4]={0},t,r=1,z=0;
	m[0]=201;
	for(i=0;i<3;i++)
	{
		for(j=0;j<k;j++)
		{
			if(m[r]<y[j]&&y[j]<m[r-1])
				m[r]=y[j];
		}
		r++;
	}
	for(i=0;i<k;i++)
	{
		if(z==3)break;
		if(y[i]==m[1])
		{
			printf("%d %d\n",x[i],y[i]);
			z++;
		}
	}
	for(i=0;i<k;i++)
	{
		if(z==3)break;
		if(y[i]==m[2])
		{
			printf("%d %d\n",x[i],y[i]);
			z++;
		}
	}
	for(i=0;i<k;i++)
	{
		if(z==3)break;
		if(y[i]==m[3])
		{
			printf("%d %d",x[i],y[i]);
			z++;
		}
	}
}
struct stu
{
	int num,yu,shu,sum;
} ;
void main()
{
	int n,i;
	struct stu a[4];
	scanf("%d",&n);
	for (i=0;i<n;i++)
	{
		scanf("%d%d%d",&a[0].num,&a[0].yu,&a[0].shu);
		a[0].sum=a[0].yu+a[0].shu;
		if (a[0].sum>a[1].sum)
		{
			a[3].sum=a[2].sum;
			a[3].num=a[2].num;
			a[2].sum=a[1].sum;
			a[2].num=a[1].num;
			a[1].sum=a[0].sum;
			a[1].num=a[0].num;
		}else
			if (a[0].sum>a[2].sum)
			{
				a[3].sum=a[2].sum;
			    a[3].num=a[2].num;
			    a[2].sum=a[0].sum;
			    a[2].num=a[0].num;
			}
			else if (a[0].sum>a[3].sum)
			{
				a[3].sum=a[0].sum;
			    a[3].num=a[0].num;
			}
	}
	for (i=1;i<=3;i++)
		printf("%d %d\n",a[i].num,a[i].sum);
}
struct stu
{
       int id;
       int shu;
       int yu;
       int he;
};
struct stu stu[100000];
int main()
{
    int n,i,max,sec,th;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
     scanf("%d%d%d",&stu[i].id,&stu[i].shu,&stu[i].yu);
     stu[i].he=stu[i].shu+stu[i].yu;
     }
     max=1;
     for(i=1;i<n;i++)
     {
       if(stu[max].he<stu[i+1].he)
       max=i+1;
       }
       printf("%d %d\n",stu[max].id,stu[max].he);
        stu[max].he=0;
        sec=1;
     for(i=1;i<n;i++)
      {  
         if(stu[sec].he<stu[i+1].he)
         sec=i+1;
         }
          printf("%d %d\n",stu[sec].id,stu[sec].he);
         stu[sec].he=0;
         th=1;
         for(i=1;i<n;i++)
         {
           if(stu[th].he<stu[i+1].he)
           th=i+1;
           }
           printf("%d %d\n",stu[th].id,stu[th].he);
           getchar();
           getchar();
}
int main(int argc, char* argv[])
{
	int x[100000];
	int i,j,n,s,y,p;
	int b[100000];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d %d %d",&x[i],&y,&p);
		b[i]=y+p;
	}
	int t;
	for(i=0;i<3;i++)
	{
		for(j=i+1;j<n;j++)
		{
			if(b[j]>b[i])
			{
				s=x[i];
				x[i]=x[j];
				x[j]=s;
				t=b[i];
				b[i]=b[j];
				b[j]=t;
				
			}

		}

	}
	for(i=0;i<3;i++)
	{
	printf("%d %d\n",x[i],b[i]);
	}
	return 0;
}
int main()
{
	struct Student
	{
		int ID;
		int Chinese;
		int Math;
		int sum;
	}student[100000]; 
    int i,j,n;
	struct Student t;
	scanf("%d", &n);
    for(i=0;i<n;i++)
		scanf("%d%d%d",&student[i].ID,&student[i].Chinese,&student[i].Math);
	for(i=0;i<3;i++)
	{
		for(j=i+1;j<n;j++)
		{
			if(student[i].Chinese+student[i].Math<student[j].Chinese+student[j].Math)
			{
				t=student[i];
				student[i]=student[j];
				student[j]=t;
			}
		}
    }
	for(i=0;i<3;i++)
	{
		printf("%d %d\n",student[i].ID,student[i].Chinese+student[i].Math);
	}
    return 0;
}
struct student{
	int id;
	int chi;
	int math;
	int total;
	struct student *next;
};
int student_num;

struct student *creat()
{
	struct student *p1,*p2,*head;
	int n=0;
	scanf("%d",&student_num);
	p1=p2=(struct student*)malloc(sizeof (struct student));
	while(n<student_num)
	{
		if (n==0) head=p1;
		if (n==student_num-1) p1->next=NULL;
		scanf("%d %d %d",&p1->id,&p1->chi,&p1->math);
		p1->total=p1->chi+p1->math;
		p2=p1;
		p1=(struct student*)malloc(sizeof (struct student));
		p2->next=p1;
		n++;
	}
	return head;
}

void main()
{
	struct student *head,*p;
	int i,n=0,first,second,third,firstid,secondid,thirdid;
	head=creat();
	first=0;
	second=0;
	third=0;
	p=head;
	for(i=1;i<=student_num;i++){
		if (p->total>first){
			third=second;second=first;first=p->total;
			thirdid=secondid;secondid=firstid;firstid=p->id;
		}
		else if (p->total<=first&&p->total>second){
			third=second;second=p->total;
			thirdid=secondid;secondid=p->id;
		}
		else if (p->total<=second&&p->total>third){
			third=p->total;
			thirdid=p->id;
		}
		p=p->next;
	}
			
	printf("%d %d\n%d %d\n%d %d\n",firstid,first,secondid,second,thirdid,third);
	
}
int main()
{
	struct student
	{
		char ID[10];
		int m;
		int c;
	
	}tmp;
    int max1=0,max2=0,max3=0;
	int a1=0,a2=0,a3=0;
	int n,i;

	scanf("%d",&n);

	for(i=1;i<=n;i++)
	{
      scanf("%s %d %d",tmp.ID,&(tmp.m),&(tmp.c)); 
	  if((tmp.m+tmp.c)>max1)
	{
		max3=max2; 
		max2=max1;
		max1=tmp.m+tmp.c;
		a3=a2;
		a2=a1;
		a1=i;
	}
    else if((tmp.m+tmp.c)==max1)
	{
		max3=max2; 
		max2=max1;
		max1=tmp.m+tmp.c;
		a3=a2;
		a2=i;
	}
	else if((tmp.m+tmp.c)<max1 && (tmp.m+tmp.c)>max2)
	{
		max3=max2; 
		max2=tmp.m+tmp.c;
		a3=a2;
		a2=i;
	}
	
	else if((tmp.m+tmp.c)==max2)
	{
		max3=max2; 
		a3=atoi(tmp.ID);
	}
	else if((tmp.m+tmp.c)<max2 && (tmp.m+tmp.c)>max3)
	{
		max3=tmp.m+tmp.c;
		a3=i;
	}
	}
	
	printf("%d %d\n",a1,max1);
	printf("%d %d\n",a2,max2);
	printf("%d %d\n",a3,max3);

	return 0;
}
int main(int argc, char* argv[])
{
	struct test {
		int ID,chinese,maths,sum;
	} ss[100000];
	int i,n;
	scanf ("%d",&n);
	for (i=1;i<=n;i++)
	{
		scanf ("%d%d%d",&ss[i].ID,&ss[i].chinese,&ss[i].maths);
		ss[i].sum=ss[i].chinese+ss[i].maths;
	}
	struct score {
		int ID,sum;
	} s[5];
	s[1].sum=0;
	s[2].sum=0;
	s[3].sum=0;
	for (i=0;i<=n;i++)
	{
		if (ss[i].sum>s[1].sum) 
		{
			s[3].ID=s[2].ID;
			s[3].sum=s[2].sum;
			s[2].ID=s[1].ID;
			s[2].sum=s[1].sum;
			s[1].ID=ss[i].ID;
			s[1].sum=ss[i].sum;
		}
		else if (ss[i].sum>s[2].sum)
		{
			s[3].ID=s[2].ID;
			s[3].sum=s[2].sum;
			s[2].ID=ss[i].ID;
			s[2].sum=ss[i].sum;
		}
		else if (ss[i].sum>s[3].sum)
		{
			s[3].ID=ss[i].ID;
			s[3].sum=ss[i].sum;
		}
	}
	for (i=1;i<=3;i++)
	{
		printf ("%d %d\n",s[i].ID,s[i].sum);
	}
	return 0;
}
struct student
{int math;
 int chi;
 int num;
 int sum;
};
void main()
{
  int i,j,k,n,t,m;
  struct student stu[100000];
  scanf("%d",&n);
  for(i=0;i<n;i++)
   scanf("%d %d %d",&stu[i].num,&stu[i].math,&stu[i].chi);
  for(i=0;i<n;i++)
   stu[i].sum=stu[i].math+stu[i].chi;
  for(i=0;i<3;i++)
    {for(j=i+1,k=i;j<n;j++)
      {
      if(stu[j].sum>stu[k].sum)
       k=j;
       }
     t=stu[i].sum;stu[i].sum=stu[k].sum;stu[k].sum=t;
     m=stu[i].num;stu[i].num=stu[k].num;stu[k].num=m;
    }
   for(i=0;i<3;i++)
     printf("%d %d\n",stu[i].num,stu[i].sum);
}
struct student
{
       int ID;
       int Chinese;
       int Math;
       int Score;
};
main()
{
      int n,i,first=0,ifirst,second=0,isecond,third=0,ithird;
      scanf("%d",&n);
      struct student STUDENT_NUM[n];
      for(i=0;i<n;i++)
      {
                      scanf("%d %d %d",&STUDENT_NUM[i].ID,&STUDENT_NUM[i].Chinese,&STUDENT_NUM[i].Math);
                      STUDENT_NUM[i].Score=STUDENT_NUM[i].Chinese+STUDENT_NUM[i].Math; 
      }
      for(i=0;i<n;i++)
      {
                      if(first<STUDENT_NUM[i].Score)
       {
                                     first=STUDENT_NUM[i].Score;
                                     ifirst=i;
       }
      }
      for(i=0;i<n;i++)
      {
                      if(second<STUDENT_NUM[i].Score&&STUDENT_NUM[i].Score<=first&&i!=ifirst)
                      {
                                     second=STUDENT_NUM[i].Score;
                                     isecond=i;
                      }
      }
      for(i=0;i<n;i++)
      {
                      if(third<STUDENT_NUM[i].Score&&STUDENT_NUM[i].Score<=second&&i!=ifirst&&i!=isecond)
                      {
                                     third=STUDENT_NUM[i].Score;
                                     ithird=i;
                      }
      }
      printf("%d %d\n",STUDENT_NUM[ifirst].ID,first);
      printf("%d %d\n",STUDENT_NUM[isecond].ID,second);
      printf("%d %d\n",STUDENT_NUM[ithird].ID,third);
      
      
      
}