{"task": {"agent_timeout": 600, "task": "259", "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: Cow Race [Brian Dean, 2013]\n\nIn order to finally settle their long-running dispute over who is the\nfaster cow, Bessie and her friend Elsie decide to hold a race across the farm.\n\nThe two cows start at the same location and begin running in the same\ndirection at the same time.  The progress of each cow is described by a\nseries of \"segments\", during each of which the cow runs at a constant\nspeed.  For example, Bessie might run at a speed of 5 for 3 units of time,\nthen at a speed of 10 for 6 units of time.  Bessie and Elsie both run for\nthe same total amount of time.\n\nThe cows would like your help in counting the number of leadership changes\nduring their race.  A leadership change happens at a point in time when cow\nA pulls into the lead of cow B, whereas the last time one cow was in the\nlead, it was cow B.  For example, if B is in the lead and then A pulls\nahead, then this is a leadership change.  If B is in the lead, and then A\nbecomes even with B for some time and then finally pulls ahead, then this\nalso counts as a leadership change.\n\nPROBLEM NAME: cowrace\n\nINPUT FORMAT:\n\n* Line 1: Two space-separated integers, N and M.  (1 <= N, M <= 1000)\n\n* Lines 2..1+N: Each line contains one of the N segments of Bessie's\n        run, described by two integers: Bessie's speed and the amount\n        of time she runs at that speed (both integers are in the range\n        1..1000).\n\n* Lines 2+N..1+N+M: Each line contains one of the M segments of\n        Elsie's run, described by two integers: Elsie's speed and the\n        amount of time she runs at that speed (both integers are in\n        the range 1..1000).\n\nSAMPLE INPUT:\n\n4 3\n1 2\n4 1\n1 1\n2 10\n2 3\n1 2\n3 9\n\nINPUT DETAILS:\n\nBessie runs at a speed of 1 for 2 units of time, then at a speed of 4 for 1\nunit of time, then at a speed of 1 for 1 unit of time, and finally at a\nspeed of 2 for 10 units of time.  Elsie runs at a speed of 2 for 3 units of\ntime, then at a speed of 1 for 2 units of time, then finally at a speed of\n3 for 9 units of time.  Note that both cows run for a total of 14 units of\ntime.\n\nOUTPUT FORMAT:\n\n* Line 1: The number of leadership changes during the race.\n\nSAMPLE OUTPUT:\n\n2\n\nOUTPUT DETAILS:\n\nElsie is ahead until time t=3, when both cows meet after both have traveled\n6 units of total distance and travel together for 1 unit of time.  Bessie\nthen pulls ahead briefly (the first leadership change), only to be\novertaken shortly thereafter by Elsie (the second leadership change). \nElsie ends the race in the lead.\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": []}