{"task": {"agent_timeout": 600, "task": "1275", "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]\n\nFarmer John has $N$ cows ($2 \\leq N \\leq 10^5$). Each cow has a breed that is\neither Guernsey or Holstein.  As is often the case, the cows are standing in a\nline, numbered $1 \\ldots N$ in this order.  \n\nOver the course of the day, each cow writes down a list of cows.  Specifically,\ncow $i$'s list contains the range of cows starting with herself (cow $i$) up to\nand including cow $E_i$ ($i \\leq E_i \\leq N$).\n\nFJ has recently discovered that each breed of cow has exactly one distinct\nleader. FJ does not know who the leaders are, but he knows that each leader must\nhave a list that includes all the cows of their breed, or the other breed's \nleader (or both).\n\nHelp FJ count the number of pairs of cows that could be leaders. It is\nguaranteed that there is at least one possible pair.\n\nINPUT FORMAT (input arrives from the terminal / stdin):\nThe first line contains $N$.\n\nThe second line contains a string of length $N$, with the $i$th character\ndenoting the breed of the $i$th cow (G meaning Guernsey and H meaning Holstein).\nIt is guaranteed that there is at least one Guernsey and one Holstein.\n\nThe third line contains $E_1 \\dots E_N$.\n\nOUTPUT FORMAT (print output to the terminal / stdout):\nOutput the number of possible pairs of leaders.\n\nSAMPLE INPUT:\n4\nGHHG\n2 4 3 4\nSAMPLE OUTPUT: \n1\n\nThe only valid leader pair is $(1, 2)$. Cow $1$'s list contains the other\nbreed's leader (cow $2$). Cow $2$'s list contains all cows of her breed\n(Holstein). \n\nNo other pairs are valid. For example, $(2,4)$ is invalid since cow $4$'s list\ndoes not contain the other breed's leader, and it also does not contain all cows\nof her breed.\n\nSAMPLE INPUT:\n3\nGGH\n2 3 3\nSAMPLE OUTPUT: \n2\n\nThere are two valid leader pairs, $(1, 3)$ and $(2, 3)$.\n\nSCORING\nInputs 3-5: $N \\leq 100$Inputs 6-10: $N \\leq 3000$Inputs 11-17: No additional constraints.\n\n\nProblem credits: Mythreya Dharani\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": []}