from math import isclose


def speedup(before: list[float], after: list[float]) -> float:
    if sum(after) <= 0:
        raise ValueError("Total latency must be positive")
    return sum(before) / sum(after)


cot = [15.9, 338.8, 29.5]
lotus = [16.7, 133.0, 31.5]
assert isclose(sum(cot), 384.2)
assert isclose(sum(lotus), 181.2)
assert 2.12 < speedup(cot, lotus) < 2.13
print(f"thought: {cot[1] / lotus[1]:.3f}x")
print(f"total: {speedup(cot, lotus):.3f}x")
