semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int main()
{
    int num[300];
    float average=0,temp,max=0;
    int i,n,flag=0;
    scanf("%d",&n);
    for(i=0;i<n;i++)
        scanf("%d",num+i);
    
    for(i=0;i<n;i++)
        average+=num[i];
    average/=n;
    
    for(i=0;i<n;i++)
        {
         temp=fabs(average-num[i]);
         if(temp>max)
            max=temp;
         }
    for(i=0;i<n;i++)
        {
         if(fabs(fabs(num[i]-average)-max)<=0.001)
            {
             if(flag==0)
                flag=1;
             else 
                 printf(",");
             printf("%d",num[i]);
            }
        }
    return 1;
}
//*************************************************
//***????????***
//***??????***
//***???2013.1.13***
//*************************************************
int main ()
{
	int n,c,i,t[2],flag;
	double a[301],average,d;
	cin >> n;
	average = 0;
	for (i = 0; i < n; i++)
	{
		cin >> a[i];
		average += a[i];
	}
	average /= n;
	d = fabs(a[0] - average);
	flag = 1;
	t[0] = a[0];
	for (i = 1; i < n; i++)
	{
		if (fabs(fabs(a[i] - average) - d) < 0.1)
		{
			t[flag] = a[i];
			flag++;
		}
		else if (fabs(a[i] - average) > d)
		{
			flag = 1;
			d = fabs(a[i] - average);
			t[0] = a[i];
		}
	}
	c = 0;
	for (i = 0; i < flag; i++)
	{
		if (t[i] < average)
		{
			cout << t[i];
			c++;
			if (c < flag)
				cout << ",";
		}	
	}
	for (i = 0; i < flag; i++)
	{
		if (t[i] > average)
		{
			cout << t[i];
			c++;
			if (c < flag)
					cout << ",";
		}
	}
	cout << endl;
	return 0;
}
int main()//?????????????????? = = ??????????????????blahblah????????
{
	int n,i,j,t,k=0,c[300]={0},a[300];
	long double sum=0,b[300],aver=0,max=0;//???????????????????????? = = 
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);//??
		sum=sum+a[i];//????????
	}
	aver=sum/n;//????
	for(i=0;i<n;i++)
	{
		b[i]=a[i]-aver;//?????????
		if(b[i]<0)b[i]=-b[i];
		if(b[i]>max)max=b[i];//??????
	}
	for(j=0;j<(n-1);j++)
	{
		for(i=0;i<(n-1-j);i++)
		{
			if(a[i]>a[i+1])
			{
				t=a[i];
				a[i]=a[i+1];
				a[i+1]=t;//??????????
			}
		}
	}
	for(i=0;i<n;i++)
	{
		if((a[i]-aver)==max||(a[i]-aver)==-max)//???????????????????????? = =
		{
			c[k]=a[i];//???c????????
			k++;
		}
	}
	for(i=0;i<k-1;i++)printf("%d,",c[i]);
	printf("%d",c[k-1]);//?????????????????????..
	return 0;
}
void main()
{
	int m,j,i=0,p[300],n,y=0;
	 float k[300],b,a=0;
	scanf("%d",&n);
	for(m=0;m<n;m++) 
	{scanf("%d",&p[m]);
	a=a+p[m];}
	b=a/n;
   for(m=0;m<n;m++)
   {if(p[m]-b>=0)
   {k[m]=p[m]-b;}
   else
	   k[m]=b-p[m];}
	for(j=1;j<n;j++)
	{if(k[j]>k[i])
	i=j;}
	for(m=0;m<n;m++)
	{if(k[m]==k[i]&&p[m]<=b)
	  {printf("%d",p[m]);
	y=1;}}
	for(m=0;m<n;m++)
	{if(k[m]==k[i]&&p[m]>b)
	{if(y==1)
	  printf(",%d",p[m]);
	else
		printf("%d",p[m]);}
	}
}
void main()
{
  long i,s,k,n,max,min;
  scanf("%ld\n",&n);
  min=32767; max=0; s=0;
  for (k=1;k<=n;k++){scanf("%ld",&i); if(max<i)max=i; if(min>i)min=i; s+=i;}
  if ((max*n-s)>(s-min*n)) printf("%ld\n",max);
  else if ((max*n-s)<(s-min*n)) printf("%ld\n",min);
  else printf("%ld,%ld",min,max);
}
int main()
{
    double s[310],av=0,n=0,max=0,sum=0,p[310],temp=0;//s???????????av?????p???????????????max???????? n?????? 
    int i=0,j=0,ge=1;
       cin>>n;
       for(i=1;i<=n;i++)//?? 
       {
          cin>>s[i];                 
       }
       for(i=1;i<=n;i++)
       {
          sum+=s[i];                 
       }
       av=sum/n;
       for(i=1;i<=n;i++)
       {
          if((s[i]>av)&&(s[i]-av>max))
            {max=s[i]-av;continue;}
          if((av>s[i])&&(av-s[i]>max)) 
            {max=av-s[i];continue;}                
       }
       ge=1;
       for(i=1;i<=n;i++)
       {
          if(abs(abs(s[i]-av)-max)<0.00001)
            {p[ge]=s[i];ge++;continue;}               
       }
       ge--;
       for(i=1;i<=ge;i++)
       {
          for(j=1;j<=ge-i;j++)
          {
                if(p[j]>p[j+1])
                    {
                       temp=p[j];
                       p[j]=p[j+1];
                       p[j+1]=temp;           
                    }            
          }                 
       }
       cout<<p[1];
       for(i=2;i<=ge;i++)
         cout<<","<<p[i];
return 0;    
}
//============================================================================
// Name        : 4.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================


int main() {
	int n;
	cin>>n;
	double a[1000],b[1000];
	for(int i=0;i<n;i++)//????
		cin>>a[i];
	double sum=0;
	for(int i=0;i<n;i++)
		sum+=a[i];
	double average=sum/n;//?????
	for(int i=0;i<n;i++)
		b[i]=fabs(a[i]-average);
	double max1=b[0];//??????
	for(int i=0;i<n;i++)
		max1=max(max1,b[i]);
	double c[1000];
	int num=0;
	for(int i=0;i<n;i++)//?????????
		if(b[i]==max1)
		{
			c[num]=a[i];
			num++;
		}
	sort(c,c+num-1);//?????
	cout<<c[0];//??????
	for(int i=1;i<num;i++)
		cout<<","<<c[i];
	return 0;
}
int main(int argc, char* argv[])
{
    int n,i,c[300],k;
    double a=0,b[300];
    scanf("%d",&n);
    for(i=0;i<n;i++){
    scanf("%d",&c[i]);
    a+=c[i];
 }
 a/=n;
    for(i=0;i<n;i++){
     b[i]=c[i]-a;
 }
    for(i=n-1;i>0;i--){
  for(k=0;k<i;k++){
   if(b[k]>b[k+1]){
   double t=b[k];
   b[k]=b[k+1];
   b[k+1]=t;}
  }
 }
 if(b[n-1]==0-b[0])
  printf("%.0lf,%.0lf",b[0]+a,b[n-1]+a);
 else if(b[n-1]<0-b[0])
  printf("%.0lf",b[0]+a);
else if(b[n-1]>0-b[0])
  printf("%.0lf",b[n-1]+a);
 return 0;
}
void bubble(int *p,int n)
{
	int i=0,pass,temp;

	for(pass=1;pass<=n;pass++)
	{
		for(i=0;i<n-pass;i++)
		{
			if(*(p)>*(p+1))
			{
				temp=*(p);
				*(p)=*(p+1);
				*(p+1)=temp;
			}
		}
	}
	return;
}
float ffabs(float x)
{
	if(x>0)
		return x;
	else
		return -x;
}
void main()
{
	int n,i,*num,sum=0,*temp,r=0;
	float ave,max=0.0;

	scanf("%d",&n);

	num=(int *)malloc(n*sizeof(int));
	temp=(int *)malloc(n*sizeof(int));
	for(i=0;i<n;i++)
	{
		scanf("%d",(num+i));
		sum+=*(num+i);
	}
	
	ave=(float)sum/(float)n;

	for(i=0;i<n;i++)
	{
		if(ffabs((float)*(num+i)-ave)>=max)
			max=ffabs((float)*(num+i)-ave);
	}

	for(i=0;i<n;i++)
	{
		if(ffabs(ffabs((float)*(num+i)-ave)-max)<0.0000001)
		{
			*(temp+r)=*(num+i);
			r++;
		}
	}
	if(r==1)
	{
		printf("%d",*(temp+0));
	}
	else
	{
		bubble(temp,r);
		for(i=0;i<r;i++)
		{
			printf("%d%c",*(temp+i),(i!=r-1?',':'\n'));
		}
	}
}
void main()
{
	int n,i,j,k,t,max,temp,sum=0,a[300],b[300];
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d",&a[i]);
	for(i=0;i<n;i++)
		sum=sum+a[i];
	if((a[0]*n)>sum)
		max=a[0]*n-sum;
	else if((a[0]*n)<sum)
		max=sum-a[0]*n;
	for(i=1;i<n;i++)
	{if(((a[i]*n)>sum)&&(((a[i]*n)-sum)>max))
	max=a[i]*n-sum;
	else if(((a[i]*n)<sum)&&((sum-(a[i]*n))>max))
		max=sum-a[i]*n;
	}
	j=0;
	for(i=0;i<n;i++)
		if(((a[i]*n-sum)==max)||((sum-(a[i]*n))==max))
		{ 
			b[j]=a[i];
			j++;
		}
		k=j;
		for(j=0;j<k;j++)
		{   i=j;
			for(t=j+1;t<=k;t++)
				if(b[i]>b[t])
					i=t;
				if(i!=j)
				{temp=b[i];
				b[i]=b[j];
				b[j]=temp;
				}
		}
		for(j=1;j<k;j++)
			printf("%d,",b[j]);
		printf("%d",b[k]);
}
struct
{float a;
float c;
}num[401];
void main()
{ 
	int n,i,j;
	float sum=0,b,h=0,k;
	scanf("%d\n",&n);
	for(i=0;i<n;i++)
		scanf("%f",&num[i].a);
	for(i=0;i<n;i++)
	{
		sum=sum+num[i].a;
	}
	b=sum/n;
	for(i=0;i<n;i++)
	{
		num[i].c=fabs(num[i].a-b);
	}
	for(j=0;j<n-1;j++)
	{
		for(i=0;i<n-1;i++)
		{
			if(num[i].c<num[i+1].c)
			{num[400]=num[i];
			num[i]=num[i+1];
			num[i+1]=num[400];
		}}
	}
	for(i=1;i<n;i++)
	{
		if(num[i].c==num[0].c)
			h=h+1;
	}
	for(j=0;j<h-1;j++)
	{
		for(i=0;i<h-1;i++)
		{
			if(num[i].c>num[i+1].c)
			{num[400]=num[i];
			num[i]=num[i+1];
			num[i+1]=num[400];
		}}
	}
	printf("%.0f",num[0].a);
	for(i=1;i<h+1;i++)
		printf(",%.0f",num[i].a);
}
int main()
{
	int n,i,j,a[300],temp,count1=0,count2=0;
	double aver=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
			aver+=a[i];
	}
     aver=aver/n;
	 for(i=n-1;i>0;i--)
		 for(j=0;j<i;j++)
		 {
			 if(a[j]>a[j+1])
			 {
               temp=a[j+1];
			   a[j+1]=a[j];
                  a[j]=temp;
			 }
		 }
		 for(i=0;i<n;i++)
		 {
			 if(a[i]==a[0])
			 {
                count1++;
			 }
			 if(a[i]==a[n-1])
			 {
				 count2++;
			 }
		 }
		 if((aver-a[0])>(a[n-1]-aver))
		 {
			 for(i=0;i<count1-1;i++)
			 {
				 printf("%d,",a[i]);
				 
			 }
                 printf("%d",a[count1-1]);
		 }
           if((aver-a[0])<(a[n-1]-aver))
		   {
			 for(i=n-count2;i<n-1;i++)
			 {
				 printf("%d,",a[i]);
			 }
                 printf("%d",a[n-1]);
		   }
           if((aver-a[0])==(a[n-1]-aver))
		   {
	          for(i=0;i<count1;i++)
			  {
				 printf("%d,",a[i]);
			  }
               for(i=n-count2;i<n-1;i++)
			   {
				 printf("%d,",a[i]);
			   }
                 printf("%d",a[n-1]);
		   }
		   return 0;
}
float my_abs(float a)
{
	return a < 0 ? -a : a;
}

int main()
{
	//freopen("in.txt", "r", stdin);

	int n;
	scanf("%d", &n);

	float avg = 0;
	float data[400];
	for (int i = 0;i < n; i++)
	{
		scanf("%f", &data[i]);
		avg += data[i];
	}
	avg /= n;

	float dif[400];
	for (int i = 0;i < n; i++)
	{
		dif[i] = my_abs(data[i] - avg);
	}
	
	float maxDif = dif[0];
	float maxIdx = 0;
	for (int i = 1;i < n; i++)
	{
		if (maxDif < dif[i])
		{
			maxDif = dif[i];
			maxIdx = i;
		}
	}

	int result[400];
	int sp = 0;
	for (int i = 0; i < n; i++)
	{
		if (dif[i] == maxDif)
		{
			result[sp++] = data[i];
		}
	}

	if (sp == 2)
	{
		if (result[0] > result[1])
		{
			int temp = result[0];
			result[0] = result[1];
			result[1] = temp;
		}
	}

	for (int i = 0; i < sp; i++)
	{
		printf("%d%c", result[i], i==sp-1 ? '\n' : ',');
	}

	return 0;
}
int main(int argc, char* argv[])
{
	int i,n,num[300],s,j,b,c;
	double ave,v[300],a;
	s=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&num[i]);
		s+=num[i];
	}
	ave=(double)s/n;
	for(i=0;i<n;i++){
		if(num[i]<ave){
			v[i]=ave-num[i];
		}
		else{
			v[i]=num[i]-ave;
		}
	}
	for(i=0;i<n-1;i++){
		for(j=i+1;j<n;j++){
			if(v[j]>v[i]){
				a=v[j];
				v[j]=v[i];
				v[i]=a;
				b=num[j];
				num[j]=num[i];
				num[i]=b;
			}
		}
	}
	if(v[i]==v[i+1]&&num[i]>num[i+1]){
			c=num[i];
			num[i]=num[j];
			num[j]=c;
		}
	printf("%d",num[0]);
	for(i=0;i<n-1;i++){
		if(v[i]==v[i+1]&&num[i]>num[i+1]){
			c=num[i];
			num[i]=num[j];
			num[j]=c;
		}
		else if(v[i]>v[i+1]){
			break;
		}
		
		printf(",%d",num[i+1]);
		
		
	}
	printf("\n");
	
	return 0;
}
int main() {
	struct data1 {
		int num;
		float min;
	} data[1000], temp;
	int n, i,j;
	float sum=0, max;
	scanf("%d", &n);
	for(i=0;i<n;i++) {
		scanf("%d", &data[i].num);
		sum+=data[i].num;
	}
	sum=sum/n;
	for(i=0;i<n;i++) {
		if(data[i].num>=sum) {
			data[i].min=data[i].num-sum;
		} else {
			data[i].min=sum-data[i].num;
		}
	}
	for(i=0;i<n;i++) {
		for(j=n-1;j>0;j--) {
			if(data[j].min>data[j-1].min) {
				temp=data[j];
				data[j]=data[j-1];
				data[j-1]=temp;
				
			}
		}
	}
	max=data[0].min;
	printf("%d", data[0].num);
	for(i=1;fabs(data[i].min-max)<1e-6;i++) {
		printf(",%d", data[i].num);
	}
	return 0;
}
void main()
{
	int n,i,j,k,t,a[300],sum=0,s=0;
	float average,b[300],max=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	for(i=0;i<n-1;i++)   //????
	{
		k=i;
		for(j=i+1;j<n;j++)
		{
			if(a[k]>a[j]) k=j;
		}
		if(k!=i)
		{
			t=a[i];
			a[i]=a[k];
			a[k]=t;
		}
	}
	for(i=0;i<n;i++)
	{
		sum=sum+a[i];
	}
	average=(float)sum/n;
	for(i=0;i<n;i++)
	{
		if(a[i]-average>0) b[i]=a[i]-average;
		else if(a[i]-average<=0) b[i]=average-a[i];
	}
	for(i=1,max=b[0],k=1;i<n;i++)
	{
		if(b[i]>=max) 
		{
			max=b[i];
			k=k+1;
		}
	}
	if(k==1)
	{
		for(i=0;i<n;i++)
		{
			if(max==b[i])
			{
				printf("%d\n",a[i]);
			}
		}
	}
	else if(k>1)
	{
		for(i=0,s=0;i<n;i++)
		{
			if(max==b[i])
			{
				if(s==0)
				{
					printf("%d",a[i]);
					s++;
				}
				else if(s!=0)
				{
					printf(",%d",a[i]);
				}
			}
		}
	}
}
int main()
{
	int i,j,k,l,m,n;
	double average,sum=0.0,max;
	int a[305];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		sum+=a[i];
	}
	average=sum/n;
	max=fabs(a[0]-average);
   // printf("%lf  %lf",average,max);
	for(i=1;i<n;i++)
	{
		if(fabs(a[i]-average)>max) max=fabs(a[i]-average);
	}
    for(i=0;i<n;i++)
	{
		if(max-fabs(a[i]-average)<1e-6) {printf("%d",a[i]);
		break;}
	}
	for(i++;i<n;i++)
	{

		if(max-fabs(a[i]-average)<(1e-6)) printf(",%d",a[i]);
	}
	return 0;
}
int main()
{
	unsigned int i,n,a[M],flag=1;
	double ave=0,max=0;

	scanf("%u",&n);
	for (i=0;i<n;i++) 
	{
		scanf("%u",&a[i]);
		ave+=a[i];
	}
	ave=ave/n;

	for (i=0;i<n;i++)
	{
		double c;

		if ((c=fabs(ave-a[i])-max)>0 && fabs(c)>E) max+=c;
	}

	for (i=0;i<n;i++)
		if (fabs(fabs(a[i]-ave)-max)<E) 
		{
			if (!flag) printf(",");
			printf("%u",a[i]);
			if (flag) flag=0;
		}

	return 0;
}
int bubble_sort(float a[300][2], float b[300][2], int n)
{
	int i, j=0, count;
	float  temp1, temp2;
	for (j=1; j<n; j++)	
	{
		for(i=0; i<n-j; i++)
		{		
			if (a[i][1]<a[i+1][1])		
			{			
				temp1=a[i][0];
				temp2=a[i][1];
				a[i][0]=a[i+1][0];
				a[i][1]=a[i+1][1];
				a[i+1][0]=temp1;
				a[i+1][1]=temp2;
			}	
		}
	}
	j=0;
	for(i=0; i<n; i++)
	{
		if(a[0][1] == a[i][1])
		{
			b[j][0]=a[i][0];
			b[j][1]=a[i][1];
		    j++;
		}
		if(a[0][1] != a[i][1])
			break;
		}
	count=i;
	for(j=1; j<count; j++)
		if(b[0][1]==0)
			break;
		else
		{
		for(i=0; i<count-j; i++)
			if(b[i][0]>b[i+1][0] && b[i+1][0]!=0)
			{
				temp1=b[i][0];
				temp2=b[i][1];
				b[i][0]=b[i+1][0];
				b[i][1]=b[i+1][1];
				b[i+1][0]=temp1;
				b[i+1][1]=temp2;
			}
		}
	return(count);
}


int main()
{
	float a[300][2], sum=0;
	float b[300][2]={0};
	int n, i, count;
	float average;
	scanf("%d", &n);
	for(i=0; i<n; i++)
	{
		scanf("%f", &a[i][0]);
		sum=sum+a[i][0];
	}
	average=(float)sum/n;
	for(i=0; i<n; i++)
	{
		if(a[i][0]-average>0)
			a[i][1]=a[i][0]-average;
		else
			a[i][1]=average-a[i][0];
	}
	count = bubble_sort(a, b, n);
	for(i=0; i<count; i++)
	{
		if(i==0)
			printf("%.0f", b[i][0]);
		else
			printf(",%.0f", b[i][0]);
	}
	printf("\n");
	return 0;
}
int main(){
	int a[300],n,i,j,he=0,temp,num=0;
	float pingjun,max;
	cin>>n;
	for(i=0;i<=n-1;i++)
	{
		cin>>a[i];
		he+=a[i];
	}
	pingjun=(float)he/(float)n;
	for(i=n-1;i>=1;i--)
		for(j=0;j<=i-1;j++)
		{
			if(a[j]>a[j+1])
			{
				temp=a[j+1];
				a[j+1]=a[j];
				a[j]=temp;
			}
		}
	for(i=0;i<=n-1;i++)
		if(abs(a[i]-pingjun)>max)
			max=abs(a[i]-pingjun);
	for(i=0;i<=n-1;i++)
		if(abs(abs(a[i]-pingjun)-max)<0.1)
		{
			num++;
			if(num==1)
				cout<<a[i];
			if(num>1)
				cout<<","<<a[i];
		}
	return 0;

}
void main()
{
	int n,i,j,k,a[300];
	float d=0,m=0,p=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);d=d+a[i];
	}
	d=(float)d;                    
	d=d/n;
	for(i=0;i<n;i++)
	{
		if(a[i]-d>=0)
		{if(a[i]-d>p)
		{p=a[i]-d;j=i;}}
		else
		{if(d-a[i]>m)
		{m=d-a[i];k=i;}
		}
	}
	if(p>m)
		printf("%d",a[j]);
	else if(p<m)
		printf("%d",a[k]);
		else printf("%d,%d",a[k],a[j]);
}
float f(float a)
{
	if(a<0)
	return -a;
	else
	return a;
}
int main()
{
	float n;
	cin>>n;
    double a[100];
	int i,j;
	float sum=0;
	for(i=1;i<=n;i++)
	{
		cin>>a[i];
		sum=sum+a[i];
	} 
	float ave,t;
	ave=sum/n;
	
	for(i=1;i<=n;i++)
	  {
	  	for(j=1;j<=n-i;j++)
	  	{
	  		if(a[j+1]<a[j])
	  		{
	  		  t=a[j];a[j]=a[j+1];a[j+1]=t;	
	  		}
	  	}
	  }
	float max=f(a[1]-ave);
	for(i=2;i<=n;i++)
	{
		
		if(f(a[i]-ave)>max)
		max=f(a[i]-ave);
	}
	float z=0;  
	for(i=1;i<=n;i++)
	{   
	
	
	    
		if((f(a[i]-ave)==max)&&(z==0))
		{
		 cout<<a[i];
		 z=1;
		 continue;
	    }
	    if((f(a[i]-ave)==max)&&(z==1))
		{
		 cout<<",";	
		 cout<<a[i];
		 z=1;
	    }
		
	}  
	return 0;  
	  
	
}
int main()
{
	int n,min=1000, max=0;
	float average=0.0, sum=0;
	cin>>n;
	int array[N];
	for(int i=0; i<n; i++)
	{
		cin>>array[i];
		sum+=array[i];
		if(array[i]>max) max=array[i];
		if(array[i]<min) min=array[i];
	}
	average=sum/n;
	float cha=0;
	
	if(fabs(max-average)>fabs(min-average))
	cout<<max<<endl;
	else if(fabs(max-average)<fabs(min-average))
	cout<<min<<endl;
	else
	cout<<min<<","<<max<<endl;
	
	return 0;
}
int main()
{
    double Numbers[500]={0};
    double Temp[100]={-1};
    double Ave=0;
    double Sum=0;
    double Max=0;
    double Exchange=0;
    int k=0;
	int n=0;
	int i=0;
    int j=0;
	cin>>n;
	for (i=0;i<n;i++)
    {cin>>Numbers[i];
     Sum+=Numbers[i];}
    Ave=Sum/n;
    for (i=0;i<n;i++)
    { if (fabs(Numbers[i]-Ave)>Max)
       {Max=fabs(Numbers[i]-Ave);}
    }
   for (i=0;i<n;i++)
   {if (fabs(fabs(Numbers[i]-Ave)-Max)<1e-5)
     {Temp[k]=Numbers[i];
      k++;
     }
   }
  if (k==1)
    {cout<<Temp[0]<<endl;}
  else
    { for (i=0;i<k-1;i++)
       {  for (j=0;j<k-1;j++)
           { if (Temp[j]>Temp[j+1])
                  {  Exchange=Temp[j];
                     Temp[j]=Temp[j+1];
                     Temp[j+1]=Exchange;
                  }
           }
       }
     cout<<Temp[0];
     for (i=1;i<k;i++)
     {cout<<","<<Temp[i];}
     cout<<endl;
    }
  



return 0;
}
float cc(int x,float y)
{
	if (x>y)
		return(x-y);
	else return(y-x);
}
void main()
{
	int n,i,p=0,j;
	float sum=0,t=0;
	int a[301],b[301];
	scanf("%d",&n);
	for (i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		sum+=a[i];
	}
	sum=sum/n;
	for (i=1;i<=n;i++)
		if (cc(a[i],sum)>t)
			t=cc(a[i],sum);
	for (i=1;i<=n;i++)
	{
		if (cc(a[i],sum)==t)
		{
			p++;
			b[p]=a[i];
		}
	}
	for (i=1;i<p;i++)
	{
		for (j=1;j<=p-i;j++)
		{
			if (b[j]>b[j+1])
			{
				t=b[j];
				b[j]=b[j+1];
				b[j+1]=t;
			}
		}
	}
	if (p==1)
		printf("%d",b[1]);
	else
	{
		printf("%d",b[1]);
		for (i=2;i<=p;i++)
			printf(",%d",b[i]);
	}
}
int main()
{
	int n,a[500],min=100000,max=0,sum=0;
	cin>>n;
	for(int i=0;i<n;i++) cin>>a[i];
	for(int i=0;i<n;i++)
	{
		if(a[i]>max) max=a[i];
		if(a[i]<min) min=a[i];
		sum+=a[i];
	}
	if(sum-min*n<max*n-sum) cout<<max;
	else if(sum-min*n>max*n-sum) cout<<min;
	else cout<<min<<','<<max;
	return 0;
}
void main()
{
	int a[301],i,j,n,sum=0,max,temp;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		sum=sum+a[i];
	}
	for(i=0;i<n-1;i++)
	{
		for(j=i+1;j<=n-1;j++)
			if(a[j]<a[i])
			{
				temp=a[i];
				a[i]=a[j];
				a[j]=temp;
			}
	}
	if((a[0]+a[n-1])*n==sum*2)
		printf("%d,%d\n",a[0],a[n-1]);
	else if((a[0]+a[n-1])*n<sum*2)
		printf("%d\n",a[0]);
	else if((a[0]+a[n-1])*n>sum*2)
		printf("%d\n",a[n-1]);
}
struct prin
{
	double b;
	int a,flag;
};
int main()
{
	double n,ar=0;
	struct prin p[10000];
	int i,j;
	double k;
	scanf("%lf",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&p[i].a);
	}
	for(i=0;i<n;i++)
	{
		ar=ar+p[i].a/n;
	}
	for(i=0;i<n;i++)
	{
		p[i].b=(double)fabs(p[i].a-ar);
		p[i].flag=0;
	}
	k=p[0].b;
	for(i=0;i<n;i++)
	{
		if(p[i].b>k)
			k=p[i].b;
	}
	for(i=0;i<n;i++)
	{
		if(p[i].b==k)
		{
			p[i].flag=1;
		}
	}
	for(i=0;i<n;i++)
	{
		if(p[i].flag==1){
			printf("%d",p[i].a);
			break;
		}
	}
	for(j=i+1;j<n;j++)
	{
		if(p[j].flag==1)
			printf(",%d",p[j].a);
	}
	return 0;
}
int main()
{
int n,i,a[100],j,t,c[100];
int s=0;
float max,m,b[100];
 scanf("%d",&n);
 for(i=0;i<n;i++)
 {
  scanf("%d",&a[i]);
  s=s+a[i];
 }for(i=0;i<n;i++)
 {
  for(j=n-1;j>i;j--)
  {
   if(a[j]<a[j-1])
   {
    t=a[j-1];
    a[j-1]=a[j];
    a[j]=t;
   }
  }
 }
 for(i=0;i<n;i++)
 {
  m=(float)s/n;
  b[i]=a[i]-m;
  if(b[i]<0.0)
   b[i]=-b[i];
  
 }
 max=0.0;
 for(i=0;i<n;i++)
 {
  if(b[i]>=max)
  {
   max=b[i];
 
  
  }

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

 for(i=1;i<j;i++)
  {
printf(",%d",c[i]);  
  
 }
 
  return 0;
}
int main()
{
int n,i,t=0,f[300]={0};
float a[300]={0},d[300]={0},s=0,max=0;
scanf("%d",&n);
for (i=0;i<n;i++)
{
scanf("%f",&a[i]);
s=s+a[i];
}
s=s/n;
for (i=0;i<n;i++)
{
d[i]=fabs((float)a[i]-s);
if (d[i]>max) max=d[i]; 
}
for (i=0;i<n;i++)
{
//printf("%f,",(d[i]-max));
if ((max-d[i])<1e-6)
{
f[t]=a[i];
t++;
}
}
//printf("%f %f\n",s,max);
for (i=0;i<t-1;i++) printf("%d,",f[i]);
printf("%d\n",f[t-1]);
return(0);
}
void main()
{
	int i,j,r=0,t;
	float n,sum=0;
	float a[100]={0},b[100]={0};
	int c[100]={0};
	scanf("%f",&n);
	for(i=0;i<n;i++)
	{
		scanf("%f",&a[i]);
		sum+=a[i];
	}
	sum=sum/n;
	for(i=0;i<n;i++)
	{
		for(j=i;j<n;j++)
		{
			if(a[i]>a[j])
			{
				t=a[i];
				a[i]=a[j];
				a[j]=t;
			}
		}
	}
	for(i=0;i<n;i++)
	{
		if(a[i]>sum) b[i]=a[i]-sum;
		else if(a[i]<sum) b[i]=sum-a[i];
	}
	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
		{
			if(b[i]<b[j]) break;
		}
		if(j==n) 
		{
			c[r]=a[i];
			r++;
		}
	}
	for(i=0;i<r;i++)
	{
		printf("%d",c[i]);
		if(i!=r-1) printf(",");
	}

}
int main()
{
	int n;
	int i,j;
	int a[300];
	float b[300];
	int c[300];
	int t=0;
	int sum=0;
	int temp;
	float ave;
	float max=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		sum=sum+a[i];
	}
	ave=(float)sum/n;
	for(i=0;i<n;i++)
	{
		if(a[i]-ave>=0)
			b[i]=a[i]-ave;
		else
			b[i]=ave-a[i];
		if (b[i]>max)
			max=b[i];
	}
	for(i=0;i<n;i++)
	{
		if(b[i]==max)
		{
			c[t]=a[i];
			t++;
		}
	}
	for(i=1;i<t;i++)
	{
		for(j=0;j<t-i;j++)
		{
			if(c[j]>c[j+1])
			{
				temp=c[j];
				c[j]=c[j+1];
				c[j+1]=temp;
			}
		}
	}
	for(i=0;i<t-1;i++)
		printf("%d,",c[i]);
	printf("%d",c[t-1]);
	return 0;
}
void main()
{
	int a[300],n,i,j,temper;
	float average,sum=0,b[300];
    scanf("%d",&n);
	for(i=0;i<n;i++)
	{
	scanf("%d",&a[i]);
	sum=sum+a[i];
	}
	average=sum/n;
    //printf("%f",average);
	for(i=0;i<n;i++)
	{
		if(a[i]>average)
		b[i]=a[i]-average;
		else
		b[i]=average-a[i];
	}
	//for(i=0;i<n;i++)
	//{
		//printf("%d",b[i]);
	//}
	for(i=0;i<n-1;i++)
	{
		for(j=i+1;j<n;j++)
		{
			if(b[i]<b[j])
			{temper=a[i];
			a[i]=a[j];
			a[j]=temper;
			temper=b[i];
			b[i]=b[j];
			b[j]=temper;}

		}

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

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

	return 0;
}
double num[400];
double dis[400];

int main()
{
    int n;
    int i,j;
    double temp;
    double ave=0;
    const double min=1e-6;
    double max=0;
    
    cin>>n;
    for(i=0;i<n;i++)
        {
         cin>>num[i];
         ave+=num[i];
         }     
    ave=ave/n;
    for(i=n-2;i>=0;i--)
        for(j=0;j<=i;j++)
            if(num[j]>num[j+1])
               {
                temp=num[j];
                num[j]=num[j+1];
                num[j+1]=temp;                 
               }
       
    for(i=0;i<n;i++)    
        dis[i]=fabs(num[i]-ave);
    for(i=0;i<n;i++)
        if(max<dis[i])max=dis[i];
    for(j=n-1;j>=0;j--)
        if(fabs(max-dis[j])<min) break;
    for(i=0;i<j;i++)
        {if(fabs(max-dis[i])<min)cout<<num[i]<<",";}
    cout<<num[j];
    
   
    return 0;
}
//#include<string.h>
int i,n,a[1000],max,min;
float aver;

int main(){
    
    scanf("%d",&n);
    scanf("%d",&a[0]);
    min=a[0];max=a[0];aver=a[0];
    for(i=1;i<n;i++){
        scanf("%d",&a[i]);
        aver+=a[i];
        if(a[i]>max)  max=a[i];
        if(a[i]<min)  min=a[i];
    }
    aver/=n;
    
    if(max+min-aver*2==0)  printf("%d,%d\n",min,max);
    if(max+min-aver*2<0)  printf("%d\n",min);
    if(max+min-aver*2>0)  printf("%d\n",max);

scanf("%d",&i);
return 0;
}
int main()
{
	int n, i, j, a[300], tempint, count = 1;
	double aver = 0, b[300], temp;
	cin >> n;
	for(i = 0; i < n; i++)
	{
		cin >> a[i];
		aver += a[i];
	}
	aver = aver / n;
	for(i = 0; i < n; i++)
	{
		b[i] = fabs(aver - a[i]);
	}
	for(i = 0; i < n - 1; i++)
	{
		for(j = 0; j < n - 1 - i; j++)
		{
			if(b[j] < b[j+1])
			{
				temp = b[j];
				b[j] = b[j+1];
				b[j+1] = temp;
				tempint = a[j];
				a[j] = a[j+1];
				a[j+1] = tempint;
			}
		}
	}
	i = 0;
	while(fabs(b[i] - b[i+1]) < 10e-6)
	{
		count++;
		i++;
	}
	cout << a[0];
	for(i = 1; i <= count - 1; i++)
	{
		cout << "," << a[i] ;
	}
	cout << endl;
	return 0;
}