Codeforces Round 310 (Div. 2)


A. Case of the Zeros and Ones
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
1100
Output
0
Input
5
01010
Output
1
Input
8
11101111
Output
6
----------------------------------------------------------------------------------------------------
B. Case of Fake Numbers
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1 0 0
Output
Yes
Input
5
4 2 1 4 3
Output
Yes
Input
4
0 2 3 1
Output
No
----------------------------------------------------------------------------------------------------
C. Case of Matryoshkas
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 2
2 1 2
1 3
Output
1
Input
7 3
3 1 3 7
2 2 5
2 4 6
Output
10
----------------------------------------------------------------------------------------------------
D. Case of Fugitive
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 4
1 4
7 8
9 10
12 14
4 5 3 8
Output
Yes
2 3 1 
Input
2 2
11 14
17 18
2 9
Output
No
Input
2 1
1 1
1000000000000000000 1000000000000000000
999999999999999999
Output
Yes
1 
----------------------------------------------------------------------------------------------------
E. Case of Chocolate
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6 5
3 4 U
6 1 L
2 5 L
1 6 U
4 3 U
Output
4
3
2
1
2
Input
10 6
2 9 U
10 1 U
1 10 U
8 3 L
10 1 L
6 5 U
Output
9
1
10
6
0
2
----------------------------------------------------------------------------------------------------
