Educational Codeforces Round 74 (Rated for Div. 2)


A. Prime Subtraction
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
100 98
42 32
1000000000000000000 1
41 40
Output
YES
YES
YES
NO
----------------------------------------------------------------------------------------------------
B. Kill 'Em All
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
3 2
1 3 5
4 1
5 2 3 5
Output
2
2
----------------------------------------------------------------------------------------------------
C. Standard Free2play
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
3 2
3 1
8 6
8 7 6 5 3 2
9 6
9 8 5 4 3 1
1 1
1
Output
0
1
2
0
----------------------------------------------------------------------------------------------------
D. AB-string
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
AABBB
Output
6
Input
3
AAA
Output
3
Input
7
AAABABB
Output
15
----------------------------------------------------------------------------------------------------
E. Keyboard Purchase
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6 3
aacabc
Output
5
Input
6 4
aaaaaa
Output
0
Input
15 4
abacabadabacaba
Output
16
----------------------------------------------------------------------------------------------------
F. The Maximum Subtree
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1
10
1 2
1 3
1 4
2 5
2 6
3 7
3 8
4 9
4 10
Output
8
----------------------------------------------------------------------------------------------------
G. Adilbek and the Watering System
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
1 5 4 2
2 4 2
0 4 5 4
2 5 3 1
1 2 4
3 1 3
2 3 5 1
2 1 1
1 4 3
Output
6
0
-1
4
----------------------------------------------------------------------------------------------------
