Codeforces Round 322 (Div. 2)


A. Vasya the Hipster
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 1
Output
1 1
Input
2 3
Output
2 0
Input
7 3
Output
3 2
----------------------------------------------------------------------------------------------------
B. Luxurious Houses
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
1 2 3 1 2
Output
3 2 0 2 0 
Input
4
3 2 1 4
Output
2 3 4 0 
----------------------------------------------------------------------------------------------------
C. Developing Skills
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 4
7 9
Output
2
Input
3 8
17 15 19
Output
5
Input
2 2
99 100
Output
20
----------------------------------------------------------------------------------------------------
D. Three Logos
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 1 2 5 5 2
Output
5
AAAAA
BBBBB
BBBBB
CCCCC
CCCCC
Input
4 4 2 6 4 2
Output
6
BBBBBB
BBBBBB
AAAACC
AAAACC
AAAACC
AAAACC
----------------------------------------------------------------------------------------------------
E. Kojiro and Furrari
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
8 4 1 1
2 4
0
Output
0 4
Input
9 3 2 3
2 3
1 6
-1 0 1
Output
-1 -1
3 3
3 2
Input
20 9 2 4
1 5
2 10
-1 0 1 2
Output
-1 -1
-1 -1
-1 -1
-1 -1
----------------------------------------------------------------------------------------------------
F. Zublicanes and Mumocrates
time limit per test: 3 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

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