messages listlengths 1 1 | ground_truth stringlengths 88 726k | dataset stringclasses 2
values |
|---|---|---|
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou have two integers $l$ and $r$. Find an integer $x$ which satisfies the conditions below:\n\n $l \\le x \\le r$. All digits of $x$ are different. \n\nIf there are multiple answers, print any of them.\n\n\n-----Input-... | [{"type": "stdin_stdout", "input": "25610 80988\n", "output": "25610\n"}, {"type": "stdin_stdout", "input": "76330 80769\n", "output": "76340\n"}, {"type": "stdin_stdout", "input": "23452 23456\n", "output": "23456\n"}, {"type": "stdin_stdout", "input": "25139 86116\n", "output": "25139\n"}, {"type": "stdin_stdout", "i... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given an array consisting of $n$ integers $a_1, a_2, \\dots , a_n$ and an integer $x$. It is guaranteed that for every $i$, $1 \\le a_i \\le x$.\n\nLet's denote a function $f(l, r)$ which erases all values such th... | [{"type": "stdin_stdout", "input": "100 100\n98 52 63 2 18 96 31 58 84 40 41 45 66 100 46 71 26 48 81 20 73 91 68 76 13 93 17 29 64 95 79 21 55 75 19 85 54 51 89 78 15 87 43 59 36 1 90 35 65 56 62 28 86 5 82 49 3 99 33 9 92 32 74 69 27 22 77 16 44 94 34 6 57 70 23 12 61 25 8 11 67 47 83 88 10 14 30 7 97 60 42 37 24 38 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAnn has recently started commuting by subway. We know that a one ride subway ticket costs a rubles. Besides, Ann found out that she can buy a special ticket for m rides (she can buy it several times). It costs b rubles. A... | [{"type": "stdin_stdout", "input": "1000 1 1000 1000\n", "output": "1000000\n"}, {"type": "stdin_stdout", "input": "1000 3 1000 1000\n", "output": "334000\n"}, {"type": "stdin_stdout", "input": "1000 2 1 1000\n", "output": "1000\n"}, {"type": "stdin_stdout", "input": "101 110 1 100\n", "output": "100\n"}, {"type": "std... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAlice and Bob love playing one-dimensional battle ships. They play on the field in the form of a line consisting of n square cells (that is, on a 1 × n table).\n\nAt the beginning of the game Alice puts k ships on the fie... | [{"type": "stdin_stdout", "input": "50 7 3\n50\n17 47 1 12 21 25 6 5 49 27 34 8 16 38 11 44 48 9 2 20 3 22 33 23 36 41 15 35 31 30 50 7 45 42 37 29 14 26 24 46 19 4 10 28 18 43 32 39 40 13\n", "output": "19\n"}, {"type": "stdin_stdout", "input": "50 1 1\n50\n1 13 21 37 30 48 23 19 6 49 36 14 9 24 44 10 41 28 20 2 15 11... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nGiven simple (without self-intersections) n-gon. It is not necessary convex. Also you are given m lines. For each line find the length of common part of the line and the n-gon.\n\nThe boundary of n-gon belongs to polygon.... | [{"type": "stdin_stdout", "input": "3 8\n-100000 -100000\n100000 100000\n1 0\n-100000 -100000 100000 -80000\n-100000 -100000 100000 -99000\n-100000 -100000 100000 -99990\n-100000 -100000 100000 -99999\n-100000 -100000 100000 -99999.99\n-100000 -100000 100000 100000\n-100000 -100000 100000 99999.99\n-100000 100000 10000... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAlice has a string $s$. She really likes the letter \"a\". She calls a string good if strictly more than half of the characters in that string are \"a\"s. For example \"aaabb\", \"axaa\" are good strings, and \"baca\", \"... | [{"type": "stdin_stdout", "input": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n", "output": "50\n"}, {"type": "stdin_stdout", "input": "ababababababababababababababababababababababababav\n", "output": "49\n"}, {"type": "stdin_stdout", "input": "abababababababababababababababababababababababava\n", "output": "4... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nXenia lives in a city that has n houses built along the main ringroad. The ringroad houses are numbered 1 through n in the clockwise order. The ringroad traffic is one way and also is clockwise.\n\nXenia has recently move... | [{"type": "stdin_stdout", "input": "100 100\n48 73 63 16 49 88 36 17 66 6 87 13 94 52 58 70 71 52 7 70 25 42 24 36 57 9 79 26 75 39 13 14 38 26 33 66 88 28 75 98 53 48 67 54 63 25 69 87 88 32 72 17 36 35 29 67 74 89 70 47 20 90 78 13 94 57 32 73 29 74 45 78 85 64 81 56 12 65 19 67 34 86 55 71 41 33 76 13 100 47 44 76 8... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nSanta Claus likes palindromes very much. There was his birthday recently. k of his friends came to him to congratulate him, and each of them presented to him a string s_{i} having the same length n. We denote the beauty o... | [{"type": "stdin_stdout", "input": "10 20\njvyxocgomfmrtllgmagp 13\ngvtjnyaofrswcnnifzfq 17\nqisxpseggpjfoijmqnel -5\nlenqmjiofjpggespxsiq 14\nqfzfinncwsrfoaynjtvg 14\ncaayidazlylxyisihdhx 14\npgamglltrmfmogcoxyvj 11\nxhdhisiyxlylzadiyaac 2\ntbirihfpjgbbtclpxwhv 19\nvhwxplctbbgjpfhiribt 10\n", "output": "109\n"}, {"typ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nTomash keeps wandering off and getting lost while he is walking along the streets of Berland. It's no surprise! In his home town, for any pair of intersections there is exactly one way to walk from one intersection to the... | [{"type": "stdin_stdout", "input": "8 56\n1 2\n1 3\n1 4\n1 5\n1 6\n1 7\n1 8\n2 1\n2 3\n2 4\n2 5\n2 6\n2 7\n2 8\n3 1\n3 2\n3 4\n3 5\n3 6\n3 7\n3 8\n4 1\n4 2\n4 3\n4 5\n4 6\n4 7\n4 8\n5 1\n5 2\n5 3\n5 4\n5 6\n5 7\n5 8\n6 1\n6 2\n6 3\n6 4\n6 5\n6 7\n6 8\n7 1\n7 2\n7 3\n7 4\n7 5\n7 6\n7 8\n8 1\n8 2\n8 3\n8 4\n8 5\n8 6\n8 7... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nStudent Valera is an undergraduate student at the University. His end of term exams are approaching and he is to pass exactly n exams. Valera is a smart guy, so he will be able to pass any exam he takes on his first try. ... | [{"type": "stdin_stdout", "input": "1\n1000000000 999999999\n", "output": "999999999\n"}, {"type": "stdin_stdout", "input": "6\n12 11\n10 9\n8 7\n6 5\n4 3\n2 1\n", "output": "11\n"}, {"type": "stdin_stdout", "input": "6\n3 1\n3 2\n4 1\n4 2\n5 4\n5 4\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "5\n4 3\n4 2\n... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nMike is trying rock climbing but he is awful at it. \n\nThere are n holds on the wall, i-th hold is at height a_{i} off the ground. Besides, let the sequence a_{i} increase, that is, a_{i} < a_{i} + 1 for all i from 1 to ... | [{"type": "stdin_stdout", "input": "100\n2 43 47 49 50 57 59 67 74 98 901 903 904 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 938 939 940 942 943 944 945 946 947 948 949 950 952 953 954 956 957 958 959 960 961 962 963 965 966 967 968 969 97... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nЗавтра у хоккейной команды, которой руководит Евгений, важный матч. Евгению нужно выбрать шесть игроков, которые выйдут на лед в стартовом составе: один вратарь, два защитника и три нападающих.\n\nТак как это стартовый со... | [{"type": "stdin_stdout", "input": "29 42 50\n605 254 369 842 889 103 937 235 135 698 482 883 738 467 848 70 1000 129 970 58 94 873 140 363 133 913 834 727 185\n17 676 703 245 149 296 800 106 153 111 285 382 12 704 830 664 30 533 604 380 469 155 216 466 36 347 270 170 10 349 86 5 164 599 517 593 373 461 908 34 569 573\... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nArkady invited Anna for a dinner to a sushi restaurant. The restaurant is a bit unusual: it offers $n$ pieces of sushi aligned in a row, and a customer has to choose a continuous subsegment of these sushi to buy.\n\nThe p... | [{"type": "stdin_stdout", "input": "100\n2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n", "output": "54\n"}, {"type": "stdin_stdout", "input": "100\n1 2 2 2 2 2 2 2 ... | 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 vertice... | [{"type": "stdin_stdout", "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... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nSereja and his friends went to a picnic. The guys had n soda bottles just for it. Sereja forgot the bottle opener as usual, so the guys had to come up with another way to open bottles.\n\nSereja knows that the i-th bottle... | [{"type": "stdin_stdout", "input": "10\n423 360\n947 538\n507 484\n31 947\n414 351\n169 901\n901 21\n592 22\n763 200\n656 485\n", "output": "8\n"}, {"type": "stdin_stdout", "input": "9\n162 942\n637 967\n356 108\n768 53\n656 656\n575 32\n32 575\n53 53\n351 222\n", "output": "6\n"}, {"type": "stdin_stdout", "input": "8\... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given N items.\n\nThe value of the i-th item (1 \\leq i \\leq N) is v_i.\n\nYour have to select at least A and at most B of these items.\n\nUnder this condition, find the maximum possible arithmetic mean of the va... | [{"type": "stdin_stdout", "input": "50 15 47\n795366679311762 795366679311762 795366679311762 795366679311762 795366679311762 795366679311762 795366679311762 795366679311762 795366679311762 795366679311762 795366679311762 473967724102502 795366679311762 766773867637913 795366679311762 795366679311762 795366679311762 79... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nGiven are N points (x_i, y_i) in a two-dimensional plane.\nFind the minimum radius of a circle such that all the points are inside or on it.\n\n-----Constraints-----\n - 2 \\leq N \\leq 50\n - 0 \\leq x_i \\leq 1000\n - 0... | [{"type": "stdin_stdout", "input": "50\n135 823\n185 467\n504 270\n210 194\n916 227\n464 284\n700 817\n593 202\n602 98\n923 371\n963 622\n532 302\n622 560\n858 287\n778 667\n921 764\n224 400\n251 423\n513 806\n546 985\n467 263\n523 834\n720 120\n677 626\n565 501\n753 239\n88 735\n341 46\n316 522\n695 47\n540 461\n714 7... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nGiven is an integer S.\nFind how many sequences there are whose terms are all integers greater than or equal to 3, and whose sum is equal to S.\nThe answer can be very large, so output it modulo 10^9 + 7.\n\n-----Constrai... | [{"type": "stdin_stdout", "input": "1729\n", "output": "294867501\n"}, {"type": "stdin_stdout", "input": "2000\n", "output": "883312678\n"}, {"type": "stdin_stdout", "input": "1445\n", "output": "157799856\n"}, {"type": "stdin_stdout", "input": "1447\n", "output": "185357934\n"}, {"type": "stdin_stdout", "input": "1497... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nIbis is fighting with a monster.\nThe health of the monster is H.\nIbis can cast N kinds of spells. Casting the i-th spell decreases the monster's health by A_i, at the cost of B_i Magic Points.\nThe same spell can be cas... | [{"type": "stdin_stdout", "input": "1832 947\n4182 1443\n3979 4739\n5500 1039\n9994 9474\n7064 5254\n3587 2902\n6074 3873\n3865 9760\n8970 4251\n6222 8535\n9192 643\n5820 6677\n9711 4431\n9112 6134\n8614 2404\n9041 3356\n7574 5999\n9710 6045\n2463 3743\n7637 6723\n7802 9816\n5829 2411\n8800 3617\n9653 7\n6034 1399\n517... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nWe have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N.\nWe will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).\n\n-----Constraints-----\n - ... | [{"type": "stdin_stdout", "input": "123333 101429\n", "output": "175623902\n"}, {"type": "stdin_stdout", "input": "141421 35623\n", "output": "220280457\n"}, {"type": "stdin_stdout", "input": "154242 56347\n", "output": "520400358\n"}, {"type": "stdin_stdout", "input": "105711 80705\n", "output": "801552417\n"}, {"type... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou've got array a[1], a[2], ..., a[n], consisting of n integers. Count the number of ways to split all the elements of the array into three contiguous parts so that the sum of elements in each part is the same. \n\nMore ... | [{"type": "stdin_stdout", "input": "100\n1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1\n", "output": "2030\n"}, {"type": "stdin_stdout", "input": "6\n1000000000 10000... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nSasha and Dima want to buy two $n$-tier cakes. Each cake should consist of $n$ different tiers: from the size of $1$ to the size of $n$. Tiers should go in order from the smallest to the biggest (from top to bottom).\n\nT... | [{"type": "stdin_stdout", "input": "10\n8 8 3 9 7 1 9 6 10 6 4 2 7 3 4 10 5 5 1 2\n", "output": "123\n"}, {"type": "stdin_stdout", "input": "9\n1 3 6 1 4 9 2 8 3 4 8 7 5 7 2 5 9 6\n", "output": "89\n"}, {"type": "stdin_stdout", "input": "8\n4 5 7 8 2 7 6 3 6 1 1 3 5 8 4 2\n", "output": "74\n"}, {"type": "stdin_stdout",... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere are $n$ pillars aligned in a row and numbered from $1$ to $n$.\n\nInitially each pillar contains exactly one disk. The $i$-th pillar contains a disk having radius $a_i$.\n\nYou can move these disks from one pillar t... | [{"type": "stdin_stdout", "input": "100\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nBill is a famous mathematician in BubbleLand. Thanks to his revolutionary math discoveries he was able to make enough money to build a beautiful house. Unfortunately, for not paying property tax on time, court decided to ... | [{"type": "stdin_stdout", "input": "100\n54 93 37 83 59 66 74 19 6 75 76 81 41 97 22 86 80 13 55 3 32 40 18 96 95 44 33 53 79 88 28 70 63 35 25 38 85 36 58 98 87 12 52 0 16 61 17 72 46 62 31 20 43 34 4 7 60 15 73 1 78 48 69 30 8 14 94 84 91 27 2 64 57 42 71 51 29 89 5 11 26 90 99 77 68 82 24 65 23 21 67 92 47 10 56 49 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nRecently Monocarp got a job. His working day lasts exactly $m$ minutes. During work, Monocarp wants to drink coffee at certain moments: there are $n$ minutes $a_1, a_2, \\dots, a_n$, when he is able and willing to take a ... | [{"type": "stdin_stdout", "input": "100 300 32\n60 255 143 42 98 120 3 96 225 18 38 17 146 299 240 250 137 117 70 296 258 279 103 244 109 80 12 285 231 248 49 237 199 283 65 138 275 79 227 40 10 89 270 44 165 177 150 132 108 97 9 269 187 71 139 101 112 263 105 14 20 281 228 171 82 30 39 193 265 212 106 236 272 129 33 2... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThe Queen of England has n trees growing in a row in her garden. At that, the i-th (1 ≤ i ≤ n) tree from the left has height a_{i} meters. Today the Queen decided to update the scenery of her garden. She wants the trees' ... | [{"type": "stdin_stdout", "input": "50 5\n232 6 11 16 21 26 31 36 41 46 665 56 61 66 71 76 602 86 91 712 101 106 111 116 121 126 131 136 141 146 151 156 161 166 755 176 181 186 191 196 201 206 211 216 221 226 231 236 241 246\n", "output": "5\n- 1 231\n- 11 614\n- 17 521\n- 20 616\n- 35 584\n"}, {"type": "stdin_stdout",... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nTo make a paper airplane, one has to use a rectangular piece of paper. From a sheet of standard size you can make $s$ airplanes.\n\nA group of $k$ people decided to make $n$ airplanes each. They are going to buy several p... | [{"type": "stdin_stdout", "input": "10000 10000 1 1\n", "output": "100000000\n"}, {"type": "stdin_stdout", "input": "10000 10000 3 2\n", "output": "16670000\n"}, {"type": "stdin_stdout", "input": "5324 5439 32 13\n", "output": "69622\n"}, {"type": "stdin_stdout", "input": "6246 8489 1227 9\n", "output": "4858\n"}, {"ty... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAfter Vitaly was expelled from the university, he became interested in the graph theory.\n\nVitaly especially liked the cycles of an odd length in which each vertex occurs at most once.\n\nVitaly was wondering how to solv... | [{"type": "stdin_stdout", "input": "5 5\n1 2\n2 3\n3 4\n4 5\n5 1\n", "output": "0 1\n"}, {"type": "stdin_stdout", "input": "100000 0\n", "output": "3 166661666700000\n"}, {"type": "stdin_stdout", "input": "59139 1\n10301 5892\n", "output": "2 59137\n"}, {"type": "stdin_stdout", "input": "92387 0\n", "output": "3 131421... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given a positive integer $m$ and two integer sequence: $a=[a_1, a_2, \\ldots, a_n]$ and $b=[b_1, b_2, \\ldots, b_n]$. Both of these sequence have a length $n$.\n\nPermutation is a sequence of $n$ different positiv... | [{"type": "stdin_stdout", "input": "20 1000000000\n667066860 170421783 139902912 635488786 31946329 289281524 541340760 264115900 680775010 102068388 128171043 636359373 477042326 879154458 716982402 654668379 256334407 874949294 737194458 663371809\n688973261 813186249 677241392 581016678 216137209 424019643 428224807... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nHideo Kojima has just quit his job at Konami. Now he is going to find a new place to work. Despite being such a well-known person, he still needs a CV to apply for a job.\n\nDuring all his career Hideo has produced n game... | [{"type": "stdin_stdout", "input": "100\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n", "output": "100\n"}, {"type": "stdin_stdout", "input": "100\n1 1 1 1 1 1 1 1... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThe problem describes the properties of a command line. The description somehow resembles the one you usually see in real operating systems. However, there are differences in the behavior. Please make sure you've read the... | [{"type": "stdin_stdout", "input": "\"RUn.exe O\" \"\" \" 2ne, \" two! . \" \"\n", "output": "<RUn.exe O>\n<>\n< 2ne, >\n<two!>\n<.>\n< >\n"}, {"type": "stdin_stdout", "input": " \"\" ZX \"\" \"\" \"b\" \"\" \" \" C \"\" \"\" \"\"\n", "output": "<>\n<ZX>\n<>\n<>\n<b>\n<>\n< >\n<C>\n<>\n<>\n<>\n"}, {"type": "stdin... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nBob is decorating his kitchen, more precisely, the floor. He has found a prime candidate for the tiles he will use. They come in a simple form factor — a square tile that is diagonally split into white and black part as d... | [{"type": "stdin_stdout", "input": "1000 1000\n", "output": "708964705\n"}, {"type": "stdin_stdout", "input": "1000 122\n", "output": "712990290\n"}, {"type": "stdin_stdout", "input": "432 333\n", "output": "726933080\n"}, {"type": "stdin_stdout", "input": "843 134\n", "output": "230806096\n"}, {"type": "stdin_stdout",... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nNew Year is coming in Line World! In this world, there are n cells numbered by integers from 1 to n, as a 1 × n board. People live in cells. However, it was hard to move between distinct cells, because of the difficulty o... | [{"type": "stdin_stdout", "input": "120 104\n41 15 95 85 34 11 25 42 65 39 77 80 74 17 66 73 21 14 36 63 63 79 45 24 65 7 63 80 51 21 2 19 78 28 71 2 15 23 17 68 62 18 54 39 43 70 3 46 34 23 41 65 32 10 13 18 10 3 16 48 54 18 57 28 3 24 44 50 15 2 20 22 45 44 3 29 2 27 11 2 12 25 25 31 1 2 32 4 11 30 13 16 26 21 1 13 2... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAshish has a tree consisting of $n$ nodes numbered $1$ to $n$ rooted at node $1$. The $i$-th node in the tree has a cost $a_i$, and binary digit $b_i$ is written in it. He wants to have binary digit $c_i$ written in the $... | [{"type": "stdin_stdout", "input": "10\n64 0 0\n10 0 0\n17 0 1\n90 1 1\n97 1 1\n19 1 0\n26 1 1\n95 1 1\n46 0 0\n86 0 0\n5 4\n7 1\n9 5\n6 8\n1 6\n7 5\n8 10\n3 7\n3 2\n", "output": "128"}, {"type": "stdin_stdout", "input": "10\n92 0 1\n19 1 0\n46 1 0\n53 1 0\n13 1 0\n63 0 1\n3 0 1\n67 1 0\n20 0 1\n82 0 1\n6 5\n9 1\n3 7\n... | 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... | [{"type": "stdin_stdout", "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... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThe end of the school year is near and Ms. Manana, the teacher, will soon have to say goodbye to a yet another class. She decided to prepare a goodbye present for her n students and give each of them a jigsaw puzzle (whic... | [{"type": "stdin_stdout", "input": "50 50\n374 573 323 744 190 806 485 247 628 336 491 606 702 321 991 678 337 579 86 240 993 208 668 686 855 205 363 177 719 249 896 919 782 434 59 647 787 996 286 216 636 212 546 903 958 559 544 126 608 993\n", "output": "937\n"}, {"type": "stdin_stdout", "input": "49 50\n58 820 826 96... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nA group of n schoolboys decided to ride bikes. As nobody of them has a bike, the boys need to rent them.\n\nThe renting site offered them m bikes. The renting price is different for different bikes, renting the j-th bike ... | [{"type": "stdin_stdout", "input": "40 40 61\n28 59 8 27 45 67 33 32 61 3 42 2 3 37 8 8 10 61 1 5 65 28 34 27 8 35 45 49 31 49 13 23 23 53 20 48 14 74 16 6\n69 56 34 66 42 73 45 49 29 70 67 77 73 26 78 11 50 69 64 72 78 66 66 29 80 40 50 75 68 47 78 63 41 70 52 52 69 22 69 66\n", "output": "22 939\n"}, {"type": "stdin_... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nLet's call a number k-good if it contains all digits not exceeding k (0, ..., k). You've got a number k and an array a containing n numbers. Find out how many k-good numbers are in a (count each number every time it occur... | [{"type": "stdin_stdout", "input": "10 6\n1234560\n1234560\n1234560\n1234560\n1234560\n1234560\n1234560\n1234560\n1234560\n1234560\n", "output": "10\n"}, {"type": "stdin_stdout", "input": "6 0\n10\n102\n120\n1032\n1212103\n1999999\n", "output": "5\n"}, {"type": "stdin_stdout", "input": "6 1\n10\n102\n120\n1032\n1212103... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nLittle Tanya decided to present her dad a postcard on his Birthday. She has already created a message — string s of length n, consisting of uppercase and lowercase English letters. Tanya can't write yet, so she found a ne... | [{"type": "stdin_stdout", "input": "DpiNBmCRFWxpdbfGOzvvOcemjructoAdEwegTvbVbfWWRPGyEAxGdDRWVlqNyGWMWHMrHAIZpyxvgaflrsVZhhZRouvpxrKXFZam\nwwPLFtNfPtJXvMLuHjKfYyaRhreNSWSzOvDpqHCGcqllACNPGHxReeFUCmAqIKXYytsSQwIxJzNiiUtgebVuwRmWpRALLyKAzyDPvgIGxALSaeeTIqm\n", "output": "66 12\n"}, {"type": "stdin_stdout", "input": "abcde... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nIahub is training for the IOI. What is a better way to train than playing a Zuma-like game? \n\nThere are n balls put in a row. Each ball is colored in one of k colors. Initially the row doesn't contain three or more cont... | [{"type": "stdin_stdout", "input": "100 100 100\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 9... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nA country has n cities. Initially, there is no road in the country. One day, the king decides to construct some roads connecting pairs of cities. Roads can be traversed either way. He wants those roads to be constructed i... | [{"type": "stdin_stdout", "input": "84 3\n39 19\n55 73\n42 43\n", "output": "83\n1 2\n1 3\n1 4\n1 5\n1 6\n1 7\n1 8\n1 9\n1 10\n1 11\n1 12\n1 13\n1 14\n1 15\n1 16\n1 17\n1 18\n1 19\n1 20\n1 21\n1 22\n1 23\n1 24\n1 25\n1 26\n1 27\n1 28\n1 29\n1 30\n1 31\n1 32\n1 33\n1 34\n1 35\n1 36\n1 37\n1 38\n1 39\n1 40\n1 41\n1 42\n1... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nOne day Vasya was on a physics practical, performing the task on measuring the capacitance. He followed the teacher's advice and did as much as n measurements, and recorded the results in the notebook. After that he was a... | [{"type": "stdin_stdout", "input": "100\n4204 4719 4688 3104 4012 4927 4696 4614 4826 4792 3891 4672 4914 4740 4968 3879 4424 4755 3856 3837 4965 4939 4030 4941 4504 4668 4908 4608 3660 4822 4846 3945 4539 4819 4895 3746 4324 4233 4135 4956 4983 4546 4673 4617 3533 4851 4868 4838 4998 4769 4899 4578 3841 4974 4627 4990... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nToday Adilbek is taking his probability theory test. Unfortunately, when Adilbek arrived at the university, there had already been a long queue of students wanting to take the same test. Adilbek has estimated that he will... | [{"type": "stdin_stdout", "input": "20 25\n1 1 1 1 1 1 2 2 1 1 2 1 2 2 1 2 1 1 2 2\n", "output": "846324940\n"}, {"type": "stdin_stdout", "input": "20 26\n1 2 1 1 1 2 1 1 2 2 2 1 2 1 2 1 1 2 2 1\n", "output": "509799974\n"}, {"type": "stdin_stdout", "input": "20 27\n1 2 1 2 1 2 1 2 2 1 2 2 1 2 2 2 1 1 2 1\n", "output":... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAlyona decided to go on a diet and went to the forest to get some apples. There she unexpectedly found a magic rooted tree with root in the vertex 1, every vertex and every edge of which has a number written on.\n\nThe gi... | [{"type": "stdin_stdout", "input": "39\n100 83 92 26 10 63 56 85 12 64 25 50 75 51 11 41 78 53 52 96 63 12 48 88 57 57 25 52 69 45 4 97 5 87 58 15 72 59 100\n35 -60\n33 -39\n1 65\n11 -65\n34 -63\n38 84\n4 76\n22 -9\n6 -91\n23 -65\n18 7\n2 -17\n29 -15\n19 26\n29 23\n14 -12\n30 -72\n9 14\n12 -1\n27 -21\n32 -67\n7 -3\n26 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYaroslav thinks that two strings s and w, consisting of digits and having length n are non-comparable if there are two numbers, i and j (1 ≤ i, j ≤ n), such that s_{i} > w_{i} and s_{j} < w_{j}. Here sign s_{i} represents... | [{"type": "stdin_stdout", "input": "10\n???0?19?01\n957461????\n", "output": "983368000\n"}, {"type": "stdin_stdout", "input": "10\n?8?528?91?\n45??06???1\n", "output": "980398000\n"}, {"type": "stdin_stdout", "input": "10\n104?3?1??3\n?1755?1??7\n", "output": "91015750\n"}, {"type": "stdin_stdout", "input": "10\n62764... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou have a Petri dish with bacteria and you are preparing to dive into the harsh micro-world. But, unfortunately, you don't have any microscope nearby, so you can't watch them.\n\nYou know that you have $n$ bacteria in th... | [{"type": "stdin_stdout", "input": "8 1000000\n1 1 5 1000000 1000000 2 2 2\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "15 1\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n", "output": "15\n"}, {"type": "stdin_stdout", "input": "7 1\n101 53 42 102 101 55 54\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "10 1\n1 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nIvan unexpectedly saw a present from one of his previous birthdays. It is array of $n$ numbers from $1$ to $200$. Array is old and some numbers are hard to read. Ivan remembers that for all elements at least one of its ne... | [{"type": "stdin_stdout", "input": "37\n52 52 66 149 149 130 47 47 26 110 185 -1 73 73 65 -1 -1 130 -1 -1 -1 94 97 190 -1 -1 49 49 54 -1 92 92 5 25 48 79 79\n", "output": "903952722\n"}, {"type": "stdin_stdout", "input": "15\n-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 20\n", "output": "368187329\n"}, {"type": "stdin_std... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nRecently Pashmak has been employed in a transportation company. The company has k buses and has a contract with a school which has n students. The school planned to take the students to d different places for d days (each... | [{"type": "stdin_stdout", "input": "27 3 3\n", "output": "1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 \n1 1 1 2 2 2 3 3 3 1 1 1 2 2 2 3 3 3 1 1 1 2 2 2 3 3 3 \n1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 \n"}, {"type": "stdin_stdout", "input": "7 2 3\n", "output": "1 1 1 1 2 2 2 \n1 1 2 2 1 1 2 \n1 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou've got an n × m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased ... | [{"type": "stdin_stdout", "input": "10 10\n20 53 6 97 74 12 92 48 13 97\n96 47 32 75 21 69 75 95 54 1\n97 36 1 41 87 1 23 39 44 27\n97 73 1 1 26 6 3 48 69 5\n70 93 42 35 5 12 22 33 29 13\n96 8 13 69 40 91 5 19 16 33\n61 92 54 82 60 24 63 64 59 65\n76 44 60 37 29 16 50 74 59 59\n77 58 95 30 52 25 34 2 49 92\n37 65 12 77... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nShaass has n books. He wants to make a bookshelf for all his books. He wants the bookshelf's dimensions to be as small as possible. The thickness of the i-th book is t_{i} and its pages' width is equal to w_{i}. The thick... | [{"type": "stdin_stdout", "input": "100\n2 2\n1 2\n1 1\n2 1\n1 2\n2 1\n2 2\n2 1\n2 1\n1 2\n1 2\n2 1\n1 2\n2 1\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 1\n2 2\n2 1\n1 1\n1 2\n2 2\n1 1\n2 2\n1 2\n2 1\n2 2\n1 2\n2 2\n1 2\n1 1\n2 2\n2 2\n1 1\n1 2\n2 2\n1 2\n1 1\n1 1\n1 1\n2 1\n2 1\n1 2\n1 2\n2 2\n1 2\n1 2\n1 1\n2 1\n2 1\n2 2\n1 2\... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThe Saratov State University Olympiad Programmers Training Center (SSU OPTC) has n students. For each student you know the number of times he/she has participated in the ACM ICPC world programming championship. According ... | [{"type": "stdin_stdout", "input": "20 1\n5 0 4 2 2 3 2 1 2 4 1 3 5 5 5 4 4 1 3 0\n", "output": "5\n"}, {"type": "stdin_stdout", "input": "20 2\n1 4 5 1 3 4 0 5 0 3 3 0 4 0 0 1 4 2 0 4\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "20 2\n1 4 5 1 3 4 0 5 0 3 3 0 4 0 0 1 4 2 0 4\n", "output": "4\n"}, {"type": "... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given a tree consisting of $n$ vertices. A tree is an undirected connected acyclic graph. [Image] Example of a tree. \n\nYou have to paint each vertex into one of three colors. For each vertex, you know the cost o... | [{"type": "stdin_stdout", "input": "15\n10 34 69 39 82 49 57 22 50 25 82 37 33 62 69\n35 14 68 31 26 8 33 98 33 95 19 22 89 18 67\n80 24 10 5 26 85 69 21 29 38 89 24 78 68 88\n13 1\n6 12\n8 4\n11 9\n14 11\n15 5\n3 15\n1 10\n13 9\n7 12\n14 6\n3 2\n2 7\n4 5\n", "output": "620\n2 3 2 2 3 3 1 1 3 3 2 2 1 1 1 \n"}, {"type":... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAll our characters have hobbies. The same is true for Fedor. He enjoys shopping in the neighboring supermarket. \n\nThe goods in the supermarket have unique integer ids. Also, for every integer there is a product with id ... | [{"type": "stdin_stdout", "input": "24 21\n240694945 246896662\n240694930 246896647\n240695065 246896782\n240695050 246896767\n240695080 246896797\n240694960 246896677\n240694975 246896692\n240694825 246896542\n240694900 246896617\n240694915 246896632\n240694885 246896602\n240694855 246896572\n240694870 246896587\n2406... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given a string $s=s_1s_2\\dots s_n$ of length $n$, which only contains digits $1$, $2$, ..., $9$.\n\nA substring $s[l \\dots r]$ of $s$ is a string $s_l s_{l + 1} s_{l + 2} \\ldots s_r$. A substring $s[l \\dots r]... | [{"type": "stdin_stdout", "input": "39\n263254663359864483324578786753512345165\n", "output": "327"}, {"type": "stdin_stdout", "input": "10\n9572683145\n", "output": "24"}, {"type": "stdin_stdout", "input": "4\n2244\n", "output": "10"}, {"type": "stdin_stdout", "input": "4\n1234\n", "output": "6"}, {"type": "stdin_stdo... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nInna and Dima bought a table of size n × m in the shop. Each cell of the table contains a single letter: \"D\", \"I\", \"M\", \"A\".\n\nInna loves Dima, so she wants to go through his name as many times as possible as she... | [{"type": "stdin_stdout", "input": "14 34\nDDDDDDDDDDDDIMADDDDDDDDDDDDDDDIMAD\nDDDDDDIMADDDDDDDDDDDDDDDDDDDDDIMAD\nDDDDDDDDDDDDDIDDDDDDDDDDDIDIMIDIMA\nDDDDDDIMDDDDDDDDDDDDDIDDDDDDDDDDDD\nDDDDDDDDDDDDDDDDDMADDDDDDDDDDDDDMD\nDDDDDDIMIDDDDDDDDDDDDIMIDIMIDDDIDD\nDDDDDDDDDDDDDDDDDMIMDDDDIMDDIMADIM\nDDDDDDDDDDDADIMADIDDDDDDI... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThe Cybernetics Failures (CF) organisation made a prototype of a bomb technician robot. To find the possible problems it was decided to carry out a series of tests. At the beginning of each test the robot prototype will b... | [{"type": "stdin_stdout", "input": "15 17 8 9\nURRDLUULLDDDRRURR\n", "output": "1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 0 0 241\n"}, {"type": "stdin_stdout", "input": "15 17 8 9\nURRDLUULLDDDRRUR\n", "output": "1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 0 241\n"}, {"type": "stdin_stdout", "input": "15 17 8 9\nURRDLUULLDDRRRRU\n", "output": "... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nPasha decided to invite his friends to a tea party. For that occasion, he has a large teapot with the capacity of w milliliters and 2n tea cups, each cup is for one of Pasha's friends. The i-th cup can hold at most a_{i} ... | [{"type": "stdin_stdout", "input": "4 1000000000\n1 1 1 1 2 2 2 2\n", "output": "12.0000000000\n"}, {"type": "stdin_stdout", "input": "4 1000000000\n1 1 1 1 1 1 1 1\n", "output": "6.0000000000\n"}, {"type": "stdin_stdout", "input": "5 15\n2 3 4 1 2 4 5 3 5 10\n", "output": "15.0000000000\n"}, {"type": "stdin_stdout", "... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nLet $n$ be an integer. Consider all permutations on integers $1$ to $n$ in lexicographic order, and concatenate them into one big sequence $P$. For example, if $n = 3$, then $P = [1, 2, 3, 1, 3, 2, 2, 1, 3, 2, 3, 1, 3, 1,... | [{"type": "stdin_stdout", "input": "1000000\n", "output": "739718215\n"}, {"type": "stdin_stdout", "input": "987654\n", "output": "801594140\n"}, {"type": "stdin_stdout", "input": "123452\n", "output": "37092478\n"}, {"type": "stdin_stdout", "input": "78266\n", "output": "379770260\n"}, {"type": "stdin_stdout", "input"... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou're given an integer $n$. For every integer $i$ from $2$ to $n$, assign a positive integer $a_i$ such that the following conditions hold: For any pair of integers $(i,j)$, if $i$ and $j$ are coprime, $a_i \\neq a_j$. ... | [{"type": "stdin_stdout", "input": "179\n", "output": "1 2 1 3 2 4 1 2 3 5 2 6 4 3 1 7 2 8 3 4 5 9 2 3 6 2 4 10 3 11 1 5 7 4 2 12 8 6 3 13 4 14 5 3 9 15 2 4 3 7 6 16 2 5 4 8 10 17 3 18 11 4 1 6 5 19 7 9 4 20 2 21 12 3 8 5 6 22 3 2 13 23 4 7 14 10 5 24 3 6 9 11 15 8 2 25 4 5 3 26 7 27 6 4 16 28 2 29 5 12 4 30 8 9 10 6 1... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThe main city magazine offers its readers an opportunity to publish their ads. The format of the ad should be like this:\n\nThere are space-separated non-empty words of lowercase and uppercase Latin letters.\n\nThere are ... | [{"type": "stdin_stdout", "input": "2\nWjrWBWqKIeSndDHeiVmfChQNsoUiRQHVplnIWkwBtxAJhOdTigAAzKtbNEqcgvbWHOopfCNgWHfwXyzSCfNqGMLnmlIdKQonLsmGSJlPBcYfHNJJDGlKNnOGtrWUhaTWuilHWMUlFEzbJYbeAWvgnSOOOPLxX-eJEKRsKqSnMjrPbFDprCqgbTfwAnPjFapVKiTjCcWEzhahwPRHScfcLnUixnxckQJzuHzshyBFKPwVGzHeJWniiRKynDFQdaazmTZtDGnFVTmTUZCRCpUHFmUHA... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nVanya walks late at night along a straight street of length l, lit by n lanterns. Consider the coordinate system with the beginning of the street corresponding to the point 0, and its end corresponding to the point l. The... | [{"type": "stdin_stdout", "input": "46 615683844\n431749087 271781274 274974690 324606253 480870261 401650581 13285442 478090364 266585394 425024433 588791449 492057200 391293435 563090494 317950 173675329 473068378 356306865 311731938 192959832 321180686 141984626 578985584 512026637 175885185 590844074 47103801 21221... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nGenerous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with thei... | [{"type": "stdin_stdout", "input": "10\n-1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000\n7 8\n5 10\n8 6\n1 5\n7 9\n3 9\n2 10\n2 6\n4 3\n", "output": "Impossible"}, {"type": "stdin_stdout", "input": "10\n1000000000 1000000000 1000000000 1000000000 1... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nXenia has a set of weights and pan scales. Each weight has an integer weight from 1 to 10 kilos. Xenia is going to play with scales and weights a little. For this, she puts weights on the scalepans, one by one. The first ... | [{"type": "stdin_stdout", "input": "0111100111\n32\n", "output": "YES\n9 10 9 10 9 10 9 10 9 10 9 10 9 10 9 10 9 8 10 9 10 9 10 9 10 9 10 9 10 9 8 10\n"}, {"type": "stdin_stdout", "input": "1000000011\n18\n", "output": "YES\n9 10 9 10 9 10 9 10 9 10 9 10 9 10 9 10 9 10\n"}, {"type": "stdin_stdout", "input": "0110110000... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nDasha logged into the system and began to solve problems. One of them is as follows:\n\nGiven two sequences a and b of length n each you need to write a sequence c of length n, the i-th element of which is calculated as f... | [{"type": "stdin_stdout", "input": "30 100 200\n102 108 122 116 107 145 195 145 119 110 187 196 140 174 104 190 193 181 118 127 157 111 139 175 173 191 181 105 142 166\n30 26 20 23 27 15 2 14 21 25 6 1 17 10 29 5 3 7 22 19 13 24 18 9 11 4 8 28 16 12\n", "output": "100 100 100 100 100 101 100 100 100 100 100 100 100 100... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAfter you had helped George and Alex to move in the dorm, they went to help their friend Fedor play a new computer game «Call of Soldiers 3».\n\nThe game has (m + 1) players and n types of soldiers in total. Players «Call... | [{"type": "stdin_stdout", "input": "13 27 7\n1893\n370\n7320\n5753\n4418\n2146\n2702\n5013\n5959\n1929\n7611\n7013\n540\n3454\n4271\n2887\n4724\n3520\n2111\n5845\n1868\n7659\n3040\n3775\n6507\n4917\n7506\n2515\n", "output": "20\n"}, {"type": "stdin_stdout", "input": "9 20 2\n197\n45\n217\n9\n156\n335\n21\n90\n33\n292\n... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given $n$ numbers $a_1, a_2, \\ldots, a_n$. Is it possible to arrange them in a circle in such a way that every number is strictly less than the sum of its neighbors?\n\nFor example, for the array $[1, 4, 5, 6, 7,... | [{"type": "stdin_stdout", "input": "43\n4182 3 6766 701408734 14930353 2585 39088170 1598 10947 988 28658 3524579 611 196419 378 22 14 267914297 90 17712 433494438 24157818 9227466 121394 832041 63245987 165580142 46369 2 514230 6 35 4 234 9 317812 145 102334156 75026 1346270 5702888 56 2178310\n", "output": "YES\n7014... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nKen loves ken-ken-pa (Japanese version of hopscotch). Today, he will play it on a directed graph G.\nG consists of N vertices numbered 1 to N, and M edges. The i-th edge points from Vertex u_i to Vertex v_i.\nFirst, Ken s... | [{"type": "stdin_stdout", "input": "6 8\n1 2\n2 3\n3 4\n4 5\n5 1\n1 4\n1 5\n4 6\n1 6\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "4 4\n1 2\n2 3\n3 4\n4 1\n1 3\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "3 3\n1 2\n2 3\n3 1\n1 2\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "2 0\n1 2\n... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nGiven are N positive integers A_1,...,A_N.\nConsider positive integers B_1, ..., B_N that satisfy the following condition.\nCondition: For any i, j such that 1 \\leq i < j \\leq N, A_i B_i = A_j B_j holds.\nFind the minim... | [{"type": "stdin_stdout", "input": "10000\n996426 991040 991394 993249 993789 994392 991787 998270 994534 999447 995337 997096 996535 997215 994454 999779 998240 991404 991682 999870 990794 994313 993602 993869 997730 991987 994764 993847 993506 990653 996555 994126 992060 995401 997275 995702 995833 993070 990511 9917... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere is a grid with N rows and N columns of squares. Let (i,j) be the square at the i-th row from the top and the j-th column from the left.\nThese squares have to be painted in one of the C colors from Color 1 to Color ... | [{"type": "stdin_stdout", "input": "153 17\n0 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1 1 1 1000 1000\n1000 0 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1 1 1 1000 1000\n1000 1000 0 1000 1000 1000 1000 1000 1000 1000 1000 1000 1 1 1 1000 1000\n1000 1000 1000 0 1000 1000 1000 1000 1000 1000 1000 10... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere are N mountains in a circle, called Mountain 1, Mountain 2, ..., Mountain N in clockwise order. N is an odd number.\nBetween these mountains, there are N dams, called Dam 1, Dam 2, ..., Dam N. Dam i (1 \\leq i \\leq... | [{"type": "stdin_stdout", "input": "4347\n260851 113568 146755 277208 291368 365593 306158 216020 344668 347475 275144 352224 284362 117882 195739 364750 445348 416819 269652 99635 82915 80392 51627 75388 237943 322687 343290 419290 298882 162789 250158 343046 283281 278723 215017 105840 263209 271290 119076 276553 322... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nTheater stage is a rectangular field of size n × m. The director gave you the stage's plan which actors will follow. For each cell it is stated in the plan if there would be an actor in this cell or not.\n\nYou are to pla... | [{"type": "stdin_stdout", "input": "10 20\n0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nLet's define a forest as a non-directed acyclic graph (also without loops and parallel edges). One day Misha played with the forest consisting of n vertices. For each vertex v from 0 to n - 1 he wrote down two integers, d... | [{"type": "stdin_stdout", "input": "19\n1 13\n0 0\n1 9\n1 11\n1 11\n2 3\n2 30\n0 0\n1 5\n1 2\n0 0\n5 29\n1 6\n2 11\n0 0\n0 0\n0 0\n0 0\n2 13\n", "output": "10\n0 13\n2 9\n3 11\n4 11\n8 5\n12 6\n13 11\n5 11\n6 18\n11 18\n"}, {"type": "stdin_stdout", "input": "18\n0 0\n0 0\n2 19\n1 2\n2 29\n0 0\n1 7\n1 6\n1 12\n1 13\n0 0... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nInna loves digit 9 very much. That's why she asked Dima to write a small number consisting of nines. But Dima must have misunderstood her and he wrote a very large number a, consisting of digits from 1 to 9.\n\nInna wants... | [{"type": "stdin_stdout", "input": "44444444444444544444444445444444444444444444444444554444444444444444444444444444444444444444455444444444444444444444444444444444444444545444444444444444444444444444444444444445444444444444444444444444444444444444544444444444444444444444444444444444444444444544444444444444444444444444... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThe police department of your city has just started its journey. Initially, they don’t have any manpower. So, they started hiring new recruits in groups.\n\nMeanwhile, crimes keeps occurring within the city. One member of... | [{"type": "stdin_stdout", "input": "146\n4 -1 -1 -1 -1 -1 -1 -1 -1 -1 4 -1 3 -1 3 -1 -1 1 4 -1 2 -1 -1 3 -1 -1 -1 4 1 -1 -1 -1 4 -1 -1 -1 -1 -1 -1 3 2 -1 3 2 4 5 2 4 1 5 -1 -1 2 -1 -1 1 -1 5 3 -1 1 2 2 3 5 3 -1 -1 3 -1 -1 3 5 5 -1 -1 5 -1 4 4 1 -1 -1 -1 2 1 -1 -1 -1 2 5 3 -1 -1 -1 3 -1 5 4 -1 1 -1 -1 3 -1 -1 3 1 1 2 -1... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nWhile walking down the street Vanya saw a label \"Hide&Seek\". Because he is a programmer, he used & as a bitwise AND for these two words represented as a integers in base 64 and got new word. Now Vanya thinks of some str... | [{"type": "stdin_stdout", "input": "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_0123456789ABCDEFGHIJKLMNOPQR... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nPavel has several sticks with lengths equal to powers of two.\n\nHe has $a_0$ sticks of length $2^0 = 1$, $a_1$ sticks of length $2^1 = 2$, ..., $a_{n-1}$ sticks of length $2^{n-1}$. \n\nPavel wants to make the maximum po... | [{"type": "stdin_stdout", "input": "100\n5 5 2 4 5 4 4 4 4 2 5 3 4 2 4 4 1 1 5 3 2 2 1 3 3 2 5 3 4 5 1 3 5 4 4 4 3 1 4 4 3 4 5 2 5 4 2 1 2 2 3 5 5 5 1 4 5 3 1 4 2 2 5 1 5 3 4 1 5 1 2 2 3 5 1 3 2 4 2 4 2 2 4 1 3 5 2 2 2 3 3 4 3 2 2 5 5 4 2 5\n", "output": "106\n"}, {"type": "stdin_stdout", "input": "100\n1 1 1 1 1 1 1 1... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nSmart Beaver decided to be not only smart, but also a healthy beaver! And so he began to attend physical education classes at school X. In this school, physical education has a very creative teacher. One of his favorite w... | [{"type": "stdin_stdout", "input": "200\n1 2 1 1 2 2 1 1 1 1 1 1 2 1 2 2 2 2 2 1 2 2 1 1 2 2 2 2 2 1 2 1 1 2 2 2 1 2 2 2 1 1 2 2 2 1 2 2 1 2 1 2 2 1 2 2 2 2 2 1 2 2 1 2 1 1 2 2 2 2 2 2 2 1 2 2 2 1 1 2 2 2 2 1 1 2 2 1 1 1 2 2 1 1 2 2 1 1 2 2 2 1 2 2 2 1 2 1 2 2 2 2 2 2 2 1 1 1 2 2 2 2 2 2 2 2 1 1 2 2 2 2 2 1 2 1 2 1 1 1... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nIn this task you need to process a set of stock exchange orders and use them to create order book.\n\nAn order is an instruction of some participant to buy or sell stocks on stock exchange. The order number i has price p_... | [{"type": "stdin_stdout", "input": "3 3\nB 5878 1568\nS 60238 4895\nS 76276 1905\n", "output": "S 76276 1905\nS 60238 4895\nB 5878 1568\n"}, {"type": "stdin_stdout", "input": "6 2\nB 10 3\nS 50 2\nS 40 1\nS 50 6\nB 20 4\nB 25 10\n", "output": "S 50 8\nS 40 1\nB 25 10\nB 20 4\n"}, {"type": "stdin_stdout", "input": "2 1\... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nBob is a duck. He wants to get to Alice's nest, so that those two can duck! [Image] Duck is the ultimate animal! (Image courtesy of See Bang) \n\nThe journey can be represented as a straight line, consisting of $n$ segmen... | [{"type": "stdin_stdout", "input": "10\n324839129156 133475576222 987711341463 185514358673 88712073883 243757012712 950854402304 21947060440 598567289966 674328002732\nGLLLLLLLLW\n", "output": "20611890699442\n"}, {"type": "stdin_stdout", "input": "2\n1 1000000000000\nGW\n", "output": "2000000000003\n"}, {"type": "std... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nBerland is going through tough times — the dirt price has dropped and that is a blow to the country's economy. Everybody knows that Berland is the top world dirt exporter!\n\nThe President of Berland was forced to leave o... | [{"type": "stdin_stdout", "input": "100\n-683 303 245 -975 345 -159 529 -752 -349 -318 -275 -62 -449 -601 -687 691 491 -297 -576 425 -468 -235 446 536 143 152 -402 -491 363 -842 676 360 -461 -170 727 53 10 823 665 716 110 450 -154 -265 -926 636 -577 99 -719 -786 373 -286 994 -756 644 -800 220 -771 860 610 -613 -51 -398... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nDima took up the biology of bacteria, as a result of his experiments, he invented k types of bacteria. Overall, there are n bacteria at his laboratory right now, and the number of bacteria of type i equals c_{i}. For conv... | [{"type": "stdin_stdout", "input": "10 0 10\n1 1 1 1 1 1 1 1 1 1\n", "output": "Yes\n0 -1 -1 -1 -1 -1 -1 -1 -1 -1\n-1 0 -1 -1 -1 -1 -1 -1 -1 -1\n-1 -1 0 -1 -1 -1 -1 -1 -1 -1\n-1 -1 -1 0 -1 -1 -1 -1 -1 -1\n-1 -1 -1 -1 0 -1 -1 -1 -1 -1\n-1 -1 -1 -1 -1 0 -1 -1 -1 -1\n-1 -1 -1 -1 -1 -1 0 -1 -1 -1\n-1 -1 -1 -1 -1 -1 -1 0 -1... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAlex enjoys performing magic tricks. He has a trick that requires a deck of n cards. He has m identical decks of n different cards each, which have been mixed together. When Alex wishes to perform the trick, he grabs n ca... | [{"type": "stdin_stdout", "input": "1000 1000\n", "output": "0.0019980019980020\n"}, {"type": "stdin_stdout", "input": "461 1000\n", "output": "0.0043315295751250\n"}, {"type": "stdin_stdout", "input": "987 123\n", "output": "0.0020170953866492\n"}, {"type": "stdin_stdout", "input": "999 999\n", "output": "0.0020000000... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nVasya owns a cornfield which can be defined with two integers $n$ and $d$. The cornfield can be represented as rectangle with vertices having Cartesian coordinates $(0, d), (d, 0), (n, n - d)$ and $(n - d, n)$.\n\n [Image... | [{"type": "stdin_stdout", "input": "9 3\n100\n0 0\n0 1\n0 2\n0 3\n0 4\n0 5\n0 6\n0 7\n0 8\n0 9\n1 0\n1 1\n1 2\n1 3\n1 4\n1 5\n1 6\n1 7\n1 8\n1 9\n2 0\n2 1\n2 2\n2 3\n2 4\n2 5\n2 6\n2 7\n2 8\n2 9\n3 0\n3 1\n3 2\n3 3\n3 4\n3 5\n3 6\n3 7\n3 8\n3 9\n4 0\n4 1\n4 2\n4 3\n4 4\n4 5\n4 6\n4 7\n4 8\n4 9\n5 0\n5 1\n5 2\n5 3\n5 4\... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given a non-decreasing array of non-negative integers $a_1, a_2, \\ldots, a_n$. Also you are given a positive integer $k$.\n\nYou want to find $m$ non-decreasing arrays of non-negative integers $b_1, b_2, \\ldots,... | [{"type": "stdin_stdout", "input": "6\n4 1\n0 0 0 1\n3 1\n3 3 3\n11 3\n0 1 2 2 3 3 3 4 4 4 4\n5 3\n1 2 3 4 5\n9 4\n2 2 3 5 7 11 13 13 17\n10 7\n0 1 1 2 3 3 4 5 5 6\n", "output": "-1\n1\n2\n2\n2\n1\n"}, {"type": "stdin_stdout", "input": "1\n5 5\n1 1 1 1 1\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "1\n5 3\n... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nSuppose there is a $h \\times w$ grid consisting of empty or full cells. Let's make some definitions:\n\n $r_{i}$ is the number of consecutive full cells connected to the left side in the $i$-th row ($1 \\le i \\le h$). ... | [{"type": "stdin_stdout", "input": "19 16\n16 16 16 16 15 15 0 5 0 4 9 9 1 4 4 0 8 16 12\n6 12 19 15 8 6 19 19 14 6 9 16 10 11 15 4\n", "output": "797922655\n"}, {"type": "stdin_stdout", "input": "9 9\n9 9 9 9 9 9 9 9 9\n9 9 9 9 9 9 9 9 9\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "3 6\n0 0 0\n0 0 0 0 0 0\... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nTsumugi brought $n$ delicious sweets to the Light Music Club. They are numbered from $1$ to $n$, where the $i$-th sweet has a sugar concentration described by an integer $a_i$.\n\nYui loves sweets, but she can eat at most... | [{"type": "stdin_stdout", "input": "37 13\n164823 8992 21818 77521 130870 83201 174985 168799 9565 84443 105083 54131 130813 42829 98759 60103 198520 125068 59611 45609 124003 106143 54167 179002 103755 152802 146640 38512 91309 6660 131534 32533 67324 27272 49166 129157 41630\n", "output": "6660 15652 25217 47035 7430... | 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 colum... | [{"type": "stdin_stdout", "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": "stdin_stdout", "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... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nNauuo is a girl who loves playing chess.\n\nOne day she invented a game by herself which needs $n$ chess pieces to play on a $m\\times m$ chessboard. The rows and columns are numbered from $1$ to $m$. We denote a cell on ... | [{"type": "stdin_stdout", "input": "79\n", "output": "40\n1 1\n2 1\n3 1\n4 1\n5 1\n6 1\n7 1\n8 1\n9 1\n10 1\n11 1\n12 1\n13 1\n14 1\n15 1\n16 1\n17 1\n18 1\n19 1\n20 1\n21 1\n22 1\n23 1\n24 1\n25 1\n26 1\n27 1\n28 1\n29 1\n30 1\n31 1\n32 1\n33 1\n34 1\n35 1\n36 1\n37 1\n38 1\n39 1\n40 1\n40 2\n40 3\n40 4\n40 5\n40 6\n4... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nIgor has been into chess for a long time and now he is sick of the game by the ordinary rules. He is going to think of new rules of the game and become world famous.\n\nIgor's chessboard is a square of size n × n cells. I... | [{"type": "stdin_stdout", "input": "10\n...o.xxx.x\n..ooxxxxxx\n.x..x.x...\nx.xxx..ox.\nxx.xoo.xxx\n.......xxx\n.x.x.xx...\nxo..xo..xx\n....x....o\n.ox.xxx..x\n", "output": "YES\nxxxxxxxx...x.xxx.xx\n...x.xxx..xxxxxxxxx\n..xx...x......x...x\n.x....x...xxx..xx.x\nx.xx..............x\nxx.x...........xx.x\n.......x.x.x.x.... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nA long time ago, in a galaxy far far away two giant IT-corporations Pineapple and Gogol continue their fierce competition. Crucial moment is just around the corner: Gogol is ready to release it's new tablet Lastus 3000.\n... | [{"type": "stdin_stdout", "input": "sosossosossosossosossosossosossosossosossosossosossosossosossosossosossosossosossosossosossosossosos\nsos\n", "output": "20"}, {"type": "stdin_stdout", "input": "abcabcabcabcabcabcabcabcabcabc\nabcabcabcabcabcabcabcabcabcabc\n", "output": "1"}, {"type": "stdin_stdout", "input": "abca... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThe circle line of the Berland subway has n stations. We know the distances between all pairs of neighboring stations:\n\n\n\n d_1 is the distance between the 1-st and the 2-nd station;\n\n d_2 is the distance between the... | [{"type": "stdin_stdout", "input": "100\n3 6 23 4 23 1 2 14 2 3 3 9 17 8 10 5 1 14 8 5 7 4 13 8 5 6 24 3 12 3 4 9 2 8 2 1 2 1 3 2 1 6 14 23 8 6 3 5 7 8 18 9 2 5 22 6 13 16 2 4 31 20 4 3 3 6 6 1 1 18 5 11 1 14 4 16 6 37 11 1 8 3 7 11 21 14 3 3 12 2 5 1 9 16 3 1 3 4 4 2\n98 24\n", "output": "195\n"}, {"type": "stdin_stdo... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nLeo Jr. draws pictures in his notebook with checkered sheets (that is, each sheet has a regular square grid printed on it). We can assume that the sheets are infinitely large in any direction.\n\nTo draw a picture, Leo Jr... | [{"type": "stdin_stdout", "input": "23\n", "output": "73\n0 0\n0 1\n1 0\n1 1\n1 2\n2 1\n2 2\n2 3\n3 2\n3 3\n3 4\n4 3\n4 4\n4 5\n5 4\n5 5\n5 6\n6 5\n6 6\n6 7\n7 6\n7 7\n7 8\n8 7\n8 8\n8 9\n9 8\n9 9\n9 10\n10 9\n10 10\n10 11\n11 10\n11 11\n11 12\n12 11\n12 12\n12 13\n13 12\n13 13\n13 14\n14 13\n14 14\n14 15\n15 14\n15 15... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given a functional graph. It is a directed graph, in which from each vertex goes exactly one arc. The vertices are numerated from 0 to n - 1.\n\nGraph is given as the array f_0, f_1, ..., f_{n} - 1, where f_{i} — ... | [{"type": "stdin_stdout", "input": "20 10\n13 10 5 6 18 5 12 13 15 1 10 3 9 16 7 9 7 11 9 13\n2634 7980 171 3503 6601 9378 4618 8243 9343 1979 4172 7441 9722 9863 6041 4790 1737 7586 6461 228\n", "output": "62163 1737\n45528 4172\n84573 171\n48662 1979\n48053 1979\n93780 9378\n49331 1979\n67772 1737\n49124 1979\n43335 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nOkabe needs to renovate the Future Gadget Laboratory after he tried doing some crazy experiments! The lab is represented as an n by n square grid of integers. A good lab is defined as a lab in which every number not equal... | [{"type": "stdin_stdout", "input": "10\n3 2 6 5 1 2 1 1 2 1\n1 2 2 3 1 4 1 1 1 1\n1 1 3 1 2 2 2 1 1 1\n1 3 1 2 1 2 1 1 1 1\n12 1 4 3 3 1 1 1 2 1\n8 1 1 1 1 3 6 5 1 3\n1 1 1 2 4 1 3 2 1 1\n1 1 1 1 1 1 1 2 1 1\n1 2 1 1 1 1 1 1 1 1\n2 1 1 1 1 1 1 1 1 2\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "4\n1 1 1 1\... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere are $n$ children, who study at the school №41. It is well-known that they are good mathematicians. Once at a break, they arranged a challenge for themselves. All children arranged in a row and turned heads either to... | [{"type": "stdin_stdout", "input": "488 2493006\nRRRRRRRRRLRRRRRLLRLLRRRLRRLRLRRRLLRLLLLRRLRLLLRLRRLLRRRRRRLLRLRLRRLRLRLRRRRLRRRRLLRLRRRLRLRRLRRLLLLLRRLRRLLLLLRRRLLRRLRRLLLLRRRRRLRLRRRLRRRLLRRLRRRLLRLRLRRRRLLLRLLLLRRLLLLRRRLLRLLRRRRLRRLRRLRLRLLLRLLRRLLRLRRRRRRLLLLLLLLRRRLRRLRLLLRLRLRLLRLRRRRLRLRRLRRRLRRRLRRRLRRLLLRLLLL... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given an undirected connected weighted graph consisting of $n$ vertices and $m$ edges. Let's denote the length of the shortest path from vertex $1$ to vertex $i$ as $d_i$. \n\nYou have to erase some edges of the g... | [{"type": "stdin_stdout", "input": "9 9 7\n1 2 1000000000\n7 9 1000000000\n9 4 1000000000\n2 6 1000000000\n2 3 1000000000\n3 7 1000000000\n6 8 1000000000\n8 4 1000000000\n4 5 1000000000\n", "output": "7\n1 5 4 6 7 8 2 "}, {"type": "stdin_stdout", "input": "10 10 4\n1 2 1000000000\n2 3 1\n3 4 1000000000\n4 5 1000000000\... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given an array $a_1, a_2, \\dots, a_n$ of integer numbers.\n\nYour task is to divide the array into the maximum number of segments in such a way that:\n\n each element is contained in exactly one segment; each s... | [{"type": "stdin_stdout", "input": "100\n1065 362 1002 1071 502 252 1401 1824 887 1803 1572 1571 502 1408 1699 1750 1785 1507 1616 1458 372 323 939 1208 1639 1517 1145 319 935 1507 1094 156 1062 39 1884 1470 646 917 1699 631 39 789 1030 1589 1700 17 495 32 506 574 1458 206 1091 211 279 1617 1624 1183 572 1496 1014 2007... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nVasya is an administrator of a public page of organization \"Mouse and keyboard\" and his everyday duty is to publish news from the world of competitive programming. For each news he also creates a list of hashtags to mak... | [{"type": "stdin_stdout", "input": "2\n#aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab\n#aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n", "output": "#aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given an integer L. Construct a directed graph that satisfies the conditions below. The graph may contain multiple edges between the same pair of vertices. It can be proved that such a graph always exists.\n - The... | [{"type": "stdin_stdout", "input": "4\n", "output": "8 10\n1 2 0\n2 3 0\n3 4 0\n1 5 0\n2 6 0\n3 7 0\n4 8 0\n5 6 1\n6 7 1\n7 8 1\n"}, {"type": "stdin_stdout", "input": "5\n", "output": "5 7\n1 2 0\n2 3 1\n3 4 0\n4 5 0\n2 4 0\n1 3 3\n3 5 1\n"}, {"type": "stdin_stdout", "input": "1000000\n", "output": "1000000\n"}, {"type... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nSnuke has decided to play with a six-sided die. Each of its six sides shows an integer 1 through 6, and two numbers on opposite sides always add up to 7.\nSnuke will first put the die on the table with an arbitrary side f... | [{"type": "stdin_stdout", "input": "999999999999990\n", "output": "181818181818180\n"}, {"type": "stdin_stdout", "input": "999999999999991\n", "output": "181818181818181\n"}, {"type": "stdin_stdout", "input": "999999999999996\n", "output": "181818181818181\n"}, {"type": "stdin_stdout", "input": "999999999999997\n", "ou... | code_stdio |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.