text
stringlengths
424
69.5k
### Prompt In Cpp, your task is to solve the following problem: The restaurant AtCoder serves the following five dishes: * ABC Don (rice bowl): takes A minutes to serve. * ARC Curry: takes B minutes to serve. * AGC Pasta: takes C minutes to serve. * APC Ramen: takes D minutes to serve. * ATC Hanbagu (hamburger patty...
### Prompt Your task is to create a cpp solution to the following problem: Find out if it is possible to partition the first n positive integers into two non-empty disjoint sets S_1 and S_2 such that: gcd(sum(S_1), sum(S_2)) > 1 Here sum(S) denotes the sum of all elements present in set S and gcd means the[greates...
### Prompt Construct a Cpp code solution to the problem outlined: Taro is not good at hide-and-seek. As soon as you hide, you will find it, and it will be difficult to find the hidden child. My father, who couldn't see it, made an ultra-high performance location search system. You can use it to know exactly where you...
### Prompt Create a solution in Cpp for the following problem: Petya learned a new programming language CALPAS. A program in this language always takes one non-negative integer and returns one non-negative integer as well. In the language, there are only three commands: apply a bitwise operation AND, OR or XOR with ...
### Prompt Please provide a CPP coded solution to the problem described below: Very soon Berland will hold a School Team Programming Olympiad. From each of the m Berland regions a team of two people is invited to participate in the olympiad. The qualifying contest to form teams was held and it was attended by n Berla...
### Prompt Generate a Cpp solution to the following problem: Chouti is working on a strange math problem. There was a sequence of n positive integers x_1, x_2, …, x_n, where n is even. The sequence was very special, namely for every integer t from 1 to n, x_1+x_2+...+x_t is a square of some integer number (that is, ...
### Prompt Please create a solution in Cpp to the following problem: Developing tools for creation of locations maps for turn-based fights in a new game, Petya faced the following problem. A field map consists of hexagonal cells. Since locations sizes are going to be big, a game designer wants to have a tool for qui...
### Prompt Please provide a cpp coded solution to the problem described below: Training is indispensable for achieving good results at ICPC. Rabbit wants to win at ICPC, so he decided to practice today as well. Today's training is to develop physical strength and judgment by running on a straight road. The rabbit is...
### Prompt Please provide a cpp coded solution to the problem described below: This time the Berland Team Olympiad in Informatics is held in a remote city that can only be reached by one small bus. Bus has n passenger seats, seat i can be occupied only by a participant from the city ai. Today the bus has completed m...
### Prompt Please formulate a Cpp solution to the following problem: A: Flick input A college student who loves 2D, commonly known as 2D, replaced his long-used Galapagos mobile phone with a smartphone. 2D, who operated the smartphone for the first time, noticed that the character input method was a little different...
### Prompt Construct a CPP code solution to the problem outlined: For a given sequence of distinct non-negative integers (b_1, b_2, ..., b_k) we determine if it is good in the following way: * Consider a graph on k nodes, with numbers from b_1 to b_k written on them. * For every i from 1 to k: find such j (1 ≤ j...
### Prompt Generate a Cpp solution to the following problem: One cold winter evening Alice and her older brother Bob was sitting at home near the fireplace and giving each other interesting problems to solve. When it was Alice's turn, she told the number n to Bob and said: —Shuffle the digits in this number in order...
### Prompt In cpp, your task is to solve the following problem: You are playing the game "Arranging The Sheep". The goal of this game is to make the sheep line up. The level in the game is described by a string of length n, consisting of the characters '.' (empty space) and '*' (sheep). In one move, you can move any ...
### Prompt Please create a solution in Cpp to the following problem: Find the smallest possible sum of the digits in the decimal notation of a positive multiple of K. Constraints * 2 \leq K \leq 10^5 * K is an integer. Input Input is given from Standard Input in the following format: K Output Print the small...
### Prompt Your task is to create a Cpp solution to the following problem: You are given an array a consisting of n integers. Indices of the array start from zero (i. e. the first element is a_0, the second one is a_1, and so on). You can reverse at most one subarray (continuous subsegment) of this array. Recall tha...
### Prompt Your challenge is to write a cpp solution to the following problem: We have a point A with coordinate x = n on OX-axis. We'd like to find an integer point B (also on OX-axis), such that the absolute difference between the distance from O to B and the distance from A to B is equal to k. <image> The descrip...
### Prompt Your challenge is to write a cpp solution to the following problem: Heidi got one brain, thumbs up! But the evening isn't over yet and one more challenge awaits our dauntless agent: after dinner, at precisely midnight, the N attendees love to play a very risky game... Every zombie gets a number ni (1 ≤ ni...
### Prompt Your task is to create a Cpp solution to the following problem: Today on Informatics class Nastya learned about GCD and LCM (see links below). Nastya is very intelligent, so she solved all the tasks momentarily and now suggests you to solve one of them as well. We define a pair of integers (a, b) good, if...
### Prompt Construct a CPP code solution to the problem outlined: Vasya has a sequence of cubes and exactly one integer is written on each cube. Vasya exhibited all his cubes in a row. So the sequence of numbers written on the cubes in the order from the left to the right equals to a1, a2, ..., an. While Vasya was w...
### Prompt Please create a solution in CPP to the following problem: Little Petya very much likes arrays consisting of n integers, where each of them is in the range from 1 to 109, inclusive. Recently he has received one such array as a gift from his mother. Petya didn't like it at once. He decided to choose exactly ...
### Prompt In CPP, your task is to solve the following problem: Today, Wet Shark is given n bishops on a 1000 by 1000 grid. Both rows and columns of the grid are numbered from 1 to 1000. Rows are numbered from top to bottom, while columns are numbered from left to right. Wet Shark thinks that two bishops attack each...
### Prompt Construct a CPP code solution to the problem outlined: Yaroslav, Andrey and Roman love playing cubes. Sometimes they get together and play cubes for hours and hours! Today they got together again and they are playing cubes. Yaroslav took unit cubes and composed them into an a × a × a cube, Andrey made a ...
### Prompt Please create a solution in CPP to the following problem: In a flower bed, there are N flowers, numbered 1,2,......,N. Initially, the heights of all flowers are 0. You are given a sequence h=\\{h_1,h_2,h_3,......\\} as input. You would like to change the height of Flower k to h_k for all k (1 \leq k \leq N...
### Prompt Develop a solution in CPP to the problem described below: You are given a picture consisting of n rows and m columns. Rows are numbered from 1 to n from the top to the bottom, columns are numbered from 1 to m from the left to the right. Each cell is painted either black or white. You think that this pict...
### Prompt Create a solution in Cpp for the following problem: Your math teacher gave you the following problem: There are n segments on the x-axis, [l_1; r_1], [l_2; r_2], …, [l_n; r_n]. The segment [l; r] includes the bounds, i.e. it is a set of such x that l ≤ x ≤ r. The length of the segment [l; r] is equal to r...
### Prompt Please create a solution in CPP to the following problem: As it's the first of April, Heidi is suspecting that the news she reads today are fake, and she does not want to look silly in front of all the contestants. She knows that a newspiece is fake if it contains heidi as a subsequence. Help Heidi assess ...
### Prompt Your task is to create a cpp solution to the following problem: Toad Ilya has a rooted binary tree with vertex 1 being the root. A tree is a connected graph without cycles. A tree is rooted if one vertex is selected and called the root. A vertex u is a child of a vertex v if u and v are connected by an edg...
### Prompt Construct a Cpp code solution to the problem outlined: Vasya studies music. He has learned lots of interesting stuff. For example, he knows that there are 12 notes: C, C#, D, D#, E, F, F#, G, G#, A, B, H. He also knows that the notes are repeated cyclically: after H goes C again, and before C stands H. W...
### Prompt Create a solution in CPP for the following problem: There is a bookshelf which can fit n books. The i-th position of bookshelf is a_i = 1 if there is a book on this position and a_i = 0 otherwise. It is guaranteed that there is at least one book on the bookshelf. In one move, you can choose some contiguou...
### Prompt Your task is to create a CPP solution to the following problem: It has been decided that a programming contest sponsored by company A will be held, so we will post the notice on a bulletin board. The bulletin board is in the form of a grid with N rows and N columns, and the notice will occupy a rectangula...
### Prompt Generate a CPP solution to the following problem: Ivan wants to make a necklace as a present to his beloved girl. A necklace is a cyclic sequence of beads of different colors. Ivan says that necklace is beautiful relative to the cut point between two adjacent beads, if the chain of beads remaining after th...
### Prompt Please provide a Cpp coded solution to the problem described below: You've got string s, consisting of only lowercase English letters. Find its lexicographically maximum subsequence. We'll call a non-empty string s[p1p2... pk] = sp1sp2... spk(1 ≤ p1 < p2 < ... < pk ≤ |s|) a subsequence of string s = s1s2....
### Prompt Generate a Cpp solution to the following problem: Now Fox Ciel becomes a commander of Tree Land. Tree Land, like its name said, has n cities connected by n - 1 undirected roads, and for any two cities there always exists a path between them. Fox Ciel needs to assign an officer to each city. Each officer h...
### Prompt Please provide a Cpp coded solution to the problem described below: Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the ...
### Prompt Please provide a CPP coded solution to the problem described below: You are given an integer m as a product of integers a1, a2, ... an <image>. Your task is to find the number of distinct decompositions of number m into the product of n ordered positive integers. Decomposition into n products, given in th...
### Prompt Develop a solution in CPP to the problem described below: The goal of 8 Queens Problem is to put eight queens on a chess-board such that none of them threatens any of others. A queen threatens the squares in the same row, in the same column, or on the same diagonals as shown in the following figure. <imag...
### Prompt Your task is to create a CPP solution to the following problem: Arkady the air traffic controller is now working with n planes in the air. All planes move along a straight coordinate axis with Arkady's station being at point 0 on it. The i-th plane, small enough to be represented by a point, currently has ...
### Prompt Please formulate a CPP solution to the following problem: Let n be an integer. Consider all permutations on integers 1 to n in lexicographic order, and concatenate them into one big sequence p. For example, if n = 3, then p = [1, 2, 3, 1, 3, 2, 2, 1, 3, 2, 3, 1, 3, 1, 2, 3, 2, 1]. The length of this sequen...
### Prompt Create a solution in Cpp for the following problem: Create a program that reads the sales unit price and sales quantity and outputs the total sales amount and the average sales quantity. Input The input is given in the following format: Sales unit price, sales quantity Sales unit price, sales quantit...
### Prompt In Cpp, your task is to solve the following problem: Given are an integer K and integers a_1,\dots, a_K. Determine whether a sequence P satisfying below exists. If it exists, find the lexicographically smallest such sequence. * Every term in P is an integer between 1 and K (inclusive). * For each i=1,\dot...
### Prompt Your task is to create a Cpp solution to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times th...
### Prompt Develop a solution in CPP to the problem described below: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which so...
### Prompt Develop a solution in CPP to the problem described below: We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required. Constraints * 1 \leq N \leq 10000 * N is an i...
### Prompt Construct a CPP code solution to the problem outlined: You are given two arithmetic progressions: a1k + b1 and a2l + b2. Find the number of integers x such that L ≤ x ≤ R and x = a1k' + b1 = a2l' + b2, for some integers k', l' ≥ 0. Input The only line contains six integers a1, b1, a2, b2, L, R (0 < a1, a...
### Prompt In CPP, your task is to solve the following problem: You are given three positive (i.e. strictly greater than zero) integers x, y and z. Your task is to find positive integers a, b and c such that x = max(a, b), y = max(a, c) and z = max(b, c), or determine that it is impossible to find such a, b and c. ...
### Prompt Construct a cpp code solution to the problem outlined: Programming teacher Dmitry Olegovich is going to propose the following task for one of his tests for students: You are given a tree T with n vertices, specified by its adjacency matrix a[1... n, 1... n]. What is the output of the following pseudocode?...
### Prompt Please create a solution in CPP to the following problem: Polycarp loves ciphers. He has invented his own cipher called Right-Left. Right-Left cipher is used for strings. To encrypt the string s=s_{1}s_{2} ... s_{n} Polycarp uses the following algorithm: * he writes down s_1, * he appends the curren...
### Prompt Construct a cpp code solution to the problem outlined: You are given an array a_1, a_2, ..., a_n of integer numbers. Your task is to divide the array into the maximum number of segments in such a way that: * each element is contained in exactly one segment; * each segment contains at least one eleme...
### Prompt Please create a solution in cpp to 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 pr...
### Prompt In Cpp, your task is to solve the following problem: Niwango has N cards, numbered 1,2,\ldots,N. He will now arrange these cards in a row. Niwango wants to know if there is a way to arrange the cards while satisfying all the N conditions below. To help him, determine whether such a way exists. If the answ...
### Prompt Create a solution in cpp for the following problem: Vasya has a tree with n vertices numbered from 1 to n, and n - 1 edges numbered from 1 to n - 1. Initially each vertex contains a token with the number of the vertex written on it. Vasya plays a game. He considers all edges of the tree by increasing of t...
### Prompt Please formulate a cpp solution to the following problem: Example Input 6 3 ((())) 4 3 1 Output 2 2 1 ### Response ```cpp #include <bits/stdc++.h> using namespace std; typedef long long ll; const int MAX_N = 1 << 19; const ll INF = 1LL << 50; struct MinSegTree2{ static const ll def = INF; int n;...
### Prompt Create a solution in cpp for the following problem: Two semifinals have just been in the running tournament. Each semifinal had n participants. There are n participants advancing to the finals, they are chosen as follows: from each semifinal, we choose k people (0 ≤ 2k ≤ n) who showed the best result in th...
### Prompt Please formulate a CPP solution to the following problem: Today, Yasser and Adel are at the shop buying cupcakes. There are n cupcake types, arranged from 1 to n on the shelf, and there are infinitely many of each type. The tastiness of a cupcake of type i is an integer a_i. There are both tasty and nasty ...
### Prompt Please provide a CPP coded solution to the problem described below: Takahashi has decided to make a Christmas Tree for the Christmas party in AtCoder, Inc. A Christmas Tree is a tree with N vertices numbered 1 through N and N-1 edges, whose i-th edge (1\leq i\leq N-1) connects Vertex a_i and b_i. He woul...
### Prompt Your challenge is to write a Cpp solution to the following problem: Polycarp urgently needs a shovel! He comes to the shop and chooses an appropriate one. The shovel that Policarp chooses is sold for k burles. Assume that there is an unlimited number of such shovels in the shop. In his pocket Polycarp has...
### Prompt Your task is to create a CPP solution to the following problem: The word `internationalization` is sometimes abbreviated to `i18n`. This comes from the fact that there are 18 letters between the first `i` and the last `n`. You are given a string s of length at least 3 consisting of lowercase English lette...
### Prompt Construct a Cpp code solution to the problem outlined: We have N+M balls, each of which has an integer written on it. It is known that: * The numbers written on N of the balls are even. * The numbers written on M of the balls are odd. Find the number of ways to choose two of the N+M balls (disregarding...
### Prompt Generate a Cpp solution to the following problem: There are N slimes lining up from left to right. The colors of these slimes will be given as a string S of length N consisting of lowercase English letters. The i-th slime from the left has the color that corresponds to the i-th character of S. Adjacent sl...
### Prompt Please create a solution in cpp to the following problem: You will receive 3 points for solving this problem. Manao is designing the genetic code for a new type of algae to efficiently produce fuel. Specifically, Manao is focusing on a stretch of DNA that encodes one protein. The stretch of DNA is represe...
### Prompt Please create a solution in CPP to the following problem: Today's morning was exceptionally snowy. Meshanya decided to go outside and noticed a huge snowball rolling down the mountain! Luckily, there are two stones on that mountain. Initially, snowball is at height h and it has weight w. Each second the f...
### Prompt Create a solution in Cpp for the following problem: Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode...
### Prompt In Cpp, your task is to solve the following problem: Snuke is buying a lamp. The light of the lamp can be adjusted to m levels of brightness, represented by integers from 1 through m, by the two buttons on the remote control. The first button is a "forward" button. When this button is pressed, the brightn...
### Prompt In Cpp, your task is to solve the following problem: A group of people played a game. All players had distinct scores, which are positive integers. Takahashi knows N facts on the players' scores. The i-th fact is as follows: the A_i-th highest score among the players is B_i. Find the maximum possible num...
### Prompt Please provide a CPP coded solution to the problem described below: Vasya's birthday is approaching and Lena decided to sew a patterned handkerchief to him as a present. Lena chose digits from 0 to n as the pattern. The digits will form a rhombus. The largest digit n should be located in the centre. The di...
### Prompt Please create a solution in Cpp to the following problem: Today is August 24, one of the five Product Days in a year. A date m-d (m is the month, d is the date) is called a Product Day when d is a two-digit number, and all of the following conditions are satisfied (here d_{10} is the tens digit of the day...
### Prompt Your challenge is to write a CPP solution to the following problem: You are given two set of points. The first set is determined by the equation A1x + B1y + C1 = 0, and the second one is determined by the equation A2x + B2y + C2 = 0. Write the program which finds the number of points in the intersection o...
### Prompt Construct a CPP code solution to the problem outlined: Natasha travels around Mars in the Mars rover. But suddenly it broke down, namely — the logical scheme inside it. The scheme is an undirected tree (connected acyclic graph) with a root in the vertex 1, in which every leaf (excluding root) is an input, ...
### Prompt Your task is to create a CPP solution to the following problem: Arkady plays Gardenscapes a lot. Arkady wants to build two new fountains. There are n available fountains, for each fountain its beauty and cost are known. There are two types of money in the game: coins and diamonds, so each fountain cost can...
### Prompt Develop a solution in CPP to the problem described below: Takahashi is locked within a building. This building consists of H×W rooms, arranged in H rows and W columns. We will denote the room at the i-th row and j-th column as (i,j). The state of this room is represented by a character A_{i,j}. If A_{i,j}...
### Prompt Please provide a CPP coded solution to the problem described below: You are given an undirected unweighted connected graph consisting of n vertices and m edges. It is guaranteed that there are no self-loops or multiple edges in the given graph. Your task is to choose at most ⌊n/2⌋ vertices in this graph s...
### Prompt Generate a Cpp solution to the following problem: The Kingdom of Neva is home to two ethnic groups, the Totata and the Tutete. The biggest feature of the Totata tribe is that they eat sweet and sour pork with pineapple. However, the Tutete tribe eats vinegared pork in pineapple. These two peoples couldn't ...
### Prompt Please formulate a CPP solution to the following problem: It is never too late to play the fancy "Binary Cards" game! There is an infinite amount of cards of positive and negative ranks that are used in the game. The absolute value of any card rank is a power of two, i.e. each card has a rank of either 2k...
### Prompt Your challenge is to write a cpp solution to the following problem: Berland is facing dark times again. The army of evil lord Van de Mart is going to conquer the whole kingdom. To the council of war called by the Berland's king Valery the Severe came n knights. After long discussions it became clear that t...
### Prompt Construct a CPP code solution to the problem outlined: A Russian space traveller Alisa Selezneva, like any other schoolgirl of the late 21 century, is interested in science. She has recently visited the MIT (Moscow Institute of Time), where its chairman and the co-inventor of the time machine academician P...
### Prompt Please formulate a CPP solution to the following problem: Today on a lecture about strings Gerald learned a new definition of string equivalency. Two strings a and b of equal length are called equivalent in one of the two cases: 1. They are equal. 2. If we split string a into two halves of the same ...
### Prompt Please formulate a cpp solution to the following problem: You are an adventurer currently journeying inside an evil temple. After defeating a couple of weak zombies, you arrived at a square room consisting of tiles forming an n × n grid. The rows are numbered 1 through n from top to bottom, and the columns...
### Prompt Your challenge is to write a cpp solution to the following problem: There are n boys and m girls attending a theatre club. To set a play "The Big Bang Theory", they need to choose a group containing exactly t actors containing no less than 4 boys and no less than one girl. How many ways are there to choose...
### Prompt Develop a solution in Cpp to the problem described below: Vasya bought the collected works of a well-known Berland poet Petya in n volumes. The volumes are numbered from 1 to n. He thinks that it does not do to arrange the book simply according to their order. Vasya wants to minimize the number of the disp...
### Prompt Construct a CPP code solution to the problem outlined: Finally Fox Ciel arrived in front of her castle! She have to type a password to enter her castle. An input device attached to her castle is a bit unusual. The input device is a 1 × n rectangle divided into n square panels. They are numbered 1 to n fr...
### Prompt Construct a cpp code solution to the problem outlined: Takahashi has decided to give a string to his mother. The value of a string T is the length of the longest common subsequence of T and T', where T' is the string obtained by reversing T. That is, the value is the longest length of the following two st...
### Prompt Develop a solution in CPP to the problem described below: We have a tree with N vertices numbered 1 to N. The i-th edge in this tree connects Vertex a_i and b_i. Additionally, each vertex is painted in a color, and the color of Vertex i is c_i. Here, the color of each vertex is represented by an integer be...
### Prompt Construct a cpp code solution to the problem outlined: In some country live wizards. They love to ride trolleybuses. A city in this country has a trolleybus depot with n trolleybuses. Every day the trolleybuses leave the depot, one by one and go to the final station. The final station is at a distance of ...
### Prompt Construct a cpp code solution to the problem outlined: Bashar was practicing for the national programming contest. Because of sitting too much in front of the computer without doing physical movements and eating a lot Bashar became much fatter. Bashar is going to quit programming after the national contest...
### Prompt Your challenge is to write a cpp solution to the following problem: Snuke received an integer sequence a of length 2N-1. He arbitrarily permuted the elements in a, then used it to construct a new integer sequence b of length N, as follows: * b_1 = the median of (a_1) * b_2 = the median of (a_1, a_2, a_3)...
### Prompt Construct a CPP code solution to the problem outlined: It is known that there are k fish species in the polar ocean, numbered from 1 to k. They are sorted by non-decreasing order of their weight, which is a positive number. Let the weight of the i-th type of fish be wi, then 0 < w1 ≤ w2 ≤ ... ≤ wk holds. ...
### Prompt Please formulate a Cpp solution to the following problem: In the Bus of Characters there are n rows of seat, each having 2 seats. The width of both seats in the i-th row is w_i centimeters. All integers w_i are distinct. Initially the bus is empty. On each of 2n stops one passenger enters the bus. There a...
### Prompt In Cpp, your task is to solve the following problem: Neko loves divisors. During the latest number theory lesson, he got an interesting exercise from his math teacher. Neko has two integers a and b. His goal is to find a non-negative integer k such that the least common multiple of a+k and b+k is the smal...
### Prompt Please provide a Cpp coded solution to the problem described below: For a dictionary $M$ that stores elements formed by a pair of a string key and an integer value, perform a sequence of the following operations. Note that each key in $M$ must be unique. * insert($key$, $x$): Insert an element formed by a...
### Prompt Generate a CPP solution to the following problem: You are planning to build housing on a street. There are n spots available on the street on which you can build a house. The spots are labeled from 1 to n from left to right. In each spot, you can build a house with an integer height between 0 and h. In ea...
### Prompt Create a solution in Cpp for the following problem: Pari wants to buy an expensive chocolate from Arya. She has n coins, the value of the i-th coin is ci. The price of the chocolate is k, so Pari will take a subset of her coins with sum equal to k and give it to Arya. Looking at her coins, a question came...
### Prompt Construct a cpp code solution to the problem outlined: Radewoosh is playing a computer game. There are n levels, numbered 1 through n. Levels are divided into k regions (groups). Each region contains some positive number of consecutive levels. The game repeats the the following process: 1. If all regio...
### Prompt In cpp, your task is to solve the following problem: The mayor of Amida, the City of Miracle, is not elected like any other city. Once exhausted by long political struggles and catastrophes, the city has decided to leave the fate of all candidates to the lottery in order to choose all candidates fairly and...
### Prompt Develop a solution in CPP to the problem described below: Bajtek is learning to skate on ice. He's a beginner, so his only mode of transportation is pushing off from a snow drift to the north, east, south or west and sliding until he lands in another snow drift. He has noticed that in this way it's impossi...
### Prompt In CPP, your task is to solve the following problem: Maxim loves to fill in a matrix in a special manner. Here is a pseudocode of filling in a matrix of size (m + 1) × (m + 1): <image> Maxim asks you to count, how many numbers m (1 ≤ m ≤ n) are there, such that the sum of values in the cells in the row n...
### Prompt Your task is to create a cpp solution to the following problem: Bachgold problem is very easy to formulate. Given a positive integer n represent it as a sum of maximum possible number of prime numbers. One can prove that such representation exists for any integer greater than 1. Recall that integer k is c...
### Prompt Your challenge is to write a cpp solution to the following problem: You are looking at the floor plan of the Summer Informatics School's new building. You were tasked with SIS logistics, so you really care about travel time between different locations: it is important to know how long it would take to get ...
### Prompt Please provide a Cpp coded solution to the problem described below: Rng is going to a festival. The name of the festival is given to you as a string S, which ends with `FESTIVAL`, from input. Answer the question: "Rng is going to a festival of what?" Output the answer. Here, assume that the name of "a fe...
### Prompt In CPP, your task is to solve 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, others a...
### Prompt Please formulate a cpp solution to the following problem: The determinant of a matrix 2 × 2 is defined as follows: <image> A matrix is called degenerate if its determinant is equal to zero. The norm ||A|| of a matrix A is defined as a maximum of absolute values of its elements. You are given a matrix ...