Codeforces Round 543 (Div. 2, based on Technocup 2019 Final Round)


A. Technogoblet of Fire
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7 3 1
1 5 3 4 6 7 2
1 3 1 2 1 2 3
3
Output
1
Input
8 4 4
1 2 3 4 5 6 7 8
4 3 2 1 4 3 2 1
3 4 5 6
Output
2
----------------------------------------------------------------------------------------------------
B. Mike and Children
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
8
1 8 3 11 4 9 2 7
Output
3
Input
7
3 1 7 11 9 2 12
Output
2
----------------------------------------------------------------------------------------------------
C. System Testing
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 2
49 100
Output
1
Input
4 2
32 100 33 1
Output
2
Input
14 5
48 19 6 9 50 20 3 42 38 43 36 21 44 6
Output
5
----------------------------------------------------------------------------------------------------
D. Diana and Liana
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7 3 2 2
1 2 3 3 2 1 2
2 2
Output
1
4 
Input
13 4 3 3
3 2 6 4 1 4 4 7 1 3 3 2 4
4 3 4
Output
-1
Input
13 4 1 3
3 2 6 4 1 4 4 7 1 3 3 2 4
4 3 4
Output
9
1 2 3 4 5 9 11 12 13
----------------------------------------------------------------------------------------------------
E. Once in a casino
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
223
322
Output
2
1 1
2 -1
Input
2
20
42
Output
2
1 1
1 1
Input
2
35
44
Output
-1
----------------------------------------------------------------------------------------------------
F. Compress String
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 3 1
aba
Output
7
Input
4 1 1
abcd
Output
4
Input
4 10 1
aaaa
Output
12
----------------------------------------------------------------------------------------------------
