semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int main()
{
 int N;
 scanf("%d",&N);   
 int a[N],b[N];
 int i,j,k,n,m = 0,flag;
 for(i = 0; i <= N; i++)
  scanf("%d",&a[i]);
 for(i = 0; i < N; i++)
 {
  flag = 1;
  for(j = 1; j <= m; j++)
   if(a[i] == b[j])
   {
    flag = 0;
    break;
   }
   if(flag)
   {
    b[j] = a[i];
    m++;
   }
 }
 printf("%d",b[1]);
 for(i = 2; i <= m; i++)
  printf(" %d",b[i]);
}
/*
 * homework1106.cpp
 *
 *  Created on: 2012-11-5
 *      Author: wangyinzhi
 */

int main(){
	int n,i,k;
     cin>>n;
	int a[n];
	for(i=0;i<=n-1;i++){
		cin>>a[i];//????
	}
	for(i=1;i<=n-1;i++){
	   for(k=0;k<=i-1;k++){
		   if(a[i]==a[k]){
			   a[i]=0;
			   break;//???????????????0
		   }
		   }
	   }

	for(i=0;i<=n-1;i++){
		if(a[i]!=0){
		if(i==0){
			cout<<a[i];
		}
		else cout<<" "<<a[i];//????0???????????
	}
	}

	return 0;
}
void main()
{int n,i,j,k,m=0;;
 int a[20001];
 scanf("%d",&n);
 for(i=0;i<n;i++)
 scanf("%d",&a[i]);
 for(i=0;i<n-1-m;i++)
  for(j=i+1;j<n-m;)
   if(a[j]==a[i])
   {for(k=j;k<n-m;k++)
    a[k]=a[k+1];
    m++;}
   else j++;
  for(i=0;i<n-1-m;i++)
  printf("%d ",a[i]);
  printf("%d",a[n-m-1]);
}
int main()
{
	int a[20001]={0};//????a[20001],??a[n]????0
	int n=0;//?????n
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];//?n????
	}
    int b[20001]={0};//????b[20001],??b[n]????0
	int c[20001]={0};//????c[20001],??c[n]????0
	int l=1;//??l
	for(int j=1;j<=n;j++)
	{
		for(int k=0;k<j;k++)
		{
			if(a[j]==a[k])
			{
				b[j]=1;
				//????????,b[j]??
			}
		}
	}
	for(int p=1;p<=n;p++)
	{
	    if(b[p]==0)
		{
			c[l]=a[p];
			l=l+1;//?????????????????c[l]
		
		}
	}
	for(int m=1;c[m]>0;m++)
	{
		if(c[m+1]>0)//?c[m]??????
			cout<<c[m]<<" ";//??c[m]???
		if(c[m+1]==0)//?c[m]?????
			cout<<c[m]<<endl;//???c[m]
	}
	return 0;
}
int main()
{
	int a[20000],i,j,n;
	scanf("%d",&n);
	
	for(i=0;i<n;i++)
		scanf("%d",&a[i]);
	printf("%d",a[0]);

	for(i=0;i<n;i++)
		for(j=0;j<n;j++)
		{
			if(a[i]==a[j]) break;
		
		if(j==i-1)
		{
			printf(" ");
			printf("%d",a[i]);
		}
		}
			
		

	return 0;
}
int main()
{
    int n;
    int i;
    int buf;
    int appeared[110] = {0};
    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%d", &buf);
        if (!appeared[buf]) {
            if (i != 0) {
                printf(" ");
            }
            printf("%d", buf);
            appeared[buf] = 1;
        }
    }
    return 0;
}
/*
 * unseennum.cpp
 *
 *  Created on: 2013-11-5
 *      Author: ???
 */

int main()
{int a[20000];
int n,i,j,l,k;
cin>>n;
l=n;
for(i=0;i<n;i++)
	cin>>a[i];

for(i=0;i<l-1;i++)
{
	for(j=i+1;j<l;j++)
	{
		if(a[i]==a[j])
		{for(k=j;k<l-1;k++)
			a[k]=a[k+1];
		j--;
		l--;
		}
	}

}
cout<<a[0];

for(i=1;i<l;i++)
	cout<<' '<<a[i];
return 0;

}
int main()
{
	int n,i,j,k,l,a,b;
	scanf("%d",&n);
	int num[20000];
	int	res[20000];
	for(i=0;i<n;i++)
		scanf("%d",&num[i]);
	b=0;
	k=0;
	for(i=0;i<n;i++)
	{
		a=num[i];
		for(j=0;j<=i;j++)
		{
			if(i==j)
			{
				b=a;
				continue;
			}
			if(a!=num[j])
				b=a;
			else
			{
				b=0;
				break;
			}
		}

		if(b!=0)
		{
			k++;
			res[k]=b;
		}
	}
	for(l=1;l<=k;l++)
	{
		if (l!=k)
			printf("%d ",res[l]);
		else
			printf("%d",res[l]);
	}
	return 0;
}
/*
 *shuchubuchongfushuzi.cpp
 *?????n????n???????????????10-100???
 *???????????????????????????????????????????
 *Created on: 2012-11-11
 *Author: ??
 */
int main() {
	int n = 0;
	int shuru[100000];
	cin >> n;
	for (int i = 0; i < n; i++) {//????
		cin >> shuru[i];
		if (getchar() == '\n')
			break;
		else
			continue;
	}
	cout << shuru[0];

	for (int i = 1; i < n; i++) {//??????
		int jishu = 0;
		for (int j = 0; j < i; j++) {
			if (shuru[i] == shuru[j])
				break;
			else {
				jishu++;
			}
		}
		if (jishu == i)//????????
			cout << ' ' << shuru[i];
		else
			continue;
	}
	return 0;
}
int main()
{
	int N, c, b = 1;
	cin >> N;
	int a[20001];
	for (int i = 1; i <= N; i ++)
		cin >> a[i];
	for (int m = 2; m <= N; m ++)
	{
		for (c = 1;c <= b; c ++)
		{
			if (a[m] == a[c]) break;
		}
		if (c == b + 1)
		{
			b ++;
			a[b] = a[m];
		}		
	}
	cout << a[1];
	for (int d = 2; d <= b; d ++)
		cout << " " << a[d];
	return 0;
}
int main()
{
    int a[20000];
	int i,j,n,k;
    k=0;
    scanf("%d",&n);
	
	n=n-1;
	for(i=0;i<=n;i++)
	   scanf("%d",&a[i]);

	for(i=0;i<n;i++)
	{
	  for(j=i+1;j<=n;j++)
		  if(a[j]==a[i]) a[j]=0;
	}
    
    printf("%d",a[0]);
	    for(i=1;i<=n;i++)
		{
			if(a[i]!=0) 
			{
			   printf(" %d",a[i]);
			}
		}

	return 0;
}
int main()
{
    int c,a[20000],n,i,l=0,p,k=0,j; 
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
       l=0;//l?????????????????? 
       scanf("%d",&c);
       for(j=0;j<k;j++)//?????????????????????? 
       {
       if (c==a[j])//????????????????? 
       l=l+1;
       }
       if(l==0)
       {
       a[k]=c;
       k++;
       }
    }
    for(i=0;i<k;i++)
    {
    if(i==0)
    printf("%d",a[i]); 
    else
    {
    printf(" %d",a[i]);
    }
    }
    getchar();
    getchar();
}
int main()
{
	int n,a[20000];
	scanf("%d",&n);
	int i,j;
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	printf("%d",a[0]);
	for(i=1;i<n;i++)
	{
		for(j=0;j<i;j++)
		{
			if(a[i]==a[j])
				break;
		}
		if(j==i)
			printf(" %d",a[i]);
	}
	return 0;
}
int main(){
	int all,name[20000],input[20000],i,p,count,judge;
	scanf("%d",&all);
	count=0;
	for(i=0;i<all;i++){name[i]=0;}
	for(i=0;i<all;i++){scanf("%d",&input[i]);}
	for(i=0;i<all;i++){
		judge=0;
		for(p=0;p<count;p++){if(name[p]==input[i]){judge=1;break;}}
		if(judge==1){continue;}
		name[count]=input[i];
		count++;
	}
	printf("%d",name[0]);
	for(i=1;i<count;i++){printf(" %d",name[i]);}

return 0;
}
int main()
{
int i,j,n,p=0,m[20000];
scanf("%d\n",&n);
for(i=0;i<n;i++)
scanf("%d",&m[i]);
for(i=0;i<n;i++)
{
	j=0;
	while(j<i)
	{
		if(m[i]==m[j])
			break;
		j++;
	}
	if(j==i)
	{
	if((i<n)&&(i>0))
		printf(" ");
	printf("%d",m[i]);
	p++;
	}
}
return 0;
}
int main()
{
	int n,b,a[20000],i,j;
	scanf("%d",&n);
	scanf("%d",&a[0]);
	printf("%d",a[0]);
	for(i=1;i<n;i++)
	{
		scanf("%d",&b);
		a[i]=b;
		for(j=0;j<i;j++)
		{
			if(a[i]==a[j])
				a[i]=0;
		}
	}
	for(i=1;i<n;i++)
	{
		if(a[i]!=0)
			printf(" %d",a[i]);
	}
	printf("\n");
	return 0;
}
// ???????
int main()
{
	int n, a, i, j, k = 1, num[20000]; // ???????num[20000]?a????????i,j,k???????
	cin >> n; // ??????
	cin >> a; 
	num[0] = a; // ???????num[0]
	for (i = 1; i < n; i++)
	{
		cin >> a; // ????
		for (j = 0; j < k; j++)
		{
			if (a == num[j]) 
				break; // ???????????????
		}
		if (j == k) // ??????
		{
			num[k] = a; // ????????
			k = k + 1;
		}
	}
	for (i = 0; i <= k - 2; i++)
		cout << num[i] << " "; // ??????????????
	cout << num[k - 1]; // ???????
	return 0;
}
void main()
{
     int n,l,i,j,x;
     scanf("%d",&n);
     l=0;
     int a[20000];
     for(i=0;i<n;i++)
     scanf("%d",&a[i]);
     for(j=0;j<n;j++)
     {
                      for(i=(j+1);i<n;i++)
       {
                         if(a[j]==a[i])
                         a[i]='*';
       }
     }
      if(a[n-1]!='*')
      {
                      for(i=0;i<n-1;i++)
          { 
                      if(a[i]!='*')
                       printf("%d ",a[i]);
         }
         printf("%d",a[n-1]);
      }
    else
     {
          for(i=n-1;i>0;i--)
      {
                        if(a[i]=='*')l=l+1;
                        else break;
      }
          for(j=0;j<n-l-1;j++)
          { 
                      if(a[j]!='*')
                       printf("%d ",a[j]);
         }
         printf("%d",a[n-l-1]);
     }
    
      
       
    
    

}
int main () {
	int n,k;
	int flag=0;
	int i;
	scanf("%d",&n);
	int *shuzu=(int*)malloc(sizeof(int)*n);
	for(i=0;i<n;i++){
		scanf("%d",&shuzu[i]);
	}
	printf("%d",shuzu[0]);
	for(i=1;i<n;i++){
		for(k=0;k<i;k++){
			if(shuzu[i]==shuzu[k]){
				flag=1;
				break;
			}
		}
		if(flag==0){
			printf(" %d",shuzu[i]);
			}
		flag=0;
	}
	free(shuzu);
	return 0;

}
int main()
{
    int u[20000];
    int a,n,i,j,k,l;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&u[i]);
    }
   k=0;
   for(i=0;i<n;i++)
    {
        for(j=i+1;j<n;j++)
        {
            if(u[i]==u[j])
            {
                u[j]=0;
               
            } 
        }
    }
    for(i=0;i<n;i++)
    {
        if(u[i]!=0)
        {
            k++;
        }
    }
    i=0;
    l=0;
    while(i<n)
    {
        if(u[i]!=0)
        
        {
            if(l<k-1)
            {
                printf("%d ",u[i]);
                l++;
            }
        
        else
            {
                printf("%d",u[i]);
            }
        }
    i++;
    }


    return 0;
}
/*
 * practice.cpp
 *???
 *  Created on: 2011-11-5
 *      Author: ???
 */
int main ()
{
  int i,n,a[1000]={0},j,k,m;
  cin>>n;
  cin>>a[1];
  for (i=2,m=2;m<=n;i++,m++)
  {
	  cin>>a[i];
	  for (j=1;j<i;j++)
	  {
		  if (a[i]==a[j])
		  {
			  i--;
			  break;
		  }
	  }
  }
  cout<<a[1];
  for (k=2;k<=i-1;k++)
	  cout<<' '<<a[k];
	return 0;
}
int main()
{
	int n;
	cin >> n;
	int count[100] = {0}, num[90] = {0};
	int i = 1, a, j = 0;
	for (i; i <= n; i++)
	{
		cin >> a;
		if (count[a] == 0)
		{
			num[j] = a;
			j += 1;
		}
		count[a] = count[a] + 1;
	}
	i = 0;
	for (i; i < j - 1; i++)
	{
		cout << num[i] << " ";
	}
	cout << num[j - 1] << endl;
	return 0;
}
/**
* ???1000012847
* ??????
* ???????????
* ?????n????n???????????????10-100??? 
* ???????????????????????????????????????????
*/

int main()
{
	//??n????????a[20000]????????i?num??????count[20000]????????
	int n , a[20000] ,i , num , count[20000] = {0};

	cin >> n;                   //??????????n

	for (i = 0; i < n; i ++)      
	{
		cin >> a[i];             //????n??
		num = a[i];              //?num??a[i]
		count[num] ++;           //num???1
		
		if (i == 0)               //???????????
			cout << a[i];
		else                     //????????
		{
			if (count[num] == 1)      //??num???1????num                    
				cout << " " << num;
		}		
	}

	cout << endl;                 //??????
	return 0;
}
int BT(int x,int a[40000])
{
    int b=0,c=0;
    while(b<40000)
    {
                 if(a[b]==x)
                 {
                            c=1;
                            break;
                 }
                 else
                 b++;
    }
    return c;
}
main()
{
      int n,a[40000],i,b[40000],c;
      scanf("%d",&n);
      for(i=0;i<n;i++)
      scanf("%d",&a[i]);
      for(i=0;i<10001;i++)
      b[i]=-1;
      for(i=0,c=0;i<n;i++)
      if(BT(a[i],b)==0)
      {
                       if(c==0)
                       printf("%d",a[i]);
                       else
                       printf(" %d",a[i]);
                       b[c]=a[i];
                       c++;
      } 
      getchar();
      getchar();
}
int main()
{
	int n,i,a[20001]={0},j,l;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	for(i=0;i<n;i++)
	{
		for(l=(i+1);l<n;l++)
		{
			if(a[l]==a[i])
			{
				for(j=(l+1);j<n;j++)
				{
					a[j-1]=a[j];
				}
			l-=1;
			n--;
			}
		}

	}
	for(i=0;i<n;i++)
	{
		if(i==0)
			printf("%d",a[i]);
		else
			printf(" %d",a[i]);
	}

	return 0;

}
int main()
{
	int n;
	int a[20000];
	int i,j;
	int t;
	int l=1;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	if(n==1)
	{
		printf("%d",a[0]);
		return 0;
	}
	printf("%d",a[0]);
	t=n;
	for(i=0;i<n;i++)
	{
		for(j=0;j<i;j++)
		{
			if(a[i]==a[j])
			{
				t=t-1;
				break;
			}
			
		}
		
	}
	for(i=0;i<n;i++)
	{
		for(j=0;j<i;j++)
		{
			if(a[i]==a[j])
			{
				break;
			}
			else if(j==i-1&&l<t)
			{	
			
			    printf(" %d",a[i]);
			}
		
			
				
			
		}
		
	}


	return 0;
}
main()
{
      int m,n,i,j;
      int a[20000];
      int count=0;
      scanf("%d",&n);
      for(i=0;i<n;i++)
      scanf("%d",&a[i]);
      printf("%d",a[0]);
      for(i=1;i<n;i++)
      {
                      int count=0;
                      for(j=0;j<i;j++)
                      {
                      if(a[i]==a[j])
                      count++;
                      }
                      if(count==0)
                      printf(" %d",a[i]);
      }
      getchar();
      getchar();
      getchar();
      getchar();
      getchar();
}
int main()
{
	int n;cin >> n;
	int m = 0;
	int a[20001];
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	for (int i = 2; i <= n; i++)
		for (int j = i - 1; j >= 1; j--)
		{
			if (a[i] == a[j])
				a[i] = 0;
		}
	cout << a[1];
	for (int i = 2; i <= n; i++)
		if (a[i] != 0)
			cout << " " << a[i];
	return 0;
}
int main()
{
    int n,i,c;
    int a[101]={0};
    cin >>n;
    cin>>c;
    a[c]=1;
    cout<<c;
    while(cin>>c)
    {
        if(a[c]==0)
        {
          cout <<" "<<c;
          a[c]=1;
        }
   }
//for (;;) ;          
    return 0;
}
int main()
{
   int n,i=1,k;
   cin>>n;
   int a[20000];   //??????????
   cin>>a[0];            //?????????????
   while(cin>>a[i])    
   {
	   i++;
	   if(i==n) break;
   }                   //??????????n???
   cout<<a[0];    //???a[0]
   i=1;
   while(i<n)
   {
	   int mid=0;
	   for(k=0;k<i;k++)
	   {	
		   if(a[i]==a[k])
		   {
			   mid=1;break;}        //?a[i]???????????????
	   }
	   if(mid==0)
		   cout<<" "<<a[i];      //???????a[i]
       i++;
   }
   cout<<"\n";
   return 0;
}
/*
 * practice.cpp
 *
 *  Created on: 2014-1-4
 *      Author: 111
 */

int main()
{
	int n;
	cin >> n;
	int str[20001];
	for(int i=0;i<n;i++)
		cin >> str[i];
	int num =0;
	for(int i=1;i<n-num;i++){
		for(int j=0;j<i;j++)
			if(str[j]==str[i]){
				for(int k=i;k<n-1-num;k++)
					str[k] = str[k+1];
				num++;
				//cout << num << endl;
				i--;
				break;
			}
	}
	cout << str[0];
	for(int i=1;i<n-num;i++)
		cout << ' ' << str[i];
	cout << endl;
	return 0;
}
int a[100000];
int n;
void del_a(int x)
{
	for(int i=x;i<n-1;i++)
	{
		a[i]=a[i+1];
	}
	a[n-1]=0;
	n=n-1;

}
int main()
{
cin>>n;
for(int i=0;i<n;i++)
{
cin>>a[i];
}
for(int i=1;i<n;i++)
{
for(int j=0;j<i;j++)
{
if(a[i]==a[j])
{
del_a(i);
i=i-1;
break;
}
}
}
for(int i=0;i<n-1;i++)
{
cout<<a[i]<<" ";
}
cout<<a[n-1];
return 0;
}
//???????????
//?????? 1000012918
//???10.28
//???
int main()
{
	int n, count[101] = {0}, num;            //count[num]???num????????????0
	cin >> n;
	for (int i = 1; i <= n; i ++)
	{
		cin >> num;  
		if (count[num] == 0)                     //?????????
			if (i == 1)
				cout << num;
			else
			cout << " " << num;
			count[num]++;                       //?????????1
	}
	return 0;
}
int main ()
{
	int n, t, i, j, m;
	cin >> n;
	int a[20000] = {0}; // ????
	cin >> t;
	cout << t;
	m = 1;         //m??????????
	a[0] = t;        //??????????
	for (i = 2; i <= n; i++)
	{
		cin >> t;
		for ( j = 0; j < m; j ++)  
		{
			if ( a[j] == t)    // ????????
				break;
		}
		if ( j >= m ) // ????????????
		{
			cout << ' ' << t;
			a[m] = t;
			m ++;
		}
	}
	return 0;
}
struct student
{
	int num;
	int yw;
	int sx;
	int zong;
}stu[100001];

int main(int argc, char* argv[])
{
	int i,n,max1=0,max2=0,max3=0,fir,sec,thi;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d %d %d",&stu[i].num,&stu[i].yw,&stu[i].sx);
		stu[i].zong=stu[i].yw+stu[i].sx;
		if(stu[i].zong>max1){
			max3=max2;
			thi=sec;
			max2=max1;
			sec=fir;
			max1=stu[i].zong;
			fir=i;
		}else if(stu[i].zong>max2){
			max3=max2;
			thi=sec;
			max2=stu[i].zong;
			sec=i;
		}else if(stu[i].zong>max3){
			max3=stu[i].zong;
			thi=i;
		}
	}

	printf("%d %d\n",stu[fir].num,stu[fir].zong);
	printf("%d %d\n",stu[sec].num,stu[sec].zong);
	printf("%d %d\n",stu[thi].num,stu[thi].zong);
	return 0;
}
struct stu
{
	int num;
	int mark1;
	int mark2;
	long int total_mark;
};

int main(void)
{
	int n,i,j,k,t=0,max;
	struct stu *p;
	struct stu *q;
	scanf("%d",&n);
	p=(struct stu *)malloc(1000000*sizeof(struct stu));
	q=p;
	for(i=0;i<n;i++)
	{
		scanf("%d %d %d",&(p+i)->num,&(p+i)->mark1,&(p+i)->mark2);
		(p+i)->total_mark=(p+i)->mark1+(p+i)->mark2;
	}
loop:	max=0;
		for(j=0;j<n;j++)
		{
			if((p+j)->total_mark>max)
	               max=(p+j)->total_mark;
		}
		for(k=0;k<n;k++)
			if(max==(p+k)->total_mark&&k<n)
			{
		        printf("%d %ld\n",(p+k)->num,(p+k)->total_mark);
			 	t++;   
				(p+k)->total_mark=0;
				break;
			}
		if(t<3) goto loop;
}
struct student
{
	int num;
	int yu;
	int shu;
	struct student *next;
};

void main()
{
	struct student *head,*p1,*p2;
	int n,i,j,k;
	scanf("%d",&n);
	head=p1=p2=(struct student*)malloc(LEN);
	scanf("%d %d %d",&p1->num,&p1->yu,&p1->shu);
	for(i=1;i<n;i++)
	{
		p1=(struct student*)malloc(LEN);
		scanf("%d %d %d",&p1->num,&p1->yu,&p1->shu);
		p2->next=p1;
		p2=p1;
	}
	p2->next=NULL;
	for(i=1;i<=3;i++)
{	p1=p2=head;
	while(p1!=NULL)
	{
		if(p1->yu+p1->shu>p2->yu+p2->shu)
			p2=p1;
		p1=p1->next;
	}
	printf("%d %d\n",p2->num,p2->yu+p2->shu);
	p2->yu=0;
	p2->shu=0;
}
	
}
void main()
{
	int mat,chi,i,num;
	struct stu{
		int id;
		int to;
	}s[100001],temp1,temp2,max1,max2,max3;
	scanf("%d",&num);
	for(i=0;i<num;i++){
		scanf("%d %d %d",&s[i].id,&chi,&mat);
		s[i].to=chi+mat;
	}
	if(s[0].to>s[1].to&&s[1].to>s[2].to){max1=s[0];max2=s[1];max3=s[2];}
	else if(s[2].to>s[0].to&&s[0].to>s[1].to){max1=s[2];max2=s[0];max3=s[1];}
	else if(s[0].to>s[2].to&&s[2].to>s[1].to){max1=s[0];max2=s[2];max3=s[1];}
	else if(s[2].to>s[1].to&&s[1].to>s[0].to){max1=s[2];max2=s[1];max3=s[0];}
	else if(s[1].to>s[0].to&&s[0].to>s[2].to){max1=s[1];max2=s[0];max3=s[2];}
	else {max1=s[1];max2=s[2];max3=s[0];}
	for(i=0;i<num-1;i++){
		if(s[i].to>max1.to){
			temp1=max1;
			temp2=max2;
			max1=s[i];
			max2=temp1;
			max3=temp2;
		}
		else if(s[i].to>max2.to&&s[i].id!=max1.id){
			temp1=max2;
			max2=s[i];
			max3=temp1;
		}
		else if(s[i].to>max3.to&&s[i].id!=max2.id&&s[i].id!=max1.id)max3=s[i];
	}
	printf("%d %d\n%d %d\n%d %d\n",max1.id,max1.to,max2.id,max2.to,max3.id,max3.to);
}
int main()
{
    int i,n; 
    struct{
       int id,chi,math,sum;
    } s,s1,s2,s3;
    s1.sum=s2.sum=s3.sum=0;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d%d%d",&s.id,&s.chi,&s.math);
        s.sum=s.chi+s.math;
        if(s.sum>s1.sum)
        {
            s3=s2;s2=s1;s1=s;
        }
        else if(s.sum>s2.sum)
        {
             s3=s2,s2=s;
        }
        else if(s.sum>s3.sum)
        {
             s3=s;
        }
    }
    printf("%d %d\n%d %d\n%d %d\n",s1.id,s1.sum,s2.id,s2.sum,s3.id,s3.sum);
    getchar();
    getchar();
    getchar();
    return 0;
}
struct student{ int num;int a;int b;int c;};
void main()
{
	  int n,i,j,m,t;
      struct student stu[100000];
	  scanf("%d",&n);
	  for(i=0;i<n;i++)
	  {scanf("%d %d %d",&stu[i].num,&stu[i].a,&stu[i].b);
	  stu[i].c=stu[i].a+stu[i].b;}
	  for(i=0;i<3;i++)
		  for(j=i+1;j<n;j++)
		  {
			  if(stu[i].c<stu[j].c){
				  t=stu[i].c;stu[i].c=stu[j].c;stu[j].c=t;
				  m=stu[i].num;stu[i].num=stu[j].num;stu[j].num=m;}
		  }
		  for(i=0;i<3;i++)
			  printf("%d %d\n",stu[i].num,stu[i].c);
}
int main(int argc, char* argv[])
{
	int n;
	scanf("%d",&n);
	struct stu{
	    int id; 
		int x,y;
	    
	
	}stu[100000];
	int no1=0;
	int no2=0;
	int no3=0;
	int i;
	int N1,N2,N3;
	for(i=0;i<n;i++)
	{
		scanf("%d%d%d",&stu[i].id,&stu[i].x,&stu[i].y);
	}
    for(i=0;i<n;i++)
	{
		if((stu[i].x+stu[i].y)>no1){no2=no1;no1=(stu[i].x+stu[i].y);N2=N1;N1=i;}
        else if((stu[i].x+stu[i].y)>no2){no3=no2;no2=(stu[i].x+stu[i].y);N3=N2;N2=i;}
		else if((stu[i].x+stu[i].y)>no3){no3=(stu[i].x+stu[i].y);N3=i;}
	}
	printf("%d %d\n%d %d\n%d %d",stu[N1].id,(stu[N1].x+stu[N1].y),stu[N2].id,(stu[N2].x+stu[N2].y),stu[N3].id,(stu[N3].x+stu[N3].y));

	return 0;
}
struct student
{long num;
 int math;
 int chinese;
 int sum;
 struct student *next;
};
long n;

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

struct student *del(struct student *head,int max)
{
	struct student *p1,*p2;
	p1=head;
	while (p1->sum!=max&&p1->next!=0)
	{
		p2=p1;p1=p1->next;
	}
	if(p1->sum==max)
	{
		if(p1==head) head=p1->next;
		else p2->next=p1->next;
		n=n-1;
	}
	return(head);
}

void print(struct student *head)
{
	struct student *p1,*p2;
	int i,max,num;
	max=head->sum;
	p1=head;
	p2=p1->next;
	for(i=1;i<=3;i++)
	{
	 while(p1->next!=0)
	 {
		 if((p2->sum)>max) {max=p2->sum; num=p2->num;}
		 p1=p2;
		 p2=p1->next;
	 }
	 printf("%ld %d\n",num,max);
	 head=del(head,max);
	 p1=head;
	 p2=p1->next;
	 max=p1->sum;
	}

}

//void print (struct student*head)
//{
//	struct student *p;
//	p=head;
//	if(head!=0)
//		do
//		{
//			printf("%ld %d %d %d\n",p->num,p->math,p->chinese,p->sum);
//			p=p->next;
//		}while (p!=0);
//}
main()
{
	struct student *head;
	head=creat();
	print(head);
}
void main()
{
	struct stu
	{
		int  num;
		int chinese;
		int math;
		int sum;
		struct stu*next;
	};
	int n,max,i;
	struct stu *p1,*p2,*head,*maxsum;
	scanf("%d",&n);
	p1=p2=(struct stu*)malloc(LEN);
	scanf("%d %d %d",&p1->num,&p1->chinese,&p1->math);
	for(i=1;i<n;i++)
	{
		if(i==1)
			head=p1;
		else p2->next=p1;
		p2=p1;
		p1=(struct stu*)malloc(LEN);
		scanf("%d %d %d",&p1->num,&p1->chinese,&p1->math);
	}
	p2->next=p1;
	p2=p1;
	p2->next=NULL;
	
	p1=head;
	while(p1->next!=NULL)
	{
		p1->sum=p1->chinese+p1->math;
		p1=p1->next;
	}
	p1->sum=p1->chinese+p1->math;
	for(i=1;i<=3;i++)
	{
		p1=head;
	    max=p1->sum;
		maxsum=p1;
	    while(p1->next!=NULL)
		{
		  if(p1->sum>max)
		  {
			maxsum=p1;
			max=p1->sum;
		  }
		  p1=p1->next;
		  
		}
		if(p1->sum>max)
		  {
			maxsum=p1;
			max=p1->sum;
		  }
	  printf("%d %d\n",maxsum->num,maxsum->sum);
	  maxsum->sum=0;
	}
}
struct stu{
	int ID;
	int ch;
	int ma;
	int sum;
	struct stu *next;
	};
int main(){
	struct stu *head;
	struct stu *p1,*p2,*a,*b,*c,*t;
	int n,i=0;
	a=b=c=p1=p2=(struct stu *) malloc(sizeof(struct stu));
	scanf("%d",&n);
	scanf("%d%d%d",&p1->ID,&p1->ch,&p1->ma);
	p1->sum=p1->ch+p1->ma;
	head=NULL;
	while(i<n-1){
		i++;
		p1->sum=p1->ch+p1->ma;
		if(i==1)head=p1;
		else p2->next=p1;
		p2=p1;
		if(p1->sum>a->sum) {c=b;b=a;a=p2;}
		else if(p1->sum>b->sum) {c=b;b=p2;}
		else if(p1->sum>c->sum) c=p2;
		p1=(struct stu *) malloc(sizeof(struct stu));
		scanf("%d%d%d",&p1->ID,&p1->ch,&p1->ma);
	}
	p2->next=NULL;
	printf("%d %d\n%d %d\n%d %d\n",a->ID,a->sum,b->ID,b->sum,c->ID,c->sum);
	return 0;
}
//#define NULL 0
struct student
{
	int num;
	int ch;
	int math;
	int sum;
	struct student*next;
};

struct student *creat(int n)
{
	struct student *head;
	struct student *p1,*p2;
	int i;
	p1=p2=(struct student *)malloc(sizeof (struct student));
	scanf("%d %d %d",&p1->num,&p1->ch,&p1->math);
	//head=NULL;
	for(i=0;i<n-1;i++)
	{
		if(i==0)head=p1;
		
		p1=(struct student*)malloc(sizeof(struct student));
		scanf("%d %d %d",&p1->num,&p1->ch,&p1->math);
		p2->next=p1;
		p2=p1;
	}
	
	p2->next=NULL;
	return (head);
}
void print(struct student*head)
{
	struct student*p;
	p=head;
	if(head!=NULL)
		do
		{
			printf("%d %d %d",p->num,p->ch,p->math);
			p=p->next;
		}while(p!=NULL);
}

main()
{
	int n,i,j,k,t;
	struct student *p1,*p2,*p3,*p;
	struct student g;
	scanf("%d",&n);
	p=creat(n);p1=p;
	
	p2=p;p3=p;
	for(i=0;i<n;i++)
	{
		p1->sum=p1->math+p1->ch;
        //printf("%d\n",p1->sum);
		p1=p1->next;
		
	}
    p1=p;p2=p;printf("\n\n");
	i=0;
	while(i<3)
	{
		p1=p2->next;
		while(p1!=NULL)
		{
			
			if((p2->sum)<(p1->sum)) 
			{
				g.num=p2->num;
				p2->num=p1->num;
				p1->num=g.num;
                g.sum=p2->sum;
				p2->sum=p1->sum;
				p1->sum=g.sum;
			}
			p1=p1->next;
			
		}
		
		p2=p2->next;i=i+1;
		
	}
	p1=p;p2=p;
	//printf("\n\n");
    /*for(i=0;i<n;i++)
	{
		
        printf("%d\n",p1->sum);
		p1=p1->next;
		
	}*/
	p1=p;
	for(i=0;i<3;i++)
	{
		
		printf("%d %d\n",p1->num,p1->sum);
		p1=p1->next;
	}
}