id
stringlengths
11
14
content
stringlengths
424
1.17M
apps_data_4600
Takahashi participated in a contest on AtCoder. The contest had N problems. Takahashi made M submissions during the contest. The i-th submission was made for the p_i-th problem and received the verdict S_i (AC or WA). The number of Takahashi's correct answers is the number of problems on which he received an AC once or...
apps_data_4601
Fennec is fighting with N monsters. The health of the i-th monster is H_i. Fennec can do the following two actions: - Attack: Fennec chooses one monster. That monster's health will decrease by 1. - Special Move: Fennec chooses one monster. That monster's health will become 0. There is no way other than Attack and Spe...
apps_data_4602
There are N balls in the xy-plane. The coordinates of the i-th of them is (x_i, i). Thus, we have one ball on each of the N lines y = 1, y = 2, ..., y = N. In order to collect these balls, Snuke prepared 2N robots, N of type A and N of type B. Then, he placed the i-th type-A robot at coordinates (0, i), and the i-th ty...
apps_data_4603
You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket. Find the minimum...
apps_data_4604
There are N people, conveniently numbered 1 through N. They were standing in a row yesterday, but now they are unsure of the order in which they were standing. However, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the nu...
apps_data_4605
Find the sum of the integers between 1 and N (inclusive), whose sum of digits written in base 10 is between A and B (inclusive). -----Constraints----- - 1 \leq N \leq 10^4 - 1 \leq A \leq B \leq 36 - All input values are integers. -----Input----- Input is given from Standard Input in the following format: N A B -...
apps_data_4606
This contest, AtCoder Beginner Contest, is abbreviated as ABC. When we refer to a specific round of ABC, a three-digit number is appended after ABC. For example, ABC680 is the 680th round of ABC. What is the abbreviation for the N-th round of ABC? Write a program to output the answer. -----Constraints----- - 100 ≤ N ...
apps_data_4607
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the "year-month-day" order, or the "month-day" order without the year. For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year. In this country, a date is called Takahashi when the month and the day are equal as numbers. For ex...
apps_data_4608
Takahashi wants to gain muscle, and decides to work out at AtCoder Gym. The exercise machine at the gym has N buttons, and exactly one of the buttons is lighten up. These buttons are numbered 1 through N. When Button i is lighten up and you press it, the light is turned off, and then Button a_i will be lighten up. It i...
apps_data_4609
You are playing the following game with Joisino. - Initially, you have a blank sheet of paper. - Joisino announces a number. If that number is written on the sheet, erase the number from the sheet; if not, write the number on the sheet. This process is repeated N times. - Then, you are asked a question: How many num...
apps_data_4610
Takahashi has N balls. Initially, an integer A_i is written on the i-th ball. He would like to rewrite the integer on some balls so that there are at most K different integers written on the N balls. Find the minimum number of balls that Takahashi needs to rewrite the integers on them. -----Constraints----- - 1 \leq ...
apps_data_4611
AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i. If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,...
apps_data_4612
You are given two positive integers a and b. Let x be the average of a and b. Print x rounded up to the nearest integer. -----Constraints----- - a and b are integers. - 1 \leq a, b \leq 100 -----Input----- Input is given from Standard Input in the following format: a b -----Output----- Print x rounded up to the ne...
apps_data_4613
You are given an undirected connected graph with N vertices and M edges that does not contain self-loops and double edges. The i-th edge (1 \leq i \leq M) connects Vertex a_i and Vertex b_i. An edge whose removal disconnects the graph is called a bridge. Find the number of the edges that are bridges among the M edg...
apps_data_4614
You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers. -----Constraints----- - -100 \leq A,B,C \...
apps_data_4615
Snuke is making sugar water in a beaker. Initially, the beaker is empty. Snuke can perform the following four types of operations any number of times. He may choose not to perform some types of operations. - Operation 1: Pour 100A grams of water into the beaker. - Operation 2: Pour 100B grams of water into the beaker...
apps_data_4616
The word internationalization is sometimes abbreviated to i18n. This comes from the fact that there are 18 letters between the first i and the last n. You are given a string s of length at least 3 consisting of lowercase English letters. Abbreviate s in the same way. -----Constraints----- - 3 ≤ |s| ≤ 100 (|s| denotes...
apps_data_4617
You are given a grid with 2 rows and 3 columns of squares. The color of the square at the i-th row and j-th column is represented by the character C_{ij}. Write a program that prints YES if this grid remains the same when rotated 180 degrees, and prints NO otherwise. -----Constraints----- - C_{i,j}(1 \leq i \leq 2, 1...
apps_data_4618
You are given a string s. Among the different substrings of s, print the K-th lexicographically smallest one. A substring of s is a string obtained by taking out a non-empty contiguous part in s. For example, if s = ababc, a, bab and ababc are substrings of s, while ac, z and an empty string are not. Also, we say that ...
apps_data_4619
There is a rectangle in the xy-plane, with its lower left corner at (0, 0) and its upper right corner at (W, H). Each of its sides is parallel to the x-axis or y-axis. Initially, the whole region within the rectangle is painted white. Snuke plotted N points into the rectangle. The coordinate of the i-th (1 ≦ i ≦ N) poi...
apps_data_4620
A railroad running from west to east in Atcoder Kingdom is now complete. There are N stations on the railroad, numbered 1 through N from west to east. Tomorrow, the opening ceremony of the railroad will take place. On this railroad, for each integer i such that 1≤i≤N-1, there will be trains that run from Station i to S...
apps_data_4621
There is an image with a height of H pixels and a width of W pixels. Each of the pixels is represented by either . or *. The character representing the pixel at the i-th row from the top and the j-th column from the left, is denoted by C_{i,j}. Extend this image vertically so that its height is doubled. That is, print ...
apps_data_4622
Given is a sequence of integers A_1, A_2, ..., A_N. If its elements are pairwise distinct, print YES; otherwise, print NO. -----Constraints----- - 2 ≤ N ≤ 200000 - 1 ≤ A_i ≤ 10^9 - All values in input are integers. -----Input----- Input is given from Standard Input in the following format: N A_1 ... A_N -----Outp...
apps_data_4623
There are $n$ people who want to participate in a boat competition. The weight of the $i$-th participant is $w_i$. Only teams consisting of two people can participate in this competition. As an organizer, you think that it's fair to allow only teams with the same total weight. So, if there are $k$ teams $(a_1, b_1)$, ...
apps_data_4624
Vasya goes to visit his classmate Petya. Vasya knows that Petya's apartment number is $n$. There is only one entrance in Petya's house and the distribution of apartments is the following: the first floor contains $2$ apartments, every other floor contains $x$ apartments each. Apartments are numbered starting from one...
apps_data_4625
You want to perform the combo on your opponent in one popular fighting game. The combo is the string $s$ consisting of $n$ lowercase Latin letters. To perform the combo, you have to press all buttons in the order they appear in $s$. I.e. if $s=$"abca" then you have to press 'a', then 'b', 'c' and 'a' again. You know t...
apps_data_4626
Three friends are going to meet each other. Initially, the first friend stays at the position $x = a$, the second friend stays at the position $x = b$ and the third friend stays at the position $x = c$ on the coordinate axis $Ox$. In one minute each friend independently from other friends can change the position $x$ b...
apps_data_4627
We call two numbers $x$ and $y$ similar if they have the same parity (the same remainder when divided by $2$), or if $|x-y|=1$. For example, in each of the pairs $(2, 6)$, $(4, 3)$, $(11, 7)$, the numbers are similar to each other, and in the pairs $(1, 4)$, $(3, 12)$, they are not. You are given an array $a$ of $n$ (...
apps_data_4628
You are a mayor of Berlyatov. There are $n$ districts and $m$ two-way roads between them. The $i$-th road connects districts $x_i$ and $y_i$. The cost of travelling along this road is $w_i$. There is some path between each pair of districts, so the city is connected. There are $k$ delivery routes in Berlyatov. The $i$...
apps_data_4629
The only difference between easy and hard versions is the maximum value of $n$. You are given a positive integer number $n$. You really love good numbers so you want to find the smallest good number greater than or equal to $n$. The positive integer is called good if it can be represented as a sum of distinct powers ...
apps_data_4630
The only difference between easy and hard versions is constraints. There are $n$ kids, each of them is reading a unique book. At the end of any day, the $i$-th kid will give his book to the $p_i$-th kid (in case of $i = p_i$ the kid will give his book to himself). It is guaranteed that all values of $p_i$ are distinct...
apps_data_4631
There are $n$ Christmas trees on an infinite number line. The $i$-th tree grows at the position $x_i$. All $x_i$ are guaranteed to be distinct. Each integer point can be either occupied by the Christmas tree, by the human or not occupied at all. Non-integer points cannot be occupied by anything. There are $m$ people ...
apps_data_4632
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 are no two packages at the same point. It is also guaranteed that th...
apps_data_4633
You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$. You have to answer $t$ independent test cases. -----Input----- The fir...
apps_data_4634
There is a bookshelf which can fit $n$ books. The $i$-th position of bookshelf is $a_i = 1$ if there is a book on this position and $a_i = 0$ otherwise. It is guaranteed that there is at least one book on the bookshelf. In one move, you can choose some contiguous segment $[l; r]$ consisting of books (i.e. for each $i$...
apps_data_4635
You are given two integers $n$ and $k$. Your task is to construct such a string $s$ of length $n$ that for each $i$ from $1$ to $k$ there is at least one $i$-th letter of the Latin alphabet in this string (the first letter is 'a', the second is 'b' and so on) and there are no other letters except these. You have to ma...
apps_data_4636
There are $n$ candies in a row, they are numbered from left to right from $1$ to $n$. The size of the $i$-th candy is $a_i$. Alice and Bob play an interesting and tasty game: they eat candy. Alice will eat candy from left to right, and Bob — from right to left. The game ends if all the candies are eaten. The process ...
apps_data_4637
You are given two arrays $a$ and $b$ both consisting of $n$ positive (greater than zero) integers. You are also given an integer $k$. In one move, you can choose two indices $i$ and $j$ ($1 \le i, j \le n$) and swap $a_i$ and $b_j$ (i.e. $a_i$ becomes $b_j$ and vice versa). Note that $i$ and $j$ can be equal or differ...
apps_data_4638
You are planning to buy an apartment in a $n$-floor building. The floors are numbered from $1$ to $n$ from the bottom to the top. At first for each floor you want to know the minimum total time to reach it from the first (the bottom) floor. Let: $a_i$ for all $i$ from $1$ to $n-1$ be the time required to go from the ...
apps_data_4639
For the given integer $n$ ($n > 2$) let's write down all the strings of length $n$ which contain $n-2$ letters 'a' and two letters 'b' in lexicographical (alphabetical) order. Recall that the string $s$ of length $n$ is lexicographically less than string $t$ of length $n$, if there exists such $i$ ($1 \le i \le n$), t...
apps_data_4640
There are $n$ points on a plane. The $i$-th point has coordinates $(x_i, y_i)$. You have two horizontal platforms, both of length $k$. Each platform can be placed anywhere on a plane but it should be placed horizontally (on the same $y$-coordinate) and have integer borders. If the left border of the platform is $(x, y)...
apps_data_4641
Recall that MEX of an array is a minimum non-negative integer that does not belong to the array. Examples: for the array $[0, 0, 1, 0, 2]$ MEX equals to $3$ because numbers $0, 1$ and $2$ are presented in the array and $3$ is the minimum non-negative integer not presented in the array; for the array $[1, 2, 3, 4]$ ME...
apps_data_4642
We have a secret array. You don't know this array and you have to restore it. However, you know some facts about this array: The array consists of $n$ distinct positive (greater than $0$) integers. The array contains two elements $x$ and $y$ (these elements are known for you) such that $x < y$. If you sort the arr...
apps_data_4643
You are developing a new feature for the website which sells airline tickets: being able to sort tickets by price! You have already extracted the tickets' prices, so there's just the last step to be done... You are given an array of integers. Sort it in non-descending order. -----Input----- The input consists of a ...
apps_data_4644
You are given an array $a$ consisting of $n$ integers. In one move, you can choose two indices $1 \le i, j \le n$ such that $i \ne j$ and set $a_i := a_j$. You can perform such moves any number of times (possibly, zero). You can choose different indices in different operations. The operation := is the operation of ass...
apps_data_4645
A permutation of length $n$ is an array $p=[p_1,p_2,\dots,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$ ($n \ge 2$), find a permutation $p$ in which absolute difference...
apps_data_4646
You are given an array $a[0 \ldots n-1]$ of length $n$ which consists of non-negative integers. Note that array indices start from zero. An array is called good if the parity of each index matches the parity of the element at that index. More formally, an array is good if for all $i$ ($0 \le i \le n - 1$) the equality...
apps_data_4647
You are given a tree consisting of $n$ vertices. A tree is a connected undirected graph with $n-1$ edges. Each vertex $v$ of this tree has a color assigned to it ($a_v = 1$ if the vertex $v$ is white and $0$ if the vertex $v$ is black). You have to solve the following problem for each vertex $v$: what is the maximum d...
apps_data_4648
You are given an integer $n$. In one move, you can either multiply $n$ by two or divide $n$ by $6$ (if it is divisible by $6$ without the remainder). Your task is to find the minimum number of moves needed to obtain $1$ from $n$ or determine if it's impossible to do that. You have to answer $t$ independent test cases...
apps_data_4649
The only difference between easy and hard versions is the size of the input. You are given a string $s$ consisting of $n$ characters, each character is 'R', 'G' or 'B'. You are also given an integer $k$. Your task is to change the minimum number of characters in the initial string $s$ so that after the changes there ...
apps_data_4650
You are given an array $a$ consisting of $n$ integers $a_1, a_2, \dots , a_n$. In one operation you can choose two elements of the array and replace them with the element equal to their sum (it does not matter where you insert the new element). For example, from the array $[2, 1, 4]$ you can obtain the following array...
apps_data_4651
You are given a permutation of length $n$. Recall that the permutation is an array consisting of $n$ distinct integers from $1$ to $n$ in arbitrary order. For example, $[2, 3, 1, 5, 4]$ is a permutation, but $[1, 2, 2]$ is not a permutation ($2$ appears twice in the array) and $[1, 3, 4]$ is also not a permutation ($n=...
apps_data_4652
There are $n$ students standing in a circle in some order. The index of the $i$-th student is $p_i$. It is guaranteed that all indices of students are distinct integers from $1$ to $n$ (i. e. they form a permutation). Students want to start a round dance. A clockwise round dance can be started if the student $2$ comes...
apps_data_4653
Santa has $n$ candies and he wants to gift them to $k$ kids. He wants to divide as many candies as possible between all $k$ kids. Santa can't divide one candy into parts but he is allowed to not use some candies at all. Suppose the kid who recieves the minimum number of candies has $a$ candies and the kid who recieves...
apps_data_4654
You are given two positive integers $n$ ($1 \le n \le 10^9$) and $k$ ($1 \le k \le 100$). Represent the number $n$ as the sum of $k$ positive integers of the same parity (have the same remainder when divided by $2$). In other words, find $a_1, a_2, \ldots, a_k$ such that all $a_i>0$, $n = a_1 + a_2 + \ldots + a_k$ and...
apps_data_4655
Alice and Bob have received three big piles of candies as a gift. Now they want to divide these candies as fair as possible. To do this, Alice takes one pile of candies, then Bob takes one of the other two piles. The last pile is split between Alice and Bob as they want: for example, it is possible that Alice takes the...
apps_data_4656
The store sells $n$ beads. The color of each bead is described by a lowercase letter of the English alphabet ("a"–"z"). You want to buy some beads to assemble a necklace from them. A necklace is a set of beads connected in a circle. For example, if the store sells beads "a", "b", "c", "a", "c", "c", then you can asse...
apps_data_4657
You are given an array $a$ consisting of $n$ integers $a_1, a_2, \dots, a_n$. You want to split it into exactly $k$ non-empty non-intersecting subsegments such that each subsegment has odd sum (i. e. for each subsegment, the sum of all elements that belong to this subsegment is odd). It is impossible to rearrange (shuf...
apps_data_4658
Reverse bits of a given 32 bits unsigned integer. Note: Note that in some languages such as Java, there is no unsigned integer type. In this case, both input and output will be given as a signed integer type. They should not affect your implementation, as the integer's internal binary representation is the same, whet...
apps_data_4659
Given a non-negative integer numRows, generate the first numRows of Pascal's triangle. In Pascal's triangle, each number is the sum of the two numbers directly above it. Example: Input: 5 Output: [ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1] ] class Solution: def generate(self, numRows): ...
apps_data_4660
=====Problem Statement===== You are given an integer N followed by N email addresses. Your task is to print a list containing only valid email addresses in lexicographical order. Valid email addresses must follow these rules: It must have the username@websitename.extension format type. The username can only contain let...
apps_data_4661
=====Problem Statement===== Let's learn some new Python concepts! You have to generate a list of the first N fibonacci numbers, 0 being the first number. Then, apply the map function and a lambda expression to cube each fibonacci number and print the list. Concept The map() function applies a function to every member...
apps_data_4662
=====Problem Statement===== You are given a valid XML document, and you have to print the maximum level of nesting in it. Take the depth of the root as 0. =====Input Format===== The first line contains N, the number of lines in the XML document. The next N lines follow containing the XML document. =====Output Format=...
apps_data_4663
=====Problem Statement===== Let's dive into the interesting topic of regular expressions! You are given some input, and you are required to check whether they are valid mobile numbers. Concept A valid mobile number is a ten digit number starting with a 7, 8, or 9. =====Input Format===== The first line contains an int...
apps_data_4664
=====Function Descriptions===== Objective Today, we're learning about a new data type: sets. Concept If the inputs are given on one line separated by a space character, use split() to get the separate values in the form of a list: >> a = raw_input() 5 4 3 2 >> lis = a.split() >> print (lis) ['5', '4', '3', '2'] If ...
apps_data_4665
=====Function Descriptions===== collections.namedtuple() Basically, namedtuples are easy to create, lightweight object types. They turn tuples into convenient containers for simple tasks. With namedtuples, you don’t have to use integer indices for accessing members of a tuple. Example Code 01 >>> from collections imp...
apps_data_4666
=====Problem Statement===== Given an integer, n, perform the following conditional actions: If n is odd, print Weird If n is even and in the inclusive range of 2 to 5, print Not Weird If n is even and in the inclusive range of 6 to 20, print Weird If n is even and greater than 20, print Not Weird =====Input Format====...
apps_data_4667
=====Problem Statement===== You are given a valid XML document, and you have to print its score. The score is calculated by the sum of the score of each element. For any element, the score is equal to the number of attributes it has. =====Input Format===== The first line contains N, the number of lines in the XML docu...
apps_data_4668
=====Problem Statement===== You are given four points A, B, C and D in a 3-dimensional Cartesian coordinate system. You are required to print the angle between the plane made by the points A, B, C and B, C, D in degrees(not radians). Let the angle be PHI. Cos(PHI) = (X.Y)/|X|Y| where X = AB x BC and Y = BC x CD. Here, ...
apps_data_4669
=====Problem Statement===== In this challenge, the task is to debug the existing code to successfully execute all provided test files. Consider that vowels in the alphabet are a, e, i, o, u and y. Function score_words takes a list of lowercase words as an argument and returns a score as follows: The score of a single w...
apps_data_4670
=====Problem Statement===== You are given a string, and you have to validate whether it's a valid Roman numeral. If it is valid, print True. Otherwise, print False. Try to create a regular expression for a valid Roman numeral. =====Input Format===== A single line of input containing a string of Roman characters. ====...
apps_data_4671
=====Problem Statement===== Let's dive into decorators! You are given N mobile numbers. Sort them in ascending order then print them in the standard format shown below: +91 xxxxx xxxxx The given mobile numbers may have +91, 91 or 0 written before the actual 10 digit number. Alternatively, there may not be any prefix a...
apps_data_4672
=====Problem Statement===== The provided code stub will read in a dictionary containing key/value pairs of name:[marks] for a list of students. Print the average of the marks array for the student name provided, showing 2 places after the decimal. =====Example===== marks key:value pairs are 'alpha': [20,30,40] 'beta':...
apps_data_4673
=====Problem Statement===== Let's use decorators to build a name directory! You are given some information about N people. Each person has a first name, last name, age and sex ('M' or 'F'). Print their names in a specific format sorted by their age in ascending order i.e. the youngest person's name should be printed fi...
apps_data_4674
=====Problem Statement===== Let's learn about list comprehensions! You are given three integers x, y and z representing the dimensions of a cuboid along with an integer n. Print a list of all possible coordinates given by (i,j,k) on a 3D grid where the sum of i+j+k is not equal to n. Here, 0≤i≤x;0≤j≤y;0≤k≤z. Please use...
apps_data_4675
=====Problem Statement===== For this challenge, you are given two complex numbers, and you have to print the result of their addition, subtraction, multiplication, division and modulus operations. The real and imaginary precision part should be correct up to two decimal places. =====Input Format===== One line of input...
apps_data_4676
Snuke signed up for a new website which holds programming competitions. He worried that he might forget his password, and he took notes of it. Since directly recording his password would cause him trouble if stolen, he took two notes: one contains the characters at the odd-numbered positions, and the other contains the...
apps_data_4677
Sig has built his own keyboard. Designed for ultimate simplicity, this keyboard only has 3 keys on it: the 0 key, the 1 key and the backspace key. To begin with, he is using a plain text editor with this keyboard. This editor always displays one string (possibly empty). Just after the editor is launched, this string is...
apps_data_4678
N persons are standing in a row. The height of the i-th person from the front is A_i. We want to have each person stand on a stool of some heights - at least zero - so that the following condition is satisfied for every person: Condition: Nobody in front of the person is taller than the person. Here, the height of a pe...
apps_data_4679
Alice, Bob and Charlie are playing Card Game for Three, as below: - At first, each of the three players has a deck consisting of some number of cards. Each card has a letter a, b or c written on it. The orders of the cards in the decks cannot be rearranged. - The players take turns. Alice goes first. - If the curren...
apps_data_4680
Iroha loves Haiku. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of ...
apps_data_4681
It is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas numbers. You are given an integer N. Find the N-th Lucas number. Here, the i-th Lucas number L_i is defined as follows: - L_0=2 - L_1=1 - L_i=L_{i-1}+L_{i-2} (i≥2) -----Constraints----- - 1≤N≤86 - It is guaranteed that the answer is less tha...
apps_data_4682
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid. -----Constraints----- - 1≦a≦100 - 1≦b≦100 - 1≦h≦100 - All input values are integers. - h is even. -----Input----- The input is given from Stan...
apps_data_4683
Given are N integers A_1,\ldots,A_N. Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7). -----Constraints----- - 2 \leq N \leq 2\times 10^5 - 0 \leq A_i \leq 10^9 - All values in input are integers. -----Input----- Input is given from Standard Input in the following f...
apps_data_4684
AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this inte...
apps_data_4685
There are three positive integers A, B and C written on a blackboard. E869120 performs the following operation K times: - Choose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n. What is the largest possible sum of the integers written on the blackboard after K ...
apps_data_4686
Let w be a string consisting of lowercase letters. We will call w beautiful if the following condition is satisfied: - Each lowercase letter of the English alphabet occurs even number of times in w. You are given the string w. Determine if w is beautiful. -----Constraints----- - 1 \leq |w| \leq 100 - w consists of ...
apps_data_4687
There is an empty array. The following N operations will be performed to insert integers into the array. In the i-th operation (1≤i≤N), b_i copies of an integer a_i are inserted into the array. Find the K-th smallest integer in the array after the N operations. For example, the 4-th smallest integer in the array \{1,2,...
apps_data_4688
There are N balls placed in a row. AtCoDeer the deer is painting each of these in one of the K colors of his paint cans. For aesthetic reasons, any two adjacent balls must be painted in different colors. Find the number of the possible ways to paint the balls. -----Constraints----- - 1≦N≦1000 - 2≦K≦1000 - The corre...
apps_data_4689
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be ...
apps_data_4690
There are two rectangles. The lengths of the vertical sides of the first rectangle are A, and the lengths of the horizontal sides of the first rectangle are B. The lengths of the vertical sides of the second rectangle are C, and the lengths of the horizontal sides of the second rectangle are D. Print the area of the re...
apps_data_4691
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is AC, WA,...
apps_data_4692
How many hours do we have until New Year at M o'clock (24-hour notation) on 30th, December? -----Constraints----- - 1≤M≤23 - M is an integer. -----Input----- Input is given from Standard Input in the following format: M -----Output----- If we have x hours until New Year at M o'clock on 30th, December, print x. --...
apps_data_4693
You are given two integers A and B as the input. Output the value of A + B. However, if A + B is 10 or greater, output error instead. -----Constraints----- - A and B are integers. - 1 ≤ A, B ≤ 9 -----Input----- Input is given from Standard Input in the following format: A B -----Output----- If A + B is 10 or great...
apps_data_4694
It is only six months until Christmas, and AtCoDeer the reindeer is now planning his travel to deliver gifts. There are N houses along TopCoDeer street. The i-th house is located at coordinate a_i. He has decided to deliver gifts to all these houses. Find the minimum distance to be traveled when AtCoDeer can start an...
apps_data_4695
Based on some criterion, Snuke divided the integers from 1 through 12 into three groups as shown in the figure below. Given two integers x and y (1 ≤ x < y ≤ 12), determine whether they belong to the same group. -----Constraints----- - x and y are integers. - 1 ≤ x < y ≤ 12 -----Input----- Input is given from Stand...
apps_data_4696
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd. -----Constraints----- - 1 ≤ a,b ≤ 10000 - a and b are integers. -----Input----- Input is given from Standard Input in the following format: a b -----Output----- If the product is odd, print Odd; if it i...
apps_data_4697
Snuke loves puzzles. Today, he is working on a puzzle using S- and c-shaped pieces. In this puzzle, you can combine two c-shaped pieces into one S-shaped piece, as shown in the figure below: Snuke decided to create as many Scc groups as possible by putting together one S-shaped piece and two c-shaped pieces. Find the m...
apps_data_4698
Joisino is about to compete in the final round of a certain programming competition. In this contest, there are N problems, numbered 1 through N. Joisino knows that it takes her T_i seconds to solve problem i(1≦i≦N). Also, there are M kinds of drinks offered to the contestants, numbered 1 through M. If Joisino takes dr...
apps_data_4699
Iroha is very particular about numbers. There are K digits that she dislikes: D_1, D_2, ..., D_K. She is shopping, and now paying at the cashier. Her total is N yen (the currency of Japan), thus she has to hand at least N yen to the cashier (and possibly receive the change). However, as mentioned before, she is very pa...