#include <bits/stdc++.h>
using namespace std;

const int INF = 1e+9;

int N, M;
double L[32], A[32], B[32];
bool check[32];

double dfs(int n, int m){
	if(m >= M){
		double cal = 0;
		for(int i = 0; i < N; ++i){
			for(int j = i + 1; j < N; ++j){
				if(check[i] && check[j])
					cal += pow(fabs(L[j] - L[i]), 2.0) + pow(fabs(A[j] - A[i]), 2.0) + pow(fabs(B[j] - B[i]), 2.0);
			}
		}
		return cal;
	}
	if(n >= N)
		return -INF;
		
	double res = 0;
	res = max(res, dfs(n + 1, m));
	check[n] = true;
	res = max(res, dfs(n + 1, m + 1));
	check[n] = false;
	
	return res;
}

int main() {
	cin >> N >> M;
	for(int i = 0; i < N; ++i)
		cin >> L[i] >> A[i] >> B[i];
	
	printf("%f\n", dfs(0, 0));
	return 0;
}