Codeforces Round 158 (Div. 2)


A. Adding Digits
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 4 5
Output
524848
Input
12 11 1
Output
121
Input
260 150 10
Output
-1
----------------------------------------------------------------------------------------------------
B. Ancient Prophesy
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
777-444---21-12-2013-12-2013-12-2013---444-777
Output
13-12-2013
----------------------------------------------------------------------------------------------------
C. Balls and Boxes
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 4
4 3 1 6
Output
3 2 5 4 
Input
5 2
3 2 0 2 7
Output
2 1 4 1 6 
Input
3 3
2 3 1
Output
1 2 3 
----------------------------------------------------------------------------------------------------
D. Black and White Tree
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

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

Examples
Input
9
1 1
1 2
1 3
2 1
2 2
2 3
3 1
3 2
3 3
1 1 1 1 1 1 1 1 1
Output
1.5000000000 2.5000000000
1.5000000000 2.5000000000
Input
15
4 4
-1 -3
1 5
3 -4
-4 4
-1 1
3 -3
-4 -5
-3 3
3 2
4 1
-4 2
-2 -5
-3 4
-1 4
2 1 2 1 2 1 3 2 1
Output
-3.5000000000 2.0000000000
3.5000000000 -1.0000000000
Input
10
-2 10
6 0
-16 -6
-4 13
-4 -2
-17 -10
9 15
18 16
-5 2
10 -5
2 1 1 1 1 1 1 1 1
Output
-1
----------------------------------------------------------------------------------------------------
