text stringlengths 424 69.5k |
|---|
### Prompt
Please create a solution in CPP to the following problem:
In this problem MEX of a certain array is the smallest positive integer not contained in this array.
Everyone knows this definition, including Lesha. But Lesha loves MEX, so he comes up with a new problem involving MEX every day, including today.
... |
### Prompt
Construct a Cpp code solution to the problem outlined:
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 take exactly... |
### Prompt
Create a solution in cpp for the following problem:
Recently, Duff has been practicing weight lifting. As a hard practice, Malek gave her a task. He gave her a sequence of weights. Weight of i-th of them is 2wi pounds. In each step, Duff can lift some of the remaining weights and throw them away. She does ... |
### Prompt
Your task is to create a CPP solution to the following problem:
A tree is an undirected connected graph without cycles. The distance between two vertices is the number of edges in a simple path between them.
Limak is a little polar bear. He lives in a tree that consists of n vertices, numbered 1 through n... |
### Prompt
Construct a CPP code solution to the problem outlined:
Write a program to simulate rolling a dice, which can be constructed by the following net.
<image>
<image>
As shown in the figures, each face is identified by a different label from 1 to 6.
Write a program which reads integers assigned to each f... |
### Prompt
Please provide a CPP coded solution to the problem described below:
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 ne... |
### Prompt
In cpp, your task is to solve 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 cupca... |
### Prompt
Generate a CPP solution to the following problem:
Takahashi has an ability to generate a tree using a permutation (p_1,p_2,...,p_n) of (1,2,...,n), in the following process:
First, prepare Vertex 1, Vertex 2, ..., Vertex N. For each i=1,2,...,n, perform the following operation:
* If p_i = 1, do nothing.
... |
### Prompt
Please provide a Cpp coded solution to the problem described below:
Let us define a magic grid to be a square matrix of integers of size n Γ n, satisfying the following conditions.
* All integers from 0 to (n^2 - 1) inclusive appear in the matrix exactly once.
* [Bitwise XOR](https://en.wikipedia.or... |
### Prompt
Please create a solution in Cpp to the following problem:
Appleman and Toastman play a game. Initially Appleman gives one group of n numbers to the Toastman, then they start to complete the following tasks:
* Each time Toastman gets a group of numbers, he sums up all the numbers and adds this sum to the... |
### Prompt
Please formulate a cpp solution to the following problem:
For an integer n not less than 0, let us define f(n) as follows:
* f(n) = 1 (if n < 2)
* f(n) = n f(n-2) (if n \geq 2)
Given is an integer N. Find the number of trailing zeros in the decimal notation of f(N).
Constraints
* 0 \leq N \leq 10^{18... |
### Prompt
Your challenge is to write a cpp solution to the following problem:
To stay woke and attentive during classes, Karen needs some coffee!
<image>
Karen, a coffee aficionado, wants to know the optimal temperature for brewing the perfect cup of coffee. Indeed, she has spent some time reading several recipe b... |
### Prompt
Your task is to create a Cpp solution to the following problem:
A TV show called "Guess a number!" is gathering popularity. The whole Berland, the old and the young, are watching the show.
The rules are simple. The host thinks of an integer y and the participants guess it by asking questions to the host. ... |
### Prompt
Your challenge is to write a Cpp solution to the following problem:
Robot Doc is located in the hall, with n computers stand in a line, numbered from left to right from 1 to n. Each computer contains exactly one piece of information, each of which Doc wants to get eventually. The computers are equipped wit... |
### Prompt
Generate a Cpp solution to the following problem:
You are given an undirected graph that consists of n vertices and m edges. Initially, each edge is colored either red or blue. Each turn a player picks a single vertex and switches the color of all edges incident to it. That is, all red edges with an endpoi... |
### Prompt
Construct a CPP code solution to the problem outlined:
Vasya lives in a strange world. The year has n months and the i-th month has ai days. Vasya got a New Year present β the clock that shows not only the time, but also the date.
The clock's face can display any number from 1 to d. It is guaranteed that ... |
### Prompt
Create a solution in cpp for the following problem:
Let's consider equation:
x2 + s(x)Β·x - n = 0,
where x, n are positive integers, s(x) is the function, equal to the sum of digits of number x in the decimal number system.
You are given an integer n, find the smallest positive integer root of equation ... |
### Prompt
Your task is to create a cpp solution to the following problem:
You have been given n distinct integers a1, a2, ..., an. You can remove at most k of them. Find the minimum modular m (m > 0), so that for every pair of the remaining integers (ai, aj), the following unequality holds: <image>.
Input
The firs... |
### Prompt
Your challenge is to write a Cpp solution to the following problem:
Game field is represented by a line of n square cells. In some cells there are packmen, in some cells there are asterisks and the rest of the cells are empty. Packmen eat asterisks.
Before the game starts you can choose a movement directi... |
### Prompt
Construct a cpp code solution to the problem outlined:
While Mike was walking in the subway, all the stuff in his back-bag dropped on the ground. There were several fax messages among them. He concatenated these strings in some order and now he has string s.
<image>
He is not sure if this is his own back... |
### Prompt
Your challenge is to write a CPP solution to the following problem:
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 Γ 2. We are only interested in two types of squares:
1. squ... |
### Prompt
Please create a solution in Cpp to the following problem:
The king of a country loves prime numbers and gambling. The unit of currency in this country is called prime. As of November 1, 2007, Prime's cross-yen rate was just prime at 9973, so the King is overjoyed. Subsidiary coins with 1/101 prime as one s... |
### Prompt
Generate a CPP solution to the following problem:
The number 105 is quite special - it is odd but still it has eight divisors. Now, your task is this: how many odd numbers with exactly eight positive divisors are there between 1 and N (inclusive)?
Constraints
* N is an integer between 1 and 200 (inclusiv... |
### Prompt
Please formulate a Cpp solution to the following problem:
You are given two sequences a and b, both of length 2N. The i-th elements in a and b are a_i and b_i, respectively. Using these sequences, Snuke is doing the job of calculating the beauty of pairs of balanced sequences of parentheses (defined below)... |
### Prompt
Please create a solution in CPP to the following problem:
You have a string s consisting of n characters. Each character is either 0 or 1.
You can perform operations on the string. Each operation consists of two steps:
1. select an integer i from 1 to the length of the string s, then delete the charact... |
### Prompt
Please provide a cpp coded solution to the problem described below:
Old timers of Summer Informatics School can remember previous camps in which each student was given a drink of his choice on the vechorka (late-evening meal). Or may be the story was more complicated?
There are n students living in a buil... |
### Prompt
In cpp, your task is to solve the following problem:
Bessie is planning a vacation! In Cow-lifornia, there are n cities, with n-1 bidirectional roads connecting them. It is guaranteed that one can reach any city from any other city.
Bessie is considering v possible vacation plans, with the i-th one consi... |
### Prompt
Your challenge is to write a CPP solution to the following problem:
Kirito is stuck on a level of the MMORPG he is playing now. To move on in the game, he's got to defeat all n dragons that live on this level. Kirito and the dragons have strength, which is represented by an integer. In the duel between two... |
### Prompt
Create a solution in cpp for the following problem:
Two people play the following string game. Initially the players have got some string s. The players move in turns, the player who cannot make a move loses.
Before the game began, the string is written on a piece of paper, one letter per cell.
<image> ... |
### Prompt
Please create a solution in Cpp to the following problem:
There is a kangaroo at coordinate 0 on an infinite number line that runs from left to right, at time 0. During the period between time i-1 and time i, the kangaroo can either stay at his position, or perform a jump of length exactly i to the left or... |
### Prompt
In Cpp, your task is to solve the following problem:
The map of Bertown can be represented as a set of n intersections, numbered from 1 to n and connected by m one-way roads. It is possible to move along the roads from any intersection to any other intersection. The length of some path from one intersectio... |
### Prompt
Your task is to create a cpp solution to the following problem:
A tournament is a directed graph without self-loops in which every pair of vertexes is connected by exactly one directed edge. That is, for any two vertexes u and v (u β v) exists either an edge going from u to v, or an edge from v to u.
You ... |
### Prompt
Please formulate a cpp solution to the following problem:
When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l.
You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median o... |
### Prompt
Please formulate a cpp solution to the following problem:
Valentin participates in a show called "Shockers". The rules are quite easy: jury selects one letter which Valentin doesn't know. He should make a small speech, but every time he pronounces a word that contains the selected letter, he receives an el... |
### Prompt
Create a solution in cpp for the following problem:
The heat during the last few days has been really intense. Scientists from all over the Berland study how the temperatures and weather change, and they claim that this summer is abnormally hot. But any scientific claim sounds a lot more reasonable if ther... |
### Prompt
Create a solution in cpp for the following problem:
Polycarp is reading a book consisting of n pages numbered from 1 to n. Every time he finishes the page with the number divisible by m, he writes down the last digit of this page number. For example, if n=15 and m=5, pages divisible by m are 5, 10, 15. The... |
### Prompt
Create a solution in cpp for the following problem:
Bizon the Champion has recently finished painting his wood fence. The fence consists of a sequence of n panels of 1 meter width and of arbitrary height. The i-th panel's height is hi meters. The adjacent planks follow without a gap between them.
After Bi... |
### Prompt
Please provide a CPP coded solution to the problem described below:
Let's define the following recurrence: $$$a_{n+1} = a_{n} + minDigit(a_{n}) β
maxDigit(a_{n}).$$$
Here minDigit(x) and maxDigit(x) are the minimal and maximal digits in the decimal representation of x without leading zeroes. For examples ... |
### Prompt
Your task is to create a CPP solution to the following problem:
Btoh yuo adn yuor roomatme lhoate wianshg disehs, btu stlil sdmoeboy msut peorrfm tihs cohre dialy. Oen dya yuo decdie to idourtcne smoe syestm. Yuor rmmotaoe sstgegus teh fooniwllg dael. Yuo argee on tow arayrs of ientgres M adn R, nmebur upm... |
### Prompt
Develop a solution in Cpp to the problem described below:
One day, as Sherlock Holmes was tracking down one very important criminal, he found a wonderful painting on the wall. This wall could be represented as a plane. The painting had several concentric circles that divided the wall into several parts. So... |
### Prompt
In cpp, your task is to solve the following problem:
Paladin Manao caught the trail of the ancient Book of Evil in a swampy area. This area contains n settlements numbered from 1 to n. Moving through the swamp is very difficult, so people tramped exactly n - 1 paths. Each of these paths connects some pair ... |
### Prompt
Please provide a CPP coded solution to the problem described below:
If you draw a few infinitely long straight lines on an infinitely wide plane, this plane will be divided into several areas. For example, if you draw a straight line, the plane will be divided into two areas. Even if you draw the same numb... |
### Prompt
Generate a cpp solution to the following problem:
You want to perform the combo on your opponent in one popular fighting game. The combo is the string s consisting of n lowercase Latin letters. To perform the combo, you have to press all buttons in the order they appear in s. I.e. if s="abca" then you have... |
### Prompt
Generate a Cpp solution to the following problem:
The Little Elephant loves to play with color cards.
He has n cards, each has exactly two colors (the color of the front side and the color of the back side). Initially, all the cards lay on the table with the front side up. In one move the Little Elephant ... |
### Prompt
Construct a CPP code solution to the problem outlined:
There is a tree with N vertices numbered 1 through N. The i-th of the N-1 edges connects vertices a_i and b_i.
Initially, each edge is painted blue. Takahashi will convert this blue tree into a red tree, by performing the following operation N-1 times... |
### Prompt
In Cpp, your task is to solve the following problem:
This is an interactive problem.
You are the head coach of a chess club. The club has 2n players, each player has some strength which can be represented by a number, and all those numbers are distinct. The strengths of the players are not known to you.
... |
### Prompt
Please create a solution in CPP to the following problem:
The cool breeze blows gently, the flowing water ripples steadily.
"Flowing and passing like this, the water isn't gone ultimately; Waxing and waning like that, the moon doesn't shrink or grow eventually."
"Everything is transient in a way and pere... |
### Prompt
Develop a solution in Cpp to the problem described below:
Takahashi is going to buy N items one by one.
The price of the i-th item he buys is A_i yen (the currency of Japan).
He has M discount tickets, and he can use any number of them when buying an item.
If Y tickets are used when buying an item price... |
### Prompt
Generate a CPP solution to 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 numb... |
### Prompt
Your challenge is to write a CPP solution to the following problem:
You are given an integer m.
Let M = 2m - 1.
You are also given a set of n integers denoted as the set T. The integers will be provided in base 2 as n binary strings of length m.
A set of integers S is called "good" if the following hold... |
### Prompt
Please provide a Cpp coded solution to the problem described below:
Owl Sonya decided to become a partymaker. To train for this role she gather all her owl friends in the country house. There are m chairs located in a circle and consequently numbered with integers from 1 to m. Thus, chairs i and i + 1 are ... |
### Prompt
In cpp, your task is to solve the following problem:
Given integers c_{0}, c_{1}, β¦, c_{k-1} we can define the cost of a number 0 β€ x < 2^{k} as p(x) = β_{i=0}^{k-1} \left( \leftβ \frac{x}{2^{i}} \rightβ mod 2 \right) β
c_{i}. In other words, the cost of number x is the sum of c_{i} over the bits of x whic... |
### Prompt
Your challenge is to write a cpp solution to the following problem:
After a lot of trying, Mashmokh designed a problem and it's your job to solve it.
You have a tree T with n vertices. Each vertex has a unique index from 1 to n. The root of T has index 1. For each vertex of this tree v, you are given a li... |
### Prompt
Your task is to create a Cpp solution to the following problem:
You are playing a new computer game in which you have to fight monsters. In a dungeon you are trying to clear, you met three monsters; the first of them has a health points, the second has b health points, and the third has c.
To kill the mon... |
### Prompt
Please provide a Cpp coded solution to the problem described below:
problem
The island where JOI lives has been invaded by zombies. JOI decided to escape to the shelter, which is set as the safest shelter on the island.
The island where JOI lives consists of N towns from town 1 to town N, and the towns a... |
### Prompt
Generate a CPP solution to the following problem:
A new agent called Killjoy invented a virus COVID-2069 that infects accounts on Codeforces. Each account has a rating, described by an integer (it can possibly be negative or very large).
Killjoy's account is already infected and has a rating equal to x. I... |
### Prompt
Construct a cpp code solution to the problem outlined:
You are given two positive integers n and k. Print the k-th positive integer that is not divisible by n.
For example, if n=3, and k=7, then all numbers that are not divisible by 3 are: 1, 2, 4, 5, 7, 8, 10, 11, 13 .... The 7-th number among them is 10... |
### Prompt
Develop a solution in CPP to the problem described below:
Example
Input
acmicpc
tsukuba
Output
No
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
string s, t, u, v;
bool func(string w){
int x = 0;
for(int i=0; i<t.size(); ++i){
if(x < w.size() && t[i] == w[x]){
++x;
}
}... |
### Prompt
Please create a solution in cpp to the following problem:
Kuroni has n daughters. As gifts for them, he bought n necklaces and n bracelets:
* the i-th necklace has a brightness a_i, where all the a_i are pairwise distinct (i.e. all a_i are different),
* the i-th bracelet has a brightness b_i, where a... |
### Prompt
Generate a Cpp solution to the following problem:
This is the hard version of the problem. The difference between the versions is the constraint on n and the required number of operations. You can make hacks only if all versions of the problem are solved.
There are two binary strings a and b of length n (... |
### Prompt
Please formulate a CPP solution to the following problem:
This contest is `CODEFESTIVAL`, which can be shortened to the string `CF` by deleting some characters.
Mr. Takahashi, full of curiosity, wondered if he could obtain `CF` from other strings in the same way.
You are given a string s consisting of up... |
### Prompt
Please provide a CPP coded solution to the problem described below:
There are N children standing in a line from left to right. The activeness of the i-th child from the left is A_i.
You can rearrange these children just one time in any order you like.
When a child who originally occupies the x-th positi... |
### Prompt
Create a solution in Cpp for the following problem:
Write a program which reads a sequence of integers $A = \\{a_0, a_1, ..., a_{n-1}\\}$ and rotate specified elements by a list of the following operation:
* rotate($b, m, e$): For each integer $k$ ($0 \leq k < (e - b)$), move element $b + k$ to the place ... |
### Prompt
Your challenge is to write a cpp solution to the following problem:
The next "Data Structures and Algorithms" lesson will be about Longest Increasing Subsequence (LIS for short) of a sequence. For better understanding, Nam decided to learn it a few days before the lesson.
Nam created a sequence a consisti... |
### Prompt
Develop a solution in cpp to the problem described below:
Yaroslav is playing a game called "Time". The game has a timer showing the lifespan he's got left. As soon as the timer shows 0, Yaroslav's character dies and the game ends. Also, the game has n clock stations, station number i is at point (xi, yi) ... |
### Prompt
Your challenge is to write a CPP solution to the following problem:
Vova and Marina love offering puzzles to each other. Today Marina offered Vova to cope with the following task.
Vova has a non-directed graph consisting of n vertices and m edges without loops and multiple edges. Let's define the operatio... |
### Prompt
Create a solution in CPP for the following problem:
You are given a matrix a, consisting of n rows and m columns. Each cell contains an integer in it.
You can change the order of rows arbitrarily (including leaving the initial order), but you can't change the order of cells in a row. After you pick some o... |
### Prompt
Construct a cpp code solution to the problem outlined:
Kana was just an ordinary high school girl before a talent scout discovered her. Then, she became an idol. But different from the stereotype, she is also a gameholic.
One day Kana gets interested in a new adventure game called Dragon Quest. In this g... |
### Prompt
In CPP, your task is to solve the following problem:
Snuke is buying a bicycle. The bicycle of his choice does not come with a bell, so he has to buy one separately.
He has very high awareness of safety, and decides to buy two bells, one for each hand.
The store sells three kinds of bells for the price o... |
### Prompt
Please formulate a CPP solution to the following problem:
Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
One day Petya dreamt of a lex... |
### Prompt
Develop a solution in CPP to the problem described below:
Polycarpus has a finite sequence of opening and closing brackets. In order not to fall asleep in a lecture, Polycarpus is having fun with his sequence. He is able to perform two operations:
* adding any bracket in any position (in the beginning, ... |
### Prompt
Your task is to create a Cpp solution to the following problem:
Peter got a new snow blower as a New Year present. Of course, Peter decided to try it immediately. After reading the instructions he realized that it does not work like regular snow blowing machines. In order to make it work, you need to tie i... |
### Prompt
Please create a solution in cpp to the following problem:
Everybody seems to think that the Martians are green, but it turns out they are metallic pink and fat. Ajs has two bags of distinct nonnegative integers. The bags are disjoint, and the union of the sets of numbers in the bags is \{0,1,β¦,M-1\}, for s... |
### Prompt
Please formulate a cpp solution to the following problem:
Malek has recently found a treasure map. While he was looking for a treasure he found a locked door. There was a string s written on the door consisting of characters '(', ')' and '#'. Below there was a manual on how to open the door. After spending... |
### Prompt
Your challenge is to write a cpp solution to the following problem:
Valentin participates in a show called "Shockers". The rules are quite easy: jury selects one letter which Valentin doesn't know. He should make a small speech, but every time he pronounces a word that contains the selected letter, he rece... |
### Prompt
Create a solution in CPP for the following problem:
You are given a sequence a_1, a_2, ..., a_n, consisting of integers.
You can apply the following operation to this sequence: choose some integer x and move all elements equal to x either to the beginning, or to the end of a. Note that you have to move al... |
### Prompt
In cpp, your task is to solve the following problem:
The R1 company has recently bought a high rise building in the centre of Moscow for its main office. It's time to decorate the new office, and the first thing to do is to write the company's slogan above the main entrance to the building.
The slogan of ... |
### Prompt
Please create a solution in cpp to the following problem:
In 2300, the Life Science Division of Federal Republic of Space starts a very ambitious project to complete the genome sequencing of all living creatures in the entire universe and develop the genomic database of all space life. Thanks to scientific... |
### Prompt
Please provide a cpp coded solution to the problem described below:
Billy investigates the question of applying greedy algorithm to different spheres of life. At the moment he is studying the application of greedy algorithm to the problem about change. There is an amount of n coins of different face values... |
### Prompt
Develop a solution in CPP to the problem described below:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n Γ m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to 4, illustr... |
### Prompt
Your task is to create a CPP solution to the following problem:
A and B are preparing themselves for programming contests.
An important part of preparing for a competition is sharing programming knowledge from the experienced members to those who are just beginning to deal with the contests. Therefore, du... |
### Prompt
Create a solution in cpp for the following problem:
A very tense moment: n cowboys stand in a circle and each one points his colt at a neighbor. Each cowboy can point the colt to the person who follows or precedes him in clockwise direction. Human life is worthless, just like in any real western.
The pict... |
### Prompt
Your challenge is to write a cpp solution to the following problem:
Mishka's favourite experimental indie band has recently dropped a new album! Songs of that album share one gimmick. Each name s_i is one of the following types:
* 1~c β a single lowercase Latin letter;
* 2~j~c β name s_j (1 β€ j < i) ... |
### Prompt
In CPP, your task is to solve the following problem:
per nextum in unam tum XI conscribementis fac sic
vestibulo perlegementum da varo.
morde varo.
seqis cumula varum.
cis
per nextum in unam tum XI conscribementis fac sic
seqis decumulamenta da... |
### Prompt
Your task is to create a cpp solution to the following problem:
Rumors say that one of Kamal-ol-molk's paintings has been altered. A rectangular brush has been moved right and down on the painting.
Consider the painting as a n Γ m rectangular grid. At the beginning an x Γ y rectangular brush is placed som... |
### Prompt
Generate a cpp solution to the following problem:
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box).
Since all the boxes have the same size, Ciel cannot pu... |
### Prompt
Construct a Cpp code solution to the problem outlined:
You are given two positive integers a and b. In one move you can increase a by 1 (replace a with a+1). Your task is to find the minimum number of moves you need to do in order to make a divisible by b. It is possible, that you have to make 0 moves, as ... |
### Prompt
Please formulate a cpp solution to the following problem:
Some number of chocolate pieces were prepared for a training camp. The camp had N participants and lasted for D days. The i-th participant (1 \leq i \leq N) ate one chocolate piece on each of the following days in the camp: the 1-st day, the (A_i + ... |
### Prompt
Generate a cpp solution to the following problem:
You are given an array of integers. Vasya can permute (change order) its integers. He wants to do it so that as many as possible integers will become on a place where a smaller integer used to stand. Help Vasya find the maximal number of such integers.
For... |
### Prompt
In cpp, your task is to solve the following problem:
You might have remembered Theatre square from the [problem 1A](https://codeforces.com/problemset/problem/1/A). Now it's finally getting repaved.
The square still has a rectangular shape of n Γ m meters. However, the picture is about to get more complica... |
### Prompt
Create a solution in CPP for the following problem:
An elephant decided to visit his friend. It turned out that the elephant's house is located at point 0 and his friend's house is located at point x(x > 0) of the coordinate line. In one step the elephant can move 1, 2, 3, 4 or 5 positions forward. Determi... |
### Prompt
Please create a solution in Cpp to the following problem:
Your search for Heidi is over β you finally found her at a library, dressed up as a human. In fact, she has spent so much time there that she now runs the place! Her job is to buy books and keep them at the library so that people can borrow and read... |
### Prompt
Construct a cpp code solution to the problem outlined:
A correct expression of the form a+b=c was written; a, b and c are non-negative integers without leading zeros. In this expression, the plus and equally signs were lost. The task is to restore the expression. In other words, one character '+' and one c... |
### Prompt
Create a solution in CPP for the following problem:
Let's call beauty of an array b_1, b_2, β¦, b_n (n > 1) β min_{1 β€ i < j β€ n} |b_i - b_j|.
You're given an array a_1, a_2, β¦ a_n and a number k. Calculate the sum of beauty over all subsequences of the array of length exactly k. As this number can be very... |
### Prompt
Your task is to create a CPP solution to the following problem:
In the town of Aalam-Aara (meaning the Light of the Earth), previously there was no crime, no criminals but as the time progressed, sins started creeping into the hearts of once righteous people. Seeking solution to the problem, some of the el... |
### Prompt
Create a solution in Cpp for the following problem:
Two pirates Polycarpus and Vasily play a very interesting game. They have n chests with coins, the chests are numbered with integers from 1 to n. Chest number i has ai coins.
Polycarpus and Vasily move in turns. Polycarpus moves first. During a move a p... |
### Prompt
Please create a solution in cpp to the following problem:
There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.
Find the way to dis... |
### Prompt
Please create a solution in cpp to the following problem:
You are given an unweighted tree with n vertices. Then n - 1 following operations are applied to the tree. A single operation consists of the following steps:
1. choose two leaves;
2. add the length of the simple path between them to the answ... |
### Prompt
Generate a Cpp solution to the following problem:
Let's define the sum of two permutations p and q of numbers 0, 1, ..., (n - 1) as permutation <image>, where Perm(x) is the x-th lexicographically permutation of numbers 0, 1, ..., (n - 1) (counting from zero), and Ord(p) is the number of permutation p in t... |
### Prompt
Please create a solution in CPP to the following problem:
Some days ago, WJMZBMR learned how to answer the query "how many times does a string x occur in a string s" quickly by preprocessing the string s. But now he wants to make it harder.
So he wants to ask "how many consecutive substrings of s are cycl... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.