question
large_stringlengths
265
13.2k
Solve the programming task below in a Python markdown code block. The only difference between easy and hard versions is the number of elements in the array. You are given an array $a$ consisting of $n$ integers. In one move you can choose any $a_i$ and divide it by $2$ rounding down (in other words, in one move you c...
Solve the programming task below in a Python markdown code block. You are given the array $a$ consisting of $n$ elements and the integer $k \le n$. You want to obtain at least $k$ equal elements in the array $a$. In one move, you can make one of the following two operations: Take one of the minimum elements of the...
Solve the programming task below in a Python markdown code block. Takahashi is practicing shiritori alone again today. Shiritori is a game as follows: - In the first turn, a player announces any one word. - In the subsequent turns, a player announces a word that satisfies the following conditions: - That word is no...
Solve the programming task below in a Python markdown code block. Takahashi is organizing a party. At the party, each guest will receive one or more snack pieces. Takahashi predicts that the number of guests at this party will be A or B. Find the minimum number of pieces that can be evenly distributed to the guests in...
Solve the programming task below in a Python markdown code block. Given is a string S. Replace every character in S with x and print the result. -----Constraints----- - S is a string consisting of lowercase English letters. - The length of S is between 1 and 100 (inclusive). -----Input----- Input is given from Sta...
Solve the programming task below in a Python markdown code block. We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required. -----Constraints----- - 1 \leq N \leq 10000 - N is...
Solve the programming task below in a Python markdown code block. Our world is one-dimensional, and ruled by two empires called Empire A and Empire B. The capital of Empire A is located at coordinate X, and that of Empire B is located at coordinate Y. One day, Empire A becomes inclined to put the cities at coordinates...
Solve the programming task below in a Python markdown code block. Each day in Berland consists of $n$ hours. Polycarp likes time management. That's why he has a fixed schedule for each day — it is a sequence $a_1, a_2, \dots, a_n$ (each $a_i$ is either $0$ or $1$), where $a_i=0$ if Polycarp works during the $i$-th hou...
Solve the programming task below in a Python markdown code block. Little Petya wanted to give an April Fools Day present to some scientists. After some hesitation he decided to give them the array that he got as a present in Codeforces Round #153 (Div.2). The scientists rejoiced at the gift and decided to put some imp...
Solve the programming task below in a Python markdown code block. Not to be confused with chessboard. [Image] -----Input----- The first line of input contains a single integer N (1 ≤ N ≤ 100) — the number of cheeses you have. The next N lines describe the cheeses you have. Each line contains two space-separated...
Solve the programming task below in a Python markdown code block. [Image] -----Input----- The input consists of four lines, each line containing a single digit 0 or 1. -----Output----- Output a single digit, 0 or 1. -----Example----- Input 0 1 1 0 Output 0 Read the inputs from stdin solve the problem and w...
Solve the programming task below in a Python markdown code block. Takahashi is meeting up with Aoki. They have planned to meet at a place that is D meters away from Takahashi's house in T minutes from now. Takahashi will leave his house now and go straight to the place at a speed of S meters per minute. Will he arrive...
Solve the programming task below in a Python markdown code block. We have a bingo card with a 3\times3 grid. The square at the i-th row from the top and the j-th column from the left contains the number A_{i, j}. The MC will choose N numbers, b_1, b_2, \cdots, b_N. If our bingo sheet contains some of those numbers, we...
Solve the programming task below in a Python markdown code block. Takahashi has N days of summer vacation. His teacher gave him M summer assignments. It will take A_i days for him to do the i-th assignment. He cannot do multiple assignments on the same day, or hang out on a day he does an assignment. What is the maxim...
Solve the programming task below in a Python markdown code block. Today, the memorable AtCoder Beginner Contest 100 takes place. On this occasion, Takahashi would like to give an integer to Ringo. As the name of the contest is AtCoder Beginner Contest 100, Ringo would be happy if he is given a positive integer that c...
Solve the programming task below in a Python markdown code block. Takahashi is a teacher responsible for a class of N students. The students are given distinct student numbers from 1 to N. Today, all the students entered the classroom at different times. According to Takahashi's record, there were A_i students in the ...
Solve the programming task below in a Python markdown code block. N friends of Takahashi has come to a theme park. To ride the most popular roller coaster in the park, you must be at least K centimeters tall. The i-th friend is h_i centimeters tall. How many of the Takahashi's friends can ride the roller coaster? ---...
Solve the programming task below in a Python markdown code block. 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 ...
Solve the programming task below in a Python markdown code block. 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...
Solve the programming task below in a Python markdown code block. 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 ...
Solve the programming task below in a Python markdown code block. 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....
Solve the programming task below in a Python markdown code block. 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...
Solve the programming task below in a Python markdown code block. 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 $...
Solve the programming task below in a Python markdown code block. 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]$ (...
Solve the programming task below in a Python markdown code block. 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 concat...
Solve the programming task below in a Python markdown code block. 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. -----Constraint...
Solve the programming task below in a Python markdown code block. 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----...
Solve the programming task below in a Python markdown code block. 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 l...
Solve the programming task below in a Python markdown code block. 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 th...
Solve the programming task below in a Python markdown code block. 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 sin...
Solve the programming task below in a Python markdown code block. 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...
Solve the programming task below in a Python markdown code block. 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 Inp...
Solve the programming task below in a Python markdown code block. 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 b...
Solve the programming task below in a Python markdown code block. 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. -----Constraint...
Solve the programming task below in a Python markdown code block. 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 o...
Solve the programming task below in a Python markdown code block. 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 wa...
Solve the programming task below in a Python markdown code block. 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...
Solve the programming task below in a Python markdown code block. 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 f...
Solve the programming task below in a Python markdown code block. 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? -----Constrai...
Solve the programming task below in a Python markdown code block. 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 cra...
Solve the programming task below in a Python markdown code block. 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...
Solve the programming task below in a Python markdown code block. 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 ...
Solve the programming task below in a Python markdown code block. 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 differenc...
Solve the programming task below in a Python markdown code block. 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 o...
Solve the programming task below in a Python markdown code block. 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$. Not...
Solve the programming task below in a Python markdown code block. 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 posit...
Solve the programming task below in a Python markdown code block. 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). Fo...
Solve the programming task below in a Python markdown code block. 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...
Solve the programming task below in a Python markdown code block. 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 integ...
Solve the programming task below in a Python markdown code block. 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----- Inp...
Solve the programming task below in a Python markdown code block. 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...
Solve the programming task below in a Python markdown code block. 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|}. Chang...
Solve the programming task below in a Python markdown code block. 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...
Solve the programming task below in a Python markdown code block. 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...
Solve the programming task below in a Python markdown code block. 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...
Solve the programming task below in a Python markdown code block. 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, ...
Solve the programming task below in a Python markdown code block. 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 nu...
Solve the programming task below in a Python markdown code block. -----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 digit...
Solve the programming task below in a Python markdown code block. 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. Poly...
Solve the programming task below in a Python markdown code block. 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 ...
Solve the programming task below in a Python markdown code block. 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 pic...
Solve the programming task below in a Python markdown code block. 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 syst...
Solve the programming task below in a Python markdown code block. 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. ----...
Solve the programming task below in a Python markdown code block. 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 -...
Solve the programming task below in a Python markdown code block. 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|,...
Solve the programming task below in a Python markdown code block. 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,...
Solve the programming task below in a Python markdown code block. 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...
Solve the programming task below in a Python markdown code block. 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. ---...
Solve the programming task below in a Python markdown code block. 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. -----Co...
Solve the programming task below in a Python markdown code block. 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 Wo...
Solve the programming task below in a Python markdown code block. 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 a...
Solve the programming task below in a Python markdown code block. 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. Fi...
Solve the programming task below in a Python markdown code block. 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 s...
Solve the programming task below in a Python markdown code block. 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 i...
Solve the programming task below in a Python markdown code block. 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 an...
Solve the programming task below in a Python markdown code block. 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 4...
Solve the programming task below in a Python markdown code block. 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 + ......
Solve the programming task below in a Python markdown code block. 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...
Solve the programming task below in a Python markdown code block. 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 ing...
Solve the programming task below in a Python markdown code block. 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. A...
Solve the programming task below in a Python markdown code block. 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....
Solve the programming task below in a Python markdown code block. 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...
Solve the programming task below in a Python markdown code block. 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. -----C...
Solve the programming task below in a Python markdown code block. 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...
Solve the programming task below in a Python markdown code block. 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...
Solve the programming task below in a Python markdown code block. 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 firs...
Solve the programming task below in a Python markdown code block. 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 privat...
Solve the programming task below in a Python markdown code block. 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 ...
Solve the programming task below in a Python markdown code block. 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...
Solve the programming task below in a Python markdown code block. 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...
Solve the programming task below in a Python markdown code block. Vova is playing a computer game. There are in total $n$ turns in the game and Vova really wants to play all of them. The initial charge of his laptop battery (i.e. the charge before the start of the game) is $k$. During each turn Vova can choose what t...
Solve the programming task below in a Python markdown code block. 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...
Solve the programming task below in a Python markdown code block. 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-...
Solve the programming task below in a Python markdown code block. 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, Prin...
Solve the programming task below in a Python markdown code block. 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 endin...
Solve the programming task below in a Python markdown code block. 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 o...
Solve the programming task below in a Python markdown code block. 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 t...
Solve the programming task below in a Python markdown code block. 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 ti...
Solve the programming task below in a Python markdown code block. 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 ...
Solve the programming task below in a Python markdown code block. 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 forma...