CodeEff/ECCO huggingface dataset:
Problem Description: Score : 400 points
Problem Statement
Give a pair of integers
(A, B)
such that
A^5-B^5 = X
.
It is guaranteed that there exists such a pair for the given integer
X
.
Constraints
1 \leq X \leq 10^9
X
is an integer.
There exists a pair of integers
(A, B)
satisfying the condition in Problem Statement.
Input
Input is given from Standard Input in the following format:
X
Output
Print
A
and
B
, with space in between.
If there are multiple pairs of integers
(A, B)
satisfying the condition, you may print any of them.
A
B
Sample Input 1
33
Sample Output 1
2 -1
For
A=2
and
B=-1
,
A^5-B^5 = 33
.
Sample Input 2
1
Sample Output 2
0 -1
Problem Description: Score: 500 points
Problem Statement
You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens.
There are
N
attendees in the party, and they are given attendee numbers from
1
through
N
. The height of Attendee
i
is
A_i
.
According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction.
The absolute difference of their attendee numbers is equal to the sum of their heights.
There are
\frac{N(N-1)}{2}
ways to choose two from the
N
attendees and make a pair. Among them, how many satisfy the condition above?
P.S.: We cannot let you know the secret.
Constraints
All values in input are integers.
2 \leq N \leq 2 \times 10^5
1 \leq A_i \leq 10^9\ (1 \leq i \leq N)
Input
Input is given from Standard Input in the following format:
N
A_1
A_2
\dots
A_N
Output
Print the number of pairs satisfying the condition.
Sample Input 1
6
2 3 3 1 3 1
Sample Output 1
3
A_1 + A_4 = 3
, so the pair of Attendee
1
and
4
satisfy the condition.
A_2 + A_6 = 4
, so the pair of Attendee
2
and
6
satisfy the condition.
A_4 + A_6 = 2
, so the pair of Attendee
4
and
6
satisfy the condition.
No other pair satisfies the condition, so you should print
3
.
Sample Input 2
6
5 2 4 2 8 8
Sample Output 2
0
No pair satisfies the condition, so you should print
0
.
Sample Input 3
32
3 1 4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4 6 2 6 4 3 3 8 3 2 7 9 5
Sample Output 3
22
Problem Description: Score: 100 points
Problem Statement
Takahashi the Jumbo will practice golf.
His objective is to get a carry distance that is a multiple of
K
, while he can only make a carry distance of between
A
and
B
(inclusive).
If he can achieve the objective, print
OK
; if he cannot, print
NG
.
Constraints
All values in input are integers.
1 \leq A \leq B \leq 1000
1 \leq K \leq 1000
Input
Input is given from Standard Input in the following format:
K
A
B
Output
If he can achieve the objective, print
OK
; if he cannot, print
NG
.
Sample Input 1
7
500 600
Sample Output 1
OK
Among the multiples of
7
, for example,
567
lies between
500
and
600
.
Sample Input 2
4
5 7
Sample Output 2
NG
No multiple of
4
lies between
5
and
7
.
Sample Input 3
1
11 11
Sample Output 3
OK
Problem Description: Score : 200 points
Problem Statement
Takahashi has a deposit of
100
yen (the currency of Japan) in AtCoder Bank.
The bank pays an annual interest rate of
1
% compounded annually. (A fraction of less than one yen is discarded.)
Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach
X
yen or above for the first time?
Constraints
101 \le X \le 10^{18}
All values in input are integers.
Input
Input is given from Standard Input in the following format:
X
Output
Print the number of years it takes for Takahashi's balance to reach
X
yen or above for the first time.
Sample Input 1
103
Sample Output 1
3
The balance after one year is
101
yen.
The balance after two years is
102
yen.
The balance after three years is
103
yen.
Thus, it takes three years for the balance to reach
103
yen or above.
Sample Input 2
1000000000000000000
Sample Output 2
3760
Sample Input 3
1333333333
Sample Output 3
1706
Problem Description: Score : 300 points
Problem Statement
Given are positive integers
N
,
M
,
Q
, and
Q
quadruples of integers (
a_i
,
b_i
,
c_i
,
d_i
).
Consider a sequence
A
satisfying the following conditions:
A
is a sequence of
N
positive integers.
1 \leq A_1 \leq A_2 \le \cdots \leq A_N \leq M
.
Let us define a score of this sequence as follows:
The score is the sum of
d_i
over all indices
i
such that
A_{b_i} - A_{a_i} = c_i
. (If there is no such
i
, the score is
0
.)
Find the maximum possible score of
A
.
Constraints
All values in input are integers.
2 ≤ N ≤ 10
1 \leq M \leq 10
1 \leq Q \leq 50
1 \leq a_i < b_i \leq N
(
i = 1, 2, ..., Q
)
0 \leq c_i \leq M - 1
(
i = 1, 2, ..., Q
)
(a_i, b_i, c_i) \neq (a_j, b_j, c_j)
(where
i \neq j
)
1 \leq d_i \leq 10^5
(
i = 1, 2, ..., Q
)
Input
Input is given from Standard Input in the following format:
N
M
Q
a_1
b_1
c_1
d_1
:
a_Q
b_Q
c_Q
d_Q
Output
Print the maximum possible score of
A
.
Sample Input 1
3 4 3
1 3 3 100
1 2 2 10
2 3 2 10
Sample Output 1
110
When
A = \{1, 3, 4\}
, its score is
110
. Under these conditions, no sequence has a score greater than
110
, so the answer is
110
.
Sample Input 2
4 6 10
2 4 1 86568
1 4 0 90629
2 3 0 90310
3 4 1 29211
3 4 3 78537
3 4 2 8580
1 2 1 96263
1 4 2 2156
1 2 0 94325
1 4 3 94328
Sample Output 2
357500
Sample Input 3
10 10 1
1 10 9 1
Sample Output 3
1
Problem Description: Score : 400 points
Problem Statement
Given are integers
A
,
B
, and
N
.
Find the maximum possible value of
floor(Ax/B) - A × floor(x/B)
for a non-negative integer
x
not greater than
N
.
Here
floor(t)
denotes the greatest integer not greater than the real number
t
.
Constraints
1 ≤ A ≤ 10^{6}
1 ≤ B ≤ 10^{12}
1 ≤ N ≤ 10^{12}
All values in input are integers.
Input
Input is given from Standard Input in the following format:
A
B
N
Output
Print the maximum possible value of
floor(Ax/B) - A × floor(x/B)
for a non-negative integer
x
not greater than
N
, as an integer.
Sample Input 1
5 7 4
Sample Output 1
2
When
x=3
,
floor(Ax/B)-A×floor(x/B) = floor(15/7) - 5×floor(3/7) = 2
. This is the maximum value possible.
Sample Input 2
11 10 9
Sample Output 2
9
Problem Description: Score : 600 points
Problem Statement
We have a tree with
N
vertices, whose
i
-th edge connects Vertex
u_i
and Vertex
v_i
.
Vertex
i
has an integer
a_i
written on it.
For every integer
k
from
1
through
N
, solve the following problem:
We will make a sequence by lining up the integers written on the vertices along the shortest path from Vertex
1
to Vertex
k
, in the order they appear. Find the length of the longest increasing subsequence of this sequence.
Here, the longest increasing subsequence of a sequence
A
of length
L
is the subsequence
A_{i_1} , A_{i_2} , ... , A_{i_M}
with the greatest possible value of
M
such that
1 \leq i_1 < i_2 < ... < i_M \leq L
and
A_{i_1} < A_{i_2} < ... < A_{i_M}
.
Constraints
2 \leq N \leq 2 \times 10^5
1 \leq a_i \leq 10^9
1 \leq u_i , v_i \leq N
u_i \neq v_i
The given graph is a tree.
All values in input are integers.
Input
Input is given from Standard Input in the following format:
N
a_1
a_2
...
a_N
u_1
v_1
u_2
v_2
:
u_{N-1}
v_{N-1}
Output
Print
N
lines. The
k
-th line, print the length of the longest increasing subsequence of the sequence obtained from the shortest path from Vertex
1
to Vertex
k
.
Sample Input 1
10
1 2 5 3 4 6 7 3 2 4
1 2
2 3
3 4
4 5
3 6
6 7
1 8
8 9
9 10
Sample Output 1
1
2
3
3
4
4
5
2
2
3
For example, the sequence
A
obtained from the shortest path from Vertex
1
to Vertex
5
is
1,2,5,3,4
. Its longest increasing subsequence is
A_1, A_2, A_4, A_5
, with the length of
4
.
Problem Description: Score : 100 points
Problem Statement
There are
S
sheep and
W
wolves.
If the number of wolves is greater than or equal to that of sheep, the wolves will attack the sheep.
If the wolves will attack the sheep, print
unsafe
; otherwise, print
safe
.
Constraints
1 \leq S \leq 100
1 \leq W \leq 100
Input
Input is given from Standard Input in the following format:
S
W
Output
If the wolves will attack the sheep, print
unsafe
; otherwise, print
safe
.
Sample Input 1
4 5
Sample Output 1
unsafe
There are four sheep and five wolves. The number of wolves is not less than that of sheep, so they will attack them.
Sample Input 2
100 2
Sample Output 2
safe
Many a sheep drive away two wolves.
Sample Input 3
10 10
Sample Output 3
unsafe
Problem Description: Score : 200 points
Problem Statement
Takahashi has
N
days of summer vacation.
His teacher gave him
M
summer assignments. It will take
A_i
days for him to do the
i
-th assignment.
He cannot do multiple assignments on the same day, or hang out on a day he does an assignment.
What is the maximum number of days Takahashi can hang out during the vacation if he finishes all the assignments during this vacation?
If Takahashi cannot finish all the assignments during the vacation, print
-1
instead.
Constraints
1 \leq N \leq 10^6
1 \leq M \leq 10^4
1 \leq A_i \leq 10^4
Input
Input is given from Standard Input in the following format:
N
M
A_1
...
A_M
Output
Print the maximum number of days Takahashi can hang out during the vacation, or
-1
.
Sample Input 1
41 2
5 6
Sample Output 1
30
For example, he can do the first assignment on the first
5
days, hang out on the next
30
days, and do the second assignment on the last
6
days of the vacation. In this way, he can safely spend
30
days hanging out.
Sample Input 2
10 2
5 6
Sample Output 2
-1
He cannot finish his assignments.
Sample Input 3
11 2
5 6
Sample Output 3
0
He can finish his assignments, but he will have no time to hang out.
Sample Input 4
314 15
9 26 5 35 8 9 79 3 23 8 46 2 6 43 3
Sample Output 4
9
Problem Description: Score : 300 points
Problem Statement
A company has
N
members, who are assigned ID numbers
1, ..., N
.
Every member, except the member numbered
1
, has exactly one immediate boss with a smaller ID number.
When a person
X
is the immediate boss of a person
Y
, the person
Y
is said to be an immediate subordinate of the person
X
.
You are given the information that the immediate boss of the member numbered
i
is the member numbered
A_i
. For each member, find how many immediate subordinates it has.
Constraints
2 \leq N \leq 2 \times 10^5
1 \leq A_i < i
Input
Input is given from Standard Input in the following format:
N
A_2
...
A_N
Output
For each of the members numbered
1, 2, ..., N
, print the number of immediate subordinates it has, in its own line.
Sample Input 1
5
1 1 2 2
Sample Output 1
2
2
0
0
0
The member numbered
1
has two immediate subordinates: the members numbered
2
and
3
.
The member numbered
2
has two immediate subordinates: the members numbered
4
and
5
.
The members numbered
3
,
4
, and
5
do not have immediate subordinates.
Sample Input 2
10
1 1 1 1 1 1 1 1 1
Sample Output 2
9
0
0
0
0
0
0
0
0
0
Sample Input 3
7
1 2 3 4 5 6
Sample Output 3
1
1
1
1
1
1
0
Problem Description: Score : 400 points
Problem Statement
We have
N+1
integers:
10^{100}
,
10^{100}+1
, ...,
10^{100}+N
.
We will choose
K
or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo
(10^9+7)
.
Constraints
1 \leq N \leq 2\times 10^5
1 \leq K \leq N+1
All values in input are integers.
Input
Input is given from Standard Input in the following format:
N
K
Output
Print the number of possible values of the sum, modulo
(10^9+7)
.
Sample Input 1
3 2
Sample Output 1
10
The sum can take
10
values, as follows:
(10^{100})+(10^{100}+1)=2\times 10^{100}+1
(10^{100})+(10^{100}+2)=2\times 10^{100}+2
(10^{100})+(10^{100}+3)=(10^{100}+1)+(10^{100}+2)=2\times 10^{100}+3
(10^{100}+1)+(10^{100}+3)=2\times 10^{100}+4
(10^{100}+2)+(10^{100}+3)=2\times 10^{100}+5
(10^{100})+(10^{100}+1)+(10^{100}+2)=3\times 10^{100}+3
(10^{100})+(10^{100}+1)+(10^{100}+3)=3\times 10^{100}+4
(10^{100})+(10^{100}+2)+(10^{100}+3)=3\times 10^{100}+5
(10^{100}+1)+(10^{100}+2)+(10^{100}+3)=3\times 10^{100}+6
(10^{100})+(10^{100}+1)+(10^{100}+2)+(10^{100}+3)=4\times 10^{100}+6
Sample Input 2
200000 200001
Sample Output 2
1
We must choose all of the integers, so the sum can take just
1
value.
Sample Input 3
141421 35623
Sample Output 3
220280457
Problem Description: Score : 500 points
Problem Statement
There are
N
children standing in a line from left to right. The activeness of the
i
-th child from the left is
A_i
.
You can rearrange these children just one time in any order you like.
When a child who originally occupies the
x
-th position from the left in the line moves to the
y
-th position from the left, that child earns
A_x \times |x-y|
happiness points.
Find the maximum total happiness points the children can earn.
Constraints
2 \leq N \leq 2000
1 \leq A_i \leq 10^9
All values in input are integers.
Input
Input is given from Standard Input in the following format:
N
A_1
A_2
...
A_N
Output
Print the maximum total happiness points the children can earn.
Sample Input 1
4
1 3 4 2
Sample Output 1
20
If we move the
1
-st child from the left to the
3
-rd position from the left, the
2
-nd child to the
4
-th position, the
3
-rd child to the
1
-st position, and the
4
-th child to the
2
-nd position, the children earns
1 \times |1-3|+3 \times |2-4|+4 \times |3-1|+2 \times |4-2|=20
happiness points in total.
Sample Input 2
6
5 5 6 1 1 1
Sample Output 2
58
Sample Input 3
6
8 6 9 1 2 1
Sample Output 3
85
Problem Description: Score : 200 points
Problem Statement
Let us define the
FizzBuzz sequence
a_1,a_2,...
as follows:
If both
3
and
5
divides
i
,
a_i=\mbox{FizzBuzz}
.
If the above does not hold but
3
divides
i
,
a_i=\mbox{Fizz}
.
If none of the above holds but
5
divides
i
,
a_i=\mbox{Buzz}
.
If none of the above holds,
a_i=i
.
Find the sum of all numbers among the first
N
terms of the FizzBuzz sequence.
Constraints
1 \leq N \leq 10^6
Input
Input is given from Standard Input in the following format:
N
Output
Print the sum of all numbers among the first
N
terms of the FizzBuzz sequence.
Sample Input 1
15
Sample Output 1
60
The first
15
terms of the FizzBuzz sequence are:
1,2,\mbox{Fizz},4,\mbox{Buzz},\mbox{Fizz},7,8,\mbox{Fizz},\mbox{Buzz},11,\mbox{Fizz},13,14,\mbox{FizzBuzz}
Among them, numbers are
1,2,4,7,8,11,13,14
, and the sum of them is
60
.
Sample Input 2
1000000
Sample Output 2
266666333332
Watch out for overflow.
Problem Description: Score : 300 points
Problem Statement
Find
\displaystyle{\sum_{a=1}^{K}\sum_{b=1}^{K}\sum_{c=1}^{K} \gcd(a,b,c)}
.
Here
\gcd(a,b,c)
denotes the greatest common divisor of
a
,
b
, and
c
.
Constraints
1 \leq K \leq 200
K
is an integer.
Input
Input is given from Standard Input in the following format:
K
Output
Print the value of
\displaystyle{\sum_{a=1}^{K}\sum_{b=1}^{K}\sum_{c=1}^{K} \gcd(a,b,c)}
.
Sample Input 1
2
Sample Output 1
9
\gcd(1,1,1)+\gcd(1,1,2)+\gcd(1,2,1)+\gcd(1,2,2)
+\gcd(2,1,1)+\gcd(2,1,2)+\gcd(2,2,1)+\gcd(2,2,2)
=1+1+1+1+1+1+1+2=9
Thus, the answer is
9
.
Sample Input 2
200
Sample Output 2
10813692
Problem Description: Score : 400 points
Problem Statement
We have a string
S
of length
N
consisting of
R
,
G
, and
B
.
Find the number of triples
(i,~j,~k)~(1 \leq i < j < k \leq N)
that satisfy both of the following conditions:
S_i \neq S_j
,
S_i \neq S_k
, and
S_j \neq S_k
.
j - i \neq k - j
.
Constraints
1 \leq N \leq 4000
S
is a string of length
N
consisting of
R
,
G
, and
B
.
Input
Input is given from Standard Input in the following format:
N
S
Output
Print the number of triplets in question.
Sample Input 1
4
RRGB
Sample Output 1
1
Only the triplet
(1,~3,~4)
satisfies both conditions. The triplet
(2,~3,~4)
satisfies the first condition but not the second, so it does not count.
Sample Input 2
39
RBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBB
Sample Output 2
1800
Problem Description: Score : 600 points
Problem Statement
Given is an integer sequence
A_1, ..., A_N
of length
N
.
We will choose exactly
\left\lfloor \frac{N}{2} \right\rfloor
elements from this sequence so that no two adjacent elements are chosen.
Find the maximum possible sum of the chosen elements.
Here
\lfloor x \rfloor
denotes the greatest integer not greater than
x
.
Constraints
2 \leq N \leq 2\times 10^5
|A_i|\leq 10^9
All values in input are integers.
Input
Input is given from Standard Input in the following format:
N
A_1
...
A_N
Output
Print the maximum possible sum of the chosen elements.
Sample Input 1
6
1 2 3 4 5 6
Sample Output 1
12
Choosing
2
,
4
, and
6
makes the sum
12
, which is the maximum possible value.
Sample Input 2
5
-1000 -100 -10 0 10
Sample Output 2
0
Choosing
-10
and
10
makes the sum
0
, which is the maximum possible value.
Sample Input 3
10
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000
Sample Output 3
5000000000
Watch out for overflow.
Sample Input 4
27
18 -28 18 28 -45 90 -45 23 -53 60 28 -74 -71 35 -26 -62 49 -77 57 24 -70 -93 69 -99 59 57 -49
Sample Output 4
295
Problem Description: Score : 100 points
Problem Statement
We have three boxes
A
,
B
, and
C
, each of which contains an integer.
Currently, the boxes
A
,
B
, and
C
contain the integers
X
,
Y
, and
Z
, respectively.
We will now do the operations below in order. Find the content of each box afterward.
Swap the contents of the boxes
A
and
B
Swap the contents of the boxes
A
and
C
Constraints
1 \leq X,Y,Z \leq 100
All values in input are integers.
Input
Input is given from Standard Input in the following format:
X
Y
Z
Output
Print the integers contained in the boxes
A
,
B
, and
C
, in this order, with space in between.
Sample Input 1
1 2 3
Sample Output 1
3 1 2
After the contents of the boxes
A
and
B
are swapped,
A
,
B
, and
C
contain
2
,
1
, and
3
, respectively.
Then, after the contents of
A
and
C
are swapped,
A
,
B
, and
C
contain
3
,
1
, and
2
, respectively.
Sample Input 2
100 100 100
Sample Output 2
100 100 100
Sample Input 3
41 59 31
Sample Output 3
31 41 59
Problem Description: Score : 300 points
Problem Statement
Given any integer
x
, Aoki can do the operation below.
Operation: Replace
x
with the absolute difference of
x
and
K
.
You are given the initial value of an integer
N
. Find the minimum possible value taken by
N
after Aoki does the operation zero or more times.
Constraints
0 ≤ N ≤ 10^{18}
1 ≤ K ≤ 10^{18}
All values in input are integers.
Input
Input is given from Standard Input in the following format:
N
K
Output
Print the minimum possible value taken by
N
after Aoki does the operation zero or more times.
Sample Input 1
7 4
Sample Output 1
1
Initially,
N=7
.
After one operation,
N
becomes
|7-4| = 3
.
After two operations,
N
becomes
|3-4| = 1
, which is the minimum value taken by
N
.
Sample Input 2
2 6
Sample Output 2
2
N=2
after zero operations is the minimum.
Sample Input 3
1000000000000000000 1
Sample Output 3
0
Problem Description: Score : 400 points
Problem Statement
A positive integer
X
is said to be a lunlun number if and only if the following condition is satisfied:
In the base ten representation of
X
(without leading zeros), for every pair of two adjacent digits, the absolute difference of those digits is at most
1
.
For example,
1234
,
1
, and
334
are lunlun numbers, while none of
31415
,
119
, or
13579
is.
You are given a positive integer
K
. Find the
K
-th smallest lunlun number.
Constraints
1 \leq K \leq 10^5
All values in input are integers.
Input
Input is given from Standard Input in the following format:
K
Output
Print the answer.
Sample Input 1
15
Sample Output 1
23
We will list the
15
smallest lunlun numbers in ascending order:
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
,
11
,
12
,
21
,
22
,
23
.
Thus, the answer is
23
.
Sample Input 2
1
Sample Output 2
1
Sample Input 3
13
Sample Output 3
21
Sample Input 4
100000
Sample Output 4
3234566667
Note that the answer may not fit into the
32
-bit signed integer type.
Problem Description: Score : 500 points
Problem Statement
Takahashi has decided to work on
K
days of his choice from the
N
days starting with tomorrow.
You are given an integer
C
and a string
S
. Takahashi will choose his workdays as follows:
After working for a day, he will refrain from working on the subsequent
C
days.
If the
i
-th character of
S
is
x
, he will not work on Day
i
, where Day
1
is tomorrow, Day
2
is the day after tomorrow, and so on.
Find all days on which Takahashi is bound to work.
Constraints
1 \leq N \leq 2 \times 10^5
1 \leq K \leq N
0 \leq C \leq N
The length of
S
is
N
.
Each character of
S
is
o
or
x
.
Takahashi can choose his workdays so that the conditions in Problem Statement are satisfied.
Input
Input is given from Standard Input in the following format:
N
K
C
S
Output
Print all days on which Takahashi is bound to work in ascending order, one per line.
Sample Input 1
11 3 2
ooxxxoxxxoo
Sample Output 1
6
Takahashi is going to work on
3
days out of the
11
days. After working for a day, he will refrain from working on the subsequent
2
days.
There are four possible choices for his workdays: Day
1,6,10
, Day
1,6,11
, Day
2,6,10
, and Day
2,6,11
.
Thus, he is bound to work on Day
6
.
Sample Input 2
5 2 3
ooxoo
Sample Output 2
1
5
There is only one possible choice for his workdays: Day
1,5
.
Sample Input 3
5 1 0
ooooo
Sample Output 3
There may be no days on which he is bound to work.
Sample Input 4
16 4 3
ooxxoxoxxxoxoxxo
Sample Output 4
11
16
Problem Description: Score : 600 points
Problem Statement
Given is a positive integer
N
.
We will choose an integer
K
between
2
and
N
(inclusive), then we will repeat the operation below until
N
becomes less than
K
.
Operation: if
K
divides
N
, replace
N
with
N/K
; otherwise, replace
N
with
N-K
.
In how many choices of
K
will
N
become
1
in the end?
Constraints
2 \leq N \leq 10^{12}
N
is an integer.
Input
Input is given from Standard Input in the following format:
N
Output
Print the number of choices of
K
in which
N
becomes
1
in the end.
Sample Input 1
6
Sample Output 1
3
There are three choices of
K
in which
N
becomes
1
in the end:
2
,
5
, and
6
.
In each of these choices,
N
will change as follows:
When
K=2
:
6 \to 3 \to 1
When
K=5
:
6 \to 1
When
K=6
:
6 \to 1
Sample Input 2
3141
Sample Output 2
13
Sample Input 3
314159265358
Sample Output 3
9
Problem Description: Score : 100 points
Problem Statement
A string of length
6
consisting of lowercase English letters is said to be coffee-like if and only if its
3
-rd and
4
-th characters are equal and its
5
-th and
6
-th characters are also equal.
Given a string
S
, determine whether it is coffee-like.
Constraints
S
is a string of length
6
consisting of lowercase English letters.
Input
Input is given from Standard Input in the following format:
S
Output
If
S
is coffee-like, print
Yes
; otherwise, print
No
.
Sample Input 1
sippuu
Sample Output 1
Yes
In
sippuu
, the
3
-rd and
4
-th characters are equal, and the
5
-th and
6
-th characters are also equal.
Sample Input 2
iphone
Sample Output 2
No
Sample Input 3
coffee
Sample Output 3
Yes
Problem Description: Score : 200 points
Problem Statement
Takahashi loves gold coins. He gains
1000
happiness points
for each
500
-yen coin he has and gains
5
happiness points for each
5
-yen coin he has. (Yen is the currency of Japan.)
Takahashi has
X
yen. If he exchanges his money so that he will gain the most happiness points, how many happiness points will he earn?
(We assume that there are six kinds of coins available:
500
-yen,
100
-yen,
50
-yen,
10
-yen,
5
-yen, and
1
-yen coins.)
Constraints
0 \leq X \leq 10^9
X
is an integer.
Input
Input is given from Standard Input in the following format:
X
Output
Print the maximum number of happiness points that can be earned.
Sample Input 1
1024
Sample Output 1
2020
By exchanging his money so that he gets two
500
-yen coins and four
5
-yen coins, he gains
2020
happiness points, which is the maximum number of happiness points that can be earned.
Sample Input 2
0
Sample Output 2
0
He is penniless - or yenless.
Sample Input 3
1000000000
Sample Output 3
2000000000
He is a billionaire - in yen.