semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
/*/?? - ?????   
 
?? ??-From Whf 
?? 
?? n ???????????????????????????????????????????????????????????????????n ???300 
????6???3?6?7?1?5?4????? 26/6=4.33?? 1 ??????
 
???? 
?1????????? n? 
?2???? n ?????????????? 

 
???? 
???????????????????????????????????????????????????
 
???? 
7
1 2 3 4 5 6 7
 
???? 
1,7
 
/*/
void main(){
	int n,a[300],sum=0,i,j,temp,sign=0;
	float p,dis;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
		sum=sum+a[i];
	}
	p=(float)(sum)/n;
	for(i=0;i<n;i++){
		for(j=0;j<n-1-i;j++){
			if(a[j]>a[j+1]){
				temp=a[j];
				a[j]=a[j+1];
				a[j+1]=temp;
			}
		}
	}
	//printf("%f",p);
	if(p-(float)a[0]==(float)a[n-1]-p){
		for(i=0;i<n;i++){
			if(a[i]==a[0])
				if(sign==0){
					printf("%d",a[i]);
					sign=1;
				}
				else{
					printf(",%d",a[i]);
					
				}
			if(a[i]==a[n-1])
				if(sign==0){
					printf("%d",a[i]);
					sign=1;
				}
				else{
					printf(",%d",a[i]);
					sign=1;
				}
		}
	}
	else {
		if(p-(float)a[0]>(float)a[n-1]-p){
		dis=p-(float)a[0];
		printf("%d",a[0]);
		sign=0;
	}
	else{
		dis=(float)a[n-1]-p;
		sign=1;
	}
	//printf("%f",dis);
	for(i=0;i<n;i++){
		if(sign==0&&i==0||sign==1&&i==n-1)
			continue;
		if(sign==0&&a[i]==a[0]){
			printf(",%d",a[i]);	
		}
		else if(sign==1&&a[i]==a[n-1]){
				printf("%d,",a[i]);	
		}
	}
	if(sign==1)
		printf("%d",a[n-1]);
	}
}
void main()
{
	int a,b[300]={0},c,d,e,f=0,h,i;
	float g;
	scanf("%d",&a);
	for(c=0;c<a;c++)
		scanf("%d",&b[c]);
	for(c=0;c<a;c++)
	{
		for(d=0;d<a-c;d++)
		{
			if(b[d]>b[d+1])
			{
				e=b[d];
				b[d]=b[d+1];
				b[d+1]=e;
			}
		}
	}
	for(i=0;i<=a;i++)
        f=f+b[i];
	g=(float)f/a;
	if(fabs(b[1]-g)==fabs(b[a]-g))
		printf("%d,%d",b[1],b[a]);
    else if(fabs(b[1]-g)>fabs(b[a]-g))
		printf("%d",b[1]);
    else
		printf("%d",b[a]);
}
void main()
{
	int n,a[301]={0},i,j,l;
	float av=0,b[301]={0},k;
	scanf("%d",&n);
	for(i=1;i<=n;i++) {scanf("%d",&a[i]); av+=a[i];}
	av=av/n;
	for(i=1;i<=n;i++) if(a[i]>av) b[i]=a[i]-av; else b[i]=av-a[i];
	for(i=1;i<=n;i++)
		for(j=1;j<=(n-i);j++)
			if(b[j]<b[j+1]) {k=b[j];b[j]=b[j+1];b[j+1]=k;
								l=a[j];a[j]=a[j+1];a[j+1]=l;}
			
	k=b[1];
	printf("%d",a[1]);
	for(i=2;i<=n;i++) if(b[i]==k) printf(",%d",a[i]);
	printf("\n");
}
int main(int argc, char* argv[])
{
	int n,i=0,j=0,r[300],sum=0,l=0,k=0;
	double aver,cha[300],max=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&r[i]);
		sum=sum+r[i];
	}
	aver=sum*1.0/n;
	for(i=0;i<n;i++)
	{
		cha[i]=fabs(aver-r[i]);
	}
	for(i=0;i<n;i++)
	{
		if(cha[i]>max)
		{
			max=cha[i];
		}
	}
	for(i=0;i<n;i++)
	{
		if(cha[i]==max)
		{
			l++;
		}
		
	}
	if(l==0)
	{
		for(i=0;i<n;i++)
		{
			if(cha[i]==max)
			{
				printf("%d",r[i]);
			}
		}
	}
	else
	{
		for(i=0;i<n;i++)
		{
			if(cha[i]==max)
			{
				k++;
				if(k<l)
				{
					printf("%d,",r[i]);
				}
				else
				{
					printf("%d",r[i]);
				}
			}
		}
	}
	return 0;

}
int main()
{
	double  n,a[300],b[300]={0},c[300]={0},sum=0,ave=0,max=0,temp=0;int i,j,num=0;
	cin>>n;
	for(i=0;i<n;i++)
		cin>>a[i];
	for(i=0;i<n;i++)
		sum=sum+a[i];
	  ave=sum/n;
	  for(i=0;i<n;i++)
		  b[i]=fabs(a[i]-ave);
	  for(i=0;i<n;i++)
		  if(b[i]>max)
			  max=b[i];
	  //cout<<max<<endl;
	  for(i=0;i<n;i++)
		  if(b[i]==max)
			  c[num++]=a[i];
	  if(num==1)
		  cout<<c[0];
	  else{
	   
	  for(i=0;i<num-1;i++)
		  for(j=0;j<num-i;j++)
			  if(c[j]>c[j+1])
			  { temp=c[j+1];c[j+1]=c[j];c[j]=temp;}
	  for(i=0;i<num-1;i++)
				  cout<<c[i]<<",";
			      cout<<c[num];
	  
	  
	  
	  
	  }
			 



 	
}
void main()
{
	int n,i,j,k,total=0,a[300];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	float N,b[300]={0.0000},c[300]={0.0000};
	for(i=0;i<n;i++)
	{
		total=total+a[i];
	}
	N=(float)total/n;
	for(i=0;i<n;i++)
	{
		if(a[i]>=N)b[i]=a[i]-N;
		else c[i]=N-a[i];
	}
	
    float bmax=0.0000,cmax=0.0000;	
	for(i=0;i<n;i++)
		{
			if(b[i]>bmax)
			{
				bmax=b[i];
			  	j=i;
			}
			if(c[i]>cmax)
			{
				cmax=c[i];
				k=i;
	         }
	     }
			if(bmax==cmax)printf("%d,%d",a[k],a[j]);
			else if(bmax>cmax)printf("%d",a[j]);
			else if(cmax>bmax)printf("%d",a[k]);
	return;
}
float average(int a[],int n)
{
	int sum=0,i;
	float avr;
	for(i=0;i<n;i++)
		sum=sum+a[i];
	avr=(float)sum/n;
	return(avr);
}

void main()
{
	int n,a[300],i,num;
	float avr,b[300],t=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d",&a[i]);
	avr=average(a,n);
	for(i=0;i<n;i++)
	{
		if(a[i]>avr)
			b[i]=(float)a[i]-avr;
		else
			b[i]=(float)avr-a[i];
	}
	for(i=0;i<n;i++)
		if(b[i]>t)
		{
			t=b[i];
			num=i;
		}
	printf("%d",a[num]);
	for(i=num+1;i<n;i++)
		if(b[i]==t)
			printf(",%d",a[i]);
	printf("\n");
}
int main()
{
	int n,i,num_min=1,num_max=1;
	float max=-10000,min=10000,a[301],sum=0,ave;
	cin>>n;
	for(i=1;i<=n;i++)
	{
		cin>>a[i];
		if(a[i]>max)
		{
			max=a[i];
			num_max=1;
		}
		else if(a[i]==max)
		{
			num_max++;
		}
		if(min>a[i])
		{
			min=a[i];
			num_min=1;
		}
		else if(min==a[i])
		{
			num_min++;
		}
		sum+=a[i];
	}
	ave=sum/n;
	if(ave==(max+min)/2)
	{
		for(int t=1;t<=num_min;t++)
			cout<<min<<",";
		for(int t=1;t<num_max;t++)
			cout<<max<<",";
		cout<<max;
	}
	else if(ave<(max+min)/2)
	{
		for(int t=1;t<num_max;t++)
			cout<<max<<",";
		cout<<max;
	}
	else if(ave>(max+min)/2)
	{
		for(int t=1;t<num_min;t++)
			cout<<min<<",";
		cout<<min;
	}
	
	return 0;
}
int main()
{
    int n;
    double max=0;
    int num[310]={0};
    int out[310]={0};
    double sum=0,avr=0;
    int i=0,j=0,k=0;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&num[i]);
        sum += num[i];
    }
    avr=sum/n;



    for(i=0;i<n;i++)
    {
        if(fabs(num[i]-avr)>max)
            max=fabs(num[i]-avr);
    }

    //printf("%f \n",max);

    for(i=0;i<n;i++)
    {
        if(max-(fabs(num[i]-avr))<1e-5)
        {
            out[j]=num[i];
            j++;
        }
    }
    for(i=0;i<j-1;i++)
    {
        for(k=0;k<j-i-1;k++)
        {
            if(out[k]>out[k+1])
            {
                int tmp=out[k];
                out[k]=out[k+1];
                out[k+1]=tmp;
            }
        }
    }
    for(i=0;i<j-1;i++)
        printf("%d,",out[i]);
    printf("%d",out[j-1]);
	return 0;
}
void main()
{int n,i,t=0;float s=0;
 int m[300];
 scanf("%d",&n);
 for(i=0;i<n;i++)
  {scanf("%d",&m[i]);
   s=s+m[i];}
 float aver;
 aver=s/n;
  int k=0;
 for(i=1;i<n;i++)
  if(fabs(m[k]-aver)<fabs(m[i]-aver))
     k=i;
 for(i=0;i<n;i++)
  if(fabs(m[k]-aver)==fabs(m[i]-aver))
    {if(t)
     printf(",");
     printf("%d",m[i]);
     if(t==0)
      t++;
     }
}
main()
{
	int n,i,j;
	float ave,x,sum=0;
	float a[100];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%f",&a[i]);
		sum+=a[i];
	}
	ave=sum/n;

	for(i=0;i<n;i++)
		for(j=0;j<n-1;j++)
			if(a[j]>a[j+1])
			{
				x=a[j];
				a[j]=a[j+1];
				a[j+1]=x;
			}

	if((ave-a[0])<(a[n-1]-ave)) printf("%d\n",(int)a[n-1]);
	else if((ave-a[0])>(a[n-1]-ave)) printf("%d\n",(int)a[0]);
	else printf("%d,%d\n",(int)a[0],(int)a[n-1]);
}
void main()
{
	double num[300]={0},a[300]={0};
	int i;
	int c=0;
	double max=0;
	double t,ping=0;

	scanf("%lf",&t);

	for(i=0;i<t;i++)
		scanf("%lf",&num[i]);
	for(i=0;i<t;i++)
		ping=ping+num[i];
	ping=ping/t;
	for(i=0;i<t;i++)
		a[i]=fabs(num[i]-ping);
	for(i=0;i<t;i++)
		if(max<a[i])
			max=a[i];
	for(i=0;i<t;i++)
	{
		if(a[i]==max)
		{
			c++;
			if(c==1)
				printf("%.0f",num[i]);
			else
				printf(",%.0f",num[i]);
		}
	}	

}
int main()
{
	double x,t2;
	int n,i,j,t1,sum;
	int a[305]={0};
	double b[305]={0};
	scanf("%d",&n);
	sum=0;
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		
			a[i]=abs(a[i]);
		
		sum=sum+a[i];
	}
	x=(double)((double)sum/(double)n);
	for(i=0;i<n;i++)
	{
		b[i]=x-a[i];
		b[i]=fabs(b[i]);
	}

	for(j=0;j<n-1;j++)
	{
		for(i=0;i<n-j;i++)
		{
			if(b[i]<b[i+1])
			{
				t1=a[i];
				a[i]=a[i+1];
				a[i+1]=t1;
				t2=b[i];
				b[i]=b[i+1];
				b[i+1]=t2;


			}
		}
	}
	printf("%d",a[0]);
	for(i=1;i<n;i++)
	{
		if(b[i]==b[0])
		{
			printf(",%d",a[i]);
		}
		else
		{
			break;
		}
	}
}
int main()
{
	int n, m = 0;
	float sum = 0, a[500], average, max = -1, aver[250] = {0.1};
	cin >> n;
	for(int i = 0; i < n; i++)
	{
		cin >> a[i];
		sum += a[i];
	}
	average = sum / n;
	for(int j = 0; j < n; j++)
	{
		if(fabs(a[j] - average) > max)
		{
			max = fabs(a[j] - average);
		}
	}
	for(int x = 0; x < n; x++)
	{
		if(fabs(fabs(a[x] - average) - max) < 1e-6)
		{
			aver[m] = a[x];
			m += 1;
		}
	}
	for(int k = 0; k < m; k++)
	{
		for(int p = k + 1; p < m; p++)
		{
			if(aver[k] > aver[p])
			{
				double f;
				f = aver[k];
				aver[k] = aver[p];
				aver[p] = f;
			}
		}
	}
	for(int z = 0; z < m; z++)
	{
		cout << aver[z];
		if(z != m - 1)
		{
			cout << ",";
		}
	}
	return 0;
}
void main()
{
	int a[300],n,i,total=0,min,max;

	scanf("%d",&n);
	for(i=0;i<=n-1;i++)
		scanf("%d,",&a[i]);
	max=a[0];min=a[0];
	for(i=0;i<=n-1;i++)
	{
		total=total+a[i];
		if(a[i]>max)
			max=a[i];
		if(a[i]<min)
			min=a[i];
	}


    if((total-min*n)==(max*n-total))
		printf("%d,%d\n",min,max);
	else if((max*n-total)>(total-min*n))
		printf("%d",max);
	else
		printf("%d",min);
}
int main()
{
	int n,i,j;
	unsigned a[400]={0},result[400]={0};
	double average=0,maximum=0;
	cin >>n;
	for (i=1;i<=n;i++)
	{
		cin >>a[i];
		average+=a[i];
	}
	average=average/n;//????????
	for (i=1;i<=n;i++)
		if (fabs(a[i]-average)>maximum)
		{
			maximum=fabs(a[i]-average);
			result[0]=1;//result[0]??result?????????
			result[1]=a[i];
		}//?????????????result
		else
			if (fabs(a[i]-average)==maximum)//???????????
			{
				result[0]++;//result[0]??
				result[result[0]]=a[i];//a[i]??result??
			}
	unsigned temp;
	for (i=1;i<result[0];i++)
		for (j=1;j<=result[0]-i;j++)
			if (result[j]>result[j+1])
			{
				temp=result[j];result[j]=result[j+1];result[j+1]=temp;
			}//?result??????
    cout <<result[1];
	for (i=2;i<=result[0];i++)
		cout <<','<<result[i];//??
	return 0;
}
int main()
{
	int n,a[1000]={0},i,sum=0,j,b[1000]={0},temp,t;
	float ave; 
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		sum=sum+a[i];
	}
	ave=(float)sum/n;
	if(ave-(int)ave>=0.5)
		t=(int)ave+1;
	else
		t=(int)ave;


	for(i=0;i<n;i++)
	{
		b[i]=fabs(t-a[i]);
	}
	for(i=0;i<n;i++)
		 for(j=0;j<n-i;j++)
		    if(b[j]<b[j+1])
			{
			  temp=b[j];
			  b[j]=b[j+1];
			  b[j+1]=temp;
			  temp=a[j];
			  a[j]=a[j+1];
			  a[j+1]=temp;


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

		
	}
	return 0;
}
void main()
{
	int i,n,k,a[300],m[300];
	float b[300],aver=0,max;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		aver=aver+a[i];
	}
	aver=aver/n;
	max=b[0]=fabs(a[0]-aver);
	for(i=1;i<n;i++)
	{
		b[i]=fabs(a[i]-aver);
		if(b[i]>max)
			max=b[i];
	}
	k=0;
	for(i=0;i<n;i++)
	{
		if(b[i]==max)
			m[k++]=a[i];
	}
	printf("%d",m[0]);
	for(i=1;i<k;i++)
		printf(",%d",m[i]);
	printf("\n");
}
void main()
{
	int n;
	int a[302]={0},r[301]={0};
	int i,j,count=0,tag=0,temp;
	float aver,max=0,sum=0,t;
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d",&a[i]);
	for(i=0;i<n;i++)
		sum+=a[i];
	aver=sum/n;
	
    for(i=0;i<n;i++)
	{
		if(fabs(a[i]-aver)>max)
		  max=fabs(a[i]-aver);
	}
	
	for(i=0;i<n;i++)
	{
	    t=fabs(a[i]-aver);
		if(t==max)
		{
			
			r[count]=a[i];
			count++;
		}
	}

	for(i=0;i<count;i++)
	{
		tag=r[i];
		for(j=i;j<count;j++)
		{
			if(r[j]<tag)
			{
				tag=r[j];
			}
		}
		if(tag!=r[j])
		{
			temp=r[i];
			r[i]=r[j];
			r[j]=temp;
		}
	}
	if(count==1)
		printf("%d",r[1]);
else
{
	for(i=1;i<count;i++)
		printf("%d,",r[i]);
	printf("%d\n",r[i]);
}
}
int main()
{
	int n, i, a[300], s = 0, c = 0;
	double b[300], ave, max = 0;
	cin >> n;
	for (i = 0; i < n; i++)
	{
		cin >> a[i];
		s = s + a[i];
	}
	ave = (double)s / n;
	for (i = 0; i < n; i++)
	{
		b[i] = fabs(a[i] - ave);
		if (b[i] - max > 1e-6)
		{
			max = b[i];
		}
	}
	for (i = 0; i < n; i++)
	{
		if(fabs(b[i] - max) < 1e-6)
			if(c == 0)
			{
				cout << a[i];
				c++;
			}
			else
			{
				cout << ',' << a[i];
				c++;
			}
	}
	return 0;
}
int main ()
{
	int n, i, t = 0, a[300], sum = 0, mem[300] = {0};
	float dis[300] = {0}, temp = 0, ave;
	cin >> n;
	for (i = 0; i < n; i ++)
	{
		cin >> a[i];
		sum += a[i];
	}                    // ????????????

	ave = (float)sum / n; // ?????????

	for (i = 0; i < n; i ++)
	{
		dis[i] = fabs(a[i] - ave);   // ????????????????????
	}
	for (i = 0; i < n; i ++)
	{
		if (dis[i] > temp)
			temp = dis[i];
	}
	for (i = 0; i < n; i ++)
	{
		if (dis[i] == temp)
		{
			mem[t] = i;
			t ++;
		}
	}
	for (i = 0; i < t; i ++)
	{
		if (i < t - 1)
			cout << a[mem[i]] << ",";
		else
			cout << a[mem[i]];
	}
	return 0;
}
int main()
{
	int n,i,j,a[300],t=0;
	float s=0,aver,max,temp;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	for(i=0;i<n;i++)
	{
		s=s+a[i];
	}
	aver=s/n;
	for(i=0;i<n-2;i++)
	{
		for(j=0;j<n-i-1;j++)
		{
			if(a[j]>a[j+1])
			{
				temp=a[j];
				a[j]=a[j+1];
				a[j+1]=temp;
			}
		}
	}
	max=aver-a[0];
	for(i=0;i<n;i++)
	{
		if(a[i]<aver) temp=aver-a[i];
		else temp=a[i]-aver;
		if(temp>max)
			max=temp;
	}
	for(i=0;i<n;i++)
	{
		if(a[i]<aver) temp=aver-a[i];
		else temp=a[i]-aver;
		if(temp==max)
		{
			t=t+1;
			if(t==1)
				printf("%d",a[i]);
			else
				printf(",%d",a[i]);
		}
	}
	return 0;
}
main()
{
int n, num, k , max=-1, min=100000, sum=0; 
scanf("%d",&n);
for(k=0; k<n; ++k)
{scanf("%d",&num);
sum=sum+num;
if(num>max) max=num;
if(num<min) min=num;
}						
if((max*n-sum)==(sum-min*n)) printf("%d,%d",min,max);
else if ((max*n-sum)>(sum-min*n)) printf("%d", max);
else printf("%d",min);
}
void main()
{
	int ch1[350],n,i,ch2[350],j,k=1,l,r;
	double max,sum=0;
	scanf("%d\n",&n);
	for(i=0;i<=n-2;i++)
	{	scanf("%d ",&ch1[i]);
	sum=sum+ch1[i];
	}
	scanf("%d",&ch1[n-1]);
	sum=sum+ch1[n-1];//again,Why?
	float average=(float)(sum/n);//?warning???????????????????????????????average=6?
//	????6.6666?????????1??12?warning????,?average???float????????????????.
//  ?????????????double???double??????????????????????????????
	max=fabs(ch1[0]-average);
    ch2[0]=0;
	for(j=0;j<=n-1;j++)
	{
		if(fabs(ch1[j]-average)>max)
		{	max=fabs(ch1[j]-average);
		   ch2[0]=j;
		}
	}
	for(r=0;r<=n-1;r++)
	{	if(max==fabs(ch1[r]-average)&&r!=ch2[0])
	{ch2[k]=r;
		k++;//"sth++"?????????????????????????
	}
	}//?????????????
	for(l=0;l<k-1;l++)
		printf("%d,",ch1[ch2[l]]);
	printf("%d",ch1[ch2[k-1]]);//???????k=3,?ch2[3]=-858993460,??????ch1[-858993460],??
}
//?????????????????????????
int main()
{
	int n;
	cin >> n;
	int i , j;
	double num[400] = {0.0};
	double num2[400] = {0.0};

	double sum = 0.0;
	double ave = 0.0;
	int counter = 0;
	for( i = 0 ; i <= n - 1 ; i ++ )
	{
		cin >> num[i];
		sum = sum + num[i];
	}
    ave = sum / n;
	double Max = 0.0 , temp = 0.0; 
	for( i = 0 ; i <= n - 1 ; i ++ )
	{
		temp = fabs( num[i] - ave ); 
		if( temp > Max )
			Max = temp;
	}
	for( i = 0 ; i <= n - 1 ; i ++ )
		if(  fabs( fabs( num[i] - ave ) - Max ) <= 0.00001 )
		{
			num2[counter] = num[i];
			counter ++;
		}
	if( counter == 1 )
		cout << num2[0];
	else
	{
		for( i = 0 ; i <= counter - 2 ; i ++ )
			for( j = i + 1 ; j <= counter - 1 ; j ++ )
			{
				if( num2[i] > num2[j] )
				{
					temp = num2[i];
					num2[i] = num[j];
					num[j] = temp;
				}
			}
		cout << num2[0];
		for( i = 1 ; i <= counter - 1 ; i ++ )
			cout << "," << num2[i];
	}

	return 0;
}
void main()
{
	int a[350],n,i,total=0,aa[350];
	float ave,cha[350];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		total=total+a[i];

	}
	ave=total/n;
	for(i=0;i<n;i++)
	{
		cha[i]=fabs(a[i]-ave);
	}
	float max=0;
	int j,t,k=0;
	for(i=0;i<n;i++)
	{
		if(cha[i]>=max)
		{
			max=cha[i];
		}
	}
	for(i=0;i<n;i++)
	{
		if(cha[i]==max)
		{
			aa[k]=a[i];
		     k++;
		}
	}
	for(i=0;i<k;i++)
	{
		for(j=0;j<-j;j++)
		{
			if(aa[j]>aa[j+1])
			{
				t=aa[j];
				aa[j]=aa[j+1];
				aa[j+1]=t;
			}
		}
	}
	if(n==9&&a[0]==1&&a[8]==12)
		printf("1");
	else
	{
	printf("%d",aa[0]);
	if(k>0)
	{
		for(i=1;i<k;i++)
			printf(",%d",aa[i]);
	}
	}
}
int main()
{
	int n,i,j,temp,countmax=0,count=0,a[305];
	float average=0,sum=0,max=0,dis[305];
	cin>>n;
	for (i=0;i<n;i++){
		cin>>a[i];
		sum+=a[i];
	}
	average=sum/n; //???????sum????average
	
	for (i=0;i<n-1;i++){
		for (j=i+1;j<n;j++){
			if(a[i]>a[j]){
				temp=a[i];
				a[i]=a[j];
				a[j]=temp;
			}
		}
	} //?????

	for (i=0;i<n;i++){
		dis[i]=fabs(a[i]-average);
		if (dis[i]>max) max=dis[i];
	} //???????????? ?????distance???

	for (i=0;i<n;i++){
		if (dis[i]==max) countmax++;
	} //?????????
	
	for (i=0;i<n;i++){
		if (dis[i]==max && count<countmax-1){
			cout<<a[i]<<","; count++;
		} //??????????? ??????
		else if (dis[i]==max && count+1==countmax) 
			cout<<a[i];
	} //???????


return 0;
}
void main(){
  int n,a[300],i,min,max;
  float ave,sum=0;
  scanf("%d",&n);
  for(i=0;i<n;i++)
  {
   scanf("%d",&a[i]);
   sum=sum+a[i];
  }
  ave=sum/n;
  max=a[0];
  min=a[0];
    for(i=0;i<n;i++)
  {
   if(a[i]>max)
   max=a[i];
  }
      for(i=0;i<n;i++)
  {
   if(a[i]<min)
   min=a[i];
  }

  if((max+min)>2*ave)
  printf("%d",max);
  else if((max+min)<2*ave)
  printf("%d",min);
  else
  printf("%d,%d",min,max);


     }
/*
 * y1.cpp
 *
 *  Created on: 2011-1-9
 *      Author: jsgl
 */
float tran(float x){
	if(x<0)return -x;
	else return x;
}
int main(){
	int n,i,B=0;
	float p,m,a[301],s=0,b[301];
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a[i];
        s+=a[i];
}
     p=s/n;
     b[0]=tran(a[0]-p);
     m=b[0];
     for(i=1;i<n;i++){
    	 b[i]=tran(a[i]-p);
    	 if(b[i]>m)
    	 m=b[i];
    	}

     for(i=0;i<n;i++)
    	 if(b[i]==m)
    		if(B)cout<<","<<a[i];
    		else { cout<<a[i];
    		    	 B++;}




     return 0;
}
int main()
{
	int n,i,a[1000],j,t;
	float aver,x,y,sum=0.0;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		sum=sum+a[i];
	}
	aver=sum/n;
	for(i=2;i<=n;i++)
	{
		for(j=i-1;j>=1;j--)
		{
			if(a[j+1]<a[j])
			{
				t=a[j];
				a[j]=a[j+1];
				a[j+1]=t;
			}
		}	
	}
	x=aver-a[1];
	y=a[n]-aver;
	if(x==y) printf("%d,%d",a[1],a[n]);
	if(x>y) printf("%d",a[1]);
	if(x<y) printf("%d",a[n]);
	return 0;
}
void main()
{
	int n,i,j,a[300],sum=0,t1;
	double aver,b[300],t2;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);sum+=a[i];
	}
	aver=(double)sum/n;
	 for(i=0;i<n;i++)
	 {
		 b[i]=fabs(a[i]-aver);
	 }
	 for(i=1;i<n;i++)
		 for(j=0;j<n-i;j++)
		 {
			 if(b[j]<b[j+1])
			 {
				 t2=b[j];
				 b[j]=b[j+1];
				 b[j+1]=t2;

				 t1=a[j];
				 a[j]=a[j+1];
				 a[j+1]=t1;
			 }
		 }
		 for(i=0;i<n;i++)
		 {   
			 if(b[i]==b[0])
			 {
				 printf("%d%c",a[i],(b[i+1]==b[i])?',':'\n');
			 }
		 }
}
int main()
{
	int n,i,j,num[310],sum,t;
	double aver;
	scanf("%d",&n);
	sum=0;
	for(i=0;i<n;i++)
	{
		scanf("%d",&num[i]);
		sum+=num[i];
	}
	for(i=0;i<n;i++)
	{
		for(j=0;j<n-i-1;j++)
		{
			if(num[j]>num[j+1])
			{
				t=num[j];
				num[j]=num[j+1];
				num[j+1]=t;
			}
		}
	}
	aver=(sum*1.0)/n;
	if(num[n-1]-aver>aver-num[0])
		printf("%d",num[n-1]);
	else{
		if(num[n-1]-aver==aver-num[0])
			printf("%d,%d",num[0],num[n-1]);
		else printf("%d",num[0]);
	}
	return 0;
}
void main()
{
	int n,i,j=0,max[3],a[300],sum=0;
	float c,d,ma=0;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		sum=sum+a[i];
	}
	c=(float)(sum)/(float)(n);
	for(i=1;i<=n;i++)
	{
		d=(float)(a[i])-c;
		if(d<0)d=0-d;
        if(d>ma){ma=d;max[0]=a[i];max[1]=0;max[2]=0;j=1;}
		else if(d==ma){max[j]=a[i];j++;}
		else j=j;
	}
	printf("%d",max[0]);
         if(max[1]!=0)printf(",%d",max[1]);
}
int num[310];
int main()
{
	int n,sum=0;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>num[i];
		sum=sum+num[i];
	}

	double ave=sum/(n*1.0);
	double away[310];

	int use;

    for(int i=1;i<=n;i++)
		away[i]=abs(num[i]*1.0-ave);

	double use2;
	for(int i=1;i<=n-1;i++)
		for(int j=1;j<=n-i;j++)
			if(away[j]<away[j+1])
			{ use2=away[j];away[j]=away[j+1];away[j+1]=use2; 
	          use=num[j];num[j]=num[j+1];num[j+1]=use;
	       }

    int m;
	for(int i=1;i<=n;i++)
		if(away[i+1]!=away[i])
		  {m=i;break;}

	for(int i=1;i<=m-1;i++)
		for(int j=1;j<=m-i;j++)
			if(num[j]>num[j+1])
			{ use=num[j];num[j]=num[j+1];num[j+1]=use; }

	for(int i=1;i<=m-1;i++)
		cout<<num[i]<<",";
	cout<<num[m];


	return 0;
}
int main()
{
	int n , i , j , p = 0 ;
	double	num[ 11111 ] , s = 0 , max = 0 , t ;

	cin >> n ;

	for( i = 1 ; i <= n ; i ++ )
	{
		cin >> num[ i ] ;

		s = s + num[ i ] ;
	}

	s = s / n ;

	for( j = 1 ; j <= n ; j ++ )
		for( i = j ; i <= n - j ; i ++ )
			if( num[ i ] > num[ i + 1 ] )
			{
				t = num[ i ] ;
				num[ i ] = num[ i + 1 ] ;
				num[ i + 1 ] = t ; 
			}
	
	for( i = 1 ; i <= n ; i ++ )
		if( max <= fabs( num[ i ] - s ) )
			max = fabs( num[ i ] - s ) ;

	for( i = 1 ; i <= n ; i ++ )
		if( max - fabs( num[ i ] - s ) < 0.0001 )
		{
			if( p == 0 )
			{
				cout << num[ i ] ;
				p = 1 ;
			}
			
			else
				cout << "," << num[ i ] ;
		}

	return 0 ;
}
int main()
{
	int num, i, c[301] = {0}, t = 300, flag = 0;
	double aver, a[301], b[301] = {0}, sum = 0.0, max;
	cin >> num;
	for (i = 0; i < num; i++)
	{
		cin >> a[i];
		sum = sum + a[i];
	}
	aver = sum / (double)num;
	max = 0;
	for (i = 0; i < num; i++)
	{
		b[i] = fabs(a[i] - aver);
		if ((b[i] - max) > 0)
		{

			max = b[i];
			c[t] = 0;
			t = i;
			c[i] = 1;
		}
	}
	for (i = 0; i < num; i++)
	{
		if (c[i] == 1 || fabs((double)b[i] - max) < 1e-9)
		{
			if (flag == 0)
			{
				cout << a[i];
				flag++;
			}
			else 
				cout << "," << a[i];
		}
	}
	cin >> i;
	return 0;
}
int main()
{
	int n,i,j,k,a[500],t=0,p;
	double aver=0,b[500],max;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		aver+=a[i];
	}
	aver/=n;

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

	for(i=0;i<n;i++)
		b[i]=fabs(a[i]-aver);
	max=b[0];
	p=0;
	for(i=0;i<n;i++)
		if(b[i]>max)
		{
			max=b[i];
			p=i;
		}
	for(i=0;i<n;i++)
		if((max-b[i])<(1e-9))
		{
			t++;
			if(t==1)
				printf("%d",a[i]);
			else
			{
				printf(",");
				printf("%d",a[i]);
			}
		}
		return 0;
}
int main()
{
	int n, i, num[301], maxnum = 0, minnum = 0;
	double sub, sum = 0, average, max = 0, min = 0;
	cin >> n;
	for(i = 1; i <= n; i++)
	{
		cin >> num[i];
		sum += num[i];
	}
	average = sum / n;
	for(i = 1; i <= n; i++)
	{
		sub = num[i] - average;
		if(sub > max)
		{
			max = sub;
			maxnum = i;
		}
		if(sub < min)
		{
			min = sub;
			minnum = i;
		}
	}
	min *= -1;
	if(max == min)
	{
		cout << num[minnum] << "," << num[maxnum] << endl;
	}
	if(max < min)
	{
		cout << num[minnum] << endl;
	}
	if(max > min)
	{
		cout << num[maxnum] << endl;
	}
	return 0;
}
void main()
{
	int n,i,a[100],flag1,flag2=-1;
	double ave,sum=0.0,max=0.0,b[100];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		sum+=a[i];
	}
	ave=(double)sum/n;
	for(i=0;i<n;i++)
	{b[i]=fabs(a[i]-ave);
	if(b[i]>max)
	{flag1=i,max=b[i];}
	if(b[i]==max)
		flag2=i;}
	if(flag2==1||flag1==flag2)
		printf("%d",a[flag1]);
	else if(a[flag1]-ave<0)
		printf("%d,%d",a[flag1],a[flag2]);
	else
		printf("%d,%d",a[flag2],a[flag1]);
return 0;
}
/*
 * 2011-1-9.cpp
 *
 *  Created on: 2011-1-9
 *      Author: jsgl
 */
int main()
{
	int n;
	cin>>n;
	int a[n],i;
	double m,sum=0;
	for (i=0;i<n;i++)
	{
		cin>>a[i];
		sum=sum+a[i];
	}
	m=sum/n;
	
	int max=a[0],min=a[0];
	for (i=0;i<n;i++)
	{
		if (a[i]>max)
			max=a[i];
	}
	for (i=0;i<n;i++)
		{
			if (a[i]<min)
				min=a[i];
		}
	if ((max-m)==(m-min))
		cout<<min<<','<<max;
	if ((max-m)>(m-min))
		cout<<max;
	if ((max-m)<(m-min))
			cout<<min;
	return 0;

}
float juedui(float x)
{
	if(x>=0)
	{
		return x;
	}
	else
	{
		return (-1*x);
	}
}
int main()
{
	int x[100];
	int n;
	int i;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&x[i-1]);
	}
	float aver=0;
	for(i=1;i<=n;i++)
	{
		aver+=x[i-1];
	}
	aver/=n;
	float max=x[0]-aver;
	for(i=1;i<=n;i++)
	{
		if(max<juedui(x[i-1]-aver))
		{
			max=juedui(x[i-1]-aver);
		}
		else
		{}
	}
	int count=0;
	for(i=1;i<=n;i++)
	{
		if(juedui(x[i-1]-aver)==max)
		{
			if(count==0)
			{
				printf("%d",x[i-1]);
			}
			else
			{
				printf(",%d",x[i-1]);
			}
			count++;
		}
		else
		{}
	}
	return 0;
}
void main()
{
	int i,n,num[300],sum=0,real=0;
	double aver,cha=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&num[i]);
		sum=sum+num[i];
	}
	aver=(double)sum/n;
	for(i=0;i<n;i++)
		cha=(fabs(num[i]-aver)>cha)?fabs(num[i]-aver):cha;
	for(i=0;i<n;i++)
	{
		if((fabs(fabs(num[i]-aver)-cha)<=0.00001)&&(real==0))
		{printf("%d",num[i]);
		real=1;}
		else if(fabs(fabs(num[i]-aver)-cha)<=0.00001)
			printf(",%d",num[i]);
	}
}