--- Final Solver (used for performance test) ---
import numpy as np


class Solver:
    def solve(self, problem, **kwargs):
        y_list = problem["y"]
        n = len(y_list)
        if n < 256:
            return self._solve_python(y_list, n)
        return self._solve_numpy(y_list)

    @staticmethod
    def _solve_python(y_list, n):
        sorted_y = sorted(y_list, reverse=True)
        cumsum = 0.0
        rho = 0
        rho_cumsum = 0.0
        for i in range(n):
            v = sorted_y[i]
            cumsum += v
            if v * (i + 1) > cumsum - 1.0:
                rho = i
                rho_cumsum = cumsum
            else:
                break
        theta = (rho_cumsum - 1.0) / (rho + 1)
        x = [v - theta if v > theta else 0.0 for v in y_list]
        return {"solution": x}

    @staticmethod
    def _solve_numpy(y_list):
        y = np.asarray(y_list, dtype=np.float64)
        n = y.size
        sorted_y = np.sort(y)[::-1]
        cumsum = np.cumsum(sorted_y) - 1.0
        arange = np.arange(1, n + 1)
        mask = sorted_y * arange > cumsum
        rho = n - 1 - np.nonzero(mask[::-1])[0][0]
        theta = cumsum[rho] / (rho + 1)
        x = np.maximum(y - theta, 0.0)
        return {"solution": x}
--- End Solver ---
Running performance test...
============================= test session starts ==============================
platform linux -- Python 3.12.13, pytest-9.0.2, pluggy-1.6.0
rootdir: /tests
plugins: anyio-4.13.0, jaxtyping-0.3.9
collected 3 items

../tests/test_outputs.py .
--- Performance Summary ---
Validity: True
Total Baseline Time: 6.0115s
Total Solver Time:   5.8490s
Raw Speedup:         1.0278 x
Final Reward (Score): 1.0278
---------------------------
..

==================================== PASSES ====================================
=========================== short test summary info ============================
PASSED ../tests/test_outputs.py::test_solver_exists
PASSED ../tests/test_outputs.py::test_solver_validity
PASSED ../tests/test_outputs.py::test_solver_speedup
======================== 3 passed in 281.05s (0:04:41) =========================
