Queue · Compiler

Queue

Simulate an initially empty printer queue. ADD x appends a job at the back. PRINT takes the job at the front and reports its ID. If the queue is empty, PRINT reports EMPTY.

Input
The first line contains the command count q (1 <= q <= 100). Each of the next q lines contains ADD x or PRINT. Job IDs are integers from 1 to 1000 and may repeat. There is at least one PRINT.
Output
Print one line per PRINT command, containing the removed job ID or EMPTY.

Compiler Explorer runs your code when you run or check it.

Loading your exercise draft…