text
stringlengths
424
69.5k
### Prompt Please formulate a cpp solution to the following problem: You are given integer n. You have to arrange numbers from 1 to 2n, using each of them exactly once, on the circle, so that the following condition would be satisfied: For every n consecutive numbers on the circle write their sum on the blackboard. ...
### Prompt Please create a solution in Cpp to the following problem: You are organizing a boxing tournament, where n boxers will participate (n is a power of 2), and your friend is one of them. All boxers have different strength from 1 to n, and boxer i wins in the match against boxer j if and only if i is stronger t...
### Prompt Please provide a CPP coded solution to the problem described below: Imagine that you have a twin brother or sister. Having another person that looks exactly like you seems very unusual. It's hard to say if having something of an alter ego is good or bad. And if you do have a twin, then you very well know w...
### Prompt Generate a cpp solution to the following problem: After winning gold and silver in IOI 2014, Akshat and Malvika want to have some fun. Now they are playing a game on a grid made of n horizontal and m vertical sticks. An intersection point is any point on the grid which is formed by the intersection of one...
### Prompt Develop a solution in Cpp to the problem described below: Genos recently installed the game Zuma on his phone. In Zuma there exists a line of n gemstones, the i-th of which has color ci. The goal of the game is to destroy all the gemstones in the line as quickly as possible. In one second, Genos is able t...
### Prompt Your task is to create a cpp solution to 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 ge...
### Prompt In cpp, your task is to solve the following problem: You are given n words, each of which consists of lowercase alphabet letters. Each word contains at least one vowel. You are going to choose some of the given words and make as many beautiful lyrics as possible. Each lyric consists of two lines. Each lin...
### Prompt Develop a solution in Cpp to the problem described below: Young Teodor enjoys drawing. His favourite hobby is drawing segments with integer borders inside his huge [1;m] segment. One day Teodor noticed that picture he just drawn has one interesting feature: there doesn't exist an integer point, that belong...
### Prompt Your challenge is to write a Cpp solution to the following problem: Misha hacked the Codeforces site. Then he decided to let all the users change their handles. A user can now change his handle any number of times. But each new handle must not be equal to any handle that is already used or that was used at...
### Prompt Create a solution in CPP for the following problem: Ralph is in the Binary Country. The Binary Country consists of n cities and (n - 1) bidirectional roads connecting the cities. The roads are numbered from 1 to (n - 1), the i-th road connects the city labeled <image> (here ⌊ xβŒ‹ denotes the x rounded down ...
### Prompt Please provide a cpp coded solution to the problem described below: Takahashi has a string S of length N consisting of lowercase English letters. On this string, he will perform the following operation K times: * Let T be the string obtained by reversing S, and U be the string obtained by concatenating S ...
### Prompt Please create a solution in CPP to the following problem: Long is a huge fan of CFC (Codeforces Fried Chicken). But the price of CFC is increasing, so he decides to breed the chicken on his own farm. His farm is presented by a rectangle grid with r rows and c columns. Some of these cells contain rice, oth...
### Prompt Your challenge is to write a Cpp solution to the following problem: This is the easier version of the problem. In this version 1 ≀ n, m ≀ 100. You can hack this problem only if you solve and lock both problems. You are given a sequence of integers a=[a_1,a_2,...,a_n] of length n. Its subsequence is obtain...
### Prompt Develop a solution in cpp to the problem described below: Little X has n distinct integers: p1, p2, ..., pn. He wants to divide all of them into two sets A and B. The following two conditions must be satisfied: * If number x belongs to set A, then number a - x must also belong to set A. * If number x...
### Prompt Generate a Cpp solution to the following problem: You have N cards. On the i-th card, an integer A_i is written. For each j = 1, 2, ..., M in this order, you will perform the following operation once: Operation: Choose at most B_j cards (possibly zero). Replace the integer written on each chosen card wit...
### Prompt Develop a solution in CPP to the problem described below: You are given circle $A$ with radius $r_a$ and with central coordinate $(x_a, y_a)$ and circle $B$ with radius $r_b$ and with central coordinate $(x_b, y_b)$. Write a program which prints: * "2" if $B$ is in $A$, * "-2" if $A$ is in $B$, * "1" if ...
### Prompt In CPP, your task is to solve the following problem: You can perfectly predict the price of a certain stock for the next N days. You would like to profit on this knowledge, but only want to transact one share of stock per day. That is, each day you will either buy one share, sell one share, or do nothing. ...
### Prompt Your task is to create a cpp solution to the following problem: In the spirit of the holidays, Saitama has given Genos two grid paths of length n (a weird gift even by Saitama's standards). A grid path is an ordered sequence of neighbouring squares in an infinite grid. Two squares are neighbouring if they ...
### Prompt Develop a solution in Cpp to the problem described below: The finalists of the "Russian Code Cup" competition in 2214 will be the participants who win in one of the elimination rounds. The elimination rounds are divided into main and additional. Each of the main elimination rounds consists of c problems, ...
### Prompt Your challenge is to write a cpp solution to the following problem: Vasya is about to take his first university exam in about several minutes. And it's not just some ordinary exam, it's on mathematical analysis. Of course, right now Vasya can only think of one thing: what the result of his talk with the ex...
### Prompt Create a solution in Cpp for the following problem: Let’s define a grid to be a set of tiles with 2 rows and 13 columns. Each tile has an English letter written in it. The letters don't have to be unique: there might be two or more tiles with the same letter written on them. Here is an example of a grid: ...
### Prompt Your challenge is to write a Cpp solution to the following problem: Problem Statement One day, you found an old scroll with strange texts on it. You revealed that the text was actually an expression denoting the position of treasure. The expression consists of following three operations: * From two poin...
### Prompt Please formulate a cpp solution to the following problem: How to make a cake you'll never eat. Ingredients. * 2 carrots * 0 calories * 100 g chocolate spread * 1 pack of flour * 1 egg Method. 1. Put calories into the mixing bowl. 2. Take carrots from refrigerator. 3. Chop carrots. ...
### Prompt Please provide a CPP coded solution to the problem described below: In 2N - 1 boxes there are apples and oranges. Your task is to choose N boxes so, that they will contain not less than half of all the apples and not less than half of all the oranges. Input The first input line contains one number T β€” am...
### Prompt Please create a solution in Cpp to the following problem: The beauty of a sequence a of length n is defined as a_1 \oplus \cdots \oplus a_n, where \oplus denotes the bitwise exclusive or (XOR). You are given a sequence A of length N. Snuke will insert zero or more partitions in A to divide it into some nu...
### Prompt Develop a solution in cpp to the problem described below: Find an n Γ— n matrix with different numbers from 1 to n2, so the sum in each row, column and both main diagonals are odd. Input The only line contains odd integer n (1 ≀ n ≀ 49). Output Print n lines with n integers. All the integers should be d...
### Prompt Please formulate a cpp solution to the following problem: A magic number is a number formed by concatenation of numbers 1, 14 and 144. We can use each of these numbers any number of times. Therefore 14144, 141414 and 1411 are magic numbers but 1444, 514 and 414 are not. You're given a number. Determine if...
### Prompt Your challenge is to write 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 ha...
### Prompt Create a solution in cpp for the following problem: Have you ever played Hanabi? If not, then you've got to try it out! This problem deals with a simplified version of the game. Overall, the game has 25 types of cards (5 distinct colors and 5 distinct values). Borya is holding n cards. The game is somewha...
### Prompt Generate a CPP solution to the following problem: This is an interactive problem. We hid from you a permutation p of length n, consisting of the elements from 1 to n. You want to guess it. To do that, you can give us 2 different indices i and j, and we will reply with p_{i} mod p_{j} (remainder of divisio...
### Prompt Develop a solution in Cpp to the problem described below: The Little Elephant has an integer a, written in the binary notation. He wants to write this number on a piece of paper. To make sure that the number a fits on the piece of paper, the Little Elephant ought to delete exactly one any digit from numbe...
### Prompt In CPP, your task is to solve the following problem: How many ways are there to choose two distinct positive integers totaling N, disregarding the order? Constraints * 1 \leq N \leq 10^6 * N is an integer. Input Input is given from Standard Input in the following format: N Output Print the answer....
### Prompt Develop a solution in Cpp to the problem described below: The whole world got obsessed with robots,and to keep pace with the progress, great Berland's programmer Draude decided to build his own robot. He was working hard at the robot. He taught it to walk the shortest path from one point to another, to rec...
### Prompt Your task is to create a cpp solution to the following problem: A lot of people in Berland hates rain, but you do not. Rain pacifies, puts your thoughts in order. By these years you have developed a good tradition β€” when it rains, you go on the street and stay silent for a moment, contemplate all around yo...
### Prompt Please formulate a Cpp solution to the following problem: Takahashi has an N \times N grid. The square at the i-th row and the j-th column of the grid is denoted by (i,j). Particularly, the top-left square of the grid is (1,1), and the bottom-right square is (N,N). An integer, 0 or 1, is written on M of t...
### Prompt In CPP, your task is to solve the following problem: Write a program which reads relations in a SNS (Social Network Service), and judges that given pairs of users are reachable each other through the network. Constraints * $2 \leq n \leq 100,000$ * $0 \leq m \leq 100,000$ * $1 \leq q \leq 10,000$ Input ...
### Prompt Develop a solution in Cpp to the problem described below: Lunar New Year is approaching, and Bob decides to take a wander in a nearby park. The park can be represented as a connected graph with n nodes and m bidirectional edges. Initially Bob is at the node 1 and he records 1 on his notebook. He can wande...
### Prompt Generate a cpp solution to the following problem: Snuke lives on an infinite two-dimensional plane. He is going on an N-day trip. At the beginning of Day 1, he is at home. His plan is described in a string S of length N. On Day i(1 ≦ i ≦ N), he will travel a positive distance in the following direction: *...
### Prompt In Cpp, your task is to solve the following problem: Dreamoon likes strings. Today he created a game about strings: String s_1, s_2, …, s_n is beautiful if and only if for each 1 ≀ i < n, s_i β‰  s_{i+1}. Initially, Dreamoon has a string a. In each step Dreamoon can choose a beautiful substring of a and re...
### Prompt Generate a cpp solution to the following problem: Cat Noku has obtained a map of the night sky. On this map, he found a constellation with n stars numbered from 1 to n. For each i, the i-th star is located at coordinates (xi, yi). No two stars are located at the same position. In the evening Noku is going...
### Prompt Construct a cpp code solution to the problem outlined: Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order ...
### Prompt In cpp, your task is to solve the following problem: An atom of element X can exist in n distinct states with energies E1 < E2 < ... < En. Arkady wants to build a laser on this element, using a three-level scheme. Here is a simplified description of the scheme. Three distinct states i, j and k are select...
### Prompt Please formulate a Cpp solution to the following problem: This is a simplified version of the task Toy Train. These two versions differ only in the constraints. Hacks for this version are disabled. Alice received a set of Toy Trainβ„’ from Bob. It consists of one train and a connected railway network of n s...
### Prompt Develop a solution in cpp to the problem described below: Everybody knows that the Berland citizens are keen on health, especially students. Berland students are so tough that all they drink is orange juice! Yesterday one student, Vasya and his mates made some barbecue and they drank this healthy drink on...
### Prompt Please provide a CPP coded solution to the problem described below: Malek is a rich man. He also is very generous. That's why he decided to split his money between poor people. A charity institute knows n poor people numbered from 1 to n. The institute gave Malek q recommendations. A recommendation is a se...
### Prompt Please formulate a Cpp solution to the following problem: Japate, while traveling through the forest of Mala, saw N bags of gold lying in a row. Each bag has some distinct weight of gold between 1 to N. Japate can carry only one bag of gold with him, so he uses the following strategy to choose a bag. Init...
### Prompt Your challenge is to write a cpp solution to the following problem: You are given a tree consisting of n vertices. A tree is a connected undirected graph with n-1 edges. Each vertex v of this tree has a color assigned to it (a_v = 1 if the vertex v is white and 0 if the vertex v is black). You have to sol...
### Prompt Please provide a Cpp coded solution to the problem described below: A Hitachi string is a concatenation of one or more copies of the string `hi`. For example, `hi` and `hihi` are Hitachi strings, while `ha` and `hii` are not. Given a string S, determine whether S is a Hitachi string. Constraints * The ...
### Prompt Construct a CPP code solution to the problem outlined: You are given two segments [l_1; r_1] and [l_2; r_2] on the x-axis. It is guaranteed that l_1 < r_1 and l_2 < r_2. Segments may intersect, overlap or even coincide with each other. <image> The example of two segments on the x-axis. Your problem is to...
### Prompt In Cpp, your task is to solve the following problem: A serious incident happened at Taro's house, which loves steamed buns. One of the three steamed buns offered at the Buddhist altar in the Japanese-style room was gone. When Taro, who was aiming for a snack someday, started an investigation to find the cr...
### Prompt Your task is to create a CPP solution to the following problem: You will turn on the air conditioner if, and only if, the temperature of the room is 30 degrees Celsius or above. The current temperature of the room is X degrees Celsius. Will you turn on the air conditioner? Constraints * -40 \leq X \leq ...
### Prompt Create a solution in cpp for the following problem: Consider a following game between two players: There is an array b_1, b_2, ..., b_k, consisting of positive integers. Initially a chip is placed into the first cell of the array, and b_1 is decreased by 1. Players move in turns. Each turn the current pla...
### Prompt Please create a solution in Cpp to the following problem: The only king stands on the standard chess board. You are given his position in format "cd", where c is the column from 'a' to 'h' and d is the row from '1' to '8'. Find the number of moves permitted for the king. Check the king's moves here https:...
### Prompt Develop a solution in Cpp to the problem described below: Taro, who aims to become a web designer, is currently training. My senior at the office tells me that the background color of this page is # ffe085, which is a color number peculiar to web design, but I can't think of what kind of color it is. This...
### Prompt Your task is to create a cpp solution to the following problem: Santa Claus has n tangerines, and the i-th of them consists of exactly ai slices. Santa Claus came to a school which has k pupils. Santa decided to treat them with tangerines. However, there can be too few tangerines to present at least one t...
### Prompt Please create a solution in cpp to the following problem: You have a pot and N ingredients. Each ingredient has a real number parameter called value, and the value of the i-th ingredient (1 \leq i \leq N) is v_i. When you put two ingredients in the pot, they will vanish and result in the formation of a ne...
### Prompt Please create a solution in Cpp to the following problem: This problem is given in two editions, which differ exclusively in the constraints on the number n. You are given an array of integers a[1], a[2], ..., a[n]. A block is a sequence of contiguous (consecutive) elements a[l], a[l+1], ..., a[r] (1 ≀ l ...
### Prompt In CPP, your task is to solve 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 numbers x...
### Prompt In cpp, your task is to solve the following problem: Vasya collects coins: he has exactly one coin for every year from 1 to n. Naturally, Vasya keeps all the coins in his collection in the order in which they were released. Once Vasya's younger brother made a change β€” he took all the coins whose release ye...
### Prompt Develop a solution in cpp to the problem described below: Codeforces user' handle color depends on his rating β€” it is red if his rating is greater or equal to 2400; it is orange if his rating is less than 2400 but greater or equal to 2200, etc. Each time participant takes part in a rated contest, his ratin...
### Prompt Please formulate a CPP solution to the following problem: There are n cities in Berland, each of them has a unique id β€” an integer from 1 to n, the capital is the one with id 1. Now there is a serious problem in Berland with roads β€” there are no roads. That is why there was a decision to build n - 1 roads...
### Prompt In CPP, your task is to solve the following problem: KleofΓ‘Ε‘ is participating in an n-thlon - a tournament consisting of n different competitions in n different disciplines (numbered 1 through n). There are m participants in the n-thlon and each of them participates in all competitions. In each of these n...
### Prompt In CPP, your task is to solve the following problem: An autumn sports festival is held. There are four events: foot race, ball-carrying, obstacle race, and relay. There are n teams participating, and we would like to commend the team with the shortest total time in this 4th event as the "winner", the next ...
### Prompt Create a solution in Cpp for the following problem: We have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N. We will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7). Constraints * 1 \leq N \leq 2\times 10^5 * 1 \leq K \leq N+1 ...
### Prompt In CPP, your task is to solve the following problem: You are playing a video game and you have just reached the bonus level, where the only possible goal is to score as many points as possible. Being a perfectionist, you've decided that you won't leave this level until you've gained the maximum possible nu...
### Prompt Generate a CPP solution to 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 robot...
### Prompt Develop a solution in CPP to the problem described below: You are given a tree with n vertices. You are allowed to modify the structure of the tree through the following multi-step operation: 1. Choose three vertices a, b, and c such that b is adjacent to both a and c. 2. For every vertex d other tha...
### Prompt Construct a cpp code solution to the problem outlined: The Berland Forest can be represented as an infinite cell plane. Every cell contains a tree. That is, contained before the recent events. A destructive fire raged through the Forest, and several trees were damaged by it. Precisely speaking, you have a...
### Prompt Develop a solution in cpp to the problem described below: You are given three integers k, pa and pb. You will construct a sequence with the following algorithm: Initially, start with the empty sequence. Each second, you do the following. With probability pa / (pa + pb), add 'a' to the end of the sequence....
### Prompt Please formulate a cpp solution to the following problem: However, you are playing a game using sequences to do brain teaser. In this game, you will be given a random sequence of numbers from 1 to 9 at the beginning. However, you will erase a part of it from the sequence. The rules are as follows. * From ...
### Prompt Generate a Cpp solution to the following problem: Calculate the minimum number of characters you need to change in the string s, so that it contains at least k different letters, or print that it is impossible. String s consists only of lowercase Latin letters, and it is allowed to change characters only ...
### Prompt Develop a solution in Cpp to the problem described below: A smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt. Create a program that reads the list of participant numbers and the number of fish caught and outputs the number of winners and the number of fish ca...
### Prompt Please provide a Cpp coded solution to the problem described below: This is an interactive problem. In the Wonderful Metropolis of the Future, there is no need in subway train drivers. Due to the technological progress, they were replaced by the Artificial Intelligence (AI). Unfortunately, one day the pre...
### Prompt Please formulate a cpp solution to the following problem: Twilight Sparkle once got a crystal from the Crystal Mine. A crystal of size n (n is odd; n > 1) is an n Γ— n matrix with a diamond inscribed into it. You are given an odd integer n. You need to draw a crystal of size n. The diamond cells of the mat...
### Prompt Please create a solution in Cpp to the following problem: Appleman has n cards. Each card has an uppercase letter written on it. Toastman must choose k cards from Appleman's cards. Then Appleman should give Toastman some coins depending on the chosen cards. Formally, for each Toastman's card i you should c...
### Prompt In CPP, your task is to solve the following problem: We conducted a survey on newspaper subscriptions. More specifically, we asked each of the N respondents the following two questions: * Question 1: Are you subscribing to Newspaper X? * Question 2: Are you subscribing to Newspaper Y? As the result, A ...
### Prompt Your task is to create a cpp solution to the following problem: We all know the impressive story of Robin Hood. Robin Hood uses his archery skills and his wits to steal the money from rich, and return it to the poor. There are n citizens in Kekoland, each person has ci coins. Each day, Robin Hood will tak...
### Prompt Construct a Cpp code solution to the problem outlined: The Smart Beaver from ABBYY decided to have a day off. But doing nothing the whole day turned out to be too boring, and he decided to play a game with pebbles. Initially, the Beaver has n pebbles. He arranges them in a equal rows, each row has b pebble...
### Prompt Please provide a CPP coded solution to the problem described below: Little Susie, thanks to her older brother, likes to play with cars. Today she decided to set up a tournament between them. The process of a tournament is described in the next paragraph. There are n toy cars. Each pair collides. The resul...
### Prompt In cpp, your task is to solve the following problem: You are given a node of the tree with index 1 and with weight 0. Let cnt be the number of nodes in the tree at any instant (initially, cnt is set to 1). Support Q queries of following two types: * <image> Add a new node (index cnt + 1) with weight W a...
### Prompt In cpp, your task is to solve the following problem: Tokitsukaze and her friends are trying to infiltrate a secret base built by Claris. However, Claris has been aware of that and set a bomb which is going to explode in a minute. Although they try to escape, they have no place to go after they find that th...
### Prompt Develop a solution in cpp to the problem described below: Given a set of integers (it can contain equal elements). You have to split it into two subsets A and B (both of them can contain equal elements or be empty). You have to maximize the value of mex(A)+mex(B). Here mex of a set denotes the smallest n...
### Prompt Your challenge is to write a CPP solution to the following problem: Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high. <ima...
### Prompt Develop a solution in cpp to the problem described below: Recently Vasya learned that, given two points with different x coordinates, you can draw through them exactly one parabola with equation of type y = x^2 + bx + c, where b and c are reals. Let's call such a parabola an U-shaped one. Vasya drew sever...
### Prompt Your challenge is to write a CPP solution to the following problem: Gleb ordered pizza home. When the courier delivered the pizza, he was very upset, because several pieces of sausage lay on the crust, and he does not really like the crust. The pizza is a circle of radius r and center at the origin. Pizza...
### Prompt Develop a solution in CPP to the problem described below: Anya has bought a new smartphone that uses Berdroid operating system. The smartphone menu has exactly n applications, each application has its own icon. The icons are located on different screens, one screen contains k icons. The icons from the firs...
### Prompt Your task is to create a CPP solution to the following problem: After years of hard work scientists invented an absolutely new e-reader display. The new display has a larger resolution, consumes less energy and its production is cheaper. And besides, one can bend it. The only inconvenience is highly unusua...
### Prompt Create a solution in Cpp for the following problem: Nauuo is a girl who loves playing games related to portals. One day she was playing a game as follows. In an nΓ— n grid, the rows are numbered from 1 to n from top to bottom, the columns are numbered from 1 to n from left to right. We denote a cell on th...
### Prompt Your challenge is to write a CPP solution to the following problem: A schoolboy named Vasya loves reading books on programming and mathematics. He has recently read an encyclopedia article that described the method of median smoothing (or median filter) and its many applications in science and engineering....
### Prompt Please create a solution in Cpp to the following problem: The closing ceremony of Squanch Code Cup is held in the big hall with n Γ— m seats, arranged in n rows, m seats in a row. Each seat has two coordinates (x, y) (1 ≀ x ≀ n, 1 ≀ y ≀ m). There are two queues of people waiting to enter the hall: k peopl...
### Prompt Please formulate a CPP solution to the following problem: Consider an n Γ— m grid. Initially all the cells of the grid are colored white. Lenny has painted some of the cells (at least one) black. We call a painted grid convex if one can walk from any black cell to any another black cell using a path of side...
### Prompt Please formulate a cpp solution to the following problem: You are given an undirected graph with n vertices numbered from 1 to n. Initially there are no edges. You are asked to perform some queries on the graph. Let last be the answer to the latest query of the second type, it is set to 0 before the first...
### Prompt Create a solution in CPP for the following problem: In one very large and very respectable company there is a cloakroom with a coat hanger. It is represented by n hooks, positioned in a row. The hooks are numbered with positive integers from 1 to n from the left to the right. The company workers have a ve...
### Prompt Develop a solution in CPP to the problem described below: 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 task is to create a CPP solution to the following problem: You are given an undirected graph, constisting of n vertices and m edges. Each edge of the graph has some non-negative integer written on it. Let's call a triple (u, v, s) interesting, if 1 ≀ u < v ≀ n and there is a path (possibly non-simple...
### Prompt Develop a solution in CPP to the problem described below: 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...
### Prompt Develop a solution in Cpp to the problem described below: There are infinitely many cards, numbered 1, 2, 3, ... Initially, Cards x_1, x_2, ..., x_N are face up, and the others are face down. Snuke can perform the following operation repeatedly: * Select a prime p greater than or equal to 3. Then, select...
### Prompt Please formulate a CPP solution to the following problem: Problem statement 2D, who is good at cooking, is trying to make lunch. Cooking requires all N ingredients a_ {0}, a_ {1},…, a_ {Nβˆ’1}. Now, 2D's refrigerator doesn't contain any ingredients, so I have to go to the supermarket to buy it. At the supe...
### Prompt Generate a cpp solution to the following problem: The Bitlandians are quite weird people. They have very peculiar customs. As is customary, Uncle J. wants to have n eggs painted for Bitruz (an ancient Bitland festival). He has asked G. and A. to do the work. The kids are excited because just as is custom...
### Prompt Generate a Cpp solution to the following problem: Sasha likes programming. Once, during a very long contest, Sasha decided that he was a bit tired and needed to relax. So he did. But since Sasha isn't an ordinary guy, he prefers to relax unusually. During leisure time Sasha likes to upsolve unsolved proble...