text stringlengths 424 69.5k |
|---|
### Prompt
Please formulate a CPP solution to the following problem:
In Takahashi Kingdom, which once existed, there are N cities, and some pairs of cities are connected bidirectionally by roads. The following are known about the road network:
* People traveled between cities only through roads. It was possible to r... |
### Prompt
Construct a cpp code solution to the problem outlined:
You are given an array of length n and a number k. Let's pick k non-overlapping non-empty subarrays of the initial array. Let si be the sum of the i-th subarray in order from left to right. Compute the maximum value of the following expression:
|s1 -... |
### Prompt
Please create a solution in cpp to the following problem:
We're giving away nice huge bags containing number tiles! A bag we want to present to you contains n tiles. Each of them has a single number written on it β either 1 or 2.
However, there is one condition you must fulfill in order to receive the pri... |
### Prompt
Please provide a Cpp coded solution to the problem described below:
Having stayed home alone, Petya decided to watch forbidden films on the Net in secret. "What ungentlemanly behavior!" β you can say that, of course, but don't be too harsh on the kid. In his country films about the Martians and other extra... |
### Prompt
Your challenge is to write a Cpp solution to the following problem:
Everything is great about Ilya's city, except the roads. The thing is, the only ZooVille road is represented as n holes in a row. We will consider the holes numbered from 1 to n, from left to right.
Ilya is really keep on helping his city... |
### Prompt
Your challenge is to write a CPP solution to the following problem:
Mike decided to teach programming to children in an elementary school. He knows that it is not an easy task to interest children in that age to code. That is why he decided to give each child two sweets.
Mike has n sweets with sizes a_1, ... |
### Prompt
Create a solution in CPP for the following problem:
Nikita likes tasks on order statistics, for example, he can easily find the k-th number in increasing order on a segment of an array. But now Nikita wonders how many segments of an array there are such that a given number x is the k-th number in increasin... |
### Prompt
Your challenge is to write a cpp solution to the following problem:
Iahub is so happy about inventing bubble sort graphs that he's staying all day long at the office and writing permutations. Iahubina is angry that she is no more important for Iahub. When Iahub goes away, Iahubina comes to his office and s... |
### Prompt
Your task is to create a cpp solution to the following problem:
Haiku is a genre of Japanese traditional poetry.
A haiku poem consists of 17 syllables split into three phrases, containing 5, 7 and 5 syllables correspondingly (the first phrase should contain exactly 5 syllables, the second phrase should co... |
### Prompt
Your challenge is to write a Cpp solution to the following problem:
A and B are preparing themselves for programming contests.
To train their logical thinking and solve problems better, A and B decided to play chess. During the game A wondered whose position is now stronger.
For each chess piece we know ... |
### Prompt
In Cpp, your task is to solve the following problem:
Polycarp has recently created a new level in this cool new game Berlio Maker 85 and uploaded it online. Now players from all over the world can try his level.
All levels in this game have two stats to them: the number of plays and the number of clears. ... |
### Prompt
In CPP, your task is to solve the following problem:
Input
The input contains a single integer a (0 β€ a β€ 35).
Output
Output a single integer.
Examples
Input
3
Output
8
Input
10
Output
1024
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int factors[1010 + 10];
int main... |
### Prompt
In cpp, your task is to solve the following problem:
There are n players numbered from 0 to n-1 with ranks. The i-th player has rank i.
Players can form teams: the team should consist of three players and no pair of players in the team should have a conflict. The rank of the team is calculated using the f... |
### Prompt
Generate a CPP solution to the following problem:
Gildong was hiking a mountain, walking by millions of trees. Inspired by them, he suddenly came up with an interesting idea for trees in data structures: What if we add another edge in a tree?
Then he found that such tree-like graphs are called 1-trees. Si... |
### Prompt
Please provide a CPP coded solution to the problem described below:
Vladimir wants to modernize partitions in his office. To make the office more comfortable he decided to remove a partition and plant several bamboos in a row. He thinks it would be nice if there are n bamboos in a row, and the i-th from th... |
### Prompt
In CPP, your task is to solve the following problem:
There are n people in a row. The height of the i-th person is a_i. You can choose any subset of these people and try to arrange them into a balanced circle.
A balanced circle is such an order of people that the difference between heights of any adjacent... |
### Prompt
Develop a solution in cpp to the problem described below:
You are given an array a of length n.
You are also given a set of distinct positions p_1, p_2, ..., p_m, where 1 β€ p_i < n. The position p_i means that you can swap elements a[p_i] and a[p_i + 1]. You can apply this operation any number of times fo... |
### Prompt
Generate 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 rectangular region with ... |
### Prompt
In Cpp, your task is to solve the following problem:
A and B are preparing themselves for programming contests.
B loves to debug his code. But before he runs the solution and starts debugging, he has to first compile the code.
Initially, the compiler displayed n compilation errors, each of them is repres... |
### Prompt
Develop a solution in cpp to the problem described below:
Mrs. Smith is trying to contact her husband, John Smith, but she forgot the secret phone number!
The only thing Mrs. Smith remembered was that any permutation of n can be a secret phone number. Only those permutations that minimize secret value mig... |
### Prompt
Please create a solution in cpp to the following problem:
"Teishi-zushi", a Japanese restaurant, is a plain restaurant with only one round counter. The outer circumference of the counter is C meters. Customers cannot go inside the counter.
Nakahashi entered Teishi-zushi, and he was guided to the counter. ... |
### Prompt
Construct a Cpp code solution to the problem outlined:
The crowdedness of the discotheque would never stop our friends from having fun, but a bit more spaciousness won't hurt, will it?
The discotheque can be seen as an infinite xy-plane, in which there are a total of n dancers. Once someone starts moving ... |
### Prompt
Your task is to create a cpp solution to the following problem:
Ujan has a lot of numbers in his boxes. He likes order and balance, so he decided to reorder the numbers.
There are k boxes numbered from 1 to k. The i-th box contains n_i integer numbers. The integers can be negative. All of the integers are... |
### Prompt
Create a solution in Cpp for the following problem:
You are given an n Γ m table, consisting of characters Β«AΒ», Β«GΒ», Β«CΒ», Β«TΒ». Let's call a table nice, if every 2 Γ 2 square contains all four distinct characters. Your task is to find a nice table (also consisting of Β«AΒ», Β«GΒ», Β«CΒ», Β«TΒ»), that differs from t... |
### Prompt
Develop a solution in cpp to the problem described below:
The Smart Beaver from ABBYY has a lot of hobbies. One of them is constructing efficient hash tables. One of the most serious problems in hash tables is resolving collisions. The Beaver is interested in this problem very much and he decided to explor... |
### Prompt
Your challenge is to write a cpp solution to the following problem:
Iahub is playing an uncommon game. Initially, he has n boxes, numbered 1, 2, 3, ..., n. Each box has some number of candies in it, described by a sequence a1, a2, ..., an. The number ak represents the number of candies in box k.
The goal... |
### Prompt
Your task is to create a CPP solution to the following problem:
One day Vasya was going home when he saw a box lying on the road. The box can be represented as a rectangular parallelepiped. Vasya needed no time to realize that the box is special, as all its edges are parallel to the coordinate axes, one of... |
### Prompt
Please create a solution in CPP to the following problem:
You are given n segments on the coordinate axis Ox and the number k. The point is satisfied if it belongs to at least k segments. Find the smallest (by the number of segments) set of segments on the coordinate axis Ox which contains all satisfied po... |
### Prompt
Develop a solution in cpp to the problem described below:
Shichikuji is the new resident deity of the South Black Snail Temple. Her first job is as follows:
There are n new cities located in Prefecture X. Cities are numbered from 1 to n. City i is located x_i km North of the shrine and y_i km East of the ... |
### Prompt
Your challenge is to write a CPP solution to the following problem:
A tree is a connected undirected graph consisting of n vertices and n - 1 edges. Vertices are numbered 1 through n.
Limak is a little polar bear and Radewoosh is his evil enemy. Limak once had a tree but Radewoosh stolen it. Bear is very ... |
### Prompt
Your task is to create a cpp solution to the following problem:
You are given n segments [l_1, r_1], [l_2, r_2], ..., [l_n, r_n]. Each segment has one of two colors: the i-th segment's color is t_i.
Let's call a pair of segments i and j bad if the following two conditions are met:
* t_i β t_j;
* the... |
### Prompt
Generate a cpp solution to the following problem:
Mishka received a gift of multicolored pencils for his birthday! Unfortunately he lives in a monochrome world, where everything is of the same color and only saturation differs. This pack can be represented as a sequence a1, a2, ..., an of n integer numbers... |
### Prompt
Generate a Cpp solution to the following problem:
qd ucyhf yi q fhycu dkcruh mxeiu huluhiu yi q tyvvuhudj fhycu dkcruh. oekh jqia yi je vydt jxu djx ucyhf.
Input
jxu ydfkj sediyiji ev q iydwbu ydjuwuh d (1 β€ d β€ 11184) β jxu edu-rqiut ydtun ev jxu ucyhf je vydt.
Output
ekjfkj q iydwbu dkcruh.
Examples... |
### Prompt
Create a solution in Cpp for the following problem:
Given an integer a as input, print the value a + a^2 + a^3.
Constraints
* 1 \leq a \leq 10
* a is an integer.
Input
Input is given from Standard Input in the following format:
a
Output
Print the value a + a^2 + a^3 as an integer.
Examples
Input... |
### Prompt
Construct a cpp code solution to the problem outlined:
problem
You are looking for a constellation in a picture of the starry sky. The photo always contains exactly one figure with the same shape, orientation, and size as the constellation you are looking for. However, there is a possibility that extra st... |
### Prompt
Construct a CPP code solution to the problem outlined:
For long time scientists study the behavior of sharks. Sharks, as many other species, alternate short movements in a certain location and long movements between locations.
Max is a young biologist. For n days he watched a specific shark, and now he kn... |
### Prompt
Please provide a CPP coded solution to the problem described below:
Urpal lives in a big city. He has planned to meet his lover tonight.
The city has n junctions numbered from 1 to n. The junctions are connected by m directed streets, all the roads have equal length. Urpal lives in junction a and the dat... |
### Prompt
In Cpp, your task is to solve the following problem:
problem
You are playing with J using the Midakuji. The Amida lottery consists of n vertical bars and m horizontal bars. The vertical bars are numbered from 1 to n in order from the left, and the vertical bar i The positive integer si is written at the b... |
### Prompt
Develop a solution in Cpp to the problem described below:
Vova is playing a computer game. There are in total n turns in the game and Vova really wants to play all of them. The initial charge of his laptop battery (i.e. the charge before the start of the game) is k.
During each turn Vova can choose what t... |
### Prompt
Please provide a CPP coded solution to the problem described below:
Write a program which judges wheather given length of three side form a right triangle. Print "YES" if the given sides (integers) form a right triangle, "NO" if not so.
Constraints
* 1 β€ length of the side β€ 1,000
* N β€ 1,000
Input
Inp... |
### Prompt
Construct a cpp code solution to the problem outlined:
There are N cities in Republic of AtCoder. The size of the i-th city is A_{i}. Takahashi would like to build N-1 bidirectional roads connecting two cities so that any city can be reached from any other city by using these roads.
Assume that the cost o... |
### Prompt
Please formulate a cpp solution to the following problem:
You have written on a piece of paper an array of n positive integers a[1], a[2], ..., a[n] and m good pairs of integers (i1, j1), (i2, j2), ..., (im, jm). Each good pair (ik, jk) meets the following conditions: ik + jk is an odd number and 1 β€ ik < ... |
### Prompt
Please create a solution in cpp to the following problem:
Nauuo is a girl who loves playing cards.
One day she was playing cards but found that the cards were mixed with some empty ones.
There are n cards numbered from 1 to n, and they were mixed with another n empty cards. She piled up the 2n cards and ... |
### Prompt
Construct a Cpp code solution to the problem outlined:
You have an array a_1, a_2, ..., a_n.
Let's call some subarray a_l, a_{l + 1}, ... , a_r of this array a subpermutation if it contains all integers from 1 to r-l+1 exactly once. For example, array a = [2, 2, 1, 3, 2, 3, 1] contains 6 subarrays which ... |
### Prompt
Generate a CPP solution to the following problem:
Two integers x and y are compatible, if the result of their bitwise "AND" equals zero, that is, a & b = 0. For example, numbers 90 (10110102) and 36 (1001002) are compatible, as 10110102 & 1001002 = 02, and numbers 3 (112) and 6 (1102) are not compatible, a... |
### Prompt
In CPP, your task is to solve the following problem:
We will say that two integer sequences of length N, x_1, x_2, ..., x_N and y_1, y_2, ..., y_N, are similar when |x_i - y_i| \leq 1 holds for all i (1 \leq i \leq N).
In particular, any integer sequence is similar to itself.
You are given an integer N a... |
### Prompt
In Cpp, your task is to solve the following problem:
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 so each unchosen... |
### Prompt
Generate a Cpp solution to the following problem:
Sereja has an n Γ m rectangular table a, each cell of the table contains a zero or a number one. Sereja wants his table to meet the following requirement: each connected component of the same values forms a rectangle with sides parallel to the sides of the ... |
### Prompt
Develop a solution in CPP to the problem described below:
Student Dima from Kremland has a matrix a of size n Γ m filled with non-negative integers.
He wants to select exactly one integer from each row of the matrix so that the bitwise exclusive OR of the selected integers is strictly greater than zero. H... |
### Prompt
Please provide a CPP coded solution to the problem described below:
Takahashi is solving quizzes. He has easily solved all but the last one.
The last quiz has three choices: 1, 2, and 3.
With his supernatural power, Takahashi has found out that the choices A and B are both wrong.
Print the correct choic... |
### Prompt
Create a solution in cpp for the following problem:
There are N panels arranged in a row in Takahashi's house, numbered 1 through N. The i-th panel has a number A_i written on it. Takahashi is playing by throwing balls at these panels.
Takahashi threw a ball K times. Let the panel hit by a boll in the i-t... |
### Prompt
Your task is to create a cpp solution to the following problem:
A little boy Gerald entered a clothes shop and found out something very unpleasant: not all clothes turns out to match. For example, Gerald noticed that he looks rather ridiculous in a smoking suit and a baseball cap.
Overall the shop sells n... |
### Prompt
In cpp, your task is to solve the following problem:
The time is 2020. There is data that saves the qualifying results of PC Koshien 2020. This data stores the reference number and the number of correct answers assigned to each team. Here, the ranking is determined by the number of correct answers, and the... |
### Prompt
Create a solution in Cpp for the following problem:
Little boy Igor wants to become a traveller. At first, he decided to visit all the cities of his motherland β Uzhlyandia.
It is widely known that Uzhlyandia has n cities connected with m bidirectional roads. Also, there are no two roads in the country th... |
### Prompt
Create a solution in Cpp for the following problem:
A conglomerate consists of n companies. To make managing easier, their owners have decided to merge all companies into one. By law, it is only possible to merge two companies, so the owners plan to select two companies, merge them into one, and continue d... |
### Prompt
Please provide a cpp coded solution to the problem described below:
You are given a matrix consisting of digits zero and one, its size is n Γ m. You are allowed to rearrange its rows. What is the maximum area of the submatrix that only consists of ones and can be obtained in the given problem by the descri... |
### Prompt
Please formulate a CPP solution to the following problem:
Valera loves to participate in competitions. Especially in programming contests. Today he has participated in the contest with his team, consisting of n students (including Valera). This contest was an individual competition, so each student in the ... |
### Prompt
Construct a CPP code solution to the problem outlined:
There are N balls in a two-dimensional plane. The i-th ball is at coordinates (x_i, y_i).
We will collect all of these balls, by choosing two integers p and q such that p \neq 0 or q \neq 0 and then repeating the following operation:
* Choose a ball ... |
### Prompt
Generate a Cpp solution to the following problem:
Write a program which converts uppercase/lowercase letters to lowercase/uppercase for a given string.
Constraints
* The length of the input string < 1200
Input
A string is given in a line.
Output
Print the converted string in a line. Note that you do ... |
### Prompt
Please formulate a cpp solution to the following problem:
Okabe needs bananas for one of his experiments for some strange reason. So he decides to go to the forest and cut banana trees.
Consider the point (x, y) in the 2D plane such that x and y are integers and 0 β€ x, y. There is a tree in such a point, ... |
### Prompt
Your task is to create a cpp solution to the following problem:
Recently you've discovered a new shooter. They say it has realistic game mechanics.
Your character has a gun with magazine size equal to k and should exterminate n waves of monsters. The i-th wave consists of a_i monsters and happens from the... |
### Prompt
Generate a Cpp solution to the following problem:
Inna loves sleeping very much, so she needs n alarm clocks in total to wake up. Let's suppose that Inna's room is a 100 Γ 100 square with the lower left corner at point (0, 0) and with the upper right corner at point (100, 100). Then the alarm clocks are po... |
### Prompt
Construct a Cpp code solution to the problem outlined:
Given simple (without self-intersections) n-gon. It is not necessary convex. Also you are given m lines. For each line find the length of common part of the line and the n-gon.
The boundary of n-gon belongs to polygon. It is possible that n-gon contai... |
### Prompt
Generate a CPP solution to the following problem:
ZS the Coder and Chris the Baboon are travelling to Udayland! To get there, they have to get on the special IOI bus. The IOI bus has n rows of seats. There are 4 seats in each row, and the seats are separated into pairs by a walkway. When ZS and Chris came,... |
### Prompt
Your challenge is to write a Cpp solution to the following problem:
Programmers' kids solve this riddle in 5-10 minutes. How fast can you do it?
Input
The input contains a single integer n (0 β€ n β€ 2000000000).
Output
Output a single integer.
Examples
Input
11
Output
2
Input
14
Output
0
I... |
### Prompt
Generate a cpp solution to the following problem:
B: Periodic Sequence-
problem
Dr. Period, a professor at H University, is studying a property called the cycle that is supposed to be hidden in all things. As a generally known basic cycle, a cycle hidden in a sequence may be considered. That is, if the s... |
### Prompt
In CPP, your task is to solve the following problem:
The range search problem consists of a set of attributed records S to determine which records from S intersect with a given range.
For n points on a plane, report a set of points which are within in a given range. Note that you do not need to consider i... |
### Prompt
Construct a Cpp code solution to the problem outlined:
In one of the games Arkady is fond of the game process happens on a rectangular field. In the game process Arkady can buy extensions for his field, each extension enlarges one of the field sizes in a particular number of times. Formally, there are n ex... |
### Prompt
Your challenge is to write a Cpp solution to the following problem:
Mr. Bender has a digital table of size n Γ n, each cell can be switched on or off. He wants the field to have at least c switched on squares. When this condition is fulfilled, Mr Bender will be happy.
We'll consider the table rows numbere... |
### Prompt
Develop a solution in cpp to the problem described below:
There is a robot in a warehouse and n packages he wants to collect. The warehouse can be represented as a coordinate grid. Initially, the robot stays at the point (0, 0). The i-th package is at the point (x_i, y_i). It is guaranteed that there are n... |
### Prompt
In cpp, your task is to solve the following problem:
To improve the boomerang throwing skills of the animals, Zookeeper has set up an n Γ n grid with some targets, where each row and each column has at most 2 targets each. The rows are numbered from 1 to n from top to bottom, and the columns are numbered f... |
### Prompt
In CPP, your task is to solve the following problem:
M-kun has the following three cards:
* A red card with the integer A.
* A green card with the integer B.
* A blue card with the integer C.
He is a genius magician who can do the following operation at most K times:
* Choose one of the three cards an... |
### Prompt
Please provide a CPP coded solution to the problem described below:
You are given an integer sequence a of length N. How many permutations p of the integers 1 through N satisfy the following condition?
* For each 1 β€ i β€ N, at least one of the following holds: p_i = a_i and p_{p_i} = a_i.
Find the coun... |
### Prompt
Please create a solution in cpp to the following problem:
Theseus has just arrived to Crete to fight Minotaur. He found a labyrinth that has a form of a rectangular field of size n Γ m and consists of blocks of size 1 Γ 1.
Each block of the labyrinth has a button that rotates all blocks 90 degrees clockwi... |
### Prompt
Your challenge is to write a cpp solution to the following problem:
There is an infinitely large pond, which we consider as a number line. In this pond, there are N lotuses floating at coordinates 0, 1, 2, ..., N-2 and N-1. On the lotus at coordinate i, an integer s_i is written.
You are standing on the l... |
### Prompt
Generate a Cpp solution to the following problem:
Let's define a balanced multiset the following way. Write down the sum of all elements of the multiset in its decimal representation. For each position of that number check if the multiset includes at least one element such that the digit of the element and... |
### Prompt
Your challenge is to write a cpp solution to the following problem:
SmallR is an archer. SmallR is taking a match of archer with Zanoes. They try to shoot in the target in turns, and SmallR shoots first. The probability of shooting the target each time is <image> for SmallR while <image> for Zanoes. The on... |
### Prompt
Please formulate a cpp solution to the following problem:
Mahmoud has an array a consisting of n integers. He asked Ehab to find another array b of the same length such that:
* b is lexicographically greater than or equal to a.
* bi β₯ 2.
* b is pairwise coprime: for every 1 β€ i < j β€ n, bi and bj ... |
### Prompt
Please formulate a cpp solution to the following problem:
Greg has an array a = a1, a2, ..., an and m operations. Each operation looks as: li, ri, di, (1 β€ li β€ ri β€ n). To apply operation i to the array means to increase all array elements with numbers li, li + 1, ..., ri by value di.
Greg wrote down k q... |
### Prompt
Your task is to create a CPP solution to the following problem:
Takahashi's office has N rooms. Each room has an ID from 1 to N. There are also N-1 corridors, and the i-th corridor connects Room a_i and Room b_i. It is known that we can travel between any two rooms using only these corridors.
Takahashi ha... |
### Prompt
Generate a Cpp solution to the following problem:
You are playing a video game and you have just reached the bonus level, where the only possible goal is to score as many points as possible. Being a perfectionist, you've decided that you won't leave this level until you've gained the maximum possible numbe... |
### Prompt
Please formulate a CPP solution to the following problem:
There are n children, who study at the school β41. It is well-known that they are good mathematicians. Once at a break, they arranged a challenge for themselves. All children arranged in a row and turned heads either to the left or to the right.
Ch... |
### Prompt
Your challenge is to write a CPP solution to the following problem:
You helped Dima to have a great weekend, but it's time to work. Naturally, Dima, as all other men who have girlfriends, does everything wrong.
Inna and Dima are now in one room. Inna tells Dima off for everything he does in her presence. ... |
### Prompt
Please create a solution in cpp to the following problem:
Xenia likes puzzles very much. She is especially fond of the puzzles that consist of domino pieces. Look at the picture that shows one of such puzzles.
<image>
A puzzle is a 3 Γ n table with forbidden cells (black squares) containing dominoes (col... |
### Prompt
Your challenge is to write a Cpp solution to the following problem:
Takeshi, who loves hot springs, is planning a trip to a hot spring resort on his next long vacation. I would like to travel by connecting to a long-distance bus and reach my destination with as little money as possible. Takeshi, who has sa... |
### Prompt
Please create a solution in cpp to the following problem:
Osaki
Osaki
English text is not available in this practice contest.
The Yamanote Line is a circular railway line laid in the 23 wards of Tokyo. The total route distance is 34.5km, and one lap takes about one hour. There are 29 stations in total. ... |
### Prompt
Generate a Cpp solution to the following problem:
Amr bought a new video game "Guess Your Way Out!". The goal of the game is to find an exit from the maze that looks like a perfect binary tree of height h. The player is initially standing at the root of the tree and the exit from the tree is located at som... |
### Prompt
Your task is to create a Cpp solution to the following problem:
You are given a positive integer n greater or equal to 2. For every pair of integers a and b (2 β€ |a|, |b| β€ n), you can transform a into b if and only if there exists an integer x such that 1 < |x| and (a β
x = b or b β
x = a), where |x| deno... |
### Prompt
Your task is to create a cpp solution to the following problem:
In Japan, temperature is usually expressed using the Celsius (β) scale. In America, they used the Fahrenheit (β) scale instead. $20$ degrees Celsius is roughly equal to $68$ degrees Fahrenheit. A phrase such as "Todayβs temperature is $68$ deg... |
### Prompt
Construct a CPP code solution to the problem outlined:
A tree is an undirected graph with exactly one simple path between each pair of vertices. We call a set of simple paths k-valid if each vertex of the tree belongs to no more than one of these paths (including endpoints) and each path consists of exactl... |
### Prompt
Please create a solution in cpp to the following problem:
In BerSoft n programmers work, the programmer i is characterized by a skill r_i.
A programmer a can be a mentor of a programmer b if and only if the skill of the programmer a is strictly greater than the skill of the programmer b (r_a > r_b) and pr... |
### Prompt
Your task is to create a cpp solution to the following problem:
The letters shop showcase is a string s, consisting of n lowercase Latin letters. As the name tells, letters are sold in the shop.
Letters are sold one by one from the leftmost to the rightmost. Any customer can only buy some prefix of letter... |
### Prompt
Please formulate a Cpp solution to the following problem:
Recently Lynyrd and Skynyrd went to a shop where Lynyrd bought a permutation p of length n, and Skynyrd bought an array a of length m, consisting of integers from 1 to n.
Lynyrd and Skynyrd became bored, so they asked you q queries, each of which ... |
### Prompt
Generate a cpp solution to the following problem:
Your friend has recently learned about coprime numbers. A pair of numbers {a, b} is called coprime if the maximum number that divides both a and b is equal to one.
Your friend often comes up with different statements. He has recently supposed that if the ... |
### Prompt
Please provide a CPP coded solution to the problem described below:
There are an integer sequence A_1,...,A_N consisting of N terms, and N buttons. When the i-th (1 β¦ i β¦ N) button is pressed, the values of the i terms from the first through the i-th are all incremented by 1.
There is also another integer... |
### Prompt
Please formulate a Cpp solution to the following problem:
There are lots of theories concerning the origin of moon craters. Most scientists stick to the meteorite theory, which says that the craters were formed as a result of celestial bodies colliding with the Moon. The other version is that the craters w... |
### Prompt
Your challenge is to write a CPP solution to the following problem:
The DNA sequence for every living creature in Berland can be represented as a non-empty line consisting of lowercase Latin letters. Berland scientists found out that all the creatures evolve by stages. During one stage exactly one symbol o... |
### Prompt
Please formulate a CPP solution 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
In Cpp, your task is to solve the following problem:
You are given an undirected graph where each edge has one of two colors: black or red.
Your task is to assign a real number to each node so that:
* for each black edge the sum of values at its endpoints is 1;
* for each red edge the sum of values... |
### Prompt
Please provide a CPP coded solution to the problem described below:
Everyone knows what the Fibonacci sequence is. This sequence can be defined by the recurrence relation:
F1 = 1, F2 = 2, Fi = Fi - 1 + Fi - 2 (i > 2).
We'll define a new number sequence Ai(k) by the formula:
Ai(k) = Fi Γ ik (i β₯ 1).
I... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.