Codeforces Round 295 (Div. 1)


A. DNA Alignment
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1
C
Output
1
Input
2
AG
Output
4
Input
3
TTT
Output
1
----------------------------------------------------------------------------------------------------
B. Cubes
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
2 1
1 0
0 1
Output
19
Input
5
0 0
0 1
0 2
0 3
0 4
Output
2930
----------------------------------------------------------------------------------------------------
C. Pluses everywhere
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 1
108
Output
27
Input
3 2
108
Output
9
----------------------------------------------------------------------------------------------------
D. Shop
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 4 3
13 20
1 1 14
1 2 30
2 1 6
3 2 2
Output
3
2 3 4
----------------------------------------------------------------------------------------------------
E. Cycling City
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 4
1 2
2 3
3 4
4 1
Output
NO
Input
5 6
1 2
1 3
1 4
2 5
3 5
4 5
Output
YES
3 5 4 1
3 5 3 1
3 5 2 1
----------------------------------------------------------------------------------------------------
