Mail.Ru Cup 2018 Round 3


A. Determine Line
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
3 1 4 6
2 1 4
5 10 5 6 4 1
Output
1 4 
Input
5
1 1
10 10 9 8 7 100 5 4 3 99 1
5 1 2 3 4 5
5 4 1 3 2 5
4 10 1 5 3
Output
1 
----------------------------------------------------------------------------------------------------
B. Divide Candies
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 3
Output
1
Input
6 5
Output
13
Input
1000000000 1
Output
1000000000000000000
----------------------------------------------------------------------------------------------------
C. Pick Heroes
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 1
1 2 3 4 5 6
2 6
1
2
4
1
Output
6
5
3
Input
3 1
1 2 3 4 5 6
1 5
2
6
1
3
Output
5
4
2
----------------------------------------------------------------------------------------------------
D. Decorate Apple Tree
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

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

Examples
Input
01
aaaaaa
Output
4
Input
001
kokokokotlin
Output
2
----------------------------------------------------------------------------------------------------
F. Write The Contest
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
4
1.000 31.000
12 3
20 6
30 1
5 1
3
1.000 30.000
1 10
10 10
20 8
Output
7
20
----------------------------------------------------------------------------------------------------
G. Take Metro
time limit per test: 2 seconds
memory limit per test: 1024 megabytes
input: standard input
output: standard output

Examples
Input
10 4
3 1
Output
4
Input
10 4
3 5
Output
4
Input
10543 437
5492 1947349
Output
438
----------------------------------------------------------------------------------------------------
H. Detect Robots
time limit per test: 1 second
memory limit per test: 1024 megabytes
input: standard input
output: standard output

Examples
Input
1
5
2
4 1 2 3 5
3 1 4 3
Output
Human
Input
1
4
4
3 1 2 3
3 2 3 4
3 3 4 1
3 4 1 2
Output
Robot
----------------------------------------------------------------------------------------------------
