text stringlengths 424 69.5k |
|---|
### Prompt
Please provide a CPP coded solution to the problem described below:
Little Petya very much likes gifts. Recently he has received a new laptop as a New Year gift from his mother. He immediately decided to give it to somebody else as what can be more pleasant than giving somebody gifts. And on this occasion ... |
### Prompt
Your task is to create a CPP solution to the following problem:
Even if the world is full of counterfeits, I still regard it as wonderful.
Pile up herbs and incense, and arise again from the flames and ashes of its predecessor — as is known to many, the phoenix does it like this.
The phoenix has a rather... |
### Prompt
Please formulate a cpp solution to the following problem:
You work in a big office. It is a 9 floor building with an elevator that can accommodate up to 4 people. It is your responsibility to manage this elevator.
Today you are late, so there are queues on some floors already. For each person you know the... |
### Prompt
Generate a cpp solution to the following problem:
One tradition of ACM-ICPC contests is that a team gets a balloon for every solved problem. We assume that the submission time doesn't matter and teams are sorted only by the number of balloons they have. It means that one's place is equal to the number of t... |
### Prompt
Your challenge is to write a CPP solution to the following problem:
Given an integer x. Your task is to find out how many positive integers n (1 ≤ n ≤ x) satisfy $$$n ⋅ a^n ≡ b (mod\;p), where a, b, p$$$ are all known constants.
Input
The only line contains four integers a,b,p,x (2 ≤ p ≤ 10^6+3, 1 ≤ a,... |
### Prompt
Your challenge is to write a cpp solution to the following problem:
Write a program which computes the digit number of sum of two integers a and b.
Constraints
* 0 ≤ a, b ≤ 1,000,000
* The number of datasets ≤ 200
Input
There are several test cases. Each test case consists of two non-negative integers ... |
### Prompt
Your challenge is to write a Cpp solution to the following problem:
PMP is getting a warrior. He is practicing a lot, but the results are not acceptable yet. This time instead of programming contests, he decided to compete in a car racing to increase the spirit of victory. He decides to choose a competitio... |
### Prompt
Develop a solution in CPP to the problem described below:
At the Byteland State University marks are strings of the same length. Mark x is considered better than y if string y is lexicographically smaller than x.
Recently at the BSU was an important test work on which Vasya recived the mark a. It is very ... |
### Prompt
Your task is to create a CPP solution to the following problem:
This is the hard version of the problem. The only difference is that here 2≤ k≤ 100. You can make hacks only if both the versions of the problem are solved.
This is an interactive problem!
Every decimal number has a base k equivalent. The in... |
### Prompt
Your task is to create a cpp solution to the following problem:
The Smart Beaver from ABBYY invented a new message encryption method and now wants to check its performance. Checking it manually is long and tiresome, so he decided to ask the ABBYY Cup contestants for help.
A message is a sequence of n inte... |
### Prompt
Develop a solution in Cpp to the problem described below:
Cat Noku has obtained a map of the night sky. On this map, he found a constellation with n stars numbered from 1 to n. For each i, the i-th star is located at coordinates (xi, yi). No two stars are located at the same position.
In the evening Noku ... |
### Prompt
Develop a solution in CPP to the problem described below:
Nagini, being a horcrux You-know-who created with the murder of Bertha Jorkins, has accumulated its army of snakes and is launching an attack on Hogwarts school.
Hogwarts' entrance can be imagined as a straight line (x-axis) from 1 to 105. Nagini ... |
### Prompt
Please create a solution in cpp to the following problem:
Ibis is fighting with a monster.
The health of the monster is H.
Ibis can cast N kinds of spells. Casting the i-th spell decreases the monster's health by A_i, at the cost of B_i Magic Points.
The same spell can be cast multiple times. There is n... |
### Prompt
Your task is to create a CPP solution to the following problem:
As a tradition, every year before IOI all the members of Natalia Fan Club are invited to Malek Dance Club to have a fun night together. Malek Dance Club has 2n members and coincidentally Natalia Fan Club also has 2n members. Each member of MDC... |
### Prompt
Develop a solution in CPP to the problem described below:
Taro and Hanako are playing card games. They have n cards each, and they compete n turns. At each turn Taro and Hanako respectively puts out a card. The name of the animal consisting of alphabetical letters is written on each card, and the bigger on... |
### Prompt
Please provide a cpp coded solution to the problem described below:
The Holmes children are fighting over who amongst them is the cleverest.
Mycroft asked Sherlock and Eurus to find value of f(n), where f(1) = 1 and for n ≥ 2, f(n) is the number of distinct ordered positive integer pairs (x, y) that satis... |
### Prompt
Your challenge is to write a CPP solution to the following problem:
This is the harder version of the problem. In this version, 1 ≤ n, m ≤ 2⋅10^5. You can hack this problem if you locked it. But you can hack the previous problem only if you locked both problems.
You are given a sequence of integers a=[a_1... |
### Prompt
In cpp, your task is to solve the following problem:
Snuke has an integer sequence A of length N.
He will make three cuts in A and divide it into four (non-empty) contiguous subsequences B, C, D and E. The positions of the cuts can be freely chosen.
Let P,Q,R,S be the sums of the elements in B,C,D,E, res... |
### Prompt
Your challenge is to write a Cpp solution to the following problem:
Iahub wants to meet his girlfriend Iahubina. They both live in Ox axis (the horizontal axis). Iahub lives at point 0 and Iahubina at point d.
Iahub has n positive integers a1, a2, ..., an. The sum of those numbers is d. Suppose p1, p2, ..... |
### Prompt
Your task is to create a Cpp solution to the following problem:
You have a coins of value n and b coins of value 1. You always pay in exact change, so you want to know if there exist such x and y that if you take x (0 ≤ x ≤ a) coins of value n and y (0 ≤ y ≤ b) coins of value 1, then the total value of tak... |
### Prompt
Generate a CPP solution to the following problem:
For the New Year, Polycarp decided to send postcards to all his n friends. He wants to make postcards with his own hands. For this purpose, he has a sheet of paper of size w × h, which can be cut into pieces.
Polycarp can cut any sheet of paper w × h that ... |
### Prompt
Your challenge is to write a Cpp solution to the following problem:
In an attempt to make peace with the Mischievious Mess Makers, Bessie and Farmer John are planning to plant some flower gardens to complement the lush, grassy fields of Bovinia. As any good horticulturist knows, each garden they plant must... |
### Prompt
Create a solution in CPP for the following problem:
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 larger th... |
### Prompt
Construct a CPP code solution to the problem outlined:
Lesha plays the recently published new version of the legendary game hacknet. In this version character skill mechanism was introduced. Now, each player character has exactly n skills. Each skill is represented by a non-negative integer ai — the curren... |
### Prompt
Generate a Cpp solution to the following problem:
A non-empty string s is called binary, if it consists only of characters "0" and "1". Let's number the characters of binary string s from 1 to the string's length and let's denote the i-th character in string s as si.
Binary string s with length n is perio... |
### Prompt
Develop a solution in cpp to the problem described below:
Yaroslav has an array, consisting of (2·n - 1) integers. In a single operation Yaroslav can change the sign of exactly n elements in the array. In other words, in one operation Yaroslav can select exactly n array elements, and multiply each of them ... |
### Prompt
Develop a solution in cpp to the problem described below:
Andrew skipped lessons on the subject 'Algorithms and Data Structures' for the entire term. When he came to the final test, the teacher decided to give him a difficult task as a punishment.
The teacher gave Andrew an array of n numbers a1, ..., an.... |
### Prompt
Please create a solution in Cpp to the following problem:
Consider a sequence [a1, a2, ... , an]. Define its prefix product sequence <image>.
Now given n, find a permutation of [1, 2, ..., n], such that its prefix product sequence is a permutation of [0, 1, ..., n - 1].
Input
The only input line contain... |
### Prompt
Generate a Cpp solution to the following problem:
You are given n strings a_1, a_2, …, a_n: all of them have the same length m. The strings consist of lowercase English letters.
Find any string s of length m such that each of the given n strings differs from s in at most one position. Formally, for each g... |
### Prompt
Construct a cpp code solution to the problem outlined:
Input
The only line of the input contains a string of digits. The length of the string is between 1 and 10, inclusive.
Output
Output "Yes" or "No".
Examples
Input
373
Output
Yes
Input
121
Output
No
Input
436
Output
Yes
### Respo... |
### Prompt
Your task is to create a CPP solution to the following problem:
Snuke has an integer sequence A of length N.
He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the sadness of Snuke is calculated as follows:
* abs(A_1 - (b+1)) + abs(A_2 - (... |
### Prompt
Please create a solution in Cpp to the following problem:
Given is a sequence of N digits a_1a_2\ldots a_N, where each element is 1, 2, or 3. Let x_{i,j} defined as follows:
* x_{1,j} := a_j \quad (1 \leq j \leq N)
* x_{i,j} := | x_{i-1,j} - x_{i-1,j+1} | \quad (2 \leq i \leq N and 1 \leq j \leq N+1-i)
... |
### Prompt
Your task is to create a Cpp solution to the following problem:
This year Alex has finished school, and now he is a first-year student of Berland State University. For him it was a total surprise that even though he studies programming, he still has to attend physical education lessons. The end of the term... |
### Prompt
Construct a cpp code solution to the problem outlined:
You are given a directed graph G which can contain loops (edges from a vertex to itself). Multi-edges are absent in G which means that for all ordered pairs (u, v) exists at most one edge from u to v. Vertices are numbered from 1 to n.
A path from u t... |
### Prompt
Please create a solution in Cpp to the following problem:
Sasha and Kolya decided to get drunk with Coke, again. This time they have k types of Coke. i-th type is characterised by its carbon dioxide concentration <image>. Today, on the party in honour of Sergiy of Vancouver they decided to prepare a glass ... |
### Prompt
Your challenge is to write a cpp solution to the following problem:
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about comp... |
### Prompt
Please provide a CPP coded solution to the problem described below:
Given is an integer N. Find the number of digits that N has in base K.
Constraints
* All values in input are integers.
* 1 \leq N \leq 10^9
* 2 \leq K \leq 10
Input
Input is given from Standard Input in the following format:
N K
Ou... |
### Prompt
Create a solution in cpp for the following problem:
Quick sort is based on the Divide-and-conquer approach. In QuickSort(A, p, r), first, a procedure Partition(A, p, r) divides an array A[p..r] into two subarrays A[p..q-1] and A[q+1..r] such that each element of A[p..q-1] is less than or equal to A[q], whi... |
### Prompt
Create a solution in Cpp for the following problem:
You are given two n × m matrices containing integers. A sequence of integers is strictly increasing if each next number is greater than the previous one. A row is strictly increasing if all numbers from left to right are strictly increasing. A column is s... |
### Prompt
Please formulate a cpp solution to the following problem:
<image>
You know the merry-go-round in the amusement park. Vehicles such as horses and carriages are fixed on a large disk, and it is a standard playset that the vehicle swings up and down at the same time as the disk rotates. A merry-go-round in ... |
### Prompt
In CPP, your task is to solve the following problem:
Consider an undirected graph G with n vertices. There is a value a_i in each vertex.
Two vertices i and j are connected with an edge if and only if gcd(a_i, a_j) > 1, where gcd(x, y) denotes the [greatest common divisor (GCD)](https://en.wikipedia.org/w... |
### Prompt
Your task is to create a CPP solution to the following problem:
We constructed a rectangular parallelepiped of dimensions A \times B \times C built of ABC cubic blocks of side 1. Then, we placed the parallelepiped in xyz-space as follows:
* For every triple i, j, k (0 \leq i < A, 0 \leq j < B, 0 \leq k < ... |
### Prompt
Construct a cpp code solution to the problem outlined:
Little Chris is a huge fan of linear algebra. This time he has been given a homework about the unusual square of a square matrix.
The dot product of two integer number vectors x and y of size n is the sum of the products of the corresponding component... |
### Prompt
Please provide a Cpp coded solution to the problem described below:
<!--
Problem E
-->
Cube Surface Puzzle
Given a set of six pieces, "Cube Surface Puzzle" is to construct a hollow cube with filled surface. Pieces of a puzzle is made of a number of small unit cubes laid grid-aligned on a plane. For a p... |
### Prompt
Generate a CPP solution to the following problem:
You've got array A, consisting of n integers and a positive integer k. Array A is indexed by integers from 1 to n.
You need to permute the array elements so that value
<image> became minimal possible. In particular, it is allowed not to change order of e... |
### Prompt
Develop a solution in Cpp to the problem described below:
Andrey's favourite number is n. Andrey's friends gave him two identical numbers n as a New Year present. He hung them on a wall and watched them adoringly.
Then Andrey got bored from looking at the same number and he started to swap digits first in... |
### Prompt
Construct a cpp code solution to the problem outlined:
Polycarp is an introvert person. In fact he is so much of an introvert that he plays "Monsters and Potions" board game alone. The board of the game is a row of n cells. The cells are numbered from 1 to n from left to right. There are three types of cel... |
### Prompt
Please create a solution in cpp to the following problem:
Two players, A and B, play the game using cards with numbers from 0 to 9. First, the two arrange the given n cards face down in a horizontal row. After that, the two players turn their cards face up one by one from the left, and the owner of the car... |
### Prompt
Construct a cpp code solution to the problem outlined:
You are given an integer a that consists of n digits. You are also given a sequence of digits s of length m. The digit in position j (1 ≤ j ≤ m) of sequence s means that you can choose an arbitrary position i (1 ≤ i ≤ n) in a and replace the digit in t... |
### Prompt
Please create a solution in cpp to the following problem:
2N players are running a competitive table tennis training on N tables numbered from 1 to N.
The training consists of rounds. In each round, the players form N pairs, one pair per table. In each pair, competitors play a match against each other. As... |
### Prompt
Your task is to create a Cpp solution to the following problem:
Arkady plays Gardenscapes a lot. Arkady wants to build two new fountains. There are n available fountains, for each fountain its beauty and cost are known. There are two types of money in the game: coins and diamonds, so each fountain cost can... |
### Prompt
In Cpp, your task is to solve the following problem:
Almost every text editor has a built-in function of center text alignment. The developers of the popular in Berland text editor «Textpad» decided to introduce this functionality into the fourth release of the product.
You are to implement the alignment ... |
### Prompt
Please provide a cpp coded solution to the problem described below:
You are given a string s consisting of n lowercase Latin letters.
Let's define a substring as a contiguous subsegment of a string. For example, "acab" is a substring of "abacaba" (it starts in position 3 and ends in position 6), but "aa" ... |
### Prompt
Your task is to create a CPP solution to the following problem:
ZS the Coder and Chris the Baboon has arrived at Udayland! They walked in the park where n trees grow. They decided to be naughty and color the trees in the park. The trees are numbered with integers from 1 to n from left to right.
Initially,... |
### Prompt
Please create a solution in cpp to the following problem:
Alice and Bob play a game. They have a binary string s (a string such that each character in it is either 0 or 1). Alice moves first, then Bob, then Alice again, and so on.
During their move, the player can choose any number (not less than one) of ... |
### Prompt
Please provide a cpp coded solution to the problem described below:
Alena has successfully passed the entrance exams to the university and is now looking forward to start studying.
One two-hour lesson at the Russian university is traditionally called a pair, it lasts for two academic hours (an academic ho... |
### Prompt
Please formulate a cpp solution to the following problem:
In one one-dimensional world there are n platforms. Platform with index k (platforms are numbered from 1) is a segment with coordinates [(k - 1)m, (k - 1)m + l], and l < m. Grasshopper Bob starts to jump along the platforms from point 0, with each j... |
### Prompt
Develop a solution in Cpp to the problem described below:
Graph constructive problems are back! This time the graph you are asked to build should match the following properties.
The graph is connected if and only if there exists a path between every pair of vertices.
The diameter (aka "longest shortest p... |
### Prompt
Create a solution in cpp for the following problem:
Nian is a monster which lives deep in the oceans. Once a year, it shows up on the land, devouring livestock and even people. In order to keep the monster away, people fill their villages with red colour, light, and cracking noise, all of which frighten th... |
### Prompt
Generate a Cpp solution to the following problem:
Living in Byteland was good enough to begin with, but the good king decided to please his subjects and to introduce a national language. He gathered the best of wise men, and sent an expedition to faraway countries, so that they would find out all about how... |
### Prompt
Please create a solution in cpp to the following problem:
Kostya is a genial sculptor, he has an idea: to carve a marble sculpture in the shape of a sphere. Kostya has a friend Zahar who works at a career. Zahar knows about Kostya's idea and wants to present him a rectangular parallelepiped of marble from ... |
### Prompt
Please provide a CPP coded solution to the problem described below:
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... |
### Prompt
Generate a Cpp solution to the following problem:
Three companies decided to order a billboard with pictures of their logos. A billboard is a big square board. A logo of each company is a rectangle of a non-zero area.
Advertisers will put up the ad only if it is possible to place all three logos on the b... |
### Prompt
Generate a CPP solution to the following problem:
We have a tree with N vertices and N-1 edges, respectively numbered 1, 2,\cdots, N and 1, 2, \cdots, N-1. Edge i connects Vertex u_i and v_i.
For integers L, R (1 \leq L \leq R \leq N), let us define a function f(L, R) as follows:
* Let S be the set of th... |
### Prompt
Generate a cpp solution to the following problem:
Today Adilbek is taking his probability theory test. Unfortunately, when Adilbek arrived at the university, there had already been a long queue of students wanting to take the same test. Adilbek has estimated that he will be able to start the test only T se... |
### Prompt
Your challenge is to write a CPP solution to the following problem:
Vasya has got three integers n, m and k. He'd like to find three integer points (x_1, y_1), (x_2, y_2), (x_3, y_3), such that 0 ≤ x_1, x_2, x_3 ≤ n, 0 ≤ y_1, y_2, y_3 ≤ m and the area of the triangle formed by these points is equal to nm/k... |
### Prompt
Your challenge is to write a CPP solution to the following problem:
Takahashi will do a tap dance. The dance is described by a string S where each character is `L`, `R`, `U`, or `D`. These characters indicate the positions on which Takahashi should step. He will follow these instructions one by one in orde... |
### Prompt
Your task is to create a CPP solution to the following problem:
Given a tree T with non-negative weight, find the height of each node of the tree. For each node, the height is the distance to the most distant leaf from the node.
Constraints
* 1 ≤ n ≤ 10,000
* 0 ≤ wi ≤ 1,000
Input
n
s1 t1 w1
s2 t2 w2
:... |
### Prompt
Generate 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 monsters, you can... |
### Prompt
Your task is to create a CPP solution to the following problem:
Helen works in Metropolis airport. She is responsible for creating a departure schedule. There are n flights that must depart today, the i-th of them is planned to depart at the i-th minute of the day.
Metropolis airport is the main transport... |
### Prompt
Please provide a cpp coded solution to the problem described below:
One day Natalia was walking in the woods when she met a little mushroom gnome. The gnome told her the following story:
Everybody knows that the mushroom gnomes' power lies in the magic mushrooms that grow in the native woods of the gnomes... |
### Prompt
Create a solution in cpp for the following problem:
Input
The input consists of a single string of uppercase letters A-Z. The length of the string is between 1 and 10 characters, inclusive.
Output
Output "YES" or "NO".
Examples
Input
GENIUS
Output
YES
Input
DOCTOR
Output
NO
Input
I... |
### Prompt
Construct a cpp code solution to the problem outlined:
PCK Taxi in Aizu city, owned by PCK company, has adopted a unique billing system: the user can decide the taxi fare. Today as usual, many people are waiting in a queue at the taxi stand in front of the station.
In front of the station, there are $N$ p... |
### Prompt
Construct a Cpp code solution to the problem outlined:
On the math lesson a teacher asked each pupil to come up with his own lucky numbers. As a fan of number theory Peter chose prime numbers. Bob was more original. He said that number t is his lucky number, if it can be represented as:
t = a2 + b2, whe... |
### Prompt
Create a solution in Cpp for the following problem:
There are n people taking part in auction today. The rules of auction are classical. There were n bids made, though it's not guaranteed they were from different people. It might happen that some people made no bids at all.
Each bid is define by two integ... |
### Prompt
Construct a Cpp code solution to the problem outlined:
Arseny likes to organize parties and invite people to it. However, not only friends come to his parties, but friends of his friends, friends of friends of his friends and so on. That's why some of Arseny's guests can be unknown to him. He decided to fi... |
### Prompt
Generate a CPP solution to the following problem:
Write a program which reads an integer n and identifies the number of combinations of a, b, c and d (0 ≤ a, b, c, d ≤ 9) which meet the following equality:
a + b + c + d = n
For example, for n = 35, we have 4 different combinations of (a, b, c, d): (8, 9,... |
### Prompt
In Cpp, your task is to solve the following problem:
Problem D: Mr. Rito Post Office
You are a programmer working at a post office on a remote island. The area you live in consists of multiple islands. There is one or more port towns on each island. There may be other towns and villages in addition to the... |
### Prompt
Construct a CPP code solution to the problem outlined:
Everyone who has played Cut the Rope knows full well how the gameplay is organized. All levels in the game are divided into boxes. Initially only one box with some levels is available. Player should complete levels to earn stars, collecting stars opens... |
### Prompt
Generate a cpp solution to the following problem:
Edogawa Conan got tired of solving cases, and invited his friend, Professor Agasa, over. They decided to play a game of cards. Conan has n cards, and the i-th card has a number ai written on it.
They take turns playing, starting with Conan. In each turn, t... |
### Prompt
Construct a CPP code solution to the problem outlined:
The only difference between easy and hard versions is constraints.
Ivan plays a computer game that contains some microtransactions to make characters look cooler. Since Ivan wants his character to be really cool, he wants to use some of these microtra... |
### Prompt
Create a solution in CPP for the following problem:
When Valera was playing football on a stadium, it suddenly began to rain. Valera hid in the corridor under the grandstand not to get wet. However, the desire to play was so great that he decided to train his hitting the ball right in this corridor. Valera... |
### Prompt
Please formulate a CPP solution to the following problem:
<image>
There used to be a game called Joseph's potatoes. Let's say n people are participating. Participants form a circle facing the center and are numbered starting from 1. One hot potato is given to participant n (the large number 30 inside the... |
### Prompt
Your task is to create a cpp solution to the following problem:
This year Alex has finished school, and now he is a first-year student of Berland State University. For him it was a total surprise that even though he studies programming, he still has to attend physical education lessons. The end of the term... |
### Prompt
Generate a CPP solution to the following problem:
A tree is a graph with n vertices and exactly n - 1 edges; this graph should meet the following condition: there exists exactly one shortest (by number of edges) path between any pair of its vertices.
A subtree of a tree T is a tree with both vertices and ... |
### Prompt
In Cpp, your task is to solve the following problem:
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, some ... |
### Prompt
Construct a cpp code solution to the problem outlined:
A sequence a_1, a_2, ..., a_n is called good if, for each element a_i, there exists an element a_j (i ≠ j) such that a_i+a_j is a power of two (that is, 2^d for some non-negative integer d).
For example, the following sequences are good:
* [5, 3, 1... |
### Prompt
Please create a solution in CPP to the following problem:
Recently Anton found a box with digits in his room. There are k2 digits 2, k3 digits 3, k5 digits 5 and k6 digits 6.
Anton's favorite integers are 32 and 256. He decided to compose this integers from digits he has. He wants to make the sum of these... |
### Prompt
Your challenge is to write a CPP solution to the following problem:
Recently, a start up by two students of a state university of city F gained incredible popularity. Now it's time to start a new company. But what do we call it?
The market analysts came up with a very smart plan: the name of the company s... |
### Prompt
Generate a Cpp solution to the following problem:
Amr bought a new video game "Guess Your Way Out! II". 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 ... |
### Prompt
Develop a solution in CPP to the problem described below:
There are two bus stops denoted A and B, and there n buses that go from A to B every day. The shortest path from A to B takes t units of time but some buses might take longer paths. Moreover, buses are allowed to overtake each other during the route... |
### Prompt
Construct a CPP code solution to the problem outlined:
This problem is same as the next one, but has smaller constraints.
Aki is playing a new video game. In the video game, he will control Neko, the giant cat, to fly between planets in the Catniverse.
There are n planets in the Catniverse, numbered from... |
### Prompt
Please create a solution in Cpp to the following problem:
I decided to plant vegetables in the vegetable garden. There were n seeds, so I sown n seeds one by one a day over n days. All seeds sprout and grow quickly. I can't wait for the harvest time.
One day, when I was watering the seedlings as usual, I ... |
### Prompt
Your task is to create a Cpp solution to the following problem:
At the beginning of the school year Berland State University starts two city school programming groups, for beginners and for intermediate coders. The children were tested in order to sort them into groups. According to the results, each stude... |
### Prompt
Please formulate a CPP solution to the following problem:
You are given an integer sequence of length N. The i-th term in the sequence is a_i. In one operation, you can select a term and either increment or decrement it by one.
At least how many operations are necessary to satisfy the following conditions... |
### Prompt
Please formulate a Cpp solution to the following problem:
A new delivery of clothing has arrived today to the clothing store. This delivery consists of a ties, b scarves, c vests and d jackets.
The store does not sell single clothing items — instead, it sells suits of two types:
* a suit of the first t... |
### Prompt
Please provide a cpp coded solution to the problem described below:
There are n people and k keys on a straight line. Every person wants to get to the office which is located on the line as well. To do that, he needs to reach some point with a key, take the key and then go to the office. Once a key is take... |
### Prompt
In Cpp, your task is to solve the following problem:
You are given an integer N that has exactly four digits in base ten. How many times does `2` occur in the base-ten representation of N?
Constraints
* 1000 \leq N \leq 9999
Input
Input is given from Standard Input in the following format:
N
Output... |
### Prompt
Please formulate a cpp solution to the following problem:
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
Your task is to create a CPP solution to the following problem:
Sereja has two sequences a1, a2, ..., an and b1, b2, ..., bm, consisting of integers. One day Sereja got bored and he decided two play with them. The rules of the game was very simple. Sereja makes several moves, in one move he can perform one... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.