Блог пользователя Hmzaawy

Автор Hmzaawy, история, 4 месяца назад, По-английски

Hello Codeforces!

TLDR; Chcek the AI Coach Chrome Extension Here: Repovive Competitive Programming, And get your Gemini API Keys Here: Google AI Studio

I’m excited to share a project I've been working on at Repovive, with the Great Shayan.

We all know the struggle: you're stuck on a problem, the editorial is confusing (or non-existent), and you just need a small hint to nudge you in the right direction—not the full solution. That's exactly what this tool is built for.

What is it?

The new addition to the Repovive Chorme Extension, an AI Agent, that embeds a context-aware AI chat directly into Codeforces (and AtCoder/LeetCode) problem pages.

It isn't just a wrapper around ChatGPT, nor is it a proprietary "Black Box" model trained from scratch.

  • Powered by Gemini: It leverages the Google Gemini API (gemini-pro/flash) for reasoning.

  • Your Own Keys: You use your own free API key from Google AI Studio. This means no subscription fees and total control over your usage.

  • Context Aware: It specifically understands competitive programming contexts:

    • It reads the problem statement, constraints, and test cases automatically.
    • It fetches Accepted solutions from top rankers (Red Coders) to understand the optimal approach.
    • It simulates a "Socratic Coach": it refuses to give you the code initially. Instead, it asks you guiding questions to help you derive the solution yourself.

First Message Logic

Platform Deep Dive: Under the Hood

Each platform requires a unique engineering approach. Here is how we handle the "Big Three":

1. Codeforces

Codeforces Support

  • How it works:
    • Parsing: We use the official codeforces.com/api to fetch problem metadata.
    • Solution Mining: We identify the contest "Winners" via the API, find their submission IDs, and then get their source code.
    • Anti-Cheat: We detect the specific .countdown timer element used in active rounds.
  • Tradeoffs & Limitations:
    • API Rate Limits: Codeforces has a strict 5 req/sec limit. If the site is under load (e.g., right after a contest), the "Solution Mining" might fail or be slow.
    • Old Contests: Some very old problems ($$$ \lt 2015$$$) might have missing metadata or different DOM structures that break parsing.

2. AtCoder

AtCoder Supoort

  • How it works:
    • Parsing: Since AtCoder has no official API, we built a robust HTML parser that reads the DOM directly to extract inputs/outputs.
    • Solution Mining: The agent navigates to the submissions page, filters for "Accepted" + "C++" + "Fastest", and gets the code from the top result.
  • Tradeoffs & Limitations:
    • Login Wall: For some contests, you must be logged in to view submissions. The agent might show a "Cookie Error" if it can't access the submission page (it tries to inherit your session, but browser security can block this).
    • Fragility: If AtCoder changes their website UI (class names), the geter will break until we update the extension.

3. LeetCode

LeetCode Support

  • How it works:
    • Parsing: We reverse-engineered LeetCode's GraphQL API to fetch clean problem questions without parsing messy HTML.
    • Knowledge Source:
      • Old Problems (ID < 3200): Since these are in the LLM's training data, we rely on the model's internal knowledge for faster responses.
      • New Problems: We fetch the top-voted "Community Solution" via GraphQL to give the model context on brand new questions.
    • Anti-Cheat: We strictly disable the agent on any URL containing /contest/.
  • Tradeoffs & Limitations:
    • SPA Navigation: LeetCode is a Single Page Application (React). Sometimes the button might disappear when navigating between problems; a page refresh fixes this.
    • Community Quality: For new problems, (ID > 3200), it is unlikely to get a solution, because the only way is to use leetcode GraphQL API, there is no official documentation, so we are still working on the best way to get a solution to feed the AI.

Customizing Your Experience

Settings Dialog

The extension also includes deep theming support to match your system style!

Legal & Ethical Notices (Anti-Cheat)

Crucial Point: We take fair play seriously.

  • Strict Anti-Cheat: The agent is programmed to automatically disable itself during live contests.
    • Codeforces: It detects the server-side countdown timer for active rounds.
    • AtCoder: It checks the contest timer element.
    • LeetCode: It hard-blocks any URL containing /contest/.
  • Purpose: This tool is strictly for upsolving and practice. Using AI assistance during a rated contest is cheating and will get you banned. Don't do it.

Privacy & Security

  • No Data Collection: Repovive DOES NOT collect, store, or transmit your data to its servers. We do not access your cookies or personal information.
  • Local Storage Only: Your API keys, settings, and chat history are stored exclusively in your browser's local storage. Nothing leaves your machine except the API request to Gemini.

How to Get Started

  1. Install Repovive: Repovive Competitive Programming
  2. Get a Gemini API Key:

    • Go to Google AI Studio and sign in with your Google account.
    • Click on the blue "Get API key" button in the top-left sidebar.
    • Click "Create API key". You might need to select "Create API key in new project" if you don't have one.

    Google AI Studio Dashboard

    • Copy the key that starts with AIza....

    Copying the API Key

  3. Open a Problem: Navigate to any Codeforces problem.
  4. Click the Sparkle: You'll see the floating AI button. Click it, paste your API key once, and start upsolving!

Known Issues & Roadmap

Since this is an early beta, you might encounter:

  • Rate Limits: If too many people use it at once, Codeforces API might slow down context fetching.

  • Parsing Errors: Extremely old contests (10+ years ago) might have broken HTML structures.

  • LeetCode Spa: On LeetCode, if the button disappears after navigating, just refresh the page.

  • Gemini Free Limits: The Google Gemini Free Tier has usage limits (RPM/TPM).

    • If you see ResourceExhausted or 429 errors, it means you've hit the limit.
    • Auto-Downgrade Feature: To keep you coding, the agent will automatically downgrade from Gemini Pro to Gemini Flash, then downgrade to Gemini Flash-Light if it detects quota issues. It automatically tries to upgrade back after 6 hours.

What's Next?

  • Better support for LeetCode new problems (ID > 3200).
  • More robust cookie handling for AtCoder login walls.
  • Integrating a "Hint Mode" that blurs the code mining output initially.

Feedback & Support

We need your help to make this better!

  • Found a bug? Please report it to me on Codeforces

  • Have a suggestion? Message me directly on Codeforces

  • Wanna contribute? Message me directly on Codeforces with your idea you want to contribute!


Features Requested And will be added Soon:

After I submit my correct code, it can take my code and create a step by step solution or hint in plain English, highlighting the key areas and how i solved it. this will be useful when we revisit the problem.

We hope to see the extension working on the private groups & private gyms too!  

Can we add  Online Judge (UVa) support?  

btw can u add so we can use Chatgpt / Deepseek too?

  • Проголосовать: нравится
  • +154
  • Проголосовать: не нравится

»
4 месяца назад, скрыть # |
 
Проголосовать: нравится +9 Проголосовать: не нравится

Auto comment: topic has been updated by Hmzaawy (previous revision, new revision, compare).

»
4 месяца назад, скрыть # |
 
Проголосовать: нравится +9 Проголосовать: не нравится

Nice job, this is an innovation

»
4 месяца назад, скрыть # |
 
Проголосовать: нравится +8 Проголосовать: не нравится

Great work bro :)

»
4 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Great Work

»
4 месяца назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

amazing ^_^

»
4 месяца назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

Well done bro

»
4 месяца назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

Every time a Game Changing thing

»
4 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Why saying API Key not valid ?

Help me someone!

»
4 месяца назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

Nice job

»
4 месяца назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

This looks pretty cool, thanks u men! U have all my congrats

»
4 месяца назад, скрыть # |
 
Проголосовать: нравится +35 Проголосовать: не нравится

I will (once again) show how repovive is great for empowering indians (this is why you keep private code server side guys!!!!!!) (the practices shown in this is for educational purposes and this comment serves as a warning for other developers (and repovive themselves) to put the code server side, or obfuscate it to some extent)

Chrome extension decompiler is trivial, you can litearlly search for it lets decompile repovives extension, ok cool, theres like 3 js files, the rest are unraeadable and not source (yes youre given the ENTIRE SOURCE)

and in one of them you see this code

    async isLiveContest(e, t) {
        if (e.includes("/contest/") || e.includes("/gym/")) {
            const n = t.querySelector(".countdown");
            if (n && n.textContent) {
                const a = n.textContent.toLowerCase();
                return a.includes("finished") || a.includes("over") || a.includes("before") ? !1 : (console.log("[Repovive] Codeforces Live Contest Detected! Disabling AI."), !0)
            }
        }
        return !1
    }

yeah. repovive is continuing to be the biggest joke of all time empowering all the Indian cheaters. This litearlly took 3 minutes.

  • »
    »
    4 месяца назад, скрыть # ^ |
     
    Проголосовать: нравится -6 Проголосовать: не нравится

    Let's first say, even if the extension is not disabled, it will not be able to solve a problem above A, because the free tier only uses the Gemini flash , the Gemini pro does not work for the free API. Flash Nor Pro cannot solve problems on its own.

    and, girl seriously, the last thing I will do when I want to cheat is use a chrome extension decompiler, It is easier to go ask some ai :D

»
4 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Nice!

btw can u add so we can use Chatgpt / Deepseek too?

»
4 месяца назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

Greatness ⚡

»
4 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Excellent work, thank you for your effort

»
4 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

This actually helps a lot. I've been needing something like this — like it or not, this is innovation.

»
4 месяца назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

This is great <3

»
4 месяца назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

Could you also add harder variations of an easy problem, maybe in the future updates for. Anyway this is totally is a gamechanger, appreciate it!

»
4 месяца назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

Great work Hamza

»
4 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Auto comment: topic has been updated by Hmzaawy (previous revision, new revision, compare).

»
4 месяца назад, скрыть # |
 
Проголосовать: нравится +8 Проголосовать: не нравится

The best part of this post is that you mentioned its anti-cheat!

Jokes aside, great work!

»
3 месяца назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

This is pretty awesome (ما شاء الله).

I have an idea. I think many people get stuck on problems in private groups more than public ones, since private groups don’t usually have tutorials or upsolve videos. So maybe you could ask Codeforces admins for permission to access the solutions and treat them like normal problems.

I’m not sure if this is possible, but if it is, it would be amazing.

»
3 месяца назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

Great Job Bro

»
3 месяца назад, скрыть # |
Rev. 2  
Проголосовать: нравится +3 Проголосовать: не нравится

Wow this will make learning easier and more approachable. I feel like i will use this a lot to upsolve problems. Thanks great job btw

»
3 месяца назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

nvm

»
3 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

so, during contest can i still use the "Open in Repovive" button? (i know the agent is disabled during live contests) but does the editor still works?