### Shayan's blog

By Shayan, history, 37 hours ago,

Video

Video

Video

Video

### 2002E — Cosmic Rays

Video
• -13

By Shayan, 3 days ago,

Video

Video

Video

Video

Video

### 1998E2 — Eliminating Balls With Merging (Hard Version)

Video
• +13

By Shayan, 4 days ago,

Hi,

As always, we have topic streams on Fridays from 12-14 GMT. Today was the second topic stream on Dynamic Programming. Here are the topics covered in this livestream:

1. The idea of updating dp in two directions (Sending a Sequence Over the Network)
2. Keeping our states for matching subsequences (Easy Problem)
3. Importance of ordering in updating DP (Gargari and Permutations)
4. Keeping max values to optimize DP (Choosing Balls)
5. Memory optimization and moving in two directions (Pigs and Palindromes)

I will write the highlights of the livestream here, embedding specific parts of the videos so you can easily watch the sections you’re interested in. You can ask questions about any part here, on YouTube, or in our Telegram Channel. The main discussion thread is in our Telegram Channel.

## Updating DP in two directions

In DP problems, sometimes we calculate dp[i] when we reach i by using smaller instances (j < i). Other times, when we reach i, we assume that we already have dp[i] and update the larger instances (j > i). In some cases, we can do both simultaneously.

Sending a Sequence Over the Network

Video

## Keeping our states for matching subsequences

In this problem, we want to remove certain characters to ensure that the string "hard" does not appear as a subsequence in our string. We explore how to maintain states that track how many characters of "hard" have already been matched and how this helps us solve the problem efficiently.

Easy Problem

Video

## Importance of ordering in updating DP

In this problem, we see how the order of calculating DP values can be important and how to find the right ordering.

Video

Gargari and Permutations

## Keeping max values to optimize DP

In this problem, we first come up with an O(n^2) DP solution. Then we optimize it by keeping track of the two maximum DP values. This way, we can update dp[i] in O(1) instead of O(n).

Choosing Balls

Video

## Memory optimization and moving in two directions

Here, in addition to the idea of considering the diagonals of a grid and maintaining our states, we see how we can optimize memory by taking one of the dimensions modulo 2.

Pigs and Palindromes

Video

Let me know your opinions! Together we can make the livestreams better.

• +28

By Shayan, 7 days ago,

Video

Video

Video

Video

Video

Video

Video

### 1999G2 — Ruler (hard version)

Video
• +21

By Shayan, 9 days ago,

Video

Video

Video

Video

### 1993E — Xor-Grid Problem

Video
• +7

By Shayan, 11 days ago,

Hi,

Today, I had my first topic stream on Dynamic Programming. The stream lasted for two hours, and this was the plan for the first livestream:

1. Start with the basics of Dynamic Programming: the logic behind it and when to apply it.
2. Boredom — difficulty 1500
3. Consecutive Subsequence — difficulty 1700
4. Red-Green Tower — difficulty 2000
5. Winter is here — difficulty 2200

I will write the highlights of the livestream here, while embedding the specific parts of the videos so that you can easily watch the parts you want. You can ask questions about any part here, on YouTube, or in our Telegram Channel. The main discussion thread is in our Telegram Channel.

## The Basics of Dynamic Programming

In this part, I talk about what Dynamic Programming is and why we might want to use it. I explain how to figure out if we can apply DP to a problem. Of course, as an example, I discuss the Fibonacci sequence—who doesn’t use Fibonacci when explaining DP? I tried to skip unnecessary details and keep the focus on the most important points.

## 455A — Boredom

This problem helps to build intuition on how DP works. It’s an example of defining states and solving the main problem using those states. In this case, we define dp[i] as the answer when considering only the numbers from 1 to i and ignoring the rest.

Video

## 977F — Consecutive Subsequence

This is another problem that helps with the idea of defining subproblems as the different cases that contribute to our final answer. Here, we define dp[i] as the answer if the last chosen number in our subsequence is i.

Video

## 478D — Red-Green Towers

This problem combines a greedy algorithm to find the best value for h and defines subproblems like (i, j). This states how many ways we can have a pyramid of height i using j red blocks.

Video

## 839D — Winter is here

This one features number theory. We want to find the value of dp[x] as the number of possible subsets whose GCD is x. To do this, we first find the number of subsets where one of their common divisors (not necessarily the maximum one) is x. From there, we determine the number of subsets whose GCD is x.

Video

Let me know your opinions! This is your livestream, and together we can make it better.

• +33

By Shayan, history, 2 weeks ago,

## 1997F — Chips on a Line

• +35

By Shayan, history, 2 weeks ago,

Today, I wasn’t at home. I was at Stevens University in New Jersey. So, the quality was not as usual and I had to keep the livestream shorter (solved only A-E), but it was a new format either way. I tried to show some views of New York City (which is on the other side of the river) to make up for it.

## Making Up for the Quality by Showing Some Scenery from New York

• +10

By Shayan, history, 3 weeks ago,

## 1996G — Penacony — Jiangly's XOR hashing beautiful solution

• +7

By Shayan, history, 3 weeks ago,

## 1995E2 — Let Me Teach You a Lesson (Hard Version)

Just explained a code. If you know the full solution, please write that in the comments below.

• +10

By Shayan, history, 3 weeks ago,

## 1990E2 — Catch the Mole(Hard Version)

Not a formal proof! (please explain the formal proof of the algorithm in the comment section if you know that)

• +2

By Shayan, 4 weeks ago,

## 1994G — Minecraft

• +48

By Shayan, 4 weeks ago,

## 1988E — Range Minimum Sum

• +33

By Shayan, history, 5 weeks ago,

## 1992G — Ultra-Meow

• +36

By Shayan, history, 5 weeks ago,

## 1983F — array-value

• +126

By Shayan, history, 6 weeks ago,

Hi,

Here is the video editorial of Problems A-F2 of EPIC Institute of Technology Round Summer 2024 (Div. 1 + Div. 2). I hope it helps.

## 1987F2 — Interesting Problem (Hard Version)

• +62

By Shayan, 7 weeks ago,

Hi,

Here is the video editorial of all the problems of Educational Codeforces Round 167 (Rated for Div. 2). I hope it helps.

## 1989F — Simultaneous Coloring

• +91

By Shayan, 7 weeks ago,

Hi,

From now on, we are going to provide video editorials for Codeforces rounds. So, Codeforces rounds are not going to be limited to text editorials, but also video editorials!

We want to seek feedback and try to improve these video editorials as much as possible. We will try different ideas like recorded videos and livestreams to see which one helps you the best. So, please help us make a better content for you!

The blog will be shortly accessible in contest materials.

## 1982E — Number of k-good subarrays

I hope it helps!

• +56

By Shayan, 7 weeks ago,

Hi,

From now on, we are going to provide video editorials for Codeforces rounds. So, Codeforces rounds are not going to be limited to text editorials, but also video editorials!

We want to seek feedback and try to improve these video editorials as much as possible. We will try different ideas like recorded videos and livestreams to see which one helps you the best. So, please help us make a better content for you!

The blog will be shortly accessible in contest materials.

## 1986G — Permutation Problem

I hope it helps!

• +18

By Shayan, 2 months ago,

Hey Guys, The interview with Adamant will be released on Saturday Jun 22, 17:00 GMT. We will talk from his work at Google to his new project OCPC and what are his hobbies. (Turns out that he is a gamer and watches animes) You may want to watch that!

And again, I will try to continue inviting interesting guests. I have a list already, if you wanted to suggest someone, feel free to let me know!

You can find the link of the video in the streams section of Codeforces! You can watch the video from Codeforces or from Youtube.

• +44

By Shayan, 3 months ago,

### First day

We have North America Championship from today (May 23rd) to May 28th in Orlando, Florida. This competition is for choosing the teams qualifying to ICPC WF 2024 in Kazakhstan.

I will make a vlog for each day. I'm trying to make each one of these vlogs 15 mins. My first try wasn't very successful and the first video is about half an hour. (It was good and I couldn't trim more than this)

By the way, we did the real duel with galen_colin and we tried to headshot each other using frisbees. We are both alive but injured.

Everyday, This post will be updated by the vlog of that day. Hope you'll enjoy, feel free to give me suggestions about the next ones. And definitely wish UMD White luck :)

### Second Day

I heard a sad news from Mohamed Bakry today. As he said, Iran and Israel cannot attend IOI 2024 onsite and this is told to them about a year ago. I personally don't know what can we do in this situation to prevent such things to happen again.

I also had a short talk with ecnerwala today. Then, we participated in the practice round today. We got the second rank, after MIT. They solved 7, we solved 6, the next teams (Waterloo and Stanford) solved 5.

There was a lot of fun back in the hotel too. Many hilarious things happened.

### Third day

Everything was very similar to the second day. We had another practice round. We did not perform well in this one. I also met and had a short talk with SecondThread. Again, we had most of the fun back in the hotel.

### Fourth Day

we had dress rehearsal round. It was basically training all the rules of the main contest with a practice round. We won it. Problems were super easy and some of them were from the previous rounds, so this does not mean anything. However, even winning meaningless competitions doesn't feel bad.

There was another round, NSA challenge. We performed poorly in it. The contest was not very good either (was not very competitive programming-ish). We got the 7th place.

Have you heard about link-cut tree? Today, I met its inventor, Professor Daniel Dominic Sleator. I recorded a short talk with him.

I also had a very short talk with our rival, MIT team. (djq_cpp, TLE, and duality) The scary fact about them is that the max rating of all of them is around 3300 ~ 3400. So, we can simply give up the first rank and fight for the second one.

The big day is tomorrow. You can watch the livestream on ICPC official YT channel. It seems like it has some cool features. Each team has a dedicated camera, and you can comment the name of a team to see them, and they will show that team to you. (You can see what they are doing at that moment) It seems cool.

We don't have any Chinese team member. So, wish us luck, we need that!

### Fifth Day

We had our contest on the fifth day. We were not at our best, however, we won some very valuable awards. We got:

Qualified to World Final 2024, Astana, Kazakhstan, NAC Bronze Medal, South division, J first accept, $7500 ($3000 for bronze, $3000 for winning South,$1500 for J first accept)

As expected, MIT won the gold medal.

Yeah, now we need to train to get in shape better. Because we need to be at our best in the WF.

### Final Day

The contest is over, and in the final day, we decided to go to Disney World. Actually, it was more fun than expected. You can watch this final vlog in the link provided below.

It's over, and now we have to get ready for the next challenge. This is the last update of this blog. Thank you for following!

## Videos

Day #1 (Coming to Florida and settling in)

Day #2 (Iran cannot attend IOI 2024, Short Talk with ecnerwala, Practice Round, Missing Frisbees)

Day #3 (Career Fairs, Second Practice Round, Short Talk with SecondThread)

Day #4 (Winning Dress Rehearsal Round, Talk with Link-Cut Tree Inventor)

Day #5 (Won Bronze and South)

Day #6 (I Rode an Ikran! | Many Disneylands, but One Disney World!)

## Photos

• +85

By Shayan, 3 months ago,

Well, since you like it even more than educational content, I'm starting to upload more of them.

Yesterday, we had Codesprint LA, an online ICPC style contest. Our team (UMD White, galen_colin, sam571128, and I) participated in it. We ended up ranked 6th in total, and 1st amongst the universities who participated. (teams that are eligible for NAC)

Who won the first place? Well, as usual, tourist with his two teammates.

We recorded some parts of it. The cam was on by itself and we were trying to solve problems. I uploaded it to youtube and you can watch it here.

And, as announced, we are going to do the duel today!

• +49

By Shayan, history, 3 months ago,

EDIT: Because of clashing with the div 2 contest, I will postpone the interview for one day.

Hey,

First, I want to mention that my interview with orz is going to be out on Friday 17:00 GMT. I will soon schedule it!

orz is a unique competitive programming legend! He has a gold medal in IMO (Um_Nik has had qualified to IPhO and orz has a gold medal in IMO, I don't know what is the problem of CP legends with IOI) He was a participant in ICPC 2024 World final. And of course, he is an IGM in Codeforces. He is currently studying PhD in mathematics and works in a startup.

Maybe we (orz and I) will have live commentary on the interview and be active in the chatbox while it is streaming. (If it makes it more interesting ofc)

You can view the trailer here:

https://www.youtube.com/shorts/5rZNLpAq8Tc

Also, I have another (maybe?) interesting material. I decided to upload a vlog of IOI 2022! (after two years lol) Because it was too dope and I'm sure it gives people a lot of motivation! Therefore, I found it very useful even after two years. So, I hope you will enjoy it.

Here is the link of this video: https://youtu.be/Oqz6Lx6Edok

And, you can find some pictures of this vlog below.

• +85

By Shayan, history, 4 months ago,

Ok, I know it took so much time, but it worth it!

Um_nik, in one word, is a legend. After this interview I found a lot more about him.

Like what? He didn't do IOI and IMO in high school, instead he advanced to IPhO! (International Physiscs Olympiad) He is the champion of ICPC in 2020. Once, he was at the first place of CF for a few weeks (in 2018).

If you are surprised, don't be yet. The real surprise is when he says he doesn't believe in talent!

I will discuss many things with him. It took more than an hour (I wanted to keep it short, but I really couldn't, it was so good that I couldn't remove any part)

He talks about his advices to competitive programmers, his own journey, what happened after he posted the solutions of a div 3 round (during the contest lol), what he did on the 4th Dec 2016 (double lol), his opinion about many different things, and definitely I asked him your questions!

I invite you all to watch this interview on Friday April 5, 17:00 GMT. You can watch later as well, but let's watch it together and chat.

Here are the trailers:

PS1: I separated the educational channel and the interviews channel.

PS2: Let me know which trailer you liked the best. It helps for making the trailers of the next interviews.

PS3: Tell me who you want me to interview next!

• +74

By Shayan, 6 months ago,

Hey guys,

Yesterday, we won both the Mid-Atlantic region of North America ICPC and the whole South Division (including the Mid-Atlantic, South Central, and Southeast Regions). Our team consists of Colin Galen (galen_colin), Sam Lee (sam571128), and me (Shayan). We are UMD White from the University of Maryland.

I created a vlog for the whole day of the contest. I hope you enjoy it.

https://www.youtube.com/watch?v=OMozjSNLS14

The next round is NAC (the whole USA and Canada will participate). It will be in around 2 months. If we perform well, we will qualify to the World Final.

• +99