Due to overwhelming demand, the principal has installed one of those "take a number" dispensers to help the attendance secretary manage the line for late slips. The dispenser is filled with slips of paper numbered in order from to . The principal has made sure to order lots of refills! The attendance desk opens at 8:00 am every morning and closes at 3:00 pm. When a late student arrives they take the next number from the machine, and when the attendance secretary is ready, he calls the next number in order. When a student takes the last number, the secretary immediately refills the machine with a new set of numbers from to . At 3:00 pm, he removes the dispenser and stores it for the next day, then serves any students who are still waiting with numbers in their hands before closing for the day.

You will be given detailed data for a number of days in the late slip lineup. The first line contains an integer representing the next number in the take a number machine. This will be followed by some number of lines (up to ) representing the activity at the attendance desk. If a line contains the word `TAKE`

, it means a student has arrived and taken the next number (when a student takes the last number available, the machine is immediately refilled). If a line contains the word `SERVE`

it means that the attendance secretary has served the next student in line (this word will only appear in the file when there is at least one student waiting). If a line contains the word `CLOSE`

it means that the desk has closed for the day and the attendance secretary will serve the students remaining in line and then go home. The very last line will contain the string `EOF`

. At no time will there be more than students waiting in line to be served.

Your job is to keep track of the line. Each time you encounter the word `CLOSE`

, you must print three integers on a single line, each separated by a single space. The first integer represents the number of students who were late that day, the second integer represents the number of students who remained in line after the desk was closed, and the third integer represents the next number in the take a number machine for the next day.

#### Sample Input

```
23
TAKE
TAKE
SERVE
TAKE
SERVE
SERVE
CLOSE
TAKE
TAKE
TAKE
SERVE
CLOSE
TAKE
SERVE
TAKE
SERVE
TAKE
TAKE
TAKE
TAKE
TAKE
TAKE
SERVE
CLOSE
EOF
```

#### Sample Output

```
3 0 26
3 2 29
8 5 37
```

Educational Computing Organization of Ontario - statements, test data and other materials can be found at ecoocs.org

## Comments

I'm grading the grader on this one... I've looked at a few of the other submissions (PY3) and noticed they allow ticket number 0 and do not allow ticket number 999!! I'm not sure of the tests used but may have been over looked or just not tested for that.

HI! at home on my machine this code runs perfectly, given the long input it prints the right numbers at the right time (at "CLOSE"). But i get WA from the dmoj grader. Do you see what#s wrong with my code? best regards, oliver

start = int(input()) no_of_T = start countT = 0 countS = 0 inpt = input() while inpt != "EOF": if inpt == "TAKE": no_of_T += 1 countT +=1 elif inpt == "SERVE": countS += 1 elif inpt == "CLOSE": print(countT, countT-countS, no_of_T) countT = 0 countS = 0 inpt = input()

you need to check if the tickets in the machine needed to be refilled.

My code works on an online compiler but it fails when I submit it. Can someone take a look?

I dont think you took in the case where the secretary refills the machine. If your output is more than 1000, you have to reset the machine and the counter goes from 1.

Thank you I didn't see that