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

#include<cstdio>

#include<cmath>

#include<cstring>

#include<cstdlib>

#include<algorithm>

#define ll long long

using namespace std;



const int mod=1000000007;

const int N=100005;



int n,k,l,r,ans;

ll x,y;

int dp1[N],dp2[N],f[2][N],p1[N],p2[N];

ll a[N];



void add(bool b,int x,int y){

	for (;x<=n+2;x+=x&-x){

		f[b][x]+=y;

		(f[b][x]>=mod)?f[b][x]-=mod:0;

	}

}



int query(bool b,int x){

	int s=0;

	for (;x;x-=x&-x){

		s+=f[b][x];

		(s>=mod)?s-=mod:0;

	}

	return s;

}



int ask(bool b,int x,int y){

	int s;

	if (x>y) return 0;

	s=(query(b,y)-query(b,x-1)+mod)%mod;

	return s;

}



int main(){

	scanf("%d%lld%lld",&n,&x,&y);

	if (x>y) swap(x,y);

	for (int i=1;i<=n;i++) scanf("%lld",&a[i]);

	l=r=n;

	for (int i=n;i>=1;i--){

		if (a[i+1]-a[i]<x) l=i;

		if (a[i+1]-a[i]<y) r=i;

		p1[i]=l;

		p2[i]=r;

	}

	for (int i=n;i>1;i--){

		if (p2[i]==n) dp1[i]=1;

		if (p1[i]==n) dp2[i]=1;

		

		l=lower_bound(a+1,a+1+n,a[i-1]+x)-a; l=max(l,i+1);

		r=p2[i]+1;

		dp1[i]+=ask(1,l,r);

		(dp1[i]>=mod)?dp1[i]-=mod:0;

		

		l=lower_bound(a+1,a+1+n,a[i-1]+y)-a; l=max(l,i+1);

		r=p1[i]+1;

		dp2[i]+=ask(0,l,r);

		(dp2[i]>=mod)?dp2[i]-=mod:0;

		

		add(0,i,dp1[i]);

		add(1,i,dp2[i]);

		if (p1[1]>=i-1) ans+=dp1[i];

		(ans>=mod)?ans-=mod:0;

		if (p2[1]>=i-1) ans+=dp2[i];

		(ans>=mod)?ans-=mod:0;

	}

	if (p1[1]==n) ans++;

	if (p2[1]==n) ans++;

	ans%=mod;

	printf("%d\n",ans);

	return 0;

}

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

#include<algorithm>

using namespace std;

const int MAXN=100005,MOD=1000000007;

const long long LLF=0x3F3F3F3F3F3F3F3FLL;



int N;

long long A,B,S[MAXN];

int f[MAXN],sum[MAXN];



int main()

{

	scanf("%d%lld%lld",&N,&A,&B);

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

		scanf("%lld",&S[i]);

	if(A>B)

		swap(A,B);

	for(int i=3;i<=N;i++)

		if(S[i]-S[i-2]<A)

		{

			puts("0");

			return 0;

		}

	S[N+1]=LLF;

	

	f[0]=sum[0]=1;

	int l=0,r=0;

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

	{

		while(r<i-1&&S[i]-S[r+1]>=B)

			r++;

		if(l<=r)

			(f[i]+=(sum[r]-(l==0?0:sum[l-1])+MOD)%MOD)%=MOD;

		sum[i]=(sum[i-1]+f[i])%MOD;

		if(i!=1&&S[i]-S[i-1]<A)

			l=i-1;

	}

	printf("%d\n",f[N+1]);

	

	return 0;

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

#include<math.h>

#include<ctype.h>

#include<algorithm>

#include<bitset>

#include<cassert>

#include<cctype>

#include<cerrno>

#include<cfloat>

#include<ciso646>

#include<climits>

#include<clocale>

#include<complex>

#include<csetjmp>

#include<csignal>

#include<cstdarg>

#include<cstddef>

#include<cstdio>

#include<cstdlib>

#include<cstring>

#include<ctime>

#include<cwchar>

#include<cwctype>

#include<deque>

#include<exception>

#include<fstream>

#include<functional>

#include<iomanip>

#include<ios>

#include<iosfwd>

#include<iostream>

#include<istream>

#include<iterator>

#include<limits>

#include<list>

#include<locale>

#include<map>

#include<memory>

#include<new>

#include<numeric>

#include<ostream>

#include<queue>

#include<set>

#include<sstream>

#include<stack>

#include<stdexcept>

#include<streambuf>

#include<string>

#include<typeinfo>

#include<utility>

#include<valarray>

#include<vector>

#include<string.h>

#include<stdlib.h>

#include<stdio.h>

using namespace std;

const int Mod=1000000007;

int n,pa[100010],pb[100010],fx[100010],fy[100010];

long long a,b,s[100010],px,py,xi,yi;

int main()

{

	scanf("%d%lld%lld",&n,&a,&b);

	if (a<=b)

	{

		swap(a,b);

	}

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

	{

		scanf("%lld",&s[i]);

	}

	fx[0]=fy[0]=1;

	int sa,sb;

	sa=sb=1;

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

	{

		while (s[sa]+a<=s[i])

		{

			sa++;

		}

		while (s[sb]+b<=s[i])

		{

			sb++;

		}

		pa[i]=sa-1;

		pb[i]=sb-1;

	}

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

	{

		xi=fy[min(i-2,pa[i])];

		yi=fx[min(i-2,pb[i])];

		if (pa[i]<i-1)

		{

			memset(fx+px,0,i-px-1<<2);

			px=i-1;

		}

		if (pb[i]<i-1)

		{

			memset(fy+py,0,i-py-1<<2);

			py=i-1;

		}

		fx[i-1]=(fx[i-1]+fx[i-2]+xi)%Mod;

		fy[i-1]=(fy[i-1]+fy[i-2]+yi)%Mod;

	}

	printf("%d\n",(fx[n-1]+fy[n-1])%Mod);

    return 0;

}

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

#include<algorithm>

using namespace std;

const int MAXN=100005,MOD=1000000007;

const long long LLF=0x3F3F3F3F3F3F3F3FLL;



int N;

long long A,B,S[MAXN];

int f[MAXN],sum[MAXN];



int main()

{

	scanf("%d%lld%lld",&N,&A,&B);

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

		scanf("%lld",&S[i]);

	if(A>B)

		swap(A,B);

	for(int i=3;i<=N;i++)

		if(S[i]-S[i-2]<A)

		{

			puts("0");

			return 0;

		}

	S[N+1]=LLF;

	

	f[0]=sum[0]=1;

	int l=0,r=0;

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

	{

		while(r<i-1&&S[i]-S[r+1]>=B)

			r++;

		if(l<=r)

			(f[i]+=(sum[r]-(l==0?0:sum[l-1])+MOD)%MOD)%=MOD;

		sum[i]=(sum[i-1]+f[i])%MOD;

		if(i!=1&&S[i]-S[i-1]<A)

			l=i-1;

	}

	printf("%d\n",f[N+1]);

	

	return 0;

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

#include<cstdio>

#include<cmath>

#include<cstring>

#include<cstdlib>

#include<algorithm>

#define ll long long

using namespace std;



const int mod=1000000007;

const int N=100005;



int n,k,l,r,ans;

ll x,y;

int dp1[N],dp2[N],f[2][N],p1[N],p2[N];

ll a[N];



void add(bool b,int x,int y){

	for (;x<=n+2;x+=x&-x){

		f[b][x]+=y;

		(f[b][x]>=mod)?f[b][x]-=mod:0;

	}

}



int query(bool b,int x){

	int s=0;

	for (;x;x-=x&-x){

		s+=f[b][x];

		(s>=mod)?s-=mod:0;

	}

	return s;

}



int ask(bool b,int x,int y){

	int s;

	if (x>y) return 0;

	s=(query(b,y)-query(b,x-1)+mod)%mod;

	return s;

}



int main(){

	scanf("%d%lld%lld",&n,&x,&y);

	if (x>y) swap(x,y);

	for (int i=1;i<=n;i++) scanf("%lld",&a[i]);

	l=r=n;

	for (int i=n;i>=1;i--){

		if (a[i+1]-a[i]<x) l=i;

		if (a[i+1]-a[i]<y) r=i;

		p1[i]=l;

		p2[i]=r;

	}

	for (int i=n;i>1;i--){

		if (p2[i]==n) dp1[i]=1;

		if (p1[i]==n) dp2[i]=1;

		

		l=lower_bound(a+1,a+1+n,a[i-1]+x)-a; l=max(l,i+1);

		r=p2[i]+1;

		dp1[i]+=ask(1,l,r);

		(dp1[i]>=mod)?dp1[i]-=mod:0;

		

		l=lower_bound(a+1,a+1+n,a[i-1]+y)-a; l=max(l,i+1);

		r=p1[i]+1;

		dp2[i]+=ask(0,l,r);

		(dp2[i]>=mod)?dp2[i]-=mod:0;

		

		add(0,i,dp1[i]);

		add(1,i,dp2[i]);

		if (p1[1]>=i-1) ans+=dp1[i];

		(ans>=mod)?ans-=mod:0;

		if (p2[1]>=i-1) ans+=dp2[i];

		(ans>=mod)?ans-=mod:0;

	}

	if (p1[1]==n) ans++;

	if (p2[1]==n) ans++;

	ans%=mod;

	printf("%d\n",ans);

	return 0;

}

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

#include<algorithm>

#define maxn 100005

#define LL long long

#define mod 1000000007

#define INF (LL)4e18

using namespace std;

int n,f[maxn],s[maxn];

LL a,b,x[maxn];

int Get(int l,int r)

{

	if(l>r) return 0;

	if(!l) return s[r];

	else return (s[r]-s[l-1]+mod)%mod;

}

int main()

{

	scanf("%d%lld%lld",&n,&a,&b);

	if(a<b) swap(a,b);

	for(int i=1;i<=n;i++) scanf("%lld",&x[i]);

	x[0]=-INF,x[n+1]=INF;

	f[0]=s[0]=1;

	int l=0,r=0;

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

	{

		while(r+1<i&&x[i]-x[r+1]>=a) r++;

		if(i>=2&&x[i-1]-x[i-2]<b) l=i-2;

		if(x[i]-x[i-1]>=a) f[i]=f[i-1];

		f[i]=(f[i]+Get(l,min(i-2,r)))%mod;

		s[i]=s[i-1];

		if(x[i+1]-x[i-1]>=b) s[i]=(s[i]+f[i])%mod;

	}

	printf("%d\n",f[n+1]);

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

#include<math.h>

#include<ctype.h>

#include<algorithm>

#include<bitset>

#include<cassert>

#include<cctype>

#include<cerrno>

#include<cfloat>

#include<ciso646>

#include<climits>

#include<clocale>

#include<complex>

#include<csetjmp>

#include<csignal>

#include<cstdarg>

#include<cstddef>

#include<cstdio>

#include<cstdlib>

#include<cstring>

#include<ctime>

#include<cwchar>

#include<cwctype>

#include<deque>

#include<exception>

#include<fstream>

#include<functional>

#include<iomanip>

#include<ios>

#include<iosfwd>

#include<iostream>

#include<istream>

#include<iterator>

#include<limits>

#include<list>

#include<locale>

#include<map>

#include<memory>

#include<new>

#include<numeric>

#include<ostream>

#include<queue>

#include<set>

#include<sstream>

#include<stack>

#include<stdexcept>

#include<streambuf>

#include<string>

#include<typeinfo>

#include<utility>

#include<valarray>

#include<vector>

#include<string.h>

#include<stdlib.h>

#include<stdio.h>

using namespace std;

const int Mod=1000000007;

int n,pa[100010],pb[100010],fx[100010],fy[100010];

long long a,b,s[100010],px,py,xi,yi;

int main()

{

	scanf("%d%lld%lld",&n,&a,&b);

	if (a<=b)

	{

		swap(a,b);

	}

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

	{

		scanf("%lld",&s[i]);

	}

	fx[0]=fy[0]=1;

	int sa,sb;

	sa=sb=1;

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

	{

		while (s[sa]+a<=s[i])

		{

			sa++;

		}

		while (s[sb]+b<=s[i])

		{

			sb++;

		}

		pa[i]=sa-1;

		pb[i]=sb-1;

	}

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

	{

		xi=fy[min(i-2,pa[i])];

		yi=fx[min(i-2,pb[i])];

		if (pa[i]<i-1)

		{

			memset(fx+px,0,i-px-1<<2);

			px=i-1;

		}

		if (pb[i]<i-1)

		{

			memset(fy+py,0,i-py-1<<2);

			py=i-1;

		}

		fx[i-1]=(fx[i-1]+fx[i-2]+xi)%Mod;

		fy[i-1]=(fy[i-1]+fy[i-2]+yi)%Mod;

	}

	printf("%d\n",(fx[n-1]+fy[n-1])%Mod);

    return 0;

}

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

#include<algorithm>

#define maxn 100005

#define LL long long

#define mod 1000000007

#define INF (LL)4e18

using namespace std;

int n,f[maxn],s[maxn];

LL a,b,x[maxn];

int Get(int l,int r)

{

	if(l>r) return 0;

	if(!l) return s[r];

	else return (s[r]-s[l-1]+mod)%mod;

}

int main()

{

	scanf("%d%lld%lld",&n,&a,&b);

	if(a<b) swap(a,b);

	for(int i=1;i<=n;i++) scanf("%lld",&x[i]);

	x[0]=-INF,x[n+1]=INF;

	f[0]=s[0]=1;

	int l=0,r=0;

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

	{

		while(r+1<i&&x[i]-x[r+1]>=a) r++;

		if(i>=2&&x[i-1]-x[i-2]<b) l=i-2;

		if(x[i]-x[i-1]>=a) f[i]=f[i-1];

		f[i]=(f[i]+Get(l,min(i-2,r)))%mod;

		s[i]=s[i-1];

		if(x[i+1]-x[i-1]>=b) s[i]=(s[i]+f[i])%mod;

	}

	printf("%d\n",f[n+1]);

}
// 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.882837576658147x):
#include <stdio.h>

#define N 22



double num[N][3];

int choose[N];

double ans;

int n, m;



double sqr(double n) {

	return n * n;

}



double max(double a, double b) {

	return a > b ? a : b;

}



void update() {

	double tmp = 0.0;

	for (int i = 0; i < m; i++) {

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

			for (int k = 0; k < 3; k++) {

				tmp += sqr( num[choose[i]][k] - num[choose[j]][k] );

			}

		}

	}

	ans = max(ans, tmp);

}



void DFS(int d, int s) {

	if (m - d > n - s) {

		return;

	} else if (d == m) {

		update();

	} else {

		for (int i = s; i < n; i++) {

			choose[d] = i;

			DFS(d + 1, i + 1);

		}

	}

}



int main () {

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

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

			for (int j = 0; j < 3; j++) {

				scanf ("%lf", &num[i][j]);

			}

		}

		ans = 0.0;

		DFS(0, 0);

		printf ("%.5f\n", ans);

	}

	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.863180236202525x):
#include<cstdio>

#include<cstdlib>

#include<cstring>

#include<algorithm>

using namespace std;



double L[22],a[22],b[22];

double d[22][22];

int now[20];

double dist(double x1,double y1,double z1,double x2,double y2,double z2)

{

    return (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)+(z1-z2)*(z1-z2);

}

int main()

{

    int n,m;

    while (scanf("%d%d",&n,&m)>0)

    {

        for (int i=0;i<n;i++) scanf("%lf%lf%lf",&L[i],&a[i],&b[i]);

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

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

                d[i][j]=dist(L[i],a[i],b[i],L[j],a[j],b[j]);

        double maxi=0;

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

        {

            int cnt=0;

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

                if (i&(1<<j))

                    now[cnt++]=j;

            if (cnt!=m) continue;

            double sum=0;

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

                for (int k=j+1;k<cnt;k++)

                    sum+=d[now[j]][now[k]];

            maxi=max(maxi,sum);

        }

        printf("%.8f\n",maxi);

    }

}
// 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.722873074545446x):
#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:
/*

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.678523164461846x):
#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 <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.68485577821035x):
#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 <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.675425567397877x):
#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;

}