Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

Anne's Diary

By TarifEzaz · Limits 1s, 512 MB

On 12 June 1942, Anne received a diary as a gift. She started writing on it. Later, her diary had become a part of history as it is considered an important document of World War II.

In order to make Anne’s work available online, you will have to write a program that will answer some queries. Initially, you will be given the list of days when Anne wrote on her diary. Based on this given list, you will have to answer some queries. In each query, you will be given two dates and you will have to answer how many days Anne had written in her diary between these two given dates.


The first line of the input will contain an integer NN (1N2001 \leq N \leq 200), the total number of days Anne had written in her diary. In the next NN lines, there will be a day in the format:

Month Day, Year

The values of the Month will be from January, February, March, April, May, June, July, August, September, October, November and December.

The next line will contain an integer QQ (1Q400001 \leq Q \leq 40000), the total number of queries.

Each query will have two valid dates each on a line by itself. The first date will be earlier or equal to the second date.

The value of all the dates can be any valid date from June 12, 1942 to December 31, 1944.


For each query, output one line, the number of days Anne has written in her diary within the given two dates.


June 12, 1942
June 21, 1942
June 15, 1942
June 22, 1942



72% Solution Ratio

BigBagEarliest, Apr '21

TurinhstuFastest, 0.0s

BigBagLightest, 131 kB

anonyo.akandShortest, 291B


Login to submit


First, the dates when Anne had written in her diary can be sorted, although it is not necessary with...

Related Contests

Toph uses cookies. By continuing you agree to our Cookie Policy.