Codeforces Round 229 (Div. 2)


A. Inna and Alarm Clock
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
0 0
0 1
0 2
1 0
Output
2
Input
4
0 0
0 1
1 0
1 1
Output
2
Input
4
1 1
1 2
2 3
3 3
Output
3
----------------------------------------------------------------------------------------------------
B. Inna, Dima and Song
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1 1 2
2 2 3
Output
4
Input
1
2
5
Output
-1
----------------------------------------------------------------------------------------------------
C. Inna and Candy Boxes
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
10 3 3
1010100011
1 3
1 6
4 9
Output
1
3
2
----------------------------------------------------------------------------------------------------
D. Inna and Sweet Matrix
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 4 4
Output
8
(1,1) (2,1) (2,2)
(1,1) (1,2)
(1,1) (2,1)
(1,1)
----------------------------------------------------------------------------------------------------
E. Inna and Large Sweet Matrix
time limit per test: 1 second
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
4 5 5
0 1 1 2 3 2
0 2 2 3 3 3
0 1 5 4 5 1
1 2 3 3 4
1 3 4 3 4
Output
2
-21
----------------------------------------------------------------------------------------------------
