AtCoder Wallpaper

AtCoder
IDabc354_d
Time2000ms
Memory256MB
Difficulty
The pattern of AtCoder's wallpaper can be represented on the $xy$\-plane as follows: * The plane is divided by the following three types of lines: * $x = n$ (where $n$ is an integer) * $y = n$ (where $n$ is an even number) * $x + y = n$ (where $n$ is an even number) * Each region is painted black or white. Any two regions adjacent along one of these lines are painted in different colors. * The region containing $(0.5, 0.5)$ is painted black. The following figure shows a part of the pattern. ![image](https://img.atcoder.jp/abc354/d_img1_34zxoiv2.png) You are given integers $A, B, C, D$. Consider a rectangle whose sides are parallel to the $x$\- and $y$\-axes, with its bottom-left vertex at $(A, B)$ and its top-right vertex at $(C, D)$. Calculate the area of the regions painted black inside this rectangle, and print twice that area. It can be proved that the output value will be an integer. ## Constraints * $-10^9 \leq A, B, C, D \leq 10^9$ * $A < C$ and $B < D$. * All input values are integers. ## Input The input is given from Standard Input in the following format: $A$ $B$ $C$ $D$ [samples]
Samples
Input #1
0 0 3 3
Output #1
10

We are to find the area of the black-painted region inside the following square:
![image](https://img.atcoder.jp/abc354/d_img2_zzwqsaaewub.png)
The area is $5$, so print twice that value: $10$.
Input #2
\-1 -2 1 3
Output #2
11

The area is $5.5$, which is not an integer, but the output value is an integer.
Input #3
\-1000000000 -1000000000 1000000000 1000000000
Output #3
4000000000000000000

This is the case with the largest rectangle, where the output still fits into a 64-bit signed integer.
API Response (JSON)
{
  "problem": {
    "name": "AtCoder Wallpaper",
    "description": {
      "content": "The pattern of AtCoder's wallpaper can be represented on the $xy$\\-plane as follows: *   The plane is divided by the following three types of lines:     *   $x = n$ (where $n$ is an integer)     *   ",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "abc354_d"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "The pattern of AtCoder's wallpaper can be represented on the $xy$\\-plane as follows:\n\n*   The plane is divided by the following three types of lines:\n    *   $x = n$ (where $n$ is an integer)\n    *   ...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments