{"task": {"agent_timeout": 600, "task": "898", "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 is attempting to sort his $N$ cows ($1 \\leq N \\leq 10^5$),\nconveniently numbered $1 \\dots N$, before they head out to the pastures for\nbreakfast.\n\nCurrently, the cows are standing in a line in the order\n$p_1, p_2, p_3, \\dots, p_N$, and Farmer John is standing in front of cow $p_1$.\nHe wants to reorder the cows so that they are in the order $1, 2, 3, \\dots, N$,\nwith cow $1$ next to Farmer John.\n\nToday the cows are a bit sleepy, so at any point in time the only cow who is\npaying attention to Farmer John's instructions is the cow directly facing Farmer\nJohn. In one time step, he can instruct this cow to move $k$ paces down the\nline, for any $k$ between $1$ and $N-1$ inclusive. The $k$ cows whom she passes\nwill amble forward, making room for her to insert herself in the line after\nthem.\n\nFor example, suppose that $N=4$ and the cows start off in the following order:\n\n FJ: 4, 3, 2, 1 \nThe only cow paying attention to FJ is cow $4$. If he instructs her to move $2$\npaces down the line, the order will subsequently look like this:\n\n FJ: 3, 2, 4, 1 \nNow the only cow paying attention to FJ is cow $3$, so in the second time step\nhe may give cow $3$ an instruction, and so forth until the cows are sorted.\n\nFarmer John is eager to complete the sorting, so he can go back to the farmhouse\nfor his own breakfast. Help him find a sequence of instructions that sorts the\ncows in the minimum number of time steps.\n\nINPUT FORMAT:\nThe first line of input contains $N$.  The second line contains $N$ space-separated integers:\n$p_1, p_2, p_3, \\dots, p_N$, indicating the starting order of the cows.\n\nOUTPUT FORMAT:\nThe first line should contain a single integer, $K$, giving the minimum number of time\nsteps required to sort the cows.\n\nThe second line should contain $K$ space-separated integers,\n$c_1, c_2, \\dots, c_K$, each in the range $1 \\ldots N-1$.  \nFurthermore, if in the $i$-th time step FJ\ninstructs the cow facing him to move $c_i$ paces down the line, then after $K$\ntime steps the cows should be in sorted order.\n\nIf there are multiple optimal instruction sequences, your program may output any\nof them.\n\nSAMPLE INPUT:\n4\n1 2 4 3\nSAMPLE OUTPUT: \n3\n2 2 3\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": []}