- Error_Yuan for his wonderful coordination.
- Alexdat2000 for Russian translation.
- Geothermal, Um_nik, and Dominater069 for nutella testing.
- __baozii__ for remaining an IGM during testing (unlike me).
- BucketPotato, kevinyang, golomb, xiaowuc1, apgpsoop, and 4fecta for red testing.
- kevin, Auchenai01, and _odium for testing and being an IM at some point in their lives (unlike conqueror_of_tourist).
- sszcdjr, fishy15, fwfjs, applepi216, beaaaan, zhed, Julto, and ow3nL for yellow testing.
- ToxicPie9, shcal, Gilwall, biximo, RTE, and aggrovector for purple testing.
- djrfrn, Leaves333, mtand872, chromate00, and mathtsai for blue testing.
- laze, LetianPie, RockingMat, and pranp_24 for cyan testing.
- waterbottledude for making sure we get every color (maybe you can test after the contest!!).
- Milmon and elituni for gray testing.
- jaguar713 for truly making sure we get every color (and drawing multiple diagrams).
- MikeMirzayanov and KAN for the great Codeforces and Polygon platforms.
You
for participating in this round.
Update 1: The score distribution is as follows
⛄ We hope you'll enjoy the problems! ⛄
Update 2: Hacks will be disabled on problems A-E.
Update 3: Editorial
Update 4: Congratulations to the winners!
We sincerely hope you enjoyed a nonnegative number of problems on the round. We hope you have a Happy New Year (both on CF and irl... maybe go touch some grass for the first time this year)!








1st
I participated in the Hello 2025 contest, and now I’m going to participate in Good Bye 2025. Time passes so fast hoping to enjoy the last contest of the year. Merry Christmas, everyone!
It's not last :D , There's Educational Codeforces Round 186 (Rated for Div. 2)
it only goes faster as you get older
r/depressingasfuck top commentator spotted
As a tester, I want to know why you're not playing Honkai: Star Rail.
What is Honkai: Star Rail?
It is something xiaowuc1 decided to stop playing in order to test this round.
I can confirm that for a nonnegative number of minutes during my testing, I was not playing Honkai: Star Rail.
What is Genshin Impact?
Ruan Mei is best supporter, change my mind
how do you have a IGM name on 1300+ rating??
try using magic tab in profile
thanks dude. NOT going for IGM tag, expert is good enough for me :)
hyw.I have already start the game seriously.
How soon will everyone start to use the term "hyw"
only Chinese
I am veryamazed by this contest.
those who tested
As a tester I can confirm that:
1: There are no ‘f’s in conqueror_of_tourist
2: twosquares is a subset of threesquares
3: I will steal YuukiS ’s profile picture for a week after me reaching red
4: One cannot heal with Auchenai01 Soulpriest on the board.
As a writer I regret to inform you that there might be an 'f' in conqueror_of_tourist.
How many ‘r’s are there in strawberry?
The word "strawberry" contains a total of two r's. The first "r" is in the middle of the word, between the "a" and the "b." The second "r" appears right after the "b." So, in total, there are two occurrences of the letter "r."
Notice how you counted 2 r's. But you failed to count the secret one. There is a hidden 'r' in 'b', for a total of 3 r's.
In fact there is another 'r' upside down in 'b', so for a total of 4 'r's.
There is also a backwards 'r' in 'a'...
Please onboard next possible ship to MARS
manbooooo
As a replier, I replied.
Zero of course. Dudes in the comments must be trippin, I ate strawberries a lot of times in my life never seen no 'r's, now 'e's, no 'z's in them dudes, relax.
Today's date (12/25/2025) can be made out of two squares: 1225 and 2025. It can also be made out of three squares: 1, 225, and 2025.
you're a square
Intellegent is a square.
we are all square
As a tester, I would like to ask when the pizza is coming
After I'm done with my run
As a tester, I can confirm that:
All of the writers are from UIUC
UIUC is the best university
If you disagree, you will get negative delta from the round
As a non-UIUC student, I'd like to thank aggrovector for giving me this tour of UIUC. After visiting these locations, especially boneyard creek, I was convinced that UIUC is indeed the best university.
I disagree !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Ggs
Agreed got my BS in CS from UIUC!
Wow, it's Frieren! Now I have to join in!
I hope to become a Candidate Master.
Wish everyone can get positive delta from the round!
I must inform you that $$$\text{you}\in \text{everyone}$$$...
I'm very sorry, now I fix it :(
Oh sry I am Chinese and I'm not good at English grammar, so I copy this sentence from others, but I forget to change the '-' to '+', now I change it, sorry for everyone see it!
You are 1800+, but profile is green instead of blue. Is that a glitch??
https://codeforces.me/blog/entry/149542
it's a feature special to new year
Wow!! Thats interesting. Thanks for responding
My goat twosquares
As purple tester, I can confirm the contest is not purple.
as a purple tester, I can confirm that I am purple.
Gonna reach IM after this contest!
(Meanwhile checking my /settings/magic)
I'm gonna reach LGM
Tested
2025 end so fast
As a tester, I'm not occupied by Chemistry homework unlike last time.
I'm always your fan Mr Z!!
Wherefore must we make haste to garner wisdom, for Time, that swift-footed traveler, doth leave us in his wake. The world’s dominion shall belong to those who, having sought a paradise of dreams and found it not, did straightway fashion it with their own hands.
orz YuukiS
Frieren never disappoints
Let's see if that changes today
How are the testers for gray/green/cyan/blue chosen, and what are their responsibilities? I'd like to help out sometime if it's possible but I'm entirely unaware of the system
Lol, they have changed their ranks as it is New Year! Magic!
R u sure??
We primarily asked people we personally knew. Testers solve the problems and provide feedback on quality and difficulty.
I am reaching rating 1200
I hope this one will be better than the 2023 goodbye
Hoping so.
Time passes so fast .... finally year came to an end
Merry Christmas!!!
Merry Christmas everyone!
Hellooooo Make mine id as Friend
ummm.... idk if i'll enjoy problems or problems will enjoy me....
This is the last CF contest because the world is ending in 2026.
will the problems be sorted?
Yes, in the sense that we ordered the problems based on how hard we think the problems are. However, difficulty is subjective so it is not necessarily true that the problems will be sorted by how hard you find them.
This will be interesting and challenging.....
is it rated as div2 or div1?
It is a Div. 1 + Div. 2 (so rated for everyone).
Hope to get a positive delta in this round!!
I took part in Hello 2025, and now I’m heading into Good Bye 2025. Time really flies. Hoping to enjoy the very last contest of the year and make it a good one. Merry Christmas, everyone
April 2025 — I wrote my first Codeforces submission. End of 2025 — I’m still here. Still solving. Still learning.****
Solved 2 previous year , maybe will get +ve this year , happy new year everyone and hope you guys enjoy the eve well ^_^
One more great year passed with codeforces with so many contests and so much learning...
When you live for 1000+ years, you eventually become Santa. Is that you, Frieren?
Wanna end this worst year with this good contest :)
HOPEFULLY!(
The e-mail about this round contained a wrong date. It said January 4th instead of December 27th
Yeah, it seems someone from CF made a mistake :(
January 4th 2025 duh. Hope you're looking forward to that date.
there are EMAILS about rounds???
Is it rated
Maybe we can still encounter in the next year!
[deleted]
[deleted]
use the "edit" function, and replace your comments with "[deleted]" or something else.
HAPPY NEW year who can give to me 5 dollars or 5$
Happy New Year!
This isn't Hello 2026
Yes, but you will see it in GoodBye 2025 :)
I am a beginner ...should i register in this contest ?? Are there any easy questions??
Good Bye 2025,This is the first year I'm truly planning to compete.
As not an is-it-rated-er, isn't it rated?
I hope everyone becomes LGM after this round
What's wrong with the color and rating? 1400 rated profiles are shown in red. Highest rated user @kevin114514 is shown in cyan. I'm seeing too many anomalies across multiple profiles. Anyone else facing this issue?
nah bro you're imagining things
Ohh just found out about magic tab. lol.
wdym? what's a magic tab? Is it some new data structure?
nah bro you're imagining things
nah bro you're imagining things
nah bro you're imagining things
I hope that I can solve 5 problems and get MORE and MORE ratings!
Hmmm
"Goodbye, 2025! Oh, wait, one more round... Ok, bye-bye!"
;)
what's nutella testing?
UPD: Oh LGM's handle color is the same as nutella's.
Hope all of us could work out one more question! Marry Christmas!
I hope to reach pupil today !
hope to solve 3 problem
The queue is slow again for me today :(
IN QUEUEE!!!
In queue ... after 20 minutes ... Gift labels got mixed up for delivery 2
But problem was good!
This is some CRAZY queueing :(
__baozii__ comes again!!
3 hours for contest with no subtasks feels too much
Yes obv 10k people solved Problem C during contest. Nice joke.
yeah , i dont even know like how u progress with it like 0 idea thats not n^2 dp , how are people doing this shit :[
Call operation 1 as taking the first element and operation 2 as taking the second element from the current array
Let $$$a_i$$$ be the remaining element.
We can prove that the maximum cost required to remove elements before $$$a_i$$$ is equal to:
$$$a_0 + \sum_{j=1}^{i-1} abs(a_j)$$$
Consider 3 elements $$$a_0, a_1, a_2$$$. Since $$$a_0$$$ is the first element, we must add $$$a_0$$$ into the result. For $$$a_1$$$ and $$$a_2$$$, you can either add it into the cost or subtract it from the cost.
$$$+a_1$$$: Perform operation 1 twice
$$$-a_1$$$: Perform operation 2 twice
$$$+a_2$$$: delete first 2 (using 1 of the 2 methods above) then perform operation 1
$$$-a_2$$$: Perform either operation, then perform the operation 2
We can also calculate the required cost to remove elements after $$$a_i$$$, which is:
$$$\sum_{i+1}^{n} -a_i$$$
After removing all elements before $$$a_i$$$, the remaining array is $$$[a_i, a_{i+1}, ..., a_n]$$$. Since we fixed $$$a_i$$$ as our last spot, we can only perform operation 2, making the cost required equal to the above.
Both of these can be preprocessed in $$$O(n)$$$ time. For every $$$i$$$, fix $$$a_i$$$ as the remaining element and calculate maximum cost over all $$$i$$$
so ultimately you are not taking exactly 1 element , lets suppose you didn't take the element i , then this element will always be at the first place and any element after it will be at the second place so they will contribute to X as — (w[i + 1] + w[i+2] .. ) , now any element before i can be taken in both positive as well as negative forms except the first element as it is bound to be at the first place , hence this part contributes w[0] + abs(w[1]) + abs(w[2]) .. abs(w[i-1]).
So, basically we iterate over all the indices and take the maximum answer using the above logic
I also thought of dp , but then i realised the constraints are high also there are too many submissions to it :)
D solved 3500+??!!! what did i miss?
same. how to approach D?
For $$$m \gt 0$$$, if $$$m \gt n/2$$$ it's impossible (each attack kills at least one elf, and calms at most $$$2$$$ (the attacking one and, if they died, the defender). Otherwise, you can sort the elves, let $$$n-2*m$$$ weakest elves attack the next stronger one (and die in the process), the split the remaining $$$2*m$$$ into pairs and let the stronger one attack the weaker one. For $$$m=0$$$, if the sum of all elves except for the strongest is less than the health of the strongest, it's impossible (they can't die), otherwise let $$$k$$$ weakest elves attack the next stronger one and die, and let all other elves except for the strongest one attack the strongest one and die, where $$$k$$$ is chosen in such a way that the last attck kills the strongest elf.
Ok, I see. Thanks, and happy New Year!
who else figured out the rest of the solution but couldn't figure out the case when m = 0
but how do we ensure that the last attack kills both the elves, which would only happen if h[i] = h[j]
for example for n = 3, m = 0 h = a = 5, 6, 10
correct solutions provide the answer:
2 1 3 2 3
but doesn't the second elf survive with 1 health here?
Attack does not reduce with health
omg bruhhhh, thank you so muchh!
ChatGPT
Good problems, bad queues.
submit and pray forces
"Good Bye Rating" ahh contest, for me, couldn't solve D :(. Either way, nice contest!
Can somebody explain the test 7 output in problem D please ;-; I was stuck there for like 2 hours Why would it be like that? After all the operation all a isnt 0?
Attention: $$$h_i$$$ may decrease but $$$a_i$$$ will never change.
Hope this could be clear.
Did anyone that got WA test 4 for E figure out what their bug was?
D>>E
too true
Can someone explain idea for D? Looked like a graph problem
Try to get yourself in a position where after sorting, the number of that should be alive are half the total remaining. So you can just attack the first half with the second
sort elves by health (!note that health is unique)
if m > 0, preserve the m elves with most health, make them kill the smaller ones, and the smaller ones kill the even smaller ones.
if m = 0, make the smallest ones attack on the biggest elf but one step from killing it, then from that step make the rest elves kill the one that is to the left of it.
also you need to handle the cases when impossible. either 2*m > n or m = 0 and all the n-1 elves combined can't kill the biggest one
See this comment.
No way, i submitted D 3 seconds before the contest ended, it shows contest is over !!
There was a typo in my previous code.
I had 2 typos in my D code, first one caught immediately after submitting,
thankfully wa on test 1,
second one didn't know it until long ass queue told me wa on test 2
editorial page isn't working!!!,btw nice problemset,thanks for the contest!
upd:it's working now!!!
Just gave the contest, was really happy for solving D. Pheww, might be the toughest one I gave till now ( a personal opinion from my side alone)
Now I only wonder how you managed to find such five extremely special examples of answers in F.
Btw the magic is real. I will really drop to my current color lol.
G is impossible to solve :( Nice problemset btw
GG guys, good contest, happy new year everyone! I wish I had more time for Codeforces, but life and work carried me away.
A very nice contest to end the year (though technically not the last) Problem D was nice and too hard for me to solve :)
I've spent 2.5 hours on C. Had zero previous DP experience (did not yet get to the theme), and wasted time scanning through the manuals (I genuinely thought it must be one). Fun fact: if I had prevous DP experience, I would have easily noticed that it is NOT DP at all, it is a tricky constructive.
After all it was like an hour trying to set all the prefix-suffix indices to work properly, which turned out to be quite a challenge. Very happy to get a working solution in the end.
yeah exact same thought process, but couldn't get the code running till end. But it has nearly 10k submissions. like that ques was not this straight forward.
Well, the cheaters rate in the last year has skyrocketed. Or (maybe) a lot of new skilled people joined. Which one, I guess...
I just tried using LLM to solve C (certainly after contest). It almost gave me the correct answer... So I think many people that solved C may be cheaters?
I am still waiting for someone to research, what is the rating where free LLMs start making errors in solutions.
yes highly likely.
Some submissions had implemented it using Dynamic Programming too. I noted in a few on the top of standings, for example: Kevin114514, Radewoosh.
That's for skilled ones. And I'm gray.
The queue was kinda bad. At this rate, we might as well remove pretests altogether and only have systests.
in D, why is recoil considered an attack?
intuitively, i thought the attacks are like directed
x attacks y doesnt mean y attacks x is what i thought
its like u punched a wall and got hurt so u tell everyone the wall hit u
edit: mb gng, im dumb af
I have been thinking about randomization in E for over an hour,but the solution is correct in any case.The solution was amazing but perhaps the disablement of hacks and the non-adaption of the interactive problem is more likely to make participants not think about that.
I came up with random too and got WA on test 4=)))
in queue... after 20 minutes tell me that there is a compilation error!!
lol
That's why you should run it yourself before submitting
Rate up!
What a bad night! I got WA 6 times for D and E, which means 12 WA in total, even though I came up with the correct solution for D. I got so many bugs=(((( But after all, this was an excelent contest. Thanks a lot to writers and testers.
Very good problems, thank you! Enjoyed thinking over D and E. Round was very balanced.
10k solves on C -_-
Edit: great contest though! Thank you to the authors
sus comments javabidov please take a look at his comment block on top YuukiS twosquares his submission 355400798
I went through a lot of peoples solutions (in java) to try to understand how to do B and C, but had that same reaction bc their solutions just looked like llm solutions.
Read my b solution
How to solve E? I get WA on test 3, when I use binary search for it. I compared sum of l to m divide m+1-l and sum from m to r divide r-m.
I did the same and found the flaw, let's say 8 8 8 8 8 gives the same sum of 8 8 16 4 4... it's no good for this approach
damn i wonder what the solution to this problem might look like
You are SUS
Great contest with good quality problems. First time solved 6 problems in div1 + div2 round, a perfect goodbye.
Good bye 2025! First year doing codeforces and many more years to practice to come. Happy holidays and a good 2026 to everyone.
C was really good
Guys, there are 2 C# submissions that won't judge
should've paid the codeforces subscription on time
Why do the judging system stuck with these two C# submissions?
Good Bye C#
I wonder if the C# situation is somehow related to: https://codeforces.me/blog/entry/148770
This is probably the best round I've ever participated in. I enjoyed solving the problems, especially upsolving G.
the problem E is awesome!so interesting,i like it.