A Little Help Goes a Long Way: Tutoring LLMs in Solving Competitive Programming Through Hints
- 26 September 2025
- journal article
- Published by Institute of Electrical and Electronics Engineers (IEEE) in IEEE Transactions on Software Engineering
- Vol. 51 (12) , 3416-3434
Abstract
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 TEACH1, 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.Keywords
This publication has 38 references indexed in Scilit:
- An Empirical Study on Fine-Tuning Large Language Models of Code for Automated Program Repair2023
- Automated Program Repair in the Era of Large Pre-trained Language Models2023
- SkCoder: A Sketch-based Approach for Automatic Code Generation2023
- Retrieval-Based Prompt Selection for Code-Related Few-Shot Learning2023
- An Extensive Study of the Structure Features in Transformer-based Code Semantic Summarization2023
- MerIt: improving neural program synthesis by merging collective intelligenceAutomated Software Engineering, 2022
- Asleep at the Keyboard? Assessing the Security of GitHub Copilot’s Code Contributions2022
- Guide to Competitive Programming2020
- Re-Factoring Based Program Repair Applied to Programming Assignments2019
- Automatic patch generation learned from human-written patches2013