// 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.7662722184867246x):
#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;

}