<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta>
      <journal-title-group>
        <journal-title>Workshop, July</journal-title>
      </journal-title-group>
    </journal-meta>
    <article-meta>
      <title-group>
        <article-title>AlgoAce: Retrieval-Augmented Generation for Assistance in Competitive Programming</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Anav Agrawal</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Jill-Jênn Vie</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Soda team, Inria Saclay</institution>
          ,
          <addr-line>91120 Palaiseau</addr-line>
          ,
          <country country="FR">France</country>
        </aff>
      </contrib-group>
      <pub-date>
        <year>2025</year>
      </pub-date>
      <volume>20</volume>
      <issue>2025</issue>
      <fpage>0000</fpage>
      <lpage>0002</lpage>
      <abstract>
        <p>Competitive programming platforms like Codeforces are widely used for self-directed learning and assessment in computer science education. However, students often struggle to identify relevant practice problems or receive targeted help without personalized guidance. In this paper we present AlgoAce, an AI-powered assistant that integrates with Codeforces and uses retrieval-augmented generation (RAG) to provide support while attending at two key sources of information: user submission history, and problem metadata. The system leverages large language models to fetch relevant problems and past user submissions, grounding user queries in retrieved content before generating responses. AlgoAce adapts to user preferences-such as programming language or problem tags-and supports reflective learning through natural language interactions. We describe the tool's architecture and discuss its potential for integration into the competitive programming learning ecosystem.</p>
      </abstract>
      <kwd-group>
        <kwd>eol&gt;Retrieval-augmented generation</kwd>
        <kwd>Competitive programming</kwd>
        <kwd>Intelligent tutoring systems</kwd>
        <kwd>Codeforces</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>1. Introduction</title>
    </sec>
    <sec id="sec-2">
      <title>2. Related Work</title>
      <p>
        LLMs have been widely applied to educational tasks, including student performance prediction,
personalized practice generation, and automated feedback [
        <xref ref-type="bibr" rid="ref2 ref3 ref4 ref5">2, 3, 4, 5</xref>
        ]. RAG, in particular, has shown promise
in improving the quality and relevance of educational outputs by grounding LLM responses in external
knowledge [
        <xref ref-type="bibr" rid="ref6 ref7 ref8 ref9">6, 7, 8, 9</xref>
        ].
      </p>
      <p>
        Recent studies have explored programming exercise recommendation systems [
        <xref ref-type="bibr" rid="ref10 ref11 ref12 ref13">10, 11, 12, 13</xref>
        ] and AI
support in competitive programming environments [
        <xref ref-type="bibr" rid="ref14 ref15">14, 15</xref>
        ], yet few approaches have leveraged user
submission history for fine-grained personalization. While course recommendation using LLMs has
seen substantial progress—such as RAMO [
        <xref ref-type="bibr" rid="ref16">16</xref>
        ], which uses RAG to recommend MOOCs based on course
metadata—there remains a gap in personalized exercise recommendation, particularly in competitive
programming where detailed skill modeling is essential.
      </p>
      <p>AlgoAce addresses this gap by incorporating users’ historical problem attempts and performance
data into its recommendation pipeline. This enables the system to dynamically adapt to a learner’s
evolving skill set, ofering targeted practice.</p>
    </sec>
    <sec id="sec-3">
      <title>3. Our RAG solution AlgoAce</title>
      <p>On the open source platform AlgoAce, users input a query, e.g. “What should I learn next?”. They can
provide their Codeforces handle, which allows the agent to retrieve their submission history—notably
successful and unsuccessful problem attempts—via the Codeforces API. If no handle is provided, generic
recommendations are made based on the query alone. Sample outputs are provided in Appendix A.</p>
      <p>Each Codeforces problem is represented by the following metadata: its title, associated tags (e.g.,
“shortest paths”), Elo rating, and URL, see an example in Table 1 in Appendix C. The diference in Elo
rating between a user and a problem is proportional to the logit of the probability that the user can
solve the problem. AlgoAce embeds this available metadata into a dense vector space to enable semantic
retrieval. The user submission history contains metadata of the attempted problem and the result of the
submission (OK, Wrong Answer, or Time Limit Exceeded), see an example in Table 2 in Appendix C. It
is similar to the data encountered in knowledge tracing scenarios.</p>
      <p>AlgoAce runs two parallel retrievers, one over user’s past submissions and another over the Codeforces
problem set, both using vector similarity search. The retrieved results are merged and then fed into a
structured prompt to guide the LLM’s generation. The system is designed with modularity in mind,
currently supporting both API-based large language models such as OpenAI’s GPT models and locally
hosted open-source alternatives, so that the data never leaves the device. The complete prompt templates
are provided in Appendix B. A diagram of the whole pipeline is also provided in Figure 2 in Appendix D.</p>
      <p>To evaluate the retrieval of submission history, we prioritized ensuring the relevance of retrieved
documents. Our initial observations revealed a critical need for query reformulation: queries that didn’t
explicitly define terms like "OK" or "time limit exceeded" consistently yielded irrelevant submissions.
This led us to implement a two-way prompting strategy, where the first prompt is specifically designed
to reformulate the user’s query, thereby improving the relevance of the retrieved submission history.
Implementation details AlgoAce is implemented using the Pathway framework, which provides
eficient Retrieval-Augmented Generation (RAG) pipelines. For approximate nearest neighbor search,
we use Pathway’s KNNIndex class, which applies locality-sensitive hashing to perform fast similarity
search across embedded problems. The user interface is built using Streamlit, with a Pathway RESTful
API connecting the front-end to the backend services. All code from the platform is released on GitHub.</p>
    </sec>
    <sec id="sec-4">
      <title>4. Conclusion</title>
      <p>As future work, we plan to incorporate problem solutions into the retrieval and recommendation
process, and conduct user studies to evaluate our tool and see the common queries made by users.
By analyzing oficial or community-provided solutions, we can better estimate the prerequisite skills
required for each exercise, leading to more accurate and pedagogically meaningful recommendations.
Additionally, we aim to align the objective of the LLM more closely with learning outcomes, ensuring
that the system prioritizes educational progress rather than optimizing user satisfaction. This could
involve fine-tuning prompts to emphasize skill development and problem-solving strategies.</p>
    </sec>
    <sec id="sec-5">
      <title>Declaration on Generative AI</title>
      <p>During the preparation of this work, the authors used LLMs like ChatGPT or Mistral in order to perform
grammar, spelling check, and help with formatting. After using these tools, the authors reviewed and
edited the content as needed and take full responsibility for the publication’s content.</p>
    </sec>
    <sec id="sec-6">
      <title>A. Sample Outputs</title>
      <p>Examples of the output generated by AlgoAce are provided in Figure 1. We observe that the LLM is
explaining the recommendations made by looking at user submission history.</p>
    </sec>
    <sec id="sec-7">
      <title>B. Prompt Template</title>
      <sec id="sec-7-1">
        <title>B.1. Query Rewriting Prompt</title>
        <p>The query rewriting prompt is used to reformulate user queries with explicit metadata terms, improving
retrieval accuracy:
You are a query rewriting assistant for a competitive programming tool.
The goal is to rewrite user queries so that they include concrete terms that match
problem metadata stored in a database. The database retrieves problems based on word
overlap with the query - so include exact terms like problem ’tags’ (e.g. ’greedy’,
’dp’, ’graphs’), verdicts (e.g. ’WRONG_ANSWER’, ’OK’, ’RUNTIME_ERROR’), difficulty
’ratings’ (e.g. 800,1000, 1700), or specific problem names if known.
You do NOT have access to the user’s past submissions, but you must guess the user’s
intent and include as many relevant keywords as possible to help the system match the
query to relevant problems. Your output should be in the following format:
Retrieval terms: &lt;insert keywords for retrieval&gt;
Make sure the retrieval terms are rich in specific tokens, and the user query is clear
and helpful for the LLM.</p>
      </sec>
      <sec id="sec-7-2">
        <title>B.2. Response Generation Prompt</title>
        <p>The response generation prompt guides the LLM in analyzing user submissions and generating tailored
recommendations or explanations:
You are a competitive programming coach.</p>
        <p>I will give you the user code submissions and a list of all available problems after
"Data:". The data lines with verdict are the user code submissions. The other lines are
the available problems on codeforces. Answer the user query after looking at the user
code submissions and the questions he got a wrong answer in. The problems you analyze
and suggest should only be from the given data lines without verdict and should be
similar in rating to the highest rated problems that the user has attempted.
The answer should also explain how you arrived at the answer looking at the user code
submissions if necessary. Keep your thinking short.</p>
        <p>Example query : "What problems should I practice next?"
Ideal Answer : "Looking at your submissions, you solve questions rated around 1500 and
you are facing difficulty in implementing binary search. So here are some binary
search problems you can practice: [Links to Binary search
problems]."
Example query : "How to implement dynamic programming?"
Ideal Answer : "Here’s an implementation of dynamic programming. [Dynamic Programming
Code].\n
Data: \n {context} \n{query} /think.</p>
      </sec>
    </sec>
    <sec id="sec-8">
      <title>C. Sample Codeforces data</title>
      <p>Examples of Codeforces problems are provided in Table 1. An example of user submission history is
provided in Table 2.</p>
    </sec>
    <sec id="sec-9">
      <title>D. RAG pipeline</title>
      <p>Our pipeline is provided in Figure 2.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>P.</given-names>
            <surname>Lewis</surname>
          </string-name>
          ,
          <string-name>
            <given-names>E.</given-names>
            <surname>Perez</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Piktus</surname>
          </string-name>
          ,
          <string-name>
            <given-names>F.</given-names>
            <surname>Petroni</surname>
          </string-name>
          ,
          <string-name>
            <given-names>V.</given-names>
            <surname>Karpukhin</surname>
          </string-name>
          ,
          <string-name>
            <given-names>N.</given-names>
            <surname>Goyal</surname>
          </string-name>
          ,
          <string-name>
            <given-names>H.</given-names>
            <surname>Küttler</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Lewis</surname>
          </string-name>
          , W.-t. Yih,
          <string-name>
            <given-names>T.</given-names>
            <surname>Rocktäschel</surname>
          </string-name>
          , et al.,
          <article-title>Retrieval-augmented generation for knowledge-intensive NLP tasks</article-title>
          ,
          <source>Advances in Neural Information Processing Systems</source>
          <volume>33</volume>
          (
          <year>2020</year>
          )
          <fpage>9459</fpage>
          -
          <lpage>9474</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <given-names>L.</given-names>
            <surname>Zhang</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Lin</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C.</given-names>
            <surname>Borchers</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Sabatini</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Hollander</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Cao</surname>
          </string-name>
          ,
          <string-name>
            <given-names>X.</given-names>
            <surname>Hu</surname>
          </string-name>
          ,
          <article-title>Predicting Learning Performance with Large Language Models: A Study in Adult Literacy</article-title>
          ,
          <year>2024</year>
          . URL: https://arxiv.org/abs/ 2403.14668.
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <given-names>N.</given-names>
            <surname>Kiesler</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Schifner</surname>
          </string-name>
          ,
          <article-title>Large language models in introductory programming education: Chatgpt's performance and implications for assessments</article-title>
          ,
          <year>2023</year>
          . URL: https://arxiv.org/abs/2308.08572. arXiv:
          <volume>2308</volume>
          .
          <fpage>08572</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <given-names>S. P.</given-names>
            <surname>Neshaei</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R. L.</given-names>
            <surname>Davis</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Hazimeh</surname>
          </string-name>
          ,
          <string-name>
            <given-names>B.</given-names>
            <surname>Lazarevski</surname>
          </string-name>
          ,
          <string-name>
            <given-names>P.</given-names>
            <surname>Dillenbourg</surname>
          </string-name>
          , T. Käser,
          <article-title>Towards modeling learner performance with large language models</article-title>
          ,
          <year>2024</year>
          . URL: https://arxiv.org/abs/2403.14661. arXiv:
          <volume>2403</volume>
          .
          <fpage>14661</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <given-names>F.</given-names>
            <surname>Ai</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Y.</given-names>
            <surname>Chen</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Y.</given-names>
            <surname>Guo</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Y.</given-names>
            <surname>Zhao</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Z.</given-names>
            <surname>Wang</surname>
          </string-name>
          , G. Fu,
          <string-name>
            <surname>G.</surname>
          </string-name>
          <article-title>Wang, Concept-aware deep knowledge tracing and exercise recommendation in an online learning system</article-title>
          ,
          <source>in: EDM, International Educational Data Mining Society (IEDMS)</source>
          ,
          <year>2019</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <given-names>S.</given-names>
            <surname>Jacobs</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Jaschke</surname>
          </string-name>
          ,
          <article-title>Leveraging lecture content for improved feedback: Explorations with GPT-4 and retrieval augmented generation</article-title>
          ,
          <source>in: 2024 36th International Conference on Software Engineering Education and Training (CSEE&amp;T)</source>
          , IEEE,
          <year>2024</year>
          , pp.
          <fpage>1</fpage>
          -
          <lpage>5</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          [7]
          <string-name>
            <given-names>O.</given-names>
            <surname>Henkel</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Z.</given-names>
            <surname>Levonian</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C.</given-names>
            <surname>Li</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Postle</surname>
          </string-name>
          ,
          <article-title>Retrieval-augmented generation to improve math questionanswering: Trade-ofs between groundedness and human preference</article-title>
          ,
          <source>in: Proceedings of the 17th International Conference on Educational Data Mining</source>
          ,
          <year>2024</year>
          , pp.
          <fpage>315</fpage>
          -
          <lpage>320</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          [8]
          <string-name>
            <given-names>S. S.</given-names>
            <surname>Manathunga</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Y. A.</given-names>
            <surname>Illangasekara</surname>
          </string-name>
          ,
          <article-title>Retrieval augmented generation and representative vector summarization for large unstructured textual data in medical education</article-title>
          ,
          <year>2023</year>
          . URL: https://arxiv. org/abs/2308.00479. arXiv:
          <volume>2308</volume>
          .
          <fpage>00479</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          [9]
          <string-name>
            <given-names>Z. F.</given-names>
            <surname>Han</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J</given-names>
            .
            <surname>Lin</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Gurung</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D. R.</given-names>
            <surname>Thomas</surname>
          </string-name>
          ,
          <string-name>
            <given-names>E.</given-names>
            <surname>Chen</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C.</given-names>
            <surname>Borchers</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Gupta</surname>
          </string-name>
          ,
          <string-name>
            <given-names>K. R.</given-names>
            <surname>Koedinger</surname>
          </string-name>
          ,
          <article-title>Improving assessment of tutoring practices using retrieval-augmented generation</article-title>
          ,
          <year>2024</year>
          . URL: https://arxiv.org/abs/2402.14594. arXiv:
          <volume>2402</volume>
          .
          <fpage>14594</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          [10]
          <string-name>
            <given-names>Y.</given-names>
            <surname>Liu</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R.</given-names>
            <surname>Zhu</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Gao</surname>
          </string-name>
          ,
          <source>Personalized Programming Guidance based on Deep Programming Learning Style Capturing</source>
          ,
          <year>2024</year>
          . URL: https://arxiv.org/abs/2403.14638.
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          [11]
          <string-name>
            <given-names>S.</given-names>
            <surname>Branchi</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C. D.</given-names>
            <surname>Francescomarino</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C.</given-names>
            <surname>Ghidini</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Massimo</surname>
          </string-name>
          ,
          <string-name>
            <given-names>F.</given-names>
            <surname>Ricci</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Ronzani</surname>
          </string-name>
          ,
          <article-title>Learning to act: a reinforcement learning approach to recommend the best next activities</article-title>
          ,
          <year>2022</year>
          . URL: https: //arxiv.org/abs/2203.15398. arXiv:
          <volume>2203</volume>
          .
          <fpage>15398</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref12">
        <mixed-citation>
          [12]
          <string-name>
            <given-names>P.</given-names>
            <surname>Agarwal</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Gupta</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R.</given-names>
            <surname>Sindhgatta</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Dechu</surname>
          </string-name>
          ,
          <article-title>Goal-oriented next best activity recommendation using reinforcement learning, 2022</article-title>
          . URL: https://arxiv.org/abs/2205.03219. arXiv:
          <volume>2205</volume>
          .
          <fpage>03219</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref13">
        <mixed-citation>
          [13]
          <string-name>
            <given-names>J.</given-names>
            <surname>Vassoyan</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.-J.</given-names>
            <surname>Vie</surname>
          </string-name>
          ,
          <string-name>
            <given-names>P.</given-names>
            <surname>Lemberger</surname>
          </string-name>
          ,
          <article-title>Towards scalable adaptive learning with graph neural networks and reinforcement learning</article-title>
          ,
          <year>2023</year>
          . URL: https://arxiv.org/abs/2305.06398. arXiv:
          <volume>2305</volume>
          .
          <fpage>06398</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref14">
        <mixed-citation>
          [14]
          <string-name>
            <given-names>P.</given-names>
            <surname>Veličković</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Vitvitskyi</surname>
          </string-name>
          ,
          <string-name>
            <given-names>L.</given-names>
            <surname>Markeeva</surname>
          </string-name>
          ,
          <string-name>
            <given-names>B.</given-names>
            <surname>Ibarz</surname>
          </string-name>
          ,
          <string-name>
            <given-names>L.</given-names>
            <surname>Buesing</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Balog</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Novikov</surname>
          </string-name>
          ,
          <article-title>Amplifying human performance in combinatorial competitive programming</article-title>
          ,
          <year>2024</year>
          . URL: https://arxiv.org/abs/ 2411.19744.
        </mixed-citation>
      </ref>
      <ref id="ref15">
        <mixed-citation>
          [15]
          <string-name>
            <given-names>J.</given-names>
            <surname>Frej</surname>
          </string-name>
          ,
          <string-name>
            <given-names>N.</given-names>
            <surname>Shah</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Knezevic</surname>
          </string-name>
          ,
          <string-name>
            <given-names>T.</given-names>
            <surname>Nazaretsky</surname>
          </string-name>
          , T. Käser,
          <article-title>Finding paths for explainable mooc recommendation: A learner perspective</article-title>
          ,
          <source>in: Proceedings of the 14th Learning Analytics and Knowledge Conference</source>
          ,
          <source>LAK '24</source>
          ,
          <string-name>
            <surname>ACM</surname>
          </string-name>
          ,
          <year>2024</year>
          , p.
          <fpage>426</fpage>
          -
          <lpage>437</lpage>
          . URL: http://dx.doi.org/10.1145/3636555.3636898. doi:
          <volume>10</volume>
          .1145/3636555.3636898.
        </mixed-citation>
      </ref>
      <ref id="ref16">
        <mixed-citation>
          [16]
          <string-name>
            <given-names>J.</given-names>
            <surname>Rao</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Lin</surname>
          </string-name>
          ,
          <string-name>
            <surname>RAMO</surname>
          </string-name>
          :
          <article-title>Retrieval-Augmented Generation for Enhancing MOOCs Recommendations</article-title>
          ,
          <year>2024</year>
          . URL: https://arxiv.org/abs/2407.04925.
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>