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


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

Examples
Input
4 7
Output
2
Input
4 9
Output
3
Input
1 1
Output
1
----------------------------------------------------------------------------------------------------
B. Bear and Friendship Condition
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 3
1 3
3 4
1 4
Output
YES
Input
4 4
3 1
2 3
3 4
1 2
Output
NO
Input
10 4
4 3
5 10
8 9
1 2
Output
YES
Input
3 2
1 2
2 3
Output
NO
----------------------------------------------------------------------------------------------------
C. 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
----------------------------------------------------------------------------------------------------
D. 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
----------------------------------------------------------------------------------------------------
E. 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
----------------------------------------------------------------------------------------------------
