Language: C++

#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

const double EPS = 1.0e-10;

double determinant(vector<vector<double> >& mat)
{   
    const int n = mat.size();
    double ret = 1.0;
    for(int i=0; i<n; ++i){
        int tmp = i;
        for(int j=i+1; j<n; ++j){
            if(abs(mat[j][i]) > abs(mat[tmp][i]))
                tmp = j;
        }
        if(abs(mat[tmp][i]) < EPS)
            return 0.0;
        if(tmp != i){
            mat[i].swap(mat[tmp]);
            ret *= -1.0;
        }

        for(int j=i+1; j<n; ++j){
            for(int k=n-1; k>=i; --k){
                mat[j][k] -= mat[i][k] * (mat[j][i] / mat[i][i]);
            }
        }
        ret *= mat[i][i];
    }
    return ret;
}

double tetrahedronVolume(const vector<double>& len)
{
    const int a[][3] = {{0,1,3}, {1,2,4}, {0,2,5}, {3,4,5}};
    for(int i=0; i<4; ++i){
        vector<double> b(3);
        for(int j=0; j<3; ++j)
            b[j] = len[a[i][j]];
        sort(b.begin(), b.end());
        if(b[2] > b[0] + b[1] - EPS)
            return 0.0;
    }

    const int y[] = {0, 3, 1, 3, 2, 3, 0, 1, 0, 2, 1, 2};
    const int x[] = {3, 0, 3, 1, 3, 2, 1, 0, 2, 0, 2, 1};

    vector<vector<double> > mat(5, vector<double>(5, 1.0));
    for(int i=0; i<12; ++i)
        mat[y[i]][x[i]] = pow(len[i/2], 2.0);
    for(int i=0; i<5; ++i)
        mat[i][i] = 0.0;

    return sqrt(determinant(mat) / 288.0);
}

template <unsigned T>
bool nextBitset(bitset<T> &bs, int digit)
{
    if(bs.none())
        return false;
    bitset<T> x, y, z;
    x = bs.to_ulong() & (~(bs.to_ulong()) + 1ULL);
    y = bs.to_ulong() + x.to_ulong() + 0ULL;
    z = bs & ~y;
    if(bs[digit-1] && bs == z)
        return false;
    bs = ((z.to_ulong() / x.to_ulong()) >> 1) + 0ULL;
    bs |= y;
    return true;
}

int main()
{
    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            return 0;

        vector<double> a(n);
        for(int i=0; i<n; ++i)
            cin >> a[i];

        double ret = 0.0;
        bitset<16> bs((1<<6)-1);
        do{
            vector<double> b;
            for(int i=0; i<n; ++i){
                if(bs[i])
                    b.push_back(a[i]);
            }
            sort(b.begin(), b.end());

            do{
                ret = max(ret, tetrahedronVolume(b));
            }while(next_permutation(b.begin(), b.end()));
        }while(nextBitset(bs, n));

        printf("%.10f\n", ret);
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:114:26: error: no matching function for call to 'nextBitset(std::bitset<16>&, int&)'
  114 |         }while(nextBitset(bs, n));
      |                ~~~~~~~~~~^~~~~~~
a.cc:74:6: note: candidate: 'template<unsigned int T> bool nextBitset(std::bitset<T>&, int)'
   74 | bool nextBitset(bitset<T> &bs, int digit)
      |      ^~~~~~~~~~
a.cc:74:6: note:   template argument deduction/substitution failed:
a.cc:114:26: note:   mismatched types 'unsigned int' and 'long unsigned int'
  114 |         }while(nextBitset(bs, n));
      |                ~~~~~~~~~~^~~~~~~