Kotlin Heroes: Episode 1


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

Examples
Input
3
123 13
2 2
2000000000 2000000000
Output
111 1 12
1 1 1
1999999999 1 1
----------------------------------------------------------------------------------------------------
B. Bad Days
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
8
3 1 4 1 5 9 2 6
Output
2
Input
5
1 1 1 1 1
Output
0
Input
13
2 7 1 8 2 8 1 8 2 8 4 5 9
Output
6
----------------------------------------------------------------------------------------------------
C. Minus and Minus Give Plus
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
-+--+
-+++
--------
-+--+-
-
+
--
---
+++
+++
Output
YES
YES
NO
NO
YES
----------------------------------------------------------------------------------------------------
D. Decoding of Integer Sequences
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
12
3 2 1 1 7 2 4 -1 3 -1 4 -1
Output
3
3 3 1 4
2 2 7
4 1 2 3 4
Input
6
2 -1 2 -1 3 -1
Output
3
1 2
0
2 2 3
----------------------------------------------------------------------------------------------------
E. Sliding Doors
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 10
2 3 2
6
1 5
2 1 10
2 2 9
2 5 6
3 1 7 8
4 1 2 3 4
Output
YES
YES
NO
NO
YES
NO
----------------------------------------------------------------------------------------------------
F. Wheels
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6 6 7
6 15 16 20 1 5
Output
39
Input
6 3 1
4 8 15 16 23 42
Output
8
Input
5 4 0
5 5 5 4 5
Output
0
----------------------------------------------------------------------------------------------------
G. Graph Decomposition
time limit per test: 6 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6 9
1 2
2 3
1 3
2 4
2 5
4 5
3 5
3 6
5 6
Output
YES
3
4 2 5 4 2 
4 3 6 5 3 
4 1 3 2 1 
Input
4 7
1 1
1 2
2 3
3 4
4 1
1 3
1 3
Output
YES
3
2 1 1 
5 1 4 3 2 1 
3 1 3 1 
Input
4 8
1 1
1 2
2 3
3 4
4 1
2 4
1 3
1 3
Output
NO
----------------------------------------------------------------------------------------------------
H. Longest Saw
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
10
10 9 8 7 6 5 4 3 2 1
7
1 2 2 2 3 2 2
3
100 100 100
Output
10
1 6 2 7 3 8 4 9 5 10 
4
2 1 3 2 
1
100 
----------------------------------------------------------------------------------------------------
I. Good Subsets
time limit per test: 6 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

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