Shayan's blog

By Shayan, 5 months ago, In English

Note: The official editorial is/will be provided by the authors of the round. This text + video tutorial acts as an additional resource for those who prefer video over text, not as a substitute for the text editorial.

The text version available at: https://repovive.com/editorial/codeforces-round-1067-div-2

2158A — Suspension

Video

2158B — Split

Video

2158C — Annoying Game

Video

2158D — Palindrome Flipping

Video

2158E — Sink

Video

2158F2 — Distinct GCDs

Only text editorial available for this problem.

Full text and comments »

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

By Shayan, 5 months ago, In English

Note: The text editorial is/will be provided by the authors of the round. This video tutorial acts as an additional resource for those who prefer video over text, not as a substitute for the text editorial.

2170A — Maximum Neighborhood

Video

2170B — Addition on a Segment

Video

2170C — Quotient and Remainder

Video

2170D — Almost Roman (quick walkthrough)

Video

2170E — Binary Strings and Blocks

Video

Feel free to check out Repovive roadmaps to learn CP topics: https://repovive.com/roadmap

(All educational content on Repovive is and remains free)

Full text and comments »

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

By Shayan, 5 months ago, In English

Note: The text editorial is/will be provided by the authors of the round. This video tutorial acts as an additional resource for those who prefer video over text, not as a substitute for the text editorial.

2157A — Dungeon Equilibrium

Video

2157B — Expansion Plan 2

Video

2157C — Meximum Array 2

Video

2157D — Billion Players Game

Video

Feel free to check out Repovive roadmaps to learn CP topics: https://repovive.com/roadmap

(All educational content on Repovive is and remains free)

Full text and comments »

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

By Shayan, 5 months ago, In English

Note: The text editorials will be provided by the authors of the round. This video tutorial acts as an additional resource for those who prefer video over text, not as a substitute for the text editorial.

2171A — Shizuku Hoshikawa and Farm Legs

Video

2171B — Yuu Koito and Minimum Absolute Sum

Video

2171C1 — Renako Amaori and XOR Game (easy version)

Video

2171C2 — Renako Amaori and XOR Game (hard version)

Video

2171D — Rae Taylor and Trees (easy version)

Video

2171F — Rae Taylor and Trees (hard version)

Video

Feel free to check out Repovive roadmaps to learn CP topics: https://repovive.com/roadmap

(All educational content on Repovive is and remains free)

Full text and comments »

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

By Shayan, 6 months ago, In English

Note: The text editorials will be provided by the authors of the round. This video tutorial acts as an additional resource for those who prefer video over text, not as a substitute for the text editorial.

2164A — Sequence Game

Video

2164‌‌‌‌B — Even Modulo Pair

Video

2164C — Dungeon

Video

2164D — Copy String

Video

Also, the free bootcamp for 1200 -> 1600 rating starts from today!

Full text and comments »

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

By Shayan, history, 12 months ago, In English

Note: The text editorials will be provided by the authors of the round. This video tutorial acts as an additional resource for those who prefer video over text, not as a substitute for the text editorial.

2107A — LRC and VIP

Video

2107B — Apples in Boxes

Video

2107C — Maximum Subarray Sum

Video

2107D — Apple Tree Traversing

Video

Full text and comments »

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

By Shayan, history, 12 months ago, In English

Note: The text editorials will be provided by the authors of the round. This video tutorial acts as an additional resource for those who prefer video over text, not as a substitute for the text editorial.

2108A — Permutation Warm-Up

Video

2108B — SUMdamental Decomposition

Video

2108C — Neo's Escape

Video

2108D — Needle in a Numstack

Video

Full text and comments »

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

By Shayan, 13 months ago, In English

Note: The text editorials will be provided by the authors of the round. This video tutorial acts as an additional resource for those who prefer video over text, not as a substitute for the text editorial.

2094A — Trippi Troppi

Video

2094B — Bobritto Bandito

Video

2094C — Brr Brr Patapim

Video

2094D — Tung Tung Sahur

Video

2094E — Boneca Ambalabu

Video

2094F — Trulimero Trulicina

Video

2094G — Chimpanzini Bananini

Video

2094H — La Vaca Saturno Saturnita

Video

Full text and comments »

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

By Shayan, 13 months ago, In English

Note: The text editorials will be provided by the authors of the round. This video tutorial acts as an additional resource for those who prefer video over text, not as a substitute for the text editorial.

2093A — Ideal Generator

Video

2093B — Expensive Number

Video

2093C — Simple Repetition

Video

2093D — Skibidi Table

Video

2093E — Min Max MEX

Video

2093F — Hackers and Neural Networks

Video

2093G — Shorten the Array

Video

Full text and comments »

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

By Shayan, 13 months ago, In English

Note: The text editorials will be provided by the authors of the round. This video tutorial acts as an additional resource for those who prefer video over text, not as a substitute for the text editorial.

2085A — Serval and String Theory

Video

2085B — Serval and Final Mex

Video

2085C — Serval and The Formula

Video

2085D — Serval and Kaitenzushi Buffet

Video

2085E — Serval and Modulo

Video

Full text and comments »

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

By Shayan, 14 months ago, In English

Note: This is what I did. This is what I always tell my students. This is what I’m sharing because I believe it is very helpful for people here.

1. Are the tips I’m sharing the only way to reach Expert? No.

2. Is it the best way to reach Expert? Not necessarily, but I think so.

3. Can I leave hateful comments below? Do something more valuable lol. Write another blog explaining how you did it, or even a comment works.

4. Are you actually helping or just promoting your video? First, regardless of any benefit to me, this is valuable information for people. Second, I genuinely don’t need the promotion. 32,000 people have already watched it in a week, and this blog might add like 1,000 more, doesn’t make any noticeable difference for me.


Two types of advice

I believe advice generally falls into two types. Some advice is not controversial, so everyone agrees on it. By definition, it is ‘useless’ because it doesn’t add new knowledge. For example, telling someone to “practice” or “train hard” isn’t helpful since everyone already knows and agrees on that. It can serve as a reminder or motivation, but it doesn’t add knowledge.

On the other hand, some advice isn’t something you hear everywhere. Not everyone may agree with it. So, what I did here was share those kinds of opinions. And of course, anyone is free to agree or disagree in the comments. This is an open discussion.


Is there really a correct and incorrect way to learn competitive programming? Definitely. I’ve seen many people do it incorrectly. At the end of this blog, I’ll share experiences I’ve had with my previous students in different schools.

I’ll attach the video I've made at the end, but I’ll also summarize some of the key points for those who prefer reading.

Why am I so confident about this style? I've did it myself. As you can see in my rating graph, I went from newbie to expert in two months (March–May 2015), and after three months, I ranked 4th in a div 2 contest (still my best CP day ever). So, I confidently say that it works.

 My chart in early days


Okay, so what is it?

For example, I tell people to solve problems around their own rating. If your rating is 1200, solve many 1200-rated problems. It’s not a waste of time. Don’t jump to harder problems too soon. Many people do this, but they end up spending too much time thinking and not enough time implementing. Therefore, they become good at problem-solving but suck at implementation.

Also, don’t think too much. If you’re stuck, feel free to look at hints or solutions, that’s fine! You’re a beginner and you are building intuition. (Some people strongly disagree and think you should never check a solution, even if a gun is pointed at your head. I completely disagree, remember, you have just started.) I recommend choosing problem that on average you spend about 30 minutes per problem. (average! so you might solve some in 10 mins, and some in more than an hour) Some say, “Think on a hard problem for 5 hours and enjoy!” No. trust me, Accepting 10 different problems helps more at this stage. I also recommend reviewing other people’s code. Early on, this helps you write more efficient solutions.

And seriously, don’t start by learning algorithms. Just solve problems. Learning complex algorithms too early is mostly a waste of time. To reach expert, you only need to solve problems with tags like implementation, brute force, math, greedy, and DP. (DP is the only one that requires serious practice.)

Here you can see the full video:

Video — Going from Newbie to Expert in 2-3 months

This is a recurrent pattern, happened over and over again in my teaching experience. I start teaching in a school, and I see that after a year the students are still newbie/pupil at most. I work with them and in several months they get to expert. Why? The previous teacher was teaching them AVL tree (or similar things), solving very hard problems, etc. If you ask the students to explain some complex algorithm in a paragraph, they can do that. But if you give them a simple problem to accept, they can't.

Trust me, this is not the correct way to learn CP. And, yes, there is a correct way and an incorrect way.

Feel free to agree/disagree in the comments. It’s welcome and helps everyone to know opposite point of views.

Full text and comments »

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

By Shayan, 14 months ago, In English

Note: The text editorials will be provided by the authors of the round. This video tutorial acts as an additional resource for those who prefer video over text, not as a substitute for the text editorial.

2070A — FizzBuzz Remixed

Video

2070B — Robot Program

Video

2070C — Limited Repainting

Video

2070D — Tree Jumps

Video

2070E — Game with Binary String

Video

Full text and comments »

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

By Shayan, 14 months ago, In English

Hi Codeforces,

Our last topic stream was on Combinatorics. We talked about exponentiation, combination (+ why does it have that formula), what is a combinatorial proof (the most interesting part), and proved Pascal's equality and a bunch of other problems using that. Then, we talked about how to calculate combination with O(N) preprocess time and O(1) query time, and finally, solved 559C — Gerald and Giant Chess.

The Full Course

Exponentiation ($$$a^b$$$) in $$$O(lgb)$$$

Video

Combination $$$n\choose k$$$ and why is it $$$\frac{n!}{k!(n-k)!}$$$

Video

Algebraic proofs suck, what is a Combinatorial Proof

(+ Proving a bunch of equalities like Pascal's, using combinatorial proof)

Video

ChatGPT trolling me

Video

Calculating combination in code

simplest: $$$O(n^2+q)$$$

better: $$$O(n+qlgn)$$$

even better: $$$O(nlgn+q)$$$

not that much different: $$$O(n + q)$$$

Video

Solving 559C — Gerald and Giant Chess

(Combination + DP)

Video

This is the link to choose the topic for the next topic stream:

Full text and comments »

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

By Shayan, 15 months ago, In English

Note: The text editorials will be provided by the authors of the round. This video tutorial acts as an additional resource for those who prefer video over text, not as a substitute for the text editorial.

2065A — Skibidus and Amog'u

Video

2065B — Skibidus and Ohio

Video

2065C — Skibidus and Fanum Tax

Video

2065D — Skibidus and Sigma

Video

2065E — Skibidus and Rizz

Video

2065F — Skibidus and Slay

Video

2065G — Skibidus and Capping

Video

2065H — Bro Thinks He's Him

Video

Full text and comments »

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

By Shayan, 15 months ago, In English

Note: The text editorials will be provided by the authors of the round. This video tutorial acts as an additional resource for those who prefer video over text, not as a substitute for the text editorial.

During today’s contest solution discussion, we tested ChatGPT o3-mini-high on our contest problems. And get this: it solved problems C and D! It claimed that it did it without internet access.

We asked about its capability, and it said that if it made a Codeforces account, its rating would be 3500–4000! I don’t know if AI has learned to solve very hard problems or if it’s getting overconfident.

All I can say is, things are getting pretty SCARY. I have no idea what’s going to happen with CP contests and competitive programmers soon.

2059A — Milya and Two Arrays

Video

2059B — Cost of the Array

Video

2059C — Customer Service

Video

GPT o3-mini-high Solved C

Video

2059D — Graph and Graph

Video

GPT o3-mini-high Solved D

Video

Asking ChatGPT if it is Cheating (Has Internet Access)

Video

o3 claiming that it has rating 3500 on Codeforces!

Video

Trying to Solve E2 with o2 — Not Successful

Video

P.S. Seems like rank 4000+ should be called GPT soon.

Full text and comments »

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

By Shayan, history, 15 months ago, In English

Note: The text editorials will be provided by the authors of the round. This video tutorial acts as an additional resource for those who prefer video over text, not as a substitute for the text editorial.

2060A — Fibonacciness

Video

2060B — Farmer John's Card Game

Video

2060C — Game of Mathletes

Video

2060D — Subtract Min Sort

Video

2060E — Graph Composition

Video

2060F — Multiplicative Arrays

Video

2060G — Bugged Sort

Video

Full text and comments »

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

By Shayan, 17 months ago, In English

Note: The text editorials will be provided by the authors of the round. This video tutorial acts as an additional resource for those who prefer video over text, not as a substitute for the text editorial.

2050A — Line Breaks

Video

2050B — Transfusion

Video

2050C — Uninteresting Number

Video

2050D — Digital string maximization

Video

2050E — Three Strings

Video

2050F — Maximum modulo equality

Video

2050G — Tree Destruction

Video

Full text and comments »

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

By Shayan, history, 17 months ago, In English

Note: The text editorials will be provided by the authors of the round. This video tutorial acts as an additional resource for those who prefer video over text, not as a substitute for the text editorial.

2042A — Greedy Monocarp

Video

2042B — Game with Colored Marbles

Video

2042C — Competitive Fishing

Video

2042D — Recommendations

Video

2042E — Vertex Pairs (not complete)

Video

2042F — Two Subarrays

Video

Full text and comments »

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

By Shayan, 17 months ago, In English

Note: The text editorials will be provided by the authors of the round. This video tutorial acts as an additional resource for those who prefer video over text, not as a substitute for the text editorial.

2034A — King Keykhosrow's Mystery

Video

2034B — Rakhsh's Revival

Video

2034C — Trapped in the Witch's Labyrinth

Video

2034D — Darius' Wisdom

Video

2034E — Permutations Harmony

Video

Full text and comments »

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

By Shayan, 17 months ago, In English

Note: The text editorials will be provided by the authors of the round. This video tutorial acts as an additional resource for those who prefer video over text, not as a substitute for the text editorial.

2037A — Twice

Video

2037B — Intercepted Inputs

Video

2037C — Superultra's Favorite Permutation

Video

2037D — Sharky Surfing

Video

2037E — Kachina's Favorite Binary String

Video

2037F — Ardent Flames

Video

2037G — Natlan Exploring

Video

Full text and comments »

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

By Shayan, 18 months ago, In English

Note: The text editorials will be provided by the authors of the round. This video tutorial acts as an additional resource for those who prefer video over text, not as a substitute for the text editorial.

2028A — Alice's Adventures in "Chess"

Video

2028B — Alice's Adventures in Permuting

Video

2028C — Alice's Adventures in Cutting Cake

Video

2028D — Alice's Adventures in Cards

Video

2028E — Alice's Adventures in the Rabbit Hole

Video

2028F — Alice's Adventures in Addition

Video

Full text and comments »

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

By Shayan, history, 18 months ago, In English

Note: The text editorials will be provided by the authors of the round. This video tutorial acts as an additional resource for those who prefer video over text, not as a substitute for the text editorial.

2029A — Set

Video

2029B — Replacement

Video

2029C — New Rating

Video

2029D — Cool Graph

Video

Full text and comments »

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

By Shayan, 18 months ago, In English

Note: The text editorials will be provided by the authors of the round. This video tutorial acts as an additional resource for those who prefer video over text, not as a substitute for the text editorial.

2036A — Quintomania

Video

2036B — Startup

Video

2036C — Anya and 1100

Video

2036D — I Love 1543

Video

2036E — Reverse the Rivers

Video

2036F — XORificator 3000

Video

2036G — Library of Magic

Video

Full text and comments »

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

By Shayan, history, 18 months ago, In English

Note: The text editorials will be provided by the authors of the round. This video tutorial acts as an additional resource for those who prefer video over text, not as a substitute for the text editorial.

2032A — Circuit

Video

2032B — Medians

Video

2032C — Trinity

Video

2032D — Genokraken

Video

2032E — Balanced

Video

Full text and comments »

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

By Shayan, history, 18 months ago, In English

Note: The text editorials will be provided by the authors of the round. This video tutorial acts as an additional resource for those who prefer video over text, not as a substitute for the text editorial.

2026A — Perpendicular Segments

Video

2026B — Black Cells

Video

2026C — Action Figures

Video

2026D — Sums of Segments

Video

2026E — Best Subsequence

Video

Full text and comments »

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