text
stringlengths
424
69.5k
### Prompt Your task is to create a Cpp solution to the following problem: This is the easy version of the problem. The difference between the versions is the constraint on n and the required number of operations. You can make hacks only if all versions of the problem are solved. There are two binary strings a and b...
### Prompt In Cpp, your task is to solve the following problem: You are given a Young diagram. Given diagram is a histogram with n columns of lengths a_1, a_2, …, a_n (a_1 ≥ a_2 ≥ … ≥ a_n ≥ 1). <image> Young diagram for a=[3,2,2,2,1]. Your goal is to find the largest number of non-overlapping dominos that you can...
### Prompt Please formulate a CPP solution to the following problem: Tenten runs a weapon shop for ninjas. Today she is willing to sell n shurikens which cost 1, 2, ..., n ryo (local currency). During a day, Tenten will place the shurikens onto the showcase, which is empty at the beginning of the day. Her job is fair...
### Prompt Construct a cpp code solution to the problem outlined: Lee is used to finish his stories in a stylish way, this time he barely failed it, but Ice Bear came and helped him. Lee is so grateful for it, so he decided to show Ice Bear his new game called "Critic"... The game is a one versus one game. It has t ...
### Prompt Your task is to create a cpp solution to the following problem: Vasya plays a computer game with ninjas. At this stage Vasya's ninja should get out of a deep canyon. The canyon consists of two vertical parallel walls, their height is n meters. Let's imagine that we split these walls into 1 meter-long area...
### 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 create a solution in cpp to the following problem: Sometimes it is not easy to come to an agreement in a bargain. Right now Sasha and Vova can't come to an agreement: Sasha names a price as high as possible, then Vova wants to remove as many digits from the price as possible. In more details, Sasha ...
### Prompt In CPP, your task is to solve the following problem: Snuke, a water strider, lives in a rectangular pond that can be seen as a grid with H east-west rows and W north-south columns. Let (i,j) be the square at the i-th row from the north and j-th column from the west. Some of the squares have a lotus leaf o...
### Prompt Your task is to create a cpp solution to the following problem: A one-dimensional Japanese crossword can be represented as a binary string of length x. An encoding of this crossword is an array a of size n, where n is the number of segments formed completely of 1's, and ai is the length of i-th segment. No...
### Prompt In Cpp, your task is to solve the following problem: You are given a sequence a_1, a_2, …, a_n of non-negative integers. You need to find the largest number m of triples (i_1, j_1, k_1), (i_2, j_2, k_2), ..., (i_m, j_m, k_m) such that: * 1 ≤ i_p < j_p < k_p ≤ n for each p in 1, 2, …, m; * a_{i_p} = a...
### Prompt Develop a solution in CPP to the problem described below: Recently, Berland faces federalization requests more and more often. The proponents propose to divide the country into separate states. Moreover, they demand that there is a state which includes exactly k towns. Currently, Berland has n towns, some...
### Prompt Please provide a CPP coded solution to the problem described below: 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...
### Prompt Please create a solution in Cpp to the following problem: You are given an integer x. Can you make x by summing up some number of 11, 111, 1111, 11111, …? (You can use any number among them any number of times). For instance, * 33=11+11+11 * 144=111+11+11+11 Input The first line of input contain...
### Prompt Generate a CPP solution to the following problem: The squirrel Chokudai has N acorns. One day, he decides to do some trades in multiple precious metal exchanges to make more acorns. His plan is as follows: 1. Get out of the nest with N acorns in his hands. 2. Go to Exchange A and do some trades. 3. Go to...
### Prompt In Cpp, your task is to solve the following problem: DZY loves planting, and he enjoys solving tree problems. DZY has a weighted tree (connected undirected graph without cycles) containing n nodes (they are numbered from 1 to n). He defines the function g(x, y) (1 ≤ x, y ≤ n) as the longest edge in the sh...
### Prompt Develop a solution in Cpp to the problem described below: Sasha and Dima want to buy two n-tier cakes. Each cake should consist of n different tiers: from the size of 1 to the size of n. Tiers should go in order from the smallest to the biggest (from top to bottom). They live on the same street, there are...
### Prompt In cpp, your task is to solve the following problem: The smallest unit of data handled by a computer is called a bit, and the amount of information that represents multiple bits together is called a word. Currently, many computers process one word as 32 bits. For a computer that represents one word in 32 ...
### Prompt Please create a solution in Cpp to the following problem: We have N logs of lengths A_1,A_2,\cdots A_N. We can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0<t<L), it becomes two logs of lengths t and L-t. Find the shortest ...
### Prompt In CPP, your task is to solve the following problem: You are given a rectangular field of n × m cells. Each cell is either empty or impassable (contains an obstacle). Empty cells are marked with '.', impassable cells are marked with '*'. Let's call two empty cells adjacent if they share a side. Let's call...
### Prompt Please provide a Cpp coded solution to the problem described below: Polycarp watched TV-show where k jury members one by one rated a participant by adding him a certain number of points (may be negative, i. e. points were subtracted). Initially the participant had some score, and each the marks were one by...
### Prompt Create a solution in Cpp for the following problem: There are N apple trees in a row. People say that one of them will bear golden apples. We want to deploy some number of inspectors so that each of these trees will be inspected. Each inspector will be deployed under one of the trees. For convenience, we...
### Prompt In Cpp, your task is to solve the following problem: There are well-known formulas: <image>, <image>, <image>. Also mathematicians found similar formulas for higher degrees. Find the value of the sum <image> modulo 109 + 7 (so you should find the remainder after dividing the answer by the value 109 + 7). ...
### Prompt Please create a solution in CPP to the following problem: We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, ...
### Prompt Create a solution in Cpp for the following problem: Before the start of the football season in Berland a strange magic ritual is held. The most experienced magicians have to find a magic matrix of the size n × n (n is even number). Gods will never allow to start the championship without it. Matrix should c...
### Prompt Your task is to create a Cpp solution to the following problem: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements of a...
### Prompt Please provide a cpp coded solution to the problem described below: A permutation of length n is an array p=[p_1,p_2,...,p_n], which contains every integer from 1 to n (inclusive) and, moreover, each number appears exactly once. For example, p=[3,1,4,2,5] is a permutation of length 5. For a given number n...
### Prompt Construct a cpp code solution to the problem outlined: Write a program which reads a sequence of integers $A = \\{a_0, a_1, ..., a_{n-1}\\}$ and swap specified elements by a list of the following operation: * swapRange($b, e, t$): For each integer $k$ ($0 \leq k < (e - b)$, swap element $(b + k)$ and elem...
### Prompt Your challenge is to write a cpp solution to the following problem: <image> William really likes the cellular automaton called "Game of Life" so he decided to make his own version. For simplicity, William decided to define his cellular automaton on an array containing n cells, with each cell either being ...
### Prompt Generate a Cpp solution to the following problem: Problem statement AOR Ika got a cabbage with $ N $ leaves. The leaves of this cabbage are numbered $ 1, \ ldots, N $ in order from the outside, and the dirtiness of the $ i $ th leaf is $ D_i $. The larger this value is, the worse the degree of dirt is. AO...
### Prompt Please provide a CPP coded solution to the problem described below: The determinant of a matrix 2 × 2 is defined as follows: <image> A matrix is called degenerate if its determinant is equal to zero. The norm ||A|| of a matrix A is defined as a maximum of absolute values of its elements. You are given...
### Prompt Create a solution in Cpp for the following problem: Allen and Bessie are playing a simple number game. They both know a function f: \{0, 1\}^n → R, i. e. the function takes n binary arguments and returns a real value. At the start of the game, the variables x_1, x_2, ..., x_n are all set to -1. Each round,...
### Prompt Your challenge is to write a Cpp solution to the following problem: After battling Shikamaru, Tayuya decided that her flute is too predictable, and replaced it with a guitar. The guitar has 6 strings and an infinite number of frets numbered from 1. Fretting the fret number j on the i-th string produces the...
### Prompt Your challenge is to write a CPP solution to the following problem: Let us consider sets of positive integers less than or equal to n. Note that all elements of a set are different. Also note that the order of elements doesn't matter, that is, both {3, 5, 9} and {5, 9, 3} mean the same set. Specifying the...
### Prompt Develop a solution in Cpp to the problem described below: Let p (i) be the i-th prime number from the smallest. For example, 7 is the fourth prime number from the smallest, 2, 3, 5, 7, so p (4) = 7. Given n, the sum of p (i) from i = 1 to n s s = p (1) + p (2) + .... + p (n) Create a program that output...
### Prompt Develop a solution in CPP to the problem described below: Ivan has a robot which is situated on an infinite grid. Initially the robot is standing in the starting cell (0, 0). The robot can process commands. There are four types of commands it can perform: * U — move from the cell (x, y) to (x, y + 1); ...
### Prompt Develop a solution in CPP to the problem described below: Joisino has a bar of length N, which has M marks on it. The distance from the left end of the bar to the i-th mark is X_i. She will place several squares on this bar. Here, the following conditions must be met: * Only squares with integral length ...
### Prompt Create a solution in Cpp for the following problem: Petya has recently learned data structure named "Binary heap". The heap he is now operating with allows the following operations: * put the given number into the heap; * get the value of the minimum element in the heap; * extract the minimum el...
### Prompt Your task is to create a CPP solution to the following problem: Vasiliy lives at point (a, b) of the coordinate plane. He is hurrying up to work so he wants to get out of his house as soon as possible. New app suggested n available Beru-taxi nearby. The i-th taxi is located at point (xi, yi) and moves with...
### Prompt Please provide a Cpp coded solution to the problem described below: The sales department of Japanese Ancient Giant Corp. is visiting a hot spring resort for their recreational trip. For deepening their friendships, they are staying in one large room of a Japanese-style hotel called a ryokan. In the ryokan...
### Prompt Please formulate a cpp solution to the following problem: Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. Iroha is looking for X,Y,Z-Haiku (defined below) in integer sequences. Consider all integer sequences of length N whose elements ...
### Prompt Please provide a cpp coded solution to the problem described below: On vacations n pupils decided to go on excursion and gather all together. They need to overcome the path with the length l meters. Each of the pupils will go with the speed equal to v1. To get to the excursion quickly, it was decided to re...
### Prompt Construct a Cpp code solution to the problem outlined: You have k pieces of laundry, each of which you want to wash, dry and fold. You are at a laundromat that has n1 washing machines, n2 drying machines and n3 folding machines. Each machine can process only one piece of laundry at a time. You can't dry a ...
### Prompt Your challenge is to write a Cpp solution to the following problem: You work as a system administrator in a dormitory, which has n rooms one after another along a straight hallway. Rooms are numbered from 1 to n. You have to connect all n rooms to the Internet. You can connect each room to the Internet d...
### Prompt Please create a solution in CPP to the following problem: Problem The popular video posting site "ZouTube" is now in the midst of an unprecedented "virtual ZouTuber" boom. Among them, the one that has been attracting particular attention recently is the junior virtual ZouTuber "Aizumarim (commonly known a...
### Prompt Please formulate a Cpp solution to the following problem: Limak is a little bear who learns to draw. People usually start with houses, fences and flowers but why would bears do it? Limak lives in the forest and he decides to draw a tree. Recall that tree is a connected graph consisting of n vertices and n...
### Prompt In Cpp, your task is to solve the following problem: You are given a [directed graph](https://en.wikipedia.org/wiki/Directed_graph) consisting of n vertices and m edges (each edge is directed, so it can be traversed in only one direction). You are allowed to remove at most one edge from it. Can you make t...
### Prompt Please create a solution in CPP to the following problem: You are given a string t consisting of n lowercase Latin letters and an integer number k. Let's define a substring of some string s with indices from l to r as s[l ... r]. Your task is to construct such string s of minimum possible length that the...
### Prompt Please create a solution in cpp to the following problem: There are N balls in a row. Initially, the i-th ball from the left has the integer A_i written on it. When Snuke cast a spell, the following happens: * Let the current number of balls be k. All the balls with k written on them disappear at the sam...
### Prompt Develop a solution in cpp to the problem described below: Vasya and Kolya play a game with a string, using the following rules. Initially, Kolya creates a string s, consisting of small English letters, and uniformly at random chooses an integer k from a segment [0, len(s) - 1]. He tells Vasya this string s...
### Prompt Please create a solution in CPP to the following problem: You are given two strings s and t. Both strings have length n and consist of lowercase Latin letters. The characters in the strings are numbered from 1 to n. You can successively perform the following move any number of times (possibly, zero): *...
### Prompt Your challenge is to write a CPP solution to 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 ...
### Prompt Your task is to create a CPP solution to the following problem: A lot of frogs want to cross a river. A river is w units width, but frogs can only jump l units long, where l < w. Frogs can also jump on lengths shorter than l. but can't jump longer. Hopefully, there are some stones in the river to help them...
### Prompt Create a solution in Cpp for the following problem: A stowaway and a controller play the following game. The train is represented by n wagons which are numbered with positive integers from 1 to n from the head to the tail. The stowaway and the controller are initially in some two different wagons. Every ...
### Prompt Develop a solution in CPP to the problem described below: For a positive integer n let's define a function f: f(n) = - 1 + 2 - 3 + .. + ( - 1)nn Your task is to calculate f(n) for a given integer n. Input The single line contains the positive integer n (1 ≤ n ≤ 1015). Output Print f(n) in a single li...
### Prompt Please provide a cpp coded solution to the problem described below: Gargari got bored to play with the bishops and now, after solving the problem about them, he is trying to do math homework. In a math book he have found k permutations. Each of them consists of numbers 1, 2, ..., n in some order. Now he sh...
### Prompt Please create a solution in Cpp to the following problem: You are given a sequence of length N: A_1, A_2, ..., A_N. For each integer i between 1 and N (inclusive), answer the following question: * Find the maximum value among the N-1 elements other than A_i in the sequence. Constraints * 2 \leq N \leq 2...
### Prompt Please create a solution in CPP to the following problem: The Little Elephant loves numbers. He has a positive integer x. The Little Elephant wants to find the number of positive integers d, such that d is the divisor of x, and x and d have at least one common (the same) digit in their decimal representa...
### Prompt Develop a solution in cpp to the problem described below: Suppose you have a special x-y-counter. This counter can store some value as a decimal number; at first, the counter has value 0. The counter performs the following algorithm: it prints its lowest digit and, after that, adds either x or y to its v...
### Prompt Your task is to create a cpp solution to the following problem: 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...
### Prompt Please provide a cpp coded solution to the problem described below: Blake is a CEO of a large company called "Blake Technologies". He loves his company very much and he thinks that his company should be the best. That is why every candidate needs to pass through the interview that consists of the following...
### Prompt Generate a Cpp solution to 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 the...
### Prompt Please provide a cpp coded solution to the problem described below: You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2). You want to construct the array a of length n such that: * The first n/2 elements of a are even (divisible by 2); * the second n/2 elements ...
### Prompt In CPP, your task is to solve the following problem: Vasya participates in a ski race along the X axis. The start is at point 0, and the finish is at L, that is, at a distance L meters from the start in the positive direction of the axis. Vasya has been training so hard that he can run one meter in exactly...
### Prompt Generate a cpp solution to the following problem: Silver Fox is fighting with N monsters. The monsters are standing in a row, and we can assume them to be standing on a number line. The i-th monster, standing at the coordinate X_i, has the health of H_i. Silver Fox can use bombs to attack the monsters. U...
### Prompt Your task is to create a CPP solution to the following problem: On vacations n pupils decided to go on excursion and gather all together. They need to overcome the path with the length l meters. Each of the pupils will go with the speed equal to v1. To get to the excursion quickly, it was decided to rent a...
### Prompt Please formulate a cpp solution to the following problem: You have two positive integers w and h. Your task is to count the number of rhombi which have the following properties: * Have positive area. * With vertices at integer points. * All vertices of the rhombi are located inside or on the bord...
### Prompt Your challenge is to write a CPP solution to the following problem: Life is not easy. Sometimes it is beyond your control. Now, as contestants of ACM ICPC, you might be just tasting the bitter of life. But don't worry! Do not look only on the dark side of life, but look also on the bright side. Life may be...
### Prompt Please provide a Cpp coded solution to the problem described below: Given a non-negative decimal integer $x$, convert it to binary representation $b$ of 32 bits. Then, print the result of the following operations to $b$ respecitvely. * Inversion: change the state of each bit to the opposite state * Logica...
### Prompt Your challenge is to write a cpp solution to the following problem: DZY loves strings, and he enjoys collecting them. In China, many people like to use strings containing their names' initials, for example: xyz, jcvb, dzy, dyh. Once DZY found a lucky string s. A lot of pairs of good friends came to DZY w...
### Prompt Please provide a cpp coded solution to the problem described below: All cinema halls in Berland are rectangles with K rows of K seats each, and K is an odd number. Rows and seats are numbered from 1 to K. For safety reasons people, who come to the box office to buy tickets, are not allowed to choose seats ...
### Prompt Create a solution in CPP for the following problem: Takahashi is competing in a sumo tournament. The tournament lasts for 15 days, during which he performs in one match per day. If he wins 8 or more matches, he can also participate in the next tournament. The matches for the first k days have finished. Yo...
### Prompt Construct a Cpp code solution to the problem outlined: We have a square grid with N rows and M columns. Takahashi will write an integer in each of the squares, as follows: * First, write 0 in every square. * For each i=1,2,...,N, choose an integer k_i (0\leq k_i\leq M), and add 1 to each of the leftmost k...
### Prompt Your task is to create a CPP solution to the following problem: Takahashi received otoshidama (New Year's money gifts) from N of his relatives. You are given N values x_1, x_2, ..., x_N and N strings u_1, u_2, ..., u_N as input. Each string u_i is either `JPY` or `BTC`, and x_i and u_i represent the conte...
### Prompt Create a solution in Cpp for the following problem: Note that this is the first problem of the two similar problems. You can hack this problem only if you solve both problems. You are given a tree with n nodes. In the beginning, 0 is written on all edges. In one operation, you can choose any 2 distinct le...
### Prompt Please provide a CPP coded solution to the problem described below: Gerald got a very curious hexagon for his birthday. The boy found out that all the angles of the hexagon are equal to <image>. Then he measured the length of its sides, and found that each of them is equal to an integer number of centimete...
### Prompt Please create a solution in Cpp to the following problem: Rumors say that one of Kamal-ol-molk's paintings has been altered. A rectangular brush has been moved right and down on the painting. Consider the painting as a n × m rectangular grid. At the beginning an x × y rectangular brush is placed somewhere...
### Prompt Create a solution in Cpp for the following problem: In "Takahashi-ya", a ramen restaurant, a bowl of ramen costs 700 yen (the currency of Japan), plus 100 yen for each kind of topping (boiled egg, sliced pork, green onions). A customer ordered a bowl of ramen and told which toppings to put on his ramen to...
### Prompt Please provide a CPP coded solution to the problem described below: The Little Elephant loves to play with color cards. He has n cards, each has exactly two colors (the color of the front side and the color of the back side). Initially, all the cards lay on the table with the front side up. In one move th...
### Prompt In cpp, your task is to solve the following problem: Students went into a class to write a test and sat in some way. The teacher thought: "Probably they sat in this order to copy works of each other. I need to rearrange them in such a way that students that were neighbors are not neighbors in a new seating...
### Prompt Construct a cpp code solution to the problem outlined: You are given two arrays A and B, each of size n. The error, E, between these two arrays is defined <image>. You have to perform exactly k1 operations on array A and exactly k2 operations on array B. In one operation, you have to choose one element of ...
### Prompt Generate a CPP solution to the following problem: Polycarp has x of red and y of blue candies. Using them, he wants to make gift sets. Each gift set contains either a red candies and b blue candies, or a blue candies and b red candies. Any candy can belong to at most one gift set. Help Polycarp to find th...
### Prompt Please formulate a Cpp solution to the following problem: There are n boxes with colored balls on the table. Colors are numbered from 1 to n. i-th box contains ai balls, all of which have color i. You have to write a program that will divide all balls into sets such that: * each ball belongs to exactly ...
### Prompt Your task is to create a CPP solution to the following problem: Mishka has got n empty boxes. For every i (1 ≤ i ≤ n), i-th box is a cube with side length ai. Mishka can put a box i into another box j if the following conditions are met: * i-th box is not put into another box; * j-th box doesn't con...
### Prompt Your challenge is to write a CPP solution to the following problem: Vasya plays Robot Bicorn Attack. The game consists of three rounds. For each one a non-negative integer amount of points is given. The result of the game is the sum of obtained points. Vasya has already played three rounds and wrote obtai...
### Prompt Please formulate a cpp solution to the following problem: Genos and Saitama went shopping for Christmas trees. However, a different type of tree caught their attention, the exalted Power Tree. A Power Tree starts out as a single root vertex indexed 1. A Power Tree grows through a magical phenomenon known...
### Prompt Please formulate a Cpp solution to the following problem: Bridge Removal ICPC islands once had been a popular tourist destination. For nature preservation, however, the government decided to prohibit entrance to the islands, and to remove all the man-made structures there. The hardest part of the project ...
### Prompt Your challenge is to write a Cpp solution to the following problem: You are given a binary string s (each character of this string is either 0 or 1). Let's denote the cost of string t as the number of occurences of s in t. For example, if s is 11 and t is 111011, then the cost of t is 3. Let's also denot...
### Prompt Please provide a Cpp coded solution to the problem described below: Dreamoon likes sequences very much. So he created a problem about the sequence that you can't find in OEIS: You are given two integers d, m, find the number of arrays a, satisfying the following constraints: * The length of a is n, n ...
### Prompt Please provide a cpp coded solution to the problem described below: This is the easy version of the problem. The difference between versions is the constraints on n and a_i. You can make hacks only if all versions of the problem are solved. First, Aoi came up with the following idea for the competitive pr...
### Prompt Generate a cpp solution to the following problem: There is a polyline going through points (0, 0) – (x, x) – (2x, 0) – (3x, x) – (4x, 0) – ... - (2kx, 0) – (2kx + x, x) – .... We know that the polyline passes through the point (a, b). Find minimum positive value x such that it is true or determine that t...
### Prompt Construct a CPP code solution to the problem outlined: <image> Matryoshka is a wooden doll in the shape of a female figure and is a typical Russian folk craft. Matryoshka has a nested structure in which smaller dolls are contained inside a large doll, and is composed of multiple dolls of different sizes. ...
### Prompt In cpp, your task is to solve the following problem: You are given an array a of length n that consists of zeros and ones. You can perform the following operation multiple times. The operation consists of two steps: 1. Choose three integers 1 ≤ x < y < z ≤ n, that form an arithmetic progression (y - x...
### Prompt Generate a cpp solution to the following problem: Vasya lives in a round building, whose entrances are numbered sequentially by integers from 1 to n. Entrance n and entrance 1 are adjacent. Today Vasya got bored and decided to take a walk in the yard. Vasya lives in entrance a and he decided that during h...
### Prompt Develop a solution in CPP to the problem described below: $N$ persons visited a restaurant. The restaurant is open from 0 to $T$. The $i$-th person entered the restaurant at $l_i$ and left at $r_i$. Find the maximum number of persons during the business hours. Constraints * $ 1 \leq N \leq 10^5 $ * $ 1 \...
### Prompt Construct a CPP code solution to the problem outlined: An arithmetic progression is such a non-empty sequence of numbers where the difference between any two successive numbers is constant. This constant number is called common difference. For example, the sequence 3, 7, 11, 15 is an arithmetic progression...
### Prompt Please create a solution in CPP to the following problem: A permutation of size n is an array of size n such that each integer from 1 to n occurs exactly once in this array. An inversion in a permutation p is a pair of indices (i, j) such that i > j and ai < aj. For example, a permutation [4, 1, 3, 2] cont...
### Prompt Please create a solution in cpp to the following problem: Write a program which manipulates a sequence A = {a1, a2, . . . , an} with the following operations: * add(s, t, x): add x to as, as+1, ..., at. * get(i): output the value of ai. Note that the initial values of ai (i = 1, 2, . . . , n) are 0. C...
### Prompt Please create a solution in cpp to the following problem: You have final scores of an examination for n students. Calculate standard deviation of the scores s1, s2 ... sn. The variance α2 is defined by α2 = (∑ni=1(si - m)2)/n where m is an average of si. The standard deviation of the scores is the squar...
### Prompt Your challenge is to write a cpp solution to the following problem: One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. T...
### Prompt Create a solution in CPP for the following problem: The weight of a sequence is defined as the number of unordered pairs of indexes (i,j) (here i < j) with same value (a_{i} = a_{j}). For example, the weight of sequence a = [1, 1, 2, 2, 1] is 4. The set of unordered pairs of indexes with same value are (1,...