CodeEff/ECCO huggingface dataset:
Problem Name: The Chopper of the Giant Tree
Problem Description: You are trying to cut down a giant tree in front of you using N types of tools. At first, the tree's durability is D, and your experience level is 0. When you hit the tree once with tool i, the tree's durability decreases by ai, and you gain ei experience points. However, in order to use tool i, you must have at least ri experience points. When the tree's durability becomes 0 or less, the tree falls.
Given information about the tree's durability and tools, create a program to determine the minimum number of times you need to hit the tree to cut it down.
Input
The input consists of multiple datasets. The end of input is indicated by two zeros on a line. Each dataset is given in the following format.
D
N
a
1
e
1
r
1
a
2
e
2
r
2
:
a
N
e
N
r
N
The first line contains an integer
D
, the tree's durability (1 ≤
D
≤ 100), and an integer
N
, the number of tool types (1 ≤
N
≤ 100). The following
N
lines give information about tools 1 to
N
.
a
i
(0 ≤
a
i
≤ 100) and
e
i
(0 ≤
e
i
≤ 100) represent the amount by which tool i reduces the tree's durability and the experience points you can gain by using it once, respectively.
r
i
(0 ≤
r
i
≤ 100) represents the experience points required to use the tool. All of
a
i
,
e
i
, and
r
i
are integers.
There are no more than 50 datasets.
Output
Output the minimum number of times you need to hit the tree to cut it down on one line. If it is impossible to cut down the tree, output
NA
.
Sample Input and Output
Input Sample
15 4
1 1 0
1 2 2
5 10 5
8 1 15
60 4
5 2 0
8 8 2
3 5 0
49 0 18
100 1
1 1 1
0 0
Output Sample
6
4
NA
Problem Name: Floppy Cube
Problem Description: Let's try to solve the Floppy Cube using programming. The Floppy Cube is a three-dimensional puzzle consisting of nine cubes with colored surfaces, as shown in the figure, and aligns the colors of each of the six surfaces by rotating the columns of cubes.
Four types of operations can be performed on the Floppy Cube as shown in the figure below, and in one operation, the three adjacent cubes at the end can be rotated 180 degrees. For ease of understanding, the symbols + (red) on the top, * (green) on the bottom, □ (yellow) on the front right, ● (blue) on the front left, ○ (light blue) on the back right, and ■ (purple) on the back left are attached to the initial state.
Given the initial state of the Floppy Cube, create a program to find the minimum number of operations needed to solve the puzzle.
Input
The input is given in the following format.
N
puzzle
1
puzzle
2
:
puzzle
N
The first line
N
(1 ≤
N
≤ 30) is the number of puzzles to calculate the number of operations for. For each of the following N lines, the initial state of each Floppy Cube
puzzle
i
is given.
puzzle
i
is given in the following format.
p
1
p
2
p
3
p
4
p
5
p
6
p
7
p
8
p
9
p
10
p
11
p
12
p
13
p
14
p
15
p
16
p
17
p
18
p
19
p
20
p
21
p
22
p
23
p
24
p
25
p
26
p
27
p
28
p
29
p
30
The information about each Floppy Cube consists of 30 integers
p
i
(1 ≤
p
i
≤ 6), which represent the colors of the faces of the cube when numbered
i
on each face of the Floppy Cube, as shown in the figure below.
It can be assumed that the puzzle can be solved with a maximum of eight operations.
Output
For each puzzle, output the minimum number of operations on one line.
Sample Input
4
1 1 1 1 1 1 1 1 1 2 2 2 4 4 4 6 6 6 5 5 5 3 3 3 3 3 3 3 3 3
3 3 3 1 1 1 1 1 1 2 2 2 4 4 6 4 6 6 5 5 5 3 3 3 3 3 3 1 1 1
3 3 3 1 1 3 1 1 1 2 2 5 6 4 4 4 6 6 2 5 5 3 3 3 1 3 3 1 1 1
1 3 1 3 1 3 3 1 3 2 2 2 6 4 4 6 6 4 5 5 5 1 3 1 1 3 1 3 1 3
Sample Output
0
1
2
7
Problem Name: Baton Relay Game
Problem Description: Every year, Akabe High School holds a game in which all students participate. First, all students in the school, N in total, line up in a circle on the school grounds. Each student wears a numbered bib from 0 to N-1, as shown in the figure below.
In the game, a baton is used, and initially student with bib number 0 holds the baton. Then, the following procedure is repeated
M
times. First, the student who currently holds the baton declares a suitable positive integer
a
. If
a
is even, the baton is passed to the next student in a clockwise direction, and if
a
is odd, the baton is passed to the next student in a counterclockwise direction, and the student who receives the baton in
a
th place is eliminated. The eliminated student then passes the baton to the next student clockwise and leaves the circle.
After the game is over, the students who remain in the circle are exempt from cleaning for one year. However, in recent years, the increasing number of students has made it difficult to gather all the students in the school. Therefore, you, a member of the programming competition club, have been asked to create a program that will simulate the selection of students who are exempt from cleaning.
Create a program that answers whether a specified student is exempt from cleaning.
Input
The input is given in the following format.
N
M
Q
a
1
a
2
...
a
M
q
1
q
2
...
q
Q
The input consists of three lines. The first line gives the number of students,
N
(10 ≤
N
≤ 200000), the number of repetitions,
M
(5 ≤
M
<
N
), and the number of queries asking whether a student is exempt from cleaning,
Q
(1 ≤
Q
≤ 1000). The second line gives the integer
a
i
(1 ≤
a
i
≤ 100) declared by the student who holds the baton initially in the i-th repetition. The third line gives the bib number
q
i
(0 ≤
q
<
N
) asked as a query.
Output
For each query, print 1 if the student with bib number
q
i
is exempt from cleaning, or 0 otherwise, in the i-th line.
Sample Input
10 5 3
2 6 5 18 3
3 0 5
Sample Output
1
0
1
Problem Name: Frame
Problem Description: Image recognition that extracts useful information from images is one of the important research topics in computer science. It is widely used in digital cameras, driving assistance systems, crime prevention systems, and more.
Thanks to such research, we can use many software and program collections to perform various processes for image analysis. On the other hand, by writing programs to analyze it by yourself, you can learn the mechanism and have a good time. Let's try a unique image recognition here.
The input is an
N
×
N
pixel with an integer value from each pixel as shown in the image below. From this image, extract one frame of a rectangle with 1-pixel thickness.
Create a program that extracts a frame so that the sum of the values of the pixels covered by the frame is maximized and report the sum. However, as shown in the figure below, even if the number of vertical or horizontal pixels is one or two, it is considered as a frame.
Input
The input is given in the following format.
N
p
1,1
p
1,2
...
p
1,N
p
2,1
p
2,2
...
p
2,N
:
p
N,1
p
N,2
...
p
N,N
The first line contains the number of vertical and horizontal pixels
N
(1 ≤
N
≤ 300). Following are
N
lines, which give integer values
p
i,j
(-1000 ≤
p
i,j
≤ 1000) representing the value of the pixel in the
i
-th row and
j
-th column.
Output
Output the sum of the pixel values of the frame that maximizes the sum of the pixel values.
Input Example
5
2 0 0 2 0
0 1 0 2 0
0 0 0 -1 0
0 4 0 3 0 
-1 0 0 1 0
Output Example
12
Input Example
3
0 0 0
0 -1 0
0 0 0
Output Example
0
Problem Name: Frog's Straight Path Home
Problem Description: A frog is trying to get back to its nest. The nest is D centimeters away from the frog, and the frog moves straight towards the nest. The frog can only perform two actions:
Big jump (move forward
L
centimeters)
Small jump (move forward 1 centimeter)
The frog aims to land exactly on the nest without jumping over it.
Write a program to determine the minimum number of jumps the frog needs to make to reach its nest.
Input
The input is given in the following format:
D
L
The input is given in one line, where
D
(1 ≤
D
≤ 10000) is the distance to the nest, and
L
(2 ≤
L
≤ 10000) is the distance the frog can jump with a big jump.
Output
Output the minimum number of jumps the frog needs to make in one line.
Sample Input 1
10 5
Sample Output 1
2
Sample Input 2
7 4
Sample Output 2
4
Problem Name: Sudoku
Problem Description: Sudoku is a logic puzzle game that consists of a grid of 9x9 cells divided into nine 3x3 sub-grids. The objective is to fill each cell with a number from 1 to 9 so that each row, column, and sub-grid contains all the digits from 1 to 9 without repetition.
In this problem, you are given a partially completed sudoku grid and you are asked to determine the number of valid solutions for the grid.
Input
The input consists of a single line containing 9 integers separated by space, representing the partially completed sudoku grid. An integer of -1 indicates an empty cell.
Output
Output the number of valid solutions for the given grid.
Examples
The sample input can be visualized as follows:
7 6 -1 1 -1 9 2 3 4
7  6  _  1  _  9  2  3  4
_  _  _  _  _  _  _  _  _
_  _  _  _  _  _  _  _  _
_  _  _  _  _  _  _  _  _
_  _  _  _  _  _  _  _  _
_  _  _  _  _  _  _  _  _
_  _  _  _  _  _  _  _  _
_  _  _  _  _  _  _  _  _
_  _  _  _  _  _  _  _  _
For this case, there is only one possible valid solution:
7  6  8  1  5  9  2  3  4
4  1  9  2  3  8  7  6  5
5  3  2  4  7  6  1  8  9
6  9  7  8  2  3  4  5  1
8  2  5  9  1  4  3  7  6
3  4  1  6  8  7  5  9  2
2  5  6  7  9  1  8  4  3
1  8  3  5  4  2  9  0  7
9  7  4  3  6  5  0  1  8
Therefore, the output is:
1
In the following example, there is no valid solution for the given grid:
Sample Input 2
7 6 5 1 8 9 2 3 4
Sample Output 2
0
In the next example, there are several valid solutions:
Sample Input 3
-1 -1 -1 -1 -1 -1 8 4 6
Sample Output 3
12
In the last example, all cells are empty, so there are 168 possible valid solutions:
Sample Input 4
-1 -1 -1 -1 -1 -1 -1 -1 -1
Sample Output 4
168
Problem Name: Circular Sugoroku
Problem Description: Yuki made a sugoroku (Japanese board game similar to Snakes and Ladders) for the children's event so that everyone can play together. In this sugoroku, the squares are arranged in a circle, and each square has an integer greater than or equal to 1 written on it.
The player chooses a square as the starting point and places their piece there. Then, they move their piece clockwise according to the number written on the square. They repeat this process, moving clockwise according to the number written on the square they land on, until they reach the starting point again, at which point they win.
In reality, there may be cases where it is impossible to win, depending on which square the player chooses as their starting point. Yuki wants to count the number of squares from which it is possible to win.
Write a program that takes the information of a sugoroku as input and reports the number of squares from which it is possible to win.
Input
The input is given in the following format.
N
a
1
a
2
...
a
N
The first line contains the number of squares
N
(1 ≤
N
≤ 100000) in the sugoroku. The second line gives the clockwise order of integers written on each square
a
i
(1 ≤
a
i
≤ 10
9
).
Output
Print the number of squares from which it is possible to win.
Sample Input 1
3
1 1 1
Sample Output 1
3
Sample Input 2
3
1 1 2
Sample Output 2
2
Sample Input 3
8
2 3 7 3 3 3 4 4
Sample Output 3
6
Problem Name: Shopping
Problem Description: You are now in a bookshop with your friend Alice to buy a book, "The Winning Strategy for the Programming Koshien Contest,” just released today. As you definitely want to buy it, you are planning to borrow some money from Alice in case the amount you have falls short of the price. If the amount you receive from Alice still fails to meet the price, you have to abandon buying the book this time.
Write a program to calculate the minimum amount of money you need to borrow from Alice given the following three items of data: the money you and Alice have now and the price of the book.
Input
The input is given in the following format.
m
f
b
A line containing the three amounts of money is given: the amount you have with you now
m
(0 ≤
m
≤ 10000), the money Alice has now
f
(0 ≤
f
≤ 10000) and the price of the book
b
(100 ≤
b
≤ 20000).
Output
Output a line suggesting the minimum amount of money you need to borrow from Alice. Output "NA" if all the money Alice has with him now is not a sufficient amount for you to buy the book.
Sample Input 1
1000 3000 3000
Sample Output 1
2000
Sample Input 2
5000 3000 4500
Sample Output 2
0
Sample Input 3
500 1000 2000
Sample Output 3
NA
Problem Name: Trampoline
Problem Description: A plurality of trampolines are arranged in a line at 10 m intervals. Each trampoline has its own maximum horizontal distance within which the jumper can jump safely. Starting from the left-most trampoline, the jumper jumps to another trampoline within the allowed jumping range. The jumper wants to repeat jumping until he/she reaches the right-most trampoline, and then tries to return to the left-most trampoline only through jumping. Can the jumper complete the roundtrip without a single stepping-down from a trampoline?
Write a program to report if the jumper can complete the journey using the list of maximum horizontal reaches of these trampolines. Assume that the trampolines are points without spatial extent.
Input
The input is given in the following format.
N
d_1
d_2
:
d_N
The first line provides the number of trampolines
N
(2 ≤
N
≤ 3 × 10
5
). Each of the subsequent
N
lines gives the maximum allowable jumping distance in integer meters for the
i
-th trampoline
d_i
(1 ≤
d_i
≤ 10
6
).
Output
Output "
yes
" if the jumper can complete the roundtrip, or "
no
" if he/she cannot.
Sample Input 1
4
20
5
10
1
Sample Output 1
no
Sample Input 2
3
10
5
10
Sample Output 2
no
Sample Input 3
4
20
30
1
20
Sample Output 3
yes
Problem Name:
Problem Description: Two players, A and B, play a game using cards with numbers from 0 to 9. First, each of the two players is given n cards, which are placed face down in a row. Then, each player turns over one card from the left and the player with the higher number takes both cards. The sum of the numbers on the two cards taken becomes the player's score. If the two cards have the same number, it is a tie and each player takes one card.
For example, consider the case where A and B have the cards below in input examples 1 to 3. The input file consists of n + 1 lines, where the first line contains the number of cards n given to each player, and the i + 1 line (i = 1, 2, ..., n) contains the numbers of A's i-th card and B's i-th card in that order, separated by a space. The left column of the input file represents the order of A's cards, and the right column represents the order of B's cards. After the game ends, A's and B's scores are shown in the corresponding output examples.
Write a program that outputs A's score and B's score, separated by a space, on one line when the game corresponding to the input file is over. n ≤ 10000.
Input Example 1
Input Example 2
Input Example 3
3
3
3
9 1
9 1
9 1
5 4
5 4
5 5
0 8
1 0
1 8
Output Example 1
Output Example 2
Output Example 3
19 8
20 0
15 14
Input
The input consists of multiple datasets. The input ends when n is 0. The number of datasets does not exceed 5.
Output
For each dataset, output A's score and B's score on one line.
Input Example
3
9 1
5 4
0 8
3
9 1
5 4
1 0
3
9 1
5 5
1 8
0
Output Example
19 8
20 0
15 14
Be sure to insert a line break after each dataset's output for B's score.
The above problem statement and test data used by the automatic judge are problem statements and scoring test data created and published by the Information Olympiad Japan Committee.
Problem Name:
Problem Description: Create a program to convert data based on the given conversion table. The characters used in the data are either letters or numbers, and letters are case-sensitive. There is no regularity in the order of characters appearing in the conversion table.
The conversion table has two characters (not strings) separated by a space. If the character before a line in the conversion table appears in the data, output the character after it each time. Conversion occurs only once, and even if the converted character becomes the target for conversion again, it will not be converted. Characters that do not appear in the conversion table are not converted and are output as is.
The input file contains the conversion table (the first n + 1 lines) followed by the data to be converted (from the n + 2 line). The first line contains the number of lines in the conversion table, n, followed by n lines with two characters separated by a space. Then, the number of lines of data to be converted, m, is written on line n + 2, followed by m lines of single characters. Set m to be less than or equal to 10
5
. The output should be one line without any spaces or line breaks as shown in the output example.
Input Example
3
A a
0 5
5 4
10
A
B
C
0
1
4
5
a
b
A
Output Example
aBC5144aba
Input
The input consists of multiple datasets. When n is 0, the input ends. The number of datasets does not exceed 5.
Output
For each dataset, output the converted string on one line.
Input Example
3	
A a	
0 5	
5 4	
10	
A	
B	
C	
0	
1	
4	
5	
a	
b	
A
3	
A a	
0 5	
5 4	
10	
A	
B	
C	
0	
1	
4	
5	
a	
b	
A
0
Output Example
aBC5144aba
aBC5144aba
Be sure to include a line break after the output for each dataset.
The above problem statement and test data used by the automatic judge are problem statements and test data created and published by the
International Olympiad in Informatics Japan Committee
.
Problem Description: The dice is placed as shown in the following figure.
In this problem, we assume that the die is such that when 1 is on the top and 2 is on the south side, 3 is on the east side. Since the sum of the opposite faces of the die is always 7, the invisible faces are 5 on the north side, 4 on the west side, and 6 on the bottom.

Starting from this initial configuration state, move the dice according to the instructions. However, the instructions are a series of six operations, which are as follows:
The North, East, South, and West operations rotate the die 90 degrees in the indicated direction. The two operations, Right and Left, rotate the die 90 degrees horizontally with the upper and lower faces remaining the same. (Be careful about the direction of rotation.)

Assume that the value on the top face of the initial configuration is 1, and after each operation, add the number of dots on the face that is now on the top, until all operations are completed according to the instructions. Write a program to output the total value obtained after executing all of the instructions.

The first line of the input file contains the total number of instructions n, and each of the following n lines contains one of the following instructions: "North, East, South, West, Right, Left". However, n ≦ 10000.

For example, the following input and output are expected:
Input Example 1
Input Example 2
5
North
North
East
South
West
8
West
North
Left
South
Right
North
Left
East
0
8
North
West
North
North
East
Left
South
South
West
Right
Left
East
West
South
East
North
0
Output Example 1
Output Example 2
21
34
27
26
The input consists of multiple datasets, and the input ends when n is 0. There are no more than 5 datasets.
Problem Description: When a string consisting of digits from 0 to 9 is given, a new string is created by following the rules below. Read the given string from the left end one by one, and if the same digit a appears r times, write the number r and the digit a in this order without separating them by a space. The operation counts all the way up to the end of the given string, no matter how many times it is written. The second and subsequent operations perform the same operation on the string written by the previous operation. For example, if the string "122244" is given, 1, 3, and 2 of 1, 2, and 4 are taken from the left, respectively. The resulting string after one operation is "113224", and the resulting string after "44444444444" (11 of 4) is "114".

Create a program that outputs a string that has undergone the above operation n times for a given string of up to 100 characters. However, n ≤ 20.

The input data consists of two lines, the number of operations n in the first line, and the initial string in the second line. Output a string that has undergone the specified number of operations, followed by a line break.

The input example is as follows:
```
5
11
```
The output example is as follows:
```
13112221
```
Problem Name:
Problem Description: Create a program that calculates the area and perimeter of a plane covered by several rectangular sheets. However, when considering the plane as a coordinate plane, the arrangement of the sheets satisfies the following conditions (1) and (2).
(1) The
x
and
y
coordinates of the four vertices of each rectangle are all integers between 0 and 10000, and each side of the rectangle is parallel to the
x
or
y
axis.
(2) There are at most 10000 sheets of paper.
The number of rectangles
n
and an integer
r
indicating the type of problem are written separated by a space on the first line of the input data. From the second line onwards, the coordinates of the lower left vertex (
x
1
,
y
1
) and the upper right vertex (
x
2
,
y
2
) of each sheet are written in order separated by spaces.
If
r
=1, output the area on the first line, and if
r
=2, output the area on the first line and the perimeter on the second line. In either case, be sure to include a line break at the end.
In addition, in 40% of the test data, the coordinates of the vertices of the rectangles are integers between 0 and 100, and half of them are problems that only require the area. Furthermore, half of the entire test data is a problem that only requires the area.
Sample Input 1
Sample Input 2
Sample Input 3
Sample Input 4
5 1
5 2
2 2
3 2
0 0 3 2
0 0 3 2
0 0 8 9
2 2 8 8
1 1 2 5
1 1 2 5
0 0 9 8
3 0 4 9
0 4 6 5
0 4 6 5
5 0 7 9
3 3 5 6
3 3 5 6
5 0 7 6
5 0 7 6
Sample Output 1
Sample Output 2
Sample Output 3
Sample Output 4
29
29
80
45
Problem Name: Score
Problem
Problem Description: Two students, A and B, from JOI High School took exams in four subjects: Information, Mathematics, Science, and English. Write a program that takes A and B's scores in these four subjects and outputs the larger of their total scores, S and T, respectively. However, if the scores are tied, output S (= T).
Input
The input consists of two lines.
The first line contains four integers separated by a single space, representing A's scores in Information, Mathematics, Science, and English, respectively.
The second line contains four integers separated by a single space, representing B's scores in Information, Mathematics, Science, and English, respectively.
All scores are out of 100, and there are no negative scores.
Output
The output consists of one integer, the larger of A's total score S and B's total score T.
Examples
Example 1
Input:
100 80 70 60
80 70 80 90
Output:
320
Example 2
Input:
100 80 70 60
80 70 60 100
Output:
310
The problem statement and test data used in the automatic judging system are provided by the
Japanese Olympiad in Informatics Committee
.