<|instruction|>
Solve the below problem. The solution should start with an abridged problem statement. Then key observations. Then full solution based on the observations. Then C++ and Python implementations with comments.

244. Height, Bisector and Median
time limit per test: 0.25 sec.
memory limit per test: 4096 KB
input: standard
output: standard



There is a triangle ABC. You are given lengths of its height, bisector and median. Your task is to construct this triangle, i.e. to find such points A, B and C, that triangle ABC will have height AH, bisector AD and median AM with lengths equal to given. Of course, if there is one solution, then there is an infinite number of solutions, so you may find any of them.

Input
Three integer numbers will be at the first line of file: |AH|, |AD|, |AM|. All numbers are positive and not exceed 100.

Output
In the first line write "YES", if such triangle could be constructed, and "NO" otherwise. In case of positive answer write coordinates of points A, B and C on the 2-nd, 3-rd and 4-th lines respectively. Coordinates must be real numbers with not more than 8 digits after decimal point and must not exceed 108 by absolute value. Your triangle must have non-zero area and the lengths of its height AH, bisector AD and median AM must not differ from given more than 10-6.

Sample test(s)

Input
Test #1
1 1 1

Test #2
1 1 2

Output
Test #1
YES
0 1
-0.5 0
0.5 0

Test #2
NO
Author:	Vladimir Yakovlev
Resource:	Ural State University training
Date:	September, 2003

<|response|>
## 1) Abridged problem statement (concise)

Given three positive integers:

- \(h = |AH|\): height from \(A\) to line \(BC\)
- \(d = |AD|\): angle bisector from \(A\) to side \(BC\)
- \(m = |AM|\): median from \(A\) to side \(BC\)

Construct any non-degenerate triangle \(ABC\) having exactly these lengths (error \(\le 10^{-6}\)), and output coordinates of \(A,B,C\). If impossible, output `NO`.

---

## 2) Key observations

1. **We can freely translate/rotate** the triangle without changing lengths.  
   So we choose a coordinate system that makes equations simple.

2. Place the height foot at the origin and the base on the x-axis:
   - \(H=(0,0)\)
   - \(BC\) is the line \(y=0\)
   - \(A=(0,h)\)

3. Then points on \(BC\) have form \(B=(x_B,0)\), \(C=(x_C,0)\).  
   Midpoint \(M\) of \(BC\) is:
   \[
   M=\left(\frac{x_B+x_C}{2},0\right)=(x_M,0)
   \]
   Angle bisector endpoint is \(D=(x_D,0)\).

4. Using Pythagoras on \(AM\) and \(AD\):
   \[
   x_M = \sqrt{m^2-h^2},\qquad x_D=\sqrt{d^2-h^2}
   \]
   So we must have **\(m\ge h\)** and **\(d\ge h\)**.

5. A convenient parameterization that guarantees \(M\) is midpoint:
   \[
   B=(x_M-t,0),\quad C=(x_M+t,0),\quad t>0
   \]
   (Then area is non-zero iff \(t>0\).)

6. Apply the **Angle Bisector Theorem**:
   \[
   \frac{AB}{AC}=\frac{BD}{DC}
   \]
   With the above coordinates it yields a closed-form:
   \[
   t^2 = \frac{(x_M-x_D)\,(h^2 + x_M x_D)}{x_D}
   \]
   This requires \(x_D>0\) and \(x_M>x_D\) in the general case.

7. Feasibility summary (matches known correct solutions):
   - If \(h > d\) or \(d > m\): impossible.
   - If equality occurs (\(h=d\) or \(d=m\)), the only non-degenerate solvable case is:
     \[
     h=d=m
     \]
     (then height = median = bisector, e.g. an isosceles triangle).

---

## 3) Full solution approach

### Step A: Check feasibility
- If \(h>d\) or \(d>m\): print `NO`.
- If \(h=d\) or \(d=m\):
  - If \(h=d=m\): print `YES` and output a simple isosceles construction:
    \[
    A=(0,h),\quad B=(-h,0),\quad C=(h,0)
    \]
  - Otherwise print `NO`.

### Step B: Construct for the general case \(h<d<m\)
1. Fix:
   \[
   A=(0,h),\quad BC: y=0
   \]
2. Compute:
   \[
   x_M=\sqrt{m^2-h^2},\quad x_D=\sqrt{d^2-h^2}
   \]
3. Compute:
   \[
   t=\sqrt{\frac{(x_M-x_D)\,(h^2+x_Mx_D)}{x_D}}
   \]
4. Output:
   \[
   B=(x_M-t,0),\quad C=(x_M+t,0)
   \]

This guarantees:
- Height from \(A\) to \(BC\) is exactly \(h\) (vertical distance to \(y=0\)).
- \(M\) is midpoint of \(BC\), and \(|AM|=m\).
- \(D\) lies on \(BC\) at distance \(|AD|=d\) and satisfies the angle bisector theorem by construction.

Complexity: \(O(1)\).

---

## 4) C++ implementation (detailed comments)

```cpp
#include <bits/stdc++.h>
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int h_in, d_in, m_in;
    cin >> h_in >> d_in >> m_in;

    // Basic necessary ordering for this standard construction:
    // h <= d <= m
    if (h_in > d_in || d_in > m_in) {
        cout << "NO\n";
        return 0;
    }

    // Boundary equalities: general formula would degenerate (division by xD or t=0).
    // The only non-degenerate triangle possible there is h = d = m.
    if (h_in == d_in || d_in == m_in) {
        if (h_in == d_in && d_in == m_in) {
            double h = (double)h_in;
            cout << "YES\n";
            cout << fixed << setprecision(8);

            // Isosceles triangle:
            // A=(0,h), base on x-axis symmetric around origin.
            cout << 0.0 << " " << h << "\n";     // A
            cout << -h  << " " << 0.0 << "\n";   // B
            cout <<  h  << " " << 0.0 << "\n";   // C
        } else {
            cout << "NO\n";
        }
        return 0;
    }

    // General case: h < d < m
    double h = (double)h_in, d = (double)d_in, m = (double)m_in;

    // Coordinate normalization:
    // H=(0,0), BC is y=0, A=(0,h)
    // From AM^2 = xM^2 + h^2 => xM = sqrt(m^2 - h^2)
    double xM = sqrt(m*m - h*h);

    // From AD^2 = xD^2 + h^2 => xD = sqrt(d^2 - h^2)
    double xD = sqrt(d*d - h*h);

    // Derived from angle bisector theorem with B=(xM-t,0), C=(xM+t,0):
    // t^2 = (xM-xD) * (h^2 + xM*xD) / xD
    double t2 = (xM - xD) * (h*h + xM*xD) / xD;

    // Guard against tiny negative due to floating-point errors
    if (t2 < 0 && t2 > -1e-12) t2 = 0;

    // If t <= 0, triangle area would be zero or impossible
    if (t2 <= 0) {
        cout << "NO\n";
        return 0;
    }
    double t = sqrt(t2);

    // Construct points
    double Ax = 0.0, Ay = h;
    double Bx = xM - t, By = 0.0;
    double Cx = xM + t, Cy = 0.0;

    cout << "YES\n";
    cout << fixed << setprecision(8);
    cout << Ax << " " << Ay << "\n";
    cout << Bx << " " << By << "\n";
    cout << Cx << " " << Cy << "\n";

    return 0;
}
```

---

## 5) Python implementation (detailed comments)

```python
import math
import sys

def solve():
    h_in, d_in, m_in = map(int, sys.stdin.read().split())

    # Need h <= d <= m for this construction
    if h_in > d_in or d_in > m_in:
        print("NO")
        return

    # Boundary equalities: only solvable non-degenerate case is h=d=m
    if h_in == d_in or d_in == m_in:
        if h_in == d_in == m_in:
            h = float(h_in)
            print("YES")
            # Isosceles triangle: A at (0,h), base symmetric
            print(f"{0.0:.8f} {h:.8f}")     # A
            print(f"{-h:.8f} {0.0:.8f}")    # B
            print(f"{h:.8f} {0.0:.8f}")     # C
        else:
            print("NO")
        return

    # General case: h < d < m
    h = float(h_in)
    d = float(d_in)
    m = float(m_in)

    # Normalize coordinates:
    # H=(0,0), BC is y=0, A=(0,h).
    # M=(xM,0) with xM = sqrt(m^2 - h^2)
    xM = math.sqrt(m*m - h*h)

    # D=(xD,0) with xD = sqrt(d^2 - h^2)
    xD = math.sqrt(d*d - h*h)

    # t^2 = (xM-xD) * (h^2 + xM*xD) / xD
    t2 = (xM - xD) * (h*h + xM*xD) / xD

    # Clamp tiny negative due to floating point
    if -1e-12 < t2 < 0:
        t2 = 0.0

    # Need t > 0 for non-zero area
    if t2 <= 0:
        print("NO")
        return

    t = math.sqrt(t2)

    # Construct points
    Ax, Ay = 0.0, h
    Bx, By = xM - t, 0.0
    Cx, Cy = xM + t, 0.0

    print("YES")
    print(f"{Ax:.8f} {Ay:.8f}")
    print(f"{Bx:.8f} {By:.8f}")
    print(f"{Cx:.8f} {Cy:.8f}")

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

