semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int main()
{
int n,i,j,k;
struct student
{
	int num;
	int chi;
	int math;
	int sum;
}score[100000],temp;
scanf("%d",&n);
for(i=0;i<n;i++)
{
	scanf("%d %d %d",&score[i].num,&score[i].chi,&score[i].math);
	score[i].sum=score[i].chi + score[i].math;
}
	for(i=0;i<4;i++)
	{
		k=i;
		for(j=i+1;j<n;j++)
			if(score[j].sum>score[k].sum) k=j;
		temp=score[k];score[k]=score[i];score[i]=temp;
	}
printf("%d %d",score[0].num,score[0].sum);printf("\n");
printf("%d %d",score[1].num,score[1].sum);printf("\n");
printf("%d %d",score[2].num,score[2].sum);
return 0;
}
int main()
{
	int i,t=0,c=1,d=1,n,p=0,q=0,r=0,*b;
	struct pp
	{
		int x;
		int y;
		int z;
	}*s;
	scanf("%d",&n);
	b=(int*)malloc(sizeof(int)*n);
	s=(struct pp*)malloc(sizeof(int)*3*n);
	for(i=0;i<n;i++)
	{
		scanf("%d%d%d",&s[i].x,&s[i].y,&s[i].z);
		b[i]=((s[i].y)+(s[i].z));
	}
	for(i=0;i<n;i++)
	{
		if(b[i]>t)
		{
			t=b[i];
			p=i;
		}
	}
	for(i=0;i<n;i++)
	{
		{
			if((b[i]>c)&&(i!=p))
			{c=b[i];
			q=i;}
		}
	}
	for(i=0;i<n;i++)
	{
		{
			if((b[i]>d)&&(i!=p)&&(i!=q))
			{d=b[i];
			r=i;}
		}
	}
	printf("%d %d\n",s[p].x,b[p]);
	printf("%d %d\n",s[q].x,b[q]);
	printf("%d %d\n",s[r].x,b[r]);
	return 0;
}
struct statistics
	{
		int num;
		int chinese;
		int math;
		int sum;
	} form[100000],temp;
int main()
{
	
	int n;
	scanf("%d",&n);
	int i,j;
	for(i=0;i<n;i++)
	{
		scanf("%d %d %d",&form[i].num,&form[i].chinese,&form[i].math);
		form[i].sum=form[i].chinese+form[i].math;
	}
	for(i=0;i<3&&i<n-1;i++)
	{
		int k=i;
		for(j=i+1;j<n;j++)
		{
			if(form[j].sum>form[k].sum)
			{
				k=j;
			}
		}
		if (k!=i)
		{
			temp=form[i];
			form[i]=form[k];
			form[k]=temp;

		}
	}
	for(i=0;i<3;i++)
		printf("%d %d\n",form[i].num,form[i].sum);
	return 0;
}
struct info
	{
		char num[10];
		int chn;
		int math;
		struct info *next;
	};
int n,all;
struct info *setup(void)
{
	struct info *head,*p1,*p2;
	n=0;
	while(n<all)
	{
		p1=(struct info*)malloc(sizeof(struct info));
		scanf("%s %d %d",p1->num,&p1->chn,&p1->math);
		n+=1;
		if(n==1)head=p1;
		else p2->next=p1;
		p2=p1;				
	}
	p2->next=NULL;
	return(head);
}
void main()
{
	
	struct info *p;
	int i,first=0,second=0,third=0;
	char fnum[10],snum[10],tnum[10];
	scanf("%d",&all);
	p=setup();
	do
	{
		if(TOTAL>first)
		{
			third=second;
			second=first;
			first=TOTAL;
			strcpy(tnum,"");
			strcat(tnum,snum);
			strcpy(snum,"");
			strcat(snum,fnum);
			strcpy(fnum,"");
			strcat(fnum,p->num);
		}
		else if(TOTAL>second)
		{
			third=second;
			second=TOTAL;
			strcpy(tnum,"");
			strcat(tnum,snum);
			strcpy(snum,"");
			strcat(snum,p->num);
		}
		else if(TOTAL>third)
		{
			third=TOTAL;
			strcpy(tnum,"");
			strcat(tnum,p->num);
		}
		p=p->next;
	}while(p!=NULL);
	printf("%s %d\n%s %d\n%s %d\n",fnum,first,snum,second,tnum,third);
}
struct stud
{
	int num;
	int score,score1,score2;
	struct stud *next;
}head,end;
void create(int n)
{
	int i;
	struct stud *p1,*p2;
	head.next=NULL;
	for (i=0;i<=n-1;i++)
	{
		p1=(struct stud *)malloc(sizeof(struct stud));
		if (!i) head.next=p1;
		else p2->next=p1;
		scanf("%d",&p1->num);
		scanf("%d",&p1->score1);
		scanf("%d",&p1->score2);
		p1->score=p1->score1+p1->score2;
		p2=p1;
	}
	p2->next=&end;
}
void find()
{
	struct stud *max1,*max2,*max3,*p1,*swap;		//max1 is the max
	max1=head.next;
	max2=max1->next;
	max3=max2->next;
	p1=max3->next;
	if ( max1->score < max2->score ) 
	{
		swap=max1;
		max1=max2;
		max2=swap;
	}
	if ( max2->score < max3->score ) 
	{
		swap=max2;
		max2=max3;
		max3=swap;
	}
	if ( max1->score < max2->score ) 
	{
		swap=max1;
		max1=max2;
		max2=swap;
	}
	while (p1!=&end)
	{
		if ( p1->score > max3->score ) max3=p1;
		if ( max3->score > max2->score )
		{
			swap=max3;
			max3=max2;
			max2=swap;
		}
		if ( max2->score > max1->score )
		{
			swap=max1;
			max1=max2;
			max2=swap;
		}
		p1=p1->next;
	}
	printf("%d %d\n",max1->num,max1->score);
	printf("%d %d\n",max2->num,max2->score);
	printf("%d %d\n",max3->num,max3->score);
}
void main()
{
	int n;
	scanf("%d",&n);
	create(n);
	find();
}
int main()
{
	int n,a[100000],b[100000],c[100000],sum[100000],i,t1,t2,t3,s1,s2,s3;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{scanf("%d%d%d",&a[i],&b[i],&c[i]);
	sum[i]=b[i]+c[i];}
	for(i=0,t1=0,s1=a[0];i<n;i++)
	{if(sum[i]>t1)
	{t1=sum[i];
	s1=a[i];}}
	printf("%d %d\n",s1,t1);
	for(i=0,t2=0,s2=a[0];i<n;i++)
	{if(a[i]==s1)continue;
	if(sum[i]>t2)
	{t2=sum[i];
	s2=a[i];}}
	printf("%d %d\n",s2,t2);
	for(i=0,t3=0,s3=a[0];i<n;i++)
	{if(a[i]==s1||a[i]==s2)continue;
	if(sum[i]>t3)
	{t3=sum[i];
	s3=a[i];}}
	printf("%d %d\n",s3,t3);
	return 0;
}
struct stu
{
	int num;
	int chinese;
	int math;
	int sum;
	struct stu *next;
};

void main()
{
	void max(struct stu*);
	int n,i;
	struct stu *p,*q,*head;
	scanf("%d\n",&n);
	head=(struct stu*)malloc(sizeof(struct stu));
	p=(struct stu*)malloc(sizeof(struct stu));
	head->next=p;
	for(i=0;i<n;i++)
	{
		scanf("%d %d %d",&p->num,&p->chinese,&p->math);
		p->sum=p->chinese+p->math;
		q=(struct stu*)malloc(sizeof(struct stu));
		p->next=q;
		p=q;
	}
	p->next=NULL;
	max(head);
	max(head);
	max(head);
}

void max(struct stu*head)
{
	struct stu *p,*k,*r,*q;
	int max=0;
	p=head;
	while(p->next!=NULL)
	{
		r=p;
		p=p->next;
		if(p->sum>max)  max=p->sum,k=r,q=p;
	}
	printf("%d %d\n",q->num,q->sum);
	k->next=q->next;
	free(q);
}
int main(){
	struct student{		//????student
		int StudentNumber;	//??
		int ChineseGrades;	//????
		int MathGrades;	    //????
		int Total;			//???
	};
	struct student Stu[100000],sTemp;	//??????Stu?sTemp
	int n,i,j;	//n??????i?j?????
	cin>>n;	//??????
	for (i=0;i<=n-1;i++){	//????????????????????????
		cin>>Stu[i].StudentNumber>>Stu[i].ChineseGrades>>Stu[i].MathGrades;
		Stu[i].Total=Stu[i].ChineseGrades+Stu[i].MathGrades;
	}
	for (i=0;i<=2;i++){	//?????????????????????
		for (j=n-1;j>=i+1;j--){
			if (Stu[j].Total>Stu[j-1].Total){
				sTemp=Stu[j];
				Stu[j]=Stu[j-1];
				Stu[j-1]=sTemp;
			}
		}
	}
	cout<<Stu[0].StudentNumber<<" "<<Stu[0].Total;	//?????
	for (i=1;i<=2;i++){
		cout<<endl;
		cout<<Stu[i].StudentNumber<<" "<<Stu[i].Total;
	}
	return 0;
}
struct student
{
        int num;
        int sum;
}stu[100000];

int main()
{

   int n,i,j,t,a,b,m;
   int tempSum;
   int tempMax;
   int rank[3]={0};
   scanf("%d",&n);
   //struct student * stu;
   //stu = (struct student *)malloc(sizeof(struct student) * n);
   for(i=0;i<n;i++)
   {
        tempSum = 0;
           scanf("%d",&stu[i].num);
           stu[i].sum = 0;
           for(j=0;j<2;j++){
            scanf("%d",&tempSum);
            stu[i].sum += tempSum;
           }
   }
   for(b=0;b<3;b++)
   {
       tempMax = 0;
       for(a=b;a<n;a++)
       {
           if(stu[a].sum > tempMax){
            tempMax = stu[a].sum;
            rank[b] = a;
           }
       }
       t = stu[b].num;
       stu[b].num = stu[rank[b]].num;
       stu[rank[b]].num = t;
       t = stu[b].sum;
       stu[b].sum = stu[rank[b]].sum;
       stu[rank[b]].sum = t;
   }
   for(a=0;a<3;a++)
   printf("%d %d\n",stu[a].num,stu[a].sum);

  return 0;
}
struct stu
{
   float num;
   float chi,mat,total;
   struct stu *next;
};
struct stu *creat(int n)
{
   int i;

   struct stu *head,*p1,*p2;
        for(i=0;i<n;i++)
   {
           p1=(struct stu*)malloc(sizeof(struct stu));
           scanf("%f %f %f",&p1->num,&p1->chi,&p1->mat);
           p1->total=p1->chi+p1->mat;
           if (i==0)
           {head=p2=p1;}
           else
           {p2->next=p1;p2=p1;}
   }
   p2->next=0;
   return(head);

}


void main()
{
        int n,i,j;
		float max;
        struct stu *head,*maxi,*p;
        scanf("%d",&n);
        head=creat(n);
       

        for(i=0;i<3;i++)
        {
            	p=head;maxi=head;
				max=head->total;
			for(j=0;j<n-1;j++)
			{
				p=p->next;
				if(p->total>max) 
				{max=p->total;maxi=p;}
			}
			
			printf("%g %g\n",maxi->num,maxi->total);
            maxi->total=0;
        }
}
void main()
{
  struct student
  {
    int num,sum;
  } stu[100000];
  int n,i,j,k,a,b,t;
  scanf("%d",&n);
  for (i=0;i<n;i++) 
  { 
    scanf("%d %d %d",&stu[i].num,&a,&b);
	stu[i].sum=a+b;
  }
  for (i=0;i<3;i++)
  for (j=n-i-1;j>0;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;
    }
  for (i=0;i<3;i++) printf("%d %d\n",stu[i].num,stu[i].sum);
}
struct Student
{
long id;
int chn;
int mth;
int total;
};
void main()
{
struct Student *p1,*top1,*top2,*top3,*temp;
int i;
long int n;
scanf("%ld",&n);

top1=(struct Student*)malloc(sizeof(struct Student));
top2=(struct Student*)malloc(sizeof(struct Student));
top3=(struct Student*)malloc(sizeof(struct Student));
temp=(struct Student*)malloc(sizeof(struct Student));
scanf("%d %d %d",&top1->id,&top1->chn,&top1->mth);
top1->total=top1->chn + top1->mth;
scanf("%d %d %d",&top2->id,&top2->chn,&top2->mth);
top2->total=top2->chn + top2->mth;
if(top2->total>top1->total)
{
temp=top2;
top2=top1;
top1=temp;
}
scanf("%d %d %d",&top3->id,&top3->chn,&top3->mth);
top3->total=top3->chn + top3->mth;
if(top3->total>top2->total)
{
temp=top3;
top3=top2;
top2=temp;
}
if(top2->total>top1->total)
{
temp=top2;
top2=top1;
top1=temp;
}
for(i=3;i<n;i++)
{
p1=(struct Student*)malloc(sizeof(struct Student));
scanf("%d %d %d",&p1->id,&p1->chn,&p1->mth);
p1->total=p1->chn + p1->mth;
if (top1->total< p1->total) {top3=top2;top2=top1;top1=p1;continue;}
if (top2->total< p1->total) {top3=top2;top2=p1;continue;}
if (top3->total< p1->total) {top3=p1;continue;}
free (p1);
}
printf("%d %d\n%d %d\n%d %d\n",top1->id,top1->total,top2->id,top2->total,top3->id,top3->total);
}
struct student
{
	int id;
	int math;
	int chinese;
	int sum;
}stu[100000];

int main(int argc, char* argv[])
{
	int i , n ;
	int max1=0,max2=0,max3=0;
	int maxid1=0,maxid2=0,maxid3=0;

	scanf("%d", &n );
	for ( i = 0 ; i < n ; i ++ )
	{
		scanf("%d %d %d", &stu[i].id , &stu[i].chinese ,&stu[i].math );
		stu[i].sum = stu[i].math + stu[i].chinese;
		if ( stu[i].sum > max1 )
		{
			max3 = max2 ;
			max2 = max1 ;
			max1 = stu[i].sum ;
			maxid3 = maxid2 ;
			maxid2 = maxid1 ;
			maxid1 = stu[i].id;
		}
		else if ( stu[i].sum > max2 )
		{
			max3 = max2 ;
			max2 = stu[i].sum ;
			maxid3 = maxid2 ;
			maxid2 = stu[i].id ;
		}
		else if ( stu[i].sum > max3 )
		{
			max3 = stu[i].sum ;
			maxid3 = stu[i].id ;
		}
	}
	printf("%d %d\n%d %d\n%d %d" , maxid1,max1,maxid2,max2,maxid3,max3);
	return 0;
}
struct stu
{
	int num;
	int yu;
	int shu;
	int tol;
	struct stu *next;
};
int n;

struct stu *creat(void)
{
	struct stu *p1,*p2,*head,*p;
	int i,k;
	p1=p2=(struct stu *)malloc(sizeof(struct stu));
	scanf("%d %d %d",&p1->num,&p1->yu,&p1->shu);
	p1->tol=p1->yu+p1->shu;
	p1->next=0;
	head=p1;
	p=p1;
	p1=(struct stu *)malloc(sizeof(struct stu));
	for(i=1;i<n;i++)
	{
		p=head;
		p2=p1;
		k=0;
		scanf("%d %d %d",&p1->num,&p1->yu,&p1->shu);
		p1->tol=p1->yu+p1->shu;
		while(p!=0&&p->tol>=p1->tol)
		{
			p2=p;
			p=p->next;
			k++;
		}
		if(k<=3)
		{
		if(p==head)
		{
			head=p1;
			p1->next=p;
		}
		if(p==0)
		{
			p2->next=p1;
			p1->next=0;
		}
		if(p!=head&&p!=0)
		{
			p2->next=p1;
			p1->next=p;
		}
		}
		p1=(struct stu *)malloc(sizeof(struct stu));
	}
	return head;
}
void main()
{
	struct stu *head,*p;
	int i=0;
	scanf("%d",&n);
	head=creat();
	p=head;
	while(i<3)
	{
		printf("%d %d\n",p->num,p->tol);
		i++;
		p=p->next;
	}
}
int main()
{
	int i,n,math,chinese,std_num;
	int first,second,third;
	int score[3]={-1,-1,-1};
	scanf("%d",&n);
	first=0;second=0;third=0;
    for(i=0;i<n;i++){
        scanf("%d",&std_num);       
        scanf("%d",&chinese);
        scanf("%d",&math);         
        if (chinese+math>score[0]){
           third =second;
           second=first;
           score[2]=score[1];
           score[1]=score[0];
           first = std_num;
           score[0]=chinese+math;
        }
        else if(chinese+math>score[1]){
                third=second;
                score[2]=score[1];
                second=std_num;
                score[1]=math+chinese;
             }
        else if(chinese+math>score[2]){
                third=std_num;
                score[2]=math+chinese;
             }
    } 
    printf("%d %d\n",first,score[0]);
    printf("%d %d\n",second,score[1]);
    printf("%d %d\n",third,score[2]);
    return 0;
}
struct student
{
long num;
int chi;
int math;
int add;
};
struct student stu[100000];
void main()
{
int m,k,n,i,j;
scanf("%d",&n);
for(i=0;i<n;i++)
 {
 scanf("%ld %d %d",&stu[i].num,&stu[i].chi,&stu[i].math);
 stu[i].add=stu[i].chi+stu[i].math;
 }
for(j=0;j<3;j++)
 for(i=n-1;i>0;i--)
 {
 if(stu[i].add>stu[i-1].add)
 {	
 k=stu[i].add;stu[i].add=stu[i-1].add;stu[i-1].add=k;
 m=stu[i].num;stu[i].num=stu[i-1].num;stu[i-1].num=m;
 }
 }
for(i=0;i<3;i++)
printf("%ld %d\n",stu[i].num,stu[i].add);
}
main()
{
      int i,n,t[3]={0},u[3]={0};
      struct student
      {
        long int ID;
        int math;
        int chinese;
        int a;
      }stu[100000];
      scanf("%d",&n);
      for(i=0;i<n;i++)
      {
           scanf("%d %d %d",&stu[i].ID,&stu[i].math,&stu[i].chinese);
           stu[i].a=stu[i].math+stu[i].chinese;
      }
      for(i=0;i<n;i++)
      {
         if(stu[i].a>t[0])
         {t[0]=stu[i].a;u[0]=i;}
      }
      for(i=0;i<n;i++)
      {
         if(i==u[0])continue;
         if(stu[i].a>t[1])
         {t[1]=stu[i].a;u[1]=i;}
      }
      for(i=0;i<n;i++)
      {
         if(i==u[0]||i==u[1])continue;
         if(stu[i].a>t[2])
         {t[2]=stu[i].a;u[2]=i;}
      }
      printf("%d %d\n%d %d\n%d %d\n",stu[u[0]].ID,t[0],stu[u[1]].ID,t[1],stu[u[2]].ID,t[2]);
}
int main()
{
	struct student
	{
		int num;
		int chinese;
		int math;
		int sum;
	}stu[100000],t;

         int n;
	int i;
	int k;

	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d %d",&stu[i].num,&stu[i].chinese,&stu[i].math);
                  stu[i].sum=stu[i].chinese+stu[i].math;
	}

         for(k=n-1;k>n-4;k--){
		for(i=0;i<k;i++){
			if(stu[i].sum>=stu[i+1].sum){
				t=stu[i];
                                    stu[i]=stu[i+1];
                                    stu[i+1]=t;
			}
		}
	}

        printf("%d %d\n",stu[n-1].num,stu[n-1].sum);
        printf("%d %d\n",stu[n-2].num,stu[n-2].sum);
        printf("%d %d\n",stu[n-3].num,stu[n-3].sum);

	return 0;
}
int main()
{
 int n,i,max1=0,max2=0,max3=0,t1=0,t2=0,t3=0;
 int ID[100000],y[100000],m[100000],s[100000];
 scanf("%d",&n);
 for(i=0;i<n;i++)
  scanf("%d %d %d",&ID[i],&y[i],&m[i]);
 for(i=0;i<n;i++)
  s[i]=y[i]+m[i]; 
 for(i=0;i<n;i++)
 {
  if(max1<s[i])
  {
   max1=s[i];
   t1=i;             
  }                
 }
 s[t1]=0;      
 for(i=0;i<n;i++)
 {
  if(max2<s[i])
  {
   max2=s[i];
   t2=i;             
  }                
 }
 s[t2]=0;
 for(i=0;i<n;i++)
 {
  if(max3<s[i])
  {
   max3=s[i];
   t3=i;             
  }                
 }           
 printf("%d %d\n",ID[t1],max1); 
 printf("%d %d\n",ID[t2],max2);
 printf("%d %d\n",ID[t3],max3);
 getchar();
 getchar();
 getchar();
 return 0;
}
struct student{
	int No;
	int yuwen;
	int shuxue;
	int sum;
};



int main(){
	
	
	int n,i,k,e,f;

	scanf("%d",&n);

	struct student *stu=(struct student*)malloc(sizeof(int)*4*n);

	for(i=0;i<n;i++){
		scanf("%d%d%d",&stu[i].No,&stu[i].yuwen,&stu[i].shuxue);
		stu[i].sum=stu[i].yuwen+stu[i].shuxue;
	}
	
	for(k=0;k<3;k++){
		for(i=n-1;i>k;i--){
			if(stu[i-1].sum<stu[i].sum){
			e=stu[i-1].sum;
			stu[i-1].sum=stu[i].sum;
			stu[i].sum=e;
			f=stu[i-1].No;
			stu[i-1].No=stu[i].No;
			stu[i].No=f;
			}
		}
	}
	for(i=0;i<3;i++){
		printf("%d %d\n",stu[i].No,stu[i].sum);
	}
	

	return 0;
}
int main()
{
	int a[3], n,c,b,d,g[3], i,temp;

	int j = 0;
	scanf("%d",&n);
	for(i = 0; i < 3; i++)
	{
		scanf("%d %d %d", &d,&b,&c);
		g[i] = d;
		a[i] = b+c;
	}

	for (i = 0; i < 3 - 1; i++)
		for (j = 0; j < 3 - 1 - i; j++)
			if (a[j] < a[j+1]) {
				temp = a[j] ;
				a[j] = a[j+1];
				a[j+1] = temp;
				temp = g[j];
				g[j] = g[j+1];
				g[j+1] = temp;
			}

	for(i=3;i<n;i++)
	{
		scanf("%d %d %d",&d,&b,&c);
		temp=b+c;

		
		if(temp <= a[2])
		{
			continue;
		} else {
			if (a[1] >= temp){
				a[2] = temp;
			g[2]=d;
			}
			else {
				a[2] = a[1];
				g[2]=g[1];
				if(a[0] >=temp){
					a[1]=temp;
				    g[1]=d;
				}
				else {
					a[1]=a[0];
					g[1]=g[0];
						a[0]=temp;
						g[0]=d;
				}
			}
		}
	}

			printf("%d %d\n%d %d\n%d %d\n",g[0],a[0],g[1],a[1],g[2],a[2]);
}
struct student
{
	int id;
	int score1;
	int score2;
	struct student *next;
};
struct student *head;
struct student *creat(int x)
{
	struct student *p1,*p2;
	p1=p2=(struct student *)malloc(LEN);
    scanf("%d %d %d",&p1->id,&p1->score1,&p1->score2);
	head=0;
	while(p1->id<x)
	{
		if(p1->id==1)
			head=p1;
		else p2->next=p1;
		p2=p1;
		p1=(struct student *)malloc(LEN);
		scanf("%d %d %d",&p1->id,&p1->score1,&p1->score2);
		if(p1->id==x){
			p2->next=p1;
			p2=p1;
		}
	}
	p2->next=0;
	return(head);
}
void main()
{
	int n;
	struct student *p,*q,*j,*k;
	scanf("%d",&n);
	creat(n);
	p=q=head;
	do{
		if((p->score1+p->score2)>(q->score1+q->score2))
			q=p;
		p=p->next;
	}while(p!=0);
	p=j=head;
	do{
		if((p->score1+p->score2)>(j->score1+j->score2)&&p!=q)
			j=p;
		p=p->next;
	}while(p!=0);
	p=k=head;
	do{
		if((p->score1+p->score2)>(k->score1+k->score2)&&p!=q&&p!=j)
			k=p;
		p=p->next;
	}while(p!=0);
	printf("%d %d\n",q->id,(q->score1+q->score2));
	printf("%d %d\n",j->id,(j->score1+j->score2));
	printf("%d %d",k->id,(k->score1+k->score2));
}
int main()
{
    int n;
    scanf("%d\n",&n);
    struct student{
           int id;
           int yu,shu;
           } stu[100000];
    int i;
    int s1=0,s2=0,s3=0;
    int x1=0,x2=0,x3=0;
    for(i=0;i<n;i++)
    {
     scanf("%d %d %d\n",&stu[i].id,&stu[i].yu,&stu[i].shu);
    } 
    int s,x;
     for(i=0;i<n;i++)
     { 
      s=stu[i].yu+stu[i].shu;
      x=stu[i].id;
      if(s>s1)
      {s3=s2;x3=x2;s2=s1;x2=x1;s1=s;x1=x;}
      else if(s==s1)
      {s3=s2;x3=x2;s2=s;x2=x;}
      else if(s<s1&&s>s2)
      {s3=s2;x3=x2;s2=s;x2=x;}
      else if(s==s2)
      {s3=s;x3=x;}
      else if(s<s2&&s>s3)
      {s3=s;x3=x;}          
     }
      printf("%d %d\n",x1,s1);
      printf("%d %d\n",x2,s2);
      printf("%d %d\n",x3,s3);   
return 0;
}
struct student
	{
		int num;
		int chi;
		int mat;
		int sum;
	}stu[100000];
void main()
{
	
	int i,n,max=0,m,k;
	scanf("%d",&n);
	for(i=0;i<n;i++) {scanf("%d %d %d",&stu[i].num,&stu[i].chi,&stu[i].mat);stu[i].sum=stu[i].chi+stu[i].mat;}
	for(k=0;k<3;k++)
	{
		for(i=0;i<n;i++) if(stu[i].sum>max) {max=stu[i].sum;m=i;}
		printf("%d %d\n",stu[m].num,stu[m].sum);
		stu[m].sum=0;
		max=0;
	}
}
struct student
{
       int id;
       int math;
       int chinese;
       int zongfen;
};
main()
{
      int n,i=1,j;
      int a[100001];
      struct student stu[100001];
      scanf("%d",&n);
      for (i=1;i<=n;i++)
      {
          scanf("%d %d %d",&stu[i].id,&stu[i].math,&stu[i].chinese);
          stu[i].zongfen=stu[i].math+stu[i].chinese;
          if (i<4)
          j=i;
          else
          j=4; 
          {
                for(;j>1&&stu[i].zongfen>stu[a[j-1]].zongfen;j--)
                a[j]=a[j-1];
          }
          a[j]=i;       
      }
      for(i=1;i<=3;i++)
      printf("%d %d\n",stu[a[i]].id,stu[a[i]].zongfen);
      getchar();
      getchar();
      scanf("%d",&n);
      return 0;
      }
struct student
{
	char xuehao[100];
	int yuwen;
	int shuxue;
	int sum;
};

int main()
{
	int n,i,j,l,m;
    struct student stu[100000];
	struct student temp;

	

	scanf("%d",&n);

	for (i=0;i<n;i++)
	{
		scanf("%s",stu[i].xuehao);
		scanf("%d %d",&stu[i].yuwen,&stu[i].shuxue);
		stu[i].sum=stu[i].yuwen+stu[i].shuxue;
	}

	for(j=1;j<4;j++)
	{
		for(m=0;m<n-j;m++)
		{
			if(stu[m].sum>=stu[m+1].sum)
			{
				temp=stu[m];
				stu[m]=stu[m+1];
				stu[m+1]=temp;
			}
		}
	}




	for(l=n-1;l>n-4;l--)
		printf("%s %d\n",stu[l].xuehao,stu[l].sum);

	return 0;
}
void main()
{
	int i,n,m;
	scanf("%d\n",&n);
	int j,b[100000]={0},t,s;
	struct student
	{
		int num;
		int lang;
		int math;
	};
	struct student a[100000];
	for(i=0;i<n;i++) scanf("%d %d %d\n",&a[i].num,&a[i].lang,&a[i].math);
    for(i=0;i<n;i++) b[i]=a[i].lang+a[i].math;
    for(j=0;j<3;j++)
		for(i=1;i<n-j;i++)
			if(b[j]<b[j+i])
			{t=b[j];b[j]=b[j+i];b[j+i]=t;}
    for(j=0;j<3;j++)
        for(i=0;i<n;i++)
		{
			m=a[i].lang+a[i].math;
			if(m==b[j] && i!=s) {printf("%d %d\n",a[i].num,m);s=i;break;}
		}
}
void main()
{
 int i,j,n,k;
 struct student
 {
  int num;
  int score1;
  int score2;
  int t;
 }stu[100000],m1,m2,m3;
 scanf("%d\n",&n);
 for(i=0;i<n;i++)
     {
      scanf("%d %d %d\n",&stu[i].num,&stu[i].score1,&stu[i].score2);
      stu[i].t=stu[i].score1+stu[i].score2;     
     }
 m1=stu[0];
 m2=stu[0];
 m3=stu[0];
 for(i=0;i<n;i++)
        {
         if(stu[i].t>m1.t)
            {
             m3=m2;
             m2=m1;
             m1=stu[i];
            }
        else if(stu[i].t>m2.t&&stu[i].t<=m1.t)
            {
             m3=m2;
             m2=stu[i];
            }
        else if(stu[i].t>m3.t&&stu[i].t<=m2.t)
            {
             m3=stu[i];
            }
        }
   printf("%d %d\n%d %d\n%d %d",m1.num,m1.t,m2.num,m2.t,m3.num,m3.t);
     
}
struct student
{
	int num,cn,math,sum,rank;
	struct student *next;
};
int n;

struct student * creat(void)
{
	int i=1;
	struct student *head;
	struct student *p1,*p2;
	p1=p2=(struct student *)malloc(LEN);
	scanf("%d %d %d",&p1->num,&p1->cn,&p1->math);
	head=p1;
	do
	{
		p2=p1;
		if(i==n)
			break;
		p1=(struct student *) malloc(LEN);
		scanf("%d %d %d",&p1->num,&p1->cn,&p1->math);
		p2->next=p1;
		i++;
	}while(1);
	p2->next=0;
	return(head);	
}

void count(struct student *head)
{
	int max=0;
	struct student *p1;
	n=1;
	p1=head;
	do
	{
		p1->sum=p1->cn+p1->math;
		if(max<p1->sum)
			max=p1->sum;
		if(p1->next==0)
			break;
		p1=p1->next;
	}while(1);
	p1=head;
	do
	{
		if(p1->sum==max)
		{
			p1->rank=n;
			n++;
		}
		if(n>3)break;
		if(p1->next==0)
		{
			p1=head;
			max--;
		}
		else
		p1=p1->next;
	}while(1);
}

void print(struct student *head)
{
	struct student *p1;
	n=1;
	p1=head;
	do
	{
		if (p1->rank==n)
		{
			printf("%d %d\n",p1->num,p1->sum);
			n++;
		}
		if(n>3)
			break;
		if(p1->next==0)
			p1=head;
		else p1=p1->next;
	}while(1);
}


void main()
{
	struct student *head;
	scanf("%d",&n);
	head=creat();
	count(head);
	print(head);
}
struct student { int id; char yw;char sx;int zf;int pm;};
int main()
{
struct student a[100000],b[2];
int n,i,j;
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d%d%d",&a[i].id,&a[i].yw,&a[i].sx);
for(i=0;i<n;i++)
a[i].zf=a[i].yw+a[i].sx;
j=0;
for(i=0;i<n;i++)
if(a[i].zf>j)
{j=a[i].zf;b[0]=a[i];}
printf("%d %d\n",b[0].id,b[0].zf);
j=0;
for(i=0;i<n;i++)
if(a[i].zf>j&&a[i].id!=b[0].id)
{j=a[i].zf;b[1]=a[i];}
printf("%d %d\n",b[1].id,b[1].zf);
j=0;
for(i=0;i<n;i++)
if(a[i].zf>j&&a[i].id!=b[0].id&&a[i].id!=b[1].id)
{j=a[i].zf;b[2]=a[i];}
printf("%d %d\n",b[2].id,b[2].zf);
}
/*
 * statistics of scores.cpp
 *
 *  Created on: 2011-12-11
 *      Author: Administrator
 */
struct stu
	{
		int Num;
		int scoreC;
		int scoreM;
		int all;
	};
	struct stu stu[100005];
void fsort(int first,int last)
{
	int chosen1,chosen2,p,q;
	if(first>=last){return;}
	chosen1=stu[first].all;
	chosen2=stu[first].Num;
	p=first;q=last;
    while(p<q)
    {
    	while((p<q)&&(stu[q].all>=chosen1)){q--;}
    	if(p<q){stu[p].all=stu[q].all;stu[p].Num=stu[q].Num;p++;}
    	while((p<q)&&(stu[p].all<chosen1)){p++;}
    	if(p<q){stu[q].all=stu[p].all;stu[q].Num=stu[p].Num;q--;}
    }
    stu[p].all=chosen1;stu[p].Num=chosen2;
    fsort(first,p-1);
    fsort(p+1,last);
}
int main()
{
	int m,i;//????
	cin>>m;
	for(i=1;i<=m;i++)//????
	{
		cin>>stu[i].Num>>stu[i].scoreC>>stu[i].scoreM;
		stu[i].all=stu[i].scoreC+stu[i].scoreM;
	}
	fsort(1,m);
	cout<<stu[m].Num<<" "<<stu[m].all<<endl;//?????
	cout<<stu[m-1].Num<<" "<<stu[m-1].all<<endl;
	cout<<stu[m-2].Num<<" "<<stu[m-2].all<<endl;
	return 0;
}
struct f{
	int a;
	int b;
	int c;}st[100000],tp;
int main(){
	int n,i,ii,j,d,a,b,c;
	char cc;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d%d%d",&st[i].a,&st[i].b,&st[i].c);
	st[i].b+=st[i].c;
	}
	for(i=1;i<=3;i++){
		for(j=i+1;j<=n;j++){
			if(st[j].b>st[i].b){
				tp=st[i];
				st[i]=st[j];
				st[j]=tp;}}}
	for(i=1;i<=3;i++)
	printf("%d %d\n",st[i].a,st[i].b);
}