Codeforces Round 340 (Div. 2)


A. Elephant
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
Output
1
Input
12
Output
3
----------------------------------------------------------------------------------------------------
B. Chocolate
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
0 1 0
Output
1
Input
5
1 0 1 0 1
Output
4
----------------------------------------------------------------------------------------------------
C. Watering Flowers
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 -1 0 5 3
0 2
5 2
Output
6
Input
4 0 0 5 0
9 4
8 3
-1 0
1 4
Output
33
----------------------------------------------------------------------------------------------------
D. Polyline
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1 -1
1 1
1 2
Output
1
Input
-1 -1
-1 3
4 3
Output
2
Input
1 1
2 3
3 2
Output
3
----------------------------------------------------------------------------------------------------
E. XOR and Favorite Number
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

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