CodeEff/ECCO huggingface dataset:
Problem Name: Vision Test
Problem Description: Create a program that receives as input the results of a vision test and outputs, for each eye separately, the number of people classified into each category according to the following table.
Category
Vision
A
1.1 or higher
B
0.6 or higher, less than 1.1
C
0.2 or higher, less than 0.6
D
less than 0.2
Input
The input is given in the following format:
l
1
r
1
l
2
r
2
l
3
r
3
:
:
The
i
-th line contains two space-separated real numbers
l
i
and
r
i
, which represent the vision of the
i
-th person's left and right eyes, respectively. The vision is given to the nearest 0.1, and is between 0.1 and 2.0 (inclusive).
There will be no more than 40 lines in the input.
Output
Output the results in the following format:
Line 1: The number of people with category A vision in the left eye, followed by the number of people with category A vision in the right eye.
Line 2: The number of people with category B vision in the left eye, followed by the number of people with category B vision in the right eye.
Line 3: The number of people with category C vision in the left eye, followed by the number of people with category C vision in the right eye.
Line 4: The number of people with category D vision in the left eye, followed by the number of people with category D vision in the right eye.
Sample Input
1.0 1.2
0.8 1.5
1.2 0.7
2.0 2.0
Output for the Sample Input
2 3
2 1
0 0
0 0
Problem Name: Card Combination
Problem Description: Let's play a game using a bag containing several cards with integers written on them. In each game, the participants first declare a number n they like. Then, they take out a suitable number of cards from the bag at once and if the sum of the numbers written on those cards is equal to n, they get a luxurious prize. Note that after each game, the cards are returned to the bag.
Create a program that takes as input the information of the
m
types of cards in the bag and the numbers declared by the participants for the
g
games, and outputs the number of combinations of cards that can get a luxurious prize for each game.
Input
The input is given in the following format for each dataset. Multiple datasets are given as input. The input ends with a single line containing a zero.
m
a
1
b
1
a
2
b
2
:
a
m
b
m
g
n
1
n
2
:
n
g
The first line contains the number of types of cards
m
(1 ≤
m
≤ 7), followed by
m
lines, each containing the integer
a
i
(1 ≤
a
i
≤ 100) written on the
i
-th type of card and the number of cards
b
i
(1 ≤
b
i
≤ 10), separated by a space.
The next line contains the number of games
g
(1 ≤
g
≤ 10), followed by
g
lines, each containing the integer
n
i
(1 ≤
n
i
≤ 1,000) declared in the
i
-th game.
The number of datasets does not exceed 100.
Output
For each input dataset, output the number of combinations of cards that can get a luxurious prize for each game on a separate line.
Sample Input
5
1 10
5 3
10 3
25 2
50 2
4
120
500
100
168
7
1 10
3 10
5 10
10 10
25 10
50 10
100 10
3
452
574
787
0
Output for the Sample Input
16
0
12
7
9789
13658
17466
Problem Name: Matryoshka Dolls
Problem Description: A matryoshka doll is a wooden doll carved in the shape of a woman, and is a representative folk art of Russia. The matryoshka doll is a nested structure, with smaller dolls inside larger dolls, and is composed of multiple dolls of different sizes. In order to create such a nested structure, the body of each doll is a cylindrical structure that can be divided into upper and lower parts. Because matryoshka dolls are handmade by craftsmen, each doll becomes a very valuable item that is unique in the world.
Ichiro and Jiro, who are brothers, love to play with matryoshka dolls and each of them had one set of matryoshka dolls. Ichiro's matryoshka doll is composed of
n
dolls and Jiro's matryoshka doll is composed of
m
dolls.
One day, curious Ichiro tried to combine the dolls in these two sets of matryoshka dolls to create a new matryoshka doll that contains more dolls. That is, he attempted to create one set of
k
dolls using
n + m
dolls. If he could make
k
larger than the larger of
n
and
m
, his goal would be achieved.
The two brothers are good friends and thought about how to combine the dolls to maximize the value of
k
. However, even for these young boys, this problem was too difficult, so the older you decided to create a program to help them.
Create a program that takes as input the information about the dolls in Ichiro and Jiro's matryoshka dolls and outputs the number of dolls that the new matryoshka doll will contain. No two dolls have the same size. Also, if a doll is regarded as a cylinder with a height of
h
and a radius of
r
, the dolls that can be contained in the doll with a height of
h
and a radius of
r
are the dolls with a height of
x
and a radius of
y
that satisfy
x < h
and
y < r
.
Input
The input consists of a sequence of multiple datasets. The end of the input is indicated by a line containing a single zero. Each dataset is given in the following format:
n
h
1
r
1
h
2
r
2
:
h
n
r
n
m
h
1
r
1
h
2
r
2
:
h
m
r
m
The first line contains the number of dolls in Ichiro's matryoshka doll,
n
(
n
≤ 100), followed by
n
lines that give the height
h
i
and radius
r
i
(
h
i
,
r
i
< 1000) of the
i
-th doll of Ichiro's matryoshka doll.
Following this are
m
lines that give the height
h
i
and radius
r
i
(
h
i
,
r
i
< 1000) of the
i
-th doll of Jiro's matryoshka doll.
There are no more than 20 datasets.
Output
For each input dataset, output the number of dolls that the new matryoshka doll will contain.
Sample Input
6
1 1
4 3
6 5
8 6
10 10
14 14
5
2 2
5 4
6 6
9 8
15 10
4
1 1
4 3
6 5
8 6
3
2 2
5 4
6 6
4
1 1
4 3
6 5
8 6
4
10 10
12 11
18 15
24 20
0
Output for the Sample Input
9
6
8
Problem Name: Collatz Conjecture
Problem Description: For a positive integer n:
If
n
is even, divide it by 2.
If
n
is odd, multiply it by 3 and add 1.
By repeating this process, the result will eventually become 1. It is known as the "Collatz conjecture" that this process will always lead to 1 for any positive integer
n
. This problem, also known as the "Kakutani problem", is an unsolved problem in Japan. Although it is known that there is no counterexample for very large numbers less than 3 × 2
53
= 27,021,597,764,222,976, it has not been mathematically proven.
Write a program that takes a positive integer
n
as input and outputs the number of times the operation is repeated until the result becomes 1. The input integer
n
is greater than or equal to 1, and the value during the calculation will be less than or equal to 1,000,000. For example, if the input is 3, the operation sequence is:
3 → 10 → 5 → 16 → 8 → 4 → 2 → 1
Therefore, output 7, which is the number of operations (the number of arrows above).
Input
The input consists of multiple datasets. The end of input is indicated by a single zero line.
For each dataset, a single integer
n
(
n
≤ 1,000,000) is given on one line.
There are no more than 50 datasets.
Output
For each dataset, output the number of operations in one line.
Sample Input
3
10
0
Output for the Sample Input
7
6
Problem Name: Sport Meet
Problem Description: The autumn sports festival will be held. The events are the 4 items of running, ball carrying, obstacle course, and relay. There are n teams participating, and the team with the smallest total time for these 4 events will be awarded the "Championship", the team with the second smallest time will be awarded the "Runner-up", and the team with the second lowest time will be awarded the "Booby Prize".
Create a program that outputs the teams that won the "Championship", "Runner-up", and "Booby Prize" based on the performance of each team. Each team is assigned a team number from 1 to
n
.
Input
A sequence of multiple data sets is given as input. The end of input is indicated by a single line of zero.
Each dataset is given in the following format:
n
record
1
record
2
:
record
n
The first line contains the number of teams
n
(4 ≤
n
≤ 100000), followed by the information for each team from 1 to
n
. The information for each team is given in the following format:
id
m1
s1
m2
s2
m3
s3
m4
s4
id
(1 ≤
id
≤
n
) is the team number,
m1
and
s1
are the minutes and seconds for running,
m2
and
s2
are the minutes and seconds for ball carrying,
m3
and
s3
are the minutes and seconds for the obstacle course, and
m4
and
s4
are the minutes and seconds for the relay. The minutes and seconds are both integers between 0 and 59. It is assumed that there is no input where the total time is the same for multiple teams.
Output
For each dataset, output the team numbers in the following format:
1st line: Team number of the champion
2nd line: Team number of the runner-up
3rd line: Team number of the booby prize
Sample Input
8
34001 3 20 3 8 6 27 2 25
20941 3 5 2 41 7 19 2 42
90585 4 8 3 12 6 46 2 34
92201 3 28 2 47 6 37 2 58
10001 3 50 2 42 7 12 2 54
63812 4 11 3 11 6 53 2 22
54092 3 33 2 54 6 18 2 19
25012 3 44 2 58 6 45 2 46
4
1 3 23 1 23 1 34 4 44
2 5 12 2 12 3 41 2 29
3 5 24 1 24 2 0 3 35
4 4 49 2 22 4 41 4 23
0
Output for the Sample Input
54092
34001
10001
1
3
2
Problem Name: Hamming Numbers
Problem Description: A number obtained by multiplying 1 with 2, 3, or 5, zero or more times, is called a Hamming number. For example:
1
1 × 2 × 2 = 4
1 × 2 × 2 × 3 × 5 × 5 = 300
are Hamming numbers, but 11, 13, 14, etc. are not.
Hamming numbers are all divisible by powers of 60 (for example, 54 is divisible by 60
3
= 21600), so they have long been known as convenient numbers for calculations in sexagesimal (base-60) notation, such as timekeeping. The Pythagorean tuning system, used for tuning musical instruments, uses a sequence of Hamming numbers: 24, 27, 30, 32, 36, 40, 45, and 48, which correspond to the ratios between the frequencies of different notes in the system.
Write a program that takes two integers,
m
and
n
(1 ≤
m
,
n
≤ 1000000,
m
≤
n
), as input and outputs the number of Hamming numbers between
m
and
n
, inclusive.
Input
The input consists of multiple datasets. The input ends with a line containing a single zero.
Each dataset consists of two integers,
m
and
n
(1 ≤
m
,
n
≤ 1000000,
m
≤
n
), separated by a space, on a single line.
There are at most 20 datasets.
Output
For each dataset, output the number of Hamming numbers between
m
and
n
, inclusive, on a single line.
Sample Input
3 8
1 27
1 86
0
Output for the Sample Input
5
17
31
Problem Name: Picking Up Marbles
Problem Description: Ichiro and Jiro, two brothers, often play "picking up marbles" game at their home. In this game, they take turns taking multiple marbles piled up in one place. The winner is the one who makes the other player take the last marble. They always use 32 marbles and start the game from Ichiro, the older brother.
They have fought against each other many times, but Jiro can't win against his older brother Ichiro. That's because Ichiro knows the winning strategy of this game. When the number of remaining marbles is
n
, Ichiro always takes (
n
- 1) % 5 marbles. Here,
x
%
y
means the remainder of
x
divided by
y
.
On the other hand, Jiro decides the number of marbles he will take each turn at the beginning of the game, regardless of the number of remaining marbles. For example, if Jiro decided on the sequence {3, 1, 4, 2}, the number of marbles he takes will be 3 -> 1 -> 4 -> 2 -> 3 -> 1 -> 4 -> ..., depending on the sequence he decided. If the number of marbles he decided to take is larger than the number of remaining marbles, he will take all the remaining marbles.
Jiro's mother, who is worried about Jiro's stubbornness, who doesn't change his way of playing even after losing many times, decided to write a program to simulate the game to show that Jiro can't win against Ichiro no matter what sequence he chooses.
Write a program that takes the sequence
a
that Jiro has thought of as input and outputs the number of marbles left after Ichiro and Jiro have taken turns picking up marbles.
Input
The input consists of multiple datasets. The end of the input is indicated by a line with a single zero.
Each dataset is given in the following format.
n
a
1
a
2
...
a
n
The first line contains the length of Jiro's sequence,
n
(1 ≤
n
≤ 25), and the second line contains the
i
-th element
a
i
(1 ≤
a
i
≤ 4) of the sequence, separated by a space. The input is all integers.
There are no more than 100 datasets.
Output
For each dataset, output the number of marbles remaining immediately after each turn of the game.
Sample Input
4
3 1 4 2
3
4 3 2
0
Output for the Sample Input
31
28
26
25
21
17
16
14
11
8
6
5
1
0
31
27
26
23
21
19
16
12
11
8
6
4
1
0
Problem Name: Lottery Ticket
Problem Description: The king of a certain country loves prime numbers and gambling. The currency unit in this country is called a Prime. As of November 1st, 2007, the cross-yen rate for Prime was exactly 9973, which is a prime number, so the king was delighted. In this country, a subprime, which is one hundred and first of a prime, is used as a subsidiary currency.
The government of this country established a lottery promotion agency with the aim of satisfying national financial stability, citizen's entertainment, and the king's hobby at the same time, and decided to start a lottery business. The king, who loves prime numbers, is happy just to talk about prime numbers and wants to give prizes. So the promotion agency came up with the following lottery:
The lottery has a series of numbers from 0 to
MP
.
MP
is the largest prime number known in this country, and is announced in the official gazette on the first day of every month. At the same time, all prime numbers up to and including
MP
are also announced. Even if a larger prime number is discovered, all public institutions, including the lottery promotion agency, treat the
MP
announced on that day as the largest prime number for that month. On November 1st, 2007,
MP
= 999983 (the largest prime number less than or equal to 1000000) was announced.
The selling price of the lottery is one subprime.
In the lottery drawing, several pairs (
p
,
m
) of winning lottery numbers
p
and numbers
m
for calculating the prize are selected.
p
and
m
are integers between 0 and
MP
.
Assuming that there are
X
prime numbers between
p
-
m
and
p
+
m
among the prime numbers known in this country, the prize of the lottery result (
p
,
m
) is
X
Prime.
Even if
X
is 0, the prize will be paid to the winner of the lottery number
p
.
One Prime of the prize is paid from the sales of the lottery, and
X
- 1 Prime is paid from the king's court expenses (paid by the king). If
X
= 0, 1 Prime from the sales of the lottery will be carried over to the court expenses. (Paid to the king)
A single number
p
may become multiple winning lottery numbers. In this case, the total amount of the prize calculated from each lottery result (
p
,
m
) will be paid to the winner.
In this lottery, people who buy a winning ticket will look for prime numbers related to the lottery results and count the number of them. Therefore, the prime numbers often become a topic among the citizens, and the king is very pleased. Since the promotion agency will bear one Prime per winning ticket and the selling price is one subprime, the number of winning tickets
n
should be less than or equal to 1 for every 101 tickets sold (i.e.,
n
≤ (number of tickets sold)/101) so that it will not be in the red.
The problem is the amount of money spent from the court expenses. Your task is to create a program that inputs the lottery results and outputs the amount of prize that the lottery promotion agency claims to the king in November 2007. However, it is assumed that the amount of money claimed is never negative.
Note:
The definition of prime numbers in this country is
Problem Name: Kannon-Do
Problem Description: There is a Kannon-Do (a temple dedicated to the goddess of mercy, Kannon) on the mountain behind Ichiro's house. There are 30 steps from the base to the Kannon-Do, and Ichiro goes to the Kannon-Do to play almost every day. Ichiro can climb up to three steps with one step. While playing, Ichiro noticed that there are many ways to climb the steps (various numbers of steps to skip).
Therefore, he decided to climb up the steps in 10 different ways every day and try all the ways. However, as a mathematician, you should know that this will take Ichiro's entire life.
To convince Ichiro that his plan is impossible, write a program that takes the number of steps
n
as input and outputs the number of years it would take for Ichiro to climb all the steps in 10 different ways per day. Assume that a year has 365 days. If at least one day is necessary, it is counted as one year. If there are 365 days, it is one year, and if there are 366 days, it is two years.
Input
The input is a sequence of multiple datasets. The end of the input is indicated by a single zero line.
For each dataset, a single integer
n
(1 ≤
n
≤ 30) representing the number of steps is given on a line.
There are no more than 30 datasets.
Output
For each dataset, output the number of years (an integer) required for Ichiro to climb all the steps in all 10 ways on a single line.
Sample Input
1
10
20
25
0
Output for the Sample Input
1
1
34
701
Problem Name: Lunch
Problem Description: To make a bento box for lunch, I bought some food at the store. At the store, I could only get a long, narrow bag to put the food in, so I need to stack all the food vertically and put it in the bag. I want to pack as much weight as possible at the bottom so that the bag does not tip over, but some of the food is soft and will be crushed if I put heavy things on top.
Therefore, given the information about the food as input, please create a program that outputs a stacking method that prevents all the food from being crushed and has the lowest possible center of gravity. For each piece of food, the name
f
, weight
w
, and the weight it can withstand on top,
s
, are specified. "All of the food does not collapse" means that when
n
pieces of food (
f
1
,
f
2
, ...,
f
n
) are stacked from the bottom, for all
f
,
s
f
i
≥ w
f
i+1
+ w
f
i+2
+
...
+ w
f
n
must hold. In addition, the center of gravity of the entire stack is defined as
G = (1 × w
f
1
+ 2 × w
f
2
+
...
+ n × w
f
n
)
/
(w
f
1
+ w
f
2
+
...
+w
f
n
)
However, assume that there is exactly one solution.
Input
The input consists of a sequence of multiple data sets. The end of the input is indicated by a single zero on a line. Each data set is given in the following format:
n
f
1
w
1
s
1
f
2
w
2
s
2
:
f
n
w
n
s
n
The first line contains the number of food items,
n
(1 ≤
n
≤ 10), and the following
n
lines contain the name
f
i
(a half-width English string of up to 20 characters), the weight
w
i
(1 ≤
w
i
≤ 1000) and the weight it can withstand
s
i
(1 ≤
s
i
≤ 1000), separated by a space.
There are no more than 20 data sets.
Output
For each data set, output the names of the food items in the order they are stacked from the bottom in the following format:
1st line: Name of the food at the bottom (a half-width English string)
2nd line: Name of the food second from the bottom
:
n
-th line: Name of the topmost food
Sample Input
4
sandwich 80 120
apple 50 200
cheese 20 40
cake 100 100
9
onigiri 80 300
onigiri 80 300
anpan 70 280
mikan 50 80
kanzume 100 500
chocolate 50 350
cookie 30 80
purin 40 400
cracker 40 160
0
Output for the Sample Input
apple
cake
sandwich
cheese
kanzume
purin
chocolate
onigiri
onigiri
anpan
mikan
cracker
cookie
Problem Name: Haunted House
Problem Description: Every year, Aizu Gakuin High School holds a school festival. The most popular event is the haunted house. The reason for its popularity is that not just one or two, but nine classes run the haunted house. Each class comes up with its own unique and creative ideas, making each haunted house different. As a result, in recent years, many visitors have come from neighboring areas to attend the festival.
Therefore, the school festival executive committee has decided to unify the admission fee for the haunted house within the school, as shown in the table below, and to calculate the total number of visitors and income for each class based on this fee.
Admission fee table (admission fee per person):
Morning   Afternoon
200 yen   300 yen
Create a program that takes the number of morning and afternoon visitors for each class as input and generates a table showing the total number of visitors and income for each class.
Input
The input is given in the following format:
name
1
a
1
b
1
name
2
a
2
b
2
:
name
9
a
9
b
9
The input consists of nine lines, and the
i
-th line contains the class name
name
i
(a string of 1 to 15 alphanumeric characters) and the number of morning and afternoon visitors
a
i
(0 ≤
a
i
≤ 400) and
b
i
(0 ≤
b
i
≤ 400) for the i-th class.
Output
For each class, output its name, total number of visitors, and total income, separated by a space, on a separate line.
Sample Input
1a 132 243
1c 324 183
1f 93 199
2b 372 163
2c 229 293
2e 391 206
3a 118 168
3b 263 293
3d 281 102
Output for the Sample Input
1a 375 99300
1c 507 119700
1f 292 78300
2b 535 123300
2c 522 133700
2e 597 140000
3a 286 74000
3b 556 140500
3d 383 86800
Problem Name: Badminton
Problem Description: A-kun, B-san, and C-kun decided to play badminton after a long time. A-kun and B-san played singles, and C-kun was the referee. The rules they agreed upon were as follows:
Three games will be played.
The winner of each game is the first to score 11 points.
The first serve of the first game is done by A-kun. The serve for the next point is done by the player who scored the previous point.
The winner of the previous game serves first in the next game.
If the score is tied at 10-10, the winner must win by two points.
After all the games were finished, they realized that C-kun forgot to keep track of the scores. However, he did keep track of who served each point. Write a program that calculates the scores based on the serve order. Assume that the sum of the number of serves by both players is less than or equal to 100, and the serve order is represented by the characters "A" or "B".
Input
The input consists of multiple datasets. The end of the input is indicated by a line containing a single zero. Each dataset is in the following format:
record
1
record
2
record
3
The i-th line contains a string representing the serve order for the i-th game.
There will be no more than 20 datasets.
Output
For each dataset, output the scores of A-kun and B-san for each game, separated by a single space, on a separate line.
Sample Input
ABAABBBAABABAAABBAA
AABBBABBABBAAABABABAAB
BABAABAABABABBAAAB
AABABAAABBAABBBABAA
AAAAAAAAAAA
ABBBBBBBBBB
0
Output for the Sample Input
11 8
10 12
11 7
11 8
11 0
0 11