{"task": {"agent_timeout": 600, "task": "922", "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]\nBessie and Elsie are helping Farmer John wash the dishes, a more complicated\nprocess than one might think due to their lack of opposable thumbs.\n\nThe two cows decide that Bessie will apply soap, and Elsie will rinse. Bessie is\ngiven a dirty stack of plates labeled $1$ through $N$ ($1 \\leq N \\leq 10^5$)\nElsie has an empty stack, where clean plates will go. There is a counter in\nbetween Bessie and Elsie for soapy stacks.\n\nAt each step, either:\n\nBessie takes a plate from the top of the dirty stack, applies soap, and then\nplaces it on the counter. When placing a soapy plate on the counter, Bessie must\neither (i) place the plate on top of an existing non-empty soapy stack or (ii)\ncreate a new soapy stack to the right of all existing soapy stacks.\n\nElsie takes a plate from the top of the leftmost soapy stack. Elsie rinses the\nplate, then places it on top of the clean stack.\n\nThe goal is for the clean stack to have all plates in order, with the smallest\nlabel on the bottom and the largest label on the top.  It may not be possible\nfor the cows to achieve this goal for the entire stack of plates, so please\ndetermine the length of the largest prefix of the input ordering for which the\ngoal is achievable.\n\nINPUT FORMAT:\nThe first line of input contains $N$.  The next $N$ lines specify the order of\nthe dishes in Bessie's stack, with the first number being the dish on top of the\nstack.\n\nOUTPUT FORMAT:\nPlease output the length of the longest prefix of the input stack that can be\nsuccessfully washed so that the plates end up ordered properly in the clean\nstack.\n\nSAMPLE INPUT:\n5\n4\n5\n2\n3\n1\nSAMPLE OUTPUT: \n4\n\n\nProblem credits: George Xing\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": []}