Kotlin Heroes: Practice 2


A. Wrong Subtraction
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
512 4
Output
50
Input
1000000000 9
Output
1
----------------------------------------------------------------------------------------------------
B. Two-gram
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7
ABACABA
Output
AB
Input
5
ZZZAA
Output
ZZ
----------------------------------------------------------------------------------------------------
C. Less or Equal
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7 4
3 7 5 1 10 3 20
Output
6
Input
7 2
3 7 5 1 10 3 20
Output
-1
----------------------------------------------------------------------------------------------------
D. Divide by three, multiply by two
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
4 8 6 3 12 9
Output
9 3 6 12 4 8 
Input
4
42 28 84 126
Output
126 42 84 28 
Input
2
1000000000000000000 3000000000000000000
Output
3000000000000000000 1000000000000000000 
----------------------------------------------------------------------------------------------------
E. Booking System
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
10 50
2 100
5 30
3
4 6 9
Output
2 130
2 1
3 2
----------------------------------------------------------------------------------------------------
F. One-Based Arithmetic
time limit per test: 0.5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
121
Output
6
----------------------------------------------------------------------------------------------------
G. Hiking
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 9
10 10
20 10
30 1
31 5
40 10
Output
1 2 4 5 
----------------------------------------------------------------------------------------------------
H. Berland Federalization
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

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