P7762 [COCI 2016/2017 #5] Unija

Description

Given $N$ rectangles whose geometric centers are at the origin of the Cartesian coordinate system. Paint these $N$ rectangles, and find the total painted area.

Input Format

The first line contains an integer $N$. The next $N$ lines each contain two even integers $X, Y$, representing the rectangle’s width and height (corresponding to the horizontal length and the vertical length, respectively).

Output Format

Output the total painted area.

Explanation/Hint

**[Sample 1 Illustration]** ![](https://cdn.luogu.com.cn/upload/image_hosting/g1w4hrf7.png?x-oss-process=image/resize,m_lfit,h_389,w_485) **[Constraints]** For $40\%$ of the testdata, all input integers are less than $3333$. For $50\%$ of the testdata, there are no rectangles that contain another. For $100\%$ of the testdata, $1 \le N \le 10^6$, $2 \le X, Y \le 10^7$. **[Hints and Notes]** **This problem is translated from [COCI 2016-2017](https://hsin.hr/coci/archive/2016_2017/) [CONTEST #5](https://hsin.hr/coci/archive/2016_2017/contest5_tasks.pdf) _T3 Unija_.** **The score of this problem follows the original COCI settings, with a full score of $100$.** Translated by ChatGPT 5