{"raw_statement":[{"iden":"statement","content":"A palindromic prime (sometimes called a palprime) is a prime number that is also a palindromic number. Palindromicity depends on the base of the numbering system and its writing conventions, while primality is independent of such concerns. \n\nThe sequence of binary palindromic primes begins(in binary): \n\n11, 101, 111, 10001, 11111, 1001001 You are given a number b (in binary), you should output the first palprime greater than or equal to b. \n\nThe input consists of multiple test cases, each test case consists of a number b in binary. \n\nWe guarantee b will be no Longer than 21 bits\n\nThe first palprime greater than or equal to b\n\n"},{"iden":"input","content":"The input consists of multiple test cases, each test case consists of a number b in binary. We guarantee b will be no Longer than 21 bits"},{"iden":"output","content":"The first palprime greater than or equal to b"},{"iden":"examples","content":"Input101001101000Output1110111110001"}],"translated_statement":null,"sample_group":[],"show_order":[],"formal_statement":"**Definitions**  \nLet $ T = (V, E, w) $ be a weighted undirected tree with $ |V| = N $, where $ w: E \\to \\mathbb{Z}^+ $ is the edge weight function.  \nLet $ S \\subseteq V $ be a dynamic subset of \"special\" cities.  \n\n**Constraints**  \n1. $ 1 \\leq N \\leq 10^5 $  \n2. $ 1 \\leq Q \\leq 10^5 $  \n3. Total sum of $ |S| $ over all type-2 queries $ \\leq 5 \\cdot 10^5 $  \n4. Edge weights $ w(e) \\in [1, 10^9] $  \n\n**Operations**  \n- **Type 1**: Toggle membership of a city $ c \\in V $ in $ S $:  \n  $ S \\leftarrow S \\oplus \\{c\\} $  \n- **Type 2**: Given $ S $, for each $ v \\in S $, compute:  \n  $$\n  f(v) = \\max_{u \\in S \\setminus \\{v\\}} \\text{dist}(v, u)\n  $$  \n  where $ \\text{dist}(v, u) $ is the sum of edge weights along the unique path between $ v $ and $ u $ in $ T $.  \n\n**Objective**  \nFor each type-2 query, output $ f(v) $ for every $ v \\in S $ in the order given in the query.","simple_statement":"You are given a tree with N cities and weighted edges. Some cities are \"special.\" For each special city, find the maximum distance to any other special city. You’ll get Q queries: type 1 adds or removes a city from the special set, type 2 asks for the farthest distance from each currently special city to any other special city.","has_page_source":false}