Dataset Viewer
messages
listlengths 1
1
| ground_truth
stringlengths 872
161M
| id
stringlengths 32
32
| dataset
stringclasses 1
value |
|---|---|---|---|
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAfter a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help.\n\nFormally the parking can be represented as a matrix 10^9 × 10^9. There is exactly one car in every cell of the matrix. All cars have their own machine numbers represented as a positive integer. Let's index the columns of the matrix by integers from 1 to 10^9 from left to right and the rows by integers from 1 to 10^9 from top to bottom. By coincidence it turned out, that for every cell (x, y) the number of the car, which stands in this cell, is equal to the minimum positive integer, which can't be found in the cells (i, y) and (x, j), 1 ≤ i < x, 1 ≤ j < y. $\\left. \\begin{array}{|l|l|l|l|l|} \\hline 1 & {2} & {3} & {4} & {5} \\\\ \\hline 2 & {1} & {4} & {3} & {6} \\\\ \\hline 3 & {4} & {1} & {2} & {7} \\\\ \\hline 4 & {3} & {2} & {1} & {8} \\\\ \\hline 5 & {6} & {7} & {8} & {1} \\\\ \\hline \\end{array} \\right.$ The upper left fragment 5 × 5 of the parking \n\nLeha wants to ask the watchman q requests, which can help him to find his car. Every request is represented as five integers x_1, y_1, x_2, y_2, k. The watchman have to consider all cells (x, y) of the matrix, such that x_1 ≤ x ≤ x_2 and y_1 ≤ y ≤ y_2, and if the number of the car in cell (x, y) does not exceed k, increase the answer to the request by the number of the car in cell (x, y). For each request Leha asks the watchman to tell him the resulting sum. Due to the fact that the sum can turn out to be quite large, hacker asks to calculate it modulo 10^9 + 7.\n\nHowever the requests seem to be impracticable for the watchman. Help the watchman to answer all Leha's requests.\n\n\n-----Input-----\n\nThe first line contains one integer q (1 ≤ q ≤ 10^4) — the number of Leha's requests.\n\nThe next q lines contain five integers x_1, y_1, x_2, y_2, k (1 ≤ x_1 ≤ x_2 ≤ 10^9, 1 ≤ y_1 ≤ y_2 ≤ 10^9, 1 ≤ k ≤ 2·10^9) — parameters of Leha's requests.\n\n\n-----Output-----\n\nPrint exactly q lines — in the first line print the answer to the first request, in the second — the answer to the second request and so on.\n\n\n-----Example-----\nInput\n4\n1 1 1 1 1\n3 2 5 4 5\n1 1 5 5 10000\n1 4 2 5 2\n\nOutput\n1\n13\n93\n0\n\n\n\n-----Note-----\n\nLet's analyze all the requests. In each case the requested submatrix is highlighted in blue.\n\nIn the first request (k = 1) Leha asks only about the upper left parking cell. In this cell the car's number is 1. Consequentally the answer is 1.\n\n$\\left. \\begin{array}{|l|l|l|l|l|} \\hline 1 & {2} & {3} & {4} & {5} \\\\ \\hline 2 & {1} & {4} & {3} & {6} \\\\ \\hline 3 & {4} & {1} & {2} & {7} \\\\ \\hline 4 & {3} & {2} & {1} & {8} \\\\ \\hline 5 & {6} & {7} & {8} & {1} \\\\ \\hline \\end{array} \\right.$\n\nIn the second request (k = 5) suitable numbers are 4, 1, 2, 3, 2, 1. Consequentally the answer is 4 + 1 + 2 + 3 + 2 + 1 = 13.\n\n$\\left. \\begin{array}{|l|l|l|l|l|} \\hline 1 & {2} & {3} & {4} & {5} \\\\ \\hline 2 & {1} & {4} & {3} & {6} \\\\ \\hline 3 & {4} & {1} & {2} & {7} \\\\ \\hline 4 & {3} & {2} & {1} & {8} \\\\ \\hline 5 & {6} & {7} & {8} & {1} \\\\ \\hline \\end{array} \\right.$\n\nIn the third request (k = 10000) Leha asks about the upper left frament 5 × 5 of the parking. Since k is big enough, the answer is equal to 93.\n\n$\\left. \\begin{array}{|l|l|l|l|l|} \\hline 1 & {2} & {3} & {4} & {5} \\\\ \\hline 2 & {1} & {4} & {3} & {6} \\\\ \\hline 3 & {4} & {1} & {2} & {7} \\\\ \\hline 4 & {3} & {2} & {1} & {8} \\\\ \\hline 5 & {6} & {7} & {8} & {1} \\\\ \\hline \\end{array} \\right.$\n\nIn the last request (k = 2) none of the cur's numbers are suitable, so the answer is 0.\n\n$\\left. \\begin{array}{|l|l|l|l|l|} \\hline 1 & {2} & {3} & {4} & {5} \\\\ \\hline 2 & {1} & {4} & {3} & {6} \\\\ \\hline 3 & {4} & {1} & {2} & {7} \\\\ \\hline 4 & {3} & {2} & {1} & {8} \\\\ \\hline 5 & {6} & {7} & {8} & {1} \\\\ \\hline \\end{array} \\right.$\n\nThe input will be stdin and you should print your solution to stdout\n\n\nNow solve the problem and return the code.",
"role": "user"
}
] |
[{"input": "4\n1 1 1 1 1\n3 2 5 4 5\n1 1 5 5 10000\n1 4 2 5 2\n", "output": "1\n13\n93\n0\n", "type": "code"}, {"input": "10\n3 7 4 10 7\n6 1 7 10 18\n9 6 10 8 3\n1 8 3 10 3\n10 4 10 5 19\n8 9 9 10 10\n10 1 10 5 4\n8 1 9 4 18\n6 3 9 5 1\n6 6 9 6 16\n", "output": "22\n130\n0\n0\n25\n3\n0\n68\n0\n22\n", "type": "code"}, {"input": "10\n1 1 2 2 8\n3 4 5 9 4\n2 10 5 10 6\n8 5 10 8 8\n1 2 8 2 20\n8 6 10 8 20\n6 7 6 7 9\n8 5 10 10 13\n1 8 10 9 13\n9 8 10 9 3\n", "output": "6\n13\n0\n10\n36\n95\n4\n42\n94\n3\n", "type": "code"}, {"input": "10\n4 4 9 8 14\n5 5 10 10 7\n1 1 10 5 14\n3 5 8 9 15\n3 2 8 7 17\n5 1 10 6 7\n6 6 10 10 1\n3 3 7 10 15\n6 6 10 10 17\n6 5 10 9 5\n", "output": "132\n46\n291\n157\n162\n92\n5\n244\n205\n33\n", "type": "code"}, {"input": "10\n6 2 10 9 7\n4 3 8 7 9\n2 1 7 9 5\n2 6 10 10 3\n1 4 7 8 18\n1 2 7 6 14\n2 6 6 10 14\n3 1 10 9 10\n4 6 10 10 14\n1 6 9 10 20\n", "output": "74\n106\n90\n24\n165\n155\n193\n257\n158\n356\n", "type": "code"}, {"input": "10\n35670 87689 78020 97199 170735\n49603 42971 77473 79458 124936\n94018 22571 99563 79717 79594\n65172 72864 69350 77801 174349\n45117 31256 60374 67497 156317\n36047 95407 60232 98208 139099\n32487 46904 57699 99668 80778\n21651 59154 75570 62785 115538\n29698 87365 74417 93703 117692\n14164 51564 33862 97087 68406\n", "output": "454444876\n271069018\n549471212\n320529941\n94517473\n311684494\n819172459\n675269446\n7036993\n762542106\n", "type": "code"}, {"input": "10\n51798 36533 70866 80025 119989\n28380 14954 62643 52624 29118\n54458 49611 75784 95421 49917\n69985 20586 84374 81162 14398\n65761 87545 72679 89308 70174\n22064 89628 77685 93857 38969\n75905 57174 86394 88214 107079\n48955 26587 98075 76935 72945\n69991 81288 96051 90174 75880\n66736 31080 84603 89293 196873\n", "output": "12182239\n653954597\n844386299\n206168423\n437228219\n154397952\n317840300\n905267860\n968243748\n750471863\n", "type": "code"}, {"input": "10\n45965 63556 68448 95894 98898\n50414 55822 93611 81912 81281\n51874 82624 99557 93570 17105\n83870 83481 98209 86976 37205\n34423 98865 81812 99559 52923\n59982 80565 63020 90493 156405\n73425 8598 94843 23120 95359\n75710 49176 96524 75354 10095\n11342 31715 50626 83343 14952\n50673 61478 61380 81973 35755\n", "output": "199194379\n133563355\n535853348\n105738618\n790969580\n176118196\n203632117\n366899916\n146517938\n749331834\n", "type": "code"}, {"input": "10\n39453 1588 68666 44518 80856\n65967 37333 79860 79474 185463\n72918 67988 88918 85752 178916\n4960 53963 30061 77750 101446\n68699 86791 98399 87875 166780\n42051 5526 86018 54457 56275\n35111 22360 46210 77033 154364\n79350 54886 79640 66722 206\n57162 67626 99566 96156 173141\n42028 40518 52695 94347 188413\n", "output": "974201015\n675658286\n140222566\n668884231\n613269116\n620825458\n239625852\n0\n193348271\n860068784\n", "type": "code"}, {"input": "10\n60149 83439 91672 93997 29005\n2170 81207 33662 85253 169296\n84242 35792 96226 46307 32764\n48745 41099 63904 50301 99488\n20797 58596 98423 69870 151507\n79648 84250 95429 93302 160725\n29270 74595 41752 87094 46279\n97721 20075 99994 24743 121486\n44598 9233 59399 56549 114860\n81435 24939 83492 87248 55048\n", "output": "922941587\n694484017\n0\n117048300\n483223856\n262420342\n0\n449352476\n757860438\n37418807\n", "type": "code"}, {"input": "10\n17273 60120 44211 66117 121362\n38045 49581 43392 60379 106182\n29993 28891 49459 68331 170383\n13745 94716 99131 96384 163728\n35994 29973 69541 91771 65364\n93514 84168 95810 91743 60595\n57881 7334 95096 48342 39876\n41495 70230 56091 84188 78893\n12540 23228 26212 81656 105752\n83061 65904 87563 68222 150811\n", "output": "908485580\n424476218\n6537747\n993909605\n825278510\n232753578\n980640613\n0\n732434354\n794713552\n", "type": "code"}, {"input": "10\n89912 38588 100000 61519 131263\n63723 14623 74226 61508 104495\n80783 19628 93957 60942 72631\n49607 2064 60475 32125 43001\n397 31798 60225 47064 161900\n87074 8737 99607 47892 162291\n10290 73252 84596 86607 106118\n38621 44306 76871 87471 44012\n26666 84711 53248 98378 27672\n22685 36055 57791 80992 140124\n", "output": "191639278\n266398397\n387687950\n268970017\n733430769\n239026110\n569640661\n502549869\n0\n901026605\n", "type": "code"}, {"input": "10\n25583 8810 71473 84303 56325\n52527 14549 67038 87309 41381\n85964 55620 99929 76963 34442\n28280 87558 56450 98865 107242\n61281 44852 99966 67445 108461\n58298 39201 70236 74834 62161\n54864 73811 68399 96057 132419\n11978 85542 35272 97885 1419\n89151 60500 99966 89149 185860\n48390 40961 87183 97309 35887\n", "output": "605688865\n873699306\n156635112\n698424830\n86490140\n906905842\n454122876\n0\n347292150\n987085065\n", "type": "code"}, {"input": "10\n1 1 100000 100000 124458\n1 1 100000 100000 89626\n1 1 100000 100000 42210\n1 1 100000 100000 65721\n1 1 100000 100000 148198\n1 1 100000 100000 122029\n1 1 100000 100000 50224\n1 1 100000 100000 16314\n1 1 100000 100000 158599\n1 1 100000 100000 142792\n", "output": "986777122\n640050028\n864029027\n339397763\n973589169\n723174232\n902088077\n287074869\n973589169\n973589169\n", "type": "code"}, {"input": "10\n1 1 100000 100000 73712\n1 1 100000 100000 193808\n1 1 100000 100000 69429\n1 1 100000 100000 162666\n1 1 100000 100000 94759\n1 1 100000 100000 21899\n1 1 100000 100000 76524\n1 1 100000 100000 182233\n1 1 100000 100000 125300\n1 1 100000 100000 71258\n", "output": "717056579\n973589169\n625066178\n973589169\n207662527\n561940319\n600480675\n973589169\n665222578\n844687430\n", "type": "code"}, {"input": "10\n63468235 40219768 326916221 835104676 1952530008\n297013188 212688608 432392437 887776079 1462376999\n153855395 41506149 261808021 778766232 291194343\n238640217 22153210 642972954 719331789 371665652\n528859722 494055455 831993741 924681396 251221747\n19429387 475067059 567446881 908192965 1886584907\n472431037 68414189 620339945 605371645 1906964799\n741781008 683180935 932571485 883233060 987079989\n557448838 174849798 875225676 549316493 360200169\n61358988 97847347 487462496 955727516 1024792731\n", "output": "383784865\n892686589\n440520525\n909297528\n857306896\n138121854\n327512104\n256512043\n89816936\n158271270\n", "type": "code"}, {"input": "10\n1 1 1000000000 1000000000 497721466\n1 1 1000000000 1000000000 1096400602\n1 1 1000000000 1000000000 1120358961\n1 1 1000000000 1000000000 232914786\n1 1 1000000000 1000000000 601018859\n1 1 1000000000 1000000000 310363393\n1 1 1000000000 1000000000 636663039\n1 1 1000000000 1000000000 1548359129\n1 1 1000000000 1000000000 1183677871\n1 1 1000000000 1000000000 792703683\n", "output": "11780124\n248752269\n248752269\n883198940\n218155629\n747605194\n352461300\n248752269\n248752269\n562283839\n", "type": "code"}, {"input": "10\n1 1 1000000000 1000000000 1477070720\n1 1 1000000000 1000000000 1378704784\n1 1 1000000000 1000000000 782520772\n1 1 1000000000 1000000000 1377211731\n1 1 1000000000 1000000000 623332716\n1 1 1000000000 1000000000 497630560\n1 1 1000000000 1000000000 47465148\n1 1 1000000000 1000000000 790892344\n1 1 1000000000 1000000000 1071836060\n1 1 1000000000 1000000000 1949232149\n", "output": "248752269\n248752269\n949069688\n248752269\n840885502\n42891263\n23378226\n985784682\n561979540\n248752269\n", "type": "code"}]
|
811b158b35eac12103a102b12f10da7c
|
code_stdio
|
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere is a beautiful garden of stones in Innopolis.\n\nIts most beautiful place is the $n$ piles with stones numbered from $1$ to $n$.\n\nEJOI participants have visited this place twice. \n\nWhen they first visited it, the number of stones in piles was $x_1, x_2, \\ldots, x_n$, correspondingly. One of the participants wrote down this sequence in a notebook. \n\nThey visited it again the following day, and the number of stones in piles was equal to $y_1, y_2, \\ldots, y_n$. One of the participants also wrote it down in a notebook.\n\nIt is well known that every member of the EJOI jury during the night either sits in the room $108$ or comes to the place with stones. Each jury member who comes there either takes one stone for himself or moves one stone from one pile to another. We can assume that there is an unlimited number of jury members. No one except the jury goes to the place with stones at night.\n\nParticipants want to know whether their notes can be correct or they are sure to have made a mistake.\n\n\n-----Input-----\n\nThe first line of the input file contains a single integer $n$, the number of piles with stones in the garden ($1 \\leq n \\leq 50$).\n\nThe second line contains $n$ integers separated by spaces $x_1, x_2, \\ldots, x_n$, the number of stones in piles recorded in the notebook when the participants came to the place with stones for the first time ($0 \\leq x_i \\leq 1000$).\n\nThe third line contains $n$ integers separated by spaces $y_1, y_2, \\ldots, y_n$, the number of stones in piles recorded in the notebook when the participants came to the place with stones for the second time ($0 \\leq y_i \\leq 1000$).\n\n\n-----Output-----\n\nIf the records can be consistent output \"Yes\", otherwise output \"No\" (quotes for clarity).\n\n\n-----Examples-----\nInput\n5\n1 2 3 4 5\n2 1 4 3 5\n\nOutput\nYes\n\nInput\n5\n1 1 1 1 1\n1 0 1 0 1\n\nOutput\nYes\n\nInput\n3\n2 3 9\n1 7 9\n\nOutput\nNo\n\n\n\n-----Note-----\n\nIn the first example, the following could have happened during the night: one of the jury members moved one stone from the second pile to the first pile, and the other jury member moved one stone from the fourth pile to the third pile.\n\nIn the second example, the jury took stones from the second and fourth piles.\n\nIt can be proved that it is impossible for the jury members to move and took stones to convert the first array into the second array.\n\nThe input will be stdin and you should print your solution to stdout\n\n\nNow solve the problem and return the code.",
"role": "user"
}
] |
[{"input": "5\n1 2 3 4 5\n2 1 4 3 5\n", "output": "Yes\n", "type": "code"}, {"input": "5\n1 1 1 1 1\n1 0 1 0 1\n", "output": "Yes\n", "type": "code"}, {"input": "3\n2 3 9\n1 7 9\n", "output": "No\n", "type": "code"}, {"input": "40\n361 372 139 808 561 460 421 961 727 719 130 235 320 470 432 759 317 886 624 666 917 133 736 710 462 424 541 118 228 216 612 339 800 557 291 128 801 9 0 318\n364 689 60 773 340 571 627 932 581 856 131 153 406 475 217 716 433 519 417 552 919 53 923 605 319 359 516 121 207 180 373 343 905 641 477 416 927 207 160 245\n", "output": "Yes\n", "type": "code"}, {"input": "45\n246 523 714 431 266 139 591 246 845 818 805 198 70 620 166 478 87 849 415 228 957 59 190 332 632 14 451 857 221 638 837 222 970 643 19 172 39 185 903 342 750 265 241 968 876\n460 389 541 164 324 52 246 107 826 864 693 132 10 697 429 434 99 950 164 85 972 157 327 337 592 241 350 962 130 673 967 373 657 923 456 347 394 76 743 407 724 117 268 741 918\n", "output": "Yes\n", "type": "code"}, {"input": "50\n620 222 703 953 303 333 371 125 554 88 60 189 873 644 817 100 760 64 887 605 611 845 762 916 21 26 254 553 602 66 796 531 329 888 274 584 215 135 69 403 680 734 440 406 53 958 135 230 918 206\n464 128 878 999 197 358 447 191 530 218 63 443 630 587 836 232 659 117 787 254 667 646 498 845 252 179 452 390 455 16 686 522 236 945 498 635 445 225 7 38 553 946 563 457 102 942 130 310 941 312\n", "output": "Yes\n", "type": "code"}, {"input": "40\n361 372 139 808 561 460 421 961 727 719 130 235 320 470 432 759 317 886 624 666 917 133 736 710 462 424 541 118 228 216 612 339 800 557 291 128 801 9 0 318\n29 469 909 315 333 412 777 490 492 431 908 412 187 829 453 595 896 817 755 914 34 890 583 691 544 969 733 132 802 170 67 68 370 146 856 184 275 785 928 798\n", "output": "No\n", "type": "code"}, {"input": "45\n246 523 714 431 266 139 591 246 845 818 805 198 70 620 166 478 87 849 415 228 957 59 190 332 632 14 451 857 221 638 837 222 970 643 19 172 39 185 903 342 750 265 241 968 876\n918 332 978 856 517 621 81 62 150 482 834 649 860 259 394 937 647 0 400 783 574 713 355 221 543 389 937 824 53 361 824 454 217 180 840 407 160 417 373 737 49 476 320 59 886\n", "output": "No\n", "type": "code"}, {"input": "50\n620 222 703 953 303 333 371 125 554 88 60 189 873 644 817 100 760 64 887 605 611 845 762 916 21 26 254 553 602 66 796 531 329 888 274 584 215 135 69 403 680 734 440 406 53 958 135 230 918 206\n494 447 642 337 839 128 971 105 915 739 803 8 848 253 554 186 338 656 238 106 89 13 622 777 663 669 360 451 461 639 403 255 570 648 996 618 55 409 733 230 533 226 774 559 161 184 933 308 554 161\n", "output": "No\n", "type": "code"}, {"input": "50\n1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000\n1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000\n", "output": "Yes\n", "type": "code"}, {"input": "1\n633\n609\n", "output": "Yes\n", "type": "code"}, {"input": "2\n353 313\n327 470\n", "output": "No\n", "type": "code"}, {"input": "3\n835 638 673\n624 232 266\n", "output": "Yes\n", "type": "code"}, {"input": "4\n936 342 19 398\n247 874 451 768\n", "output": "No\n", "type": "code"}, {"input": "5\n417 666 978 553 271\n488 431 625 503 978\n", "output": "No\n", "type": "code"}, {"input": "10\n436 442 197 740 550 361 317 473 843 982\n356 826 789 479 641 974 106 221 57 858\n", "output": "Yes\n", "type": "code"}, {"input": "15\n702 593 763 982 263 48 487 759 961 80 642 169 778 621 764\n932 885 184 230 411 644 296 351 112 940 73 707 296 472 86\n", "output": "Yes\n", "type": "code"}, {"input": "20\n82 292 379 893 300 854 895 638 58 971 278 168 580 272 653 315 176 773 709 789\n298 710 311 695 328 459 510 994 472 515 634 568 368 913 182 223 361 132 92 620\n", "output": "Yes\n", "type": "code"}, {"input": "25\n349 443 953 126 394 160 63 924 795 450 572 513 338 33 768 34 955 737 874 731 329 16 377 318 125\n56 39 740 846 938 851 459 538 617 664 268 981 315 2 23 76 974 417 786 816 207 227 870 385 958\n", "output": "No\n", "type": "code"}, {"input": "30\n722 523 950 656 431 347 463 795 893 348 208 893 140 65 419 36 627 333 972 346 230 422 337 893 896 442 835 56 846 986\n429 148 890 854 546 680 776 265 551 465 387 823 996 845 374 867 411 742 447 267 711 989 501 694 456 451 192 529 215 709\n", "output": "No\n", "type": "code"}, {"input": "35\n607 674 142 278 135 34 13 80 629 448 875 856 518 446 161 376 406 288 764 289 643 347 164 515 73 39 126 413 848 788 653 651 67 320 655\n717 5 441 833 869 107 620 329 877 536 753 593 610 811 360 42 46 996 635 96 301 565 190 99 570 168 528 355 830 392 356 106 211 405 607\n", "output": "No\n", "type": "code"}, {"input": "1\n633\n633\n", "output": "Yes\n", "type": "code"}, {"input": "2\n353 313\n344 322\n", "output": "Yes\n", "type": "code"}, {"input": "3\n835 638 673\n516 880 750\n", "output": "Yes\n", "type": "code"}, {"input": "4\n936 342 19 398\n807 250 199 439\n", "output": "Yes\n", "type": "code"}, {"input": "5\n417 666 978 553 271\n72 946 832 454 581\n", "output": "Yes\n", "type": "code"}, {"input": "10\n436 442 197 740 550 361 317 473 843 982\n788 683 32 402 305 396 823 206 739 967\n", "output": "Yes\n", "type": "code"}, {"input": "15\n702 593 763 982 263 48 487 759 961 80 642 169 778 621 764\n346 342 969 741 762 123 89 823 955 599 575 312 547 784 645\n", "output": "Yes\n", "type": "code"}, {"input": "20\n82 292 379 893 300 854 895 638 58 971 278 168 580 272 653 315 176 773 709 789\n370 433 505 670 178 892 948 864 252 906 45 275 891 185 432 12 43 270 951 953\n", "output": "Yes\n", "type": "code"}, {"input": "25\n349 443 953 126 394 160 63 924 795 450 572 513 338 33 768 34 955 737 874 731 329 16 377 318 125\n75 296 997 211 919 7 357 928 891 829 119 509 184 29 769 262 973 936 100 588 115 536 398 163 186\n", "output": "Yes\n", "type": "code"}, {"input": "30\n722 523 950 656 431 347 463 795 893 348 208 893 140 65 419 36 627 333 972 346 230 422 337 893 896 442 835 56 846 986\n914 569 671 995 728 188 135 588 943 433 368 615 218 38 810 484 468 128 785 149 398 587 174 881 875 477 737 181 752 821\n", "output": "Yes\n", "type": "code"}, {"input": "35\n607 674 142 278 135 34 13 80 629 448 875 856 518 446 161 376 406 288 764 289 643 347 164 515 73 39 126 413 848 788 653 651 67 320 655\n452 596 228 56 48 35 155 250 793 729 630 495 803 209 156 423 427 270 925 479 635 639 50 489 27 198 324 241 564 898 178 713 131 337 738\n", "output": "Yes\n", "type": "code"}, {"input": "1\n1000\n1000\n", "output": "Yes\n", "type": "code"}, {"input": "2\n1000 1000\n1000 1000\n", "output": "Yes\n", "type": "code"}, {"input": "3\n1000 1000 1000\n1000 1000 1000\n", "output": "Yes\n", "type": "code"}, {"input": "4\n1000 1000 1000 1000\n1000 1000 1000 1000\n", "output": "Yes\n", "type": "code"}, {"input": "5\n1000 1000 1000 1000 1000\n1000 1000 1000 1000 1000\n", "output": "Yes\n", "type": "code"}, {"input": "10\n1000 1000 1000 1000 1000 1000 1000 1000 1000 1000\n1000 1000 1000 1000 1000 1000 1000 1000 1000 1000\n", "output": "Yes\n", "type": "code"}, {"input": "15\n1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000\n1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000\n", "output": "Yes\n", "type": "code"}, {"input": "20\n1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000\n1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000\n", "output": "Yes\n", "type": "code"}, {"input": "25\n1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000\n1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000\n", "output": "Yes\n", "type": "code"}, {"input": "30\n1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000\n1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000\n", "output": "Yes\n", "type": "code"}, {"input": "35\n1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000\n1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000\n", "output": "Yes\n", "type": "code"}, {"input": "40\n1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000\n1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000\n", "output": "Yes\n", "type": "code"}, {"input": "45\n1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000\n1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000\n", "output": "Yes\n", "type": "code"}, {"input": "8\n5 5 0 0 0 0 0 0\n1 0 0 0 0 0 0 0\n", "output": "Yes\n", "type": "code"}, {"input": "1\n50\n1\n", "output": "Yes\n", "type": "code"}, {"input": "5\n9 9 9 9 9\n10 9 9 9 1\n", "output": "Yes\n", "type": "code"}, {"input": "6\n3 4 2 5 6 3\n2 3 2 5 6 3\n", "output": "Yes\n", "type": "code"}, {"input": "4\n1 1 1 1\n0 0 0 0\n", "output": "Yes\n", "type": "code"}, {"input": "3\n3 3 3\n1 0 0\n", "output": "Yes\n", "type": "code"}, {"input": "3\n2 1 5\n1 2 4\n", "output": "Yes\n", "type": "code"}, {"input": "3\n2 4 5\n1 2 3\n", "output": "Yes\n", "type": "code"}, {"input": "3\n3 4 5\n1 1 1\n", "output": "Yes\n", "type": "code"}, {"input": "2\n5 3\n2 4\n", "output": "Yes\n", "type": "code"}, {"input": "3\n5 5 5\n1 1 1\n", "output": "Yes\n", "type": "code"}, {"input": "1\n11\n9\n", "output": "Yes\n", "type": "code"}, {"input": "5\n1 2 3 4 6\n1 2 3 4 5\n", "output": "Yes\n", "type": "code"}, {"input": "50\n1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000\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\n", "output": "Yes\n", "type": "code"}, {"input": "3\n3 4 4\n3 5 4\n", "output": "No\n", "type": "code"}, {"input": "1\n100\n1\n", "output": "Yes\n", "type": "code"}, {"input": "1\n300\n1\n", "output": "Yes\n", "type": "code"}, {"input": "5\n5 5 5 5 5\n1 1 1 1 1\n", "output": "Yes\n", "type": "code"}, {"input": "3\n1000 1000 1000\n0 0 0\n", "output": "Yes\n", "type": "code"}, {"input": "1\n3\n2\n", "output": "Yes\n", "type": "code"}, {"input": "2\n5 5\n1 1\n", "output": "Yes\n", "type": "code"}, {"input": "2\n10 1\n1 9\n", "output": "Yes\n", "type": "code"}, {"input": "5\n3 3 3 3 3\n2 2 2 2 2\n", "output": "Yes\n", "type": "code"}, {"input": "1\n10\n5\n", "output": "Yes\n", "type": "code"}, {"input": "5\n2 3 4 5 6\n0 0 0 0 4\n", "output": "Yes\n", "type": "code"}, {"input": "2\n3 3\n2 2\n", "output": "Yes\n", "type": "code"}, {"input": "1\n100\n0\n", "output": "Yes\n", "type": "code"}, {"input": "5\n2 3 4 5 1\n1 1 3 4 5\n", "output": "Yes\n", "type": "code"}, {"input": "3\n10 10 1\n0 0 2\n", "output": "Yes\n", "type": "code"}, {"input": "5\n2 3 4 5 6\n0 0 0 0 19\n", "output": "Yes\n", "type": "code"}, {"input": "1\n1000\n0\n", "output": "Yes\n", "type": "code"}, {"input": "1\n1\n5\n", "output": "No\n", "type": "code"}, {"input": "4\n1 1 1 1\n0 0 0 3\n", "output": "Yes\n", "type": "code"}, {"input": "5\n2 3 4 5 1\n1 1 1 1 1\n", "output": "Yes\n", "type": "code"}, {"input": "1\n6\n1\n", "output": "Yes\n", "type": "code"}, {"input": "5\n4 5 3 6 7\n1 1 4 4 5\n", "output": "Yes\n", "type": "code"}, {"input": "2\n500 500\n1 1\n", "output": "Yes\n", "type": "code"}, {"input": "1\n10\n1\n", "output": "Yes\n", "type": "code"}, {"input": "1\n1\n1\n", "output": "Yes\n", "type": "code"}, {"input": "3\n2 4 2\n4 3 0\n", "output": "Yes\n", "type": "code"}, {"input": "1\n0\n0\n", "output": "Yes\n", "type": "code"}, {"input": "1\n7\n3\n", "output": "Yes\n", "type": "code"}, {"input": "3\n4 5 6\n3 2 1\n", "output": "Yes\n", "type": "code"}, {"input": "5\n1 2 3 4 5\n0 0 0 0 0\n", "output": "Yes\n", "type": "code"}, {"input": "1\n2\n1\n", "output": "Yes\n", "type": "code"}, {"input": "3\n3 3 3\n1 1 1\n", "output": "Yes\n", "type": "code"}]
|
934bd3611c16f47df53dbfa21be2637c
|
code_stdio
|
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAndrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudocode of the algorithm is as follows:\n\nBinarySearch(a, x)\n left = 0\n right = a.size()\n while left < right\n middle = (left + right) / 2\n if a[middle] <= x then\n left = middle + 1\n else\n right = middle\n \n if left > 0 and a[left - 1] == x then\n return true\n else\n return false\n\nNote that the elements of the array are indexed from zero, and the division is done in integers (rounding down).\n\nAndrey read that the algorithm only works if the array is sorted. However, he found this statement untrue, because there certainly exist unsorted arrays for which the algorithm find $x$!\n\nAndrey wants to write a letter to the book authors, but before doing that he must consider the permutations of size $n$ such that the algorithm finds $x$ in them. A permutation of size $n$ is an array consisting of $n$ distinct integers between $1$ and $n$ in arbitrary order.\n\nHelp Andrey and find the number of permutations of size $n$ which contain $x$ at position $pos$ and for which the given implementation of the binary search algorithm finds $x$ (returns true). As the result may be extremely large, print the remainder of its division by $10^9+7$.\n\n\n-----Input-----\n\nThe only line of input contains integers $n$, $x$ and $pos$ ($1 \\le x \\le n \\le 1000$, $0 \\le pos \\le n - 1$) — the required length of the permutation, the number to search, and the required position of that number, respectively.\n\n\n-----Output-----\n\nPrint a single number — the remainder of the division of the number of valid permutations by $10^9+7$.\n\n\n-----Examples-----\nInput\n4 1 2\n\nOutput\n6\n\nInput\n123 42 24\n\nOutput\n824071958\n\n\n\n-----Note-----\n\nAll possible permutations in the first test case: $(2, 3, 1, 4)$, $(2, 4, 1, 3)$, $(3, 2, 1, 4)$, $(3, 4, 1, 2)$, $(4, 2, 1, 3)$, $(4, 3, 1, 2)$.\n\nThe input will be stdin and you should print your solution to stdout\n\n\nNow solve the problem and return the code.",
"role": "user"
}
] |
[{"input": "4 1 2\n", "output": "6\n", "type": "code"}, {"input": "123 42 24\n", "output": "824071958\n", "type": "code"}, {"input": "1 1 0\n", "output": "1\n", "type": "code"}, {"input": "1000 501 501\n", "output": "646597996\n", "type": "code"}, {"input": "1000 999 799\n", "output": "0\n", "type": "code"}, {"input": "2 1 1\n", "output": "1\n", "type": "code"}, {"input": "2 2 0\n", "output": "0\n", "type": "code"}, {"input": "3 1 2\n", "output": "0\n", "type": "code"}, {"input": "3 2 2\n", "output": "1\n", "type": "code"}, {"input": "3 3 1\n", "output": "0\n", "type": "code"}, {"input": "4 2 0\n", "output": "2\n", "type": "code"}, {"input": "4 3 2\n", "output": "2\n", "type": "code"}, {"input": "4 4 3\n", "output": "6\n", "type": "code"}, {"input": "7 1 1\n", "output": "720\n", "type": "code"}, {"input": "7 7 6\n", "output": "720\n", "type": "code"}, {"input": "7 2 4\n", "output": "120\n", "type": "code"}, {"input": "7 4 4\n", "output": "216\n", "type": "code"}, {"input": "8 4 1\n", "output": "1440\n", "type": "code"}, {"input": "8 1 5\n", "output": "0\n", "type": "code"}, {"input": "8 8 7\n", "output": "5040\n", "type": "code"}, {"input": "8 7 6\n", "output": "720\n", "type": "code"}, {"input": "8 3 0\n", "output": "1440\n", "type": "code"}, {"input": "9 1 7\n", "output": "0\n", "type": "code"}, {"input": "9 9 5\n", "output": "0\n", "type": "code"}, {"input": "9 5 5\n", "output": "5760\n", "type": "code"}, {"input": "9 4 4\n", "output": "7200\n", "type": "code"}, {"input": "9 3 3\n", "output": "8640\n", "type": "code"}, {"input": "10 1 1\n", "output": "362880\n", "type": "code"}, {"input": "10 10 9\n", "output": "362880\n", "type": "code"}, {"input": "10 5 5\n", "output": "43200\n", "type": "code"}, {"input": "10 3 7\n", "output": "70560\n", "type": "code"}, {"input": "10 4 4\n", "output": "90720\n", "type": "code"}, {"input": "10 6 6\n", "output": "43200\n", "type": "code"}, {"input": "10 7 7\n", "output": "90720\n", "type": "code"}, {"input": "10 9 5\n", "output": "0\n", "type": "code"}, {"input": "74 16 54\n", "output": "625981152\n", "type": "code"}, {"input": "63 15 45\n", "output": "581829795\n", "type": "code"}, {"input": "54 4 47\n", "output": "911648281\n", "type": "code"}, {"input": "92 22 62\n", "output": "628152721\n", "type": "code"}, {"input": "82 15 14\n", "output": "187724629\n", "type": "code"}, {"input": "91 60 48\n", "output": "233776714\n", "type": "code"}, {"input": "91 51 5\n", "output": "660447677\n", "type": "code"}, {"input": "70 45 16\n", "output": "578976138\n", "type": "code"}, {"input": "61 21 16\n", "output": "516359078\n", "type": "code"}, {"input": "61 29 15\n", "output": "252758304\n", "type": "code"}, {"input": "69 67 68\n", "output": "736622722\n", "type": "code"}, {"input": "59 40 1\n", "output": "384105577\n", "type": "code"}, {"input": "98 86 39\n", "output": "132656801\n", "type": "code"}, {"input": "97 89 29\n", "output": "673334741\n", "type": "code"}, {"input": "78 66 16\n", "output": "703501645\n", "type": "code"}, {"input": "777 254 720\n", "output": "57449468\n", "type": "code"}, {"input": "908 216 521\n", "output": "601940707\n", "type": "code"}, {"input": "749 158 165\n", "output": "849211382\n", "type": "code"}, {"input": "535 101 250\n", "output": "111877808\n", "type": "code"}, {"input": "665 5 305\n", "output": "400272219\n", "type": "code"}, {"input": "856 406 675\n", "output": "663368144\n", "type": "code"}, {"input": "697 390 118\n", "output": "844062514\n", "type": "code"}, {"input": "539 246 0\n", "output": "410139856\n", "type": "code"}, {"input": "669 380 461\n", "output": "921432102\n", "type": "code"}, {"input": "954 325 163\n", "output": "917113541\n", "type": "code"}, {"input": "646 467 58\n", "output": "214437899\n", "type": "code"}, {"input": "542 427 258\n", "output": "830066531\n", "type": "code"}, {"input": "562 388 191\n", "output": "935998075\n", "type": "code"}, {"input": "958 817 269\n", "output": "513948977\n", "type": "code"}, {"input": "1000 888 888\n", "output": "644649893\n", "type": "code"}, {"input": "1000 2 2\n", "output": "22779421\n", "type": "code"}, {"input": "534 376 180\n", "output": "984450056\n", "type": "code"}, {"input": "1000 1 1\n", "output": "756641425\n", "type": "code"}, {"input": "1000 3 3\n", "output": "606772288\n", "type": "code"}, {"input": "1000 500 500\n", "output": "646597996\n", "type": "code"}, {"input": "1000 1000 999\n", "output": "756641425\n", "type": "code"}, {"input": "1000 501 50\n", "output": "636821580\n", "type": "code"}, {"input": "6 4 3\n", "output": "12\n", "type": "code"}, {"input": "3 2 1\n", "output": "1\n", "type": "code"}, {"input": "100 5 50\n", "output": "469732450\n", "type": "code"}, {"input": "999 490 499\n", "output": "998308393\n", "type": "code"}, {"input": "7 3 3\n", "output": "288\n", "type": "code"}, {"input": "10 7 5\n", "output": "4320\n", "type": "code"}, {"input": "123 1 24\n", "output": "0\n", "type": "code"}, {"input": "5 5 2\n", "output": "0\n", "type": "code"}]
|
d7a794d4b0390b4696e11f43bdc610eb
|
code_stdio
|
[
{
"content": "Solve the following coding problem using the programming language python:\n\nBajtek, known for his unusual gifts, recently got an integer array $x_0, x_1, \\ldots, x_{k-1}$.\n\nUnfortunately, after a huge array-party with his extraordinary friends, he realized that he'd lost it. After hours spent on searching for a new toy, Bajtek found on the arrays producer's website another array $a$ of length $n + 1$. As a formal description of $a$ says, $a_0 = 0$ and for all other $i$ ($1 \\le i \\le n$) $a_i = x_{(i-1)\\bmod k} + a_{i-1}$, where $p \\bmod q$ denotes the remainder of division $p$ by $q$.\n\nFor example, if the $x = [1, 2, 3]$ and $n = 5$, then: $a_0 = 0$, $a_1 = x_{0\\bmod 3}+a_0=x_0+0=1$, $a_2 = x_{1\\bmod 3}+a_1=x_1+1=3$, $a_3 = x_{2\\bmod 3}+a_2=x_2+3=6$, $a_4 = x_{3\\bmod 3}+a_3=x_0+6=7$, $a_5 = x_{4\\bmod 3}+a_4=x_1+7=9$. \n\nSo, if the $x = [1, 2, 3]$ and $n = 5$, then $a = [0, 1, 3, 6, 7, 9]$.\n\nNow the boy hopes that he will be able to restore $x$ from $a$! Knowing that $1 \\le k \\le n$, help him and find all possible values of $k$ — possible lengths of the lost array.\n\n\n-----Input-----\n\nThe first line contains exactly one integer $n$ ($1 \\le n \\le 1000$) — the length of the array $a$, excluding the element $a_0$.\n\nThe second line contains $n$ integers $a_1, a_2, \\ldots, a_n$ ($1 \\le a_i \\le 10^6$).\n\nNote that $a_0$ is always $0$ and is not given in the input.\n\n\n-----Output-----\n\nThe first line of the output should contain one integer $l$ denoting the number of correct lengths of the lost array.\n\nThe second line of the output should contain $l$ integers — possible lengths of the lost array in increasing order.\n\n\n-----Examples-----\nInput\n5\n1 2 3 4 5\n\nOutput\n5\n1 2 3 4 5 \nInput\n5\n1 3 5 6 8\n\nOutput\n2\n3 5 \nInput\n3\n1 5 3\n\nOutput\n1\n3 \n\n\n-----Note-----\n\nIn the first example, any $k$ is suitable, since $a$ is an arithmetic progression.\n\nPossible arrays $x$: $[1]$ $[1, 1]$ $[1, 1, 1]$ $[1, 1, 1, 1]$ $[1, 1, 1, 1, 1]$\n\nIn the second example, Bajtek's array can have three or five elements.\n\nPossible arrays $x$: $[1, 2, 2]$ $[1, 2, 2, 1, 2]$\n\nFor example, $k = 4$ is bad, since it leads to $6 + x_0 = 8$ and $0 + x_0 = 1$, which is an obvious contradiction.\n\nIn the third example, only $k = n$ is good.\n\nArray $[1, 4, -2]$ satisfies the requirements.\n\nNote that $x_i$ may be negative.\n\nThe input will be stdin and you should print your solution to stdout\n\n\nNow solve the problem and return the code.",
"role": "user"
}
] |
[{"input": "5\n1 2 3 4 5\n", "output": "5\n1 2 3 4 5 ", "type": "code"}, {"input": "5\n1 3 5 6 8\n", "output": "2\n3 5 ", "type": "code"}, {"input": "3\n1 5 3\n", "output": "1\n3 ", "type": "code"}, {"input": "1\n5\n", "output": "1\n1 ", "type": "code"}, {"input": "10\n500000 500000 500000 500000 500000 500000 500000 1000000 1000000 1000000\n", "output": "2\n7 10 ", "type": "code"}, {"input": "50\n12 52 88 116 124 127 150 180 208 235 268 298 332 367 391 439 464 482 502 515 535 540 563 564 577 621 638 657 691 725 766 778 818 854 882 890 893 916 946 974 1001 1034 1064 1098 1133 1157 1205 1230 1248 1268\n", "output": "2\n31 50 ", "type": "code"}, {"input": "2\n500000 1000000\n", "output": "2\n1 2 ", "type": "code"}, {"input": "2\n2 3\n", "output": "1\n2 ", "type": "code"}, {"input": "5\n1 1 1 2 2\n", "output": "2\n3 5 ", "type": "code"}, {"input": "10\n1 2 2 2 2 2 1 2 2 1\n", "output": "1\n10 ", "type": "code"}, {"input": "10\n2 2 4 4 3 1 1 2 3 2\n", "output": "1\n10 ", "type": "code"}, {"input": "5\n5 7 12 14 19\n", "output": "3\n2 4 5 ", "type": "code"}, {"input": "6\n5 9 11 16 20 22\n", "output": "2\n3 6 ", "type": "code"}, {"input": "9\n5 6 14 19 20 28 33 34 42\n", "output": "3\n3 6 9 ", "type": "code"}, {"input": "13\n11 21 24 30 41 51 54 60 71 81 84 90 101\n", "output": "4\n4 8 12 13 ", "type": "code"}, {"input": "25\n19 36 61 67 71 90 107 132 138 142 161 178 203 209 213 232 249 274 280 284 303 320 345 351 355\n", "output": "5\n5 10 15 20 25 ", "type": "code"}, {"input": "31\n31 61 91 122 152 182 213 243 273 304 334 364 395 425 455 486 516 546 577 607 637 668 698 728 759 789 819 850 880 910 941\n", "output": "11\n3 6 9 12 15 18 21 24 27 30 31 ", "type": "code"}, {"input": "31\n26 46 63 73 75 94 101 103 119 121 140 158 161 164 171 197 217 234 244 246 265 272 274 290 292 311 329 332 335 342 368\n", "output": "3\n15 30 31 ", "type": "code"}, {"input": "50\n20 40 60 80 100 120 140 160 180 200 220 240 260 280 300 320 340 360 380 400 420 440 460 480 500 520 540 560 580 600 620 640 660 680 700 720 740 760 780 800 820 840 860 880 900 920 940 960 980 1000\n", "output": "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 50 ", "type": "code"}, {"input": "50\n26 35 84 121 132 161 187 213 222 271 308 319 348 374 400 409 458 495 506 535 561 587 596 645 682 693 722 748 774 783 832 869 880 909 935 961 970 1019 1056 1067 1096 1122 1148 1157 1206 1243 1254 1283 1309 1335\n", "output": "8\n7 14 21 28 35 42 49 50 ", "type": "code"}, {"input": "100\n57 81 176 211 251 311 346 404 469 506 563 587 682 717 757 817 852 910 975 1012 1069 1093 1188 1223 1263 1323 1358 1416 1481 1518 1575 1599 1694 1729 1769 1829 1864 1922 1987 2024 2081 2105 2200 2235 2275 2335 2370 2428 2493 2530 2587 2611 2706 2741 2781 2841 2876 2934 2999 3036 3093 3117 3212 3247 3287 3347 3382 3440 3505 3542 3599 3623 3718 3753 3793 3853 3888 3946 4011 4048 4105 4129 4224 4259 4299 4359 4394 4452 4517 4554 4611 4635 4730 4765 4805 4865 4900 4958 5023 5060\n", "output": "10\n10 20 30 40 50 60 70 80 90 100 ", "type": "code"}, {"input": "100\n48 55 64 122 179 274 347 446 536 600 676 764 797 888 940 1004 1033 1080 1092 1146 1166 1222 1307 1393 1424 1437 1509 1541 1570 1641 1672 1739 1778 1802 1838 1866 1945 2006 2007 2040 2064 2132 2166 2172 2272 2370 2392 2411 2501 2523 2600 2648 2655 2664 2722 2779 2874 2947 3046 3136 3200 3276 3364 3397 3488 3540 3604 3633 3680 3692 3746 3766 3822 3907 3993 4024 4037 4109 4141 4170 4241 4272 4339 4378 4402 4438 4466 4545 4606 4607 4640 4664 4732 4766 4772 4872 4970 4992 5011 5101\n", "output": "2\n51 100 ", "type": "code"}, {"input": "5\n1 2 5 6 7\n", "output": "3\n3 4 5 ", "type": "code"}, {"input": "5\n1 2 4 5 6\n", "output": "3\n3 4 5 ", "type": "code"}, {"input": "4\n2 1 3 3\n", "output": "1\n4 ", "type": "code"}, {"input": "6\n1 3 4 5 7 8\n", "output": "3\n3 5 6 ", "type": "code"}, {"input": "6\n1 1 2 2 3 4\n", "output": "2\n5 6 ", "type": "code"}, {"input": "8\n1 3 6 10 11 13 16 17\n", "output": "2\n7 8 ", "type": "code"}, {"input": "10\n1 2 3 4 5 6 7 8 9 20\n", "output": "1\n10 ", "type": "code"}, {"input": "4\n3 2 5 7\n", "output": "1\n4 ", "type": "code"}, {"input": "4\n1 2 3 5\n", "output": "1\n4 ", "type": "code"}, {"input": "6\n4 3 7 6 10 10\n", "output": "1\n6 ", "type": "code"}, {"input": "6\n2 1 3 2 4 100\n", "output": "1\n6 ", "type": "code"}, {"input": "12\n1 3 5 6 8 10 11 13 15 16 18 21\n", "output": "1\n12 ", "type": "code"}, {"input": "10\n1 2 3 4 5 10 11 12 13 14\n", "output": "5\n6 7 8 9 10 ", "type": "code"}, {"input": "7\n1 3 4 7 8 10 11\n", "output": "3\n4 6 7 ", "type": "code"}, {"input": "4\n2 2 4 5\n", "output": "1\n4 ", "type": "code"}, {"input": "9\n1 2 3 4 5 6 7 9 10\n", "output": "2\n8 9 ", "type": "code"}, {"input": "4\n2 2 4 6\n", "output": "2\n3 4 ", "type": "code"}, {"input": "4\n2 1 3 5\n", "output": "2\n3 4 ", "type": "code"}, {"input": "4\n1 1 2 3\n", "output": "2\n3 4 ", "type": "code"}, {"input": "4\n3 1 4 1\n", "output": "1\n4 ", "type": "code"}, {"input": "6\n3 2 1 4 5 6\n", "output": "1\n6 ", "type": "code"}, {"input": "21\n1 3 4 5 7 8 10 11 12 14 15 16 18 19 21 22 23 25 26 28 29\n", "output": "4\n13 18 20 21 ", "type": "code"}, {"input": "4\n5 4 9 11\n", "output": "1\n4 ", "type": "code"}, {"input": "7\n1 2 3 4 5 6 9\n", "output": "1\n7 ", "type": "code"}, {"input": "4\n10 9 19 20\n", "output": "1\n4 ", "type": "code"}, {"input": "6\n10 9 8 18 19 20\n", "output": "1\n6 ", "type": "code"}, {"input": "4\n2 1 3 1\n", "output": "1\n4 ", "type": "code"}, {"input": "8\n1 2 3 4 5 6 7 9\n", "output": "1\n8 ", "type": "code"}, {"input": "10\n1 3 6 6 11 12 14 17 18 22\n", "output": "1\n10 ", "type": "code"}, {"input": "6\n5 4 3 2 7 8\n", "output": "1\n6 ", "type": "code"}, {"input": "4\n2 1 3 6\n", "output": "1\n4 ", "type": "code"}]
|
c0907e1ac4d1f713f34e41ce4190b14a
|
code_stdio
|
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere are $n$ slimes in a row. Each slime has an integer value (possibly negative or zero) associated with it.\n\nAny slime can eat its adjacent slime (the closest slime to its left or to its right, assuming that this slime exists). \n\nWhen a slime with a value $x$ eats a slime with a value $y$, the eaten slime disappears, and the value of the remaining slime changes to $x - y$.\n\nThe slimes will eat each other until there is only one slime left. \n\nFind the maximum possible value of the last slime.\n\n\n-----Input-----\n\nThe first line of the input contains an integer $n$ ($1 \\le n \\le 500\\,000$) denoting the number of slimes.\n\nThe next line contains $n$ integers $a_i$ ($-10^9 \\le a_i \\le 10^9$), where $a_i$ is the value of $i$-th slime.\n\n\n-----Output-----\n\nPrint an only integer — the maximum possible value of the last slime.\n\n\n-----Examples-----\nInput\n4\n2 1 2 1\n\nOutput\n4\nInput\n5\n0 -1 -1 -1 -1\n\nOutput\n4\n\n\n-----Note-----\n\nIn the first example, a possible way of getting the last slime with value $4$ is:\n\n Second slime eats the third slime, the row now contains slimes $2, -1, 1$\n\n Second slime eats the third slime, the row now contains slimes $2, -2$\n\n First slime eats the second slime, the row now contains $4$ \n\nIn the second example, the first slime can keep eating slimes to its right to end up with a value of $4$.\n\nThe input will be stdin and you should print your solution to stdout\n\n\nNow solve the problem and return the code.",
"role": "user"
}
] |
[{"input": "4\n2 1 2 1\n", "output": "4", "type": "code"}, {"input": "5\n0 -1 -1 -1 -1\n", "output": "4", "type": "code"}, {"input": "2\n10 8\n", "output": "2", "type": "code"}, {"input": "5\n-14 -2 0 -19 -12\n", "output": "47", "type": "code"}, {"input": "6\n-15 2 -19 20 0 9\n", "output": "65", "type": "code"}, {"input": "3\n17 4 -1\n", "output": "22", "type": "code"}, {"input": "4\n20 3 -15 7\n", "output": "45", "type": "code"}, {"input": "1\n11\n", "output": "11", "type": "code"}, {"input": "1\n-10\n", "output": "-10", "type": "code"}, {"input": "7\n-8 9 0 -10 -20 -8 3\n", "output": "58", "type": "code"}, {"input": "9\n2 4 -4 15 1 11 15 -7 -20\n", "output": "79", "type": "code"}, {"input": "10\n-20 0 3 -5 -18 15 -3 -9 -7 9\n", "output": "89", "type": "code"}, {"input": "8\n-1 5 -19 4 -12 20 1 -12\n", "output": "74", "type": "code"}, {"input": "1\n-1000000000\n", "output": "-1000000000", "type": "code"}, {"input": "3\n-1 -2 -3\n", "output": "4", "type": "code"}, {"input": "3\n-1 -1 -1\n", "output": "1", "type": "code"}, {"input": "2\n-9 -3\n", "output": "6", "type": "code"}, {"input": "5\n-1 -1 -1 -1 -1\n", "output": "3", "type": "code"}, {"input": "2\n-1 -1\n", "output": "0", "type": "code"}, {"input": "5\n-7 -1 -1 -1 -1\n", "output": "9", "type": "code"}, {"input": "2\n-5 -5\n", "output": "0", "type": "code"}, {"input": "2\n-1 -2\n", "output": "1", "type": "code"}, {"input": "4\n-1 -1 -1 -1\n", "output": "2", "type": "code"}, {"input": "2\n-2 -2\n", "output": "0", "type": "code"}, {"input": "4\n-1 -2 -3 -4\n", "output": "8", "type": "code"}, {"input": "3\n-2 -4 -6\n", "output": "8", "type": "code"}, {"input": "2\n-10 -5\n", "output": "5", "type": "code"}, {"input": "2\n-2 -1\n", "output": "1", "type": "code"}, {"input": "2\n-2 -4\n", "output": "2", "type": "code"}, {"input": "2\n1 2\n", "output": "1", "type": "code"}, {"input": "2\n-4 -5\n", "output": "1", "type": "code"}, {"input": "2\n-2 -3\n", "output": "1", "type": "code"}, {"input": "2\n-1 -5\n", "output": "4", "type": "code"}, {"input": "5\n-1 -2 -3 -2 -1\n", "output": "7", "type": "code"}]
|
2b7bc0ce0fd388c83595c160e5300d93
|
code_stdio
|
[
{
"content": "Solve the following coding problem using the programming language python:\n\nSome natural number was written on the board. Its sum of digits was not less than k. But you were distracted a bit, and someone changed this number to n, replacing some digits with others. It's known that the length of the number didn't change.\n\nYou have to find the minimum number of digits in which these two numbers can differ.\n\n\n-----Input-----\n\nThe first line contains integer k (1 ≤ k ≤ 10^9).\n\nThe second line contains integer n (1 ≤ n < 10^100000).\n\nThere are no leading zeros in n. It's guaranteed that this situation is possible.\n\n\n-----Output-----\n\nPrint the minimum number of digits in which the initial number and n can differ.\n\n\n-----Examples-----\nInput\n3\n11\n\nOutput\n1\n\nInput\n3\n99\n\nOutput\n0\n\n\n\n-----Note-----\n\nIn the first example, the initial number could be 12.\n\nIn the second example the sum of the digits of n is not less than k. The initial number could be equal to n.\n\nThe input will be stdin and you should print your solution to stdout\n\n\nNow solve the problem and return the code.",
"role": "user"
}
] |
[{"input": "3\n11\n", "output": "1\n", "type": "code"}, {"input": "3\n99\n", "output": "0\n", "type": "code"}, {"input": "10\n5205602270\n", "output": "0\n", "type": "code"}, {"input": "70\n3326631213\n", "output": "6\n", "type": "code"}, {"input": "200\n1000000010000000000000000000010000000000000001000001000000000000000000000000000000000000000000000000\n", "output": "22\n", "type": "code"}, {"input": "500\n1899337170458531693764539600958943248270674811247191310452938511077656066239840703432499357537079035\n", "output": "6\n", "type": "code"}, {"input": "700\n9307216756404590162143344901558545760612901767837570518638460182990196397856220673189163417019781185\n", "output": "32\n", "type": "code"}, {"input": "900\n7570423817272967027553082464863962024635217372307919506594193055572300657732661146354209508997483330\n", "output": "91\n", "type": "code"}, {"input": "18\n900\n", "output": "1\n", "type": "code"}, {"input": "23\n12138\n", "output": "1\n", "type": "code"}, {"input": "16\n333\n", "output": "2\n", "type": "code"}, {"input": "3\n12\n", "output": "0\n", "type": "code"}, {"input": "3\n111\n", "output": "0\n", "type": "code"}, {"input": "1\n100\n", "output": "0\n", "type": "code"}, {"input": "17\n89\n", "output": "0\n", "type": "code"}, {"input": "18\n99\n", "output": "0\n", "type": "code"}, {"input": "42\n97779\n", "output": "2\n", "type": "code"}, {"input": "2\n11\n", "output": "0\n", "type": "code"}, {"input": "6\n33\n", "output": "0\n", "type": "code"}, {"input": "45\n23456\n", "output": "5\n", "type": "code"}, {"input": "3\n21\n", "output": "0\n", "type": "code"}, {"input": "2\n2\n", "output": "0\n", "type": "code"}, {"input": "108\n199999899899\n", "output": "3\n", "type": "code"}, {"input": "6\n222\n", "output": "0\n", "type": "code"}, {"input": "1\n1\n", "output": "0\n", "type": "code"}, {"input": "9\n9\n", "output": "0\n", "type": "code"}, {"input": "5\n5\n", "output": "0\n", "type": "code"}, {"input": "27\n888\n", "output": "3\n", "type": "code"}]
|
2e4043fa95fcbed5bdc168967f8f9628
|
code_stdio
|
[
{
"content": "Solve the following coding problem using the programming language python:\n\nXenia the beginner mathematician is a third year student at elementary school. She is now learning the addition operation.\n\nThe teacher has written down the sum of multiple numbers. Pupils should calculate the sum. To make the calculation easier, the sum only contains numbers 1, 2 and 3. Still, that isn't enough for Xenia. She is only beginning to count, so she can calculate a sum only if the summands follow in non-decreasing order. For example, she can't calculate sum 1+3+2+1 but she can calculate sums 1+1+2 and 3+3.\n\nYou've got the sum that was written on the board. Rearrange the summans and print the sum in such a way that Xenia can calculate the sum.\n\n\n-----Input-----\n\nThe first line contains a non-empty string s — the sum Xenia needs to count. String s contains no spaces. It only contains digits and characters \"+\". Besides, string s is a correct sum of numbers 1, 2 and 3. String s is at most 100 characters long.\n\n\n-----Output-----\n\nPrint the new sum that Xenia can count.\n\n\n-----Examples-----\nInput\n3+2+1\n\nOutput\n1+2+3\n\nInput\n1+1+3+1+3\n\nOutput\n1+1+1+3+3\n\nInput\n2\n\nOutput\n2\n\nThe input will be stdin and you should print your solution to stdout\n\n\nNow solve the problem and return the code.",
"role": "user"
}
] |
[{"input": "3+2+1\n", "output": "1+2+3\n", "type": "code"}, {"input": "1+1+3+1+3\n", "output": "1+1+1+3+3\n", "type": "code"}, {"input": "2\n", "output": "2\n", "type": "code"}, {"input": "2+2+1+1+3\n", "output": "1+1+2+2+3\n", "type": "code"}, {"input": "2+1+2+2+2+3+1+3+1+2\n", "output": "1+1+1+2+2+2+2+2+3+3\n", "type": "code"}, {"input": "1+2+1+2+2+2+2+1+3+3\n", "output": "1+1+1+2+2+2+2+2+3+3\n", "type": "code"}, {"input": "2+3+3+1+2+2+2+1+1+2+1+3+2+2+3+3+2+2+3+3+3+1+1+1+3+3+3+2+1+3+2+3+2+1+1+3+3+3+1+2+2+1+2+2+1+2+1+3+1+1\n", "output": "1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "1\n", "output": "1\n", "type": "code"}, {"input": "2+1+2+2+1+3+2+3+1+1+2+1+2+2+3+1+1+3+3+3+2+2+3+2+2+2+1+2+1+2+3+2+2+2+1+3+1+3+3+3+1+2+1+2+2+2+2+3+1+1\n", "output": "1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "2+2+1+1+1+3+1+1+3+3+2+3+1+3+1+1+3+1+1+2+2+2+2+1+2+1+2+1+1+1+3+1+3+2+3+2+3+3+1+1+1+2+3+2+1+3+1+3+2+2\n", "output": "1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "3+2+3+3+2+2+1+2+1+2+3+1+2+3+2+3+2+1+2+2+1+1+2+2+3+2+1+3+1+1+3+2+2+2+2+3+3+2+2+3+3+1+1+2+3+3+2+3+3+3\n", "output": "1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "3\n", "output": "3\n", "type": "code"}, {"input": "1+1\n", "output": "1+1\n", "type": "code"}, {"input": "1+2\n", "output": "1+2\n", "type": "code"}, {"input": "1+3\n", "output": "1+3\n", "type": "code"}, {"input": "2+1\n", "output": "1+2\n", "type": "code"}, {"input": "2+2\n", "output": "2+2\n", "type": "code"}, {"input": "2+3\n", "output": "2+3\n", "type": "code"}, {"input": "3+1\n", "output": "1+3\n", "type": "code"}, {"input": "3+2\n", "output": "2+3\n", "type": "code"}, {"input": "3+3\n", "output": "3+3\n", "type": "code"}]
|
2b127a6c62af05e03e48ac4e7112c6ce
|
code_stdio
|
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere are $n$ students and $m$ clubs in a college. The clubs are numbered from $1$ to $m$. Each student has a potential $p_i$ and is a member of the club with index $c_i$. Initially, each student is a member of exactly one club. A technical fest starts in the college, and it will run for the next $d$ days. There is a coding competition every day in the technical fest. \n\nEvery day, in the morning, exactly one student of the college leaves their club. Once a student leaves their club, they will never join any club again. Every day, in the afternoon, the director of the college will select one student from each club (in case some club has no members, nobody is selected from that club) to form a team for this day's coding competition. The strength of a team is the mex of potentials of the students in the team. The director wants to know the maximum possible strength of the team for each of the coming $d$ days. Thus, every day the director chooses such team, that the team strength is maximized.\n\nThe mex of the multiset $S$ is the smallest non-negative integer that is not present in $S$. For example, the mex of the $\\{0, 1, 1, 2, 4, 5, 9\\}$ is $3$, the mex of $\\{1, 2, 3\\}$ is $0$ and the mex of $\\varnothing$ (empty set) is $0$.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $m$ ($1 \\leq m \\leq n \\leq 5000$), the number of students and the number of clubs in college.\n\nThe second line contains $n$ integers $p_1, p_2, \\ldots, p_n$ ($0 \\leq p_i < 5000$), where $p_i$ is the potential of the $i$-th student.\n\nThe third line contains $n$ integers $c_1, c_2, \\ldots, c_n$ ($1 \\leq c_i \\leq m$), which means that $i$-th student is initially a member of the club with index $c_i$.\n\nThe fourth line contains an integer $d$ ($1 \\leq d \\leq n$), number of days for which the director wants to know the maximum possible strength of the team. \n\nEach of the next $d$ lines contains an integer $k_i$ ($1 \\leq k_i \\leq n$), which means that $k_i$-th student lefts their club on the $i$-th day. It is guaranteed, that the $k_i$-th student has not left their club earlier.\n\n\n-----Output-----\n\nFor each of the $d$ days, print the maximum possible strength of the team on that day.\n\n\n-----Examples-----\nInput\n5 3\n0 1 2 2 0\n1 2 2 3 2\n5\n3\n2\n4\n5\n1\n\nOutput\n3\n1\n1\n1\n0\n\nInput\n5 3\n0 1 2 2 1\n1 3 2 3 2\n5\n4\n2\n3\n5\n1\n\nOutput\n3\n2\n2\n1\n0\n\nInput\n5 5\n0 1 2 4 5\n1 2 3 4 5\n4\n2\n3\n5\n4\n\nOutput\n1\n1\n1\n1\n\n\n\n-----Note-----\n\nConsider the first example:\n\nOn the first day, student $3$ leaves their club. Now, the remaining students are $1$, $2$, $4$ and $5$. We can select students $1$, $2$ and $4$ to get maximum possible strength, which is $3$. Note, that we can't select students $1$, $2$ and $5$, as students $2$ and $5$ belong to the same club. Also, we can't select students $1$, $3$ and $4$, since student $3$ has left their club.\n\nOn the second day, student $2$ leaves their club. Now, the remaining students are $1$, $4$ and $5$. We can select students $1$, $4$ and $5$ to get maximum possible strength, which is $1$.\n\nOn the third day, the remaining students are $1$ and $5$. We can select students $1$ and $5$ to get maximum possible strength, which is $1$.\n\nOn the fourth day, the remaining student is $1$. We can select student $1$ to get maximum possible strength, which is $1$. \n\nOn the fifth day, no club has students and so the maximum possible strength is $0$.\n\nThe input will be stdin and you should print your solution to stdout\n\n\nNow solve the problem and return the code.",
"role": "user"
}
] |
[{"input": "5 3\n0 1 2 2 0\n1 2 2 3 2\n5\n3\n2\n4\n5\n1\n", "output": "3\n1\n1\n1\n0\n", "type": "code"}, {"input": "5 3\n0 1 2 2 1\n1 3 2 3 2\n5\n4\n2\n3\n5\n1\n", "output": "3\n2\n2\n1\n0\n", "type": "code"}, {"input": "5 5\n0 1 2 4 5\n1 2 3 4 5\n4\n2\n3\n5\n4\n", "output": "1\n1\n1\n1\n", "type": "code"}, {"input": "10 10\n8 5 1 3 9 2 7 0 6 4\n6 4 8 2 7 9 5 1 10 3\n10\n9\n2\n1\n7\n5\n6\n8\n3\n10\n4\n", "output": "6\n5\n5\n5\n5\n2\n0\n0\n0\n0\n", "type": "code"}, {"input": "10 10\n2 0 3 5 6 1 9 4 7 8\n9 2 5 7 1 6 4 10 8 3\n5\n9\n5\n4\n10\n7\n", "output": "7\n6\n5\n5\n5\n", "type": "code"}, {"input": "10 5\n5 1 9 7 3 2 8 0 6 4\n1 1 1 5 4 3 2 5 2 4\n10\n9\n3\n5\n7\n10\n6\n1\n4\n2\n8\n", "output": "4\n4\n3\n3\n3\n2\n2\n2\n1\n0\n", "type": "code"}, {"input": "10 5\n9 7 8 0 1 4 5 2 6 3\n5 5 4 4 2 2 1 3 4 5\n5\n9\n6\n10\n5\n1\n", "output": "4\n4\n3\n1\n1\n", "type": "code"}, {"input": "20 8\n1 17 10 12 13 7 14 9 16 15 6 3 11 18 19 8 4 2 0 5\n8 6 3 4 4 8 5 8 3 7 4 2 4 5 7 1 4 6 4 1\n8\n13\n17\n20\n11\n3\n16\n2\n4\n", "output": "4\n4\n4\n4\n4\n4\n4\n4\n", "type": "code"}, {"input": "20 20\n10 13 3 14 17 19 0 7 16 5 9 8 12 2 18 6 11 4 15 1\n20 8 17 11 2 10 12 4 19 7 6 3 1 18 16 5 14 13 9 15\n15\n9\n15\n6\n5\n13\n2\n19\n4\n11\n17\n12\n1\n10\n18\n16\n", "output": "16\n16\n16\n16\n12\n12\n12\n12\n9\n9\n8\n8\n5\n4\n4\n", "type": "code"}, {"input": "10 5\n0 1 1 0 3 1 3 0 2 0\n5 4 3 4 3 4 1 2 3 3\n10\n1\n2\n8\n7\n3\n9\n6\n5\n10\n4\n", "output": "4\n4\n2\n2\n2\n2\n1\n1\n1\n0\n", "type": "code"}, {"input": "20 5\n0 1 418 1718 2027 0 1 2 2 1 433 227 0 1 0 2 0 114 1 1329\n4 5 4 2 4 1 3 1 2 4 5 1 5 2 3 5 3 2 3 4\n10\n20\n12\n11\n18\n5\n3\n4\n9\n16\n8\n", "output": "3\n3\n3\n3\n3\n3\n3\n3\n3\n2\n", "type": "code"}, {"input": "20 20\n0 0 3 2 1 2 2 3 2 2 1 1 0 3 0 0 1 1 1 3\n15 1 20 13 6 12 16 8 3 14 10 5 18 17 4 9 2 11 7 19\n20\n2\n10\n7\n4\n6\n5\n14\n8\n9\n18\n13\n11\n19\n1\n16\n20\n17\n12\n15\n3\n", "output": "4\n4\n4\n4\n4\n4\n4\n4\n2\n2\n2\n2\n2\n2\n2\n2\n2\n1\n0\n0\n", "type": "code"}, {"input": "1 1\n0\n1\n1\n1\n", "output": "0\n", "type": "code"}, {"input": "5 5\n0 0 1 1 2\n1 2 2 3 2\n2\n2\n3\n", "output": "3\n3\n", "type": "code"}, {"input": "5 3\n0 0 1 1 2\n1 2 2 3 2\n2\n2\n3\n", "output": "3\n3\n", "type": "code"}, {"input": "10 5\n1 2 0 4 2 4 1 3 4 4\n2 4 4 3 5 1 1 4 4 2\n10\n1\n8\n2\n9\n10\n3\n5\n4\n6\n7\n", "output": "3\n3\n3\n3\n3\n0\n0\n0\n0\n0\n", "type": "code"}, {"input": "10 5\n3 1 4 3 4 2 3 1 0 1\n2 5 3 5 2 5 4 4 1 4\n5\n4\n2\n10\n7\n1\n", "output": "5\n5\n5\n5\n3\n", "type": "code"}, {"input": "10 5\n1 0 1 4 2 4 4 0 1 1\n4 4 4 5 2 1 4 2 3 5\n5\n1\n6\n3\n2\n7\n", "output": "3\n3\n3\n2\n2\n", "type": "code"}, {"input": "20 5\n6 3 8 0 0 2 7 5 7 1059 9 4 9 3457 1 3 8 988 6 8\n1 4 2 3 2 2 4 1 1 5 1 5 1 3 1 5 2 5 3 4\n10\n3\n11\n12\n19\n18\n10\n17\n13\n8\n14\n", "output": "5\n5\n4\n4\n4\n4\n4\n4\n4\n4\n", "type": "code"}]
|
f72f6c50394787652ffbb964db61256a
|
code_stdio
|
[
{
"content": "Solve the following coding problem using the programming language python:\n\nOstap already settled down in Rio de Janiero suburb and started to grow a tree in his garden. Recall that a tree is a connected undirected acyclic graph. \n\nOstap's tree now has n vertices. He wants to paint some vertices of the tree black such that from any vertex u there is at least one black vertex v at distance no more than k. Distance between two vertices of the tree is the minimum possible number of edges of the path between them.\n\nAs this number of ways to paint the tree can be large, Ostap wants you to compute it modulo 10^9 + 7. Two ways to paint the tree are considered different if there exists a vertex that is painted black in one way and is not painted in the other one.\n\n\n-----Input-----\n\nThe first line of the input contains two integers n and k (1 ≤ n ≤ 100, 0 ≤ k ≤ min(20, n - 1)) — the number of vertices in Ostap's tree and the maximum allowed distance to the nearest black vertex. Don't miss the unusual constraint for k.\n\nEach of the next n - 1 lines contain two integers u_{i} and v_{i} (1 ≤ u_{i}, v_{i} ≤ n) — indices of vertices, connected by the i-th edge. It's guaranteed that given graph is a tree.\n\n\n-----Output-----\n\nPrint one integer — the remainder of division of the number of ways to paint the tree by 1 000 000 007 (10^9 + 7).\n\n\n-----Examples-----\nInput\n2 0\n1 2\n\nOutput\n1\n\nInput\n2 1\n1 2\n\nOutput\n3\n\nInput\n4 1\n1 2\n2 3\n3 4\n\nOutput\n9\n\nInput\n7 2\n1 2\n2 3\n1 4\n4 5\n1 6\n6 7\n\nOutput\n91\n\n\n\n-----Note-----\n\nIn the first sample, Ostap has to paint both vertices black.\n\nIn the second sample, it is enough to paint only one of two vertices, thus the answer is 3: Ostap can paint only vertex 1, only vertex 2, vertices 1 and 2 both.\n\nIn the third sample, the valid ways to paint vertices are: {1, 3}, {1, 4}, {2, 3}, {2, 4}, {1, 2, 3}, {1, 2, 4}, {1, 3, 4}, {2, 3, 4}, {1, 2, 3, 4}.\n\nThe input will be stdin and you should print your solution to stdout\n\n\nNow solve the problem and return the code.",
"role": "user"
}
] |
[{"input": "2 0\n1 2\n", "output": "1\n", "type": "code"}, {"input": "2 1\n1 2\n", "output": "3\n", "type": "code"}, {"input": "4 1\n1 2\n2 3\n3 4\n", "output": "9\n", "type": "code"}, {"input": "7 2\n1 2\n2 3\n1 4\n4 5\n1 6\n6 7\n", "output": "91\n", "type": "code"}, {"input": "1 0\n", "output": "1\n", "type": "code"}, {"input": "10 0\n5 6\n4 3\n8 5\n3 7\n10 4\n1 2\n2 8\n10 1\n7 9\n", "output": "1\n", "type": "code"}, {"input": "10 1\n6 8\n1 9\n1 5\n6 10\n3 9\n9 4\n10 9\n2 4\n7 4\n", "output": "255\n", "type": "code"}, {"input": "10 2\n7 10\n2 1\n6 5\n10 6\n3 1\n10 4\n3 4\n9 3\n8 4\n", "output": "705\n", "type": "code"}, {"input": "10 4\n4 6\n3 5\n7 3\n4 9\n10 2\n1 9\n4 8\n10 3\n8 7\n", "output": "993\n", "type": "code"}, {"input": "10 3\n2 5\n4 8\n4 5\n6 8\n4 1\n5 10\n7 9\n4 7\n3 9\n", "output": "945\n", "type": "code"}, {"input": "10 4\n9 6\n10 8\n9 2\n7 10\n3 7\n7 9\n10 4\n1 7\n9 5\n", "output": "1023\n", "type": "code"}, {"input": "10 5\n6 4\n4 1\n7 5\n8 7\n2 6\n3 6\n8 6\n10 3\n4 9\n", "output": "1023\n", "type": "code"}, {"input": "10 0\n9 10\n5 1\n10 5\n8 6\n8 2\n7 8\n8 1\n8 3\n4 3\n", "output": "1\n", "type": "code"}, {"input": "10 1\n6 3\n1 5\n10 7\n4 10\n2 4\n5 9\n8 1\n1 3\n7 3\n", "output": "279\n", "type": "code"}, {"input": "10 2\n1 4\n10 9\n1 5\n3 10\n2 10\n5 8\n6 1\n2 7\n6 10\n", "output": "743\n", "type": "code"}, {"input": "10 9\n1 2\n3 1\n6 10\n6 1\n10 9\n4 5\n7 1\n5 6\n8 5\n", "output": "1023\n", "type": "code"}, {"input": "5 1\n1 2\n4 3\n5 3\n2 3\n", "output": "15\n", "type": "code"}, {"input": "63 5\n2 31\n5 41\n15 20\n38 12\n54 7\n31 54\n24 47\n13 19\n54 39\n57 50\n25 18\n59 11\n47 30\n60 49\n13 24\n7 11\n16 4\n28 59\n43 36\n3 33\n10 32\n40 48\n63 35\n49 56\n29 20\n44 18\n7 24\n49 18\n36 11\n9 13\n58 23\n34 47\n3 51\n5 61\n1 16\n26 6\n37 57\n26 8\n48 52\n25 43\n26 28\n22 39\n14 31\n44 21\n5 17\n33 23\n48 41\n42 44\n12 51\n59 50\n12 62\n25 41\n53 23\n16 28\n51 32\n63 27\n55 57\n33 20\n45 39\n32 46\n50 63\n3 43\n", "output": "560665636\n", "type": "code"}, {"input": "64 3\n13 10\n60 54\n23 35\n4 41\n59 18\n41 36\n48 13\n64 8\n30 19\n53 3\n34 11\n24 27\n21 25\n5 55\n51 11\n3 45\n24 57\n47 38\n55 26\n8 20\n29 42\n44 3\n7 15\n9 1\n17 4\n41 9\n15 29\n60 13\n31 36\n53 52\n59 14\n12 52\n24 31\n47 28\n29 23\n2 49\n30 44\n28 31\n25 22\n9 58\n64 11\n45 35\n59 44\n62 8\n49 53\n32 48\n36 45\n4 56\n25 42\n42 33\n23 10\n48 39\n37 28\n10 64\n6 7\n30 63\n33 50\n40 7\n33 16\n49 46\n60 61\n52 43\n15 55\n", "output": "257869945\n", "type": "code"}]
|
b8217840dea518ac49b3940ac9183ac5
|
code_stdio
|
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThe first algorithm for detecting a face on the image working in realtime was developed by Paul Viola and Michael Jones in 2001. A part of the algorithm is a procedure that computes Haar features. As part of this task, we consider a simplified model of this concept.\n\nLet's consider a rectangular image that is represented with a table of size n × m. The table elements are integers that specify the brightness of each pixel in the image.\n\nA feature also is a rectangular table of size n × m. Each cell of a feature is painted black or white.\n\nTo calculate the value of the given feature at the given image, you must perform the following steps. First the table of the feature is put over the table of the image (without rotations or reflections), thus each pixel is entirely covered with either black or white cell. The value of a feature in the image is the value of W - B, where W is the total brightness of the pixels in the image, covered with white feature cells, and B is the total brightness of the pixels covered with black feature cells.\n\nSome examples of the most popular Haar features are given below. [Image] \n\nYour task is to determine the number of operations that are required to calculate the feature by using the so-called prefix rectangles.\n\nA prefix rectangle is any rectangle on the image, the upper left corner of which coincides with the upper left corner of the image.\n\nYou have a variable value, whose value is initially zero. In one operation you can count the sum of pixel values at any prefix rectangle, multiply it by any integer and add to variable value.\n\nYou are given a feature. It is necessary to calculate the minimum number of operations required to calculate the values of this attribute at an arbitrary image. For a better understanding of the statement, read the explanation of the first sample.\n\n\n-----Input-----\n\nThe first line contains two space-separated integers n and m (1 ≤ n, m ≤ 100) — the number of rows and columns in the feature.\n\nNext n lines contain the description of the feature. Each line consists of m characters, the j-th character of the i-th line equals to \"W\", if this element of the feature is white and \"B\" if it is black.\n\n\n-----Output-----\n\nPrint a single number — the minimum number of operations that you need to make to calculate the value of the feature.\n\n\n-----Examples-----\nInput\n6 8\nBBBBBBBB\nBBBBBBBB\nBBBBBBBB\nWWWWWWWW\nWWWWWWWW\nWWWWWWWW\n\nOutput\n2\n\nInput\n3 3\nWBW\nBWW\nWWW\n\nOutput\n4\n\nInput\n3 6\nWWBBWW\nWWBBWW\nWWBBWW\n\nOutput\n3\n\nInput\n4 4\nBBBB\nBBBB\nBBBB\nBBBW\n\nOutput\n4\n\n\n\n-----Note-----\n\nThe first sample corresponds to feature B, the one shown in the picture. The value of this feature in an image of size 6 × 8 equals to the difference of the total brightness of the pixels in the lower and upper half of the image. To calculate its value, perform the following two operations:\n\n add the sum of pixels in the prefix rectangle with the lower right corner in the 6-th row and 8-th column with coefficient 1 to the variable value (the rectangle is indicated by a red frame); $\\left. \\begin{array}{|r|r|r|r|r|r|r|r|} \\hline 1 & {1} & {1} & {1} & {1} & {1} & {1} & {1} \\\\ \\hline 1 & {1} & {1} & {1} & {1} & {1} & {1} & {1} \\\\ \\hline 1 & {1} & {1} & {1} & {1} & {1} & {1} & {1} \\\\ \\hline 1 & {1} & {1} & {1} & {1} & {1} & {1} & {1} \\\\ \\hline 1 & {1} & {1} & {1} & {1} & {1} & {1} & {1} \\\\ \\hline 1 & {1} & {1} & {1} & {1} & {1} & {1} & {1} \\\\ \\hline \\end{array} \\right.$\n\n add the number of pixels in the prefix rectangle with the lower right corner in the 3-rd row and 8-th column with coefficient - 2 and variable value. [Image] \n\nThus, all the pixels in the lower three rows of the image will be included with factor 1, and all pixels in the upper three rows of the image will be included with factor 1 - 2 = - 1, as required.\n\nThe input will be stdin and you should print your solution to stdout\n\n\nNow solve the problem and return the code.",
"role": "user"
}
] |
[{"input": "6 8\nBBBBBBBB\nBBBBBBBB\nBBBBBBBB\nWWWWWWWW\nWWWWWWWW\nWWWWWWWW\n", "output": "2\n", "type": "code"}, {"input": "3 3\nWBW\nBWW\nWWW\n", "output": "4\n", "type": "code"}, {"input": "3 6\nWWBBWW\nWWBBWW\nWWBBWW\n", "output": "3\n", "type": "code"}, {"input": "4 4\nBBBB\nBBBB\nBBBB\nBBBW\n", "output": "4\n", "type": "code"}, {"input": "10 9\nBWWWBWWBB\nBBWWBWBBW\nBBWBWBWBB\nBWBWBBBBB\nBBWBWBWBW\nBWWBWWBBW\nWBWWWBWWW\nWBBWBWBWW\nBBWWBWWBB\nBBWWBWWBW\n", "output": "61\n", "type": "code"}, {"input": "4 1\nW\nW\nB\nB\n", "output": "2\n", "type": "code"}, {"input": "2 10\nBBWBWWBWBB\nBBBBBBBBBW\n", "output": "10\n", "type": "code"}, {"input": "100 1\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\nB\n", "output": "2\n", "type": "code"}, {"input": "1 100\nWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\n", "output": "2\n", "type": "code"}, {"input": "4 5\nBWWBB\nBWBBW\nWBWWW\nWBWWB\n", "output": "13\n", "type": "code"}, {"input": "2 9\nWBBBWBBBW\nBWWBBBBBB\n", "output": "9\n", "type": "code"}, {"input": "6 6\nBBWWWB\nWBBBWB\nBBBBBW\nWWWWWW\nBBBBBW\nBWWBBB\n", "output": "16\n", "type": "code"}, {"input": "1 1\nW\n", "output": "1\n", "type": "code"}, {"input": "1 1\nB\n", "output": "1\n", "type": "code"}, {"input": "1 8\nWWBWWWWW\n", "output": "3\n", "type": "code"}, {"input": "2 8\nBBBBBBBB\nBBBBBBBB\n", "output": "1\n", "type": "code"}, {"input": "1 52\nBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\n", "output": "1\n", "type": "code"}, {"input": "11 8\nWWWWWWWW\nWWWWWWWW\nWWWWWWWW\nWWWWWWWW\nWWWWWWWW\nWWWBWWWW\nWWWWWWWW\nWBWWWWWW\nWWWWWWWW\nWWWWWWWW\nWWWWWWWW\n", "output": "9\n", "type": "code"}]
|
f547e94d09cd6987ab96a77e995cd3d6
|
code_stdio
|
[
{
"content": "Solve the following coding problem using the programming language python:\n\nIn this problem, a $n \\times m$ rectangular matrix $a$ is called increasing if, for each row of $i$, when go from left to right, the values strictly increase (that is, $a_{i,1}<a_{i,2}<\\dots<a_{i,m}$) and for each column $j$, when go from top to bottom, the values strictly increase (that is, $a_{1,j}<a_{2,j}<\\dots<a_{n,j}$).\n\nIn a given matrix of non-negative integers, it is necessary to replace each value of $0$ with some positive integer so that the resulting matrix is increasing and the sum of its elements is maximum, or find that it is impossible.\n\nIt is guaranteed that in a given value matrix all values of $0$ are contained only in internal cells (that is, not in the first or last row and not in the first or last column).\n\n\n-----Input-----\n\nThe first line contains integers $n$ and $m$ ($3 \\le n, m \\le 500$) — the number of rows and columns in the given matrix $a$.\n\nThe following lines contain $m$ each of non-negative integers — the values in the corresponding row of the given matrix: $a_{i,1}, a_{i,2}, \\dots, a_{i,m}$ ($0 \\le a_{i,j} \\le 8000$).\n\nIt is guaranteed that for all $a_{i,j}=0$, $1 < i < n$ and $1 < j < m$ are true.\n\n\n-----Output-----\n\nIf it is possible to replace all zeros with positive numbers so that the matrix is increasing, print the maximum possible sum of matrix elements. Otherwise, print -1.\n\n\n-----Examples-----\nInput\n4 5\n1 3 5 6 7\n3 0 7 0 9\n5 0 0 0 10\n8 9 10 11 12\n\nOutput\n144\n\nInput\n3 3\n1 2 3\n2 0 4\n4 5 6\n\nOutput\n30\n\nInput\n3 3\n1 2 3\n3 0 4\n4 5 6\n\nOutput\n-1\n\nInput\n3 3\n1 2 3\n2 3 4\n3 4 2\n\nOutput\n-1\n\n\n\n-----Note-----\n\nIn the first example, the resulting matrix is as follows: \n\n1 3 5 6 7\n\n3 6 7 8 9\n\n5 7 8 9 10\n\n8 9 10 11 12\n\n\n\nIn the second example, the value $3$ must be put in the middle cell.\n\nIn the third example, the desired resultant matrix does not exist.\n\nThe input will be stdin and you should print your solution to stdout\n\n\nNow solve the problem and return the code.",
"role": "user"
}
] |
[{"input": "4 5\n1 3 5 6 7\n3 0 7 0 9\n5 0 0 0 10\n8 9 10 11 12\n", "output": "144\n", "type": "code"}, {"input": "3 3\n1 2 3\n2 0 4\n4 5 6\n", "output": "30\n", "type": "code"}, {"input": "3 3\n1 2 3\n3 0 4\n4 5 6\n", "output": "-1\n", "type": "code"}, {"input": "3 3\n1 2 3\n2 3 4\n3 4 2\n", "output": "-1\n", "type": "code"}, {"input": "3 3\n733 1305 1980\n1283 1780 2328\n2136 2791 3586\n", "output": "17922\n", "type": "code"}, {"input": "3 3\n2999 3000 4000\n3000 0 5000\n4000 6000 8000\n", "output": "40998\n", "type": "code"}, {"input": "3 3\n2999 3000 4000\n3000 0 7000\n4000 6000 8000\n", "output": "43998\n", "type": "code"}, {"input": "8 5\n2 3 6 7 9\n4 0 0 0 12\n5 7 0 9 15\n6 0 0 0 16\n9 12 13 0 18\n10 14 0 0 21\n12 0 15 0 23\n15 17 20 23 26\n", "output": "-1\n", "type": "code"}, {"input": "4 10\n3 4 7 10 14 18 22 23 26 27\n5 9 0 11 18 0 0 0 0 31\n7 0 10 0 0 23 0 28 0 32\n11 12 15 18 22 26 30 31 35 37\n", "output": "-1\n", "type": "code"}, {"input": "10 4\n4 9 11 12\n8 11 13 18\n13 16 18 21\n15 21 0 24\n17 0 21 29\n21 26 0 33\n26 31 33 35\n30 32 35 37\n33 37 40 43\n34 41 46 51\n", "output": "-1\n", "type": "code"}, {"input": "3 3\n1 1 1\n1 1 1\n1 1 1\n", "output": "-1\n", "type": "code"}, {"input": "3 3\n7996 7997 7998\n7997 7998 7999\n7998 7998 8000\n", "output": "-1\n", "type": "code"}, {"input": "3 3\n7996 7997 7998\n7997 7998 7999\n7998 7999 8000\n", "output": "71982\n", "type": "code"}, {"input": "3 3\n7996 7997 7998\n7997 7998 7998\n7998 7999 8000\n", "output": "-1\n", "type": "code"}, {"input": "3 3\n1 2 3\n2 3 4\n3 4 4\n", "output": "-1\n", "type": "code"}, {"input": "3 3\n1 2 3\n2 3 4\n3 5 5\n", "output": "-1\n", "type": "code"}, {"input": "3 3\n1 2 3\n2 3 5\n3 4 5\n", "output": "-1\n", "type": "code"}]
|
0cab7c559cc44ed5b98cea104536ee69
|
code_stdio
|
[
{
"content": "Solve the following coding problem using the programming language python:\n\nFor integers b (b \\geq 2) and n (n \\geq 1), let the function f(b,n) be defined as follows:\n - f(b,n) = n, when n < b\n - f(b,n) = f(b,\\,{\\rm floor}(n / b)) + (n \\ {\\rm mod} \\ b), when n \\geq b\nHere, {\\rm floor}(n / b) denotes the largest integer not exceeding n / b,\nand n \\ {\\rm mod} \\ b denotes the remainder of n divided by b.\nLess formally, f(b,n) is equal to the sum of the digits of n written in base b.\nFor example, the following hold:\n - f(10,\\,87654)=8+7+6+5+4=30\n - f(100,\\,87654)=8+76+54=138\nYou are given integers n and s.\nDetermine if there exists an integer b (b \\geq 2) such that f(b,n)=s.\nIf the answer is positive, also find the smallest such b.\n\n-----Constraints-----\n - 1 \\leq n \\leq 10^{11}\n - 1 \\leq s \\leq 10^{11}\n - n,\\,s are integers.\n\n-----Input-----\nThe input is given from Standard Input in the following format:\nn\ns\n\n-----Output-----\nIf there exists an integer b (b \\geq 2) such that f(b,n)=s, print the smallest such b.\nIf such b does not exist, print -1 instead.\n\n-----Sample Input-----\n87654\n30\n\n-----Sample Output-----\n10\n\n\nThe input will be stdin and you should print your solution to stdout\n\n\nNow solve the problem and return the code.",
"role": "user"
}
] |
[{"input": "87654\n30\n", "output": "10\n", "type": "code"}, {"input": "87654\n138\n", "output": "100\n", "type": "code"}, {"input": "87654\n45678\n", "output": "-1\n", "type": "code"}, {"input": "31415926535\n1\n", "output": "31415926535\n", "type": "code"}, {"input": "1\n31415926535\n", "output": "-1\n", "type": "code"}, {"input": "100000000000\n1\n", "output": "10\n", "type": "code"}, {"input": "100000000000\n100000000000\n", "output": "100000000001\n", "type": "code"}, {"input": "100000000000\n2\n", "output": "50000000000\n", "type": "code"}, {"input": "100000000000\n3\n", "output": "99999999998\n", "type": "code"}, {"input": "100000000000\n50000000000\n", "output": "50000000001\n", "type": "code"}, {"input": "100000000000\n50000000001\n", "output": "-1\n", "type": "code"}, {"input": "100000000000\n99999999999\n", "output": "-1\n", "type": "code"}, {"input": "16983563041\n1\n", "output": "19\n", "type": "code"}, {"input": "1\n1\n", "output": "2\n", "type": "code"}, {"input": "1\n2\n", "output": "-1\n", "type": "code"}, {"input": "239484768\n194586924\n", "output": "-1\n", "type": "code"}, {"input": "2\n1\n", "output": "2\n", "type": "code"}, {"input": "2\n2\n", "output": "3\n", "type": "code"}, {"input": "49234683534\n2461734011\n", "output": "46772949524\n", "type": "code"}, {"input": "4\n1\n", "output": "2\n", "type": "code"}, {"input": "58640129658\n232122496\n", "output": "296487347\n", "type": "code"}, {"input": "68719476735\n35\n", "output": "131070\n", "type": "code"}, {"input": "68719476735\n36\n", "output": "2\n", "type": "code"}, {"input": "68719476735\n37\n", "output": "1857283155\n", "type": "code"}, {"input": "68719476736\n1\n", "output": "2\n", "type": "code"}, {"input": "68719476736\n2\n", "output": "32\n", "type": "code"}, {"input": "72850192441\n16865701\n", "output": "17592592\n", "type": "code"}, {"input": "79285169301\n27\n", "output": "3\n", "type": "code"}, {"input": "82914867733\n1676425945\n", "output": "1934248615\n", "type": "code"}, {"input": "8594813796\n75700\n", "output": "47573\n", "type": "code"}, {"input": "87654\n12345\n", "output": "25104\n", "type": "code"}, {"input": "87654\n4294967308\n", "output": "-1\n", "type": "code"}, {"input": "97822032312\n49157112\n", "output": "49156801\n", "type": "code"}, {"input": "98750604051\n977728851\n", "output": "977728753\n", "type": "code"}, {"input": "99999515529\n1\n", "output": "316227\n", "type": "code"}, {"input": "99999515529\n316226\n", "output": "1327148\n", "type": "code"}, {"input": "99999515529\n316227\n", "output": "316228\n", "type": "code"}, {"input": "99999515529\n316228\n", "output": "463602\n", "type": "code"}, {"input": "99999515529\n49999757765\n", "output": "49999757765\n", "type": "code"}, {"input": "99999515529\n49999757766\n", "output": "-1\n", "type": "code"}, {"input": "99999515530\n2\n", "output": "316227\n", "type": "code"}, {"input": "99999999977\n1\n", "output": "99999999977\n", "type": "code"}, {"input": "99999999977\n2\n", "output": "99999999976\n", "type": "code"}, {"input": "99999999977\n49999999989\n", "output": "49999999989\n", "type": "code"}, {"input": "99999999977\n49999999990\n", "output": "-1\n", "type": "code"}, {"input": "99999999999\n1\n", "output": "99999999999\n", "type": "code"}, {"input": "99999999999\n100000000000\n", "output": "-1\n", "type": "code"}]
|
9af28efda47122106d3d3cbfb6c56b1f
|
code_stdio
|
[
{
"content": "Solve the following coding problem using the programming language python:\n\nRikhail Mubinchik believes that the current definition of prime numbers is obsolete as they are too complex and unpredictable. A palindromic number is another matter. It is aesthetically pleasing, and it has a number of remarkable properties. Help Rikhail to convince the scientific community in this!\n\nLet us remind you that a number is called prime if it is integer larger than one, and is not divisible by any positive integer other than itself and one.\n\nRikhail calls a number a palindromic if it is integer, positive, and its decimal representation without leading zeros is a palindrome, i.e. reads the same from left to right and right to left.\n\nOne problem with prime numbers is that there are too many of them. Let's introduce the following notation: π(n) — the number of primes no larger than n, rub(n) — the number of palindromic numbers no larger than n. Rikhail wants to prove that there are a lot more primes than palindromic ones.\n\nHe asked you to solve the following problem: for a given value of the coefficient A find the maximum n, such that π(n) ≤ A·rub(n).\n\n\n-----Input-----\n\nThe input consists of two positive integers p, q, the numerator and denominator of the fraction that is the value of A ($A = \\frac{p}{q}$, $p, q \\leq 10^{4}, \\frac{1}{42} \\leq \\frac{p}{q} \\leq 42$).\n\n\n-----Output-----\n\nIf such maximum number exists, then print it. Otherwise, print \"Palindromic tree is better than splay tree\" (without the quotes).\n\n\n-----Examples-----\nInput\n1 1\n\nOutput\n40\n\nInput\n1 42\n\nOutput\n1\n\nInput\n6 4\n\nOutput\n172\n\nThe input will be stdin and you should print your solution to stdout\n\n\nNow solve the problem and return the code.",
"role": "user"
}
] |
[{"input": "1 1\n", "output": "40\n", "type": "code"}, {"input": "1 42\n", "output": "1\n", "type": "code"}, {"input": "6 4\n", "output": "172\n", "type": "code"}, {"input": "3 1\n", "output": "2530\n", "type": "code"}, {"input": "42 1\n", "output": "1179858\n", "type": "code"}, {"input": "10000 239\n", "output": "1168638\n", "type": "code"}, {"input": "5 8\n", "output": "16\n", "type": "code"}, {"input": "7 11\n", "output": "16\n", "type": "code"}, {"input": "16 60\n", "output": "1\n", "type": "code"}, {"input": "214 210\n", "output": "40\n", "type": "code"}, {"input": "620 35\n", "output": "251262\n", "type": "code"}, {"input": "940 480\n", "output": "1372\n", "type": "code"}, {"input": "1307 3420\n", "output": "1\n", "type": "code"}, {"input": "6811 5416\n", "output": "66\n", "type": "code"}, {"input": "7 267\n", "output": "1\n", "type": "code"}, {"input": "106 6\n", "output": "250300\n", "type": "code"}, {"input": "10000 10000\n", "output": "40\n", "type": "code"}, {"input": "10000 9999\n", "output": "40\n", "type": "code"}, {"input": "9999 9998\n", "output": "40\n", "type": "code"}, {"input": "9999 9999\n", "output": "40\n", "type": "code"}, {"input": "4 9\n", "output": "10\n", "type": "code"}, {"input": "1000 10000\n", "output": "1\n", "type": "code"}, {"input": "238 9996\n", "output": "1\n", "type": "code"}, {"input": "999 10000\n", "output": "1\n", "type": "code"}, {"input": "241 10000\n", "output": "1\n", "type": "code"}, {"input": "239 10000\n", "output": "1\n", "type": "code"}, {"input": "5858 674\n", "output": "71118\n", "type": "code"}]
|
c390e12d92e3f803fe81d289c99dcdb2
|
code_stdio
|
[
{
"content": "Solve the following coding problem using the programming language python:\n\nRecently you have received two positive integer numbers $x$ and $y$. You forgot them, but you remembered a shuffled list containing all divisors of $x$ (including $1$ and $x$) and all divisors of $y$ (including $1$ and $y$). If $d$ is a divisor of both numbers $x$ and $y$ at the same time, there are two occurrences of $d$ in the list.\n\nFor example, if $x=4$ and $y=6$ then the given list can be any permutation of the list $[1, 2, 4, 1, 2, 3, 6]$. Some of the possible lists are: $[1, 1, 2, 4, 6, 3, 2]$, $[4, 6, 1, 1, 2, 3, 2]$ or $[1, 6, 3, 2, 4, 1, 2]$.\n\nYour problem is to restore suitable positive integer numbers $x$ and $y$ that would yield the same list of divisors (possibly in different order).\n\nIt is guaranteed that the answer exists, i.e. the given list of divisors corresponds to some positive integers $x$ and $y$.\n\n\n-----Input-----\n\nThe first line contains one integer $n$ ($2 \\le n \\le 128$) — the number of divisors of $x$ and $y$.\n\nThe second line of the input contains $n$ integers $d_1, d_2, \\dots, d_n$ ($1 \\le d_i \\le 10^4$), where $d_i$ is either divisor of $x$ or divisor of $y$. If a number is divisor of both numbers $x$ and $y$ then there are two copies of this number in the list.\n\n\n-----Output-----\n\nPrint two positive integer numbers $x$ and $y$ — such numbers that merged list of their divisors is the permutation of the given list of integers. It is guaranteed that the answer exists.\n\n\n-----Example-----\nInput\n10\n10 2 8 1 2 4 1 20 4 5\n\nOutput\n20 8\n\nThe input will be stdin and you should print your solution to stdout\n\n\nNow solve the problem and return the code.",
"role": "user"
}
] |
[{"input": "10\n10 2 8 1 2 4 1 20 4 5\n", "output": "20 8\n", "type": "code"}, {"input": "4\n9973 9973 1 1\n", "output": "9973 9973\n", "type": "code"}, {"input": "66\n35 90 36 7560 189 14 360 180 168 12 1 252 21 8 630 15 40 1512 18 9973 108 7 540 3 210 270 2520 504 1890 6 378 70 1080 30 20 84 1260 420 105 9 135 28 60 72 315 24 63 126 27 280 45 5 120 1 42 945 216 4 756 140 840 56 10 2 54 3780\n", "output": "9973 7560\n", "type": "code"}, {"input": "128\n540 90 378 3780 270 35 180 15 6 14 20 3780 2520 140 1080 54 540 120 1890 15 420 840 20 756 10 126 42 54 36 14 216 8 168 210 60 7 63 2 216 21 30 189 28 135 2 630 21 30 60 1512 7560 70 5 12 40 7560 252 378 3 108 5 72 10 3 28 24 1 27 9 45 180 56 1260 945 1080 420 168 2520 18 70 1 27 9 7 315 4 84 40 504 360 252 6 8 360 315 140 45 210 84 56 945 135 1260 280 756 90 108 630 36 42 72 504 1512 189 120 105 105 280 24 270 63 18 840 1890 126 35 12 4\n", "output": "7560 7560\n", "type": "code"}, {"input": "23\n16 128 256 27 32 243 1 512 64 8192 2 1024 81 8 1 4 729 4096 3 2187 6561 9 2048\n", "output": "8192 6561\n", "type": "code"}, {"input": "65\n108 90 27 72 2520 30 3780 35 20 21 315 42 63 120 1 945 135 1512 28 40 210 756 9 24 180 1890 1 2 189 378 5 1080 280 168 126 840 45 7 6 216 630 4 7560 18 8 56 140 504 60 105 54 252 3 360 1260 15 420 12 14 36 270 70 10 540 84\n", "output": "7560 1\n", "type": "code"}, {"input": "28\n8192 4 128 1024 8 4 2048 8 16 64 2 512 1 2048 32 256 8192 4096 64 4096 256 16 1024 512 128 2 32 1\n", "output": "8192 8192\n", "type": "code"}, {"input": "2\n1 1\n", "output": "1 1\n", "type": "code"}, {"input": "50\n1250 5000 250 1000 500 10 40 250 80 16 10000 125 200 50 80 1 4 20 1 10000 2500 100 4 20 625 10 2 200 8 1000 16 2000 400 5 5 2500 8 400 5000 2 625 125 50 25 2000 1250 100 40 500 25\n", "output": "10000 10000\n", "type": "code"}, {"input": "89\n1080 126 315 18 3780 84 180 2520 12 756 70 504 15 9 36 630 20 2 2500 360 200 1000 100 108 5000 5 14 1890 10 90 105 7560 2 80 16 28 35 840 1 189 125 6 4 1512 945 40 10 210 8 25 280 8 20 270 27 1260 72 420 120 168 30 625 500 540 140 42 252 1 54 50 56 40 21 7 1250 63 216 250 4 10000 5 400 3 60 45 24 135 2000 378\n", "output": "10000 7560\n", "type": "code"}, {"input": "8\n1234 4321 29 1 2 1 149 617\n", "output": "4321 1234\n", "type": "code"}, {"input": "64\n945 130 78 135 91 630 14 2730 27 1 35 2 5 210 9 65 195 1365 7 3 390 70 455 10 15 378 3 315 39 105 273 10 21 2 45 15 546 35 42 90 18 182 26 910 63 189 30 210 6 70 105 30 54 270 1890 6 13 5 21 7 1 42 14 126\n", "output": "2730 1890\n", "type": "code"}, {"input": "20\n1 243 1 6561 128 81 4 8 32 16 3 2187 64 512 9 27 256 1024 2 729\n", "output": "6561 1024\n", "type": "code"}, {"input": "12\n66 6 3 33 22 3 1 1 2 11 11 33\n", "output": "66 33\n", "type": "code"}, {"input": "6\n6 1 1 2 3 3\n", "output": "6 3\n", "type": "code"}, {"input": "14\n14 28 2 2 56 1 14 28 4 7 1 7 8 4\n", "output": "56 28\n", "type": "code"}, {"input": "69\n1 7560 2 3780 3 2520 4 1890 5 1512 6 1260 7 1080 8 945 9 840 10 756 12 630 14 540 15 504 18 420 20 378 21 360 24 315 27 280 28 270 30 252 35 216 36 210 40 189 42 180 45 168 54 140 56 135 60 126 63 120 70 108 72 105 84 90 1 2 4 8 16\n", "output": "7560 16\n", "type": "code"}, {"input": "14\n2 1 3 1 16 2 12 8 24 6 3 6 48 4\n", "output": "48 6\n", "type": "code"}, {"input": "10\n2 1 5 6 15 2 30 10 3 1\n", "output": "30 2\n", "type": "code"}, {"input": "18\n1 2 4 5 10 20 1 2 4 5 10 20 30 60 15 3 6 12\n", "output": "60 20\n", "type": "code"}, {"input": "5\n1 3 9 3 1\n", "output": "9 3\n", "type": "code"}, {"input": "7\n1 1 2 2 4 4 8\n", "output": "8 4\n", "type": "code"}, {"input": "6\n1 7 1 14 7 2\n", "output": "14 7\n", "type": "code"}, {"input": "7\n1 2 4 1 2 4 8\n", "output": "8 4\n", "type": "code"}, {"input": "8\n1 2 4 1 2 4 8 16\n", "output": "16 4\n", "type": "code"}, {"input": "12\n5 2 10 8 20 4 2 4 1 40 1 8\n", "output": "40 8\n", "type": "code"}, {"input": "6\n29 29 1 1 58 2\n", "output": "58 29\n", "type": "code"}, {"input": "10\n1 2 4 5 10 20 1 2 5 10\n", "output": "20 10\n", "type": "code"}, {"input": "8\n16 8 4 2 1 4 2 1\n", "output": "16 4\n", "type": "code"}, {"input": "10\n1 2 5 10 1 2 4 5 10 20\n", "output": "20 10\n", "type": "code"}, {"input": "5\n1 2 4 1 2\n", "output": "4 2\n", "type": "code"}, {"input": "12\n3 15 1 10 2 15 1 3 30 5 5 6\n", "output": "30 15\n", "type": "code"}, {"input": "10\n1 2 1 2 4 5 5 10 10 20\n", "output": "20 10\n", "type": "code"}, {"input": "5\n1 7 49 1 7\n", "output": "49 7\n", "type": "code"}, {"input": "5\n1 1 2 2 4\n", "output": "4 2\n", "type": "code"}, {"input": "6\n29 58 2 29 1 1\n", "output": "58 29\n", "type": "code"}, {"input": "10\n7 14 5 35 70 1 7 2 10 1\n", "output": "70 7\n", "type": "code"}, {"input": "5\n1 2 1 2 4\n", "output": "4 2\n", "type": "code"}, {"input": "15\n12 36 8 4 6 9 72 2 4 2 1 18 24 3 1\n", "output": "72 4\n", "type": "code"}, {"input": "12\n1 2 8 4 3 24 4 6 1 2 8 12\n", "output": "24 8\n", "type": "code"}, {"input": "12\n2 32 64 4 16 16 8 8 2 1 1 4\n", "output": "64 16\n", "type": "code"}, {"input": "5\n31 1 1 7 49\n", "output": "49 31\n", "type": "code"}, {"input": "12\n2 3 13 3 39 13 1 6 39 26 78 1\n", "output": "78 39\n", "type": "code"}, {"input": "9\n7 49 1 1 98 14 49 7 2\n", "output": "98 49\n", "type": "code"}, {"input": "6\n13 5 1 1 13 65\n", "output": "65 13\n", "type": "code"}, {"input": "4\n1 61 31 1\n", "output": "61 31\n", "type": "code"}, {"input": "5\n1 5 5 25 1\n", "output": "25 5\n", "type": "code"}, {"input": "5\n25 5 1 5 1\n", "output": "25 5\n", "type": "code"}, {"input": "10\n1 1 2 2 3 3 4 6 6 12\n", "output": "12 6\n", "type": "code"}, {"input": "5\n25 5 5 1 1\n", "output": "25 5\n", "type": "code"}, {"input": "6\n23 1 2 46 23 1\n", "output": "46 23\n", "type": "code"}, {"input": "18\n10 1 4 5 20 10 40 16 20 8 2 5 8 40 2 80 1 4\n", "output": "80 40\n", "type": "code"}, {"input": "6\n1 1 2 2 5 10\n", "output": "10 2\n", "type": "code"}, {"input": "10\n6 10 1 3 15 5 2 61 30 1\n", "output": "61 30\n", "type": "code"}, {"input": "6\n1 6 3 2 3 1\n", "output": "6 3\n", "type": "code"}, {"input": "16\n30 1 3 90 9 27 3 9 45 10 6 18 1 15 2 5\n", "output": "90 27\n", "type": "code"}, {"input": "11\n54 18 1 3 27 9 6 1 9 3 2\n", "output": "54 9\n", "type": "code"}, {"input": "7\n1 2 4 8 16 1 2\n", "output": "16 2\n", "type": "code"}, {"input": "7\n1 16 1 4 2 2 8\n", "output": "16 2\n", "type": "code"}, {"input": "6\n1 1 2 5 5 10\n", "output": "10 5\n", "type": "code"}, {"input": "9\n9 2 6 3 18 1 1 3 9\n", "output": "18 9\n", "type": "code"}, {"input": "13\n1 2 3 4 6 9 12 18 36 1 2 3 6\n", "output": "36 6\n", "type": "code"}, {"input": "6\n1 1 2 3 3 6\n", "output": "6 3\n", "type": "code"}, {"input": "8\n2 2 1 5 50 25 10 1\n", "output": "50 2\n", "type": "code"}, {"input": "4\n67 1 13 1\n", "output": "67 13\n", "type": "code"}, {"input": "18\n75 3 9 8 18 2 12 36 25 3 15 72 24 4 6 1 5 1\n", "output": "75 72\n", "type": "code"}, {"input": "12\n2 1 3 12 4 8 24 4 1 8 6 2\n", "output": "24 8\n", "type": "code"}, {"input": "9\n20 10 5 4 2 1 4 2 1\n", "output": "20 4\n", "type": "code"}, {"input": "18\n8 8 3 16 4 2 20 2 5 4 24 6 40 1 1 10 80 12\n", "output": "80 24\n", "type": "code"}, {"input": "13\n100 50 25 20 10 5 4 2 1 10 5 2 1\n", "output": "100 10\n", "type": "code"}, {"input": "6\n94 2 47 1 1 3\n", "output": "94 3\n", "type": "code"}, {"input": "6\n58 2 2 1 29 1\n", "output": "58 2\n", "type": "code"}, {"input": "20\n1 18 10 9 2 15 5 45 3 10 1 30 15 6 5 2 30 3 6 90\n", "output": "90 30\n", "type": "code"}, {"input": "13\n2 1 8 10 2 4 16 5 40 1 4 20 80\n", "output": "80 4\n", "type": "code"}, {"input": "6\n6 3 1 3 2 1\n", "output": "6 3\n", "type": "code"}, {"input": "10\n1 3 5 15 1 3 5 9 15 45\n", "output": "45 15\n", "type": "code"}, {"input": "6\n47 47 2 94 1 1\n", "output": "94 47\n", "type": "code"}, {"input": "14\n4 56 14 4 2 7 28 8 14 7 1 1 2 28\n", "output": "56 28\n", "type": "code"}, {"input": "6\n1 1 2 2 4 8\n", "output": "8 2\n", "type": "code"}, {"input": "6\n55 5 11 1 1 5\n", "output": "55 5\n", "type": "code"}, {"input": "11\n36 2 3 1 18 6 2 4 1 9 12\n", "output": "36 2\n", "type": "code"}, {"input": "6\n1 2 31 31 1 62\n", "output": "62 31\n", "type": "code"}, {"input": "10\n1 7 11 77 121 847 1 7 11 77\n", "output": "847 77\n", "type": "code"}, {"input": "4\n1 1 2 7\n", "output": "7 2\n", "type": "code"}, {"input": "18\n90 18 2 9 5 6 18 1 6 3 1 3 10 45 9 15 2 30\n", "output": "90 18\n", "type": "code"}, {"input": "6\n1 2 1 2 4 8\n", "output": "8 2\n", "type": "code"}, {"input": "20\n24 16 32 2 3 96 1 2 12 48 4 6 8 12 6 8 24 3 4 1\n", "output": "96 24\n", "type": "code"}, {"input": "10\n1 2 3 6 1 2 3 4 6 12\n", "output": "12 6\n", "type": "code"}, {"input": "10\n11 11 1 44 2 22 4 22 1 2\n", "output": "44 22\n", "type": "code"}, {"input": "10\n3 1 15 2 30 10 1 5 23 6\n", "output": "30 23\n", "type": "code"}, {"input": "8\n1 3 9 27 81 1 3 9\n", "output": "81 9\n", "type": "code"}, {"input": "6\n6 1 3 3 2 1\n", "output": "6 3\n", "type": "code"}, {"input": "10\n76 38 1 2 1 4 5 3 15 19\n", "output": "76 15\n", "type": "code"}, {"input": "6\n1 2 3 6 1 3\n", "output": "6 3\n", "type": "code"}, {"input": "6\n23 23 2 1 1 46\n", "output": "46 23\n", "type": "code"}, {"input": "3\n1 3 1\n", "output": "3 1\n", "type": "code"}, {"input": "12\n4 1 1 12 6 21 63 2 9 3 7 3\n", "output": "63 12\n", "type": "code"}, {"input": "6\n11 1 2 22 2 1\n", "output": "22 2\n", "type": "code"}, {"input": "10\n21 3 63 9 5 1 15 7 1 3\n", "output": "63 15\n", "type": "code"}, {"input": "10\n3 11 1 11 1 33 33 3 9 99\n", "output": "99 33\n", "type": "code"}, {"input": "10\n22 1 33 11 3 6 66 11 1 2\n", "output": "66 11\n", "type": "code"}, {"input": "18\n4 2 30 5 3 1 12 6 4 60 12 15 1 3 6 10 2 20\n", "output": "60 12\n", "type": "code"}, {"input": "16\n2 7 84 14 6 1 7 1 3 21 12 42 28 2 4 14\n", "output": "84 14\n", "type": "code"}, {"input": "6\n1 2 5 10 1 5\n", "output": "10 5\n", "type": "code"}, {"input": "3\n1 1 2\n", "output": "2 1\n", "type": "code"}, {"input": "12\n3 1 2 6 5 1 10 2 10 5 30 15\n", "output": "30 10\n", "type": "code"}, {"input": "10\n3 1 5 30 10 2 15 6 3 1\n", "output": "30 3\n", "type": "code"}, {"input": "21\n72 9 3 6 3 1 18 36 2 24 36 2 12 4 9 12 8 18 6 4 1\n", "output": "72 36\n", "type": "code"}, {"input": "11\n2 6 12 4 18 3 1 3 36 1 9\n", "output": "36 3\n", "type": "code"}, {"input": "18\n1 4 12 6 72 8 3 36 1 18 9 18 24 2 3 2 9 6\n", "output": "72 18\n", "type": "code"}, {"input": "11\n36 3 1 1 4 9 12 2 3 18 6\n", "output": "36 3\n", "type": "code"}, {"input": "6\n65 1 5 5 1 13\n", "output": "65 5\n", "type": "code"}, {"input": "8\n1 2 17 17 34 68 1 4\n", "output": "68 17\n", "type": "code"}, {"input": "5\n1 1 3 3 9\n", "output": "9 3\n", "type": "code"}, {"input": "10\n39 26 6 1 1 2 13 78 3 13\n", "output": "78 13\n", "type": "code"}, {"input": "12\n2 5 50 25 25 5 10 20 100 1 4 1\n", "output": "100 25\n", "type": "code"}, {"input": "14\n1 6 9 90 10 5 5 2 30 1 18 15 3 45\n", "output": "90 5\n", "type": "code"}, {"input": "10\n17 17 1 34 4 68 2 2 34 1\n", "output": "68 34\n", "type": "code"}, {"input": "16\n4 36 3 4 2 1 72 9 8 2 6 8 12 24 18 1\n", "output": "72 8\n", "type": "code"}, {"input": "11\n1 9 54 27 6 3 2 1 9 3 18\n", "output": "54 9\n", "type": "code"}, {"input": "5\n1 3 3 9 1\n", "output": "9 3\n", "type": "code"}, {"input": "8\n1 65 29 58 5 2 1 13\n", "output": "65 58\n", "type": "code"}, {"input": "3\n1 2 1\n", "output": "2 1\n", "type": "code"}, {"input": "14\n2 2 3 7 1 42 14 28 84 4 21 6 12 1\n", "output": "84 2\n", "type": "code"}, {"input": "8\n7 14 7 1 2 4 1 28\n", "output": "28 7\n", "type": "code"}, {"input": "6\n1 2 1 2 3 6\n", "output": "6 2\n", "type": "code"}, {"input": "12\n25 20 2 5 1 1 4 10 50 100 5 25\n", "output": "100 25\n", "type": "code"}, {"input": "10\n1 8 3 9 4 2 33 11 99 1\n", "output": "99 8\n", "type": "code"}, {"input": "6\n1 11 1 11 5 55\n", "output": "55 11\n", "type": "code"}, {"input": "10\n32 1 1 2 2 8 4 4 8 16\n", "output": "32 8\n", "type": "code"}, {"input": "8\n9 9 1 81 3 27 1 3\n", "output": "81 9\n", "type": "code"}, {"input": "6\n7 1 11 7 77 1\n", "output": "77 7\n", "type": "code"}, {"input": "20\n12 21 7 21 2 1 6 42 3 42 3 7 4 84 14 14 2 6 28 1\n", "output": "84 42\n", "type": "code"}, {"input": "4\n1 2 53 1\n", "output": "53 2\n", "type": "code"}, {"input": "14\n1 2 4 5 8 10 20 40 1 2 4 5 10 20\n", "output": "40 20\n", "type": "code"}, {"input": "18\n1 4 16 3 12 12 3 24 1 4 6 48 8 6 2 24 2 8\n", "output": "48 24\n", "type": "code"}, {"input": "4\n5 1 1 61\n", "output": "61 5\n", "type": "code"}, {"input": "15\n24 8 4 3 2 6 1 2 32 1 48 12 96 4 16\n", "output": "96 4\n", "type": "code"}, {"input": "6\n62 1 31 31 2 1\n", "output": "62 31\n", "type": "code"}, {"input": "11\n2 18 4 27 54 3 2 1 6 1 9\n", "output": "54 4\n", "type": "code"}, {"input": "18\n6 1 36 3 1 9 9 72 4 18 12 6 2 3 18 8 2 24\n", "output": "72 18\n", "type": "code"}, {"input": "6\n1 3 2 1 39 13\n", "output": "39 2\n", "type": "code"}, {"input": "6\n87 29 29 3 1 1\n", "output": "87 29\n", "type": "code"}, {"input": "12\n4 8 7 14 14 2 2 7 28 56 1 1\n", "output": "56 14\n", "type": "code"}, {"input": "6\n2 1 43 86 1 2\n", "output": "86 2\n", "type": "code"}, {"input": "12\n21 2 33 6 66 7 3 3 1 1 11 22\n", "output": "66 21\n", "type": "code"}, {"input": "5\n1 7 1 49 7\n", "output": "49 7\n", "type": "code"}, {"input": "12\n2 1 16 4 6 3 8 1 48 24 2 12\n", "output": "48 2\n", "type": "code"}, {"input": "4\n1 43 1 13\n", "output": "43 13\n", "type": "code"}, {"input": "11\n5 2 25 100 20 50 10 1 5 1 4\n", "output": "100 5\n", "type": "code"}, {"input": "9\n27 6 81 3 3 1 1 2 9\n", "output": "81 6\n", "type": "code"}, {"input": "6\n1 1 29 3 87 29\n", "output": "87 29\n", "type": "code"}, {"input": "8\n15 5 3 75 1 5 1 25\n", "output": "75 5\n", "type": "code"}, {"input": "10\n4 32 16 4 1 2 8 64 2 1\n", "output": "64 4\n", "type": "code"}, {"input": "8\n3 12 6 4 3 1 1 2\n", "output": "12 3\n", "type": "code"}, {"input": "6\n47 1 1 94 7 2\n", "output": "94 7\n", "type": "code"}, {"input": "12\n3 7 1 1 21 14 21 6 3 42 2 7\n", "output": "42 21\n", "type": "code"}, {"input": "8\n1 5 1 2 4 5 10 20\n", "output": "20 5\n", "type": "code"}, {"input": "16\n2 1 5 30 1 6 12 2 4 10 60 20 10 5 15 3\n", "output": "60 10\n", "type": "code"}, {"input": "20\n9 12 2 24 36 24 1 3 18 6 8 72 12 4 1 2 8 3 6 4\n", "output": "72 24\n", "type": "code"}, {"input": "14\n24 9 18 8 6 12 72 1 3 4 1 5 2 36\n", "output": "72 5\n", "type": "code"}, {"input": "6\n1 7 1 7 5 35\n", "output": "35 7\n", "type": "code"}, {"input": "16\n6 4 1 1 6 2 2 36 8 3 12 9 3 18 24 72\n", "output": "72 6\n", "type": "code"}, {"input": "3\n67 1 1\n", "output": "67 1\n", "type": "code"}, {"input": "6\n1 58 29 1 2 2\n", "output": "58 2\n", "type": "code"}, {"input": "20\n12 8 6 96 4 3 16 8 32 12 6 4 48 1 24 3 24 1 2 2\n", "output": "96 24\n", "type": "code"}, {"input": "4\n5 25 1 1\n", "output": "25 1\n", "type": "code"}, {"input": "8\n5 33 9 99 3 11 1 1\n", "output": "99 5\n", "type": "code"}, {"input": "6\n1 1 17 51 3 3\n", "output": "51 3\n", "type": "code"}, {"input": "8\n87 7 14 1 2 29 1 3\n", "output": "87 14\n", "type": "code"}, {"input": "6\n23 23 2 46 1 1\n", "output": "46 23\n", "type": "code"}, {"input": "10\n1 1 2 2 4 5 5 10 10 20\n", "output": "20 10\n", "type": "code"}, {"input": "9\n81 2 1 9 27 3 6 3 1\n", "output": "81 6\n", "type": "code"}, {"input": "14\n48 16 4 6 1 8 3 4 12 1 2 2 8 24\n", "output": "48 8\n", "type": "code"}, {"input": "6\n1 2 2 14 1 7\n", "output": "14 2\n", "type": "code"}, {"input": "14\n12 18 4 2 2 72 6 36 24 8 3 1 9 1\n", "output": "72 2\n", "type": "code"}, {"input": "12\n15 5 10 1 1 5 6 30 3 2 3 15\n", "output": "30 15\n", "type": "code"}, {"input": "6\n1 2 5 95 1 19\n", "output": "95 2\n", "type": "code"}, {"input": "10\n1 7 42 7 1 2 21 3 14 6\n", "output": "42 7\n", "type": "code"}, {"input": "9\n1 18 2 6 9 1 3 3 9\n", "output": "18 9\n", "type": "code"}, {"input": "12\n8 6 1 3 1 4 12 24 2 16 48 3\n", "output": "48 3\n", "type": "code"}, {"input": "5\n1 25 1 5 5\n", "output": "25 5\n", "type": "code"}, {"input": "7\n3 27 1 81 3 1 9\n", "output": "81 3\n", "type": "code"}, {"input": "11\n6 24 8 1 2 4 1 12 3 4 2\n", "output": "24 4\n", "type": "code"}, {"input": "11\n4 10 5 20 25 2 50 1 2 100 1\n", "output": "100 2\n", "type": "code"}, {"input": "8\n23 46 2 4 1 1 23 92\n", "output": "92 23\n", "type": "code"}, {"input": "6\n85 17 5 17 1 1\n", "output": "85 17\n", "type": "code"}, {"input": "9\n4 4 11 44 2 22 2 1 1\n", "output": "44 4\n", "type": "code"}, {"input": "11\n2 4 1 4 16 32 16 8 8 1 2\n", "output": "32 16\n", "type": "code"}, {"input": "14\n8 2 16 5 2 1 10 1 4 80 20 10 5 40\n", "output": "80 10\n", "type": "code"}, {"input": "11\n18 2 1 3 12 6 1 4 2 36 9\n", "output": "36 2\n", "type": "code"}, {"input": "6\n1 2 4 8 1 16\n", "output": "16 1\n", "type": "code"}, {"input": "8\n10 4 20 2 1 1 5 2\n", "output": "20 2\n", "type": "code"}, {"input": "5\n1 1 3 9 3\n", "output": "9 3\n", "type": "code"}, {"input": "18\n10 20 4 12 30 6 5 5 3 4 10 1 20 1 15 2 2 60\n", "output": "60 20\n", "type": "code"}, {"input": "13\n4 16 8 4 2 1 8 64 1 2 32 16 32\n", "output": "64 32\n", "type": "code"}, {"input": "10\n27 54 18 1 2 1 9 3 6 3\n", "output": "54 3\n", "type": "code"}, {"input": "8\n7 6 1 1 5 3 2 35\n", "output": "35 6\n", "type": "code"}, {"input": "16\n28 2 14 4 3 12 84 6 7 21 1 2 3 42 6 1\n", "output": "84 6\n", "type": "code"}, {"input": "10\n9 1 11 33 1 11 99 3 33 3\n", "output": "99 33\n", "type": "code"}, {"input": "11\n2 1 6 12 8 2 24 3 4 1 4\n", "output": "24 4\n", "type": "code"}, {"input": "18\n2 6 8 6 2 4 1 3 1 36 72 3 12 24 12 4 18 9\n", "output": "72 12\n", "type": "code"}, {"input": "15\n96 48 16 4 2 24 12 6 1 8 2 1 4 32 3\n", "output": "96 4\n", "type": "code"}, {"input": "18\n12 28 3 3 14 6 4 7 2 42 12 21 6 1 2 1 84 4\n", "output": "84 12\n", "type": "code"}, {"input": "15\n5 3 3 6 15 18 45 9 9 10 1 90 2 1 30\n", "output": "90 9\n", "type": "code"}, {"input": "12\n10 1 5 100 25 20 4 2 50 1 5 25\n", "output": "100 25\n", "type": "code"}, {"input": "6\n3 1 3 1 6 2\n", "output": "6 3\n", "type": "code"}, {"input": "10\n95 1 19 6 18 1 9 5 3 2\n", "output": "95 18\n", "type": "code"}, {"input": "18\n72 24 2 3 6 8 3 6 18 9 9 36 1 2 1 12 18 4\n", "output": "72 18\n", "type": "code"}, {"input": "6\n71 47 2 1 94 1\n", "output": "94 71\n", "type": "code"}, {"input": "20\n8 96 5 2 6 12 10 1 4 6 3 48 3 32 30 15 2 16 1 24\n", "output": "96 30\n", "type": "code"}, {"input": "7\n9 3 1 31 93 3 1\n", "output": "93 9\n", "type": "code"}, {"input": "10\n1 1 2 2 4 4 5 8 10 20\n", "output": "20 8\n", "type": "code"}, {"input": "12\n7 5 14 2 1 14 70 35 2 1 7 10\n", "output": "70 14\n", "type": "code"}, {"input": "4\n1 1 29 19\n", "output": "29 19\n", "type": "code"}, {"input": "14\n4 12 1 1 2 6 30 10 5 20 3 60 15 5\n", "output": "60 5\n", "type": "code"}, {"input": "11\n3 36 12 3 9 18 6 4 2 1 1\n", "output": "36 3\n", "type": "code"}, {"input": "12\n1 24 2 16 48 3 4 8 3 1 6 12\n", "output": "48 3\n", "type": "code"}, {"input": "10\n4 3 6 2 12 1 24 3 8 1\n", "output": "24 3\n", "type": "code"}, {"input": "6\n1 16 4 1 8 2\n", "output": "16 1\n", "type": "code"}, {"input": "5\n7 49 2 1 1\n", "output": "49 2\n", "type": "code"}, {"input": "7\n1 27 81 1 9 3 7\n", "output": "81 7\n", "type": "code"}, {"input": "4\n4 1 2 1\n", "output": "4 1\n", "type": "code"}, {"input": "13\n50 25 5 100 1 4 10 1 2 20 2 4 8\n", "output": "100 8\n", "type": "code"}, {"input": "9\n8 5 16 1 32 1 4 2 64\n", "output": "64 5\n", "type": "code"}, {"input": "8\n32 64 1 4 16 8 1 2\n", "output": "64 1\n", "type": "code"}, {"input": "12\n3 4 1 12 48 16 1 24 2 6 8 3\n", "output": "48 3\n", "type": "code"}, {"input": "4\n1 3 9 1\n", "output": "9 1\n", "type": "code"}, {"input": "6\n5 1 5 19 1 95\n", "output": "95 5\n", "type": "code"}, {"input": "9\n64 32 16 1 2 1 8 3 4\n", "output": "64 3\n", "type": "code"}, {"input": "5\n1 1 67 2 4\n", "output": "67 4\n", "type": "code"}, {"input": "5\n1 3 1 3 9\n", "output": "9 3\n", "type": "code"}, {"input": "9\n9 27 81 3 27 1 9 3 1\n", "output": "81 27\n", "type": "code"}, {"input": "8\n10 1 1 20 2 5 5 4\n", "output": "20 5\n", "type": "code"}, {"input": "5\n5 3 1 25 1\n", "output": "25 3\n", "type": "code"}, {"input": "6\n2 5 3 15 1 1\n", "output": "15 2\n", "type": "code"}, {"input": "10\n4 1 1 6 3 24 8 3 2 12\n", "output": "24 3\n", "type": "code"}, {"input": "3\n5 1 1\n", "output": "5 1\n", "type": "code"}, {"input": "4\n1 1 5 25\n", "output": "25 1\n", "type": "code"}, {"input": "12\n5 70 5 1 35 2 1 2 7 14 10 10\n", "output": "70 10\n", "type": "code"}, {"input": "4\n9 1 1 3\n", "output": "9 1\n", "type": "code"}, {"input": "9\n81 4 1 9 3 1 27 8 2\n", "output": "81 8\n", "type": "code"}, {"input": "6\n1 2 4 1 5 25\n", "output": "25 4\n", "type": "code"}, {"input": "9\n1 2 4 1 2 4 5 10 20\n", "output": "20 4\n", "type": "code"}]
|
7ebbe2e7a034c6c858d9044dbb6a699c
|
code_stdio
|
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given a problemset consisting of $n$ problems. The difficulty of the $i$-th problem is $a_i$. It is guaranteed that all difficulties are distinct and are given in the increasing order.\n\nYou have to assemble the contest which consists of some problems of the given problemset. In other words, the contest you have to assemble should be a subset of problems (not necessary consecutive) of the given problemset. There is only one condition that should be satisfied: for each problem but the hardest one (the problem with the maximum difficulty) there should be a problem with the difficulty greater than the difficulty of this problem but not greater than twice the difficulty of this problem. In other words, let $a_{i_1}, a_{i_2}, \\dots, a_{i_p}$ be the difficulties of the selected problems in increasing order. Then for each $j$ from $1$ to $p-1$ $a_{i_{j + 1}} \\le a_{i_j} \\cdot 2$ should hold. It means that the contest consisting of only one problem is always valid.\n\nAmong all contests satisfying the condition above you have to assemble one with the maximum number of problems. Your task is to find this number of problems.\n\n\n-----Input-----\n\nThe first line of the input contains one integer $n$ ($1 \\le n \\le 2 \\cdot 10^5$) — the number of problems in the problemset.\n\nThe second line of the input contains $n$ integers $a_1, a_2, \\dots, a_n$ ($1 \\le a_i \\le 10^9$) — difficulties of the problems. It is guaranteed that difficulties of the problems are distinct and are given in the increasing order.\n\n\n-----Output-----\n\nPrint a single integer — maximum number of problems in the contest satisfying the condition in the problem statement.\n\n\n-----Examples-----\nInput\n10\n1 2 5 6 7 10 21 23 24 49\n\nOutput\n4\n\nInput\n5\n2 10 50 110 250\n\nOutput\n1\n\nInput\n6\n4 7 12 100 150 199\n\nOutput\n3\n\n\n\n-----Note-----\n\nDescription of the first example: there are $10$ valid contests consisting of $1$ problem, $10$ valid contests consisting of $2$ problems ($[1, 2], [5, 6], [5, 7], [5, 10], [6, 7], [6, 10], [7, 10], [21, 23], [21, 24], [23, 24]$), $5$ valid contests consisting of $3$ problems ($[5, 6, 7], [5, 6, 10], [5, 7, 10], [6, 7, 10], [21, 23, 24]$) and a single valid contest consisting of $4$ problems ($[5, 6, 7, 10]$).\n\nIn the second example all the valid contests consist of $1$ problem.\n\nIn the third example are two contests consisting of $3$ problems: $[4, 7, 12]$ and $[100, 150, 199]$.\n\nThe input will be stdin and you should print your solution to stdout\n\n\nNow solve the problem and return the code.",
"role": "user"
}
] |
[{"input": "10\n1 2 5 6 7 10 21 23 24 49\n", "output": "4\n", "type": "code"}, {"input": "5\n2 10 50 110 250\n", "output": "1\n", "type": "code"}, {"input": "6\n4 7 12 100 150 199\n", "output": "3\n", "type": "code"}, {"input": "1\n1000000000\n", "output": "1\n", "type": "code"}, {"input": "2\n1 2\n", "output": "2\n", "type": "code"}, {"input": "4\n1 2 4 8\n", "output": "4\n", "type": "code"}, {"input": "5\n1 2 3 4 5\n", "output": "5\n", "type": "code"}, {"input": "3\n2 4 8\n", "output": "3\n", "type": "code"}, {"input": "10\n1 2 5 11 12 24 25 26 27 28\n", "output": "7\n", "type": "code"}, {"input": "9\n1 2 3 7 8 20 21 22 23\n", "output": "4\n", "type": "code"}, {"input": "3\n10 20 40\n", "output": "3\n", "type": "code"}, {"input": "8\n2 4 6 23 60 120 200 210\n", "output": "4\n", "type": "code"}, {"input": "5\n2 4 8 16 32\n", "output": "5\n", "type": "code"}, {"input": "9\n4 6 9 12 100 150 200 400 800\n", "output": "5\n", "type": "code"}, {"input": "7\n1 3 9 27 100 200 400\n", "output": "3\n", "type": "code"}, {"input": "3\n1 2 4\n", "output": "3\n", "type": "code"}, {"input": "3\n1 2 9\n", "output": "2\n", "type": "code"}, {"input": "5\n1 2 3 4 8\n", "output": "5\n", "type": "code"}, {"input": "2\n2 3\n", "output": "2\n", "type": "code"}, {"input": "2\n99999999 1000000000\n", "output": "1\n", "type": "code"}, {"input": "5\n1 2 4 8 16\n", "output": "5\n", "type": "code"}, {"input": "7\n4 7 12 100 150 300 600\n", "output": "4\n", "type": "code"}, {"input": "5\n1 2 4 5 8\n", "output": "5\n", "type": "code"}, {"input": "6\n1 2 5 10 21 42\n", "output": "2\n", "type": "code"}, {"input": "3\n1 3 6\n", "output": "2\n", "type": "code"}, {"input": "3\n1 2 5\n", "output": "2\n", "type": "code"}, {"input": "5\n1 2 5 10 20\n", "output": "3\n", "type": "code"}, {"input": "2\n1 3\n", "output": "1\n", "type": "code"}, {"input": "2\n10 20\n", "output": "2\n", "type": "code"}, {"input": "6\n1 2 5 11 22 44\n", "output": "3\n", "type": "code"}, {"input": "5\n1 2 4 9 18\n", "output": "3\n", "type": "code"}, {"input": "1\n1\n", "output": "1\n", "type": "code"}]
|
0fb99dd4ba0acceaa7431d7e18dfba09
|
code_stdio
|
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given an integer sequence $a_1, a_2, \\dots, a_n$.\n\nFind the number of pairs of indices $(l, r)$ ($1 \\le l \\le r \\le n$) such that the value of median of $a_l, a_{l+1}, \\dots, a_r$ is exactly the given number $m$.\n\nThe median of a sequence is the value of an element which is in the middle of the sequence after sorting it in non-decreasing order. If the length of the sequence is even, the left of two middle elements is used.\n\nFor example, if $a=[4, 2, 7, 5]$ then its median is $4$ since after sorting the sequence, it will look like $[2, 4, 5, 7]$ and the left of two middle elements is equal to $4$. The median of $[7, 1, 2, 9, 6]$ equals $6$ since after sorting, the value $6$ will be in the middle of the sequence.\n\nWrite a program to find the number of pairs of indices $(l, r)$ ($1 \\le l \\le r \\le n$) such that the value of median of $a_l, a_{l+1}, \\dots, a_r$ is exactly the given number $m$.\n\n\n-----Input-----\n\nThe first line contains integers $n$ and $m$ ($1 \\le n,m \\le 2\\cdot10^5$) — the length of the given sequence and the required value of the median.\n\nThe second line contains an integer sequence $a_1, a_2, \\dots, a_n$ ($1 \\le a_i \\le 2\\cdot10^5$).\n\n\n-----Output-----\n\nPrint the required number.\n\n\n-----Examples-----\nInput\n5 4\n1 4 5 60 4\n\nOutput\n8\n\nInput\n3 1\n1 1 1\n\nOutput\n6\n\nInput\n15 2\n1 2 3 1 2 3 1 2 3 1 2 3 1 2 3\n\nOutput\n97\n\n\n\n-----Note-----\n\nIn the first example, the suitable pairs of indices are: $(1, 3)$, $(1, 4)$, $(1, 5)$, $(2, 2)$, $(2, 3)$, $(2, 5)$, $(4, 5)$ and $(5, 5)$.\n\nThe input will be stdin and you should print your solution to stdout\n\n\nNow solve the problem and return the code.",
"role": "user"
}
] |
[{"input": "5 4\n1 4 5 60 4\n", "output": "8\n", "type": "code"}, {"input": "3 1\n1 1 1\n", "output": "6\n", "type": "code"}, {"input": "15 2\n1 2 3 1 2 3 1 2 3 1 2 3 1 2 3\n", "output": "97\n", "type": "code"}, {"input": "1 1\n1\n", "output": "1\n", "type": "code"}, {"input": "2 1\n1 2\n", "output": "2\n", "type": "code"}, {"input": "2 1\n2 1\n", "output": "2\n", "type": "code"}, {"input": "2 2\n1 2\n", "output": "1\n", "type": "code"}, {"input": "2 2\n2 1\n", "output": "1\n", "type": "code"}, {"input": "3 1\n1 2 3\n", "output": "2\n", "type": "code"}, {"input": "3 1\n1 3 2\n", "output": "2\n", "type": "code"}, {"input": "3 1\n2 1 3\n", "output": "3\n", "type": "code"}, {"input": "3 1\n2 3 1\n", "output": "2\n", "type": "code"}, {"input": "3 1\n3 1 2\n", "output": "3\n", "type": "code"}, {"input": "3 1\n3 2 1\n", "output": "2\n", "type": "code"}, {"input": "2 2\n1 1\n", "output": "0\n", "type": "code"}, {"input": "3 2\n1 1 2\n", "output": "1\n", "type": "code"}, {"input": "2 1\n1 1\n", "output": "3\n", "type": "code"}, {"input": "1 1\n2\n", "output": "0\n", "type": "code"}, {"input": "2 2\n4 1\n", "output": "0\n", "type": "code"}, {"input": "3 3\n5 5 3\n", "output": "2\n", "type": "code"}, {"input": "4 3\n3 5 2 3\n", "output": "6\n", "type": "code"}, {"input": "5 2\n1 9 2 8 10\n", "output": "5\n", "type": "code"}, {"input": "6 5\n7 2 11 8 9 12\n", "output": "0\n", "type": "code"}, {"input": "7 5\n14 4 1 11 12 3 4\n", "output": "0\n", "type": "code"}, {"input": "8 2\n2 6 11 14 10 9 9 5\n", "output": "2\n", "type": "code"}, {"input": "9 8\n10 8 8 15 1 2 13 8 6\n", "output": "27\n", "type": "code"}, {"input": "10 7\n14 20 3 3 8 16 17 13 6 4\n", "output": "0\n", "type": "code"}, {"input": "1 200000\n1\n", "output": "0\n", "type": "code"}, {"input": "1 200000\n200000\n", "output": "1\n", "type": "code"}]
|
ca3d9bba40ea3b2c17a4cfd70e37dc5a
|
code_stdio
|
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given a permutation $p_1, p_2, \\dots, p_n$. A permutation of length $n$ is a sequence such that each integer between $1$ and $n$ occurs exactly once in the sequence.\n\nFind the number of pairs of indices $(l, r)$ ($1 \\le l \\le r \\le n$) such that the value of the median of $p_l, p_{l+1}, \\dots, p_r$ is exactly the given number $m$.\n\nThe median of a sequence is the value of the element which is in the middle of the sequence after sorting it in non-decreasing order. If the length of the sequence is even, the left of two middle elements is used.\n\nFor example, if $a=[4, 2, 7, 5]$ then its median is $4$ since after sorting the sequence, it will look like $[2, 4, 5, 7]$ and the left of two middle elements is equal to $4$. The median of $[7, 1, 2, 9, 6]$ equals $6$ since after sorting, the value $6$ will be in the middle of the sequence.\n\nWrite a program to find the number of pairs of indices $(l, r)$ ($1 \\le l \\le r \\le n$) such that the value of the median of $p_l, p_{l+1}, \\dots, p_r$ is exactly the given number $m$.\n\n\n-----Input-----\n\nThe first line contains integers $n$ and $m$ ($1 \\le n \\le 2\\cdot10^5$, $1 \\le m \\le n$) — the length of the given sequence and the required value of the median.\n\nThe second line contains a permutation $p_1, p_2, \\dots, p_n$ ($1 \\le p_i \\le n$). Each integer between $1$ and $n$ occurs in $p$ exactly once.\n\n\n-----Output-----\n\nPrint the required number.\n\n\n-----Examples-----\nInput\n5 4\n2 4 5 3 1\n\nOutput\n4\n\nInput\n5 5\n1 2 3 4 5\n\nOutput\n1\n\nInput\n15 8\n1 15 2 14 3 13 4 8 12 5 11 6 10 7 9\n\nOutput\n48\n\n\n\n-----Note-----\n\nIn the first example, the suitable pairs of indices are: $(1, 3)$, $(2, 2)$, $(2, 3)$ and $(2, 4)$.\n\nThe input will be stdin and you should print your solution to stdout\n\n\nNow solve the problem and return the code.",
"role": "user"
}
] |
[{"input": "5 4\n2 4 5 3 1\n", "output": "4\n", "type": "code"}, {"input": "5 5\n1 2 3 4 5\n", "output": "1\n", "type": "code"}, {"input": "15 8\n1 15 2 14 3 13 4 8 12 5 11 6 10 7 9\n", "output": "48\n", "type": "code"}, {"input": "1 1\n1\n", "output": "1\n", "type": "code"}, {"input": "2 1\n1 2\n", "output": "2\n", "type": "code"}, {"input": "2 1\n2 1\n", "output": "2\n", "type": "code"}, {"input": "2 2\n1 2\n", "output": "1\n", "type": "code"}, {"input": "2 2\n2 1\n", "output": "1\n", "type": "code"}, {"input": "3 1\n1 2 3\n", "output": "2\n", "type": "code"}, {"input": "3 1\n1 3 2\n", "output": "2\n", "type": "code"}, {"input": "3 1\n2 1 3\n", "output": "3\n", "type": "code"}, {"input": "3 1\n2 3 1\n", "output": "2\n", "type": "code"}, {"input": "3 1\n3 1 2\n", "output": "3\n", "type": "code"}, {"input": "3 1\n3 2 1\n", "output": "2\n", "type": "code"}, {"input": "5 2\n2 1 3 4 5\n", "output": "3\n", "type": "code"}, {"input": "6 3\n3 6 1 4 2 5\n", "output": "6\n", "type": "code"}, {"input": "7 4\n1 7 6 4 2 3 5\n", "output": "10\n", "type": "code"}, {"input": "8 7\n2 3 6 8 7 5 4 1\n", "output": "4\n", "type": "code"}, {"input": "9 9\n6 4 8 5 1 7 2 9 3\n", "output": "1\n", "type": "code"}, {"input": "10 1\n6 9 8 10 4 3 7 1 5 2\n", "output": "3\n", "type": "code"}, {"input": "11 2\n9 4 7 5 11 1 3 8 10 2 6\n", "output": "3\n", "type": "code"}, {"input": "12 3\n6 4 3 7 8 10 1 2 11 5 12 9\n", "output": "4\n", "type": "code"}, {"input": "14 5\n13 14 5 11 3 2 10 8 12 9 6 1 7 4\n", "output": "10\n", "type": "code"}, {"input": "100 1\n78 52 95 76 96 49 53 59 77 100 64 11 9 48 15 17 44 46 21 54 39 68 43 4 32 28 73 6 16 62 72 84 65 86 98 75 33 45 25 3 91 82 2 92 63 88 7 50 97 93 14 22 20 42 60 55 80 85 29 34 56 71 83 38 26 47 90 70 51 41 40 31 37 12 35 99 67 94 1 87 57 8 61 19 23 79 36 18 66 74 5 27 81 69 24 58 13 10 89 30\n", "output": "3\n", "type": "code"}, {"input": "100 50\n2 4 82 12 47 63 52 91 87 45 53 1 17 25 64 50 9 13 22 54 21 30 43 24 38 33 68 11 41 78 99 23 28 18 58 67 79 10 71 56 49 61 26 29 59 20 90 74 5 75 89 8 39 95 72 42 66 98 44 32 88 35 92 3 97 55 65 51 77 27 81 76 84 69 73 85 19 46 62 100 60 37 7 36 57 6 14 83 40 48 16 70 96 15 31 93 80 86 94 34\n", "output": "182\n", "type": "code"}, {"input": "100 100\n70 54 10 72 81 84 56 15 27 19 43 100 49 44 52 33 63 40 95 17 58 2 51 39 22 18 82 1 16 99 32 29 24 94 9 98 5 37 47 14 42 73 41 31 79 64 12 6 53 26 68 67 89 13 90 4 21 93 46 74 75 88 66 57 23 7 25 48 92 62 30 8 50 61 38 87 71 34 97 28 80 11 60 91 3 35 86 96 36 20 59 65 83 45 76 77 78 69 85 55\n", "output": "1\n", "type": "code"}]
|
d5d753fc449988807bedee39b05ca89f
|
code_stdio
|
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere are two sisters Alice and Betty. You have $n$ candies. You want to distribute these $n$ candies between two sisters in such a way that: Alice will get $a$ ($a > 0$) candies; Betty will get $b$ ($b > 0$) candies; each sister will get some integer number of candies; Alice will get a greater amount of candies than Betty (i.e. $a > b$); all the candies will be given to one of two sisters (i.e. $a+b=n$). \n\nYour task is to calculate the number of ways to distribute exactly $n$ candies between sisters in a way described above. Candies are indistinguishable.\n\nFormally, find the number of ways to represent $n$ as the sum of $n=a+b$, where $a$ and $b$ are positive integers and $a>b$.\n\nYou have to answer $t$ independent test cases.\n\n\n-----Input-----\n\nThe first line of the input contains one integer $t$ ($1 \\le t \\le 10^4$) — the number of test cases. Then $t$ test cases follow.\n\nThe only line of a test case contains one integer $n$ ($1 \\le n \\le 2 \\cdot 10^9$) — the number of candies you have.\n\n\n-----Output-----\n\nFor each test case, print the answer — the number of ways to distribute exactly $n$ candies between two sisters in a way described in the problem statement. If there is no way to satisfy all the conditions, print $0$.\n\n\n-----Example-----\nInput\n6\n7\n1\n2\n3\n2000000000\n763243547\n\nOutput\n3\n0\n0\n1\n999999999\n381621773\n\n\n\n-----Note-----\n\nFor the test case of the example, the $3$ possible ways to distribute candies are: $a=6$, $b=1$; $a=5$, $b=2$; $a=4$, $b=3$.\n\nThe input will be stdin and you should print your solution to stdout\n\n\nNow solve the problem and return the code.",
"role": "user"
}
] |
[{"input": "6\n7\n1\n2\n3\n2000000000\n763243547\n", "output": "3\n0\n0\n1\n999999999\n381621773\n", "type": "code"}, {"input": "2\n1\n2\n", "output": "0\n0\n", "type": "code"}, {"input": "1\n108139\n", "output": "54069\n", "type": "code"}, {"input": "5\n1\n1\n1\n1\n1\n", "output": "0\n0\n0\n0\n0\n", "type": "code"}, {"input": "39\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n", "output": "0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\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", "type": "code"}, {"input": "1\n121112422\n", "output": "60556210\n", "type": "code"}, {"input": "1\n1411\n", "output": "705\n", "type": "code"}, {"input": "39\n2\n3\n5\n7\n9\n8\n6\n5\n4\n4\n9\n4\n5\n6\n8\n1\n5\n4\n3\n10\n7\n1\n1\n4\n3\n5\n6\n2\n5\n9\n9\n6\n6\n4\n5\n3\n10\n10\n1\n", "output": "0\n1\n2\n3\n4\n3\n2\n2\n1\n1\n4\n1\n2\n2\n3\n0\n2\n1\n1\n4\n3\n0\n0\n1\n1\n2\n2\n0\n2\n4\n4\n2\n2\n1\n2\n1\n4\n4\n0\n", "type": "code"}, {"input": "39\n7\n1\n2\n3\n2000000000\n763243547\n7\n1\n2\n3\n2000000000\n763243547\n7\n1\n2\n3\n2000000000\n763243547\n7\n1\n2\n3\n2000000000\n763243547\n7\n1\n2\n3\n2000000000\n763243547\n7\n1\n2\n3\n2000000000\n763243547\n7\n1\n2\n", "output": "3\n0\n0\n1\n999999999\n381621773\n3\n0\n0\n1\n999999999\n381621773\n3\n0\n0\n1\n999999999\n381621773\n3\n0\n0\n1\n999999999\n381621773\n3\n0\n0\n1\n999999999\n381621773\n3\n0\n0\n1\n999999999\n381621773\n3\n0\n0\n", "type": "code"}, {"input": "39\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n31\n32\n32\n34\n35\n36\n37\n35\n39\n", "output": "0\n0\n1\n1\n2\n2\n3\n3\n4\n4\n5\n5\n6\n6\n7\n7\n8\n8\n9\n9\n10\n10\n11\n11\n12\n12\n13\n13\n14\n14\n15\n15\n15\n16\n17\n17\n18\n17\n19\n", "type": "code"}, {"input": "98\n710\n896\n635\n909\n528\n799\n184\n970\n731\n285\n481\n62\n829\n815\n204\n927\n48\n958\n858\n549\n722\n900\n290\n96\n414\n323\n488\n140\n494\n286\n783\n551\n896\n580\n724\n766\n841\n914\n200\n170\n384\n664\n14\n203\n582\n203\n678\n502\n677\n318\n189\n144\n97\n330\n169\n20\n492\n233\n198\n876\n697\n624\n877\n514\n828\n41\n575\n959\n499\n786\n621\n878\n547\n409\n194\n59\n657\n893\n230\n559\n170\n238\n752\n854\n385\n365\n415\n505\n584\n434\n135\n136\n610\n525\n945\n889\n941\n579\n", "output": "354\n447\n317\n454\n263\n399\n91\n484\n365\n142\n240\n30\n414\n407\n101\n463\n23\n478\n428\n274\n360\n449\n144\n47\n206\n161\n243\n69\n246\n142\n391\n275\n447\n289\n361\n382\n420\n456\n99\n84\n191\n331\n6\n101\n290\n101\n338\n250\n338\n158\n94\n71\n48\n164\n84\n9\n245\n116\n98\n437\n348\n311\n438\n256\n413\n20\n287\n479\n249\n392\n310\n438\n273\n204\n96\n29\n328\n446\n114\n279\n84\n118\n375\n426\n192\n182\n207\n252\n291\n216\n67\n67\n304\n262\n472\n444\n470\n289\n", "type": "code"}, {"input": "3\n1\n1\n1\n", "output": "0\n0\n0\n", "type": "code"}, {"input": "1\n10\n", "output": "4\n", "type": "code"}, {"input": "7\n1\n7\n1\n2\n3\n2000000000\n763243547\n", "output": "0\n3\n0\n0\n1\n999999999\n381621773\n", "type": "code"}, {"input": "3\n3\n4\n5\n", "output": "1\n1\n2\n", "type": "code"}, {"input": "31\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n31\n", "output": "0\n0\n1\n1\n2\n2\n3\n3\n4\n4\n5\n5\n6\n6\n7\n7\n8\n8\n9\n9\n10\n10\n11\n11\n12\n12\n13\n13\n14\n14\n15\n", "type": "code"}, {"input": "1\n54334\n", "output": "27166\n", "type": "code"}, {"input": "1\n54332\n", "output": "27165\n", "type": "code"}, {"input": "1\n54331\n", "output": "27165\n", "type": "code"}, {"input": "1\n54335\n", "output": "27167\n", "type": "code"}, {"input": "1\n54330\n", "output": "27164\n", "type": "code"}]
|
6030a2a7ba30edca9b0aac86ee36da0f
|
code_stdio
|
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere are n persons who initially don't know each other. On each morning, two of them, who were not friends before, become friends.\n\nWe want to plan a trip for every evening of m days. On each trip, you have to select a group of people that will go on the trip. For every person, one of the following should hold: \n\n * Either this person does not go on the trip, \n * Or at least k of his friends also go on the trip. \n\n\n\nNote that the friendship is not transitive. That is, if a and b are friends and b and c are friends, it does not necessarily imply that a and c are friends.\n\nFor each day, find the maximum number of people that can go on the trip on that day.\n\nInput\n\nThe first line contains three integers n, m, and k (2 ≤ n ≤ 2 ⋅ 10^5, 1 ≤ m ≤ 2 ⋅ 10^5, 1 ≤ k < n) — the number of people, the number of days and the number of friends each person on the trip should have in the group.\n\nThe i-th (1 ≤ i ≤ m) of the next m lines contains two integers x and y (1≤ x, y≤ n, x≠ y), meaning that persons x and y become friends on the morning of day i. It is guaranteed that x and y were not friends before.\n\nOutput\n\nPrint exactly m lines, where the i-th of them (1≤ i≤ m) contains the maximum number of people that can go on the trip on the evening of the day i.\n\nExamples\n\nInput\n\n4 4 2\n2 3\n1 2\n1 3\n1 4\n\n\nOutput\n\n0\n0\n3\n3\n\n\nInput\n\n5 8 2\n2 1\n4 2\n5 4\n5 2\n4 3\n5 1\n4 1\n3 2\n\n\nOutput\n\n0\n0\n0\n3\n3\n4\n4\n5\n\n\nInput\n\n5 7 2\n1 5\n3 2\n2 5\n3 4\n1 2\n5 3\n1 3\n\n\nOutput\n\n0\n0\n0\n0\n3\n4\n4\n\nNote\n\nIn the first example, \n\n * 1,2,3 can go on day 3 and 4. \n\n\n\nIn the second example, \n\n * 2,4,5 can go on day 4 and 5. \n * 1,2,4,5 can go on day 6 and 7. \n * 1,2,3,4,5 can go on day 8. \n\n\n\nIn the third example, \n\n * 1,2,5 can go on day 5. \n * 1,2,3,5 can go on day 6 and 7. \n\nThe input will be given via stdin and the output should be printed to stdout by your code.\n\nNow solve the problem by providing the code.",
"role": "user"
}
] |
[{"input": "4 4 2\n2 3\n1 2\n1 3\n1 4\n", "output": "0\n0\n3\n3\n", "type": "code"}, {"input": "5 8 2\n2 1\n4 2\n5 4\n5 2\n4 3\n5 1\n4 1\n3 2\n", "output": "0\n0\n0\n3\n3\n4\n4\n5\n", "type": "code"}, {"input": "5 7 2\n1 5\n3 2\n2 5\n3 4\n1 2\n5 3\n1 3\n", "output": "0\n0\n0\n0\n3\n4\n4\n", "type": "code"}, {"input": "16 20 2\n10 3\n5 3\n10 5\n12 7\n7 6\n9 12\n9 6\n1 10\n11 16\n11 1\n16 2\n10 2\n14 4\n15 14\n4 13\n13 15\n1 8\n7 15\n1 7\n8 15\n", "output": "0\n0\n3\n3\n3\n3\n7\n7\n7\n7\n7\n11\n11\n11\n11\n15\n15\n15\n15\n16\n", "type": "code"}, {"input": "2 1 1\n2 1\n", "output": "2\n", "type": "code"}, {"input": "16 20 2\n10 3\n5 3\n10 5\n12 7\n7 6\n9 10\n9 6\n1 10\n11 16\n11 1\n16 2\n10 2\n14 4\n15 14\n4 13\n13 15\n1 8\n7 15\n1 7\n8 15\n", "output": "0\n0\n3\n3\n3\n3\n3\n3\n3\n3\n3\n7\n7\n7\n7\n11\n11\n14\n14\n15\n", "type": "code"}, {"input": "16 20 2\n10 3\n5 3\n10 5\n12 7\n7 6\n9 10\n2 6\n1 10\n11 16\n11 1\n16 2\n10 2\n14 4\n15 14\n4 13\n13 15\n1 8\n7 15\n1 7\n8 15\n", "output": "0\n0\n3\n3\n3\n3\n3\n3\n3\n3\n3\n7\n7\n7\n7\n11\n11\n13\n13\n14\n", "type": "code"}, {"input": "16 20 2\n10 4\n5 3\n10 5\n12 7\n7 6\n9 12\n9 6\n1 10\n11 16\n11 1\n16 2\n10 2\n14 4\n15 14\n4 13\n13 15\n1 8\n7 15\n1 7\n8 15\n", "output": "0\n0\n0\n0\n0\n0\n4\n4\n4\n4\n4\n9\n9\n9\n9\n13\n13\n13\n13\n14\n", "type": "code"}, {"input": "9 8 2\n2 1\n4 2\n5 4\n5 2\n4 3\n5 1\n4 1\n3 2\n", "output": "0\n0\n0\n3\n3\n4\n4\n5\n", "type": "code"}, {"input": "16 20 2\n10 3\n5 3\n10 5\n12 7\n7 6\n9 10\n2 6\n1 10\n11 16\n11 1\n16 2\n10 2\n14 4\n15 14\n4 3\n13 15\n1 8\n7 15\n1 7\n8 15\n", "output": "0\n0\n3\n3\n3\n3\n3\n3\n3\n3\n3\n7\n7\n7\n7\n7\n7\n12\n12\n13\n", "type": "code"}, {"input": "2 1 2\n2 1\n", "output": "0\n", "type": "code"}, {"input": "16 20 2\n10 3\n5 3\n10 5\n12 7\n7 6\n9 10\n2 6\n1 10\n11 16\n11 1\n16 2\n10 2\n14 4\n15 14\n3 13\n13 15\n1 8\n7 15\n1 7\n8 15\n", "output": "0\n0\n3\n3\n3\n3\n3\n3\n3\n3\n3\n7\n7\n7\n7\n7\n7\n11\n11\n12\n", "type": "code"}, {"input": "16 20 2\n10 4\n5 3\n10 5\n12 7\n7 6\n9 12\n9 6\n1 10\n11 16\n11 1\n16 3\n10 2\n14 4\n15 14\n4 13\n13 15\n1 8\n7 15\n1 7\n8 15\n", "output": "0\n0\n0\n0\n0\n0\n4\n4\n4\n4\n10\n10\n10\n10\n10\n14\n14\n14\n14\n15\n", "type": "code"}, {"input": "16 20 2\n10 3\n5 3\n10 5\n12 7\n7 6\n9 10\n2 6\n1 10\n11 16\n11 1\n16 2\n10 2\n14 4\n15 14\n4 3\n13 15\n1 14\n7 15\n1 7\n8 15\n", "output": "0\n0\n3\n3\n3\n3\n3\n3\n3\n3\n3\n7\n7\n7\n7\n7\n9\n12\n12\n12\n", "type": "code"}, {"input": "16 20 2\n10 3\n5 3\n10 5\n12 7\n7 6\n9 10\n2 6\n1 10\n11 16\n11 1\n16 2\n10 2\n14 4\n15 14\n3 13\n1 15\n1 8\n7 15\n1 7\n8 15\n", "output": "0\n0\n3\n3\n3\n3\n3\n3\n3\n3\n3\n7\n7\n7\n7\n7\n7\n10\n10\n11\n", "type": "code"}, {"input": "16 20 2\n10 3\n5 3\n11 5\n12 7\n7 6\n9 10\n2 6\n1 10\n11 16\n11 1\n16 2\n10 2\n14 4\n15 14\n4 3\n13 15\n1 14\n7 15\n1 7\n8 15\n", "output": "0\n0\n0\n0\n0\n0\n0\n0\n0\n5\n5\n7\n7\n7\n7\n7\n9\n12\n12\n12\n", "type": "code"}, {"input": "27 20 2\n10 3\n5 3\n20 5\n12 7\n7 6\n9 10\n2 6\n1 10\n11 16\n11 1\n16 2\n10 2\n14 4\n15 14\n3 13\n1 15\n1 8\n7 15\n1 7\n8 15\n", "output": "0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n5\n5\n5\n5\n5\n5\n8\n8\n9\n", "type": "code"}, {"input": "27 20 3\n10 3\n5 1\n20 5\n12 7\n7 6\n9 10\n2 6\n1 10\n11 16\n11 1\n16 2\n10 2\n14 4\n15 14\n3 13\n1 15\n1 8\n7 15\n1 7\n8 15\n", "output": "0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n", "type": "code"}, {"input": "16 20 2\n10 3\n5 3\n10 5\n12 3\n7 6\n9 12\n9 6\n1 10\n11 16\n11 1\n16 2\n10 2\n14 4\n15 14\n4 13\n13 15\n1 8\n7 15\n1 7\n8 15\n", "output": "0\n0\n3\n3\n3\n3\n3\n3\n3\n3\n3\n7\n7\n7\n7\n11\n11\n15\n15\n16\n", "type": "code"}, {"input": "9 7 2\n1 5\n3 2\n2 5\n3 4\n1 2\n5 3\n1 3\n", "output": "0\n0\n0\n0\n3\n4\n4\n", "type": "code"}, {"input": "16 20 2\n10 3\n5 3\n10 5\n12 7\n7 6\n9 10\n2 6\n1 10\n11 16\n11 2\n16 2\n10 2\n14 4\n15 14\n4 13\n13 15\n1 8\n7 15\n1 7\n8 15\n", "output": "0\n0\n3\n3\n3\n3\n3\n3\n3\n3\n6\n6\n6\n6\n6\n10\n10\n12\n13\n14\n", "type": "code"}, {"input": "16 20 2\n10 4\n5 3\n10 5\n12 7\n7 6\n9 12\n9 6\n1 10\n11 16\n11 1\n16 2\n10 2\n14 4\n15 14\n4 12\n13 15\n1 8\n7 15\n1 7\n8 15\n", "output": "0\n0\n0\n0\n0\n0\n4\n4\n4\n4\n4\n9\n9\n9\n10\n10\n10\n12\n12\n13\n", "type": "code"}, {"input": "16 20 2\n10 4\n5 3\n10 5\n12 7\n7 6\n9 12\n9 6\n1 10\n11 16\n11 1\n9 3\n10 2\n14 4\n15 14\n4 13\n13 15\n1 8\n7 15\n1 7\n8 15\n", "output": "0\n0\n0\n0\n0\n0\n4\n4\n4\n4\n4\n4\n4\n4\n4\n11\n11\n11\n12\n13\n", "type": "code"}, {"input": "16 20 2\n10 3\n5 3\n13 5\n12 7\n7 6\n9 10\n2 6\n1 10\n11 16\n11 1\n16 2\n10 2\n14 4\n15 14\n4 3\n13 15\n1 14\n7 15\n1 7\n8 15\n", "output": "0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n5\n5\n5\n5\n11\n11\n13\n13\n13\n", "type": "code"}, {"input": "16 20 2\n10 3\n5 3\n10 5\n12 7\n7 6\n9 10\n2 5\n1 10\n11 16\n11 1\n16 2\n10 2\n14 4\n15 14\n3 13\n1 15\n1 8\n7 15\n1 7\n8 15\n", "output": "0\n0\n3\n3\n3\n3\n3\n3\n3\n3\n7\n7\n7\n7\n7\n7\n7\n7\n9\n10\n", "type": "code"}, {"input": "16 20 2\n10 4\n5 3\n10 5\n12 7\n7 6\n9 12\n9 6\n1 10\n11 16\n11 1\n16 3\n10 3\n14 4\n15 14\n4 13\n13 3\n1 8\n7 15\n1 7\n8 15\n", "output": "0\n0\n0\n0\n0\n0\n4\n4\n4\n4\n10\n10\n10\n10\n10\n12\n12\n14\n14\n15\n", "type": "code"}, {"input": "16 20 2\n10 3\n5 3\n11 9\n12 7\n7 6\n9 10\n2 6\n1 10\n11 16\n11 1\n16 2\n10 2\n14 4\n15 14\n4 3\n13 15\n1 14\n7 15\n1 7\n8 15\n", "output": "0\n0\n0\n0\n0\n0\n0\n0\n0\n4\n4\n6\n6\n6\n6\n6\n9\n12\n12\n12\n", "type": "code"}, {"input": "9 7 2\n1 5\n4 2\n2 5\n3 4\n1 2\n5 3\n1 3\n", "output": "0\n0\n0\n0\n3\n5\n5\n", "type": "code"}, {"input": "16 20 2\n10 4\n5 3\n10 5\n12 7\n7 6\n9 12\n9 6\n1 10\n11 16\n11 1\n16 2\n10 2\n14 4\n15 14\n6 12\n13 15\n1 8\n7 15\n1 7\n8 15\n", "output": "0\n0\n0\n0\n0\n0\n4\n4\n4\n4\n4\n9\n9\n9\n9\n9\n9\n12\n12\n13\n", "type": "code"}, {"input": "16 20 2\n10 3\n5 3\n11 9\n12 7\n7 6\n9 10\n2 6\n1 10\n11 16\n11 1\n16 2\n10 2\n14 4\n15 14\n4 3\n13 15\n1 14\n3 15\n1 7\n8 15\n", "output": "0\n0\n0\n0\n0\n0\n0\n0\n0\n4\n4\n6\n6\n6\n6\n6\n9\n10\n12\n12\n", "type": "code"}, {"input": "9 8 2\n2 1\n4 2\n5 4\n5 2\n4 3\n5 1\n7 1\n3 2\n", "output": "0\n0\n0\n3\n3\n4\n4\n5\n", "type": "code"}, {"input": "16 20 2\n10 4\n5 3\n10 5\n12 7\n7 6\n9 12\n9 6\n1 10\n11 16\n11 1\n16 3\n10 3\n14 4\n15 14\n4 13\n13 15\n1 8\n7 15\n1 7\n8 15\n", "output": "0\n0\n0\n0\n0\n0\n4\n4\n4\n4\n10\n10\n10\n10\n10\n14\n14\n14\n14\n15\n", "type": "code"}, {"input": "27 20 2\n10 3\n5 3\n10 5\n12 7\n7 6\n9 10\n2 6\n1 10\n11 16\n11 1\n16 2\n10 2\n14 4\n15 14\n3 13\n1 15\n1 8\n7 15\n1 7\n8 15\n", "output": "0\n0\n3\n3\n3\n3\n3\n3\n3\n3\n3\n7\n7\n7\n7\n7\n7\n10\n10\n11\n", "type": "code"}, {"input": "27 20 2\n10 3\n5 1\n20 5\n12 7\n7 6\n9 10\n2 6\n1 10\n11 16\n11 1\n16 2\n10 2\n14 4\n15 14\n3 13\n1 15\n1 8\n7 15\n1 7\n8 15\n", "output": "0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n5\n5\n5\n5\n5\n5\n8\n8\n9\n", "type": "code"}, {"input": "27 20 3\n10 3\n5 1\n20 5\n12 7\n7 6\n12 10\n2 6\n1 10\n11 16\n11 1\n16 2\n10 2\n14 4\n15 14\n3 13\n1 15\n1 8\n7 15\n1 7\n8 15\n", "output": "0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n", "type": "code"}, {"input": "27 20 3\n10 3\n5 1\n20 5\n12 5\n7 6\n12 10\n2 6\n1 10\n11 16\n11 1\n16 2\n10 2\n14 4\n15 14\n3 13\n1 15\n1 8\n7 15\n1 7\n8 15\n", "output": "0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n", "type": "code"}, {"input": "27 20 3\n10 3\n5 1\n20 5\n12 5\n7 6\n12 10\n2 6\n1 10\n11 16\n11 1\n16 4\n10 2\n14 4\n15 14\n3 13\n1 15\n1 8\n7 15\n1 7\n8 15\n", "output": "0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n", "type": "code"}, {"input": "27 20 3\n10 3\n5 1\n20 5\n12 5\n13 6\n12 10\n2 6\n1 10\n11 16\n11 1\n16 4\n10 2\n14 4\n15 14\n3 13\n1 15\n1 8\n7 15\n1 7\n8 15\n", "output": "0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n", "type": "code"}, {"input": "27 20 3\n10 3\n5 1\n20 5\n12 5\n13 6\n12 10\n2 6\n1 10\n11 16\n11 1\n16 4\n3 2\n14 4\n15 14\n3 13\n1 15\n1 8\n7 15\n1 7\n8 15\n", "output": "0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n", "type": "code"}, {"input": "2 1 3\n2 1\n", "output": "0\n", "type": "code"}, {"input": "27 20 2\n10 3\n5 3\n10 5\n12 7\n7 6\n9 10\n2 6\n1 10\n11 16\n11 1\n16 2\n10 2\n14 4\n19 14\n3 13\n1 15\n1 8\n7 15\n1 7\n8 15\n", "output": "0\n0\n3\n3\n3\n3\n3\n3\n3\n3\n3\n7\n7\n7\n7\n7\n7\n10\n10\n11\n", "type": "code"}, {"input": "27 20 2\n10 3\n5 3\n20 5\n12 7\n7 6\n9 10\n2 6\n1 10\n11 16\n11 1\n16 2\n10 2\n14 4\n15 23\n3 13\n1 15\n1 8\n7 15\n1 7\n8 15\n", "output": "0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n5\n5\n5\n5\n5\n5\n8\n8\n9\n", "type": "code"}, {"input": "27 20 2\n10 3\n5 1\n20 5\n12 7\n7 6\n9 10\n2 6\n1 10\n11 16\n11 1\n16 2\n10 2\n14 4\n15 14\n3 13\n1 15\n1 8\n7 15\n1 7\n8 16\n", "output": "0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n5\n5\n5\n5\n5\n5\n8\n8\n9\n", "type": "code"}, {"input": "27 20 3\n10 3\n5 1\n20 2\n12 7\n7 6\n9 10\n2 6\n1 10\n11 16\n11 1\n16 2\n10 2\n14 4\n15 14\n3 13\n1 15\n1 8\n7 15\n1 7\n8 15\n", "output": "0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n", "type": "code"}, {"input": "27 20 3\n10 3\n5 1\n20 5\n12 7\n7 6\n12 10\n2 6\n1 10\n11 16\n11 1\n16 2\n10 2\n25 4\n15 14\n3 13\n1 15\n1 8\n7 15\n1 7\n8 15\n", "output": "0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n", "type": "code"}, {"input": "27 20 3\n10 3\n5 1\n20 7\n12 5\n7 6\n12 10\n2 6\n1 10\n11 16\n11 1\n16 2\n10 2\n14 4\n15 14\n3 13\n1 15\n1 8\n7 15\n1 7\n8 15\n", "output": "0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n", "type": "code"}, {"input": "27 20 3\n10 3\n5 1\n20 5\n12 5\n13 6\n12 10\n2 6\n1 10\n11 16\n11 1\n16 4\n10 2\n14 4\n15 24\n3 13\n1 15\n1 8\n7 15\n1 7\n8 15\n", "output": "0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n", "type": "code"}, {"input": "27 20 3\n10 3\n5 1\n20 5\n12 5\n13 6\n12 10\n3 6\n1 10\n11 16\n11 1\n16 4\n3 2\n14 4\n15 14\n3 13\n1 15\n1 8\n7 15\n1 7\n8 15\n", "output": "0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n", "type": "code"}, {"input": "16 20 2\n10 3\n5 3\n13 5\n12 7\n7 6\n9 10\n2 6\n1 10\n11 16\n11 1\n16 2\n10 2\n14 4\n15 14\n4 3\n13 15\n2 14\n7 15\n1 7\n8 15\n", "output": "0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n5\n5\n5\n5\n11\n11\n13\n13\n13\n", "type": "code"}, {"input": "16 20 2\n10 4\n5 3\n10 5\n12 7\n7 6\n9 12\n9 6\n1 10\n11 16\n11 1\n16 3\n10 3\n14 4\n15 14\n4 13\n13 3\n1 8\n7 15\n2 7\n8 15\n", "output": "0\n0\n0\n0\n0\n0\n4\n4\n4\n4\n10\n10\n10\n10\n10\n12\n12\n14\n14\n15\n", "type": "code"}]
|
550450240449db4654469cafa0a52b16
|
code_stdio
|
[
{
"content": "Solve the following coding problem using the programming language python:\n\nXenia the beginner mathematician is a third year student at elementary school. She is now learning the addition operation.\n\nThe teacher has written down the sum of multiple numbers. Pupils should calculate the sum. To make the calculation easier, the sum only contains numbers 1, 2 and 3. Still, that isn't enough for Xenia. She is only beginning to count, so she can calculate a sum only if the summands follow in non-decreasing order. For example, she can't calculate sum 1+3+2+1 but she can calculate sums 1+1+2 and 3+3.\n\nYou've got the sum that was written on the board. Rearrange the summans and print the sum in such a way that Xenia can calculate the sum.\n\nInput\n\nThe first line contains a non-empty string s — the sum Xenia needs to count. String s contains no spaces. It only contains digits and characters \"+\". Besides, string s is a correct sum of numbers 1, 2 and 3. String s is at most 100 characters long.\n\nOutput\n\nPrint the new sum that Xenia can count.\n\nExamples\n\nInput\n\n3+2+1\n\n\nOutput\n\n1+2+3\n\n\nInput\n\n1+1+3+1+3\n\n\nOutput\n\n1+1+1+3+3\n\n\nInput\n\n2\n\n\nOutput\n\n2\n\nThe input will be given via stdin and the output should be printed to stdout by your code.\n\nNow solve the problem by providing the code.",
"role": "user"
}
] |
[{"input": "2\n", "output": "2\n", "type": "code"}, {"input": "3+2+1\n", "output": "1+2+3\n", "type": "code"}, {"input": "1+1+3+1+3\n", "output": "1+1+1+3+3\n", "type": "code"}, {"input": "2+2+1+1+3\n", "output": "1+1+2+2+3\n", "type": "code"}, {"input": "3+1\n", "output": "1+3\n", "type": "code"}, {"input": "1+3\n", "output": "1+3\n", "type": "code"}, {"input": "2+2+1+1+1+3+1+1+3+3+2+3+1+3+1+1+3+1+1+2+2+2+2+1+2+1+2+1+1+1+3+1+3+2+3+2+3+3+1+1+1+2+3+2+1+3+1+3+2+2\n", "output": "1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "2+2\n", "output": "2+2\n", "type": "code"}, {"input": "1+1\n", "output": "1+1\n", "type": "code"}, {"input": "2+3+3+1+2+2+2+1+1+2+1+3+2+2+3+3+2+2+3+3+3+1+1+1+3+3+3+2+1+3+2+3+2+1+1+3+3+3+1+2+2+1+2+2+1+2+1+3+1+1\n", "output": "1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "1\n", "output": "1\n", "type": "code"}, {"input": "1+2+1+2+2+2+2+1+3+3\n", "output": "1+1+1+2+2+2+2+2+3+3\n", "type": "code"}, {"input": "2+3\n", "output": "2+3\n", "type": "code"}, {"input": "1+2\n", "output": "1+2\n", "type": "code"}, {"input": "3+2\n", "output": "2+3\n", "type": "code"}, {"input": "3+3\n", "output": "3+3\n", "type": "code"}, {"input": "2+1+2+2+1+3+2+3+1+1+2+1+2+2+3+1+1+3+3+3+2+2+3+2+2+2+1+2+1+2+3+2+2+2+1+3+1+3+3+3+1+2+1+2+2+2+2+3+1+1\n", "output": "1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "2+1+2+2+2+3+1+3+1+2\n", "output": "1+1+1+2+2+2+2+2+3+3\n", "type": "code"}, {"input": "2+1\n", "output": "1+2\n", "type": "code"}, {"input": "3+2+3+3+2+2+1+2+1+2+3+1+2+3+2+3+2+1+2+2+1+1+2+2+3+2+1+3+1+1+3+2+2+2+2+3+3+2+2+3+3+1+1+2+3+3+2+3+3+3\n", "output": "1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "3\n", "output": "3\n", "type": "code"}, {"input": "1+1+3+1+2+1+2+2+1+2+2+1+3+3+3+1+1+2+3+2+3+1+2+3+3+3+1+1+1+3+3+3+2+2+3+3+2+2+3+1+2+1+1+2+2+2+1+3+3+2\n", "output": "1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "2+1+2+2+1+3+2+3+1+1+2+1+2+2+3+1+1+3+3+3+2+2+3+2+2+2+1+2+1+2+1+2+2+2+1+3+1+3+3+3+1+2+1+2+2+2+2+3+3+1\n", "output": "1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "3+2+3+3+2+2+1+2+1+2+3+1+2+3+2+3+2+1+2+2+1+1+2+2+3+2+1+3+1+1+3+3+2+2+2+3+3+2+2+3+3+1+1+2+3+3+2+3+3+3\n", "output": "1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "3+3+1\n", "output": "1+3+3\n", "type": "code"}, {"input": "3+1+3+1+1\n", "output": "1+1+1+3+3\n", "type": "code"}, {"input": "3+2+2+3+2+2+1+2+1+2+3+1+2+3+2+3+2+1+2+2+1+1+2+2+3+2+1+3+1+1+3+3+2+2+2+3+3+2+2+3+3+1+1+2+3+3+2+3+3+3\n", "output": "1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "3+2+2+3+2+2+1+2+1+2+3+1+2+3+2+3+2+1+2+2+1+1+2+2+3+2+1+3+1+1+3+3+2+2+2+3+3+2+2+3+2+1+1+2+3+3+2+3+3+3\n", "output": "1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "3+1+1+2+2\n", "output": "1+1+2+2+3\n", "type": "code"}, {"input": "2+2+1+1+1+3+1+1+3+3+2+3+1+3+1+1+3+1+1+2+2+2+2+1+2+1+2+1+1+1+3+1+3+2+3+3+3+3+1+1+1+2+3+2+1+3+1+3+2+2\n", "output": "1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "2+3+3+1+2+2+1+1+1+2+1+3+2+2+3+3+2+2+3+3+3+1+1+1+3+3+3+2+1+3+2+3+2+1+1+3+3+3+1+2+2+1+2+2+1+2+1+3+1+1\n", "output": "1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "2+1+3+1+3+2+2+2+1+2\n", "output": "1+1+1+2+2+2+2+2+3+3\n", "type": "code"}, {"input": "3+1+2+2+1+3+2+3+1+1+2+1+2+2+3+1+1+3+3+3+2+2+3+2+2+2+1+2+1+2+1+2+2+2+1+3+1+3+3+3+1+2+1+2+2+2+2+3+3+1\n", "output": "1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "2+2+2+1+3\n", "output": "1+2+2+2+3\n", "type": "code"}, {"input": "2+2+1+1+1+3+1+1+3+3+2+3+1+3+1+1+3+1+1+2+2+2+2+1+2+1+2+1+1+1+3+1+3+2+3+3+3+3+1+1+1+2+3+2+2+3+1+3+2+2\n", "output": "1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "1+1+3+1+2+1+1+2+1+2+2+1+3+3+3+1+1+2+3+2+3+1+2+3+3+3+1+1+1+3+3+3+2+2+3+3+2+2+3+1+2+1+1+1+2+2+1+3+3+2\n", "output": "1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "2+2+3+1+3+1+2+3+2+1+1+1+3+3+2+3+2+3+1+3+1+1+1+2+1+2+1+2+2+2+2+1+1+3+1+1+3+1+3+2+3+3+1+1+3+1+1+1+2+2\n", "output": "1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "1+2+3\n", "output": "1+2+3\n", "type": "code"}, {"input": "2+1+2+1+3+2+2+2+1+2\n", "output": "1+1+1+2+2+2+2+2+2+3\n", "type": "code"}, {"input": "2+3+3+2+3+3+3+1+1+2+3+2+2+3+3+2+2+2+3+3+1+1+3+1+2+3+2+2+1+1+2+2+1+2+3+2+3+2+1+3+3+2+2+1+2+2+3+2+2+3\n", "output": "1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "3+2+2+3+2+2+1+2+1+3+3+1+2+3+2+3+2+1+2+2+1+3+2+1+1+2+1+3+1+1+3+3+3+2+2+3+3+2+2+3+2+1+1+3+3+3+2+3+3+2\n", "output": "1+1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "3+2+2+3+2+2+1+2+1+2+3+1+2+3+2+3+2+1+2+2+1+1+3+2+2+2+1+3+1+1+3+3+2+2+2+3+3+2+2+3+2+1+1+2+3+3+2+3+3+2\n", "output": "1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "1+1+3+1+2+1+1+2+1+2+2+1+3+3+3+1+1+2+3+2+3+1+2+3+3+3+1+1+1+3+3+3+2+3+3+3+2+2+3+1+2+1+1+1+2+2+1+3+3+2\n", "output": "1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "3+2+2+3+2+2+1+2+1+3+3+1+2+3+2+3+2+1+2+2+1+3+2+1+1+2+1+3+1+1+3+3+2+2+2+3+3+2+2+3+2+1+1+3+3+3+2+3+3+2\n", "output": "1+1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "1+1+3+1+2+1+2+2+2+2+2+1+3+3+3+1+1+2+3+2+3+1+1+3+3+3+2+1+1+3+3+3+2+2+3+3+2+2+3+1+2+1+1+2+2+2+1+3+3+2\n", "output": "1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "1+1+3+1+2+1+2+2+1+2+2+1+3+3+3+1+1+2+3+2+3+1+2+3+2+3+1+1+1+3+3+3+2+2+3+3+2+2+3+1+2+1+1+2+2+2+1+3+3+2\n", "output": "1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "1+1+3+1+2+1+2+2+1+2+2+1+3+3+3+1+1+2+3+2+3+1+2+3+3+3+1+1+1+3+3+3+2+2+3+3+2+2+3+1+3+1+1+2+2+2+1+3+3+2\n", "output": "1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "2+3+3+2+3+3+3+1+1+2+3+2+2+3+3+2+2+2+3+3+2+1+3+1+2+3+2+2+1+1+2+2+1+2+3+2+3+2+1+3+3+2+2+1+2+2+3+2+2+3\n", "output": "1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "3+2+2+3+3+2+1+2+1+3+3+1+2+3+2+3+2+1+2+2+1+3+2+1+1+2+1+3+1+1+3+3+3+2+2+3+3+2+2+3+2+1+1+3+3+3+2+3+3+2\n", "output": "1+1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "3+2+2+3+2+2+1+2+1+3+3+1+2+3+2+3+2+1+2+2+1+3+2+1+1+2+1+3+1+1+3+3+2+2+2+3+2+2+2+3+2+1+1+3+3+3+2+3+3+2\n", "output": "1+1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "3+2+2+3+2+2+1+2+1+3+3+3+2+3+2+3+2+1+2+2+1+3+2+2+1+2+1+3+1+1+3+3+2+2+2+3+3+2+3+3+2+1+1+2+3+3+2+3+3+2\n", "output": "1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "3+3+3+2+3+3+3+1+1+2+3+2+2+3+3+2+2+2+3+3+2+1+3+1+2+3+2+2+1+1+2+2+1+2+3+2+3+2+1+3+3+2+2+1+2+2+3+2+2+3\n", "output": "1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "3+2+3+3+3+2+1+2+1+3+3+1+2+3+2+3+2+1+2+2+1+3+2+1+1+2+1+3+1+1+3+3+3+2+2+3+3+2+2+3+2+1+1+3+3+3+2+3+3+2\n", "output": "1+1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "3+3+3+2+3+3+3+1+1+2+3+2+2+3+3+2+2+2+3+3+2+1+3+2+2+3+2+2+1+1+2+2+1+2+3+2+3+2+1+3+3+2+2+1+2+2+3+2+2+3\n", "output": "1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "3+2+2+3+2+2+1+2+1+3+3+1+2+3+2+3+2+1+2+2+1+1+2+2+3+2+1+3+1+1+3+3+2+2+2+3+3+2+2+3+2+1+1+2+3+3+2+3+3+2\n", "output": "1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "1+1+3+1+2+1+2+2+1+2+2+1+3+3+3+1+1+2+3+2+3+1+1+3+3+3+1+1+1+3+3+3+2+2+3+3+2+2+3+1+2+1+1+2+2+2+1+3+3+2\n", "output": "1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "3+2+2+3+2+2+1+2+1+3+3+1+2+3+2+3+2+1+2+2+1+1+2+2+3+2+1+3+1+1+3+3+2+2+2+3+3+2+2+3+2+1+1+3+3+3+2+3+3+2\n", "output": "1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "1+1+3+1+2+1+2+2+1+2+2+1+3+3+3+1+1+2+3+2+3+1+2+3+3+3+1+1+1+3+3+3+2+2+3+3+2+2+3+1+2+1+1+1+2+2+1+3+3+2\n", "output": "1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "2+3+3+2+3+3+3+1+1+2+3+2+2+3+3+2+2+2+3+3+1+1+3+1+2+3+2+2+1+1+2+2+1+2+3+2+3+2+1+3+3+1+2+1+2+2+3+2+2+3\n", "output": "1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "2+3+3+2+3+3+3+1+1+2+3+2+2+3+3+2+2+2+3+3+1+1+3+1+2+1+2+2+3+1+2+2+1+2+3+2+3+2+1+3+3+1+2+1+2+2+3+2+2+3\n", "output": "1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "2+3+3+2+3+3+3+1+1+2+3+2+2+3+3+2+2+3+3+3+1+1+3+1+2+1+2+2+3+1+2+2+1+2+3+2+3+2+1+3+3+1+2+1+2+2+3+2+2+3\n", "output": "1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "3+2+2+3+2+2+1+2+1+3+3+1+2+3+2+3+2+1+2+2+1+3+2+2+1+2+1+3+1+1+3+3+3+2+2+3+3+2+2+3+2+1+1+3+3+3+2+3+3+2\n", "output": "1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "2+3+3+1+2+2+2+1+2+2+1+3+2+2+3+3+2+2+3+3+3+1+1+1+3+3+3+2+1+3+2+3+2+1+1+3+3+3+1+2+2+1+2+1+1+2+1+3+1+1\n", "output": "1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "3+3+3+2+3+3+2+1+1+3+3+2+2+3+3+2+2+2+3+3+1+1+3+1+2+3+2+2+1+1+2+2+1+2+3+2+3+2+1+3+2+1+2+1+2+2+3+3+2+3\n", "output": "1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "3+2+2+3+2+2+1+2+1+3+3+1+2+3+2+3+2+1+2+2+1+1+3+2+2+2+1+3+1+1+3+3+2+2+2+3+3+2+2+3+2+1+1+2+3+3+2+3+3+2\n", "output": "1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "2+3+3+1+2+2+2+1+1+2+1+3+2+2+3+3+2+2+3+3+3+1+1+1+3+3+3+1+1+3+2+3+2+1+1+3+3+3+1+2+2+1+2+2+1+2+1+3+1+1\n", "output": "1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "1+3+3+2+2+2+2+1+2+1+3+3+3+1+3+1+2+2+2+1+2+1+2+1+2+2+2+3+2+2+3+3+3+1+1+3+2+2+1+2+1+1+3+2+3+1+2+2+1+3\n", "output": "1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "3+1+2+2+2\n", "output": "1+2+2+2+3\n", "type": "code"}, {"input": "2+3+3+1+2+2+1+1+1+2+1+3+2+2+3+3+2+2+3+3+3+1+1+1+3+3+3+2+1+3+2+3+2+1+1+3+3+3+1+2+2+1+2+1+1+2+1+3+1+1\n", "output": "1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "3+2+2+3+2+2+1+2+1+3+3+1+2+3+2+3+2+1+2+2+1+3+2+2+1+2+1+3+1+1+3+3+2+2+2+3+3+2+2+3+2+1+1+3+3+3+2+3+3+2\n", "output": "1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "2+3+3+2+3+3+1+1+1+2+3+2+2+3+3+2+2+3+3+3+1+1+3+1+2+1+2+2+3+1+2+2+1+2+3+2+3+2+3+3+3+1+2+1+2+2+3+2+2+3\n", "output": "1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "2+3+3+1+2+2+2+1+1+2+1+3+2+2+3+3+2+2+3+3+3+1+1+1+3+3+3+1+1+3+2+3+2+1+1+3+3+3+1+2+2+2+2+2+1+2+1+3+1+1\n", "output": "1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "3+2+2+3+2+2+1+2+2+3+3+1+2+3+2+3+2+1+2+2+1+1+2+2+3+2+1+3+1+1+3+3+2+2+2+3+3+2+2+3+2+1+1+3+3+3+2+3+3+2\n", "output": "1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "2+3+3+2+3+3+1+1+1+2+3+2+2+3+3+2+2+2+3+3+1+1+3+1+2+1+2+2+3+1+2+2+1+2+3+2+3+2+3+3+3+1+2+1+2+2+3+2+2+3\n", "output": "1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "1+1+3+1+2+1+2+2+2+2+2+1+3+3+3+1+1+2+3+2+3+1+1+3+3+3+1+1+1+3+3+3+2+2+3+3+2+2+3+1+2+1+1+2+2+2+1+3+3+2\n", "output": "1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "2+3+3+2+3+3+3+1+1+2+3+2+2+3+3+2+2+2+3+3+1+1+3+1+2+1+1+2+3+1+2+2+1+2+3+2+3+2+1+3+3+1+2+1+2+2+3+2+2+3\n", "output": "1+1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "3+2+2+3+2+2+1+2+1+3+3+3+2+3+2+3+2+1+2+2+1+3+2+2+1+2+1+3+1+1+3+3+2+2+2+3+3+2+2+3+2+1+1+1+3+3+2+3+3+2\n", "output": "1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "3+2+2+3+2+2+1+2+1+3+3+1+2+3+2+3+2+1+2+2+1+3+2+1+2+2+1+3+1+1+3+3+2+2+2+3+3+2+2+3+2+1+1+3+3+3+2+3+3+2\n", "output": "1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "3+2+2+3+2+2+1+2+1+3+3+3+2+3+2+3+2+1+2+2+1+3+2+2+1+2+1+3+1+1+3+3+2+2+2+3+3+2+2+3+2+1+1+2+3+3+2+3+3+2\n", "output": "1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "1+1+3+1+2+1+2+2+2+2+2+1+3+3+3+1+1+3+2+2+3+1+1+3+3+3+2+1+1+3+3+3+2+2+3+3+2+2+3+1+2+1+1+2+2+2+1+3+3+2\n", "output": "1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "1+2+1+2+2+2+2+1+3+2\n", "output": "1+1+1+2+2+2+2+2+2+3\n", "type": "code"}, {"input": "3+3+3+2+3+3+2+1+1+3+3+2+2+3+3+2+2+2+2+3+1+1+3+1+2+3+2+2+1+1+2+2+1+2+3+2+3+2+1+3+2+1+2+1+2+2+3+3+2+3\n", "output": "1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "1+3+3+2+2+2+2+1+2+1+3+3+3+1+3+1+2+2+2+1+2+1+2+1+2+2+2+3+2+2+3+3+3+1+1+3+2+2+1+2+1+1+3+2+3+1+2+2+1+2\n", "output": "1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "3+3+3+2+3+3+2+1+1+2+3+2+2+3+3+2+2+2+3+3+1+1+3+1+2+3+2+2+1+1+2+2+1+2+3+2+3+2+1+3+2+1+2+1+2+2+3+2+2+3\n", "output": "1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "3+2+2+3+2+2+1+2+1+3+3+1+2+3+2+3+2+1+2+2+1+1+2+2+3+2+1+3+1+1+3+3+2+2+2+3+3+2+2+3+2+1+1+2+3+3+3+3+3+2\n", "output": "1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "3+2+1+2+1\n", "output": "1+1+2+2+3\n", "type": "code"}, {"input": "2+3+3+2+3+3+3+1+1+2+3+2+2+3+3+2+2+3+3+3+1+1+3+1+2+1+2+2+3+1+2+2+1+2+3+2+3+2+1+3+3+2+2+1+2+2+3+1+2+3\n", "output": "1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "2+1+2+2+2+3+1+2+1+2\n", "output": "1+1+1+2+2+2+2+2+2+3\n", "type": "code"}, {"input": "3+1+2+1+2\n", "output": "1+1+2+2+3\n", "type": "code"}, {"input": "1+1+3+2+2+1+1+2+1+2+2+1+3+3+3+1+1+2+3+2+3+1+2+3+3+3+1+1+1+3+3+3+2+2+3+3+2+2+3+1+2+1+1+1+2+2+1+3+3+2\n", "output": "1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "2+3+3+2+3+3+2+1+1+2+3+2+2+3+3+2+2+2+3+3+1+1+3+1+2+2+2+3+1+1+2+2+1+2+3+2+3+2+1+3+2+1+2+1+2+2+3+2+2+3\n", "output": "1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "2+3+3+1+2+2+1+1+1+2+1+3+2+2+3+3+3+2+3+3+3+1+1+1+3+3+3+2+1+3+2+3+2+1+1+3+3+3+1+2+2+1+2+1+1+2+1+3+1+1\n", "output": "1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "3+2+2+3+2+2+1+2+1+3+3+1+2+3+2+3+2+1+2+2+1+3+2+1+2+1+1+3+1+1+3+3+2+2+2+3+3+2+2+3+2+1+1+3+3+3+2+3+3+2\n", "output": "1+1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "1+1+3+1+2+1+2+2+2+2+2+1+3+3+3+1+1+3+2+2+3+1+1+3+3+3+2+1+1+3+3+3+2+2+3+3+2+2+3+1+2+1+1+2+1+2+1+3+3+2\n", "output": "1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "2+3+3+3+3+3+2+1+1+2+3+2+2+3+3+2+2+2+3+3+1+1+3+1+2+3+2+2+1+1+2+2+1+2+3+2+3+2+1+3+3+1+2+1+2+2+3+2+2+3\n", "output": "1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "2+3+3+2+3+3+3+1+1+1+3+2+2+3+3+2+2+3+3+3+1+1+3+1+2+1+2+2+3+1+2+2+1+2+3+2+3+2+1+3+3+2+2+1+2+2+3+1+2+3\n", "output": "1+1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "2+3+3+1+2+2+2+1+1+3+1+3+2+2+3+3+2+2+3+3+3+1+1+1+3+3+3+2+1+3+2+3+2+1+1+3+3+3+1+2+2+1+2+2+1+2+1+3+1+1\n", "output": "1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "1+1+3+2+2+1+1+2+1+2+2+1+3+3+3+1+1+2+3+2+3+1+2+3+3+3+1+1+1+3+3+3+2+2+3+3+2+2+3+1+2+2+1+1+2+2+1+3+3+2\n", "output": "1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "2+3+3+2+3+3+2+1+1+2+3+2+2+3+3+2+2+2+3+3+1+1+3+1+2+2+2+3+1+1+2+2+1+2+3+2+3+2+1+3+2+1+2+1+2+2+3+2+3+3\n", "output": "1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "2+3+3+2+3+3+3+1+1+2+3+2+2+2+3+2+2+2+3+3+1+1+3+1+2+1+1+2+3+1+2+2+1+2+3+2+3+2+1+3+3+1+2+1+2+2+3+2+2+3\n", "output": "1+1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "2+3+3+1+2+2+1+1+2+2+1+3+2+2+3+3+2+2+3+3+3+1+1+1+3+3+3+2+1+3+2+3+2+1+1+3+3+3+1+2+2+1+2+1+1+2+2+3+1+1\n", "output": "1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "2+3+2+2+2+1+1+2+1+2\n", "output": "1+1+1+2+2+2+2+2+2+3\n", "type": "code"}, {"input": "1+1+3+3+1\n", "output": "1+1+1+3+3\n", "type": "code"}, {"input": "3+3+3+2+3+3+2+1+1+3+3+2+2+3+3+2+2+2+3+3+1+1+3+1+2+3+2+2+1+1+2+2+1+2+3+2+3+2+1+3+2+1+2+1+2+2+3+2+2+3\n", "output": "1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "3+2+2+3+2+2+1+2+1+3+3+1+2+3+2+3+2+1+2+2+1+1+2+2+3+2+1+3+1+1+3+3+2+2+2+3+3+2+2+2+2+1+1+2+3+3+2+3+3+2\n", "output": "1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "2+2+3+1+3+1+2+3+2+1+1+1+3+3+3+3+2+3+1+3+1+1+1+2+1+2+1+2+2+2+2+1+1+3+1+1+3+1+3+2+3+3+1+1+3+1+1+1+2+2\n", "output": "1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "3+2+2+2+1+3+2+3+1+1+1+1+2+2+3+1+1+3+3+3+2+2+3+2+2+2+1+2+1+2+1+2+2+2+1+3+1+3+3+3+1+2+1+2+2+2+2+3+3+1\n", "output": "1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "2+2+3+1+3+2+2+3+2+1+1+1+3+3+3+3+2+3+1+3+1+1+1+2+1+2+1+2+2+2+2+1+1+3+1+1+3+1+3+2+3+3+1+1+3+1+1+1+2+2\n", "output": "1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "2+3+3+1+2+3+1+1+1+2+1+3+2+2+3+3+2+2+3+3+3+1+1+1+3+3+3+2+1+3+2+3+2+1+1+3+3+3+1+2+2+1+2+1+1+2+1+3+1+1\n", "output": "1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "2+3+3+2+3+3+3+1+1+2+3+2+2+3+3+2+2+3+3+3+1+1+3+1+2+1+2+2+3+1+2+2+1+2+3+2+2+2+1+3+3+1+2+1+2+2+3+2+2+3\n", "output": "1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "2+3+3+2+3+3+2+1+1+2+3+2+2+3+3+2+2+2+3+3+1+1+3+1+2+2+2+3+1+1+2+2+1+2+3+2+3+2+1+3+3+1+2+1+2+2+3+2+2+3\n", "output": "1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "1+3+3+2+2+2+2+1+2+1+3+3+3+1+3+1+2+2+2+1+2+1+2+1+2+2+2+3+2+2+3+3+3+1+1+3+2+2+1+2+1+1+3+1+3+2+2+2+1+3\n", "output": "1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}, {"input": "2+3+3+2+3+3+3+1+1+2+3+2+2+3+3+2+2+2+3+3+1+1+3+1+2+3+2+2+1+1+2+2+1+2+3+2+3+2+1+3+3+3+2+1+2+2+3+2+2+3\n", "output": "1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n", "type": "code"}]
|
4ed91a995e908a6994e25bbcef2a2cfa
|
code_stdio
|
[
{
"content": "Solve the following coding problem using the programming language python:\n\nJoisino is planning to open a shop in a shopping street.\n\nEach of the five weekdays is divided into two periods, the morning and the evening. For each of those ten periods, a shop must be either open during the whole period, or closed during the whole period. Naturally, a shop must be open during at least one of those periods.\n\nThere are already N stores in the street, numbered 1 through N.\n\nYou are given information of the business hours of those shops, F_{i,j,k}. If F_{i,j,k}=1, Shop i is open during Period k on Day j (this notation is explained below); if F_{i,j,k}=0, Shop i is closed during that period. Here, the days of the week are denoted as follows. Monday: Day 1, Tuesday: Day 2, Wednesday: Day 3, Thursday: Day 4, Friday: Day 5. Also, the morning is denoted as Period 1, and the afternoon is denoted as Period 2.\n\nLet c_i be the number of periods during which both Shop i and Joisino's shop are open. Then, the profit of Joisino's shop will be P_{1,c_1}+P_{2,c_2}+...+P_{N,c_N}.\n\nFind the maximum possible profit of Joisino's shop when she decides whether her shop is open during each period, making sure that it is open during at least one period.\n\nConstraints\n\n* 1≤N≤100\n* 0≤F_{i,j,k}≤1\n* For every integer i such that 1≤i≤N, there exists at least one pair (j,k) such that F_{i,j,k}=1.\n* -10^7≤P_{i,j}≤10^7\n* All input values are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\n\nN\nF_{1,1,1} F_{1,1,2} ... F_{1,5,1} F_{1,5,2}\n:\nF_{N,1,1} F_{N,1,2} ... F_{N,5,1} F_{N,5,2}\nP_{1,0} ... P_{1,10}\n:\nP_{N,0} ... P_{N,10}\n\n\nOutput\n\nPrint the maximum possible profit of Joisino's shop.\n\nExamples\n\nInput\n\n1\n1 1 0 1 0 0 0 1 0 1\n3 4 5 6 7 8 9 -2 -3 4 -2\n\n\nOutput\n\n8\n\n\nInput\n\n2\n1 1 1 1 1 0 0 0 0 0\n0 0 0 0 0 1 1 1 1 1\n0 -2 -2 -2 -2 -2 -1 -1 -1 -1 -1\n0 -2 -2 -2 -2 -2 -1 -1 -1 -1 -1\n\n\nOutput\n\n-2\n\n\nInput\n\n3\n1 1 1 1 1 1 0 0 1 1\n0 1 0 1 1 1 1 0 1 0\n1 0 1 1 0 1 0 1 0 1\n-8 6 -2 -8 -8 4 8 7 -6 2 2\n-9 2 0 1 7 -5 0 -2 -6 5 5\n6 -6 7 -9 6 -5 8 0 -9 -7 -7\n\n\nOutput\n\n23\n\nThe input will be given via stdin and the output should be printed to stdout by your code.\n\nNow solve the problem by providing the code.",
"role": "user"
}
] |
[{"input": "1\n1 1 0 1 0 0 0 1 0 1\n3 4 5 6 7 8 9 -2 -3 4 -2", "output": "8", "type": "code"}, {"input": "3\n1 1 1 1 1 1 0 0 1 1\n0 1 0 1 1 1 1 0 1 0\n1 0 1 1 0 1 0 1 0 1\n-8 6 -2 -8 -8 4 8 7 -6 2 2\n-9 2 0 1 7 -5 0 -2 -6 5 5\n6 -6 7 -9 6 -5 8 0 -9 -7 -7", "output": "23", "type": "code"}, {"input": "2\n1 1 1 1 1 0 0 0 0 0\n0 0 0 0 0 1 1 1 1 1\n0 -2 -2 -2 -2 -2 -1 -1 -1 -1 -1\n0 -2 -2 -2 -2 -2 -1 -1 -1 -1 -1", "output": "-2", "type": "code"}, {"input": "2\n1 1 1 1 1 0 0 0 0 0\n0 0 0 0 0 1 1 1 1 1\n0 -2 -2 -2 -2 -2 -1 -1 -1 -1 -1\n0 -2 -2 -2 -1 -2 -1 -1 -1 -1 -1", "output": "-1\n", "type": "code"}, {"input": "1\n1 1 0 1 0 0 0 1 0 1\n3 4 5 6 7 8 9 -4 -3 4 -2", "output": "8\n", "type": "code"}, {"input": "2\n1 1 1 1 1 0 0 0 0 0\n0 0 0 0 0 1 1 1 1 1\n0 -2 -2 -2 -4 -2 -1 -1 -1 -1 -1\n0 -2 -2 -2 -2 -2 -1 -1 -1 -1 -1", "output": "-2\n", "type": "code"}, {"input": "2\n1 1 1 1 1 0 0 0 0 0\n0 0 0 0 0 1 1 1 1 1\n0 -2 -2 -2 -2 -2 -1 -1 -1 -1 -1\n0 0 -2 -2 -1 -2 -1 -1 -1 -1 -1", "output": "0\n", "type": "code"}, {"input": "1\n1 1 0 1 0 1 0 1 0 1\n3 4 5 6 7 8 10 -4 -3 4 -2", "output": "10\n", "type": "code"}, {"input": "1\n1 1 0 1 0 0 0 1 0 1\n3 4 5 11 7 8 9 -2 -3 4 -2", "output": "11\n", "type": "code"}, {"input": "3\n1 1 1 1 1 1 0 0 1 0\n0 1 0 1 1 1 1 0 1 0\n1 0 1 1 0 1 0 1 0 1\n-8 6 -2 -8 -8 4 8 7 -6 2 2\n-9 2 0 1 7 -5 0 -2 -6 5 5\n6 -6 7 -9 6 -5 8 0 -9 -7 -7", "output": "23\n", "type": "code"}, {"input": "2\n1 1 1 1 1 0 0 0 0 0\n0 0 0 0 0 1 1 1 1 1\n1 -2 -2 -2 -2 -2 -1 -1 -1 -1 -1\n0 0 -2 -2 -1 -2 -1 -1 -1 -1 -1", "output": "1\n", "type": "code"}, {"input": "1\n1 1 0 1 0 0 0 1 0 0\n3 1 5 6 7 8 9 -7 -3 4 -2", "output": "7\n", "type": "code"}, {"input": "1\n1 1 0 1 1 0 0 1 0 1\n4 4 5 12 7 8 10 -4 -3 4 -2", "output": "12\n", "type": "code"}, {"input": "1\n1 1 0 1 0 0 0 1 0 1\n3 1 5 6 7 13 16 -7 -5 2 -2", "output": "13\n", "type": "code"}, {"input": "3\n1 1 1 1 1 1 0 0 0 0\n0 1 0 1 1 1 1 0 1 0\n1 0 1 1 0 1 0 1 0 1\n-8 6 -2 -16 -15 0 8 7 -6 0 2\n-9 2 0 1 7 -5 0 -2 -6 5 5\n6 -6 7 -9 1 -5 0 0 -9 -7 -7", "output": "16\n", "type": "code"}, {"input": "1\n1 0 0 1 0 0 0 1 0 0\n2 0 5 21 7 13 16 -7 -5 0 -1", "output": "21\n", "type": "code"}, {"input": "1\n1 1 0 1 1 0 1 1 0 1\n3 0 10 12 14 11 13 -4 -2 4 -2", "output": "14\n", "type": "code"}, {"input": "2\n1 1 1 1 1 1 0 0 0 0\n0 0 1 0 0 1 1 1 0 1\n0 -2 -2 -2 -7 -2 -1 0 0 -2 -1\n0 1 2 -2 -2 -2 -2 -1 -1 0 0", "output": "2\n", "type": "code"}, {"input": "1\n1 1 0 1 0 1 1 1 0 1\n3 8 5 6 7 8 15 -5 -3 4 -2", "output": "15\n", "type": "code"}, {"input": "3\n1 1 1 0 1 1 0 0 0 0\n0 1 0 1 1 1 1 0 1 0\n1 0 1 1 0 1 0 1 0 1\n-8 6 -2 -16 -15 0 8 7 -6 0 2\n-9 2 0 1 7 -5 0 -2 -6 5 5\n6 -6 7 -9 1 -5 8 0 -9 -7 -7", "output": "20\n", "type": "code"}, {"input": "1\n0 0 0 1 0 0 0 1 0 1\n3 0 5 6 7 13 16 -7 -5 2 -2", "output": "6\n", "type": "code"}, {"input": "1\n0 0 0 0 0 0 0 1 0 1\n3 0 5 6 7 13 16 -7 -5 2 -2", "output": "5\n", "type": "code"}, {"input": "2\n1 1 1 1 1 1 0 0 0 0\n0 0 1 0 0 0 1 1 0 1\n1 -2 -2 -2 -7 -3 -1 0 0 -2 -1\n0 1 2 -2 -2 -2 -2 -1 -1 0 0", "output": "3\n", "type": "code"}, {"input": "3\n1 1 1 1 1 1 0 0 0 0\n0 1 0 1 1 1 1 0 1 0\n1 0 1 1 0 1 0 1 0 1\n-8 6 -2 -16 -15 0 11 7 -6 0 2\n-9 2 0 1 7 -5 0 -2 -7 5 5\n6 -6 7 -9 1 -5 0 1 -9 -7 -7", "output": "19\n", "type": "code"}, {"input": "1\n0 1 1 1 1 0 0 1 1 0\n4 0 5 12 7 8 18 -4 -3 4 -2", "output": "18\n", "type": "code"}, {"input": "3\n1 1 1 1 1 1 1 0 0 0\n0 1 0 1 0 1 1 0 1 0\n1 0 1 1 0 1 0 1 0 1\n-8 6 -2 -16 -8 0 0 7 -5 0 2\n-9 2 1 2 7 -5 0 -3 -6 5 5\n6 -6 7 -9 1 -5 8 0 -9 -7 -7", "output": "22\n", "type": "code"}, {"input": "3\n1 1 1 1 1 1 1 0 0 0\n0 1 0 1 0 1 1 0 1 0\n1 0 1 1 0 1 0 1 0 1\n-8 6 -2 -16 -8 0 0 7 -5 0 2\n-9 2 1 2 7 -5 0 -3 -6 5 5\n6 -1 7 -9 1 -5 16 0 -9 -7 -7", "output": "30\n", "type": "code"}, {"input": "1\n1 1 0 1 0 0 1 1 0 1\n3 1 5 6 7 8 9 -7 -3 4 -2", "output": "9\n", "type": "code"}, {"input": "3\n1 1 1 1 1 1 0 0 1 1\n0 1 0 1 1 1 1 0 1 0\n1 0 1 1 0 1 0 1 0 1\n-8 6 -2 -8 -8 4 8 9 -6 2 2\n-9 2 0 1 7 -5 0 -2 -6 5 5\n6 -6 7 -9 6 -5 8 0 -9 -7 -7", "output": "24\n", "type": "code"}, {"input": "3\n1 1 1 1 1 1 0 0 1 1\n0 1 0 1 1 0 1 0 1 0\n1 0 1 1 0 0 0 1 0 1\n-8 6 -2 -8 -8 4 14 9 -6 2 2\n-9 2 0 1 7 -5 0 -2 -6 5 5\n6 -6 7 -9 6 -5 8 0 -9 -7 -7", "output": "28\n", "type": "code"}, {"input": "3\n1 1 1 1 1 1 0 0 1 1\n0 1 0 1 1 0 1 0 1 0\n1 0 1 1 0 0 0 1 0 1\n-8 6 -2 -8 -8 4 8 9 -6 2 2\n-9 2 0 1 7 -5 0 -2 -1 5 5\n6 -6 12 -9 6 -5 8 0 -9 -7 -7", "output": "27\n", "type": "code"}, {"input": "3\n1 1 1 1 1 1 0 0 1 1\n0 1 0 1 1 0 0 0 1 1\n0 0 1 1 1 0 0 1 0 1\n-15 6 -2 -8 -8 4 9 17 -6 2 2\n-9 2 0 1 3 -5 0 -2 -1 5 5\n6 -6 0 -9 6 -5 8 0 -9 -9 -8", "output": "26\n", "type": "code"}, {"input": "3\n1 1 1 1 1 1 0 0 1 1\n0 1 0 1 1 0 0 0 1 1\n0 0 1 1 1 0 0 1 0 1\n-15 6 -2 -8 -8 4 9 27 -6 2 2\n-9 2 0 1 3 -5 0 -2 -1 5 5\n6 -6 0 -9 6 -5 8 0 -9 -9 -8", "output": "36\n", "type": "code"}, {"input": "3\n1 1 1 1 1 1 0 0 1 1\n0 1 0 1 1 0 0 0 1 1\n0 1 1 1 1 0 0 1 0 1\n-15 6 -2 -8 -8 4 9 27 -6 2 2\n-11 2 0 1 3 -5 0 -2 -1 5 5\n6 -6 0 -9 6 -5 8 0 -9 -9 -8", "output": "38\n", "type": "code"}, {"input": "2\n1 1 1 1 1 0 0 1 0 0\n0 0 0 0 0 1 1 1 1 1\n-1 -2 -2 -2 -2 -3 -1 -1 -2 -1 -1\n-1 -2 -2 -4 -2 -2 -1 -2 -1 -1 -1", "output": "-3\n", "type": "code"}, {"input": "3\n1 1 1 1 1 1 0 0 1 1\n0 1 0 1 1 0 1 0 1 0\n1 0 1 1 0 1 0 1 0 1\n-4 1 -2 -8 -8 4 8 9 -6 2 2\n-9 2 0 1 7 -5 0 -2 -6 5 5\n6 -6 7 -9 6 -5 9 0 -9 -7 -7", "output": "25\n", "type": "code"}, {"input": "3\n1 1 1 1 1 1 0 0 1 1\n0 1 0 1 1 0 1 0 1 0\n1 0 1 1 0 0 0 1 0 1\n-8 6 -2 -11 -12 4 14 9 -6 2 2\n-9 2 0 1 7 -5 0 -2 -6 5 5\n6 -6 9 -9 12 -5 8 0 -9 -7 -7", "output": "33\n", "type": "code"}, {"input": "1\n1 1 0 1 0 0 0 1 0 1\n3 4 5 6 7 8 16 -4 -3 4 -2", "output": "8\n", "type": "code"}, {"input": "2\n1 1 1 1 1 1 0 0 0 0\n0 0 0 0 0 1 1 1 1 1\n0 -2 -2 -2 -4 -2 -1 -1 -1 -1 -1\n0 -2 -2 -2 -2 -2 -1 -1 -1 -1 -1", "output": "-2\n", "type": "code"}, {"input": "2\n1 1 1 1 1 0 0 0 0 0\n0 0 0 0 0 1 1 1 1 1\n0 -2 -2 -2 -2 -2 -1 -1 -1 -1 0\n0 0 -2 -2 -1 -2 -1 -1 -1 -1 -1", "output": "0\n", "type": "code"}, {"input": "1\n1 1 0 1 0 0 0 1 0 1\n3 4 5 6 7 8 10 -4 -3 4 -2", "output": "8\n", "type": "code"}, {"input": "2\n1 1 1 1 1 1 0 0 0 0\n0 0 0 0 0 1 1 1 1 1\n0 -2 -2 -2 -4 -2 -1 -1 0 -1 -1\n0 -2 -2 -2 -2 -2 -1 -1 -1 -1 -1", "output": "-2\n", "type": "code"}, {"input": "2\n1 1 1 1 1 0 0 0 0 0\n0 0 0 0 0 1 1 1 1 1\n0 -2 -2 -2 -2 -2 -1 -1 -1 -1 0\n0 0 -2 -2 -1 -2 -1 -2 -1 -1 -1", "output": "0\n", "type": "code"}, {"input": "2\n1 1 1 1 1 1 0 0 0 0\n0 0 0 1 0 1 1 1 1 1\n0 -2 -2 -2 -4 -2 -1 -1 0 -1 -1\n0 -2 -2 -2 -2 -2 -1 -1 -1 -1 -1", "output": "-2\n", "type": "code"}, {"input": "2\n1 1 1 1 1 0 0 1 0 0\n0 0 0 0 0 1 1 1 1 1\n0 -2 -2 -2 -2 -2 -1 -1 -1 -1 0\n0 0 -2 -2 -1 -2 -1 -2 -1 -1 -1", "output": "0\n", "type": "code"}, {"input": "1\n1 1 0 1 0 0 0 1 0 1\n3 1 5 6 7 8 9 -4 -3 4 -2", "output": "8\n", "type": "code"}, {"input": "1\n1 1 0 1 0 0 0 1 0 1\n3 4 5 6 7 8 16 -4 -3 2 -2", "output": "8\n", "type": "code"}, {"input": "2\n1 1 1 1 1 1 0 0 0 0\n0 0 0 0 0 1 1 1 1 1\n-1 -2 -2 -2 -4 -2 -1 -1 -1 -1 -1\n0 -2 -2 -2 -2 -2 -1 -1 -1 -1 -1", "output": "-2\n", "type": "code"}, {"input": "1\n1 1 0 1 0 0 0 1 0 1\n4 4 5 6 7 8 10 -4 -3 4 -2", "output": "8\n", "type": "code"}, {"input": "2\n1 1 1 1 1 1 0 0 0 0\n0 0 0 0 0 1 1 1 1 1\n0 -2 -2 -2 -4 -2 -1 -1 0 -1 -1\n0 0 -2 -2 -2 -2 -1 -1 -1 -1 -1", "output": "0\n", "type": "code"}, {"input": "2\n1 1 1 1 1 0 0 0 0 0\n0 0 0 0 0 1 1 1 1 1\n0 -2 -2 0 -2 -2 -1 -1 -1 -1 0\n0 0 -2 -2 -1 -2 -1 -2 -1 -1 -1", "output": "0\n", "type": "code"}, {"input": "1\n1 1 0 1 0 1 0 1 0 1\n3 8 5 6 7 8 10 -4 -3 4 -2", "output": "10\n", "type": "code"}, {"input": "2\n1 1 1 1 1 1 0 0 0 0\n0 0 0 1 0 1 1 1 1 1\n1 -2 -2 -2 -4 -2 -1 -1 0 -1 -1\n0 -2 -2 -2 -2 -2 -1 -1 -1 -1 -1", "output": "-1\n", "type": "code"}, {"input": "1\n0 1 0 1 0 0 0 1 0 1\n3 4 5 11 7 8 9 -2 -3 4 -2", "output": "11\n", "type": "code"}, {"input": "3\n1 1 1 1 1 1 0 0 1 0\n0 1 0 1 1 1 1 0 1 0\n1 0 1 1 0 1 0 1 0 1\n-8 6 -2 -8 -8 0 8 7 -6 2 2\n-9 2 0 1 7 -5 0 -2 -6 5 5\n6 -6 7 -9 6 -5 8 0 -9 -7 -7", "output": "23\n", "type": "code"}, {"input": "1\n1 1 0 1 0 0 0 1 0 1\n3 1 5 6 7 8 9 -7 -3 4 -2", "output": "8\n", "type": "code"}, {"input": "2\n1 1 1 1 1 0 0 0 0 0\n0 0 0 0 0 1 1 1 1 1\n1 -2 -2 -2 -2 -2 -1 -1 -1 -1 -1\n0 0 -2 -2 0 -2 -1 -1 -1 -1 -1", "output": "1\n", "type": "code"}, {"input": "1\n1 1 0 1 0 0 0 1 0 1\n3 1 5 6 7 8 16 -4 -3 2 -2", "output": "8\n", "type": "code"}, {"input": "2\n1 1 1 1 1 1 0 0 0 0\n0 0 0 0 0 1 1 1 1 1\n-1 -2 -2 0 -4 -2 -1 -1 -1 -1 -1\n0 -2 -2 -2 -2 -2 -1 -1 -1 -1 -1", "output": "0\n", "type": "code"}, {"input": "1\n1 1 0 1 1 0 0 1 0 1\n4 4 5 6 7 8 10 -4 -3 4 -2", "output": "10\n", "type": "code"}, {"input": "2\n1 1 1 1 1 1 0 0 0 0\n0 0 0 0 0 1 1 1 1 1\n0 -2 -2 -2 -4 -2 -1 0 0 -1 -1\n0 0 -2 -2 -2 -2 -1 -1 -1 -1 -1", "output": "0\n", "type": "code"}, {"input": "2\n1 1 0 1 1 0 0 0 0 0\n0 0 0 0 0 1 1 1 1 1\n0 -2 -2 0 -2 -2 -1 -1 -1 -1 0\n0 0 -2 -2 -1 -2 -1 -2 -1 -1 -1", "output": "0\n", "type": "code"}, {"input": "1\n1 1 0 1 0 1 0 1 0 1\n3 8 5 6 7 8 10 -5 -3 4 -2", "output": "10\n", "type": "code"}, {"input": "2\n1 1 1 1 1 1 0 0 0 0\n0 0 0 1 0 1 1 1 1 1\n1 -2 -2 -2 -4 -2 -1 -1 0 -1 -1\n0 -2 -2 -2 -2 -2 -1 -1 -1 -1 -2", "output": "-1\n", "type": "code"}, {"input": "1\n0 1 0 1 0 0 0 1 0 1\n3 5 5 11 7 8 9 -2 -3 4 -2", "output": "11\n", "type": "code"}, {"input": "3\n1 1 1 1 1 1 0 0 0 0\n0 1 0 1 1 1 1 0 1 0\n1 0 1 1 0 1 0 1 0 1\n-8 6 -2 -8 -8 0 8 7 -6 2 2\n-9 2 0 1 7 -5 0 -2 -6 5 5\n6 -6 7 -9 6 -5 8 0 -9 -7 -7", "output": "23\n", "type": "code"}, {"input": "2\n1 1 1 1 1 0 0 0 0 0\n0 0 0 0 0 1 1 1 1 1\n1 -2 -2 0 -2 -2 -1 -1 -1 -1 -1\n0 0 -2 -2 0 -2 -1 -1 -1 -1 -1", "output": "1\n", "type": "code"}, {"input": "1\n1 1 0 1 0 0 0 1 0 1\n3 1 5 6 7 8 16 -7 -3 2 -2", "output": "8\n", "type": "code"}, {"input": "2\n1 1 1 1 1 1 0 0 0 0\n0 0 0 0 0 1 1 1 1 1\n-1 -2 -2 0 -4 -2 -1 -1 -1 -1 -1\n0 -2 -2 0 -2 -2 -1 -1 -1 -1 -1", "output": "0\n", "type": "code"}, {"input": "2\n1 1 1 1 1 1 0 0 0 0\n0 0 0 0 0 1 1 1 1 1\n0 -2 -2 -2 -4 -2 -1 0 0 -1 -1\n0 1 -2 -2 -2 -2 -1 -1 -1 -1 -1", "output": "1\n", "type": "code"}, {"input": "2\n1 1 0 1 1 0 0 0 0 0\n0 0 0 0 0 1 1 1 1 1\n0 -2 -2 1 -2 -2 -1 -1 -1 -1 0\n0 0 -2 -2 -1 -2 -1 -2 -1 -1 -1", "output": "1\n", "type": "code"}, {"input": "1\n1 1 0 1 0 1 1 1 0 1\n3 8 5 6 7 8 10 -5 -3 4 -2", "output": "10\n", "type": "code"}, {"input": "2\n1 1 1 1 1 1 0 0 0 0\n0 0 0 1 0 1 1 1 1 1\n1 -2 -2 -2 -4 -2 -1 -1 0 -1 -2\n0 -2 -2 -2 -2 -2 -1 -1 -1 -1 -2", "output": "-1\n", "type": "code"}, {"input": "1\n0 1 0 1 0 0 0 1 0 1\n2 5 5 11 7 8 9 -2 -3 4 -2", "output": "11\n", "type": "code"}, {"input": "3\n1 1 1 1 1 1 0 0 0 0\n0 1 0 1 1 1 1 0 1 0\n1 0 1 1 0 1 0 1 0 1\n-8 6 -2 -8 -8 0 8 7 -6 2 2\n-9 2 0 1 7 -5 0 -2 -6 5 5\n6 -6 7 -9 1 -5 8 0 -9 -7 -7", "output": "23\n", "type": "code"}, {"input": "1\n1 1 0 1 0 0 0 1 0 0\n3 1 5 2 7 8 9 -7 -3 4 -2", "output": "7\n", "type": "code"}, {"input": "1\n1 1 0 1 0 0 0 1 0 1\n3 1 5 6 7 8 16 -7 -5 2 -2", "output": "8\n", "type": "code"}, {"input": "2\n1 1 1 1 1 1 0 0 0 0\n0 0 0 0 0 1 0 1 1 1\n-1 -2 -2 0 -4 -2 -1 -1 -1 -1 -1\n0 -2 -2 0 -2 -2 -1 -1 -1 -1 -1", "output": "0\n", "type": "code"}, {"input": "1\n1 1 0 1 1 0 0 1 0 1\n4 0 5 12 7 8 10 -4 -3 4 -2", "output": "12\n", "type": "code"}, {"input": "2\n1 1 1 1 1 1 0 0 0 0\n0 0 0 0 0 1 1 1 1 1\n0 -2 -2 -2 -4 -2 -1 0 0 -1 -1\n0 1 -2 -2 -2 -2 -1 -1 -1 0 -1", "output": "1\n", "type": "code"}, {"input": "1\n1 1 0 1 0 1 1 1 0 1\n3 8 5 6 7 8 10 -5 -3 7 -2", "output": "10\n", "type": "code"}, {"input": "2\n1 1 1 1 1 1 0 0 0 0\n0 0 0 1 0 1 1 1 1 1\n1 -2 -2 -2 -4 -2 -1 -1 1 -1 -2\n0 -2 -2 -2 -2 -2 -1 -1 -1 -1 -2", "output": "-1\n", "type": "code"}, {"input": "1\n0 1 1 1 0 0 0 1 0 1\n2 5 5 11 7 8 9 -2 -3 4 -2", "output": "11\n", "type": "code"}, {"input": "3\n1 1 1 1 1 1 0 0 0 0\n0 1 0 1 1 1 1 0 1 0\n1 0 1 1 0 1 0 1 0 1\n-8 6 -2 -16 -8 0 8 7 -6 2 2\n-9 2 0 1 7 -5 0 -2 -6 5 5\n6 -6 7 -9 1 -5 8 0 -9 -7 -7", "output": "23\n", "type": "code"}, {"input": "1\n1 1 0 1 0 0 0 1 0 0\n3 1 5 2 7 8 9 -7 -3 0 -2", "output": "7\n", "type": "code"}, {"input": "2\n1 1 1 1 1 1 0 0 0 0\n-1 0 0 0 0 1 0 1 1 1\n-1 -2 -2 0 -4 -2 -1 -1 -1 -1 -1\n0 -2 -2 0 -2 -2 -1 -1 -1 -1 -1", "output": "0\n", "type": "code"}, {"input": "1\n1 1 0 1 1 0 0 1 0 1\n4 0 5 12 8 8 10 -4 -3 4 -2", "output": "12\n", "type": "code"}, {"input": "2\n1 1 1 1 1 1 0 0 0 0\n0 0 0 0 0 1 1 1 1 1\n0 -2 -2 -2 -4 -2 -1 0 0 -2 -1\n0 1 -2 -2 -2 -2 -1 -1 -1 0 -1", "output": "1\n", "type": "code"}, {"input": "1\n1 1 0 1 0 1 1 1 0 1\n3 8 10 6 7 8 10 -5 -3 7 -2", "output": "10\n", "type": "code"}, {"input": "1\n0 1 1 1 0 0 0 0 0 1\n2 5 5 11 7 8 9 -2 -3 4 -2", "output": "11\n", "type": "code"}, {"input": "3\n1 1 1 1 1 1 0 0 0 0\n0 1 0 1 1 1 1 0 1 0\n1 0 1 1 0 1 0 1 0 1\n-8 6 -2 -16 -8 0 8 7 -6 0 2\n-9 2 0 1 7 -5 0 -2 -6 5 5\n6 -6 7 -9 1 -5 8 0 -9 -7 -7", "output": "23\n", "type": "code"}, {"input": "1\n1 1 0 1 0 0 0 1 0 0\n3 1 5 2 7 8 9 -7 -3 -1 -2", "output": "7\n", "type": "code"}, {"input": "1\n1 0 0 1 0 0 0 1 0 1\n3 1 5 6 7 13 16 -7 -5 2 -2", "output": "7\n", "type": "code"}, {"input": "2\n1 1 1 1 1 1 0 0 0 0\n-1 0 0 0 0 1 0 1 1 1\n-1 -2 -2 0 -4 -3 -1 -1 -1 -1 -1\n0 -2 -2 0 -2 -2 -1 -1 -1 -1 -1", "output": "0\n", "type": "code"}, {"input": "1\n1 1 0 1 1 0 0 1 0 1\n4 0 5 12 8 11 10 -4 -3 4 -2", "output": "12\n", "type": "code"}, {"input": "2\n1 1 1 1 1 1 0 0 0 0\n0 0 0 0 0 1 1 1 1 1\n0 -2 -2 -2 -4 -2 -1 0 0 -2 -1\n0 1 0 -2 -2 -2 -1 -1 -1 0 -1", "output": "1\n", "type": "code"}, {"input": "1\n1 1 0 1 0 1 1 1 0 1\n3 8 10 6 0 8 10 -5 -3 7 -2", "output": "10\n", "type": "code"}, {"input": "1\n0 1 1 1 0 0 0 0 0 1\n2 5 5 11 7 8 9 -2 -3 0 -2", "output": "11\n", "type": "code"}, {"input": "3\n1 1 1 1 1 1 0 0 0 0\n0 1 0 1 1 1 1 0 1 0\n1 0 1 1 0 1 0 1 0 1\n-8 6 -2 -16 -15 0 8 7 -6 0 2\n-9 2 0 1 7 -5 0 -2 -6 5 5\n6 -6 7 -9 1 -5 8 0 -9 -7 -7", "output": "23\n", "type": "code"}, {"input": "1\n1 0 0 1 0 0 0 1 0 1\n3 0 5 6 7 13 16 -7 -5 2 -2", "output": "7\n", "type": "code"}, {"input": "2\n1 1 1 1 1 1 0 0 0 0\n-1 0 0 0 0 1 0 1 1 1\n-1 -2 -2 0 -4 -3 -1 -1 -1 -1 -1\n0 -2 -2 0 -2 -2 -1 -1 -2 -1 -1", "output": "0\n", "type": "code"}, {"input": "1\n1 1 0 1 1 0 0 1 0 1\n4 0 5 12 8 11 13 -4 -3 4 -2", "output": "13\n", "type": "code"}, {"input": "2\n1 1 1 1 1 1 0 0 0 0\n0 0 1 0 0 1 1 1 1 1\n0 -2 -2 -2 -4 -2 -1 0 0 -2 -1\n0 1 0 -2 -2 -2 -1 -1 -1 0 -1", "output": "1\n", "type": "code"}]
|
3e20c8a46e3cb6bdee90bff720dbbf55
|
code_stdio
|
End of preview. Expand
in Data Studio
README.md exists but content is empty.
- Downloads last month
- 9