Codeforces Beta Round 22 (Div. 2 Only)


A. Second Order Statistics
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
1 2 2 -4
Output
1
Input
5
1 2 3 1 1
Output
2
----------------------------------------------------------------------------------------------------
B. Bargaining Table
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 3
000
010
000
Output
8
Input
5 4
1100
0000
0000
0000
0000
Output
16
----------------------------------------------------------------------------------------------------
C. System Administrator
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 6 3
Output
1 2
2 3
3 4
4 5
1 3
3 5
Input
6 100 1
Output
-1
----------------------------------------------------------------------------------------------------
D. Segments
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

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

Examples
Input
3
3 3 2
Output
1
3 1
Input
7
2 3 1 3 4 4 1
Output
3
2 5
2 6
3 7
----------------------------------------------------------------------------------------------------
