Codeforces Round 378 (Div. 2)


A. Grasshopper And the String
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
ABABBBACFEYUKOTT
Output
4
Input
AAA
Output
1
----------------------------------------------------------------------------------------------------
B. Parade
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
5 6
8 9
10 3
Output
3
Input
2
6 5
5 6
Output
1
Input
6
5 9
1 3
4 8
4 5
23 54
12 32
Output
0
----------------------------------------------------------------------------------------------------
C. Epidemic in Monstropolis
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
1 2 2 2 1 2
2
5 5
Output
YES
2 L
1 R
4 L
3 L
Input
5
1 2 3 4 5
1
15
Output
YES
5 L
4 L
3 L
2 L
Input
5
1 1 1 3 3
3
2 1 6
Output
NO
----------------------------------------------------------------------------------------------------
D. Kostya the Sculptor
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
5 5 5
3 2 4
1 4 1
2 1 3
3 2 4
3 3 4
Output
1
1
Input
7
10 7 8
5 10 3
4 2 6
5 5 5
10 2 8
4 2 1
7 7 7
Output
2
1 5
----------------------------------------------------------------------------------------------------
E. Sleep in Class
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
UUD
Output
5 6 3 
Input
10
UUDUDUUDDU
Output
5 12 23 34 36 27 18 11 6 1 
----------------------------------------------------------------------------------------------------
F. Drivers Dissatisfaction
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6 9
1 3 1 1 3 1 2 2 2
4 1 4 2 2 5 3 1 6
1 2
1 3
2 3
2 4
2 5
3 5
3 6
4 5
5 6
7
Output
0
1 1
3 1
6 1
7 2
8 -5
Input
3 3
9 5 1
7 7 2
2 1
3 1
3 2
2
Output
5
3 0
2 5
----------------------------------------------------------------------------------------------------
