Codeforces Round 493 (Div. 1)


A. Convert to Ones
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 1 10
01000
Output
11
Input
5 10 1
01000
Output
2
Input
7 2 3
1111111
Output
0
----------------------------------------------------------------------------------------------------
B. Roman Digits
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1
Output
4
Input
2
Output
10
Input
10
Output
244
----------------------------------------------------------------------------------------------------
C. Sky Full of Stars
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1
Output
3
Input
2
Output
63
Input
3
Output
9933
----------------------------------------------------------------------------------------------------
D. Cycles in product
time limit per test: 7 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 2 2
1 2
1 2
Output
8
Input
2 2 4
1 2
1 2
Output
32
Input
2 3 4
1 2
1 2
1 3
Output
70
Input
4 2 2
1 2
1 3
1 4
1 2
Output
20
----------------------------------------------------------------------------------------------------
E. Good Subsegments
time limit per test: 7 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
5
1 3 2 5 4
15
1 1
1 2
1 3
1 4
1 5
2 2
2 3
2 4
2 5
3 3
3 4
3 5
4 4
4 5
5 5
Output
1
2
5
6
10
1
3
4
7
1
2
4
1
3
1
----------------------------------------------------------------------------------------------------
