{"raw_statement":[{"iden":"statement","content":"Little Timmy is going trick or treating this year, but has decided that he will only look for his favorite kind of candy: Chuckles bars. Unfortunately, Alice has bought up all of the Chuckles bars in the neighborhood and using them to trade for other candies, so Timmy must find the candies that Alice is looking for and trade them in for Chuckles bars. Alice has posted $n$ types of trades that she is willing to make, where a trade consists of a type of candy and how many Chuckles bars Alice is willing to give for one piece of that type of candy.\n\nLittle Timmy has done extensive research and discovered what candies and amounts each of the $h$ houses in his neighborhood is going to be giving out. When Little Timmy goes to a particular house, he can take all of the candy that the house is giving out. However, he only has time to visit $k$ different houses before the night ends. Given the candies that each house gives out and the deals Alice is willing to make, what is the maximum amount of Chuckles bars that Little Timmy can end up getting?\n\nThe first line of the input will consist of a single integer $n$ ($1 <= n <= 200$), which gives the number of deals that Alice is willing to make. The next $n$ lines of the input will consist of a string $s_i$ made of only alphanumeric characters ($1 <= | s_i | <= 15$) and an integer $v_i$ ($1 <= v_i <= 100$), which indicates that Alice is willing to give $v_i$ Chuckles bars for a single candy with the name $s_i$. The next line of the input will consist of two integers $h$ and $k$ ($1 <= k <= h <= 200$), which gives the number of houses in Timmy's neighborhood and the number of houses that he can visit. The next lines of the input consist of $h$ house-descriptions, which consist of a single integer $c_i$ ($1 <= c_i <= n$) giving the number of types of candies that house $i$ is giving out, followed by $c_i$ lines that each consist of one of the $n$ types of candies that Alice is willing to send and an integer $m_j$ ($1 <= m_j <= 100$) that gives the number of candies of that type that house $i$ is giving out. \n\nOutput a single integer and new line that gives the maximum number of Chuckles bars that Little Timmy can end up collecting. \n\n"},{"iden":"input","content":"The first line of the input will consist of a single integer $n$ ($1 <= n <= 200$), which gives the number of deals that Alice is willing to make. The next $n$ lines of the input will consist of a string $s_i$ made of only alphanumeric characters ($1 <= | s_i | <= 15$) and an integer $v_i$ ($1 <= v_i <= 100$), which indicates that Alice is willing to give $v_i$ Chuckles bars for a single candy with the name $s_i$. The next line of the input will consist of two integers $h$ and $k$ ($1 <= k <= h <= 200$), which gives the number of houses in Timmy's neighborhood and the number of houses that he can visit. The next lines of the input consist of $h$ house-descriptions, which consist of a single integer $c_i$ ($1 <= c_i <= n$) giving the number of types of candies that house $i$ is giving out, followed by $c_i$ lines that each consist of one of the $n$ types of candies that Alice is willing to send and an integer $m_j$ ($1 <= m_j <= 100$) that gives the number of candies of that type that house $i$ is giving out. "},{"iden":"output","content":"Output a single integer and new line that gives the maximum number of Chuckles bars that Little Timmy can end up collecting. "}],"translated_statement":null,"sample_group":[],"show_order":[],"formal_statement":"**Definitions**  \nLet $ n, q \\in \\mathbb{Z}^+ $ with $ 1 \\le n, q \\le 3 \\cdot 10^5 $.  \nLet $ A = (a_1, a_2, \\dots, a_n) \\in \\{0,1\\}^n $ be the initial binary sequence representing star counts on sneetches.  \n\n**Operations**  \nFor each query $ (t, l, r) $ with $ 1 \\le l \\le r \\le n $:  \n- If $ t = 1 $: For all $ i \\in [l, r] $, set $ a_i \\leftarrow 1 - a_i $ (bit flip).  \n- If $ t = 2 $: Reverse the subsequence $ (a_l, a_{l+1}, \\dots, a_r) $, then relabel indices $ 1 $ to $ n $ left-to-right.  \n- If $ t = 3 $: Sort the subsequence $ (a_l, a_{l+1}, \\dots, a_r) $ in non-decreasing order, then relabel indices $ 1 $ to $ n $ left-to-right.  \n\n**Objective**  \nAfter each operation, compute:  \n$$\n\\max \\{ k \\in \\mathbb{Z}^+ \\mid \\exists\\, i \\text{ s.t. } a_i = a_{i+1} = \\dots = a_{i+k-1} \\}\n$$  \ni.e., the length of the longest contiguous substring of equal values in $ A $.","simple_statement":"You are given a string of 0s and 1s representing sneetches with or without stars. You must handle q operations:\n\n1. Flip all bits in range [l, r] (0→1, 1→0).\n2. Reverse the substring [l, r].\n3. Sort the substring [l, r] in non-decreasing order (0s then 1s).\n\nAfter each operation, output the length of the longest consecutive sequence of identical bits (0s or 1s).","has_page_source":false}