Codeforces Beta Round 17


A. Noldbach problem
time limit per test: 2 seconds
memory limit per test: 64 megabytes
input: standard input
output: standard output

Examples
Input
27 2
Output
YES
Input
45 7
Output
NO
----------------------------------------------------------------------------------------------------
B. Hierarchy
time limit per test: 2 seconds
memory limit per test: 64 megabytes
input: standard input
output: standard output

Examples
Input
4
7 2 3 1
4
1 2 5
2 4 1
3 4 1
1 3 5
Output
11
Input
3
1 2 3
2
3 1 2
3 1 3
Output
-1
----------------------------------------------------------------------------------------------------
C. Balance
time limit per test: 3 seconds
memory limit per test: 128 megabytes
input: standard input
output: standard output

Examples
Input
4
abca
Output
7
Input
4
abbc
Output
3
Input
2
ab
Output
1
----------------------------------------------------------------------------------------------------
D. Notepad
time limit per test: 2 seconds
memory limit per test: 64 megabytes
input: standard input
output: standard output

Examples
Input
2 3 3
Output
1
Input
2 3 4
Output
4
----------------------------------------------------------------------------------------------------
E. Palisection
time limit per test: 2 seconds
memory limit per test: 128 megabytes
input: standard input
output: standard output

Examples
Input
4
babb
Output
6
Input
2
aa
Output
2
----------------------------------------------------------------------------------------------------
