Codeforces Round 404 (Div. 2)


A. Anton and Polyhedrons
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
Icosahedron
Cube
Tetrahedron
Dodecahedron
Output
42
Input
3
Dodecahedron
Octahedron
Octahedron
Output
28
----------------------------------------------------------------------------------------------------
B. Anton and Classes
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1 5
2 6
2 3
2
2 4
6 8
Output
3
Input
3
1 5
2 6
3 7
2
2 4
1 4
Output
0
----------------------------------------------------------------------------------------------------
C. Anton and Fairy Tale
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 2
Output
4
Input
8 1
Output
5
----------------------------------------------------------------------------------------------------
D. Anton and School - 2
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
)(()()
Output
6
Input
()()()
Output
7
Input
)))
Output
0
----------------------------------------------------------------------------------------------------
E. Anton and Permutation
time limit per test: 4 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

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