//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

double l[25], a[25], b[25];
signed main(void)
{
	int n, m;
	cin >> n >> m;
	REP(i, n) cin >> l[i] >> a[i] >> b[i];

	double ans = -1;
	REP(i, 1<<n) {
		int cnt = 0;
		VI c;
		REP(j, n) {
			if(i>>j&1) {
				cnt++;
				c.PB(j);
			}
		}
		if(cnt != m) continue;
		double ret = 0;
		REP(j, m) FOR(k, j+1, m) {
			ret += (l[c[j]]-l[c[k]])*(l[c[j]]-l[c[k]]) + (a[c[j]]-a[c[k]])*(a[c[j]]-a[c[k]]) + (b[c[j]]-b[c[k]])*(b[c[j]]-b[c[k]]);
		}
		if(ret > ans) ans = ret;
	}
	cout << fixed << setprecision(9) << ans << endl;

	return 0;
}