Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/funksiya-sanalar-farqi

Day of the year

Easy 1000 ms 128 MB 26%
Share

Write a function DayOfYear(d, m, y) that returns which day of the year $y$ the $d$-th day of month $m$ is (January $1$ is day $1$). Days in the months: January $31$, February $28$ ($29$ in a leap year), March $31$, April $30$, May $31$, June $30$, July $31$, August $31$, September $30$, October $31$, November $30$, December $31$. A year is a leap year if it is divisible by $4$ but not by $100$, or if it is divisible by $400$.

Example 1: DayOfYear(1, 3, 2024) → 61 — $31 + 29 + 1 = 61$, $2024$ is a leap year.

Example 2: DayOfYear(31, 12, 2023) → 365

Write only the function body.

The day, month and year go into the function DayOfYear, which returns the number of the day in the year

Input

One line with three positive integers $d$, $m$ and $y$ — the arguments of the function.

Output

The value returned by the function: an integer.

Note

$1 \le d \le 31$
$1 \le m \le 12$
$1900 \le y \le 2100$
The date exists.

Examples

Input #1
1 3 2024
Output #1
61
Input #2
31 12 2023
Output #2
365

Sign in to submit a solution

Signing up is free and takes a minute.