Codeforces Round 104 (Div. 2)


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

Examples
Input
2
47
Output
NO
Input
4
4738
Output
NO
Input
4
4774
Output
YES
----------------------------------------------------------------------------------------------------
B. Lucky Mask
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1 7
Output
7
Input
100 47
Output
147
----------------------------------------------------------------------------------------------------
C. 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
----------------------------------------------------------------------------------------------------
D. 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
----------------------------------------------------------------------------------------------------
E. 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
----------------------------------------------------------------------------------------------------
