VK Cup 2017 - Qualification 1


A. Year of University Entrance
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
2014 2016 2015
Output
2015
Input
1
2050
Output
2050
----------------------------------------------------------------------------------------------------
B. News About Credit
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
1 2 1 0
Output
3
1 2
2 4
2 3
Input
6
2 0 1 3 2 0
Output
6
1 3
3 4
1 2
4 5
5 6
4 6
Input
3
0 2 2
Output
-1
----------------------------------------------------------------------------------------------------
C. Cycle In Maze
time limit per test: 15 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 3 2
.**
X..
Output
RL
Input
5 6 14
..***.
*...X.
..*...
..*.**
....*.
Output
DLDDLLLRRRUURU
Input
3 3 4
***
*X*
***
Output
IMPOSSIBLE
----------------------------------------------------------------------------------------------------
D. k-Interesting Pairs Of Integers
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 1
0 3 2 1
Output
4
Input
6 0
200 100 100 100 200 200
Output
6
----------------------------------------------------------------------------------------------------
