id stringlengths 11 14 | content stringlengths 424 1.17M |
|---|---|
apps_data_4200 | We have held a popularity poll for N items on sale. Item i received A_i votes.
From these N items, we will select M as popular items. However, we cannot select an item with less than \dfrac{1}{4M} of the total number of votes.
If M popular items can be selected, print Yes; otherwise, print No.
-----Constraints-----
-... |
apps_data_4201 | We have a grid of H rows and W columns of squares. The color of the square at the i-th row from the top and the j-th column from the left (1 \leq i \leq H, 1 \leq j \leq W) is given to you as a character c_{i,j}: the square is white if c_{i,j} is ., and black if c_{i,j} is #.
Consider doing the following operation:
- ... |
apps_data_4202 | You are given two non-negative integers L and R.
We will choose two integers i and j such that L \leq i < j \leq R.
Find the minimum possible value of (i \times j) \mbox{ mod } 2019.
-----Constraints-----
- All values in input are integers.
- 0 \leq L < R \leq 2 \times 10^9
-----Input-----
Input is given from Stand... |
apps_data_4203 | You are given a string S. Each character of S is uppercase or lowercase English letter.
Determine if S satisfies all of the following conditions:
- The initial character of S is an uppercase A.
- There is exactly one occurrence of C between the third character from the beginning and the second to last character (incl... |
apps_data_4204 | Mr. Infinity has a string S consisting of digits from 1 to 9. Each time the date changes, this string changes as follows:
- Each occurrence of 2 in S is replaced with 22. Similarly, each 3 becomes 333, 4 becomes 4444, 5 becomes 55555, 6 becomes 666666, 7 becomes 7777777, 8 becomes 88888888 and 9 becomes 999999999. 1 r... |
apps_data_4205 | We have a sequence p = {p_1,\ p_2,\ ...,\ p_N} which is a permutation of {1,\ 2,\ ...,\ N}.
You can perform the following operation at most once: choose integers i and j (1 \leq i < j \leq N), and swap p_i and p_j. Note that you can also choose not to perform it.
Print YES if you can sort p in ascending order in this w... |
apps_data_4206 | Polycarp likes numbers that are divisible by 3.
He has a huge number $s$. Polycarp wants to cut from it the maximum number of numbers that are divisible by $3$. To do this, he makes an arbitrary number of vertical cuts between pairs of adjacent digits. As a result, after $m$ such cuts, there will be $m+1$ parts in tot... |
apps_data_4207 | You are given two arrays $a$ and $b$, each contains $n$ integers.
You want to create a new array $c$ as follows: choose some real (i.e. not necessarily integer) number $d$, and then for every $i \in [1, n]$ let $c_i := d \cdot a_i + b_i$.
Your goal is to maximize the number of zeroes in array $c$. What is the largest... |
apps_data_4208 | There are $n$ left boots and $n$ right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings $l$ and $r$, both of length $n$. The character $l_i$ stands for the color of the $i$-th left boot and the character $r_i$ stands for the color of the... |
apps_data_4209 | This problem is given in two editions, which differ exclusively in the constraints on the number $n$.
You are given an array of integers $a[1], a[2], \dots, a[n].$ A block is a sequence of contiguous (consecutive) elements $a[l], a[l+1], \dots, a[r]$ ($1 \le l \le r \le n$). Thus, a block is defined by a pair of indic... |
apps_data_4210 | You are given an array $a$, consisting of $n$ positive integers.
Let's call a concatenation of numbers $x$ and $y$ the number that is obtained by writing down numbers $x$ and $y$ one right after another without changing the order. For example, a concatenation of numbers $12$ and $3456$ is a number $123456$.
Count the... |
apps_data_4211 | There is an integer sequence A of length N whose values are unknown.
Given is an integer sequence B of length N-1 which is known to satisfy the following:
B_i \geq \max(A_i, A_{i+1})
Find the maximum possible sum of the elements of A.
-----Constraints-----
- All values in input are integers.
- 2 \leq N \leq 100
-... |
apps_data_4212 | Given are positive integers N, M, Q, and Q quadruples of integers ( a_i , b_i , c_i , d_i ).
Consider a sequence A satisfying the following conditions:
- A is a sequence of N positive integers.
- 1 \leq A_1 \leq A_2 \le \cdots \leq A_N \leq M.
Let us define a score of this sequence as follows:
- The score is the sum... |
apps_data_4213 | You are given an integer sequence A of length N.
Find the maximum absolute difference of two elements (with different indices) in A.
-----Constraints-----
- 2 \leq N \leq 100
- 1 \leq A_i \leq 10^9
- All values in input are integers.
-----Input-----
Input is given from Standard Input in the following format:
N
A_1... |
apps_data_4214 | There are N towns in a coordinate plane. Town i is located at coordinates (x_i, y_i). The distance between Town i and Town j is \sqrt{\left(x_i-x_j\right)^2+\left(y_i-y_j\right)^2}.
There are N! possible paths to visit all of these towns once. Let the length of a path be the distance covered when we start at the first ... |
apps_data_4215 | The window of Takahashi's room has a width of A. There are two curtains hung over the window, each of which has a horizontal length of B. (Vertically, the curtains are long enough to cover the whole window.)
We will close the window so as to minimize the total horizontal length of the uncovered part of the window.
Find... |
apps_data_4216 | You are given an integer N.
For two positive integers A and B, we will define F(A,B) as the larger of the following: the number of digits in the decimal notation of A, and the number of digits in the decimal notation of B.
For example, F(3,11) = 2 since 3 has one digit and 11 has two digits.
Find the minimum value o... |
apps_data_4217 | Katsusando loves omelette rice.
Besides, he loves crème brûlée, tenderloin steak and so on, and believes that these foods are all loved by everyone.
To prove that hypothesis, he conducted a survey on M kinds of foods and asked N people whether they like these foods or not.
The i-th person answered that he/she only like... |
apps_data_4218 | Given is an integer N.
Takahashi chooses an integer a from the positive integers not greater than N with equal probability.
Find the probability that a is odd.
-----Constraints-----
- 1 \leq N \leq 100
-----Input-----
Input is given from Standard Input in the following format:
N
-----Output-----
Print the probabili... |
apps_data_4219 | There are N people numbered 1 to N. Each of them is either an honest person whose testimonies are always correct or an unkind person whose testimonies may be correct or not.
Person i gives A_i testimonies. The j-th testimony by Person i is represented by two integers x_{ij} and y_{ij}. If y_{ij} = 1, the testimony says... |
apps_data_4220 | We have a string S consisting of lowercase English letters.
If the length of S is at most K, print S without change.
If the length of S exceeds K, extract the first K characters in S, append ... to the end of them, and print the result.
-----Constraints-----
- K is an integer between 1 and 100 (inclusive).
- S is a ... |
apps_data_4221 | In the Kingdom of AtCoder, people use a language called Taknese, which uses lowercase English letters.
In Taknese, the plural form of a noun is spelled based on the following rules:
- If a noun's singular form does not end with s, append s to the end of the singular form.
- If a noun's singular form ends with s, appe... |
apps_data_4222 | N Snukes called Snuke 1, Snuke 2, ..., Snuke N live in a town.
There are K kinds of snacks sold in this town, called Snack 1, Snack 2, ..., Snack K. The following d_i Snukes have Snack i: Snuke A_{i, 1}, A_{i, 2}, \cdots, A_{i, {d_i}}.
Takahashi will walk around this town and make mischief on the Snukes who have no sna... |
apps_data_4223 | There are N slimes lining up from left to right. The colors of these slimes will be given as a string S of length N consisting of lowercase English letters. The i-th slime from the left has the color that corresponds to the i-th character of S.
Adjacent slimes with the same color will fuse into one larger slime without... |
apps_data_4224 | As AtCoder Beginner Contest 100 is taking place, the office of AtCoder, Inc. is decorated with a sequence of length N, a = {a_1, a_2, a_3, ..., a_N}.
Snuke, an employee, would like to play with this sequence.
Specifically, he would like to repeat the following operation as many times as possible:
For every i satisfyin... |
apps_data_4225 | We have A cards, each of which has an integer 1 written on it. Similarly, we also have B cards with 0s and C cards with -1s.
We will pick up K among these cards. What is the maximum possible sum of the numbers written on the cards chosen?
-----Constraints-----
- All values in input are integers.
- 0 \leq A, B, C
- ... |
apps_data_4226 | There are some animals in a garden. Each of them is a crane with two legs or a turtle with four legs.
Takahashi says: "there are X animals in total in the garden, and they have Y legs in total." Determine whether there is a combination of numbers of cranes and turtles in which this statement is correct.
-----Constrain... |
apps_data_4227 | You are given an undirected unweighted graph with N vertices and M edges that contains neither self-loops nor double edges.
Here, a self-loop is an edge where a_i = b_i (1≤i≤M), and double edges are two edges where (a_i,b_i)=(a_j,b_j) or (a_i,b_i)=(b_j,a_j) (1≤i<j≤M).
How many different paths start from vertex 1 and ... |
apps_data_4228 | You have N apples, called Apple 1, Apple 2, Apple 3, ..., Apple N. The flavor of Apple i is L+i-1, which can be negative.
You can make an apple pie using one or more of the apples. The flavor of the apple pie will be the sum of the flavors of the apples used.
You planned to make an apple pie using all of the apples, bu... |
apps_data_4229 | Let us define the FizzBuzz sequence a_1,a_2,... as follows:
- If both 3 and 5 divides i, a_i=\mbox{FizzBuzz}.
- If the above does not hold but 3 divides i, a_i=\mbox{Fizz}.
- If none of the above holds but 5 divides i, a_i=\mbox{Buzz}.
- If none of the above holds, a_i=i.
Find the sum of all numbers among the first... |
apps_data_4230 | Given are an integer X and an integer sequence of length N: p_1, \ldots, p_N.
Among the integers not contained in the sequence p_1, \ldots, p_N (not necessarily positive), find the integer nearest to X, that is, find the integer whose absolute difference with X is the minimum. If there are multiple such integers, repor... |
apps_data_4231 | There are H rows and W columns of white square cells.
You will choose h of the rows and w of the columns, and paint all of the cells contained in those rows or columns.
How many white cells will remain?
It can be proved that this count does not depend on what rows and columns are chosen.
-----Constraints-----
- All v... |
apps_data_4232 | You are given a sequence of integers of length $n$ and integer number $k$. You should print any integer number $x$ in the range of $[1; 10^9]$ (i.e. $1 \le x \le 10^9$) such that exactly $k$ elements of given sequence are less than or equal to $x$.
Note that the sequence can contain equal elements.
If there is no suc... |
apps_data_4233 | A star is a figure of the following type: an asterisk character '*' in the center of the figure and four rays (to the left, right, top, bottom) of the same positive length. The size of a star is the length of its rays. The size of a star must be a positive number (i.e. rays of length $0$ are not allowed).
Let's consid... |
apps_data_4234 | Let's call (yet again) a string good if its length is even, and every character in odd position of this string is different from the next character (the first character is different from the second, the third is different from the fourth, and so on). For example, the strings good, string and xyyx are good strings, and ... |
apps_data_4235 | You are given a connected undirected graph consisting of $n$ vertices and $m$ edges. There are no self-loops or multiple edges in the given graph.
You have to direct its edges in such a way that the obtained directed graph does not contain any paths of length two or greater (where the length of path is denoted as the ... |
apps_data_4236 | You are given a set of $n$ segments on the axis $Ox$, each segment has integer endpoints between $1$ and $m$ inclusive. Segments may intersect, overlap or even coincide with each other. Each segment is characterized by two integers $l_i$ and $r_i$ ($1 \le l_i \le r_i \le m$) — coordinates of the left and of the right e... |
apps_data_4237 | You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.
-----Constraints-----
- 1\leq A\leq B\leq 10^{18}
- 1\leq C,D\leq 10^9
- All values in input are integers.
-----Input-----
Input is given from Standard Input in the fol... |
apps_data_4238 | An integer N is a multiple of 9 if and only if the sum of the digits in the decimal representation of N is a multiple of 9.
Determine whether N is a multiple of 9.
-----Constraints-----
- 0 \leq N < 10^{200000}
- N is an integer.
-----Input-----
Input is given from Standard Input in the following format:
N
-----Ou... |
apps_data_4239 | To make it difficult to withdraw money, a certain bank allows its customers to withdraw only one of the following amounts in one operation:
- 1 yen (the currency of Japan)
- 6 yen, 6^2(=36) yen, 6^3(=216) yen, ...
- 9 yen, 9^2(=81) yen, 9^3(=729) yen, ...
At least how many operations are required to withdraw exactly... |
apps_data_4240 | You are given string S and T consisting of lowercase English letters.
Determine if S equals T after rotation.
That is, determine if S equals T after the following operation is performed some number of times:
Operation: Let S = S_1 S_2 ... S_{|S|}. Change S to S_{|S|} S_1 S_2 ... S_{|S|-1}.
Here, |X| denotes the length ... |
apps_data_4241 | Given are two strings S and T.
Let us change some of the characters in S so that T will be a substring of S.
At least how many characters do we need to change?
Here, a substring is a consecutive subsequence. For example, xxx is a substring of yxxxy, but not a substring of xxyxx.
-----Constraints-----
- The lengths of... |
apps_data_4242 | You are given positive integers A and B.
Find the K-th largest positive integer that divides both A and B.
The input guarantees that there exists such a number.
-----Constraints-----
- All values in input are integers.
- 1 \leq A, B \leq 100
- The K-th largest positive integer that divides both A and B exists.
- K... |
apps_data_4243 | Takahashi loves gold coins. He gains 1000 happiness points for each 500-yen coin he has and gains 5 happiness points for each 5-yen coin he has. (Yen is the currency of Japan.)
Takahashi has X yen. If he exchanges his money so that he will gain the most happiness points, how many happiness points will he earn?
(We assu... |
apps_data_4244 | There are N people living on a number line.
The i-th person lives at coordinate X_i.
You are going to hold a meeting that all N people have to attend.
The meeting can be held at any integer coordinate. If you choose to hold the meeting at coordinate P, the i-th person will spend (X_i - P)^2 points of stamina to attend ... |
apps_data_4245 | Takahashi's house has only one socket.
Takahashi wants to extend it with some number of power strips, each with A sockets, into B or more empty sockets.
One power strip with A sockets can extend one empty socket into A empty sockets.
Find the minimum number of power strips required.
-----Constraints-----
- All values... |
apps_data_4246 | You will be given a string S of length 3 representing the weather forecast for three days in the past.
The i-th character (1 \leq i \leq 3) of S represents the forecast for the i-th day. S, C, and R stand for sunny, cloudy, and rainy, respectively.
You will also be given a string T of length 3 representing the actual w... |
apps_data_4247 | We have a permutation p = {p_1,\ p_2,\ ...,\ p_n} of {1,\ 2,\ ...,\ n}.
Print the number of elements p_i (1 < i < n) that satisfy the following condition:
- p_i is the second smallest number among the three numbers p_{i - 1}, p_i, and p_{i + 1}.
-----Constraints-----
- All values in input are integers.
- 3 \leq n \... |
apps_data_4248 | -----Input-----
The first line contains a single integer n (1 ≤ n ≤ 1000) — the number of points on a plane.
Each of the next n lines contains two real coordinates x_{i} and y_{i} of the $i^{\text{th}}$ point, specified with exactly 2 fractional digits. All coordinates are between - 1000 and 1000, inclusive.
-----... |
apps_data_4249 | The only difference between easy and hard versions is the constraints.
Polycarp has to write a coursework. The coursework consists of $m$ pages.
Polycarp also has $n$ cups of coffee. The coffee in the $i$-th cup Polycarp has $a_i$ caffeine in it. Polycarp can drink some cups of coffee (each one no more than once). He... |
apps_data_4250 | You are given an array $s$ consisting of $n$ integers.
You have to find any array $t$ of length $k$ such that you can cut out maximum number of copies of array $t$ from array $s$.
Cutting out the copy of $t$ means that for each element $t_i$ of array $t$ you have to find $t_i$ in $s$ and remove it from $s$. If for so... |
apps_data_4251 | You are given a matrix $a$, consisting of $n$ rows and $m$ columns. Each cell contains an integer in it.
You can change the order of rows arbitrarily (including leaving the initial order), but you can't change the order of cells in a row. After you pick some order of rows, you traverse the whole matrix the following w... |
apps_data_4252 | You can not just take the file and send it. When Polycarp trying to send a file in the social network "Codehorses", he encountered an unexpected problem. If the name of the file contains three or more "x" (lowercase Latin letters "x") in a row, the system considers that the file content does not correspond to the socia... |
apps_data_4253 | It is known that the area of a regular dodecagon inscribed in a circle of radius a is 3a^2.
Given an integer r, find the area of a regular dodecagon inscribed in a circle of radius r.
-----Constraints-----
- 1 \leq r \leq 100
- r is an integer.
-----Input-----
Input is given from Standard Input in the following for... |
apps_data_4254 | There are S sheep and W wolves.
If the number of wolves is greater than or equal to that of sheep, the wolves will attack the sheep.
If the wolves will attack the sheep, print unsafe; otherwise, print safe.
-----Constraints-----
- 1 \leq S \leq 100
- 1 \leq W \leq 100
-----Input-----
Input is given from Standard In... |
apps_data_4255 | There is a right triangle ABC with ∠ABC=90°.
Given the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC.
It is guaranteed that the area of the triangle ABC is an integer.
-----Constraints-----
- 1 \leq |AB|,|BC|,|CA| \leq 100
- All values in input are integers.
- The area of t... |
apps_data_4256 | Takahashi likes the sound when he buys a drink from a vending machine.
That sound can be heard by spending A yen (the currency of Japan) each time.
Takahashi has B yen. He will hear the sound as many times as he can with that money, but at most C times, as he would be satisfied at that time.
How many times will he hear... |
apps_data_4257 | Compute A \times B.
-----Constraints-----
- 1 \leq A \leq 100
- 1 \leq B \leq 100
- All values in input are integers.
-----Input-----
Input is given from Standard Input in the following format:
A B
-----Output-----
Print the value A \times B as an integer.
-----Sample Input-----
2 5
-----Sample Output-----
10
... |
apps_data_4258 | A biscuit making machine produces B biscuits at the following moments: A seconds, 2A seconds, 3A seconds and each subsequent multiple of A seconds after activation.
Find the total number of biscuits produced within T + 0.5 seconds after activation.
-----Constraints-----
- All values in input are integers.
- 1 \leq A... |
apps_data_4259 | Takahashi the Jumbo will practice golf.
His objective is to get a carry distance that is a multiple of K, while he can only make a carry distance of between A and B (inclusive).
If he can achieve the objective, print OK; if he cannot, print NG.
-----Constraints-----
- All values in input are integers.
- 1 \leq A \le... |
apps_data_4260 | In order to pass the entrance examination tomorrow, Taro has to study for T more hours.
Fortunately, he can leap to World B where time passes X times as fast as it does in our world (World A).
While (X \times t) hours pass in World B, t hours pass in World A.
How many hours will pass in World A while Taro studies for T... |
apps_data_4261 | We have two bottles for holding water.
Bottle 1 can hold up to A milliliters of water, and now it contains B milliliters of water.
Bottle 2 contains C milliliters of water.
We will transfer water from Bottle 2 to Bottle 1 as much as possible.
How much amount of water will remain in Bottle 2?
-----Constraints-----
- A... |
apps_data_4262 | We have two permutations P and Q of size N (that is, P and Q are both rearrangements of (1,~2,~...,~N)).
There are N! possible permutations of size N. Among them, let P and Q be the a-th and b-th lexicographically smallest permutations, respectively. Find |a - b|.
-----Notes-----
For two sequences X and Y, X is said t... |
apps_data_4263 | You are given a string S consisting of uppercase English letters. Find the length of the longest ACGT string that is a substring (see Notes) of S.
Here, a ACGT string is a string that contains no characters other than A, C, G and T.
-----Notes-----
A substring of a string T is a string obtained by removing zero or mor... |
apps_data_4264 | Given is an integer N. Find the number of positive integers less than or equal to N that have an odd number of digits (in base ten without leading zeros).
-----Constraints-----
- 1 \leq N \leq 10^5
-----Input-----
Input is given from Standard Input in the following format:
N
-----Output-----
Print the number of pos... |
apps_data_4265 | Given are strings S and T. Consider changing S to T by repeating the operation below. Find the minimum number of operations required to do so.
Operation: Choose one character of S and replace it with a different character.
-----Constraints-----
- S and T have lengths between 1 and 2\times 10^5 (inclusive).
- S and T... |
apps_data_4266 | There are 2000001 stones placed on a number line. The coordinates of these stones are -1000000, -999999, -999998, \ldots, 999999, 1000000.
Among them, some K consecutive stones are painted black, and the others are painted white.
Additionally, we know that the stone at coordinate X is painted black.
Print all coordinat... |
apps_data_4267 | You will turn on the air conditioner if, and only if, the temperature of the room is 30 degrees Celsius or above.
The current temperature of the room is X degrees Celsius. Will you turn on the air conditioner?
-----Constraints-----
- -40 \leq X \leq 40
- X is an integer.
-----Input-----
Input is given from Standard... |
apps_data_4268 | There are N points in a D-dimensional space.
The coordinates of the i-th point are (X_{i1}, X_{i2}, ..., X_{iD}).
The distance between two points with coordinates (y_1, y_2, ..., y_D) and (z_1, z_2, ..., z_D) is \sqrt{(y_1 - z_1)^2 + (y_2 - z_2)^2 + ... + (y_D - z_D)^2}.
How many pairs (i, j) (i < j) are there such tha... |
apps_data_4269 | The door of Snuke's laboratory is locked with a security code.
The security code is a 4-digit number. We say the security code is hard to enter when it contains two consecutive digits that are the same.
You are given the current security code S. If S is hard to enter, print Bad; otherwise, print Good.
-----Constraints... |
apps_data_4270 | You have a pot and N ingredients. Each ingredient has a real number parameter called value, and the value of the i-th ingredient (1 \leq i \leq N) is v_i.
When you put two ingredients in the pot, they will vanish and result in the formation of a new ingredient. The value of the new ingredient will be (x + y) / 2 where ... |
apps_data_4271 | Takahashi went to an all-you-can-eat buffet with N kinds of dishes and ate all of them (Dish 1, Dish 2, \ldots, Dish N) once.
The i-th dish (1 \leq i \leq N) he ate was Dish A_i.
When he eats Dish i (1 \leq i \leq N), he gains B_i satisfaction points.
Additionally, when he eats Dish i+1 just after eating Dish i (1 \leq... |
apps_data_4272 | We have a string S of length N consisting of uppercase English letters.
How many times does ABC occur in S as contiguous subsequences (see Sample Inputs and Outputs)?
-----Constraints-----
- 3 \leq N \leq 50
- S consists of uppercase English letters.
-----Input-----
Input is given from Standard Input in the followi... |
apps_data_4273 | There are N people. The name of the i-th person is S_i.
We would like to choose three people so that the following conditions are met:
- The name of every chosen person begins with M, A, R, C or H.
- There are no multiple people whose names begin with the same letter.
How many such ways are there to choose three peop... |
apps_data_4274 | Takahashi is participating in a programming contest, AXC001. He has just submitted his code to Problem A.
The problem has N test cases, all of which must be passed to get an AC verdict.
Takahashi's submission has passed M cases out of the N test cases.
Determine whether Takahashi's submission gets an AC.
-----Const... |
apps_data_4275 | A string of length 6 consisting of lowercase English letters is said to be coffee-like if and only if its 3-rd and 4-th characters are equal and its 5-th and 6-th characters are also equal.
Given a string S, determine whether it is coffee-like.
-----Constraints-----
- S is a string of length 6 consisting of lowercas... |
apps_data_4276 | When Mr. X is away from home, he has decided to use his smartwatch to search the best route to go back home, to participate in ABC.
You, the smartwatch, has found N routes to his home.
If Mr. X uses the i-th of these routes, he will get home in time t_i at cost c_i.
Find the smallest cost of a route that takes not long... |
apps_data_4277 | N of us are going on a trip, by train or taxi.
The train will cost each of us A yen (the currency of Japan).
The taxi will cost us a total of B yen.
How much is our minimum total travel expense?
-----Constraints-----
- All values in input are integers.
- 1 \leq N \leq 20
- 1 \leq A \leq 50
- 1 \leq B \leq 50
----... |
apps_data_4278 | We will call a string obtained by arranging the characters contained in a string a in some order, an anagram of a.
For example, greenbin is an anagram of beginner. As seen here, when the same character occurs multiple times, that character must be used that number of times.
Given are N strings s_1, s_2, \ldots, s_N. Ea... |
apps_data_4279 | 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$\dots$" which consist of blocks of all consecutive positive integers written one after another. The first block consists of all numbers from $1$ to $1$, the second one — f... |
apps_data_4280 | Treeland consists of $n$ cities and $n-1$ roads. Each road is bidirectional and connects two distinct cities. From any city you can get to any other city by roads. Yes, you are right — the country's topology is an undirected tree.
There are some private road companies in Treeland. The government decided to sell roads ... |
apps_data_4281 | Oh, New Year. The time to gather all your friends and reflect on the heartwarming events of the past year...
$n$ friends live in a city which can be represented as a number line. The $i$-th friend lives in a house with an integer coordinate $x_i$. The $i$-th friend can come celebrate the New Year to the house with coo... |
apps_data_4282 | There are $n$ kids, numbered from $1$ to $n$, dancing in a circle around the Christmas tree. Let's enumerate them in a clockwise direction as $p_1$, $p_2$, ..., $p_n$ (all these numbers are from $1$ to $n$ and are distinct, so $p$ is a permutation). Let the next kid for a kid $p_i$ be kid $p_{i + 1}$ if $i < n$ and $p_... |
apps_data_4283 | You are a coach at your local university. There are $n$ students under your supervision, the programming skill of the $i$-th student is $a_i$.
You have to create a team for a new programming competition. As you know, the more students some team has the more probable its victory is! So you have to create a team with th... |
apps_data_4284 | Vova is playing a computer game. There are in total $n$ turns in the game and Vova really wants to play all of them. The initial charge of his laptop battery (i.e. the charge before the start of the game) is $k$.
During each turn Vova can choose what to do: If the current charge of his laptop battery is strictly gre... |
apps_data_4285 | You are given a string $s$ consisting of lowercase Latin letters "a", "b" and "c" and question marks "?".
Let the number of question marks in the string $s$ be $k$. Let's replace each question mark with one of the letters "a", "b" and "c". Here we can obtain all $3^{k}$ possible strings consisting only of letters "a",... |
apps_data_4286 | You are given an undirected graph consisting of $n$ vertices. A number is written on each vertex; the number on vertex $i$ is $a_i$. Initially there are no edges in the graph.
You may add some edges to this graph, but you have to pay for them. The cost of adding an edge between vertices $x$ and $y$ is $a_x + a_y$ coin... |
apps_data_4287 | Polycarp lives on a coordinate line at the point $x = 0$. He goes to his friend that lives at the point $x = a$. Polycarp can move only from left to right, he can pass one unit of length each second.
Now it's raining, so some segments of his way are in the rain. Formally, it's raining on $n$ non-intersecting segments,... |
apps_data_4288 | A triple of numbers is said to be poor when two of those numbers are equal but the other number is different from those two numbers.
You will be given three integers A, B, and C. If this triple is poor, print Yes; otherwise, print No.
-----Constraints-----
- A, B, and C are all integers between 1 and 9 (inclusive).
... |
apps_data_4289 | A country decides to build a palace.
In this country, the average temperature of a point at an elevation of x meters is T-x \times 0.006 degrees Celsius.
There are N places proposed for the place. The elevation of Place i is H_i meters.
Among them, Princess Joisino orders you to select the place whose average temperatu... |
apps_data_4290 | 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 (disregarding order) so that the sum of the numbers written on them is even.
It... |
apps_data_4291 | You are given a string S of length N consisting of A, C, G and T. Answer the following Q queries:
- Query i (1 \leq i \leq Q): You will be given integers l_i and r_i (1 \leq l_i < r_i \leq N). Consider the substring of S starting at index l_i and ending at index r_i (both inclusive). In this string, how many times doe... |
apps_data_4292 | A shop sells N kinds of fruits, Fruit 1, \ldots, N, at prices of p_1, \ldots, p_N yen per item, respectively. (Yen is the currency of Japan.)
Here, we will choose K kinds of fruits and buy one of each chosen kind. Find the minimum possible total price of those fruits.
-----Constraints-----
- 1 \leq K \leq N \leq 1000... |
apps_data_4293 | There are three airports A, B and C, and flights between each pair of airports in both directions.
A one-way flight between airports A and B takes P hours, a one-way flight between airports B and C takes Q hours, and a one-way flight between airports C and A takes R hours.
Consider a route where we start at one of the ... |
apps_data_4294 | X and A are integers between 0 and 9 (inclusive).
If X is less than A, print 0; if X is not less than A, print 10.
-----Constraints-----
- 0 \leq X, A \leq 9
- All values in input are integers.
-----Input-----
Input is given from Standard Input in the following format:
X A
-----Output-----
If X is less than A, pri... |
apps_data_4295 | Given any integer x, Aoki can do the operation below.
Operation: Replace x with the absolute difference of x and K.
You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
-----Constraints-----
- 0 ≤ N ≤ 10^{18}
- 1 ≤ K ≤ 10^{18}
... |
apps_data_4296 | Given are three integers A_1, A_2, and A_3.
If A_1+A_2+A_3 is greater than or equal to 22, print bust; otherwise, print win.
-----Constraints-----
- 1 \leq A_i \leq 13 \ \ (i=1,2,3)
- All values in input are integers.
-----Input-----
Input is given from Standard Input in the following format:
A_1 A_2 A_3
-----Outp... |
apps_data_4297 | You are given a positive integer N.
Find the minimum positive integer divisible by both 2 and N.
-----Constraints-----
- 1 \leq N \leq 10^9
- All values in input are integers.
-----Input-----
Input is given from Standard Input in the following format:
N
-----Output-----
Print the minimum positive integer divisible... |
apps_data_4298 | 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 will assign numbers from 1 through N to the trees. An inspector de... |
apps_data_4299 | The cat Snuke wants to play a popular Japanese game called ÅtCoder, so Iroha has decided to teach him Japanese.
When counting pencils in Japanese, the counter word "本" follows the number. The pronunciation of this word varies depending on the number. Specifically, the pronunciation of "本" in the phrase "N 本" for a posi... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.