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 maspy, history, 2 months ago, In English
0 Problems Remaining [日本語記事(For Japanese Speakers)](https://maspypy.com/codeforces-all-ac) ---- Previous post: https://codeforces.me/blog/entry/150057 Submission: [submission:384239819] 2026/07/26 03:13:42 JST (2026/07/25 18:13:42 UTC) I have solved every problem in the Codeforces PROBLEMSET except for those for which I determined that obtaining an accepted verdict is impossible. ![unsolved problem list](https://maspypy.com/wp-content/uploads/2026/07/problemset.png) # Scope I considered the problems listed in the [PROBLEMSET](https://codeforces.me/problemset). I have solved very few problems from the [GYM](https://codeforces.me/gyms). The only collection I worked through systematically was the PROBLEMSET. I determined that it is theoretically impossible to obtain an accepted verdict for the following 31 problems: [problem:775A], ([92101](https://codeforces.me/problemset/problem/921/01) ... [92114](https://codeforces.me/problemset/problem/921/14)), [problem:927A], [prob...
implementations written in C++ or another language into the required language. Doing this during a, increase. I believe that most users who have continued competitive programming understand the enjoyment

Full text and comments »

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

2.
By MikeMirzayanov, 9 years ago, translation, In English
New: Diagnostics of Solutions in C++ <img src = "/predownloaded/b5/d2/b5d246ffc32dfe82c3cbac77d1898c5fcb62fa57.jpg" style = "float: right; margin: 0 1em 1em 1em;"/> Hello! I am pleased to report that two rounds of Codeforces have gone quite well in terms of the work of Codeforces, I am very glad about it. These <s>days</s> nights I spent in a profiler, fixing the code, researching the settings of MariaDB. In addition, I managed to allocate several hours on Sunday (to be honest, until Monday morning) to finish the long-planned innovation. Meet, diagnostics of solutions in C++! Many Codeforces visitors are already tired of the questions of less experienced participants: "Why does my solution not work on some test on the Codeforces servers, if I locally launch it and it works correctly? You have the wrong compiler/servers!" In 99% of cases this is an example of <a href ="https://en.wikipedia.org/wiki/Undefined_behavior">undefined behavior</a> in a program. In other words, the program contains mistakes that, du...
New: Diagnostics of Solutions in C++, "Custom invocation" tab. I recall that the program runs many times slower and consumes more memory, ="https://en.wikipedia.org/wiki/Undefined_behavior">undefined behavior in a program. In other words, incorrect answer on the test and to an runtime error of the program., report in English, but often it will indicate to you the error of the program. Often it contains the, -planned innovation. Meet, diagnostics of solutions in C++! Many Codeforces visitors are already, In g++/clang++ there is a remarkable tools called sanitizers. It's such a way to compile aprogram

Full text and comments »

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

3.
By zscoder, history, 6 years ago, In English
[Tutorial] Generating Functions in Competitive Programming (Part 1) Hi everyone! Inspired by the recent [Codeforces Round 641](https://codeforces.me/contest/1349), I decided to write an introductory tutorial on generating functions here. I am by no means an expert in generating functions so I will write about what I currently know about them. [user:MiFaFaOvO,2020-05-15] has written a really interesting [blog](https://codeforces.me/blog/entry/76447) here on Codeforces about more advanced applications of generating functions, but I think there is no English tutorial on the basics of this topic yet (or at least on CP sites). Thus, I would like to share about this topic here. I plan to split this tutorial into two parts. The first part (this post) will be an introduction to generating functions for those who have never learned about them at all, and some standard examples and showcases of generating functions. The second part will be a collection of several applications of generating functions in CP-style problems. If you are already familiar with ge...
[Tutorial] Generating Functions in Competitive Programming (Part 1), calculus, you will recognize that if we integrate both sides, we get $\ln B(x) = e^{x} +c$. Since $b_{0}=1, graphs on $n$ vertices (call the count $c_{n}$ and EGF $C(x)$). However this is easy, since each, #### Addition For both OGF and EGF, $C(x)=A(x)+B(x)$ generates the sequence $c_{n}=a_{n}+b_{n}$., #### Shifting For OGF, $C(x) = x^{k}A(x)$ generates the sequence $c_{n}=a_{n-k}$ where $a_{i}=0, $ and $G(x)$ as the EGF of $g$. Using the same function $C$ in the previous problems, we need to find, $C(x,y) = \displaystyle\sum_{n \ge 0}\frac{y^{n}}{n!}\displaystyle\sum_{a_{1}+2a_{2}+...=n,a_{i, $C(x,y) = \left(\displaystyle\sum_{a_{1} \ge 0}\frac{(yx_{1})^{a_{1}}}{a_{1}!1^{a_{1}}}\right)\left, **Example.** The binomial coefficients $c(n,k)$ is defined by the recurrences $f(n,0)=1$ for $n \ge, , we have $D(x) = \exp(C(x))$ using the exponential argument. Thus, $D(x) = \exp(C(x)) = \exp\left, . 2 C. However, why stop here? Suppose the problem asks you to find $b_{n}$ for $n \le 3 \cdot 10^{5, For EGF, $C(x) = A^{(k)}(x)$ generates the sequence $c_{n} = a_{n+k}$, where $A^{(k)}(x)$ denotes, For EGF, $C(x)=A(x)B(x)$ generates the sequence $c_{n} = \displaystyle\sum_{k=0}^{n}\binom{n}{k}a_, For EGF, $C(x)=A(x)^{k}$ generates the sequence $c_{n} = \displaystyle\sum_{i_{1}+i_{2}+...+i_{k}=n, For OGF, $C(x) = \frac{A(x) - (a_{0} + a_{1}x + a_{2}x^2 + ... + a_{k-1}x^{k-1})}{x^{k}}$ generates, For OGF, $C(x)=A(x)B(x)$ generates the sequence $c_{n} = \displaystyle\sum_{k=0}^{n}a_{k}b_{n-k}$., For OGF, $C(x)=A(x)^{k}$ generates the sequence $c_{n} = \displaystyle\sum_{i_{1}+i_{2}+...+i_{k}=n, For both OGF and EGF, $C(x) = xC'(x)$ generates the sequence $c_{n}=na_{n}$., From our discussion above, we know how to find $c(a)$, thus we can write $C (x,y)$ as, Hence, $C(x) = \frac{1-\sqrt{1-4x}}{2x} = \frac{1}{2x}\left[1 - 1 - \displaystyle\sum_{n \ge 1, Hence, we have $C(x)-1=xC(x)^{2}$, which is a quadratic equation in $C(x)$! Using the quadratic, How do we interpret the RHS? We claim that it is $xC(x)^{2}$. Consider the expansion of $C(x)^2, However, $C(x) = \displaystyle\sum_{k \ge 1}\frac{(k-1)!}{k!}x^{k} = \displaystyle\sum_{k \ge 1, Let $c(a)$ denote the number of permutations of length $n = a_{1}+2a_{2}+...$ with cycle type $a, Let $c_{n} = (n-1)!$ be the number of permutations of length $n$ which is a cycle. Let $C(x, Our first step is to look for a recurrence relation. Suppose you have this as a Div. 2C problem, The LHS is easy to intepret: it is just $C(x) - 1$., This time, we need to find $[x^{n}]\displaystyle\sum_{k \ge 0}\frac{1}{k!}C (x)^{k} = [x^{n}]\exp(C, We have shown before that the OGF of the Catalan numbers is $C(x) = \frac{1 - \sqrt{1-4x}}{2x, {k}=n}\frac{c_{a_{1}}c_{a_{2}}...c_{a_{k}}}{a_{1}!a_{2}!...a_{k}!}$ is $[x^{n}]C (x)^{k}$, so $F(x, }+a_{1}+...+a_{n}$. Then, we can take $C(x) = \frac{1}{1-x}A(x)$.

Full text and comments »

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

4.
By MikeMirzayanov, 5 years ago, In English
C++20 Is Released Hello, Codeforces. Please, welcome c++20 support on Codeforces. Yes, it is 64-bit. Thanks to Brecht Sanders: I used his distribution GCC-11.2.0-64 from https://winlibs.com/. If you have installed [PBOX](http://pbox.me/packages), you can add this compiler with the line `pbox install gcc11-64-winlibs`. Probably, a good idea is to add `C:\Programs\gcc11-64-winlibs\bin` into the PATH. More about PBOX you can read [here](https://codeforces.me/blog/entry/18274). I use the compilation command line similar to other GCC installations: `g++ -Wall -Wextra -Wconversion -static -DONLINE_JUDGE -Wl,--stack=268435456 -O2 -std=c++20 <source>`. The only differences are `-std=c++20` and `-Wall -Wextra -Wconversion` (I plan to use somehow such warnings in Polygon to suggest fixes in uploaded files). Now you can use c++20 in your solutions. I'm not sure there are many features useful in competitive programming. Probably, I'm wrong. For example, now you can write `vector v{vector{1, 2}};` inste...
C++20 Is Released, `pbox install gcc11-64-winlibs`. Probably, a good idea is to add `C :\Programs\gcc11-64-winlibs\bin` into, Hello, Codeforces. Please, welcome c++20 support on Codeforces. Yes, it is 64-bit. Thanks to, Now you can use c++20 in your solutions. I'm not sure there are many features useful in competitive

Full text and comments »

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

5.
By parveen1981, history, 5 years ago, In English
I compiled a list of almost all useful blogs ever published on Codeforces [update: till 09.06.2021] <h3 style="color:red">If there are any blogs that I have missed, please tell in the comment section. Thank you.</h3> # Mathematics Stuff - [Number Theory in Competitive Programming [Tutorial]](https://codeforces.me/blog/entry/46620) - [Number of points on Convex hull with lattice points](https://codeforces.me/blog/entry/62183) - [FFT, big modulos, precision errors.](https://codeforces.me/blog/entry/48465) - [Number of ways between two vertices](https://codeforces.me/blog/entry/19078) - [Mathematics For Competitive Programming](https://codeforces.me/blog/entry/76938) - [FFT and NTT](https://codeforces.me/blog/entry/19862) - [Burnside Lemma](https://codeforces.me/blog/entry/51272) - [Number of positive integral solutions of equation 1/x+1/y=1/n!](https://codeforces.me/blog/entry/76836) - [On burnside (again)](https://codeforces.me/blog/entry/64860) - [Simple but often unknown theorems/lemmas/formula? Do you know?](https://codeforces.me/blog/entry/55912) - [Probabili...
. Thank you. # Mathematics Stuff - [Number Theory in Competitive Programming [Tutorial, ] — tools for competitive programming](https://codeforces.me/blog/entry/60627) - [(almost) Every

Full text and comments »

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

6.
By tourist, 9 years ago, In English
My strategy at AtCoder & CS Academy There's been much controversy lately about the late submission strategy not penalized by scoring systems of AtCoder and CS Academy. Most of the relevant discussion happened earlier at http://codeforces.me/blog/entry/53431 and http://codeforces.me/blog/entry/53449. I have a lot of thoughts on the topic, so I've decided to share them in a separate blog post. I really like the strategic part of programming competitions. Of course, problem solving is more important. But every contest consists of multiple problems, so there has to be a way of comparing participants which performed better at different problems. There's a huge variety of scoring rules, and I find it truly amusing. The "submit after solving all problems" strategy looks widely attributed to me now, mostly due to [user:Petr,2017-07-24]'s remarks regarding my participation in AtCoder contests. In my opinion, it's wrong for multiple reasons. A closer five-word description of my strategy is "implement after solvin...
part of programming competitions. Of course, problem solving is more important. But every contest, I really like the strategic part of programming competitions. Of course, problem solving is more

Full text and comments »

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

7.
By TLE, history, 8 years ago, In English
Linear Recurrence and Berlekamp-Massey Algorithm **#IjustWantContribution** It seems there isn't any blog about Berlekamp-Massey Algorithm around here, so I decided to go on a try. :P Acknowledgement: Hats off to matthew99 for introducing this algorithm. #### What is 'linear recurrence'? Assuming there is a (probably infinity) sequence $a_0,a_1...a_{n-1}$, we call this sequence satisfies a linear recurrence relation $p_1,p_2...p_m$, iff $\forall i \geq m,~a_i=\sum_{j=1}^m a_{i-j}p_j$. (Obviously, if $m\geq n$ any $p$ can do :P) #### How to calculate k-th term of a linear recurrence? For a polynomial $f(x)=\sum_{i=0}^{t} c_ix^i$, we define $G(f)=\sum_{i=0}^{t} c_ia_i$. Obviously $G$ satisfies $G(f)\pm G(g) =G(f \pm g)$. Because $a_i=\sum_{j=1}^m a_{i-j}p_j$, if we let $f(x)=x^m-\sum_{j=1}^m x^{m-j}p_j$, then $G(f)=0$. Also $G(fx),G(fx^2)...=0$. So $G(fg)=0$ (g is any polynomial). What we want is $G(x^k)$. Because $G(f\lfloor x^k/f\rfloor)=0$, then $G(x^k)=G(x^k \bmod f)$. [cut] We can calculate $x^k \b...
division, the modulus needs to be a prime. ```C++ #include

Full text and comments »

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

8.
By HosseinYousefi, 12 years ago, In English
C++ Tricks I see lots of programmers write code like this one: ~~~~~ pair<int, int> p; vector<int> v; // ... p = make_pair(3, 4); v.push_back(4); v.push_back(5); ~~~~~ while you can just do this: ~~~~~ pair<int, int> p; vector<int> v; // ... p = {3, 4}; v = {4, 5}; ~~~~~ [cut] [This](http://codeforces.me/blog/entry/10124) is a great C++11 tutorial for those who want to know more about C++11. #### 1. Assign value by a pair of {} to a container I see lots of programmers write code like this one: ~~~~~ pair<int, int> p; // ... p = make_pair(3, 4); ~~~~~ while you can just do this: ~~~~~ pair<int, int> p; // ... p = {3, 4}; ~~~~~ even a more complex `pair` ~~~~~ pair<int, pair<char, long long> > p; // ... p = {3, {'a', 8ll}}; ~~~~~ What about `vector`, `deque`, `set` and other containers? ~~~~~ vector<int> v; v = {1, 2, 5, 2}; for (auto i: v) cout << i << ' '; cout << '\n'; // prints "1 2 5 2" deque<vector<pair<in...
C++ Tricks, Regular expressions are useful tools in programming, we can define a regular expression by `regex, ] [This](http://codeforces.me/blog/entry/10124) is a great C++11 tutorial for those who want to know

Full text and comments »

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

9.
By rng_58, history, 6 years ago, In English
AtCoder Library Recently, the number of algorithms and data structures we use in competitive programming are rapidly growing. It's a nice thing: by using more algorithms, the variety of possible problems gets wider, and we can enjoy more problems. On the other hand, before reaching adhoc, thinking-oriented part of this competition, we have to spend more and more time to learn algorithms. Sometimes a problem asks matching on general graphs; you have to find a paper describing it, read it, and implement its really complicated algorithm. Or sometimes you have to spend time tuning your library by a constant factor. Or sometimes you use multiple pre-written codes together, the variable names collide, and get annoyed. Until now, I basically rejected all problems that require pre-written codes of complicated algorithms because I don't like these things. For example, we never used segment trees with lazy propagation in our contests. However this way we can't use otherwise interesting problems and it ...
Recently, the number of algorithms and data structures we use in competitive programming are

Full text and comments »

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

10.
By Golovanov399, 7 years ago, In English
C++ tips and tricks Hello, codeforces. I would like to tell you about some tricks and constructions I use in C++. They are not hidden or anything, moreover, most of them are from stl or maybe well known among software engineers, but I often see codes where something is done by hand in, say, 5 lines, while in stl there is a function which does the same. The things below are filtered by my personal sense of non-popularity (so no `__builtin` functions) and usage frequency (so there almost surely are similar things I don't know about) and are not really sorted in any reasonable order. Let's begin. [cut] <hr> - ### `all(x)` This may be an exception to the rule of non-popularity -- this is quite widely used, but some next items will depend on `all(x)`, so I define it here. So, I talk about ```[c++] #define all(x) (x).begin(), (x).end() ``` Now sorting a vector looks like `sort(all(vec))` instead of `sort(vec.begin(), vec.end())`. However, it's not all about this define. Imagine you nee...
C++ tips and tricks, something useful here. C++, as every other language (programming or natural), is evolving, after all, , I hope a lot of you will find something useful here. C++, as every other language (programming or, , end)`. I didn't use this in competitive programming (yet), but once wanted to use it for my job

Full text and comments »

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

11.
By Radewoosh, history, 8 years ago, In English
Blogewoosh #1 Hello, codeforces! The community wants so the community gets it! :D Here it is, my very first blog about tasks and algorithms. At the beginning I've decided to post my entries on codeforces, maybe I'll switch to something different if it becomes uncomfortable. To pour the first blood I decided to choose a task from one of the old ONTAK camps. Task's name is "different words" ([you can submit here](https://szkopul.edu.pl/problemset/problem/wTy-sxQCIKry0Ml-6RvM0L78/site/?key=statement)). The statement goes as follows: You are given $n$ words ($2 \leq n \leq 50\,000$), every of length exactly $5$ characters. Each character can be a lowercase letter, an uppercase letter, a digit, a comma... basically, it can be any character with ASCII code between $48$ and $122$ (let's say that $k$ is the number of possible characters). A task is to find all pairs of indexes of words which are $\textbf{really different}$. Two words are $\textbf{really different}$ if they differ at all $5$ corres...
$100\,000$ pairs, then the program should print that there are only $100\,000$ and print this number

Full text and comments »

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

12.
By MikeMirzayanov, 7 years ago, translation, In English
Codeforces: Results of 2019 <a style="float:right; display: inline-block; margin:0 1em 1em 2em; max-width: 60%;" href="https://codeforces.me/10years"/> <img style="max-width:100%" src="https://assets.codeforces.com/images/codeforces-10-years-300.png"/> </a> Hi Codeforces! The platform recently turned 10 years old. We accept your congratulations at <a href="https://codeforces.me/10years">https://codeforces.me/10years</a>. Please review the progress in 2019 and support the anniversary crowdfunding campaign. Your donation will be a contribution to the future of Codeforces, will help its development and work. We need resources to continue to host rounds, not to stop developing, to innovate and to maintain the existing infrastructure. In 2019, together with numerous writers the coordinators worked on problems: [user:KAN,2020-02-06], [user:300iq,2020-02-06], [user:cdkrot,2020-02-06], [user:arsijo,2020-02-06] and recently joined [user:isaf27,2020-02-06]. And this year, rounds coordinated by other exper...
network widgets 1. Special notes for programming languages (e.g. recommend PyPy) 1. Improved, pleased to hold programming competitions with companies or for companies. I'm sure this is a great way

Full text and comments »

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

13.
By Zhtluo, history, 3 years ago, In English
The Reason You are Bad at Codeforces — You are Not Russian Enough If you are triggered by this clickbaity blog title, you are probably interested in improving your Codeforces skills. Now, I will share my point of view on the differences between Codeforces and ICPC contests, and how you can, in my humble opinion, maximize your Codeforces rating gain. I mostly consider that all conceivable competitive programming problems need three aspects of skill: 1. Observation &mdash; the ability to understand the problem and come up with non-trivial properties. 2. Technique &mdash; the ability to apply a well-known algorithm or data structure to the problem. 3. Implementation &mdash; the ability to code fast and debug fast. Collaterally, I refer to these three skills as Russian-ness, Chinese-ness and American-ness, respectively, for reasons you will soon see below. ## Observation (Russian-ness) Observation means that you stare at some problem for a sufficient amount of time and you are able to reduce it to some easier problem. One good proble...
*Claim 2: Div. 2 A, B, and C require nothing but basic programming skills and good math skills.*, , and C require nothing but basic programming skills and good math skills.* This is more debatable

Full text and comments »

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

14.
By maomao90, 3 years ago, In English
Editorial for Hello 2024 ### [problem:1919a] Author: [user:maomao90,2024-01-02] <spoiler summary="Hint 1"> When does the game end? </spoiler> <spoiler summary="Solution"> Depending on whether the player chooses to exchange wallets with their opponent on step $1$, $1$ coins will be removed from either the opponent's wallet or the player's wallet. This means that if either of the players still has remaining coins, the game will not end as at least one of the choices will still be valid. The only way that the game ends is when both players have $0$ coins. Since each operation decreases the total amount of coins by exactly $1$, the only way for Alice to win the game is if $a + b$ is odd. </spoiler> <spoiler summary="Code"> ~~~~~ #include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int a, b; cin >> a >> b; if ((a + b) % 2 == 0) { cout << "Bob\n"; } else { cout << "Alice\n"; } } ...
programming. $s_{i, j} = \mathtt{1}$ if and only if at least one child $c$ of vertex $j$ (when the

Full text and comments »

Tutorial of Hello 2024
  • Vote: I like it
  • +760
  • Vote: I do not like it

15.
By YouKn0wWho, 4 years ago, In English
[Tutorial] Common Mistakes in Competitive Programming and How to Avoid Them One thing is for sure. You do make mistakes. I also make miskates and that's what makes us human. But what we can surely do is &mdash; to try to minimize the errors that we make throughout our life. I have compiled some of the mistakes that I made in my early Competitive Programming phase. I also mentioned how to avoid them. Also, in most cases, I will give you a chance to find out what the bug is before I reveal the culprit as I tried to make this blog interactive. The codes that I have used in this blog have been written in C++ as it is the most used language for CP. **So, if you are new to CP, stick with me as you might don't wanna repeat the mistakes that I made when I was a beginner.** #### Mistake 1 Check out the following code: <spoiler summary="Code"> ~~~~~ #include<bits/stdc++.h> using namespace std; int main() { int a = 1000'000'000,b = 1000'000'000; long long product = a * b; cout << product << '\n'; return 0; } ~~~~~ </spoiler> The outp...
[Tutorial] Common Mistakes in Competitive Programming and How to Avoid Them, [Don't use rand(): a guide to random number generators in C ++](https://codeforces.me/blog/entry/61587, about C++ operator precedence., . I have compiled some of the mistakes that I made in my early Competitive Programming phase. I, I have compiled some of the mistakes that I made in my early Competitive Programming phase. I also, So do not mix C-style and C++-style printers after using `ios_base::sync_with_stdio(0)`., const int mod = 1e9 + 7; int main() { // 0 <= a, b, c < mod int a = 1e9, b = 1e9,c = 1e9;, const int mod = 1e9 + 7; int main() { int a = 1e9, b = 1e9, c = 1e9; int sum = (a + b +c, int random = 1LL * a * (b * c % mod) % mod; // overflow in the (b * c % mod) part // correct, int sum = (a + b + c) % mod; // overflow as (a + b + c) > INT_MAX(=2147483647) // better way

Full text and comments »

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

16.
By AksLolCoding, history, 12 months ago, In English
Essential Tips for AI in Competitive Programming With the rise of AI in competitive programming, this blog aims to assist AI with essential tips to make it's submissions valid and acceptable on programming sites such as Codeforces. Following these is also essential for AI to blend in with human participants. This blog does NOT attempt to sabotage AI in any way. Feel free post more essential AI programming tips in the comments. 1. Use long variable names. Because AI can code extremely fast, these long variable names save time in the long term since they make code easier to adjust and debug. 2. Comment code thoroughly with long detailed and grammatically correct sentences. This makes code cleaner to read and more humanoid. Even if it doesn't seem necessary, such as after `i++`, it is still important to comment this code. 3. Always check if input variables such as `n` are positive. Many problems will have edge case tests where input variables are negative, even if the constraints say they are greater than or equal to $0$. This is n...
Essential Tips for AI in Competitive Programming, chance of success. If C++ won't work, try Python, then maybe Java!, With the rise of AI in competitive programming, this blog aims to assist AI with essential tips to

Full text and comments »

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

17.
By andreyv, 12 years ago, translation, In English
Catching silly mistakes with GCC As you know, the C++ language assumes that the programmer is always correct. Therefore C++ compilers don't add additional checks to the program, such as checks for null pointer dereference or out-of-bounds array access. This is good, because C++ programs run as fast as possible, and this is bad, because sometimes we may spend a long time debugging some silly mistake. We would want that the compiler can find such mistakes automatically. And many compilers can! In this post I will show various GCC options that do this. Previously [user:zakharvoit,2015-01-02] already wrote about this [here](/blog/entry/13875). All options that will follow should be added to the GCC command line. In various IDEs you can do it in IDE or compiler settings. Many of the options can also be used with Clang (for example, in Xcode). For MSVC++, I think, there is nothing better than Debug mode and `/W4`. [cut]   GCC warnings ------------------ Of course, the first step to debugging is to enable compi...
As you know, the C++ language assumes that the programmer is always correct. ThereforeC, Как известно, C++ принимает, что программист всегда прав, и поэтому компиляторы C++ не вставляют в

Full text and comments »

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

18.
By MikeMirzayanov, 6 years ago, In English
Codeforces: Results of 2020 [list some changes and improvements] Hello, Codeforces! I understand that 2021 has been going on for a long time, but here I have picked up a subset of some of the improvements that the Codeforces team made in 2020. Soon I will publish numbers (no, charts) with statistics for 2020. In the meantime, I bring to your attention a list of changes and improvements. By the way, this is a decent list. This is about half to a quarter of all changes. It's just that other changes are more often somewhere in the internals of the system and are not visible to users. Please read this list. Each item is the effort of someone from the team. Thanks to [user:geranazavr555,2021-03-14], [user:kuviman,2021-03-14] and [user:cannor147,2021-03-14] for their efforts. You've made our platform better! Well, by the way, I don't quit programming and many improvements were made by me. The items on the list are written in a concise and informal form, many of the items I just copied from commit messages from git. If you want more details &mdash...
-14] for their efforts. You've made our platform better! Well, by the way, I don't quitprogramming

Full text and comments »

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

19.
By zscoder, history, 6 years ago, In English
[Tutorial] Generating Functions in Competitive Programming (Part 2) Welcome to Part 2 of my tutorial on generating functions. The [first part](https://codeforces.me/blog/entry/77468) focused on introducing generating functions to those without any background in generating functions. In this post, I will demonstrate a few applications of generating functions in CP problems. Let us start with some relatively straightforward examples. Note: Unless stated otherwise, all computations are done modulo a convenient prime (usually $998244353$). Also, $[n]$ denotes the set $\\{1,2,...,n\\}$. ### Blatant Applications in Counting Problems **Problem.** [AGC 005 Problem F](https://atcoder.jp/contests/agc005/tasks/agc005_f) You have a tree $T$ with $n$ vertices. For a subset $S$ of vertices, let $f(S)$ denote the minimum number of vertices in a subtree of $T$ which contains all vertices in $S$. For all $1 \le k \le n$, find the sum of $f(S)$ over all subsets $S$ with $|S| = k$. Constraints: $n \le 2 \cdot 10^{5}$. <spoiler summary="Solution"> First, ...
[Tutorial] Generating Functions in Competitive Programming (Part 2), $c(k)$). This is just $C_{o}'(1)$. By Quotient Rule, this is equivalent to finding $\frac{A_{o}'(1, a set of positive integers $C = \\{c_1, c_2, ..., c_{n}\\}$. A vertex-weighted rooted binary tree is, above (I will skip this step) to obtain $G(x) = \exp(C(x))$, which gives $C(x) = \ln(G(x))$. Since we, always write $E(i)$ in terms of $c_{0}E(0) + c_{1}E(1) + c_{2}E(2) + ... + c_{n-1}E(n-1) +C$ for some, implementation detail here. $C(x)$ has constant term $0$, and thus we cannot take the reciprocal directly, let's show a method using EGFs as it will be useful later. Let $C(x)$ be the EGF of the number of, over all possible weights of the left subtree, giving the recurrence $f_{s} = \displaystyle\sum_{c \in, significantly easier task. For the second term, we can partition it into $\frac{Mx}{1-x-x^2}$ and $\frac{C, !} \displaystyle\sum_{a_{1}+a_{2}+...+a_{k}=n-s} \displaystyle\prod_{j=1}^{k}\frac{c(a_{j}) \cdot a_{j}}{a_, $\displaystyle\sum_{n \ge 1}f_{n}x^{n} = \displaystyle\sum_{n \ge 1}\displaystyle\sum_{c \in C}x^{c, $\frac{1}{n}[x^{n-1}]\left(\frac{C(x)}{1-(x+1)y}\right)'D(x) = \frac{1}{n}[x^{n-1}]\frac{C'(x)D(x, $\left(\frac{C(x)}{1-(x+1)y}\right)' = \frac{C'(x)[1-(x+1)y] - C(x)(-y)}{(1 - (x+1)y)^2} = \frac{C, $c(n) = \displaystyle\sum_{s=1}^{n} b(s) \cdot \binom{n-1}{s-1} \cdot (n-s)! \cdot \displaystyle, ), .., E(n-1)$ and a constant $C$ for any $m$ in an efficient manner., **Problem.** [Sum Modulo](https://codeforces.me/gym/102586/problem/C) You have a number $x$ which, /problem/438/E) You have a set of positive integers $C = \\{c_1, c_2, ..., c_{n}\\}$. A vertex-weighted, Note that we have $nc(n)$ and $a_{j} \cdot c(a_{j})$ appearing in the summand. It seems like it is, Now, our problem reduces to finding $\frac{1}{n}[x^{n-1}]\left(\frac{C (x)}{1-(x+1)y}\right)'D(x, Ok, so we can find $a(k)$. Let $c(k)$ denote the probability that the game ends (all switches are, Since $B(x)$ is linear, if we let $B(x) = mx+c$ we can solve for the coefficients of $B$ using, The idea is to relate $b(n)$ with $c(n)$. Suppose we have a labelled connected graph on $n, This motivates us to define $F(x) = \displaystyle\sum_{n \ge 0}f_{n}x^{n}$ and $ C(x, To relate $c(k)$ with $a(k), b(k)$, we need to look at the OGFs of $a$ and $b$ (call them $A_{o}(x, {c(a_{j}) \cdot a_{j}}{a_{j}!}$, {j=1}^{k}\frac{c(a_{j}) \cdot a_{j} \cdot x^{a_{j}}}{a_{j}!}$, } \frac{s^{k}}{k!} \displaystyle\sum_{a_{1}+a_{2}+...+a_{k}=n-s} \displaystyle\prod_{j=1}^{k}\frac{c(a_, }\right)^{n}}$. Let $C(x) = f(A^{-1}(x))$ and $D(x) = \frac{1}{\left(\frac{A^{-1}(x)}{x}\right)^{n

Full text and comments »

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

20.
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...
the way to go. *C-The Hard Work of Paparazzi* is a classical dynamic- programming problem with a, #### General comments Broadly speaking, problems A-B-C-D were "div2 problems", while F-G-H were, > Find an $O(n^2)$ dynamic

Full text and comments »

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

21.
By MikeMirzayanov, 9 years ago, translation, In English
Codeforces: Results of 2017 <img src="/predownloaded/e4/09/e40915ee54c5991b91098756a90270d94be893b3.jpg"/> Happy New Year, Codeforces! I hasten to wish the whole community (and including me) correct programs, sudden insights, beautiful ideas and interesting problems! I hope that you have met the new year at least as fun as I am. Have you had enough sleep after New Year's Eve? This year, the traditional post summarizing the past year, I sat down to write only on January 1, 2018. I hope that I will not have to sum up the whole year. This post is important to me, since it draws a line to all the work done by the Codeforces team and the entire community in 2017. Many thanks to the team: all of the achievements listed below are the result of joint efforts. We did an excellent job! The community must know its heroes. In 2017, [user:MikeMirzayanov,2018-01-02], [user:KAN,2018-01-02] (problem coordinator), ~gritukan,2018-01-02 (second problem coordinator), ~netman,2018-01-02 (ex-second problem coordinator), ~k...
of Botan Investments grant program. 1. Search has been improved in Codeforces::Gym. 1. Autologout, pay attention to the programming contest whether in order to find the brightest talent (yes, you

Full text and comments »

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

22.
By Errichto, 8 years ago, In English
Stream I want to try streaming competitive programming. The goal is to make it educational so I will be talking a lot, also answering (at least some) questions. I'm planning three completely different streams to see what format to use: 1. Solving random easy-medium problems. 2. Solving old problems from Polish olympiad. 3. Post-contest stream, assuming I'm a setter or tester of a contest. Similar to what [user:scott_wu,2018-09-27], [user:ecnerwala,2018-09-27] and [user:stevenkplus,2018-09-27] did. Any thoughts, ideas? The first stream will most likely be on Sunday, starting around 7-8pm CEST. I will use Twitch and talk in English only. These first streams should show me and you whether it's cool and useful, and whether I like doing it. Also, I will try to make the video accessible later. **--- UPDATE ---** The first stream will start on Saturday at 10am CEST (check your [timezone](https://www.timeanddate.com/worldclock/fixedtime.html?msg=Errichto+Stream+%231&iso=2018...
I want to try streaming competitive programming. The goal is to make it educational so I will be

Full text and comments »

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

23.
By -is-this-fft-, history, 4 years ago, In English
PSA: don't use these functions unless you really, really need to When solving problems in competitive programming, it is almost never a good idea to use the following inbuilt C++ functions. You **will** be hacked or fail a pretest or worse, a systest. Why? Because they use floating-point numbers. They are designed to be used with a floating-point input and a floating-point output. The issue is that on a floating-point number, the result may not be exact. Worse, floating-point numbers may not be able to accurately encode the integer. ##### To calculate $\lfloor \frac{a}{b} \rfloor$ for positive integers $a$ and $b$: * **Don't** use `floor((double) a / (double) b)` or similar. * **Do** use `a / b`. It will round down. * **Warning:** be careful with negative numbers. The answer depends on whether we should round down or towards 0. ##### To calculate $\lceil \frac{a}{b} \rceil$ for positive integers $a$ and $b$: * **Don't** use `ceil((double) a / (double) b)` or similar. * **Do** use `(a + b - 1) / b`. * **Warning:** the same caveat ...
— on the binary representation of the number. If you have access to C++20, there is also the, When solving problems in competitive programming, it is almost never a good idea to use the

Full text and comments »

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

24.
By scott_wu, history, 7 years ago, In English
New contest format?! Stream feat. tourist, Um_nik Hey all! We've created a new 1v1 programming contest format: **Lockout**. Like in most contests, each round has a set of problems and contestants work to solve them as quickly as they can. In Lockout, however, contestants compete head-to-head and only the first contestant to solve each problem gets the points. Contestants can work on problems in any order, so speed and strategy are crucial to avoid getting sniped! The head-to-head action also makes the contest much more exciting for viewers. We ran the first edition of Lockout at TCO Finals last month as a double-elimination bracket [tournament](https://challonge.com/lockout0). All of the finalists who were available competed (and even some of the problem writers) and we got to see a lot of exciting back-and-forth matches! As you can see though, there's still one set left to play. So we'll be streaming **Grand Finals of Lockout 0 featuring [user:tourist,2019-12-28] vs. [user:Um_nik,2019-12-28]** at [9:30 AM PST](https://www.timea...
Hey all! We've created a new 1v1 programming contest format: **Lockout**. Like in most contests

Full text and comments »

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

25.
By Igorjan94, history, 9 years ago, In English
C++17, competitive programming edition C++17 is now [available](http://codeforces.me/blog/entry/57646) on codeforces, community [wants](http://codeforces.me/blog/entry/15643?#comment-413401) new edition of [C++ tricks](http://codeforces.me/blog/entry/15643) by [user:Swift,2018-02-19], so, let's start! Disclaimer: I have done only few examples of new features, which in my opinion are related to competitive programming. Feel free to comment and provide more real-world examples or ask to elaborate some features with more examples or explanations. ### Fold expressions * I think that everybody knows, what reduce or fold means, but a c++11 example: ``` vector<int> v = {1, 3, 5, 7}; int res = accumulate(v.begin(), v.end(), 0, [](int a, int b) { return a + b; }); cout << res; // 16 ``` * In C++17 there is also folding support for a template parameters list. It has the following syntax: ``` (pack op ...) (... op pack) (pack op ... op init) (init op ... op pack) ``` * For example, implement a template...
C++17, competitive programming edition, guaranteed to be evaluated first, then b, then c:, гарантированно сначала вычисляется a, затем b, затем c:, * I think that everybody knows, what reduce or fold means, but a c++11 example:, * In C++17 there is also folding support for a template parameters list. It has the following, * Начиная с C++17 есть поддержка свертки для шаблонного списка со следующим синтаксисом:, * Я думаю все знают, что такое reduce и свертка, но все-таки приведу пример из c ++11:, // C++14 void func() { auto lambda1 = [self = *this]() { self.f, // C++17 void funcNew() { auto lambda1 = [*this]() { f(); }; auto, //C++11 pair p1 = {14, 17.0} point u = {1, 2};, //C++17 for (auto& [x, y] : points) { //...Some compex logic with x and y } ```, //C++17 for (auto& [x, y] : points) { //...Какая-то сложная логика с x и y } ```, //C++17 pair p2 = {14, 17.0} point v = {1, 2}; ```, And in general c++17 introduces new rules, defining more strictly the evaluation order of, Before C++17 we cannot do this without explicit first argument:, C++17 is now [available](http://codeforces.me/blog/entry/57646) on codeforces, community [wants, C++17 уже [доступен](http://codeforces.me/blog/entry/57646) на codeforces, сообщество [хочет](http, For C-lovers:, ``` // C++17 template void pushToVector(vector& v, Args, ``` //C++14 auto Sum() { return 0; }, ``` //C++17 template auto Func(Args... args) { return (args + ...); }, ``` //C++17 template void readln(Args&... args) { ((cin >> args), ...); }, ``` a.b a->b a->*b a(b1, b2, b3) b @= a a[b] a << b << c a >> b >> c ```, vector> points = {{0, 0}, {1, 0}, {1, 1}, {1, 0}}; //C++11 for (auto& point : points, В C++17 появились новые правила, более строго определяющие порядок вычисления выражений:

Full text and comments »

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

26.
By dj3500, 12 years ago, In English
Hightail — automatic tester for programming contests Hi! In this post I would like to introduce you to an application called [Hightail](http://github.com/dj3500/hightail). [Hightail](http://github.com/dj3500/hightail) is an automatic tester for programming contests such as CodeForces rounds. It will parse the problem statement, extract sample test cases (inputs and outputs) from it, and verify the correctness of your program against them. It is built to provide maximum automation and to relieve the contestant as much as possible. A list of Hightail's features: - parsing problem statements - parsing entire contests (autoloading all problems) - scheduling contest parsing ahead of time - ability to comfortably view, edit and add test cases - handling of all verdicts: WA, TLE, RE, even AC - customizable time limits - ability to create in/out files in your working directory - detection of floating point values (comparing 0.1 vs. 0.10 does not give WA) - easy-to-use UI, keyboard shortcuts - resilient: it is multi-threaded so ...
Hightail — automatic tester for programming contests, program hang it; it will withstand large amounts of output from your program - support for all, programming contests such as CodeForces rounds. It will parse the problem statement, extract sample test

Full text and comments »

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

27.
By adamant, history, 4 years ago, In English
Duality in linear programming. Part 1 — definition and construction Hi everyone! Previously I [wrote](https://codeforces.me/blog/entry/98334) about theoretical grounds of "aliens trick". Specifically, I introduced the concept of the Lagrangian duality and explained its connection with the trick. Today I want to elaborate a bit more on the concept of dual problems and their applications to linear programming as well as to common problems in competitive programming. I initially wanted to also write about some applications in competitive programming problems, but given that the introduction is already quite lengthy, I decided to leave it for another blog, while using most common and well-known theoretical examples here, focusing more on how to construct and interpret dual problems to begin with, rather than how to use it in contests. I think, it is a crucial first step towards using the duality in actual programming challenges. #### Prerequisites It is highly recommended to have some general understanding of basic mathematical optimization...
Duality in linear programming. Part 1 — definition and construction, \mathbb R^c$ and $\lambda_2 \in \mathbb R^d$. Then the Lagrangian is, from the dual problem formulation replacing $A^\top\lambda_1 - c = \lambda_2$ equality with $A^\top, meaning behind $Ax \leq b$ and $A^\top \lambda \geq c$?, strong duality $t(\lambda^*) = f(x^*)$ holds. #### In linear programming **Def. 12**. Let $c \in, $$ L(x,\lambda_1, \lambda_2) = c^\top x + \lambda_1^\top (b-Ax) + \lambda_2^\top x $$, $$ \lambda^\top c = \sum\limits_{i,j} x_{ij} c_{ij}. $$, $$ c^\top x \leq \lambda^\top A x \leq \lambda^\top b. $$, $$ t(\lambda_1, \lambda_2) = \max\limits_{x \in \mathbb R^d} [c^\top x + \lambda_1^\top (b-Ax, $$\begin{gather} \max\limits_x & c^\top x & \color{red}{\text{(maximization)}} & \overset{\text, $$\begin{gather} \max\limits_{\lambda \in \mathbb R^c} & t(\lambda) \\ s.t. & \lambda \geq 0, $$\begin{gather} \max\limits_{\lambda \in \mathbb R^c} & t(\lambda),\\ s.t. & \lambda \geq 0, $$\begin{gather} \max\limits_{\lambda, \mu \in \mathbb R^{c+d}} & t(\lambda, \mu),\\ s.t, $$\begin{gather} \max\limits_{x \in \mathbb R^d} & c^\top x,\\ s.t. & Ax \leq b,\\ & x \geq 0, $$\begin{gather} \max\limits_{x,y,z} & c^\top x + d^\top y + f^\top z & \overset{\text{dual}}{\iff, $$\begin{gather} \min\limits_{\lambda \in \mathbb R^c} & b^\top \lambda,\\ s.t. & A^\top\lambda, $$\begin{gather} \min\limits_{\lambda \in \mathbb R^c} & t(\lambda) \\ s.t. & \lambda \geq 0, $$\begin{gather} \min\limits_{\lambda \in \mathbb R^c} & t(\lambda),\\ s.t. & \lambda \geq 0, **Def. 12**. Let $c \in \mathbb R^d$, $b \in \mathbb R^c$ and $A \in \mathbb R^{ c \times d}$. The, **Def. 7**. A vector $\lambda \in \mathbb R^c$ defined above is called the **Lagrange multiplier**., At the same time $\lambda^\top A = (A^\top \lambda)^\top$, hence for $A^\top \lambda \geqc$ it, Let $f : X \mapsto \mathbb R$ be the objective function and $g : X \mapsto \mathbb R^c$ be the, Now, $A^\top \lambda \geq c$ inequality says that there are $m$ dual variable $\lambda_1, \dots, This immediately shows that $\lambda^\top b$ provides an upper bound for $c ^\top x$ and by, When $A^\top\lambda_1 - c \neq \lambda_2$, this value can be arbitrarily large. Otherwise $t, where $f: X \mapsto \mathbb R$ is the objective function and $g: X \mapsto \mathbb R^c$ is the

Full text and comments »

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

28.
By lnishan, 11 years ago, In English
An awesome list for competitive programming! This is a project I started from late January 2016. My motive is that: Although there's fantastic information out there, I think they're still spread all over the place. Therefore, in my opinion it would probably be cool if there's an [awesome list](https://github.com/sindresorhus/awesome) for competitive programming! ( *It's now featured on the main list!* ) I'm actively updating the list here: [https://github.com/lnishan/awesome-competitive-programming](https://github.com/lnishan/awesome-competitive-programming) # Awesome Competitive Programming [![Awesome](https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg)](https://github.com/sindresorhus/awesome) A curated list of awesome `Competitive Programming`, `Algorithm` and `Data Structure` resources. Created with a view to connecting people to information, this list below contains a complete collection of all the fantastic resources I've collected over the course of my 11...
An awesome list for competitive programming!, H. Rosen | Discrete Mathematics is closely relevant to competitive programming . This book provides, competitive programming. | | ★★★ | [Stanford CS 97SI: Introduction to CompetitiveProgramming Contests, floating point numbers. A must read especially for geometry topics. | | ★★☆ | [Object-OrientedC Style, for algorithms and data structures in Java and C++. You may also visit his [GitHub Repository](https, visualize graphs. | | ★★☆ | [tcframe](http://tcframe.org/) | A C++ framework for generating test cases, ### C/C++, ) * [Language Specifics](#language-specifics) * [C/C++](#cc) | [Java](#java) | [Miscellaneous, ) | Hybrid / Windows | Far Manager is the most widely-used editor in the RU/CIS competitiveprogramming, -are-some-cool-C++-tricks-to-use-in-a-programming-contest) | Plentiful C++ tricks for competitive, -programming-books) | | Community-curated C++ Resources | [Hackr.io](https://hackr.io/tutorials/learn-c-plus, /15643) ... [What are some cool C++ tricks to use in a programming contest? — Quora](https, programming competitions. The competition consists of unique programming challenges which must be

Full text and comments »

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

29.
By -is-this-fft-, history, 4 years ago, In English
[Tutorial] The command line: how to read input from file without #ifdef and much more #### Introduction Instead of algorithms and math, I'll be doing something completely different here. There is something that has bothered me for a long time: people not understanding the tools they use to participate in contests and thus failing to take real advantage of them. And it all goes back to not understanding the command line. Some of you might say, "well surely, the command line is something obsolete and you're only clinging to it because you [insert ridiculous amateur-psychology here]?" No! The command line is not obsolete, and unless competitive programming becomes so mainstream that software vendors start writing professional-grade tools aimed specifically at us, it won't be. [cut] $~$ What is the command line? Any of these: ![ ](/predownloaded/bd/b6/bdb6c157b9b3ce5ae046c9064e469e0081f8c0fe.png) As you can see, it comes in many background colors and fonts, but the basic idea is always the same. It's a box you can type commands in, which it will ...
wrote.** A very basic thing in competitive programming that you have to do is test yourprogram, at, Finally, in case you get stuck in an infinite loop, Ctrl-C will stop the program ., This tells another program, called `g++` (the real name is GNU Compiler Collection, g++ is just a, programming. First, we shall write a program. Of course, you already know how to do this, so there is no

Full text and comments »

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

30.
By pwned, 22 months ago, In English
Train Better with ThemeCPs (+ Website)! Hello Codeforces! I am excited to share with you my competitive programming innovation which successfully propelled me to master (2100+)! This is the **<span style="color:black;">Theme</span><span style="color:red;">CP</span>** training method, which stands for **Themed <span style="color:red;">C</span>odeforces <span style="color:red;">P</span>rogressions**. Use at your discretion -- your Codeforces practice may get too effective and addictive! ![ ](/predownloaded/b5/33/b533201227bd15e23e4d344e38cf7f454e27e08a.png) **Want to read this blog in document form (with images)? Check out the following Google Doc!** https://tinyurl.com/themecp #### What is **<span style="color:black;">Theme</span><span style="color:red;">CP</span>**? **<span style="color:black;">Theme</span><span style="color:red;">CP</span>** is an experimental training system wherein users train on a perpetual ladder for ratings in **[<span style="color:gray;">900</span>, <span style="color:black;">3</span><...
I am excited to share with you my competitive programming innovation which successfully propelled

Full text and comments »

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

31.
By indy256, 13 years ago, In English
Dynamic Programming Optimizations Several recent problems on Codeforces concerned dynamic programming optimization techniques. The following table summarizes methods known to me. <table> <tr> <th>Name</th> <th>Original Recurrence</th> <th>Sufficient Condition of Applicability</th> <th>Original Complexity</th> <th>Optimized Complexity</th> <th>Links</th> </tr> <tr> <td><small>Convex Hull Optimization1</small></td> <td nowrap><small>$dp[i] = min_{j<i}\{dp[j]+b[j] \star a[i]\}$</small></td> <td nowrap>$b[j] \geq b[j+1]$<br/><small><s>optionally</s>&nbsp;$a[i] \leq a[i+1]$</small></td> <td nowrap>$O(n^2)$</td> <td nowrap>$O(n)$</td> <td nowrap><small>[1](https://web.archive.org/web/20181030143808/http://wcipeg.com/wiki/Convex_hull_trick) [2](https://cp-algorithms.com/geometry/convex_hull_trick.html) [3](https://codeforces.me/blog/entry/63823)<br/>[p1](/contest/319/problem/C)</small></td> </tr> <tr> <td><small>Convex Hull Optimization2</small></td> <td nowrap><small>$dp[i][j] = min_{k<j}{dp[i-1][k]+b...
Dynamic Programming Optimizations, sufficient condition of applying **Divide and Conquer Optimization** in terms of function $C[i][j]$?, Several recent problems on Codeforces concerned dynamic programming optimization techniques. The, ](https://codeforces.me/blog/entry/63823) [p1](/contest/319/problem/C) , ]+C[k][j]$ - $C[i][j]$ — some given cost function - We can generalize a bit in the following

Full text and comments »

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

32.
By qwexd, 13 days ago, In English
Codeforces Round 1121 (Div. 2) <div class="problem-statement" style="border:0 !important; padding:0 !important; margin:0.5em !important; box-shadow:none !important;"> <div class="header"> <div class="title">1121. Another Round</div> <div class="time-limit"><div class="property-title">time limit per participant</div> 2 hours</div> <div class="memory-limit"><div class="property-title">memory limit per participant</div> 1 brain</div> </div> <div class="legend"> <p> <i>This is <s>an interactive problem</s> a contest with an <b>unusual start time</b>.</i> </p> <p> You are given a Codeforces account and $n = 6$ problems, authored and prepared by [user:qwexd,2026-09-12] and [user:jeroenodb,2026-09-12]. </p> <p> In one operation, you may choose a problem $i$ ($1 \le i \le n$) and submit a program intended to solve it. </p> <p> The maximum scores are given below. Problem E is divided into two subtasks. </p> <div style="overflow-x:auto; margin:0.5em 0 1em;"> <table style="border-collapse:co...
> In one operation, you may choose a problem $i$ ($1 \le i \le n$) and submit a program

Full text and comments »

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

33.
By duality, 3 years ago, In English
Codeforces Round #884 (Div. 1 + Div. 2) Editorial Video editorials for [B](https://www.youtube.com/watch?v=5nzUni8dFLQ), [C](https://www.youtube.com/watch?v=8mz7gnAJ5QM), and [D](https://www.youtube.com/watch?v=ahnNAwpGwHc) are available on [user:ak2006,2023-07-11]'s channel. ### [problem:1844A] <spoiler summary="Hint 1"> There exists a small $n$ where the second player can win. </spoiler> <spoiler summary="Hint 2"> If $a \ge 2$, then $n = 1$ works. </spoiler> <spoiler summary="Solution"> [tutorial:1844A] </spoiler> <spoiler summary="Implementation"> ~~~~~ #include <bits/stdc++.h> using namespace std; int main() { int t,a,b; scanf("%d",&t); while (t--) { scanf("%d %d",&a,&b); printf("%d\n",a+b); } return 0; } ~~~~~ </spoiler> ### [problem:1844B] <spoiler summary="Hint 1"> In order for $(l,r)$ to contribute to the primality, we must have $\operatorname{MEX}(a_l,\dots,a_r) \ge 2$, so there is some value $1$ between indices $l$ and $r$. </spoiler> <spoile...
multiple of $3$? Let $f(a,b,c)$ be the answer. Write some dynamic programming recurrences for $f(a,b

Full text and comments »

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

34.
By Arpa, history, 4 years ago, In English
Ten years of Competitive Programming Hey Codeforces! I’m AmirReza PourAkhavan, Codeforces Contest Coordinator. I let the story become complete and I’m sharing it now. The story is about a 16-year competitive programmer, who left his family and migrated to another city alone to follow competitive programming. After seven years, he advanced to the International Collegiate Programming Contest World Finals, twice. ### Why I’m writing this Six years ago someone asked me [here](https://codeforces.me/blog/entry/45186?#comment-297837) to write my story. I think it can help you to never give up. ### A brief about me I've been doing competitive programming for ten years. I advanced to ICPC (International Collegiate Programming Contests) World Finals twice, in 2019 at Porto and 2020 at Moscow. At ICPC World Finals 2020, our team took high-honored place twenty-four, which is equal to the top 0.03% of 200k students participating in ICPC. <center> <br> <img width="50%" src="/predownloaded/c2/0c/c20c501bba688...
Ten years of Competitive Programming, his family and migrated to another city alone to follow competitive programming . After seven years, A teacher (Seyed Hamed Sadat Hosseini) taught me C++ in the summer before 9th grade. He was my

Full text and comments »

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

35.
By Gassa, history, 8 years ago, translation, In English
The D programming language in competitive programming Hi all! This post is inspired by a question [here](/blog/entry/51923?#comment-446901) which asks [user:yosupo,2018-07-28] how using the D progamming language compares to using C++. I regularly use D where possible in contests (and problemsetting) since 2014, with some success (for example, a program in D brought me victory in [AZsPCs: Alphabet City](http://azspcs.com/Contest/AlphabetCity/Standings)). So I'd like to share my experience. I'll try to focus on stuff which is important in competitive programming. The general feeling is as follows. You can write in D as in plain C when you need full control. You can also write more like in Python using the powerful standard library. However, D is a compiled language, so in both cases, the performance is similar to C++. Additionally, when the program is written, it is much easier to debug than a similar program in C++. For an example, let us look at two solutions of a [recent problem](/contest/1010/problem/A). [cut] ...
The D programming language in competitive programming, %s " (n, m); auto c = (readln ~ readln) .splitter .map !(to!double, [user:yosupo,2018-07-28] how using the D progamming language compares to using C++. I regularly use D where, competitive programming. The general feeling is as follows. You can write in D as in plainC, every language except C++., for HashSet and TreeMap. (As is the case with C++, D can do anything, it's just the matter of, language, so in both cases, the performance is similar to C++. Additionally, when theprogram is, languages, they are most likely a subset of C, C++, Java, Pascal, Python, and maybe the organizers, of magnitude than for C++., of minor features which together mean a world of difference compared to C++ when writing programs, * Library. The standard library of C++ has weak, cumbersome, and unwieldy parts: string, * Style choice. Be it an imperative program, a chain of transformations applied to the data, or, A phrase like `function !(args1) (args2)` is analogous to `function (args2)` in C++: the, C program is compiled with D, it either throws a compile error or works the same., The first solution [is written](/contest/1010/submission/40877038) like plain C:, ~~~~~ import std.stdio; int main () { int n, m, i; double c = 1.0, x; scanf ("%d%d

Full text and comments »

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

36.
By errorgorn, 5 years ago, In English
Linear Basis (Xor Basis Extended) As part of the graduation requirements for my school, I have to complete a simple research project, so I decided to do something related to data structure and algorithms. I believe I have come out with a data structure that maintains the basis of vectors in $(\mathbb{Z}/m\mathbb{Z})^d$, where $m$ **may not be prime**. Since this was related to competitive programming, I think it is a good idea to share it here. Hopefully, this algorithm is actually novel :P I would like to thank: - [user:icypiggy,2021-12-26] for being my research mentor and tolerating my dumb questions - [user:rama_pang,2021-12-26] and [user:adamant,2021-12-28] for their helpful suggestions and comments Please comment under the blog or message me on codeforces if any parts are unclear or wrong. Also, I hope that some LGMs can help solve the open problems in this blog. # Introduction Maintaining the basis of vectors in $(\mathbb{Z}/2 \mathbb{Z})^d$, also known as the xor basis algorithm is a well-studie...
Of course, this is a competitive programming site, so I will also provide a sample implementation

Full text and comments »

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

37.
By HosseinYousefi, history, 8 years ago, In English
Competitive C++ Manifesto: A Style Guide # Competitive C++ Manifesto: A Style Guide There are many style guides for C++ out there, but we can't really use them as competitive programmers. We just want to write our code correctly as fast as possible! Trying to hack people here on codeforces, I realized there is a need for a style guide! Our goal is to write correct, fast, clear and consistent code. > #### Disclaimer > This is not a rulebook. You can integrate parts of it into your coding style. > Don't overthink it, especially during a contest! I'm going to use this guide for myself and to [teach my students](https://in.harbour.space/computer-science/modern-c-programming-hossein-yousefi/). I'm planning to make some good stuff in the future following these principles! Stay tuned! ## Compiler Make use of C++17. Use `-Wall -Wextra -Wshadow` flags for compilation, and try to eliminate all of the warning messages, this will prevent you from having some silly bugs. There are more debugging flags like `-fsanitize=un...
Competitive C++ Manifesto: A Style Guide, ## Comments In competitive programming, you usually don't want to write long comments, but in case, ## Read more * [Stroustrup: C++](http://www.stroustrup.com/C++.html) by Bjarne Stroustrup * [C, -science/modern-c-programming-hossein-yousefi/). I'm planning to make some good stuff in the future, ://in.harbour.space/computer-science/modern-c-programming-hossein-yousefi/). I'm planning to make some, ;`. *Rationale: It's more consistent with the style of modern C++.* * Use `struct` instead of `class

Full text and comments »

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

38.
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...
I've written a simple C++ program. It generates a random tree by selecting the parent of vertex $u

Full text and comments »

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

39.
By mukel, 13 years ago, In English
C++11 for programming contests... Updated: 30 December 2013 3:27 CEST (Added a brief introduction to Lambda Functions). The [new C++ standard](http://en.wikipedia.org/wiki/C++11), also known as C++11 and also as C++0x is here, with some sugars for programming contest. I'll update this thread soon with new contents (and better structure). You can use C++11 on Topcoder, Codeforces, HackerRank ... This thread is based on my own experience, so you don't need to dig on the whole C++11 specification to find some useful feature you can use in programming contests. ### The "auto" keyword: Type inference is included in many modern programming languages, and C++ is not behind, the "auto" keyword works like "var" in C#, it only tells the compiler to infer the type for us: So, ~~~~~ map< string, pair< int, int > > somyLongTypeName = map< string, pair< int, int > >(); ~~~~~ Can be shortened to, with no impact on speed, since the type is inferred at compile time: ~~~~~ auto longTypeNamesAreHistory = map< strin...
### The "auto" keyword: Type inference is included in many modern programming languages, andC, C++

Full text and comments »

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

40.
By TheScrasse, history, 5 years ago, In English
[Tutorial] Product Trick Hello everyone,<br> in this tutorial we will see a trick that can be useful in combinatorics and/or DP tasks. In particular, you can use it when the statement says something similar to "the score of an array is the product of its elements, find the sum of the scores over all the possible arrays". Prerequisites: basic combinatorics and DP The trick ------------------ The trick is very simple. "The score of an array $a$ is $\prod_{i=1}^n a_i$" can be rephrased as "if there are $n$ boxes, and the $i$-th box contains $a_i$ distinguishable balls, the score of $a$ is equal to the number of ways to color a ball for each box". This is quite obvious, but it can be extremely powerful. Let's see some problems that are trivialized by this trick. [Dwango Programming Contest 6th, problem C](https://atcoder.jp/contests/dwacon6th-prelims/tasks/dwacon6th_prelims_c) (rating: 2618) ------------------ <spoiler summary="Hint 1"> You have to output the sum of the happiness over all po...
[Dwango Programming Contest 6th, problem C ](https://atcoder.jp/contests/dwacon6th-prelims/tasks

Full text and comments »

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

41.
By pajenegod, history, 3 years ago, In English
Tutorial: A simple O(n log n) polynomial multiplication algorithm Hi Codeforces! I have something exciting to tell you guys about today! I have recently come up with a really neat and simple recursive algorithm for multiplying polynomials in $O(n \log n)$ time. It is so neat and simple that I think it might possibly revolutionize the way that fast polynomial multiplication is taught and coded. You don't need to know anything about FFT to understand and implement this algorithm. Big thanks to [user:nor,2023-07-10], [user:c1729,2023-07-10] and [user:spheniscine,2023-07-10] for discussing the contents of the blog with me and comming up with ideas for how to improve the blog =). I've split this blog up into two parts. The first part is intended for anyone to be able to read and understand. The second part is advanced and goes into a ton of interesting ideas and concepts related to this algorithm. Prerequisite: Polynomial quotient and remainder, see [Wiki article] (https://en.wikipedia.org/wiki/Polynomial_greatest_common_divisor#Euclidean_divi...
Here is an FTT, Here is an NTT

Full text and comments »

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

42.
By dolphingarlic, history, 6 years ago, In English
What to do at the IOI after you (inevitably) solve everything With IOI just around the corner, [some](https://codeforces.me/profile/tmwilliamlin168) [of](https://codeforces.me/profile/300iq) [you](https://codeforces.me/profile/saba2000) may be wondering: **"what should I do after I AK after 3 hours?"** In this post, I'll share some activities that you can do to pass the time! (Note that some of these may not be applicable for an online IOI) ## Level 1 &mdash; Built-in software on your computer The most obvious thing you can do is use the built-in stuff. I'm talking about playing Minesweeper, reading the C++ documentation, or anything similar. While Minesweeper is quite fun and the C++ documentation is... interesting, Minesweeper quickly becomes boring and you'll look like a huge nerd if you read the documentation (and you don't want that, do you?) That's why I'll only recommend this if you're a noob and only AK in 4 hours. ## Level 2 &mdash; Creating software So you've beaten Minesweeper 10 times already and read throug...
So you've beaten Minesweeper 10 times already and read through the C++ documentation twice. What

Full text and comments »

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

43.
By awoo, history, 4 years ago, translation, In English
Educational Codeforces Round 142 [Rated for Div. 2] Hello Codeforces! On [contest_time:1792] [contest:1792] will start. Series of Educational Rounds continue being held as [Harbour.Space University](https://harbour.space/) initiative! You can read the details about the cooperation between [Harbour.Space University](https://harbour.space/) and Codeforces in the <a href="http://codeforces.me/blog/entry/51208">blog post</a>. 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 **6 or 7 problems** and **2 hours** to solve them. The problems were invented and prepared by Adilbek [user:adedalic,2023-01-23] Dalabaev, Vladimir [user:vovuh,2023-01-23] Petrov, Ivan [user:BledDest,2023-01-23] Androsov, Ma...
competitive programming competitions in general._ - _**Division C.** Designed for newcomers to the, of ICPC and competitive programming competitions in general._ - _**Division C .** Designed for, _Preparations are under way for the second “Hello Muscat 2023” ICPC programming bootcamp, the

Full text and comments »

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

44.
By adamant, history, 22 months ago, In English
std::generator and recursive lambdas in C++23 Hi everyone! As Codeforces now [supports C++23](https://codeforces.me/blog/entry/133046), it seems to be the right time to discuss some of the particularly interesting features. Some noteworthy ones that were already mentioned elsewhere include: - `views::zip` that maps two ranges into pairs `(A[i], B[i])`. - `views::enumerate` that maps range into pairs `(i, a[i])`. - `views::adjacent<k>` that maps range into tuples `(a[i], ..., a[i+k-1])`. - `views::cartesian_product` that maps two ranges into pairs `(A[i], B[j])` with all possible `i` and `j`. - Some more [specialized views](https://en.cppreference.com/w/cpp/ranges). - `ranges::to<Container>` that creates a container out of a view, e.g. `to<vector>(views::iota(0, n))`. - `ranges::fold_left` and `ranges::fold_right`, range versions of `std::accumulate`/`std::reduce`. - `insert_range`/`append_range`/`prepend_range`/`assign_range` for containers (not in GCC yet). - `print`/`println` for formatted printing (it seems t...
std::generator and recursive lambdas in C++23, Another interesting feature that I haven't seen mentioned in competitive programming discussions at, Hi everyone! As Codeforces now [supports C ++23](https://codeforces.me/blog/entry/133046), it

Full text and comments »

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

45.
By Franklyn_W, history, 5 years ago, In English
When Dreams Come True: The only solve on N at ICPC WF 2020. _Addendum: This is mostly about the story behind our solution to N. To see more about the math, see [here](https://codeforces.me/blog/ekzhang)_ When I was younger, fairytales always captivated me, with their nice and clean stories. All through my life I've liked the idea of having a fairytale ending to a life arc, but I was frequently disappointed. Many times after an unsuccessful experience, one simply gets more unsucessful experiences and then time runs out... At ICPC recently, I was lucky enough to finally attain my fairytale ending to my competitive programming career. I figured I would tell the fairytale, to close a career that started about 6 years ago. On my World Finals team, my role is to help the team get hard math problems, as I haven't actively processed algorithms in years. So imagine my delight when my teammate ([user:ekzhang,2021-10-06]) points out that problem N reduces to finding a vector so that the (l2)-norm of x is r, and $Ax = b$ for a matrix $A$ and vect...
lucky enough to finally attain my fairytale ending to my competitive programming career. I figured I, At the last few programming contests I've participated in, run-time error has been a pretty common

Full text and comments »

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

46.
By Vladithur, history, 4 years ago, In English
Codeforces Round #813 (Div. 2) Editorial Thanks for participating in the round, we hope you liked the problems! <spoiler summary="Solve count predictions (official div. 2)"> Handle | A | B | C | D | E1 | E2 | F --- | --- | --- | --- | --- | --- | --- | --- [user:Vladithur,2022-08-13] | 16K | 8K | 3K | 900 | 500 | 50 | 4 [user:_dlbm17,2022-08-13] | 14K | 9K | 5K | 500 | ? | ? | ? [user:thanhchauns2,2022-08-13] | 14K | 8K | 2K | 1K | 500 | ? | ? [user:QuangBuiCP,2022-08-13] | 14K | 7K | 2K | 1K | 500 | 24 | 5 [user:welleyth,2022-08-13] | 16K | 10K | 4K | 1.5K | 600 | 130 | 2 [user:Kon567889,2022-08-13] | 14K | 10K | 5K | 2K | ? | ? | 5 </spoiler> [problem:1712A] <spoiler summary="Hint"> The smallest possible sum is $1 + 2 + \ldots + k$. </spoiler> <spoiler summary="Tutorial"> [tutorial:1712A] </spoiler> <spoiler summary="Solution"> ~~~~~ #include <bits/stdc++.h> #define all(x) (x).begin(), (x).end() #define allr(x) (x).rbegin(), (x).rend() #define gsize(x) (int)((x).size()) const ch...
The quote is the meme "people die when they are killed" in the Fate series

Full text and comments »

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

47.
By orz, history, 2 years ago, In English
C++20 is back In contests and in the custom invocation, after a pause, one can again find GNU G++20 64-bit. However, the [slowdown issue](https://codeforces.me/blog/entry/126654) because of which the language disappeared persists, there are still snippets of code that can slow down the execution on Codeforces servers by a factor of 100 or so. So what is the official position of Codeforces headquarters and of our community on that? 1. Are there general methods of constructing testcases that can exploit this GCC/Windows bug and therefore slow down solutions (like there are [anti-hash tests](https://codeforces.me/blog/entry/62393) for solutions using `unordered_set`)? Are there methods that slow down both contest mode and custom invocation mode (since [submission:249807302] is only slow in the contest mode whereas [submission:253289473] is only slow in the custom invocation)? 2. If so, should we expect such tests in future contests, will such methods be used during the test preparation in co...
C++20 is back, accepted?) 4. Is there no bug in 32-bit version? If it's 64-bit only, maybe CF team could add aC

Full text and comments »

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

48.
By adamant, 10 months ago, In English
Caveats of using optimize("Ofast") with target("avx2") Hi everyone! As you may know, it is often recommended to put these lines in your header: ```cpp #pragma GCC optimize("Ofast,unroll-loops") #pragma GCC target("avx2") ``` And they're usually great!<sup>[1]</sup> Well, until they aren't. For last 2-3 days I was riddled with the issue that [CP-Algorithms Library](https://lib.cp-algorithms.com) would perform very well on Library Checker, but whenever I tried to also apply it on Codeforces, it will fail to speed up the code, and sometimes would even make it much slower. As I finally figured out the cause, I'd like to write a blog about it, so that other people don't waste as much time. Mitigating these issues improved my running time on [problem:1975G] from **1530 ms** in [submission:316602668] to **203 ms** in [submission:352602775]. ##### Tl'dr See the "Takeaway" section at the bottom. [cut]<br> ##### Example problem I will reproduce the issue on a simple example: <hr> **[problem:911G]**: You are given an...
```cpp C:/Programs/gcc14-64-msys2/mingw64/include/c ++/14.2.0/bits/allocator.h:182:7: error

Full text and comments »

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

49.
By adamant, history, 16 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...
regret, the overwhelming mainstream in modern competitive programming is NTT. Primary reasons are

Full text and comments »

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

50.
By AlexSkidanov, 13 years ago, In English
MemSQL announces the start[c]up [MemSQL](http://www.memsql.com) is happy to announce **start[c]up** -- a programming competition, hosted by Codeforces and MemSQL HQ located in San Francisco, California. start[c]up consists of two rounds. All rounds will be prepared by MemSQL engineers: [**<font color=red>pieguy</font>**](http://community.topcoder.com/tc?module=MemberProfile&cr=22777893), [**<font color=red>nika</font>**](http://community.topcoder.com/tc?module=MemberProfile&cr=20315020), [**<font color=red>exod40</font>**](http://community.topcoder.com/tc?module=MemberProfile&cr=20036294), [**<font color=red>SkidanovAlex</font>**](http://community.topcoder.com/tc?module=MemberProfile&cr=22662189) and [**<font color=red>dolphinigle</font>**](http://community.topcoder.com/tc?module=MemberProfile&cr=22752635). Round 1 is online and takes place on July 13. Round 1 follows regular Codeforces rules and consists of 5 problems. For this round, the complexity of the problems will be comparable to a regular Codeforces ro...
MemSQL announces the start[c]up, [MemSQL](http://www.memsql.com) is happy to announce **start[c]up** -- a programming competition

Full text and comments »

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

51.
By Errichto, 15 months ago, In English
DP Group Class in August 2025 _The blog publish date is incorrect, should be around 12.07.2025. CF saved the draft date._ Hi, I'm organizing paid group classes on Dynamic Programming in August. Last year, I did something similar with general problem-solving ([link](https://codeforces.me/blog/entry/129878)). There will be two groups of different style and difficulty. Each group gets 8 lessons of 1h30m each, from 28.07.2025 to 24-31.08.2025. Group size up to 12 people. You get access to recordings and problems from both groups, but you should actively attend only one. There's a lot of homework, some to be discussed next lesson. I will create new original CF/Polygon problems, especially for the easy group. These problems will eventually be published for everybody! **Price**: 250 EUR with a small country-based discount. **Registration**: You should pay via [link (Stripe)](https://buy.stripe.com/7sY3cx2nD5Oh8CQ7w96wE03) and choose the group there. I will send you the Discord invite link via e-mail. Co...
You can use any programming language. I will use C++ for my examples.

Full text and comments »

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

52.
By PurpleThinker, 5 years ago, In English
How LEGENDARY programmers solve the A + B problem Hello, Codeforces! For many of us, the A + B problem was the first one we've solved and we think of it as just a really easy problem. But what if I told you there is a way to flex your programming skills by solving this problem _with style_? On this wonderful day of March 32nd, I will present a few ways to solve this interesting problem. I will only consider `a` and `b` strictly larger than `0`. Noob approach ================== ~~~~~ std::cout << a + b; ~~~~~ Almost-noob approach ================== Notice that we can interpret a + b as a incrementing a number `a` times, then `b` times. We get: ~~~~~ int ans = 0; for (int i = 1; i <= a; i++) ans++; for (int i = 1; i <= b; i++) ans++; std::cout << ans; ~~~~~ Slightly clever approach ================== Of course, we cannot stop there. A wise man once said: "every competitive programming problem is a dynamic programming problem if you try hard enough". So... let's be a little bit more imaginative! We define `dp[i][...
it as just a really easy problem. But what if I told you there is a way to flex yourprogramming, simplifying everything (for example, logos and UIs), sooner or later, the world will throw awayC, A programming challenge isn't just about algorithms; it can also be about the programming language

Full text and comments »

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

53.
By SecondThread, history, 6 years ago, In English
Why problem writers should stop saying “It is guaranteed that” Please Stop Guaranteeing Things ================== There are two common meanings for something being “guaranteed”, and often it is up to the reader to guess the author’s intended meaning. This is annoying and creates unnecessary barriers to entry. **Meaning #1:** The thing we are guaranteeing is provably true for the given input. The thing we are guaranteeing is simply true. We don’t want to provide a proof since it would be long, unnecessary, and annoying to read, and might spoil the solution, but you have our word that an answer always exists. Example: We give you two positive integers A and B (1 <= A, B <= 100). Find some positive integer C (1 <= C <= 200) such that C < A + B. **It is guaranteed that some C exists.** **Meaning #2:** The only input that is legal is input for which this is true. The thing we are guaranteeing might not always be true without this guarantee. Thankfully, we are providing this guarantee so that you only need to concern yourself with solving t...
integers A and B (1 <= A, B <= 100). Find some positive integer C (1 <= C <= 200) such thatC < A + B

Full text and comments »

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

54.
By AlexSkidanov, 12 years ago, translation, In English
Announcing MemSQL Start[c]UP 2.0 <a href=http://memsql.com>MemSQL</a> is excited to announce Start[c]UP 2.0 – the second annual programming competition hosted by Codeforces with an onsite at MemSQL HQ in San Francisco, California. Start[c]UP 2.0 consists of two rounds. Round 1 is online and takes place on <a href="http://www.timeanddate.com/worldclock/fixedtime.html?msg=MemSQL+Start%5Bc%5DUP+2.0+Round+1&iso=20140727T10&p1=224&ah=2&am=30">July 27th at 10:00 AM PST</a>. Round 1 follows regular Codeforces rules and consists of 5 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 round will be 2.5 hours long, and will be rated. Round 2 takes place on [August 10th at 10:00 AM PST](http://www.timeanddate.com/worldclock/fixedtime.html?msg=MemSQL+Start%5Bc%5DUP+2.0+Round+2&iso=20140810T10&p1=224&ah=3&am=00), consists of 6 problems, and uses regular Codeforces rules. The complexity of the problem...
Announcing MemSQL Start[c]UP 2.0, MemSQL <http://memsql.com> is excited to announce Start[c]UP 2.0 – the second annual

Full text and comments »

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

55.
By gojira, 5 years ago, In English
A look at Competitive Programming post-hibernation Hello friends! As I've recollected in a previous [post](https://codeforces.me/blog/entry/97566), I am an old competitor who hadn't really participated since ~2014, and recently got a bout of nostalgia to return to Competitive Programming. So, I did a couple Topcoder SRMs, suffered through some SNWS rounds, participated in [three regional 5hr competitions](https://contest.yandex.ru/3QF2021) on three consecutive days, and dozed off at every Codeforces contest I tried to wake up for. A lot of things are still the same as 8 years ago: [user:tourist,2022-01-26] is still at the top, grey coders still ask for how many minutes to solve a problem before reading the editorial, Russian university teams [continue winning](https://icpc.global/worldfinals/results) ACM ICPC, and Snarknews never gives up on his alternate competition formats. But in this post, I want to focus on the new patterns that emerged since my last time around. #### #1: Codeforces rounds timing Did you know that t...
A look at Competitive Programming post-hibernation, looking for an intelligible implementation of any contest problem. You would sail through the ocean ofC, nostalgia to return to Competitive Programming. So, I did a couple Topcoder SRMs, suffered through some

Full text and comments »

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

56.
By The-Winner, history, 10 months ago, In English
[Tips; personal stuff] I got red rank. Here's some stuff I learned Hello everyone! This blog will be a collection of ideas, thoughts and personal experiences I gathered over the past ~7 years (darn, I am old). It might not contribute much to the world so feel free to skip it, but I do believe most people can get something interesting out of it. I waited on writing this until my opinion was actually worth something (still, take the following with a grain of salt or two). It is be a big wall of text (you have been warned). Sorry for taking a week to post this, University is crazy at times. [cut] Tips (and some personal experience) for problems solving (can probably extend to whatever else it is you want to do): - The most important thing: **Have fun**. If you don't have fun doing whatever it is you are doing, you are motivated by an external factor, that when removed from the equation will remove you from the action. Without a reason to come back, you will not, and the whole experience will slowly fade away (congrats, you wasted your time). ...
Romanian brothers and sisters — [Emanuela Cerchez si Marinel Serban, Programarea in limbajulC/C

Full text and comments »

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

57.
By Chilli, history, 8 years ago, In English
C++ STL: Order of magnitude faster hash tables with Policy Based Data Structures TL;DR ----- The Policy Hash Table has 3-6x faster insertion/deletion and 4-10x increase for writes/reads. As far as I can tell, there are no downsides. The policy hash table (specifically the open-addressing version), beats out unordered_map in all my benchmarks. PS: Make sure you read the section a better hash function and use it &mdash; I'd recommend this one: https://github.com/kth-competitive-programming/kactl/blob/master/content/data-structures/HashMap.h Background ------ I've often been irritated by how slow unordered_map is in C++. Too often, I have something that runs fast enough in terms of complexity, but the constant factor from unordered_map slows down the solution too much. Yesterday though, after using the useful order statistics tree from https://codeforces.me/blog/entry/11080, I was curious if there were any other useful data structures hiding in the Policy STL. And lo and behold, I found a hash table. Benchmarks ------------------ Well, enough backsto...
C++ STL: Order of magnitude faster hash tables with Policy Based Data Structures, : https://github.com/kth-competitive-programming /kactl/blob/master/content/data-structures/HashMap.h

Full text and comments »

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

58.
By Sparky_Master_WCH1226, history, 19 months ago, In English
Problem of cheating in Competitive Programming You are probably already familiar with the following cheating methods, submitting your solution on alt account, with 4o, and then deep seek, and then o1, and then o3, finding solutions on telegram, finding solutions on youtube, finding solutions on discord, asking your blue rated friend, asking your purple rated friend, asking your orange rated friend, asking your red rated friend, asking your lgm rated friend, play as a team of cyan, play as a team of blue, play as a team of purple, play as a team of orange, play as a team of red, play as a team of lgm, asking some other blue that is not your friend, asking some other purple that is not your friend, asking some other orange that is not your friend, asking some other red that is not your friend, asking some other Lgm that is not your friend, pay an orange to play the contest for you, pay a red to play the contest for you, pay an LGM to play the contest for you, print out katcl and bring it to IOI, print out cp-algorithm and bring it to...
Problem of cheating in Competitive Programming, to rejudge your RE solution until all undefined behaviors are defined like your ownC++ standard

Full text and comments »

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

59.
By tiger2005, history, 3 years ago, In English
Introduction to CPLib (1) — Modern C++ Library for Test Data in CP You can refer to the second introduction post [here](https://codeforces.me/blog/entry/132343). CPLib is a library written in C++ for processing test data of competitive programming problems. It helps you write clear and efficient checkers, interactors, validators, and generators. CPLib uses "variable input template" as its major feature, provides friendly feedback for humans and backends, and is working hard to reach better compatibility and efficiency. You can get CPLib from [Github Repository](https://github.com/rindag-devs/cplib). The "single-header-snapshot" branch automatically updates single-header version of CPLib which is easy to use. Also, you can visit [cplib.aberter0x3f.top](https://cplib.aberter0x3f.top/) for more information. For regex-related questions, please refer to the [FAQ page](https://cplib.aberter0x3f.top/user-guide/faq). Here is a basic example of a checker using CPLib. For more examples, visit the links above. ```cpp #include "cplib.hpp" using ...
Introduction to CPLib (1) — Modern C++ Library for Test Data in CP, CPLib is a library written in C++ for processing test data of competitive programming problems. It

Full text and comments »

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

60.
By adamant, 13 years ago, translation, In English
C++ STL: Policy based data structures Hi everyone! After a relatively long lull, I decided that <s>my contribution growing too slowly</s> the hour has come to please you with another article in the blog _:)_ 2 months ago user [user:Perlik,2014-03-19] wrote an [article] (/blog/entry/10355), in which he described a very interesting STL implemented data structure that allows you to quickly perform various operations with substrings. Some time after I tested it on various tasks and, unfortunately, tend to get a negative result &mdash; rope was too slow, especially when it came to working with individual elements. For some time, I forgot about that article. Increasingly, however, I was faced with problems in which it was necessary to implement set with the ability to know ordinal number of item and also to get item by its ordinal number (ie, order statistic in the set). And then I remembered that in the comments to that article, someone mentioned about the mysterious data structure order statistics tree, which supports th...
C++ STL: Policy based data structures, implementation, greatly limiting its usefulness in programming olympiads, so I decided not to talk

Full text and comments »

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

61.
By Gellyfish, 16 months ago, In English
Codeforces Round 1028 (Div.1, Div.2) Editorial You could tell people didn't seem to like the match very much. I'm sorry I screwed up again ¯\\_(ツ)_/¯ If you're interested, I'd like to share some thoughts I have about this contest. <spoiler summary="sad story"> This time I've been trying my best to make the problems use more varied algorithms instead of just dp problems, but sadly [problem:2115C] was much harder than expected. But it seems like people are complaining more about the narrow time limit, centered on [problem:2116C] and [problem:2115C]. No one realized this before the contest, because none of the tester's code is get TLE except the wrong time complexity. I actually don't see a problem with the Time Limit of [problem:2116C]. Some of you may be puzzled, but let me try to explain this: - The intended solution is $O(\sum n \max(a) + \max(a)^2)$ and does not contain $\log \max(a)$. Computing $\gcd(x, y)$ is not $O(1)$, if you don't preprocess, then it's not unusual to actually get a TLE. - I believe the v...
Thus when $r > \max(c)^2$, that's the answer of the problem. And we can use another dynamic

Full text and comments »

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

62.
By Wind_Eagle, history, 4 years ago, translation, In English
How to train: why it's not enough to just do a lot of tasks Hello, Codeforces! I, like many of you, read blogs periodically. Lately, blogs from low-rated users who ask me how to raise their ratings have been catching my attention. I want to tell you a little bit about my opinion on these blogs. So what do these blogs look like? Usually this is a blog with a title something like <b>"I need help right now!"</b> or <b>"How to improve my rating, help me!"</b> When you open this blog, you see the most detailed description of the problem, such as: "I have solved 500 problems, but no improvement" or "I have solved 100 problems with rating >= 1500, but my rating is not increasing". And in the comments they usually write "you haven't solved enough, solve more" or "solve more difficult problems". <b>In my opinion, this is incorrect and misleads such users. So, imagine that you do not know anything at all about sports programming, or even about the basics of Olympic math. You at best (because many people don't even do that) have learned a programmin...
So, imagine that you do not know anything at all about sports programming, or even about the basics

Full text and comments »

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

63.
By E869120, 9 years ago, In English
[Tutorial] A Way to Practice Competitive Programming : From rating 1000 to 2000 Dear Codeforces Community.<br /> <br /> Today I want to share some ways to practice competitive programming and getting rating. I think this is helpful for those who is practicing competitive programming hardly but rating is sluggish. (By the way, on July 17th, I have a project of competitive programming said CombNaf in Japan. I did a lecture about this. Great thanks to the CombNaf's organizer is [user:Nafmo2,2017-07-17].)<br /> <br /> I will write this by **4 steps**: rating **<font color="grey">1000</font> --> <font color="green">1250</font>**, **<font color="green">1250</font> --> <font color="aqua">1500</font>**, **<font color="aqua">1500</font> --> <font color="blue">1750</font>**, **<font color="blue">1750</font> --> <font color="purple">2000</font>**, in Codeforces Rating System.<br /> <br /> Before writing about each step, I wrote it as premise: You don't have to do this way. This is just a way to practice. Ways to practice is different among people, so I think this may n...
[Tutorial] A Way to Practice Competitive Programming : From rating 1000 to 2000, Div2 A. * Solve ABC-C in AtCoder. There are many educational problems in AtCoder Beginner, of contest is mainly 5-6. * The problems of Div.2 said Div2 A, Div2 B, Div2 C, Div2 D, Div2, programming and getting rating. I think this is helpful for those who is practicing competitive

Full text and comments »

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

64.
By MikeMirzayanov, 8 years ago, translation, In English
Codeforces: Results of 2018 Hi Codeforces! February 2019 is already on the calendar, which means that I was late with the report for 2018. Better late than never! Let's remember last year. In 2018, [user:_kun_,2019-02-05], [user:300iq,2019-02-05] and [user:arsijo,2019-02-05] joined the team of coordinators. The work of the coordinators is headed (and is the coordinator of the coordinators) [user:KAN,2019-02-05]. I really hope that a more measured schedule of preparing rounds by a large team of coordinators will give a better insight into the contests. The main innovations in the platform are implemented by me and the developers [user:kuviman,2019-02-05], [user:fcspartakm,2019-02-05], [user:MaximShipko,2019-02-05]. Great work on the organization of events and prizes mailing was done by [user:gKseni,2019-02-05]. Special thanks to the writers of the problems and testers. It is your content that charges the community with life and unites all of us. Thank you for the problems! And now let's summarize...
summarize the 2018th year. #### Partner Events We are pleased to hold programming competitions with

Full text and comments »

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

65.
By Sharon, history, 8 years ago, In English
Grandmasters HATE this one weird trick!!! Top ten tips to speed up your program (NUMBER THREE WILL SHOCK YOU!!) It is currently 12:00AM, March 32nd. I was digging through the deep web and I found out about a couple tricks that legendary grandmasters have been using on this website for ages, though it was kept secret from the rest of humanity. These tricks are too dangerous for dangerous people to know (Kim Jong Un if you are reading this please stop). However, I am personally sick of the inequality and I think it is time to let the world know the secrets to make your programs run super fast. Trick 1: The O(N) to O(1) trick. Consider [this problem](http://codeforces.me/problemset/problem/955/C). The bounds are clearly too large for an O(N) solution (looping from L to R). However, what if I told you that you could easily modify your O(N) code to make it O(1)? Consider this piece of code: ~~~~~ long sum = 0; for(long i = 0; i < N; i++){ sum += i; } ~~~~~ We can clearly see that for large N, such as 10^18, the program will take a long time to run. BUT!!! We can turn every...
Grandmasters HATE this one weird trick!!! Top ten tips to speed up your program (NUMBER THREE WILL, : The O(N) to O(1) trick. Consider [this problem](http://codeforces.me/problemset/problem/955/C, Trick 2: Thread.Sleep, a trick for the Java folks that are sick and tired of C ++'s supremacy.

Full text and comments »

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

66.
By Geothermal, history, 3 years ago, In English
I'm Geothermal. AMA! After reaching 3200 in yesterday's contest, now feels like as good a time as any to hop on this bandwagon. Feel free to ask questions in the comments and I'll respond to as many as I can. A few sidenotes: ### Thoughts on Practicing In my streams, by far the most common questions I receive are variants of "how can I improve at competitive programming?" I'm happy to offer advice if people have specific questions about training related to their particular circumstances, but I wanted to write down some general thoughts so that I can redirect people who ask about general practice strategies (in this AMA or in my future streams) to this post. I endorse most of the advice given [at this link](https://github.com/Errichto/youtube/wiki/How-to-practice%3F). In short, I recommend solving problems around or slightly above your skill level (I like to go to [clist.by](https://clist.by/problems/) and choose Codeforces problems with luck between around 25% and 75%). If you run out of id...
just getting started, you should learn the basics of programming--in C++, this includes things like

Full text and comments »

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

67.
By Baba, history, 6 years ago, In English
Indian Programming Camp 2020 Hi Everyone, I'm delighted to announce that we will be hosting Indian Programming Camp (IPC) &mdash; 2020 edition online from **November 20th &mdash; November 22nd**. The camp has **no charges** and anyone can **register** and attend. In the past, the IPC camp used to be conducted offline and was mainly targetted towards experienced IOI and ICPC aspirants. You can take a look at the [IPC 2016](https://www.youtube.com/playlist?list=PLi0ZM-RCX5nsTc2Z6woHr5qoF6n3b-thO) and [IPC 2017](https://www.youtube.com/playlist?list=PLi0ZM-RCX5nvImim3_ilsdLOtDDkOWt-X) playlists to get an idea of the format. This year, we are introducing three different tracks &mdash; Div3/Div2/Div1, catering to Beginner/Intermediate/Advanced programmers. Event: **Indian Programming Camp 2020** Dates: **November 20th &mdash; November 22nd, 2020** Platform: **[YouTube](youtube.com)** and **[Unacademy](https://unacademy.com/goal/competitive-programming/LEARNCP)** Tracks: **Div1/Div...
Indian Programming Camp 2020, -p-c-advanced-track **Div2:** https://unacademy.com/a/i-p-c-intermediate-track **Div3, Hi Everyone, I'm delighted to announce that we will be hosting Indian Programming Camp (IPC

Full text and comments »

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

68.
By Proof_by_QED, 15 months ago, In English
EPIC Institute of Technology Round Summer 2025 (Codeforces Round 1036, Div. 1 + Div. 2) # Hello Codeforces Once Again <img alt="" src="https://codeforces.me/predownloaded/4e/71/4e713a365fc86888c808b3b56d6fecfb529973e6.png" style="float:right; height: 154px; padding-left: 35px; padding-right: 73px; padding-top: 41px; padding-bottom: 33px;"/> After months of hard work, [user:cry,2025-07-01], [user:Lilypad,2025-07-01] and I are extremely proud to welcome you to participate in [contest:2124] at [contest_time:2124]. This round is combined for Division 1 and Division 2, and it will be rated for everyone. You will be given $3$ hours to solve $9$ problems. One problem will be split into two subtasks. We would like to thank the following people for making the contest possible: - [user:satyam343,2025-07-01] for outstanding coordination, working tirelessly with us to improve problem quality and donating his own problems to us. I cannot thank him enough. - [user:Error_Yuan,2025-07-01] for proposing some ideas that weren't used in the end. - [user:Benq,2025-07-01...
: center;">C D

Full text and comments »

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

69.
By dario2994, 6 years ago, In English
About Problemsetting (for AtCoder and Codeforces) Since the amount of information available about the preparation of a competitive programming contest for AtCoder/Codeforces is very little, I decided to collect here what was my experience. I will try to both describe my experiences and give some general advice to wannabe problemsetters. I hope that this will be useful to future problemsetters who are "out of the loop". Moreover, participants might be curious to know what happens behind the scenes (and maybe the platforms may consider this as a form of constructive feedback). *Acronyms*: - AGC = Atcoder Grand Contest - GR = Codeforces Global Round ### Why I know something about problemsetting? I am in the competitive programming world since ~8 years: I have participated in IOI/ICPC/GCJ and a number of contests on AtCoder/Codeforces (and lately Codechef). I am not a top participant but, being in this world for so long, I know, more or less, all the standard tricks. Recently, I was the author of the *flagship conte...
Since the amount of information available about the preparation of a competitive programming

Full text and comments »

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

70.
By Geothermal, history, 3 years ago, In English
A Highly Experimental Training Plan for Beginners Very loosely inspired by some comments on [Thoughts on Reaching Cyan?](https://codeforces.me/blog/entry/101561) and [my recent AMA](https://codeforces.me/blog/entry/118845). Until now, I've avoided telling beginners to practice math before working on competitive programing problems because I haven't figured out a helpful way of doing so. This post is my attempt at telling grays to train math first in a way that might lead to improvement without an absurd time commitment. ## Introduction This section is largely motivation for why I'm proposing this training plan. If you just want to see the instructions for the training plan I'm proposing, you can skip this part. The first subsection in particular is not especially relevant to the rest of the post, but I wanted to have some documentation explaining why I still think the traditional "just solve problems" advice is good. ### The Conventional Advice on Improvement I'm frequently asked for advice on how to improve at co...
competitive programming. Typically, I tell people to focus on solving problems and learning from the

Full text and comments »

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

71.
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...
Duality in linear programming. Part 2 — in competitive programming, $$\begin{gather} \max\limits_x & c^\top x & \color{red}{\text{(maximization)}} & \overset{\text, $$\begin{gather} \max\limits_{x,y,z} & c^\top x + d^\top y + f^\top z & \overset{\text{dual}}{\iff, The optimal solution to the dual problem can be found in $O(\log C)$ with ternary search

Full text and comments »

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

72.
By alireza_kaviani, 10 months ago, In English
Repovive Opening Contest Hello everyone, We at Repovive are hosting our opening contest! Repovive is a new platform that aims to fill some of the gaps in access to high-quality competitive programming and CS education, especially for students who don’t have many local opportunities. Everything on Repovive is free, and our goal is to help improve the quality of CS education worldwide. Our opening contest will be held on Sunday, <s>November 23rd at 14:35 UTC</s> <s>November 30th at 14:35 UTC</s> **[December 14th at 14:35 UTC](https://www.timeanddate.com/worldclock/fixedtime.html?day=07&month=12&year=2025&hour=14&min=35&sec=0)**, in a Codeforces-style Div. 1 + Div. 2 format. Everyone is welcome to participate! Register at: https://repovive.com/contests Problem setters: [user:AmShZ,2025-11-16], [user:Muhammad-Ahmad,2025-11-16], [user:M.ZeeshanRashid,2025-11-16], [user:Muhammad-Saram,2025-11-16], [user:Amirrzwm,2025-11-16], [user:Kaleem_Raza_Syed,2025-11-16], [user:Shayan,2025-11-16], [user:Ghulam_Jun...
of the gaps in access to high-quality competitive programming and CS education, especially for

Full text and comments »

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

73.
By KAN, 9 years ago, translation, In English
VK Cup 2017 — Wild-card раунд 1 Hi all! Tomorrow, on [April 5th 2017, at 15:35 UTC](https://www.timeanddate.com/worldclock/fixedtime.html?msg=VK+Cup+Wild-card+Round+1&iso=20170405T1835&p1=166&ah=2) the first Wild-card Round of VK Cup 2017 will be held. Along with it there will be parallel unofficial round in which everyone can take part. The rounds will use **special rules, the rounds will be unrated.** The problems were prepared by Codeforces team. The detailed rules will be added to this post 30 minutes before the rounds. I can say now that there will be 24-hours open hacks phase after the round, like in Codeforces Educational Rounds. **Round rules:** The round will be almost usual contest with ACM ICPC rules. There will be 12 problems for 2 hours. During the round your solutions will be tested on some basic tests, they should be much stronger than usual pretests. After the round you will have 24 hours to find tests against other participants’ solutions, this part is the same as in Educational round...
You should submit each problem in a unique programming language. Different compilers of same

Full text and comments »

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

74.
By Errichto, 10 years ago, In English
How to stress test two programs millions times? Help Both a participant and a contest organizer sometimes wants to stress test their solution with the brute force. Sometimes random tests are quite weak and one needs many thousands (and sometimes millions) of them to become sure about the correctness. The thing is that running a program is quite slow itself, what may hurt if the computation part is fast. On my laptop running a C++ program with empty main() one thousand times takes 1.3s, what doesn't satisfy me. How to make it faster? I recently prepared a problem with a binary grid (SRM 699, div1-hard TwoSquares) and I wanted to be very careful about the correctness. I wrote slow solutions in C++ and the intended one in Java. Only then I realized how slow usual stress testing is. If they all were in one language, I would quite easily get everything into one program with classes (structs) and I would just run it once, without any overheads. But since the languages were different, I had to rewrite one solution, what not only requ...
slow itself, what may hurt if the computation part is fast. On my laptop running aC++ program with, Does running a program on Windows take the similar amount of time? Is it possible to run aprogram

Full text and comments »

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

75.
By purplesyringa, history, 2 years ago, In English
We teach wrong When I was a child, I knew software development well (though not much of C++), and my parents motivated me to try out competitive programming. The first thing I tried was dkirienko's section. In the first 20 minutes, GCD and the Euclidian algorithm were explained, the complexity of the Euclidian algorithm was proven, and that was pretty much it. We were then asked to solve a problem set on Codeforces individually. I didn't understand much from the complexity proof, couldn't solve a single problem, failed to figure out what I was supposed to do, and left crying. So yeah, stuff like that doesn't work. I understood simpler topics, though. I knew basic math, like how to solve linear systems and quadratic equations, and could make simple observations, so the school stage of ROI was quite easy to get through. (The hardest part was to explain to my then-informatics teacher that yes, I want the adult problems.) During the municipal stage, I had 3 hours to solve what I'd classify as a 5-t...
When I was a child, I knew software development well (though not much of C++), and my parents

Full text and comments »

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

76.
By Endagorion, 11 years ago, In English
Codeforces Round #300 Editorial (+challenges) As usual, a challenge comes with every problem. I tried not to repeat the mistakes of my previous editorials and made sure that all challenges have a solution =) (except for the _italics_ parts that are open questions, at least for me). Go ahead and discuss them in the comments! General questions about problems and clarification requests are welcomed too. **UPD**: I added codes of my solutions for all the problems. I didn't try to make them readable, but I believe most part of them should be clear. Feel free to ask questions. [problem:538A] Let me first clarify the statement (I really wish I didn't have to do that but it seems many participants had trouble with the correct understanding). You had to erase exactly one substring from the given string so that the rest part would form the word `CODEFORCES`. The (somewhat vague) wording `some substring` in the English translation may be the case many people thought that many substrings can be erased; still, it is beyond my understa...
$\displaystyle O(n^c l^{o(1)})$, for example?)_, }$; they are _fixed_ from now on. One more important fixed value is $s_l = s$. In any correctprogram

Full text and comments »

Tutorial of Codeforces Round 300
  • Vote: I like it
  • +312
  • Vote: I do not like it

77.
By MikeMirzayanov, 8 years ago, In English
Experiment: teaching programming from the scratch via problems Hey. Last week I started the experiment. I believe in semi-automated learning of programming through problem solving. There are clear advantages of this approach: independence of practice from the teacher, good testing of solutions, clear milestones for students, ability of the approach to scale. The fundamentals of programming in this sense are quite good: it is easy to prepare problems, there is a clear learning plan, and student progress is well understood. Surely some structured courses for learning the language from scratch already exist. But why not do it exactly the way I like it? IMHO, a set of problems is crucial here. The devil in the details: increase in the level of problems complexity, diversity, lack of requirements in mathematical preparation, and so on. I have teaching experience (OMG, almost 20 years!), some teaching materials from my work with students of Saratov University and the desire to try! So, experiment. Since February 20, a wonderful girl [use...
Experiment: teaching programming from the scratch via problems, basics of C ++ from scratch under my supervision and guidance. We agreed that she captures her, Hey. Last week I started the experiment. I believe in semi-automated learning of programming

Full text and comments »

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

78.
By yummy, 2 years ago, In English
OpenAI o1 IOI submissions Hi Codeforces! I am a member of the reasoning team at OpenAI. We are especially excited to see your interest in the OpenAI o1 model launch, many of us being Codeforces users ourselves ([user:chenmark,2024-09-17], [user:meret,2024-09-17], [user:qwerty787788,2024-09-17], among others). Given the curiosity around the IOI results, we wanted to share the submissions that scored 362.14—above the gold medal threshold—from the [research blog post](https://openai.com/index/learning-to-reason-with-llms/) with you. These were the highest scoring among 10,000 submissions, so still a ways to go until top human performance, but we aspire to be there one day. The following C++ programs (including comments!) are written entirely by the model. Special thanks to [user:PavelKunyavskiy,2024-09-17] for maintaining the IOI mirror, which we used to check our scores. We hope you enjoy taking a look! **nile (100/100)** - [Submission](https://gist.github.com/aw31/2500acc418419e022021617170cbfc9f#file-n...
The following C++ programs (including comments!) are written entirely by the model. Special thanks

Full text and comments »

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

79.
By vaibhav1997, history, 9 years ago, In English
All the good tutorials found for Competitive Programming Here is the list of some of the good tutorials written by codeforces users :- **C++** - [C++ Tricks](http://codeforces.me/blog/entry/15643) by [user:Swift,2018-01-22] - [C++ STL: map and set](http://codeforces.me/blog/entry/9702) by [user:adamant,2018-01-24] - [C++ STL: Policy based data structures](http://codeforces.me/blog/entry/11080) by [user:adamant,2018-03-05] - [Competitive C++ Manifesto: A Style Guide](https://codeforces.me/blog/entry/64218) by [user:Swift,2019-03-04] - [Catching silly mistakes with GCC](https://codeforces.me/blog/entry/15547) by [user:andreyv,2019-03-04] - [About a general reader / writer for STL-Structures,](https://codeforces.me/blog/entry/71075) by [user:Arturgo,2020-12-20] - [Blowing up unordered_map, and how to stop getting hacked on it](https://codeforces.me/blog/entry/62393) by [user:neal,2020-12-20] - [C++ tips and tricks](https://codeforces.me/...
All the good tutorials found for Competitive Programming, Linear Algebraic Equation](http://codeforces.me/blog/entry/54111) by [user:J-C ,2018-07-21

Full text and comments »

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

80.
By Redpo, 3 years ago, In English
[C++] Some programming language tips and tricks Hello, Codeforces! Here are some language tips and tricks I have discovered that could (hopefully) help you write more concise or efficient code. Note that all of the below tips are specific to the C++ programming language and the STL library. ## Creating a `std::set` or `std::map` from sorted data in $O(n)$ time The sorted containers `set` and `map` are usually implemented as red–black trees, meaning that their `insert` operation runs in $O(\log n)$ time by default. Naturally, repeating the `insert` operation $n$ times would result in a time complexity of $O(n\log n)$. ~~~~~ vector<int> a = /* ... */; set<int> s1; for (int e : a) { s1.insert(e); } // O(n log n) ~~~~~ However, `set` and `map` also provide a constructor method, that directly constructs the data structure from a given pair of iterators. In most implementations of C++, if the data contained within the range is already sorted, the constructor instead runs in $O(n)$ time. ~~~~~ vector<int> a = /* some...
[C++] Some programming language tips and tricks, concise or efficient code. Note that all of the below tips are specific to the C++ programming

Full text and comments »

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

81.
By Dominater069, 9 months ago, In English
IICPC Global Codefest 2026 Hello! Registrations for IICPC Global Codefest 2026 are opening soon. This is the first global edition of India's largest offline competitive programming competition. **About IICPC Codefest** IICPC (Intercollegiate Informatic and Competitive Programming Camp) is an academic and industry-backed organization focused on identifying, evaluating, and nurturing high-potential students in competitive programming, algorithms, and computer science fundamentals through rigorously designed, large-scale competitive examinations and camps. We organize Codefest, a multi-stage competitive programming competition conducted across India. This year, we are opening participation to international students from 50+ countries. **The prelims is individual participation, and online for international students. The deadline for registration is 15th January, 23:59 IST**. <img src="https://i.ibb.co/bRJt7y44/codefest-banner.png" height="50"> **Competition Structure** Prelims &mdash; Janua...
edition of India's largest offline competitive programming competition. **About IICPC Codefest

Full text and comments »

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

82.
By kuviman, 9 years ago, translation, In English
Russian AI Cup 2017 — CodeWars Hey everyone! Good news &mdash; Russian AI Cup 2017 has started! This competition is being held for the sixth time, and this time, hopefully, we will make happy all the fans of the RTS game genre &mdash; you will be controlling 500 vehicles of 5 different types at once. The task is to destroy the opponent! Try yourself in creating an artificial intelligence, it's simple and fun. Go to [Russian AI Cup site](http://russianaicup.ru) and enter the battle. Good luck! ![ Russian AI Cup ](/predownloaded/4a/df/4adfe13a25f1b8a2e90e72f98d6c12f7783ce57e.jpg) [cut] &nbsp; ### What is it? **Russian AI Cup** &mdash; largest annual artificial intelligence programming contest in Russia, and third open competition for talented IT-specialists that is part of Mail.Ru Group strategy of forming and developing competitive Russian IT-industry on a global scale. Following programming languages are supported: C++, C#, Java, Pascal, Python 2, Python 3 и Ruby. Anyway, as previously, we are ...
Following programming languages are supported: C++, C#, Java, Pascal, Python 2, Python 3 и Ruby

Full text and comments »

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

83.
By awoo, history, 4 years ago, translation, In English
Educational Codeforces Round 141 [Rated for Div. 2] Hello Codeforces! On [contest_time:1783] [contest:1783] will start. Series of Educational Rounds continue being held as [Harbour.Space University](https://harbour.space/) initiative! You can read the details about the cooperation between [Harbour.Space University](https://harbour.space/) and Codeforces in the <a href="http://codeforces.me/blog/entry/51208">blog post</a>. 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 **6 or 7 problems** and **2 hours** to solve them. The problems were invented and prepared by Adilbek [user:adedalic,2023-01-07] Dalabaev, Vladimir [user:vovuh,2023-01-07] Petrov, Ivan [user:BledDest,2023-01-07] Androsov, Ma...
competitive programming competitions in general._ - _**Division C.** Designed for newcomers to the, _We are pleased to announce the second “Hello Muscat 2023” ICPC programming bootcamp, the

Full text and comments »

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

84.
By Anshul_Johri, 3 years ago, In English
C++ Debug Template! # C++ Debug Template &#x1F6E0; **Simplify variable tracking across functions and loops!** **Note:** For latest updates and a colored stderr version of this template, visit my [Github](https://github.com/Anshul-Johri-1/Debug-Template). <spoiler summary="Longer Template (std >= C++11)"> ```c++ #ifndef DEBUG_TEMPLATE_CPP #define DEBUG_TEMPLATE_CPP #include <bits/stdc++.h> // #define cerr cout namespace __DEBUG_UTIL__ { using namespace std; /* Primitive Datatypes Print */ void print(const char *x) { cerr << x; } void print(bool x) { cerr << (x ? "T" : "F"); } void print(char x) { cerr << '\'' << x << '\''; } void print(signed short int x) { cerr << x; } void print(unsigned short int x) { cerr << x; } void print(signed int x) { cerr << x; } void print(unsigned int x) { cerr << x; } void print(signed long int x) { cerr << x; } void print(unsigned long int x) { cerr << x; } void print(signed long long int x) { cerr...
C++ Debug Template!, Additionally, you can install `Competitive Programming Helper` extension from VS Code to make your

Full text and comments »

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

85.
By errorgorn, 4 years ago, In English
On "PermutationForces" Disclaimer: This blog is entirely my own opinion, please do not get mad at the authors from round 779. If you did not enjoy that round, please do not blame the authors. Personally, I felt that the authors overall did a wonderful job ([user:SPyofgame,2022-04-02]'s div 2F was honestly one of my favourite problems in 2022 so far). Last week round 779 was held, a common feedback that people seemed to be quite vocal about was that the round was "PermutationForces". ![ ](https://cdn.discordapp.com/attachments/953845613458522154/959661720647901205/unknown.png) ![ ](https://cdn.discordapp.com/attachments/953845613458522154/959661763014582282/unknown.png) ![ ](https://cdn.discordapp.com/attachments/953845613458522154/959661819516059648/unknown.png) ![ ](https://cdn.discordapp.com/attachments/953845613458522154/959664244431913030/unknown.png) If we look at the actual contest, we do see that problems B, C, D, E all contain the word permutation inside, so it is natural to think that pr...
If we look at the actual contest, we do see that problems B, C, D, E all contain the word

Full text and comments »

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

86.
By pllk, 11 years ago, In English
Programming contest book reviews There are several programming contest books, but what do they contain and how good are they? Of course, it is difficult to know before buying and reading them. In this blog post I review programming contest books that I have read. Do you know other books or have different opinions? *** - **Programming Challenges: The Programming Contest Training Manual** - URL: [http://www.programming-challenges.com/](http://www.programming-challenges.com/) - Authors: Steven Skiena & Miguel Revilla - Year: 2003 - Price (Amazon): 56.67 USD (paperback) ![Programming Challenges](http://pllk.kapsi.fi/book1.png) This is a classic book about programming contests, written more than ten years ago. The book contains 14 chapters that discuss topics such as data structures, combinatorics, dynamic programming, and computational geometry. Each chapter begins with an introduction to the topic, followed by a collection of programming tasks. A lot has happened in the world of programming conte...
Programming contest book reviews, There are several programming contest books, but what do they contain and how good are they? Of

Full text and comments »

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

87.
By cjquines, history, 9 years ago, In English
On designing a Codeforces shirt I heard about the Codeforces shirt design the day before the deadline, and I looked at the designs and they were almost all memes. I thought of making a serious design, since I am not good at memes. (I am also not good at comp prog.) Most programming shirts that I liked have nice abstract patterns based on algorithms, like the [Yandex.Algorithm 2015 shirt](http://codeforces.me/blog/entry/44549?#comment-293712). So I wanted to add a bunch of cool diagrams of algorithms. And I decided to use black, because, well, black is nice. I came up with the design of overlaying algorithms in the Codeforces logo, but I could not draw enough different diagrams, so I used three components. You can see the whole design here: #### Overall ![ ](https://i.imgur.com/mfFORa9.png) I was inspired by the typography of [Material Design](https://material.io/), as well as the [old Google Design](https://web.archive.org/web/20160207175056/https://design.google.com/). So I used [Roboto Mono](https://fo...
knowledge of encoding appears in competitive programming sometimes. For example, `c - 'a' + 'A, I was actually torn between using C++ or just pseudocode, and between using lines of disjointed, I’m sorry for using C++ code. But it’s a [majority of the code](http://codeforces.me/blog/entry

Full text and comments »

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

88.
By eatmore, history, 6 years ago, In English
My experience with Microsoft Q# Coding Contest Here I want to tell my personal opinion of the [Microsoft Q# coding contest](/blog/entry/77614). First, I'd like to thank Microsoft Quantum team for making a great contest in an unusual format. All the problems were interesting (except D problems ‒ more about them below), and I'm looking forward to similar contests in the future. However, there is a number of issues that I'd like to see discussed and hopefully fixed. The tools --------- The first problem with Q# compiler that everyone trying to use it will see is that it is SLOW. On my machine, compiling a trivial Hello World program takes about 45 seconds. This is a well known problem, reported both on [GitHub](https://github.com/microsoft/qsharp-compiler/issues/436) and even [here on Codeforces](/blog/entry/77614?#comment-642186), and frankly it's a PITA to wait so much after every fix to know if your code still compiles (or still doesn't). But this is only a tip of the iceberg. Before the contest, I decided to read the sou...
is that they "compile" Q# programs by converting them into C#. As a result, it is not possible to use

Full text and comments »

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

89.
By cerealguy, 9 years ago, In English
Announcing MemSQL Start[c]UP 3.0 MemSQL is excited to announce Start[c]UP 3.0 – the third iteration of the programming competition hosted by Codeforces with an onsite at MemSQL HQ in San Francisco, California. Start[c]UP 3.0 consists of two rounds. Round 1 is online and takes place on September 16th at [10:35 AM PST](https://www.timeanddate.com/worldclock/fixedtime.html?msg=MemSQL+Start%5Bc%5DUP+3.0+Round+1&iso=20170916T1035&p1=224&ah=2&am=30). Round 1 follows regular Codeforces rules and consists of at least 5 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 round will be 2.5 hours long, and will be rated. Round 2 takes place on September 30th at 10:30 AM PST and uses regular Codeforces rules. The complexity of the problems is higher than a regular Codeforces round, the round will be 3 hours long, and will be rated. Only people who finished in the top 500 in Round 1 can participate. T...
Announcing MemSQL Start[c]UP 3.0, MemSQL is excited to announce Start[c]UP 3.0 – the third iteration of the programming competition

Full text and comments »

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

90.
By Errichto, 3 years ago, In English
Group tutoring Hi. I offer classes for groups of 2-3 students. I teach competitive programming with a focus on problem-solving. There won't be many lectures because I can send you an article/video link instead. The lesson cycle is usually: I choose a problem, you say your thoughts and ideas, I comment on incorrect ideas, and we talk about the valid solution(s), possibly with drawings and pseudocode. In beginner groups, I might ask you to implement something, C++ or Python preferred. There's a lot of homework and you're expected to practice a few hours per week. We might spend half a lesson talking about 1-2 homework problems from last week. This is intended. We use Google Meet, shared whiteboard, and a collaborative editor Codebunk. After a lesson, you get a video recording and a codebunk with code/text history like this one https://codebunk.com/pb/3501100331621/. This allows you to copy links and code easily. There's a Discord group chat to ask questions between classes. - 1.5h les...
completely different from competitive programming and I don't mix them within one group. Interview classes, Hi. I offer classes for groups of 2-3 students. I teach competitive programming with a focus on

Full text and comments »

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

91.
By adamant, history, 4 years ago, In English
On continued fractions. Part 3: In competitive programming Hi everyone! It's been quite some time since I wrote two previous articles in the cycle: [Part 1: Introduction](https://codeforces.me/blog/entry/73655)<br> [Part 2: Properties and interpretation](https://codeforces.me/blog/entry/73687)<br> **Part 3: In competitive programming** This time I finally decided to publish something on how one can actually use continued fractions in competitive programming problems. Few months ago, I joined [CP-Algorithms](https://cp-algorithms.com/algebra/continued-fractions.html) as a collaborator. The website also underwent a major design update recently, so I decided it would be great to use this opportunity and publish my new article there, so here it is: <center><big><b><a href = "https://cp-algorithms.com/algebra/continued-fractions.html">CP-Algorithms &mdash; Continued fractions</a></b></big></center> It took me quite a while to write and I made sure to not only describe common competitive programming challenges related to contin...
On continued fractions. Part 3: In competitive programming, interpretation](https://codeforces.me/blog/entry/73687) **Part 3: In competitive programming** This

Full text and comments »

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

92.
By Al.Cash, 10 years ago, In English
Fast and furious C++ I/O For a long time I've been upset with C++ standard input/output. First of all, I heard that `fread`/`fwrite` are much faster than everything else, and it's impossible to get good times on problems with huge input or output without using those. Secondly, it's really annoying to write formatting string and ampersands in `scanf`, especially with many variables to read. Thirdly, the only way to expand I/O to custom types is by overloading `<<` and `>>` operators on streams, but they are the slowest. I tried to tackle all these issues in my implementation. Remember, that it's targeted for the common use case in programming contests, so it's not as flexible as one might wish. [The code is here](http://ideone.com/X1tP8Q) **Doesn't compile with MSVS.** I apologize in advance to everyone, who will be scrolling through this 500 lines trying to read my solutions. Also it's not advised for people without broad experience with C++ to try to understand the entirety of it (dangerous for your men...
Fast and furious C++ I/O, For a long time I've been upset with C++ standard input/output. First of all, I heard that `fread

Full text and comments »

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

93.
By Xellos, history, 5 months ago, In English
C++ quirks: variable shadowing C++ is a very permissive language. It'll let you write basically anything on the assumption that you know what you're doing... or let you shoot yourself in the foot if you don't. For example: ```cpp class C { int a; public: C(int a) : a{a} {} }; ``` It's a fairly common pattern in simple class design that's perfectly fine until it's not. The class member and constructor argument (c.arg.) have the same name. This is known as shadowing and compilers will warn you about it, though you need to use a flag `-Wshadow` that isn't included among `-Wall` or `-Wextra`. Another example of shadowing is ```cpp for(int i = 0; i < t; i++) for(int i = 0; i < n; i++) ``` which is fine if the first `i` isn't used for anything except making a loop (such as over test cases) but otherwise it's a solid source of bugs, especially if you "fix" it into `for(int j = 0; j < n; i++)`. ### How does shadowing work? First off, when can one variable shadow another? The standa...
C++ quirks: variable shadowing, /2d20123984e9479b8a56ebe0d6a51e23ad7c35b3/testlib.h)-using program locally reveals quite a lot of warnings about shadow variables

Full text and comments »

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

94.
By brunomont, 4 months ago, In English
Chinese Postman Problem: How I Ran a 180 km Ultramarathon Through Every Street in My City Hello, Codeforces! A couple of years ago, a friend of mine told me that two cyclists had passed through every single street in the center region of the city I live in (Belo Horizonte, southeastern Brazil), on the [third try](https://www.strava.com/activities/1030665876/overview). <spoiler summary="First try"> After ~160 km, they had not completed 1/3 of the goal. [Strava link](https://www.strava.com/activities/976021527). <img src="/predownloaded/8a/53/8a53829f7d78e88808a3ff751b64406ec2fc0efd.png" style="width: 600.0px;max-width: 100.0%;max-height: 100.0%;"> </spoiler> <spoiler summary="Second try"> They were better prepared, but one of the guys was run over by a car (no big injuries). [Strava link](https://www.strava.com/activities/999450285). <img src="/predownloaded/85/8f/858fdcdcfda93cd1d9c7c59db7dbfad9e63d6ea2.png" style="width: 600.0px;max-width: 100.0%;max-height: 100.0%;"> </spoiler> <center> <img src="/predownloaded/8d/5c/8d5cfb677a361654105e49f36f214c35...
simple. We define the **cost** $c$ of the closed walk as the sum of the weights of the edges in

Full text and comments »

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

95.
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...
$ artificial variables with infinite cost, since that is what we did in the linearprogram. - We

Full text and comments »

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

96.
By EnDeRBeaT, 23 months ago, In English
Tutorial: Stealing the coolest debug feature from Rust # Introduction Rust is a quite popular programming language with a lot of different takes on how to write good code. Some people use it in competitive programming with varying success, but in general, C++ is the king. That doesn't mean that we can't take great ideas from this language, and one of Rust's shining jewels is it's macro system. Describing why it is better than "find and replace" thing we have in C++ is not the topic of this blog. We are here to steal from Rust, and today we will steal one of the coolest utilities for a competitive programmer: `dbg!` macro! # dbg! The `dbg!` macro in Rust has simple functionality: it evaluates the expression, prints it's to `stderr` and **returns it**. Last part is very, **very** useful, and you will see why. Example: ~~~~~ let a = 2; let b = dbg!(a * 2) + 1; // ^-- prints: [src/main.rs:2:9] a * 2 = 4 assert_eq!(b, 5); ~~~~~ Look, we evaluated `a * 2` mid expression and `b` still became `5`. Isn't that cool? ...
code. Some people use it in competitive programming with varying success, but in general,C++ is the

Full text and comments »

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

97.
By TheScrasse, history, 4 years ago, In English
Thoughts on Coaching Grays? Hello everyone, I'm asking for some help about how to train my schoolmates for Regional OI. Most of them have a fairly good MO background, so they are supposed to get good even if they don't practice at home (i.e., I think the $2$ hours a week at school should be enough to qualify to National OI). However, the results so far are quite disappointing: I feel I'm doing something really wrong. #### Format of Regional OI The statements are [here](https://territoriali.olinfo.it/) (requires registration). Each year, there are usually - $2$ easy problems (let's say A, B); - $1$ standard DP with a twist (C); - $1$ standard graph problem with a twist (D). A < B < C < D (in order of difficulty and points). They are similar to Div. 3 C, D, E, F. Solving A and C is enough to go to National OI. #### Schedule of this year The training started in October 2021. - October \- November: introduction to C++ and STL (in the [CPH](https://cses.fi/book/book.pdf), they correspond to c...
- October \- November: introduction to C++ and STL (in the [CPH](https://cses.fi/book/book.pdf

Full text and comments »

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

98.
By galen_colin, 2 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...
(c) [My opinion on how to practice competitive programming ](https://codeforces.me/blog/entry/91114

Full text and comments »

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

99.
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...
sub-areas of it are programming from examples (synthesizing a program from few input/output examples

Full text and comments »

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

100.
By brunomont, 3 months ago, In English
Introducing tgen: a testcase generation library <center> <img src="/predownloaded/72/82/7282f22a0748c711b1964af0315893578b0d32d5.png" style="width: 350.0px;max-width: 100.0%;max-height: 100.0%;"> <br> <i>Testcase generation for random inputs.</i> </center> Hello, Codeforces! Here I introduce **tgen**, a single-header C++ library (similar to [jngen](https://codeforces.me/blog/entry/53081)) for generating random and adversarial testcases for competitive programming problems. <center style="margin: 2em;"> <a href="https://github.com/brunomaletta/tgen" style=" display: inline-block; text-decoration: none; font-size: 18px; font-weight: 600; color: #000; background: #99ccff; padding: 0.75em 1.5em; border: 2px solid #000; border-radius: 8px; box-shadow: 2px 2px 0 #000; transition: all 0.15s ease; " > Open tgen on GitHub </a> <br><br> <a href="https://github.com/brunomaletta/tgen/blob/main/single_include/tgen.h"> ...
Here I introduce **tgen**, a single-header C++ library (similar to [jngen](https://codeforces.com

Full text and comments »

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

101.
By gabrielwu, history, 5 years ago, In English
[Tutorial] Expected number of coin flips required to achieve a given string (You can find a slightly different version of this article, tailored more for a non-CP audience, on my [website](https://gabrieldwu.github.io/flipping-coins).) Thank you to [user:smax,2022-01-07] for his feedback on this post. *Prerequisites:* - expected value, linearity of expectation - basic linear algebra - familiarity with string algorithms such as KMP (only in certain sections) <h2> The Problem </h2> Say you're given a string of coin flips, such as **HTTH** or **TTTHHT**. What is the expected number of times you must flip a coin until you encounter that string? A common initial (incorrect) intuition about this problem is that all strings of length $n$ should have the same answer -- something like $2^n$. We sense that there should be some sort of symmetry between heads and tails, so it feels odd that **HHHH** should appear any earlier or later than **HTHT**. But in this case, our intuition is simply wrong. It is true that the answer will always be on the order o...
It turns out that we can generate all four of these arrays in linear time using dynamicprogramming

Full text and comments »

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

102.
By Geothermal, history, 22 months ago, In English
2024 ICPC North America South Regional On November 16th starting at [1:30 PM US Eastern Time](https://www.timeanddate.com/worldclock/fixedtime.html?msg=2024+ICPC+North+America+South+Regional&iso=20241116T1330&p1=867&ah=5), the 2024 ICPC North America South Regional will take place. This year, [user:galen_colin,2024-11-16] and I will host the official contest broadcast, starting shortly before the beginning of the contest, on the [ICPC Live YouTube channel](https://www.youtube.com/watch?v=pd2HVL-GlnQ). During the stream, we'll * Follow the scoreboard and discuss the contest * Discuss the problems and possibly solve a few of them (though unlike some of my past personal ICPC streams, solving problems and competing for the highest score will not be the main goal of the stream) * Talk about the teams competing to advance to the 2025 ICPC North America Championship * In keeping with recent tradition, I'm hoping to share some fun facts about the competing teams. If you're the contestant or coach of a competing team and ...
meant for teams with competitive programming experience and will decide the teams advancing to NAC

Full text and comments »

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

103.
By neal, 8 years ago, In English
Blowing up unordered_map, and how to stop getting hacked on it C++ has always had the convenient data structures `std::set` and `std::map`, which are tree data structures whose operations take $O(\log n)$ time. With C++11, we finally received a hash set and hash map in `std::unordered_set` and `std::unordered_map`. Unfortunately, I've seen a lot of people on Codeforces get hacked or fail system tests when using these. In this post I'll explain how it's possible to break these data structures and what you can do in order to continue using your favorite hash maps without worrying about being hacked [cut] . So how are they hackable? We always assume hash maps are $O(1)$ per operation (insert, erase, access, etc.). But this depends on a key assumption, which is that each item _only runs into $O(1)$ collisions on average_. If our input data is completely random, this is a reasonable assumption. But this is no longer a safe bet when the input isn't random, especially so if someone is adversarially designing inputs to our code (a.k.a. hacking ph...
C++ has always had the convenient data structures `std::set` and `std::map`, which are tree data

Full text and comments »

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

104.
By Noble_Mushtak, history, 4 years ago, In English
Every Technique and Algorithm I Used to Become Grandmaster Hi everyone, I became grandmaster today so I decided to go down memory lane and review every problem I have ever done in a CodeForces contest to look back and see every technique and algorithm I had to use to become a grandmaster. I am not sure how useful this is, I mostly think it's fun to look at all the old solutions I wrote and how different it was from how I write code now. The main takeaway is that, as many people have said before, you don't need to know or memorize a bunch of advanced algorithms to become grandmaster. As you will see, there are many problems where I just used "ad hoc reasoning," meaning there's not a standard technique I used to solve the problem and you just need to make some clever mathematical observations to solve the problem. Also, there are many popular algorithms that I have never needed in a CodeForces contest despite being a grandmaster: - Sparse tables, Fenwick trees, and segment trees - String algos, like rolling hashes, Knuth-Morris-Pratt, suffix...
- [Problem C](https://codeforces.me/contest/1253/submission/65182125): Sorting, prefix sums, and, maps - [Problem C](https://codeforces.me/contest/1625/submission/142480739): Dynamicprogramming, ](https://codeforces.me/contest/699/submission/19243705): Brute force - [ProblemC](https

Full text and comments »

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

105.
By AlexLuchianov, 5 years ago, In English
[Tutorial]Using Segment Trees to solve Dynamic Programming problems Both segment trees and dynamic programming are common topics in competitive programming. Sometimes, they even appear together. In this blog, we will mostly use segment trees as a black-box. As such, it is not necessary (though it is highly recommended) to know segment trees to understand this blog. Let's begin. ###Longest Increasing Subsequence(LIS) _"You are given an array $v$ containing $N$ integers. Your task is to determine the longest increasing subsequence in the array, i.e., the longest subsequence where every element is larger than the previous one._ _A subsequence is a sequence that can be derived from the array by deleting some elements without changing the order of the remaining elements."_ This problem is most often solved using binary search. There are countless tutorials about this method, so I will not discuss it in detail. However, there exists a more general way to solve it using segment trees. Since we only care about the order of the elements and not a...
[Tutorial]Using Segment Trees to solve Dynamic Programming problems, Both segment trees and dynamic programming are common topics in competitive programming. Sometimes, This problem actually appeared in the past [here](https://codeforces.me/contest/597/problem/C) on

Full text and comments »

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

106.
By ToxicPie9, 4 years ago, In English
[Tutorial/Parody Post] Common Mistakes in Competitive Programming and How to Avoid Them Yesterday [user:YouKn0wWho,2023-01-11] posted a [blog](https://codeforces.me/blog/entry/111217) explaining common mistakes in competitive programming and how to avoid them. I was greatly inspired by that post so I decided to make my own. I have compiled some of the mistakes that I didn't make in my early Competitive Programming phase. I also mentioned how to avoid them. Also, in most cases, I will give you a chance to find out what the bug is before I reveal the culprit as I tried to make this blog interactive. The codes that I have used in this blog have been written in Rust as it is the most beloved language for CP. #### Mistake 1 Check out the following code: <spoiler summary="Code"> ``` fn main() { let x: i32 = 1_000_000_000; let y: i32 = 1_000_000_000; println!("{}", x * y); } ``` </spoiler> The output should be $10^{18}$. But if you run the code, you will get a different output. Why? <spoiler summary="Reason"> Because it won't even compile....
[Tutorial/Parody Post] Common Mistakes in Competitive Programming and How to Avoid Them, languages like C++.

Full text and comments »

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

107.
By ahmed_aly, 14 years ago, In English
Some Statistics About Codeforces 1- The maximum number of successful hacks made by the same user in the same contest is 39, made by [user:Kenny_HORROR,2012-07-30] in [contest:65]: [standings:65] 1st place. 2- The maximum number of unsuccessful submissions before getting a problem accept in a contests is 81, made by [user:shahbox,2012-07-30] in [contest:47]: [standings](http://codeforces.me/contest/47/standings/page/6) 518th place. 3- The user who solved the maximum number of problems during all Codeforces contests is [user:Egor,2012-07-30], he solved 453 problems. 4- The user who made the maximum number of successful hacks during all Codeforces contests is [user:Egor,2012-07-30] again, he made 358 successful hacks. 5- The user who participated in the maximum number of Codeforces contests is [user:PAG,2012-07-30], he/she participated in 130 contests. 6- The maximum number of unsuccessful hacks made by the same user in the same contest is 150, made by [user:dragan224,2012-07-30] in [contest:155]: [standi...
8- The user who used the maximum number of different programming languages during Codeforces

Full text and comments »

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

108.
By galen_colin, 6 years ago, In English
Community-prepared testing rounds Since the two failures of the contests last weekend, a lot of people have expressed that they want to help Codeforces in some way, but there isn't much many of us can actually do about the system. At the same time, there have also been a lot of (reasonable) requests for a testing round before round 656. So let's put those two together. Why don't we set some potential testing rounds? Maybe they should be rated, maybe they shouldn't, but in any case, they should be interesting enough to draw in participants like normal rounds do. It's probably not a good idea to "sacrifice" rounds not rated for Div. 1, as some have suggested, because that still wastes the efforts of the setters. So what I'm suggesting is that we prepare rounds with the specific intent of them being testing rounds. Some advantages of this system: - If these rounds are unrated, there's much less pressure for original/novel problems (and probably fewer problems will be rejected), so more of these rounds will be able t...
If you really want to put load on the queue, you can stall your program until it gets close to 15

Full text and comments »

Announcement of Testing Round #XVII
  • Vote: I like it
  • +257
  • Vote: I do not like it

109.
By Michael, history, 10 years ago, translation, In English
Data Structures and Algorithms Specialization at Coursera [fully launched] Last year we've won in Request for Proposals from Coursera, and this year we've launched the [Data Structures and Algorithms Specialization at Coursera](https://goo.gl/bpJ1KC). It is now the main option for studying algorithms and data structures on the platform. Specialization is a series of courses ending with a Capston Project which enables to learn the subject much deeper than it is usually possible in the scope of a massive online course. The Specialization is launched by [University of California, San Diego](https://ucsd.edu) (Computer Science program ranked 11-th in the world) and the [Computer Science Department of Higher School of Economics](https://cs.hse.ru/en/): 1. Daniel Kane &mdash; Professor at [UCSD](https://ucsd.edu), Harvard graduate, PhD from MIT, four times Putnam fellow (US mathematical olympiad for university students), and there is even a [wikipedia article](https://goo.gl/vmFuJy) about him. 2. Pavel Pevzner &mdash; Professor at [UCSD](https://ucsd.edu), l...
**UPD.2** You can submit problems in one of the following programming languages: C, C++, Java

Full text and comments »

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

110.
By SlavicG, history, 3 years ago, In English
EGOI 2024 Call for Problems Hello Codeforces! We are looking for problems for the European Girls' Olympiad in Informatics (EGOI) 2024. The contest will be held in Eindhoven, The Netherlands, 21-27 July 2024. The submission deadline is **Sunday, 14 January 2024**. Details about the problem proposal process can also be found [here](https://egoi2024.nl/index.php/call-for-problems/). <spoiler summary="Details about the submission process"> We are looking for problems of varying difficulties and types (batch, output-only or interactive). To get an idea of style and difficulty, see the problems from the [previous three years](https://stats.egoi.org/tasks/). The problems should be original and should not have been seen by any potential EGOI 2024 contestants. The topics and techniques used must conform to the [IOI syllabus](https://ioinformatics.org/page/syllabus/12). #### Acceptance Criteria Any problem submitted to EGOI 2024 must consider the following criteria to be considered for acceptance: ...
- Solution sketches should be provided in C++, Python, or any other major programming language

Full text and comments »

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

111.
By -XraY-, history, 14 months ago, In English
Order Capital Intro <img alt="Order Capital" src="/predownloaded/00/3e/003eef1043e9506ad4620583c5be192631830899.png" style="float:right;height: 200px; margin: 10px; max-width:40%;"/> Hello everyone! I invite you to take part in [contest:2122]. My name is Igor Pyshkin. Throughout my academic career, I participated in a lot of programming and math competitions: I am the 2016 ACM ICPC World Champion and competed in the onsite finals of the Facebook Hacker Cup, Google Code Jam, and TopCoder Open. After completing my degree, I transitioned into a new field — high-frequency trading (HFT). Four years ago, I founded my own HFT fund — [Order Capital](https://ordercapital.com/). Since then together with my colleagues I have been working really hard to reach the highest levels of the HFT industry. Launching this contest on Codeforces is quite special to me, as it is our first contest on the platform as a company. I would like to thank the Codeforces team and everyone involved in the round preparation...
participated in a lot of programming and math competitions: I am the 2016 ACM ICPC World Champion and

Full text and comments »

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

112.
By SuperJ6, 3 years ago, In English
How to Effectively Practice CP + Problem Solving Guide This is a slight tweak of [a practice guide](https://www.reddit.com/r/usaco/comments/pk3tjp/the_ultimate_usaco_practice_method/) I wrote a while ago on USACO reddit since I thought it could be helpful to people here. Some USACO specific sections or extra clutter I left out here that aren't needed for a general audience. This should cover all general cp advice I have so I never have to retype. #Introduction This is a post on how I believe is the best method to practice modern day competitive programming based on my experiences. I assume you already have some knowledge and know simple things like binary search and dfs/bfs, but **read the footnote if you are complete beginner** (never code, solved <50 problems, div2 A/B too difficult, grey or stuck low pupil). First, a quick tl;dr of the practice strategy before a bunch of specifics and explanation: >**In short, mostly you only need to use codeforces (no matter what contest you're training for), find a rating range where you c...
know the very basics to a programming language, preferably c++ (you can use codeacademy to learn

Full text and comments »

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

113.
By kustizus, history, 22 months ago, In English
Memory Optimization When Declaring Structs in C++ In C++ programming, structs are commonly used to group related variables together. However, I realize that the **order of declaration** of struct members can have a significant impact on the **memory size** that the struct occupies. This is due to **memory alignment** in C++, which can lead to the insertion of **padding** (unused memory) between struct members. In this post, we will explore how to **arrange struct members** in a way that optimizes memory usage and minimizes unnecessary padding. What is Memory Alignment and Padding? ------------------------------------- **Memory alignment** refers to how data types are stored in memory at specific byte boundaries. On most systems, certain data types such as **int**, **long long**, **char**, and **bool** are required to be stored at memory addresses that are divisible by their respective sizes. ### For example: **int** usually requires 4-byte alignment. **long long** requires 8-byte alignment. **char** and **bool** ...
Memory Optimization When Declaring Structs in C++, In C++ programming, structs are commonly used to group related variables together. However, I

Full text and comments »

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

114.
By waipoli, history, 18 months ago, In English
How I reached GM using Generative Functions Hello, Codeforces! In this blog, having thought of nothing better, I want to tell you a story. A story about how little Chmyaaax, even before school, was forbidden to play computer games. About how, driven by a great desire to play tanks, he started making them in Scratch. About how he moved on from Scratch to Robot, and then to Turtle. From Turtle to Pascal. About how, at the age of 10, he was introduced to competitive programming. About how, after two failed Div3 contests, he quit for two years. About how, during that time, he passionately learned C++ so he could continue making computer games (which he still wasn’t allowed to play). About how he later returned, motivated by money (the story about NEAR, where you had to reach 1600 to earn cash) (to then buy a second phone and play Brawl Stars). About how, after failing, he abandoned it again and went into commercial programming (making games). And then he came back to the sacred world, failing every TST the year before l...
was introduced to competitive programming. About how, after two failed Div3 contests, he quit for

Full text and comments »

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

115.
By khatribiru, history, 10 years ago, In English
Dynamic Programming Optimizations ( Problems ) This Blog is Just the List of Problems for Dynamic Programming Optimizations.Before start read [This](http://codeforces.me/blog/entry/8219) blog. #### **1.Knuth Optimization** Read [This](https://www.quora.com/What-is-Knuths-optimization-in-dynamic-programming) article before solving Knuth optimization problems. [Problem 1](https://uva.onlinejudge.org/external/100/10003.pdf) [Problem 2](https://uva.onlinejudge.org/external/103/10304.pdf) [Problem 3](http://codeforces.me/gym/100212/attachments/download/1727/20042005-winter-petrozavodsk-camp-andrew-stankevich-contest-10-en.pdf) ( **C** ) [Problem 4](http://www.spoj.com/problems/BRKSTRNG/) [Problem 5](https://uva.onlinejudge.org/external/120/12057.pdf) [Problem 6](https://uva.onlinejudge.org/external/128/12836.pdf) #### **2. Divide and Conquer Optimization** Read [This](https://www.quora.com/What-is-divide-and-conquer-optimization-in-dynamic-programming) article before solving Divide and Conquer Optimization problems...
Dynamic Programming Optimizations ( Problems ), This Blog is Just the List of Problems for Dynamic Programming Optimizations.Before start read

Full text and comments »

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

116.
By Jrke, 7 weeks ago, In English
Indian ICPC Camp 2026 ## Greetings Codeforces! ![ ](/predownloaded/87/8c/878cceb76b9a8b056b91b757d30549c8521ae520.png) This year, that pride comes with something new: some of India's strongest competitive programming communities are stepping up to help the next generation make the same leap. IIT Roorkee, IIT BHU, IIT Delhi, IIIT Hyderabad, IIT Indore, IIT Kanpur, IIIT Delhi, IIT Hyderabad, IIT Madras, IIT Kharagpur and IIIT Bangalore will each be hosting one week of this year's camp — several of them home to teams heading to the World Finals themselves. Each host college will also conduct a class on a topic relevant to their week's contest, so you're not just solving problems set by these communities, you're learning directly from them. The people setting your problems and running your contests this year are drawn from the very communities pushing India towards the top of competitive programming. If that isn't motivation to give this camp everything you've got, we don't know what is. With that, we're...
**Q. What all programming languages are allowed?** A. The same set of languages officially allowed

Full text and comments »

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

117.
By rewhile, 18 months ago, In English
<h1>Mike, please stop ignoring your userbase</h1> **This blog will compile a list of codeforces issues along with all the times Mike has ignored complaints about them** ## 1. Unreasonable delay for viewing submissions [<a class="rated-user user-green">+973</a>] - [Submission pages on Codeforces often not loading](https://codeforces.me/blog/entry/134655) [<a class="rated-user user-green">+281</a>] by [user:jeroenodb,2025-04-04] on *October 2024* - [Unreasonable delay for viewing submissions](https://codeforces.me/blog/entry/135457) [<a class="rated-user user-green" title="Green 392">+392</a>] by [user:djm03178,2025-04-04] on *October 2024* - [Please, give us proper explanations about this nonsense.](https://codeforces.me/blog/entry/136830) [<a class="rated-user user-green">+300</a>] by [user:djm03178,2025-04-04] on *December 2024* No [user:MikeMirzayanov,2025-04-04] reply ## 2. Cloudflare misconfiguration [<a class="rated-user user-green">+1232</a>] Posted [CF should rename itself to Cloudflare instead of Codef...
type `c` in browser it autocompletes to `codeforces.com` instead of `chatgpt.com

Full text and comments »

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

118.
By fatalerror, history, 14 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...
Python Optimization Tricks in Competitive Programming, afterward is not necessarily faster than directly using C++. So although Python has some excellent

Full text and comments »

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

119.
By peltorator, 4 years ago, In English
[Stream] Is Rust the Future of Competitive Programming? C++ is an excellent language for competitive programming, and most of the top performers use it. However, it has many flaws. Lately, Rust is getting increasingly more popular on CodeForces. I haven't yet written a single program in Rust in my entire life, however from what I have heard about it, I feel like there is actually a possibility that in 15 years it will be the most popular CP programming language as now is C++ and as 15 years ago was Pascal (don't quote me on that). **So this Saturday, [January 21st at 11:00 AM UTC](https://www.timeanddate.com/worldclock/fixedtime.html?msg=Stream+%22Is+Rust+the+Future+of+Competitive+Programming%3F%22&iso=20230121T11&p1=136) I will be streaming and trying to solve a CodeForces round using Rust**, learning it along the way and seeking help from viewers. Additionally, we will be raising money for a great non-profit organization that helps Ukraine. More details at the beginning of the stream. [The link to the stream.](https://youtu.be/hpENt...
[Stream] Is Rust the Future of Competitive Programming?, C++ is an excellent language for competitive programming, and most of the top performers use it

Full text and comments »

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

120.
By Divine_Spark, history, 13 months ago, In English
Indian ICPC Camp 2025 Greetings Codeforces! --------------------- ![ ](/predownloaded/8e/0a/8e0a5ad523d74a538a8b6ba5feeefaaf77cc391a.png) ![ ](/predownloaded/be/46/be465cb8559948f49a8d15c132e34eb2f4a96b4a.jpeg) Indian ICPC Camp 2025, proudly sponsored by Go For Gold (powered by NST), is organized jointly by leading Indian institutes including IITs, NITs, IIITs and BITs. This camp is a continuation of last year’s massively successful edition, which saw participation from over 3000 teams across India. ## Schedule Contest window: 31 August 2025 – 19 October 2025 Contests every Sunday, 2 PM – 7 PM IST (unless otherwise mentioned via Discord/WhatsApp). First contest: 31 August 2025. Ranklist freeze after 4 hours. ## Educational Sessions Alongside contests, we’ll host topic-focused sessions by some of India’s best competitive programmers — including ICPC World Finalists and Codeforces Grandmasters. These will cover advanced algorithms, data structures, and problem-solving strategi...
**Q. What all programming languages are allowed?** A. The same set of languages officially

Full text and comments »

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

121.
By kuviman, 6 years ago, In English
AI Cup 2020 Hello everyone! [AI Cup 2020](https://russianaicup.ru/) &mdash; the annual artificial intelligence programming championship by Mail.Ru Group is already running. ![ ](https://hsto.org/webt/lc/cr/py/lccrpynunbyrcvkh1v7lxtgdhdu.jpeg) AI Cup — open artificial intelligence programming contest. Test yourself writing a game strategy! It’s simple, clear and fun! This year's theme is — RTS. We are waiting for you on [our site](https://russianaicup.ru/)! The site is already open, you can start implementing your strategies. Ninth AI Cup championship is named CodeCraft. You are to program an artificial intelligence to control a number of units, gather resources, build your settlement and attack your enemies. Your strategies will compete with each other in the Sandbox and the championship. Currently availiable programming languages: C++, C#, F#, D, Go, Java, Kotlin, Scala, Python, Rust. The Sandbox is already open. Good luck! ## Schedule - Sandbox: already open for everyone. -...
programming languages: C++, C#, F#, D, Go, Java, Kotlin, Scala, Python, Rust. The Sandbox is already open

Full text and comments »

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

122.
By nikgaevoy, 4 years ago, In English
Push-Free Segment Tree ![ ](/predownloaded/95/ad/95ad3397de22cc8b20c52a1eccc87ac0c34e76cb.jpg) Figure 1: Tiffany A pdf version of this text could be found [here](https://acm.math.spbu.ru/trains/push_free_segment_tree.pdf). Prerequisites ------------- First of all, who this article is aimed at. This article assumes you already know what a segment tree is. Have you never heard about the segment tree, the Fenwick tree (aka binary indexed tree, BIT) or the RMQ problem, you should better read about it [somewhere else](https://codeforces.me/catalog) and then come back here right after to learn a bunch of cool stuff. The model target audience is the people able to solve [this problem](https://judge.yosupo.jp/problem/range_affine_range_sum) at least in theory. But even if you can't, this article could still be helpful. However, I think this article contains some ideas that were never published before, thus making it interesting even for people who are closely familiar with different variants o...
, from the programming point of view, type; moreover, implementation-wise it makes much more sense to

Full text and comments »

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

123.
By ArshiaDadras, 22 months ago, In English
Rayan 2024 Selection Round (Div. 1 + Div. 2, Rated, Prizes!) &#128075; Salam, Codeforces! ------------------ <img src="/predownloaded/10/20/1020443c4ada8a8d0aeaa46f6dd4a34120fe8030.png" style="width: 30.0%;float: right;margin: 0 0.5em 0.5em 0.5em;max-width: 100.0%;max-height: 100.0%;"> We are thrilled to invite you to the [contest:2034]. The **Selection Round** is a rated contest for Div. 1 + Div. 2, taking place on [contest_time:2034]. The problems for this round were crafted and prepared by [user:ArshiaDadras,2024-11-19], [user:MohammadParsaElahimanesh,2024-11-19], [user:AmShZ,2024-11-19], [user:AmirrzwM,2024-11-19], and [user:Keshi,2024-11-19]. The **top 60 trusted participants** (with a maximum of three from each country) will qualify for the onsite **Final Round** in Tehran, in Spring 2025. An additional quota is reserved for the host country. Hotel accommodation, local transportation, and meals will be provided to all finalists. More details about the final contest will be available on the [Rayan](https://rayan.global/) website. ...
the problems and rejecting a big chunk of our problems for Problem C. He also contributed some

Full text and comments »

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

124.
By abdude824, history, 5 years ago, In English
Object Oriented Programming Notes(C++) OOPs are actually very simple but we can have some difficult questions on OOPs as well. We will first have short notes of theory(which can be asked in form of questions) and then shift to questions. I am refering E balaguruswamy book for this. These are short notes and may miss something, if you think something is missing please comment. Also, we would be using this track: 1. Introduction to classes and objects 2. Constructors and Destructors 3. Operator Overloading 4. Inheritance 5. Polymorphism > We will be discussing major topics here and actually difficult ones. **You must know basic OOPs**. ### Introduction <spoiler summary="C structures Vs C++ Classes"> We know structures can be used to create user-defined data types in C and C++. But then why we need classes? We can have functions, constructors, etc in structures as well but what differentiates it from classes are lack of abstraction and inheritance(And actually many other things as well). We can hide certain...
Object Oriented Programming Notes(C++), We know structures can be used to create user

Full text and comments »

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

125.
By dmkozyrev, history, 8 years ago, translation, In English
[Tutorial] Rolling hash and 8 interesting problems [Editorial] **UPD**: while I was translating this post from Russian to English, [user:dacin21,2018-07-06] wrote his post, more advanced, [link](http://codeforces.me/blog/entry/60442). I hope that my post will help beginners, but in my post more rough estimates. And in Russia we call **rolling hashes** as a **polynomial hashes**. Hello, codeforces! This blogpost is written for all those who want to understand and use polynomial hashes and learn how to apply them in solving various problems. I will briefly write the theoretical material, consider the features of the implementation and consider some problems, among them: 1. Searching all occurrences of one string of length $n$ in another string length $m$ in $O(n + m)$ time 2. Searching for the largest common substring of two strings of lengths $ n $ and $ m $ $(n \ge m) $ in $O((n+m \cdot log(n)) \cdot log(m))$ and $O(n \cdot log(m))$ time 3. Finding the lexicographically minimal cyclic shift of a string of length $ n $ in $ O(n \cdo...
unsigned 64-bit type, for example, in the type `unsigned long long` in C++, because in manyprogramming

Full text and comments »

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