Codeforces Round #Pi (Div. 2)


A. Lineland Mail
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
-5 -2 2 7
Output
3 12
3 9
4 7
5 12
Input
2
-1 1
Output
2 2
2 2
----------------------------------------------------------------------------------------------------
B. Berland National Library
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
+ 12001
- 12001
- 1
- 1200
+ 1
+ 7
Output
3
Input
2
- 1
- 2
Output
2
Input
2
+ 1
- 1
Output
1
----------------------------------------------------------------------------------------------------
C. Geometric Progression
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 2
1 1 2 2 4
Output
4
Input
3 1
1 1 1
Output
1
Input
10 3
1 2 6 2 3 6 9 18 3 9
Output
6
----------------------------------------------------------------------------------------------------
D. One-Dimensional Battle Ships
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
11 3 3
5
4 8 6 1 11
Output
3
Input
5 1 3
2
1 5
Output
-1
Input
5 1 3
1
3
Output
1
----------------------------------------------------------------------------------------------------
E. President and Roads
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6 7 1 6
1 2 2
1 3 10
2 3 7
2 4 8
3 5 3
4 5 2
5 6 1
Output
YES
CAN 2
CAN 1
CAN 1
CAN 1
CAN 1
YES
Input
3 3 1 3
1 2 10
2 3 10
1 3 100
Output
YES
YES
CAN 81
Input
2 2 1 2
1 2 1
1 2 2
Output
YES
NO
----------------------------------------------------------------------------------------------------
F. Mausoleum
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 0
Output
9
Input
3 1
2 > 3
Output
1
Input
4 1
3 = 6
Output
3
----------------------------------------------------------------------------------------------------
