eolymp
bolt
Попробуйте наш новый интерфейс для отправки задач
Задачи

First Date

First Date

В 1582 году папа Григорий XIII объявил реформу календаря для того чтобы привести среднюю длину календарного года (подсчитанную в днях) к соответствию с фактическим количеством дней в астрономическом году. Эта календарная реформа привела к переходу от юлианского календаря к григорианскому календарю.

Как юлианский, так и григорианский календари имеют обычные годы с 365 днями и так называемые високосные годы с 366 днями. В течение обычных лет месяц февраль имеет 28 дней, а в високосные годы он имеет дополнительный «високосный день»: 29 февраля.

Единственное различие между юлианским и григорианским календарями заключалось в правилах определения високосного года. В юлианском календаре високосные годы - это те годы, которые делятся на 4. Правило григорианского календаря для определения високосных лет несколько сложнее: годы, делящиеся на 4, являются високосными, если они делятся на 100, но не на 400.

Следуя этим правилам, года 1600, 1700, 1800, 1900, 2000, 2100, 2200, 2300 и 2400 являются високосными в юлианском календаре. В григорианском календаре из приведенных годов високосными будут только 1600, 2000 и 2400.

The old Julian calendar has a mean year length of 365.25 days, while the new Gregorian calendar has a mean year length of 365.2425 days. Given that the actual number of days in an astronomical year is about 365.24219 days, you can see why the Gregorian calendar is an improvement.

As part of the Gregorian reform, a number of dates were skipped, to reverse the effects of having used the Julian calendar for over 1500 years. Specifically, the Gregorian reform decreed that October 4, 1582 (Julian) was to be followed by October 15, 1582 (Gregorian).

However, by the end of the 16th century the Reformation was in full swing. While the Catholic countries tended to follow the Papal decree, many countries continued using the Julian calendar until much later. For example, the United Kingdom switched from the Julian calendar to the Gregorian calendar on September 2, 1752 (Julian) which was followed by September 14, 1752 (Gregorian) - by that time, 11 dates had to be skipped to make the switch. The last European country to switch was Greece, which made the transition as late as February 15, 1923 (Julian) which was followed by March 1, 1923 (Gregorian), skipping 13 dates.

Given the last day for which the Julian calendar is in effect for some country (expressed as a Julian date), determine the next day's Gregorian date, i.e., the first date that uses the Gregorian calendar.

Входные данные

For each test case, the input consists of one line containing a date in the Julian calendar, formatted as YYYY-MM-DD. This date will be no earlier than October 4, 1582, and no later than October 18, 9999. The given date represents the last day that the Julian calendar is in effect for some country.

Выходные данные

For each test case, print the first Gregorian date after the calendar transition.

Лимит времени 1 секунда
Лимит использования памяти 128 MiB
Входные данные #1
1582-10-04
1752-09-02
1900-02-25
1923-02-15
Выходные данные #1
1582-10-15
1752-09-14
1900-03-10
1923-03-01
Источник 2013 ACM North Western European Regional Contest (NWERC), Ноябрь 24, Задача F