messages listlengths 1 1 | ground_truth stringlengths 156 726k | dataset stringclasses 2
values |
|---|---|---|
[
{
"content": "The Little Elephant very much loves sums on intervals.\n\nThis time he has a pair of integers l and r (l ≤ r). The Little Elephant has to find the number of such integers x (l ≤ x ≤ r), that the first digit of integer x equals the last one (in decimal notation). For example, such numbers as 101, 4... | [{"input": "100000000000000000 1000000000000000000\n", "output": "90000000000000000\n"}, {"input": "779547115376367013 980561039207670775\n", "output": "20101392383130376\n"}, {"input": "458985985498001244 985458425544874008\n", "output": "52647244004687276\n"}, {"input": "645762257531682046 885295120956158518\n", "out... | code_stdio |
[
{
"content": "Once upon a time in the Kingdom of Far Far Away lived Sam the Farmer. Sam had a cow named Dawn and he was deeply attached to her. Sam would spend the whole summer stocking hay to feed Dawn in winter. Sam scythed hay and put it into haystack. As Sam was a bright farmer, he tried to make the process... | [{"input": "1987385827\n", "output": "3123034907 15899086625\n"}, {"input": "1286843196\n", "output": "1286843244 10294745577\n"}, {"input": "1600010311\n", "output": "1936854671 12800082497\n"}, {"input": "1856589245\n", "output": "1007862841 14852713969\n"}, {"input": "1207747990\n", "output": "1328522831 9661983929\... | code_stdio |
[
{
"content": "Ashish and Vivek play a game on a matrix consisting of $n$ rows and $m$ columns, where they take turns claiming cells. Unclaimed cells are represented by $0$, while claimed cells are represented by $1$. The initial state of the matrix is given. There can be some claimed cells in the initial state.... | [{"input": "4\n2 2\n0 0\n0 0\n2 2\n1 0\n0 0\n2 3\n0 0 0\n1 1 0\n3 3\n1 0 0\n0 0 0\n1 0 0\n", "output": "Vivek\nAshish\nAshish\nAshish\n"}, {"input": "4\n2 2\n1 0\n0 0\n2 2\n0 0\n0 1\n2 3\n1 0 1\n1 1 0\n3 3\n1 0 0\n0 0 0\n1 0 0\n", "output": "Ashish\nAshish\nVivek\nAshish\n"}, {"input": "4\n2 2\n0 0\n0 0\n2 2\n1 0\n0 0\... | code_stdio |
[
{
"content": "There is a farm whose length and width are A yard and B yard, respectively. A farmer, John, made a vertical road and a horizontal road inside the farm from one border to another, as shown below: (The gray part represents the roads.)\n\nWhat is the area of this yard excluding the roads? Find it.\n\... | [{"input": "100 100\n", "output": "9801\n"}, {"input": "91 61\n", "output": "5400\n"}, {"input": "-33 13", "output": "-408\n"}, {"input": "-36 13", "output": "-444\n"}, {"input": "-36 17", "output": "-592\n"}, {"input": "-1 -105", "output": "212\n"}, {"input": "-2 -105", "output": "318\n"}, {"input": "-2 -162", "output... | code_stdio |
[
{
"content": "Levko loves array a_1, a_2, ... , a_{n}, consisting of integers, very much. That is why Levko is playing with array a, performing all sorts of operations with it. Each operation Levko performs is of one of two types:\n\n Increase all elements from l_{i} to r_{i} by d_{i}. In other words, perform ... | [{"input": "97 29\n2 78 82 356152\n2 14 29 430177\n1 59 84 3680\n1 49 89 -2247\n1 92 96 3701\n2 54 89 377271\n1 62 70 -507\n2 94 97 431563\n1 46 55 -9257\n1 51 83 1627\n1 10 20 6633\n1 17 34 -9263\n2 66 92 383251\n1 12 82 3884\n1 78 96 -5379\n2 13 35 424798\n1 68 91 2939\n2 80 84 214725\n1 61 85 -4390\n1 85 96 3106\n2 ... | code_stdio |
[
{
"content": "The only difference between easy and hard versions is the constraints.\n\nPolycarp has to write a coursework. The coursework consists of $m$ pages.\n\nPolycarp also has $n$ cups of coffee. The coffee in the $i$-th cup Polycarp has $a_i$ caffeine in it. Polycarp can drink some cups of coffee (each ... | [{"input": "100 10000\n93 99 95 105 94 108 104 104 102 112 106 82 114 104 88 107 105 104 93 96 103 109 105 82 107 95 83 93 120 115 96 104 96 86 87 102 103 108 97 84 108 117 109 107 80 87 102 107 88 97 96 101 101 114 106 103 99 101 105 102 85 94 98 101 115 100 91 92 108 105 94 110 91 89 119 119 93 103 101 84 87 81 105 1... | code_stdio |
[
{
"content": "You have probably registered on Internet sites many times. And each time you should enter your invented password. Usually the registration form automatically checks the password's crypt resistance. If the user's password isn't complex enough, a message is displayed. Today your task is to implement... | [{"input": "c7jqaudcqmv8o7zvb5x_gp6zcgl6nwr7tz5or!28.tj8s1m2.wxz5a4id03!rq07?662vy.7.p5?vk2f2mc7ag8q3861rgd0rmbr\n", "output": "Too weak\n"}, {"input": "i6a.,8jb,n0kv4.1!7h?p.96pnhhgy6cl7dg7e4o6o384ys3z.t71kkq,,w,oqi4?u,,m5!rzu6wym_4hm,ohjy!.vvksl?pt,,1\n", "output": "Too weak\n"}, {"input": "M10V_MN_1K8YX2LA!89EYV7!5V... | code_stdio |
[
{
"content": "In computer science and discrete mathematics, an [inversion](https://en.wikipedia.org/wiki/Inversion_%28discrete_mathematics%29) is a pair of places in a sequence where the elements in these places are out of their natural order. So, if we use ascending order for a group of numbers, then an invers... | [{"input": "[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]", "output": "[0]", "fn_name": "count_inversion"}, {"input": "[14, 12, 17, 124, 1, -12, 21, -24]", "output": "[18]", "fn_name": "count_inversion"}, {"input": "[10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]", "output": "[55]", "fn_name": "count_inversion"}, {"input": "[324, 1... | code_functional |
[
{
"content": "There is a string S consisting of digits 1, 2, ..., 9.\nLunlun, the Dachshund, will take out three consecutive digits from S, treat them as a single integer X and bring it to her master. (She cannot rearrange the digits.)\nThe master's favorite number is 753. The closer to this number, the better.... | [{"input": "1111111111\n", "output": "642\n"}, {"input": "2432423234\n", "output": "321\n"}, {"input": "8889998899\n", "output": "135\n"}, {"input": "1234567876\n", "output": "34\n"}, {"input": "6945248811\n", "output": "58\n"}, {"input": "1110111111", "output": "642\n"}, {"input": "1011001000", "output": "643\n"}, {"i... | code_stdio |
[
{
"content": "Read problems statements in Mandarin Chinese and Russian. \n\nAlice and Bob, both have to drink water. But they both don't want to go, so they will play a game to decide who will fetch water for both of them. Alice will choose a number randomly between 1 and N (both inclusive) and Bob will choose... | [{"input": "3\n17 13\n3 12\n5 3", "output": "110/221\n1/2\n7/15\n"}, {"input": "3\n17 11\n3 5\n5 3", "output": "93/187\n7/15\n7/15\n"}, {"input": "3\n17 11\n3 6\n5 3", "output": "93/187\n1/2\n7/15\n"}, {"input": "3\n1 2\n11 11\n2 1", "output": "1/2\n60/121\n1/2\n"}, {"input": "3\n17 11\n1 5\n1 3", "output": "93/187\n2/... | code_stdio |
[
{
"content": "Tokitsukaze is one of the characters in the game \"Kantai Collection\". In this game, every character has a common attribute — health points, shortened to HP.\n\nIn general, different values of HP are grouped into $4$ categories: Category $A$ if HP is in the form of $(4 n + 1)$, that is, when div... | [{"input": "100\n", "output": "1 A\n"}, {"input": "100\n", "output": "1 A\n"}, {"input": "101\n", "output": "0 A\n"}, {"input": "130\n", "output": "1 B\n"}, {"input": "121\n", "output": "0 A\n"}, {"input": "118\n", "output": "1 B\n"}, {"input": "112\n", "output": "1 A\n"}, {"input": "109\n", "output": "0 A\n"}, {"input... | code_stdio |
[
{
"content": "In the evening, after the contest Ilya was bored, and he really felt like maximizing. He remembered that he had a set of n sticks and an instrument. Each stick is characterized by its length l_{i}.\n\nIlya decided to make a rectangle from the sticks. And due to his whim, he decided to make rectang... | [{"input": "100\n4116 4116 4117 4117 4117 4117 4118 4119 4119 4119 4119 4120 4120 4120 4120 4121 4122 4123 4123 4123 4123 4124 4124 4124 4124 4125 4126 4126 4126 4126 4127 4127 4127 4127 4128 4128 4128 4128 4129 4129 4130 4130 4131 4132 4133 4133 4134 4134 4135 4135 4136 4137 4137 4137 4138 4139 4140 4140 4141 4141 414... | code_stdio |
[
{
"content": "Berland starts to seize the initiative on the war with Flatland. To drive the enemy from their native land, the berlanders need to know exactly how many more flatland soldiers are left in the enemy's reserve. Fortunately, the scouts captured an enemy in the morning, who had a secret encrypted mess... | [{"input": "63 5\n76826 79919 83599 93821 79919 46132 46132 46132 79919 76826 79919 79919 76826 79919 79919 76826 76826 46132 76826 40347 79919 46132 76826 83599 79919 79919 46132 46132 46132 83599 83599 79919 46132 83599 93821 76826 81314 79919 79919 83599 76826 76826 76826 76826 46132 76826 46132 79919 76826 83599 79... | code_stdio |
[
{
"content": "You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.\n\nFor example:\n\nif $l=909$, then addin... | [{"input": "4\n0 9\n0 10\n10 23\n2 1010000000\n", "output": "9\n11\n14\n1122222220\n"}, {"input": "4\n1 18\n8 10\n10 12\n1 1000000000\n", "output": "18\n3\n2\n1111111110\n"}, {"input": "4\n0 12\n9 10\n6 23\n1 1000000000\n", "output": "13\n2\n19\n1111111110\n"}, {"input": "4\n1 36\n8 10\n10 12\n1 1000000000\n", "output"... | code_stdio |
[
{
"content": "Little Masha loves arranging her toys into piles on the floor. And she also hates it when somebody touches her toys. One day Masha arranged all her n toys into several piles and then her elder brother Sasha came and gathered all the piles into one. Having seen it, Masha got very upset and started ... | [{"input": "7\n", "output": "877\n{1,2,3,4,5,6,7}\n{1,2,3,4,5,6},{7}\n{1,2,3,4,5},{6},{7}\n{1,2,3,4,5},{6,7}\n{1,2,3,4,5,7},{6}\n{1,2,3,4,7},{5},{6}\n{1,2,3,4},{5,7},{6}\n{1,2,3,4},{5},{6,7}\n{1,2,3,4},{5},{6},{7}\n{1,2,3,4},{5,6},{7}\n{1,2,3,4},{5,6,7}\n{1,2,3,4,7},{5,6}\n{1,2,3,4,6,7},{5}\n{1,2,3,4,6},{5,7}\n{1,2,3,4... | code_stdio |
[
{
"content": "You are given two integers $n$ and $m$. Find the $\\operatorname{MEX}$ of the sequence $n \\oplus 0, n \\oplus 1, \\ldots, n \\oplus m$. Here, $\\oplus$ is the bitwise XOR operator .\n\n$\\operatorname{MEX}$ of the sequence of non-negative integers is the smallest non-negative integer that doesn't... | [{"input": "5\n14 1\n3 0\n2 0\n110 1252\n528350 1051160\n", "output": "0\n0\n0\n1152\n1048576\n"}, {"input": "5\n22 0\n3 0\n1 1\n100 1218\n137071 1051160\n", "output": "0\n0\n2\n1152\n1048576\n"}, {"input": "5\n28 0\n4 0\n1 2\n110 1590\n978289 1283232\n", "output": "0\n0\n2\n1536\n1048576\n"}, {"input": "5\n28 0\n4 0\n... | code_stdio |
[
{
"content": "Buses run between the cities A and B, the first one is at 05:00 AM and the last one departs not later than at 11:59 PM. A bus from the city A departs every a minutes and arrives to the city B in a t_{a} minutes, and a bus from the city B departs every b minutes and arrives to the city A in a t_{b}... | [{"input": "60 120\n17 120\n23:00\n", "output": "11\n"}, {"input": "60 120\n17 120\n23:00\n", "output": "11\n"}, {"input": "60 120\n17 175\n23:00\n", "output": "14\n"}, {"input": "111 120\n24 100\n13:00\n", "output": "9\n"}, {"input": "88 120\n17 175\n23:00\n", "output": "14\n"}, {"input": "60 120\n24 100\n13:00\n", "o... | code_stdio |
[
{
"content": "In a far away kingdom young pages help to set the table for the King. As they are terribly mischievous, one needs to keep an eye on the control whether they have set everything correctly. This time the royal chef Gerasim had the impression that the pages have played a prank again: they had poured ... | [{"input": "98\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\n702\... | code_stdio |
[
{
"content": "-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 30).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Example-----\nInput\n3\n\nOutput\n27\n\nWrite Python code to solve this problem. Your program should read the input from stdin and write the output to stdout. Enclose ... | [{"input": "011\n", "output": "274\n"}, {"input": "010\n", "output": "265\n"}, {"input": "10\n", "output": "265\n"}, {"input": "11\n", "output": "274\n"}, {"input": "12\n", "output": "319\n"}, {"input": "13\n", "output": "346\n"}, {"input": "14\n", "output": "355\n"}, {"input": "15\n", "output": "378\n"}, {"input": "16... | code_stdio |
[
{
"content": "The Little Elephant loves sortings.\n\nHe has an array a consisting of n integers. Let's number the array elements from 1 to n, then the i-th element will be denoted as ai. The Little Elephant can make one move to choose an arbitrary pair of integers l and r (1 ≤ l ≤ r ≤ n) and increase ai by 1 fo... | [{"input": "47\n703599938 780784195 912005704 957182560 961181825 964876912 996677776 997012583 999004240 999888999 999980718 999997556 999997940 999999989 999999991 999999991 999999999 999999999 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 100... | code_stdio |
[
{
"content": "In one little known, but very beautiful country called Waterland, lives a lovely shark Valerie. Like all the sharks, she has several rows of teeth, and feeds on crucians. One of Valerie's distinguishing features is that while eating one crucian she uses only one row of her teeth, the rest of the t... | [{"input": "54 22 1009\n15 7\n17 7\n11 9\n6 11\n12 9\n13 8\n13 12\n22 11\n20 9\n20 7\n16 11\n19 12\n3 12\n15 9\n1 12\n2 10\n16 10\n16 10\n14 10\n15 11\n11 9\n14 8\n10 10\n16 12\n1 8\n3 8\n21 11\n18 12\n2 6\n9 11\n11 7\n15 9\n20 11\n6 8\n8 8\n19 11\n15 7\n9 9\n22 3\n12 9\n17 9\n17 11\n12 7\n15 9\n5 11\n11 11\n18 8\n7 10... | code_stdio |
[
{
"content": "For a given polygon g, computes the area of the polygon.\n\ng is represented by a sequence of points p1, p2,..., pn where line segments connecting pi and pi+1 (1 ≤ i ≤ n-1) are sides of g. The line segment connecting pn and p1 is also a side of the polygon.\n\nNote that the polygon is not necessar... | [{"input": "4\n-1 -2\n-1 0\n-1 14\n-5 2", "output": "32.0\n"}, {"input": "4\n-1 -2\n-1 0\n-1 17\n-5 2", "output": "38.0\n"}, {"input": "4\n0 -1\n10 -3\n71 0\n0 11", "output": "502.0\n"}, {"input": "4\n0 -4\n-1 0\n-1 14\n-6 3", "output": "43.5\n"}, {"input": "4\n0 -4\n-1 0\n-1 14\n-5 3", "output": "34.5\n"}, {"input": "... | code_stdio |
[
{
"content": "Let N be a positive integer.\nThere is a numerical sequence of length 3N, a = (a_1, a_2, ..., a_{3N}).\nSnuke is constructing a new sequence of length 2N, a', by removing exactly N elements from a without changing the order of the remaining elements.\nHere, the score of a' is defined as follows: (... | [{"input": "3\n23 1 2 -2 1 12 -2 -1 3", "output": "37\n"}, {"input": "3\n8 2 2 13 4 6 4 -1 15", "output": "16\n"}, {"input": "3\n7 1 2 18 11 1 2 2 11", "output": "31\n"}, {"input": "3\n13 2 2 13 4 6 4 0 11", "output": "20\n"}, {"input": "3\n7 1 2 18 11 1 2 0 11", "output": "33\n"}, {"input": "3\n7 4 2 26 14 1 1 1 13", ... | code_stdio |
[
{
"content": "Pashmak's homework is a problem about graphs. Although he always tries to do his homework completely, he can't solve this problem. As you know, he's really weak at graph theory; so try to help him in solving the problem.\n\nYou are given a weighted directed graph with n vertices and m edges. You n... | [{"input": "10 12\n1 2 2\n2 1 2\n1 3 1\n3 1 1\n1 4 1\n4 1 1\n2 3 1\n3 2 1\n2 4 1\n4 2 1\n3 4 2\n4 3 2\n", "output": "2\n"}, {"input": "4 12\n1 2 2\n2 1 2\n1 3 1\n3 1 1\n1 4 1\n4 1 1\n2 3 1\n3 2 1\n2 4 1\n4 2 1\n3 4 2\n4 3 2\n", "output": "2\n"}, {"input": "4 12\n1 2 2\n2 1 2\n1 3 1\n3 1 1\n1 4 1\n4 1 1\n2 3 1\n3 2 1\n2... | code_stdio |
[
{
"content": "John Doe started thinking about graphs. After some thought he decided that he wants to paint an undirected graph, containing exactly k cycles of length 3. \n\nA cycle of length 3 is an unordered group of three distinct graph vertices a, b and c, such that each pair of them is connected by a graph ... | [{"input": "105906\n", "output": "90\n011111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\n101111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\n110111111111111111111111111111111111111111111111111111111111111111111111111111111111111100\n111011... | code_stdio |
[
{
"content": "Your task is to convert a given number into a string with commas added for easier readability. The number should be rounded to 3 decimal places and the commas should be added at intervals of three digits before the decimal point. There does not need to be a comma at the end of the number.\n\nYou ... | [{"input": "1000000000.23", "output": "[\"1,000,000,000.23\"]", "fn_name": "commas"}, {"input": "-1000000.123", "output": "[\"-1,000,000.123\"]", "fn_name": "commas"}, {"input": "-1234567.0001236", "output": "[\"-1,234,567\"]", "fn_name": "commas"}, {"input": "9123.212", "output": "[\"9,123.212\"]", "fn_name": "commas"... | code_functional |
[
{
"content": "A decimal representation of an integer can be transformed to another integer by rearranging the order of digits. Let us make a sequence using this fact.\n\nA non-negative integer a0 and the number of digits L are given first. Applying the following rules, we obtain ai+1 from ai.\n\n1. Express the ... | [{"input": "2012 8\n83268 3\n1112 9\n0 1\n20 2\n0 0", "output": "13 86526432 3\n5 74943 4\n5 954197541 14\n0 0 1\n2 63 5\n"}, {"input": "245 9\n83268 23\n821 3\n0 0\n99 1\n0 -1", "output": "3 863098632 14\n12 98765433331976666543211 5\n3 495 1\n"}, {"input": "2012 8\n83268 3\n1112 9\n0 1\n17 2\n0 0", "output": "13 8652... | code_stdio |
[
{
"content": "A matrix of size $n \\times m$ is called nice, if all rows and columns of the matrix are palindromes. A sequence of integers $(a_1, a_2, \\dots , a_k)$ is a palindrome, if for any integer $i$ ($1 \\le i \\le k$) the equality $a_i = a_{k - i + 1}$ holds.\n\nSasha owns a matrix $a$ of size $n \\time... | [{"input": "9\n1 1\n132703760\n1 1\n33227322\n1 1\n943066084\n1 1\n729139464\n1 1\n450488051\n1 1\n206794512\n1 1\n372520051\n1 1\n552003271\n1 1\n319080560\n", "output": "0\n0\n0\n0\n0\n0\n0\n0\n0\n"}, {"input": "9\n1 1\n132703760\n1 1\n33227322\n1 1\n943066084\n1 1\n729139464\n1 1\n450488051\n1 1\n206794512\n1 1\n372... | code_stdio |
[
{
"content": "We have 3N colored balls with IDs from 1 to 3N. A string S of length 3N represents the colors of the balls. The color of Ball i is red if S_i is `R`, green if S_i is `G`, and blue if S_i is `B`. There are N red balls, N green balls, and N blue balls.\n\nTakahashi will distribute these 3N balls to ... | [{"input": "5\nRRRGRBBBBGBGGRG", "output": "12960"}, {"input": "5\nBBRBRRGGRGRGGBB", "output": "11520"}, {"input": "5\nBBBRBGGRBRRGRGG", "output": "25920"}, {"input": "5\nBRRRRGBBGGGBGRB", "output": "1440"}, {"input": "5\nBRRGRBBBBGRGGRG", "output": "1920"}, {"input": "5\nGGBBRBGGBRRGRRB", "output": "2880"}, {"input": ... | code_stdio |
[
{
"content": "**Steps**\n1. Square the numbers that are greater than zero.\n2. Multiply by 3 every third number.\n3. Multiply by -1 every fifth number.\n4. Return the sum of the sequence.\n\n**Example** \n`{ -2, -1, 0, 1, 2 }` returns `-6`\n```\n1. { -2, -1, 0, 1 * 1, 2 * 2 }\n2. { -2, -1, 0 * 3, 1, 4 }\n3. {... | [{"input": "[1, -1, 10, -9, 16, 15, 45, -73, -26]", "output": "[2584]", "fn_name": "calc"}, {"input": "[1, 1, -9, 9, 16, -15, -45, -73, 26]", "output": "[1665]", "fn_name": "calc"}, {"input": "[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]", "output": "[0]", "fn_name": "calc"}, {"input": "[-5, -5, -5, -5, -5, -5, -5]", "outpu... | code_functional |
[
{
"content": "There are N robots numbered 1 to N placed on a number line. Robot i is placed at coordinate X_i. When activated, it will travel the distance of D_i in the positive direction, and then it will be removed from the number line. All the robots move at the same speed, and their sizes are ignorable.\nTa... | [{"input": "20\n-8 1\n26 4\n0 5\n9 1\n19 4\n22 20\n28 27\n11 8\n-3 20\n-25 17\n10 4\n-18 27\n24 28\n-11 19\n2 27\n-2 18\n-1 12\n-24 29\n31 29\n29 7\n", "output": "110\n"}, {"input": "20\n-8 2\n26 0\n0 5\n15 1\n10 4\n22 10\n28 27\n11 8\n-3 61\n-25 17\n13 4\n-18 27\n24 28\n-11 19\n2 27\n-2 18\n-1 12\n-24 29\n31 68\n29 7"... | code_stdio |
[
{
"content": "Revised\n\nThe current era, Heisei, will end on April 30, 2019, and a new era will begin the next day. The day after the last day of Heisei will be May 1, the first year of the new era.\n\nIn the system developed by the ACM-ICPC OB / OG Association (Japanese Alumni Group; JAG), the date uses the J... | [{"input": "HEISEI 1 0 0\nHEISEI 31 4 2\nIETEIH 31 5 3\nIFISEH 142 12 42\nHEISEI 15 8 30\nIEJSEH 103 2 42\nHEISEI 3 3 14\nHEISEI 28 2 23\n#", "output": "HEISEI 1 0 0\nHEISEI 31 4 2\n? 1 5 3\n? 112 12 42\nHEISEI 15 8 30\n? 73 2 42\nHEISEI 3 3 14\nHEISEI 28 2 23\n"}, {"input": "HEISEI 1 0 0\nHEISEI 31 4 2\nIETEIH 31 5 2\... | code_stdio |
[
{
"content": "HDD hard drives group data by sectors. All files are split to fragments and each of them are written in some sector of hard drive. Note the fragments can be written in sectors in arbitrary order.\n\nOne of the problems of HDD hard drives is the following: the magnetic head should move from one sec... | [{"input": "100\n11 9 35 34 51 74 16 67 26 21 14 80 84 79 7 61 28 3 53 43 42 5 56 36 69 30 22 88 1 27 65 91 46 31 59 50 17 96 25 18 64 55 78 2 63 24 95 48 93 13 38 76 89 94 15 90 45 81 52 87 83 73 44 49 23 82 85 75 86 33 47 19 58 97 37 20 40 10 92 4 6 68 77 54 71 12 62 60 100 39 41 99 72 29 57 8 70 32 66 98\n", "output... | code_stdio |
[
{
"content": "Polycarp wants to buy exactly $n$ shovels. The shop sells packages with shovels. The store has $k$ types of packages: the package of the $i$-th type consists of exactly $i$ shovels ($1 \\le i \\le k$). The store has an infinite number of packages of each type.\n\nPolycarp wants to choose one type ... | [{"input": "10\n208790602 104395300\n208790602 104395300\n208790602 104395300\n208790602 104395300\n208790602 104395300\n208790602 104395300\n208790602 104395300\n208790602 104395300\n208790602 104395300\n208790602 104395300\n", "output": "104395301\n104395301\n104395301\n104395301\n104395301\n104395301\n104395301\n104... | code_stdio |
[
{
"content": "You are given a connected weighted undirected graph without any loops and multiple edges. \n\nLet us remind you that a graph's spanning tree is defined as an acyclic connected subgraph of the given graph that includes all of the graph's vertexes. The weight of a tree is defined as the sum of weigh... | [{"input": "25 25\n17 13 578885\n18 25 860003\n21 12 860003\n16 4 860003\n7 14 752263\n25 11 860003\n11 19 860003\n17 5 752263\n14 25 752263\n8 17 578885\n18 17 860003\n1 16 860003\n6 1 578885\n23 18 752263\n25 10 578885\n5 9 752263\n6 18 752263\n2 15 578885\n19 12 860003\n22 7 578885\n14 5 860003\n15 16 752263\n20 16 ... | code_stdio |
[
{
"content": "Sereja has two sequences a and b and number p. Sequence a consists of n integers a_1, a_2, ..., a_{n}. Similarly, sequence b consists of m integers b_1, b_2, ..., b_{m}. As usual, Sereja studies the sequences he has. Today he wants to find the number of positions q (q + (m - 1)·p ≤ n; q ≥ 1), such... | [{"input": "82 50 1\n4 2 2 4 4 3 2 2 3 3 4 3 4 1 4 1 4 3 5 3 4 2 4 4 5 2 5 4 2 4 2 5 3 2 3 4 2 5 4 3 3 4 3 4 1 1 5 2 4 1 3 3 2 4 1 2 2 5 4 4 5 3 3 1 2 3 4 5 3 1 2 3 3 5 5 2 4 1 4 2 3 1\n4 3 3 3 4 1 4 4 5 5 5 2 5 4 1 2 2 1 3 3 3 3 2 5 3 2 4 3 2 2 4 4 4 3 4 2 1 2 3 2 1 1 5 2 3 5 4 5 3 4\n", "output": "2\n24 28\n"}, {"inp... | code_stdio |
[
{
"content": "This is an easier version of the problem. In this version $n \\le 1000$\n\nThe outskirts of the capital are being actively built up in Berland. The company \"Kernel Panic\" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway... | [{"input": "100\n82 51 81 14 37 17 78 92 64 15 8 86 89 8 87 77 66 10 15 12 100 25 92 47 21 78 20 63 22 49 41 36 41 79 16 87 87 69 3 76 80 60 100 49 70 59 72 8 38 71 45 97 71 14 76 54 81 4 59 46 39 29 92 3 49 22 53 99 59 52 74 31 92 43 42 23 44 9 82 47 7 40 12 9 3 55 37 85 46 22 84 52 98 41 21 77 63 17 62 91\n", "output... | code_stdio |
[
{
"content": "Raccoon is fighting with a monster.\nThe health of the monster is H.\nRaccoon can use N kinds of special moves. Using the i-th move decreases the monster's health by A_i.\nThere is no other way to decrease the monster's health.\nRaccoon wins when the monster's health becomes 0 or below.\nIf Raccoo... | [{"input": "210 5\n31 41 59 26 53\n", "output": "Yes\n"}, {"input": "211 5\n31 41 59 26 53\n", "output": "No\n"}, {"input": "210 3\n31 41 59 26 53", "output": "Yes\n"}, {"input": "210 3\n31 55 59 26 53", "output": "Yes\n"}, {"input": "211 5\n31 33 59 26 53", "output": "No\n"}, {"input": "211 5\n31 33 59 26 24", "output... | code_stdio |
[
{
"content": "For some time the program of rounding numbers that had been developed by the Codeforces participants during one of the previous rounds, helped the citizens of Far Far Away to convert numbers into a more easily readable format. However, as time went by, the economy of the Far Far Away developed and... | [{"input": "2567340036354357844391998756110821468858185018763415770617907336824217629234299240638243305079104961\n", "output": "$2,567,340,036,354,357,844,391,998,756,110,821,468,858,185,018,763,415,770,617,907,336,824,217,629,234,299,240,638,243,305,079,104,961.00\n"}, {"input": "16094449032068386105581779066195819551... | code_stdio |
[
{
"content": "You are given a string $s$ of length $n$ consisting only of the characters 0 and 1.\n\nYou perform the following operation until the string becomes empty: choose some consecutive substring of equal characters, erase it from the string and glue the remaining two parts together (any of them can be e... | [{"input": "3\n3 2 -1\n010\n5 -2 5\n01001\n6 -1 -12\n110111\n", "output": "4\n15\n-30\n"}, {"input": "3\n3 3 -1\n010\n5 -2 5\n01001\n6 -1 -12\n110111\n", "output": "7\n15\n-30\n"}, {"input": "3\n3 3 -2\n011\n5 -2 5\n01001\n6 -1 -12\n110111\n", "output": "5\n15\n-30\n"}, {"input": "3\n3 3 -1\n010\n5 -2 5\n01001\n6 -2 -1... | code_stdio |
[
{
"content": "You are given an integer m as a product of integers a_1, a_2, ... a_{n} $(m = \\prod_{i = 1}^{n} a_{i})$. Your task is to find the number of distinct decompositions of number m into the product of n ordered positive integers.\n\nDecomposition into n products, given in the input, must also be consi... | [{"input": "50\n675 25000 2025 83 450 31250 3750 225 1350 250 72 187500 12000 281250 187500 30000 45000 90000 90 1200 9000 56250 5760 270000 3125 3796875 2250 101250 40 2500 175781250 1250000 45000 2250 3000 31250 46875 135000 421875000 36000 360 140625000 13500 1406250 1125 250 75000 62500 150 6\n", "output": "6873067... | code_stdio |
[
{
"content": "Ted has a pineapple. This pineapple is able to bark like a bulldog! At time t (in seconds) it barks for the first time. Then every s seconds after it, it barks twice with 1 second interval. Thus it barks at times t, t + s, t + s + 1, t + 2s, t + 2s + 1, etc.\n\n [Image] \n\nBarney woke up in the m... | [{"input": "749399100 103031711 761562532\n", "output": "NO\n"}, {"input": "749399100 103031711 761562532\n", "output": "NO\n"}, {"input": "178769979 103031711 761562532\n", "output": "NO\n"}, {"input": "4363010 696782227 701145238\n", "output": "YES\n"}, {"input": "8897216 734348516 743245732\n", "output": "YES\n"}, {... | code_stdio |
[
{
"content": "Consider some square matrix A with side n consisting of zeros and ones. There are n rows numbered from 1 to n from top to bottom and n columns numbered from 1 to n from left to right in this matrix. We'll denote the element of the matrix which is located at the intersection of the i-row and the j-... | [{"input": "100\n", "output": "15\n"}, {"input": "89\n", "output": "15\n"}, {"input": "91\n", "output": "15\n"}, {"input": "76\n", "output": "13\n"}, {"input": "80\n", "output": "13\n"}, {"input": "96\n", "output": "15\n"}, {"input": "72\n", "output": "13\n"}, {"input": "79\n", "output": "13\n"}, {"input": "74\n", "out... | code_stdio |
[
{
"content": "You are given an undirected connected weighted graph with N vertices and M edges that contains neither self-loops nor double edges.\nThe i-th (1≤i≤M) edge connects vertex a_i and vertex b_i with a distance of c_i.\nHere, a self-loop is an edge where a_i = b_i (1≤i≤M), and double edges are two edge... | [{"input": "7 1\n1 -1 0\n-1 4 1\n-1 0 4", "output": "0\n"}, {"input": "7 1\n1 -1 0\n-1 4 2\n-1 0 4", "output": "0\n"}, {"input": "7 1\n1 -2 0\n-1 4 2\n-1 0 4", "output": "0\n"}, {"input": "14 -1\n2 0 1\n0 3 1\n0 0 4", "output": "0\n"}, {"input": "7 1\n1 -1 0\n-1 8 1\n0 0 4", "output": "0\n"}, {"input": "7 1\n1 -1 0\n-1... | code_stdio |
[
{
"content": "Given are N integers A_1,\\ldots,A_N.\nWe will choose exactly K of these elements. Find the maximum possible product of the chosen elements.\nThen, print the maximum product modulo (10^9+7), using an integer between 0 and 10^9+6 (inclusive).\n\n-----Constraints-----\n - 1 \\leq K \\leq N \\leq 2\\... | [{"input": "10 10\n1000000000 100000000 10000000 1000000 100000 10000 1000 100 10 1\n", "output": "999983200\n"}, {"input": "16 1\n1000000001 100000100 10000100 1000001 100000 10001 1000 000 18 1", "output": "1000000001\n"}, {"input": "10 10\n1000000000 100000000 10000000 1100010 100000 10000 1000 100 10 1", "output": ... | code_stdio |
[
{
"content": "Consider a sequence, which is formed by the following rule: next term is taken as the smallest possible non-negative integer, which is not yet in the sequence, so that `no 3` terms of sequence form an arithmetic progression.\n\n## Example\n\n`f(0) = 0` -- smallest non-negative \n`f(1) = 1` -- sma... | [{"input": "14514", "output": "[2305425]", "fn_name": "sequence"}, {"input": "1634", "output": "[79707]", "fn_name": "sequence"}, {"input": "546", "output": "[19929]", "fn_name": "sequence"}, {"input": "334", "output": "[7329]", "fn_name": "sequence"}, {"input": "123", "output": "[1084]", "fn_name": "sequence"}, {"inpu... | code_functional |
[
{
"content": "In a far away country called AlgoLandia, there are `N` islands numbered `1` to `N`. Each island is denoted by `k[i]`. King Algolas, king of AlgoLandia, built `N - 1` bridges in the country. A bridge is built between islands `k[i]` and `k[i+1]`. Bridges are two-ways and are expensive to build.\n\nT... | [{"input": "[true, true, true, true, true, false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, false, true, true, true, true, true, true, true, true, true, true, true, true, false, true, true, true, true, true, true, true, true, true, true, true, true, true, true... | code_functional |
[
{
"content": "A boy PCK is playing with N electric metronomes. The i-th metronome is set to tick every t_i seconds. He started all of them simultaneously.\n\nHe noticed that, even though each metronome has its own ticking interval, all of them tick simultaneously from time to time in certain intervals. To explo... | [{"input": "3\n16\n6\n33", "output": "22\n"}, {"input": "3\n2\n0\n11", "output": "10\n"}, {"input": "2\n3\n206", "output": "100\n"}, {"input": "2\n3\n409", "output": "406\n"}, {"input": "3\n8\n5\n23", "output": "33\n"}, {"input": "2\n2\n409", "output": "407\n"}, {"input": "2\n4\n394", "output": "193\n"}, {"input": "2\n... | code_stdio |
[
{
"content": "Instructors of Some Informatics School make students go to bed.\n\nThe house contains n rooms, in each room exactly b students were supposed to sleep. However, at the time of curfew it happened that many students are not located in their assigned rooms. The rooms are arranged in a row and numbered... | [{"input": "100 3 30\n20 10 8 3 97 20 40 4 58 24 105 56 26 21 66 1 126 4 21 46 8 2 9 21 0 13 24 53 58 23 3 107 1 22 189 3 31 4 31 0 3 0 9 43 19 74 92 7 71 22 46 26 31 49 18 3 10 9 9 110 30 2 40 21 33 4 11 14 47 4 1 37 3 19 18 63 10 53 19 35 11 57 8 3 11 27 23 5 45 15 127 27 23 48 3 8 20 33 5 28\n", "output": "0\n"}, {"... | code_stdio |
[
{
"content": "Tax Rate Changed\n\nVAT (value-added tax) is a tax imposed at a certain rate proportional to the sale price.\n\nOur store uses the following rules to calculate the after-tax prices.\n\n* When the VAT rate is x%, for an item with the before-tax price of p yen, its after-tax price of the item is p (... | [{"input": "5 8 105\n8 5 105\n1 2 24\n99 98 24\n12 13 26\n1 22 23\n1 19 201\n13 16 112\n2 24 50\n1 82 61\n1 84 125\n1 99 999\n99 1 3106\n98 99 999\n1 99 11\n99 2 12\n0 0 0", "output": "109\n103\n24\n24\n26\n27\n237\n116\n62\n111\n230\n1972\n1576\n1004\n20\n7\n"}, {"input": "5 8 105\n8 5 105\n1 2 24\n99 98 24\n12 13 26\... | code_stdio |
[
{
"content": "During the breaks between competitions, top-model Izabella tries to develop herself and not to be bored. For example, now she tries to solve Rubik's cube 2x2x2.\n\nIt's too hard to learn to solve Rubik's cube instantly, so she learns to understand if it's possible to solve the cube in some state u... | [{"input": "2 6 3 3 5 5 2 6 1 1 12 4 4 4 2 4 6 5 3 1 2 5 3 1\n", "output": "NO\n"}, {"input": "5 2 6 1 5 3 5 3 1 1 3 6 6 2 4 2 5 4 4 2 1 3 4 10\n", "output": "NO\n"}, {"input": "2 6 3 3 5 5 2 6 2 1 12 4 4 4 2 4 6 5 3 1 2 5 3 1\n", "output": "NO\n"}, {"input": "1 3 5 6 3 4 4 3 5 2 2 2 3 1 5 6 3 4 6 5 1 2 1 10\n", "outpu... | code_stdio |
[
{
"content": "Om Nom really likes candies and doesn't like spiders as they frequently steal candies. One day Om Nom fancied a walk in a park. Unfortunately, the park has some spiders and Om Nom doesn't want to see them at all. [Image] \n\nThe park can be represented as a rectangular n × m field. The park has k ... | [{"input": "2 100 59\n....................................................................................................\n.DR.D..DLLR.LDRR..L.LDRRRDLD.LDRR.LLR.R...DRLD.RRLL.L.D..R.LD.DL....LR.LR.DRLD.....L.D..RD...D.LL.R.\n", "output": "0 0 0 1 0 0 0 1 1 0 0 2 0 0 0 1 1 1 0 1 0 0 0 1 1 2 0 0 1 0 0 0 1 2 1 0 0 1 0 1 ... | code_stdio |
[
{
"content": "You have recently discovered that horses travel in a unique pattern - they're either running (at top speed) or resting (standing still).\n\nHere's an example of how one particular horse might travel:\n\n```\nThe horse Blaze can run at 14 metres/second for 60 seconds, but must then rest for 45 seco... | [{"input": "100000000\n21\n5\n14", "output": "[1130769276]", "fn_name": "travel"}, {"input": "35869784\n90\n100\n5", "output": "[84954920]", "fn_name": "travel"}, {"input": "1234567\n4\n3\n11", "output": "[7760148]", "fn_name": "travel"}, {"input": "1000\n10\n127\n14", "output": "[1120]", "fn_name": "travel"}, {"input"... | code_functional |
[
{
"content": "problem\n\nGiven the sequence $ A $ of length $ N $. Find the maximum value of $ \\ sum B_i $, where $ B $ is one of the longest increasing subsequences of the sequence $ A $.\n\nThe longest increasing subsequence of the sequence $ A $ is the longest subsequence that satisfies $ A_i <A_j $ with al... | [{"input": "4\n14 15 0 10", "output": "29\n"}, {"input": "4\n17 19 0 20", "output": "56\n"}, {"input": "4\n12 23 0 10", "output": "35\n"}, {"input": "4\n14 8 0 10", "output": "18\n"}, {"input": "4\n7 14 0 14", "output": "21\n"}, {"input": "4\n7 15 0 20", "output": "42\n"}, {"input": "4\n5 15 0 20", "output": "40\n"}, {... | code_stdio |
[
{
"content": "We have a set S of N points in a two-dimensional plane. The coordinates of the i-th point are (x_i, y_i). The N points have distinct x-coordinates and distinct y-coordinates.\nFor a non-empty subset T of S, let f(T) be the number of points contained in the smallest rectangle, whose sides are paral... | [{"input": "10\n19 -11\n-3 -12\n5 3\n3 -15\n8 -14\n-9 -20\n10 -9\n0 2\n-7 17\n6 -6\n", "output": "7222\n"}, {"input": "10\n19 -11\n-3 -12\n5 3\n3 -15\n13 -14\n-9 -20\n10 -9\n0 2\n-7 17\n6 -6", "output": "7246"}, {"input": "10\n19 -11\n-3 -12\n5 3\n3 -15\n8 -19\n-9 -20\n10 -14\n0 2\n-7 17\n6 -6", "output": "7233"}, {"in... | code_stdio |
[
{
"content": "A bitstring is a string consisting only of the characters 0 and 1. A bitstring is called k-balanced if every substring of size k of this bitstring has an equal amount of 0 and 1 characters (k/2 of each).\n\nYou are given an integer k and a string s which is composed only of characters 0, 1, and ?.... | [{"input": "9\n6 4\n100110\n3 2\n1?1\n3 2\n1?0\n4 4\n????\n7 4\n1?0??1?\n10 10\n11??11??11\n4 4\n1??1\n4 4\n?0?0\n6 2\n????00\n", "output": "YES\nYES\nNO\nYES\nYES\nNO\nYES\nYES\nNO\n"}, {"input": "9\n6 4\n100110\n3 2\n1?1\n3 2\n0?1\n4 4\n????\n7 4\n1?0??1?\n10 10\n11???11?11\n4 2\n1??1\n4 4\n?0?0\n6 2\n????10\n", "out... | code_stdio |
[
{
"content": "Write a function that gets a sequence and value and returns `true/false` depending on whether the variable exists in a multidimentional sequence.\n\nExample:\n```\nlocate(['a','b',['c','d',['e']]],'e'); // should return true\nlocate(['a','b',['c','d',['e']]],'a'); // should return true\nlocate(['a... | [{"input": "[\"a\", \"b\", [\"c\", \"d\", [\"e\", [\"a\", \"b\", [\"c\", \"d\", [\"e\", [\"a\", \"b\", [\"c\", \"d\", [\"e4\", [\"a\", \"b\", [\"c\", \"d\", [\"e\", [\"a\", \"b\", [\"c\", \"d\", [\"e\", [\"a\", \"b\", [\"c\", \"d\", [\"e14\"]]]]]]]]]]]]]]]]]]\n\"e\"", "output": "[true]", "fn_name": "locate"}, {"input":... | code_functional |
[
{
"content": "Vanya and his friends are walking along the fence of height h and they do not want the guard to notice them. In order to achieve this the height of each of the friends should not exceed h. If the height of some person is greater than h he can bend down and then he surely won't be noticed by the gu... | [{"input": "100 342\n478 143 359 336 162 333 385 515 117 496 310 538 469 539 258 676 466 677 1 296 150 560 26 213 627 221 255 126 617 174 279 178 24 435 70 145 619 46 669 566 300 67 576 251 58 176 441 564 569 194 24 669 73 262 457 259 619 78 400 579 222 626 269 47 80 315 160 194 455 186 315 424 197 246 683 220 68 682 8... | code_stdio |
[
{
"content": "Read problems statements in Mandarin Chinese and Russian. \nThis is a very easy warm-up problem.\nYou are given a string. Your task is to determine whether number of occurrences of some character in the string is equal to the sum of the numbers of occurrences of other characters in the string. \... | [{"input": "4\nacab\nzzqzqq\ncba\nkklkwwww", "output": "YES\nYES\nNO\nYES\n"}, {"input": "4\nacab\nzzqzqq\ncba\nkkmkwwww", "output": "YES\nYES\nNO\nYES\n"}, {"input": "4\nacab\nzzqzqq\nbca\nkkmkwwww", "output": "YES\nYES\nNO\nYES\n"}, {"input": "4\nacac\nzzqzqq\nabc\nkklkwwww", "output": "YES\nYES\nNO\nYES\n"}, {"input... | code_stdio |
[
{
"content": "The little girl loves the problems on array queries very much.\n\nOne day she came across a rather well-known problem: you've got an array of n elements (the elements of the array are indexed starting from 1); also, there are q queries, each one is defined by a pair of integers l_{i}, r_{i} (1 ≤ l... | [{"input": "31 48\n45 19 16 42 38 18 50 7 28 40 39 25 45 14 36 18 27 30 16 4 22 6 1 23 16 47 14 35 27 47 2\n6 16\n11 28\n4 30\n25 26\n11 30\n5 9\n4 17\n15 17\n10 25\n15 26\n1 3\n9 26\n8 29\n16 30\n3 24\n27 30\n9 10\n22 29\n2 6\n15 24\n6 21\n19 21\n4 28\n1 7\n18 21\n10 22\n6 15\n14 28\n4 19\n12 13\n19 29\n5 6\n13 31\n21... | code_stdio |
[
{
"content": "We have a sequence of N integers: A_1, A_2, \\cdots, A_N.\nYou can perform the following operation between 0 and K times (inclusive):\n - Choose two integers i and j such that i \\neq j, each between 1 and N (inclusive). Add 1 to A_i and -1 to A_j, possibly producing a negative element.\nCompute t... | [{"input": "500 1000000000\n1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000... | code_stdio |
[
{
"content": "The prison of your city has n prisoners. As the prison can't accommodate all of them, the city mayor has decided to transfer c of the prisoners to a prison located in another city.\n\nFor this reason, he made the n prisoners to stand in a line, with a number written on their chests. The number is ... | [{"input": "57 3 9\n4 5 2 7 12 1 1 3 2 9 4 9 0 6 12 5 -1 6 11 1 0 0 -1 3 1 0 5 1 0 31 8 8 0 1 7 3 1 13 4 4 5 1 4 -2 1 7 1 1 1 4 5 1 24 5 1 9 6\n", "output": "0\n"}, {"input": "57 3 9\n4 5 2 7 12 1 1 0 2 9 4 9 0 6 12 5 -1 6 11 1 0 0 -1 3 1 0 5 1 0 31 8 8 0 1 7 3 1 13 4 4 5 1 4 -2 1 7 1 1 1 4 5 1 24 5 1 9 6\n", "output":... | code_stdio |
[
{
"content": "In \"Takahashi-ya\", a ramen restaurant, a bowl of ramen costs 700 yen (the currency of Japan), plus 100 yen for each kind of topping (boiled egg, sliced pork, green onions).\nA customer ordered a bowl of ramen and told which toppings to put on his ramen to a clerk. The clerk took a memo of the or... | [{"input": "ooo\n", "output": "1000\n"}, {"input": "oxo\n", "output": "900\n"}, {"input": "xxx\n", "output": "700\n"}, {"input": "pxo", "output": "800\n"}, {"input": "yxx", "output": "700\n"}, {"input": "opo", "output": "900\n"}, {"input": "oxp", "output": "800\n"}, {"input": "xyx", "output": "700\n"}, {"input": "opn",... | code_stdio |
[
{
"content": "I decided to plant vegetables in the vegetable garden. There were n seeds, so I sown n seeds one by one a day over n days. All seeds sprout and grow quickly. I can't wait for the harvest time.\n\nOne day, when I was watering the seedlings as usual, I noticed something strange. There should be n ve... | [{"input": "5\n1 2 3 11 4 5\n6\n1 3 6 9 12 15 18\n4\n5 7 9 11 12\n0", "output": "11\n1\n12\n"}, {"input": "5\n1 2 3 14 4 5\n6\n1 3 6 9 12 15 18\n4\n5 7 9 11 12\n0", "output": "14\n1\n12\n"}, {"input": "5\n1 2 3 25 4 5\n6\n1 3 6 9 12 15 18\n4\n5 7 9 11 12\n0", "output": "25\n1\n12\n"}, {"input": "5\n1 2 3 25 4 5\n6\n1 3... | code_stdio |
[
{
"content": "The main city magazine offers its readers an opportunity to publish their ads. The format of the ad should be like this:\n\nThere are space-separated non-empty words of lowercase and uppercase Latin letters.\n\nThere are hyphen characters '-' in some words, their positions set word wrapping points... | [{"input": "2\nWjrWBWqKIeSndDHeiVmfChQNsoUiRQHVplnIWkwBtxAJhOdTigAAzKtbNEqcgvbWHOopfCNgWHfwXyzSCfNqGMLnmlIdKQonLsmGSJlPBcYfHNJJDGlKNnOGtrWUhaTWuilHWMUlFEzbJYbeAWvgnSOOOPLxX-eJEKRsKqSnMjrPbFDprCqgbTfwAnPjFapVKiTjCcWEzhahwPRHScfcLnUixnxckQJzuHzshyBFKPwVGzHeJWniiRKynDFQdaazmTZtDGnFVTmTUZCRCpUHFmUHAVtEdweCImRztqrkQInyCsnMn... | code_stdio |
[
{
"content": "The task is simply stated. Given an integer n (3 < n < 10^(9)), find the length of the smallest list of [*perfect squares*](https://en.wikipedia.org/wiki/Square_number) which add up to n. Come up with the best algorithm you can; you'll need it!\n\nExamples:\n\nsum_of_squares(17) = 2 17 = 16 + 1 (... | [{"input": "661915703", "output": "[4]", "fn_name": "sum_of_squares"}, {"input": "999887641", "output": "[1]", "fn_name": "sum_of_squares"}, {"input": "999950886", "output": "[3]", "fn_name": "sum_of_squares"}, {"input": "999951173", "output": "[2]", "fn_name": "sum_of_squares"}, {"input": "999998999", "output": "[4]",... | code_functional |
[
{
"content": "Dr .: Peter, do you know \"Yes, I have a number\"?\n\nPeter: I used to do it on TV the other day. You remember something by the number of characters in each word contained in a sentence. \"Yes, I have a number\", so it means \"the number 3.14\" and is a keyword for remembering pi.\n\nDr .: Peter, ... | [{"input": "Yes I have a number\nHow I wish I could calculate an unused bolor for space\nThank you\nEND OF INPUT", "output": "31416\n31415926535\n53\n"}, {"input": "Yes I have a rebmun\nHow I wish I could calculate an unused bolor for space\nThank you\nEND OF INPUT", "output": "31416\n31415926535\n53\n"}, {"input": "Ye... | code_stdio |
[
{
"content": "3D Printing\n\nWe are designing an installation art piece consisting of a number of cubes with 3D printing technology for submitting one to Installation art Contest with Printed Cubes (ICPC). At this time, we are trying to model a piece consisting of exactly k cubes of the same size facing the sam... | [{"input": "1 1 100\n100 100 100\n6 4 10\n100 100 100\n106 102 102\n112 110 104\n104 116 102\n100 114 104\n92 107 100\n10 1 10\n-100 101 100\n-108 102 120\n-116 103 100\n-124 100 100\n-132 99 100\n-92 98 100\n-84 100 140\n-76 103 100\n-68 146 100\n-60 101 100\n10 4 10\n100 100 100\n108 101 100\n116 102 100\n124 100 100... | code_stdio |
[
{
"content": "Write a program which converts uppercase/lowercase letters to lowercase/uppercase for a given string.\n\nConstraints\n\n* The length of the input string < 1200\n\nInput\n\nA string is given in a line.\n\nOutput\n\nPrint the converted string in a line. Note that you do not need to convert any chara... | [{"input": "f@IR, LATER, OCCASIONALLY CLOUDY.", "output": "F@ir, later, occasionally cloudy.\n"}, {"input": "f@IR, LATER, YLLANOISACCO CLOUDY.", "output": "F@ir, later, yllanoisacco cloudy.\n"}, {"input": "f@IR, LATER, OLLANOISACCY CLOUDY.", "output": "F@ir, later, ollanoisaccy cloudy.\n"}, {"input": "f@IR, LATER, OLKA... | code_stdio |
[
{
"content": "Create the function ```consecutive(arr)``` that takes an array of integers and return the minimum number of integers needed to make the contents of ```arr``` consecutive from the lowest number to the highest number.\nFor example: If ```arr``` contains [4, 8, 6] then the output should be 2 because... | [{"input": "[1, 2, 3, 4]", "output": "[0]", "fn_name": "consecutive"}, {"input": "[10, -10]", "output": "[19]", "fn_name": "consecutive"}, {"input": "[-10, 10]", "output": "[19]", "fn_name": "consecutive"}, {"input": "[4, 8, 6]", "output": "[2]", "fn_name": "consecutive"}, {"input": "[-10, -9]", "output": "[0]", "fn_na... | code_functional |
[
{
"content": "The characters of Chima need your help. Their weapons got mixed up! They need you to write a program that accepts the name of a character in Chima then tells which weapon he/she owns.\n\nFor example: for the character `\"Laval\"` your program should return the solution `\"Laval-Shado Valious\"`\n\... | [{"input": "\"qwertyuiopasdfghjklzxcvbnm\"", "output": "[\"Not a character\"]", "fn_name": "identify_weapon"}, {"input": "\"Stinkin gorillas\"", "output": "[\"Not a character\"]", "fn_name": "identify_weapon"}, {"input": "\"Lagravis\"", "output": "[\"Lagravis-Blazeprowlor\"]", "fn_name": "identify_weapon"}, {"input": "... | code_functional |
[
{
"content": "Vasya and Petya are playing a simple game. Vasya thought of number x between 1 and n, and Petya tries to guess the number.\n\nPetya can ask questions like: \"Is the unknown number divisible by number y?\".\n\nThe game is played by the following rules: first Petya asks all the questions that intere... | [{"input": "1000\n", "output": "193\n2 4 8 16 32 64 128 256 512 3 9 27 81 243 729 5 25 125 625 7 49 343 11 121 13 169 17 289 19 361 23 529 29 841 31 961 37 41 43 47 53 59 61 67 71 73 79 83 89 97 101 103 107 109 113 127 131 137 139 149 151 157 163 167 173 179 181 191 193 197 199 211 223 227 229 233 239 241 251 257 263 2... | code_stdio |
[
{
"content": "### Task:\n\nYour job is to take a pair of parametric equations, passed in as strings, and convert them into a single rectangular equation by eliminating the parameter. Both parametric halves will represent linear equations of x as a function of time and y as a function of time respectively. \n\nT... | [{"input": "\"x = -144t - 118\"\n\"y = -142t + 65\"", "output": "[\"71x - 72y = -13058\"]", "fn_name": "para_to_rect"}, {"input": "\"x = 138t - 139\"\n\"y = -47t - 134\"", "output": "[\"47x + 138y = -25025\"]", "fn_name": "para_to_rect"}, {"input": "\"x = -71t + 37\"\n\"y = -131t - 124\"", "output": "[\"131x - 71y = 13... | code_functional |
[
{
"content": "You are given a string of numbers between 0-9. Find the average of these numbers and return it as a floored whole number (ie: no decimal places) written out as a string. Eg:\n\n\"zero nine five two\" -> \"four\"\n\nIf the string is empty or includes a number greater than 9, return \"n/a\"\n\nWrite... | [{"input": "\"one two three four five\"", "output": "[\"three\"]", "fn_name": "average_string"}, {"input": "\"zero zero zero zero zero\"", "output": "[\"zero\"]", "fn_name": "average_string"}, {"input": "\"four six two three\"", "output": "[\"three\"]", "fn_name": "average_string"}, {"input": "\"zero nine five two\"", ... | code_functional |
[
{
"content": "In this Kata, you will write a function `doubles` that will remove double string characters that are adjacent to each other.\n\nFor example:\n\n`doubles('abbcccdddda') = 'aca'`, because, from left to right:\n```Haskell\na) There is only one 'a' on the left hand side, so it stays.\nb) The 2 b's dis... | [{"input": "\"qqqqqqnpppgooooonpppppqmmmmmc\"", "output": "[\"npgonpqmc\"]", "fn_name": "doubles"}, {"input": "\"iiiiibllllllyqqqqqbiiiiiituuf\"", "output": "[\"ibyqbtf\"]", "fn_name": "doubles"}, {"input": "\"jjjjjfuuuutgggggqppdaaas\"", "output": "[\"jftgqdas\"]", "fn_name": "doubles"}, {"input": "\"jjjfzzzzzzsddgrrr... | code_functional |
[
{
"content": "Bob loves everything sweet. His favorite chocolate bar consists of pieces, each piece may contain a nut. Bob wants to break the bar of chocolate into multiple pieces so that each part would contain exactly one nut and any break line goes between two adjacent pieces.\n\nYou are asked to calculate t... | [{"input": "100\n1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1\n", "output": "5559060566555523\n"}, {"input": "100\n1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 ... | code_stdio |
[
{
"content": "Example\n\nInput\n\n201\n\n\nOutput\n\n701\n\nWrite Python code to solve this problem. Your program should read the input from stdin and write the output to stdout. Enclose your complete solution in a single ```python code block.",
"role": "user"
}
] | [{"input": "148", "output": "648\n"}, {"input": "106", "output": "605\n"}, {"input": "145", "output": "645\n"}, {"input": "225", "output": "725\n"}, {"input": "171", "output": "671\n"}, {"input": "177", "output": "678\n"}, {"input": "116", "output": "615\n"}, {"input": "119", "output": "619\n"}, {"input": "368", "outpu... | code_stdio |
[
{
"content": "The brothers Hiroshi and Kenjiro came to Lake Inawashiro for fishing. The two decided to score as follows and compete with the total score of the fish they caught.\n\n* One char is a point\n* One yamame trout b points\n* Add c points for every 10 chars\n* Add d points for every 20 yamame trout\n\n... | [{"input": "0 11\n10 0\n-1 1 41 0", "output": "kenjiro\n"}, {"input": "0 11\n10 0\n-1 2 41 0", "output": "kenjiro\n"}, {"input": "0 10\n10 0\n-1 2 41 0", "output": "kenjiro\n"}, {"input": "0 10\n10 1\n-1 2 41 0", "output": "kenjiro\n"}, {"input": "2 1\n19 4\n-1 1 24 -1", "output": "kenjiro\n"}, {"input": "2 1\n19 4\n-1... | code_stdio |
[
{
"content": "Read problems statements in Mandarin Chinese and Russian \n\nChef is sitting in a very boring lecture, waiting for it to end. He has recently asked his friend about the time, and instead of the straightforward answer, his friend, being an absolute jerk, told him the absolute value of angle betwe... | [{"input": "2\n11\n26", "output": "00:02\n11:58\n05:32\n06:28\n"}, {"input": "2\n4\n104", "output": "05:28\n06:32\n01:52\n10:08\n"}, {"input": "2\n1\n104", "output": "04:22\n07:38\n01:52\n10:08\n"}, {"input": "2\n1\n116", "output": "04:22\n07:38\n02:32\n09:28\n"}, {"input": "2\n1\n152", "output": "04:22\n07:38\n03:44\n... | code_stdio |
[
{
"content": "Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1.\n\n<image>\n\nFigure D-1: A sample railway network\n\n\nSuppose you are going to station D from station A. Obviously, the path with the shortest distance is A->B->D. Howev... | [{"input": "4 4 2 1 4\n1 2 2 1\n3 3 2 1\n3 1 5 1\n2 4 4 2\n3 1\n3 11\n10 5 3\n\n10\n2 0 1 1 2\n1\n\n1\n4 5 2 4 1\n4 3 10 1\n3 2 2 1\n3 4 1 2\n3 2 5 2\n2 1 10 1\n3 3\n20 30\n3 2 1\n5 10\n4 2 1\n5 5 2 1 5\n2 2 10 2\n1 3 20 2\n1 4 32 1\n3 4 10 1\n4 5 20 1\n2 2\n20\n10 1\n20\n3 1\n0 0 0 0 0", "output": "60\n-1\n40\n232\n"}... | code_stdio |
[
{
"content": "The goal of this Kata is to remind/show you, how Z-algorithm works and test your implementation.\n\nFor a string str[0..n-1], Z array is of same length as string. An element Z[i] of Z array stores length of the longest substring starting from str[i] which is also a prefix of str[0..n-1]. The first... | [{"input": "\"abracadabra\"", "output": "[[11, 0, 0, 1, 0, 1, 0, 4, 0, 0, 1]]", "fn_name": "zfunc"}, {"input": "\"ababababab\"", "output": "[[10, 0, 8, 0, 6, 0, 4, 0, 2, 0]]", "fn_name": "zfunc"}, {"input": "\"aaaa$aaaa\"", "output": "[[9, 3, 2, 1, 0, 4, 3, 2, 1]]", "fn_name": "zfunc"}, {"input": "\"ababcaba\"", "outpu... | code_functional |
[
{
"content": "You are given an integer $n$. Check if $n$ has an odd divisor, greater than one (does there exist such a number $x$ ($x > 1$) that $n$ is divisible by $x$ and $x$ is odd).\n\nFor example, if $n=6$, then there is $x=3$. If $n=4$, then such a number does not exist.\n\n\n-----Input-----\n\nThe first ... | [{"input": "6\n3\n3\n4\n5\n998244353\n1368804034442\n", "output": "YES\nYES\nNO\nYES\nYES\nYES\n"}, {"input": "6\n3\n3\n4\n5\n998244353\n1099511627776\n", "output": "YES\nYES\nNO\nYES\nYES\nNO\n"}, {"input": "6\n3\n3\n4\n5\n998244353\n852815039649\n", "output": "YES\nYES\nNO\nYES\nYES\nYES\n"}, {"input": "6\n2\n6\n7\n4... | code_stdio |
[
{
"content": "The sequence of n - 1 consecutive composite numbers (positive integers that are not prime and not equal to 1) lying between two successive prime numbers p and p + n is called a prime gap of length n. For example, (24, 25, 26, 27, 28) between 23 and 29 is a prime gap of length 6.\n\nYour mission is... | [{"input": "10\n11\n27\n4\n492170\n0", "output": "4\n0\n6\n2\n114\n"}, {"input": "10\n9\n142\n2\n199792\n0", "output": "4\n4\n10\n0\n16\n"}, {"input": "10\n11\n27\n2\n296421\n0", "output": "4\n0\n6\n0\n60\n"}, {"input": "10\n11\n27\n2\n525306\n0", "output": "4\n0\n6\n0\n14\n"}, {"input": "10\n11\n27\n2\n245198\n0", "ou... | code_stdio |
[
{
"content": "Ilya is a very good-natured lion. He likes maths. Of all mathematical objects, his favourite one is matrices. Now he's faced a complicated matrix problem he needs to solve.\n\nHe's got a square 2^{n} × 2^{n}-sized matrix and 4^{n} integers. You need to arrange all these numbers in the matrix (put ... | [{"input": "16\n978618343 473608041 799158564 800910753 461479363 520477481 780529176 678879534 118274424 720632652 1126830014 582019792 225578081 537373229 944668919 758615621\n", "output": "15485512030\n"}, {"input": "16\n978618343 473608041 799158564 800910753 461479363 520477481 780529176 678879534 118274424 720632... | code_stdio |
[
{
"content": "You have an n × m rectangle table, its cells are not initially painted. Your task is to paint all cells of the table. The resulting picture should be a tiling of the table with squares. More formally: each cell must be painted some color (the colors are marked by uppercase Latin letters); we wil... | [{"input": "100 100\n", "output": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA... | code_stdio |
[
{
"content": "Mike wants to prepare for IMO but he doesn't know geometry, so his teacher gave him an interesting geometry problem. Let's define f([l, r]) = r - l + 1 to be the number of integer points in the segment [l, r] with l ≤ r (say that $f(\\varnothing) = 0$). You are given two integers n and k and n clo... | [{"input": "9 6\n-44 -29\n-11 85\n11 84\n-63 1\n75 89\n-37 61\n14 73\n78 88\n-22 -18\n", "output": " 0\n"}, {"input": "2 2\n-93 -22\n12 72\n", "output": " 0\n"}, {"input": "2 2\n26 99\n-56 40\n", ... | code_stdio |
[
{
"content": "Snuke has N sticks.\nThe length of the i-th stick is l_i.\nSnuke is making a snake toy by joining K of the sticks together.\nThe length of the toy is represented by the sum of the individual sticks that compose it.\nFind the maximum possible length of the toy.\n\n-----Constraints-----\n - 1 \\leq ... | [{"input": "15 14\n50 26 27 21 41 7 42 35 7 5 5 36 39 1 45\n", "output": "386\n"}, {"input": "15 14\n49 26 27 21 41 12 42 35 7 5 5 36 39 1 45", "output": "390\n"}, {"input": "15 14\n49 26 27 21 33 14 42 35 7 5 5 31 39 1 45", "output": "379\n"}, {"input": "15 14\n42 26 27 21 12 14 42 35 7 5 5 31 39 1 45", "output": "351... | code_stdio |
[
{
"content": "You are asked to watch your nephew who likes to play with toy blocks in a strange way.\n\nHe has $n$ boxes and the $i$-th box has $a_i$ blocks. His game consists of two steps:\n\nhe chooses an arbitrary box $i$;\n\nhe tries to move all blocks from the $i$-th box to other boxes.\n\nIf he can make t... | [{"input": "20\n2\n1000000000 999999999\n2\n1000000000 999999999\n2\n1000000000 999999999\n2\n1000000000 999999999\n2\n1000000000 999999999\n2\n1000000000 999999999\n2\n1000000000 999999999\n2\n1000000000 999999999\n2\n1000000000 999999999\n2\n1000000000 999999999\n2\n1000000000 999999999\n2\n1000000000 999999999\n2\n1... | code_stdio |
[
{
"content": "You work as a system administrator in a dormitory, which has $n$ rooms one after another along a straight hallway. Rooms are numbered from $1$ to $n$.\n\nYou have to connect all $n$ rooms to the Internet.\n\nYou can connect each room to the Internet directly, the cost of such connection for the $i... | [{"input": "200 10\n10000010101010110011110010100010010000001100101111011001010010001101001011111110011010111101000101011110101001001101101011010011100000100101000010110111000110000010101110110000110000100000101110111100\n", "output": "989\n"}, {"input": "200 10\n10000010101010110011110010100010010000001100101111011001... | code_stdio |
[
{
"content": "Takahashi is standing on a multiplication table with infinitely many rows and columns.\nThe square (i,j) contains the integer i \\times j. Initially, Takahashi is standing at (1,1).\nIn one move, he can move from (i,j) to either (i+1,j) or (i,j+1).\nGiven an integer N, find the minimum number of m... | [{"input": "613921846801\n", "output": "613921846800\n"}, {"input": "550310490859\n", "output": "550310490858\n"}, {"input": "571704556531\n", "output": "571704556530\n"}, {"input": "472249589291\n", "output": "472249589290\n"}, {"input": "310812811094\n", "output": "155406405547\n"}, {"input": "10000000019\n", "output... | code_stdio |
[
{
"content": "Takahashi wants to be a member of some web service.\nHe tried to register himself with the ID S, which turned out to be already used by another user.\nThus, he decides to register using a string obtained by appending one character at the end of S as his ID.\nHe is now trying to register with the I... | [{"input": "aaaaaaaaaa\naaaaaaaaaaa\n", "output": "Yes\n"}, {"input": "vgxgpuamkx\nvgxgpuamkxk\n", "output": "Yes\n"}, {"input": "chokudai\nchokudaiz\n", "output": "Yes\n"}, {"input": "vfjaqmop\nodotkrjzr\n", "output": "No\n"}, {"input": "choktdai\nchokudaiz", "output": "No\n"}, {"input": "choktdai\nbhokudaiz", "output... | code_stdio |
[
{
"content": "Little Petya likes points a lot. Recently his mom has presented him n points lying on the line OX. Now Petya is wondering in how many ways he can choose three distinct points so that the distance between the two farthest of them doesn't exceed d.\n\nNote that the order of the points inside the gro... | [{"input": "100 100\n-98 -97 -96 -93 -92 -91 -90 -87 -86 -84 -81 -80 -79 -78 -76 -75 -73 -71 -69 -67 -65 -64 -63 -62 -61 -54 -51 -50 -49 -48 -46 -45 -44 -37 -36 -33 -30 -28 -27 -16 -15 -13 -12 -10 -9 -7 -6 -5 -4 2 3 5 8 9 10 11 13 14 15 16 17 19 22 24 25 26 27 28 30 31 32 36 40 43 45 46 47 50 51 52 53 58 60 63 69 70 73... | code_stdio |
[
{
"content": "# Situation\nYou have been hired by a company making electric garage doors. Accidents with the present product line have resulted in numerous damaged cars, broken limbs and several killed pets. Your mission is to write a safer version of their controller software.\n\n# Specification\nWe always sta... | [{"input": "\".....P......P.P..P....\"", "output": "[\"0000012345554333321000\"]", "fn_name": "controller"}, {"input": "\".....P.P........P....\"", "output": "[\"000001222222222234555\"]", "fn_name": "controller"}, {"input": "\"P......P..OP..P...\"", "output": "[\"123455543233334555\"]", "fn_name": "controller"}, {"inp... | code_functional |
[
{
"content": "Bear Limak prepares problems for a programming competition. Of course, it would be unprofessional to mention the sponsor name in the statement. Limak takes it seriously and he is going to change some words. To make it still possible to read, he will try to modify each word as little as possible.\n... | [{"input": "75\nVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK\n", "output": "1406\n"}, {"input": "75\nVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK\n", "output": "1406\n"}, {"input": "75\nVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVKVVVVVVVKKKKKKKKKKKKKKKKKKKKKKKKKKVKKKKKKK... | code_stdio |
[
{
"content": "Write a function that returns the count of characters that have to be removed in order to get a string with no consecutive repeats.\n\n*Note:* This includes any characters\n\n## Examples\n\n```python\n'abbbbc' => 'abc' # answer: 3\n'abbcca' => 'abca' # answer: 2\n'ab cca' => 'ab ca' # ... | [{"input": "\"abmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmvxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa... | code_functional |
[
{
"content": "Today Johnny wants to increase his contribution. His plan assumes writing $n$ blogs. One blog covers one topic, but one topic can be covered by many blogs. Moreover, some blogs have references to each other. Each pair of blogs that are connected by a reference has to cover different topics because... | [{"input": "25 50\n25 2\n6 17\n11 4\n3 18\n11 20\n6 7\n24 15\n1 8\n13 5\n12 25\n15 18\n14 21\n13 6\n5 10\n3 14\n1 2\n23 13\n12 20\n6 4\n8 9\n3 5\n10 7\n20 2\n20 16\n7 4\n8 25\n15 6\n24 14\n2 23\n2 13\n11 3\n16 21\n18 10\n22 1\n5 24\n6 18\n22 23\n4 13\n8 18\n5 20\n22 17\n20 7\n19 15\n10 12\n2 3\n1 20\n2 24\n7 14\n16 17\... | code_stdio |
[
{
"content": "You have just been put in charge of developing a new shredder for the Shredding Company. Although a ``normal'' shredder would just shred sheets of paper into little pieces so that the contents would become unreadable, this new shredder needs to have the following unusual basic characteristics.\n\n... | [{"input": "50 12346\n712 144139\n927438 667387\n23 3312\n9 3142\n25 1299\n101 63556\n103 862150\n6 1104\n0 0", "output": "43 1 2 34 6\n481 1 441 39\n667387 667387\n18 3 3 12\nerror\n21 1 2 9 9\n97 6 35 56\n103 86 2 15 0\nrejected\n"}, {"input": "50 12346\n712 144139\n1585609 667387\n23 3312\n9 3142\n25 1299\n111 63556... | code_stdio |
[
{
"content": "An SNS has N users - User 1, User 2, \\cdots, User N.\nBetween these N users, there are some relationships - M friendships and K blockships.\nFor each i = 1, 2, \\cdots, M, there is a bidirectional friendship between User A_i and User B_i.\nFor each i = 1, 2, \\cdots, K, there is a bidirectional b... | [{"input": "10 9 3\n10 1\n6 7\n8 2\n2 5\n8 4\n7 3\n10 9\n6 4\n5 8\n2 6\n7 5\n3 1\n", "output": "1 3 5 4 3 3 3 3 1 0\n"}, {"input": "10 9 3\n10 1\n10 6\n8 2\n2 5\n8 4\n7 3\n10 9\n6 4\n5 8\n2 6\n7 5\n3 1", "output": "6 4 0 5 5 4 0 4 6 4\n"}, {"input": "10 9 3\n10 1\n10 6\n8 2\n2 5\n8 4\n7 3\n10 9\n6 4\n5 8\n2 7\n7 5\n3 1... | code_stdio |
[
{
"content": "Innopolis University scientists continue to investigate the periodic table. There are n·m known elements and they form a periodic table: a rectangle with n rows and m columns. Each element can be described by its coordinates (r, c) (1 ≤ r ≤ n, 1 ≤ c ≤ m) in the table.\n\nRecently scientists discov... | [{"input": "20 20 80\n5 3\n13 13\n8 5\n2 9\n12 16\n1 11\n15 11\n3 20\n10 7\n5 4\n11 2\n5 20\n14 8\n5 1\n8 13\n11 5\n19 2\n15 12\n12 7\n16 5\n17 3\n12 2\n17 16\n12 3\n12 6\n18 20\n2 20\n9 1\n5 10\n9 18\n17 1\n17 10\n20 1\n12 12\n19 14\n7 8\n2 19\n6 14\n5 6\n15 2\n18 14\n5 7\n14 14\n17 2\n20 20\n11 6\n18 15\n10 5\n20 3\n... | code_stdio |
[
{
"content": "Vasya owns a cornfield which can be defined with two integers $n$ and $d$. The cornfield can be represented as rectangle with vertices having Cartesian coordinates $(0, d), (d, 0), (n, n - d)$ and $(n - d, n)$.\n\n [Image] An example of a cornfield with $n = 7$ and $d = 2$. \n\nVasya also knows th... | [{"input": "9 3\n100\n0 0\n0 1\n0 2\n0 3\n0 4\n0 5\n0 6\n0 7\n0 8\n0 9\n1 0\n1 1\n1 2\n1 3\n1 4\n1 5\n1 6\n1 7\n1 8\n1 9\n2 0\n2 1\n2 2\n2 3\n2 4\n2 5\n2 6\n2 7\n2 8\n2 9\n3 0\n3 1\n3 2\n3 3\n3 4\n3 5\n3 6\n3 7\n3 8\n3 9\n4 0\n4 1\n4 2\n4 3\n4 4\n4 5\n4 6\n4 7\n4 8\n4 9\n5 0\n5 1\n5 2\n5 3\n5 4\n5 5\n5 6\n5 7\n5 8\n5 9... | code_stdio |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.