#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>

using namespace std;

struct Lab {
	double L, a, b;
};

double sqsum(Lab a, Lab b) {
	return (a.L - b.L) * (a.L - b.L) +
		(a.a - b.a) * (a.a - b.a) + (a.b - b.b) * (a.b - b.b);
}

int main() {
	int n, m; cin >> n >> m;
	vector<Lab> Labs(n);
	for (auto& a : Labs) cin >> a.L >> a.a >> a.b;
	double ans = 0;
	for (int bit = 0; bit < (1 << n); ++bit) {
		if (__builtin_popcount(bit) != m) continue;
		vector<Lab> tLab;
		for (int flag = 0; flag < n; ++flag)
			if (bit & (1 << flag)) tLab.push_back(Labs[flag]);
		double tmp = 0;
		for (int i = 0; i < m; ++i)
			for (int j = i + 1; j < m; ++j)
				tmp += sqsum(tLab[i], tLab[j]);
		ans = max(ans, tmp);
	}
	printf("%.20f\n", ans);

	return 0;
}
