## 1) Abridged problem statement

You are given the six edge lengths of a tetrahedron \(ABCD\) (in order: \(AB, AC, AD, BC, BD, CD\)), each a positive integer \(\le 1000\). Compute and print the tetrahedron’s volume with exactly 4 digits after the decimal point.

---

## 2) Detailed editorial (how the solution works)

### Key idea
A tetrahedron is a 3D simplex. If you know all pairwise distances between its 4 vertices (i.e., its 6 edges), you can compute its volume directly using the **Cayley–Menger determinant**, which generalizes Heron’s formula to higher dimensions.

This avoids:
- reconstructing coordinates,
- computing a base triangle area + height,
- solving systems / vector geometry.

### Cayley–Menger determinant for a tetrahedron
Let the vertices be \(A,B,C,D\). Define the squared distances:
- \(d_{AB}^2, d_{AC}^2, d_{AD}^2, d_{BC}^2, d_{BD}^2, d_{CD}^2\)

Build the \(5 \times 5\) matrix:
\[
M =
\begin{pmatrix}
0 & 1 & 1 & 1 & 1 \\
1 & 0 & d_{AB}^2 & d_{AC}^2 & d_{AD}^2 \\
1 & d_{AB}^2 & 0 & d_{BC}^2 & d_{BD}^2 \\
1 & d_{AC}^2 & d_{BC}^2 & 0 & d_{CD}^2 \\
1 & d_{AD}^2 & d_{BD}^2 & d_{CD}^2 & 0
\end{pmatrix}
\]

Then:
\[
V^2 = \frac{\det(M)}{288}
\quad\Longrightarrow\quad
V = \sqrt{\frac{\det(M)}{288}}
\]

The constant \(288\) comes from the general simplex formula:
\[
V_n^2 = \frac{(-1)^{n+1}}{2^n (n!)^2}\det(M)
\]
For a tetrahedron, \(n=3\):
\[
2^3 (3!)^2 = 8 \cdot 36 = 288
\]
and the sign works out so that valid tetrahedra produce a non-negative value (small negative due to floating errors can happen).

### Computing the determinant
The solution computes \(\det(M)\) via **Gaussian elimination with partial pivoting**:
- For each column \(i\), choose a pivot row with the largest absolute value in that column.
- Swap rows if needed (flips sign of determinant).
- Multiply determinant by the pivot value.
- Eliminate entries below the pivot.

This is \(O(5^3)\), trivial in time.

### Numerical notes
- Uses `double`.
- If the determinant is slightly negative due to rounding, `abs` is taken before `sqrt`.
- Output formatted to 4 digits after the decimal.

---

## 3) Provided C++ solution with detailed line-by-line comments

```cpp
#include <bits/stdc++.h>              // Includes almost all standard C++ headers
using namespace std;

// Overload operator<< to print pairs (not used in this problem, but present)
template<typename T1, typename T2>
ostream& operator<<(ostream& out, const pair<T1, T2>& x) {
    return out << x.first << ' ' << x.second;
}

// Overload operator>> to read pairs (not used here)
template<typename T1, typename T2>
istream& operator>>(istream& in, pair<T1, T2>& x) {
    return in >> x.first >> x.second;
}

// Overload operator>> to read vectors element-wise (not used here)
template<typename T>
istream& operator>>(istream& in, vector<T>& a) {
    for(auto& x: a) {                 // For each element in the vector
        in >> x;                      // read it
    }
    return in;
};

// Overload operator<< to print vectors (not used here)
template<typename T>
ostream& operator<<(ostream& out, const vector<T>& a) {
    for(auto x: a) {
        out << x << ' ';
    }
    return out;
};

// Global variables for the 6 edge lengths
double AB, AC, AD, BC, BD, CD;

// Reads the six edge lengths from input in the specified order
void read() { cin >> AB >> AC >> AD >> BC >> BD >> CD; }

// Computes determinant of a square matrix using Gaussian elimination
double gaussian_det(vector<vector<double>> mat) {
    int n = mat.size();               // matrix dimension
    double det = 1.0;                 // determinant accumulator

    // Perform elimination for each column i
    for(int i = 0; i < n; ++i) {
        int pivot = i;                // start with diagonal row as pivot

        // Find row with maximum absolute value in column i (partial pivoting)
        for(int j = i + 1; j < n; ++j) {
            if(abs(mat[j][i]) > abs(mat[pivot][i])) {
                pivot = j;            // better pivot found
            }
        }

        // If pivot row differs, swap rows (determinant changes sign)
        if(pivot != i) {
            swap(mat[i], mat[pivot]);
            det = -det;               // swapping rows multiplies determinant by -1
        }

        // If pivot is too close to 0, determinant is 0 (singular matrix)
        if(abs(mat[i][i]) < 1e-10) {
            return 0.0;
        }

        // Multiply determinant by pivot (since we will eliminate below it)
        det *= mat[i][i];

        // Eliminate entries below pivot in column i
        for(int j = i + 1; j < n; ++j) {
            double factor = mat[j][i] / mat[i][i];  // elimination factor
            for(int k = i; k < n; ++k) {            // update row j from column i onward
                mat[j][k] -= factor * mat[i][k];
            }
        }
    }
    return det;                        // resulting product is determinant
}

void solve() {
    // Use Cayley–Menger determinant to compute tetrahedron volume from edge lengths.

    // Precompute squared edge lengths
    double a2 = AB * AB, b2 = AC * AC, c2 = AD * AD;
    double d2 = BC * BC, e2 = BD * BD, f2 = CD * CD;

    // Build the 5x5 Cayley–Menger matrix
    vector<vector<double>> m(5, vector<double>(5));
    m[0] = {0, 1, 1, 1, 1};
    m[1] = {1, 0, a2, b2, c2};
    m[2] = {1, a2, 0, d2, e2};
    m[3] = {1, b2, d2, 0, f2};
    m[4] = {1, c2, e2, f2, 0};

    // Compute determinant of the Cayley–Menger matrix
    double determinant = gaussian_det(m);

    // For a tetrahedron: V = sqrt(det(M) / 288).
    // abs() guards against small negative due to floating-point error.
    double volume = sqrt(abs(determinant) / 288.0);

    // Print with exactly 4 digits after decimal point
    cout << fixed << setprecision(4) << volume << endl;
}

int main() {
    ios_base::sync_with_stdio(false); // faster I/O
    cin.tie(nullptr);                 // untie cin from cout for speed

    int T = 1;                        // single test case
    // cin >> T;                       // left commented out

    for(int test = 1; test <= T; test++) {
        read();                       // read input
        solve();                      // compute and output answer
    }

    return 0;
}
```

---

## 4) Python solution (same approach) with detailed comments

```python
import sys
import math

def determinant_gauss(a):
    """
    Compute determinant of a square matrix a (list of lists) using
    Gaussian elimination with partial pivoting.
    Works in O(n^3), which is tiny here (n=5).
    """
    n = len(a)
    # Make a deep copy so we don't mutate the original matrix
    mat = [row[:] for row in a]

    det = 1.0

    for i in range(n):
        # Choose pivot row with maximum absolute value in column i
        pivot = i
        for r in range(i + 1, n):
            if abs(mat[r][i]) > abs(mat[pivot][i]):
                pivot = r

        # If pivot is (near) zero, determinant is zero
        if abs(mat[pivot][i]) < 1e-12:
            return 0.0

        # Swap pivot row into place; each swap flips determinant sign
        if pivot != i:
            mat[i], mat[pivot] = mat[pivot], mat[i]
            det = -det

        pivot_val = mat[i][i]
        det *= pivot_val

        # Eliminate below pivot
        for r in range(i + 1, n):
            factor = mat[r][i] / pivot_val
            # Start from column i to avoid unnecessary work
            for c in range(i, n):
                mat[r][c] -= factor * mat[i][c]

    return det


def main():
    # Read six edge lengths
    data = sys.stdin.read().strip().split()
    AB, AC, AD, BC, BD, CD = map(float, data)

    # Squared lengths
    a2 = AB * AB
    b2 = AC * AC
    c2 = AD * AD
    d2 = BC * BC
    e2 = BD * BD
    f2 = CD * CD

    # Cayley–Menger 5x5 matrix for tetrahedron volume
    M = [
        [0.0, 1.0, 1.0, 1.0, 1.0],
        [1.0, 0.0, a2,  b2,  c2 ],
        [1.0, a2,  0.0, d2,  e2 ],
        [1.0, b2,  d2,  0.0, f2 ],
        [1.0, c2,  e2,  f2,  0.0],
    ]

    det = determinant_gauss(M)

    # V^2 = det/288, take abs to protect from tiny negative due to rounding
    volume = math.sqrt(abs(det) / 288.0)

    # Print with 4 digits after decimal
    print(f"{volume:.4f}")


if __name__ == "__main__":
    main()
```

---

## 5) Compressed editorial

Use the Cayley–Menger determinant to compute tetrahedron volume from its six edge lengths. Form the \(5\times5\) matrix with 0 on the diagonal, squared edge lengths in the distance positions, and a top row/left column of ones (except the top-left 0). Compute \(\det(M)\) via Gaussian elimination. Then:
\[
V=\sqrt{\frac{\det(M)}{288}}
\]
Print \(V\) to 4 decimals (use `abs(det)` to avoid negative zero due to floating errors).