Educational Codeforces Round 129 (Rated for Div. 2)


A. Game with Cards
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
1
6
2
6 8
4
1 3 3 7
2
4 2
1
50
2
25 50
10
1 2 3 4 5 6 7 8 9 10
2
5 15
Output
Bob
Bob
Alice
Alice
Alice
Bob
Bob
Bob
----------------------------------------------------------------------------------------------------
B. Card Trick
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

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

Examples
Input
3
2
1 2
1 2
2
2 1
1 2
4
2 3 1 2
2 3 2 3
Output
0
-1
3
3 1
3 2
4 3
----------------------------------------------------------------------------------------------------
D. Required Length
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
2 1
Output
-1
Input
3 2
Output
4
Input
13 42
Output
12
----------------------------------------------------------------------------------------------------
E. Labyrinth Adventures
time limit per test: 6 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
2
1 1 1 1
10
1 1 1 1
1 1 1 2
1 1 2 1
1 1 2 2
1 2 1 2
1 2 2 1
1 2 2 2
2 1 2 1
2 1 2 2
2 2 2 2
Output
0
1
1
2
0
2
1
0
1
0
Input
4
1 1 1 1
2 1 2 2
3 2 1 3
5
2 4 4 3
4 4 3 3
1 2 3 3
2 2 4 4
1 4 2 3
Output
3
4
3
6
2
----------------------------------------------------------------------------------------------------
F. Unique Occurrences
time limit per test: 6 seconds
memory limit per test: 1024 megabytes
input: standard input
output: standard output

Examples
Input
3
1 2 1
1 3 2
Output
4
Input
3
1 2 2
1 3 2
Output
2
Input
5
1 4 4
1 2 3
3 4 4
4 5 5
Output
14
Input
2
2 1 1
Output
1
Input
10
10 2 3
3 8 8
4 8 9
5 8 5
3 10 7
7 8 2
5 6 6
9 3 4
1 6 3
Output
120
----------------------------------------------------------------------------------------------------
