stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include<cstdio>

#include<vector>

#include<cmath>

using namespace std;

struct node

{

	double x,y,z;

};

struct node x[21];

vector<double>a;

int b[25],i,n,m,j;

double d[21][21],maxx=0,ans;



double dis(int i,int j)

{

 return 

((x[i].x-x[j].x)*(x[i].x-x[j].x)+(x[i].y-x[j].y)*(x[i].y-x[j].y)+(x[i].z-x[j].z)*(x[i].z-x[j].z));

}

void dfs(int v,int k)

{

	int x,i,j,t;

 b[v]=1;

 if(k==m)

 {

	ans=0;

	for(i=0;i<a.size();i++)

	{

		x=a[i];

		for(j=0;j<a.size();j++)

			if(j!=i)

			{

				t=a[j];

				ans=ans+d[x][t];

			}

	}

	if(ans/2>maxx)maxx=ans/2;

	return;

 }

 a.push_back(v); k++;

 if(v+1<=n)dfs(v+1,k);

 a.pop_back(); k--;

 if(v+1<=n)dfs(v+1,k);

 b[v]=0;

}

int main()

{

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

	for(i=0;i<n;i++)

		scanf("%lf%lf%lf",&x[i].x,&x[i].y,&x[i].z);

    for(i=0;i<n;i++)

		for(j=0;j<n;j++)

			d[i][j]=dis(i,j);

	dfs(0,0);

	printf("%lf\n",maxx);

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 4.392672965585118x):
#include<stdio.h>

#include<math.h>

#include<string.h>

#define MAX 25

double x[MAX],y[MAX],z[MAX],Dis[MAX][MAX],Max;

int N,M,ipos[MAX];

double dis(int n,int m)

{

	return pow(x[n]-x[m],2)+pow(y[n]-y[m],2)+pow(z[n]-z[m],2);

}

void dfs(int cur,int count,double ans)

{

	double k=ans;

	int i;

	if(count==M)

	{

		if(Max<ans)

			Max=ans;

		return ;

	}

	if(cur>=N)

		return;

	if(count>M)

		return;

	dfs(cur+1,count,ans);

	ipos[cur]=1;

	for(i=0;i<cur;i++)

	{

		if(ipos[i]==1)

			k+=Dis[i][cur];

	}

	dfs(cur+1,count+1,k);

	ipos[cur]=0;

	return ;

}

int main()

{	

	int i,j;

	while(scanf("%d%d",&N,&M)!=EOF)

	{

		for(i=0;i<N;i++)

			scanf("%lf%lf%lf",&x[i],&y[i],&z[i]);

		memset(Dis,0,sizeof(Dis));

		memset(ipos,0,sizeof(ipos));

		Max=0;

		for(i=0;i<N;i++)

			for(j=i+1;j<N;j++)

				Dis[i][j]=dis(i,j);

			dfs(0,0,0);

			printf("%.20lf\n",Max);

	}

	return 0;

}
// Slower C++ solution:
# include <math.h>

# include <stdio.h>

# include <string.h>

# include <stdlib.h>

# include <algorithm>

# include <iostream>



# define For(i,x,y)   for((i)=(x);i<(y);(i)++)

# define MAX(x,y)   ((x)>(y)? (x):(y))

# define MIN(x,y)   ((x)<(y)? (x):(y))

# define sz(a)      (sizeof(a))

# define mem(a)     (memset((a),0,sizeof(a)))



# define fop freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);

# define print(x) (printf("%d\n",x))

# define scan(x) (scanf("%d",&x))

# define printc(x) (printf("%c\n",x))

# define scanc(x) (scanf("%c",&x))

# define INF 0x7fffffff



using namespace std;

typedef long long           ll;

int v[25],m,n;

double a[25],b[25],c[25],d[25][25],ans;

int dfs(int i,int j,double x)

{

    int k;

    double kk=0;

    // printf("%d %d %lf\n",i,j,x);

    if (j>=m)

    {



        if (x>ans) ans=x;

        return 0;

    }

    if (i>n) return 0;

    v[i]=1;

    For (k,1,n+1)

      if (v[k]) kk+=d[i][k];

    dfs(i+1,j+1,x+kk);

    v[i]=0;

    dfs(i+1,j,x);

    return 0;

}

int main()

{

    int i,j;

    scan(n);scan(m);

    mem(v);

    For(i,1,n+1)

    {

        scanf("%lf%lf%lf",&a[i],&b[i],&c[i]);

    }

    For (i,1,n+1)

      For (j,1,n+1)

        d[i][j]=(a[i]-a[j])*(a[i]-a[j])+(b[i]-b[j])*(b[i]-b[j])+(c[i]-c[j])*(c[i]-c[j]);

    dfs(1,0,0);

    printf("%.10lf\n",ans);

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 4.680057172894386x):
#include<stdio.h>

#include<math.h>

#include<string.h>

#define MAX 25

double x[MAX],y[MAX],z[MAX],Dis[MAX][MAX],Max;

int N,M,ipos[MAX];

double dis(int n,int m)

{

	return pow(x[n]-x[m],2)+pow(y[n]-y[m],2)+pow(z[n]-z[m],2);

}

void dfs(int cur,int count,double ans)

{

	double k=ans;

	int i;

	if(count==M)

	{

		if(Max<ans)

			Max=ans;

		return ;

	}

	if(cur>=N)

		return;

	if(count>M)

		return;

	dfs(cur+1,count,ans);

	ipos[cur]=1;

	for(i=0;i<cur;i++)

	{

		if(ipos[i]==1)

			k+=Dis[i][cur];

	}

	dfs(cur+1,count+1,k);

	ipos[cur]=0;

	return ;

}

int main()

{	

	int i,j;

	while(scanf("%d%d",&N,&M)!=EOF)

	{

		for(i=0;i<N;i++)

			scanf("%lf%lf%lf",&x[i],&y[i],&z[i]);

		memset(Dis,0,sizeof(Dis));

		memset(ipos,0,sizeof(ipos));

		Max=0;

		for(i=0;i<N;i++)

			for(j=i+1;j<N;j++)

				Dis[i][j]=dis(i,j);

			dfs(0,0,0);

			printf("%.20lf\n",Max);

	}

	return 0;

}
// Slower C++ solution:
#include <vector>

#include <list>

#include <map>

#include <set>

#include <deque>

#include <stack>

#include <memory.h>

#include <bitset>

#include <algorithm>

#include <functional>

#include <numeric>

#include <utility>

#include <sstream>

#include <iostream>

#include <iomanip>

#include <cstdio>

#include <cmath>

#include <cstdlib>

#include <ctime>

#include <cstring>



using namespace std;











int i,j;

int nn,mm;

double l[100];

double a[100];

double b[100];

double core[100][100];



int s[100];

double maxx=0.0;

void print(int N)

{

     double num=0.0;

for(int ii=1;ii<=N;ii++)

{

 for(int jj=1;jj<=N;jj++)

{

 //printf("ii=%d jj=%d\n",s[ii],s[jj]);

 num+=core[s[ii]][s[jj]];

}

//printf("\n");

}

 if(num>maxx){maxx=num;}

}

void zuhe(int a,int n,int M,int N)

{

if(n<=N)

{

int i;

for(int ii=a;ii<=M-N+n;ii++)

{

s[n]=ii;

if(n==N)

print(N);

else

zuhe(a+1,n+1,M,N);

a++;

}

}

}







int main()

{

scanf("%d%d",&nn,&mm);

if(mm==1){printf("0.00000000000000000000\n");return 0;}

for(i=1;i<=nn;i++)

{

    scanf("%lf%lf%lf",&l[i],&a[i],&b[i]);

}

int topp=0;



for(i=1;i<=nn;i++)

{

               // printf("%.20f\n",(l[i]*l[i]+a[i]*a[i]+b[i]*b[i]));

}



for(i=1;i<=nn;i++)

{

    for(j=1;j<=nn;j++)

    {

       

       core[i][j]=((l[i]-l[j])*(l[i]-l[j])+(a[i]-a[j])*(a[i]-a[j])+(b[i]-b[j])*(b[i]-b[j]));

       //printf("%.2f ",core[i][j]);

       

    }

    //printf("\n");

}

zuhe(1,1,nn,mm);

printf("%.20f\n",maxx/2);



//system("pause");

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 4.658591038315537x):
#include<stdio.h>

#include<math.h>

#include<string.h>

#define MAX 25

double x[MAX],y[MAX],z[MAX],Dis[MAX][MAX],Max;

int N,M,ipos[MAX];

double dis(int n,int m)

{

	return pow(x[n]-x[m],2)+pow(y[n]-y[m],2)+pow(z[n]-z[m],2);

}

void dfs(int cur,int count,double ans)

{

	double k=ans;

	int i;

	if(count==M)

	{

		if(Max<ans)

			Max=ans;

		return ;

	}

	if(cur>=N)

		return;

	if(count>M)

		return;

	dfs(cur+1,count,ans);

	ipos[cur]=1;

	for(i=0;i<cur;i++)

	{

		if(ipos[i]==1)

			k+=Dis[i][cur];

	}

	dfs(cur+1,count+1,k);

	ipos[cur]=0;

	return ;

}

int main()

{	

	int i,j;

	while(scanf("%d%d",&N,&M)!=EOF)

	{

		for(i=0;i<N;i++)

			scanf("%lf%lf%lf",&x[i],&y[i],&z[i]);

		memset(Dis,0,sizeof(Dis));

		memset(ipos,0,sizeof(ipos));

		Max=0;

		for(i=0;i<N;i++)

			for(j=i+1;j<N;j++)

				Dis[i][j]=dis(i,j);

			dfs(0,0,0);

			printf("%.20lf\n",Max);

	}

	return 0;

}
// Slower C++ solution:
#include<cstdio>

#include<cstring>

#include<cstdlib>

#include<ctime>

#include<algorithm>

#include<iostream>

#include<string>

#include<cmath>

#include<queue>

#include<vector>

#include<map>

using namespace std;

double Rel[30][30];

struct Point

{

    double x,y,z;

}P[30];

int main()

{

    int s,i,j,M,N;

    double Ans,tmp;

    while (~scanf("%d%d",&N,&M))

    {

        for (i=0;i<N;i++)

            scanf("%lf%lf%lf",&P[i].x,&P[i].y,&P[i].z);

        for (i=0;i<N;i++)

        {

            Rel[i][i]=0;

            for (j=i+1;j<N;j++)

                Rel[i][j]=Rel[j][i]=(P[i].x-P[j].x)*(P[i].x-P[j].x)+(P[i].y-P[j].y)*(P[i].y-P[j].y)+(P[i].z-P[j].z)*(P[i].z-P[j].z);

        }

        Ans=0;

        for (s=1;s<(1<<N);s++)

            if (__builtin_popcount(s)==M)

            {

                tmp=0;

                for (i=0;i<N;i++)

                    if (s&(1<<i))

                        for (j=i+1;j<N;j++)

                            if (s&(1<<j))

                                tmp+=Rel[i][j];

                if (tmp>Ans)

                    Ans=tmp;

            }

        printf("%.15lf\n",Ans);

    }

}

// Faster C++ solution for the same problem (measured speedup: 4.832040104293923x):
#include <stdio.h>

#define MAXN (1<<21)

double f[1050000];

double map[21][21],x[21],y[21],z[21];

int num(int a)

{

    int ans=0;

    for(int i=0;i<20;i++)

        if((a>>i)&1)

            ans++;

    return ans;

}

int main()

{

    int n,m,i,j,a,b,t;



    while(scanf("%d%d",&n,&m)!=EOF)

    {

        for(i=0;i<n;i++)

        {

            scanf("%lf%lf%lf",x+i,y+i,z+i);

        }

        for(i=0;i<n;i++)

            for(map[i][i]=0,j=0;j<i;j++)

                map[i][j]=map[j][i]=(x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])+(z[i]-z[j])*(z[i]-z[j]);



        int temp;

        double ans=0;



        for(i=1;i<(1<<n);i++)

        {

            f[i]=0;

            temp=num(i);

            //printf("%d %d\n",i,temp);

            if(temp==1)

                    f[i]=0;

            else if(temp==2){

               // puts("!");

                for(t=j=0;j<20;j++)

                {

                    if((i>>j)&1)

                    {

                        if(t==0)

                            a=j,t=1;

                        else

                            b=j;

                    }

                }



                f[i]=map[a][b];// printf("%d %d %d\n\n",a,b,f[i]);

            }

            else{

                for(j=0;j<20;j++)

                {

                    if((i>>j)&1)

                        f[i]+=f[i-(1<<j)];

                }

                f[i]/=(double)(temp-2);

            }

           // printf("%d %lf\n\n",i,f[i]);

            if(temp==m&&ans<f[i])

                    ans=f[i];

        }



        printf("%.10lf\n",ans);

    }

    return 0;

}
// Slower C++ solution:
/*

ID: qazzaq71

PROG: test

LANG: C++

*/

#include <algorithm>

#include <iostream>

#include <cstdio>

#include <cmath>

#include <cstdlib>

#include <ctime>

#include <cstring>

#include <cassert>



using namespace std;



#define REP(a,n) for(int a=0;a<(n);++a)

#define FOR(a,b,c) for(int a=(b);a<=(c);++a)

#define FORD(a,b,c) for(int a=(b);a>=(c);--a)

#define swap(t,a,b) t=a,a=b,b=t

#define min(a,b) (a)<(b)?(a):(b)

#define max(a,b) (a)>(b)?(a):(b)



typedef long long ll;

typedef unsigned long long ull;



int n,m;



double c[50][3];

double maxDist=-1;

int res[50];



void judge(void){

	double dist=0;

	FOR(i,0,m-1)FOR(j,i+1,m-1){

		dist+=	(c[res[i]][0]-c[res[j]][0])*(c[res[i]][0]-c[res[j]][0])+

				(c[res[i]][1]-c[res[j]][1])*(c[res[i]][1]-c[res[j]][1])+

				(c[res[i]][2]-c[res[j]][2])*(c[res[i]][2]-c[res[j]][2]);

	}

	if(dist>maxDist)maxDist=dist;

}

void dfs(int k,int cur){

	if(k==m){

		judge();

		return ;

	}

	FOR(i,cur,n-1){

		res[k]=i;

		dfs(k+1,i+1);

	}

}

int main(){

#ifdef DEBUG

	FILE * ptrFILE=freopen("a.txt","r",stdin);

	assert(ptrFILE!=NULL);

#endif

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

	memset(c,0,sizeof(c));

	FOR(i,0,n-1)

		scanf("%lf%lf%lf",&c[i][0],&c[i][1],&c[i][2]);

	maxDist=-1;

	dfs(0,0);

	printf("%f\n",maxDist);

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 4.786665066522786x):
#include <stdio.h>

#define MAXN (1<<21)

double f[1050000];

double map[21][21],x[21],y[21],z[21];

int num(int a)

{

    int ans=0;

    for(int i=0;i<20;i++)

        if((a>>i)&1)

            ans++;

    return ans;

}

int main()

{

    int n,m,i,j,a,b,t;



    while(scanf("%d%d",&n,&m)!=EOF)

    {

        for(i=0;i<n;i++)

        {

            scanf("%lf%lf%lf",x+i,y+i,z+i);

        }

        for(i=0;i<n;i++)

            for(map[i][i]=0,j=0;j<i;j++)

                map[i][j]=map[j][i]=(x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])+(z[i]-z[j])*(z[i]-z[j]);



        int temp;

        double ans=0;



        for(i=1;i<(1<<n);i++)

        {

            f[i]=0;

            temp=num(i);

            //printf("%d %d\n",i,temp);

            if(temp==1)

                    f[i]=0;

            else if(temp==2){

               // puts("!");

                for(t=j=0;j<20;j++)

                {

                    if((i>>j)&1)

                    {

                        if(t==0)

                            a=j,t=1;

                        else

                            b=j;

                    }

                }



                f[i]=map[a][b];// printf("%d %d %d\n\n",a,b,f[i]);

            }

            else{

                for(j=0;j<20;j++)

                {

                    if((i>>j)&1)

                        f[i]+=f[i-(1<<j)];

                }

                f[i]/=(double)(temp-2);

            }

           // printf("%d %lf\n\n",i,f[i]);

            if(temp==m&&ans<f[i])

                    ans=f[i];

        }



        printf("%.10lf\n",ans);

    }

    return 0;

}
// Slower C++ solution:
#include <iostream>

#include <algorithm>

#include <cmath>

#include <cstdio>

#include <cstdlib>

#include <queue>

#include <vector>

#include <stack>

#include <set>

#include <map>

#include <string>

#include <cctype>

#include <cstring>

#include <string>

#include <numeric>

#include <functional>

#include <iomanip>

#include <ctime>



using namespace std;



typedef long long LL;

typedef unsigned long long uLL;



struct NODE

{

    double x,y,z;

}nd[22];

int n,m;

double res;

double dis[22][22];

int pik[22];

int len;

void DFS(int u,int last)

{

    if(u==m)

    {

        double sum=0;

        for(int i=0;i<u;i++)

        {

            int x=pik[i];

            for(int j=i+1;j<u;j++)

            {

                int y=pik[j];

                sum+=dis[x][y];

            }

        }

        if(res<sum)res=sum;

        return ;

    }

    for(int i=last;i<n;i++)

    {

        pik[u]=i;

        DFS(u+1,i+1);

    }

}



int main()

{

	while(~scanf("%d%d",&n,&m))

	{

	    for(int i=0;i<n;i++)

	    {

	        scanf("%lf%lf%lf",&nd[i].x,&nd[i].y,&nd[i].z);

	    }

	    for(int i=0;i<n;i++)

	    {

	        for(int j=0;j<n;j++)

	        {

	            dis[i][j]=(nd[i].x-nd[j].x)*(nd[i].x-nd[j].x)+(nd[i].y-nd[j].y)*(nd[i].y-nd[j].y)+(nd[i].z-nd[j].z)*(nd[i].z-nd[j].z);

	        }

	    }

	    res=0;

	    DFS(0,0);

	    printf("%.10lf\n",res);

	}

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 4.7931440557132206x):
#include <stdio.h>

#define MAXN (1<<21)

double f[1050000];

double map[21][21],x[21],y[21],z[21];

int num(int a)

{

    int ans=0;

    for(int i=0;i<20;i++)

        if((a>>i)&1)

            ans++;

    return ans;

}

int main()

{

    int n,m,i,j,a,b,t;



    while(scanf("%d%d",&n,&m)!=EOF)

    {

        for(i=0;i<n;i++)

        {

            scanf("%lf%lf%lf",x+i,y+i,z+i);

        }

        for(i=0;i<n;i++)

            for(map[i][i]=0,j=0;j<i;j++)

                map[i][j]=map[j][i]=(x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])+(z[i]-z[j])*(z[i]-z[j]);



        int temp;

        double ans=0;



        for(i=1;i<(1<<n);i++)

        {

            f[i]=0;

            temp=num(i);

            //printf("%d %d\n",i,temp);

            if(temp==1)

                    f[i]=0;

            else if(temp==2){

               // puts("!");

                for(t=j=0;j<20;j++)

                {

                    if((i>>j)&1)

                    {

                        if(t==0)

                            a=j,t=1;

                        else

                            b=j;

                    }

                }



                f[i]=map[a][b];// printf("%d %d %d\n\n",a,b,f[i]);

            }

            else{

                for(j=0;j<20;j++)

                {

                    if((i>>j)&1)

                        f[i]+=f[i-(1<<j)];

                }

                f[i]/=(double)(temp-2);

            }

           // printf("%d %lf\n\n",i,f[i]);

            if(temp==m&&ans<f[i])

                    ans=f[i];

        }



        printf("%.10lf\n",ans);

    }

    return 0;

}
// Slower C++ solution:
#include <iostream>

#include <cstdio>

#include <cmath>

#include <cstring>

#include <algorithm>



#define INF 0x7fffffff

#define MOD 10000007

#define N 30



using namespace std;



struct node

{

      double a,b,c;

} color[N];

int ans[N];

int n,m;

double Min;



double squr(double a,double b,double c)

{

      return a*a+b*b+c*c;

}

void dfs(int now,int tot)

{

      if(tot==m)

      {

            double cnt=0.0;

            for(int i=1;i<=m;i++)

            {

                  for(int j=i+1;j<=m;j++)

                  {

                        double aa=fabs(color[ans[i]].a-color[ans[j]].a);

                        double bb=fabs(color[ans[i]].b-color[ans[j]].b);

                        double cc=fabs(color[ans[i]].c-color[ans[j]].c);

                        cnt=cnt+squr(aa,bb,cc);

                  }

            }

            if(cnt>Min) Min=cnt;

            return;

      }

      if(m-tot>n-now+1) return;

      for(int i=now;i<=n;i++)

      {

            ans[tot+1]=i;

            dfs(i+1,tot+1);

      }

}

int main()

{

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

      for(int i=1;i<=n;i++)

      {

            scanf("%lf%lf%lf",&color[i].a,&color[i].b,&color[i].c);

      }

      memset(ans,0,sizeof(ans));

      Min=0.0;

      dfs(1,0);

      printf("%lf\n",Min);

      return 0;

}

// Faster C++ solution for the same problem (measured speedup: 4.783495869933381x):
#include <stdio.h>

#define MAXN (1<<21)

double f[1050000];

double map[21][21],x[21],y[21],z[21];

int num(int a)

{

    int ans=0;

    for(int i=0;i<20;i++)

        if((a>>i)&1)

            ans++;

    return ans;

}

int main()

{

    int n,m,i,j,a,b,t;



    while(scanf("%d%d",&n,&m)!=EOF)

    {

        for(i=0;i<n;i++)

        {

            scanf("%lf%lf%lf",x+i,y+i,z+i);

        }

        for(i=0;i<n;i++)

            for(map[i][i]=0,j=0;j<i;j++)

                map[i][j]=map[j][i]=(x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])+(z[i]-z[j])*(z[i]-z[j]);



        int temp;

        double ans=0;



        for(i=1;i<(1<<n);i++)

        {

            f[i]=0;

            temp=num(i);

            //printf("%d %d\n",i,temp);

            if(temp==1)

                    f[i]=0;

            else if(temp==2){

               // puts("!");

                for(t=j=0;j<20;j++)

                {

                    if((i>>j)&1)

                    {

                        if(t==0)

                            a=j,t=1;

                        else

                            b=j;

                    }

                }



                f[i]=map[a][b];// printf("%d %d %d\n\n",a,b,f[i]);

            }

            else{

                for(j=0;j<20;j++)

                {

                    if((i>>j)&1)

                        f[i]+=f[i-(1<<j)];

                }

                f[i]/=(double)(temp-2);

            }

           // printf("%d %lf\n\n",i,f[i]);

            if(temp==m&&ans<f[i])

                    ans=f[i];

        }



        printf("%.10lf\n",ans);

    }

    return 0;

}
// Slower C++ solution:
#include<cstdio>

#include<vector>

#include<cmath>

using namespace std;

struct node

{

	double x,y,z;

};

struct node x[21];

vector<double>a;

int b[25],i,n,m,j;

double d[21][21],maxx=0,ans;



double dis(int i,int j)

{

 return 

((x[i].x-x[j].x)*(x[i].x-x[j].x)+(x[i].y-x[j].y)*(x[i].y-x[j].y)+(x[i].z-x[j].z)*(x[i].z-x[j].z));

}

void dfs(int v,int k)

{

	int x,i,j,t;

 b[v]=1;

 if(k==m)

 {

	ans=0;

	for(i=0;i<a.size();i++)

	{

		x=a[i];

		for(j=0;j<a.size();j++)

			if(j!=i)

			{

				t=a[j];

				ans=ans+d[x][t];

			}

	}

	if(ans/2>maxx)maxx=ans/2;

	return;

 }

 a.push_back(v); k++;

 if(v+1<=n)dfs(v+1,k);

 a.pop_back(); k--;

 if(v+1<=n)dfs(v+1,k);

 b[v]=0;

}

int main()

{

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

	for(i=0;i<n;i++)

		scanf("%lf%lf%lf",&x[i].x,&x[i].y,&x[i].z);

    for(i=0;i<n;i++)

		for(j=0;j<n;j++)

			d[i][j]=dis(i,j);

	dfs(0,0);

	printf("%lf\n",maxx);

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 4.494207572325637x):
#include <stdio.h>

#define MAXN (1<<21)

double f[1050000];

double map[21][21],x[21],y[21],z[21];

int num(int a)

{

    int ans=0;

    for(int i=0;i<20;i++)

        if((a>>i)&1)

            ans++;

    return ans;

}

int main()

{

    int n,m,i,j,a,b,t;



    while(scanf("%d%d",&n,&m)!=EOF)

    {

        for(i=0;i<n;i++)

        {

            scanf("%lf%lf%lf",x+i,y+i,z+i);

        }

        for(i=0;i<n;i++)

            for(map[i][i]=0,j=0;j<i;j++)

                map[i][j]=map[j][i]=(x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])+(z[i]-z[j])*(z[i]-z[j]);



        int temp;

        double ans=0;



        for(i=1;i<(1<<n);i++)

        {

            f[i]=0;

            temp=num(i);

            //printf("%d %d\n",i,temp);

            if(temp==1)

                    f[i]=0;

            else if(temp==2){

               // puts("!");

                for(t=j=0;j<20;j++)

                {

                    if((i>>j)&1)

                    {

                        if(t==0)

                            a=j,t=1;

                        else

                            b=j;

                    }

                }



                f[i]=map[a][b];// printf("%d %d %d\n\n",a,b,f[i]);

            }

            else{

                for(j=0;j<20;j++)

                {

                    if((i>>j)&1)

                        f[i]+=f[i-(1<<j)];

                }

                f[i]/=(double)(temp-2);

            }

           // printf("%d %lf\n\n",i,f[i]);

            if(temp==m&&ans<f[i])

                    ans=f[i];

        }



        printf("%.10lf\n",ans);

    }

    return 0;

}