Problem:
Calender Colors
Taro  is a member of a programming contest circle.
In this circle, the members manage their schedules in the system called
Great Web Calender
.
Taro has just added some of his friends to his calendar so that he can browse their schedule on his calendar.
Then he noticed that the system currently displays all the schedules in only one color, mixing the schedules for all his friends.
This is  difficult to manage because  it's hard to tell whose schedule each entry is.
But actually this calender system has the  feature to change  the color of schedule entries, based on the person who has the entries.
So Taro wants to  use that feature to distinguish their plans by color.
Given the colors Taro can use and the number of members,
your task is to calculate the subset of colors to color all  schedule entries.
The colors are given by "Lab color space".
In Lab color space,
the   distance between two colors is defined by the square sum of the difference of each element.
Taro has to pick up the  subset of colors  that maximizes the sum of distances of all color pairs in the set.
Input
The input is like the following style.
N
M
L_{0}
a_{0}
b_{0}
L_{1}
a_{1}
b_{1}
...
L_{N-1}
a_{N-1}
b_{N-1}
The first line contains two integers
N
and
M
(
0 \leq M \leq N \leq 20
), where
N
is the number of colors in the input, and
M
is the number of friends Taro wants to select the colors for.
Each of the following
N
lines contains three decimal integers
L
(
0.0 \leq L \leq 100.0
),
a
(
-134.0 \leq a \leq 220.0
) and
b
(
-140.0 \leq b \leq 122.0
) which represents a single color in Lab color space.
Output
Output the maximal of the total distance.
The output should not contain an error greater than
10^{-5}
.
Sample Input 1
3 2
0 0 0
10 10 10
100 100 100
Output for the Sample Input 1
30000.00000000000000000000
Sample Input 2
5 3
12.0 15.0 9.0
10.0 -3.0 2.2
3.5 6.8 9.0
2.1 4.4 5.9
1.2 4.0 -5.4
Output for the Sample Input 2
1003.44000000000005456968
Sample Input 3
2 1
1.0 1.0 1.0
0.0 0.0 0.0
Output for the Sample Input 3
0.00000000000000000000

Submitted solutions:

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using a2 = array<int, 2>;
using a3 = array<ll, 3>;

bool chmin(auto& a, const auto& b) { return a > b ? a = b, 1 : 0; }
bool chmax(auto& a, const auto& b) { return a < b ? a = b, 1 : 0; }

ll mod = 998244353;
const ll INF = 1e18;

ifstream in;
ofstream out;

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    if(argc > 2) {
        in.open(argv[1]);
        cin.rdbuf(in.rdbuf());
        out.open(argv[2]);
        cout.rdbuf(out.rdbuf());
    }

    ll n, m;
    cin >> n >> m;

    using ld = long double;
    using d3 = array<ld, 3>;

    vector<d3> v(n);
    for(auto& x : v) cin >> x[0] >> x[1] >> x[2];

    ld ans = 0;
    for(unsigned i = 0; i < (1 << n); i++) {
        if(popcount(i) == m) {
            ld sum = 0;
            for(int j = 0; j < n; j++) {
                for(int k = j + 1; k < n; k++) {
                    if(((1 << j) & i) && ((1 << k) & i)) {
                        for(int l = 0; l < 3; l++)
                            sum += pow(v[j][l] - v[k][l], 2);
                    }
                }
            }
            chmax(ans, sum);
        }
    }

    cout << fixed << setprecision(15) << ans << endl;

    return 0;
}
accuracy: 1
time_ms: 50
memory_kb: 3840
final_rank: 12

code_snippet: #include<bits/stdc++.h>
// #include<atcoder/all>
// #include<boost/multiprecision/cpp_int.hpp>

using namespace std;
// using namespace atcoder;
// using bint = boost::multiprecision::cpp_int;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<ll>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using ve = vector<vector<int>>;
using vb = vector<bool>;
using vvb = vector<vb>;
#define rep(i,s,n) for(ll i = (ll)s;i < (ll)n;i++)
#define rrep(i,l,r) for(ll i = r-1;i >= l;i--)
#define ALL(x) (x).begin(),(x).end()
#define sz(c) ((ll)(c).size())
#define LB(A,x) (int)(lower_bound(A.begin(),A.end(),x)-A.begin())
#define UB(A,x) (int)(upper_bound(A.begin(),A.end(),x)-A.begin())
// #define MOD 1000000007
#define MOD 998244353
template<typename T>using min_priority_queue=priority_queue<T,vector<T>,greater<T>>;
template<typename T>ostream&operator<<(ostream&os,vector<T>&v){for(int i = 0;i < v.size();i++)os<<v[i]<<(i+1!=v.size()?" ":"");return os;}
template<typename T>istream&operator>>(istream&is,vector<T>&v){for(T&in:v)is>>in;return is;}
template<typename T1,typename T2>ostream&operator<<(ostream&os,pair<T1,T2>&p){os<<p.first<<" "<<p.second;return os;}
template<typename T1,typename T2>istream&operator>>(istream&is,pair<T1,T2>&p){is>>p.first>>p.second;return is;}
template<typename T> inline bool chmax(T &a,T b){if(a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a,T b){if(a > b){a = b;return true;}return false;}
ld dist(ld x1,ld y1,ld x2, ld y2){return sqrtl((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));}


int main(){
  
  ios_base::sync_with_stdio(0), cin.tie(0);
  int n,m;cin >> n >> m;
  using vd = vector<ld>;
  vector<vd> v(n,vd(3));
  cin >> v;
  ld res = 0;
  rep(bit,0,1 << n){
    if(__builtin_popcount(bit) != m)continue;
    ld C = 0;
    vi cand;
    rep(i,0,n)if(bit >> i & 1)cand.emplace_back(i);
    rep(i,0,sz(cand))rep(j,0,i)rep(k,0,3)C += (v[cand[i]][k]-v[cand[j]][k])*(v[cand[i]][k]-v[cand[j]][k]);
    chmax(res,C);
  }
  cout << fixed << setprecision(20);
  cout << res << endl;
  

  return 0;
}
accuracy: 1
time_ms: 50
memory_kb: 3620
final_rank: 11

code_snippet: #include<bits/stdc++.h>
template <class T>
inline bool rd(T &ret) {
    char c; int sgn;
    if(c=getchar(),c==EOF) return 0;
    while(c!='-'&&(c<'0'||c>'9')) c=getchar();
    sgn=(c=='-')?-1:1;
    ret=(c=='-')?0:(c-'0');
    while(c=getchar(),c>='0'&&c<='9') ret=ret*10+(c-'0');
    ret*=sgn;
    return 1;
}
template <class T>
inline void pt(T x) {
    if (x <0) {
        putchar('-');
        x = -x;
    }
    if(x>9) pt(x/10);
    putchar(x%10+'0');
}
using namespace std;
const int N = 21;
struct node{
    double x, y, z;
}a[N];
double d[N][N];
double dis(node u, node v){
    u.x -= v.x;
    u.y -= v.y;
    u.z -= v.z;
    return u.x*u.x+u.y*u.y+u.z*u.z;
}
int n, m;
double ans;
int st[N], top;
void work(){
    ans = 0;
    for(int i = 1; i < (1<<n); i++)
    {
        top = 0;
        for(int j = 0; j < n; j++){
            if(i & (1<<j))
                st[top++] = j;
        }
        if(top!=m)continue;

        double tmp = 0;
        for(int j = 0; j < top; j++)
            for(int k = j +1; k < top; k++)
            tmp += d[st[j]][st[k]];
  //      cout<<i;for(int j = 0; j < top; j++)printf(" %d", st[j]);cout<<" :"<<tmp;puts("");
        ans = max(ans, tmp);
    }
}
void input(){
    for(int i = 0; i < n; i++)scanf("%lf %lf %lf", &a[i].x, &a[i].y, &a[i].z);
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            d[i][j] = dis(a[i], a[j]);
   //         printf("%f ",d[i][j]);
        }
 //       puts("");
    }
}
int main(){
    while(~scanf("%d %d", &n, &m)){
        input();
        work();
        printf("%.10f\n", ans);
    }
    return 0;
}
accuracy: 1
time_ms: 40
memory_kb: 3608
final_rank: 8

code_snippet: #include <iostream>
#include <iomanip>
#include <cassert>
#include <vector>
#include <algorithm>
#include <utility>
#include <numeric>
#include <tuple>
#include <ranges>
namespace ranges = std::ranges;
namespace views = std::views;
// #include "Src/Number/IntegerDivision.hpp"
// #include "Src/Utility/BinarySearch.hpp"
// #include "Src/Sequence/CompressedSequence.hpp"
// #include "Src/Sequence/RunLengthEncoding.hpp"
// #include "Src/Algebra/Group/AdditiveGroup.hpp"
// #include "Src/DataStructure/FenwickTree/FenwickTree.hpp"
// #include "Src/DataStructure/SegmentTree/SegmentTree.hpp"
// using namespace zawa;
// #include "atcoder/modint"
// using mint = atcoder::modint998244353;
int N, M;
long double L[20], A[20], B[20];
int main() {
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cin >> N >> M;
    for (int i = 0 ; i < N ; i++) std::cin >> L[i] >> A[i] >> B[i];
    std::vector<int> a(N);
    for (int i = 0 ; i < M ; i++) a[N - i - 1] = 1;
    long double ans = 0;
    do {
        std::vector<int> use;
        use.reserve(M);
        for (int i = 0 ; i < N ; i++) if (a[i]) use.push_back(i);
        assert(std::ssize(use) == M);
        long double v = 0;
        for (int i = 0 ; i < M ; i++) for (int j = i + 1 ; j < M ; j++) {
            v += (L[use[i]] - L[use[j]]) * (L[use[i]] - L[use[j]]);
            v += (A[use[i]] - A[use[j]]) * (A[use[i]] - A[use[j]]);
            v += (B[use[i]] - B[use[j]]) * (B[use[i]] - B[use[j]]);
        }
        ans = std::max(ans, v);
    } while (std::next_permutation(a.begin(), a.end()));
    std::cout << std::fixed << std::setprecision(8) << ans << '\n';
}
accuracy: 1
time_ms: 20
memory_kb: 3840
final_rank: 3

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(a) a.begin(),a.end()
#define reps(i, a, n) for (int i = (a); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)
#define rreps(i, a, n) for (int i = (a); i > (int)(n); i--)
const long long mod = 1000000007;
const long long INF = 1e18;
ll myceil(ll a, ll b) {return (a+b-1)/b;}


void solve() {

    cout << setprecision(10) << fixed;

    int n,m;
    cin >> n >> m;
    vector<vector<double>> v(n,vector<double> (3));
    rep(i,n) {
        cin >> v[i][0] >> v[i][1] >> v[i][2];
    }

    double ans = 0;
    double temp;

    for (unsigned int msk = 0; msk < 1<<n; msk++) {
        if (popcount(msk) != m) continue;
        temp = 0;
        rep(i,n) {
            while (i<n && ((msk & 1<<i) == 0)) {
                i++;
            }
            if (i == n) break;
            reps(j,i+1,n) {
                while (j<n && ((msk & 1<<j) == 0)) {
                    j++;
                }
                if (j == n) break;

                rep(k,3) {
                    temp += (v[i][k]-v[j][k])*(v[i][k]-v[j][k]);
                }
            }
        }
        ans = max(ans,temp);
    }

    cout << ans << endl;
    return;
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    int t = 1;
    //cin >> t;
    rep(i,t) {
        solve();
    }
}
accuracy: 1
time_ms: 40
memory_kb: 3840
final_rank: 10

code_snippet: #include <bits/stdc++.h>


using namespace std;
//make -f ../makefile SRC=
/*
*/


//-------------a-----------------------------------------------------------------
bool DEBUG = false;
const int INF = 1000000000;

const int MAX_N = 20;
static double a[MAX_N];
static double b[MAX_N];
static double c[MAX_N];

static double D[MAX_N][MAX_N];

//------------------------------------------------------------------------------
void setup(int N)
{
    for (int i=0; i<N; ++i) D[i][i] = 0;
    for (int i=0; i<N-1; ++i)
        for (int j=i+1; j<N; ++j)
            {
                D[i][j] = (a[i]-a[j])*(a[i]-a[j]) + (b[i]-b[j])*(b[i]-b[j]) + (c[i]-c[j])*(c[i]-c[j]);
                D[j][i] = D[i][j];
            }
}

double cost(int N, int mask)
{
    vector<int> indices;
    for (int i=0; i<N; i++)
        if (mask & (1<<i))
            indices.push_back( i );
    if (DEBUG) {printf("indices: "); for (int x: indices) printf("%d ",x); printf("\n");}

    double res = 0;
    for (int i: indices)
        for (int j: indices)
            if (j > i)
                res += D[i][j];
    return res;
}
double solve(int N, int K)
{
    if (DEBUG) {for (int i=0; i<N; ++i) printf("%0.2lf %0.2lf %0.2lf\n", a[i], b[i], c[i]);}
    //--------------------------------------------------------------------------
    // base cases:
    //--------------------------------------------------------------------------
    // init:
    setup(N);
    //--------------------------------------------------------------------------
    // compute:
    double res = 0;
    for (int mask=0; mask<(1<<N); ++mask)
        if (__builtin_popcount(mask) == K)
            res = max(res, cost(N,mask));
    //--------------------------------------------------------------------------
    // report:
    //printf("%d\n", res);
    return res;
}

//------------------------------------------------------------------------------
void test()
{

}

//------------------------------------------------------------------------------
int main()
{
    //test(); return 0;
    //DEBUG = true;
    //--------------------------------------------------------------------------
    int N, K, num;
    num = scanf("%d %d ", &N, &K);
    for (int i=0; i<N; ++i) num = scanf("%lf %lf %lf ", &a[i], &b[i], &c[i]);
    double res = solve(N, K);
    printf("%0.6lf\n", res);
    //--------------------------------------------------------------------------
    return 0;
}
//------------------------------------------------------------------------------
accuracy: 1
time_ms: 30
memory_kb: 3576
final_rank: 4

code_snippet: #include <bits/stdc++.h>

using namespace std;

#define rep(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rrep(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define ALL(v) (v).begin(), (v).end()
#define UNIQUE(v) sort(ALL(v)), (v).erase(unique(ALL(v)), (v).end())
#define SZ(v) (int)v.size()
#define MIN(v) *min_element(ALL(v))
#define MAX(v) *max_element(ALL(v))
#define LB(v, x) int(lower_bound(ALL(v), (x)) - (v).begin())
#define UB(v, x) int(upper_bound(ALL(v), (x)) - (v).begin())

using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long;
using i128 = __int128_t;
using u128 = __uint128_t;
const int inf = 0x3fffffff;
const ll INF = 0x1fffffffffffffff;

template <typename T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T, typename U> T ceil(T x, U y) {
    assert(y != 0);
    if (y < 0)
        x = -x, y = -y;
    return (x > 0 ? (x + y - 1) / y : x / y);
}
template <typename T, typename U> T floor(T x, U y) {
    assert(y != 0);
    if (y < 0)
        x = -x, y = -y;
    return (x > 0 ? x / y : (x - y + 1) / y);
}
template <typename T> int popcnt(T x) {
    return __builtin_popcountll(x);
}
template <typename T> int topbit(T x) {
    return (x == 0 ? -1 : 63 - __builtin_clzll(x));
}
template <typename T> int lowbit(T x) {
    return (x == 0 ? -1 : __builtin_ctzll(x));
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "P(" << p.first << ", " << p.second << ")";
    return os;
}
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &map_var) {
    os << "{";
    for (auto itr = map_var.begin(); itr != map_var.end(); itr++) {
        os << "(" << itr->first << ", " << itr->second << ")";
        itr++;
        if (itr != map_var.end())
            os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
template <typename T> ostream &operator<<(ostream &os, const set<T> &set_var) {
    os << "{";
    for (auto itr = set_var.begin(); itr != set_var.end(); itr++) {
        os << *itr;
        ++itr;
        if (itr != set_var.end())
            os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
#ifdef LOCAL
#define show(...) _show(0, #__VA_ARGS__, __VA_ARGS__)
#else
#define show(...) true
#endif
template <typename T> void _show(int i, T name) {
    cerr << '\n';
}
template <typename T1, typename T2, typename... T3>
void _show(int i, const T1 &a, const T2 &b, const T3 &...c) {
    for (; a[i] != ',' && a[i] != '\0'; i++)
        cerr << a[i];
    cerr << ":" << b << " ";
    _show(i + 1, a, c...);
}

#include <unistd.h>

namespace fastio {
static constexpr uint32_t SZ = 1 << 17;
char ibuf[SZ];
char obuf[SZ];
char out[100];
// pointer of ibuf, obuf


uint32_t pil = 0, pir = 0, por = 0;

struct Pre {
    char num[10000][4];
    constexpr Pre() : num() {
        for (int i = 0; i < 10000; i++) {
            int n = i;
            for (int j = 3; j >= 0; j--) {
                num[i][j] = n % 10 | '0';
                n /= 10;
            }
        }
    }
} constexpr pre;

inline void load() {
    memmove(ibuf, ibuf + pil, pir - pil);
    pir = pir - pil + fread(ibuf + pir - pil, 1, SZ - pir + pil, stdin);
    pil = 0;
    if (pir < SZ)
        ibuf[pir++] = '\n';
}

inline void flush() {
    fwrite(obuf, 1, por, stdout);
    por = 0;
}

void rd(char &c) {
    do {
        if (pil + 1 > pir)
            load();
        c = ibuf[pil++];
    } while (isspace(c));
}

void rd(string &x) {
    x.clear();
    char c;
    do {
        if (pil + 1 > pir)
            load();
        c = ibuf[pil++];
    } while (isspace(c));
    do {
        x += c;
        if (pil == pir)
            load();
        c = ibuf[pil++];
    } while (!isspace(c));
}

template <typename T> void rd_real(T &x) {
    string s;
    rd(s);
    x = stod(s);
}

template <typename T> void rd_integer(T &x) {
    if (pil + 100 > pir)
        load();
    char c;
    do
        c = ibuf[pil++];
    while (c < '-');
    bool minus = 0;
    if constexpr (is_signed<T>::value || is_same_v<T, i128>) {
        if (c == '-') {
            minus = 1, c = ibuf[pil++];
        }
    }
    x = 0;
    while ('0' <= c) {
        x = x * 10 + (c & 15), c = ibuf[pil++];
    }
    if constexpr (is_signed<T>::value || is_same_v<T, i128>) {
        if (minus)
            x = -x;
    }
}

void rd(int &x) {
    rd_integer(x);
}
void rd(ll &x) {
    rd_integer(x);
}
void rd(i128 &x) {
    rd_integer(x);
}
void rd(uint &x) {
    rd_integer(x);
}
void rd(ull &x) {
    rd_integer(x);
}
void rd(u128 &x) {
    rd_integer(x);
}
void rd(double &x) {
    rd_real(x);
}
void rd(long double &x) {
    rd_real(x);
}

template <class T, class U> void rd(pair<T, U> &p) {
    return rd(p.first), rd(p.second);
}
template <size_t N = 0, typename T> void rd_tuple(T &t) {
    if constexpr (N < std::tuple_size<T>::value) {
        auto &x = std::get<N>(t);
        rd(x);
        rd_tuple<N + 1>(t);
    }
}
template <class... T> void rd(tuple<T...> &tpl) {
    rd_tuple(tpl);
}

template <size_t N = 0, typename T> void rd(array<T, N> &x) {
    for (auto &d : x)
        rd(d);
}
template <class T> void rd(vector<T> &x) {
    for (auto &d : x)
        rd(d);
}

void read() {}
template <class H, class... T> void read(H &h, T &...t) {
    rd(h), read(t...);
}

void wt(const char c) {
    if (por == SZ)
        flush();
    obuf[por++] = c;
}
void wt(const string s) {
    for (char c : s)
        wt(c);
}
void wt(const char *s) {
    size_t len = strlen(s);
    for (size_t i = 0; i < len; i++)
        wt(s[i]);
}

template <typename T> void wt_integer(T x) {
    if (por > SZ - 100)
        flush();
    if (x < 0) {
        obuf[por++] = '-', x = -x;
    }
    int outi;
    for (outi = 96; x >= 10000; outi -= 4) {
        memcpy(out + outi, pre.num[x % 10000], 4);
        x /= 10000;
    }
    if (x >= 1000) {
        memcpy(obuf + por, pre.num[x], 4);
        por += 4;
    } else if (x >= 100) {
        memcpy(obuf + por, pre.num[x] + 1, 3);
        por += 3;
    } else if (x >= 10) {
        int q = (x * 103) >> 10;
        obuf[por] = q | '0';
        obuf[por + 1] = (x - q * 10) | '0';
        por += 2;
    } else
        obuf[por++] = x | '0';
    memcpy(obuf + por, out + outi + 4, 96 - outi);
    por += 96 - outi;
}

template <typename T> void wt_real(T x) {
    ostringstream oss;
    oss << fixed << setprecision(15) << double(x);
    string s = oss.str();
    wt(s);
}

void wt(int x) {
    wt_integer(x);
}
void wt(ll x) {
    wt_integer(x);
}
void wt(i128 x) {
    wt_integer(x);
}
void wt(uint x) {
    wt_integer(x);
}
void wt(ull x) {
    wt_integer(x);
}
void wt(u128 x) {
    wt_integer(x);
}
void wt(double x) {
    wt_real(x);
}
void wt(long double x) {
    wt_real(x);
}

template <class T, class U> void wt(const pair<T, U> val) {
    wt(val.first);
    wt(' ');
    wt(val.second);
}
template <size_t N = 0, typename T> void wt_tuple(const T t) {
    if constexpr (N < std::tuple_size<T>::value) {
        if constexpr (N > 0) {
            wt(' ');
        }
        const auto x = std::get<N>(t);
        wt(x);
        wt_tuple<N + 1>(t);
    }
}
template <class... T> void wt(tuple<T...> tpl) {
    wt_tuple(tpl);
}
template <class T, size_t S> void wt(const array<T, S> val) {
    auto n = val.size();
    for (size_t i = 0; i < n; i++) {
        if (i)
            wt(' ');
        wt(val[i]);
    }
}
template <class T> void wt(const vector<T> val) {
    auto n = val.size();
    for (size_t i = 0; i < n; i++) {
        if (i)
            wt(' ');
        wt(val[i]);
    }
}

void print() {
    wt('\n');
}
template <class Head, class... Tail> void print(Head &&head, Tail &&...tail) {
    wt(head);
    if (sizeof...(Tail))
        wt(' ');
    print(forward<Tail>(tail)...);
}
void __attribute__((destructor)) _d() {
    flush();
}
} // namespace fastio


using fastio::flush;
using fastio::print;
using fastio::read;

inline void first(bool i = true) {
    print(i ? "first" : "second");
}
inline void Alice(bool i = true) {
    print(i ? "Alice" : "Bob");
}
inline void Takahashi(bool i = true) {
    print(i ? "Takahashi" : "Aoki");
}
inline void yes(bool i = true) {
    print(i ? "yes" : "no");
}
inline void Yes(bool i = true) {
    print(i ? "Yes" : "No");
}
inline void No() {
    print("No");
}
inline void YES(bool i = true) {
    print(i ? "YES" : "NO");
}
inline void NO() {
    print("NO");
}
inline void Yay(bool i = true) {
    print(i ? "Yay!" : ":(");
}
inline void Possible(bool i = true) {
    print(i ? "Possible" : "Impossible");
}
inline void POSSIBLE(bool i = true) {
    print(i ? "POSSIBLE" : "IMPOSSIBLE");
}

/**
 * @brief Fast IO
 */

int main() {
    int N, M;
    cin >> N >> M;
    vector<double> A(N), B(N), C(N);
    vector<vector<double>> D(N,vector<double>(N));
    rep(i,0,N) cin >> A[i] >> B[i] >> C[i];
    rep(i,0,N) rep(j,0,N) D[i][j] = (A[i]-A[j])*(A[i]-A[j])+(B[i]-B[j])*(B[i]-B[j])+(C[i]-C[j])*(C[i]-C[j]);
    vector<int> X(N,0);
    rep(i,N-M,N) X[i] = 1;
    double ANS = 0.0;
    do {
        double COUNT = 0.0;
        rep(i,0,N) {
            rep(j,i+1,N) {
                if (X[i] == 1 && X[j] == 1) COUNT += D[i][j];
            }
        }
        chmax(ANS,COUNT);
    } while(next_permutation(ALL(X)));
    print(ANS);
}
accuracy: 1
time_ms: 60
memory_kb: 3640
final_rank: 13

code_snippet: // (⁠◕⁠ᴗ⁠◕⁠✿⁠)

// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define srep(i, s, n) for (ll i = s; i < (n); i++)
#define len(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
using namespace std;
template<typename T> using vc = vector<T>;
template<typename T> using vv = vc<vc<T>>;
template<typename T> using vvv = vv<vc<T>>;
using vi = vc<int>;using vvi = vv<int>; using vvvi = vv<vi>;
using ll = long long;using vl = vc<ll>;using vvl = vv<ll>; using vvvl = vv<vl>;
using ld = long double; using vld = vc<ld>; using vvld = vc<vld>; using vvvld = vc<vvld>;
using uint = unsigned int;
using ull = unsigned long long;
const ld pi = 3.141592653589793;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
// const ll mod = 1000000007;
const ll mod = 998244353;
inline bool inside(ll y, ll x, ll H, ll W) {return 0 <= (y) and (y) < (H) and 0 <= (x) and (x) < (W); }

#define debug(var)  do{std::cout << #var << " : \n";view(var);}while(0)
template<typename T> void view(T e){cout << e << endl;}
template<typename T> void view(const vc<T>& v){for(const auto& e : v){ cout << e << " "; } cout << endl;}
template<typename T> void view(const vv<T>& vv){ for(const auto& v : vv){ view(v); } }

bool next_combination(int N, vi &P){
    int k = len(P);
    rep(i, k - 1) if (P[i] + 1 < P[i + 1]){
        P[i]++;
        rep(j, i) P[j] = j;
        return true;
    }
    if (P[k - 1] < N - 1){
        P[k - 1]++;
        rep(i, k - 1) P[i] = i;
        return true;
    }
    return false;
}


ld solve(int N, int M){
    vv<ld> ele(N, vld(3)); rep(i, N) rep(j, 3) cin >> ele[i][j];
    auto dist = [&](int i, int j){
        return (ele[i][0] - ele[j][0]) * (ele[i][0] - ele[j][0]) + 
               (ele[i][1] - ele[j][1]) * (ele[i][1] - ele[j][1]) + 
               (ele[i][2] - ele[j][2]) * (ele[i][2] - ele[j][2]);
    };

    if (M == 0) return 0;
    vi P(M); rep(i, M) P[i] = i;
    ld ans = 0;
    do{
        ld cand = 0;
        rep(j, len(P)) rep(i, j) cand += dist(P[i], P[j]);
        ans = max(ans, cand);
    }while (next_combination(N, P));
    return ans;
}

int main(){
    vc<ld> ans;
    while (true){
        int N, M; cin >> N >> M;
        if (N == 0) break;
        ans.push_back(solve(N, M));
        break;
    }
    for (auto x : ans) cout << fixed << setprecision(16) << x << endl;
}
accuracy: 1
time_ms: 20
memory_kb: 3580
final_rank: 2

code_snippet: // (⁠◕⁠ᴗ⁠◕⁠✿⁠)

// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define srep(i, s, n) for (ll i = s; i < (n); i++)
#define len(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
using namespace std;
template<typename T> using vc = vector<T>;
template<typename T> using vv = vc<vc<T>>;
template<typename T> using vvv = vv<vc<T>>;
using vi = vc<int>;using vvi = vv<int>; using vvvi = vv<vi>;
using ll = long long;using vl = vc<ll>;using vvl = vv<ll>; using vvvl = vv<vl>;
using ld = long double; using vld = vc<ld>; using vvld = vc<vld>; using vvvld = vc<vvld>;
using uint = unsigned int;
using ull = unsigned long long;
const ld pi = 3.141592653589793;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
// const ll mod = 1000000007;
const ll mod = 998244353;
inline bool inside(ll y, ll x, ll H, ll W) {return 0 <= (y) and (y) < (H) and 0 <= (x) and (x) < (W); }

#define debug(var)  do{std::cout << #var << " : \n";view(var);}while(0)
template<typename T> void view(T e){cout << e << endl;}
template<typename T> void view(const vc<T>& v){for(const auto& e : v){ cout << e << " "; } cout << endl;}
template<typename T> void view(const vv<T>& vv){ for(const auto& v : vv){ view(v); } }

bool next_combination(int N, vi &P){
    int k = len(P);
    rep(i, k - 1) if (P[i] + 1 < P[i + 1]){
        P[i]++;
        rep(j, i) P[j] = j;
        return true;
    }
    if (P[k - 1] < N - 1){
        P[k - 1]++;
        rep(i, k - 1) P[i] = i;
        return true;
    }
    return false;
}


ld solve(int N, int M){
    vv<ld> ele(N, vld(3)); rep(i, N) rep(j, 3) cin >> ele[i][j];
    auto dist = [&](int i, int j){
        return (ele[i][0] - ele[j][0]) * (ele[i][0] - ele[j][0]) + 
               (ele[i][1] - ele[j][1]) * (ele[i][1] - ele[j][1]) + 
               (ele[i][2] - ele[j][2]) * (ele[i][2] - ele[j][2]);
    };

    vi P(M); rep(i, M) P[i] = i;
    ld ans = 0;
    do{
        ld cand = 0;
        rep(j, len(P)) rep(i, j) cand += dist(P[i], P[j]);
        ans = max(ans, cand);
    }while (next_combination(N, P));
    return ans;
}

int main(){
    vc<ld> ans;
    while (true){
        int N, M; cin >> N >> M;
        if (N == 0) break;
        ans.push_back(solve(N, M));
        break;
    }
    for (auto x : ans) cout << fixed << setprecision(16) << x << endl;
}
accuracy: 0.06593406593406594
time_ms: 20
memory_kb: 3524
final_rank: 20

code_snippet: #include<bits/stdc++.h>
using namespace std;
int n, m;
double l[22], a[22], b[22];
double memo[(1<<21)];
double dfs(int bit, int num){
    if(num == 0) return 0;
    if(memo[bit]!=-1) return memo[bit];
    double res = 0;
    for(int i=0;i<n;i++){
        if((bit&1<<i)!=0) continue;
        double dis = 0;
        for(int j=0;j<n;j++){
            if((bit&1<<j)!=0) dis += pow(l[i]-l[j],2)+pow(a[i]-a[j],2)+pow(b[i]-b[j],2);
        }
        res = max(res, dfs((bit|1<<i), num-1)+dis);
    }
    return memo[bit] = res;
}
int main(){
    cin >> n >> m;
    for(int i=0;i<n;i++){
        cin >> l[i] >> a[i] >> b[i];
    }
    fill(memo, memo+(1<<(n+1)), -1);
    printf("%.9lf\n", dfs(0, m));
    return(0);
}
accuracy: 1
time_ms: 460
memory_kb: 19644
final_rank: 19

code_snippet: #include<bits/stdc++.h>
using namespace std;
int n, m;
double l[22], a[22], b[22];
double memo[(1<<21)];
double dfs(int bit, int num){
    if(num == 0) return 0;
    if(memo[bit]!=-1) return memo[bit];
    double res = 0;
    for(int i=0;i<n;i++){
        if((bit&1<<i)!=0) continue;
        double dis = 0;
        for(int j=0;j<n;j++){
            if((bit&1<<j)!=0) dis += pow(l[i]-l[j],2)+pow(a[i]-a[j],2)+pow(b[i]-b[j],2);
        }
        res = max(res, dfs((bit|1<<i), num-1)+dis);
    }
    return memo[bit] = res;
}
int main(){
    cin >> n >> m;
    for(int i=0;i<n;i++){
        cin >> l[i] >> a[i] >> b[i];
    }
    fill(memo, memo+(1<<21), -1);
    printf("%.9lf\n", dfs(0, m));
    return(0);
}
accuracy: 1
time_ms: 450
memory_kb: 19644
final_rank: 18

code_snippet: #include<bits/stdc++.h>
using namespace std;
using ll=long long;
double a[20][3],ans=0,p;
ll n,m,c[20];
void DFS(ll x,ll d){
    if(d==m){
        p=0;
        for(ll i=0;i<m;i++){
            for(ll j=i+1;j<m;j++){
                p+=pow(a[c[i]][0]-a[c[j]][0],2)+pow(a[c[i]][1]-a[c[j]][1],2)+pow(a[c[i]][2]-a[c[j]][2],2);
            }
        }
        ans=max(ans,p);
    }else if(x==n){
        return;
    }else{
        c[d]=x;
        DFS(x+1,d+1);
        DFS(x+1,d);
    }
}
int main(void){
    cin>>n>>m;
    for(ll i=0;i<n;i++){
        cin>>a[i][0]>>a[i][1]>>a[i][2];
    }
    DFS(0,0);
    printf("%.6f\n",ans);
    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3588
final_rank: 1

code_snippet: #include <bits/stdc++.h>
//#include<atcoder/all>
//using namespace atcoder;
using namespace std;
using ll = long long;
#define all(A) A.begin(),A.end()
using vll = vector<ll>;
using v2ll = vector<vll>;
using v3ll = vector<v2ll>;
using v4ll = vector<v3ll>;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)



int main() {
   ll N,M;
   cin>>N>>M;
   vector<vector<double>> A(N,vector<double>(3));
   rep(i,N)rep(a,3)cin>>A[i][a];
   double an=0.0;
   rep(bit,(1<<N)){
       vector<vector<double>> B;
       rep(n,N){
           if(bit&(1<<n))B.push_back(A[n]);
       }
       if(B.size()!=M)continue;
       double k=0.0;
       rep(i,M)rep(j,i){
           
           rep(a,3){
               k+=(B[i][a]-B[j][a])*(B[i][a]-B[j][a]);
           }
           an=max(an,k);
       }
   }
   cout<<fixed<<setprecision(16)<<an<<endl;
}
accuracy: 1
time_ms: 320
memory_kb: 3576
final_rank: 17

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define inc(i, a, b) for (int i = (a); i <= (b); ++i)
#define dec(i, a, b) for (int i = (a); i >= (b); --i)

int main() {
    ll n, m;
    cin >> n >> m;
    using ld = long double;
    ld a[n], b[n], c[n];

    rep(i, n) cin >> a[i] >> b[i] >> c[i];

    ld res = 0;
    rep(i, 1 << n) {
        if (__builtin_popcount(i) != m) continue;
        ld sum = 0;
        rep(j, n) {
            if (!(i >> j & 1)) continue;
            inc(k, j + 1, n - 1) {
                if (!(i >> k & 1)) continue;

                sum += (a[j] - a[k]) * (a[j] - a[k])
                        + (b[j] - b[k]) * (b[j] - b[k])
                        + (c[j] - c[k]) * (c[j] - c[k]);
            }
        }
        res = max(res, sum);
    }

    cout << fixed << setprecision(10) << res << endl;
}
accuracy: 1
time_ms: 40
memory_kb: 3568
final_rank: 5

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

using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(x) x.begin(), x.end()

const ll INF = 1ll << 60;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, M;
    cin >> N >> M;
    vector<ld> L(N), A(N), B(N);
    rep(i, N) cin >> L[i] >> A[i] >> B[i];
    int N2 = 1 << N;
    ld ans = 0;
    rep(b, N2) {
        if (__builtin_popcount(b) != M) continue;
        ld s = 0;
        vector<int> ind;
        rep(i, N) if (b >> i & 1) ind.push_back(i);
        rep(i, M) {
            rep(j, i) {
                s += (L[ind[i]] - L[ind[j]]) * (L[ind[i]] - L[ind[j]]);
                s += (A[ind[i]] - A[ind[j]]) * (A[ind[i]] - A[ind[j]]);
                s += (B[ind[i]] - B[ind[j]]) * (B[ind[i]] - B[ind[j]]);
            }
        }
        ans = max(ans, s);
    }
    printf("%.15Lf\n", ans);
    return 0;
}
accuracy: 1
time_ms: 40
memory_kb: 3608
final_rank: 8

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

int main() {
    int N,M;
    cin >> N >> M;
    vector<double>a(N),b(N),c(N);
    for(int i = 0; i < N; i++) {
        cin >> a[i] >> b[i] >> c[i];
    }
    double ans = 0;
    for(int i = 0; i < (1 << N); i++) {
        if(__builtin_popcount(i) == M) {
            vector<double>idx;
            for(int j = 0; j < N;j ++) {
                if(1 & (i >> j)) {
                    idx.push_back(j);
                }
            }
            double sum = 0;
            for(int j = 0; j < M; j++) {
                for(int k = j+1; k < M; k++) {
                    sum += pow(abs(a[idx[j]]-a[idx[k]]),2);
                    sum += pow(abs(b[idx[j]]-b[idx[k]]),2);
                    sum += pow(abs(c[idx[j]]-c[idx[k]]),2);
                }
            }
            ans = max(ans,sum);
        }
    }
    cout << fixed << setprecision(18) << ans << endl;
}
accuracy: 1
time_ms: 40
memory_kb: 3580
final_rank: 7

code_snippet: #include <bits/stdc++.h>
using namespace std;
int main(void){
    int n, m;
    cin >> n >> m;
    double ans = 0;
    vector<double> L(n), A(n), B(n);
    for(int i = 0; i < n; i++) cin >> L[i] >> A[i] >> B[i];
    for(int bit = 0; bit < (1 << n); bit++){
        vector<int> lst;
        for(int j = 0; j < n; j++){
            if(bit >> j & 1) lst.push_back(j);
        }
        if(lst.size() != m) continue;
        double tot = 0;
        for(int i = 0; i < m; i++){
            for(int j = i + 1; j < m; j++){
                tot += (L[lst[i]] - L[lst[j]]) * (L[lst[i]] - L[lst[j]]);
                tot += (A[lst[i]] - A[lst[j]]) * (A[lst[i]] - A[lst[j]]);
                tot += (B[lst[i]] - B[lst[j]]) * (B[lst[i]] - B[lst[j]]);
            }
        }
        if(tot > ans) ans = tot;
    }
    
    cout << fixed << setprecision(12) << ans;

}
accuracy: 1
time_ms: 260
memory_kb: 3292
final_rank: 16

code_snippet: #pragma GCC ta g("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define DEBUG
#ifdef DEBUG
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << '(' << p.first << ',' << p.second << ')';
    return os;
}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << '{';
    for(int i = 0; i < (int)v.size(); i++) {
        if(i) { os << ','; }
        os << v[i];
    }
    os << '}';
    return os;
}
void debugg() { cerr << endl; }
template <class T, class... Args>
void debugg(const T &x, const Args &... args) {
    cerr << " " << x;
    debugg(args...);
}
#define debug(...)                                                             \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]: ", debugg(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    int sz = a.size();
    for(auto itr = a.begin(); itr != a.end(); itr++){
		cout << *itr;
        sz--;
        if(sz) cout << " ";
	}
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){
	cout << a << " " << b << "\n";
}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
void mark() {cout << "#" << "\n";}
ll pcount(ll x) {return __builtin_popcountll(x);}
//#include <atcoder/maxflow>
//using namespace atcoder;
const int inf = (1<<30)-1;
const ll linf = 1LL<<61;
const int MAX = 510000;
int dy[8] = {0,1,0,-1,1,-1,-1,1};
int dx[8] = {-1,0,1,0,1,-1,1,-1};
const double pi = acos(-1);
const double eps = 1e-9;
//const int mod = 1e9 + 7;
const int mod = 998244353;

int main(){
	int n,m; cin >> n >> m;
	vd a(n),b(n),c(n);
	rep(i,n) cin >> a[i] >> b[i] >> c[i];
	double ans = 0;
	rep(bit,1<<n){
		if(pcount(bit) != m) continue;
		double res = 0;
		rep(i,n) rep(j,i){
			if((bit>>i & 1) && (bit>>j & 1)){
				res += (a[i]-a[j])*(a[i]-a[j]) + (b[i]-b[j])*(b[i]-b[j]) + (c[i]-c[j])*(c[i]-c[j]);
			}
		}
		chmax(ans, res);
	}
	printf("%.10f\n",ans);
}
accuracy: 1
time_ms: 70
memory_kb: 3572
final_rank: 15

code_snippet: #include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define drep(i,j,n) for(int i=0;i<(int)(n-1);i++)for(int j=i+1;j<(int)(n);j++)
#define trep(i,j,k,n) for(int i=0;i<(int)(n-2);i++)for(int j=i+1;j<(int)(n-1);j++)for(int k=j+1;k<(int)(n);k++)
#define codefor int test;scanf("%d",&test);while(test--)
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define yes(ans) if(ans)printf("yes\n");else printf("no\n")
#define Yes(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YES(ans) if(ans)printf("YES\n");else printf("NO\n")
#define popcount(v) __builtin_popcount(v)
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define vector3d(type,name,h,w,...) vector<vector<vector<type>>>name(h,vector<vector<type>>(w,vector<type>(__VA_ARGS__)))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
const int MOD2=998244353;
const int INF=1<<30;
const ll INF2=(ll)1<<60;
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T,class L>void scan(pair<T, L>& p){scan(p.first);scan(p.second);}
template<class T,class U,class V>void scan(tuple<T,U,V>& p){scan(get<0>(p));scan(get<1>(p));scan(get<2>(p));}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T,class L>void print(const pair<T, L>& p){print(p.first);putchar(' ');print(p.second);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }
ll modinv(ll a, ll m) {ll b = m, u = 1, v = 0;while (b) {ll t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}
ll updivide(ll a,ll b){if(a%b==0) return a/b;else return (a/b)+1;}
template<class T> void chmax(T &a,const T b){if(b>a)a=b;}
template<class T> void chmin(T &a,const T b){if(b<a)a=b;}

int main(){
    INT(n,m);
    vector2d(double,a,n,3);
    in(a);
    vector<bool> b(m,1);
    while(b.size()<n)b.push_back(0);
    sort(all(b));
    double ans=0;
    do{
        double d=0;
        drep(i,j,n){
            if(b[i]&&b[j]){
                double d2=0;
                rep(k,3){
                    d2+=(a[i][k]-a[j][k])*(a[i][k]-a[j][k]);
                }
                d+=d2;
            }
        }
        chmax(ans,d);
    }while(next_permutation(all(b)));
    out(ans);
}
accuracy: 1
time_ms: 70
memory_kb: 3552
final_rank: 14

code_snippet: #include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int N,M; cin >> N >> M;
    vector<double> L(N), a(N), b(N);
    rep(i,N) cin >> L[i] >> a[i] >> b[i];

    double ans = 0;
    rep(i,1<<N) {
        double cur = 0;
        if(__builtin_popcount(i) == M) {
            vector<int> v;
            rep(j,N) if(i & (1 << j)) v.push_back(j);
            for(int j : v) for(int k : v) if(j < k)
                cur += (L[k] - L[j]) * (L[k] - L[j]) + (a[k] - a[j]) * (a[k] - a[j]) + (b[k] - b[j]) * (b[k] - b[j]);
        }
        ans = max(ans, cur);
    }
    cout.precision(17);
    cout << ans << endl;
}
accuracy: 1
time_ms: 40
memory_kb: 3568
final_rank: 5