Олимпиадный тренинг

Задача 30723. Pyramid (maximum)


Задача

Темы: Куча
Write a program that will process a sequence of queries like this:
 
CLEAR — make the pyramid empty (if there were already some elements in the pyramid, delete all). The action occurs only with the data in memory, nothing is displayed on the screen.
 
ADD n — add the number n to the pyramid. The action occurs only with the data in memory, nothing is displayed on the screen.
 
EXTRACT — take out the maximum value from the pyramid. You should both change the data in memory and display either the maximum value found, or, if the pyramid was empty, the word "CANNOT" (in capital letters).
 
Input
The input contains an arbitrary sequence of queries CLEAR, ADD and EXTRACT — each on a separate line, following the format described above. The data ends with the string "END!"
 
The total number of all requests does not exceed 200000.
 
Output
For each EXTRACT query, print its result to the standard output (screen) (on a separate line).

Enter Output
ADD 192168812
ADD 125
ADD 321
EXTRACT
EXTRACT
CLEAR
ADD7
ADD 555
EXTRACT
EXTRACT
EXTRACT
END!
192168812
321
555
7
CANNOT