CodeEff/ECCO huggingface dataset:
Problem Name: Problem C: K Poker
Description
Problem Description: It is the year 200X, and the mysterious circle K, active at K University, announced a new game they had created called K Poker in K East 4F during the university's cultural festival.
At first glance, this game appears to be a normal game of poker, but it adds an element called "basic points" to the cards, making it a deeper game of poker. 
The basic points of the cards are determined by the designs on the cards, and the score of a hand is equal to the sum of the basic points of the five cards in the hand multiplied by the multiplier of the hand. 
By introducing these basic points, even if you create a strong hand like a full house, if the basic points are 0, you will be treated like a pig and may even lose to a one pair. 
All other rules are the same as regular poker. 
You have decided to write a program to calculate the score of a hand while porting this K Poker to a PC.
Note that this game cannot be played by anyone under 18 years old.
Input
The input consists of multiple test cases.
The first line of each test case contains the number N of hands to check.
The next four lines contain 13 integers each, in order from 1 to 13, representing the basic points of the cards. The suits of the four lines are spades, clubs, hearts, and diamonds in order from top to bottom.
The next line contains nine integers, representing the multipliers of one pair, two pair, three of a kind, straight, flush, full house, four of a kind, straight flush, and royal straight flush, in that order. The multipliers of hands are always in ascending order. The multiplier of no pair (pig) is always 0.
The next N lines each contain five different two-character strings representing the hand. The first character represents the card's numerical value, which can be A, 2, 3, 4, 5, 6, 7, 8, 9, T, J, Q, or K. The second character represents the card's suit, which can be S, C, H, or D. Each letter represents Ace, 10, Jack, Queen, King, spades, clubs, hearts, and diamonds, respectively.
All input values are within the range [0, 10000].
The input ends with EOF.
Output
Output the score of each hand on a separate line.
Leave one blank line between two consecutive test cases.
For information on hands, see the
Poker page on wikipedia
.
Note that a straight may span from Ace to King, but it is only counted as a straight if the hand consists of the cards 10, Jack, Queen, King, and Ace.
Sample Input
3
0 1 0 1 0 0 0 0 0 1 0 0 0
1 0 0 0 0 0 1 0 0 1 0 0 2
0 1 1 0 1 1 1 0 0 0 0 5 5
3 1 1 1 0 1 0 0 1 0 3 0 2
1 1 2 4 5 10 20 50 100
7H 6H 2H 5H 3H
9S 9C 9H 8H 8D
KS KH QH JD TS
10
1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1
1 2 3 4 5 6 7 8 9
AS 3D 2C 5D 6H
6S 6C 7D 8H 9C
TS TD QC JD JC
KD KH KC AD 2C
3D 4H 6D 5H 7C
2S KS QS AS JS
TS TD JD JC TH
8H 8D TC 8C 8S
4S 5S 3S 7S 6S
KD QD JD TD AD
Output for Sample Input
25
0
14

0
5
10
15
20
25
30
35
40
45
Problem Name: Problem D: THE BYDOLM@STER
Description
Problem Description: THE BYDOLM@STER (The Idolmaster) is a nurturing simulation game scheduled to be released on April 1, 2010, by 1rem Inc. on EXIDNA. Just to clarify, it is probably unrelated to a certain arcade game whose network connection service was stopped earlier this month.
In this game, the player selects the members of a unit (formation) produced by Bydol and raises them to become top idols through lessons and communication with the members. The image on the right is a figure of one of the top idols, "Dobkeradops". 
Each Bydol has three parameters of ability values: vocal, dance, and looks. The unit's ability value is the sum of all the Bydols' parameters belonging to the unit. The maximum of the three ability values of the unit becomes the unit's rank.
There is no limit on the number of members in a unit, and a unit can function with one, three, or 100 members. Of course, it is possible to hire the same Bydol multiple times, but one must consider the cost of hiring Bydols.
As a producer, you have decided to write a program to calculate and create the best unit.
Input
The input consists of multiple test cases.
The first line of each test case gives N, the number of Bydols, and M, the available cost. (1<=N,M<=300)
The following 2*N lines contain information about each Bydol.
The first line of Bydol's information gives the name of Bydol. The name of the Bydol consists of alphabets and spaces and is less than or equal to 30 characters. Also, there are no Bydols with the same name.
The second line gives the integers C, V, D, and L. C is the cost to hire that Bydol, and V, D, and L represent the ability values of vocal, dance, and looks, respectively. (1<=C,V,D,L<=300)
The input ends with EOF.
Output
Output the maximum rank of the unit that can be created within the given cost.
If a unit cannot be created, output 0.
Sample Input
3 10
Dobkeradops
7 5 23 10
PataPata
1 1 2 1
dop
5 3 11 14
2 300
Bydo System Alpha
7 11 4 7
Green Inferno
300 300 300 300
Output for Sample Input
29
462
Problem Name: Problem A: Ennichi
Problem Description: A rabbit who came to a shrine's festival found a game booth where the prize was a carrot cake. The rules for this game are as follows:
There is a rectangular field with h rows and w columns, and at most one block is placed in each square. Each block is colored with one of the uppercase letters ('A' - 'Z'). When n or more blocks of the same color are aligned vertically or horizontally, they disappear.
Participants can choose two adjacent squares horizontally and swap their states. When a block falls because of swapping, disappearing, or falling, the block falls one square down. When n or more blocks of the same color are aligned again, they disappear. However, the blocks do not disappear while falling, and all the blocks disappear at the same time when all the blocks have finished falling.
If all the blocks on the field disappear in one operation, the game is successful, and the rabbit can get the cake. The rabbit wants to get the cake by paying the participation fee only once, and does not want to participate if it is impossible. Given the initial state of the field at the start of the game, determine whether the rabbit should participate in the game.
Input
The first line of the input contains three integers h, w, and n separated by spaces.
2 ≤ h, w, n ≤ 30.
The next h lines give the state of the field from top to bottom. Uppercase letters represent blocks, and periods represent empty squares. The state of the field given does not contain n or more blocks of the same color aligned vertically or horizontally and there is no block in the state that will fall. There is at least one block.
Output
If the rabbit should participate in the game, print "YES". Otherwise, print "NO".
Sample Input 1
4 6 3
......
...Y..
...Y..
RRYRYY
Sample Output 2
YES
Sample Input 1
4 6 3
......
...Y..
...Y..
RRYRY.
Sample Output 2
NO
Problem Name: Problem A: Era Name
Problem Description: As many of you know, we have two major calendar systems used in Japan today. One of them
is Gregorian calendar which is widely used across the world. It is also known as “Western
calendar” in Japan.
The other calendar system is era-based calendar, or so-called “Japanese calendar.” This system
comes from ancient Chinese systems. Recently in Japan it has been a common way to associate
dates with the Emperors. In the era-based system, we represent a year with an era name given
at the time a new Emperor assumes the throne. If the era name is “A”, the first regnal year
will be “A 1”, the second year will be “A 2”, and so forth.
Since we have two different calendar systems, it is often needed to convert the date in one
calendar system to the other. In this problem, you are asked to write a program that converts
western year to era-based year, given a database that contains association between several
western years and era-based years.
For the simplicity, you can assume the following:
A new era always begins on January 1st of the corresponding Gregorian year.
The first year of an era is described as 1.
There is no year in which more than one era switch takes place.
Please note that, however, the database you will see may be incomplete. In other words, some
era that existed in the history may be missing from your data. So you will also have to detect
the cases where you cannot determine exactly which era the given year belongs to.
Input
The input contains multiple test cases. Each test case has the following format:
N Q
EraName
1
EraBasedYear
1
WesternYear
1
.
.
.
EraName
N
EraBasedYear
N
WesternYear
N
Query
1
.
.
.
Query
Q
The first line of the input contains two positive integers
N
and
Q
(1 ≤
N
≤ 1000, 1 ≤
Q
≤ 1000).
N
is the number of database entries, and Q is the number of queries.
Each of the following N lines has three components: era name, era-based year number and the
corresponding western year (1 ≤
EraBasedYear
i
≤
WesternYear
i
≤ 10
9
). Each of era names
consist of at most 16 Roman alphabet characters. Then the last
Q
lines of the input specifies
queries (1 ≤
Query
i
≤ 10
9
), each of which is a western year to compute era-based representation.
The end of input is indicated by a line containing two zeros. This line is not part of any dataset
and hence should not be processed.
You can assume that all the western year in the input is positive integers, and that there is no
two entries that share the same era name.
Output
For each query, output in a line the era name and the era-based year number corresponding to
the western year given, separated with a single whitespace. In case you cannot determine the
era, output “
Unknown
” without quotes.
Sample Input
4 3
meiji 10 1877
taisho 6 1917
showa 62 1987
heisei 22 2010
1868
1917
1988
1 1
universalcentury 123 2168
2010
0 0
Output for the Sample Input
meiji 1
taisho 6
Unknown
Unknown
Problem Name: Problem I: Mobile Network
Problem Description: The trafic on the Internet is increasing these days due to smartphones. The wireless carriers
have to enhance their network infrastructure.
The network of a wireless carrier consists of a number of base stations and lines. Each line connects two base stations bi-directionally. The bandwidth of a line increases every year and is given by a polynomial
f
(
x
) of the year
x
.
Your task is, given the network structure, to write a program to calculate the maximal bandwidth between the 1-st and
N
-th base stations as a polynomial of
x
.
Input
The input consists of multiple datasets. Each dataset has the following format:
N M
u
1
v
1
p
1
...
u
M
v
M
p
M
The first line of each dataset contains two integers
N
(2 ≤
N
≤ 50) and
M
(0 ≤
M
≤ 500), which indicates the number of base stations and lines respectively. The following
M
lines describe the network structure. The
i
-th of them corresponds to the
i
-th network line and contains two integers
u
i
and
v
i
and a polynomial
p
i
.
u
i
and
v
i
indicate the indices of base stations (1 ≤
u
i
,
v
i
≤
N
);
p
i
indicates the network bandwidth.
Each polynomial has the form of:
a
L
x
L
+
a
L
-1
x
L
-1
+ ... +
a
2
x
2
+
a
1
x
+
a
0
where
L
(0 ≤
L
≤ 50) is the degree and
a
i
's (0 ≤
i
≤
L
, 0 ≤
a
i
≤ 100) are the coefficients. In the input,
each term
a
i
x
i
(for
i
≥ 2) is represented as <
a
i
>
x
^<
i
>
the linear term (
a
1
x
) is represented as <
a
1
>
x
;
the constant (
a
0
) is represented just by digits;
these terms are given in the strictly decreasing order of the degrees and connected by a
plus sign ("
+
");
just like the standard notations, the <
a
i
> is omitted if
a
i
= 1 for non-constant terms;
similarly, the entire term is omitted if
a
i
= 0 for any terms; and
the polynomial representations contain no space or characters other than digits, "x", "^", and "+".
For example, 2
x
2
+ 3
x
+ 5 is represented as
2x^2+3x+5
; 2
x
3
+
x
is represented as
2x^3+x
, not
2x^3+0x^2+1x+0
or the like. No polynomial is a constant zero, i.e. the one with all the coefficients being zero.
The end of input is indicated by a line with two zeros. This line is not part of any dataset.
Output
For each dataset, print the maximal bandwidth as a polynomial of
x
. The polynomial should be represented in the same way as the input format except that a constant zero is possible and should be represented by "0" (without quotes).
Sample Input
3 3
1 2 x+2
2 3 2x+1
3 1 x+1
2 0
3 2
1 2 x
2 3 2
4 3
1 2 x^3+2x^2+3x+4
2 3 x^2+2x+3
3 4 x+2
0 0
Output for the Sample Input
2x+3
0
2
x+2
Problem Name: Problem 3: Spacetime Sugoroku Road
Problem Description: The All-Timespace Unified Dimension Sugoroku Tournament. You are participating in this tournament as the representative of 21st century Earth, to decide the Sugoroku absolute champion from among over 500 trillion participants.
The challenge you are currently facing is a one-dimensional Sugoroku where your own self is the playing piece. In this familiar format of Sugoroku, you roll a huge six-faced die with numbers one to six written on them one at a time and move forward by the number of squares that has come up. Starting from the start square at one end, you win when you land on the goal square at the opposite end. Of course, the fewer times you roll the die before reaching the goal, the better your score.
There are squares with special effects, "advance ○ squares" and "go back ○ squares", and if you land on them, you must move forward or backward by the specified number of squares. If you land on a square with an effect and move as a result, you continue to move as instructed.
However, this is a spacetime Sugoroku that cannot be easily conquered. Terrifyingly, it is possible for a "go back ○ squares" to be placed three squares ahead of an "advance ○ squares". If you land on such a square and get stuck in an infinite loop due to the effect of the square, you must continue to move back and forth on that square forever.
But fortunately, your body is endowed with the ability of "Probability Bending", which can change any desired event into any other event. With this power, you can also freely manipulate the roll of the die. When you move forward while avoiding getting stuck in an infinite loop, what is the minimum number of times you need to roll the die before reaching the goal, taking advantage of this advantage?
Input
N
p
1
p
2
.
.
.
p
N
The first line of the input contains an integer
N
(3 ≤
N
≤ 100,000), which represents the number of squares in Sugoroku. Each square is numbered from 1 to
N
. The start square is square 1, and then the squares are numbered in order of proximity to the start, from square 2 to square
N
- 1, with the goal square being square
N
. If you roll the die with
i
as the starting square and it comes up
j
, you move to square
i
+
j
. However, if
i
+
j
exceeds
N
, you are considered to have reached the goal without moving back the excess number of squares.
The following
N
lines contain integers
p
i
(-100,000 ≤
p
i
≤ 100,000). The integer
p
i
on the (1 +
i
) line represents the instruction written on square
i
. If
p
i
> 0, it means "advance
p
i
squares", if
p
i
< 0, it means "go back
p
i
squares", and if
p
i
= 0, the square has no effect.
p
1
and
p
N
are always 0. Due to the effects of the squares, you will never be instructed to move forward or backward beyond the start or goal.
It is assumed that the Sugoroku given can be won.
Output
Output the minimum number of times you need to roll the die before reaching the goal.
Sample Input 1
11
0
0
-2
0
-4
1
-1
2
0
0
0
Sample Output 1
3
Sample Input 2
12
0
0
7
0
2
0
0
3
-6
-2
1
0
Sample Output 2
1
Sample Input 3
8
0
4
-1
1
-2
-2
0
0
Sample Output 3
2
Problem Name: C - Social
Problem statement
Problem Description: There are N rabbits that are trying to cross a river using boats. There are K boats, and it is decided that they will ride on the boats as they please.
By the way, rabbits are sensitive to the quality of their relationships with each other, and when they are trapped in a small space with rabbits they don't get along with, they feel bad. For this
N
rabbits, it is known that some of them do not get along with each other, and there is a possibility that some of them will feel bad with the current assignment. Although it is better to consider a better assignment, for now, please calculate the number of rabbits that will feel bad with the current assignment.
Input format
The input is given in the following format.
N
K
m
1
bunny
1,1
...
bunny
1,m
1
m
2
bunny
2,1
...
bunny
2,m
2
...
m
K
bunny
K,1
...
bunny
K,m
K
R
p
1
q
1
...
p
R
q
R
N
is the number of rabbits that ride on the boat.
K
is the number of boats.
m
i
is the number of rabbits that ride on boat
i
, and
bunny
i,1
, ..., bunny
i,m
i
represents the number (1 to
N
) of rabbits that ride on boat
i
.
R
is the number of rabbit pairs that do not get along with each other.
p
j
, q
j
means that rabbits
p
j
and
q
j
do not get along with each other.
Output format
Output the number of rabbits that will feel bad.
Constraints
1 ≤ N ≤ 50
1 ≤ K ≤ N
m
1
+ ... + m
K
= N
{bunny
1,1
, ..., bunny
1,m
1
, bunny
2,1
, ..., bunny
K,m
K
} = {1, 2, ..., N}
0 ≤ R ≤ N(N-1)/2
1 ≤ p
j
< q
j
≤ N
The pair
(p
j
, q
j
)
is different for all.
All input values are integers.
Sample Input and Output
Sample Input 1
6 2
2 1 5
4 2 3 4 6
2
1 2
2 5
Sample Output 1
0
No rabbits are feeling bad.
Sample Input 2
6 2
2 1 5
4 2 3 4 6
3
2 3
3 4
1 2
Sample Output 2
3
Although the assignment is the same as in Example 1, the pairs of bad relationships are different. In this example, rabbits 2, 3, and 4 feel bad.
Sample Input 3
10 3
3 4 1 9
3 10 5 2
4 3 8 7 6
9
3 4
1 2
1 9
6 8
1 6
1 8
6 7
6 10
7 8
Sample Output 3
5
Writer: Mitsuru Kusumoto
Tester: Shotaro Ohama
Problem Name: D - Power
Problem Statement
Problem Description: Building 10 is a facility located at a certain university where members of the J research department work day and night on their research.
Although Building 10 was famous for its old building, it was finally renovated this year. One day, after the renovation was completed, news came that some members of the K research department were going to invade the rooms in Building 10.
If the rooms in Building 10 were invaded by the K research department, the members of the J research department who were working in that room would have to move to Building 2, which is also known for its old building. To prevent this from happening, the J research department decided that the professors would exercise their authority to protect the rooms in Building 10 from the K research department.
Building 10 has
N
rooms lined up in a straight line, with numbers
1,2,...,N
assigned to them in order. The K research department tries to invade all of these
N
rooms. The J research department has
M
professors, each of whom can exercise their authority over a range of rooms. Rooms in which one or more professors exercise their authority will not be invaded by the K research department and can be protected, but rooms in which no professors exercise their authority will be invaded.
Since the professors are busy with their research, they want to protect all the rooms with as few people as possible. Find the minimum number of professors who should exercise their authority to protect all the rooms. Note that there may be cases where all professors exercising their authority cannot protect all the rooms.
Input Format
The input is given in the following format.
N M
a
1
b
1
...
a
M
b
M
N
is the number of rooms in Building 10, and
M
is the number of professors in the J research department.
a
i
, b
i
means that Professor
i
can exercise their authority over the rooms
a
i
, a
i
+1, ..., b
i
.
Output Format
If all the rooms in Building 10 can be protected, output the minimum number of professors who should exercise their authority to do so on one line. Otherwise, output
Impossible
on one line.
Constraints
1 ≤ N ≤ 100, 1 ≤ M ≤ 100
1 ≤ a
i
≤ b
i
≤ N
All input values are integers.
Sample Input and Output
Sample Input 1
8 4
3 7
1 5
2 5
4 8
Sample Output 1
2
By exercising their authority, Professor 2 and Professor 4 can protect all the rooms in Building 10.
Sample Input 2
8 4
1 4
2 5
3 6
4 7
Sample Output 2
Impossible
Writer: Kazunori Tamura
Tester: Hiroaki Hatanaka
Problem Name: F - Acceleration of Network
Problem Description: The vast sea called the Internet has gradually been painted black.
In the war with bots, DDoS attacks, and virus outbreaks,
people and the Internet became worn out by repeated battles with crackers.

The Internet cannot be fixed by human hands.
So people created a "girl" who could restore the Internet
by spending an unbelievable amount of time on it.

The girl started taking care of the Internet.
She tried hard to do something about the infinitely vast Internet world.

Although the girl can only weave twisted pairs by herself for now,
she hopes that someday the Internet will be a little restored,
and she can work hard with everyone else.
Problem Statement
The girl is working hard every day to restore
N
services that once existed on the Internet.
The current day is considered to be day 0.
The degree of restoration of the Internet is represented by an indicator called
restoration degree
, and the current restoration degree is 0.
The girl works every day and raises the restoration degree by 1 per day.
When the restoration degree of any service
i
reaches
w
i
or more, the service
i
automatically restores.
When service
i
is restored, the restoration degree accelerates for
x
i
days starting from the day after restoration, because everyone helps with the work.
There are three types of services, and the degree of restoration increase differs depending on the type.
The types of services are represented by numbers
0, 1, 2
.
If the type of service
i
is t
i
(∈ {0, 1, 2}),
service
i
restores, and from day
d-1
to day
d
(
1 ≤ d ≤ x
i
),
the restoration degree increases by
1
if
t
i
=0
,
d
if
t
i
=1
,
and
d
2
if
t
i
=2
, in addition to the girl's work.
Also, when multiple services are restored at the same time, each service independently increases the restoration degree in parallel.
The girl thought it would take an unbelievably long time for the service to be restored, so she decided to find out how many days it would take for the service to be restored from the current day.
She also became curious about what the restoration degree would be on a certain day
y
j
Problem Name: Treasure Hunt
Problem Description: Taro has come to a square to search for treasure. There are many treasures buried in this square, but Taro has the latest machine, so he knows exactly where each treasure is buried. However, since the square is very large, Taro has decided to determine the area and search for the treasure, but since there are many treasures, he does not know which treasure is in that area. Therefore, Taro decided to count the number of treasures in that area.
Input
n
m
x
1
y
1
x
2
y
2
...
x
n
y
n
x
11
y
11
x
12
y
12
x
21
y
21
x
22
y
22
...
x
m1
y
m1
x
m2
y
m2
n
represents the number of treasures buried in the square.
m
represents the number of areas to be searched.
The coordinates where each treasure is buried are represented from the second to the n+1th lines.
The n+2th to n+m+1th lines represent each area to be searched.
The positive x-axis represents the east and the positive y-axis represents the north.
Each area is a rectangle, and
x
i1
and
y
i1
represent the coordinates of the southwest vertex of the rectangle, and
x
i2
and
y
i2
represent the coordinates of the northeast vertex of the rectangle.
Constraints
1 ≤ n ≤ 5000
1 ≤ m ≤ 5×10
5
|x
i
|, |y
i
| ≤ 10
9
(1 ≤ i ≤ n)
|x
i1
|, |y
i1
|, |x
i2
|, |y
i2
| ≤ 10
9
(1 ≤ i ≤ m)
x
i1
≤ x
i2
, y
i1
≤ y
i2
(1 ≤ i ≤ m)
All input is given as integers.
Output
C
1
C
2
...
C
m
Output the number of treasures in each area on a separate line.
Sample Input 1
3 1
1 1
2 4
5 3
0 0 5 5
Output for the Sample Input 1
3
Treasures on the boundary of the area are also considered to be included in the area.
Sample Input 2
4 2
-1 1
0 3
4 0
2 1
-3 1 5 1
4 0 4 0
Output for the Sample Input 2
2
1
Areas can also be lines or points.
Sample Input 3
2 3
0 0
0 0
-1 -1 1 1
0 0 2 2
1 1 4 4
Output for the Sample Input 3
2
2
0
There may be multiple treasures in the same place.
Sample Input 4
5 5
10 5
-3 -8
2 11
6 0
-1 3
-3 1 3 13
-1 -1 9 5
-3 -8 10 11
0 0 5 5
-10 -9 15 10
Output for the Sample Input 4
2
2
5
0
4