Codecraft-17 and Codeforces Round 391 (Div. 1 + Div. 2, combined)


A. Gotta Catch Em' All!
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
Bulbbasaur
Output
1
Input
F
Output
0
Input
aBddulbasaurrgndgbualdBdsagaurrgndbb
Output
2
----------------------------------------------------------------------------------------------------
B. Bash's Big Day
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3
2 3 4
Output
2
Input
5
2 3 4 6 7
Output
3
----------------------------------------------------------------------------------------------------
C. Felicity is Coming!
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 3
2 1 2
2 2 3
Output
1
Input
1 3
3 1 2 3
Output
6
Input
2 4
2 1 2
3 2 3 4
Output
2
Input
2 2
3 2 2 1
2 1 2
Output
1
Input
3 7
2 1 2
2 3 4
3 5 6 7
Output
24
----------------------------------------------------------------------------------------------------
D. Felicity's Big Secret Revealed
time limit per test: 4 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
4
1011
Output
10
Input
2
10
Output
1
----------------------------------------------------------------------------------------------------
E. Bash Plays with Functions
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
0 30
1 25
3 65
2 5
4 48
Output
8
5
25
4
630
----------------------------------------------------------------------------------------------------
F. Team Rocket Rises Again
time limit per test: 2.5 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
4 4 3
1 2 1
2 3 1
2 4 1
3 1 1
Output
2
Input
7 11 2
1 2 5
1 3 5
2 4 2
2 5 2
3 6 3
3 7 3
4 6 2
3 4 2
6 7 3
4 5 7
4 7 7
Output
4
----------------------------------------------------------------------------------------------------
G. Can Bash Save the Day?
time limit per test: 5 seconds
memory limit per test: 768 megabytes
input: standard input
output: standard output

Examples
Input
5 5
4 5 1 3 2
4 2 4
1 3 9
4 1 4
4 5 2
1
1 5 4
1
22 20 20
2
38
2
39
1
36 38 38
Output
23
37
28
----------------------------------------------------------------------------------------------------
