text stringlengths 424 69.5k |
|---|
### Prompt
Please formulate a cpp solution to the following problem:
It is said that a legendary treasure left by Mr. Yao is sleeping somewhere in Hachioji long ago. The treasure map, which is said to show its whereabouts, has been handed down by Yao's n descendants, divided into several pieces.
Now, the descendants... |
### Prompt
Your task is to create a cpp solution to the following problem:
You are a judge of a programming contest. You are preparing a dataset for a graph problem to seek for the cost of the minimum cost path. You've generated some random cases, but they are not interesting. You want to produce a dataset whose answ... |
### Prompt
Generate a Cpp solution to the following problem:
Based on some criterion, Snuke divided the integers from 1 through 12 into three groups as shown in the figure below. Given two integers x and y (1 β€ x < y β€ 12), determine whether they belong to the same group.
b4ab979900ed647703389d4349eb84ee.png
Constr... |
### Prompt
Your challenge is to write a Cpp solution to the following problem:
Two polar bears Menshykov and Uslada from the St.Petersburg zoo and elephant Horace from the Kiev zoo got six sticks to play with and assess the animals' creativity. Menshykov, Uslada and Horace decided to make either an elephant or a bear... |
### Prompt
Your challenge is to write a cpp solution to the following problem:
After a hard day Vitaly got very hungry and he wants to eat his favorite potato pie. But it's not that simple. Vitaly is in the first room of the house with n room located in a line and numbered starting from one from left to right. You ca... |
### Prompt
Please formulate a CPP solution to the following problem:
A game field is a strip of 1 Γ n square cells. In some cells there are Packmen, in some cells β asterisks, other cells are empty.
Packman can move to neighboring cell in 1 time unit. If there is an asterisk in the target cell then Packman eats it. ... |
### Prompt
Construct a cpp code solution to the problem outlined:
There are N points on the 2D plane, i-th of which is located on (x_i, y_i). There can be multiple points that share the same coordinate. What is the maximum possible Manhattan distance between two distinct points?
Here, the Manhattan distance between ... |
### Prompt
Please create a solution in Cpp to the following problem:
There is an airplane which has n rows from front to back. There will be m people boarding this airplane.
This airplane has an entrance at the very front and very back of the plane.
Each person has some assigned seat. It is possible for multiple pe... |
### Prompt
Create a solution in CPP for the following problem:
Drazil likes heap very much. So he created a problem with heap:
There is a max heap with a height h implemented on the array. The details of this heap are the following:
This heap contains exactly 2^h - 1 distinct positive non-zero integers. All integer... |
### Prompt
Your task is to create 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"... |
### Prompt
Develop a solution in CPP to the problem described below:
All our characters have hobbies. The same is true for Fedor. He enjoys shopping in the neighboring supermarket.
The goods in the supermarket have unique integer ids. Also, for every integer there is a product with id equal to this integer. Fedor h... |
### Prompt
Develop a solution in cpp to the problem described below:
Gildong has an interesting machine that has an array a with n integers. The machine supports two kinds of operations:
1. Increase all elements of a suffix of the array by 1.
2. Decrease all elements of a suffix of the array by 1.
A suffix ... |
### Prompt
Generate a Cpp solution to the following problem:
The Little Elephant loves playing with arrays. He has array a, consisting of n positive integers, indexed from 1 to n. Let's denote the number with index i as ai.
Additionally the Little Elephant has m queries to the array, each query is characterised by ... |
### Prompt
Your challenge is to write a cpp solution to the following problem:
For a non-negative integer K, we define a fractal of level K as follows:
* A fractal of level 0 is a grid with just one white square.
* When K > 0, a fractal of level K is a 3^K \times 3^K grid. If we divide this grid into nine 3^{K-1} \t... |
### Prompt
Generate a cpp solution to the following problem:
You are given the array a consisting of n elements and the integer k β€ n.
You want to obtain at least k equal elements in the array a. In one move, you can make one of the following two operations:
* Take one of the minimum elements of the array and inc... |
### Prompt
Your challenge is to write a cpp solution to the following problem:
This problem only differs from the next problem in constraints.
This is an interactive problem.
Alice and Bob are playing a game on the chessboard of size n Γ m where n and m are even. The rows are numbered from 1 to n and the columns ar... |
### Prompt
Please create a solution in cpp to the following problem:
Monocarp wants to draw four line segments on a sheet of paper. He wants the i-th segment to have its length equal to a_i (1 β€ i β€ 4). These segments can intersect with each other, and each segment should be either horizontal or vertical.
Monocarp w... |
### Prompt
Please provide a CPP coded solution to the problem described below:
Berland has n cities connected by m bidirectional roads. No road connects a city to itself, and each pair of cities is connected by no more than one road. It is not guaranteed that you can get from any city to any other one, using only the... |
### Prompt
Generate a cpp solution to the following problem:
Consider a football tournament where n teams participate. Each team has two football kits: for home games, and for away games. The kit for home games of the i-th team has color xi and the kit for away games of this team has color yi (xi β yi).
In the tourn... |
### Prompt
Construct a cpp code solution to the problem outlined:
The only difference between easy and hard versions is constraints.
A session has begun at Beland State University. Many students are taking exams.
Polygraph Poligrafovich is going to examine a group of n students. Students will take the exam one-by-o... |
### Prompt
Please formulate a cpp solution to the following problem:
One day Petya was solving a very interesting problem. But although he used many optimization techniques, his solution still got Time limit exceeded verdict. Petya conducted a thorough analysis of his program and found out that his function for findi... |
### Prompt
Please create a solution in CPP to the following problem:
Hongcow is ruler of the world. As ruler of the world, he wants to make it easier for people to travel by road within their own countries.
The world can be modeled as an undirected graph with n nodes and m edges. k of the nodes are home to the gover... |
### Prompt
Please create a solution in Cpp to the following problem:
Janusz is a businessman. He owns a company "Januszex", which produces games for teenagers. Last hit of Januszex was a cool one-person game "Make it one". The player is given a sequence of n integers a_i.
It is allowed to select any subset of them, ... |
### Prompt
Your challenge is to write a CPP solution to the following problem:
Smart Beaver is careful about his appearance and pays special attention to shoes so he has a huge number of pairs of shoes from the most famous brands of the forest. He's trying to handle his shoes carefully so that each pair stood side by... |
### Prompt
Please formulate a cpp solution to the following problem:
You are playing a game where your character should overcome different obstacles. The current problem is to come down from a cliff. The cliff has height h, and there is a moving platform on each height x from 1 to h.
Each platform is either hidden i... |
### Prompt
Create a solution in Cpp for the following problem:
We have an N \times M grid. The square at the i-th row and j-th column will be denoted as (i,j). Particularly, the top-left square will be denoted as (1,1), and the bottom-right square will be denoted as (N,M). Takahashi painted some of the squares (possi... |
### Prompt
Please formulate a Cpp solution to the following problem:
At the beginning of the new semester there is new schedule in the Berland State University. According to this schedule, n groups have lessons at the room 31. For each group the starting time of the lesson and the finishing time of the lesson are kno... |
### Prompt
Your task is to create a Cpp solution to the following problem:
We have 3N colored balls with IDs from 1 to 3N. A string S of length 3N represents the colors of the balls. The color of Ball i is red if S_i is `R`, green if S_i is `G`, and blue if S_i is `B`. There are N red balls, N green balls, and N blue... |
### Prompt
Create a solution in cpp for the following problem:
We have sticks numbered 1, \cdots, N. The length of Stick i (1 \leq i \leq N) is L_i.
In how many ways can we choose three of the sticks with different lengths that can form a triangle?
That is, find the number of triples of integers (i, j, k) (1 \leq i... |
### Prompt
Please provide a Cpp coded solution to the problem described below:
You are given a string S of length N consisting of `A`, `B` and `C`, and an integer K which is between 1 and N (inclusive). Print the string S after lowercasing the K-th character in it.
Constraints
* 1 β€ N β€ 50
* 1 β€ K β€ N
* S is a stri... |
### 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
Your task is to create a Cpp solution to the following problem:
Recently, the Fair Nut has written k strings of length n, consisting of letters "a" and "b". He calculated c β the number of strings that are prefixes of at least one of the written strings. Every string was counted only one time.
Then, he lo... |
### Prompt
Your task is to create a cpp solution to the following problem:
Professor GukiZ makes a new robot. The robot are in the point with coordinates (x1, y1) and should go to the point (x2, y2). In a single step the robot can change any of its coordinates (maybe both of them) by one (decrease or increase). So th... |
### Prompt
In Cpp, your task is to solve the following problem:
N tiles are arranged in a row from left to right. The initial color of each tile is represented by a string S of length N.
The i-th tile from the left is painted black if the i-th character of S is `0`, and painted white if that character is `1`.
You w... |
### Prompt
Develop a solution in CPP to the problem described below:
This is an interactive problem.
Note: the XOR-sum of an array a_1, a_2, β¦, a_n (1 β€ a_i β€ 10^9) is defined as a_1 β a_2 β β¦ β a_n, where β denotes the [bitwise XOR operation](https://en.wikipedia.org/wiki/Bitwise_operation#XOR).
Little Dormi recei... |
### Prompt
Develop a solution in Cpp to the problem described below:
JATC and his friend Giraffe are currently in their room, solving some problems. Giraffe has written on the board an array a_1, a_2, ..., a_n of integers, such that 1 β€ a_1 < a_2 < β¦ < a_n β€ 10^3, and then went to the bathroom.
JATC decided to prank... |
### Prompt
Generate a cpp solution to the following problem:
This is the easier version of the problem. In this version, 1 β€ n β€ 10^5 and 0 β€ a_i β€ 1. You can hack this problem only if you solve and lock both problems.
Christmas is coming, and our protagonist, Bob, is preparing a spectacular present for his long-tim... |
### Prompt
Construct a CPP code solution to the problem outlined:
Find the number, modulo 998244353, of sequences of length N consisting of 0, 1 and 2 such that none of their contiguous subsequences totals to X.
Constraints
* 1 \leq N \leq 3000
* 1 \leq X \leq 2N
* N and X are integers.
Input
Input is given from ... |
### Prompt
Please formulate a Cpp solution to the following problem:
Ivan places knights on infinite chessboard. Initially there are n knights. If there is free cell which is under attack of at least 4 knights then he places new knight in this cell. Ivan repeats this until there are no such free cells. One can prove ... |
### Prompt
Create a solution in CPP for the following problem:
Fox Ciel is going to publish a paper on FOCS (Foxes Operated Computer Systems, pronounce: "Fox"). She heard a rumor: the authors list on the paper is always sorted in the lexicographical order.
After checking some examples, she found out that sometimes ... |
### Prompt
Generate a CPP solution to the following problem:
There are n students in a school class, the rating of the i-th student on Codehorses is a_i. You have to form a team consisting of k students (1 β€ k β€ n) such that the ratings of all team members are distinct.
If it is impossible to form a suitable team, p... |
### Prompt
Please formulate a Cpp solution to the following problem:
Limak is going to participate in a contest on the last day of the 2016. The contest will start at 20:00 and will last four hours, exactly until midnight. There will be n problems, sorted by difficulty, i.e. problem 1 is the easiest and problem n is ... |
### Prompt
In CPP, your task is to solve the following problem:
Consider a sequence of digits of length 2^k [a_1, a_2, β¦, a_{2^k}]. We perform the following operation with it: replace pairs (a_{2i+1}, a_{2i+2}) with (a_{2i+1} + a_{2i+2})mod 10 for 0β€ i<2^{k-1}. For every i where a_{2i+1} + a_{2i+2}β₯ 10 we get a candy... |
### Prompt
In Cpp, your task is to solve the following problem:
This is the hard version of the problem. You can find the easy version in the Div. 2 contest. Both versions only differ in the number of times you can ask your friend to taste coffee.
This is an interactive problem.
You're considering moving to another... |
### Prompt
Generate a CPP solution to the following problem:
Bob is an active user of the social network Faithbug. On this network, people are able to engage in a mutual friendship. That is, if a is a friend of b, then b is also a friend of a. Each user thus has a non-negative amount of friends.
This morning, somebo... |
### Prompt
Your task is to create a cpp solution to the following problem:
Princess Twilight went to Celestia and Luna's old castle to research the chest from the Elements of Harmony.
<image>
A sequence of positive integers bi is harmony if and only if for every two elements of the sequence their greatest common di... |
### Prompt
Generate a cpp solution to the following problem:
Permutation p is an ordered set of integers p1, p2, ..., pn, consisting of n distinct positive integers not larger than n. We'll denote as n the length of permutation p1, p2, ..., pn.
Your task is to find such permutation p of length n, that the group of n... |
### Prompt
Please formulate a cpp solution to the following problem:
Recently, Tokitsukaze found an interesting game. Tokitsukaze had n items at the beginning of this game. However, she thought there were too many items, so now she wants to discard m (1 β€ m β€ n) special items of them.
These n items are marked with i... |
### Prompt
Create a solution in cpp for the following problem:
A convex polygon consisting of N vertices is given. The coordinates of each vertex are represented counterclockwise by (X1, Y1), (X2, Y2), β¦β¦, (XN, YN). No matter what straight line passes through the point P, find the coordinates of the point P so that t... |
### Prompt
Your task is to create a Cpp solution to the following problem:
12:17 (UTC): The sample input 1 and 2 were swapped. The error is now fixed. We are very sorry for your inconvenience.
There are N children in AtCoder Kindergarten, conveniently numbered 1 through N. Mr. Evi will distribute C indistinguishable... |
### Prompt
Please formulate a cpp solution to the following problem:
A long time ago, in a galaxy far far away two giant IT-corporations Pineapple and Gogol continue their fierce competition. Crucial moment is just around the corner: Gogol is ready to release it's new tablet Lastus 3000.
This new device is equipped ... |
### Prompt
Generate a CPP solution to the following problem:
One day Ms Swan bought an orange in a shop. The orange consisted of nΒ·k segments, numbered with integers from 1 to nΒ·k.
There were k children waiting for Ms Swan at home. The children have recently learned about the orange and they decided to divide it be... |
### Prompt
Construct a CPP code solution to the problem outlined:
Uh oh! Applications to tech companies are due soon, and you've been procrastinating by doing contests instead! (Let's pretend for now that it is actually possible to get a job in these uncertain times.)
You have completed many programming projects. In... |
### Prompt
Your challenge is to write a Cpp solution to the following problem:
You are given N points in the xy-plane. You have a circle of radius one and move it on the xy-plane, so as to enclose as many of the points as possible. Find how many points can be simultaneously enclosed at the maximum. A point is conside... |
### Prompt
Please create a solution in cpp to the following problem:
International Women's Day is coming soon! Polycarp is preparing for the holiday.
There are n candy boxes in the shop for sale. The i-th box contains d_i candies.
Polycarp wants to prepare the maximum number of gifts for k girls. Each gift will con... |
### Prompt
Generate a cpp solution to the following problem:
Bear Limak examines a social network. Its main functionality is that two members can become friends (then they can talk with each other and share funny pictures).
There are n members, numbered 1 through n. m pairs of members are friends. Of course, a membe... |
### Prompt
Develop a solution in Cpp to the problem described below:
You are given three positive integers n, a and b. You have to construct a string s of length n consisting of lowercase Latin letters such that each substring of length a has exactly b distinct letters. It is guaranteed that the answer exists.
You h... |
### Prompt
In Cpp, your task is to solve the following problem:
Vasiliy finally got to work, where there is a huge amount of tasks waiting for him. Vasiliy is given a matrix consisting of n rows and m columns and q tasks. Each task is to swap two submatrices of the given matrix.
For each task Vasiliy knows six integ... |
### Prompt
Please provide a cpp coded solution to the problem described below:
There are two rectangles whose bases are parallel to the x-axis. Read the lower left coordinates (xa1, ya1) and upper right coordinates (xa2, ya2) of rectangle A, the lower left coordinates (xb1, yb1) and upper right coordinates (xb2, yb2)... |
### Prompt
Your task is to create a cpp solution to the following problem:
You are given an array a_1, a_2, ..., a_n consisting of n distinct integers. Count the number of pairs of indices (i, j) such that i < j and a_i β
a_j = i + j.
Input
The first line contains one integer t (1 β€ t β€ 10^4) β the number of test c... |
### Prompt
In CPP, your task is to solve the following problem:
An integer sequence is called beautiful if the difference between any two consecutive numbers is equal to 1. More formally, a sequence s_1, s_2, β¦, s_{n} is beautiful if |s_i - s_{i+1}| = 1 for all 1 β€ i β€ n - 1.
Trans has a numbers 0, b numbers 1, c nu... |
### Prompt
Your challenge is to write a CPP solution to the following problem:
Snuke has a blackboard and a set S consisting of N integers. The i-th element in S is S_i.
He wrote an integer X on the blackboard, then performed the following operation N times:
* Choose one element from S and remove it.
* Let x be the... |
### Prompt
Please create a solution in CPP to the following problem:
John Doe has an n Γ m table. John Doe can paint points in some table cells, not more than one point in one table cell. John Doe wants to use such operations to make each square subtable of size n Γ n have exactly k points.
John Doe wondered, how ma... |
### Prompt
In cpp, your task is to solve the following problem:
The Smart Beaver from ABBYY loves puzzles. One of his favorite puzzles is the magic square. He has recently had an idea to automate the solution of this puzzle. The Beaver decided to offer this challenge to the ABBYY Cup contestants.
The magic square is... |
### Prompt
Create a solution in CPP for the following problem:
There are three airports A, B and C, and flights between each pair of airports in both directions.
A one-way flight between airports A and B takes P hours, a one-way flight between airports B and C takes Q hours, and a one-way flight between airports C a... |
### Prompt
Generate a CPP solution to the following problem:
George decided to prepare a Codesecrof round, so he has prepared m problems for the round. Let's number the problems with integers 1 through m. George estimates the i-th problem's complexity by integer bi.
To make the round good, he needs to put at least n... |
### Prompt
Generate a Cpp solution to the following problem:
problem
Given the sequence $ A $ of length $ N $. Find the maximum value of $ \ sum B_i $, where $ B $ is one of the longest increasing subsequences of the sequence $ A $.
The longest increasing subsequence of the sequence $ A $ is the longest subsequence... |
### Prompt
Develop a solution in Cpp to the problem described below:
Drazil is playing a math game with Varda.
Let's define <image> for positive integer x as a product of factorials of its digits. For example, <image>.
First, they choose a decimal number a consisting of n digits that contains at least one digit lar... |
### Prompt
Construct a Cpp code solution to the problem outlined:
Polycarp is preparing the first programming contest for robots. There are n problems in it, and a lot of robots are going to participate in it. Each robot solving the problem i gets p_i points, and the score of each robot in the competition is calculat... |
### Prompt
In CPP, your task is to solve the following problem:
A map of some object is a rectangular field consisting of n rows and n columns. Each cell is initially occupied by the sea but you can cover some some cells of the map with sand so that exactly k islands appear on the map. We will call a set of sand cell... |
### Prompt
Create a solution in Cpp for the following problem:
Most C/C++ programmers know about excellent opportunities that preprocessor #define directives give; but many know as well about the problems that can arise because of their careless use.
In this problem we consider the following model of #define constru... |
### Prompt
Construct a cpp code solution to the problem outlined:
One quite ordinary day Valera went to school (there's nowhere else he should go on a week day). In a maths lesson his favorite teacher Ms. Evans told students about divisors. Despite the fact that Valera loved math, he didn't find this particular topic... |
### Prompt
Construct a Cpp code solution to the problem outlined:
The year of 2012 is coming...
According to an ancient choradrican legend in this very year, in 2012, Diablo and his brothers Mephisto and Baal will escape from hell, and innumerable hordes of demons will enslave the human world. But seven brave heroes... |
### Prompt
Create a solution in Cpp for the following problem:
Nothing is eternal in the world, Kostya understood it on the 7-th of January when he saw partially dead four-color garland.
Now he has a goal to replace dead light bulbs, however he doesn't know how many light bulbs for each color are required. It is gua... |
### Prompt
In Cpp, your task is to solve the following problem:
Given is an integer sequence of length N+1: A_0, A_1, A_2, \ldots, A_N. Is there a binary tree of depth N such that, for each d = 0, 1, \ldots, N, there are exactly A_d leaves at depth d? If such a tree exists, print the maximum possible number of vertic... |
### Prompt
Construct a cpp code solution to the problem outlined:
Let N be a positive integer. You are given a string s of length N - 1, consisting of `<` and `>`.
Find the number of permutations (p_1, p_2, \ldots, p_N) of (1, 2, \ldots, N) that satisfy the following condition, modulo 10^9 + 7:
* For each i (1 \leq... |
### Prompt
Construct a CPP code solution to the problem outlined:
You are given two integers n and k. Find k-th smallest divisor of n, or report that it doesn't exist.
Divisor of n is any such natural number, that n can be divided by it without remainder.
Input
The first line contains two integers n and k (1 β€ n β€... |
### Prompt
Please create a solution in Cpp to the following problem:
You are given a string, consisting of lowercase Latin letters.
A pair of neighbouring letters in a string is considered ugly if these letters are also neighbouring in a alphabet. For example, string "abaca" contains ugly pairs at positions (1, 2) β... |
### Prompt
Your task is to create a CPP solution to the following problem:
There are two rival donut shops.
The first shop sells donuts at retail: each donut costs a dollars.
The second shop sells donuts only in bulk: box of b donuts costs c dollars. So if you want to buy x donuts from this shop, then you have to b... |
### Prompt
Construct a CPP code solution to the problem outlined:
There is a triangle formed by three points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$ on a plain.
Write a program which prints "YES" if a point $P$ $(x_p, y_p)$ is in the triangle and "NO" if not.
Constraints
You can assume that:
* $ -100 \leq x_1, y... |
### Prompt
Your task is to create a Cpp solution to the following problem:
When Sasha was studying in the seventh grade, he started listening to music a lot. In order to evaluate which songs he likes more, he introduced the notion of the song's prettiness. The title of the song is a word consisting of uppercase Latin... |
### Prompt
Please formulate a cpp solution to the following problem:
Write a program which reads a word W and a text T, and prints the number of word W which appears in text T
T consists of string Ti separated by space characters and newlines. Count the number of Ti which equals to W. The word and text are case inse... |
### Prompt
Please provide a Cpp coded solution to the problem described below:
Makes solves problems on Decoforces and lots of other different online judges. Each problem is denoted by its difficulty β a positive integer number. Difficulties are measured the same across all the judges (the problem with difficulty d o... |
### Prompt
Please create a solution in cpp to the following problem:
Maxim always goes to the supermarket on Sundays. Today the supermarket has a special offer of discount systems.
There are m types of discounts. We assume that the discounts are indexed from 1 to m. To use the discount number i, the customer takes a... |
### Prompt
Please provide a cpp coded solution to the problem described below:
There are n districts in the town, the i-th district belongs to the a_i-th bandit gang. Initially, no districts are connected to each other.
You are the mayor of the city and want to build n-1 two-way roads to connect all districts (two d... |
### Prompt
Create a solution in CPP for the following problem:
Chloe, the same as Vladik, is a competitive programmer. She didn't have any problems to get to the olympiad like Vladik, but she was confused by the task proposed on the olympiad.
Let's consider the following algorithm of generating a sequence of integer... |
### Prompt
Please provide a CPP coded solution to the problem described below:
In this problem, we will deal with binary strings. Each character of a binary string is either a 0 or a 1. We will also deal with substrings; recall that a substring is a contiguous subsequence of a string. We denote the substring of strin... |
### Prompt
Your challenge is to write a Cpp solution to the following problem:
Nowadays all circuses in Berland have a round arena with diameter 13 meters, but in the past things were different.
In Ancient Berland arenas in circuses were shaped as a regular (equiangular) polygon, the size and the number of angles co... |
### Prompt
Develop a solution in Cpp to the problem described below:
For each of the K^{NM} ways to write an integer between 1 and K (inclusive) in every square in a square grid with N rows and M columns, find the value defined below, then compute the sum of all those K^{NM} values, modulo D.
* For each of the NM sq... |
### Prompt
Please create a solution in Cpp to the following problem:
Bob recently read about bitwise operations used in computers: AND, OR and XOR. He have studied their properties and invented a new game.
Initially, Bob chooses integer m, bit depth of the game, which means that all numbers in the game will consist ... |
### Prompt
Generate a CPP solution to the following problem:
You are given a string s consisting of n lowercase Latin letters. Polycarp wants to remove exactly k characters (k β€ n) from the string s. Polycarp uses the following algorithm k times:
* if there is at least one letter 'a', remove the leftmost occurrenc... |
### Prompt
Construct a Cpp code solution to the problem outlined:
This problem is a little bit unusual. Here you are to implement an interaction with a testing system. That means that you can make queries and get responses in the online mode. Please be sure to use the stream flushing operation after each query's outp... |
### Prompt
Construct a Cpp code solution to the problem outlined:
Recently Polycarpus has learned the "bitwise AND" operation (which is also called "AND") of non-negative integers. Now he wants to demonstrate the school IT teacher his superb manipulation with the learned operation.
For that Polycarpus came to school... |
### Prompt
Generate a Cpp solution to the following problem:
A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car an... |
### Prompt
Please provide a cpp coded solution to the problem described below:
Vasya owns three strings s , a and b, each of them consists only of first k Latin letters.
Let a template be such a string of length k that each of the first k Latin letters appears in it exactly once (thus there are k! distinct templates... |
### Prompt
Your task is to create a CPP solution to the following problem:
There was an electronic store heist last night.
All keyboards which were in the store yesterday were numbered in ascending order from some integer number x. For example, if x = 4 and there were 3 keyboards in the store, then the devices had i... |
### Prompt
Create a solution in Cpp for the following problem:
Welcome to PC Koshien, players. Physical condition management is important to participate in the event. It is said that at the turn of the season when the temperature fluctuates greatly, it puts a strain on the body and it is easy to catch a cold. The day... |
### Prompt
Develop a solution in cpp to the problem described below:
Everyone knows that hobbits love to organize all sorts of parties and celebrations. There are n hobbits living in the Shire. They decided to organize the Greatest Party (GP) that would last for several days. Next day the hobbits wrote a guest list, ... |
### Prompt
Develop a solution in CPP to the problem described below:
Sereja has a bracket sequence s1, s2, ..., sn, or, in other words, a string s of length n, consisting of characters "(" and ")".
Sereja needs to answer m queries, each of them is described by two integers li, ri (1 β€ li β€ ri β€ n). The answer to the... |
### Prompt
Please create a solution in cpp to the following problem:
Alyona has a tree with n vertices. The root of the tree is the vertex 1. In each vertex Alyona wrote an positive integer, in the vertex i she wrote ai. Moreover, the girl wrote a positive integer to every edge of the tree (possibly, different intege... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.