messages listlengths 1 1 | ground_truth stringlengths 156 726k | dataset stringclasses 2
values |
|---|---|---|
[
{
"content": "You are given a set of n points on the plane. A line containing the origin is called good, if projection of the given set to this line forms a symmetric multiset of points. Find the total number of good lines.\n\nMultiset is a set where equal elements are allowed.\n\nMultiset is called symmetric, ... | [{"input": "50\n-38 -107\n-34 -75\n-200 -143\n-222 -139\n-34 55\n-102 -79\n48 -99\n2 -237\n-118 -167\n-56 -41\n10 17\n68 -89\n-32 41\n-100 -93\n84 -1\n86 -15\n46 -145\n-58 -117\n8 31\n-36 -61\n-12 21\n-116 79\n88 -205\n70 -103\n-78 -37\n106 -5\n-96 -201\n-60 -103\n-54 45\n-138 -177\n-178 -47\n-154 -5\n-138 83\n44 -131\... | code_stdio |
[
{
"content": "You are a teacher at a cram school for elementary school pupils.\n\nOne day, you showed your students how to calculate division of fraction in a class of mathematics. Your lesson was kind and fluent, and it seemed everything was going so well - except for one thing. After some experiences, a stude... | [{"input": "2 6\n1 16\n3 9\n2 334\n34 79\n0 0", "output": "0 1\n4 0\n0 1\n0 166\n0 13\n"}, {"input": "3 8\n1 5\n3 10\n2 218\n36 198\n0 0", "output": "3 0\n1 0\n1 0\n0 108\n0 2\n"}, {"input": "2 6\n1 16\n3 15\n2 200\n34 62\n0 0", "output": "0 1\n4 0\n1 0\n2 0\n0 15\n"}, {"input": "2 6\n1 16\n2 15\n2 200\n34 62\n0 0", "o... | code_stdio |
[
{
"content": "Chef has gone shopping with his 5-year old son. They have bought N items so far. The items are numbered from 1 to N, and the item i weighs Wi grams.\n\nChef's son insists on helping his father in carrying the items. He wants his dad to give him a few items. Chef does not want to burden his son. Bu... | [{"input": "2\n5 4\n12 2 5 0 18\n8 3\n4 -2 1 1 1 0 1 2", "output": "37\n10\n"}, {"input": "2\n5 4\n12 2 5 0 18\n8 3\n2 -1 1 1 1 0 1 1", "output": "37\n6\n"}, {"input": "2\n5 4\n12 2 5 0 18\n8 3\n2 -2 1 1 1 0 1 1", "output": "37\n7\n"}, {"input": "2\n5 1\n6 8 5 1 10\n8 3\n4 1 1 0 2 1 0 -1", "output": "28\n10\n"}, {"inpu... | code_stdio |
[
{
"content": "There are 2N squares arranged from left to right. You are given a string of length 2N representing the color of each of the squares.\n\nThe color of the i-th square from the left is black if the i-th character of S is `B`, and white if that character is `W`.\n\nYou will perform the following opera... | [{"input": "5\nWWVWWWWWWW", "output": "0\n"}, {"input": "4\nBWWWBBWB", "output": "288\n"}, {"input": "5\nWWVWWWWWWX", "output": "0\n"}, {"input": "5\nWWVWWWXWWX", "output": "0\n"}, {"input": "5\nWWVVWWXWWX", "output": "0\n"}, {"input": "5\nWXWWWWWWWW", "output": "0\n"}, {"input": "5\nWWVWWXWWWW", "output": "0\n"}, {"in... | code_stdio |
[
{
"content": "You are given positive integers A and B.\nFind the K-th largest positive integer that divides both A and B.\nThe input guarantees that there exists such a number.\n\n-----Constraints-----\n - All values in input are integers.\n - 1 \\leq A, B \\leq 100\n - The K-th largest positive integer that di... | [{"input": "100 100 1\n", "output": "100\n"}, {"input": "100 50 4\n", "output": "5\n"}, {"input": "96 96 12\n", "output": "1\n"}, {"input": "60 60 11\n", "output": "2\n"}, {"input": "93 31 1\n", "output": "31\n"}, {"input": "100 50 2", "output": "25\n"}, {"input": "100 50 3", "output": "10\n"}, {"input": "132 36 1", "o... | code_stdio |
[
{
"content": "Dreamoon has a string s and a pattern string p. He first removes exactly x characters from s obtaining string s' as a result. Then he calculates $\\operatorname{occ}(s^{\\prime}, p)$ that is defined as the maximal number of non-overlapping substrings equal to p that can be found in s'. He wants to... | [{"input": "a\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa... | code_stdio |
[
{
"content": "In this Kata, you will be given a string and your task is to determine if that string can be a palindrome if we rotate one or more characters to the left.\n\n```Haskell\nsolve(\"4455\") = true, because after 1 rotation, we get \"5445\" which is a palindrome\nsolve(\"zazcbaabc\") = true, because af... | [{"input": "\"qponmlkjihgfeeiefghijklmnopqrsttsr\"", "output": "[false]", "fn_name": "solve"}, {"input": "\"432612345665\"", "output": "[false]", "fn_name": "solve"}, {"input": "\"223456776543\"", "output": "[true]", "fn_name": "solve"}, {"input": "\"zazcbaabc\"", "output": "[true]", "fn_name": "solve"}, {"input": "\"a... | code_functional |
[
{
"content": "You are given $n$ segments on a coordinate line; each endpoint of every segment has integer coordinates. Some segments can degenerate to points. Segments can intersect with each other, be nested in each other or even coincide.\n\nYour task is the following: for every $k \\in [1..n]$, calculate the... | [{"input": "1\n0 1000000000000000000\n", "output": "1000000000000000001 \n"}, {"input": "1\n1 1000000000000000000\n", "output": "1000000000000000000 \n"}, {"input": "1\n0 1000000000000000000\n", "output": "1000000000000000001\n"}, {"input": "1\n2 1000000000000000000\n", "output": "999999999999999999 \n"}, {"input": "1\... | code_stdio |
[
{
"content": "Create an OR function, without use of the 'or' keyword, that takes an list of boolean values and runs OR against all of them.\n\nAssume there will be between 1 and 6 variables, and return None for an empty list.\n\nWrite Python code to solve this problem. Define a top-level function named `alt_or`... | [{"input": "[false, false, false, false, false, false]", "output": "[false]", "fn_name": "alt_or"}, {"input": "[false, false, false, false, false, true]", "output": "[true]", "fn_name": "alt_or"}, {"input": "[false, false, false, false, true, false]", "output": "[true]", "fn_name": "alt_or"}, {"input": "[false, false, ... | code_functional |
[
{
"content": "Snuke has four cookies with deliciousness A, B, C, and D. He will choose one or more from those cookies and eat them. Is it possible that the sum of the deliciousness of the eaten cookies is equal to that of the remaining cookies?\n\n-----Constraints-----\n - All values in input are integers.\n - ... | [{"input": "45445415 46908390 31865171 30402196\n", "output": "Yes\n"}, {"input": "93407609 30427494 56229544 81174201\n", "output": "No\n"}, {"input": "76041209 81456309 25817729 23366690\n", "output": "No\n"}, {"input": "97957785 12940168 86812983 92704508\n", "output": "No\n"}, {"input": "63214004 4741111 4654151 63... | code_stdio |
[
{
"content": "As Will is stuck in the Upside Down, he can still communicate with his mom, Joyce, through the Christmas lights (he can turn them on and off with his mind). He can't directly tell his mom where he is, because the monster that took him to the Upside Down will know and relocate him. \n\n<image>\n\nT... | [{"input": ")?(??((???????()?(?????????)??(????????((?)?????)????)??????(?????)?)?????)??????(??()??????)????????)?)()??????????????())????????(???)??)????????????????????(?????)??)???)??(???????????????)???)??)?\n", "output": "8314\n"}, {"input": "?)??)???)???????????????(??)???)??)?????(????????????????????)??)???(??... | code_stdio |
[
{
"content": "Ilya plays a card game by the following rules.\n\nA player has several cards. Each card contains two non-negative integers inscribed, one at the top of the card and one at the bottom. At the beginning of the round the player chooses one of his cards to play it. If the top of the card contains numb... | [{"input": "100\n0 1\n0 1\n0 1\n0 1\n0 1\n0 1\n0 1\n0 1\n0 1\n0 1\n0 1\n0 1\n0 1\n0 1\n0 1\n0 1\n0 1\n0 1\n0 1\n0 1\n0 1\n0 1\n0 1\n0 1\n0 1\n0 1\n0 1\n0 1\n0 1\n0 1\n0 1\n0 1\n0 0\n0 1\n0 1\n0 1\n0 1\n0 1\n0 1\n0 1\n0 1\n0 1\n0 1\n0 1\n0 1\n0 1\n0 1\n0 1\n0 1\n0 1\n0 1\n0 1\n0 1\n0 1\n0 1\n0 1\n0 1\n0 1\n0 1\n0 1\n0 1... | code_stdio |
[
{
"content": "Igor is in 11th grade. Tomorrow he will have to write an informatics test by the strictest teacher in the school, Pavel Denisovich.\n\nIgor knows how the test will be conducted: first of all, the teacher will give each student two positive integers $a$ and $b$ ($a < b$). After that, the student ca... | [{"input": "18\n2 3\n2 3\n2 3\n3 4\n1 4\n3 4\n160570 255604\n3 4\n3 5\n4 5\n1 5\n1 3\n1 2\n1 2\n113836 489816\n1 4\n2 4\n233746 254500\n", "output": "1\n1\n1\n1\n2\n1\n3271\n1\n2\n1\n1\n1\n1\n1\n17237\n2\n2\n3823\n"}, {"input": "14\n1 2\n51649 234369\n3 5\n2 4\n4 5\n2 3\n178731 226389\n1 2\n2 4\n185546 371108\n4 5\n4 5... | code_stdio |
[
{
"content": "Find the longest substring within a string that contains at most 2 unique characters.\n\n```\nsubstring(\"a\") => \"a\"\nsubstring(\"aaa\") => \"aaa\"\nsubstring(\"abacd\") => \"aba\"\nsubstring(\"abacddcd\") => \"cddcd\"\nsubstring(\"cefageaacceaccacca\") => \"accacca\"\n```\n\nThis function will... | [{"input": "\"aaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbccccccccccccccccccccddddddddddddddddddddeeeeeeeeeeeeeeeeeeeeffffffffffffffffffffgggggggggggggggggggghhhhhhhhhhhhhhhhhhhhiiiiiiiiiiiiiiiiiiiijjjjjjjjjjjjjjjjjjjjkkkkkkkkkkkkkkkkkkkkllllllllllllllllllllmmmmmmmmmmmmmmmmmmmmnnnnnnnnnnnnnnnnnnnnoooooooooooooooooooopppppp... | code_functional |
[
{
"content": "Problem\n\nThere are n vertices that are not connected to any of the vertices.\nAn undirected side is stretched between each vertex.\nFind out how many sides can be stretched when the diameter is set to d.\nThe diameter represents the largest of the shortest distances between two vertices.\nHere, ... | [{"input": "-11 14", "output": "287\n"}, {"input": "-14 17", "output": "449\n"}, {"input": "-11 18", "output": "393\n"}, {"input": "-1 20", "output": "207\n"}, {"input": "-6 11", "output": "128\n"}, {"input": "-3 14", "output": "131\n"}, {"input": "-6 21", "output": "343\n"}, {"input": "-7 21", "output": "369\n"}, {"in... | code_stdio |
[
{
"content": "The only difference between easy and hard versions is the length of the string.\n\nYou are given a string $s$ and a string $t$, both consisting only of lowercase Latin letters. It is guaranteed that $t$ can be obtained from $s$ by removing some (possibly, zero) number of characters (not necessary ... | [{"input": "ziurxtzxixmsmewfuffsqdkpphssdcgybwtmzavkosqtmcntspzvftqybaldjllvgttblectspqinfdhhnpvkcbwjlqlquajueqsgymyekuswjctumsbnvvaiinxjlzcnyixfaykolkeogufvzvhnatqtelgjkqfvexghiznwubwihjkznkhepjzrnyzftmimqtlihpn\nzurzximmewfuffskppsdcybwmzavkosqtmctspvftybaljlgtltsqinfdhhpvkcwjlqlqymykusctumsbnvvainxjlcyxfykokeguvvhat... | code_stdio |
[
{
"content": "The Smart Beaver from ABBYY plans a space travel on an ultramodern spaceship. During the voyage he plans to visit n planets. For planet i ai is the maximum number of suitcases that an alien tourist is allowed to bring to the planet, and bi is the number of citizens on the planet.\n\nThe Smart Beav... | [{"input": "26 919241245\n302193 763904252\n302152 990010704\n453347 786598325\n302156 614790744\n151113 552970041\n151053 935503943\n453339 788648514\n453340 819457698\n604398 992471599\n453342 141598754\n302166 998869126\n151098 158907792\n453293 724150038\n604414 436248800\n604434 447578562\n151038 922548042\n302224... | code_stdio |
[
{
"content": "Create a program that outputs all leap years between the year a and year b.\n\nThe leap year conditions are as follows. However, 0 <a ≤ b <3,000. If there is no leap year in the given period, output \"NA\".\n\n* The year is divisible by 4.\n* However, a year divisible by 100 is not a leap year.\n*... | [{"input": "265 2171\n1686 3636\n2001 2275\n0 0", "output": "268\n272\n276\n280\n284\n288\n292\n296\n304\n308\n312\n316\n320\n324\n328\n332\n336\n340\n344\n348\n352\n356\n360\n364\n368\n372\n376\n380\n384\n388\n392\n396\n400\n404\n408\n412\n416\n420\n424\n428\n432\n436\n440\n444\n448\n452\n456\n460\n464\n468\n472\n476\... | code_stdio |
[
{
"content": "Simon has a rectangular table consisting of n rows and m columns. Simon numbered the rows of the table from top to bottom starting from one and the columns — from left to right starting from one. We'll represent the cell on the x-th row and the y-th column as a pair of numbers (x, y). The table co... | [{"input": "5 50\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\... | code_stdio |
[
{
"content": "You have invented a time-machine which has taken you back to ancient Rome. Caeser is impressed with your programming skills and has appointed you to be the new information security officer.\n\nCaeser has ordered you to write a Caeser cipher to prevent Asterix and Obelix from reading his emails.\n\... | [{"input": "\"This is a message\"\n0", "output": "[\"THIS IS A MESSAGE\"]", "fn_name": "caeser"}, {"input": "\"who are you?\"\n18", "output": "[\"OZG SJW QGM?\"]", "fn_name": "caeser"}, {"input": "\"final one\"\n9", "output": "[\"ORWJU XWN\"]", "fn_name": "caeser"}, {"input": "\"..5tyu..\"\n25", "output": "[\"..5SXT..\... | code_functional |
[
{
"content": "Iahub is very proud of his recent discovery, propagating trees. Right now, he invented a new tree, called xor-tree. After this new revolutionary discovery, he invented a game for kids which uses xor-trees.\n\nThe game is played on a tree having n nodes, numbered from 1 to n. Each node i has an ini... | [{"input": "30\n2 1\n3 2\n4 3\n5 3\n6 5\n7 3\n8 3\n9 2\n10 3\n11 2\n12 11\n13 6\n14 4\n15 5\n16 11\n17 9\n18 14\n19 6\n20 2\n21 19\n22 9\n23 19\n24 20\n25 14\n26 22\n27 1\n28 6\n29 13\n30 27\n1 0 1 1 1 1 0 1 0 0 1 0 0 0 1 0 0 0 0 1 0 0 1 1 0 1 1 1 1 0\n0 1 0 1 1 1 0 0 1 1 0 1 1 1 0 1 1 1 1 0 1 0 0 1 0 1 1 0 0 0\n", "ou... | code_stdio |
[
{
"content": "You are given a string S consisting of digits between 1 and 9, inclusive.\nYou can insert the letter + into some of the positions (possibly none) between two letters in this string.\nHere, + must not occur consecutively after insertion.\nAll strings that can be obtained in this way can be evaluate... | [{"input": "9999999999\n", "output": "12656242944\n"}, {"input": "9999999999", "output": "12656242944"}, {"input": "1333", "output": "1952\n"}, {"input": "1455", "output": "2280\n"}, {"input": "1573", "output": "2576\n"}, {"input": "1479", "output": "2400\n"}, {"input": "2515", "output": "3452\n"}, {"input": "125\n", "... | code_stdio |
[
{
"content": "You have a set of $n$ discs, the $i$-th disc has radius $i$. Initially, these discs are split among $m$ towers: each tower contains at least one disc, and the discs in each tower are sorted in descending order of their radii from bottom to top.\n\nYou would like to assemble one tower containing al... | [{"input": "10 10\n2 10 8 7 9 3 4 6 5 1\n10 4\n10 1\n10 6\n10 8\n10 2\n10 9\n10 7\n10 3\n10 5\n", "output": "9\n9\n9\n8\n7\n6\n6\n4\n2\n0\n"}, {"input": "10 10\n2 10 8 7 9 3 4 6 5 1\n10 4\n10 1\n10 6\n10 8\n10 2\n10 9\n10 7\n10 3\n10 5\n", "output": "9\n9\n9\n8\n7\n6\n6\n4\n2\n0\n"}, {"input": "10 10\n2 10 8 7 9 3 4 6 ... | code_stdio |
[
{
"content": "G: Palindromic Subsequences\n\nproblem\n\nGiven a string S consisting only of lowercase letters, find out how many subsequences of this string S are not necessarily continuous and are palindromes.\n\nHere, a subsequence that is not necessarily continuous with S is an arbitrary selection of one or ... | [{"input": "ccpa", "output": "4\n"}, {"input": "cnbc", "output": "6\n"}, {"input": "emec", "output": "5\n"}, {"input": "ccoa", "output": "4\n"}, {"input": "aocc", "output": "4\n"}, {"input": "pcca", "output": "4\n"}, {"input": "ccao", "output": "4\n"}, {"input": "pcda", "output": "4\n"}, {"input": "ccbo", "output": "4\... | code_stdio |
[
{
"content": "We have an N \\times N square grid.\nWe will paint each square in the grid either black or white.\nIf we paint exactly A squares white, how many squares will be painted black?\n\n-----Constraints-----\n - 1 \\leq N \\leq 100\n - 0 \\leq A \\leq N^2\n\n-----Inputs-----\nInput is given from Standard... | [{"input": "19\n100\n", "output": "261\n"}, {"input": "10\n202", "output": "-102\n"}, {"input": "19\n110", "output": "251\n"}, {"input": "10\n-13", "output": "113\n"}, {"input": "10\n-16", "output": "116\n"}, {"input": "10\n145", "output": "-45\n"}, {"input": "10\n174", "output": "-74\n"}, {"input": "10\n199", "output"... | code_stdio |
[
{
"content": "A new pack of n t-shirts came to a shop. Each of the t-shirts is characterized by three integers p_{i}, a_{i} and b_{i}, where p_{i} is the price of the i-th t-shirt, a_{i} is front color of the i-th t-shirt and b_{i} is back color of the i-th t-shirt. All values p_{i} are distinct, and values a_{... | [{"input": "20\n414468312 20329584 106106409 584924603 666547477 670032002 726095027 276840253 368277336 940941705 531635095 213813062 440421387 959075599 240727854 495316522 838268432 786936631 586382273 806443734\n3 1 2 3 3 2 2 1 3 2 3 2 3 3 3 2 1 3 1 2\n3 1 2 2 2 2 3 1 2 3 2 1 1 2 3 1 2 3 3 2\n40\n1 1 2 1 3 2 3 1 3 ... | code_stdio |
[
{
"content": "*Inspired by the [Fold an Array](https://www.codewars.com/kata/fold-an-array) kata. This one is sort of similar but a little different.*\n\n---\n\n## Task\nYou will receive an array as parameter that contains 1 or more integers and a number `n`.\n\nHere is a little visualization of the process:\n\... | [{"input": "[3, 234, 25, 345, 45, 34, 234, 235, 345, 34, 534, 45, 645, 645, 645, 4656, 45, 3]\n4", "output": "[[1040, 7712]]", "fn_name": "split_and_add"}, {"input": "[23, 345, 345, 345, 34536, 567, 568, 6, 34536, 54, 7546, 456]\n20", "output": "[[79327]]", "fn_name": "split_and_add"}, {"input": "[32, 45, 43, 23, 54, 2... | code_functional |
[
{
"content": "A binary matrix is called good if every even length square sub-matrix has an odd number of ones. \n\nGiven a binary matrix $a$ consisting of $n$ rows and $m$ columns, determine the minimum number of cells you need to change to make it good, or report that there is no way to make it good at all. \n... | [{"input": "2 58\n1100001110010010100001000000000110110001101001100010101110\n1110110010101111001110010001100010001010100011111110110100\n", "output": "27\n"}, {"input": "2 58\n1100001110010010100001000000000110110001101001100010101110\n1110110010101111001110010001100010001010100011111110110100\n", "output": "27"}, {"i... | code_stdio |
[
{
"content": "We have two integers: A and B.\nPrint the largest number among A + B, A - B, and A \\times B.\n\n-----Constraints-----\n - All values in input are integers.\n - -100 \\leq A,\\ B \\leq 100\n\n-----Input-----\nInput is given from Standard Input in the following format:\nA B\n\n-----Output-----\nPri... | [{"input": "100 100\n", "output": "10000\n"}, {"input": "-96 -16\n", "output": "1536\n"}, {"input": "36 80\n", "output": "2880\n"}, {"input": "-76 39\n", "output": "-37\n"}, {"input": "-13 3\n", "output": "-10\n"}, {"input": "50 -24\n", "output": "74\n"}, {"input": "1 -33\n", "output": "34\n"}, {"input": "13 3\n", "out... | code_stdio |
[
{
"content": "A tourist is visiting Byteland. The tourist knows English very well. The language of Byteland is rather different from English. To be exact it differs in following points:\n\n- Bytelandian alphabet has the same letters as English one, but possibly different in meaning. Like 'A' in Bytelandian may ... | [{"input": "5 qwertyuiopasdfghjklzxcvbnm\nPh\nisscP\nBpke_kdc_epclc_jcijsc_mihyo?\nEpcf_kdc_liswhyo_EIED_hy_Vimcvpcn_Zkdvp_siyo_viyecle.\nIpp!", "output": "Hi\nolleH\nWhat are these people doing?\nThey are solving TOTR in Codechef March long contest.\nOhh!\n"}, {"input": "5 qwertyuiopasdfghjklzxcvbnm\nPh\nisscP\nBpke_k... | code_stdio |
[
{
"content": "# Introduction \n\nA grille cipher was a technique for encrypting a plaintext by writing it onto a sheet of paper through a pierced sheet (of paper or cardboard or similar). The earliest known description is due to the polymath Girolamo Cardano in 1550. His proposal was for a rectangular stencil a... | [{"input": "\"tcddoadepwweasresd\"\n77098", "output": "[\"codewars\"]", "fn_name": "grille"}, {"input": "\"abcdef\"\n5", "output": "[\"df\"]", "fn_name": "grille"}, {"input": "\"ab\"\n255", "output": "[\"ab\"]", "fn_name": "grille"}, {"input": "\"abcde\"\n32", "output": "[\"\"]", "fn_name": "grille"}, {"input": "\"abcd... | code_functional |
[
{
"content": "You are given a string A. Find a string B, where B is a palindrome and A is a subsequence of B.\n\nA subsequence of a string is a string that can be derived from it by deleting some (not necessarily consecutive) characters without changing the order of the remaining characters. For example, \"cots... | [{"input": "fggbyzobbmxtwdajawqdywnppflkkmtxzjvxopqvliwdwhzepcuiwelhbuotlkvesexnwkytonfrpqcxzzqzdvsmbsjcxxeugavekozfjlolrtqgwzqxsfgrnvrgfrqpixhsskbpzghndesvwptpvvkasfalzsetopervpwzmkgpcexqnvtnoulprwnowmsorscecvvvrjfwumcjqyrounqsgdruxttvtmrkivtxauhosokdiahsyrftzsgvgyveqwkzhqstbgywrvmsgfcfyuxpphvmyydzpohgdicoxbtjnsbyhoid... | code_stdio |
[
{
"content": "You are given a non-empty string s=s_1s_2... s_n, which consists only of lowercase Latin letters. Polycarp does not like a string if it contains at least one string \"one\" or at least one string \"two\" (or both at the same time) as a substring. In other words, Polycarp does not like the string s... | [{"input": "10\nonetwonetwooneooonetwooo\ntwo\none\ntwooooo\nttttwo\nttwwoo\nooone\nonnne\noneeeee\noneeeeeeetwooooo\n", "output": "6\n2 6 10 13 18 21 \n1\n2 \n1\n2 \n1\n2 \n1\n5 \n0\n\n1\n4 \n0\n\n1\n2 \n2\n2 11 \n"}, {"input": "10\nonetwonetwooneooonetwooo\ntwo\none\ntwooooo\nttttwo\nttwwoo\nooone\nonnne\nonedeee\non... | code_stdio |
[
{
"content": "The postal system in the area where Masa lives has changed a bit. In this area, each post office is numbered consecutively from 1 to a different number, and mail delivered to a post office is intended from that post office via several post offices. Delivered to the post office. Mail \"forwarding\"... | [{"input": "4 5\n1 2 10\n1 3 15\n2 3 5\n2 4 3\n3 4 10\n2\n1 4 10 LoveLetter\n2 3 13 Greetings\n3 3\n1 2 1\n2 3 1\n3 1 1\n3\n1 2 1 BusinessMailC\n2 3 1 BusinessMailB\n3 1 1 BusinessMailA\n0 0", "output": "Greetings 18\nLoveLetter 26\n\nBusinessMailA 2\nBusinessMailB 2\nBusinessMailC 2\n"}, {"input": "4 5\n1 2 10\n2 3 15... | code_stdio |
[
{
"content": "You have been speeding on a motorway and a police car had to stop you. The policeman is a funny guy that likes to play games. Before issuing penalty charge notice he gives you a choice to change your penalty. \n\nYour penalty charge is a combination of numbers like: speed of your car, speed limit ... | [{"input": "[\"72\", \"7\", \"7\", \"78\", \"79\", \"709\", \"94\"]", "output": "[\"7097277787994\"]", "fn_name": "penalty"}, {"input": "[\"71\", \"82\", \"42\", \"34\", \"90\"]", "output": "[\"3442718290\"]", "fn_name": "penalty"}, {"input": "[\"45\", \"30\", \"50\", \"1\"]", "output": "[\"1304550\"]", "fn_name": "pen... | code_functional |
[
{
"content": "Read problems statements in Russian also. \nChef likes shopping, and especially he likes to buy oranges. But right now he is short of money. He has only k rubles. There are n oranges. The i-th one costs cost_{i} rubles and has weight equal to weight_{i}. Chef wants to buy a set of oranges with the... | [{"input": "2\n2 0\n-1 1\n2 4\n2 6\n-1 10\n1 7", "output": "1\n17\n"}, {"input": "2\n2 0\n-1 2\n2 4\n2 6\n-1 10\n1 7", "output": "2\n17\n"}, {"input": "2\n2 3\n-1 1\n2 4\n2 6\n-1 5\n1 7", "output": "5\n12\n"}, {"input": "2\n2 0\n-1 1\n2 4\n2 6\n-1 5\n1 7", "output": "1\n12\n"}, {"input": "2\n1 1\n1 5\n3 4\n1 -1\n2 0\n1... | code_stdio |
[
{
"content": "Shuseki Kingdom is the world's leading nation for innovation and technology. There are n cities in the kingdom, numbered from 1 to n.\n\nThanks to Mr. Kitayuta's research, it has finally become possible to construct teleportation pipes between two cities. A teleportation pipe will connect two citi... | [{"input": "7 13\n6 1\n7 2\n3 7\n6 5\n3 6\n7 4\n3 5\n4 1\n3 1\n1 5\n1 6\n6 2\n2 4\n", "output": "7\n"}, {"input": "8 12\n6 1\n7 5\n2 5\n4 1\n6 3\n4 3\n5 7\n1 3\n5 2\n2 7\n4 6\n7 2\n", "output": "6\n"}, {"input": "8 12\n6 1\n7 5\n2 5\n4 1\n6 3\n4 3\n5 7\n1 3\n5 2\n2 8\n4 6\n7 2\n", "output": "7\n"}, {"input": "8 12\n6 1... | code_stdio |
[
{
"content": "Having stayed home alone, Petya decided to watch forbidden films on the Net in secret. \"What ungentlemanly behavior!\" — you can say that, of course, but don't be too harsh on the kid. In his country films about the Martians and other extraterrestrial civilizations are forbidden. It was very unfa... | [{"input": "000:0010\n", "output": "2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 "}, {"input": "001:010\n", "output": "2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 3... | code_stdio |
[
{
"content": "Pig Latin is an English language game where the goal is to hide the meaning of a word from people not aware of the rules.\n\nSo, the goal of this kata is to wite a function that encodes a single word string to pig latin.\n\nThe rules themselves are rather easy:\n\n1) The word starts with a vowel(a... | [{"input": "\"yaYAya\"", "output": "[\"ayayayay\"]", "fn_name": "pig_latin"}, {"input": "\"YayayA\"", "output": "[\"ayayayay\"]", "fn_name": "pig_latin"}, {"input": "\"Hello\"", "output": "[\"ellohay\"]", "fn_name": "pig_latin"}, {"input": "\"CCCC\"", "output": "[\"ccccay\"]", "fn_name": "pig_latin"}, {"input": "\"tes3... | code_functional |
[
{
"content": "You are given $n$ rectangles on a plane with coordinates of their bottom left and upper right points. Some $(n-1)$ of the given $n$ rectangles have some common point. A point belongs to a rectangle if this point is strictly inside the rectangle or belongs to its boundary.\n\nFind any point with in... | [{"input": "3\n-1000000000 -1000000000 -999999999 -999999999\n-1000000000 -1000000000 1000000000 1000000000\n-1000000000 -1000000000 -999999999 -999999999\n", "output": "-1000000000 -1000000000\n"}, {"input": "3\n-1000000000 -1000000000 -999999999 -999999999\n-1000000000 -1000000000 1000000000 1000000000\n-1000000000 -... | code_stdio |
[
{
"content": "problem\n\nDuring this time of winter in Japan, hot days continue in Australia in the Southern Hemisphere. IOI, who lives in Australia, decided to plan what clothes to wear based on the weather forecast for a certain D day. The maximum temperature on day i (1 ≤ i ≤ D) is predicted to be Ti degrees... | [{"input": "3 4\n31\n27\n35\n20 25 30\n23 29 90\n21 35 60\n28 48 40", "output": "100\n"}, {"input": "3 4\n31\n27\n35\n20 25 30\n23 29 90\n21 35 60\n28 48 25", "output": "130\n"}, {"input": "3 4\n34\n40\n44\n38 25 30\n24 29 11\n21 69 99\n28 43 40", "output": "118\n"}, {"input": "3 4\n34\n40\n30\n15 25 30\n43 29 11\n21 1... | code_stdio |
[
{
"content": "Chef and Roma are playing a game. Rules of the game are quite simple.\nInitially there are N piles of stones on the table.\nIn each turn, a player can choose one pile and remove it from the table.\nEach player want to maximize the total number of stones removed by him.\nChef takes the first turn. ... | [{"input": "2\n3\n1 1 14\n3\n-2 0 1", "output": "15\n-1\n"}, {"input": "2\n3\n-1 2 12\n3\n-1 3 0", "output": "11\n2\n"}, {"input": "2\n3\n0 -1 25\n3\n-1 4 1", "output": "24\n3\n"}, {"input": "2\n3\n-1 2 21\n3\n-1 3 1", "output": "20\n2\n"}, {"input": "2\n3\n-1 2 12\n3\n-1 1 1", "output": "11\n0\n"}, {"input": "2\n3\n0 ... | code_stdio |
[
{
"content": "Princess'Gamble\n\nPrincess gambling\n\nEnglish text is not available in this practice contest.\n\nOne day, a brave princess in a poor country's tomboy broke the walls of her room, escaped from the castle, and entered the gambling hall where horse racing and other gambling were held. However, the ... | [{"input": "3 2 50\n1\n4\n2\n4 4 65\n1\n0\n3\n-1\n3 1 10\n8\n2\n1\n0 0 0", "output": "87\n-105\n123\n"}, {"input": "3 2 50\n1\n2\n3\n4 4 65\n-1\n2\n5\n1\n3 1 10\n8\n0\n1\n0 0 0", "output": "150\n245\n101\n"}, {"input": "3 2 50\n1\n2\n3\n4 4 65\n-1\n2\n5\n1\n3 1 10\n8\n-1\n1\n0 0 0", "output": "150\n245\n90\n"}, {"input... | code_stdio |
[
{
"content": "Yura has been walking for some time already and is planning to return home. He needs to get home as fast as possible. To do this, Yura can use the instant-movement locations around the city.\n\nLet's represent the city as an area of $n \\times n$ square blocks. Yura needs to move from the block wi... | [{"input": "995078784 16\n623812784 347467913 233267735 582455459\n355611107 277980472\n78770458 786182235\n815219022 611815511\n786044046 363376661\n290398527 1777289213\n846155104 388600335\n143085949 155695413\n287078777 918827034\n432395923 126620751\n52941102 329010981\n237509699 571287936\n556130019 602129300\n44... | code_stdio |
[
{
"content": "Dreamoon likes coloring cells very much.\n\nThere is a row of n cells. Initially, all cells are empty (don't contain any color). Cells are numbered from 1 to n.\n\nYou are given an integer m and m integers l_1, l_2, …, l_m (1 ≤ l_i ≤ n)\n\nDreamoon will perform m operations.\n\nIn i-th operation, ... | [{"input": "2000 100\n5 128 1368 1679 1265 313 1854 1512 1924 338 38 1971 238 1262 1834 1878 1749 784 770 1617 191 395 303 214 1910 1300 741 1966 1367 24 268 403 1828 1033 1424 218 1146 925 1501 1760 1164 1881 1628 1596 1358 1360 29 1343 922 618 1537 1839 1114 1381 704 464 692 1450 1590 1121 670 300 1053 1730 1024 1292... | code_stdio |
[
{
"content": "Little Alyona is celebrating Happy Birthday! Her mother has an array of n flowers. Each flower has some mood, the mood of i-th flower is a_{i}. The mood can be positive, zero or negative.\n\nLet's define a subarray as a segment of consecutive flowers. The mother suggested some set of subarrays. Al... | [{"input": "86 30\n16 -12 11 16 8 14 7 -29 18 30 -32 -10 20 29 -14 -21 23 -19 -15 17 -2 25 -22 2 26 15 -7 -12 -4 -28 21 -4 -2 22 28 -32 9 -20 23 38 -21 21 37 -13 -30 25 31 6 18 29 29 29 27 38 -15 -32 32 -7 -8 -33 -11 24 23 -19 -36 -36 -18 9 -1 32 -34 -26 1 -1 -16 -14 17 -17 15 -24 38 5 -27 -12 8 -38\n60 66\n29 48\n32 5... | code_stdio |
[
{
"content": "# Background\n\n\nMy TV remote control has arrow buttons and an `OK` button.\n\nI can use these to move a \"cursor\" on a logical screen keyboard to type words...\n\n# Keyboard\n\nThe screen \"keyboard\" layout looks like this\n\n\n #tvkb {\n width : 400px;\n border: 5px solid gray; border-... | [{"input": "\"The Quick Brown Fox Jumps Over A Lazy Dog.\"", "output": "[254]", "fn_name": "tv_remote"}, {"input": "\"Pack My Box With Five Dozen Liquor Jugs.\"", "output": "[242]", "fn_name": "tv_remote"}, {"input": "\" x X \"", "output": "[30]", "fn_name": "tv_remote"}, {"input": "\"MISSISSIPPI\"", "output": ... | code_functional |
[
{
"content": "Mainak has an array $a_1, a_2, \\ldots, a_n$ of $n$ positive integers. He will do the following operation to this array exactly once:\n\nPick a subsegment of this array and cyclically rotate it by any amount.\n\nFormally, he can do the following exactly once:\n\nPick two integers $l$ and $r$, such... | [{"input": "50\n1\n999\n1\n998\n1\n997\n1\n996\n1\n995\n1\n994\n1\n993\n1\n992\n1\n991\n1\n990\n1\n989\n1\n988\n1\n987\n1\n986\n1\n985\n1\n984\n1\n983\n1\n982\n1\n981\n1\n980\n1\n979\n1\n978\n1\n977\n1\n976\n1\n975\n1\n974\n1\n973\n1\n972\n1\n971\n1\n970\n1\n969\n1\n968\n1\n967\n1\n966\n1\n965\n1\n964\n1\n963\n1\n962\n... | code_stdio |
[
{
"content": "Vasya has n items lying in a line. The items are consecutively numbered by numbers from 1 to n in such a way that the leftmost item has number 1, the rightmost item has number n. Each item has a weight, the i-th item weights w_{i} kilograms.\n\nVasya needs to collect all these items, however he wo... | [{"input": "2 100 100 10000 10000\n100 100\n", "output": "20000\n"}, {"input": "2 100 100 10000 10000\n100 100\n", "output": "20000\n"}, {"input": "2 100 100 00000 10000\n100 100\n", "output": "20000\n"}, {"input": "2 100 100 00001 10000\n000 100\n", "output": "10000\n"}, {"input": "2 100 100 00001 10000\n001 100\n", "... | code_stdio |
[
{
"content": "In the spirit of the holidays, Saitama has given Genos two grid paths of length n (a weird gift even by Saitama's standards). A grid path is an ordered sequence of neighbouring squares in an infinite grid. Two squares are neighbouring if they share a side.\n\nOne example of a grid path is (0, 0) →... | [{"input": "200\nNESENEESEESWWWNWWSWSWNWNNWNNESWSWNNWNWNENESENNESSWSESWWSSSEEEESSENNNESSWWSSSSESWSWWNNEESSWWNNWSWSSWWNWNNEENNENWWNESSSENWNESWNESWNESEESSWNESSSSSESESSWNNENENESSWWNNWWSWWNESEENWWWWNWWNWWNENESESSWWSWWSES\nNWNESESSENNNESWNWWSWWWNWSESSSWWNWWNNWSENWSWNENNNWWSWWSWNNNESWWWSSESSWWWSSENWSENWWNENESESWNENNESWNWNNEN... | code_stdio |
[
{
"content": "Beroffice text editor has a wide range of features that help working with text. One of the features is an automatic search for typos and suggestions of how to fix them.\n\nBeroffice works only with small English letters (i.e. with 26 letters from a to z). Beroffice thinks that a word is typed with... | [{"input": "bddabcdfaccdabcdfadddabcdfabbdabcdfacddabcdfacdbabcdfacbbabcdfacbcabcdfacbdabcdfadbbabcdfabdbabcdfabdcabcdfabbcabcdfabccabcdfabbbabcdfaddcabcdfaccbabcdfadbdabcdfacccabcdfadcdabcdfadcbabcdfabcbabcdfadbcabcdfacdcabcdfabcdabcdfadccabcdfaddb\n", "output": "bd dabc dfacc dabc dfadddabc dfabb dabc dfacd dabc dfac... | code_stdio |
[
{
"content": "A string a of length m is called antipalindromic iff m is even, and for each i (1 ≤ i ≤ m) a_{i} ≠ a_{m} - i + 1.\n\nIvan has a string s consisting of n lowercase Latin letters; n is even. He wants to form some string t that will be an antipalindromic permutation of s. Also Ivan has denoted the be... | [{"input": "100\nadebebcdacabaadcbcdebcccdaadaeeedecdbcbdeddcbcaeedbecaeeabaabbdccaebdebabbabdcebbbdaabdbddcadaddadad\n52 62 28 18 100 84 16 53 43 52 49 92 10 64 50 95 90 52 21 14 60 3 94 63 31 70 74 62 93 75 100 96 58 36 76 40 62 74 91 77 92 78 65 11 50 18 79 29 10 25 4 24 44 39 4 91 81 63 97 65 50 65 77 51 19 87 43 3... | code_stdio |
[
{
"content": "Permutation p is an ordered set of integers p_1, p_2, ..., p_{n}, consisting of n distinct positive integers, each of them doesn't exceed n. We'll denote the i-th element of permutation p as p_{i}. We'll call number n the size or the length of permutation p_1, p_2, ..., p_{n}.\n\nYou have a ... | [{"input": "100\n-77 57 -95 -23 53 -29 82 -83 38 -73 85 28 25 6 -16 4 -10 -30 -9 -92 14 34 -93 61 36 -100 90 -68 28 16 100 -4 49 23 36 -87 62 -62 53 74 -50 -2 102 8 22 -30 -19 83 7 84 43 90 -65 -75 -15 97 90 15 66 2 13 -91 91 -44 62 51 51 -58 95 77 20 45 76 79 91 60 76 2 82 42 -130 94 -70 122 65 -95 -66 100 -11 33 -67 ... | code_stdio |
[
{
"content": "A permutation is a sequence of integers p_1, p_2, ..., p_{n}, consisting of n distinct positive integers, each of them doesn't exceed n. Let's denote the i-th element of permutation p as p_{i}. We'll call number n the size of permutation p_1, p_2, ..., p_{n}.\n\nNickolas adores permutations. He li... | [{"input": "102\n", "output": "2 1 4 3 6 5 8 7 10 9 12 11 14 13 16 15 18 17 20 19 22 21 24 23 26 25 28 27 30 29 32 31 34 33 36 35 38 37 40 39 42 41 44 43 46 45 48 47 50 49 52 51 54 53 56 55 58 57 60 59 62 61 64 63 66 65 68 67 70 69 72 71 74 73 76 75 78 77 80 79 82 81 84 83 86 85 88 87 90 89 92 91 94 93 96 95 98 97 100 ... | code_stdio |
[
{
"content": "N friends of Takahashi has come to a theme park.\nTo ride the most popular roller coaster in the park, you must be at least K centimeters tall.\nThe i-th friend is h_i centimeters tall.\nHow many of the Takahashi's friends can ride the roller coaster?\n\n-----Constraints-----\n - 1 \\le N \\le 10... | [{"input": "81 358\n59 53 2 54 462 325 435 279 464 327 49 332 95 200 220 158 139 492 130 467 489 458 81 100 466 473 429 275 81 270 455 218 128 307 335 398 52 30 311 69 148 384 454 413 114 315 186 334 382 392 326 8 53 462 457 350 231 61 185 88 305 480 64 390 52 247 443 240 93 469 370 16 443 7 25 299 412 163 199 71 476\n... | code_stdio |
[
{
"content": "Vasya is choosing a laptop. The shop has n laptops to all tastes.\n\nVasya is interested in the following properties: processor speed, ram and hdd. Vasya is a programmer and not a gamer which is why he is not interested in all other properties.\n\nIf all three properties of a laptop are strictly l... | [{"input": "27\n1689 1927 40 270\n3833 2570 167 134\n2580 3589 390 300\n1898 2587 407 316\n1841 2772 411 187\n1296 288 407 506\n1215 263 236 307\n2737 1427 84 992\n1107 1879 284 866\n3311 2507 475 147\n2951 2214 209 375\n1352 2582 110 324\n2082 747 289 521\n2226 1617 209 108\n2253 1993 109 835\n2866 2360 29 206\n1431 3... | code_stdio |
[
{
"content": "A programming competition site AtCode regularly holds programming contests.\nThe next contest on AtCode is called ABC, which is rated for contestants with ratings less than 1200.\nThe contest after the ABC is called ARC, which is rated for contestants with ratings less than 2800.\nThe contest afte... | [{"input": "1199\n", "output": "ABC\n"}, {"input": "1200\n", "output": "ARC\n"}, {"input": "4208\n", "output": "AGC\n"}, {"input": "1234\n", "output": "ARC\n"}, {"input": "2799\n", "output": "ARC\n"}, {"input": "2800\n", "output": "AGC\n"}, {"input": "3399\n", "output": "AGC\n"}, {"input": "600\n", "output": "ABC\n"}, ... | code_stdio |
[
{
"content": "You are given integers N and K. Find the number of triples (a,b,c) of positive integers not greater than N such that a+b,b+c and c+a are all multiples of K. The order of a,b,c does matter, and some of them can be the same.\n\nConstraints\n\n* 1 \\leq N,K \\leq 2\\times 10^5\n* N and K are integers... | [{"input": "150607 162", "output": "1606122089\n"}, {"input": "101525 92", "output": "2687492591\n"}, {"input": "101525 162", "output": "491806259\n"}, {"input": "35897 92", "output": "118638000\n"}, {"input": "62976 92", "output": "641432629\n"}, {"input": "50082 162", "output": "59007258\n"}, {"input": "53556 162", "... | code_stdio |
[
{
"content": "Square1001 has seen an electric bulletin board displaying the integer 1.\nHe can perform the following operations A and B to change this value:\n - Operation A: The displayed value is doubled.\n - Operation B: The displayed value increases by K.\nSquare1001 needs to perform these operations N time... | [{"input": "10\n-32", "output": "-16128\n"}, {"input": "10\n-23", "output": "-11520\n"}, {"input": "10\n-37", "output": "-18688\n"}, {"input": "10\n-42", "output": "-21248\n"}, {"input": "10\n-33", "output": "-16640\n"}, {"input": "10\n-62", "output": "-31488\n"}, {"input": "10\n-41", "output": "-20736\n"}, {"input": "... | code_stdio |
[
{
"content": "You have two positive integers w and h. Your task is to count the number of rhombi which have the following properties: \n\n * Have positive area. \n * With vertices at integer points. \n * All vertices of the rhombi are located inside or on the border of the rectangle with vertices at points (... | [{"input": "4000 4000\n", "output": "16000000000000\n"}, {"input": "1913 3980\n", "output": "3623063809200\n"}, {"input": "3727 2044\n", "output": "3627108561888\n"}, {"input": "1499 2172\n", "output": "662525703000\n"}, {"input": "1913 6242\n", "output": "8911634525772"}, {"input": "1499 2871\n", "output": "1157575755... | code_stdio |
[
{
"content": "You are given a binary string of length $n$ (i. e. a string consisting of $n$ characters '0' and '1').\n\nIn one move you can swap two adjacent characters of the string. What is the lexicographically minimum possible string you can obtain from the given one if you can perform no more than $k$ move... | [{"input": "3\n8 10\n01011011\n7 6\n0111100\n7 11\n0111100\n", "output": "00011111\n0011011\n0001111\n"}, {"input": "3\n8 10\n01011011\n7 6\n0111100\n7 15\n1111100\n", "output": "00011111\n0011011\n0011111\n"}, {"input": "3\n8 10\n01011011\n7 9\n0111100\n7 11\n0111100\n", "output": "00011111\n0001111\n0001111\n"}, {"in... | code_stdio |
[
{
"content": "You are given n integers a_1, a_2, ..., a_n, where n is odd. You are allowed to flip the sign of some (possibly all or none) of them. You wish to perform these flips in such a way that the following conditions hold:\n\n 1. At least (n - 1)/(2) of the adjacent differences a_{i + 1} - a_i for i = 1... | [{"input": "5\n3\n-2 4 3\n5\n1 1 1 1 0\n5\n-2 4 13 -6 4\n9\n9 7 -4 -2 2 -3 9 -4 -2\n9\n-4 1 28 3 1 9 5 1 -15\n", "output": "2 -4 3\n1 -1 1 -1 0\n2 -4 13 -6 4\n9 -7 4 -2 2 -3 9 -4 2\n4 -1 28 -3 1 -9 5 -1 15\n"}, {"input": "5\n3\n-2 4 3\n5\n1 1 1 1 0\n5\n-2 4 13 -6 4\n9\n3 7 -4 -2 2 -3 9 -4 -2\n9\n-4 1 28 3 1 9 5 1 -15\n... | code_stdio |
[
{
"content": "After Fox Ciel got off a bus, she found that the bus she was on was a wrong bus and she lost her way in a strange town. However, she fortunately met her friend Beaver Taro and asked which way to go to her castle. Taro's response to her was a string s, and she tried to remember the string s correct... | [{"input": "6CLznedj88834gqTIhMTPjm_3DbkQpuYkBvU3o55h79ntRqjHTOu3WWNNGLyQSZ_o45mK5mMtRJmWUq2twqWP10OlnDAB1EP2rG\n10\n834gqTI\n_o4\nvU2o55h79n\nvLwlk3PY7Z\nk8PnkBpRYB\nqdkB9b_SS2\nkY4mBeAdgK\nb577cjQiSx\nyOFiEkP1sD\noYOqd8uuTt\n", "output": "54 11\n"}, {"input": "6CLznedj88834gqTIhMTPjm_3DbkQpuYkBvU3o55h79ntRqjHTOu3WWNN... | code_stdio |
[
{
"content": "You are given a non-empty string s consisting of lowercase English letters. You have to pick exactly one non-empty substring of s and shift all its letters 'z' $\\rightarrow$ 'y' $\\rightarrow$ 'x' $\\rightarrow \\ldots \\rightarrow$ 'b' $\\rightarrow$ 'a' $\\rightarrow$ 'z'. In other words, each ... | [{"input": "abbbbbbbabbbbbbbbbbbbbbbbbbbbbbbabbabbbbbabbbbbbbbbbbabbbbbbbbabbabbbbbbbbbbbbbbabbabbbaababbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbabbbbbbbbbbbbbbbbabbbbabbbbbbbbbbbbbbbabbbbbbbbbaababbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbabbabbbbbbbbbbbbbbbbabbbabbbbbaabbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbb... | code_stdio |
[
{
"content": "Today, Chef woke up to find that he had no clean socks. Doing laundry is such a turn-off for Chef, that in such a situation, he always buys new socks instead of cleaning the old dirty ones. He arrived at the fashion store with money rupees in his pocket and started looking for socks. Everything lo... | [{"input": "-1 4 14", "output": "Unlucky Chef\n"}, {"input": "1 2 11", "output": "Unlucky Chef\n"}, {"input": "2 1 11", "output": "Unlucky Chef\n"}, {"input": "-1 4 6", "output": "Unlucky Chef\n"}, {"input": "0 2 14", "output": "Unlucky Chef\n"}, {"input": "2 2 16", "output": "Unlucky Chef\n"}, {"input": "-1 1 4", "out... | code_stdio |
[
{
"content": "Given an D-dimension array, where each axis is of length N, your goal is to find the sum of every index in the array starting from 0.\n\nFor Example if D=1 and N=10 then the answer would be 45 ([0,1,2,3,4,5,6,7,8,9])\nIf D=2 and N = 3 the answer is 18 which would be the sum of every number in the ... | [{"input": "19\n84", "output": "[2871495452512585452340652014195036913664]", "fn_name": "super_sum"}, {"input": "17\n76", "output": "[60022109925215517405815155929907200]", "fn_name": "super_sum"}, {"input": "15\n8", "output": "[1847179534663680]", "fn_name": "super_sum"}, {"input": "11\n11", "output": "[15692141883605... | code_functional |
[
{
"content": "Little Petya often travels to his grandmother in the countryside. The grandmother has a large garden, which can be represented as a rectangle 1 × n in size, when viewed from above. This rectangle is divided into n equal square sections. The garden is very unusual as each of the square sections pos... | [{"input": "100\n1 2 3 7 5 6 10 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 30 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 1 82 83 84 85 86 87 88 89 90 91 92 93 94 100 5 4 3 2 1\n", "output": "3... | code_stdio |
[
{
"content": "Write a function that accepts a string, and returns true if it is in the form of a phone number. Assume that any integer from 0-9 in any of the spots will produce a valid phone number.\n\nOnly worry about the following format:\n(123) 456-7890 (don't forget the space after the close parentheses) ... | [{"input": "\"abc(123) 456-7890abc\"", "output": "[false]", "fn_name": "validPhoneNumber"}, {"input": "\"abc(123)456-7890abc\"", "output": "[false]", "fn_name": "validPhoneNumber"}, {"input": "\"abc(123) 456-7890\"", "output": "[false]", "fn_name": "validPhoneNumber"}, {"input": "\"(123) 456-7890abc\"", "output": "[fal... | code_functional |
[
{
"content": "The Happy Farm 5 creators decided to invent the mechanism of cow grazing. The cows in the game are very slow and they move very slowly, it can even be considered that they stand still. However, carnivores should always be chased off them. \n\nFor that a young player Vasya decided to make the sheph... | [{"input": "60\n-20 179\n-68 0\n-110 68\n-22 177\n47 140\n-49 -4\n-106 38\n-23 22\n20 193\n47 173\n-23 22\n-100 32\n-97 29\n47 124\n-49 -4\n20 193\n-20 179\n-50 149\n-59 -7\n4 193\n-23 22\n-97 29\n-23 22\n-66 133\n47 167\n-61 138\n-49 -4\n-91 108\n-110 84\n47 166\n-110 77\n-99 100\n-23 22\n-59 -7\n47 128\n46 91\n9 193\... | code_stdio |
[
{
"content": "The ship crashed into a reef and is sinking. Now the entire crew must be evacuated. All n crew members have already lined up in a row (for convenience let's label them all from left to right with positive integers from 1 to n) and await further instructions. However, one should evacuate the crew p... | [{"input": "36\nKqxmtwmsf child\nIze woman\nDlpr child\nK woman\nF captain\nRjwfeuhba rat\nBbv rat\nS rat\nMnmg woman\nSmzyx woman\nSr man\nQmhroracn rat\nSoqpuqock rat\nPibdq man\nIlrkrptx rat\nZaecfyqka man\nMmersfs child\nVvvocqi man\nHjeqxvq rat\nMpmb woman\nWmgu woman\nCerelmhoxi child\nA man\nDylv man\nXrdgmmtcpq... | code_stdio |
[
{
"content": "When you asked some guy in your class his name, he called himself S, where S is a string of length between 3 and 20 (inclusive) consisting of lowercase English letters. You have decided to choose some three consecutive characters from S and make it his nickname. Print a string that is a valid nick... | [{"input": "sakahashi", "output": "sak\n"}, {"input": "sbkahashi", "output": "sbk\n"}, {"input": "ihsahakbs", "output": "ihs\n"}, {"input": "hhsaiakbr", "output": "hhs\n"}, {"input": "rbkaiashh", "output": "rbk\n"}, {"input": "rkbaiashh", "output": "rkb\n"}, {"input": "skbajashh", "output": "skb\n"}, {"input": "ska^ias... | code_stdio |
[
{
"content": "Given a string as input, move all of its vowels to the end of the string, in the same order as they were before.\n\nVowels are (in this kata): `a, e, i, o, u`\n\nNote: all provided input strings are lowercase.\n\n## Examples\n```python\n\"day\" ==> \"dya\"\n\"apple\" ==> \"pplae\"\n```\n\nWr... | [{"input": "\"programming\"", "output": "[\"prgrmmngoai\"]", "fn_name": "move_vowels"}, {"input": "\"javascript\"", "output": "[\"jvscrptaai\"]", "fn_name": "move_vowels"}, {"input": "\"haskell\"", "output": "[\"hskllae\"]", "fn_name": "move_vowels"}, {"input": "\"clojure\"", "output": "[\"cljroue\"]", "fn_name": "move... | code_functional |
[
{
"content": "The Fair Nut found a string $s$. The string consists of lowercase Latin letters. The Nut is a curious guy, so he wants to find the number of strictly increasing sequences $p_1, p_2, \\ldots, p_k$, such that: For each $i$ ($1 \\leq i \\leq k$), $s_{p_i} =$ 'a'. For each $i$ ($1 \\leq i < k$), th... | [{"input": "babbbaaaaaabbbaabaaaaaoaabababaababaaaaababaaaaaaabbbbbbaaapaabaaabaaababaaaabaaaabaaaaababaaaabaaab\n", "output": "813881762\n"}, {"input": "babbbaaaaaabbbaabaaaaaoaabababaababaaaaababaaaaaaabbbbbbaaapaabaaabaaababaaaabbaaabaaaaababaaaabaaab\n", "output": "451105408\n"}, {"input": "bbbbabbabaababaaaabaaabb... | code_stdio |
[
{
"content": "$N$ persons visited a restaurant. The restaurant is open from 0 to $T$. The $i$-th person entered the restaurant at $l_i$ and left at $r_i$. Find the maximum number of persons during the business hours.\n\nConstraints\n\n* $ 1 \\leq N \\leq 10^5 $\n* $ 1 \\leq T \\leq 10^5 $\n* $ 0 \\leq l_i < r_i... | [{"input": "0 12\n1 -1\n1 4\n0 8\n0 11\n6 19\n7 21", "output": "0\n"}, {"input": "0 12\n0 -1\n1 4\n0 8\n0 11\n6 19\n7 21", "output": "0\n"}, {"input": "0 12\n1 0\n1 14\n0 0\n0 11\n6 19\n7 32", "output": "0\n"}, {"input": "0 10\n1 -1\n1 3\n0 8\n3 11\n3 12\n5 24", "output": "0\n"}, {"input": "0 12\n0 -1\n1 4\n1 8\n0 11\n... | code_stdio |
[
{
"content": "When Darth Vader gets bored, he sits down on the sofa, closes his eyes and thinks of an infinite rooted tree where each node has exactly n sons, at that for each node, the distance between it an its i-th left child equals to d_{i}. The Sith Lord loves counting the number of nodes in the tree that ... | [{"input": "97 78153\n2 2 1 2 2 2 2 2 2 1 2 2 2 2 2 2 2 2 4 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 1 2 2 2 1 2 2 2 2 2 2 2 2 2 2 1 2 2 2 2 2 2 2 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 2\n", "output": "620983468\n"}, {"input": "97 78153\n2 2 1 2 2 2 2 2 2 1 2 2 2 2 2 2 2 2 4 2 2 2 2 2 2 2 2... | code_stdio |
[
{
"content": "Levko loves tables that consist of n rows and n columns very much. He especially loves beautiful tables. A table is beautiful to Levko if the sum of elements in each row and column of the table equals k.\n\nUnfortunately, he doesn't know any such table. Your task is to help him to find at least on... | [{"input": "100 1000\n", "output": "1000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n0 1000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ... | code_stdio |
[
{
"content": "You are given a permutation of 1,2,...,N: p_1,p_2,...,p_N. Determine if the state where p_i=i for every i can be reached by performing the following operation any number of times:\n - Choose three elements p_{i-1},p_{i},p_{i+1} (2\\leq i\\leq N-1) such that p_{i-1}>p_{i}>p_{i+1} and reverse the or... | [{"input": "7\n3\n2\n1\n6\n5\n4\n7\n", "output": "Yes\n"}, {"input": "7\n4\n2\n1\n6\n5\n4\n14", "output": "No\n"}, {"input": "7\n4\n2\n1\n11\n5\n4\n7", "output": "No\n"}, {"input": "7\n4\n2\n1\n6\n5\n4\n7", "output": "No\n"}, {"input": "7\n3\n2\n1\n6\n5\n4\n7", "output": "Yes"}, {"input": "6\n5\n3\n4\n1\n2\n6\n", "outp... | code_stdio |
[
{
"content": "Alice and Bob are playing a fun game of tree tag.\n\nThe game is played on a tree of $n$ vertices numbered from $1$ to $n$. Recall that a tree on $n$ vertices is an undirected, connected graph with $n-1$ edges.\n\nInitially, Alice is located at vertex $a$, and Bob at vertex $b$. They take turns al... | [{"input": "10\n10 9 10 6 6\n6 1\n7 6\n4 2\n6 10\n5 1\n9 5\n6 8\n3 4\n4 10\n2 1 2 1 1\n2 1\n9 7 4 2 3\n5 1\n2 4\n4 8\n8 6\n8 9\n7 8\n1 8\n1 3\n11 1 11 6 8\n1 10\n6 11\n8 2\n11 3\n1 7\n11 4\n5 8\n11 7\n1 9\n1 8\n5 3 2 1 1\n3 1\n2 1\n4 5\n1 5\n2 1 2 1 1\n2 1\n2 2 1 1 1\n2 1\n2 2 1 1 1\n1 2\n2 2 1 1 1\n2 1\n5 4 5 4 2\n2 1... | code_stdio |
[
{
"content": "Polycarp is making a quest for his friends. He has already made n tasks, for each task the boy evaluated how interesting it is as an integer q_{i}, and the time t_{i} in minutes needed to complete the task. \n\nAn interesting feature of his quest is: each participant should get the task that is be... | [{"input": "70 4\n1 83\n3 923\n2 627\n4 765\n3 74\n4 797\n4 459\n2 682\n1 840\n2 414\n4 797\n3 832\n3 203\n2 939\n4 694\n1 157\n3 544\n1 169\n3 100\n4 69\n1 851\n3 605\n4 562\n1 718\n3 74\n3 740\n2 655\n2 804\n2 218\n4 186\n4 999\n3 989\n2 407\n4 702\n2 15\n1 509\n4 376\n4 260\n1 533\n2 514\n3 520\n4 737\n2 877\n2 383\... | code_stdio |
[
{
"content": "Please write a function that sums a list, but ignores any duplicate items in the list.\n\nFor instance, for the list [3, 4, 3, 6] , the function should return 10.\n\nWrite Python code to solve this problem. Define a top-level function named `sum_no_duplicates` that takes the input arguments descri... | [{"input": "[6, 7, 6, 6, 8, 0, 2, 0, 3, 2, 3, 0, 9, 10, 4, 8, 5, 1, 6, 3, 4, 3, 3, 4, 6, 8, 7, 6, 2, 2, 6, 9, 1, 9, 2, 1, 1, 0, 9, 9, 9, 4, 3, 6, 1, 2, 1, 9, 9, 9, 7, 4, 6, 6, 0, 8, 10, 9, 0, 7, 0, 7, 2, 4, 7, 9, 0, 4, 9, 3, 5, 7, 4, 6, 9, 1, 10, 10, 5, 0, 2, 3, 10, 10, 10, 2, 8, 7, 4, 8, 5, 10, 4, 9, 4, 5, 3, 9, 3, 5,... | code_functional |
[
{
"content": "This is an easy version of the problem. The actual problems are different, but the easy version is almost a subtask of the hard version. Note that the constraints and the output format are different.\n\nYou are given a string $s$ consisting of $n$ lowercase Latin letters.\n\nYou have to color all ... | [{"input": "500\nxwxpgalijfbdbdmluuaubobxztpkfnuparzxczfzchinxdtaevbepdxlouzfzaizkinuaufhckjvydmgnkuaneqohcqocfrsbmmohgpoacnqlgspppfogdkkbrkrhdpdlnknjyeccbqssqtaqmyamtkedlhpbjmchfnmwhxepzfrfmlrxrirbvvlryzmulxqjlthclocmiudxbtqpihlnielggjxjmvqjbeozjpskenampuszybcorplicekprqbsdkidwpgwkrpvbpcsdcngawcgeyxsjimalrrwttjjualmhy... | code_stdio |
[
{
"content": "Let's write a program related to an unsolved math problem called \"Happy End Problem\". Create a program to find the smallest convex polygon formed by connecting exactly k points from the N points given on the plane. However, after being given the coordinates of N points, the question is given the... | [{"input": "5\n2 -1\n3 -1\n5 2\n3 4\n-1 3\n3\n5\n4\n5", "output": "1 2 3 4 5\n1 2 3 4\n1 2 3 4 5\n"}, {"input": "5\n1 -1\n3 -1\n0 2\n1 4\n0 3\n3\n4\n4\n5", "output": "1 4 5 3\n1 4 5 3\n1 2 4 5 3\n"}, {"input": "5\n2 -1\n3 -1\n2 2\n1 4\n0 3\n3\n4\n4\n5", "output": "1 2 3 4\n1 2 3 4\n1 2 3 4 5\n"}, {"input": "5\n2 -1\n3 ... | code_stdio |
[
{
"content": "Bizon the Champion is called the Champion for a reason. \n\nBizon the Champion has recently got a present — a new glass cupboard with n shelves and he decided to put all his presents there. All the presents can be divided into two types: medals and cups. Bizon the Champion has a_1 first prize cups... | [{"input": "100 100 100\n100 100 100\n100\n", "output": "YES\n"}, {"input": "100 100 100\n100 100 100\n100\n", "output": "YES\n"}, {"input": "100 100 100\n101 100 100\n100\n", "output": "YES\n"}, {"input": "100 100 000\n101 100 100\n100\n", "output": "YES\n"}, {"input": "000 100 000\n101 100 100\n100\n", "output": "YES... | code_stdio |
[
{
"content": "Two foxes Jiro and Saburo are playing a game called 1D Reversi. This game is played on a board, using black and white stones. On the board, stones are placed in a row, and each player places a new stone to either end of the row. Similarly to the original game of Reversi, when a white stone is plac... | [{"input": "WBWBWBWBWB\n", "output": "9\n"}, {"input": "WBWBWBBBWW", "output": "6\n"}, {"input": "WWBBCWBWBV", "output": "7\n"}, {"input": "XWBBCWBWBV", "output": "8\n"}, {"input": "XWVBCWBWCB", "output": "9\n"}, {"input": "WWBBBWBWBW", "output": "6\n"}, {"input": "WWBBBWBWBV", "output": "6\n"}, {"input": "XWVBCWBWBB",... | code_stdio |
[
{
"content": "Find the minimum prime number greater than or equal to X.\n\n-----Notes-----\nA prime number is an integer greater than 1 that cannot be evenly divided by any positive integer except 1 and itself.\nFor example, 2, 3, and 5 are prime numbers, while 4 and 6 are not.\n\n-----Constraints-----\n - 2 \... | [{"input": "100000\n", "output": "100003\n"}, {"input": "99992\n", "output": "100003\n"}, {"input": "64993\n", "output": "64997\n"}, {"input": "90371\n", "output": "90371\n"}, {"input": "92227\n", "output": "92227\n"}, {"input": "59054\n", "output": "59063\n"}, {"input": "56588\n", "output": "56591\n"}, {"input": "1568... | code_stdio |
[
{
"content": "Calculate the value of the sum: n mod 1 + n mod 2 + n mod 3 + ... + n mod m. As the result can be very large, you should print the value modulo 10^9 + 7 (the remainder when divided by 10^9 + 7).\n\nThe modulo operator a mod b stands for the remainder after dividing a by b. For example 10 mod 3 = 1... | [{"input": "10000000000000 10000000000000\n", "output": "869957328\n"}, {"input": "10000000000000 10000000000000\n", "output": "869957328\n"}, {"input": "7244641009859 6300054748096\n", "output": "955368330\n"}, {"input": "3483524125987 5259923264237\n", "output": "953462184\n"}, {"input": "9726702209411 4215496813081\... | code_stdio |
[
{
"content": "You are given an array $a$ of length $n$.\n\nYou are also given a set of distinct positions $p_1, p_2, \\dots, p_m$, where $1 \\le p_i < n$. The position $p_i$ means that you can swap elements $a[p_i]$ and $a[p_i + 1]$. You can apply this operation any number of times for each of the given positio... | [{"input": "6\n3 2\n3 2 1\n1 2\n4 2\n4 1 2 3\n3 2\n5 1\n1 2 3 4 5\n1\n4 2\n2 1 4 3\n1 3\n4 2\n4 3 2 1\n1 3\n5 2\n2 1 2 3 3\n1 4\n", "output": "YES\nNO\nYES\nYES\nNO\nYES\n"}, {"input": "6\n3 2\n3 2 1\n1 2\n4 2\n4 1 2 3\n3 2\n5 1\n1 2 3 4 5\n1\n4 2\n2 1 4 3\n1 3\n4 2\n4 3 3 1\n1 3\n5 2\n2 1 2 3 3\n1 4\n", "output": "YES... | code_stdio |
[
{
"content": "Little Lesha loves listening to music via his smartphone. But the smartphone doesn't have much memory, so Lesha listens to his favorite songs in a well-known social network InTalk.\n\nUnfortunately, internet is not that fast in the city of Ekaterinozavodsk and the song takes a lot of time to downl... | [{"input": "100000 99999 4\n", "output": "1\n"}, {"input": "100000 1 10000\n", "output": "2\n"}, {"input": "10028 13 10000\n", "output": "1\n"}, {"input": "100000 99999 2\n", "output": "1\n"}, {"input": "100000 99999 3\n", "output": "1\n"}, {"input": "100000 1 10000\n", "output": "2\n"}, {"input": "100000 99999 3\n", "... | code_stdio |
[
{
"content": "There are two popular keyboard layouts in Berland, they differ only in letters positions. All the other keys are the same. In Berland they use alphabet with 26 letters which coincides with English alphabet.\n\nYou are given two strings consisting of 26 distinct letters each: all keys of the first ... | [{"input": "buneohqdgxjsafrmwtzickvlpy\nzblwamjxifyuqtnrgdkchpoves\n4RZf8YivG6414X1GdDfcCbc10GA0Wz8514LI9D647XzPb66UNh7lX1rDQv0hQvJ7aqhyh1Z39yABGKn24g185Y85ER5q9UqPFaQ2JeK97wHZ78CMSuU8Zf091mePl2OX61BLe5KdmUWodt4BXPiseOZkZ4SZ27qtBM4hT499mCirjy6nB0ZqjQie4Wr3uhW2mGqBlHyEZbW7A6QnsNX9d3j5aHQN0H6GF8J0365KWuAmcroutnJD6l6HI3kS... | code_stdio |
[
{
"content": "Many students live in a dormitory. A dormitory is a whole new world of funny amusements and possibilities but it does have its drawbacks. \n\nThere is only one shower and there are multiple students who wish to have a shower in the morning. That's why every morning there is a line of five people i... | [{"input": "0 14299 32984 96001 30445\n77723 0 75669 14101 55389\n30897 17295 0 52675 29987\n36518 108118 11343 0 64020\n91242 50085 86272 62454 0\n", "output": "747422\n"}, {"input": "0 14299 32984 96001 30445\n77723 0 75669 14101 55389\n30897 17295 0 52675 29987\n36518 108118 92955 0 64020\n91242 50085 86272 62454 0\... | code_stdio |
[
{
"content": "Let's solve the puzzle by programming.\n\nThe numbers n x n are arranged in a grid pattern. Some of the numbers are circled and we will call them the starting point. The rules of the puzzle are as follows:\n\n* Draw one line that goes vertically and horizontally from each starting point (cannot be... | [{"input": "3\n-3 1 1\n2 -4 1\n2 1 -1\n3\n-2 1 1\n1 0 -6\n1 -5 3\n4\n-8 11 -2 1\n2 -7 -2 2\n1 -1 1 2\n1 1 1 -1\n6\n2 0 3 -7 0 2\n1 -10 1 1 4 2\n2 10 5 2 -6 0\n2 4 -23 2 1 8\n3 3 -8 2 3 7\n-7 2 5 2 -3 -18\n6\n3 2 3 -7 1 2\n1 -10 1 0 3 2\n2 6 5 0 -6 1\n0 4 -23 2 2 5\n4 3 -2 2 3 5\n-7 2 4 1 -5 -12\n0", "output": "YES\nNO\... | code_stdio |
[
{
"content": "In this Kata, you will check if it is possible to convert a string to a palindrome by changing one character. \n\nFor instance:\n```Haskell\nsolve (\"abbx\") = True, because we can convert 'x' to 'a' and get a palindrome. \nsolve (\"abba\") = False, because we cannot get a palindrome by changing a... | [{"input": "\"abba\"", "output": "[false]", "fn_name": "solve"}, {"input": "\"abbaa\"", "output": "[true]", "fn_name": "solve"}, {"input": "\"abcba\"", "output": "[true]", "fn_name": "solve"}, {"input": "\"abbx\"", "output": "[true]", "fn_name": "solve"}, {"input": "\"aa\"", "output": "[false]", "fn_name": "solve"}, {"... | code_functional |
[
{
"content": "Sasha and Ira are two best friends. But they aren’t just friends, they are software engineers and experts in artificial intelligence. They are developing an algorithm for two bots playing a two-player game. The game is cooperative and turn based. In each turn, one of the players makes a move (it d... | [{"input": "1000000\n", "output": "627314155\n"}, {"input": "1000000\n", "output": "627314155\n"}, {"input": "999999\n", "output": "192151599\n"}, {"input": "524287\n", "output": "295397547\n"}, {"input": "131071\n", "output": "920253602\n"}, {"input": "178481\n", "output": "845172388\n"}, {"input": "524288\n", "output... | code_stdio |
[
{
"content": "You are given two arrays $a$ and $b$, both of length $n$.\n\nLet's define a function $f(l, r) = \\sum\\limits_{l \\le i \\le r} a_i \\cdot b_i$.\n\nYour task is to reorder the elements (choose an arbitrary order of elements) of the array $b$ to minimize the value of $\\sum\\limits_{1 \\le l \\le r... | [{"input": "5\n1 11 7 6 5\n9 11 2 18 3\n", "output": "1162\n"}, {"input": "5\n1 11 7 6 5\n9 11 2 9 3\n", "output": "1077\n"}, {"input": "5\n1 11 7 6 5\n9 11 3 6 3\n", "output": "1021\n"}, {"input": "5\n1 11 7 2 5\n9 11 3 10 3\n", "output": "893\n"}, {"input": "5\n0 3 2 0 2\n14 1 0 11 13\n", "output": "128\n"}, {"input"... | code_stdio |
[
{
"content": "# Let's watch a parade!\n## Brief\nYou're going to watch a parade, but you only care about one of the groups marching. The parade passes through the street where your house is. Your house is at number `location` of the street. Write a function `parade_time` that will tell you the times when you ne... | [{"input": "[\"a\", \"b\", \"c\", \"c\", \"e\", \"c\"]\n7\n1\n\"c\"", "output": "[[10, 11, 13]]", "fn_name": "parade_time"}, {"input": "[\"c\", \"b\", \"c\", \"d\", \"e\", \"f\"]\n3\n2\n\"c\"", "output": "[[2, 3]]", "fn_name": "parade_time"}, {"input": "[\"a\", \"b\", \"c\", \"d\", \"e\", \"b\"]\n1\n2\n\"b\"", "output"... | code_functional |
[
{
"content": "Transpose means is to interchange rows and columns of a two-dimensional array matrix.\n\n[A^(T)]ij=[A]ji\n\nie:\nFormally, the i th row, j th column element of AT is the j th row, i th column element of A:\n\n\n\nExample :\n\n```\n[[1,2,3],[4,5,6]].transpose() //should return [[1,4],[2,5],[3,6]]\n... | [{"input": "[[true, false, true], [false, true, false]]", "output": "[[[true, false], [false, true], [true, false]]]", "fn_name": "transpose"}, {"input": "[[\"a\", \"b\", \"c\"], [\"d\", \"e\", \"f\"]]", "output": "[[[\"a\", \"d\"], [\"b\", \"e\"], [\"c\", \"f\"]]]", "fn_name": "transpose"}, {"input": "[[1, 2, 3, 4, 5,... | code_functional |
[
{
"content": "Alexandra has an even-length array $a$, consisting of $0$s and $1$s. The elements of the array are enumerated from $1$ to $n$. She wants to remove at most $\\frac{n}{2}$ elements (where $n$ — length of array) in the way that alternating sum of the array will be equal $0$ (i.e. $a_1 - a_2 + a_3 - a... | [{"input": "4\n2\n1 1\n2\n0 0\n4\n0 1 1 1\n4\n1 1 0 0\n", "output": "2\n1 1 \n2\n0 0 \n2\n1 1 \n2\n0 0 \n"}, {"input": "4\n2\n0 0\n2\n0 0\n4\n0 1 1 1\n4\n1 1 0 0\n", "output": "2\n0 0 \n2\n0 0 \n2\n1 1 \n2\n0 0 \n"}, {"input": "4\n2\n1 1\n2\n0 0\n4\n0 1 0 1\n4\n1 1 0 0\n", "output": "2\n1 1 \n2\n0 0 \n2\n0 0 \n2\n0 0 \... | code_stdio |
[
{
"content": "You are given an array a_1, a_2, ..., a_{n} consisting of n integers, and an integer k. You have to split the array into exactly k non-empty subsegments. You'll then compute the minimum integer on each subsegment, and take the maximum integer over the k obtained minimums. What is the maximum possi... | [{"input": "39 1\n676941771 -923780377 -163050076 -230110947 -208029500 329620771 13954060 158950156 -252501602 926390671 -678745080 -921892226 -100127643 610420285 602175224 -839193819 471391946 910035173 777969600 -736144413 -489685522 60986249 830784148 278642552 -375298304 197973611 -354482364 187294011 636628282 2... | code_stdio |
[
{
"content": "As most of you might know already, a prime number is an integer `n` with the following properties:\n\n* it must be greater than 1\n* it must be divisible only by itself and 1\n\nAnd that's it: -15 or 8 are not primes, 5 or 97 are; pretty easy, isn't it?\n\nWell, turns out that primes are not just ... | [{"input": "143", "output": "[false]", "fn_name": "is_prime"}, {"input": "529", "output": "[false]", "fn_name": "is_prime"}, {"input": "-1", "output": "[false]", "fn_name": "is_prime"}, {"input": "1", "output": "[false]", "fn_name": "is_prime"}, {"input": "29", "output": "[true]", "fn_name": "is_prime"}, {"input": "53"... | code_functional |
[
{
"content": "In this Kata, you will count the number of times the first string occurs in the second. \n\n```Haskell\nsolve(\"zaz\",\"zazapulz\") = 4 because they are ZAZapulz, ZAzapulZ, ZazApulZ, zaZApulZ\n```\n\nMore examples in test cases. \n\nGood luck!\n\nPlease also try [Simple time difference](https://ww... | [{"input": "\"defg\"\n\"dvsxvevdvsvfvsvgvsvgg\"", "output": "[3]", "fn_name": "solve"}, {"input": "\"code\"\n\"cozzdezodeczzode\"", "output": "[11]", "fn_name": "solve"}, {"input": "\"kata\"\n\"kataxxxxkatak\"", "output": "[7]", "fn_name": "solve"}, {"input": "\"code\"\n\"codeodecode\"", "output": "[11]", "fn_name": "s... | code_functional |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.