{"task": {"agent_timeout": 600, "task": "346", "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]\nProblem 1: Empty Stalls [Brian Dean, 2013]\n\nFarmer John's new barn consists of a huge circle of N stalls (2 <= N <=\n3,000,000), numbered 0..N-1, with stall N-1 being adjacent to stall 0.  \n\nAt the end of each day, FJ's cows arrive back at the barn one by one, each\nwith a preferred stall they would like to occupy.  However, if a cow's\npreferred stall is already occupied by another cow, she scans forward\nsequentially from this stall until she finds the first unoccupied stall,\nwhich she then claims.  If she scans past stall N-1, she continues scanning\nfrom stall 0.\n\nGiven the preferred stall of each cow, please determine the smallest index\nof a stall that remains unoccupied after all the cows have returned to the\nbarn.  Notice that the answer to this question does not depend on the order\nin which the cows return to the barn.\n\nIn order to avoid issues with reading huge amounts of input, the input to\nthis problem is specified in a concise format using K lines (1 <= K <=\n10,000) each of the form:\n\nX Y A B\n\nOne of these lines specifies the preferred stall for XY total cows: X cows\nprefer each of the stalls f(1) .. f(Y), where f(i) = (Ai + B) mod N.  The\nvalues of A and B lie in the range 0...1,000,000,000. \n\nDo not forget the standard memory limit of 64MB for all problems.\n\nPROBLEM NAME: empty\n\nINPUT FORMAT:\n\n* Line 1: Two space-separated integers: N and K.\n\n* Lines 2..1+K: Each line contains integers X Y A B, interpreted as\n        above.  The total number of cows specified by all these lines\n        will be at most N-1.  Cows can be added to the same stall by\n        several of these lines.\n\nSAMPLE INPUT:\n\n10 3\n3 2 2 4\n2 1 0 1\n1 1 1 7 \n\nINPUT DETAILS:\n\nThere are 10 stalls in the barn, numbered 0..9.  The second line of input\nstates that 3 cows prefer stall (2*1+4) mod 10 = 6, and 3 cows prefer stall\n(2*2+4) mod 10 = 8.  The third line states that 2 cows prefer stall (0*1+1)\nmod 10 = 1.  Line four specifies that 1 cow prefers stall (1*1+7) mod 10 =\n8 (so a total of 4 cows prefer this stall).\n\nOUTPUT FORMAT:\n\n* Line 1: The minimum index of an unoccupied stall.\n\nSAMPLE OUTPUT:\n\n5\n\nOUTPUT DETAILS:\n\nAll stalls will end up occupied except stall 5.\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": []}