stablegradients/pie-gem5-pairs huggingface dataset:
// 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.792266513421977x):
#include<cmath>

#include<cstdio>

#include<cstring>

#include<cstdlib>

#include<algorithm>

using namespace std;

const double eps = 1e-10;

const int N=25;



struct point {

    double x,y,z;

}pt[N];

int n,m;

double dis[N][N];



double dist(point p1,point p2) {

    return (p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y)+(p1.z-p2.z)*(p1.z-p2.z);

}



double ret;

int ans[N];

void dfs(int idx,int k,double sum) {

    if(k+(n-idx)+2<m) return;

    if(k==m) {

        ret=max(ret,sum);

        return;

    }



    dfs(idx+1,k,sum);

    double tmp=0;

    for(int i=0;i<k;i++) tmp+=dis[ans[i]][idx];

    ans[k]=idx;

    dfs(idx+1,k+1,sum+tmp);

}



int main()

{

    int i,j,t,cas=0;

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

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

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

        }

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

            for(j=1;j<=n;j++) {

                dis[i][j]=dist(pt[i],pt[j]);

            }

        }



        ret=0.0;

        dfs(1,0,0);



        printf("%.10f\n",ret);

    }

    return 0;

}



/*

20 10

0 0 0

1 1 1

2 2 2

3 3 3

4 4 4

5 5 5

6 6 6

7 7 7

8 8 8

9 9 9

10 10 10

11 11 11

12 12 12

13 13 13

14 14 14

15 15 15

16 16 16

17 17 17

18 18 18

19 19 19

*/
// 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.798753084449328x):
#include<cmath>

#include<cstdio>

#include<cstring>

#include<cstdlib>

#include<algorithm>

using namespace std;

const double eps = 1e-10;

const int N=25;



struct point {

    double x,y,z;

}pt[N];

int n,m;

double dis[N][N];



double dist(point p1,point p2) {

    return (p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y)+(p1.z-p2.z)*(p1.z-p2.z);

}



double ret;

int ans[N];

void dfs(int idx,int k,double sum) {

    if(k+(n-idx)+2<m) return;

    if(k==m) {

        ret=max(ret,sum);

        return;

    }



    dfs(idx+1,k,sum);

    double tmp=0;

    for(int i=0;i<k;i++) tmp+=dis[ans[i]][idx];

    ans[k]=idx;

    dfs(idx+1,k+1,sum+tmp);

}



int main()

{

    int i,j,t,cas=0;

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

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

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

        }

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

            for(j=1;j<=n;j++) {

                dis[i][j]=dist(pt[i],pt[j]);

            }

        }



        ret=0.0;

        dfs(1,0,0);



        printf("%.10f\n",ret);

    }

    return 0;

}



/*

20 10

0 0 0

1 1 1

2 2 2

3 3 3

4 4 4

5 5 5

6 6 6

7 7 7

8 8 8

9 9 9

10 10 10

11 11 11

12 12 12

13 13 13

14 14 14

15 15 15

16 16 16

17 17 17

18 18 18

19 19 19

*/
// 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.789093608178182x):
#include<cmath>

#include<cstdio>

#include<cstring>

#include<cstdlib>

#include<algorithm>

using namespace std;

const double eps = 1e-10;

const int N=25;



struct point {

    double x,y,z;

}pt[N];

int n,m;

double dis[N][N];



double dist(point p1,point p2) {

    return (p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y)+(p1.z-p2.z)*(p1.z-p2.z);

}



double ret;

int ans[N];

void dfs(int idx,int k,double sum) {

    if(k+(n-idx)+2<m) return;

    if(k==m) {

        ret=max(ret,sum);

        return;

    }



    dfs(idx+1,k,sum);

    double tmp=0;

    for(int i=0;i<k;i++) tmp+=dis[ans[i]][idx];

    ans[k]=idx;

    dfs(idx+1,k+1,sum+tmp);

}



int main()

{

    int i,j,t,cas=0;

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

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

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

        }

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

            for(j=1;j<=n;j++) {

                dis[i][j]=dist(pt[i],pt[j]);

            }

        }



        ret=0.0;

        dfs(1,0,0);



        printf("%.10f\n",ret);

    }

    return 0;

}



/*

20 10

0 0 0

1 1 1

2 2 2

3 3 3

4 4 4

5 5 5

6 6 6

7 7 7

8 8 8

9 9 9

10 10 10

11 11 11

12 12 12

13 13 13

14 14 14

15 15 15

16 16 16

17 17 17

18 18 18

19 19 19

*/
// 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.499466779878383x):
#include<cmath>

#include<cstdio>

#include<cstring>

#include<cstdlib>

#include<algorithm>

using namespace std;

const double eps = 1e-10;

const int N=25;



struct point {

    double x,y,z;

}pt[N];

int n,m;

double dis[N][N];



double dist(point p1,point p2) {

    return (p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y)+(p1.z-p2.z)*(p1.z-p2.z);

}



double ret;

int ans[N];

void dfs(int idx,int k,double sum) {

    if(k+(n-idx)+2<m) return;

    if(k==m) {

        ret=max(ret,sum);

        return;

    }



    dfs(idx+1,k,sum);

    double tmp=0;

    for(int i=0;i<k;i++) tmp+=dis[ans[i]][idx];

    ans[k]=idx;

    dfs(idx+1,k+1,sum+tmp);

}



int main()

{

    int i,j,t,cas=0;

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

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

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

        }

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

            for(j=1;j<=n;j++) {

                dis[i][j]=dist(pt[i],pt[j]);

            }

        }



        ret=0.0;

        dfs(1,0,0);



        printf("%.10f\n",ret);

    }

    return 0;

}



/*

20 10

0 0 0

1 1 1

2 2 2

3 3 3

4 4 4

5 5 5

6 6 6

7 7 7

8 8 8

9 9 9

10 10 10

11 11 11

12 12 12

13 13 13

14 14 14

15 15 15

16 16 16

17 17 17

18 18 18

19 19 19

*/
// 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.793837816370396x):
#include<cmath>

#include<cstdio>

#include<cstring>

#include<cstdlib>

#include<algorithm>

using namespace std;

const double eps = 1e-10;

const int N=25;



struct point {

    double x,y,z;

}pt[N];

int n,m;

double dis[N][N];



double dist(point p1,point p2) {

    return (p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y)+(p1.z-p2.z)*(p1.z-p2.z);

}



double ret;

int ans[N];

void dfs(int idx,int k,double sum) {

    if(k+(n-idx)+2<m) return;

    if(k==m) {

        ret=max(ret,sum);

        return;

    }



    dfs(idx+1,k,sum);

    double tmp=0;

    for(int i=0;i<k;i++) tmp+=dis[ans[i]][idx];

    ans[k]=idx;

    dfs(idx+1,k+1,sum+tmp);

}



int main()

{

    int i,j,t,cas=0;

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

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

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

        }

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

            for(j=1;j<=n;j++) {

                dis[i][j]=dist(pt[i],pt[j]);

            }

        }



        ret=0.0;

        dfs(1,0,0);



        printf("%.10f\n",ret);

    }

    return 0;

}



/*

20 10

0 0 0

1 1 1

2 2 2

3 3 3

4 4 4

5 5 5

6 6 6

7 7 7

8 8 8

9 9 9

10 10 10

11 11 11

12 12 12

13 13 13

14 14 14

15 15 15

16 16 16

17 17 17

18 18 18

19 19 19

*/
// 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.771849801285584x):
#include<cmath>

#include<cstdio>

#include<cstring>

#include<cstdlib>

#include<algorithm>

using namespace std;

const double eps = 1e-10;

const int N=25;



struct point {

    double x,y,z;

}pt[N];

int n,m;

double dis[N][N];



double dist(point p1,point p2) {

    return (p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y)+(p1.z-p2.z)*(p1.z-p2.z);

}



double ret;

int ans[N];

void dfs(int idx,int k,double sum) {

    if(k+(n-idx)+2<m) return;

    if(k==m) {

        ret=max(ret,sum);

        return;

    }



    dfs(idx+1,k,sum);

    double tmp=0;

    for(int i=0;i<k;i++) tmp+=dis[ans[i]][idx];

    ans[k]=idx;

    dfs(idx+1,k+1,sum+tmp);

}



int main()

{

    int i,j,t,cas=0;

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

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

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

        }

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

            for(j=1;j<=n;j++) {

                dis[i][j]=dist(pt[i],pt[j]);

            }

        }



        ret=0.0;

        dfs(1,0,0);



        printf("%.10f\n",ret);

    }

    return 0;

}



/*

20 10

0 0 0

1 1 1

2 2 2

3 3 3

4 4 4

5 5 5

6 6 6

7 7 7

8 8 8

9 9 9

10 10 10

11 11 11

12 12 12

13 13 13

14 14 14

15 15 15

16 16 16

17 17 17

18 18 18

19 19 19

*/
// Slower C++ solution:
#include <stdio.h>

#include <string.h>

#include <cstdio>

#include <iostream>

#include <string>

#include <algorithm>

using namespace std;

#define Max 110

#define LL long long



double l[Max], a[Max], b[Max];

double dis[Max][Max], num[Max];

LL temp[Max];



//void init ()

//{

//	LL ans = 0, x;

//	for (LL i = 0;i <= 30;i ++)

//	{

//		x = i;

//		ans = 0;

//		while(x)

//		{

//			if(x % 2 == 1) 

//				ans ++;

//			x /= 2;

//		}

//		num[i] = ans;

//	}

//}





LL judge (LL x)

{

	LL ans = 0;



	while(x)

	{

		if(x % 2 == 1) 

			ans ++;

		x /= 2;

	}

	return ans;

}





double cal(LL x)

{

	double ans = 0.0;

	LL cnt = 0;

	for(LL i = 1; x; i++)

	{

		if(x % 2 == 1)

		{

			temp[++ cnt] = i;

			for(LL j = 1;j < cnt; j++)

			{

				ans += dis[i][temp[j]];

			}

		}

		x /= 2;

	}

	return ans;

}



double MAX(double a, double b)

{return a > b ? a : b;}



int main()

{

	//init ();

	LL n, m, i, j, k;

	while (scanf("%lld%lld", &n, &m) == 2)

	{

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

		{

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

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

			{

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

			}

		}



		if (m <= 1 || n == 0)

		{

			printf ("0.00000000000000000000\n");

			continue;

		}

		double ans = 0.0;

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

		{

			//if (num[i] == m)

			if (judge (i) == m)

			{

				double temp = cal (i);

				ans = MAX (ans, temp);

			}

		}

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

	}

}

// Faster C++ solution for the same problem (measured speedup: 4.785220901789381x):
#include<cmath>

#include<cstdio>

#include<cstring>

#include<cstdlib>

#include<algorithm>

using namespace std;

const double eps = 1e-10;

const int N=25;



struct point {

    double x,y,z;

}pt[N];

int n,m;

double dis[N][N];



double dist(point p1,point p2) {

    return (p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y)+(p1.z-p2.z)*(p1.z-p2.z);

}



double ret;

int ans[N];

void dfs(int idx,int k,double sum) {

    if(k+(n-idx)+2<m) return;

    if(k==m) {

        ret=max(ret,sum);

        return;

    }



    dfs(idx+1,k,sum);

    double tmp=0;

    for(int i=0;i<k;i++) tmp+=dis[ans[i]][idx];

    ans[k]=idx;

    dfs(idx+1,k+1,sum+tmp);

}



int main()

{

    int i,j,t,cas=0;

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

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

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

        }

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

            for(j=1;j<=n;j++) {

                dis[i][j]=dist(pt[i],pt[j]);

            }

        }



        ret=0.0;

        dfs(1,0,0);



        printf("%.10f\n",ret);

    }

    return 0;

}



/*

20 10

0 0 0

1 1 1

2 2 2

3 3 3

4 4 4

5 5 5

6 6 6

7 7 7

8 8 8

9 9 9

10 10 10

11 11 11

12 12 12

13 13 13

14 14 14

15 15 15

16 16 16

17 17 17

18 18 18

19 19 19

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

#include <algorithm>

#include <cstdlib>

#include <cstring>

#include <string>

#include <vector>

#include <cstdio>

#include <queue>

#include <cmath>

#include <string.h>

#include <assert.h>

#include <stack>

#define PI 3.1415926535897932384626433832795028



using namespace std;

struct point 

{

	double x,y,z;

}a[30];

int n,m,num[1000];

double map[100][100];

double f()

{

	double k=0;

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

	{

		if(num[i]==0)

		{

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

			{

				if(num[j]==0&&i!=j)

				{

					k+=map[i][j];

				}

			}

		}

	}

	return k;

}

int main()

{

	int i,j,nx,ny,k;

	double max1,max2,sum,ans,temp;

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

	{

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

		{

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

		}

		if(m==1)

		{

			printf("0.00000000000000000000\n");

			continue;

		}

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

		{

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

			{

				if(i!=j)

				{

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

				}

			}

		}

		ans=0;

		for(int j=(1<<m)-1;j<1<<n;j++)

		{							    

			memset(num,1,sizeof(num));

			int count=0;

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

			{

				if(j&(1<<i))  num[i]=0,count++;

			}

			if(count==m)

			{

				temp=f();

				if(temp>ans) 

					ans=temp;

			}

		}

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

	}

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 4.814296309436233x):
#include<cmath>

#include<cstdio>

#include<cstring>

#include<cstdlib>

#include<algorithm>

using namespace std;

const double eps = 1e-10;

const int N=25;



struct point {

    double x,y,z;

}pt[N];

int n,m;

double dis[N][N];



double dist(point p1,point p2) {

    return (p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y)+(p1.z-p2.z)*(p1.z-p2.z);

}



double ret;

int ans[N];

void dfs(int idx,int k,double sum) {

    if(k+(n-idx)+2<m) return;

    if(k==m) {

        ret=max(ret,sum);

        return;

    }



    dfs(idx+1,k,sum);

    double tmp=0;

    for(int i=0;i<k;i++) tmp+=dis[ans[i]][idx];

    ans[k]=idx;

    dfs(idx+1,k+1,sum+tmp);

}



int main()

{

    int i,j,t,cas=0;

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

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

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

        }

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

            for(j=1;j<=n;j++) {

                dis[i][j]=dist(pt[i],pt[j]);

            }

        }



        ret=0.0;

        dfs(1,0,0);



        printf("%.10f\n",ret);

    }

    return 0;

}



/*

20 10

0 0 0

1 1 1

2 2 2

3 3 3

4 4 4

5 5 5

6 6 6

7 7 7

8 8 8

9 9 9

10 10 10

11 11 11

12 12 12

13 13 13

14 14 14

15 15 15

16 16 16

17 17 17

18 18 18

19 19 19

*/