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 YouKn0wWho, 5 years ago, In English
The Ultimate Topic List (with Resources, Problems and Templates) This post took $4$ years to make. And this is the most significant thing that I have ever shared in my whole life. #### Story Hi, I have been doing CP for like $4$ years and from the very beginning what I have been feeling is a need for a comprehensive topic list that will contain all sorts of topics from easy to advanced with corresponding tutorials, problem lists and templates so that I wouldn't have to look at different sites, from here to there. So what do you do when you think something is missing from the world? Yeah, you create that thing! So here I am, sharing the ultimate topic list that you will need in CP. When I say that it took me $4$ years to make it, I genuinely mean it. I have been collecting them from the inception of my CP journey and yesterday I thought that it got its almost complete shape. You may not imagine the sheer excitement hidden under each of the characters of this post. #### Payment You can pay me just by upvoting this blog and by being a bet...
have any problem attached. That's because under the attached tutorial section you will find lots of, problem attached. That's because under the attached tutorial section you will find lots of problems with

Full text and comments »

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

2.
By tourist, history, 9 years ago, translation, In English
Hello 2018 Hello 2018! If you're still thinking what to do on the eighth day of year 2018, pay attention! The first round for both divisions of the new year starts on January 8 at 17:35 Moscow time ([what about other timezones?](https://www.timeanddate.com/worldclock/fixedtime.html?msg=Hello+2018&iso=20180108T1735&p1=3396&ah=2&am=30)). Four important components of Hello 2018 will be the same as in Good Bye 2017: - Div1 + Div2 combined - 8 problems - 2 hours 30 minutes - Rated But there will also be a substantial difference: - Different problems The problems of this round have been proposed and prepared by [user:YakutovDmitriy,2018-01-06], [user:BudAlNik,2018-01-06] and myself. Thanks to everyone without whom this round wouldn't be possible as well: [user:AlexFetisov,2018-01-06], [user:Golovanov399,2018-01-08], [user:KAN,2018-01-06], [user:MikeMirzayanov,2018-01-06], [user:PavelKunyavskiy,2018-01-06], [user:qwerty787788,2018-01-06], [user:VArtem,2018-01-07], [user:winger,20...
; 1750 — 2250 — 3000 — 3500. Problem tutorial can be found [here](http, Problem tutorial can be found [here](http://codeforces.me/blog/entry/56992).

Full text and comments »

Announcement of Hello 2018
  • Vote: I like it
  • +2848
  • Vote: I do not like it

3.
By tourist, 10 years ago, translation, In English
VK Cup 2017 Round 3 + Codeforces Round #412 (Div. 1 + Div. 2) Hi everyone! The last elimination round of VK Cup 2017, Round 3, will take place on May 7 at 18:35 MSK ([check your timezone here](https://www.timeanddate.com/worldclock/fixedtime.html?msg=VK+Cup+Round+3&iso=20170507T1835&p1=352&ah=3)), along with separate Codeforces Round #412 for both divisions. All three rounds will be three hours long, and all three rounds will be rated. The contest "VK Cup 2017 — Round 3" is for teams qualified from Round 2 or Wildcard Round 2. The top 20 teams will advance to the final which will be held in July 2017 in Saint Petersburg! Huge thanks to [user:KAN,2017-05-06], [user:qwerty787788,2017-05-06], [user:PavelKunyavskiy,2017-05-06], [user:AlexFetisov,2017-05-07], [user:MikeMirzayanov,2017-05-06], and VK company for making this round possible. Codeforces will be the main character of most problems. Don't forget that it's useful to read the statements of all the problems. Good luck! As we're in year 2017, the scoring will obviously be stat...
**UPD 4.** [Tutorial](http://codeforces.me/blog/entry/51883) is now available., . [user:hieutrungle,2017-05-07] **UPD 4.** [Tutorial ](http://codeforces.me/blog/entry/51883) is now

Full text and comments »

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

4.
By zscoder, history, 7 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), decided to write an introductory tutorial on generating functions here. I am by no means an expert, I plan to split this tutorial into two parts. The first part (this post) will be an introduction to, This ends the first part of my tutorial on generating functions. The next part will focus more on, To end the first part of this tutorial, I will briefly introduce a trick to simplify combinatorial

Full text and comments »

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

5.
By parveen1981, history, 6 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...
structures](https://codeforces.me/blog/entry/89730) - [[Tutorial] 1D and 2D constant time per query, ) - [Faster Dijkstra on Special Graphs [Tutorial ]](https://codeforces.me/blog/entry/43508) - [Kőnig's, ) - [[Tutorial] Dictionary of Basic Factors — O(1) String Matching](https://codeforces.me/blog/entry, ) - [[Tutorial] How to use polygon.codeforces in problem preperation?](https://codeforces.me/blog/entry/83104, ) - [[Tutorial] Initializing Binary Indexed Trees in linear time](https://codeforces.me/blog/entry/63064, . Thank you. # Mathematics Stuff - [Number Theory in Competitive Programming [ Tutorial, /43256) - [Tutorial — \"Randomized\" DP leading to state elimination](https://codeforces.me/blog, /blog/entry/46744) - [[Tutorial] Slope Trick](https://codeforces.me/blog/entry/47821) - [Easy, /blog/entry/83170) - [[Video Tutorial] Majority Element Range Queries (Segment Tree)](https

Full text and comments »

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

6.
By platelet, 3 years ago, In English
CodeTON Round 5 (Div. 1 + Div. 2, Rated, Prizes!) **Note the unusual start time of the round.** Hello, Codeforces! Now that Gaokao is over, we are very glad to invite you to participate in [contest:1842], which will start at [contest_time:1842]. You will be given **9 problems** and **3 hours** to solve them. The round will be rated for everyone. All problems are written and prepared by [user:Gary2005,2023-06-21], [user:Asuka,2023-06-21], [user:Crying,2023-06-21], [user:sjcsjcsjc,2023-06-21], [user:MonkeyKing,2023-06-21], [user:DerekFeng,2023-06-21], [user:KbltQaQ,2023-06-21], [user:ShmilyTY,2023-06-21] and me. Statements and editorials will be available in Chinese (Simplified) after the contest. We would like to give our sincere thanks to: - [user:errorgorn,2023-06-21] for his wonderful coordination! - [user:Alexdat2000,2023-06-21] for translating problem statements. - [user:gyh20,2023-06-21], [user:wangziji,2023-06-21], [user:flowerletter,2023-06-21], [user:themoon,2023-06-21], [user:qiuzx,2023-06-21], [user:Gezh...
**UPD2: [Tutorial](https://codeforces.me/blog/entry/117606) is available.**

Full text and comments »

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

7.
By AquaMoon, 4 years ago, In English
CodeTON Round 2 Hello, Codeforces! A wonderful summer holiday! After College Entrance Examination, we are extremely delighted to invite you to our second round, [contest:1704], which will be held on [contest_time:1704]. **Note the unusual start time of the round.**You are given **8 problems** and **2.5 hours** to solve them. All problems were written and prepared by [user:Cirno_9baka,2022-07-23], [user:CoupDeGrace,2022-07-23], [user:Heltion,2022-07-23], [user:ODT,2022-07-23], [user:Yakumo_Ran,2022-07-23], [user:farmerj,2022-07-23], [user:flowerletter,2022-07-26], [user:izlyforever,2022-07-23], [user:kuangbin,2022-07-23], [user:mejiamejia,2022-07-23], [user:ugly2333,2022-07-23] and me. Task statements and editorials will also be available in Chinese (Simplified) and Chinese (Traditional) after the contest. We are sincerely thankful for the help provided by: - [user:3.141592653,2022-07-25], [user:emorgan5289,2022-07-25], [user:errorgorn,2022-07-25], [user:SevenDawns,2022-07-25], [user:pr...
**UPD2:[Tutorial](https://codeforces.me/blog/entry/105464) is available.**, **UPD3: [Simplified Chinese tutorial ](https://www.cnblogs.com/aaaaawa/p/16538468.html) is available.**, **UPD4: [Traditional Chinese tutorial ](https://hackmd.io/nSTr3Ky4SyWNyvatJOXefw?view) is available.**, -2000-2750-3500-(2250+2750)** **UPD2:[Tutorial ](https://codeforces.me/blog/entry/105464) is

Full text and comments »

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

8.
By AquaMoon, history, 5 years ago, In English
Codeforces Round #732 Hello, Codeforces! I'm glad to invite you to [contest:1545] and [contest:1546], which will be held on [contest_time:1545]. **Note the unusual start time of the round.** The round will be rated for both divisions. Each division will have **6 problems** and **2.5 hours** to solve them. There may or may not be an interactive problem, so I suggest you should read the [guide for interactive problems](https://codeforces.me/blog/entry/45307). All problems were written and prepared by [user:CoupDeGrace,2021-07-02], [user:kuangbin,2021-07-02], [user:mejiamejia,2021-07-02], [user:Heltion,2021-07-02], [user:Melacau,2021-07-02], [user:Nanako,2021-07-02], [user:GOATWU,2021-07-02], [user:Cirno_9baka,2021-07-02], [user:Suiseiseki,2021-07-02], [user:ODT,2021-07-02], [user:box,2021-07-03], [user:Ynoi,2021-07-02], [user:syh0313,2021-07-02], [user:wh0816,2021-07-02] and me. And thanks to [user:QAQAutoMaton,2021-07-02], [user:gamegame,2021-07-02], [user:starusc,2021-07-02], [user:interesting...
**UPD3**: [Tutorial](https://codeforces.me/blog/entry/92739) is available.

Full text and comments »

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

9.
By star_xingchen_c, 6 years ago, In English
Codeforces Global Round 13 Hello Codeforces! On [contest_time:1491] we will host [contest:1491]. **<img src="/predownloaded/2e/e2/2ee2f0f95f05aae6ca6f47812dae2dc2aabf277b.png" style="width: 200.0px;float: right;margin: 0 1.0em 1.0em 1.0em;max-width: 100.0%;max-height: 100.0%;">** It is the first round of a 2021 series of [Codeforces Global Rounds](https://codeforces.me/blog/entry/65002). The rounds are open and rated for everybody. The prizes for this round: - 30 best participants get a t-shirt. - 20 t-shirts are randomly distributed among those with ranks between 31 and 500, inclusive. The prizes for the 6-round series in 2021: - In each round top-100 participants get points according to the [table](https://pastebin.com/QT5sXEaT). - The final result for each participant is equal to the sum of points he gets in the four rounds he placed the highest. - The best 20 participants over all series get sweatshirts and place certificates. Thanks to XTX, which in 2021 supported the global rounds ...
**UPD2:** [Tutorial](https://codeforces.me/blog/entry/88248) published.

Full text and comments »

Announcement of Codeforces Global Round 13
  • Vote: I like it
  • +1092
  • Vote: I do not like it

10.
By -is-this-fft-, history, 5 years ago, In English
[Tutorial] Collection of little techniques #### Introduction There are a number of "small" algorithms and facts that come up again and again in problems. I feel like there I have had to explain them many times, partly because there are no blogs about them. On the other hand, writing a blog about them is also weird because there is not that much to be said. To settle these things "once and for all", I decided to write my own list about about common "small tricks" that don't really warrant a full tutorial because they can be adequately explained in a paragraph or two and there often isn't really anything to add except for padding. This blog is partly inspired by [user:adamant,2022-03-15]'s [blog](48417) from a few years ago. At first, I wanted to mimic adamant's blog structure exactly, but I found myself wanting to write longer paragraphs and using just bolded sentences as section headers got messy. Still, each section is short enough that it would not make much sense to write separate blogs about each of these things. A...
[Tutorial] Collection of little techniques, about common "small tricks" that don't really warrant a full tutorial because they can be adequately, tricks" that don't really warrant a full tutorial because they can be adequately explained in a

Full text and comments »

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

11.
By tourist, history, 10 years ago, translation, In English
VK Cup 2017 Round 3 + Codeforces Round #412 -- Tutorial Here is the tutorial of VK Cup 2017 Round 3 and Codeforces Round #412. Enjoy! <spoiler summary="Is it rated?"> [tutorial:807A] <spoiler summary="Code"> ~~~~~ n = int(input()) results = [] for i in range(n): results.append(list(map(int, input().split()))) for r in results: if r[0] != r[1]: print("rated") exit() for i in range(n): for j in range(i): if results[i][0] > results[j][0]: print("unrated") exit() print("maybe") ~~~~~ </spoiler> </spoiler> <spoiler summary="T-Shirt Hunt"> [tutorial:807B] <spoiler summary="More efficient code"> ~~~~~ #include <bits/stdc++.h> using namespace std; int main() { int p, x, y; cin >> p >> x >> y; for (int s = y; ; s++) { if (s % 50 != x % 50) { continue; } bool me = false; int i = s / 50 % 475; for (int j = 0; j < 25; j++) { i = (i * 96 + 42) % 475; if (i + 26 == p) { me = true; ...
VK Cup 2017 Round 3 + Codeforces Round #412 -- Tutorial, [tutorial:806A], [tutorial:806B], [tutorial:806C], [tutorial:806D], [tutorial:806E], [tutorial:806F], [tutorial:807A], [tutorial:807B], Here is the tutorial of VK Cup 2017 Round 3 and Codeforces Round #412. Enjoy!

Full text and comments »

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

12.
By arsijo, 7 years ago, translation, In English
Codeforces Round 591 (and Technocup — Elimination Round 1) Hi all! This weekend, on [contest_time:1223] we will hold Codeforces Round 591. It is based on problems of Technocup 2020 Elimination Round 1 that will be held at the same time. Technocup is a major olympiad for Russian-speaking high-school students, so if you fall into this category, please register at <a href="https://technocup.mail.ru/">Technocup 2020 website</a> and take part in the Elimination Round. Div. 1 and Div.2 editions are open and rated for everyone. Register and enjoy the contests! The Elimination Round authors are [user:BledDest,2019-10-06], [user:MikeMirzayanov,2019-10-06], [user:Ne0n25,2019-10-06], [user:PikMike,2019-10-06], [user:Roms,2019-10-06], [user:adedalic,2019-10-06] and me. This round would also be not possible without the help of our testers: [user:KAN,2019-10-06], [user:chemthan,2019-10-06], [user:gisp_zjz,2019-10-06], [user:Kallaseldor,2019-10-06], [user:JeffreyHo,2019-10-06], [user:danya.smelskiy,2019-10-06], [user:Juve45,2019-10-06], thank you...
Tutorial. <https://codeforces.me/blog/entry/70358>

Full text and comments »

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

13.
By Errichto, 6 years ago, In English
Matrix Exponentiation tutorial + training contest tl;dr &mdash; video tutorial https://www.youtube.com/watch?v=eMXNWcbw75E and codeforces GYM training https://codeforces.me/gym/102644 (register by finding this contest in GYM instead of using the link directly) video editorial: [part 1 (ABCDEF)](https://www.youtube.com/watch?v=kQuCOFzWoa0) and [part 2 (GHI)](https://www.youtube.com/watch?v=RA_SpxP2t54) codes to all 9 problems: https://github.com/Errichto/youtube/tree/master/matrix-exponentiation Prerequisites: binary exponentiation and iterative dp (you don't need to know matrices) The youtube tutorial ([link](https://www.youtube.com/watch?v=eMXNWcbw75E)) focuses on intuition and graph-like visualization . Or, if you prefer, below is a shorter (less detailed) text tutorial instead. You can practice by solving a set of 9 educational problems in GYM https://codeforces.me/gym/102644. ABCD are easy, EF medium, GHI are hard. If you are stuck, see hints below or watch the full solution analysis &mdash; [part 1 (ABCDEF)](https:...
Matrix Exponentiation tutorial + training contest, I hope you learned something thanks to this tutorial. Feel free to discuss problems from the GYM, The youtube tutorial ([link](https://www.youtube.com/watch?v=eMXNWcbw75E)) focuses on intuition and, tl;dr — video tutorial https://www.youtube.com/watch?v=eMXNWcbw75E and codeforces GYM

Full text and comments »

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

14.
By tourist, history, 9 years ago, translation, In English
Hello 2018 -- Tutorial Here is the tutorial of Hello 2018. Enjoy! <spoiler summary="Modular Exponentiation"> Problem writer: [user:tourist,2018-01-08] [tutorial:913A] <spoiler summary="Solution"> ~~~~~ #include <bits/stdc++.h> using namespace std; int main() { int n, m; scanf("%d %d", &n, &m); printf("%d\n", n >= 31 ? m : m % (1 << n)); return 0; } ~~~~~ </spoiler> </spoiler> <spoiler summary="Christmas Spruce"> Problem writer: [user:BudAlNik,2018-01-08] [tutorial:913B] <spoiler summary="C++ solution"> ~~~~~ #include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> p(n), deg(n); for (int i = 1; i < n; i++) { cin >> p[i]; p[i]--; deg[p[i]]++; } vector<int> sons_leaves(n); for (int i = 0; i < n; i++) { if (deg[i] == 0) { sons_leaves[p[i]]++; } } for (int i = 0; i < n; i++) { if (deg[i] > 0 && sons_leaves[i] < 3) { puts("No"); return 0; } } puts...
Hello 2018 -- Tutorial, Problem writer: [user:BudAlNik,2018-01-08] [tutorial:913B], Problem writer: [user:BudAlNik,2018-01-08] [tutorial:913E], Problem writer: [user:YakutovDmitriy,2018-01-08] [tutorial, Problem writer: [user:tourist,2018-01-08] [tutorial, Here is the tutorial of Hello 2018. Enjoy!, ] [tutorial:913F]

Full text and comments »

Tutorial of Hello 2018
  • Vote: I like it
  • +463
  • Vote: I do not like it

15.
By MikeMirzayanov, 10 years ago, translation, In English
Codeforces: summing up 2016 year <center> <img src="http://assets.codeforces.com/images/Happy-New-Year-HD-Wallpapers.jpg"/> </center> Somehow it turns out that for me, each coming the New Year means more and more. This is an excellent opportunity to take stock, to breathe fresh air and to go through a kind of catharsis. This is a rare opportunity to be with the family, dress up in Santa Claus and just have fun. Holidays give me a clear criterion that I do the right things. If during the holidays, I begin to think about it, to recall some deferred ideas, eager to implement something new. So I’m doing right things. My things. And now exactly the same as in several recent years: during New Year holidays I write code for Codeforces, trying new technology or simply I’m making minor changes in testlib. It is necessary to me: at this moment are no deadlines, do not press the obligation. Just now, at 3 am, I can not break away from being able to do something new. I would like to take a moment and realize that spun in ...

Full text and comments »

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

16.
By TheOneYouWant, history, 7 years ago, In English
Editorial — Codeforces Round #646 Hello, everyone! It was a delight for us to have you participate in our contest. We hope you enjoyed the problems! Here, we present to you the solutions of the problems. I have also prepared some memes for you to enjoy &mdash; disclaimer: not all of them were created by me. [tutorial:1363A] Author of this problem was [user:Ashishgup,2020-05-31]. <spoiler summary="Relevant Meme"> ![ ](/predownloaded/cd/f1/cdf13618b93c6243dec10ec495181286a2616caa.jpg) </spoiler> <spoiler summary="Code for A"> ~~~~~ #include <bits/stdc++.h> using namespace std; #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define endl "\n" #define int long long const int N = 2e5 + 5; int n, x; int a[N], f[2]; int32_t main() { IOS; int t; cin >> t; while(t--) { f[0] = f[1] = 0; cin >> n >> x; for(int i = 1; i <= n; i++) { cin >> a[i]; f[a[i] % 2]++; } bool flag = 0; for(int i = 1; i <= f[1] && i <= x; i ...
[tutorial:1363A], [tutorial:1363B], [tutorial:1363C], [tutorial:1363D], [tutorial:1363E], [tutorial:1363F]

Full text and comments »

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

17.
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...
[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

18.
By tourist, history, 7 years ago, In English
Codeforces Global Round 5 Editorial Enjoy! <spoiler summary="A. Balanced Rating Changes"> [tutorial:1237A] <spoiler summary="Solution by tourist"> ~~~~~ #include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; int flag = 1; for (int i = 0; i < n; i++) { int x; cin >> x; if (x % 2 == 0) { cout << x / 2 << '\n'; } else { cout << (x + flag) / 2 << '\n'; flag *= -1; } } return 0; } ~~~~~ </spoiler> </spoiler> <spoiler summary="B. Balanced Tunnel"> [tutorial:1237B] <spoiler summary="Solution by tourist"> ~~~~~ #include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector<int> a(n), b(n); for (int i = 0; i < n; i++) { cin >> a[i]; --a[i]; } for (int i = 0; i < n; i++) { cin >> b[i]; --b[i]; } vector<int> pos(n); for (int i = 0; i < n; i++) { pos[b[i...
[tutorial:1237A], [tutorial:1237B], [tutorial:1237C1], [tutorial:1237C2], [tutorial:1237D], [tutorial:1237E], [tutorial:1237F], [tutorial:1237G], [tutorial:1237H]

Full text and comments »

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

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

Full text and comments »

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

20.
By rama_pang, history, 6 years ago, In English
[Tutorial] Li Chao Tree Extended Hello everyone! I discovered a new (?) trick on how to apply lazy propagation on the Li Chao Tree and decided to write a blog about it. I've personally never seen it before (outside of myself), nor have I seen a problem that needs the Extended Li Chao Tree specifically, but it *can* overkill some problems. Of course, I might not be looking hard enough... You can learn about the basics of Li Chao Tree from [cp-algorithms](https://cp-algorithms.com/geometry/convex_hull_trick.html) or [this simple blog](https://robert1003.github.io/2020/02/06/li-chao-segment-tree.html). The Extended Li Chao Tree can do the following problems (and other variations): ## Problem 1 There is an array $A$ of size $N$. There are $Q$ online operations: - Range Line Insertion. Given $l$, $r$, $a$, $b$, do $A_i = \max(A_i, a \cdot i + b)$, $\forall i \in [l, r]$ in $O(\log^2 N)$ - Range Line Addition. Given $l$, $r$, $a$, $b$, do $A_i += a \cdot i + b$, $\forall i \in [l, r]$ in $O(\log^2 N)$. - Po...
[Tutorial] Li Chao Tree Extended, - [[Tutorial] Slope Trick](https://codeforces.me/blog/entry/47821). - [Slope trick explained

Full text and comments »

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

21.
By E869120, 8 years ago, In English
[Tutorial] A way to Practice Competitive Programming : From Rating 1000 to 2400+ Dear Codeforces community.<br /> Finally red :)<br /> <br /> Today, I want to share about some ways to practice competitive and gain your rating. I hope that this is helpful for those who is practicing competitive programming harder but rating is sluggish. There are 54,000+ people who participated in Codeforces contests actively, but sadly only a few people reach a red-ranked coders. For people who can't reach red, I will introduce my way to gain rating in some steps.<br /> <br /> This blog is an extended and more detailed version of [my previous tutorial blog](http://codeforces.me/blog/entry/53341), but 2 years and now are different. So there are many points that are different from blog which has written 2 years ago. Note: Some people who already read my previous tutorial blog may doubt, but do not doubt &mdash; I should say that the "from rating 1000 to 2000" part of this blog is not the copy of my previous blog and it's very different.<br /> <br /> Since the size is very big...
[Tutorial] A way to Practice Competitive Programming : From Rating 1000 to 2400+, The link of my blog (PDF) is as follows: [[Tutorial] A way to practice , blog is an extended and more detailed version of [my previous tutorial blog](http://codeforces.me/blog, This blog is an extended and more detailed version of [my previous tutorial blog](http

Full text and comments »

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

22.
By zscoder, history, 10 years ago, In English
[Tutorial] Non-trivial DP Tricks and Techniques Hi everyone! Today I want to share some DP tricks and techniques that I have seen from some problems. I think this will be helpful for those who just started doing DP. Sometimes the tutorials are very brief and assumes the reader already understand the technique so it will be hard for people who are new to the technique to understand it. Note : You should know how to do basic DP before reading the post DP + Bitmasks ------------------ This is actually a very well-known technique and most people should already know this. This trick is usually used when one of the variables have very small constraints that can allow exponential solutions. The classic example is applying it to solve the Travelling Salesman Problem in $O(n^{2} \cdot 2^{n})$ time. We let $dp[i][j]$ be the minimum time needed to visit the vertices in the set denoted by $i$ and ending at vertex $j$. Note that $i$ will iterate through all possible subsets of the vertices and thus the number of states is $O(2^{n} \cdo...
[Tutorial] Non-trivial DP Tricks and Techniques

Full text and comments »

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

23.
By Radewoosh, history, 8 years ago, In English
Blogewoosh #5 (with images from now) Hello, codeforces! Because after Round #507 sad men in suits visited me in my flat, this time I won't write about any task from the future. Instead, this blog will be about my own trick. I said "my own," but probably some of you have already heard about it or even figured it out, but I've developed it by myself, so I consider it as my own. In particular, it's **GEOMETRY TIME!!!**. But please, don't escape already. I also don't like this topic so much, that's why I really like this trick. Let me tell you a story from one onsite Polish contest, which took place a few months ago. I was thinking about one of the problems, and I've figured out that I had to do some binary-search (on doubles) and then check if a set of half-planes has a non-empty intersection. The answer would tell me in which direction should I turn in the binary search. Firstly, I grabbed my head, because I've never written an intersection of half-planes. I had my acm library with [user:Errichto,2018-09-07]'s code...
feels that he is really good at handling with doubles precision and wants to write sometutorial about

Full text and comments »

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

24.
By PurpleCrayon, 5 years ago, In English
[Tutorial] Simulated Annealing in Competitive Programming Hi Codeforces! I've recently noticed a lack of simulated annealing tutorials, so I decided to make one. It all started when I was trying to "cheese" [problem:1556H] after the contest. In general, simulated annealing is a pretty niche topic, but it can sometimes lend you unintended solutions for very hard problems. It's also very useful in contests like Google Hashcode, where you can add simulated annealing to an already good solution to make it a lot better. Simulated annealing's name and terms are derived from physical annealing, the process of letting metals or glass cool down and harden while removing internal stresses. An Overview ------------------ Simulated Annealing is an approximation algorithm. It's generally useful in problems with low constraints (i.e. $n \leq 50$ or $n \leq 100$) where you need to find the minimum/maximum of something over all possible states (and there are usually way too many of them to check). In general, it's good at finding the global maximum...
[Tutorial] Simulated Annealing in Competitive Programming, Thanks for reading! This was my first tutorial blog, so let me know if there's anything that should

Full text and comments »

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

25.
By Phantasmagorias, history, 5 years ago, In English
Codeforces Round #745 Editorial I'm very sorry about all the inconvenience, and I would like to bear the blame. Much thanks to those who help me prepare this round. It's not their fault. And much thanks to your participation. [problem:1581A] ------------------ idea: [user:interlude,2021-09-30] preparation: [user:CQXYM,2021-09-30] tutorial: [user:CQXYM,2021-09-30] Assume a permutation $p$, and $\sum_{i=2}^{2n}[p_{i-1}<p_i]=k$. Assume a permutaion $q$, satisfying $\forall 1 \leqslant i \leqslant 2n, q_i=2n-p_i$. We can know that $\forall 2 \leqslant i \leqslant 2n,[p_{i-1}<p_i]+[q_{i-1}<q_i]=1$. Thus,$\sum_{i=2}^{2n}[q_{i-1}<q_i]=2n-1-k$, and either $p$ should be counted or $q$ should be counted. All in all, the half of all the permutaions would be counted in the answer. Thus, the answer is $\frac{1}{2}(2n)!$. The time complexity is $O(\sum n)$. If you precalulate the factors, then the complexity will be $O(t+n)$. ----- <spoiler summary="solution"> ~~~~~ #include<stdio.h> int f[100001]; int m...
#### Tutorial by [user:CQXYM,2021-09-30], tutorial: [user:CQXYM,2021-09-30], tutorial: [user:interlude,2021-09-30]

Full text and comments »

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

26.
By RDDCCD, history, 4 years ago, In English
CodeTON Round 4 (Div. 1 + Div. 2, Rated, Prizes!) Hello, Codeforces! I'm very glad to invite you to participate in [CodeTON Round 4 (Div. 1 + Div. 2, Rated, Prizes!)](https://codeforces.me/contests/1810), which will start on [contest_time:1810].You will be given **8 problems** and **2 hours** to solve them. The round will be rated for everyone. I'd like to give my sincere thanks to: * [user:74TrAkToR,2023-03-29] for the wonderful coordination! * [user:Sulfox,2023-03-29] for the help with the statements. * [user:Suika_predator,2023-03-29], [user:SSerxhs,2023-03-29], [user:LLL_2820,2023-03-29], [user:xay5421,2023-03-29], [user:NemanjaSo2005,2023-03-29], [user:applese,2023-03-29], [user:bxhnb,2023-03-29], [user:fr200110217102,2023-03-29], [user:Sulfox,2023-03-29], [user:CCSU_DZX,2023-03-29] [user:PaperCloud,2023-03-29], [user:CedeaT0,2023-03-29], [user:Kath1031,2023-03-29], [user:jcccc,2023-03-29], [user:dyxg,2023-03-29], [user:tzc_wk,2023-03-29], [user:xiaoziya,2023-03-29], [user:qiqi20021026,2023-03-29], [user:Pointy,20...
**UPD**: The tutorial is [here](https://codeforces.me/blog/entry/114521).

Full text and comments »

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

27.
By Radewoosh, history, 8 years ago, In English
Blogewoosh #4 Hello, codeforces! It's time to continue the series of Polish tasks. I've decided to write about my own task one more time. Its name is "cook" ([you can submit here](https://szkopul.edu.pl/problemset/problem/9NFtPM59qGWa7wdn570ifuP0/site/?key=statement)). The task isn't very hard, but it uses cute (in my opinion) trick. The statement goes as follows: There is a cook in a restaurant. He has $n$ ($1 \leq n \leq 10^6$) orders which he must fill. Every order is a piece of paper, and all orders are speared on a spindle (sharp stick with pierced pieces of paper) in a fixed order which cannot be changed. Normal cook would just take orders one by one from the top of the spindle and fill them in this order, but the cook in this task has supernatural cooking powers and can combine orders to fill them faster. In particular, if at some moment there are $k$ out of $n$ orders still on the spindle, he can choose one of three options: $---$ He can take the topmost piece of paper and fill this...
Did you enjoy this blog? I wanted to choose an easier task with a shorter tutorial than the last

Full text and comments »

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

28.
By Monogon, 4 years ago, In English
[Tutorial] Supporting Priority-Queue-like Undoing on DS _Good morning!_ In this blog, I will present an online algorithm that can perform priority-queue-like undoing on a data structure, given a few assumptions. I will also present and solve a generalization of that problem. For context, I highly recommend reading this blog that shows how to solve the easier problem of queue-like undoing. That blog gave me the inspiration for the trick I will describe here, but I will still try to write this blog so that it can be understood without it. Thank you [user:Noam527,2023-01-08] for introducing such a great trick to the competitive programming community. [[Tutorial] Supporting Queue-like Undoing on DS](https://codeforces.me/blog/entry/83467) Acknowledgment ----------------- Huge thanks go to [user:peltorator,2023-02-20] for hosting a [blog contest](https://codeforces.me/blog/entry/110840). His generous prize of $300 got many people to write blogs on new, interesting ideas, and it was one of the main reasons I wrote this blog. I'm...
[Tutorial] Supporting Priority-Queue-like Undoing on DS, [[Tutorial] Supporting Queue-like Undoing on DS](https://codeforces.me/blog/entry/83467)

Full text and comments »

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

29.
By twosquares, 11 months ago, In English
Good Bye 2025 Editorial We'd like to thank you all for participating in the contest, and hope you enjoyed it. Any feedback would be appreciated! <!-- You lost the game. --> <spoiler summary="Rate the contest"> - Great contest: - Good contest: - Average contest: - Bad contest: </spoiler> --- <spoiler summary="Did Franklin (from problem D) succeed in massacring a village of innocent elves like Frieren and Dilhan (from problem E)?"> The official lore is that he got lost in a forest of oddly colored Christmas trees (from problem F) and decided instead to write this editorial. </spoiler> <!-- ########### --> <!-- #PROBLEM A# --> <!-- ########### --> <h2>[problem:2178A]</h2> <spoiler summary="Did you like the problem?"> - Great problem: - Good problem: - Average problem: - Bad problem: - Did not solve: ...
[tutorial: 2178A], [tutorial: 2178B], [tutorial: 2178C], [tutorial: 2178D], [tutorial: 2178E], [tutorial: 2178F], [tutorial: 2178G], [tutorial: 2178H], [tutorial: 2178I]

Full text and comments »

Tutorial of Good Bye 2025
Tags sus
  • Vote: I like it
  • +697
  • Vote: I do not like it

30.
By errorgorn, 6 years ago, In English
Tutorial on Permutation Tree (析合树) So my O level Chinese exam is in 2 days so I decided to learn a data structure that I can only find [resources](https://oi-wiki.org/ds/divide-combine/) for in Chinese. I thought I might as well write a tutorial in English. This data structure is called 析合树, directly translated is cut join tree, but I think permutation tree is a better name. Honestly, after learning about it, it seems like a very niche data structure with very limited uses, but anyways here is the tutorial on it. Thanks to [user:dantoh,2020-06-16] and [user:oolimry,2020-06-16] for helping me proofread. ### Motivation Consider this [problem](https://codeforces.me/contest/526/problem/F). We are given a permutation,$P$ of length $n$. A good range is a contiguous subsequence such that $\max\limits_{l \leq i \leq r} P_i - \min\limits_{l \leq i \leq r} P_i = r-l$. This can be thought of the number of contiguous subsequence such that when we sort the numbers in this subsequence, we get contiguous values. Count the...
Tutorial on Permutation Tree (析合树), a tutorial in English., with very limited uses, but anyways here is the tutorial on it.

Full text and comments »

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

31.
By zscoder, history, 7 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), Welcome to Part 2 of my tutorial on generating functions. The [first part](https://codeforces.com

Full text and comments »

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

32.
By Arpa, history, 14 months ago, In English
I Filled an Empty Codeforces Page! <div style="float: right;margin: 0 1.0em 1.0em 1.0em;text-align: center;"> <iframe allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen="" frameborder="0" height="560" src="https://www.youtube.com/embed/T9UZ21eaZJE" title="YouTube video player" width="315"></iframe> </div> <center> <be> <a href="https://algoritmiacademy.com/wp-content/uploads/2025/09/comments.png"> <img width="50%" src="https://algoritmiacademy.com/wp-content/uploads/2025/09/comments.png"> </a> <br> </center> You might wonder: what kind of _popular_ or _controversial_ topic gets **175 comments**? The answer: <center> <be> <a href="https://algoritmiacademy.com/wp-content/uploads/2025/09/content.png"> <img width="50%" src="https://algoritmiacademy.com/wp-content/uploads/2025/09/content.png"> </a> <br> </center> You are right! [Codeforces edu section &mdash; Community Course](https://codeforces.me/edu/course/3)! Most of ...

Full text and comments »

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

33.
By ATSTNG, history, 7 years ago, In English
[Tutorial] Пересечение матроидов простыми словами **[This article is also available in [English](https://codeforces.me/blog/entry/69287?locale=en)]** Привет, CodeForces. Я думаю, что матроиды &mdash; это прекрасные и очень мощные структуры, однако, не настолько хорошо известные в спортивном программировании. Я познакомился с матроидами на Зимних Петрозаводских Сборах 2019. Там была задача, которая очевидно не решалась обычными способами, известными мне тогда. Разбор этой задачи состоял буквально из трех слов “just matroid intersection”. Тогда мне потребовалось больше двух дней дорешивания чтоб найти всю необходимую информацию и детали и написать решение, которое получает Accepted. И намного больше времени мне потребовалось чтобы понять почему это действительно работает и как именно это работает. (Я до сих пор сомневаюсь в некоторых деталях.) Конечно, совершенно не трудно нагуглить все необходимые определения и статьи, связанные с этой темой, но мне кажется, что все они больше сконцентрированы на математической теории, с...
[Tutorial] Пересечение матроидов простыми словами

Full text and comments »

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