Abstract
The rise of reasoning models necessitates large-scale verifiable data, for which programming tasks serve as an ideal source. However, while competitive programming platforms provide abundant problems and solutions, high-quality test cases for verification remain scarce. Existing approaches attempt to synthesize test cases using Large Language Models (LLMs), but rely solely on the model's intrinsic generation capabilities without external feedback, frequently resulting in insufficiently diverse cases. To address this limitation, we propose a Feedback-Driven Iterative Framework for comprehensive test case construction. Specifically, our method leverages the LLM to generate initial test cases, executes them against known correct and incorrect solutions, and utilizes the failed results as feedback to guide the LLM in refining the test cases toward high fidelity and discriminability. We then apply this method to the CodeContests dataset to construct an optimized high-quality derivative, CodeContests-O. Evaluating against the entire pool of solutions ($1.1 \times 10^7$ in total), our dataset achieves an average True Positive Rate (TPR) of $89.37\%$ and True Negative Rate (TNR) of $90.89\%$, significantly outperforming the CodeContests and CodeContests+ by margins of $4.32\%$ and $9.37\%$, respectively. Furthermore, fine-tuning the Qwen2.5-7B model on CodeContests-O results in a $9.52\%$ improvement on LiveCodeBench (Pass@1). Experiments demonstrate the effectiveness of our framework and the quality of CodeContests-O.
1. Introduction
The current advancement in AI reasoning, exemplified by models like OpenAI’s o1 and DeepSeek-R1, relies heavily on large-scale, verifiable data. Programming tasks are ideal for this purpose because code is objectively verifiable through execution. However, a significant bottleneck exists: the quality of available test cases. Competitive programming platforms often provide sparse test suites. Weak test suites allow "hallucinated" solutions—code that appears correct but fails on edge cases—to pass, providing false reward signals during training. While LLMs have been used to generate additional tests, these "open-loop" methods often fail to capture complex edge cases because they lack external verification during the generation process.
2. Methodology: Feedback-Driven Iterative Framework
To overcome the limitations of open-loop generation, we propose a "closed-loop" system that treats test case generation as an evolutionary process. The framework consists of four primary stages:
- Initial Generation: An LLM analyzes the problem description to produce a generator program (typically in C++ using
testlib.h) and execution commands for input generation. - Execution & Feedback Collection: Generated test cases are executed against a massive pool of over 11 million existing correct ($S^+$) and incorrect ($S^-$) solutions. The system identifies False Positives (buggy code passing) and False Negatives (correct code failing).
- Feedback-Guided Refinement: The LLM performs root-cause analysis on these failures. Using a "search-and-replace" strategy, it surgically updates the generator logic to target specific missed edge cases.
- Synchronized Checker Generation: For problems where multiple outputs are valid, the system generates logic-based checkers rather than relying on simple string matching, ensuring high fidelity.
3. Experimental Results and Dataset Quality
We applied this framework to the CodeContests dataset to create CodeContests-O, which includes 11,682 refined problems. Our evaluation focuses on the trade-off between the True Positive Rate (TPR), representing fidelity, and the True Negative Rate (TNR), representing rigor or discriminability.
As shown in Figure 1, our iterative process consistently pushes the Pareto frontier toward the top-right corner. CodeContests-O (iter 3) achieves a TPR of 89.37% and a TNR of 90.89%. This represents a significant improvement over the original CodeContests (TPR 85.18%, TNR 81.52%) and the augmented CodeContests+ (5x) (TPR 83.84%, TNR 89.35%). Notably, our method achieves a 9.37% margin in discriminability over CodeContests+.
The impact of this high-quality data is further demonstrated through downstream fine-tuning. Training a Qwen2.5-7B model using CodeContests-O as a reward signal led to a 9.52% improvement on the LiveCodeBench (Pass@1) leaderboard. The resulting model (34.57% accuracy) even surpassed the larger Qwen2.5-7B-Instruct model (29.33%), highlighting the importance of data quality over mere quantity.
4. Conclusion
CodeContests-O demonstrates that discriminability—the ability to reject incorrect solutions—is a critical metric for model training. By closing the loop with feedback-driven refinement, we can significantly enhance the rigor of existing programming datasets. While the iterative process is computationally intensive, the resulting gains in model reasoning capabilities are substantial. Future work will explore applying this feedback-driven recipe to other verifiable domains such as mathematical proof checking and formal hardware verification.
Summary updated