A Little Help Goes a Long Way: Tutoring LLMs in Solving Competitive Programming Through Hints
Code generation has advanced with large language models (LLMs), but LLMs still struggle with complex tasks, especially in competitive programming. These tasks require understanding complex problems, generating correct code that passes numerous test cases, and meeting tight time and memory limits. We observed that there are some critical hints provided by competition platforms, which often point to the most critical information needed to solve the problem, thus guiding participants to accurate solutions. Inspired by these observations, we propose TEACH<sup xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink">1</sup>, an approach that tutors LLMs in solving competitive programming by combining critical hints with a structured Chain of Thought (CoT). The key insight of TEACH is to employ a domain-specialized hint generator that is fine-tuned on curated data from competitive programming platforms, enabling it to produce concise and targeted algorithmic hints. By integrating these hints into the reasoning process of LLMs, TEACH helps LLMs bridge the gap between complex tasks and solutions. Furthermore, TEACH simulates human problem-solving through a structured CoT that covers problem understanding, analysis, algorithm selection, and coding. We extensively evaluate TEACH on both proprietary (GPT-3.5, GPT-4o, Claude-3.5-Sonnet, Gemini-2.5-Flash) and open-source (DeepSeek-V3) LLMs. TEACH achieves up to 6.56 absolute (17.4% relative) gain in pass@1 on LeetCode, and demonstrates strong generalization to APPS and ASAC, with maximum pass@1 relative improvements of 17.6% and 26.9%, respectively. Furthermore, existing CoT methods with the hints generated from TEACH yield additional gains, demonstrating its compatibility and extensibility across models and prompting strategies.
Authors
- Deze Wang
- Jiaxin Liu (ORCID: https://orcid.org/0000-0003-2449-1150)
- Shangwen Wang (ORCID: https://orcid.org/0000-0003-1469-2063)
- Wei Dong (ORCID: https://orcid.org/0000-0002-8033-7943)
- Kang Yang (ORCID: https://orcid.org/0000-0003-2313-7141)
- Yating Zhang (ORCID: https://orcid.org/0000-0001-6071-5997)
- Yiwei Li (ORCID: https://orcid.org/0009-0009-3329-810X)
- Tiecheng Ma (ORCID: https://orcid.org/0009-0004-7508-0348)
Institutions
- National University of Defense Technology (CN)
Publication Details
- Journal
- IEEE Transactions on Software Engineering
- Published
- 2025-09-26
- DOI
- https://doi.org/10.1109/tse.2025.3614204
- Primary Topic
- Open Education and E-Learning
- Type
- article
- Field-Weighted Citation Impact
- 0.00