Codeforces Round 405 (rated, Div. 1, based on VK Cup 2017 Round 1)


A. Bear and Different Names
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
8 3
NO NO YES YES YES NO
Output
Adam Bob Bob Cpqepqwer Limak Adam Bob Adam
Input
9 8
YES NO
Output
R Q Ccccccccc Ccocc Ccc So Strong Samples Ccc
Input
3 2
NO NO
Output
Na Na Na
----------------------------------------------------------------------------------------------------
B. Bear and Tree Jumps
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6 2
1 2
1 3
2 4
2 5
4 6
Output
20
Input
13 3
1 2
3 2
4 2
5 2
3 6
10 6
6 7
6 13
5 8
5 9
9 11
11 12
Output
114
Input
3 5
2 1
3 1
Output
3
----------------------------------------------------------------------------------------------------
C. Bear and Company
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
VKVK
Output
3
Input
5
BVVKV
Output
2
Input
7
VVKEVKK
Output
3
Input
20
VKVKVVVKVOVKVQKKKVVK
Output
8
Input
5
LIMAK
Output
0
----------------------------------------------------------------------------------------------------
D. Bear and Rectangle Strips
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
70 70 70 70 70 -15
90 -60 -30 30 -30 15
Output
3
Input
4
0 -1 0 0
0 0 1 0
Output
6
Input
3
1000000000 999999999 -1000000000
999999999 -1000000000 -999999998
Output
1
----------------------------------------------------------------------------------------------------
E. Bear and Isomorphic Points
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
4
5 3
0 1
10 1
3 51
3
-999123 700000
-950000 123456
-950000 987654
3
2 3
10 -1
-4 6
5
1 3
5 2
6 1
4 4
-3 3
Output
250.000000000000
100000000000.000000000000
0.000000000000
6.562500000000
----------------------------------------------------------------------------------------------------
