CodeEff/ECCO huggingface dataset:
Problem Name: Water Pipe Construction
Problem Description: In the year 21XX, humanity finally began a plan to migrate to Mars. You, who were selected as the first wave of immigrants to Mars, were assigned to the Administrative Center of Mars and are dealing with various problems that occur on Mars. The biggest problem at the moment for the administrative center is to secure a self-sufficient supply and demand cycle. Since it takes several months for aid supplies from the moon to arrive, it is essential to solve the needs on Mars within Mars. In addition, until a circulation system is established, resources must be conserved as much as possible.
The Administrative Center has started mining ice in the polar regions. The ultimate goal is to melt it with solar energy and supply it to each base as water. In the first stage, they decided to lay water pipes from bases with water sources to the two main bases. Also, at present, only some bases and roads connecting them have been developed, and laying water pipes in undeveloped areas requires a significant cost and fuel along the roads, so they decided to lay water pipes along the roads. Furthermore, due to technological constraints, their water pipes always flow in only one direction.
Your job is to create a program that minimizes the cost of laying water pipes under these conditions.
Input
The input consists of multiple datasets.
The first line of each dataset consists of five integers in order: the number of bases
n
on Mars (3 <=
n
<= 100), the number of roads
m
(2 <=
m
<= 1000) connecting the bases, the number
s
of the base that serves as the water source, and the numbers
g
1
and
g
2
of the two main bases that are the destinations of the water pipes. The base numbers are represented by integers from 1 to
n
.
s
,
g
1
, and
g
2
are distinct.
The following
m
lines provide information on roads where water pipes can be laid. Each line represents information on a road between two bases, consisting of three integers
b
1
,
b
2
, and
c
(1 <=
c
<= 1000). Here,
b
1
and
b
2
represent the base numbers at the start and end of the road, respectively, and they are distinct.
c
is the cost required to lay a water pipe from base
b
1
to base
b
2
.
For all datasets, it can be assumed that there is always a path to supply water from the source to the destination. Moreover, since there is at most one road between any two bases, cost information is given at most once for each direction.
The end of the input is indicated by a line containing five zeros separated by spaces.
Output
For each dataset, output the minimum cost to lay water pipes on one line.
Sample Input
4 5 1 3 4
1 2 5
2 3 5
2 4 5
1 3 8
1 4 8
0 0 0 0 0
Output for the Sample Input
15
Problem Name: Problem F: Gather the Maps!
Problem Description: Long ago, it was said that a legendary treasure left by the Yao clan is sleeping somewhere in Hachioji. The map of the treasure that is supposed to indicate its location is divided into several pieces and is inherited by n descendants of Yao clan.
Now, the descendants of Yao clan were trying to cooperate to obtain the treasure. However, it was impossible to find the treasure with only a part of the map that indicates its location. Therefore, all descendants of Yao clan decided to gather the maps in one place.
    However, they cannot gather because their schedules do not match even if they try to implement it. However, information about this treasure has been a valuable secret that has been passed down among the clan. Considering the risk of leakage, it is impossible to exchange maps using public communication methods.
Therefore, they decided to repeatedly hand over the map to one descendant by directly meeting each other.
    Note that there is no limit to the number of people one person can meet per day, but it is necessary for each other to have free schedules.
Your task is to write a program that determines the minimum number of days required to collect the map from each descendant's list of available schedule dates.
By the way, the unity of the Yao clan is very strong. If a descendant who finally got the entire map steals the treasure from other descendants, they will be punished by the clan. The punishment is very terrible, so it is practically impossible for that descendant to steal the treasure.
Input
The input consists of multiple datasets.
Each dataset consists of several lines. The first line describes an integer
n
(1 <
n
<= 50) representing the number of people who have fragments of the map. The following
n
lines describe the schedule of each descendant.
    The
i
-th line represents the schedule of the
i
-th descendant, and several integers are written separated by a single space.
    The first integer
f
i
(0 <=
f
i
<= 30) represents the number of days the descendant's schedule is available. The next
f
i
integers represent the dates when the schedule is free. These dates are all different from each other and are all between 1 and 30.
The last line of the input contains only 0.
Output
For each dataset, output one integer per line. If it is possible to collect the map within 30 days, output the minimum number of days required to collect the map. If it is impossible to collect, output -1.
Note:
The "minimum number of days required to collect the map" mentioned above means the date when all the maps will be collected as soon as possible, starting from one day.
Sample Input
4
1 1
2 2 3
2 1 2
3 3 4 5
0
Output for the Sample Input
3
Osaki
Problem Description: English text is not available in this practice contest.
The Yamanote Line is a circular railway line laid within Tokyo's 23 wards. The total length of the route is 34.5 km and it takes about an hour to complete one loop. There are a total of 29 stations. The line color is uguisu (olive green). The peak congestion rate exceeds 200%, making it one of the most crowded railway lines in Japan. In the most crowded time zone, trains run every three minutes, and people who come to Tokyo for the first time are surprised by the sight.
Tekko-san is a pure railway enthusiast who loves the Yamanote Line. One day, while reading her favorite book, the JR timetable, she came up with the following question: "How many vehicles are used on the Yamanote Line in a day?"
She tried to determine the minimum number of vehicles required for operation from the timetable. However, since there were a large number of trains, she alone could not count them. So she asked for help from you, an excellent programmer.
Your job is to write a program that calculates the minimum number of vehicles required to operate the Yamanote Line from the given timetable. Since the Yamanote Line is a circular route, the timetable is often expressed with "Osaki Station" as the starting and ending station. Therefore, the timetable given to her only shows the departure and arrival times at Osaki Station for each train.
Note that this is not possible on the actual Yamanote Line. However, in order to simplify the situation, it is assumed that a train can leave Osaki Station immediately after arriving there. Also, there may be errors in the time taken by Tekko-san or trains that have been added to the timetable by her imagination, but you cannot detect them, so you must find the number of vehicles for the times written.
If you write a program that works properly, she may invite you on a date on the train. However, whether to accept or reject the invitation is up to you.
Input
The input consists of multiple datasets. Each dataset is in the following format.
n
hh
:
mm
:
ss
hh
:
mm
:
ss
hh
:
mm
:
ss
hh
:
mm
:
ss
...
hh
:
mm
:
ss
hh
:
mm
:
ss
The first integer
n
is the number of trains in the timetable. This value is guaranteed not to exceed 10,000. From the 2nd to the
n
+ 1th lines, the departure and arrival times of each train at Osaki Station are given in this order. There is one space between the departure time and the arrival time. Each time is represented in the form of
hh
:
mm
:
ss
, where
hh
represents the hour,
mm
represents the minute, and
ss
represents the second. The range of each value is 0 ≦
hh
< 24, 0 ≦
mm
< 60, 0 ≦
ss
< 60. These numbers have two digits each, and a 0 is added to the beginning if necessary.
Trains that operate across midnight at 24:00 are not included. Therefore, the departure time is always earlier than the arrival time.
The end of the input is indicated by
n
= 0, which is not included in the dataset.
Output
For each dataset, output the minimum number of vehicles required on one line.
Sample Input
3
05:47:15 09:54:40
12:12:59 12:13:00
16:15:00 19:26:20
3
05:47:15 09:54:40
12:12:59 12:13:00
16:15:00 19:26:20
0
Sample Output
2
2
Square Route
Problem Description: Mr. Shina, a billionaire who has decided to build a new mansion, is wondering which city to build it in. In fact, Mr. Shina is a unique person who loves squares very much, so he wants to live in a city with as many squares as possible.
Mr. Shina obtained a list of cities with grid-like road systems and decided to count the number of squares formed by the roads in each city. However, since the distance between the roads is not necessarily constant, it is difficult to count the squares by hand. Therefore, he wants you to write a program to count the number of squares when given information about the grid-like roads.
Input
The input consists of multiple datasets and each dataset has the following format.
N
M
h
1
h
2
...
h
N
w
1
w
2
...
w
M
The first line contains two positive integers
N
and
M
(1 ≦
N
,
M
≦ 1500). The following
N
lines
h
1
,
h
2
, ...,
h
N
(1 ≦
h
i
≦ 1000) represent the distance between the north-south roads. Here,
h
i
is the distance between the
i
-th road from the north and the (
i
+1)-th road from the north. Similarly, the following
M
lines
w
1
, ...,
w
M
(1 ≦
w
i
≦ 1000) represent the distance between the east-west roads. Here,
w
i
is the distance between the
i
-th road from the west and the (
i
+1)-th road from the west. The width of the roads themselves is sufficiently small and does not need to be considered.
Figure D-1: Data Set 1
There are no more datasets when
N
=
M
= 0, and this dataset should not be included in the input.
Output
For each dataset, output the number of squares on a single line. For example, in the first dataset of the Sample Input, there are 6 squares as shown below, so the output for this dataset is 6.
Figure D-2: Squares in the first dataset
Sample Input
3 3
1
1
4
2
3
1
1 2
10
10
10
0 0
Output for the Sample Input
6
2
Princess' Marriage
Problem Description: There are multiple data sets in the input. Each data set has the following format.
N
M
D
1
P
1
D
2
P
2
...
D
N
P
N
The first line of each data set contains two integers
N
(1≦
N
≦10,000), which represents the number of intervals, and
M
(0≦
M
≦1,000,000,000), which represents the budget the princess has. The following
N
lines represent the information of the road that the princess passes. Each line contains two integers, where the
i
-th line represents the distance of the interval
D
i
(1≦
D
i
≦10,000) and the expected number of times that the princess will be attacked by assassins when she moves one unit distance
P
i
(0≦
P
i
<=10).
The end of input is represented by a data set where
N
=0 and
M
=0. Do not output any results for this data set.
Input Format:
The input contains multiple test cases. Each test case is described as follows:
The first line contains two integers
N
and
M
.
The following
N
lines contain two integers each, representing a distance
D
i
and the expected number of times the princess will be attacked when she moves one unit distance
P
i
.
Output Format:
For each test case, output the expected number of times the princess is expected to be attacked by assassins before reaching the final destination.
Sample Input/Output:
Sample Input 1:
2 8
5 6
4 5
3 1
5 10
5 10
5 10
0 0
Sample Output 1:
5
140
Sample Input 2:
3 100
3 3
3 3
3 3
3 3
3 3
3 3
0 0
Sample Output 2:
3
Problem Name: Problem A:Saizou
Problem Description: In a certain country, a TV program called "Saizou" is popular.
    This program is about participants challenging a field athletics,
    and if they successfully clear it, they can receive a prize money.
The field athletics is made by arranging blocks of different heights in a row,
    and it is important to figure out how to climb and descend the steps
    (Figure 1) in order to clear it.
    Your friend who is going to participate in this program
    has asked you, a skilled programmer, to write a program to calculate
    the maximum step to climb and the maximum step to descend
    when the structure of the field athletics is given.
Figure 1: An example of the structure of the athletics (the first dataset of the input example).
Input
The first line of the input contains the number of datasets,
t
(0 <
t
≤ 100).
    This is followed by
t
datasets.
The first line of each dataset is the number of blocks that make up the field athletics,
n
(2 ≤
n
≤ 100).
    The second line shows a sequence of integers that represent the height of the blocks
    from the start to the goal.
    The first number corresponds to the starting block and the
n
-th number corresponds to the goal block.
    These integers are separated by a single space.
    The height
h
of each block satisfies 0 <
h
≤ 1000.
Output
For each dataset, output the maximum height difference to climb and the maximum height difference to descend,
    separated by a single space on a single line.
    If there is no step to climb or to descend, the maximum height difference for that should be 0.
Sample Input
5
5
10 70 30 50 90
2
20 100
2
100 30
3
50 50 50
7
123 45 678 901 234 567 890
Output for the Sample Input
60 40
80 0
0 70
0 0
633 667
Problem Name: Problem E: Country Road
Problem Description: This is a story that takes place in a depopulated area. Along the straight road called the Country Road, houses are sparsely built. Although there was no electricity in this area until now, the government has provided several generators this time. The generators can be installed anywhere, but to supply electricity to each house, it must be connected to one of the generators via an electric wire, and cost is incurred proportional to the length of the wire. Your job, the only technical civil servant in the area, is to find the configuration of the generators and electric wires that will minimize the total length of the electric wires, subject to the condition that electricity is supplied to all houses. It is assumed that the capacity of the generators is sufficiently large to supply electricity to as many houses as possible.
Figure 2 shows the first dataset of the sample input. To provide the optimal configuration for this problem, place the generators at
x var> = 20 and
x
= 80 as shown in the figure, and draw electric wires at the positions shown in gray in the figure.
Figure 2: Example of generator and electric wire configuration (first dataset of the input).
Input
The first line of input contains the number
t
(0 <
t
≤ 50) of datasets.
Then
t
datasets are given in the following format for each.
n
k
x
1
x
2
...
x
n
n
is the number of houses, and
k
is the number of generators.
x
1
,
x
2
, ...,
x
n
are one-dimensional coordinates representing the positions of the houses. These values are all integers and satisfy 0 <
n
≤ 100000, 0 <
k
≤ 100000, 0 ≤
x
1
<
x
2
< ... <
x
n
≤ 1000000.
Furthermore, 90% of the datasets satisfy 0 <
n
≤ 100, 0 <
k
≤ 100.
Output
For each dataset, output the minimum total length of the required electric wires in one line.
Sample Input
6
5 2
10 30 40 70 100
7 3
3 6 10 17 21 26 28
1 1
100
2 1
0 1000000
3 5
30 70 150
6 4
0 10 20 30 40 50
Output for the Sample Input
60
13
0
1000000
0
20
Problem Name: Problem C: Dial Lock
Problem Description: A dial lock is a kind of lock which has some dials with printed numbers. It has a special sequence of
numbers, namely an unlocking sequence, to be opened.
You are working at a manufacturer of dial locks. Your job is to verify that every manufactured lock is
unlocked by its unlocking sequence. In other words, you have to rotate many dials of many many locks.
It’s a very hard and boring task. You want to reduce time to open the locks.
It’s a good idea to rotate multiple dials at one time. It is, however, a difficult problem to find steps to open
a given lock with the fewest rotations. So you decided to write a program to find such steps for given
initial and unlocking sequences.
Your company’s dial locks are composed of vertically stacked k (1 ≤
k
≤ 10) cylindrical dials. Every dial
has 10 numbers, from 0 to 9, along the side of the cylindrical shape from the left to the right in sequence.
The neighbor on the right of 9 is 0.
A dial points one number at a certain position. If you rotate a dial to the left by
i
digits, the dial newly
points the
i
-th right number. In contrast, if you rotate a dial to the right by
i
digits, it points the
i
-th left
number. For example, if you rotate a dial pointing 8 to the left by 3 digits, the dial newly points 1.
You can rotate more than one adjacent dial at one time. For example, consider a lock with 5 dials. You
can rotate just the 2nd dial. You can rotate the 3rd, 4th and 5th dials at the same time. But you cannot
rotate the 1st and 3rd dials at one time without rotating the 2nd dial. When you rotate multiple dials, you
have to rotate them to the same direction by the same digits.
Your program is to calculate the fewest number of rotations to unlock, for given initial and unlocking
sequences. Rotating one or more adjacent dials to the same direction by the same digits is counted as one
rotation.
Input
The input consists of multiple datasets. 

Each datset consists of two lines. The first line contains an integer k. The second lines contain two strings,
separated by a space, which indicate the initial and unlocking sequences.
The last dataset is followed by a line containing one zero. This line is not a part of any dataset and should not be processed.
Output
For each dataset, print the minimum number of rotations in one line.
Sample Input
4
1357 4680
6
777777 003330
0
Output for the Sample Input
1
2
Problem Name: Problem A: Strange String Manipulation
Problem Description: A linear congruential generator produces a series R(⋅) of pseudo-random numbers by the following for-
mulas:
where
S
,
A
,
C
, and
M
are all parameters. In this problem, 0 ≤
S
,
A
,
C
≤ 15 and
M
= 256.
Now suppose we have some input string
I
(⋅), where each character in the string is an integer between 0
and (
M
- 1). Then, using the pseudo-random number series
R
(⋅), we obtain another string
O
(⋅) as the
output by the following formula:
Your task is to write a program that shows the parameters
S
,
A
, and
C
such that the information entropy of the output string
O
(⋅) is minimized. Here, the information entropy
H
is given by the following formula:
where
N
is the length of the string and #(
x
) is the number of occurences of the alphabet
x
.
Input
The input consists of multiple datasets. Each dataset has the following format:
N
I
(1)
I
(2) ...
I
(
N
)
N
does not exceed 256.
The last dataset is followed by a line containing one zero. This line is not a part of any dataset and should not be processed.
Output
For each dataset, print in a line the values of the three parameters
S
,
A
, and
C
separated by a single space. If more than one solution gives the same minimum entropy, choose the solution with the smallest
S
,
A
, and then
C
.
Sample Input
5
5 4 3 2 1
5
7 7 7 7 7
10
186 8 42 24 154 40 10 56 122 72
0
Output for the Sample Input
0 1 1
0 0 0
8 7 14
Problem Name: Problem H: Eleven Lover
Problem Description: Edward Leven loves multiples of eleven very much. When he sees a number, he always tries
to find consecutive subsequences (or substrings) forming multiples of eleven. He calls such
subsequences as 11-sequences. For example, he can find an 11-sequence 781 in a number 17819.
He thinks a number which has many 11-sequences is a
good
number. He would like to find out
a very
good
number. As the first step, he wants an easy way to count how many 11-sequences
are there in a given number. Even for him, counting them from a big number is not easy.
Fortunately, one of his friends, you, is a brilliant programmer. He asks you to write a program
to count the number of 11-sequences. Note that an 11-sequence must be a positive number
without leading zeros.
Input
The input is a sequence of lines each of which contains a number consisting of less than or equal
to 80000 digits.
The end of the input is indicated by a line containing a single zero, which should not be processed.
Output
For each input number, output a line containing the number of 11-sequences.
You can assume the answer fits in a 32-bit signed integer.
Sample Input
17819
1111
11011
1234567891011121314151617181920
0
Output for the Sample Input
1
4
4
38
Problem Name: Problem A: Sum of Consecutive Integers
Problem Description: You've successfully won a months-long battle of entrance exams and have finally been admitted to ICPC University. On the day of enrollment procedures, there were enthusiastic circle recruitment activities taking place on the university campus, and you received a large number of pamphlets before returning home. When you returned to your room, you found a pamphlet that caught your eye. It was given to you by the university's public relations department.
The pamphlet contained the following problem:
How many combinations of two or more consecutive positive integers have a sum of
N
? For example, 9 can be expressed as 2+3+4 or 4+5, so there are two possible combinations.
Curious about the answer to this problem, you decided to write a program to find out. Therefore, your task is to write a program that takes a positive integer
N
as input and outputs the answer to the problem.
Input
The input consists of a sequence of datasets. Each dataset is represented by a single integer
N
on a line. Here, 1 ≤
N
≤ 1000.
The end of the input is indicated by a line containing a single zero.
Output
The output is the answer to the problem for each positive integer represented in the input dataset, listed in the order of the input datasets. There should be no extra characters in the output.
Sample Input
9
500
0
Output for the Sample Input
2
3
Problem Name: Problem B: Let's JUMPSTYLE
Description
Problem Description: F, who loves dancing, has decided to practice a hardcore dance called JUMPSTYLE in a certain dance hall.
The floor is covered with tiles in a grid of N×N. To support the dance practice, each tile has the coordinates of the tile to jump to next step written on it. F has strong motor skills from daily practice and can jump to any tile on the floor.
F realized that if he continued this dance for a long enough time, he would eventually enter a steady state and loop the same route. He wondered how many such loops existed on this floor and consulted with you, a programmer.
Input
The input consists of multiple test cases.
Each test case begins with a line containing the length of one side of the floor N. (1 ≦ N ≦ 100)
The next N lines represent the coordinates to jump to written on each tile of the floor, as shown below:
represents the x-coordinate and y-coordinate of the jump destination written on the tile at coordinate (i, j). Coordinates are 0-based and all coordinate values are integers between 0 and N-1.
The input ends with a line consisting of only 0.
Output
For each test case, output the number of different loops on one line.
Sample Input
1
0 0
2
1 1 0 1
1 0 0 0
2
1 1 0 1
1 1 1 0
3
0 1 2 2 2 1
0 2 1 2 2 1
0 0 0 1 1 1
4
3 2 2 0 3 2 2 1
1 1 0 3 1 1 3 1
0 3 2 3 3 0 2 3
1 1 1 1 3 2 1 3
0
Output for Sample Input
1
2
1
2
3