Codeforces Round 226 (Div. 2)


A. Bear and Raspberry
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 1
5 10 7 3 20
Output
3
Input
6 2
100 1 10 40 10 40
Output
97
Input
3 0
1 2 3
Output
0
----------------------------------------------------------------------------------------------------
B. Bear and Strings
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
bearbtear
Output
6
Input
bearaabearc
Output
20
----------------------------------------------------------------------------------------------------
C. Bear and Prime Numbers
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
6
5 5 7 10 14 15
3
2 11
3 12
4 4
Output
9
7
0
Input
7
2 3 5 7 11 4 8
2
8 10
2 123
Output
0
7
----------------------------------------------------------------------------------------------------
D. Bear and Floodlight
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 3 5
3 1 45
5 1 45
Output
2.000000000
Input
1 0 1
1 1 30
Output
0.732050808
Input
1 0 1
1 1 45
Output
1.000000000
Input
1 0 2
0 2 90
Output
2.000000000
----------------------------------------------------------------------------------------------------
E. Bear in the Field
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

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