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\nA tetromino is a figure formed by joining four squares edge to edge. We will refer to the following seven kinds of tetromino as I-, O-, T-, J-, L-, S- and Z-tetrominos, respectively:\n\na60bcb8e9e8f22e3af51049eda063392.pn...
[{"type": "stdin_stdout", "input": "10 1 2 0 0 -1 0", "output": "11\n"}, {"type": "stdin_stdout", "input": "1 13 1 0 1 -1 2", "output": "13\n"}, {"type": "stdin_stdout", "input": "10 2 0 0 4 -1 0", "output": "16\n"}, {"type": "stdin_stdout", "input": "1 26 1 0 1 -1 2", "output": "26\n"}, {"type": "stdin_stdout", "input...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYouKn0wWho has an integer sequence $a_1, a_2, \\ldots a_n$. Now he will split the sequence $a$ into one or more consecutive subarrays so that each element of $a$ belongs to exactly one subarray. Let $k$ be the number of r...
[{"type": "stdin_stdout", "input": "4\n7\n1 12 3 0 1 1 5\n3\n2 2 5\n5\n1 3 2 4 4\n4\n4 5 -1 1\n", "output": "YES\nYES\nYES\nYES\n"}, {"type": "stdin_stdout", "input": "4\n7\n1 11 3 2 1 1 5\n3\n2 2 5\n5\n1 3 2 4 4\n4\n4 5 -2 1\n", "output": "YES\nYES\nYES\nYES\n"}, {"type": "stdin_stdout", "input": "4\n7\n1 4 3 2 -1 1 -...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an array $d_1, d_2, \\dots, d_n$ consisting of $n$ integer numbers.\n\nYour task is to split this array into three parts (some of which may be empty) in such a way that each element of the array belongs to e...
[{"type": "stdin_stdout", "input": "5\n2 3 5 4 10\n", "output": "10\n"}, {"type": "stdin_stdout", "input": "1\n1000000000\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "1\n1000000000\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "1\n1000000100\n", "output": "0\n"}, {"type": "stdin_stdout", "input": ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are n pearls in a row. Let's enumerate them with integers from 1 to n from the left to the right. The pearl number i has the type a_{i}.\n\nLet's call a sequence of consecutive pearls a segment. Let's call a segment...
[{"type": "stdin_stdout", "input": "10\n460626451 460626451 460626451 460626451 460626451 460626451 460626451 460626451 460626451 460626451\n", "output": "5\n1 2\n3 4\n5 6\n7 8\n9 10\n"}, {"type": "stdin_stdout", "input": "10\n460626451 460626451 460626451 460626451 460626451 460626451 460626451 460626451 460626451 460...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAlice has a string consisting of characters 'A', 'B' and 'C'. Bob can use the following transitions on any substring of our string in any order any number of times: A $\\rightarrow$ BC B $\\rightarrow$ AC C $\\rightar...
[{"type": "stdin_stdout", "input": "AAAAAA\nAAAAAA\n30\n3 4 1 2\n3 3 4 4\n5 6 3 4\n3 3 2 3\n6 6 1 5\n2 4 4 6\n1 6 2 5\n6 6 3 4\n3 5 1 4\n4 5 3 6\n2 3 2 4\n3 4 4 4\n6 6 4 6\n3 3 2 5\n1 5 3 3\n4 6 1 2\n6 6 6 6\n3 3 3 4\n6 6 6 6\n5 6 4 4\n6 6 5 5\n2 3 1 4\n3 6 4 5\n3 5 6 6\n4 5 2 6\n5 6 6 6\n1 4 2 5\n4 5 2 5\n4 5 1 3\n2 2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOn the xy-plane, Snuke is going to travel from the point (x_s, y_s) to the point (x_t, y_t).\nHe can move in arbitrary directions with speed 1.\nHere, we will consider him as a point without size.\nThere are N circular ba...
[{"type": "stdin_stdout", "input": "711627115 480696358 633203014 877112611\n997\n823068082 -750068892 144324195\n-150528283 572165970 8705984\n579786057 146049479 458783401\n-571870801 -833355728 354709151\n-225671601 -182489804 264833500\n816772899 775985943 18276416\n111104358 490248913 465440593\n-508331521 -827309...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nKolya got string s for his birthday, the string consists of small English letters. He immediately added k more characters to the right of the string.\n\nThen Borya came and said that the new string contained a tandem repe...
[{"type": "stdin_stdout", "input": "jhfwjyyzwrjiyrrgveiqkoltivghgkontrqragikttxxuwszjwqhwxindyrdqhucnbwgwrppgqmsasrzohezjlfmkzsqptwpratprcrxyxecnlsaiqrvimihmhjfgzwdtvmfhgbuonpsblphyoxzclkrwbwrkasahiirzqlfjdoomlosltldbpomyyhmdwfchzxnmwlh\n200\n", "output": "400\n"}, {"type": "stdin_stdout", "input": "nemtbujbscvkgxnbqbo...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an array of integers $a_1,a_2,\\ldots,a_n$. Find the maximum possible value of $a_ia_ja_ka_la_t$ among all five indices $(i, j, k, l, t)$ ($i<j<k<l<t$).\n\n\n-----Input-----\n\nThe input consists of multiple...
[{"type": "stdin_stdout", "input": "4\n5\n-1 -1 -4 -1 -5\n6\n-4 -4 -3 1 2 -1\n6\n0 -1 -1 -1 -1 -1\n6\n-12 -7 -10 -3 -2 1\n", "output": "-20\n96\n0\n2520\n"}, {"type": "stdin_stdout", "input": "4\n5\n-1 -1 -4 -1 -5\n6\n-4 -4 -3 1 2 -1\n6\n0 -1 -1 -1 -1 -1\n6\n-9 -7 -10 -3 -2 1\n", "output": "-20\n96\n0\n1890\n"}, {"type...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMultiplication of Big Integers\n\nGiven two integers $A$ and $B$, compute the product, $A \\times B$.\n\nInput\n\nTwo integers $A$ and $B$ separated by a space character are given in a line.\n\nOutput\n\nPrint the product...
[{"type": "stdin_stdout", "input": "2 -134", "output": "-268\n"}, {"type": "stdin_stdout", "input": "3 -134", "output": "-402\n"}, {"type": "stdin_stdout", "input": "6 -134", "output": "-804\n"}, {"type": "stdin_stdout", "input": "-124 4", "output": "-496\n"}, {"type": "stdin_stdout", "input": "-103 -1", "output": "103...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFind the number of palindromic numbers among the integers between A and B (inclusive).\nHere, a palindromic number is a positive integer whose string representation in base 10 (without leading zeros) reads the same forwar...
[{"type": "stdin_stdout", "input": "31415 92653\n", "output": "612\n"}, {"type": "stdin_stdout", "input": "31415 97709", "output": "662\n"}, {"type": "stdin_stdout", "input": "53417 77120", "output": "237\n"}, {"type": "stdin_stdout", "input": "44323 77120", "output": "328\n"}, {"type": "stdin_stdout", "input": "44323 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasya likes everything infinite. Now he is studying the properties of a sequence s, such that its first element is equal to a (s_1 = a), and the difference between any two neighbouring elements is equal to c (s_{i} - s_{i...
[{"type": "stdin_stdout", "input": "-1000000000 1000000000 1000000000\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "-1000000000 1000000000 1000000000\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "-1000000000 1001000000 1000000000\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "119057...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDr .: Peter. I did.\n\nPeter: See you again? What kind of silly invention is this time?\n\nDr .: You invented the detector for that phantom elementary particle axion.\n\nPeter: Speaking of Axion, researchers such as the E...
[{"type": "stdin_stdout", "input": "1\n0 1 0 0 0 0 0 0 0 0\n1 1 1 0 0 0 0 0 0 0\n0 1 0 0 0 0 0 0 0 0\n0 0 0 0 0 1 0 0 0 0\n0 0 0 1 0 0 1 0 0 0\n0 0 0 0 1 1 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 1 0\n0 0 0 0 0 0 0 1 1 1\n0 0 0 0 0 0 0 0 1 0", "output": "0 0 0 0 1 0 1 0 0 0\n0 1 0 1 1 0 1 1 0 0\n0 0 1 0 1 0 1 0 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAnimation is one of methods for making movies and in Japan, it is popular to broadcast as a television program or perform as a movie. Many people, especially the young, love one. And here is an anime lover called Jack. We...
[{"type": "stdin_stdout", "input": "1\ngalaxy_angel 0 1197\n1\ngalaxy_angel\n11\nA 0 600\nB 0 610\nC 0 610\nD 0 931\nE 0 640\nEE 0 700\nF 0 788\nG 0 710\nH 0 710\nI 0 740\nJ 0 750\n2\nB\nH\n42\nnchj 6 2620\nanhnnnmewbktthsrn 4 2515\ngntmdsh 1 1800\nachnnl 4 2540\nhnskirh 0 2200\naonexrcst 0 1700\ndgdys 6 2330\nhdnnara ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a tree that consists of $n$ nodes. You should label each of its $n-1$ edges with an integer in such way that satisfies the following conditions: each integer must be greater than $0$; the product of all $...
[{"type": "stdin_stdout", "input": "4\n3\n3 1\n2 1\n4\n22861 20707 59627 9293\n3\n3 1\n1 2\n6\n15767 40973 20807 24419 46439 62816\n3\n3 2\n1 2\n6\n31575 54493 10799 37529 59743 30529\n3\n3 1\n2 1\n1\n51618\n", "output": "783349080\n372565328\n603348715\n103238\n"}, {"type": "stdin_stdout", "input": "4\n3\n3 1\n2 1\n4\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYelisey has an array $a$ of $n$ integers.\n\nIf $a$ has length strictly greater than $1$, then Yelisei can apply an operation called minimum extraction to it:\n\nFirst, Yelisei finds the minimal number $m$ in the array. I...
[{"type": "stdin_stdout", "input": "8\n1\n10\n2\n0 0\n3\n-1 2 -1\n4\n2 18 1 -1\n2\n3 6\n5\n3 2 -4 -2 0\n2\n-1 -1\n1\n-2\n", "output": "10\n0\n3\n16\n3\n2\n0\n-2\n"}, {"type": "stdin_stdout", "input": "8\n1\n10\n2\n1 0\n3\n-1 2 -1\n4\n2 18 1 -1\n2\n3 6\n5\n3 2 -4 -2 0\n2\n-1 -1\n1\n-2\n", "output": "10\n1\n3\n16\n3\n2\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe only difference between easy and hard versions is constraints.\n\nThe BerTV channel every day broadcasts one episode of one of the $k$ TV shows. You know the schedule for the next $n$ days: a sequence of integers $a_1...
[{"type": "stdin_stdout", "input": "30\n4 4 1\n3 3 1 2\n4 4 1\n4 1 4 1\n1 1 1\n1\n3 2 1\n2 1 2\n4 4 2\n3 2 2 2\n4 2 4\n1 2 2 2\n1 4 1\n4\n2 3 1\n2 3\n2 2 1\n2 2\n4 4 2\n1 2 4 2\n4 4 1\n2 4 4 3\n4 3 1\n1 3 1 3\n1 1 1\n1\n2 2 2\n2 1\n2 4 1\n1 4\n2 4 1\n3 4\n1 2 1\n1\n2 4 2\n2 1\n3 1 2\n1 1 1\n2 4 1\n1 4\n2 3 1\n3 3\n4 2 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRick and Morty are playing their own version of Berzerk (which has nothing in common with the famous Berzerk game). This game needs a huge space, so they play it with a computer.\n\nIn this game there are n objects number...
[{"type": "stdin_stdout", "input": "7000\n7 419 1631 1925 3861 6940 379 493\n29 5389 5925 2923 4696 972 6125 3779 6044 5477 1305 6488 5059 5515 3238 3863 248 6947 4023 6168 1915 6607 2991 2220 2023 200 4457 6398 1017 447\n", "output": "Loop Loop Loop Loop Loop Loop Loop Loop Loop Loop Loop Loop Loop Loop Loop Loop Loop...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA magic number is a number formed by concatenation of numbers 1, 14 and 144. We can use each of these numbers any number of times. Therefore 14144, 141414 and 1411 are magic numbers but 1444, 514 and 414 are not.\n\nYou'r...
[{"type": "stdin_stdout", "input": "1000000000\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "144144144\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "141414141\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "114114144\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "11111111...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWe have a large square grid with H rows and W columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the bottom-right cell.\n\nHowever, she cannot ...
[{"type": "stdin_stdout", "input": "100000 100000 99999 72298", "output": "471980925\n"}, {"type": "stdin_stdout", "input": "100000 100000 43938 55555", "output": "265769345\n"}, {"type": "stdin_stdout", "input": "100000 100000 99999 39553", "output": "199584029\n"}, {"type": "stdin_stdout", "input": "100000 100000 439...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVanya smashes potato in a vertical food processor. At each moment of time the height of the potato in the processor doesn't exceed h and the processor smashes k centimeters of potato each second. If there are less than k ...
[{"type": "stdin_stdout", "input": "25 1000000000 1\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 100...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDZY loves planting, and he enjoys solving tree problems.\n\nDZY has a weighted tree (connected undirected graph without cycles) containing n nodes (they are numbered from 1 to n). He defines the function g(x, y) (1 ≤ x, y...
[{"type": "stdin_stdout", "input": "10\n1 10 4313\n2 6 2842\n3 6 7059\n4 6 3007\n5 6 6195\n7 6 3962\n8 6 3413\n9 6 7658\n10 6 8049\n3\n3\n2\n1\n4\n4\n5\n2\n1\n1\n", "output": "7059\n"}, {"type": "stdin_stdout", "input": "10\n2 1 8760\n3 1 3705\n4 1 1862\n5 2 7332\n6 3 7015\n7 5 4866\n8 3 4465\n9 7 8886\n10 3 9362\n2\n5...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPolycarp calls an array dense if the greater of any two adjacent elements is not more than twice bigger than the smaller. More formally, for any $i$ ($1 \\le i \\le n-1$), this condition must be satisfied: $$\\frac{\\max(...
[{"type": "stdin_stdout", "input": "6\n4\n4 2 10 1\n2\n1 3\n2\n12 1\n3\n1 4 2\n5\n1 2 3 4 3\n12\n4 27 25 50 30 20 34 46 42 16 15 21\n", "output": "5\n1\n3\n1\n0\n3\n"}, {"type": "stdin_stdout", "input": "6\n4\n4 2 10 1\n2\n1 6\n2\n6 1\n3\n1 7 2\n5\n1 1 2 6 1\n12\n3 58 25 17 43 21 20 46 42 11 30 16\n", "output": "5\n2\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSnuke loves flags.\n\nSnuke is placing N flags on a line.\n\nThe i-th flag can be placed at either coordinate x_i or coordinate y_i.\n\nSnuke thinks that the flags look nicer when the smallest distance between two of them...
[{"type": "stdin_stdout", "input": "22\n93 6440\n78 6647\n1028 11\n8306 9689\n798 99\n801 521\n188 206\n6079 971\n4559 209\n50 94\n92 6270\n5403 560\n803 83\n1855 99\n42 504\n75 484\n629 11\n92 122\n3359 37\n28 16\n648 14\n11 269", "output": "17\n"}, {"type": "stdin_stdout", "input": "22\n93 6440\n78 6647\n889 11\n8306...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPetya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.\n\...
[{"type": "stdin_stdout", "input": "485 9554485\n7759121368632736852539182753173468028218114958118158732302477551670775608015153610483175626465946144780731573954182900412248382710280376491925985206156109890139333293746203940442347501294009600230166311978044218247083102712257326301109220002496805123344816427514286225153...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe Smart Beaver from ABBYY began to develop a new educational game for children. The rules of the game are fairly simple and are described below.\n\nThe playing field is a sequence of n non-negative integers ai numbered ...
[{"type": "stdin_stdout", "input": "120\n242 524 420 973 816 432 247 666 134 849 145 366 608 930 613 315 863 628 97 109 65 704 741 314 736 17 872 971 559 648 223 771 171 327 782 837 303 393 292 339 730 834 794 868 540 251 789 893 23 305 116 220 699 863 580 992 861 393 98 253 544 171 336 207 348 496 316 285 286 727 613 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a string S of length N consisting of lowercase English letters, and an integer K. Print the string obtained by replacing every character in S that differs from the K-th character of S, with `*`.\n\nConstrain...
[{"type": "stdin_stdout", "input": "9\nedtbiuaon\n-2", "output": "******a**\n"}, {"type": "stdin_stdout", "input": "9\neducation\n4", "output": "***c*****\n"}, {"type": "stdin_stdout", "input": "9\nedubation\n4", "output": "***b*****\n"}, {"type": "stdin_stdout", "input": "9\nedubation\n6", "output": "*****t***\n"}, {"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSnuke is having another barbeque party.\n\nThis time, he will make one serving of Skewer Meal.\n\nHe has a stock of N Skewer Meal Packs. The i-th Skewer Meal Pack contains one skewer, A_i pieces of beef and B_i pieces of ...
[{"type": "stdin_stdout", "input": "3\n11 3\n2 2\n0 2", "output": "12951\n"}, {"type": "stdin_stdout", "input": "3\n12 2\n2 3\n2 0", "output": "11783\n"}, {"type": "stdin_stdout", "input": "3\n12 2\n2 3\n1 0", "output": "11753\n"}, {"type": "stdin_stdout", "input": "3\n3 1\n0 4\n7 9", "output": "262332\n"}, {"type": "s...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSasha is a very happy guy, that's why he is always on the move. There are $n$ cities in the country where Sasha lives. They are all located on one straight line, and for convenience, they are numbered from $1$ to $n$ in i...
[{"type": "stdin_stdout", "input": "84 15\n", "output": "2429 \n"}, {"type": "stdin_stdout", "input": "100 100\n", "output": "99 \n"}, {"type": "stdin_stdout", "input": "100 98\n", "output": "100 \n"}, {"type": "stdin_stdout", "input": "100 97\n", "output": "102 \n"}, {"type": "stdin_stdout", "input": "100 3\n", "outpu...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe string $t_1t_2 \\dots t_k$ is good if each letter of this string belongs to at least one palindrome of length greater than 1.\n\nA palindrome is a string that reads the same backward as forward. For example, the strin...
[{"type": "stdin_stdout", "input": "7\nAAABABB\n", "output": "15\n"}, {"type": "stdin_stdout", "input": "7\nBBABAAA\n", "output": "15\n"}, {"type": "stdin_stdout", "input": "7\nBAAAABB\n", "output": "12\n"}, {"type": "stdin_stdout", "input": "7\nABABAAB\n", "output": "14\n"}, {"type": "stdin_stdout", "input": "7\nBBAAA...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFor given two lines s1 and s2, print \"2\" if they are parallel, \"1\" if they are orthogonal, or \"0\" otherwise.\n\ns1 crosses points p0 and p1, and s2 crosses points p2 and p3.\n\nConstraints\n\n* 1 ≤ q ≤ 1000\n* -1000...
[{"type": "stdin_stdout", "input": "3\n-1 -1 10 1 2 0 2 2\n0 5 6 -1 0 -1 0 22\n-2 -1 1 1 0 -1 2 2", "output": "0\n0\n0\n"}, {"type": "stdin_stdout", "input": "3\n-1 -1 10 1 2 0 2 2\n0 5 6 -1 0 -1 0 22\n-2 -1 1 1 1 -1 2 2", "output": "0\n0\n0\n"}, {"type": "stdin_stdout", "input": "3\n-1 -1 10 1 2 0 2 4\n0 5 6 -1 0 -1 0...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given some text $t$ and a set of $n$ strings $s_1, s_2, \\dots, s_n$.\n\nIn one step, you can choose any occurrence of any string $s_i$ in the text $t$ and color the corresponding characters of the text in red. Fo...
[{"type": "stdin_stdout", "input": "5\naaaaa\n3\naaa\naaa\na\nabbaa\n4\nab\nbaa\nabb\na\nabcdefg\n10\na\nb\nc\nd\ne\nf\ng\nh\ni\nj\nabcdefghijklmnop\n4\nabcdefg\nefghijklmo\nijklmnop\nhijklmnop\nababababbababba\n5\na\nabba\nb\nbb\naa\n", "output": "2\n1 1\n1 3\n2\n3 1\n2 3\n7\n1 1\n2 2\n3 3\n4 4\n5 5\n6 6\n7 7\n2\n1 1\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTwo players, A and B, play the game using cards with numbers from 0 to 9. First, the two arrange the given n cards face down in a horizontal row. After that, the two players turn their cards face up one by one from the le...
[{"type": "stdin_stdout", "input": "3\n13 1\n1 4\n1 4\n3\n20 1\n6 7\n1 1\n3\n15 1\n5 5\n1 8\n0", "output": "14 10\n22 14\n21 14\n"}, {"type": "stdin_stdout", "input": "3\n13 1\n1 4\n1 4\n3\n20 1\n6 8\n1 1\n3\n15 1\n5 5\n1 8\n0", "output": "14 10\n22 15\n21 14\n"}, {"type": "stdin_stdout", "input": "3\n13 1\n1 4\n0 4\n3...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA railroad running from west to east in Atcoder Kingdom is now complete.\nThere are N stations on the railroad, numbered 1 through N from west to east.\nTomorrow, the opening ceremony of the railroad will take place.\nOn ...
[{"type": "stdin_stdout", "input": "4\n12 13 1\n44 17 17\n66 4096 64\n", "output": "4162\n4162\n4162\n0\n"}, {"type": "stdin_stdout", "input": "4\n1 13 1\n44 17 22\n101 4096 64", "output": "4197\n4197\n4197\n0\n"}, {"type": "stdin_stdout", "input": "4\n1 13 1\n44 17 22\n120 4096 64", "output": "4216\n4216\n4216\n0\n"},...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe development of a text editor is a hard problem. You need to implement an extra module for brackets coloring in text.\n\nYour editor consists of a line with infinite length and cursor, which points to the current chara...
[{"type": "stdin_stdout", "input": "21\n(RRRRR)LLLL(RRR)LL(R)\n", "output": "-1 -1 -1 -1 -1 -1 1 1 1 1 1 -1 -1 -1 -1 2 2 2 -1 -1 3 "}, {"type": "stdin_stdout", "input": "21\n(RRRRR)LLLL(RRR)LL(R)\n", "output": "-1 -1 -1 -1 -1 -1 1 1 1 1 1 -1 -1 -1 -1 2 2 2 -1 -1 3 "}, {"type": "stdin_stdout", "input": "11\n'R)R(R)Ra)c\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nHave you ever heard of the unit \"○○ tsubo\" that expresses the area of ​​land? Since ancient times, one samurai has said the area for making rice to eat in a day.\n\nThere is a land of a [m] x b [m]. Enter a and b and cr...
[{"type": "stdin_stdout", "input": "101 -1", "output": "-30.5525011457\n"}, {"type": "stdin_stdout", "input": "111 -1", "output": "-33.5775012592\n"}, {"type": "stdin_stdout", "input": "-1 106", "output": "-32.0650012024\n"}, {"type": "stdin_stdout", "input": "26 -1", "output": "-7.86500029494\n"}, {"type": "stdin_stdo...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAt the store, the salespeople want to make all prices round.\n\nIn this problem, a number that is a power of $10$ is called a round number. For example, the numbers $10^0 = 1$, $10^1 = 10$, $10^2 = 100$ are round numbers,...
[{"type": "stdin_stdout", "input": "7\n100\n40000000\n89657\n326894\n2325566\n74444\n200055\n", "output": "0\n30000000\n79657\n226894\n1325566\n64444\n100055\n"}, {"type": "stdin_stdout", "input": "7\n1\n2\n178\n20\n999999999\n9000\n987654321\n", "output": "0\n1\n78\n10\n899999999\n8000\n887654321\n"}, {"type": "stdin_...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAn art exhibition will be held in JOI. At the art exhibition, various works of art from all over the country will be exhibited.\n\nN works of art were collected as candidates for the works of art to be exhibited. These wo...
[{"type": "stdin_stdout", "input": "3\n1 12\n26 -1\n2 0", "output": "12\n"}, {"type": "stdin_stdout", "input": "3\n1 11\n80 0\n2 -1", "output": "11\n"}, {"type": "stdin_stdout", "input": "3\n0 17\n14 1\n13 2", "output": "17\n"}, {"type": "stdin_stdout", "input": "3\n0 16\n54 3\n5 1", "output": "16\n"}, {"type": "stdin_...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a set of n elements indexed from 1 to n. The weight of i-th element is w_{i}. The weight of some subset of a given set is denoted as $W(S) =|S|\\cdot \\sum_{i \\in S} w_{i}$. The weight of some partition R o...
[{"type": "stdin_stdout", "input": "6 2\n2578 6301 8624 6020 8513 9486\n", "output": "4401332\n"}, {"type": "stdin_stdout", "input": "6 3\n4759 5555 7401 8003 2501 6345\n", "output": "7431260\n"}, {"type": "stdin_stdout", "input": "6 2\n2578 6301 8624 6020 8513 9486\n", "output": "4401332\n"}, {"type": "stdin_stdout", ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are two bus stops denoted A and B, and there n buses that go from A to B every day. The shortest path from A to B takes t units of time but some buses might take longer paths. Moreover, buses are allowed to overtake...
[{"type": "stdin_stdout", "input": "2 1000000000\n999999999 1000000000\n1 2\n", "output": "Yes\n1999999999 2000000000\n"}, {"type": "stdin_stdout", "input": "2 1000000000\n1 1000000000\n2 2\n", "output": "Yes\n2000000000 2000000001\n"}, {"type": "stdin_stdout", "input": "2 1000010000\n1 1000000000\n2 2\n", "output": "Y...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRng is preparing a problem set for a qualification round of CODEFESTIVAL.\n\nHe has N candidates of problems. The difficulty of the i-th candidate is D_i.\n\nThere must be M problems in the problem set, and the difficulty...
[{"type": "stdin_stdout", "input": "7\n100 200 500 700 238 1600 2000\n6\n100 200 500 700 1600 1600", "output": "NO\n"}, {"type": "stdin_stdout", "input": "7\n100 200 500 700 238 1600 2000\n6\n100 200 500 337 1600 1600", "output": "NO\n"}, {"type": "stdin_stdout", "input": "7\n100 200 500 700 1200 1600 2000\n6\n100 200 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe biggest event of the year – Cota 2 world championship \"The Innernational\" is right around the corner. $2^n$ teams will compete in a double-elimination format (please, carefully read problem statement even if you kno...
[{"type": "stdin_stdout", "input": "16 50\n57794 44224 38309 41637 11732 44974 655 27143 11324 49584 3371 17159 26557 38800 33033 18231 26264 14765 33584 30879 46988 60703 52973 47349 22720 51251 54716 29642 7041 54896 12197 38530 51481 43063 55463 2057 48064 41953 16250 21272 34003 51464 50389 30417 45901 38895 25949 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGiven are two strings s and t consisting of lowercase English letters. Determine if there exists an integer i satisfying the following condition, and find the minimum such i if it exists.\n - Let s' be the concatenation o...
[{"type": "stdin_stdout", "input": "contest\nprogramming\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "contest\nprogrammhng", "output": "-1\n"}, {"type": "stdin_stdout", "input": "eontcst\nprogrammhng", "output": "-1\n"}, {"type": "stdin_stdout", "input": "eonscst\nprogrammhng", "output": "-1\n"}, {"type": ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAfter the educational reform Polycarp studies only two subjects at school, Safety Studies and PE (Physical Education). During the long months of the fourth term, he received n marks in them. When teachers wrote a mark in ...
[{"type": "stdin_stdout", "input": "100\n45 55\n3 5 3 4 1 1 1 1 5 2 1 3 1 5 3 5 1 1 3 1 1 3 5 5 1 1 1 5 5 1 3 1 1 1 3 3 1 1 1 4 3 1 5 1 3 1 4 5 4 3 3 1 1 5 5 1 3 5 1 1 5 1 1 3 5 5 1 1 3 3 4 1 1 4 5 3 1 3 1 5 1 5 4 5 1 1 1 1 4 5 4 5 3 1 1 5 1 5 1 4\n", "output": "1 1 1 1 2 2 2 2 1 2 2 1 2 1 1 1 2 2 1 2 2 1 1 1 2 2 2 1 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nClaire is a man-eater. She's a real man-eater. She's going around with dozens of guys. She's dating all the time. And one day she found some conflicts in her date schedule. D'oh!\n\nSo she needs to pick some dates and giv...
[{"type": "stdin_stdout", "input": "2\n2 100\n10 12\n14 16\n2 200\n12 13\n18 20\n4\n1 100\n6 22\n1 1000\n12 22\n1 10000\n6 22\n1 100000\n6 22\n16\n1 100000000\n6 7\n1 100000000\n7 8\n1 100000000\n8 15\n1 110000000\n9 10\n1 100000000\n10 11\n1 100000000\n11 12\n1 100000000\n12 13\n1 100000000\n13 17\n1 100000000\n14 15\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGiven the list of numbers, you are to sort them in non decreasing order.\n\n-----Input-----\nt – the number of numbers in list, then t lines follow [t <= 10^6]. \n\nEach line contains one integer: N [0 <= N <= 10^6]\n\n--...
[{"type": "stdin_stdout", "input": "5\n0\n0\n10\n11\n2", "output": "0\n0\n2\n10\n11\n"}, {"type": "stdin_stdout", "input": "5\n1\n1\n3\n11\n2", "output": "1\n1\n2\n3\n11\n"}, {"type": "stdin_stdout", "input": "5\n1\n1\n3\n11\n4", "output": "1\n1\n3\n4\n11\n"}, {"type": "stdin_stdout", "input": "5\n1\n0\n3\n11\n4", "out...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDiameter of a Tree\n\n\n\n\nGiven a tree T with non-negative weight, find the diameter of the tree.\n\nThe diameter of a tree is the maximum distance between two nodes in a tree.\n\nConstraints\n\n* 1 ≤ n ≤ 100,000\n* 0 ≤...
[{"type": "stdin_stdout", "input": "4\n1 0 -2\n2 1 10\n1 3 4", "output": "14\n"}, {"type": "stdin_stdout", "input": "4\n1 0 1\n0 2 12\n2 3 -1", "output": "13\n"}, {"type": "stdin_stdout", "input": "4\n1 0 0\n2 1 11\n0 3 11", "output": "22\n"}, {"type": "stdin_stdout", "input": "4\n1 0 -1\n2 1 15\n1 3 4", "output": "19\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are N people standing on the x-axis.\nLet the coordinate of Person i be x_i.\nFor every i, x_i is an integer between 0 and 10^9 (inclusive).\nIt is possible that more than one person is standing at the same coordina...
[{"type": "stdin_stdout", "input": "10 3\n8 7 100\n7 9 100\n9 8 100\n", "output": "No\n"}, {"type": "stdin_stdout", "input": "3 3\n1 2 1\n2 3 1\n1 3 2\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "4 3\n2 1 1\n2 3 5\n3 4 2\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "3 3\n1 2 1\n2 3 1\n1 3 5\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFor a dynamic array $A = \\\\{a_0, a_1, ...\\\\}$ of integers, perform a sequence of the following operations:\n\n* pushBack($x$): add element $x$ at the end of $A$\n* randomAccess($p$):print element $a_p$\n* popBack(): d...
[{"type": "stdin_stdout", "input": "8\n0 -1\n0 14\n0 1\n2\n0 4\n1 0\n1 0\n1 1", "output": "-1\n-1\n14\n"}, {"type": "stdin_stdout", "input": "8\n0 -1\n0 9\n1 1\n2\n0 4\n1 0\n1 0\n1 1", "output": "9\n-1\n-1\n4\n"}, {"type": "stdin_stdout", "input": "8\n0 -1\n0 2\n0 3\n2\n0 4\n1 0\n1 0\n1 0", "output": "-1\n-1\n-1\n"}, {...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRead problems statements in Mandarin Chinese and Russian. \nRoman has no idea, why this problem is called Stone. He also has no idea on how to solve the followong problem: given array of N integers A and a number K. Duri...
[{"type": "stdin_stdout", "input": "4 0\n5 -1 14 -1", "output": "5 -1 14 -1\n"}, {"type": "stdin_stdout", "input": "4 0\n6 -1 14 -1", "output": "6 -1 14 -1\n"}, {"type": "stdin_stdout", "input": "4 1\n1 -1 19 4", "output": "18 20 0 15\n"}, {"type": "stdin_stdout", "input": "4 1\n5 -1 15 0", "output": "10 16 0 15\n"}, {...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nEkiden competitions are held every year in Aizukuni. The country of Aiz is dotted with N towns, each numbered from 1 to N. Several towns are connected by roads that allow them to come and go directly to each other. You ca...
[{"type": "stdin_stdout", "input": "7 11\n2 4 2\n1 6 2\n2 4 2\n1 5 10\n2 6 2\n6 4 1\n6 5 1\n3 6 1\n4 7 0\n5 5 6\n6 7 1", "output": "4\n3\n4\n5\n7\n"}, {"type": "stdin_stdout", "input": "7 11\n2 1 2\n1 3 1\n2 3 2\n3 4 4\n2 6 1\n4 4 1\n3 5 2\n3 6 1\n4 7 3\n5 7 7\n6 7 1", "output": "4\n1\n2\n6\n7\n"}, {"type": "stdin_stdo...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a permutation of n numbers p1, p2, ..., pn. We perform k operations of the following type: choose uniformly at random two indices l and r (l ≤ r) and reverse the order of the elements pl, pl + 1, ..., pr. Yo...
[{"type": "stdin_stdout", "input": "100 83\n6 98 18 72 51 83 66 40 32 60 90 53 91 10 92 47 94 1 77 8 19 78 9 52 85 2 26 12 97 100 82 84 46 79 38 39 50 35 55 99 37 88 74 4 20 23 43 11 87 59 75 61 71 73 34 130 21 17 44 62 42 95 30 54 5 25 64 81 58 65 7 3 45 70 76 24 89 28 80 41 14 31 49 56 22 63 68 13 29 33 67 96 27 36 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSnuke has an empty sequence a.\n\nHe will perform N operations on this sequence.\n\nIn the i-th operation, he chooses an integer j satisfying 1 \\leq j \\leq i, and insert j at position j in a (the beginning is position 1...
[{"type": "stdin_stdout", "input": "9\n1 1 1 1 2 1 2 3 2", "output": "1\n2\n2\n3\n1\n2\n1\n1\n1\n"}, {"type": "stdin_stdout", "input": "9\n1 1 1 2 1 1 2 3 2", "output": "1\n2\n2\n3\n1\n1\n2\n1\n1\n"}, {"type": "stdin_stdout", "input": "9\n1 1 1 1 2 1 4 3 2", "output": "1\n2\n1\n3\n2\n4\n1\n1\n1\n"}, {"type": "stdin_std...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn some country live wizards. They love to ride trolleybuses.\n\nA city in this country has a trolleybus depot with n trolleybuses. Every day the trolleybuses leave the depot, one by one and go to the final station. The f...
[{"type": "stdin_stdout", "input": "10 7 8\n2 4\n3 13\n4 7\n5 1\n6 16\n10 9\n12 18\n16 4\n17 16\n20 6\n", "output": "4.285714285714286\n4.511857892036909\n5.642857142857143\n13.071428571428573\n13.071428571428573\n13.071428571428573\n13.51185789203691\n18.28571428571429\n18.511857892036907\n21.761904761904763\n"}, {"ty...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nHeidi found out that the Daleks have created a network of bidirectional Time Corridors connecting different destinations (at different times!). She suspects that they are planning another invasion on the entire Space and ...
[{"type": "stdin_stdout", "input": "10 26\n9 5 277429172\n10 8 789225932\n5 2 992601916\n9 8 277294258\n8 6 245446241\n9 2 378979732\n7 1 895407000\n10 6 699661758\n1 9 865851152\n2 8 397672809\n7 10 756200111\n8 3 431547893\n5 6 465205287\n7 4 957301499\n3 4 308491540\n3 7 258504473\n10 5 282875145\n1 8 262659451\n5 4...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOnce upon a time in the thicket of the mushroom forest lived mushroom gnomes. They were famous among their neighbors for their magic mushrooms. Their magic nature made it possible that between every two neighboring mushro...
[{"type": "stdin_stdout", "input": "62 47 14 888621154\n202 268 300 401 422 660 782 822 1164 1300 1571 1670 1713 1807 2677 2700 2747 2873 2956 3068 3798 4159 4221 4232 4485 4507 4803 5071 5161 5161 5595 5600 5623 5846 5867 5949 6140 6560 6727 6781 6873 7159 7218 7232 7241 7333 7369 7415 7486 7506 7538 7681 7781 8074 87...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA team of three programmers is going to play a contest. The contest consists of $n$ problems, numbered from $1$ to $n$. Each problem is printed on a separate sheet of paper. The participants have decided to divide the pro...
[{"type": "stdin_stdout", "input": "11 7 9\n4 8 9 12 14 16 19 21 22 23 27\n1 2 3 11 17 18 26\n5 6 7 10 13 15 20 24 25\n", "output": "15\n"}, {"type": "stdin_stdout", "input": "11 7 9\n4 8 9 12 14 16 19 21 22 23 27\n1 2 3 11 17 18 26\n5 6 7 10 13 15 20 24 25\n", "output": "15"}, {"type": "stdin_stdout", "input": "5 10 6...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are going out for a walk, when you suddenly encounter a monster. Fortunately, you have N katana (swords), Katana 1, Katana 2, …, Katana N, and can perform the following two kinds of attacks in any order:\n - Wield one...
[{"type": "stdin_stdout", "input": "2 1000000000\n1 1\n1 00000000\n0 30000000\n2 164820504", "output": "1000000000\n"}, {"type": "stdin_stdout", "input": "4 1000000000\n1 1\n1 10000000\n1 30000000\n1 99999999\n", "output": "860000004\n"}, {"type": "stdin_stdout", "input": "4 1000000000\n1 1\n1 00000000\n1 30000000\n1 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe king Copa often has been reported about the Codeforces site, which is rapidly getting more and more popular among the brightest minds of the humanity, who are using it for training and competing. Recently Copa underst...
[{"type": "stdin_stdout", "input": "02.05.90\n08.03.50\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "29.02.80\n29.02.60\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "15.12.62\n17.12.21\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "08.07.20\n27.01.01\n", "output": "YES\n"}, {"type"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nproblem\n\nYou are looking for a constellation in a picture of the starry sky. The photo always contains exactly one figure with the same shape, orientation, and size as the constellation you are looking for. However, the...
[{"type": "stdin_stdout", "input": "5\n8 5\n6 4\n4 3\n7 10\n0 10\n10\n10 5\n2 7\n9 7\n8 10\n10 2\n1 2\n8 1\n6 7\n6 0\n0 0\n5\n904207 809784\n845370 244806\n499091 59863\n638406 182509\n435076 362268\n10\n757559 866424\n114810 239537\n519926 989458\n461089 424480\n674361 448440\n81851 150384\n459107 795405\n299682 6700\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasya decided to write an anonymous letter cutting the letters out of a newspaper heading. He knows heading s1 and text s2 that he wants to send. Vasya can use every single heading letter no more than once. Vasya doesn't ...
[{"type": "stdin_stdout", "input": "kKhuIwRPLCwPFfcnsyCfBdnsraGeOCcLTfXuGjqFSGPSAeDZJSS bXKFanNqWjpFnvRpWxHJspvisDlADJBioxXNbVoXeUedoPcNEpUyEeYxdJXhGzFAmpAiHotSVwbZQsuWjIVhVaEGgqbZHIoDpiEmjTtFylCwCkWWzUOoUfOHxEZvDwNpXhBWamHn\nK VpJjGhNbwCRhcfmNGVjewBFpEmPlIKeTuWiukDtEWpjgqciqglkyNfWrBLbGAKvlNWxaUelJmSlSoakSpRzePvJsshOs...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA programming contest will be held at White Tiger University this year as well. There are several questions in the contest, each of which is assigned a score according to the difficulty level.\n\nThe executive committee d...
[{"type": "stdin_stdout", "input": "7\n-1 -1 19 1 0 4 -2", "output": "2\n"}, {"type": "stdin_stdout", "input": "7\n-1 -1 19 2 0 4 -2", "output": "2\n"}, {"type": "stdin_stdout", "input": "7\n-1 1 19 2 2 4 -1", "output": "2\n"}, {"type": "stdin_stdout", "input": "7\n-1 1 19 2 3 4 -1", "output": "3\n"}, {"type": "stdin_s...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFind the sum of the weights of edges of the Minimum-Cost Arborescence with the root r for a given weighted directed graph G = (V, E).\n\nConstraints\n\n* 1 ≤ |V| ≤ 100\n* 0 ≤ |E| ≤ 1,000\n* 0 ≤ wi ≤ 10,000\n* G has arbore...
[{"type": "stdin_stdout", "input": "6 10 0\n0 2 14\n0 0 1\n0 3 5\n1 4 7\n2 1 6\n1 3 2\n4 1 3\n4 2 2\n1 3 10\n0 5 3", "output": "32\n"}, {"type": "stdin_stdout", "input": "6 10 0\n0 2 14\n0 0 1\n0 3 5\n1 4 7\n2 1 6\n1 3 2\n4 1 3\n4 2 2\n1 3 0\n0 5 3", "output": "30\n"}, {"type": "stdin_stdout", "input": "6 10 0\n0 2 14\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFor given two segments s1 and s2, print \"1\" if they are intersect, \"0\" otherwise.\n\ns1 is formed by end points p0 and p1, and s2 is formed by end points p2 and p3.\n\nConstraints\n\n* 1 ≤ q ≤ 1000\n* -10000 ≤ xpi, yp...
[{"type": "stdin_stdout", "input": "3\n-1 0 0 -1 2 1 4 -2\n1 -1 -1 0 4 2 6 -1\n0 -1 6 1 0 -2 5 0", "output": "0\n0\n0\n"}, {"type": "stdin_stdout", "input": "3\n-1 0 -1 -1 2 1 4 -2\n1 0 0 0 4 1 6 -1\n0 -1 12 1 1 -2 0 0", "output": "0\n0\n1\n"}, {"type": "stdin_stdout", "input": "3\n-1 0 0 -1 2 1 4 -2\n1 0 0 0 4 1 6 -1\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDepth-first search (DFS) follows the strategy to search ”deeper” in the graph whenever possible. In DFS, edges are recursively explored out of the most recently discovered vertex $v$ that still has unexplored edges leavin...
[{"type": "stdin_stdout", "input": "6\n1 2 2 3\n2 2 3 4\n3 1 5\n4 1 6\n5 1 6\n6 -1", "output": "1 1 12\n2 2 11\n3 3 8\n4 9 10\n5 4 7\n6 5 6\n"}, {"type": "stdin_stdout", "input": "6\n1 2 2 3\n2 2 4 4\n3 1 5\n4 1 6\n5 1 6\n6 -1", "output": "1 1 12\n2 2 7\n3 8 11\n4 3 6\n5 9 10\n6 4 5\n"}, {"type": "stdin_stdout", "input...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nByteburg Senate elections are coming. Usually \"United Byteland\", the ruling Byteland party, takes all the seats in the Senate to ensure stability and sustainable development. But this year there is one opposition candid...
[{"type": "stdin_stdout", "input": "11 14\n8 4 17 5 14 9 13 3 17 21 27\n5 16 1 4 24 14 8 32 29 19 17\n11 6 12 0 16 31 27 11 4 7 32\n2 9 2 31 30 12 21 11 29 29 26\n9 21 4 25 26 14 28 16 12 26 23\n31 22 30 5 6 29 31 11 20 18 29\n5 21 27 13 23 23 9 6 25 21 25\n8 16 29 5 26 14 2 15 3 15 22\n19 18 18 21 5 31 14 1 8 3 19\n16...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe country Treeland consists of n cities, some pairs of them are connected with unidirectional roads. Overall there are n - 1 roads in the country. We know that if we don't take the direction of the roads into considerat...
[{"type": "stdin_stdout", "input": "15\n15 6\n2 15\n14 15\n15 12\n1 2\n10 15\n14 4\n13 7\n11 1\n5 2\n7 2\n3 2\n14 8\n9 15\n", "output": "7\n11 13\n"}, {"type": "stdin_stdout", "input": "15\n15 6\n2 15\n14 15\n15 12\n1 2\n10 15\n14 4\n13 7\n11 1\n5 2\n7 2\n3 2\n7 8\n9 15\n", "output": "7\n11 13\n"}, {"type": "stdin_stdo...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMoamen has an array of $n$ distinct integers. He wants to sort that array in non-decreasing order by doing the following operations in order exactly once:\n\nSplit the array into exactly $k$ non-empty subarrays such that ...
[{"type": "stdin_stdout", "input": "3\n5 4\n6 3 4 2 2\n4 4\n1 -8 -1 -2\n5 4\n1 0 3 4 12\n", "output": "YES\nYES\nYES\n"}, {"type": "stdin_stdout", "input": "3\n5 4\n6 3 4 2 2\n4 4\n1 -8 -1 -2\n5 4\n1 0 3 5 12\n", "output": "YES\nYES\nYES\n"}, {"type": "stdin_stdout", "input": "3\n5 4\n6 3 4 2 2\n4 2\n1 -8 -1 -2\n5 4\n1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPolycarp and his friends want to visit a new restaurant. The restaurant has $n$ tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from $1$ to $n$ in the order from l...
[{"type": "stdin_stdout", "input": "7\n4 4\n0100\n4 4\n0100\n4 4\n0100\n4 4\n0100\n4 4\n0100\n4 4\n0100\n4 4\n0100\n", "output": "0\n0\n0\n0\n0\n0\n0\n"}, {"type": "stdin_stdout", "input": "7\n4 4\n0100\n4 4\n0100\n4 4\n0100\n4 4\n0100\n4 4\n0100\n4 4\n0100\n4 4\n0100\n", "output": "0\n0\n0\n0\n0\n0\n0\n"}, {"type": "s...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOn a weekend, Qingshan suggests that she and her friend Daniel go hiking. Unfortunately, they are busy high school students, so they can only go hiking on scratch paper.\n\nA permutation $p$ is written from left to right ...
[{"type": "stdin_stdout", "input": "50\n3 10 13 26 31 27 22 20 9 8 33 30 12 21 16 7 17 11 6 24 14 5 19 25 29 36 37 40 41 44 45 46 47 48 49 50 43 42 39 38 35 34 32 28 23 18 15 4 2 1\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "50\n3 10 13 26 31 27 22 20 9 8 33 30 12 21 16 7 17 11 6 24 14 5 19 25 29 36 37 40 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given $n$ words, each of which consists of lowercase alphabet letters. Each word contains at least one vowel. You are going to choose some of the given words and make as many beautiful lyrics as possible.\n\nEach ...
[{"type": "stdin_stdout", "input": "14\nwow\nthis\nis\nthe\nfirst\nmcdics\ncodeforces\nround\nhooray\ni\nam\nproud\nabout\nthat\n", "output": "3\nabout proud\nhooray round\nwow first\nthis is\ni that\nmcdics am\n"}, {"type": "stdin_stdout", "input": "14\nwow\nthis\nis\nthe\nfirst\nmcdics\ncodeforces\nround\nhooray\ni\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTwo coordinates (a1, a2) and (b1, b2) on a two-dimensional grid of r × c are given. The cost of moving from a cell (e, f) to one of the cells (e + 1, f), (e-1, f), (e, f + 1), (e, f-1) is 1. And. You can also move between...
[{"type": "stdin_stdout", "input": "1226 500 1 0 107 129", "output": "14190866\n"}, {"type": "stdin_stdout", "input": "912 500 2 -1 107 239", "output": "98025026\n"}, {"type": "stdin_stdout", "input": "500 500 -1 0 107 239", "output": "68765037\n"}, {"type": "stdin_stdout", "input": "1174 500 0 0 107 298", "output": "7...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nProblem\n\nFind the area of ​​a regular N / K polygon inscribed in a circle with a radius of 1.\n\nHowever, a regular N / K polygon is defined as \"the outermost figure that takes N points on the circumference at equal in...
[{"type": "stdin_stdout", "input": "110111 100", "output": "3.1415923987\n"}, {"type": "stdin_stdout", "input": "010111 100", "output": "3.1415624160\n"}, {"type": "stdin_stdout", "input": "010111 110", "output": "3.1415593799\n"}, {"type": "stdin_stdout", "input": "010011 110", "output": "3.1415587116\n"}, {"type": "s...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFind places where a string P is found within a text T. Print all indices of T where P found. The indices of T start with 0.\n\nConstraints\n\n* 1 ≤ length of T ≤ 1000\n* 1 ≤ length of P ≤ 1000\n* The input consists of alp...
[{"type": "stdin_stdout", "input": "aaaaaa\naa", "output": "0\n1\n2\n3\n4\n"}, {"type": "stdin_stdout", "input": "aaaaab\naa", "output": "0\n1\n2\n3\n"}, {"type": "stdin_stdout", "input": "`aaaaa\naa", "output": "1\n2\n3\n4\n"}, {"type": "stdin_stdout", "input": "aaabaa\naa", "output": "0\n1\n4\n"}, {"type": "stdin_std...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWe know that prime numbers are positive integers that have exactly two distinct positive divisors. Similarly, we'll call a positive integer t Т-prime, if t has exactly three distinct positive divisors.\n\nYou are given an...
[{"type": "stdin_stdout", "input": "22\n1 2 3 4 5 6 7 13 14 10 12752041 64 121 144 55063932582 124 42550 23756 135153365 25235235235 42351351 81\n", "output": "NO \nNO \nNO \nYES\nNO \nNO \nNO \nNO \nNO \nNO \nYES\nNO \nYES\nNO \nNO \nNO \nNO \nNO \nNO \nNO \nNO \nNO \n"}, {"type": "stdin_stdout", "input": "22\n1 2 3 4...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nCarl is a beginner magician. He has a blue, b violet and c orange magic spheres. In one move he can transform two spheres of the same color into one sphere of any other color. To make a spell that has never been seen befo...
[{"type": "stdin_stdout", "input": "1000000 1000000 1000000\n1000000 1000000 1000000\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "1000000 1000000 1000000\n1000000 1000000 1000000\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "1000100 1000000 1000000\n1000000 1000000 1000000\n", "output": "Yes\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLindsey Buckingham told Stevie Nicks \"Go your own way\". Nicks is now sad and wants to go away as quickly as possible, but she lives in a 2D hexagonal world.\n\nConsider a hexagonal tiling of the plane as on the picture ...
[{"type": "stdin_stdout", "input": "2\n-3 1\n1 3 5 7 9 11\n1000000000 1000000000\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000000\n", "output": "18\n1000000000000000000\n"}, {"type": "stdin_stdout", "input": "2\n-3 1\n1 3 5 7 9 11\n1000000000 1000000000\n1000000000 1000000000 1000000000 1000000000 110...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTanya wants to go on a journey across the cities of Berland. There are $n$ cities situated along the main railroad line of Berland, and these cities are numbered from $1$ to $n$. \n\nTanya plans her journey as follows. Fi...
[{"type": "stdin_stdout", "input": "15\n10 10 10 1 2 3 4 5 6 7 8 9 10 11 12\n", "output": "78\n"}, {"type": "stdin_stdout", "input": "10\n10 60 12 13 14 15 16 66 18 130\n", "output": "130\n"}, {"type": "stdin_stdout", "input": "9\n18 11 24 7 18 10 1 20 17\n", "output": "24\n"}, {"type": "stdin_stdout", "input": "9\n4 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are n wizards. They are numbered from 1 to n, and the i-th wizard has the magical power ri (1 ≤ i ≤ n). Now they are confronting a powerful wizard, whose enemy's magical power is S. n Wizards are good at fighting to...
[{"type": "stdin_stdout", "input": "3 11\n0\n3\n10\n0 0", "output": "1\n"}, {"type": "stdin_stdout", "input": "3 11\n0\n3\n18\n0 0", "output": "2\n"}, {"type": "stdin_stdout", "input": "3 11\n0\n3\n20\n0 0", "output": "2\n"}, {"type": "stdin_stdout", "input": "3 13\n1\n3\n10\n0 0", "output": "0\n"}, {"type": "stdin_std...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe crowdedness of the discotheque would never stop our friends from having fun, but a bit more spaciousness won't hurt, will it?\n\nThe discotheque can be seen as an infinite xy-plane, in which there are a total of n dan...
[{"type": "stdin_stdout", "input": "20\n-961747 0 961747\n-957138 0 957138\n-921232 0 921232\n-887450 0 887450\n-859109 0 859109\n-686787 0 686787\n-664613 0 664613\n-625553 0 625553\n-464803 0 464803\n-422784 0 422784\n-49107 0 49107\n-37424 0 37424\n134718 0 134718\n178903 0 178903\n304415 0 304415\n335362 0 335362\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSereja has a bracket sequence s_1, s_2, ..., s_{n}, or, in other words, a string s of length n, consisting of characters \"(\" and \")\".\n\nSereja needs to answer m queries, each of them is described by two integers l_{i...
[{"type": "stdin_stdout", "input": "(()((((()(())((((((((()((((((()((((\n71\n15 29\n17 18\n5 26\n7 10\n16 31\n26 35\n2 30\n16 24\n2 24\n7 12\n15 18\n12 13\n25 30\n1 30\n12 13\n16 20\n6 35\n20 28\n18 23\n9 31\n12 35\n14 17\n8 16\n3 10\n12 33\n7 19\n2 33\n7 17\n21 27\n10 30\n29 32\n9 28\n18 32\n28 31\n31 33\n4 26\n15 27\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order:\n - Choose two among A, B a...
[{"type": "stdin_stdout", "input": "27 39 17\n", "output": "17\n"}, {"type": "stdin_stdout", "input": "19 43 41\n", "output": "13\n"}, {"type": "stdin_stdout", "input": "39 49 21\n", "output": "19\n"}, {"type": "stdin_stdout", "input": "26 37 19\n", "output": "16\n"}, {"type": "stdin_stdout", "input": "13 48 20\n", "ou...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOne day Alex was creating a contest about his friends, but accidentally deleted it. Fortunately, all the problems were saved, but now he needs to find them among other problems.\n\nBut there are too many problems, to do i...
[{"type": "stdin_stdout", "input": "____________________________________________________________________________________________________\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "__________________________________________________________________________________________________`_\n", "output": "NO\n"}, {...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given array $a_1, a_2, \\dots, a_n$. Find the subsegment $a_l, a_{l+1}, \\dots, a_r$ ($1 \\le l \\le r \\le n$) with maximum arithmetic mean $\\frac{1}{r - l + 1}\\sum\\limits_{i=l}^{r}{a_i}$ (in floating-point nu...
[{"type": "stdin_stdout", "input": "101\n2 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 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 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 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2\n", "output": "101\n"}, {"type": "stdin_stdout", "input": "101\n2 2 2 2 2 2 2...
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\nAfter lessons Nastya decided to read a book. The book contains $n$ chapters, going one after another, so that one page of the book belongs to exactly one chapter and each chapter contains at least one page.\n\nYesterday e...
[{"type": "stdin_stdout", "input": "49\n1 17\n18 115\n116 211\n212 269\n270 345\n346 404\n405 441\n442 467\n468 526\n527 583\n584 664\n665 757\n758 794\n795 802\n803 882\n883 920\n921 960\n961 962\n963 1006\n1007 1081\n1082 1112\n1113 1149\n1150 1217\n1218 1282\n1283 1287\n1288 1365\n1366 1374\n1375 1379\n1380 1478\n14...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAs you have noticed, there are lovely girls in Arpa’s land.\n\nPeople in Arpa's land are numbered from 1 to n. Everyone has exactly one crush, i-th person's crush is person with the number crushi.\n\n<image>\n\nSomeday Ar...
[{"type": "stdin_stdout", "input": "100\n84 94 72 32 61 90 61 2 76 42 35 82 90 29 51 27 65 99 38 41 44 73 100 58 56 64 54 31 14 58 57 64 90 49 73 80 74 19 31 86 73 44 39 43 28 95 23 5 85 5 74 81 34 44 86 30 50 57 94 56 53 42 53 87 92 78 53 49 78 60 37 63 41 19 15 68 25 77 87 48 23 100 54 27 68 84 43 92 76 55 2 94 100 2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nConvexity of a set of points on the plane is the size of the largest subset of points that form a convex polygon. Your task is to build a set of n points with the convexity of exactly m. Your set of points should not cont...
[{"type": "stdin_stdout", "input": "278 100\n", "output": "0 100000\n1 100001\n2 100004\n3 100009\n4 100016\n5 100025\n6 100036\n7 100049\n8 100064\n9 100081\n10 100100\n11 100121\n12 100144\n13 100169\n14 100196\n15 100225\n16 100256\n17 100289\n18 100324\n19 100361\n20 100400\n21 100441\n22 100484\n23 100529\n24 1005...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAt the school where the twins Ami and Mami attend, the summer vacation has already begun, and a huge amount of homework has been given this year as well. However, the two of them were still trying to go out without doing ...
[{"type": "stdin_stdout", "input": "4\n1 2\n3 1\n4 1\n2 1\n3\n10 4\n1 2\n1 2\n1\n1000 1000\n10\n5 62\n10 68\n15 132\n20 73\n25 75\n30 77\n35 79\n40 82\n45 100\n815 283\n6\n106 21\n53 55\n118 77\n19 13\n83 42\n2 1\n0", "output": "15\n24\n3000\n2072\n590\n"}, {"type": "stdin_stdout", "input": "4\n1 2\n3 1\n4 1\n2 2\n3\n1...
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": "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": "st...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nExample\n\nInput\n\n2 2 2 0 0 0 5\n\n\nOutput\n\n1 3 3 1 0\n\nThe input will be stdin and you should print your solution to stdout\n\n\nNow solve the problem and return the code.\n\nWrite Python code to solve this problem...
[{"type": "stdin_stdout", "input": "2 2 4 1 0 1 35", "output": "1 4 6 4 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\n"}, {"type": "stdin_stdout", "input": "1 1 4 0 0 0 24", "output": "1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n"}, {"type": "stdin_stdout", "input": "1 1 4 0 0 1 24", "output": "1 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFafa owns a company that works on huge projects. There are n employees in Fafa's company. Whenever the company has a new project to start working on, Fafa has to divide the tasks of this project among all the employees.\n...
[{"type": "stdin_stdout", "input": "100000\n", "output": "35\n"}, {"type": "stdin_stdout", "input": "83160\n", "output": "127\n"}, {"type": "stdin_stdout", "input": "127925\n", "output": "23\n"}, {"type": "stdin_stdout", "input": "99999\n", "output": "11\n"}, {"type": "stdin_stdout", "input": "65536\n", "output": "16\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRead problems statements in Mandarin Chinese and Russian. \n\nAditi recently discovered a new magic trick. First, she gives you an integer N and asks you to think an integer between 1 and N. Then she gives you a bundle o...
[{"type": "stdin_stdout", "input": "2\n12\n191", "output": "5\n11\n"}, {"type": "stdin_stdout", "input": "2\n14\n108", "output": "6\n10\n"}, {"type": "stdin_stdout", "input": "2\n21\n114", "output": "7\n10\n"}, {"type": "stdin_stdout", "input": "2\n25\n193", "output": "7\n11\n"}, {"type": "stdin_stdout", "input": "2\n3...
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 \n"}, {"type": "stdin_stdout", "input": "9 9 7\n1 2 1000000000\n7 9 1000000000\n9 4 1000000000\n2 6 10...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe sales department of Japanese Ancient Giant Corp. is visiting a hot spring resort for their recreational trip. For deepening their friendships, they are staying in one large room of a Japanese-style hotel called a ryok...
[{"type": "stdin_stdout", "input": "4\n0 0 x\n2 0 x\n0 1 x\n2 1 x\n4\n1 0 x\n0 1 x\n3 1 x\n1 2 x\n4\n0 0 x\n2 0 y\n0 1 y\n1 2 x\n0", "output": "Yes\nYes\nYes\n"}, {"type": "stdin_stdout", "input": "4\n0 0 x\n2 0 x\n0 1 x\n2 1 x\n4\n1 0 x\n0 1 x\n3 1 x\n1 2 x\n4\n0 0 x\n2 0 y\n0 1 y\n2 2 x\n0", "output": "Yes\nYes\nYes\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPeter likes to travel by train. He likes it so much that on the train he falls asleep. \n\nOnce in summer Peter was going by train from city A to city B, and as usual, was sleeping. Then he woke up, started to look throug...
[{"type": "stdin_stdout", "input": "aababaaababaabbaabababaaababaabababbaabbabaabababaabbabbbababbababababababaabababaababaaaabababaabab\nabaabababaa\nabaabbaa\n", "output": "backward\n"}, {"type": "stdin_stdout", "input": "aababaaababaabbaabababaaababaabababbaabbabaabababaabbabbbababbababababababaabababaababaaaabababa...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA permutation of size n is an array of size n such that each integer from 1 to n occurs exactly once in this array. An inversion in a permutation p is a pair of indices (i, j) such that i > j and a_{i} < a_{j}. For exampl...
[{"type": "stdin_stdout", "input": "1\n1\n10\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n", "output": "even\neven\neven\neven\neven\neven\neven\neven\neven\neven\n"}, {"type": "stdin_stdout", "input": "1\n1\n10\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n", "output": "even\neven\neven\neven\neven\neven\ne...
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": "12 12\n10\n11\n5\n3\n11\n2\n8\n6\n4\n4\n12\n1\n", "output": "9\n6\n3\n2\n6\n7\n12\n8\n10\n10\n11\n1\n"}, {"type": "stdin_stdout", "input": "12 12\n9\n11\n5\n3\n11\n2\n8\n4\n4\n4\n12\n1\n", "output": "5\n6\n3\n2\n6\n7\n12\n10\n10\n10\n11\n1\n"}, {"type": "stdin_stdout", "input": "12 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLimak is a little polar bear. He loves connecting with other bears via social networks. He has n friends and his relation with the i-th of them is described by a unique integer t_{i}. The bigger this value is, the better ...
[{"type": "stdin_stdout", "input": "20 2 15\n1744261 55128070 116962690 156763505 188535242 194018601 134662359 428710623 442819431 483000923 516768937 552903993 633087286 373594646 415184994 714291344 717660646 846508634 879748146 937368929\n2 20\n1 2\n2 2\n1 19\n1 12\n2 2\n2 18\n2 11\n1 16\n2 1\n2 3\n2 19\n1 17\n2 9\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFor a given sequence $A = \\\\{a_0, a_1, ... a_{n-1}\\\\}$, the number of pairs $(i, j)$ where $a_i > a_j$ and $i < j$, is called the number of inversions. The number of inversions is equal to the number of swaps of Bubbl...
[{"type": "stdin_stdout", "input": "5\n3 -13 7 -1 -4", "output": "6\n"}, {"type": "stdin_stdout", "input": "5\n3 -13 10 0 -4", "output": "6\n"}, {"type": "stdin_stdout", "input": "5\n3 -13 10 0 -5", "output": "6\n"}, {"type": "stdin_stdout", "input": "5\n2 -13 10 0 -5", "output": "6\n"}, {"type": "stdin_stdout", "input...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are $n$ detachments on the surface, numbered from $1$ to $n$, the $i$-th detachment is placed in a point with coordinates $(x_i, y_i)$. All detachments are placed in different points.\n\nBrimstone should visit each ...
[{"type": "stdin_stdout", "input": "23\n-1000000000 -964752353\n-967012509 -1000000000\n34021744 1000000000\n-931956512 -34021744\n-1034253 967204159\n-1034253 -34021744\n-1034253 -1000000000\n-931956512 -1000000000\n-967012509 1000000000\n964944003 1225903\n1000000000 1225903\n-967012509 1225903\n-1034253 -964752353\n...
code_stdio