text
stringlengths
424
69.5k
### Prompt Generate a cpp solution to the following problem: You are given a string s consisting only of lowercase Latin letters. You can rearrange all letters of this string as you wish. Your task is to obtain a good string by rearranging the letters of the given string or report that it is impossible to do it. Le...
### Prompt Please create a solution in CPP to the following problem: We have N pieces of ropes, numbered 1 through N. The length of piece i is a_i. At first, for each i (1≀i≀N-1), piece i and piece i+1 are tied at the ends, forming one long rope with N-1 knots. Snuke will try to untie all of the knots by performing ...
### Prompt Your challenge is to write a Cpp solution to the following problem: Input The only line of the input is a string of 7 characters. The first character is letter A, followed by 6 digits. The input is guaranteed to be valid (for certain definition of "valid"). Output Output a single integer. Examples I...
### Prompt Generate a Cpp solution to the following problem: AtCoDeer the deer has N square tiles. The tiles are numbered 1 through N, and the number given to each tile is written on one side of the tile. Also, each corner of each tile is painted in one of the 1000 colors, which are represented by the integers 0 betw...
### Prompt Please create a solution in Cpp to the following problem: Takahashi has A cookies, and Aoki has B cookies. Takahashi will do the following action K times: * If Takahashi has one or more cookies, eat one of his cookies. * Otherwise, if Aoki has one or more cookies, eat one of Aoki's cookies. * If they both...
### Prompt Your challenge is to write a cpp solution to the following problem: There is a tree with N vertices, numbered 1 through N. The i-th of the N-1 edges connects vertices a_i and b_i. Currently, there are A_i stones placed on vertex i. Takahashi and Aoki will play a game using this tree. First, Takahashi wil...
### Prompt Please formulate a Cpp solution to the following problem: There are n banks in the city where Vasya lives, they are located in a circle, such that any two banks are neighbouring if their indices differ by no more than 1. Also, bank 1 and bank n are neighbours if n > 1. No bank is a neighbour of itself. Va...
### Prompt Please formulate a CPP solution to the following problem: If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`. * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading ze...
### Prompt Please formulate a Cpp solution to the following problem: Xenia is a girl being born a noble. Due to the inflexibility and harshness of her family, Xenia has to find some ways to amuse herself. <image> Recently Xenia has bought n_r red gems, n_g green gems and n_b blue gems. Each of the gems has a weight...
### Prompt Please formulate a CPP solution to the following problem: Omkar and Akmar are playing a game on a circular board with n (2 ≀ n ≀ 10^6) cells. The cells are numbered from 1 to n so that for each i (1 ≀ i ≀ n-1) cell i is adjacent to cell i+1 and cell 1 is adjacent to cell n. Initially, each cell is empty. ...
### Prompt Your challenge is to write a Cpp solution to the following problem: AtCoder Inc. has decided to lock the door of its office with a 3-digit PIN code. The company has an N-digit lucky number, S. Takahashi, the president, will erase N-3 digits from S and concatenate the remaining 3 digits without changing th...
### Prompt Please provide a Cpp coded solution to the problem described below: Vasilisa the Wise from a far away kingdom got a present from her friend Helga the Wise from a farther away kingdom. The present is a surprise box, yet Vasilisa the Wise doesn't know yet what the surprise actually is because she cannot open...
### Prompt In Cpp, your task is to solve the following problem: Entrance Examination The International Competitive Programming College (ICPC) is famous for its research on competitive programming. Applicants to the college are required to take its entrance examination. The successful applicants of the examination a...
### Prompt Generate a Cpp solution to the following problem: Note that this is the first problem of the two similar problems. You can hack this problem only if you solve both problems. You are given a tree with n nodes. In the beginning, 0 is written on all edges. In one operation, you can choose any 2 distinct leav...
### Prompt Please create a solution in CPP to the following problem: There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain. Write a program which prints "YES" if a point $P$ $(x_p, y_p)$ is in the triangle and "NO" if not. Constraints You can assume that: * $ -100 \leq x_1...
### Prompt Develop a solution in CPP to the problem described below: Maria participates in a bicycle race. The speedway takes place on the shores of Lake Lucerne, just repeating its contour. As you know, the lake shore consists only of straight sections, directed to the north, south, east or west. Let's introduce a...
### Prompt Generate a Cpp solution to the following problem: You are policeman and you are playing a game with Slavik. The game is turn-based and each turn consists of two phases. During the first phase you make your move and during the second phase Slavik makes his move. There are n doors, the i-th door initially h...
### Prompt Generate a cpp solution to the following problem: You are given a prime number p, n integers a_1, a_2, …, a_n, and an integer k. Find the number of pairs of indexes (i, j) (1 ≀ i < j ≀ n) for which (a_i + a_j)(a_i^2 + a_j^2) ≑ k mod p. Input The first line contains integers n, p, k (2 ≀ n ≀ 3 β‹… 10^5, 2...
### Prompt Create a solution in cpp for the following problem: Luba thinks about watering her garden. The garden can be represented as a segment of length k. Luba has got n buckets, the i-th bucket allows her to water some continuous subsegment of garden of length exactly ai each hour. Luba can't water any parts of t...
### Prompt Generate a CPP solution to the following problem: In this problem you will write a simple code generator for a 2D programming language derived from [Brainfuck](https://en.wikipedia.org/wiki/Brainfuck). The code in this language is a rectangular grid of characters '.' and 'X'. The code is converted to a Br...
### Prompt Please formulate a Cpp solution to the following problem: Limak is a little bear who loves to play. Today he is playing by destroying block towers. He built n towers in a row. The i-th tower is made of hi identical blocks. For clarification see picture for the first sample. Limak will repeat the following...
### Prompt Your challenge is to write a cpp solution to the following problem: Ataru Oafoot of Aizu Gakuen University High School decided to play with a slot machine. When you insert a medal on this machine, three reels will start spinning and each reel will stop automatically. In a normal game (normal game), 3 meda...
### Prompt In cpp, your task is to solve the following problem: Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes. Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e...
### Prompt Please create a solution in Cpp to the following problem: There is a game called Sim Forest 2013. In this game, the player can become a forest god and raise forest animals. Animals hatch from eggs and breed. When certain conditions are met, eggs are mutated with a certain probability to give birth to new ...
### Prompt Please create a solution in Cpp 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 will be not ...
### Prompt Develop a solution in cpp to the problem described below: You have a grid with n rows and n columns. Each cell is either empty (denoted by '.') or blocked (denoted by 'X'). Two empty cells are directly connected if they share a side. Two cells (r1, c1) (located in the row r1 and column c1) and (r2, c2) ar...
### Prompt Construct a Cpp code solution to the problem outlined: In this problem you will meet the simplified model of game King of Thieves. In a new ZeptoLab game called "King of Thieves" your aim is to reach a chest with gold by controlling your character, avoiding traps and obstacles on your way. <image> An in...
### Prompt In cpp, your task is to solve the following problem: Unary is a minimalistic Brainfuck dialect in which programs are written using only one token. Brainfuck programs use 8 commands: "+", "-", "[", "]", "<", ">", "." and "," (their meaning is not important for the purposes of this problem). Unary programs...
### Prompt Please create a solution in CPP to the following problem: This problem differs from the previous one only in the absence of the constraint on the equal length of all numbers a_1, a_2, ..., a_n. A team of SIS students is going to make a trip on a submarine. Their target is an ancient treasure in a sunken s...
### Prompt In Cpp, your task is to solve the following problem: Tomash keeps wandering off and getting lost while he is walking along the streets of Berland. It's no surprise! In his home town, for any pair of intersections there is exactly one way to walk from one intersection to the other one. The capital of Berlan...
### Prompt Construct a cpp code solution to the problem outlined: You have to restore the wall. The wall consists of N pillars of bricks, the height of the i-th pillar is initially equal to h_{i}, the height is measured in number of bricks. After the restoration all the N pillars should have equal heights. You are a...
### Prompt Please formulate a cpp solution to the following problem: You are given three integers n, k, m and m conditions (l_1, r_1, x_1), (l_2, r_2, x_2), ..., (l_m, r_m, x_m). Calculate the number of distinct arrays a, consisting of n integers such that: * 0 ≀ a_i < 2^k for each 1 ≀ i ≀ n; * bitwise AND of...
### Prompt Your challenge is to write a Cpp solution to the following problem: You are given a rectangular field of n Γ— m cells. Each cell is either empty or impassable (contains an obstacle). Empty cells are marked with '.', impassable cells are marked with '*'. Let's call two empty cells adjacent if they share a si...
### Prompt Please create a solution in Cpp to the following problem: Asterix, Obelix and their temporary buddies Suffix and Prefix has finally found the Harmony temple. However, its doors were firmly locked and even Obelix had no luck opening them. A little later they found a string s, carved on a rock below the tem...
### Prompt Construct a Cpp code solution to the problem outlined: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distri...
### Prompt Please formulate a CPP solution to the following problem: Little beaver is a beginner programmer, so informatics is his favorite subject. Soon his informatics teacher is going to have a birthday and the beaver has decided to prepare a present for her. He planted n flowers in a row on his windowsill and sta...
### Prompt Please provide a CPP coded solution to the problem described below: Rudolf is on his way to the castle. Before getting into the castle, the security staff asked him a question: Given two binary numbers a and b of length n. How many different ways of swapping two digits in a (only in a, not b) so that bitw...
### Prompt Create a solution in Cpp for the following problem: The Shuseki Islands are an archipelago of 30001 small islands in the Yutampo Sea. The islands are evenly spaced along a line, numbered from 0 to 30000 from the west to the east. These islands are known to contain many treasures. There are n gems in the Sh...
### Prompt Construct a Cpp code solution to the problem outlined: One day Polycarp published a funny picture in a social network making a poll about the color of his handle. Many of his friends started reposting Polycarp's joke to their news feed. Some of them reposted the reposts and so on. These events are given a...
### Prompt Your task is to create a cpp solution to the following problem: Ivan has number b. He is sorting through the numbers a from 1 to 10^{18}, and for every a writes ([a, b])/(a) on blackboard. Here [a, b] stands for least common multiple of a and b. Ivan is very lazy, that's why this task bored him soon....
### Prompt Develop a solution in cpp to the problem described below: At many competitions that have a word Β«cupΒ» in its official name the winner is presented with an actual cup. This time the organizers of one unusual programming competition have decided to please the winner even more and to add a nameplate to the cu...
### Prompt In CPP, your task is to solve the following problem: You are given a string s consisting of n lowercase Latin letters. n is even. For each position i (1 ≀ i ≀ n) in string s you are required to change the letter on this position either to the previous letter in alphabetic order or to the next one (letters...
### Prompt Your challenge is to write a Cpp solution to the following problem: The HR manager was disappointed again. The last applicant failed the interview the same way as 24 previous ones. "Do I give such a hard task?" β€” the HR manager thought. "Just raise number 5 to the power of n and get last two digits of the ...
### Prompt In CPP, your task is to solve the following problem: Shuseki Kingdom is the world's leading nation for innovation and technology. There are n cities in the kingdom, numbered from 1 to n. Thanks to Mr. Kitayuta's research, it has finally become possible to construct teleportation pipes between two cities. ...
### Prompt Please create a solution in CPP to the following problem: Ralph has a magic field which is divided into n Γ— m blocks. That is to say, there are n rows and m columns on the field. Ralph can put an integer in each block. However, the magic field doesn't always work properly. It works only if the product of i...
### Prompt Please provide a CPP coded solution to the problem described below: You are given an array a consisting of n integers. Your task is to determine if a has some subsequence of length at least 3 that is a palindrome. Recall that an array b is called a subsequence of the array a if b can be obtained by remov...
### Prompt In CPP, your task is to solve the following problem: You're given an array a of n integers, such that a_1 + a_2 + β‹…β‹…β‹… + a_n = 0. In one operation, you can choose two different indices i and j (1 ≀ i, j ≀ n), decrement a_i by one and increment a_j by one. If i < j this operation is free, otherwise it costs...
### Prompt Develop a solution in CPP to the problem described below: After lessons Nastya decided to read a book. The book contains n chapters, going one after another, so that one page of the book belongs to exactly one chapter and each chapter contains at least one page. Yesterday evening Nastya did not manage to ...
### Prompt Please provide a CPP coded solution to the problem described below: Vasya is developing his own programming language VPL (Vasya Programming Language). Right now he is busy making the system of exceptions. He thinks that the system of exceptions must function like that. The exceptions are processed by try-...
### Prompt In CPP, your task is to solve the following problem: One day n friends gathered together to play "Mafia". During each round of the game some player must be the supervisor and other n - 1 people take part in the game. For each person we know in how many rounds he wants to be a player, not the supervisor: th...
### Prompt Create a solution in cpp for the following problem: The array a with n integers is given. Let's call the sequence of one or more consecutive elements in a segment. Also let's call the segment k-good if it contains no more than k different values. Find any longest k-good segment. As the input/output can r...
### Prompt Your challenge is to write a Cpp solution to the following problem: It is a balmy spring afternoon, and Farmer John's n cows are ruminating about link-cut cacti in their stalls. The cows, labeled 1 through n, are arranged so that the i-th cow occupies the i-th stall from the left. However, Elsie, after rea...
### Prompt Please create a solution in CPP to the following problem: Two best friends Serozha and Gena play a game. Initially there is one pile consisting of n stones on the table. During one move one pile should be taken and divided into an arbitrary number of piles consisting of a1 > a2 > ... > ak > 0 stones. The ...
### Prompt Your task is to create a cpp solution to the following problem: This problem is same as the next one, but has smaller constraints. Aki is playing a new video game. In the video game, he will control Neko, the giant cat, to fly between planets in the Catniverse. There are n planets in the Catniverse, numb...
### Prompt Create a solution in Cpp for the following problem: You are given a string s consisting of exactly n characters, and each character is either '0', '1' or '2'. Such strings are called ternary strings. Your task is to replace minimum number of characters in this string with other characters to obtain a bala...
### Prompt Create a solution in cpp for the following problem: Taro is playing with a puzzle that places numbers 1-9 in 9x9 squares. In this puzzle, you have to arrange the numbers according to the following rules. * One number appears exactly once in the same column * A number appears exactly once on the same line ...
### Prompt Please create a solution in cpp to the following problem: Example Input 4 3 1000 1 2000 2 3000 3 Output 2 3 4 4 ### Response ```cpp #include <iostream> #include <cstring> #include <vector> #include <map> #include <algorithm> using namespace std; int low[200001], hi[200001]; int main() { int n, m...
### Prompt Please create a solution in CPP to the following problem: Takahashi is going to buy N items one by one. The price of the i-th item he buys is A_i yen (the currency of Japan). He has M discount tickets, and he can use any number of them when buying an item. If Y tickets are used when buying an item price...
### Prompt Please create a solution in CPP 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 Please provide a Cpp coded solution to the problem described below: The clique problem is one of the most well-known NP-complete problems. Under some simplification it can be formulated as follows. Consider an undirected graph G. It is required to find a subset of vertices C of the maximum size such that a...
### Prompt Your task is to create a CPP solution to the following problem: Example Input 3 1 3 3 2 1 2 1 3 Output 5 ### Response ```cpp #include <iostream> #include <vector> #include <algorithm> #include <utility> #include <set> #include <map> using namespace std; typedef long long int lli; struct UnionFindTr...
### Prompt Please formulate a CPP solution to the following problem: Mahmoud and Ehab live in a country with n cities numbered from 1 to n and connected by n - 1 undirected roads. It's guaranteed that you can reach any city from any other using these roads. Each city has a number ai attached to it. We define the dis...
### Prompt Please create a solution in CPP to the following problem: You are given an undirected graph with N vertices and M edges. Here, N-1≀M≀N holds and the graph is connected. There are no self-loops or multiple edges in this graph. The vertices are numbered 1 through N, and the edges are numbered 1 through M. E...
### Prompt Construct a cpp code solution to the problem outlined: Polycarpus likes giving presents to Paraskevi. He has bought two chocolate bars, each of them has the shape of a segmented rectangle. The first bar is a1 Γ— b1 segments large and the second one is a2 Γ— b2 segments large. Polycarpus wants to give Parask...
### Prompt In CPP, your task is to solve the following problem: A group of n dancers rehearses a performance for the closing ceremony. The dancers are arranged in a row, they've studied their dancing moves and can't change positions. For some of them, a white dancing suit is already bought, for some of them β€” a black...
### Prompt Construct a cpp code solution to the problem outlined: We have a sequence of length N consisting of non-negative integers. Consider performing the following operation on this sequence until the largest element in this sequence becomes N-1 or smaller. * Determine the largest element in the sequence (if the...
### Prompt Your task is to create a Cpp solution to the following problem: This is an easier version of the problem. In this version n ≀ 1000 The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskv...
### Prompt Please create a solution in Cpp to the following problem: Recently Anton found a box with digits in his room. There are k2 digits 2, k3 digits 3, k5 digits 5 and k6 digits 6. Anton's favorite integers are 32 and 256. He decided to compose this integers from digits he has. He wants to make the sum of these...
### Prompt Please create a solution in cpp to the following problem: Bob is playing with 6-sided dice. A net of such standard cube is shown below. <image> He has an unlimited supply of these dice and wants to build a tower by stacking multiple dice on top of each other, while choosing the orientation of each dice. ...
### Prompt Your challenge is to write a Cpp solution to the following problem: Hakone Ekiden is one of the Japanese New Year's traditions. In Hakone Ekiden, 10 runners from each team aim for the goal while connecting the sashes at each relay station. In the TV broadcast, the ranking change from the previous relay sta...
### Prompt Please provide a CPP coded solution to the problem described below: A non-empty string s is called binary, if it consists only of characters "0" and "1". Let's number the characters of binary string s from 1 to the string's length and let's denote the i-th character in string s as si. Binary string s with...
### Prompt Please create a solution in cpp to the following problem: Some company is going to hold a fair in Byteland. There are n towns in Byteland and m two-way roads between towns. Of course, you can reach any town from any other town using roads. There are k types of goods produced in Byteland and every town pro...
### Prompt Create a solution in CPP for the following problem: The Bitlandians are quite weird people. They have their own problems and their own solutions. They have their own thoughts and their own beliefs, they have their own values and their own merits. They have their own dishes and their own sausages! In Bitla...
### Prompt Develop a solution in CPP to the problem described below: DLS and JLS are bored with a Math lesson. In order to entertain themselves, DLS took a sheet of paper and drew n distinct lines, given by equations y = x + p_i for some distinct p_1, p_2, …, p_n. Then JLS drew on the same paper sheet m distinct lin...
### Prompt Construct a cpp code solution to the problem outlined: It's been long after the events of the previous problems, and Karen has now moved on from student life and is looking to relocate to a new neighborhood. <image> The neighborhood consists of n houses in a straight line, labelled 1 to n from left to ri...
### Prompt Construct a CPP code solution to the problem outlined: A string is called a k-string if it can be represented as k concatenated copies of some string. For example, the string "aabaabaabaab" is at the same time a 1-string, a 2-string and a 4-string, but it is not a 3-string, a 5-string, or a 6-string and so...
### Prompt Please formulate a cpp solution to the following problem: You are given an array a consisting of n integers, and additionally an integer m. You have to choose some sequence of indices b1, b2, ..., bk (1 ≀ b1 < b2 < ... < bk ≀ n) in such a way that the value of <image> is maximized. Chosen sequence can be e...
### Prompt Create a solution in Cpp for the following problem: You're given a tree with n vertices rooted at 1. We say that there's a k-ary heap of depth m located at u if the following holds: * For m = 1 u itself is a k-ary heap of depth 1. * For m > 1 vertex u is a k-ary heap of depth m if at least k of its ...
### Prompt Your task is to create a CPP solution to the following problem: Sig has built his own keyboard. Designed for ultimate simplicity, this keyboard only has 3 keys on it: the `0` key, the `1` key and the backspace key. To begin with, he is using a plain text editor with this keyboard. This editor always displ...
### Prompt Please create a solution in CPP to the following problem: Vanya and his friends are walking along the fence of height h and they do not want the guard to notice them. In order to achieve this the height of each of the friends should not exceed h. If the height of some person is greater than h he can bend d...
### Prompt Construct a Cpp code solution to the problem outlined: There is a grid with H rows and W columns. The square at the i-th row and j-th column contains a string S_{i,j} of length 5. The rows are labeled with the numbers from 1 through H, and the columns are labeled with the uppercase English letters from `...
### Prompt Develop a solution in CPP to the problem described below: One day Sasha visited the farmer 2D and his famous magnetic farm. On this farm, the crop grows due to the influence of a special magnetic field. Maintaining of the magnetic field is provided by n machines, and the power of the i-th machine is a_i. ...
### Prompt Your task is to create a Cpp solution to the following problem: <image> At the request of a friend who started learning abacus, you decided to create a program to display the abacus beads. Create a program that takes a certain number as input and outputs a row of abacus beads. However, the number of digi...
### Prompt In Cpp, your task is to solve the following problem: There are n segments drawn on a plane; the i-th segment connects two points (x_{i, 1}, y_{i, 1}) and (x_{i, 2}, y_{i, 2}). Each segment is non-degenerate, and is either horizontal or vertical β€” formally, for every i ∈ [1, n] either x_{i, 1} = x_{i, 2} or...
### Prompt Generate a CPP solution to the following problem: Each student eagerly awaits the day he would pass the exams successfully. Thus, Vasya was ready to celebrate, but, alas, he didn't pass it. However, many of Vasya's fellow students from the same group were more successful and celebrated after the exam. Som...
### Prompt Develop a solution in CPP to the problem described below: Today is tuesday, that means there is a dispute in JOHNNY SOLVING team again: they try to understand who is Johnny and who is Solving. That's why guys asked Umnik to help them. Umnik gave guys a connected graph with n vertices without loops and mult...
### Prompt Generate a Cpp solution to the following problem: One popular website developed an unusual username editing procedure. One can change the username only by deleting some characters from it: to change the current name s, a user can pick number p and character c and delete the p-th occurrence of character c f...
### Prompt Your task is to create a Cpp solution to the following problem: You are the gym teacher in the school. There are n students in the row. And there are two rivalling students among them. The first one is in position a, the second in position b. Positions are numbered from 1 to n from left to right. Since t...
### Prompt Please formulate a Cpp solution to the following problem: Shubham has an array a of size n, and wants to select exactly x elements from it, such that their sum is odd. These elements do not have to be consecutive. The elements of the array are not guaranteed to be distinct. Tell him whether he can do so. ...
### Prompt Develop a solution in cpp to the problem described below: You are given n strings ti. Each string has cost ci. Let's define the function of string <image>, where ps, i is the number of occurrences of s in ti, |s| is the length of the string s. Find the maximal value of function f(s) over all strings. Not...
### Prompt Develop a solution in cpp to the problem described below: Andrew, Fedor and Alex are inventive guys. Now they invent the game with strings for two players. Given a group of n non-empty strings. During the game two players build the word together, initially the word is empty. The players move in turns. On ...
### Prompt Please formulate a Cpp solution to the following problem: problem You are looking for a constellation in a picture of the starry sky. The photo always contains exactly one figure with the same shape, orientation, and size as the constellation you are looking for. However, there is a possibility that extra...
### Prompt Your task is to create a cpp solution to the following problem: problem Hanako is playing with n (4 ≀ n ≀ 10) cards side by side. Each card has one integer between 1 and 99. Hanako chose k cards (2 ≀ k ≀ 4) from these cards and arranged them in a horizontal row to make an integer. How many kinds of intege...
### Prompt Your task is to create a CPP solution to the following problem: Polycarp found n segments on the street. A segment with the index i is described by two integers l_i and r_i β€” coordinates of the beginning and end of the segment, respectively. Polycarp realized that he didn't need all the segments, so he wan...
### Prompt Please formulate a Cpp solution to the following problem: A string s of length n (1 ≀ n ≀ 26) is called alphabetical if it can be obtained using the following algorithm: * first, write an empty string to s (i.e. perform the assignment s := ""); * then perform the next step n times; * at the i-th s...
### Prompt Please create a solution in CPP to the following problem: Little Mishka is a great traveller and she visited many countries. After thinking about where to travel this time, she chose XXX β€” beautiful, but little-known northern country. Here are some interesting facts about XXX: 1. XXX consists of n citi...
### Prompt Generate a CPP solution to the following problem: Some natural number was written on the board. Its sum of digits was not less than k. But you were distracted a bit, and someone changed this number to n, replacing some digits with others. It's known that the length of the number didn't change. You have to...
### Prompt Please create a solution in Cpp to the following problem: Little C loves number Β«3Β» very much. He loves all things about it. Now he has a positive integer n. He wants to split n into 3 positive integers a,b,c, such that a+b+c=n and none of the 3 integers is a multiple of 3. Help him to find a solution. I...
### Prompt Construct a cpp code solution to the problem outlined: There are N men and N women, both numbered 1, 2, \ldots, N. For each i, j (1 \leq i, j \leq N), the compatibility of Man i and Woman j is given as an integer a_{i, j}. If a_{i, j} = 1, Man i and Woman j are compatible; if a_{i, j} = 0, they are not. ...
### Prompt Your challenge is to write a cpp solution to the following problem: Professor GukiZ is concerned about making his way to school, because massive piles of boxes are blocking his way. In total there are n piles of boxes, arranged in a line, from left to right, i-th pile (1 ≀ i ≀ n) containing ai boxes. Luc...