#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
using namespace std;
struct LCS{
  double l,a,b;
  LCS(double l,double a,double b):l(l),a(a),b(b){};
};
int n,m;
double ans = 0;
vector<LCS> vec;
vector<int> used;
double cal(LCS a,LCS b){
  return pow(a.l - b.l,2) + pow(a.a - b.a,2) + pow(a.b - b.b,2);
}
double solve(){
  double res = 0;
  for(int i = 0;i < n;i++){
	if(used[i]){
	  for(int j = i+1;j < n;j++){
		if(used[j]){
		  res+= cal(vec[i],vec[j]);
		}
	  }
	}
  }
  return res;
}
void dfs(int cnt,int num){
/*  cout << "cnt = " << cnt << "   num = " << num << endl;
  cout << "used flag " ;
  for(int i = 0;i < n;i++){
	if(used[i])cout << i << " " ;
	
  }
  cout << endl;
*/


  
  if(cnt == m){
	ans = max(ans,solve());
	return;
  }
  if(num >= n)return;
  if(!used[num]){
	used[num] = 1;
	dfs(cnt+1,num+1);
	used[num] = 0;
  }
  dfs(cnt,num+1);
  
}

int main(){
  
  cin >> n >> m;
  used = vector<int>(n,0);
  for(int i = 0;i < n;i++){
	double l,a,b;
	cin >> l >> a >> b;
	vec.emplace_back(l,a,b);	
  }
  dfs(0,0);
  cout << fixed << setprecision(5) << ans << endl;
  
  return 0;
}