semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
struct student
{
	int id;
	int chinese;
	int math;
}student[100000];
void main()
{
	int n,i,j,sum[100000]={0},h1=0,h2=0,h3=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d%d%d",&student[i].id,&student[i].chinese,&student[i].math);
	}
	int first=0;
	int sec=0;
	int thi=0;
	for(j=0;j<n;j++){
		if(first<student[j].chinese+student[j].math)
		{
			thi=sec;
			h3=h2;
			sec=first;
			h2=h1;
			first=student[j].chinese+student[j].math;
			h1=student[j].id; 
		}
		else if((first>student[j].chinese+student[j].math)&&(sec<student[j].chinese+student[j].math))
		{
			thi=sec;
			h3=h2;
			sec=student[j].chinese+student[j].math;
			h2=student[j].id;
		}
		else if((sec>student[j].chinese+student[j].math)&&(thi<student[j].chinese+student[j].math))
		{
			thi=student[j].chinese+student[j].math;
			h3=student[j].id;
		}
		else if((first==student[j].chinese+student[j].math)&&(sec<student[j].chinese+student[j].math))
		{
			thi=sec;
			h3=h2;
			sec=student[j].chinese+student[j].math;
			h2=student[j].id;
		}
		else if((sec==student[j].chinese+student[j].math)&&(thi<student[j].chinese+student[j].math))
		{
			thi=student[j].chinese+student[j].math;
			h3=student[j].id;
		}
	}
	printf("%d %d\n%d %d\n%d %d",h1,first,h2,sec,h3,thi);
}
struct student
{
int ID;
int chi;
int math;
int total;
} stu[1000000];

void main()
{
	int STUDENT_NUM,i,j,temp1,temp2;	
	scanf("%d",&STUDENT_NUM);
	for(i=0;i<STUDENT_NUM;i++)
	{
		scanf("%d %d %d",&stu[i].ID,&stu[i].chi,&stu[i].math);
		stu[i].total=stu[i].chi+stu[i].math;
	}
	for(i=0;i<3;i++)
	{
	    for(j=i+1;j<STUDENT_NUM;j++)
		{
			if(stu[i].total<stu[j].total)
			{
				temp1=stu[i].ID;
				stu[i].ID=stu[j].ID;
				stu[j].ID=temp1;
				temp2=stu[i].total;
				stu[i].total=stu[j].total;
				stu[j].total=temp2;
			}
		}
	}
	printf("%d %d\n%d %d\n%d %d\n",stu[0].ID,stu[0].total,stu[1].ID,stu[1].total,stu[2].ID,stu[2].total);
}
void main(int argc, char* argv[])
{
	int num,chi,math,sum;
	struct student{
		int num,chi,math,sum;
	}students[100000];
	int i;
	int STUDENT_NUM;
	scanf("%d",&STUDENT_NUM);
	for (i=0;i<STUDENT_NUM;i++)
	{
		scanf("%d %d %d",&num,&chi,&math);
		students[i].num=num;
		students[i].chi=chi;
		students[i].math=math;
		sum=chi+math;
		students[i].sum=sum;
	}
	int sum1=0,sum2=0,sum3=0;
	int num1,num2,num3;
	for (i=0;i<STUDENT_NUM;i++)
	{
		if(i==0)
		{
			sum1=students[0].sum;
			num1=students[0].num;
		}
		else if(i==1)
		{
			if(students[1].sum>students[0].sum)
			{
				sum2=sum1;
				num2=num1;
				sum1=students[1].sum;
				num1=students[1].num;
			}
			else
			{
				sum2=students[1].sum;
				num2=students[1].num;
			}
		}
		else 
		{
			if(students[i].sum>sum1)
			{
				sum3=sum2;
				num3=num2;
				sum2=sum1;
				num2=num1;
				sum1=students[i].sum;
				num1=students[i].num;
			}
			else if(students[i].sum>sum2)
			{
				sum3=sum2;
				num3=num2;
				sum2=students[i].sum;
				num2=students[i].num;
			}
			else if(students[i].sum>sum3)
			{
				sum3=students[i].sum;
				num3=students[i].num;
			}
		}
	}
	printf("%d %d\n",num1,sum1);
	printf("%d %d\n",num2,sum2);
	printf("%d %d\n",num3,sum3);
}
int main()
{
    int N,i,j,k;
    cin>>N;
    struct Student_Num    //?????  
    {
        int num;         //?? 
        int Chinese;     //???? 
        int Math;        //???? 
    };
    struct Student_Num student[N];       //N?????? 
    struct Student_Num temp;            
    for(i=0;i<N;i++)
    {
        cin>>student[i].num>>student[i].Chinese>>student[i].Math;   //???????? 
    }
    int total[N],totalNum[3],p[3];       //????????????????????????? 
    for(i=0;i<N;i++)
    {
        total[i]=student[i].Chinese+student[i].Math;  //??? 
    }
    for(i=0;i<3;i++)               //????0 
    {
        totalNum[i]=0;
    }
    for(i=0;i<3;i++)      //????? 
    {
        for(j=0;j<N;j++)
        {
            if(totalNum[i]<total[j])
            {
                totalNum[i]=total[j];
                p[i]=j;
            }
        }
        total[p[i]]=0;   //?????????????????0??????????????? 
    }
    for(i=0;i<3;i++)
    {
        cout<<student[p[i]].num<<' '<<totalNum[i]<<endl;   //???????? 
    }
    return 0;
}
struct student
    {
           int num,chi,mat,tot;           
    }stu[100000];

int main()
{
    void max(struct student [],int n);
    int n,i,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].tot=stu[i].chi+stu[i].mat;
    }
                                     
                                        
                                                                               
   
    for(k=0;k<3;k++)
    {
                    max(stu,n);
                    if(k<2)
                    printf("\n");
                   
    }
}

void max(struct student stu[],int n)
{
     int i,j,max;
     max=stu[0].tot;
     for(i=0;i<n;i++)
      if(stu[i].tot>max)
       {
        max=stu[i].tot;
        j=i;
        }

     printf("%d %d",stu[j].num,max);
     stu[j].tot=-1;
}
struct student
{
	int num;
	int score1;
	int score2;
	int score;
};

void main()
{
	int n;
	scanf("%d",&n);
	struct student stu[100000];
	struct student *p,*p1,*t1,*t2,*t3;
	int tem,tem1;
	for(p=stu;p<stu+n;p++)
	{
		scanf("%d %d %d",&p->num,&p->score1,&p->score2);
		p->score=p->score1+p->score2;
	}
	int max;
	for(p=stu,t1=stu,max=stu->score;p<stu+n;p++)
	{
		if(p->score>max) {t1=p;max=p->score;}
	}
	for(p=stu,t2=stu,max=stu->score;p<stu+n;p++)
	{
		if(p==t1) continue;
		if(p->score>max) {t2=p;max=p->score;}
	}
	for(p=stu,t3=stu,max=stu->score;p<stu+n;p++)
	{
		if((p==t1)||(p==t2)) continue;
		if(p->score>max) {t3=p;max=p->score;}
	}
	printf("%d %d\n",t1->num,t1->score);
	printf("%d %d\n",t2->num,t2->score);
	printf("%d %d\n",t3->num,t3->score);
}
struct inf
{
	int nu;
	int b;
	int c;
	int sum;
} a[100010],tmp;
int main()
{
	int n,i,j,k,tmp1,tmp2;
	char c;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
		{
			a[i-1].sum=0;
			scanf("%d%d%d",&a[i-1].nu,&a[i-1].b,&a[i-1].c);
			a[i-1].sum=a[i-1].b+a[i-1].c;
	}
	for(i=0;i<3;i++)
	{
		tmp1=i;tmp2=a[i].sum;
		for(j=i+1;j<n;j++)
		{
			if(a[j].sum>tmp2)
				{
					tmp2=a[j].sum;
					tmp1=j;
			}
		}
		tmp=a[i];
		a[i]=a[tmp1];
		a[tmp1]=tmp;
	}
	for(i=0;i<3;i++)
		printf("%d %d\n",a[i].nu,a[i].sum);
	return 0;
}
int main(int argc, char* argv[])
{
	int n;
	scanf("%d",&n);
	struct student{
		int a,b,c;
	}student_1;
	int x,i=0;
	int a1=0,a2=0,b1=0,b2=0,c1=0,c2=0;
	while(i<n){
		scanf("%d%d%d",&student_1.a,&student_1.b,&student_1.c);
		x=student_1.b+student_1.c;
			if(x>a2){
				c1=b1;
				c2=b2;
				b1=a1;
				b2=a2;
				a1=student_1.a;
				a2=x;
			}
			else if(x==a2){
				if (x > b2)
				{
					c1 = b1;
					c2 = b2;
					b1=student_1.a;
					b2=x;
				}
				else if (x > c2)
				{
					c1 = student_1.a;
					c2 = x;
				}
			}
			else if(x>b2){
				c1=b1;
				c2=b2;
				b1=student_1.a;
				b2=x;
			}
			else if(x==b2){
				if (x > c2)
				{
					c1=student_1.a;
					c2=x;
				}
			}
			else if(x>c2){
				c1=student_1.a;
				c2=x;
			}
		i++;
	}
	printf("%d %d\n",a1,a2);
	printf("%d %d\n",b1,b2);
	printf("%d %d\n",c1,c2);
	return 0;
}
struct student
{
       int i;
       int j; 
       int k;
       }; 
main()
{
      int n;
      scanf("%d",&n);
      struct student c[n+10];
      int m1=1,m2=1,m3=1;
      for(int m=1;m<=n;m++)
     { scanf("%d %d %d",&c[m].i,&c[m].j,&c[m].k);
      if((c[m].j+c[m].k)>(c[m1].j+c[m1].k))
      {m3=m2;m2=m1;m1=m;}
      else if((c[m].j+c[m].k)>(c[m2].j+c[m2].k))
     { m3=m2;m2=m;}
      else if((c[m].j+c[m].k)>(c[m3].j+c[m3].k))
      m3=m;}
      printf("%d %d\n",c[m1].i,c[m1].j+c[m1].k);
      printf("%d %d\n",c[m2].i,c[m2].j+c[m2].k);
      printf("%d %d\n",c[m3].i,c[m3].j+c[m3].k);
      getchar();getchar();getchar();}
struct student
{
	int num;
	int chinese;
	int math;
	int total;
}s[N];
		
int main()
{
	int n,i,j,tn,tt;
	scanf("%d",&n);
	for (i=0;i<n;i++)
	{
		scanf("%d%d%d",&s[i].num,&s[i].chinese,&s[i].math);
		s[i].total=s[i].math+s[i].chinese;
	}
	for (i=1;i<4;i++)
	{
		for (j=0;j<n-i;j++)
		{
			if (s[j].total>=s[j+1].total)
			{
				tt=s[j].total;            tn=s[j].num;
				s[j].total=s[j+1].total;  s[j].num=s[j+1].num;
				s[j+1].total=tt;          s[j+1].num=tn;
			}
		}
	}
	printf("%d %d\n%d %d\n%d %d\n",s[n-1].num,s[n-1].total,s[n-2].num,s[n-2].total,s[n-3].num,s[n-3].total);
    return (0);
}
int main(){
	struct student{
		int stuno;
		int score1;
		int score2;
		int score0;
	};
	int n,i,j,temp;
	cin>>n;
	struct student num[n];
	for(i=0;i<n;i++){
		cin>>num[i].stuno;
		cin>>num[i].score1;
		cin>>num[i].score2;
		num[i].score0=num[i].score1+num[i].score2;
	}
	for(i=0;i<3;i++)
		for(j=i+1;j<n;j++)
			if(num[i].score0<num[j].score0){
				temp=num[i].score0;
				num[i].score0=num[j].score0;
				num[j].score0=temp;
				temp=num[i].stuno;
				num[i].stuno=num[j].stuno;
				num[j].stuno=temp;
			}
	for(i=0;i<3&&i<n;i++)
		cout<<num[i].stuno<<" "<<num[i].score0<<endl;
	return 0;
}
struct student
{int num;
 int yw;
 int sx;
 struct student *next;
};
void main()
{
	struct student *head,*p1,*p2;
	int i,max,n;
	scanf("%d",&n);
	p1=p2=head=NULL;
	for(i=0;i<n;i++)
	  {p1=(struct student*)malloc(LEN);
	   scanf("%d%d%d",&p1->num,&p1->yw,&p1->sx);
	   if(i==0)head=p1;
	   else p2->next=p1;
	   p2=p1;
	   } 
	 p2->next=NULL;

   for(i=0;i<3;i++)
   {p1=p2=head;
    max=p1->yw+p1->sx;
	while(p1!=NULL)
	   {if((p1->yw+p1->sx)>max)
	       {max=p1->yw+p1->sx;
	        p2=p1;
	       }
	   p1=p1->next;
	   }
	printf("%d %d\n",p2->num,max);
	p1=head;
	while(p1->next!=p2)
	   {p1=p1->next;}
	p1->next=p2->next;
   }
}
int main()
{
    int n,i,j,k,h,b;
    scanf("%d",&n);
    struct sb
    {
         int ID;
         int m;
         int c;
         int sum;
    }a[n];
    for(i=0;i<n;i++)
    {
         scanf("%d%d%d",&a[i].ID,&a[i].m,&a[i].c);
         a[i].sum=a[i].m+a[i].c;
    }
    for(i=0,b=0;i<n;i++)
    {
         if(a[i].sum>b)
         {
             b=a[i].sum;
             h=i;
         }
    }
    printf("%d %d\n",a[h].ID,a[h].sum);
    a[h].sum=-1;
    for(i=0,b=0;i<n;i++)
    {
         if(a[i].sum>b)
         {
             b=a[i].sum;
             h=i;
         }
    }
    printf("%d %d\n",a[h].ID,a[h].sum);
    a[h].sum=-1;
    for(i=0,b=0;i<n;i++)
    {
         if(a[i].sum>b)
         {
             b=a[i].sum;
             h=i;
         }
    }
    printf("%d %d\n",a[h].ID,a[h].sum);
    getchar();
    getchar();
}
int b[100000];

struct student 
	{   int num;
	    int  score1;
		int score2;
		
	}a[100000];

void main()
{   int max(int b[],int n);
	
		int i,j=0,n,c;
  
		scanf("%d",&n);
	
     for (i=0;i<n;i++)
	 {      
		 scanf("%d%d%d",&a[i].num,&a[i].score1,&a[i].score2);
	      b[i]=a[i].score1+a[i].score2;
	 }
	while(j<3)
	{
	       	c=max(b,n) ;
		 for (i=0;i<n;i++)
		 {    
			 if (b[i]==c)
			 {
				 printf("%d %d\n",a[i].num,b[i]);
				 b[i]=0;j=j+1;
				 if (j==3) break;
			 }
			
		 }
	}
	 
       

}
int max(int b[],int n)
{
	int c,i;
	   c=b[0];
      for (i=0;i<n;i++)
	  {
      if (c<b[i])
		  c=b[i];
	  }
	  return(c);
}
int main()
{
 struct {
  int ID;
  int ch,math;
  int sum;
 }a[100000];
 int n,m1,m2,m3,x,y,z;
 scanf("%d",&n);
 scanf("%d %d %d",&a[0].ID,&a[0].ch,&a[0].math);
 m1=a[0].ch+a[0].math;
 int i;
 for(i=0;i<n;i++)
 {
  scanf("%d %d %d",&a[i].ID,&a[i].ch,&a[i].math);
  a[i].sum=a[i].ch+a[i].math;
  if(a[i].sum>m1)
  {
   m1=a[i].sum;
   x=i;
  }
 }
 printf("%d %d\n",a[x].ID,m1);
 a[x].ch=a[x].math=a[x].sum=0;
 int j;
 scanf("%d %d %d",&a[0].ID,&a[0].ch,&a[0].math);
 m2=a[0].sum;
 for(j=0;j<n;j++)
 {
  scanf("%d %d %d",&a[j].ID,&a[j].ch,&a[j].math);
  a[j].sum=a[j].ch+a[j].math;
  if(a[j].sum>m2)
  {
   m2=a[j].sum;
   y=j;
  }
 }
 printf("%d %d\n",a[y].ID,m2);
 a[y].ch=a[y].math=a[y].sum=0;
 int k;
 scanf("%d %d %d",&a[0].ID,&a[0].ch,&a[0].math);
 m3=a[0].sum;
 for(k=0;k<n;k++)
 {
  scanf("%d %d %d",&a[k].ID,&a[k].ch,&a[k].math);
  a[k].sum=a[k].ch+a[k].math;
  if(a[k].sum>m3)
  {
   m3=a[k].sum;
   z=k;
  }
 }
 printf("%d %d\n",a[z].ID,m3);
 return 0;
}
struct student
{
	int number;
	int score1;
	int score2;
};
struct student stu[100000];
int main()
{
	int n,i,first=0,second=0,third=0,a[100000];
	scanf("%d\n",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d %d %d",&stu[i].number,&stu[i].score1,&stu[i].score2);
		a[i]=stu[i].score1+stu[i].score2;
	}
	for(i=0;i<n-1;i++)
	{
		if(a[first]<a[i])
		{
			third=second;
			second=first;
			first=i;
		}
		else if(a[second]<a[i])
		{
			third=second;
			second=i;
		}
		else if(a[third]<a[i])
		{
			third=i;
		}
	}
	printf("%d %d\n%d %d\n%d %d\n",stu[first].number,a[first],stu[second].number,a[second],stu[third].number,a[third]);
	return(0);
}
struct stu
{
	int num;
	int score1;
	int score2;
}
main()
{
	struct stu damn[4];
	int n,i,j,total;
	scanf("%d",&n);
	for(i=0;i<3;i++) scanf("%d %d %d",&damn[i].num,&damn[i].score1,&damn[i].score2);
	for(i=0;i<2;i++)
	{
		for(j=0;j<2-i;j++)
		{
			if(damn[j].score1+damn[j].score2<damn[j+1].score1+damn[j+1].score2)
			{
				damn[3]=damn[j];
				damn[j]=damn[j+1];
				damn[j+1]=damn[3];
			}
		}
	}
	for(i=0;i<n-3;i++)
	{
		scanf("%d %d %d",&damn[3].num,&damn[3].score1,&damn[3].score2);
		if(damn[3].score1+damn[3].score2<damn[2].score1+damn[2].score2) continue;
		else if(damn[3].score1+damn[3].score2<=damn[1].score1+damn[1].score2&&damn[3].score1+damn[3].score2>damn[2].score1+damn[2].score2)
		{
			damn[2]=damn[3];
		}
		else if(damn[3].score1+damn[3].score2<=damn[0].score1+damn[0].score2&&damn[3].score1+damn[3].score2>damn[1].score1+damn[1].score2)
		{
			damn[2]=damn[1];
			damn[1]=damn[3];
		}
		else if(damn[3].score1+damn[3].score2>damn[0].score1+damn[0].score2)
		{
			damn[2]=damn[1];
			damn[1]=damn[0];
			damn[0]=damn[3];
		}

	}
	for(i=0;i<2;i++)
	{
		total=damn[i].score1+damn[i].score2;
		printf("%d %d\n",damn[i].num,total);
	}
	total=damn[i].score1+damn[i].score2;
	printf("%d %d",damn[i].num,total);
}
struct student
	{
		char number[20];
		int chinese;
		int math;
		int sum;
		struct student *next;
	}stu[100000],*s1,*s2,*s3;

int n,max1=0,max2=0,max3=0;


struct student *creat(void)
{
	int i;
	struct student *head,*p1,*p2;
    p1=p2=(struct student*)malloc(LEN);
	for(i=0;i<n;i++)
	{
		scanf("%s%d%d",&p1->number,&p1->chinese,&p1->math);
		p2=p1;
		p1->sum=p1->chinese+p1->math;
		if(p1->sum>max1)
		{max3=max2;s3=s2;max2=max1;s2=s1;max1=p1->sum;s1=p1;}
		else if(p1->sum>max2)
		{max3=max2;s3=s2;max2=p1->sum;s2=p1;}
		else if(p1->sum>max3)
		{max3=p1->sum;s3=p1;}
		if(i==0)head=p1;
		else p2->next=p1;
		
		p1=(struct student*)malloc(LEN);
	}
	p1=NULL;
	return(head);
}

void main()
{
	struct student *p;
	scanf("%d",&n);
	p=creat();
    printf("%s %d\n",s1->number,s1->sum);
	printf("%s %d\n",s2->number,s2->sum);
	printf("%s %d",s3->number,s3->sum);
}
int pfCompare(const void * elem1, const void * elem2)
{
    int c;
    c=*(int*)elem1-*(int*)elem2;
    return c;
}
struct student
{
      int num;
      int x;
      int y;
}a[100000];
main()
{
    int n,i,j,d=0,b[100000],c[100000];
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
                    scanf("%d",&a[i].num);
                    scanf("%d",&a[i].x);
                    scanf("%d",&a[i].y);
    }
    for(i=0;i<n;i++)
    {
                    b[i]=a[i].x+a[i].y; 
    }
    qsort(b,n,sizeof(int),pfCompare);
    for(j=0;j<n;j++)
    {
             if(b[n-1]==a[j].x+a[j].y)
             {
                     printf("%d"" ""%d",a[j].num,b[n-1]);
                     printf("\n");
                     d++;
             }
             if(d==3)
             break;
    }  
    for(i=n-2;i>n-4;i--)
    { 
                  if(b[i]==b[i+1])
                  continue;
                  else
                  {
                                  for(j=0;j<n;j++)
                                  {
                                              if(b[i]==a[j].x+a[j].y)
                                              {
                                                      printf("%d"" ""%d",a[j].num,b[i]);
                                                      printf("\n");
                                                      d++;
                                              }
                                              if(d==3)
                                              break;
                                  }
                                  if(d==3)
                                  break;
                  }
    }
   }
struct student
{
	int num;
	int score1;
	int score2;
	int sum;
	struct student *next;
	struct student *before;
};
main()
{
	int i,n,n1=0,n2=0,n3=0,m1=0,m2=0,m3=0;
	struct student *head;
	struct student *p1,*p2;
	scanf("%d",&n);
	p1=p2=(struct student *)malloc(LEN);
	scanf("%d %d %d",&p1->num,&p1->score1,&p1->score1);
	p1->sum=p1->score1+p1->score2;
	m1=p1->sum;
	n1=p1->num;
	head=0;
	i=0;
	while(i<=n-2)
	{
		i++;
		if(i==1)
			head=p1;
		else
		{
			p1->before=p2;
			p2->next=p1;
		}
		p2=p1;
		p1=(struct student *)malloc(LEN);
        scanf("%d %d %d",&p1->num,&p1->score1,&p1->score2);
		p1->sum=p1->score1+p1->score2;
		if(p1->sum>m3 && p1->sum<=m2)
		{
			m3=p1->sum;
			n3=p1->num;
		}
		if(p1->sum>m2 && p1->sum<=m1)
		{
			m3=m2;
			n3=n2;
			m2=p1->sum;
			n2=p1->num;
		}
		if(p1->sum>m1)
		{
			m3=m2;
			n3=n2;
			m2=m1;
			n2=n1;
			m1=p1->sum;
			n1=p1->num;
		}
	}
	printf("%d %d\n",n1,m1);
	printf("%d %d\n",n2,m2);
	printf("%d %d\n",n3,m3);
}
void main()
{
	struct student
	{
		int xh;
		int yw;
		int sx;
		int zf;
		struct student *next;
	};
	int i,j,k,n,m,max;
	struct student *p1,*p2,*head;
	scanf("%d",&n);
	head=p1=p2=(struct student *)malloc(sizeof(struct student));
	scanf("%d %d %d",&p1->xh,&p1->yw,&p1->sx);
	p1->zf=p1->yw+p1->sx;
	for(i=2;i<=n;i++)
	{
		p1=(struct student *)malloc(sizeof(struct student));
		scanf("%d %d %d",&p1->xh,&p1->yw,&p1->sx);
		p1->zf=p1->yw+p1->sx;
		p2->next=p1;
		p2=p1;
		if(i==n)p1->next=0;
	}
	p1=head;
	for(i=1;i<=3;i++)
	{
		p1=head;
		max=0;
		for(j=1;j<=n;j++)
		{
			max=max>p1->zf?max:p1->zf;
			p1=p1->next;
		}
		//printf("%d\n",max);
		p1=head;
		for(j=1;j<=n;j++)
		{
			if(p1->zf==max)
			{
				printf("%d %d\n",p1->xh,p1->zf);
				p1->zf=0;
				break;
				
			}
			p1=p1->next;
		}
	}
		
}
struct stu
{int xuehao,yuwen,shuxue,sum;
struct stu *next;
};
void max(struct stu *h)
{
	struct stu *a,*b,*c,*d;
	int m=0;
	a=h;
	do
	{
		c=a;
		a=a->next;
		if(m<a->sum)
		{
			m=a->sum;
			d=c;
			b=a;
		}
		}while(a->next);
		printf("%d %d\n",b->xuehao,b->sum);
		d->next=b->next;
		free(b);
}

void main()
{
	struct stu *head,*p,*q;
	int n,i;
	scanf("%d",&n);
	head=M;
	p=M;
	head->next=p;
	for(i=0;i<n;i++){
		scanf("%d %d %d",&p->xuehao,&p->yuwen,&p->shuxue);
		p->sum=p->yuwen+p->shuxue;
	    q=M;
		p->next=q;
		p=q;
	}
	p->next=NULL;
	max(head);
	max(head);
	max(head);
}
struct student
{
	int id;
	int yu;
	int shu;
	struct student *next;
};
void main()
{
    int n,i,j=0;
    
    
	struct student *head,*p1,*p2;
	
	scanf("%d",&n);
	head=p1=p2=(struct student *)malloc(LEN);
	for(i=0;i<n;i++)
	{
		scanf("%d %d %d",&p1->id,&p1->yu,&p1->shu);
		p1=(struct student *)malloc(LEN);
		p2->next=p1;
		p2=p1;
	}
	p2->next=NULL;
	p1=head;
	for(i=200;i>10;i--)
	{
		p1=head;
		while(p1!=NULL)
		{
		    if((p1->yu+p1->shu)==i)
		    {
			    printf("%d %d\n",p1->id,i);
			    j++;
			
		    }
		    p1=p1->next;
		    if(j==3)break;
		}
		if(j==3)break;
	}
}
struct stu
{
	char name[20];
	int sbu[3];
};
int main()
{
       int n;
      scanf("%d",&n);
	int i,j=0,j2=0,j3=0,min=0;
	struct stu stu[100000];
	for(i=0;i<n;i++)
	{
		scanf("%s %d %d",stu[i].name,&stu[i].sbu[0],&stu[i].sbu[1]);
		stu[i].sbu[2]=stu[i].sbu[0]+stu[i].sbu[1];
	}
	
	for(i=0;i<n;i++)
	{		
		if(stu[i].sbu[2]>min)
		{min=stu[i].sbu[2];
		j=i;}
	}
		printf("%s %d\n",stu[j].name,min);
min=0;       
for(i=0;i<n;i++)
	{		
		if(stu[i].sbu[2]<=stu[j].sbu[2]&&stu[i].sbu[2]>min&&i!=j)
		{min=stu[i].sbu[2];
		j2=i;}
	}
		printf("%s %d\n",stu[j2].name,min);
min=0;       
for(i=0;i<n;i++)
	{		
		if(stu[i].sbu[2]<=stu[j2].sbu[2]&&stu[i].sbu[2]>min&&i!=j&i!=j2)
		{min=stu[i].sbu[2];
		j3=i;}
	}
		printf("%s %d\n",stu[j3].name,min);
}
struct
	{
	int x;
	int y;
	int s;
	int z;
	}a[100010],t;
	
int main()
{

	int n,i,j;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d%d%d",&a[i].x,&a[i].y,&a[i].s);
		a[i].z=a[i].y+a[i].s;
	}
	for(i=0;i<=2;i++)
		for(j=n-1;j>=i;j--)
		{
			if(a[j+1].z>a[j].z)
			{
				t=a[j];
				a[j]=a[j+1];
				a[j+1]=t;
			}
		}
printf("%d %d\n",a[0].x,a[0].z);
printf("%d %d\n",a[1].x,a[1].z);
printf("%d %d\n",a[2].x,a[2].z);
return 0;
}
struct student
{
	int num;
    int chinese;
	int maths;
	int sum;};
int main()
{ struct student stu[4]={0,0,0,0};
  struct student temp[4]={0,0,0,0};
  int n,i;
  scanf("%d",&n);
  for(i=0;i<n;i++)
  {
	  scanf("%d%d%d",&stu[3].num,&stu[3].chinese,&stu[3].maths);
	  stu[3].sum=stu[3].chinese+stu[3].maths;
	  //printf("%d",stu[3].chinese);
	  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 Student
{
	int No;
	int Chinese;
	int Maths;
    int Total;
};

void bubble(struct Student a[],int n)
{
	int i,j;
	struct Student temp;
	for(i=0;i<n-1;i++)
	{
		for(j=0;j<n-1-i;j++)
		{
			if(a[j].Total<a[j+1].Total)
			{
				temp=a[j];
				a[j]=a[j+1];
				a[j+1]=temp;
			}
		}
	}
}

int main()
{
	int n,i;
	struct Student stu[4];
	scanf("%d",&n);
	if(n>3)
	{
		for(i=0;i<3;i++)
		{
	    	scanf("%d%d%d",&stu[i].No,&stu[i].Chinese,&stu[i].Maths);
	    	stu[i].Total=stu[i].Chinese+stu[i].Maths;
		}
        for(i=3;i<n;i++)
		{
		    scanf("%d%d%d",&stu[3].No,&stu[3].Chinese,&stu[3].Maths);
			stu[3].Total=+stu[3].Chinese+stu[3].Maths;
			bubble(stu,4);
		}
	}
	else
	{	
		for(i=0;i<n;i++)
		{
	    	scanf("%d%d%d",&stu[i].No,&stu[i].Chinese,&stu[i].Maths);
	    	stu[i].Total=stu[i].No+stu[i].Chinese+stu[i].Maths;
		}
		bubble(stu,n);
	}
	for(i=0;i<n&&i<3;i++)printf("%d %d\n",stu[i].No,stu[i].Total);
	return 0;
}
struct student
{
int num;
int yuwen;
int shuxue;
struct student *next;
};
int m;

void main()
{
int n;
scanf("%d",&n);

struct student *creat(int n);
void print(struct student *head,int n);

struct student *head;
head=creat(n);
print(head,n);
print(head,n);
print(head,n);
}

struct student *creat(int n)
{
struct student *head;
struct student *p1,*p2;
m=0;
p1=p2=(struct student*)malloc(LEN);
scanf("%d %d %d\n",&p1->num,&p1->yuwen,&p1->shuxue);
head=NULL;
for(;n!=0;n--)
{
 m+=1;
 if(m==1)head=p1;
 else p2->next=p1;
 p2=p1;
 p1=(struct student*)malloc(LEN);
 scanf("%d %d %d\n",&p1->num,&p1->yuwen,&p1->shuxue);
 }
p2->next=NULL;
return(head);
}


void print(struct student *head,int n)
{
struct student *p,*q;
p=head;
int max=0,index=0;
for(;n!=0;n--)
{
 if(max<((p->yuwen)+(p->shuxue)))
 {
 max=((p->yuwen)+(p->shuxue));
 index=p->num;
 q=p;
  }
 p=p->next;
 }
printf("%d %d\n",index,max);
q->yuwen=0;
q->shuxue=0;
}
void main()
{
    struct student
    {
    	long num;
    	int chinese;
    	int math;
    };
    struct student stu[100001];
    int i,t,h,l=0;
    long n;
    int a[100001];
    scanf("%ld",&n);
    for(i=0;i<n;i++)
    scanf("%d%d%d",&stu[i].num,&stu[i].chinese,&stu[i].math);
    for(i=0;i<n;i++)
    a[i]=stu[i].chinese+stu[i].math;
    leap:
    t=a[0];
    h=0;
    for(i=1;i<n;i++)
    {
    	if(a[i]>t)
    	{
    		t=a[i];
    	    h=i;
    	}
    }
    printf("%ld %d\n",stu[h].num,a[h]); 
    l++;
    a[h]=0;
    if(l<3)
    goto leap; 
}
int main(int argc, char* argv[])
{
	int x,i,n,m=0,j=0,k=0,s,l1,l2,l3;
	int a[100000],b[100000];
	scanf("%d",&n);
	for (i=1;i<=n;i++)
	{
		scanf("%d%d%d",&x,&(a[i]),&(b[i]));
		s=a[i]+b[i];
		if(s>m)
		{
			
			j=m;
			m=s;
			l2=l1;
			l1=i;}
		else if(s>j)
		{
		k=j;
		j=s;
		l3=l2;
		l2=i;}
		else if(s>k)
		{	k=s;
		l3=i;}
	}
	printf("%d %d\n",l1,m);
	printf("%d %d\n",l2,j);
	printf("%d %d\n",l3,k);
	return 0;
}