text
stringlengths
424
69.5k
### 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 Please provide a CPP coded solution to the problem described below: A kindergarten teacher Natalia Pavlovna has invented a new ball game. This game not only develops the children's physique, but also teaches them how to count. The game goes as follows. Kids stand in circle. Let's agree to think of the ch...
### Prompt Please formulate a cpp solution to the following problem: You are given a sequence a1, a2, ..., an consisting of different integers. It is required to split this sequence into the maximum number of subsequences such that after sorting integers in each of them in increasing order, the total sequence also wi...
### Prompt Your task is to create a cpp solution to the following problem: Let's define the permutation of length n as an array p = [p1, p2, ..., pn] consisting of n distinct integers from range from 1 to n. We say that this permutation maps value 1 into the value p1, value 2 into the value p2 and so on. Kyota Ootor...
### Prompt Generate a Cpp solution to the following problem: problem Santa Claus came from the sky to JOI town this year as well. Since every house in JOI has children, this Santa Claus must give out presents to every house in JOI. However, this year the reindeer I am carrying is a little deaf and I can only get off...
### Prompt Your task is to create a CPP solution to the following problem: Your program fails again. This time it gets "Wrong answer on test 233" . This is the easier version of the problem. In this version 1 ≤ n ≤ 2000. You can hack this problem only if you solve and lock both problems. The problem is about a tes...
### Prompt Construct a CPP code solution to the problem outlined: Find the number of the possible tuples of sequences (A_0,A_1,...,A_N) that satisfy all of the following conditions, modulo M: * For every i (0\leq i\leq N), A_i is a sequence of length i consisting of integers between 1 and K (inclusive); * For every ...
### Prompt Please provide a CPP coded solution to the problem described below: JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way. First, he splits the Banh-mi into n part...
### Prompt Construct a Cpp code solution to the problem outlined: Gildong is playing a video game called Block Adventure. In Block Adventure, there are n columns of blocks in a row, and the columns are numbered from 1 to n. All blocks have equal heights. The height of the i-th column is represented as h_i, which is t...
### Prompt Generate a Cpp solution to the following problem: You're given a string of lower-case Latin letters. Your task is to find the length of its longest substring that can be met in the string at least twice. These occurrences can overlap (see sample test 2). Input The first input line contains the string. It...
### Prompt Please formulate a Cpp solution to the following problem: You are given an array with n integers ai and m queries. Each query is described by two integers (lj, rj). Let's define the function <image>. The function is defined for only u ≤ v. For each query print the maximal value of the function f(ax, ay) ...
### Prompt In Cpp, your task is to solve the following problem: Kevin Sun has just finished competing in Codeforces Round #334! The round was 120 minutes long and featured five problems with maximum point values of 500, 1000, 1500, 2000, and 2500, respectively. Despite the challenging tasks, Kevin was uncowed and bul...
### Prompt Construct a cpp code solution to the problem outlined: Tavas lives in Kansas. Kansas has n cities numbered from 1 to n connected with m bidirectional roads. We can travel from any city to any other city via these roads. Kansas is as strange as Tavas. So there may be a road between a city and itself or more...
### Prompt In CPP, your task is to solve the following problem: Theatre Square in the capital city of Berland has a rectangular shape with the size n × m meters. On the occasion of the city's anniversary, a decision was taken to pave the Square with square granite flagstones. Each flagstone is of the size a × a. Wha...
### Prompt Please formulate a Cpp solution to the following problem: There are n parliamentarians in Berland. They are numbered with integers from 1 to n. It happened that all parliamentarians with odd indices are Democrats and all parliamentarians with even indices are Republicans. New parliament assembly hall is a...
### Prompt Construct a cpp code solution to the problem outlined: Arseniy is already grown-up and independent. His mother decided to leave him alone for m days and left on a vacation. She have prepared a lot of food, left some money and washed all Arseniy's clothes. Ten minutes before her leave she realized that it...
### Prompt In cpp, your task is to solve the following problem: Coloring of the vertices of a tree G is called a good coloring when, for every pair of two vertices u and v painted in the same color, picking u as the root and picking v as the root would result in isomorphic rooted trees. Also, the colorfulness of G i...
### Prompt Generate a Cpp solution to the following problem: Sereja has a bracket sequence s1, s2, ..., sn, or, in other words, a string s of length n, consisting of characters "(" and ")". Sereja needs to answer m queries, each of them is described by two integers li, ri (1 ≤ li ≤ ri ≤ n). The answer to the i-th qu...
### Prompt In cpp, your task is to solve the following problem: Galya is playing one-dimensional Sea Battle on a 1 × n grid. In this game a ships are placed on the grid. Each of the ships consists of b consecutive cells. No cell can be part of two ships, however, the ships can touch each other. Galya doesn't know th...
### Prompt Please formulate a Cpp solution to the following problem: Evlampiy was gifted a rooted tree. The vertices of the tree are numbered from 1 to n. Each of its vertices also has an integer a_i written on it. For each vertex i, Evlampiy calculated c_i — the number of vertices j in the subtree of vertex i, such ...
### Prompt Your challenge is to write a CPP solution to the following problem: Santa has n candies and he wants to gift them to k kids. He wants to divide as many candies as possible between all k kids. Santa can't divide one candy into parts but he is allowed to not use some candies at all. Suppose the kid who reci...
### Prompt Please create a solution in CPP to the following problem: Misha and Vasya participated in a Codeforces contest. Unfortunately, each of them solved only one problem, though successfully submitted it at the first attempt. Misha solved the problem that costs a points and Vasya solved the problem that costs b ...
### Prompt In CPP, your task is to solve the following problem: All modern mobile applications are divided into free and paid. Even a single application developers often release two versions: a paid version without ads and a free version with ads. <image> Suppose that a paid version of the app costs p (p is an inte...
### Prompt Your task is to create a Cpp solution to the following problem: Petya has come to the math exam and wants to solve as many problems as possible. He prepared and carefully studied the rules by which the exam passes. The exam consists of n problems that can be solved in T minutes. Thus, the exam begins at t...
### Prompt Please formulate a CPP solution to the following problem: For an array b of length m we define the function f as f(b) = \begin{cases} b[1] & if m = 1 \\\ f(b[1] ⊕ b[2],b[2] ⊕ b[3],...,b[m-1] ⊕ b[m]) & otherwise, \end{cases} where ⊕ is [bitwise exclusive OR](https://en.wikipedia.org/wiki/Bitwise_...
### Prompt Please formulate a CPP solution to the following problem: Hongcow is ruler of the world. As ruler of the world, he wants to make it easier for people to travel by road within their own countries. The world can be modeled as an undirected graph with n nodes and m edges. k of the nodes are home to the gover...
### Prompt Construct a cpp code solution to the problem outlined: Tsuruga Castle, a symbol of Aizuwakamatsu City, was named "Tsuruga Castle" after Gamo Ujisato built a full-scale castle tower. You can overlook the Aizu basin from the castle tower. On a clear day, you can see Tsuruga Castle from the summit of Mt. Iimo...
### Prompt Create a solution in cpp for the following problem: You are given a bipartite graph: the first part of this graph contains n_1 vertices, the second part contains n_2 vertices, and there are m edges. The graph can contain multiple edges. Initially, each edge is colorless. For each edge, you may either leav...
### Prompt Create a solution in Cpp for the following problem: Snow Queen told Kay to form a word "eternity" using pieces of ice. Kay is eager to deal with the task, because he will then become free, and Snow Queen will give him all the world and a pair of skates. Behind the palace of the Snow Queen there is an infi...
### Prompt Please provide a cpp coded solution 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 wri...
### Prompt Construct a Cpp code solution to the problem outlined: This is the hard version of the problem. You can find the easy version in the Div. 2 contest. Both versions only differ in the number of times you can ask your friend to taste coffee. This is an interactive problem. You're considering moving to anoth...
### Prompt Your task is to create a Cpp solution to the following problem: Little X used to play a card game called "24 Game", but recently he has found it too easy. So he invented a new game. Initially you have a sequence of n integers: 1, 2, ..., n. In a single step, you can pick two of them, let's denote them a a...
### Prompt Please provide a Cpp coded solution to the problem described below: Let's define a forest as a non-directed acyclic graph (also without loops and parallel edges). One day Misha played with the forest consisting of n vertices. For each vertex v from 0 to n - 1 he wrote down two integers, degreev and sv, wer...
### Prompt Generate a Cpp solution to the following problem: <image> Recently, a wild Krakozyabra appeared at Jelly Castle. It is, truth to be said, always eager to have something for dinner. Its favorite meal is natural numbers (typically served with honey sauce), or, to be more precise, the zeros in their corresp...
### Prompt Create a solution in Cpp for the following problem: Arkady's code contains n variables. Each variable has a unique name consisting of lowercase English letters only. One day Arkady decided to shorten his code. He wants to replace each variable name with its non-empty prefix so that these new names are sti...
### Prompt Construct a Cpp code solution to the problem outlined: Little Petya very much likes playing with little Masha. Recently he has received a game called "Zero-One" as a gift from his mother. Petya immediately offered Masha to play the game with him. Before the very beginning of the game several cards are lai...
### Prompt Please formulate a CPP solution to the following problem: Lengths are measures in Baden in inches and feet. To a length from centimeters it is enough to know that an inch equals three centimeters in Baden and one foot contains 12 inches. You are given a length equal to n centimeters. Your task is to conve...
### Prompt Construct a CPP code solution to the problem outlined: There are N squares arranged in a row, numbered 1 to N from left to right. Takahashi will stack building blocks on these squares, on which there are no blocks yet. He wants to stack blocks on the squares evenly, so he will repeat the following operati...
### Prompt Your task is to create a Cpp solution to the following problem: Let T be arbitrary binary tree — tree, every vertex of which has no more than two children. Given tree is rooted, so there exists only one vertex which doesn't have a parent — it's the root of a tree. Every vertex has an integer number written...
### Prompt Develop a solution in Cpp to the problem described below: In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the "year-month-day" order, or the "month-day" order without the year. For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year. In this country, a date is cal...
### Prompt Please create a solution in cpp to the following problem: Petya has equal wooden bars of length n. He wants to make a frame for two equal doors. Each frame has two vertical (left and right) sides of length a and one top side of length b. A solid (i.e. continuous without breaks) piece of bar is needed for e...
### Prompt Create a solution in cpp for the following problem: Jack has become a soldier now. Unfortunately, he has trouble with the drill. Instead of marching beginning with the left foot and then changing legs with each step, as ordered, he keeps repeating a sequence of steps, in which he sometimes makes the wrong ...
### Prompt In CPP, your task is to solve the following problem: You are given two positive integer numbers x and y. An array F is called an y-factorization of x iff the following conditions are met: * There are y elements in F, and all of them are integer numbers; * <image>. You have to count the number of ...
### Prompt Create a solution in CPP for the following problem: Pashmak decided to give Parmida a pair of flowers from the garden. There are n flowers in the garden and the i-th of them has a beauty number bi. Parmida is a very strange girl so she doesn't want to have the two most beautiful flowers necessarily. She wa...
### Prompt Generate a cpp solution to the following problem: Monocarp has drawn a tree (an undirected connected acyclic graph) and then has given each vertex an index. All indices are distinct numbers from 1 to n. For every edge e of this tree, Monocarp has written two numbers: the maximum indices of the vertices of ...
### Prompt Your challenge is to write a CPP solution to the following problem: Little Maxim loves interesting problems. He decided to share one such problem with you. Initially there is an array a, consisting of n zeroes. The elements of the array are indexed, starting from 1. Then follow queries to change array a....
### Prompt Your challenge is to write a CPP solution to the following problem: You are given two integer sequences S and T of length N and M, respectively, both consisting of integers between 1 and 10^5 (inclusive). In how many pairs of a subsequence of S and a subsequence of T do the two subsequences are the same i...
### Prompt Please create a solution in CPP to the following problem: The only difference between easy and hard versions is constraints. Now elections are held in Berland and you want to win them. More precisely, you want everyone to vote for you. There are n voters, and two ways to convince each of them to vote for...
### Prompt Create a solution in Cpp for the following problem: You are given a permutation p_1, p_2, ..., p_n. A permutation of length n is a sequence such that each integer between 1 and n occurs exactly once in the sequence. Find the number of pairs of indices (l, r) (1 ≤ l ≤ r ≤ n) such that the value of the medi...
### Prompt Your task is to create a Cpp solution to the following problem: While Mahmoud and Ehab were practicing for IOI, they found a problem which name was Longest common subsequence. They solved it, and then Ehab challenged Mahmoud with another problem. Given two strings a and b, find the length of their longest...
### Prompt Your task is to create a Cpp solution to the following problem: The Hedgehog likes to give presents to his friend, but no less he likes to receive them. Having received another present today, the Hedgehog suddenly understood that he has no place to put it as there was no room left on the special shelf in ...
### Prompt Your challenge is to write a cpp solution to the following problem: You may know that Euclid was a mathematician. Well, as it turns out, Morpheus knew it too. So when he wanted to play a mean trick on Euclid, he sent him an appropriate nightmare. In his bad dream Euclid has a set S of n m-dimensional vec...
### Prompt Please provide a cpp coded solution to the problem described below: Kate has a set S of n integers \{1, ..., n\} . She thinks that imperfection of a subset M ⊆ S is equal to the maximum of gcd(a, b) over all pairs (a, b) such that both a and b are in M and a ≠ b. Kate is a very neat girl and for each k...
### Prompt Please formulate a CPP solution to the following problem: Acacius is studying strings theory. Today he came with the following problem. You are given a string s of length n consisting of lowercase English letters and question marks. It is possible to replace question marks with lowercase English letters i...
### Prompt Please formulate a cpp solution to the following problem: Slime has a sequence of positive integers a_1, a_2, …, a_n. In one operation Orac can choose an arbitrary subsegment [l … r] of this sequence and replace all values a_l, a_{l + 1}, …, a_r to the value of median of \\{a_l, a_{l + 1}, …, a_r\}. In t...
### Prompt Construct a cpp code solution to the problem outlined: You are given a graph with 3 ⋅ n vertices and m edges. You are to find a matching of n edges, or an independent set of n vertices. A set of edges is called a matching if no two edges share an endpoint. A set of vertices is called an independent set i...
### Prompt Your challenge is to write a cpp solution to the following problem: In the beginning of the new year Keivan decided to reverse his name. He doesn't like palindromes, so he changed Naviek to Navick. He is too selfish, so for a given n he wants to obtain a string of n characters, each of which is either 'a'...
### Prompt Create a solution in Cpp for the following problem: Vasya is a regular participant at programming contests and is already experienced in finding important sentences in long statements. Of course, numbers constraints are important — factorization of a number less than 1000000 is easier than of a number less...
### Prompt Please formulate a cpp solution to the following problem: There is a bus route as shown in Figure 1. There are 10 stops, each numbered 0-9. The bus turns back at stop 0, but the other side is a circulation route, which circulates in the order of 5 → 6 → 7 → 8 → 9 → 5 as shown in the figure. <image> For ...
### Prompt Create a solution in CPP for the following problem: Gerald got a very curious hexagon for his birthday. The boy found out that all the angles of the hexagon are equal to <image>. Then he measured the length of its sides, and found that each of them is equal to an integer number of centimeters. There the pr...
### Prompt Construct a CPP code solution to the problem outlined: Two players, A and B, play the game using cards with numbers from 0 to 9. First, the two arrange the given n cards face down in a horizontal row. After that, the two players turn their cards face up one by one from the left, and the owner of the card w...
### Prompt In Cpp, your task is to solve the following problem: There is a stack of N cards, each of which has a non-negative integer written on it. The integer written on the i-th card from the top is A_i. Snuke will repeat the following operation until two cards remain: * Choose three consecutive cards from the s...
### Prompt Your task is to create a Cpp solution to the following problem: The following sorting operation is repeated for the stacked blocks as shown in Fig. A. 1. Stack all the bottom blocks (white blocks in Figure a) on the right edge (the remaining blocks will automatically drop one step down, as shown in Figure...
### Prompt Please provide a CPP coded solution to the problem described below: Example Input anagram grandmother Output 4 ### Response ```cpp #include <bits/stdc++.h> using namespace std; #define for_(i,a,b) for(int i=(a);i<(b);++i) #define for_rev(i,a,b) for(int i=(a);i>=(b);--i) typedef unsigned long long u...
### Prompt Please formulate a Cpp solution to the following problem: This is an interactive problem. In the interaction section below you will see the information about flushing the output. In this problem, you will be playing a game with Hongcow. How lucky of you! Hongcow has a hidden n by n matrix M. Let Mi, j de...
### Prompt Develop a solution in CPP to the problem described below: Recall that the permutation is an array consisting of n distinct integers from 1 to n in arbitrary order. For example, [2,3,1,5,4] is a permutation, but [1,2,2] is not a permutation (2 appears twice in the array) and [1,3,4] is also not a permutatio...
### Prompt Please formulate a cpp solution to the following problem: There are n students at Berland State University. Every student has two skills, each measured as a number: ai — the programming skill and bi — the sports skill. It is announced that an Olympiad in programming and sports will be held soon. That's wh...
### Prompt Your task is to create a cpp solution to the following problem: It is Borya's eleventh birthday, and he has got a great present: n cards with numbers. The i-th card has the number ai written on it. Borya wants to put his cards in a row to get one greater number. For example, if Borya has cards with numbers...
### Prompt Your challenge is to write a CPP solution to the following problem: You've got a rectangular table with length a and width b and the infinite number of plates of radius r. Two players play the following game: they take turns to put the plates on the table so that the plates don't lie on each other (but the...
### Prompt Develop a solution in cpp to the problem described below: Evi has N integers a_1,a_2,..,a_N. His objective is to have N equal integers by transforming some of them. He may transform each integer at most once. Transforming an integer x into another integer y costs him (x-y)^2 dollars. Even if a_i=a_j (i≠j)...
### Prompt Generate a CPP solution to the following problem: Given are a prime number p and a sequence of p integers a_0, \ldots, a_{p-1} consisting of zeros and ones. Find a polynomial of degree at most p-1, f(x) = b_{p-1} x^{p-1} + b_{p-2} x^{p-2} + \ldots + b_0, satisfying the following conditions: * For each i ...
### Prompt Create a solution in CPP for the following problem: "This problem is rubbish! There is not statement, and there are only 5 test cases. The problemsetter took liberties with this problem!" — people complained in the comments to one round on Codeforces. And even more... No, wait, the checker for the problem ...
### Prompt Develop a solution in Cpp to the problem described below: Diameter of a Tree Given a tree T with non-negative weight, find the diameter of the tree. The diameter of a tree is the maximum distance between two nodes in a tree. Constraints * 1 ≤ n ≤ 100,000 * 0 ≤ wi ≤ 1,000 Input n s1 t1 w1 s2 t2 w2...
### Prompt Please create a solution in CPP to the following problem: Today Peter has got an additional homework for tomorrow. The teacher has given three integers to him: n, m and k, and asked him to mark one or more squares on a square grid of size n × m. The marked squares must form a connected figure, and there ...
### Prompt Your challenge is to write a CPP solution to the following problem: You are given a string S consisting of letters `b`, `d`, `p` and `q`. Determine whether S is a mirror string. Here, a mirror string is a string S such that the following sequence of operations on S results in the same string S: 1. Revers...
### Prompt Create a solution in cpp for the following problem: The only difference between easy and hard versions is constraints. Now elections are held in Berland and you want to win them. More precisely, you want everyone to vote for you. There are n voters, and two ways to convince each of them to vote for you. ...
### Prompt Create a solution in Cpp for the following problem: Polycarp is flying in the airplane. Finally, it is his favorite time — the lunchtime. The BerAvia company stewardess is giving food consecutively to all the passengers from the 1-th one to the last one. Polycarp is sitting on seat m, that means, he will b...
### Prompt Construct a CPP code solution to the problem outlined: Two players, A and B, play the game using cards with numbers from 0 to 9. First, the two arrange the given n cards face down in a horizontal row. After that, the two players turn their cards face up one by one from the left, and the owner of the card w...
### Prompt Generate a Cpp solution to the following problem: This is the easy version of this problem. The only difference is the limit of n - the length of the input string. In this version, 1 ≤ n ≤ 2000. The hard version of this challenge is not offered in the round for the second division. Let's define a correct...
### Prompt Please create a solution in CPP to the following problem: Anu has created her own function f: f(x, y) = (x | y) - y where | denotes the [bitwise OR operation](https://en.wikipedia.org/wiki/Bitwise_operation#OR). For example, f(11, 6) = (11|6) - 6 = 15 - 6 = 9. It can be proved that for any nonnegative numb...
### Prompt Create a solution in Cpp for the following problem: Top-model Izabella participates in the competition. She wants to impress judges and show her mathematical skills. Her problem is following: for given string, consisting of only 0 and 1, tell if it's possible to remove some digits in such a way, that rema...
### Prompt Your task is to create a cpp solution to the following problem: At the end of last year, Santa Claus forgot to give Christmas presents to the children in JOI village. Therefore, I decided to deliver the chocolate cake to the children as an apology. The day to deliver is approaching tomorrow, so it's time t...
### Prompt In Cpp, your task is to solve the following problem: The stardate is 1977 and the science and art of detecting Death Stars is in its infancy. Princess Heidi has received information about the stars in the nearby solar system from the Rebel spies and now, to help her identify the exact location of the Death...
### Prompt Your task is to create a Cpp solution to the following problem: Suppose you are given two strings a and b. You can apply the following operation any number of times: choose any contiguous substring of a or b, and sort the characters in it in non-descending order. Let f(a, b) the minimum number of operation...
### Prompt Create a solution in Cpp for the following problem: There are league games and tournament games in sports competitions. In soccer league games, points are given to each of the wins, losses, and draws, and the rankings are competed based on the points. The points are win (3 points), negative (0 points), and...
### Prompt Please formulate a CPP solution to the following problem: Daisy is a senior software engineer at RainyDay, LLC. She has just implemented three new features in their product: the first feature makes their product work, the second one makes their product fast, and the third one makes their product correct. T...
### Prompt Your task is to create a CPP solution to the following problem: A string s of length n can be encrypted by the following algorithm: * iterate over all divisors of n in decreasing order (i.e. from n to 1), * for each divisor d, reverse the substring s[1 ... d] (i.e. the substring which starts at posit...
### Prompt Your challenge is to write a cpp solution to the following problem: During a New Year special offer the "Sudislavl Bars" offered n promo codes. Each promo code consists of exactly six digits and gives right to one free cocktail at the bar "Mosquito Shelter". Of course, all the promocodes differ. As the "M...
### Prompt Create a solution in Cpp for the following problem: Dreamoon loves summing up something for no reason. One day he obtains two integers a and b occasionally. He wants to calculate the sum of all nice integers. Positive integer x is called nice if <image> and <image>, where k is some integer number in range ...
### Prompt Please provide a CPP coded solution to the problem described below: Mike is a bartender at Rico's bar. At Rico's, they put beer glasses in a special shelf. There are n kinds of beer at Rico's numbered from 1 to n. i-th kind of beer has ai milliliters of foam on it. <image> Maxim is Mike's boss. Today he ...
### Prompt Construct a cpp code solution to the problem outlined: Takahashi has a string S of length N consisting of digits from `0` through `9`. He loves the prime number P. He wants to know how many non-empty (contiguous) substrings of S - there are N \times (N + 1) / 2 of them - are divisible by P when regarded a...
### Prompt Generate a Cpp solution to the following problem: In programming, hexadecimal notation is often used. In hexadecimal notation, besides the ten digits 0, 1, ..., 9, the six letters `A`, `B`, `C`, `D`, `E` and `F` are used to represent the values 10, 11, 12, 13, 14 and 15, respectively. In this problem, yo...
### Prompt Please create a solution in Cpp to the following problem: You are given k sequences of integers. The length of the i-th sequence equals to n_i. You have to choose exactly two sequences i and j (i ≠ j) such that you can remove exactly one element in each of them in such a way that the sum of the changed se...
### Prompt In CPP, your task is to solve the following problem: Johnny's younger sister Megan had a birthday recently. Her brother has bought her a box signed as "Your beautiful necklace — do it yourself!". It contains many necklace parts and some magic glue. The necklace part is a chain connecting two pearls. Colo...
### Prompt Your task is to create a cpp solution to the following problem: There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: * Choose K consecutive elements in the sequence. Then, replace the v...
### Prompt Please create a solution in Cpp to the following problem: Sereja loves number sequences very much. That's why he decided to make himself a new one following a certain algorithm. Sereja takes a blank piece of paper. Then he starts writing out the sequence in m stages. Each time he either adds a new number ...
### Prompt Create a solution in Cpp for the following problem: Little Artyom decided to study probability theory. He found a book with a lot of nice exercises and now wants you to help him with one of them. Consider two dices. When thrown each dice shows some integer from 1 to n inclusive. For each dice the probabil...
### Prompt In Cpp, your task is to solve the following problem: At the children's festival, children were dancing in a circle. When music stopped playing, the children were still standing in a circle. Then Lena remembered, that her parents gave her a candy box with exactly k candies "Wilky May". Lena is not a greedy ...
### Prompt Develop a solution in CPP to the problem described below: Write a program which reads the two dices constructed in the same way as Dice I, and determines whether these two dices are identical. You can roll a dice in the same way as Dice I, and if all integers observed from the six directions are the same a...
### Prompt Your task is to create a cpp solution to the following problem: Old MacDonald has a farm and a large potato field, (1010 + 1) × (1010 + 1) square meters in size. The field is divided into square garden beds, each bed takes up one square meter. Old McDonald knows that the Colorado potato beetle is about to...