{"task": {"agent_timeout": 600, "task": "120", "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 3: Nearby Cows [Neal Wu and Eric Price, 2011]\n\nFarmer John has noticed that his cows often move between nearby fields. \nTaking this into account, he wants to plant enough grass in each of his\nfields not only for the cows situated initially in that field, but also for\ncows visiting from nearby fields.\n\nSpecifically, FJ's farm consists of N fields (1 <= N <= 100,000), where\nsome pairs of fields are connected with bi-directional trails (N-1 of them\nin total).  FJ has designed the farm so that between any two fields i and\nj, there is a unique path made up of trails connecting between i and j. \nField i is home to C(i) cows, although cows sometimes move to a different\nfield by crossing up to K trails (1 <= K <= 20).  \n\nFJ wants to plant enough grass in each field i to feed the maximum number\nof cows, M(i), that could possibly end up in that field -- that is, the\nnumber of cows that can potentially reach field i by following at most K\ntrails.  Given the structure of FJ's farm and the value of C(i) for each\nfield i, please help FJ compute M(i) for every field i.\n\nPROBLEM NAME: nearcows\n\nINPUT FORMAT:\n\n* Line 1: Two space-separated integers, N and K.\n\n* Lines 2..N: Each line contains two space-separated integers, i and j\n        (1 <= i,j <= N) indicating that fields i and j are directly\n        connected by a trail.\n\n* Lines N+1..2N: Line N+i contains the integer C(i). (0 <= C(i) <=\n        1000)\n\nSAMPLE INPUT:\n\n6 2\n5 1\n3 6\n2 4\n2 1\n3 2\n1\n2\n3\n4\n5\n6\n\nINPUT DETAILS:\n\nThere are 6 fields, with trails connecting (5,1), (3,6), (2,4), (2,1), and\n(3,2).  Field i has C(i) = i cows.  \n\nOUTPUT FORMAT:\n\n* Lines 1..N: Line i should contain the value of M(i).\n\nSAMPLE OUTPUT:\n\n15\n21\n16\n10\n8\n11\n\nOUTPUT DETAILS:\n\nField 1 has M(1) = 15 cows within a distance of 2 trails, etc.\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": []}