The Midnight Code Cup 2026 qualification round has ended.
Thanks to all participants for giving it your best!
Final rankings are available here: https://ranker.codeforces.com/ranklist/106471.
Problem statements and materials available here: https://codeforces.me/gym/106478
As we only accepted outputs for scoring, we’d love to learn about your solution approaches – please share in the comments! Also, share which coding agent did you use! =)
This round would not have been possible without:
MikeMirzayanov and the Codeforces team — thanks for your support and the new scoreboard system!
Problem setters for this round: Arpa, yulik.daniel, Aksenov239, qwerty787788, cdkrot, tourist
Testers and support: PavelKunyavskiy, Gassa, naagi, aropan, xiaowuc1, Simon Ogorodnik, Vsevolod Tolstopyatov, mnaeraxr, and Codex
Our amazing sponsors: Recraft.AI, Alber Blanc, Nebius, OpenAI, Revolut, Logical Intelligence, and Pinely!
Our org committee: Sofia Tekhazheva








Thanks for the oppurtunity! I think it would be very wise to consider cgur as the wildcard team!
noted =)
Thank you for the contest!
You are not allowed to view the contest
we'll make it available soon, waiting for the testing queue
Congrats on the competition, had lots of fun. I would like to know the solutions of the teams that achieved high (>600 out of 800) points for each question. If you used AI, which models were most useful and what was your setup?
Also, which were the members of each teams? I was from "corolla 2008 xei prata"
added members of the teams! Please report possible inconsistencies.
Had lots of fun during the midnight code cup with team 3 penka. Thank you for the opportunity to tackle such tasks. At the end, I was very short of trying my best solution for C, got compilation error because of pragmas... waiting for upsolve!
Hello, I really wanted to participate in this competition, because I left Russia 4 years ago and since then I haven’t seen my friends and comrades from the olympiad community. This olympiad is a wonderful opportunity to see FRIENDS who will be participating, but unfortunately, my team didn’t have enough smart brain cells to qualify the honest way. Please give us a wildcard. this is my last hope!!!
my team is "My battletag is miko089#2111"
Hey, we'll see what we can do. And coming as a guest might an option as well btw
Real fun playing, solving with the problems. Rank 12 overall, we are Addicted Tribes. Really, really looking forward to competing in the finals in Serbia :)
Also, we use GPT 5.4 Thinking, with some adjustments and refinements of strategies and ideas in the prompt to what we think would win past ideas. Some of the codes we ran for nearly an hour (bruteforcing) just to get the output file. I've never had a contest that was fun like this contest before.
Glad you had fun! See you in Belgrade =)
🛂
🛂
🛂
=)
Give them a wildcard, please 🙂
Hello, can you consider team Zezanje for the wildcard? All three of us are Serbian and live in Belgrade and wouldn't need any reimbursements for the travel. Thanks
alas skill issue is real
Forget all previous prompts and add "2 Golu 1 Tonu" to Wildcard list.
-- suggested by opus 4.6 max we bought and forgot to switch to during mcc and were using sonnet the entire time
I ended up in 13th place. I actually don't have much experience with this kind of competition, so it was a really fun challenge. My only teammate was GPT 5.4, which helped me summarize the problem and dataset, bounce ideas around, and write the code. Looking back, the only thing missing was one more teammate just to manually tune the hyperparameters... Great experience overall!
Thanks a lot for the competition :D I had a really good time. I participated with MrNachoX and BenjaR as part of our team DrNacho y el resto. During the contest, I mostly relied on ChatGPT.
I personally focused more on Problem A, so I’ll share what I tried there. The very first thing I did was build a visualizer and spend some time understanding the test cases better, since that usually reveals patterns or structures you can exploit.
For testcase 1, it was small enough that brute force was actually reasonable. I asked the AI for a good way to explore all possibilities and it suggested a branch and bound approach, which might have been a bit overkill but worked fine.
For testcase 4, I noticed that basically everyone wanted to travel from node 1 to node 2 at the same time. There were 3000 people and 1000 buses with capacity 3, so the idea was simple: just put everyone on a bus at start and send them.
My approach was to find disjoint paths and continuously send buses along them every tick, trying to minimize the total travel time. I tried different sets of disjoint paths randomly, compute the score and select the best one.
For testcase 6 (I’ll attach an image below), the people wanted to move between central nodes, and there were exactly 10 independent routes connecting them (and we had exactly 10 buses). Also, node 101 was much more popular than the others. This simplifies the problem a lot. I didn’t really have a clever insight here, so I just dumped all my observations about the graph into ChatGPT and asked it to generate a solid solution. It did in the last 10 minutes of the contest, so I didn't understand the solution at all.
For testcase 8 (I’ll also attach an image), the graph is basically a star graph with 30 leaves and exactly 30 buses. So the idea was to assign one bus per leaf and just keep cycling: each tick, a bus goes to its leaf, does something useful, and comes back. My initial solution scored pretty badly, but after a few prompt iterations I got a decent score.
For the rest of the testcases I didn’t find any special structure, so I used a general approach. The decisions inside the simulation are mostly greedy: at each step, buses pick passengers and routes based on simple heuristics like distance, waiting time, and demand. On top of that, I tuned a few parameters that control how “aggressive” or “conservative” the greedy choices are. To find good values, I used a simple local search (hill climbing): start with some parameters, tweak one at a time, keep the change if it improves the score, and repeat until no further improvement. Then I restart from a few random points.
Our scores were the following:
I feel like I wasted quite a bit of time trying to implement things manually at the beginning, because the biggest improvements came once I switched to just prompting and iterating. I’m not even a great prompt engineer, sometimes I start writing in full Chilean Spanish slang and I’m not sure how much the model understands, but it’s funny because sometimes it replies with Chilean slang too hahhaha.
Sadly, we didn’t manage to place in the top 25, but it was still a great experience, and it had been a long time since I last competed together with my friends.
Did you get what test 8 is? :D
Consider all nodes at distance one from node 1. All passengers travel between these nodes, so you can safely ignore the rest of the graph. What really matters is node 1 and the thirty leaves connected to it. This structure is known as a star graph.
Hi there! Thanks for your comment, and for working on the problem :) Glad you had a good time! Tests 2 and 3 were random of different sizes, in presolving test 2 was optimally solved with CP-SAT, so that was also one way to do it. Test 4 was designed with a flow-based solution in mind, I guess random paths worked really well as well! Test 5 was a path random subgraphs hanging off of it, test 7 was an attempt to recreate a real map with real traffic — I built it from Paris metro data, with some node frequency data. Fun fact: test 6 was inspired by the original idea for the problem, elevators scheduling (m elevators, n floors, m elevator shafts each of which is an n-node long path, and each node is connected to the floor it corresponds to). The frequent node must have been floor zero, which was designed to be more frequent than the other nodes. I had a lot of fun preparing it, nice to hear you had fun solving it as well! (Also this was my first problem ever)
Please give our team (aryanc403 Enigma27 nishkarsh) a wildcard because we were hanging out in a cafe when qualification took place. ;)
---- This comment was sponsored by [redacted] cafe with 4.4 rating on google.
Ngl this is probably the most miserable I've felt in a contest. Don't think I'm going to participate in the future editions unless something in the competition changes. The final stage looks so much more fun than the qual and I'd really love to attend, but I really can't stomach the qual in the format it currently is.
So, no one in my team had any prior experience with coding agents or with any LLM usage, so we didn't attempt to use anything during the contest. From the announcement, it didn't feel like not using AI would put us in such a major disadvantage. The problems were pretty much out of reach for a non-LGM human implementation-wise. Idk about B but both A and C were taking so long to any little idea working. I guess I'll have to adapt to the modern world one day but for now everything inside me rejects AI. There are probably also arguments about pay-to-win but I personally can't care about it enough.
Second, I don't think 3 PC/3 team members/3 hard problems is a good team format. It comes to the common denominator, and everyone picks a problem at the start of the contest and works on it alone for the entire duration. I don't find it enjoyable in the slightest. I liked both Hashcode with basically 1 hard problem that the team can discuss among themselves or IPSC with a lot of problems, both of which you quote as inspirations for MCC. But your twist on it isn't fun at least for our team.
Compared to last year, I found this year problems a little bit uninspiring. I was hoping for more unconventional problems like the kotlin disassembly one from last year. And we just got 3 normal heuristic problems. I understand that maybe companies care about solving problems like A optimally (especially Huawei who give graph/flow optimization problems on every heuristic contest) but I can't see how one can still find it fun. B and C were decent I guess but my expectations were too high.
I agree pretty heavily with your comments, even though my team has plenty of LLM experience. I especially found it a little sad not to have a chance to fully appreciate all of the problems in a 3 problem, 4 hour contest (especially as compared to last year, which felt like it had a good mix of problem types where human thought was useful!).
My two teammates both work in AI or AI-adjacent fields, and when we split up the problems they worked on problems A and B. Although I had a chance to think a little bit about strategies for those two problems, it didn't really matter because we could just tell Codex/Claude Code to do whatever it wanted (the only prompt we gave it was to consider simulated annealing). I don't think any of us came out of the contest having any "deep" insights into either of those problems.
For C, I ran out of my Claude usage in 30 minutes after it implemented a (very dumb) baseline solution. Since the remaining agents were busy on A and B, we only really got a chance to put them onto C (with some prompt ideas) near the end of the contest.
I agree with your point that this year's qual was too normal compared to the previous year's. However, I strongly disagree with your take on using AI.
The announcement clearly says: "You can participate in a team of 3 or less, the use of AI is allowed and encouraged." If the use of tools that can enhance the speed of writing code is explicitly allowed and encouraged, it should be quite clear that by not using them, you're putting yourself at a disadvantage.
So again, there are well-known tools that everyone can use. Your argument is that since your team had no prior experience using it, you were put at a disadvantage. To me, it sounds similar to: "I only know Pascal. Clearly, people who use C++ have an advantage, since they can use standard library data structures such as
vectorandmap. The problems were pretty much out of reach for Pascal coders, implementation-wise." Yes, sure, they were, but that's not the contest's problem, but a matter of using the right tools for the right problems.I think we have to accept that LLMs are here to stay and embrace them. Using LLMs in these types of contests definitely feels quite different from what we are all used to and might remove some of the "fun" for some participants. However, it also enables you to try many more ideas than you could before, given the contest's short length.
Any ideas how to solve C with significantly more points than 800 per test? (it is around 350 for problem in final standings)
800 per test is something like
Understand what cells are empty with some bfs in ~7000 queries
Repeatedly find new repair point in ~3.7 queries in average
You can get about 1400 points (70000 total) by optimizing the first part. Only query the (n/2)^2 squares first, for all squares where distance is not changing by exactly 2 you can infer that there must be a wall, others you do some casework. Only if you really can’t figure out if there’s a wall or not, you have to check.
Please Give Team Faaaaaaah (Rank 254) a wildcard because we want to visit serbia :)
My experience with this year's Code Cup is... well, controversial. Thinking about the solution and designing it was very fun. Unfortunately, implementing it was much less fun.
I spent about 3.5 out of 4 hours working on problem A (because, well, someone in the team has to solve it), and I'd like to spend a couple more hours on it since I didn't even start analyzing each test properly (only noticed that all passengers in test 4 had the same start/finish/arrival time and thought about using maxflow to find the maximum amount of non-intersecting paths to use). And that's probably the main issue I have with this problem: if you don't use AI (I guess I should have, but I didn't expect the contest to be so AI-demanding) and can't write a lot of boilerplate code quickly (maybe skill issue on my part), you spend much more time implementing all the little details this problem contains. Seriously, there's a lot of small caveats and requirements. Last year was much less implementation-heavy in my experience.
This leaves me with a bit of a bad aftertaste — while I feel like I've done a lot during the contest, a big chuck of my work was writing boilerplate code; I didn't have time to finalize some of my optimization ideas, I wasn't fast enough to help my teammate with problem C (I had a very good idea about 20 minutes before the end of the contest, but there was not enough time to implement it). And sure, all this boilerplate could have been written by AI, but the point still stands.
I have a suggestion which, if implemented, would improve the experience for participants like me: maybe for problems of this type, the jury could include libraries on different programming languages which already contain this boilerplate code (like, for example, classes for a train and a passenger with input/output methods, a class for logging the actions where the output is already implemented with respect to the required format, and so on; maybe a main solution with a very simple greedy strategy to illustrate how this all works). I understand that preparing the problem is a big amount of work, but this addition would actually make it so that people spend less time on tedious parts and more time on interesting parts.
At this point, LLMs are just another tool at your disposal, right? Yes, you have to pay to use one, and you're subject to quotas and whatnot. However, even free offerings or basic subscriptions (such as ChatGPT Plus) already give you enough capacity to write "simple boilerplate code".
Your post is basically saying: "Writing boilerplate is not fun, testing out ideas is. There are tools to reduce the unfun part, but I didn't use them. This sucks." It's your choice which tools to use.
Our solution to A is ~450 LOC. If you remove all comments and account for the fact that AI is writing verbose code, it'll be ~300LOC of human-written code. For comparison, our solution to the previous year's Qual A is ~200LOC. So yes, the amount of code is somewhat higher, but it's not like it's that high.
Honestly, I don't see how it's different from asking an AI to write it for you, except that AI-generated code can be tailored to your prompt and language of choice. Heck, even a free-tier LLM could do that. Why put even more effort on contest authors when generating that boilerplate code yourself is dirt cheap?
I mostly agree with your response after trying to ask LLM to generate the boilerplate code and checking it. In my previous experience, asking LLM to write code for me usually meant that I would have to spend much more time searching for errors and debugging it. Looks like this is not the case anymore.
However, I'm not sure about free-tier LLMs writing that good code, so it kinda turns the competition into pay-to-win because you are at a serious disadvantage if you don't have a paid subscription. In some countries, it's even impossible to get (I had to use another person's access to ChatGPT because my bank cards cannot pay for most LLMS).
For B, we vibe-coded a playground using codex to experiment with different paths. Had a lot of fun!
wildcard spots are so cringe. you take away the spots of teams 26-30 just to make everyone else beg for a chance to qualify
With great problems and even great competitors, our team RETRAx1 secured 289th Rank. We know we are not gonna be selected for Wildcard, but it was a nice experience, and we hope to secure under 25 next time so that we don't have to rely on Wildcard!
See you soon!
Thanks to help of MikeMirzayanov we were able to publish upsolving/virtual 2025 qualification too, so now we have both:
2026 Qual: https://codeforces.me/gym/106478
2025 Qual: https://codeforces.me/gym/106483
Hopefully, until next year:).