text
stringlengths
424
69.5k
### Prompt Generate a CPP solution to the following problem: You are given a text of single-space separated words, consisting of small and capital Latin letters. Volume of the word is number of capital letters in the word. Volume of the text is maximum volume of all words in the text. Calculate the volume of the gi...
### Prompt Generate a CPP solution to the following problem: Sereja has a sequence that consists of n positive integers, a1, a2, ..., an. First Sereja took a piece of squared paper and wrote all distinct non-empty non-decreasing subsequences of sequence a. Then for each sequence written on the squared paper, Sereja...
### Prompt Your task is to create a cpp solution to the following problem: Given is an integer N. Find the number of positive integers less than or equal to N that have an odd number of digits (in base ten without leading zeros). Constraints * 1 \leq N \leq 10^5 Input Input is given from Standard Input in the fol...
### Prompt In cpp, your task is to solve the following problem: Tak has N cards. On the i-th (1 \leq i \leq N) card is written an integer x_i. He is selecting one or more cards from these N cards, so that the average of the integers written on the selected cards is exactly A. In how many ways can he make his selectio...
### Prompt Please provide a Cpp coded solution to the problem described below: When Xellos was doing a practice course in university, he once had to measure the intensity of an effect that slowly approached equilibrium. A good way to determine the equilibrium intensity would be choosing a sufficiently large number of...
### Prompt In CPP, your task is to solve the following problem: Your city has n junctions. There are m one-way roads between the junctions. As a mayor of the city, you have to ensure the security of all the junctions. To ensure the security, you have to build some police checkposts. Checkposts can only be built in a...
### Prompt Please create a solution in Cpp to the following problem: You are given an integer n. You should find a list of pairs (x_1, y_1), (x_2, y_2), ..., (x_q, y_q) (1 ≀ x_i, y_i ≀ n) satisfying the following condition. Let's consider some function f: N Γ— N β†’ N (we define N as the set of positive integers). In ...
### Prompt Construct a Cpp code solution to the problem outlined: Nick is interested in prime numbers. Once he read about Goldbach problem. It states that every even integer greater than 2 can be expressed as the sum of two primes. That got Nick's attention and he decided to invent a problem of his own and call it No...
### Prompt Your task is to create a cpp solution to the following problem: You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order). Input The only line of input contains a string s of length between 1 and 105 ...
### Prompt Construct a cpp code solution to the problem outlined: Petr wants to make a calendar for current month. For this purpose he draws a table in which columns correspond to weeks (a week is seven consequent days from Monday to Sunday), rows correspond to weekdays, and cells contain dates. For example, a calend...
### Prompt In CPP, your task is to solve the following problem: Given an integer x. Your task is to find out how many positive integers n (1 ≀ n ≀ x) satisfy $$$n β‹… a^n ≑ b (mod\;p), where a, b, p$$$ are all known constants. Input The only line contains four integers a,b,p,x (2 ≀ p ≀ 10^6+3, 1 ≀ a,b < p, 1 ≀ x ≀ ...
### Prompt In cpp, your task is to solve the following problem: There is a square grid of size n Γ— n. Some cells are colored in black, all others are colored in white. In one operation you can select some rectangle and color all its cells in white. It costs min(h, w) to color a rectangle of size h Γ— w. You are to mak...
### Prompt Construct a cpp code solution to the problem outlined: A false witness that speaketh lies! You are given a sequence containing n integers. There is a variable res that is equal to 0 initially. The following process repeats k times. Choose an index from 1 to n uniformly at random. Name it x. Add to res th...
### Prompt Create a solution in cpp for the following problem: You are given a Young diagram. Given diagram is a histogram with n columns of lengths a_1, a_2, …, a_n (a_1 β‰₯ a_2 β‰₯ … β‰₯ a_n β‰₯ 1). <image> Young diagram for a=[3,2,2,2,1]. Your goal is to find the largest number of non-overlapping dominos that you can ...
### Prompt Generate a cpp solution to the following problem: After Fox Ciel won an onsite round of a programming contest, she took a bus to return to her castle. The fee of the bus was 220 yen. She met Rabbit Hanako in the bus. They decided to play the following game because they got bored in the bus. * Initially,...
### Prompt In Cpp, your task is to solve the following problem: There are n players numbered from 0 to n-1 with ranks. The i-th player has rank i. Players can form teams: the team should consist of three players and no pair of players in the team should have a conflict. The rank of the team is calculated using the f...
### Prompt Develop a solution in cpp to the problem described below: Euler is a little, cute squirrel. When the autumn comes, he collects some reserves for winter. The interesting fact is that Euler likes to collect acorns in a specific way. A tree can be described as n acorns connected by n - 1 branches, such that t...
### Prompt Develop a solution in CPP to the problem described below: Kostya is a progamer specializing in the discipline of Dota 2. Valve Corporation, the developer of this game, has recently released a new patch which turned the balance of the game upside down. Kostya, as the captain of the team, realizes that the g...
### Prompt Generate a Cpp solution to the following problem: AtCoDeer the deer found N rectangle lying on the table, each with height 1. If we consider the surface of the desk as a two-dimensional plane, the i-th rectangle i(1≀i≀N) covers the vertical range of [i-1,i] and the horizontal range of [l_i,r_i], as shown i...
### Prompt Generate a cpp solution to the following problem: You are given a directed graph, consisting of n vertices and m edges. The vertices s and t are marked as source and sink correspondingly. Additionally, there are no edges ending at s and there are no edges beginning in t. The graph was constructed in a fol...
### Prompt Generate a CPP solution to the following problem: Vanya has a table consisting of 100 rows, each row contains 100 cells. The rows are numbered by integers from 1 to 100 from bottom to top, the columns are numbered from 1 to 100 from left to right. In this table, Vanya chose n rectangles with sides that g...
### Prompt Your challenge is to write a CPP solution to the following problem: IT City administration has no rest because of the fame of the Pyramids in Egypt. There is a project of construction of pyramid complex near the city in the place called Emerald Walley. The distinction of the complex is that its pyramids wi...
### Prompt Please formulate a cpp solution to the following problem: Hanh is a famous biologist. He loves growing trees and doing experiments on his own garden. One day, he got a tree consisting of n vertices. Vertices are numbered from 1 to n. A tree with n vertices is an undirected connected graph with n-1 edges. ...
### Prompt Generate a CPP solution to the following problem: "Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B...
### Prompt Develop a solution in Cpp to the problem described below: Pavel loves grid mazes. A grid maze is an n Γ— m rectangle maze where each cell is either empty, or is a wall. You can go from one cell to another only if both cells are empty and have a common side. Pavel drew a grid maze with all empty cells formi...
### Prompt In cpp, your task is to solve the following problem: Bankopolis, the city you already know, finally got a new bank opened! Unfortunately, its security system is not yet working fine... Meanwhile hacker Leha arrived in Bankopolis and decided to test the system! Bank has n cells for clients' money. A sequen...
### Prompt Please create a solution in cpp to the following problem: In mathematical terms, the sequence Fn of Fibonacci numbers is defined by the recurrence relation F1 = 1; F2 = 1; Fn = Fn - 1 + Fn - 2 (n > 2). DZY loves Fibonacci numbers very much. Today DZY gives you an array consisting of n integers: a1, a2, ...
### Prompt Create a solution in CPP for the following problem: Bizon the Champion isn't just attentive, he also is very hardworking. Bizon the Champion decided to paint his old fence his favorite color, orange. The fence is represented as n vertical planks, put in a row. Adjacent planks have no gap between them. The...
### Prompt Please create a solution in Cpp to the following problem: Many of you must be familiar with the Google Code Jam round rules. Let us remind you of some key moments that are crucial to solving this problem. During the round, the participants are suggested to solve several problems, each divided into two subp...
### Prompt Your challenge is to write a cpp solution to the following problem: The city of Kyoto is well-known for its Chinese plan: streets are either North-South or East-West. Some streets are numbered, but most of them have real names. Crossings are named after the two streets crossing there, e.g. Kawaramachi-Sanj...
### Prompt Construct a CPP code solution to the problem outlined: Given a positive integer m, we say that a sequence x_1, x_2, ..., x_n of positive integers is m-cute if for every index i such that 2 ≀ i ≀ n it holds that x_i = x_{i - 1} + x_{i - 2} + ... + x_1 + r_i for some positive integer r_i satisfying 1 ≀ r_i ≀...
### Prompt Generate a Cpp solution to the following problem: N people are arranged in a row from left to right. You are given a string S of length N consisting of `0` and `1`, and a positive integer K. The i-th person from the left is standing on feet if the i-th character of S is `0`, and standing on hands if that...
### Prompt Your task is to create a cpp solution to the following problem: The final round of Bayan Programming Contest will be held in Tehran, and the participants will be carried around with a yellow bus. The bus has 34 passenger seats: 4 seats in the last row and 3 seats in remaining rows. <image> The event coo...
### Prompt Please create a solution in CPP to the following problem: <image> Some time ago Slastyona the Sweetmaid decided to open her own bakery! She bought required ingredients and a wonder-oven which can bake several types of cakes, and opened the bakery. Soon the expenses started to overcome the income, so Slas...
### Prompt Construct a cpp code solution to the problem outlined: In the official contest this problem has a different statement, for which jury's solution was working incorrectly, and for this reason it was excluded from the contest. This mistake have been fixed and the current given problem statement and model solu...
### Prompt Please provide a CPP coded solution to the problem described below: Arpa is researching the Mexican wave. There are n spectators in the stadium, labeled from 1 to n. They start the Mexican wave at time 0. * At time 1, the first spectator stands. * At time 2, the second spectator stands. * ... ...
### Prompt Construct a CPP code solution to the problem outlined: You are given a string S of length N consisting of lowercase English letters, and an integer K. Print the string obtained by replacing every character in S that differs from the K-th character of S, with `*`. Constraints * 1 \leq K \leq N\leq 10 * S ...
### Prompt Develop a solution in cpp to the problem described below: Polycarp is practicing his problem solving skill. He has a list of n problems with difficulties a_1, a_2, ..., a_n, respectively. His plan is to practice for exactly k days. Each day he has to solve at least one problem from his list. Polycarp solve...
### Prompt Develop a solution in cpp to the problem described below: You are given an undirected graph consisting of n vertices. A number is written on each vertex; the number on vertex i is a_i. Initially there are no edges in the graph. You may add some edges to this graph, but you have to pay for them. The cost o...
### Prompt Please provide a CPP coded solution to the problem described below: Polycarpus has a ribbon, its length is n. He wants to cut the ribbon in a way that fulfils the following two conditions: * After the cutting each ribbon piece should have length a, b or c. * After the cutting the number of ribbon pi...
### Prompt Your task is to create a Cpp solution to the following problem: Mashmokh's boss, Bimokh, didn't like Mashmokh. So he fired him. Mashmokh decided to go to university and participate in ACM instead of finding a new job. He wants to become a member of Bamokh's team. In order to join he was given some programm...
### Prompt Generate a cpp solution to the following problem: Adilbek was assigned to a special project. For Adilbek it means that he has n days to run a special program and provide its results. But there is a problem: the program needs to run for d days to calculate the results. Fortunately, Adilbek can optimize the...
### Prompt Develop a solution in Cpp to the problem described below: Grigory loves strings. Recently he found a metal strip on a loft. The strip had length n and consisted of letters "V" and "K". Unfortunately, rust has eaten some of the letters so that it's now impossible to understand which letter was written. Gri...
### Prompt Construct a CPP code solution to the problem outlined: A ski base is planned to be built in Walrusland. Recently, however, the project is still in the constructing phase. A large land lot was chosen for the construction. It contains n ski junctions, numbered from 1 to n. Initially the junctions aren't conn...
### Prompt Develop a solution in cpp to the problem described below: Chaneka has a hobby of playing with animal toys. Every toy has a different fun value, a real number. Chaneka has four boxes to store the toys with specification: * The first box stores toys with fun values in range of (-∞,-1]. * The second bo...
### Prompt Please formulate a Cpp solution to the following problem: The door of Snuke's laboratory is locked with a security code. The security code is a 4-digit number. We say the security code is hard to enter when it contains two consecutive digits that are the same. You are given the current security code S. I...
### Prompt Construct a cpp code solution to the problem outlined: Oleg's favorite subjects are History and Math, and his favorite branch of mathematics is division. To improve his division skills, Oleg came up with t pairs of integers p_i and q_i and for each pair decided to find the greatest integer x_i, such that:...
### Prompt Please create a solution in Cpp to the following problem: Professor Matsuzaki is a scientist studying the truth of the universe. Life, the universe, all the answers are said to be 42, but Professor Matsuzaki thinks that this alone is not enough to elucidate the truth of the universe. Professor Matsuzaki be...
### Prompt Please formulate a cpp solution to the following problem: Tanya has n candies numbered from 1 to n. The i-th candy has the weight a_i. She plans to eat exactly n-1 candies and give the remaining candy to her dad. Tanya eats candies in order of increasing their numbers, exactly one candy per day. Your tas...
### Prompt Please provide a Cpp coded solution to the problem described below: Robbers, who attacked the Gerda's cab, are very successful in covering from the kingdom police. To make the goal of catching them even harder, they use their own watches. First, as they know that kingdom police is bad at math, robbers use...
### Prompt Develop a solution in CPP to the problem described below: There is a pond with a rectangular shape. The pond is divided into a grid with H rows and W columns of squares. We will denote the square at the i-th row from the top and j-th column from the left by (i,\ j). Some of the squares in the pond contain...
### Prompt In cpp, your task is to solve the following problem: Little C loves number Β«3Β» very much. He loves all things about it. Now he is playing a game on a chessboard of size n Γ— m. The cell in the x-th row and in the y-th column is called (x,y). Initially, The chessboard is empty. Each time, he places two ches...
### Prompt Please formulate a cpp solution to the following problem: Alice got an array of length n as a birthday present once again! This is the third year in a row! And what is more disappointing, it is overwhelmengly boring, filled entirely with zeros. Bob decided to apply some changes to the array to cheer up A...
### Prompt Generate a CPP solution to the following problem: Having endured all the hardships, Lara Croft finally found herself in a room with treasures. To her surprise she didn't find golden mountains there. Lara looked around and noticed on the floor a painted table n Γ— m panels in size with integers written on th...
### Prompt Please create a solution in cpp to the following problem: Petya and Vasya arranged a game. The game runs by the following rules. Players have a directed graph consisting of n vertices and m edges. One of the vertices contains a chip. Initially the chip is located at vertex s. Players take turns moving the ...
### Prompt In cpp, your task is to solve the following problem: The sequence is called ordered if it is non-decreasing or non-increasing. For example, sequnces [3, 1, 1, 0] and [1, 2, 3, 100] are ordered, but the sequence [1, 3, 3, 1] is not. You are given a sequence of numbers. You are to find it's shortest subseque...
### Prompt Construct a cpp code solution to the problem outlined: 1000000000000001 dogs suddenly appeared under the roof of Roger's house, all of which he decided to keep. The dogs had been numbered 1 through 1000000000000001, but he gave them new names, as follows: * the dogs numbered 1,2,\cdots,26 were respectivel...
### Prompt Please create a solution in CPP to the following problem: Today, hedgehog Filya went to school for the very first time! Teacher gave him a homework which Filya was unable to complete without your help. Filya is given an array of non-negative integers a1, a2, ..., an. First, he pick an integer x and then h...
### Prompt In Cpp, your task is to solve the following problem: In late autumn evening n robots gathered in the cheerful company of friends. Each robot has a unique identifier β€” an integer from 1 to 109. At some moment, robots decided to play the game "Snowball". Below there are the rules of this game. First, all ro...
### Prompt Please formulate a cpp solution to the following problem: Reziba has many magic gems. Each magic gem can be split into M normal gems. The amount of space each magic (and normal) gem takes is 1 unit. A normal gem cannot be split. Reziba wants to choose a set of magic gems and split some of them, so the tot...
### Prompt Please provide a cpp coded solution to the problem described below: Everyone loves a freebie. Especially students. It is well-known that if in the night before exam a student opens window, opens the student's record-book and shouts loudly three times "Fly, freebie, fly!" β€” then flown freebie helps him to ...
### Prompt Construct a cpp code solution to the problem outlined: You are given a string q. A sequence of k strings s1, s2, ..., sk is called beautiful, if the concatenation of these strings is string q (formally, s1 + s2 + ... + sk = q) and the first characters of these strings are distinct. Find any beautiful sequ...
### Prompt Please formulate a Cpp solution to the following problem: Two children are playing tag on a number line. (In the game of tag, the child called "it" tries to catch the other child.) The child who is "it" is now at coordinate A, and he can travel the distance of V per second. The other child is now at coordi...
### Prompt Please create a solution in Cpp to the following problem: There are 2N squares arranged from left to right. You are given a string of length 2N representing the color of each of the squares. The color of the i-th square from the left is black if the i-th character of S is `B`, and white if that character ...
### Prompt Your challenge is to write a Cpp solution to the following problem: You are given an undirected unweighted connected graph consisting of n vertices and m edges. It is guaranteed that there are no self-loops or multiple edges in the given graph. Your task is to choose at most ⌊n/2βŒ‹ vertices in this graph s...
### Prompt Your challenge is to write a cpp solution to the following problem: Oscolcovo city has a campus consisting of n student dormitories, n universities and n military offices. Initially, the i-th dormitory belongs to the i-th university and is assigned to the i-th military office. Life goes on and the campus ...
### Prompt Generate a cpp solution to the following problem: You are working for an amusement park as an operator of an obakeyashiki, or a haunted house, in which guests walk through narrow and dark corridors. The house is proud of their lively ghosts, which are actually robots remotely controlled by the operator, hi...
### Prompt In Cpp, your task is to solve the following problem: Luke Skywalker got locked up in a rubbish shredder between two presses. R2D2 is already working on his rescue, but Luke needs to stay alive as long as possible. For simplicity we will assume that everything happens on a straight line, the presses are ini...
### Prompt Please provide a CPP coded solution to the problem described below: The city of Fishtopia can be imagined as a grid of 4 rows and an odd number of columns. It has two main villages; the first is located at the top-left cell (1,1), people who stay there love fishing at the Tuna pond at the bottom-right cell...
### Prompt Please create a solution in Cpp to the following problem: You are given an integer number n. The following algorithm is applied to it: 1. if n = 0, then end algorithm; 2. find the smallest prime divisor d of n; 3. subtract d from n and go to step 1. Determine the number of subtrations the algo...
### Prompt Construct a Cpp code solution to the problem outlined: Gildong owns a bulgogi restaurant. The restaurant has a lot of customers, so many of them like to make a reservation before visiting it. Gildong tries so hard to satisfy the customers that he even memorized all customers' preferred temperature ranges!...
### Prompt Create a solution in Cpp for the following problem: This is the easy version of the problem. The difference between the versions is that the easy version has no swap operations. You can make hacks only if all versions of the problem are solved. Pikachu is a cute and friendly pokΓ©mon living in the wild pik...
### Prompt Construct a cpp code solution to the problem outlined: You are given three integers A, B and C. Determine if there exists an equilateral triangle whose sides have lengths A, B and C. Constraints * All values in input are integers. * 1 \leq A,B,C \leq 100 Input Input is given from Standard Input in the...
### Prompt Develop a solution in CPP to the problem described below: Two beavers, Timur and Marsel, play the following game. There are n logs, each of exactly m meters in length. The beavers move in turns. For each move a beaver chooses a log and gnaws it into some number (more than one) of equal parts, the length o...
### Prompt Your challenge is to write a Cpp solution to the following problem: Kostya is a progamer specializing in the discipline of Dota 2. Valve Corporation, the developer of this game, has recently released a new patch which turned the balance of the game upside down. Kostya, as the captain of the team, realizes ...
### Prompt Create a solution in cpp for the following problem: You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq...
### Prompt Please formulate a Cpp solution to the following problem: Factorize a given integer n. Constraints * 2 ≀ n ≀ 109 Input n An integer n is given in a line. Output Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the pri...
### Prompt Please create a solution in cpp to the following problem: Polycarpus enjoys studying Berland hieroglyphs. Once Polycarp got hold of two ancient Berland pictures, on each of which was drawn a circle of hieroglyphs. We know that no hieroglyph occurs twice in either the first or the second circle (but in can ...
### Prompt Please create a solution in cpp to the following problem: Alice has a string consisting of characters 'A', 'B' and 'C'. Bob can use the following transitions on any substring of our string in any order any number of times: * A <image> BC * B <image> AC * C <image> AB * AAA <image> empty string ...
### Prompt Your task is to create a CPP solution to the following problem: Bertown is a city with n buildings in a straight line. The city's security service discovered that some buildings were mined. A map was compiled, which is a string of length n, where the i-th character is "1" if there is a mine under the buil...
### Prompt Develop a solution in CPP to the problem described below: Little Petya likes permutations a lot. Recently his mom has presented him permutation q1, q2, ..., qn of length n. A permutation a of length n is a sequence of integers a1, a2, ..., an (1 ≀ ai ≀ n), all integers there are distinct. There is only ...
### Prompt Develop a solution in cpp to the problem described below: In a galaxy far, far away Lesha the student has just got to know that he has an exam in two days. As always, he hasn't attended any single class during the previous year, so he decided to spend the remaining time wisely. Lesha knows that today he c...
### Prompt Construct a CPP code solution to the problem outlined: You are given an integer sequence of length N, a_1,a_2,...,a_N. For each 1≀i≀N, you have three choices: add 1 to a_i, subtract 1 from a_i or do nothing. After these operations, you select an integer X and count the number of i such that a_i=X. Maxim...
### Prompt Generate a Cpp solution to the following problem: Mahmoud and Ehab play a game called the even-odd game. Ehab chooses his favorite integer n and then they take turns, starting from Mahmoud. In each player's turn, he has to choose an integer a and subtract it from n such that: * 1 ≀ a ≀ n. * If it's M...
### Prompt Develop a solution in Cpp to the problem described below: You are given n numbers a_1, a_2, …, a_n. Is it possible to arrange them in a circle in such a way that every number is strictly less than the sum of its neighbors? For example, for the array [1, 4, 5, 6, 7, 8], the arrangement on the left is valid...
### Prompt Please formulate a CPP solution to the following problem: N problems have been chosen by the judges, now it's time to assign scores to them! Problem i must get an integer score A_i between 1 and N, inclusive. The problems have already been sorted by difficulty: A_1 \le A_2 \le \ldots \le A_N must hold. Di...
### Prompt Please create a solution in CPP to the following problem: We start with a permutation a_1, a_2, …, a_n and with an empty array b. We apply the following operation k times. On the i-th iteration, we select an index t_i (1 ≀ t_i ≀ n-i+1), remove a_{t_i} from the array, and append one of the numbers a_{t_i-1...
### Prompt Construct a CPP code solution to the problem outlined: Gildong recently learned how to find the [longest increasing subsequence](https://en.wikipedia.org/wiki/Longest_increasing_subsequence) (LIS) in O(nlog{n}) time for a sequence of length n. He wants to test himself if he can implement it correctly, but ...
### Prompt Create a solution in Cpp for the following problem: You are given a string s and should process m queries. Each query is described by two 1-based indices li, ri and integer ki. It means that you should cyclically shift the substring s[li... ri] ki times. The queries should be processed one after another in...
### Prompt Generate a CPP solution to the following problem: King of Berland Berl IV has recently died. Hail Berl V! As a sign of the highest achievements of the deceased king the new king decided to build a mausoleum with Berl IV's body on the main square of the capital. The mausoleum will be constructed from 2n bl...
### Prompt Please formulate a Cpp solution to the following problem: This is an interactive problem. Jury has hidden a permutation p of integers from 0 to n - 1. You know only the length n. Remind that in permutation all integers are distinct. Let b be the inverse permutation for p, i.e. pbi = i for all i. The only...
### Prompt In cpp, your task is to solve the following problem: Furik loves writing all sorts of problems, especially such that he can't solve himself. You've got one of his problems, the one Furik gave to Rubik. And Rubik asks you to solve it. There is integer n and array a, consisting of ten integers, indexed by n...
### Prompt Your task is to create a Cpp solution to the following problem: You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}....
### Prompt Your challenge is to write a Cpp solution to the following problem: Boboniu gives you * r red balls, * g green balls, * b blue balls, * w white balls. He allows you to do the following operation as many times as you want: * Pick a red ball, a green ball, and a blue ball and then change ...
### Prompt Construct a Cpp code solution to the problem outlined: problem At the JOI pasta shop, the recommended pasta for lunch and the set menu of freshly squeezed juice are popular. When ordering this set menu, choose one from each of the three pasta and two juices of the day. The price is the total price of past...
### Prompt Please provide a Cpp coded solution to the problem described below: You are given a tree (a connected undirected graph without cycles) of n vertices. Each of the n - 1 edges of the tree is colored in either black or red. You are also given an integer k. Consider sequences of k vertices. Let's call a seque...
### Prompt Your challenge is to write a Cpp solution to the following problem: You are given a table consisting of n rows and m columns. Each cell of the table contains a number, 0 or 1. In one move we can choose some row of the table and cyclically shift its values either one cell to the left, or one cell to the rig...
### Prompt Generate a CPP solution to the following problem: Dima has a birthday soon! It's a big day! Saryozha's present to Dima is that Seryozha won't be in the room and won't disturb Dima and Inna as they celebrate the birthday. Inna's present to Dima is a stack, a queue and a deck. Inna wants her present to show...
### Prompt Please provide a Cpp coded solution to the problem described below: Snark and Philip are preparing the problemset for the upcoming pre-qualification round for semi-quarter-finals. They have a bank of n problems, and they want to select any non-empty subset of it as a problemset. k experienced teams are pa...
### Prompt Please formulate a Cpp solution to the following problem: In the capital city of Berland, Bertown, demonstrations are against the recent election of the King of Berland. Berland opposition, led by Mr. Ovalny, believes that the elections were not fair enough and wants to organize a demonstration at one of t...