Codeforces Round 104 (Div. 1)


A. Lucky Conversion
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
47
74
Output
1
Input
774
744
Output
1
Input
777
444
Output
3
----------------------------------------------------------------------------------------------------
B. Lucky Number 2
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 2 1 1
Output
4774
Input
4 7 3 1
Output
-1
----------------------------------------------------------------------------------------------------
C. Lucky Subsequence
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 2
10 10 10
Output
3
Input
4 2
4 4 7 7
Output
4
----------------------------------------------------------------------------------------------------
D. Lucky Pair
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
1 4 2 4
Output
9
Input
2
4 7
Output
1
Input
4
4 4 7 7
Output
9
----------------------------------------------------------------------------------------------------
E. Lucky Queries
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 3
47
count
switch 1 2
count
Output
2
1
Input
3 5
747
count
switch 1 1
count
switch 1 3
count
Output
2
3
2
----------------------------------------------------------------------------------------------------
