text
stringlengths
424
69.5k
### Prompt Generate a CPP solution to the following problem: You are developing frog-shaped robots, and decided to race them against each other. First, you placed N robots onto a number line. These robots are numbered 1 through N. The current coordinate of robot i is x_i. Here, all x_i are integers, and 0 < x_1 < x_...
### Prompt In CPP, your task is to solve the following problem: The MST (Meaningless State Team) company won another tender for an important state reform in Berland. There are n cities in Berland, some pairs of the cities are connected by roads. Each road has its price. One can move along any road in any direction. ...
### Prompt Construct a CPP code solution to the problem outlined: A tree is a connected graph that doesn't contain any cycles. The distance between two vertices of a tree is the length (in edges) of the shortest path between these vertices. You are given a tree with n vertices and a positive number k. Find the numb...
### Prompt Your task is to create a Cpp solution to the following problem: Vasya and Petya are using an interesting data storing structure: a pyramid. The pyramid consists of n rows, the i-th row contains i cells. Each row is shifted half a cell to the left relative to the previous row. The cells are numbered by int...
### Prompt Please provide a cpp coded solution to the problem described below: 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...
### Prompt Please create a solution in CPP to the following problem: Little Gerald and his coach Mike play an interesting game. At the beginning of the game there is a pile consisting of n candies and a pile consisting of m stones. Gerald and Mike move in turns, Mike goes first. During his move Mike checks how many c...
### Prompt Please provide a Cpp coded solution to the problem described below: The only difference between easy and hard versions is a number of elements in the array. You are given an array a consisting of n integers. The value of the i-th element of the array is a_i. You are also given a set of m segments. The j-...
### Prompt In cpp, your task is to solve the following problem: Berland, 2016. The exchange rate of currency you all know against the burle has increased so much that to simplify the calculations, its fractional part was neglected and the exchange rate is now assumed to be an integer. Reliable sources have informed ...
### Prompt Construct a cpp code solution to the problem outlined: You are given three integers x, y and n. Your task is to find the maximum integer k such that 0 ≤ k ≤ n that k mod x = y, where mod is modulo operation. Many programming languages use percent operator % to implement it. In other words, with given x, y...
### Prompt Your challenge is to write a Cpp solution to the following problem: These days Arkady works as an air traffic controller at a large airport. He controls a runway which is usually used for landings only. Thus, he has a schedule of planes that are landing in the nearest future, each landing lasts 1 minute. ...
### Prompt Create a solution in Cpp for the following problem: M-kun is a competitor in AtCoder, whose highest rating is X. In this site, a competitor is given a kyu (class) according to his/her highest rating. For ratings from 400 through 1999, the following kyus are given: * From 400 through 599: 8-kyu * From 600 ...
### Prompt Your task is to create a CPP solution to the following problem: Inna loves sweets very much. That's why she decided to play a game called "Sweet Matrix". Inna sees an n × m matrix and k candies. We'll index the matrix rows from 1 to n and the matrix columns from 1 to m. We'll represent the cell in the i-t...
### Prompt Your challenge is to write a CPP solution to the following problem: Recently Pashmak has been employed in a transportation company. The company has k buses and has a contract with a school which has n students. The school planned to take the students to d different places for d days (each day in one place)...
### Prompt Generate a Cpp solution to the following problem: JAG mock qualifying practice session The ACM-ICPC OB / OG Association (Japanese Alumni Group; JAG) has N questions in stock of questions to be asked in the mock contest, and each question is numbered with an integer from 1 to N. Difficulty evaluation and r...
### Prompt Please provide a Cpp coded solution to the problem described below: <image> Some time ago Slastyona the Sweetmaid decided to open her own bakery! She bought required ingredients and a wonder-oven which can bake several types of cakes, and opened the bakery. Soon the expenses started to overcome the incom...
### Prompt Create a solution in cpp for the following problem: This is an easier version of the next problem. The difference is only in constraints. You are given a rectangular n × m matrix a. In one move you can choose any column and cyclically shift elements in this column. You can perform this operation as many t...
### Prompt Please create a solution in CPP to the following problem: You are given n points on the plane. You need to delete exactly k of them (k < n) so that the diameter of the set of the remaining n - k points were as small as possible. The diameter of a set of points is the maximum pairwise distance between the p...
### Prompt Your task is to create a CPP solution to the following problem: The nth triangular number is defined as the sum of the first n positive integers. The nth tetrahedral number is defined as the sum of the first n triangular numbers. It is easy to show that the nth tetrahedral number is equal to n(n+1)(n+2) ⁄ ...
### Prompt Generate a cpp solution to the following problem: You are given an infinite checkered field. You should get from a square (x1; y1) to a square (x2; y2). Using the shortest path is not necessary. You can move on the field squares in four directions. That is, when you are positioned in any square, you can mo...
### Prompt Generate a Cpp solution to the following problem: Niwel is a little golden bear. As everyone knows, bears live in forests, but Niwel got tired of seeing all the trees so he decided to move to the city. In the city, Niwel took on a job managing bears to deliver goods. The city that he lives in can be repre...
### Prompt Please provide a cpp coded solution to the problem described below: Beroffice text editor has a wide range of features that help working with text. One of the features is an automatic search for typos and suggestions of how to fix them. Beroffice works only with small English letters (i.e. with 26 letters...
### Prompt Please create a solution in Cpp to the following problem: The sequence is called ordered if it is non-decreasing or non-increasing. For example, sequnces [3, 1, 1, 0] and [1, 2, 3, 100] are ordered, but the sequence [1, 3, 3, 1] is not. You are given a sequence of numbers. You are to find it's shortest sub...
### Prompt Please formulate a cpp solution to the following problem: problem You love pasta, and you make and eat pasta for dinner every day. You can make three types of pasta: tomato sauce, cream sauce, and basil sauce. I decided to plan a dinner for N days. Choose one of the three types of pasta each day. However...
### Prompt In Cpp, your task is to solve the following problem: Ksenia has an array a consisting of n positive integers a_1, a_2, …, a_n. In one operation she can do the following: * choose three distinct indices i, j, k, and then * change all of a_i, a_j, a_k to a_i ⊕ a_j ⊕ a_k simultaneously, where ⊕ denot...
### Prompt Develop a solution in CPP to the problem described below: The programming competition season has already started and it's time to train for ICPC. Sereja coaches his teams for a number of year and he knows that to get ready for the training session it's not enough to prepare only problems and editorial. As ...
### Prompt Please create a solution in Cpp to the following problem: Mishka is decorating the Christmas tree. He has got three garlands, and all of them will be put on the tree. After that Mishka will switch these garlands on. When a garland is switched on, it periodically changes its state — sometimes it is lit, so...
### Prompt Your task is to create a cpp solution to the following problem: Xenia the horse breeder has n (n > 1) horses that stand in a row. Each horse has its own unique number. Initially, the i-th left horse has number i. That is, the sequence of numbers of horses in a row looks as follows (from left to right): 1, ...
### Prompt Generate a CPP solution to the following problem: The only difference between easy and hard versions is the constraints. Vova likes pictures with kittens. The news feed in the social network he uses can be represented as an array of n consecutive pictures (with kittens, of course). Vova likes all these pi...
### Prompt Please create a solution in Cpp to the following problem: Imp is really pleased that you helped him. But it you solve the last problem, his gladness would raise even more. <image> Let's define <image> for some set of integers <image> as the number of pairs a, b in <image>, such that: * a is strictly le...
### Prompt Your challenge is to write a cpp solution to the following problem: You are given a string S. Takahashi can insert the character `A` at any position in this string any number of times. Can he change S into `AKIHABARA`? Constraints * 1 \leq |S| \leq 50 * S consists of uppercase English letters. Input ...
### Prompt Please formulate a CPP solution to the following problem: Appleman has a very big sheet of paper. This sheet has a form of rectangle with dimensions 1 × n. Your task is help Appleman with folding of such a sheet. Actually, you need to perform q queries. Each query will have one of the following types: 1...
### Prompt Generate a cpp solution to the following problem: Nikolay has only recently started in competitive programming, but already qualified to the finals of one prestigious olympiad. There going to be n participants, one of whom is Nikolay. Like any good olympiad, it consists of two rounds. Tired of the traditio...
### Prompt Construct a CPP code solution to the problem outlined: You are given two integers n and k. Your task is to find if n can be represented as a sum of k distinct positive odd (not divisible by 2) integers or not. You have to answer t independent test cases. Input The first line of the input contains one in...
### Prompt Develop a solution in Cpp to the problem described below: Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The ...
### Prompt Please create a solution in CPP to the following problem: The weather in Takahashi's town changes day by day, in the following cycle: Sunny, Cloudy, Rainy, Sunny, Cloudy, Rainy, ... Given is a string S representing the weather in the town today. Predict the weather tomorrow. Constraints * S is `Sunny`, ...
### Prompt In CPP, your task is to solve the following problem: Taro loves chocolate and when he returns from school he eats his favorite chocolate bar with a heart symbol on it. A recent pleasure is to eat all the heart symbol blocks to the end. Taro , Try to eat as many heartless blocks as possible, with all heartm...
### Prompt Generate a cpp solution to the following problem: Life in Bertown has become hard. The city has too many roads and the government spends too much to maintain them. There are n junctions and m two way roads, at which one can get from each junction to any other one. The mayor wants to close some roads so tha...
### Prompt Your task is to create a Cpp solution to the following problem: Vasya's birthday is approaching and Lena decided to sew a patterned handkerchief to him as a present. Lena chose digits from 0 to n as the pattern. The digits will form a rhombus. The largest digit n should be located in the centre. The digits...
### Prompt Construct a cpp code solution to the problem outlined: IT City company developing computer games invented a new way to reward its employees. After a new game release users start buying it actively, and the company tracks the number of sales with precision to each transaction. Every time when the next numbe...
### Prompt Your task is to create a cpp solution to the following problem: We have N bricks arranged in a row from left to right. The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it. Among them, you can break at most N-1 bricks of your choice. Let us say there are K bricks remaining. Sn...
### Prompt Develop a solution in Cpp to the problem described below: Sasha is taking part in a programming competition. In one of the problems she should check if some rooted trees are isomorphic or not. She has never seen this problem before, but, being an experienced participant, she guessed that she should match t...
### Prompt Construct a Cpp code solution to the problem outlined: You need to execute several tasks, each associated with number of processors it needs, and the compute power it will consume. You have sufficient number of analog computers, each with enough processors for any task. Each computer can execute up to one...
### Prompt Your challenge is to write a CPP solution to the following problem: A tennis tournament with n participants is running. The participants are playing by an olympic system, so the winners move on and the losers drop out. The tournament takes place in the following way (below, m is the number of the particip...
### Prompt Your task is to create a CPP solution to the following problem: Snuke found a random number generator. It generates an integer between 0 and 2^N-1 (inclusive). An integer sequence A_0, A_1, \cdots, A_{2^N-1} represents the probability that each of these integers is generated. The integer i (0 \leq i \leq 2...
### Prompt Please provide a cpp coded solution to the problem described below: <image> The International Clown and Pierrot Competition (ICPC), is one of the most distinguished and also the most popular events on earth in the show business. One of the unique features of this contest is the great number of judges tha...
### Prompt Your task is to create a cpp solution to the following problem: Finally! Vasya have come of age and that means he can finally get a passport! To do it, he needs to visit the passport office, but it's not that simple. There's only one receptionist at the passport office and people can queue up long before i...
### Prompt Develop a solution in CPP to the problem described below: Let's define the permutation of length n as an array p = [p1, p2, ..., pn] consisting of n distinct integers from range from 1 to n. We say that this permutation maps value 1 into the value p1, value 2 into the value p2 and so on. Kyota Ootori has ...
### Prompt Generate a CPP solution to the following problem: There are n models in the shop numbered from 1 to n, with sizes s_1, s_2, …, s_n. Orac will buy some of the models and will arrange them in the order of increasing numbers (i.e. indices, but not sizes). Orac thinks that the obtained arrangement is beatifu...
### Prompt Please formulate a CPP solution to the following problem: We have N+M balls, each of which has an integer written on it. It is known that: * The numbers written on N of the balls are even. * The numbers written on M of the balls are odd. Find the number of ways to choose two of the N+M balls (disregard...
### Prompt Your challenge is to write a CPP solution to the following problem: There are n students at Berland State University. Every student has two skills, each measured as a number: ai — the programming skill and bi — the sports skill. It is announced that an Olympiad in programming and sports will be held soon....
### Prompt Your task is to create a cpp solution to the following problem: From beginning till end, this message has been waiting to be conveyed. For a given unordered multiset of n lowercase English letters ("multi" means that a letter may appear more than once), we treat all letters as strings of length 1, and rep...
### Prompt Construct a Cpp code solution to the problem outlined: Once Max found an electronic calculator from his grandfather Dovlet's chest. He noticed that the numbers were written with seven-segment indicators (<https://en.wikipedia.org/wiki/Seven-segment_display>). <image> Max starts to type all the values fro...
### Prompt Your task is to create a cpp solution to the following problem: This is an interactive problem. In the interaction section below you will find the information about flushing the output. The New Year tree of height h is a perfect binary tree with vertices numbered 1 through 2h - 1 in some order. In this pr...
### Prompt Develop a solution in CPP to the problem described below: One very important person has a piece of paper in the form of a rectangle a × b. Also, he has n seals. Each seal leaves an impression on the paper in the form of a rectangle of the size xi × yi. Each impression must be parallel to the sides of the ...
### Prompt Please provide a Cpp coded solution to the problem described below: Curry making As the ACM-ICPC domestic qualifying is approaching, you who wanted to put more effort into practice decided to participate in a competitive programming camp held at a friend's house. Participants decided to prepare their own ...
### Prompt Develop a solution in CPP to the problem described below: There always is something to choose from! And now, instead of "Noughts and Crosses", Inna choose a very unusual upgrade of this game. The rules of the game are given below: There is one person playing the game. Before the beginning of the game he p...
### Prompt Please formulate a cpp solution to the following problem: We are committed to the well being of all participants. Therefore, instead of the problem, we suggest you enjoy a piece of cake. Uh oh. Somebody cut the cake. We told them to wait for you, but they did it anyway. There is still some left, though, i...
### Prompt Please provide a Cpp coded solution to the problem described below: Heidi got one brain, thumbs up! But the evening isn't over yet and one more challenge awaits our dauntless agent: after dinner, at precisely midnight, the N attendees love to play a very risky game... Every zombie gets a number ni (1 ≤ ni...
### Prompt Develop a solution in Cpp to the problem described below: During the loading of the game "Dungeons and Candies" you are required to get descriptions of k levels from the server. Each description is a map of an n × m checkered rectangular field. Some cells of the field contain candies (each cell has at most...
### Prompt Your challenge is to write a Cpp solution to the following problem: A famous sculptor Cicasso goes to a world tour! Well, it is not actually a world-wide. But not everyone should have the opportunity to see works of sculptor, shouldn't he? Otherwise there will be no any exclusivity. So Cicasso will entire...
### Prompt Develop a solution in CPP to the problem described below: The only difference between the easy and the hard versions is the maximum value of k. You are given an infinite sequence of form "112123123412345..." which consist of blocks of all consecutive positive integers written one after another. The first ...
### Prompt Please create a solution in Cpp to the following problem: You are given a string s consisting of `A`, `B` and `C`. Snuke wants to perform the following operation on s as many times as possible: * Choose a contiguous substring of s that reads `ABC` and replace it with `BCA`. Find the maximum possible n...
### Prompt Your challenge is to write a cpp solution to the following problem: Vasya became interested in bioinformatics. He's going to write an article about similar cyclic DNA sequences, so he invented a new method for determining the similarity of cyclic sequences. Let's assume that strings s and t have the same ...
### Prompt Please create a solution in CPP to the following problem: You are given an array a_1, a_2, ..., a_n. All a_i are pairwise distinct. Let's define function f(l, r) as follows: * let's define array b_1, b_2, ..., b_{r - l + 1}, where b_i = a_{l - 1 + i}; * sort array b in increasing order; * result...
### Prompt Generate a Cpp solution to the following problem: Berland annual chess tournament is coming! Organizers have gathered 2·n chess players who should be divided into two teams with n people each. The first team is sponsored by BerOil and the second team is sponsored by BerMobile. Obviously, organizers should...
### Prompt Construct a CPP code solution to the problem outlined: Given is a tree G with N vertices. The vertices are numbered 1 through N, and the i-th edge connects Vertex a_i and Vertex b_i. Consider painting the edges in G with some number of colors. We want to paint them so that, for each vertex, the colors of ...
### Prompt Create a solution in CPP for the following problem: Sometimes one has to spell email addresses over the phone. Then one usually pronounces a dot as dot, an at sign as at. As a result, we get something like vasyaatgmaildotcom. Your task is to transform it into a proper email address (vasya@gmail.com). It ...
### Prompt Develop a solution in CPP to the problem described below: On the way to Rio de Janeiro Ostap kills time playing with a grasshopper he took with him in a special box. Ostap builds a line of length n such that some cells of this line are empty and some contain obstacles. Then, he places his grasshopper to on...
### Prompt Your task is to create a cpp solution to the following problem: In this problem you will have to help Berland army with organizing their command delivery system. There are n officers in Berland army. The first officer is the commander of the army, and he does not have any superiors. Every other officer ha...
### Prompt Your task is to create a cpp solution to the following problem: You are given a tetrahedron. Let's mark its vertices with letters A, B, C and D correspondingly. <image> An ant is standing in the vertex D of the tetrahedron. The ant is quite active and he wouldn't stay idle. At each moment of time he make...
### Prompt Create a solution in cpp for the following problem: Iahub helps his grandfather at the farm. Today he must milk the cows. There are n cows sitting in a row, numbered from 1 to n from left to right. Each cow is either facing to the left or facing to the right. When Iahub milks a cow, all the cows that see t...
### Prompt Generate a Cpp solution to the following problem: The nation of Panel holds an annual show called The Number Games, where each district in the nation will be represented by one contestant. The nation has n districts numbered from 1 to n, each district has exactly one path connecting it to every other dist...
### Prompt In CPP, your task is to solve the following problem: Shuseki Kingdom is the world's leading nation for innovation and technology. There are n cities in the kingdom, numbered from 1 to n. Thanks to Mr. Kitayuta's research, it has finally become possible to construct teleportation pipes between two cities. ...
### Prompt Generate a Cpp solution to the following problem: This is a harder version of the problem. In this version, n ≤ 300 000. Vasya is an experienced developer of programming competitions' problems. As all great minds at some time, Vasya faced a creative crisis. To improve the situation, Petya gifted him a str...
### Prompt Your task is to create a cpp solution to the following problem: One day Vasya decided to have a look at the results of Berland 1910 Football Championship’s finals. Unfortunately he didn't find the overall score of the match; however, he got hold of a profound description of the match's process. On the whol...
### Prompt In cpp, your task is to solve the following problem: Now you can take online courses in the Berland State University! Polycarp needs to pass k main online courses of his specialty to get a diploma. In total n courses are availiable for the passage. The situation is complicated by the dependence of online ...
### Prompt Generate a cpp solution to the following problem: While Farmer John rebuilds his farm in an unfamiliar portion of Bovinia, Bessie is out trying some alternative jobs. In her new gig as a reporter, Bessie needs to know about programming competition results as quickly as possible. When she covers the 2016 Ro...
### Prompt Your task is to create a Cpp solution to the following problem: Alice and Bob are playing a fun game of tree tag. The game is played on a tree of n vertices numbered from 1 to n. Recall that a tree on n vertices is an undirected, connected graph with n-1 edges. Initially, Alice is located at vertex a, an...
### Prompt Generate a cpp solution to the following problem: Smart Beaver became interested in drawing. He draws suns. However, at some point, Smart Beaver realized that simply drawing suns is boring. So he decided to design a program that will process his drawings. You are given a picture drawn by the beaver. It wil...
### Prompt Please create a solution in cpp to the following problem: Jack decides to invite Emma out for a dinner. Jack is a modest student, he doesn't want to go to an expensive restaurant. Emma is a girl with high taste, she prefers elite places. Munhattan consists of n streets and m avenues. There is exactly one ...
### Prompt Create a solution in cpp for the following problem: Hacker Zhorik wants to decipher two secret messages he intercepted yesterday. Yeah message is a sequence of encrypted blocks, each of them consists of several bytes of information. Zhorik knows that each of the messages is an archive containing one or mo...
### Prompt Your task is to create a cpp solution to the following problem: Iahub and his friend Floyd have started painting a wall. Iahub is painting the wall red and Floyd is painting it pink. You can consider the wall being made of a very large number of bricks, numbered 1, 2, 3 and so on. Iahub has the following...
### Prompt Your task is to create a Cpp solution to the following problem: Two children are playing tag on a number line. (In the game of tag, the child called "it" tries to catch the other child.) The child who is "it" is now at coordinate A, and he can travel the distance of V per second. The other child is now at ...
### Prompt Please formulate a CPP solution to the following problem: Do the following for a four-digit number N consisting of numbers 0-9. 1. Let L be the number obtained as a result of arranging the numerical values ​​of each of the N digits in descending order. 2. Let S be the number obtained as a result of arrang...
### Prompt Your challenge is to write a cpp solution to the following problem: There are N squares in a row, numbered 1 through N from left to right. Snuke and Rng are playing a board game using these squares, described below: 1. First, Snuke writes an integer into each square. 2. Each of the two players possesses o...
### Prompt Please provide a CPP coded solution to the problem described below: Problem statement You are a hero. The world in which the hero is traveling consists of N cities and M roads connecting different cities. Road i connects town a_i and town b_i and can move in both directions. The purpose of the brave is t...
### Prompt Generate a Cpp solution to the following problem: Nate U. Smith runs a railroad company in a metropolitan area. In addition to his railroad company, there are rival railroad companies in this metropolitan area. The two companies are in a competitive relationship with each other. In this metropolitan area,...
### Prompt Your challenge is to write a cpp solution to the following problem: Joisino is planning to record N TV programs with recorders. The TV can receive C channels numbered 1 through C. The i-th program that she wants to record will be broadcast from time s_i to time t_i (including time s_i but not t_i) on Cha...
### Prompt Your challenge is to write a cpp solution to the following problem: We all know the impressive story of Robin Hood. Robin Hood uses his archery skills and his wits to steal the money from rich, and return it to the poor. There are n citizens in Kekoland, each person has ci coins. Each day, Robin Hood will...
### Prompt Please formulate a Cpp solution to the following problem: Alex enjoys performing magic tricks. He has a trick that requires a deck of n cards. He has m identical decks of n different cards each, which have been mixed together. When Alex wishes to perform the trick, he grabs n cards at random and performs t...
### Prompt Construct a CPP code solution to the problem outlined: N programmers are going to participate in the preliminary stage of DDCC 20XX. Due to the size of the venue, however, at most 9 contestants can participate in the finals. The preliminary stage consists of several rounds, which will take place as follow...
### Prompt Create a solution in CPP for the following problem: This is a simplified version of the task Toy Train. These two versions differ only in the constraints. Hacks for this version are disabled. Alice received a set of Toy Train™ from Bob. It consists of one train and a connected railway network of n station...
### Prompt Construct a cpp code solution to the problem outlined: Arpa is researching the Mexican wave. There are n spectators in the stadium, labeled from 1 to n. They start the Mexican wave at time 0. * At time 1, the first spectator stands. * At time 2, the second spectator stands. * ... * At time k, ...
### Prompt In cpp, your task is to solve the following problem: Write a program which manipulates a sequence $A$ = {$a_0, a_1, ..., a_{n-1}$} with the following operations: * $add(s, t, x)$ : add $x$ to $a_s, a_{s+1}, ..., a_t$. * $find(s, t)$ : report the minimum value in $a_s, a_{s+1}, ..., a_t$. Note that the ...
### Prompt In Cpp, your task is to solve the following problem: Once upon a time, Oolimry saw a suffix array. He wondered how many strings can produce this suffix array. More formally, given a suffix array of length n and having an alphabet size k, count the number of strings that produce such a suffix array. Let...
### Prompt Please provide a cpp coded solution to the problem described below: A team of furry rescue rangers was sitting idle in their hollow tree when suddenly they received a signal of distress. In a few moments they were ready, and the dirigible of the rescue chipmunks hit the road. We assume that the action tak...
### Prompt Generate a CPP solution to the following problem: Consider the following game for two players. There is one white token and some number of black tokens. Each token is placed on a plane in a point with integer coordinates x and y. The players take turn making moves, white starts. On each turn, a player mov...
### Prompt In Cpp, your task is to solve the following problem: Kuriyama Mirai has killed many monsters and got many (namely n) stones. She numbers the stones from 1 to n. The cost of the i-th stone is vi. Kuriyama Mirai wants to know something about these stones so she will ask you two kinds of questions: 1. She ...
### Prompt Develop a solution in CPP to the problem described below: We have a connected undirected graph with N vertices and M edges. Edge i in this graph (1 \leq i \leq M) connects Vertex U_i and Vertex V_i bidirectionally. We are additionally given N integers D_1, D_2, ..., D_N. Determine whether the conditions b...
### Prompt Please formulate a Cpp solution to the following problem: 10^{10^{10}} participants, including Takahashi, competed in two programming contests. In each contest, all participants had distinct ranks from first through 10^{10^{10}}-th. The score of a participant is the product of his/her ranks in the two con...