Codeforces Round 153 (Div. 1)


A. Points on Line
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 3
1 2 3 4
Output
4
Input
4 2
-3 -2 -1 0
Output
2
Input
5 19
1 10 20 30 50
Output
1
----------------------------------------------------------------------------------------------------
B. Playing with Permutations
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 1
2 3 4 1
1 2 3 4
Output
NO
Input
4 1
4 3 1 2
3 4 2 1
Output
YES
Input
4 3
4 3 1 2
3 4 2 1
Output
YES
Input
4 2
4 3 1 2
2 1 4 3
Output
YES
Input
4 1
4 3 1 2
2 1 4 3
Output
NO
----------------------------------------------------------------------------------------------------
C. Number Transformation
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
10 1 4
Output
6
Input
6 3 10
Output
2
Input
1000000000000000000 1 3
Output
666666666666666667
----------------------------------------------------------------------------------------------------
D. Two Sets
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
1 2 3 4 5 6
Output
2 2 2 2 2 2
Input
3
1000000000000 1000000000000 1000000000000
Output
2 2 2
Input
8
1 1 2 2 3 3 4 4
Output
1 2 1 2 2 2 1 2
----------------------------------------------------------------------------------------------------
E. Tree and Table
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1 3
2 3
4 3
5 1
6 2
Output
12
Input
4
1 2
2 3
3 4
4 5
5 6
6 7
7 8
Output
28
Input
2
1 2
3 2
4 2
Output
0
----------------------------------------------------------------------------------------------------
