brain

tamnd's digital brain — notes, problems, research

41830 notes

CF 105D - Entertaining Geodetics

The statement is intentionally wrapped in game terminology, but the underlying process is a sequence of color merges. Each map cell has a panel color. Some cells also contain a symbol, and every symbol has its own color. We start by destroying one specific symbol.

codeforcescompetitive-programmingbrute-forcedsuimplementation
CF 105B - Dark Assembly

We have a small assembly of n senators, each defined by a level and a loyalty score. Loyalty is a probability that a senator votes in favor of a proposal, given in 10% increments. If more than half of senators vote yes, the proposal passes.

codeforcescompetitive-programmingbrute-forceprobabilities
CF 2227D - Palindromex

We are given an array of length $2n$. Every value from $0$ to $n-1$ appears exactly twice. The task is to select a contiguous segment of this array that reads the same left-to-right and right-to-left, and among all such segments we want the one whose mex is as large as possible.

codeforcescompetitive-programmingbinary-searchbrute-forceconstructive-algorithmsdata-structuresgreedyimplementationtwo-pointers
CF 2227F - It Just Keeps Going Sideways

Each column contains cubes stacked from height $1$ up to height $ai$. After gravity turns to the right, cubes never change height. Cubes at the same height slide independently and occupy the rightmost available positions on that horizontal level.

codeforcescompetitive-programmingbinary-searchdata-structuresdpgreedymath
CF 105E - Lift and Throw

We are given three characters, each standing on a different position along a one-dimensional half-line. Each position is an integer starting at 1, and each character has a movement range and a throwing range.

codeforcescompetitive-programmingbrute-force
CF 2227C - Snowfall

A subarray product is divisible by $6$ if and only if the product contains at least one factor $2$ and at least one factor $3$. For each number, only its divisibility by $2$ and $3$ matters. The exact value is irrelevant.

codeforcescompetitive-programmingconstructive-algorithmsmath
CF 2227A - Koshary

We are given a grid starting at the origin point $(0,0)$ and a target point $(x,y)$. At each move, Yousef can increase exactly one coordinate by 2 using a long step, either moving right by 2 or up by 2.

codeforcescompetitive-programmingimplementationmath
CF 2227G - Drowning

Ta có một mảng số nguyên dương. Một phép giảm chọn ba phần tử liên tiếp sao cho phần tử giữa nhỏ hơn tổng hai phần tử hai bên. Khi đó bộ ba $$(c{i-1},ci,c{i+1})$$ được thay bằng một giá trị duy nhất $$x=c{i-1}-ci+c{i+1}.

codeforcescompetitive-programmingbinary-searchdata-structuresmath
CF 2226B - Everything Everywhere

We are given a permutation of the integers from 1 to n. For every contiguous subarray, we look at three quantities: - its maximum value, - its minimum value, - the GCD of all values inside it.

codeforcescompetitive-programminggreedymathnumber-theory
CF 2227E - It All Went Sideways

Each test case gives a sequence of column heights. Think of column i as a vertical stack of unit blocks, occupying rows 1 up to ai. All blocks in a row are aligned across columns.

codeforcescompetitive-programmingbinary-searchdata-structuresdpgreedy
CF 2226A - Disturbing Distribution

We are given a sequence of positive integers. We repeatedly remove groups of elements until nothing remains. Each group must respect two constraints: if we look at the chosen indices in increasing order, the corresponding values must be nondecreasing, and the indices…

codeforcescompetitive-programminggreedymath
CF 2227H - Fallen Leaves

We are given a tree and a fixed set of vertices consisting of all leaves in the original tree. These leaves are determined once from the initial structure and do not change during the process.

codeforcescompetitive-programmingdfs-and-similardptrees
CF 2226C - Mental Monumental (Easy Version)

Each array element can be modified independently. For a value $x$, we may choose any positive integer $b$, then replace $x$ by $x bmod b$. The goal is to maximize the MEX of the resulting array.

codeforcescompetitive-programmingbinary-searchdata-structuresgreedymathtwo-pointers
CF 2226F - Inversion Invasion

For every divisor $dmid n$, define $$Gd={vin[1,n]mid gcd(v,n)=d}.$$ The array $a$ gradually fixes some positions. If $ai=dneq 0$, then position $i$ must contain a value from $Gd$. Unfixed positions may contain any remaining values.

codeforcescompetitive-programmingmathnumber-theory
CF 2227B - Party Monster

We are given a string made only of opening and closing parentheses. In one move, we are allowed to take a contiguous block, remove it, and then reinsert its characters anywhere in the remaining string, with full freedom to permute those removed characters and place each one…

codeforcescompetitive-programminggreedy
LeetCode 3310 - Remove Methods From Project

Understood. For any TAOCP Volume 1 exercise you provide, I will write the solution in the style of a rigorous solution manual: - Use Knuth's notation and terminology from the relevant section. - State precisely what is to be proved or computed.

leetcodemediumdepth-first-searchbreadth-first-searchgraph-theory
LeetCode 3158 - Find the XOR of Numbers Which Appear Twice

This problem asks us to find all numbers in the array that appear exactly twice and compute the bitwise XOR of those numbers. The input is an integer array nums. The problem guarantees that every value appears either once or twice, never more than twice.

leetcodeeasyarrayhash-tablebit-manipulation
LeetCode 3004 - Maximum Subtree of the Same Color

We are given a rooted tree with n nodes, where node 0 is the root. The input edges describes the tree structure. Each entry edges[i] = [u, v] indicates that there is an undirected edge between nodes u and v.

leetcodemediumarraydynamic-programmingtreedepth-first-search
LeetCode 3660 - Jump Game IX

The problem asks us to determine, for each position in an array nums, the maximum value that can be reached by making a series of jumps under strict rules.

leetcodemediumarraydynamic-programming
LeetCode 3774 - Absolute Difference Between Maximum and Minimum K Elements

The problem asks us to calculate the absolute difference between the sum of the k largest elements and the sum of the k smallest elements in a given array nums.

leetcodeeasyarraysorting
LeetCode 3738 - Longest Non-Decreasing Subarray After Replacing at Most One Element

assert Solution().

leetcodemediumarraydynamic-programming
LeetCode 3438 - Find Valid Pair of Adjacent Digits in String

The problem gives us a string s containing only digits from '1' to '9'. We need to find the first adjacent pair of digits that satisfies two conditions. First, the two digits in the pair must be different. A pair like "22" or "55" is never valid.

leetcodeeasyhash-tablestringcounting
Kvant Math Problem 241

The exponent $1974$ is large, so direct computation is impossible.

kvantmathematicsolympiad
LeetCode 3430 - Maximum and Minimum Sums of at Most Size K Subarrays

We are remains efficient even at the maximum constraint limit.

leetcodehardarraymathstackmonotonic-stack
LeetCode 3421 - Find Students Who Improved

This This ensures that performance in one subject never affects another subject's result.

leetcodemediumdatabase
LeetCode 3394 - Check if Grid can be Cut into Sections

LeetCode 3394: Check if Grid can be Cut into Sections (Medium)

leetcodemediumarraysorting
LeetCode 3675 - Minimum Operations to Transform String

We are given a string s consisting of lowercase English letters. An operation chooses a character value c and simultaneously replaces every occurrence of c in the current string with the next letter of the alphabet. The alphabet is circular, so 'z' becomes 'a'.

leetcodemediumstringgreedy
LeetCode 3671 - Sum of Beautiful Subsequences

Let a subsequence of nums be any sequence multiples. citeturn0search1turn0search2 check whether it is strictly increasing, compute its GCD, and add that GCD to the answer. This is correct because every valid subsequence is examined exactly once.

leetcodehardarraymathbinary-indexed-treenumber-theory
LeetCode 3639 - Minimum Time to Activate String

We are given a string s of length n and a permutation array order. At time t = 0, the character at index order[0] is replaced with ''. At time t = 1, the character at index order[1] is also replaced with ''.

leetcodemediumarraybinary-search
LeetCode 3633 - Earliest Finish Time for Land and Water Rides I

The problem asks us to determine the earliest possible time a tourist can finish exactly one land ride and one water ride at a theme park, where rides may be taken in either order.

leetcodeeasyarraytwo-pointersbinary-searchgreedysorting
LeetCode 3634 - Minimum Removals to Balance Array

The problem asks us to transform a given integer array nums into a balanced array with the minimum number of removals. An array is defined as balanced if its maximum element does not exceed k times its minimum element.

leetcodemediumarraybinary-searchsliding-windowsorting
LeetCode 3621 - Number of Integers With Popcount-Depth Equal to K I

This problem asks us to count integers x in the range [1, n] such that the popcount-depth of x is exactly k. The popcount-depth is defined via a sequence p0, p1, ... where p0 = x and pi+1 = popcount(pi) for all i ≥ 0.

leetcodehardmathdynamic-programmingbit-manipulationcombinatorics
LeetCode 3616 - Number of Student Replacements

The problem models a simple selection process among students arriving one by one. Each student has a rank, where a smaller rank value represents a better student. The first arriving student is automatically selected.

leetcodemediumarraysimulation
LeetCode 3615 - Longest Palindromic Path in Graph

We are given an undirected graph with n ≤ 14 vertices. Each vertex has a character label. We may choose any simple path in the graph, meaning a sequence of adjacent vertices in which no vertex is visited more than once.

leetcodehardstringdynamic-programmingbit-manipulationgraph-theorybitmask
LeetCode 3610 - Minimum Number of Primes to Sum to Target

The problem requires us to determine the minimum number of prime numbers from the first m primes whose sum equals n. A multiset is allowed, meaning each prime may be chosen multiple times.

leetcodemediumarraymathdynamic-programmingnumber-theory
LeetCode 3600 - Maximize Spanning Tree Stability with Upgrades

This problem asks us to determine the maximum possible stability of a spanning tree built from a weighted, undirected graph with certain constraints. Each edge in the graph has a strength and a mandatory flag.

leetcodehardbinary-searchgreedyunion-findgraph-theoryminimum-spanning-tree
CF 1958I - Equal Trees

We are given two rooted trees on the same labeled vertex set from 1 to n, both rooted at 1. Each tree is described by its parent array, so every node knows its immediate parent except the root.

codeforcescompetitive-programming*specialgraphsmeet-in-the-middle
CF 1952A - Are You a Robot, Again?

In this problem, we are given a string of digits that a robot has produced. The robot operates under a simple but peculiar rule: for each digit in the string, if the digit is even, it will remain in the output string as-is.

codeforcescompetitive-programming*specialstrings
CF 1973D - Cat, Fox and Maximum Array Split

Codeforces 1973D: Cat, Fox and Maximum Array Split

codeforcescompetitive-programmingbrute-forceinteractivemath
CF 1945C - Left and Right Houses

We are given a village with n houses aligned in a row. Each resident has a preference for which side of a street they want to live on: left (0) or right (1).

codeforcescompetitive-programmingbrute-force
CF 488B - Candy Boxes

The task is to reconstruct a set of four integers representing candy counts in boxes such that three properties are equal: the arithmetic mean, the median, and the range. We are given some subset of these four numbers (0 to 4) in arbitrary order.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsmath
CF 1942E - Farm Game

The cows of the two farmers must appear in alternating order on the line. Once the order of the first cow is chosen, the entire sequence is fixed: either J N J N ... J N or N J N J ... N J. The actual positions are not fixed.

codeforcescompetitive-programmingcombinatoricsgames
CF 1942D - Learning to Paint

We are asked to help Elsie evaluate her paintings on a 1D canvas of n cells. Each cell can be painted or left empty, and the painting's beauty is determined by a 2D array a.

codeforcescompetitive-programmingbinary-searchdata-structuresdfs-and-similardpgreedyimplementationsortings
CF 1958J - Necromancer

We are simulating a very specific combat process on a fixed line of monsters, and answering many independent queries on subsegments of that line.

codeforcescompetitive-programming*special
HSK 4 Grammar Points

Comprehensive guide to HSK 4 grammar: complex comparisons, formal negation, pivotal constructions, topic-comment structures, and upper-intermediate patterns.

chinesehsk4grammarupper-intermediatehskb1
CF 1942C1 - Bessie's Birthday Cake (Easy Version)

We are given a regular polygon with $n$ vertices representing a cake. Some vertices are already selected by Bessie as potential endpoints for drawing diagonals.

codeforcescompetitive-programminggeometrygreedymath
CF 1949H - Division Avoidance

The process starts with a single cell at (0, 0). Whenever we divide a cell (x, y), that cell disappears and produces (x + 1, y) and (x, y + 1). A division is only legal if neither child is currently present. We are given a finite set of forbidden coordinates.

codeforcescompetitive-programminggreedymath
CF 1945E - Binary Search

We are given a permutation of size $n$, meaning every number from $1$ to $n$ appears exactly once, but in some arbitrary order. Along with it, we are given a target value $x$ that definitely exists somewhere in the array.

codeforcescompetitive-programmingbinary-searchconstructive-algorithmsgreedy
CF 1956D - Nene and the Mex Operator

We are given a short array of length at most 18. The only allowed move is to pick a contiguous segment, compute the mex of that segment, and overwrite the entire segment with that mex value.

codeforcescompetitive-programmingbitmasksbrute-forceconstructive-algorithmsdivide-and-conquerdpgreedyimplementationmath
CF 1942B - Bessie and MEX

We are given an array a of length n, constructed from some unknown permutation p of the integers 0 through n-1. Each element of a satisfies the relation a[i] = MEX(p[1..i]) - p[i]. The task is to reconstruct any valid permutation p that produces this a.

codeforcescompetitive-programmingconstructive-algorithmsmath
CF 1952I - Dark Matter

The input describes a single arithmetic-style expression consisting of integers combined with the + operator. The key difference from standard arithmetic is that + does not mean numeric addition.

codeforcescompetitive-programming*specialbitmasksgeometry
CF 1958F - Narrow Paths

We are working on a very constrained grid: only two rows and a large number of columns. The start is the top-left cell, and the goal is the bottom-right cell.

codeforcescompetitive-programming*specialcombinatorics
CF 1973B - Cat, Fox and the Lonely Array

Codeforces 1973B: Cat, Fox and the Lonely Array

codeforcescompetitive-programmingbinary-searchbitmasksdata-structuresgreedymathtwo-pointers
CF 1945F - Kirill and Mushrooms

Kirill wants to gather mushrooms under a Wise Oak to brew an elixir. Each mushroom has a magic power, and the strength of an elixir made from a group of mushrooms is the product of the count of mushrooms and the minimum magic power among them.

codeforcescompetitive-programmingdata-structuressortings
CF 491B - New York Hotel

The city is a rectangular grid. Every hotel and every restaurant is located at an intersection with coordinates $(x,y)$.

codeforcescompetitive-programminggreedymath
Sindarin Vocabulary: Numbers

Complete Sindarin number system: cardinals 1–1000, ordinals 1st–10th, number compounds, duodecimal counting, and number words in place names.

sindarinvocabularynumberstolkien
CF 1945B - Fireworks

Two firework machines start at time zero and then keep launching fireworks periodically. The first machine fires at times that are multiples of a, and the second fires at multiples of b.

codeforcescompetitive-programmingmathnumber-theory
CF 1942F - Farmer John's Favorite Function

We have an array $a$, and a recursively defined value: $$f(1)=sqrt{a1}, qquad f(i)=sqrt{f(i-1)+ai}.$$ After every point update $ak leftarrow x$, we need the integer part of $f(n)$. The first obstacle is that the recurrence uses real numbers.

codeforcescompetitive-programmingbrute-forcedata-structuresimplementationmath
CF 1950B - Upscaling

We are asked to generate a checkerboard pattern that is made of larger $2 times 2$ tiles. Each tile is either fully filled with the character or fully filled with .. The size of the grid is determined by an input integer $n$, and the final grid has dimensions $2n times 2n.

codeforcescompetitive-programmingimplementation
Sindarin Vocabulary: Colors

Sindarin color words: attested terms for green, white, grey, black, red, blue, gold, and silver — with place name examples and nuance notes.

sindarinvocabularycolorscolourstolkien
CF 1949A - Grove

Every tree is planted at an integer lattice point. Around that point we place a disk of radius r, representing the root system. Two conditions must hold. The entire disk must stay inside the square lawn.

codeforcescompetitive-programmingbrute-forcedfs-and-similardpgeometryprobabilities
CF 480E - Parking Lot

Codeforces 480E: Parking Lot

codeforcescompetitive-programmingdata-structuresdivide-and-conquer
CF 1951H - Thanos Snap

We are given an array whose length is a power of two, and it initially contains all integers from 1 to $2^k$ exactly once. So the array is just a permutation, but its initial order matters. A game is played on this array. A parameter $t$ is fixed first.

codeforcescompetitive-programmingbinary-searchdpgamesgreedytrees
CF 1942G - Bessie and Cards

The deck contains four kinds of cards. A draw-0 card consumes one playable card from your hand and gives nothing back. A draw-1 card replaces itself. A draw-2 card consumes one card and gives two new cards, so it increases your future drawing power by one.

codeforcescompetitive-programmingcombinatoricsdpmath
CF 1975A - Bazoka and Mocha's Array

Codeforces 1975A: Bazoka and Mocha's Array

codeforcescompetitive-programmingbrute-forcegreedyimplementationsortings
CF 1945D - Seraphim the Owl

We are given a queue of n people waiting to ask Seraphim the Owl a question. Kirill arrives at the end of the line and wants to move forward so that he is among the first m people.

codeforcescompetitive-programmingdpgreedy
CF 493C - Vasya and Basketball

Vasya wants to maximize the point advantage of his team in a basketball game by choosing a threshold distance, d, that separates 2-point throws from 3-point throws. Each team has a list of distances from which they made successful throws.

codeforcescompetitive-programmingbinary-searchbrute-forcedata-structuresimplementationsortingstwo-pointers
CF 1975G - Zimpha Fan Club

Codeforces 1975G: Zimpha Fan Club

codeforcescompetitive-programmingfftgreedymathstrings
CF 1976A - Verify Password

Codeforces 1976A: Verify Password

codeforcescompetitive-programmingimplementationsortingsstrings
CF 1951I - Growing Trees

We are given a connected simple undirected graph with up to 50 vertices and at most 50 edges. Each edge can be used multiple times in a constructed multigraph, and we control how many copies of each edge we create through a non-negative integer array $x$.

codeforcescompetitive-programmingbinary-searchconstructive-algorithmsflowsgraphsgreedy
CF 493E - Vasya and Polynomial

We are asked to count the number of polynomials with non-negative integer coefficients that satisfy a very specific evaluation property.

codeforcescompetitive-programmingmath
CF 488A - Giga Tower

We are standing at an integer floor number in a very large tower that extends far below zero and far above zero. From our current floor $a$, we are only allowed to move upward, meaning we repeatedly add positive integers.

codeforcescompetitive-programmingbrute-force
CF 1951E - No Palindromes

We are given a string and we are allowed to cut it into contiguous pieces. The goal is to decide whether we can cut it so that every resulting piece is not a palindrome. If it is possible, we must also construct one such cut.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsdivide-and-conquergreedyhashingimplementationmathstrings
CF 1967C - Fenwick Tree

We are asked to reverse a Fenwick Tree construction. A Fenwick Tree is normally defined for an array a of length n such that each element sk stores the sum of a contiguous subarray of a whose length is the lowest set bit of k.

codeforcescompetitive-programmingbitmasksbrute-forcecombinatoricsdata-structuresdpmathtrees
CF 1974C - Beautiful Triple Pairs

Codeforces 1974C: Beautiful Triple Pairs

codeforcescompetitive-programmingcombinatoricsdata-structures
CF 1949K - Make Triangle

We are given a multiset of positive integers and three required group sizes. Every number must belong to exactly one of the three groups, and each group must contain exactly the requested number of elements. After splitting the numbers, we look only at the three group sums.

codeforcescompetitive-programmingconstructive-algorithmsmath
CF 1955D - Inaccurate Subsequence Search

We are asked to count subsegments of length m in an array a that are “good” relative to another array b of length m. A subsegment is considered good if, after rearranging its elements, at least k of them match elements from b.

codeforcescompetitive-programmingdata-structurestwo-pointers
CF 1944A - Destroying Bridges

We are asked to consider a network of islands where initially every pair of islands is connected by a bridge. There are n islands, numbered from 1 to n, and Everule lives on island 1. Dominater can destroy up to k bridges to reduce the number of islands that Everule can reach.

codeforcescompetitive-programminggraphsgreedymath
HSK 8 Grammar Points

Comprehensive guide to HSK 8 grammar: expert academic writing, cross-register fluency, archaic vocabulary in modern use, and C2-level mastery patterns.

chinesehsk8grammarexperthskc2
CF 1945A - Setting up Camp

We are given a group of participants who must be assigned into tents, where each tent can hold at most three people. The participants come in three types with different constraints on how they are willing to share a tent.

codeforcescompetitive-programminggreedymath
CF 1974B - Symmetric Encoding

Codeforces 1974B: Symmetric Encoding

codeforcescompetitive-programmingimplementationsortingsstrings
CF 495A - Digital Counter

The elevator always displays a two-digit floor number from 00 to 99. Each digit is drawn using a seven-segment display. A segment can be broken. When a segment is broken, it cannot light up even if it should.

codeforcescompetitive-programmingimplementation
CF 1967D - Long Way to be Non-decreasing

We are given an array where each position contains a value in the range $1$ to $m$, and a second array that defines a deterministic transformation on values: every value $x$ has a fixed replacement $bx$.

codeforcescompetitive-programmingbinary-searchdfs-and-similargraphsimplementationshortest-pathstwo-pointers
CF 1955C - Inhabitant of the Deep Sea

We are given a line of ships, each with some durability, and a fixed attack pattern that always targets the current leftmost surviving ship, then the current rightmost surviving ship, and repeats this alternation until a total of $k$ attacks have been made or all ships sink.

codeforcescompetitive-programminggreedyimplementationmath
CF 1950D - Product of Binary Decimals

We are given up to 50,000 independent queries. For each query, a number n is provided, where 1 ≤ n ≤ 100000. A number is called a binary decimal if every digit in its usual decimal representation is either 0 or 1. Examples include 1, 10, 11, 101, and 1001.

codeforcescompetitive-programmingbrute-forcedpimplementationnumber-theory
CF 1975C - Chamo and Mocha's Array

Codeforces 1975C: Chamo and Mocha's Array

codeforcescompetitive-programmingbinary-searchbrute-forcegreedy
CF 1943D1 - Counting Is Fun (Easy Version)

We are looking at arrays of length n, where each position can hold an integer between 0 and k. Every such array is considered a candidate, so the total universe is (k+1)^n. The notion of “good” is defined through an operation that subtracts 1 from a contiguous segment.

codeforcescompetitive-programmingbrute-forcecombinatoricsdpmath
CF 1957A - Stickogon

We are given a collection of sticks, each with an integer length. The goal is to build as many regular polygons as possible using these sticks, with the restriction that each side of a polygon must be exactly one stick, and no stick can be reused.

codeforcescompetitive-programmingconstructive-algorithmsgreedy
CF 1943E1 - MEX Game 2 (Easy Version)

We are asked to simulate a two-player game on an array of integers, but with a compressed representation where we only know the frequencies of each integer.

codeforcescompetitive-programmingbinary-searchbrute-forcegreedy
CF 1951A - Dual Trigger

We are given a row of lamps, all initially off. We can perform one type of operation any number of times: choose two lamps that are currently off and are not next to each other, and turn them both on simultaneously.

codeforcescompetitive-programmingconstructive-algorithmsgreedymath
CF 1955H - The Most Reckless Defense

We are given a grid where some cells form a fixed path from the top-left corner to the bottom-right corner. An enemy walks along this path one cell per second.

codeforcescompetitive-programmingbitmasksbrute-forceconstructive-algorithmsdpflowsgraph-matchingsshortest-paths
CF 1973C - Cat, Fox and Double Maximum

Codeforces 1973C: Cat, Fox and Double Maximum

codeforcescompetitive-programmingconstructive-algorithmsgreedyimplementationmathsortings
CF 1958D - Staircase

We are given a line of staircase steps, each step either needing repair or already fine. If a step is fine, it behaves like a zero in the input. If it is broken, it carries a positive cost value that represents its repair difficulty. The repair process is constrained by days.

codeforcescompetitive-programming*special
CF 1965A - Everything Nim

We are given several independent games, each defined by a list of piles containing stones. Two players alternate turns.

codeforcescompetitive-programminggamesgreedymathsortings
CF 1948G - MST with Matching

We are given a connected undirected weighted graph with at most 20 vertices. We must choose a spanning tree. The cost of that tree has two parts. The first part is standard, the sum of the chosen edge weights. The second part depends on the structure of the tree.

codeforcescompetitive-programmingbitmasksbrute-forcedsugraph-matchingstrees
CF 1949B - Charming Meals

We have two arrays of size n. The array a contains the spiciness values of the appetizers, and the array b contains the spiciness values of the main dishes. Every appetizer must be paired with exactly one main dish, and every main dish must be used exactly once.

codeforcescompetitive-programmingbinary-searchbrute-forcegreedysortings
CF 493B - Vasya and Wrestling

We are given a chronological log of wrestling techniques. Each entry is an integer that describes both who performed the move and how many points it contributed.

codeforcescompetitive-programmingimplementation
CF 1956E2 - Nene vs. Monsters (Hard Version)

We are given a circle of monsters, each with an energy level. The monsters attack their neighbor in a fixed clockwise order: monster 1 attacks monster 2, monster 2 attacks monster 3, and so on, with the last monster attacking the first.

codeforcescompetitive-programmingbrute-forcegreedyimplementationmath
CF 1955G - GCD on a grid

We are given a rectangular grid of integers. A move starts at the top-left cell and ends at the bottom-right cell, and at each step we can only go either one cell down or one cell right. Every such move sequence forms a monotone path.

codeforcescompetitive-programmingbrute-forcedfs-and-similardpimplementationmathnumber-theory
CF 1973E - Cat, Fox and Swaps

Codeforces 1973E: Cat, Fox and Swaps

codeforcescompetitive-programminggraphsmathsortings