CodeEff/ECCO huggingface dataset:
Problem Name: Affine Cipher
Problem Description: An affine cipher is one of the simplest ciphers. First, the alphabet a-z is replaced with numbers from 0 to 25, such as a=0, b=1, c=2,..., x=23, y=24, z=25. Then, the original alphabet is replaced by the following formula.
$F(\gamma) = (\alpha \cdot \gamma + \beta)$ mod $26$
Here, mod 26 denotes the remainder when it is divided by 26. For example, when $\alpha=3$ and $\beta=2$, the alphabet 'a' (=0) is replaced with 'c' by $F(0) = (3 \cdot 0 + 2)$ mod $26 = 2$. The alphabet 'n' (=13) is replaced with 'p' by $F(13) = (3 \cdot 13 + 2)$ mod $26 = 15$. Carefully choose $\alpha$ and $\beta$ so that $F(\gamma)$ always corresponds uniquely to $\gamma$; $\alpha$ and 26 must satisfy the condition that they are relatively prime. For example, in the case of $\alpha=4$ and $\beta=7$, "a" and "n" are replaced by the same "h," so this condition is not satisfied. Non-alphabetic characters are not replaced.
Create a program that decrypts the encrypted string and outputs the original text. The original text may include one of the following keywords.
that
this
Input
There are multiple datasets. The first line contains the number n (n ≤ 30) of datasets. Then, n lines of data are given. For each dataset, a single encrypted text consisting of up to 256 characters of lowercase alphabets and spaces is given.
Output
For each dataset, output the decoded original text on a single line.
Sample Input
1
y eazqyp pnop pngtg ye obmpngt xmybp mr lygw
Sample Output
I submit that there is another point of view
Problem Name: Expression
Problem Description: Create an expression that evaluates to 10 using four integers between 1 and 9 (inclusive). Given four integers a, b, c, and d, write a program that outputs an expression that satisfies the following conditions, using only addition (+), subtraction (-), and multiplication (*). If multiple solutions are possible, output only the first one found. If no solution is possible, output 0.
You must use all four numbers.
The order of the four numbers can be changed.
You may use up to three sets of parentheses (6 total).
Input
The input consists of multiple datasets. Each dataset is given in the following form:
a
b
c
d
The input ends with four 0's. The number of datasets does not exceed 40.
Output
For each dataset, output one line that contains an expression using the four given numbers and the above operators and parentheses that evaluates to 10, or 0 if no such expression exists. The length of the expression string should not exceed 1024 characters.
Sample Input
8 7 9 9
4 4 4 4
5 5 7 5
0 0 0 0
Output for the Sample Input
((9 * (9 - 7)) - 8)
0
((7 * 5) - (5 * 5))
Problem Name: Thief
Problem Description: A thief broke into a museum where many treasures are stored. He was carrying a large cloth and nothing else. The thief planned to steal many things, but the crucial point is that the fabric that he’s carrying has a limit to its weight. If there's weight exceeding its capacity, the fabric will tear apart and break. Therefore, the thief needed to consider the combination of treasures with the highest value without breaking the fabric.
A program should be written considering the equipment level and price to maximize the commodity value by this script.
Please write a program that reads the value and weight of each treasure of the museum and the load capacity
W
of the fabric from the first line.
An integer representing the load capacity of the fabric,
W
( ≤ 1,000), is written in the first line. The second line contains an integer
N
(1 ≤
N
≤ 1,000), indicating the number of treasures. In each of the following
N
lines, the value
v
i
of the
i
-th treasure (0 ≤
v
i
≤ 10,000) is written. The weight
w
i
(0 ≤
w
i
≤
W
) of the
i
-th treasure is also given on the same line.( ,  indicate that v
i
and w
i
are separated by a comma.)
When W is zero, input ends. There are no more than 50 datasets.
For each dataset, output in the following format:
X =htmlentities(" ")?> Pull Down: 
   

    The country with the highest concentration of neodeyration of showa element in the world
Case Dataset: 
Total value of the treasures
Total weight of the treasures contained in the fabric
Sample input
50
5
60,10
100,20
120,30
210,45
10,4
50
5
60,10
100,20
120,30
210,45
10,4
0
Sample Output
Case 1:
220
49
Case 2:
220
49
Problem Name: Puzzle
Problem Description: There is a puzzle in which 14 numbers from 1 to 9 are combined. Add one more number to the given 13 numbers to complete the puzzle.
The completion conditions of the puzzle are:
Two of the same numbers must be combined.
The remaining 12 numbers are combinations of three numbers in four ways.
The combinations of three numbers are either three of the same number or three consecutive numbers. However, a sequence such as 9 1 2 is not considered consecutive numbers.
The same number can be used up to 4 times.
Create a program that reads a string of 13 numbers and outputs all the numbers that can complete the puzzle in ascending order. If no number from 1 to 9 can complete the puzzle, output 0.
For example, if the given string is 3456666777999,
if "2" is added, the puzzle will be completed by
234 567 666 77 999
if "3" is added, the puzzle will be completed by
33 456 666 777 999
if "5" is added, the puzzle will be completed by
345 567 666 77 999
if "8" is added, the puzzle will be completed by
345 666 678 77 999
Note that the puzzle can also be completed with "6", but it cannot be used in this example because it would be the fifth use.
Input
Multiple data sets are provided as input. Each data set consists of 13 numbers on one line. The number of data sets is no more than 50.
Output
For each data set, output the numbers that can be used to complete the puzzle in ascending order, separated by spaces.
Sample Input
3649596966777
6358665788577
9118992346175
9643871425498
7755542764533
1133557799246
Output for the Sample Input
2 3 5 8
3 4
1 2 3 4 5 6 7 8 9
7 8 9
1 2 3 4 6 7 8
0
Problem Name: Prime Number II
Problem Description: A prime number is an integer greater than 1 that is only divisible by itself and 1. For example, 2 is a prime number because it can only be divided by 2 and 1, but 12 is not a prime number because it can be divided by 2, 3, 4, and 6 in addition to 12 and 1.
Write a program that takes an integer
n
as input and outputs the largest prime number smaller than
n
and the smallest prime number larger than
n
.
Input
Multiple datasets are given. Each dataset is given on one line as
n
(3 ≤
n
≤ 50,000).
There are no more than 50 datasets.
Output
For each dataset, output the largest prime number smaller than
n
and the smallest prime number larger than
n
on one line separated by a space.
Sample Input
19
3517
Output for the Sample Input
17 23
3511 3527
Problem Name: Weight Classes
Problem Description: In boxing, weight classes are divided by weight. Create a program that reads in weight and outputs the corresponding weight class. The relationship between weight classes and weight is as follows:
Weight Class
Weight (kg)
light fly
Below 48.00kg
fly
48.00kg or more but less than or equal to 51.00kg
bantam
51.00kg or more but less than or equal to 54.00kg
feather
54.00kg or more but less than or equal to 57.00kg
light
57.00kg or more but less than or equal to 60.00kg
light welter
60.00kg or more but less than or equal to 64.00kg
welter
64.00kg or more but less than or equal to 69.00 kg
light middle
69.00kg or more but less than or equal to 75.00 kg
middle
75.00kg or more but less than or equal to 81.00 kg
light heavy
81.00kg or more but less than or equal to 91.00 kg
heavy
More than 91.00kg
Input
The input consists of multiple datasets. For each dataset, a single real number
w
representing the weight is given on one line. The number of datasets is no more than 50.
Output
For each dataset, output the corresponding weight class on one line.
Sample Input
60.2
70.2
48.0
80.2
Output for the Sample Input
light welter
light middle
light fly
middle
Problem Name: Blood Type
Problem Description: Create a program that reads data containing the attendance number and ABO blood type of students in a certain class, and outputs the number of people with each blood type. There are four types of ABO blood types: A, B, AB, and O.
Input
The input consists of multiple lines each containing a comma-separated pair of attendance number and blood type. The attendance number is an integer between 1 and 50, and the blood type is one of the strings "A", "B", "AB", or "O". There are no more than 50 students in the class.
Output
Output the number of people with each blood type on separate lines, in the following order:
The number of people with blood type A
The number of people with blood type B
The number of people with blood type AB
The number of people with blood type O
Sample Input
1,B
2,A
3,B
4,AB
5,B
6,O
7,A
8,O
9,AB
10,A
11,A
12,B
13,AB
14,A
Output for the Sample Input
5
4
3
2
Problem Name: Factorial II
Problem Description: The factorial of n, denoted by n!, is the product of all positive integers less than or equal to n. For example, 12! = 12 × 11 × 10 × 9 × 8 × 7 × 6 × 5 × 4 × 3 × 2 × 1 = 479001600, and it has two consecutive zeros at the end.
Write a program that reads a positive integer
n
(≤ 20000) and outputs the number of consecutive zeros at the end of
n!
.
Input
The input consists of multiple datasets. Each dataset consists of a single line containing a positive integer
n
(≤ 20000). The end of the input is indicated by a line containing a single zero.
Output
For each dataset, output the number of consecutive zeros at the end of
n!
.
Sample Input
2
12
10000
0
Output for the Sample Input
0
2
2499
Problem Name: Sum of Prime Numbers
Problem Description: Let p(i) be the i-th prime number in ascending order. For example, 7 is the 4th prime number, which is 2, 3, 5, 7 in ascending order, so p(4) = 7.
Given an integer
n
, create a program that outputs the sum
s
of
p(i)
for
i = 1
to
n
, where
s = p(1) + p(2) +
....
+ p(n)
.
For example, when
n = 9
,
s = 2 + 3 + 5 + 7 + 11 + 13 + 17 + 19 + 23 = 100
.
Input
Multiple datasets will be given. For each dataset, an integer
n
(
n
≤ 10000) will be given. When
n
is 0, it is the end of the input. There will be no more than 50 datasets.
Output
For each
n
in each dataset, output
s
on one line.
Sample Input
2
9
0
Output for the Sample Input
5
100
Problem Name: Goldbach's Conjecture
Problem Description: It is known that any even number greater than or equal to 4 can be expressed as the sum of two prime numbers. This is called Goldbach's conjecture, and it has been confirmed to be true for very large numbers by computer calculations. For example, 10 can be expressed as the sum of two prime numbers, 7 + 3 and 5 + 5.
Write a program that takes an integer
n
as input and outputs the number of ways to express
n
as the sum of two prime numbers. Assume that
n
is even and between 4 and 50,000. There may be multiple datasets, and the input ends with 0.
Input
Multiple datasets are given. Each dataset consists of a single line containing an integer
n
. When
n
is 0, it indicates the end of the input. The number of datasets does not exceed 10,000.
Output
For each dataset, output the number of ways to express
n
as the sum of two prime numbers on a single line.
Sample Input
10
11
0
Output for the Sample Input
2
0
Problem Name: Orthogonal Judgment
Problem Description: Write a program that reads the coordinates of four different points on a plane, $A(x_A,y_A)$, $B(x_B,y_B)$, $C(x_C,y_C)$, and $D(x_D,y_D)$, and outputs YES if the line AB and CD are orthogonal, or NO if they are not orthogonal. Note that "line" here refers to a straight line, not a line segment. See the figure below for reference.
Input
The input consists of multiple datasets. The format for each dataset is as follows.
$x_A$ $y_A$ $x_B$ $y_B$ $x_C$ $y_C$ $x_D$ $y_D$
Here, $x_A$, $y_A$, $x_B$, $y_B$, $x_C$, $y_C$, $x_D$, and $y_D$ are real numbers ranging from -100 to 100, and each value is given as a real number with up to five decimal places.
There are no more than 100 datasets.
Output
For each dataset, output
YES
or
NO
on a single line.
Sample Input
1.0 1.0 2.0 2.0 0.0 0.0 1.0 -1.0
0.0 0.0 2.0 0.0 -1.0 2.0 2.0 2.0
10.0 6.0 3.4 5.2 6.8 9.5 4.3 2.1
2.5 3.5 2.5 4.5 -3.3 -2.3 6.8 -2.3
Output for the Sample Input
YES
NO
NO
YES
Problem Name: Card Game
Problem Description: There are 10 cards with numbers from 1 to 10 written on them, each with one card. The cards have numbers written on the front and nothing on the back. You and your opponent will play a game using these cards following the rules below.
You and your opponent are each dealt two cards, one with the front facing up and one with the back facing up. You can see the number on your opponent's card with the front facing up, but not the one with the back facing up.
You win if the total of the numbers on the cards dealt is less than or equal to 20 and greater than the total of your opponent's cards. For example, if your cards are "7" and "8" (total of 15) and your opponent's cards are "9" and "10" (total of 19), your opponent wins.
You and your opponent can draw one more card at most. You don't have to draw it.
Here, as a guideline for deciding whether to draw one more card, let's draw a card if the probability of the total becoming 20 or less when we draw it is 50% or more. When calculating this probability, you can use information about your two cards and your opponent's face-up card. In other words, since there is only one of each card, you will not draw those cards.
Write a program that reads your two cards and your opponent's face-up card and outputs YES if the probability of the total becoming 20 or less when you draw one more card is 50% or more, and NO otherwise.
Input
The input consists of multiple datasets. Let C1 be the number on your first card, C2 be the number on your second card, and C3 be the number on your opponent's face-up card. Each dataset is given in the following format.
C1 C2 C3
Output
For each dataset, output YES or NO on one line.
Sample Input
1 2 3
5 6 9
8 9 10
Output for the Sample Input
YES
YES
NO
Problem Name: Number of Islands
Problem Description: You are given a map of a terrain represented by a 12 x 12 grid of squares. Each square is painted black or white. White represents the sea, and black represents land. Two black squares that are adjacent vertically or horizontally are said to be contiguous. In this map, a single black square or a contiguous group of black squares is called an "island." For example, there are five islands in the following figure:
■■■■□□□□■■■■
■■■□□□□□■■■■
■■□□□□□□■■■■
■□□□□□□□■■■■
□□□■□□□■□□□□
□□□□□□■■■□□□
□□□□□■■■■■□□
■□□□■■■■■■■□
■■□□□■■■■■□□
■■■□□□■■■□□□
■■■■□□□■□□□□
□□□□□□□□□□□□
Write a program that reads the map data and outputs the number of islands.
Input
The input consists of multiple data sets. Each data set represents a single map. A single map is represented as a 12 x 12 grid of squares, each of which is represented as a 0 or a 1. 0 represents a white square, and 1 represents a black square. Each map is separated by a single blank line.
There are at most 20 data sets.
Output
For each data set, output the number of islands in the map on a single line.
Sample Input
111100001111
111000001111
110000001111
100000001111
000100010000
000000111000
000001111100
100011111110
110001111100
111000111000
111100010000
000000000000

010001111100
110010000010
010010000001
010000000001
010000000110
010000111000
010000000100
010000000010
010000000001
010010000001
010010000010
111001111100

000000000000
111111111111
100010100001
100010100001
100010100001
100010100001
100100100101
101000011101
100000000001
100000000001
111111111111
100000000001
Output for the Sample Input
5
13
4
Hint
The following is a representation of the sample input using ■ and □.
■■■■□□□□■■■■　　□■□□□■■■■■□□　　□□□□□□□□□□□□
■■■□□□□□■■■■　　■■□□■□□□□□■□　　■■■■■■■■■■■■
■■□□□□□□■■■■　　□■□□■□□□□□□■　　■□□□■□■□□□□■
■□□□□□□□■■■■　　□■□□□□□□□□□■　　■□□□■□■□□□□■
□□□■□□□■□□□□　　□■□□□□□□□■■□　　■□□□■□■□□□□■
□□□□□□■■■□□□　　□■□□□□■■■□□□　　■□□□■□■□□□□■
□□□□□■■■■■□□　　□■□□□□□□□■□□　　■□□■□□■□□■□■
■□□□■■■■■■■□　　□■□□□□□□□□■□　　■□■□□□□■■■□■
■■□□□■■■■■□□　　□■□□□□□□□□□■　　■□□□□□□□□□□■
■■■□□□■■■□□□　　□■□□■□□□□□□■　　■□□□□□□□□□□■
■■■■□□□■□□□□　　□■□□■□□□□□■□　　■■■■■■■■■■■■
□□□□□□□□□□□□　　■■■□□■■■■■□□　　■□□□□□□□□□□■
Problem Name: Amidakuji II
Problem Description: There is an amidakuji with n vertical lines. The following conditions are satisfied by this amidakuji:
The horizontal lines are drawn horizontally. They are not drawn diagonally.
The horizontal lines always connect adjacent vertical lines. In other words, the horizontal lines do not cross any vertical lines.
No two horizontal lines come out of the same point on any vertical line. In other words, the horizontal lines do not cross each other.
There is only one winning position.
The example of amidakuji with
n
= 5 is shown in the figure below. The numbers at the top indicate the numbers of vertical lines (1, 2, 3, 4, 5 from left to right). The ☆ represents the winning position.
Write a program that reads the number of vertical lines
n
, the number
m
of the selected vertical line, the position of the winning position, and the presence or absence of horizontal lines at each level of the amidakuji, and determines whether the winning position can be reached. It is assumed that one horizontal line can be added at any position of the given amidakuji (but it is not necessary to add it). The amidakuji after adding one horizontal line must also satisfy the above conditions.
Input
Multiple data sets are given. Each data set is as follows:
The first line contains the number of vertical lines
n
(1 <
n
≤ 10).
The second line contains the number
m
of the selected vertical line (1 ≤
m
≤
n
).
The third line contains the number of the winning position (counted from the left).
The fourth line contains the number of levels
d
of the amidakuji (1 ≤
d
≤ 30).
From the fifth line onwards,
n
- 1 numbers are listed in order from top to bottom of the amidakuji, with 1 indicating the presence of a horizontal line and 0 indicating its absence.
The input ends with a line containing a single 0.
Output
For each data set, output the following values depending on whether the winning position can be reached from the selected vertical line
m
:
If the winning position can be reached without drawing any horizontal lines, output 0.
If the winning position can be reached by drawing one horizontal line, output the position of the line closest to the starting side (upward in the figure). Output the number of the vertical line counting from the left and the level counting from the starting side where the line is drawn (refer to the figure) separated by a space.
If the winning position cannot be reached even by drawing one horizontal line, output 1.
Sample Input
5
2
3
9
1010
1001
0100
1001
0010
1000
0100
0101
1010
0
Output for the Sample Input
6 4
Problem Name: Combination of Number Sequences
Problem Description: Consider an arrangement of n integers from 0 to 9, denoted by k1, k2, ..., kn. Read in positive integers n and s, and output the number of arrangements of n integers for which the sum of k1 + 2 × k2 + 3 × k3 + ... + n × kn = s. Note that each arrangement of n integers must contain unique numbers without repetition.
Input
The input consists of multiple datasets. Each dataset consists of two integers separated by a single space:
n
(1 ≤
n
≤ 10) and
s
(0 ≤
s
≤ 10,000).
There are no more than 100 datasets.
Output
For each dataset, output the number of arrangements of
n
integers whose sum is
s
on one line.
Sample Input
3 10
3 1
Output for the Sample Input
8
0
Problem Description: **Translation**
Problem Name: Chain of Bombs
There is a grid consisting of 8 rows and 8 columns, as shown in Figure 1. On that grid, several bombs are placed. An example of this is shown in Figure 2 (● = bomb).
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
□
●
□
□
●
□
□
□
□
□
□
●
□
□
●
□
□
□
●
□
□
●
□
□
●
□
□
□
●
□
□
●
□
□
□
□
□
□
Problem Name: BMI
Problem Description: Obesity is listed as a cause of many adult illnesses. In the past, with a few exceptions, it was something that high school students were not concerned about. However, it has become unrealistic for them to become physically inactive due to excessive studying, or to develop overeating disorders due to stress. It may become a problem that high school students need to be sufficiently concerned about.
Therefore, you have been asked to create a program that finds students suspected of being obese from student data as an assistant to the school nurse.
The method is to calculate a numerical value called BMI (Body Mass Index). BMI is given by the following formula.
BMI = 22 is standard, and a BMI of 25 or higher is suspected of being obese.
Create a program that calculates the BMI from the weight and height information of each student and outputs the student ID of the students with a BMI of 25 or higher.
Input
The input is given in the following format.
s
1
,
w
1
,
h
1
s
2
,
w
2
,
h
2
...
...
s
i
(1 ≤
s
i
≤ 2,000),
w
i
(1 ≤
w
i
≤ 200), and
h
i
(1.0 ≤
h
i
≤ 2.0) represent the student ID (integer), weight (real number), and height (real number) of the i-th student, respectively.
The number of students is no more than 50.
Output
Output the student ID of the students with a BMI of 25 or higher, one per line, in the order of input.
Sample Input
1001,50.0,1.60 
1002,60.0,1.70 
1003,70.0,1.80 
1004,80.0,1.70 
1005,90.0,1.60
Output for the Sample Input
1004
1005
Problem Name: Cubic Root
Problem Description: The solution to $x^3 = q$ can be approximated by calculating the recursive formula $x_{n+1} = x_n - \frac{x_{n}^3 - q}{3x_{n}^2}$, and repeating the calculation for $x_2 = x_1 - \frac{x_{1}^3 - q}{3x_{1}^2}$, $x_3 = x_2 - \frac{x_{2}^3 - q}{3x_{2}^2}$, and so on.
While doing this calculation, if the value of $|x^3 - q|$ becomes sufficiently small, stop the calculation and take the last calculated $x_n$ as an approximate solution to $x^3 = q$.
Following this method, create a program that outputs an approximation of the cubic root of the positive integer $q$ entered. However, use the judgment "$|x^3 - q| < 0.00001 q$" to determine when it has become "sufficiently small."
Input
Multiple datasets are given. One line contains a positive integer $q$ ($1 \leq q < 2^{31}$) (an integer) for each dataset. The end of the input is -1.
The number of datasets does not exceed 50.
Output
For each dataset, output $x$ (real number) on one line. The output may contain errors of 0.00001 or less.
Sample Input
15
15
-1
Output for the Sample Input
2.466212
2.466212