Analyze the following problem specification, solution code, and test code:

Problem Specification:
{{ problem_spec }}

Source Code:
{{ read_file(source_file) }}

Test Code:
{{ read_file(test_file) }}

The tests are not passing and you need to determine the root cause of the problem.  Think critically about the failing test cases in the context of the problem specification.  Do not assume that the test cases are valid.  Did the test generator correctly understand the code and the problem spec?  Are the expected results correct for each test case?  Are the failing tests catching real issues in the solution code?

{% if test_failures_summary %}
Failed Tests Details:
{{ test_failures_summary }}
{% else %}
Note: No test failures provided. Please analyze the code logic directly against the problem specification and test cases.
{% endif %}

IMPORTANT: Methodically think through the problem step by step:
1. Analyze the code correctness with respect to the spec.  Remember that leetcode-style problems often involve a "trick" or clever observation to produce an efficient solution
2. Analyze the test code with respect to the spec and solution code. Is it correctly covering all relevant corner cases?
3. Examine the test failures.  Do the expected results make sense for the failing cases? What is the underlying cause of each failure?
4. Use what you've learned to determine whether the solution code is wrong, the test code is wrong, or both.

Think critically about the analysis and take your time.  Make sure that you are confident in your verdict before returning a result.

Provide:
1. A clear verdict that matches your final analysis
2. Detailed explanation of your reasoning process
3. Clear, directive instructions for what to fix. Use imperative language that tells the generator exactly what to do. For example: "Fix the off-by-one error in the loop", "Change the base case to handle empty input", "Update the test assertion to expect the correct output format".
