messages
listlengths
1
1
ground_truth
stringlengths
88
726k
dataset
stringclasses
1 value
[ { "content": "Solve the following coding problem using the programming language python:\n\nBeing a nonconformist, Volodya is displeased with the current state of things, particularly with the order of natural numbers (natural number is positive integer number). He is determined to rearrange them. But there are ...
[{"type": "stdin_stdout", "input": "1000000000000 1000000000000\n", "output": "1000000000000\n"}, {"type": "stdin_stdout", "input": "1000000000000 1276759536556\n", "output": "1553519073112\n"}, {"type": "stdin_stdout", "input": "1000000000000 1000000000000\n", "output": "1000000000000"}, {"type": "stdin_stdout", "inpu...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nToday, Mezo is playing a game. Zoma, a character in that game, is initially at position $x = 0$. Mezo starts sending $n$ commands to Zoma. There are two possible commands: 'L' (Left) sets the position $x: =x - 1$; 'R' (...
[{"type": "stdin_stdout", "input": "13\nLRLLLLRRLLRLR\n", "output": "14\n"}, {"type": "stdin_stdout", "input": "13\nLRLLLLRRLLRLR\n", "output": "14\n"}, {"type": "stdin_stdout", "input": "13\nLRLRLLRLLLRLR\n", "output": "14\n"}, {"type": "stdin_stdout", "input": "13\nRLRLLRRLLLLRL\n", "output": "14\n"}, {"type": "stdin...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTaro made a sugoroku so that everyone can play at the children's association event. In order to make the game interesting, I wrote instructions such as \"advance 6\" and \"back 5\" in some of the sugoroku squares other th...
[{"type": "stdin_stdout", "input": "3\n3\n-1\n1\n-1\n3\n0\n4\n2\n0\n-6\n4\n2\n-1\n-7\n0", "output": "OK\nOK\nOK\nOK\n"}, {"type": "stdin_stdout", "input": "3\n3\n0\n1\n-1\n3\n0\n4\n2\n0\n-6\n4\n2\n-1\n-8\n0", "output": "OK\nOK\nOK\nOK\n"}, {"type": "stdin_stdout", "input": "3\n3\n0\n1\n-1\n3\n0\n4\n2\n0\n-6\n4\n2\n-1\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a binary array A=(A_1,A_2,\\cdots,A_N) of length N.\n\nProcess Q queries of the following types. The i-th query is represented by three integers T_i,L_i,R_i.\n\n* T_i=1: Replace the value of A_j with 1-A_j f...
[{"type": "stdin_stdout", "input": "5 9\n1 1 0 0 1\n2 1 4\n1 3 4\n2 2 5\n2 1 3\n2 1 2", "output": "4\n0\n0\n0\n0\n0\n0\n0\n"}, {"type": "stdin_stdout", "input": "5 8\n1 1 0 0 1\n2 1 4\n1 3 4\n2 3 5\n2 1 3\n2 1 2", "output": "4\n0\n0\n0\n0\n0\n0\n"}, {"type": "stdin_stdout", "input": "5 6\n1 1 0 0 0\n2 3 5\n2 3 4\n2 2 3...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOne day Vasya painted a Cartesian coordinate system on a piece of paper and marked some set of points (x1, y1), (x2, y2), ..., (xn, yn). Let's define neighbors for some fixed point from the given set (x, y): \n\n * point...
[{"type": "stdin_stdout", "input": "30\n507 836\n525 836\n-779 196\n507 -814\n525 -814\n525 42\n525 196\n525 -136\n-779 311\n507 -360\n525 300\n507 578\n507 311\n-779 836\n507 300\n525 -360\n525 311\n-779 -360\n-779 578\n-779 300\n507 42\n525 578\n-779 379\n507 196\n525 379\n507 379\n-779 -814\n-779 42\n-779 -136\n507 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\n<image>\n\n\nMy grandmother uses a balance. The balance will balance if you place the same size on both of the two dishes, otherwise it will tilt to the heavier side. The weights of the 10 weights are 1g, 2g, 4g, 8g, 16g,...
[{"type": "stdin_stdout", "input": "5\n11\n731", "output": "1 4\n1 2 8\n1 2 8 16 64 128 512\n"}, {"type": "stdin_stdout", "input": "5\n17\n731", "output": "1 4\n1 16\n1 2 8 16 64 128 512\n"}, {"type": "stdin_stdout", "input": "5\n17\n994", "output": "1 4\n1 16\n2 32 64 128 256 512\n"}, {"type": "stdin_stdout", "input":...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPasha has a positive integer a without leading zeroes. Today he decided that the number is too small and he should make it larger. Unfortunately, the only operation Pasha can do is to swap two adjacent decimal digits of t...
[{"type": "stdin_stdout", "input": "1541326723729813719 14\n", "output": "9541132672372813719\n"}, {"type": "stdin_stdout", "input": "219810011901120912 100\n", "output": "999822211111110000\n"}, {"type": "stdin_stdout", "input": "191919191919119911 100\n", "output": "999999991111111111\n"}, {"type": "stdin_stdout", "i...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA bracket sequence is a string containing only characters \"(\" and \")\". A regular bracket sequence (or, shortly, an RBS) is a bracket sequence that can be transformed into a correct arithmetic expression by inserting c...
[{"type": "stdin_stdout", "input": "10\n((((((((((((((((()))))))))))))))))\n(((((((((((((((())))))))))))))))\n((((((((((((((((((((()))))))))))))))))))))\n(((((((((((((((((((((())))))))))))))))))))))\n()()()()()()()()()()()()()()()()()()()()\n()()()()()()()()()()()()()()()()()()()()()()()()()()\n(((((((((((((((((())))))...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAiz Onsen has a bathhouse and a pool. To use the bathhouse, you need to buy a bathing ticket, and to use the pool, you need to buy a pool ticket. Prices for these tickets may vary from day to day. In addition, Aiz Onsen h...
[{"type": "stdin_stdout", "input": "2\n111 101 -1 -2\n1001 722 131 -3", "output": "-313\n106060\n"}, {"type": "stdin_stdout", "input": "2\n111 001 -1 -2\n1001 722 131 -3", "output": "-113\n106060\n"}, {"type": "stdin_stdout", "input": "2\n111 000 -1 -2\n1001 722 131 -3", "output": "-111\n106060\n"}, {"type": "stdin_std...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nJett is tired after destroying the town and she wants to have a rest. She likes high places, that's why for having a rest she wants to get high and she decided to craft staircases.\n\nA staircase is a squared figure that ...
[{"type": "stdin_stdout", "input": "4\n1\n10\n28\n0111101000000000100\n", "output": "1\n2\n2\n28\n"}, {"type": "stdin_stdout", "input": "4\n1\n10\n28\n0101101000000000100\n", "output": "1\n2\n2\n28\n"}, {"type": "stdin_stdout", "input": "4\n2\n10\n28\n0101101000000000100\n", "output": "1\n2\n2\n28\n"}, {"type": "stdin_...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an array $a$ consisting of $n$ integers $a_1, a_2, \\dots, a_n$.\n\nYour problem is to find such pair of indices $i, j$ ($1 \\le i < j \\le n$) that $lcm(a_i, a_j)$ is minimum possible.\n\n$lcm(x, y)$ is the...
[{"type": "stdin_stdout", "input": "4\n9999991 9999883 9999659 9999433\n", "output": "3 4\n"}, {"type": "stdin_stdout", "input": "4\n9999991 9999883 9999659 9999433\n", "output": "3 4\n"}, {"type": "stdin_stdout", "input": "4\n9999991 5101198 9999659 9999433\n", "output": "2 4\n"}, {"type": "stdin_stdout", "input": "3\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nToday, as a friendship gift, Bakry gave Badawy $n$ integers $a_1, a_2, \\dots, a_n$ and challenged him to choose an integer $X$ such that the value $\\underset{1 \\leq i \\leq n}{\\max} (a_i \\oplus X)$ is minimum possibl...
[{"type": "stdin_stdout", "input": "5\n1073741823 1073741823 181085488 1073741823 1073741823\n", "output": "536870912\n"}, {"type": "stdin_stdout", "input": "5\n1073741823 29972487 1073741823 1073741823 1073741823\n", "output": "536870912\n"}, {"type": "stdin_stdout", "input": "5\n219338430 29972487 1073741823 10737418...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTaro has decided to move. Taro has a lot of luggage, so I decided to ask a moving company to carry the luggage. Since there are various weights of luggage, I asked them to arrange them in order from the lightest one for e...
[{"type": "stdin_stdout", "input": "8\n7 2 1 3 8 5 4 6", "output": "20\n"}, {"type": "stdin_stdout", "input": "8\n5 2 1 3 8 6 4 7", "output": "18\n"}, {"type": "stdin_stdout", "input": "8\n6 4 1 1 8 5 4 7", "output": "20\n"}, {"type": "stdin_stdout", "input": "8\n6 2 1 3 8 5 4 7", "output": "19"}, {"type": "stdin_stdou...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou've got string s, consisting of only lowercase English letters. Find its lexicographically maximum subsequence.\n\nWe'll call a non-empty string s[p1p2... pk] = sp1sp2... spk(1 ≤ p1 < p2 < ... < pk ≤ |s|) a subsequence...
[{"type": "stdin_stdout", "input": "zyxzxzwyxywxxwabcdabdacdbcacdbcacabaaba\n", "output": "zzzyyxxwddddccbba\n"}, {"type": "stdin_stdout", "input": "zyxzxzwyxywxxwabcdabcacdbcacdbdacabaaba\n", "output": "zzzyyxxwddddcbba\n"}, {"type": "stdin_stdout", "input": "thankstosamarasauteddybearsforthiscontest\n", "output": "yt...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFor given a circle $c$ and a line $l$, print the coordinates of the cross points of them.\n\nConstraints\n\n* $p1$ and $p2$ are different\n* The circle and line have at least one cross point\n* $1 \\leq q \\leq 1,000$\n* ...
[{"type": "stdin_stdout", "input": "2 0 3\n2\n-1 -1 11 0\n1 -1 12 3", "output": "-0.83330025 -0.98610835 4.95743818 -0.50354682\n-0.55841103 -1.56669492 4.96717016 0.44260733\n"}, {"type": "stdin_stdout", "input": "2 -1 3\n2\n0 -1 14 0\n1 0 10 11", "output": "-0.99915098 -1.07136793 4.97884641 -0.64436811\n-0.76686667 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAs a German University in Cairo (GUC) student and a basketball player, Herr Wafa was delighted once he heard the news. GUC is finally participating in the Annual Basketball Competition (ABC). \n\nA team is to be formed of...
[{"type": "stdin_stdout", "input": "65 173 136\n26 18 8 11 1 22 44 6 15 22 13 49 30 36 37 41 25 27 9 36 36 1 45 20 7 47 28 30 30 21 33 32 9 11 16 5 19 12 44 40 25 40 32 36 15 34 4 43 28 19 29 33 7 11 18 13 40 18 10 26 1 48 20 38 1 20 34 8 46 8 32 35 16 49 26 36 11 16 4 29 35 44 14 21 22 42 10 1 3 12 35 30 14 45 2 24 32...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe clique problem is one of the most well-known NP-complete problems. Under some simplification it can be formulated as follows. Consider an undirected graph G. It is required to find a subset of vertices C of the maximu...
[{"type": "stdin_stdout", "input": "12\n66 4\n12 7\n60 1\n24 4\n48 4\n-1 4\n36 4\n30 4\n6 4\n54 4\n42 2\n18 4\n", "output": "8\n"}, {"type": "stdin_stdout", "input": "12\n67 4\n12 7\n60 1\n24 4\n48 4\n-1 4\n36 4\n30 4\n6 4\n54 4\n42 2\n18 4\n", "output": "8\n"}, {"type": "stdin_stdout", "input": "12\n67 8\n12 7\n60 1\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDZY loves Physics, and he enjoys calculating density.\n\nAlmost everything has density, even a graph. We define the density of a non-directed graph (nodes and edges of the graph have some values) as follows: $\\left\\{\\b...
[{"type": "stdin_stdout", "input": "20 20\n265918 744212 196368 74731 293587 679367 460805 632939 453630 565881 835276 606327 181087 721045 219431 849838 370939 582350 335676 32244\n2 16 989\n14 19 628\n1 6 483\n5 8 733\n13 19 556\n10 17 911\n2 7 599\n13 17 390\n10 20 965\n9 11 449\n3 15 310\n3 6 557\n14 18 225\n1 18 7...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are enthusiastic about the popular web game \"Moonlight Ranch\". The purpose of this game is to grow crops in the fields, sell them to earn income, and use that income to grow the ranch.\n\nYou wanted to grow the fiel...
[{"type": "stdin_stdout", "input": "5\nelppa 2 2 -1 1 1 0 1 13 1\nan`ban 1 0 3 9 2 2 4 1 0\ncatror 0 2 2 2 1 4 1 18 2\ncqniau 1 3 0 2 -1 3 1 -1 1\nfghplant 0 4 0 3 2 3 0 110 1\n4\nenoki 1 3 2 -1 6 3 1 10 1\ntpmato 1 0 0 10 0 3 -1 1 1\nqotato -1 0 8 4 1 -1 4 7 1\nonion 3 4 0 3 3 7 0 10 1\n3\na 15 1 1 1 1 1 1 14 5\nc 16 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet's call some positive integer classy if its decimal representation contains no more than $3$ non-zero digits. For example, numbers $4$, $200000$, $10203$ are classy and numbers $4231$, $102306$, $7277420000$ are not.\n...
[{"type": "stdin_stdout", "input": "4\n1 1000\n1024 1024\n65536 65536\n999999 1000001\n", "output": " 1000\n 1\n 0\n ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSeryozha conducts a course dedicated to building a map of heights of Stepanovo recreation center. He laid a rectangle grid of size $n \\times m$ cells on a map (rows of grid are numbered from $1$ to $n$ from north to sout...
[{"type": "stdin_stdout", "input": "3000 3000 4 10\n623629309 917769297 890844966 987654319\n", "output": "215591588260257\n"}, {"type": "stdin_stdout", "input": "3000 3000 10 4\n122375063 551934841 132649021 999999937\n", "output": "218197599525055\n"}, {"type": "stdin_stdout", "input": "3000 3000 1000 1000\n794639486...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nNatasha is planning an expedition to Mars for $n$ people. One of the important tasks is to provide food for each participant.\n\nThe warehouse has $m$ daily food packages. Each package has some food type $a_i$.\n\nEach pa...
[{"type": "stdin_stdout", "input": "4 100\n84 99 66 69 86 94 89 96 98 93 93 82 87 93 91 100 69 99 93 81 99 84 75 100 86 88 98 100 84 96 44 70 94 91 85 78 86 79 45 88 91 78 98 94 81 87 93 72 96 88 96 97 96 62 86 72 94 84 80 98 88 90 93 73 73 98 78 50 91 96 97 82 85 90 87 41 97 82 97 77 100 100 92 83 98 81 70 81 74 78 84...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou need to execute several tasks, each associated with number of processors it needs, and the compute power it will consume.\n\nYou have sufficient number of analog computers, each with enough processors for any task. Ea...
[{"type": "stdin_stdout", "input": "50\n83 43 73 75 11 53 6 43 67 38 83 12 70 27 60 13 9 79 61 30 29 71 10 11 95 87 26 26 19 99 13 47 66 93 91 47 90 75 68 3 22 29 59 12 44 41 64 3 99 100\n31 36 69 25 18 33 15 70 12 91 41 44 1 96 80 74 12 80 16 82 88 25 87 17 53 63 3 42 81 6 50 78 34 68 65 78 94 14 53 14 41 97 63 44 21 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTwo participants are each given a pair of distinct numbers from 1 to 9 such that there's exactly one number that is present in both pairs. They want to figure out the number that matches by using a communication channel y...
[{"type": "stdin_stdout", "input": "12 12\n6 7 5 4 7 8 2 9 12 5 3 5 1 6 7 3 7 9 5 7 1 8 6 8\n6 4 2 1 7 8 1 6 8 5 9 8 1 5 7 2 5 9 6 3 9 2 9 4\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "12 12\n1 6 2 6 8 3 6 4 4 8 7 2 7 5 9 4 2 4 9 5 8 5 3 2\n2 8 6 9 2 6 7 4 6 5 6 3 5 8 7 8 7 1 1 9 9 7 7 3\n", "output": "-1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are n cities in Berland. Each city has its index — an integer number from 1 to n. The capital has index r1. All the roads in Berland are two-way. The road system is such that there is exactly one path from the capit...
[{"type": "stdin_stdout", "input": "100 62 42\n45 66 13 18 93 47 83 19 41 66 5 70 16 29 54 28 65 91 92 24 90 54 7 40 77 53 68 58 70 65 68 30 94 80 16 18 69 21 94 1 99 61 97 2 69 15 79 38 61 46 88 32 57 84 35 18 17 77 38 91 84 2 53 54 68 19 13 78 62 16 63 17 76 49 28 45 94 13 35 69 37 56 12 41 95 70 57 24 45 84 87 65 14...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nEvery year a race takes place on the motorway between cities A and B. This year Vanya decided to take part in the race and drive his own car that has been around and bears its own noble name — The Huff-puffer.\n\nSo, Vasy...
[{"type": "stdin_stdout", "input": "76\n342 684 1027 1369 1711 2054 2396 2738 3081 3423 3765 4108 4450 4792 5135 5477 5819 6162 6504 6846 7189 7531 7873 8216 8558 8900 9243 9585 9927 10270 10612 10954 11297 11639 11981 12324 12666 13009 13351 13693 14036 14378 14720 15063 15405 15747 16090 16432 16774 17117 17459 17801...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe Little Elephant has an integer a, written in the binary notation. He wants to write this number on a piece of paper.\n\nTo make sure that the number a fits on the piece of paper, the Little Elephant ought to delete ex...
[{"type": "stdin_stdout", "input": "11100010010010000110101101101100111111001010001101101001001111010110010111001011010000001100110101000101111000001111101111110010000010101110011110101101010110001100011101111011100010011101100111110010111111100110101000000111101000000000110100100101111101000110101010101101001110001110...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nEven if the world is full of counterfeits, I still regard it as wonderful.\n\nPile up herbs and incense, and arise again from the flames and ashes of its predecessor — as is known to many, the phoenix does it like this.\n...
[{"type": "stdin_stdout", "input": "1000000000000000000 1000000000000000000\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "1000000000000000000 1000000000000000000\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "1000000000000000000 1000000000100000000\n", "output": "0\n"}, {"type": "stdin_stdout", "in...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRead problems statements in Mandarin Chinese and Russian as well. \n\nIn every contest there should be an easy problem about matrices. December Cook-Off is not an exception.\n\nGiven a matrix A which consists of n rows an...
[{"type": "stdin_stdout", "input": "1 2\n1 -1\n14 -2", "output": "10000006\n"}, {"type": "stdin_stdout", "input": "2 2\n-1 0\n8 -1", "output": "10000000\n"}, {"type": "stdin_stdout", "input": "2 2\n0 0\n14 -1", "output": "9999993\n"}, {"type": "stdin_stdout", "input": "1 2\n-1 2\n3 4", "output": "10000005\n"}, {"type":...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nHaving bought his own apartment, Boris decided to paper the walls in every room. Boris's flat has n rooms, each of which has the form of a rectangular parallelepiped. For every room we known its length, width and height o...
[{"type": "stdin_stdout", "input": "20\n110 466 472\n112 153 152\n424 492 490\n348 366 113\n208 337 415\n491 448 139\n287 457 403\n444 382 160\n325 486 284\n447 454 136\n216 412 418\n217 208 228\n109 436 291\n293 382 421\n483 339 174\n213 327 183\n278 268 147\n181 424 457\n388 289 430\n174 269 305\n20\n221 4 334\n257 4...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTo decide which is the strongest among Rock, Paper, and Scissors, we will hold an RPS tournament.\nThere are 2^k players in this tournament, numbered 0 through 2^k-1. Each player has his/her favorite hand, which he/she wi...
[{"type": "stdin_stdout", "input": "100 100\nPSRRPRRSPSPSSSPSSSPSSSSSPSRSPRRPSRSSPSPPRRSRRRRPSSRRRRPSPSPSSRPRPPRSSRSSPSRPRSRPPSRPRPRPSPSPRRSRSPSP\n", "output": "R\n"}, {"type": "stdin_stdout", "input": "100 100\nRRPSSPPPPSRSRPSSPRSPPSPRSRRPSSPRRPSPPSPSPPRSSRPRPRRSSPSRSSRPSRSRRPRPPPSSSRRRPPRRRSPRRSPSSRRRRRPPPRPP\n", "ou...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nArthur owns a ski resort on a mountain. There are $n$ landing spots on the mountain numbered from $1$ to $n$ from the top to the foot of the mountain. The spots are connected with one-directional ski tracks. All tracks go...
[{"type": "stdin_stdout", "input": "2\n4 6\n1 2\n1 3\n2 3\n2 4\n3 4\n3 4\n7 6\n1 2\n1 3\n2 4\n2 5\n3 6\n3 7\n", "output": "2\n3 4 \n4\n4 5 6 7 \n"}, {"type": "stdin_stdout", "input": "2\n4 6\n1 2\n1 3\n2 3\n2 4\n3 4\n3 4\n7 6\n1 2\n1 3\n2 4\n2 5\n3 6\n3 7\n", "output": "2\n3 4 \n4\n4 5 6 7 \n"}, {"type": "stdin_stdout"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYour city has n junctions. There are m one-way roads between the junctions. As a mayor of the city, you have to ensure the security of all the junctions.\n\nTo ensure the security, you have to build some police checkposts...
[{"type": "stdin_stdout", "input": "100\n174 174 49 152 10 185 101 157 28 177 105 83 155 178 119 123 197 197 56 174 39 53 85 94 72 166 71 43 177 123 186 11 64 82 145 81 11 29 100 10 106 45 138 79 131 90 80 104 149 116 129 30 96 192 11 182 92 157 95 136 152 38 68 34 42 95 164 134 117 75 186 185 28 146 86 24 147 12 166 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRead the coordinates of four different points on the plane, $ A (x_A, y_A) $, $ B (x_B, y_B) $, $ C (x_C, y_C) $, $ D (x_D, y_D) $, and straight line $ Create a program that outputs YES if AB $ and $ CD $ are orthogonal, ...
[{"type": "stdin_stdout", "input": "3.338679167476614 4.153021285774258 3.5962681645685493 3.0562783924178016 0.7824583380395241 0.6535611152381731 1.4307644766957708 0.2352661769827814\n2.6749426974072605 2.336361124342693 3.280415305064114 1.6735605571901062 -0.04476814775527138 2.2725919391555047 3.1294550602222495 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nproblem\n\nThere are the following two-player card games.\n\n* This game uses a total of 2n cards with each integer from 1 to 2n written on it. Here, n is an integer between 1 and 100.\n* Deal n cards to each of the two.\...
[{"type": "stdin_stdout", "input": "5\n1\n7\n9\n6\n4\n10\n10\n7\n13\n18\n1\n11\n12\n17\n5\n19\n0", "output": "0\n1\n2\n0\n"}, {"type": "stdin_stdout", "input": "5\n1\n7\n9\n6\n4\n10\n10\n7\n13\n18\n1\n20\n12\n17\n5\n19\n0", "output": "0\n1\n4\n0\n"}, {"type": "stdin_stdout", "input": "5\n1\n2\n9\n6\n10\n10\n16\n7\n14\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nHave you ever played Hanabi? If not, then you've got to try it out! This problem deals with a simplified version of the game.\n\nOverall, the game has 25 types of cards (5 distinct colors and 5 distinct values). Borya is ...
[{"type": "stdin_stdout", "input": "100\nW4 Y1 W5 R4 W3 Y1 R4 W2 G3 G1 B5 Y5 Y2 Y3 G4 B5 W1 G5 Y5 Y3 G2 Y5 Y5 G5 R2 B3 B1 W5 Y1 W5 B4 W4 R4 B1 R1 W3 R5 R4 G2 W3 W3 R2 W5 Y2 B2 R3 R3 Y1 G5 G2 Y1 R4 Y5 W5 G5 B3 W2 R1 B2 W2 W2 Y5 W3 G1 B1 G2 Y3 W3 G1 W5 W1 G5 G2 Y1 W5 B5 W4 Y5 G2 R3 B4 R5 B1 R1 B4 Y4 Y4 Y3 R5 Y3 B3 W5 R5 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWelcome to PC Koshien, players. At PC Koshien, competitions are currently being held in a total of three categories: programming category, mobile category, and Ichimai's picture CG category.\n\nGiven the number of partici...
[{"type": "stdin_stdout", "input": "0000 1000 1000", "output": "2000\n"}, {"type": "stdin_stdout", "input": "0000 0000 1000", "output": "1000\n"}, {"type": "stdin_stdout", "input": "0001 0000 1000", "output": "1001\n"}, {"type": "stdin_stdout", "input": "0101 0000 1000", "output": "1101\n"}, {"type": "stdin_stdout", "i...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPhone number in Berland is a sequence of n digits. Often, to make it easier to memorize the number, it is divided into groups of two or three digits. For example, the phone number 1198733 is easier to remember as 11-987-3...
[{"type": "stdin_stdout", "input": "100\n4004223124942730640235383244438257614581534320356060987241659784249551110165034719443327659510644224\n", "output": "40-04-22-31-24-94-27-30-64-02-35-38-32-44-43-82-57-61-45-81-53-43-20-35-60-60-98-72-41-65-97-84-24-95-51-11-01-65-03-47-19-44-33-27-65-95-10-64-42-24\n"}, {"type":...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given N points on a plane. Write a program which will find the sum of squares of distances between all pairs of points.\n\nInput\n\nThe first line of input contains one integer number N (1 ≤ N ≤ 100 000) — the num...
[{"type": "stdin_stdout", "input": "30\n-7 -23\n-2 5\n13 8\n12 17\n15 -18\n20 6\n21 8\n-13 12\n-4 -20\n-11 -16\n-6 16\n1 -1\n5 -12\n13 -17\n11 10\n8 -9\n-13 3\n19 -13\n-19 -8\n-14 10\n10 3\n-16 -8\n-17 16\n-14 -15\n5 1\n-13 -14\n13 17\n-12 -8\n2 1\n18 5\n", "output": "279169\n"}, {"type": "stdin_stdout", "input": "30\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet's call a sequence $b_1, b_2, b_3 \\dots, b_{k - 1}, b_k$ almost increasing if $$\\min(b_1, b_2) \\le \\min(b_2, b_3) \\le \\dots \\le \\min(b_{k - 1}, b_k).$$ In particular, any sequence with no more than two elements...
[{"type": "stdin_stdout", "input": "3\n8\n1 2 7 3 2 1 2 3\n2\n2 1\n7\n4 1 5 2 6 3 7\n", "output": "\n6\n2\n7\n"}, {"type": "stdin_stdout", "input": "3\n8\n1 2 7 3 2 1 2 3\n2\n2 1\n7\n4 1 5 2 6 3 7\n", "output": "6\n2\n7\n"}, {"type": "stdin_stdout", "input": "3\n8\n1 2 7 3 2 1 2 5\n2\n2 1\n7\n4 1 5 2 6 3 7\n", "output"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMany years ago Berland was a small country where only $n$ people lived. Each person had some savings: the $i$-th one had $a_i$ burles.\n\nThe government considered a person as wealthy if he had at least $x$ burles. To inc...
[{"type": "stdin_stdout", "input": "4\n4 3\n6 1 2 1\n4 10\n11 9 11 18\n2 5\n4 3\n3 7\n9 4 11\n", "output": "3\n4\n0\n3\n"}, {"type": "stdin_stdout", "input": "4\n4 3\n10 1 2 1\n4 10\n11 7 11 9\n2 5\n4 3\n3 7\n9 2 9\n", "output": "4\n3\n0\n2\n"}, {"type": "stdin_stdout", "input": "4\n4 3\n10 1 3 1\n4 10\n11 7 11 9\n2 5\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA subsequence of length |x| of string s = s1s2... s|s| (where |s| is the length of string s) is a string x = sk1sk2... sk|x| (1 ≤ k1 < k2 < ... < k|x| ≤ |s|).\n\nYou've got two strings — s and t. Let's consider all subseq...
[{"type": "stdin_stdout", "input": "ctkhagrifaztmnxhmqztzibnmzzkojiztvrkfeoqegvwtbxlvvjhebshqaicsovtkcdovytimjggglyxlvglgunbohnkxargymbqvzgsnvjzgxivdgnaesgxqcruaopjuqsyyorrobnelehjnxcetveehlbmeskptivsuhuqupbieumycwczxyqjtwfofehfkpqmjngygwxkaviuyouiippgvlxjgtkxmhcwtzacbllsybgiujyryngapfwjkkyapfgxtcdpc\nctkhagrifaztmnxhm...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given integers N and K. Find the number of triples (a,b,c) of positive integers not greater than N such that a+b,b+c and c+a are all multiples of K.\nThe order of a,b,c does matter, and some of them can be the sam...
[{"type": "stdin_stdout", "input": "200000 1\n", "output": "8000000000000000\n"}, {"type": "stdin_stdout", "input": "200000 2\n", "output": "2000000000000000\n"}, {"type": "stdin_stdout", "input": "200000 3\n", "output": "296287407496296\n"}, {"type": "stdin_stdout", "input": "100004 8\n", "output": "3906718787501\n"},...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasily has a number a, which he wants to turn into a number b. For this purpose, he can do two types of operations: multiply the current number by 2 (that is, replace the number x by 2·x); append the digit 1 to the righ...
[{"type": "stdin_stdout", "input": "1 536870912\n", "output": "YES\n30\n1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 65536 131072 262144 524288 1048576 2097152 4194304 8388608 16777216 33554432 67108864 134217728 268435456 536870912 \n"}, {"type": "stdin_stdout", "input": "1 536870912\n", "output": "YES...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\n<image>\n\nInput\n\nThe input contains two integers a, b (1 ≤ a ≤ 10, 0 ≤ b ≤ 22·a - 1) separated by a single space.\n\nOutput\n\nOutput two integers separated by a single space.\n\nExamples\n\nInput\n\n1 0\n\n\nOutput\n\...
[{"type": "stdin_stdout", "input": "10 165056\n", "output": "391 431\n"}, {"type": "stdin_stdout", "input": "10 595169\n", "output": "619 770\n"}, {"type": "stdin_stdout", "input": "10 156555\n", "output": "468 325\n"}, {"type": "stdin_stdout", "input": "10 140634\n", "output": "323 383"}, {"type": "stdin_stdout", "inp...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe Little Elephant loves Ukraine very much. Most of all he loves town Rozdol (ukr. \"Rozdil\").\n\nHowever, Rozdil is dangerous to settle, so the Little Elephant wants to go to some other town. The Little Elephant doesn'...
[{"type": "stdin_stdout", "input": "100\n922 938 103 689 526 118 314 496 373 47 224 544 495 656 804 754 269 356 354 536 817 597 787 178 516 659 790 993 786 169 866 779 997 350 674 310 219 546 564 893 402 449 751 628 329 686 392 951 716 439 332 563 215 146 746 311 866 773 548 1100 731 183 890 802 488 944 473 25 662 559 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a string s consisting of `A`, `B` and `C`.\n\nSnuke wants to perform the following operation on s as many times as possible:\n\n* Choose a contiguous substring of s that reads `ABC` and replace it with `BCA`...
[{"type": "stdin_stdout", "input": "ABBACCBACCBCAABCB", "output": "2\n"}, {"type": "stdin_stdout", "input": "ACBAACBCCABCCBBBA", "output": "1\n"}, {"type": "stdin_stdout", "input": "ABCAACBCAABCCBBBC", "output": "3\n"}, {"type": "stdin_stdout", "input": "ACCAAABCAABCCBBBC", "output": "8\n"}, {"type": "stdin_stdout", "i...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPolycarpus is the director of a large corporation. There are n secretaries working for the corporation, each of them corresponds via the famous Spyke VoIP system during the day. We know that when two people call each othe...
[{"type": "stdin_stdout", "input": "123\n0 6361 8903 10428 0 258 0 10422 0 0 2642 1958 0 0 0 0 0 8249 1958 0 0 2642 0 0 0 11566 4709 1847 3998 0 1331 0 0 10289 2739 6135 3450 0 0 10994 6069 4337 5854 1331 5854 0 630 630 11244 5928 2706 0 683 214 0 9080 0 0 0 10422 683 11566 10994 0 0 3450 11244 11542 3998 1847 2708 987...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWhile doing some spring cleaning, Daniel found an old calculator that he loves so much. However, it seems like it is broken. When he tries to compute $1 + 3$ using the calculator, he gets $2$ instead of $4$. But when he t...
[{"type": "stdin_stdout", "input": "3\n1 8\n378 590\n0 1001000\n", "output": "26\n3586\n3444149719\n"}, {"type": "stdin_stdout", "input": "3\n0 4\n378 590\n1 1000000\n", "output": "17\n3586\n3439863766\n"}, {"type": "stdin_stdout", "input": "3\n1 4\n323 590\n1 1000000\n", "output": "8\n4758\n3439863766\n"}, {"type": "s...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLately, Mr. Chanek frequently plays the game Arena of Greed. As the name implies, the game's goal is to find the greediest of them all, who will then be crowned king of Compfestnesia.\n\nThe game is played by two people t...
[{"type": "stdin_stdout", "input": "2\n18\n122\n", "output": "14\n114\n"}, {"type": "stdin_stdout", "input": "2\n20\n122\n", "output": "15\n114\n"}, {"type": "stdin_stdout", "input": "2\n12\n122\n", "output": "9\n114\n"}, {"type": "stdin_stdout", "input": "2\n10\n122\n", "output": "8\n114\n"}, {"type": "stdin_stdout", ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe annual college sports-ball tournament is approaching, which for trademark reasons we'll refer to as Third Month Insanity. There are a total of 2^{N} teams participating in the tournament, numbered from 1 to 2^{N}. The...
[{"type": "stdin_stdout", "input": "3\n0 0 100 0 100 0 0 0\n100 0 100 0 0 0 100 100\n0 0 0 100 100 0 0 0\n100 100 0 0 0 0 100 100\n0 100 0 100 0 0 100 0\n100 100 100 100 100 0 0 0\n100 0 100 0 0 100 0 0\n100 0 100 0 100 100 100 0\n", "output": "12.00000000000000"}, {"type": "stdin_stdout", "input": "3\n0 53 31 33 2 34 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nNezzar has a binary string s of length n that he wants to share with his best friend, Nanako. Nanako will spend q days inspecting the binary string. At the same time, Nezzar wants to change the string s into string f duri...
[{"type": "stdin_stdout", "input": "4\n5 2\n00000\n00111\n1 5\n1 3\n2 1\n00\n01\n1 2\n10 6\n1111111111\n0110001110\n1 10\n5 9\n7 10\n1 7\n3 5\n6 10\n5 2\n10000\n11000\n2 5\n1 3\n", "output": "\nYES\nNO\nYES\nNO\n"}, {"type": "stdin_stdout", "input": "4\n5 2\n00000\n00111\n1 5\n1 3\n2 1\n00\n01\n1 2\n10 6\n1111111111\n0...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFor a positive integer n, let us define f(n) as the number of digits in base 10.\nYou are given an integer S.\nCount the number of the pairs of positive integers (l, r) (l \\leq r) such that f(l) + f(l + 1) + ... + f(r) =...
[{"type": "stdin_stdout", "input": "100000000\n", "output": "914705724\n"}, {"type": "stdin_stdout", "input": "91304885\n", "output": "555850206\n"}, {"type": "stdin_stdout", "input": "89317875\n", "output": "494668252\n"}, {"type": "stdin_stdout", "input": "78876118\n", "output": "915018436\n"}, {"type": "stdin_stdout...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a chessboard consisting of $n$ rows and $n$ columns. Rows are numbered from bottom to top from $1$ to $n$. Columns are numbered from left to right from $1$ to $n$. The cell at the intersection of the $x$-th ...
[{"type": "stdin_stdout", "input": "5 3 5\n4 4\n3 5\n2 4\n3 4\n3 5\n", "output": "0\n1\n2\n2\n1\n"}, {"type": "stdin_stdout", "input": "5 5 5\n4 4\n3 5\n2 4\n3 4\n3 5\n", "output": "0\n2\n3\n3\n2\n"}, {"type": "stdin_stdout", "input": "5 5 5\n4 4\n3 5\n2 3\n3 3\n3 5\n", "output": "0\n2\n2\n3\n2\n"}, {"type": "stdin_std...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nKris works in a large company \"Blake Technologies\". As a best engineer of the company he was assigned a task to develop a printer that will be able to print horizontal and vertical strips. First prototype is already bui...
[{"type": "stdin_stdout", "input": "17 1 1\n2 1 1000000000\n", "output": "1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n"}, {"type": "stdin_stdout", "input": "10 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYeah, we failed to make up a New Year legend for this problem.\n\nA permutation of length $n$ is an array of $n$ integers such that every integer from $1$ to $n$ appears in it exactly once. \n\nAn element $y$ of permutati...
[{"type": "stdin_stdout", "input": "5\n3 1\n15 21\n4 13\n13 2\n8 1\n", "output": "1 2 3\n1 2 3 4 5 6 7 8 9 10 15 13 14 11 12\n-1\n1 2 3 4 5 6 7 8 9 10 11 13 12\n1 2 3 4 5 6 7 8\n"}, {"type": "stdin_stdout", "input": "5\n3 2\n10 21\n4 13\n13 2\n8 1\n", "output": "1 3 2\n1 2 3 4 5 10 8 9 6 7\n-1\n1 2 3 4 5 6 7 8 9 10 11 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are n games in a football tournament. Three teams are participating in it. Currently k games had already been played. \n\nYou are an avid football fan, but recently you missed the whole k games. Fortunately, you rem...
[{"type": "stdin_stdout", "input": "5\n3 0 0 0\n3 3 0 0\n6 4 1 0\n6 6 0 0\n3 3 3 2\n", "output": "yes\nyes\nyes\nyes\nno\n"}, {"type": "stdin_stdout", "input": "5\n3 0 0 0\n3 3 0 0\n6 4 1 0\n6 3 3 -1\n3 3 3 2\n", "output": "yes\nyes\nyes\nno\nno\n"}, {"type": "stdin_stdout", "input": "5\n3 0 0 0\n3 3 0 0\n6 4 1 0\n6 3 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAmugae has a hotel consisting of $10$ rooms. The rooms are numbered from $0$ to $9$ from left to right.\n\nThe hotel has two entrances — one from the left end, and another from the right end. When a customer arrives to th...
[{"type": "stdin_stdout", "input": "100\nLLLLLLLLLL0L2L48LL6L7L7L0L3L0L63LL3L4L9L2L7L6L3L8L2L5L9L0L3L3L9L3L3L3L5L2L2L2L1L8L5L7L9L2L05L0LL6L2L\n", "output": "1111111111\n"}, {"type": "stdin_stdout", "input": "100\nRRLLLLLLRR1R7R3L2R0L52RR2R4L1L7L6R4R0R4L5L4L5R2R8L7R0R6R4R8L6L8L4R5R7R3L9R7L64RR8L0R6R4R9L0R9R7R7R0L\n", "o...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFor given n points in metric space, find the distance of the closest points.\n\nConstraints\n\n* 2 ≤ n ≤ 100,000\n* -100 ≤ x, y ≤ 100\n\nInput\n\n\nn\nx0 y0\nx1 y1\n:\nxn-1 yn-1\n\n\nThe first integer n is the number of p...
[{"type": "stdin_stdout", "input": "3\n1.2898350068806816 1.1467446289152408\n2.4176469021911005 0.7451543895838713\n1.341841261706021 1.7448621958767283", "output": "0.600374279\n"}, {"type": "stdin_stdout", "input": "3\n1.2898350068806816 1.8470651543589152\n3.7080917383371705 0.7451543895838713\n1.341841261706021 1....
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOne day Squidward, Spongebob and Patrick decided to go to the beach. Unfortunately, the weather was bad, so the friends were unable to ride waves. However, they decided to spent their time building sand castles.\n\nAt the...
[{"type": "stdin_stdout", "input": "101\n1 50 170 269 214 153 132 234 181 188 180 225 226 200 197 122 181 168 160 220 223 160 235 94 257 145 199 235 102 146 119 60 109 134 209 260 210 191 180 271 236 195 155 169 166 143 106 102 208 137 278 269 156 251 198 165 111 198 151 213 256 121 276 163 179 285 104 99 139 122 188 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThis is a story of a world somewhere far from the earth. In this world, the land is parted into a number of countries ruled by empires. This world is not very peaceful: they have been involved in army race.\n\nThey are co...
[{"type": "stdin_stdout", "input": "3 3\n3 4 1 1\n2 1 5\n2 3 3\n3 6\n3 2 5 1\n2 1 5\n2 3 3\n0 0", "output": "Yes\nYes\n"}, {"type": "stdin_stdout", "input": "3 6\n3 8 1 1\n2 2 6\n2 2 3\n3 3\n3 2 5 1\n2 1 11\n2 3 3\n0 0", "output": "Yes\nNo\n"}, {"type": "stdin_stdout", "input": "3 2\n3 11 1 1\n2 2 8\n2 2 3\n3 5\n3 4 5 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nBecause of budget cuts one IT company established new non-financial reward system instead of bonuses.\n\nTwo kinds of actions are rewarded: fixing critical bugs and suggesting new interesting features. A man who fixed a c...
[{"type": "stdin_stdout", "input": "444\n", "output": "2159776046970635520\n"}, {"type": "stdin_stdout", "input": "498\n", "output": "5392730685240975000"}, {"type": "stdin_stdout", "input": "500\n", "output": "5567867859752100000"}, {"type": "stdin_stdout", "input": "500\n", "output": "5567867859752100000"}, {"type": ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRoma is playing a new expansion for his favorite game World of Darkraft. He made a new character and is going for his first grind.\n\nRoma has a choice to buy exactly one of n different weapons and exactly one of m differ...
[{"type": "stdin_stdout", "input": "10 10 10\n51 87\n68 743\n82 1284\n73 936\n55 242\n89 1554\n58 357\n66 666\n62 512\n51 87\n92 1670\n56 280\n56 280\n91 1631\n77 1091\n89 1554\n61 473\n98 1901\n77 1091\n77 1091\n86 15 386\n43 58 386\n68 33 386\n39 62 386\n95 6 386\n74 27 386\n94 7 386\n17 84 386\n97 4 386\n45 56 386\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWe guessed some integer number $x$. You are given a list of almost all its divisors. Almost all means that there are all divisors except $1$ and $x$ in the list.\n\nYour task is to find the minimum possible integer $x$ th...
[{"type": "stdin_stdout", "input": "25\n2\n999389 999917\n2\n999307 999613\n2\n999529 999611\n2\n999221 999853\n2\n999683 999433\n2\n999907 999749\n2\n999653 999499\n2\n999769 999931\n2\n999809 999287\n2\n999233 999239\n2\n999553 999599\n2\n999371 999763\n2\n999491 999623\n2\n999961 999773\n2\n999671 999269\n2\n999883 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAccording to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most d centimeters. Captain Bob ...
[{"type": "stdin_stdout", "input": "100 100\n51 93 101 960 2 477 213 129 663 925 254 78 1486 274 160 481 132 156 589 372 3 57 210 298 1771 7 359 468 254 406 202 929 221 366 552 97 555 29 634 118 539 140 992 854 7 163 134 103 940 30 409 1003 564 43 555 79 107 40 23 103 643 171 310 382 770 288 18 189 570 177 29 54 855 17...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAlyona's mother wants to present an array of n non-negative integers to Alyona. The array should be special. \n\nAlyona is a capricious girl so after she gets the array, she inspects m of its subarrays. Subarray is a set ...
[{"type": "stdin_stdout", "input": "15 10\n1 9\n4 8\n4 8\n5 9\n1 9\n3 5\n1 6\n1 9\n2 6\n6 9\n", "output": "3\n0 1 2 0 1 2 0 1 2 0 1 2 0 1 2\n"}, {"type": "stdin_stdout", "input": "15 10\n1 9\n4 8\n4 8\n5 9\n1 9\n3 5\n1 6\n1 9\n4 6\n6 9\n", "output": "3\n0 1 2 0 1 2 0 1 2 0 1 2 0 1 2\n"}, {"type": "stdin_stdout", "input...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPolycarpus has postcards and photos hung in a row on the wall. He decided to put them away to the closet and hang on the wall a famous painter's picture. Polycarpus does it like that: he goes from the left to the right an...
[{"type": "stdin_stdout", "input": "CPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCP\n", "output": "100\n"}, {"type": "stdin_stdout", "input": "PPPPPPPPPPPPPPPPPPPPPPPCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCPPPPPCCCPPPPCCCCCPCC\n", "output": "23\n"}, ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\n[INSPION FullBand Master - INSPION](https://www.youtube.com/watch?v=kwsciXm_7sA)\n\n[INSPION - IOLITE-SUNSTONE](https://www.youtube.com/watch?v=kwsciXm_7sA)\n\nOn another floor of the A.R.C. Markland-N, the young man Simo...
[{"type": "stdin_stdout", "input": "50\n21 10\n30 22\n3 37\n37 32\n4 27\n18 10\n2 30\n29 19\n6 37\n12 39\n47 25\n41 49\n45 9\n25 48\n16 14\n10 7\n33 28\n3 31\n34 16\n35 37\n27 40\n45 16\n29 44\n16 15\n26 3\n1 12\n2 13\n15 21\n43 14\n9 33\n44 15\n46 1\n38 5\n15 5\n1 32\n42 35\n20 27\n23 12\n1 16\n15 17\n36 50\n13 8\n49 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an array $a$ of $n$ integers and an integer $s$. It is guaranteed that $n$ is odd.\n\nIn one operation you can either increase or decrease any single element by one. Calculate the minimum number of operation...
[{"type": "stdin_stdout", "input": "7 33\n21 15 12 11 20 19 12\n", "output": "57\n"}, {"type": "stdin_stdout", "input": "7 20\n2 15 12 11 20 19 12\n", "output": "14\n"}, {"type": "stdin_stdout", "input": "7 20\n1 15 12 11 29 20 12\n", "output": "13\n"}, {"type": "stdin_stdout", "input": "7 20\n1 13 12 11 29 20 12\n", "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFor a given weighted graph $G = (V, E)$, find the shortest path from a source to each vertex. For each vertex $u$, print the total weight of edges on the shortest path from vertex $0$ to $u$.\n\nConstraints\n\n* $1 \\leq ...
[{"type": "stdin_stdout", "input": "5\n0 3 2 4 3 1 1 2\n1 2 3 3 3 4\n2 3 0 3 3 2 4 1\n3 4 0 1 0 -1 1 0 3 3\n4 2 0 1 3 3", "output": "0 0\n1 1\n2 4\n3 1\n4 5\n"}, {"type": "stdin_stdout", "input": "5\n0 3 2 4 3 1 1 2\n1 2 1 4 3 4\n2 3 0 10 3 0 4 1\n3 4 0 1 0 1 1 1 1 3\n4 2 2 1 3 3", "output": "0 0\n1 2\n2 4\n3 1\n4 5\n"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDima is a beginner programmer. During his working process, he regularly has to repeat the following operation again and again: to remove every second element from the array. One day he has been bored with easy solutions o...
[{"type": "stdin_stdout", "input": "15 12\n2\n10\n5\n2\n8\n2\n8\n6\n4\n10\n12\n1\n", "output": "12\n13\n3\n12\n10\n12\n10\n14\n9\n13\n11\n1\n"}, {"type": "stdin_stdout", "input": "15 12\n9\n10\n5\n2\n8\n2\n8\n6\n4\n10\n12\n1\n", "output": "5\n13\n3\n12\n10\n12\n10\n14\n9\n13\n11\n1\n"}, {"type": "stdin_stdout", "input"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGiven is a three-digit integer N. Does N contain the digit 7?\nIf so, print Yes; otherwise, print No.\n\n-----Constraints-----\n - 100 \\leq N \\leq 999\n\n-----Input-----\nInput is given from Standard Input in the follow...
[{"type": "stdin_stdout", "input": "117\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "777\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "974\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "477\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "758\n", "output": "Yes\n"}, {"ty...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given two binary strings $x$ and $y$, which are binary representations of some two integers (let's denote these integers as $f(x)$ and $f(y)$). You can choose any integer $k \\ge 0$, calculate the expression $s_k ...
[{"type": "stdin_stdout", "input": "4\n1010\n11\n10001\n110\n1\n1\n1010101010101\n11110000\n", "output": "1\n3\n0\n0\n"}, {"type": "stdin_stdout", "input": "4\n1010\n11\n10001\n110\n1\n1\n1010101010100\n11110000\n", "output": "1\n3\n0\n0\n"}, {"type": "stdin_stdout", "input": "4\n1010\n11\n10001\n110\n1\n1\n10101010101...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet's assume that v(n) is the largest prime number, that does not exceed n;\n\n u(n) is the smallest prime number strictly greater than n. \n\nFind $\\sum_{i = 2}^{n} \\frac{1}{v(i) u(i)}$.\n\n\n-----Input-----\n\nThe f...
[{"type": "stdin_stdout", "input": "6\n885\n419\n821\n635\n63\n480\n", "output": "781453/1566442\n175559/352798\n674039/1351366\n403199/808942\n3959/8174\n232303/466546\n"}, {"type": "stdin_stdout", "input": "6\n885\n419\n821\n635\n63\n480\n", "output": "781453/1566442\n175559/352798\n674039/1351366\n403199/808942\n395...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere is little time left before the release of the first national operating system BerlOS. Some of its components are not finished yet — the memory manager is among them. According to the developers' plan, in the first r...
[{"type": "stdin_stdout", "input": "47 43\nerase 1\nalloc 95\nalloc 53\nerase 2\ndefragment\nalloc 100\nerase 4\nerase 2\nerase -849472053\ndefragment\nerase -638355221\nalloc 90\nerase 3\nerase 2\ndefragment\nalloc 17\nerase 5\ndefragment\nerase 6\ndefragment\nerase 3\ndefragment\ndefragment\nalloc 99\nalloc 69\nalloc...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRead problems statements in Mandarin Chinese, Russian and Vietnamese as well. \n\nArrays have fallen out of Chef's good books, and he plans to destroy all arrays he possesses. He is left with the last array A, consisting ...
[{"type": "stdin_stdout", "input": "3\n2\n1 1\n2\n1 1\n3\n1 2 -1", "output": "2\n2\n2\n"}, {"type": "stdin_stdout", "input": "3\n2\n1 1\n2\n1 2\n3\n1 2 -1", "output": "2\n1\n2\n"}, {"type": "stdin_stdout", "input": "3\n2\n1 2\n2\n1 1\n3\n1 2 -1", "output": "1\n2\n2\n"}, {"type": "stdin_stdout", "input": "3\n2\n2 2\n2\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThanos sort is a supervillain sorting algorithm, which works as follows: if the array is not sorted, snap your fingers* to remove the first or the second half of the items, and repeat the process.\n\nGiven an input array,...
[{"type": "stdin_stdout", "input": "16\n12 17 18 51 49 54 107 59 68 74 88 91 98 100 66 49\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "16\n12 17 18 51 52 54 56 59 68 74 88 91 98 100 66 49\n", "output": "8\n"}, {"type": "stdin_stdout", "input": "16\n12 17 18 51 52 54 56 59 68 74 88 91 98 100 66 49\n", "outpu...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWrite a program that takes in a letterclass ID of a ship and display the equivalent string class description of the given ID. Use the table below.\n\nClass ID Ship ClassB or bBattleShipC or cCruiserD or dDestroyerF or fFr...
[{"type": "stdin_stdout", "input": "3 \nB\nb\nB", "output": "BattleShip\nBattleShip\nBattleShip\n"}, {"type": "stdin_stdout", "input": "3 \nD\nb\nB", "output": "Destroyer\nBattleShip\nBattleShip\n"}, {"type": "stdin_stdout", "input": "3 \nB\nb\nD", "output": "BattleShip\nBattleShip\nDestroyer\n"}, {"type": "stdin_stdou...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a text of single-space separated words, consisting of small and capital Latin letters.\n\nVolume of the word is number of capital letters in the word. Volume of the text is maximum volume of all words in the...
[{"type": "stdin_stdout", "input": "200\nLBmJKQLCKUgtTxMoDsEerwvLOXsxASSydOqWyULsRcjMYDWdDCgaDvBfATIWPVSXlbcCLHPYahhxMEYUiaxoCebghJqvmRnaNHYTKLeOiaLDnATPZAOgSNfBzaxLymTGjfzvTegbXsAthTxyDTcmBUkqyGlVGZhoazQzVSoKbTFcCRvYsgSCwjGMxBfWEwMHuagTBxkz\n", "output": "105\n"}, {"type": "stdin_stdout", "input": "200\nAAAAAAAAAAAAAA...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDima loves Inna very much. He decided to write a song for her. Dima has a magic guitar with n strings and m frets. Dima makes the guitar produce sounds like that: to play a note, he needs to hold one of the strings on one...
[{"type": "stdin_stdout", "input": "11 11 9 11\n1 1 1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 2 2 1\n1 1 1 1 1 1 1 1 3 1 1\n1 1 1 1 1 1 1 3 1 1 1\n1 1 1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1 1 1\n1 1 1 2 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1 1 1\n3 3 3 3 3 3 3 3 3 2...
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
[ { "content": "Solve the following coding problem using the programming language python:\n\nWe have a 3 \\times 3 grid. A number c_{i, j} is written in the square (i, j), where (i, j) denotes the square at the i-th row from the top and the j-th column from the left.\n\nAccording to Takahashi, there are six integ...
[{"type": "stdin_stdout", "input": "19 -1 0\n2 3 6\n4 -4 -1", "output": "No\n"}, {"type": "stdin_stdout", "input": "12 -1 3\n2 2 3\n2 -4 2", "output": "No\n"}, {"type": "stdin_stdout", "input": "12 -1 0\n2 2 3\n2 -4 2", "output": "No\n"}, {"type": "stdin_stdout", "input": "12 -1 0\n2 2 3\n4 -4 2", "output": "No\n"}, {"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere was a powerful school where powerful people gathered. At the athletic meet of the powerful school, powerful people march in a formation.\n\nWhile the powerhouses always want to show off their power, most of them don...
[{"type": "stdin_stdout", "input": "3\n156 120\n100 50\n80 100", "output": "1\n"}, {"type": "stdin_stdout", "input": "3\n156 120\n100 50\n80 000", "output": "1\n"}, {"type": "stdin_stdout", "input": "3\n156 159\n100 50\n80 000", "output": "1\n"}, {"type": "stdin_stdout", "input": "3\n156 22\n100 50\n152 000", "output":...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSnuke, who loves animals, built a zoo.\nThere are N animals in this zoo. They are conveniently numbered 1 through N, and arranged in a circle.\nThe animal numbered i (2≤i≤N-1) is adjacent to the animals numbered i-1 and i...
[{"type": "stdin_stdout", "input": "10\noxooxoxoox\n", "output": "SSWWSSSWWS\n"}, {"type": "stdin_stdout", "input": "10\nxooxoxooxo", "output": "SWWSSSWWSS\n"}, {"type": "stdin_stdout", "input": "10\nxxooxoxooo", "output": "SWSWWWSSSS\n"}, {"type": "stdin_stdout", "input": "10\noxooooxxox", "output": "SSWWSWWWWS\n"}, {...
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 1 1\n", "output": "100000000\n"}, {"type": "stdin_stdout", "input": "10000 10000 3 2\n", "output": "16670000\n"}, {"type": "stdin_stdout", "input": "10000 10000 3 2\n", "output": "16670000\n"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\n<!--\n\nProblem B\n\n-->\n\nOn-Screen Keyboard\n\nYou are to input a string with an OSK (on-screen keyboard). A remote control with five buttons, four arrows and an OK (Fig. B-1), is used for the OSK. Find the minimum num...
[{"type": "stdin_stdout", "input": "3 9\nABCDEFGHI\nJKLMNOPQR\nSTUVWXYZ_\nICPC\n5 11\n___________\n____A______\n________M__\n___________\n_C_________\nACM\n4 21\n1_2_3_4_5_6_7_8_9_0_-\nQqWwEeRrTtYyUuIiOoPp@\nAaSsDdFfGgHhJjKkLl;^:\nZzXxCcVvBbNnMm,_._/__\nICPC2019,AsiaYokohamaRegional,QualificationRound\n0 0", "output": ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere is a house with $n$ flats situated on the main street of Berlatov. Vova is watching this house every night. The house can be represented as an array of $n$ integer numbers $a_1, a_2, \\dots, a_n$, where $a_i = 1$ if...
[{"type": "stdin_stdout", "input": "100\n0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 -1 1 0\n", "output": "24\n"}, {"type": "stdin_stdout", "input": "100\n0 0 1 0 1 0 1 0...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAlexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will ...
[{"type": "stdin_stdout", "input": "2\n110111100000101101101011001110100111011001000000000000000000\n", "output": "1000000000000000000"}, {"type": "stdin_stdout", "input": "2\n110111100000101101101011001110100111011001000000000000000000\n", "output": "1000000000000000000"}, {"type": "stdin_stdout", "input": "2\n1110110...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLittle penguin Polo loves his home village. The village has n houses, indexed by integers from 1 to n. Each house has a plaque containing an integer, the i-th house has a plaque containing integer pi (1 ≤ pi ≤ n).\n\nLitt...
[{"type": "stdin_stdout", "input": "1000 8\n", "output": "339760446\n"}, {"type": "stdin_stdout", "input": "1000 6\n", "output": "834332109\n"}, {"type": "stdin_stdout", "input": "1000 1\n", "output": "760074701\n"}, {"type": "stdin_stdout", "input": "1000 5\n", "output": "583047503\n"}, {"type": "stdin_stdout", "input...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSome dwarves that are finishing the StUDY (State University for Dwarven Youngsters) Bachelor courses, have been told \"no genome, no degree\". That means that all dwarves should write a thesis on genome. Dwarven genome is...
[{"type": "stdin_stdout", "input": "aaaabcccca\naaaadccccb\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "aaaabcccca\naaaadccdcb\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "accccbaaaa\naaaadccdcb\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "rtfabanpc\natfabrnpc\n", "output": "YES\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe Bubble Cup hypothesis stood unsolved for $130$ years. Who ever proves the hypothesis will be regarded as one of the greatest mathematicians of our time! A famous mathematician Jerry Mao managed to reduce the hypothesi...
[{"type": "stdin_stdout", "input": "100\n891 894 462 899 163 868 418 903 31 333 670 32 705 561 505 920 414 81 723 603 513 25 896 879 703 415 799 271 440 8 596 207 296 116 458 646 781 842 963 174 157 747 207 996 361 371 721 447 566 438 566 449 522 176 79 740 757 156 436 296 23 704 542 572 455 886 962 194 219 301 437 315...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLittle Susie listens to fairy tales before bed every day. Today's fairy tale was about wood cutters and the little girl immediately started imagining the choppers cutting wood. She imagined the situation that is described...
[{"type": "stdin_stdout", "input": "67\n1 1\n3 8\n4 10\n7 8\n9 2\n10 1\n11 5\n12 8\n13 4\n16 6\n18 3\n19 3\n22 5\n24 6\n27 5\n28 3\n29 3\n30 5\n32 5\n33 10\n34 7\n35 8\n36 5\n41 3\n42 2\n43 5\n46 4\n48 4\n49 9\n52 4\n53 9\n55 1\n56 4\n59 7\n68 7\n69 4\n71 9\n72 10\n74 5\n76 4\n77 9\n80 7\n81 9\n82 5\n83 5\n84 9\n85 7\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nKaavi, the mysterious fortune teller, deeply believes that one's fate is inevitable and unavoidable. Of course, she makes her living by predicting others' future. While doing divination, Kaavi believes that magic spells c...
[{"type": "stdin_stdout", "input": "babbaaababbbbabbaaaababbbaabababbaabbaababbaaabaabbabaabbaababababbaabaaabaaaaababbaabaaaaabaabbabaaababbbb\nbbaabbbbabbbbaaaaaababbbabaaabbbbabababbbaabbbbbabaababbaabaaabaabbababababaaaaabaabbabaaabaaaaaaaaaaaaabbb\n", "output": "284471294\n"}, {"type": "stdin_stdout", "input": "ba...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTwo chess pieces, a rook and a knight, stand on a standard chessboard 8 × 8 in size. The positions in which they are situated are known. It is guaranteed that none of them beats the other one.\n\nYour task is to find the ...
[{"type": "stdin_stdout", "input": "c1\nd2\n", "output": "42\n"}, {"type": "stdin_stdout", "input": "g1\ne6\n", "output": "39\n"}, {"type": "stdin_stdout", "input": "h8\ng2\n", "output": "43\n"}, {"type": "stdin_stdout", "input": "a8\nf1\n", "output": "42\n"}, {"type": "stdin_stdout", "input": "e4\nc1\n", "output": "37...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nExample\n\nInput\n\n1\n\n\nOutput\n\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.\n\nWrite Python code to solve this problem. Your program shou...
[{"type": "stdin_stdout", "input": "321", "output": ")))))))))))))))))))))())))((((((((((((((((((((((((\n"}, {"type": "stdin_stdout", "input": "222", "output": "))))))))))))()))))))))((((((((((((((((((((\n"}, {"type": "stdin_stdout", "input": "193", "output": ")))()))))))))))))))))(((((((((((((((((((\n"}, {"type": "std...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAnd where the are the phone numbers?\n\nYou are given a string s consisting of lowercase English letters and an integer k. Find the lexicographically smallest string t of length k, such that its set of letters is a subset...
[{"type": "stdin_stdout", "input": "3 99948\nttt\n", "output": "tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou have given an array $a$ of length $n$ and an integer $x$ to a brand new robot. What the robot does is the following: it iterates over the elements of the array, let the current element be $q$. If $q$ is divisible by $...
[{"type": "stdin_stdout", "input": "1\n20 9\n288 279 252 279 288 207 261 270 297 288 276 265 209 217 214 300 227 221 215 271\n", "output": "7833\n"}, {"type": "stdin_stdout", "input": "1\n20 9\n288 279 252 279 288 207 261 270 297 288 276 265 209 217 214 300 227 221 215 271\n", "output": "7833\n"}, {"type": "stdin_stdou...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIkshu's love for binary numbers\n\nIkshu recently learnt to generate random numbers. He is generating stream binary numbers. Uptil now he has generated N bits of the binary number. Now, he wants to know if there is a stre...
[{"type": "stdin_stdout", "input": "32 7\n", "output": "288230376151711743/288230376151711744\n"}, {"type": "stdin_stdout", "input": "27 10\n", "output": "1541494189855/140737488355328\n"}, {"type": "stdin_stdout", "input": "54 11\n", "output": "37241906121/1099511627776\n"}, {"type": "stdin_stdout", "input": "5 3\n", ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWrite a program which performs the following operations to a binary search tree $T$ by adding delete operation to B: Binary Search Tree II.\n\n* insert $k$: Insert a node containing $k$ as key into $T$.\n* find $k$: Repo...
[{"type": "stdin_stdout", "input": "18\ninsert 13\ninsert 2\ninsert 3\ninsert 7\ninsert 22\ninsert 1\nfind 1\nfind 2\nfind 3\nfind 13\nfind 5\nfind 6\nfind 4\nfind 7\nprint\ndelete 3\ndelete 7\nprint", "output": "yes\nyes\nyes\nyes\nno\nno\nno\nyes\n 1 2 3 7 13 22\n 13 2 1 3 7 22\n 1 2 13 22\n 13 2 1 22\n"}, {"type": "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAt the school where Vasya is studying, preparations are underway for the graduation ceremony. One of the planned performances is a ball, which will be attended by pairs of boys and girls.\n\nEach class must present two co...
[{"type": "stdin_stdout", "input": "3\n12 6 4\n2 1 2 4\n1 1 2 3\n2 1 1\n1\n1\n3 15 4\n1 1 2 2\n1 2 1 2\n", "output": "4\n0\n2\n"}, {"type": "stdin_stdout", "input": "3\n12 6 4\n2 1 2 4\n1 1 3 3\n2 1 1\n1\n1\n3 15 4\n1 1 2 2\n1 2 1 2\n", "output": "3\n0\n2\n"}, {"type": "stdin_stdout", "input": "3\n12 6 4\n2 1 2 7\n1 1 ...
code_stdio