Area of Rectangles

From CSES 1741. You are given axis-aligned rectangles. Each rectangle is described by (x1,y1,x2,y2), where its lower-left corner is (x1,y1) and its upper-right corner is (x2,y2). Return the total area covered by at least one rectangle. The platform adapter passes the rectangles flattened as [x1,y1,x2,y2,...]. The result may exceed 32-bit range, so native implementations must use a wide accumulator.

Examples
Input: [0,0,2,2]
Output: 4
Hints

Area of Rectangles

**From CSES 1741.** You are given axis-aligned rectangles. Each rectangle is described by `(x1,y1,x2,y2)`, where its lower-left corner is `(x1,y1)` and its upper-right corner is `(x2,y2)`. Return the total area covered by at least one rectangle. The platform adapter passes the rectangles flattened as `[x1,y1,x2,y2,...]`. The result may exceed 32-bit range, so native implementations must use a wide accumulator.