VK Cup 2016 - Qualification Round 1


A. Voting for Photos
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
1 3 2 2 1
Output
2
Input
9
100 200 300 200 100 300 300 100 200
Output
300
----------------------------------------------------------------------------------------------------
B. Chat Order
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
alex
ivan
roman
ivan
Output
ivan
roman
alex
Input
8
alina
maria
ekaterina
darya
darya
ekaterina
maria
alina
Output
alina
maria
ekaterina
darya
----------------------------------------------------------------------------------------------------
C. Promocodes with Mistakes
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
000000
999999
Output
2
Input
6
211111
212111
222111
111111
112111
121111
Output
0
----------------------------------------------------------------------------------------------------
D. Running with Obstacles
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 10 1 3
3 4 7
Output
RUN 2
JUMP 3
RUN 1
JUMP 2
RUN 2
Input
2 9 2 3
6 4
Output
IMPOSSIBLE
----------------------------------------------------------------------------------------------------
