Codeforces Round 230 (Div. 1)


A. Blocked Points
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1
Output
4
Input
2
Output
8
Input
3
Output
16
----------------------------------------------------------------------------------------------------
B. Tower of Hanoi
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
0 1 1
1 0 1
1 1 0
3
Output
7
Input
0 2 2
1 0 100
1 2 0
3
Output
19
Input
0 2 1
1 0 100
1 2 0
5
Output
87
----------------------------------------------------------------------------------------------------
C. Yet Another Number Sequence
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1 1
Output
1
Input
4 1
Output
34
Input
5 2
Output
316
Input
7 4
Output
73825
----------------------------------------------------------------------------------------------------
D. Three Arrays
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1 1 101
1 2 1
3 2 1
Output
5
Input
5
1 1 2 2 3
2 2 4 3 3
3 3 1 1 1
Output
5
----------------------------------------------------------------------------------------------------
E. Deleting Substrings
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
0 0 3
1 2 1
Output
3
Input
6
1 4 5 6 7 1000
2 1 1 2 2 3
Output
12
----------------------------------------------------------------------------------------------------
