info
large_stringlengths
120
50k
question
large_stringlengths
504
10.4k
avg@8_qwen3_4b_instruct_2507
float64
0
0.88
{"tests": "{\"inputs\": [\"2 3 2\\n2 1\\n1 2 3\\n1 2 2\\n2 2 1\\n\", \"4 5 3\\n1 2 3\\n1 2 5\\n4 2 1\\n2 3 2\\n1 4 4\\n1 3 3\\n\", \"5 7 4\\n1 2 3 4\\n1 2 3\\n5 1 4\\n3 1 1\\n4 2 5\\n2 5 6\\n2 3 3\\n3 4 6\\n\", \"2 1 2\\n1 2\\n1 2 1000000000\\n\", \"3 2 2\\n2 3\\n1 2 2\\n2 3 1\\n\", \"3 2 2\\n2 3\\n1 2 5\\n2 3 1\\n\", \"4 4 2\\n3 4\\n1 2 1000000000\\n2 3 1000000000\\n3 1 1000000000\\n3 4 1\\n\", \"3 2 2\\n2 3\\n1 2 1000\\n2 3 1\\n\", \"4 3 2\\n1 2\\n1 2 1\\n2 3 2\\n3 4 1\\n\", \"3 2 2\\n1 2\\n1 2 1\\n2 3 2\\n\", \"4 3 2\\n1 4\\n1 2 1\\n2 3 3\\n3 4 1\\n\", \"5 5 2\\n1 2\\n1 2 1\\n2 3 2\\n3 4 2\\n4 5 2\\n5 1 2\\n\", \"5 4 2\\n4 5\\n1 2 10\\n2 3 10\\n3 4 1\\n3 5 1\\n\", \"3 2 2\\n1 2\\n1 2 10\\n2 3 15\\n\", \"3 2 2\\n2 3\\n1 2 100\\n2 3 1\\n\", \"3 2 2\\n1 2\\n1 2 1\\n2 3 5\\n\", \"3 2 2\\n1 2\\n1 2 1\\n2 3 4\\n\", \"4 3 2\\n3 4\\n1 2 2\\n1 3 4\\n3 4 1\\n\", \"6 5 4\\n1 2 3 4\\n1 2 1\\n2 3 1\\n3 4 1\\n4 5 1\\n5 6 10\\n\", \"4 3 3\\n1 2 3\\n1 2 5\\n1 3 4\\n1 4 5\\n\", \"3 2 2\\n1 2\\n1 2 2\\n2 3 3\\n\", \"7 6 2\\n6 7\\n1 2 1\\n2 3 1\\n3 4 1\\n4 5 1\\n5 6 1\\n6 7 1\\n\", \"3 2 2\\n3 2\\n1 2 233\\n2 3 3\\n\", \"4 3 2\\n2 3\\n1 2 100\\n2 3 1\\n3 4 100\\n\", \"4 3 2\\n2 3\\n1 2 1000\\n2 3 1\\n3 4 1000\\n\", \"3 4 2\\n2 1\\n1 2 3\\n1 2 2\\n2 2 1\\n1 3 99\\n\", \"6 5 3\\n1 2 4\\n1 3 3\\n3 2 2\\n2 4 1\\n3 5 4\\n5 6 10\\n\", \"3 2 2\\n1 2\\n1 2 10\\n3 2 20\\n\", \"4 3 2\\n1 4\\n1 2 1\\n2 3 5\\n3 4 1\\n\", \"5 4 2\\n4 5\\n1 2 100\\n2 3 100\\n3 4 100\\n4 5 1\\n\", \"3 2 2\\n1 2\\n1 2 3\\n1 3 5\\n\", \"3 2 2\\n1 2\\n1 2 3\\n2 3 5\\n\", \"3 2 2\\n1 2\\n1 2 3\\n2 3 100\\n\", \"5 4 2\\n4 5\\n1 2 10\\n2 3 10\\n3 4 1\\n4 5 1\\n\", \"3 2 2\\n1 2\\n1 2 1\\n2 3 100\\n\", \"3 2 2\\n1 2\\n1 2 10\\n2 3 100\\n\", \"4 3 2\\n1 2\\n1 2 1\\n2 3 1000\\n3 4 1000\\n\", \"3 2 2\\n2 3\\n1 2 3\\n2 3 1\\n\", \"4 3 2\\n3 4\\n1 2 10000\\n2 3 10000\\n3 4 1\\n\", \"3 3 2\\n1 2\\n1 2 1\\n1 3 1000\\n2 3 1000\\n\", \"2 2 2\\n1 2\\n1 2 3\\n1 2 5\\n\", \"4 3 2\\n3 4\\n1 2 9\\n2 3 6\\n3 4 1\\n\", \"3 2 2\\n1 2\\n1 2 1\\n2 3 1000\\n\", \"4 3 2\\n1 4\\n1 2 3\\n2 3 4\\n3 4 3\\n\", \"5 4 2\\n4 5\\n1 2 100\\n2 3 100\\n3 4 10\\n3 5 20\\n\", \"4 3 2\\n1 2\\n1 2 1\\n2 3 23\\n3 4 1231\\n\", \"4 3 2\\n1 4\\n1 2 4\\n2 3 6\\n3 4 4\\n\", \"4 3 2\\n1 2\\n1 2 1\\n2 3 123\\n3 4 12321\\n\", \"3 2 2\\n2 1\\n1 2 1\\n2 3 100\\n\", \"4 3 2\\n3 4\\n1 2 100\\n2 3 2\\n2 4 2\\n\", \"4 3 2\\n1 2\\n1 2 1\\n2 3 12\\n3 4 123123\\n\", \"4 4 3\\n1 2 3\\n1 2 1\\n1 3 2\\n2 3 3\\n3 4 5\\n\", \"5 4 2\\n1 5\\n1 2 1\\n1 3 2\\n2 4 5\\n3 5 3\\n\", \"3 3 2\\n1 2\\n1 2 1\\n2 3 4\\n1 3 5\\n\", \"4 4 3\\n1 2 3\\n1 2 1\\n2 3 2\\n1 3 3\\n1 4 4\\n\", \"3 2 2\\n1 2\\n1 2 1\\n2 3 47\\n\", \"3 2 2\\n1 2\\n3 2 10\\n2 1 1\\n\", \"3 2 2\\n2 3\\n1 2 10\\n2 3 1\\n\", \"4 3 3\\n1 2 3\\n1 2 1\\n3 1 2\\n4 3 3\\n\", \"4 3 2\\n3 4\\n1 2 5\\n2 3 3\\n2 4 4\\n\", \"3 2 2\\n1 3\\n1 2 1\\n2 3 1\\n\", \"3 2 2\\n1 2\\n1 2 1\\n2 3 3\\n\", \"5 4 3\\n1 2 4\\n1 2 10\\n2 3 100\\n2 4 20\\n5 3 1000\\n\", \"4 5 2\\n2 3\\n1 2 5\\n4 2 1\\n2 3 2\\n1 4 4\\n1 3 3\\n\", \"4 3 3\\n1 2 3\\n1 2 6\\n1 3 7\\n1 4 10\\n\", \"6 5 2\\n1 6\\n1 2 1\\n2 3 2\\n3 4 3\\n4 5 2\\n5 6 1\\n\", \"3 3 2\\n2 3\\n1 2 100\\n1 3 100\\n2 3 1\\n\", \"3 2 2\\n2 3\\n1 2 7\\n2 3 1\\n\"], \"outputs\": [\"2 2 \\n\", \"3 3 3 \\n\", \"5 5 5 5 \\n\", \"1000000000 1000000000 \\n\", \"1 1 \\n\", \"1 1 \\n\", \"1 1 \\n\", \"1 1 \\n\", \"1 1 \\n\", \"1 1 \\n\", \"3 3 \\n\", \"1 1 \\n\", \"1 1 \\n\", \"10 10 \\n\", \"1 1 \\n\", \"1 1 \\n\", \"1 1 \\n\", \"1 1 \\n\", \"1 1 1 1 \\n\", \"5 5 5 \\n\", \"2 2 \\n\", \"1 1 \\n\", \"3 3 \\n\", \"1 1 \\n\", \"1 1 \\n\", \"2 2 \\n\", \"3 3 3 \\n\", \"10 10 \\n\", \"5 5 \\n\", \"1 1 \\n\", \"3 3 \\n\", \"3 3 \\n\", \"3 3 \\n\", \"1 1 \\n\", \"1 1 \\n\", \"10 10 \\n\", \"1 1 \\n\", \"1 1 \\n\", \"1 1 \\n\", \"1 1 \\n\", \"3 3 \\n\", \"1 1 \\n\", \"1 1 \\n\", \"4 4 \\n\", \"20 20 \\n\", \"1 1 \\n\", \"6 6 \\n\", \"1 1 \\n\", \"1 1 \\n\", \"2 2 \\n\", \"1 1 \\n\", \"2 2 2 \\n\", \"3 3 \\n\", \"1 1 \\n\", \"2 2 2 \\n\", \"1 1 \\n\", \"1 1 \\n\", \"1 1 \\n\", \"2 2 2 \\n\", \"4 4 \\n\", \"1 1 \\n\", \"1 1 \\n\", \"20 20 20 \\n\", \"2 2 \\n\", \"7 7 7 \\n\", \"3 3 \\n\", \"1 1 \\n\", \"1 1 \\n\"]}", "source": "primeintellect"}
Chouti was tired of the tedious homework, so he opened up an old programming problem he created years ago. You are given a connected undirected graph with $n$ vertices and $m$ weighted edges. There are $k$ special vertices: $x_1, x_2, \ldots, x_k$. Let's define the cost of the path as the maximum weight of the edges in it. And the distance between two vertexes as the minimum cost of the paths connecting them. For each special vertex, find another special vertex which is farthest from it (in terms of the previous paragraph, i.e. the corresponding distance is maximum possible) and output the distance between them. The original constraints are really small so he thought the problem was boring. Now, he raises the constraints and hopes you can solve it for him. -----Input----- The first line contains three integers $n$, $m$ and $k$ ($2 \leq k \leq n \leq 10^5$, $n-1 \leq m \leq 10^5$) — the number of vertices, the number of edges and the number of special vertices. The second line contains $k$ distinct integers $x_1, x_2, \ldots, x_k$ ($1 \leq x_i \leq n$). Each of the following $m$ lines contains three integers $u$, $v$ and $w$ ($1 \leq u,v \leq n, 1 \leq w \leq 10^9$), denoting there is an edge between $u$ and $v$ of weight $w$. The given graph is undirected, so an edge $(u, v)$ can be used in the both directions. The graph may have multiple edges and self-loops. It is guaranteed, that the graph is connected. -----Output----- The first and only line should contain $k$ integers. The $i$-th integer is the distance between $x_i$ and the farthest special vertex from it. -----Examples----- Input 2 3 2 2 1 1 2 3 1 2 2 2 2 1 Output 2 2 Input 4 5 3 1 2 3 1 2 5 4 2 1 2 3 2 1 4 4 1 3 3 Output 3 3 3 -----Note----- In the first example, the distance between vertex $1$ and $2$ equals to $2$ because one can walk through the edge of weight $2$ connecting them. So the distance to the farthest node for both $1$ and $2$ equals to $2$. In the second example, one can find that distance between $1$ and $2$, distance between $1$ and $3$ are both $3$ and the distance between $2$ and $3$ is $2$. The graph may have multiple edges between and self-loops, as in the first example. Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0.25
{"tests": "{\"inputs\": [\"1 2 2 1\\n\", \"1 1 1 2\\n\", \"2 12 3 1\\n\", \"4 6 2 1\\n\", \"4 6 2 2\\n\", \"6 4 2 2\\n\", \"10 1 3 3\\n\", \"5 3 1 1\\n\", \"50 22 5 5\\n\", \"6 20 1 1\\n\", \"42 42 2 3\\n\", \"42 42 3 2\\n\", \"45 54 4 5\\n\", \"6 5 4 3\\n\", \"42 42 42 42\\n\", \"1 100 42 42\\n\", \"1 100 1000 100\\n\", \"1 1 1000 100\\n\", \"100 100 1000 100\\n\", \"1 8 1 4\\n\", \"9 4 5 2\\n\", \"2 6 6 2\\n\", \"7 8 5 9\\n\", \"3 7 8 6\\n\", \"69 69 803 81\\n\", \"67 67 871 88\\n\", \"71 71 891 31\\n\", \"49 49 631 34\\n\", \"83 83 770 49\\n\", \"49 49 163 15\\n\", \"38 38 701 74\\n\", \"65 65 803 79\\n\", \"56 56 725 64\\n\", \"70 70 176 56\\n\", \"32 32 44 79\\n\", \"35 35 353 21\\n\", \"57 57 896 52\\n\", \"86 86 373 19\\n\", \"27 27 296 97\\n\", \"60 60 86 51\\n\", \"40 40 955 95\\n\", \"34 34 706 59\\n\", \"74 74 791 51\\n\", \"69 69 443 53\\n\", \"59 19 370 48\\n\", \"78 82 511 33\\n\", \"66 90 805 16\\n\", \"60 61 772 19\\n\", \"81 13 607 21\\n\", \"35 79 128 21\\n\", \"93 25 958 20\\n\", \"44 85 206 80\\n\", \"79 99 506 18\\n\", \"97 22 29 8\\n\", \"14 47 184 49\\n\", \"74 33 868 5\\n\", \"53 79 823 11\\n\", \"99 99 913 42\\n\", \"52 34 89 41\\n\", \"87 100 200 80\\n\", \"40 94 510 53\\n\", \"2 56 438 41\\n\", \"6 68 958 41\\n\", \"44 80 814 26\\n\", \"100 1 1000 100\\n\", \"1 3 1000 100\\n\", \"10 10 1000 100\\n\"], \"outputs\": [\"6\\n\", \"31\\n\", \"0\\n\", \"3\\n\", \"122\\n\", \"435\\n\", \"112812\\n\", \"8\\n\", \"876439301\\n\", \"0\\n\", \"6937\\n\", \"1085\\n\", \"433203628\\n\", \"282051\\n\", \"284470145\\n\", \"58785421\\n\", \"542673827\\n\", \"922257788\\n\", \"922257788\\n\", \"1\\n\", \"11045\\n\", \"8015\\n\", \"860378382\\n\", \"510324293\\n\", \"74925054\\n\", \"123371511\\n\", \"790044038\\n\", \"764129060\\n\", \"761730117\\n\", \"458364105\\n\", \"496603581\\n\", \"253679300\\n\", \"338598412\\n\", \"990579000\\n\", \"20803934\\n\", \"149936279\\n\", \"271910130\\n\", \"940701970\\n\", \"394599845\\n\", \"277883413\\n\", \"600387428\\n\", \"274236101\\n\", \"367968499\\n\", \"385620893\\n\", \"125206836\\n\", \"375900871\\n\", \"593436252\\n\", \"931528755\\n\", \"762608093\\n\", \"177972209\\n\", \"873170266\\n\", \"170080402\\n\", \"486170430\\n\", \"471632954\\n\", \"726421144\\n\", \"826980486\\n\", \"526626321\\n\", \"446683872\\n\", \"905639400\\n\", \"913761305\\n\", \"233079261\\n\", \"500592304\\n\", \"719351710\\n\", \"414148151\\n\", \"603336175\\n\", \"604187087\\n\", \"922257788\\n\"]}", "source": "primeintellect"}
Memory and his friend Lexa are competing to get higher score in one popular computer game. Memory starts with score a and Lexa starts with score b. In a single turn, both Memory and Lexa get some integer in the range [ - k;k] (i.e. one integer among - k, - k + 1, - k + 2, ..., - 2, - 1, 0, 1, 2, ..., k - 1, k) and add them to their current scores. The game has exactly t turns. Memory and Lexa, however, are not good at this game, so they both always get a random integer at their turn. Memory wonders how many possible games exist such that he ends with a strictly higher score than Lexa. Two games are considered to be different if in at least one turn at least one player gets different score. There are (2k + 1)^2t games in total. Since the answer can be very large, you should print it modulo 10^9 + 7. Please solve this problem for Memory. -----Input----- The first and only line of input contains the four integers a, b, k, and t (1 ≤ a, b ≤ 100, 1 ≤ k ≤ 1000, 1 ≤ t ≤ 100) — the amount Memory and Lexa start with, the number k, and the number of turns respectively. -----Output----- Print the number of possible games satisfying the conditions modulo 1 000 000 007 (10^9 + 7) in one line. -----Examples----- Input 1 2 2 1 Output 6 Input 1 1 1 2 Output 31 Input 2 12 3 1 Output 0 -----Note----- In the first sample test, Memory starts with 1 and Lexa starts with 2. If Lexa picks - 2, Memory can pick 0, 1, or 2 to win. If Lexa picks - 1, Memory can pick 1 or 2 to win. If Lexa picks 0, Memory can pick 2 to win. If Lexa picks 1 or 2, Memory cannot win. Thus, there are 3 + 2 + 1 = 6 possible games in which Memory wins. Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0
{"tests": "{\"inputs\": [\"3 250 185 230\\n0 185 250\\n\", \"4 250 185 230\\n0 20 185 250\\n\", \"2 300 185 230\\n0 300\\n\", \"4 300 4 5\\n0 6 7 300\\n\", \"2 100 30 70\\n0 100\\n\", \"2 300 140 160\\n0 300\\n\", \"4 300 1 2\\n0 298 299 300\\n\", \"3 350 150 160\\n0 310 350\\n\", \"4 300 4 5\\n0 298 299 300\\n\", \"19 180 117 148\\n0 1 19 20 21 28 57 65 68 70 78 88 100 116 154 157 173 179 180\\n\", \"14 134 99 114\\n0 6 8 19 50 61 69 83 84 96 111 114 125 134\\n\", \"18 187 27 157\\n0 17 18 31 36 37 40 53 73 86 96 107 119 150 167 181 184 187\\n\", \"20 179 69 120\\n0 6 8 11 21 24 55 61 83 84 96 111 114 116 125 140 147 154 176 179\\n\", \"16 115 62 112\\n0 5 24 32 38 43 44 57 62 72 74 92 103 105 113 115\\n\", \"112 1867 1261 1606\\n0 7 17 43 67 70 87 112 129 141 148 162 179 180 189 202 211 220 231 247 250 277 308 311 327 376 400 406 409 417 418 444 480 512 514 515 518 547 572 575 578 587 612 617 654 684 701 742 757 761 788 821 825 835 841 843 850 858 869 872 881 936 939 969 970 971 997 1026 1040 1045 1068 1070 1073 1076 1095 1110 1115 1154 1166 1178 1179 1203 1204 1225 1237 1241 1246 1275 1302 1305 1311 1312 1315 1338 1340 1419 1428 1560 1561 1576 1591 1594 1618 1643 1658 1660 1664 1689 1803 1822 1835 1867\\n\", \"2 2 1 2\\n0 2\\n\", \"3 2 1 2\\n0 1 2\\n\", \"3 10 2 3\\n0 1 10\\n\", \"4 10 3 5\\n0 1 9 10\\n\", \"5 1000 777 778\\n0 1 500 501 1000\\n\", \"3 10 1 3\\n0 2 10\\n\", \"4 300 120 150\\n0 110 140 300\\n\", \"5 401 300 400\\n0 100 250 350 401\\n\", \"3 10 1 8\\n0 7 10\\n\", \"4 1000 2 3\\n0 400 405 1000\\n\", \"6 12 7 10\\n0 1 3 4 6 12\\n\", \"4 1000 10 20\\n0 500 530 1000\\n\", \"3 8 2 3\\n0 7 8\\n\", \"4 10 8 9\\n0 4 5 10\\n\", \"4 10 7 8\\n0 5 6 10\\n\", \"6 35 29 30\\n0 10 11 31 32 35\\n\", \"5 200000 1 100029\\n0 100000 100009 100010 200000\\n\", \"4 1000 900 901\\n0 950 951 1000\\n\", \"6 504 400 500\\n0 3 5 103 105 504\\n\", \"5 550 300 400\\n0 151 251 450 550\\n\", \"4 300 40 50\\n0 280 290 300\\n\", \"2 1000000000 100000000 500000000\\n0 1000000000\\n\", \"4 600 100 400\\n0 50 350 600\\n\", \"4 100 7 8\\n0 3 4 100\\n\", \"4 100 80 81\\n0 2 3 100\\n\", \"3 13 8 10\\n0 2 13\\n\", \"4 10 7 8\\n0 4 5 10\\n\", \"3 450 100 400\\n0 150 450\\n\", \"4 500 30 50\\n0 20 40 500\\n\", \"4 100 10 11\\n0 4 5 100\\n\", \"2 10 5 7\\n0 10\\n\", \"6 100 70 71\\n0 50 51 90 91 100\\n\", \"4 9 6 7\\n0 4 5 9\\n\", \"3 10 1 8\\n0 3 10\\n\", \"3 12 1 2\\n0 10 12\\n\", \"4 100 3 5\\n0 40 48 100\\n\", \"3 20 17 18\\n0 19 20\\n\", \"4 1000 45 46\\n0 2 3 1000\\n\", \"4 10 5 7\\n0 4 6 10\\n\", \"3 12 1 3\\n0 10 12\\n\", \"4 20 6 7\\n0 1 15 20\\n\", \"3 11 3 5\\n0 9 11\\n\", \"3 100 9 10\\n0 99 100\\n\", \"3 10 7 8\\n0 1 10\\n\", \"3 10 5 6\\n0 9 10\\n\", \"3 10 7 8\\n0 9 10\\n\", \"3 10 6 7\\n0 9 10\\n\", \"3 9 6 7\\n0 1 9\\n\", \"3 1000000000 99 100\\n0 1 1000000000\\n\", \"4 10 3 5\\n0 2 4 10\\n\", \"4 100 90 91\\n0 7 8 100\\n\", \"4 100 80 81\\n0 98 99 100\\n\"], \"outputs\": [\"1\\n230\\n\", \"0\\n\", \"2\\n185 230\\n\", \"1\\n11\\n\", \"1\\n30\\n\", \"1\\n140\\n\", \"0\\n\", \"1\\n150\\n\", \"1\\n294\\n\", \"2\\n117 148\\n\", \"1\\n99\\n\", \"1\\n27\\n\", \"1\\n27\\n\", \"1\\n112\\n\", \"1\\n1808\\n\", \"1\\n1\\n\", \"0\\n\", \"1\\n3\\n\", \"1\\n4\\n\", \"1\\n778\\n\", \"1\\n3\\n\", \"1\\n260\\n\", \"1\\n400\\n\", \"1\\n8\\n\", \"1\\n402\\n\", \"1\\n10\\n\", \"1\\n510\\n\", \"1\\n5\\n\", \"2\\n8 9\\n\", \"2\\n7 8\\n\", \"1\\n2\\n\", \"1\\n100029\\n\", \"1\\n50\\n\", \"1\\n503\\n\", \"1\\n150\\n\", \"1\\n240\\n\", \"2\\n100000000 500000000\\n\", \"1\\n450\\n\", \"1\\n11\\n\", \"1\\n83\\n\", \"1\\n10\\n\", \"2\\n7 8\\n\", \"1\\n50\\n\", \"1\\n50\\n\", \"1\\n15\\n\", \"2\\n5 7\\n\", \"1\\n20\\n\", \"2\\n6 7\\n\", \"1\\n2\\n\", \"1\\n1\\n\", \"1\\n43\\n\", \"1\\n2\\n\", \"1\\n48\\n\", \"2\\n5 7\\n\", \"1\\n9\\n\", \"1\\n7\\n\", \"1\\n6\\n\", \"1\\n90\\n\", \"1\\n8\\n\", \"1\\n4\\n\", \"1\\n2\\n\", \"1\\n3\\n\", \"1\\n7\\n\", \"1\\n100\\n\", \"1\\n5\\n\", \"1\\n98\\n\", \"1\\n18\\n\"]}", "source": "primeintellect"}
Valery is a PE teacher at a school in Berland. Soon the students are going to take a test in long jumps, and Valery has lost his favorite ruler! However, there is no reason for disappointment, as Valery has found another ruler, its length is l centimeters. The ruler already has n marks, with which he can make measurements. We assume that the marks are numbered from 1 to n in the order they appear from the beginning of the ruler to its end. The first point coincides with the beginning of the ruler and represents the origin. The last mark coincides with the end of the ruler, at distance l from the origin. This ruler can be repesented by an increasing sequence a_1, a_2, ..., a_{n}, where a_{i} denotes the distance of the i-th mark from the origin (a_1 = 0, a_{n} = l). Valery believes that with a ruler he can measure the distance of d centimeters, if there is a pair of integers i and j (1 ≤ i ≤ j ≤ n), such that the distance between the i-th and the j-th mark is exactly equal to d (in other words, a_{j} - a_{i} = d). Under the rules, the girls should be able to jump at least x centimeters, and the boys should be able to jump at least y (x < y) centimeters. To test the children's abilities, Valery needs a ruler to measure each of the distances x and y. Your task is to determine what is the minimum number of additional marks you need to add on the ruler so that they can be used to measure the distances x and y. Valery can add the marks at any integer non-negative distance from the origin not exceeding the length of the ruler. -----Input----- The first line contains four positive space-separated integers n, l, x, y (2 ≤ n ≤ 10^5, 2 ≤ l ≤ 10^9, 1 ≤ x < y ≤ l) — the number of marks, the length of the ruler and the jump norms for girls and boys, correspondingly. The second line contains a sequence of n integers a_1, a_2, ..., a_{n} (0 = a_1 < a_2 < ... < a_{n} = l), where a_{i} shows the distance from the i-th mark to the origin. -----Output----- In the first line print a single non-negative integer v — the minimum number of marks that you need to add on the ruler. In the second line print v space-separated integers p_1, p_2, ..., p_{v} (0 ≤ p_{i} ≤ l). Number p_{i} means that the i-th mark should be at the distance of p_{i} centimeters from the origin. Print the marks in any order. If there are multiple solutions, print any of them. -----Examples----- Input 3 250 185 230 0 185 250 Output 1 230 Input 4 250 185 230 0 20 185 250 Output 0 Input 2 300 185 230 0 300 Output 2 185 230 -----Note----- In the first sample it is impossible to initially measure the distance of 230 centimeters. For that it is enough to add a 20 centimeter mark or a 230 centimeter mark. In the second sample you already can use the ruler to measure the distances of 185 and 230 centimeters, so you don't have to add new marks. In the third sample the ruler only contains the initial and the final marks. We will need to add two marks to be able to test the children's skills. Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0.125
{"tests": "{\"inputs\": [\"5 5\\n3 1 2 2 4\\n\", \"4 5\\n2 3 4 5\\n\", \"2 2\\n1 1\\n\", \"5 5\\n5 5 5 5 5\\n\", \"5 20\\n5 5 5 5 5\\n\", \"2 3\\n2 2\\n\", \"4 5\\n2 2 2 2\\n\", \"5 6\\n2 2 2 2 7\\n\", \"1 1\\n1\\n\", \"5 5\\n1 1 1 1 1\\n\", \"3 3\\n10 10 10\\n\", \"2 3\\n5 5\\n\", \"1 100\\n1\\n\", \"1 4\\n1\\n\", \"4 4\\n4 4 4 4\\n\", \"2 100\\n5 5\\n\", \"5 5\\n3 3 3 3 3\\n\", \"1 5\\n1\\n\", \"1 1\\n4\\n\", \"1 5\\n5\\n\", \"1 10\\n1000\\n\", \"3 3\\n1 1 1\\n\", \"5 5\\n4 4 4 4 4\\n\", \"2 5\\n2 2\\n\", \"2 3\\n1 1\\n\", \"2 2\\n5 5\\n\", \"4 10\\n2 2 2 2\\n\", \"4 4\\n1 1 1 1\\n\", \"10 10\\n1 1 1 1 1 1 1 1 1 1\\n\", \"1 2\\n1\\n\", \"5 6\\n3 3 3 3 3\\n\", \"2 2\\n3 3\\n\", \"2 2\\n1 9\\n\", \"1 200000\\n200000\\n\", \"3 3\\n1 200000 200000\\n\", \"1 1\\n3\\n\", \"3 3\\n3 3 3\\n\", \"3 3\\n5 5 5\\n\", \"2 10\\n1 9\\n\", \"2 10\\n2 2\\n\", \"3 3\\n100 100 100\\n\", \"5 5\\n2 2 2 2 2\\n\", \"2 1000000000\\n1 10\\n\", \"4 6\\n1 3 3 3\\n\", \"5 5\\n8 8 8 8 8\\n\", \"2 10\\n1 2\\n\", \"1 44550514\\n127593\\n\", \"1 10\\n10\\n\", \"3 4\\n3 3 3\\n\", \"4 6\\n1 1 1 1\\n\", \"2 2\\n2 2\\n\", \"5 5\\n5 5 5 5 11\\n\", \"3 10\\n2 2 2\\n\", \"4 5\\n4 4 4 4\\n\", \"5 5\\n1 1 1 1 2\\n\", \"5 15\\n2 2 2 2 2\\n\", \"4 6\\n2 2 2 2\\n\", \"1 4\\n2\\n\", \"10 10\\n3 3 3 3 3 3 3 3 3 3\\n\", \"4 5\\n1 2 4 2\\n\", \"1 1\\n234\\n\", \"4 4\\n2 4 4 4\\n\", \"4 5\\n3 3 3 4\\n\", \"5 10\\n2 2 2 2 3\\n\", \"1 2164\\n10648\\n\", \"2 25584\\n13182 19648\\n\", \"2 1000000000\\n1 2\\n\"], \"outputs\": [\"2\\n\", \"2\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"1\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"4\\n\", \"0\\n\", \"199999\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"1\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"1\\n\", \"1\\n\", \"0\\n\", \"1\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"2\\n\", \"0\\n\", \"0\\n\", \"1\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"1\\n\", \"0\\n\", \"2\\n\", \"1\\n\", \"1\\n\", \"0\\n\", \"1\\n\", \"1\\n\"]}", "source": "primeintellect"}
There is a toy building consisting of $n$ towers. Each tower consists of several cubes standing on each other. The $i$-th tower consists of $h_i$ cubes, so it has height $h_i$. Let's define operation slice on some height $H$ as following: for each tower $i$, if its height is greater than $H$, then remove some top cubes to make tower's height equal to $H$. Cost of one "slice" equals to the total number of removed cubes from all towers. Let's name slice as good one if its cost is lower or equal to $k$ ($k \ge n$). [Image] Calculate the minimum number of good slices you have to do to make all towers have the same height. Of course, it is always possible to make it so. -----Input----- The first line contains two integers $n$ and $k$ ($1 \le n \le 2 \cdot 10^5$, $n \le k \le 10^9$) — the number of towers and the restriction on slices, respectively. The second line contains $n$ space separated integers $h_1, h_2, \dots, h_n$ ($1 \le h_i \le 2 \cdot 10^5$) — the initial heights of towers. -----Output----- Print one integer — the minimum number of good slices you have to do to make all towers have the same heigth. -----Examples----- Input 5 5 3 1 2 2 4 Output 2 Input 4 5 2 3 4 5 Output 2 -----Note----- In the first example it's optimal to make $2$ slices. The first slice is on height $2$ (its cost is $3$), and the second one is on height $1$ (its cost is $4$). Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0.625
{"tests": "{\"inputs\": [\"2 2 3\\n\", \"4 2 3\\n\", \"1499 1498 1500\\n\", \"1500 1500 1500\\n\", \"100 4 1\\n\", \"4 2 4\\n\", \"3 3 3\\n\", \"2 3 6\\n\", \"2 3 3\\n\", \"4 4 2\\n\", \"1 1 1\\n\", \"2 11 2\\n\", \"4 4 4\\n\", \"4 4 5\\n\", \"3 3 2\\n\", \"3 6 6\\n\", \"2 3 2\\n\", \"1 1 3\\n\", \"3 3 4\\n\", \"2 4 4\\n\", \"2 2 2\\n\", \"2 10 10\\n\", \"3 4 4\\n\", \"2 5 5\\n\", \"2 4 5\\n\", \"228 2 2\\n\", \"2 998 1000\\n\", \"2 6 6\\n\", \"6 4 7\\n\", \"2 5 2\\n\", \"2 100 100\\n\", \"7 7 2\\n\", \"3 3 6\\n\", \"82 3 82\\n\", \"2 3 5\\n\", \"1 218 924\\n\", \"4 4 123\\n\", \"4 4 3\\n\", \"3 4 2\\n\", \"2 2 5\\n\", \"2 10 2\\n\", \"5 2 2\\n\", \"3 3 9\\n\", \"1 5 5\\n\", \"2 4 6\\n\", \"15 3 3\\n\", \"1 5 10\\n\", \"2 3 14\\n\", \"1265 2 593\\n\", \"2 2 567\\n\", \"1 6 5\\n\", \"2 2 7\\n\", \"2 2 1500\\n\", \"3 6 9\\n\", \"1 46 79\\n\", \"4 3 3\\n\", \"2 4 8\\n\", \"1493 1489 1487\\n\", \"1 2 3\\n\", \"1 2 5\\n\", \"1 2 8\\n\", \"3 4 5\\n\", \"2 2 4\\n\", \"3 2 3\\n\", \"7 2 2\\n\", \"3 2 2\\n\", \"6 7 4\\n\"], \"outputs\": [\"YES\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"YES\\n\", \"YES\\n\", \"YES\\n\", \"NO\\n\", \"NO\\n\", \"YES\\n\", \"YES\\n\", \"YES\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"YES\\n\", \"YES\\n\", \"NO\\n\", \"YES\\n\", \"YES\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"YES\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"YES\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"YES\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"YES\\n\", \"YES\\n\", \"YES\\n\", \"NO\\n\", \"YES\\n\", \"NO\\n\", \"NO\\n\", \"YES\\n\", \"NO\\n\", \"NO\\n\", \"YES\\n\", \"YES\\n\", \"YES\\n\", \"YES\\n\", \"NO\\n\", \"YES\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"YES\\n\", \"YES\\n\", \"YES\\n\", \"NO\\n\", \"YES\\n\", \"NO\\n\", \"YES\\n\", \"YES\\n\", \"NO\\n\"]}", "source": "primeintellect"}
Mishka is decorating the Christmas tree. He has got three garlands, and all of them will be put on the tree. After that Mishka will switch these garlands on. When a garland is switched on, it periodically changes its state — sometimes it is lit, sometimes not. Formally, if i-th garland is switched on during x-th second, then it is lit only during seconds x, x + k_{i}, x + 2k_{i}, x + 3k_{i} and so on. Mishka wants to switch on the garlands in such a way that during each second after switching the garlands on there would be at least one lit garland. Formally, Mishka wants to choose three integers x_1, x_2 and x_3 (not necessarily distinct) so that he will switch on the first garland during x_1-th second, the second one — during x_2-th second, and the third one — during x_3-th second, respectively, and during each second starting from max(x_1, x_2, x_3) at least one garland will be lit. Help Mishka by telling him if it is possible to do this! -----Input----- The first line contains three integers k_1, k_2 and k_3 (1 ≤ k_{i} ≤ 1500) — time intervals of the garlands. -----Output----- If Mishka can choose moments of time to switch on the garlands in such a way that each second after switching the garlands on at least one garland will be lit, print YES. Otherwise, print NO. -----Examples----- Input 2 2 3 Output YES Input 4 2 3 Output NO -----Note----- In the first example Mishka can choose x_1 = 1, x_2 = 2, x_3 = 1. The first garland will be lit during seconds 1, 3, 5, 7, ..., the second — 2, 4, 6, 8, ..., which already cover all the seconds after the 2-nd one. It doesn't even matter what x_3 is chosen. Our choice will lead third to be lit during seconds 1, 4, 7, 10, ..., though. In the second example there is no way to choose such moments of time, there always be some seconds when no garland is lit. Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0
{"tests": "{\"inputs\": [\"5\\nabaca\\n\", \"8\\nabcddcba\\n\", \"1\\nx\\n\", \"500\\nbbababaabaabaabbbbbbaabbabbabbaabababababbbbabaaabbbbaaabbbbbbbabababaaaaabbbbabaababbababbaaaaaabbaaabbaabaaababbbbbabbaabaabaabbbaaabaabbaaabbaabababbaaabaaabaaaaabbbababaabbbbabbbbbababbbaabaabbabaabbabbababbbbbaababbaabbbbbbbbaabbabbbabababaaaaaaaaaabababaaabbaabbbabbabbbbabbbaabaaabbbaabbabbbbbbbaaabbbabaaaaaabaabbbabbbbaaaabbbbbbabaaaaaaabbbbbbabababbaabbbaabaabbbabbbbaaaabbbbbabaaababbababbbabaaabbbbaababaababaaaaabbbaabbababaabaaabaaabbbbbabbbabbaaabbbbbbbaaaaabaaabbabaabbabbbbbbbbabbbab\\n\", \"500\\nccacbbbbbbbccbccbccbacbabcaaaabbcbcaabbababcbbcbcbbcbabbacbacbacbcaccccaaccbabcbbbbccbbaacbcbcaaabbbbbaaabbabacacaabcaababcbbcbcababbbabbaaaccbcabcabbbcbcccbcbcacabbbbbacbcbabbcbaabcbcbcacacccabbbccacaacaaccbbabbbaaccabcaaaaacbbcacacbacabbccaaaccccaabbaacbabbcbccababbabacabbcacbcbaaccbcaccabbbbacabcbccbabacbcbaaaacbbcbccacaaaabacaabbaaccabacababcbcbcacbcccccbbabbccbaabcbaaabbcbacacbbbbabbacbabbabbaacccbaababccaaccbaaabcaccaaacbbbcaabcbcbcbccbbbbcbacbccbabcbbcbbbabbcbaccabacbbbabcbcbcbbbacccbabab\\n\", \"500\\ndadcbaaaabbddbbacdbabdcbcdcabacbddddbaabacbcabdccdcdadcbabdbcabcccbdcabdcaacdbabdcbbbdbacdddaaddccbacabbdbbcbbcadcdaadcababbbacabcdbbbadbdacbcddbccdbacbddbdababdcadbbabccbcdcccccadbbdbdbdcbcbdcddaacdababdddacadaddcdcbaabaddaadacbaadcdcacbdcbaddddbdbddacaadaaaaabdccccbccbcabddbbcaacadccdbcccdcdbbabbcbabdbccdcdbcbbadaaadddcbcbbbabbadcddbaaabbbdabbcbcacbbaaaddbcbaccaaadcdbcdbbbbbcdbbbcdadacdbcbbaaddbdabcbccabbadadbbbbdccacbbbacacadbcaadbccdbadacdaddacddcccbcbdbdbcbdbdaabdcdabbaadcdccdbdcccadabdbddd\\n\", \"500\\neebcacaadebcdebdeaaaceaabacabbaadaadebbceeabbdbdbaaeababdaeddabbeebccbcbbdbdecececebdcceaddbbabbcdadcacecedaabbeeaaddbbddddddadcaeeebabeaadbaabcecadaabbabcbeadbdaabebeeadbadcaadbecdcecaeeebeebbececdeddbdcdccacaeccbdcbbeeeedeabdceaaacdbbddaceccbeaedbadcebebdceeabadeceeedecaaeedeebabdadcaeabdadaeabcbccdacbabcacbcaeadbacbddbcecddebeabbedbcadeeeaebabbeccdbadceccaeecdaccccceeccbebabaaaacedaadbbaddacbaedccabeaddbedaadacedacdbcabddbeaaecaebddecddacbbceebeacadeeaadcbdcbccbccdcddabdcecaebadccccaeadddacbe\\n\", \"500\\nbceeccdebbecfffabeeeeaceaaeeecccfcafeefdadfbfceaacceacabefbceaaeefabaabaabcefdcdccabeddbdabebcbdfdbbfcefffcccedbbfbcbafcabaddcdfecedfdeafccbfbbabaabaccadfcaccdbdbbbacfcebebcadecabdfcefddffbffabbaaddbccdaadeadefebcdfefddceefcdeefbbeeebdcaacdcfafcdbadbaeadcbfbbcaacdeacbceddefebbaddbadaeebefcffcecbacfeabebfbeabdfbefeeeaaeebcdfecedecdeeeefcaeaeffcafcecedddcbbffbeaadfbfcccfbeacfddbbfccbafdfccebbbfadebbceedfafcbffbacafdbcaabdbcfdceffbbdbceaefcabfbbeedffecaafccaafbeadaaabedccfcecceebebfdfcbedaddfeefcea\\n\", \"500\\nafdfdcfebagfdcdbacdeggffebbcgfdbeeeegbgagaccbgegdfbffdbfaaeabebcgcabdebdeadbggadffdedfgadbdcdeacffebbceefedbeabeaefdcgddaccfaagcaedgdcfeafaaadfgcgcabdddgcccbbaeccgbfefaggabddeaffbaabadfbddcdafcfdaedbdfafgagddgdgdfdabbceddfcffafbabefeadecccadebbbfeegbfdgbbaaffgeaagegbbeddfbfeeecdagbfacffebbbfcfeffbcddaaecadfdbegfacbfeeggdbacfgecfbgfdfacffebfabddebgcdfdaacdedgeggdbaadagebbdbfdcbbbbbfabafddebfaffacffccdbccedbaadbdcgbedbddebbcadfbgdgfagffgacgeadbdgedcccgbcecadgbdcafbffggcccfffbffaefdbcdgdeefceceaagd\\n\", \"500\\ndbcbdhbacghbacfeaecddchgffchhbhheacheagadabedhfcgfbgfahgebdgdecfgeaggebahhbhaaeagdhbadegebdfbededdffdfcbebhchgahafdegbbhhgaecadcdhaecbbceaefbadgedfhgfdaeheeeabbehbeddhdgdhbegefdffdbeebdegdbefbadbehacecdaedbeeedehfhddeggdafaagehefcefbghadhbehgbdehaeaeeecbbagbdefafhcgffgcfeefehgddgggbegcaabcfehcdbfcbbccheeafebdfageefeafafhffdaadcddgbfaegafbhafdbhfgebaaebegcddgcadddfgfcddggbdffffhghcbghbhdcebeacagbdfadhdbghaeacadbccbbebhfeeaghgebghbabbfhcdfagccaadhhgdeechghceefaaeacheedhbdaedcffhcgfeagdgfdchghbbfbf\\n\", \"500\\nahecidbhaccbabcggeceaebgcbaeagehfhgiebafdcgiiehegggcdfbdccicbfficggabdhfihheadafdcccbbgbgfgehchdbihdidddagdafigbbbhgaiagiacbhhegdgchcfiabbiidhhfbabdfehcifgegieihfibheedfbiadbfdafdgbehfeifgcfhieiaheebeiiabggbecedchhicfeccfadhbfgahefdchibaecbifeadfdadfefifeibcbbibibbcchadbbbedcbgeiefdhedddedhfeecfafggghdffbcgigigeeieeafgciececicgeegafbcdahighgahgdeahfhfebegebfedfdfadiafdcdebgeacedeiecdcaghibhedaaecdaahdaecdbahcfchebiafcfhacabcgbaadibgfgbdcebifdafbgabageebfeebefhffdcdgehgfchiabfabcbefhccehffibaeiac\\n\", \"500\\ncachgdaghedbbfbcbicbabfcahhbeaafeaafgcaafcabeabccbbbjhjbjcabcfdcbjedeaijeebcabbfaiicebgfbchcaeachceigihhbifcdgdfhdjabjajfhhfajddghebbdiegadfahdahddfdeaagjfgafhjhfbeehbgahgeefggdgdcfcifagibijcgifehjccfggajjfajecbffdedfhgebfefibeiceigcddfjhgcghbbhjbhficggfighjdijjefcjchdihgfdcjgeeeiicihfdhbibijhgjdgdhcafdaafbfgjgcggidgebchbejiidjgbfcbcjejgfgeiaaebeajhdaijhgbebeefchahbbgcgegieagcdahgdfbidehbfafbigadjdedhdhaegbbcgifeahgchiafffjgfgaajjhedbiffbbjdijehdfiegiabeadfcifcbjjhidiieebaiffdjfhfidffgfchchegjed\\n\", \"500\\ndffchafckjeihjicjdebhahafcdcbbghebdedkdgihgdeddjijdadgaggfciedejdgicbjjjidfbfjecabddaggidbfaadbhcgddagkcdbhdakceidkaekefhcdjgadefidfjbcejeeghbaffkabeejidkkcdfkijeiehiedfacjbhbahkckidjdekbgkdfjkibhahegghbdaggcejbkkgkiaibbefjfkgfghikifaaeekjafdcgefibgfdhahicfidbgbcebfekjkikekjdedieiifddgcfekaifabgafahegkhjfjdjjefbebcigikafjcbcijbjfkdbiaaibbjejehhacejakikjfebabjffhcgikbcedhdefkakibdjbekdkdbhfaafcigahbabcjibbgkaikkagakakbcahfkgjfjiccicchggagifajggckjckffdaehdejfihcdkjkcahakibfbakhheiacgkhbhhbjjkcbke\\n\", \"500\\ndkhedelgflihgabkcjkjdjggkfahheklbffhaidljfikfjgbckejfahehkiieflelcifagakijiajjhhdglhibeaagehkiihcjgijlfdaejaacehejbilefhgijeebfefgbccfgdebkledbjbjilcggaiekacehlikekdcebeidhfbdgkahifgilhcdbikbfdlheefgbebikfcbihjlliegabgfjlbdallhjgdahffcdcblbjekfijalefkaklfglggaikcacllhdcfilbkbelcfdgaafahhdkcjgafddhfaijakffdhfafbgfhlaccbhjlaeaaajfaagdhfehdiflehghfiidjcachclgddkkgkllcdldekgflakgalekefffakklgjejjlfjblkjilhfdckahbedeckhfefkfjlgaflffgfkkhacchgjceelechdceehfhjbecgiflajlechkldhjgbeeijbadikbhiddjjbfficfa\\n\", \"500\\nghgbegjdahcmgdjgmbaehhgmmlbjgigielfbddkhfbfgbgcmdfekcaeejgidledgcghicgmmblbaljhgggkimcagblckjkimcglahiambbccefkbmlmdgmkglfdmjdflbfdbekmjbghjjikjgkmeigifllmmgijkcclgjkmcahdjgkcekeagklgfhgidbedbgkgkmbjbkbdhiijjbkcdeallkjmjfldamkcmiijmgfkmhkhcgggfbhldjehbmmebkfeibhimddigfbgflifgmcdhmhjcfcmijjeaaegagcikmglclcblacjfclghgfkfaflhggjdmdjlcheehfhekcbdfkihgfjgakjbaihdmkhjfcfhfbeeifaghmmhiijaeglkackhllehlmmjklcelggahhlilgmbemkkjdcmhakbfgjdakhgekhcddmafkidefbffjdcmcidjmllkeedgiikjdlggigchgckdijhjgfmmfekmdcm\\n\", \"500\\nfnfckgnagbnmhglkdliekejfciahennmjahibikiimkdfcblgcgegenjeaaiddhehkdemeibehbbnahfkdbhkddbgjamfakhgjefljbfnegkgbldkknmmlailkjmmimnfgnccghgnnemignlmnedminddglamlllaekjgjnfcjiaafgnmheedlknlgacebdkgccgkchjhacbbiddjhjhgdkedbcfnaniaaimibgkkdgmnegiandbdmnchehkcidfegaakndccljlganndfbnkenmgcflhammgiggcfmdcjnmncdgfaejaadelhjemekdnlbklcfjaeblhgbccjgechgniedfngfhjidjgangcfabnlblmiadabeeahfdfjhlkfmecnddbhcjgkjfejemfilhdcihfcenmbmblijkiilndnkafdejjnlgnadcllinjnfkfjnbleljledmjbleihgdicmcefaihhbmhnejmcieamkhebme\\n\", \"500\\nbfdalabnagjcojejahgifmbmgokfmmbnaflhbiiijnaidocachemkknjdbohmkciconnnigiciclgldngikjbmodfdfhegkcemlgngiadeffhliacnonnadnblkmmmbkicdemnjibokljonefjahllbkeaaecboadjfhnkhmmalnjfdmmkmjnabojdmfhelnkaehoaiojeajjahlhakikimbobejoeagkhcnadjogjocngaddbfekecokdhcjehenfegjjelekfjolajeibmaodkagkgfnjfinfgdcknbmgemobehekdcclmlfnkmodogedmhaieojgigklajkabjhcgldagaifoaggbibjajgilahejjcoaocncgmnefcglkjledcdcjehlondnilbnojikmomlfdagoaobmekadabiblijldngammojgkgjojhoanfclimkebkfdmoigjkmcnfmmddiahakdjdngffgdjaaklkecgj\\n\", \"500\\ndicdkeichmcjhbnkiglmnephogelfohjboiihaocmpaemlmbgjdaoblkkomngcelapdlmophamcnjihpfhadhaddhbinpinepkcnjpndfeiepiocepbdjchcenilbaccopfnpciglfcknjbmdbhcdgihbeniklehnonlnhooabbodnbmdoaafnedpffdnibdnijidpbngidabdncdfolpfnenbcmhhlenmjcbiacmilahlfpdgafcacnlgedkicmnknliemncdgoggjcdbhnmneljgjjemekndgdhddoiiflndklehceancaiadnicdoofciodhgphjgmchkehailolkhfbpdkoipcemoghegbbpedaafbeloccmgddphefjakjofldineohdgflhflmkiedfmkocbjablcofcmdfconlmhoiehlobdbfpelhaindhamnmbenldbmefgkmhjlloeendgdbeafncjohclenmdeppemplf\\n\", \"500\\nkjcllbkmamlbogkopfqhjfpejfeglpbdqjikbgakecolabphkmpnjfbhpdnlcqcfdaljmegiljlqpkdnomcglpkbaiencimbkehpiqmpafeabbohfajahfablplcpacngfpghjdhbonglhaedpihkbjbkcpjdkqkpdobjfqepolgdgjonaogkingfmacbflbmjhhjbnnffbmcohgmmfbjqojnocjlfhlhflpkddmiijomenhldcoijnqcomjnbbpnffkgelnigkcmnaqdnkpmoejllkilfdlqoqcbmbqdaobndpgjkffebhgmfclhncalfeamiqhclllpoefaaobhqfnljloimkdoaggjammqliommkllnhhqoagcpmlkddkclokjlccgfapodfolmfejdkofqncjkjhqcledaplificibodhddlhmqqckjenpjalokpllnldqppjceelgjbjqqqlcecjcjmkiklbbdikblddkikpfea\\n\", \"500\\nbfhofhrkimdpgpnjhelnqlgbjpddbanmdfqciedrdgednbjjinlmbormkckfcqghoibpcadmnigckajnklngnmpoaiaepajkhegipdadoipgmcncncbhcjkhfechneecqmchnqgpaqkrhipgnqcojhaliokihgqbadmkkcffkeorbjorqbbojiqlpdlohbmhmlmliadlbrpcdmfckfgdqcpflghdfkqceminjlollkbmqreeilffqigjelerjpiakllbgiogqdpkochbjpnppagaooqdgocnnrpkeiekhkibrfjdbkfmlnmbgejcfklgnaacrpnhakkpinnolnbikcrqlgfhcoqpaainlklpamdeapnqpcgflfnlgkpcicdbiodgdngaeaanbjhnfbgogclpherrqodalbbpjkfiohpqngmfialgdejlgddkqrhgnblbqkamajnehebbnkcrlhnrnlcoondjhhnghecmlqfogbiaggkl\\n\", \"500\\ncdmkfpciphakoplkedblrkgkeopflkqhokgfiehpjdbbjidapefhognhgheikdbaepqasmfdsbkdbbjaesoikmglimmabfbsreakbpnhsclohfbaqamjlhhaiqchpoaibqldehsprprscrinsdgrlsmidkdhbsgqnlhlbldrnqhgfhmcsmncqmohkcbkgnbrofccliqjpqdpesfnabndkkklmoemsfksqmjajbgheijcgjiinppnpqlilarocbphlogqrmcheflskedeomfsjkoojfjsdoibiadoeickchjhssjaqhsnbnahqcqnelemollsncrfhjrngeighcqirbphqharlgiblchqjgblkfemlhofrjjceeerolsndsncjksanpkcqiopkmqmlfginppbhkbbdshpbjblheolofkpcjjeedholrqklhiiohmdjbbseclssdlcbkjribjggfggsljidsngsgjpankfckidrpsjsgaq\\n\", \"500\\nfpkfjphbmbqmikncnatbjfldpcohbgamfjrceshfgffllbjcrkeemqboblbjtsgqbeplcrkstcginnjqqolijjbbcnabagheaaisdoiieesogomilkcookbsgebbbmqssrbgdmblmmccgeciaeiasbatraotjlafhmjmddsldfqgfeqkrmkafqdlikttmdtkdmmosqgfflseiibjnahjqsmhcmklgqrqdbccegjeschpcdnbjscqoifipbrfillscdqpjfaippqaloqpdfcmtmjptchiipedetijorrolndnehtkfjarpfqphmmmbeeeomfbshkehesalaeccpgpolhncijsihhdloesfjherreaclrplrtcbsrlefqeksgtdnkmdfcklgskqqkgcndthpgdkitiataqosqdrtjmirsicnrbblofqfsqsdksngrkaefmgnpaaroelimcpnnibekhompicrocopcscfajqdbfpqcrrnlm\\n\", \"500\\nraqqhocfiosbkfjtbjnbatojfmummlrghpkmcghfagdmmkbesdhtelromtkmdmltiljttepgeqdlhtgkpgljrmqjjtmretsdincjjqilahapcjcdlkrftoaeramgrudjbtpjblaksjjjburngarjitmebjiotofctgppktkqkianmucafsspbefuijcmsqamuenlrfrunfhgfqjhkjgrdjrkjgbpifadsjabktgdsgjsslipnqncbdfaphfndssljbthhcrfoijilodnuosmirctsjbhtlbehnljqcjdahcmjqsursqemcmtbgdaegdugqskskfdcffuilthtnjfhujgpifckubajoorllaruqfmbgrcutjushbflsqeiqdddenhurmunhsqqnbsfnjhgdodhmdugisalahiiedmhcgudjfhuumtlndkneauikebmgnrbdmegeotncdllcmmqfudldikeasisllapabefdubasndtobm\\n\", \"500\\ndkftkjtfjdrrjnruuafncvesfngrsrmpmursvssubifcmaeivkrocrhkujbldcgvpifnttfgvrppjpfogmietujqnierfoflmqgbpgsqnagqjqhdjmejllchtldrtrcgemvcalcabieheheagnsmvhrdeeonfckgkuhciivibchbqmvbcdugvcbnqbujgeljqclunbgpguufqhletqstbeabcuncibkdkntbunnvquqshmkqmpbaoaujofaraipvjirvvggrnlvonqsehduohpauqetcujmgutoqigpuqijnevgmcmanalrvsaivueouviobdmucsljnfocsbvlrvmnoevhbpamqqcupcrbfdcerhchteersfjafuiekuchemvhctjfgsgmssfsanrcfjlvithppcqauuepopjolbojemvqfjhjfbiflmihnnkkgmaeecpeaascsasokudhjtkgclbomlbaicffhhlslseaaihlipgiv\\n\", \"500\\nfropdpoauqarcbsnlpkwtcpabgsvcsfltusgobcghdbioeivlddcdadaawjhnljgsfjnfdebgucqmhivqvcrlnmogjapkocfffhdbtqcwauhfmlkwcdutvfwrhdclsjuqwsrrwgquducmguvlralvnspclfsgdpqudmishuwqhvfndqjrdiekbopjwqnbldtgafoqewwkwmdmvdwokekrqbbqfejrhervtbgsualsneufmohsrhwcvwoudfpofbnsbvqoogbrjjhmjiatfpsrvjdiohwhgkrwjcskibimsnlsgogbutccwjedroqtgumopbkshhsllkrlklihjicfaivckdsijgnvuraoiiwdhnoimwfgbslfoehwpdrknljsediqvmtkkgpfneuvjucgkochhbtcvnjhgafrhdhrpjchbociesjfmtwnckbobjimtbrfebdoronmeatuhtafvtssficqnwgdslcvmbmvaodutmpotjc\\n\", \"500\\nnjjiptmrcggwwtbcxbmmiqrqdhhgciaskwustnvmbkbvghlcnrctbcjlepnkqcktsbxgjnvhmndnbqnmhwrlfijpimlojsmvfjidtcmujmnoihwhlronmmpeiobmoperdwsranlbtqgbktpdtbtihnwlsvfefrugurkjbvajxsovpuwjoohmvtdlarbeabmejbrkmkfjwbgsisvxfakjphpmrtmwwwktroitlmstbwuilftpwqmqtitwgkwbpiaueqopotnfxhchsoqqlvwqlogbooqnmpvvtxmtdqqkjwhifmvltxxbwjjgaxjkuuraneqrucchncusshrwxhhdukkexwjrxgufkgmiqblonthwtqulftphghltqcarvfhkknpqxftvqscspvosxvguskdmfdocxrrjvcskjhtxwomiwiqjemdklldgnkeuelcjuudmhokbihwpibicfbjjoqbbqnbqmcsdwdeiisqfvvoxggqeqcfs\\n\", \"500\\njqpyiogllhoobjixnlhskgwowfrhkuotvjbmgatrspqreavqwsuljxqduutxudueenmvarsmqqaqxohtsmxdqdhcvydhuiqcchvvxroqieeffipvlumywcthdafsgnwyamumpknqittxakhlbrbhrtcfbrkvjrypxqochjnmyihuqtrrbgiiytifqeqbnssrmywtdghpekqjxkvoefiwpbepqstotqyiohuawpvawephiexxnofiipkwmshhyaprhrryspbvfoasagdldqeasajhqsurmduuusiwgyuroimbyfjogkxcgjorxpqblhtwvlgognnvisqdkheurkikjcgmoyvafiqhfcbmgmybefsmkroftstqmhkfkuxufghjhveuhhkecushenjqyvqhxcfqdcbkxufhxpbamaowjnuaxjcsuuryvjtnwrhwiurrsehusxwrjwsotefacjxjanphxngylkmjbvhfqghtlnlvdbcnkfjd\\n\", \"500\\nlkuvqevrlanaugfoadmkdqpljknwfoftofyxcvsfvprqxuwkfwunfilaqrzqhsjhsaoynbsuiqyzwqfkmbddngwydhrtimoerqpehjsgqojuhtxvaayzsbxmsqckibtcangzdnnpcpqkqgzbzbeaejuhprrqxdhyfrtzwhvnnrfocwrwfzbgtvdpwlkrqisjqpszykzhfjrstcvmmnebwgvwxsppyxihkepmndwgtzlsurasjfrkqqnxjqdsbmsggakyuouevxdxuwyxbhkmvpjqvoklaknxsmzqpjrftvzifnqjporbvtpdnzfhckjnwgeddpjycnqrtphjhqkfvpoerzkilpjuteidflpulppotglglarrwopryxbjjsroguskwzalrmasgcioovteyuukwnosswdwnqmrbdkssgnkaivtufoayaxgqpprnoyvoeqqpywboofudtutiweaaqzbneqmxgnfkxdnjdbijlveapyrybiw\\n\", \"500\\nccbbbbaabaabccaabcaaccaabbaaaaaaaabaacccbcbccbccbbaabcbbbaacbbbacbccabbabacbcccbbaabbaaccbaacbcbcbabccbacbccccccbcbcbaaaaacabaabbbacabaababbbccaababbacbcbbacbbbbccbacaaccaaccbccbaacbcaaaaabacabbaaabcccaaacccabababbcbacaababcaabbcbacaabbcccccbccbaacacbcabaacbbababacabbcccbccccaababacbcbbaabaabcbaacaccbaacbbcbcbacbbbbabbcbbccabaabbaaabccabbbbbbaaabbbaabcabbbbbbcaaaabcbcbbcbbbbbbcabaababcabbabcacbaccaacacabbbbbcbaccacbbbcaacbbacccaabaababcbbacccababaabcabbccbbbabbaabacabcbabcaabcaacabcaaccacbcbbcaa\\n\", \"500\\ncccaaccbcacbacccbcccbcabcccaaaaaabbccbbbacbacaaacbbcbbacaacbabababcaaacbcacacbacccccccbcccaaabbabccbccbcaabbcaccbbbbbccabcacccabbcbcacbcabaccabcbacacbbbcbaabacbcbbbbbabcbcabbccbbabbbbaccacaacabcacbacaaacacbbbccbcbaccaabbbcbcacbaaacaccaaabccbbabbaaabbbabacbaccaabbbaaacbacaabbaaaacccabbabbbcbcacbcccbbacaccacbcccacabbaabbbaaabbcbacaaaabbcccbacbbbaacacccccbccabbbaababbacccabaaabccbbccbbbbccacbccbcbbbcacaabacbcabaaababbaacaccbbbacbcabbbcacbaccacbcabbbcccbabbabbcaacbcbcaabaaaccacababbbaacacbbbcbabbcac\\n\", \"500\\nabccacbaabaabaaccaaaacacbbcbccaababacbbbccbbcbcccabbccacbacbbacabbcbccccbcbbaccbcaacbacbbaaababccaccbcacaccccabbcbcbaacccbccabccaacccccccccbcabaacaaabccaaaabcccbcbbaabccabbbaaccbbcccbcccbabacbcabbbbccaaacaabcbabbbacacacbcaabbbacaaaaaaacbcabbcaccbcbaabacccacccabbbcbcbacccabcabbaabaacbcbaacbbccccbbbccaabcbcbbbccccccbbabcbabbacbaabaccabcabcabcbbabccacbbaacbcccbaaabacaaacaccbccbccaccccaccbbaabbaabbbccccbbcababcaaaaacbaabcaaccacbbabbbbcabbbbabbabbcaaabccacbcaccbbcabbaaababaaaccbbcccababacaabbccacccab\\n\", \"500\\ncbbbcababbbbbcccbcccabbcaabcabcaaacccabcbbbaacabacbbbcbbccbacbbcabbbacbbabcbccabbababcaabcbabcbababbbaaaaaabcbcccaaaabaaaccaacbcbabccaaaccabccaaabcaacbcaacccccabbbbabaacacbbaabcbcabaaabbbabababccbacbcbbcccbcabacbbbbccbbcacbbbccacacacabccacbccabbbabbabcccabbccbabccccbbbcabcabcccabbababcbcccababccacbaaacaabcbbccbbcccbcbcabbacbabacaccaaacacbbacacbccaaccbbcabcbcacabbaccaccccbacbbcacccacabccbabbbbcbbbbabccbaabbabcaaccbbbaccbacaccbbbabaacabbcbbbaacaacaabaacbcbaaccbbaabbcabbacbcaabccbbccbcbcabbcbcbaaca\\n\", \"500\\naacaabcbaaacbbaacbccbbaacbabbaaabcacbcabaaaaaacccbabcbbbacaaacabbbbaaacaacaacbbbbbabccbcbabcabccbbaabccbccacccacbcbaaaaaaababbccccccacbaccaabcaccbacbccbacccacbacacbaabcabbbcbcbaaabbabbbbbcabbabcbbaabbcacccaaacaaccbaaabaccbaabbbababbabbbcababbcbbaaacacabbcccaaabcccabbbaababbacbaaccbbaabbcabbbbcabcaccbcbcbbbcabccacbcabbaacabbccccaacbbbbaccccbcabccbccbccbccacabaabbbbcbcbacabccbbcbaabacbacbacaabbcacbcacccacbbbcabcccabacbabbcbbacabcbcacbaaabcccaaaccaccaaccbbcabbbbbccaacccacbcccaaccaccaabaabcaabaacaac\\n\", \"500\\nabaabaccacaabbcbacbbbbaaaaacabaaaabbcbcbcccbacabcbabbccbcabacababbbbccbaaccaaccbacbbbbaaabacbbaccabaacacacabcbbcbbcbacccccaccbbacbbcbababaccbbbabbcbcbbbaccbccbbbcccbcbbacacabcccccbbaaaabbbcabbcaaacaccbaabacacacccabcccbabcbbabbaabaababbaaacbccbacacbcaabacccbaacbacabbbaaccbcbbcaaaabcbcccbcbcacabbbbacbbcaccaabbbcaccacbaacbcccbbbbbaccccacabcccccaabccabacabaccbbbaabcaaccacacccbaabbabccbaabbbbbababaaabbbbbaacbcbacaacbcbcbaacbcaacbbcaaacccccbbbbabaacbccbabacabcccabacacacbcaaababcbbcbacbccaabcccaabcbcbc\\n\", \"500\\nbbacbbaacbcabaabbaaccbbbbccacabacabbaaabcccaacbaaaaaaccbaabaaabcabbacbaacaaaabcbacbcbcbccaaccacbacbcbbcaccbccbabacbaacacacccabaabbacbcaacacbcbacaabbcacbcaccbbcbbacabacbbaccababacbccacaababbbacbbbbbaccacbaabbccccbbababaaccbbabbbcaabbbaacccacbcabbacbabbcbbbbbbcabcaabcbbcabbbcaabaaaaccaaacaccbbbcbabcacbacbacbcabccabbccaabacabbbbacacbbbabcbacbccccabcacbbbcabccacabaabcabababbbcbacabbbbccabccaacaabbbbacabaabcaccbaabcbccbabaaccbbabbbbcbcbcbcccbbbbbbbabbaaacabbaccacabcabbbabbaabcbcabacaabcabacbbbaaacabb\\n\", \"500\\nccbbbaaaabaccacaccbbccabaacbbcaacbabaabcaabbaaabacbccabbccbbbccbcbccbababacaccaabbaacbcbccaccccccbaaabbbbccbacabaacbabbbccaabaccabbbaabaaacaccaacbbacbbaacabaccbaccbccabbcbcccacaccbaabcacbabbaabccbaccbcbcbccbcaabaacbbcaacabcacaaacaaccccbcaaaabaaabaabbbcbbbbaabcbcbbbacbaacbbbbbaacbcabccbcacaacbbcbcbbbacbbcacbbbbabacaccbaaaacaaaabbcbcbaaccabbacccaabbabbacbccbacbaabbabcaababaaaabaacabacbaabccbbccbababbbcbacbbbcabacccacaababbabbcaaaaccababbacaacbcbbcaccbcaabcbcccacccabaabaabbcccabcaccbbcbccccbcacbaba\\n\", \"500\\ncaccacbcaababbbacaaaacacbbcaccaaaabaacbbaaaabbbaacbbcbbaaccbcabccbbaabbbcbccbacabaabacabbbcbbacbbcbcbcacacbacbbbcccbaccccacaaccbcbcbccbacccabaaccaaabaaacbcaacccaaacacacbcaccbbcccabccacacabbcababaacbccbcbcabbabbbccbbabbbabcccbabcbababccabcaccbabbbbbcccacaccaabcbbbbaacbccccccabcccaacccbccbaabaaccbbbaaccbcacbcaaaacabaacbbaaacbcbcaabbbaccabbbcbacbbbabcbcccbccccbbcccacacbccaccacaccccaabcabcbbacccccbccbbbabbbbbbcbcccababccabaaaabccabaabbcbcbcabbccabababcabaabbabcccaabacaaaabbabaccbbacaacaabcacccbbcbcc\\n\", \"500\\nbbabcacccbcbbcaaacacabababbbcacabccacbabcacccbccbccbabbbbbbccbbaabcccacabccbaaccacabaabcabcacbcccbaacccaabcacacaacabccbabccccbbaababcccbacbcbaacbccabbbbacbaabaccccccababcababccaabcbaaacacaccccbaacaabaacbaccacaacccabbbcabababbcabbacbccabbaaaabcabaabbbbaacacabbabcbaccbcbbcaaaaaabccccacacaaabccbabacacbcbbccacbacbccaacabcccbabbccbbababbccabcccbbbacabcbabbbcbbcbaabcaccaccaccaabbccaacaaccabbabcbccaccbcbbbcabcabcbbacccbabcbababcbbcacbbbabbacbcbbbaacccbbbaabbcaaabbbaccbaabcacbccbacabacacaaaaabcbacacccaa\\n\", \"500\\ncbdcdcbdbcdbbcbdbddadbadddcdacdadbcaaaaddcadabdbabbcbbcccbbbbdbbccdcdcccdcdccaacaabacbdddddaaabaaacbbabdbcaacdabdaddacbdccddbbacabaaadddcdddadbdadacbccdabccadaacdadcbdaadacacbcdddbadcaddcbcbddcbcccacbbaacdcdbbdbbbadbbdbbbdacbddcbaccaccbaddaaaabbcdccccadcdcccbcbdbdcdcbddbacacbddbaacbaaabbbaccadcbbbacbacddbcbdbbcbcdbcdbbcdbcbdcdddbcbbbdbcabbdaaacdbdcdbccddbdababadddcdcabcbcbcccbcccdcaccacaddcabadacabbddaaabbdbdacccacabcaccddbbbcabcdaabdbddaaadbddccacbbcbccdccaaccbacacbcdbbcbccadcdabdbadbcabccddaba\\n\", \"500\\ncbbdbdadbadbddaaabbaadbcaadaaabcccdacdcbaabcbadbcaccdccbacacaaadcaaccacbcccacdbcdbdabbcbacbadbccadabccccaacdccdcdcdaccccddbabdaccdabbcbaaacacdacccdbcbbbccaccdaddbddddadabbcbbaabcbdcadbdbdaddabaaccabcaaddbdbacddddbbacacbacbdaaadcbacbcdacbbddbcbaddbbbabbbbcbdcaaabdaadbdbdbabcbcbcaaaacaabddbaacadcbbbacbdccbabbbcdbdabdbdaccadcccbcbbadadccacdcbacaacaaccaddccdacdbbbcadbcdcccdbdddcbccccabdadcaaabddddaabcaddcddaaccdcbacacaabacacbcadbadbbbadbbaccddcadaaabbcadabdcaabbbcbbaacadbacdacdbbcdaacadbdaacbabaacdd\\n\", \"500\\ncbcbcaadaddabadbcddbabcbbaabbcaabcdaacdabdcacacbadacaccdddacdbdbbbbcbcddbbbcccccbbcadbcacbdbccdabcdbdadbccbcdcdcdbdbddccbbdcbbabbcadbbaadbbbaadbbabaddddaddcacabbddddaacacbcbaabaaababacaddaacbcbdbccbbdcccbddbacacbbbbddcaadacccbacbbdbadccbacbbbbdbacdddbcdaaadcdbacaccddbddaaaaaddaabdccdacbbaacddccbacadbbbcacdbaacbaddcadddcbbccaacdccdabdcdcdccbadbdbdbcbaabbacbcbcbabddcadbdaaacacbdccdadccbacaadbccccdaadbdbccaddbbadccbacbccbddababbbdcaadbacdaaddababbcabcdacbddccbccdabdcdbcdcacccaacbacbabbcdcbbbbbcbaac\\n\", \"500\\nccadaaddabcadcccbbbcbdaacabcbbcdacaababdbbdccdcacccbbccccadcdcddaccbaaababbacadcabaacbccaabbbdbcbcbbacaaaaababcddadcbddcccbabdabdabbbacbccaccacdacadbbbbcaccccbdcccaabbcaacbcdddcdcdcbbdabadbadadcacdbbbaaaadbcbbabdabcbcbddaccabdadabdbbabcbdcdbdccababcbadbdcaacbddabdadcdbddbdcdabddbdaccadacabddccbbdcbacdbbcbcbdbabbcbadddacddcddccaaaaacabccccccbdbdccacdcaaaababccbbddbbaadacdcbbbadccaacaaccaabbcbabdcdccdcbbbbcdaccbbdccabcbdbacadcbdcdcccdaaccdddbbbcbadcccbacadadaddaabdbacbcdbaadbaaabdcbcdddbcdbdbacdcb\\n\", \"500\\ncccabbcdddcacdbdddddbabadacdcdabadbaddcbcaabddbaaaabcdcabbcccdcbdadbdcbadbaccdaccbcabbcbbcdcaacabbdcbabddccaaacadcdddaacaadcbbaabcbdcdacaddcabbcdadccdadbbacacbbaabaaccbabcbccdaacabaccaadaccdabacabbcbadddddaddaaabacdcbbddbbbcdabdacdadbdccbbccccbcbbabddadcadacabcbdacabbddcbcacbdbcccccbdbcaabbdbcbbdcbaccaabdbbcccadbddcdccbabcdcbbcbdadababcccdcddbadacbadbddbddacdadaddbaabbdcddcbdacbaabdcdacabddacabccacbcadabbadabcddaacbddbaabddabbcabbbbdbcabccdcdaccccdccccbdcbaaabdbddbdaabcdcdcdbdcbcdabaaaacaaacdbdb\\n\", \"500\\ncddcdcbddbbdaaaabcbacccdabaacbcaddcbbcaadcbdadbacdbbddccacbcbabdcbabcacccadbdcbcbbbaabcddbbcabddbabccddcbabdbdbbdbdaaaabbbaaccaaaabacddcdacdccabbcbbdbcbdcdcdbbdbcaabacaacdadbdccacdcddbabbcdcbdcbdbdcbdbccddcabdaddacddabcdcdaacbbaacdabcbccabacadabcdcdcdbbcccbcddbdacaaddadbbbcbcbacccacadcacdbdabbabccbbcaaadcabadaaadbbbdbdbbdcababadbbdcddbcbcddbdbaadbbbbcccbccdcaabbdbaabacabacdbcbcbbaacaacaabbadaddbbcbdcdcdcabbcdacdbcacabddbadccbdcbadbdddbdaccbcabdabddbddccaacdcbccadbdaddcabaadcccdddabdaacbaacadadba\\n\", \"500\\ncdbdadbdcabdcbdbaadacaacbbbbcdaccddbdbbdabccacbaacdbbdcbddadabaaccbabccabadddbdcdcdddbbcbadddcabcddcdbabacacbdbcaadacbbbdccbcabacdbcccbdccbaacddaaaabdacbdccbbbbcaabbbdabadadacabdbbaaacadcbaacadadbbdbcdabcdabccacbdcaadaccdbdcaccaaddacddccdadddddddbacaccdbbbbcbbabbdcacbcaacaabdddbdccdaddcddbbaabaabdbcccadcacbdacabcdaddaabcbcaadabadbdaacacacaaddbbbcabccdbbcbaccbadcddaaccdbacaabbcdbcbdbcbacacdccccabaaabbcbccdcaabcadcaccadbbbcccabbbcdbaccaabdcbcdbcdcaddaabcdacaddcccaddabcbabdcabbdbaaaccbbabcdaddbbccd\\n\", \"500\\ncddbcaadccbdacccccbbdcbbcbcbdccbbadbaadbaddabcaacabbcacdbaddaddcbabaaaddbacbdaacccbdcbbaccbdcdbdcdbcbdbacadbccacacdbdbbbaaadccbdabbacbdabdabcdccdcddcbdadbacdbbdacdbccddbbadadcbdbddcabdabcbbddcbdcbcdabcdabddcaaabdddbbcabcaacaddcaadddaacddcabdcacbacdbcbdbadbcdaddcdaaaadaadcdcaabbadbadddaabdbdbdbaabdbdcbdcadbbcbaddbcccddbaddcbccadccccbbbdcacaabcbbcbdbdaaaacddbdcdaadbdadbacdddbbbddacbcaadcddcbdbabcadcddbbabccddbadddabacbbdacbbbcbcbdcadaccddbbbadddaaddddcddabaccaddbadcbcbabdcdbcaaabcadaacaddbabddcaad\\n\", \"500\\ncaadabddbaacdabdbadcadcadbdcdaadaaabcdbabcadcbaaadcadacbabcddacaabcadcabaabdddbcbcadbbbdabdabacbccddcbcdacbacbadabdcbccacbcbcabdcdbcdacadaacaabbbabbddbcccdcbabbbbcbcaacbdadacbdbabbabcaacdacbadcccbadaaabdbcbdbdadbddcdbdbcbccbbadbaaddcaaddadaaaabababdbbaddbadddbcaabcadbcacccadbdaaabcdcdbddcbbbdadaadbddddbdbacbccdaaabbdccaabcbbbaadaccdcbccdcabdccccabbbbadddccadddcbdddaddbdcaccbaadadbbdcaabdcdaacadddadbbbdadcdcdcbbabdcdbdbdddababaaabcdcbdccabbcaabbccadcdbdbbcdbbaabadacdaccaabbdabdcdbabcdbcbdacdbdcbc\\n\", \"500\\nddaabdcccadcabacacdbaabacbaadcbcaadcbccabdbddbabacdaccbadaccabcddadccbdcbbacddcdccaccbddcbcdadadaabcacbddcabbaabbbdddccbdccdaadcbcabadbdccbdabacbdcacdcdacadcaaaaaaabaccccaaabcccbdabdaadbdcbaccabccddabdbabcbabbbbaccdadaaabdbdbcbdccddcdbabdaabbbcaadaaccbcbbdabbddaaacaddbbbccbbaacadcdbcbdddaaccbbcadbccccddbddbadcbcdbcbdccbcabacbabbddadcdabcbcdccddcbcdcaddadbccdbabaacddbcdbbcdcbcbdaddbdabacbdbcdbabbbcdcaabbccbabbabccdadabdccaabdadaadcdcddbbcbccbdbbbddacacddbdcdabcdaddcacdabacdacabbaddbadabcdabccbcba\\n\", \"500\\naadbeaacbbbbccaaadabcebbadddcaeeadcddeabdaaddedeceadeaeedbeaddddacbeadeeeabdcdbdedcdebabeaeeddbadbbcedbadbeddebcabaaeccecaeeeadbeccbabdecddecaeecbcedccdcddbcbbcdcedbbcbbecdadbdbbceeeabaadbacaaddebccededacadeecdbcbbedcbaeaccadcaaabcddeaeecabdebaaccecababccacbeeeabceacbbeecaebdebeddaeaeaebcacdeccbeebceddabaeedccdbaeaeebdedeecdccdcbddedcedacdceaacbadbaadcaececacaaebecaecababedebcdaceeedbbaeeadaecaadbcabacbecaecdeaeaedddeecaceabbcdceecedeacaebaddbaeacbccddcdabdedbeacccbdbabdccebaecaacacaabaeacedaaea\\n\", \"500\\nebceccdebaaacaeecbcbaedbeebceaccabacdadbaebcbbdebeeacacdecdceddbbecebcaaeeddeabbbbdceedaebceeeadbdadacdbbddcdaaddeabedccdacdecabcebcdbdaaeeaedbabaeaedaddcdebdbcdebbcbccddbdbbcdedaccbbaedeeedacabbddcdeedbaeabebbdddcceaaacbdbdcbdeeeccadabeadddcebbededdebaaaedabadbabcddebeaeebcebbdddcbacbeeeedacbeaddbccebecdceeabebabbbbbcaaaaeadaaeccaebeedababbabedbdcadeeabaaeddbedddeadecaedbbeccdbcdadededcddceaccceeabadabcebdcbecdebcaaeadbcdbcbdcbbedbecbbccbedabcbedceccdbabdababddeeeaaaabcbdbcedcbbdecaeebedddccbaa\\n\", \"500\\ncdeaeeedacbedcbbbcaaeccebccdeeddccdceabbaccbdabdeecccaeebddabbcdbedaababeaddbbecbdeaacebaebbbddeeccdeaedbdebebecccebebacdeadebedbdddcdbceacdedadeddaaaaeaddceaecdbedcdeabcacbaddcaebebdccbdcaacbacabbdabceaacdedacbcdadadeeecbceadaaaeceacadcaebcbaadddadeedbcdebcdcaccbccedcacaebcaccaadedddddaedaddaacecccbeececdeeccaaaebddeecccabbbdcbceeeedaceddaecdadcedacbdaebcbdddcedbdeadddebbaacccbabbcbaebceebacaddecadcdbccdeebabaccdcbababaaedbabbdadebeeacbbccaeabdcdceecbbcaedcadaccdaabdeabbaabebedcacedbeeaabdeeecb\\n\", \"500\\nbdeadccaedebabcdeadedebdcacdcaebdeeadedbdccabeaddaaabdaeedbecdcbeacdaceeccdebecabeaedebdadadddccaabddeaddaddedaebccabeccbeeceeaecbaaabccabdccdbeeebcbccebbaeebcdcaabdabcabadbccdcbdebdabbeeeccddaadedddbddeebdacacddcaddccbebbbaeddcecccabcacceadacbdabaddbebbaecebeebabeabaddbbdddbddacaddedbaeaeedcccccbdbcdcadccaadabaacbeaddcabcccacabcdcaabadacdccabcdaceeacbbeeedeacbcaaabeaacaabaccdbddeabdbdabccdceeecbeeeecdddacbbebceaccdbccabebedaeceadaacaebacdaeceeacedbadebeadaaebaebcadcedabecdbedbbadbccabadbbcbcbda\\n\", \"500\\nacdccbcdabcabdeaceeacabdebeccabcabcaeaadeaaaaecdeecbaecdeebcaccdacddeabedbddcbbdbabbddaeeddebebdecceeebbcaecadbedbaaccadcacbbcbebceabbddbbccdcdcddebbdbbdebbcbbdadbedebacaecabbbedccebcaecbceadaeabbaeecceacaacbeaebdbaeedabbebbaaadeceabeccccbadcebbeccdeadddedcdeebcaeedddbdcccddbaeabeeacddbdcdbaebeedbdeadbcabaaeabcbeeadcabddeceedaececdadeadabdbabcbbeeaabddcbbdeeeeeacdebdbdcacbcdacdbccbbccdeabecedbadddebbcdccedaebacaedcdbceadbeababbcbdaccdecbbeaeedbdceebadeadbdccaccccdbdcdddaedaababcaeeaddbdbaabeaaaa\\n\", \"500\\nebeeeeabaebabbacacccbcddbdadabdaedbecadecacdcdeccabdbbddbccabeccbdebdebedbaedeeaecccdadbcabbcdacadaddacbbbdaaeceaaeabbacdecacbebebbbbededccbdbbeddabcbebdabcccedabdbcccbbeebaecabcacbcdadcbebbadcbeadebccedaceebcebceeaacbbdcdacdcdedaddeedaddedadbccccdddcddccceaabcadecbebdeeeebcbcadedbdddaadcdceceaadeeadddacacaedaebbcbabacabacaaeecaebbabbeaeabecbddaaeaeadccdeebcedbdcaadceaaaaebaaccecccdecdeeccaaeeeccbdcebedbcadabceedbcecbbeacbadcccdaebbdddacaacadcdbaeeecdadbccbebebbaddeecbceebaaacdecabeabdaecaeaceac\\n\", \"500\\ncbbbbbdeeaacadcbdcedeacaccbdababbeedcbbddacdaaacbabcedeccddeeecccddaedebcdadaacddeabbdacceedadeedacacecdcceecaaeaecbcaabdabaddabadecebdbddbadacbbcddedddadabbeddedeabdcaabccbbdadddeaecebaaeedbbbebddaecccebebcaebebddadceebedeecbbacadadcccdacecbdcebdcdcaceeedbcdddabdcabdeccadbdddabbbaebbdadadebadbeddeecebeddaaaadbaaebaeaebdaddccddbaddcadaeaacabcdeaddaedddbbacdcbeeaaecbecceadeeacceeaaddaecdadddbbeebeedecbaeacaceacccbdcbcaccaceccadcebacaebccdcacebbedeaaeccaddedccedceeedeecbaccbcebaeacbbcbeedabceaebdc\\n\", \"500\\nbbcbdedcadacabdcbacdabcedeebdbdeddedccceedcececcebddeacaeddbaabbaaaedccccabdccbbeacebbdecbdbaecabceedcdecdebbbaecddbbcecbbeaddbcdaddaecddeceeeedbcccedbabbdccbceecbccaebbcccbacdaeeecdedacbacabdceaaabcacceedeadeebbeeceebaeebcaddecccdeedeecaacebddedeeddccacccdaaaebecdbcbdcbaddceacbbedbcabbbedcadadbcbeeecaceddabdabeabbabddcabdecabdeccccaabaeebcddebdcdbdccccdecacaeccccbddcabbbeadccebddbccbcbecbaedabcdcceeabadbcabddecbccbdabbcccdebbaebbebadaceaceaebbbeaabeedeaabbdaadccdabbcbabcdceabdeabdaebbddedecdbcc\\n\", \"500\\ncefcddeacbbffacacefaaaceebbcdbafdbcfbcdbffddabfeccaffaaddeecfebebaaaccabedeceddbdebeadfeeecddceedbbebffbbcfcbbefcefafdefbadabafbbddddfcbcdfefeaaeddbbacaeafdeffbabddabdcefbbaadfdabcddfccffbbaacdbddedddeeabfffdafdbdbbcefeeafcaabcfccfccceaaefebcaabddcbaccdaafffccfdcfccdfdeccdcfeaaedbadfbbdedcddfecbdfafddaaecaaadadcdfbefcdffbccfbbcdbedfbfcefadffebbcaebbffccbdbabfcbadacdbebabccbadefdfccfccedcbdeffaaadafdfbadefadaabafceecaaebdeedcebbbacfcceadcfcfaddffcaeafeacebbffddbfddabddeaafdcfdaabacfcdeceeadfacaea\\n\", \"500\\nedfeaaaaddffdbfbcebefebdfdadbdadcbbdbdcabfdbdeccaeebcdebdddfedcacbbefeabdbbdeceeacadbbbebffcebbaffdcabcedccddeeccdfbdedfeddcbebdadffbaacbbedbdbfdbcaecccbbcfefdbddabdeadeeeecffdbcfcbeabcdeeaaddeeddeadccdefbeaabfabadaddbfaddbecaaeccbdefececdbebbddffbbfcfdddcadbccedcecabdcfceeefcdbbfcaeccbcdcddbfabcbedfdcdfafabadbbcdcfbfccafafacacbcbfbcabefacedadfdbdbaeeffbcfdbcabdbdedbfcbadfcaafbaeadecdedcddecfdfddaadaebacabafcdcdeecefeddcfcceeddebccafbdbafffbecdbbbaaeebdabddaadadbbdceffdbbefccfbcbcbdaaefcabdebfba\\n\", \"500\\ncffaebdcbfbfbacefefbaeedaddacbdcfaeadcadcacaaacaadedebeecaebfdbcffaceadeedddbdfadcebcdffbafefcaecafcafbfccdeefadecfcbafaedbcecdbabdfbbfdeebabdaecbababcebbbdaadffbeffeffcfeefaccdfeafffeaaedfbbdafedecfdefbcaadecbffaadeadfecffaffdeeddbbadeadcfafbceaffabfefcddceeefacaceeffeefbcfcadaeeeabeebfcabbebddcdcedddddbceadbdddfeadafabfebdbcdeedadbbfacaeedefeafedbecbaafecffbaffbbfadfdfcebabddebcedacaaaafdfdefbaafdcfacfbddbfbdefcebdabcfdfaeebcbfbacffabbbbbdbfedebabbedadbaecbedbdeadddcfffaebdececfcbbbbcdecaacddb\\n\", \"500\\ncbadfcecebaefcfbfbbaedbcfacdcbfcacfadbebdedaaffaaabffdeedbfbdececccfbaccddeffeeabaaffedfdcdfffdaabbafccaceedacdceabdabcebeddeaeeecbcabddebdfbcbecbffdbbcdaffacdacfbaafbacdbbbdacecabbaffacfbcbacdadafdbebcadeeabcfcfecaefecbbeaafcbaafabbbdbfaeaccedcdcfbbadfeddfcadcdafaeffdcdfceedeaacecaaafffeadcdfffbfedccbaefeebabeafddbddeacefcfbbbceacbcacaecddbcfadcdeafdedadddfefaadfdbbeaaaceacecfefefceeecaefeebfccdcffadbfbeacfbcfeecadcbbebaefaebcecbffaefbbcfacfddbdcdaaeddfdabbefbddcfdeaceafdddffffaffdcdebdacefbdba\\n\", \"500\\naaafbfcaaeeeadcaebfffbfdaccaccfceaccaebecbefbbfeafffecaaeeadefcdebddaebcccfffdfacbffeeeacdbbeebdcadceabbccecfcdeebfeafbadaadcaaefcececdedccefcadbdbeaffeebeccabacbeeaacbeefdafeaecedfacadceabaffffdcfbbdfdbbeddddffdfabfecafcefaaaafeacefdfdfccabeecaeeefcecdfdacadbffdcaabdecaededeadbdfeadcaabbfbccbcfeccbecedbcdebbbabebbcfeaaacdaecdafbaacdbfefabebcafedacbbabadaeeaffebcdcabefbfdbbaaddacfafadbecbbcddcafcaefbefeffbbebeaaefcfafffacbdacadbbfadeececcaafcaadacdbfefaddefebaeebefadcdccddaaccebdaafffefeeddbacae\\n\", \"500\\ncaebcfbedafeaedbedddbdecfafbbefdddcaedffbbddefacafdcfafddddfdaddddcbbaaddabadedacbbdfeaacabcbdebaadbbcacbcbdbfcfadfcfcfdabefacacdacccbebafdabdfcadcfbfdeacfccfbefebcbcadeccdcefdabcfffdbdaedeaabcdacfbaacfceafeaafcdfadcdfbdfbefdfedacecaaffefbaddbdbbbcaaddbabbeacfabceeaefeebedefbcfadbacdefeabdadcecacceaaaadfaaeaebebbdabbcbfbaddfbfcfddbaaccacabbbbcbbccedcfccffbbcededafcccbceeefcedafdebbbeebaafdbadebdfcfbbbebcbeccaccafbacffdccdcaecebcaadffffabeccfddeffcfedcadcefafcbeabcadabddbfaffbbffaccbafbacadbfbaaf\\n\", \"500\\naefceaacfeddedcdedacacfbeeedfabbebbeccadfaabfacceaacdcbdfeeaffebcadeecddeacadfcaffedccabdebccabbdbbbaefbfacecaacdefbddcfcbafeccfbaaadccbbccfbeaaeadebbaaafbebfaaccfbdddeedaaeddbfdadbacafcbfdffcceacceefecbcedacfbffddedcdeacbdbdedbcdcacfcbceddaadcfcdcdcaefbcbbafffccbabfdecaaeceeaaaceedaceeebdebbeaadecfefacaddefbbdaebedbfadeafdeccaeaffedefcebababceccfacceddabcecbebccdcabddfdeefcabdbddcccdbccdacddbbaeaeadcfeccbcaabfcabceadfababecccbbbcddddeabdbbeacdbcdfacaafeedeadcbabbfeffcebfcfaceaecdfddbdbbeeebaebe\\n\", \"500\\nabfaaffaaebbefbabfefacdddddafbbabdacebeeccfabcfaebaeabbfabfcceddbdaadeddbffcfedaebecbaccdfbfafabfceffceeaccdfebbdbdafdebfcafebededcfbbaefefcbefdfabdefafeaccdfaeeacdacddccfcfcadbafbdbbdfcfecfeaffdcceccabcfeaddabfbaddebdecdfabebaeefefecedeeadaeedcfabcbcfbfaadaddaabeedfdccbbfeffccfcceddebecabacaedaaceedfddebbeaefbbcfdcdcbdfadadfefcaaffdfeedbcaebccdfecbfccacadccecbdcbdabbeaebdcedfbfaffbccbeaeebacceedceaabebeddbeedbfafeecdfdceebaaecabbefcabbaffdacfcebdbfffeadabddccaebdeffaacfdfcfdffabeefaecafaccabfbd\\n\", \"500\\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\n\", \"500\\nzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\\n\", \"500\\nbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\\n\"], \"outputs\": [\"3\\n\", \"4\\n\", \"1\\n\", \"121\\n\", \"174\\n\", \"196\\n\", \"217\\n\", \"228\\n\", \"246\\n\", \"261\\n\", \"273\\n\", \"281\\n\", \"294\\n\", \"300\\n\", \"303\\n\", \"314\\n\", \"321\\n\", \"331\\n\", \"325\\n\", \"335\\n\", \"335\\n\", \"326\\n\", \"339\\n\", \"339\\n\", \"351\\n\", \"338\\n\", \"350\\n\", \"358\\n\", \"161\\n\", \"164\\n\", \"161\\n\", \"174\\n\", \"163\\n\", \"170\\n\", \"172\\n\", \"170\\n\", \"164\\n\", \"176\\n\", \"195\\n\", \"196\\n\", \"196\\n\", \"193\\n\", \"201\\n\", \"201\\n\", \"194\\n\", \"202\\n\", \"204\\n\", \"202\\n\", \"223\\n\", \"217\\n\", \"214\\n\", \"219\\n\", \"217\\n\", \"215\\n\", \"213\\n\", \"216\\n\", \"228\\n\", \"236\\n\", \"238\\n\", \"235\\n\", \"230\\n\", \"233\\n\", \"228\\n\", \"236\\n\", \"1\\n\", \"1\\n\", \"1\\n\"]}", "source": "primeintellect"}
You are given a string $s$ of length $n$ consisting of lowercase Latin letters. You may apply some operations to this string: in one operation you can delete some contiguous substring of this string, if all letters in the substring you delete are equal. For example, after deleting substring bbbb from string abbbbaccdd we get the string aaccdd. Calculate the minimum number of operations to delete the whole string $s$. -----Input----- The first line contains one integer $n$ ($1 \le n \le 500$) — the length of string $s$. The second line contains the string $s$ ($|s| = n$) consisting of lowercase Latin letters. -----Output----- Output a single integer — the minimal number of operation to delete string $s$. -----Examples----- Input 5 abaca Output 3 Input 8 abcddcba Output 4 Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0
{"tests": "{\"inputs\": [\"1 1\\n\", \"3 2\\n\", \"3 3\\n\", \"1 11\\n\", \"4 20\\n\", \"45902564 24\\n\", \"330 8\\n\", \"10 10\\n\", \"0 2\\n\", \"1000000 55\\n\", \"1 60\\n\", \"1000000000 52\\n\", \"101628400788615604 30\\n\", \"101628400798615604 31\\n\", \"55 55\\n\", \"14240928 10\\n\", \"1000000000 10\\n\", \"1111111 11\\n\", \"10000000000000000 35\\n\", \"0 19\\n\", \"768 10\\n\", \"3691 6\\n\", \"16 15\\n\", \"427 4\\n\", \"669 9\\n\", \"0 16\\n\", \"286 11\\n\", \"6 16\\n\", \"13111 8\\n\", \"17 2\\n\", \"440 4\\n\", \"5733 6\\n\", \"3322 6\\n\", \"333398 7\\n\", \"19027910 20\\n\", \"73964712 13\\n\", \"33156624 15\\n\", \"406 3\\n\", \"3600 4\\n\", \"133015087 16\\n\", \"14065439 11\\n\", \"135647 6\\n\", \"613794 8\\n\", \"79320883 13\\n\", \"433 3\\n\", \"142129 6\\n\", \"20074910 16\\n\", \"27712 4\\n\", \"109197403264830 17\\n\", \"1767 3\\n\", \"2518095982 9\\n\", \"16184825266581 15\\n\", \"60 2\\n\", \"51908921235703 16\\n\", \"373301530 8\\n\", \"51140330728306 16\\n\", \"78015012688021 17\\n\", \"360651917262546 18\\n\", \"15619605006173 15\\n\", \"296851618 8\\n\", \"1651507249349341 20\\n\", \"234217752433205 18\\n\", \"5004844 6\\n\", \"820882585293 13\\n\", \"0 64\\n\"], \"outputs\": [\"1\\n\", \"5\\n\", \"7\\n\", \"1024\\n\", \"983040\\n\", \"6406200698\\n\", \"2033\\n\", \"1023\\n\", \"1\\n\", \"504262282264444927\\n\", \"576460752303423488\\n\", \"542648557841154044\\n\", \"999999999999995905\\n\", \"981546175132942729\\n\", \"36028797018963967\\n\", \"999948289\\n\", \"38209103398929\\n\", \"7734675\\n\", \"247948501945678280\\n\", \"1\\n\", \"9471\\n\", \"39105\\n\", \"40960\\n\", \"18561\\n\", \"5535\\n\", \"1\\n\", \"8185\\n\", \"64512\\n\", \"73033\\n\", \"65537\\n\", \"20993\\n\", \"96257\\n\", \"34441\\n\", \"142974977\\n\", \"530210696\\n\", \"808934145\\n\", \"217957249\\n\", \"402653185\\n\", \"310378497\\n\", \"903250260\\n\", \"277820673\\n\", \"612761601\\n\", \"47611905\\n\", \"877746562\\n\", \"603979777\\n\", \"893386753\\n\", \"156957897\\n\", \"54078379900534785\\n\", \"530824147803045889\\n\", \"612489549322387457\\n\", \"835136255900516353\\n\", \"753750817529397249\\n\", \"576460752303423489\\n\", \"927684967108968449\\n\", \"628568807366983681\\n\", \"880672956240363521\\n\", \"237668409087623169\\n\", \"866841191969193985\\n\", \"676897611185127425\\n\", \"208581753835618305\\n\", \"660934198681731073\\n\", \"333773758789582849\\n\", \"488640559569698817\\n\", \"167167411424854017\\n\", \"1\\n\"]}", "source": "primeintellect"}
One day, after a difficult lecture a diligent student Sasha saw a graffitied desk in the classroom. She came closer and read: "Find such positive integer n, that among numbers n + 1, n + 2, ..., 2·n there are exactly m numbers which binary representation contains exactly k digits one". The girl got interested in the task and she asked you to help her solve it. Sasha knows that you are afraid of large numbers, so she guaranteed that there is an answer that doesn't exceed 10^18. -----Input----- The first line contains two space-separated integers, m and k (0 ≤ m ≤ 10^18; 1 ≤ k ≤ 64). -----Output----- Print the required number n (1 ≤ n ≤ 10^18). If there are multiple answers, print any of them. -----Examples----- Input 1 1 Output 1 Input 3 2 Output 5 Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0
{"tests": "{\"inputs\": [\"3 4\\n2 6 7\\n4 2 3 9 5\\n3 2 3 9\\n100 1 7\\n400 3 3 2 5\\n100 2 9 2\\n500 3 2 9 5\\n\", \"4 3\\n1 1\\n1 2\\n1 3\\n1 4\\n10 4 1 2 3 4\\n20 4 1 2 3 4\\n30 4 1 2 3 4\\n\", \"1 5\\n9 9 8 7 6 5 4 3 2 1\\n3 4 1 2 3 4\\n1 4 5 6 7 8\\n4 4 1 3 5 7\\n1 4 2 4 6 8\\n5 4 1 9 2 8\\n\", \"1 2\\n8 5 2 7 4 3 6 9 1\\n1 3 9 2 3\\n1 7 7 8 6 4 9 5 2\\n\", \"1 5\\n9 9 8 7 6 5 4 3 2 1\\n3 4 1 2 3 4\\n1 4 5 6 7 8\\n4 4 1 3 5 7\\n10 4 2 4 6 8\\n5 4 1 9 2 8\\n\", \"1 2\\n8 5 3 9 8 6 7 4 1\\n1 7 3 8 2 6 5 7 9\\n1 7 3 2 5 6 8 7 4\\n\", \"1 2\\n2 4 2\\n2 1 3\\n2 2 3 2\\n\", \"1 2\\n9 2 8 7 6 3 4 1 5 9\\n3 6 4 3 1 7 5 9\\n4 2 1 9\\n\", \"1 3\\n2 8 6\\n1 3 6 7 9\\n1 3 6 4 3\\n1 5 7 4 1 3 8\\n\", \"1 3\\n5 6 1 9 3 2\\n3 6 1 4 5 7 3 9\\n1 1 6\\n2 1 2\\n\", \"1 3\\n3 9 4 6\\n4 3 6 1 8\\n1 6 3 2 4 7 9 1\\n2 6 8 6 9 5 1 2\\n\", \"1 4\\n4 9 7 1 5\\n1 8 8 1 9 6 5 7 3 2\\n1 2 3 2\\n1 3 8 2 1\\n1 5 1 4 8 6 7\\n\", \"1 4\\n3 2 9 1\\n1 6 3 1 5 8 9 7\\n2 2 2 6\\n1 1 7\\n3 1 9\\n\", \"1 4\\n6 5 4 7 1 6 9\\n4 5 8 2 9 5 6\\n2 8 3 8 1 6 7 5 9 2\\n4 4 1 5 7 2\\n1 4 8 4 6 2\\n\", \"1 5\\n6 2 6 3 4 8 9\\n1 8 5 3 9 7 6 2 1 4\\n1 4 1 3 6 8\\n1 2 8 7\\n1 1 1\\n1 8 1 3 8 2 5 7 9 4\\n\", \"1 5\\n4 2 5 9 4\\n2 1 2\\n1 5 2 8 1 9 3\\n3 3 1 4 8\\n2 5 1 9 7 4 3\\n1 2 5 2\\n\", \"1 5\\n7 1 4 2 6 3 8 9\\n2 9 9 7 5 4 6 3 8 2 1\\n1 8 8 3 7 9 2 4 6 1\\n2 9 1 8 3 5 4 7 2 9 6\\n5 3 3 9 2\\n2 8 1 8 4 9 2 3 6 5\\n\", \"2 2\\n8 5 1 4 2 3 8 7 6\\n4 6 8 2 9\\n1 1 5\\n1 5 4 5 8 7 6\\n\", \"2 2\\n2 3 6\\n1 1\\n1 5 3 8 9 1 6\\n1 3 1 7 8\\n\", \"2 2\\n9 4 1 3 9 6 5 7 8 2\\n8 6 1 4 7 3 5 9 8\\n1 2 7 5\\n1 5 1 9 4 7 3\\n\", \"1 2\\n1 2\\n1000000000 1 1\\n1000000000 1 1\\n\", \"2 4\\n4 2 5 8 6\\n6 6 2 9 5 3 7\\n1 7 4 8 5 9 6 2 3\\n1 3 5 4 6\\n1 9 3 1 5 8 6 9 7 2 4\\n1 6 5 4 9 8 7 6\\n\", \"2 4\\n7 7 3 1 4 5 8 2\\n5 8 4 1 6 7\\n2 6 8 2 6 7 1 4\\n1 5 7 3 4 9 1\\n3 5 8 7 1 5 4\\n2 6 4 9 1 8 2 3\\n\", \"2 4\\n5 5 1 4 2 7\\n6 8 7 2 5 6 9\\n5 2 5 8\\n1 5 8 1 2 3 7\\n3 7 8 2 9 6 3 7 5\\n5 2 6 3\\n\", \"2 5\\n7 7 4 2 1 9 3 5\\n4 9 7 5 2\\n1 6 6 5 9 3 1 8\\n1 8 2 5 7 9 6 8 1 3\\n1 5 4 5 3 7 8\\n1 9 4 3 6 5 2 8 7 1 9\\n1 8 2 1 9 5 6 7 3 8\\n\", \"2 5\\n5 9 7 3 1 4\\n5 5 1 6 2 8\\n1 5 5 6 1 3 2\\n1 5 7 4 2 1 3\\n3 3 7 1 5\\n2 8 1 9 2 4 6 3 7 5\\n1 4 5 7 4 9\\n\", \"2 5\\n8 9 5 6 1 4 2 8 7\\n3 7 9 3\\n3 5 5 8 4 6 9\\n1 2 7 5\\n1 5 6 2 9 5 1\\n5 8 3 6 4 2 9 1 7 5\\n5 8 2 1 5 8 3 4 9 6\\n\", \"3 2\\n9 5 9 2 1 3 8 7 6 4\\n8 9 3 2 6 4 7 5 8\\n9 6 5 2 1 8 3 9 4 7\\n1 1 4\\n1 4 3 2 1 4\\n\", \"3 2\\n7 7 3 6 9 2 5 8\\n1 6\\n8 3 8 5 4 9 6 7 2\\n1 7 8 9 2 4 7 3 1\\n3 5 3 5 9 7 6\\n\", \"3 2\\n6 8 5 7 1 4 2\\n5 8 7 9 6 3\\n1 5\\n5 2 7 2\\n1 6 9 8 2 4 3 5\\n\", \"3 3\\n1 9\\n6 4 9 5 7 8 1\\n3 5 8 3\\n1 2 7 4\\n1 2 5 9\\n1 8 5 7 9 1 4 3 2 6\\n\", \"3 3\\n8 4 7 1 2 6 8 9 3\\n2 9 5\\n1 7\\n3 8 7 3 2 6 9 1 4 8\\n2 4 1 6 7 8\\n1 5 3 4 1 9 6\\n\", \"3 3\\n3 8 1 4\\n1 5\\n2 5 9\\n4 3 4 2 9\\n5 8 7 9 3 4 6 8 1 2\\n1 7 4 1 5 3 8 2 7\\n\", \"3 4\\n8 3 5 1 8 6 2 4 9\\n1 4\\n3 2 7 6\\n1 4 2 1 3 5\\n1 1 9\\n1 1 7\\n1 3 7 1 9\\n\", \"3 4\\n2 1 2\\n1 8\\n8 2 9 3 4 1 8 6 5\\n3 7 5 6 7 9 4 3 8\\n2 3 1 9 7\\n3 1 2\\n1 9 7 6 8 4 3 9 1 5 2\\n\", \"3 4\\n5 3 8 7 4 1\\n4 4 3 6 7\\n5 5 7 3 6 4\\n3 5 5 1 7 3 9\\n5 8 7 1 8 6 3 9 4 2\\n3 7 2 5 6 8 4 7 3\\n4 9 8 9 3 6 5 2 7 4 1\\n\", \"3 5\\n2 8 9\\n7 7 8 9 3 1 6 4\\n7 3 4 7 5 1 8 6\\n1 4 6 1 4 9\\n1 2 2 6\\n1 3 8 6 1\\n1 8 5 6 7 2 3 8 4 1\\n1 1 4\\n\", \"3 5\\n5 6 9 5 1 8\\n4 3 5 4 6\\n7 9 5 4 2 8 7 1\\n1 7 9 4 2 5 7 1 8\\n3 6 4 7 5 6 3 9\\n2 6 7 6 5 4 2 3\\n2 5 2 5 9 4 8\\n3 1 9\\n\", \"3 5\\n8 4 7 2 5 8 3 6 1\\n8 9 5 3 7 8 1 2 6\\n8 3 8 7 6 2 1 9 4\\n1 2 5 2\\n5 8 2 6 5 7 9 3 1 8\\n4 7 1 5 7 8 3 2 6\\n2 4 6 3 1 7\\n1 4 8 1 3 4\\n\", \"4 2\\n9 8 4 6 7 5 3 2 1 9\\n4 8 4 9 7\\n7 6 4 5 9 2 3 1\\n9 9 2 7 8 5 3 1 6 4\\n1 3 8 6 9\\n1 1 5\\n\", \"4 2\\n7 8 5 2 6 3 1 9\\n9 5 3 9 6 2 7 1 8 4\\n9 8 3 5 2 1 9 6 4 7\\n3 8 6 1\\n2 2 2 7\\n1 2 8 6\\n\", \"4 2\\n1 4\\n4 7 8 6 9\\n5 8 7 4 3 9\\n2 6 1\\n1 9 7 1 6 3 8 4 9 2 5\\n4 5 9 8 2 1 3\\n\", \"4 3\\n2 3 2\\n5 3 6 4 9 5\\n7 4 8 2 3 9 6 5\\n8 3 2 7 1 4 8 6 9\\n1 3 3 6 5\\n1 8 9 5 2 6 7 3 8 1\\n1 7 1 2 7 5 4 6 8\\n\", \"4 3\\n9 9 2 7 6 3 4 5 1 8\\n7 4 9 8 3 2 6 7\\n1 9\\n1 4\\n2 1 1\\n1 4 8 1 2 7\\n2 2 2 7\\n\", \"4 3\\n3 2 6 1\\n3 2 8 4\\n8 2 1 7 5 8 4 9 6\\n3 2 6 4\\n1 5 5 4 9 7 8\\n4 4 1 7 4 6\\n3 7 7 6 4 8 2 3 5\\n\", \"4 4\\n5 2 5 8 3 4\\n5 7 5 2 4 9\\n9 4 9 5 7 1 2 8 6 3\\n5 2 5 9 4 3\\n1 1 7\\n1 3 3 1 6\\n1 1 5\\n1 1 6\\n\", \"4 4\\n3 8 3 5\\n6 4 6 9 8 1 7\\n5 7 2 4 3 1\\n4 6 8 5 2\\n2 7 4 9 5 3 8 6 7\\n2 8 6 5 9 8 3 7 4 1\\n3 7 5 2 1 6 8 4 7\\n2 9 4 7 1 3 8 6 9 2 5\\n\", \"4 4\\n1 4\\n9 7 3 1 9 2 6 8 5 4\\n5 3 2 6 7 4\\n1 3\\n3 6 5 8 4 1 2 7\\n2 6 1 8 6 2 7 3\\n5 5 4 5 6 3 9\\n4 3 9 6 5\\n\", \"4 5\\n2 5 1\\n8 2 9 3 6 4 7 1 8\\n2 9 8\\n2 6 3\\n1 7 4 9 6 8 5 1 3\\n1 6 7 5 4 2 8 6\\n1 3 5 1 4\\n1 5 5 6 9 1 2\\n1 3 8 2 5\\n\", \"4 5\\n5 6 7 8 5 3\\n3 2 5 8\\n3 8 9 1\\n1 1\\n1 2 2 6\\n1 3 3 2 6\\n2 4 3 1 6 8\\n1 4 2 8 4 3\\n1 2 3 8\\n\", \"4 5\\n3 1 6 7\\n7 7 4 2 1 8 5 6\\n3 6 3 4\\n5 4 1 2 7 3\\n5 2 5 3\\n3 6 9 1 6 2 7 4\\n4 8 5 7 2 6 3 1 4 9\\n3 5 8 3 9 7 4\\n1 2 5 2\\n\", \"5 2\\n8 2 5 8 3 6 1 9 4\\n3 3 1 8\\n2 5 3\\n9 8 9 5 6 7 1 2 3 4\\n6 6 1 8 5 9 4\\n1 6 4 5 7 9 6 3\\n1 4 9 7 2 1\\n\", \"5 2\\n2 4 5\\n5 6 4 1 9 3\\n9 8 2 7 5 4 3 9 1 6\\n1 6\\n5 7 3 6 5 8\\n2 3 3 1 8\\n2 9 7 5 9 1 6 4 2 8 3\\n\", \"5 2\\n1 9\\n5 3 6 4 8 9\\n9 7 4 8 2 3 6 1 5 9\\n1 7\\n1 6\\n5 5 6 3 5 1 4\\n2 8 9 5 1 6 8 2 7 3\\n\", \"5 3\\n2 6 9\\n5 2 9 4 1 3\\n6 2 5 4 9 7 1\\n4 8 1 2 4\\n6 8 5 9 3 7 1\\n1 1 4\\n1 6 2 7 9 8 3 1\\n1 3 7 2 1\\n\", \"5 3\\n9 6 1 2 9 3 5 8 4 7\\n2 7 3\\n4 9 7 4 5\\n9 8 1 4 3 5 6 7 2 9\\n1 8\\n2 5 2 7 8 4 9\\n1 2 3 4\\n2 5 5 6 7 4 2\\n\", \"5 3\\n3 8 5 3\\n5 2 5 1 8 7\\n2 3 7\\n8 9 1 2 8 7 5 3 4\\n4 8 7 9 4\\n3 8 5 4 7 2 3 9 8 6\\n4 1 4\\n3 8 2 8 5 7 3 4 6 1\\n\", \"5 4\\n5 8 9 5 4 1\\n6 1 4 3 2 8 9\\n5 6 4 8 5 1\\n6 1 7 4 3 5 9\\n6 8 5 3 7 1 2\\n1 7 4 9 6 7 1 2 8\\n1 8 7 8 5 1 4 3 9 2\\n1 7 3 5 1 7 8 6 9\\n1 3 8 6 7\\n\", \"5 4\\n3 7 9 1\\n1 7\\n3 1 8 2\\n4 5 4 8 2\\n1 3\\n1 2 2 8\\n2 2 9 5\\n2 6 7 2 3 5 9 6\\n3 9 5 7 4 2 8 9 3 6 1\\n\", \"5 4\\n6 5 7 1 9 3 4\\n4 3 8 1 7\\n6 4 2 5 7 6 3\\n4 6 1 4 3\\n7 9 2 6 5 3 7 4\\n5 5 2 6 3 8 9\\n5 1 8\\n2 8 5 4 8 2 7 1 6 3\\n5 5 1 8 6 7 3\\n\", \"5 5\\n8 5 3 8 4 1 9 7 6\\n4 6 7 8 2\\n4 8 4 1 3\\n1 7\\n9 9 4 7 6 5 8 3 1 2\\n1 5 8 2 4 5 3\\n1 9 2 6 9 5 8 4 3 1 7\\n1 8 1 6 2 7 9 5 4 3\\n1 3 7 9 6\\n1 7 6 9 2 1 5 8 7\\n\", \"5 5\\n6 5 8 4 2 9 7\\n5 4 7 9 8 2\\n4 7 4 9 8\\n5 1 2 3 6 9\\n7 3 4 8 1 5 7 6\\n1 2 5 6\\n3 6 6 1 5 2 9 3\\n2 2 9 4\\n1 9 6 9 3 1 5 7 4 2 8\\n2 6 5 4 8 7 2 9\\n\", \"5 5\\n9 7 3 2 9 4 6 1 5 8\\n3 1 9 8\\n4 1 3 8 9\\n5 7 5 6 9 3\\n8 5 1 4 3 7 9 2 8\\n5 7 1 4 2 5 3 7 6\\n4 2 8 2\\n4 6 9 8 4 6 1 5\\n3 6 6 3 8 9 1 4\\n1 6 5 1 4 7 9 2\\n\", \"1 2\\n1 1\\n1000000000 1 1\\n1000000000 1 1\\n\", \"2 3\\n5 9 5 7 4 3\\n1 2\\n1 8 2 7 8 4 1 3 6 5\\n3 9 7 8 4 9 3 2 6 5 1\\n1 4 2 4 8 9\\n\", \"2 3\\n3 3 5 7\\n3 1 9 4\\n4 2 3 6\\n2 4 8 2 6 9\\n5 8 4 8 2 1 9 6 7 3\\n\", \"2 3\\n2 5 4\\n9 9 6 3 2 8 4 5 1 7\\n1 7 9 4 1 6 8 2 5\\n1 6 1 9 3 8 5 4\\n1 1 3\\n\", \"1 2\\n1 1\\n5 1 1\\n6 1 1\\n\", \"1 2\\n1 1\\n5 1 1\\n5 1 1\\n\", \"1 3\\n1 1\\n6 1 2\\n5 1 1\\n5 1 1\\n\"], \"outputs\": [\"2 3\\n\", \"1 2\\n\", \"2 4\\n\", \"1 2\\n\", \"1 2\\n\", \"1 2\\n\", \"1 2\\n\", \"1 2\\n\", \"1 3\\n\", \"2 3\\n\", \"2 3\\n\", \"1 2\\n\", \"1 2\\n\", \"2 4\\n\", \"1 2\\n\", \"4 5\\n\", \"1 2\\n\", \"1 2\\n\", \"1 2\\n\", \"1 2\\n\", \"1 2\\n\", \"1 3\\n\", \"1 2\\n\", \"2 3\\n\", \"1 4\\n\", \"1 5\\n\", \"2 5\\n\", \"1 2\\n\", \"1 2\\n\", \"1 2\\n\", \"1 2\\n\", \"1 3\\n\", \"1 3\\n\", \"1 2\\n\", \"2 4\\n\", \"1 3\\n\", \"1 4\\n\", \"1 3\\n\", \"2 5\\n\", \"1 2\\n\", \"1 2\\n\", \"1 2\\n\", \"2 3\\n\", \"1 2\\n\", \"2 3\\n\", \"1 2\\n\", \"1 4\\n\", \"2 3\\n\", \"1 2\\n\", \"1 3\\n\", \"3 4\\n\", \"1 2\\n\", \"1 2\\n\", \"1 2\\n\", \"1 2\\n\", \"1 2\\n\", \"1 3\\n\", \"1 2\\n\", \"1 4\\n\", \"1 3\\n\", \"1 2\\n\", \"1 4\\n\", \"4 5\\n\", \"1 2\\n\", \"1 3\\n\", \"2 3\\n\", \"1 2\\n\", \"1 2\\n\", \"1 2\\n\", \"2 3\\n\"]}", "source": "primeintellect"}
A company of $n$ friends wants to order exactly two pizzas. It is known that in total there are $9$ pizza ingredients in nature, which are denoted by integers from $1$ to $9$. Each of the $n$ friends has one or more favorite ingredients: the $i$-th of friends has the number of favorite ingredients equal to $f_i$ ($1 \le f_i \le 9$) and your favorite ingredients form the sequence $b_{i1}, b_{i2}, \dots, b_{if_i}$ ($1 \le b_{it} \le 9$). The website of CodePizza restaurant has exactly $m$ ($m \ge 2$) pizzas. Each pizza is characterized by a set of $r_j$ ingredients $a_{j1}, a_{j2}, \dots, a_{jr_j}$ ($1 \le r_j \le 9$, $1 \le a_{jt} \le 9$) , which are included in it, and its price is $c_j$. Help your friends choose exactly two pizzas in such a way as to please the maximum number of people in the company. It is known that a person is pleased with the choice if each of his/her favorite ingredients is in at least one ordered pizza. If there are several ways to choose two pizzas so as to please the maximum number of friends, then choose the one that minimizes the total price of two pizzas. -----Input----- The first line of the input contains two integers $n$ and $m$ ($1 \le n \le 10^5, 2 \le m \le 10^5$) — the number of friends in the company and the number of pizzas, respectively. Next, the $n$ lines contain descriptions of favorite ingredients of the friends: the $i$-th of them contains the number of favorite ingredients $f_i$ ($1 \le f_i \le 9$) and a sequence of distinct integers $b_{i1}, b_{i2}, \dots, b_{if_i}$ ($1 \le b_{it} \le 9$). Next, the $m$ lines contain pizza descriptions: the $j$-th of them contains the integer price of the pizza $c_j$ ($1 \le c_j \le 10^9$), the number of ingredients $r_j$ ($1 \le r_j \le 9$) and the ingredients themselves as a sequence of distinct integers $a_{j1}, a_{j2}, \dots, a_{jr_j}$ ($1 \le a_{jt} \le 9$). -----Output----- Output two integers $j_1$ and $j_2$ ($1 \le j_1,j_2 \le m$, $j_1 \ne j_2$) denoting the indices of two pizzas in the required set. If there are several solutions, output any of them. Pizza indices can be printed in any order. -----Examples----- Input 3 4 2 6 7 4 2 3 9 5 3 2 3 9 100 1 7 400 3 3 2 5 100 2 9 2 500 3 2 9 5 Output 2 3 Input 4 3 1 1 1 2 1 3 1 4 10 4 1 2 3 4 20 4 1 2 3 4 30 4 1 2 3 4 Output 1 2 Input 1 5 9 9 8 7 6 5 4 3 2 1 3 4 1 2 3 4 1 4 5 6 7 8 4 4 1 3 5 7 1 4 2 4 6 8 5 4 1 9 2 8 Output 2 4 Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0.875
{"tests": "{\"inputs\": [\"helloworld\\nehoolwlroz\\n\", \"hastalavistababy\\nhastalavistababy\\n\", \"merrychristmas\\nchristmasmerry\\n\", \"kusyvdgccw\\nkusyvdgccw\\n\", \"bbbbbabbab\\naaaaabaaba\\n\", \"zzzzzzzzzzzzzzzzzzzzz\\nqwertyuiopasdfghjklzx\\n\", \"accdccdcdccacddbcacc\\naccbccbcbccacbbdcacc\\n\", \"giiibdbebjdaihdghahccdeffjhfgidfbdhjdggajfgaidadjd\\ngiiibdbebjdaihdghahccdeffjhfgidfbdhjdggajfgaidadjd\\n\", \"gndggadlmdefgejidmmcglbjdcmglncfmbjjndjcibnjbabfab\\nfihffahlmhogfojnhmmcflkjhcmflicgmkjjihjcnkijkakgak\\n\", \"ijpanyhovzwjjxsvaiyhchfaulcsdgfszjnwtoqbtaqygfmxuwvynvlhqhvmkjbooklxfhmqlqvfoxlnoclfxtbhvnkmhjcmrsdc\\nijpanyhovzwjjxsvaiyhchfaulcsdgfszjnwtoqbtaqygfmxuwvynvlhqhvmkjbooklxfhmqlqvfoxlnoclfxtbhvnkmhjcmrsdc\\n\", \"ab\\naa\\n\", \"a\\nz\\n\", \"zz\\nzy\\n\", \"as\\ndf\\n\", \"abc\\nbca\\n\", \"rtfg\\nrftg\\n\", \"y\\ny\\n\", \"qwertyuiopasdfghjklzx\\nzzzzzzzzzzzzzzzzzzzzz\\n\", \"qazwsxedcrfvtgbyhnujmik\\nqwertyuiasdfghjkzxcvbnm\\n\", \"aaaaaa\\nabcdef\\n\", \"qwerty\\nffffff\\n\", \"dofbgdppdvmwjwtdyphhmqliydxyjfxoopxiscevowleccmhwybsxitvujkfliamvqinlrpytyaqdlbywccprukoisyaseibuqbfqjcabkieimsggsakpnqliwhehnemewhychqrfiuyaecoydnromrh\\ndofbgdppdvmwjwtdyphhmqliydxyjfxoopxiscevowleccmhwybsxitvujkfliamvqinlrpytyaqdlbywccprukoisyaseibuqbfqjcabkieimsggsakpnqliwhehnemewhychqrfiuyaecoydnromrh\\n\", \"acdbccddadbcbabbebbaebdcedbbcebeaccecdabadeabeecbacacdcbccedeadadedeccedecdaabcedccccbbcbcedcaccdede\\ndcbaccbbdbacadaaeaadeabcebaaceaedccecbdadbedaeecadcdcbcaccebedbdbebeccebecbddacebccccaacacebcdccbebe\\n\", \"bacccbbacabbcaacbbba\\nbacccbbacabbcaacbbba\\n\", \"dbadbddddb\\nacbacaaaac\\n\", \"dacbdbbbdd\\nadbdadddaa\\n\", \"bbbbcbcbbc\\ndaddbabddb\\n\", \"dddddbcdbd\\nbcbbbdacdb\\n\", \"cbadcbcdaa\\nabbbababbb\\n\", \"dmkgadidjgdjikgkehhfkhgkeamhdkfemikkjhhkdjfaenmkdgenijinamngjgkmgmmedfdehkhdigdnnkhmdkdindhkhndnakdgdhkdefagkedndnijekdmkdfedkhekgdkhgkimfeakdhhhgkkff\\nbdenailbmnbmlcnehjjkcgnehadgickhdlecmggcimkahfdeinhflmlfadfnmncdnddhbkbhgejblnbffcgdbeilfigegfifaebnijeihkanehififlmhcbdcikhieghenbejneldkhaebjggncckk\\n\", \"acbbccabaa\\nabbbbbabaa\\n\", \"ccccaccccc\\naaaabaaaac\\n\", \"acbacacbbb\\nacbacacbbb\\n\", \"abbababbcc\\nccccccccbb\\n\", \"jbcbbjiifdcbeajgdeabddbfcecafejddcigfcaedbgicjihifgbahjihcjefgabgbccdiibfjgacehbbdjceacdbdeaiibaicih\\nhhihhhddcfihddhjfddhffhcididcdhffidjciddfhjdihdhdcjhdhhdhihdcjdhjhiifddhchjdidhhhfhiddifhfddddhddidh\\n\", \"ahaeheedefeehahfefhjhhedheeeedhehhfhdejdhffhhejhhhejadhefhahhadjjhdhheeeehfdaffhhefehhhefhhhhehehjda\\neiefbdfgdhffieihfhjajifgjddffgifjbhigfagjhhjicaijbdaegidhiejiegaabgjidcfcjhgehhjjchcbjjdhjbiidjdjage\\n\", \"fficficbidbcbfaddifbffdbbiaccbbciiaidbcbbiadcccbccbbaibabcbbdbcibcciibiccfifbiiicadibbiaafadacdficbc\\nddjhdghbgcbhadeccjdbddcbfjeiiaaigjejcaiabgechiiahibfejbeahafcfhjbihgjfgihdgdagjjhecjafjeedecehcdjhai\\n\", \"z\\nz\\n\", \"a\\nz\\n\", \"z\\na\\n\", \"aa\\nzz\\n\", \"az\\nza\\n\", \"aa\\nza\\n\", \"za\\nzz\\n\", \"aa\\nab\\n\", \"hehe\\nheeh\\n\", \"bd\\ncc\\n\", \"he\\nhh\\n\", \"hee\\nheh\\n\", \"aa\\nac\\n\", \"ab\\naa\\n\", \"hello\\nehlol\\n\", \"ac\\naa\\n\", \"aaabbb\\nbbbaab\\n\", \"aa\\nfa\\n\", \"hg\\nee\\n\", \"helloworld\\nehoolwlrow\\n\", \"abb\\nbab\\n\", \"aaa\\naae\\n\", \"aba\\nbaa\\n\", \"aa\\nba\\n\", \"da\\naa\\n\", \"aaa\\naab\\n\", \"xy\\nzz\\n\"], \"outputs\": [\"3\\nh e\\nl o\\nd z\\n\", \"0\\n\", \"-1\\n\", \"0\\n\", \"1\\nb a\\n\", \"-1\\n\", \"1\\nd b\\n\", \"0\\n\", \"5\\ng f\\nn i\\nd h\\ne o\\nb k\\n\", \"0\\n\", \"-1\\n\", \"1\\na z\\n\", \"-1\\n\", \"2\\na d\\ns f\\n\", \"-1\\n\", \"1\\nt f\\n\", \"0\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"0\\n\", \"-1\\n\", \"0\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"0\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"0\\n\", \"1\\na z\\n\", \"1\\nz a\\n\", \"1\\na z\\n\", \"1\\na z\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\"]}", "source": "primeintellect"}
Santa Claus decided to disassemble his keyboard to clean it. After he returned all the keys back, he suddenly realized that some pairs of keys took each other's place! That is, Santa suspects that each key is either on its place, or on the place of another key, which is located exactly where the first key should be. In order to make sure that he's right and restore the correct order of keys, Santa typed his favorite patter looking only to his keyboard. You are given the Santa's favorite patter and the string he actually typed. Determine which pairs of keys could be mixed. Each key must occur in pairs at most once. -----Input----- The input consists of only two strings s and t denoting the favorite Santa's patter and the resulting string. s and t are not empty and have the same length, which is at most 1000. Both strings consist only of lowercase English letters. -----Output----- If Santa is wrong, and there is no way to divide some of keys into pairs and swap keys in each pair so that the keyboard will be fixed, print «-1» (without quotes). Otherwise, the first line of output should contain the only integer k (k ≥ 0) — the number of pairs of keys that should be swapped. The following k lines should contain two space-separated letters each, denoting the keys which should be swapped. All printed letters must be distinct. If there are several possible answers, print any of them. You are free to choose the order of the pairs and the order of keys in a pair. Each letter must occur at most once. Santa considers the keyboard to be fixed if he can print his favorite patter without mistakes. -----Examples----- Input helloworld ehoolwlroz Output 3 h e l o d z Input hastalavistababy hastalavistababy Output 0 Input merrychristmas christmasmerry Output -1 Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0
{"tests": "{\"inputs\": [\"8\\n[[][]][]\\n\", \"6\\n[[[]]]\\n\", \"6\\n[[][]]\\n\", \"2\\n[]\\n\", \"4\\n[][]\\n\", \"4\\n[[]]\\n\", \"6\\n[][][]\\n\", \"6\\n[][[]]\\n\", \"6\\n[[]][]\\n\", \"8\\n[[]][[]]\\n\", \"10\\n[[[]][[]]]\\n\", \"8\\n[][][][]\\n\", \"8\\n[[][][]]\\n\", \"8\\n[[][[]]]\\n\", \"8\\n[[[]][]]\\n\", \"8\\n[][[][]]\\n\", \"8\\n[[]][[]]\\n\", \"8\\n[[]][][]\\n\", \"8\\n[][[]][]\\n\", \"8\\n[][][[]]\\n\", \"8\\n[[[][]]]\\n\", \"10\\n[[[[[]]]]]\\n\", \"14\\n[[[][[[[]]]]]]\\n\", \"10\\n[[[[[]]]]]\\n\", \"14\\n[[[[]][[[]]]]]\\n\", \"10\\n[[[[][]]]]\\n\", \"14\\n[[[[[[[]]]]]]]\\n\", \"10\\n[[[][[]]]]\\n\", \"14\\n[[[[[]][][]]]]\\n\", \"10\\n[[[]]][[]]\\n\", \"14\\n[[[[[[[]]]]]]]\\n\", \"10\\n[[][[[]]]]\\n\", \"14\\n[[[[[]]]][[]]]\\n\", \"10\\n[[[][]]][]\\n\", \"14\\n[[[[[]]]]][[]]\\n\", \"10\\n[[[][]]][]\\n\", \"14\\n[[[[]][]][[]]]\\n\", \"10\\n[[]][][[]]\\n\", \"14\\n[[][]][[]][][]\\n\", \"10\\n[[]][[[]]]\\n\", \"14\\n[[[]]][[[[]]]]\\n\", \"10\\n[[[[]]][]]\\n\", \"14\\n[[[]][]][[]][]\\n\", \"10\\n[[[][]]][]\\n\", \"14\\n[[[[[]]][]]][]\\n\", \"10\\n[[][[]][]]\\n\", \"14\\n[[]][][[]][][]\\n\", \"10\\n[][[[][]]]\\n\", \"14\\n[[]][][[]][[]]\\n\", \"10\\n[[[][][]]]\\n\", \"14\\n[[][][]][[][]]\\n\", \"30\\n[[[[][]][]]][][[[][[]]][[]][]]\\n\", \"10\\n[[][]][][]\\n\", \"14\\n[[][][][][]][]\\n\", \"30\\n[[]][[[[]]][]][[[[][]][]]][[]]\\n\", \"10\\n[][[]][][]\\n\", \"14\\n[[]][[[]][][]]\\n\", \"10\\n[[[][]][]]\\n\", \"14\\n[[[]][]][[]][]\\n\", \"10\\n[[[]]][][]\\n\", \"14\\n[[[][][]][][]]\\n\", \"30\\n[][[][[][][][]][]][][[][]][][]\\n\", \"10\\n[[]][][][]\\n\", \"14\\n[[][]][][][][]\\n\"], \"outputs\": [\"+- -++- -+\\n|+- -++- -+|| |\\n|| || ||| |\\n|+- -++- -+|| |\\n+- -++- -+\\n\", \"+- -+\\n|+- -+|\\n||+- -+||\\n||| |||\\n||+- -+||\\n|+- -+|\\n+- -+\\n\", \"+- -+\\n|+- -++- -+|\\n|| || ||\\n|+- -++- -+|\\n+- -+\\n\", \"+- -+\\n| |\\n+- -+\\n\", \"+- -++- -+\\n| || |\\n+- -++- -+\\n\", \"+- -+\\n|+- -+|\\n|| ||\\n|+- -+|\\n+- -+\\n\", \"+- -++- -++- -+\\n| || || |\\n+- -++- -++- -+\\n\", \"+- -++- -+\\n| ||+- -+|\\n| ||| ||\\n| ||+- -+|\\n+- -++- -+\\n\", \"+- -++- -+\\n|+- -+|| |\\n|| ||| |\\n|+- -+|| |\\n+- -++- -+\\n\", \"+- -++- -+\\n|+- -+||+- -+|\\n|| |||| ||\\n|+- -+||+- -+|\\n+- -++- -+\\n\", \"+- -+\\n|+- -++- -+|\\n||+- -+||+- -+||\\n||| |||| |||\\n||+- -+||+- -+||\\n|+- -++- -+|\\n+- -+\\n\", \"+- -++- -++- -++- -+\\n| || || || |\\n+- -++- -++- -++- -+\\n\", \"+- -+\\n|+- -++- -++- -+|\\n|| || || ||\\n|+- -++- -++- -+|\\n+- -+\\n\", \"+- -+\\n|+- -++- -+|\\n|| ||+- -+||\\n|| ||| |||\\n|| ||+- -+||\\n|+- -++- -+|\\n+- -+\\n\", \"+- -+\\n|+- -++- -+|\\n||+- -+|| ||\\n||| ||| ||\\n||+- -+|| ||\\n|+- -++- -+|\\n+- -+\\n\", \"+- -++- -+\\n| ||+- -++- -+|\\n| ||| || ||\\n| ||+- -++- -+|\\n+- -++- -+\\n\", \"+- -++- -+\\n|+- -+||+- -+|\\n|| |||| ||\\n|+- -+||+- -+|\\n+- -++- -+\\n\", \"+- -++- -++- -+\\n|+- -+|| || |\\n|| ||| || |\\n|+- -+|| || |\\n+- -++- -++- -+\\n\", \"+- -++- -++- -+\\n| ||+- -+|| |\\n| ||| ||| |\\n| ||+- -+|| |\\n+- -++- -++- -+\\n\", \"+- -++- -++- -+\\n| || ||+- -+|\\n| || ||| ||\\n| || ||+- -+|\\n+- -++- -++- -+\\n\", \"+- -+\\n|+- -+|\\n||+- -++- -+||\\n||| || |||\\n||+- -++- -+||\\n|+- -+|\\n+- -+\\n\", \"+- -+\\n|+- -+|\\n||+- -+||\\n|||+- -+|||\\n||||+- -+||||\\n||||| |||||\\n||||+- -+||||\\n|||+- -+|||\\n||+- -+||\\n|+- -+|\\n+- -+\\n\", \"+- -+\\n|+- -+|\\n||+- -++- -+||\\n||| ||+- -+|||\\n||| |||+- -+||||\\n||| ||||+- -+|||||\\n||| ||||| ||||||\\n||| ||||+- -+|||||\\n||| |||+- -+||||\\n||| ||+- -+|||\\n||+- -++- -+||\\n|+- -+|\\n+- -+\\n\", \"+- -+\\n|+- -+|\\n||+- -+||\\n|||+- -+|||\\n||||+- -+||||\\n||||| |||||\\n||||+- -+||||\\n|||+- -+|||\\n||+- -+||\\n|+- -+|\\n+- -+\\n\", \"+- -+\\n|+- -+|\\n||+- -++- -+||\\n|||+- -+||+- -+|||\\n|||| ||||+- -+||||\\n|||| ||||| |||||\\n|||| ||||+- -+||||\\n|||+- -+||+- -+|||\\n||+- -++- -+||\\n|+- -+|\\n+- -+\\n\", \"+- -+\\n|+- -+|\\n||+- -+||\\n|||+- -++- -+|||\\n|||| || ||||\\n|||+- -++- -+|||\\n||+- -+||\\n|+- -+|\\n+- -+\\n\", \"+- -+\\n|+- -+|\\n||+- -+||\\n|||+- -+|||\\n||||+- -+||||\\n|||||+- -+|||||\\n||||||+- -+||||||\\n||||||| |||||||\\n||||||+- -+||||||\\n|||||+- -+|||||\\n||||+- -+||||\\n|||+- -+|||\\n||+- -+||\\n|+- -+|\\n+- -+\\n\", \"+- -+\\n|+- -+|\\n||+- -++- -+||\\n||| ||+- -+|||\\n||| ||| ||||\\n||| ||+- -+|||\\n||+- -++- -+||\\n|+- -+|\\n+- -+\\n\", \"+- -+\\n|+- -+|\\n||+- -+||\\n|||+- -++- -++- -+|||\\n||||+- -+|| || ||||\\n||||| ||| || ||||\\n||||+- -+|| || ||||\\n|||+- -++- -++- -+|||\\n||+- -+||\\n|+- -+|\\n+- -+\\n\", \"+- -++- -+\\n|+- -+||+- -+|\\n||+- -+|||| ||\\n||| ||||| ||\\n||+- -+|||| ||\\n|+- -+||+- -+|\\n+- -++- -+\\n\", \"+- -+\\n|+- -+|\\n||+- -+||\\n|||+- -+|||\\n||||+- -+||||\\n|||||+- -+|||||\\n||||||+- -+||||||\\n||||||| |||||||\\n||||||+- -+||||||\\n|||||+- -+|||||\\n||||+- -+||||\\n|||+- -+|||\\n||+- -+||\\n|+- -+|\\n+- -+\\n\", \"+- -+\\n|+- -++- -+|\\n|| ||+- -+||\\n|| |||+- -+|||\\n|| |||| ||||\\n|| |||+- -+|||\\n|| ||+- -+||\\n|+- -++- -+|\\n+- -+\\n\", \"+- -+\\n|+- -++- -+|\\n||+- -+||+- -+||\\n|||+- -+|||| |||\\n||||+- -+||||| |||\\n||||| |||||| |||\\n||||+- -+||||| |||\\n|||+- -+|||| |||\\n||+- -+||+- -+||\\n|+- -++- -+|\\n+- -+\\n\", \"+- -++- -+\\n|+- -+|| |\\n||+- -++- -+||| |\\n||| || |||| |\\n||+- -++- -+||| |\\n|+- -+|| |\\n+- -++- -+\\n\", \"+- -++- -+\\n|+- -+||+- -+|\\n||+- -+|||| ||\\n|||+- -+||||| ||\\n||||+- -+|||||| ||\\n||||| ||||||| ||\\n||||+- -+|||||| ||\\n|||+- -+||||| ||\\n||+- -+|||| ||\\n|+- -+||+- -+|\\n+- -++- -+\\n\", \"+- -++- -+\\n|+- -+|| |\\n||+- -++- -+||| |\\n||| || |||| |\\n||+- -++- -+||| |\\n|+- -+|| |\\n+- -++- -+\\n\", \"+- -+\\n|+- -++- -+|\\n||+- -++- -+||+- -+||\\n|||+- -+|| |||| |||\\n|||| ||| |||| |||\\n|||+- -+|| |||| |||\\n||+- -++- -+||+- -+||\\n|+- -++- -+|\\n+- -+\\n\", \"+- -++- -++- -+\\n|+- -+|| ||+- -+|\\n|| ||| ||| ||\\n|+- -+|| ||+- -+|\\n+- -++- -++- -+\\n\", \"+- -++- -++- -++- -+\\n|+- -++- -+||+- -+|| || |\\n|| || |||| ||| || |\\n|+- -++- -+||+- -+|| || |\\n+- -++- -++- -++- -+\\n\", \"+- -++- -+\\n|+- -+||+- -+|\\n|| ||||+- -+||\\n|| ||||| |||\\n|| ||||+- -+||\\n|+- -+||+- -+|\\n+- -++- -+\\n\", \"+- -++- -+\\n|+- -+||+- -+|\\n||+- -+||||+- -+||\\n||| ||||||+- -+|||\\n||| ||||||| ||||\\n||| ||||||+- -+|||\\n||+- -+||||+- -+||\\n|+- -+||+- -+|\\n+- -++- -+\\n\", \"+- -+\\n|+- -++- -+|\\n||+- -+|| ||\\n|||+- -+||| ||\\n|||| |||| ||\\n|||+- -+||| ||\\n||+- -+|| ||\\n|+- -++- -+|\\n+- -+\\n\", \"+- -++- -++- -+\\n|+- -++- -+||+- -+|| |\\n||+- -+|| |||| ||| |\\n||| ||| |||| ||| |\\n||+- -+|| |||| ||| |\\n|+- -++- -+||+- -+|| |\\n+- -++- -++- -+\\n\", \"+- -++- -+\\n|+- -+|| |\\n||+- -++- -+||| |\\n||| || |||| |\\n||+- -++- -+||| |\\n|+- -+|| |\\n+- -++- -+\\n\", \"+- -++- -+\\n|+- -+|| |\\n||+- -++- -+||| |\\n|||+- -+|| |||| |\\n||||+- -+||| |||| |\\n||||| |||| |||| |\\n||||+- -+||| |||| |\\n|||+- -+|| |||| |\\n||+- -++- -+||| |\\n|+- -+|| |\\n+- -++- -+\\n\", \"+- -+\\n|+- -++- -++- -+|\\n|| ||+- -+|| ||\\n|| ||| ||| ||\\n|| ||+- -+|| ||\\n|+- -++- -++- -+|\\n+- -+\\n\", \"+- -++- -++- -++- -++- -+\\n|+- -+|| ||+- -+|| || |\\n|| ||| ||| ||| || |\\n|+- -+|| ||+- -+|| || |\\n+- -++- -++- -++- -++- -+\\n\", \"+- -++- -+\\n| ||+- -+|\\n| |||+- -++- -+||\\n| |||| || |||\\n| |||+- -++- -+||\\n| ||+- -+|\\n+- -++- -+\\n\", \"+- -++- -++- -++- -+\\n|+- -+|| ||+- -+||+- -+|\\n|| ||| ||| |||| ||\\n|+- -+|| ||+- -+||+- -+|\\n+- -++- -++- -++- -+\\n\", \"+- -+\\n|+- -+|\\n||+- -++- -++- -+||\\n||| || || |||\\n||+- -++- -++- -+||\\n|+- -+|\\n+- -+\\n\", \"+- -++- -+\\n|+- -++- -++- -+||+- -++- -+|\\n|| || || |||| || ||\\n|+- -++- -++- -+||+- -++- -+|\\n+- -++- -+\\n\", \"+- -++- -++- -+\\n|+- -+|| ||+- -++- -++- -+|\\n||+- -++- -+||| |||+- -++- -+||+- -+|| ||\\n|||+- -++- -+|| |||| |||| ||+- -+|||| ||| ||\\n|||| || ||| |||| |||| ||| ||||| ||| ||\\n|||+- -++- -+|| |||| |||| ||+- -+|||| ||| ||\\n||+- -++- -+||| |||+- -++- -+||+- -+|| ||\\n|+- -+|| ||+- -++- -++- -+|\\n+- -++- -++- -+\\n\", \"+- -++- -++- -+\\n|+- -++- -+|| || |\\n|| || ||| || |\\n|+- -++- -+|| || |\\n+- -++- -++- -+\\n\", \"+- -++- -+\\n|+- -++- -++- -++- -++- -+|| |\\n|| || || || || ||| |\\n|+- -++- -++- -++- -++- -+|| |\\n+- -++- -+\\n\", \"+- -++- -++- -++- -+\\n|+- -+||+- -++- -+||+- -+||+- -+|\\n|| ||||+- -+|| ||||+- -++- -+|||| ||\\n|| |||||+- -+||| |||||+- -++- -+|| ||||| ||\\n|| |||||| |||| |||||| || ||| ||||| ||\\n|| |||||+- -+||| |||||+- -++- -+|| ||||| ||\\n|| ||||+- -+|| ||||+- -++- -+|||| ||\\n|+- -+||+- -++- -+||+- -+||+- -+|\\n+- -++- -++- -++- -+\\n\", \"+- -++- -++- -++- -+\\n| ||+- -+|| || |\\n| ||| ||| || |\\n| ||+- -+|| || |\\n+- -++- -++- -++- -+\\n\", \"+- -++- -+\\n|+- -+||+- -++- -++- -+|\\n|| ||||+- -+|| || ||\\n|| ||||| ||| || ||\\n|| ||||+- -+|| || ||\\n|+- -+||+- -++- -++- -+|\\n+- -++- -+\\n\", \"+- -+\\n|+- -++- -+|\\n||+- -++- -+|| ||\\n||| || ||| ||\\n||+- -++- -+|| ||\\n|+- -++- -+|\\n+- -+\\n\", \"+- -++- -++- -+\\n|+- -++- -+||+- -+|| |\\n||+- -+|| |||| ||| |\\n||| ||| |||| ||| |\\n||+- -+|| |||| ||| |\\n|+- -++- -+||+- -+|| |\\n+- -++- -++- -+\\n\", \"+- -++- -++- -+\\n|+- -+|| || |\\n||+- -+||| || |\\n||| |||| || |\\n||+- -+||| || |\\n|+- -+|| || |\\n+- -++- -++- -+\\n\", \"+- -+\\n|+- -++- -++- -+|\\n||+- -++- -++- -+|| || ||\\n||| || || ||| || ||\\n||+- -++- -++- -+|| || ||\\n|+- -++- -++- -+|\\n+- -+\\n\", \"+- -++- -++- -++- -++- -++- -+\\n| ||+- -++- -++- -+|| ||+- -++- -+|| || |\\n| ||| ||+- -++- -++- -++- -+|| ||| ||| || ||| || |\\n| ||| ||| || || || ||| ||| ||| || ||| || |\\n| ||| ||+- -++- -++- -++- -+|| ||| ||| || ||| || |\\n| ||+- -++- -++- -+|| ||+- -++- -+|| || |\\n+- -++- -++- -++- -++- -++- -+\\n\", \"+- -++- -++- -++- -+\\n|+- -+|| || || |\\n|| ||| || || |\\n|+- -+|| || || |\\n+- -++- -++- -++- -+\\n\", \"+- -++- -++- -++- -++- -+\\n|+- -++- -+|| || || || |\\n|| || ||| || || || |\\n|+- -++- -+|| || || || |\\n+- -++- -++- -++- -++- -+\\n\"]}", "source": "primeintellect"}
A sequence of square brackets is regular if by inserting symbols "+" and "1" into it, you can get a regular mathematical expression from it. For example, sequences "[[]][]", "[]" and "[[][[]]]" — are regular, at the same time "][", "[[]" and "[[]]][" — are irregular. Draw the given sequence using a minimalistic pseudographics in the strip of the lowest possible height — use symbols '+', '-' and '|'. For example, the sequence "[[][]][]" should be represented as: +- -++- -+ |+- -++- -+|| | || || ||| | |+- -++- -+|| | +- -++- -+ Each bracket should be represented with the hepl of one or more symbols '|' (the vertical part) and symbols '+' and '-' as on the example which is given above. Brackets should be drawn without spaces one by one, only dividing pairs of consecutive pairwise brackets with a single-space bar (so that the two brackets do not visually merge into one symbol). The image should have the minimum possible height. The enclosed bracket is always smaller than the surrounding bracket, but each bracket separately strives to maximize the height of the image. So the pair of final brackets in the example above occupies the entire height of the image. Study carefully the examples below, they adequately explain the condition of the problem. Pay attention that in this problem the answer (the image) is unique. -----Input----- The first line contains an even integer n (2 ≤ n ≤ 100) — the length of the sequence of brackets. The second line contains the sequence of brackets — these are n symbols "[" and "]". It is guaranteed that the given sequence of brackets is regular. -----Output----- Print the drawn bracket sequence in the format which is given in the condition. Don't print extra (unnecessary) spaces. -----Examples----- Input 8 [[][]][] Output +- -++- -+ |+- -++- -+|| | || || ||| | |+- -++- -+|| | +- -++- -+ Input 6 [[[]]] Output +- -+ |+- -+| ||+- -+|| ||| ||| ||+- -+|| |+- -+| +- -+ Input 6 [[][]] Output +- -+ |+- -++- -+| || || || |+- -++- -+| +- -+ Input 2 [] Output +- -+ | | +- -+ Input 4 [][] Output +- -++- -+ | || | +- -++- -+ Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0
{"tests": "{\"inputs\": [\"4\\nred\\npurple\\nyellow\\norange\\n\", \"0\\n\", \"6\\npurple\\nblue\\nyellow\\nred\\ngreen\\norange\\n\", \"1\\npurple\\n\", \"3\\nblue\\norange\\npurple\\n\", \"2\\nyellow\\nred\\n\", \"1\\ngreen\\n\", \"2\\npurple\\ngreen\\n\", \"1\\nblue\\n\", \"2\\npurple\\nblue\\n\", \"2\\ngreen\\nblue\\n\", \"3\\npurple\\ngreen\\nblue\\n\", \"1\\norange\\n\", \"2\\npurple\\norange\\n\", \"2\\norange\\ngreen\\n\", \"3\\norange\\npurple\\ngreen\\n\", \"2\\norange\\nblue\\n\", \"3\\nblue\\ngreen\\norange\\n\", \"4\\nblue\\norange\\ngreen\\npurple\\n\", \"1\\nred\\n\", \"2\\nred\\npurple\\n\", \"2\\nred\\ngreen\\n\", \"3\\nred\\npurple\\ngreen\\n\", \"2\\nblue\\nred\\n\", \"3\\nred\\nblue\\npurple\\n\", \"3\\nred\\nblue\\ngreen\\n\", \"4\\npurple\\nblue\\ngreen\\nred\\n\", \"2\\norange\\nred\\n\", \"3\\nred\\norange\\npurple\\n\", \"3\\nred\\norange\\ngreen\\n\", \"4\\nred\\norange\\ngreen\\npurple\\n\", \"3\\nblue\\norange\\nred\\n\", \"4\\norange\\nblue\\npurple\\nred\\n\", \"4\\ngreen\\norange\\nred\\nblue\\n\", \"5\\npurple\\norange\\nblue\\nred\\ngreen\\n\", \"1\\nyellow\\n\", \"2\\npurple\\nyellow\\n\", \"2\\ngreen\\nyellow\\n\", \"3\\npurple\\nyellow\\ngreen\\n\", \"2\\nblue\\nyellow\\n\", \"3\\nyellow\\nblue\\npurple\\n\", \"3\\ngreen\\nyellow\\nblue\\n\", \"4\\nyellow\\nblue\\ngreen\\npurple\\n\", \"2\\nyellow\\norange\\n\", \"3\\nyellow\\npurple\\norange\\n\", \"3\\norange\\nyellow\\ngreen\\n\", \"4\\ngreen\\nyellow\\norange\\npurple\\n\", \"3\\nyellow\\nblue\\norange\\n\", \"4\\norange\\npurple\\nblue\\nyellow\\n\", \"4\\nblue\\norange\\nyellow\\ngreen\\n\", \"5\\ngreen\\nyellow\\norange\\nblue\\npurple\\n\", \"3\\nyellow\\npurple\\nred\\n\", \"3\\nred\\ngreen\\nyellow\\n\", \"4\\nred\\npurple\\ngreen\\nyellow\\n\", \"3\\nred\\nyellow\\nblue\\n\", \"4\\nblue\\nyellow\\nred\\npurple\\n\", \"4\\nblue\\nyellow\\nred\\ngreen\\n\", \"5\\nred\\nyellow\\ngreen\\nblue\\npurple\\n\", \"3\\nred\\nyellow\\norange\\n\", \"4\\norange\\ngreen\\nyellow\\nred\\n\", \"5\\norange\\nred\\ngreen\\nyellow\\npurple\\n\", \"4\\nyellow\\nred\\norange\\nblue\\n\", \"5\\npurple\\nblue\\norange\\nyellow\\nred\\n\", \"5\\norange\\nblue\\nyellow\\nred\\ngreen\\n\"], \"outputs\": [\"2\\nTime\\nSpace\\n\", \"6\\nReality\\nTime\\nMind\\nSpace\\nPower\\nSoul\\n\", \"0\\n\", \"5\\nMind\\nSpace\\nReality\\nSoul\\nTime\\n\", \"3\\nReality\\nMind\\nTime\\n\", \"4\\nTime\\nPower\\nSoul\\nSpace\\n\", \"5\\nReality\\nSpace\\nMind\\nPower\\nSoul\\n\", \"4\\nSpace\\nReality\\nSoul\\nMind\\n\", \"5\\nMind\\nSoul\\nTime\\nPower\\nReality\\n\", \"4\\nReality\\nTime\\nSoul\\nMind\\n\", \"4\\nPower\\nMind\\nSoul\\nReality\\n\", \"3\\nSoul\\nReality\\nMind\\n\", \"5\\nReality\\nTime\\nSpace\\nMind\\nPower\\n\", \"4\\nTime\\nSpace\\nReality\\nMind\\n\", \"4\\nMind\\nReality\\nSpace\\nPower\\n\", \"3\\nReality\\nSpace\\nMind\\n\", \"4\\nPower\\nReality\\nMind\\nTime\\n\", \"3\\nMind\\nReality\\nPower\\n\", \"2\\nMind\\nReality\\n\", \"5\\nSoul\\nTime\\nPower\\nMind\\nSpace\\n\", \"4\\nSoul\\nMind\\nSpace\\nTime\\n\", \"4\\nSoul\\nSpace\\nPower\\nMind\\n\", \"3\\nMind\\nSpace\\nSoul\\n\", \"4\\nSoul\\nTime\\nPower\\nMind\\n\", \"3\\nTime\\nSoul\\nMind\\n\", \"3\\nSoul\\nMind\\nPower\\n\", \"2\\nMind\\nSoul\\n\", \"4\\nTime\\nSpace\\nMind\\nPower\\n\", \"3\\nTime\\nSpace\\nMind\\n\", \"3\\nPower\\nMind\\nSpace\\n\", \"2\\nSpace\\nMind\\n\", \"3\\nPower\\nMind\\nTime\\n\", \"2\\nMind\\nTime\\n\", \"2\\nPower\\nMind\\n\", \"1\\nMind\\n\", \"5\\nSoul\\nTime\\nSpace\\nReality\\nPower\\n\", \"4\\nReality\\nSpace\\nSoul\\nTime\\n\", \"4\\nReality\\nSoul\\nPower\\nSpace\\n\", \"3\\nReality\\nSoul\\nSpace\\n\", \"4\\nTime\\nReality\\nPower\\nSoul\\n\", \"3\\nTime\\nSoul\\nReality\\n\", \"3\\nPower\\nSoul\\nReality\\n\", \"2\\nReality\\nSoul\\n\", \"4\\nPower\\nReality\\nSpace\\nTime\\n\", \"3\\nSpace\\nTime\\nReality\\n\", \"3\\nPower\\nSpace\\nReality\\n\", \"2\\nReality\\nSpace\\n\", \"3\\nTime\\nReality\\nPower\\n\", \"2\\nReality\\nTime\\n\", \"2\\nReality\\nPower\\n\", \"1\\nReality\\n\", \"3\\nSoul\\nSpace\\nTime\\n\", \"3\\nSpace\\nPower\\nSoul\\n\", \"2\\nSoul\\nSpace\\n\", \"3\\nSoul\\nTime\\nPower\\n\", \"2\\nSoul\\nTime\\n\", \"2\\nPower\\nSoul\\n\", \"1\\nSoul\\n\", \"3\\nPower\\nSpace\\nTime\\n\", \"2\\nPower\\nSpace\\n\", \"1\\nSpace\\n\", \"2\\nPower\\nTime\\n\", \"1\\nTime\\n\", \"1\\nPower\\n\"]}", "source": "primeintellect"}
You took a peek on Thanos wearing Infinity Gauntlet. In the Gauntlet there is a place for six Infinity Gems: the Power Gem of purple color, the Time Gem of green color, the Space Gem of blue color, the Soul Gem of orange color, the Reality Gem of red color, the Mind Gem of yellow color. Using colors of Gems you saw in the Gauntlet determine the names of absent Gems. -----Input----- In the first line of input there is one integer $n$ ($0 \le n \le 6$) — the number of Gems in Infinity Gauntlet. In next $n$ lines there are colors of Gems you saw. Words used for colors are: purple, green, blue, orange, red, yellow. It is guaranteed that all the colors are distinct. All colors are given in lowercase English letters. -----Output----- In the first line output one integer $m$ ($0 \le m \le 6$) — the number of absent Gems. Then in $m$ lines print the names of absent Gems, each on its own line. Words used for names are: Power, Time, Space, Soul, Reality, Mind. Names can be printed in any order. Keep the first letter uppercase, others lowercase. -----Examples----- Input 4 red purple yellow orange Output 2 Space Time Input 0 Output 6 Time Mind Soul Power Reality Space -----Note----- In the first sample Thanos already has Reality, Power, Mind and Soul Gems, so he needs two more: Time and Space. In the second sample Thanos doesn't have any Gems, so he needs all six. Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0
{"tests": "{\"inputs\": [\"4\\n4 3 2 1\\n0 1 1 1\\n\", \"3\\n2 3 1\\n0 0 0\\n\", \"1\\n1\\n0\\n\", \"2\\n1 2\\n0 0\\n\", \"2\\n2 1\\n0 0\\n\", \"2\\n1 2\\n0 1\\n\", \"2\\n2 1\\n1 0\\n\", \"2\\n1 2\\n1 1\\n\", \"2\\n2 1\\n1 1\\n\", \"5\\n2 1 3 4 5\\n1 0 0 0 1\\n\", \"10\\n4 10 5 1 6 8 9 2 3 7\\n0 1 0 0 1 0 0 1 0 0\\n\", \"20\\n10 15 20 17 8 1 14 6 3 13 19 2 16 12 4 5 11 7 9 18\\n0 0 0 1 0 0 0 1 0 0 1 0 0 0 0 0 0 1 0 0\\n\", \"100\\n87 69 49 86 96 12 10 79 29 66 48 77 73 62 70 52 22 28 97 35 91 5 33 82 65 85 68 80 64 8 38 23 94 34 75 53 57 6 100 2 56 50 55 58 74 9 18 44 40 3 43 45 99 51 21 92 89 36 88 54 42 14 78 71 25 76 13 11 27 72 7 32 93 46 83 30 26 37 39 31 95 59 47 24 67 16 4 15 1 98 19 81 84 61 90 41 17 20 63 60\\n1 1 1 0 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\\n\", \"1\\n1\\n1\\n\", \"2\\n1 2\\n1 0\\n\", \"2\\n2 1\\n0 1\\n\", \"3\\n1 2 3\\n0 0 0\\n\", \"3\\n1 2 3\\n1 0 0\\n\", \"3\\n1 2 3\\n0 1 0\\n\", \"3\\n1 2 3\\n1 1 0\\n\", \"3\\n1 2 3\\n0 0 1\\n\", \"3\\n1 2 3\\n1 0 1\\n\", \"3\\n1 2 3\\n0 1 1\\n\", \"3\\n1 2 3\\n1 1 1\\n\", \"3\\n1 3 2\\n0 0 0\\n\", \"3\\n1 3 2\\n1 0 0\\n\", \"3\\n1 3 2\\n0 1 0\\n\", \"3\\n1 3 2\\n1 1 0\\n\", \"3\\n1 3 2\\n0 0 1\\n\", \"3\\n1 3 2\\n1 0 1\\n\", \"3\\n1 3 2\\n0 1 1\\n\", \"3\\n1 3 2\\n1 1 1\\n\", \"3\\n2 1 3\\n0 0 0\\n\", \"3\\n2 1 3\\n1 0 0\\n\", \"3\\n2 1 3\\n0 1 0\\n\", \"3\\n2 1 3\\n1 1 0\\n\", \"3\\n2 1 3\\n0 0 1\\n\", \"3\\n2 1 3\\n1 0 1\\n\", \"3\\n2 1 3\\n0 1 1\\n\", \"3\\n2 1 3\\n1 1 1\\n\", \"3\\n2 3 1\\n0 0 0\\n\", \"3\\n2 3 1\\n1 0 0\\n\", \"3\\n2 3 1\\n0 1 0\\n\", \"3\\n2 3 1\\n1 1 0\\n\", \"3\\n2 3 1\\n0 0 1\\n\", \"3\\n2 3 1\\n1 0 1\\n\", \"3\\n2 3 1\\n0 1 1\\n\", \"3\\n2 3 1\\n1 1 1\\n\", \"3\\n3 1 2\\n0 0 0\\n\", \"3\\n3 1 2\\n1 0 0\\n\", \"3\\n3 1 2\\n0 1 0\\n\", \"3\\n3 1 2\\n1 1 0\\n\", \"3\\n3 1 2\\n0 0 1\\n\", \"3\\n3 1 2\\n1 0 1\\n\", \"3\\n3 1 2\\n0 1 1\\n\", \"3\\n3 1 2\\n1 1 1\\n\", \"3\\n3 2 1\\n0 0 0\\n\", \"3\\n3 2 1\\n1 0 0\\n\", \"3\\n3 2 1\\n0 1 0\\n\", \"3\\n3 2 1\\n1 1 0\\n\", \"3\\n3 2 1\\n0 0 1\\n\", \"3\\n3 2 1\\n1 0 1\\n\", \"3\\n3 2 1\\n0 1 1\\n\", \"3\\n3 2 1\\n1 1 1\\n\"], \"outputs\": [\"2\\n\", \"1\\n\", \"1\\n\", \"3\\n\", \"1\\n\", \"2\\n\", \"0\\n\", \"3\\n\", \"1\\n\", \"5\\n\", \"2\\n\", \"3\\n\", \"4\\n\", \"0\\n\", \"2\\n\", \"0\\n\", \"4\\n\", \"3\\n\", \"3\\n\", \"4\\n\", \"3\\n\", \"4\\n\", \"4\\n\", \"3\\n\", \"3\\n\", \"2\\n\", \"2\\n\", \"3\\n\", \"2\\n\", \"3\\n\", \"3\\n\", \"2\\n\", \"3\\n\", \"2\\n\", \"2\\n\", \"3\\n\", \"2\\n\", \"3\\n\", \"3\\n\", \"2\\n\", \"1\\n\", \"0\\n\", \"0\\n\", \"1\\n\", \"0\\n\", \"1\\n\", \"1\\n\", \"0\\n\", \"1\\n\", \"0\\n\", \"0\\n\", \"1\\n\", \"0\\n\", \"1\\n\", \"1\\n\", \"0\\n\", \"3\\n\", \"2\\n\", \"2\\n\", \"3\\n\", \"2\\n\", \"3\\n\", \"3\\n\", \"2\\n\"]}", "source": "primeintellect"}
Pavel cooks barbecue. There are n skewers, they lay on a brazier in a row, each on one of n positions. Pavel wants each skewer to be cooked some time in every of n positions in two directions: in the one it was directed originally and in the reversed direction. Pavel has a plan: a permutation p and a sequence b_1, b_2, ..., b_{n}, consisting of zeros and ones. Each second Pavel move skewer on position i to position p_{i}, and if b_{i} equals 1 then he reverses it. So he hope that every skewer will visit every position in both directions. Unfortunately, not every pair of permutation p and sequence b suits Pavel. What is the minimum total number of elements in the given permutation p and the given sequence b he needs to change so that every skewer will visit each of 2n placements? Note that after changing the permutation should remain a permutation as well. There is no problem for Pavel, if some skewer visits some of the placements several times before he ends to cook. In other words, a permutation p and a sequence b suit him if there is an integer k (k ≥ 2n), so that after k seconds each skewer visits each of the 2n placements. It can be shown that some suitable pair of permutation p and sequence b exists for any n. -----Input----- The first line contain the integer n (1 ≤ n ≤ 2·10^5) — the number of skewers. The second line contains a sequence of integers p_1, p_2, ..., p_{n} (1 ≤ p_{i} ≤ n) — the permutation, according to which Pavel wants to move the skewers. The third line contains a sequence b_1, b_2, ..., b_{n} consisting of zeros and ones, according to which Pavel wants to reverse the skewers. -----Output----- Print single integer — the minimum total number of elements in the given permutation p and the given sequence b he needs to change so that every skewer will visit each of 2n placements. -----Examples----- Input 4 4 3 2 1 0 1 1 1 Output 2 Input 3 2 3 1 0 0 0 Output 1 -----Note----- In the first example Pavel can change the permutation to 4, 3, 1, 2. In the second example Pavel can change any element of b to 1. Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0
{"tests": "{\"inputs\": [\"2 4\\n\", \"0 10\\n\", \"107 109\\n\", \"10 13\\n\", \"998244355 998244359\\n\", \"999999999000000000 1000000000000000000\\n\", \"2 3\\n\", \"3 15\\n\", \"24 26\\n\", \"14 60\\n\", \"11 79\\n\", \"1230 1232\\n\", \"2633 2634\\n\", \"535 536\\n\", \"344319135 396746843\\n\", \"696667767 696667767\\n\", \"419530302 610096911\\n\", \"238965115 821731161\\n\", \"414626436 728903812\\n\", \"274410639 293308324\\n\", \"650636673091305697 650636673091305702\\n\", \"651240548333620923 651240548333620924\\n\", \"500000000000000000 1000000000000000000\\n\", \"999999999999999999 1000000000000000000\\n\", \"1000000000000000000 1000000000000000000\\n\", \"0 4\\n\", \"50000000062000007 50000000062000011\\n\", \"0 0\\n\", \"1 1\\n\", \"0 2\\n\", \"10000000000012 10000000000015\\n\", \"5 5\\n\", \"12 23\\n\", \"0 11\\n\", \"11111234567890 11111234567898\\n\", \"0 3\\n\", \"1 2\\n\", \"999999999999999997 999999999999999999\\n\", \"4 5\\n\", \"0 1\\n\", \"101 1002\\n\", \"0 100000000000000001\\n\", \"99999999999999997 99999999999999999\\n\", \"14 15\\n\", \"8 19\\n\", \"12 22\\n\", \"999999999999996 999999999999999\\n\", \"1 3\\n\", \"124 125\\n\", \"11 32\\n\", \"0 5\\n\", \"0 999999\\n\", \"151151151515 151151151526\\n\", \"6 107\\n\", \"5 16\\n\", \"7 16\\n\", \"6 19\\n\", \"11113111111111 13111111111111\\n\", \"1 1000\\n\", \"24 25\\n\", \"0 100000000000\\n\", \"1 22\\n\", \"999999999999999996 999999999999999999\\n\"], \"outputs\": [\"2\\n\", \"0\\n\", \"2\\n\", \"6\\n\", \"4\\n\", \"0\\n\", \"3\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"2\\n\", \"4\\n\", \"6\\n\", \"0\\n\", \"1\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"4\\n\", \"0\\n\", \"0\\n\", \"1\\n\", \"4\\n\", \"0\\n\", \"1\\n\", \"1\\n\", \"2\\n\", \"0\\n\", \"1\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"6\\n\", \"2\\n\", \"2\\n\", \"5\\n\", \"1\\n\", \"0\\n\", \"0\\n\", \"2\\n\", \"5\\n\", \"0\\n\", \"0\\n\", \"4\\n\", \"6\\n\", \"5\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"5\\n\", \"0\\n\", \"0\\n\", \"4\\n\"]}", "source": "primeintellect"}
Even if the world is full of counterfeits, I still regard it as wonderful. Pile up herbs and incense, and arise again from the flames and ashes of its predecessor — as is known to many, the phoenix does it like this. The phoenix has a rather long lifespan, and reincarnates itself once every a! years. Here a! denotes the factorial of integer a, that is, a! = 1 × 2 × ... × a. Specifically, 0! = 1. Koyomi doesn't care much about this, but before he gets into another mess with oddities, he is interested in the number of times the phoenix will reincarnate in a timespan of b! years, that is, [Image]. Note that when b ≥ a this value is always integer. As the answer can be quite large, it would be enough for Koyomi just to know the last digit of the answer in decimal representation. And you're here to provide Koyomi with this knowledge. -----Input----- The first and only line of input contains two space-separated integers a and b (0 ≤ a ≤ b ≤ 10^18). -----Output----- Output one line containing a single decimal digit — the last digit of the value that interests Koyomi. -----Examples----- Input 2 4 Output 2 Input 0 10 Output 0 Input 107 109 Output 2 -----Note----- In the first example, the last digit of $\frac{4 !}{2 !} = 12$ is 2; In the second example, the last digit of $\frac{10 !}{0 !} = 3628800$ is 0; In the third example, the last digit of $\frac{109 !}{107 !} = 11772$ is 2. Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0.875
{"tests": "{\"inputs\": [\"4\\n31 31 30 31\\n\", \"2\\n30 30\\n\", \"5\\n29 31 30 31 30\\n\", \"3\\n31 28 30\\n\", \"3\\n31 31 28\\n\", \"24\\n29 28 31 30 31 30 31 31 30 31 30 31 31 29 31 30 31 30 31 31 30 31 30 31\\n\", \"4\\n31 29 31 30\\n\", \"24\\n31 28 31 30 31 30 31 31 30 31 30 31 31 29 31 30 31 30 31 31 30 31 30 31\\n\", \"8\\n31 29 31 30 31 30 31 31\\n\", \"1\\n29\\n\", \"1\\n31\\n\", \"11\\n30 31 30 31 31 30 31 30 31 31 28\\n\", \"21\\n30 31 30 31 31 28 31 30 31 30 31 31 30 31 30 31 31 28 31 30 31\\n\", \"2\\n30 31\\n\", \"7\\n28 31 30 31 30 31 31\\n\", \"4\\n28 31 30 31\\n\", \"9\\n31 31 29 31 30 31 30 31 31\\n\", \"4\\n31 28 31 30\\n\", \"2\\n31 31\\n\", \"17\\n31 30 31 30 31 31 28 31 30 31 30 31 31 30 31 30 31\\n\", \"4\\n30 31 30 31\\n\", \"12\\n31 28 31 30 31 30 31 31 30 31 30 31\\n\", \"12\\n31 29 31 30 31 30 31 31 30 31 30 31\\n\", \"22\\n31 30 31 30 31 31 30 31 30 31 31 28 31 30 31 30 31 31 30 31 30 31\\n\", \"14\\n31 30 31 31 28 31 30 31 30 31 31 30 31 30\\n\", \"12\\n31 30 31 31 28 31 30 31 30 31 31 30\\n\", \"17\\n31 30 31 30 31 31 29 31 30 31 30 31 31 30 31 30 31\\n\", \"4\\n31 28 28 30\\n\", \"4\\n31 29 29 30\\n\", \"8\\n31 29 31 30 31 31 31 31\\n\", \"11\\n30 31 30 31 31 30 31 30 31 29 28\\n\", \"21\\n30 31 30 31 31 28 31 30 31 30 31 29 30 31 30 31 31 28 31 30 31\\n\", \"7\\n28 28 30 31 30 31 31\\n\", \"9\\n29 31 29 31 30 31 30 31 31\\n\", \"2\\n31 29\\n\", \"17\\n28 30 31 30 31 31 28 31 30 31 30 31 31 30 31 30 31\\n\", \"12\\n31 28 31 30 31 30 31 31 30 31 28 31\\n\", \"2\\n29 31\\n\", \"12\\n31 29 31 30 31 30 31 30 30 31 30 31\\n\", \"12\\n31 28 31 30 31 29 31 31 30 31 30 31\\n\", \"22\\n31 30 31 30 31 31 30 31 30 31 31 28 31 30 28 30 31 31 30 31 30 31\\n\", \"14\\n31 30 31 31 28 31 30 31 30 31 31 30 29 30\\n\", \"12\\n31 30 31 31 28 28 30 31 30 31 31 30\\n\", \"17\\n31 30 31 30 31 31 29 31 30 31 31 31 31 30 31 30 31\\n\", \"19\\n31 28 31 30 31 30 31 31 30 31 30 31 31 28 31 30 31 30 31\\n\", \"20\\n31 28 31 30 31 30 31 31 30 31 30 31 31 28 31 30 31 30 31 31\\n\", \"1\\n28\\n\", \"1\\n29\\n\", \"1\\n30\\n\", \"1\\n31\\n\", \"24\\n31 29 31 30 31 30 31 31 30 31 30 31 31 29 31 30 31 30 31 31 30 31 30 31\\n\", \"24\\n31 28 31 30 31 30 31 31 30 31 30 31 31 28 31 30 31 30 31 31 30 31 30 31\\n\", \"24\\n28 31 30 31 30 31 31 30 31 30 31 31 28 31 30 31 30 31 31 30 31 30 31 31\\n\", \"24\\n29 31 30 31 30 31 31 30 31 30 31 31 28 31 30 31 30 31 31 30 31 30 31 31\\n\", \"24\\n28 31 30 31 30 31 31 30 31 30 31 31 29 31 30 31 30 31 31 30 31 30 31 31\\n\", \"13\\n28 31 30 31 30 31 31 30 31 30 31 31 28\\n\", \"15\\n31 31 28 31 30 31 30 31 31 30 31 30 31 31 29\\n\", \"23\\n31 30 31 31 30 31 30 31 31 28 31 30 31 30 31 31 30 31 30 31 31 29 31\\n\", \"24\\n31 30 31 30 31 31 30 31 30 31 31 30 31 30 31 30 31 31 30 31 30 31 31 30\\n\", \"23\\n29 31 30 31 30 31 31 30 31 30 31 31 29 31 30 31 30 31 31 30 31 30 31\\n\", \"15\\n31 31 29 31 30 31 30 31 31 30 31 30 31 31 28\\n\", \"12\\n31 30 31 30 31 30 31 31 30 31 30 31\\n\"], \"outputs\": [\"Yes\\n\\n\", \"No\\n\\n\", \"Yes\\n\\n\", \"No\\n\\n\", \"Yes\\n\\n\", \"No\\n\\n\", \"Yes\\n\\n\", \"Yes\\n\\n\", \"Yes\\n\\n\", \"Yes\\n\\n\", \"Yes\\n\\n\", \"Yes\\n\\n\", \"Yes\\n\\n\", \"Yes\\n\\n\", \"Yes\\n\\n\", \"Yes\\n\\n\", \"Yes\\n\\n\", \"Yes\\n\\n\", \"Yes\\n\\n\", \"Yes\\n\\n\", \"Yes\\n\\n\", \"Yes\\n\\n\", \"Yes\\n\\n\", \"Yes\\n\\n\", \"Yes\\n\\n\", \"Yes\\n\\n\", \"Yes\\n\\n\", \"No\\n\\n\", \"No\\n\\n\", \"No\\n\\n\", \"No\\n\\n\", \"No\\n\\n\", \"No\\n\\n\", \"No\\n\\n\", \"Yes\\n\\n\", \"No\\n\\n\", \"No\\n\\n\", \"Yes\\n\\n\", \"No\\n\\n\", \"No\\n\\n\", \"No\\n\\n\", \"No\\n\\n\", \"No\\n\\n\", \"No\\n\\n\", \"Yes\\n\\n\", \"Yes\\n\\n\", \"Yes\\n\\n\", \"Yes\\n\\n\", \"Yes\\n\\n\", \"Yes\\n\\n\", \"No\\n\\n\", \"Yes\\n\\n\", \"Yes\\n\\n\", \"Yes\\n\\n\", \"Yes\\n\\n\", \"Yes\\n\\n\", \"Yes\\n\\n\", \"Yes\\n\\n\", \"No\\n\\n\", \"No\\n\\n\", \"Yes\\n\\n\", \"No\\n\\n\"]}", "source": "primeintellect"}
Everybody in Russia uses Gregorian calendar. In this calendar there are 31 days in January, 28 or 29 days in February (depending on whether the year is leap or not), 31 days in March, 30 days in April, 31 days in May, 30 in June, 31 in July, 31 in August, 30 in September, 31 in October, 30 in November, 31 in December. A year is leap in one of two cases: either its number is divisible by 4, but not divisible by 100, or is divisible by 400. For example, the following years are leap: 2000, 2004, but years 1900 and 2018 are not leap. In this problem you are given n (1 ≤ n ≤ 24) integers a_1, a_2, ..., a_{n}, and you have to check if these integers could be durations in days of n consecutive months, according to Gregorian calendar. Note that these months could belong to several consecutive years. In other words, check if there is a month in some year, such that its duration is a_1 days, duration of the next month is a_2 days, and so on. -----Input----- The first line contains single integer n (1 ≤ n ≤ 24) — the number of integers. The second line contains n integers a_1, a_2, ..., a_{n} (28 ≤ a_{i} ≤ 31) — the numbers you are to check. -----Output----- If there are several consecutive months that fit the sequence, print "YES" (without quotes). Otherwise, print "NO" (without quotes). You can print each letter in arbitrary case (small or large). -----Examples----- Input 4 31 31 30 31 Output Yes Input 2 30 30 Output No Input 5 29 31 30 31 30 Output Yes Input 3 31 28 30 Output No Input 3 31 31 28 Output Yes -----Note----- In the first example the integers can denote months July, August, September and October. In the second example the answer is no, because there are no two consecutive months each having 30 days. In the third example the months are: February (leap year) — March — April – May — June. In the fourth example the number of days in the second month is 28, so this is February. March follows February and has 31 days, but not 30, so the answer is NO. In the fifth example the months are: December — January — February (non-leap year). Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0
{"tests": "{\"inputs\": [\"2\\n\", \"6\\n\", \"3\\n\", \"4\\n\", \"5\\n\", \"7\\n\", \"10895\\n\", \"16968\\n\", \"18438\\n\", \"9589\\n\", \"16705\\n\", \"2789\\n\", \"15821\\n\", \"96120064\\n\", \"49438110\\n\", \"32954134\\n\", \"71851857\\n\", \"6094109\\n\", \"77044770\\n\", \"58644781\\n\", \"792852058\\n\", \"208253300\\n\", \"584467493\\n\", \"967671675\\n\", \"381468071\\n\", \"539044761\\n\", \"672783194\\n\", \"1000000000\\n\", \"640603919\\n\", \"353407931\\n\", \"517920199\\n\", \"262759087\\n\", \"860452507\\n\", \"685518877\\n\", \"846706411\\n\", \"536870912\\n\", \"387420489\\n\", \"244140625\\n\", \"282475249\\n\", \"418195493\\n\", \"214358881\\n\", \"20151121\\n\", \"887503681\\n\", \"62742241\\n\", \"25411681\\n\", \"295943209\\n\", \"208466113\\n\", \"103756027\\n\", \"424759273\\n\", \"294390793\\n\", \"146521747\\n\", \"303427699\\n\", \"706815862\\n\", \"788277261\\n\", \"525518174\\n\", \"294053760\\n\", \"367567200\\n\", \"551350800\\n\", \"698377680\\n\", \"735134400\\n\", \"321197185\\n\", \"321197186\\n\"], \"outputs\": [\"NO\\n\", \"YES\\n2\\n1 2\\n1 3\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"YES\\n2\\n1 5\\n1743 2179\\n\", \"YES\\n2\\n7 8\\n265 2121\\n\", \"YES\\n2\\n1 2\\n4609 9219\\n\", \"YES\\n2\\n16 43\\n140 223\\n\", \"YES\\n2\\n4 5\\n668 3341\\n\", \"NO\\n\", \"YES\\n2\\n8 13\\n468 1217\\n\", \"YES\\n2\\n219 256\\n54267 375469\\n\", \"YES\\n2\\n1 2\\n12359527 24719055\\n\", \"YES\\n2\\n1 2\\n8238533 16477067\\n\", \"YES\\n2\\n1 3\\n15967079 23950619\\n\", \"YES\\n2\\n5 7\\n248739 870587\\n\", \"YES\\n2\\n1 2\\n19261192 38522385\\n\", \"YES\\n2\\n11 13\\n694021 4511137\\n\", \"YES\\n2\\n1 2\\n198213014 396426029\\n\", \"YES\\n2\\n3 4\\n13015831 52063325\\n\", \"YES\\n2\\n17 19\\n3238047 30761447\\n\", \"YES\\n2\\n1 9\\n95572511 107519075\\n\", \"NO\\n\", \"YES\\n2\\n2 3\\n59893862 179681587\\n\", \"YES\\n2\\n1 2\\n168195798 336391597\\n\", \"YES\\n2\\n403 512\\n415802 1953125\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"YES\\n2\\n6233 8443\\n6463 24691\\n\", \"YES\\n2\\n371 8443\\n11749 12289\\n\", \"YES\\n2\\n14986 17203\\n3182 24691\\n\", \"YES\\n2\\n7436 11923\\n9292 24691\\n\", \"YES\\n2\\n2769 11923\\n9435 12289\\n\", \"YES\\n2\\n435 12289\\n23817 24691\\n\", \"YES\\n2\\n1 2\\n176703965 353407931\\n\", \"YES\\n2\\n2 3\\n87586362 262759087\\n\", \"YES\\n2\\n1 2\\n131379543 262759087\\n\", \"YES\\n2\\n81 128\\n843538 2297295\\n\", \"YES\\n2\\n29 32\\n1076857 11486475\\n\", \"YES\\n2\\n15 16\\n2153714 34459425\\n\", \"YES\\n2\\n11 16\\n13640189 43648605\\n\", \"YES\\n2\\n29 64\\n6281666 11486475\\n\", \"YES\\n2\\n2 5\\n38543662 64239437\\n\", \"YES\\n2\\n1 2\\n80299296 160598593\\n\"]}", "source": "primeintellect"}
You are given a positive integer $n$. Find a sequence of fractions $\frac{a_i}{b_i}$, $i = 1 \ldots k$ (where $a_i$ and $b_i$ are positive integers) for some $k$ such that: $$ \begin{cases} \text{$b_i$ divides $n$, $1 < b_i < n$ for $i = 1 \ldots k$} \\ \text{$1 \le a_i < b_i$ for $i = 1 \ldots k$} \\ \text{$\sum\limits_{i=1}^k \frac{a_i}{b_i} = 1 - \frac{1}{n}$} \end{cases} $$ -----Input----- The input consists of a single integer $n$ ($2 \le n \le 10^9$). -----Output----- In the first line print "YES" if there exists such a sequence of fractions or "NO" otherwise. If there exists such a sequence, next lines should contain a description of the sequence in the following format. The second line should contain integer $k$ ($1 \le k \le 100\,000$) — the number of elements in the sequence. It is guaranteed that if such a sequence exists, then there exists a sequence of length at most $100\,000$. Next $k$ lines should contain fractions of the sequence with two integers $a_i$ and $b_i$ on each line. -----Examples----- Input 2 Output NO Input 6 Output YES 2 1 2 1 3 -----Note----- In the second example there is a sequence $\frac{1}{2}, \frac{1}{3}$ such that $\frac{1}{2} + \frac{1}{3} = 1 - \frac{1}{6}$. Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0
{"tests": "{\"inputs\": [\"4\\n5 7\\n3 3 4 1\\n\", \"3\\n2 3\\n1 3 1\\n\", \"3\\n3 3\\n2 2 2\\n\", \"6\\n12 3\\n1 4 1 4 1 4\\n\", \"5\\n10 7\\n1 2 3 1 3\\n\", \"5\\n4 8\\n1 1 1 2 2\\n\", \"6\\n10 11\\n1 1 12 1 1 1\\n\", \"9\\n5 24\\n1 6 1 6 1 6 1 6 1\\n\", \"10\\n10 13\\n2 3 4 4 2 3 1 4 4 2\\n\", \"20\\n13 10\\n1 4 3 2 5 4 5 4 5 1 1 2 4 5 4 4 2 4 2 4\\n\", \"100\\n7842 5229\\n55 33 28 70 76 63 88 78 64 49 98 8 86 39 18 61 100 70 42 45 62 75 76 93 25 92 51 76 35 70 35 55 88 83 99 15 64 39 39 91 81 17 52 93 48 41 61 59 60 89 2 68 36 49 46 26 72 25 46 50 15 35 74 50 1 47 52 55 61 29 97 33 76 35 81 17 74 97 91 86 10 6 72 66 39 14 91 55 46 31 96 16 88 82 87 39 7 5 91 27\\n\", \"200\\n163 20\\n3 2 1 1 2 1 2 1 2 2 2 1 1 2 2 2 1 2 2 1 3 2 2 1 1 3 3 1 1 1 3 3 1 2 2 3 1 2 3 3 2 1 3 2 1 1 3 3 3 3 2 1 2 1 1 2 3 1 3 2 1 2 2 3 3 1 3 1 2 3 2 3 1 3 2 3 3 2 1 1 2 2 3 3 3 1 2 1 1 2 1 1 2 3 3 3 2 3 1 2 1 1 1 1 3 3 2 1 1 2 3 2 2 2 2 2 3 1 3 1 1 1 1 1 1 3 3 3 3 3 3 2 2 3 2 2 1 1 3 2 3 1 1 1 1 3 2 2 1 1 3 1 2 2 2 3 3 1 3 1 3 2 1 2 2 2 3 3 1 2 2 3 3 2 1 3 1 3 2 1 3 3 3 1 2 3 1 3 1 1 1 3 2 2 1 1 1 3 3 1\\n\", \"200\\n170 213\\n1 8 7 2 3 5 1 7 2 2 4 2 5 5 1 1 2 1 2 4 9 8 1 4 3 3 3 2 5 4 3 9 4 8 5 8 1 7 1 8 8 6 1 6 8 2 3 2 5 8 1 3 1 7 8 9 8 8 2 9 1 4 6 8 5 7 2 8 9 2 1 6 8 8 3 9 3 9 8 3 5 1 7 1 2 1 9 9 3 2 5 4 2 8 3 5 3 3 5 7 7 9 4 5 6 9 4 5 9 2 6 4 6 9 1 7 9 7 4 4 1 5 5 2 3 1 6 8 4 2 6 3 7 8 4 4 7 2 5 4 6 1 3 6 9 4 1 1 4 7 4 6 8 9 9 6 1 5 3 5 8 3 6 5 8 8 9 5 2 1 6 4 6 4 7 3 2 9 4 7 1 5 2 9 8 9 8 1 8 8 9 4 8 3 6 1 9 2 5 8\\n\", \"100\\n445 1115\\n16 49 13 7 21 31 50 6 14 49 51 33 33 26 41 11 54 19 22 20 32 35 36 49 23 19 52 15 29 39 48 39 17 51 20 10 32 4 12 44 9 2 44 52 36 7 53 14 18 43 20 42 29 22 11 14 8 42 30 18 23 6 8 41 26 5 4 47 52 9 3 22 33 18 53 1 33 22 48 33 35 15 45 5 37 51 3 3 39 22 22 41 5 11 38 8 16 46 21 27\\n\", \"10\\n18 36\\n1 10 1 10 1 1 7 8 6 7\\n\", \"20\\n168 41\\n17 20 16 5 12 5 14 13 13 15 3 3 2 4 18 10 5 19 6 7\\n\", \"30\\n161 645\\n12 31 19 20 25 33 23 26 41 12 46 17 43 45 43 17 43 1 42 8 2 27 12 42 12 8 26 44 43 42\\n\", \"50\\n464 92\\n16 11 20 18 13 1 13 3 11 4 17 15 10 15 8 9 16 11 17 16 3 3 20 14 13 12 15 9 10 14 2 12 12 13 17 6 10 20 9 2 8 13 7 7 20 15 3 1 20 2\\n\", \"10\\n64 453\\n2 17 53 94 95 57 36 47 68 48\\n\", \"80\\n1115 2232\\n55 20 16 40 40 23 64 3 52 47 61 9 34 64 12 4 53 41 75 55 54 2 68 1 46 28 41 39 27 21 71 75 55 67 53 25 54 22 67 38 22 8 61 2 46 46 56 52 49 69 33 34 42 55 18 8 31 22 31 45 64 45 50 51 39 68 4 70 56 74 21 9 47 42 64 30 70 56 58 76\\n\", \"80\\n2148 2147\\n20 77 45 21 5 43 64 13 78 67 100 56 100 66 2 96 81 89 10 55 95 30 63 28 90 86 1 81 4 22 12 79 24 84 67 39 93 96 100 24 97 45 4 48 85 32 97 90 25 65 9 63 22 46 18 39 77 41 74 58 58 75 89 77 28 65 40 68 34 55 74 4 89 89 34 27 2 43 26 76\\n\", \"90\\n775 258\\n7 20 17 16 6 14 19 5 15 6 14 18 8 2 11 17 20 5 8 19 12 3 8 13 12 5 2 2 10 17 13 2 14 19 6 13 20 5 20 4 17 20 10 6 14 16 4 19 6 7 14 4 20 2 7 17 14 14 3 17 19 3 17 10 1 4 17 9 19 1 10 17 15 19 1 13 16 7 19 17 13 7 10 16 20 2 17 8 16 12\\n\", \"100\\n3641 1213\\n85 50 17 89 65 89 5 20 86 26 16 21 85 14 44 31 87 31 6 2 48 67 8 80 79 1 48 36 97 1 5 30 79 50 78 12 2 55 76 100 54 40 26 81 97 96 68 56 87 14 51 17 54 37 52 33 69 62 38 63 74 15 62 78 9 19 67 2 60 58 93 60 18 96 55 48 34 7 79 82 32 58 90 67 20 50 27 15 7 89 98 10 11 15 99 49 4 51 77 52\\n\", \"99\\n4398 628\\n36 86 61 77 19 53 39 34 70 69 100 86 85 32 59 62 16 13 29 4 43 83 74 5 32 9 97 25 62 58 38 67 37 96 52 74 50 98 35 56 18 100 92 80 24 11 94 57 17 15 56 15 16 95 69 87 72 20 14 12 51 40 100 29 94 18 41 11 29 96 1 2 58 51 42 80 27 51 58 95 21 34 94 93 97 35 70 80 31 65 13 69 55 18 31 50 26 10 75\\n\", \"100\\n3761 1253\\n69 46 76 47 71 9 66 46 78 17 96 83 56 96 29 3 43 48 79 23 93 61 19 9 29 72 15 84 93 46 71 87 11 43 96 44 54 75 3 66 2 95 46 32 69 52 79 38 57 53 37 60 71 82 28 31 84 58 89 40 62 74 22 50 45 38 99 67 24 28 28 12 69 88 33 10 31 71 46 7 42 81 54 81 96 44 8 1 20 24 28 19 54 35 69 32 71 13 66 15\\n\", \"100\\n48 97\\n1 2 2 1 2 1 1 2 1 1 1 2 2 1 1 1 2 2 2 1 2 1 1 1 1 1 2 1 2 1 2 1 2 1 2 1 1 1 2 1 1 1 1 1 2 2 1 2 1 2 1 2 2 2 1 2 1 2 2 1 1 2 2 1 1 2 2 2 1 1 2 1 1 2 2 1 2 1 1 2 2 1 2 1 1 2 2 1 1 1 1 2 1 1 1 1 2 2 2 2\\n\", \"13\\n318 317\\n46 55 50 50 76 53 5 33 24 75 59 28 80\\n\", \"1\\n4 3\\n6\\n\", \"2\\n37 5\\n13 27\\n\", \"100\\n51 50\\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\\n\", \"40\\n227 37\\n12 3 4 6 2 4 6 2 10 2 6 1 7 11 7 13 7 12 10 9 1 12 3 6 4 8 6 7 6 5 11 3 8 11 13 3 2 6 11 4\\n\", \"30\\n30 600\\n1 40 1 40 1 40 1 40 1 40 1 40 1 40 1 40 1 40 1 40 1 40 1 40 1 40 1 40 1 40\\n\", \"15\\n199 33\\n3 27 15 9 16 9 16 23 21 5 20 21 26 12 8\\n\", \"7\\n94 15\\n25 3 17 8 28 7 21\\n\", \"98\\n4119 823\\n89 30 25 49 46 2 50 89 65 59 95 44 45 59 30 59 64 23 73 43 86 93 71 47 25 5 18 5 91 88 64 93 36 74 28 55 92 13 36 62 40 73 36 45 12 1 6 53 59 86 93 34 79 68 10 53 31 63 55 84 39 88 70 95 76 5 95 8 24 67 85 44 52 5 23 51 16 11 83 40 93 95 30 22 21 4 64 37 76 46 70 39 95 5 44 24 77 19\\n\", \"82\\n2521 1260\\n16 49 45 3 16 76 75 15 8 77 68 66 3 90 3 25 42 21 82 78 81 65 31 84 55 66 30 8 43 75 5 11 50 6 50 6 13 37 24 69 47 25 85 57 86 70 31 2 52 50 88 37 6 51 72 30 73 64 32 70 66 51 76 13 6 63 72 48 86 90 71 88 5 11 53 28 5 73 55 57 34 33\\n\", \"81\\n2024 2025\\n7 25 42 9 91 66 44 61 77 24 58 71 37 88 91 39 86 59 31 27 29 81 62 25 65 69 62 49 19 29 76 45 77 25 63 17 53 17 89 93 56 57 71 72 17 63 62 68 65 40 30 95 86 56 16 29 70 41 73 32 82 16 7 2 5 93 80 87 21 25 23 14 62 71 25 78 43 69 25 27 15\\n\", \"100\\n1546 3093\\n28 2 85 37 14 59 71 51 89 7 50 19 21 38 19 40 40 14 86 59 24 21 40 1 13 58 71 87 16 15 54 58 36 1 45 68 48 62 43 3 6 32 90 86 21 85 31 79 40 39 75 64 26 72 77 3 76 62 30 8 20 55 66 44 10 3 52 46 7 10 53 31 59 73 84 76 22 57 80 68 26 51 7 76 7 71 89 77 34 90 60 54 41 76 68 68 73 42 53 64\\n\", \"100\\n3623 905\\n24 76 11 6 14 72 42 23 37 78 32 21 12 39 71 35 30 73 5 62 19 4 91 63 80 71 33 25 11 36 47 8 88 12 3 46 84 49 20 21 68 6 63 32 3 49 86 51 82 48 93 27 12 60 22 90 54 64 39 38 78 62 21 59 84 44 60 28 58 43 51 22 23 20 21 36 85 47 65 53 33 14 43 79 42 34 51 48 68 57 84 22 14 88 26 41 40 59 84 79\\n\", \"1\\n0 0\\n1\\n\", \"5\\n3 15\\n1 2 3 4 5\\n\", \"80\\n808 2427\\n25 29 70 24 40 25 57 39 74 62 77 65 61 72 21 65 62 58 58 71 39 55 71 19 16 36 35 53 57 30 8 14 66 42 23 52 56 37 13 73 77 33 23 36 70 1 56 13 23 11 67 2 33 9 54 48 49 16 64 1 16 19 57 35 29 12 71 19 22 66 61 11 39 34 9 36 77 20 62 3\\n\", \"87\\n1015 3046\\n57 20 1 87 38 31 33 20 52 82 81 40 2 64 55 72 16 14 42 57 24 75 51 92 86 51 83 83 70 30 61 64 45 15 22 90 54 10 62 16 70 1 35 88 83 72 11 80 20 35 12 33 22 55 78 19 7 31 37 75 14 2 5 30 28 48 79 1 81 68 66 30 56 88 72 13 87 27 73 35 78 64 33 2 21 85 63\\n\", \"62\\n1670 278\\n25 47 6 43 38 45 31 16 46 44 20 58 33 54 12 33 38 29 26 8 24 48 34 46 22 10 2 39 43 34 7 50 46 11 41 31 23 57 21 34 19 27 47 35 30 1 4 8 21 22 59 9 33 20 48 5 55 52 55 51 49 21\\n\", \"94\\n0 3698\\n3 15 49 63 19 63 38 54 44 72 12 24 73 42 45 58 18 3 78 29 8 6 75 11 38 4 77 26 64 37 53 6 36 77 48 24 61 25 66 51 13 17 45 35 80 6 57 78 77 2 59 68 54 60 48 33 52 67 64 71 13 16 13 23 16 54 51 70 22 35 23 9 32 14 10 44 61 8 53 4 66 29 28 2 33 2 61 32 53 54 80 3 50 51\\n\", \"81\\n0 4090\\n46 90 45 77 84 55 93 16 41 57 46 96 55 25 34 1 96 44 42 74 78 70 10 60 67 83 57 47 5 14 18 98 10 59 71 16 3 6 43 2 77 95 96 94 87 76 12 76 97 66 77 51 19 49 5 44 29 63 8 33 44 25 94 48 13 61 90 65 6 3 45 68 68 53 62 13 10 83 45 89 15\\n\", \"100\\n3777 5935\\n36 91 57 68 29 61 68 93 97 17 43 72 65 57 74 5 61 74 83 50 47 91 44 84 100 87 33 90 44 71 81 5 89 25 69 6 73 90 13 17 67 97 24 47 5 28 84 80 61 21 47 74 87 11 99 36 36 16 94 11 33 77 85 96 80 34 97 43 69 65 33 73 2 3 49 90 11 86 38 51 59 15 70 93 68 25 40 56 34 48 22 96 100 42 49 47 84 53 44 4\\n\", \"100\\n864 2595\\n66 9 37 32 5 12 33 18 57 59 45 6 50 48 40 13 46 38 2 44 24 53 58 32 54 52 36 36 48 29 44 21 59 24 20 26 46 11 21 51 31 63 3 54 14 57 40 5 16 49 68 32 9 18 27 61 63 8 13 50 36 32 16 28 7 31 1 4 55 27 68 24 18 63 66 61 14 63 14 35 47 29 52 51 19 1 43 12 23 45 32 43 33 1 39 63 8 64 41 64\\n\", \"100\\n816 4082\\n27 73 74 36 2 63 5 22 30 48 60 4 76 17 81 88 72 64 57 82 41 69 78 7 64 47 13 45 76 5 66 31 83 84 76 19 14 54 74 65 76 52 54 63 42 27 46 41 74 13 26 16 57 84 43 31 65 73 42 29 71 75 23 16 50 43 12 5 78 84 74 52 87 76 81 29 44 53 52 38 31 75 20 43 40 68 52 81 21 10 39 56 27 62 16 32 62 69 24 80\\n\", \"104\\n7940 1985\\n63 49 147 71 164 111 47 85 162 103 138 151 162 146 53 78 32 125 168 7 107 48 17 38 41 144 68 27 42 60 30 103 102 100 37 85 123 170 110 167 158 123 89 136 60 33 99 126 65 34 98 91 66 155 111 158 23 139 154 129 89 30 27 145 74 135 114 120 94 65 156 26 1 48 121 122 7 142 137 160 82 119 156 149 132 147 146 66 122 65 153 8 168 140 47 95 147 19 127 39 145 37 42 33\\n\", \"116\\n2784 5569\\n83 129 137 8 73 132 142 5 119 131 15 46 49 3 26 10 33 120 45 49 14 62 104 12 140 53 42 42 39 135 138 132 51 21 90 102 57 143 13 131 116 97 84 148 111 56 77 45 109 137 83 146 3 122 10 26 121 4 49 6 24 25 79 38 1 69 122 81 144 75 130 147 92 2 92 130 143 56 120 130 38 7 5 23 27 144 18 84 102 83 101 137 21 115 94 32 40 5 127 144 17 116 54 79 121 68 11 44 31 56 47 97 54 36 33 16\\n\", \"118\\n8850 1770\\n97 19 137 20 92 16 145 35 2 86 4 83 147 135 125 7 145 84 142 124 14 91 169 132 149 117 67 41 137 132 91 34 162 70 92 75 73 24 6 143 24 12 149 48 107 82 146 119 107 174 166 103 42 31 70 142 156 25 153 159 116 108 151 21 156 43 38 85 68 2 107 16 163 179 92 150 48 52 85 115 37 186 82 94 67 170 66 20 132 72 111 1 95 183 135 23 3 138 103 104 127 178 27 116 111 89 60 12 61 75 112 100 101 36 185 25 105 4\\n\", \"50\\n4433 738\\n56 144 164 58 163 145 58 55 110 16 3 114 105 108 148 70 135 156 170 179 112 174 37 105 154 142 62 101 9 169 108 51 8 98 159 115 19 145 189 61 22 129 39 167 155 83 138 152 5 106\\n\", \"66\\n866 4330\\n57 76 22 84 136 70 43 92 84 32 59 88 94 74 79 80 24 60 125 63 96 90 91 32 117 107 95 43 48 69 5 72 36 107 95 106 95 135 62 132 70 47 104 47 52 43 71 18 123 101 80 64 48 103 136 77 123 136 41 113 28 63 99 130 79 125\\n\", \"67\\n394 2762\\n55 32 78 68 71 12 26 47 8 78 7 94 68 33 17 54 56 15 38 46 34 59 38 26 19 22 28 67 31 1 27 47 40 39 34 86 25 53 43 39 66 79 86 22 51 22 25 74 75 58 12 83 47 80 47 96 2 65 89 96 69 97 55 39 34 18 6\\n\", \"23\\n135 678\\n53 28 25 21 57 5 65 43 38 27 29 33 5 46 54 57 51 58 43 47 14 1 11\\n\", \"29\\n971 161\\n77 11 26 70 61 33 66 62 67 73 4 62 43 66 41 74 25 11 6 51 34 13 15 25 33 39 3 32 9\\n\", \"10\\n90 360\\n61 42 69 7 17 71 81 8 18 74\\n\", \"22\\n254 127\\n20 14 12 5 34 7 12 1 8 11 5 24 4 28 24 29 27 29 34 36 11 6\\n\", \"22\\n1248 1249\\n181 59 97 191 44 15 154 37 139 181 2 197 50 186 174 17 186 33 122 146 89 197\\n\", \"104\\n1207 8449\\n166 188 60 126 30 86 52 151 37 5 48 169 169 14 191 69 69 166 155 33 191 35 116 71 137 38 62 147 27 149 124 158 54 198 176 164 83 25 23 75 36 105 19 19 96 2 49 92 79 37 98 64 27 36 106 169 62 90 197 144 111 198 116 157 11 174 129 53 16 102 184 13 68 167 50 166 64 154 40 118 159 37 56 40 139 17 76 140 193 185 136 18 161 13 57 18 141 2 12 99 101 72 8 121\\n\", \"36\\n2704 386\\n46 38 91 15 75 158 113 125 194 123 67 6 138 34 82 8 72 122 79 1 105 74 18 3 149 176 119 24 14 131 67 137 64 74 178 168\\n\"], \"outputs\": [\"3\\n\", \"2\\n\", \"-1\\n\", \"5\\n\", \"0\\n\", \"0\\n\", \"-1\\n\", \"8\\n\", \"-1\\n\", \"-1\\n\", \"0\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"7\\n\", \"7\\n\", \"28\\n\", \"3\\n\", \"102\\n\", \"14\\n\", \"15\\n\", \"4\\n\", \"15\\n\", \"25\\n\", \"15\\n\", \"1\\n\", \"80\\n\", \"-1\\n\", \"-1\\n\", \"1\\n\", \"2\\n\", \"29\\n\", \"26\\n\", \"30\\n\", \"18\\n\", \"14\\n\", \"49\\n\", \"16\\n\", \"24\\n\", \"-1\\n\", \"0\\n\", \"17\\n\", \"13\\n\", \"21\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"13\\n\", \"27\\n\", \"70\\n\", \"17\\n\", \"30\\n\", \"57\\n\", \"99\\n\", \"14\\n\", \"33\\n\", \"32\\n\", \"48\\n\", \"15\\n\", \"108\\n\", \"41\\n\", \"35\\n\"]}", "source": "primeintellect"}
Vasya should paint a fence in front of his own cottage. The fence is a sequence of n wooden boards arranged in a single row. Each board is a 1 centimeter wide rectangle. Let's number the board fence using numbers 1, 2, ..., n from left to right. The height of the i-th board is h_{i} centimeters. Vasya has a 1 centimeter wide brush and the paint of two colors, red and green. Of course, the amount of the paint is limited. Vasya counted the area he can paint each of the colors. It turned out that he can not paint over a square centimeters of the fence red, and he can not paint over b square centimeters green. Each board of the fence should be painted exactly one of the two colors. Perhaps Vasya won't need one of the colors. In addition, Vasya wants his fence to look smart. To do this, he should paint the fence so as to minimize the value that Vasya called the fence unattractiveness value. Vasya believes that two consecutive fence boards, painted different colors, look unattractive. The unattractiveness value of a fence is the total length of contact between the neighboring boards of various colors. To make the fence look nice, you need to minimize the value as low as possible. Your task is to find what is the minimum unattractiveness Vasya can get, if he paints his fence completely. $1$ The picture shows the fence, where the heights of boards (from left to right) are 2,3,2,4,3,1. The first and the fifth boards are painted red, the others are painted green. The first and the second boards have contact length 2, the fourth and fifth boards have contact length 3, the fifth and the sixth have contact length 1. Therefore, the unattractiveness of the given painted fence is 2+3+1=6. -----Input----- The first line contains a single integer n (1 ≤ n ≤ 200) — the number of boards in Vasya's fence. The second line contains two integers a and b (0 ≤ a, b ≤ 4·10^4) — the area that can be painted red and the area that can be painted green, correspondingly. The third line contains a sequence of n integers h_1, h_2, ..., h_{n} (1 ≤ h_{i} ≤ 200) — the heights of the fence boards. All numbers in the lines are separated by single spaces. -----Output----- Print a single number — the minimum unattractiveness value Vasya can get if he paints his fence completely. If it is impossible to do, print - 1. -----Examples----- Input 4 5 7 3 3 4 1 Output 3 Input 3 2 3 1 3 1 Output 2 Input 3 3 3 2 2 2 Output -1 Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0.125
{"tests": "{\"inputs\": [\"4 3 3\\n\", \"4 4 7\\n\", \"3 4 2\\n\", \"3 4 3\\n\", \"3 4 12\\n\", \"16904235 79092881 127345237\\n\", \"1000000000 999999937 1024\\n\", \"229999981 1000000000 2048\\n\", \"1 1 2\\n\", \"1000000000 1000000000 2\\n\", \"799999999 217041223 5865979\\n\", \"899999963 558436066 279988\\n\", \"217041223 799999999 5865979\\n\", \"311 2886317 897644587\\n\", \"1 156483121 156483121\\n\", \"237349317 1 237349317\\n\", \"1747211 283 494460713\\n\", \"8824 785 2\\n\", \"4422 1826 3\\n\", \"4354 3801 181\\n\", \"13 51 298401051\\n\", \"2 19 182343418\\n\", \"1 361 656220385\\n\", \"4 16 540162752\\n\", \"69 4761 424105119\\n\", \"45418 13277 603014786\\n\", \"10267 1 781924453\\n\", \"186860 5142 960834120\\n\", \"22207 109 844776487\\n\", \"49435 13164 650762340\\n\", \"1 19 534704707\\n\", \"1 58 418647074\\n\", \"1 1 892524041\\n\", \"3 2344 776466408\\n\", \"185 5 955376075\\n\", \"1 1 612615929\\n\", \"13903 56932 791525596\\n\", \"1869 1 970435263\\n\", \"302 5 854377630\\n\", \"6 11 33287298\\n\", \"1 6 212196966\\n\", \"1 23 96139333\\n\", \"1 2 614160842\\n\", \"339 3 498103209\\n\", \"4 1 677012876\\n\", \"3 1 560955243\\n\", \"1 3 34832211\\n\", \"71 7 918774577\\n\", \"8 2 802716944\\n\", \"974654615 59871038 562\\n\", \"568435169 488195690 755\\n\", \"307439915 61744535 511\\n\", \"887669087 755467202 3\\n\", \"626673832 329016046 38\\n\", \"925487090 902564890 70\\n\", \"236887699 1000000000 2\\n\", \"3 5 30\\n\", \"99999989 999999937 2\\n\", \"9 2 3\\n\", \"62 14 8\\n\", \"2 2 8\\n\", \"1200 143143 336\\n\"], \"outputs\": [\"YES\\n0 0\\n0 2\\n4 0\\n\", \"NO\\n\", \"YES\\n0 0\\n0 4\\n3 0\\n\", \"YES\\n0 0\\n0 4\\n2 0\\n\", \"YES\\n0 0\\n0 2\\n1 0\\n\", \"YES\\n0 0\\n0 699937\\n30 0\\n\", \"YES\\n0 0\\n0 999999937\\n1953125 0\\n\", \"NO\\n\", \"YES\\n0 0\\n0 1\\n1 0\\n\", \"YES\\n0 0\\n0 1000000000\\n1000000000 0\\n\", \"YES\\n0 0\\n0 74\\n799999999 0\\n\", \"YES\\n0 0\\n0 3989\\n899999963 0\\n\", \"YES\\n0 0\\n0 799999999\\n74 0\\n\", \"YES\\n0 0\\n0 1\\n2 0\\n\", \"YES\\n0 0\\n0 2\\n1 0\\n\", \"YES\\n0 0\\n0 1\\n2 0\\n\", \"YES\\n0 0\\n0 1\\n2 0\\n\", \"YES\\n0 0\\n0 785\\n8824 0\\n\", \"YES\\n0 0\\n0 1826\\n2948 0\\n\", \"YES\\n0 0\\n0 42\\n4354 0\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"YES\\n0 0\\n0 1\\n2 0\\n\", \"NO\\n\", \"YES\\n0 0\\n0 2\\n1 0\\n\", \"NO\\n\", \"YES\\n0 0\\n0 2\\n1 0\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"YES\\n0 0\\n0 2\\n1 0\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"YES\\n0 0\\n0 17316634\\n626673832 0\\n\", \"NO\\n\", \"YES\\n0 0\\n0 1000000000\\n236887699 0\\n\", \"YES\\n0 0\\n0 1\\n1 0\\n\", \"YES\\n0 0\\n0 999999937\\n99999989 0\\n\", \"YES\\n0 0\\n0 2\\n6 0\\n\", \"YES\\n0 0\\n0 7\\n31 0\\n\", \"YES\\n0 0\\n0 1\\n1 0\\n\", \"YES\\n0 0\\n0 20449\\n50 0\\n\"]}", "source": "primeintellect"}
Vasya has got three integers $n$, $m$ and $k$. He'd like to find three integer points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$, such that $0 \le x_1, x_2, x_3 \le n$, $0 \le y_1, y_2, y_3 \le m$ and the area of the triangle formed by these points is equal to $\frac{nm}{k}$. Help Vasya! Find such points (if it's possible). If there are multiple solutions, print any of them. -----Input----- The single line contains three integers $n$, $m$, $k$ ($1\le n, m \le 10^9$, $2 \le k \le 10^9$). -----Output----- If there are no such points, print "NO". Otherwise print "YES" in the first line. The next three lines should contain integers $x_i, y_i$ — coordinates of the points, one point per line. If there are multiple solutions, print any of them. You can print each letter in any case (upper or lower). -----Examples----- Input 4 3 3 Output YES 1 0 2 3 4 1 Input 4 4 7 Output NO -----Note----- In the first example area of the triangle should be equal to $\frac{nm}{k} = 4$. The triangle mentioned in the output is pictured below: [Image] In the second example there is no triangle with area $\frac{nm}{k} = \frac{16}{7}$. Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0
{"tests": "{\"inputs\": [\"2 4\\n\", \"1 3\\n\", \"8 5\\n\", \"0 0\\n\", \"1 1\\n\", \"5 8\\n\", \"0 10\\n\", \"0 1\\n\", \"10 2\\n\", \"38795264078389352 381146357267900812\\n\", \"289719432793352230 735866345619386710\\n\", \"432666984839714080 440710284985952692\\n\", \"78250495401599104 155124107471631150\\n\", \"104665012166857792 976183227639207028\\n\", \"216225752073924647 810168351641272615\\n\", \"293940563294568706 438904680704414994\\n\", \"235470417020619915 308266943609253107\\n\", \"293341698588646512 496573494755010944\\n\", \"705450082349979461 755311110516647561\\n\", \"297364533143758810 472596515119019550\\n\", \"247970080241541989 808225497994435575\\n\", \"117123211753443326 744169331802580326\\n\", \"217282410437604880 460155962367260448\\n\", \"659416161540338013 793205918385085997\\n\", \"96021440171939377 647083697349695499\\n\", \"288230376151711743 576460752303423485\\n\", \"288230376151711744 864691128455135232\\n\", \"0 576460752303423488\\n\", \"0 1000000000000000000\\n\", \"1000000000000000000 1000000000000000000\\n\", \"16714672462274 231322522212\\n\", \"999999999999999999 1000000000000000000\\n\", \"742044456693272852 905581766057209382\\n\", \"118951810196310661 119659802361556245\\n\", \"740993906271323148 967511581620345260\\n\", \"759043763661311444 805778668098104870\\n\", \"193655197401686113 196202826827120009\\n\", \"130623142136776194 133170025264297522\\n\", \"432981670644947524 563665833504433496\\n\", \"68055407164478484 937373174342195558\\n\", \"27025996623314964 253544043262273190\\n\", \"1511211343071260 7493697601090076\\n\", \"297432954811859201 516024771401584985\\n\", \"31605485653926165 38937599617545689\\n\", \"59747581891571716 348880966461814244\\n\", \"160034479758380420 989965647617356312\\n\", \"490420388887506226 651415492270871218\\n\", \"312045112624037256 934323258556088276\\n\", \"745585109855064297 894399607569809353\\n\", \"193587332009244033 258506286098056787\\n\", \"55168310369541854 865861741843885420\\n\", \"330824273487261943 906896417544075361\\n\", \"4664324082316783 920867280092197783\\n\", \"9741471907681019 176713193164232415\\n\", \"137260320016953256 587594061159025476\\n\", \"221689123160051222 388276998624989142\\n\", \"43027423184281380 743312518754687818\\n\", \"131315934729547724 719918032618420732\\n\", \"441562547952882888 602152751139035248\\n\", \"225480223106384657 702333086973909255\\n\", \"346354 31423874927\\n\"], \"outputs\": [\"2\\n3 1\", \"3\\n1 1 1\", \"-1\", \"0\", \"1\\n1\", \"-1\", \"2\\n5 5\", \"-1\", \"-1\", \"2\\n209970810673145082 171175546594755730\", \"2\\n512792889206369470 223073456413017240\", \"2\\n436688634912833386 4021650073119306\", \"2\\n116687301436615127 38436806035016023\", \"2\\n540424119903032410 435759107736174618\", \"2\\n513197051857598631 296971299783673984\", \"2\\n366422621999491850 72482058704923144\", \"2\\n271868680314936511 36398263294316596\", \"3\\n293341698588646512 101615898083182216 101615898083182216\", \"3\\n705450082349979461 24930514083334050 24930514083334050\", \"3\\n297364533143758810 87615990987630370 87615990987630370\", \"3\\n247970080241541989 280127708876446793 280127708876446793\", \"3\\n117123211753443326 313523060024568500 313523060024568500\", \"3\\n217282410437604880 121436775964827784 121436775964827784\", \"3\\n659416161540338013 66894878422373992 66894878422373992\", \"3\\n96021440171939377 275531128588878061 275531128588878061\", \"3\\n288230376151711743 144115188075855871 144115188075855871\", \"3\\n288230376151711744 288230376151711744 288230376151711744\", \"2\\n288230376151711744 288230376151711744\", \"2\\n500000000000000000 500000000000000000\", \"1\\n1000000000000000000\", \"-1\", \"-1\", \"2\\n823813111375241117 81768654681968265\", \"2\\n119305806278933453 353996082622792\", \"2\\n854252743945834204 113258837674511056\", \"2\\n782411215879708157 23367452218396713\", \"2\\n194929012114403061 1273814712716948\", \"2\\n131896583700536858 1273441563760664\", \"2\\n498323752074690510 65342081429742986\", \"2\\n502714290753337021 434658883588858537\", \"2\\n140285019942794077 113259023319479113\", \"2\\n4502454472080668 2991243129009408\", \"2\\n406728863106722093 109295908294862892\", \"2\\n35271542635735927 3666056981809762\", \"2\\n204314274176692980 144566692285121264\", \"2\\n575000063687868366 414965583929487946\", \"3\\n490420388887506226 80497551691682496 80497551691682496\", \"3\\n312045112624037256 311139072966025510 311139072966025510\", \"3\\n745585109855064297 74407248857372528 74407248857372528\", \"3\\n193587332009244033 32459477044406377 32459477044406377\", \"3\\n55168310369541854 405346715737171783 405346715737171783\", \"3\\n330824273487261943 288036072028406709 288036072028406709\", \"3\\n4664324082316783 458101478004940500 458101478004940500\", \"3\\n9741471907681019 83485860628275698 83485860628275698\", \"3\\n137260320016953256 225166870571036110 225166870571036110\", \"3\\n221689123160051222 83293937732468960 83293937732468960\", \"3\\n43027423184281380 350142547785203219 350142547785203219\", \"3\\n131315934729547724 294301048944436504 294301048944436504\", \"3\\n441562547952882888 80295101593076180 80295101593076180\", \"3\\n225480223106384657 238426431933762299 238426431933762299\", \"-1\"]}", "source": "primeintellect"}
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$. -----Input----- The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$. -----Output----- If there's no array that satisfies the condition, print "-1". Otherwise: The first line should contain one integer, $n$, representing the length of the desired array. The next line should contain $n$ positive integers, the array itself. If there are multiple possible answers, print any. -----Examples----- Input 2 4 Output 2 3 1 Input 1 3 Output 3 1 1 1 Input 8 5 Output -1 Input 0 0 Output 0 -----Note----- In the first sample, $3\oplus 1 = 2$ and $3 + 1 = 4$. There is no valid array of smaller length. Notice that in the fourth sample the array is empty. Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0
{"tests": "{\"inputs\": [\"121\\n\", \"10\\n\", \"72\\n\", \"1\\n\", \"2\\n\", \"3\\n\", \"4\\n\", \"5\\n\", \"6\\n\", \"7\\n\", \"11\\n\", \"12\\n\", \"2038946593\\n\", \"81924761239462\\n\", \"973546235465729\\n\", \"999999999999999\\n\", \"21\\n\", \"79\\n\", \"33\\n\", \"185\\n\", \"513\\n\", \"634\\n\", \"5300\\n\", \"3724\\n\", \"2148\\n\", \"82415\\n\", \"35839\\n\", \"79263\\n\", \"274634\\n\", \"690762\\n\", \"374186\\n\", \"2673749\\n\", \"5789877\\n\", \"1873301\\n\", \"30272863\\n\", \"33388991\\n\", \"11472415\\n\", \"345871978\\n\", \"528988106\\n\", \"302038826\\n\", \"1460626450\\n\", \"3933677170\\n\", \"6816793298\\n\", \"75551192860\\n\", \"28729276284\\n\", \"67612392412\\n\", \"532346791975\\n\", \"575524875399\\n\", \"614407991527\\n\", \"2835997166898\\n\", \"1079175250322\\n\", \"8322353333746\\n\", \"26602792766013\\n\", \"42845970849437\\n\", \"59089148932861\\n\", \"842369588365127\\n\", \"768617061415848\\n\", \"694855944531976\\n\", \"898453513288965\\n\", \"98596326741327\\n\", \"59191919191919\\n\"], \"outputs\": [\"6\\n\", \"3\\n\", \"15\\n\", \"1\\n\", \"2\\n\", \"3\\n\", \"4\\n\", \"5\\n\", \"6\\n\", \"6\\n\", \"2\\n\", \"3\\n\", \"145\\n\", \"321\\n\", \"263\\n\", \"32\\n\", \"5\\n\", \"10\\n\", \"6\\n\", \"16\\n\", \"25\\n\", \"22\\n\", \"32\\n\", \"34\\n\", \"21\\n\", \"53\\n\", \"45\\n\", \"45\\n\", \"62\\n\", \"65\\n\", \"65\\n\", \"81\\n\", \"61\\n\", \"59\\n\", \"118\\n\", \"57\\n\", \"72\\n\", \"95\\n\", \"118\\n\", \"128\\n\", \"152\\n\", \"159\\n\", \"153\\n\", \"151\\n\", \"212\\n\", \"178\\n\", \"158\\n\", \"189\\n\", \"236\\n\", \"275\\n\", \"188\\n\", \"169\\n\", \"288\\n\", \"325\\n\", \"265\\n\", \"330\\n\", \"390\\n\", \"348\\n\", \"248\\n\", \"260\\n\", \"342\\n\"]}", "source": "primeintellect"}
Prof. Vasechkin wants to represent positive integer n as a sum of addends, where each addends is an integer number containing only 1s. For example, he can represent 121 as 121=111+11+–1. Help him to find the least number of digits 1 in such sum. -----Input----- The first line of the input contains integer n (1 ≤ n < 10^15). -----Output----- Print expected minimal number of digits 1. -----Examples----- Input 121 Output 6 Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0
{"tests": "{\"inputs\": [\"97\\n\", \"2028\\n\", \"1\\n\", \"10\\n\", \"168\\n\", \"999999\\n\", \"987654320023456789\\n\", \"1000000000000000000\\n\", \"74774\\n\", \"2\\n\", \"3\\n\", \"4\\n\", \"5\\n\", \"6\\n\", \"7\\n\", \"8\\n\", \"9\\n\", \"101010101\\n\", \"1010101010\\n\", \"707070707070707070\\n\", \"19293\\n\", \"987650\\n\", \"123456\\n\", \"900008\\n\", \"1000000\\n\", \"9900111\\n\", \"11112222\\n\", \"88888880\\n\", \"100000009\\n\", \"203456799\\n\", \"890009800\\n\", \"900000000\\n\", \"987654321\\n\", \"999999999\\n\", \"1000000000\\n\", \"999999999999999999\\n\", \"987654321123456789\\n\", \"987654321123456780\\n\", \"888888888888888888\\n\", \"888884444444448888\\n\", \"880000000008888888\\n\", \"122661170586643693\\n\", \"166187867387753706\\n\", \"54405428089931205\\n\", \"96517150587709082\\n\", \"234906817379759421\\n\", \"470038695054731020\\n\", \"888413836884649324\\n\", \"978691308972024154\\n\", \"484211136976275613\\n\", \"824250067279351651\\n\", \"269041787841325833\\n\", \"462534182594129378\\n\", \"79318880250640214\\n\", \"58577142509378476\\n\", \"973088698775609061\\n\", \"529916324588161451\\n\", \"406105326393716536\\n\", \"490977896148785607\\n\", \"547694365350162078\\n\", \"868572419889505545\\n\"], \"outputs\": [\"2\\n\", \"13\\n\", \"1\\n\", \"1\\n\", \"6\\n\", \"6\\n\", \"29340299842560\\n\", \"18\\n\", \"28\\n\", \"1\\n\", \"1\\n\", \"1\\n\", \"1\\n\", \"1\\n\", \"1\\n\", \"1\\n\", \"1\\n\", \"246\\n\", \"456\\n\", \"92368\\n\", \"84\\n\", \"600\\n\", \"720\\n\", \"28\\n\", \"6\\n\", \"404\\n\", \"242\\n\", \"28\\n\", \"70\\n\", \"196560\\n\", \"1120\\n\", \"8\\n\", \"362880\\n\", \"9\\n\", \"9\\n\", \"18\\n\", \"33007837322880\\n\", \"55657759288320\\n\", \"18\\n\", \"184736\\n\", \"92368\\n\", \"4205605773600\\n\", \"224244425700\\n\", \"417074011200\\n\", \"417074011200\\n\", \"22773236965920\\n\", \"5099960335680\\n\", \"76835760120\\n\", \"33638772575520\\n\", \"6471643862880\\n\", \"21519859273920\\n\", \"22773236965920\\n\", \"13498126800480\\n\", \"2075276790720\\n\", \"1126629393120\\n\", \"1646603038080\\n\", \"3614537707200\\n\", \"2760291011520\\n\", \"2054415328560\\n\", \"21519859273920\\n\", \"1124978369760\\n\"]}", "source": "primeintellect"}
This night wasn't easy on Vasya. His favorite team lost, and he didn't find himself victorious either — although he played perfectly, his teammates let him down every time. He had to win at least one more time, but the losestreak only grew longer and longer... It's no wonder he didn't get any sleep this night at all. In the morning, Vasya was waiting the bus to the university on the bus stop. Vasya's thoughts were hazy and so he couldn't remember the right bus' number quite right and got onto the bus with the number $n$. In the bus, Vasya thought that he could get the order of the digits in the number of the bus wrong. Futhermore, he could "see" some digits several times, but the digits he saw were definitely in the real number of the bus. For example, if Vasya saw the number 2028, it could mean that the real bus number could be 2028, 8022, 2820 or just 820. However, numbers 80, 22208, 52 definitely couldn't be the number of the bus. Also, real bus number couldn't start with the digit 0, this meaning that, for example, number 082 couldn't be the real bus number too. Given $n$, determine the total number of possible bus number variants. -----Input----- The first line contains one integer $n$ ($1 \leq n \leq 10^{18}$) — the number of the bus that was seen by Vasya. It is guaranteed that this number does not start with $0$. -----Output----- Output a single integer — the amount of possible variants of the real bus number. -----Examples----- Input 97 Output 2 Input 2028 Output 13 -----Note----- In the first sample, only variants $97$ and $79$ are possible. In the second sample, the variants (in the increasing order) are the following: $208$, $280$, $802$, $820$, $2028$, $2082$, $2208$, $2280$, $2802$, $2820$, $8022$, $8202$, $8220$. Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0
{"tests": "{\"inputs\": [\"6 4 3 1\\n\", \"9 3 8 10\\n\", \"9 4 3 10\\n\", \"9 8 2 10\\n\", \"1 1 1 1\\n\", \"10 7 2 7\\n\", \"8 2 6 10\\n\", \"8 1 2 10\\n\", \"6 1 4 10\\n\", \"1000000 951981 612086 60277\\n\", \"1000000 587964 232616 62357\\n\", \"1000000 948438 69861 89178\\n\", \"1000000000 504951981 646612086 602763371\\n\", \"1000000000 81587964 595232616 623563697\\n\", \"1000000000 55 60 715189365\\n\", \"1000000000 85 61 857945620\\n\", \"1000000000 55 85 423654797\\n\", \"1000000000 63 65 384381709\\n\", \"1000000000 44 30 891773002\\n\", \"1000000000 6 97 272656295\\n\", \"1000000000 999999946 999999941 715189365\\n\", \"1000000000 999999916 999999940 857945620\\n\", \"1000000000 999999946 999999916 423654797\\n\", \"1000000000 999999938 999999936 384381709\\n\", \"1000000000 55 999999941 715189365\\n\", \"1000000000 85 999999940 857945620\\n\", \"1000000000 55 999999916 423654797\\n\", \"1000000000 63 999999936 384381709\\n\", \"1000000000 44 999999971 891773002\\n\", \"1000000000 6 999999904 272656295\\n\", \"1000000000 999999946 60 715189365\\n\", \"1000000000 999999916 61 857945620\\n\", \"1000000000 999999946 85 423654797\\n\", \"1000000000 999999938 65 384381709\\n\", \"1000000000 999999957 30 891773002\\n\", \"548813503 532288332 26800940 350552333\\n\", \"847251738 695702891 698306947 648440371\\n\", \"891773002 152235342 682786380 386554406\\n\", \"812168727 57791401 772019566 644719499\\n\", \"71036059 25478942 38920202 19135721\\n\", \"549 198 8 262611\\n\", \"848 409 661 620581\\n\", \"892 364 824 53858\\n\", \"813 154 643 141422\\n\", \"72 40 68 849\\n\", \"958 768 649 298927\\n\", \"800 305 317 414868\\n\", \"721 112 687 232556\\n\", \"522 228 495 74535\\n\", \"737 231 246 79279\\n\", \"6 4 3 36\\n\", \"9 3 8 55\\n\", \"9 4 3 73\\n\", \"9 8 2 50\\n\", \"1 1 1 1\\n\", \"10 7 2 7\\n\", \"8 2 6 20\\n\", \"8 1 2 64\\n\", \"6 1 4 15\\n\", \"8 8 3 1\\n\"], \"outputs\": [\"0\\n\", \"2\\n\", \"2\\n\", \"2\\n\", \"0\\n\", \"2\\n\", \"2\\n\", \"3\\n\", \"3\\n\", \"174\\n\", \"177\\n\", \"211\\n\", \"17360\\n\", \"17657\\n\", \"37707\\n\", \"41279\\n\", \"28970\\n\", \"27600\\n\", \"42159\\n\", \"23250\\n\", \"37707\\n\", \"41279\\n\", \"28970\\n\", \"27600\\n\", \"37707\\n\", \"41279\\n\", \"28970\\n\", \"27600\\n\", \"42159\\n\", \"23250\\n\", \"37707\\n\", \"41279\\n\", \"28970\\n\", \"27600\\n\", \"42159\\n\", \"13239\\n\", \"18006\\n\", \"13902\\n\", \"17954\\n\", \"3093\\n\", \"635\\n\", \"771\\n\", \"183\\n\", \"299\\n\", \"25\\n\", \"431\\n\", \"489\\n\", \"556\\n\", \"249\\n\", \"199\\n\", \"6\\n\", \"7\\n\", \"8\\n\", \"7\\n\", \"0\\n\", \"2\\n\", \"3\\n\", \"13\\n\", \"3\\n\", \"0\\n\"]}", "source": "primeintellect"}
Mr. Bender has a digital table of size n × n, each cell can be switched on or off. He wants the field to have at least c switched on squares. When this condition is fulfilled, Mr Bender will be happy. We'll consider the table rows numbered from top to bottom from 1 to n, and the columns — numbered from left to right from 1 to n. Initially there is exactly one switched on cell with coordinates (x, y) (x is the row number, y is the column number), and all other cells are switched off. Then each second we switch on the cells that are off but have the side-adjacent cells that are on. For a cell with coordinates (x, y) the side-adjacent cells are cells with coordinates (x - 1, y), (x + 1, y), (x, y - 1), (x, y + 1). In how many seconds will Mr. Bender get happy? -----Input----- The first line contains four space-separated integers n, x, y, c (1 ≤ n, c ≤ 10^9; 1 ≤ x, y ≤ n; c ≤ n^2). -----Output----- In a single line print a single integer — the answer to the problem. -----Examples----- Input 6 4 3 1 Output 0 Input 9 3 8 10 Output 2 -----Note----- Initially the first test has one painted cell, so the answer is 0. In the second test all events will go as is shown on the figure. [Image]. Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0
{"tests": "{\"inputs\": [\"5\\n0 1 0 1 1\\n\", \"7\\n1 0 1 0 0 1 0\\n\", \"1\\n0\\n\", \"1\\n1\\n\", \"2\\n0 0\\n\", \"2\\n0 1\\n\", \"2\\n1 0\\n\", \"2\\n1 1\\n\", \"10\\n0 0 0 0 0 0 0 0 0 0\\n\", \"9\\n1 1 1 1 1 1 1 1 1\\n\", \"11\\n0 0 0 0 0 0 0 0 0 0 1\\n\", \"12\\n1 0 0 0 0 0 0 0 0 0 0 0\\n\", \"20\\n1 1 0 1 1 1 1 1 1 1 1 0 1 1 1 0 0 1 0 0\\n\", \"41\\n1 1 0 1 0 1 0 0 1 0 1 1 1 0 0 0 1 1 1 0 1 0 1 1 0 1 0 1 0 0 0 0 0 0 1 0 0 1 0 1 1\\n\", \"63\\n1 1 0 1 1 0 0 0 1 1 0 0 1 1 1 1 0 1 1 0 1 0 1 1 1 1 1 0 0 0 0 0 0 1 0 0 1 0 0 1 0 1 1 0 0 1 1 0 0 1 1 1 1 0 0 1 1 0 0 1 0 1 0\\n\", \"80\\n0 1 1 1 0 1 1 1 1 1 0 0 1 0 1 1 0 1 1 1 0 1 1 1 1 0 1 0 1 0 0 0 1 1 0 1 1 0 0 0 0 1 1 1 0 0 0 1 0 0 1 1 1 0 0 0 0 0 0 1 0 1 0 0 1 0 1 1 1 1 1 0 0 0 1 1 0 0 1 1\\n\", \"99\\n1 1 0 0 0 1 0 0 1 1 1 1 0 0 0 1 0 1 1 0 1 1 1 1 0 0 0 0 1 1 1 1 0 1 0 1 0 1 1 1 0 0 1 1 1 0 0 0 1 1 1 0 1 1 1 0 1 0 0 1 1 0 1 0 0 1 1 1 1 0 0 1 1 0 0 1 0 1 1 1 0 1 1 0 1 0 0 1 0 1 0 1 0 1 1 0 1 0 1\\n\", \"100\\n0 1 1 0 1 1 0 0 1 1 0 1 1 1 1 1 0 0 1 1 1 0 0 0 0 1 1 0 0 1 0 0 1 0 0 0 0 1 1 1 1 1 1 0 0 1 1 0 0 0 0 1 0 1 1 1 0 1 1 0 1 0 0 0 0 0 1 0 1 1 0 0 1 1 0 1 1 0 0 1 1 1 0 1 1 1 1 1 1 0 0 1 1 1 1 0 1 1 1 0\\n\", \"11\\n0 1 1 0 0 0 0 0 0 0 0\\n\", \"11\\n0 1 0 1 0 0 1 1 0 1 1\\n\", \"11\\n1 0 1 0 1 1 0 1 1 1 0\\n\", \"11\\n1 0 0 0 0 0 1 0 1 1 1\\n\", \"22\\n0 1 1 0 0 0 0 0 1 0 0 0 0 1 1 0 0 1 0 0 1 0\\n\", \"22\\n0 1 0 1 0 1 1 1 1 0 0 1 1 1 0 1 1 1 0 0 0 1\\n\", \"22\\n1 0 1 0 1 0 0 0 0 0 0 1 0 0 0 0 1 1 0 1 1 0\\n\", \"22\\n1 0 1 0 0 0 1 0 0 1 1 0 1 0 1 1 0 0 0 1 0 1\\n\", \"33\\n0 1 1 0 1 1 0 1 0 1 1 0 1 1 1 1 0 1 1 1 0 0 1 1 0 0 1 1 0 1 1 0 0\\n\", \"33\\n0 1 0 1 0 1 1 0 0 0 1 1 1 0 1 0 1 1 0 1 0 1 0 0 1 1 1 0 1 1 1 0 1\\n\", \"33\\n1 0 1 0 1 0 0 0 1 0 1 1 1 0 0 0 0 1 1 0 1 0 1 1 0 1 0 1 1 1 1 1 0\\n\", \"33\\n1 0 1 0 1 1 1 1 1 0 1 0 1 1 0 0 1 0 1 0 0 0 1 0 1 0 1 0 0 0 0 1 1\\n\", \"44\\n0 1 1 0 1 0 0 0 0 1 1 0 0 0 0 0 1 1 1 0 0 0 0 0 1 0 0 1 1 0 0 0 0 1 1 1 0 0 1 0 1 1 0 0\\n\", \"44\\n0 1 1 1 1 0 1 0 0 1 0 1 0 0 1 1 0 1 1 0 0 1 0 1 0 1 1 0 1 0 1 0 1 0 1 0 0 0 0 0 1 0 1 1\\n\", \"44\\n1 0 1 0 0 1 0 1 0 1 0 1 0 1 1 1 1 1 0 1 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 1 0 0 1 0 0 1 0\\n\", \"44\\n1 0 1 0 1 1 1 0 0 0 0 0 0 1 0 0 0 1 1 1 0 0 0 1 0 1 0 1 1 0 1 1 0 1 0 1 1 0 1 0 1 1 1 1\\n\", \"55\\n0 1 1 0 1 0 0 0 1 0 0 0 1 0 1 0 0 1 0 0 0 0 1 1 1 0 0 1 1 0 0 0 0 0 1 0 1 1 1 0 0 0 0 0 1 0 0 0 0 1 1 0 0 1 0\\n\", \"55\\n0 1 1 0 1 0 1 1 1 1 0 1 1 0 0 1 1 1 0 0 0 1 1 0 0 1 0 1 0 1 0 0 1 1 1 1 1 0 0 0 1 1 1 1 1 1 1 1 0 1 1 0 0 0 1\\n\", \"55\\n1 0 1 0 0 1 0 0 1 1 0 1 0 1 0 0 1 1 0 0 0 0 1 1 1 0 0 0 1 1 1 1 0 1 0 1 0 0 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1 0 0\\n\", \"55\\n1 0 1 0 1 0 1 0 1 1 0 0 1 1 1 1 0 1 0 0 0 1 1 0 0 1 0 1 0 1 1 1 0 0 0 0 0 0 1 0 0 0 1 1 1 0 0 0 1 0 1 0 1 1 1\\n\", \"66\\n0 1 1 0 0 1 0 1 0 1 0 1 1 0 1 1 0 0 1 1 0 1 0 0 0 0 0 0 0 1 0 0 0 1 1 1 1 1 1 0 0 1 1 1 0 1 0 1 1 0 1 0 0 1 1 0 1 1 1 0 0 0 0 0 1 0\\n\", \"66\\n0 1 1 0 1 1 1 0 0 0 1 1 0 1 1 0 0 1 1 1 1 1 0 1 1 1 0 1 1 1 0 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 0 0 1 0 0 0 0 0 1 0 1 0 0 1 0 0 1 1 0 1\\n\", \"66\\n1 0 1 0 0 0 1 0 1 0 1 0 1 1 0 1 0 1 1 0 0 0 1 1 1 0 1 0 0 1 0 1 0 0 0 0 1 1 0 1 1 0 1 0 0 0 1 1 0 1 0 1 1 0 0 0 1 1 0 1 1 0 1 1 0 0\\n\", \"66\\n1 0 1 0 0 0 1 1 1 1 1 0 1 0 0 0 1 1 1 0 1 1 0 1 0 1 0 0 1 0 0 1 0 1 0 1 0 0 1 0 0 1 0 1 1 1 1 1 0 1 1 1 1 1 1 0 0 0 1 0 1 1 0 0 0 1\\n\", \"77\\n0 0 1 0 0 1 0 0 1 1 1 1 0 1 0 0 1 0 0 0 0 1 0 0 0 0 1 0 1 0 1 0 0 0 1 0 0 1 1 0 1 0 1 1 0 0 0 1 0 0 1 1 1 0 1 0 1 1 0 1 0 0 0 1 0 1 1 0 1 1 1 0 1 1 0 1 0\\n\", \"77\\n0 0 1 0 0 0 1 0 1 1 1 1 0 1 1 1 0 1 1 0 1 1 1 0 1 1 0 1 0 0 0 0 1 1 0 0 0 1 1 0 0 1 1 0 1 0 0 1 0 0 0 1 0 0 1 0 0 0 1 0 0 0 1 0 0 1 0 1 1 0 1 0 0 0 0 1 1\\n\", \"77\\n1 0 0 0 1 0 1 1 0 0 1 0 0 0 1 1 1 1 0 1 0 0 0 0 0 0 1 1 0 0 0 1 0 1 0 1 1 1 0 1 1 1 0 0 0 1 1 0 1 1 1 0 1 1 0 0 1 0 0 1 1 1 1 0 1 0 0 0 1 0 1 1 0 0 0 0 0\\n\", \"77\\n1 0 1 0 0 1 1 0 0 0 0 0 0 0 0 0 0 1 0 1 1 1 0 0 1 1 1 0 1 1 0 1 0 0 0 0 1 1 1 0 1 0 0 1 1 0 1 0 1 1 1 1 1 1 1 0 0 1 1 0 0 1 0 1 1 1 1 1 1 1 1 0 0 1 0 1 1\\n\", \"88\\n0 0 1 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 1 0 1 1 1 0 0 1 1 0 0 1 0 1 1 1 0 1 1 1 0 1 1 1 1 0 0 0 0 1 0 0 0 1 0 1 1 0 1 0 1 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 1 1 0 0 1 0 0 1 1 1 0\\n\", \"88\\n0 0 1 0 0 0 1 1 0 1 0 1 1 1 0 1 1 1 0 1 1 1 1 1 0 1 1 0 1 1 1 0 1 0 0 1 0 1 1 0 0 0 0 0 1 1 0 0 1 0 1 1 1 0 1 1 0 1 1 0 0 0 1 1 1 1 1 1 1 0 0 1 0 1 0 0 0 1 0 1 0 0 0 0 0 0 0 1\\n\", \"88\\n1 0 0 0 1 1 1 0 1 1 0 0 0 0 0 0 1 0 1 0 0 0 1 1 0 0 1 1 1 1 1 1 0 0 0 0 0 1 0 1 0 0 0 0 0 1 1 1 0 1 1 0 0 1 1 1 0 0 1 0 0 1 1 1 1 0 0 1 0 1 1 1 0 1 0 1 1 1 1 0 1 0 1 1 1 0 0 0\\n\", \"88\\n1 1 1 0 0 1 1 0 1 0 0 0 1 0 1 1 1 1 1 0 1 1 1 1 1 1 1 0 0 1 0 1 1 1 0 0 0 1 1 0 1 1 0 1 0 0 1 0 0 1 0 0 1 0 1 1 0 1 0 1 0 1 0 0 1 1 1 0 0 0 1 0 0 1 0 0 1 1 0 1 1 1 1 0 1 1 0 1\\n\", \"99\\n0 0 0 0 1 0 0 1 0 0 0 1 1 1 1 1 1 0 1 1 0 1 0 0 1 0 1 1 1 1 1 0 1 0 1 1 1 0 0 0 1 0 0 1 0 1 0 1 0 0 0 0 1 0 1 1 0 0 1 1 1 0 0 1 1 0 0 0 0 0 0 1 0 0 0 1 1 0 0 0 1 1 1 0 1 1 0 1 0 1 0 0 0 1 1 0 0 0 0\\n\", \"99\\n0 0 1 0 0 1 1 0 0 0 1 1 0 0 1 0 0 0 1 1 1 1 0 0 0 1 1 0 0 0 1 0 1 1 0 0 1 1 1 0 1 1 0 0 0 0 0 1 0 0 1 0 1 1 0 1 0 1 0 0 1 0 1 1 1 1 1 1 0 1 0 0 1 1 0 0 1 0 1 0 1 0 1 1 1 0 0 1 1 1 0 0 0 0 0 0 1 1 1\\n\", \"99\\n1 1 0 0 1 1 1 0 0 0 1 0 1 0 1 1 0 0 0 0 0 0 0 0 1 0 1 1 0 0 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 0 1 0 1 1 1 1 0 1 1 1 0 0 1 0 0 1 1 0 0 0 0 1 0 0 1 0 1 1 0 1 1 0 0 1 0 0 1 0 1 0 1 1 0 1 0 1 1 1 1 0 0 1 0\\n\", \"99\\n1 1 1 0 1 0 1 1 0 1 1 0 0 1 0 0 1 1 1 0 1 1 0 0 0 1 1 1 1 0 1 1 1 0 1 1 0 1 1 0 1 0 1 0 0 1 1 1 1 1 0 1 1 0 1 1 0 0 0 1 0 1 0 1 0 1 0 0 0 1 1 1 1 0 0 1 1 0 1 0 0 0 1 0 1 1 1 0 0 1 1 1 1 1 0 1 1 1 1\\n\", \"90\\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\\n\", \"90\\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\\n\", \"95\\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\\n\", \"95\\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\\n\", \"100\\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\\n\", \"100\\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\\n\"], \"outputs\": [\"4\\n\", \"4\\n\", \"0\\n\", \"1\\n\", \"0\\n\", \"1\\n\", \"1\\n\", \"2\\n\", \"0\\n\", \"9\\n\", \"1\\n\", \"1\\n\", \"16\\n\", \"28\\n\", \"39\\n\", \"52\\n\", \"72\\n\", \"65\\n\", \"2\\n\", \"8\\n\", \"10\\n\", \"6\\n\", \"7\\n\", \"16\\n\", \"11\\n\", \"14\\n\", \"26\\n\", \"27\\n\", \"25\\n\", \"24\\n\", \"19\\n\", \"32\\n\", \"23\\n\", \"32\\n\", \"23\\n\", \"39\\n\", \"32\\n\", \"36\\n\", \"41\\n\", \"42\\n\", \"46\\n\", \"46\\n\", \"47\\n\", \"44\\n\", \"45\\n\", \"51\\n\", \"44\\n\", \"59\\n\", \"53\\n\", \"63\\n\", \"56\\n\", \"58\\n\", \"65\\n\", \"77\\n\", \"0\\n\", \"90\\n\", \"0\\n\", \"95\\n\", \"0\\n\", \"100\\n\"]}", "source": "primeintellect"}
Alena has successfully passed the entrance exams to the university and is now looking forward to start studying. One two-hour lesson at the Russian university is traditionally called a pair, it lasts for two academic hours (an academic hour is equal to 45 minutes). The University works in such a way that every day it holds exactly n lessons. Depending on the schedule of a particular group of students, on a given day, some pairs may actually contain classes, but some may be empty (such pairs are called breaks). The official website of the university has already published the schedule for tomorrow for Alena's group. Thus, for each of the n pairs she knows if there will be a class at that time or not. Alena's House is far from the university, so if there are breaks, she doesn't always go home. Alena has time to go home only if the break consists of at least two free pairs in a row, otherwise she waits for the next pair at the university. Of course, Alena does not want to be sleepy during pairs, so she will sleep as long as possible, and will only come to the first pair that is presented in her schedule. Similarly, if there are no more pairs, then Alena immediately goes home. Alena appreciates the time spent at home, so she always goes home when it is possible, and returns to the university only at the beginning of the next pair. Help Alena determine for how many pairs she will stay at the university. Note that during some pairs Alena may be at the university waiting for the upcoming pair. -----Input----- The first line of the input contains a positive integer n (1 ≤ n ≤ 100) — the number of lessons at the university. The second line contains n numbers a_{i} (0 ≤ a_{i} ≤ 1). Number a_{i} equals 0, if Alena doesn't have the i-th pairs, otherwise it is equal to 1. Numbers a_1, a_2, ..., a_{n} are separated by spaces. -----Output----- Print a single number — the number of pairs during which Alena stays at the university. -----Examples----- Input 5 0 1 0 1 1 Output 4 Input 7 1 0 1 0 0 1 0 Output 4 Input 1 0 Output 0 -----Note----- In the first sample Alena stays at the university from the second to the fifth pair, inclusive, during the third pair she will be it the university waiting for the next pair. In the last sample Alena doesn't have a single pair, so she spends all the time at home. Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0.125
{"tests": "{\"inputs\": [\"1\\n\", \"512\\n\", \"10000000\\n\", \"2\\n\", \"3\\n\", \"4\\n\", \"8958020\\n\", \"6\\n\", \"7\\n\", \"8\\n\", \"9\\n\", \"10\\n\", \"11\\n\", \"12\\n\", \"13\\n\", \"14\\n\", \"15\\n\", \"16\\n\", \"17\\n\", \"18\\n\", \"19\\n\", \"20\\n\", \"253574\\n\", \"3194897\\n\", \"6767476\\n\", \"4695418\\n\", \"7320749\\n\", \"7365657\\n\", \"6415292\\n\", \"865176\\n\", \"5615225\\n\", \"7609348\\n\", \"9946581\\n\", \"4639396\\n\", \"7457651\\n\", \"819893\\n\", \"3588154\\n\", \"543812\\n\", \"3762219\\n\", \"5\\n\", \"100\\n\", \"267\\n\", \"13\\n\", \"7\\n\", \"9\\n\", \"63\\n\", \"17\\n\", \"21\\n\", \"11\\n\", \"999995\\n\", \"29\\n\", \"37\\n\", \"9999999\\n\", \"9999991\\n\", \"602663\\n\", \"5\\n\", \"19\\n\", \"9999889\\n\", \"107\\n\"], \"outputs\": [\"9 8\\n\", \"4608 4096\\n\", \"90000000 80000000\\n\", \"18 16\\n\", \"27 24\\n\", \"36 32\\n\", \"80622180 71664160\\n\", \"54 48\\n\", \"63 56\\n\", \"72 64\\n\", \"81 72\\n\", \"90 80\\n\", \"99 88\\n\", \"108 96\\n\", \"117 104\\n\", \"126 112\\n\", \"135 120\\n\", \"144 128\\n\", \"153 136\\n\", \"162 144\\n\", \"171 152\\n\", \"180 160\\n\", \"2282166 2028592\\n\", \"28754073 25559176\\n\", \"60907284 54139808\\n\", \"42258762 37563344\\n\", \"65886741 58565992\\n\", \"66290913 58925256\\n\", \"57737628 51322336\\n\", \"7786584 6921408\\n\", \"50537025 44921800\\n\", \"68484132 60874784\\n\", \"89519229 79572648\\n\", \"41754564 37115168\\n\", \"67118859 59661208\\n\", \"7379037 6559144\\n\", \"32293386 28705232\\n\", \"4894308 4350496\\n\", \"33859971 30097752\\n\", \"45 40\\n\", \"900 800\\n\", \"2403 2136\\n\", \"117 104\\n\", \"63 56\\n\", \"81 72\\n\", \"567 504\\n\", \"153 136\\n\", \"189 168\\n\", \"99 88\\n\", \"8999955 7999960\\n\", \"261 232\\n\", \"333 296\\n\", \"89999991 79999992\\n\", \"89999919 79999928\\n\", \"5423967 4821304\\n\", \"45 40\\n\", \"171 152\\n\", \"89999001 79999112\\n\", \"963 856\\n\"]}", "source": "primeintellect"}
Let's call a positive integer composite if it has at least one divisor other than $1$ and itself. For example: the following numbers are composite: $1024$, $4$, $6$, $9$; the following numbers are not composite: $13$, $1$, $2$, $3$, $37$. You are given a positive integer $n$. Find two composite integers $a,b$ such that $a-b=n$. It can be proven that solution always exists. -----Input----- The input contains one integer $n$ ($1 \leq n \leq 10^7$): the given integer. -----Output----- Print two composite integers $a,b$ ($2 \leq a, b \leq 10^9, a-b=n$). It can be proven, that solution always exists. If there are several possible solutions, you can print any. -----Examples----- Input 1 Output 9 8 Input 512 Output 4608 4096 Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0
{"tests": "{\"inputs\": [\"nniinneetteeeenn\\n\", \"nneteenabcnneteenabcnneteenabcnneteenabcnneteenabcii\\n\", \"nineteenineteen\\n\", \"nssemsnnsitjtihtthij\\n\", \"eehihnttehtherjsihihnrhimihrjinjiehmtjimnrss\\n\", \"rrrteiehtesisntnjirtitijnjjjthrsmhtneirjimniemmnrhirssjnhetmnmjejjnjjritjttnnrhnjs\\n\", \"mmrehtretseihsrjmtsenemniehssnisijmsnntesismmtmthnsieijjjnsnhisi\\n\", \"hshretttnntmmiertrrnjihnrmshnthirnnirrheinnnrjiirshthsrsijtrrtrmnjrrjnresnintnmtrhsnjrinsseimn\\n\", \"snmmensntritetnmmmerhhrmhnehehtesmhthseemjhmnrti\\n\", \"rmeetriiitijmrenmeiijt\\n\", \"ihimeitimrmhriemsjhrtjtijtesmhemnmmrsetmjttthtjhnnmirtimne\\n\", \"rhtsnmnesieernhstjnmmirthhieejsjttsiierhihhrrijhrrnejsjer\\n\", \"emmtjsjhretehmiiiestmtmnmissjrstnsnjmhimjmststsitemtttjrnhsrmsenjtjim\\n\", \"nmehhjrhirniitshjtrrtitsjsntjhrstjehhhrrerhemehjeermhmhjejjesnhsiirheijjrnrjmminneeehtm\\n\", \"hsntijjetmehejtsitnthietssmeenjrhhetsnjrsethisjrtrhrierjtmimeenjnhnijeesjttrmn\\n\", \"jnirirhmirmhisemittnnsmsttesjhmjnsjsmntisheneiinsrjsjirnrmnjmjhmistntersimrjni\\n\", \"neithjhhhtmejjnmieishethmtetthrienrhjmjenrmtejerernmthmsnrthhtrimmtmshm\\n\", \"sithnrsnemhijsnjitmijjhejjrinejhjinhtisttteermrjjrtsirmessejireihjnnhhemiirmhhjeet\\n\", \"jrjshtjstteh\\n\", \"jsihrimrjnnmhttmrtrenetimemjnshnimeiitmnmjishjjneisesrjemeshjsijithtn\\n\", \"hhtjnnmsemermhhtsstejehsssmnesereehnnsnnremjmmieethmirjjhn\\n\", \"tmnersmrtsehhntsietttrehrhneiireijnijjejmjhei\\n\", \"mtstiresrtmesritnjriirehtermtrtseirtjrhsejhhmnsineinsjsin\\n\", \"ssitrhtmmhtnmtreijteinimjemsiiirhrttinsnneshintjnin\\n\", \"rnsrsmretjiitrjthhritniijhjmm\\n\", \"hntrteieimrimteemenserntrejhhmijmtjjhnsrsrmrnsjseihnjmehtthnnithirnhj\\n\", \"nmmtsmjrntrhhtmimeresnrinstjnhiinjtnjjjnthsintmtrhijnrnmtjihtinmni\\n\", \"eihstiirnmteejeehimttrijittjsntjejmessstsemmtristjrhenithrrsssihnthheehhrnmimssjmejjreimjiemrmiis\\n\", \"srthnimimnemtnmhsjmmmjmmrsrisehjseinemienntetmitjtnnneseimhnrmiinsismhinjjnreehseh\\n\", \"etrsmrjehntjjimjnmsresjnrthjhehhtreiijjminnheeiinseenmmethiemmistsei\\n\", \"msjeshtthsieshejsjhsnhejsihisijsertenrshhrthjhiirijjneinjrtrmrs\\n\", \"mehsmstmeejrhhsjihntjmrjrihssmtnensttmirtieehimj\\n\", \"mmmsermimjmrhrhejhrrejermsneheihhjemnehrhihesnjsehthjsmmjeiejmmnhinsemjrntrhrhsmjtttsrhjjmejj\\n\", \"rhsmrmesijmmsnsmmhertnrhsetmisshriirhetmjihsmiinimtrnitrseii\\n\", \"iihienhirmnihh\\n\", \"ismtthhshjmhisssnmnhe\\n\", \"rhsmnrmhejshinnjrtmtsssijimimethnm\\n\", \"eehnshtiriejhiirntminrirnjihmrnittnmmnjejjhjtennremrnssnejtntrtsiejjijisermj\\n\", \"rnhmeesnhttrjintnhnrhristjrthhrmehrhjmjhjehmstrijemjmmistes\\n\", \"ssrmjmjeeetrnimemrhimes\\n\", \"n\\n\", \"ni\\n\", \"nine\\n\", \"nineteenineteenineteenineteenineteenineteenineteenineteenineteenineteenineteenineteenineteen\\n\", \"ninetee\\n\", \"mzbmweyydiadtlcouegmdbyfwurpwbpuvhifnuapwynd\\n\", \"zenudggmyopddhszhrbmftgzmjorabhgojdtfnzxjkayjlkgczsyshczutkdch\\n\", \"rtzxovxqfapkdmelxiyjroohufhbakpmmvaxq\\n\", \"zninetneeineteeniwnteeennieteenineteenineteenineteenineteenineteenineteenineteenineteeninetzeenz\\n\", \"nnnnnnniiiiiiiiiiiitttttttttteeeeeeeeeeeeeeeeee\\n\", \"ttttiiiieeeeeeeeeeeennnnnnnnn\\n\", \"ttttttttteeeeeeeeeeeeeeeeeeeeeiiiiiiiiiiiinnnnnnn\\n\", \"nnnnnnnnnneeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeiiiiiiiiiiiiiiiiiiiitttttttttttttttttttt\\n\", \"eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeiiiiiiiiiiiiiiiiittttttttttttttttnnnnnnn\\n\", \"nineeen\\n\", \"nineteeeeeeeeeeeeeeeeettttttttttttttttttiiiiiiiiiiiiiiiiii\\n\", \"nineteenieteenieteenieteenieteenieteenieteen\\n\", \"nineteenineteenineteenineteenineteen\\n\"], \"outputs\": [\"2\", \"2\", \"2\", \"0\", \"1\", \"2\", \"2\", \"1\", \"2\", \"0\", \"1\", \"2\", \"2\", \"3\", \"3\", \"1\", \"2\", \"3\", \"0\\n\", \"2\", \"2\", \"1\", \"2\", \"1\", \"0\", \"3\", \"0\", \"2\", \"3\", \"3\", \"1\", \"1\", \"2\", \"1\", \"0\", \"0\", \"0\", \"3\", \"2\", \"0\", \"0\", \"0\", \"0\", \"13\", \"0\", \"0\", \"0\", \"0\\n\", \"13\", \"3\", \"4\", \"3\", \"4\", \"3\", \"0\", \"0\", \"4\", \"5\"]}", "source": "primeintellect"}
Alice likes word "nineteen" very much. She has a string s and wants the string to contain as many such words as possible. For that reason she can rearrange the letters of the string. For example, if she has string "xiineteenppnnnewtnee", she can get string "xnineteenppnineteenw", containing (the occurrences marked) two such words. More formally, word "nineteen" occurs in the string the number of times you can read it starting from some letter of the string. Of course, you shouldn't skip letters. Help her to find the maximum number of "nineteen"s that she can get in her string. -----Input----- The first line contains a non-empty string s, consisting only of lowercase English letters. The length of string s doesn't exceed 100. -----Output----- Print a single integer — the maximum number of "nineteen"s that she can get in her string. -----Examples----- Input nniinneetteeeenn Output 2 Input nneteenabcnneteenabcnneteenabcnneteenabcnneteenabcii Output 2 Input nineteenineteen Output 2 Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0
{"tests": "{\"inputs\": [\"5\\n3 4 3 2 1\\n6 8\\n\", \"5\\n0 3 3 4 2\\n3 10\\n\", \"2\\n2 5\\n3 6\\n\", \"3\\n0 1 0\\n2 10\\n\", \"5\\n2 2 2 2 2\\n5 5\\n\", \"10\\n1 1 1 1 1 1 1 1 1 1\\n1 10\\n\", \"10\\n1 1 1 1 1 1 1 1 1 1\\n5 5\\n\", \"6\\n0 0 1 1 0 0\\n1 6\\n\", \"7\\n3 2 3 3 2 1 1\\n5 10\\n\", \"4\\n1 0 0 100\\n1 100\\n\", \"100\\n46 6 71 27 94 59 99 82 5 41 18 89 86 2 31 35 52 18 1 14 54 11 28 83 42 15 13 77 22 70 87 65 79 35 44 71 79 9 95 57 5 59 42 62 66 26 33 66 67 45 39 17 97 28 36 100 52 23 68 29 83 6 61 85 71 2 85 98 85 65 95 53 35 96 29 28 82 80 52 60 61 46 46 80 11 3 35 6 12 10 64 7 7 7 65 93 58 85 20 12\\n2422 2429\\n\", \"10\\n3 6 1 5 3 7 0 1 0 8\\n16 18\\n\", \"10\\n3 3 0 4 0 5 2 10 7 0\\n10 24\\n\", \"10\\n9 4 7 7 1 3 7 3 8 5\\n23 31\\n\", \"10\\n9 6 9 5 5 4 3 3 9 10\\n9 54\\n\", \"10\\n2 4 8 5 2 2 2 5 6 2\\n14 24\\n\", \"10\\n10 58 86 17 61 12 75 93 37 30\\n10 469\\n\", \"10\\n56 36 0 28 68 54 34 48 28 92\\n92 352\\n\", \"10\\n2 81 94 40 74 62 39 70 87 86\\n217 418\\n\", \"10\\n48 93 9 96 70 14 100 93 44 79\\n150 496\\n\", \"10\\n94 85 4 9 30 45 90 76 0 65\\n183 315\\n\", \"100\\n1 0 7 9 0 4 3 10 9 4 9 7 4 4 7 7 6 1 3 3 8 1 4 3 5 8 0 0 6 2 3 5 0 1 5 8 6 3 2 4 9 5 8 6 0 2 5 1 9 5 9 0 6 0 4 5 9 7 1 4 7 5 4 5 6 8 2 3 3 2 8 2 9 5 9 2 4 7 7 8 10 1 3 0 8 0 9 1 1 7 7 8 9 3 5 9 9 8 0 8\\n200 279\\n\", \"100\\n5 4 9 7 8 10 7 8 10 0 10 9 7 1 0 7 8 5 5 8 7 7 7 2 5 8 0 7 5 7 1 7 6 5 4 10 6 1 4 4 8 7 0 3 2 10 8 6 1 3 2 6 8 1 9 3 9 5 2 0 3 6 7 5 10 0 2 8 3 10 1 3 8 8 0 2 10 3 4 4 0 7 4 0 9 7 10 2 7 10 9 9 6 6 8 1 10 1 2 0\\n52 477\\n\", \"100\\n5 1 6 6 5 4 5 8 0 2 10 1 10 0 6 6 0 1 5 7 10 5 8 4 4 5 10 4 10 3 0 10 10 1 2 6 2 6 3 9 4 4 5 5 7 7 7 4 3 2 1 4 5 0 2 1 8 5 4 5 10 7 0 3 5 4 10 4 10 7 10 1 8 3 9 8 6 9 5 7 3 4 7 8 4 0 3 4 4 1 6 6 2 0 1 5 3 3 9 10\\n22 470\\n\", \"100\\n73 75 17 93 35 7 71 88 11 58 78 33 7 38 14 83 30 25 75 23 60 10 100 7 90 51 82 0 78 54 61 32 20 90 54 45 100 62 40 99 43 86 87 64 10 41 29 51 38 22 5 63 10 64 90 20 100 33 95 72 40 82 92 30 38 3 71 85 99 66 4 26 33 41 85 14 26 61 21 96 29 40 25 14 48 4 30 44 6 41 71 71 4 66 13 50 30 78 64 36\\n2069 2800\\n\", \"100\\n86 19 100 37 9 49 97 9 70 51 14 31 47 53 76 65 10 40 4 92 2 79 22 70 85 58 73 96 89 91 41 88 70 31 53 33 22 51 10 56 90 39 70 38 86 15 94 63 82 19 7 65 22 83 83 71 53 6 95 89 53 41 95 11 32 0 7 84 39 11 37 73 20 46 18 28 72 23 17 78 37 49 43 62 60 45 30 69 38 41 71 43 47 80 64 40 77 99 36 63\\n1348 3780\\n\", \"100\\n65 64 26 48 16 90 68 32 95 11 27 29 87 46 61 35 24 99 34 17 79 79 11 66 14 75 31 47 43 61 100 32 75 5 76 11 46 74 81 81 1 25 87 45 16 57 24 76 58 37 42 0 46 23 75 66 75 11 50 5 10 11 43 26 38 42 88 15 70 57 2 74 7 72 52 8 72 19 37 38 66 24 51 42 40 98 19 25 37 7 4 92 47 72 26 76 66 88 53 79\\n1687 2986\\n\", \"100\\n78 43 41 93 12 76 62 54 85 5 42 61 93 37 22 6 50 80 63 53 66 47 0 60 43 93 90 8 97 64 80 22 23 47 30 100 80 75 84 95 35 69 36 20 58 99 78 88 1 100 10 69 57 77 68 61 62 85 4 45 24 4 24 74 65 73 91 47 100 35 25 53 27 66 62 55 38 83 56 20 62 10 71 90 41 5 75 83 36 75 15 97 79 52 88 32 55 42 59 39\\n873 4637\\n\", \"100\\n12 25 47 84 72 40 85 37 8 92 85 90 12 7 45 14 98 62 31 62 10 89 37 65 77 29 5 3 21 21 10 98 44 37 37 37 50 15 69 27 19 99 98 91 63 42 32 68 77 88 78 35 13 44 4 82 42 76 28 50 65 64 88 46 94 37 40 7 10 58 21 31 17 91 75 86 3 9 9 14 72 20 40 57 11 75 91 48 79 66 53 24 93 16 58 4 10 89 75 51\\n666 4149\\n\", \"10\\n8 0 2 2 5 1 3 5 2 2\\n13 17\\n\", \"10\\n10 4 4 6 2 2 0 5 3 7\\n19 24\\n\", \"10\\n96 19 75 32 94 16 81 2 93 58\\n250 316\\n\", \"10\\n75 65 68 43 89 57 7 58 51 85\\n258 340\\n\", \"100\\n59 51 86 38 90 10 36 3 97 35 32 20 25 96 49 39 66 44 64 50 97 68 50 79 3 33 72 96 32 74 67 9 17 77 67 15 1 100 99 81 18 1 15 36 7 34 30 78 10 97 7 19 87 47 62 61 40 29 1 34 6 77 76 21 66 11 65 96 82 54 49 65 56 90 29 75 48 77 48 53 91 21 98 26 80 44 57 97 11 78 98 45 40 88 27 27 47 5 26 6\\n2479 2517\\n\", \"100\\n5 11 92 53 49 42 15 86 31 10 30 49 21 66 14 13 80 25 21 25 86 20 86 83 36 81 21 23 0 30 64 85 15 33 74 96 83 51 84 4 35 65 10 7 11 11 41 80 51 51 74 52 43 83 88 38 77 20 14 40 37 25 27 93 27 77 48 56 93 65 79 33 91 14 9 95 13 36 24 2 66 31 56 28 49 58 74 17 88 36 46 73 54 18 63 22 2 41 8 50\\n2229 2279\\n\", \"2\\n0 1\\n1 1\\n\", \"4\\n1 0 0 4\\n1 3\\n\", \"4\\n1 0 0 0\\n1 10\\n\", \"3\\n2 1 4\\n3 3\\n\", \"5\\n2 0 2 0 0\\n2 2\\n\", \"4\\n1 2 3 4\\n1 7\\n\", \"2\\n7 1\\n1 6\\n\", \"5\\n1 3 7 8 9\\n4 6\\n\", \"2\\n5 2\\n5 6\\n\", \"2\\n1 0\\n1 2\\n\", \"4\\n2 3 9 10\\n5 14\\n\", \"3\\n1 2 1\\n1 1\\n\", \"4\\n2 3 9 50\\n5 30\\n\", \"3\\n7 1 1\\n6 8\\n\", \"6\\n1 1 2 3 4 5\\n3 9\\n\", \"3\\n4 5 5\\n4 9\\n\", \"6\\n1 2 3 4 5 6\\n1 3\\n\", \"5\\n3 4 3 2 10\\n6 8\\n\", \"5\\n1 1 3 4 6\\n2 2\\n\", \"5\\n5 3 5 8 10\\n2 20\\n\", \"4\\n0 0 5 0\\n3 6\\n\", \"8\\n1 1 1 1 2 2 2 1\\n3 7\\n\", \"3\\n1 100 100\\n101 200\\n\"], \"outputs\": [\"3\\n\", \"4\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"10\\n\", \"6\\n\", \"4\\n\", \"4\\n\", \"4\\n\", \"52\\n\", \"6\\n\", \"8\\n\", \"7\\n\", \"10\\n\", \"7\\n\", \"10\\n\", \"10\\n\", \"8\\n\", \"8\\n\", \"7\\n\", \"63\\n\", \"91\\n\", \"98\\n\", \"57\\n\", \"74\\n\", \"65\\n\", \"85\\n\", \"88\\n\", \"6\\n\", \"5\\n\", \"6\\n\", \"6\\n\", \"53\\n\", \"52\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"3\\n\", \"4\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"4\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"5\\n\", \"3\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"4\\n\", \"0\\n\", \"6\\n\", \"0\\n\"]}", "source": "primeintellect"}
At the beginning of the school year Berland State University starts two city school programming groups, for beginners and for intermediate coders. The children were tested in order to sort them into groups. According to the results, each student got some score from 1 to m points. We know that c_1 schoolchildren got 1 point, c_2 children got 2 points, ..., c_{m} children got m points. Now you need to set the passing rate k (integer from 1 to m): all schoolchildren who got less than k points go to the beginner group and those who get at strictly least k points go to the intermediate group. We know that if the size of a group is more than y, then the university won't find a room for them. We also know that if a group has less than x schoolchildren, then it is too small and there's no point in having classes with it. So, you need to split all schoolchildren into two groups so that the size of each group was from x to y, inclusive. Help the university pick the passing rate in a way that meets these requirements. -----Input----- The first line contains integer m (2 ≤ m ≤ 100). The second line contains m integers c_1, c_2, ..., c_{m}, separated by single spaces (0 ≤ c_{i} ≤ 100). The third line contains two space-separated integers x and y (1 ≤ x ≤ y ≤ 10000). At least one c_{i} is greater than 0. -----Output----- If it is impossible to pick a passing rate in a way that makes the size of each resulting groups at least x and at most y, print 0. Otherwise, print an integer from 1 to m — the passing rate you'd like to suggest. If there are multiple possible answers, print any of them. -----Examples----- Input 5 3 4 3 2 1 6 8 Output 3 Input 5 0 3 3 4 2 3 10 Output 4 Input 2 2 5 3 6 Output 0 -----Note----- In the first sample the beginner group has 7 students, the intermediate group has 6 of them. In the second sample another correct answer is 3. Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0
{"tests": "{\"inputs\": [\"20\\n\", \"5184\\n\", \"1000000\\n\", \"999979\\n\", \"559872\\n\", \"256\\n\", \"279936\\n\", \"1\\n\", \"786432\\n\", \"531441\\n\", \"524288\\n\", \"605000\\n\", \"328509\\n\", \"9602\\n\", \"196608\\n\", \"982081\\n\", \"999983\\n\", \"30492\\n\", \"262144\\n\", \"390625\\n\", \"1009\\n\", \"499979\\n\", \"999958\\n\", \"341\\n\", \"1105\\n\", \"1729\\n\", \"29341\\n\", \"162000\\n\", \"162401\\n\", \"252601\\n\", \"994009\\n\", \"982802\\n\", \"36\\n\", \"6\\n\", \"18\\n\", \"144\\n\", \"2\\n\", \"10\\n\", \"49\\n\", \"589824\\n\", \"900\\n\", \"6444\\n\", \"10609\\n\", \"52488\\n\", \"1\\n\", \"2\\n\", \"3\\n\", \"4\\n\", \"5\\n\", \"6\\n\", \"7\\n\", \"8\\n\", \"9\\n\", \"10\\n\", \"11\\n\", \"12\\n\", \"13\\n\", \"14\\n\"], \"outputs\": [\"10 2\", \"6 4\", \"10 4\", \"999979 0\", \"6 4\", \"2 3\", \"6 4\", \"1 0\\n\", \"6 6\", \"3 5\", \"2 6\", \"110 3\", \"69 3\", \"9602 0\", \"6 5\", \"991 1\", \"999983 0\", \"462 2\", \"2 6\", \"5 3\", \"1009 0\", \"499979 0\", \"999958 0\", \"341 0\", \"1105 0\", \"1729 0\", \"29341 0\", \"30 3\", \"162401 0\", \"252601 0\", \"997 1\", \"1402 2\", \"6 1\", \"6 0\", \"6 2\", \"6 3\", \"2 0\", \"10 0\", \"7 1\", \"6 5\", \"30 1\", \"1074 2\", \"103 1\", \"6 4\", \"1 0\\n\", \"2 0\", \"3 0\", \"2 1\", \"5 0\", \"6 0\", \"7 0\", \"2 3\", \"3 1\", \"10 0\", \"11 0\", \"6 2\", \"13 0\", \"14 0\"]}", "source": "primeintellect"}
JATC's math teacher always gives the class some interesting math problems so that they don't get bored. Today the problem is as follows. Given an integer $n$, you can perform the following operations zero or more times: mul $x$: multiplies $n$ by $x$ (where $x$ is an arbitrary positive integer). sqrt: replaces $n$ with $\sqrt{n}$ (to apply this operation, $\sqrt{n}$ must be an integer). You can perform these operations as many times as you like. What is the minimum value of $n$, that can be achieved and what is the minimum number of operations, to achieve that minimum value? Apparently, no one in the class knows the answer to this problem, maybe you can help them? -----Input----- The only line of the input contains a single integer $n$ ($1 \le n \le 10^6$) — the initial number. -----Output----- Print two integers: the minimum integer $n$ that can be achieved using the described operations and the minimum number of operations required. -----Examples----- Input 20 Output 10 2 Input 5184 Output 6 4 -----Note----- In the first example, you can apply the operation mul $5$ to get $100$ and then sqrt to get $10$. In the second example, you can first apply sqrt to get $72$, then mul $18$ to get $1296$ and finally two more sqrt and you get $6$. Note, that even if the initial value of $n$ is less or equal $10^6$, it can still become greater than $10^6$ after applying one or more operations. Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0
{"tests": "{\"inputs\": [\"3 3\\n2 1 9\\n\", \"4 20\\n10 3 6 3\\n\", \"1 1000000000\\n1\\n\", \"1 1\\n3\\n\", \"50 100\\n74 55 33 5 83 24 75 59 30 36 13 4 62 28 96 17 6 35 45 53 33 11 37 93 34 79 61 72 13 31 44 75 7 3 63 46 18 16 44 89 62 25 32 12 38 55 75 56 61 82\\n\", \"100 10\\n246 286 693 607 87 612 909 312 621 37 801 558 504 914 416 762 187 974 976 123 635 488 416 659 988 998 93 662 92 749 889 78 214 786 735 625 921 372 713 617 975 119 402 411 878 138 548 905 802 762 940 336 529 373 745 835 805 880 816 94 166 114 475 699 974 462 61 337 555 805 968 815 392 746 591 558 740 380 668 29 881 151 387 986 174 923 541 520 998 947 535 651 103 584 664 854 180 852 726 93\\n\", \"2 1\\n1 1000000000\\n\", \"29 2\\n1 3 7 15 31 63 127 255 511 1023 2047 4095 8191 16383 32767 65535 131071 262143 524287 1048575 2097151 4194303 8388607 16777215 33554431 67108863 134217727 268435455 536870911\\n\", \"1 1\\n1000000000\\n\", \"7 6\\n4 20 16 14 3 17 4\\n\", \"2 1\\n3 6\\n\", \"1 1\\n20\\n\", \"5 2\\n86 81 53 25 18\\n\", \"4 1\\n88 55 14 39\\n\", \"3 1\\n2 3 6\\n\", \"3 2\\n4 9 18\\n\", \"5 3\\n6 6 6 13 27\\n\", \"5 1\\n23 8 83 26 18\\n\", \"3 1\\n4 5 6\\n\", \"3 1\\n1 3 6\\n\", \"1 1\\n2\\n\", \"3 2\\n4 5 6\\n\", \"5 1\\n100 200 400 1000 2000\\n\", \"2 1\\n1 4\\n\", \"4 1\\n2 4 8 32\\n\", \"2 10\\n21 42\\n\", \"3 3\\n1 7 13\\n\", \"3 1\\n1 4 6\\n\", \"2 2\\n2 8\\n\", \"1 1\\n4\\n\", \"2 2\\n8 16\\n\", \"3 1\\n4 8 16\\n\", \"3 1\\n3 6 9\\n\", \"2 1\\n4 8\\n\", \"2 2\\n7 14\\n\", \"1 4\\n9\\n\", \"5 3\\n1024 4096 16384 65536 536870913\\n\", \"2 5\\n10 11\\n\", \"2 2\\n3 6\\n\", \"2 2\\n8 11\\n\", \"3 19905705\\n263637263 417905394 108361057\\n\", \"4 25\\n100 11 1 13\\n\", \"10 295206008\\n67980321 440051990 883040288 135744260 96431758 242465794 576630162 972797687 356406646 547451696\\n\", \"4 2\\n45 44 35 38\\n\", \"1 2\\n9\\n\", \"3 6\\n13 26 52\\n\", \"9 30111088\\n824713578 11195876 458715185 731769293 680826358 189542586 550198537 860586039 101083021\\n\", \"3 72014068\\n430005292 807436976 828082746\\n\", \"3 165219745\\n737649884 652879952 506420386\\n\", \"2 60669400\\n95037700 337255240\\n\", \"4 28\\n34 1 86 90\\n\", \"2 1\\n5 10\\n\", \"2 1\\n4 1000000000\\n\", \"2 1\\n2 3\\n\", \"2 1\\n3 5\\n\", \"3 3\\n1 5 20\\n\", \"9 1\\n1 2 4 9 15 32 64 128 1024\\n\"], \"outputs\": [\"1\\n\", \"0\\n\", \"0\\n\", \"1\\n\", \"0\\n\", \"1\\n\", \"29\\n\", \"27\\n\", \"29\\n\", \"1\\n\", \"1\\n\", \"4\\n\", \"4\\n\", \"4\\n\", \"0\\n\", \"1\\n\", \"2\\n\", \"4\\n\", \"1\\n\", \"1\\n\", \"0\\n\", \"0\\n\", \"7\\n\", \"1\\n\", \"1\\n\", \"1\\n\", \"1\\n\", \"1\\n\", \"1\\n\", \"1\\n\", \"1\\n\", \"1\\n\", \"1\\n\", \"1\\n\", \"1\\n\", \"1\\n\", \"24\\n\", \"0\\n\", \"0\\n\", \"1\\n\", \"3\\n\", \"1\\n\", \"0\\n\", \"4\\n\", \"2\\n\", \"1\\n\", \"2\\n\", \"2\\n\", \"1\\n\", \"1\\n\", \"1\\n\", \"2\\n\", \"28\\n\", \"0\\n\", \"1\\n\", \"1\\n\", \"4\\n\"]}", "source": "primeintellect"}
Makes solves problems on Decoforces and lots of other different online judges. Each problem is denoted by its difficulty — a positive integer number. Difficulties are measured the same across all the judges (the problem with difficulty d on Decoforces is as hard as the problem with difficulty d on any other judge). Makes has chosen n problems to solve on Decoforces with difficulties a_1, a_2, ..., a_{n}. He can solve these problems in arbitrary order. Though he can solve problem i with difficulty a_{i} only if he had already solved some problem with difficulty $d \geq \frac{a_{i}}{2}$ (no matter on what online judge was it). Before starting this chosen list of problems, Makes has already solved problems with maximum difficulty k. With given conditions it's easy to see that Makes sometimes can't solve all the chosen problems, no matter what order he chooses. So he wants to solve some problems on other judges to finish solving problems from his list. For every positive integer y there exist some problem with difficulty y on at least one judge besides Decoforces. Makes can solve problems on any judge at any time, it isn't necessary to do problems from the chosen list one right after another. Makes doesn't have too much free time, so he asked you to calculate the minimum number of problems he should solve on other judges in order to solve all the chosen problems from Decoforces. -----Input----- The first line contains two integer numbers n, k (1 ≤ n ≤ 10^3, 1 ≤ k ≤ 10^9). The second line contains n space-separated integer numbers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 10^9). -----Output----- Print minimum number of problems Makes should solve on other judges in order to solve all chosen problems on Decoforces. -----Examples----- Input 3 3 2 1 9 Output 1 Input 4 20 10 3 6 3 Output 0 -----Note----- In the first example Makes at first solves problems 1 and 2. Then in order to solve the problem with difficulty 9, he should solve problem with difficulty no less than 5. The only available are difficulties 5 and 6 on some other judge. Solving any of these will give Makes opportunity to solve problem 3. In the second example he can solve every problem right from the start. Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0
{"tests": "{\"inputs\": [\"2 18 13\\n\", \"4 4 4\\n\", \"3 4 3\\n\", \"9 81 23\\n\", \"11 21 21\\n\", \"55 178 996\\n\", \"8 81 60\\n\", \"3 1000000000 1000000000\\n\", \"1000000000 1000000000 1000000000\\n\", \"1 1000000000 1000000000\\n\", \"6 1000000000 1000000000\\n\", \"6 1000000000 956431324\\n\", \"546 182989 371991\\n\", \"45 654489 357075\\n\", \"97259 999895180 999895180\\n\", \"453145 999531525 999531525\\n\", \"2233224 998602326 998602326\\n\", \"8710006 993275594 993275594\\n\", \"599950915 648757793 648757793\\n\", \"85556375 910931345 910931345\\n\", \"263288720 933114664 933114664\\n\", \"1 1 1\\n\", \"2 1 1\\n\", \"1000000000 1 1\\n\", \"1000000000 1 1000000000\\n\", \"1000000000 1000000000 1\\n\", \"3 3 6\\n\", \"500000000 1000000000 1000000000\\n\", \"369635700 359542423 359542423\\n\", \"9294381 967160417 967160417\\n\", \"77810521 953603507 953603507\\n\", \"56392069 977149846 977149846\\n\", \"29940914 962870226 962870226\\n\", \"98457054 957936620 957936620\\n\", \"26781706 947683080 947683080\\n\", \"95297847 943912393 943912393\\n\", \"599950915 648757793 648757793\\n\", \"878532463 907519567 907519567\\n\", \"452081307 790635695 790635695\\n\", \"320597448 968719119 968719119\\n\", \"894146292 146802543 146802543\\n\", \"322470944 972242878 972242878\\n\", \"896019789 208002095 208002095\\n\", \"469568633 681052815 681052815\\n\", \"338084774 564168943 564168943\\n\", \"18926797 930932717 930932717\\n\", \"234739357 906319479 906319479\\n\", \"488724368 443674657 443674657\\n\", \"380555977 422333785 422333785\\n\", \"77 844667647 844667647\\n\", \"7 908904220 908904220\\n\", \"2 999999999 999999999\\n\", \"7 999999999 999999999\\n\", \"17 999999999 999999999\\n\", \"6 4 4\\n\"], \"outputs\": [\"0.50000000000000000000\\n\", \"0.00000000000000000000\\n\", \"-1\\n\", \"-1\\n\", \"5.00000000000000000000\\n\", \"-1\\n\", \"-1\\n\", \"0.00000000299999980413\\n\", \"0.00000000000000000000\\n\", \"0.00000000000000000000\\n\", \"0.00000002400000020941\\n\", \"-1\\n\", \"235.00000000000000000000\\n\", \"1.50000000000000000000\\n\", \"7.06740589436958543956\\n\", \"157.20761559385573491454\\n\", \"783.92410714272409677505\\n\", \"2912.26086956448853015900\\n\", \"24403439.00000000000000000000\\n\", \"5033417.72727273404598236084\\n\", \"35812126.00000000000000000000\\n\", \"0.00000000000000000000\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"0.00000000000000000000\\n\", \"0.00000000000000000000\\n\", \"-1\\n\", \"5188.50476190447807312012\\n\", \"1529019.61538460850715637207\\n\", \"1026926.27777777612209320068\\n\", \"144272.06060606241226196289\\n\", \"7182313.40000000596046447754\\n\", \"286760.27777777612209320068\\n\", \"8623177.00000000000000000000\\n\", \"24403439.00000000000000000000\\n\", \"14493552.00000000000000000000\\n\", \"169277194.00000000000000000000\\n\", \"1731693.75000000000000000000\\n\", \"-1\\n\", \"1207511.50000000000000000000\\n\", \"-1\\n\", \"105742091.00000000000000000000\\n\", \"113042084.50000000000000000000\\n\", \"70393.28000000119209289551\\n\", \"50525352.00000000000000000000\\n\", \"-1\\n\", \"20888904.00000000000000000000\\n\", \"0.00000492264608453752\\n\", \"0.00000000000000000000\\n\", \"0.00000000200000016548\\n\", \"0.00000003500000023138\\n\", \"0.00000010199999778138\\n\", \"-1\\n\"]}", "source": "primeintellect"}
Arkadiy has lots square photos with size a × a. He wants to put some of them on a rectangular wall with size h × w. The photos which Arkadiy will put on the wall must form a rectangular grid and the distances between neighboring vertically and horizontally photos and also the distances between outside rows and columns of photos to the nearest bound of the wall must be equal to x, where x is some non-negative real number. Look on the picture below for better understanding of the statement. [Image] Arkadiy haven't chosen yet how many photos he would put on the wall, however, he want to put at least one photo. Your task is to determine the minimum value of x which can be obtained after putting photos, or report that there is no way to put positive number of photos and satisfy all the constraints. Suppose that Arkadiy has enough photos to make any valid arrangement according to the constraints. Note that Arkadiy wants to put at least one photo on the wall. The photos should not overlap, should completely lie inside the wall bounds and should have sides parallel to the wall sides. -----Input----- The first line contains three integers a, h and w (1 ≤ a, h, w ≤ 10^9) — the size of photos and the height and the width of the wall. -----Output----- Print one non-negative real number — the minimum value of x which can be obtained after putting the photos on the wall. The absolute or the relative error of the answer must not exceed 10^{ - 6}. Print -1 if there is no way to put positive number of photos and satisfy the constraints. -----Examples----- Input 2 18 13 Output 0.5 Input 4 4 4 Output 0 Input 3 4 3 Output -1 -----Note----- In the first example Arkadiy can put 7 rows of photos with 5 photos in each row, so the minimum value of x equals to 0.5. In the second example Arkadiy can put only 1 photo which will take the whole wall, so the minimum value of x equals to 0. In the third example there is no way to put positive number of photos and satisfy the constraints described in the statement, so the answer is -1. Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0
{"tests": "{\"inputs\": [\"4 1\\n2 1 4 2\\n\", \"5 2\\n2 2 4 5 3\\n\", \"3 10\\n1 2 3\\n\", \"1 1\\n2\\n\", \"1 2\\n2\\n\", \"10 6\\n8 5 1 6 6 5 10 6 9 8\\n\", \"7 2\\n1 2 2 1 1 1 1\\n\", \"8 2\\n1 1 3 2 3 2 3 2\\n\", \"10 9\\n6 4 7 1 8 9 5 9 4 5\\n\", \"6 1\\n2 3 3 1 1 2\\n\", \"4 1\\n2 1 1 2\\n\", \"5 1\\n3 2 1 2 1\\n\", \"5 3\\n1 2 3 2 3\\n\", \"1 1000000\\n1\\n\", \"6 3\\n1 2 3 2 3 2\\n\", \"3 2\\n1 2 3\\n\", \"6 2\\n5 3 2 4 4 2\\n\", \"6 1\\n5 2 1 4 2 1\\n\", \"6 1\\n2 2 2 1 1 1\\n\", \"5 2\\n3 1 1 2 2\\n\", \"2 2\\n1 2\\n\", \"30 1\\n2 2 2 2 2 3 3 3 1 1 1 1 3 3 3 3 3 3 3 3 3 3 3 2 2 2 2 1 1 1\\n\", \"2 1\\n1 2\\n\", \"5 3\\n1 2 2 3 3\\n\", \"10 1000000\\n1 2 3 4 5 6 7 8 9 10\\n\", \"6 1\\n3 1 2 2 3 1\\n\", \"5 1\\n2 3 3 1 1\\n\", \"9 1\\n2 3 3 1 4 1 3 2 1\\n\", \"10 9\\n8 9 1 1 1 1 1 1 1 9\\n\", \"13 2\\n3 3 3 2 1 1 1 1 1 2 3 2 2\\n\", \"5 1\\n2 3 1 3 1\\n\", \"8 7\\n6 7 2 2 4 5 4 4\\n\", \"2 7\\n6 7\\n\", \"3 5\\n9 5 7\\n\", \"6 2\\n1 2 1 2 1 2\\n\", \"6 3\\n1000 2 3 2 2 3\\n\", \"10 5\\n1 1 1 1 1 5 5 5 5 5\\n\", \"4 9\\n4 9 9 4\\n\", \"4 1\\n2 1 3 3\\n\", \"19 3\\n1 2 3 1 2 3 1 2 3 5 5 5 5 5 5 5 5 2 3\\n\", \"15 1\\n2 5 5 1 2 1 5 2 1 5 2 1 5 1 5\\n\", \"14 1\\n2 5 5 1 2 1 5 2 1 5 2 1 5 1\\n\", \"8 5\\n1 2 5 1 2 5 2 5\\n\", \"5 1000000\\n1 2 1000000 2 1\\n\", \"8 2\\n1 2 1 3 2 3 3 3\\n\", \"9 10\\n4 9 7 3 3 3 10 3 10\\n\", \"6 2\\n5 3 9 2 10 1\\n\", \"10 4\\n7 5 4 4 1 5 7 9 10 6\\n\", \"2 1\\n9 1\\n\", \"3 7\\n5 7 1\\n\", \"6 3\\n1 3 5 4 2 3\\n\", \"7 1\\n7 3 1 4 5 8 5\\n\", \"2 3\\n6 3\\n\", \"10 8\\n2 8 8 9 6 9 1 3 2 4\\n\", \"6 1\\n1 7 8 4 8 6\\n\"], \"outputs\": [\"2\\n\", \"-1\\n\", \"4\\n\", \"3\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"3\\n\", \"-1\\n\", \"3\\n\", \"-1\\n\", \"2\\n\", \"2\\n\", \"2\\n\", \"2\\n\", \"1\\n\", \"-1\\n\", \"2\\n\", \"2\\n\", \"1\\n\", \"1\\n\", \"2\\n\", \"-1\\n\", \"2\\n\", \"11\\n\", \"3\\n\", \"3\\n\", \"3\\n\", \"-1\\n\", \"3\\n\", \"3\\n\", \"6\\n\", \"6\\n\", \"9\\n\", \"1\\n\", \"2\\n\", \"1\\n\", \"-1\\n\", \"2\\n\", \"2\\n\", \"5\\n\", \"5\\n\", \"2\\n\", \"1\\n\", \"1\\n\", \"3\\n\", \"3\\n\", \"-1\\n\", \"9\\n\", \"5\\n\", \"-1\\n\", \"3\\n\", \"6\\n\", \"-1\\n\", \"-1\\n\"]}", "source": "primeintellect"}
Alice and Bob got very bored during a long car trip so they decided to play a game. From the window they can see cars of different colors running past them. Cars are going one after another. The game rules are like this. Firstly Alice chooses some color A, then Bob chooses some color B (A ≠ B). After each car they update the number of cars of their chosen color that have run past them. Let's define this numbers after i-th car cnt_{A}(i) and cnt_{B}(i). If cnt_{A}(i) > cnt_{B}(i) for every i then the winner is Alice. If cnt_{B}(i) ≥ cnt_{A}(i) for every i then the winner is Bob. Otherwise it's a draw. Bob knows all the colors of cars that they will encounter and order of their appearance. Alice have already chosen her color A and Bob now wants to choose such color B that he will win the game (draw is not a win). Help him find this color. If there are multiple solutions, print any of them. If there is no such color then print -1. -----Input----- The first line contains two integer numbers n and A (1 ≤ n ≤ 10^5, 1 ≤ A ≤ 10^6) – number of cars and the color chosen by Alice. The second line contains n integer numbers c_1, c_2, ..., c_{n} (1 ≤ c_{i} ≤ 10^6) — colors of the cars that Alice and Bob will encounter in the order of their appearance. -----Output----- Output such color B (1 ≤ B ≤ 10^6) that if Bob chooses it then he will win the game. If there are multiple solutions, print any of them. If there is no such color then print -1. It is guaranteed that if there exists any solution then there exists solution with (1 ≤ B ≤ 10^6). -----Examples----- Input 4 1 2 1 4 2 Output 2 Input 5 2 2 2 4 5 3 Output -1 Input 3 10 1 2 3 Output 4 -----Note----- Let's consider availability of colors in the first example: cnt_2(i) ≥ cnt_1(i) for every i, and color 2 can be the answer. cnt_4(2) < cnt_1(2), so color 4 isn't the winning one for Bob. All the other colors also have cnt_{j}(2) < cnt_1(2), thus they are not available. In the third example every color is acceptable except for 10. Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0
{"tests": "{\"inputs\": [\"aabc\\n\", \"aabcd\\n\", \"u\\n\", \"ttttt\\n\", \"xxxvvvxxvv\\n\", \"wrwrwfrrfrffrrwwwffffwrfrrwfrrfrwwfwfrwfwfwffwrrwfrrrwwwfrrrwfrrfwrwwrwrrrffffwrrrwrwfffwrffrwwwrwww\\n\", \"aabbcccdd\\n\", \"baaab\\n\", \"aaabbbhhlhlugkjgckj\\n\", \"aabcc\\n\", \"bbbcccddd\\n\", \"zzzozzozozozoza\\n\", \"aaabb\\n\", \"zza\\n\", \"azzzbbb\\n\", \"bbaaccddc\\n\", \"aaabbbccc\\n\", \"aaaaabbccdd\\n\", \"aaabbbcccdd\\n\", \"aaaabbcccccdd\\n\", \"aaacccb\\n\", \"abcd\\n\", \"abb\\n\", \"abababccc\\n\", \"aaadd\\n\", \"qqqqaaaccdd\\n\", \"affawwzzw\\n\", \"hack\\n\", \"bbaaa\\n\", \"ababa\\n\", \"aaazzzz\\n\", \"aabbbcc\\n\", \"successfullhack\\n\", \"aaabbccdd\\n\", \"zaz\\n\", \"aaabbbcccdddeee\\n\", \"zaaz\\n\", \"acc\\n\", \"abbbzzz\\n\", \"zzzzazazazazazznnznznnznnznznzaajzjajjjjanaznnzanzppnzpaznnpanz\\n\", \"aaaaabbbcccdddd\\n\", \"aaaaabbccdddd\\n\", \"abababa\\n\", \"azz\\n\", \"abbbccc\\n\", \"aaacccddd\\n\", \"asbbsha\\n\", \"bababab\\n\", \"aaabbccddbbccddaaaaaaaaaaaaaaaa\\n\", \"aaabbccddbbccddaaaaaaaaaaaaaa\\n\", \"aaabbccddbbccddaaaaaaaaaaaa\\n\", \"ooooo\\n\", \"aaabbccddbbccddaaaaaaaaaa\\n\", \"aaabbccddbbccddaaaaaaaa\\n\", \"aaabbccddbbccddaa\\n\"], \"outputs\": [\"abba\\n\", \"abcba\\n\", \"u\\n\", \"ttttt\\n\", \"vvvxxxxvvv\\n\", \"fffffffffffffffrrrrrrrrrrrrrrrrrrwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwrrrrrrrrrrrrrrrrrrfffffffffffffff\\n\", \"abcdcdcba\\n\", \"ababa\\n\", \"aabbghjklclkjhgbbaa\\n\", \"acbca\\n\", \"bbcdcdcbb\\n\", \"aoozzzzozzzzooa\\n\", \"ababa\\n\", \"zaz\\n\", \"abzbzba\\n\", \"abcdcdcba\\n\", \"aabcbcbaa\\n\", \"aabcdadcbaa\\n\", \"aabcdbdcbaa\\n\", \"aabccdcdccbaa\\n\", \"aacbcaa\\n\", \"abba\\n\", \"bab\\n\", \"aabcbcbaa\\n\", \"adada\\n\", \"acdqqaqqdca\\n\", \"afwzwzwfa\\n\", \"acca\\n\", \"ababa\\n\", \"ababa\\n\", \"azzazza\\n\", \"abcbcba\\n\", \"accelsufuslecca\\n\", \"abcdadcba\\n\", \"zaz\\n\", \"aabbcdecedcbbaa\\n\", \"azza\\n\", \"cac\\n\", \"abzbzba\\n\", \"aaaaaaajjjnnnnnnnnppzzzzzzzzzzznzzzzzzzzzzzppnnnnnnnnjjjaaaaaaa\\n\", \"aaabcddbddcbaaa\\n\", \"aabcddaddcbaa\\n\", \"aabbbaa\\n\", \"zaz\\n\", \"abcbcba\\n\", \"aacdcdcaa\\n\", \"abshsba\\n\", \"abbabba\\n\", \"aaaaaaaaabbccddaddccbbaaaaaaaaa\\n\", \"aaaaaaaabbccddaddccbbaaaaaaaa\\n\", \"aaaaaaabbccddaddccbbaaaaaaa\\n\", \"ooooo\\n\", \"aaaaaabbccddaddccbbaaaaaa\\n\", \"aaaaabbccddaddccbbaaaaa\\n\", \"aabbccddaddccbbaa\\n\"]}", "source": "primeintellect"}
A string is called palindrome if it reads the same from left to right and from right to left. For example "kazak", "oo", "r" and "mikhailrubinchikkihcniburliahkim" are palindroms, but strings "abb" and "ij" are not. You are given string s consisting of lowercase Latin letters. At once you can choose any position in the string and change letter in that position to any other lowercase letter. So after each changing the length of the string doesn't change. At first you can change some letters in s. Then you can permute the order of letters as you want. Permutation doesn't count as changes. You should obtain palindrome with the minimal number of changes. If there are several ways to do that you should get the lexicographically (alphabetically) smallest palindrome. So firstly you should minimize the number of changes and then minimize the palindrome lexicographically. -----Input----- The only line contains string s (1 ≤ |s| ≤ 2·10^5) consisting of only lowercase Latin letters. -----Output----- Print the lexicographically smallest palindrome that can be obtained with the minimal number of changes. -----Examples----- Input aabc Output abba Input aabcd Output abcba Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0
{"tests": "{\"inputs\": [\"11\\n-1 2\\n\", \"4600\\n52 149\\n\", \"4\\n9 9\\n\", \"9943\\n-97653 -1777\\n\", \"411603622\\n-1675 797\\n\", \"169842662\\n42126 4592\\n\", \"64860\\n-46171 -65442\\n\", \"31399\\n-23985 -64005\\n\", \"72515\\n-1684 -2028\\n\", \"55545\\n6440 3414\\n\", \"12\\n-3387 14\\n\", \"25\\n360 440\\n\", \"137273866\\n-75883 -100000\\n\", \"162957408\\n69008 -80583\\n\", \"12896\\n-7245 99955\\n\", \"89389\\n91529 73854\\n\", \"49929\\n26391 -29574\\n\", \"36023\\n45523 20312\\n\", \"12\\n1 20285\\n\", \"59620\\n-36256 82984\\n\", \"896454475\\n-75982 -100000\\n\", \"394508031\\n99658 84934\\n\", \"10\\n84908 18\\n\", \"43733\\n-23957 2374\\n\", \"55685\\n-3668 1081\\n\", \"8057\\n-30887 20542\\n\", \"12\\n-15 20515\\n\", \"31261\\n-14433 16828\\n\", \"378803379\\n97242 -89159\\n\", \"312486645\\n86212 34851\\n\", \"10\\n-15 -34825\\n\", \"7\\n-10 12\\n\", \"18015\\n-23089 961\\n\", \"82995\\n-71582 -63658\\n\", \"2\\n0 1\\n\", \"10\\n15 -34825\\n\", \"1\\n100000 100000\\n\", \"42195\\n40000 -2194\\n\", \"42195\\n40000 -2196\\n\", \"1000000000\\n1 1\\n\", \"3139\\n23985 -64005\\n\", \"31\\n23985 -64005\\n\", \"7\\n4 8\\n\", \"7\\n8 4\\n\", \"625\\n-3999 5999\\n\", \"5\\n-1 -2\\n\", \"555\\n-101 232\\n\", \"555\\n-101 232\\n\", \"73\\n24441 -57030\\n\", \"3\\n100000 100000\\n\", \"3\\n1 1\\n\", \"5\\n1 1\\n\", \"3\\n1 0\\n\", \"3\\n-99999 100000\\n\", \"4\\n1 1\\n\"], \"outputs\": [\"3\\n7 4\\n2 10\\n-1 2\\n\", \"-1\\n\", \"5\\n1 3\\n4 2\\n4 6\\n6 8\\n9 9\\n\", \"10\\n\", \"2\\n\", \"2\\n\", \"-1\\n\", \"4\\n\", \"2\\n\", \"2\\n\", \"-1\\n\", \"32\\n\", \"-1\\n\", \"-1\\n\", \"9\\n\", \"3\\n\", \"3\\n\", \"3\\n\", \"1691\\n\", \"2\\n\", \"2\\n\", \"2\\n\", \"8493\\n\", \"3\\n\", \"3\\n\", \"7\\n\", \"1711\\n\", \"1\\n\", \"3\\n\", \"3\\n\", \"3484\\n\", \"4\\n\", \"2\\n\", \"2\\n\", \"-1\\n\", \"3484\\n\", \"200000\\n\", \"2\\n\", \"2\\n\", \"2\\n\", \"30\\n\", \"2840\\n\", \"2\\n\", \"2\\n\", \"16\\n\", \"3\\n\", \"3\\n\", \"3\\n\", \"1117\\n\", \"66668\\n\", \"2\\n\", \"2\\n\", \"3\\n\", \"66667\\n\", \"2\\n\"]}", "source": "primeintellect"}
Jumbo Takahashi will play golf on an infinite two-dimensional grid. The ball is initially at the origin (0, 0), and the goal is a grid point (a point with integer coordinates) (X, Y). In one stroke, Jumbo Takahashi can perform the following operation: - Choose a grid point whose Manhattan distance from the current position of the ball is K, and send the ball to that point. The game is finished when the ball reaches the goal, and the score will be the number of strokes so far. Jumbo Takahashi wants to finish the game with the lowest score possible. Determine if the game can be finished. If the answer is yes, find one way to bring the ball to the goal with the lowest score possible. What is Manhattan distance? The Manhattan distance between two points (x_1, y_1) and (x_2, y_2) is defined as |x_1-x_2|+|y_1-y_2|. -----Constraints----- - All values in input are integers. - 1 \leq K \leq 10^9 - -10^5 \leq X, Y \leq 10^5 - (X, Y) \neq (0, 0) -----Input----- Input is given from Standard Input in the following format: K X Y -----Output----- If the game cannot be finished, print -1. If the game can be finished, print one way to bring the ball to the destination with the lowest score possible, in the following format: s x_1 y_1 x_2 y_2 . . . x_s y_s Here, s is the lowest score possible, and (x_i, y_i) is the position of the ball just after the i-th stroke. -----Sample Input----- 11 -1 2 -----Sample Output----- 3 7 4 2 10 -1 2 - The Manhattan distance between (0, 0) and (7, 4) is |0-7|+|0-4|=11. - The Manhattan distance between (7, 4) and (2, 10) is |7-2|+|4-10|=11. - The Manhattan distance between (2, 10) and (-1, 2) is |2-(-1)|+|10-2|=11. Thus, this play is valid. Also, there is no way to finish the game with less than three strokes. Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0
{"tests": "{\"inputs\": [\"0 0 4\\n6 0 4\\n\", \"0 0 5\\n11 0 5\\n\", \"0 0 10\\n9 0 1\\n\", \"0 0 2\\n2 2 2\\n\", \"0 0 10\\n5 0 5\\n\", \"-9 8 7\\n-9 8 5\\n\", \"-60 -85 95\\n-69 -94 95\\n\", \"159 111 998\\n161 121 1023\\n\", \"6008 8591 6693\\n5310 8351 7192\\n\", \"-13563 -6901 22958\\n-19316 -16534 18514\\n\", \"-875463 79216 524620\\n-891344 76571 536598\\n\", \"-8907963 -8149654 8808560\\n-8893489 -8125053 8830600\\n\", \"-56452806 56199829 45467742\\n-56397667 56292048 45489064\\n\", \"-11786939 388749051 844435993\\n-11696460 388789113 844535886\\n\", \"-944341103 -3062765 891990581\\n-943884414 -3338765 891882754\\n\", \"808468733 166975547 650132512\\n807140196 169714842 655993403\\n\", \"-16 -107 146\\n75 25 19\\n\", \"468534418 -876402362 779510\\n392125478 -856995174 1\\n\", \"368831644 125127030 959524552\\n690900461 -368007601 1000000000\\n\", \"638572730 86093565 553198855\\n-151099010 -5582761 1000000000\\n\", \"567845488 379750385 112902105\\n567845488 379750385 112902105\\n\", \"817163584 -145230792 164258581\\n826720200 -149804696 98\\n\", \"-812130546 -209199732 799576707\\n-728169661 -278950375 4385\\n\", \"-36140638 -933845433 250828868\\n90789911 -245130908 328547\\n\", \"34537868 -531411810 591044372\\n34536968 -531411968 58\\n\", \"-410889750 -716765873 303980004\\n-410889749 -716765874 7\\n\", \"-304 -310 476\\n120 -294 1\\n\", \"-999999999 0 1000000000\\n999999999 0 1000000000\\n\", \"-1000000000 0 1000000000\\n999999999 0 1000000000\\n\", \"-99999999 0 100000000\\n99999999 0 100000000\\n\", \"-999999999 0 1000000000\\n999999999 1 1000000000\\n\", \"-1000000000 0 999999999\\n999999997 0 999999999\\n\", \"0 1000000000 1\\n0 0 1000000000\\n\", \"10000000 0 10000001\\n-10000000 0 10000000\\n\", \"1000000000 0 1000000000\\n-999999999 1 1000000000\\n\", \"44721 999999999 400000000\\n0 0 600000000\\n\", \"-1000000000 1 1000000000\\n999999998 0 1000000000\\n\", \"0 0 500000000\\n431276 999999907 500000000\\n\", \"1000000000 0 1000000000\\n-999999998 -87334 1000000000\\n\", \"0 0 10\\n0 0 25\\n\", \"0 0 1000000000\\n707106781 707106781 1\\n\", \"100 10 10\\n100 20 10\\n\", \"1000000000 0 1000000000\\n-999999998 -88334 1000000000\\n\", \"0 0 999999999\\n1000000000 0 2\\n\", \"-99999999 0 100000000\\n99999999 1 100000000\\n\", \"1000000000 0 1000000000\\n-999999999 60333 1000000000\\n\", \"1000000000 0 1000000000\\n-999999999 58333 1000000000\\n\", \"1000000000 0 1000000000\\n-999999998 -85334 1000000000\\n\", \"0 0 1000000000\\n999999999 1 2\\n\", \"0 0 1000000000\\n999999998 0 3\\n\", \"141 9999 5000\\n0 0 5000\\n\", \"-1000000000 0 1000000000\\n999999998 0 1000000000\\n\", \"0 0 10\\n1 0 10\\n\", \"0 0 1000000000\\n707106782 707106781 2\\n\"], \"outputs\": [\"7.25298806364175601379\\n\", \"0.00000000000000000000\\n\", \"3.14159265358979311600\\n\", \"2.28318530717958647659\\n\", \"78.53981633974482789995\\n\", \"78.53981633974482789995\\n\", \"25936.37843115316246844770\\n\", \"3129038.84934604830277748988\\n\", \"138921450.46886559338599909097\\n\", \"868466038.83295116270892322063\\n\", \"862534134678.47474157810211181641\\n\", \"243706233220003.66226196289062500000\\n\", \"6487743741270471.46582031250000000000\\n\", \"2240182216213578196.25000000000000000000\\n\", \"2498325849744150942.00000000000000000000\\n\", \"1327864139649690571.00000000000000000000\\n\", \"75.73941676175987183783\\n\", \"0.00000000000000000000\\n\", \"1877639096067727828.75000000000000000000\\n\", \"648156847022339121.87500000000000000000\\n\", \"40045521256826535.57031250000000000000\\n\", \"30171.85584507637308604444\\n\", \"60407250.40157159973750822246\\n\", \"0.00000000000000000000\\n\", \"10568.31768667606404221715\\n\", \"153.93804002589986268390\\n\", \"3.14159265358979311600\\n\", \"119256.95877838134765625000\\n\", \"42163.70213317871093750000\\n\", \"37712.36160683631896972656\\n\", \"119256.95874786376953125000\\n\", \"42163.70211410522460937500\\n\", \"1.57079632649338855020\\n\", \"4216.37028734199702739716\\n\", \"42163.70212173461914062500\\n\", \"0.00188343226909637451\\n\", \"119256.95874786376953125000\\n\", \"0.33492207527160644531\\n\", \"1199.53919601440429687500\\n\", \"314.15926535897931159980\\n\", \"2.09224628662147114737\\n\", \"122.83696986087568455565\\n\", \"461.20431423187255859375\\n\", \"2.45673939563023624650\\n\", \"37712.36153602600097656250\\n\", \"1138.08371162414550781250\\n\", \"2432.73669052124023437500\\n\", \"3207.25725555419921875000\\n\", \"10.10963121370591567653\\n\", \"25.17685179846658691770\\n\", \"0.04272695172407026121\\n\", \"119256.95877838134765625000\\n\", \"294.16760182010623145277\\n\", \"4.52465731000908907454\\n\"]}", "source": "primeintellect"}
You are given two circles. Find the area of their intersection. -----Input----- The first line contains three integers x_1, y_1, r_1 ( - 10^9 ≤ x_1, y_1 ≤ 10^9, 1 ≤ r_1 ≤ 10^9) — the position of the center and the radius of the first circle. The second line contains three integers x_2, y_2, r_2 ( - 10^9 ≤ x_2, y_2 ≤ 10^9, 1 ≤ r_2 ≤ 10^9) — the position of the center and the radius of the second circle. -----Output----- Print the area of the intersection of the circles. The answer will be considered correct if the absolute or relative error doesn't exceed 10^{ - 6}. -----Examples----- Input 0 0 4 6 0 4 Output 7.25298806364175601379 Input 0 0 5 11 0 5 Output 0.00000000000000000000 Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0
{"tests": "{\"inputs\": [\"3\\n1 1\\n3 1 2\\n\", \"3\\n1 1\\n3 1 3\\n\", \"3\\n1 1\\n2 0 0\\n\", \"2\\n1\\n487981126 805590708\\n\", \"5\\n1 1 1 4\\n28 0 0 0 0\\n\", \"2\\n1\\n91 0\\n\", \"10\\n1 1 1 1 1 1 1 1 1\\n64 0 0 0 0 0 0 0 0 0\\n\", \"50\\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\\n51 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\\n\", \"100\\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\\n71 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\\n\", \"2\\n1\\n3 0\\n\", \"10\\n1 1 1 1 1 1 1 1 1\\n69 0 0 0 0 0 0 0 0 0\\n\", \"50\\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\\n9 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\\n\", \"100\\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\\n29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\\n\", \"2\\n1\\n96 0\\n\", \"10\\n1 1 2 4 4 3 6 1 5\\n44 0 0 0 0 0 0 0 0 0\\n\", \"50\\n1 1 2 3 1 2 4 6 3 7 7 5 12 13 7 7 4 10 14 8 18 14 19 22 11 4 17 14 11 12 11 18 19 28 9 27 9 7 7 13 17 24 21 9 33 11 44 45 33\\n67 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\\n\", \"100\\n1 2 1 2 2 5 3 8 9 4 4 7 2 4 6 3 13 2 10 10 17 15 15 9 17 8 18 18 29 7 1 13 32 13 29 12 14 12 24 21 12 31 4 36 5 39 33 6 37 40 2 29 39 42 18 40 26 44 52 22 50 49 1 21 46 59 25 39 38 42 34 45 3 70 57 60 73 76 38 69 38 24 30 40 70 21 38 16 30 41 40 31 11 65 9 46 3 70 85\\n50 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\\n\", \"2\\n1\\n3 0\\n\", \"10\\n1 2 3 4 5 6 7 8 9\\n92 0 0 0 0 0 0 0 0 0\\n\", \"50\\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49\\n73 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\\n\", \"100\\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99\\n62 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\\n\", \"2\\n1\\n10 0\\n\", \"10\\n1 2 3 4 5 6 7 8 9\\n3 0 0 0 0 0 0 0 0 0\\n\", \"50\\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49\\n60 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\\n\", \"100\\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99\\n58 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\\n\", \"2\\n1\\n74 73\\n\", \"10\\n1 1 1 1 1 1 1 1 1\\n77 10 36 51 50 82 8 56 7 26\\n\", \"50\\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\\n65 78 71 17 56 55 65 58 64 71 23 22 82 99 79 54 10 6 52 68 99 40 21 100 47 11 72 68 13 45 1 82 73 60 51 16 28 82 17 64 94 39 58 62 99 7 92 95 13 92\\n\", \"100\\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\\n0 0 63 70 92 75 4 96 52 33 86 57 53 85 91 62 23 0 28 37 41 69 26 64 7 100 41 19 70 60 1 50 12 98 62 45 77 15 72 25 84 70 38 28 21 58 51 23 40 88 34 85 36 95 65 14 4 13 98 73 93 78 70 29 44 73 49 60 54 49 60 45 99 91 19 67 44 42 14 10 83 74 78 67 61 91 92 23 94 59 36 82 61 33 59 59 80 95 25 33\\n\", \"2\\n1\\n59 12\\n\", \"10\\n1 1 1 1 1 1 1 1 1\\n9 52 36 0 19 79 13 3 89 31\\n\", \"50\\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\\n43 93 92 69 61 67 69 2 81 41 4 68 10 19 96 14 48 47 85 5 78 58 57 72 75 92 12 33 63 14 7 50 80 88 24 97 38 18 70 45 73 74 40 6 36 71 66 68 1 64\\n\", \"100\\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\\n79 29 58 69 56 0 57 27 97 99 80 98 54 7 93 65 29 34 88 74 23 0 23 60 93 24 27 66 42 40 29 89 7 98 49 18 29 49 64 59 56 43 33 88 33 72 81 0 54 70 91 33 61 27 55 37 43 27 90 87 88 90 38 51 66 84 78 47 8 98 1 18 36 23 99 30 61 76 15 30 85 15 41 53 41 67 22 34 42 99 100 31 18 20 26 98 11 38 39 82\\n\", \"2\\n1\\n48 32\\n\", \"10\\n1 2 3 1 3 4 2 4 6\\n68 5 44 83 46 92 32 51 2 89\\n\", \"50\\n1 2 1 4 1 2 1 8 4 1 9 10 9 11 4 7 14 3 10 2 11 4 21 11 12 17 2 2 10 29 13 1 11 4 5 22 36 10 5 11 7 17 12 31 1 1 42 25 46\\n13 58 22 90 81 91 48 25 61 76 92 86 89 94 8 97 74 16 21 27 100 92 57 87 67 8 89 61 22 3 86 0 95 89 9 59 88 65 30 42 33 63 67 46 66 17 89 49 60 59\\n\", \"2\\n1\\n76 37\\n\", \"10\\n1 2 3 4 5 6 7 8 9\\n68 35 94 38 33 77 81 65 90 71\\n\", \"50\\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49\\n82 30 98 3 92 42 28 41 90 67 83 5 2 77 38 39 96 22 18 37 88 42 91 34 39 2 89 72 100 18 11 79 77 82 10 48 61 39 80 13 61 76 87 17 58 83 21 19 46 65\\n\", \"2\\n1\\n83 79\\n\", \"10\\n1 2 3 4 5 6 7 8 9\\n13 35 33 86 0 73 15 3 74 100\\n\", \"50\\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49\\n67 8 36 45 5 65 80 3 0 96 13 98 96 46 87 9 31 16 36 0 84 4 65 64 96 70 10 72 85 53 28 67 57 50 38 4 97 38 63 22 4 62 81 50 83 52 82 84 63 71\\n\", \"2\\n1\\n472137027 495493860\\n\", \"10\\n1 1 1 1 1 1 1 1 1\\n841306067 40156990 957137872 873138809 930194285 483020948 155552934 851771372 401782261 183067980\\n\", \"2\\n1\\n39002084 104074590\\n\", \"10\\n1 1 1 1 1 1 1 1 1\\n204215424 439630330 408356675 696347865 314256806 345663675 226463233 883526778 85214111 989916765\\n\", \"2\\n1\\n529696753 688701773\\n\", \"10\\n1 2 1 2 1 2 6 7 7\\n137037598 441752911 759804266 209515812 234899988 38667789 389711866 680023681 753276683 251101203\\n\", \"2\\n1\\n978585177 622940364\\n\", \"10\\n1 2 3 4 5 6 7 8 9\\n285667137 980023651 876517010 722834015 294393310 199165086 321915358 105753310 222692362 161158342\\n\", \"2\\n1\\n293175439 964211398\\n\", \"10\\n1 2 3 4 5 6 7 8 9\\n572824925 20293494 105606574 673623641 152420817 620499198 326794512 710530240 321931146 608064601\\n\", \"3\\n1 1\\n0 0 0\\n\", \"15\\n1 1 2 2 3 3 4 4 5 5 6 6 7 7\\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\\n\"], \"outputs\": [\"3\\n\", \"4\\n\", \"1\\n\", \"1293571834\\n\", \"10\\n\", \"91\\n\", \"8\\n\", \"2\\n\", \"1\\n\", \"3\\n\", \"8\\n\", \"1\\n\", \"1\\n\", \"96\\n\", \"11\\n\", \"3\\n\", \"2\\n\", \"3\\n\", \"92\\n\", \"73\\n\", \"62\\n\", \"10\\n\", \"3\\n\", \"60\\n\", \"58\\n\", \"147\\n\", \"82\\n\", \"100\\n\", \"100\\n\", \"71\\n\", \"89\\n\", \"97\\n\", \"100\\n\", \"80\\n\", \"181\\n\", \"187\\n\", \"113\\n\", \"652\\n\", \"2598\\n\", \"162\\n\", \"432\\n\", \"2536\\n\", \"967630887\\n\", \"957137872\\n\", \"143076674\\n\", \"989916765\\n\", \"1218398526\\n\", \"759804266\\n\", \"1601525541\\n\", \"4170119581\\n\", \"1257386837\\n\", \"4112589148\\n\", \"0\\n\", \"2\\n\"]}", "source": "primeintellect"}
Bandits appeared in the city! One of them is trying to catch as many citizens as he can. The city consists of $n$ squares connected by $n-1$ roads in such a way that it is possible to reach any square from any other square. The square number $1$ is the main square. After Sunday walk all the roads were changed to one-way roads in such a way that it is possible to reach any square from the main square. At the moment when the bandit appeared on the main square there were $a_i$ citizens on the $i$-th square. Now the following process will begin. First, each citizen that is currently on a square with some outgoing one-way roads chooses one of such roads and moves along it to another square. Then the bandit chooses one of the one-way roads outgoing from the square he is located and moves along it. The process is repeated until the bandit is located on a square with no outgoing roads. The bandit catches all the citizens on that square. The bandit wants to catch as many citizens as possible; the citizens want to minimize the number of caught people. The bandit and the citizens know positions of all citizens at any time, the citizens can cooperate. If both sides act optimally, how many citizens will be caught? -----Input----- The first line contains a single integer $n$ — the number of squares in the city ($2 \le n \le 2\cdot10^5$). The second line contains $n-1$ integers $p_2, p_3 \dots p_n$ meaning that there is a one-way road from the square $p_i$ to the square $i$ ($1 \le p_i < i$). The third line contains $n$ integers $a_1, a_2, \dots, a_n$ — the number of citizens on each square initially ($0 \le a_i \le 10^9$). -----Output----- Print a single integer — the number of citizens the bandit will catch if both sides act optimally. -----Examples----- Input 3 1 1 3 1 2 Output 3 Input 3 1 1 3 1 3 Output 4 -----Note----- In the first example the citizens on the square $1$ can split into two groups $2 + 1$, so that the second and on the third squares will have $3$ citizens each. In the second example no matter how citizens act the bandit can catch at least $4$ citizens. Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0.25
{"tests": "{\"inputs\": [\"7\\nreading\\ntrading\\n\", \"5\\nsweet\\nsheep\\n\", \"3\\ntoy\\ntry\\n\", \"5\\nspare\\nspars\\n\", \"1\\na\\nb\\n\", \"1\\nz\\ny\\n\", \"2\\nab\\nac\\n\", \"2\\nba\\nca\\n\", \"2\\nac\\ncb\\n\", \"100\\neebdeddddbecdbddaaecbbaccbecdeacedddcaddcdebedbabbceeeadecadbbeaecdaeabbceacbdbdbbdacebbbccdcbbeedbe\\ndacdeebebeaeaacdeedadbcbaedcbddddddedacbabeddebaaebbdcebebaaccbaeccbecdbcbceadaaecadecbadbcddcdabecd\\n\", \"250\\niiffiehchidfgigdbcciahdehjjfacbbaaadagaibjjcehjcbjdhaadebaejiicgidbhajfbfejcdicgfbcchgbahfccbefdcddbjjhejigiafhdjbiiehadfficicbebeeegcebideijidbgdecffeaegjfjbbcfiabfbaiddbjgidebdiccfcgfbcbbfhaejaibeicghecchjbiaceaibfgibhgcfgifiedcbhhfadhccfdhejeggcah\\njbadcfjffcfabbecfabgcafgfcgfeffjjhhdaajjgcbgbechhiadfahjidcdiefhbabhjhjijghghcgghcefhidhdgficiffdjgfdahcaicidfghiedgihbbjgicjeiacihdihfhadjhccddhigiibafiafficegaiehabafiiecbjcbfhdbeaebigaijehhdbfeehbcahaggbbdjcdbgbiajgeigdeabdbddbgcgjibfdgjghhdidjdhh\\n\", \"100\\nabababbbababbababaaabbbbaaaabbabbabbabababbbaaaabbababbbbababbabbbaaababababbbaaaabbbabbababbbbbbaba\\nabababbbababbababaaabbbbaaaabbabbabbabababbbaaaabaababbbbababbabbbaaababababbbaaaabbbabbababbbbbbaba\\n\", \"100\\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaaaaaaa\\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\n\", \"100\\naaaaaaaaaaaaaaaaaaaaaalaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\naaaaaaaaaaaaaaaaaaaaaakaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\n\", \"100\\ndwtsrrtztfuibkrpwbxjrcxsonrwoydkmbhxrghekvusiyzqkyvulrvtfxmvrphpzpmazizogfbyauxtjfesocssnxvjjdedomlz\\ndwtsrrtztfuibkrpwbxjrcxsonrwoydkmbhxrghekvusiyzqkyvulrvtfxmvrphpzpzazizogfbyauxtjfesocssnxvjjdedomlz\\n\", \"100\\naaabaabbbababbbaabbbbbaaababbabbaaabbabaabbabbabbbbbabbaaabbbbbbbbbbbbbbbababaaababbaaabeabbabaabbab\\naaabaabbbababbbaabbbbbaaababbabbaaabbabaabbabbabbbbbabbaaabbbbbbbbbbbbbbbababaaababbaaabtabbabaabbab\\n\", \"100\\naaaabaaaaabbaababaaabaababaabbbaabaaabbbaaababbabaabbabababbaaabaabababbbababbbabbaaaabbbbbbbaaababa\\naaaabaaaaabbaababaaabaababaabbbaabaaabbbaaaabbbabaabbabababbaaabaabababbbababbbabbaaaabbbbbbbaaababa\\n\", \"100\\neebdeddddbecdbddaaecbbaccbecdeacedddcaddcdebedbabbceeeadecadbbeaecdaeabbceacbdbdbbdacebbbccdcbbeedbe\\needbeddddbecdbddaaecbbaccbecdeacedddcaddcdebedbabbceeeadecadbbeaecdaeabbceacbdbdbbdacebbbccdcbbeedbe\\n\", \"100\\nxjywrmrwqaytezhtqmcnrrjomslvcmevncvzeddnvqgkbusnbzrppdsuzsmcobmnslpvosunavayvdbxhtavvwodorwijxfjjlat\\nxjywrmrwqaytezhtqmcrnrjomslvcmevncvzeddnvqgkbusnbzrppdsuzsmcobmnslpvosunavayvdbxhtavvwodorwijxfjjlat\\n\", \"4\\nbbca\\nabab\\n\", \"4\\nabcb\\nccac\\n\", \"4\\ncaaa\\nabab\\n\", \"4\\nacca\\nbabb\\n\", \"4\\nccba\\nbabb\\n\", \"4\\nbcca\\ncbaa\\n\", \"4\\naaca\\ncaab\\n\", \"4\\nbaab\\nbcbc\\n\", \"4\\nabba\\ncaca\\n\", \"4\\nbcbb\\nccac\\n\", \"4\\ncbba\\nabba\\n\", \"4\\nbaca\\nccbc\\n\", \"4\\ncabc\\naacc\\n\", \"4\\nbbab\\ncbaa\\n\", \"4\\nabcc\\nbcab\\n\", \"4\\nbaaa\\nbbbc\\n\", \"4\\naabc\\naacb\\n\", \"4\\nccbb\\nbbcb\\n\", \"4\\nbaba\\naccc\\n\", \"4\\nbbbc\\nbbab\\n\", \"2\\nab\\nba\\n\", \"5\\ncabac\\ncbabc\\n\", \"3\\naba\\nbab\\n\", \"5\\nabxxx\\nbayyy\\n\", \"4\\nxaxa\\naxax\\n\", \"5\\nababa\\nbabab\\n\", \"5\\nbabab\\nababa\\n\", \"154\\nwqpewhyutqnhaewqpewhywqpewhyutqnhaeutqnhaeutqnhaewqpewhyutqnhaewqpewhywqpewhyutqnhaeutqnhaeutqnhaeutqnhaewqpewhyutqnhaewqpewhywqpewhywqpewhywqpewhyutqnhae\\nutqnhaeutqnhaeutqnhaewqpewhywqpewhyutqnhaewqpewhyutqnhaewqpewhywqpewhyutqnhaeutqnhaeutqnhaewqpewhyutqnhaewqpewhywqpewhywqpewhyutqnhaewqpewhyutqnhaewqpewhy\\n\", \"7\\ntrading\\nrtading\\n\", \"5\\nxabax\\nxbabx\\n\", \"3\\nabc\\nacb\\n\", \"4\\nabab\\nbaba\\n\", \"3\\naab\\naba\\n\", \"2\\ner\\nre\\n\", \"5\\ntabat\\ntbaat\\n\"], \"outputs\": [\"1\\n\", \"0\\n\", \"2\\n\", \"2\\n\", \"2\\n\", \"2\\n\", \"2\\n\", \"2\\n\", \"1\\n\", \"0\\n\", \"0\\n\", \"2\\n\", \"2\\n\", \"2\\n\", \"2\\n\", \"2\\n\", \"2\\n\", \"2\\n\", \"2\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"2\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"2\\n\", \"0\\n\", \"0\\n\", \"1\\n\", \"2\\n\", \"2\\n\", \"2\\n\", \"0\\n\", \"2\\n\", \"2\\n\", \"2\\n\", \"0\\n\", \"2\\n\", \"2\\n\", \"2\\n\", \"2\\n\", \"2\\n\", \"2\\n\", \"2\\n\"]}", "source": "primeintellect"}
Analyzing the mistakes people make while typing search queries is a complex and an interesting work. As there is no guaranteed way to determine what the user originally meant by typing some query, we have to use different sorts of heuristics. Polycarp needed to write a code that could, given two words, check whether they could have been obtained from the same word as a result of typos. Polycarpus suggested that the most common typo is skipping exactly one letter as you type a word. Implement a program that can, given two distinct words S and T of the same length n determine how many words W of length n + 1 are there with such property that you can transform W into both S, and T by deleting exactly one character. Words S and T consist of lowercase English letters. Word W also should consist of lowercase English letters. -----Input----- The first line contains integer n (1 ≤ n ≤ 100 000) — the length of words S and T. The second line contains word S. The third line contains word T. Words S and T consist of lowercase English letters. It is guaranteed that S and T are distinct words. -----Output----- Print a single integer — the number of distinct words W that can be transformed to S and T due to a typo. -----Examples----- Input 7 reading trading Output 1 Input 5 sweet sheep Output 0 Input 3 toy try Output 2 -----Note----- In the first sample test the two given words could be obtained only from word "treading" (the deleted letters are marked in bold). In the second sample test the two given words couldn't be obtained from the same word by removing one letter. In the third sample test the two given words could be obtained from either word "tory" or word "troy". Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0
{"tests": "{\"inputs\": [\"5\\n1 2 3 4 5\\n1 2\\n2 3\\n3 4\\n4 5\\n\", \"7\\n38 -29 87 93 39 28 -55\\n1 2\\n2 5\\n3 2\\n2 4\\n1 7\\n7 6\\n\", \"5\\n1 2 7 6 7\\n1 5\\n5 3\\n3 4\\n2 4\\n\", \"3\\n2 2 2\\n3 2\\n1 2\\n\", \"3\\n999397 999397 999397\\n2 3\\n2 1\\n\", \"5\\n1000000000 0 1000000000 0 1000000000\\n1 2\\n2 3\\n3 4\\n4 5\\n\", \"10\\n-1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000\\n10 3\\n7 4\\n2 6\\n9 2\\n5 10\\n1 8\\n7 8\\n7 2\\n10 6\\n\", \"1\\n0\\n\", \"2\\n0 0\\n2 1\\n\", \"3\\n0 0 0\\n1 3\\n2 3\\n\", \"1\\n0\\n\", \"2\\n0 0\\n2 1\\n\", \"2\\n0 1\\n2 1\\n\", \"3\\n0 0 0\\n1 3\\n2 3\\n\", \"3\\n1 0 0\\n2 1\\n3 2\\n\", \"3\\n-2 -2 2\\n1 3\\n2 1\\n\", \"4\\n0 0 0 0\\n2 4\\n1 4\\n3 2\\n\", \"4\\n0 0 0 -1\\n3 1\\n4 1\\n2 4\\n\", \"4\\n1 -2 2 2\\n4 3\\n2 4\\n1 2\\n\", \"5\\n0 0 0 0 0\\n3 2\\n1 2\\n5 1\\n4 2\\n\", \"5\\n-1 -1 -1 0 0\\n4 3\\n5 3\\n1 4\\n2 5\\n\", \"5\\n-2 -1 -2 1 0\\n3 1\\n5 1\\n2 1\\n4 2\\n\", \"1\\n-1000000000\\n\", \"2\\n-1000000000 -1000000000\\n2 1\\n\", \"2\\n-999999999 -1000000000\\n1 2\\n\", \"3\\n-1000000000 -1000000000 -1000000000\\n3 1\\n2 1\\n\", \"3\\n-1000000000 -999999999 -1000000000\\n1 2\\n3 1\\n\", \"3\\n-999999999 -999999998 -1000000000\\n2 3\\n1 2\\n\", \"1\\n1000000000\\n\", \"2\\n1000000000 1000000000\\n2 1\\n\", \"2\\n999999999 1000000000\\n2 1\\n\", \"3\\n1000000000 1000000000 1000000000\\n1 3\\n2 1\\n\", \"3\\n999999999 1000000000 1000000000\\n2 1\\n3 2\\n\", \"3\\n999999998 999999998 999999998\\n1 3\\n2 1\\n\", \"3\\n1000000000 -1000000000 1000000000\\n1 2\\n2 3\\n\", \"4\\n1000000000 -1000000000 -1000000000 1000000000\\n1 2\\n3 2\\n4 3\\n\", \"1\\n-1000000000\\n\", \"2\\n-1000000000 -1\\n1 2\\n\", \"3\\n-1 -1000000000 -1000000000\\n2 1\\n3 1\\n\", \"5\\n-1 -1000000000 -1 -2 -1\\n5 2\\n1 2\\n3 2\\n4 1\\n\", \"10\\n-2 -1000000000 -2 -1000000000 -2 -5 -3 -1 -2 -1000000000\\n8 6\\n10 6\\n5 10\\n3 10\\n7 5\\n2 8\\n1 6\\n4 1\\n9 5\\n\", \"4\\n1 2 2 2\\n1 2\\n1 3\\n1 4\\n\", \"5\\n1 1 7 7 7\\n1 3\\n2 3\\n3 4\\n4 5\\n\", \"3\\n10 1 10\\n1 2\\n2 3\\n\", \"3\\n8 7 8\\n1 2\\n2 3\\n\", \"1\\n-11\\n\", \"6\\n10 1 10 1 1 1\\n1 2\\n2 3\\n3 4\\n4 5\\n5 6\\n\", \"3\\n7 6 7\\n1 2\\n2 3\\n\", \"7\\n5 0 0 0 0 5 5\\n1 2\\n1 3\\n1 4\\n1 5\\n4 6\\n4 7\\n\", \"4\\n7 1 1 7\\n1 2\\n1 3\\n3 4\\n\", \"6\\n5 5 5 4 4 4\\n1 2\\n1 3\\n3 4\\n3 5\\n3 6\\n\", \"4\\n1 93 93 93\\n1 2\\n1 3\\n1 4\\n\", \"3\\n2 1 2\\n1 2\\n2 3\\n\", \"6\\n10 10 10 1 1 1\\n1 2\\n2 3\\n3 4\\n1 5\\n1 6\\n\"], \"outputs\": [\"5\", \"93\", \"8\", \"3\", \"999398\", \"1000000002\", \"-999999998\", \"0\", \"1\", \"1\", \"0\", \"1\", \"1\", \"1\", \"2\", \"2\", \"2\", \"2\", \"3\", \"2\", \"1\", \"2\", \"-1000000000\", \"-999999999\", \"-999999999\", \"-999999999\", \"-999999998\", \"-999999998\", \"1000000000\", \"1000000001\", \"1000000000\", \"1000000001\", \"1000000001\", \"999999999\", \"1000000001\", \"1000000002\", \"-1000000000\", \"-1\", \"-1\", \"0\", \"0\", \"3\", \"8\", \"11\", \"9\", \"-11\", \"11\", \"8\", \"6\", \"8\", \"6\", \"94\", \"3\", \"11\"]}", "source": "primeintellect"}
Although Inzane successfully found his beloved bone, Zane, his owner, has yet to return. To search for Zane, he would need a lot of money, of which he sadly has none. To deal with the problem, he has decided to hack the banks. [Image] There are n banks, numbered from 1 to n. There are also n - 1 wires connecting the banks. All banks are initially online. Each bank also has its initial strength: bank i has initial strength a_{i}. Let us define some keywords before we proceed. Bank i and bank j are neighboring if and only if there exists a wire directly connecting them. Bank i and bank j are semi-neighboring if and only if there exists an online bank k such that bank i and bank k are neighboring and bank k and bank j are neighboring. When a bank is hacked, it becomes offline (and no longer online), and other banks that are neighboring or semi-neighboring to it have their strengths increased by 1. To start his plan, Inzane will choose a bank to hack first. Indeed, the strength of such bank must not exceed the strength of his computer. After this, he will repeatedly choose some bank to hack next until all the banks are hacked, but he can continue to hack bank x if and only if all these conditions are met: Bank x is online. That is, bank x is not hacked yet. Bank x is neighboring to some offline bank. The strength of bank x is less than or equal to the strength of Inzane's computer. Determine the minimum strength of the computer Inzane needs to hack all the banks. -----Input----- The first line contains one integer n (1 ≤ n ≤ 3·10^5) — the total number of banks. The second line contains n integers a_1, a_2, ..., a_{n} ( - 10^9 ≤ a_{i} ≤ 10^9) — the strengths of the banks. Each of the next n - 1 lines contains two integers u_{i} and v_{i} (1 ≤ u_{i}, v_{i} ≤ n, u_{i} ≠ v_{i}) — meaning that there is a wire directly connecting banks u_{i} and v_{i}. It is guaranteed that the wires connect the banks in such a way that Inzane can somehow hack all the banks using a computer with appropriate strength. -----Output----- Print one integer — the minimum strength of the computer Inzane needs to accomplish the goal. -----Examples----- Input 5 1 2 3 4 5 1 2 2 3 3 4 4 5 Output 5 Input 7 38 -29 87 93 39 28 -55 1 2 2 5 3 2 2 4 1 7 7 6 Output 93 Input 5 1 2 7 6 7 1 5 5 3 3 4 2 4 Output 8 -----Note----- In the first sample, Inzane can hack all banks using a computer with strength 5. Here is how: Initially, strengths of the banks are [1, 2, 3, 4, 5]. He hacks bank 5, then strengths of the banks become [1, 2, 4, 5, - ]. He hacks bank 4, then strengths of the banks become [1, 3, 5, - , - ]. He hacks bank 3, then strengths of the banks become [2, 4, - , - , - ]. He hacks bank 2, then strengths of the banks become [3, - , - , - , - ]. He completes his goal by hacking bank 1. In the second sample, Inzane can hack banks 4, 2, 3, 1, 5, 7, and 6, in this order. This way, he can hack all banks using a computer with strength 93. Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0
{"tests": "{\"inputs\": [\"1 -1\\n1 1\\n1 2\\n\", \"-1 -1\\n-1 3\\n4 3\\n\", \"1 1\\n2 3\\n3 2\\n\", \"1000000000 -1000000000\\n1000000000 1000000000\\n-1000000000 -1000000000\\n\", \"-510073119 -991063686\\n583272581 -991063686\\n623462417 -991063686\\n\", \"-422276230 -422225325\\n-422276230 -544602611\\n-282078856 -544602611\\n\", \"127447697 -311048187\\n-644646254 135095006\\n127447697 135095006\\n\", \"-609937696 436598127\\n-189924209 241399893\\n-883780251 296798182\\n\", \"-931665727 768789996\\n234859675 808326671\\n-931665727 879145023\\n\", \"899431605 238425805\\n899431605 339067352\\n940909482 333612216\\n\", \"143495802 -137905447\\n-922193757 -660311216\\n-922193757 659147504\\n\", \"-759091260 362077211\\n-759091260 123892252\\n-79714253 226333388\\n\", \"-495060442 -389175621\\n79351129 -146107545\\n-495060442 59059286\\n\", \"-485581506 973584319\\n-762068259 670458753\\n-485581506 -661338021\\n\", \"-865523810 66779936\\n-865523810 879328244\\n551305309 495319633\\n\", \"-985816934 85994062\\n490801388 171721095\\n-985816934 265995176\\n\", \"-322848128 276304614\\n-228010033 -361111909\\n-137761352 276304614\\n\", \"648743183 -329867260\\n680098341 -988370978\\n594847608 -988370978\\n\", \"-636111887 -755135651\\n-411477790 -755135651\\n-540985255 -808506689\\n\", \"-280166733 -215262264\\n-257537874 640677716\\n-288509263 640677716\\n\", \"158219297 -796751401\\n464911767 780525998\\n25054022 780525998\\n\", \"-76151678 894169660\\n125930178 -434000890\\n259457432 894169660\\n\", \"403402592 55070913\\n-703565711 55070913\\n-141194091 -66977045\\n\", \"-485970125 725016060\\n-972748484 -602121312\\n183987969 -602121312\\n\", \"-494824697 -964138793\\n-494824697 671151995\\n-24543485 877798954\\n\", \"-504439520 685616264\\n-575788481 178485261\\n-575788481 -998856787\\n\", \"446038601 -598441655\\n446038601 -781335731\\n-446725217 -862937359\\n\", \"443336387 317738308\\n-731455437 682073969\\n443336387 -487472781\\n\", \"-954908844 156002304\\n-954908844 507051490\\n-377680300 878914758\\n\", \"437180709 -829478932\\n-775395571 -605325538\\n-775395571 298582830\\n\", \"791725263 -592101263\\n791725263 -401786481\\n953501658 -699705540\\n\", \"621619191 -223521454\\n621619191 -746436580\\n-886355353 -920817120\\n\", \"353770247 742032246\\n391091420 742032246\\n113505964 105784687\\n\", \"-386452587 -689699105\\n-51244121 425743943\\n736584134 425743943\\n\", \"-354329375 -222798859\\n-636793392 28344958\\n989602966 -222798859\\n\", \"439039590 -419754858\\n-16966935 -979701468\\n276072230 -979701468\\n\", \"-160622039 260994846\\n-981120537 -453711571\\n-899331084 260994846\\n\", \"755966021 -977934315\\n-693932164 -977934315\\n780740735 341305212\\n\", \"997183648 -430699196\\n555277138 -34246328\\n962365828 -34246328\\n\", \"394482565 -5842724\\n-120921456 -5842724\\n474336847 -666083693\\n\", \"451140644 -552066345\\n451140644 97091285\\n643901618 -552066345\\n\", \"-397991545 510063044\\n347795937 510063044\\n-397991545 944965447\\n\", \"361702696 891912906\\n742864513 891912906\\n361702696 616808838\\n\", \"950548287 766404840\\n995400182 976310818\\n950548287 976310818\\n\", \"512806478 -76305905\\n51445888 -189759697\\n512806478 -189759697\\n\", \"134061442 -132620069\\n-215253638 -132620069\\n134061442 112298311\\n\", \"-225194635 772128906\\n-9640584 -636384130\\n-9640584 772128906\\n\", \"976530519 -932140580\\n418643692 -845327922\\n976530519 -845327922\\n\", \"-960958311 -757098377\\n-960958311 -153001649\\n-960958311 567188828\\n\", \"487214658 518775922\\n487214658 -869675495\\n487214658 -106351878\\n\", \"58011742 175214671\\n-853914900 175214671\\n-245334045 175214671\\n\", \"306134424 46417066\\n-503106271 46417066\\n-286564055 46417066\\n\", \"150098962 830455428\\n-70279563 -160635038\\n-721135733 -627254059\\n\", \"-664035427 -710202693\\n527339005 -8499215\\n414350757 -966228511\\n\"], \"outputs\": [\"1\\n\", \"2\\n\", \"3\\n\", \"2\\n\", \"1\\n\", \"2\\n\", \"2\\n\", \"3\\n\", \"3\\n\", \"3\\n\", \"3\\n\", \"3\\n\", \"3\\n\", \"3\\n\", \"3\\n\", \"3\\n\", \"3\\n\", \"3\\n\", \"3\\n\", \"3\\n\", \"3\\n\", \"3\\n\", \"3\\n\", \"3\\n\", \"2\\n\", \"2\\n\", \"2\\n\", \"2\\n\", \"2\\n\", \"2\\n\", \"2\\n\", \"2\\n\", \"2\\n\", \"2\\n\", \"2\\n\", \"2\\n\", \"2\\n\", \"2\\n\", \"2\\n\", \"2\\n\", \"2\\n\", \"2\\n\", \"2\\n\", \"2\\n\", \"2\\n\", \"2\\n\", \"2\\n\", \"2\\n\", \"1\\n\", \"1\\n\", \"1\\n\", \"1\\n\", \"3\\n\", \"3\\n\"]}", "source": "primeintellect"}
There are three points marked on the coordinate plane. The goal is to make a simple polyline, without self-intersections and self-touches, such that it passes through all these points. Also, the polyline must consist of only segments parallel to the coordinate axes. You are to find the minimum number of segments this polyline may consist of. -----Input----- Each of the three lines of the input contains two integers. The i-th line contains integers x_{i} and y_{i} ( - 10^9 ≤ x_{i}, y_{i} ≤ 10^9) — the coordinates of the i-th point. It is guaranteed that all points are distinct. -----Output----- Print a single number — the minimum possible number of segments of the polyline. -----Examples----- Input 1 -1 1 1 1 2 Output 1 Input -1 -1 -1 3 4 3 Output 2 Input 1 1 2 3 3 2 Output 3 -----Note----- The variant of the polyline in the first sample: [Image] The variant of the polyline in the second sample: $1$ The variant of the polyline in the third sample: $\because$ Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0
{"tests": "{\"inputs\": [\"1\\n\", \"3\\n\", \"10\\n\", \"2\\n\", \"4\\n\", \"5\\n\", \"6\\n\", \"7\\n\", \"8\\n\", \"12\\n\", \"14\\n\", \"16\\n\", \"18\\n\", \"20\\n\", \"22\\n\", \"24\\n\", \"26\\n\", \"28\\n\", \"30\\n\", \"32\\n\", \"34\\n\", \"36\\n\", \"38\\n\", \"40\\n\", \"42\\n\", \"44\\n\", \"46\\n\", \"48\\n\", \"50\\n\", \"52\\n\", \"54\\n\", \"56\\n\", \"58\\n\", \"60\\n\", \"62\\n\", \"64\\n\", \"66\\n\", \"68\\n\", \"70\\n\", \"72\\n\", \"74\\n\", \"76\\n\", \"78\\n\", \"80\\n\", \"82\\n\", \"84\\n\", \"86\\n\", \"88\\n\", \"90\\n\", \"92\\n\", \"94\\n\", \"96\\n\", \"98\\n\", \"100\\n\"], \"outputs\": [\"YES\\n2 1\\n1 2\\n\", \"YES\\n10 15\\n1 6\\n1 2\\n1 3\\n2 4\\n2 5\\n3 4\\n3 5\\n4 5\\n6 7\\n6 8\\n7 9\\n7 10\\n8 9\\n8 10\\n9 10\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"YES\\n14 35\\n1 8\\n1 2\\n1 3\\n1 4\\n1 5\\n2 6\\n2 7\\n2 4\\n2 5\\n3 6\\n3 7\\n3 4\\n3 5\\n4 6\\n4 7\\n5 6\\n5 7\\n6 7\\n8 9\\n8 10\\n8 11\\n8 12\\n9 13\\n9 14\\n9 11\\n9 12\\n10 13\\n10 14\\n10 11\\n10 12\\n11 13\\n11 14\\n12 13\\n12 14\\n13 14\\n\", \"NO\\n\", \"YES\\n18 63\\n1 10\\n1 2\\n1 3\\n1 4\\n1 5\\n1 6\\n1 7\\n2 8\\n2 9\\n2 4\\n2 5\\n2 6\\n2 7\\n3 8\\n3 9\\n3 4\\n3 5\\n3 6\\n3 7\\n4 8\\n4 9\\n4 6\\n4 7\\n5 8\\n5 9\\n5 6\\n5 7\\n6 8\\n6 9\\n7 8\\n7 9\\n8 9\\n10 11\\n10 12\\n10 13\\n10 14\\n10 15\\n10 16\\n11 17\\n11 18\\n11 13\\n11 14\\n11 15\\n11 16\\n12 17\\n12 18\\n12 13\\n12 14\\n12 15\\n12 16\\n13 17\\n13 18\\n13 15\\n13 16\\n14 17\\n14 18\\n14 15\\n14 16\\n15 17\\n15 18\\n16 17\\n16 18\\n17 18\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\"]}", "source": "primeintellect"}
An undirected graph is called k-regular, if the degrees of all its vertices are equal k. An edge of a connected graph is called a bridge, if after removing it the graph is being split into two connected components. Build a connected undirected k-regular graph containing at least one bridge, or else state that such graph doesn't exist. -----Input----- The single line of the input contains integer k (1 ≤ k ≤ 100) — the required degree of the vertices of the regular graph. -----Output----- Print "NO" (without quotes), if such graph doesn't exist. Otherwise, print "YES" in the first line and the description of any suitable graph in the next lines. The description of the made graph must start with numbers n and m — the number of vertices and edges respectively. Each of the next m lines must contain two integers, a and b (1 ≤ a, b ≤ n, a ≠ b), that mean that there is an edge connecting the vertices a and b. A graph shouldn't contain multiple edges and edges that lead from a vertex to itself. A graph must be connected, the degrees of all vertices of the graph must be equal k. At least one edge of the graph must be a bridge. You can print the edges of the graph in any order. You can print the ends of each edge in any order. The constructed graph must contain at most 10^6 vertices and 10^6 edges (it is guaranteed that if at least one graph that meets the requirements exists, then there also exists the graph with at most 10^6 vertices and at most 10^6 edges). -----Examples----- Input 1 Output YES 2 1 1 2 -----Note----- In the sample from the statement there is a suitable graph consisting of two vertices, connected by a single edge. Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0
{"tests": "{\"inputs\": [\"8 4 5\\n(())()()\\nRDLD\\n\", \"12 5 3\\n((()())(()))\\nRRDLD\\n\", \"8 8 8\\n(())()()\\nLLLLLLDD\\n\", \"4 2 2\\n()()\\nLD\\n\", \"6 4 1\\n()()()\\nDRRD\\n\", \"8 2 4\\n(())()()\\nRR\\n\", \"10 7 3\\n(()())()()\\nRDLRDRD\\n\", \"12 10 11\\n(())()()()()\\nDLRDLRDDLR\\n\", \"14 8 13\\n((())())((()))\\nDLRLLRLR\\n\", \"16 2 10\\n(((())())())()()\\nLD\\n\", \"18 8 11\\n((()))(()()()())()\\nLLLRRRRD\\n\", \"20 16 3\\n(()()())()(())()()()\\nLDRRRRRRLRLRLLLL\\n\", \"22 9 12\\n(()())((()()())())()()\\nRDLLLRDRL\\n\", \"24 15 14\\n((()())()()())(())()()()\\nLDRRLDLDRRDDLRL\\n\", \"26 3 15\\n((())())(((())()()))(())()\\nRDL\\n\", \"28 13 16\\n(()()())(()()())(())(())()()\\nLRLDRRRRRLLLR\\n\", \"30 18 15\\n(()((()()())()(())())())()()()\\nRRRLRRRLRRDLLLDRDR\\n\", \"32 6 19\\n((()())((())())())((())()(()))()\\nLDRLRR\\n\", \"34 8 20\\n(())((()())()((())())()()())()()()\\nRLLDLRRL\\n\", \"36 11 36\\n(()()()()())((())())(()()())((())())\\nLDLRLLLLRLR\\n\", \"38 8 26\\n((((())())(()))(()()))(((())())())()()\\nDDDLRLDR\\n\", \"40 22 35\\n(((()()()())()()())((())())()(())())()()\\nDRRLDRLRLLLDLLLDRLLRLD\\n\", \"42 7 29\\n(((())()(()())())(((()())())(()())())())()\\nDDRRRRD\\n\", \"44 13 42\\n((()()())()()()())(((()()())())()())(()())()\\nLRRRLLDRDLDLR\\n\", \"46 3 11\\n(()()(())())(()())((()((())())(()())(())())())\\nDDD\\n\", \"48 33 11\\n((((())())((()()())())()()(()()))()(()())())()()\\nRLRDLDRLLLRRRLRDLRLDDRRDRLRRDRLRD\\n\", \"50 32 32\\n(()()())(())(())((()())())((())())((()())())(())()\\nLRLLLRDRRDLRRRLRLLDDRLLRDLRDLRLD\\n\", \"52 24 39\\n((()(()())(()())()())()())((()())(())())(())(()())()\\nDRRDLDRLRRLLRRDRRLDRRLLL\\n\", \"54 22 3\\n(((()())(())()())((()())())())((())((()()())()())())()\\nLRLRDLRDLLRLDRLRRDRLRD\\n\", \"56 43 9\\n(((((())())(()()))()()()())(()()(()))(()())(())())()()()\\nRLRLDLRLLRLRLDLLRLRRLLLRLRRLDLDRDLLRLRRLLDR\\n\", \"58 3 22\\n((((())()())())((())())(())())(((())()()())(())()())()(())\\nLLR\\n\", \"60 50 23\\n((((())(()())()())(()())()()()(()())())((())()())()())(())()\\nDRDLLDDLLLLDDRRDRDLLLRRRLRLDDDLRLLRRDLRLRRDDDRDRRL\\n\", \"62 34 43\\n(()((()())()()))(((())())()(()())(())())((())(()(()())()))()()\\nRLDDDDDDLRDLLRLDRLLDLRLDLLDRLLRRLL\\n\", \"64 19 15\\n((((())((())())()())(())())(()())(()())())((()()())(())())()()()\\nDRRLRLRDDDDLLDRLRLD\\n\", \"66 55 24\\n(((())(((()())()()))(()())(()())())(())((()())())(()()())())()()()\\nRDLRLRRRLRDLRRLLDDRDRRDLRLDRRDRDLRDDLLRRDRDRLRRLLLDLRRR\\n\", \"68 34 8\\n((()(()())()())(()))((()())()())((()()())())(((())(()))(())()(())())\\nDLRRLRRRDLLDLLDDDLRRLRLRRRDDRLRRLL\\n\", \"70 33 26\\n((()(())()())((())())(()())(())())((()((()())()())())()()(())())(()())\\nDLDRRRLRLDLRLLRDDRLRRLLLRDRLRLDRL\\n\", \"72 23 38\\n(((((()()())()())(((()()))(())())()(()())(()(())())))(())((())())())()()\\nRDLRLRRRDLLRDLRDLLRRLLD\\n\", \"74 26 27\\n(((()()())())(())()())((()()(())())()())((()()())()())(()()())(()()())()()\\nLDRLLRLRLLDDDLDRRDRLLRDLRD\\n\", \"76 51 69\\n(((())()())())(()()()()())(((((())(())())())())(((()(())())(()()())())()))()\\nLRLLRRLLLDRDDRLLDLRLRDRLRDLRLRLRLLDLRLRLLLDDLLRRDLD\\n\", \"78 33 22\\n(((()((()()())())()()())((()())()())(())())(((((())())()())()())(())())())()()\\nRDRRRRRLDRDLDRLLLLDRDRRRDLDRDLLRD\\n\", \"2 1 1\\n()\\nR\\n\", \"80 31 30\\n(((()()())(((())())((()())()()())()()))(()()()())(()())(()())(())(())()()()())()\\nDDDLLDLDDLRLRLDDRDRRLDRDLLDRLRL\\n\", \"82 16 6\\n(((())())(())()())(((()()((()()))())()(())())(()())(())((())())()()())(()()()())()\\nRLLLLRRDDRRLRRRL\\n\", \"84 18 78\\n(())(((()(()))()((((()())())(()())())()())((()())())())(((())(())())(())())())()()()\\nLLLRDDLRDRLDDLLRRL\\n\", \"86 11 62\\n(((())())(((()())())()()())(()())(()()())()())((()()())())(((())()())((())(()())())())\\nDLDLRLRLRRR\\n\", \"88 33 12\\n(())((((())()((()())())())(((())())(())()())(()))((()())())())(((())()())(())()())()()()\\nLLLRRLRDRDRLDDLLRDLLDRLRDDLDRDLRR\\n\", \"90 44 6\\n(((((())()())(((()())())())()()))(()())((())()())(()())((())())(()()())())(())((())())()()\\nRLDLRRLLDRDDDLRDRRDLLRRDDDDLRLRDRLLDRDLRDDRR\\n\", \"92 51 30\\n(()(((()())(()())())())(()())()()()())((()()())(())(())(()((())()())())(())())((())()())()()\\nLRLRLLLLRRRLLRRLDLRLRRLRDLDLDLDDRRLRRRLLRDRLDDRLRRD\\n\", \"94 48 47\\n(((()(())())(((())())())()())()()())((()()())(()(()()()())())())(()())(()(())(())()())(()())()\\nLLLLLLDLDRLLDLRRDLLLLRLLDLLRRDDRDRRLLRRDRRRDRLLD\\n\", \"96 37 18\\n((()()()())((((())()())())(())()())()()())(((())()(()(())())()()())(())())((()())()()())(()())()\\nDDLRRDDLDLRDDDRLDLRRDDDLLDRRRDDLDLLRL\\n\", \"98 38 40\\n((()((((()))(())(()(())))))((())()())(())()())((((()())(((()()))()))()(())()()())())((()))(())()()\\nLRLRRDLDDRRLRDRDDLDRDLDRDLRLRLRLRLRLRR\\n\", \"100 57 80\\n(((())(()))(()())())((((()()()())((())())()())(()((()())()()()))())()()())((())()((())()))((()))()()\\nLLRRLLLRLRLRLDLLRRRDDLRDDDLRLRLLLRLRRRLLDRLRDLLDLRLRLDDLR\\n\", \"10 3 3\\n(())((()))\\nDRD\\n\"], \"outputs\": [\"()\\n\", \"(()(()))\\n\", \"()()\\n\", \"()\\n\", \"()\\n\", \"(())()()\\n\", \"()\\n\", \"(())\\n\", \"((())())()\\n\", \"(())()()\\n\", \"((()))(()()())()\\n\", \"(()())()(())()()()\\n\", \"(()())((())())()()\\n\", \"()\\n\", \"((())())(((())()))(())()\\n\", \"(()()())(()())(())(())()()\\n\", \"()()\\n\", \"((())()(()))()\\n\", \"(())((()())()((()))()()())()()()\\n\", \"(()()()()())((())())(()()())((()))\\n\", \"((((())())(()))(()()))(())()()\\n\", \"(())()\\n\", \"(((())()(()())())(((()())()))())\\n\", \"((()()())()()()())(((()()())())())\\n\", \"((()((())())(()())(())())())\\n\", \"(()(()())())()()\\n\", \"(()()())(())(())((()()))\\n\", \"((()(()())(()())()())()())((()())(()))()()\\n\", \"(()())()\\n\", \"()()()\\n\", \"((((())()())())((())())(())())(((())()()())(())()())()(())\\n\", \"(()())(())()\\n\", \"(())\\n\", \"()()()\\n\", \"()()()()\\n\", \"((()())()())((()()())())(((())(()))(())()(())())\\n\", \"(()())\\n\", \"()()\\n\", \"()()()\\n\", \"(((())()()))\\n\", \"((((((())())()())()())(())())())()()\\n\", \"()\\n\", \"()\\n\", \"((())(())()())(((()()((()()))())()(())())(()())(())((())())()()())(()()()())()\\n\", \"(())\\n\", \"(((())())(((()())())()()())(()())(()()())()())((()()())())((()())((())(()())())())\\n\", \"(())()()\\n\", \"()()\\n\", \"(()()())()()\\n\", \"((())()())(()())()\\n\", \"((()()()))((()())()()())(()())()\\n\", \"()()()\\n\", \"(((())(()))(()())())\\n\", \"()\\n\"]}", "source": "primeintellect"}
Recently Polycarp started to develop a text editor that works only with correct bracket sequences (abbreviated as CBS). Note that a bracket sequence is correct if it is possible to get a correct mathematical expression by adding "+"-s and "1"-s to it. For example, sequences "(())()", "()" and "(()(()))" are correct, while ")(", "(()" and "(()))(" are not. Each bracket in CBS has a pair. For example, in "(()(()))": 1st bracket is paired with 8th, 2d bracket is paired with 3d, 3d bracket is paired with 2d, 4th bracket is paired with 7th, 5th bracket is paired with 6th, 6th bracket is paired with 5th, 7th bracket is paired with 4th, 8th bracket is paired with 1st. Polycarp's editor currently supports only three operations during the use of CBS. The cursor in the editor takes the whole position of one of the brackets (not the position between the brackets!). There are three operations being supported: «L» — move the cursor one position to the left, «R» — move the cursor one position to the right, «D» — delete the bracket in which the cursor is located, delete the bracket it's paired to and all brackets between them (that is, delete a substring between the bracket in which the cursor is located and the one it's paired to). After the operation "D" the cursor moves to the nearest bracket to the right (of course, among the non-deleted). If there is no such bracket (that is, the suffix of the CBS was deleted), then the cursor moves to the nearest bracket to the left (of course, among the non-deleted). There are pictures illustrated several usages of operation "D" below. [Image] All incorrect operations (shift cursor over the end of CBS, delete the whole CBS, etc.) are not supported by Polycarp's editor. Polycarp is very proud of his development, can you implement the functionality of his editor? -----Input----- The first line contains three positive integers n, m and p (2 ≤ n ≤ 500 000, 1 ≤ m ≤ 500 000, 1 ≤ p ≤ n) — the number of brackets in the correct bracket sequence, the number of operations and the initial position of cursor. Positions in the sequence are numbered from left to right, starting from one. It is guaranteed that n is even. It is followed by the string of n characters "(" and ")" forming the correct bracket sequence. Then follow a string of m characters "L", "R" and "D" — a sequence of the operations. Operations are carried out one by one from the first to the last. It is guaranteed that the given operations never move the cursor outside the bracket sequence, as well as the fact that after all operations a bracket sequence will be non-empty. -----Output----- Print the correct bracket sequence, obtained as a result of applying all operations to the initial sequence. -----Examples----- Input 8 4 5 (())()() RDLD Output () Input 12 5 3 ((()())(())) RRDLD Output (()(())) Input 8 8 8 (())()() LLLLLLDD Output ()() -----Note----- In the first sample the cursor is initially at position 5. Consider actions of the editor: command "R" — the cursor moves to the position 6 on the right; command "D" — the deletion of brackets from the position 5 to the position 6. After that CBS takes the form (())(), the cursor is at the position 5; command "L" — the cursor moves to the position 4 on the left; command "D" — the deletion of brackets from the position 1 to the position 4. After that CBS takes the form (), the cursor is at the position 1. Thus, the answer is equal to (). Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0
{"tests": "{\"inputs\": [\"4\\n>= 1 Y\\n< 3 N\\n<= -3 N\\n> 55 N\\n\", \"2\\n> 100 Y\\n< -100 Y\\n\", \"4\\n< 1 N\\n> 1 N\\n> 1 N\\n> 1 N\\n\", \"4\\n<= 1 Y\\n>= 1 Y\\n>= 1 Y\\n<= 1 Y\\n\", \"4\\n< 10 Y\\n> -6 Y\\n< 10 Y\\n< -10 N\\n\", \"1\\n< 1 N\\n\", \"1\\n<= 1 Y\\n\", \"1\\n> 1 N\\n\", \"1\\n>= 1 Y\\n\", \"4\\n< 1 N\\n< 1 N\\n< 1 N\\n<= 1 Y\\n\", \"4\\n< 1 N\\n>= 1 Y\\n< 1 N\\n< 1 N\\n\", \"4\\n> 1 N\\n<= 1 Y\\n<= 1 Y\\n> 1 N\\n\", \"4\\n>= 1 Y\\n> 1 N\\n>= 1 Y\\n>= 1 Y\\n\", \"4\\n<= 9 Y\\n< 3 Y\\n< 2 Y\\n< 2 Y\\n\", \"4\\n< 0 N\\n< -7 N\\n>= 8 N\\n>= -5 Y\\n\", \"4\\n<= -6 N\\n<= -8 N\\n<= 3 Y\\n<= 7 Y\\n\", \"4\\n>= 7 N\\n<= -1 N\\n>= 5 N\\n<= -10 N\\n\", \"4\\n> 5 N\\n>= -5 Y\\n> -9 Y\\n> -9 Y\\n\", \"10\\n<= -60 N\\n>= -59 Y\\n> 22 Y\\n> 95 N\\n<= 91 Y\\n> 77 Y\\n>= -59 Y\\n> -25 Y\\n> -22 Y\\n>= 52 Y\\n\", \"10\\n>= -18 Y\\n>= -35 Y\\n> -94 Y\\n< -23 N\\n< -69 N\\n< -68 N\\n< 82 Y\\n> 92 N\\n< 29 Y\\n>= -25 Y\\n\", \"10\\n>= 18 Y\\n<= -32 N\\n>= 85 N\\n<= 98 Y\\n<= -43 N\\n<= -79 N\\n>= 97 N\\n< -38 N\\n< -55 N\\n<= -93 N\\n\", \"10\\n<= 2 Y\\n< -33 Y\\n> 6 N\\n> -6 N\\n< -28 Y\\n> -62 Y\\n< 57 Y\\n<= 24 Y\\n> 23 N\\n> -25 N\\n\", \"10\\n<= -31 N\\n>= 66 N\\n<= 0 Y\\n> -95 Y\\n< 27 Y\\n< -42 N\\n> 3 N\\n< 6 Y\\n>= -42 Y\\n> -70 Y\\n\", \"10\\n>= 54 N\\n<= -52 N\\n>= 64 N\\n> 65 N\\n< 37 Y\\n> -84 Y\\n>= -94 Y\\n>= -95 Y\\n> -72 Y\\n<= 18 N\\n\", \"10\\n> -24 N\\n<= -5 Y\\n<= -33 Y\\n> 45 N\\n> -59 Y\\n> -21 N\\n<= -48 N\\n> 40 N\\n< 12 Y\\n>= 14 N\\n\", \"10\\n>= 91 Y\\n>= -68 Y\\n< 92 N\\n>= -15 Y\\n> 51 Y\\n<= 14 N\\n> 17 Y\\n< 94 Y\\n>= 49 Y\\n> -36 Y\\n\", \"1\\n< -1000000000 Y\\n\", \"1\\n< 1 Y\\n\", \"1\\n>= -999999999 Y\\n\", \"1\\n> 100000 Y\\n\", \"1\\n<= 999999999 Y\\n\", \"1\\n<= 1000000000 N\\n\", \"4\\n< -1000000000 Y\\n< -1000000000 Y\\n< -1000000000 Y\\n< -1000000000 Y\\n\", \"1\\n>= 1000000000 Y\\n\", \"1\\n<= 999999999 N\\n\", \"1\\n<= 100 Y\\n\", \"1\\n> 1000000000 Y\\n\", \"1\\n<= 1 Y\\n\", \"1\\n<= 1000000000 Y\\n\", \"1\\n<= -1000000000 Y\\n\", \"1\\n<= -999999999 Y\\n\", \"1\\n> 100 Y\\n\", \"2\\n< -1000000000 Y\\n< 3 Y\\n\", \"1\\n<= -1000000 Y\\n\", \"8\\n< -1000000000 Y\\n< -1000000000 Y\\n< -1000000000 Y\\n< -1000000000 Y\\n< -1000000000 Y\\n< -1000000000 Y\\n< -1000000000 Y\\n< -1000000000 Y\\n\", \"1\\n<= 15 Y\\n\", \"1\\n< 1000000000 Y\\n\", \"1\\n> 10000000 Y\\n\", \"1\\n< 0 Y\\n\", \"1\\n< 100 Y\\n\", \"1\\n<= 5 Y\\n\", \"3\\n> 5 Y\\n> 0 Y\\n< 4 Y\\n\", \"1\\n>= -1000000000 N\\n\", \"3\\n>= 1 Y\\n<= 1 Y\\n> 10 Y\\n\", \"2\\n> 1 Y\\n< 2 Y\\n\", \"3\\n>= 5 Y\\n<= 5 Y\\n< 5 Y\\n\", \"2\\n>= 5 N\\n> 5 Y\\n\", \"3\\n>= 4 Y\\n> 4 Y\\n<= 4 Y\\n\", \"2\\n>= 4 Y\\n> 4 Y\\n\"], \"outputs\": [\"17\\n\", \"Impossible\\n\", \"1\\n\", \"1\\n\", \"-5\\n\", \"1361956\\n\", \"-1998638045\\n\", \"-1998638045\\n\", \"1361956\\n\", \"1\\n\", \"1361956\\n\", \"-1998638045\\n\", \"1\\n\", \"-1998638045\\n\", \"3\\n\", \"-2\\n\", \"0\\n\", \"-4\\n\", \"85\\n\", \"18\\n\", \"64\\n\", \"-54\\n\", \"-29\\n\", \"22\\n\", \"-47\\n\", \"93\\n\", \"-1998638045\\n\", \"-1998638045\\n\", \"-998638044\\n\", \"1461956\\n\", \"-1998638045\\n\", \"1001361956\\n\", \"-1998638045\\n\", \"1001361955\\n\", \"1001361955\\n\", \"-1998638045\\n\", \"1001361956\\n\", \"-1998638045\\n\", \"-1998638045\\n\", \"-1998638045\\n\", \"-1998638045\\n\", \"1362056\\n\", \"-1998638045\\n\", \"-1998638045\\n\", \"-1998638045\\n\", \"-1998638045\\n\", \"-1998638045\\n\", \"11361956\\n\", \"-1998638045\\n\", \"-1998638045\\n\", \"-1998638045\\n\", \"Impossible\\n\", \"-1998638045\\n\", \"Impossible\\n\", \"Impossible\\n\", \"Impossible\\n\", \"Impossible\\n\", \"Impossible\\n\", \"1361960\\n\"]}", "source": "primeintellect"}
A TV show called "Guess a number!" is gathering popularity. The whole Berland, the old and the young, are watching the show. The rules are simple. The host thinks of an integer y and the participants guess it by asking questions to the host. There are four types of acceptable questions: Is it true that y is strictly larger than number x? Is it true that y is strictly smaller than number x? Is it true that y is larger than or equal to number x? Is it true that y is smaller than or equal to number x? On each question the host answers truthfully, "yes" or "no". Given the sequence of questions and answers, find any integer value of y that meets the criteria of all answers. If there isn't such value, print "Impossible". -----Input----- The first line of the input contains a single integer n (1 ≤ n ≤ 10000) — the number of questions (and answers). Next n lines each contain one question and one answer to it. The format of each line is like that: "sign x answer", where the sign is: ">" (for the first type queries), "<" (for the second type queries), ">=" (for the third type queries), "<=" (for the fourth type queries). All values of x are integer and meet the inequation - 10^9 ≤ x ≤ 10^9. The answer is an English letter "Y" (for "yes") or "N" (for "no"). Consequtive elements in lines are separated by a single space. -----Output----- Print any of such integers y, that the answers to all the queries are correct. The printed number y must meet the inequation - 2·10^9 ≤ y ≤ 2·10^9. If there are many answers, print any of them. If such value doesn't exist, print word "Impossible" (without the quotes). -----Examples----- Input 4 >= 1 Y < 3 N <= -3 N > 55 N Output 17 Input 2 > 100 Y < -100 Y Output Impossible Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0
{"tests": "{\"inputs\": [\"2 4\\n\", \"5 3\\n\", \"1 1\\n\", \"1 2\\n\", \"2 1\\n\", \"1000000000 1\\n\", \"1 1000000000\\n\", \"1000000000 1000000000\\n\", \"49464524 956817411\\n\", \"917980664 839933539\\n\", \"491529509 18016963\\n\", \"65078353 196100387\\n\", \"933594493 374183811\\n\", \"1000000000 956817411\\n\", \"1000000000 839933539\\n\", \"1000000000 18016963\\n\", \"1 122878623\\n\", \"1 300962047\\n\", \"1 479045471\\n\", \"956817411 1000000000\\n\", \"839933539 1000000000\\n\", \"18016963 1000000000\\n\", \"804463085 1\\n\", \"982546509 1\\n\", \"865662637 1\\n\", \"500000000 515868890\\n\", \"500000000 693952314\\n\", \"500000000 577068442\\n\", \"97590986 500000000\\n\", \"275674410 500000000\\n\", \"453757834 500000000\\n\", \"310973933 310973932\\n\", \"194090061 194090063\\n\", \"728340333 728340331\\n\", \"611471244 611471251\\n\", \"943610807 943610806\\n\", \"486624528 486624569\\n\", \"355140669 355140562\\n\", \"370754498 370754723\\n\", \"310973932 310973933\\n\", \"194090063 194090061\\n\", \"728340331 728340333\\n\", \"611471251 611471244\\n\", \"943610806 943610807\\n\", \"486624569 486624528\\n\", \"355140562 355140669\\n\", \"370754723 370754498\\n\", \"1 3\\n\", \"3 1\\n\", \"2 2\\n\", \"1 4\\n\", \"2 3\\n\", \"3 2\\n\", \"4 1\\n\"], \"outputs\": [\"4\\n\", \"5\\n\", \"1\\n\", \"2\\n\", \"2\\n\", \"500000001\\n\", \"500000001\\n\", \"1999936805\\n\", \"1006177186\\n\", \"1757835091\\n\", \"509460797\\n\", \"261146454\\n\", \"1307707417\\n\", \"1956733985\\n\", \"1839852485\\n\", \"1017851489\\n\", \"61439312\\n\", \"150481024\\n\", \"239522736\\n\", \"1956733985\\n\", \"1839852485\\n\", \"1017851489\\n\", \"402231543\\n\", \"491273255\\n\", \"432831319\\n\", \"1015808858\\n\", \"1193887001\\n\", \"1077006614\\n\", \"597537504\\n\", \"775621118\\n\", \"953699599\\n\", \"621912604\\n\", \"388152264\\n\", \"1456626719\\n\", \"1222892906\\n\", \"1887160182\\n\", \"973204768\\n\", \"710242885\\n\", \"741469514\\n\", \"621912604\\n\", \"388152264\\n\", \"1456626719\\n\", \"1222892906\\n\", \"1887160182\\n\", \"973204768\\n\", \"710242885\\n\", \"741469514\\n\", \"2\\n\", \"2\\n\", \"3\\n\", \"3\\n\", \"4\\n\", \"4\\n\", \"3\\n\"]}", "source": "primeintellect"}
You are given $a$ uppercase Latin letters 'A' and $b$ letters 'B'. The period of the string is the smallest such positive integer $k$ that $s_i = s_{i~mod~k}$ ($0$-indexed) for each $i$. Note that this implies that $k$ won't always divide $a+b = |s|$. For example, the period of string "ABAABAA" is $3$, the period of "AAAA" is $1$, and the period of "AABBB" is $5$. Find the number of different periods over all possible strings with $a$ letters 'A' and $b$ letters 'B'. -----Input----- The first line contains two integers $a$ and $b$ ($1 \le a, b \le 10^9$) — the number of letters 'A' and 'B', respectively. -----Output----- Print the number of different periods over all possible strings with $a$ letters 'A' and $b$ letters 'B'. -----Examples----- Input 2 4 Output 4 Input 5 3 Output 5 -----Note----- All the possible periods for the first example: $3$ "BBABBA" $4$ "BBAABB" $5$ "BBBAAB" $6$ "AABBBB" All the possible periods for the second example: $3$ "BAABAABA" $5$ "BAABABAA" $6$ "BABAAABA" $7$ "BAABAAAB" $8$ "AAAAABBB" Note that these are not the only possible strings for the given periods. Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0
{"tests": "{\"inputs\": [\"8 3\\nNO NO YES YES YES NO\\n\", \"9 8\\nYES NO\\n\", \"3 2\\nNO NO\\n\", \"2 2\\nYES\\n\", \"2 2\\nNO\\n\", \"7 2\\nYES NO YES YES NO YES\\n\", \"18 7\\nYES YES YES YES YES YES YES NO NO NO NO NO\\n\", \"50 3\\nNO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO YES NO\\n\", \"19 15\\nNO YES YES YES NO\\n\", \"3 2\\nNO NO\\n\", \"3 2\\nNO YES\\n\", \"3 2\\nYES NO\\n\", \"3 2\\nYES YES\\n\", \"26 17\\nNO YES YES YES NO YES NO YES YES YES\\n\", \"12 2\\nYES YES YES YES YES YES YES YES YES YES YES\\n\", \"16 2\\nNO NO NO NO NO NO NO NO NO NO NO NO NO NO NO\\n\", \"42 20\\nYES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES\\n\", \"37 14\\nNO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO\\n\", \"29 10\\nYES NO YES NO YES NO YES YES YES YES YES NO NO NO NO NO YES YES YES YES\\n\", \"37 3\\nYES NO YES NO YES NO YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES NO NO YES NO NO YES YES YES YES NO\\n\", \"44 11\\nNO NO YES NO YES NO YES YES YES YES YES YES YES YES YES YES YES YES YES NO YES YES YES YES YES NO NO YES NO NO YES YES YES NO\\n\", \"50 49\\nNO YES\\n\", \"50 49\\nYES YES\\n\", \"50 49\\nNO NO\\n\", \"50 49\\nYES NO\\n\", \"46 42\\nNO YES YES YES NO\\n\", \"45 26\\nYES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES\\n\", \"45 26\\nNO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO\\n\", \"50 3\\nNO YES NO YES NO YES NO YES NO YES NO YES NO YES NO YES NO YES NO YES NO YES NO YES NO YES NO YES NO YES NO YES NO YES NO YES NO YES NO YES NO YES NO YES NO YES NO YES\\n\", \"50 2\\nNO YES NO YES NO YES NO YES NO YES NO YES NO YES NO YES NO YES NO YES NO YES NO YES NO YES NO YES NO YES NO YES NO YES NO YES NO YES NO YES NO YES NO YES NO YES NO YES NO\\n\", \"50 3\\nNO YES NO YES NO YES NO YES NO YES NO YES NO YES NO YES NO YES NO YES NO YES NO YES NO YES YES YES YES YES NO YES NO YES NO YES NO YES NO YES NO YES NO YES NO YES NO YES\\n\", \"49 2\\nNO YES NO YES NO YES NO YES NO YES NO YES NO YES NO YES NO YES NO YES NO YES NO NO NO YES NO YES NO YES NO YES NO YES NO YES NO YES NO YES NO YES NO YES NO YES NO YES\\n\", \"35 22\\nNO NO NO NO NO NO NO NO NO NO NO NO NO NO\\n\", \"46 41\\nYES YES YES YES YES YES\\n\", \"12 4\\nYES YES NO NO NO NO NO YES YES\\n\", \"50 2\\nYES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES\\n\", \"50 4\\nYES YES YES YES YES NO YES YES YES YES NO NO YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES NO YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES\\n\", \"34 5\\nYES YES YES YES YES NO YES YES YES YES NO NO YES YES YES NO NO YES NO YES YES YES YES YES YES YES YES YES YES YES\\n\", \"50 43\\nYES NO YES NO YES YES YES YES\\n\", \"38 30\\nNO NO YES NO YES NO NO NO NO\\n\", \"50 50\\nNO\\n\", \"50 50\\nYES\\n\", \"5 3\\nYES NO YES\\n\", \"30 2\\nYES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES\\n\", \"50 50\\nYES\\n\", \"27 27\\nYES\\n\", \"28 2\\nYES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES\\n\", \"50 2\\nYES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES\\n\", \"8 3\\nYES NO YES NO YES NO\\n\", \"42 30\\nNO YES YES NO NO YES NO YES NO YES NO NO YES\\n\", \"50 49\\nYES YES\\n\", \"50 3\\nYES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES\\n\", \"7 5\\nYES NO YES\\n\", \"8 4\\nNO YES NO YES NO\\n\", \"50 50\\nNO\\n\", \"50 48\\nYES NO YES\\n\", \"29 14\\nYES NO YES NO NO YES YES NO NO YES YES NO NO YES YES YES\\n\", \"10 3\\nNO YES NO YES NO YES NO YES\\n\", \"10 5\\nYES NO YES NO YES NO\\n\"], \"outputs\": [\"Ab Ac Ab Ac Af Ag Ah Ag \\n\", \"Ab Ac Ad Ae Af Ag Ah Ai Ac \\n\", \"Ab Ab Ab \\n\", \"Ab Ac \\n\", \"Ab Ab \\n\", \"Ab Ac Ac Ae Af Af Ah \\n\", \"Ab Ac Ad Ae Af Ag Ah Ai Aj Ak Al Am An Ai Aj Ak Al Am \\n\", \"Ab Ac Ab Ac Ab Ac Ab Ac Ab Ac Ab Ac Ab Ac Ab Ac Ab Ac Ab Ac Ab Ac Ab Ac Ab Ac Ab Ac Ab Ac Ab Ac Ab Ac Ab Ac Ab Ac Ab Ac Ab Ac Ab Ac Ab Ac Ab Ac Bx Ac \\n\", \"Ab Ac Ad Ae Af Ag Ah Ai Aj Ak Al Am An Ao Ab Aq Ar As Af \\n\", \"Ab Ab Ab \\n\", \"Ab Ab Ad \\n\", \"Ab Ac Ac \\n\", \"Ab Ac Ad \\n\", \"Ab Ac Ad Ae Af Ag Ah Ai Aj Ak Al Am An Ao Ap Aq Ab As At Au Af Aw Ah Ay Az Ba \\n\", \"Ab Ac Ad Ae Af Ag Ah Ai Aj Ak Al Am \\n\", \"Ab Ab Ab Ab Ab Ab Ab Ab Ab Ab Ab Ab Ab Ab Ab Ab \\n\", \"Ab Ac Ad Ae Af Ag Ah Ai Aj Ak Al Am An Ao Ap Aq Ar As At Au Av Aw Ax Ay Az Ba Bb Bc Bd Be Bf Bg Bh Bi Bj Bk Bl Bm Bn Bo Bp Bq \\n\", \"Ab Ac Ad Ae Af Ag Ah Ai Aj Ak Al Am An Ab Ac Ad Ae Af Ag Ah Ai Aj Ak Al Am An Ab Ac Ad Ae Af Ag Ah Ai Aj Ak Al \\n\", \"Ab Ac Ad Ae Af Ag Ah Ai Aj Ak Ac Am Ae Ao Ag Aq Ar As At Au Am Ae Ao Ag Aq Ba Bb Bc Bd \\n\", \"Ab Ac Ad Ac Af Ac Ah Ac Aj Ak Al Am An Ao Ap Aq Ar As At Au Av Aw Ax Ay Az Ba Bb Ba Bb Be Bb Be Bh Bi Bj Bk Bj \\n\", \"Ab Ac Ad Ae Af Ag Ah Ai Aj Ak Ab Ac An Ae Ap Ag Ar As At Au Av Aw Ax Ay Az Ba Bb Bc Bd Au Bf Bg Bh Bi Bj Ba Bb Bm Bd Au Bp Bq Br Bi \\n\", \"Ab Ac Ad Ae Af Ag Ah Ai Aj Ak Al Am An Ao Ap Aq Ar As At Au Av Aw Ax Ay Az Ba Bb Bc Bd Be Bf Bg Bh Bi Bj Bk Bl Bm Bn Bo Bp Bq Br Bs Bt Bu Bv Bw Ab By \\n\", \"Ab Ac Ad Ae Af Ag Ah Ai Aj Ak Al Am An Ao Ap Aq Ar As At Au Av Aw Ax Ay Az Ba Bb Bc Bd Be Bf Bg Bh Bi Bj Bk Bl Bm Bn Bo Bp Bq Br Bs Bt Bu Bv Bw Bx By \\n\", \"Ab Ac Ad Ae Af Ag Ah Ai Aj Ak Al Am An Ao Ap Aq Ar As At Au Av Aw Ax Ay Az Ba Bb Bc Bd Be Bf Bg Bh Bi Bj Bk Bl Bm Bn Bo Bp Bq Br Bs Bt Bu Bv Bw Ab Ac \\n\", \"Ab Ac Ad Ae Af Ag Ah Ai Aj Ak Al Am An Ao Ap Aq Ar As At Au Av Aw Ax Ay Az Ba Bb Bc Bd Be Bf Bg Bh Bi Bj Bk Bl Bm Bn Bo Bp Bq Br Bs Bt Bu Bv Bw Bx Ac \\n\", \"Ab Ac Ad Ae Af Ag Ah Ai Aj Ak Al Am An Ao Ap Aq Ar As At Au Av Aw Ax Ay Az Ba Bb Bc Bd Be Bf Bg Bh Bi Bj Bk Bl Bm Bn Bo Bp Ab Br Bs Bt Af \\n\", \"Ab Ac Ad Ae Af Ag Ah Ai Aj Ak Al Am An Ao Ap Aq Ar As At Au Av Aw Ax Ay Az Ba Bb Bc Bd Be Bf Bg Bh Bi Bj Bk Bl Bm Bn Bo Bp Bq Br Bs Bt \\n\", \"Ab Ac Ad Ae Af Ag Ah Ai Aj Ak Al Am An Ao Ap Aq Ar As At Au Av Aw Ax Ay Az Ab Ac Ad Ae Af Ag Ah Ai Aj Ak Al Am An Ao Ap Aq Ar As At Au \\n\", \"Ab Ac Ab Ae Ab Ag Ab Ai Ab Ak Ab Am Ab Ao Ab Aq Ab As Ab Au Ab Aw Ab Ay Ab Ba Ab Bc Ab Be Ab Bg Ab Bi Ab Bk Ab Bm Ab Bo Ab Bq Ab Bs Ab Bu Ab Bw Ab By \\n\", \"Ab Ab Ad Ad Af Af Ah Ah Aj Aj Al Al An An Ap Ap Ar Ar At At Av Av Ax Ax Az Az Bb Bb Bd Bd Bf Bf Bh Bh Bj Bj Bl Bl Bn Bn Bp Bp Br Br Bt Bt Bv Bv Bx Bx \\n\", \"Ab Ac Ab Ae Ab Ag Ab Ai Ab Ak Ab Am Ab Ao Ab Aq Ab As Ab Au Ab Aw Ab Ay Ab Ba Ab Bc Bd Be Bf Bg Bf Bi Bf Bk Bf Bm Bf Bo Bf Bq Bf Bs Bf Bu Bf Bw Bf By \\n\", \"Ab Ab Ad Ad Af Af Ah Ah Aj Aj Al Al An An Ap Ap Ar Ar At At Av Av Ax Ax Ax Ax Bb Bb Bd Bd Bf Bf Bh Bh Bj Bj Bl Bl Bn Bn Bp Bp Br Br Bt Bt Bv Bv Bx \\n\", \"Ab Ac Ad Ae Af Ag Ah Ai Aj Ak Al Am An Ao Ap Aq Ar As At Au Av Ab Ac Ad Ae Af Ag Ah Ai Aj Ak Al Am An Ao \\n\", \"Ab Ac Ad Ae Af Ag Ah Ai Aj Ak Al Am An Ao Ap Aq Ar As At Au Av Aw Ax Ay Az Ba Bb Bc Bd Be Bf Bg Bh Bi Bj Bk Bl Bm Bn Bo Bp Bq Br Bs Bt Bu \\n\", \"Ab Ac Ad Ae Af Ad Ae Af Ad Ae Al Am \\n\", \"Ab Ac Ad Ae Af Ag Ah Ai Aj Ak Al Am An Ao Ap Aq Ar As At Au Av Aw Ax Ay Az Ba Bb Bc Bd Be Bf Bg Bh Bi Bj Bk Bl Bm Bn Bo Bp Bq Br Bs Bt Bu Bv Bw Bx By \\n\", \"Ab Ac Ad Ae Af Ag Ah Ai Ag Ak Al Am An Al Am Aq Ar As At Au Av Aw Ax Ay Az Ba Bb Bc Bd Be Bc Bg Bh Bi Bj Bk Bl Bm Bn Bo Bp Bq Br Bs Bt Bu Bv Bw Bx By \\n\", \"Ab Ac Ad Ae Af Ag Ah Ai Aj Ag Al Am An Ao Al Am Ar As At Am Ar Aw At Ay Az Ba Bb Bc Bd Be Bf Bg Bh Bi \\n\", \"Ab Ac Ad Ae Af Ag Ah Ai Aj Ak Al Am An Ao Ap Aq Ar As At Au Av Aw Ax Ay Az Ba Bb Bc Bd Be Bf Bg Bh Bi Bj Bk Bl Bm Bn Bo Bp Bq Br Ac Bt Ae Bv Bw Bx By \\n\", \"Ab Ac Ad Ae Af Ag Ah Ai Aj Ak Al Am An Ao Ap Aq Ar As At Au Av Aw Ax Ay Az Ba Bb Bc Bd Ab Ac Bg Ae Bi Ag Ah Ai Aj \\n\", \"Ab Ac Ad Ae Af Ag Ah Ai Aj Ak Al Am An Ao Ap Aq Ar As At Au Av Aw Ax Ay Az Ba Bb Bc Bd Be Bf Bg Bh Bi Bj Bk Bl Bm Bn Bo Bp Bq Br Bs Bt Bu Bv Bw Bx Ab \\n\", \"Ab Ac Ad Ae Af Ag Ah Ai Aj Ak Al Am An Ao Ap Aq Ar As At Au Av Aw Ax Ay Az Ba Bb Bc Bd Be Bf Bg Bh Bi Bj Bk Bl Bm Bn Bo Bp Bq Br Bs Bt Bu Bv Bw Bx By \\n\", \"Ab Ac Ad Ac Af \\n\", \"Ab Ac Ad Ae Af Ag Ah Ai Aj Ak Al Am An Ao Ap Aq Ar As At Au Av Aw Ax Ay Az Ba Bb Bc Bd Be \\n\", \"Ab Ac Ad Ae Af Ag Ah Ai Aj Ak Al Am An Ao Ap Aq Ar As At Au Av Aw Ax Ay Az Ba Bb Bc Bd Be Bf Bg Bh Bi Bj Bk Bl Bm Bn Bo Bp Bq Br Bs Bt Bu Bv Bw Bx By \\n\", \"Ab Ac Ad Ae Af Ag Ah Ai Aj Ak Al Am An Ao Ap Aq Ar As At Au Av Aw Ax Ay Az Ba Bb \\n\", \"Ab Ac Ad Ae Af Ag Ah Ai Aj Ak Al Am An Ao Ap Aq Ar As At Au Av Aw Ax Ay Az Ba Bb Bc \\n\", \"Ab Ac Ad Ae Af Ag Ah Ai Aj Ak Al Am An Ao Ap Aq Ar As At Au Av Aw Ax Ay Az Ba Bb Bc Bd Be Bf Bg Bh Bi Bj Bk Bl Bm Bn Bo Bp Bq Br Bs Bt Bu Bv Bw Bx By \\n\", \"Ab Ac Ad Ac Af Ac Ah Ac \\n\", \"Ab Ac Ad Ae Af Ag Ah Ai Aj Ak Al Am An Ao Ap Aq Ar As At Au Av Aw Ax Ay Az Ba Bb Bc Bd Ab Bf Bg Ae Af Bj Ah Bl Aj Bn Al Am Bq \\n\", \"Ab Ac Ad Ae Af Ag Ah Ai Aj Ak Al Am An Ao Ap Aq Ar As At Au Av Aw Ax Ay Az Ba Bb Bc Bd Be Bf Bg Bh Bi Bj Bk Bl Bm Bn Bo Bp Bq Br Bs Bt Bu Bv Bw Bx By \\n\", \"Ab Ac Ad Ae Af Ag Ah Ai Aj Ak Al Am An Ao Ap Aq Ar As At Au Av Aw Ax Ay Az Ba Bb Bc Bd Be Bf Bg Bh Bi Bj Bk Bl Bm Bn Bo Bp Bq Br Bs Bt Bu Bv Bw Bx By \\n\", \"Ab Ac Ad Ae Af Ac Ah \\n\", \"Ab Ac Ad Ab Af Ad Ah Af \\n\", \"Ab Ac Ad Ae Af Ag Ah Ai Aj Ak Al Am An Ao Ap Aq Ar As At Au Av Aw Ax Ay Az Ba Bb Bc Bd Be Bf Bg Bh Bi Bj Bk Bl Bm Bn Bo Bp Bq Br Bs Bt Bu Bv Bw Bx Ab \\n\", \"Ab Ac Ad Ae Af Ag Ah Ai Aj Ak Al Am An Ao Ap Aq Ar As At Au Av Aw Ax Ay Az Ba Bb Bc Bd Be Bf Bg Bh Bi Bj Bk Bl Bm Bn Bo Bp Bq Br Bs Bt Bu Bv Bw Ac By \\n\", \"Ab Ac Ad Ae Af Ag Ah Ai Aj Ak Al Am An Ao Ac Aq Ae Af At Au Ai Aj Ax Ay Am An Bb Bc Bd \\n\", \"Ab Ac Ab Ae Ab Ag Ab Ai Ab Ak \\n\", \"Ab Ac Ad Ae Af Ac Ah Ae Aj Ac \\n\"]}", "source": "primeintellect"}
In the army, it isn't easy to form a group of soldiers that will be effective on the battlefield. The communication is crucial and thus no two soldiers should share a name (what would happen if they got an order that Bob is a scouter, if there are two Bobs?). A group of soldiers is effective if and only if their names are different. For example, a group (John, Bob, Limak) would be effective, while groups (Gary, Bob, Gary) and (Alice, Alice) wouldn't. You are a spy in the enemy's camp. You noticed n soldiers standing in a row, numbered 1 through n. The general wants to choose a group of k consecutive soldiers. For every k consecutive soldiers, the general wrote down whether they would be an effective group or not. You managed to steal the general's notes, with n - k + 1 strings s_1, s_2, ..., s_{n} - k + 1, each either "YES" or "NO". The string s_1 describes a group of soldiers 1 through k ("YES" if the group is effective, and "NO" otherwise). The string s_2 describes a group of soldiers 2 through k + 1. And so on, till the string s_{n} - k + 1 that describes a group of soldiers n - k + 1 through n. Your task is to find possible names of n soldiers. Names should match the stolen notes. Each name should be a string that consists of between 1 and 10 English letters, inclusive. The first letter should be uppercase, and all other letters should be lowercase. Names don't have to be existing names — it's allowed to print "Xyzzzdj" or "T" for example. Find and print any solution. It can be proved that there always exists at least one solution. -----Input----- The first line of the input contains two integers n and k (2 ≤ k ≤ n ≤ 50) — the number of soldiers and the size of a group respectively. The second line contains n - k + 1 strings s_1, s_2, ..., s_{n} - k + 1. The string s_{i} is "YES" if the group of soldiers i through i + k - 1 is effective, and "NO" otherwise. -----Output----- Find any solution satisfying all given conditions. In one line print n space-separated strings, denoting possible names of soldiers in the order. The first letter of each name should be uppercase, while the other letters should be lowercase. Each name should contain English letters only and has length from 1 to 10. If there are multiple valid solutions, print any of them. -----Examples----- Input 8 3 NO NO YES YES YES NO Output Adam Bob Bob Cpqepqwer Limak Adam Bob Adam Input 9 8 YES NO Output R Q Ccccccccc Ccocc Ccc So Strong Samples Ccc Input 3 2 NO NO Output Na Na Na -----Note----- In the first sample, there are 8 soldiers. For every 3 consecutive ones we know whether they would be an effective group. Let's analyze the provided sample output: First three soldiers (i.e. Adam, Bob, Bob) wouldn't be an effective group because there are two Bobs. Indeed, the string s_1 is "NO". Soldiers 2 through 4 (Bob, Bob, Cpqepqwer) wouldn't be effective either, and the string s_2 is "NO". Soldiers 3 through 5 (Bob, Cpqepqwer, Limak) would be effective, and the string s_3 is "YES". ..., Soldiers 6 through 8 (Adam, Bob, Adam) wouldn't be effective, and the string s_6 is "NO". Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0
{"tests": "{\"inputs\": [\"1\\n\", \"2\\n\", \"3\\n\", \"4\\n\", \"5\\n\", \"6\\n\", \"7\\n\", \"9\\n\", \"11\\n\", \"13\\n\", \"15\\n\", \"17\\n\", \"19\\n\", \"21\\n\", \"23\\n\", \"25\\n\", \"27\\n\", \"29\\n\", \"31\\n\", \"33\\n\", \"35\\n\", \"37\\n\", \"39\\n\", \"41\\n\", \"43\\n\", \"45\\n\", \"47\\n\", \"49\\n\", \"51\\n\", \"53\\n\", \"55\\n\", \"57\\n\", \"59\\n\", \"61\\n\", \"63\\n\", \"65\\n\", \"67\\n\", \"69\\n\", \"71\\n\", \"73\\n\", \"75\\n\", \"77\\n\", \"79\\n\", \"81\\n\", \"83\\n\", \"85\\n\", \"87\\n\", \"89\\n\", \"91\\n\", \"93\\n\", \"95\\n\", \"97\\n\", \"99\\n\"], \"outputs\": [\"-1\\n\", \"bb\\nww\\n\\nbb\\nww\\n\", \"-1\\n\", \"bbbb\\nbwwb\\nbwwb\\nbbbb\\n\\nwwww\\nwbbw\\nwbbw\\nwwww\\n\\nbbbb\\nbwwb\\nbwwb\\nbbbb\\n\\nwwww\\nwbbw\\nwbbw\\nwwww\\n\", \"-1\\n\", \"bbbbbb\\nbwwwwb\\nbwbbwb\\nbwbbwb\\nbwwwwb\\nbbbbbb\\n\\nwwwwww\\nwbbbbw\\nwbwwbw\\nwbwwbw\\nwbbbbw\\nwwwwww\\n\\nbbbbbb\\nbwwwwb\\nbwbbwb\\nbwbbwb\\nbwwwwb\\nbbbbbb\\n\\nwwwwww\\nwbbbbw\\nwbwwbw\\nwbwwbw\\nwbbbbw\\nwwwwww\\n\\nbbbbbb\\nbwwwwb\\nbwbbwb\\nbwbbwb\\nbwwwwb\\nbbbbbb\\n\\nwwwwww\\nwbbbbw\\nwbwwbw\\nwbwwbw\\nwbbbbw\\nwwwwww\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\"]}", "source": "primeintellect"}
You are given a cube of size k × k × k, which consists of unit cubes. Two unit cubes are considered neighbouring, if they have common face. Your task is to paint each of k^3 unit cubes one of two colours (black or white), so that the following conditions must be satisfied: each white cube has exactly 2 neighbouring cubes of white color; each black cube has exactly 2 neighbouring cubes of black color. -----Input----- The first line contains integer k (1 ≤ k ≤ 100), which is size of the cube. -----Output----- Print -1 if there is no solution. Otherwise, print the required painting of the cube consequently by layers. Print a k × k matrix in the first k lines, showing how the first layer of the cube should be painted. In the following k lines print a k × k matrix — the way the second layer should be painted. And so on to the last k-th layer. Note that orientation of the cube in the space does not matter. Mark a white unit cube with symbol "w" and a black one with "b". Use the format of output data, given in the test samples. You may print extra empty lines, they will be ignored. -----Examples----- Input 1 Output -1 Input 2 Output bb ww bb ww Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0.5
{"tests": "{\"inputs\": [\"2 3 5\\n4 6\\n\", \"2 3 5\\n4 7\\n\", \"6 3 5\\n12 11 12 11 12 11\\n\", \"1 4 3\\n12\\n\", \"10 1 17\\n3 1 1 2 1 3 4 4 1 4\\n\", \"3 6 3\\n2 5 9\\n\", \"7 26 8\\n5 11 8 10 12 12 3\\n\", \"11 5 85\\n19 20 6 7 6 2 1 5 8 15 6\\n\", \"7 7 2\\n5 2 4 2 4 1 1\\n\", \"8 5 10\\n1 7 2 5 2 1 6 5\\n\", \"10 27 34\\n11 8 11 5 14 1 12 10 12 6\\n\", \"4 2 2\\n1 2 3 1\\n\", \"5 1 45\\n7 14 15 7 7\\n\", \"9 7 50\\n10 9 10 10 8 3 5 10 2\\n\", \"5 0 0\\n100 100 100 200 301\\n\", \"5 1000000000 1000000000\\n100 200 300 400 501\\n\", \"1 1 0\\n1\\n\", \"1 1 0\\n3\\n\", \"1 0 0\\n10000\\n\", \"1 0 1\\n1\\n\", \"1 1 0\\n2\\n\", \"1 0 0\\n1\\n\", \"1 0 1\\n2\\n\", \"5 4 1\\n1 2 1 1 1\\n\", \"20 5 0\\n9 4 1 2 1 1 4 4 9 1 9 3 8 1 8 9 4 1 7 4\\n\", \"100 1019 35\\n34 50 60 47 49 49 59 60 37 51 3 86 93 33 78 31 75 87 26 74 32 30 52 57 44 10 33 52 78 16 36 77 53 49 98 82 93 85 16 86 19 57 17 24 73 93 37 46 27 87 35 76 33 91 96 55 34 65 97 66 7 30 45 68 18 51 77 43 99 76 35 47 6 1 83 49 67 85 89 17 20 7 49 33 43 59 53 71 86 71 3 47 65 59 40 34 35 44 46 64\\n\", \"2 1 0\\n1 1\\n\", \"2 3 0\\n3 3\\n\", \"1 1000000000 1000000000\\n1\\n\", \"3 2 0\\n1 1 1\\n\", \"2 2 0\\n1 3\\n\", \"1 3 0\\n3\\n\", \"2 2 0\\n1 1\\n\", \"5 1 0\\n1 1 1 1 1\\n\", \"4 2 0\\n1 1 1 1\\n\", \"1 2 0\\n3\\n\", \"4 1 0\\n1 1 1 1\\n\", \"2 2 0\\n3 1\\n\", \"6 1000000000 1000000000\\n12 11 12 11 12 11\\n\", \"2 3 0\\n5 1\\n\", \"1 3 0\\n5\\n\", \"2 1000000000 1000000000\\n10000 1000\\n\", \"5 1000000000 1000000000\\n1 2 3 4 5\\n\", \"2 1 0\\n2 2\\n\", \"2 1000000000 1000000000\\n10000 10000\\n\", \"2 3 0\\n3 4\\n\", \"3 4 0\\n3 3 3\\n\", \"4 3 1\\n3 1 1 1\\n\", \"1 2 0\\n1\\n\", \"5 2 0\\n1 1 1 1 1\\n\", \"2 1000000000 1000000000\\n1 1\\n\", \"3 1 0\\n1 1 1\\n\"], \"outputs\": [\"2\\n\", \"2\\n\", \"1\\n\", \"0\\n\", \"8\\n\", \"2\\n\", \"6\\n\", \"11\\n\", \"6\\n\", \"6\\n\", \"9\\n\", \"3\\n\", \"4\\n\", \"8\\n\", \"0\\n\", \"5\\n\", \"1\\n\", \"0\\n\", \"0\\n\", \"1\\n\", \"1\\n\", \"0\\n\", \"0\\n\", \"5\\n\", \"5\\n\", \"59\\n\", \"1\\n\", \"1\\n\", \"1\\n\", \"2\\n\", \"1\\n\", \"1\\n\", \"2\\n\", \"1\\n\", \"2\\n\", \"1\\n\", \"1\\n\", \"1\\n\", \"6\\n\", \"1\\n\", \"1\\n\", \"2\\n\", \"5\\n\", \"1\\n\", \"2\\n\", \"1\\n\", \"2\\n\", \"3\\n\", \"1\\n\", \"2\\n\", \"2\\n\", \"1\\n\"]}", "source": "primeintellect"}
На тренировку по подготовке к соревнованиям по программированию пришли n команд. Тренер для каждой команды подобрал тренировку, комплект задач для i-й команды занимает a_{i} страниц. В распоряжении тренера есть x листов бумаги, у которых обе стороны чистые, и y листов, у которых только одна сторона чистая. При печати условия на листе первого типа можно напечатать две страницы из условий задач, а при печати на листе второго типа — только одну. Конечно, на листе нельзя печатать условия из двух разных комплектов задач. Обратите внимание, что при использовании листов, у которых обе стороны чистые, не обязательно печатать условие на обеих сторонах, одна из них может остаться чистой. Вам предстоит определить максимальное количество команд, которым тренер сможет напечатать комплекты задач целиком. -----Входные данные----- В первой строке входных данных следуют три целых числа n, x и y (1 ≤ n ≤ 200 000, 0 ≤ x, y ≤ 10^9) — количество команд, количество листов бумаги с двумя чистыми сторонами и количество листов бумаги с одной чистой стороной. Во второй строке входных данных следует последовательность из n целых чисел a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 10 000), где i-е число равно количеству страниц в комплекте задач для i-й команды. -----Выходные данные----- Выведите единственное целое число — максимальное количество команд, которым тренер сможет напечатать комплекты задач целиком. -----Примеры----- Входные данные 2 3 5 4 6 Выходные данные 2 Входные данные 2 3 5 4 7 Выходные данные 2 Входные данные 6 3 5 12 11 12 11 12 11 Выходные данные 1 -----Примечание----- В первом тестовом примере можно напечатать оба комплекта задач. Один из возможных ответов — напечатать весь первый комплект задач на листах с одной чистой стороной (после этого останется 3 листа с двумя чистыми сторонами и 1 лист с одной чистой стороной), а второй комплект напечатать на трех листах с двумя чистыми сторонами. Во втором тестовом примере можно напечатать оба комплекта задач. Один из возможных ответов — напечатать первый комплект задач на двух листах с двумя чистыми сторонами (после этого останется 1 лист с двумя чистыми сторонами и 5 листов с одной чистой стороной), а второй комплект напечатать на одном листе с двумя чистыми сторонами и на пяти листах с одной чистой стороной. Таким образом, тренер использует все листы для печати. В третьем тестовом примере можно напечатать только один комплект задач (любой из трёх 11-страничных). Для печати 11-страничного комплекта задач будет израсходована вся бумага. Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0
{"tests": "{\"inputs\": [\"4\\n2 4 4 2\\n\", \"4\\n2 2 3 5\\n\", \"4\\n100003 100004 100005 100006\\n\", \"8\\n5 3 3 3 3 4 4 4\\n\", \"10\\n123 124 123 124 2 2 2 2 9 9\\n\", \"8\\n10 10 10 10 11 10 11 10\\n\", \"1\\n1000000\\n\", \"10\\n10519 10519 10520 10520 10520 10521 10521 10521 10522 10523\\n\", \"100\\n4116 4116 4117 4117 4117 4117 4118 4119 4119 4119 4119 4120 4120 4120 4120 4121 4122 4123 4123 4123 4123 4124 4124 4124 4124 4125 4126 4126 4126 4126 4127 4127 4127 4127 4128 4128 4128 4128 4129 4129 4130 4130 4131 4132 4133 4133 4134 4134 4135 4135 4136 4137 4137 4137 4138 4139 4140 4140 4141 4141 4142 4143 4143 4143 4144 4144 4144 4144 4145 4145 4145 4146 4146 4146 4147 4147 4147 4147 4148 4148 4148 4149 4149 4149 4150 4151 4151 4151 4152 4152 4153 4153 4154 4154 4155 4155 4155 4155 4156 4156\\n\", \"10\\n402840 873316 567766 493234 711262 291654 683001 496971 64909 190173\\n\", \"45\\n1800 4967 1094 551 871 3505 846 960 4868 4304 2112 496 2293 2128 2430 2119 4497 2159 774 4520 3535 1013 452 1458 1895 1191 958 1133 416 2613 4172 3926 1665 4237 539 101 2448 1212 2631 4530 3026 412 1006 2515 1922\\n\", \"69\\n2367 2018 3511 1047 1789 2332 1082 4678 2036 4108 2357 339 536 2272 3638 2588 754 3795 375 506 3243 1033 4531 1216 4266 2547 3540 4642 1256 2248 4705 14 629 876 2304 1673 4186 2356 3172 2664 3896 552 4293 1507 3307 2661 3143 4565 58 1298 4380 2738 917 2054 2676 4464 1314 3752 3378 1823 4219 3142 4258 1833 886 4286 4040 1070 2206\\n\", \"93\\n13 2633 3005 1516 2681 3262 1318 1935 665 2450 2601 1644 214 929 4873 955 1983 3945 3488 2927 1516 1026 2150 974 150 2442 2610 1664 636 3369 266 2536 3132 2515 2582 1169 4462 4961 200 2848 4793 2795 4657 474 2640 2488 378 544 1805 1390 1548 2683 1474 4027 1724 2078 183 3717 1727 1780 552 2905 4260 1444 2906 3779 400 1491 1467 4480 3680 2539 4681 2875 4021 2711 106 853 3094 4531 4066 372 2129 2577 3996 2350 943 4478 3058 3333 4592 232 2780\\n\", \"21\\n580 3221 3987 2012 35 629 1554 654 756 2254 4307 2948 3457 4612 4620 4320 1777 556 3088 348 1250\\n\", \"45\\n4685 272 3481 3942 952 3020 329 4371 2923 2057 4526 2791 1674 3269 829 2713 3006 2166 1228 2795 983 1065 3875 4028 3429 3720 697 734 4393 1176 2820 1173 4598 2281 2549 4341 1504 172 4230 1193 3022 3742 1232 3433 1871\\n\", \"69\\n3766 2348 4437 4438 3305 386 2026 1629 1552 400 4770 4069 4916 1926 2037 1079 2801 854 803 216 2152 4622 1494 3786 775 3615 4766 2781 235 836 1892 2234 3563 1843 4314 3836 320 2776 4796 1378 380 2421 3057 964 4717 1122 620 530 3455 1639 1618 3109 3120 564 2382 1995 1173 4510 286 1088 218 734 2779 3738 456 1668 4476 2780 3555\\n\", \"4\\n2 2 2 4\\n\", \"8\\n10 10 10 11 14 14 14 16\\n\", \"2\\n2 3\\n\", \"3\\n2 3 5\\n\", \"8\\n2 1000000 2 1000000 2 1000000 2 1000000\\n\", \"4\\n2 4 6 8\\n\", \"4\\n2 3 6 8\\n\", \"5\\n2 2 3 4 5\\n\", \"5\\n1000000 999999 999999 999999 999999\\n\", \"6\\n2 2 2 2 2 2\\n\", \"4\\n2 4 5 5\\n\", \"20\\n4 4 8 4 5 6 7 4 5 4 6 4 4 5 7 6 5 8 8 4\\n\", \"10\\n8 4 6 6 8 5 7 7 6 8\\n\", \"11\\n4 4 9 9 3 8 8 8 6 4 3\\n\", \"8\\n2 3 3 4 4 5 5 5\\n\", \"4\\n3 3 3 2\\n\", \"5\\n3 3 10 100 100\\n\", \"8\\n9 9 9 8 8 7 7 6\\n\", \"4\\n5 6 6 7\\n\", \"5\\n9 9 5 2 2\\n\", \"6\\n3 4 100 200 1001 1002\\n\", \"6\\n3 4 5 100 101 102\\n\", \"5\\n2 2 4 6 6\\n\", \"6\\n2 3 8 10 13 14\\n\", \"7\\n2 2 2 2 2 2 2\\n\", \"5\\n5 2 2 2 2\\n\", \"6\\n3 4 100 200 1000 1001\\n\", \"5\\n5 5 7 9 9\\n\", \"5\\n8 8 7 4 4\\n\", \"5\\n2 2 5 8 9\\n\", \"5\\n4 4 4 2 2\\n\", \"5\\n3 10 100 1000 10000\\n\", \"6\\n10 10 7 4 2 2\\n\", \"6\\n5 5 7 9 10 10\\n\", \"7\\n10 10 7 5 3 2 2\\n\", \"7\\n10 9 9 9 9 2 2\\n\"], \"outputs\": [\"8\\n\", \"0\\n\", \"10000800015\\n\", \"25\\n\", \"15270\\n\", \"210\\n\", \"0\\n\", \"221372362\\n\", \"427591742\\n\", \"0\\n\", \"0\\n\", \"7402552\\n\", \"4403980\\n\", \"0\\n\", \"0\\n\", \"12334860\\n\", \"0\\n\", \"140\\n\", \"0\\n\", \"0\\n\", \"1000000000004\\n\", \"0\\n\", \"0\\n\", \"8\\n\", \"999998000001\\n\", \"4\\n\", \"0\\n\", \"149\\n\", \"92\\n\", \"84\\n\", \"26\\n\", \"6\\n\", \"300\\n\", \"114\\n\", \"30\\n\", \"18\\n\", \"3003\\n\", \"404\\n\", \"12\\n\", \"26\\n\", \"4\\n\", \"4\\n\", \"3000\\n\", \"45\\n\", \"32\\n\", \"16\\n\", \"8\\n\", \"0\\n\", \"20\\n\", \"50\\n\", \"20\\n\", \"81\\n\"]}", "source": "primeintellect"}
In the evening, after the contest Ilya was bored, and he really felt like maximizing. He remembered that he had a set of n sticks and an instrument. Each stick is characterized by its length l_{i}. Ilya decided to make a rectangle from the sticks. And due to his whim, he decided to make rectangles in such a way that maximizes their total area. Each stick is used in making at most one rectangle, it is possible that some of sticks remain unused. Bending sticks is not allowed. Sticks with lengths a_1, a_2, a_3 and a_4 can make a rectangle if the following properties are observed: a_1 ≤ a_2 ≤ a_3 ≤ a_4 a_1 = a_2 a_3 = a_4 A rectangle can be made of sticks with lengths of, for example, 3 3 3 3 or 2 2 4 4. A rectangle cannot be made of, for example, sticks 5 5 5 7. Ilya also has an instrument which can reduce the length of the sticks. The sticks are made of a special material, so the length of each stick can be reduced by at most one. For example, a stick with length 5 can either stay at this length or be transformed into a stick of length 4. You have to answer the question — what maximum total area of the rectangles can Ilya get with a file if makes rectangles from the available sticks? -----Input----- The first line of the input contains a positive integer n (1 ≤ n ≤ 10^5) — the number of the available sticks. The second line of the input contains n positive integers l_{i} (2 ≤ l_{i} ≤ 10^6) — the lengths of the sticks. -----Output----- The first line of the output must contain a single non-negative integer — the maximum total area of the rectangles that Ilya can make from the available sticks. -----Examples----- Input 4 2 4 4 2 Output 8 Input 4 2 2 3 5 Output 0 Input 4 100003 100004 100005 100006 Output 10000800015 Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0
{"tests": "{\"inputs\": [\"6\\n1 2 2 2 1 2\\n2\\n5 5\\n\", \"5\\n1 2 3 4 5\\n1\\n15\\n\", \"5\\n1 1 1 3 3\\n3\\n2 1 6\\n\", \"5\\n1 1 1 1 2\\n3\\n1 1 4\\n\", \"5\\n1 1 1 1 1\\n4\\n1 1 2 1\\n\", \"6\\n2 1 2 2 1 2\\n2\\n5 5\\n\", \"8\\n2 5 3 1 4 2 3 4\\n3\\n10 6 8\\n\", \"1\\n959139\\n1\\n470888\\n\", \"3\\n2 2 1\\n1\\n5\\n\", \"3\\n1 2 2\\n1\\n5\\n\", \"5\\n1 2 3 4 5\\n1\\n10\\n\", \"5\\n325539 329221 106895 882089 718673\\n5\\n699009 489855 430685 939232 282330\\n\", \"10\\n30518 196518 274071 359971 550121 204862 843967 173607 619138 690754\\n3\\n171337 183499 549873\\n\", \"3\\n2 1 1\\n1\\n3\\n\", \"4\\n2 2 2 1\\n3\\n2 2 2\\n\", \"3\\n1 2 3\\n1\\n3\\n\", \"2\\n1 2\\n2\\n3 1\\n\", \"5\\n3 3 2 2 1\\n2\\n8 3\\n\", \"3\\n3 2 5\\n1\\n10\\n\", \"3\\n1 5 1\\n1\\n6\\n\", \"5\\n1 2 3 4 5\\n3\\n1 2 3\\n\", \"3\\n5 2 3\\n1\\n10\\n\", \"3\\n2 1 3\\n1\\n6\\n\", \"3\\n3 2 1\\n1\\n6\\n\", \"2\\n5 5\\n1\\n5\\n\", \"3\\n1 2 3\\n2\\n1 2\\n\", \"4\\n1 2 3 4\\n3\\n1 2 3\\n\", \"4\\n4 3 2 1\\n3\\n3 2 1\\n\", \"2\\n5 3\\n1\\n5\\n\", \"5\\n1 1 1 1 1\\n4\\n1 1 1 1\\n\", \"3\\n3 3 2\\n1\\n8\\n\", \"8\\n2 2 1 2 2 1 2 4\\n2\\n9 8\\n\", \"4\\n3 2 1 4\\n3\\n3 2 1\\n\", \"5\\n3 3 2 3 1\\n2\\n11 1\\n\", \"3\\n2 1 3\\n1\\n3\\n\", \"4\\n2 3 3 2\\n2\\n5 3\\n\", \"16\\n2 2 2 1 2 2 2 1 1 2 2 2 1 2 2 2\\n4\\n7 7 7 7\\n\", \"2\\n1 1\\n1\\n1\\n\", \"3\\n1 2 1\\n2\\n3 2\\n\", \"3\\n2 3 5\\n1\\n10\\n\", \"5\\n1 2 3 4 5\\n2\\n3 7\\n\", \"4\\n1 2 3 4\\n2\\n1 2\\n\", \"8\\n1 2 2 2 1 2 1 1\\n2\\n5 5\\n\", \"3\\n5 5 4\\n1\\n14\\n\", \"22\\n3 2 3 3 3 1 1 2 1 2 1 1 1 2 2 3 1 2 3 3 3 3\\n5\\n5 16 5 5 15\\n\", \"4\\n2 2 1 2\\n1\\n7\\n\", \"7\\n2 2 2 1 2 2 2\\n1\\n13\\n\", \"2\\n1 2\\n1\\n1\\n\", \"14\\n5 5 5 5 4 4 4 3 3 3 4 4 4 4\\n3\\n32 21 4\\n\", \"5\\n2 2 1 2 2\\n1\\n9\\n\", \"1\\n2\\n1\\n2\\n\"], \"outputs\": [\"YES\\n2 L\\n1 R\\n4 L\\n3 L\\n\", \"YES\\n5 L\\n4 L\\n3 L\\n2 L\\n\", \"NO\", \"YES\\n5 L\\n4 L\\n\", \"NO\", \"YES\\n3 L\\n2 L\\n4 L\\n3 L\\n\", \"NO\", \"NO\", \"YES\\n2 R\\n2 L\\n\", \"YES\\n2 L\\n1 R\\n\", \"NO\", \"NO\", \"NO\", \"NO\", \"NO\", \"NO\", \"NO\", \"YES\\n2 R\\n2 L\\n2 R\\n\", \"YES\\n3 L\\n2 L\\n\", \"NO\", \"NO\", \"YES\\n1 R\\n1 R\\n\", \"YES\\n3 L\\n2 L\\n\", \"YES\\n1 R\\n1 R\\n\", \"NO\", \"NO\", \"NO\", \"NO\", \"NO\", \"NO\", \"YES\\n2 R\\n2 L\\n\", \"NO\", \"NO\", \"YES\\n4 L\\n3 L\\n2 L\\n\", \"NO\", \"NO\", \"YES\\n3 R\\n3 L\\n2 L\\n4 R\\n4 L\\n3 L\\n4 L\\n3 R\\n3 R\\n5 L\\n4 R\\n4 R\\n\", \"NO\", \"NO\", \"YES\\n3 L\\n2 L\\n\", \"NO\", \"NO\", \"NO\", \"YES\\n2 R\\n2 L\\n\", \"YES\\n1 R\\n4 R\\n4 R\\n4 R\\n4 R\\n4 R\\n4 L\\n3 L\\n6 L\\n5 L\\n4 L\\n5 L\\n7 L\\n6 L\\n5 R\\n5 R\\n5 R\\n\", \"YES\\n4 L\\n3 L\\n2 L\\n\", \"YES\\n5 L\\n4 L\\n3 L\\n2 L\\n1 R\\n1 R\\n\", \"NO\", \"YES\\n4 R\\n4 R\\n4 R\\n4 L\\n3 L\\n2 L\\n5 L\\n4 L\\n3 L\\n2 R\\n2 R\\n\", \"YES\\n4 L\\n3 L\\n2 L\\n1 R\\n\", \"YES\\n\"]}", "source": "primeintellect"}
There was an epidemic in Monstropolis and all monsters became sick. To recover, all monsters lined up in queue for an appointment to the only doctor in the city. Soon, monsters became hungry and began to eat each other. One monster can eat other monster if its weight is strictly greater than the weight of the monster being eaten, and they stand in the queue next to each other. Monsters eat each other instantly. There are no monsters which are being eaten at the same moment. After the monster A eats the monster B, the weight of the monster A increases by the weight of the eaten monster B. In result of such eating the length of the queue decreases by one, all monsters after the eaten one step forward so that there is no empty places in the queue again. A monster can eat several monsters one after another. Initially there were n monsters in the queue, the i-th of which had weight a_{i}. For example, if weights are [1, 2, 2, 2, 1, 2] (in order of queue, monsters are numbered from 1 to 6 from left to right) then some of the options are: the first monster can't eat the second monster because a_1 = 1 is not greater than a_2 = 2; the second monster can't eat the third monster because a_2 = 2 is not greater than a_3 = 2; the second monster can't eat the fifth monster because they are not neighbors; the second monster can eat the first monster, the queue will be transformed to [3, 2, 2, 1, 2]. After some time, someone said a good joke and all monsters recovered. At that moment there were k (k ≤ n) monsters in the queue, the j-th of which had weight b_{j}. Both sequences (a and b) contain the weights of the monsters in the order from the first to the last. You are required to provide one of the possible orders of eating monsters which led to the current queue, or to determine that this could not happen. Assume that the doctor didn't make any appointments while monsters were eating each other. -----Input----- The first line contains single integer n (1 ≤ n ≤ 500) — the number of monsters in the initial queue. The second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 10^6) — the initial weights of the monsters. The third line contains single integer k (1 ≤ k ≤ n) — the number of monsters in the queue after the joke. The fourth line contains k integers b_1, b_2, ..., b_{k} (1 ≤ b_{j} ≤ 5·10^8) — the weights of the monsters after the joke. Monsters are listed in the order from the beginning of the queue to the end. -----Output----- In case if no actions could lead to the final queue, print "NO" (without quotes) in the only line. Otherwise print "YES" (without quotes) in the first line. In the next n - k lines print actions in the chronological order. In each line print x — the index number of the monster in the current queue which eats and, separated by space, the symbol 'L' if the monster which stays the x-th in the queue eats the monster in front of him, or 'R' if the monster which stays the x-th in the queue eats the monster behind him. After each eating the queue is enumerated again. When one monster eats another the queue decreases. If there are several answers, print any of them. -----Examples----- Input 6 1 2 2 2 1 2 2 5 5 Output YES 2 L 1 R 4 L 3 L Input 5 1 2 3 4 5 1 15 Output YES 5 L 4 L 3 L 2 L Input 5 1 1 1 3 3 3 2 1 6 Output NO -----Note----- In the first example, initially there were n = 6 monsters, their weights are [1, 2, 2, 2, 1, 2] (in order of queue from the first monster to the last monster). The final queue should be [5, 5]. The following sequence of eatings leads to the final queue: the second monster eats the monster to the left (i.e. the first monster), queue becomes [3, 2, 2, 1, 2]; the first monster (note, it was the second on the previous step) eats the monster to the right (i.e. the second monster), queue becomes [5, 2, 1, 2]; the fourth monster eats the mosnter to the left (i.e. the third monster), queue becomes [5, 2, 3]; the finally, the third monster eats the monster to the left (i.e. the second monster), queue becomes [5, 5]. Note that for each step the output contains numbers of the monsters in their current order in the queue. Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0
{"tests": "{\"inputs\": [\"2 2\\n5 5\\n2 2\\n\", \"2 2\\n5 6\\n2 2\\n\", \"4 1\\n4 1 10 1\\n3 2 10 1\\n\", \"53 3\\n2 3 1 2 2 6 1 5 6 1 5 3 1 1 6 4 3 2 4 1 1 4 4 3 5 6 1 2 2 1 2 2 2 5 4 2 1 4 2 5 3 1 3 6 6 4 4 5 2 1 2 2 1\\n5 2 6 3 5 5 1 1 2 4 6 1 4 2 4 1 4 4 5 3 6 4 6 5 6 3 4 4 3 1 1 5 5 1 1 2 4 4 3 1 2 2 3 2 3 2 2 4 5 1 5 2 6\\n\", \"59 4\\n8 1 7 5 4 2 7 5 7 4 4 2 3 7 6 5 1 4 6 6 2 4 6 7 6 7 5 8 8 8 6 3 7 7 2 8 5 5 8 1 2 3 3 6 8 2 3 1 8 3 1 2 3 7 7 3 2 7 5\\n1 4 8 6 3 8 2 2 5 7 4 8 8 8 7 8 3 5 4 5 2 6 3 7 3 5 7 8 1 3 7 7 4 8 6 7 6 6 3 7 7 6 8 2 1 8 6 8 4 6 6 2 1 8 1 1 1 1 8\\n\", \"81 2\\n1 2 3 1 3 3 3 3 2 2 2 1 2 1 2 1 2 1 3 3 2 2 1 3 1 3 2 2 3 2 3 1 3 1 1 2 3 1 1 2 1 2 1 2 3 3 1 3 2 2 1 1 3 3 1 1 3 2 1 3 1 3 1 2 1 2 3 3 2 1 3 3 2 1 2 1 3 2 2 3 3\\n2 3 1 3 1 1 2 3 2 2 3 3 3 2 2 3 3 1 1 3 1 2 2 1 3 2 3 3 3 3 3 1 1 3 1 2 2 1 1 3 2 3 1 1 2 2 1 1 2 1 3 1 3 2 3 3 1 2 2 2 1 3 2 3 3 1 2 3 1 3 1 1 1 3 3 2 3 3 2 3 2\\n\", \"17 3\\n8 2 4 5 4 5 3 6 6 6 4 1 5 5 8 6 3\\n8 4 1 5 1 3 5 6 7 1 5 5 2 6 4 5 4\\n\", \"33 4\\n8 6 6 8 2 5 5 5 2 7 2 6 1 6 7 4 7 4 3 8 6 8 8 4 6 4 8 1 2 1 3 6 8\\n7 2 5 2 2 5 2 3 6 8 3 2 2 5 2 7 2 4 7 3 4 6 5 6 3 6 3 3 7 2 3 2 1\\n\", \"69 2\\n2 3 2 3 2 2 2 3 1 2 1 2 3 3 1 2 1 1 1 2 1 2 1 2 2 2 3 2 2 1 2 1 2 2 1 2 2 2 2 3 1 1 2 1 1 1 2 1 3 1 3 1 3 2 2 2 1 1 3 3 1 2 1 3 3 3 1 2 2\\n2 1 3 3 2 1 1 3 3 3 1 1 2 3 3 3 3 1 1 3 3 3 3 3 3 2 2 3 2 3 2 1 3 3 3 3 3 2 2 3 3 3 3 2 2 3 1 3 3 2 2 3 3 3 1 2 2 2 3 2 1 3 2 2 1 2 1 1 2\\n\", \"65 3\\n2 1 4 2 4 1 3 2 3 4 3 4 4 3 1 4 4 3 3 1 4 2 1 1 4 3 4 4 3 1 2 4 4 4 3 2 1 4 1 3 4 1 4 3 4 1 1 3 3 2 2 1 2 2 3 2 1 4 2 3 3 3 3 4 3\\n1 3 1 3 3 2 1 4 3 4 3 3 1 3 4 2 3 3 1 1 1 3 3 1 1 2 3 3 4 2 2 1 1 3 1 3 4 1 1 2 4 4 3 3 2 2 4 4 4 4 1 1 3 2 3 3 3 2 4 4 1 1 3 4 3\\n\", \"94 3\\n4 2 1 6 1 1 1 5 1 3 3 3 6 1 6 6 3 5 3 1 4 1 3 6 4 5 3 4 6 5 5 2 1 5 4 5 6 5 2 2 6 5 4 6 1 3 5 1 2 5 5 2 1 3 4 5 6 4 3 1 4 4 1 5 4 4 2 2 2 4 4 3 6 2 6 1 5 6 1 3 5 5 1 3 5 3 5 2 6 1 3 6 1 5\\n5 6 3 5 4 1 4 6 3 1 4 4 3 3 6 2 1 1 4 6 4 2 4 1 3 1 5 3 6 2 5 6 1 6 6 2 2 2 2 5 2 6 1 4 1 5 1 3 6 6 5 3 2 6 6 2 5 6 3 4 4 4 2 3 1 2 4 5 2 6 3 3 3 3 1 1 1 3 6 3 3 6 5 2 4 1 2 2 1 6 3 5 1 5\\n\", \"1 1\\n1\\n1\\n\", \"1 1000000\\n1\\n2\\n\", \"1 1\\n2\\n1\\n\", \"1 1\\n1\\n2\\n\", \"1 1\\n3\\n1\\n\", \"1 1\\n1\\n3\\n\", \"2 2\\n1 5\\n1 1\\n\", \"2 1\\n1 1\\n2 2\\n\", \"3 2\\n4 1 1\\n1 4 3\\n\", \"69 6969\\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\\n\", \"2 3\\n3 7\\n2 1\\n\", \"4 2\\n6 6 2 2\\n2 2 6 6\\n\", \"3 2\\n6 9 1\\n3 3 4\\n\", \"9 5\\n7 2 9 1 1 9 1 2 7\\n10 1 9 10 9 2 9 6 4\\n\", \"10 2\\n4 6 7 4 4 3 10 3 6 9\\n6 2 7 7 6 4 10 3 2 4\\n\", \"10 3\\n7 9 1 3 6 4 4 6 10 4\\n3 2 6 10 9 4 7 5 8 6\\n\", \"5 3\\n3 1 5 1 1\\n1 1 4 5 5\\n\", \"4 4\\n3 2 1 10\\n9 10 7 5\\n\", \"5 2\\n8 3 8 7 3\\n3 6 3 7 3\\n\", \"5 2\\n4 6 3 5 10\\n7 8 8 2 4\\n\", \"4 4\\n5 1 2 1\\n1 9 1 3\\n\", \"3 2\\n4 1 4\\n9 3 9\\n\", \"2 1\\n6 9\\n7 10\\n\", \"2 1\\n6 4\\n5 3\\n\", \"5 4\\n3 6 7 8 9\\n9 6 3 1 3\\n\", \"4 1\\n8 2 10 6\\n8 3 10 7\\n\", \"3 5\\n1 1 1\\n10 1 10\\n\", \"5 3\\n1 1 2 2 3\\n6 1 7 7 10\\n\", \"5 4\\n1 8 10 10 3\\n7 4 2 2 6\\n\", \"5 4\\n9 7 2 1 3\\n9 8 9 7 4\\n\", \"4 1\\n9 8 6 4\\n8 8 6 3\\n\", \"44 14\\n28 27 28 14 29 6 5 20 10 16 19 12 14 28 1 16 8 1 15 4 22 1 8 26 28 30 1 28 2 6 17 21 21 8 29 3 30 10 9 17 13 10 29 28\\n6 21 13 6 9 8 5 23 24 7 7 19 13 4 25 3 24 15 19 14 26 8 16 3 15 3 1 1 29 9 30 28 3 5 18 14 14 5 4 27 19 18 13 15\\n\", \"5 2\\n6 9 5 8 10\\n5 8 7 6 3\\n\", \"29 15\\n11 8 3 9 30 27 29 13 18 14 30 22 27 22 19 1 14 24 28 21 9 18 3 15 3 12 19 12 24\\n18 11 23 11 2 1 1 1 1 1 28 7 14 27 21 14 21 27 1 6 17 3 4 9 8 18 4 23 15\\n\", \"2 1\\n24 21\\n24 20\\n\", \"3 3\\n6 1 6\\n1 1 1\\n\", \"49 7\\n16 17 2 3 4 4 30 26 24 4 16 4 15 24 28 8 5 17 8 13 11 1 29 3 28 11 8 17 25 7 8 5 9 23 20 4 2 25 21 3 23 27 21 30 3 10 5 25 19\\n11 14 21 21 5 1 18 16 28 3 10 28 19 16 13 11 10 15 26 2 11 1 26 1 8 17 11 25 16 18 9 29 14 11 4 7 3 8 15 12 5 25 15 7 18 9 2 23 18\\n\", \"5 3\\n1 6 1 3 6\\n6 1 1 1 1\\n\", \"4 1\\n1 1 1 1\\n2 1 1 2\\n\"], \"outputs\": [\"YES\\n\", \"NO\\n\", \"YES\\n\", \"YES\\n\", \"YES\\n\", \"YES\\n\", \"YES\\n\", \"YES\\n\", \"YES\\n\", \"YES\\n\", \"YES\\n\", \"YES\\n\", \"YES\\n\", \"YES\\n\", \"YES\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"YES\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"YES\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"YES\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"YES\\n\", \"YES\\n\", \"NO\\n\", \"YES\\n\", \"NO\\n\", \"NO\\n\", \"YES\\n\", \"NO\\n\", \"YES\\n\", \"NO\\n\", \"NO\\n\"]}", "source": "primeintellect"}
Vova has taken his summer practice this year and now he should write a report on how it went. Vova has already drawn all the tables and wrote down all the formulas. Moreover, he has already decided that the report will consist of exactly $n$ pages and the $i$-th page will include $x_i$ tables and $y_i$ formulas. The pages are numbered from $1$ to $n$. Vova fills the pages one after another, he can't go filling page $i + 1$ before finishing page $i$ and he can't skip pages. However, if he draws strictly more than $k$ tables in a row or writes strictly more than $k$ formulas in a row then he will get bored. Vova wants to rearrange tables and formulas in each page in such a way that he doesn't get bored in the process. Vova can't move some table or some formula to another page. Note that the count doesn't reset on the start of the new page. For example, if the page ends with $3$ tables and the next page starts with $5$ tables, then it's counted as $8$ tables in a row. Help Vova to determine if he can rearrange tables and formulas on each page in such a way that there is no more than $k$ tables in a row and no more than $k$ formulas in a row. -----Input----- The first line contains two integers $n$ and $k$ ($1 \le n \le 3 \cdot 10^5$, $1 \le k \le 10^6$). The second line contains $n$ integers $x_1, x_2, \dots, x_n$ ($1 \le x_i \le 10^6$) — the number of tables on the $i$-th page. The third line contains $n$ integers $y_1, y_2, \dots, y_n$ ($1 \le y_i \le 10^6$) — the number of formulas on the $i$-th page. -----Output----- Print "YES" if Vova can rearrange tables and formulas on each page in such a way that there is no more than $k$ tables in a row and no more than $k$ formulas in a row. Otherwise print "NO". -----Examples----- Input 2 2 5 5 2 2 Output YES Input 2 2 5 6 2 2 Output NO Input 4 1 4 1 10 1 3 2 10 1 Output YES -----Note----- In the first example the only option to rearrange everything is the following (let table be 'T' and formula be 'F'): page $1$: "TTFTTFT" page $2$: "TFTTFTT" That way all blocks of tables have length $2$. In the second example there is no way to fit everything in such a way that there are no more than $2$ tables in a row and $2$ formulas in a row. Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0
{"tests": "{\"inputs\": [\"1 2\\n-1\\n?\\n\", \"2 100\\n-10000\\n0\\n1\\n\", \"4 5\\n?\\n1\\n?\\n1\\n?\\n\", \"68 -9959\\n-3666\\n-3501\\n9169\\n5724\\n1478\\n-643\\n-3039\\n-5537\\n-4295\\n-1856\\n-6720\\n6827\\n-39\\n-9509\\n-7005\\n1942\\n-5173\\n-4564\\n2390\\n4604\\n-6098\\n-9847\\n-9708\\n2382\\n7421\\n8716\\n9718\\n9895\\n-4553\\n-8275\\n4771\\n1538\\n-8131\\n9912\\n-4334\\n-3702\\n7035\\n-106\\n-1298\\n-6190\\n1321\\n332\\n7673\\n-5336\\n5141\\n-2289\\n-1748\\n-3132\\n-4454\\n-2357\\n2661\\n2756\\n-9964\\n2859\\n-1277\\n-259\\n-2472\\n-9222\\n2316\\n-6965\\n-7811\\n-8158\\n-9712\\n105\\n-960\\n-1058\\n9264\\n-7353\\n-2555\\n\", \"5 10\\n5400\\n-900\\n-1014\\n325\\n-32\\n1\\n\", \"5 -6\\n-5400\\n-2700\\n414\\n151\\n-26\\n1\\n\", \"10 100\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n?\\n\", \"9 100\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n?\\n\", \"4 0\\n0\\n-10000\\n10000\\n-10000\\n10000\\n\", \"5 3\\n?\\n?\\n?\\n?\\n?\\n?\\n\", \"4 4\\n?\\n?\\n?\\n?\\n?\\n\", \"5 6\\n-5400\\n-2700\\n414\\n151\\n-26\\n1\\n\", \"5 10\\n30\\n27\\n-53\\n5\\n-10\\n1\\n\", \"64 4\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n1\\n\", \"3 0\\n5\\n3\\n?\\n13\\n\", \"4 0\\n?\\n10000\\n-10000\\n15\\n?\\n\", \"4 0\\n0\\n3\\n?\\n13\\n?\\n\", \"5 0\\n?\\n-123\\n534\\n?\\n?\\n?\\n\", \"1 10000\\n?\\n?\\n\", \"1 10000\\n0\\n0\\n\", \"1 10000\\n?\\n0\\n\", \"7 10000\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n10000\\n\", \"32 2\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n1\\n\", \"64 2\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n1\\n\", \"100 100\\n1\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n\", \"1 0\\n1\\n?\\n\", \"2 0\\n0\\n?\\n?\\n\", \"18 10\\n3\\n2\\n4\\n0\\n0\\n0\\n0\\n0\\n0\\n6\\n5\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n1\\n\", \"17 10\\n3\\n6\\n0\\n0\\n0\\n0\\n0\\n0\\n7\\n9\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n1\\n\", \"3 0\\n1\\n?\\n?\\n?\\n\", \"2 0\\n?\\n?\\n1\\n\", \"1 0\\n-1\\n?\\n\", \"17 10\\n1\\n1\\n2\\n4\\n2\\n0\\n3\\n6\\n8\\n3\\n7\\n1\\n9\\n8\\n2\\n3\\n2\\n1\\n\", \"18 16\\n13\\n0\\n7\\n3\\n5\\n12\\n11\\n3\\n15\\n2\\n13\\n12\\n12\\n1\\n3\\n2\\n13\\n2\\n1\\n\", \"1 0\\n?\\n?\\n\", \"102 31\\n-1\\n4\\n-6\\n3\\n2\\n-1\\n-4\\n7\\n-4\\n-1\\n-1\\n3\\n4\\n2\\n1\\n-7\\n7\\n2\\n-4\\n4\\n5\\n-4\\n-4\\n3\\n1\\n7\\n-2\\n9\\n-6\\n-12\\n-9\\n-1\\n6\\n3\\n-6\\n-1\\n-7\\n0\\n-3\\n0\\n0\\n-1\\n4\\n-4\\n2\\n-5\\n4\\n-6\\n3\\n-2\\n-7\\n-1\\n7\\n5\\n1\\n2\\n-8\\n1\\n-1\\n0\\n-5\\n-7\\n1\\n6\\n7\\n4\\n5\\n-4\\n-3\\n-3\\n1\\n-2\\n-2\\n1\\n-5\\n-1\\n0\\n4\\n-1\\n0\\n0\\n-1\\n-1\\n-5\\n-6\\n0\\n-3\\n0\\n5\\n4\\n10\\n-4\\n-2\\n6\\n-6\\n7\\n3\\n0\\n8\\n-4\\n1\\n4\\n5\\n\", \"26 10\\n8\\n2\\n7\\n7\\n7\\n7\\n7\\n0\\n2\\n6\\n8\\n5\\n7\\n9\\n1\\n1\\n0\\n3\\n5\\n5\\n3\\n2\\n1\\n0\\n0\\n0\\n1\\n\", \"53 10\\n1\\n1\\n5\\n8\\n3\\n2\\n9\\n9\\n6\\n2\\n8\\n7\\n0\\n3\\n1\\n2\\n3\\n1\\n4\\n3\\n9\\n5\\n8\\n4\\n2\\n0\\n9\\n0\\n8\\n5\\n4\\n5\\n3\\n2\\n4\\n2\\n9\\n8\\n4\\n9\\n3\\n1\\n2\\n9\\n2\\n3\\n0\\n2\\n0\\n9\\n2\\n4\\n7\\n1\\n\", \"84 10\\n9\\n9\\n1\\n5\\n7\\n1\\n9\\n0\\n9\\n0\\n2\\n1\\n4\\n2\\n8\\n7\\n5\\n2\\n4\\n6\\n1\\n4\\n2\\n2\\n1\\n7\\n6\\n9\\n0\\n6\\n4\\n0\\n3\\n8\\n9\\n8\\n3\\n4\\n0\\n0\\n4\\n5\\n2\\n5\\n7\\n1\\n9\\n2\\n1\\n0\\n0\\n0\\n2\\n3\\n6\\n7\\n1\\n3\\n1\\n4\\n6\\n9\\n5\\n4\\n8\\n9\\n2\\n6\\n8\\n6\\n4\\n2\\n0\\n7\\n3\\n7\\n9\\n8\\n3\\n9\\n1\\n4\\n7\\n0\\n1\\n\", \"44 10\\n9\\n5\\n1\\n4\\n5\\n0\\n9\\n7\\n8\\n7\\n1\\n5\\n2\\n9\\n1\\n6\\n9\\n6\\n0\\n6\\n3\\n6\\n7\\n8\\n7\\n4\\n2\\n2\\n9\\n5\\n4\\n4\\n5\\n2\\n3\\n7\\n7\\n2\\n4\\n0\\n3\\n1\\n8\\n9\\n5\\n\", \"18 10\\n3\\n6\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n6\\n1\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n1\\n\", \"100 10000\\n427\\n5059\\n4746\\n3792\\n2421\\n1434\\n4381\\n9757\\n9891\\n45\\n7135\\n933\\n8193\\n805\\n5369\\n8487\\n5065\\n4881\\n4459\\n4228\\n8920\\n5272\\n7420\\n5685\\n4612\\n2641\\n6890\\n2826\\n2318\\n6590\\n4634\\n5534\\n9709\\n3951\\n3604\\n8736\\n1303\\n9939\\n5769\\n3690\\n6163\\n2136\\n5933\\n4906\\n9187\\n808\\n7153\\n5830\\n2599\\n6141\\n5544\\n7001\\n7919\\n205\\n4770\\n1869\\n2840\\n6\\n100\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n\", \"19 10\\n-6\\n-1\\n-6\\n-1\\n-5\\n-5\\n-9\\n0\\n-7\\n-3\\n-7\\n0\\n-4\\n-4\\n-7\\n-6\\n-4\\n-4\\n-8\\n-1\\n\", \"100 10000\\n9137\\n5648\\n7125\\n5337\\n4138\\n5127\\n3419\\n7396\\n9781\\n6103\\n3941\\n9511\\n9183\\n4193\\n7945\\n52\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n\", \"2 0\\n?\\n1\\n?\\n\", \"30 1000\\n564\\n146\\n187\\n621\\n589\\n852\\n981\\n874\\n602\\n667\\n263\\n721\\n246\\n93\\n992\\n868\\n168\\n521\\n618\\n471\\n511\\n876\\n742\\n810\\n899\\n258\\n172\\n177\\n523\\n417\\n68\\n\", \"30 1000\\n832\\n350\\n169\\n416\\n972\\n507\\n385\\n86\\n581\\n80\\n59\\n281\\n635\\n507\\n86\\n639\\n257\\n738\\n325\\n285\\n688\\n20\\n263\\n763\\n443\\n467\\n952\\n928\\n590\\n876\\n13\\n\", \"1 0\\n?\\n1\\n\", \"100 2\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n0\\n-1\\n\", \"6 1000\\n63\\n0\\n0\\n16\\n0\\n0\\n1\\n\"], \"outputs\": [\"Yes\\n\", \"Yes\", \"No\", \"No\", \"Yes\", \"No\", \"No\", \"Yes\\n\", \"Yes\\n\", \"Yes\\n\", \"No\", \"Yes\", \"Yes\", \"No\", \"No\\n\", \"Yes\\n\", \"Yes\\n\", \"No\\n\", \"Yes\\n\", \"Yes\", \"Yes\\n\", \"No\", \"No\", \"No\", \"No\", \"No\\n\", \"Yes\\n\", \"No\", \"No\", \"No\\n\", \"Yes\\n\", \"No\\n\", \"No\", \"No\", \"No\\n\", \"No\", \"No\", \"No\", \"No\", \"No\", \"No\", \"No\", \"No\", \"No\", \"Yes\\n\", \"No\", \"No\", \"Yes\\n\", \"No\", \"No\"]}", "source": "primeintellect"}
100 years have passed since the last victory of the man versus computer in Go. Technologies made a huge step forward and robots conquered the Earth! It's time for the final fight between human and robot that will decide the faith of the planet. The following game was chosen for the fights: initially there is a polynomial P(x) = a_{n}x^{n} + a_{n} - 1x^{n} - 1 + ... + a_1x + a_0, with yet undefined coefficients and the integer k. Players alternate their turns. At each turn, a player pick some index j, such that coefficient a_{j} that stay near x^{j} is not determined yet and sets it to any value (integer or real, positive or negative, 0 is also allowed). Computer moves first. The human will be declared the winner if and only if the resulting polynomial will be divisible by Q(x) = x - k. Polynomial P(x) is said to be divisible by polynomial Q(x) if there exists a representation P(x) = B(x)Q(x), where B(x) is also some polynomial. Some moves have been made already and now you wonder, is it true that human can guarantee the victory if he plays optimally? -----Input----- The first line of the input contains two integers n and k (1 ≤ n ≤ 100 000, |k| ≤ 10 000) — the size of the polynomial and the integer k. The i-th of the following n + 1 lines contain character '?' if the coefficient near x^{i} - 1 is yet undefined or the integer value a_{i}, if the coefficient is already known ( - 10 000 ≤ a_{i} ≤ 10 000). Each of integers a_{i} (and even a_{n}) may be equal to 0. Please note, that it's not guaranteed that you are given the position of the game where it's computer's turn to move. -----Output----- Print "Yes" (without quotes) if the human has winning strategy, or "No" (without quotes) otherwise. -----Examples----- Input 1 2 -1 ? Output Yes Input 2 100 -10000 0 1 Output Yes Input 4 5 ? 1 ? 1 ? Output No -----Note----- In the first sample, computer set a_0 to - 1 on the first move, so if human can set coefficient a_1 to 0.5 and win. In the second sample, all coefficients are already set and the resulting polynomial is divisible by x - 100, so the human has won. Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0.625
{"tests": "{\"inputs\": [\"14\\n\", \"20\\n\", \"8192\\n\", \"1000000\\n\", \"959806\\n\", \"1452\\n\", \"4\\n\", \"6\\n\", \"8\\n\", \"9\\n\", \"10\\n\", \"12\\n\", \"15\\n\", \"16\\n\", \"110880\\n\", \"166320\\n\", \"221760\\n\", \"277200\\n\", \"332640\\n\", \"498960\\n\", \"554400\\n\", \"665280\\n\", \"720720\\n\", \"510510\\n\", \"570570\\n\", \"690690\\n\", \"959818\\n\", \"959878\\n\", \"959902\\n\", \"974847\\n\", \"974859\\n\", \"974931\\n\", \"885481\\n\", \"896809\\n\", \"908209\\n\", \"935089\\n\", \"720721\\n\", \"690691\\n\", \"959903\\n\", \"974932\\n\", \"935090\\n\", \"524288\\n\", \"524289\\n\", \"524286\\n\", \"531441\\n\", \"531442\\n\", \"531440\\n\", \"81\\n\", \"999958\\n\", \"2048\\n\"], \"outputs\": [\"6\\n\", \"15\\n\", \"8191\\n\", \"998677\\n\", \"239958\\n\", \"1206\\n\", \"3\\n\", \"3\\n\", \"7\\n\", \"7\\n\", \"4\\n\", \"6\\n\", \"8\\n\", \"11\\n\", \"55440\\n\", \"110879\\n\", \"110880\\n\", \"138600\\n\", \"166320\\n\", \"332639\\n\", \"415798\\n\", \"498958\\n\", \"540538\\n\", \"255248\\n\", \"285282\\n\", \"460455\\n\", \"239958\\n\", \"239978\\n\", \"239978\\n\", \"324954\\n\", \"324978\\n\", \"324980\\n\", \"442272\\n\", \"447944\\n\", \"453632\\n\", \"467064\\n\", \"355298\\n\", \"342864\\n\", \"479702\\n\", \"470060\\n\", \"463950\\n\", \"524287\\n\", \"174768\\n\", \"262110\\n\", \"526737\\n\", \"262490\\n\", \"265704\\n\", \"76\\n\", \"250008\\n\", \"1959\\n\"]}", "source": "primeintellect"}
Alice and Bob begin their day with a quick game. They first choose a starting number X_0 ≥ 3 and try to reach one million by the process described below. Alice goes first and then they take alternating turns. In the i-th turn, the player whose turn it is selects a prime number smaller than the current number, and announces the smallest multiple of this prime number that is not smaller than the current number. Formally, he or she selects a prime p < X_{i} - 1 and then finds the minimum X_{i} ≥ X_{i} - 1 such that p divides X_{i}. Note that if the selected prime p already divides X_{i} - 1, then the number does not change. Eve has witnessed the state of the game after two turns. Given X_2, help her determine what is the smallest possible starting number X_0. Note that the players don't necessarily play optimally. You should consider all possible game evolutions. -----Input----- The input contains a single integer X_2 (4 ≤ X_2 ≤ 10^6). It is guaranteed that the integer X_2 is composite, that is, is not prime. -----Output----- Output a single integer — the minimum possible X_0. -----Examples----- Input 14 Output 6 Input 20 Output 15 Input 8192 Output 8191 -----Note----- In the first test, the smallest possible starting number is X_0 = 6. One possible course of the game is as follows: Alice picks prime 5 and announces X_1 = 10 Bob picks prime 7 and announces X_2 = 14. In the second case, let X_0 = 15. Alice picks prime 2 and announces X_1 = 16 Bob picks prime 5 and announces X_2 = 20. Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0
{"tests": "{\"inputs\": [\"5 1 2 0 1 2\\n\", \"1 1 1 -1 -1 2\\n\", \"1 1 1 1 1 0\\n\", \"2 2 1 -2 -2 5\\n\", \"1000000000 1 1 1 1 1000000000000000000\\n\", \"1000000000 1 2 -100 -100 1\\n\", \"3 2 2 -100 -100 2\\n\", \"1000000000 1000000000 1000000000 100 -100 1000000000000000000\\n\", \"907122235 107269653 309181328 26 -64 242045007473044676\\n\", \"804 658 177 -95 37 9\\n\", \"2 1 1 31 -74 2712360435504330\\n\", \"230182675 73108597 42152975 -72 -8 93667970058209518\\n\", \"487599125 469431740 316230350 -77 57 18\\n\", \"1710 654 941 -81 -37 1281183940\\n\", \"568980902 147246752 87068387 -17 58 677739653\\n\", \"38 10 36 19 30 4054886\\n\", \"546978166 115293871 313560296 -33 54 215761558342792301\\n\", \"323544442 39059198 2970015 92 17 98\\n\", \"321575625 2929581 31407414 -40 -44 920902537044\\n\", \"5928 1508 4358 75 -4 794927060433551549\\n\", \"7310962 7564 6333485 -45 41 81980903005818\\n\", \"224 81 30 57 -13 8363\\n\", \"75081054 91 47131957 -94 -54 5588994022550344\\n\", \"185144 100489 52 32 -21 5752324832726786\\n\", \"61728 24280 17963 -19 81 652432745607745078\\n\", \"25699863 23288611 24796719 -45 46 437606836\\n\", \"475875319 333393831 284835031 22 7 90332975949346\\n\", \"372903 106681 40781 54 -40 6188704\\n\", \"923 452 871 -95 -55 273135237285890\\n\", \"672939 589365 391409 -54 -70 205083640\\n\", \"560010572 4172512 514044248 -78 13 97386\\n\", \"717485513 5935 3 -5 -67 28\\n\", \"138971202 137695723 48931985 -28 -3 68901440898766\\n\", \"910958510 60 98575 38 -99 97880\\n\", \"67163467 36963416 50381 -49 -12 76558237\\n\", \"557911547 9 460221236 -58 -96 74518856\\n\", \"85 37 69 30 47 131\\n\", \"852525230 538352221 97088953 -12 98 9197937568\\n\", \"885849694 703278210 46391 33 23 965949118732\\n\", \"976890548 675855343 988 -11 46 796041265897304\\n\", \"108774060 15274597 430014 -85 -94 6\\n\", \"2 2 2 -36 94 9429569334\\n\", \"713835677 404390162 67429 -91 10 178697004637242062\\n\", \"620330674 603592488 3 38 94 34309127789188\\n\", \"95 70 7 -36 -100 5\\n\", \"900854530 82 7 30 -88 6797628981503799\\n\", \"147834 6 2565 15 -35 166779\\n\", \"642762664 588605882 1 -47 82 8\\n\", \"122740849 8646067 70003215 -100 -80 70\\n\", \"73221379 4311914 992324 65 -40 705623357422685593\\n\"], \"outputs\": [\"3 1\", \"1 1\", \"1 1\", \"1 2\", \"168318977 168318977\", \"999999904 999999905\", \"1 1\", \"969796608 969796608\", \"23731316 525833901\", \"270 173\", \"1 1\", \"34918692 197804272\", \"320939970 167740992\", \"1568 945\", \"150920864 281916196\", \"18 36\", \"353006839 497349709\", \"105890973 69794440\", \"320222592 65760999\", \"4973 5148\", \"5246110 6302893\", \"130 205\", \"6742019 52104963\", \"56326 173503\", \"3174 1169\", \"24072870 13015404\", \"441571464 288459461\", \"161485 86089\", \"563 142\", \"503747 218115\", \"11882888 530616750\", \"71683921 71676253\", \"110585553 85995539\", \"304849180 291538135\", \"23368224 65407811\", \"246089810 106240697\", \"74 38\", \"84737577 321684009\", \"16593182 13087113\", \"652954007 789518296\", \"98184736 83340099\", \"1 1\", \"244834060 560206120\", \"200990066 258175045\", \"85 82\", \"66039616 641057009\", \"54423 144570\", \"355500874 409658689\", \"80795619 19413318\", \"62692638 21726334\"]}", "source": "primeintellect"}
Our bear's forest has a checkered field. The checkered field is an n × n table, the rows are numbered from 1 to n from top to bottom, the columns are numbered from 1 to n from left to right. Let's denote a cell of the field on the intersection of row x and column y by record (x, y). Each cell of the field contains growing raspberry, at that, the cell (x, y) of the field contains x + y raspberry bushes. The bear came out to walk across the field. At the beginning of the walk his speed is (dx, dy). Then the bear spends exactly t seconds on the field. Each second the following takes place: Let's suppose that at the current moment the bear is in cell (x, y). First the bear eats the raspberry from all the bushes he has in the current cell. After the bear eats the raspberry from k bushes, he increases each component of his speed by k. In other words, if before eating the k bushes of raspberry his speed was (dx, dy), then after eating the berry his speed equals (dx + k, dy + k). Let's denote the current speed of the bear (dx, dy) (it was increased after the previous step). Then the bear moves from cell (x, y) to cell (((x + dx - 1) mod n) + 1, ((y + dy - 1) mod n) + 1). Then one additional raspberry bush grows in each cell of the field. You task is to predict the bear's actions. Find the cell he ends up in if he starts from cell (sx, sy). Assume that each bush has infinitely much raspberry and the bear will never eat all of it. -----Input----- The first line of the input contains six space-separated integers: n, sx, sy, dx, dy, t (1 ≤ n ≤ 10^9; 1 ≤ sx, sy ≤ n;  - 100 ≤ dx, dy ≤ 100; 0 ≤ t ≤ 10^18). -----Output----- Print two integers — the coordinates of the cell the bear will end up in after t seconds. -----Examples----- Input 5 1 2 0 1 2 Output 3 1 Input 1 1 1 -1 -1 2 Output 1 1 -----Note----- Operation a mod b means taking the remainder after dividing a by b. Note that the result of the operation is always non-negative. For example, ( - 1) mod 3 = 2. In the first sample before the first move the speed vector will equal (3,4) and the bear will get to cell (4,1). Before the second move the speed vector will equal (9,10) and he bear will get to cell (3,1). Don't forget that at the second move, the number of berry bushes increased by 1. In the second sample before the first move the speed vector will equal (1,1) and the bear will get to cell (1,1). Before the second move, the speed vector will equal (4,4) and the bear will get to cell (1,1). Don't forget that at the second move, the number of berry bushes increased by 1. Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0
{"tests": "{\"inputs\": [\"2 2\\n0010\\n0100\\n\", \"3 4\\n001000\\n000010\\n000010\\n\", \"4 3\\n01110\\n01110\\n01110\\n01110\\n\", \"3 2\\n0000\\n0100\\n0100\\n\", \"1 89\\n0000000000000000000000000000000100000000000000010000000000010000000000000000000000000000000\\n\", \"2 73\\n000000000000000000000000000000000000000000000000000000000000000000000000000\\n000000000000000000000000000000000000000100000010000000000000000000000000000\\n\", \"3 61\\n000000000000000000000000000000000000000000000000000000000000000\\n000000000000000000000000000000000000000000000000000000000000000\\n000000000000000000000000000000000000000000000000000000000000000\\n\", \"4 53\\n0000000000000000000000000000000000000000000000000000000\\n0000000000000000000000000000000000000000000000000000000\\n0000000000000000000000000000000000000000000000000000000\\n0000000000000000000000000000000000000000000000000000000\\n\", \"5 93\\n00000000000000000000000000000000000000000000000000000000100000000000000000000000000000000001010\\n00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\n00000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\n00000000000000000000000000000010000000000000000000100000000000000000000000000000000000000000000\\n00000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000\\n\", \"6 77\\n0000000000000000100000000000000000000000000000000000000000000000000000000000000\\n0000000000000000000000000000000000000000000000000000000000000000010000000000000\\n0000000000010000000000000000000000000000000000000000000000000000000000000000010\\n0000000000000000000001000000000000000000000000000000000000000000000000000000000\\n0000000000000000000000000000000000000000000000000000000000000000000000000000000\\n0000000000000000000000000000000000000000000000000100000000000000000000000000000\\n\", \"7 65\\n0000000001000000000000000010000000000000000000000000000000000000000\\n0000000000000000000000000000000000000000000000000000000000000000000\\n0000000000000000000000000000000000000000000000000000000000000000000\\n0000000000000000000000000000000000000000000000000000000000000000000\\n0000000001000001000000000000000000000000000000000000000000000000000\\n0000000000000000000000000000000000000000000000000000000000000000000\\n0000000000000000000000000000000000000000000000000000000000000000000\\n\", \"8 57\\n00000000100000000000000000000000000000000000000000000000000\\n00000000000000010000000000000000000000000000000000000000000\\n00000000000000000000000000000000000100000000000000000000000\\n00000000000000000000000000000000000000000000000000000000000\\n00000000000000000000000000000000000100000000000000000000000\\n00000000000000000000000000000000000000000000000000000000000\\n00000000000010000000000000000000000000000000000000000000000\\n00000000000000000000000000000000000000000000000001000000000\\n\", \"12 13\\n000000000000000\\n000000000000000\\n000000000000000\\n000000000000000\\n000000000000000\\n000000000000000\\n010000000000000\\n000000000000000\\n000000000000000\\n000000000000000\\n000010000000000\\n000000000000000\\n\", \"13 1\\n000\\n000\\n000\\n000\\n000\\n000\\n000\\n000\\n000\\n000\\n000\\n000\\n000\\n\", \"1 33\\n00000100101110001101000000110100010\\n\", \"2 21\\n00100110100010010010010\\n01000001111001010000000\\n\", \"3 5\\n0001010\\n0100000\\n0100000\\n\", \"4 45\\n00010000101101100000101101000000100000001101100\\n01110000100111010011000000100000000001000001100\\n00000000001000100110100001000010011010001010010\\n01111110100100000101101010011000100100001000000\\n\", \"5 37\\n010100000000000000000110000110010000010\\n001101100010110011101000001010101101110\\n010000001000100010010100000000001010000\\n000000000100101000000101100001000001110\\n000010000000000000100001001000011100110\\n\", \"6 25\\n011001000100111010000101000\\n000000000010000010001000010\\n011001100001100001001001010\\n000000100000010000000000110\\n010001100001000001000000010\\n011000001001010111110000100\\n\", \"7 61\\n010000111100010100001000011010100001000000000011100000100010000\\n000010011000001000000100110101010001000000010001100000100100100\\n000010001000001000000100001000000100100011001110000111000000100\\n000000000101000011010000011000000101000001011001000011101010010\\n000010010011000000100000110000001000000101000000101000010000010\\n000010010101101100100100100011001011101010000101000010000101010\\n000100001100001001000000001000000001011000110010100000000010110\\n\", \"8 49\\n000100100000000111110010011100110100010010000011000\\n001000000101111000000001111100010010100000010000000\\n000000010000011100001000000000101000110010000100100\\n000000000001000110000011101101000000100000101010000\\n000000110001000101101000000001000000110001000110000\\n000100000000000000100100010011000001111101010100110\\n000000001000000010101111000100001100000000010111000\\n001000010000110000011100000000100110000010001000000\\n\", \"9 41\\n0011000000000101001101001000000001110000010\\n0000110000001010110010110010110010010001000\\n0001100010100000000001110100100001101000100\\n0001010101111010000000010010001001011111000\\n0101000101000011101011000000001100110010000\\n0001010000000000000001011000000100010101000\\n0000010011000000001000110001000010110001000\\n0000100010000110100001000000100010001111100\\n0000001110100001000001000110001110000100000\\n\", \"10 29\\n0000000000101001100001001011000\\n0001110100000000000000100010000\\n0010001001000011000100010001000\\n0001000010101000000010100010100\\n0111000000000000100100100010100\\n0001000100011111000100010100000\\n0000000000000001000001001011000\\n0000101110000001010001011001110\\n0000001000101010011000001100100\\n0100010000101011010000000000000\\n\", \"1 57\\n00011101100001110001111000000100101111000111101100111001000\\n\", \"2 32\\n0011110111011011011101111101011110\\n0111000110111111011110011101011110\\n\", \"3 20\\n0110011111110101101100\\n0111110000111010100100\\n0110111110010100011110\\n\", \"4 4\\n011100\\n001010\\n010000\\n011110\\n\", \"5 44\\n0001010010001111111001111111000010100100000010\\n0001111001111001101111011111010110001001111110\\n0111111010111111011101100011101010100101110110\\n0011010011101011101111001001010110000111111100\\n0110100111011100110101110010010011011101100100\\n\", \"6 36\\n01110101111111110101011000011111110010\\n00011101100010110111111111110001100100\\n00001111110010111111101110101110111110\\n00110110011100100111011110000000000010\\n01100101101001010001011111100111101100\\n00011111111011001000011001011110011110\\n\", \"7 24\\n01111001111001011010010100\\n00111011010101000111101000\\n01001110110010010110011110\\n00000101111011011111111000\\n01111111101111001001010010\\n01110000111101011111111010\\n00000100011100110000110000\\n\", \"8 8\\n0011101110\\n0110010100\\n0100111110\\n0111111100\\n0011010100\\n0001101110\\n0111100000\\n0110111000\\n\", \"9 48\\n00011010111110111011111001111111111101001111110010\\n01000101000101101101111110111101011100001011010010\\n00110111110110101110101110111111011011101111011000\\n00110111111100010110110110111001001111011010101110\\n01111111100101010011111100100111110011001101110100\\n01111011110011111101010101010100001110111111111000\\n01110101101101110001000010110100010110101111111100\\n00111101001010110010110100000111110101010100001000\\n00011011010110011111001100111100100011100110110100\\n\", \"10 40\\n010011001001111011011011101111010001010010\\n011000000110000010001011111010100000110000\\n011010101001110010110110011111010101101000\\n000111111010101111000110011111011011011010\\n010110101110001001001111111000110011101010\\n010011010100111110010100100111100111011110\\n001111101100111111111111001010111010000110\\n001111110010101100110100101110001011100110\\n010111010010001111110101111111111110111000\\n011101101111000100111111111001111100111010\\n\", \"11 28\\n011100111101101001011111001110\\n010001111110011101101011001000\\n001010011011011010101101101100\\n001100011001101011011001110100\\n010111110011101110000110111100\\n010010001111110000011111010100\\n001011111111110011101101111010\\n001101101011100100011011001110\\n001111110110100110101011000010\\n000101101011100001101101100100\\n010011101101111011100111110100\\n\", \"1 68\\n0101111110111111111111111111110111111111111111111110111111101111111110\\n\", \"2 56\\n0011111111111110111111111111111111011111111111011111011110\\n0111111111010111111111110111111111111110111111010111111110\\n\", \"3 17\\n0111111101111111110\\n0111111111101011110\\n0101111111111111110\\n\", \"4 4\\n011110\\n010110\\n010110\\n011110\\n\", \"5 89\\n0011111111111101110110111111111101111011111011101110111111111111111111111111111111111111110\\n0111111111111111111111111101111111111111111111111111111111111111111111111111111111111111110\\n0111111111111011111111111111111111101111011111111111111111110110111101111111111111111011010\\n0111111111111111011011111111111011111111111111111111111111111111111111111111111110111111010\\n0111111101111011111110101011111111110111100100101111111011111111111111011011101111111111110\\n\", \"6 77\\n0111111110101011111111111111111111111111111111111111100111111111101111111111110\\n0111111111111111111101111101111111111011111111011111111001011111111111101111110\\n0111101111111111111111111111111111111110110011111111111011111111101111111111110\\n0111110111111111111111111111111111111111111111111111011011111111111111111111110\\n0101111110111111111111111111111111111111111011111111111111111111101111011011110\\n0110111111101111110111111111111011111111101011111101111111111111111111110111100\\n\", \"7 20\\n0111111111111111111100\\n0111110111111111111110\\n0111111111111111111100\\n0111111011111111111110\\n0111111111111011101110\\n0111101011110111111010\\n0111111111111111111010\\n\", \"8 8\\n0111111110\\n0111101110\\n0111111110\\n0111111110\\n0111111110\\n0110111100\\n0101111110\\n0110111110\\n\", \"11 24\\n01111111111101111111111110\\n01111111111111111111111110\\n01110111111111111111111110\\n01111111111111111111011110\\n01111111111111111110111110\\n01111010111111100111101110\\n01111111111111010101111100\\n01111111111111110111111110\\n01011101111111111101111110\\n00111111011111111110111110\\n01111111101111111101111110\\n\", \"12 12\\n01111111111000\\n01101111110110\\n01111110111110\\n01111111111110\\n01111111111010\\n01011111110110\\n01111111111110\\n01101101011110\\n01111111111110\\n01111101011110\\n00111111111110\\n01111111011110\\n\", \"15 28\\n011111111101011111111101111110\\n011111111111111111111111111110\\n011101110111011011101111011110\\n011111111011111011110111111110\\n011111111110101111111111111110\\n011111011111110011111111011010\\n011110111111001101111111111110\\n011111111110111111111011111110\\n011111111111111111111111011110\\n011111011111111111111011001010\\n011111111101111111111101111110\\n011111111110111111101111011110\\n010111111111101111111111111110\\n011111111111111111011111111110\\n011011111111111110110111110110\\n\", \"2 11\\n0100000000000\\n0000000010000\\n\", \"1 100\\n010010010011100001101101110111101010000101010001111001001101011110000011101110101000100111111001101110\\n\", \"15 1\\n010\\n010\\n010\\n010\\n010\\n010\\n000\\n000\\n000\\n010\\n000\\n010\\n000\\n000\\n000\\n\", \"3 3\\n00010\\n00000\\n00010\\n\"], \"outputs\": [\"5\\n\", \"12\\n\", \"18\\n\", \"4\\n\", \"59\\n\", \"46\\n\", \"0\\n\", \"0\\n\", \"265\\n\", \"311\\n\", \"62\\n\", \"277\\n\", \"14\\n\", \"0\\n\", \"33\\n\", \"43\\n\", \"11\\n\", \"184\\n\", \"193\\n\", \"160\\n\", \"436\\n\", \"404\\n\", \"385\\n\", \"299\\n\", \"55\\n\", \"65\\n\", \"63\\n\", \"22\\n\", \"228\\n\", \"226\\n\", \"179\\n\", \"77\\n\", \"448\\n\", \"418\\n\", \"328\\n\", \"68\\n\", \"113\\n\", \"55\\n\", \"22\\n\", \"453\\n\", \"472\\n\", \"151\\n\", \"78\\n\", \"284\\n\", \"166\\n\", \"448\\n\", \"18\\n\", \"100\\n\", \"29\\n\", \"7\\n\"]}", "source": "primeintellect"}
Some people leave the lights at their workplaces on when they leave that is a waste of resources. As a hausmeister of DHBW, Sagheer waits till all students and professors leave the university building, then goes and turns all the lights off. The building consists of n floors with stairs at the left and the right sides. Each floor has m rooms on the same line with a corridor that connects the left and right stairs passing by all the rooms. In other words, the building can be represented as a rectangle with n rows and m + 2 columns, where the first and the last columns represent the stairs, and the m columns in the middle represent rooms. Sagheer is standing at the ground floor at the left stairs. He wants to turn all the lights off in such a way that he will not go upstairs until all lights in the floor he is standing at are off. Of course, Sagheer must visit a room to turn the light there off. It takes one minute for Sagheer to go to the next floor using stairs or to move from the current room/stairs to a neighboring room/stairs on the same floor. It takes no time for him to switch the light off in the room he is currently standing in. Help Sagheer find the minimum total time to turn off all the lights. Note that Sagheer does not have to go back to his starting position, and he does not have to visit rooms where the light is already switched off. -----Input----- The first line contains two integers n and m (1 ≤ n ≤ 15 and 1 ≤ m ≤ 100) — the number of floors and the number of rooms in each floor, respectively. The next n lines contains the building description. Each line contains a binary string of length m + 2 representing a floor (the left stairs, then m rooms, then the right stairs) where 0 indicates that the light is off and 1 indicates that the light is on. The floors are listed from top to bottom, so that the last line represents the ground floor. The first and last characters of each string represent the left and the right stairs, respectively, so they are always 0. -----Output----- Print a single integer — the minimum total time needed to turn off all the lights. -----Examples----- Input 2 2 0010 0100 Output 5 Input 3 4 001000 000010 000010 Output 12 Input 4 3 01110 01110 01110 01110 Output 18 -----Note----- In the first example, Sagheer will go to room 1 in the ground floor, then he will go to room 2 in the second floor using the left or right stairs. In the second example, he will go to the fourth room in the ground floor, use right stairs, go to the fourth room in the second floor, use right stairs again, then go to the second room in the last floor. In the third example, he will walk through the whole corridor alternating between the left and right stairs at each floor. Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0
{"tests": "{\"inputs\": [\"9\\n8 6 4 2 1 4 7 10 2\\n\", \"9\\n-1 6 -1 2 -1 4 7 -1 2\\n\", \"5\\n-1 -1 -1 -1 -1\\n\", \"7\\n-1 -1 4 5 1 2 3\\n\", \"1\\n1\\n\", \"1\\n65\\n\", \"1\\n1000000000\\n\", \"1\\n-1\\n\", \"2\\n1000000000 1000000000\\n\", \"2\\n1000000000 -1\\n\", \"2\\n-1 1000000000\\n\", \"2\\n-1 -1\\n\", \"3\\n999999999 1000000000 -1\\n\", \"3\\n999999999 -1 1000000000\\n\", \"3\\n1000000000 999999999 1000000000\\n\", \"3\\n-1 1000000000 999999999\\n\", \"3\\n-1 1000000000 -1\\n\", \"3\\n-1 1 2\\n\", \"3\\n-1 1 1000000000\\n\", \"5\\n-1 1 7 -1 5\\n\", \"7\\n-1 2 4 -1 4 1 5\\n\", \"2\\n-1 21\\n\", \"3\\n39 42 -1\\n\", \"4\\n45 -1 41 -1\\n\", \"5\\n-1 40 42 -1 46\\n\", \"6\\n-1 6 1 -1 -1 -1\\n\", \"7\\n32 33 34 -1 -1 37 38\\n\", \"8\\n-1 12 14 16 18 20 -1 -1\\n\", \"9\\n42 39 36 33 -1 -1 -1 34 39\\n\", \"10\\n29 27 -1 23 42 -1 -1 45 -1 -1\\n\", \"5\\n40 -1 44 46 48\\n\", \"6\\n43 40 37 34 -1 -1\\n\", \"7\\n11 8 5 -1 -1 -1 -1\\n\", \"8\\n-1 12 14 16 18 20 -1 -1\\n\", \"9\\n42 39 36 33 -1 -1 -1 34 39\\n\", \"10\\n29 27 -1 23 42 -1 -1 45 -1 -1\\n\", \"11\\n9 21 17 13 -1 -1 -1 -1 -1 -1 -1\\n\", \"12\\n-1 17 -1 54 -1 64 -1 74 79 84 -1 94\\n\", \"13\\n25 24 23 22 24 27 -1 33 -1 2 2 2 -1\\n\", \"14\\n-1 5 3 -1 -1 31 31 31 -1 31 -1 -1 4 7\\n\", \"15\\n-1 28 -1 32 34 26 -1 26 -1 -1 26 26 26 -1 -1\\n\", \"16\\n3 8 13 18 23 -1 -1 -1 43 48 53 45 -1 -1 -1 -1\\n\", \"17\\n-1 -1 -1 -1 64 68 72 -1 45 46 47 48 49 50 51 52 53\\n\", \"18\\n21 19 -1 -1 -1 48 50 -1 54 -1 5 1 -1 -1 -1 37 36 35\\n\", \"19\\n23 26 -1 -1 35 38 41 -1 -1 -1 53 -1 59 62 6 7 8 9 -1\\n\", \"6\\n-1 2 6 -1 -1 6\\n\", \"8\\n-1 -1 1 7 -1 9 5 2\\n\", \"20\\n-1 32 37 -1 -1 -1 57 -1 -1 40 31 33 -1 -1 39 47 43 -1 35 32\\n\", \"13\\n2 -1 3 1 3 1 -1 1 3 -1 -1 1 1\\n\", \"3\\n-1 1 -1\\n\"], \"outputs\": [\"3\\n\", \"3\\n\", \"1\\n\", \"2\\n\", \"1\\n\", \"1\\n\", \"1\\n\", \"1\\n\", \"1\\n\", \"1\\n\", \"1\\n\", \"1\\n\", \"1\\n\", \"2\\n\", \"2\\n\", \"1\\n\", \"1\\n\", \"2\\n\", \"2\\n\", \"2\\n\", \"3\\n\", \"1\\n\", \"1\\n\", \"1\\n\", \"1\\n\", \"2\\n\", \"1\\n\", \"1\\n\", \"2\\n\", \"2\\n\", \"1\\n\", \"1\\n\", \"2\\n\", \"1\\n\", \"2\\n\", \"2\\n\", \"3\\n\", \"2\\n\", \"3\\n\", \"3\\n\", \"2\\n\", \"2\\n\", \"2\\n\", \"4\\n\", \"2\\n\", \"2\\n\", \"3\\n\", \"5\\n\", \"6\\n\", \"1\\n\"]}", "source": "primeintellect"}
Polycarpus develops an interesting theory about the interrelation of arithmetic progressions with just everything in the world. His current idea is that the population of the capital of Berland changes over time like an arithmetic progression. Well, or like multiple arithmetic progressions. Polycarpus believes that if he writes out the population of the capital for several consecutive years in the sequence a_1, a_2, ..., a_{n}, then it is convenient to consider the array as several arithmetic progressions, written one after the other. For example, sequence (8, 6, 4, 2, 1, 4, 7, 10, 2) can be considered as a sequence of three arithmetic progressions (8, 6, 4, 2), (1, 4, 7, 10) and (2), which are written one after another. Unfortunately, Polycarpus may not have all the data for the n consecutive years (a census of the population doesn't occur every year, after all). For this reason, some values of a_{i} ​​may be unknown. Such values are represented by number -1. For a given sequence a = (a_1, a_2, ..., a_{n}), which consists of positive integers and values ​​-1, find the minimum number of arithmetic progressions Polycarpus needs to get a. To get a, the progressions need to be written down one after the other. Values ​​-1 may correspond to an arbitrary positive integer and the values a_{i} > 0 must be equal to the corresponding elements of sought consecutive record of the progressions. Let us remind you that a finite sequence c is called an arithmetic progression if the difference c_{i} + 1 - c_{i} of any two consecutive elements in it is constant. By definition, any sequence of length 1 is an arithmetic progression. -----Input----- The first line of the input contains integer n (1 ≤ n ≤ 2·10^5) — the number of elements in the sequence. The second line contains integer values a_1, a_2, ..., a_{n} separated by a space (1 ≤ a_{i} ≤ 10^9 or a_{i} = - 1). -----Output----- Print the minimum number of arithmetic progressions that you need to write one after another to get sequence a. The positions marked as -1 in a can be represented by any positive integers. -----Examples----- Input 9 8 6 4 2 1 4 7 10 2 Output 3 Input 9 -1 6 -1 2 -1 4 7 -1 2 Output 3 Input 5 -1 -1 -1 -1 -1 Output 1 Input 7 -1 -1 4 5 1 2 3 Output 2 Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0
{"tests": "{\"inputs\": [\"5 1 1\\n*...*\\n\", \"6 2 3\\n*...*.\\n\", \"11 3 10\\n.*....**.*.\\n\", \"3 2 3\\n***\\n\", \"9 5 3\\n*...*...*\\n\", \"9 2 4\\n*...*...*\\n\", \"9 2 200000\\n*...*...*\\n\", \"1 0 1\\n.\\n\", \"20 5 5\\n.*.*.........*......\\n\", \"14 3 7\\n.*.......*..*.\\n\", \"6 1 3\\n*....*\\n\", \"9 2 4\\n..*.*....\\n\", \"5 1 2\\n...*.\\n\", \"2 2 0\\n..\\n\", \"2 0 2\\n..\\n\", \"10 1 1\\n..........\\n\", \"4 0 1\\n....\\n\", \"5 3 3\\n...**\\n\", \"3 0 1\\n.*.\\n\", \"4 2 2\\n....\\n\", \"13 3 3\\n*...*...*...*\\n\", \"5 10 1\\n*....\\n\", \"7 0 4\\n...*..*\\n\", \"20 5 5\\n.*.*.............*..\\n\", \"6 2 1\\n..*...\\n\", \"17 11 2\\n.*..*..*.*.***...\\n\", \"5 2 3\\n.....\\n\", \"64 59 2\\n.*.***......****.*..**..**..****.*.*.*.**...**..***.***.*..*..*.\\n\", \"5 1 2\\n.*...\\n\", \"2 1 1\\n..\\n\", \"10 15 15\\n..........\\n\", \"10 7 0\\n.*...*..*.\\n\", \"5 0 1\\n.....\\n\", \"4 1 1\\n..*.\\n\", \"10 4 6\\n..........\\n\", \"5 1 4\\n.....\\n\", \"10 4 3\\n.*..*...*.\\n\", \"4 2 0\\n....\\n\", \"5 0 2\\n.....\\n\", \"5 0 1\\n*.*.*\\n\", \"10 20 0\\n..........\\n\", \"10 8 1\\n.*.*......\\n\", \"6 1 1\\n*...*.\\n\", \"7 1 0\\n.*.....\\n\", \"1 1 1\\n.\\n\", \"10 5 1\\n..........\\n\", \"4 3 0\\n....\\n\", \"11 6 2\\n.*...*...*.\\n\", \"11 7 1\\n.*...*...*.\\n\"], \"outputs\": [\"2\\n\", \"4\\n\", \"7\\n\", \"0\\n\", \"6\\n\", \"6\\n\", \"6\\n\", \"1\\n\", \"10\\n\", \"10\\n\", \"3\\n\", \"6\\n\", \"3\\n\", \"1\\n\", \"1\\n\", \"2\\n\", \"1\\n\", \"3\\n\", \"1\\n\", \"4\\n\", \"6\\n\", \"3\\n\", \"3\\n\", \"10\\n\", \"3\\n\", \"9\\n\", \"5\\n\", \"23\\n\", \"3\\n\", \"2\\n\", \"10\\n\", \"5\\n\", \"1\\n\", \"2\\n\", \"9\\n\", \"4\\n\", \"7\\n\", \"2\\n\", \"2\\n\", \"1\\n\", \"5\\n\", \"6\\n\", \"2\\n\", \"1\\n\", \"1\\n\", \"6\\n\", \"2\\n\", \"8\\n\", \"7\\n\"]}", "source": "primeintellect"}
There are $n$ consecutive seat places in a railway carriage. Each place is either empty or occupied by a passenger. The university team for the Olympiad consists of $a$ student-programmers and $b$ student-athletes. Determine the largest number of students from all $a+b$ students, which you can put in the railway carriage so that: no student-programmer is sitting next to the student-programmer; and no student-athlete is sitting next to the student-athlete. In the other words, there should not be two consecutive (adjacent) places where two student-athletes or two student-programmers are sitting. Consider that initially occupied seat places are occupied by jury members (who obviously are not students at all). -----Input----- The first line contain three integers $n$, $a$ and $b$ ($1 \le n \le 2\cdot10^{5}$, $0 \le a, b \le 2\cdot10^{5}$, $a + b > 0$) — total number of seat places in the railway carriage, the number of student-programmers and the number of student-athletes. The second line contains a string with length $n$, consisting of characters "." and "*". The dot means that the corresponding place is empty. The asterisk means that the corresponding place is occupied by the jury member. -----Output----- Print the largest number of students, which you can put in the railway carriage so that no student-programmer is sitting next to a student-programmer and no student-athlete is sitting next to a student-athlete. -----Examples----- Input 5 1 1 *...* Output 2 Input 6 2 3 *...*. Output 4 Input 11 3 10 .*....**.*. Output 7 Input 3 2 3 *** Output 0 -----Note----- In the first example you can put all student, for example, in the following way: *.AB* In the second example you can put four students, for example, in the following way: *BAB*B In the third example you can put seven students, for example, in the following way: B*ABAB**A*B The letter A means a student-programmer, and the letter B — student-athlete. Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0
{"tests": "{\"inputs\": [\"3\\n1 2 1\\n\", \"2\\n5 5\\n\", \"1\\n10\\n\", \"1\\n1\\n\", \"10\\n1 1 1 1 1 1 1 1 1 1\\n\", \"10\\n1 1 1 1 1 1 1 1 1 9\\n\", \"10\\n26 723 970 13 422 968 875 329 234 983\\n\", \"3\\n3 2 1\\n\", \"10\\n1000 1000 1000 1000 1000 1000 1000 1000 1000 1000\\n\", \"10\\n1 9 7 6 2 4 7 8 1 3\\n\", \"2\\n9 6\\n\", \"2\\n89 7\\n\", \"2\\n101 807\\n\", \"5\\n8 7 4 8 3\\n\", \"5\\n55 62 70 100 90\\n\", \"5\\n850 840 521 42 169\\n\", \"6\\n7 1 4 1 6 1\\n\", \"6\\n36 80 38 88 79 69\\n\", \"6\\n108 318 583 10 344 396\\n\", \"9\\n10 9 10 10 8 3 5 10 2\\n\", \"9\\n90 31 28 63 57 57 27 62 42\\n\", \"9\\n665 646 152 829 190 64 555 536 321\\n\", \"10\\n99 62 10 47 53 9 83 33 15 24\\n\", \"4\\n600 200 100 300\\n\", \"2\\n4 5\\n\", \"2\\n5 12\\n\", \"2\\n1 2\\n\", \"3\\n1 1 2\\n\", \"2\\n3 2\\n\", \"3\\n1 4 5\\n\", \"4\\n5 5 5 5\\n\", \"1\\n5\\n\", \"3\\n5 5 5\\n\", \"5\\n5 5 5 5 5\\n\", \"4\\n2 7 10 1\\n\", \"3\\n1 1 1\\n\", \"4\\n8 4 2 2\\n\", \"2\\n3 4\\n\", \"4\\n1 1 3 1\\n\", \"7\\n1 2 3 4 5 6 7\\n\", \"2\\n18 19\\n\", \"2\\n17 18\\n\", \"2\\n1 3\\n\", \"4\\n5 5 4 4\\n\", \"2\\n10 11\\n\", \"2\\n10 20\\n\", \"2\\n2 1\\n\", \"4\\n2 3 2 3\\n\", \"2\\n5 6\\n\"], \"outputs\": [\"1\\n1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"1\\n1\\n\", \"1\\n1\\n\", \"1\\n4\\n\", \"1\\n3\\n\", \"1\\n1\\n\", \"1\\n1\\n\", \"1\\n2\\n\", \"1\\n2\\n\", \"1\\n1\\n\", \"1\\n5\\n\", \"1\\n1\\n\", \"1\\n4\\n\", \"1\\n2\\n\", \"1\\n1\\n\", \"1\\n4\\n\", \"1\\n9\\n\", \"1\\n7\\n\", \"1\\n6\\n\", \"1\\n6\\n\", \"1\\n3\\n\", \"1\\n1\\n\", \"1\\n1\\n\", \"1\\n1\\n\", \"1\\n1\\n\", \"1\\n2\\n\", \"1\\n1\\n\", \"1\\n1\\n\", \"-1\\n\", \"1\\n1\\n\", \"1\\n1\\n\", \"1\\n4\\n\", \"1\\n1\\n\", \"1\\n3\\n\", \"1\\n1\\n\", \"1\\n1\\n\", \"1\\n1\\n\", \"1\\n1\\n\", \"1\\n1\\n\", \"1\\n1\\n\", \"1\\n3\\n\", \"1\\n1\\n\", \"1\\n1\\n\", \"1\\n2\\n\", \"1\\n1\\n\", \"1\\n1\\n\"]}", "source": "primeintellect"}
There are quite a lot of ways to have fun with inflatable balloons. For example, you can fill them with water and see what happens. Grigory and Andrew have the same opinion. So, once upon a time, they went to the shop and bought $n$ packets with inflatable balloons, where $i$-th of them has exactly $a_i$ balloons inside. They want to divide the balloons among themselves. In addition, there are several conditions to hold: Do not rip the packets (both Grigory and Andrew should get unbroken packets); Distribute all packets (every packet should be given to someone); Give both Grigory and Andrew at least one packet; To provide more fun, the total number of balloons in Grigory's packets should not be equal to the total number of balloons in Andrew's packets. Help them to divide the balloons or determine that it's impossible under these conditions. -----Input----- The first line of input contains a single integer $n$ ($1 \le n \le 10$) — the number of packets with balloons. The second line contains $n$ integers: $a_1$, $a_2$, $\ldots$, $a_n$ ($1 \le a_i \le 1000$) — the number of balloons inside the corresponding packet. -----Output----- If it's impossible to divide the balloons satisfying the conditions above, print $-1$. Otherwise, print an integer $k$ — the number of packets to give to Grigory followed by $k$ distinct integers from $1$ to $n$ — the indices of those. The order of packets doesn't matter. If there are multiple ways to divide balloons, output any of them. -----Examples----- Input 3 1 2 1 Output 2 1 2 Input 2 5 5 Output -1 Input 1 10 Output -1 -----Note----- In the first test Grigory gets $3$ balloons in total while Andrey gets $1$. In the second test there's only one way to divide the packets which leads to equal numbers of balloons. In the third test one of the boys won't get a packet at all. Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0
{"tests": "{\"inputs\": [\"1\\n\", \"4\\n\", \"27\\n\", \"239\\n\", \"191\\n\", \"94\\n\", \"57\\n\", \"78\\n\", \"224\\n\", \"2\\n\", \"3\\n\", \"5\\n\", \"6\\n\", \"7\\n\", \"8\\n\", \"9\\n\", \"10\\n\", \"11\\n\", \"12\\n\", \"13\\n\", \"14\\n\", \"15\\n\", \"16\\n\", \"17\\n\", \"18\\n\", \"19\\n\", \"121\\n\", \"9\\n\", \"7\\n\", \"3\\n\", \"8\\n\", \"169\\n\", \"246\\n\", \"122\\n\", \"222\\n\", \"223\\n\", \"117\\n\", \"11\\n\", \"136\\n\", \"193\\n\", \"67\\n\", \"99\\n\", \"237\\n\", \"71\\n\", \"132\\n\", \"46\\n\", \"5\\n\", \"69\\n\", \"2\\n\"], \"outputs\": [\"1\\n1 \", \"4\\n1 1 1 1 \", \"27\\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 \", \"239\\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 \", \"191\\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 \", \"94\\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 \", \"57\\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 \", \"78\\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 \", \"224\\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 \", \"2\\n1 1 \", \"3\\n1 1 1 \", \"5\\n1 1 1 1 1 \", \"6\\n1 1 1 1 1 1 \", \"7\\n1 1 1 1 1 1 1 \", \"8\\n1 1 1 1 1 1 1 1 \", \"9\\n1 1 1 1 1 1 1 1 1 \", \"10\\n1 1 1 1 1 1 1 1 1 1 \", \"11\\n1 1 1 1 1 1 1 1 1 1 1 \", \"12\\n1 1 1 1 1 1 1 1 1 1 1 1 \", \"13\\n1 1 1 1 1 1 1 1 1 1 1 1 1 \", \"14\\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 \", \"15\\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 \", \"16\\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 \", \"17\\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 \", \"18\\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 \", \"19\\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 \", \"121\\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 \", \"9\\n1 1 1 1 1 1 1 1 1 \", \"7\\n1 1 1 1 1 1 1 \", \"3\\n1 1 1 \", \"8\\n1 1 1 1 1 1 1 1 \", \"169\\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 \", \"246\\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 \", \"122\\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 \", \"222\\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 \", \"223\\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 \", \"117\\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 \", \"11\\n1 1 1 1 1 1 1 1 1 1 1 \", \"136\\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 \", \"193\\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 \", \"67\\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 \", \"99\\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 \", \"237\\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 \", \"71\\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 \", \"132\\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 \", \"46\\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 \", \"5\\n1 1 1 1 1 \", \"69\\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 \", \"2\\n1 1 \"]}", "source": "primeintellect"}
Vasya has his favourite number $n$. He wants to split it to some non-zero digits. It means, that he wants to choose some digits $d_1, d_2, \ldots, d_k$, such that $1 \leq d_i \leq 9$ for all $i$ and $d_1 + d_2 + \ldots + d_k = n$. Vasya likes beauty in everything, so he wants to find any solution with the minimal possible number of different digits among $d_1, d_2, \ldots, d_k$. Help him! -----Input----- The first line contains a single integer $n$ — the number that Vasya wants to split ($1 \leq n \leq 1000$). -----Output----- In the first line print one integer $k$ — the number of digits in the partition. Note that $k$ must satisfy the inequality $1 \leq k \leq n$. In the next line print $k$ digits $d_1, d_2, \ldots, d_k$ separated by spaces. All digits must satisfy the inequalities $1 \leq d_i \leq 9$. You should find a partition of $n$ in which the number of different digits among $d_1, d_2, \ldots, d_k$ will be minimal possible among all partitions of $n$ into non-zero digits. Among such partitions, it is allowed to find any. It is guaranteed that there exists at least one partition of the number $n$ into digits. -----Examples----- Input 1 Output 1 1 Input 4 Output 2 2 2 Input 27 Output 3 9 9 9 -----Note----- In the first test, the number $1$ can be divided into $1$ digit equal to $1$. In the second test, there are $3$ partitions of the number $4$ into digits in which the number of different digits is $1$. This partitions are $[1, 1, 1, 1]$, $[2, 2]$ and $[4]$. Any of these partitions can be found. And, for example, dividing the number $4$ to the digits $[1, 1, 2]$ isn't an answer, because it has $2$ different digits, that isn't the minimum possible number. Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0
{"tests": "{\"inputs\": [\"2\\n2 3\\n\", \"2\\n2 2\\n\", \"3\\n2 1 1\\n\", \"2\\n83 14\\n\", \"10\\n10 10 1 2 3 3 1 2 1 5\\n\", \"100\\n314 905 555 526 981 360 424 104 920 814 143 872 741 592 105 573 837 962 220 692 560 493 889 824 145 491 828 960 889 87 375 486 609 423 386 323 124 830 206 446 899 522 514 696 786 783 268 483 318 261 675 445 1000 896 812 277 131 264 860 514 701 678 792 394 324 244 483 357 69 931 590 452 626 451 976 317 722 564 809 40 265 709 13 700 769 869 131 834 712 478 661 369 805 668 512 184 477 896 808 168\\n\", \"100\\n174 816 593 727 182 151 842 277 1 942 307 939 447 738 823 744 319 394 515 451 875 950 319 789 384 292 190 758 927 103 246 1 675 42 398 631 382 893 646 2 773 157 992 425 804 565 500 242 2 657 611 647 4 331 99 1 694 18 119 364 458 569 94 999 72 7 297 102 982 859 786 868 178 393 642 254 707 41 103 764 934 70 775 41 188 199 767 64 84 899 626 224 279 188 659 374 105 178 154 758\\n\", \"100\\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\\n\", \"100\\n966 680 370 134 202 826 254 620 700 336 938 344 368 108 732 130 134 700 996 904 644 734 184 134 996 46 146 928 320 664 304 160 358 306 330 132 674 16 338 138 926 994 196 960 972 972 756 276 600 982 588 978 868 572 446 578 692 976 780 434 882 344 980 536 856 916 966 936 178 300 294 568 984 54 238 718 582 400 572 142 118 306 222 850 948 954 682 256 70 550 830 980 646 970 688 56 552 592 200 682\\n\", \"100\\n598 236 971 958 277 96 651 366 629 50 601 822 744 326 276 330 413 531 791 655 450 173 992 80 401 760 227 64 350 711 258 545 212 690 996 515 983 835 388 311 970 608 185 164 491 419 295 293 274 93 339 761 155 307 991 857 309 957 563 232 328 682 779 637 312 888 305 184 15 556 427 211 327 313 516 815 914 588 592 988 151 839 828 339 196 462 752 454 865 479 356 529 320 59 908 840 294 882 189 6\\n\", \"20\\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 204239 1 194239 216480\\n\", \"10\\n4 3 1 1 1 1 1 1 1 1\\n\", \"2\\n1000000 1000000\\n\", \"1\\n4\\n\", \"1\\n1\\n\", \"2\\n999997 999994\\n\", \"5\\n1 1 1 8 9\\n\", \"3\\n1 5 8\\n\", \"2\\n999996 999997\\n\", \"2\\n1 2\\n\", \"3\\n1 8 9\\n\", \"2\\n1 1\\n\", \"2\\n1 3\\n\", \"3\\n1 9 8\\n\", \"6\\n1 3 3 3 3 20\\n\", \"1\\n3\\n\", \"2\\n3 3\\n\", \"5\\n1 1 1 8 3\\n\", \"1\\n9\\n\", \"3\\n2 4 7\\n\", \"6\\n2 5 1 1 1 1\\n\", \"3\\n1 3 14\\n\", \"1\\n6\\n\", \"3\\n2 7 12\\n\", \"3\\n3 6 7\\n\", \"3\\n7 3 2\\n\", \"3\\n1 8 5\\n\", \"2\\n1000000 999993\\n\", \"5\\n1 5 8 1 1\\n\", \"1\\n8\\n\", \"3\\n1 13 13\\n\", \"3\\n5 8 1\\n\", \"3\\n8 1 5\\n\", \"3\\n1 3 8\\n\", \"2\\n1 9\\n\", \"2\\n5 5\\n\", \"1\\n5\\n\", \"3\\n1 83 14\\n\", \"5\\n123445 32892 32842 432721 39234\\n\"], \"outputs\": [\"2\\n3 2\\n\", \"1\\n2\\n\", \"3\\n1 1 2\\n\", \"2\\n14 83\\n\", \"4\\n1 1 10 1\\n\", \"2\\n104 905\\n\", \"4\\n1 1 738 1\\n\", \"100\\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\\n\", \"1\\n966\\n\", \"2\\n96 277\\n\", \"18\\n1 1 1 1 1 1 1 216480 1 1 1 1 1 1 1 1 1 1\\n\", \"9\\n4 1 1 1 1 1 1 1 1\\n\", \"1\\n1000000\\n\", \"1\\n4\\n\", \"1\\n1\\n\", \"1\\n999997\\n\", \"3\\n1 1 1\\n\", \"2\\n8 5\\n\", \"2\\n999997 999996\\n\", \"2\\n1 2\\n\", \"2\\n9 8\\n\", \"2\\n1 1\\n\", \"1\\n1\\n\", \"2\\n8 9\\n\", \"2\\n20 3\\n\", \"1\\n3\\n\", \"1\\n3\\n\", \"3\\n1 1 1\\n\", \"1\\n9\\n\", \"2\\n7 4\\n\", \"5\\n2 1 1 1 1\\n\", \"2\\n14 3\\n\", \"1\\n6\\n\", \"2\\n12 7\\n\", \"2\\n7 6\\n\", \"2\\n2 3\\n\", \"2\\n5 8\\n\", \"2\\n999993 1000000\\n\", \"3\\n1 1 1\\n\", \"1\\n8\\n\", \"1\\n1\\n\", \"2\\n8 5\\n\", \"2\\n5 8\\n\", \"2\\n8 3\\n\", \"1\\n1\\n\", \"1\\n5\\n\", \"1\\n5\\n\", \"2\\n14 83\\n\", \"1\\n123445\\n\"]}", "source": "primeintellect"}
A tuple of positive integers {x_1, x_2, ..., x_{k}} is called simple if for all pairs of positive integers (i, j) (1 ≤ i < j ≤ k), x_{i} + x_{j} is a prime. You are given an array a with n positive integers a_1, a_2, ..., a_{n} (not necessary distinct). You want to find a simple subset of the array a with the maximum size. A prime number (or a prime) is a natural number greater than 1 that has no positive divisors other than 1 and itself. Let's define a subset of the array a as a tuple that can be obtained from a by removing some (possibly all) elements of it. -----Input----- The first line contains integer n (1 ≤ n ≤ 1000) — the number of integers in the array a. The second line contains n integers a_{i} (1 ≤ a_{i} ≤ 10^6) — the elements of the array a. -----Output----- On the first line print integer m — the maximum possible size of simple subset of a. On the second line print m integers b_{l} — the elements of the simple subset of the array a with the maximum size. If there is more than one solution you can print any of them. You can print the elements of the subset in any order. -----Examples----- Input 2 2 3 Output 2 3 2 Input 2 2 2 Output 1 2 Input 3 2 1 1 Output 3 1 1 2 Input 2 83 14 Output 2 14 83 Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0
{"tests": "{\"inputs\": [\"1 0\\n\", \"2 1\\n\", \"3 2\\n\", \"4 1\\n\", \"7 4\\n\", \"7 7\\n\", \"8 4\\n\", \"8 5\\n\", \"10 3\\n\", \"20 0\\n\", \"100 99\\n\", \"13 13\\n\", \"100 100\\n\", \"1000 0\\n\", \"1000 1\\n\", \"1000 2\\n\", \"1000 10\\n\", \"1000 99\\n\", \"1000 500\\n\", \"1000 700\\n\", \"1000 900\\n\", \"1000 999\\n\", \"1000 998\\n\", \"1000 1000\\n\", \"999 0\\n\", \"999 1\\n\", \"999 5\\n\", \"999 13\\n\", \"999 300\\n\", \"999 600\\n\", \"999 999\\n\", \"999 989\\n\", \"999 998\\n\", \"10 0\\n\", \"5 0\\n\", \"5 1\\n\", \"5 2\\n\", \"5 3\\n\", \"5 4\\n\", \"5 5\\n\", \"4 4\\n\", \"4 3\\n\", \"4 2\\n\", \"1 1\\n\", \"2 2\\n\", \"3 1\\n\", \"3 3\\n\", \"2 0\\n\", \"3 0\\n\"], \"outputs\": [\"1\\n\", \"0\\n\", \"4\\n\", \"6\\n\", \"328\\n\", \"0\\n\", \"2658\\n\", \"688\\n\", \"614420\\n\", \"111008677\\n\", \"2450\\n\", \"0\\n\", \"1\\n\", \"845393494\\n\", \"418947603\\n\", \"819706485\\n\", \"305545369\\n\", \"115316732\\n\", \"979041279\\n\", \"642759746\\n\", \"301804159\\n\", \"249500\\n\", \"583666213\\n\", \"1\\n\", \"184907578\\n\", \"167859862\\n\", \"642835575\\n\", \"740892203\\n\", \"562270116\\n\", \"553332041\\n\", \"0\\n\", \"254295912\\n\", \"250000\\n\", \"543597\\n\", \"21\\n\", \"36\\n\", \"42\\n\", \"12\\n\", \"9\\n\", \"0\\n\", \"1\\n\", \"2\\n\", \"10\\n\", \"0\\n\", \"1\\n\", \"0\\n\", \"0\\n\", \"1\\n\", \"2\\n\"]}", "source": "primeintellect"}
Permutation p is an ordered set of integers p_1, p_2, ..., p_{n}, consisting of n distinct positive integers, each of them doesn't exceed n. We'll denote the i-th element of permutation p as p_{i}. We'll call number n the size or the length of permutation p_1, p_2, ..., p_{n}. We'll call position i (1 ≤ i ≤ n) in permutation p_1, p_2, ..., p_{n} good, if |p[i] - i| = 1. Count the number of permutations of size n with exactly k good positions. Print the answer modulo 1000000007 (10^9 + 7). -----Input----- The single line contains two space-separated integers n and k (1 ≤ n ≤ 1000, 0 ≤ k ≤ n). -----Output----- Print the number of permutations of length n with exactly k good positions modulo 1000000007 (10^9 + 7). -----Examples----- Input 1 0 Output 1 Input 2 1 Output 0 Input 3 2 Output 4 Input 4 1 Output 6 Input 7 4 Output 328 -----Note----- The only permutation of size 1 has 0 good positions. Permutation (1, 2) has 0 good positions, and permutation (2, 1) has 2 positions. Permutations of size 3: (1, 2, 3) — 0 positions $(1,3,2)$ — 2 positions $(2,1,3)$ — 2 positions $(2,3,1)$ — 2 positions $(3,1,2)$ — 2 positions (3, 2, 1) — 0 positions Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0
{"tests": "{\"inputs\": [\"3 2\\n\", \"39 14\\n\", \"44 350\\n\", \"22 444\\n\", \"1 0\\n\", \"34 712\\n\", \"10 82\\n\", \"17 222\\n\", \"40 1062\\n\", \"38 716\\n\", \"11 102\\n\", \"20 350\\n\", \"32 1000\\n\", \"15 154\\n\", \"1 0\\n\", \"12 55\\n\", \"35 289\\n\", \"12 0\\n\", \"34 123\\n\", \"7 1\\n\", \"31 344\\n\", \"27 451\\n\", \"28 177\\n\", \"21 71\\n\", \"21 233\\n\", \"9 34\\n\", \"7 31\\n\", \"31 603\\n\", \"2 3\\n\", \"17 56\\n\", \"1 0\\n\", \"1 1\\n\", \"2 0\\n\", \"2 1\\n\", \"2 2\\n\", \"2 3\\n\", \"43 668\\n\", \"2 4\\n\", \"49 1200\\n\", \"49 1202\\n\", \"50 0\\n\", \"50 2\\n\", \"50 1250\\n\", \"50 1252\\n\", \"50 2500\\n\", \"31 520\\n\", \"2 0\\n\", \"14 148\\n\", \"49 2174\\n\"], \"outputs\": [\"2\\n\", \"74764168\\n\", \"15060087\\n\", \"0\\n\", \"1\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"810790165\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"1\\n\", \"0\\n\", \"0\\n\", \"1\\n\", \"0\\n\", \"0\\n\", \"996412950\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"25632\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"329733855\\n\", \"1\\n\", \"0\\n\", \"1\\n\", \"0\\n\", \"1\\n\", \"0\\n\", \"484721091\\n\", \"0\\n\", \"366641438\\n\", \"0\\n\", \"1\\n\", \"49\\n\", \"472467292\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"1\\n\", \"0\\n\", \"0\\n\"]}", "source": "primeintellect"}
Let us define the oddness of a permutation p = {p_1,\ p_2,\ ...,\ p_n} of {1,\ 2,\ ...,\ n} as \sum_{i = 1}^n |i - p_i|. Find the number of permutations of {1,\ 2,\ ...,\ n} of oddness k, modulo 10^9+7. -----Constraints----- - All values in input are integers. - 1 \leq n \leq 50 - 0 \leq k \leq n^2 -----Input----- Input is given from Standard Input in the following format: n k -----Output----- Print the number of permutations of {1,\ 2,\ ...,\ n} of oddness k, modulo 10^9+7. -----Sample Input----- 3 2 -----Sample Output----- 2 There are six permutations of {1,\ 2,\ 3}. Among them, two have oddness of 2: {2,\ 1,\ 3} and {1,\ 3,\ 2}. Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0
{"tests": "{\"inputs\": [\"2 5 4 6 1 3 6 2 5 5 1 2 3 5 3 1 1 2 4 6 6 4 3 4\\n\", \"5 3 5 3 2 5 2 5 6 2 6 2 4 4 4 4 1 1 1 1 6 3 6 3\\n\", \"2 6 3 3 5 5 2 6 1 1 6 4 4 4 2 4 6 5 3 1 2 5 3 1\\n\", \"3 4 2 3 5 5 6 6 4 5 4 6 5 1 1 1 6 2 1 3 3 2 4 2\\n\", \"5 5 2 5 3 3 2 6 6 4 2 4 6 1 4 3 1 6 2 1 3 4 5 1\\n\", \"6 6 1 2 6 1 1 3 5 4 3 4 3 5 5 2 4 4 6 2 1 5 3 2\\n\", \"2 2 1 1 5 5 5 5 3 3 4 4 1 4 1 4 2 3 2 3 6 6 6 6\\n\", \"1 1 1 1 5 5 3 3 4 4 4 4 3 3 2 2 6 6 5 5 2 2 6 6\\n\", \"1 1 1 1 3 3 3 3 5 5 5 5 2 2 2 2 4 4 4 4 6 6 6 6\\n\", \"5 4 5 4 4 6 4 6 6 3 6 3 1 1 1 1 2 2 2 2 5 3 5 3\\n\", \"3 3 5 5 2 2 2 2 6 6 4 4 6 3 6 3 4 5 4 5 1 1 1 1\\n\", \"6 6 6 6 2 2 5 5 1 1 1 1 4 4 2 2 5 5 3 3 3 3 4 4\\n\", \"4 6 4 6 6 1 6 1 1 3 1 3 2 2 2 2 5 5 5 5 4 3 4 3\\n\", \"6 6 2 2 3 3 3 3 4 4 5 5 4 6 4 6 5 2 5 2 1 1 1 1\\n\", \"3 3 3 3 4 4 5 5 1 1 1 1 2 2 4 4 5 5 6 6 6 6 2 2\\n\", \"2 5 2 5 4 2 4 2 1 4 1 4 6 6 6 6 3 3 3 3 1 5 1 5\\n\", \"4 4 3 3 5 5 5 5 1 1 6 6 3 6 3 6 4 1 4 1 2 2 2 2\\n\", \"5 5 5 5 6 6 2 2 3 3 3 3 2 2 1 1 4 4 6 6 1 1 4 4\\n\", \"1 4 3 4 2 6 5 2 1 5 1 6 3 4 3 6 5 5 1 3 2 6 4 2\\n\", \"4 4 2 5 3 2 4 2 5 3 6 4 6 5 1 3 1 5 6 3 1 1 6 2\\n\", \"4 5 3 4 5 5 6 3 2 5 1 6 2 1 6 3 1 4 2 3 2 6 1 4\\n\", \"3 3 2 3 6 4 4 4 1 2 1 3 2 5 6 6 1 2 6 5 4 5 1 5\\n\", \"5 6 1 1 4 5 6 5 4 6 2 1 4 2 6 5 3 2 3 2 3 1 3 4\\n\", \"4 4 4 5 2 3 4 1 3 3 1 5 6 5 6 6 1 3 6 2 5 2 1 2\\n\", \"3 2 5 6 1 4 3 4 6 5 4 3 2 3 2 2 1 4 1 1 6 5 6 5\\n\", \"5 4 6 2 5 6 4 1 6 3 3 1 3 2 4 1 1 6 2 3 5 2 4 5\\n\", \"6 6 3 1 5 6 5 3 2 5 3 1 2 4 1 6 4 5 2 2 4 1 3 4\\n\", \"6 5 4 1 6 5 2 3 3 5 3 6 4 2 6 5 4 2 1 1 4 1 3 2\\n\", \"1 3 5 6 4 4 4 3 5 2 2 2 3 1 5 6 3 4 6 5 1 2 1 6\\n\", \"3 6 5 4 4 6 1 4 3 2 5 2 1 2 6 2 5 4 1 3 1 6 5 3\\n\", \"5 2 6 1 5 3 5 3 1 1 3 6 6 2 4 2 5 4 4 2 1 3 4 6\\n\", \"2 5 6 2 3 6 5 6 2 3 1 3 6 4 5 4 1 1 1 5 3 4 4 2\\n\", \"4 5 4 4 3 3 1 2 3 1 1 5 2 2 5 6 6 4 3 2 6 5 1 6\\n\", \"5 2 5 2 3 5 3 5 4 3 4 3 6 6 6 6 1 1 1 1 4 2 4 2\\n\", \"2 4 2 4 4 5 4 5 5 1 5 1 3 3 3 3 6 6 6 6 2 1 2 1\\n\", \"3 5 3 5 5 1 5 1 1 4 1 4 6 6 6 6 2 2 2 2 3 4 3 4\\n\", \"2 1 2 1 4 2 4 2 6 4 6 4 5 5 5 5 3 3 3 3 6 1 6 1\\n\", \"4 4 2 2 1 1 1 1 5 5 6 6 2 6 2 6 4 5 4 5 3 3 3 3\\n\", \"1 1 2 2 4 4 4 4 5 5 6 6 5 1 5 1 6 2 6 2 3 3 3 3\\n\", \"2 2 6 6 4 4 4 4 1 1 5 5 1 2 1 2 5 6 5 6 3 3 3 3\\n\", \"2 2 3 3 6 6 6 6 4 4 1 1 3 1 3 1 2 4 2 4 5 5 5 5\\n\", \"6 6 6 6 4 4 3 3 5 5 5 5 3 3 1 1 2 2 4 4 1 1 2 2\\n\", \"2 2 2 2 4 4 5 5 3 3 3 3 6 6 4 4 5 5 1 1 1 1 6 6\\n\", \"1 1 1 1 5 5 6 6 3 3 3 3 4 4 5 5 6 6 2 2 2 2 4 4\\n\", \"4 4 4 4 2 2 3 3 1 1 1 1 3 3 6 6 5 5 2 2 6 6 5 5\\n\", \"1 1 1 1 2 2 3 3 6 6 6 6 5 5 4 4 3 3 2 2 4 4 5 5\\n\", \"1 1 2 2 3 3 1 1 2 2 3 3 4 4 4 4 5 5 5 5 6 6 6 6\\n\", \"5 5 5 5 1 1 2 2 6 6 6 6 4 4 3 3 3 3 4 4 2 2 1 1\\n\"], \"outputs\": [\"NO\", \"YES\", \"NO\", \"NO\", \"NO\", \"NO\", \"YES\", \"YES\", \"NO\", \"YES\", \"YES\", \"YES\", \"YES\", \"YES\", \"YES\", \"YES\", \"YES\", \"YES\", \"NO\", \"NO\", \"NO\", \"NO\", \"NO\", \"NO\", \"NO\", \"NO\", \"NO\", \"NO\", \"NO\", \"NO\", \"NO\", \"NO\", \"NO\", \"YES\", \"YES\", \"YES\", \"YES\", \"YES\", \"YES\", \"YES\", \"YES\", \"YES\", \"YES\", \"YES\", \"YES\", \"NO\", \"NO\", \"NO\"]}", "source": "primeintellect"}
During the breaks between competitions, top-model Izabella tries to develop herself and not to be bored. For example, now she tries to solve Rubik's cube 2x2x2. It's too hard to learn to solve Rubik's cube instantly, so she learns to understand if it's possible to solve the cube in some state using 90-degrees rotation of one face of the cube in any direction. To check her answers she wants to use a program which will for some state of cube tell if it's possible to solve it using one rotation, described above. Cube is called solved if for each face of cube all squares on it has the same color. https://en.wikipedia.org/wiki/Rubik's_Cube -----Input----- In first line given a sequence of 24 integers a_{i} (1 ≤ a_{i} ≤ 6), where a_{i} denotes color of i-th square. There are exactly 4 occurrences of all colors in this sequence. -----Output----- Print «YES» (without quotes) if it's possible to solve cube using one rotation and «NO» (without quotes) otherwise. -----Examples----- Input 2 5 4 6 1 3 6 2 5 5 1 2 3 5 3 1 1 2 4 6 6 4 3 4 Output NO Input 5 3 5 3 2 5 2 5 6 2 6 2 4 4 4 4 1 1 1 1 6 3 6 3 Output YES -----Note----- In first test case cube looks like this: [Image] In second test case cube looks like this: [Image] It's possible to solve cube by rotating face with squares with numbers 13, 14, 15, 16. Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0
{"tests": "{\"inputs\": [\"3 1 2\\n\", \"3 3 3\\n\", \"5 1 1\\n\", \"2 1 1\\n\", \"1 1 1\\n\", \"3 1 1\\n\", \"5 2 2\\n\", \"4 1 1\\n\", \"4 4 1\\n\", \"3 1 3\\n\", \"2 1 2\\n\", \"6 1 1\\n\", \"3 2 1\\n\", \"5 1 2\\n\", \"4 1 2\\n\", \"2 2 1\\n\", \"3 3 1\\n\", \"2 2 2\\n\", \"1 1 1\\n\", \"2 1 1\\n\", \"2 1 2\\n\", \"2 2 1\\n\", \"2 2 2\\n\", \"3 1 1\\n\", \"3 1 2\\n\", \"3 1 3\\n\", \"3 2 1\\n\", \"3 2 2\\n\", \"3 2 3\\n\", \"3 3 1\\n\", \"3 3 2\\n\", \"3 3 3\\n\", \"4 1 1\\n\", \"4 1 2\\n\", \"4 1 3\\n\", \"4 1 4\\n\", \"4 2 1\\n\", \"4 2 2\\n\", \"4 2 3\\n\", \"4 2 4\\n\", \"4 3 1\\n\", \"4 3 2\\n\", \"4 3 3\\n\", \"4 3 4\\n\", \"4 4 1\\n\", \"4 4 2\\n\", \"4 4 3\\n\", \"4 4 4\\n\"], \"outputs\": [\"YES\\n001\\n001\\n110\\n\", \"NO\\n\", \"YES\\n01000\\n10100\\n01010\\n00101\\n00010\\n\", \"NO\\n\", \"YES\\n0\\n\", \"NO\\n\", \"NO\\n\", \"YES\\n0100\\n1010\\n0101\\n0010\\n\", \"YES\\n0000\\n0000\\n0000\\n0000\\n\", \"YES\\n011\\n101\\n110\\n\", \"YES\\n01\\n10\\n\", \"YES\\n010000\\n101000\\n010100\\n001010\\n000101\\n000010\\n\", \"YES\\n010\\n100\\n000\\n\", \"YES\\n00111\\n00011\\n10001\\n11001\\n11110\\n\", \"YES\\n0011\\n0001\\n1001\\n1110\\n\", \"YES\\n00\\n00\\n\", \"YES\\n000\\n000\\n000\\n\", \"NO\\n\", \"YES\\n0\\n\", \"NO\\n\", \"YES\\n01\\n10\\n\", \"YES\\n00\\n00\\n\", \"NO\\n\", \"NO\\n\", \"YES\\n001\\n001\\n110\\n\", \"YES\\n011\\n101\\n110\\n\", \"YES\\n010\\n100\\n000\\n\", \"NO\\n\", \"NO\\n\", \"YES\\n000\\n000\\n000\\n\", \"NO\\n\", \"NO\\n\", \"YES\\n0100\\n1010\\n0101\\n0010\\n\", \"YES\\n0011\\n0001\\n1001\\n1110\\n\", \"YES\\n0011\\n0011\\n1101\\n1110\\n\", \"YES\\n0111\\n1011\\n1101\\n1110\\n\", \"YES\\n0100\\n1010\\n0100\\n0000\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"YES\\n0100\\n1000\\n0000\\n0000\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"YES\\n0000\\n0000\\n0000\\n0000\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\"]}", "source": "primeintellect"}
Given three numbers $n, a, b$. You need to find an adjacency matrix of such an undirected graph that the number of components in it is equal to $a$, and the number of components in its complement is $b$. The matrix must be symmetric, and all digits on the main diagonal must be zeroes. In an undirected graph loops (edges from a vertex to itself) are not allowed. It can be at most one edge between a pair of vertices. The adjacency matrix of an undirected graph is a square matrix of size $n$ consisting only of "0" and "1", where $n$ is the number of vertices of the graph and the $i$-th row and the $i$-th column correspond to the $i$-th vertex of the graph. The cell $(i,j)$ of the adjacency matrix contains $1$ if and only if the $i$-th and $j$-th vertices in the graph are connected by an edge. A connected component is a set of vertices $X$ such that for every two vertices from this set there exists at least one path in the graph connecting this pair of vertices, but adding any other vertex to $X$ violates this rule. The complement or inverse of a graph $G$ is a graph $H$ on the same vertices such that two distinct vertices of $H$ are adjacent if and only if they are not adjacent in $G$. -----Input----- In a single line, three numbers are given $n, a, b \,(1 \le n \le 1000, 1 \le a, b \le n)$: is the number of vertexes of the graph, the required number of connectivity components in it, and the required amount of the connectivity component in it's complement. -----Output----- If there is no graph that satisfies these constraints on a single line, print "NO" (without quotes). Otherwise, on the first line, print "YES"(without quotes). In each of the next $n$ lines, output $n$ digits such that $j$-th digit of $i$-th line must be $1$ if and only if there is an edge between vertices $i$ and $j$ in $G$ (and $0$ otherwise). Note that the matrix must be symmetric, and all digits on the main diagonal must be zeroes. If there are several matrices that satisfy the conditions — output any of them. -----Examples----- Input 3 1 2 Output YES 001 001 110 Input 3 3 3 Output NO Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0
{"tests": "{\"inputs\": [\"ABCDEFGHIJKLMNOPQRSGTUVWXYZ\\n\", \"BUVTYZFQSNRIWOXXGJLKACPEMDH\\n\", \"DYCEUXXKMGZOINVPHWQSRTABLJF\\n\", \"UTEDBZRVWLOFUASHCYIPXGJMKNQ\\n\", \"ZWMFLTCQIAJEVUPODMSGXKHRNYB\\n\", \"QGZEMFKWLUHOVSXJTCPIYREDNAB\\n\", \"BMVFGRNDOWTILZVHAKCQSXYEJUP\\n\", \"MKNTKOBFLJSXWQPVUERDHIACYGZ\\n\", \"YOFJVQSWBUZENPCXGQTHMDKAILR\\n\", \"GYCUAXSBNAWFIJPDQVETKZOMLHR\\n\", \"BITCRJOKMPDDUSWAYXHQZEVGLFN\\n\", \"XCDSLTYWJIGUBPHNFZWVMQARKOE\\n\", \"XTSHBGLRJAMDUIPCWYOZVERNKQF\\n\", \"RFKNZXHAIMVBWEBPTCSYOLJGDQU\\n\", \"HVDEBKMJTLKQORNWCZSGXYIPUAF\\n\", \"XZTMCRBONHFIUVPKWSDLJQGAHYE\\n\", \"YAMVOHUJLEDCWZLXNRGPIQTBSKF\\n\", \"XECPFJBHINOWVLAGTUMRZYHQSDK\\n\", \"UULGRBAODZENVCSMJTHXPWYKFIQ\\n\", \"BADSLHIYGMZJQKTCOPRVUXFWENN\\n\", \"TEGXHBUVZDPAMIJFQYCWRKSTNLO\\n\", \"XQVBTCNIRFPLOHAYZUMKWEJSXDG\\n\", \"MIDLBEUAGTNPYKFWHVSRJOXCZMQ\\n\", \"NMGIFDZKBCVRYLTWOASXHEUQPJN\\n\", \"AHGZCRJTKPMQUNBWSIYLDXEHFVO\\n\", \"UNGHFQRCIPBZTEOAYJXLDMSKNWV\\n\", \"MKBGVNDJRAWUEHFSYLIZCOPTXKQ\\n\", \"UTGDEJHCBKRWLYFSONAQVMPIXZT\\n\", \"BETRFOVLPCMWKHAXSGUDQYJTZIN\\n\", \"HIDCLZUTPOQGEXFASJNYBVRMDKW\\n\", \"CNHIKJWRLPXTQZVUGYDMBAOEFHS\\n\", \"LCFNHUQWXBPOSJMYTGKDAZVREIF\\n\", \"OURNQJWMIXCLGSDVEKZAFBYNTPH\\n\", \"ZWFIRJNXVKHOUSTQBLEGYMAPIDC\\n\", \"UOWJXRKHZDNGLSAMEIYTQBVCFJP\\n\", \"IHDTJLGRFUXQSOZEMVYKWCPANBT\\n\", \"ABCDEFGHIJKLMNOPQRSTUVWXYZA\\n\", \"ABACDEFGHIJKLMNOPQRSTUVWXYZ\\n\", \"ABCDEFGHIJKLMNOPQRSTUVWXYZG\\n\", \"ABCDEFGHGIJKLMNOPQRSTUVWXYZ\\n\", \"ABCDEFGHIJKLMNOPQRSTUVWXYZX\\n\", \"ABCDEFGHIJKLMNOPQRSTUVWYXYZ\\n\", \"BUVTYZFQSNRIWOXGJLKACPEMDHB\\n\", \"QWERTYUIOPASDFGHJKLZXCVBNMQ\\n\", \"ABCBDEFGHIJKLMNOPQRSTUVWXYZ\\n\", \"ABCDEFGHIJKLMNOPQRSTUVWXAYZ\\n\", \"ABCDEFGHIJKLMZYXWVUTSRQPONA\\n\", \"BACDEFGHIJKLMNOPQRSTUVWXYZA\\n\"], \"outputs\": [\"YXWVUTGHIJKLM\\nZABCDEFSRQPON\\n\", \"Impossible\\n\", \"Impossible\\n\", \"PIYCHSAUTEDBZ\\nXGJMKNQFOLWVR\\n\", \"HKXGSMFLTCQIA\\nRNYBZWDOPUVEJ\\n\", \"ANDEMFKWLUHOV\\nBQGZRYIPCTJXS\\n\", \"XSQCKAHVFGRND\\nYEJUPBMZLITWO\\n\", \"VPQWXSJLFBOKN\\nUERDHIACYGZMT\\n\", \"IAKDMHTQSWBUZ\\nLRYOFJVGXCPNE\\n\", \"TEVQDPJIFWAXS\\nKZOMLHRGYCUNB\\n\", \"Impossible\\n\", \"OKRAQMVWJIGUB\\nEXCDSLTYZFNHP\\n\", \"XFQKNRJAMDUIP\\nTSHBGLEVZOYWC\\n\", \"QDGJLOYSCTPBW\\nURFKNZXHAIMVE\\n\", \"XGSZCWNROQKMJ\\nYIPUAFHVDEBLT\\n\", \"TZXEYHFIUVPKW\\nMCRBONAGQJLDS\\n\", \"SBTQIPGRNXLED\\nKFYAMVOHUJZWC\\n\", \"XKDSQHINOWVLA\\nECPFJBYZRMUTG\\n\", \"Impossible\\n\", \"Impossible\\n\", \"NTEGXHBUVZDPA\\nLOSKRWCYQFJIM\\n\", \"DXQVBTCNIRFPL\\nGSJEWKMUZYAHO\\n\", \"MIDLBEUAGTNPY\\nQZCXOJRSVHWFK\\n\", \"NMGIFDZKBCVRY\\nJPQUEHXSAOWTL\\n\", \"VFHGZCRJTKPMQ\\nOAEXDLYISWBNU\\n\", \"WNGHFQRCIPBZT\\nVUKSMDLXJYAOE\\n\", \"QKBGVNDJRAWUE\\nMXTPOCZILYSFH\\n\", \"TGDEJHCBKRWLY\\nUZXIPMVQANOSF\\n\", \"IZTRFOVLPCMWK\\nNBEJYQDUGSXAH\\n\", \"WKDCLZUTPOQGE\\nHIMRVBYNJSAFX\\n\", \"SHIKJWRLPXTQZ\\nCNFEOABMDYGUV\\n\", \"LFNHUQWXBPOSJ\\nCIERVZADKGTYM\\n\", \"HPTNQJWMIXCLG\\nOURYBFAZKEVDS\\n\", \"CDIRJNXVKHOUS\\nZWFPAMYGELBQT\\n\", \"UPJXRKHZDNGLS\\nOWFCVBQTYIEMA\\n\", \"ITJLGRFUXQSOZ\\nHDBNAPCWKYVME\\n\", \"ABCDEFGHIJKLM\\nZYXWVUTSRQPON\\n\", \"NMLKJIHGFEDCA\\nOPQRSTUVWXYZB\\n\", \"CBAGHIJKLMNOP\\nDEFZYXWVUTSRQ\\n\", \"TSRQPONMLKJIG\\nUVWXYZABCDEFH\\n\", \"KJIHGFEDCBAXY\\nLMNOPQRSTUVWZ\\n\", \"KJIHGFEDCBAZY\\nLMNOPQRSTUVWX\\n\", \"BUVTYZFQSNRIW\\nHDMEPCAKLJGXO\\n\", \"QWERTYUIOPASD\\nMNBVCXZLKJHGF\\n\", \"ONMLKJIHGFEDB\\nPQRSTUVWXYZAC\\n\", \"YABCDEFGHIJKL\\nZXWVUTSRQPONM\\n\", \"ABCDEFGHIJKLM\\nNOPQRSTUVWXYZ\\n\", \"ACDEFGHIJKLMN\\nBZYXWVUTSRQPO\\n\"]}", "source": "primeintellect"}
Let’s define a grid to be a set of tiles with 2 rows and 13 columns. Each tile has an English letter written in it. The letters don't have to be unique: there might be two or more tiles with the same letter written on them. Here is an example of a grid: ABCDEFGHIJKLM NOPQRSTUVWXYZ We say that two tiles are adjacent if they share a side or a corner. In the example grid above, the tile with the letter 'A' is adjacent only to the tiles with letters 'B', 'N', and 'O'. A tile is not adjacent to itself. A sequence of tiles is called a path if each tile in the sequence is adjacent to the tile which follows it (except for the last tile in the sequence, which of course has no successor). In this example, "ABC" is a path, and so is "KXWIHIJK". "MAB" is not a path because 'M' is not adjacent to 'A'. A single tile can be used more than once by a path (though the tile cannot occupy two consecutive places in the path because no tile is adjacent to itself). You’re given a string s which consists of 27 upper-case English letters. Each English letter occurs at least once in s. Find a grid that contains a path whose tiles, viewed in the order that the path visits them, form the string s. If there’s no solution, print "Impossible" (without the quotes). -----Input----- The only line of the input contains the string s, consisting of 27 upper-case English letters. Each English letter occurs at least once in s. -----Output----- Output two lines, each consisting of 13 upper-case English characters, representing the rows of the grid. If there are multiple solutions, print any of them. If there is no solution print "Impossible". -----Examples----- Input ABCDEFGHIJKLMNOPQRSGTUVWXYZ Output YXWVUTGHIJKLM ZABCDEFSRQPON Input BUVTYZFQSNRIWOXXGJLKACPEMDH Output Impossible Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0
{"tests": "{\"inputs\": [\"5 7 1 3 2 2\\n\", \"5 5 2 3 1 1\\n\", \"1 1 1 1 1 1\\n\", \"23000 15500 100 333 9 1\\n\", \"33999 99333 33000 99000 3 9\\n\", \"5 7 1 3 1 2\\n\", \"1 100 1 50 1 50\\n\", \"1000 1 1 1 1 500\\n\", \"304 400 12 20 4 4\\n\", \"1000000 1000000 1000000 1000000 1000000 1000000\\n\", \"1000000 99999 12345 23456 23 54\\n\", \"50000 100000 500 1000 500 1000\\n\", \"50000 100000 500 1000 500 2000\\n\", \"50000 100000 500 1000 500 500\\n\", \"99999 99999 1 2 1 1\\n\", \"5 4 2 3 2 2\\n\", \"5 4 2 3 1 1\\n\", \"5 5 1 3 1 2\\n\", \"2347 2348 234 48 238 198\\n\", \"1000000 2 2 2 2 1\\n\", \"100 100 50 50 500 500\\n\", \"1000 2000 100 200 90 90\\n\", \"1000 1000 10 15 10 5\\n\", \"23000 15500 100 333 9 1\\n\", \"5 5 4 3 1 2\\n\", \"5 5 4 4 1 1\\n\", \"5 5 4 2 1 1\\n\", \"3 3 2 2 2 2\\n\", \"5 8 4 1 2 1\\n\", \"5 8 4 2 1 2\\n\", \"2 8 1 2 1 3\\n\", \"1000000 1000000 500000 500000 1 1\\n\", \"500000 100000 400 80000 2 2\\n\", \"1004 999004 4 4 5 5\\n\", \"11 11 3 3 4 4\\n\", \"100 100 70 5 1 1\\n\", \"1 5 1 3 1 1\\n\", \"1 5 1 3 10 1\\n\", \"6 1 5 1 2 2\\n\", \"2 10 1 5 2 2\\n\", \"5 1 3 1 1 1\\n\", \"1000 1000 1 3 10000 1\\n\", \"2 6 1 2 2 2\\n\", \"2 6 1 2 6 2\\n\", \"7 1 5 1 2 2\\n\", \"2 20 2 5 2 2\\n\", \"4 4 3 4 1 5\\n\"], \"outputs\": [\"2\\n\", \"Poor Inna and pony!\\n\", \"0\\n\", \"15167\\n\", \"333\\n\", \"2\\n\", \"Poor Inna and pony!\\n\", \"0\\n\", \"95\\n\", \"0\\n\", \"Poor Inna and pony!\\n\", \"99\\n\", \"Poor Inna and pony!\\n\", \"Poor Inna and pony!\\n\", \"Poor Inna and pony!\\n\", \"Poor Inna and pony!\\n\", \"1\\n\", \"Poor Inna and pony!\\n\", \"Poor Inna and pony!\\n\", \"499999\\n\", \"Poor Inna and pony!\\n\", \"20\\n\", \"197\\n\", \"15167\\n\", \"1\\n\", \"1\\n\", \"1\\n\", \"Poor Inna and pony!\\n\", \"Poor Inna and pony!\\n\", \"3\\n\", \"2\\n\", \"499999\\n\", \"249800\\n\", \"199800\\n\", \"2\\n\", \"30\\n\", \"Poor Inna and pony!\\n\", \"Poor Inna and pony!\\n\", \"Poor Inna and pony!\\n\", \"Poor Inna and pony!\\n\", \"Poor Inna and pony!\\n\", \"Poor Inna and pony!\\n\", \"Poor Inna and pony!\\n\", \"Poor Inna and pony!\\n\", \"Poor Inna and pony!\\n\", \"Poor Inna and pony!\\n\", \"Poor Inna and pony!\\n\"]}", "source": "primeintellect"}
Dima and Inna are doing so great! At the moment, Inna is sitting on the magic lawn playing with a pink pony. Dima wanted to play too. He brought an n × m chessboard, a very tasty candy and two numbers a and b. Dima put the chessboard in front of Inna and placed the candy in position (i, j) on the board. The boy said he would give the candy if it reaches one of the corner cells of the board. He's got one more condition. There can only be actions of the following types: move the candy from position (x, y) on the board to position (x - a, y - b); move the candy from position (x, y) on the board to position (x + a, y - b); move the candy from position (x, y) on the board to position (x - a, y + b); move the candy from position (x, y) on the board to position (x + a, y + b). Naturally, Dima doesn't allow to move the candy beyond the chessboard borders. Inna and the pony started shifting the candy around the board. They wonder what is the minimum number of allowed actions that they need to perform to move the candy from the initial position (i, j) to one of the chessboard corners. Help them cope with the task! -----Input----- The first line of the input contains six integers n, m, i, j, a, b (1 ≤ n, m ≤ 10^6; 1 ≤ i ≤ n; 1 ≤ j ≤ m; 1 ≤ a, b ≤ 10^6). You can assume that the chessboard rows are numbered from 1 to n from top to bottom and the columns are numbered from 1 to m from left to right. Position (i, j) in the statement is a chessboard cell on the intersection of the i-th row and the j-th column. You can consider that the corners are: (1, m), (n, 1), (n, m), (1, 1). -----Output----- In a single line print a single integer — the minimum number of moves needed to get the candy. If Inna and the pony cannot get the candy playing by Dima's rules, print on a single line "Poor Inna and pony!" without the quotes. -----Examples----- Input 5 7 1 3 2 2 Output 2 Input 5 5 2 3 1 1 Output Poor Inna and pony! -----Note----- Note to sample 1: Inna and the pony can move the candy to position (1 + 2, 3 + 2) = (3, 5), from there they can move it to positions (3 - 2, 5 + 2) = (1, 7) and (3 + 2, 5 + 2) = (5, 7). These positions correspond to the corner squares of the chess board. Thus, the answer to the test sample equals two. Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0
{"tests": "{\"inputs\": [\"aabb\\n\", \"aabcaa\\n\", \"abbcccbba\\n\", \"aaaaaaaaaaa\\n\", \"aaaaaaaaabbbbbaaaabaaaaaaaaaaaaaaaaabaaaaaabbbbbbbaaabbbbbbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaaaaaaaaaaaa\\n\", \"abc\\n\", \"a\\n\", \"ab\\n\", \"ba\\n\", \"aaabbb\\n\", \"abababababab\\n\", \"aaabbbbbbaaa\\n\", \"bbbbbbbbbbbbbbbbbbbbbbddddddddddddddddaaaaaaaaaaaaaccccccccbbbbbbbaaaaaaaaaabbbbbbbbaaaaaaaaaacccccc\\n\", \"bbeeeeaaaaccccbbbbeeeeeeeeeeaaaaddddddddddddddddddbbbbbbbdddeeeeeeeeeeaaaaaaaaeeeeeaaaaadbbbbbbbeadd\\n\", \"abaabaaaabaabbaabaabaabbaabbaabaaaabbaabbaabaabaabaabbabaabbababbababbabaababbaaabbbbaabbabbaabbaaba\\n\", \"bbbbbbbbbbbbbbbbbbbbbbbbbbddddddddddddddddddddddddddddddddddddddcccccccccccccccccccccccccccccccccccc\\n\", \"bcddbbdaebbaeaceaaebaacacbeecdbaeccaccbddedaceeeeecccabcabcbddbadaebcecdeaddcccacaeacddadbbeabeecadc\\n\", \"aaaaaaacccccccccdddddaaaaaaaaccaaaaaaaaaaaccccccccceebbbbbbbbbdddddddddcccccccbbbbbbbbbeeeedddddeeee\\n\", \"cccbcccabcaaaacabcacacccabbacccaccabbbcaaccaaabcccaabcbbcbcabccbccbbacbacabccabcbbbaaaccaaaaccaaccaa\\n\", \"bbbbbbcccccccccccccccccccbbbbaaaaaaaaaccccccbbbbaaaaaaaaaaabbbbbaccccccccccccccccccccbbbbaaaaaabbbbb\\n\", \"aaaaaaccccccccccccccaaaacccccccccccaaaaaacaaaaaaaabbbbaacccccccccccccccaaaaaaaaccccccbbbbbbbbccccccc\\n\", \"acaaacaaacaacabcaaabbbabcbccbccbcccbbacbcccababccabcbbcbcbbabccabacccabccbbbbbabcbbccacaacbbbccbbcab\\n\", \"bbbbbbddddddddddddddddddddcccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\\n\", \"abaaababbbbbbabababbaabbabbbaababaaabaabbbaaaabaabaaabababbaaaabbbbbbaaabbbbababbaababaabaaaabbabbab\\n\", \"ddaaaaaaaaaaccccddddddddddeeeeaaaeedddddaaaaaaeebedddddeeeeeeeeeebbbbbbbbbbbbbbaaaaaabbbbbbbeeeeeebb\\n\", \"abbabbaaabababaababaaaabababbbbaabaaaaaaaaaabbbbababababababababbabaaabbaaaaabaaaabaaaaababaabaabaab\\n\", \"cccccccccccccccccccccccccccaaaaaccccaaabbbbbbbbbbbbbbbbbbbbbbbbcbbbbbbbbbbbbbbbbbaaaaaaabbbbbbbbbaaa\\n\", \"cbbabaacccacaaacacbabcbbacacbbbcaccacbcbbbabbaccaaacbbccbaaaabbcbcccacbababbbbcaabcbacacbbccaabbaaac\\n\", \"ddddddbdddddcccccccbbccccccddcccccccccbbbbbbbbbbddddddddddddddaaaeeeeedddddddddddddddcccccccbbbbbbbb\\n\", \"aaaaabbbbbaaaaabbbbaaabbbbbbbaaabbbbbabbbbbbbaabbbbbbbbbbbbaaaaabbbbbbbbbbbbbbbbbbbbbbbbaaaaaabbbbbb\\n\", \"ccbacccbcbabcbbcaacbcacccaabbababacbaabacababcaacbaacbaccccacccaababbbccacacacacababbabbbbbbbcbabaaa\\n\", \"aabbabbbbbbbbaaaaaaaaaaaaaaaaaaaaaaaccccaaaabbbbbbaaaaacccccccccccccbbbbbbbbbbcccccccccbbaaaaaaaaaaa\\n\", \"bddbeddebbeaccdeeeceaebbdaabecbcaeaaddbbeadebbbbebaddbdcdecaeebaceaeeabbbccccaaebbadcaaaebcedccecced\\n\", \"abcaccabbacbcabaabaacabbbaabcbbbbacccaaabaacabbababbbbbcbcbbaaaabcaacbcccbabcaacaabbcbbcbbbcaabccacc\\n\", \"bbbbbbbbbbbbbbbbbbbbbbbbbbbeeeeeeeeeeeeeeeeeeeeeeeeeeeebbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\n\", \"ccccccccccccccccccccccccccccccccaaaaaaaaaaaaaacccccccccccccccccccccccccccccccccccccccccccccccccccccc\\n\", \"eeeeeeeeebbbbbbbbbbbbbbeeeeeeeeddcccccccccbbbbbbbbbbbbeeeeeddbbbbbbbbbbeeeeeebbaaaaddeeebbbbbbbacccc\\n\", \"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbaaaaaaaaaaabbbbbbbbaaaaaaaaabbbbbaaaaaaaaaaabbbbbbaaabbbbaaabbbbbbaaa\\n\", \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeaaaaaaaaaaaaaaaaaa\\n\", \"bbbbbbbbaaaaaaaaaaaccccccaaaaaaaaaaaaaaccccccccaaaaaaaaabbbbbbccbbbaaaaaabccccccaaaacaaacccccccccccb\\n\", \"aaaaaaabbbbbbbbbddddddddddeeeeeeeebbbbbeeebbbbccccccceeeeeeeaaaaaaaaabbbbbbdddddbbbbbbeeeeeeaaeeeaaa\\n\", \"aaabbbbbbbbbbbbbbbbbbbbbbbbbbbbaaaaaaaabbbaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbaaaaaabbbbbbbbbbbbbaaaaa\\n\", \"dbcbacdcacacdccddbbbabbcdcccacbaccbadacdbdbccdccacbcddcbcdbacdccddcdadaadabcdabcbddddcbaaacccacacbbc\\n\", \"aaaaaaacccccccccccccccccccbbaaaaaaaaabcccaaaaaaaaaabbccccaaaaaaaaaaccccaabbcccbbbbbbbbbbaaaaaaaaaaaa\\n\", \"ebbcadacbaacdedeaaaaccbaceccbbbcbaceadcbdeaebcbbbacaebaaaceebcaaaeabdeaaddabcccceecaebdbacdadccaedce\\n\", \"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaccccccccccccccddddddddddd\\n\", \"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbddddddaaaaaaaaaaaaaaaaaaaaaaaaaaaaaccccccccccccccccc\\n\"], \"outputs\": [\"2\\n\", \"1\\n\", \"1\\n\", \"0\\n\", \"12\\n\", \"1\\n\", \"0\\n\", \"1\\n\", \"1\\n\", \"3\\n\", \"1\\n\", \"3\\n\", \"11\\n\", \"8\\n\", \"3\\n\", \"26\\n\", \"3\\n\", \"5\\n\", \"4\\n\", \"7\\n\", \"6\\n\", \"4\\n\", \"14\\n\", \"4\\n\", \"8\\n\", \"2\\n\", \"27\\n\", \"2\\n\", \"9\\n\", \"5\\n\", \"5\\n\", \"7\\n\", \"2\\n\", \"2\\n\", \"27\\n\", \"7\\n\", \"9\\n\", \"12\\n\", \"15\\n\", \"10\\n\", \"5\\n\", \"7\\n\", \"2\\n\", \"12\\n\", \"3\\n\", \"28\\n\", \"17\\n\"]}", "source": "primeintellect"}
You are given a set of points on a straight line. Each point has a color assigned to it. For point a, its neighbors are the points which don't have any other points between them and a. Each point has at most two neighbors - one from the left and one from the right. You perform a sequence of operations on this set of points. In one operation, you delete all points which have a neighbor point of a different color than the point itself. Points are deleted simultaneously, i.e. first you decide which points have to be deleted and then delete them. After that you can perform the next operation etc. If an operation would not delete any points, you can't perform it. How many operations will you need to perform until the next operation does not have any points to delete? -----Input----- Input contains a single string of lowercase English letters 'a'-'z'. The letters give the points' colors in the order in which they are arranged on the line: the first letter gives the color of the leftmost point, the second gives the color of the second point from the left etc. The number of the points is between 1 and 10^6. -----Output----- Output one line containing an integer - the number of operations which can be performed on the given set of points until there are no more points to delete. -----Examples----- Input aabb Output 2 Input aabcaa Output 1 -----Note----- In the first test case, the first operation will delete two middle points and leave points "ab", which will be deleted with the second operation. There will be no points left to apply the third operation to. In the second test case, the first operation will delete the four points in the middle, leaving points "aa". None of them have neighbors of other colors, so the second operation can't be applied. Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0.375
{"tests": "{\"inputs\": [\"^ >\\n1\\n\", \"< ^\\n3\\n\", \"^ v\\n6\\n\", \"^ >\\n999999999\\n\", \"> v\\n1\\n\", \"v <\\n1\\n\", \"< ^\\n1\\n\", \"v <\\n422435957\\n\", \"v >\\n139018901\\n\", \"v ^\\n571728018\\n\", \"^ ^\\n0\\n\", \"< >\\n2\\n\", \"> >\\n1000000000\\n\", \"v v\\n8\\n\", \"< <\\n1568\\n\", \"^ v\\n2\\n\", \"^ <\\n1\\n\", \"< v\\n1\\n\", \"v >\\n1\\n\", \"> ^\\n1\\n\", \"v <\\n422435957\\n\", \"v v\\n927162384\\n\", \"v ^\\n571728018\\n\", \"^ <\\n467441155\\n\", \"^ >\\n822875521\\n\", \"^ <\\n821690113\\n\", \"^ <\\n171288453\\n\", \"^ <\\n110821381\\n\", \"^ ^\\n539580280\\n\", \"^ >\\n861895563\\n\", \"v v\\n4\\n\", \"^ ^\\n4\\n\", \"> >\\n4\\n\", \"< <\\n8\\n\", \"v v\\n0\\n\", \"^ <\\n11\\n\", \"< <\\n4\\n\", \"< <\\n0\\n\", \"< v\\n3\\n\", \"^ <\\n3\\n\", \"^ <\\n7\\n\", \"< >\\n6\\n\", \"v >\\n3\\n\", \"> >\\n300\\n\", \"> >\\n0\\n\", \"v <\\n3\\n\", \"> >\\n12\\n\"], \"outputs\": [\"cw\\n\", \"ccw\\n\", \"undefined\\n\", \"ccw\\n\", \"cw\\n\", \"cw\\n\", \"cw\\n\", \"cw\\n\", \"ccw\\n\", \"undefined\\n\", \"undefined\\n\", \"undefined\\n\", \"undefined\\n\", \"undefined\\n\", \"undefined\\n\", \"undefined\\n\", \"ccw\\n\", \"ccw\\n\", \"ccw\\n\", \"ccw\\n\", \"cw\\n\", \"undefined\\n\", \"undefined\\n\", \"cw\\n\", \"cw\\n\", \"ccw\\n\", \"ccw\\n\", \"ccw\\n\", \"undefined\\n\", \"ccw\\n\", \"undefined\\n\", \"undefined\\n\", \"undefined\\n\", \"undefined\\n\", \"undefined\\n\", \"cw\\n\", \"undefined\\n\", \"undefined\\n\", \"cw\\n\", \"cw\\n\", \"cw\\n\", \"undefined\\n\", \"cw\\n\", \"undefined\\n\", \"undefined\\n\", \"ccw\\n\", \"undefined\\n\"]}", "source": "primeintellect"}
[Image] Walking through the streets of Marshmallow City, Slastyona have spotted some merchants selling a kind of useless toy which is very popular nowadays – caramel spinner! Wanting to join the craze, she has immediately bought the strange contraption. Spinners in Sweetland have the form of V-shaped pieces of caramel. Each spinner can, well, spin around an invisible magic axis. At a specific point in time, a spinner can take 4 positions shown below (each one rotated 90 degrees relative to the previous, with the fourth one followed by the first one): [Image] After the spinner was spun, it starts its rotation, which is described by a following algorithm: the spinner maintains its position for a second then majestically switches to the next position in clockwise or counter-clockwise order, depending on the direction the spinner was spun in. Slastyona managed to have spinner rotating for exactly n seconds. Being fascinated by elegance of the process, she completely forgot the direction the spinner was spun in! Lucky for her, she managed to recall the starting position, and wants to deduct the direction given the information she knows. Help her do this. -----Input----- There are two characters in the first string – the starting and the ending position of a spinner. The position is encoded with one of the following characters: v (ASCII code 118, lowercase v), < (ASCII code 60), ^ (ASCII code 94) or > (ASCII code 62) (see the picture above for reference). Characters are separated by a single space. In the second strings, a single number n is given (0 ≤ n ≤ 10^9) – the duration of the rotation. It is guaranteed that the ending position of a spinner is a result of a n second spin in any of the directions, assuming the given starting position. -----Output----- Output cw, if the direction is clockwise, ccw – if counter-clockwise, and undefined otherwise. -----Examples----- Input ^ > 1 Output cw Input < ^ 3 Output ccw Input ^ v 6 Output undefined Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0.625
{"tests": "{\"inputs\": [\"7\\n1 2\\n1 3\\n2 4\\n2 5\\n3 6\\n3 7\\n\", \"6\\n1 2\\n2 3\\n2 4\\n2 5\\n2 6\\n\", \"4\\n1 2\\n2 3\\n3 4\\n\", \"10\\n2 9\\n9 3\\n3 10\\n9 4\\n9 6\\n9 5\\n2 7\\n2 1\\n2 8\\n\", \"10\\n2 5\\n5 6\\n6 1\\n6 7\\n6 8\\n5 10\\n5 3\\n2 9\\n2 4\\n\", \"8\\n7 8\\n8 2\\n2 4\\n8 6\\n8 5\\n7 3\\n7 1\\n\", \"10\\n10 9\\n9 3\\n3 4\\n4 5\\n5 1\\n1 8\\n8 2\\n2 6\\n6 7\\n\", \"12\\n1 5\\n5 7\\n7 4\\n4 6\\n4 2\\n7 11\\n7 9\\n5 10\\n5 3\\n1 8\\n1 12\\n\", \"15\\n2 5\\n5 10\\n10 14\\n14 3\\n3 7\\n7 11\\n3 6\\n3 15\\n14 1\\n14 8\\n14 12\\n10 13\\n5 4\\n2 9\\n\", \"20\\n12 7\\n7 17\\n17 19\\n19 15\\n15 4\\n4 5\\n5 18\\n18 16\\n16 13\\n13 2\\n2 3\\n16 8\\n18 9\\n18 11\\n5 10\\n5 14\\n4 6\\n17 1\\n17 20\\n\", \"21\\n12 20\\n20 6\\n6 9\\n9 11\\n11 5\\n5 7\\n7 17\\n17 16\\n16 19\\n19 8\\n16 21\\n17 13\\n7 4\\n5 18\\n11 3\\n11 1\\n6 14\\n6 2\\n20 15\\n20 10\\n\", \"20\\n6 20\\n20 10\\n10 5\\n5 2\\n2 7\\n7 14\\n14 4\\n4 3\\n14 15\\n14 19\\n7 18\\n7 8\\n2 13\\n5 9\\n5 1\\n10 12\\n20 11\\n20 17\\n6 16\\n\", \"15\\n8 14\\n14 3\\n3 1\\n1 13\\n13 5\\n5 15\\n15 2\\n15 4\\n5 10\\n13 6\\n1 12\\n3 11\\n14 7\\n8 9\\n\", \"13\\n1 2\\n1 3\\n1 4\\n2 5\\n2 6\\n2 7\\n3 8\\n3 9\\n3 10\\n4 11\\n4 12\\n4 13\\n\", \"20\\n1 2\\n1 3\\n1 4\\n1 5\\n2 6\\n2 7\\n2 8\\n3 9\\n3 10\\n3 11\\n4 12\\n4 13\\n4 14\\n5 15\\n5 16\\n5 17\\n18 17\\n19 17\\n20 17\\n\", \"1\\n\", \"20\\n6 1\\n7 1\\n8 1\\n6 5\\n5 4\\n4 3\\n3 2\\n7 9\\n9 10\\n10 11\\n11 12\\n12 13\\n14 8\\n15 14\\n15 16\\n17 16\\n17 18\\n18 19\\n19 20\\n\", \"25\\n1 2\\n1 3\\n1 4\\n2 5\\n5 6\\n6 7\\n7 8\\n2 9\\n9 10\\n11 2\\n12 11\\n13 12\\n3 14\\n14 15\\n14 16\\n16 17\\n14 18\\n18 19\\n20 4\\n20 21\\n20 22\\n22 23\\n20 24\\n24 25\\n\", \"30\\n1 2\\n1 3\\n1 4\\n1 5\\n1 6\\n1 7\\n1 8\\n1 9\\n1 10\\n1 11\\n1 12\\n1 13\\n1 14\\n1 15\\n1 16\\n1 17\\n1 18\\n1 19\\n1 20\\n1 21\\n1 22\\n1 23\\n1 24\\n1 25\\n1 26\\n1 27\\n1 28\\n1 29\\n1 30\\n\", \"21\\n17 7\\n7 14\\n14 6\\n6 2\\n2 20\\n20 11\\n11 4\\n11 18\\n20 16\\n20 13\\n2 1\\n2 15\\n6 19\\n6 5\\n14 21\\n14 10\\n7 3\\n7 12\\n17 9\\n17 8\\n\", \"17\\n9 17\\n17 4\\n4 1\\n1 3\\n3 14\\n14 7\\n7 16\\n16 10\\n16 15\\n7 8\\n14 13\\n3 11\\n1 6\\n4 5\\n17 2\\n9 12\\n\", \"19\\n3 12\\n12 11\\n11 17\\n17 2\\n2 19\\n19 16\\n19 4\\n19 1\\n2 8\\n2 5\\n17 14\\n17 10\\n11 13\\n11 9\\n12 18\\n12 6\\n3 15\\n3 7\\n\", \"18\\n17 13\\n13 11\\n11 9\\n9 15\\n15 3\\n3 16\\n3 14\\n15 10\\n15 5\\n9 1\\n9 7\\n11 4\\n11 2\\n13 6\\n13 12\\n17 18\\n17 8\\n\", \"30\\n29 3\\n3 13\\n13 7\\n7 5\\n5 6\\n6 10\\n10 8\\n8 26\\n26 17\\n26 15\\n8 25\\n8 12\\n8 11\\n10 27\\n10 14\\n6 21\\n5 2\\n5 1\\n5 19\\n5 30\\n7 4\\n13 18\\n3 9\\n3 28\\n3 24\\n3 20\\n29 16\\n29 23\\n29 22\\n\", \"30\\n28 30\\n30 20\\n20 29\\n29 15\\n15 2\\n2 27\\n27 6\\n6 4\\n6 11\\n6 7\\n6 10\\n6 24\\n27 14\\n27 5\\n27 22\\n2 16\\n15 13\\n15 9\\n15 25\\n29 1\\n29 3\\n29 12\\n29 26\\n30 8\\n30 18\\n30 23\\n30 17\\n30 19\\n28 21\\n\", \"2\\n2 1\\n\", \"3\\n1 2\\n2 3\\n\", \"4\\n2 1\\n1 3\\n3 4\\n\", \"5\\n2 4\\n4 1\\n1 3\\n3 5\\n\", \"6\\n3 4\\n4 1\\n1 5\\n5 2\\n2 6\\n\", \"7\\n5 4\\n4 7\\n7 1\\n1 2\\n2 3\\n3 6\\n\", \"8\\n5 6\\n6 8\\n8 2\\n2 7\\n7 1\\n1 4\\n4 3\\n\", \"9\\n7 1\\n1 4\\n4 5\\n5 6\\n6 2\\n2 8\\n8 3\\n3 9\\n\", \"3\\n2 1\\n3 1\\n\", \"4\\n2 1\\n1 3\\n1 4\\n\", \"5\\n5 1\\n1 4\\n1 3\\n2 1\\n\", \"30\\n1 15\\n15 30\\n30 14\\n14 16\\n16 19\\n19 12\\n19 22\\n19 2\\n16 9\\n16 21\\n16 23\\n16 24\\n14 7\\n14 29\\n14 17\\n14 18\\n30 13\\n30 27\\n30 4\\n30 8\\n15 10\\n15 11\\n15 5\\n15 3\\n15 25\\n1 6\\n1 26\\n1 28\\n1 20\\n\", \"30\\n29 18\\n18 8\\n8 27\\n27 26\\n26 17\\n17 11\\n11 23\\n23 16\\n16 6\\n23 19\\n23 22\\n23 2\\n23 28\\n23 1\\n11 14\\n11 13\\n11 5\\n11 9\\n11 30\\n17 15\\n26 3\\n26 7\\n26 25\\n27 24\\n27 4\\n8 21\\n18 20\\n18 12\\n29 10\\n\", \"30\\n10 15\\n15 17\\n17 14\\n14 7\\n7 3\\n3 27\\n3 25\\n3 21\\n3 5\\n3 9\\n7 11\\n7 18\\n7 26\\n7 16\\n7 4\\n7 8\\n7 23\\n7 2\\n7 29\\n17 12\\n17 30\\n17 13\\n17 24\\n17 20\\n17 28\\n17 22\\n17 1\\n15 6\\n10 19\\n\", \"30\\n8 23\\n23 13\\n13 29\\n29 14\\n13 18\\n13 5\\n13 24\\n13 21\\n13 4\\n13 1\\n13 9\\n13 16\\n13 19\\n23 12\\n23 17\\n23 11\\n23 27\\n23 22\\n23 28\\n23 20\\n8 3\\n8 10\\n8 26\\n8 15\\n8 25\\n8 6\\n8 30\\n8 7\\n8 2\\n\", \"17\\n2 13\\n13 7\\n7 6\\n6 12\\n6 9\\n6 14\\n6 1\\n6 4\\n7 8\\n7 11\\n13 17\\n13 10\\n2 3\\n2 5\\n2 16\\n2 15\\n\", \"20\\n17 18\\n18 13\\n13 6\\n6 3\\n6 2\\n6 14\\n13 20\\n13 15\\n18 11\\n18 7\\n18 19\\n18 9\\n17 5\\n17 4\\n17 12\\n17 10\\n17 16\\n17 1\\n17 8\\n\", \"6\\n2 1\\n1 4\\n4 6\\n4 3\\n1 5\\n\", \"10\\n9 1\\n9 10\\n9 5\\n9 8\\n9 2\\n9 7\\n9 3\\n9 6\\n9 4\\n\", \"15\\n5 2\\n2 7\\n7 3\\n3 9\\n9 15\\n9 12\\n3 10\\n3 11\\n7 1\\n7 6\\n2 13\\n2 8\\n5 14\\n5 4\\n\", \"30\\n7 20\\n20 25\\n25 4\\n4 17\\n17 28\\n4 23\\n4 3\\n4 10\\n25 18\\n25 13\\n25 9\\n25 14\\n25 29\\n25 27\\n25 21\\n25 6\\n20 5\\n20 15\\n20 16\\n20 24\\n20 2\\n7 26\\n7 12\\n7 8\\n7 1\\n7 30\\n7 19\\n7 11\\n7 22\\n\", \"30\\n6 29\\n29 27\\n27 4\\n4 2\\n2 10\\n10 19\\n10 8\\n10 25\\n2 16\\n2 15\\n2 28\\n4 1\\n4 30\\n27 18\\n27 12\\n27 20\\n27 7\\n27 3\\n29 26\\n29 23\\n29 17\\n29 22\\n29 14\\n29 24\\n6 5\\n6 9\\n6 13\\n6 21\\n6 11\\n\", \"19\\n13 3\\n3 10\\n10 19\\n19 14\\n19 16\\n19 17\\n19 2\\n19 11\\n10 7\\n10 6\\n10 18\\n10 12\\n10 15\\n10 8\\n3 9\\n3 5\\n13 1\\n13 4\\n\", \"18\\n12 16\\n16 5\\n5 10\\n10 7\\n10 11\\n5 18\\n5 8\\n5 13\\n5 6\\n5 3\\n5 1\\n16 2\\n16 9\\n12 17\\n12 15\\n12 4\\n12 14\\n\", \"15\\n5 13\\n13 15\\n15 10\\n10 9\\n10 6\\n10 8\\n15 7\\n13 4\\n13 11\\n13 2\\n5 14\\n5 1\\n5 3\\n5 12\\n\", \"4\\n3 2\\n3 4\\n3 1\\n\"], \"outputs\": [\"YES\\n0 0\\n0 1073741824\\n1073741824 0\\n0 1610612736\\n536870912 1073741824\\n1073741824 536870912\\n1610612736 0\\n\", \"NO\\n\", \"YES\\n0 0\\n0 1073741824\\n0 1610612736\\n0 1879048192\\n\", \"NO\\n\", \"YES\\n0 0\\n0 1879048192\\n-268435456 1610612736\\n134217728 1879048192\\n0 1610612736\\n0 1073741824\\n536870912 1073741824\\n-536870912 1073741824\\n0 2013265920\\n268435456 1610612736\\n\", \"YES\\n0 0\\n0 1879048192\\n536870912 1073741824\\n0 2013265920\\n-268435456 1610612736\\n268435456 1610612736\\n0 1073741824\\n0 1610612736\\n\", \"YES\\n0 0\\n1073741824 536870912\\n0 1879048192\\n0 1610612736\\n0 1073741824\\n1073741824 805306368\\n1073741824 939524096\\n1073741824 0\\n0 2013265920\\n0 2080374784\\n\", \"YES\\n0 0\\n134217728 1879048192\\n-536870912 1073741824\\n0 1879048192\\n0 1073741824\\n0 2013265920\\n0 1610612736\\n1073741824 0\\n-268435456 1610612736\\n536870912 1073741824\\n268435456 1610612736\\n0 -1073741824\\n\", \"NO\\n\", \"YES\\n0 0\\n536870912 1606418432\\n536870912 1608515584\\n536870912 1476395008\\n536870912 1543503872\\n603979776 1476395008\\n0 1610612736\\n545259520 1593835520\\n553648128 1577058304\\n570425344 1543503872\\n520093696 1577058304\\n0 1879048192\\n536870912 1602224128\\n503316480 1543503872\\n536870912 1342177280\\n536870912 1593835520\\n0 1073741824\\n536870912 1577058304\\n536870912 1073741824\\n-536870912 1073741824\\n\", \"YES\\n0 0\\n-134217728 1879048192\\n-536870912 1073741824\\n671088640 1342177280\\n536870912 1073741824\\n0 1879048192\\n536870912 1342177280\\n536870912 1593835520\\n0 1610612736\\n-67108864 2013265920\\n0 1073741824\\n0 2080374784\\n603979776 1476395008\\n134217728 1879048192\\n67108864 2013265920\\n536870912 1543503872\\n536870912 1476395008\\n805306368 1073741824\\n536870912 1577058304\\n0 2013265920\\n570425344 1543503872\\n\", \"YES\\n0 0\\n536870912 1073741824\\n536870912 1577058304\\n536870912 1543503872\\n0 1073741824\\n0 2013265920\\n536870912 1342177280\\n402653184 1342177280\\n-536870912 1073741824\\n0 1610612736\\n134217728 1879048192\\n268435456 1610612736\\n805306368 1073741824\\n536870912 1476395008\\n603979776 1476395008\\n0 2080374784\\n-134217728 1879048192\\n671088640 1342177280\\n469762048 1476395008\\n0 1879048192\\n\", \"YES\\n0 0\\n1073741824 939524096\\n0 1073741824\\n1207959552 805306368\\n1073741824 536870912\\n1610612736 0\\n268435456 1610612736\\n0 1879048192\\n0 2013265920\\n1342177280 536870912\\n536870912 1073741824\\n0 -1073741824\\n1073741824 0\\n0 1610612736\\n1073741824 805306368\\n\", \"YES\\n0 0\\n0 1073741824\\n1073741824 0\\n0 -1073741824\\n0 1610612736\\n536870912 1073741824\\n-536870912 1073741824\\n1073741824 536870912\\n1610612736 0\\n1073741824 -536870912\\n536870912 -1073741824\\n0 -1610612736\\n-536870912 -1073741824\\n\", \"YES\\n0 0\\n0 1073741824\\n1073741824 0\\n0 -1073741824\\n-1073741824 0\\n0 1610612736\\n536870912 1073741824\\n-536870912 1073741824\\n1073741824 536870912\\n1610612736 0\\n1073741824 -536870912\\n536870912 -1073741824\\n0 -1610612736\\n-536870912 -1073741824\\n-1073741824 536870912\\n-1073741824 -536870912\\n-1610612736 0\\n-1610612736 268435456\\n-1610612736 -268435456\\n-1879048192 0\\n\", \"YES\\n0 0\\n\", \"YES\\n0 0\\n0 2080374784\\n0 2013265920\\n0 1879048192\\n0 1610612736\\n0 1073741824\\n1073741824 0\\n0 -1073741824\\n1073741824 536870912\\n1073741824 805306368\\n1073741824 939524096\\n1073741824 1006632960\\n1073741824 1040187392\\n536870912 -1073741824\\n536870912 -805306368\\n536870912 -671088640\\n536870912 -603979776\\n536870912 -570425344\\n536870912 -553648128\\n536870912 -545259520\\n\", \"YES\\n0 0\\n0 1073741824\\n1073741824 0\\n0 -1073741824\\n0 1610612736\\n0 1879048192\\n0 2013265920\\n0 2080374784\\n536870912 1073741824\\n536870912 1342177280\\n-536870912 1073741824\\n-536870912 1342177280\\n-536870912 1476395008\\n1073741824 536870912\\n1073741824 805306368\\n1342177280 536870912\\n1342177280 671088640\\n805306368 536870912\\n805306368 671088640\\n536870912 -1073741824\\n536870912 -805306368\\n805306368 -1073741824\\n805306368 -939524096\\n536870912 -1342177280\\n671088640 -1342177280\\n\", \"NO\\n\", \"YES\\n0 0\\n0 1073741824\\n67108864 2013265920\\n536870912 1476395008\\n-268435456 1610612736\\n0 1610612736\\n0 2013265920\\n33554432 2080374784\\n0 2113929216\\n-134217728 1879048192\\n536870912 1342177280\\n-67108864 2013265920\\n536870912 805306368\\n0 1879048192\\n-536870912 1073741824\\n805306368 1073741824\\n0 2080374784\\n671088640 1342177280\\n268435456 1610612736\\n536870912 1073741824\\n134217728 1879048192\\n\", \"YES\\n0 0\\n268435456 1610612736\\n1073741824 0\\n0 1073741824\\n536870912 1073741824\\n0 -1073741824\\n1073741824 805306368\\n1207959552 805306368\\n0 1879048192\\n1073741824 1006632960\\n1610612736 0\\n0 2013265920\\n1342177280 536870912\\n1073741824 536870912\\n1140850688 939524096\\n1073741824 939524096\\n0 1610612736\\n\", \"YES\\n0 0\\n0 1610612736\\n0 2113929216\\n-536870912 1073741824\\n-268435456 1610612736\\n-33554432 2080374784\\n16777216 2113929216\\n268435456 1610612736\\n-67108864 2013265920\\n-134217728 1879048192\\n0 2013265920\\n0 2080374784\\n67108864 2013265920\\n134217728 1879048192\\n0 2130706432\\n536870912 1073741824\\n0 1879048192\\n33554432 2080374784\\n0 1073741824\\n\", \"YES\\n0 0\\n-268435456 1610612736\\n536870912 1342177280\\n268435456 1610612736\\n536870912 805306368\\n134217728 1879048192\\n-536870912 1073741824\\n67108864 2013265920\\n0 1073741824\\n805306368 1073741824\\n0 1610612736\\n-134217728 1879048192\\n0 1879048192\\n671088640 1342177280\\n536870912 1073741824\\n536870912 1476395008\\n0 2013265920\\n0 2080374784\\n\", \"NO\\n\", \"NO\\n\", \"YES\\n0 0\\n0 1073741824\\n\", \"YES\\n0 0\\n0 1073741824\\n0 1610612736\\n\", \"YES\\n0 0\\n0 1073741824\\n1073741824 0\\n1073741824 536870912\\n\", \"YES\\n0 0\\n0 1610612736\\n1073741824 0\\n0 1073741824\\n1073741824 536870912\\n\", \"YES\\n0 0\\n1073741824 536870912\\n0 1610612736\\n0 1073741824\\n1073741824 0\\n1073741824 805306368\\n\", \"YES\\n0 0\\n1073741824 0\\n1073741824 536870912\\n0 1610612736\\n0 1879048192\\n1073741824 805306368\\n0 1073741824\\n\", \"YES\\n0 0\\n0 1610612736\\n1073741824 536870912\\n1073741824 0\\n0 2080374784\\n0 2013265920\\n0 1073741824\\n0 1879048192\\n\", \"YES\\n0 0\\n1073741824 939524096\\n1073741824 1040187392\\n1073741824 0\\n1073741824 536870912\\n1073741824 805306368\\n0 1073741824\\n1073741824 1006632960\\n1073741824 1056964608\\n\", \"YES\\n0 0\\n0 1073741824\\n1073741824 0\\n\", \"YES\\n0 0\\n0 1073741824\\n1073741824 0\\n0 -1073741824\\n\", \"YES\\n0 0\\n-1073741824 0\\n0 -1073741824\\n1073741824 0\\n0 1073741824\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"YES\\n0 0\\n0 1073741824\\n1610612736 0\\n1073741824 0\\n0 -1073741824\\n1073741824 536870912\\n\", \"NO\\n\", \"YES\\n0 0\\n0 1610612736\\n536870912 1073741824\\n134217728 1879048192\\n0 1879048192\\n-536870912 1073741824\\n0 1073741824\\n-268435456 1610612736\\n536870912 1342177280\\n805306368 1073741824\\n536870912 805306368\\n671088640 1342177280\\n268435456 1610612736\\n0 2013265920\\n536870912 1476395008\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"YES\\n0 0\\n0 1610612736\\n0 1073741824\\n536870912 1073741824\\n\"]}", "source": "primeintellect"}
Dasha decided to have a rest after solving the problem. She had been ready to start her favourite activity — origami, but remembered the puzzle that she could not solve. [Image] The tree is a non-oriented connected graph without cycles. In particular, there always are n - 1 edges in a tree with n vertices. The puzzle is to position the vertices at the points of the Cartesian plane with integral coordinates, so that the segments between the vertices connected by edges are parallel to the coordinate axes. Also, the intersection of segments is allowed only at their ends. Distinct vertices should be placed at different points. Help Dasha to find any suitable way to position the tree vertices on the plane. It is guaranteed that if it is possible to position the tree vertices on the plane without violating the condition which is given above, then you can do it by using points with integral coordinates which don't exceed 10^18 in absolute value. -----Input----- The first line contains single integer n (1 ≤ n ≤ 30) — the number of vertices in the tree. Each of next n - 1 lines contains two integers u_{i}, v_{i} (1 ≤ u_{i}, v_{i} ≤ n) that mean that the i-th edge of the tree connects vertices u_{i} and v_{i}. It is guaranteed that the described graph is a tree. -----Output----- If the puzzle doesn't have a solution then in the only line print "NO". Otherwise, the first line should contain "YES". The next n lines should contain the pair of integers x_{i}, y_{i} (|x_{i}|, |y_{i}| ≤ 10^18) — the coordinates of the point which corresponds to the i-th vertex of the tree. If there are several solutions, print any of them. -----Examples----- Input 7 1 2 1 3 2 4 2 5 3 6 3 7 Output YES 0 0 1 0 0 1 2 0 1 -1 -1 1 0 2 Input 6 1 2 2 3 2 4 2 5 2 6 Output NO Input 4 1 2 2 3 3 4 Output YES 3 3 4 3 5 3 6 3 -----Note----- In the first sample one of the possible positions of tree is: [Image] Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0
{"tests": "{\"inputs\": [\"0 1 1 1 1 0\\n\", \"1 1 0 0 1000 1000\\n\", \"1 0 2 0 3 0\\n\", \"3 4 0 0 4 3\\n\", \"-1000000000 1 0 0 1000000000 1\\n\", \"49152 0 0 0 0 81920\\n\", \"1 -1 4 4 2 -3\\n\", \"-2 -2 1 4 -2 0\\n\", \"5 0 4 -2 0 1\\n\", \"-4 -3 2 -1 -3 4\\n\", \"-3 -3 5 2 3 -1\\n\", \"-1000000000 -1000000000 0 0 1000000000 999999999\\n\", \"-1000000000 -1000000000 0 0 1000000000 1000000000\\n\", \"-357531221 381512519 -761132895 -224448284 328888775 -237692564\\n\", \"264193194 -448876521 736684426 -633906160 -328597212 -47935734\\n\", \"419578772 -125025887 169314071 89851312 961404059 21419450\\n\", \"-607353321 -620687860 248029390 477864359 728255275 -264646027\\n\", \"299948862 -648908808 338174789 841279400 -850322448 350263551\\n\", \"48517753 416240699 7672672 272460100 -917845051 199790781\\n\", \"-947393823 -495674431 211535284 -877153626 -522763219 -778236665\\n\", \"-685673792 -488079395 909733355 385950193 -705890324 256550506\\n\", \"-326038504 547872194 49630307 713863100 303770000 -556852524\\n\", \"-706921242 -758563024 -588592101 -443440080 858751713 238854303\\n\", \"-1000000000 -1000000000 0 1000000000 1000000000 -1000000000\\n\", \"1000000000 1000000000 0 -1000000000 -1000000000 1000000000\\n\", \"-999999999 -1000000000 0 0 1000000000 999999999\\n\", \"-1000000000 -999999999 0 0 1000000000 999999999\\n\", \"-1 -1000000000 0 1000000000 1 -1000000000\\n\", \"0 1000000000 1 0 0 -1000000000\\n\", \"0 1000000000 0 0 0 -1000000000\\n\", \"0 1 1 2 2 3\\n\", \"999999999 1000000000 0 0 -1000000000 -999999999\\n\", \"0 0 1 1 2 0\\n\", \"0 0 1 1 2 2\\n\", \"1 1 2 2 3 3\\n\", \"0 2 0 3 0 4\\n\", \"1 1 1 2 1 3\\n\", \"0 0 3 4 3 9\\n\", \"589824 196608 262144 196608 0 0\\n\", \"0 0 1000000000 1 1000000000 -999999999\\n\", \"0 0 2 45 0 90\\n\", \"0 0 0 2 0 1\\n\", \"0 2 4 5 4 0\\n\", \"0 0 2 0 4 0\\n\", \"1 1 3 3 5 5\\n\", \"1 1 2 2 3 1\\n\"], \"outputs\": [\"Yes\\n\", \"No\\n\", \"No\\n\", \"Yes\\n\", \"Yes\\n\", \"No\\n\", \"No\\n\", \"No\\n\", \"No\\n\", \"No\\n\", \"No\\n\", \"No\\n\", \"No\\n\", \"No\\n\", \"No\\n\", \"No\\n\", \"No\\n\", \"No\\n\", \"No\\n\", \"No\\n\", \"No\\n\", \"No\\n\", \"No\\n\", \"Yes\\n\", \"Yes\\n\", \"Yes\\n\", \"No\\n\", \"Yes\\n\", \"Yes\\n\", \"No\\n\", \"No\\n\", \"Yes\\n\", \"Yes\\n\", \"No\\n\", \"No\\n\", \"No\\n\", \"No\\n\", \"Yes\\n\", \"Yes\\n\", \"No\\n\", \"Yes\\n\", \"No\\n\", \"Yes\\n\", \"No\\n\", \"No\\n\", \"Yes\\n\"]}", "source": "primeintellect"}
Arpa is taking a geometry exam. Here is the last problem of the exam. You are given three points a, b, c. Find a point and an angle such that if we rotate the page around the point by the angle, the new position of a is the same as the old position of b, and the new position of b is the same as the old position of c. Arpa is doubting if the problem has a solution or not (i.e. if there exists a point and an angle satisfying the condition). Help Arpa determine if the question has a solution or not. -----Input----- The only line contains six integers a_{x}, a_{y}, b_{x}, b_{y}, c_{x}, c_{y} (|a_{x}|, |a_{y}|, |b_{x}|, |b_{y}|, |c_{x}|, |c_{y}| ≤ 10^9). It's guaranteed that the points are distinct. -----Output----- Print "Yes" if the problem has a solution, "No" otherwise. You can print each letter in any case (upper or lower). -----Examples----- Input 0 1 1 1 1 0 Output Yes Input 1 1 0 0 1000 1000 Output No -----Note----- In the first sample test, rotate the page around (0.5, 0.5) by $90^{\circ}$. In the second sample test, you can't find any solution. Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0.75
{"tests": "{\"inputs\": [\"5\\n1 2 3 4 3\\n1 2 5 4 5\\n\", \"5\\n4 4 2 3 1\\n5 4 5 3 1\\n\", \"4\\n1 1 3 4\\n1 4 3 4\\n\", \"10\\n1 2 3 4 7 6 7 8 9 10\\n1 2 3 4 5 6 5 8 9 10\\n\", \"10\\n1 2 3 4 5 6 7 8 7 10\\n1 2 3 4 5 6 7 8 9 9\\n\", \"10\\n1 2 3 4 5 6 7 8 4 10\\n1 2 3 4 5 6 7 6 9 10\\n\", \"10\\n8 6 1 7 9 3 5 2 10 9\\n8 6 1 7 4 3 5 2 10 4\\n\", \"10\\n2 9 7 7 8 5 4 10 6 1\\n2 8 7 3 8 5 4 10 6 1\\n\", \"2\\n2 2\\n1 1\\n\", \"3\\n1 2 2\\n1 3 3\\n\", \"3\\n2 2 3\\n1 2 1\\n\", \"3\\n1 3 3\\n1 1 3\\n\", \"3\\n2 1 1\\n2 3 3\\n\", \"3\\n3 3 2\\n1 1 2\\n\", \"3\\n1 3 3\\n3 3 2\\n\", \"4\\n3 2 3 4\\n1 2 1 4\\n\", \"4\\n2 2 3 4\\n1 2 3 2\\n\", \"4\\n1 2 4 4\\n2 2 3 4\\n\", \"4\\n4 1 3 4\\n2 1 3 2\\n\", \"4\\n3 2 1 3\\n4 2 1 2\\n\", \"4\\n1 4 1 3\\n2 4 1 4\\n\", \"4\\n1 3 4 4\\n3 3 2 4\\n\", \"5\\n5 4 5 3 1\\n4 4 2 3 1\\n\", \"5\\n4 1 2 4 5\\n3 1 2 5 5\\n\", \"3\\n2 2 3\\n1 3 3\\n\", \"3\\n1 1 3\\n2 3 3\\n\", \"5\\n5 4 5 3 1\\n2 4 4 3 1\\n\", \"3\\n3 3 1\\n2 1 1\\n\", \"5\\n5 4 3 5 2\\n5 4 1 1 2\\n\", \"6\\n1 2 3 4 2 5\\n1 6 3 4 4 5\\n\", \"4\\n1 3 2 1\\n2 3 2 1\\n\", \"4\\n1 3 3 4\\n1 4 3 4\\n\", \"11\\n1 2 3 4 5 6 7 8 9 10 10\\n1 2 3 4 5 6 7 8 9 10 3\\n\", \"5\\n1 2 3 2 5\\n1 4 3 3 5\\n\", \"5\\n1 2 3 4 3\\n1 2 5 4 2\\n\", \"5\\n1 2 3 4 4\\n1 2 3 4 3\\n\", \"4\\n1 3 1 4\\n1 3 4 4\\n\", \"5\\n2 5 3 2 1\\n4 5 3 3 1\\n\", \"5\\n1 2 3 2 5\\n1 3 3 4 5\\n\", \"5\\n5 2 3 4 5\\n2 2 3 4 5\\n\", \"5\\n5 4 1 1 2\\n5 4 3 5 2\\n\", \"4\\n1 4 3 4\\n1 3 3 4\\n\", \"4\\n1 2 3 1\\n1 2 3 2\\n\", \"5\\n4 5 3 3 1\\n2 5 3 2 1\\n\", \"5\\n1 2 3 5 5\\n1 2 3 4 3\\n\", \"4\\n2 3 3 4\\n2 4 3 4\\n\"], \"outputs\": [\"1 2 5 4 3\\n\", \"5 4 2 3 1\\n\", \"1 2 3 4\\n\", \"1 2 3 4 5 6 7 8 9 10\\n\", \"1 2 3 4 5 6 7 8 9 10\\n\", \"1 2 3 4 5 6 7 8 9 10\\n\", \"8 6 1 7 4 3 5 2 10 9\\n\", \"2 9 7 3 8 5 4 10 6 1\\n\", \"1 2\\n\", \"1 3 2\\n\", \"1 2 3\\n\", \"1 2 3\\n\", \"2 3 1\\n\", \"1 3 2\\n\", \"1 3 2\\n\", \"1 2 3 4\\n\", \"1 2 3 4\\n\", \"1 2 3 4\\n\", \"2 1 3 4\\n\", \"4 2 1 3\\n\", \"2 4 1 3\\n\", \"1 3 2 4\\n\", \"5 4 2 3 1\\n\", \"3 1 2 4 5\\n\", \"1 2 3\\n\", \"2 1 3\\n\", \"2 4 5 3 1\\n\", \"2 3 1\\n\", \"5 4 3 1 2\\n\", \"1 6 3 4 2 5\\n\", \"4 3 2 1\\n\", \"1 2 3 4\\n\", \"1 2 3 4 5 6 7 8 9 10 11\\n\", \"1 4 3 2 5\\n\", \"1 2 5 4 3\\n\", \"1 2 3 4 5\\n\", \"1 3 2 4\\n\", \"4 5 3 2 1\\n\", \"1 2 3 4 5\\n\", \"1 2 3 4 5\\n\", \"5 4 3 1 2\\n\", \"1 2 3 4\\n\", \"1 2 3 4\\n\", \"4 5 3 2 1\\n\", \"1 2 3 4 5\\n\", \"2 1 3 4\\n\"]}", "source": "primeintellect"}
Sengoku still remembers the mysterious "colourful meteoroids" she discovered with Lala-chan when they were little. In particular, one of the nights impressed her deeply, giving her the illusion that all her fancies would be realized. On that night, Sengoku constructed a permutation p_1, p_2, ..., p_{n} of integers from 1 to n inclusive, with each integer representing a colour, wishing for the colours to see in the coming meteor outburst. Two incredible outbursts then arrived, each with n meteorids, colours of which being integer sequences a_1, a_2, ..., a_{n} and b_1, b_2, ..., b_{n} respectively. Meteoroids' colours were also between 1 and n inclusive, and the two sequences were not identical, that is, at least one i (1 ≤ i ≤ n) exists, such that a_{i} ≠ b_{i} holds. Well, she almost had it all — each of the sequences a and b matched exactly n - 1 elements in Sengoku's permutation. In other words, there is exactly one i (1 ≤ i ≤ n) such that a_{i} ≠ p_{i}, and exactly one j (1 ≤ j ≤ n) such that b_{j} ≠ p_{j}. For now, Sengoku is able to recover the actual colour sequences a and b through astronomical records, but her wishes have been long forgotten. You are to reconstruct any possible permutation Sengoku could have had on that night. -----Input----- The first line of input contains a positive integer n (2 ≤ n ≤ 1 000) — the length of Sengoku's permutation, being the length of both meteor outbursts at the same time. The second line contains n space-separated integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ n) — the sequence of colours in the first meteor outburst. The third line contains n space-separated integers b_1, b_2, ..., b_{n} (1 ≤ b_{i} ≤ n) — the sequence of colours in the second meteor outburst. At least one i (1 ≤ i ≤ n) exists, such that a_{i} ≠ b_{i} holds. -----Output----- Output n space-separated integers p_1, p_2, ..., p_{n}, denoting a possible permutation Sengoku could have had. If there are more than one possible answer, output any one of them. Input guarantees that such permutation exists. -----Examples----- Input 5 1 2 3 4 3 1 2 5 4 5 Output 1 2 5 4 3 Input 5 4 4 2 3 1 5 4 5 3 1 Output 5 4 2 3 1 Input 4 1 1 3 4 1 4 3 4 Output 1 2 3 4 -----Note----- In the first sample, both 1, 2, 5, 4, 3 and 1, 2, 3, 4, 5 are acceptable outputs. In the second sample, 5, 4, 2, 3, 1 is the only permutation to satisfy the constraints. Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0
{"tests": "{\"inputs\": [\"3 15\\n\", \"4 67\\n\", \"4 68\\n\", \"3 1\\n\", \"3 180\\n\", \"100000 1\\n\", \"100000 180\\n\", \"100000 42\\n\", \"100000 123\\n\", \"5 1\\n\", \"5 36\\n\", \"5 54\\n\", \"5 55\\n\", \"5 70\\n\", \"5 89\\n\", \"5 90\\n\", \"5 91\\n\", \"5 111\\n\", \"5 126\\n\", \"5 127\\n\", \"5 141\\n\", \"5 162\\n\", \"5 180\\n\", \"6 46\\n\", \"6 33\\n\", \"13 4\\n\", \"23 11\\n\", \"11 119\\n\", \"13 117\\n\", \"18 174\\n\", \"8509 139\\n\", \"29770 76\\n\", \"59115 40\\n\", \"68459 88\\n\", \"85100 129\\n\", \"100000 13\\n\", \"100000 35\\n\", \"100000 49\\n\", \"100000 71\\n\", \"100000 79\\n\", \"100000 101\\n\", \"100000 109\\n\", \"100000 143\\n\", \"100000 148\\n\", \"100000 176\\n\", \"4 16\\n\"], \"outputs\": [\"2 1 3\\n\", \"2 1 3\\n\", \"2 1 4\\n\", \"2 1 3\\n\", \"2 1 3\\n\", \"2 1 558\\n\", \"2 1 100000\\n\", \"2 1 23335\\n\", \"2 1 68335\\n\", \"2 1 3\\n\", \"2 1 3\\n\", \"2 1 3\\n\", \"2 1 4\\n\", \"2 1 4\\n\", \"2 1 4\\n\", \"2 1 4\\n\", \"2 1 5\\n\", \"2 1 5\\n\", \"2 1 5\\n\", \"2 1 5\\n\", \"2 1 5\\n\", \"2 1 5\\n\", \"2 1 5\\n\", \"2 1 4\\n\", \"2 1 3\\n\", \"2 1 3\\n\", \"2 1 3\\n\", \"2 1 9\\n\", \"2 1 10\\n\", \"2 1 18\\n\", \"2 1 6573\\n\", \"2 1 12572\\n\", \"2 1 13139\\n\", \"2 1 33471\\n\", \"2 1 60990\\n\", \"2 1 7224\\n\", \"2 1 19446\\n\", \"2 1 27224\\n\", \"2 1 39446\\n\", \"2 1 43891\\n\", \"2 1 56113\\n\", \"2 1 60558\\n\", \"2 1 79446\\n\", \"2 1 82224\\n\", \"2 1 97780\\n\", \"2 1 3\\n\"]}", "source": "primeintellect"}
On one quiet day all of sudden Mister B decided to draw angle a on his field. Aliens have already visited his field and left many different geometric figures on it. One of the figures is regular convex n-gon (regular convex polygon with n sides). That's why Mister B decided to use this polygon. Now Mister B must find three distinct vertices v_1, v_2, v_3 such that the angle $\angle v_{1} v_{2} v_{3}$ (where v_2 is the vertex of the angle, and v_1 and v_3 lie on its sides) is as close as possible to a. In other words, the value $|\angle v_{1} v_{2} v_{3} - a|$ should be minimum possible. If there are many optimal solutions, Mister B should be satisfied with any of them. -----Input----- First and only line contains two space-separated integers n and a (3 ≤ n ≤ 10^5, 1 ≤ a ≤ 180) — the number of vertices in the polygon and the needed angle, in degrees. -----Output----- Print three space-separated integers: the vertices v_1, v_2, v_3, which form $\angle v_{1} v_{2} v_{3}$. If there are multiple optimal solutions, print any of them. The vertices are numbered from 1 to n in clockwise order. -----Examples----- Input 3 15 Output 1 2 3 Input 4 67 Output 2 1 3 Input 4 68 Output 4 1 2 -----Note----- In first sample test vertices of regular triangle can create only angle of 60 degrees, that's why every possible angle is correct. Vertices of square can create 45 or 90 degrees angles only. That's why in second sample test the angle of 45 degrees was chosen, since |45 - 67| < |90 - 67|. Other correct answers are: "3 1 2", "3 2 4", "4 2 3", "4 3 1", "1 3 4", "1 4 2", "2 4 1", "4 1 3", "3 1 4", "3 4 2", "2 4 3", "2 3 1", "1 3 2", "1 2 4", "4 2 1". In third sample test, on the contrary, the angle of 90 degrees was chosen, since |90 - 68| < |45 - 68|. Other correct answers are: "2 1 4", "3 2 1", "1 2 3", "4 3 2", "2 3 4", "1 4 3", "3 4 1". Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0
{"tests": "{\"inputs\": [\"3\\n1 -1\\n-1 4\\n-1 6\\n\", \"2\\n1 4\\n2 3\\n\", \"2\\n4 1\\n2 4\\n\", \"2\\n3 -1\\n-1 2\\n\", \"6\\n6 10\\n5 9\\n1 2\\n11 12\\n4 8\\n3 7\\n\", \"1\\n1 2\\n\", \"98\\n17 49\\n139 171\\n-1 114\\n147 179\\n26 58\\n-1 50\\n11 43\\n1 2\\n74 106\\n134 166\\n157 189\\n67 99\\n33 -1\\n155 187\\n25 57\\n156 -1\\n21 53\\n-1 126\\n98 130\\n6 38\\n153 185\\n8 40\\n81 113\\n69 101\\n84 116\\n150 182\\n89 121\\n34 66\\n154 186\\n32 64\\n95 127\\n162 194\\n-1 119\\n16 48\\n19 51\\n76 108\\n-1 45\\n75 107\\n79 111\\n149 181\\n161 -1\\n-1 104\\n3 35\\n93 125\\n22 -1\\n77 109\\n151 -1\\n85 -1\\n195 196\\n20 52\\n68 100\\n152 184\\n31 63\\n158 190\\n132 164\\n-1 180\\n160 192\\n140 172\\n78 110\\n-1 62\\n86 118\\n133 165\\n131 163\\n71 103\\n7 39\\n135 167\\n146 -1\\n27 59\\n5 37\\n15 47\\n4 36\\n12 44\\n97 129\\n137 -1\\n29 -1\\n143 175\\n136 168\\n159 191\\n91 123\\n24 56\\n88 120\\n145 177\\n14 46\\n96 128\\n90 122\\n144 176\\n92 124\\n28 60\\n138 170\\n142 174\\n70 102\\n23 55\\n10 42\\n9 41\\n73 105\\n-1 112\\n141 173\\n83 115\\n\", \"93\\n95 -1\\n137 140\\n144 147\\n81 84\\n131 133\\n9 -1\\n53 55\\n160 167\\n-1 111\\n92 99\\n32 39\\n58 -1\\n125 130\\n93 100\\n13 14\\n7 10\\n71 74\\n-1 114\\n158 165\\n143 146\\n28 35\\n172 175\\n145 148\\n151 153\\n118 120\\n132 134\\n155 162\\n60 65\\n156 163\\n17 20\\n15 18\\n24 26\\n149 150\\n8 11\\n61 66\\n31 38\\n43 46\\n182 184\\n68 70\\n107 110\\n-1 -1\\n44 47\\n79 82\\n-1 37\\n23 25\\n141 142\\n41 42\\n51 52\\n169 170\\n123 128\\n33 40\\n157 164\\n87 89\\n109 112\\n72 75\\n73 76\\n173 176\\n77 78\\n-1 6\\n171 174\\n88 90\\n49 50\\n1 2\\n-1 126\\n122 127\\n45 48\\n105 106\\n16 -1\\n96 103\\n-1 168\\n-1 34\\n91 -1\\n97 104\\n135 138\\n185 186\\n177 178\\n-1 83\\n57 62\\n159 166\\n115 116\\n179 180\\n67 69\\n3 5\\n117 119\\n136 139\\n-1 56\\n85 86\\n94 101\\n124 129\\n152 154\\n-1 36\\n59 64\\n21 22\\n\", \"98\\n-1 164\\n138 170\\n-1 55\\n-1 188\\n5 37\\n81 -1\\n11 43\\n142 174\\n146 178\\n-1 181\\n-1 173\\n93 125\\n152 -1\\n137 169\\n158 190\\n98 130\\n144 176\\n-1 -1\\n85 117\\n160 192\\n94 -1\\n-1 101\\n30 62\\n139 171\\n91 123\\n16 48\\n25 57\\n-1 59\\n97 129\\n74 106\\n31 63\\n19 51\\n-1 109\\n29 61\\n140 172\\n32 -1\\n-1 165\\n82 114\\n-1 56\\n131 163\\n95 127\\n22 54\\n20 52\\n145 177\\n70 -1\\n7 39\\n136 -1\\n67 99\\n3 35\\n12 -1\\n155 -1\\n143 -1\\n13 45\\n89 121\\n90 122\\n26 58\\n151 183\\n92 124\\n153 185\\n84 116\\n-1 186\\n148 180\\n161 193\\n-1 105\\n72 104\\n-1 103\\n134 166\\n-1 60\\n33 -1\\n18 50\\n157 189\\n83 115\\n162 194\\n-1 191\\n76 108\\n147 179\\n68 -1\\n88 120\\n79 111\\n9 41\\n87 119\\n86 -1\\n80 -1\\n-1 46\\n195 196\\n10 -1\\n96 128\\n78 -1\\n4 36\\n17 49\\n150 182\\n135 167\\n-1 53\\n15 47\\n1 2\\n8 40\\n-1 -1\\n6 38\\n\", \"90\\n-1 123\\n-1 166\\n101 102\\n-1 19\\n78 82\\n-1 168\\n69 -1\\n23 -1\\n77 81\\n85 -1\\n161 162\\n-1 65\\n21 22\\n31 32\\n-1 -1\\n1 2\\n89 93\\n95 96\\n154 -1\\n48 60\\n-1 104\\n-1 -1\\n25 -1\\n-1 -1\\n-1 84\\n107 119\\n99 100\\n-1 83\\n115 -1\\n67 -1\\n151 -1\\n-1 -1\\n175 180\\n26 30\\n134 -1\\n16 20\\n169 170\\n37 -1\\n-1 -1\\n-1 140\\n97 98\\n45 57\\n143 147\\n-1 120\\n-1 139\\n90 94\\n-1 59\\n-1 -1\\n73 -1\\n-1 128\\n24 -1\\n-1 -1\\n174 -1\\n39 -1\\n51 63\\n13 17\\n131 132\\n113 125\\n-1 42\\n-1 -1\\n54 66\\n-1 135\\n9 11\\n117 129\\n-1 -1\\n33 34\\n105 -1\\n159 160\\n-1 150\\n50 62\\n114 126\\n70 72\\n118 -1\\n173 178\\n112 -1\\n-1 58\\n-1 -1\\n171 -1\\n43 55\\n74 -1\\n141 145\\n-1 18\\n10 -1\\n49 -1\\n35 -1\\n-1 -1\\n142 -1\\n3 4\\n5 -1\\n52 64\\n\", \"94\\n145 146\\n59 64\\n101 103\\n79 80\\n17 18\\n25 26\\n62 67\\n179 -1\\n44 -1\\n117 118\\n161 163\\n124 129\\n127 132\\n165 167\\n185 186\\n97 99\\n41 46\\n2 4\\n45 50\\n-1 86\\n105 110\\n-1 184\\n42 47\\n119 120\\n27 30\\n123 128\\n69 72\\n173 178\\n19 20\\n61 66\\n157 160\\n-1 122\\n5 8\\n139 140\\n170 -1\\n-1 24\\n6 9\\n87 88\\n21 22\\n155 158\\n107 112\\n141 -1\\n29 32\\n71 74\\n7 -1\\n135 138\\n75 76\\n28 31\\n15 16\\n156 159\\n60 -1\\n51 52\\n169 174\\n81 82\\n147 -1\\n166 168\\n153 154\\n-1 40\\n92 95\\n108 113\\n172 177\\n171 -1\\n149 150\\n53 54\\n133 136\\n91 94\\n-1 58\\n34 36\\n102 104\\n1 3\\n143 144\\n-1 137\\n115 -1\\n43 -1\\n13 14\\n162 164\\n106 111\\n77 78\\n83 84\\n63 68\\n151 152\\n187 188\\n181 182\\n-1 35\\n11 12\\n125 -1\\n70 73\\n-1 100\\n93 96\\n109 114\\n126 131\\n37 39\\n89 90\\n55 56\\n\", \"94\\n50 52\\n159 160\\n187 188\\n-1 45\\n124 128\\n80 82\\n97 100\\n59 63\\n162 -1\\n-1 90\\n-1 140\\n131 -1\\n83 84\\n53 -1\\n182 184\\n21 22\\n147 148\\n98 101\\n167 169\\n61 65\\n57 58\\n172 174\\n67 69\\n15 17\\n132 134\\n33 36\\n-1 180\\n117 119\\n141 -1\\n47 48\\n108 110\\n29 30\\n87 88\\n44 46\\n99 102\\n35 -1\\n19 20\\n114 -1\\n-1 32\\n161 164\\n72 -1\\n149 150\\n75 76\\n16 18\\n13 14\\n4 6\\n-1 129\\n23 24\\n-1 -1\\n-1 37\\n111 -1\\n-1 127\\n143 -1\\n1 2\\n175 176\\n157 158\\n79 81\\n177 179\\n3 -1\\n11 12\\n151 152\\n126 130\\n25 -1\\n155 156\\n-1 86\\n49 51\\n93 94\\n181 183\\n171 -1\\n54 56\\n68 70\\n107 109\\n-1 120\\n-1 166\\n95 96\\n8 10\\n40 -1\\n91 92\\n27 28\\n-1 64\\n71 73\\n103 105\\n113 115\\n62 -1\\n135 137\\n121 122\\n-1 186\\n168 170\\n39 41\\n77 78\\n-1 106\\n7 9\\n144 146\\n153 154\\n\", \"94\\n111 -1\\n12 -1\\n125 129\\n21 22\\n73 74\\n27 28\\n9 10\\n166 -1\\n121 -1\\n-1 79\\n-1 106\\n97 105\\n-1 89\\n61 65\\n-1 -1\\n187 188\\n23 -1\\n-1 -1\\n175 178\\n135 136\\n76 80\\n101 109\\n164 -1\\n160 168\\n113 116\\n133 134\\n147 -1\\n85 86\\n96 104\\n157 158\\n137 -1\\n-1 153\\n48 -1\\n5 6\\n-1 50\\n102 -1\\n38 46\\n100 108\\n141 -1\\n93 94\\n32 40\\n53 55\\n91 92\\n-1 184\\n78 82\\n124 -1\\n152 154\\n62 -1\\n176 179\\n131 132\\n14 18\\n-1 -1\\n67 68\\n83 84\\n60 -1\\n11 15\\n99 107\\n71 72\\n162 170\\n49 52\\n185 -1\\n77 81\\n181 183\\n19 20\\n177 180\\n1 2\\n-1 41\\n-1 45\\n95 103\\n24 26\\n35 43\\n-1 119\\n123 127\\n13 17\\n-1 120\\n59 -1\\n165 173\\n-1 -1\\n88 90\\n139 -1\\n159 167\\n54 56\\n149 150\\n155 156\\n126 130\\n29 -1\\n57 58\\n112 115\\n161 -1\\n140 144\\n7 8\\n-1 39\\n69 70\\n142 146\\n\", \"99\\n14 46\\n-1 -1\\n131 -1\\n-1 63\\n152 184\\n135 -1\\n-1 102\\n-1 -1\\n30 62\\n-1 194\\n-1 -1\\n-1 2\\n-1 -1\\n17 -1\\n146 -1\\n-1 -1\\n-1 114\\n12 44\\n-1 -1\\n67 99\\n-1 -1\\n5 -1\\n160 192\\n-1 36\\n84 -1\\n132 164\\n153 -1\\n-1 60\\n71 103\\n-1 -1\\n74 -1\\n93 125\\n-1 -1\\n-1 -1\\n-1 121\\n139 -1\\n-1 42\\n-1 -1\\n-1 -1\\n25 -1\\n-1 129\\n78 110\\n-1 188\\n-1 -1\\n-1 -1\\n-1 190\\n11 -1\\n69 -1\\n136 168\\n79 111\\n-1 193\\n154 -1\\n-1 104\\n27 -1\\n150 182\\n-1 -1\\n83 -1\\n-1 180\\n-1 -1\\n145 177\\n-1 -1\\n138 -1\\n195 197\\n16 -1\\n-1 -1\\n3 35\\n133 165\\n-1 -1\\n157 189\\n21 53\\n73 105\\n-1 55\\n80 -1\\n-1 -1\\n-1 119\\n149 181\\n22 -1\\n32 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n134 166\\n34 -1\\n8 40\\n-1 51\\n95 127\\n26 -1\\n-1 107\\n151 183\\n92 124\\n81 -1\\n-1 -1\\n33 65\\n86 118\\n-1 -1\\n91 -1\\n-1 -1\\n-1 128\\n196 198\\n\", \"94\\n-1 184\\n-1 144\\n174 176\\n98 100\\n52 -1\\n-1 73\\n101 104\\n6 10\\n78 81\\n45 47\\n182 187\\n122 130\\n19 20\\n171 172\\n142 145\\n85 89\\n-1 94\\n97 99\\n54 62\\n29 30\\n87 91\\n-1 170\\n162 -1\\n15 18\\n121 129\\n-1 178\\n86 90\\n3 4\\n72 76\\n136 140\\n-1 27\\n22 26\\n70 74\\n102 105\\n37 40\\n103 106\\n149 153\\n157 158\\n161 163\\n95 96\\n88 92\\n57 65\\n134 -1\\n181 186\\n-1 125\\n173 175\\n79 82\\n107 -1\\n-1 75\\n33 35\\n133 137\\n115 123\\n180 185\\n-1 32\\n118 126\\n110 112\\n38 -1\\n159 160\\n83 -1\\n152 156\\n43 44\\n135 -1\\n151 155\\n166 169\\n77 80\\n109 111\\n-1 -1\\n116 124\\n55 63\\n113 114\\n131 132\\n-1 148\\n21 25\\n58 66\\n120 128\\n13 -1\\n165 168\\n119 127\\n5 9\\n34 -1\\n143 -1\\n67 -1\\n14 17\\n39 42\\n-1 64\\n7 11\\n-1 50\\n8 12\\n150 154\\n183 -1\\n1 2\\n-1 -1\\n46 48\\n-1 28\\n\", \"98\\n-1 179\\n74 172\\n36 -1\\n-1 100\\n54 152\\n68 166\\n22 120\\n27 125\\n-1 189\\n35 -1\\n51 149\\n84 182\\n48 146\\n14 112\\n66 164\\n-1 193\\n49 147\\n6 104\\n73 171\\n-1 121\\n76 174\\n56 154\\n77 -1\\n83 181\\n96 -1\\n92 190\\n-1 178\\n-1 177\\n85 -1\\n63 161\\n1 99\\n67 165\\n97 -1\\n62 160\\n64 162\\n-1 116\\n-1 140\\n-1 -1\\n16 114\\n98 196\\n37 135\\n87 -1\\n-1 105\\n90 188\\n61 159\\n33 131\\n26 124\\n65 163\\n28 126\\n40 138\\n-1 107\\n47 -1\\n93 191\\n39 137\\n94 192\\n44 142\\n12 110\\n8 106\\n11 109\\n78 176\\n17 115\\n38 136\\n89 187\\n5 103\\n46 144\\n15 113\\n19 117\\n-1 -1\\n30 -1\\n20 118\\n21 -1\\n59 157\\n72 170\\n41 139\\n52 150\\n70 168\\n75 173\\n25 123\\n29 127\\n4 102\\n45 143\\n50 148\\n13 -1\\n43 141\\n53 151\\n-1 155\\n86 184\\n88 186\\n82 180\\n34 132\\n58 156\\n60 158\\n3 -1\\n-1 -1\\n31 129\\n71 169\\n24 122\\n32 130\\n\", \"94\\n147 148\\n33 39\\n135 137\\n118 120\\n112 116\\n75 79\\n86 88\\n140 144\\n-1 51\\n174 178\\n141 145\\n48 52\\n95 96\\n-1 -1\\n110 114\\n29 30\\n182 184\\n37 43\\n-1 170\\n-1 132\\n7 9\\n77 81\\n142 146\\n100 106\\n-1 179\\n123 129\\n59 65\\n-1 172\\n101 107\\n19 -1\\n-1 87\\n187 -1\\n124 130\\n31 32\\n-1 42\\n12 16\\n-1 18\\n1 4\\n3 6\\n21 23\\n91 92\\n63 69\\n173 177\\n83 84\\n62 68\\n153 154\\n46 50\\n155 -1\\n165 171\\n149 151\\n99 105\\n-1 103\\n181 183\\n8 10\\n139 143\\n35 41\\n-1 66\\n93 94\\n163 169\\n162 168\\n57 58\\n78 82\\n11 15\\n61 67\\n22 24\\n117 119\\n98 104\\n157 -1\\n72 74\\n176 180\\n128 134\\n109 113\\n45 49\\n161 167\\n89 90\\n25 26\\n38 44\\n121 122\\n127 133\\n13 17\\n136 138\\n159 -1\\n53 -1\\n102 108\\n185 186\\n111 115\\n54 56\\n27 28\\n64 70\\n2 5\\n34 40\\n76 -1\\n71 73\\n150 152\\n\", \"96\\n168 174\\n113 -1\\n51 54\\n106 -1\\n127 129\\n64 66\\n-1 46\\n83 88\\n143 -1\\n137 -1\\n141 144\\n42 48\\n1 2\\n53 56\\n-1 155\\n49 -1\\n122 -1\\n-1 -1\\n4 7\\n169 175\\n38 44\\n-1 45\\n166 -1\\n-1 32\\n-1 89\\n9 10\\n86 91\\n-1 136\\n-1 27\\n-1 76\\n87 92\\n67 70\\n161 162\\n142 -1\\n-1 24\\n-1 -1\\n57 59\\n3 6\\n-1 107\\n41 47\\n99 100\\n-1 43\\n103 109\\n105 -1\\n-1 62\\n33 34\\n-1 -1\\n148 -1\\n125 126\\n77 80\\n85 90\\n-1 154\\n-1 171\\n-1 12\\n147 152\\n-1 72\\n170 176\\n102 108\\n68 -1\\n63 65\\n181 184\\n23 28\\n97 98\\n73 74\\n14 17\\n115 118\\n180 183\\n-1 120\\n167 -1\\n5 -1\\n78 81\\n58 60\\n151 156\\n158 160\\n79 82\\n-1 134\\n94 -1\\n104 110\\n116 119\\n-1 18\\n20 25\\n128 -1\\n177 178\\n-1 -1\\n157 159\\n52 55\\n139 140\\n35 -1\\n29 31\\n179 182\\n-1 -1\\n21 26\\n-1 192\\n13 -1\\n186 188\\n189 190\\n\", \"100\\n159 189\\n1 2\\n36 66\\n99 129\\n137 167\\n147 177\\n11 41\\n163 193\\n151 -1\\n145 175\\n24 54\\n17 47\\n26 -1\\n14 44\\n-1 -1\\n28 58\\n142 172\\n155 185\\n12 -1\\n73 103\\n3 5\\n195 197\\n33 63\\n161 191\\n74 104\\n160 -1\\n131 133\\n-1 169\\n162 192\\n15 45\\n30 60\\n78 108\\n149 179\\n-1 39\\n68 70\\n156 186\\n67 69\\n96 126\\n-1 130\\n83 113\\n-1 116\\n138 168\\n16 46\\n-1 49\\n76 106\\n35 65\\n199 200\\n141 171\\n140 170\\n79 -1\\n132 134\\n88 118\\n77 107\\n82 112\\n13 43\\n90 120\\n72 102\\n4 6\\n91 121\\n143 173\\n135 165\\n93 -1\\n32 62\\n92 122\\n27 57\\n34 64\\n144 174\\n25 55\\n23 53\\n-1 198\\n84 114\\n95 125\\n71 101\\n152 182\\n136 166\\n158 188\\n75 105\\n153 183\\n94 124\\n80 -1\\n-1 -1\\n85 115\\n89 119\\n20 -1\\n8 38\\n-1 -1\\n148 178\\n87 117\\n164 194\\n-1 187\\n150 180\\n154 184\\n29 59\\n31 61\\n18 48\\n22 52\\n97 127\\n98 128\\n81 111\\n21 51\\n\", \"90\\n151 152\\n57 -1\\n-1 -1\\n135 136\\n51 62\\n32 36\\n7 8\\n139 141\\n177 -1\\n42 48\\n114 -1\\n157 161\\n165 171\\n166 172\\n37 43\\n9 10\\n83 86\\n123 134\\n29 33\\n49 60\\n79 80\\n-1 20\\n168 -1\\n25 27\\n145 148\\n95 99\\n-1 129\\n1 4\\n52 63\\n147 150\\n82 85\\n-1 124\\n39 45\\n31 -1\\n54 65\\n159 163\\n146 149\\n26 28\\n160 164\\n96 100\\n153 -1\\n58 69\\n94 -1\\n103 109\\n170 176\\n116 127\\n106 112\\n12 14\\n87 88\\n41 -1\\n115 126\\n76 78\\n105 111\\n11 13\\n73 74\\n158 162\\n-1 108\\n53 64\\n59 70\\n56 67\\n154 156\\n15 16\\n71 72\\n40 46\\n117 128\\n18 21\\n75 77\\n104 110\\n120 131\\n-1 133\\n119 130\\n19 22\\n169 175\\n121 132\\n2 5\\n93 97\\n89 91\\n50 61\\n143 -1\\n38 44\\n55 66\\n30 34\\n90 92\\n81 -1\\n137 138\\n167 173\\n178 180\\n101 -1\\n3 6\\n23 24\\n\", \"92\\n29 -1\\n8 12\\n59 66\\n179 182\\n79 83\\n125 132\\n37 40\\n85 86\\n49 52\\n113 116\\n21 22\\n149 150\\n-1 34\\n-1 98\\n2 4\\n36 -1\\n16 20\\n56 63\\n159 160\\n120 127\\n144 -1\\n154 156\\n80 84\\n109 111\\n157 158\\n46 48\\n174 176\\n93 94\\n26 28\\n169 170\\n141 145\\n35 38\\n90 92\\n99 102\\n178 181\\n122 129\\n55 62\\n105 -1\\n136 140\\n23 24\\n121 128\\n107 108\\n77 81\\n124 131\\n72 76\\n-1 166\\n-1 64\\n5 9\\n-1 75\\n45 47\\n173 175\\n89 91\\n-1 117\\n134 138\\n177 180\\n43 44\\n78 82\\n101 104\\n14 -1\\n183 184\\n31 32\\n13 17\\n87 88\\n50 53\\n6 10\\n165 168\\n15 19\\n51 54\\n119 -1\\n110 112\\n133 137\\n142 146\\n61 68\\n143 147\\n135 139\\n7 11\\n100 -1\\n25 27\\n41 -1\\n58 65\\n123 -1\\n153 155\\n1 3\\n115 118\\n161 162\\n60 67\\n95 96\\n151 152\\n-1 172\\n-1 73\\n164 167\\n70 74\\n\", \"91\\n-1 177\\n46 -1\\n10 -1\\n57 -1\\n35 36\\n118 -1\\n-1 16\\n-1 -1\\n76 85\\n138 -1\\n-1 -1\\n121 -1\\n157 -1\\n-1 -1\\n-1 89\\n134 -1\\n-1 153\\n-1 154\\n-1 104\\n131 132\\n-1 -1\\n158 162\\n-1 -1\\n-1 33\\n156 -1\\n-1 -1\\n165 166\\n-1 108\\n181 -1\\n-1 171\\n136 -1\\n163 164\\n39 40\\n155 159\\n-1 150\\n37 38\\n-1 52\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 90\\n-1 -1\\n45 49\\n-1 82\\n-1 -1\\n-1 68\\n8 17\\n174 178\\n-1 -1\\n-1 -1\\n167 168\\n-1 61\\n-1 -1\\n-1 -1\\n47 51\\n-1 60\\n119 126\\n-1 26\\n71 80\\n59 -1\\n9 18\\n120 -1\\n-1 -1\\n69 78\\n-1 -1\\n139 -1\\n72 -1\\n-1 100\\n-1 124\\n-1 142\\n-1 44\\n58 65\\n27 31\\n-1 83\\n-1 -1\\n77 86\\n122 129\\n3 4\\n-1 22\\n135 144\\n105 -1\\n-1 113\\n110 114\\n112 -1\\n-1 97\\n-1 -1\\n-1 -1\\n-1 179\\n12 21\\n-1 -1\\n170 172\\n\", \"97\\n-1 12\\n119 -1\\n-1 -1\\n151 -1\\n-1 156\\n177 -1\\n55 56\\n-1 128\\n73 -1\\n45 -1\\n-1 174\\n-1 -1\\n-1 -1\\n121 122\\n-1 72\\n-1 192\\n167 -1\\n-1 -1\\n169 170\\n85 86\\n-1 -1\\n-1 -1\\n115 -1\\n43 -1\\n145 -1\\n-1 114\\n-1 20\\n35 36\\n-1 -1\\n61 62\\n137 138\\n-1 76\\n41 -1\\n-1 -1\\n23 24\\n87 -1\\n-1 32\\n65 -1\\n-1 92\\n-1 -1\\n-1 110\\n-1 -1\\n-1 -1\\n-1 34\\n-1 154\\n-1 126\\n-1 -1\\n79 -1\\n97 -1\\n-1 -1\\n25 -1\\n53 -1\\n-1 -1\\n-1 144\\n131 -1\\n-1 4\\n59 60\\n105 106\\n-1 -1\\n-1 -1\\n179 -1\\n-1 194\\n-1 48\\n163 -1\\n-1 64\\n-1 -1\\n-1 -1\\n-1 -1\\n123 -1\\n-1 28\\n139 140\\n-1 -1\\n-1 -1\\n-1 18\\n-1 -1\\n187 188\\n99 -1\\n141 142\\n161 162\\n57 58\\n147 148\\n-1 102\\n-1 70\\n21 -1\\n-1 -1\\n-1 -1\\n51 -1\\n-1 -1\\n111 112\\n-1 -1\\n81 -1\\n-1 -1\\n1 2\\n83 -1\\n-1 -1\\n-1 -1\\n107 108\\n\", \"1\\n1 2\\n\", \"100\\n65 165\\n6 106\\n41 141\\n1 101\\n4 104\\n33 133\\n5 105\\n57 157\\n98 198\\n15 115\\n52 152\\n53 153\\n46 146\\n29 129\\n42 142\\n8 108\\n12 112\\n69 169\\n47 147\\n87 187\\n79 179\\n88 188\\n67 167\\n26 126\\n55 155\\n73 173\\n72 172\\n74 174\\n95 195\\n36 136\\n61 161\\n10 110\\n17 117\\n7 107\\n23 123\\n30 130\\n14 114\\n90 190\\n66 166\\n99 199\\n94 194\\n91 191\\n82 182\\n62 162\\n81 181\\n44 144\\n51 151\\n78 178\\n11 111\\n43 143\\n50 150\\n19 119\\n83 183\\n49 149\\n80 180\\n54 154\\n18 118\\n21 121\\n75 175\\n34 134\\n77 177\\n31 131\\n28 128\\n68 168\\n84 184\\n92 192\\n22 122\\n60 160\\n24 124\\n38 138\\n93 193\\n13 113\\n9 109\\n100 200\\n58 158\\n45 145\\n97 197\\n63 163\\n89 189\\n16 116\\n56 156\\n37 137\\n20 120\\n48 148\\n39 139\\n96 196\\n71 171\\n32 132\\n64 164\\n2 102\\n70 170\\n35 135\\n3 103\\n59 159\\n76 176\\n25 125\\n40 140\\n86 186\\n85 185\\n27 127\\n\", \"100\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n\", \"55\\n92 93\\n49 -1\\n34 -1\\n-1 89\\n25 -1\\n-1 99\\n33 -1\\n-1 -1\\n106 107\\n104 105\\n1 2\\n41 98\\n15 16\\n42 61\\n-1 60\\n-1 -1\\n-1 67\\n-1 64\\n-1 72\\n43 -1\\n62 65\\n84 85\\n70 97\\n12 13\\n31 100\\n-1 -1\\n-1 81\\n-1 78\\n82 91\\n101 102\\n-1 -1\\n17 110\\n94 -1\\n-1 -1\\n44 55\\n-1 21\\n-1 36\\n-1 53\\n46 47\\n-1 27\\n-1 90\\n-1 -1\\n-1 59\\n4 5\\n6 7\\n87 88\\n3 8\\n68 -1\\n32 39\\n-1 -1\\n45 54\\n-1 109\\n23 -1\\n76 77\\n-1 -1\\n\", \"74\\n80 -1\\n43 46\\n-1 66\\n10 -1\\n109 110\\n14 -1\\n121 124\\n-1 126\\n138 141\\n96 97\\n132 -1\\n73 74\\n21 -1\\n-1 135\\n-1 71\\n-1 45\\n54 77\\n-1 88\\n55 -1\\n-1 83\\n130 131\\n34 -1\\n47 -1\\n-1 -1\\n116 125\\n117 -1\\n79 -1\\n99 -1\\n98 103\\n-1 -1\\n100 101\\n-1 58\\n-1 140\\n52 53\\n72 75\\n63 64\\n35 38\\n4 5\\n27 -1\\n145 146\\n2 3\\n-1 142\\n-1 70\\n32 49\\n133 136\\n-1 -1\\n12 111\\n-1 6\\n60 -1\\n78 89\\n-1 -1\\n29 90\\n-1 148\\n17 20\\n30 51\\n143 -1\\n-1 108\\n-1 68\\n62 65\\n-1 -1\\n128 129\\n15 -1\\n118 119\\n7 8\\n26 91\\n94 -1\\n-1 115\\n33 42\\n31 50\\n13 106\\n113 -1\\n-1 37\\n23 104\\n122 123\\n\", \"31\\n3 4\\n-1 -1\\n-1 6\\n23 -1\\n-1 -1\\n39 40\\n9 -1\\n-1 20\\n37 -1\\n-1 27\\n21 -1\\n41 -1\\n-1 -1\\n-1 30\\n51 52\\n1 2\\n58 61\\n55 62\\n47 50\\n36 45\\n-1 -1\\n-1 57\\n25 -1\\n48 49\\n-1 43\\n34 35\\n-1 32\\n-1 54\\n12 17\\n33 46\\n-1 -1\\n\", \"93\\n-1 186\\n89 -1\\n166 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 170\\n-1 -1\\n-1 179\\n-1 -1\\n-1 176\\n-1 112\\n139 98\\n-1 161\\n-1 -1\\n23 -1\\n-1 -1\\n-1 -1\\n-1 129\\n-1 8\\n-1 -1\\n-1 -1\\n-1 46\\n-1 -1\\n-1 -1\\n-1 128\\n140 -1\\n159 66\\n108 107\\n-1 -1\\n-1 74\\n67 128\\n-1 73\\n16 -1\\n-1 170\\n-1 85\\n-1 -1\\n133 -1\\n151 152\\n-1 -1\\n3 -1\\n-1 107\\n111 -1\\n13 17\\n141 -1\\n-1 -1\\n158 186\\n115 33\\n-1 42\\n101 -1\\n-1 -1\\n58 63\\n37 40\\n139 143\\n-1 -1\\n43 144\\n-1 -1\\n147 149\\n52 55\\n175 -1\\n133 134\\n115 -1\\n-1 105\\n-1 170\\n-1 -1\\n57 62\\n43 44\\n78 -1\\n-1 -1\\n59 -1\\n-1 -1\\n103 -1\\n16 35\\n-1 -1\\n-1 54\\n-1 -1\\n159 163\\n-1 120\\n18 14\\n-1 30\\n7 9\\n-1 35\\n-1 125\\n-1 42\\n-1 119\\n-1 -1\\n93 98\\n6 -1\\n185 186\\n-1 88\\n-1 142\\n-1 -1\\n\", \"96\\n134 136\\n3 4\\n49 51\\n163 -1\\n185 188\\n-1 -1\\n-1 34\\n46 48\\n102 106\\n5 7\\n-1 138\\n43 44\\n140 142\\n143 145\\n126 129\\n152 158\\n24 30\\n164 168\\n19 25\\n161 162\\n100 104\\n16 18\\n23 -1\\n147 153\\n-1 90\\n148 154\\n70 -1\\n117 118\\n36 40\\n99 103\\n11 13\\n127 130\\n9 10\\n183 186\\n21 27\\n86 92\\n-1 157\\n171 172\\n76 78\\n-1 122\\n15 17\\n75 -1\\n110 112\\n159 160\\n63 66\\n50 -1\\n80 82\\n55 58\\n131 -1\\n177 179\\n69 71\\n165 169\\n149 155\\n31 -1\\n87 93\\n53 54\\n79 81\\n-1 94\\n45 47\\n113 115\\n190 -1\\n61 64\\n-1 191\\n133 -1\\n-1 -1\\n97 98\\n101 105\\n-1 187\\n150 156\\n62 -1\\n121 124\\n57 60\\n173 175\\n67 68\\n181 182\\n120 123\\n56 59\\n20 26\\n95 96\\n125 128\\n-1 91\\n38 42\\n166 170\\n144 146\\n107 108\\n-1 180\\n174 -1\\n12 -1\\n73 74\\n109 -1\\n6 8\\n-1 89\\n139 141\\n37 41\\n35 39\\n1 2\\n\", \"90\\n142 -1\\n-1 -1\\n109 114\\n150 154\\n41 46\\n85 -1\\n59 51\\n27 23\\n18 -1\\n102 101\\n44 -1\\n-1 -1\\n87 -1\\n172 177\\n-1 90\\n105 -1\\n56 64\\n108 113\\n-1 135\\n29 31\\n143 -1\\n-1 38\\n-1 112\\n98 -1\\n106 111\\n-1 175\\n168 -1\\n-1 180\\n93 -1\\n138 141\\n116 124\\n-1 65\\n55 63\\n21 -1\\n17 -1\\n42 -1\\n22 26\\n84 82\\n-1 -1\\n10 13\\n-1 83\\n-1 -1\\n161 162\\n146 -1\\n115 123\\n94 96\\n69 70\\n119 127\\n30 32\\n-1 -1\\n-1 3\\n39 40\\n45 -1\\n-1 8\\n1 2\\n88 92\\n74 77\\n52 60\\n121 129\\n75 78\\n43 48\\n171 -1\\n54 -1\\n80 79\\n157 159\\n-1 -1\\n-1 53\\n118 -1\\n24 -1\\n131 -1\\n76 73\\n173 178\\n145 147\\n71 72\\n-1 -1\\n-1 -1\\n-1 122\\n149 153\\n-1 35\\n16 -1\\n-1 68\\n169 174\\n99 100\\n-1 133\\n-1 164\\n165 166\\n151 155\\n-1 6\\n103 104\\n-1 156\\n\", \"91\\n18 26\\n97 99\\n114 -1\\n161 163\\n47 -1\\n24 32\\n70 29\\n49 58\\n22 30\\n149 112\\n133 135\\n116 125\\n179 26\\n148 -1\\n-1 176\\n120 176\\n172 26\\n17 25\\n141 109\\n-1 128\\n131 132\\n108 110\\n77 93\\n111 112\\n19 27\\n-1 160\\n-1 39\\n147 160\\n-1 -1\\n169 153\\n21 29\\n82 -1\\n3 36\\n165 -1\\n84 92\\n97 65\\n-1 25\\n165 181\\n143 158\\n53 62\\n137 138\\n-1 168\\n88 96\\n107 109\\n11 176\\n67 -1\\n171 95\\n86 94\\n-1 61\\n162 164\\n134 136\\n-1 -1\\n50 59\\n165 167\\n117 80\\n151 159\\n-1 93\\n-1 -1\\n87 64\\n152 124\\n-1 68\\n23 29\\n13 14\\n20 -1\\n43 45\\n150 158\\n1 2\\n9 10\\n-1 89\\n118 127\\n121 130\\n117 -1\\n75 76\\n-1 91\\n148 156\\n51 60\\n20 -1\\n171 -1\\n47 48\\n152 26\\n113 122\\n-1 40\\n-1 42\\n117 104\\n33 60\\n117 -1\\n175 176\\n105 106\\n34 36\\n44 46\\n20 28\\n\", \"95\\n181 182\\n18 17\\n183 50\\n94 -1\\n4 182\\n-1 163\\n108 110\\n69 72\\n88 86\\n57 58\\n150 35\\n123 127\\n-1 38\\n126 -1\\n-1 105\\n150 2\\n16 -1\\n96 90\\n143 144\\n187 189\\n115 43\\n85 87\\n84 83\\n53 54\\n188 190\\n14 13\\n186 185\\n124 -1\\n103 106\\n81 82\\n3 6\\n124 128\\n139 140\\n-1 164\\n-1 35\\n-1 128\\n92 98\\n115 116\\n112 74\\n39 176\\n89 -1\\n78 -1\\n184 183\\n-1 174\\n19 20\\n176 -1\\n37 40\\n104 54\\n117 118\\n121 97\\n12 11\\n107 109\\n155 -1\\n9 -1\\n68 71\\n-1 13\\n-1 80\\n-1 153\\n59 -1\\n-1 112\\n150 145\\n149 -1\\n61 65\\n64 60\\n137 -1\\n131 23\\n154 160\\n47 -1\\n75 129\\n126 162\\n-1 177\\n171 173\\n26 32\\n-1 125\\n-1 120\\n115 141\\n133 74\\n153 121\\n131 -1\\n44 97\\n132 -1\\n-1 -1\\n68 33\\n-1 -1\\n39 129\\n179 180\\n62 66\\n150 -1\\n94 125\\n28 34\\n56 35\\n147 148\\n5 8\\n47 49\\n51 38\\n\", \"93\\n-1 100\\n-1 36\\n-1 -1\\n64 72\\n146 -1\\n-1 84\\n37 -1\\n4 8\\n57 65\\n-1 142\\n39 -1\\n-1 75\\n48 53\\n167 171\\n121 -1\\n-1 108\\n29 30\\n47 -1\\n31 34\\n-1 170\\n96 99\\n128 -1\\n113 118\\n93 94\\n174 179\\n-1 98\\n176 181\\n38 42\\n173 178\\n59 67\\n61 69\\n62 70\\n-1 -1\\n13 -1\\n160 163\\n165 -1\\n63 71\\n111 116\\n-1 135\\n152 -1\\n-1 90\\n21 22\\n103 -1\\n-1 19\\n137 -1\\n46 51\\n151 154\\n149 150\\n112 -1\\n183 184\\n77 78\\n40 -1\\n2 6\\n-1 26\\n125 133\\n88 91\\n143 144\\n55 -1\\n185 186\\n81 83\\n-1 172\\n-1 105\\n89 -1\\n-1 132\\n119 120\\n79 -1\\n-1 115\\n-1 -1\\n153 156\\n58 66\\n175 -1\\n126 134\\n159 -1\\n1 5\\n85 86\\n3 7\\n138 140\\n-1 -1\\n24 27\\n-1 -1\\n49 54\\n-1 11\\n-1 164\\n-1 130\\n32 -1\\n-1 20\\n25 28\\n60 68\\n102 106\\n10 12\\n-1 114\\n177 -1\\n-1 147\\n\", \"90\\n23 26\\n55 27\\n103 155\\n98 100\\n37 41\\n25 126\\n111 50\\n19 106\\n58 -1\\n134 136\\n89 10\\n48 77\\n88 91\\n137 150\\n122 135\\n133 60\\n159 -1\\n140 164\\n51 74\\n57 125\\n12 4\\n112 94\\n157 160\\n143 107\\n109 163\\n9 -1\\n175 177\\n80 18\\n115 124\\n102 67\\n95 -1\\n153 156\\n56 68\\n151 154\\n79 142\\n139 132\\n53 7\\n38 49\\n-1 174\\n21 64\\n15 17\\n45 84\\n166 92\\n47 63\\n162 99\\n59 65\\n6 171\\n104 46\\n176 30\\n73 138\\n123 148\\n179 72\\n52 3\\n117 14\\n120 129\\n144 180\\n83 -1\\n97 81\\n39 8\\n167 86\\n93 105\\n75 178\\n31 32\\n40 44\\n76 82\\n2 66\\n116 141\\n165 169\\n16 61\\n152 158\\n147 42\\n33 35\\n149 113\\n101 28\\n24 114\\n85 110\\n87 108\\n173 90\\n70 146\\n168 172\\n54 62\\n5 20\\n29 78\\n161 131\\n121 -1\\n34 36\\n11 13\\n1 96\\n119 128\\n118 127\\n\", \"96\\n53 119\\n13 8\\n191 192\\n131 137\\n156 -1\\n185 186\\n-1 76\\n-1 178\\n89 140\\n123 -1\\n3 106\\n31 138\\n105 150\\n40 172\\n95 158\\n102 151\\n96 108\\n-1 -1\\n187 85\\n145 52\\n33 36\\n159 162\\n25 26\\n121 122\\n19 115\\n38 154\\n66 72\\n91 93\\n18 23\\n17 22\\n118 120\\n177 51\\n-1 134\\n176 46\\n16 70\\n112 -1\\n37 42\\n-1 174\\n160 163\\n59 43\\n125 126\\n181 183\\n75 116\\n79 94\\n161 164\\n-1 -1\\n48 60\\n80 190\\n61 179\\n39 99\\n54 56\\n-1 35\\n47 50\\n82 180\\n1 90\\n-1 170\\n-1 21\\n68 184\\n132 171\\n153 44\\n-1 136\\n28 142\\n147 88\\n144 149\\n92 14\\n-1 78\\n57 173\\n155 34\\n15 20\\n143 9\\n67 73\\n117 -1\\n97 100\\n141 152\\n104 109\\n166 133\\n65 71\\n-1 87\\n77 24\\n111 114\\n-1 86\\n167 45\\n11 62\\n83 30\\n182 74\\n129 135\\n27 29\\n189 188\\n-1 6\\n63 69\\n2 107\\n101 58\\n41 12\\n5 10\\n-1 110\\n146 157\\n\", \"94\\n78 18\\n172 46\\n47 48\\n-1 34\\n113 114\\n-1 176\\n1 2\\n140 144\\n59 63\\n115 116\\n-1 52\\n123 127\\n39 41\\n40 74\\n60 64\\n85 -1\\n25 27\\n104 106\\n61 35\\n133 134\\n149 152\\n101 102\\n20 23\\n62 66\\n37 38\\n179 -1\\n89 91\\n57 58\\n12 16\\n5 6\\n54 56\\n84 87\\n14 82\\n93 94\\n69 79\\n159 -1\\n11 -1\\n32 65\\n33 100\\n31 158\\n165 166\\n118 120\\n95 98\\n177 178\\n71 73\\n53 55\\n43 50\\n72 42\\n44 174\\n19 70\\n121 122\\n29 30\\n147 150\\n185 186\\n3 4\\n8 10\\n-1 119\\n21 24\\n148 151\\n142 146\\n67 81\\n167 169\\n49 45\\n154 156\\n136 138\\n135 137\\n153 155\\n161 164\\n90 86\\n97 36\\n181 112\\n139 143\\n77 68\\n111 183\\n131 132\\n141 145\\n83 92\\n26 28\\n107 109\\n175 80\\n103 105\\n171 173\\n125 129\\n13 17\\n168 170\\n96 99\\n75 22\\n182 184\\n160 163\\n108 110\\n187 188\\n-1 9\\n126 130\\n-1 128\\n\", \"90\\n121 139\\n-1 104\\n31 92\\n81 149\\n80 86\\n77 156\\n71 44\\n-1 180\\n45 36\\n101 88\\n103 162\\n107 69\\n3 6\\n93 70\\n32 85\\n142 22\\n-1 11\\n143 132\\n145 66\\n37 65\\n18 4\\n119 72\\n117 75\\n95 63\\n154 155\\n96 19\\n59 -1\\n79 8\\n89 -1\\n113 147\\n177 -1\\n105 133\\n110 64\\n10 62\\n82 124\\n1 175\\n26 125\\n15 97\\n160 129\\n-1 -1\\n58 99\\n2 20\\n158 128\\n169 76\\n174 108\\n94 61\\n144 127\\n171 60\\n17 112\\n120 131\\n54 111\\n122 24\\n13 100\\n41 42\\n30 23\\n173 176\\n118 12\\n123 164\\n115 126\\n46 5\\n146 134\\n-1 151\\n74 102\\n178 91\\n114 28\\n-1 27\\n56 33\\n-1 35\\n90 150\\n167 106\\n57 68\\n39 40\\n9 148\\n165 47\\n51 163\\n157 161\\n153 83\\n29 98\\n52 130\\n49 21\\n137 34\\n138 140\\n25 168\\n50 38\\n14 67\\n141 48\\n159 84\\n43 166\\n109 170\\n55 172\\n\", \"95\\n111 112\\n72 76\\n175 176\\n97 100\\n85 88\\n127 132\\n42 45\\n161 162\\n8 12\\n7 -1\\n-1 108\\n150 153\\n74 78\\n22 25\\n41 44\\n117 121\\n126 -1\\n93 96\\n35 60\\n15 17\\n83 84\\n71 75\\n37 39\\n-1 110\\n115 116\\n55 59\\n86 89\\n182 186\\n165 167\\n87 90\\n33 34\\n183 187\\n64 69\\n62 67\\n-1 -1\\n29 32\\n2 5\\n-1 180\\n128 133\\n1 4\\n47 48\\n80 82\\n136 140\\n54 58\\n-1 -1\\n119 123\\n49 50\\n-1 168\\n125 130\\n38 40\\n3 6\\n73 77\\n79 81\\n9 13\\n28 31\\n137 141\\n155 158\\n184 188\\n16 18\\n10 14\\n101 103\\n163 164\\n19 -1\\n143 145\\n91 94\\n135 139\\n113 114\\n63 68\\n147 148\\n171 174\\n177 178\\n-1 -1\\n92 95\\n65 70\\n43 46\\n27 30\\n118 122\\n23 26\\n156 159\\n21 24\\n99 98\\n53 57\\n51 52\\n129 134\\n56 36\\n144 146\\n189 190\\n106 109\\n120 124\\n102 -1\\n157 160\\n61 66\\n151 154\\n149 152\\n170 -1\\n\", \"88\\n-1 129\\n9 97\\n32 120\\n18 106\\n28 116\\n34 122\\n49 137\\n73 161\\n25 113\\n17 105\\n67 155\\n72 160\\n31 119\\n52 140\\n75 163\\n63 151\\n48 136\\n27 115\\n61 149\\n80 168\\n82 170\\n44 132\\n66 154\\n56 144\\n30 118\\n5 93\\n33 121\\n71 159\\n6 94\\n2 90\\n81 169\\n19 107\\n64 152\\n76 164\\n23 111\\n7 95\\n60 148\\n10 98\\n40 128\\n74 162\\n47 135\\n65 153\\n68 156\\n8 96\\n29 117\\n41 -1\\n50 138\\n79 167\\n57 145\\n11 99\\n36 124\\n85 173\\n77 165\\n26 114\\n55 143\\n16 104\\n54 142\\n84 172\\n35 123\\n53 141\\n88 176\\n15 103\\n78 166\\n21 109\\n22 110\\n39 127\\n58 146\\n43 131\\n24 112\\n3 91\\n45 133\\n70 158\\n86 174\\n20 108\\n59 147\\n12 100\\n87 175\\n42 130\\n62 150\\n1 89\\n13 101\\n46 134\\n51 139\\n4 92\\n14 102\\n38 126\\n83 171\\n37 125\\n\", \"82\\n19 101\\n33 115\\n68 150\\n3 85\\n45 127\\n46 128\\n25 107\\n49 131\\n37 119\\n13 95\\n2 84\\n65 147\\n70 152\\n11 93\\n32 114\\n35 117\\n48 130\\n82 164\\n20 102\\n53 135\\n41 123\\n22 104\\n47 129\\n15 97\\n64 146\\n40 122\\n78 160\\n12 94\\n43 125\\n56 138\\n58 140\\n-1 110\\n28 -1\\n24 106\\n77 159\\n6 88\\n14 96\\n54 136\\n10 -1\\n9 91\\n52 134\\n42 124\\n17 99\\n27 109\\n75 157\\n60 142\\n34 116\\n16 98\\n1 83\\n51 133\\n80 162\\n-1 92\\n66 148\\n72 154\\n57 139\\n55 137\\n61 143\\n59 141\\n44 126\\n29 111\\n62 144\\n74 156\\n26 108\\n73 155\\n39 121\\n23 105\\n4 86\\n30 112\\n69 151\\n63 145\\n81 163\\n79 161\\n76 158\\n18 100\\n67 149\\n50 132\\n38 120\\n71 153\\n7 89\\n21 103\\n36 118\\n31 113\\n\", \"68\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 81\\n-1 -1\\n1 69\\n-1 111\\n60 128\\n2 -1\\n49 -1\\n-1 -1\\n14 -1\\n55 -1\\n-1 -1\\n31 99\\n63 -1\\n-1 117\\n-1 -1\\n-1 -1\\n13 -1\\n-1 -1\\n-1 -1\\n67 -1\\n-1 -1\\n64 -1\\n-1 -1\\n-1 -1\\n47 115\\n4 -1\\n-1 97\\n-1 -1\\n-1 -1\\n52 120\\n40 -1\\n-1 74\\n57 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n-1 -1\\n23 91\\n-1 -1\\n-1 -1\\n27 -1\\n-1 80\\n-1 126\\n-1 102\\n28 96\\n-1 133\\n-1 -1\\n-1 -1\\n-1 76\\n-1 -1\\n-1 131\\n-1 -1\\n68 136\\n3 -1\\n-1 124\\n-1 123\\n-1 -1\\n-1 82\\n-1 72\\n-1 -1\\n-1 -1\\n-1 113\\n-1 -1\\n\", \"3\\n3 6\\n1 -1\\n1 -1\\n\", \"3\\n1 4\\n-1 6\\n-1 6\\n\", \"4\\n3 6\\n2 -1\\n4 -1\\n1 8\\n\"], \"outputs\": [\"Yes\\n\", \"No\\n\", \"No\\n\", \"Yes\\n\", \"Yes\\n\", \"Yes\\n\", \"Yes\\n\", \"Yes\\n\", \"Yes\\n\", \"Yes\\n\", \"Yes\\n\", \"Yes\\n\", \"Yes\\n\", \"Yes\\n\", \"Yes\\n\", \"Yes\\n\", \"Yes\\n\", \"Yes\\n\", \"Yes\\n\", \"Yes\\n\", \"Yes\\n\", \"Yes\\n\", \"Yes\\n\", \"Yes\\n\", \"Yes\\n\", \"Yes\\n\", \"No\\n\", \"No\\n\", \"No\\n\", \"No\\n\", \"Yes\\n\", \"No\\n\", \"No\\n\", \"No\\n\", \"Yes\\n\", \"No\\n\", \"No\\n\", \"No\\n\", \"No\\n\", \"No\\n\", \"No\\n\", \"No\\n\", \"No\\n\", \"No\\n\", \"No\\n\", \"No\\n\"]}", "source": "primeintellect"}
There is a building with 2N floors, numbered 1, 2, \ldots, 2N from bottom to top. The elevator in this building moved from Floor 1 to Floor 2N just once. On the way, N persons got on and off the elevator. Each person i (1 \leq i \leq N) got on at Floor A_i and off at Floor B_i. Here, 1 \leq A_i < B_i \leq 2N, and just one person got on or off at each floor. Additionally, because of their difficult personalities, the following condition was satisfied: - Let C_i (= B_i - A_i - 1) be the number of times, while Person i were on the elevator, other persons got on or off. Then, the following holds: - If there was a moment when both Person i and Person j were on the elevator, C_i = C_j. We recorded the sequences A and B, but unfortunately, we have lost some of the records. If the record of A_i or B_i is lost, it will be given to you as -1. Additionally, the remaining records may be incorrect. Determine whether there is a pair of A and B that is consistent with the remaining records. -----Constraints----- - 1 \leq N \leq 100 - A_i = -1 or 1 \leq A_i \leq 2N. - B_i = -1 or 1 \leq B_i \leq 2N. - All values in input are integers. -----Input----- Input is given from Standard Input in the following format: N A_1 B_1 A_2 B_2 : A_N B_N -----Output----- If there is a pair of A and B that is consistent with the remaining records, print Yes; otherwise, print No. -----Sample Input----- 3 1 -1 -1 4 -1 6 -----Sample Output----- Yes For example, if B_1 = 3, A_2 = 2, and A_3 = 5, all the requirements are met. In this case, there is a moment when both Person 1 and Person 2 were on the elevator, which is fine since C_1 = C_2 = 1. Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0
{"tests": "{\"inputs\": [\"2\\n\", \"6\\n\", \"3\\n\", \"4\\n\", \"5\\n\", \"1000000\\n\", \"1\\n\", \"7\\n\", \"8\\n\", \"9\\n\", \"10\\n\", \"11\\n\", \"12\\n\", \"13\\n\", \"14\\n\", \"15\\n\", \"16\\n\", \"17\\n\", \"18\\n\", \"19\\n\", \"20\\n\", \"21\\n\", \"22\\n\", \"23\\n\", \"24\\n\", \"25\\n\", \"26\\n\", \"27\\n\", \"28\\n\", \"29\\n\", \"30\\n\", \"31\\n\", \"32\\n\", \"33\\n\", \"34\\n\", \"35\\n\", \"36\\n\", \"37\\n\", \"38\\n\", \"39\\n\", \"40\\n\", \"462\\n\", \"1317\\n\", \"88\\n\", \"87\\n\"], \"outputs\": [\"8\\n\", \"888\\n\", \"86\\n\", \"88\\n\", \"886\\n\", \"-1\\n\", \"6\\n\", \"8886\\n\", \"8888\\n\", \"88886\\n\", \"88888\\n\", \"888886\\n\", \"888888\\n\", \"8888886\\n\", \"8888888\\n\", \"88888886\\n\", \"88888888\\n\", \"888888886\\n\", \"888888888\\n\", \"8888888886\\n\", \"8888888888\\n\", \"88888888886\\n\", \"88888888888\\n\", \"888888888886\\n\", \"888888888888\\n\", \"8888888888886\\n\", \"8888888888888\\n\", \"88888888888886\\n\", \"88888888888888\\n\", \"888888888888886\\n\", \"888888888888888\\n\", \"8888888888888886\\n\", \"8888888888888888\\n\", \"88888888888888886\\n\", \"88888888888888888\\n\", \"888888888888888886\\n\", \"888888888888888888\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\"]}", "source": "primeintellect"}
Apart from Nian, there is a daemon named Sui, which terrifies children and causes them to become sick. Parents give their children money wrapped in red packets and put them under the pillow, so that when Sui tries to approach them, it will be driven away by the fairies inside. Big Banban is hesitating over the amount of money to give out. He considers loops to be lucky since it symbolizes unity and harmony. He would like to find a positive integer n not greater than 10^18, such that there are exactly k loops in the decimal representation of n, or determine that such n does not exist. A loop is a planar area enclosed by lines in the digits' decimal representation written in Arabic numerals. For example, there is one loop in digit 4, two loops in 8 and no loops in 5. Refer to the figure below for all exact forms. $0123456789$ -----Input----- The first and only line contains an integer k (1 ≤ k ≤ 10^6) — the desired number of loops. -----Output----- Output an integer — if no such n exists, output -1; otherwise output any such n. In the latter case, your output should be a positive decimal integer not exceeding 10^18. -----Examples----- Input 2 Output 462 Input 6 Output 8080 Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0
{"tests": "{\"inputs\": [\"5 3 2\\n\", \"8 5 2\\n\", \"8 4 2\\n\", \"2 1 1\\n\", \"10 3 3\\n\", \"15 6 4\\n\", \"16 15 14\\n\", \"1000 51 25\\n\", \"3 1 1\\n\", \"3 2 1\\n\", \"3 2 2\\n\", \"4 1 1\\n\", \"4 2 1\\n\", \"4 2 2\\n\", \"4 3 1\\n\", \"4 3 2\\n\", \"4 3 3\\n\", \"8 5 3\\n\", \"20 19 19\\n\", \"30 14 14\\n\", \"33 5 3\\n\", \"5433 200 99\\n\", \"99999 1 1\\n\", \"9999 7 3\\n\", \"100000 1 1\\n\", \"100000 3 1\\n\", \"100000 99998 1\\n\", \"100000 99999 1\\n\", \"100000 99999 49999\\n\", \"3 1 1\\n\", \"5 1 1\\n\", \"10 1 1\\n\", \"3 2 1\\n\", \"8 1 1\\n\", \"4 1 1\\n\", \"6 1 1\\n\", \"20 1 1\\n\", \"5 2 1\\n\", \"100 1 1\\n\", \"10 2 1\\n\", \"47 1 1\\n\", \"7 1 1\\n\", \"4 2 1\\n\", \"5 2 2\\n\", \"8 2 1\\n\", \"1000 1 1\\n\", \"11 1 1\\n\", \"15 2 1\\n\", \"3 2 2\\n\", \"8 2 2\\n\"], \"outputs\": [\"1 2\\n2 3\\n1 4\\n5 1\\n\", \"-1\\n\", \"4 8\\n5 7\\n2 3\\n8 1\\n2 1\\n5 6\\n1 5\\n\", \"1 2\\n\", \"1 2\\n2 3\\n3 4\\n5 2\\n6 2\\n7 2\\n8 2\\n9 2\\n10 2\\n\", \"1 2\\n2 3\\n3 4\\n4 5\\n1 6\\n6 7\\n8 1\\n9 1\\n10 1\\n11 1\\n12 1\\n13 1\\n14 1\\n15 1\\n\", \"1 2\\n2 3\\n3 4\\n4 5\\n5 6\\n6 7\\n7 8\\n8 9\\n9 10\\n10 11\\n11 12\\n12 13\\n13 14\\n14 15\\n1 16\\n\", \"-1\\n\", \"-1\\n\", \"1 2\\n1 3\\n\", \"1 2\\n2 3\\n\", \"-1\\n\", \"1 2\\n1 3\\n4 1\\n\", \"1 2\\n2 3\\n4 2\\n\", \"-1\\n\", \"1 2\\n2 3\\n1 4\\n\", \"1 2\\n2 3\\n3 4\\n\", \"1 2\\n2 3\\n3 4\\n1 5\\n5 6\\n7 1\\n8 1\\n\", \"1 2\\n2 3\\n3 4\\n4 5\\n5 6\\n6 7\\n7 8\\n8 9\\n9 10\\n10 11\\n11 12\\n12 13\\n13 14\\n14 15\\n15 16\\n16 17\\n17 18\\n18 19\\n19 20\\n\", \"1 2\\n2 3\\n3 4\\n4 5\\n5 6\\n6 7\\n7 8\\n8 9\\n9 10\\n10 11\\n11 12\\n12 13\\n13 14\\n14 15\\n16 2\\n17 2\\n18 2\\n19 2\\n20 2\\n21 2\\n22 2\\n23 2\\n24 2\\n25 2\\n26 2\\n27 2\\n28 2\\n29 2\\n30 2\\n\", \"1 2\\n2 3\\n3 4\\n1 5\\n5 6\\n7 1\\n8 1\\n9 1\\n10 1\\n11 1\\n12 1\\n13 1\\n14 1\\n15 1\\n16 1\\n17 1\\n18 1\\n19 1\\n20 1\\n21 1\\n22 1\\n23 1\\n24 1\\n25 1\\n26 1\\n27 1\\n28 1\\n29 1\\n30 1\\n31 1\\n32 1\\n33 1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"1 2\\n1 3\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"1 2\\n1 3\\n4 1\\n5 1\\n\", \"-1\\n\", \"1 2\\n1 3\\n4 1\\n5 1\\n6 1\\n7 1\\n8 1\\n9 1\\n10 1\\n\", \"-1\\n\", \"-1\\n\", \"1 2\\n1 3\\n4 1\\n\", \"1 2\\n2 3\\n4 2\\n5 2\\n\", \"1 2\\n1 3\\n4 1\\n5 1\\n6 1\\n7 1\\n8 1\\n\", \"-1\\n\", \"-1\\n\", \"1 2\\n1 3\\n4 1\\n5 1\\n6 1\\n7 1\\n8 1\\n9 1\\n10 1\\n11 1\\n12 1\\n13 1\\n14 1\\n15 1\\n\", \"1 2\\n2 3\\n\", \"1 2\\n2 3\\n4 2\\n5 2\\n6 2\\n7 2\\n8 2\\n\"]}", "source": "primeintellect"}
A tree is a connected undirected graph consisting of n vertices and n - 1 edges. Vertices are numbered 1 through n. Limak is a little polar bear and Radewoosh is his evil enemy. Limak once had a tree but Radewoosh stolen it. Bear is very sad now because he doesn't remember much about the tree — he can tell you only three values n, d and h: The tree had exactly n vertices. The tree had diameter d. In other words, d was the biggest distance between two vertices. Limak also remembers that he once rooted the tree in vertex 1 and after that its height was h. In other words, h was the biggest distance between vertex 1 and some other vertex. The distance between two vertices of the tree is the number of edges on the simple path between them. Help Limak to restore his tree. Check whether there exists a tree satisfying the given conditions. Find any such tree and print its edges in any order. It's also possible that Limak made a mistake and there is no suitable tree – in this case print "-1". -----Input----- The first line contains three integers n, d and h (2 ≤ n ≤ 100 000, 1 ≤ h ≤ d ≤ n - 1) — the number of vertices, diameter, and height after rooting in vertex 1, respectively. -----Output----- If there is no tree matching what Limak remembers, print the only line with "-1" (without the quotes). Otherwise, describe any tree matching Limak's description. Print n - 1 lines, each with two space-separated integers – indices of vertices connected by an edge. If there are many valid trees, print any of them. You can print edges in any order. -----Examples----- Input 5 3 2 Output 1 2 1 3 3 4 3 5 Input 8 5 2 Output -1 Input 8 4 2 Output 4 8 5 7 2 3 8 1 2 1 5 6 1 5 -----Note----- Below you can see trees printed to the output in the first sample and the third sample. [Image] Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0
{"tests": "{\"inputs\": [\"3 1\\n\", \"6 1\\n\", \"100 100\\n\", \"5 6\\n\", \"7 5\\n\", \"8 3\\n\", \"10 5\\n\", \"4 2\\n\", \"5 6\\n\", \"7 3\\n\", \"9 5\\n\", \"10 3\\n\", \"4 9\\n\", \"4 35\\n\", \"7 3\\n\", \"9 76\\n\", \"3 32\\n\", \"5 100\\n\", \"8 57\\n\", \"10 25\\n\", \"4 90\\n\", \"6 54\\n\", \"10 33\\n\", \"16 9\\n\", \"94 9\\n\", \"84 7\\n\", \"25 2\\n\", \"5 2\\n\", \"83 1\\n\", \"63 1\\n\", \"4 9\\n\", \"92 10\\n\", \"33 3\\n\", \"11 26\\n\", \"78 87\\n\", \"58 37\\n\", \"66 90\\n\", \"45 52\\n\", \"15 5\\n\", \"93 67\\n\", \"62 16\\n\", \"90 70\\n\", \"72 100\\n\", \"13 13\\n\", \"99 27\\n\"], \"outputs\": [\"6.4641016\\n\", \"1.0000000\\n\", \"3.2429391\\n\", \"8.5555200\\n\", \"3.8321081\\n\", \"1.8597432\\n\", \"2.2360680\\n\", \"4.8284271\\n\", \"8.5555200\\n\", \"2.2992648\\n\", \"2.5990168\\n\", \"1.3416408\\n\", \"21.7279221\\n\", \"84.4974747\\n\", \"2.2992648\\n\", \"39.5050557\\n\", \"206.8512517\\n\", \"142.5919998\\n\", \"35.3351211\\n\", \"11.1803399\\n\", \"217.2792206\\n\", \"54.0000000\\n\", \"14.7580487\\n\", \"2.1813788\\n\", \"0.3111312\\n\", \"0.2719052\\n\", \"0.2865851\\n\", \"2.8518400\\n\", \"0.0393298\\n\", \"0.0524608\\n\", \"21.7279221\\n\", \"0.3534793\\n\", \"0.3151224\\n\", \"10.1982159\\n\", \"3.6501120\\n\", \"2.1177947\\n\", \"4.4963157\\n\", \"3.8993409\\n\", \"1.3124275\\n\", \"2.3419654\\n\", \"0.8536219\\n\", \"2.5313061\\n\", \"4.5608816\\n\", \"4.0898747\\n\", \"0.8847247\\n\"]}", "source": "primeintellect"}
NN is an experienced internet user and that means he spends a lot of time on the social media. Once he found the following image on the Net, which asked him to compare the sizes of inner circles: [Image] It turned out that the circles are equal. NN was very surprised by this fact, so he decided to create a similar picture himself. He managed to calculate the number of outer circles $n$ and the radius of the inner circle $r$. NN thinks that, using this information, you can exactly determine the radius of the outer circles $R$ so that the inner circle touches all of the outer ones externally and each pair of neighboring outer circles also touches each other. While NN tried very hard to guess the required radius, he didn't manage to do that. Help NN find the required radius for building the required picture. -----Input----- The first and the only line of the input file contains two numbers $n$ and $r$ ($3 \leq n \leq 100$, $1 \leq r \leq 100$) — the number of the outer circles and the radius of the inner circle respectively. -----Output----- Output a single number $R$ — the radius of the outer circle required for building the required picture. Your answer will be accepted if its relative or absolute error does not exceed $10^{-6}$. Formally, if your answer is $a$ and the jury's answer is $b$. Your answer is accepted if and only when $\frac{|a-b|}{max(1, |b|)} \le 10^{-6}$. -----Examples----- Input 3 1 Output 6.4641016 Input 6 1 Output 1.0000000 Input 100 100 Output 3.2429391 Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0.75
{"tests": "{\"inputs\": [\"3 3\\ntab\\none\\nbat\\n\", \"4 2\\noo\\nox\\nxo\\nxx\\n\", \"3 5\\nhello\\ncodef\\norces\\n\", \"9 4\\nabab\\nbaba\\nabcd\\nbcde\\ncdef\\ndefg\\nwxyz\\nzyxw\\nijji\\n\", \"5 6\\najwwja\\nfibwwz\\nbjwker\\ndfjsep\\nzwwbif\\n\", \"7 3\\nbob\\nmqf\\nsik\\nkld\\nfwe\\nfnz\\ndlk\\n\", \"6 3\\nwji\\niwn\\nfdp\\nnwi\\nsdz\\nwow\\n\", \"1 48\\nyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy\\n\", \"26 1\\nz\\ny\\nx\\nw\\nv\\nu\\nt\\ns\\nr\\nq\\np\\no\\nn\\nm\\nl\\nk\\nj\\ni\\nh\\ng\\nf\\ne\\nd\\nc\\nb\\na\\n\", \"4 2\\nzz\\nvv\\nzv\\nvz\\n\", \"8 3\\nttt\\nttq\\ntqt\\nqtq\\nqqq\\ntqq\\nqqt\\nqtt\\n\", \"13 4\\nhhhm\\nmhmh\\nmmhh\\nhmhm\\nmhhm\\nhmmm\\nhhhh\\nmmmm\\nhmmh\\nhhmm\\nmmhm\\nhhmh\\nmhmm\\n\", \"15 4\\njjhj\\nhjhh\\njjjh\\njjjj\\nhjhj\\nhjjj\\nhhhh\\nhhjh\\njhjh\\nhhhj\\njhhh\\njhjj\\nhjjh\\njjhh\\nhhjj\\n\", \"19 6\\nbbsssb\\nbbsbsb\\nbbssbb\\nbssbbs\\nsbbbsb\\nsbbssb\\nsbsbss\\nssbsbb\\nbssssb\\nsssbsb\\nbbbbbs\\nsssbss\\nbsssbb\\nbssbbb\\nsssssb\\nbbbsbs\\nsbbbbb\\nbbbsss\\nssbbbs\\n\", \"19 5\\nassaa\\nsaaas\\naaass\\nassss\\nsssas\\nasasa\\nsasss\\naasaa\\nsasaa\\nsasas\\nassas\\nsssss\\nasass\\naaasa\\nasaaa\\nssaaa\\naaaas\\naasas\\naassa\\n\", \"20 8\\ngggxgggg\\nxxxggxxg\\nxxgggxgx\\nxxggxgxg\\ngxxxxxxg\\ngxggxxxg\\nxxgxxxgx\\ngggxgggx\\nxgxxggxx\\ngxgggxgg\\nggxxggxg\\nxxggxxxg\\nxgggxgxg\\nxgggxxxx\\nxxggxggg\\ngxgxxxgx\\nggxgxxxx\\nggggxxgg\\nggggxxgx\\nxxgxxgxx\\n\", \"16 9\\nviiviiviv\\nivviivivv\\nivvivviiv\\nivvvvvivv\\nviviiivvv\\nivivivvii\\niiiiiivvi\\niiviviivv\\niiiiviviv\\niviviiiii\\nvivviviiv\\nviivivivi\\niivvvvivv\\niivviivvv\\niiviiviiv\\nivviiiiiv\\n\", \"15 10\\nhhhlhhllhh\\nlllhlhllhl\\nllhhllllhh\\nlhhhhllllh\\nlhhhllhlll\\nllhhlhhhlh\\nllhhhhhlhh\\nhlllhhhhll\\nhhlhhhhlll\\nlhhllhhlll\\nlhlhhllhhh\\nhhlllhhhhl\\nllllllhllh\\nlhhhlhllll\\nhlhllhlhll\\n\", \"19 11\\niijijiiiiii\\njjjjjjjjiji\\njjijjiiijij\\nijjjjiiijij\\njijijiijijj\\niijiijiijij\\niiijjijijjj\\njjjjjjiiiij\\niiiiijjiiii\\njiijiijjjjj\\niiiiijiijji\\niijijjjijji\\njijjjiijijj\\nijjijiiijjj\\nijijjjijjij\\nijjjiiijjjj\\nijjijiiijji\\niijjjijiiii\\niijijjijjjj\\n\", \"9 2\\nss\\nat\\nst\\ntt\\nta\\nsa\\nas\\nts\\naa\\n\", \"9 2\\naa\\nii\\nkk\\nia\\nak\\nik\\nai\\nka\\nki\\n\", \"8 2\\nya\\nyp\\naa\\nap\\npa\\npp\\nyy\\npy\\n\", \"16 13\\nejlvcbnfwcufg\\nbmvnpbzrtcvts\\nuxkanaezbvqgq\\nsqaqpfuzqdfpg\\noxwudrawjxssu\\nsicswzfzknptx\\nrmutvsxzrdene\\nfmeqzuufksowc\\nerterswsretre\\napwvlfulvfahg\\ngybyiwjwhvqdt\\nouvkqcjjdnena\\ncwoskfuuzqemf\\nqkyfapjycrapc\\ncmjurbzlfuihj\\nrnjtncwjzonce\\n\", \"17 14\\nufkgjuympyvbdt\\ninohechmqqntac\\npnrthedikyelhu\\nkibretxzbokkul\\nagmpxldeaicfip\\najxhqqbgqiaujf\\ncvaoithqvhqzmp\\ngltyuliiluytlg\\nfjlyvpggpvyljf\\negoyzxewwwwkdc\\nukasrncwnxmwzh\\nilwjzvnerjygvm\\nhrhttsttcgrbaw\\npmzqhvqhtioavc\\nazzvicbnvvujrg\\ntczhcacvevibkt\\ngvhhusgdjifmmu\\n\", \"18 15\\nhprpaepyybpldwa\\npoveplrjqgbrirc\\ninsvahznhlugdrc\\nawdlpbyypeaprph\\ngurilzdjrfrfdnt\\nkqxtzzdddrzzwva\\ndvrjupbgvfysjis\\nvcehqrjsjrqhecv\\nefcudkqpcsoxeek\\nghnyixevvhaniyw\\nwaylplvlkfwyvfy\\nhvcxvkdmdkvxcvh\\nswvvohscareynep\\ncljjjrxwvmbhmdx\\nmmnrmrhxhrmrnmm\\nrkvlobbtpsyobtq\\ntjguaaeewdhuzel\\nodewcgawocrczjc\\n\", \"17 14\\niqjzbmkkmbzjqi\\nflaajsyoyjqbta\\nzvkqmwyvyvqrto\\nohqsfzzjqzirgh\\neqlkoxraesjfyn\\nsxsnqmgknyrtzh\\nhctwrsetmqnspz\\npzrdlfzqfgyggt\\nfpppuskqkafddl\\nvqzozehbutyudm\\ncprzqnxhyhpucu\\nekbauejlymnlun\\natbqjyoysjaalf\\nzpsnqmtesrwtch\\ntssovnhzbvhmrd\\ngzgybjgrrypgyw\\nawpkcwyswerzar\\n\", \"19 15\\nkzxrduectwevzya\\nrvbbobbwbbobbvr\\nfnrsfapipafsrnf\\najrgjayyijtakwo\\nszcbqnxerrckvmq\\nqwqcjnklyhqzwlv\\nqtljkxivuuquagh\\nzmoatzyyuvxvvhn\\nqevycxrkxxztjqu\\nffcoecqrultafej\\nayzvewtceudrxzk\\nsdvfbzlbqpneilp\\njefatlurqceocff\\nwtkfzdlenlrupbn\\ncxlehlbfqxuxehh\\npdnorfgpiftfidf\\nhvpcirhwigzmwee\\njkyqsfzgttackpr\\npfcoduejjsmgekv\\n\", \"21 16\\nbouivksewcfbggsi\\nucisrymoomyrsicu\\nlbfnxsbmumdwnvdz\\nkqhxcvtpdxdwcxzx\\nutukvguzuickqgbc\\nqwagyohxthiilhmk\\ntrgvhvvttvvhvgrt\\nnxvwzbdimdzkjqgb\\njfqmhvbflacvocaq\\naboijsvharstfygt\\niirhlhuggqewuyiy\\nqacovcalfbvhmqfj\\nwmmdwejepfxojarg\\neyyfdcqpbsfkxqed\\nvlcezvrrmnxkvyfy\\nsgdgrvtimaacwmnp\\nomlspljvkpytqoay\\nhezwngleelgnwzeh\\nasthcgrdjscygqlz\\nhatzcsjktartsctc\\nyfyvkxnmrrvzeclv\\n\", \"18 15\\ntouncxctlwjlnix\\ncrdhfensgnoxsqs\\nauckexocydmizxi\\nqtggbkrcwsdabnn\\nskqkditatcinnij\\neoyixhclebzgvab\\nugwazjibyjxkgio\\npfqwckybokoboml\\naagasbbbrsnlgfm\\nqvjeqybuigwoclt\\ntzxognenxqkbcuu\\nxjluzkcigarbjzi\\nbavgzbelchxiyoe\\nnprzcwsbswczrpn\\nizjbragickzuljx\\nbnmukiouinxhrfw\\nkoytmudzyrmiktj\\nnnbadswcrkbggtq\\n\", \"21 16\\nivmdykxgzpmpsojj\\nlsacbvwkzrihbxae\\nwcwvukyhtrgmimaq\\nebzvsaushchiqugo\\njnpxszhkapzlexcg\\nishppvuydabnmcor\\ndublllwaawlllbud\\nnznmhodswuhvcybg\\nvfucufwyywfucufv\\nllxpiainiamylrwm\\nbgfembyqiswnxheb\\nxarywsepptlzqywj\\nicpjbiovfkhxbnkk\\nbwndaszybdwlllbn\\nwgzhopfdluolqcbs\\nzevijfwyyvzwimod\\neaxbhirzkwvbcasl\\ndomiwzvyywfjivez\\nukoehxfhrinomhxf\\nmwrlymainiaipxll\\nfxkafzyelkilisjc\\n\", \"24 17\\ngdnaevfczjayllndr\\nwmuarvqwpbhuznpxz\\nlurusjuzrkxmdvfhw\\nyckftntrvdatssgbb\\nzxpnzuhbpwqvraumw\\nwaxuutbtbtbtuuxaw\\ndgwjcwilgyrgpohnr\\ntrcttthipihtttcrt\\ncmbovzvfgdqlfkfqp\\nqbgqnzkhixnnvzvqi\\nqiursxnedmveeuxdq\\nrdnllyajzcfveandg\\nbzwxilleapxzcxmde\\ncxcfjzlfdtytldtqf\\nyhukzlipwduzwevmg\\nrorwbyuksboagybcn\\nambwnlhroyhjfrviw\\nuhkfyflnnnlfyfkhu\\noqujycxjdwilbxfuw\\nkjvmprbgqlgptzdcg\\nntvbvmwtoljxorljp\\nwivrfjhyorhlnwbma\\nukeawbyxrsrsgdhjg\\nlkstfcrcpwzcybdfp\\n\", \"17 14\\ntzmqqlttfuopox\\ndlgvbiydlxmths\\ndxnyijdxjuvvej\\nnfxqnqtffqnojm\\nrkfvitydhceoum\\ndycxhtklifleqe\\nldjflcylhmjxub\\nurgabqqfljxnps\\nshtmxldyibvgld\\nosjuvluhehilmn\\nwtdlavffvaldtw\\nabjixlbuwfyafp\\naojogsmvdzyorp\\nsicdoeogurcwor\\nocxbhsfmhmumef\\ndqxmxaadjwhqus\\nclwotgqvdwcbar\\n\", \"19 15\\nvckwliplqlghsrj\\nijodcwwahmyhlcw\\nvmxtpfqfucsrlkj\\nurfpsqvvghujktj\\ndqzjhsahqclpdnk\\ngxkkfjpgksgvosn\\ntdzghaxmubitpho\\nauspvsdadsvpsua\\njrshglqlpilwkcv\\nmczlxjpwkjkafdq\\nogoiebrhicgygyw\\nmqvfljsycyjgmry\\nrypgirpkaijxjis\\nfdqqybfabhektcz\\nqjlgcyyvgybkfob\\nfgdacgwkwtzmxaw\\nbeodeawdxtjkmul\\nuvofthzdouykfbm\\nfohvezsyszevhof\\n\", \"21 16\\nnmonvcjsrzaaptwq\\ngwfqpwpzpomihwrk\\nwpddhveysfqnahtp\\napudlvvoovvldupa\\nrmmdkvxhbaatqbix\\nnuylrmomksyzfvqj\\ntehasluuazwsubot\\nkvmtoacwfvgaswjc\\nkzeqgpbbvbkopdep\\nuuqfkyksskykfquu\\ncdvgblxukhlauyrt\\nqufnzzgoyrinljba\\nwawqpunycdjrtugt\\njainpkxzzxkpniaj\\nbqxflkftillbhziu\\nypdoaowbvafxcavr\\nffsnmnwxarihoetb\\nvkjeolamwejtoeyb\\nuizhbllitfklfxqb\\nenmimfyotwwxlubl\\njdapubmqhivhvtpk\\n\", \"19 15\\njbrkxvujnnbqtxl\\nnccimzpijbvkgsw\\nthkzoeuqubgqmyg\\ngawdqgcmsyyqjqi\\ntpmtyqywcibpmsx\\ncdizsrcxbyxgjhy\\nhbdtwfbigjgjvvx\\nzsgqmcnzpyjtptx\\nsdunabpxjgmjini\\npegfxzgxgzxfgep\\ndadoreolxiexykr\\nwlammhynkmvknbf\\ncwnddcwxvttsrkf\\nllqpdraducfzraa\\nxjobmfjbqnvzgen\\ntanxwnfblurruuz\\nxvvjgjgibfwtdbh\\nzuurrulbfnwxnat\\ndbyznxuogfpdooq\\n\", \"23 16\\nhguaqgtvkgjujqsw\\nourwjkcqcyhwopbx\\nmbzsqzrdrexcyteq\\nikymlzfsglgnrrsk\\nhrkgfbszibphqxug\\nwtahnxkohpjtgqxw\\njqukumpdalhatcuw\\nyeykmsvzalxjkpet\\ncytqzyfmbrdfzksn\\nmxnlbjvghjzukfqq\\nrekvgjgifopxchgw\\nnqezefubkbwkquxn\\ntwytadlousxwkyrw\\nunovmzyhjyydnzyu\\nubpegcvfelmnkxfx\\nhpgbwhlmmlhwbgph\\npusmzqjvwcrxckxi\\nooetmunvipomrexv\\npcetnonmmnontecp\\ntewdbezylmzkjrvo\\nksrrnglgsfzlmyki\\ntliczkoxzeypchxm\\nwuctahladpmukuqj\\n\", \"21 16\\nogkkdydrhzgavqkc\\niqaxpnpsjdvgkrrz\\ntewguczyqcisoqzh\\npeqnniumbtkxbyks\\nwsqyouoxwktyrcjo\\nrvoezvxklbyaeuzn\\niolswzrxjomtadts\\neycdlpicgozjcigd\\nwrsbhqcffrsphnmh\\nncjsrocnbxuuerot\\npxalvbzhtirkcbqk\\ndgicjzogcipldcye\\nlymeaolddloaemyl\\ntfcknbkxzfcuiycj\\njnirwmlmvxtmgnma\\nojcrytkwxouoyqsw\\nsivatxubbohsutgi\\nuxzptbnuymgogsqs\\nvxhpocemmsltfnas\\nizbrffhfzwroasyl\\nnzueayblkxvzeovr\\n\", \"18 15\\nragnnivnpxztdrs\\nvkyxdmkucqqbpug\\nitkvrrlnlmtjqcr\\nxyxdblwlwlbdxyx\\nwkyzxwlbrdbqkem\\nihaamxlwxksuzog\\nutzglkmjsnvajkt\\nxpscnineyfjbtiz\\ndansieshwouxwed\\ngpesrpjnjjfhvpn\\nlytyezeofixktph\\nqcmqoukytsxdkvj\\ntkjavnsjmklgztu\\naekyzxlyqanqfzp\\nduqoshteikxqgzl\\nptqylxvlzxlgdhj\\nktresxutnpspgix\\nnzyzrihyzbelvac\\n\", \"21 16\\nfumufbuqukamthau\\nwrvomjqjmzmujnhx\\nqgsmvvkmvkosktvp\\nzifwbktvdtceafla\\niwhwzjoxpmfengim\\njzvtjjshhsjjtvzj\\nektvzejyypqdglgp\\nhazzzvyqzcfrhlew\\nrrmnojzxdisryhlf\\nydhwyvjbbjvywhdy\\ndcbwaeidaibouinw\\nkzamfhfzywfulczz\\nqqnxvlaaqtwnujzx\\ntvziydcmzomoumhz\\njalitflajnnojsho\\npxnvfqubwwrbtflh\\nwelhrfczqyvzzzah\\ncmzuycjmflasndrt\\niquvnxxqyyhhabdw\\nkdemxeezdudoolsl\\nmsmvkvpwyshrtmfc\\n\", \"24 17\\nmhcuaxurtqranxfzs\\nuvkvuufjvabbhphfr\\npvecnayhshocfcteo\\nnxpzsisqaqsiszpxn\\nectznpabcztyqidmg\\nuonnubzlvqovzarun\\ntdfoxciotaewhxaky\\npfdiagdzhacyttkdq\\nbvafrpvllatsdohrx\\nymjramutquyxaldxi\\nigzbnrrayqklxvrct\\nmpfaoooffuptrvpob\\nwhyeubpfcbfnaqmgt\\nkkvrolvfrrgyjtxvs\\nsxvytjtdpmoiqmrco\\nqpybyiznrnziybypq\\nosqtsegisigestqso\\npwdbqdwvwrwsntzgn\\ninnhvyozrobihcxms\\nvhyehewofkpywdsyp\\nocrmqiompdtjtyvxs\\naojkeenmaxymwsuto\\nkkddoxvljvlfrywwf\\nntvhgwbtqbivbppzo\\n\", \"21 16\\nqrunmhntskbkettu\\niljrukpcgdyzfbyk\\nrivdpsimmucsovvt\\npomwlbeecucszzmn\\nsadqtntuieyxyrlf\\nkybfzydgcpkurjli\\nmhnslegyceewirxd\\nmqekpftantmdjcyf\\nocziqcwnsxdnzyee\\nwjprnaxrhwwjsgtk\\nvmwednvvvvndewmv\\nbaulcpgwypwkhocn\\nlvlcoumjcgtmetqq\\nqvcbnuesqlqspayl\\nzywarsfzdulycrsk\\nyevkxvgfkxaarshu\\nphpytewxkgarmpjk\\nqoiuwdzjxuyjyzvn\\nnvzyjyuxjzdwuioq\\nwitjhtpepmunlvzl\\nvxzuvllrhbrhvuek\\n\", \"24 17\\nzndmakqspbruuzsta\\nnvacnkaubelqshjle\\ngzvbehvxuxvhebvzg\\nohnqptaomnrqltjpb\\nbrxlqhayktxoovmfw\\nyxodyrfutnofhoydu\\nznnnrxnueijnbgkyh\\njuzlmpnwtoxbhesft\\nugiakrtzkpavxrntw\\nrzbjnfyrsnrybsgdl\\nhivnuuhrwfwlhhdbf\\nprjbnmwxftlmtbfjr\\nmsuznhixqorujbwas\\nufuoquqdalffvvkuf\\nudyohfontufrydoxy\\njsrawuqtapdqhsniy\\nvphlnhoiirfsadsof\\nldgsbyrnsryfnjbzr\\ntlsngxmxzhmwrqtfp\\nafmeaepzxqcbxphly\\npexlxzqtydcturlis\\nsawbjuroqxihnzusm\\nrkczcixiyhmnwgcsu\\nchswoyhmadcdpsobh\\n\", \"1 1\\na\\n\", \"1 50\\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\n\", \"1 50\\naaaaaaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaaaaa\\n\"], \"outputs\": [\"6\\ntabbat\\n\", \"6\\noxxxxo\\n\", \"0\\n\\n\", \"20\\nababwxyzijjizyxwbaba\\n\", \"18\\nfibwwzajwwjazwwbif\\n\", \"9\\nkldbobdlk\\n\", \"9\\niwnwownwi\\n\", \"48\\nyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy\\n\", \"1\\na\\n\", \"6\\nzvvvvz\\n\", \"15\\nttqtqqqqqqqtqtt\\n\", \"28\\nmhmhmmhhmmhmhmmhmhmmhhmmhmhm\\n\", \"52\\njjhjhjhhjjjhhjhjhhhjjjhhhjjhhhjjjhhhjhjhhjjjhhjhjhjj\\n\", \"42\\nbbsssbbssbbsbbbbbsbssssbsbbbbbsbbssbbsssbb\\n\", \"55\\nassaaaaasssssassasaaaaasasssssasaaaaasassasssssaaaaassa\\n\", \"8\\nxxgxxgxx\\n\", \"0\\n\\n\", \"0\\n\\n\", \"0\\n\\n\", \"14\\natstsaaaaststa\\n\", \"14\\niaakikkkkikaai\\n\", \"10\\nypapyypapy\\n\", \"39\\nfmeqzuufksowcerterswsretrecwoskfuuzqemf\\n\", \"42\\ncvaoithqvhqzmpfjlyvpggpvyljfpmzqhvqhtioavc\\n\", \"45\\nhprpaepyybpldwammnrmrhxhrmrnmmawdlpbyypeaprph\\n\", \"70\\nflaajsyoyjqbtahctwrsetmqnspziqjzbmkkmbzjqizpsnqmtesrwtchatbqjyoysjaalf\\n\", \"75\\nkzxrduectwevzyaffcoecqrultafejfnrsfapipafsrnfjefatlurqceocffayzvewtceudrxzk\\n\", \"80\\njfqmhvbflacvocaqvlcezvrrmnxkvyfyhezwngleelgnwzehyfyvkxnmrrvzeclvqacovcalfbvhmqfj\\n\", \"105\\nqtggbkrcwsdabnneoyixhclebzgvabxjluzkcigarbjzinprzcwsbswczrpnizjbragickzuljxbavgzbelchxiyoennbadswcrkbggtq\\n\", \"112\\nlsacbvwkzrihbxaellxpiainiamylrwmzevijfwyyvzwimodvfucufwyywfucufvdomiwzvyywfjivezmwrlymainiaipxlleaxbhirzkwvbcasl\\n\", \"119\\ngdnaevfczjayllndrwmuarvqwpbhuznpxzambwnlhroyhjfrviwuhkfyflnnnlfyfkhuwivrfjhyorhlnwbmazxpnzuhbpwqvraumwrdnllyajzcfveandg\\n\", \"42\\ndlgvbiydlxmthswtdlavffvaldtwshtmxldyibvgld\\n\", \"45\\nvckwliplqlghsrjfohvezsyszevhofjrshglqlpilwkcv\\n\", \"48\\nbqxflkftillbhziujainpkxzzxkpniajuizhbllitfklfxqb\\n\", \"75\\nhbdtwfbigjgjvvxtanxwnfblurruuzpegfxzgxgzxfgepzuurrulbfnwxnatxvvjgjgibfwtdbh\\n\", \"80\\nikymlzfsglgnrrskjqukumpdalhatcuwpcetnonmmnontecpwuctahladpmukuqjksrrnglgsfzlmyki\\n\", \"112\\nwsqyouoxwktyrcjorvoezvxklbyaeuzneycdlpicgozjcigdlymeaolddloaemyldgicjzogcipldcyenzueayblkxvzeovrojcrytkwxouoyqsw\\n\", \"45\\nutzglkmjsnvajktxyxdblwlwlbdxyxtkjavnsjmklgztu\\n\", \"48\\nhazzzvyqzcfrhlewydhwyvjbbjvywhdywelhrfczqyvzzzah\\n\", \"51\\nsxvytjtdpmoiqmrcoosqtsegisigestqsoocrmqiompdtjtyvxs\\n\", \"80\\niljrukpcgdyzfbykqoiuwdzjxuyjyzvnvmwednvvvvndewmvnvzyjyuxjzdwuioqkybfzydgcpkurjli\\n\", \"119\\nyxodyrfutnofhoydurzbjnfyrsnrybsgdlmsuznhixqorujbwasgzvbehvxuxvhebvzgsawbjuroqxihnzusmldgsbyrnsryfnjbzrudyohfontufrydoxy\\n\", \"1\\na\\n\", \"50\\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\n\", \"0\\n\\n\"]}", "source": "primeintellect"}
Returning back to problem solving, Gildong is now studying about palindromes. He learned that a palindrome is a string that is the same as its reverse. For example, strings "pop", "noon", "x", and "kkkkkk" are palindromes, while strings "moon", "tv", and "abab" are not. An empty string is also a palindrome. Gildong loves this concept so much, so he wants to play with it. He has $n$ distinct strings of equal length $m$. He wants to discard some of the strings (possibly none or all) and reorder the remaining strings so that the concatenation becomes a palindrome. He also wants the palindrome to be as long as possible. Please help him find one. -----Input----- The first line contains two integers $n$ and $m$ ($1 \le n \le 100$, $1 \le m \le 50$) — the number of strings and the length of each string. Next $n$ lines contain a string of length $m$ each, consisting of lowercase Latin letters only. All strings are distinct. -----Output----- In the first line, print the length of the longest palindrome string you made. In the second line, print that palindrome. If there are multiple answers, print any one of them. If the palindrome is empty, print an empty line or don't print this line at all. -----Examples----- Input 3 3 tab one bat Output 6 tabbat Input 4 2 oo ox xo xx Output 6 oxxxxo Input 3 5 hello codef orces Output 0 Input 9 4 abab baba abcd bcde cdef defg wxyz zyxw ijji Output 20 ababwxyzijjizyxwbaba -----Note----- In the first example, "battab" is also a valid answer. In the second example, there can be 4 different valid answers including the sample output. We are not going to provide any hints for what the others are. In the third example, the empty string is the only valid palindrome string. Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0
{"tests": "{\"inputs\": [\"3 2\\n0 0\\n0 0\\n0 0\\n\", \"2 3\\n7 7 7\\n7 7 10\\n\", \"1 1\\n706\\n\", \"1 1\\n0\\n\", \"1 1\\n20\\n\", \"1 2\\n0 682\\n\", \"2 1\\n287\\n287\\n\", \"2 1\\n287\\n341\\n\", \"2 2\\n383 383\\n383 665\\n\", \"2 2\\n383 383\\n383 383\\n\", \"2 2\\n383 129\\n66 592\\n\", \"1 249\\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 67 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\\n\", \"1 249\\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\\n\", \"2 2\\n8 9\\n8 8\\n\", \"4 3\\n1 1 1\\n2 2 2\\n4 3 3\\n7 7 7\\n\", \"2 2\\n5 7\\n7 7\\n\", \"3 2\\n0 1\\n1 0\\n0 0\\n\", \"2 2\\n0 0\\n1 1\\n\", \"3 3\\n1 2 3\\n1 2 3\\n0 0 0\\n\", \"2 1\\n1\\n0\\n\", \"2 3\\n1 7 7\\n7 7 7\\n\", \"3 2\\n0 0\\n0 1\\n1 0\\n\", \"2 2\\n0 1\\n0 0\\n\", \"2 2\\n1 2\\n1 1\\n\", \"2 1\\n0\\n1\\n\", \"2 2\\n3 4\\n4 4\\n\", \"3 2\\n1 4\\n2 2\\n3 3\\n\", \"2 2\\n3 4\\n3 3\\n\", \"2 2\\n7 9\\n5 7\\n\", \"3 2\\n0 0\\n0 0\\n0 1\\n\", \"2 2\\n1 10\\n2 10\\n\", \"3 2\\n1 2\\n2 1\\n3 3\\n\", \"4 3\\n3 3 3\\n3 3 3\\n1 2 2\\n1 1 1\\n\", \"2 2\\n1 0\\n0 1\\n\", \"2 2\\n7 1\\n7 7\\n\", \"3 2\\n0 1\\n4 4\\n5 5\\n\", \"3 2\\n4 5\\n4 4\\n1 1\\n\", \"4 4\\n1 2 3 4\\n1 2 3 4\\n1 2 3 4\\n1 2 3 4\\n\", \"3 3\\n0 0 0\\n1 0 0\\n1 0 0\\n\", \"3 3\\n0 0 0\\n2 2 2\\n0 0 0\\n\", \"2 2\\n2 1\\n2 1\\n\", \"2 2\\n2 7\\n2 2\\n\", \"3 3\\n7 7 7\\n7 7 7\\n1 1 1\\n\", \"3 2\\n1 0\\n2 0\\n3 3\\n\", \"4 2\\n2 2\\n2 2\\n4 8\\n8 8\\n\"], \"outputs\": [\"NIE\\n\", \"TAK\\n1 3 \\n\", \"TAK\\n1 \\n\", \"NIE\\n\", \"TAK\\n1 \\n\", \"TAK\\n2 \\n\", \"NIE\\n\", \"TAK\\n1 1 \\n\", \"TAK\\n1 2 \\n\", \"NIE\\n\", \"TAK\\n1 1 \\n\", \"TAK\\n127 \\n\", \"NIE\\n\", \"TAK\\n2 1 \\n\", \"TAK\\n1 1 2 1 \\n\", \"TAK\\n1 1 \\n\", \"TAK\\n1 1 1 \\n\", \"TAK\\n1 1 \\n\", \"TAK\\n2 1 1 \\n\", \"TAK\\n1 1 \\n\", \"TAK\\n1 1 \\n\", \"TAK\\n1 1 1 \\n\", \"TAK\\n2 1 \\n\", \"TAK\\n2 1 \\n\", \"TAK\\n1 1 \\n\", \"TAK\\n1 1 \\n\", \"TAK\\n2 1 1 \\n\", \"TAK\\n2 1 \\n\", \"TAK\\n1 1 \\n\", \"TAK\\n1 1 2 \\n\", \"TAK\\n1 1 \\n\", \"TAK\\n2 1 1 \\n\", \"TAK\\n1 1 2 1 \\n\", \"TAK\\n1 1 \\n\", \"TAK\\n2 1 \\n\", \"TAK\\n1 1 1 \\n\", \"TAK\\n1 1 1 \\n\", \"TAK\\n2 1 1 1 \\n\", \"TAK\\n1 2 1 \\n\", \"TAK\\n1 1 1 \\n\", \"TAK\\n2 1 \\n\", \"TAK\\n2 1 \\n\", \"TAK\\n1 1 1 \\n\", \"TAK\\n2 1 1 \\n\", \"TAK\\n1 1 1 1 \\n\"]}", "source": "primeintellect"}
Student Dima from Kremland has a matrix $a$ of size $n \times m$ filled with non-negative integers. He wants to select exactly one integer from each row of the matrix so that the bitwise exclusive OR of the selected integers is strictly greater than zero. Help him! Formally, he wants to choose an integers sequence $c_1, c_2, \ldots, c_n$ ($1 \leq c_j \leq m$) so that the inequality $a_{1, c_1} \oplus a_{2, c_2} \oplus \ldots \oplus a_{n, c_n} > 0$ holds, where $a_{i, j}$ is the matrix element from the $i$-th row and the $j$-th column. Here $x \oplus y$ denotes the bitwise XOR operation of integers $x$ and $y$. -----Input----- The first line contains two integers $n$ and $m$ ($1 \leq n, m \leq 500$) — the number of rows and the number of columns in the matrix $a$. Each of the next $n$ lines contains $m$ integers: the $j$-th integer in the $i$-th line is the $j$-th element of the $i$-th row of the matrix $a$, i.e. $a_{i, j}$ ($0 \leq a_{i, j} \leq 1023$). -----Output----- If there is no way to choose one integer from each row so that their bitwise exclusive OR is strictly greater than zero, print "NIE". Otherwise print "TAK" in the first line, in the next line print $n$ integers $c_1, c_2, \ldots c_n$ ($1 \leq c_j \leq m$), so that the inequality $a_{1, c_1} \oplus a_{2, c_2} \oplus \ldots \oplus a_{n, c_n} > 0$ holds. If there is more than one possible answer, you may output any. -----Examples----- Input 3 2 0 0 0 0 0 0 Output NIE Input 2 3 7 7 7 7 7 10 Output TAK 1 3 -----Note----- In the first example, all the numbers in the matrix are $0$, so it is impossible to select one number in each row of the table so that their bitwise exclusive OR is strictly greater than zero. In the second example, the selected numbers are $7$ (the first number in the first line) and $10$ (the third number in the second line), $7 \oplus 10 = 13$, $13$ is more than $0$, so the answer is found. Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0.375
{"tests": "{\"inputs\": [\"AprilFool\\n14\\n\", \"abcdefabc\\n3\\n\", \"fgWjSAlPOvcAbCdDEFjz\\n7\\n\", \"sm\\n26\\n\", \"GnlFOqPeZtPiBkvvLhaDvGPgFqBTnLgMT\\n12\\n\", \"sPWSFWWqZBPon\\n3\\n\", \"fQHHXCdeaintxHWcFcaSGWFvqnYMEByMlSNKumiFgnJB\\n0\\n\", \"RtsUOGkraqKyjTktAXloOEmQj\\n18\\n\", \"DuFhhnq\\n4\\n\", \"RvpuYTxsbDiJDOLauRlfatcfwvtnDzKyaewGrZ\\n22\\n\", \"isfvbcBEEPaXUDhbVhwddjEutVQqNdlimIKjUnajDQ\\n2\\n\", \"VtQISIHREYaEGPustEkzJRN\\n20\\n\", \"jWBVk\\n17\\n\", \"VWOibsVSFkxPCmyZLWIOxFbfXdlsNzxVcUVf\\n8\\n\", \"HXyXuYceFtVUMyLqi\\n21\\n\", \"tAjlldiqGZUayJZHFQHFJVRukaIKepPVucrkyPtMrhIXoxZbw\\n12\\n\", \"fBUycJpfGhsfIVnXAovyoDyndkhv\\n9\\n\", \"uehLuNwrjO\\n0\\n\", \"gfSAltDEjuPqEsOFuiTpcUpCOiENCLbHHnCgvCQtW\\n13\\n\", \"SICNEaKsjCnvOEcVqFHLIC\\n16\\n\", \"LdsmfiNFkPfJgRxytsSJMQZnDTZZ\\n11\\n\", \"xedzyPU\\n13\\n\", \"kGqopTbelcDUcoZgnnRYXgPCRQwSLoqeIByFWDI\\n26\\n\", \"WHbBHzhSNkCZOAOwiKdu\\n17\\n\", \"Ik\\n3\\n\", \"WlwbRjvrOZakKXqecEdlrCnmvXQtLKBsy\\n5\\n\", \"IOJRIQefPFxpUj\\n18\\n\", \"vPuebwksPlxuevRLuWcACTBBgVnmcAUsQUficgEAhoEm\\n9\\n\", \"hQfrRArEPuVAQGfcSuoVKBKvY\\n22\\n\", \"TtQEIg\\n24\\n\", \"abczxy\\n0\\n\", \"aaaaaaAAAaaaaAaaAaaAaaaaAAaAAAaaAAaaaAAaaaaaAaaAAa\\n2\\n\", \"aaaaAaaaaaaAAaaAaaAaAaaaAaaaaaAAaaAAAAAaaAaAAAAaAA\\n4\\n\", \"bBbAbbbbaaAAAaabbBbaaabBaaaBaBbAaBabaAAAaaaaBabbb\\n4\\n\", \"BCABcbacbcbAAACCabbaccAabAAaaCCBcBAcCcbaABCCAcCb\\n4\\n\", \"cdccAAaBBAADdaCDBbDcaDDabdadAbBccCCCDDBADDcdAdC\\n4\\n\", \"EcCEECdCEBaaeCBEBbAaCAeEdeCEedCAdDeEbcACdCcCCd\\n4\\n\", \"cefEDAbedffbaCcEDfEeCEaAcCeFCcEabEecdEdcaFFde\\n4\\n\", \"nifzlTLaeWxTD\\n0\\n\", \"LiqWMLEULRhW\\n1\\n\", \"qH\\n2\\n\", \"R\\n26\\n\", \"MDJivQRiOIVRcCdkSuUlNbMEOkIVJRMTAnHbkVaOmOblLfignh\\n25\\n\", \"pFgLGSkFnGpNKALeDPGlciUNTTlCtAPlFhaIRutCFaFo\\n24\\n\"], \"outputs\": [\"AprILFooL\\n\", \"ABCdefABC\\n\", \"FGwjsAlpovCABCDDEFjz\\n\", \"SM\\n\", \"GnLFoqpEztpIBKvvLHADvGpGFqBtnLGmt\\n\", \"spwsfwwqzBpon\\n\", \"fqhhxcdeaintxhwcfcasgwfvqnymebymlsnkumifgnjb\\n\", \"RtsuOGKRAQKyJtKtAxLOOEMQJ\\n\", \"Dufhhnq\\n\", \"RVPUyTxSBDIJDOLAURLFATCFwVTNDzKyAEwGRz\\n\", \"isfvBcBeepAxudhBvhwddjeutvqqndlimikjunAjdq\\n\", \"vTQISIHREyAEGPuSTEKzJRN\\n\", \"JwBvK\\n\", \"vwoiBsvsFkxpCmyzlwioxFBFxDlsnzxvCuvF\\n\", \"HxyxUyCEFTvUMyLQI\\n\", \"tAJLLDIqGzuAyJzHFqHFJvruKAIKEppvuCrKyptmrHIxoxzBw\\n\", \"FBuyCjpFGHsFIvnxAovyoDynDkHv\\n\", \"uehlunwrjo\\n\", \"GFsALtDEJupqEsoFuItpCupCoIEnCLBHHnCGvCqtw\\n\", \"sICNEAKsJCNvOECvqFHLIC\\n\", \"lDsmFInFKpFJGrxytssJmqznDtzz\\n\", \"xEDzypu\\n\", \"KGQOPTBELCDUCOZGNNRYXGPCRQWSLOQEIBYFWDI\\n\", \"wHBBHzHsNKCzOAOwIKDu\\n\", \"ik\\n\", \"wlwBrjvrozAkkxqECEDlrCnmvxqtlkBsy\\n\", \"IOJRIQEFPFxPuJ\\n\", \"vpuEBwksplxuEvrluwCACtBBGvnmCAusquFICGEAHoEm\\n\", \"HQFRRAREPUVAQGFCSUOVKBKVy\\n\", \"TTQEIG\\n\", \"abczxy\\n\", \"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\\n\", \"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\\n\", \"BBBABBBBAAAAAAABBBBAAABBAAABABBAABABAAAAAAAABABBB\\n\", \"BCABCBACBCBAAACCABBACCAABAAAACCBCBACCCBAABCCACCB\\n\", \"CDCCAAABBAADDACDBBDCADDABDADABBCCCCCDDBADDCDADC\\n\", \"eCCeeCDCeBAAeCBeBBAACAeeDeCeeDCADDeeBCACDCCCCD\\n\", \"CefeDABeDffBACCeDfeeCeAACCefCCeABeeCDeDCAffDe\\n\", \"nifzltlaewxtd\\n\", \"liqwmleulrhw\\n\", \"qh\\n\", \"R\\n\", \"MDJIVQRIOIVRCCDKSUULNBMEOKIVJRMTANHBKVAOMOBLLFIGNH\\n\", \"PFGLGSKFNGPNKALEDPGLCIUNTTLCTAPLFHAIRUTCFAFO\\n\"]}", "source": "primeintellect"}
[Image] -----Input----- The first line of the input is a string (between 1 and 50 characters long, inclusive). Each character will be a letter of English alphabet, lowercase or uppercase. The second line of the input is an integer between 0 and 26, inclusive. -----Output----- Output the required string. -----Examples----- Input AprilFool 14 Output AprILFooL Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0
{"tests": "{\"inputs\": [\"6\\n-1 1 1 0 0 -1\\n\", \"3\\n100 100 101\\n\", \"7\\n-10 -9 -10 -8 -10 -9 -9\\n\", \"60\\n-8536 -8536 -8536 -8535 -8536 -8536 -8536 -8536 -8536 -8536 -8536 -8535 -8536 -8535 -8536 -8536 -8536 -8536 -8536 -8536 -8536 -8536 -8536 -8536 -8536 -8536 -8536 -8535 -8536 -8536 -8535 -8536 -8536 -8536 -8536 -8536 -8536 -8536 -8536 -8536 -8536 -8536 -8536 -8535 -8536 -8536 -8536 -8535 -8535 -8536 -8536 -8536 -8536 -8536 -8536 -8536 -8536 -8536 -8536 -8535\\n\", \"9\\n-71360 -71359 -71360 -71360 -71359 -71359 -71359 -71359 -71359\\n\", \"10\\n100 100 100 100 100 100 100 100 100 100\\n\", \"100\\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\\n\", \"5\\n-399 -399 -400 -399 -400\\n\", \"10\\n1001 1000 1000 1001 1000 1000 1001 1001 1000 1001\\n\", \"20\\n-100000 -99999 -100000 -99999 -99999 -100000 -99999 -100000 -99999 -100000 -99999 -99999 -99999 -100000 -100000 -99999 -100000 -100000 -100000 -99999\\n\", \"50\\n99999 99999 99999 99999 99999 99999 99999 99999 99999 99999 99999 99999 99999 99999 99999 99999 99999 99999 99999 99999 99999 100000 99999 99999 99999 99999 99999 100000 99999 99999 99999 100000 99999 99999 99999 99999 99999 99999 99999 99999 99999 99999 100000 99999 99999 99999 100000 99999 99999 99999\\n\", \"100\\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\\n\", \"1\\n-100000\\n\", \"1\\n-1\\n\", \"1\\n0\\n\", \"1\\n1\\n\", \"1\\n100000\\n\", \"5\\n2 2 1 1 2\\n\", \"10\\n0 -1 0 1 1 1 1 -1 0 0\\n\", \"20\\n-4344 -4342 -4344 -4342 -4343 -4343 -4344 -4344 -4342 -4343 -4344 -4343 -4344 -4344 -4344 -4342 -4344 -4343 -4342 -4344\\n\", \"40\\n113 113 112 112 112 112 112 112 112 112 112 113 113 112 113 112 113 112 112 112 111 112 112 113 112 112 112 112 112 112 112 112 113 112 113 112 112 113 112 113\\n\", \"5\\n-94523 -94523 -94523 -94524 -94524\\n\", \"10\\n-35822 -35823 -35823 -35823 -35821 -35823 -35823 -35821 -35822 -35821\\n\", \"11\\n-50353 -50353 -50353 -50353 -50353 -50352 -50353 -50353 -50353 -50353 -50352\\n\", \"20\\n46795 46795 46795 46795 46795 46795 46795 46793 46794 46795 46794 46795 46795 46795 46795 46795 46795 46795 46795 46795\\n\", \"40\\n72263 72261 72262 72263 72263 72263 72263 72263 72263 72262 72263 72263 72263 72263 72263 72262 72263 72262 72263 72262 72262 72263 72263 72262 72263 72263 72262 72262 72263 72262 72263 72263 72263 72263 72263 72263 72263 72263 72263 72262\\n\", \"50\\n-46992 -46992 -46992 -46991 -46992 -46991 -46992 -46992 -46992 -46992 -46992 -46992 -46992 -46992 -46991 -46991 -46991 -46992 -46990 -46991 -46991 -46991 -46991 -46992 -46992 -46991 -46992 -46992 -46992 -46990 -46992 -46991 -46991 -46992 -46992 -46992 -46991 -46991 -46991 -46992 -46992 -46992 -46992 -46992 -46992 -46992 -46992 -46992 -46992 -46992\\n\", \"60\\n-86077 -86075 -86076 -86076 -86077 -86077 -86075 -86075 -86075 -86077 -86075 -86076 -86075 -86075 -86075 -86076 -86075 -86076 -86075 -86075 -86076 -86076 -86076 -86075 -86075 -86075 -86075 -86077 -86075 -86076 -86075 -86075 -86075 -86076 -86075 -86076 -86077 -86075 -86075 -86075 -86076 -86075 -86076 -86075 -86076 -86076 -86075 -86076 -86076 -86075 -86075 -86075 -86077 -86076 -86075 -86075 -86075 -86075 -86075 -86075\\n\", \"70\\n-87 -86 -88 -86 -87 -86 -88 -88 -87 -86 -86 -88 -86 -86 -88 -87 -87 -87 -86 -87 -87 -87 -88 -88 -88 -87 -88 -87 -88 -87 -88 -86 -86 -86 -88 -86 -87 -87 -86 -86 -88 -86 -88 -87 -88 -87 -87 -86 -88 -87 -86 -88 -87 -86 -87 -87 -86 -88 -87 -86 -87 -88 -87 -88 -86 -87 -88 -88 -87 -87\\n\", \"2\\n0 2\\n\", \"4\\n1 1 3 3\\n\", \"6\\n1 1 1 3 3 3\\n\", \"2\\n1 3\\n\", \"7\\n0 1 1 1 1 1 2\\n\", \"6\\n1 1 1 -1 -1 -1\\n\", \"3\\n1 1 3\\n\", \"2\\n2 0\\n\", \"10\\n1 3 3 3 3 3 3 3 3 3\\n\", \"7\\n1 3 3 3 3 3 3\\n\", \"7\\n1 2 2 2 2 2 3\\n\", \"5\\n-8 -8 -8 -10 -10\\n\", \"3\\n1 2 3\\n\", \"4\\n2 2 4 4\\n\", \"4\\n1 1 -1 -1\\n\"], \"outputs\": [\"2\\n0 0 0 0 0 0 \\n\", \"3\\n101 100 100 \\n\", \"5\\n-10 -10 -9 -9 -9 -9 -9 \\n\", \"60\\n-8535 -8536 -8536 -8536 -8536 -8536 -8536 -8536 -8536 -8536 -8536 -8535 -8535 -8536 -8536 -8536 -8535 -8536 -8536 -8536 -8536 -8536 -8536 -8536 -8536 -8536 -8536 -8536 -8536 -8535 -8536 -8536 -8535 -8536 -8536 -8536 -8536 -8536 -8536 -8536 -8536 -8536 -8536 -8536 -8536 -8536 -8535 -8536 -8535 -8536 -8536 -8536 -8536 -8536 -8536 -8536 -8535 -8536 -8536 -8536 \\n\", \"9\\n-71359 -71359 -71359 -71359 -71359 -71360 -71360 -71359 -71360 \\n\", \"10\\n100 100 100 100 100 100 100 100 100 100 \\n\", \"100\\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \\n\", \"5\\n-400 -399 -400 -399 -399 \\n\", \"10\\n1001 1000 1001 1001 1000 1000 1001 1000 1000 1001 \\n\", \"20\\n-99999 -100000 -100000 -100000 -99999 -100000 -100000 -99999 -99999 -99999 -100000 -99999 -100000 -99999 -100000 -99999 -99999 -100000 -99999 -100000 \\n\", \"50\\n99999 99999 99999 100000 99999 99999 99999 100000 99999 99999 99999 99999 99999 99999 99999 99999 99999 99999 100000 99999 99999 99999 100000 99999 99999 99999 99999 99999 100000 99999 99999 99999 99999 99999 99999 99999 99999 99999 99999 99999 99999 99999 99999 99999 99999 99999 99999 99999 99999 99999 \\n\", \"100\\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 \\n\", \"1\\n-100000 \\n\", \"1\\n-1 \\n\", \"1\\n0 \\n\", \"1\\n1 \\n\", \"1\\n100000 \\n\", \"5\\n2 1 1 2 2 \\n\", \"6\\n0 0 0 0 0 0 0 0 1 1 \\n\", \"10\\n-4344 -4344 -4344 -4344 -4344 -4343 -4343 -4343 -4343 -4343 -4343 -4343 -4343 -4343 -4343 -4343 -4343 -4343 -4343 -4343 \\n\", \"12\\n111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 113 113 113 113 113 113 113 113 113 113 113 113 113 113 113 113 113 113 113 113 113 113 113 113 113 \\n\", \"5\\n-94524 -94524 -94523 -94523 -94523 \\n\", \"4\\n-35823 -35823 -35822 -35822 -35822 -35822 -35822 -35822 -35822 -35822 \\n\", \"11\\n-50352 -50353 -50353 -50353 -50353 -50352 -50353 -50353 -50353 -50353 -50353 \\n\", \"18\\n46794 46794 46794 46794 46795 46795 46795 46795 46795 46795 46795 46795 46795 46795 46795 46795 46795 46795 46795 46795 \\n\", \"30\\n72261 72261 72261 72261 72261 72261 72262 72263 72263 72263 72263 72263 72263 72263 72263 72263 72263 72263 72263 72263 72263 72263 72263 72263 72263 72263 72263 72263 72263 72263 72263 72263 72263 72263 72263 72263 72263 72263 72263 72263 \\n\", \"36\\n-46992 -46992 -46992 -46992 -46992 -46992 -46992 -46992 -46992 -46992 -46992 -46992 -46992 -46992 -46992 -46992 -46992 -46992 -46992 -46992 -46992 -46992 -46992 -46992 -46992 -46992 -46992 -46992 -46992 -46992 -46992 -46992 -46992 -46992 -46992 -46992 -46992 -46992 -46992 -46992 -46991 -46990 -46990 -46990 -46990 -46990 -46990 -46990 -46990 -46990 \\n\", \"42\\n-86077 -86077 -86077 -86077 -86077 -86077 -86077 -86077 -86077 -86077 -86077 -86077 -86077 -86077 -86077 -86077 -86075 -86075 -86075 -86075 -86075 -86075 -86075 -86075 -86075 -86075 -86075 -86075 -86075 -86075 -86075 -86075 -86075 -86075 -86075 -86075 -86075 -86075 -86075 -86075 -86075 -86075 -86075 -86075 -86075 -86075 -86075 -86075 -86075 -86075 -86075 -86075 -86075 -86075 -86075 -86075 -86075 -86075 -86075 -86075 \\n\", \"28\\n-88 -87 -87 -87 -87 -87 -87 -87 -87 -87 -87 -87 -87 -87 -87 -87 -87 -87 -87 -87 -87 -87 -87 -87 -87 -87 -87 -87 -87 -87 -87 -87 -87 -87 -87 -87 -87 -87 -87 -87 -87 -87 -87 -87 -87 -87 -87 -87 -87 -87 -87 -87 -87 -87 -87 -87 -87 -87 -87 -87 -87 -87 -87 -87 -87 -87 -87 -87 -87 -87 \\n\", \"0\\n1 1 \\n\", \"0\\n2 2 2 2 \\n\", \"0\\n2 2 2 2 2 2 \\n\", \"0\\n2 2 \\n\", \"3\\n0 0 0 1 2 2 2 \\n\", \"0\\n0 0 0 0 0 0 \\n\", \"1\\n1 2 2 \\n\", \"0\\n1 1 \\n\", \"8\\n2 2 3 3 3 3 3 3 3 3 \\n\", \"5\\n2 2 3 3 3 3 3 \\n\", \"3\\n1 1 1 2 3 3 3 \\n\", \"1\\n-9 -9 -9 -9 -8 \\n\", \"1\\n2 2 2 \\n\", \"0\\n3 3 3 3 \\n\", \"0\\n0 0 0 0 \\n\"]}", "source": "primeintellect"}
Anya and Kirill are doing a physics laboratory work. In one of the tasks they have to measure some value n times, and then compute the average value to lower the error. Kirill has already made his measurements, and has got the following integer values: x_1, x_2, ..., x_{n}. It is important that the values are close to each other, namely, the difference between the maximum value and the minimum value is at most 2. Anya does not want to make the measurements, however, she can't just copy the values from Kirill's work, because the error of each measurement is a random value, and this coincidence will be noted by the teacher. Anya wants to write such integer values y_1, y_2, ..., y_{n} in her work, that the following conditions are met: the average value of x_1, x_2, ..., x_{n} is equal to the average value of y_1, y_2, ..., y_{n}; all Anya's measurements are in the same bounds as all Kirill's measurements, that is, the maximum value among Anya's values is not greater than the maximum value among Kirill's values, and the minimum value among Anya's values is not less than the minimum value among Kirill's values; the number of equal measurements in Anya's work and Kirill's work is as small as possible among options with the previous conditions met. Formally, the teacher goes through all Anya's values one by one, if there is equal value in Kirill's work and it is not strike off yet, he strikes off this Anya's value and one of equal values in Kirill's work. The number of equal measurements is then the total number of strike off values in Anya's work. Help Anya to write such a set of measurements that the conditions above are met. -----Input----- The first line contains a single integer n (1 ≤ n ≤ 100 000) — the numeber of measurements made by Kirill. The second line contains a sequence of integers x_1, x_2, ..., x_{n} ( - 100 000 ≤ x_{i} ≤ 100 000) — the measurements made by Kirill. It is guaranteed that the difference between the maximum and minimum values among values x_1, x_2, ..., x_{n} does not exceed 2. -----Output----- In the first line print the minimum possible number of equal measurements. In the second line print n integers y_1, y_2, ..., y_{n} — the values Anya should write. You can print the integers in arbitrary order. Keep in mind that the minimum value among Anya's values should be not less that the minimum among Kirill's values, and the maximum among Anya's values should be not greater than the maximum among Kirill's values. If there are multiple answers, print any of them. -----Examples----- Input 6 -1 1 1 0 0 -1 Output 2 0 0 0 0 0 0 Input 3 100 100 101 Output 3 101 100 100 Input 7 -10 -9 -10 -8 -10 -9 -9 Output 5 -10 -10 -9 -9 -9 -9 -9 -----Note----- In the first example Anya can write zeros as here measurements results. The average value is then equal to the average value of Kirill's values, and there are only two equal measurements. In the second example Anya should write two values 100 and one value 101 (in any order), because it is the only possibility to make the average be the equal to the average of Kirill's values. Thus, all three measurements are equal. In the third example the number of equal measurements is 5. Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0
{"tests": "{\"inputs\": [\"1 2\\n\", \"4 8\\n\", \"4 10\\n\", \"1 5\\n\", \"3 4\\n\", \"3 10\\n\", \"74 99\\n\", \"19 30\\n\", \"33 77\\n\", \"3342 3339\\n\", \"7757 7755\\n\", \"10 8\\n\", \"9801 19605\\n\", \"1781 1272\\n\", \"9079 100096\\n\", \"32342 64687\\n\", \"873192 873189\\n\", \"3 1\\n\", \"14124 242112\\n\", \"2 1\\n\", \"2 3\\n\", \"1 4\\n\", \"2 6\\n\", \"2 5\\n\", \"2 4\\n\", \"2 3\\n\", \"2 2\\n\", \"2 1\\n\", \"1 1\\n\", \"1 3\\n\", \"3 2\\n\", \"5 4\\n\", \"4 3\\n\", \"11 10\\n\", \"8 7\\n\", \"4 2\\n\", \"6 5\\n\", \"3 7\\n\", \"5 1\\n\", \"10 1\\n\", \"4 9\\n\", \"6 4\\n\", \"12 10\\n\", \"4 100\\n\"], \"outputs\": [\"101\\n\", \"110110110101\\n\", \"11011011011011\\n\", \"-1\\n\", \"1010101\\n\", \"-1\\n\", \"11011011011011011011011011011011011011011011011011011011011011011011011010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101\\n\", \"1101101101101101101101101101101010101010101010101\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\", \"010\", \"10101\\n\", \"11011\\n\", \"11011011\\n\", \"1101101\\n\", \"110101\\n\", \"10101\\n\", \"1010\", \"010\", \"10\", \"1101\\n\", \"01010\", \"010101010\", \"0101010\", \"010101010101010101010\", \"010101010101010\", \"-1\\n\", \"01010101010\", \"1101101101\\n\", \"-1\\n\", \"-1\\n\", \"1101101101101\\n\", \"-1\\n\", \"-1\\n\", \"-1\\n\"]}", "source": "primeintellect"}
Now it's time of Olympiads. Vanya and Egor decided to make his own team to take part in a programming Olympiad. They've been best friends ever since primary school and hopefully, that can somehow help them in teamwork. For each team Olympiad, Vanya takes his play cards with numbers. He takes only the cards containing numbers 1 and 0. The boys are very superstitious. They think that they can do well at the Olympiad if they begin with laying all the cards in a row so that: there wouldn't be a pair of any side-adjacent cards with zeroes in a row; there wouldn't be a group of three consecutive cards containing numbers one. Today Vanya brought n cards with zeroes and m cards with numbers one. The number of cards was so much that the friends do not know how to put all those cards in the described way. Help them find the required arrangement of the cards or else tell the guys that it is impossible to arrange cards in such a way. -----Input----- The first line contains two integers: n (1 ≤ n ≤ 10^6) — the number of cards containing number 0; m (1 ≤ m ≤ 10^6) — the number of cards containing number 1. -----Output----- In a single line print the required sequence of zeroes and ones without any spaces. If such sequence is impossible to obtain, print -1. -----Examples----- Input 1 2 Output 101 Input 4 8 Output 110110110101 Input 4 10 Output 11011011011011 Input 1 5 Output -1 Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0
{"tests": "{\"inputs\": [\"4 6\\nX...XX\\n...XX.\\n.X..X.\\n......\\n1 6\\n2 2\\n\", \"5 4\\n.X..\\n...X\\nX.X.\\n....\\n.XX.\\n5 3\\n1 1\\n\", \"4 7\\n..X.XX.\\n.XX..X.\\nX...X..\\nX......\\n2 2\\n1 6\\n\", \"5 3\\n.XX\\n...\\n.X.\\n.X.\\n...\\n1 3\\n4 1\\n\", \"1 1\\nX\\n1 1\\n1 1\\n\", \"1 6\\n.X...X\\n1 2\\n1 5\\n\", \"7 1\\nX\\n.\\n.\\n.\\nX\\n.\\n.\\n5 1\\n3 1\\n\", \"1 2\\nXX\\n1 1\\n1 1\\n\", \"2 1\\n.\\nX\\n2 1\\n2 1\\n\", \"3 4\\n.X..\\n..XX\\n..X.\\n1 2\\n3 4\\n\", \"3 5\\n.X.XX\\nX...X\\nX.X..\\n2 1\\n1 5\\n\", \"3 2\\n..\\nX.\\n.X\\n3 2\\n3 1\\n\", \"3 4\\nXX.X\\nX...\\n.X.X\\n1 2\\n1 1\\n\", \"1 2\\nX.\\n1 1\\n1 2\\n\", \"2 1\\nX\\nX\\n2 1\\n1 1\\n\", \"2 2\\nXX\\nXX\\n1 1\\n2 2\\n\", \"2 2\\n..\\n.X\\n2 2\\n1 1\\n\", \"2 2\\n.X\\n.X\\n1 2\\n2 2\\n\", \"2 2\\n..\\nXX\\n2 1\\n1 1\\n\", \"4 2\\nX.\\n.X\\n.X\\nXX\\n2 2\\n3 1\\n\", \"2 4\\nX.XX\\n.X..\\n2 2\\n2 3\\n\", \"6 4\\nX..X\\n..X.\\n.X..\\n..X.\\n.X..\\nX..X\\n1 1\\n6 4\\n\", \"5 4\\nX...\\n..X.\\n.X..\\nX..X\\n....\\n4 4\\n3 1\\n\", \"3 4\\nX..X\\n..XX\\n.X..\\n2 3\\n3 1\\n\", \"20 20\\n....................\\n.......X...........X\\n............X......X\\n.X...XX..X....X.....\\n....X.....X.........\\nX..........X........\\n......X........X....\\n....................\\n...................X\\n......X.............\\n..............X.....\\n......X.X...........\\n.X.........X.X......\\n.........X......X..X\\n..................X.\\n...X........X.......\\n....................\\n....................\\n..X.....X...........\\n........X......X.X..\\n20 16\\n5 20\\n\", \"21 21\\n.....X...X.........X.\\n...X...XX......X.....\\n..X........X.X...XX..\\n.........X....X...X..\\nX...X...........XX...\\n...X...X....XX...XXX.\\n.X............X......\\n......X.X............\\n.X...X.........X.X...\\n......XX......X.X....\\n....X.......X.XXX....\\n.X.......X..XXX.X..X.\\n..X........X....X...X\\n.........X..........X\\n.....XX.....X........\\n...XX......X.........\\n.....X...XX...X......\\n..X.X....XX..XX.X....\\nX........X.X..XX..X..\\nX..X......X...X.X....\\nX.....X.....X.X......\\n20 4\\n21 5\\n\", \"2 1\\nX\\nX\\n2 1\\n2 1\\n\", \"2 2\\nXX\\nX.\\n1 1\\n2 2\\n\", \"2 1\\nX\\nX\\n1 1\\n1 1\\n\", \"1 2\\nXX\\n1 2\\n1 2\\n\", \"1 2\\nXX\\n1 1\\n1 2\\n\", \"1 2\\nXX\\n1 2\\n1 1\\n\", \"2 1\\nX\\nX\\n1 1\\n2 1\\n\", \"2 1\\n.\\nX\\n2 1\\n1 1\\n\", \"2 1\\nX\\n.\\n1 1\\n2 1\\n\", \"1 2\\n.X\\n1 2\\n1 1\\n\", \"2 1\\nX\\n.\\n1 1\\n1 1\\n\", \"1 2\\nX.\\n1 1\\n1 1\\n\", \"1 2\\n.X\\n1 2\\n1 2\\n\", \"2 2\\nX.\\n..\\n1 1\\n2 2\\n\", \"2 2\\n..\\nX.\\n2 1\\n1 1\\n\", \"4 3\\n..X\\n..X\\n.XX\\n.XX\\n4 2\\n2 2\\n\", \"3 3\\nXXX\\nX..\\nXXX\\n2 1\\n2 2\\n\", \"5 4\\nXXXX\\nX..X\\nX..X\\nXXXX\\nXXXX\\n4 2\\n3 3\\n\"], \"outputs\": [\"YES\\n\", \"NO\\n\", \"YES\\n\", \"YES\\n\", \"NO\\n\", \"NO\\n\", \"YES\\n\", \"NO\\n\", \"YES\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"YES\\n\", \"NO\\n\", \"YES\\n\", \"NO\\n\", \"YES\\n\", \"YES\\n\", \"YES\\n\", \"NO\\n\", \"YES\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"YES\\n\", \"YES\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"YES\\n\", \"YES\\n\", \"YES\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"YES\\n\", \"YES\\n\", \"YES\\n\", \"YES\\n\", \"YES\\n\", \"YES\\n\", \"YES\\n\", \"YES\\n\"]}", "source": "primeintellect"}
You play a computer game. Your character stands on some level of a multilevel ice cave. In order to move on forward, you need to descend one level lower and the only way to do this is to fall through the ice. The level of the cave where you are is a rectangular square grid of n rows and m columns. Each cell consists either from intact or from cracked ice. From each cell you can move to cells that are side-adjacent with yours (due to some limitations of the game engine you cannot make jumps on the same place, i.e. jump from a cell to itself). If you move to the cell with cracked ice, then your character falls down through it and if you move to the cell with intact ice, then the ice on this cell becomes cracked. Let's number the rows with integers from 1 to n from top to bottom and the columns with integers from 1 to m from left to right. Let's denote a cell on the intersection of the r-th row and the c-th column as (r, c). You are staying in the cell (r_1, c_1) and this cell is cracked because you've just fallen here from a higher level. You need to fall down through the cell (r_2, c_2) since the exit to the next level is there. Can you do this? -----Input----- The first line contains two integers, n and m (1 ≤ n, m ≤ 500) — the number of rows and columns in the cave description. Each of the next n lines describes the initial state of the level of the cave, each line consists of m characters "." (that is, intact ice) and "X" (cracked ice). The next line contains two integers, r_1 and c_1 (1 ≤ r_1 ≤ n, 1 ≤ c_1 ≤ m) — your initial coordinates. It is guaranteed that the description of the cave contains character 'X' in cell (r_1, c_1), that is, the ice on the starting cell is initially cracked. The next line contains two integers r_2 and c_2 (1 ≤ r_2 ≤ n, 1 ≤ c_2 ≤ m) — the coordinates of the cell through which you need to fall. The final cell may coincide with the starting one. -----Output----- If you can reach the destination, print 'YES', otherwise print 'NO'. -----Examples----- Input 4 6 X...XX ...XX. .X..X. ...... 1 6 2 2 Output YES Input 5 4 .X.. ...X X.X. .... .XX. 5 3 1 1 Output NO Input 4 7 ..X.XX. .XX..X. X...X.. X...... 2 2 1 6 Output YES -----Note----- In the first sample test one possible path is: [Image] After the first visit of cell (2, 2) the ice on it cracks and when you step there for the second time, your character falls through the ice as intended. Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0
{"tests": "{\"inputs\": [\"3 2\\nabc\\nxyc\\n\", \"1 0\\nc\\nb\\n\", \"1 1\\na\\na\\n\", \"2 1\\naa\\naa\\n\", \"3 1\\nbcb\\nbca\\n\", \"4 3\\nccbb\\ncaab\\n\", \"4 2\\nacbc\\nacba\\n\", \"4 1\\nbcbc\\nacab\\n\", \"4 2\\nacbb\\nbabc\\n\", \"5 2\\nabaac\\nbbbaa\\n\", \"5 2\\nabbab\\nacbab\\n\", \"5 3\\nbcaaa\\ncbacc\\n\", \"5 3\\ncbacb\\ncbacb\\n\", \"5 1\\ncbabb\\nbabaa\\n\", \"1 0\\na\\na\\n\", \"2 2\\nbb\\ncb\\n\", \"2 1\\ncc\\nba\\n\", \"2 0\\nbb\\nab\\n\", \"3 3\\naac\\nabc\\n\", \"1 1\\na\\nc\\n\", \"3 0\\ncba\\ncca\\n\", \"2 1\\niy\\niy\\n\", \"2 2\\nfg\\nfn\\n\", \"2 1\\npd\\nke\\n\", \"3 3\\nyva\\nyvq\\n\", \"3 2\\npxn\\ngxn\\n\", \"3 1\\nlos\\nlns\\n\", \"4 2\\nhbnx\\nhwmm\\n\", \"4 4\\nqtto\\nqtto\\n\", \"4 3\\nchqt\\nchet\\n\", \"5 3\\nwzcre\\nwzcrp\\n\", \"5 1\\nicahj\\nxdvch\\n\", \"5 1\\npmesm\\npzeaq\\n\", \"7 4\\nycgdbph\\nfdtapch\\n\", \"10 6\\nrnsssbuiaq\\npfsbsbuoay\\n\", \"20 5\\ndsjceiztjkrqgpqpnakr\\nyijdvcjtjnougpqprrkr\\n\", \"100 85\\njknccpmanwhxqnxivdgguahjcuyhdrazmbfwoptatlgytakxsfvdzzcsglhmswfxafxyregdbeiwpawrjgwcqrkbhmrfcscgoszf\\nhknccpmanwhxjnxivdggeahjcuyhdrazmbfwoqtatlgytdkxsfvdztcsglhmssfxsfxyrngdbeiwpawrjgwcqrkbhmrfcsckoskf\\n\", \"1 0\\nz\\nz\\n\", \"1 1\\nz\\ny\\n\", \"1 1\\nz\\nz\\n\", \"1 0\\nz\\ny\\n\", \"10 1\\ngjsywvenzc\\nfssywvenzc\\n\", \"20 2\\nywpcwcwgkhdeonzbeamf\\ngdcmwcwgkhdeonzbeamf\\n\"], \"outputs\": [\"bac\", \"-1\\n\", \"b\", \"ab\", \"bcc\", \"cbca\", \"acab\", \"-1\\n\", \"aaba\", \"abbab\", \"aabaa\", \"bbabb\", \"cbbaa\", \"-1\\n\", \"a\", \"aa\", \"ca\", \"-1\\n\", \"bca\", \"b\", \"-1\\n\", \"ia\", \"aa\", \"pe\", \"aab\", \"axa\", \"las\", \"hbma\", \"aaaa\", \"caaa\", \"wzaaa\", \"-1\\n\", \"-1\\n\", \"yctaaah\", \"aasasbuaba\", \"-1\\n\", \"aknccpmanwhxanxivaaaabaaaaaaaabaaaaaaaabaaaaabaaaaaaaaaaaaaaaaaabaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaa\", \"z\", \"a\", \"a\", \"-1\\n\", \"gssywvenzc\", \"ywcmwcwgkhdeonzbeamf\"]}", "source": "primeintellect"}
Marina loves strings of the same length and Vasya loves when there is a third string, different from them in exactly t characters. Help Vasya find at least one such string. More formally, you are given two strings s_1, s_2 of length n and number t. Let's denote as f(a, b) the number of characters in which strings a and b are different. Then your task will be to find any string s_3 of length n, such that f(s_1, s_3) = f(s_2, s_3) = t. If there is no such string, print - 1. -----Input----- The first line contains two integers n and t (1 ≤ n ≤ 10^5, 0 ≤ t ≤ n). The second line contains string s_1 of length n, consisting of lowercase English letters. The third line contain string s_2 of length n, consisting of lowercase English letters. -----Output----- Print a string of length n, differing from string s_1 and from s_2 in exactly t characters. Your string should consist only from lowercase English letters. If such string doesn't exist, print -1. -----Examples----- Input 3 2 abc xyc Output ayd Input 1 0 c b Output -1 Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0
{"tests": "{\"inputs\": [\"6 5\\naabbaa\\nbaaaab\\naaaaa\\n\", \"5 4\\nazaza\\nzazaz\\nazaz\\n\", \"9 12\\nabcabcabc\\nxyzxyzxyz\\nabcabcayzxyz\\n\", \"1 2\\nt\\nt\\ntt\\n\", \"20 40\\nxxxxxxxxxxxxxxxxxxxx\\nxxxxxxxxxxxxxxxxxxxx\\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\\n\", \"20 27\\nmmmmmmmmmmmmmmmmmmmm\\nmmmmmmmmmmmmmmmmmmmm\\nmmmmmmmmmmmmmmmmmmmmmmmmmmm\\n\", \"20 2\\nrrrrrrrrrrrrrrrrrrrr\\nrrrrrrrrrrrrrrrrrrrr\\nrr\\n\", \"20 10\\naaaaaaaaaamaaaaaaaax\\nfaaaaaaaaaaaaaaaaaaa\\naaaaaaaaaa\\n\", \"20 31\\npspsppspsppsppspspps\\nspspsspspsspsspspssp\\npspsppsppspsppspsspspsspsspspss\\n\", \"19 13\\nfafaffafaffaffafaff\\nafafaafafaafaafafaa\\nfafafafafaafa\\n\", \"20 23\\nzizizzizizzizzizizzi\\niziziizizpiziiziziiz\\nzizizzizzizizziiziziizi\\n\", \"20 17\\nkpooixkpooixkpokpowi\\noixtpooixkpooixoixkp\\npooixkpoixkpooixk\\n\", \"20 25\\nzvozvozvozvozvozvozv\\nozvozvozvozvozvozvoz\\nzvozvozvozvozvozvozvozvoz\\n\", \"20 40\\ngvgvgvgvgvgvgvgvgvgv\\ngvgvgvgvgvgvgvgvgvgv\\ngvgvgvgvgvgvgvgvgvgvgvgvgvgvgvgvgvgvgvgv\\n\", \"20 35\\ncyvvqscyvvqscyvvqscy\\nscyvvqscyvvqscyvvqsc\\nvqscyvvqscyvvqscyvvqscyvvqscyvvqscy\\n\", \"20 6\\ndqgdqgdqydqgdqgqqgdq\\ndqtdqgdqgdqgdqgdfgdq\\ndqgdqg\\n\", \"20 40\\nypqwnaiotllzrsoaqvau\\nzjveavedxiqzzusesven\\nypqwnaiotllzrsoaqvauzjveavedxiqzzusesven\\n\", \"20 40\\nxdjlcpeaimrjukhizoan\\nobkcqzkcrvxxfbrvzoco\\nxdrlcpeaimrjukhizoanobkcqzkcrvxxfbrvzoco\\n\", \"20 22\\nxsxxsxssxsxxssxxsxss\\nxssxsxxssxxsxssxxssx\\nxxsxssxsxxssxxsxssxsxx\\n\", \"20 15\\nwwawaawwaawawwaawwaw\\nawawwawaawhaawcwwawa\\nwwawaawwaawawwa\\n\", \"20 10\\ndctctdtdcctdtdcdcttd\\ntdcdctdctctdtdcctdtd\\ncdctctddct\\n\", \"20 8\\nurrndundurdurnurndnd\\nurndrnduurndrndundur\\nrndundur\\n\", \"20 11\\nlmmflflmlmflmfmflflm\\nmlmfmfllmfaflflmflml\\nlmlmfmfllmf\\n\", \"100 200\\ndddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd\\ndddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd\\ndddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd\\n\", \"100 100\\nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn\\nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn\\nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn\\n\", \"100 2\\ntttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt\\ntttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt\\ntt\\n\", \"100 20\\nrrrrrrprrjrrrhrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrerrwrrrrrrrrrrrrlrrrrrr\\nrrrrrrrrrrrrlrrrrkrrrrrrrrrrrrrrrrrrrrrrrrrqrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrcrrrrrrrr\\nrrrrrrrrrrrrrrrrrrrr\\n\", \"100 33\\nuuuluyguuuuuuuouuwuuumuuuuuuuuluuuvuuuuzfuuuuusuuuuuuuuuuuuuuuuuuuuuuuuduunuuuuuuhuuuuuuuueuuumuuumu\\nuueuuuuuuuuuuuuuzuuuuuuuuuuuuuuuuuuuduuuuuuuuuuuuuuouuuuuueuuuuaujuuruuuuuguuuuuuuuuuuuuuuuuuuuuuuuw\\nuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu\\n\", \"100 94\\nmkmkmmkmkmmkmmkmkmmkmkmmkmmkmkmmkmmkmkmmkmkmmkmmkmkmmkmkmmkmmkmkmmkmmkmkmmkmkmmkmmkmkmmkmmkmkmmkmkmm\\nkmkmkkmkmkkmkkmkmkkmkmkkmkkmkmkkmkkmkmkkmkmkkmkkmkmkkmkmkkmkkmkmkkmkkmkmkkmkmkkmkkmkmkkmkkmkmkkmkmkk\\nkmkmmkmkmmkmmkmkmmkmkmmkmmkmkmmkmmkmkmmkmkkmkmkkmkmkkmkkmkmkkmkmkkmkkmkmkkmkkmkmkkmkmkkmkkmkmk\\n\", \"100 136\\ncunhfnhfncunhfnhfncunhfncunhfnhfncunhfnhfncunhfncunhfnhfncunhfncunhfnhfncunhfnhfncunhfncunhfnhfncunh\\nhfncuncunhfncuncunhfncunhfncuncunhfncuncunhfncunhfncuncunhfncunhfncuncunhfncuncunhfncunhfncuncunhfnc\\nhfncunhfnhfncunhfnhfncunhfncunhfnhfncunhfncunhfnhfncunhfnhfncunhfncunhfnhfnhfncuncunhfncunhfncuncunhfncunhfncuncunhfncuncunhfncunhfncunc\\n\", \"100 24\\nzvahgmahgmzvahgmahgmzvahgmzvahgmahgmzvahgmahgmzvahgmzvahgmahgmzvahgmzvahgmahgmzvahgmahgmzvahgmzvahgm\\nzvahgmzvahgmzvzvahgmzvahgmzvzvahgmzvzvahgmzvahgmzvzvahgmzvahgmzvzvahgmzvzvahgmzvahgmzvzvahgmzvzvahgm\\ngmahgmzvahgmahgmzvahgmzv\\n\", \"99 105\\nanhrqanhrqanhranhrqanhrqanhranhrqanhranhrqanhrqanhranhrqanhrqanhranhaqanhranhrqanhrqanhranhrqanhran\\nqanhrqanhrqqanhrqanhrqqanhrqqanhrqanhrqqanhraanhrqqanhrqqanhrqanhrqqanhrqqanhrqanhrqqanhrqanhrqqanh\\nanhranhrqanhrqanhranhrqanhranhrqanhrqanhranhrqanhrqanhrqanhrqqanhrqqanhrqanhrqqanhrqanhrqqanhrqqanhrqanhr\\n\", \"100 10\\nedcfynedcfynedcfynedcfynedcfynegcfynedcfynedcfynedcfynedcfynedcfwnedcfynedcfynedcfynedcfynedcfynedcf\\nnedcfynedcfynedcfynedcfynedcfynedcfynedcfynedcfynedcfynedcfynedcfynedcfynedcfynedcfynedcfynedcdynedc\\nfynedcfyne\\n\", \"100 100\\nxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxb\\nxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxb\\nxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxbxb\\n\", \"100 133\\nsfdsfdsfdsfdsfdsfdsfdsfdsfdsfdsfdsfdsfdsfdsfdsfdsfdsfdsfdsfdsfdsfdsfdsfdsfdsfdsfdsfdsfdsfdsfdsfdsfds\\ndsfdsfdsfdsfdsfdsfdsfdsfdsfdsfdsfdsfdsfdsfdsfdsfdsfdsfdsfdsfdsfdsfdsfdsfdsfdsfdsfdsfdsfdsfdsfdsfdsfd\\nfdsfdsfdsfdsfdsfdsfdsfdsfdsfdsfdsfdsfdsfdsfdsfdsfdsfdsfdsfdsfdsfdsfdsfdsfdsfdsfdsfdsfdsfdsfdsfdsfdsfdsfdsfdsfdsfdsfdsfdsfdsfdsfdsfdsf\\n\", \"100 200\\noqbywigblumgeyvlesocpdrevxgyjgjjwzjldwjqeodthpjvygateqslhidczhwlaafovdjsdmzfyfiqoojsyszqjbrzlnqboets\\nxkxlxbmdzvtgplzpcepazuuuumwjmrftrlxbnawbeejiagywxssitkixdjdjfwthldtovkfzciaugahqexdwjnlummvtgbpawxbs\\noqbywigblumgeyvlesocpdrevxgyjgjjwzjldwjqeodthpjvygateqslhidczhwlaafovdjsdmzfyfiqoojsyszqjbrzlnqboetsxkxlxbmdzvtgplzpcepazuuuumwjmrftrlxbnawbeejiagywxssitkixdjdjfwthldtovkfzciaugahqexdwjnlummvtgbpawxbs\\n\", \"100 200\\nboyjrjoeozwqgxexhcuioymcmnkvctbmnmsycolzhooftwndexqtwbttuwwfttaxymqsjiihgsdjasaxycgoznjiorzfiwabmhsg\\nazrxzoqaombkfdlqocjgufzhtogekkfqqtkndjydeiulljvuwvtvyszrlnvumwbflyyhlqrnthiqmgoskrhzfktwcxdzidbyoqtn\\nboyjrjoeozwqgxexhcuioymcmnkvctbmnmsycolzhooftwndexqtwbttuwwfttaxymqsjiihgsdjasaxycgoznjiorzfiwabmhsgazrxzoqaombkfdlqocjgufzhtogekkzqqtkndjydeiulljvuwvtvyszrlnvumwbflyyhlqrnthiqmgoskrhzfktwcxdzidbyoqtn\\n\", \"100 33\\ncqcqqccqqcqccqqccqcqqcqccqcqqccqqcqccqcqqcqccqqccqcqqcqccqcqqccqqcqccqqccqcqqccqqcqccqcqqcqccqqccqcq\\ncqccqqccqcqqcqccqcqqccqqcqccqqccqcqqccqqcqccqcqqcqccqqccqcqqcqccqcqqccqqcqccqcqqcqccqqccqcqqccqqcqcc\\nqcqqccqqcqccqcqqcqccqqccqcqqcqccq\\n\", \"100 89\\nshpashpaypayshayshpyshpashpayhpaysayshpyshpashpayhpayspayshshpayhpayspayshayshpyshpahpayspayshayshpy\\nayspayshyshpashpayhpayspayshayshpshpayhpayspayshayshpyshpahpayspayshayshpyshpashpayayshpyshpashpayhp\\npayshayshpyshpashpayhpayspayshayshpyshpashpaypayshayshpyshpashpayhpaysayshpyshpashpayhpay\\n\", \"100 9\\nunujjnunujujnjnunujujnnujujnjnuujnjnunujnujujnjnuujnjnunujjnunujujnujnjnunujjnunujujnnujujnjnunujujn\\nnunujnujujnjnuujnjnunujjnunujujnujnjnunujjnunujujnnujujnjnujnunujujnnujujnjnuujnpnunujnujujnjnuujnjn\\njjnunujuj\\n\", \"50 100\\nejdbvpkfoymumiujhtplntndyfkkujqvkgipbrbycmwzawcely\\nyomcgzecbzkvaeziqmbkoknfavurydjupmsfnsthvdgookxfdx\\nejdbvpkfoymumiujhtplntndyfkkujqvkgipbrbycmwzawcelyyomcgzecbzkvaeziqmbkoknfavurydjupmsfnsthvdgookxfdx\\n\", \"50 100\\nclentmsedhhrdafyrzkgnzugyvncohjkrknsmljsnhuycjdczg\\nchkzmprhkklrijxswxbscgxoobsmfduyscbxnmsnabrddkritf\\nclentmsedhhrdafyrzkgnzugyvncohjkrknsmljsnhuycjdczgchkzmprhkklrijxswxbscgxoobnmfduyscbxnmsnabrddkritf\\n\", \"1 2\\nj\\nj\\njj\\n\"], \"outputs\": [\"4\\n\", \"11\\n\", \"2\\n\", \"1\\n\", \"1\\n\", \"560\\n\", \"20\\n\", \"561\\n\", \"3\\n\", \"3\\n\", \"1\\n\", \"0\\n\", \"126\\n\", \"1\\n\", \"0\\n\", \"13\\n\", \"1\\n\", \"0\\n\", \"4\\n\", \"14\\n\", \"0\\n\", \"4\\n\", \"10\\n\", \"1\\n\", \"176451\\n\", \"100\\n\", \"14414\\n\", \"40\\n\", \"10\\n\", \"2\\n\", \"98\\n\", \"0\\n\", \"120\\n\", \"45276\\n\", \"6072\\n\", \"1\\n\", \"0\\n\", \"112\\n\", \"0\\n\", \"23\\n\", \"1\\n\", \"0\\n\", \"1\\n\"]}", "source": "primeintellect"}
Vasya had three strings $a$, $b$ and $s$, which consist of lowercase English letters. The lengths of strings $a$ and $b$ are equal to $n$, the length of the string $s$ is equal to $m$. Vasya decided to choose a substring of the string $a$, then choose a substring of the string $b$ and concatenate them. Formally, he chooses a segment $[l_1, r_1]$ ($1 \leq l_1 \leq r_1 \leq n$) and a segment $[l_2, r_2]$ ($1 \leq l_2 \leq r_2 \leq n$), and after concatenation he obtains a string $a[l_1, r_1] + b[l_2, r_2] = a_{l_1} a_{l_1 + 1} \ldots a_{r_1} b_{l_2} b_{l_2 + 1} \ldots b_{r_2}$. Now, Vasya is interested in counting number of ways to choose those segments adhering to the following conditions: segments $[l_1, r_1]$ and $[l_2, r_2]$ have non-empty intersection, i.e. there exists at least one integer $x$, such that $l_1 \leq x \leq r_1$ and $l_2 \leq x \leq r_2$; the string $a[l_1, r_1] + b[l_2, r_2]$ is equal to the string $s$. -----Input----- The first line contains integers $n$ and $m$ ($1 \leq n \leq 500\,000, 2 \leq m \leq 2 \cdot n$) — the length of strings $a$ and $b$ and the length of the string $s$. The next three lines contain strings $a$, $b$ and $s$, respectively. The length of the strings $a$ and $b$ is $n$, while the length of the string $s$ is $m$. All strings consist of lowercase English letters. -----Output----- Print one integer — the number of ways to choose a pair of segments, which satisfy Vasya's conditions. -----Examples----- Input 6 5 aabbaa baaaab aaaaa Output 4 Input 5 4 azaza zazaz azaz Output 11 Input 9 12 abcabcabc xyzxyzxyz abcabcayzxyz Output 2 -----Note----- Let's list all the pairs of segments that Vasya could choose in the first example: $[2, 2]$ and $[2, 5]$; $[1, 2]$ and $[2, 4]$; $[5, 5]$ and $[2, 5]$; $[5, 6]$ and $[3, 5]$; Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0.625
{"tests": "{\"inputs\": [\"6\\n(?????\\n\", \"10\\n(???(???(?\\n\", \"4\\n))((\\n\", \"6\\n))??((\\n\", \"10\\n((?()??())\\n\", \"10\\n())))()(((\\n\", \"6\\n(?((??\\n\", \"18\\n?(?(?(?(?(?(?(?(??\\n\", \"18\\n??)??))?)?)???))))\\n\", \"18\\n((?((((???(??(????\\n\", \"2\\n??\\n\", \"1\\n?\\n\", \"4\\n????\\n\", \"6\\n((((??\\n\", \"6\\n??))))\\n\", \"8\\n(((?(?(?\\n\", \"30\\n?()????(????)???)??)?????????(\\n\", \"30\\n???(??)??(??)?(??()(?????(?)?(\\n\", \"30\\n((?(?????()?(?)???????)?)??(??\\n\", \"30\\n((??)?)???(????(????)???????((\\n\", \"30\\n???(???(?????(?????????((?????\\n\", \"300\\n)?)???????(?????????)??)??)?)??)??()???)??)??????????(?)???(?????)????????????????????)?????)???(???????)?????)?)??????????????))????(?)??????)???)?(?????????)?))???)???????????????))))???)???)????????(?())?????)????(??))???)????)??????)???)?)?????))???)??(?)??????????)??????)??????)????)?)?)??)??)?\\n\", \"300\\n???)??????(?)(????????((????????)????)????????????????)??)??)(?))???))??)?)(?)?????(???)?)?))?????????))??????????)???????????)??)?(????(????))?????))???(????)?)????)???)??))?(?(?))?)???)?????)??????????????)??)???)(????)????????)?)??))???)?)?)???((??)??(?)??)?????(??)?????????????????(?(??)????(?)(\\n\", \"300\\n????(??)?(???(???????????)?(??(?(????)????)????(??????????????????)?????(???)(??????????(???(?(?(((?)????(??)(??(?????)?)???????)??????(??)(??)???????(?()???????)???)???????????????))?(????)?(????(???)???????????)????????????)???)??(???????)???)??(?())????((?)??)(????)?)?)???(?????????(??????)(?)??(\\n\", \"300\\n??????(??????(???)??(???????)??????)((??????(???(??)())?(???????)???????????((??(??(??(?)???)(????)??(??(?(??(????????()?????(????(?(??(?(?????)??(????(????(??(??(????((??)(??(??????????????????(????????(????(?(???????(??(????(???)?(???????)?)??(?????((??(??(??????????()?????(??????)??(((??(????????\\n\", \"300\\n?(??(??????????(?????????(????(????)???????????((??????((??(???(?(((????(??((?((((??(?(?????(???????????)??)????????(?(????????(?(??(???????(???(???((???()?????(???????(?????(?????((?????????(??(????(????????((?????????((???????)?()????????(??????)???????????(??(??????(?(???????((????(?(?(??????(???\\n\", \"1\\n(\\n\", \"1\\n)\\n\", \"2\\n((\\n\", \"3\\n(()\\n\", \"3\\n))(\\n\", \"3\\n())\\n\", \"4\\n()()\\n\", \"4\\n((((\\n\", \"4\\n))))\\n\", \"4\\n)()(\\n\", \"4\\n(())\\n\", \"4\\n)??(\\n\", \"4\\n(??)\\n\", \"4\\n?)??\\n\", \"4\\n??(?\\n\", \"6\\n((?())\\n\"], \"outputs\": [\"((()))\\n\", \":(\\n\", \":(\\n\", \":(\\n\", \"(((()))())\\n\", \":(\\n\", \":(\\n\", \"(()()()()()()()())\\n\", \"(()(())()()((())))\\n\", \"((((((()))())())))\\n\", \"()\\n\", \":(\\n\", \"(())\\n\", \":(\\n\", \":(\\n\", \":(\\n\", \":(\\n\", \":(\\n\", \"(((((((((()((()()))))))))))())\\n\", \":(\\n\", \"(((((((((((()()))))))))(()))))\\n\", \":(\\n\", \":(\\n\", \":(\\n\", \"((((((((((((((((()(((((((((()(((((()((((((((((((((()())((((((((()((((((((((((((((((((((()((()((((()(((((((((((((((((((()((((((((()()())()())))))))())))())))())())())))(()))())())))))))))))))))))())))))))())))()()))))))())())))()))))())))))))))))()))))(())())())))))))))())))))()))))))))((())())))))))\\n\", \"((((((((((((((((((((((((((((((((((()(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((()(()((((((((((((())))))()())()))))))()))()))(()))())))))()))))))()))))()))))(()))))))))())())))())))))))(()))))))))(()))))))))()))))))))())))))))))))))))))())())))))()()))))))(())))()()())))))()))\\n\", \":(\\n\", \":(\\n\", \":(\\n\", \":(\\n\", \":(\\n\", \":(\\n\", \":(\\n\", \":(\\n\", \":(\\n\", \":(\\n\", \"(())\\n\", \":(\\n\", \"(())\\n\", \":(\\n\", \":(\\n\", \"(()())\\n\"]}", "source": "primeintellect"}
Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School. In his favorite math class, the teacher taught him the following interesting definitions. A parenthesis sequence is a string, containing only characters "(" and ")". A correct parenthesis sequence is a parenthesis sequence that can be transformed into a correct arithmetic expression by inserting characters "1" and "+" between the original characters of the sequence. For example, parenthesis sequences "()()", "(())" are correct (the resulting expressions are: "(1+1)+(1+1)", "((1+1)+1)"), while ")(" and ")" are not. Note that the empty string is a correct parenthesis sequence by definition. We define that $|s|$ as the length of string $s$. A strict prefix $s[1\dots l]$ $(1\leq l< |s|)$ of a string $s = s_1s_2\dots s_{|s|}$ is string $s_1s_2\dots s_l$. Note that the empty string and the whole string are not strict prefixes of any string by the definition. Having learned these definitions, he comes up with a new problem. He writes down a string $s$ containing only characters "(", ")" and "?". And what he is going to do, is to replace each of the "?" in $s$ independently by one of "(" and ")" to make all strict prefixes of the new sequence not a correct parenthesis sequence, while the new sequence should be a correct parenthesis sequence. After all, he is just a primary school student so this problem is too hard for him to solve. As his best friend, can you help him to replace the question marks? If there are many solutions, any of them is acceptable. -----Input----- The first line contains a single integer $|s|$ ($1\leq |s|\leq 3 \cdot 10^5$), the length of the string. The second line contains a string $s$, containing only "(", ")" and "?". -----Output----- A single line contains a string representing the answer. If there are many solutions, any of them is acceptable. If there is no answer, print a single line containing ":(" (without the quotes). -----Examples----- Input 6 (????? Output (()()) Input 10 (???(???(? Output :( -----Note----- It can be proved that there is no solution for the second sample, so print ":(". Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0
{"tests": "{\"inputs\": [\"1 1 5 5\\n\", \"-1 -3 1 3\\n\", \"-2 -2 2 2\\n\", \"0 0 2 2\\n\", \"0 0 2 0\\n\", \"0 0 0 0\\n\", \"0 -2 0 2\\n\", \"-2 -2 -2 0\\n\", \"-1000000000 -1000000000 1000000000 1000000000\\n\", \"-999999999 -999999999 999999999 999999999\\n\", \"-999999999 -999999999 -1 -1\\n\", \"-411495869 33834653 -234317741 925065545\\n\", \"-946749893 -687257665 -539044455 -443568671\\n\", \"-471257905 -685885153 782342299 909511043\\n\", \"-26644507 -867720841 975594569 264730225\\n\", \"-537640548 -254017710 62355638 588691834\\n\", \"309857887 -687373065 663986893 403321751\\n\", \"-482406510 -512306894 412844236 -168036050\\n\", \"-330513944 -970064382 500608496 369852884\\n\", \"-157778763 218978791 976692563 591093087\\n\", \"1000000000 1000000000 1000000000 1000000000\\n\", \"1 0 5 6\\n\", \"-1 -4 1 4\\n\", \"-2 -3 2 3\\n\", \"0 -1 2 3\\n\", \"0 -1 2 1\\n\", \"0 -1 0 1\\n\", \"0 -3 0 3\\n\", \"-2 -3 -2 1\\n\", \"-1000000000 -999999999 1000000000 999999999\\n\", \"-999999999 -1000000000 999999999 1000000000\\n\", \"-999999999 -1000000000 -1 0\\n\", \"-411495869 33834652 -234317741 925065546\\n\", \"-946749893 -687257666 -539044455 -443568670\\n\", \"-471257905 -685885154 782342299 909511044\\n\", \"-26644507 -867720842 975594569 264730226\\n\", \"-537640548 -254017711 62355638 588691835\\n\", \"309857887 -687373066 663986893 403321752\\n\", \"-482406510 -512306895 412844236 -168036049\\n\", \"-330513944 -970064383 500608496 369852885\\n\", \"-157778763 218978790 976692563 591093088\\n\", \"1000000000 999999999 1000000000 999999999\\n\"], \"outputs\": [\"13\", \"11\", \"13\", \"5\", \"2\", \"1\", \"3\", \"2\", \"2000000002000000001\", \"1999999998000000001\", \"499999999000000001\", \"78953311064369599\", \"49676664342971903\", \"999994499807710193\", \"567493356068872580\", \"252811256874252458\", \"193123336242128360\", \"154104365578285608\", \"556817654843544374\", \"211076500156631060\", \"1\", \"18\", \"14\", \"18\", \"8\", \"5\", \"2\", \"4\", \"3\", \"2000000000000000000\", \"2000000000000000000\", \"500000000000000000\", \"78953311241547728\", \"49676664750677342\", \"999994501061310398\", \"567493357071111657\", \"252811257474248645\", \"193123336596257367\", \"154104366473536355\", \"556817655674666815\", \"211076501291102387\", \"1\"]}", "source": "primeintellect"}
Developing tools for creation of locations maps for turn-based fights in a new game, Petya faced the following problem. A field map consists of hexagonal cells. Since locations sizes are going to be big, a game designer wants to have a tool for quick filling of a field part with identical enemy units. This action will look like following: a game designer will select a rectangular area on the map, and each cell whose center belongs to the selected rectangle will be filled with the enemy unit. More formally, if a game designer selected cells having coordinates (x_1, y_1) and (x_2, y_2), where x_1 ≤ x_2 and y_1 ≤ y_2, then all cells having center coordinates (x, y) such that x_1 ≤ x ≤ x_2 and y_1 ≤ y ≤ y_2 will be filled. Orthogonal coordinates system is set up so that one of cell sides is parallel to OX axis, all hexagon centers have integer coordinates and for each integer x there are cells having center with such x coordinate and for each integer y there are cells having center with such y coordinate. It is guaranteed that difference x_2 - x_1 is divisible by 2. Working on the problem Petya decided that before painting selected units he wants to output number of units that will be painted on the map. Help him implement counting of these units before painting. [Image] -----Input----- The only line of input contains four integers x_1, y_1, x_2, y_2 ( - 10^9 ≤ x_1 ≤ x_2 ≤ 10^9, - 10^9 ≤ y_1 ≤ y_2 ≤ 10^9) — the coordinates of the centers of two cells. -----Output----- Output one integer — the number of cells to be filled. -----Examples----- Input 1 1 5 5 Output 13 Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0
{"tests": "{\"inputs\": [\"8\\n4 4\\n1 3\\n3 1\\n\", \"8\\n4 4\\n2 3\\n1 6\\n\", \"8\\n3 5\\n1 2\\n6 1\\n\", \"1000\\n500 200\\n350 300\\n400 401\\n\", \"1000\\n600 600\\n700 653\\n650 701\\n\", \"999\\n999 999\\n998 1\\n1 998\\n\", \"3\\n1 1\\n3 2\\n2 3\\n\", \"50\\n2 3\\n1 1\\n50 50\\n\", \"75\\n16 12\\n75 75\\n1 1\\n\", \"75\\n16 12\\n75 1\\n1 75\\n\", \"4\\n1 2\\n4 1\\n4 4\\n\", \"4\\n1 2\\n4 3\\n4 4\\n\", \"4\\n1 2\\n3 1\\n4 1\\n\", \"4\\n2 3\\n3 1\\n4 2\\n\", \"20\\n5 10\\n7 7\\n8 8\\n\", \"20\\n9 10\\n12 16\\n13 17\\n\", \"20\\n11 10\\n18 12\\n12 18\\n\", \"20\\n11 10\\n12 18\\n18 11\\n\", \"1000\\n500 500\\n2 3\\n700 3\\n\", \"1000\\n500 500\\n893 450\\n891 449\\n\", \"1000\\n400 500\\n32 796\\n415 888\\n\", \"1000\\n350 112\\n372 113\\n352 113\\n\", \"3\\n2 3\\n1 1\\n3 1\\n\", \"1000\\n112 350\\n113 372\\n113 352\\n\", \"1000\\n114 350\\n113 372\\n113 352\\n\", \"1000\\n112 380\\n113 372\\n113 352\\n\", \"1000\\n114 372\\n112 350\\n113 352\\n\", \"1000\\n113 352\\n114 372\\n112 370\\n\", \"1000\\n112 350\\n113 352\\n113 372\\n\", \"5\\n5 4\\n1 5\\n1 3\\n\", \"5\\n3 3\\n4 1\\n5 2\\n\", \"100\\n2 6\\n1 3\\n3 4\\n\", \"5\\n5 2\\n3 3\\n3 1\\n\", \"5\\n2 4\\n1 2\\n3 2\\n\", \"10\\n1 2\\n2 4\\n2 5\\n\", \"1000\\n500 500\\n498 504\\n498 505\\n\", \"10\\n1 1\\n2 4\\n4 2\\n\", \"100\\n12 47\\n24 26\\n3 4\\n\", \"4\\n3 1\\n1 2\\n1 4\\n\", \"6\\n5 6\\n3 5\\n4 4\\n\", \"5\\n1 2\\n2 4\\n2 5\\n\", \"1000\\n500 2\\n498 502\\n498 499\\n\"], \"outputs\": [\"YES\\n\", \"NO\\n\", \"NO\\n\", \"YES\\n\", \"YES\\n\", \"YES\\n\", \"YES\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"YES\\n\", \"YES\\n\", \"YES\\n\", \"YES\\n\", \"YES\\n\", \"YES\\n\", \"YES\\n\", \"NO\\n\", \"YES\\n\", \"NO\\n\", \"YES\\n\", \"NO\\n\", \"YES\\n\", \"YES\\n\", \"YES\\n\", \"YES\\n\", \"NO\\n\", \"YES\\n\", \"NO\\n\", \"YES\\n\", \"NO\\n\", \"NO\\n\", \"NO\\n\", \"YES\\n\", \"YES\\n\", \"YES\\n\", \"NO\\n\", \"YES\\n\", \"YES\\n\", \"YES\\n\", \"YES\\n\"]}", "source": "primeintellect"}
Alice and Bob are playing chess on a huge chessboard with dimensions $n \times n$. Alice has a single piece left — a queen, located at $(a_x, a_y)$, while Bob has only the king standing at $(b_x, b_y)$. Alice thinks that as her queen is dominating the chessboard, victory is hers. But Bob has made a devious plan to seize the victory for himself — he needs to march his king to $(c_x, c_y)$ in order to claim the victory for himself. As Alice is distracted by her sense of superiority, she no longer moves any pieces around, and it is only Bob who makes any turns. Bob will win if he can move his king from $(b_x, b_y)$ to $(c_x, c_y)$ without ever getting in check. Remember that a king can move to any of the $8$ adjacent squares. A king is in check if it is on the same rank (i.e. row), file (i.e. column), or diagonal as the enemy queen. Find whether Bob can win or not. -----Input----- The first line contains a single integer $n$ ($3 \leq n \leq 1000$) — the dimensions of the chessboard. The second line contains two integers $a_x$ and $a_y$ ($1 \leq a_x, a_y \leq n$) — the coordinates of Alice's queen. The third line contains two integers $b_x$ and $b_y$ ($1 \leq b_x, b_y \leq n$) — the coordinates of Bob's king. The fourth line contains two integers $c_x$ and $c_y$ ($1 \leq c_x, c_y \leq n$) — the coordinates of the location that Bob wants to get to. It is guaranteed that Bob's king is currently not in check and the target location is not in check either. Furthermore, the king is not located on the same square as the queen (i.e. $a_x \neq b_x$ or $a_y \neq b_y$), and the target does coincide neither with the queen's position (i.e. $c_x \neq a_x$ or $c_y \neq a_y$) nor with the king's position (i.e. $c_x \neq b_x$ or $c_y \neq b_y$). -----Output----- Print "YES" (without quotes) if Bob can get from $(b_x, b_y)$ to $(c_x, c_y)$ without ever getting in check, otherwise print "NO". You can print each letter in any case (upper or lower). -----Examples----- Input 8 4 4 1 3 3 1 Output YES Input 8 4 4 2 3 1 6 Output NO Input 8 3 5 1 2 6 1 Output NO -----Note----- In the diagrams below, the squares controlled by the black queen are marked red, and the target square is marked blue. In the first case, the king can move, for instance, via the squares $(2, 3)$ and $(3, 2)$. Note that the direct route through $(2, 2)$ goes through check. [Image] In the second case, the queen watches the fourth rank, and the king has no means of crossing it. [Image] In the third case, the queen watches the third file. [Image] Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0.375
{"tests": "{\"inputs\": [\"6 7 1 6\\n1 2 2\\n1 3 10\\n2 3 7\\n2 4 8\\n3 5 3\\n4 5 2\\n5 6 1\\n\", \"3 3 1 3\\n1 2 10\\n2 3 10\\n1 3 100\\n\", \"2 2 1 2\\n1 2 1\\n1 2 2\\n\", \"2 1 1 2\\n1 2 1\\n\", \"3 3 1 3\\n1 2 10\\n2 3 10\\n1 3 19\\n\", \"4 3 1 4\\n1 2 1\\n2 3 1\\n3 4 1\\n\", \"4 4 1 4\\n1 2 1\\n2 3 1\\n3 4 1\\n1 3 2\\n\", \"4 4 1 4\\n1 2 1\\n2 3 1\\n3 4 1\\n1 3 1\\n\", \"6 6 1 6\\n1 2 2\\n2 3 4\\n2 4 3\\n3 5 2\\n4 5 3\\n5 6 10\\n\", \"6 6 1 6\\n1 2 2\\n2 3 3\\n2 4 3\\n3 5 2\\n4 5 3\\n5 6 10\\n\", \"2 1 1 2\\n1 2 1\\n\", \"2 2 1 2\\n1 2 6\\n1 2 6\\n\", \"2 3 1 2\\n1 2 7\\n1 2 7\\n1 2 7\\n\", \"2 10 1 2\\n1 2 5\\n1 2 5\\n1 2 7\\n1 2 5\\n1 2 6\\n1 2 5\\n1 2 5\\n1 2 6\\n1 2 5\\n1 2 6\\n\", \"3 2 1 2\\n3 2 3\\n1 3 6\\n\", \"3 3 1 3\\n2 3 7\\n2 3 7\\n1 2 6\\n\", \"3 4 3 1\\n2 1 4\\n2 1 2\\n3 2 1\\n2 1 2\\n\", \"3 5 1 2\\n1 3 3\\n1 2 9\\n3 2 6\\n1 2 10\\n1 3 3\\n\", \"3 7 1 3\\n1 3 11\\n1 3 12\\n1 2 2\\n1 3 11\\n1 2 2\\n2 3 9\\n2 3 9\\n\", \"5 7 3 2\\n5 4 8\\n3 1 2\\n1 2 20\\n1 5 8\\n4 2 4\\n1 5 8\\n5 4 9\\n\", \"7 8 5 3\\n4 3 5\\n7 1 8\\n2 1 16\\n2 7 7\\n2 6 21\\n5 2 10\\n6 4 4\\n1 6 5\\n\", \"6 8 1 6\\n1 2 13\\n3 2 3\\n4 5 6\\n1 6 28\\n1 3 10\\n1 4 18\\n2 4 4\\n5 6 4\\n\", \"7 10 4 7\\n6 3 9\\n2 1 4\\n3 7 3\\n5 2 6\\n1 3 12\\n5 2 6\\n4 5 4\\n4 5 3\\n1 6 3\\n4 6 16\\n\", \"10 13 2 10\\n7 3 5\\n6 1 10\\n9 6 4\\n4 10 48\\n9 5 2\\n1 10 3\\n5 6 2\\n7 6 19\\n4 8 8\\n2 4 8\\n8 7 7\\n7 6 20\\n3 9 10\\n\", \"4 4 1 4\\n1 2 1\\n2 3 1\\n3 4 1\\n1 4 3\\n\", \"5 6 1 5\\n1 2 2\\n2 5 5\\n2 3 4\\n1 4 1\\n4 3 3\\n3 5 1\\n\", \"5 6 1 5\\n1 2 2\\n2 5 5\\n2 3 4\\n1 4 1\\n4 3 3\\n3 5 1\\n\", \"2 1 1 2\\n1 2 1\\n\", \"3 3 1 3\\n1 2 1\\n1 3 2\\n2 3 1\\n\", \"10 10 1 10\\n1 5 178\\n1 8 221\\n2 7 92\\n2 8 159\\n3 5 55\\n3 6 179\\n3 10 237\\n4 8 205\\n5 6 191\\n8 10 157\\n\", \"10 10 1 10\\n1 4 201\\n2 3 238\\n3 4 40\\n3 6 231\\n3 8 45\\n4 5 227\\n4 6 58\\n4 9 55\\n5 7 14\\n6 10 242\\n\", \"3 3 1 3\\n1 2 1\\n2 3 1\\n1 3 2\\n\", \"6 7 1 6\\n1 2 1000000\\n2 3 1000000\\n2 5 1000000\\n1 3 1000000\\n3 5 1000000\\n2 4 1000000\\n5 6 1000000\\n\", \"2 1 1 2\\n1 2 1000000\\n\", \"2 2 1 2\\n1 2 1000000\\n1 2 1000000\\n\", \"2 2 1 2\\n1 2 1000000\\n1 2 1000000\\n\", \"2 9 1 2\\n1 2 1000000\\n1 2 1000000\\n1 2 1000000\\n1 2 1000000\\n1 2 1\\n1 2 1000000\\n1 2 1000000\\n1 2 1000000\\n1 2 1000000\\n\", \"2 9 1 2\\n1 2 1000000\\n1 2 1000000\\n1 2 1000000\\n1 2 1000000\\n1 2 2\\n1 2 1000000\\n1 2 1000000\\n1 2 1000000\\n1 2 1000000\\n\", \"3 2 1 3\\n1 3 1\\n1 2 1\\n\", \"4 5 1 4\\n1 2 1\\n1 2 1\\n2 3 1\\n3 4 1\\n3 4 1\\n\", \"3 3 1 3\\n1 2 666\\n2 3 555\\n3 1 1\\n\"], \"outputs\": [\"YES\\nCAN 2\\nCAN 1\\nCAN 1\\nCAN 1\\nCAN 1\\nYES\\n\", \"YES\\nYES\\nCAN 81\\n\", \"YES\\nNO\\n\", \"YES\\n\", \"CAN 2\\nCAN 2\\nYES\\n\", \"YES\\nYES\\nYES\\n\", \"NO\\nNO\\nYES\\nCAN 1\\n\", \"NO\\nNO\\nYES\\nYES\\n\", \"YES\\nCAN 1\\nCAN 1\\nCAN 1\\nCAN 1\\nYES\\n\", \"YES\\nYES\\nCAN 2\\nYES\\nCAN 2\\nYES\\n\", \"YES\\n\", \"CAN 1\\nCAN 1\\n\", \"CAN 1\\nCAN 1\\nCAN 1\\n\", \"CAN 1\\nCAN 1\\nCAN 3\\nCAN 1\\nCAN 2\\nCAN 1\\nCAN 1\\nCAN 2\\nCAN 1\\nCAN 2\\n\", \"YES\\nYES\\n\", \"CAN 1\\nCAN 1\\nYES\\n\", \"CAN 3\\nCAN 1\\nYES\\nCAN 1\\n\", \"CAN 1\\nCAN 1\\nCAN 1\\nCAN 2\\nCAN 1\\n\", \"CAN 1\\nCAN 2\\nCAN 1\\nCAN 1\\nCAN 1\\nCAN 1\\nCAN 1\\n\", \"CAN 1\\nYES\\nCAN 1\\nCAN 1\\nCAN 1\\nCAN 1\\nCAN 2\\n\", \"YES\\nYES\\nCAN 2\\nYES\\nCAN 2\\nYES\\nYES\\nYES\\n\", \"CAN 1\\nCAN 1\\nYES\\nCAN 2\\nCAN 1\\nCAN 2\\nYES\\nYES\\n\", \"CAN 1\\nCAN 1\\nYES\\nCAN 1\\nCAN 1\\nCAN 1\\nCAN 2\\nCAN 1\\nCAN 1\\nCAN 1\\n\", \"CAN 1\\nYES\\nCAN 1\\nCAN 2\\nCAN 1\\nYES\\nCAN 1\\nCAN 1\\nYES\\nYES\\nYES\\nCAN 2\\nCAN 1\\n\", \"NO\\nNO\\nNO\\nCAN 1\\n\", \"NO\\nCAN 3\\nCAN 3\\nYES\\nYES\\nYES\\n\", \"NO\\nCAN 3\\nCAN 3\\nYES\\nYES\\nYES\\n\", \"YES\\n\", \"NO\\nCAN 1\\nNO\\n\", \"NO\\nYES\\nNO\\nNO\\nNO\\nNO\\nNO\\nNO\\nNO\\nYES\\n\", \"YES\\nNO\\nNO\\nNO\\nNO\\nNO\\nYES\\nNO\\nNO\\nYES\\n\", \"NO\\nNO\\nCAN 1\\n\", \"CAN 1\\nNO\\nCAN 1\\nCAN 1\\nCAN 1\\nNO\\nYES\\n\", \"YES\\n\", \"CAN 1\\nCAN 1\\n\", \"CAN 1\\nCAN 1\\n\", \"NO\\nNO\\nNO\\nNO\\nYES\\nNO\\nNO\\nNO\\nNO\\n\", \"CAN 999999\\nCAN 999999\\nCAN 999999\\nCAN 999999\\nYES\\nCAN 999999\\nCAN 999999\\nCAN 999999\\nCAN 999999\\n\", \"YES\\nNO\\n\", \"NO\\nNO\\nYES\\nNO\\nNO\\n\", \"YES\\nYES\\nNO\\n\"]}", "source": "primeintellect"}
Berland has n cities, the capital is located in city s, and the historic home town of the President is in city t (s ≠ t). The cities are connected by one-way roads, the travel time for each of the road is a positive integer. Once a year the President visited his historic home town t, for which his motorcade passes along some path from s to t (he always returns on a personal plane). Since the president is a very busy man, he always chooses the path from s to t, along which he will travel the fastest. The ministry of Roads and Railways wants to learn for each of the road: whether the President will definitely pass through it during his travels, and if not, whether it is possible to repair it so that it would definitely be included in the shortest path from the capital to the historic home town of the President. Obviously, the road can not be repaired so that the travel time on it was less than one. The ministry of Berland, like any other, is interested in maintaining the budget, so it wants to know the minimum cost of repairing the road. Also, it is very fond of accuracy, so it repairs the roads so that the travel time on them is always a positive integer. -----Input----- The first lines contain four integers n, m, s and t (2 ≤ n ≤ 10^5; 1 ≤ m ≤ 10^5; 1 ≤ s, t ≤ n) — the number of cities and roads in Berland, the numbers of the capital and of the Presidents' home town (s ≠ t). Next m lines contain the roads. Each road is given as a group of three integers a_{i}, b_{i}, l_{i} (1 ≤ a_{i}, b_{i} ≤ n; a_{i} ≠ b_{i}; 1 ≤ l_{i} ≤ 10^6) — the cities that are connected by the i-th road and the time needed to ride along it. The road is directed from city a_{i} to city b_{i}. The cities are numbered from 1 to n. Each pair of cities can have multiple roads between them. It is guaranteed that there is a path from s to t along the roads. -----Output----- Print m lines. The i-th line should contain information about the i-th road (the roads are numbered in the order of appearance in the input). If the president will definitely ride along it during his travels, the line must contain a single word "YES" (without the quotes). Otherwise, if the i-th road can be repaired so that the travel time on it remains positive and then president will definitely ride along it, print space-separated word "CAN" (without the quotes), and the minimum cost of repairing. If we can't make the road be such that president will definitely ride along it, print "NO" (without the quotes). -----Examples----- Input 6 7 1 6 1 2 2 1 3 10 2 3 7 2 4 8 3 5 3 4 5 2 5 6 1 Output YES CAN 2 CAN 1 CAN 1 CAN 1 CAN 1 YES Input 3 3 1 3 1 2 10 2 3 10 1 3 100 Output YES YES CAN 81 Input 2 2 1 2 1 2 1 1 2 2 Output YES NO -----Note----- The cost of repairing the road is the difference between the time needed to ride along it before and after the repairing. In the first sample president initially may choose one of the two following ways for a ride: 1 → 2 → 4 → 5 → 6 or 1 → 2 → 3 → 5 → 6. Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0
{"tests": "{\"inputs\": [\"3\\n1 2\\n1 3\\n\", \"5\\n1 2\\n1 3\\n2 4\\n2 5\\n\", \"2\\n1 2\\n\", \"4\\n1 3\\n1 4\\n1 2\\n\", \"4\\n2 1\\n1 3\\n3 4\\n\", \"4\\n4 3\\n3 2\\n2 1\\n\", \"5\\n2 1\\n2 3\\n2 4\\n2 5\\n\", \"5\\n4 5\\n4 1\\n1 2\\n2 3\\n\", \"5\\n1 4\\n4 3\\n3 2\\n2 5\\n\", \"6\\n4 5\\n4 1\\n4 6\\n4 2\\n4 3\\n\", \"6\\n6 5\\n6 2\\n2 3\\n5 4\\n4 1\\n\", \"6\\n1 5\\n5 4\\n4 2\\n2 6\\n6 3\\n\", \"7\\n7 5\\n7 3\\n7 6\\n7 4\\n7 1\\n7 2\\n\", \"7\\n7 6\\n7 5\\n7 2\\n7 1\\n5 4\\n5 3\\n\", \"7\\n2 7\\n7 6\\n6 5\\n5 4\\n4 1\\n1 3\\n\", \"8\\n8 6\\n8 7\\n8 2\\n8 5\\n8 1\\n8 4\\n8 3\\n\", \"8\\n6 3\\n3 7\\n6 1\\n1 2\\n3 5\\n5 4\\n2 8\\n\", \"8\\n4 1\\n1 3\\n3 6\\n6 2\\n2 7\\n7 5\\n5 8\\n\", \"9\\n3 2\\n3 1\\n3 8\\n3 5\\n3 6\\n3 9\\n3 4\\n3 7\\n\", \"9\\n2 6\\n6 1\\n2 8\\n6 7\\n1 5\\n7 3\\n8 9\\n5 4\\n\", \"9\\n9 4\\n4 6\\n6 2\\n2 1\\n1 3\\n3 5\\n5 8\\n8 7\\n\", \"10\\n3 2\\n3 7\\n3 6\\n3 8\\n3 1\\n3 5\\n3 9\\n3 4\\n3 10\\n\", \"10\\n8 2\\n8 10\\n10 3\\n2 4\\n3 6\\n8 1\\n2 7\\n10 9\\n4 5\\n\", \"10\\n7 10\\n10 6\\n6 4\\n4 5\\n5 8\\n8 2\\n2 1\\n1 3\\n3 9\\n\", \"4\\n3 4\\n4 1\\n1 2\\n\", \"5\\n1 4\\n4 2\\n2 3\\n3 5\\n\", \"6\\n5 3\\n3 6\\n6 1\\n1 4\\n4 2\\n\", \"7\\n1 2\\n2 3\\n3 6\\n6 7\\n7 4\\n4 5\\n\", \"8\\n6 2\\n2 1\\n1 8\\n8 5\\n5 7\\n7 3\\n3 4\\n\", \"9\\n1 6\\n6 4\\n4 5\\n5 9\\n9 8\\n8 7\\n7 3\\n3 2\\n\", \"10\\n5 1\\n1 6\\n6 2\\n2 8\\n8 3\\n3 4\\n4 10\\n10 9\\n9 7\\n\", \"4\\n3 4\\n3 1\\n3 2\\n\", \"5\\n1 4\\n1 2\\n1 3\\n1 5\\n\", \"6\\n5 3\\n5 6\\n5 1\\n5 4\\n5 2\\n\", \"7\\n1 2\\n1 3\\n1 6\\n1 7\\n1 4\\n1 5\\n\", \"8\\n6 2\\n6 1\\n6 8\\n6 5\\n6 7\\n6 3\\n6 4\\n\", \"9\\n1 6\\n1 4\\n1 5\\n1 9\\n1 8\\n1 7\\n1 3\\n1 2\\n\", \"10\\n5 1\\n5 6\\n5 2\\n5 8\\n5 3\\n5 4\\n5 10\\n5 9\\n5 7\\n\", \"10\\n4 10\\n10 5\\n5 1\\n1 6\\n6 8\\n8 9\\n9 2\\n9 3\\n9 7\\n\", \"10\\n5 8\\n8 4\\n4 9\\n9 6\\n6 1\\n6 2\\n6 7\\n6 3\\n6 10\\n\", \"10\\n5 6\\n6 7\\n7 3\\n7 8\\n7 4\\n7 2\\n7 1\\n7 10\\n7 9\\n\"], \"outputs\": [\"3\\n2 3 3\\n2 1 1\\n\", \"9\\n3 5 5\\n4 3 3\\n4 1 1\\n4 2 2\\n\", \"1\\n2 1 1\\n\", \"5\\n3 4 4\\n2 3 3\\n2 1 1\\n\", \"6\\n4 2 2\\n4 1 1\\n4 3 3\\n\", \"6\\n4 1 1\\n4 2 2\\n4 3 3\\n\", \"7\\n1 4 4\\n1 5 5\\n3 1 1\\n3 2 2\\n\", \"10\\n3 5 5\\n3 4 4\\n3 1 1\\n3 2 2\\n\", \"10\\n5 1 1\\n5 4 4\\n5 3 3\\n5 2 2\\n\", \"9\\n1 5 5\\n1 6 6\\n1 3 3\\n2 1 1\\n2 4 4\\n\", \"15\\n3 1 1\\n3 4 4\\n3 5 5\\n3 6 6\\n3 2 2\\n\", \"15\\n3 1 1\\n3 5 5\\n3 4 4\\n3 2 2\\n3 6 6\\n\", \"11\\n1 5 5\\n1 3 3\\n1 6 6\\n1 4 4\\n2 1 1\\n2 7 7\\n\", \"15\\n3 6 6\\n3 2 2\\n1 4 4\\n3 1 1\\n3 7 7\\n3 5 5\\n\", \"21\\n2 3 3\\n2 1 1\\n2 4 4\\n2 5 5\\n2 6 6\\n2 7 7\\n\", \"13\\n1 6 6\\n1 7 7\\n1 5 5\\n1 4 4\\n1 3 3\\n2 1 1\\n2 8 8\\n\", \"26\\n8 7 7\\n4 8 8\\n4 2 2\\n4 1 1\\n4 6 6\\n4 3 3\\n4 5 5\\n\", \"28\\n8 4 4\\n8 1 1\\n8 3 3\\n8 6 6\\n8 2 2\\n8 7 7\\n8 5 5\\n\", \"15\\n1 8 8\\n1 5 5\\n1 6 6\\n1 9 9\\n1 4 4\\n1 7 7\\n2 1 1\\n2 3 3\\n\", \"30\\n4 3 3\\n4 7 7\\n9 4 4\\n9 5 5\\n9 1 1\\n9 6 6\\n9 2 2\\n9 8 8\\n\", \"36\\n7 9 9\\n7 4 4\\n7 6 6\\n7 2 2\\n7 1 1\\n7 3 3\\n7 5 5\\n7 8 8\\n\", \"17\\n1 7 7\\n1 6 6\\n1 8 8\\n1 5 5\\n1 9 9\\n1 4 4\\n1 10 10\\n2 1 1\\n2 3 3\\n\", \"35\\n5 9 9\\n6 1 1\\n6 7 7\\n5 6 6\\n5 3 3\\n5 10 10\\n5 8 8\\n5 2 2\\n5 4 4\\n\", \"45\\n7 9 9\\n7 3 3\\n7 1 1\\n7 2 2\\n7 8 8\\n7 5 5\\n7 4 4\\n7 6 6\\n7 10 10\\n\", \"6\\n3 2 2\\n3 1 1\\n3 4 4\\n\", \"10\\n5 1 1\\n5 4 4\\n5 2 2\\n5 3 3\\n\", \"15\\n5 2 2\\n5 4 4\\n5 1 1\\n5 6 6\\n5 3 3\\n\", \"21\\n5 1 1\\n5 2 2\\n5 3 3\\n5 6 6\\n5 7 7\\n5 4 4\\n\", \"28\\n4 6 6\\n4 2 2\\n4 1 1\\n4 8 8\\n4 5 5\\n4 7 7\\n4 3 3\\n\", \"36\\n2 1 1\\n2 6 6\\n2 4 4\\n2 5 5\\n2 9 9\\n2 8 8\\n2 7 7\\n2 3 3\\n\", \"45\\n7 5 5\\n7 1 1\\n7 6 6\\n7 2 2\\n7 8 8\\n7 3 3\\n7 4 4\\n7 10 10\\n7 9 9\\n\", \"5\\n1 4 4\\n2 1 1\\n2 3 3\\n\", \"7\\n3 4 4\\n3 5 5\\n2 3 3\\n2 1 1\\n\", \"9\\n1 3 3\\n1 6 6\\n1 4 4\\n2 1 1\\n2 5 5\\n\", \"11\\n3 6 6\\n3 7 7\\n3 4 4\\n3 5 5\\n2 3 3\\n2 1 1\\n\", \"13\\n1 8 8\\n1 5 5\\n1 7 7\\n1 3 3\\n1 4 4\\n2 1 1\\n2 6 6\\n\", \"15\\n3 6 6\\n3 4 4\\n3 5 5\\n3 9 9\\n3 8 8\\n3 7 7\\n2 3 3\\n2 1 1\\n\", \"17\\n1 6 6\\n1 8 8\\n1 3 3\\n1 4 4\\n1 10 10\\n1 9 9\\n1 7 7\\n2 1 1\\n2 5 5\\n\", \"42\\n4 3 3\\n4 7 7\\n2 4 4\\n2 10 10\\n2 5 5\\n2 1 1\\n2 6 6\\n2 8 8\\n2 9 9\\n\", \"35\\n5 2 2\\n5 7 7\\n5 3 3\\n5 10 10\\n5 1 1\\n5 6 6\\n5 9 9\\n5 4 4\\n5 8 8\\n\", \"24\\n5 3 3\\n5 8 8\\n5 4 4\\n5 2 2\\n5 10 10\\n5 9 9\\n5 1 1\\n5 7 7\\n5 6 6\\n\"]}", "source": "primeintellect"}
You are given an unweighted tree with n vertices. Then n - 1 following operations are applied to the tree. A single operation consists of the following steps: choose two leaves; add the length of the simple path between them to the answer; remove one of the chosen leaves from the tree. Initial answer (before applying operations) is 0. Obviously after n - 1 such operations the tree will consist of a single vertex. Calculate the maximal possible answer you can achieve, and construct a sequence of operations that allows you to achieve this answer! -----Input----- The first line contains one integer number n (2 ≤ n ≤ 2·10^5) — the number of vertices in the tree. Next n - 1 lines describe the edges of the tree in form a_{i}, b_{i} (1 ≤ a_{i}, b_{i} ≤ n, a_{i} ≠ b_{i}). It is guaranteed that given graph is a tree. -----Output----- In the first line print one integer number — maximal possible answer. In the next n - 1 lines print the operations in order of their applying in format a_{i}, b_{i}, c_{i}, where a_{i}, b_{i} — pair of the leaves that are chosen in the current operation (1 ≤ a_{i}, b_{i} ≤ n), c_{i} (1 ≤ c_{i} ≤ n, c_{i} = a_{i} or c_{i} = b_{i}) — choosen leaf that is removed from the tree in the current operation. See the examples for better understanding. -----Examples----- Input 3 1 2 1 3 Output 3 2 3 3 2 1 1 Input 5 1 2 1 3 2 4 2 5 Output 9 3 5 5 4 3 3 4 1 1 4 2 2 Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0
{"tests": "{\"inputs\": [\"5\\n3 7 9 7 8\\n5 2 5 7 5\\n\", \"5\\n1 2 3 4 5\\n1 1 1 1 1\\n\", \"5\\n12 4 19 18 19\\n15467 14873 66248 58962 90842\\n\", \"40\\n19 20 8 13 13 17 1 14 15 20 14 17 2 9 9 10 19 16 6 12 9 7 20 5 12 6 4 4 12 5 4 11 8 1 2 8 11 19 18 4\\n52258 5648 46847 9200 63940 79328 64407 54479 1788 60107 8234 64215 15419 84411 50307 78075 92548 17867 43456 7970 1390 99373 97297 90662 82950 678 79356 51351 2794 82477 16508 19254 81295 9711 72350 11578 21595 69230 82626 25134\\n\", \"1\\n204\\n74562\\n\", \"1\\n1\\n72\\n\", \"1\\n1\\n40825\\n\", \"1\\n5\\n16\\n\", \"1\\n4\\n85648\\n\", \"1\\n3\\n31\\n\", \"1\\n23\\n29532\\n\", \"1\\n743365444\\n98\\n\", \"1\\n380100964\\n63923\\n\", \"1\\n1000000000\\n100000\\n\", \"2\\n5 3\\n96 59\\n\", \"2\\n3 2\\n55839 83916\\n\", \"2\\n8 4\\n57 28\\n\", \"2\\n7 6\\n2374 9808\\n\", \"2\\n84 18\\n96 92\\n\", \"2\\n86 67\\n77701 9079\\n\", \"2\\n624526990 51492804\\n74 4\\n\", \"2\\n759394108 613490963\\n19556 57005\\n\", \"2\\n1000000000 1000000000\\n100000 100000\\n\", \"5\\n4 2 4 3 3\\n8 9 34 54 14\\n\", \"5\\n1 5 1 2 1\\n49027 92184 18591 86401 84238\\n\", \"5\\n8 2 3 10 1\\n2 37 19 73 60\\n\", \"5\\n3 10 9 5 8\\n12157 40766 83283 22455 29741\\n\", \"5\\n2 52 60 67 26\\n51 96 75 41 88\\n\", \"5\\n82 90 21 10 3\\n37195 83314 87379 83209 32491\\n\", \"5\\n298137706 371378543 159326899 423775489 643749813\\n1 90 76 23 14\\n\", \"5\\n487208130 193137490 653652531 77955217 628457798\\n37995 12724 66478 45619 87697\\n\", \"5\\n1000000000 1000000000 1000000000 1000000000 1000000000\\n100000 100000 100000 100000 100000\\n\", \"10\\n4 4 1 2 2 2 5 4 1 5\\n28 81 36 44 2 40 39 43 36 33\\n\", \"10\\n1 4 2 3 5 1 3 5 4 2\\n95757 10134 79392 48220 34450 34587 61472 88154 76492 38800\\n\", \"10\\n2 2 2 6 4 4 10 2 2 8\\n18 13 94 43 72 62 23 47 94 41\\n\", \"10\\n2 5 1 9 1 2 7 8 1 10\\n38888 43309 35602 62895 51161 96523 20607 20309 21976 21231\\n\", \"10\\n14 31 50 67 42 44 86 82 35 63\\n76 17 26 44 60 54 50 73 71 70\\n\", \"10\\n97 75 68 98 56 44 68 24 40 18\\n75753 53146 17573 59200 87853 73083 67536 45475 70260 99681\\n\", \"10\\n69564153 558821634 273092444 121621442 354953668 157021146 918149509 902159900 772175415 945981912\\n29 26 22 78 90 35 24 75 52 53\\n\", \"10\\n400625724 498124775 960958038 697226708 233136478 292118728 33139194 339478293 914271877 828083523\\n9789 90524 51162 97707 59267 60261 43260 60358 64419 44097\\n\", \"10\\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000\\n100000 100000 100000 100000 100000 100000 100000 100000 100000 100000\\n\"], \"outputs\": [\"6\\n\", \"0\\n\", \"66248\\n\", \"6113465\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"100000\\n\", \"44\\n\", \"153827\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"1000000\\n\", \"593\\n\", \"779373\\n\", \"630\\n\", \"255574\\n\", \"0\\n\", \"17573\\n\", \"0\\n\", \"0\\n\", \"4500000\\n\"]}", "source": "primeintellect"}
VK news recommendation system daily selects interesting publications of one of $n$ disjoint categories for each user. Each publication belongs to exactly one category. For each category $i$ batch algorithm selects $a_i$ publications. The latest A/B test suggests that users are reading recommended publications more actively if each category has a different number of publications within daily recommendations. The targeted algorithm can find a single interesting publication of $i$-th category within $t_i$ seconds. What is the minimum total time necessary to add publications to the result of batch algorithm execution, so all categories have a different number of publications? You can't remove publications recommended by the batch algorithm. -----Input----- The first line of input consists of single integer $n$ — the number of news categories ($1 \le n \le 200\,000$). The second line of input consists of $n$ integers $a_i$ — the number of publications of $i$-th category selected by the batch algorithm ($1 \le a_i \le 10^9$). The third line of input consists of $n$ integers $t_i$ — time it takes for targeted algorithm to find one new publication of category $i$ ($1 \le t_i \le 10^5)$. -----Output----- Print one integer — the minimal required time for the targeted algorithm to get rid of categories with the same size. -----Examples----- Input 5 3 7 9 7 8 5 2 5 7 5 Output 6 Input 5 1 2 3 4 5 1 1 1 1 1 Output 0 -----Note----- In the first example, it is possible to find three publications of the second type, which will take 6 seconds. In the second example, all news categories contain a different number of publications. Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0
{"tests": "{\"inputs\": [\"10\\n()()())(()\\n\", \"12\\n)(()(()())()\\n\", \"6\\n)))(()\\n\", \"10\\n(()(()))()\\n\", \"26\\n((()))(()()()()()()()()())\\n\", \"1\\n(\\n\", \"499\\n)(()))))(())(((())())()()(())))(()))))(())))()())()(((((()))()(())()()((()()(()())())))()(())()))())(())()(())))))((())()(((()))(())(()(())(()((()))()()((())()()))()((((()()((()))(()())()()(())((()())(()()()(()(()))(()(((()(())(()))())(((()()(((())((()()((((())(()(()((())(((()()()))(((()()))()(()()))))))((((((((()(((()()())(()))(()())))()))())())(((()))())))(())(()))()(((((()))())())))))())))()()(()()))(())())(())((((()(()())(()()()))())(()()(()()))((()(())()((()()())()()(())))(()()()(()())(())\\n\", \"500\\n)())))()((()))(((()()))())(()((()())((()))(()))())((((()(()())()())))())()()(()(((((())()))())))()()(((()()())))()()(()(()))()(()(()()(()()()()))())()((()(()())))(((())()))(((())))(((()(())(())))()())((((()))()))()((((())))()())((()()()())())()()()(((()(((()))())))())()((((()(())(()(()))))))((((()())(())()())))((((())()(()))))((()(()(()))))((((())(()))))((((())())))()(((()())))(()(((())(())()()))())(((()())))(()(()()))(()((()()()())))()((()(()())))()()(()((()(()()()()()))))((((())(()())))())((((\\n\", \"500\\n)))(()(()())))))())()))(((()(()())(((()())(((()(((((())))))))))())())))()(((()))(((()())()()))))))()()()()()()()()()()()()()()()()()()()()()()()())(()()()()()()()()()()()()()()()()()(()(()(()))(((((()))(()())))((())((((((()(((((())))(()))())(())(()()(())())())(())()))(((()())((((())((()()((((())))))()())((()(()())()))()(()())((()))))()(()))(((()())((())()(()))()(()()))(())(()((()()))()())())))()))(()())))))()()()())(()((())(()(((()()((()(())((())()(()())()()()((()(())()())((())((()())))()(((()()\\n\", \"500\\n)())(()(((())))))))(()((())()(()()((())))))()()()()()(((())((())(()())(()()()))))(((((()())((()()(())))))))((((((()))()()(())())((())))))()()()()(()((()()()((()()((((()(()))))()))))))()(((()(((((())))()(())((()))))()()()((()(())))))())(()(((())()(((()))()()(()))((()))())))()(()(()((()(())(())(())))))()()((((((()(()))))(((()))())((((()((())))))(())))))((()(()(()((())(()()()))))))()(((((((())()())(())())(()()(()))())(()))))()(((()()((((())((())))()))(()))())())()(()()(()(((()()()())((((())()(())))\\n\", \"500\\n(((()(()))()()()))())(()(()))((()()()()(()()))())(((())((())()()()())))((()(()()())()()))()(()(((())(())()))())()(((()(()))))()()()()(((((()))))())()((((()))()))()((()()()()))(((()((()())))))()((()((())())))()()()((())())()(((()()()()())))(()())()()((((()()(())()()()()))))()((((()))((())())))((((())))())(()(((())())))((()((()((()))()))))((()()(()))()())((()))((()(()(())()))())(()(((((())(()))()))))()((((()()())))()())(()((((())))))()((((()(())())))())(()((()(()(()))))())()(((()((()())))))()()()(\\n\", \"500\\n())()(((())))()()()()()(())()()((()))(((())))()()()()()()()(()())()()((()()))()(((()())))(()()())()()()()(((()))())()()()()()((())())()()(((())))()()()()(())()()()()((()))()()()()()()()((()))()()()((()))(((()())))()((((()))))(((())))(())(())()()()(())()(())(()())()()(()(((()))))()()()()()(((())))()()()()()()((()))()()((()))((((((()))))))()()()()(((((())))))()()()()((())())()()()()()((()))()(())(()())()()()(((())))(())()()()()()()()()()()(()())()()(())()()()()()()(()(()))()()()()()()((()(())))()(\\n\", \"500\\n(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((())))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((\\n\", \"500\\n(()()())))))))((((()())(((()((())())(((()()))(()((()))((()()((())())(((()())))()(((((()())))()))(((((()((((())((()(())()(())((()))()))((()(()()))))((((()()())()())()))()(((((()))(((((())(()(((()()()((()(())))))))(()((()))(((((((())))()())((((()))()()()))()(((()))())())()()()()(())(()((()))(()))))()()((((()(()(())((((())()(()))()((()(()()))))))))(()()())()))(())())()()()))()(())))()))(())))())()()))))((()()))))())(()()))()()()()()())(())()(()()(((((()(())((())())())(()()(()(()()())))))(()))())())\\n\", \"500\\n)(((())(()(()()())()()()))()(())((())))(((((()(()()())()()()))))())((((()))()))()()())))(()((()(()((()))(())()()(()())(()())()()(()))))(()(())()()))()(()))((()))))())((()()))()(())))(()(()(((((())()))()())())()((())()))))(()(()))()(((()(())(())))))()(()())((()(())())()(((()((((())())))))()())()(()((()(()()()()()()())((()(()()((()))()(()()())))((((())())()))()(()(())()()((()()())((()()())((()()((())))()))(((())))((()(()))()()()()()(())())(()()())(())())(())((()())(())(())))()()))()))))()()())(())\\n\", \"500\\n)()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()(\\n\", \"4\\n))((\\n\", \"4\\n()()\\n\", \"4\\n)()(\\n\", \"10\\n(())())()(\\n\", \"10\\n))))((((()\\n\", \"10\\n())(((()))\\n\", \"11\\n)(())(((())\\n\", \"10\\n)()()()()(\\n\", \"50\\n()())()))()())((())))(((((()))(((()))((((()(()))))\\n\", \"51\\n))((((((((()))(())()(()(()())()(()(())(())()())))))\\n\", \"50\\n)()()()()()()()()()()()()()()()()()()()()()()()()(\\n\", \"50\\n(((((((((((((((((((((((()))))))))))))))))))))))))(\\n\", \"100\\n)))))))(((((((((((((((((((((((((((((((((((((((((((((((((()))))))))))))))))))))))))))))))))))))))))))\\n\", \"100\\n)(((((()())((())((())((()))())))))(())())()((())))(()()))(((((((()())())()(()())(((())())())())()))(\\n\", \"100\\n()()()()()()()()()()())(()()()()()()()()()()()()()()()()()()()())(()()()()()()()()()()()()()()()()()\\n\", \"100\\n((()()))(()()))(())))((()((()()))(()))())((()(())(((())())((()))())))((()(())((())(())())))(()((())(\\n\", \"100\\n))()()(())()()(()()())((()()())())((())())((()))(())()((()))((())())()((()())())(()())(())(()(()))((\\n\", \"101\\n(())))))()))()())(()))((())))((())(()()()(()()((()()((()((())))((()))()(())(()(())((()))(()))()(((()(\\n\", \"100\\n)()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()(\\n\", \"500\\n((()))()()()()(())(())))()(()())(()(((()((()))()((()))))))(((()))))))))()()()(())))(()))((())))))())((()()()(((((())(())(()(((((()(())))(()(()))())))())(((()())((())((())(()()()))(()())((())()((())))())()()())))((()())())))((()(((()())(()))())()()())(()()))(())))()())((()(((()()()(())(((()())()))(())))()((()())()(()(((()())()()()()(())((((())((()(((()())(())(()(()))))()((()))(())))(())()))(((()())(()()())()()(()()))()())))()()))))))()((((((())((((((((((((())(()((())((()()(())))))())))(()))()()((\\n\", \"500\\n))))())))((((((()((())()())()((()()()))))))()((()(())(()))(()))))((()(()((()))(((()()()(((())))((()()()))())(()()))))))(((((()()()())(()())()(()))()(()(((()()))))((((()))())))))(()((((()(((())()()(()()(())))((())()(())((()()())())(())))))))()())(((()(((()(()())())()(((()()))))((()()()()()))))))((()(()(((()((((())())()))(()()(())())))(((()))))(())())))()(((((()))()()()(((()(()(()))())))(()))()((((()))(()())())()())))(((((()()()()((()()(())(((((()))))()))((())))()())(()(()())(()()())(((())))(()(()\\n\", \"500\\n)()()()()()()()())(()()()()()()()()()()()()()()()()())(()()()()()()()()()()()()()())(()()()()()()()()()()()()()()()()())(()()()()()()()()()()())(()()()()()()()()()()()()()()()()()()()()())(()()()()()()()()()()()()()()())(()()()()()()()()()()()()()()()()()()()())(()()()()()()()()()()()()()()()()()())(()()()()()()()()()()()()())(()()()()()()()()()()()()()()()()()()()()()())(()()()()()()()()()()()()()()()()()()()()())(()()()()()()()()()()()()()())(()()()()()()()()()()())(()()()()()()()()()()()()()(\\n\", \"500\\n)))())(())((()))()((())())((()))()()(()(()))((()))(()()())()(())()()()(()()(()))((()))(((()))()())()((()))()()(()()(()())())(((()))()())(()())(()()(())())()((()))()()((())())(())()()()()()()(())()()(()())(((())))(()())((()))()((()))()(((()())))()(()(())())()(()())(()())(())((())())(()((())))()()((()))()((()))()()(()()())(())()(())(())(())()()((())()())(())(((())))((())()())(())()()()((()))(()())()()(())(()(()()))(()(())())((()))(()(()()))(())((()(()())))(()())((()))()(())(()()()(()))(())()((((()\\n\", \"498\\n)())()(()()))())())()((()())((((()))()((()())()))())())))((()(()())))())())(()()(())())(((()))()))))(((((()())(()))(()((()(((()()()(()((()()))(((((((())((())((())(()(((()))())(((((())())())(())(((())(((()))))(())())()()((((())())()(((((()))())())(()))))))((((()())))((()()()))())()))())())(()()()())())((())(((())())((())()()(((()())())())))(((()))(())(((()()))()())))()))()()())))()()))()))))())()(((()()()))())(()))((()(()(())((((()()())(((((()))()((((((((()((()))()))())()))((())))(()(())(()()))\\n\", \"497\\n)()()((()((()()())(((()()(())(()(((()(()((())()()()()())((()()(()))(()(((()))((()()(((()(((((())(()))())))(()())))())((((((((())))))()))))((())))((()((()((((()()))())()())())(()))(())())())())))()()))()()()(((())())(()())))()(((((((((())))))(((((((()))()()))(()()())())())(())()((()()()((())))(())()()()(()))(((((((((())((())))))()))))(((((()())(((((()()()))()()(()())(())())(()(()()()()(())(()()(()())())((())(())(())))))(())((((()))))))())()((()()()(()())())())()))))))()()(())))))())()(()))()))\\n\"], \"outputs\": [\"5\\n8 7\\n\", \"4\\n5 10\\n\", \"0\\n1 1\\n\", \"4\\n4 7\\n\", \"10\\n7 26\\n\", \"0\\n1 1\\n\", \"0\\n1 1\\n\", \"54\\n230 239\\n\", \"27\\n420 147\\n\", \"33\\n23 42\\n\", \"57\\n31 46\\n\", \"152\\n489 496\\n\", \"3\\n400 397\\n\", \"3\\n16 13\\n\", \"0\\n1 1\\n\", \"250\\n2 2\\n\", \"2\\n4 1\\n\", \"2\\n1 1\\n\", \"2\\n2 2\\n\", \"4\\n1 4\\n\", \"3\\n6 3\\n\", \"3\\n5 10\\n\", \"0\\n1 1\\n\", \"5\\n2 2\\n\", \"5\\n23 14\\n\", \"0\\n1 1\\n\", \"25\\n2 2\\n\", \"3\\n1 48\\n\", \"3\\n9 6\\n\", \"7\\n59 50\\n\", \"29\\n66 23\\n\", \"8\\n95 20\\n\", \"23\\n24 31\\n\", \"0\\n1 1\\n\", \"50\\n2 2\\n\", \"9\\n102 263\\n\", \"13\\n357 418\\n\", \"23\\n473 18\\n\", \"102\\n448 457\\n\", \"6\\n102 417\\n\", \"0\\n1 1\\n\"]}", "source": "primeintellect"}
This is an easier version of the problem. In this version, $n \le 500$. Vasya is an experienced developer of programming competitions' problems. As all great minds at some time, Vasya faced a creative crisis. To improve the situation, Petya gifted him a string consisting of opening and closing brackets only. Petya believes, that the beauty of the bracket string is a number of its cyclical shifts, which form a correct bracket sequence. To digress from his problems, Vasya decided to select two positions of the string (not necessarily distinct) and swap characters located at this positions with each other. Vasya will apply this operation exactly once. He is curious what is the maximum possible beauty he can achieve this way. Please help him. We remind that bracket sequence $s$ is called correct if: $s$ is empty; $s$ is equal to "($t$)", where $t$ is correct bracket sequence; $s$ is equal to $t_1 t_2$, i.e. concatenation of $t_1$ and $t_2$, where $t_1$ and $t_2$ are correct bracket sequences. For example, "(()())", "()" are correct, while ")(" and "())" are not. The cyclical shift of the string $s$ of length $n$ by $k$ ($0 \leq k < n$) is a string formed by a concatenation of the last $k$ symbols of the string $s$ with the first $n - k$ symbols of string $s$. For example, the cyclical shift of string "(())()" by $2$ equals "()(())". Cyclical shifts $i$ and $j$ are considered different, if $i \ne j$. -----Input----- The first line contains an integer $n$ ($1 \le n \le 500$), the length of the string. The second line contains a string, consisting of exactly $n$ characters, where each of the characters is either "(" or ")". -----Output----- The first line should contain a single integer — the largest beauty of the string, which can be achieved by swapping some two characters. The second line should contain integers $l$ and $r$ ($1 \leq l, r \leq n$) — the indices of two characters, which should be swapped in order to maximize the string's beauty. In case there are several possible swaps, print any of them. -----Examples----- Input 10 ()()())(() Output 5 8 7 Input 12 )(()(()())() Output 4 5 10 Input 6 )))(() Output 0 1 1 -----Note----- In the first example, we can swap $7$-th and $8$-th character, obtaining a string "()()()()()". The cyclical shifts by $0, 2, 4, 6, 8$ of this string form a correct bracket sequence. In the second example, after swapping $5$-th and $10$-th character, we obtain a string ")(())()()(()". The cyclical shifts by $11, 7, 5, 3$ of this string form a correct bracket sequence. In the third example, swap of any two brackets results in $0$ cyclical shifts being correct bracket sequences. Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0
{"tests": "{\"inputs\": [\"6 3\\n12 10 20 20 25 30\\n10 20 30\\n\", \"4 2\\n1 3 3 7\\n3 7\\n\", \"8 2\\n1 2 2 2 2 2 2 2\\n1 2\\n\", \"18 10\\n8 1 2 3 4 9 9 5 1 6 6 7 8 6 2 9 10 7\\n1 2 3 4 5 6 7 8 9 10\\n\", \"1 1\\n1000000000\\n1000000000\\n\", \"1 1\\n1\\n1\\n\", \"5 1\\n7 10 3 11 3\\n3\\n\", \"5 1\\n7 10 3 11 2\\n3\\n\", \"10 1\\n1 1 1 1 1 1 1 1 1 1\\n1\\n\", \"2 3\\n1 3\\n1 2 3\\n\", \"1 5\\n1\\n1 2 3 4 1000000000\\n\", \"9 9\\n3 4 5 6 7 8 9 10 11\\n3 4 5 6 7 8 9 10 11\\n\", \"3 2\\n2 2 3\\n1 2\\n\", \"5 2\\n2 1 2 3 2\\n1 3\\n\", \"1 1\\n2\\n1\\n\", \"6 3\\n12 10 20 20 15 30\\n10 20 30\\n\", \"2 2\\n10 7\\n5 7\\n\", \"3 3\\n2 5 6\\n1 5 6\\n\", \"1 1\\n3\\n2\\n\", \"2 3\\n2 3\\n1 2 3\\n\", \"3 2\\n2 2 8\\n1 2\\n\", \"10 5\\n9 8 7 6 5 6 7 8 9 10\\n6 7 8 9 10\\n\", \"20 5\\n8 8 2 5 2 1 5 3 6 5 5 4 5 6 3 5 5 7 3 7\\n1 3 4 5 7\\n\", \"5 5\\n2 3 4 5 6\\n1 2 3 4 5\\n\", \"24 3\\n4 12 3 14 2 7 12 7 11 3 5 10 14 1 6 12 13 4 1 5 5 9 8 6\\n1 5 8\\n\", \"1 1\\n5\\n3\\n\", \"39 3\\n4 8 12 9 19 4 2 21 20 15 6 7 4 13 10 4 10 4 22 22 12 11 10 14 5 2 11 20 15 16 14 18 1 3 4 19 4 6 15\\n1 3 4\\n\", \"1 2\\n2\\n1 2\\n\", \"7 2\\n2 2 3 2 3 4 3\\n2 4\\n\", \"5 4\\n1 5 3 10 15\\n1 5 10 15\\n\", \"6 3\\n12 20 20 25 10 30\\n7 10 30\\n\", \"6 3\\n12 20 20 25 10 30\\n10 30 35\\n\", \"4 2\\n3 2 6 2\\n2 6\\n\", \"10 4\\n1 6 1 4 8 4 4 6 5 1\\n1 6 7 9\\n\", \"47 2\\n6 2 5 1 1 9 10 7 8 6 10 8 5 10 3 5 1 7 1 1 10 8 2 4 3 9 4 6 2 8 3 5 3 8 6 7 5 4 6 6 5 3 8 2 10 6 3\\n1 9\\n\", \"71 4\\n9 9 6 9 8 2 10 9 2 5 10 1 9 7 5 6 4 9 3 7 3 8 5 3 4 10 5 9 9 1 2 1 10 1 10 8 2 9 2 2 8 8 2 4 10 1 6 9 7 2 7 5 1 1 8 6 7 9 5 6 8 2 3 4 3 1 3 7 2 7 4\\n1 2 3 7\\n\", \"77 22\\n7 2 4 8 10 7 5 7 9 7 5 6 2 9 10 1 5 4 5 8 6 9 3 1 8 1 10 9 6 7 7 1 5 3 6 4 9 10 7 8 2 3 10 10 9 9 2 9 1 9 7 3 2 4 7 7 1 1 10 4 2 2 8 3 2 9 9 9 5 6 7 1 10 8 3 9 1\\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22\\n\", \"5 2\\n2 3 4 5 6\\n1 4\\n\", \"6 1\\n2 2 2 2 2 4\\n1\\n\", \"6 3\\n12 10 20 20 5 30\\n10 20 30\\n\", \"6 3\\n12 10 20 20 10 30\\n7 10 30\\n\"], \"outputs\": [\"2\\n\", \"0\\n\", \"7\\n\", \"0\\n\", \"1\\n\", \"1\\n\", \"1\\n\", \"0\\n\", \"1\\n\", \"0\\n\", \"0\\n\", \"1\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"3\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"0\\n\"]}", "source": "primeintellect"}
You are given two arrays $a_1, a_2, \dots , a_n$ and $b_1, b_2, \dots , b_m$. Array $b$ is sorted in ascending order ($b_i < b_{i + 1}$ for each $i$ from $1$ to $m - 1$). You have to divide the array $a$ into $m$ consecutive subarrays so that, for each $i$ from $1$ to $m$, the minimum on the $i$-th subarray is equal to $b_i$. Note that each element belongs to exactly one subarray, and they are formed in such a way: the first several elements of $a$ compose the first subarray, the next several elements of $a$ compose the second subarray, and so on. For example, if $a = [12, 10, 20, 20, 25, 30]$ and $b = [10, 20, 30]$ then there are two good partitions of array $a$: $[12, 10, 20], [20, 25], [30]$; $[12, 10], [20, 20, 25], [30]$. You have to calculate the number of ways to divide the array $a$. Since the number can be pretty large print it modulo 998244353. -----Input----- The first line contains two integers $n$ and $m$ ($1 \le n, m \le 2 \cdot 10^5$) — the length of arrays $a$ and $b$ respectively. The second line contains $n$ integers $a_1, a_2, \dots , a_n$ ($1 \le a_i \le 10^9$) — the array $a$. The third line contains $m$ integers $b_1, b_2, \dots , b_m$ ($1 \le b_i \le 10^9; b_i < b_{i+1}$) — the array $b$. -----Output----- In only line print one integer — the number of ways to divide the array $a$ modulo 998244353. -----Examples----- Input 6 3 12 10 20 20 25 30 10 20 30 Output 2 Input 4 2 1 3 3 7 3 7 Output 0 Input 8 2 1 2 2 2 2 2 2 2 1 2 Output 7 Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0
{"tests": "{\"inputs\": [\"4\\n3 2 2 3\\n\", \"6\\n4 5 6 3 2 1\\n\", \"10\\n6 8 4 6 7 1 6 3 4 5\\n\", \"6\\n5 5 5 6 4 6\\n\", \"50\\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\\n\", \"50\\n1 1 2 1 1 1 1 1 1 1 1 1 2 1 2 1 1 2 1 1 1 1 1 1 1 1 1 2 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\\n\", \"50\\n2 4 1 2 3 7 2 2 1 1 3 4 2 12 4 3 2 1 2 5 1 3 3 7 9 6 10 5 7 1 4 3 6 2 3 12 1 3 2 6 2 2 2 4 1 6 1 3 7 13\\n\", \"50\\n11 3 15 13 1 10 27 4 18 20 6 1 5 8 9 19 6 13 5 19 5 3 1 8 2 3 3 6 4 19 11 6 3 1 3 1 8 14 2 2 8 13 12 1 15 2 1 2 1 1\\n\", \"50\\n9 10 1 6 7 3 25 4 11 15 3 6 25 1 6 17 1 25 16 2 10 22 17 11 1 14 4 6 9 18 12 9 10 1 10 13 8 13 24 28 12 14 1 2 1 4 20 9 7 4\\n\", \"10\\n8 1 2 1 8 8 1 5 1 2\\n\", \"3\\n2 1 2\\n\", \"50\\n25 48 15 25 49 39 34 15 9 3 12 11 11 3 30 7 6 47 36 1 39 27 17 1 31 39 3 42 19 20 26 41 10 15 29 44 26 32 37 39 43 38 42 6 37 36 50 47 43 21\\n\", \"50\\n50 46 38 41 49 23 16 17 48 32 31 49 40 21 41 31 47 17 15 50 38 20 37 47 24 47 15 46 24 18 41 40 45 25 31 45 14 30 17 16 16 44 44 46 45 5 41 16 24 34\\n\", \"50\\n26 46 50 31 47 40 25 47 41 47 31 30 50 40 46 44 26 48 37 19 28 19 50 22 42 38 47 22 44 44 35 30 50 45 49 34 19 37 36 32 50 29 50 42 34 49 40 50 8 50\\n\", \"20\\n15 18 20 6 19 13 20 17 20 16 19 17 17 19 16 12 14 19 20 20\\n\", \"50\\n48 37 47 50 46 43 42 46 36 40 45 41 40 50 35 49 37 42 44 45 49 44 31 47 45 49 48 41 45 45 48 20 34 43 43 41 47 50 41 48 38 48 43 48 46 48 32 37 47 45\\n\", \"26\\n26 26 23 25 22 26 26 24 26 26 25 18 25 22 24 24 24 24 24 26 26 25 24 26 26 23\\n\", \"50\\n50 50 50 49 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 49 50 49 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 49\\n\", \"50\\n50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50\\n\", \"50\\n4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4\\n\", \"50\\n32 4 32 4 42 32 32 42 4 4 32 4 42 4 32 42 4 42 32 42 32 32 32 42 4 4 32 4 32 4 32 4 42 32 4 42 32 42 32 32 4 42 42 42 42 42 42 32 32 4\\n\", \"50\\n18 42 38 38 38 50 50 38 49 49 38 38 42 18 49 49 49 49 18 50 18 38 38 49 49 50 49 42 38 49 42 38 38 49 38 49 50 49 49 49 18 49 18 38 42 50 42 49 18 49\\n\", \"50\\n17 31 7 41 30 38 38 5 38 39 5 1 41 17 5 15 7 15 15 7 39 17 38 7 39 41 5 7 38 1 39 31 41 7 5 38 17 15 39 30 39 38 7 15 30 17 7 5 41 31\\n\", \"50\\n23 14 39 19 31 39 18 18 31 14 45 7 42 25 20 25 14 19 29 45 33 7 8 32 29 24 26 13 25 24 25 13 4 23 39 45 25 21 38 45 20 45 18 7 27 23 29 15 31 39\\n\", \"50\\n4 50 27 48 32 32 37 33 18 24 38 6 32 17 1 46 36 16 10 9 9 25 26 40 28 2 1 5 15 50 2 4 18 39 42 46 25 3 10 42 37 23 28 41 33 45 25 11 13 18\\n\", \"50\\n39 49 43 21 22 27 28 41 35 6 31 9 4 39 27 27 7 41 9 28 43 37 20 47 28 37 8 46 23 14 50 48 21 47 9 31 9 37 34 17 15 17 18 16 29 6 43 33 16 17\\n\", \"2\\n1 2\\n\", \"2\\n2 1\\n\", \"2\\n1 1\\n\", \"2\\n2 2\\n\", \"3\\n1 1 1\\n\", \"3\\n2 2 2\\n\", \"3\\n3 3 3\\n\", \"3\\n1 2 2\\n\", \"3\\n2 1 3\\n\", \"3\\n3 2 1\\n\", \"3\\n2 2 3\\n\", \"3\\n3 1 3\\n\", \"3\\n2 2 1\\n\", \"3\\n3 1 2\\n\"], \"outputs\": [\"2\\n1 2 4 3 \\n\", \"0\\n4 5 6 3 2 1 \\n\", \"3\\n2 8 4 6 7 1 9 3 10 5 \\n\", \"3\\n1 2 5 3 4 6 \\n\", \"49\\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 \\n\", \"48\\n1 3 2 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 \\n\", \"39\\n2 4 1 8 3 7 11 14 15 16 17 18 19 12 20 21 22 23 24 5 25 26 27 28 9 6 10 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 13 \\n\", \"32\\n7 3 15 13 1 10 27 4 18 20 6 16 5 8 9 17 21 22 23 19 24 25 26 28 2 29 30 31 32 33 11 34 35 36 37 38 39 14 40 41 42 43 12 44 45 46 47 48 49 50 \\n\", \"28\\n5 10 1 6 7 3 19 4 11 15 21 23 25 26 27 17 29 30 16 2 31 22 32 33 34 14 35 36 9 18 12 37 38 39 40 13 8 41 24 28 42 43 44 45 46 47 20 48 49 50 \\n\", \"6\\n3 1 2 4 6 8 7 5 9 10 \\n\", \"1\\n2 1 3 \\n\", \"17\\n2 48 4 25 49 5 34 8 9 3 12 11 13 14 30 7 6 16 18 1 22 27 17 23 31 24 28 33 19 20 26 41 10 15 29 44 35 32 37 39 40 38 42 45 46 36 50 47 43 21 \\n\", \"24\\n1 2 3 4 6 23 7 8 48 32 9 49 10 21 11 12 13 17 15 50 38 20 37 19 22 47 26 27 24 18 28 40 29 25 31 33 14 30 35 16 36 39 44 46 45 5 41 42 43 34 \\n\", \"25\\n1 2 3 4 5 6 25 7 41 9 31 10 11 12 46 13 26 48 14 15 28 16 17 18 20 38 47 22 21 44 35 30 23 45 24 27 19 37 36 32 33 29 39 42 34 49 40 43 8 50 \\n\", \"10\\n15 18 1 6 2 13 3 4 5 7 8 9 17 10 16 12 14 19 11 20 \\n\", \"31\\n1 2 3 4 5 6 7 8 36 9 10 11 40 12 35 13 14 42 15 16 17 44 31 18 19 49 21 22 23 24 25 20 34 26 27 28 29 50 41 30 38 33 43 39 46 48 32 37 47 45 \\n\", \"20\\n1 2 3 4 5 6 7 8 9 10 11 18 12 22 13 14 15 16 17 19 20 25 24 21 26 23 \\n\", \"48\\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 50 49 \\n\", \"49\\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 \\n\", \"49\\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 \\n\", \"47\\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 33 34 32 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 \\n\", \"45\\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 19 18 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 39 40 41 43 44 45 38 42 50 46 47 48 49 \\n\", \"40\\n2 3 4 6 8 9 10 5 11 12 13 1 14 16 18 15 7 19 20 21 22 17 23 24 25 26 27 28 29 32 33 31 34 35 36 37 40 42 39 30 43 38 44 45 46 47 48 49 41 50 \\n\", \"27\\n1 2 3 5 6 9 10 11 12 14 16 7 42 17 20 22 28 19 29 30 33 34 8 32 35 24 26 13 25 36 37 40 4 23 39 41 43 21 38 44 46 45 18 47 27 48 49 15 31 50 \\n\", \"17\\n4 7 27 48 8 12 14 19 18 24 38 6 32 17 1 20 36 16 10 9 21 22 26 40 28 2 29 5 15 50 30 31 34 39 35 46 25 3 43 42 37 23 44 41 33 45 47 11 13 49 \\n\", \"20\\n1 49 2 3 22 5 10 11 35 6 12 9 4 39 13 27 7 41 19 24 25 26 20 30 28 32 8 46 23 14 50 48 21 47 36 31 38 37 34 17 15 40 18 16 29 42 43 33 44 45 \\n\", \"0\\n1 2 \\n\", \"0\\n2 1 \\n\", \"1\\n1 2 \\n\", \"1\\n1 2 \\n\", \"2\\n1 2 3 \\n\", \"2\\n1 2 3 \\n\", \"2\\n1 2 3 \\n\", \"1\\n1 2 3 \\n\", \"0\\n2 1 3 \\n\", \"0\\n3 2 1 \\n\", \"1\\n1 2 3 \\n\", \"1\\n2 1 3 \\n\", \"1\\n2 3 1 \\n\", \"0\\n3 1 2 \\n\"]}", "source": "primeintellect"}
Ivan has an array consisting of n elements. Each of the elements is an integer from 1 to n. Recently Ivan learned about permutations and their lexicographical order. Now he wants to change (replace) minimum number of elements in his array in such a way that his array becomes a permutation (i.e. each of the integers from 1 to n was encountered in his array exactly once). If there are multiple ways to do it he wants to find the lexicographically minimal permutation among them. Thus minimizing the number of changes has the first priority, lexicographical minimizing has the second priority. In order to determine which of the two permutations is lexicographically smaller, we compare their first elements. If they are equal — compare the second, and so on. If we have two permutations x and y, then x is lexicographically smaller if x_{i} < y_{i}, where i is the first index in which the permutations x and y differ. Determine the array Ivan will obtain after performing all the changes. -----Input----- The first line contains an single integer n (2 ≤ n ≤ 200 000) — the number of elements in Ivan's array. The second line contains a sequence of integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ n) — the description of Ivan's array. -----Output----- In the first line print q — the minimum number of elements that need to be changed in Ivan's array in order to make his array a permutation. In the second line, print the lexicographically minimal permutation which can be obtained from array with q changes. -----Examples----- Input 4 3 2 2 3 Output 2 1 2 4 3 Input 6 4 5 6 3 2 1 Output 0 4 5 6 3 2 1 Input 10 6 8 4 6 7 1 6 3 4 5 Output 3 2 8 4 6 7 1 9 3 10 5 -----Note----- In the first example Ivan needs to replace number three in position 1 with number one, and number two in position 3 with number four. Then he will get a permutation [1, 2, 4, 3] with only two changed numbers — this permutation is lexicographically minimal among all suitable. In the second example Ivan does not need to change anything because his array already is a permutation. Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0
{"tests": "{\"inputs\": [\"5 3\\n20 10 30 40 10\\n\", \"6 5\\n90 20 35 40 60 100\\n\", \"100 7\\n85 66 9 91 50 46 61 12 55 65 95 1 25 97 95 4 59 59 52 34 94 30 60 11 68 36 17 84 87 68 72 87 46 99 24 66 75 77 75 2 19 3 33 19 7 20 22 3 71 29 88 63 89 47 7 52 47 55 87 77 9 81 44 13 30 43 66 74 9 42 9 72 97 61 9 94 92 29 18 7 92 68 76 43 35 71 54 49 77 50 77 68 57 24 84 73 32 85 24 37\\n\", \"1 1\\n10\\n\", \"1 1\\n86\\n\", \"100 79\\n83 83 83 83 83 94 94 83 83 83 83 90 83 99 83 91 83 83 83 83 83 83 83 83 83 83 83 91 83 83 83 83 83 96 83 83 83 91 83 83 92 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 98 83 83 91 97 83 83 83 83 83 83 83 92 83 83 83 83 83 83 83 93 83 83 91 83 83 83 83 83 83 83 83 83 83 83 96 83 83 83 83 83\\n\", \"20 3\\n17 76 98 17 55 17 17 99 65 17 17 17 17 52 17 17 69 88 17 17\\n\", \"15 1\\n0 78 24 24 61 60 0 65 52 57 97 51 56 13 10\\n\", \"50 50\\n59 40 52 0 65 49 3 58 57 22 86 37 55 72 11 3 30 30 20 64 44 45 12 48 96 96 39 14 8 53 40 37 8 58 97 16 96 48 30 89 66 19 31 50 23 80 67 16 11 7\\n\", \"60 8\\n59 12 34 86 57 65 42 24 62 18 94 92 43 29 95 33 73 3 69 18 36 18 34 97 85 65 74 25 26 70 46 31 57 73 78 89 95 77 94 71 38 23 30 97 69 97 76 43 76 31 38 50 13 16 55 85 47 5 71 4\\n\", \"70 5\\n76 16 20 60 5 96 32 50 35 9 79 42 38 35 72 45 98 33 55 0 86 92 49 87 22 79 35 27 69 35 89 29 31 43 88 1 48 95 3 92 82 97 53 80 79 0 78 58 37 38 45 9 5 38 53 49 71 7 91 3 75 17 76 44 77 31 78 91 59 91\\n\", \"12 3\\n18 64 98 27 36 27 65 43 39 41 69 47\\n\", \"15 13\\n6 78 78 78 78 20 78 78 8 3 78 18 32 56 78\\n\", \"17 4\\n75 52 24 74 70 24 24 53 24 48 24 0 67 47 24 24 6\\n\", \"14 2\\n31 18 78 90 96 2 90 27 86 9 94 98 94 34\\n\", \"100 56\\n56 64 54 22 46 0 51 27 8 10 5 26 68 37 51 53 4 64 82 23 38 89 97 20 23 31 7 95 55 27 33 23 95 6 64 69 27 54 36 4 96 61 68 26 46 10 61 53 32 19 28 62 7 32 86 84 12 88 92 51 53 23 80 7 36 46 48 29 12 98 72 99 16 0 94 22 83 23 12 37 29 13 93 16 53 21 8 37 67 33 33 67 35 72 3 97 46 30 9 57\\n\", \"90 41\\n43 24 4 69 54 87 33 34 9 77 87 66 66 0 71 43 42 10 78 48 26 40 8 61 80 38 76 63 7 47 99 69 77 43 29 74 86 93 39 28 99 98 11 27 43 58 50 61 1 79 45 17 23 13 10 98 41 28 19 98 87 51 26 28 88 60 42 25 19 3 29 18 0 56 84 27 43 92 93 97 25 90 13 90 75 52 99 6 66 87\\n\", \"100 71\\n29 56 85 57 40 89 93 81 92 38 81 41 18 9 89 21 81 6 95 94 38 11 90 38 6 81 61 43 81 12 36 35 33 10 81 49 59 37 81 61 95 34 43 20 94 88 57 81 42 81 50 24 85 81 1 90 33 8 59 87 17 52 91 54 81 98 28 11 24 51 95 31 98 29 5 81 91 52 41 81 7 9 81 81 13 81 3 81 10 0 37 47 62 50 81 81 81 94 93 38\\n\", \"100 55\\n72 70 77 90 86 96 60 60 60 60 87 62 60 87 0 60 82 60 86 74 60 60 60 60 60 60 78 60 60 60 96 60 60 0 60 60 89 99 60 60 60 60 60 60 89 60 88 84 60 93 0 60 60 60 75 60 67 64 65 60 65 60 72 60 76 4 60 60 60 63 96 62 78 71 63 81 89 98 60 60 69 60 61 60 60 60 85 71 82 79 67 60 60 60 79 96 2 60 60 60\\n\", \"100 27\\n25 87 25 25 77 78 25 73 91 25 25 70 84 25 61 75 82 25 25 25 25 65 25 25 82 63 93 25 93 75 25 25 25 89 98 25 25 72 70 25 72 25 25 25 70 25 25 98 90 25 25 25 25 25 91 25 78 71 63 69 25 25 25 63 25 25 75 94 25 25 25 25 25 97 25 78 66 87 25 89 25 25 73 85 25 91 72 25 25 80 25 70 25 96 25 25 25 25 25 25\\n\", \"100 99\\n1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2\\n\", \"100 50\\n1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2\\n\", \"100 51\\n1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2\\n\", \"100 75\\n1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2\\n\", \"100 45\\n1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2\\n\", \"2 2\\n2 2\\n\", \"2 1\\n2 1\\n\", \"2 1\\n1 2\\n\", \"3 1\\n1 2 0\\n\", \"3 2\\n0 0 0\\n\", \"3 3\\n0 1 0\\n\", \"3 2\\n99 100 99\\n\", \"1 1\\n0\\n\", \"4 1\\n100 100 0 100\\n\", \"4 2\\n0 1 0 1\\n\", \"10 3\\n0 1 2 3 0 1 2 3 0 1\\n\", \"10 9\\n0 1 0 1 100 100 1 0 1 0\\n\", \"7 7\\n1 0 0 0 0 0 0\\n\", \"7 6\\n0 0 0 0 0 0 1\\n\", \"7 1\\n12 33 12 88 10 0 3\\n\", \"7 1\\n0 1 1 1 1 1 1\\n\", \"7 6\\n1 1 1 1 1 1 0\\n\", \"7 2\\n1 0 1 1 1 1 1\\n\", \"8 4\\n1 1 1 1 0 0 0 0\\n\", \"7 5\\n1 1 1 2 0 0 0\\n\"], \"outputs\": [\"20\\n1 3 4 \\n\", \"35\\n1 3 4 5 6 \\n\", \"94\\n11 14 15 21 34 73 76 \\n\", \"10\\n1 \\n\", \"86\\n1 \\n\", \"83\\n6 7 12 14 16 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 \\n\", \"88\\n3 8 18 \\n\", \"97\\n11 \\n\", \"0\\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 \\n\", \"92\\n11 12 15 24 37 39 44 46 \\n\", \"92\\n6 17 38 40 42 \\n\", \"65\\n3 7 11 \\n\", \"8\\n2 3 4 5 6 7 8 9 11 12 13 14 15 \\n\", \"67\\n1 4 5 13 \\n\", \"96\\n5 12 \\n\", \"33\\n1 2 3 5 7 13 14 15 16 18 19 21 22 23 28 29 33 35 36 38 39 41 42 43 45 47 48 52 55 56 58 59 60 61 63 65 66 67 70 71 72 75 77 80 83 85 88 89 90 91 92 93 94 96 97 100 \\n\", \"52\\n4 5 6 10 11 12 13 15 19 24 25 27 28 31 32 33 36 37 38 41 42 46 48 50 56 60 61 65 66 74 75 78 79 80 82 84 85 86 87 89 90 \\n\", \"35\\n2 3 4 5 6 7 8 9 10 11 12 15 17 19 20 21 23 24 26 27 28 29 31 32 35 36 37 38 39 40 41 43 45 46 47 48 49 50 51 53 54 56 59 60 62 63 64 65 66 70 71 73 76 77 78 79 80 83 84 86 88 91 92 93 94 95 96 97 98 99 100 \\n\", \"60\\n1 2 3 4 5 6 11 12 14 17 19 20 27 31 37 38 45 47 48 50 55 57 58 59 61 63 65 70 71 72 73 74 75 76 77 78 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 98 99 100 \\n\", \"75\\n2 5 6 9 13 16 17 25 27 29 30 34 35 48 49 55 57 67 68 74 76 78 80 84 86 90 94 \\n\", \"1\\n2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 \\n\", \"2\\n2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62 64 66 68 70 72 74 76 78 80 82 84 86 88 90 92 94 96 98 100 \\n\", \"1\\n2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62 64 66 68 70 72 74 76 78 80 82 84 86 88 90 92 94 96 98 99 100 \\n\", \"1\\n2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 \\n\", \"2\\n12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62 64 66 68 70 72 74 76 78 80 82 84 86 88 90 92 94 96 98 100 \\n\", \"2\\n1 2 \\n\", \"2\\n1 \\n\", \"2\\n2 \\n\", \"2\\n2 \\n\", \"0\\n2 3 \\n\", \"0\\n1 2 3 \\n\", \"99\\n2 3 \\n\", \"0\\n1 \\n\", \"100\\n4 \\n\", \"1\\n2 4 \\n\", \"2\\n4 7 8 \\n\", \"0\\n2 3 4 5 6 7 8 9 10 \\n\", \"0\\n1 2 3 4 5 6 7 \\n\", \"0\\n2 3 4 5 6 7 \\n\", \"88\\n4 \\n\", \"1\\n7 \\n\", \"1\\n1 2 3 4 5 6 \\n\", \"1\\n6 7 \\n\", \"1\\n1 2 3 4 \\n\", \"0\\n1 2 3 4 7 \\n\"]}", "source": "primeintellect"}
Vasya is going to the Olympics in the city Ntown by train. The boy wants to read the textbook to prepare for the Olympics. He counted that he needed k hours for this. He also found that the light in the train changes every hour. The light is measured on a scale from 0 to 100, where 0 is very dark, and 100 is very light. Vasya has a train lighting schedule for all n hours of the trip — n numbers from 0 to 100 each (the light level in the first hour, the second hour and so on). During each of those hours he will either read the whole time, or not read at all. He wants to choose k hours to read a book, not necessarily consecutive, so that the minimum level of light among the selected hours were maximum. Vasya is very excited before the upcoming contest, help him choose reading hours. -----Input----- The first input line contains two integers n and k (1 ≤ n ≤ 1000, 1 ≤ k ≤ n) — the number of hours on the train and the number of hours to read, correspondingly. The second line contains n space-separated integers a_{i} (0 ≤ a_{i} ≤ 100), a_{i} is the light level at the i-th hour. -----Output----- In the first output line print the minimum light level Vasya will read at. In the second line print k distinct space-separated integers b_1, b_2, ..., b_{k}, — the indexes of hours Vasya will read at (1 ≤ b_{i} ≤ n). The hours are indexed starting from 1. If there are multiple optimal solutions, print any of them. Print the numbers b_{i} in an arbitrary order. -----Examples----- Input 5 3 20 10 30 40 10 Output 20 1 3 4 Input 6 5 90 20 35 40 60 100 Output 35 1 3 4 5 6 -----Note----- In the first sample Vasya should read at the first hour (light 20), third hour (light 30) and at the fourth hour (light 40). The minimum light Vasya will have to read at is 20. Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0
{"tests": "{\"inputs\": [\"7 2\\n1 2\\n1 3\\n1 4\\n3 5\\n3 6\\n3 7\\n2 7\\n\", \"6 4\\n1 2\\n2 3\\n2 4\\n4 5\\n4 6\\n2 4 5 6\\n\", \"2 1\\n2 1\\n1\\n\", \"1 1\\n1\\n\", \"10 2\\n6 9\\n6 2\\n1 6\\n4 10\\n3 7\\n9 4\\n9 5\\n6 7\\n2 8\\n7 6\\n\", \"15 2\\n7 12\\n13 11\\n6 8\\n2 15\\n10 9\\n5 1\\n13 5\\n5 4\\n14 3\\n8 9\\n8 4\\n4 7\\n12 14\\n5 2\\n7 4\\n\", \"20 2\\n1 16\\n12 5\\n15 19\\n18 9\\n8 4\\n10 16\\n9 16\\n20 15\\n14 19\\n7 4\\n18 12\\n17 12\\n2 20\\n6 14\\n3 19\\n7 19\\n18 15\\n19 13\\n9 11\\n12 18\\n\", \"4 2\\n4 3\\n3 1\\n1 2\\n3 4\\n\", \"8 5\\n2 5\\n1 8\\n6 7\\n3 4\\n6 8\\n8 5\\n5 3\\n1 6 7 3 8\\n\", \"16 8\\n16 12\\n16 15\\n15 9\\n15 13\\n16 3\\n15 2\\n15 10\\n1 2\\n6 16\\n5 15\\n2 7\\n15 4\\n14 15\\n11 16\\n8 5\\n5 10 14 6 8 3 1 9\\n\", \"32 28\\n30 12\\n30 27\\n24 32\\n6 13\\n11 5\\n4 30\\n8 28\\n9 20\\n8 20\\n7 20\\n5 30\\n18 5\\n20 14\\n23 20\\n17 20\\n8 26\\n20 1\\n15 2\\n20 13\\n24 20\\n22 24\\n25 16\\n2 3\\n19 5\\n16 10\\n31 2\\n29 5\\n20 16\\n2 20\\n5 21\\n5 20\\n32 11 6 12 22 30 23 21 14 13 1 20 7 25 9 29 10 27 5 19 24 31 15 26 8 3 28 17\\n\", \"10 3\\n10 5\\n3 2\\n6 8\\n1 5\\n10 4\\n6 1\\n9 8\\n2 9\\n7 3\\n3 9 1\\n\", \"7 5\\n6 4\\n5 6\\n6 7\\n2 3\\n5 2\\n2 1\\n4 6 1 7 3\\n\", \"15 7\\n5 4\\n12 5\\n7 13\\n10 11\\n3 8\\n6 12\\n3 15\\n1 3\\n5 14\\n7 9\\n1 10\\n6 1\\n12 7\\n10 2\\n4 10 8 13 1 7 9\\n\", \"31 16\\n3 25\\n8 1\\n1 9\\n1 23\\n16 15\\n10 6\\n25 30\\n20 29\\n2 24\\n3 7\\n19 22\\n2 12\\n16 4\\n7 26\\n31 10\\n17 13\\n25 21\\n7 18\\n28 2\\n6 27\\n19 5\\n13 3\\n17 31\\n10 16\\n20 14\\n8 19\\n6 11\\n28 20\\n13 28\\n31 8\\n31 27 25 20 26 8 28 15 18 17 10 23 4 16 30 22\\n\", \"63 20\\n35 26\\n54 5\\n32 56\\n56 53\\n59 46\\n37 31\\n46 8\\n4 1\\n2 47\\n59 42\\n55 11\\n62 6\\n30 7\\n60 24\\n41 36\\n34 22\\n24 34\\n21 2\\n12 52\\n8 44\\n60 21\\n24 30\\n48 35\\n48 25\\n32 57\\n20 37\\n11 54\\n11 62\\n42 58\\n31 43\\n12 23\\n55 48\\n51 55\\n41 27\\n25 33\\n21 18\\n42 12\\n4 15\\n51 60\\n62 39\\n46 41\\n57 9\\n30 61\\n31 4\\n58 13\\n34 29\\n37 32\\n18 16\\n57 45\\n2 49\\n40 51\\n43 17\\n40 20\\n20 59\\n8 19\\n58 10\\n43 63\\n54 50\\n18 14\\n25 38\\n56 28\\n35 3\\n41 36 18 28 54 22 20 6 23 38 33 52 48 44 29 56 63 4 27 50\\n\", \"4 2\\n2 3\\n2 1\\n2 4\\n3 4\\n\", \"13 11\\n4 11\\n2 7\\n4 13\\n8 12\\n8 9\\n8 6\\n3 8\\n4 1\\n2 10\\n2 5\\n3 4\\n3 2\\n10 4 5 6 1 2 3 9 13 7 12\\n\", \"7 5\\n1 5\\n4 1\\n1 3\\n7 1\\n1 6\\n1 2\\n2 4 1 3 7\\n\", \"12 9\\n11 12\\n1 10\\n1 7\\n5 6\\n8 7\\n9 8\\n4 5\\n1 4\\n2 3\\n1 2\\n10 11\\n4 9 11 3 5 12 8 6 7\\n\", \"56 34\\n7 31\\n47 6\\n13 4\\n51 29\\n13 12\\n10 52\\n10 41\\n1 47\\n47 54\\n9 1\\n4 27\\n4 40\\n49 19\\n21 26\\n24 33\\n56 49\\n41 56\\n7 23\\n41 48\\n16 34\\n35 9\\n56 51\\n5 43\\n44 46\\n10 25\\n49 2\\n1 21\\n9 32\\n33 20\\n16 5\\n5 35\\n55 50\\n55 53\\n37 44\\n43 15\\n4 55\\n8 10\\n8 24\\n21 42\\n37 8\\n39 13\\n49 38\\n39 16\\n50 3\\n55 7\\n51 45\\n21 11\\n51 28\\n50 18\\n50 30\\n5 37\\n7 17\\n35 22\\n47 36\\n35 14\\n3 38 47 22 34 10 54 50 9 52 36 1 21 29 28 6 13 39 4 40 53 51 35 55 45 18 44 20 42 31 11 46 41 12\\n\", \"26 22\\n20 16\\n2 7\\n7 19\\n5 9\\n20 23\\n22 18\\n24 3\\n8 22\\n16 10\\n5 2\\n7 15\\n22 14\\n25 4\\n25 11\\n24 13\\n8 24\\n13 1\\n20 8\\n22 6\\n7 26\\n16 12\\n16 5\\n13 21\\n25 17\\n2 25\\n16 4 7 24 10 12 2 23 20 1 26 14 8 9 3 6 21 13 11 18 22 17\\n\", \"43 13\\n7 28\\n17 27\\n39 8\\n21 3\\n17 20\\n17 2\\n9 6\\n35 23\\n43 22\\n7 41\\n5 24\\n26 11\\n21 43\\n41 17\\n16 5\\n25 15\\n39 10\\n18 7\\n37 33\\n39 13\\n39 16\\n10 12\\n1 21\\n2 25\\n14 36\\n12 7\\n16 34\\n24 4\\n25 40\\n5 29\\n37 31\\n3 32\\n22 14\\n16 35\\n5 37\\n10 38\\n25 19\\n9 1\\n26 42\\n43 26\\n10 30\\n33 9\\n28 6 42 38 27 32 8 11 36 7 41 29 19\\n\", \"21 20\\n16 9\\n7 11\\n4 12\\n2 17\\n17 7\\n5 2\\n2 8\\n4 10\\n8 19\\n6 15\\n2 6\\n12 18\\n16 5\\n20 16\\n6 14\\n5 3\\n5 21\\n20 1\\n17 13\\n6 4\\n6 4 18 11 14 1 19 15 10 8 9 17 16 3 20 13 2 5 12 21\\n\", \"29 6\\n16 9\\n20 13\\n24 3\\n24 28\\n22 12\\n10 11\\n10 26\\n22 4\\n10 27\\n5 1\\n2 23\\n23 5\\n16 7\\n8 24\\n7 19\\n19 17\\n8 10\\n20 16\\n20 25\\n24 20\\n23 15\\n22 29\\n2 8\\n7 22\\n2 21\\n23 14\\n19 18\\n19 6\\n19 17 18 27 29 4\\n\", \"31 29\\n10 14\\n16 6\\n23 22\\n25 23\\n2 27\\n24 17\\n20 8\\n5 2\\n8 24\\n16 5\\n10 26\\n8 7\\n5 29\\n20 16\\n13 9\\n13 21\\n24 30\\n13 1\\n10 15\\n23 3\\n25 10\\n2 25\\n20 13\\n25 11\\n8 12\\n30 28\\n20 18\\n5 4\\n23 19\\n16 31\\n13 14 3 30 5 6 26 22 25 1 23 7 31 12 16 28 17 2 8 18 24 4 20 21 15 11 9 29 10\\n\", \"54 8\\n33 9\\n39 36\\n22 14\\n24 13\\n8 50\\n34 52\\n47 2\\n35 44\\n16 54\\n34 25\\n1 3\\n39 11\\n9 17\\n43 19\\n10 40\\n47 38\\n5 37\\n21 47\\n37 12\\n16 6\\n37 7\\n32 26\\n39 42\\n44 10\\n1 18\\n37 8\\n9 1\\n8 24\\n10 33\\n33 53\\n5 4\\n21 30\\n9 31\\n24 28\\n24 49\\n16 5\\n34 35\\n21 48\\n47 43\\n13 34\\n39 16\\n10 27\\n22 32\\n43 22\\n13 46\\n33 23\\n44 15\\n1 21\\n8 41\\n43 45\\n5 29\\n35 20\\n13 51\\n40 50 33 14 48 25 44 9\\n\", \"17 12\\n5 2\\n4 3\\n8 17\\n2 4\\n2 8\\n17 12\\n8 10\\n6 11\\n16 7\\n4 14\\n15 13\\n6 9\\n4 6\\n15 16\\n16 5\\n9 1\\n4 8 1 9 3 12 15 10 13 6 14 16\\n\", \"28 6\\n25 21\\n9 18\\n25 1\\n16 5\\n9 11\\n28 19\\n5 2\\n20 16\\n20 13\\n2 23\\n5 25\\n8 24\\n14 27\\n3 15\\n24 28\\n8 10\\n22 14\\n14 17\\n13 9\\n3 22\\n22 26\\n16 7\\n2 8\\n25 3\\n3 12\\n14 4\\n9 6\\n28 27 22 24 20 16\\n\", \"10 9\\n3 9\\n4 8\\n10 1\\n2 3\\n5 6\\n4 3\\n1 2\\n5 4\\n6 7\\n9 1 5 8 7 3 4 6 10\\n\", \"9 6\\n1 6\\n3 4\\n9 7\\n3 2\\n8 7\\n2 1\\n6 7\\n3 5\\n2 5 1 6 3 9\\n\", \"19 11\\n8 9\\n10 13\\n16 15\\n6 4\\n3 2\\n17 16\\n4 7\\n1 14\\n10 11\\n15 14\\n4 3\\n10 12\\n4 5\\n2 1\\n16 19\\n8 1\\n10 9\\n18 16\\n10 14 18 12 17 11 19 8 1 3 9\\n\", \"36 5\\n36 33\\n11 12\\n14 12\\n25 24\\n27 26\\n23 24\\n20 19\\n1 2\\n3 2\\n17 18\\n33 34\\n23 1\\n32 31\\n12 15\\n25 26\\n4 5\\n5 8\\n5 6\\n26 29\\n1 9\\n35 33\\n33 32\\n16 1\\n3 4\\n31 30\\n16 17\\n19 21\\n1 30\\n7 5\\n9 10\\n13 12\\n19 18\\n10 11\\n22 19\\n28 26\\n29 12 11 17 33\\n\", \"10 2\\n5 1\\n1 3\\n3 4\\n4 2\\n5 10\\n1 9\\n3 8\\n4 7\\n2 6\\n3 4\\n\", \"53 30\\n41 42\\n27 24\\n13 11\\n10 11\\n32 33\\n34 33\\n37 40\\n21 22\\n21 20\\n46 47\\n2 1\\n31 30\\n29 30\\n11 14\\n42 43\\n50 51\\n34 35\\n36 35\\n24 23\\n48 47\\n41 1\\n28 29\\n45 44\\n16 15\\n5 4\\n6 5\\n18 19\\n9 8\\n37 38\\n11 12\\n39 37\\n49 48\\n50 49\\n43 44\\n50 53\\n3 4\\n50 52\\n24 25\\n7 6\\n46 45\\n2 3\\n17 18\\n31 32\\n19 20\\n7 8\\n15 1\\n36 37\\n23 22\\n9 10\\n17 16\\n24 26\\n28 1\\n38 52 41 35 53 43 3 29 36 4 23 20 46 5 40 30 49 25 16 48 17 27 21 9 45 44 15 13 14 2\\n\", \"10 4\\n2 3\\n4 2\\n8 9\\n6 5\\n8 1\\n5 1\\n8 10\\n7 5\\n1 2\\n4 10 2 5\\n\", \"10 5\\n4 5\\n9 1\\n1 2\\n7 1\\n5 1\\n10 1\\n7 3\\n6 3\\n5 8\\n5 2 7 10 1\\n\", \"10 4\\n8 7\\n7 6\\n1 2\\n3 2\\n3 4\\n6 5\\n10 7\\n7 9\\n5 4\\n9 5 10 4\\n\", \"5 4\\n2 3\\n2 1\\n3 5\\n4 3\\n4 2 5 1\\n\", \"5 1\\n1 2\\n2 3\\n3 4\\n4 5\\n4\\n\"], \"outputs\": [\"2\\n3\\n\", \"2\\n4\\n\", \"1\\n0\\n\", \"1\\n0\\n\", \"6\\n1\\n\", \"4\\n1\\n\", \"12\\n1\\n\", \"3\\n1\\n\", \"3\\n6\\n\", \"1\\n16\\n\", \"3\\n53\\n\", \"1\\n5\\n\", \"1\\n8\\n\", \"4\\n14\\n\", \"4\\n34\\n\", \"6\\n66\\n\", \"3\\n2\\n\", \"1\\n18\\n\", \"2\\n6\\n\", \"6\\n16\\n\", \"3\\n70\\n\", \"1\\n37\\n\", \"19\\n41\\n\", \"1\\n32\\n\", \"4\\n16\\n\", \"3\\n46\\n\", \"14\\n21\\n\", \"1\\n20\\n\", \"27\\n13\\n\", \"7\\n11\\n\", \"5\\n6\\n\", \"11\\n18\\n\", \"12\\n21\\n\", \"3\\n1\\n\", \"13\\n74\\n\", \"4\\n6\\n\", \"2\\n6\\n\", \"4\\n6\\n\", \"1\\n5\\n\", \"4\\n0\\n\"]}", "source": "primeintellect"}
Ari the monster is not an ordinary monster. She is the hidden identity of Super M, the Byteforces’ superhero. Byteforces is a country that consists of n cities, connected by n - 1 bidirectional roads. Every road connects exactly two distinct cities, and the whole road system is designed in a way that one is able to go from any city to any other city using only the given roads. There are m cities being attacked by humans. So Ari... we meant Super M have to immediately go to each of the cities being attacked to scare those bad humans. Super M can pass from one city to another only using the given roads. Moreover, passing through one road takes her exactly one kron - the time unit used in Byteforces. [Image] However, Super M is not on Byteforces now - she is attending a training camp located in a nearby country Codeforces. Fortunately, there is a special device in Codeforces that allows her to instantly teleport from Codeforces to any city of Byteforces. The way back is too long, so for the purpose of this problem teleportation is used exactly once. You are to help Super M, by calculating the city in which she should teleport at the beginning in order to end her job in the minimum time (measured in krons). Also, provide her with this time so she can plan her way back to Codeforces. -----Input----- The first line of the input contains two integers n and m (1 ≤ m ≤ n ≤ 123456) - the number of cities in Byteforces, and the number of cities being attacked respectively. Then follow n - 1 lines, describing the road system. Each line contains two city numbers u_{i} and v_{i} (1 ≤ u_{i}, v_{i} ≤ n) - the ends of the road i. The last line contains m distinct integers - numbers of cities being attacked. These numbers are given in no particular order. -----Output----- First print the number of the city Super M should teleport to. If there are many possible optimal answers, print the one with the lowest city number. Then print the minimum possible time needed to scare all humans in cities being attacked, measured in Krons. Note that the correct answer is always unique. -----Examples----- Input 7 2 1 2 1 3 1 4 3 5 3 6 3 7 2 7 Output 2 3 Input 6 4 1 2 2 3 2 4 4 5 4 6 2 4 5 6 Output 2 4 -----Note----- In the first sample, there are two possibilities to finish the Super M's job in 3 krons. They are: $2 \rightarrow 1 \rightarrow 3 \rightarrow 7$ and $7 \rightarrow 3 \rightarrow 1 \rightarrow 2$. However, you should choose the first one as it starts in the city with the lower number. Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0
{"tests": "{\"inputs\": [\"5 3 3 1 1\\n\", \"10 5 5 5 15\\n\", \"5 0 0 0 7\\n\", \"10 0 0 0 0\\n\", \"100000 100000 100000 10000 10000\\n\", \"100000 -100000 100000 -10000 100000\\n\", \"1 0 0 0 -1\\n\", \"100000 83094 84316 63590 53480\\n\", \"1 0 0 0 0\\n\", \"1 0 0 -2 -2\\n\", \"10 0 0 4 0\\n\", \"82 1928 -30264 2004 -30294\\n\", \"75 -66998 89495 -66988 89506\\n\", \"11 9899 34570 9895 34565\\n\", \"21 7298 -45672 7278 -45677\\n\", \"31 84194 -71735 84170 -71758\\n\", \"436 25094 -66597 25383 -66277\\n\", \"390 -98011 78480 -98362 78671\\n\", \"631 -21115 -1762 -21122 -1629\\n\", \"872 55782 51671 54965 51668\\n\", \"519 -92641 -28571 -92540 -28203\\n\", \"3412 23894 22453 26265 25460\\n\", \"3671 -99211 -3610 -99825 -1547\\n\", \"3930 -76494 -83852 -78181 -81125\\n\", \"4189 -24915 61224 -28221 65024\\n\", \"8318 -2198 35161 3849 29911\\n\", \"15096 -12439 58180 -10099 50671\\n\", \"70343 64457 3256 83082 -17207\\n\", \"66440 -58647 -76987 2151 -40758\\n\", \"62537 18249 96951 -3656 54754\\n\", \"88209 95145 42027 21960 26111\\n\", \"100000 -100000 -100000 -100000 -100000\\n\", \"100000 100000 100000 100000 100000\\n\", \"2 0 0 0 1\\n\", \"1 1 0 1 0\\n\", \"2 3 3 3 3\\n\", \"1 1 1 1 1\\n\", \"10 1 1 1 1\\n\", \"10 5 5 5 10\\n\", \"5 0 0 0 0\\n\"], \"outputs\": [\"3.7677669529663684 3.7677669529663684 3.914213562373095\\n\", \"5.0 5.0 10.0\\n\", \"0 0 5\\n\", \"5.0 0.0 5.0\\n\", \"100000 100000 100000\\n\", \"-105000.0 100000.0 95000.0\\n\", \"0.0 0.0 1.0\\n\", \"100069.69149822203 111154.72144376408 68243.2515742123\\n\", \"0.5 0.0 0.5\\n\", \"0 0 1\\n\", \"-3.0 0.0 7.0\\n\", \"1927.8636359254158 -30263.946172075823 81.85339643163098\\n\", \"-67018.22522977486 89472.75224724766 44.933034373659254\\n\", \"9900.435822761548 34571.794778451935 8.701562118716424\\n\", \"7298.186496251526 -45671.95337593712 20.80776406404415\\n\", \"84194 -71735 31\\n\", \"25092.386577687754 -66598.78648837341 433.5927874489312\\n\", \"-98011 78480 390\\n\", \"-21101.91768814977 -2010.563925154407 382.0920415665416\\n\", \"55809.49706065544 51671.100968398976 844.502753968685\\n\", \"-92659.18165738975 -28637.246038806206 450.30421903092184\\n\", \"23894 22453 3412\\n\", \"-98994.40770099283 -4337.736014416596 2911.7161725229744\\n\", \"-76303.71953677801 -84159.58436467478 3568.316718555632\\n\", \"-24915 61224 4189\\n\", \"-2315.0277877457083 35262.60342081445 8163.0201360632545\\n\", \"-13514.641370727473 61631.70557811649 11480.578066612283\\n\", \"50095.092392996106 19035.206193939368 49006.464709026186\\n\", \"-58647 -76987 66440\\n\", \"21702.922094423477 103604.5106422455 55040.41533091097\\n\", \"101649.61478542663 43441.59928844504 81552.34132964142\\n\", \"-50000.0 -100000.0 50000.0\\n\", \"150000.0 100000.0 50000.0\\n\", \"0.0 -0.5 1.5\\n\", \"1.5 0.0 0.5\\n\", \"4.0 3.0 1.0\\n\", \"1.5 1.0 0.5\\n\", \"6.0 1.0 5.0\\n\", \"5.0 2.5 7.5\\n\", \"2.5 0.0 2.5\\n\"]}", "source": "primeintellect"}
Fifa and Fafa are sharing a flat. Fifa loves video games and wants to download a new soccer game. Unfortunately, Fafa heavily uses the internet which consumes the quota. Fifa can access the internet through his Wi-Fi access point. This access point can be accessed within a range of r meters (this range can be chosen by Fifa) from its position. Fifa must put the access point inside the flat which has a circular shape of radius R. Fifa wants to minimize the area that is not covered by the access point inside the flat without letting Fafa or anyone outside the flat to get access to the internet. The world is represented as an infinite 2D plane. The flat is centered at (x_1, y_1) and has radius R and Fafa's laptop is located at (x_2, y_2), not necessarily inside the flat. Find the position and the radius chosen by Fifa for his access point which minimizes the uncovered area. -----Input----- The single line of the input contains 5 space-separated integers R, x_1, y_1, x_2, y_2 (1 ≤ R ≤ 10^5, |x_1|, |y_1|, |x_2|, |y_2| ≤ 10^5). -----Output----- Print three space-separated numbers x_{ap}, y_{ap}, r where (x_{ap}, y_{ap}) is the position which Fifa chose for the access point and r is the radius of its range. Your answer will be considered correct if the radius does not differ from optimal more than 10^{ - 6} absolutely or relatively, and also the radius you printed can be changed by no more than 10^{ - 6} (absolutely or relatively) in such a way that all points outside the flat and Fafa's laptop position are outside circle of the access point range. -----Examples----- Input 5 3 3 1 1 Output 3.7677669529663684 3.7677669529663684 3.914213562373095 Input 10 5 5 5 15 Output 5.0 5.0 10.0 Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0
{"tests": "{\"inputs\": [\"5 5 3\\n2 6 10 5 9\\n\", \"5 5 3\\n7 14 2 9 5\\n\", \"5 3 1\\n1 2 3 7 5\\n\", \"10 5 3\\n194757070 828985446 11164 80016 84729 117765558 111730436 164044532 419732980 48834\\n\", \"10 6 3\\n861947514 34945 190135645 68731 44833 387988147 84308862 878151920 458358978 809653252\\n\", \"10 8 3\\n677037706 41099140 89128206 168458947 367939060 940344093 191391519 981938946 31319 34929915\\n\", \"10 8 4\\n214605891 246349108 626595204 63889 794527783 83684156 5535 865709352 262484651 157889982\\n\", \"10 6 3\\n223143676 316703192 5286 408323576 61758 566101388 9871840 93989 91890 99264208\\n\", \"2 2 1\\n409447178 258805801\\n\", \"2 1 1\\n29161 15829\\n\", \"3 3 1\\n357071129 476170324 503481367\\n\", \"3 3 1\\n357071129 476170324 503481367\\n\", \"2 1 1\\n29161 15829\\n\", \"23 22 3\\n777717359 54451 123871650 211256633 193354035 935466677 800874233 532974165 62256 6511 3229 757421727 371493777 268999168 82355 22967 678259053 886134047 207070129 122416584 79851 35753 730872007\\n\", \"16 9 9\\n826588597 70843 528358243 60844 636968393 862405463 58232 69241 617006886 903909155 973050249 9381 49031 40100022 62141 43805\\n\", \"5 2 2\\n316313049 24390603 595539594 514135024 39108\\n\", \"5 2 1\\n12474 117513621 32958 767146609 20843\\n\", \"5 4 1\\n387119493 716009972 88510 375210205 910834347\\n\", \"5 4 3\\n674318396 881407702 882396010 208141498 53145\\n\", \"3 2 1\\n976825506 613159225 249024714\\n\", \"4 1 1\\n173508914 11188 90766233 20363\\n\", \"30 24 12\\n459253071 24156 64054 270713791 734796619 379920883 429646748 332144982 20929 27685 53253 82047732 172442017 34241 880121331 890223629 974692 954036632 68638567 972921811 421106382 64615 819330514 179630214 608594496 802986133 231010377 184513476 73143 93045\\n\", \"9 5 1\\n91623 466261329 311727429 18189 42557 22943 66177 473271749 62622\\n\", \"4 1 1\\n266639563 36517 172287193 166673809\\n\", \"5 2 2\\n19571 180100775 421217758 284511211 49475\\n\", \"4 2 2\\n736788713 82230 66800 37791827\\n\", \"5 1 1\\n33889 469945850 40673 939970023 776172319\\n\", \"1 1 0\\n2\\n\", \"1 1 0\\n3\\n\", \"1 1 1\\n2\\n\", \"1 1 1\\n3\\n\", \"2 2 2\\n2 3\\n\", \"2 2 2\\n2 4\\n\", \"2 2 1\\n3 2\\n\", \"4 2 0\\n3 5 7 9\\n\", \"3 2 0\\n1 3 2\\n\", \"2 1 1\\n2 4\\n\", \"7 3 0\\n1 3 5 7 9 11 13\\n\", \"8 4 4\\n1 3 5 7 9 11 13 15\\n\", \"2 1 1\\n1 3\\n\"], \"outputs\": [\"YES\\n1 9\\n1 5\\n1 10\\n1 6\\n1 2\\n\", \"NO\\n\", \"YES\\n3 5 1 3\\n1 7\\n1 2\\n\", \"NO\\n\", \"YES\\n5 387988147 861947514 84308862 34945 190135645\\n1 44833\\n1 68731\\n1 809653252\\n1 458358978\\n1 878151920\\n\", \"YES\\n3 34929915 677037706 41099140\\n1 31319\\n1 191391519\\n1 940344093\\n1 168458947\\n1 981938946\\n1 367939060\\n1 89128206\\n\", \"NO\\n\", \"NO\\n\", \"YES\\n1 258805801\\n1 409447178\\n\", \"YES\\n2 15829 29161\\n\", \"YES\\n1 503481367\\n1 357071129\\n1 476170324\\n\", \"YES\\n1 503481367\\n1 357071129\\n1 476170324\\n\", \"YES\\n2 15829 29161\\n\", \"YES\\n2 730872007 123871650\\n1 35753\\n1 79851\\n1 207070129\\n1 886134047\\n1 678259053\\n1 22967\\n1 82355\\n1 371493777\\n1 757421727\\n1 3229\\n1 6511\\n1 532974165\\n1 800874233\\n1 935466677\\n1 193354035\\n1 211256633\\n1 54451\\n1 777717359\\n1 122416584\\n1 268999168\\n1 62256\\n\", \"YES\\n3 40100022 826588597 70843\\n1 617006886\\n1 58232\\n1 60844\\n2 43805 62141\\n2 49031 9381\\n2 973050249 903909155\\n2 69241 862405463\\n2 636968393 528358243\\n\", \"YES\\n4 39108 595539594 316313049 24390603\\n1 514135024\\n\", \"YES\\n4 20843 12474 117513621 767146609\\n1 32958\\n\", \"YES\\n2 910834347 716009972\\n1 375210205\\n1 387119493\\n1 88510\\n\", \"YES\\n2 53145 674318396\\n1 208141498\\n1 882396010\\n1 881407702\\n\", \"YES\\n2 613159225 976825506\\n1 249024714\\n\", \"YES\\n4 11188 173508914 90766233 20363\\n\", \"YES\\n7 93045 459253071 270713791 734796619 379920883 20929 27685\\n1 73143\\n1 231010377\\n1 802986133\\n1 64615\\n1 972921811\\n1 68638567\\n1 890223629\\n1 880121331\\n1 34241\\n1 172442017\\n1 53253\\n1 184513476\\n1 608594496\\n1 179630214\\n1 819330514\\n1 421106382\\n1 954036632\\n1 974692\\n1 82047732\\n1 332144982\\n1 429646748\\n1 64054\\n1 24156\\n\", \"YES\\n5 473271749 91623 466261329 311727429 18189\\n1 66177\\n1 22943\\n1 42557\\n1 62622\\n\", \"YES\\n4 166673809 172287193 266639563 36517\\n\", \"YES\\n3 421217758 19571 180100775\\n2 49475 284511211\\n\", \"YES\\n3 66800 736788713 37791827\\n1 82230\\n\", \"YES\\n5 469945850 33889 40673 939970023 776172319\\n\", \"NO\\n\", \"YES\\n1 3\\n\", \"YES\\n1 2\\n\", \"NO\\n\", \"NO\\n\", \"YES\\n1 4\\n1 2\\n\", \"YES\\n1 3\\n1 2\\n\", \"YES\\n3 9 3 5\\n1 7\\n\", \"YES\\n2 3 2\\n1 1\\n\", \"YES\\n2 4 2\\n\", \"YES\\n5 13 1 3 5 7\\n1 11\\n1 9\\n\", \"YES\\n2 15 13\\n2 11 9\\n2 7 5\\n2 3 1\\n\", \"YES\\n2 3 1\\n\"]}", "source": "primeintellect"}
Devu being a small kid, likes to play a lot, but he only likes to play with arrays. While playing he came up with an interesting question which he could not solve, can you please solve it for him? Given an array consisting of distinct integers. Is it possible to partition the whole array into k disjoint non-empty parts such that p of the parts have even sum (each of them must have even sum) and remaining k - p have odd sum? (note that parts need not to be continuous). If it is possible to partition the array, also give any possible way of valid partitioning. -----Input----- The first line will contain three space separated integers n, k, p (1 ≤ k ≤ n ≤ 10^5; 0 ≤ p ≤ k). The next line will contain n space-separated distinct integers representing the content of array a: a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 10^9). -----Output----- In the first line print "YES" (without the quotes) if it is possible to partition the array in the required way. Otherwise print "NO" (without the quotes). If the required partition exists, print k lines after the first line. The i^{th} of them should contain the content of the i^{th} part. Print the content of the part in the line in the following way: firstly print the number of elements of the part, then print all the elements of the part in arbitrary order. There must be exactly p parts with even sum, each of the remaining k - p parts must have odd sum. As there can be multiple partitions, you are allowed to print any valid partition. -----Examples----- Input 5 5 3 2 6 10 5 9 Output YES 1 9 1 5 1 10 1 6 1 2 Input 5 5 3 7 14 2 9 5 Output NO Input 5 3 1 1 2 3 7 5 Output YES 3 5 1 3 1 7 1 2 Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0
{"tests": "{\"inputs\": [\"2 2 2\\n\", \"2 3 3\\n\", \"1 1 1\\n\", \"3 5 10\\n\", \"2 3 1000000000000000000\\n\", \"7 8 9\\n\", \"8 10 11\\n\", \"5 30 930\\n\", \"3 3 3\\n\", \"1 5 5\\n\", \"1 2 2\\n\", \"1 2 5\\n\", \"1 2 4\\n\", \"1000000000000000000 1000000000000000000 1000000000000000000\\n\", \"1 125 15625\\n\", \"1000000000000 1000000000000000 1000000000000000000\\n\", \"5 2 2\\n\", \"1 3 6561\\n\", \"3 6 5\\n\", \"1 5 625\\n\", \"3 2 2\\n\", \"1 2 65536\\n\", \"1 12 1728\\n\", \"110 115 114\\n\", \"1 2 128\\n\", \"110 1000 998\\n\", \"5 5 4\\n\", \"2 2 10\\n\", \"1 1000000000000000000 1000000000000000000\\n\", \"2 999999999999999999 1000000000000000000\\n\", \"1 4 288230376151711744\\n\", \"1 999999999 1000000000000000000\\n\", \"12365 1 1\\n\", \"135645 1 365333453\\n\", \"1 1 12345678901234567\\n\", \"563236 135645 356563\\n\", \"6 1 1\\n\", \"1 7 1\\n\", \"1 10 1000000000000000000\\n\", \"1 10 999999999999999999\\n\"], \"outputs\": [\"2\\n\", \"1\\n\", \"inf\\n\", \"0\\n\", \"0\\n\", \"1\\n\", \"0\\n\", \"1\\n\", \"2\\n\", \"1\\n\", \"1\\n\", \"1\\n\", \"1\\n\", \"2\\n\", \"1\\n\", \"1\\n\", \"1\\n\", \"1\\n\", \"0\\n\", \"1\\n\", \"1\\n\", \"1\\n\", \"1\\n\", \"0\\n\", \"1\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"1\\n\", \"0\\n\", \"1\\n\", \"0\\n\", \"1\\n\", \"0\\n\", \"0\\n\", \"0\\n\", \"1\\n\", \"0\\n\", \"1\\n\", \"0\\n\"]}", "source": "primeintellect"}
Vasya is studying in the last class of school and soon he will take exams. He decided to study polynomials. Polynomial is a function P(x) = a_0 + a_1x^1 + ... + a_{n}x^{n}. Numbers a_{i} are called coefficients of a polynomial, non-negative integer n is called a degree of a polynomial. Vasya has made a bet with his friends that he can solve any problem with polynomials. They suggested him the problem: "Determine how many polynomials P(x) exist with integer non-negative coefficients so that $P(t) = a$, and $P(P(t)) = b$, where $t, a$ and b are given positive integers"? Vasya does not like losing bets, but he has no idea how to solve this task, so please help him to solve the problem. -----Input----- The input contains three integer positive numbers $t, a, b$ no greater than 10^18. -----Output----- If there is an infinite number of such polynomials, then print "inf" without quotes, otherwise print the reminder of an answer modulo 10^9 + 7. -----Examples----- Input 2 2 2 Output 2 Input 2 3 3 Output 1 Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0
{"tests": "{\"inputs\": [\"AC|T\\nL\\n\", \"|ABC\\nXYZ\\n\", \"W|T\\nF\\n\", \"ABC|\\nD\\n\", \"A|BC\\nDEF\\n\", \"|\\nABC\\n\", \"|\\nZXCVBANMIO\\n\", \"|C\\nA\\n\", \"|\\nAB\\n\", \"A|XYZ\\nUIOPL\\n\", \"K|B\\nY\\n\", \"EQJWDOHKZRBISPLXUYVCMNFGT|\\nA\\n\", \"|MACKERIGZPVHNDYXJBUFLWSO\\nQT\\n\", \"ERACGIZOVPT|WXUYMDLJNQS\\nKB\\n\", \"CKQHRUZMISGE|FBVWPXDLTJYN\\nOA\\n\", \"V|CMOEUTAXBFWSK\\nDLRZJGIYNQHP\\n\", \"QWHNMALDGKTJ|\\nPBRYVXZUESCOIF\\n\", \"|\\nFXCVMUEWZAHNDOSITPRLKQJYBG\\n\", \"IB|PCGHZ\\nFXWTJQNEKAUM\\n\", \"EC|IWAXQ\\nJUHSRKGZTOMYN\\n\", \"VDINYMA|UQKWBCLRHZJ\\nXEGOF\\n\", \"ZLTPSIQUBAR|XFDEMYC\\nHNOJWG\\n\", \"R|FLZOTJNU\\nGIYHKVX\\n\", \"W|TL\\nQROFSADYPKHEJNMXBZVUCIG\\n\", \"NRDFQSEKLAYMOT|ZH\\nGUXIBJCVPW\\n\", \"FGRT|\\nAC\\n\", \"|FGRT\\nAC\\n\", \"A|\\nB\\n\", \"|A\\nB\\n\", \"|\\nA\\n\", \"|\\nQWERTYUIOPASDFGHJKLZXCVBNM\\n\", \"QWERTYUIOPASDFGHJKLZXCVBN|\\nM\\n\", \"QWERTY|VBN\\nUIOPASDFGHJKLZXC\\n\", \"ABC|D\\nKSL\\n\", \"A|BCDEF\\nGH\\n\", \"|ABC\\nD\\n\", \"A|BC\\nDE\\n\", \"|ASD\\nX\\n\", \"AB|CDEF\\nXYZRT\\n\"], \"outputs\": [\"AC|TL\\n\", \"XYZ|ABC\\n\", \"Impossible\\n\", \"Impossible\\n\", \"ADF|BCE\\n\", \"Impossible\\n\", \"XVAMO|ZCBNI\\n\", \"A|C\\n\", \"B|A\\n\", \"Impossible\\n\", \"Impossible\\n\", \"Impossible\\n\", \"Impossible\\n\", \"ERACGIZOVPTB|WXUYMDLJNQSK\\n\", \"CKQHRUZMISGEA|FBVWPXDLTJYNO\\n\", \"VDLRZJGIYNQHP|CMOEUTAXBFWSK\\n\", \"QWHNMALDGKTJF|PBRYVXZUESCOI\\n\", \"XVUWANOIPLQYG|FCMEZHDSTRKJB\\n\", \"Impossible\\n\", \"ECJUHRGTMN|IWAXQSKZOY\\n\", \"Impossible\\n\", \"ZLTPSIQUBARG|XFDEMYCHNOJW\\n\", \"RGIYHKVX|FLZOTJNU\\n\", \"WQOSDPHJMBVCG|TLRFAYKENXZUI\\n\", \"Impossible\\n\", \"Impossible\\n\", \"Impossible\\n\", \"A|B\\n\", \"B|A\\n\", \"Impossible\\n\", \"WRYIPSFHKZCBM|QETUOADGJLXVN\\n\", \"Impossible\\n\", \"Impossible\\n\", \"Impossible\\n\", \"Impossible\\n\", \"Impossible\\n\", \"Impossible\\n\", \"Impossible\\n\", \"Impossible\\n\"]}", "source": "primeintellect"}
Ksenia has ordinary pan scales and several weights of an equal mass. Ksenia has already put some weights on the scales, while other weights are untouched. Ksenia is now wondering whether it is possible to put all the remaining weights on the scales so that the scales were in equilibrium. The scales is in equilibrium if the total sum of weights on the left pan is equal to the total sum of weights on the right pan. -----Input----- The first line has a non-empty sequence of characters describing the scales. In this sequence, an uppercase English letter indicates a weight, and the symbol "|" indicates the delimiter (the character occurs in the sequence exactly once). All weights that are recorded in the sequence before the delimiter are initially on the left pan of the scale. All weights that are recorded in the sequence after the delimiter are initially on the right pan of the scale. The second line contains a non-empty sequence containing uppercase English letters. Each letter indicates a weight which is not used yet. It is guaranteed that all the English letters in the input data are different. It is guaranteed that the input does not contain any extra characters. -----Output----- If you cannot put all the weights on the scales so that the scales were in equilibrium, print string "Impossible". Otherwise, print the description of the resulting scales, copy the format of the input. If there are multiple answers, print any of them. -----Examples----- Input AC|T L Output AC|TL Input |ABC XYZ Output XYZ|ABC Input W|T F Output Impossible Input ABC| D Output Impossible Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0
{"tests": "{\"inputs\": [\"0 0\\n1 0\\n0 1\\n\", \"0 -1\\n-1 0\\n1 1\\n\", \"-1 -1\\n0 1\\n1 1\\n\", \"1000 1000\\n-1000 -1000\\n-1000 1000\\n\", \"-1000 1000\\n1000 -1000\\n-1000 -1000\\n\", \"-4 -5\\n7 10\\n3 -10\\n\", \"-86 25\\n-55 18\\n58 24\\n\", \"-301 -397\\n192 317\\n-98 729\\n\", \"1000 1000\\n999 1000\\n-1000 -1000\\n\", \"-1000 0\\n999 0\\n1000 1\\n\", \"-1000 1000\\n1000 -1000\\n0 1\\n\", \"1000 -1000\\n1000 1000\\n-1000 0\\n\", \"-1000 -1000\\n-1 -1000\\n-1000 -2\\n\", \"0 -1000\\n0 1000\\n-1 -1000\\n\", \"0 -1000\\n0 1000\\n1 -1000\\n\", \"9 5\\n-6 6\\n8 -8\\n\", \"5 0\\n-7 -7\\n-3 3\\n\", \"1 -1\\n1 7\\n2 9\\n\", \"-7 -9\\n1 -10\\n4 8\\n\", \"10 3\\n4 -9\\n-8 -2\\n\", \"6 -5\\n4 -4\\n-6 5\\n\", \"2 7\\n8 9\\n-5 4\\n\", \"-6 2\\n-10 -7\\n9 -6\\n\", \"-6 -23\\n-68 -8\\n-63 71\\n\", \"-11 -61\\n56 9\\n-57 46\\n\", \"-17 0\\n-95 26\\n-25 -54\\n\", \"-22 -38\\n-70 -58\\n-19 21\\n\", \"73 -2\\n79 -16\\n13 -4\\n\", \"-33 60\\n3 0\\n-57 97\\n\", \"-38 22\\n53 -83\\n-50 -28\\n\", \"57 83\\n-24 -66\\n-19 -53\\n\", \"21 185\\n966 -167\\n-291 -804\\n\", \"-917 -272\\n-285 -579\\n318 -437\\n\", \"-969 -199\\n766 -179\\n626 -372\\n\", \"980 -656\\n-485 -591\\n-766 880\\n\", \"928 1\\n-319 111\\n428 -754\\n\", \"-10 658\\n732 -301\\n735 197\\n\", \"-948 201\\n-519 -713\\n459 564\\n\", \"-114 -28\\n532 573\\n766 931\\n\"], \"outputs\": [\"3\\n1 -1\\n-1 1\\n1 1\\n\", \"3\\n-2 -2\\n2 0\\n0 2\\n\", \"3\\n-2 -1\\n0 -1\\n2 3\\n\", \"3\\n1000 -1000\\n1000 3000\\n-3000 -1000\\n\", \"3\\n1000 1000\\n-3000 1000\\n1000 -3000\\n\", \"3\\n0 15\\n-8 -25\\n14 5\\n\", \"3\\n-199 19\\n27 31\\n89 17\\n\", \"3\\n-11 -809\\n-591 15\\n395 1443\\n\", \"3\\n2999 3000\\n-999 -1000\\n-1001 -1000\\n\", \"3\\n-1001 -1\\n-999 1\\n2999 1\\n\", \"3\\n0 -1\\n-2000 2001\\n2000 -1999\\n\", \"3\\n3000 0\\n-1000 -2000\\n-1000 2000\\n\", \"3\\n-1 -1998\\n-1999 -2\\n-1 -2\\n\", \"3\\n1 1000\\n-1 -3000\\n-1 1000\\n\", \"3\\n-1 1000\\n1 -3000\\n1 1000\\n\", \"3\\n-5 19\\n23 -9\\n-7 -7\\n\", \"3\\n1 -10\\n9 10\\n-15 -4\\n\", \"3\\n0 -3\\n2 1\\n2 17\\n\", \"3\\n-10 -27\\n-4 9\\n12 7\\n\", \"3\\n22 -4\\n-2 10\\n-14 -14\\n\", \"3\\n16 -14\\n-4 4\\n-8 6\\n\", \"3\\n15 12\\n-11 2\\n1 6\\n\", \"3\\n-25 1\\n13 3\\n5 -15\\n\", \"3\\n-11 -102\\n-1 56\\n-125 86\\n\", \"3\\n102 -98\\n-124 -24\\n10 116\\n\", \"3\\n-87 80\\n53 -80\\n-103 -28\\n\", \"3\\n-73 -117\\n29 41\\n-67 1\\n\", \"3\\n139 -14\\n7 10\\n19 -18\\n\", \"3\\n27 -37\\n-93 157\\n-21 37\\n\", \"3\\n65 -33\\n-141 77\\n41 -133\\n\", \"3\\n52 70\\n62 96\\n-100 -202\\n\", \"3\\n1278 822\\n-1236 -452\\n654 -1156\\n\", \"3\\n-1520 -414\\n-314 -130\\n950 -744\\n\", \"3\\n-829 -6\\n-1109 -392\\n2361 -352\\n\", \"3\\n1261 -2127\\n699 815\\n-2231 945\\n\", \"3\\n181 866\\n1675 -864\\n-819 -644\\n\", \"3\\n-13 160\\n-7 1156\\n1477 -762\\n\", \"3\\n-1926 -1076\\n30 1478\\n888 -350\\n\", \"3\\n-348 -386\\n120 330\\n1412 1532\\n\"]}", "source": "primeintellect"}
Long time ago Alex created an interesting problem about parallelogram. The input data for this problem contained four integer points on the Cartesian plane, that defined the set of vertices of some non-degenerate (positive area) parallelogram. Points not necessary were given in the order of clockwise or counterclockwise traversal. Alex had very nice test for this problem, but is somehow happened that the last line of the input was lost and now he has only three out of four points of the original parallelogram. He remembers that test was so good that he asks you to restore it given only these three points. -----Input----- The input consists of three lines, each containing a pair of integer coordinates x_{i} and y_{i} ( - 1000 ≤ x_{i}, y_{i} ≤ 1000). It's guaranteed that these three points do not lie on the same line and no two of them coincide. -----Output----- First print integer k — the number of ways to add one new integer point such that the obtained set defines some parallelogram of positive area. There is no requirement for the points to be arranged in any special order (like traversal), they just define the set of vertices. Then print k lines, each containing a pair of integer — possible coordinates of the fourth point. -----Example----- Input 0 0 1 0 0 1 Output 3 1 -1 -1 1 1 1 -----Note----- If you need clarification of what parallelogram is, please check Wikipedia page: https://en.wikipedia.org/wiki/Parallelogram Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0.625
{"tests": "{\"inputs\": [\"11\\n1 2 3 -4 -5 -6 5 -5 -6 -7 6\\n\", \"5\\n0 -1 100 -1 0\\n\", \"1\\n0\\n\", \"1\\n-1\\n\", \"2\\n0 0\\n\", \"2\\n-2 2\\n\", \"2\\n-2 -1\\n\", \"12\\n1 -12 -5 -8 0 -8 -1 -1 -6 12 -9 12\\n\", \"4\\n1 2 0 3\\n\", \"4\\n4 -3 3 3\\n\", \"4\\n0 -3 4 -3\\n\", \"4\\n-3 -2 4 -3\\n\", \"4\\n-3 -2 -1 -4\\n\", \"5\\n-2 -2 4 0 -1\\n\", \"5\\n-5 -3 -1 2 -1\\n\", \"5\\n-3 -2 -3 -2 -3\\n\", \"10\\n0 5 2 3 10 9 4 9 9 3\\n\", \"10\\n10 2 1 2 9 10 7 4 -4 5\\n\", \"10\\n1 -3 1 10 -7 -6 7 0 -5 3\\n\", \"10\\n6 5 -10 -4 -3 -7 5 -2 -6 -10\\n\", \"10\\n-2 -4 -1 -6 -5 -5 -7 0 -7 -8\\n\", \"4\\n1 2 3 4\\n\", \"4\\n1 2 3 -4\\n\", \"4\\n-4 2 1 2\\n\", \"1\\n-1\\n\", \"2\\n2 -1\\n\", \"2\\n-100 100\\n\", \"3\\n-100 0 -100\\n\", \"5\\n1 2 3 -1 -1\\n\", \"5\\n-1 -1 2 3 4\\n\", \"3\\n-3 -4 -5\\n\", \"4\\n-3 -4 1 -3\\n\", \"1\\n-1\\n\", \"2\\n-1 0\\n\", \"4\\n0 0 0 0\\n\", \"3\\n-1 -1 -1\\n\", \"6\\n-1 -1 0 -1 -1 -1\\n\", \"2\\n0 0\\n\", \"6\\n0 0 -1 -1 -1 0\\n\"], \"outputs\": [\"3\\n5 3 3 \", \"1\\n5 \", \"1\\n1 \", \"1\\n1 \", \"1\\n2 \", \"1\\n2 \", \"1\\n2 \", \"4\\n3 3 2 4 \", \"1\\n4 \", \"1\\n4 \", \"1\\n4 \", \"2\\n1 3 \", \"2\\n2 2 \", \"2\\n1 4 \", \"2\\n2 3 \", \"3\\n1 2 2 \", \"1\\n10 \", \"1\\n10 \", \"2\\n5 5 \", \"4\\n3 2 3 2 \", \"5\\n1 2 2 2 3 \", \"1\\n4 \", \"1\\n4 \", \"1\\n4 \", \"1\\n1 \", \"1\\n2 \", \"1\\n2 \", \"1\\n3 \", \"1\\n5 \", \"1\\n5 \", \"2\\n1 2 \", \"2\\n1 3 \", \"1\\n1 \", \"1\\n2 \", \"1\\n4 \", \"2\\n1 2 \", \"3\\n1 3 2 \", \"1\\n2 \", \"2\\n3 3 \"]}", "source": "primeintellect"}
Polycarpus has been working in the analytic department of the "F.R.A.U.D." company for as much as n days. Right now his task is to make a series of reports about the company's performance for the last n days. We know that the main information in a day report is value a_{i}, the company's profit on the i-th day. If a_{i} is negative, then the company suffered losses on the i-th day. Polycarpus should sort the daily reports into folders. Each folder should include data on the company's performance for several consecutive days. Of course, the information on each of the n days should be exactly in one folder. Thus, Polycarpus puts information on the first few days in the first folder. The information on the several following days goes to the second folder, and so on. It is known that the boss reads one daily report folder per day. If one folder has three or more reports for the days in which the company suffered losses (a_{i} < 0), he loses his temper and his wrath is terrible. Therefore, Polycarpus wants to prepare the folders so that none of them contains information on three or more days with the loss, and the number of folders is minimal. Write a program that, given sequence a_{i}, will print the minimum number of folders. -----Input----- The first line contains integer n (1 ≤ n ≤ 100), n is the number of days. The second line contains a sequence of integers a_1, a_2, ..., a_{n} (|a_{i}| ≤ 100), where a_{i} means the company profit on the i-th day. It is possible that the company has no days with the negative a_{i}. -----Output----- Print an integer k — the required minimum number of folders. In the second line print a sequence of integers b_1, b_2, ..., b_{k}, where b_{j} is the number of day reports in the j-th folder. If there are multiple ways to sort the reports into k days, print any of them. -----Examples----- Input 11 1 2 3 -4 -5 -6 5 -5 -6 -7 6 Output 3 5 3 3 Input 5 0 -1 100 -1 0 Output 1 5 -----Note----- Here goes a way to sort the reports from the first sample into three folders: 1 2 3 -4 -5 | -6 5 -5 | -6 -7 6 In the second sample you can put all five reports in one folder. Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0
{"tests": "{\"inputs\": [\"3 5\\n\", \"4 4\\n\", \"100 100\\n\", \"1 100\\n\", \"100 1\\n\", \"1 4\\n\", \"1 1\\n\", \"8 8\\n\", \"7 2\\n\", \"24 15\\n\", \"19 30\\n\", \"15 31\\n\", \"14 15\\n\", \"58 33\\n\", \"15 25\\n\", \"59 45\\n\", \"3 73\\n\", \"48 1\\n\", \"100 25\\n\", \"40 49\\n\", \"85 73\\n\", \"29 1\\n\", \"74 25\\n\", \"24 57\\n\", \"23 12\\n\", \"2 99\\n\", \"98 2\\n\", \"2 97\\n\", \"30 54\\n\", \"32 53\\n\", \"32 54\\n\", \"1 2\\n\", \"2 1\\n\", \"2 2\\n\", \"1 3\\n\", \"3 1\\n\", \"1 4\\n\", \"2 3\\n\", \"3 2\\n\"], \"outputs\": [\"6\\n\", \"5\\n\", \"197\\n\", \"98\\n\", \"98\\n\", \"2\\n\", \"0\\n\", \"13\\n\", \"7\\n\", \"36\\n\", \"47\\n\", \"44\\n\", \"27\\n\", \"89\\n\", \"38\\n\", \"102\\n\", \"74\\n\", \"47\\n\", \"122\\n\", \"86\\n\", \"155\\n\", \"28\\n\", \"97\\n\", \"78\\n\", \"33\\n\", \"99\\n\", \"97\\n\", \"97\\n\", \"81\\n\", \"82\\n\", \"84\\n\", \"1\\n\", \"1\\n\", \"1\\n\", \"2\\n\", \"2\\n\", \"2\\n\", \"3\\n\", \"3\\n\"]}", "source": "primeintellect"}
Friends are going to play console. They have two joysticks and only one charger for them. Initially first joystick is charged at a_1 percent and second one is charged at a_2 percent. You can connect charger to a joystick only at the beginning of each minute. In one minute joystick either discharges by 2 percent (if not connected to a charger) or charges by 1 percent (if connected to a charger). Game continues while both joysticks have a positive charge. Hence, if at the beginning of minute some joystick is charged by 1 percent, it has to be connected to a charger, otherwise the game stops. If some joystick completely discharges (its charge turns to 0), the game also stops. Determine the maximum number of minutes that game can last. It is prohibited to pause the game, i. e. at each moment both joysticks should be enabled. It is allowed for joystick to be charged by more than 100 percent. -----Input----- The first line of the input contains two positive integers a_1 and a_2 (1 ≤ a_1, a_2 ≤ 100), the initial charge level of first and second joystick respectively. -----Output----- Output the only integer, the maximum number of minutes that the game can last. Game continues until some joystick is discharged. -----Examples----- Input 3 5 Output 6 Input 4 4 Output 5 -----Note----- In the first sample game lasts for 6 minute by using the following algorithm: at the beginning of the first minute connect first joystick to the charger, by the end of this minute first joystick is at 4%, second is at 3%; continue the game without changing charger, by the end of the second minute the first joystick is at 5%, second is at 1%; at the beginning of the third minute connect second joystick to the charger, after this minute the first joystick is at 3%, the second one is at 2%; continue the game without changing charger, by the end of the fourth minute first joystick is at 1%, second one is at 3%; at the beginning of the fifth minute connect first joystick to the charger, after this minute the first joystick is at 2%, the second one is at 1%; at the beginning of the sixth minute connect second joystick to the charger, after this minute the first joystick is at 0%, the second one is at 2%. After that the first joystick is completely discharged and the game is stopped. Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0.125
{"tests": "{\"inputs\": [\"2 4 6\\n4 7\\n\", \"4 2 6\\n1 3 2 3\\n\", \"1 59139 1199252\\n70888\\n\", \"9 99252 6470888\\n74578 2746 96295 86884 21198 28655 22503 7868 47942\\n\", \"9 2 8\\n74578 2746 96295 86884 21198 28655 22503 7868 47942\\n\", \"1 1 1\\n1\\n\", \"1 9859 4748096\\n75634\\n\", \"1 25987 3264237\\n88891\\n\", \"1 9411 6813081\\n2149\\n\", \"9 48096 5475634\\n28248 27808 75072 58867 37890 95515 26685 68307 40390\\n\", \"7 64237 4288891\\n90429 44358 21145 30851 89174 29670 63571\\n\", \"1 13081 3102149\\n19907\\n\", \"9 29221 2106895\\n82089 18673 2890 99009 89855 30685 39232 82330 30021\\n\", \"9 10770 5887448\\n3054 67926 81667 95184 41139 64840 76118 18577 22469\\n\", \"7 35422 9924898\\n32532 92988 84636 99872 57831 31700 47597\\n\", \"5 51563 3705451\\n94713 9537 30709 63343 41819\\n\", \"9 407 2710197\\n24191 58791 9486 68030 25807 11 88665 32600 12100\\n\", \"8 96518 274071\\n59971 50121 4862 43967 73607 19138 90754 19513\\n\", \"9 6 4\\n28248 27808 75072 58867 37890 95515 26685 68307 40390\\n\", \"7 7 1\\n90429 44358 21145 30851 89174 29670 63571\\n\", \"1 1 9\\n19907\\n\", \"9 1 5\\n82089 18673 2890 99009 89855 30685 39232 82330 30021\\n\", \"9 10 8\\n3054 67926 81667 95184 41139 64840 76118 18577 22469\\n\", \"7 2 8\\n32532 92988 84636 99872 57831 31700 47597\\n\", \"5 3 1\\n94713 9537 30709 63343 41819\\n\", \"9 7 7\\n24191 58791 9486 68030 25807 11 88665 32600 12100\\n\", \"8 8 1\\n59971 50121 4862 43967 73607 19138 90754 19513\\n\", \"5 2 1\\n4 4 4 4 5\\n\", \"3 3 2\\n2 2 2\\n\", \"4 5 5\\n3 3 3 3\\n\", \"7 3 3\\n1 2 2 2 2 2 2\\n\", \"5 4 4\\n5 5 5 5 5\\n\", \"4 2 2\\n1 3 3 3\\n\", \"3 1 2\\n5 5 5\\n\", \"3 2 2\\n1 2 2\\n\", \"3 5 2\\n2 6 6\\n\", \"4 1 2\\n2 4 4 4\\n\", \"3 1 2\\n1 100 100\\n\", \"4 1 2\\n4 4 4 4\\n\"], \"outputs\": [\"11.00000000000000000000\\n\", \"5.00000000000000000000\\n\", \"130027.00000000000000000000\\n\", \"195547.00000000000000000000\\n\", \"96295.00000000000000000000\\n\", \"2.00000000000000000000\\n\", \"85493.00000000000000000000\\n\", \"114878.00000000000000000000\\n\", \"11560.00000000000000000000\\n\", \"143611.00000000000000000000\\n\", \"154666.00000000000000000000\\n\", \"32988.00000000000000000000\\n\", \"128230.00000000000000000000\\n\", \"105954.00000000000000000000\\n\", \"135294.00000000000000000000\\n\", \"146276.00000000000000000000\\n\", \"89072.00000000000000000000\\n\", \"187272.00000000000000000000\\n\", \"67630.20000000000000284217\\n\", \"58008.83333333333333214910\\n\", \"19908.00000000000000000000\\n\", \"88320.75000000000000000000\\n\", \"95184.00000000000000000000\\n\", \"99874.00000000000000000000\\n\", \"57646.00000000000000000000\\n\", \"78347.50000000000000000000\\n\", \"51010.14285714285714234961\\n\", \"4.40000000000000000009\\n\", \"2.66666666666666666674\\n\", \"5.00000000000000000000\\n\", \"2.33333333333333333326\\n\", \"5.80000000000000000017\\n\", \"3.33333333333333333326\\n\", \"5.66666666666666666652\\n\", \"2.50000000000000000000\\n\", \"6.50000000000000000000\\n\", \"4.33333333333333333348\\n\", \"100.50000000000000000000\\n\", \"4.50000000000000000000\\n\"]}", "source": "primeintellect"}
Every superhero has been given a power value by the Felicity Committee. The avengers crew wants to maximize the average power of the superheroes in their team by performing certain operations. Initially, there are $n$ superheroes in avengers team having powers $a_1, a_2, \ldots, a_n$, respectively. In one operation, they can remove one superhero from their team (if there are at least two) or they can increase the power of a superhero by $1$. They can do at most $m$ operations. Also, on a particular superhero at most $k$ operations can be done. Can you help the avengers team to maximize the average power of their crew? -----Input----- The first line contains three integers $n$, $k$ and $m$ ($1 \le n \le 10^{5}$, $1 \le k \le 10^{5}$, $1 \le m \le 10^{7}$) — the number of superheroes, the maximum number of times you can increase power of a particular superhero, and the total maximum number of operations. The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^{6}$) — the initial powers of the superheroes in the cast of avengers. -----Output----- Output a single number — the maximum final average power. Your answer is considered correct if its absolute or relative error does not exceed $10^{-6}$. Formally, let your answer be $a$, and the jury's answer be $b$. Your answer is accepted if and only if $\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$. -----Examples----- Input 2 4 6 4 7 Output 11.00000000000000000000 Input 4 2 6 1 3 2 3 Output 5.00000000000000000000 -----Note----- In the first example, the maximum average is obtained by deleting the first element and increasing the second element four times. In the second sample, one of the ways to achieve maximum average is to delete the first and the third element and increase the second and the fourth elements by $2$ each. Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0
{"tests": "{\"inputs\": [\"5 6\\n\", \"6 12\\n\", \"10 31\\n\", \"1 1\\n\", \"2 1\\n\", \"100000 1\\n\", \"572 99644\\n\", \"571 99404\\n\", \"100 3044\\n\", \"10 32\\n\", \"100000 99998\\n\", \"530 100000\\n\", \"2 2\\n\", \"3 2\\n\", \"1 1\\n\", \"1 2\\n\", \"1 3\\n\", \"1 4\\n\", \"1 5\\n\", \"2 1\\n\", \"2 2\\n\", \"2 3\\n\", \"2 4\\n\", \"2 5\\n\", \"3 1\\n\", \"3 2\\n\", \"3 3\\n\", \"3 4\\n\", \"3 5\\n\", \"4 1\\n\", \"4 2\\n\", \"4 3\\n\", \"4 4\\n\", \"4 5\\n\", \"5 1\\n\", \"5 2\\n\", \"5 3\\n\", \"5 4\\n\", \"5 5\\n\"], \"outputs\": [\"Possible\\n1 2\\n2 3\\n3 4\\n4 5\\n1 3\\n1 4\\n\", \"Impossible\\n\", \"Possible\\n1 2\\n2 3\\n3 4\\n4 5\\n5 6\\n6 7\\n7 8\\n8 9\\n9 10\\n1 3\\n1 4\\n1 5\\n2 5\\n3 5\\n1 6\\n1 7\\n2 7\\n3 7\\n4 7\\n5 7\\n1 8\\n3 8\\n5 8\\n1 9\\n2 9\\n4 9\\n5 9\\n7 9\\n1 10\\n3 10\\n7 10\\n\", \"Impossible\\n\", \"Possible\\n1 2\\n\", \"Impossible\\n\", \"Impossible\\n\", \"Impossible\\n\", \"Impossible\\n\", \"Impossible\\n\", \"Impossible\\n\", \"Impossible\\n\", \"Impossible\\n\", \"Possible\\n1 2\\n2 3\\n\", \"Impossible\\n\", \"Impossible\\n\", \"Impossible\\n\", \"Impossible\\n\", \"Impossible\\n\", \"Possible\\n1 2\\n\", \"Impossible\\n\", \"Impossible\\n\", \"Impossible\\n\", \"Impossible\\n\", \"Impossible\\n\", \"Possible\\n1 2\\n2 3\\n\", \"Possible\\n1 2\\n2 3\\n1 3\\n\", \"Impossible\\n\", \"Impossible\\n\", \"Impossible\\n\", \"Impossible\\n\", \"Possible\\n1 2\\n2 3\\n3 4\\n\", \"Possible\\n1 2\\n2 3\\n3 4\\n1 3\\n\", \"Possible\\n1 2\\n2 3\\n3 4\\n1 3\\n1 4\\n\", \"Impossible\\n\", \"Impossible\\n\", \"Impossible\\n\", \"Possible\\n1 2\\n2 3\\n3 4\\n4 5\\n\", \"Possible\\n1 2\\n2 3\\n3 4\\n4 5\\n1 3\\n\"]}", "source": "primeintellect"}
Let's call an undirected graph $G = (V, E)$ relatively prime if and only if for each edge $(v, u) \in E$  $GCD(v, u) = 1$ (the greatest common divisor of $v$ and $u$ is $1$). If there is no edge between some pair of vertices $v$ and $u$ then the value of $GCD(v, u)$ doesn't matter. The vertices are numbered from $1$ to $|V|$. Construct a relatively prime graph with $n$ vertices and $m$ edges such that it is connected and it contains neither self-loops nor multiple edges. If there exists no valid graph with the given number of vertices and edges then output "Impossible". If there are multiple answers then print any of them. -----Input----- The only line contains two integers $n$ and $m$ ($1 \le n, m \le 10^5$) — the number of vertices and the number of edges. -----Output----- If there exists no valid graph with the given number of vertices and edges then output "Impossible". Otherwise print the answer in the following format: The first line should contain the word "Possible". The $i$-th of the next $m$ lines should contain the $i$-th edge $(v_i, u_i)$ of the resulting graph ($1 \le v_i, u_i \le n, v_i \neq u_i$). For each pair $(v, u)$ there can be no more pairs $(v, u)$ or $(u, v)$. The vertices are numbered from $1$ to $n$. If there are multiple answers then print any of them. -----Examples----- Input 5 6 Output Possible 2 5 3 2 5 1 3 4 4 1 5 4 Input 6 12 Output Impossible -----Note----- Here is the representation of the graph from the first example: [Image] Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0
{"tests": "{\"inputs\": [\"3 1\\n1 1\\n\", \"12 2\\n4 1\\n8 1\\n\", \"1 1\\n1 2\\n\", \"4 0\\n\", \"100 44\\n41 1\\n13 1\\n52 1\\n83 1\\n64 2\\n86 2\\n12 1\\n77 1\\n100 2\\n97 2\\n58 1\\n33 2\\n8 1\\n72 2\\n2 1\\n88 1\\n50 2\\n4 1\\n18 1\\n36 2\\n46 2\\n57 1\\n29 2\\n22 1\\n75 2\\n44 2\\n80 2\\n84 1\\n62 1\\n42 1\\n94 1\\n96 2\\n31 2\\n45 2\\n10 2\\n17 1\\n5 1\\n53 1\\n98 2\\n21 1\\n82 1\\n15 1\\n68 2\\n91 1\\n\", \"18 4\\n6 2\\n10 2\\n13 1\\n12 1\\n\", \"24 8\\n3 1\\n15 1\\n24 2\\n7 1\\n13 2\\n18 2\\n5 1\\n1 2\\n\", \"5 2\\n3 2\\n4 2\\n\", \"10 2\\n5 2\\n7 1\\n\", \"20 3\\n18 1\\n2 1\\n15 2\\n\", \"30 4\\n11 2\\n8 2\\n21 1\\n23 1\\n\", \"40 6\\n23 1\\n19 1\\n14 2\\n28 1\\n15 2\\n17 1\\n\", \"50 3\\n28 1\\n25 2\\n23 2\\n\", \"60 3\\n35 1\\n29 1\\n26 2\\n\", \"70 3\\n36 1\\n47 1\\n25 2\\n\", \"80 11\\n58 1\\n30 1\\n20 2\\n66 1\\n78 2\\n56 2\\n28 1\\n38 1\\n62 1\\n4 1\\n41 2\\n\", \"90 10\\n20 2\\n17 1\\n61 2\\n18 1\\n38 2\\n28 1\\n33 1\\n26 2\\n74 2\\n72 1\\n\", \"91 18\\n27 1\\n70 1\\n43 2\\n38 2\\n72 1\\n34 1\\n15 1\\n14 1\\n25 1\\n63 2\\n52 1\\n16 1\\n49 1\\n77 2\\n79 1\\n32 2\\n73 1\\n57 2\\n\", \"92 8\\n25 2\\n48 1\\n68 1\\n42 1\\n47 1\\n46 1\\n54 2\\n39 2\\n\", \"93 5\\n40 2\\n45 2\\n43 2\\n37 2\\n56 1\\n\", \"94 4\\n62 1\\n58 1\\n34 1\\n45 2\\n\", \"95 19\\n34 2\\n21 2\\n40 1\\n76 2\\n72 2\\n50 2\\n65 2\\n30 2\\n58 1\\n38 1\\n29 2\\n56 2\\n53 2\\n46 2\\n54 2\\n69 1\\n20 2\\n47 2\\n39 1\\n\", \"96 16\\n67 2\\n33 1\\n37 2\\n43 2\\n19 1\\n53 2\\n23 2\\n62 1\\n49 2\\n85 1\\n4 2\\n94 2\\n50 2\\n91 2\\n55 1\\n59 1\\n\", \"97 15\\n63 2\\n35 2\\n74 2\\n20 2\\n60 1\\n31 2\\n68 1\\n21 2\\n42 1\\n29 1\\n44 2\\n79 1\\n73 2\\n53 1\\n77 1\\n\", \"98 12\\n42 2\\n57 1\\n30 2\\n17 1\\n24 2\\n83 1\\n28 1\\n44 2\\n22 2\\n69 2\\n33 2\\n75 1\\n\", \"99 14\\n17 2\\n82 2\\n85 2\\n52 1\\n46 1\\n36 1\\n58 2\\n19 2\\n15 2\\n71 1\\n61 2\\n16 2\\n57 2\\n79 2\\n\", \"2 0\\n\", \"9 0\\n\", \"44 0\\n\", \"69 0\\n\", \"100 0\\n\", \"1 0\\n\", \"10 4\\n8 2\\n2 2\\n5 2\\n7 2\\n\", \"45 4\\n5 1\\n37 1\\n38 1\\n25 1\\n\", \"88 35\\n40 2\\n42 1\\n24 1\\n75 1\\n4 2\\n63 2\\n26 2\\n81 1\\n61 1\\n19 2\\n53 1\\n71 1\\n84 2\\n5 2\\n3 2\\n8 1\\n58 2\\n37 1\\n1 1\\n56 1\\n13 1\\n88 1\\n36 1\\n17 1\\n70 1\\n32 1\\n68 2\\n27 2\\n33 1\\n46 2\\n23 1\\n47 2\\n78 1\\n29 2\\n9 1\\n\", \"100 1\\n1 1\\n\", \"100 1\\n100 2\\n\", \"100 2\\n1 2\\n100 2\\n\", \"100 2\\n1 1\\n100 2\\n\"], \"outputs\": [\"WIN\\n\", \"WIN\\n\", \"LOSE\\n\", \"LOSE\\n\", \"WIN\\n\", \"WIN\\n\", \"LOSE\\n\", \"WIN\\n\", \"WIN\\n\", \"WIN\\n\", \"WIN\\n\", \"WIN\\n\", \"LOSE\\n\", \"LOSE\\n\", \"WIN\\n\", \"LOSE\\n\", \"WIN\\n\", \"WIN\\n\", \"WIN\\n\", \"WIN\\n\", \"LOSE\\n\", \"LOSE\\n\", \"LOSE\\n\", \"WIN\\n\", \"WIN\\n\", \"WIN\\n\", \"LOSE\\n\", \"WIN\\n\", \"LOSE\\n\", \"WIN\\n\", \"LOSE\\n\", \"WIN\\n\", \"WIN\\n\", \"WIN\\n\", \"WIN\\n\", \"WIN\\n\", \"WIN\\n\", \"LOSE\\n\", \"WIN\\n\"]}", "source": "primeintellect"}
In a far away land, there are two cities near a river. One day, the cities decide that they have too little space and would like to reclaim some of the river area into land. The river area can be represented by a grid with r rows and exactly two columns — each cell represents a rectangular area. The rows are numbered 1 through r from top to bottom, while the columns are numbered 1 and 2. Initially, all of the cells are occupied by the river. The plan is to turn some of those cells into land one by one, with the cities alternately choosing a cell to reclaim, and continuing until no more cells can be reclaimed. However, the river is also used as a major trade route. The cities need to make sure that ships will still be able to sail from one end of the river to the other. More formally, if a cell (r, c) has been reclaimed, it is not allowed to reclaim any of the cells (r - 1, 3 - c), (r, 3 - c), or (r + 1, 3 - c). The cities are not on friendly terms, and each city wants to be the last city to reclaim a cell (they don't care about how many cells they reclaim, just who reclaims a cell last). The cities have already reclaimed n cells. Your job is to determine which city will be the last to reclaim a cell, assuming both choose cells optimally from current moment. -----Input----- The first line consists of two integers r and n (1 ≤ r ≤ 100, 0 ≤ n ≤ r). Then n lines follow, describing the cells that were already reclaimed. Each line consists of two integers: r_{i} and c_{i} (1 ≤ r_{i} ≤ r, 1 ≤ c_{i} ≤ 2), which represent the cell located at row r_{i} and column c_{i}. All of the lines describing the cells will be distinct, and the reclaimed cells will not violate the constraints above. -----Output----- Output "WIN" if the city whose turn it is to choose a cell can guarantee that they will be the last to choose a cell. Otherwise print "LOSE". -----Examples----- Input 3 1 1 1 Output WIN Input 12 2 4 1 8 1 Output WIN Input 1 1 1 2 Output LOSE -----Note----- In the first example, there are 3 possible cells for the first city to reclaim: (2, 1), (3, 1), or (3, 2). The first two possibilities both lose, as they leave exactly one cell for the other city. [Image] However, reclaiming the cell at (3, 2) leaves no more cells that can be reclaimed, and therefore the first city wins. $\text{-}$ In the third example, there are no cells that can be reclaimed. Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
0