#K55207. Weekend or Weekday Checker

    ID: 29924 Type: Default 1000ms 256MiB

Weekend or Weekday Checker

Weekend or Weekday Checker

Given a date string in the format YYYY-MM-DD, determine whether the date falls on a weekend or a weekday. A date is considered a weekend if it is a Saturday or Sunday, and a weekday if it falls between Monday and Friday. If the input date is not valid or does not follow the YYYY-MM-DD format, output Invalid date.

To determine the day of the week, one may use algorithms such as Zeller's Congruence. In particular, one formulation is given by:

$$ h = \left(q + \left\lfloor \frac{13(m+1)}{5} \right\rfloor + K + \left\lfloor \frac{K}{4} \right\rfloor + \left\lfloor \frac{J}{4} \right\rfloor + 5J \right) \mod 7 $$

where (q) is the day of the month, (m) is the month (with January and February treated as months 13 and 14 of the previous year), (K) is the year of the century, and (J) is the zero-based century. The result (h) corresponds to the day of the week (with specific mappings, e.g. 0 for Saturday and 1 for Sunday).

inputFormat

The input consists of a single line read from standard input containing a date string in the format YYYY-MM-DD.

outputFormat

Output a single line to standard output. The output should be one of the following strings exactly: Weekend if the date is a Saturday or Sunday, Weekday if it is a weekday (Monday to Friday), or Invalid date if the input is not a valid date in the required format.## sample

2023-10-14
Weekend

</p>