{"task": {"agent_timeout": 600, "task": "794", "verifier_timeout": 7200, "instruction": "Please implement a Python 3 solution to the below problem.\nReason through the problem and:\n1. Restate the problem in plain English\n2. Conceptualize a solution first in plain English\n3. Write a pseudocode solution\n4. Save your solution as solution.py\nNo outside libraries are allowed.\n\n[BEGIN PROBLEM]\nFarmer John has a large field, and he is thinking of planting sweet corn in some\npart of it. After surveying his field, FJ found that it forms an\n$(N-1) \\times (N-1)$ square. The southwest corner is at coordinates $(0,0)$, and\nthe northeast corner is at $(N-1,N-1)$.\n\nAt some integer coordinates there are double-headed sprinklers, each one\nsprinkling both water and fertilizer. A double-heading sprinkler at coordinates\n$(i,j)$  sprinkles water on the part of the field north and east of it, and\nsprinkles fertilizer on the part of the field south and west of it. Formally, it\nwaters all real coordinates $(x,y)$ for which $N \\geq x \\geq i$ and\n$N \\geq y \\geq j$, and it fertilizes all real coordinates $(x,y)$ for which\n$0 \\leq x \\leq i$ and $0 \\leq y \\leq j$.\n\nFarmer John wants to plant sweet corn in some axis-aligned rectangle in his\nfield with integer-valued corner coordinates. However, for the sweet corn to\ngrow, all points in the rectangle must be both watered and fertilized by the\ndouble-headed sprinklers. And of course the rectangle must have positive area,\nor Farmer John wouldn't be able to grow any corn in it!\n\nHelp Farmer John determine the number of rectangles of positive area in which he\ncould grow sweet corn. Since this number may be large, output the remainder of\nthis number modulo\n$10^9 + 7$.\n\nINPUT FORMAT:\nThe first line of the input consists of a single integer $N$, the size of the\nfield ($1 \\leq N \\leq 10^5$).\n\nThe next $N$ lines each contain two space-separated integers. If these integers\nare $i$ and $j$, where $0 \\leq i,j \\leq N-1$, they denote a sprinkler located at\n$(i,j)$.\n\nIt is guaranteed that there is exactly one sprinkler in each column and exactly\none sprinkler in each row. That is, no two sprinklers have the same\n$x$-coordinate, and no two sprinklers have the same $y$-coordinate.\n\n\nOUTPUT FORMAT:\nThe output should consist of a single integer: the number of rectangles of\npositive area which are fully watered and fully fertilized, modulo $10^9 + 7$.\n\nSAMPLE INPUT:\n5\n0 4\n1 1\n2 2\n3 0\n4 3\nSAMPLE OUTPUT: \n21\n\n\nProblem credits: Dhruv Rohatgi\n\n[END PROBLEM]\n", "memory": "2048m", "runnable": false, "difficulty": "medium", "language": "", "cpus": 1, "instruction_truncated": false, "category": "python_programming", "compose": false, "has_solution": true, "oracle": null, "docker_image": "", "taskset": "usaco", "tags": ["python", "programming", "usaco"]}, "runs": []}