Kotlin Heroes: Practice 3


A. Restoring Three Numbers
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 6 5 4
Output
2 1 3
Input
40 40 40 60
Output
20 20 20
Input
201 101 101 200
Output
1 100 100
----------------------------------------------------------------------------------------------------
B. Remove Duplicates
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
1 5 5 1 6 1
Output
3
5 6 1 
Input
5
2 4 2 4 4
Output
2
2 4 
Input
5
6 6 6 6 6
Output
1
6 
----------------------------------------------------------------------------------------------------
C. File Name
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
xxxiii
Output
1
Input
5
xxoxx
Output
0
Input
10
xxxxxxxxxx
Output
8
----------------------------------------------------------------------------------------------------
D. Bus Video System
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 5
2 1 -3
Output
3
Input
2 4
-1 1
Output
4
Input
4 10
2 4 1 2
Output
2
----------------------------------------------------------------------------------------------------
E. Mentors
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 2
10 4 10 15
1 2
4 3
Output
0 0 1 2 
Input
10 4
5 4 1 5 4 3 7 1 2 5
4 6
2 1
10 8
3 5
Output
5 4 0 5 3 3 9 0 2 5 
----------------------------------------------------------------------------------------------------
F1. Median on Segments (Permutations Edition)
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 4
2 4 5 3 1
Output
4
Input
5 5
1 2 3 4 5
Output
1
Input
15 8
1 15 2 14 3 13 4 8 12 5 11 6 10 7 9
Output
48
----------------------------------------------------------------------------------------------------
F2. Median on Segments (General Case Edition)
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 4
1 4 5 60 4
Output
8
Input
3 1
1 1 1
Output
6
Input
15 2
1 2 3 1 2 3 1 2 3 1 2 3 1 2 3
Output
97
----------------------------------------------------------------------------------------------------
