Kotlin Heroes: Practice 6


A. 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 
----------------------------------------------------------------------------------------------------
B. Water Buying
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
10 1 3
7 3 2
1 1000 1
1000000000000 42 88
Output
10
9
1000
42000000000000
----------------------------------------------------------------------------------------------------
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. Substrings Sort
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
a
aba
abacaba
ba
aba
Output
YES
a
ba
aba
aba
abacaba
Input
5
a
abacaba
ba
aba
abab
Output
NO
Input
3
qwerty
qwerty
qwerty
Output
YES
qwerty
qwerty
qwerty
----------------------------------------------------------------------------------------------------
E. Books Queries
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
8
L 1
R 2
R 3
? 2
L 4
? 1
L 5
? 1
Output
1
1
2
Input
10
L 100
R 100000
R 123
L 101
? 123
L 10
R 115
? 100
R 110
? 115
Output
0
2
1
----------------------------------------------------------------------------------------------------
F. Boxes Packing
time limit per test: 2.0 s
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 2 6
5 2 1 4 2
Output
4
Input
5 1 4
4 2 3 4 1
Output
1
Input
5 3 3
1 2 3 1 1
Output
5
----------------------------------------------------------------------------------------------------
G. Make It Connected
time limit per test: 3.0 s
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 2
1 3 3
2 3 5
2 1 1
Output
5
Input
4 0
1 3 3 7
Output
16
Input
5 4
1 2 3 4 5
1 2 8
1 3 10
1 4 7
1 5 15
Output
18
----------------------------------------------------------------------------------------------------
