You can use several words in query to find by all of them at the same time. In addition, if you are lucky search understands word forms and some synonyms. It supports search by title and author. Examples:

  • 305 — search for 305, most probably it will find blogs about the Round 305
  • andrew stankevich contests — search for words "andrew", "stankevich" and "contests" at the same time
  • user:mikemirzayanov title:testlib — search containing "testlib" in title by MikeMirzayanov
  • "vk cup" — use quotes to find phrase as is
  • title:educational — search in title

Results

1.
By MikeMirzayanov, history, 2 years ago, In English
Rule Restricting the Use of AI [revision 2024-09-14] It seems that neural networks are working technological wonders. Not long ago, they struggled with even the simplest tasks in our competitions, but now they are reaching new heights that cannot be overlooked. There is reason to believe that progress will continue, and we can expect further advancements in neural networks within the realm of programming competitions. For this reason, we are explicitly limiting the use of AI-based systems (such as various models like GPT, Gemini, Gemma, Llama, Claude, and others) for solving programming problems. However, we recognize that AI can be a valuable tool for learning and coding assistance, so we aim to establish clear boundaries for its use. **Application of this Rule:**<br/>This rule applies strictly to in-contest participation. This includes both registered contestants and out-of-competition participants in any rated Codeforces round. If a round is unrated and this is explicitly stated in the round announcement or rules, the rul...
non-competitive problem-solving. **Permitted AI Use:** * **Translation of Problem Statements, * **Translation of Problem Statements:** You may use AI-based systems to translateproblem

Full text and comments »

  • Vote: I like it
  • +2558
  • Vote: I do not like it

2.
By MikeMirzayanov, 8 years ago, translation, In English
Hello, ITMO! <img src="https://assets.codeforces.com/images/itmo-logo.png" style="margin:1em 1em 1em 1em; float:right;"/> Hi Codeforces! For you, perhaps it was yet another Codeforces round. But not for me. [contest:1066] is the first round tested on new judging servers at ITMO University. And this is not just an update of location. Ta-dam! Now your solutions will be judged on the new Intel i3-8100 processors. And this is not all news. The number of judging servers has increased, which means fewer queues during rounds! I am pleased to announce that now I live in St. Petersburg, I work at ITMO, and Codeforces is gradually moving from the walls of dear to me Saratov University to ITMO University. The decision to move was not easy for me. My plan is that, based on ITMO, I can focus more on Codeforces development and work on the platform. The number of world champions per square meter is simply overwhelming, and working with a large team of such enthusiasts (and professionals!) of sports pro...
performance of a single core is not very different from the one that the old generation of judging, -8100 processors. Fortunately, the performance of a single core is not very different from the one

Full text and comments »

  • Vote: I like it
  • +1331
  • Vote: I do not like it

3.
By dario2994, 6 years ago, In English
Editorial of Global Round 11 #### General comments Broadly speaking, problems A-B-C-D were "div2 problems", while F-G-H were "strong grandmaster problems" (with E staying in the middle). I did not expect anyone to solve all the problems and thus I decided to give the scoring F+G=H (so that maybe someone would have solved H). <br><br> Many of the problems (A, C, D, E, G) admit multiple solutions. Sometimes the core of the solution is the same (C, D) and sometimes the solutions are truly different (A, E, G). <br><br> If you are an experienced participant, I would like to hear your opinion on the problems. Feel free to comment on this post or send me a private message. <br><br> <spoiler summary="Overview of the problemset" > The easiest problem of the contest, *A-Avoiding Zero*, is about rearranging an array of numbers. It is intended as a very easy problem that still requires to think. Then, in *B-Chess Cheater* an intuitive (but nontrivial to prove) greedy approach is the way to go. *C-The Hard Work of P...
). Many of the problems (A, C, D, E, G) admit multiple solutions. Sometimes the core of the, Many of the problems (A, C, D, E, G) admit multiple solutions. Sometimes the core of the solution

Full text and comments »

  • Vote: I like it
  • +758
  • Vote: I do not like it

4.
By MikeMirzayanov, 4 years ago, In English
Codeforces Sponsored by TON! <img src="/predownloaded/12/a0/12a02d5f16863f9f45bba4c6cd4224f0f2178b94.png" style="float:right; margin: 0 1em 1em 1em; width: 400px;"/> Hello, Codeforces. We have exciting news! Look at the logo. See the changes? Yes, we are happy to announce our new sponsor and partner – the TON Foundation! We appreciate their support! The Open Network (TON) is a fully decentralized layer-1 blockchain designed by Telegram to onboard billions of users. The TON Foundation is aimed to further develop and advance the TON Blockchain and its related products for a mass audience. Andrew Rogozov, founding member at the TON Foundation, says, "<i>We strongly believe in the idea of competitive programming itself, because it is in the TON Blockchain DNA.</i>" The TON Blockchain protocol was designed by Nikolai Durov — who is a two-time ICPC world champion, a three-time IMO gold medalist, a multiple IOI medalist, and a co-founder of Telegram — and other winners of international competitions...
competitions. Now the TON Blockchain core team consists of winners of blockchain contests held by Telegram

Full text and comments »

  • Vote: I like it
  • +1188
  • Vote: I do not like it

5.
By MikeMirzayanov, 8 years ago, In English
Codeforces Global Rounds Hello! It is always satisfying and important for me when former contest participants offer their help to the community and support the development of programming competitions. And now I am in a hurry to share the news that thanks to the support of <a href="https://www.xtxmarkets.com/">XTX Markets</a> and the personal participation of Yuri Bedny and Alexander Gerko, we are launching a new line of Codeforces Global Rounds. Hooray! <img src="/predownloaded/2e/e2/2ee2f0f95f05aae6ca6f47812dae2dc2aabf277b.png" style="width:200px; float:right; margin: 0 1em 1em 1em"/> Like many of you, I had never heard of <a href="https://www.xtxmarkets.com/">XTX Markets</a> before but it is one of the largest quantitative-driven electronic liquidity providers in the world. I understand little about the financial sector, but with their 34,148 cores and 42 petabytes of usable storage in their research cluster, XTX’s rapid growth and strong market share globally speak for themselves. So, in 2019, w...
give T-shirts to all authors and problem testers. I will be very happy for Codeforces to work

Full text and comments »

  • Vote: I like it
  • +1206
  • Vote: I do not like it

6.
By AlexSkidanov, history, 8 years ago, In English
Are we close to machines solving ICPC problems? Hi, all, I with few other folks at [NEAR](http://near.ai/blog) work on teaching machines to program. A particularly exciting sub-project of that is teaching machines to solve competitive programming problems. In this post I would like to give a quick overview of where the state of the art is today, what the major challenges are, why this is not a popular area of research, and how the CodeForces community can help to address some of the issues the program synthesis community is facing today. We also have a certain budged allocated for this project, and we are paying to the CodeForces members who help us with some data annotation challenges. We have paid more than $10k in our first two annotation projects, and are launching three more projects today. Scroll to the end if you are interested. Competitive programming as a benchmark ====================================== With the emergence of deep learning, neural networks started performing almost at a human level in many ta...
. 2. No context besides the problem statement is needed to write it. 3. The dataset of statements, At the core of our approaches are deep learning models that read in text and produce code as either

Full text and comments »

  • Vote: I like it
  • +336
  • Vote: I do not like it

7.
By AkiLotus, history, 8 years ago, In English
Codeforces Round #554 (Div. 2) Once again, **TREMBLE BEFORE THE MIGHTY OMEGALULRIPGRAPE.** ![ ](https://i.imgur.com/kpS7NEq.png) ![ ](https://i.imgur.com/A2dF7M2.jpg) *(He last walked the Earth in round [538](https://codeforces.me/blog/entry/65033) btw.)* Hello Codeforces! We are here to invite you to Codeforces Round #554 (Div. 2), which will take place at [contest_time:1152]. The round will be rated for all Division 2 participants **(with rating less than 2100)**, yet any Division 1 participants are welcome to join us out of competition. The round will be cat themed. Raise your paws and prepare your catnips! *(Or even cat memes, while you're at it).* You will be given **6+1** problems ( **6** problems, one of them has **2** subtasks ) to solve in **2 hours.** The round's problems were prepared by Xuan-Quang ~xuanquang1999,2019-04-23 D. Nguyen, Duy-Bach ~Akikaze,2019-04-23 Le, Stefan ~stefdasca,2019-04-23 Dascalescu, Quang-Minh ~MofK,2019-04-23 D. Nguyen and our dear Codeforces coordinator ...
Dmitry ~_kun_,2019-04-23 Sayutin. *Gladly (or sadly), no interactive problem tonight!* Also, - Andrew ~GreenGrape,2019-04-23 Rayskiy for various problem suggestions **and the infamous

Full text and comments »

  • Vote: I like it
  • +436
  • Vote: I do not like it

8.
By adamant, history, 4 years ago, In English
Partitions and pentagonal number theorem Hi everyone! In today's blog I'd like to write about the theorem that allows to efficiently solve the following problems: - What is the number of partitions of a non-negative number $n$ for $n \leq 10^5$? - What is the number of partitions of a non-negative number $n$ for $n \leq 10^5$, so that no summand repeats $d$ or more times? - What is the number of partitions of a non-negative number $n$ for $n \leq 10^5$, so that no summand is divisible by $d$? - **[HackerEarth &mdash; Perfect Permutations](https://www.hackerearth.com/de/problem/algorithm/perfect-permutations-september-clash/)**: What is the number of permutations of length $n$ with $k$ inversions for $k \leq n \leq 10^5$? - **[problem:102354E]**: Let $\phi = \frac{9}{10} \cdot \frac{99}{100} \cdot \frac{999}{1000} \cdot \dots$, what is the $k$-th digit of $\phi$ for $k \leq 10^{18}$? - **[SNSS-2018 Round 5 &mdash; Investment Portfolio](https://contest.yandex.ru/contest/8703/problems/C/)**: You have $2n$ dollars and ...
Permutations](https://www.hackerearth.com/de/problem /algorithm/perfect-permutations-september-clash, The core fact that allows us to solve these problems efficiently is the pentagonal number theorem:

Full text and comments »

  • Vote: I like it
  • +172
  • Vote: I do not like it

9.
By Mindeveloped, history, 22 months ago, In English
[Suggestion] Some Problem Tags Might Need Revamp Problem tags, which are supposed to help people categorize problems, some of them doesn't make much sense and need revamp. For example, take a look at [problem:2057E2]. At the time of this blog, it has tags "binary search" "brute force" "dp" "dsu" "graphs" "shortest paths" "sortings". Some of them doesn't make much sense to me. "dsu" "graphs" "shortest paths" are fine imo. They either describe the core idea or the main techniques the problem use. Then "dp" might be a bit controversial, it is probably about the fact that the modified Floyd algorithm is based on DP. It could be reasonable, especially if you didn't recognize that you are using Floyd algorithm when adding edges dynamically. The editorial also agrees with this idea. This trick seems rather classical to me. I don't think this is a big problem. However the rest of them does not make much sense imo. For "binary search", I guess it's about the binary search approach for E1. That is too slow and cannot pass E2. And f...
[Suggestion] Some Problem Tags Might Need Revamp, describe the core idea or the main techniques the problem use. Then "dp" might be a bit controversial, "dsu" "graphs" "shortest paths" are fine imo. They either describe the core idea or the main

Full text and comments »

  • Vote: I like it
  • +101
  • Vote: I do not like it

10.
By dmkozyrev, history, 3 years ago, In English
[Tutorial] Quick start in solving problems on GPU + CPU Hello, codeforces! Do you have modern GPU and CPU and want to calculate something with them, but you don't know how to do it? Dont be upset, because you can read this blog and run your first GPU program on your AMD/Intel/NVIDIA GPU. I will describe an installation process and then we will dive into the C++ code. As an example, we will calculate a lot of mazes for [Bug Game](https://codeforces.me/blog/entry/115144) in parallel. For doing this in simple way, we will use library [Boost.Compute](https://www.boost.org/doc/libs/1_80_0/libs/compute/doc/html/index.html), which is a C++ STL-style wrapper over OpenCL library. [cut] ... Installation for MacOS (Apple M1 Pro) ================== As [user:Gosunov,2023-06-10] said, `OpenCL` and `g++` are pre-installed on `MacOS`. Everything that you have to do is install `Boost` with command `brew install boost`. After this you will be able to compile your program with command `g++ -std=c++17 -O3 -I/opt/homebrew/Cellar/boost/1.81.0_1/...
`Search: gcc` and select next packages: - colorgcc - gcc-core - gcc-g++ - libgcc1, - colorgcc - gcc-core - gcc-g++ - libgcc1

Full text and comments »

  • Vote: I like it
  • +118
  • Vote: I do not like it

11.
By brunovsky, 5 years ago, In English
[Tutorial] Network simplex Hello! If you've learned the simplex algorithm and a minimum cost flow algorithm, perhaps you've also heard about this fancy thing called [network simplex](https://en.wikipedia.org/wiki/Network_simplex_algorithm) which is supposed to be a specialization/optimization of the simplex algorithm for computing a [minimum cost circulation](https://en.wikipedia.org/wiki/Minimum-cost_flow_problem). If your google search didn't turn up any interesting results or your interest faded, you might have moved on to other subjects. Well I didn't! So this is a tutorial on network simplex (NS) for the **minimum cost circulation** problem. I'll describe and formulate the problem, show how it relates to the usual minimum cost flow problem, explain the theory behind the algorithm in-depth, and then derive the implementation details. ## Introduction The algorithm commonly used in competitive programming for this sort of task is a minimum cost flow algorithm based on finding augmenting paths in a *f...
**minimum cost circulation** problem. I'll describe and formulate the problem, show how it relates to, algorithm cannot handle negative cost cycles since its core algorithm is Dijkstra, and in many cases

Full text and comments »

  • Vote: I like it
  • +493
  • Vote: I do not like it

12.
By __baozii__, 9 months ago, In English
Codeforces Round 1077 (Div. 1, Div. 2) Editorial We hope you enjoyed the problems! <spoiler summary="Rate the contest!"> <spoiler summary="Quality"> - Excellent contest - Good contest - Average contest - Bad contest - Horrible contest </spoiler> <spoiler summary="Difficulty"> - Trivial contest - Easy contest - Average contest - Hard contest - Impossible contest </spoiler> </spoiler> [problem:2188A] - Idea: [user:__baozii__,2026-01-29], [user:Tobo,2026-01-29] - Solution: [user:__baozii__,2026-01-29] - Editorial: [user:__baozii__,2026-01-29] <spoiler summary="Solution"> For $|p_{n-1}-p_n|$ to be divisible by $n-1$, either $p_{n-1}=1$ and $p_n=n$, or $p_{n-1}=n$ and $p_n=1$. Either way, we can construct $p$ backwards. For $i$ from $n-2$ to $1$, there will only by one possible choice for $p_i$, where $...
:22,option5] Impossible contest [problem:2188A] - Idea: [user, To solve this problem using a divide-and-conquer approach, we define a recursive function that

Full text and comments »

  • Vote: I like it
  • +89
  • Vote: I do not like it

13.
By Bahamin, history, 15 months ago, In English
Atto Round 1 (Codeforces Round 1041, Div. 1 + Div. 2) Editorial ### ✨ **Hope you enjoyed the problems!** ✨ <span style="font-size: 20px;">[problem:2127A]</span><br> **Idea:** [user:Bahamin,2025-08-04]<br> **Preparation:** [user:Hamed_Ghaffari,2025-08-04] <spoiler summary="Hints"> <spoiler summary="Hint 1"> What happens if $\operatorname{mex}([a_i, a_{i+1}, a_{i+2}]) = 0$? </spoiler> <spoiler summary="Hint 2"> Now what happens if $\operatorname{mex}([a_i, a_{i+1}, a_{i+2}]) \neq 0$? </spoiler> </spoiler> <spoiler summary="Solution"> Let's see when does $\operatorname{mex}([a_i, a_{i+1}, a_{i+2}])$ equal $\max([a_i, a_{i+1}, a_{i+2}]) - \min([a_i, a_{i+1}, a_{i+2}])$. **Case 1:** $\operatorname{mex}([a_i, a_{i+1}, a_{i+2}]) = 0$ This implies that all numbers are equal and non-zero, since otherwise $\min$ would be less than $\max$ and the difference wouldn't be $0$. **Case 2:** $\operatorname{mex}([a_i, a_{i+1}, a_{i+2}]) \neq 0$ In this case $\min([a_i, a_{i+1}, a_{i+2}])$ should be $0$ because $0$ is in the seque...
solutions to this problem, but they use a similar core idea., problem, but they use a similar core idea. The **virtual tree** of a set of vertices like $S$ is

Full text and comments »

  • Vote: I like it
  • +243
  • Vote: I do not like it

14.
By NemanjaSo2005, 22 months ago, In English
I Reached GM! Hello, codeforces community, After the last round of 2024, [contest: 2053], I finally reached Grandmaster (GM)—an achievement I had dreamed of ever since I became a Master 2 years ago, but doubted I could achieve. In Spring 2024 I set myself a goal to reach GM before the end of 2024, which felt ambitious and even unrealistic at times. But here I am, thrilled to share that I have accomplished my goal! Some of you have noticed that upon reaching 2400 rating I used magic to change my rank to CM. Why? For two reasons: first, I quite like the CM color. Perhaps it is because CM seemed like such a cool rank when I started. Second, I wanted to give myself more time to write this blog, so I hope you will enjoy it! While some of you might know me, I assume most are seeing my name for the first time. Allow me to introduce myself briefly. I am a 19-year-old Serbian competitive programmer who has been doing CP for around 8 years now. My journey is filled with many highs and lows &mdash; ma...
most of the problem difficulty comes from the core ideas of the problem, not from knowing some crazy, nowadays are usually such that most of the problem difficulty comes from the core ideas of the problem, not

Full text and comments »

  • Vote: I like it
  • +234
  • Vote: I do not like it

15.
By chromate00, 13 months ago, In English
Codeforces Round 1058 Editorial Thanks for the participation! We hope you enjoyed the contest. <spoiler summary="Rate the contest!"> - Epic - Good - Moderate - Bad - Horrendous </spoiler> <strike>The solution codes will be added shortly after the system tests are finished.</strike> They have been added. [problem:2160A] Problem Credit: [user:Proof_by_QED,2025-10-12] <spoiler summary="Rate the problem!"> - Epic - Good - Moderate - Bad - Horrendous </spoiler> <spoiler summary="Solution"> First, let $m=\operatorname{mex}(A)$. We can ignore all elements that are greater than $m$. This is because since $m$ is the mex, $m$ does not appear in $A$, and consequently it also cannot appear in any of the partitions. Thus, which of the partitions each element goes to does not matter. Now, let's consider the n...
For this problem there exist two versions of a core observation, shortly after the system tests are finished. They have been added. [problem :2160A

Full text and comments »

  • Vote: I like it
  • +68
  • Vote: I do not like it

16.
By box, history, 6 years ago, In English
[Tutorial] Generalized Chirp Z-Transform <s>My last blog was a bit too esoteric</s> This blog assumes that you can do a basic convolution (e.g. FFT). After I saw that many people did not know how to do Chirp Z-Transform with arbitrary exponents fast from [my blog 9 weeks ago](https://codeforces.me/blog/entry/82165) I decided to <s>shitpost</s> write a short tutorial on it. Let's say we have a polynomial $P(x)$, such that $$\begin{align}P(x)=\sum_{i=0}^{n-1}a_ix^i\end{align}$$ Now, let's say we have $c$ and $m$, and we want to find $P(c^0),P(c^1),P(c^2),\dots,P(c^m)$. Let $b_j=P(c^j)$. Consider the implications of having $x$ as such a form: $$\begin{align}b_j=\sum_{i=0}^{n-1}a_ic^{ij}\end{align}$$ Tinkering around with different expressions for $ij$, one finds that $ij=\frac{(i+j)^2}{2}-\frac{i^2}{2}-\frac{j^2}{2}$. This means that $$\begin{align}b_j=\sum_{i=0}^{n-1}a_ic^{\frac{(i+j)^2}{2}-\frac{i^2}{2}-\frac{j^2}{2}}\end{align}$$ $$\begin{align}b_jc^{\frac{j^2}{2}}=\sum_{i=0}^{n-1}(a_ic^{-\frac{i^2}{2...
This method can be used to cheese [problem:1184A3] and [problem:1054H], and is also acore point in, ], and is also a core point in [problem:901E].

Full text and comments »

  • Vote: I like it
  • +146
  • Vote: I do not like it

17.
By ssvb, 5 years ago, In English
$O(N^2)$ solution to Facebook Hacker Cup 2021 Round 1 problem A2 (part one) Right after the end of Facebook Hacker Cup 2021 Round 1, [user:wjomlex,2021-09-25] posted the following [comment](https://codeforces.me/blog/entry/94726?#comment-839269) in the discussion section under the announcement blog: > A common issue was people writing O(N^2) solutions to problem A when O(N) solutions are necessary. You won't be able to run an O(N^2) solution in 6 minutes when N = 800,000. But is this really true? Challenge accepted! ##### Problem A1 <div> <spoiler summary="Spoiler"> First of all, here is an $O(N)$ solution for [problem A1](https://www.facebook.com/codingcompetitions/hacker-cup/2021/round-1/problems/A1): <spoiler summary="Spoiler"> ~~~~~ #include <iostream> #include <vector> #include <stdint.h> using namespace std; /* * This is a solution for problem A1. Time complexity: O(N) * Characters in the input buffer are remapped: 'F' => 0, 'X' => 1, 'O' => 2 */ static int32_t solve_a1(const int8_t *arr, int n) { int32_t ans = 0, h...
$O(N^2)$ solution to Facebook Hacker Cup 2021 Round 1 problem A2 (part one), data even on my desktop computer with a quad-core Intel Core i7-860 processor @2.8GHz:, single thread of an Intel Core i7-860 processor in less than 6 minutes by a vectorized $O(N^2, under the announcement blog: > A common issue was people writing O(N^2) solutions toproblem A when, v0desktop computerquad-core Intel Core i7-860 @2.8GHz28m13.998s

Full text and comments »

  • Vote: I like it
  • +203
  • Vote: I do not like it

18.
By ACGN, history, 2 years ago, In English
About 2031C (Penchick and BBQ Buns, problem C of CF Round 987), and extra challenges Author of the problem [problem:2031C] here, hope you enjoyed the contest yesterday (Almost exactly 24 hours ago...)! Looking at the votes on [the editorial](https://codeforces.me/blog/entry/136260), it's obvious that it's a very polarizing problem: an hour or so after the contest, the problem had roughly equal numbers of "likes" and "dislikes", and now (as of writing) there are around 320 likes to 200 dislikes. Of course, this is completely predictable: the opinions on this problem were quite polarized for a few reasons: 1. Troll and WA trap: it's **very** easy to fall into the trap of thinking that there is no solution for all odd $n$; thus, **over 12,900** (!) WA on pretest 2 solutions were received, as compared to only 4,700ish Accepted solutions. This ratio seems a bit extreme for a problem C; in the previous Div.2's problem C ([problem:2028C]), there were 3,500ish Rejected solutions to 2,500ish Accepted ones. 2. The construction: hard-coding the case $n=27$ seems weird an...
About 2031C (Penchick and BBQ Buns, problem C of CF Round 987), and extra challenges, Author of the problem [problem:2031C] here, hope you enjoyed the contest yesterday (Almost exactly, But this is a core part of the competition process; you're gonna get trolled.

Full text and comments »

  • Vote: I like it
  • +103
  • Vote: I do not like it

19.
By drdilyor, history, 3 years ago, In English
LAZY solution to problem D in Codeton round 8 + PYTHON solution Heyo! If you tried to solve problem D you have probably ended up trying to optimize this algorithm: <spoiler summary="C++ brute force"> ``` // input int n, k; cin >> n >> k; vector arr(n, vector<int>(n)); for (int i = 0; i < n;i++) for (int j = i; j < n; j++) cin >> arr[i][j]; vector dp(n+2, vector<int>()); dp[n] = dp[n+1] = {0}; for (int i = n-1; i >= 0; i--) { vector<int> cur; for (int j = i-1; j < n; j++) { // prepare to merge by adding a[i][j] vector<int> tomerge = dp[j+2]; if (j >= i) { for (int& x : tomerge) x += arr[i][j]; } vector<int> merged; merge(cur.begin(), cur.end(), tomerge.begin(), tomerge.end(), back_inserter(merged), greater()); cur = merged; } dp[i] = cur; } // output top k values ...
LAZY solution to problem D in Codeton round 8 + PYTHON solution, Heyo! If you tried to solve problem D you have probably ended up trying to optimize this algorithm, Now to rewrite the core of the algorithm above (it's possible to do this without recursion but it's

Full text and comments »

  • Vote: I like it
  • +142
  • Vote: I do not like it

20.
By choice, history, 10 years ago, In English
Lagrange Multipliers for "Core Training" (Code Jam 2017, Round 1C) I found the following derivation using Lagrange multipliers for the solution of the [Core Training](https://code.google.com/codejam/contest/3274486/dashboard#s=p2&a=2) problem in Code Jam this year. I liked this approach particularly because I don't get to use Lagrange multipliers very often in programming competitions. Let $ \mathbf{p^0} = (p^0_1, p^0_2, \ldots, p^0_n) $ denote the initial vector of success probabilities that we are given, and let $ \mathbf{p} = (p_1, p_2, \ldots, p_n) $ be an arbitrary vector of success probabilities. Let $ S(i, \mathbf{p}) $ denote the probability of exactly $ i $ cores succeeding given the success probabilities in $ \mathbf{p} $. Then we are trying to maximise $$ f(\mathbf{p}) = \sum_{i \geq K} S(i, \mathbf{p}) $$ subject to $$ g(\mathbf{p}) = \sum_{i} p_i = u + \sum_{i} p^0_i $$ By using the Lagrangian method, we get that an optimal solution must satisfy $$ \nabla_{\mathbf{p}} f(\mathbf{p}) = \lambda \cdot \nabla_{\mathbf{p}} \left(\su...
Lagrange Multipliers for "Core Training" (Code Jam 2017, Round 1C), I found the following derivation using Lagrange multipliers for the solution of the [Core Training

Full text and comments »

  • Vote: I like it
  • +111
  • Vote: I do not like it

21.
By enratingion, history, 5 months ago, In English
Using Genetic Algorithm to solve CP problems <p>Hello everyone,</p> <p>Recently, I was reading about Genetic Algorithms (GA) used in AI training. It sparked an interesting thought: could we apply this concept to Competitive Programming to fish for an AC? I decided to put this to the test on a classic problem: <strong>CSES – Elevator Rides</strong>.</p> <blockquote> <strong>Problem Summary:</strong> There are <strong>n</strong> people who want to get to the top of a building using a single elevator. You are given the weight of each person and the maximum weight capacity of the elevator. What is the minimum number of elevator rides required? (<strong>n &lt;= 16</strong>). </blockquote> <p>With <strong>n &lt;= 16</strong>, this is obviously a standard Bitmask DP problem. However, just for the sake of experimentation, I decided to solve it using a Genetic Algorithm.</p> <h2>The Core Idea: Permutations as Individuals</h2> <p>Initially, we have <strong>n</strong> people, where the <strong>i</strong>-th person has a w...
The Core Idea: Permutations as Individuals , fish for an AC? I decided to put this to the test on a classic problem: CSES – Elevator Rides

Full text and comments »

  • Vote: I like it
  • +84
  • Vote: I do not like it

22.
By yse, 3 months ago, In English
Codeforces Round 1114 (Div. 3) — Editorial Thank you for participating in the contest! I hope you enjoyed all problems :) Also, thanks to [user:reirugan,2026-08-04] for proofreading the editorial. <spoiler summary="Rating Predictions"> | Predictor | A | B | C1 C2 | D | E | F | G | |----------------------------------|-----|-----|------|------|------|------|------| | [user:yse,2026-08-04] | 800 | 800 | (900 &mdash; 1000) | 1200 | 1400 | 1700 | 2000 | | [user:Wageeh,2026-08-04] | &mdash; | 1000 | (1300 &mdash; 1300) | 1500 | &mdash; | &mdash; | 1900 | | [user:Proof_by_QED,2026-08-04] | 800 | 800 | (1000 &mdash; 1100) | 1300 | 1300 | 1900 | 2100 | | [user:detective...dots,2026-08-04] | 800 | 900 | (1100 &mdash; 1100) | 1300 | 1400 | 1800 | 2100 | | [user:Mr_Bald,2026-08-04] | 800 | 900 | (1100 &mdash; 1200) | 1400 | 1500 | 1800 | &mdash; | | [user:Argentum47,2026-08-04] | 800 | 900 | (1000 &mdash; 1200) | 1300 | 1400 | 1800 | 2000 | </spoiler> <spoiler summary=...
is different, but the set of values is identical. This reveals the core property of theproblem, This reveals the core property of the problem: no matter how many operations you perform, the

Full text and comments »

  • Vote: I like it
  • +94
  • Vote: I do not like it

23.
By Misuki, 3 years ago, In English
An intuitive and standard way to solve 1842G — Tenzing and Random Operations Hello codeforces community! Today I want to share my solution to a counting problem from recent contest: [1842G &mdash; Tenzing and Random Operations](https://codeforces.me/contest/1842/problem/G). But first, why would I write a blog specifically for this problem? Because I found out this solution comprises a lot of common technique in counting problems and basic problem solving skill, which may be served as a wrap up of standard counting technique and idea used in CP, also providing an evidence that you can solve recent CF problems by just mastering the basic problem solving skill and common techniques, even on a 2800* one! And last but not least, provide an alternative solution to the problem :) Now, let get started with the solution itself. [The problem description](https://codeforces.me/contest/1842/problem/G) For people who haven't try it, I recommend you to try it first before opening the spoiler! <spoiler summary="Spoiler"> First, since all sequences of choi...
got fascinated by the solution itself, especially the process of clarifying the core of the problem, $ feel like a "noise" and not related to the core of the problem, also doing suffix add feels a bit, I decide to lift the suffix add constraint first because it feels more related to thecore of the, Since constraints on $a_n$ and $v$ feel like a "noise" and not related to the core of the problem

Full text and comments »

  • Vote: I like it
  • +35
  • Vote: I do not like it

24.
By AkiLotus, history, 3 years ago, In English
Reflection on my past authored problems Hello Codeforces! This is not a round announcement, however. I realize it's around 4 years since my last rated participation, and 3 years since my last problemsetting contribution. I think I have never said a proper goodbye to competitive programming since then. I know, I know, this is not an airport, thus my departure is not mandatory. But after all, this is a free space of my blog entries after all. Besides, today is my 25th cake day, and I just feel nostalgic reflecting everything I have gone through. Thus, rather than just saying farewell, I'd like to, in an absolutely styled late attempt, jump on the [trend](https://codeforces.me/blog/entry/113715) and reflect on the past programming problems that I have authored. My format would be a bit different though. I prefer to write in my own style and convey my thoughts the way I feel comfortable. ;) Okay, first and foremost, I'll only consider those available in official Codeforces rounds. I've done quite a myriad of work...
. | # | Problem | Comments | | - | --------------- | -------- | | 1 | [problem :1114A] | A classic Div2A, Analyzing the core requirements would be enough to solve it, and this is the next part I loved in

Full text and comments »

  • Vote: I like it
  • +105
  • Vote: I do not like it

25.
By SPyofcode, history, 5 years ago, In English
[Variants] An interesting counting problem related to square product ## The statement: Given three integers $n, k, p$, $(1 \leq k \leq n < p)$. Count the number of array $a[]$ of size $k$ that satisfied - $1 \leq a_1 < a_2 < \dots < a_k \leq n$ - $a_i \times a_j$ is perfect square $\forall 1 \leq i < j \leq k$ Since the result can be big, output it under modulo $p$. For convenient, you can assume $p$ is a large constant prime $10^9 + 7$ **Notice that in this blog, we will solve for generalized harder variants** **For original problem you can see in this blog [[Tutorial] An interesting counting problem related to square product](https://codeforces.cc/blog/entry/96379)** --- ## Extra Tasks **These are harder variants, and generalization from the original problem. You can see more detail [here](https://codeforces.cc/blog/entry/96379)** *Marked as solved only if tested with atleast $10^6$ queries **[Solved A](https://codeforces.cc/blog/entry/964...
[Variants] An interesting counting problem related to square product, that in this blog, we will solve for generalized harder variants** **For originalproblem you, Literally what we do up to now just optimize the counting part. The counting, which is thecore is, The core of calculating is to find out the number of non-decreasing integer sequence of size $k

Full text and comments »

  • Vote: I like it
  • +164
  • Vote: I do not like it

26.
By shiny_shine, 18 months ago, In English
Don't care about AIs. Here's why. **TLDR:** AIs give us a lesson. Rating and scoreboards are meaningless. And they tell us, it's time to find the real spirit of "competitive programming". If you want to understand the sentence above, please enter. [cut] Let's make a short description of the state now. Taking the example from the edu round last night. A brave candidate master [user:xiaoxiaobaozi,2025-04-29], which is **definitely not an AI**, successfully beat all the AIs. However, despite this, the top pages of the scoreboard are almost captured by AIs. Randomly choose a submission by top greys/greens/cyans. OH. ENGINEERIC VARIABLE NAMES. Ok. They are AI. But, look at him. [user:Nikhilesh_Kancherla,2025-04-29]. He conquered the contest in 6 minutes. Looks weird. Let's check his code. Hmmmm. Regular code style. Sussy tab distance. With them, you can't identify whether he's an AI or not. It's easy for a VSCode user to change his tab distance by just a click away. Surely a lot of user believe he is an AI, b...
. Don't forget the happiness you get when you finally solve a difficult problem . Don't forget the, Guys. It's time to find the core spirit of the competitive programming instead of being interested

Full text and comments »

  • Vote: I like it
  • +79
  • Vote: I do not like it

27.
By -is-this-fft-, history, 7 years ago, In English
[Tutorial] The DFS tree and its applications: how I found out I really didn't understand bridges #### Introduction This is a tutorial/exploration of problems that can be solved using the "DFS tree" of a graph. For a way too long time, I didn't really understand how and why the classical algorithm for finding bridges works. It felt like many tutorials didn't really explain how it works, kind of just mentioned it in passing and quickly just moved on to implementation. The day someone explained what the DFS tree is, I finally understood it properly. Before, it took me ages to implement bridge-finding properly, and I always had to look up some detail. Now I can implement it at typing speed. But more importantly, I began to see how the same techniques can be used to solve graph problems that have more or less nothing to do with bridges. The thing is, when you have a black box, you can only ever use it as a black box. But if you have a box that you understand well, you can take it into pieces, repurpose the pieces for completely different things, all without getting lost...
core of Tarjan's bridge-finding algorithm. [Typical](https://cp-algorithms.com/graph/bridge

Full text and comments »

  • Vote: I like it
  • +565
  • Vote: I do not like it

28.
By gojira, 13 years ago, translation, In English
Rockethon 2014 Editorial In this post you will find the authors' solutions for the problems and subproblems featured in the competition, as well as some bonus questions related to these tasks. [problem:391A] -------------- Note that we can consider each maximal sequence of identical characters independently, since there is no way to insert a character and affect more than one such sequence. Also, note that there are multiple ways to correct a single maximal sequence by inserting one character into it: we can either insert a different character somewhere in this sequence and divide it into two sequences of odd length (this is always possible for a sequence of even length), or even just add the same character in any point of this sequence, thus increasing its length by 1 and changing its parity. Therefore, the answer to the problem is the number of maximal sequences of even length. One can find all such sequences in linear time. A pseudocode of the solution follows: ~~~~~ i = 1 ans = 0 while i ...
explain every step of the algorithm. The core idea of the problem is the same as for the previous, The core idea of the problem is the same as for the previous subproblem: we are maximizing a sum

Full text and comments »

Tutorial of Rockethon 2014
  • Vote: I like it
  • +101
  • Vote: I do not like it

29.
By DanTheMan., 18 months ago, In English
mBIT 2025 Editorial Thank you to everyone who competed in mBIT 2025! It was a record breaking year for us with 84 in-person participants and 135 online participants. We hoped you guys enjoyed it as much as we did. We tried hard to make the problems fun and interesting for as wide of a skill gap as possible. In fact, this year's competition had an in-person team of middle schoolers that was unfamiliar with for loops, and an online team with all three participants in the top 15 in the world in codeforces. We are glad to contribute to all niches of the computer science community: beginner and advanced, local and global. Thank you all for your enthusiasm. Congratulations to the winners: **Online Advanced:** - 1st place &mdash; HoMaMaOvo &mdash; Masaki Nishimoto, Riku Kawasaki, Yui Hosaka - 2nd place &mdash; mathforcesbox &mdash; Brian Xue, Bing-Dong Liu, Alex Chen - 3rd place &mdash; bluepuppygreenturtle &mdash; Rain Jiang, Kai Jiang **Online Intermediate:** - 1st place &mdash; NULP Lega...
its segments are still present). Stilly pointy? How interesting! The core of thisproblem is the, The core of this problem is the following theorem: There is a bijection between (pointy partitions

Full text and comments »

  • Vote: I like it
  • +77
  • Vote: I do not like it

30.
By wakanda-forever, 13 days ago, In English
Codeforces Round 1131 (Div. 3) Editorial Thanks for participating in the round. We hope you enjoyed the problems!!! ####[problem:2278A] <div style="height:16px"></div> <spoiler summary = "Idea"> The problem requires the remaining characters in the numerator $p$ to form exactly the string `six` after completely cancelling out the denominator $q$. This means the collection of characters in $p$ must be exactly the characters in $q$ combined with the letters `s`, `i`, and `x`. Therefore, if we append the string `six` to $q$, the modified string $q$ must be an exact anagram of $p$. We can check this condition by sorting both strings and verifying if they are identical, or by comparing their character frequency counts. Time Complexity: $\mathcal{O}(n + m)$. </spoiler> <spoiler summary = "Implementation"> ~~~~~ #include<bits/stdc++.h> using namespace std; int main(){ int t; cin >> t; while(t--){ int n, m; string p, q; cin >> n >> m >> p >> q; q += ...
we want. This is the core idea of the problem. All that's left is just some math. Now, let's express, Thanks for participating in the round. We hope you enjoyed the problems!!! ####[ problem:2278A

Full text and comments »

  • Vote: I like it
  • +46
  • Vote: I do not like it

31.
By djm03178, 22 months ago, In English
Make Polygon rules less strict and make case-by-case decisions So today I heard a news: ![ ](https://doyak.s-ul.eu/2j6cVKxA) Personally I would like these tests to be included in the main tests, but that's not what I want to bring up now. Often these days, I find some cases where the constraints and tests seem unreasonable. Example 1. [problem:2056C] consisted of a total of 12 tests. Why was there a need to add so many tests, when a single test can include every $n$? Even if we want to include a maximal test, one additional test with $t=n=100$ is enough. The only reason it had so many tests I can think of, is just because the Polygon rules allowed it. Example 2. If you remember this problem: [problem:2034A], some naive bruteforce solutions, written in C++ with `int` passed, but the ones that used `long long` (some luckily passed) or slower languages couldn't. As stated in https://codeforces.me/blog/entry/136579?#comment-1222858, it turned out that they only focused on following the Polygon rules and didn't actually consider enough tha...
, I find some cases where the constraints and tests seem unreasonable. Example 1. [problem:2056C, I don't get why 2A problems should keep their constraints and size absolutely tiny when thecore

Full text and comments »

  • Vote: I like it
  • +20
  • Vote: I do not like it

32.
By UnexpectedValue, 21 month(s) ago, In English
[Tutorial] A New Perspective on Numbers and Operators: Introducing Group Theory We often start our mathematical journey with counting, primes, and basic arithmetic. Then we encounter modular arithmetic, with its intriguing properties and theorems like Euclid's algorithm and the Chinese Remainder Theorem. But what if there's a deeper, more abstract framework that ties all these concepts together? You might have encountered hints that group theory is behind some clever algorithms and data structures ([like this comment suggests](https://codeforces.me/blog/entry/103174?#comment-915676)). But if you've tried to learn about it, you might have found resources that felt either too abstract and disconnected from your existing knowledge ([for instance](https://zhtluo.com/cp/from-burnside-to-polya-a-short-introduction-to-group-theory.html)), or too intimidating and complex ([like this one](https://codeforces.me/blog/entry/91731)). This blog aims to bridge that gap. We'll start with familiar ground in discrete math and modular arithmetic, and then progressively in...
arithmetic, and then progressively introduce the core concepts of group theory, showing how they

Full text and comments »

  • Vote: I like it
  • +93
  • Vote: I do not like it

33.
By BledDest, 2 months ago, translation, In English
Educational Codeforces Round 194 [rated for Div. 2] <img alt="Neapolis University Pafos" src="/predownloaded/9a/33/9a332fadbb47050ba9405057df022a6e37eaf5c0.png" style="float:right;height: 150px; margin: 10px; max-width:40%;"/> Hello Codeforces! The series of Educational Rounds continues thanks to the support of the [Neapolis University Pafos](https://www.nup.ac.cy/). [contest:2260] will start on [contest_time:2260]. This round will be **rated for the participants with rating lower than 2100**. It will be held on extended ICPC rules. The penalty for each incorrect submission until the submission with a full solution is 10 minutes. After the end of the contest, you will have 12 hours to hack any solution you want. You will have access to copy any solution and test it locally. You will be given **7 problems** and **2 hours** to solve them. I hope everyone participating finds interesting problems for them to solve. I would like to express my gratitude to Mike [user:MikeMirzayanov,2026-09-06] Mirzayanov for creating Cod...
/) is a chance to explore one of the core areas you’ll study in the CSAI program. You’ll work with AI

Full text and comments »

  • Vote: I like it
  • +214
  • Vote: I do not like it

34.
By indjev99, history, 15 months ago, In English
A solution for IOI Day 2, Problem 2: Migrations with M <= 11 messages (and Z <= 4) EDIT: I have read the code for the author solution for $M \leq 8$ and it is mostly in this style and includes a chunking like here and a similar case breakdown at the final chunk of size $3$. I'd say all of the ideas here are a subset of the ideas in the full solution, though it also has one more clever element and a few more deails around it. I'll sum up the main clever part (as I understand it) at the end of the post. I came up with this solution with $M \leq 11$ to the problem and noticed the best solution at the competition was with $M \leq 12$, so I decided to post about it. This solution is quite complicated (I also have a simpler scheme with $12$), so it is understandable that no one had time for it (and I imagine $M \leq 8$ is even harder and/or cleverer). Here is a link to the problem: https://drive.google.com/file/d/1jMpszX2nPZ79jrK8yzDFIZXNb0CG_efi/view First notice that we can keep a state of which two nodes are opposite ends of some diameter. Then on a given node,...
A solution for IOI Day 2, Problem 2: Migrations with M <= 11 messages (and Z <= 4), ) at the end of the post. I came up with this solution with $M \leq 11$ to the problem and noticed, EDIT: Seems like the core idea of the full solution with 8 messages is to not keep the state fully, The core idea is that each chunk will encode the updates to the state (which 2 nodes are ends of

Full text and comments »

  • Vote: I like it
  • +102
  • Vote: I do not like it

35.
By OSt, 14 years ago, translation, In English
Web service for defrost standings of competition — S4RiS StanD Good afternoon. Today I want to share with the public my little project (which was part of my thesis), service on the "defrost" the results of the competition format ACM ICPC &mdash; "System for Right Solutions Standings Dancing" (S4RiS StanD). Hosted on [github](https://github.com/OStrekalovsky/S4RiS-StanD). #### Introduction In 2011, my team is still held in the semifinals, where at the close I saw the live operation of such a system ITMO. The feeling was strong. But after analyzing the work and reviewing captured my video, I realized that it is possible to improve this implementation, make it open to and more modest, local competitions, the participants were able to watch in awe tabulation of results. It was chosen as part of my thesis was used already in one competition and received a logical extension. <p> [cut] </p> #### About the service and its features Service is just a web page with a core written in JS and requires no "server" scripts. Therefore, this service ...
just a web page with a core written in JS and requires no "server" scripts. Therefore, this service, Service is just a web page with a core written in JS and requires no "server" scripts. Therefore

Full text and comments »

  • Vote: I like it
  • +133
  • Vote: I do not like it

36.
By Aveiro_quanyue, history, 4 years ago, In English
A note on a nowcoder problem -- Centroid decomposition (点分治) Nowcoder problem (Chinese) [link](https://ac.nowcoder.com/acm/contest/51721/E). The submission is private because I don't want to publish my Nowcoder account, but you can copy the code at the end of this blog and paste it to the answer sheet, it will get AC. [English version](https://codeforces.me/blog/entry/114434) First I would like to thank [user:ShaoNianTongXue5307,2023-03-28] for his idea! This is a learning note, most for myself. Most of this blog is not original. **Part 1: Problem Statement:** A tree $T=(V, E)$ has $n$ vertices and $n-1$ edges, the weight of each vertex $i$ is $a_i$. For each edge $e$, you can determine its direction, i.e., for two vertices $u, v$, there are two states: $u \rightarrow v$ and $v \rightarrow u$. There are $2^{n-1}$ states in total. For each state $S$, we define $f(S)$ as $f(S) := \sum\limits_{(u, v) \in V \times V, v\,\text{is reachable from}\,u} |a_u - a_v|$. Compute the sum of $f(S)$ over all $2^{n-1}$ states $S$, mo...
A note on a nowcoder problem -- Centroid decomposition (点分治), paste the core code here:, Nowcoder problem (Chinese) [link](https://ac.nowcoder.com/acm/contest/51721/E). The submission is

Full text and comments »

  • Vote: I like it
  • +107
  • Vote: I do not like it

37.
By chithanh_nguyen, 6 months ago, In English
Duplicate Problem in Codeforces Round 1099 Div. 2? During [Codeforces Round 1099 (Div. 2),](https://codeforces.me/contest/2231), I noticed that Problem E appears to be very similar to an old problem from the Vietnamese Olympiad in Informatics 2021 (VOI 2021). The statement of Problem E can be summarized as follows: > Given a tree with $n$ vertices, count the number of triples $(a, b, c)$ such that $a < b < c$ and the number of vertices in the Steiner tree connecting $a$, $b$, and $c$ is exactly $d$. **Note.** Here, the Steiner tree of a set of vertices in a tree simply means the smallest connected subgraph containing all chosen vertices. **Constraints.** $3 \leq d \leq n \leq 2000$. However, in VOI 2021, Problem 2 had an almost identical idea. The original Vietnamese statement can be found [here](https://oj.vnoi.info/problem/voi21_comnet). Its statement can be summarized as follows: > Given a tree with $n$ vertices, count the number of ways to choose $k$ vertices such that the number of edges in the Steiner tree conne...
Duplicate Problem in Codeforces Round 1099 Div. 2?, Problem E appears to be very similar to an old problem from the Vietnamese Olympiad in Informatics 2021, This similarity is quite concerning, especially because Problem E had a relatively high score in

Full text and comments »

  • Vote: I like it
  • +29
  • Vote: I do not like it

38.
By Nisiyama_Suzune, history, 8 years ago, In English
[Reserach] The application of ML techniques on certain problems (i.e. How to make crazy hard problems that nobody can solve) Background ================== The idea of this article originated from a contest (Petrozavodsk Summer-2016. Petr Mitrichev Contest 14), which I believe is attributed to [user:Petr,2018-07-25]. In this contest, an interesting problem is proposed: "Cosider this process: pick a random number $n_i$ uniformly at random between $10$ and $100$. Generate $n_i$ random points with integer coordinates, picking each coordinate independently and uniformly at random from all integers between $0$ and $10^9$, inclusive. Find the convex hull of those points. Now you are given $10000$ polygons generated by this program. For each polygon, you need to guess the value $n_i$ that was used for generating it. Your answer will be accepted if the average (over all $10000$ hulls) absolute difference between the natural logarithm of your guess and the natural logarithm of the true $n_i$ is below $0.2$." Unfortunately, I didn't really manage to work this one out during our 5-hour training session. ...
simplicity, especially due to the fact that its core code can be written with about 60 lines. I will, this contest, an interesting problem is proposed: "Cosider this process: pick a random number $n_i, As we can see, the core code of a neuron network takes only about 60 lines to finish (which I

Full text and comments »

  • Vote: I like it
  • +132
  • Vote: I do not like it

39.
By 0t0infinity, history, 6 months ago, In English
(Intermediate Part) — Bits That Changed My CP Thinking ! This is the **Part-2** of my Bitwise Operations Blog. In this part, I focused more on intermediate-level bitwise tricks, Common CP Patterns and a few slightly advanced techniques that appear frequently in contest. &mdash; [**Part-1 &mdash; Click Here**](https://codeforces.me/blog/entry/153600) I tried to explain the intuition and thinking process behind each trick as clearly and simple as possible. And as always, Heartfelt thanks to `Raha Ahmed` for her endless encouragement, strongest support and constant belief in me ! --- # Core Concepts You Must Understand First :- --- Intermediate level Bitwise Problems in CP rarely ask you to just "check" or "set" a bit. Instead, they require you to use the Mathematical Properties of bits to optimize your code. Before we jump into the 8 Master Pattern, you need to firmly understand these 5 core concepts. If you understand these the upcoming patterns will feels like magic ! --- <spoiler summary="Core Explan...
into the 8 Master Pattern, you need to firmly understand these 5 core concepts. If you understand, , strongest support and constant belief in me ! --- # Core Concepts You Must Understand First

Full text and comments »

  • Vote: I like it
  • +75
  • Vote: I do not like it

40.
By gwgdg, 18 months ago, In English
A Beginner's Guide to Number Theory Concepts in Competitive Programming through a Single Problem! To understand these concepts, you just need basic arithmetic knowledge, typically covered up to 10th-grade mathematics. I'll start straight away by introducing the problem. First, the easier version, and then we'll move to the harder version, which is just the easier version with increased constraints. **Problem Statement** – Given an array $A$ of size $N$ and a positive integer $M$, perform these steps: - First, create array $B$ such that $B_i = A_i \times M!$ ($M!$ denotes the [factorial](https://en.wikipedia.org/wiki/Factorial) of $M$). - Then, for each element in array $B$, calculate $F(B_i)$, where $F(x)$ represents the number of divisors of $x$. Since these values can be large, output each $F(B_i) \bmod (1e9+7)$. - Output $N$ space-separated integers representing $F(B_i) \bmod (1e9+7)$. ### Constraints - $1 \leq N \leq 1e5$ - $1 \leq M \leq 100$ - $1 \leq A_i \leq 1e5$ --- What's the first thing that comes to your mind after reading the problem stat...
A Beginner's Guide to Number Theory Concepts in Competitive Programming through a SingleProblem!, 10th-grade mathematics. I'll start straight away by introducing the problem. First, the easier, **Core Concepts Covered**, What's the first thing that comes to your mind after reading the problem statement? Naturally, it

Full text and comments »

  • Vote: I like it
  • +24
  • Vote: I do not like it

41.
By truthforces, 19 months ago, In English
Cheaters are now becoming Core Members of University Coding Clubs (I am sorry for bringing up this blog more frequently in recent actions, but I'm doing it so that my seniors notice it and can take strict action against him once they see it) Hello Codeforces, Let me introduce you to [**Soumyadeep Singh**](https://www.linkedin.com/in/soumyadeep-singh-347044258) , who has successfully cheated his way through Codeforces and LeetCode contests, Online Assessments, university examinations, and now we can also see him as an official problem setter in coding contests organized by Jadavpur University's coding clubs. ![ ](/predownloaded/ed/6d/ed6d51b9168cc84d5b14fdd4bb507c780a349e81.png) [user:singhsoumya_coder,2025-04-14] is a pre-final year student at Jadavpur University, and he is well-known for his massive cheating scandals and for his consistent track record in cheating. He cheated his way to **Google** during campus internships, and people also found his behavior suspicious when he used to write outrageous messages in AskSenior and other cod...
Cheaters are now becoming Core Members of University Coding Clubs, Assessments, university examinations, and now we can also see him as an officialproblem setter in coding

Full text and comments »

  • Vote: I like it
  • +167
  • Vote: I do not like it

42.
By ainta, history, 9 years ago, In English
Quality of the WF problems A &mdash; ok. B &mdash; easy. ok. C &mdash; most interesting D &mdash; O(N^2) &mdash; precision issue, AC with biginteger / Slower solution &mdash; TL issue E &mdash; I don't like this G &mdash; straightforward voronoi I &mdash; input format.. FGHI &mdash; TL issue (especially I) J &mdash; see model solution. really? K &mdash; easy. ok. ICPC WF should keep the level of the problem high. But for this year it seems like a big fail... Too many problems have issues not related to the core solution.
level of the problem high. But for this year it seems like a big fail... Too many problems have, Too many problems have issues not related to the core solution.

Full text and comments »

  • Vote: I like it
  • +302
  • Vote: I do not like it

43.
By vlalit834, history, 6 months ago, In English
AtCoder AI Tagged Problems: Instant Topic-Based Problems # AtCoder AI Tagged Problems: Instant Topic-Based Problem Discovery *A zero-configuration platform for filtering AtCoder problems by algorithmic topic, difficulty, and contest type.* --- [AtCoder AI Tagged Problems](https://atcoder-ai-tagged-problem.vercel.app/) provides structured access to the AtCoder problem set through AI-generated topic annotations and a multi-dimensional filtering interface. The application requires no installation, no user account, and no browser extensions. --- ## Core Capabilities - **AI-Generated Topic Annotations**: Every problem in the AtCoder archive is annotated with algorithmic topics including Dynamic Programming, Graph Theory, Greedy Algorithms, Mathematics, String Processing, and Computational Geometry. Tags are generated automatically and available immediately for all problems, without dependence on community voting or manual curation. - **Multi-Criteria Filtering Interface**: Problems can be filtered concurrently by algorithmic ...
## Core Capabilities

Full text and comments »

  • Vote: I like it
  • -1
  • Vote: I do not like it

44.
By adamant, history, 4 years ago, In English
How to read my blogs Hi everyone! I saw that a lot of people write meta blogs recently. As my blog count approaches 90, I feel like it may make a lot of sense to write another one that kind of focuses on the philosophy behind my blogs and explains potential readers what they should expect from my blogs and how to approach them. So, without further ado... ##### Tldr. 1. Read my blogs if and only if the general setup itself appeals to you. Don't feel obliged to do it to get better at competitive programming. 2. Don't be driven away by seemingly dense math notation if the topic looks interesting. Ask questions if something is difficult to comprehend, I will explain in a more detail and it will help others too. 3. Be ready to fill some possible gaps in the story yourself, as an exercise. 4. Be open-minded about analyzing setup in general, rather than working towards predetermined goal. 5. Be prepared to see too little explanation on how abstract nonsense from my blogs connects with concrete applic...
not by reading the title and skimming through first 2-3 paragraphs. Does the setup and theproblem, the times is very simple: you just do what you think is natural to do to analyze theproblem

Full text and comments »

  • Vote: I like it
  • +52
  • Vote: I do not like it

45.
By Leeking, history, 6 months ago, In English
LeekCF-Rating: Fix for cf-getrating (View problem ratings without spoilers) <img src="/predownloaded/eb/77/eb770853b3660f9e8129810a5b2f4704347d5377.png" style="float: right; margin-right: 45px; margin-left: 15px; margin-bottom: 10px; width: 230px;" /> ## Hello Codeforces! As many of you noticed, recent API changes broke several extensions, including the popular cf-getrating. Since the original creator seems to be inactive (no response to PRs or emails), I have forked and fixed the extension so we can all keep using this functionality. ## What is LeekCF-Rating (cf-getrating) For those unfamiliar, this extension allows you to see the **difficulty rating** of a problem while keeping `problem tags` hidden. **Why??:** Solve problems 100% on your own. Tags often act as **spoilers** (e.g., seeing "Dynamic Programming" tells you exactly how to approach the problem) <spoiler summary="Check Images"> ![ ](https://i.imgur.com/eUFLZvF.png) ![ ](https://i.imgur.com/CwNRKhn.png) </spoilter> **Installation Links:** - [Chrome Web Store](https://chromewe...
LeekCF-Rating: Fix for cf-getrating (View problem ratings without spoilers), I kept the core logic identical to the original but updated the API call methods, icons, and readme, problem while keeping `problem tags` hidden. **Why??:** Solve problems 100% on your own. Tags

Full text and comments »

  • Vote: I like it
  • +20
  • Vote: I do not like it

46.
By greateric, history, 5 months ago, In English
Stresstesting script Don't worry, your regularly scheduled useless information programming will resume soon. Anyway, here is [`gtest`, my attempt at writing a script to help with stresstesting](https://github.com/greatericontop/gtest). Note that I still personally think stresstesting is slightly overrated. It is not a silver bullet, especially when some questions are unstresstestable, like some constructive problems, [problems where the solution space grows way faster than even exponentially if you're trying to brute](https://codeforces.me/contest/1747/problem/D), other cases where your brute forcer has to make some core observation that could potentially be wrong, or if your brute forcer is bugged too and misses the same edge case your fast solution does (Cirno and Number with digit 0 be like). I also think it takes a lot of time so you decide whether you want to write everything up or not. With that being said though, it should be very helpful for debugging WA2s, hopefully. The format is ~~~...
to brute](https://codeforces.me/contest/1747/problem/D), other cases where your brute forcer has to, ://codeforces.com/contest/1747/problem/D), other cases where your brute forcer has to make somecore

Full text and comments »

  • Vote: I like it
  • +22
  • Vote: I do not like it

47.
By WorldWarV, history, 12 months ago, In English
Introducing Lynkforces -- A Smarter Way to Practice Ever felt like Codeforces tags are too limited? [Lynkforces](https://lynkforces.vercel.app/) (pronounced link-forces) lets you fly around a 3D map of problems and discover clusters by reasoning and technique. Click points to fly to problems, see related ones, adjust rating, and enter your handle to see solves! Full link: [lynkforces.vercel.app](https://lynkforces.vercel.app/) ## What it is - Two maps: - Reasoning — clusters by similarity of how you think about the solution. - Tags — clusters by techniques/data structures (segment tree, DSU, XOR basis, etc.). - Color key: white = unsolved & not relevant (default), green = solved, purple = relevant (darker = more relevant), blue = solved + relevant (darker = more relevant). - Dataset note: coverage isn’t comprehensive; latest I saw while testing was about a year back (Round ~995-ish). 3D clustering isn’t perfect since high-dimensional vectors were compressed to 3D, so some related points may still be far apart. Main map...
thinking. I summarized editorials into skill vectors, core tasks, pure reasoning, and other fields, very different thinking. I summarized editorials into skill vectors, core tasks, pure reasoning, and

Full text and comments »

  • Vote: I like it
  • +67
  • Vote: I do not like it

48.
By MrStark2244, history, 16 months ago, In English
Beyond Basic BFS: Solving Multi-Agent and Complex Path Problems with State-Space BFS Hello Codeforces community! We all know and love Breadth-First Search (BFS). It's our go-to for finding the shortest path in unweighted graphs. But what happens when the problem isn't just about moving a single entity from point A to point B? What if there are two entities moving simultaneously, or if the "state" of our problem involves more than just a single vertex? This is where the powerful technique of **BFS on a State-Space Graph (often implicitly a Product Graph)** comes into play. It's not a new algorithm, but rather a fundamental *application pattern* of BFS that allows us to tackle a much wider range of problems. --- ### The Core Concept: State-Space BFS Imagine your problem isn't just about a single node in a graph. Instead, the "situation" or "configuration" of your problem is more complex. * **What is a "State"?** In State-Space BFS, a "state" is a tuple that encapsulates *all the necessary information* to describe the current configuration of your p...
finding the shortest path in unweighted graphs. But what happens when the problem isn't just about, ### The Core Concept: State-Space BFS, ### The Core Idea: Two Travelers & State Definition

Full text and comments »

  • Vote: I like it
  • +6
  • Vote: I do not like it

49.
By ethflow, history, 22 months ago, In English
About Ethflow Hello, Codeforces! <img src="/predownloaded/be/de/bede115074d89e31af9bec68662549e90587cf99.png" style="width:250px;float:right;margin:0 1em 1em 1em;"/> We are [Ethflow](https://ethflow.io) &mdash; proprietary trading fund, specializing in cryptocurrency trading. We are glad to host our first Codeforces round! All participants will **have a chance to win T-shirts** (top 50 + 50 random participants who ranked below 50th place and solved at least 3 problems). <center><img alt="image" src="/predownloaded/ef/67/ef67cdf961558f2fbc67b241dc95c5a11a12eed5.png" style="float:center;height: 400px; margin: 10px; max-width:80%;"/></center> Many of our team members, such as [user:VEGAnn,2025-01-24], [user:_Time_Lord_,2025-01-24], [user:welleyth,2025-01-24], [user:FLEA,2025-01-24], [user:vgzowski,2025-01-24] and others, are former Codeforces participants, including our CEO, [user:altruist, 2025-01-24] and CTO, [user:SoMuchDrama,2025-01-24]. Now, some of them were involved in four different ...
roles over time: first as participants, then as teachers and problem setters, and now as sponsors, [Ethflow](https://ethflow.io) is not just yet another HFT company. **The core of our culture is

Full text and comments »

  • Vote: I like it
  • +242
  • Vote: I do not like it

50.
By Semyazi, history, 12 months ago, In English
Rethinking Binary Search with Non-Monotone Predicates Binary search is one of those algorithms that's easy to understand the idea of, but it's often hard to work out the implementation details. For example, should it be $\text{lo}=0$ or $\text{lo}=1$? Should I set $\text{lo}$ to $\text{mid}$ or $\text{mid}+1$? Is the answer going to be $\text{lo}$ or $\text{hi}$? The questions are endless. As a result, I'd like to share with you a perspective on binary search that makes it easier to implement without bugs (in my opinion), and also more general. It involves abstracting out the actual binary search step by thinking of it as a method of finding a $[0,1]$ subarray in an array of $0$'s and $1$'s. After doing this, we find that binary search can be applied to search predicates that aren't monotone, allowing it to be applied to more problems that wouldn't usually be considered binary search at a glance. I hope you find it helpful! Also, huge thanks to my friends: [user:Wobert,2026-01-16] and [user:andrewtam,2026-01-16] for proofreading! :) ...
can do just that! The above problem is the quintessential binary search problem . At its verycore, just that! The above problem is the quintessential binary search problem. At its verycore, binary

Full text and comments »

  • Vote: I like it
  • +60
  • Vote: I do not like it

51.
By MrMoon, 3 months ago, In English
PSUT JCPC Qualification 2026 Tutorial Hints are mostly related, so you have to think and get some observations before understanding the next, make sure to understand the code before you submit it as well, "Most problems in life are due two reasons: act without thinking, think without acting" ~the,2026-08-02 poet,2026-08-01 Big thank you to the testers for improving this problem set beyond what it was, [user:the_seal,2026-08-02] , [user:Rayo,2026-08-02], [user:samsoom,2026-08-02], [user:lazlooz,2026-08-02] The contest exist in the group so make sure to join https://codeforces.me/group/ppRciMeJFg Some of these problems were inspired from other problems across the internet, "If I have seen further, it is by standing on the shoulders of giants." ~the,2026-08-02 poet [Problem A: MrMoon creates Lucky Number Seven Command](https://codeforces.me/group/ppRciMeJFg/contest/707652/problem/A) ================== ### 7 [Problem B: Moon creates seal backflips](https://codeforces.me/group/ppRciMeJFg/contest/707652/probl...
$0$ or $2\pi$ boundary The core of the problem is, The core of the problem is determining the exact angular interval, The core of the problem is finding the shortest path (minimum time

Full text and comments »

  • Vote: I like it
  • +21
  • Vote: I do not like it

52.
By Bekh, history, 6 years ago, In English
My Uninspirational Story from Pupil to Candidate Master Since everyone's sharing their journeys in cp, I thought I might as well. Hope you don't find it relatable. Here is the timeline of my journey. - Got exposed to programming when I was a kid. Had all the resources and guidance I needed to start. Doing nothing was much more appealing back then. - Reach 18. Have to pick something to study in college. Everyone is studying cs nowadays so why not jump on the bandwagon? I sit in front of a screen all day anyway so this will fit me, right? - It didn't. - Hear that big companies that have sleeping capsules and free food ask algorithmic questions in their interviews. - Start solving problems. - It's not like anything else is remotely interesting. Everything is built above nine thousand layers of abstraction it's fucking impossible to understand shit. Would much rather if people explained stuff in core instead of giving tricks on the surface to memorize to get shit done. - Keep solving problems to escape the guilt that i'm doing nothin...
explained stuff in core instead of giving tricks on the surface to memorize to get shit done. - Keep, understand shit. Would much rather if people explained stuff in core instead of giving tricks on the

Full text and comments »

  • Vote: I like it
  • +515
  • Vote: I do not like it

53.
By kiyotaka, 7 years ago, translation, In English
Codeforces Global Round 3 Hi! On [contest_time: 1148] we will host Codeforces Global Round 3. It is the third round of a new series of Codeforces Global Rounds supported by XTX Markets. The rounds are open for everybody, the rating will be updated for everybody. The prizes for this round: * 30 best participants get a t-shirt. * 20 t-shirts are randomly distributed among those with ranks between 31 and 500, inclusive. The prizes for the 6-round series in 2019: * In each round top-100 participants get points according to the [table](https://pastebin.com/QT5sXEaT). * The final result for each participant is equal to the sum of points he gets in the four rounds he placed the highest. * The best 20 participants over all series get sweatshirts and place certificates. The problems of the round were developed by me, [user:egor.lifar,2019-05-31] and [user:UnstoppableSolveMachine,2019-05-31]. We are glad to say that we have prepared 8 tricky tasks for you. We hope you will enjoy them! Tha...
hiring into its Core Development team in London. This team is responsible for the design and, -Job-SpecFinR.pdf">the link. * XTX Markets is hiring into its Core Development team in

Full text and comments »

Announcement of Codeforces Global Round 3
  • Vote: I like it
  • +121
  • Vote: I do not like it

54.
By mousahamed, history, 6 months ago, In English
Breaking the Language Barrier: Official Problem Translations for Major Languages Hello Codeforces Community! First of all, I want to express my deep appreciation for this amazing platform. Codeforces has been the ultimate home for competitive programmers worldwide, helping us learn, compete, and grow. However, I would like to discuss a challenge that affects a massive segment of our community: The Language Barrier. At its core, competitive programming is a test of logical thinking, mathematical skills, and algorithmic knowledge—not an English reading comprehension test. While English and Russian are the primary languages for problem statements, many talented participants from non-English speaking regions struggle not with the logic of the problem, but with misunderstanding subtle linguistic details in the problem description during the pressure of a contest. The Proposal: I would like to suggest a system where Codeforces officially supports problem translations in other widely spoken global languages, especially during official rounds. Alongside Eng...
Breaking the Language Barrier: Official Problem Translations for Major Languages, segment of our community: The Language Barrier. At its core, competitive programming is a test of, At its core, competitive programming is a test of logical thinking, mathematical skills, and

Full text and comments »

  • Vote: I like it
  • +9
  • Vote: I do not like it

55.
By saanTH, history, 4 months ago, In English
How Codeforces Catches Cheaters: A Look Inside Plagiarism Detection If you've competed on Codeforces long enough, you've probably seen the aftermath of a plagiarism sweep — ratings quietly rolled back days after a round, a wave of "why did I lose rating?" posts, someone's submission flagged with a red "SKIPPED" or a hack. Ever wondered what's actually happening behind the scenes? Here's a breakdown of how automated code-similarity detection works, and why it's harder to dodge than people think. The core problem: comparing everyone to everyone A typical Div. 2 round pulls in tens of thousands of submissions per problem. To catch copied code, you'd naively need to compare every submission against every other submission — that's roughly O(n²) pairs. For 30,000 participants, that's on the order of 450 million comparisons per problem. Even at a blistering 10,000 comparisons per second, that's over 12 hours of raw compute for one problem alone. This is exactly why plagiarism results don't show up immediately after a contest. Ratings get updated firs...
harder to dodge than people think. The core problem: comparing everyone to everyone A typical, The core problem: comparing everyone to everyone

Full text and comments »

  • Vote: I like it
  • +6
  • Vote: I do not like it

56.
By soullless, 10 months ago, translation, In English
I think we are checking the wrong thing against LLM cheating ### 1. What exactly is the problem During rounds, a specific pattern has appeared: a participant gets ready-made code from an LLM and simply submits it, almost without understanding it. This is not always caught by plagiarism: a person can rename variables, swap some parts of the code. ### 2. The idea #### Xeppelin — an open-source tool, originally made for ICPC, which: - is launched locally before the contest - logs file changes in the working directory - stores a development timeline (when and how the code changed) - does not record the screen, keyboard, network, or tabs - after the contest builds a visualization of activity #### [This is not my tool, but you can find it here](https://github.com/KiK0S/xeppelin) ### 3. What exactly is proposed for Codeforces (implementation, not an idea) The proposal is to use Xeppelin as an external source of behavioral data, without interfering with CF infrastructure. Workflow: 1. The participant launches Xeppelin bef...
### 1. What exactly is the problem During rounds, a specific pattern has appeared: a participant

Full text and comments »

  • Vote: I like it
  • +392
  • Vote: I do not like it

57.
By Aylup, 20 months ago, In English
Problem vs Question: Concept > Semantics The long-standing debate between "problems" and "questions" is rife with political turmoil and irrelevant tangents, but ultimately there is merit to its resolution. Both sides have valid concerns and they aren't necessarily at odds with each other. #### Concept Over Semantics 1. **The word itself doesn’t matter.** Calling something a “question” doesn’t make someone inferior or less capable. Language is fluid, everchanging and contextual, so going down a rabbit-hole of dictionary definitions is ultimately unproductive. 2. **What matters is the burden of constraints.** The difference lies in whether you are merely seeking information or actively solving something with real-world implications. I am only describing what these words mean to me and why I found it helpful in my journey. The concept is what matters, not the actual word choice. #### The Core Distinction - A **question** seeks an accurate answer. Open-ended questions receive loose answers, so the responsibility l...
Problem vs Question: Concept > Semantics, #### The Core Distinction - A **question** seeks an accurate answer. Open-ended questions, . The concept is what matters, not the actual word choice. #### The Core Distinction - A

Full text and comments »

  • Vote: I like it
  • -9
  • Vote: I do not like it

58.
By dalex, 13 years ago, In Russian
Topcoder из Eclipse (инструкция для новичков) Этот текст я пишу в основном для ребят младших курсов своего университета, чтобы они наконец начали участвовать в соревнованиях Topcoder. Так получилось, что на Codeforces это сделать мне наиболее удобно. Может быть, кому-то еще пригодится. ### Что вообще такое Topcoder [Topcoder](http://community.topcoder.com/tc) &mdash; это как Codeforces, только менее удобный. На самом деле, помимо соревнований по спортивному программированию там проводится еще куча мероприятий, которым аналогов в мире нет, так что многим деваться просто некуда :) А для тех, кто занимается именно спортивным программированием, это просто еще три-четыре неплохих контеста в месяц. Если кликнуть на сайте на ссылку Events, а далее &mdash; Event Calendar, можно увидеть [расписание](http://community.topcoder.com/tc?module=Static&d1=calendar&d2=thisMonth) этих контестов. Время там указано какое-то американское, чтобы получить московское, нужно в разное время года прибавлять либо 8 часов, либо 9. Кроме того, можно к...
компоненты (см. картинку). Выбираем Core, Java Support и Problem Archive, принимаем лицензионное, . картинку). Выбираем Core, Java Support и Problem Archive, принимаем лицензионное соглашение

Full text and comments »

  • Vote: I like it
  • +92
  • Vote: I do not like it

59.
By smooth, history, 10 months ago, In English
Workaround for The In-queue Problem on Cf If you’ve participated in Codeforces contests, you already know the drill. You submit a solution, it goes **In Queue**, and suddenly your flow breaks. You keep refreshing the page. You switch between tabs. You’re unsure whether to move on to the next problem or wait. And most importantly, you have no idea how long the judging queue actually is. That uncertainty adds unnecessary friction during contests, where focus and momentum matter the most. ### **The Core Problems** From personal experience (and talking to friends), a few issues stood out clearly: - Constant refreshing just to see if the verdict changed - No queue visibility, so “In Queue” could mean 2 submissions ahead… or 200 - Context switching between problems and submissions, breaking concentration - Wasted mental bandwidth waiting instead of solving the next problem - None of these problems are hard individually, but together they disrupt the contest experience. ### **The Solution** Instead of forcing users...
Workaround for The In-queue Problem on Cf, between tabs. You’re unsure whether to move on to the next problem or wait. And most importantly, you, ### **The Core Problems** From personal experience (and talking to friends), a few issues stood

Full text and comments »

  • Vote: I like it
  • +7
  • Vote: I do not like it

60.
By purplesyringa, history, 2 years ago, In English
AI might erase CP, but not us I haven't slept for 20 hours and I can't fall asleep. I've been reading others' topics on AI, and I had a sort of epiphany. These ideas have been brewing inside me for many years, and I thought it might be time to share them with the community. --- There were times when I was a "competitive programmer" at the core. I spent many years doing that exclusively. I've never been to IOI, but I like to think that I've reached some good heights. Two years ago, I stopped writing online competitions. I've written a few offline competitions after that, but eventually, I decided to stop that too. Yet somehow Codeforces still attracts me. I don't want to solve problems, but I keep typing codeforces.com into the address bar. *Why?* Just yesterday, I didn't have an answer. --- Imagine a layperson asking you what competitive programming is. What are you going to say? My answer has always been "Oh, we solve interesting algorithmic problems with time constraints and other limits". Many ...
programmer" at the core. I spent many years doing that exclusively. I've never been to IOI, but I

Full text and comments »

  • Vote: I like it
  • +293
  • Vote: I do not like it

61.
By shsh, history, 8 months ago, In English
HPI 2026 Editorial Thank you to everyone who attended this year's Harker Programming Invitational (HPI)! If you haven't already, we would really appreciate it if you filled out our [feedback form](https://forms.gle/opwQmMZPBtM7uWCt9) so we can make our contest even better next year. Also, [Novice](https://codeforces.me/gym/106410) and [Advanced](https://codeforces.me/gym/106409) problems have been uploaded to the Gym for upsolving. *Note:* Only solutions for the Advanced division are presented here, but solutions for Novice-only problems (Yash is Cross-Eyed, Repetition, Skills) can be provided upon request. ## Harker!! <spoiler summary="Solution"> Pretty straightforward: most languages have a standard library function for finding a given substring in a string, so you can just use that. </spoiler> <spoiler summary="Code (Team Aarav)"> ```python def solution(s): if "harker" in s: return 1 return 0 T = int(input()) for _ in range(T): s = input() prin...
similar to the core idea for [range distinct value queries](https://judge.yosupo.jp/problem, sufficient to solve the problem. Note that this also means that the transformation is possible iff the

Full text and comments »

Tutorial of HPI 2026 Advanced
Tutorial of HPI 2026 Novice
  • Vote: I like it
  • +28
  • Vote: I do not like it

62.
By ScotchOnTheRocks, history, 6 years ago, In English
Frustration and Stagnation If you do not like these types of blogs, here's your warning to move on. Problem: ------------------ Firstly I'd like to address all the people who are going to say rating doesn't matter, what matters is just developing problem solving skills, because that's the only thing under your control. To that I say, perfectly agreed, because rating is only an approximation of one's skill, and a large number of variable factors control it. But you cannot deny that there is a postiive correlation between the two in the long run. The idea behind saying "just develop problem solving skills" is to essentially say that over the long run, rating will eventually pick up, don't worry about it. I honestly feel like I'm a much better solver than two-three months ago. But as you would see on my profile page, I've been largely hovering around 1750, and now I've dropped multiple times continuously in rating, to add fuel to fire. And its not a one or two contest whine. It's been the story over 20+ co...
necessarily get, not the usual one or two observations, but all the way to the core of the problem. One, , not the usual one or two observations, but all the way to the core of the problem. One wrong

Full text and comments »

  • Vote: I like it
  • +92
  • Vote: I do not like it

63.
By 0t0infinity, history, 6 months ago, In English
Bits That Changed My CP Thinking — (Beginner Part) Bitwise Operations was one of the most confusing topics for me at first. But once I started understanding how bits actually work, many CP problems suddenly became much easier to think about and optimize. This blog is the result of a full day of grinding, where I tried to organize everything I know about bitwise tricks into a clear and structured form — from the basics to useful CP patterns. I tried to keep everything as simple and beginner-friendly as possible so that anyone can understand the core idea behind each trick instead of memorizing formulas. If even one trick from this blog helps someone solve a problem faster or understand bits more clearly, then this effort feels truly meaningful for me. And finally, I want to express my deepest gratitude to `Raha Ahmed` for being The Strongest support in my CP journey. Her constant encouragement, belief and presence have played a huge role in shaping my progress and I’m truly grateful for everything she has done. --- #...
to keep everything as simple and beginner-friendly as possible so that anyone can understand thecore, understand the core idea behind each trick instead of memorizing formulas. If even one trick from this blog

Full text and comments »

  • Vote: I like it
  • +62
  • Vote: I do not like it

64.
By OmarAfterMidnight, history, 3 months ago, In English
VoidHub Update: 1v1 Duels, Solo Sprint, Originals, and CPC Problems Hi Codeforces! About seven weeks ago, [user:AdhamAfterMidnight,2026-08-19] and I shared [VoidHub](https://voidhub.co), a project we started while preparing for the ECPC. The main idea was simple: make regular practice feel less repetitive. Invite a friend, enter a live 1v1 room, solve under a timer, and let the original judge decide the result. Since that post, we kept building, testing, and fixing plenty of details. This is a small update about what has changed. [cut] ## VoidHub is still about 1v1 The core of VoidHub is still live 1v1 competitive programming. You can invite a friend, choose a mode, set a difficulty range and timer, then play in the same room using problems from: - Codeforces - HackerRank - Online Judge The available duel formats include BO3, BO5, Blitz, Pick & Play, and Quick Match links. ![VoidHub compete modes](/predownloaded/d1/fc/d1fcd4fd5f1a2a017a3e93648e93df92e470e605.png) For Codeforces rooms, submissions are sent through the ...
is still about 1v1 The core of VoidHub is still live 1v1 competitive programming. You can, The core of VoidHub is still live 1v1 competitive programming.

Full text and comments »

65.
By gkcs, history, 11 years ago, In English
The other end of the telescope To try and understand the psychology of a problem solver, let us ask a few abstract questions: 1) Why do you like solving problems? 2) What is the biggest challenge you face when implementing your solution? 3) Which key area in your skill set can you improve simultaneously along with problem solving? The answers to the first question are very interesting: Contestants swear about how much they love math/algorithms and designing data structures. I have **never** heard someone say : "Oh, I _love_ checking for integer overflows!" or "Finding the maximum in an array is so _awesome_!". And yet, we find ourselves stuck doing these exact same things, again and again, till our minds are trying hard to stick to the original problem while our fingers frantically type out the code. So we have an answer to our first question. We solve problems to challenge our mind, to sooth our egos by looking at green ticks and savour the adrenaline coursing through our veins when we are put in cr...
Design patterns, programming principles, Github integration etc... are not core to competitive, To try and understand the psychology of a problem solver, let us ask a few abstract questions: 1

Full text and comments »

  • Vote: I like it
  • +67
  • Vote: I do not like it

66.
By Semarapura, 11 years ago, In English
Is this maxflow problem? [Let's discuss interesting hard(?) problem] Hello great codeforces community, I was trying to solve [this problem](http://codechillout.sphere-contest.com/problems/onlineround/LADYBUGS), the core problem is simple: Given n lines, find maximum number line segments such that no two line segments intersect. Formally: Given set A containing n line segments from point (Xs[i],0) to point (Xf[i],Yf[i]) inclusive for each integer (1 ≤ i ≤ n), with satisfy this condition: (1 ≤ n ≤ 200, -40000 ≤ Xs[i], Xf[i] ≤ 40000, 0 ≤ Yf[i] ≤ 40000; all n,Xs[i],Xf[i],Yf[i] are integers), let set B containing all subset of set A such that no pair of line segments in that set intersect. The problem is to find an element from set B with maximum length. ------------------------------------------------------------- One valid example: ![ ](http://www.spoj.com/content/tjandra:case.png) in the picture above there are 12 line segments: A={AB,BC,CD,EF,GH,IJ,KL,MN,OP,QR,ST,UV} One of the solution (maximum subset of set A such that no two line seg...
Is this maxflow problem? [Let's discuss interesting hard(?) problem], -contest.com/problems/onlineround/LADYBUGS), the core problem is simple: Given n lines, find maximum

Full text and comments »

  • Vote: I like it
  • +28
  • Vote: I do not like it

67.
By Crysfly, history, 3 months ago, In English
UOJ Prime Round 2026 & UOJ Challenge #1 [UOJ Prime Round 2026](https://uoj.ac/contest/112) will be held at [10:00 AM on Saturday, August 8 (UTC +8)](https://www.timeanddate.com/worldclock/fixedtime.html?iso=20260808T1000&p1=33)! The contest will last for 672 hours (28 days). [UOJ Challenge #1](https://uoj.ac/contest/113) will be held at [10:00 AM on Sunday, August 9 (UTC +8)](https://www.timeanddate.com/worldclock/fixedtime.html?iso=20260809T1000&p1=33)! The contest will also last for 672 hours (28 days). UOJ Prime Round has already been mentioned in a [previous blog post](https://gezhiyuan.blog.uoj.ac/blog/9779). It will bring together problems from on-site contests over the past year that were solved by almost nobody during the contests and have received relatively few post-contest submissions. As for UOJ Challenge, [user:Gellyfish,2026-08-08] happened to have an interesting problem that did not seem to fit particularly well anywhere else, so we thought we might as well release it alongside UOJ Prime Round for eve...
, [user:Gellyfish,2026-08-08] happened to have an interesting problem that did not seem to fit

Full text and comments »

  • Vote: I like it
  • +22
  • Vote: I do not like it

68.
By sushmit2022, history, 6 months ago, In English
Editorial - Insomnia 2026 [A. The Oracle's Curse](https://codeforces.me/gym/682678/problem/A) ================== Author: [user:aditya1977,2026-04-27] <spoiler summary="Explanation"> <h3>Observation</h3> An alarm rings when a stock with a low starting price passes a stock with a high starting price. Since all stocks go up by exactly $1$ every day, a lower stock can only pass a higher stock if the higher one hits its maximum limit and stops growing. Once it passes, it stays ahead forever. Because the total number of alarms only goes up over time (it never goes back down), we can easily use <b>Binary Search</b>. In coding terms, when a smaller starting value overtakes a larger one, we call this an <b>inversion</b>. <hr> <h3>Definition</h3> Let $N$ be the number of stocks and $g$ be the target alarms. First, we sort all stocks by their starting prices $s_i$. Each stock is stored as a pair: $$ E_i = (s_i, u_i) $$ For any guessed day $D$, the new projected price $P_i$ of the $i$-th stock...
### The Core Insight: The State Space is Tiny In many game theory problems, the best strategy is, [A. The Oracle's Curse](https://codeforces.me/gym/682678/problem/A) ================== Author

Full text and comments »

  • Vote: I like it
  • +13
  • Vote: I do not like it

69.
By grecil, history, 18 months ago, In English
[Tutorial] Ternary Mask Dynamic Programming Recently I came across several problems on different platforms that use the seemingly obscure—but actually very intuitive—idea of “Ternary Mask DP.” It’s just like bitmask DP, but instead of each bit representing two states, each digit represents three: 0, 1, or 2. The core idea is simple: convert a number into base 3, so each digit is in {0, 1, 2}. You can generalize this to any k states by using base-k. Here’s a generalized function that encodes any integer n into an m-digit list in base k. It returns a little‑endian array of integers, but you can easily modify it to produce a string or even pack the digits into a base‑10 integer. Reverse the output if you prefer big‑endian order. (See [Endianness](https://en.wikipedia.org/wiki/Endianness).) ```python def encode_base_k(n, m, k): nums = [] while n: n, r = divmod(n, k) nums.append(r) return nums + [0] * (m - len(nums)) ``` Below are three examples. **1) [ABC 404 D – Goin’ to the Zoo](https...
representing two states, each digit represents three: 0, 1, or 2. The core idea is simple: convert

Full text and comments »

  • Vote: I like it
  • +19
  • Vote: I do not like it

70.
By NPsolved.cpp, 11 months ago, In English
Editorial: OPC Good Bye Thank you for taking part in $\textbf{OPC Goodbye 2025}$. This editorial walks through the core ideas and solution strategies behind each problem. We hope it helps you learn something new and refine your approach to competitive programming. If you have any reviews please put them in this [Google Form](https://docs.google.com/forms/d/e/1FAIpQLSeguT9leXrI3tyrmjwhXSfqj4LVF16zE5AIzKx-bcLHJclDRQ/viewform?usp=sharing&ouid=115085258461331858898). Contest Link: [Link](https://codeforces.me/group/hUywLYmr80/contest/660904) ### [A. Make It Organised](https://codeforces.me/group/hUywLYmr80/contest/660904/problem/A) <spoiler summary="Hint 1"> For each position, think: *how many times do I divide this number by 2 until it becomes the parity I need (even/odd)?* If it never reaches that parity, this pattern is impossible. </spoiler> <spoiler summary="Solution"> We observe that there are only two possible valid arrangements of parities in the final array: even, odd, ev...
Thank you for taking part in $\textbf{OPC Goodbye 2025}$. This editorial walks through thecore

Full text and comments »

  • Vote: I like it
  • +5
  • Vote: I do not like it

71.
By scott_wu, 11 years ago, In English
8VC Venture Cup Announcement <img src="http://assets.codeforces.com/images/8vc/8vc-venturecup-logo.png" style="float:right;margin:0 1em 1em 1em"/> Hey Codeforces! I’ve worked with Addepar and the broader 8 | family of companies in Silicon Valley throughout 2014 and 2015, and it’s been an excellent experience. I would encourage everyone in the community to learn more about the great work that these companies are doing and I’m happy to announce that 8 | Partners will be hosting the 8 | VC VentureCup on Codeforces! It’ll be a fun contest and I’ve worked on the problems along with a few competitive programmers in our network. The contest will begin on February 13 and consist of two rounds. ##### ABOUT 8 | PARTNERS <a href="http://eight.vc/">8 | Partners</a>, which consists of Joe Lonsdale (co-founder of Palantir) and his core team from Formation | 8, is a Silicon Valley venture capital firm that invests in industry-transforming technology companies. The team's investment portfolio includes companies suc...
Palantir) and his core team from Formation | 8, is a Silicon Valley venture capital firm that invests

Full text and comments »

  • Vote: I like it
  • +477
  • Vote: I do not like it

72.
By sigma__1, history, 7 months ago, In English
Editorial for CodeRed Prelims 2026 On behalf of the organizing team, we extend our deepest gratitude to everyone who participated in CodeRed Prelims 2026. Witnessing your dedication and fierce competitive spirit on the leaderboard validated the immense effort our team invested behind the scenes. Our problem-setters spent countless hours crafting and balancing these challenges. We sincerely hope the problemset provided a rewarding and engaging experience for the IIIT Allahabad community and our global participants. Below, you will find the official hints, detailed editorials, and author solutions. Happy upsolving! A: Ashutosh's Triad ---------------------- Author: [user:sigma__1,2026-04-16] <spoiler summary="Hint 1"> The phrase "minimize the maximum salary" is a classic indicator that we should use Binary Search on the answer. </spoiler> <spoiler summary="Hint 2"> Since $X$ is square-free, the maximum number of distinct prime factors $m$ is very small ($m \le 15$). Think about representing each wizard's ...
**1. The Core Identity Reduction** The problem requires us to

Full text and comments »

  • Vote: I like it
  • +13
  • Vote: I do not like it

73.
By Nickolas, 8 years ago, In English
Announcement: Microsoft Q# Coding Contest — Summer 2018 Microsoft's Quantum Team has good news for quantum enthusiasts and coders looking for new challenges. We are excited to announce Microsoft Q# Coding Contest &mdash; Summer 2018! By entering the contest, you can hone your quantum coding skills by tackling problems of varying difficulty and implementing solutions in the quantum programming language Q#. Winners will receive a Microsoft Quantum T-shirt! Quantum computing is a radically different computing paradigm compared to classical computing. Indeed, it is so different that some tasks that are believed to be classically intractable (such as factoring integers, computing discrete logarithms on elliptic curves, or simulating physical systems) can be performed efficiently on a quantum computer. Microsoft recently introduced the Quantum Development Kit which includes Q# &mdash; a new programming language to express quantum programs in a way that makes it easier for classical coders to enter the space. Q# integrates into [Visual Studi...
](https://tio.run/#qs-core) * [Quantum Computing: Lecture Notes by Ronald de Wolf](https

Full text and comments »

  • Vote: I like it
  • +413
  • Vote: I do not like it

74.
By abdude824, 5 years ago, In English
Operating Systems Notes If you are struggling with the right track and a 10-min read for Operating systems from beginning to end, you're at the right place. Even I am not sure where to start, but we would figure it and if you are reading this, I have successfully completed these notes or at least am on right track. Let's start our struggle for OS: ### The Track I found many resources to learn, let's just list all: (Galvin Concise PPTs)[https://www.os-book.com/OS9/slide-dir/index.html]: These were great but I felt that these are a little bit too much, so here are the chapters we would do: 1. Processes 2. Threads 3. Process Synchronization 4. CPU Scheduling Algorithms 5. Deadlocks 6. Main memory 7. Virtual memory 8. Virtual Machines > I am skipping the introduction of OS for now as it was not that important, this is going to be a fast article that works like a last night dose. <spoiler summary="A simple introduction(May skip if you are already familiar)"> An Operating system is like a...
solution to the above problem. In this we do not wait for the process to completely execute, we, problem. In this we do not wait for the process to completely execute, we just unassign the process when

Full text and comments »

  • Vote: I like it
  • +160
  • Vote: I do not like it

75.
By Gerald, 13 years ago, translation, In English
Coder-Strike 2014: Qualification Round (Tutorial) ### [problem:411A] In the first problem you should correctly implement what was written in statement. It could be done like this: string s; cin >> s; bool upper = false, lower = false, digit = false; for(int i= 0; i < s.size(); ++i){ if(isupper(s[i])) upper = true; if(islower(s[i])) lower = true; if(isdigit(s[i])) digit = true; } puts((upper && lower && digit && s.size() >= 5) ? "Correct" : "Too weak"); ### [problem:411B] In this problem you should read the statement carefully, consider some principal cases and implement them in your program. The author's solution is: 1. We will store array$blockedCell[]$ (value in cell $i$ equals $1$ if this cell is blocked, $0$ otherwise), blockedCore[]$ (value in cell $i$ equals $0$, if this core is not blocked and the number cycle when this core is blocked otherwise). 2. Consider all cycles from the first to the last. Consider the cycle nu...
### [problem:411A] In the first problem you should correctly implement what was written in

Full text and comments »

  • Vote: I like it
  • +34
  • Vote: I do not like it

76.
By vishwas_16.0, history, 9 months ago, In English
Editorial - Codeguerra Editorial &mdash; Codeguerra ================== [contest:663321] ------------------ [Problem A : Hawkins Rift](https://codeforces.me/gym/663321/problem/A) <br> Author : [user:vishwas_16.0,2026-01-30] <spoiler summary="Hint 1"> Notice that the rift at index $n$ is always stable, because $a_n \le n$ for every possible value.</spoiler> <spoiler summary="Hint 2"> $n$ can be as large as $10^{18}$. Do we really need to compute factorial up to that value? Think about the modulus $69696$ </spoiler> <spoiler summary="Solution"> We want arrays where after choosing exactly one index $i$ and setting $a_i=i$, there is exactly one stable rift ($a_i \le i$). All other positions must be unstable $\Rightarrow a_j > j$. Since position n is always stable eleven has no choice but to chose it. There are total of n different values for last index $\rightarrow n$ ways. Number of choices for rest: <ul> <li>Index 1 $\rightarrow (n-1)$ choices</li> <li>Index 2 $\rightarrow (n-2)$ choi...
Core Logic: **Chicken McNugget Theorem** By the Chicken McNugget, Editorial — Codeguerra ================== [contest:663321] ------------------ [ Problem A

Full text and comments »

  • Vote: I like it
  • +9
  • Vote: I do not like it

77.
By KAN, 10 years ago, In English
8VC Venture Cup 2017 — Final Round and Codeforces Round #393 Hi all, The [contest:756] is tommorrow at [18:05 UTC](https://www.timeanddate.com/worldclock/fixedtime.html?msg=8VC+Venture+Cup+2017+-+Final+Round&iso=20170122T2105&p1=166&ah=2). Along with that, Codeforces Round #393 will be held at the same time both for Div. 1 and Div. 2 participants. The Div. 1 Edition will contain the same problems as the Final Round, the Div. 2 Edition will be easier. Of course, those who have placed in top 200 in [contest:755] should register for the Final Round, all the others should register for Div. 1 or Div. 2 editions according to their rating. All three contests will contain six problems, last two hours and be rated. The problem authors are [user:Um_nik,2017-01-21], [user:Endagorion,2017-01-21], [user:Umqra,2017-01-21], ~pashka,2017-01-21 and me. Also huge thanks to ~fcspartakm,2017-01-21 for his help in preparation, and to ~vepifanov,2017-01-21 and ~AlexFetisov,2017-01-21 for testing the round. I suggest you reading all the problems to find which...
contests will contain six problems, last two hours and be rated. The problem authors are

Full text and comments »

  • Vote: I like it
  • +204
  • Vote: I do not like it

78.
By ADJA, history, 7 years ago, In English
Unofficial AtCoder Translations on GitHub Hello, hope you all are well and doing fine! Recently, I've been solving some old AtCoder problems that are only available in Japanese (with Google Translate and a lot of guessing). Problems are really nice, so I decided to put short English translations of them on GitHub. Nothing fancy, just several sentences describing the core part of each problem. There are 10 translated problems so far: [https://github.com/ADJA/AtCoderTranslations](https://github.com/ADJA/AtCoderTranslations#contribute) (current problems are in the 2100–2400 difficulty range) #### Contribute? **How you can help**: There are ~382 untranslated problems from the early AtCoder Beginner and Regular contests left, so I encourage you all to contribute! No Japanese required. It takes about 5-10 minutes for each problem (please solve the problem first if you don't speak Japanese), and can be done right from the GitHub web interface. Please see contributing section in the README for more information: ...
several sentences describing the core part of each problem. There are 10 translated problems so far, translations of them on GitHub. Nothing fancy, just several sentences describing thecore part of each

Full text and comments »

  • Vote: I like it
  • +102
  • Vote: I do not like it

79.
By Sarvesh0955, history, 13 months ago, In English
CodePlus Long 2025 Editorial Welcome to the Editorial of CodelPlus Long 2025. CodePlus Long Contest is a 2-day coding competition featuring a mix of educational and challenging problems. It allows participants to learn, practice, and compete to enhance their problem-solving skills. You can attempt the contest [here](https://codeforces.me/contestInvitation/940e1bd9749a95d26fbca52cd74512d1b505f65e). (Many Original and Challenging problems, you can give it a try :) ) The problems were authored and prepared by [user:pranavsingh0111,2025-10-14],[user:Sarvesh0955,2025-10-16],[user:Ragnar21,2025-10-16],[user:rndascode,2025-10-16],[user:ankitgarg2105,2025-5-14],[user:utk_09,2025-8-14]. We would also like to thank, [user:Rishabh_king,2025-10-16] for testing. Author : [user:Sarvesh0955,2025-10-14] <spoiler summary="Problem A"> This problem can be solved in several ways; one approach is as follows: --- ### Graph Construction Construct a new graph ( **nodes n+1 to 2n** ) where all edge weights ar...
The core idea is that a number x can be formed if and only if the

Full text and comments »

  • Vote: I like it
  • +6
  • Vote: I do not like it

80.
By scott_wu, 11 years ago, In English
8VC Venture Cup 2016 — Final Round Hello everyone! The final round of the 8VC Venture Cup will be held on [Feb/28/2016 18:10 (UTC)](http://www.timeanddate.com/worldclock/fixedtime.html?day=28&month=2&year=2016&hour=21&min=10&sec=0&p1=166). [user:ecnerwal,2016-02-28] and I are the problem setters. We want to thank [user:GlebsHP,2016-02-28] and [user:vnovakovski,2016-02-28] for help in preparing the contest, [user:stella_marine,2016-02-28] for fixing the statements, and [user:MikeMirzayanov,2016-02-28] for creating the Codeforces platform. The contest is by invitation only to the top 200 contestants and top local contestants from Round 1 and contains six problems. We will also hold rated, out-of-contest participation for both div1 and div2 contestants — all three groups will feature slightly different problemsets. Local contestants will compete onsite in Silicon Valley. OpenGov, one of the featured 8 | VC companies, has been generous to host this competition at their offices; see more details about this awesome com...
&p1=166). [user:ecnerwal,2016-02-28] and I are the problem setters. We want to thank [user:GlebsHP

Full text and comments »

  • Vote: I like it
  • +165
  • Vote: I do not like it

81.
By -is-this-fft-, history, 2 years ago, In English
PSA on Meta Hacker Cup (must read if its your first time!) Meta Hacker Cup is upon us again. Along with it comes the unique format where we have to run our code on large test cases ourselves. Unfortunately, past experience shows that not everyone knows how to do this reliably. Usually, after the first round, many people lose points as a result of an unreliable workflow. This time, let's try to prevent that from happening. Sorry for the somewhat self-important title, but I really do wish that everyone understood this and that no one will fail the contest because of this. ### Don't EVER copy-paste huge files A lot of people's workflow to run a solution is the following: - Click some green button in the IDE - A box comes up, copy-paste the input into that box - The output shows up somewhere This may work well for running your solution on small sample test cases. It is **terrible** for running your solution on the huge test cases in Meta Hacker Cup. In last year's Round 1, the full test case for [problem C](https://www.facebook.com...
Meta Hacker Cup. In last year's Round 1, the full test case for [problem C](https

Full text and comments »

  • Vote: I like it
  • +310
  • Vote: I do not like it

82.
By adamant, history, 3 years ago, In English
Implementing Dinitz on bipartite graphs Hi everyone! if you read about [Dinic algorithm](https://cp-algorithms.com/graph/dinic.html) on CP-Algorithms, especially the [section](https://cp-algorithms.com/graph/dinic.html#unit-networks) about how it works on unit networks, you'll notice that its supposed runtime for bipartite matching is $O(E \sqrt V)$, where $E$ is the total number of edges, and $V$ is the total number of vertices of a bipartite graph. Let's try it out on the following problem: **[Library Checker &mdash; matching on Bipartite Graph](https://judge.yosupo.jp/problem/bipartitematching)**. Given a bipartite graph with $V, E \leq 2 \cdot 10^5$, find the maximum matching. The implementation of the Dinitz algorithm that I typically use looks as follows: <spoiler summary="code"> ```cpp struct unit_network { int n; vector<int> to, cap; vector<vector<int>> g; unit_network(int n): n(n), g(n) {} void add_edge(int a, int b, int cp) { g[a].push_back(size(to)); ...
a bipartite graph. Let's try it out on the following problem: **[Library Checker — matching

Full text and comments »

  • Vote: I like it
  • +245
  • Vote: I do not like it

83.
By Roshan.029, history, 18 months ago, In English
What’s Better: Solving Lots of Problems or Solving Quality Problems? In the world of programming, especially competitive coding or technical interviews, there's always one big question: Should I solve hundreds of problems, or focus on fewer but more insightful ones? **Quantity Teaches Patterns** Solving a lot of problems exposes you to a variety of problem types, tricks, and edge cases. It builds intuition over time. You start recognizing patterns faster, and brute force becomes your debugging tool rather than your go-to strategy. But here's the catch: if you’re solving 50 easy problems the same way without understanding why the solution works or fails, you’re just spinning your wheels. **Quality Builds Depth** On the other hand, solving fewer but quality problems forces you to go deep. These are the problems that make you think, get stuck, revisit your approach, and finally understand the core concept behind them. One well-understood dynamic programming or graph problem can teach you more than 20 surface-level ones. This is the type of l...
understand the core concept behind them. One well-understood dynamic programming or graphproblem can, ? **Quantity Teaches Patterns** Solving a lot of problems exposes you to a variety ofproblem

Full text and comments »

  • Vote: I like it
  • +48
  • Vote: I do not like it

84.
By timeisvaccum, history, 3 months ago, In English
The Paradox of Originality: When Automated Judges Punish Optimal Logic Competitive programming relies on a simple social contract: 1. I solve the problem. 2. I submit my code. 3. I accept the verdict. But what happens when the judge tells you that your solution "significantly coincides" with dozens of strangers you have never met or know? This is exactly what happened to me in a recent Div. 1 contest. I solved two problems independently. I did not use AI, I did not communicate with anyone, and I did not share my code. Yet, both of my submissions were skipped, accompanied by a system warning listing numerous contestants whose code apparently mirrored mine. My first reaction wasn't anger. It was confusion, followed by the realization of a profound, structural contradiction in how we enforce academic integrity in algorithmic competitions. I am writing this not to attack Codeforces, nor to ask for special treatment &mdash; I am publishing this openly because I have nothing to hide. But I want to talk about something much bigger: the inherent pa...
**3. The Complexity Inevitability (The Kolmogorov Problem)** For highly restricted problems, the, Problem)** For highly restricted problems, the required core logic is often under 20 lines. In

Full text and comments »

  • Vote: I like it
  • -123
  • Vote: I do not like it

85.
By ExplodingFreeze, history, 7 years ago, In English
How many "simple" operations can you run on Codeforces in a second? Tl;dr &mdash; Assuming negligible cache misses, how many simple operations (reading/setting array values, comparing integers, addition, subtraction, multiplication) can you perform in a second on Codeforces? So recently I was trying [problem:1303E] and I realized that my code which appeared to be $ N^{4} $ ran extremely quickly in custom test for inputs with $ N = 400 $, so I ended up submitting it and got accepted in just 650ms &mdash; [submission:79311246]. While at first glance it appears as if it the loop would run $ N^{4} $ times ($ 2.5 * 10^{10}$ times at worst), you can show it will run much faster than that, actually taking $ \sum_{i = 1}^{\left | t \right |} (i + 1)(\left | t \right | - i + 1)(\left | s \right | - \left | t \right | + 1) $ operations. Simplyifying this we get $ \frac{1}{6}(\left | s \right | - \left | t \right | + 1)(\left | t \right |^{3} + 6 * \left | t \right |^{2}) $. Maximizing $ \left | s \right | $ and throwing this equation into [Wolfram Al...
Codeforces? So recently I was trying [problem:1303E] and I realized that my code which appeared to

Full text and comments »

  • Vote: I like it
  • +41
  • Vote: I do not like it

86.
By A2SV_Group6, history, 18 months ago, In English
A2SV G6 — Round #14 (Editorial) [Here](https://codeforces.me/gym/608931) is the contest link. #### [A. Funny Game](https://codeforces.me/gym/608931/problem/A) <spoiler summary = "Hint"> 1 sounds like the minimum value we can get. Why? Is it always true? </spoiler> <spoiler summary = "Solution"> When n ≤ 2, we can do nothing. When n ≥ 3, since , n - 1 isn't a divisor of n, so we can choose it and get 1 as the result. </spoiler> <spoiler summary="Code"> ```python3 n = int(input()) if n == 2: print(2) else: print(1) ``` </spoiler> #### [B. Metshaf Exchange](https://codeforces.me/gym/608931/problem/B) <spoiler summary="Problem Summary"> You're given a permutation p of n elements. Each person i gives their item to p[i]. The process continues daily. For each person, compute the number of days it takes to get their own item back. This is equivalent to finding the length of the cycle each element is part of </spoiler> <spoiler summary="Hint 1"> Can u check the con...
To solve the problem efficiently, we can use the **Disjoint Set, ://codeforces.com/gym/608931/problem/A) 1 sounds like the minimum value we

Full text and comments »

  • Vote: I like it
  • -5
  • Vote: I do not like it

87.
By ImJettMain, history, 11 months ago, In English
Clarification Regarding Problem 2170F # Appeal Regarding Plagiarism Flag: Submission [351054331] **To the Administration/Judge,** I am writing to formally appeal the plagiarism flag on my submission **[351054331]** for problem **2170F**. While I acknowledge that my solution coincides with a list of other users, I want to state clearly and unequivocally that I wrote this code independently. The reason so many people (including myself) wrote nearly identical code is that this problem requires a very specific, standard optimization technique known as **"Offline Queries with Rightmost Index DP."** Here is a detailed breakdown of exactly why my code ended up looking like others: ### 1. The "Offline Query" Boilerplate Since the problem asks about ranges, the standard, most efficient method is to process the queries "offline." This involves iterating through the array once (from index $1$ to $N$) and handling all queries ending at the current index $R$. My code does exactly this: > vector<Query> qryAt[MAXN];...
Clarification Regarding Problem 2170F, am writing to formally appeal the plagiarism flag on my submission **[351054331]** forproblem, ### 2. The "Rightmost Index" Trick The core difficulty of this problem is checking if a subset

Full text and comments »

  • Vote: I like it
  • -33
  • Vote: I do not like it

88.
By TrainingMachine, history, 10 years ago, In English
What are your favorite problems on codeforces? For coders who have learned computer science for years, there should be many hard problems you encountered in Codeforces. However, only some of them are memorable. Each of those problems became a vertebrae in the whole backbone which you lean on to solve other problems e.g. When I encountered [this problem](http://www.spoj.com/problems/MKTHNUM/) on spoj, I learned the idea about how to apply persistent segment tree and binary search on find k-smallest number => it helps me a lot, for example, in solving the problem E in Regional acm icpc 2016 in Bangkok. Because there are tons of problems on codeforces and core problems are not that plenty, I want to create a blog that sum up as many core problems as possible to help learners, from juniors to seniors, to shorten the time spending on finding good problems. So, please comment some problems that, in your perspective, are core problems. Thank you!!! ![ ](http://codeforces.me/predownloaded/92/7a/927ac1a9a29a893eeb9cd69b589125...
Because there are tons of problems on codeforces and core problems are not that plenty, I want to, So, please comment some problems that, in your perspective, are core problems., problem](http://www.spoj.com/problems/MKTHNUM/) on spoj, I learned the idea about how to apply

Full text and comments »

  • Vote: I like it
  • +56
  • Vote: I do not like it

89.
By saanTH, history, 4 months ago, In English
Everyday Apps You Use That Are Secretly Running Graph Algorithms Open your phone right now. Maps, Instagram, Spotify, LinkedIn, Uber — whatever you tap on, there's a good chance a graph is quietly doing the heavy lifting behind the scenes. In competitive programming, graphs are just nodes and edges you traverse with BFS, DFS, or Dijkstra. In the real world, those same nodes and edges represent people, places, songs, and rides — and the algorithms running on them are worth billions of dollars. **Here are 5 apps you probably used today that are secretly graph problems in disguise.** **** **** **1. Google Maps / Waze — Shortest Path Algorithms** **** The graph: Every intersection is a node. Every road segment is an edge, weighted by distance, speed limit, and live traffic. The algorithm: A modified version of Dijkstra's algorithm or A* search — the same algorithm you'd use to solve a "shortest path" problem on a competitive programming judge. The twist is that edge weights change in real time based on traffic data from millions of phones, so...
CP problem and one of these real systems isn't really the algorithm — it's scale. Thecore idea, The difference between a CP problem and one of these real systems isn't really the algorithm — it's

Full text and comments »

  • Vote: I like it
  • -11
  • Vote: I do not like it

90.
By -is-this-fft-, history, 4 years ago, In English
[Tutorial] FFT If I was a YouTuber, this would be the place where I fill the entire screen with screenshots of people asking me to make this. Anyway, not so long ago I gave a lecture on FFT and now [user:peltorator,2023-01-11] is giving away [free money](https://codeforces.me/blog/entry/110840), so let's bring this meme to completion. In this blog, I am going to cover the basic theory and (competitive programming related) applications of FFT. There is a long list of generalizations and weird applications and implementation details that make it faster. Maybe at some point I'll write about them. For now, let's stick to the basics. **The problem.** Given two arrays $a$ and $b$, both of length $n$. You want to quickly and efficiently calculate another array $c$ (of length $2n - 1$), defined by the following formula. $$c_k = \displaystyle \sum_{i + j = k} a_i \cdot b_j.$$ Solve it in $O(n \log n)$. First of all, why should you care? Because this kind of expression comes up in combinatorics a...
, let's stick to the basics. **The problem.** Given two arrays $a$ and $b$, both of length $n$. You

Full text and comments »

  • Vote: I like it
  • +436
  • Vote: I do not like it

91.
By graknlabs, 6 years ago, In English
Grakn Forces 2020 “Codeforces… assemble!” <center> <img alt="grakn" src="https://grakn.ai/assets/svg/logo.svg" style="float:right; height: 50px; margin: 10px; max-width:10%;"/> </center> We are thrilled to announce **Grakn Forces 2020**; hosted by Codeforces and sponsored by [Grakn Labs](https://vaticle.com/). Thank you to Codeforces for providing a world-class competition structure to partner with. We can’t wait to see what you all are capable of. This international competition consists of 1 round, lasting 2.5 hours. The contest will comprise 7-9 problems and will be in accordance with classic Codeforces rules. **Prizes:** - 1st place = 500 euros - 2nd place = 250 euros - 3rd place = 100 euros **Additional Prizes:** Top 50 receive: _Grakn Labs swag pack:_ - Stickers - Grakn Labs t-shirt Random 50 from 51-250 receive: _Grakn Labs swag pack:_ - Stickers - Grakn Labs t-shirt **About Grakn Labs** [Grakn Labs](https://github.com/graknlabs) is a team...
://github.com/graknlabs), while Grakn comes in two forms: Grakn Core — which is also open-source, and

Full text and comments »

Announcement of Grakn Forces 2020
  • Vote: I like it
  • +464
  • Vote: I do not like it

92.
By ICPCNews, 4 years ago, In English
45th ICPC World Finals Challenge powered by Huawei <img src="/predownloaded/af/22/af228fee1abb015217d8c524de74898aeff36419.png" align="right" style="height: 300px;" alt="text"/> Hello, Codeforces! **UPD:** Challenge is over. You can find result [by this link](https://codeforces.me/blog/entry/109841) We are happy to invite you to the great event the **45th ICPC World Finals Challenge powered by Huawei**,which will start on [November 17, 2022, 00:00 UTC (UTC+0)](https://www.timeanddate.com/worldclock/fixedtime.html?msg=ICPC+World+Finals+Challenge+powered+by+Huawei&iso=20221117T00&p1=1440). In this Challenge, You will have a unique chance: - to compete during **14 days online challenge**; - to solve **1 or 2 problems** prepared by different business domains of HUAWEI; - to win amazing prizes from HUAWEI! As a special prize, HUAWEI together with ICPC Foundation will provide the travel trip to the 46th Annual ICPC World Finals in a guest role to the 2 winners (1 winner for each problem)! Everybody is welcome to part...
Finals in a guest role to the 2 winners (1 winner for each problem)! Everybody is welcome to, This is a problem about job scheduling and data assignment. Consider a scenario, where we want to

Full text and comments »

  • Vote: I like it
  • +223
  • Vote: I do not like it

93.
By mohit07dec, 17 months ago, In English
Codeforces Round 1032 (Div. 3) — Problem Intuitions # Codeforces Contest — Problem Intuitions --- ## Problem A — Letter Home Given a sorted array of positions and a starting point, you must reach both ends of the array in the minimum number of steps. **Optimal Strategy:** - Move to the nearest boundary (either the smallest or largest position). - Then traverse the entire array to the opposite end. - The answer is: `abs(max_x - min_x) + min(abs(s - min_x), abs(s - max_x))` **Why:** You must visit both ends, so always minimize the initial distance to the closest end. --- ## Problem B — Above the Clouds **Core Idea:** Partition the string into three non-empty substrings `a`, `b`, `c` such that `b` is a substring of `a+c`. **Key Insight:** - For every possible split, check if the middle part (`b`) appears as a substring in the concatenation of the first and third parts (`a+c`). **Approach:** - Iterate over all valid split points. - For each, check the substring condition. - Output "Yes" if a...
Codeforces Round 1032 (Div. 3) — Problem Intuitions, minimize the initial distance to the closest end. --- ## Problem B — Above the Clouds **Core, **Core Idea:** Partition the string into three non-empty substrings `a`, `b`, `c` such that `b, **Core Idea:** You can decrease all elements in a chosen row and column by 1. Find the minimal

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it

94.
By Monyura, 12 years ago, translation, In English
Looksery Cup Hello everybody!<br><br> Our company wants to say thanks to Codeforces and congratulate it with the 5 years birthday:)<br><br> A year and a half ago I and the team ([user:Sfairat,2015-01-01], [user:olpetOdessaONU,2015-03-03], [user:Sklyack,2015-03-03]) met Victor Shaburov and became co-founders of [Looksery](http://looksery.com). We work in Computer Vision and Augmented Reality areas.<br> On behalf of all our collective I want to say thanks to [user:MikeMirzayanov,2015-03-03] and Codeforces team, you do a great matter, and I'm sure it will have a huge impact on the IT segment of the nearest future. To tell the truth, I don't know how we would be able to solve the problems that we had at the beginning of Looksery path if there were no Codeforces or ACM ICPC in our lives.<br> I would like to tell a few words about our organization, clarifying my opinion about popular [topic](http://codeforces.me/blog/entry/17302) of the last few days about competitive programming and "real" job.<br...
competitive programmers work on the "core" functionality, but you can also find them in each of the, . In Looksery, most of the competitive programmers work on the "core" functionality, but you can

Full text and comments »

  • Vote: I like it
  • +232
  • Vote: I do not like it

95.
By Proof_by_QED, 8 months ago, In English
Nebius Round 2 (Codeforces Round 1088, Div. 1 + Div. 2) # Hello Codeforces _After countless nights of yapping, bedfight duels, and failed zero cycles_ The authors of the [three](https://codeforces.me/contest/2124) [best](https://codeforces.me/contest/2190) [Div. 1](https://codeforces.me/contest/2201) of all time, [user:nifeshe,2026-03-18], [user:chromate00,2026-03-18], and I, have joined forces to create the Division $1+2$ round that will break the internet: [contest:2211], which will be held on [contest_time:2211]. This round will be combined for Division $1$ and Division $2$ and will be rated for everyone. You will have $2.5$ hours to solve $8$ problems. Between $6$ and $7$ problems will not be split into subtasks. Also, between $6$ and $7$ problems will not be interactive, so you are recommended to read the [guide](https://codeforces.me/blog/entry/45307) to interactive problems if you have not encountered them before. We would like to thank the following people for making the contest possible: - [user:Um_Nik,2026-03-2...
, contribute to building AI infrastructure, and grow into core members of our team. If you are

Full text and comments »

  • Vote: I like it
  • +180
  • Vote: I do not like it

96.
By Tabriz-Talayi, history, 2 months ago, In English
609E — MST for Each Edge: Using a Kruskal Property Without LCA **Context:** <br> I recently learnt MST and reached this problem ([problem:609E]). I was stuck on it for like 2 days, and I only managed to come up with an $O(m\log m + mn)$ solution, which will obviously TLE. I decided to read some of my teachers'/friends'/top coders' codes to get some idea, but they all used some kind of heavy algorithm I haven't learnt yet (mostly LCA). I was ready to give up on the problem; I decided to hand-run the current algorithm I had one more time to look for improvements before giving up, and fortunately during hand-running I noticed a key property in the Kruskal algorithm which led to me coming up with an extremely clean sol. <br> It solves the problem in $O(m\log m + (n + m\log n)\log n)$ and uses the core [Kruskal Algorithm](https://cp-algorithms.com/graph/mst_kruskal.html) plus a vector-based [StoL DSU](https://codeforces.me/blog/entry/67696). <br> IDK if this is a well-known property or not, but after checking some submissions, I'm sure it's not ...
**Context:** I recently learnt MST and reached this problem ([problem:609E]). I was stuck on

Full text and comments »

  • Vote: I like it
  • +8
  • Vote: I do not like it

97.
By Karan2116, history, 11 years ago, In English
Everything About Dynamic Programming **I decided to gather some good material on the web related to DP and found some good explanation by svg on topcoder forums..Hence wrote this blog.Will format it when i get time.** ![ ](http://codeforces.me/predownloaded/2c/af/2caf058ab9cf6db0f875c573fb0d6e73de572122.png) **Problem:** About 25% of all SRM problems have the "Dynamic Programming" category tag. The DP problems are popular among problemsetters because each DP problem is original in some sense and you have to think hard to invent the solution for it. Since dynamic programming is so popular, it is perhaps the most important method to master in algorithm competitions. The easiest way to learn the DP principle is by examples. The current recipe contains a few DP examples, but unexperienced reader is advised to refer to other DP tutorials to make the understanding easier. You can find a lot of DP examples and explanations in an excellent tutorial Dynamic Programming: From novice to advanced by Dumitru. The purpose ...
://codeforces.com/predownloaded/2c/af/2caf058ab9cf6db0f875c573fb0d6e73de572122.png) **Problem, But there are redundant operations in such a solution. Notice that the core part of transition

Full text and comments »

  • Vote: I like it
  • +90
  • Vote: I do not like it

98.
By chumeng, history, 11 months ago, In English
Introduction to XCPC statement generator -- A Web-Based XCPC-style Contest Statement Generator Introduction ------------------ XCPC Statement Generator is an open-source, browser-based application designed specifically for creating XCPC-style contest statements. Built with React, TypeScript, and powered by Typst (a modern typesetting system), this tool allows contest organizers to edit problem statements from various formats(Markdown, LaTeX and Typst) and export them as formatted PDFs that closely mirror the style of major competitive programming competitions in China (or competitions that use olymp.sty to create contest statements). ![screenshot](/predownloaded/10/c6/10c6c4828a559d1e4157a11135bde659bfd87816.png) You can try XCPC Statement Generator on [This Website](https://xcpc-statement-generator.netlify.app/), or get the source code on [GitHub](https://github.com/lihaoze123/xcpc-statement-generator) Features ------------------ - Pure Browser-Based Operation: It runs entirely in your browser, simply open the web application. - Support Polygon Packages: The too...
problem statements from various formats(Markdown, LaTeX and Typst) and export them as formatted PDFs

Full text and comments »

  • Vote: I like it
  • +120
  • Vote: I do not like it

99.
By SANYASI_RAJA, 17 months ago, In English
CSES — Sliding Window Editorial Some of the most powerful techniques are also the simplest yet identifying when and how to apply them effectively can be challenging. Sliding window is one such method. Sliding window helps solve problems involving sequences, subarrays, or continuous segments by efficiently tracking changes as the window moves forward. While tackling the CSES Sliding window problems, I noticed that many seemingly complex tasks like tracking the sum of elements in a dynamic segment, finding a subarray's minimum or maximum, or counting distinct elements can be simplified and optimized with this technique. Initially, one might consider brute-force methods iterating over every possible subarray or recomputing values from scratch. However, the core idea behind sliding window is smartly updating the state of the window rather than recalculating everything each time. In my experience, the primary challenge while solving these problems came down to accurately managing the data structures supporting the w...
. However, the core idea behind sliding window is smartly updating the state of the window rather than

Full text and comments »

  • Vote: I like it
  • +5
  • Vote: I do not like it

100.
By ICPCNews, 4 years ago, In English
ICPC 2022 Online Challenge powered by HUAWEI <img src="/predownloaded/af/22/af228fee1abb015217d8c524de74898aeff36419.png" align="right" style="height: 300px;" alt="text"/> Hello, Codeforces! We are happy to invite you to an exciting online event: **ICPC 2022 Online Challenge powered by HUAWEI**,which will start on **[September 15, 2022, 00:00 UTC (UTC+0)](https://www.timeanddate.com/worldclock/fixedtime.html?msg=ICPC+2022+Online+Challenge+powered+by+HUAWEI&iso=20220915T00).** In this Challenge, you will have a unique chance: - to compete for **2 weeks online** during the challenge - to solve **1 or 2 problems** prepared by different business domains of HUAWEI - to win amazing prizes from HUAWEI! As a special prize, HUAWEI together with ICPC Foundation will provide the travel trip to the 46th Annual ICPC World Finals in a guest role to the 2 winners (1 winner for each problem)! **Everyone is welcome to participate. It is an individual competition.** **ICPC 2022 Online Challenge powered by HUAWEI** (open to t...
Finals in a guest role to the 2 winners (1 winner for each problem)! **Everyone is welcome to

Full text and comments »

  • Vote: I like it
  • +260
  • Vote: I do not like it

101.
By adamant, history, 18 months ago, In English
Complex FFT is not as bad as you think ... Probably. Hi everyone! As some of you _might_ already know, I don't like NTT. Primary reasons for this are: - I don't like modular arithmetic optimizations (Montgomery, etc). - I don't like NTT mods, and prefer good, old $10^9+7$. - I do like algebra of complex numbers. But, to my regret, the overwhelming mainstream in modern competitive programming is NTT. Primary reasons are: - It's allegedly faster. - It needs less memory. - It has no precision issues. - People don't like algebra of complex numbers. There is nothing I can do about the last, but today I'll address the first 3. Optimizing complex FFT was on my mind for quite some time, but I didn't really work on it _that much_ until the [blog](https://codeforces.me/blog/entry/142063) by [user:Qwerty1232,2025-04-24] on optimizing NTT has dropped, which motivated me to actually put some serious effort into this. In this blog, we will primarily focus on optimizations that are specific to complex arithmetic...
://judge.yosupo.jp/problem/wildcard_pattern_matching) runs in **[only 5 ms](https://judge.yosupo.jp/submission

Full text and comments »

  • Vote: I like it
  • +731
  • Vote: I do not like it

102.
By galen_colin, 3 years ago, In English
THE OPTIMAL PRACTICE STRATEGY (**NOT CLICKBAIT**) Spoiler: it's clickbait. Sorry. Titles like those are fun. ...but, it's the same style of clickbait as my [roadmap](https://www.youtube.com/watch?v=bSdp2WeyuJY) [spoiler 2: if you haven't seen that, it markets itself as a standard roadmap (y'know, soulless and devoid of purpose), but then a few minutes in, says "ok but roadmaps are stupid and here's the advice that you really need" and completely changes the direction of the video]. That's my style of clickbait, and that's the vibe this blog goes for. [cut] <br><br> So... hear me out, please. The start ------------------ First, a couple meta-notes. I will likely exaggerate my tone a bit here for dramatic effect. Don't take it personally, please. Also, **this applies to almost all ratings**. At the very least, I recommend you process the main point of this blog and see whether or not you already do something similar (for most people... probably not?) The problem ------------------ I'm sure if you've looked at the...
most people... probably not?) The problem ------------------ I'm sure if you've looked at

Full text and comments »

Tags hi
  • Vote: I like it
  • +207
  • Vote: I do not like it

103.
By RussianCodeCup, history, 9 years ago, translation, In English
Russian Code Cup 2017 Elimination Round — Editorial <h2>A. Small Numbers</h2> <p>First of all, find prime factorization of numbers <i>a</i> and <i>b</i>.</p><p>After that you need to notice that if <i>ab</i> is divisible by <i>p</i><sup>2</sup>, (where <i>p</i> is a prime number), it is either possible to divide both <i>a</i> and <i>b</i> by <i>p</i> instantly, or you will need to perform one of the latter two operations first to move one of <i>p</i> factors to the other number, and then divide both by <i>p</i>.</p><p>Obviously, parity of occurrence of prime numbers in the multiple <i>ab</i> remains unchanged in all operations. Therefore we can either remove <i>p</i> factor completely from <i>ab</i> or leave it occurring only once. After removing all primes, lets say the ones left are <i>p</i><sub>1</sub>,&thinsp;<i>p</i><sub>2</sub>,&thinsp;...,&thinsp;<i>p</i><sub><i>n</i></sub>. Let us call multiple of all these numbers <i>d</i>. Important observation is that <i>n</i> can't exceed 14 because multiple of first 15 prime numbers is mor...
> Let us consider two solutions for the problem, that take O(k2·

Full text and comments »

  • Vote: I like it
  • +26
  • Vote: I do not like it

104.
By singhcoder694, 17 months ago, In English
Practice Like It's a Real Contest – Introducing a Time-Bound Codeforces Practice Platform Hey Codeforces community! ------------------------- Like many of you, I'm someone who grinds problems by filtering difficulty ranges on Codeforces, setting a timer on my phone, and diving in. It’s a solid way to practice — but let’s be honest: it doesn’t quite match the adrenaline or pressure of a real contest. No leaderboard. No penalty. No dopamine hit when you solve under time pressure. So, why not bring that contest feeling into our everyday practice? ### Introducing: A Time-Bound CF Practice Platform (v1.0.0) I've built a platform that transforms your regular problem-solving sessions into competitive, time-bound experiences, either solo or with friends. Here's what you can do on it: #### Solo Virtual Contests (with rating filters) - Select your desired rating range and number of questions. - The platform fetches Codeforces problems matching your filter. - You’ll get a contest-like interface with a timer, penalties, and a live scoreboard (even for solo practice!). ...
CF Practice Platform (v1.0.0) I've built a platform that transforms your regularproblem-solving

Full text and comments »

  • Vote: I like it
  • +71
  • Vote: I do not like it

105.
By MidnightCodeCup, 17 months ago, In English
Midnight Code Cup Finals 2025 This weekend concluded the first season of the Midnight Code Cup with a long-awaited 24-hour contest. 29 teams – the best from the qualification round, including the qualification winners **Omogen Heap** – competed on-site in Belgrade, Serbia, on June 7-8. Team **Omogen Heap** jumped into first place around the midpoint of the contest and held the title until the very end. Congratulations to our first Midnight Code Cup champions on their dominant performance! Second place went to team **GoodBye2023**, and **Jinotega** finished in third. <img src="/predownloaded/e9/4e/e94e30de980b4d744d2ab445f30b58727f6a5871.jpg" align="left" style="width: 100%;" alt="Omogen Heap"/> <img src="/predownloaded/29/50/2950dfc71ef7a653721f8eb8830c0d79e3cc43b1.jpg" align="left" style="width: 50%;" alt="GoodBye2023"/><img src="/predownloaded/ab/d2/abd21f99c60852c6891a0ef545fbf8dd30370a93.jpg" align="left" style="width: 50%;" alt="Jinotega"/> <spoiler summary="Finalists"> 1 Omogen Heap: 23125.99 ...
problems and the contest in the comments – and don’t forget to post the cutest solutions toproblem

Full text and comments »

  • Vote: I like it
  • +318
  • Vote: I do not like it

106.
By chubakueno, history, 11 years ago, In English
UVA problem seemingly above the State of the Art I stumbled upon [UVA Summing the Lengths of the Longest Increasing Subsequence of Permutations](https://uva.onlinejudge.org/index.php?option=onlinejudge&page=show_problem&problem=2247), that basically asks for the first three digits of the sum of the LIS lengths over all permutations of length $n$. After trying it or a few days, I gave up and searched for information. It is easy to see that: $$\sum_{w\in permutations(1,2,..,n)} LIS(w)= \mathbb E(LIS(w))\times n!$$ Where $\mathbb{E}$ denotes the expected value. It is easy to manage the logarithm of that number with Stirling's approximation, get the fractional part of the logarithm and exponentiate to get the first digits. Nevertheless the core of the problem lies in computing $\mathbb{E}(w)$ for a random permutation $w$ of length $n$. I have been reading about the topic, and [this paper](http://stanford.edu/~mikep15/mike_math310_report.pdf) gives the estimate $$\mathbb{E}(w)=2\sqrt{n}+cn^{1/6}+o(n^{1/6})$$ Where $c\approx -1.77108$ ...
UVA problem seemingly above the State of the Art, core of the problem lies in computing $\mathbb{E}(w)$ for a random permutation $w$ of length $n$. I

Full text and comments »

  • Vote: I like it
  • +68
  • Vote: I do not like it

107.
By HailOtg, history, 7 weeks ago, In English
Codewarts Editorial Congratulations to all the wizards and witches who participated in Codewarts! Here is the official editorial for all the problems. Round 1 ------------------ <spoiler summary="Problem-A: Tom Riddle's Diary"> <spoiler summary="Hint-1"> Since $N$ is always even, try visualizing the array as $N/2$ non-overlapping pairs of adjacent elements.<br> $(A_1,A_2), (A_3,A_4), \dots$ </spoiler> <spoiler summary="Hint-2"> If every pair must sum to a multiple of $P$, what must the total sum $M$ be a multiple of? Given that numbers must be positive, what is the absolute minimum possible total sum? </spoiler> <spoiler summary="Hint-3"> To build the array, try repeating a simple pair like $(1,P-1)$ for most of the array, and put all the remaining required sum into the very last element. </spoiler> <spoiler summary="Solution"> **When to print NO:** - Because $N$ is even, we can split the array into exactly $N/2$ disjoint pairs. The problem requires every adjacent pai...
**Core Idea** The problem asks for the maximum distance from a given node $v$ to any other, ? **Core Idea** The problem asks for the maximum distance

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it

108.
By adamant, 11 months ago, In English
Finding all primes up to half a billion in 83 ms Hi everyone! I was itching to apply SIMD in another problem, and this time my attention picked the following problem: --- **[Library Checker &mdash; Enumerate Primes](https://judge.yosupo.jp/problem/enumerate_primes)**. You are given $N$, $A$ and $B$. Find $\pi(N)$, and print all $p_{kA + B} \leq N$. It is guaranteed that $N \leq 5 \cdot 10^8$ and that the total number of primes to print is at most $10^6$. --- After some tweaking, I managed ([#336744](https://judge.yosupo.jp/submission/336744)) to reduce my time consumption in this problem to **83 ms** and memory consumption to **25 MiB**, which makes it a top-1 submission on the Library Checker. For comparison, the top-2 solution ([#148169](https://judge.yosupo.jp/submission/148169)) takes 172 ms and 15 MiB, meaning that what I describe here is a 2x improvement in terms of the running time. We can also compare it to what appears to be the state of the art of sieving, the [primesieve](https://github.com/kimwalisch/...
Hi everyone! I was itching to apply SIMD in another problem, and this time my attention picked

Full text and comments »

  • Vote: I like it
  • +375
  • Vote: I do not like it

109.
By pashka, 7 months ago, In English
ACTS 2026.2 in Bremen The best summer school is back! This time in a new country and with a brand new track! ![ ](/predownloaded/28/76/28762d11bd0e2d369d9cb4a93d6cc2f2316ebbc5.jpg) We’re happy to invite you to the upcoming [ACTS in Germany 2026.2](https://lp.jetbrains.com/academy/acts/2026.2/), the best summer camp full of learning, problem-solving, and fun. - Date & location: July 10-20, 2026 at Constructor University, Bremen, Germany - Participants: High school students aged 16-19 - Organizers: Constructor University Bremen, Neapolis University Pafos, with support from the JetBrains Foundation. - Tracks: Competitive Programming & Software Engineering - Costs: Accommodation, meals, and the academic program are fully covered by the organizers. Participants' only costs are travel and a camp fee of 100 EUR. - Entrance Contest: **April 26, 8:00-11:00 UTC**. Competitive Programming track. For students who love algorithms and contests - Teachers: Top coaches, including me ([user:pashka,2026-...
camp full of learning, problem-solving, and fun. - Date & location: July 10-20, 2026 at Constructor

Full text and comments »

  • Vote: I like it
  • +136
  • Vote: I do not like it

110.
By -is-this-fft-, history, 5 years ago, In English
CodeChef virtual contests on Vjudge A week ago, I made [this](https://codeforces.me/blog/entry/90896) blog post. Earlier, I already wrote a small update to the blog, but I wanted to make a separate post to <s>get more contribution</s> properly announce what I did as well as to share my code. Thanks to vjudge's suggestion, there is now a way to participate in CodeChef Cook-Off contests virtually on vjudge. #### How to participate - Go to [the list](https://vjudge.net/contest#category=replay&running=0&title=CodeChef&owner=). - Open a contest by clicking on its name. - Click the "clone" button to create your own private copy of the contest. - Set the "begin time" to the time you'd like to start the contest, somewhere in the future. Keep reading if you want to know how it works. [cut] $~$ #### How it works The contests are so-called _replays_ -- they are generated from the final ranklists (complete with "time of AC" and penalty for every problem and contestant) of the contests. The contest data is downl...
"time of AC" and penalty for every problem and contestant) of the contests. The contest data is

Full text and comments »

  • Vote: I like it
  • +93
  • Vote: I do not like it

111.
By jaipkapoor, history, 17 months ago, In English
Universal C++20 Competitive Programming Template Universal C++20 Competitive Programming Template: A Modern Development Toolkit ═══════════════════════════════════════════════════════════════════════════════ **IMPORTANT DISCLAIMER** ┌─────────────────────────────────────────────────────────────────┐ │ CONTEST INTEGRITY │ ├─────────────────────────────────────────────────────────────────┤ │ │ │ This template is for PRACTICE and LEARNING purposes only. │ │ │ │ ⚠️ NO AI assistance is used during rated contests │ │ ⚠️ All contest submissions are my own work │ │ ⚠️ This template respects competitive programming ethics │ │ │ │ The template contains only standard algorithms and C++ │ │ language features &mdash; no external AI tool...
is not intended to replace the fundamental process of learning algorithms and problem-solving that, - Learning fundamental algorithms and data structures - Developing problem -solving intuition

Full text and comments »

  • Vote: I like it
  • -25
  • Vote: I do not like it

112.
By Ayush687141, history, 5 months ago, In English
My Competitive Programming Journey So Far Hello everyone, I wanted to share some thoughts about my competitive programming journey so far and also seek guidance from more experienced programmers in the community. When I started competitive programming, I had absolutely no idea what programming was really about. I didn't understand problem solving, algorithms, or even how to approach a coding problem. Looking back, I would say it took me nearly six months just to understand what was actually happening. One of the biggest mistakes I made in the beginning was focusing too much on the story of the problem instead of its essence. I would get lost in the narrative and details rather than identifying what the problem was really asking. As a result, even relatively simple problems felt overwhelming. Over time, I slowly realized that every problem is essentially hiding a pattern, observation, or logical requirement behind its story. Once I started looking for the core idea instead of the wording, things began to make much m...
Over time, I slowly realized that every problem is essentially hiding a pattern, observation, or, problem solving, algorithms, or even how to approach a coding problem. Looking back, I would say it

Full text and comments »

  • Vote: I like it
  • -14
  • Vote: I do not like it

113.
By phanquocthai2012, history, 4 months ago, In English
A Question About a Submission in Codeforces Round 1111 (Div. 2) ## The participant I'm referring to is: **Prototype1510** ### Submission https://codeforces.me/contest/2247/submission/383359064 ### Screenshot (https://drive.google.com/file/d/1J3rfKOxOfwAbEAqG06M7-tJRN8EYBJbx/view?usp=sharing) --- Hi everyone! Today, I'd like to hear the opinions of people who participated in this round or solved Problem F. I noticed a contestant whose submission timeline caught my attention. During the contest, they submitted an accepted solution roughly every 30 minutes. They solved only Problems A and B before eventually getting an accepted solution on Problem F, which is a significant jump in difficulty. To better understand how they solved it, I contacted them privately after the contest and politely asked them to explain their solution, including the main idea, the algorithm, and the implementation. However, instead of receiving a technical explanation, the only reply I got was:"like u think" After that response, I honestly ...
solved Problem F, would you normally expect them to be able to explain the core idea afterward, - Does this progression seem unusual to you? - If someone legitimately solved Problem F, would you

Full text and comments »

  • Vote: I like it
  • +27
  • Vote: I do not like it

114.
By adamant, history, 4 years ago, In English
Duality in linear programming. Part 2 — in competitive programming Hi everyone! Previously, I wrote a [general introduction](https://codeforces.me/blog/entry/105049) to linear programming duality. In this blog, I would like to write about several problems that could be solved with this technique. Familiarity with the first blog, or general knowledge of dual problems and how to construct them is generally expected to navigate in this one. Thanks to [user:brunovsky,2022-08-09] and [user:Golovanov399,2022-08-09] for problem suggestions! And particularly special thanks to [user:WeakestTopology,2022-08-09] for problem suggestions and all insightful discussions on the topic! [cut]<br> ### Dual construction mnemonics To simplify the construction of dual problems, let's recall the correspondence between constraints/variables in primal and dual problems. <spoiler summary="LP duality mnemonics"> Standard definition of LP dual problem looks like this: $$\begin{gather} \max\limits_x & c^\top x & \color{red}{\text{(maximization)}} & \ove...
[user:brunovsky,2022-08-09] and [user:Golovanov399,2022-08-09] for problem suggestions! And particularly

Full text and comments »

  • Vote: I like it
  • +169
  • Vote: I do not like it

115.
By mst_molik, 20 months ago, In English
Invitation to Dementia 2025, IIT Mandi Hello folks, As we gear up for our Annual Techfest , Xpecto'25 , we at Kamand Prompt (Programming Club of IIT Mandi) are excited to invite you to Dementia , a competitive programming contest. Dementia offers you a fantastic opportunity to show off your coding prowess and compete against the best in the globe to solve challenging and authentic competitive coding problems. <blockquote>"Step into the realm where logic and art align, Through geometric puzzles and graphs that entwine. With greedy pursuits and strategies deep, Where dynamic dreams and game theories creep. Only the sharpest minds will rise and define!"</blockquote> Registrations are <b>free</b> and open at <a href = "https://forms.gle/LAKggNVNhE27wziu6">this link</a>. <br> Date and Time: Sunday, 30th March, 2025 — 3:00 pm — 5:30pm IST <b>UPD(1) : </b> Expect 8 &mdash; 10 problems in the contest. One of them will be an <b>interactive</b> problem so kindly go through this <a href = "https://codeforces.me/blog/e...
* Problem Setters : [user:Suri429,2025-03-23] , [user:ParasBedi298,2025-03-22, will be an interactive problem so kindly go through this

Full text and comments »

  • Vote: I like it
  • +26
  • Vote: I do not like it

116.
By purplesyringa, history, 6 years ago, In English
crazySegmentTree: Segment Tree implementation with 5x faster queries than bottom-up tree Hello, Codeforces! A few days ago [user:MohammadParsaElahimanesh,2021-04-06] posted a blog titled [Can we find each Required node in segment tree in O(1)?](https://codeforces.me/blog/entry/89377) Apparently what they meant was to find each node in $\mathcal{O}(ans)$, according to [ecnerwala's explanation](https://codeforces.me/blog/entry/89377?#comment-777885). But I was too dumb to realize that and accidentally invented a parallel node resolution method instead, which speeds up segment tree a lot. A benchmark for you first, with 30 million RMQ on a 32-bit integer array of 17 million elements. It was run in custom test on Codeforces on Apr 6, 2021. - **Classic implementation from cp-algorithms:** 7.765 seconds, or 260 ns per query - **Optimized classic implementation:** (which I was taught) 4.452 seconds, or 150 ns per query (75% faster than classic) - **Bottom-up implementation:** 1.914 seconds, or 64 ns per query (133% faster than optimized) - **Novel parallel implement...
fast?** I shamelessly stole someone's solution for [problem:1355C] which uses prefix sums

Full text and comments »

  • Vote: I like it
  • +402
  • Vote: I do not like it

117.
By tafit3, history, 10 years ago, In English
Surprise! [My surprise in the latest Surprise Language Round #8](http://codeforces.me/blog/entry/45454?#comment-300476) got me thinking. What is a surprise? Everybody is surprised by different things. If someone is new to competitive programming, there is an easy way to surprise him: just let him multiply two numbers. The constraints don't even have to be 10^9, 10^5 is enough:) But surprising more experienced coders is much harder. I like the problems that have some element of surprise or anything non-standard. The problems that somehow force the contestant to dig deeper. Something more than just reading the problem statement and converting it to DP. In the regular rounds most often the surprise comes from the missing knowledge about the particular algorithm. If I didn't know about the algorithm, I can google it after the contest, study it, add to personal library and wait for the next contest with similar problem. How can a problem statement be even more surprising? There is a link betw...
high that the only way to solve the problem would be to upload the solution that outputs: "This does, reading the problem statement and converting it to DP. In the regular rounds most often the surprise

Full text and comments »

  • Vote: I like it
  • +27
  • Vote: I do not like it

118.
By OtterZ, history, 19 months ago, In English
[Tutorial] Compare different spanning trees on graphs When I was trying to solve [ABC419G](https://atcoder.jp/contests/abc419/tasks/abc419_g) in the contest,I found myself wrongly use BFS tree instead of DFS tree and failed,that day I found it might be important to write a tutorial about different spanning trees to make it easier to know how to choose right spanning trees while we're managing to solve graphs problems especailly the creative problems nowadays.I'll write down what I know and might extend the blog due to comments. # DFS tree The reason I write about DFS trees first is that DFS trees arethe most common for simple graphs problem.When The code tries to run dfs algorithm on a graph starting with a node,the edges that was used to visit new nodes appears to be a tree. On undirected graphs,the edges is garenteed to connect from a node to its ancesters(back edges) or its sons(tree edges),making it easier to study undirected graphs problems. And on directed paths,the edges turns to four kinds: 1. tree edges:edges from ...
using greedy algorithms,with two core features: 1. Mininum spanning trees leads to adding smaller

Full text and comments »

  • Vote: I like it
  • +9
  • Vote: I do not like it

119.
By Qwerty1232, 19 months ago, In English
Making NTT convolution 10x faster with avx2 > Text is also available on [github pages](https://piskareviv.github.io/blog_aux_ntt_1/) (formatting may look a bit cleaner there) > Thanks [user:alexxela12345,2025-05-05] for reviewing this blog Hello everyone! I want to share some of my thoughts and experiments on vectorizing NTT. I prefer NTT to real-valued FFT because of the imprecision of the latter. I use `avx2` because it is the most advanced vector extension supported by the majority of modern online judges (including Codeforces), as of 2024. And I have no idea how many bugs (already found two) and how much UB my code contains, at least it passes some kind of tests. ### Benchmark info All the benchmarks are performed on my `Ubuntu 22` `Intel i5-1135g7` laptop. I execute `cpupower frequency-set -d 3.0ghz -u 3.0ghz` before benchmarks to (attempt to) fix CPU frequency for better accuracy. Code is available at [github](https://github.com/piskareviv/blog_aux_ntt_1). You can try running all the benchmarks o...
core of it looks like this ```cpp void transform(int lg, u32* data) { for (int i = 0; i

Full text and comments »

  • Vote: I like it
  • +366
  • Vote: I do not like it

120.
By ManGeo, history, 5 years ago, In English
Reflections in Problem Solving We live in a steadily upgrading society. Problem solving and algorithmic thinking is an art which has steadily defined human progress over quite some time. Although this art has defined progress over centuries, the computer age has significantly highlighted it as a progressive entity rather than a passive one. Many people believe that this is the era of rapid technological advancement. Day after day each sector of industry is undergoing automation advancement, thanks to the surplus of computer science engineers and software professionals. While monitoring closely we find changes, we may find rapid development, but the reality is quite different. It is definitely a hidden fact far from our reach, now. Problem solving is an art humans have developed over millenniums. We are millennials in our thought evolution. Today every country's education system is competitive. Every job prospect competitive. Humans have become competitive to achieve short term goals of name and fame, with their only...
Reflections in Problem Solving, We live in a steadily upgrading society. Problem solving and algorithmic thinking is an art which

Full text and comments »

  • Vote: I like it
  • -11
  • Vote: I do not like it

121.
By nuredinbederu10k, history, 15 months ago, In English
A2SV Contest #23 Editorial [Here](https://codeforces.me/contestInvitation/aa5538088b7a06cee3169aeed4c171ef954ce504) is the link to the contest. All problems are from Codeforces' problem set. [A. Verifying Access Keys](https://codeforces.me/gym/625306/problem/A) <spoiler summary="Solution"> To determine if each access key is **secure**, we need to validate it against **three specific rules**. 1. **Digits appear before letters:** All digits (if present) must appear before any letters. This means the transition from digits to letters can happen **only once**, and once it does, **no digit should appear afterward**. - For example, `"123abc"` is valid, but `"a1b2"` is not. 2. **Digits are non-decreasing:** The digits must be in **non-decreasing order**. As we read through the digits from left to right, each digit must be greater than or equal to the previous one. - For example, `"1125"` is valid, but `"132"` is not, because `3` comes before `2`, which violates the order. 3. **...
link to the contest. All problems are from Codeforces' problem set. [A. Verifying Access Keys, The core question then becomes: **Is there a permutation of the alphabet that satisfies all these

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it

122.
By arvindf232, history, 12 months ago, In English
Quadratic binary energy function minimisations by Flow ## Motivations I tried to read [https://codeforces.me/blog/entry/148438](https://codeforces.me/blog/entry/148438) and failed. It contains a lot of extra explanations and intuition that I either already knew or could reconstruct immediately. That is not inherently bad, but for me personally it made the key ideas harder to see. (I think most contestants would not struggle with visualising binary logical relations...) As I asked around (and with help from LLMs), it became clear that the underlying structure is the Kolmogorov–Zabih characterization of which quadratic binary energies are solvable via a single max-flow. This blog is essentially a reweighting of that material: shorter, more “algebraic”, and aimed at people who are already comfortable with max-flow / min-cut and with abstracting away implementation details. This blog is also just essentially an extremely long comment that is too long to fit in comment section. ## Declarations While writing this, I did **not**...
/michaelmas2002/23520065.pdf). * Solve a large number of max-flow problems to add my ownproblem

Full text and comments »

  • Vote: I like it
  • +95
  • Vote: I do not like it

123.
By zonedout, history, 15 months ago, In English
Codeforces Aggregator Hello Codeforces Community! Have you ever tried to find a common unsolved problem for you and your friends to practice on? Or maybe you wanted to quickly compare your combined problem-solving stats without juggling multiple browser tabs? It can be a hassle, right? Therefore, hereby I present to you [CF aggregrator](https://cf-aggregator.vercel.app/) !! CF Aggregator is a simple, fast, and clean web tool that lets you combine data from multiple Codeforces handles into a single, unified dashboard. What Can It Do? Multi-Handle Aggregation: Just enter a few handles separated by commas, and the tool will fetch and combine all the data for you. It's perfect for teams or practice groups. Combined Dashboard: Get a quick overview of your group's collective stats. See the total unique problems solved, the highest max rating in the group, total submissions, and more. Visual Statistics Tab: A very smart idea to track progress inspired by **cf analytics** Smart Problem Fin...
Hello Codeforces Community! Have you ever tried to find a common unsolved problem for you and, Smart Problem Finder: This is the core feature! You can filter the entire problemset by: ->Rating

Full text and comments »

  • Vote: I like it
  • +3
  • Vote: I do not like it

124.
By dogedogedoge, history, 8 years ago, In English
Difference between taking cumulative maximum VS individual maximum for SPOJ problem: ABCPATH I successfully solved a very simple and yet conceptual problem on SPOJ called ( [ABCPATH ](https://www.spoj.com/problems/ABCPATH/)) using three concepts(multi source BFS, Dijkstra and DP) and in the process I hit a surprising result in between, while implementing DP solution. Let me first describe the problem in a nutshell : We are given a 2D array of characters from 'A' to 'Z'. We need to start from 'A' and find the longest path with consecutive alphabets ( cannot trace back like 'N' to 'M' and then again a 'N'). Direction of travel is horizontal, vertical and diagonal. I submitted two times for the problem. One wrong answer and second accepted. The only thing I did differently in the accepted logic was taking maximum after travelling into all eight directions. To give more insight let me add the logic of code. Link to the Accepted solution : [Accepted Solution](https://ideone.com/FnY4vt) Link to the Wrong solution : [Wrong Solution with one line shifted](https://ideon...
Difference between taking cumulative maximum VS individual maximum for SPOJ problem: ABCPATH, I successfully solved a very simple and yet conceptual problem on SPOJ called ( [ABCPATH ](https, I would be really obliged to see a test case to get the core logic of code failure in one case and

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it

125.
By biximo, history, 19 months ago, In English
CP Toolkit V2 UPDATE!! <hr /> CP TOOLKIT V2 NEW UPDATE!!! ================== This new update comes PACKED with a ton of new features, which I'll list below. Newly Added Core Features ------------------------- **Graph Editor** An intuitive editor where nodes move smoothly. Build and edit graphs with drag-and-drop interaction. ![ ](https://i.imgur.com/jWjoNJa.png) **Graph Generator** Generate Trees, Cactus Graphs, Complete Graphs, Connected Graphs, Planar Graphs, Forests, and more. Perfect for creating custom test cases. ![ ](https://i.imgur.com/N0eWRmh.png) **Big Integer Calculator** Handles large integer operations with full precision. Great for number theory problems. ![ ](https://i.imgur.com/YxdeMpO.png) **Array Visualizer** Cleanly displays 1D and 2D arrays. Automatically adjusts font size and cell spacing for large arrays. ![ ](https://i.imgur.com/lWA3FPH.png) **NTT-Friendly Prime Generator** Select primes of specific length and base. Browse from a list of 320,...
new features, which I'll list below. Newly Added Core Features

Full text and comments »

  • Vote: I like it
  • +53
  • Vote: I do not like it

126.
By AmanGuptacd, 8 months ago, In English
Invitation to Dementia 2026, IIT Mandi Hello folks, As we gear up for our Annual Techfest , Xpecto'26 , we at Kamand Prompt (Programming Club of IIT Mandi) are excited to invite you to Dementia , a competitive programming contest. Dementia offers you a fantastic opportunity to show off your coding prowess and compete against the best in the globe to solve challenging and authentic competitive coding problems. <blockquote>"Step into the realm where logic and art align, Through geometric puzzles and graphs that entwine. With greedy pursuits and strategies deep, Where dynamic dreams and game theories creep. Only the sharpest minds will rise and define!"</blockquote> Registrations are <b>free</b> and open at <a href = "https://forms.gle/WFiXSDJYHyy7obLr7">this link</a>. <br> Date and Time: Monday, 16th March, 2025 (2:00 PM – 4:00 PM) IST <b>UPD(1) : </b> Expect 7 to 8 problems in the contest. One of them will be an <b>interactive</b> problem so kindly go through this <a href = "https://codeforces.me/blog/entry/4...
* Problem Setters : [user:HoneyGupta,2026-03-13] , [user:the_hadamard_gate, an interactive problem so kindly go through this

Full text and comments »

  • Vote: I like it
  • +10
  • Vote: I do not like it

127.
By fogsmozetvse, history, 4 months ago, translation, In English
Bottom-Up Segment Tree with Layered Binary Lifting (SBLD) Initially, I had an idea to create a multi-layered decomposition structure where the first layer would have block sizes of $(\sqrt{N}\)$, the second layer $(\sqrt{\sqrt{N}}\)$, and so on. I thought it would be an interesting alternative to standard approaches. However, after exploring the Codeforces archives, I found out that a similar concept (Layered SQRT-decomposition) had already been thoroughly discussed in previous blogs, so reinventing it didn't make much sense. Consequently, I decided to move away from square roots and look into powers of two instead. Rather than using a Sparse Table (which doesn't support updates and consumes too much memory), I opted for a rigid grid of layers combined with binary lifting logic. I named this structure SBLD (Segment Binary Lifting Data-structure). The result is a hybrid that processes range queries and point updates in $(2\log N\)$ operations in the worst case, utilizing strict O(N) memory (exactly 2N elements including the base array). ...
the Codeforces parser, so if some formulas still look a bit weird, my bad — hope thecore idea is, core idea is clear anyway :) UPD: Thanks to the community for the active feedback and interest in my

Full text and comments »

  • Vote: I like it
  • -2
  • Vote: I do not like it

128.
By dragonslayerintraining, 7 years ago, In English
Codeforces Round #584 (Dasha Code Championship Elimination Round) (div. 1 + div. 2) Editorial [1209A &mdash; Paint the Numbers](https://codeforces.me/contest/1209/problem/A) ================== Author: [user:MikeMirzayanov,2019-09-14] Consider the smallest element $x$ in the array. We need to paint it in some color, right? Observe, that we can paint all elements divisible by $x$ in that color as well. So we can perform the following while the array is not empty: * find the minimum element $x$, * assign new color and remove all elements divisible by $x$ Complexity: $\mathcal{O}(n^2)$. [1209B &mdash; Koala and Lights](https://codeforces.me/contest/1209/problem/B) ================== Author: [user:FieryPhoenix,2019-11-28] Because each individual light flashes periodically, all the lights together are periodic as well. Therefore, we can simulate the lights up to the period to get the answer. The actual period can be calculated as follows: <spoiler summary="Spoiler"> * If a light toggles every $t$ seconds, its period is $2t$. * The overall per...
[1209A — Paint the Numbers](https://codeforces.me/contest/1209/problem/A

Full text and comments »

129.
By LorentzianExpanders, history, 20 months ago, In English
Modulo Inversion in Constant Time, with Subpolynomial Precomputation Hi everyone, In this post, I'll share a method to compute modular inverses in $O(1)$ time under some $p^{\varepsilon}$-time precomputation. Rather than simply computing the modular inverse, we aim to solve for a pair of integers $x, y$ such that $ax + by = \gcd(a, b)$. I.e., find the solution of the Bezout equation. #### Observations > **Observation.** For two non-zero positive integers $a, b$ less than some bound $X$, there exists an invertible integer matrix $M \in \mathrm{GL}_2(\mathbb{Z})$ such that one component of the vector $M \begin{pmatrix}a\\\\b \end{pmatrix}$ is bounded by $X^{1/2}$, and the absolute values of the elements in $M$ are also bounded by $X^{1/2}$. _Proof._ The pigeonhole principle is sufficient to prove this observation. However, there could be a more algorithmic proof by analyzing the execution of Euclid's algorithm. We omit the details of this proof here. $\square$ > **Corollary.** Given two non-zero positive integers $a, b$ less than $X$, an...
difference $O(B/X)$. In total, the error is bounded by $3X/B^{1/2}$. $\square$ Thecore of the

Full text and comments »

  • Vote: I like it
  • +116
  • Vote: I do not like it

130.
By kfx, history, 11 years ago, In English
Python performance tips Python is a great programming language: simple, expressive, compact. In Codeforces, Python is often the best choice for Div 2 A and B problems. For example, problem [problem:600A] is very easy to write in Python: first tokenize the string with the built-in `split()` function, then try to parse the integers with the built-in `int()`, then output the comma-separated strings of results with `",".join(lst)`. For the more complex problems, writing fast-enough Python code is often a challenge. Here is a list of tips to improve performance. - Use PyPy instead of the standard Python interpreter. According to [20 offical benchmarks](http://speed.pypy.org/) it is on average 7 times faster than Python 2. PyPy2 is in my opinion the best option at the moment for competitive programming. - Append to an existing string with "+=" instead of concatenating **more than two** strings with "+" and storing the result with "=". (With two strings, both ways work fine. `s1 = s1 + s2` is fast becaus...
often the best choice for Div 2 A and B problems. For example, problem [problem :600A] is very easy to

Full text and comments »

  • Vote: I like it
  • +124
  • Vote: I do not like it

131.
By slycelote, 12 years ago, In English
caide is like chelper but for C++, C#, Visual Studio, Codelite and other IDEs/languages **tl;dr:** Install [VsCaide](https://visualstudiogallery.msdn.microsoft.com/4fa8cbb8-abb3-4bc6-97c8-6dd25a3a3c74?SRC=Home) extension in extensions manager of Visual Studio 2013. (NOTE: it's recommended to create caide project from scratch after update: use `caide init` from command line or "Create caide solution" button in Visual Studio.) **v1.2.1:** * Fix Codeforces contest parser, GCJ, HackerRank * Support RCC contests, POJ * C++ inliner: don't remove used typedefs defined at class scope. **v1.2:** * Fix Codeforces parser in russian interface * C++: Remove inactive preprocessor blocks, unused macros, unused typedefs * C# support in VS plugin * Compatibility with CHelper extension (command line only) * Support Google Code Jam, Russian Code Cup, HackerRank Currently supported online judges: Codeforces, GCJ, CodeChef, Timus, HackerRank, POJ, RCC. (Topcoder is planned.) Currently supported IDEs: Visual Studio 2013, CodeLite. Currently supported programming langu...
you do during programming competitions: parsing, running and debugging problem tests, inlining

Full text and comments »

  • Vote: I like it
  • +46
  • Vote: I do not like it

132.
By _ahat, history, 16 months ago, In English
We need to save codeforces Codeforces used to be the one place I felt truly challenged. Now, it feels rigged. Does anyone else remember Codeforces during last year's summer? I do. I remember waking up early to do the frequent and high-quality contests; I remember getting on calls with friends and discussing solutions post-contest and laughing at WA attempts; I also remember times where when I couldn't think of a solution and I would bang my head on the wall and draw trillions of random dots, parenthesis, letters and numbers on paper &mdash; all in the name of hoping that I would stumble upon an observation. I grew, the community grew, and we all thrived. We've all been there, fallen in love with competitive programming and problem-solving. That feeling of getting AC after debugging for an hour and then finding out it was a random global variable is ... indescribable. Codeforces used to be a haven for us problem-solvers. It used to be a place where we could *be ourselves*. Ratings weren't everything for us: we...
programming and problem-solving. That feeling of getting AC after debugging for an hour and then finding

Full text and comments »

  • Vote: I like it
  • +27
  • Vote: I do not like it

133.
By MikeMirzayanov, 15 years ago, translation, In English
Codeforces Contest Rules This document provides a detailed and formal version of the Codeforces contest rules. If you're simply looking to understand the basics, we recommend starting with the post [Codeforces Contests](/blog/entry/456). Please note that organizers may make minor modifications to the rules for specific rounds; any such changes will be included in the official announcement of the respective round. Unless otherwise stated, the following rules should be considered the default for all contests. By participating in a Codeforces contest and/or submitting any materials, you automatically agree to abide by these [terms and conditions](/terms). ### General information about a round 1. You need to register to participate in a round. The registration opens six hours before the start of the contest and closes 5 minutes before it, unless the information about the round states otherwise. 1. The system of conducting contests has two interface languages available: Russian and English. The cont...
solve, unless the information about the round states another number of problems. 1.Problem

Full text and comments »

  • Vote: I like it
  • +17
  • Vote: I do not like it

134.
By Ahanab, history, 4 weeks ago, In English
This Vietnamese still cheat Title: Cheating Report: Account nvhoang in AtCoder Beginner Contest 479 Hello everyone, Note: Since my English is not very good, this blog post was translated and polished with the help of AI.) Following up on my [previous post](https://codeforces.me/blog/entry/157523) regarding account [nvhoang](https://atcoder.jp/users/nvhoang) ([user:NGUYENVUHOANG,2026-10-11]), he has once again exhibited clear signs of cheating in AtCoder Beginner Contest 479 &mdash; in fact, I am completely certain of it. After several cheaters were removed from the official standings, his rank jumped straight into the Top 5. To verify my suspicions, I prompted Claude (Sonnet 3.5) to solve problems F and G. To my surprise, the core logic, algorithmic approach, and code structure generated by the AI were almost identical to his submitted solutions, with only minor tweaks made to disguise the AI footprint. Anyone can easily verify this by generating a solution using Claude/ChatGPT for problems F and G...
, the core logic, algorithmic approach, and code structure generated by the AI were almost identical, . To my surprise, the core logic, algorithmic approach, and code structure generated by the AI were

Full text and comments »

  • Vote: I like it
  • -35
  • Vote: I do not like it

135.
By nuredinbederu10k, history, 18 months ago, In English
Editorial For A2SV Contest #11 [Here](https://codeforces.me/contestInvitation/ebf08ef54eb14b2568eb54315b4d0d23dd8d4a1f) is the link to the contest. All problems are from Codeforces' problem set. [A. Modern Name Generator ](https://codeforces.me/gym/605795/problem/A) <spoiler summary="solution"> Split the input into three strings, take the first character of each, and join them. </spoiler> <spoiler summary="code"> ```python for _ in range(int(input())): print(''.join(x[0] for x in input().split())) ``` </spoiler> [B. Aaron and Repeated Letters](https://codeforces.me/gym/605795/problem/B) <spoiler summary="solution"> We use a stack to keep track of characters. For each character, if it matches the top of the stack, we remove the top (both letters cancel out). Otherwise, we push the current character onto the stack. At the end, the stack contains the corrected string without consecutive duplicates. </spoiler> <spoiler summary="code"> ```python s=input() st=[] for c in s: if st a...
The problem requires constructing a lexicographically minimal string, link to the contest. All problems are from Codeforces' problem set. [A. Modern Name Generator

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it

136.
By adarsh7203, 5 months ago, In English
[Website] CF UpsolveX — Automated Upsolving Companion for Codeforces (Web App + Chrome Extension) Hello everyone! I built **CF UpsolveX**, an automated upsolving companion for Codeforces. It consists of a full-stack web application along with a Chrome extension that helps you track, prioritize, and consistently upsolve the problems you missed in contests. --- ### Problem: While participating in Codeforces contests, I often found myself saying: *"I'll upsolve the remaining problems tomorrow."* But after a few contests, dozens of unsolved problems start piling up and it becomes difficult to decide: * Which problems should be upsolved first? * Which contests still have pending problems? * How much progress has been made overall? * Whether I am actually being consistent with upsolving? Since upsolving is one of the most important aspects of improvement in competitive programming, I felt there should be a better system for tracking and prioritizing missed problems. --- ### Solution: So I built **CF UpsolveX**. It automatically tracks your missed...
, prioritize, and consistently upsolve the problems you missed in contests. --- ###Problem: While

Full text and comments »

  • Vote: I like it
  • +1
  • Vote: I do not like it

137.
By amartya110, history, 9 months ago, In English
Editorial for CodeHurdle Athlos 02 We want to thank you all for participating in the contest, and hope you enjoyed it. Any feedback would be appreciated! [Contest Link](https://codeforces.me/contestInvitation/c9482c2d71d0b5cdc04841221671e06b827c1e07) ### [A — Costly Divisibility](https://codeforces.me/gym/670769/problem/A) Writer: [user:amartya110,2026-01-19] <spoiler summary="Editorial"> In this case any $a[i]>=b[i]$ for all $(1<=i<=n)$, you can easily make a[i]%b[i]==0 by decreasing the value of a[i] or increase the value of b[i] with cost 0, and otherwise the cost is the absolute difference between a[i] and b[i]. </spoiler> <spoiler summary="Solution"> ```c++ #include <bits/stdc++.h> using namespace std; #define faster ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); #define testcase int t; cin>>t; for(int i=0;i<t;i++) #define ll long long int ll lcm(ll a, ll b) { return (a / __gcd(a, b)) * b; } void solved(){ /*start*/ ll n; cin>>n; vecto...
The core of this problem lies in recognizing that repeated prefix

Full text and comments »

  • Vote: I like it
  • +14
  • Vote: I do not like it

138.
By chumeng, history, 11 months ago, In English
Introduction to CP Tracker -- A Web-Based Competitive Programming Archive & Management Tool Introduction ================== ![ ](/predownloaded/0d/b3/0db3633acf00903acd27057b6dffcdfdd9547884.png) CP Tracker (Competitive Programming Tracker) is a comprehensive tool I maintain for archiving and managing your competitive programming progress. [Live Demo](https://competitive-programming-tracker.netlify.app/) | [GitHub Repository](https://github.com/lihaoze123/cptracker) Core Highlights ------------------ * One-Click Import: Seamlessly import submission records from major platforms including Codeforces, AtCoder, Luogu, and QOJ. * Visual Analytics: Built-in interactive charts and dynamic heatmaps intuitively visualize your daily activity and skill growth curves. * Rich Text Support: Native rendering support for Markdown and LaTeX mathematical formulas. * Data Flexibility: Full support for CSV import and export. * Storage & Sharing: Supports local offline storage. You can also choose cloud synchronization to generate a personal public profile and share your pro...
-programming-tracker.netlify.app/) | [GitHub Repository](https://github.com/lihaoze123/cptracker)Core, Core Highlights ------------------ * One-Click Import: Seamlessly import submission records from

Full text and comments »

  • Vote: I like it
  • +16
  • Vote: I do not like it

139.
By wakanda-forever, history, 19 months ago, In English
Found an interesting Number Theory property Hello Codeforces, Recently I was trying to make a number theory problem, I haven't framed the entire question yet but the core part goes something like this $-$ Given an integer $a$, find an integer $b$ ($ \le a $) such that $gcd(a,b)$ $+$ $lcm(a,b)$ is a prime number. The condition $gcd(a,b)$ $+$ $lcm(a,b)$ is a prime number boils down to $gcd(a,b) = 1$ and $a \cdot b + 1$ is a prime where $b \le a$. I tried brute-forcing $b$ by fixing $a$ and I found that there exists such $b$ for all $1 \le a \le 10^5$. However, I am not sure whether there exists such $b$ for all $a$. Does anyone have a formal or intuitive proof why this is happening and is there any approach to find $b$ given $a$ ?
Hello Codeforces, Recently I was trying to make a number theory problem, I haven't framed the, Recently I was trying to make a number theory problem, I haven't framed the entire question yet but

Full text and comments »

  • Vote: I like it
  • +37
  • Vote: I do not like it

140.
By priyadarshinir, history, 9 months ago, In English
Dive in Thoughts ### A Dive Into Thoughts — And How Not to Lose the Idea That Brought You ================== ------------------ ### Every developer remembers the moment an idea first appeared. ### ### It was simple. ### Clear. ### Almost obvious. ### ### Maybe it was a solution to a bug. ### Maybe a product idea. ### Maybe a side project you couldn’t stop thinking about. ### ### At that moment, the idea felt alive. ### ### Then we did what developers do best — ### we started thinking deeply. ### ### And somewhere in that depth, many ideas slowly disappear. ### ### Not because they were bad. ### But because they drifted. ### Deep Thinking Is a Gift — But It Has a Shadow --------------------------------------------- ### Thinking deeply is our strength. ### We question edge cases. ### We optimize. ### We prepare for scale. ### We imagine everything that could go wrong. ### ### But deep thinking has a shadow side. ### ### Sometimes we go so deep that we forget ...
complex that even we struggle to remember the core. ### ### The idea didn’t fail. ### It got lost., not yet real. ### We explain ideas so complex that even we struggle to remember thecore

Full text and comments »

  • Vote: I like it
  • -27
  • Vote: I do not like it

141.
By StrikingResemblence, history, 10 years ago, In English
Need help with a job scheduling problem Hello, recently I faced with a problem that I have no idea how to solve. The problem goes like this: A computer has Five(5) processing cores. 'N' processes or jobs come to the cores at a certain time to get processed. Each core has a queue of its own which is used to store jobs. Each job has an 'entry time' and a 'length'. Whenever a core starts processing a job it takes 'length' amount of time to complete. Whenever a job sits on some core's queue it accrues 'waiting time' till it is processed. The 'processing time' of a job is equal to the 'waiting time' plus 'length'. That is: Processing Time = Waiting Time + Length (Notice that the 'entry time' is not contained within the 'waiting time'.) Whichever core will take a certain job is up to us. If a job is selected to be processed by a core but the core is already processing something, the job will enter the core's queue. Our task is to **minimize** the **number of cores** used, such the the **'processing time' of every job i...
Need help with a job scheduling problem, to get processed. Each core has a queue of its own which is used to store jobs. Each job has an, As it can be seen that only one core is required to complete all job such that none of their, Explanation of test case 1: The first job enters at time 1. The core immediately takes in the job, Explanation of test case 2: We can use two cores here: the first core will handle the first, third, Hello, recently I faced with a problem that I have no idea how to solve. The problem goes like this, Whichever core will take a certain job is up to us. If a job is selected to be processed by acore

Full text and comments »

142.
By AkiLotus, history, 2 years ago, In English
Very brief unofficial editorial for Codeforces Round 981 (Div. 3) I just feel like doing it, despite knowing that official one should come in less than a day after this blog post... We might miss some proofs here and there (I only wrote this in half an hour, for quickie's sake), so we'd love to see your proofs contributing in the comments. Special thanks to [user:iristran911,2024-10-25] for coding with me during the VC. [problem:2033A] - Editorialist: [user:AkiLotus,2024-10-25] - Implementation: [submission:287849922] <spoiler summary="Tutorial"> It is obvious that to prolong the game as much as possible, alternating players will move the dot in alternating directions. And conveniently speaking, each turn will only increase the absolute value of the dot's coordinate by $1$. Proof of this is trivial enough to be left as a mathematical task for readers. Thus, the player doing the last turn can be determined by the parity of $n$: the one making the dot's absolute coordinate $n+1$ would be such player, and thus it'd be Kosuke if $n$ i...
[user:iristran911,2024-10-25] for coding with me during the VC. [problem:2033A

Full text and comments »

  • Vote: I like it
  • +68
  • Vote: I do not like it

143.
By orz, history, 5 years ago, translation, In English
Fast modular multiplication Consider the following problem: given three integers $x$, $y$ и $m$, $0 \leqslant x,y < m < 2^{32}$, calculate $xy\bmod m$. The easy way is just to multiply these numbers and apply the modulo operation: ~~~~~ uint32_t prod(const uint32_t x, const uint32_t y, const uint32_t m) { return x * y % m; } ~~~~~ As you might have guessed, this solution is wrong. The thing is that an overflow is possible in such a procedure: the operation `x * y` is performed in the type` uint32_t`, and in fact the intermediate result of this operation will not be $xy$, but $xy\bmod2^{32}$. If after that we take the result modulo $m$, it may differ from the correct one: $$ \left(xy\bmod2^{32}\right)\bmod m\ne xy\bmod m. $$ The way out is simple — you need to multiply in a larger type: ~~~~~ uint64_t prod_uint64(const uint64_t x, const uint64_t y, const uint64_t m) { return x * y % m; } ~~~~~ If you do this, then, since $xy<2^{64}$, this product will definitely not overflow, and after tak...
Consider the following problem: given three integers $x$, $y$ и $m$, $0 \leqslant x,y < m < 2^{32

Full text and comments »

  • Vote: I like it
  • +269
  • Vote: I do not like it

144.
By Sangeet.cpp, history, 13 months ago, In English
Eertree (Palindromic Tree) — Comprehensive Resource Guide Hi Codeforces! During Codeforces Round 1059 (Div. 3), I encountered **Problem E: Beautiful Palindromes**, which involves minimizing palindromic subarrays. While researching optimal solutions, I discovered the **Eertree (Palindromic Tree)** data structure &mdash; a powerful but relatively unknown tool for efficiently handling palindrome-related problems. The Eertree can process all palindromic substrings of a string in **O(n)** time and space, making it ideal for problems involving palindrome counting, queries, and optimizations. However, I noticed there are limited and scattered resources for learning this data structure, so I've compiled this comprehensive guide to help the community. ### What is an Eertree (Palindromic Tree)? The **Palindromic Tree** (also called **Eertree**) is a tree-like data structure that stores all unique palindromic substrings of a string efficiently. It was introduced by Mikhail Rubinchik and Arseny M. Shur in 2014. **Key Properties:** - Proc...
Hi Codeforces! During Codeforces Round 1059 (Div. 3), I encountered **Problem E: Beautiful

Full text and comments »

  • Vote: I like it
  • +16
  • Vote: I do not like it

145.
By Nan-Do, 11 months ago, In English
A Proposal to Fight AI Cheating: Using LLMs Against Themselves Hello everyone, I hesitated to make this post, but I believe the potential benefits outweigh the downsides. Recently, there has been significant discussion regarding the cheating problem, specifically how AI tools allow users to reach Grandmaster (Red) status in just a few contests. While many advocate for stricter identification measures, I would like to propose a different technical approach. As the title suggests, I have created an open-source tool inspired by AlphaCode to generate solutions for competitive programming problems. Although I developed this for personal research, I believe tools like this can be used to combat AI-driven cheating. I believe this approach helps in two key ways: 1. **Assisting Problem Setters:** It allows setters to verify if a proposed problem is easily solvable by current AI models. 2. **Identifying Cheaters:** It helps flag users who utilize LLMs during contests. #### The Logic At their core, LLMs are statistical machines. They will ev...
downsides. Recently, there has been significant discussion regarding the cheatingproblem

Full text and comments »

  • Vote: I like it
  • -13
  • Vote: I do not like it

146.
By orz69, history, 23 months ago, In English
Newbies, pupils, and specialists on Codeforces often lack skill due to a fundamental failure t Newbies, pupils, and specialists on Codeforces often lack skill due to a fundamental failure to engage deeply with the core principles of competitive programming. Newbies typically rush through basic concepts without truly internalizing them, leading to shallow understanding. Pupils often plateau because they focus too much on solving problems within their current comfort zone, neglecting to expand their knowledge of more advanced algorithms and data structures. Specialists, despite being more experienced, often become complacent, relying on repetitive prNewbies, pupils, and specialists on Codeforces often lack skill due to a fundamental failure to engage deeply with the core principles of competitive programming. Newbies typically rush through basic concepts without truly internalizing them, leading to shallow understanding. Pupils often plateau because they focus too much on solving problems within their current comfort zone, neglecting to expand their knowledge of more advanced algo...
engage deeply with the core principles of competitive programming. Newbies typically rush through basic

Full text and comments »

  • Vote: I like it
  • -25
  • Vote: I do not like it

147.
By H_a_r_M_i_t, history, 19 months ago, In English
Seeking Guidance on My Journey to Candidate Master !! ##### Hey Codeforces _:D_ I’m Harmit [user:H_a_r_M_i_t,2025-04-10] Khimani, and I’ve been steadily working on my competitive programming skills with the goal of reaching **Candidate Master**. I’ve made decent progress so far, but I know there’s still a long way to go, so I’d really appreciate any insights to help me level up faster. [Here’s my profile](https://codeforces.me/profile/H_a_r_M_i_t) if you’d like to take a look. ![ ](/predownloaded/b6/b1/b6b1f92be8b2acd2ca0f60a6f0032c4ae917f262.png) ![ ](/predownloaded/86/29/8629437dd953195207bad362146d647c84b5003f.png) I’m looking for advice and would love feedback on a few things: - Speed and Accuracy Under Pressure: - How do you stay fast *and* accurate when time is tight and pressure kicks in? - Consistency in Contests: - How do you deal with rating ups and downs? What helped you stay steady? - Solving 1600–2000 Rated Problems: - What’s your approach to consistently crack problems in this ...
range? - Any particular patterns or problem types that helped you improve? - Underrated

Full text and comments »

  • Vote: I like it
  • +40
  • Vote: I do not like it

148.
By misof, 11 years ago, In English
Yandex Algo 2015 (cancelled) round 2 editorial Hello :) I was the writer for the Round 2. I'm very sad that the contest platform failed and you couldn't do your best solving them -- for me it's also sad as my work on the problems is now wasted. Hopefully you liked the problems themselves. Here are the problem statements: - A http://pastebin.com/raw.php?i=U8SfbSL8 - B http://pastebin.com/raw.php?i=bAi07eMm - C http://pastebin.com/raw.php?i=R72vqKkk - D http://pastebin.com/raw.php?i=Ar5CmJ8j - E http://pastebin.com/raw.php?i=wiCtb0ab - F http://pastebin.com/raw.php?i=iaMnb9cs And below are brief solution ideas. Ask if anything is unclear. **A (ascending the stairs)** Dynamic programming in O(n). Let W[x] be the number of ways to climb the first x steps of the stairs. (We will call that "state x".) W[n] is the answer we want. For each x, let y be the lowest state that we can go directly from state y to state x -- i.e., the sum H[y]+...+H[x-1] is still <= m. Then W[x] is simply the sum of W[y] through W[...
. Hopefully you liked the problems themselves. Here are the problem statements: - A http

Full text and comments »

  • Vote: I like it
  • +156
  • Vote: I do not like it

149.
By pratik447, history, 7 weeks ago, In English
Trust Your Gut: Why My Code Worked After the Contest Ended During a recent competitive programming contest, I encountered a particularly tricky problem that perfectly tested both algorithmic intuition and psychological resilience. The core objective seemed straightforward enough: we needed to construct or manipulate an array in such a way that its sum was maximized for a specific prefix mode. Right from the initial reading, my mind clicked with a potential approach. I formed a solid mental model, sketched out the logic on my scratchpad, and felt a strong sense of confidence that my algorithmic path was heading in the right direction. However, competitive programming can be a brutal mental game, and this problem had a hidden trap that completely derailed my progress. As I tested my code against the provided sample cases, the results did not match the expected output. In contests, seeing a mismatch between your implementation and the official sample output is an immediate psychological blow. It forces you into a state of intense self-doubt. I...
During a recent competitive programming contest, I encountered a particularly trickyproblem that

Full text and comments »

  • Vote: I like it
  • -23
  • Vote: I do not like it

150.
By iiser.ayush, history, 2 years ago, In English
The Role of Randomness in Problem Solving and Creativity Randomness often plays a crucial role in various problem-solving strategies, such as the hill-climbing approach. In this strategy, you start by identifying a local maximum—an optimal solution within a limited scope. From this point, you have two choices: 1.Use this local maximum as a base to explore more optimal solutions. 2.Intentionally deviate from your current choice, allowing for the possibility of discovering better solutions more quickly. This journey from more randomness to less is akin to elongating a path until we arrive at a final solution. Interestingly, if we rush the process, the final outcome may differ significantly from one achieved through careful exploration. Consider the analogy of planning a trip through ten cities. While the number of cities seems manageable, the permutations involved—10! (10 factorial)—reveal just how complex the task can become. Moreover, some physicists, including an Italian researcher from Indiana University, have highlighted th...
The Role of Randomness in Problem Solving and Creativity, Core idea through :- "Algorithms to live by" Brian C. and Tom G. Refined through :- Chatgpt, Randomness often plays a crucial role in various problem-solving strategies, such as the hill

Full text and comments »

  • Vote: I like it
  • -10
  • Vote: I do not like it

151.
By EbTech, 7 years ago, In English
How to Interpret Contest Ratings **UPDATE: the [new rating system paper](https://arxiv.org/abs/2101.00400) will appear in the Web Conference 2021!** If you're new to competitive programming, you may be wondering: what are ratings and colors? What do they mean? As a contestant and now coach of the UBC team, I've taken enough interest in the subject to have developed my own rating system, Elo-MMR, which I might describe in a future blog post. For now, I want to talk about ratings more generally: what does it mean to achieve a certain rating or title? How concerned should you be with your rating and title? Might it be harmful to be concerned with them at all? A Brief History of Contest Ratings -------------------------------------- Contest rating systems can trace their heritage back to the [Elo system](https://en.wikipedia.org/wiki/Elo_rating_system). Elo was devised for 2-player games, with rating updates based on whether a player wins, loses or draws. Starting in 1960, it was adopted by the chess community ...
the control structures and core libraries of your chosen programming language. You might wonder if

Full text and comments »

  • Vote: I like it
  • +236
  • Vote: I do not like it

152.
By MikeMirzayanov, history, 10 years ago, In English
8VC Venture Cup 2017 Announcement <img src="http://assets.codeforces.com/images/8vc/8vc-venturecup-logo.png" style="float:right;margin:0 1em 1em 1em"/> Hello Codeforces! I'm pleased to announce the first championship hosted on the Codeforces platform. Welcome <b>8VC Venture Cup 2017</b>! 8VC will be hosting a coding championship on Codeforces. The championship will begin on January 15 and take place in 2 rounds. The contest will occur in two rounds: * The Elimination Round is online and takes place on <a href="https://www.timeanddate.com/worldclock/fixedtime.html?day=15&month=1&year=2017&hour=20&min=05&sec=0&p1=166">January 15, 17:05 (UTC)</a>. Elimination Round follows regular Codeforces rules and consists of 7-8 problems. For this round, the complexity of the problems will be comparable to a regular Codeforces round. There are no eligibility restrictions to participate in the round. * The Final Round takes place on January 22, consists of 5-6 problems, and uses regular Codeforces rules. The...
Lonsdale (co-founder of Palantir) and his core team from Formation | 8, is a Silicon Valley venture

Full text and comments »

  • Vote: I like it
  • +164
  • Vote: I do not like it

153.
By mosambijuice, 16 months ago, In English
Leetcode Stress Tester Excited to share my project. LeetCode Stress Tester – a VS Code extension that brings powerful, no-code stress testing to competitive programmers! This extension lets you fetch LeetCode problems, auto-pull brute-force solutions, generate random tests, and compare outputs seamlessly in your editor. Debug edge cases without the hassle of manual setups. Why This Tool? Stress testing is essential for catching hidden bugs in optimized solutions. This extension automates it for C++, using your code against a reliable baseline. No need to write brute-force logic – it fetches official LeetCode or [GitHub solutions]() for brute.cpp! Key Features:- No-Code Brute Integration: Automatically source brute-force code from official solutions or GitHub repos, so you focus on your solution.cpp. Smart Test Generation: Customize gen.cpp with minimal effort using the generative.h header. Functions include: generate_number(l, r): Random int in [l, r]. generate_array(l, r, n): Array of size n ...
tweaks. Workflow Here's a quick step-by-step on how it works: Fetch Problem: Pull a LeetCode

Full text and comments »

  • Vote: I like it
  • +8
  • Vote: I do not like it

154.
By Seferoglu, history, 13 months ago, In English
[HELP NEEDED]: Insane Bug in C++20 Solution Good evening CodeForces,today I tried solving https://oj.uz/problem/view/JOI16_selling_rna. My code has a very weird behaviour. To start, compiling in C++20 takes so long that I guess oj.uz marks it as compilation error. The same code gets AC in C++17 (and compiles instantly on my machine). See here: https://oj.uz/submission/1277541 https://oj.uz/submission/1277540 Another weird behavior I encountered while implementing is if you switch the vector<int> ids; with set<int> ids; in the Node struct, and change the push_back's with insert's, it causes an infinite loop I wasn't able to put my finger on. Also if one compiles the set solution with glibcxx, the following error message is produced (which I'm unable to use to my advantage) <spoiler summary="Spoiler"> ~~~~~ /usr/include/c++/13/debug/safe_iterator.h:298: In function: gnu_debug::_Safe_iterator<_Iterator, _Sequence, _Category>::reference gnu_debug::_Safe_iterator<_Iterator, _Sequence, _Category>::operato...
(core dumped) ~~~~~ Please help me since I had a similar problem with c++20 before

Full text and comments »

  • Vote: I like it
  • +45
  • Vote: I do not like it

155.
By Pulkit_gupta, 4 months ago, In English
IICPC Global Quantfest 2026 Hello! Registrations for **IICPC Global Quantfest 2026** are now open. This is 2nd Global IICPC Examination, bringing together Quantitative Finance, Probability, and Competitive Programming, built on IICPC's rich legacy of nurturing top talent. **About IICPC Quantfest** IICPC (Intercollegiate Informatic and Competitive Programming Camp) is a student-led initiative dedicated to advancing competitive programming and quantitative problem solving for the globe. Over the past few years, IICPC has organized bootcamps, contests , recruitment examinations, and educational programs connecting thousands of students with industry and academia. Quantfest is a global quantitative problem-solving festival where the brightest analytical minds tackle challenges inspired by real-world trading and quantitative roles. This year, we are opening participation to international students from 50+ countries. **Registrations go live on July 20, and remain open till August 20.** There is no partic...
competitive programming and quantitative problem solving for the globe. Over the past few years

Full text and comments »

  • Vote: I like it
  • +130
  • Vote: I do not like it

156.
By wakanda-forever, 7 months ago, In English
Codeforces Round 1095 (Div. 2) Editorial Thanks for participating. We hope you liked the problems and enjoyed the round. #### [problem:2226A] Idea: [user:wakanda-forever,2026-04-21] <br> Preparation: [user:wakanda-forever,2026-04-21] <br> Solution: [user:wakanda-forever,2026-04-21] <br> <spoiler summary = "Solution"> For any two positive integers $x$ and $y$, observe that $x \times y \ge x + y$ when $x > 1$ and $y > 1$. Thus, it is never optimal to choose two elements that are more than $1$ in a single operation. Also, it is optimal to choose as many $1$'s as possible in a single operation. Hence, we opt to choose subsequences of the form $[1, 1, \ldots, x]$ and delete them. Note that the cost for this operation is equal to $x$. Therefore, the answer is just the sum of elements that are more than $1$. But if the last element is $1$, it cannot be clubbed with any "more than $1$ element", and it adds $1$ to the answer. Time Complexity: $\mathcal{O(n)}$ </spoiler> <spoiler summary = "Implementation"> ...
Thanks for participating. We hope you liked the problems and enjoyed the round. #### [problem

Full text and comments »

  • Vote: I like it
  • +86
  • Vote: I do not like it

157.
By MikeMirzayanov, 13 years ago, translation, In English
Codeforces: new computers for testing and testing compatibility mode Rah-rah! We are moving forward to accelerate testing. In fact, when our rounds attract 3500+ registrations, it is hard to test all the submissions on nine computers "Core 2 Duo E6750, 2.66 Ghz, 3Gb". Computer Science Department of Saratov State U has recently got 20 new computers i5-3470, 8Gb. After a little research it was found that if boost CPU to 3.5Ghz (of course, turning off all sorts of turbo boost and after many hours of stability check), the speed is approximately equal to twice the speed of the old testing machines. This is very convenient as it will in future only to divide all the time constraints in the problems by 2. We have moved to testing on new computers and we do it in **compatibility mode**. This means that all the time constraints before the start of the program are divided into 2, the program is executed, and at the end a running time is multiplied by 2. In fact, if you do not use the cut-off by time or some other unsavory stunts, you will not detect any ...
+ registrations, it is hard to test all the submissions on nine computers "Core 2 Duo E6750, 2.66 Ghz

Full text and comments »

  • Vote: I like it
  • +104
  • Vote: I do not like it

158.
By mst_molik, 21 month(s) ago, In English
Freshers Coding Contest 1.0 by Kamand Prompt Hello freshers , we at <b>Programming club of IIT Mandi</b> are glad to invite you to [contest:555365] on <a href = "https://www.timeanddate.com/worldclock/fixedtime.html?iso=20250215T1800&p1=176&msg=Freshers%20Coding%20Contest%201.0"> Saturday , 15 February 2025 <sup> IST </sup></a>. (This Round is exclusively for <b>first year students</b> of IIT Mandi). <p> You can Register for the same using this <a href = "https://forms.gle/avVjxRvYeiMtZ1HN9">link</a>.<p> <br> <div style="text-align: center;"> <img src="/predownloaded/07/14/07148f9621316bf3539f48cfee2e6b8f91306946.jpeg" alt="Contest Banner"> </div> The contest contains 8 carefully crafted tasks, one of them divided into two subtasks, to be solved in 2 hours. Themes of the problems include <i>Harshit's</i> Post-Valentine Life , Seniors' recent credits dilemma and much more. This round could not have been possible without the generous help of so many people: <ul> <li><b>Abhijeet Bhaiya (Co-ordinator)</b> :...
coordinating the round for you all. * Problem-Setters : [user:mst_molik,2025-02-11, >Problem-Setters : [user:mst_molik,2025-02-11] and [user:gyanratan,2025-02-11] for creating and

Full text and comments »

  • Vote: I like it
  • -18
  • Vote: I do not like it

159.
By ICPCNews, 4 years ago, In English
ICPC 2023 Online Spring Challenge powered by Huawei <img src="/predownloaded/af/22/af228fee1abb015217d8c524de74898aeff36419.png" align="right" style="height: 280px;" alt="text"/> Hello, Codeforces! **UPD:** Challenge is over. You can find results [in this post](https://codeforces.me/blog/entry/115695) We are happy to invite you to an exciting online event: ICPC 2023 Online Spring Challenge powered by Huawei, which will start on [April 13, 2023, 11:00 UTC](https://www.timeanddate.com/worldclock/fixedtime.html?msg=ICPC+2023+Online+Spring+Challenge+powered+by+Huawei&iso=20230413T11&p1=1440). In this Challenge, you will have a unique chance: - to compete during 14 days online challenge - to solve 1 exciting problem prepared by Huawei - to win amazing prizes from Huawei! As a special prize, Huawei together with ICPC Foundation will provide the travel trip to the 46th Annual ICPC World Finals in a guest role! Everyone is welcome to participate. It is an individual competition. **ICPC 2023 Online Spring Challenge p...
unique chance: - to compete during 14 days online challenge - to solve 1 excitingproblem prepared by

Full text and comments »

  • Vote: I like it
  • +262
  • Vote: I do not like it

160.
By -egoist-, history, 10 months ago, In English
Writing down ideas for future use (Part 1: Beautiful DP idea for "Xor Sum" Problem) Problem: [Xor Sum](https://atcoder.jp/contests/abc050/tasks/arc066_b) Given a constraint $N$, find the number of unique pairs $(u, v)$ such that $0 \le u, v \le N$ and there exist non-negative integers $a, b$ satisfying $a \oplus b = u$ and $a + b = v$. The Core Idea: The relationship between bitwise XOR and arithmetic addition is governed by the identity $a + b = (a \oplus b) + 2(a \text{ AND } b)$. Because both $u$ and $v$ are derived from the same underlying bits $(a_i, b_i)$, we can solve this using Digit DP by processing bits from most to least significant. We represent the three unique ways $a$ and $b$ can contribute to the pair $(u, v)$ at any bit $i$ as "bit-sums" $s \in \{0, 1, 2\}$, where $s=1$ covers both $(0,1)$ and $(1,0)$ because they produce the same result for $u$ and $v$. By maintaining a "tightness" or "buffer" state $j$ (where $j$ tracks the difference between the prefix of $N$ and our constructed sum $v$), we can ensure $v \le N$. Crucially, since $a + b \ge a...
Writing down ideas for future use (Part 1: Beautiful DP idea for "Xor Sum" Problem), Problem: [Xor Sum](https://atcoder.jp/contests/abc050/tasks/arc066_b) Given a constraint $N, The Core Idea: The relationship between bitwise XOR and arithmetic addition is governed by the

Full text and comments »

  • Vote: I like it
  • -13
  • Vote: I do not like it

161.
By DBND, 6 weeks ago, In English
Beating Treaps & Splay with a Simple Idea: A Fast, Amortized Dynamic Segment Tree with Insertion ## The Origin & The Benchmarks: A Hardware-Aware Approach A few months ago, I independently conceptualized an idea for an amortized dynamic data structure. However, it wasn't until recently that I finally found the time to sit down and write a truly optimized, production-ready implementation for it. Curious to see if anyone else had thought of this, I dug deep into the Codeforces archives and stumbled upon a heavily forgotten [blog post from 12 years ago](http://codeforces.me/blog/entry/12285). The author successfully implemented the core base-logic: traversing down to a leaf and splitting it into two new children. **However, there was a major bottleneck in that ancient version:** It relied on **AVL Tree Rotations** (`left_rotate`, `right_rotate`) to keep the height balanced. In modern competitive programming, heavy pointer-chasing and branch-heavy rotation conditions destroy Cache Locality and inflate the constant factor massively. I realized that instead of doing local...
/12285). The author successfully implemented the core base-logic: traversing down to a leaf and

Full text and comments »

  • Vote: I like it
  • +74
  • Vote: I do not like it

162.
By IamDragonite, history, 11 months ago, In English
Frequency Splitting (Binary Decomposition) Knapsack trick # Frequency Splitting (Binary Decomposition) Knapsack ## Problem Overview You are given a multiset of items. Each item has a **weight** `w`, and weight `w` appears **`cnt` times**. Your task is to determine **which total sums are achievable**. i.e., solve the subset-sum/knapsack *feasibility* problem. **Constraints** * Total sum of all weights `S = Σ (w · cnt) ≤ 1e6` * Many items may have identical weights * Only *reachability* matters (we do not need the number of ways) --- ## Naïve Approach Treat every copy as a separate item and run a standard bitset DP: ``` bitset<MAXS> dp; dp[0] = 1; for (int w : all_items) dp |= (dp << w); ``` Time complexity: * Number of items = `n` * One bitset shift costs `O(S / W)` where `W` is machine word size (typically 64) So total complexity is: `O(n · S / W)` Worst case example: * `n = 1e6`, `S = 1e6` → ~`1.5 × 10^10` word operations → **Time Limit Exceeded** --- ## Key Observations * M...
# Frequency Splitting (Binary Decomposition) Knapsack ## Problem Overview You are given a

Full text and comments »

  • Vote: I like it
  • +35
  • Vote: I do not like it

163.
By mazhar_ansari, history, 13 months ago, In English
How to crack MAANG (from competitive programming → interviews) — roadmap, timeline & resources Hey CF fam — many of you ask how to turn competitive programming skills into an offer from MAANG companies. Here’s a compact, battle-tested roadmap I’d post for anyone serious about making it happen. 1) Mindset first Treat it like a long contest with phases: preparation → polishing → interviewing → negotiation. Consistency beats intensity. Daily focused practice (1–3 hours) for many months wins. Track progress (problem lists, mock interviews, resume versions). 2) What the companies actually test Coding & algorithms: data structures, graph/tree/DP, greedy, bitmasks, complexity analysis. System design (mid–senior roles): high-level system thinking, trade-offs, scalability. Behavioral: clear communication, ownership stories, impact metrics. (Optional) ML/infra/OS/DB knowledge for specific roles. 3) Concrete 6–12 month plan (competitive programmers) Months 0–3 — Foundation Master arrays, strings, sorting, two pointers, hashing, stacks/queues. Implemen...
months wins. Track progress (problem lists, mock interviews, resume versions). 2) What the

Full text and comments »

  • Vote: I like it
  • -17
  • Vote: I do not like it

164.
By MrPupsik, 8 months ago, In English
Private Rooms on Orz Chat ! <div class="user-content"> <p>We know that you have used <a href="https://orzchat.com">orzchat.com</a> with great popularity, and that is why we are adding this bonus feature to make your experience even better.</p> <p>You can now create private, isolated chat rooms instantly for quick coordination with friends or discussing problems without clutter.</p> <ul> <li><b>Custom URLs:</b> Simply add any room name after the slash. For example: <code>orzchat.com/codeforces</code> or <code>orzchat.com/hello</code>. Anyone with that specific link can join.</li> <li><b>One-Click Private Chat:</b> Click the <b><img src="https://i.ibb.co/nM8b17bZ/image.png" alt="New private chat" style="max-width: 150px; height: auto; vertical-align: middle; margin: 0 5px;"/></b> button located on the bottom part of the page to automatically generate a unique, shareable link.</li> </ul> <p>The core philosophy remains the same: no registration, no persistent accounts,...
> The core philosophy remains the same: no registration, no persistent accounts

Full text and comments »

  • Vote: I like it
  • +19
  • Vote: I do not like it

165.
By Marinush, history, 5 years ago, In English
How to become Master. I see a lot of newbies trying to get better at cp. But working hard isn't enough. You need to have a goal in mind and follow it till the end (like becoming X till Y). Here I am gonna give some tips on how to become master. #### Participate in contests For master you need rating. To get rating you have to participate in contests. Nothing more needed to be said. #### Solve problems To get a good place in a contest, you have to solve problems. So, obviously, try to solve as many problems as you can. You might say that me saying this is useless and idiotic, but I disagree! I see a lot of people that give up after solving a certain amount of problems, but don't be like those people. They will never achieve anything meaningful in life. #### Have the correct mindset. Competitive programming is just as much about programming as it is about having a good mindset. It's all about competing, so you have to be in the right state of mind. You might ask me what it is, but I can'...
. #### Start small Solve an $800$ rating problem, if you can solve it without help then solve a $900

Full text and comments »

  • Vote: I like it
  • -35
  • Vote: I do not like it

166.
By reeWorld, 6 years ago, In English
ICPC Graph Mining Challenge solution Hi, fellow programmer :) I want to describe ideas that I used during [contest:1378]. #### First, how to get more than 600k score? For 600k score we can just implement what [this](https://arxiv.org/pdf/0803.0476.pdf) article says. Lets start with each cluster having only one vertex. **(1)** Then do the following thing until converge: choose random vertex and move it to one of the adjacent vertices cluster if it makes result better. **(2)** Now compress each cluster to one vertex and make new graph with weighted edges, then do everything like in **(1)** but now you are making clusters of clusters. I think image in article above explains it quite good. So, do **(1)** once and **(2)** until converge. Basically, that's it. <spoiler summary="features"> In my case "until converge" means "do _const_ iterations" (about 10kk-40kk iterations for **(1)**, 100k-3kk iterations for **(2)** and reapeat **(2)** 5-10 times). Not sure if it is all that important but: - if there are sever...
size and 1000-3000 clusters with single vertex. In the problem statement

Full text and comments »

  • Vote: I like it
  • +233
  • Vote: I do not like it

167.
By oversolver, 4 years ago, In English
Outstanding members of my cp library I like to build my [cp library](https://github.com/demidenko/olymp-cpp-lib). I am not aiming to fill it by each algo I have met, so content looks poor. Instead I am focusing on frequently used features or implement convenient api for powerful methods. Also I like to rate cp libraries of others and currently I noticed that my lib have enough implementations which I never seen before, so I want to share it with community. Hope it will inspire you to improve or rewrite your library and eventually rethink about some algorithms (which happens to me couple times). ## #5 Centroid decomposition [graphs/trees/centriod_decomposition.cpp](https://github.com/demidenko/olymp-cpp-lib/blob/master/graphs/trees/centriod_decomposition.cpp) This one is the perfect example of what I am calling convenient api. I've seen a lot of centroid decomposition snippets and almost all of them is template code or unfinished data structure with piece of code where you need to add your solution. I have s...
> [problem:484E] ~~~~~ auto res_bs = parallel_binary_search

Full text and comments »

  • Vote: I like it
  • +116
  • Vote: I do not like it

168.
By slycelote, 16 years ago, In English
Codeforces FAQ (unofficial) (This FAQ may be outdated. Please refer to official <a href="http://codeforces.me/help">help</a>).<br><br> I'm sure we won't need this post after Codeforces comes out of beta, but meanwhile it could be useful :) Feel free to suggest what should be added here.<br> <br><h3 align="center"><b>Competitions: general</b></h3><span class="comment-content-22873"><b>Q.</b> What are the rules of these contests?<div><b>A.</b> Read <a href="http://codeforces.me/blog/entry/456">this</a>.</div></span><br><div><b>Q. </b>What languages are supported? What are the compiler options and run command lines? What is the configuration of judge servers?<br> </div><b>A.</b> <span class="comment-content-11692">The judge machines are Core 2 Duo, 2.67 Ghz (E6750). </span>The full list of supported languages and compiler options can be found in <a href="../79">this post</a><br><br><b>Q.</b> How do I hack other's solutions?<br><b>A.</b> First lock your own solution in the main ('problems') tab. Then in you...
">The judge machines are Core 2 Duo, 2.67 Ghz (E6750). The full list of supported languages

Full text and comments »

  • Vote: I like it
  • +14
  • Vote: I do not like it

169.
By mostafa.saad.fci, 5 years ago, In English
@Udemy: Mastering critical SKILLS in Data Structures using C++ Dears, I recently started a new series of courses at Udemy [**[Mastering critical SKILLS](https://bit.ly/3lJ2SiL)**] series. The core value of this series is focusing on **gaining skills** through extensive practice NOT just knowledge like most of the free materials. So far I have finished C++17 and Python courses. The new course is a _C++ Data Structures_ course covering basic to advanced topics. [[**Coupons**](https://bit.ly/3lJ2SiL)]. About Udemy: - Don't get cheated by the default $150+ price. Udemy is usually on sale on weekly basis for $10-15. My coupons are active anyway - Within 30 days you can ask for refund for whatever reason (read policy). Feel free to try. Why paying if there are a lot of free materials? - My explanations are short and to the point in a practical way - Extensive practice from easy to hard. You can find hundreds of (redundant) problems on the internet. The course again saves your time by being very selective. - After the course, one sho...
://bit.ly/3lJ2SiL)**] series. The core value of this series is focusing on **gaining skills** through

Full text and comments »

  • Vote: I like it
  • +9
  • Vote: I do not like it

170.
By yeputons, 16 years ago, translation, In English
One more GCC bug (#323) Test code that I've created on contest:<br><a href="http://pastebin.com/jvkUcZx3">http://pastebin.com/jvkUcZx3</a><br>I think that function should return the same results if it calles with byte-to-byte equas parameters.<br>But in this case they are distinct.<br><strike>There is one more test program from MaxBuzz:<br></strike><span class="comment-content-18020"><div class="from-renderer"><strike>#include &lt;cstring&gt;</strike><div><strike>#include &lt;cstdio&gt;</strike></div><div><strike><br></strike></div><div><strike>int f(int x) { return 1 &lt;&lt; x; }</strike></div><div><strike><br></strike></div><div><strike>int main() {</strike></div><div><strike><span class="Apple-tab-span" style="white-space: pre;"> </span>for (int i = 0, j = 42; i &lt; 1000000; ++i)</strike></div><div><strike><span class="Apple-tab-span" style="white-space: pre;"> </span>if (!memcmp(&amp;i, &amp;j, sizeof(int)))&nbsp;</strike></div><div><strike><span class="Apple-tab-span" style="white-space: pre;"> </sp...
=/mingw Thread model: win32 gcc version 4.5.0 (GCC) Intel Core i3 M350 (x86)

Full text and comments »

  • Vote: I like it
  • +43
  • Vote: I do not like it

171.
By rishi2674, history, 2 years ago, In English
CSES-Longest Flight Route (Solutions) This is a very simple and detailed solution for the CSES problem [Longest Flight Route](https://www.cses.fi/problemset/task/1680) which a problem involving graph theory. The problem statement aims to find the longest route between 2 cities (1 and n) such that the route covers maximum no of distinct cities in the route. If we cannot reach the nth node from the 1st node, "IMPOSSIBLE" has to be printed. Else, print the length of route along with the cities encountered. The solution of this problem can be intuitively thought to be to find the maximum route using the depth first traversal in a graph. 1. The input is taken as an adjacency list represented the edges in a directed graph. 2. A visited array and mark_dfs() function is used to check whether nth node is reachable or not. If it is not reachable, "IMPOSSIBLE" is printed. 3. The core logic of the solution lies in storing the maximum distance of a node from the nth node in the dp array. A dfs is implemented from the 1st node tr...
The solution of this problem can be intuitively thought to be to find the maximum route using the, This is a very simple and detailed solution for the CSES problem [Longest Flight Route](https

Full text and comments »

  • Vote: I like it
  • +8
  • Vote: I do not like it

172.
By brunomont, history, 6 years ago, In English
[Tutorial] A powerful representation of integer sets Hello, Codeforces! This blog is heavily inspired by [user:TLE,2020-10-22]'s blog [using merging segment tree to solve problems about sorted list](https://codeforces.me/blog/entry/49446). I don't know exactly how well known this data structure is, but I thought it would be nice to share it anyway, along with some more operations that are possible with it. What it can do ------------------ We want a data structure that we can think of a set/multiset of **non-negative integers**, or even as a sorted array. We want to support all of the following operations: 1. Create an empty structure; 2. Insert an element to the structure; 3. Remove an element from the structure; 4. Print the $k$'th smallest element (if we think of the structure as a sorted array $a$, we are asking for $a[k]$); 5. Print how many numbers less than $x$ there are in the set (similar to lower_bound in a std::vector); 6. Split the structure into two: one containing the $k$ smallest elements, and the other ...
------------------ The memory consumption of the data structure might be a problem, though it can be

Full text and comments »

  • Vote: I like it
  • +338
  • Vote: I do not like it

173.
By Mkswll, 3 years ago, In English
Some tips regarding sets and multisets I actually thought I had a quite good understanding of std::set and std::multiset until D of the last Div. 2 contest taught me a lesson (you can tell from my submissions on D). So I decided to write this blog to prevent other people from making similar mistakes when overloading the < operator in sets (if these are just common sense then it's probably just my skill issue). If there exists a blog that talks about similar things please do inform me. Try to think of the output for each of the following codes. 1) (with std::set) <spoiler summary="Code 1"> ~~~~~ #include <bits/stdc++.h> using namespace std; struct node{ int l, r; bool operator < (node t) const& { return r - l < t.r - t.l; } }; int main(){ set <node> st; st.insert({1, 2}); st.insert({3, 5}); st.insert({6, 7}); cout << st.size() << "\n"; return 0; } ~~~~~ </spoiler> <spoiler summary="Explanation 1"> The output is 2 instead of 3 because {1, ...
> These tips are really about the same core idea, but I decided to write three tips because I

Full text and comments »

  • Vote: I like it
  • +78
  • Vote: I do not like it

174.
By ZodiacZ408, history, 4 months ago, In English
The Art of Disarray: A Deep Dive into Derangements (Subfactorials) Hello Codeforces! Combinatorics and counting problems are a staple in competitive programming. Today, I want to discuss a classic yet incredibly powerful concept that frequently appears in $O(N)$ DP optimizations and math-heavy problems: **Derangements**. Whether you are grinding Div. 2 B/C problems or tackling high-level combinatorics on USACO and AtCoder, understanding the intuition behind derangements is a massive advantage. Let's dive in! --- ### 1. What is a Derangement? A **derangement** is a permutation of the elements of a set such that *no element appears in its original position*. If we have an array $A = [1, 2, 3, \dots, N]$, a derangement is a permutation $P$ where $P[i] \neq i$ for all $1 \le i \le N$. **Classic Examples:** * **Secret Santa:** $N$ people put their names in a hat and each draws one. A valid state is when *nobody* draws their own name. * **The Hat-Check Problem:** $N$ guests check their hats. The attendant hands them back randomly. W...
. * **The Hat-Check Problem:** $N$ guests check their hats. The attendant hands them back randomly

Full text and comments »

  • Vote: I like it
  • +5
  • Vote: I do not like it

175.
By aviralx, history, 16 months ago, In English
What Happens When You Do CP Without Discipline > This isn’t one of those "how I became Candidate Master in 6 months" stories. > This is what happens when you say "I’ll do it tomorrow" for 3 straight years. I’m not red. Not purple. Hell, I’m not even consistent. I’m just someone who started CP with big dreams — and then made every mistake possible. If you’re stuck, lazy, unmotivated, scared, or feeling like you’re not improving... **Read this before you waste the same time I did.** --- ## Mistake #1: Practicing only when I felt motivated I’d solve 5 problems in one random burst, feel proud… and then disappear for 10 days. I blamed mood, college, stress, sleep. But here’s the thing: > CP doesn’t care how you feel. > If you're not consistent, you're not improving. --- ## Mistake #2: Clicking the editorial the second I got scared I’d read the statement. Felt hard. Editorial. Copy-paste. Move on. And then I told myself, "Well, at least I understood the idea." No. I didn’t. > I skippe...
stayed stuck. > You can’t dodge math in CP. > It’s not optional. It's the core

Full text and comments »

  • Vote: I like it
  • +88
  • Vote: I do not like it

176.
By greateric, history, 5 months ago, In English
IQ is Pure COPE, Here's Why (Useful CP and Life Information #5?) Background ------------------ On CF I think you can tend to see people attributing good rating to IQ. This is often associated with hopelessness when people are stuck in gray/green. I think it's the perfect cope &mdash; it's the easiest thing to say that completely explains why you're 1100 and your friend is orange, and, bonus, if anyone tries to prove you wrong, you can just claim that they are privileged and intelligent. You may think I am 2000 and thus out of touch to be able to comment on this topic, which _may_ be true. However, I was also once a noob who got 28/1000 on a USACO silver round. And I was pretty overweight as a kid and sucked at sports and always thought of myself as not having the genetics to be an athlete, but [I now hold the squat, bench, and deadlift 18-and-under state records in my powerlifting federation](https://pa.liftingdatabase.com/records-default?recordtypeid=72&categoryid=603&weightclassid=5). (Probably not for long though lol) A lot of this i...
> They can't even measure intelligence. Some guy DMed me a few weeks ago asking me to take aCORE IQ

Full text and comments »

  • Vote: I like it
  • +67
  • Vote: I do not like it

177.
By LightRay, history, 10 years ago, translation, In English
Are we getting closer to accepting C# as third language for competitive programming? Some time ago I read a lot of discussions about C# and competitive programming (particularly about C# and ACM). Many people think C# allows competitors to write cleaner (in comparison with C++) and shorter (in comparison with JAVA) code. There was the main problem with C# mentioned in almost all discussions: .NET wasn't open source and it required Windows for good performance and IDE. With developing Visual Studio Code and announcing .NET Core 1.0 these problems seem to be gone. Should we expect adding C# as third language in the nearest future, or some other problems exist?
shorter (in comparison with JAVA) code. There was the main problem with C# mentioned in almost all, With developing Visual Studio Code and announcing .NET Core 1.0 these problems seem to be gone

Full text and comments »

  • Vote: I like it
  • +45
  • Vote: I do not like it

178.
By DuyMinh3005, 3 months ago, In English
Is this acceptable? No, clearly not. <i>TL,DR: We (me and my friends) found a cheater in CF after he flexed his performance at round 1113 in LQDOJ's chat (an Online Judge's chat). We found some evidence, and he admitted that he used AI during the contest. However, he didn't even sorry, he just started to normalzize cheating, saying that cheating is crucial for the future. In this blog, I won't go deep into the evidence, but his attitude toward cheating.</i> This all started when he posted this: ![ ](https://cdn.corenexis.com/f/FLEtZepW31o.png) <blockquote> Translation:<br> pvhung (him): maybe it's D <br> pvhung: C used DP so it's quite hard.<br> pvhung: *started to flex* </blockquote> At this point, we are quite sure that he cheated, because his performance has never been this good. So we asked for his account. He didn't reply. That's when my friend realized that, if you calculate the total points that he got, combining with the timing that he sent. The result is, this is his accou...
> pvhung: That's your problem ![ ](https://cdn.corenexis.com/f/incmdeqXk00.png

Full text and comments »

  • Vote: I like it
  • +103
  • Vote: I do not like it

179.
By Kochekov, history, 5 years ago, In English
Hackerrank [Compile Error] Hello CF community, I encountered interesting compile error(bug?) while I was preparing contest on Hackerrank. When I run this code: <spoiler summary="Code"> ```cpp #include "bits/stdc++.h" using namespace std; vector<int>res; void solve(int l,int r){ if(l>r)return; res.push_back(r+1); solve(l+1,r); } int main(){ solve(0,1000000); cout<<res.size()<<endl; } ``` </spoiler> (you can open any problem and paste it on IDE part of problem), I get this type of error log: <spoiler summary="Error (stderr)"> ``` Reading symbols from Solution...done. [New LWP 357307] [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". Core was generated by `./Solution'. Program terminated with signal SIGSEGV, Segmentation fault. #0 0x000000000040125b in solve (l=698913, r=1000000) at Solution.cpp:6 6 res.push_back(r+1); To enable execution of this file add add-auto-load-safe-path /us...
; } ``` (you can open any problem and paste it on IDE part of problem), I get this type

Full text and comments »

  • Vote: I like it
  • +55
  • Vote: I do not like it

180.
By mostafa.saad.fci, 5 years ago, In English
Enhanced Training roadmap for newcomers Hey, I previously shared several posts about my training sheets. There are a lot of trainees used these sheets to improve their performance. The juniors sheet is a great **road-map** to avoid solving huge number of duplicate or uninteresting ideas. 1- [Juniors sheet problems](https://goo.gl/unDETI). [English Video](https://www.youtube.com/watch?v=4yt_PV3tflA) explaining it. [CF post](https://codeforces.me/blog/entry/65133) 2- [Seniors/ICPC/IOI Releasing sheet](https://bit.ly/37MSCjV). [CF post](https://codeforces.me/blog/entry/79231). Finish above sheet first (even for IOIers) 3- [Discord channel](https://discord.gg/BPXwwcBVZJ) 4- [Important Video](https://www.youtube.com/watch?v=tsNv9F3DGpQ) to address Psychological Concerns in CP ---------- I recently have started a **Udemy** series named **Mastering Critical Skills**. The goal of the series is to smoothly teach Programming, OOP, Algorithms and Data Structures. The core of the series is to provide **intens...
teach Programming, OOP, Algorithms and Data Structures. The core of the series is to provide

Full text and comments »

  • Vote: I like it
  • +30
  • Vote: I do not like it

181.
By flying_saucer, 9 months ago, In English
Iterative Digit DP (A bit simpler approach) ## 1. What is Digit DP? Digit DP is a technique used to compute information such as counts or sums of numbers within a range `[l, r]`, when the constraint depends on the digits of the number. Here, the bounds can be very large (up to $10^{18}$ or larger). Instead of solving the range directly, we reduce the problem to: <br><br> $$ Answer(l, r) = F(r + 1) - F(l) $$ where `F(n)` computes the required information for all numbers in the range `[0, n)`. Thus, the main task becomes implementing a function `F(n)`. Although Digit DP is often presented recursively, an iterative formulation is usually easier to debug and understand once the idea is clear. This article describes the iterative viewpoint. --- ## 2. Core Idea to implement the function F(n) To make this work cleanly, we represent all integers using the same number of digits by allowing leading zeros. Additionally, we prepend one extra leading zero to every integer so that the most significant digit is a...
directly, we reduce the problem to: $$ Answer(l, r) = F(r + 1) - F(l) $$ where `F(n

Full text and comments »

  • Vote: I like it
  • +37
  • Vote: I do not like it

182.
By NISARG_07, history, 5 months ago, In English
CSES Pro: Collapsible Progress Dashboard, Codeforces-style Copy/Paste & Star Bookmarks Hello Codeforces Community! The CSES Problemset (cses.fi) is widely considered one of the best platforms for mastering core algorithms and data structures. However, compared to platforms like Codeforces, it lacks a few quality-of-life features that can make your practice workflow much smoother. Specifically: 1. You have to save your code to a file locally just to upload and submit it. 2. There are no copy buttons on the input/output sample test cases. 3. There is no built-in way to bookmark/star tasks you want to review later. 4. There is no dynamic category-wise progress tracker, solve streak counter, or random problem selector. To solve these annoyances, I built CSES Pro -- a lightweight, completely free, and open-source Chrome Extension that injects these features directly into the native CSES site. --- ## Feature Showcase ### 1. Codeforces-Style Submit Editor No more saving temporary .cpp or .py files on your desktop just to upload them. The extension repl...
platforms for mastering core algorithms and data structures. However, compared to platforms like

Full text and comments »

  • Vote: I like it
  • +4
  • Vote: I do not like it

183.
By dkdk, history, 3 months ago, In English
Constructive Algorithms: Binary & Fibonacci # Fixed Value Construction: Binary & Fibonacci *Translated to English using AI. For a better reading experience, please visit: [https://dk-qwq.github.io/blog/posts/bin-fib-decomposition/](https://dk-qwq.github.io/blog/posts/bin-fib-decomposition/)* ## Core Idea: Base Graph + Regulator Regardless of the fixed-value construction method used, the essence is to construct a logarithmic-level base, and then use a regulator to construct the target fixed value through splitting methods similar to binary or Fibonacci. --- ## 1. Binary Decomposition ### 1. Principle Overview By observing the value function, construct a base graph of the form $f_i = 2 \times f_{i - 1}$, obtaining $f_i = 2^i$. Perform a binary decomposition on the required fixed value, and finally achieve the construction of the fixed value through the regulator. ### 2. Practice Problems #### [Codeforces 388B &mdash; Fox and Minimal path](https://codeforces.me/problemset/problem/388/B) **Problem Stat...
://dk-qwq.github.io/blog/posts/bin-fib-decomposition/)* ## Core Idea: Base Graph + Regulator

Full text and comments »

  • Vote: I like it
  • +16
  • Vote: I do not like it

184.
By CristianoPenaldo, history, 4 years ago, In English
Atcoder 279G-At most 2 colors: Generating functions [Second-hand, Newbie Oriented]. **Part1: Introduction** [Atcoder Beginner Contest 279](https://atcoder.jp/contests/abc279) is good for learning [generating functions (GFs)](https://en.wikipedia.org/wiki/Generating_function). GFs could solve two of them (G and Ex). The English version tutorial of [279Ex](https://atcoder.jp/contests/abc279/tasks/abc279_h) has already been posted on the [MathStackExchange](https://math.stackexchange.com/questions/4586327/sum-of-product-of-min-which-is-related-to-the-pentagonal-number-theorem) by a kind person. Unfortunately, the English tutorial on [279G](https://atcoder.jp/contests/abc279/tasks/abc279_g) is not available. Now I would like to make a second-hand tutorial on [279G](https://atcoder.jp/contests/abc279/tasks/abc279_g) based on [PCTprobability's idea](https://atcoder.jp/contests/abc279/editorial/5293). I spend a huge amount of time understanding this idea. For contestants at about my level, it is quite difficult to understand [the idea](https://atcoder.jp/contests/abc27...
is definitely not the best way to solve this problem. It could be solved much simpler by using

Full text and comments »

  • Vote: I like it
  • +77
  • Vote: I do not like it

185.
By Abdullah_Ahmer, 3 days ago, In English
Would you be interested in a platform dedicated to actually learning competitive programming? **Hi Codeforces.** I've been working on an idea for a platform aimed primarily at beginners who want to get into competitive programming, but also at more experienced programmers who want to strengthen their fundamentals and fill gaps in their knowledge. The goal is to create a structured learning environment that takes someone from the absolute basics to more advanced concepts, with an emphasis on actually understanding algorithms, data structures, and problem-solving techniques rather than simply memorising solutions. A few things I'm considering: - **A substantial free tier:** Most of the core learning experience would be freely accessible, so beginners can get genuine value without having to pay. - **Two optional paid tiers:** For those who want additional resources, features, and a more comprehensive learning experience. - **Structured learning:** Helping beginners build strong foundations, while also giving more experienced users an opportunity to revisit and refine...
emphasis on actually understanding algorithms, data structures, and problem -solving techniques rather

Full text and comments »

  • Vote: I like it
  • -3
  • Vote: I do not like it

186.
By 39_w_M9, 2 years ago, In English
Binarysearch.com [Potential Buyout] bump! Hello Codeforces, If you were active in the CP community 2 years ago or so, you are probably familiar with the website 'Binarysearch.com'. It created a unique mix of the layout of discord with the core concept of problem-solving. One of its main features was creating private/public rooms where you can compete to solve problems and gain tokens to advance in levels. Sadly, the owners shutdown the site due to budget issues, and with that went a community of eager problem solvers and streamers that spent lots of time progressing on this website as well as a very well designed platform with many nice problems. A team and I are considering a potential buyout of this website. If anyone is in contact with the owners or knows how we can reach them, we would appreciate it if you can comment or message us.
the core concept of problem-solving. One of its main features was creating private/public rooms where, website 'Binarysearch.com'. It created a unique mix of the layout of discord with thecore concept of

Full text and comments »

  • Vote: I like it
  • +22
  • Vote: I do not like it

187.
By satylogin, history, 5 years ago, In English
[Rust] Generic Segment Tree I wanted to write and keep a segment tree implementation for myself, that I could use more generally (all reasonable data types, and all reasonable operations). I finally decided to write one and add it to [cp-lib](https://github.com/satylogin/cp-lib). The core struct for now is: ~~~~~ pub struct SegTree<T, F> where T: Clone + Copy, F: Fn(T, T) -> T, { n: i32, default: T, cell: Vec<T>, lazy: Vec<T>, op: F, } ~~~~~ And usage: ~~~~ let mut tree = SegTree::new(10, i32::MIN, std::cmp::max); tree.insert(1, 10); tree.insert(2, 20); assert_eq!(tree.query(1, 10), 20); tree.insert_range(3, 6, 10); assert_eq!(tree.query(5, 10), 10); ~~~~ Where op is the operation that the segment tree performs (min, max, gcd, or something custom), and default is the value the should be returned as query default and gets stored during initialization. The major benefit is that it allows for me to write more complicated segtree rather easily,<br>...
it to [cp-lib](https://github.com/satylogin/cp-lib). The core struct for now is: ~~~~~ pub

Full text and comments »

  • Vote: I like it
  • +26
  • Vote: I do not like it

188.
By mdammarhossain, history, 10 months ago, In English
Not a Regular Coder, But a Logical Thinker: My Journey with Codeforces I am not a regular coder. I don’t solve problems every day, I code occasionally, whenever time, motivation, or curiosity allow. However, one thing has always remained constant: my interest in logic and algorithms. For me, Codeforces is not just a competitive programming platform. It is a place where reasoning matters more than speed, where understanding a problem deeply is often more important than writing code quickly. When I approach a problem, I don’t immediately jump into implementation. Instead, I ask myself: What is the core idea of the problem? What do the constraints suggest? Is this based on observation, greedy thinking, dynamic programming, or graphs? Sometimes I solve a problem quickly. Sometimes I spend a long time thinking and still fail to get an accepted solution. But even then, I usually learn something valuable. There are days when I read editorials instead of coding. There are days when I only solve easier problems. And there are days when I surprise ...
implementation. Instead, I ask myself: What is the core idea of the problem? What do the constraints suggest, : What is the core idea of the problem? What do the constraints suggest? Is this based on observation

Full text and comments »

  • Vote: I like it
  • -28
  • Vote: I do not like it

189.
By YF_YUSUF, 5 months ago, translation, In English
I didnt undesrtand E2 In the latest Educational Round, there was [a problem E](https://codeforces.me/contest/2233/problem/E2) that was split into two subproblems. After solving E1, I realized that my solution can solve E2. This made me curious about the participants who hadn't solved E2 yet, and what their idea was. After looking at a few submissions, I noticed their core idea was identical to mine. I even resubmitted four of their solutions for E2—and three of them got Accepted, even though those participants hadn't even attempted E2. Looking further, I found the exact same code used by [this participant](https://codeforces.me/contest/2233/submission/377982014) and another user, though I forgot the handle of the other one. My sample size was taken from participants ranked between 200th and 400th on the leaderboard. In short, I wanted to point out that many gray and green participants submitted E1 but didn't submit E2, even though their code passes all the tests for E2.
In the latest Educational Round, there was [a problem E](https://codeforces.me/contest/2233

Full text and comments »

  • Vote: I like it
  • +15
  • Vote: I do not like it

190.
By dinohaur, history, 16 months ago, In English
CEOI 2025 discussion Since CEOI 2025 is over and the tasks and test data have been published, can we discuss the solutions here? Here are the [tasks](https://ceoi2025.utcluj.ro/category/13). Upd: you can find the tasks [here](https://codeforces.me/blog/entry/144670?#comment-1293960) (for now) Upd: https://github.com/asociatia-sepi/archive/tree/main/CEOI-2025 Upd: I was upsolving this CEOI now for practice and I decided to write some solutions because I couldn't find them. ## Boardgames ### Solution 1 This is the approach from the official editorial. The core idea relies on a **divide and conquer** strategy: 1. Initially, we invoke the function $f(1, n)$. 2. Find the position $i$ closest to the border such that $i$ and $i+1$ are not in the same connected component. 3. If the subgraph from $L$ to $R$ is connected, we can just return $1$. 4. Otherwise, we split the problem and return $f(L, i) + f(i+1, R)$. The main implementation challenge here is to efficiently maintain graph con...
### Solution 1 This is the approach from the official editorial. The core idea relies on a **divide and

Full text and comments »

  • Vote: I like it
  • +70
  • Vote: I do not like it

191.
By adamant, history, 4 years ago, In English
Nimbers and Sprague-Grundy theorem Hi everyone! Today I'd like to write about the so-called Grundy numbers, or nimbers. I will start by providing a formal recap on the Sprague-Grundy theorem and then will advance to the topic that is rarely covered in competitive programming resources, that is I will write about nimber product and its meaning to the game theory. _I was asked to add the following to the blog: THANK SIR MASTER [user:ADAM_GS,2022-06-12] FOR GREAT AND VALUABLE REVIEW SIR_ ## Prerequisites Familiarity with the following concepts: - Basic [set theory](https://en.wikipedia.org/wiki/Set_theory) notion: [union](https://en.wikipedia.org/wiki/Union_%28set_theory%29), [cartesian product](https://en.wikipedia.org/wiki/Cartesian_product) and [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference) of sets, [set of all subsets](https://en.wikipedia.org/wiki/Power_set) denoted as $2^A$, etc; - [Groups](https://en.wikipedia.org/wiki/Group_%28mathematics%29) and [fields](https://en.wiki...
$. What we need to prove now is that there is $a_v$ such that $(V, \delta, v) \sim N_{a_v}$.Core

Full text and comments »

  • Vote: I like it
  • +204
  • Vote: I do not like it

192.
By hadi, 17 years ago, In English
Max-Flow Min-Cut Some days ago I came across a nice problem: <a href="http://acm.timus.ru/problem.aspx?space=1&amp;num=1533">Fat Hobbits</a> . The problem's input is a directed acyclic graph G = (V, E)&nbsp; with additional property that if (u, v) is in E and (v, z) is in E then (u, z) is also in E, i.e. it has transitive closure, and asks for a maximum size subset of vertices IND such that if v is in IND and u is in IND, then none of (u, v) and (v, u) are in E.<br><br>Problem seemed difficult for me at first, but finally I could solve it by modeling it as a min-cut problem. The problem can be easier solved once you know <a href="http://en.wikipedia.org/wiki/Dilworth%27s_theorem">Dilworth's Theorem</a> and how to prove it.<br><br>From time to time you will see problems which can be solved using max-flow min-cut algorithms. To see some more problems, see topcoder tutorial <a href="http://www.topcoder.com/tc?module=Static&amp;d1=tutorials&amp;d2=maxFlow2">Maximum Flow, Section 2</a> and also <a href="htt...
/problem?id=3469">Dual Core CPU, , Core CPU, Intervals <http://acm.pku.edu.cn/JudgeOnline/<B>problem</B>?id=3680>, and many

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it

193.
By Pathya, history, 15 months ago, In English
Alternating Turns on a Graph I was thinking of creating this problem (it feels like a fundamental one, but I haven’t found it on any website). Can anyone help me figure out the optimal solution, or point me to a known reference if it already exists? Problem Statement: You are given a directed graph with n nodes labeled 0 to n-1. A token starts at node 0. Two players play a game on this graph, taking turns alternately: On each turn, the current player must move the token along one outgoing edge of the current node. Player A wants the token to reach node n-1 in as few moves as possible. Player B wants to delay this as much as possible, or prevent the token from ever reaching node n-1. If both players play optimally, output the number of moves required for the token to reach node n-1. If Player A cannot guarantee reaching node n-1, output -1. Note: As a variation, edge weights can be introduced but I feel the essence of this problem is that it is closer to chess than Dijkstra. Here's wh...
why this problem seems so complicated to me: The core difficulty is mutual anticipation; Every

Full text and comments »

  • Vote: I like it
  • +3
  • Vote: I do not like it

194.
By ok12, 8 months ago, In English
Editorial of ICPC de Tryst 2026 I hope you enjoyed the contest! [Contest link](https://codeforces.me/contestInvitation/f8ab858a73f3627f85787c828e7ba84d12495ce9) <spoiler summary="Rating Predictions and Tags for the Problem"> | Problem | Expected Rating | Tags| | :---: | :---: | :---: | | [A. Game is Game](https://codeforces.me/gym/675631/problem/A) | 1500 | games, math | | [B. Hakurei Shrine's Purification Ritual](https://codeforces.me/gym/675631/problem/B)| 1600 |number theory, binary search| | [C. Permutation Game](https://codeforces.me/gym/675631/problem/C) | 2600 | dp, greedy, implementation,brute force | | [D. Path Blow-up?](https://codeforces.me/gym/675631/problem/D) | 2400|bitmasks, trees, dp, combinatorics, implementation| | [E. Coffee Date of MEX](https://codeforces.me/gym/675631/problem/E)|2100|constructive algorithms, brute force| | [F. Wordleforces](https://codeforces.me/gym/675631/problem/F) |1800 |math, combinatorics| | [G. Adaptive Guessing](https://codeforces.me/gym/675631/probl...
/f8ab858a73f3627f85787c828e7ba84d12495ce9)

Full text and comments »

  • Vote: I like it
  • +102
  • Vote: I do not like it

195.
By Geothermal, history, 7 years ago, In English
AtCoder Beginner Contest 133 English Solutions Since AtCoder often doesn't release English editorials to their beginner contests, I thought I'd write up my solutions. Feel free to add a comment if anything was unclear! A &mdash; T or T ------------------ Our alternatives here are sending all $N$ people on the train, for a total of $N \cdot A$ yen, or using the taxi, for a total of $B$ yen. We should thus print the minimum of these two values. Code: https://atcoder.jp/contests/abc133/submissions/6265526 B &mdash; Good Distance ------------------ We reword the problem slightly: for how many points $y$ and $z$ is $\sum_{k=1}^D (y_i-z_i)^2$ a perfect square? Given the small input constraints, we know that this sum is going to be at most $10 \cdot (20-20)^2 = 16000$. Hence, we can simply compute a list of all perfect squares less than $16000$ and iterate over all $\dbinom{N}{2}$ pairs of points. For each pair of points, we compute the summation and check if it is equal to any of our squares. If so, we increment th...
------------------ We reword the problem slightly: for how many points $y$ and $z$ is $\sum_{k=1

Full text and comments »

  • Vote: I like it
  • +98
  • Vote: I do not like it

196.
By Adarsh_Singh_01, history, 23 months ago, In English
Why Math is Crucial for Competitive Programming? Mathematics and competitive programming go hand in hand. At first glance, competitive programming might seem all about coding, algorithms, and data structures. However, a closer look reveals that math plays a fundamental role in solving many of the problems we encounter in contests. Here’s why math is so important for competitive programming: --- **1. Core Concepts Are Rooted in Math** Many algorithms and techniques are based on mathematical principles. From number theory (modular arithmetic, GCD/LCM) to combinatorics (permutations and combinations), these concepts frequently show up in competitive programming problems. Understanding these ideas helps you approach problems with confidence. --- **2. Optimization Requires Mathematical Insight** Efficient solutions often involve reducing the problem to a mathematical formula. For example, finding patterns, computing minimum steps, or solving recurrence relations requires logical thinking derived from math. --- **...
is so important for competitive programming: --- **1. Core Concepts Are Rooted in Math

Full text and comments »

  • Vote: I like it
  • -31
  • Vote: I do not like it

197.
By Arbuzik342, history, 6 weeks ago, translation, In English
Div. 4 G = 1800: Evolution or Loss of Division Purpose? Hello Codeforces! Lately, I’ve been looking closely at the difficulty distribution in recent **Division 4** rounds, and something feels fundamentally off. When [user:MikeMirzayanov,2026-10-03] originally introduced Div. 4, the core philosophy was clear: create an accessible, welcoming environment for absolute beginners and lower-rated participants to experience competitive programming without hitting an immediate, insurmountable wall. It was meant for people who are still mastering basic concepts. But let’s look at the reality of recent contests. We are routinely seeing **Problem G (and sometimes F) hitting 1700–1800+ difficulty ratings**. Is this really a natural "evolution" of the platform, or have we completely lost the original purpose of the division? ### The Two Sides of the Coin Like any controversial topic, there are two main perspectives here: * **The "Top Separator" Argument:** Supporters argue that the last problem *must* be difficult. It acts as a har...
] originally introduced Div. 4, the core philosophy was clear: create an accessible, welcoming

Full text and comments »

  • Vote: I like it
  • -6
  • Vote: I do not like it

198.
By BitwiseXOR, history, 2 years ago, In English
N-ary tree Locking Problem I’ve been working on this problem for several days but still struggle. The problem involves an N-ary tree (where each non-leaf node has exactly n children). The goal is to implement a Lock() operation with the following rules: Lock(string X, int id): If node X is already locked, you cannot lock it, so return false. If any of X's descendants are locked, you cannot lock it, so return false. If any of X's ancestors are locked, you cannot lock it, so return false. If none of the above conditions are met, lock node X with the given ID and return true. You are required to handle M queries of the Lock() operation on a multi-core machine, allowing M threads to run the Lock() function concurrently. However, since the function involves multiple internal checks, locking two nodes simultaneously can result in race conditions. How would you make the Lock() function thread-safe?
N-ary tree Locking Problem, I’ve been working on this problem for several days but still struggle. The problem involves an N, You are required to handle M queries of the Lock() operation on a multi-core machine, allowing M

Full text and comments »

  • Vote: I like it
  • -11
  • Vote: I do not like it

199.
By sh19910711, 12 years ago, In English
Snippet Manager for Online Judges Greetings :-) ### tl;dr https://github.com/social-snippet/social-snippet ![Application Demo](http://social-snippet.github.io/img/ss-use.gif) ---- ### 0. Introduction to the Social Snippet I'm starting a new software project, "[The Social Snippet Project](https://social-snippet.github.io/)", to manage the snippet libraries for the online judges (e.g. [watashi's library](https://github.com/watashi/AlgoLib), [marioyc's library](https://github.com/marioyc/ACM-ICPC-Library) and etc...). As its name implies, it's made possible to share and retrieve your snippet libraries around the world through [GitHub](https://github.com) and other hosting services. The social snippet project provides several things: 1. Command-line interface to use and manage the snippet libraries and its dependencies 2. [Registry system](https://sspm.herokuapp.com) to find the snippet libraries 3. Editor plugins to use the snippets actually (e.g. [Vim](http://www.vim.org), [Emacs](http://...
/501/submission/9413315 ---- #### Installation Guide Core utilities (including command-line

Full text and comments »

  • Vote: I like it
  • +26
  • Vote: I do not like it

200.
By Nourhan_Abo-Heba, history, 9 months ago, In English
Dijkstra's Algorithm (Priority Queue Version) In this blog, we discuss an implementation of Dijkstra's Algorithm to compute the shortest paths from a single source in a directed weighted graph with non-negative weights. --- ## Problem Setting We are given: * `n` nodes (numbered from 1 to n) * `m` directed edges * Each edge has weight `w ≥ 0` Goal: Find the shortest distance from node `1` to every other node. ### Example Input: ``` 4 5 1 2 1 1 3 4 2 3 2 2 4 5 3 4 1 ``` Output: ``` 0 1 3 4 ``` Explanation: * Node 1 → Node 1: distance = 0 * Node 1 → Node 2: distance = 1 (direct edge) * Node 1 → Node 3: distance = 3 (path: 1 → 2 → 3) * Node 1 → Node 4: distance = 4 (path: 1 → 2 → 3 → 4) --- ## When to Use Dijkstra Use Dijkstra when: * The graph is weighted * All weights are non-negative * You need shortest paths from a single source Do NOT use Dijkstra when: * Negative edge weights → use Bellman-Ford or SPFA * All-pairs shortest paths → use Floyd-Warshall * Unweig...
from a single source in a directed weighted graph with non-negative weights. --- ##Problem

Full text and comments »

  • Vote: I like it
  • -24
  • Vote: I do not like it

201.
By tonstudio, history, 19 months ago, In English
Tact Smart Battle 1 Hello everyone! <img src="/predownloaded/3a/50/3a50476aa2f98e2292fa0193e214deba84429d19.png" style="width:250px;float:right;margin:0 1em 1em 1em;"/> We at [TON Studio](https://tonstudio.io/) are proud to present the [contest:2105], a week-long smart contract coding competition powered by the [Tact language](https://tact-lang.org/). This challenge is designed to push your problem-solving skills to the limit as you tackle real-world blockchain development tasks on The Open Network (TON). With a $20,000 prize pool and unique opportunities for recognition, we invite you to join this exciting event. **<u><font color="#008ce3">About the Challenge</font></u>** Participants will solve five progressively complex tasks focused on building efficient voting systems. Each task is crafted to test different aspects of smart contract development: 1. **Simple Voting:** — basic voting system. 1. **Serial Voting:** — multiple proposals via a master contract. 1. **Scalable Voting:** — sup...
[Tact language](https://tact-lang.org/). This challenge is designed to push yourproblem-solving

Full text and comments »

Announcement of Tact Smart Battle 1
  • Vote: I like it
  • +91
  • Vote: I do not like it

202.
By do4Z, history, 4 years ago, In English
An intresting debugging incidence in a beginner's(my) CF journey - Hashmap Blowup I was solving [Train and Queries](https://codeforces.me/contest/1702/problem/C) and my submission [190745271](https://codeforces.me/contest/1702/submission/190745271) got TLE in test case 19(I know space complexity is bad but it's beacuse i wanted to solve it with priority queue only). I was calculating time complexity of my code again and again but it was all ok in code according to me because i was considering time complexity of operations of hashmap O(1) ( which is true for most of the cases) . Then i watched tutorial and seen the same core approach as mine,but i didn't copy that solution because i wanted to know what was wrong in my code. Then i noticed 18th test case(previous one of the failed test case) and that test case passed by using same size of array and number of queries that of failed test case. Then i came to know that TLE is not because of size of array and number of queries,instead it's due to elements of the array and then had intuition that there is something wrong...
I was solving [Train and Queries](https://codeforces.me/contest/1702/problem /C) and my submission

Full text and comments »

  • Vote: I like it
  • -4
  • Vote: I do not like it

203.
By bhikkhu, 14 months ago, In English
BUMP: Super lean lazy Fenwick tree with auto tests I have polished my implementation after ten long days of refactoring and minimizing the number of variables required to keep track of each action. I added hardcore random numbers tests to tally results against brute force verifier. I have tested it against a dozen problems. It's a continuous process. Please just run the program it will automatically test against the brute force algorithm for range update and queries. The code should be extremely easy to understand from what it was ten days ago. The rest of logic is just propagation of lazy values from top to the bottom of the intervals. Solution for below CSES https://pastebin.com/Tnr0f5PF https://cses.fi/alon/task/1651 <spoiler summary="Fenwick tree with lazy propagation "> ~~~~~ #include <iostream> // For cin, cout #include<cassert> #include <vector> // For vector container #include <tuple> // For tuple #include <random> // For mt19937 and uniform_int_distribution #include <chr...
DEFAULT_COMBINE (0) // ===================== Core Functions ===================== bool

Full text and comments »

  • Vote: I like it
  • +10
  • Vote: I do not like it

204.
By IBACKFORREVENGE, history, 3 months ago, In English
If you are trying to understand the optimal strategy for E [**If you are trying to understand the optimal strategy for E.**](https://codeforces.me/contest/2257/problem/E) Busy Beaver, you can think of it like an RPG city-building game where your goal is to use greedy block merging and a min-heap to grind for cash and build the tallest skyscraper possible. You start with a small amount of carrots and need to complete profitable construction "quests" across various sites before dumping all your accumulated wealth into a single building. Since some individual floors make a profit while others lose money, you first merge any unprofitable floor with the floors directly above it until the combined block yields a strictly positive net profit, creating a "quest" with a specific peak money requirement to survive construction and a total net payout at the end. Once you have these strictly profitable quests, you throw the first available one from every building into a min-heap sorted by their entry requirement and greedily complete the cheapest ones...
/2257/problem/E) Busy Beaver, you can think of it like an RPG city-building game where your goal is, To mathematically solve the "Busy Beaver" problem, you must model the construction process using

Full text and comments »

  • Vote: I like it
  • -21
  • Vote: I do not like it

205.
By Baraa-Ahmed, 9 months ago, In English
Zaglol FCDS Contest Solutions **[Zaglol Contest &mdash; FCDS level 1:](https://codeforces.me/gym/106350)** Problem [A. Zaglol welcoming](https://codeforces.me/gym/106350/problem/A): <spoiler summary="Solution"> Print **FCDS** </spoiler> <spoiler summary="Code"> ~~~~~ #include <iostream> using namespace std; int main() { cout << "FCDS" << endl; } ~~~~~ </spoiler> Problem [B. Baby Baraa in ALBAIK](https://codeforces.me/gym/106350/problem/B): <spoiler summary="Hint"> Notice that the values of $a_i$ are bounded: $(1 \le a_i \le 100)$. </spoiler> <spoiler summary="Solution"> It is easy to see that the $O(N^2)$ brute-force approach will be too slow for the given constraints. Therefore, we need a faster way to count, for each $i$, how many indices $j > i$ satisfy $(a_i > a_j)$. Since that the values of $a_i$ are bounded: $(1 \le a_i \le 100)$, we can use a frequency array to count how many numbers smaller than a given value appear to its right. We process the array fro...
**[Zaglol Contest — FCDS level 1:](https://codeforces.me/gym/106350)** Problem [A. Zaglol

Full text and comments »

  • Vote: I like it
  • +18
  • Vote: I do not like it

206.
By hydroshiba, 5 years ago, In English
Weird sorts #1 — LIS sort I like sorting algorithms very much, and I usually come up with weird ideas for sorting. Sometimes I wonder would those work properly, and now when I finally have the time from social distancing, I decided to start a series on my eccentric ideas &mdash; Weird sorts. As an introductory problem for Dynamic Programming, you all probably know about the Longest Increasing Subsequence problem (LIS). But what if we apply this… to sorting? Today in the first blog of the Weird sorts series, I introduce to you… the LIS sort. #### **Basic idea** The core idea is to extract the LIS from the current array and repeat it until the current array is empty. It can be shown that this process always terminates, because there will always be a LIS that have a size of at least 1, thus at each pass, we will always take at least 1 element away from the array. In the implementation, we will first find the LIS of the array and separate the LIS from the rest of the array. We will then recursively perfo...
decided to start a series on my eccentric ideas — Weird sorts. As an introductoryproblem

Full text and comments »

  • Vote: I like it
  • +184
  • Vote: I do not like it

207.
By ConstructorU, history, 5 years ago, translation, In English
SIT & JUB STAR Contest 2022 <center> <img alt="SIT" src="https://codeforces.me/predownloaded/b7/59/b7597e61079718f49f275cfc2b343e9c1461bb78.png" style="float:right; height: 250px; margin: 10px; max-width:50%;"/> </center> Hello, Codeforces! We are thrilled to announce the dates of our annual online programming competition, the **SIT & JUB STAR Contest 2022**, organized by the Schaffhausen Institute of Technology (SIT) in Switzerland and our partner Jacobs University Bremen (JUB) in Germany. Winners will have the chance to receive exciting prizes, including a full scholarship for **Master in Computer Science and Software Engineering** program. **<font color="#00a987">What is the SIT & JUB STAR Contest?</font>** The goal of the SIT & JUB STAR Contest is to promote interest in the field of Computer Science and Software Engineering, giving participants an opportunity to demonstrate their knowledge of programming. It is also a winning ticket for full scholarship to a master program. To partici...
research-centric approach and an entrepreneurial mentality at its core, the SIT education ecosystem is a

Full text and comments »

  • Vote: I like it
  • +201
  • Vote: I do not like it

208.
By Sacha, history, 9 months ago, In English
[Tutorial] Auxiliary Trees for QlogQ offline queries about Dynamic Forest _This blog post is a submission for the [Codeforces Month of Blog Posts Pt. III](https://codeforces.me/blog/entry/149422) challenge. Thank you [user:cadmiumky,2026-02-09] for the initiative!_ Hello, Codeforces! Recently I heard a short tale about one idea on algocourses.ru (from [user:teraqqq,2026-02-01]) and I realized the idea is powerful, so probably it should be more recognized. **This post has been written with my best knowledge. If something is incorrect, please let me know!** #### **Intro** Dynamic Forest queries are usually solved with [Link Cut Tree (LCT)] (https://youkn0wwho.academy/topic-list/lct). However, for offline queries there's a powerful Divide&Conquer technique that avoids the heavy implementation of LCT. This blog explains this technique. Spoiler: LCT is faster. <hr> Related techniques <span style="color: gray; font-size: 70%;">($N$ denotes the number of vertices and $Q$ denotes the number of queries.)</span>: - [Auxiliary/Virtual tree](https:...
merge vertices ####Core idea: **Unlike Methods 1️⃣ and 2️⃣, we don't merge vertices. However

Full text and comments »

  • Vote: I like it
  • +115
  • Vote: I do not like it

209.
By YoussefMorad1, 3 years ago, In English
More Respectful Problem Names, please! #### Hello Codeforces community! I'd like to discuss an issue from [contest:1847] that caught my attention. The problem name, **"The Man who became a God"**. Codeforces has been an incredible platform for enhancing our skills and engaging in healthy competition. However, the problem name gave me pause. As a Muslim, it directly contradicts and disrespects my core beliefs. Moreover, it may also offend individuals of different faiths. Furthermore, I discovered that some of my friends chose not to participate in the contest upon noticing the problem name (unfortunately, I only noticed it after the contest had ended). This incident highlights the impact that such names create divisions and discourage people from engaging in the Codeforces community. It is important to remember that Codeforces is a global community with participants from diverse backgrounds, cultures, and beliefs. As a platform that aims to bring programmers together, it is crucial that we keep an environment where ...
More Respectful Problem Names, please!, attention. The problem name, **"The Man who became a God"**. Codeforces has been an incredible, competition. However, the problem name gave me pause. As a Muslim, it directly contradicts and disrespects

Full text and comments »

  • Vote: I like it
  • -236
  • Vote: I do not like it

210.
By bholagabbar, 11 years ago, In English
BitMasking & Subset Listing for Absolute Beginners I happened to write an answer on Quora yesterday for **'How to list all the subsets of a set where elements need not be necessarily unique'**. http://qr.ae/fwOCc Though several tutorials already exist, here is my 'simplified' version solving the above problem using bitmasking because personally, I was really confused when i learnt this first. Also, this is my first attempt at writing something. Please feel free to comment/criticize and please upvote if you liked the explanation :) More than often, problems where you feel the answer can be found after brute forcing through all the subsets, have smarter and more efficient solutions using Dynamic Programming. Have a look at an Introduction to the Knapsack Problem and Dynamic Programming: http://www.cs.rit.edu/~zjb/courses/800/lec7.pdf That aside, if n is reasonably small, you CAN use BruteForce and list down all the subsets in the process. As mentioned, we will use the technique of BitMasking. Alright, so lets start by trying ...
exist, here is my 'simplified' version solving the above problem using bitmasking because personally

Full text and comments »

  • Vote: I like it
  • +13
  • Vote: I do not like it

211.
By Obadajo, history, 6 weeks ago, In English
[Trick] Checking Divisibility of Large Numbers by 2^a 5^b **Checking Divisibility of Large Numbers by 2^a * 5^b** Just wanted to share a simple math **trick** regarding the divisibility of large numbers (represented as strings) when the divisor $N$ consists of powers of 2 and 5. ### Core Idea Since base 10 is formed by $10 = 2 \times 5$, any power $10^k$ contains $2^k \cdot 5^k$ as factors. If $N = 2^a \cdot 5^b$ and $k = \max(a, b)$, then $10^k$ is guaranteed to be a multiple of $N$. Any large integer $S$ can be written as: $$S = A \cdot 10^k + B$$ where $B$ is the integer formed by the last $k$ digits of $S$, and $A$ represents all preceding digits. Taking both sides modulo $N$: $$S \pmod N \equiv (A \cdot 10^k + B) \pmod N \equiv B \pmod N$$ **Takeaway:** A number $S$ is divisible by $N = 2^a \cdot 5^b$ if and only if the integer formed by its last $k = \max(a, b)$ digits is divisible by $N$. ### Quick Examples * $N = 8 = 2^3$: Check the last 3 digits ($k = 3$). * $N = 25 = 5^2$: Check the last 2 digits ($k =...
$ consists of powers of 2 and 5. ### Core Idea Since base 10 is formed by $10 = 2 \times 5$, any power

Full text and comments »

  • Vote: I like it
  • +16
  • Vote: I do not like it

212.
By amartya110, 8 months ago, In English
Editorial for CodeHurdle Athlos 03 We want to thank you all for participating in the contest, and hope you enjoyed it. Any feedback would be appreciated! [Contest Link](https://codeforces.me/contestInvitation/757663ba04187f27abf08bbf2fa40710f1777b4f) ### [A — Modular Station Assembly](https://codeforces.me/gym/677155/problem/A) Writer: [user:amartya110,2026-01-19] <spoiler summary="Editorial"> Even Dimensions: If $n$ or $m$ is even, the grid can be perfectly tiled using only $1 \times 2$ I-Beams, making the answer YES.Thin Grids: If $n=1$ or $m=1$ (and the other is odd), the C-Core module cannot fit physically as it requires a $2 \times 3$ footprint, leaving an odd area that $1 \times 2$ beams cannot fill (NO).Small Odd Grids ($3 \times 3$): Although the area is 9, placing a $2 \times 3$ footprint C-Core in a $3 \times 3$ space creates geometric obstructions that prevent the remaining 4 cells from forming two valid $1 \times 2$ blocks (NO).Large Odd Grids: For all other odd $n, m \ge 3$, there is sufficient...
="Editorial"> $1.$ Understanding the Core Constraint The most important rule in thisproblem is the

Full text and comments »

  • Vote: I like it
  • +9
  • Vote: I do not like it

213.
By orz69, history, 2 years ago, In English
I hate newbies and pupils and specialists they all lack skill and need to grind Newbies, pupils, and specialists on Codeforces often lack skill due to a fundamental failure to engage deeply with the core principles of competitive programming. Newbies typically rush through basic concepts without truly internalizing them, leading to shallow understanding. Pupils often plateau because they focus too much on solving problems within their current comfort zone, neglecting to expand their knowledge of more advanced algorithms and data structures. Specialists, despite being more experienced, often become complacent, relying on repetitive problem types and avoiding the more complex, diverse challenges that would push their skills further. Overall, many fail to invest in deliberate practice, struggle to adapt to a variety of problem-solving approaches, and rarely step outside their limited scope, resulting in slow or stagnant skill growth. **I also hate [user:TheSlayer33]as I am from the future and I know it is gonna be a very low quality user judging from the score distr...
engage deeply with the core principles of competitive programming. Newbies typically rush through basic

Full text and comments »

  • Vote: I like it
  • -18
  • Vote: I do not like it

214.
By smax, 4 years ago, In English
[Tutorial] Fully Dynamic Trees Supporting Path/Subtree Aggregates and Lazy Path/Subtree Updates Hey everyone! Usually when I post stuff on CF I just drop an external link to my blog, but this time I would like to also paste the same content natively on CF to see if it leads to more engagement. You can read the exact same article on my blog [here](https://mzhang2021.github.io/cp-blog/ds5/). Also, special thanks to [user:alien_lover,2022-06-10] and [user:gabrielwu,2022-06-10] for proofreading. --- ## Motivation We will solve **[this problem](https://dmoj.ca/problem/ds5)**. ## Prologue The original name of this problem is [SONE1](https://darkbzoj.cc/problem/3153), originating from the fiery depths of Chinese OI. Amazingly, the Chinese have figured out how to augment the link/cut tree to solve this problem (ref [1](https://www.cnblogs.com/clrs97/p/4403244.html), [2](https://blog.csdn.net/iamzky/article/details/43494481)). Maintaining subtree aggregates with a LCT isn't difficult, and there's a well-known [Codeforces article](https://codeforces.me/blog/entry/67637) ...
proofreading. --- ## Motivation We will solve **[this problem](https://dmoj.ca/ problem/ds5

Full text and comments »

  • Vote: I like it
  • +259
  • Vote: I do not like it

215.
By M_Sameer, history, 6 weeks ago, In English
Yet another AI tool: SMS AI for text, code, and document processing has major update. ![SMS AI Platform Screenshot](/predownloaded/3e/9f/3e9fcbf2650418a66c5efe5ea813f0c645135b2c.png) Hello Codeforces. Recently, I have been building a project called SMS AI. It is a simple but fast multimodal workspace to chat, generate code snippets, and parse documents. Now it has major update. I noticed that a lot of general web tools have quite high latency when streaming code blocks or rendering formatting properly. I wanted to see if I could optimize the processing structure to bring the time-to-first-token down under 100 milliseconds. [cut] The current implementation is live and can be tested here: [SMS AI](http://sms-ai-delta.lovable.app). Core implementation details The platform is lightweight and split into a few basic utilities that might be helpful if you are working on problems or analyzing long reference texts: • Syntax Highlighting & Code Generation: It outputs and formats raw scripts in standard languages (C++, Python, etc.) with clean sy...
is live and can be tested here: [SMS AI](http://sms-ai-delta.lovable.app). Core implementation

Full text and comments »

  • Vote: I like it
  • -16
  • Vote: I do not like it

216.
By d1mk, 10 months ago, In English
Project 525 — Introduction ### Core Idea I have set 6 goals that I want to achieve in the next 525 days. The date I am aiming for is the **16th of June, 2027** (exactly 525 days from today). I choose that date because it should be about the day when I graduate from high school, which I believe is a great milestone in my life. All of the goals will be known only by me, and they will be revealed after 525 days. If I fail in accomplishing any set goals, I (and everybody interested) will know it's only my fault, and it will be pretty unpleasant. On the other hand, if I succeed in accomplishing all of them, then I can add some more to fail! I will be posting weekly blogs and updates on goals, without revealing too much. To make the blogs less plain and boring to read, I will also be adding some cool problems and their solutions or some useful algorithms/techniques that I encountered in that week. I will try to have something interesting, but don't expect too much, as I am quite inexperienced. ### Inspiration ...
### Core Idea I have set 6 goals that I want to achieve in the next 525 days. The date I am aiming

Full text and comments »

  • Vote: I like it
  • +40
  • Vote: I do not like it

217.
By stark_happy, history, 2 years ago, In English
Can someone PLEASE help me out for upskilling myself iafter these contests ? Hi ! to whoever is reading this . I know this is another post crying out for some help to reach Pupil or Grandmaster but please , I really need some guidance . I had been practising CP from last 1.5 years on various platforms ( CP , not DSA or core concepts ) and initially I could solve Div 2A , 2B in half and hour and 2C after the Contest :( but I was never admant to reach an appreciable level on the platform. But , SInce last 20-30 days , I have been toiling hard and practising and studying DSA and all the core concepts of CP on various platforms , solving problems , reading solutions and again repeating the cycle and this time , after a very large gap , I decided to again take the challenge and reach atleast reach green in 2-3 Contests ( too much overconfidence ) but , to my shock , I rarely cross Div 2A these days and Div 2B also seems undoable . I don't know what went wrong in that large gap . SO , this is just a request if some experienced people can guide me &mdash; h...
the core concepts of CP on various platforms , solving problems , reading solutions and again, years on various platforms ( CP , not DSA or core concepts ) and initially I could solve Div 2A , 2B

Full text and comments »

  • Vote: I like it
  • -3
  • Vote: I do not like it

218.
By cschill, history, 5 years ago, In English
Explained: why you are stuck between pupil and expert Hello everyone, In this blog, I have given some relevant logic on why you are stuck between pupil and expert. Please at least skim through the text once to get the idea. I am a noob-coder so, don't expect some algo material in this blog. However, if you are stuck between pupil and expert and feeling sad (like I do) because we are not getting any motivation, as the hard work we put in doesn't correspond with the result, then this blog is definitely for you. I started code forces in mid-2020, wasn't regular gave some contests that time, I had zero knowledge of any DSA concepts. Barely knew STL, and now I have done DSA and Advanced Algorithms courses in my college, in which I performed greatly. Solved all the standard questions of DP & graph. But apparently, I am performing worse than before, so I went to the old contest that I have solved previously in which I was able to solve A and B getting me to a rating around 1340, I was easily able to solve A, B and C under 45 mins. I r...
realised some things have changed, or maybe it could be that I just got lucky with the Cproblem

Full text and comments »

  • Vote: I like it
  • -36
  • Vote: I do not like it

219.
By dcordb, history, 10 years ago, In English
My solution gets TLE on 712D (Memory and Scores) Hi everyone. My [solution](http://codeforces.me/contest/712/submission/20538623) to problem [712D](http://codeforces.me/contest/712/problem/D) gets TLE, even though its complexity is $\mathcal{O}(t \cdot d)$. Where $d$ is the difference between the score of Memory and Lexa. Note that $-2 \cdot 10^5 \leq d \leq 2 \cdot 10^5$. The funny thing is that in my laptop (Intel Core i5, 4gb ram) my solution runs in 1.2s. What do you think about this, is CF that slow? Anyway could you help me?
Hi everyone. My [solution](http://codeforces.me/contest/712/submission/20538623) toproblem [712D

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it

220.
By MrMoon, 3 months ago, In English
HU JCPC Qualification 2026 Tutorial Hints are mostly related, so you have to think and get some observations before understanding the next, make sure to understand the code before you submit it as well, "The world is full of obvious things which nobody by any chance ever observes" ~the,2026-08-02 poet. Big thank you to the testers for improving this problem set beyond what it was, [user:JwanaAlghonmien,2026-08-20] , [user:halakreishan7,2026-08-20], [user:Mohammad-Najjar,2026-08-20], [user:samuelster,2026-08-20], [user:moath_mohammed,2026-08-20], [user:real_MBS,2026-08-20], [user:SaDOS.exe,2026-08-20] and Thank you to the organizers in HU especially [user:hyasat,2026-08-21] and of course judges and writers, [user:DarkVoidd,2026-08-21] and [user:Aziz_05,2026-08-21] and [user:babushkaguy,2026-08-21] and others that are mentioned down in the blog. The contest exist in the group so make sure to join https://codeforces.me/group/ppRciMeJFg/contests A video tutorial by the one and only [user:hyasat,2026-08-22] [YouT...
for improving this problem set beyond what it was, [user:JwanaAlghonmien,2026-08-20

Full text and comments »

  • Vote: I like it
  • +7
  • Vote: I do not like it

221.
By techgodprogrammer, history, 5 months ago, In English
Announcement: A New Unified Discord Community for Competitive Programmers! Hey everyone! I am incredibly excited to announce the launch of a brand-new Discord server built entirely for competitive programmers who want to learn, discuss solutions, and grow together! Instead of isolating everyone into separate skill channels, this server is designed to be one massive, unified community space. We believe that Newbies, Pupils, Specialists, Experts, and Candidate Masters should all chat, debug, and share insights in the exact same rooms to maximize mentorship and learning speed. What makes this server special? Native Onboarding Role Selection: The moment you click join, Discord will let you instantly select your official Codeforces rating tier to customize your color profile! Unified Hub Channels: One central place to talk about algorithms, hardware setups, and interesting CF blogs. Post-Contest Debriefs: A dedicated fast-paced channel to discuss approaches, logic, and system tests right after the contest timer hits zero. Deep Problem Solving Help: A shared debug...
, and system tests right after the contest timer hits zero. Deep Problem Solving Help: A shared

Full text and comments »

  • Vote: I like it
  • -27
  • Vote: I do not like it

222.
By CodeAmico, history, 2 years ago, In English
Breadth-First Search (BFS): The Layer-by-Layer Exploration ## **1. Introduction to BFS** BFS, or Breadth-First Search, is one of the primary techniques for traversing graphs and trees. It’s commonly used in scenarios where you want to: - Explore all nodes connected to a starting node before moving deeper. - Find the shortest path in an unweighted graph (more on this soon). - Work with level-order traversal in tree structures. If you’re familiar with Depth-First Search (DFS), you’ll notice BFS works differently. While DFS “dives deep” and backtracks, BFS explores **breadth-wise**, visiting nodes layer by layer, radiating out from the starting node. ### Visual Example Consider the following graph: ``` A / \ B C /| |\ D E F G ``` Starting from **A**, BFS visits nodes in this order: **A, B, C, D, E, F, G**. ### Why BFS is Layer-by-Layer BFS is designed to visit nodes in waves or “levels” around the start node. This property makes it perfect for finding the shortest path in unweighted graphs. Let...
. Let’s break down how this level-wise processing works. ## **2. The Core Idea Behind BFS** In BFS

Full text and comments »

  • Vote: I like it
  • +2
  • Vote: I do not like it

223.
By CristianoPenaldo, history, 4 years ago, In English
On Atcoder Beginner Contest 272F -- Two Strings Please note that this blog is a review of [this problem](https://atcoder.jp/contests/abc272/tasks/abc272_f). It is not novel enough to be an editorial. This problem may not be difficult for those people who are beyond purple, but very difficult for me. To be more self-contained, I copy the problem here: Problem Statement: You are given strings $S$ and $T$ of length $n$ each, consisting of lowercase English letters. For a string $X$ and an integer $i$, let $f(X,i)$ be the string obtained by performing on $X$ the following operation $i$ times: Remove the first character of $X$ and append the same character to the end of $X$. Find the number of integer pairs $(i,j)$ satisfying $0≤i,j≤n−1$ such that $f(S,i) \leq f(T,j)$ lexicographically. For example, when $n=3$, $S=$"adb", $T=$"cab", there are 4 pairs: (1)$i=j=0$, "adb" $\leq$ "cab"; (2)$i=2, j=0$, "bad" $\leq$ "cab"; (3)$i=0, j=2$, "adb" $\leq$ "bca"; (4)$i=j=2$, "bad" $\leq$ "bca". You can find more test cases here:...
Please note that this blog is a review of [this problem ](https://atcoder.jp/contests/abc272/tasks

Full text and comments »

  • Vote: I like it
  • +42
  • Vote: I do not like it

224.
By AB22, 4 weeks ago, In English
Eitri: A Practical Competitive Programming Workflow ## The problem [Eitri](https://github.com/veryshyjelly/eitri) solves In competitive programming, the code you write while developing a solution often differs from the code you finally submit. During development, you benefit from a modular codebase: separate files for I/O utilities, graph algorithms, data structures, and other helpers make your work easier to read, test, and reuse. However, most online judges expect a single source file. Manually combining library files, resolving dependencies, maintaining the correct order, and stripping unused code is tedious and error‑prone—especially during a contest when minutes matter. Beyond library management, competitive programmers face other repetitive tasks: creating a new file for each problem, copying sample test cases whenever the solution changes, hunting through a file picker to open the right source, and repeatedly compiling and testing by hand. [Eitri](https://github.com/veryshyjelly/eitri) addresses these pain points by inte...
## The problem [Eitri](https://github.com/veryshyjelly/eitri) solves In competitive programming

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it

225.
By pimenta, history, 10 years ago, In English
Two versions of the offline square root decomposition for dynamic minimum spanning tree ### Introduction It's been around 18 months since dynamic minimum spanning tree first crossed my way and yesterday I've finally understood the offline square root decomposition for this problem. I think this solution is somehow explained [here](http://codeforces.me/blog/entry/16967), but I also think it can be explained in a better way. This is the goal of this post. I'll explain how to solve two versions of the problem. ### Acknowledgments I'd like to thank [user:thiagocarvp,2017-02-25] for explaining me the solution to the first version and [user:victoragnez,2017-02-25] for explaining me the solution to the second version. ### First version #### Problem statement First, you're given a connected graph with $n$ vertices and $m$ weighted edges. And then a sequence of $q$ new edges is added to the graph. For each of these $q$ new edges, output the weight of a minimum spanning tree considering only this and the previous edges. For example, take $V = \{1,2\}$, $E = \{(\{...
way and yesterday I've finally understood the offline square root decomposition for thisproblem. I

Full text and comments »

  • Vote: I like it
  • +82
  • Vote: I do not like it

226.
By nithinsanjey, history, 8 years ago, In English
First 4 codeforces contests. Learning from mistakes. I am a full time corporate programmer in Java for web development and a CS engineering graduate. Here I would like to share my experience through my first 4 Codeforces contests. Programming for web development is a lot different from programming in competitive contests. In web, much work depends on where the data comes from(customer/database) and where the data goes to (database/UI). But here, in Codeforces, programming is Math. And so depends on algorithm and data structures. As Knuth points out, Algorithm + Data structure = Programming I would like to write on my learning in each part separately. ### Algorithm I was jumping into programming immediately on seeing the problem which worked well in A problems but not to others. I realize that I should I should take my pen & paper and make an algorithm before jumping into code. Otherwise I consumed a lot of time figuring out the algorithm while coding while paper is easier and more intuitive as a beginner(at least for me)....
problem which worked well in A problems but not to others. I realize that I should I should take my pen

Full text and comments »

  • Vote: I like it
  • +38
  • Vote: I do not like it

227.
By HGGMco15, history, 3 months ago, In English
How to practice algorithm for newbie? Hi everyone, I just created a new account on Codeforces to practice competitive programming. I am currently a Newbie I am comfortable with basic programming syntax, but I want to improve my problem-solving skills systematically. I can usually solve problems A and B in Div. 3 or Div. 4 contests, but I often get stuck on problem C or when a problem requires specific algorithmic thinking. I would appreciate any advice on the following questions: 1. What core algorithms or mathematical topics should a Newbie master first to consistently solve Div. 3/Div. 4 C problems?What is the most effective way to practice? 2. Should I solve problems by specific tags (like greedy or math) or just pick random problems from the problemset within a specific rating range (e.g., 1100–1200)? 3. Are there any specific training sheets, ladders, or groups you recommend for someone at my level? Thank you for your time and guidance!
currently a Newbie I am comfortable with basic programming syntax, but I want to improve myproblem, 1. What core algorithms or mathematical topics should a Newbie master first to consistently solve

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it

228.
By bugfree786, history, 6 years ago, In English
idleness limit exceeded on test 1 .net core c# Hello This is Mehtab Butt from Pakistan I really need the help of the code forces community because I am new at this platform and on the submission of my Nezzar and Symmetric Array, the problem I am getting the error Idleness limit exceeded. I am coding in c#. I did not find any satisfactory solution on google as well. Link to my code: https://codeforces.me/contest/1478/submission/106223889
idleness limit exceeded on test 1 .net core c#, because I am new at this platform and on the submission of my Nezzar and Symmetric Array, theproblem I

Full text and comments »

  • Vote: I like it
  • +9
  • Vote: I do not like it

229.
By sidat, 7 months ago, In English
International Coding League Round 1 Editorial ### [problem:681359A] **Problem Idea:** [user:kkapoor,2026-03-31] <spoiler summary="Solution"> We are given an array $a$ and need to find the maximum length subsequence $b$ such that for every adjacent pair: $$b_i \ \&\ b_{i+1} \ne 0$$ This means that every pair of consecutive elements in the subsequence must share at least one common set bit. #### Key Observation Two elements can be adjacent in the subsequence if and only if their bitwise AND is non-zero, i.e., they share at least one common bit. Instead of working with values directly, we can think in terms of bits (from $0$ to $32$). #### Approach Define a DP array: $$dp[b] = \text{maximum length of a valid subsequence ending with an element having bit } b$$ We process the array from left to right. For each element $a_i$: 1. Find all bits that are set in $a_i$ 2. Compute: $$best = 1 + \max(dp[b]) \quad \text{over all bits } b \text{ set in } a_i$$ If no such bit exists (i.e., all correspon...
### [problem:681359A] **Problem Idea:** [user:kkapoor,2026-03-31]

Full text and comments »

  • Vote: I like it
  • +10
  • Vote: I do not like it

230.
By sofyanalam, 4 months ago, In English
[Tutorial] Solution for Codeforces Round 1111: E. Build a Tree [cut] In this post, I want to share my approach to solving **Problem E: Build a Tree** from Codeforces Round 1111. <spoiler summary="The Math Intuition"> The problem asks us to construct a tree with $n$ vertices such that $\sum_{i=1}^{n} dist(i, (i \bmod n) + 1) = k$. Let $dist(i, j) = dep(i) + dep(j) - 2 \cdot dep(LCA(i, j))$. Summing this over the cycle $i=1 \dots n$: $$\sum_{i=1}^n dist(i, (i \bmod n) + 1) = 2 \sum_{i=1}^n dep(i) - 2 \sum_{i=1}^n dep(LCA(i, (i \bmod n) + 1))$$ **Key takeaways from this equation:** 1. **$k$ must be even:** Since the RHS is multiplied by $2$, the total sum $k$ must be an even number. If $k$ is odd, no such tree exists. 2. **Minimum $k$ is $2(n-1)$:** This occurs when the tree is a "star graph" (all nodes connected to the root), which keeps depths minimal. 3. **Maximizing $k$:** To reach a higher $k$, we need to maximize depths and minimize the $dep(LCA)$ terms. The LCA of adjacent nodes $(i, i+1)$ becomes $0$ (the root) ...
[cut] In this post, I want to share my approach to solving **Problem E: Build a Tree** from

Full text and comments »

  • Vote: I like it
  • +36
  • Vote: I do not like it

231.
By NWm, history, 10 months ago, In English
Happy New Year 2026! CF-Tool Browser Mode is Here! tDear Codeforces Community, As we bid farewell to an amazing 2025 and welcome the exciting possibilities of 2026, I'm thrilled to announce a significant update to **cf-tool** that brings a powerful new way to interact with Codeforces from your command line! ## What's New? **cf-tool now supports Browser Mode!** After Cloudflare tightened its protection, traditional command-line tools faced challenges accessing Codeforces. Today, we're proud to introduce a solution that leverages your browser's authenticated session through the power of browser automation. ### Key Achievement: Parse & Submit POC Complete The core functionality is now **fully working**: - **`cf parse`** &mdash; Fetch problem test cases with ease - Supports both old (`<br>`) and new (`<div>`) HTML formats - Automatically handles multi-line inputs correctly - Clean, formatted test case files - **`cf submit`** &mdash; Submit your code directly from CLI - Automatic problem selection (w...
: Parse & Submit POC Complete The core functionality is now **fully working**: - **`cf parse

Full text and comments »

  • Vote: I like it
  • -8
  • Vote: I do not like it

232.
By AnandOza, history, 6 years ago, In English
Atcoder Beginner Contest 183 — Unofficial English Editorial Hi all, [Atcoder Beginner Contest 183](https://atcoder.jp/contests/abc183) was today. I wrote an unofficial English editorial. Hope it helps! ### [A: ReLU](https://atcoder.jp/contests/abc183/tasks/abc183_a) We simply write an if statement. Runtime: $\mathcal{O}(1)$. <spoiler summary="Sample code"> ~~~~~ int x; re(x); if (x < 0) { x = 0; } ps(x); ~~~~~ </spoiler> ### [B: Billiards](https://atcoder.jp/contests/abc183/tasks/abc183_b) The trick is to reflect $G$ over the x-axis, so the desired path becomes a straight line. Then it's a matter of simple math to compute the intersection of that line with the x-axis. Runtime: $\mathcal{O}(1)$. <spoiler summary="Sample code"> ~~~~~ double x1, y1, x2, y2; re(x1, y1, x2, y2); y2 *= -1; double r = -y2 / (y1 - y2); double ans = x1 * r + x2 * (1 - r); ps(ans); ~~~~~ </spoiler> ### [C: Travel](https://atcoder.jp/contests/abc183/tasks/abc183_c) Because $N$ is so small, we can simply try all $(N-1)!$ o...
/tasks/abc183_f) The core idea is that there are two $O(NQ)$ solutions (too slow!). Let's call type 1

Full text and comments »

  • Vote: I like it
  • +44
  • Vote: I do not like it

233.
By 4aii_Blabn, 2 months ago, In English
[Tutorial] Online Dynamic Generalized Suffix Automaton (Trie SAM) via Link-Cut Tree Hello Codeforces! Building a Suffix Automaton (SAM) for a single string is a classic linear-time algorithm. Extending it to a set of strings (a Trie) is also common, known as a Generalized Suffix Automaton (GSAM). However, most standard implementations for GSAM are done **offline** (usually using BFS) to preserve the $O(N)$ time complexity. For a deep mathematical analysis of the standard offline construction and space bounds, you can refer to this paper: https://static.googleusercontent.com/media/research.google.com/en//pubs/archive/35395.pdf But what if the problem forces us to build the SAM on a Trie **strictly online**? If we blindly apply the standard SAM construction online on a Trie, the amortized complexity analysis breaks. The cloned states and suffix link redirections can force us to traverse long paths repeatedly, blowing the complexity up to $O(N^2)$ in the worst case (imagine a star-shaped Trie or multiple branches sharing the same suffix paths). In this tut...
://static.googleusercontent.com/media/research.google.com/en//pubs/archive/35395.pdf But what if theproblem forces us to

Full text and comments »

  • Vote: I like it
  • +78
  • Vote: I do not like it

234.
By jigyasu_kalyan, 13 months ago, In English
Why Lazy Segment Tree needs a push() function? Hello Codeforces, We all learn `push()/push_down()` function when studying Lazy Segment Trees. It's the engine that propagates the changes stored on a node to its children. This ensures that before we recurse deeper, the children of the current node are updated with any pending changes, guaranteeing we always work with consistent data. I was just studying Lazy Segment Trees and a fundamental question came to my mind. Is it possible to continue in Lazy trees without this `push()` function? I tried some variations of problems where we use Lazy Propagation with push() function, and tried to solve and find approaches on paper pen and I was able to find way to solve problems without push() function. I discussed with my peers an faculty if they can prove me wrong in those solutions and can provide some variation where we strictly need push() function with lazy tree. I am listing some variations below and their standard approaches of lazy tree with push() function and my approach of lazy tre...
tree without push() function. Range Update Point Query ------------------------ Theproblem is to

Full text and comments »

  • Vote: I like it
  • +5
  • Vote: I do not like it

235.
By A2SV_Group6, history, 13 months ago, In English
A2SV G6 — Round #33 (Editorial) [Here](https://codeforces.me/contests/643986) is the contest link. All problems are from Codeforces' Problemset. #### [A. Memory and Crow](https://codeforces.me/gym/643986/problem/A) <spoiler summary="Solution"> Note that a[i] + a[i + 1] = b[i]. Use the initial condition b[n] = a[n] and we can figure out the entire array b. Time Complexity: O(n) </spoiler> <spoiler summary="Code"> ```python3 n = int(input()) nums = list(map(int, input().split())) answer = [] for i in range(n): if i == n-1: answer.append(nums[i]) else: answer.append(nums[i] + nums[i + 1]) print(*answer) ``` </spoiler> #### [B. Kassu and a Beautiful Array](https://codeforces.me/gym/613323/problem/B) <spoiler summary="Hint"> What is the maximum possible gcd that we can get? </spoiler> <spoiler summary = "Solution"> We need the number of permutations P of length N such that gcd⁡(1 * P1, 2 * P2, …, N * PN) > 1. <p> <strong> Key idea: <stron...
Codeforces' Problemset. #### [A. Memory and Crow](https://codeforces.me/gym/643986/problem/A

Full text and comments »

  • Vote: I like it
  • +3
  • Vote: I do not like it

236.
By Renegade, 12 years ago, In English
My solution to Google APAC 2015 Cut Tiles Problem Enzo is doing renovation for his new house. The most difficult part is to buy exactly the right number of tiles. He wants N tiles of different sizes. Of course they have to be cut from the tiles he bought. All the required tiles are square. The lengths of side of the tiles are 2S1, 2S2, ..., 2SN. He can only buy a lot of tiles sized M*M, and he decides to only cut tiles parallel to their sides for convenience. How many tiles does he need to buy? [cut] Input The first line of the input gives the number of test cases: T. T lines follow. Each line start with the number N and M, indicating the number of required tiles and the size of the big tiles Enzo can buy. N numbers follow: S1, S2, ... SN, showing the sizes of the required tiles. [cut] Output For each test case, output one line containing "Case #x: y", where x is the test case number (starting from 1) and y is the number of the big tiles Enzo need to buy. [cut] Limits 1 ≤ 2Sk ≤ M ≤ 2^31-1. Small dataset ...
Problem Enzo is doing renovation for his new house. The most difficult part is to buy exactly

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it

237.
By ROKKAMKARTHIKEYAREDDY, history, 2 weeks ago, In English
Request for Account Review and Restoration Dear [ MikeMirzayanov] and Codeforces Administration, ========================================================= I am writing to sincerely apologize and request a manual review of my disabled account, [karthikeya_rk]. My account was recently disabled due to a violation regarding AI usage. I fully acknowledge that using AI assistants to generate code solutions during live contests goes against the core values of fair competition on Codeforces. I deeply regret making this mistake and taking an unfair shortcut.`` Codeforces has always been an invaluable platform for me to learn, improve my problem-solving skills, and be part of the competitive programming community. Losing access to my account has made me realize the importance of academic integrity and honest practice. If given a second chance, I promise to strictly adhere to all platform rules, solve every problem completely on my own, and never use AI tools or external assistance during active rounds again. I am entirely willing to...
the core values of fair competition on Codeforces. I deeply regret making this mistake and taking an

Full text and comments »

238.
By NPsolved.cpp, history, 8 months ago, In English
OPC March 2026 Editorial Thank you for participating in $\mathbf{OPC\ March\ 2026}$! This editorial outlines the key ideas and solution approaches for each problem. We hope it helps you gain deeper insights and further strengthen your problem-solving skills in competitive programming. We would greatly appreciate your feedback. Please share your thoughts through this [Google Form](https://docs.google.com/forms/d/e/1FAIpQLSf2jvScUIwpxy16neU-CKQj7wIFx9diAO7vFY7TJSERR_PFwQ/viewform) Contest Link: [Link](https://codeforces.me/group/hUywLYmr80/contest/678537) ### [A. Find Sum](https://codeforces.me/group/hUywLYmr80/contest/678537/problem/A) <spoiler summary="Hint 1"> To make a sum of differences as large as possible, you want to subtract the smallest available numbers and add the largest available numbers. </spoiler> <spoiler summary="Solution"> The cost function is $Cost = |a_n - a_1| + \sum_{i=2}^{n} |a_i - a_{i-1}|$. This is equivalent to the total distance traveled if you start...
ideas and solution approaches for each problem. We hope it helps you gain deeper insights and further

Full text and comments »

  • Vote: I like it
  • +8
  • Vote: I do not like it

239.
By paarth_arora, history, 4 months ago, In English
D. diss_quack and Array Game Hello Codeforces! Today I want to share a detailed breakdown of the problem D. diss_quack and Array Game. This problem initially looks like a complex game theory simulation, but it elegantly reduces to bitwise math and offline precomputation. Here is a step-by-step approach to solving it. ### Prerequisites * Bitwise Operations (Popcount, Leading Zeros) * Greedy Algorithms * Suffix Minimums / Precomputation --- ### Observation 1: Bob's "Stopper" Strategy Let's analyze the game from Bob's perspective. Bob wants to maximize Alice's moves. Alice's most powerful move is dividing the entire array by 2 (which she can only do if $a_1$ and all elements in the prefix are even). To stop this, Bob's optimal strategy is to find an odd number and swap it to index 2. This acts as a "stopper," completely breaking Alice's even prefix and forcing her to only divide $a_1$, completely isolating her moves to one element at a time. If Bob can do this, Alice is forced to eliminate the...
Hello Codeforces! Today I want to share a detailed breakdown of the problem D. diss_quack and Array

Full text and comments »

  • Vote: I like it
  • -18
  • Vote: I do not like it

240.
By i_hate_pahadans, history, 10 months ago, In English
how do you find questions? hey am just about to get completed with cses sheet now i wanna practice more questions not learn any algo i mean i left advanced maths topics for now ill do it later i wanna find tough or mediocre questions of what ive learned so far and random not like selecting cause if i seelct i get to know the tags which makes it useless and i end up finding solution more easily like given the problem uses dsu so it just gives me a huge hint about the problem and i continue to think around dsu and end up finding answer i wanna find random problems recently ive been giving virtual contests or just solving random d's from div 2 cause they have the core dsa please help me with this or give me some sheet or smth to practice
tags which makes it useless and i end up finding solution more easily like given theproblem uses

Full text and comments »

  • Vote: I like it
  • -2
  • Vote: I do not like it

241.
By geetxnshgoyal, history, 10 months ago, In English
Common Mistakes Beginners Make in Codeforces (From a Newbie) Hi everyone, I am a beginner on Codeforces (newbie rating ~800), and I wanted to share a few simple but important things I learned while participating in my first few contests. These are not advanced tricks or optimizations — just basic observations that helped me reduce mistakes and understand problems better. I hope this helps other beginners like me. 1. Always read constraints before coding Earlier, I used to directly start coding after reading the statement. Many wrong answers happened because the input size was too large for my approach or I used int where long long was required. Now I first decide the time complexity and data types before writing code. 2. Edge cases are as important as main logic Even when the core logic is correct, missing edge cases like single element, empty range, or all values being the same can easily cause WA. Testing small cases manually helped me a lot. 3. Div-3 A/B problems are usually straightforward Many times I felt that a problem l...
as important as main logic Even when the core logic is correct, missing edge cases like single

Full text and comments »

  • Vote: I like it
  • -1
  • Vote: I do not like it

242.
By rsampaths16, history, 9 years ago, In English
Help to verify Deep-Q-network, reinforcement learning algorithm source. ***disclaimer : I do realise this request is not related to the conventional coding contests | problems asked here, but still hope to find people of similar interests, who would like to help.*** I have been into Machine Learning and Deep Learning for a while now and it's been going smoothly. There is however a catch, that it's hard for me to verify the working of complex structures due to the limit's of my hardware compute (quad-core i5-processor, no Nvidia -> no Cuda). I've recently implemented Deep-Q-Network reinforcement learning algorithm, and it's taking eternity to converge (seriously it's hard to wait that long without results, or at-least a little sign that I was heading in the right direction). What I'm hoping from the community is that little sign, weather I'm heading in the right direction :) , or my implementation is wrong ;-; . It would be cool if you could verify the source, and validate it. Even awesome if you could post results after training it. Link to git...
limit's of my hardware compute (quad-core i5-processor, no Nvidia -> no Cuda). I've recently

Full text and comments »

  • Vote: I like it
  • -15
  • Vote: I do not like it

243.
By vaibhavsaxena533, history, 17 months ago, In English
Why is my DFS + Memoization failing for LeetCode's Snakes and Ladders (Shortest Path)? Hi everyone, I'm trying to solve LeetCode's "Snakes and Ladders" using DFS with memoization (dp[square] for min moves) and a visited_in_path[square] check to prevent infinite loops if square is already in the current recursion stack. However, for some test cases, my DFS outputs a suboptimal path (e.g., 4 moves when 3 is expected). My Core Confusion: I understand visited_in_path stops simple stack overflow cycles like A → B → A. But I'm struggling to see exactly how this check causes my dp values for some squares to become permanently suboptimal, leading to a longer overall path found. Specifically, can the true shortest path for a subproblem (e.g., from square X) sometimes require taking a snake or ladder to an Ancestor square (where Ancestor is still active higher up in dfs(X)'s current call stack)? If so, my visited_in_path[Ancestor] check would prune this path segment for X. How does this pruning specifically lead to dp[X] (and subsequently dp[Start_Square]) being wr...
path (e.g., 4 moves when 3 is expected). My Core Confusion: I understand visited_in_path stops

Full text and comments »

  • Vote: I like it
  • -8
  • Vote: I do not like it

244.
By Haaland-Erling, history, 15 months ago, In English
Want to Gain Rating? Treat Codeforces like a Sport You want to gain rating, right? Well, you probably won't gain rating, because you never tried to gain rating in your life, "you expect all hard work to be done for you by someone else". Let's start! ### **Equipment Matters &mdash; But Only a Little** Your equipment such as your keyboard, monitor etc can help you perform better. A comfortable environment can reduce distractions, a fast keyboard can improve your typing speed, a bigger screen can help you read problems faster. But the thing is, fancy gear alone won't help you gain rating. Just like how footballers don't score more goals because of their football boots, sure, it makes a difference, but just because I bought Haaland's boots, does not make me Haaland. Appreciate the gear that you have, but terat it as helpful tools, not magic solutions. ### **Techniques Aren't Enough** There are various techniques used in competetive programming, learning to use different data structures and algorithms are essential to gaining rating...
Codeforces, its not just about knowing these core data structures and algorithms, it's about using them

Full text and comments »

  • Vote: I like it
  • -27
  • Vote: I do not like it

245.
By Knight_master, 5 months ago, In English
C2 Seating Arrangement (Hard) — O(n) Greedy with Floating Ambiverts [Codeforces Round 1101 Div. 2] Introduction ================ The editorial for this problem offers two approaches: a min/max table range tracker and a binary-search-over-ambiverts solution. This blog presents a third, independently derived O(n) greedy that feels more intuitive — at least to me. The central idea is tracking floating ambiverts: ambiverts who sat down in an already-occupied table but haven't been committed to a specific role yet, and can retroactively "become" introverts to rescue a future extrovert. Key observation =============== An extrovert needs a non-empty table. An introvert needs a completely empty table. An ambivert can do either. The tricky part is the order of decisions: we can't look ahead, so we must make lazy commitments. Core insight ============ When an ambivert sits at an already-occupied table (acting like an extrovert), we don't need to commit them yet. If a later extrovert arrives with no free seat, we can retroactively declare one of those ambiverts an introvert — openi...
Introduction ================ The editorial for this problem offers two approaches: a min/max

Full text and comments »

  • Vote: I like it
  • +2
  • Vote: I do not like it

246.
By abhinav700, history, 12 months ago, In English
Euler's totient formula intution for beginners Recently, I was going through [segment tree problems](https://codeforces.me/blog/entry/22616) list and encountered [this problem](https://codeforces.me/contest/594/problem/D) It introduced me to the `Euler's Totient Formula` and it took multiple attempts for me to understand the concept, because of the mathematical notations and terms used. So I thought of creating of this resource for me to understand the formula in a more intutive way, and hope it will help other beginners also. I have started from the core `prime number` concepts and have built up to the final formula. I hope this is helpful. --- ### Prime Numbers Integers > 1 with exactly two divisors. Used in: divisibility, coprimality, modular arithmetic. ### Coprime numbers Two numbers are coprime if:<br> **They do not share any prime factor.** Examples: gcd(8, 15) = 1 8 = 2³ 15 = 3 × 5 → No common prime → coprime * gcd(12, 18) = 6 12 = 2² × 3 18 = 2 × 3² → Both share prime 2 and 3 → not ...
and encountered [this problem](https://codeforces.me/contest/594/problem/D) It introduced me to

Full text and comments »

  • Vote: I like it
  • +13
  • Vote: I do not like it

247.
By joseph_goldberg, history, 5 years ago, In English
Please Help me in understanding why we use Random in the question I know 2-D segment tree and 2-D Fenwick tree and I have used them. I was trying to solve the problem [problem:869E] . In this question, I understood the whole core logic of 2-D Fenwick tree but I couldn't understand why we use random instead of that if I use count=0 like assigning count for one boundary then I increment the count and assign that count to another boundary and so on. I tried this approach and I got the wrong answer on Test Case 9 but it was too large that I couldn't see what the test case was. So, if you can tell me why we use random numbers it will be helpful.
problem [problem:869E] . In this question, I understood the whole core logic of 2-D Fenwick tree but I

Full text and comments »

  • Vote: I like it
  • +3
  • Vote: I do not like it

248.
By AnkushRaj977, history, 4 months ago, In English
Editorial PRO-TEST Thank you everyone for participating in the PRO-TEST! ### [A &mdash; Harmendra's Helpline](https://codeforces.me/gym/701868/problem/A) #### **Prerequisites:** Number Theory, Math & Algebra <spoiler summary="Hint 1"> Try to make $\text{lcm}(c, d) = 1$. </spoiler> <spoiler summary="Hint 2"> What happens when $b = 1$? </spoiler> <spoiler summary="Solution"> We can solve this problem in $O(1)$ time by using a fixed constructive approach that works for any $n \ge 4$. Since we can choose any positive integers, we minimize the right side of the equation by setting $c = 1$ and $d = 1$, which makes $\text{lcm}(1, 1) = 1$. This simplifies our target condition to finding two numbers where $\gcd(a, b) = 1$ and their remaining sum is $a + b = n - 2$. To easily guarantee a GCD of $1$, we can fix $b = 1$, which leaves us with $a = n - 3$. Ultimately, the fixed tuple $(n - 3, 1, 1, 1)$ will always satisfy both the sum and the GCD-LCM constraints for any valid input. </spoile...
](https://codeforces.me/gym/701868/problem/A) #### **Prerequisites:** Number Theory, Math & Algebra

Full text and comments »

  • Vote: I like it
  • +24
  • Vote: I do not like it

249.
By Casual_W, 10 months ago, In English
Tutorial for AlgoArena 2026 [Problem A1 : Pentagon Orchard(Easy version)](https://codeforces.me/gym/664936/problem/A1) <br> Author : [user:Casual_W,2026-01-18] <spoiler summary="Hint1"> First, calculate the total number of trees without worrying about visibility.<br> Layer 1 has 5 trees.<br> Layer 2 has 10 trees.<br> .......<br> Layer $k$ has $5k$ trees.<br> What is the sum of $5k$ for $k=1$ to $n$? </spoiler> <spoiler summary="Hint 2"> A tree is "visible" if no other tree blocks the line of sight from the center. Think of a tree's position as a fraction along one side of the pentagon. A tree at layer $k$ and position $m$ (where $0 \le m \le k$) corresponds to the fraction $m/k$. When is the fraction $m/k$ "blocked" by a previous layer? It is blocked if the fraction can be simplified (e.g., $2/4$ is blocked by $1/2$). </spoiler> <spoiler summary="Hint 3"> A tree is visible only if its position fraction $m/k$ cannot be simplified. This happens when $\gcd(m, k) = 1$. The number of integ...
[Problem A1 : Pentagon Orchard(Easy version)](https://codeforces.me/gym/664936/ problem/A1)

Full text and comments »

  • Vote: I like it
  • +19
  • Vote: I do not like it

250.
By singh_am, history, 11 months ago, In English
How to Determine If a Graph Is Bipartite Using DFS/BFS (Graph Coloring & Odd Cycle Detection) Graph theory is one of the most versatile tools in computer science. Many real-world systems from networks to data relationships naturally form graphs. Among the most fundamental graph structures is the **bipartite graph**. Understanding bipartite graphs helps in solving constraint-based problems, partitioning systems, matching tasks, and reasoning about conflicts in large networks. --- ## What Is a Bipartite Graph? ![ ](/predownloaded/26/15/2615fcb92c4e814059d9f08d2ed2f801a59b9278.png) A graph is **bipartite** if its vertices can be divided into **two disjoint sets** such that: * Every edge connects a vertex from one set to the other * No two vertices within the same set are directly connected ### Formal Definition A graph G = (V, E) is bipartite if the vertex set V can be partitioned into two disjoint sets U and W such that U ∩ W = ∅, and every edge in E connects a vertex in U to a vertex in W. --- ## The Core Property > **A graph is bipartite if and ...
connects a vertex in U to a vertex in W. --- ## The Core Property > **A graph is bipartite if and

Full text and comments »

  • Vote: I like it
  • -17
  • Vote: I do not like it

251.
By Satayev, 12 years ago, In English
runtime error with Java 8 I'm trying out the new Java 8 features, and decided to implement the easy problems with the new lambda functions. I have experienced RUNTIME ERROR twice though. Am I doing something completely wrong, or perhaps the system needs some tweaking to better support Java 8? http://codeforces.me/contest/25/submission/6666271 http://codeforces.me/contest/38/submission/6667775 ~~~~~ Both submissions fail with the same runtime error (different pid's obviously): A fatal error has been detected by the Java Runtime Environment: Internal Error (0xc06d007e), pid=5512, tid=4272 JRE version: Java(TM) SE Runtime Environment (8.0-b132) (build 1.8.0-b132) Java VM: Java HotSpot(TM) Server VM (25.0-b70 mixed mode windows-x86 ) Problematic frame: C [KERNELBASE.dll+0xc41f] Failed to write core dump. Minidumps are not enabled by default on client versions of Windows An error report file with more information is saved as: C:\Contesters\Work\invoker-... ~~~~~ The first submission...
core dump. Minidumps are not enabled by default on client versions of Windows An error report file

Full text and comments »

  • Vote: I like it
  • +8
  • Vote: I do not like it

252.
By BYN, 12 years ago, In English
Shortcut! Round is over Thank you all for participating in Bayan Programming Contest 2014-2015. We honestly didn't expect to host around 2500 contestants for the Shortcut! round. We had hosted 7 successful rounds with previous stable version of our platform, but due to major changes in it, we needed to test the new version, and that's why we planned to add the Shortcut! round as an opportunity ["mainly meant to help us actively test our new contest platform"](http://codeforces.me/blog/entry/13542). Round Issues ------------ Although we were prepared to face some issues, we seriously never expected to lose about 20 minutes of the contest. We were experiencing about 550 requests per second from more than **12,000 IPs**! With the start of the round, the burden was increased to **700 req/sec**. We first tried to mitigate the attacks, and then we tripled our computing power by adding CPU cores as fast as we could, after which the situation became more stable. As we've mentioned before, our official...
solving the 3rd problem (and thus owning the problemset) in the very last moments of the round, and

Full text and comments »

  • Vote: I like it
  • +53
  • Vote: I do not like it

253.
By feruz.atamuradov, history, 6 years ago, In Russian
Installation problem Hello everyone. I need your help. I am trying to installation Windows 10 my computer. I always selected one disk and format after I install this. After installation it didn't work well when I connect internet my pc work slowle. I have seen some videos on the youtube. But in those videos clears the all disks. I'm just trying to put it on one disc. Trying not to touch my other disks. because it contains the necessary information. How can I change? My pc: Intel(R) Core(TM)i3-3100M CPU @2.40GHZ, RAM: 2gb, 64prossesor Thanks advance!!! Sorry my english!
Installation problem, contains the necessary information. How can I change? My pc: Intel(R) Core (TM)i3-3100M CPU @2.40GHZ

Full text and comments »

254.
By isitcorrect, history, 14 months ago, In English
can anyone tell me why this is wrong approach. please!!!!! in problem https://codeforces.me/contest/1579/problem/D my previous solution has core implementation https://codeforces.me/contest/1579/submission/338348122 in this i was taking two biggest numbers a,b and saving them min(a,b)*times in answer vector but it gave wrong answer on 2nd test case this gets accepted https://codeforces.me/contest/1579/submission/338349269 but when i checked the other solution they were simulating one by one pairs i didn't get what difference will it create when taking all simultenously or taking one by one why take one by one here please help!!!
in problem https://codeforces.me/contest/1579/problem/D my previous solution hascore

Full text and comments »

  • Vote: I like it
  • -11
  • Vote: I do not like it

255.
By 3bdo_Khaled_X, history, 2 months ago, In English
Say Goodbye to TLE: Master Two Pointers What is the Two Pointers Technique: =================================== uses two index variables to traverse a linear data structure—like an array, string, or linked list—to solve problems efficiently without nested loops. Why Use it ? ------------- Time Efficiency: It often reduces time complexity from O(n²) (using nested loops) down to linear time O(n). Space Efficiency: It typically requires constant space O(1) because it only tracks a few indices. ##Whats Patterns of 2 Pointers ## **Pattern 1 (Variable_Size)** **1.1 Opposite Direction (Converging Pointers):**One pointer starts at the beginning (left = 0) and the other at the end (right = n &mdash; 1). They move toward each other until they meet. ​Best Used For: Sorted arrays, pair sum problems (ex: Two Sum on sorted input), or checking palindromes. Problem: Can you choose two indices i , j (i≠j) and ai+aj=K If you can choose to indices solving the equation print "YES" otherwise "NO" **Brute Force Approa...
sorted input), or checking palindromes. Problem: Can you choose two indices i , j (i≠j) and ai+aj=K

Full text and comments »

  • Vote: I like it
  • -15
  • Vote: I do not like it

256.
By OjjOj_, history, 2 years ago, In English
Check if integer is a power of 2 in O(1) Problem Description ================== Having an unsigned integer **x** (x > 0), return **True** if it is a power of 2, else return **False**. Example: 16 -> True (12 = 2 * 2 * 2 * 2) 12 -> False (12 = 2 * 2 * 3) Traditional Algorithm : O(logn) ------------------ ```python def is_power_of_two(x): while x > 1: if x % 2 != 0: return False x = x // 2 return True ``` Explanation: This code keeps dividing the number by 2 until it reaches 1 (for powers of 2) or finds an odd number (for non-powers of 2). Prerequisites ------------------ Before getting to O(1) algorithm let's spend some time playing with bitwise operations ### Bitwise AND Bitwise AND (&) is a binary operation that compares each bit of two numbers: - It returns 1 for each bit position where both input bits are 1. - It returns 0 for all other cases. Example (&): 1010 (10 in decimal) 1100 (12 in decimal) ---- 1000 (8 in decimal) ### Bit...
Problem Description ================== Having an unsigned integer **x** (x > 0), return **True

Full text and comments »

  • Vote: I like it
  • -26
  • Vote: I do not like it

257.
By amartya110, 10 months ago, In English
Editorial for CodeHurdle Athlos 01 We'd like to thank you all for participating in the contest, and hope you enjoyed it. Any feedback would be appreciated! * Special thanks to the tester [user:Ajay_2705,2026-01-19] in the last moment, correcting Problem C. [Contest Link](https://codeforces.me/contestInvitation/701bbd9bb27890c9f44ff4ceb70e38f74e0844d6) [](https://codeforces.me/contestInvitation/701bbd9bb27890c9f44ff4ceb70e38f74e0844d6) ### A — The Dual-Core Conflict Writer: [user:amartya110,2026-01-19] <spoiler summary="Editorial"> In this game to win, Alice has to choose one 2 and all 3 in his first chances only otherwises he loses. So, if he have number 2 less than two then he lose otherwise win. </spoiler> <spoiler summary="Solution"> ```c++ #include <bits/stdc++.h> using namespace std; int main(){ int t; cin>>t; while(t--){ int n; cin>>n; vector <int> a(n); int x=0; for(int i=0;i<n;i++){ cin>>a[i]; if...
moment, correcting Problem C. [Contest Link](https://codeforces.me/contestInvitation

Full text and comments »

  • Vote: I like it
  • +2
  • Vote: I do not like it

258.
By dsogari, 2 years ago, In English
Reusable modular integer for C++ (with static/dynamic moduli) <spoiler summary="A little bit about myself"> This is my first blog post on CF, and is probably a good starting topic for someone of my rating. Technically I'm not a CS, but an engineer who worked professionally as a software developer. CP was uncharted territory to me until recently, though now I find myself studying algorithms and working to improve my math skills so I can have fun solving difficult problems. :) </spoiler> So here's what I present: a structure for modular arithmetic operations which is short, reusable across static and dynamic moduli, supports 64-bit moduli and is as efficient as performing the operations manually. It requires the C++17 standard or newer. ### Motivation For the most part, there's obviously nothing novel about this idea: it was inspired by other blog posts ([63903](https://codeforces.me/blog/entry/63903), [23365](https://codeforces.me/blog/entry/23365)), as well as by various submissions to CF problems. On the other hand, I haven't come a...
* inv(rhs.x, M) % M, *this; } ~~~~~ Here's the core functionality of our structure: the assignment

Full text and comments »

  • Vote: I like it
  • +45
  • Vote: I do not like it

259.
By TheUserWW, history, 4 weeks ago, In English
Codeforces 1195 C. Basketball Exercise explanation # [Codeforces 1195 C. Basketball Exercise](https://codeforces.me/contest/1195/problem/C) This is a very typical dynamic programming problem. In this write-up, I will show three ways to solve it using dynamic programming. ## Problem Analysis First, we need to analyze the problem carefully. According to the statement, there are four restrictions we must respect when choosing students: 1. We choose players from left to right. 2. The index of each chosen player (except the first one) must be strictly greater than the index of the previous player. 3. Demid chooses students such that no two consecutive chosen students belong to the same row. 4. The total height of all chosen students must be as large as possible. Given these conditions, we can try to define the states for dynamic programming. When designing a DP state, we must ensure that it satisfies two important properties: 1. The state clearly reflects the restrictions above. 2. The state is independent of the f...
# [Codeforces 1195 C. Basketball Exercise](https://codeforces.me/contest/1195/ problem/C) This

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it

260.
By sufiyankhan27764, history, 13 months ago, In English
LLM(large language model) Large Multimodal Models (LMMs) – Detailed Overview 1. Introduction to LMMs Large Multimodal Models (LMMs) are an evolution of Large Language Models (LLMs). Unlike LLMs, which process only text, LMMs handle multiple modalities such as text, images, audio, video, and sometimes even structured data. Their core idea is to unify representation learning across modalities, allowing cross-modal reasoning and understanding. They are foundational models powering systems like GPT-4V (vision), Gemini, LLaVA, Kosmos, Flamingo, CLIP, and ImageBind. The ability to reason over multimodal data makes them crucial for AI applications in robotics, autonomous driving, healthcare imaging, multimodal search, and interactive AI systems. 2. Why Multimodality? Human intelligence is inherently multimodal. We process language, vision, sound, and spatial reasoning together seamlessly. LMMs aim to replicate this ability in artificial systems. A single modality (e.g., text-only) limits...
data. Their core idea is to unify representation learning across modalities, allowing cross-modal

Full text and comments »

Tags llm
  • Vote: I like it
  • -37
  • Vote: I do not like it

261.
By HussainAli404, history, 4 years ago, In English
Learning Roadmap for a Data Analyst **The very first question to hit our mind is who is a data analyst? What do they do?.** In simple words, a data analyst is responsible for collecting data, processing it, and analyzing it to find sensible insights for decision making. In most cases, an analyst will work on the raw data, grind it to produce action-oriented insights. Most of the analysts won’t work on the core machine learning or the deep learning models. A data analyst will make use of multiple tools to process the data and work with it. Having experience in working with different tools and statistics is most important for them. In the next blocks, we will be discussing each skill and related certifications as well. **1. Statistics** For every data professional, stats and math are the must-haves. Because, without the knowledge of stats and probability, one cannot able to interpret the data effectively. Some of the major topics include descriptive and inferential stats. If you are a pure beginner, you ...
it to produce action-oriented insights. Most of the analysts won’t work on the core machine

Full text and comments »

  • Vote: I like it
  • -4
  • Vote: I do not like it

262.
By jiraiya_777, history, 6 years ago, In English
Recursive calls causing seg fault This code snippet is giving: Segmentation fault (core dumped) on my laptop, but running just fine on Custom test on codeforces when I give input like 10^6 or so. I think the problem is related to space taken by recursive calls, but i don't understand it completely. Help!! ~~~~~ #include <bits/stdc++.h> using namespace std; int n; int solve(int i){ if(i==(n-1)){ return 1; } int sum1 = solve(i+1); return 1; } int main(){ int i; cin>>n; int ans =solve(1); cout<<ans; return 0; } ~~~~~
This code snippet is giving: Segmentation fault (core dumped) on my laptop, but running just fine

Full text and comments »

  • Vote: I like it
  • -14
  • Vote: I do not like it

263.
By Rapt0r_nj, 2 years ago, In English
Combinatorial Game Theory: Starters' Blog This blog intends to give you a kickstart with game theory and it'll cover all the core concepts of Combinatorial game theory with some insights. If you're new, game theory studies behavior of games, most commonly answering which player will win the game in an optimal gameplay. **Contents**: 1. Intro 1. Combinatorial games 1. Game States 1. The Game of Nim 1. Sprague Grundy theorem 1. Solving Games and Coding ### Combinatorial Games Combinatorial Game theory studies a special class of games, as the name suggests. A combinatorial game has the following properties: - **Two-Player**: The game is played between two players, each alternatingly taking turns. - **Perfect Information**: Both Players always have complete knowledge about the game state and all rules. - **No Randomness**: The game is completely determined by the player's moves only. - **Deterministic Outcome**: The game will end in finite moves, making one of the players win. (We will be ignoring Draw in th...
This blog intends to give you a kickstart with game theory and it'll cover all thecore concepts of

Full text and comments »

  • Vote: I like it
  • +2
  • Vote: I do not like it

264.
By cybersecessential, history, 15 months ago, In English
Getting Started with Learning Cybersecurity As a beginner in this field, I hope to use this blog to learn as much as I can, practice as much as possible and help anyone interested in learning cybersecurity. The first basics that I have to get out of the way on the first learning day is having a Personal Knowledge Management folder(PKM). Why is this important? A Personal Knowledge Management (PKM) system is a structured approach that will help me to capture, organize, retrieve, and utilize information I interact with throughout this learning process. It can help me gather and store information from various sources, such as articles, websites, peer discussions, feedback, lecture discussions, case studies and personal experiences, in a systematic manner. Lets focus on the core journey that we are going to use to master the essentials Cybersecurity is often seen as a mysterious field filled with hackers, advanced tools, and complex exploits. In reality, every expert starts with the same foundation: understanding how comp...
, in a systematic manner. Lets focus on the core journey that we are going to use to master the

Full text and comments »

  • Vote: I like it
  • -12
  • Vote: I do not like it

265.
By water, 13 years ago, In English
Java got TLE but C++ got AC,why? When I was sovling the[problem:356C],my java code got TEL but c++ code got AC,why? The core code of them is the same. JAVA:[submission:4857792] C++:[submission:4857784]
When I was sovling the[problem:356C],my java code got TEL but c++ code got AC,why? Thecore code of

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it

266.
By fatalerror, history, 15 months ago, In English
Python Optimization Tricks in Competitive Programming > For better reading experience in Chinese, please refer to: [LeetCode](https://leetcode.cn/discuss/post/3746464). # Preface This article introduces techniques to reduce runtime in competitive programming using Python, under the premise that the complexity remains **correct** and **unchanged**. Each technique is accompanied by a Speedup on CPython 3.11.5 / PyPy 3.10.13. # I/O ### Use fast input Replace the built-in `input` with `sys.stdin.readline`. Each `input()` call incurs prompt handling and a `sys.stdin` lookup, while `readline()` reads a line directly. The more input lines, the larger the gap. Speedup: CPython ~×4.2; PyPy ~×16.4. ~~~~~ import sys input = lambda: sys.stdin.readline().rstrip() # strip the trailing newline II = lambda: int(input()) LII = lambda: list(map(int, input().split())) ~~~~~ ### Read all input at once Use `sys.stdin.read().split()` to read everything into memory once, then consume as needed. This avoids calling the read fun...
core reason is that **the dominant costs at the Python-bytecode level are branches, function calls

Full text and comments »

  • Vote: I like it
  • +94
  • Vote: I do not like it

267.
By taap_cader, history, 6 years ago, In English
Best strategy for placement season Hello Codeforces!<br> I am ready for lot of downvotes but I want a serious advice.<br> I am pre-final year student in Tier 1/Tier 2 college(new IIT, consider it in whichever tier you want). I have done internship in a small start-up. Now I have two options, can do one more internship in relatively good company(obviously not in Amazon/Microsoft) or can do lot of coding, enhance my coding skills and core subject knowledge.<br> Which option will be more beneficial for my placements, a good internship or coding skills.<br> <br> For those who will downvote, I have no problem with you but please give me advise before doing that.<br> I am sure lot of students may have same question.<br>
and core subject knowledge. Which option will be more beneficial for my placements, a good

Full text and comments »

  • Vote: I like it
  • -25
  • Vote: I do not like it

268.
By nuredinbederu10k, history, 15 months ago, In English
A2SV Contest #24 Editorial [Here](https://codeforces.me/contestInvitation/3f06f4e1ac120eedc5edd3945965af03bdf0976a) is the link to the contest. All problems are from Codeforces' problem set [A. Life of a Flower](https://codeforces.me/gym/626626/problem/A) <spoiler summary="Solution"> We are given an array of length $n$ that represents whether Petya watered his flower each day. Each element $a_i$ is either: - $1$ → the flower **was watered** - $0$ → the flower **was not watered** The flower begins at a height of **$1$ cm** on **day 0** (before processing any input days). --- ## Simulation Logic We iterate through the array starting from index $1$ (the **second day**), and at each step, we examine the **current** element $a_i$ and the **previous** element $a_{i-1}$. There are **four possible scenarios**: --- - **Case 1:** $a_i = 1$ and $a_{i-1} = 1$ → The flower was watered **both yesterday and today** → It grows by **$5$ cm** → `height += 5` --- - **Case...
link to the contest. All problems are from Codeforces' problem set [A. Life of a Flower](https

Full text and comments »

  • Vote: I like it
  • -1
  • Vote: I do not like it

269.
By algoslayer, 13 months ago, In English
Meta Hacker Cup 2025 — Round 1 Editorial Hey everyone I recently participated in **Meta Hacker Cup 2025 Round 1** and I’m thrilled to share that I secured **Rank 333 / 13,676** with a **perfect score of 105/105**, successfully solving every problem from **A1 → D**! I've qualified for Round 2 of the Meta Hacker Cup 2025! Round 1 was a fantastic set of problems, and I managed to solve all of them for a full score. This post includes **my hints, solution approaches, and final codes** for all problems — written to help learners strengthen their **DSA and problem-solving** intuition. [A1: Snakes Scales (Chapter 1) :](https://www.facebook.com/codingcompetitions/hacker-cup/2025/round-1/problems/A1) <spoiler summary="Hint"> Snake must walk from platform 1 to N. To get from platform $i$ to $i+1$, he needs a ladder of height $|A_i - A_{i+1}|$. Since he brings only one ladder, it must be tall enough for the hardest (i.e., highest) adjacent jump in the entire path. </spoiler> <spoiler summary="Solution"> The s...
every problem from **A1 → D**! I've qualified for Round 2 of the Meta Hacker Cup 2025! Round 1

Full text and comments »

  • Vote: I like it
  • -46
  • Vote: I do not like it