Codeforces Round 407 (Div. 2)


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

Examples
Input
3 2
2 3 4
Output
3
Input
5 4
3 1 8 9 7
Output
5
----------------------------------------------------------------------------------------------------
B. Masha and geometric depression
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 2 30 4
6 14 25 48
Output
3
Input
123 1 2143435 4
123 11 -5453 141245
Output
0
Input
123 1 2143435 4
54343 -13 6 124
Output
inf
----------------------------------------------------------------------------------------------------
C. Functions again
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
1 4 2 3 1
Output
3
Input
4
1 5 4 7
Output
6
----------------------------------------------------------------------------------------------------
D. Weird journey
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 4
1 2
1 3
1 4
1 5
Output
6
Input
5 3
1 2
2 3
4 5
Output
0
Input
2 2
1 1
1 2
Output
1
----------------------------------------------------------------------------------------------------
E. The Great Mixing
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
400 4
100 300 450 500
Output
2
Input
50 2
100 25
Output
3
----------------------------------------------------------------------------------------------------
