question
stringlengths
29
1.88k
test_input
listlengths
0
10
test_output
listlengths
0
10
test_time_limit
int64
1
1
test_method
stringclasses
1 value
It's March and you just can't seem to get your mind off brackets. However, it is not due to basketball. You need to extract statements within strings that are contained within brackets. You have to write a function that returns a list of statements that are contained within brackets given a string. If the value entere...
[]
[]
1
stdio
Sergey is testing a next-generation processor. Instead of bytes the processor works with memory cells consisting of n bits. These bits are numbered from 1 to n. An integer is stored in the cell in the following way: the least significant bit is stored in the first bit of the cell, the next significant bit is stored in ...
[ "4\n1100\n", "4\n1111\n", "1\n0\n", "1\n1\n", "2\n00\n", "2\n01\n", "2\n10\n", "2\n11\n", "10\n0000000000\n", "20\n11111111110110001100\n" ]
[ "3\n", "4\n", "1\n", "1\n", "1\n", "1\n", "2\n", "2\n", "1\n", "11\n" ]
1
stdio
Vasilisa the Wise from a far away kingdom got a present from her friend Helga the Wise from a farther away kingdom. The present is a surprise box, yet Vasilisa the Wise doesn't know yet what the surprise actually is because she cannot open the box. She hopes that you can help her in that. The box's lock is constructed...
[ "VYYYVV\n", "OBRRYY\n", "RRYOGB\n", "RROOYY\n", "GOGGVG\n", "GVGBVO\n", "BOBGBB\n", "OOYYBY\n", "VVRVVV\n", "VOVRBV\n" ]
[ "2\n", "8\n", "15\n", "6\n", "2\n", "8\n", "2\n", "3\n", "1\n", "5\n" ]
1
stdio
## Description: Remove all exclamation marks from the end of words. Words are separated by spaces in the sentence. ### Examples ``` remove("Hi!") === "Hi" remove("Hi!!!") === "Hi" remove("!Hi") === "!Hi" remove("!Hi!") === "!Hi" remove("Hi! Hi!") === "Hi Hi" remove("!!!Hi !!hi!!! !hi") === "!!!Hi !!hi !hi" ``` Wri...
[]
[]
1
stdio
You are required to create a simple calculator that returns the result of addition, subtraction, multiplication or division of two numbers. Your function will accept three arguments: The first and second argument should be numbers. The third argument should represent a sign indicating the operation to perform on these...
[]
[]
1
stdio
Given an array (or list or vector) of arrays (or, guess what, lists or vectors) of integers, your goal is to return the sum of a specific set of numbers, starting with elements whose position is equal to the main array length and going down by one at each step. Say for example the parent array (etc, etc) has 3 sub-arr...
[]
[]
1
stdio
## Task In this kata you'll be given a string of English digits "collapsed" together, like this: `zeronineoneoneeighttwoseventhreesixfourtwofive` Your task is to split the string back to digits: `zero nine one one eight two seven three six four two five` ## Examples ``` three -> three eightsix -> eight six fivefour...
[]
[]
1
stdio
A nearby pie shop is having a special sale. For each pie you pay full price for, you may select one pie of a strictly lesser value to get for free. Given the prices of all the pies you wish to acquire, determine the minimum total amount you must pay for all of the pies. Input Input will begin with an integer n (1 ≤ n...
[ "30\n3 6 3 8 6 4 4 2 4 10 8 5 9 6 7 7 9 4 7 4 10 1 9 10 4 7 7 4 2 3\n", "1\n1\n", "50\n4 2 6 7 2 6 3 8 8 2 4 8 4 4 1 4 5 2 2 5 6 4 3 3 3 6 8 2 1 3 1 8 2 3 7 4 7 5 4 8 3 5 7 8 6 7 5 8 7 1\n", "40\n2 6 5 5 6 6 7 8 6 5 3 9 9 1 8 3 7 3 7 2 3 1 3 1 5 8 1 3 8 2 3 2 2 1 4 4 4 3 5 5\n", "10\n1 1 1 1 1 2 3 4 5 6\n",...
[ "96\n", "1\n", "130\n", "100\n", "16\n", "505072434\n", "22\n", "880460566", "96\n", "2\n" ]
1
stdio
Iahub likes chess very much. He even invented a new chess piece named Coder. A Coder can move (and attack) one square horizontally or vertically. More precisely, if the Coder is located at position (x, y), he can move to (or attack) positions (x + 1, y), (x–1, y), (x, y + 1) and (x, y–1). Iahub wants to know how many ...
[ "2\n", "3\n", "4\n", "10\n", "15\n", "1\n", "15\n", "101\n", "3\n", "4\n" ]
[ "2\nC.\n.C\n", "5\nC.C\n.C.\nC.C\n", "8\nC.C.\n.C.C\nC.C.\n.C.C\n", "50\nC.C.C.C.C.\n.C.C.C.C.C\nC.C.C.C.C.\n.C.C.C.C.C\nC.C.C.C.C.\n.C.C.C.C.C\nC.C.C.C.C.\n.C.C.C.C.C\nC.C.C.C.C.\n.C.C.C.C.C\n", "113\nC.C.C.C.C.C.C.C\n.C.C.C.C.C.C.C.\nC.C.C.C.C.C.C.C\n.C.C.C.C.C.C.C.\nC.C.C.C.C.C.C.C\n.C.C.C.C.C.C.C.\nC.C....
1
stdio
Algorithmic predicament - Bug Fixing #9 Oh no! Timmy's algorithim has gone wrong! help Timmy fix his algorithim! Task Your task is to fix timmy's algorithim so it returns the group name with the highest total age. You will receive two groups of `people` objects, with two properties `name` and `age`. The name prope...
[]
[]
1
stdio
Given is an integer N. Find the minimum possible positive integer k such that (1+2+\cdots+k) is a multiple of N. It can be proved that such a positive integer k always exists. Constraints * 1 \leq N \leq 10^{15} * All values in input are integers. Input Input is given from Standard Input in the following format: ...
[ "39730771", "5", "36307133", "71266519", "3807301", "3003457", "3532816", "6261239", "8870499", "11036793" ]
[ "39730770\n", "4\n", "3157141\n", "17269679\n", "928609\n", "295422\n", "220800\n", "914563\n", "328536\n", "3678930\n" ]
1
stdio
Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states: XX XX .X X. X. .X XX XX Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't oc...
[ "00\n00\n", "00X00X0XXX0\n0XXX0X00X00\n", "0X0X0\n0X0X0\n", "0XXX0\n00000\n", "0\n0\n", "0\nX\n", "X\n0\n", "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\nXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...
[ "1", "4", "0", "2", "0", "0", "0", "0", "18", "0" ]
1
stdio
I conducted an exit poll of the shopping amount at a department store. Create a program that takes the shopping amount data as input, calculates the average shopping amount per person, and outputs it. The number of people surveyed shall be 100,000 or less, and the shopping amount per person shall not exceed 1 million y...
[ "6\n23426\n5600\n33800\n0\n26495\n52000", "6\n23426\n5600\n33800\n0\n17519\n52000", "6\n23426\n5600\n33800\n0\n14222\n52000", "6\n23426\n5600\n33800\n0\n2007\n52000", "6\n23426\n5600\n33800\n0\n2007\n80378", "6\n23426\n5600\n33800\n0\n3681\n80378", "6\n23426\n5600\n33800\n0\n3681\n10193", "6\n46488\n5...
[ "23553\n", "22057\n", "21508\n", "19472\n", "24201\n", "24480\n", "12783\n", "16627\n", "16293\n", "16294\n" ]
1
stdio
Description In English we often use "neutral vowel sounds" such as "umm", "err", "ahh" as fillers in conversations to help them run smoothly. Bob always finds himself saying "err". Infact he adds an "err" to every single word he says that ends in a consonant! Because Bob is odd, he likes to stick to this habit even w...
[]
[]
1
stdio
The number 81 has a special property, a certain power of the sum of its digits is equal to 81 (nine squared). Eighty one (81), is the first number in having this property (not considering numbers of one digit). The next one, is 512. Let's see both cases with the details 8 + 1 = 9 and 9^(2) = 81 512 = 5 + 1 + 2 = 8 a...
[]
[]
1
stdio
Summer vacation ended at last and the second semester has begun. You, a Kyoto University student, came to university and heard a rumor that somebody will barricade the entrance of your classroom. The barricade will be built just before the start of the A-th class and removed by Kyoto University students just before the...
[ "4 1 6\n9\n6\n8\n1", "2 1 2\n2\n2", "5 5 5\n5\n6\n11\n8\n9", "4 1 11\n7\n6\n0\n1", "4 3 6\n9\n6\n6\n1", "5 5 18\n5\n6\n7\n8\n9", "5 4 9\n5\n6\n11\n8\n9", "4 1 6\n9\n6\n0\n1", "2 2 2\n2\n2", "5 5 9\n5\n6\n11\n8\n9" ]
[ "3\n", "2\n", "5\n", "1\n", "4\n", "0\n", "2\n", "3\n", "2\n", "2\n" ]
1
stdio
Takahashi has N blue cards and M red cards. A string is written on each card. The string written on the i-th blue card is s_i, and the string written on the i-th red card is t_i. Takahashi will now announce a string, and then check every card. Each time he finds a blue card with the string announced by him, he will ear...
[ "3\napple\norange\napple\n1\ngrape\n", "3\napple\norange\napple\n5\napple\napple\napple\napple\napple\n", "1\nvoldemort\n10\nvoldemort\nvoldemort\nvoldemort\nvoldemort\nvoldemort\nvoldemort\nvoldemort\nvoldemort\nvoldemort\nvoldemort\n", "6\nred\nred\nblue\nyellow\nyellow\nred\n5\nred\nred\nyellow\ngreen\nblu...
[ "2\n", "1\n", "0\n", "1\n", "1\n", "2\n", "0\n", "3\n", "1\n", "1\n" ]
1
stdio
Write a program that extracts n different numbers from the numbers 0 to 9 and outputs the number of combinations that add up to s. Each n number is from 0 to 9, and the same number cannot be used in one combination. For example, if n is 3 and s is 6, the combination of the three numbers totaling 6 is 1 + 2 + 3 = 6 0 +...
[ "3 5\n3 1\n0 0", "3 0\n5 1\n0 0", "1 0\n5 1\n0 0", "3 6\n3 0\n0 0", "2 5\n1 1\n0 0", "2 0\n1 1\n0 0", "3 2\n0 0\n0 0", "2 2\n0 0\n0 0", "3 7\n3 1\n0 0", "3 8\n3 1\n0 0" ]
[ "2\n0\n", "0\n0\n", "1\n0\n", "3\n0\n", "3\n1\n", "0\n1\n", "0\n", "1\n", "4\n0\n", "5\n0\n" ]
1
stdio
Given an integer N, Chef wants to find the smallest positive integer M such that the bitwise XOR of M and M+1 is N. If no such M exists output -1. -----Input----- The first line of input contain an integer T denoting the number of test cases. Each of the following T lines contains an integer N for that test case. ---...
[ "1\n3\n", "1\n1", "1\n2", "1\n7", "1\n15", "1\n31", "1\n63", "1\n127", "1\n6", "1\n4" ]
[ "1\n", "2\n", "-1\n", "3\n", "7\n", "15\n", "31\n", "63\n", "-1\n", "-1\n" ]
1
stdio
A teacher decides to give toffees to his students. He asks n students to stand in a queue. Since the teacher is very partial, he follows the following rule to distribute toffees. He looks at the first two students and gives more toffees to the student having higher marks than the other one. If they have the same marks...
[ "166\nR===RL=LRRR=RRRL=LRR=R=RR==L=R=R=RRR=RR=RLLRRL=LLRL==L=R==RLR==RL=RR=LR==R=R=LLRLRLR=RR=RLLRLR=RRLL==L=LR=RR=RRRL=RLLLR==L=RRLRLLLLLLLRL===LRLRLRLRRLL=LRLL===LRLRR==\n", "3\nR=\n", "6\nRLRL=\n", "453\nR==LL==RRLLRRLR=L=LRLL=LRRR=R====L=RL======RR==RRRR=LRR=LLLRR=LLLLL===LL=LLL=LR=RLRL===L==R=LRL=L=R==RR...
[ "1 2 2 2 2 3 2 2 1 2 3 4 4 5 6 7 2 2 1 2 3 3 4 4 5 6 6 6 1 1 2 2 3 3 4 5 6 6 7 8 8 9 2 1 2 4 3 3 2 1 3 2 2 2 1 1 2 2 2 3 1 2 2 2 3 1 1 2 3 3 1 2 2 2 3 3 4 4 2 1 2 1 2 1 2 2 3 4 4 5 2 1 2 1 2 2 3 5 4 3 3 3 2 2 1 2 2 3 4 4 5 6 7 1 1 4 3 2 1 2 2 2 1 1 2 3 1 8 7 6 5 4 3 2 1 3 2 2 2 2 1 2 1 2 1 2 1 2 4 3 2 2 1 4 3 2 2 2...
1
stdio
Example Input crc 1 Output crc
[ "crb\n1", "bqc\n1", "bcq\n2", "ccq\n2", "cdq\n2", "dcq\n2", "dcq\n4", "qcd\n3", "qce\n3", "qce\n4" ]
[ "bcrcb\n", "bcqcb\n", "bqcqb\n", "NONE\n", "cqdqc\n", "dqcqd\n", "qdcdq\n", "qcdcq\n", "qcecq\n", "qeceq\n" ]
1
stdio
While surfing in web I found interesting math problem called "Always perfect". That means if you add 1 to the product of four consecutive numbers the answer is ALWAYS a perfect square. For example we have: 1,2,3,4 and the product will be 1X2X3X4=24. If we add 1 to the product that would become 25, since the result numb...
[]
[]
1
stdio
Write a method that returns true if a given parameter is a power of 4, and false if it's not. If parameter is not an Integer (eg String, Array) method should return false as well. (In C# Integer means all integer Types like Int16,Int32,.....) ### Examples ```python isPowerOf4 1024 #should return True isPowerOf4 102...
[]
[]
1
stdio
Yaroslav has an array, consisting of (2·n - 1) integers. In a single operation Yaroslav can change the sign of exactly n elements in the array. In other words, in one operation Yaroslav can select exactly n array elements, and multiply each of them by -1. Yaroslav is now wondering: what maximum sum of array elements c...
[ "2\n50 50 50\n", "2\n-1 -100 -1\n", "3\n-959 -542 -669 -513 160\n", "4\n717 473 344 -51 -548 703 -869\n", "5\n270 -181 957 -509 -6 937 -175 434 -625\n", "6\n-403 901 -847 -708 -624 413 -293 709 886 445 716\n", "7\n-236 533 869 903 655 -714 27 890 -311 800 307 -682 665\n", "8\n-338 134 708 -761 -135 53...
[ "150\n", "100\n", "2843\n", "3603\n", "4094\n", "6359\n", "7592\n", "6463\n", "8094\n", "9591\n" ]
1
stdio
While most devs know about [big/little-endianness](https://en.wikipedia.org/wiki/Endianness), only a selected few know the secret of real hard core coolness with mid-endians. Your task is to take a number and return it in its mid-endian format, putting the most significant couple of bytes in the middle and all the oth...
[]
[]
1
stdio
Two integers are coprimes if the their only greatest common divisor is 1. ## Task In this kata you'll be given a number ```n >= 2``` and output a list with all positive integers less than ```gcd(n, k) == 1```, with ```k``` being any of the output numbers. The list cannot include duplicated entries and has to be sorte...
[]
[]
1
stdio
Once Bob decided to lay a parquet floor in his living room. The living room is of size n × m metres. Bob had planks of three types: a planks 1 × 2 meters, b planks 2 × 1 meters, and c planks 2 × 2 meters. Help Bob find out, if it is possible to parquet the living room with such a set of planks, and if it is possible, f...
[ "100 100 10000 10000 10000\n", "100 100 0 0 0\n", "100 100 2498 2498 1\n", "1 2 0 1 0\n", "100 100 2499 2499 0\n", "90 100 1488 2992 10\n", "2 1 1 0 0\n", "97 100 58 172 2310\n", "100 100 2474 270 1128\n", "99 99 2797 749 677\n" ]
[ "aabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabb\naabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabb\nbbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaa\nbbaabbaab...
1
stdio
Several drivers had lined up for the Drag Racing Competition at the Tokyo Drift Street. Dom had organized the competition, but he was not available during all the races and hence he did not know their results. In the drag race match, 2 drivers race against each other and one of them is the winner, and the loser gets el...
[ "9\nznejwgwpok wohkjjwlwn\nuwdszgerob pxutblrgio\ntnvpozvuib rmkroequbu\nxozaulqdsc wneolwstpl\ntnvpozvuib evrtybebba\nrfsijiyzzn ehbrqxwqft\nrphpmhvjxw luohdaqoyr\nrsdfhgmges chjthfleee\nqrjdszcwxt abzorlrlsh\ntgszjlyyra cdvenegwyc\nneigxtnilh mcizjrkuof\njyxkpozzlr iijjdgauzu\nvkzhdolaqo yldeohgpgi\nvtsnibclli ew...
[ "pxrtqhmuoa\n", "axtzpuwube\n", "qbpapwvndk\n", "ijetrpnsjc\n", "hrrugxurrh\n", "iwtqgydtbw\n", "fovjpmznym\n", "daoeglsuhs\n", "gkjjvchyhp\n", "tgajndqkfb\n" ]
1
stdio
For an integer ```k``` rearrange all the elements of the given array in such way, that: all elements that are less than ```k``` are placed before elements that are not less than ```k```; all elements that are less than ```k``` remain in the same order with respect to each other; all elements that are not less than ```...
[]
[]
1
stdio
Due to another of his misbehaved, the primary school's teacher of the young Gauß, Herr J.G. Büttner, to keep the bored and unruly young schoolboy Karl Friedrich Gauss busy for a good long time, while he teaching arithmetic to his mates, assigned him the problem of adding up all the whole numbers from 1 through a give...
[]
[]
1
stdio
You are given three numbers. Is there a way to replace variables A, B and C with these numbers so the equality A + B = C is correct? Input: There are three numbers X1, X2 and X3 (1 ≤ Xi ≤ 10^100), each on a separate line of input. Output: Output either "YES", if there is a way to substitute variables A, B and C wit...
[ "1000000000000000000000000000000000000000000000000000000000000000000000000000\n2000000000000000000000000000000000000000000000000000000000000000000000000000\n4000000000000000000000000000000000000000000000000000000000000000000000000000", "3000000000000000000000000000000\n7000000000000000000000000000000\n20000000000...
[ "YES", "NO", "YES", "YES", "NO", "NO", "YES", "YES", "NO", "NO" ]
1
stdio
Teacher thinks that we make a lot of progress. Now we are even allowed to use decimal notation instead of counting sticks. After the test the teacher promised to show us a "very beautiful number". But the problem is, he's left his paper with the number in the teachers' office. The teacher remembers that the "very beau...
[ "6 5\n", "1 2\n", "6 4\n", "11 1\n", "42 5\n", "36 5\n", "56 3\n", "88 9\n", "81 7\n", "100 1\n" ]
[ "142857", "Impossible\n", "102564", "11111111111", "102040816326530612244897959183673469387755", "142857142857142857142857142857142857", "10344827586206896551724137931034482758620689655172413793", "1011235955056179775280898876404494382022471910112359550561797752808988764044943820224719", "Impossible...
1
stdio
Finish the solution so that it sorts the passed in array of numbers. If the function passes in an empty array or null/nil value then it should return an empty array. For example: ```python solution([1,2,3,10,5]) # should return [1,2,3,5,10] solution(None) # should return [] ``` ```Hakell sortNumbers [1, 2, 10, 50, 5...
[]
[]
1
stdio
# Introduction: Reversi is a game usually played by 2 people on a 8x8 board. Here we're only going to consider a single 8x1 row. Players take turns placing pieces, which are black on one side and white on the other, onto the board with their colour facing up. If one or more of the opponents pieces are sandwiched by ...
[]
[]
1
stdio
# Task A media access control address (MAC address) is a unique identifier assigned to network interfaces for communications on the physical network segment. The standard (IEEE 802) format for printing MAC-48 addresses in human-friendly form is six groups of two hexadecimal digits (0 to 9 or A to F), separated by hy...
[]
[]
1
stdio
Stepan has the newest electronic device with a display. Different digits can be shown on it. Each digit is shown on a seven-section indicator like it is shown on the picture below. [Image] So, for example, to show the digit 3 on the display, 5 sections must be highlighted; and for the digit 6, 6 sections must be high...
[ "2\n", "3\n", "4\n", "5\n", "6\n", "9\n", "156\n", "255\n", "8343\n", "156\n" ]
[ "1\n", "7\n", "11\n", "71\n", "111\n", "7111\n", "111111111111111111111111111111111111111111111111111111111111111111111111111111\n", "7111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\n", "711111111111111111111111111111111...
1
stdio
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd. -----Constraints----- - 1 ≤ a,b ≤ 10000 - a and b are integers. -----Input----- Input is given from Standard Input in the following format: a b -----Output----- If the product is odd, print Odd; if it i...
[ "3 4\n", "1 21\n", "4 4", "1 15", "2 4", "2 15", "3 0", "2 26", "3 -1", "2 32" ]
[ "Even\n", "Odd\n", "Even\n", "Odd\n", "Even\n", "Even\n", "Even\n", "Even\n", "Odd\n", "Even\n" ]
1
stdio
Not considering number 1, the integer 153 is the first integer having this property: the sum of the third-power of each of its digits is equal to 153. Take a look: 153 = 1^3 + 5^3 + 3^3 = 1 + 125 + 27 = 153 The next number that experiments this particular behaviour is 370 with the same power. Write the function `eq_...
[]
[]
1
stdio
Tavak and Seyyed are good friends. Seyyed is very funny and he told Tavak to solve the following problem instead of longest-path. You are given l and r. For all integers from l to r, inclusive, we wrote down all of their integer divisors except 1. Find the integer that we wrote down the maximum number of times. Solve...
[ "19 29\n", "3 6\n", "39 91\n", "76 134\n", "93 95\n", "17 35\n", "94 95\n", "51 52\n", "47 52\n", "38 98\n" ]
[ "2\n", "2\n", "2\n", "2\n", "2\n", "2\n", "2\n", "2\n", "2\n", "2\n" ]
1
stdio
Read problems statements in Mandarin Chinese and Russian. Chef had a hard day and want to play little bit. The game is called "Chain". Chef has the sequence of symbols. Each symbol is either '-' or '+'. The sequence is called Chain if each two neighboring symbols of sequence are either '-+' or '+-'. For example seq...
[ "2\n---+-+-+++\n-------", "2\n+++-+-+---\n-------", "2\n-+--+++--+\n-------", "2\n-+-+-+-+-+\n-------", "2\n--++---+++\n-----+-", "2\n---+-+-+++\n-----+-", "2\n+-+-+-+--+\n-------", "2\n---+++-+-+\n-------", "2\n-+-+++---+\n-------", "2\n+-+++----+\n-------" ]
[ "2\n3", "2\n3\n", "4\n3\n", "0\n3\n", "4\n2\n", "2\n2\n", "2\n3\n", "2\n3\n", "2\n3\n", "4\n3\n" ]
1
stdio
The chef has a recipe he wishes to use for his guests, but the recipe will make far more food than he can serve to the guests. The chef therefore would like to make a reduced version of the recipe which has the same ratios of ingredients, but makes less food. The chef, however, does not like fractions. The original rec...
[ "3\n2 4 4\n3 2 3 4\n4 3 15 9 6", "3\n2 4 4\n3 2 3 4\n4 3 20 9 6", "3\n2 4 4\n3 2 1 4\n4 3 15 9 6", "3\n2 4 4\n3 2 3 4\n4 3 20 9 8", "3\n2 4 7\n3 2 1 4\n4 3 15 9 6", "3\n2 4 4\n3 2 3 6\n4 3 20 9 8", "3\n2 4 4\n3 2 3 8\n4 3 15 9 6", "3\n2 4 8\n3 2 3 4\n4 3 20 9 6", "3\n2 4 8\n3 2 1 4\n4 3 15 9 6", "...
[ "1 1\n2 3 4\n1 5 3 2", "1 1\n2 3 4\n3 20 9 6\n", "1 1\n2 1 4\n1 5 3 2\n", "1 1\n2 3 4\n3 20 9 8\n", "4 7\n2 1 4\n1 5 3 2\n", "1 1\n2 3 6\n3 20 9 8\n", "1 1\n2 3 8\n1 5 3 2\n", "1 2\n2 3 4\n3 20 9 6\n", "1 2\n2 1 4\n1 5 3 2\n", "1 1\n3 3 8\n1 5 3 2\n" ]
1
stdio
You are given a sequence of N integer numbers A. Calculate the sum of A_{i} AND A_{j} for all the pairs (i, j) where i < j. The AND operation is the Bitwise AND operation, defined as in here. ------ Input ------ The first line of input consists of the integer N. The second line contains N integer numbers - the s...
[ "5\n1 2 3 4 5", "5\n2 2 3 4 5", "5\n2 2 6 4 5", "5\n0 2 6 4 5", "5\n1 2 5 4 6", "5\n0 2 3 4 5", "5\n2 2 6 6 5", "5\n1 2 8 4 6", "5\n0 2 5 4 4", "5\n0 2 3 0 5" ]
[ "9", "11\n", "18\n", "14\n", "15\n", "7\n", "24\n", "6\n", "12\n", "3\n" ]
1
stdio
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal to qi. Your task is to find any interesting array of n elements or state that su...
[ "1 2\n1 1 1\n1 1 3\n", "1 1\n1 1 10\n", "1 2\n1 1 10\n1 1 5\n", "3 2\n1 2 536870912\n2 3 536870911\n", "1 1\n1 1 19\n", "3 2\n1 2 536870912\n3 3 536870911\n", "3 2\n1 2 536870912\n3 3 952275870\n", "3 2\n1 2 536870912\n3 3 121805432\n", "1 1\n1 1 11\n", "3 2\n1 2 536870912\n2 3 331461822\n" ]
[ "NO\n", "YES\n10\n", "NO\n", "YES\n536870912 1073741823 536870911\n", "YES\n19\n", "YES\n536870912 536870912 536870911\n", "YES\n536870912 536870912 952275870\n", "YES\n536870912 536870912 121805432\n", "YES\n11\n", "YES\n536870912 868332734 331461822\n" ]
1
stdio
Given a long number, return all the possible sum of two digits of it. For example, `12345`: all possible sum of two digits from that number are: [ 1 + 2, 1 + 3, 1 + 4, 1 + 5, 2 + 3, 2 + 4, 2 + 5, 3 + 4, 3 + 5, 4 + 5 ] Therefore the result must be: [ 3, 4, 5, 6, 5, 6, 7, 7, 8, 9 ] Write your solution by mod...
[]
[]
1
stdio
For a given weighted directed graph G(V, E), find the distance of the shortest route that meets the following criteria: * It is a closed cycle where it ends at the same point it starts. * It visits each vertex exactly once. Constraints * 2 ≤ |V| ≤ 15 * 0 ≤ di ≤ 1,000 * There are no multiedge Input |V| |E| s0 t0 d...
[ "3 3\n0 0 1\n1 2 1\n0 2 1", "4 6\n0 1 2\n2 2 3\n1 3 9\n2 0 1\n2 3 6\n3 2 4", "4 6\n0 1 2\n2 2 3\n1 3 1\n2 0 1\n2 3 6\n3 2 4", "4 6\n0 1 2\n2 2 3\n1 3 14\n2 0 1\n2 3 19\n3 2 4", "1 1\n0 0 0\n1 2 1\n0 2 1", "4 6\n0 1 2\n2 2 3\n1 3 8\n2 0 1\n2 3 19\n3 2 4", "3 3\n0 0 1\n2 2 1\n0 2 1", "3 3\n0 1 1\n1 2 1\...
[ "-1\n", "16\n", "8\n", "21\n", "0\n", "15\n", "-1\n", "-1\n", "-1\n", "-1\n" ]
1
stdio
For given $N$ points in the 2D Euclidean plane, find the distance of the shortest tour that meets the following criteria: * Visit the points according to the following steps: 1. It starts from the leftmost point (starting point), goes strictly from left to right, and then visits the rightmost point (turn-around point)...
[ "3\n0 -1\n1 1\n2 0", "5\n-1 0\n1 2\n2 1\n3 2\n4 0", "4\n0 1\n1 2\n3 0\n3 1", "3\n0 -1\n1 2\n2 0", "4\n0 1\n1 4\n3 0\n3 1", "3\n0 -1\n1 0\n2 0", "4\n0 0\n1 4\n3 0\n3 1", "3\n0 -1\n1 0\n0 0", "4\n0 0\n1 6\n3 0\n3 1", "3\n0 0\n1 0\n0 0" ]
[ "5.886349517\n", "12.462840740\n", "7.812559200\n", "7.634413615\n", "10.930106596\n", "4.650281540\n", "11.728656901\n", "3.414213562\n", "15.467927337\n", "2.000000000\n" ]
1
stdio
Write a function that when given a URL as a string, parses out just the domain name and returns it as a string. For example: ```python domain_name("http://github.com/carbonfive/raygun") == "github" domain_name("http://www.zombie-bites.com") == "zombie-bites" domain_name("https://www.cnet.com") == "cnet" ``` Write you...
[]
[]
1
stdio
You are given two strings s and t consisting of lowercase English letters and an integer L. We will consider generating a string of length L by concatenating one or more copies of s and t. Here, it is allowed to use the same string more than once. For example, when s = `at`, t = `code` and L = 6, the strings `atatat`...
[ "10\ncoin\nahe", "8\ncoding\nfestiual", "6\nat\ncnde", "8\nsamd\nsame", "10\ncoin\naeh", "10\nnioc\naeh", "6\nta\nncde", "8\nsame\nsmae", "10\ncnin\naeh", "8\ngnicoc\nfisteual" ]
[ "aheahecoin\n", "festiual\n", "atatat\n", "samdsamd\n", "aehaehcoin\n", "aehaehnioc\n", "ncdeta\n", "samesame\n", "aehaehcnin\n", "fisteual\n" ]
1
stdio
You are given a range of positive integers from $l$ to $r$. Find such a pair of integers $(x, y)$ that $l \le x, y \le r$, $x \ne y$ and $x$ divides $y$. If there are multiple answers, print any of them. You are also asked to answer $T$ independent queries. -----Input----- The first line contains a single integer...
[ "3\n1 10\n3 14\n1 10\n", "3\n6969 696969\n6969 696969\n6969 696969\n", "1\n696969 100000000\n", "1\n69696969 998244353\n", "1\n69696969 998244353\n", "1\n696969 100000000\n", "3\n6969 696969\n6969 696969\n6969 696969\n", "3\n1 10\n3 14\n1 10\n", "1\n81363505 998244353\n", "1\n1163931 100000000\n" ...
[ "1 2\n3 6\n1 2\n", "6969 13938\n6969 13938\n6969 13938\n", "696969 1393938\n", "69696969 139393938\n", "69696969 139393938\n", "696969 1393938\n", "6969 13938\n6969 13938\n6969 13938\n", "1 2\n3 6\n1 2\n", "81363505 162727010\n", "1163931 2327862\n" ]
1
stdio
Vitaly is a diligent student who never missed a lesson in his five years of studying in the university. He always does his homework on time and passes his exams in time. During the last lesson the teacher has provided two strings s and t to Vitaly. The strings have the same length, they consist of lowercase English l...
[ "pkjlxzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\npkjlyaaaaaaaaaaaaaaaaaaaaaaaaaaaahr\n", "kexdbtpkjbwwyibjndbtmwqzolopqitgkomqggojevoankiepxirrcidxldlzsppehmoazdywltmjbxgsxgihwnwpmczjrcwpywl\nkexdbtpkjbwwyibjndbtmwqzolopqitgkomqggojevoankiepxirrcidxldlzsppehmoazdywltmjbxgsxgihwnwpmczjrcwpywm\n", "ddzzzzzzzzzzzzzzzzzzzzzzz...
[ "pkjlyaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "No such string", "deaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "aab", "baaa", "abcdefh", "No such string", "xqzbhslocdbifnyzyjenlpctocieaccsycmwlcebkqqkeibatfvylbqlutvjijgjhdetqsjqnoipqbmjhhzxggdobyvpczda...
1
stdio
You wrote all your unit test names in camelCase. But some of your colleagues have troubles reading these long test names. So you make a compromise to switch to underscore separation. To make these changes fast you wrote a class to translate a camelCase name into an underscore separated name. Implement the ToUnderscor...
[]
[]
1
stdio
You would like to get the 'weight' of a name by getting the sum of the ascii values. However you believe that capital letters should be worth more than mere lowercase letters. Spaces, numbers, or any other character are worth 0. Normally in ascii a has a value of 97 A has a value of 65 ' ' has a value of ...
[]
[]
1
stdio
Snuke has come to a store that sells boxes containing balls. The store sells the following three kinds of boxes: * Red boxes, each containing R red balls * Green boxes, each containing G green balls * Blue boxes, each containing B blue balls Snuke wants to get a total of exactly N balls by buying r red boxes, g gre...
[ "1 2 3 1", "13 1 4 540", "1 2 3 2", "17 1 4 540", "13 2 4 3000", "13 1 4 97", "18 1 4 540", "13 2 1 3000", "13 1 4 62", "13 1 4 92" ]
[ "1\n", "2898\n", "2\n", "2232\n", "43732\n", "108\n", "2116\n", "174001\n", "48\n", "98\n" ]
1
stdio
If you like Taco Bell, you will be familiar with their signature doritos locos taco. They're very good. Why can't everything be a taco? We're going to attempt that here, turning every word we find into the taco bell recipe with each ingredient. We want to input a word as a string, and return a list representing tha...
[]
[]
1
stdio
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade a_{i} for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write b_...
[ "5 5 4\n5 2\n4 7\n3 1\n3 2\n2 5\n", "2 5 4\n5 2\n5 2\n", "6 5 5\n1 7\n2 4\n3 5\n4 6\n5 6\n4 7\n", "1 1000000000 1000000\n1 1000000\n", "10 10 7\n1 10\n2 9\n3 8\n4 7\n5 6\n6 5\n7 4\n8 3\n9 2\n10 1\n", "3 5 2\n1 10\n1 7\n1 4\n", "10 10 10\n9 8\n3 9\n3 6\n10 5\n5 5\n6 10\n10 3\n6 7\n2 3\n9 8\n", "1 1 1\n...
[ "4\n", "0\n", "63\n", "999999000000\n", "70\n", "12\n", "238\n", "0\n", "54\n", "10\n" ]
1
stdio
We have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand. How many grams of sand will the upper bulb contains after t seconds? -----Constraints----- - 1≤X≤10^9 - 1≤t≤10^9 - X and t are integers. -----I...
[ "100 17\n", "48 58\n", "1000000000 1000000000\n", "48 39", "1000000010 1000000000", "000 17", "48 19", "1001000010 1000000000", "48 0", "1001000010 1000010000" ]
[ "83\n", "0\n", "0\n", "9\n", "10\n", "0\n", "29\n", "1000010\n", "48\n", "990010\n" ]
1
stdio
Oh no! Ghosts have reportedly swarmed the city. It's your job to get rid of them and save the day! In this kata, strings represent buildings while whitespaces within those strings represent ghosts. So what are you waiting for? Return the building(string) without any ghosts(whitespaces)! Example: Should return: If ...
[]
[]
1
stdio
Write a function that takes an arbitrary number of strings and interlaces them (combines them by alternating characters from each string). For example `combineStrings('abc', '123')` should return `'a1b2c3'`. If the strings are different lengths the function should interlace them until each string runs out, continuing...
[]
[]
1
stdio
There is an image with a height of H pixels and a width of W pixels. Each of the pixels is represented by either . or *. The character representing the pixel at the i-th row from the top and the j-th column from the left, is denoted by C_{i,j}. Extend this image vertically so that its height is doubled. That is, print ...
[ "2 2\n*.\n.*\n", "1 4\n***.\n", "9 20\n.....***....***.....\n....*...*..*...*....\n...*.....**.....*...\n...*.....*......*...\n....*.....*....*....\n.....**..*...**.....\n.......*..*.*.......\n........**.*........\n.........**.........\n", "9 20\n.....***....***.....\n....*...*..*...*....\n...*.....**.....*.....
[ "*.\n*.\n.*\n.*\n", "***.\n***.\n", ".....***....***.....\n.....***....***.....\n....*...*..*...*....\n....*...*..*...*....\n...*.....**.....*...\n...*.....**.....*...\n...*.....*......*...\n...*.....*......*...\n....*.....*....*....\n....*.....*....*....\n.....**..*...**.....\n.....**..*...**.....\n.......*..*...
1
stdio
Witua is a little student from the University of Lviv. He enjoys studying math. Witua knows a lot of famous mathematicians like Eratosthenes, Pythagoras, Fermat, Diophantus, Furko, Gauss and so on. However, his favorite one is Euler. The only thing Witua likes more than Euler is Euler’s totient function φ. He is explor...
[ "3\n2\n3\n4\n", "3\n4\n3\n4", "3\n4\n2\n4", "3\n6\n2\n3", "3\n6\n2\n7", "3\n12\n2\n7", "3\n14\n2\n7", "3\n2\n2\n4", "3\n6\n4\n3", "3\n14\n3\n7" ]
[ "2\n3\n3\n", "3\n3\n3\n", "3\n2\n3\n", "5\n2\n3\n", "5\n2\n7\n", "11\n2\n7\n", "13\n2\n7\n", "2\n2\n3\n", "5\n3\n3\n", "13\n3\n7\n" ]
1
stdio
Read problems statements in Mandarin Chinese and Russian. You are given a multiset of N integers. Please find such a nonempty subset of it that the sum of the subset's elements is divisible by N. Otherwise, state that this subset doesn't exist. ------ Input ------ The first line of the input contains an integer T...
[ "1\n3\n4 6 10", "1\n3\n4 6 16", "1\n3\n4 11 3", "1\n3\n2 11 3", "1\n3\n0 6 10", "1\n3\n4 4 4", "1\n3\n2 5 1", "1\n3\n4 6 4", "1\n3\n4 6 0", "1\n3\n4 6 3" ]
[ "1\n2", "1\n2 \n", "2\n1 2 \n", "1\n3 \n", "1\n1 \n", "3\n1 2 3 \n", "2\n2 3 \n", "1\n2 \n", "1\n2 \n", "1\n2 \n" ]
1
stdio
Today at the lesson Vitya learned a very interesting function — mex. Mex of a sequence of numbers is the minimum non-negative number that is not present in the sequence as element. For example, mex([4, 33, 0, 1, 1, 5]) = 2 and mex([1, 2, 3]) = 0. Vitya quickly understood all tasks of the teacher, but can you do the sa...
[ "10 30\n0 0 0 0 0 0 0 0 0 0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n", "5 5\n1 2 3 4 5\n1\n2\n3\n4\n5\n", "17 30\n4194 1990 2257 1363 2798 386 3311 3152 1808 1453 3874 4388 1268 3924 3799 1269 968\n8\n8\n8\n8\n8\n8\n8\n8\n8\n8\n8\n8\n8\n8\n8\n8\n8\n8\n8\n8\n8\n...
[ "1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n", "1\n3\n0\n2\n1\n", "0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n", "0\n2\n0\n", "1\n0\n0\n2\n1\n", "0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n...
1
stdio
You have unlimited number of coins with values $1, 2, \ldots, n$. You want to select some set of coins having the total value of $S$. It is allowed to have multiple coins with the same value in the set. What is the minimum number of coins required to get sum $S$? -----Input----- The only line of the input contains...
[ "5 11\n", "6 16\n", "14 28\n", "5 29\n", "10 24\n", "1 30\n", "14969 66991573\n", "1 1000000000\n", "100000 1\n", "10 46\n" ]
[ "3", "3", "2", "6", "3", "30", "4476", "1000000000", "1", "5" ]
1
stdio
How many strings can be obtained by applying the following operation on a string S exactly K times: "choose one lowercase English letter and insert it somewhere"? The answer can be enormous, so print it modulo (10^9+7). -----Constraints----- - K is an integer between 1 and 10^6 (inclusive). - S is a string of length...
[ "5\noof\n", "37564\nwhydidyoudesertme\n", "5\nooe", "37564\nwhydidzoudesertme", "5\neoo", "37564\nwhxdidzoudesertme", "5\ndoo", "37564\nwhxdidzoudesertne", "5\ndop", "37564\nwhxdiczoudesertne" ]
[ "575111451\n", "318008117\n", "575111451\n", "318008117\n", "575111451\n", "318008117\n", "575111451\n", "318008117\n", "575111451\n", "318008117\n" ]
1
stdio
Your boss decided to save money by purchasing some cut-rate optical character recognition software for scanning in the text of old novels to your database. At first it seems to capture words okay, but you quickly notice that it throws in a lot of numbers at random places in the text. For example: ```python string_clea...
[]
[]
1
stdio
Snuke is standing on a two-dimensional plane. In one operation, he can move by 1 in the positive x-direction, or move by 1 in the positive y-direction. Let us define a function f(r, c) as follows: - f(r,c) := (The number of paths from the point (0, 0) to the point (r, c) that Snuke can trace by repeating the operatio...
[ "1 1 2 2\n", "314 159 2653 589\n", "1 1 1000000 1000000\n", "349 602 998593 983904\n", "33400 31000 33400 593020\n", "1999 1322 290329 1325\n", "799999 789898 979797 999999\n", "1000000 1000000 1000000 1000000\n", "53245 34234 643323 948342\n", "3 3 3 3\n" ]
[ "14\n", "602215194\n", "625314154\n", "601079779\n", "67962523\n", "333678807\n", "50188529\n", "192151600\n", "574642047\n", "20\n" ]
1
stdio
Phoenix is playing with a new puzzle, which consists of $n$ identical puzzle pieces. Each puzzle piece is a right isosceles triangle as shown below. A puzzle piece The goal of the puzzle is to create a square using the $n$ pieces. He is allowed to rotate and move the pieces around, but none of them can overlap and al...
[ "3\n2\n4\n6\n", "1\n999939200\n", "1\n92888450\n", "1\n1458\n", "1\n9060100\n", "1\n500101938\n", "1\n100000001\n", "1\n200040002\n", "1\n200000000\n", "1\n536870913\n" ]
[ "YES\nYES\nNO\n", "YES\n", "YES\n", "YES\n", "YES\n", "YES\n", "NO\n", "YES\n", "YES\n", "NO\n" ]
1
stdio
Alex doesn't like boredom. That's why whenever he gets bored, he comes up with games. One long winter evening he came up with a game and decided to play it. Given a sequence a consisting of n integers. The player can make several steps. In a single step he can choose an element of the sequence (let's denote it a_{k}) ...
[ "2\n1 2\n", "3\n1 2 3\n", "9\n1 2 1 3 2 2 2 2 3\n", "5\n3 3 4 5 4\n", "5\n5 3 5 3 4\n", "5\n4 2 3 2 5\n", "10\n10 5 8 9 5 6 8 7 2 8\n", "10\n1 1 1 1 1 1 2 3 4 4\n", "100\n6 6 8 9 7 9 6 9 5 7 7 4 5 3 9 1 10 3 4 5 8 9 6 5 6 4 10 9 1 4 1 7 1 4 9 10 8 2 9 9 10 5 8 9 5 6 8 7 2 8 7 6 2 6 10 8 6 2 5 5 3 2 ...
[ "2\n", "4\n", "10\n", "11\n", "16\n", "9\n", "46\n", "14\n", "296\n", "313\n" ]
1
stdio
A word or a sentence in some language is called a pangram if all the characters of the alphabet of this language appear in it at least once. Pangrams are often used to demonstrate fonts in printing or test the output devices. You are given a string consisting of lowercase and uppercase Latin letters. Check whether thi...
[ "12\ntoosmallword\n", "35\nTheQuickBrownFoxJumpsOverTheLazyDog\n", "1\na\n", "26\nqwertyuiopasdfghjklzxcvbnm\n", "26\nABCDEFGHIJKLMNOPQRSTUVWXYZ\n", "48\nthereisasyetinsufficientdataforameaningfulanswer\n", "30\nToBeOrNotToBeThatIsTheQuestion\n", "30\njackdawslovemybigsphinxofquarz\n", "31\nTHEFIVEB...
[ "NO\n", "YES\n", "NO\n", "YES\n", "YES\n", "NO\n", "NO\n", "NO\n", "YES\n", "NO\n" ]
1
stdio
There are two rectangles. The lengths of the vertical sides of the first rectangle are A, and the lengths of the horizontal sides of the first rectangle are B. The lengths of the vertical sides of the second rectangle are C, and the lengths of the horizontal sides of the second rectangle are D. Print the area of the re...
[ "3 5 2 7\n", "100 600 200 300\n", "100 600 200 6", "3 3 2 7", "100 480 244 6", "0 3 0 7", "100 169 362 6", "100 311 362 6", "000 311 50 6", "110 311 50 6" ]
[ "15\n", "60000\n", "60000\n", "14\n", "48000\n", "0\n", "16900\n", "31100\n", "300\n", "34210\n" ]
1
stdio
Blackjack is a type of card game played in casinos, where the game is played using cards with numbers from 1 to 13. The score of each card is decided as follows. * 1 is 1 point or 11 points * From 2 to 9, the score is as written. * 10 points from 10 to 13 There are several participants in this game, including paren...
[ "1\n7 7 7\n7 7 8\n12 1\n10 1 2\n0", "1\n7 7 7\n7 7 8\n10 1\n10 1 1\n0", "1\n7 7 7\n7 7 8\n2 1\n10 2 1\n0", "1\n7 9 7\n7 7 8\n2 1\n10 2 1\n0", "1\n7 9 7\n1 9 8\n2 1\n10 2 1\n0", "1\n7 4 7\n1 9 8\n2 1\n10 2 1\n0", "1\n7 4 2\n1 9 8\n2 1\n10 2 1\n0", "1\n7 3 2\n1 9 8\n2 1\n10 2 1\n0", "1\n7 3 4\n1 9 8\n...
[ "11\n21\n0\n21\n13\n", "11\n21\n0\n21\n12\n", "11\n21\n0\n13\n13\n", "11\n0\n0\n13\n13\n", "11\n0\n18\n13\n13\n", "11\n18\n18\n13\n13\n", "11\n13\n18\n13\n13\n", "11\n12\n18\n13\n13\n", "11\n14\n18\n13\n13\n", "11\n14\n18\n13\n14\n" ]
1
stdio
Create a function that takes a string and an integer (`n`). The function should return a string that repeats the input string `n` number of times. If anything other than a string is passed in you should return `"Not a string"` ## Example ``` "Hi", 2 --> "HiHi" 1234, 5 --> "Not a string" ``` Write your solution by...
[]
[]
1
stdio
Little Petya loves presents. His mum bought him two strings of the same size for his birthday. The strings consist of uppercase and lowercase Latin letters. Now Petya wants to compare those two strings lexicographically. The letters' case does not matter, that is an uppercase letter is considered equivalent to the corr...
[ "kigPrWNTOUNDBskAfefjhHYZNYdnfZWuXWzHiBxFQryBbAkPtenFwWvCSTYGpzOntUNzNUhxRWjKmicTwLwJAnbAxj\nkigpRWntOUNdBsKaFEFjhhYZnYDNfzWuXwZhibxFQRybbakPteNfwwvcStyGPzoNTunznuHXrWjKMIctWLWJANBAxJ\n", "DQBdtSEDtFGiNRUeJNbOIfDZnsryUlzJHGTXGFXnwsVyxNtLgmklmFvRCzYETBVdmkpJJIvIOkMDgCFHZOTODiYrkwXd\nDQbDtsEdTFginRUEJNBOIfdZnsryulZ...
[ "0\n", "0\n", "-1\n", "-1\n", "1\n", "1\n", "1\n", "1\n", "0\n", "-1\n" ]
1
stdio
Draw a rectangle which has a height of H cm and a width of W cm. Draw a 1-cm square by single '#'. Constraints * 1 ≤ H ≤ 300 * 1 ≤ W ≤ 300 Input The input consists of multiple datasets. Each dataset consists of two integers H and W separated by a single space. The input ends with two 0 (when both H and W are zero)...
[ "3 4\n5 6\n2 3\n0 0", "3 4\n5 6\n2 0\n0 0", "3 4\n5 6\n2 4\n0 0", "4 4\n5 6\n2 0\n0 0", "4 4\n5 6\n4 0\n0 0", "4 3\n5 6\n4 -1\n0 0", "3 5\n5 6\n2 2\n0 0", "3 4\n5 0\n2 2\n0 0", "3 4\n5 6\n2 1\n0 0", "6 4\n5 6\n2 4\n0 0" ]
[ "####\n####\n####\n\n######\n######\n######\n######\n######\n\n###\n###\n\n", "####\n####\n####\n\n######\n######\n######\n######\n######\n\n\n\n\n", "####\n####\n####\n\n######\n######\n######\n######\n######\n\n####\n####\n\n", "####\n####\n####\n####\n\n######\n######\n######\n######\n######\n\n\n\n\n", ...
1
stdio
Catherine has a deck of n cards, each of which is either red, green, or blue. As long as there are at least two cards left, she can do one of two actions: take any two (not necessarily adjacent) cards with different colors and exchange them for a new card of the third color; take any two (not necessarily adjacent) c...
[ "2\nRB\n", "3\nGRG\n", "5\nBBBBB\n", "1\nR\n", "200\nBBRGRRBBRGGGBGBGBGRRGRGRGRBGRGRRBBGRGBGRRGRRRGGBBRGBGBGBRBBBBBBBGGBRGGRRRGGRGBGBGGBRRRRBRRRBRBBGGBGBRGRGBBBBGGBGBBBGBGRRBRRRGBGGBBBRBGRBRRGGGRRGBBBGBGRRRRRRGGRGRGBBBRGGGBGGGBRBBRRGBGRGRBRRRBRBGRGGBRBB\n", "101\nRRRRRRRRRRRRRRRRRRRBRRRRRRRRRRRRRRRRRRRRRR...
[ "G\n", "BR\n", "B\n", "R\n", "BGR\n", "BG\n", "BGR\n", "BGR\n", "BGR\n", "B\n" ]
1
stdio
A palindrome is a word, phrase, number, or other sequence of characters which reads the same backward as forward. Examples of numerical palindromes are: * 232 * 110011 * 54322345 Complete the function to test if the given number (`num`) **can be rearranged** to form a numerical palindrome or not. Return a boolean (`...
[]
[]
1
stdio
After several latest reforms many tourists are planning to visit Berland, and Berland people understood that it's an opportunity to earn money and changed their jobs to attract tourists. Petya, for example, left the IT corporation he had been working for and started to sell souvenirs at the market. This morning, as us...
[ "1 1\n2 1\n", "2 2\n1 3\n2 2\n", "4 3\n3 10\n2 7\n2 8\n1 1\n", "5 5\n3 5\n2 6\n3 2\n1 1\n1 6\n", "6 6\n1 6\n1 4\n1 8\n3 2\n3 2\n2 8\n", "6 12\n1 7\n1 10\n2 8\n1 2\n2 9\n3 5\n", "6 18\n3 3\n1 10\n2 10\n3 6\n1 3\n2 3\n", "20 25\n2 13\n3 11\n1 32\n1 43\n3 85\n1 14\n2 57\n1 54\n1 38\n2 96\n2 89\n3 64\n1 7...
[ "0\n", "3\n", "10\n", "13\n", "26\n", "41\n", "35\n", "990\n", "1605\n", "22\n" ]
1
stdio
Chingel is practicing for a rowing competition to be held on this saturday. He is trying his best to win this tournament for which he needs to figure out how much time it takes to cover a certain distance. **Input** You will be provided with the total distance of the journey, speed of the boat and whether he is goin...
[]
[]
1
stdio
In this kata we want to convert a string into an integer. The strings simply represent the numbers in words. Examples: * "one" => 1 * "twenty" => 20 * "two hundred forty-six" => 246 * "seven hundred eighty-three thousand nine hundred and nineteen" => 783919 Additional Notes: * The minimum number is "zero" (inclusiv...
[]
[]
1
stdio
Example Input 7 >> Output 7
[ "7\n>=", "7\n=>", "7\n?=", "7\n=?", "7\n<?", "7\n?<", "7\n><", "7\n>?", "7\n?>", "7\n?;" ]
[ "7\n", "7\n", "7\n", "7\n", "7\n", "7\n", "7\n", "7\n", "7\n", "7\n" ]
1
stdio
On the eve of Teddy Day Chotu decided to buy a teddy for his girlfriend Choti. He has N coins each having distinct value from 1 to N. Now after collecting all the coins he went to buy a Teddy. Now the shopkeeper Motu told Chotu that there is only one Teddy in the shop of Value K. As Chotu is very bhondu(idiot) he won...
[ "100\n4 29\n11 89\n16 150\n14 125\n18 192\n5 30\n8 47\n5 18\n20 17\n14 127\n11 80\n10 71\n12 6\n6 31\n13 112\n4 10\n8 45\n7 40\n7 50\n2 13\n6 49\n1 17\n8 54\n13 107\n20 228\n4 37\n16 163\n19 5\n16 147\n10 68\n12 92\n5 1\n5 15\n7 47\n16 7\n2 28\n2 27\n10 59\n13 109\n7 45\n1 22\n15 13\n5 38\n1 30\n19 213\n8 50\n5 15\...
[ "NO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nYES\nNO\nNO\nNO\nYES\nNO\nNO\nYES\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nNO\nYES\nNO\nNO\nNO\nNO\nNO\nNO\nYES\nNO\nNO\nNO\nNO\nYES\nNO\nNO\nNO\nYES\nNO\nNO\nYES\nYES\nNO\nNO\nYES\nNO\nNO\nNO\nYES\nNO\nYES\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\n...
1
stdio
Hannibal is on a mission. He has to shoot a criminal. Hannibal was on the point (0, 0) and the criminal is on the point (Xc, Yc). But there is a wall between the point (X1, Y1) and (X2, Y2). You have to tell whether Hannibal can shoot criminal or not. INPUT: First line contains the total number of test cases T. For...
[ "2\n1 1 2 2 3 3\n2 2 3 3 1 1", "100\n514485 388976 839005 669007 -35746 820627\n-22300 -496891 -440342 179934 -76598 -35916\n-11644 21883 16840 463 113936 -85680\n-603635 450048 -805597 -333898 -213708 -571090\n-138484 -880640 520676 -793813 -794299 641302\n-211207 300339 263771 -725539 -269273 -54088\n-798338 23...
[ "NO\nYES", "YES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nNO\nNO\nYES\nYES\nYES\nYES\nYES\nNO\nYES\nYES\nYES\nNO\nNO\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nNO\nNO\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nNO\nYES\nYES\nYES\nYES\nYES\nNO\nYES\nYES\nNO\nYES\nYES\nYES\nYES\nYES\nYES\nNO\nYES\nYES\nYES\nYES\nYES\nYES...
1
stdio
Polycarpus just has been out of luck lately! As soon as he found a job in the "Binary Cat" cafe, the club got burgled. All ice-cream was stolen. On the burglary night Polycarpus kept a careful record of all club visitors. Each time a visitor entered the club, Polycarpus put down character "+" in his notes. Similarly, ...
[ "+-+-+\n", "---\n", "-\n", "--\n", "---\n", "----\n", "---+\n", "--+-\n", "--++\n", "-+--\n" ]
[ "1\n", "3\n", "1\n", "2\n", "3\n", "4\n", "3\n", "2\n", "2\n", "2\n" ]
1
stdio
After a hard quarter in the office you decide to get some rest on a vacation. So you will book a flight for you and your girlfriend and try to leave all the mess behind you. You will need a rental car in order for you to get around in your vacation. The manager of the car rental makes you some good offers. Every day ...
[]
[]
1
stdio
To celebrate the opening of the Winter Computer School the organizers decided to buy in n liters of cola. However, an unexpected difficulty occurred in the shop: it turned out that cola is sold in bottles 0.5, 1 and 2 liters in volume. At that, there are exactly a bottles 0.5 in volume, b one-liter bottles and c of two...
[ "10 20 10 5\n", "20 1 2 3\n", "7 2 2 2\n", "25 10 5 10\n", "999 999 899 299\n", "10000 5000 0 5000\n", "2 2 2 2\n", "1 0 2 0\n", "3 3 2 1\n", "1 1 0 0\n" ]
[ "36\n", "0\n", "1\n", "12\n", "145000\n", "1251\n", "3\n", "1\n", "3\n", "0\n" ]
1
stdio
You are given a sequence of positive integers of length N, a = (a_1, a_2, ..., a_N). Your objective is to remove some of the elements in a so that a will be a good sequence. Here, an sequence b is a good sequence when the following condition holds true: - For each element x in b, the value x occurs exactly x times in ...
[ "4\n3 3 3 3\n", "5\n2 4 1 4 2\n", "6\n1 2 2 3 3 3\n", "1\n1000000000\n", "8\n2 7 1 8 2 8 1 8\n" ]
[ "1\n", "2\n", "0\n", "1\n", "5\n" ]
1
stdio
# One is the loneliest number ## Task The range of vision of a digit is its own value. `1` can see one digit to the left and one digit to the right,` 2` can see two digits, and so on. Thus, the loneliness of a digit `N` is the sum of the digits which it can see. Given a non-negative integer, your funtion must deter...
[]
[]
1
stdio
Extended Euclid Algorithm Given positive integers a and b, find the integer solution (x, y) to ax + by = gcd(a, b), where gcd(a, b) is the greatest common divisor of a and b. Constraints * 1 ≤ a, b ≤ 109 Input a b Two positive integers a and b are given separated by a space in a line. Output Print two inte...
[ "5 8", "5 15", "5 1", "5 2", "15 2", "55 2", "61 2", "47 2", "11 2", "6 8" ]
[ "-3 2\n", "1 0\n", "0 1\n", "1 -2\n", "1 -7\n", "1 -27\n", "1 -30\n", "1 -23\n", "1 -5\n", "-1 1\n" ]
1
stdio
Lucifer and Crowley being two most dangerous demons are fighting to become king of hell. A question is given to them. The one who solves it first becomes King. Given an array A of N elements and an integer M. Print YES if you find three distinct indexes i, j, k such that 1 ≤ i, j, k ≤ N and A[i]+A[j]+A[k] = M else prin...
[ "1000 10043313\n41 18467 6334 26500 19169 15724 11478 29358 26962 24464 5705 28145 23281 16827 9961 491 2995 11942 4827 5436 32391 14604 3902 153 292 12382 17421 18716 19718 19895 5447 21726 14771 11538 1869 19912 25667 26299 17035 9894 28703 23811 31322 30333 17673 4664 15141 7711 28253 6868 25547 27644 32662 3275...
[ "YES", "YES", "YES", "NO", "YES", "YES", "YES", "YES", "NO", "YES" ]
1
stdio
[Image] -----Input----- The first line of the input is a string (between 1 and 50 characters long, inclusive). Each character will be a letter of English alphabet, lowercase or uppercase. The second line of the input is an integer between 0 and 26, inclusive. -----Output----- Output the required string. -----...
[ "AprilFool\n14\n", "abcdefabc\n3\n", "fgWjSAlPOvcAbCdDEFjz\n7\n", "sm\n26\n", "GnlFOqPeZtPiBkvvLhaDvGPgFqBTnLgMT\n12\n", "sPWSFWWqZBPon\n3\n", "fQHHXCdeaintxHWcFcaSGWFvqnYMEByMlSNKumiFgnJB\n0\n", "RtsUOGkraqKyjTktAXloOEmQj\n18\n", "DuFhhnq\n4\n", "RvpuYTxsbDiJDOLauRlfatcfwvtnDzKyaewGrZ\n22\n" ]
[ "AprILFooL\n", "ABCdefABC\n", "FGwjsAlpovCABCDDEFjz\n", "SM\n", "GnLFoqpEztpIBKvvLHADvGpGFqBtnLGmt\n", "spwsfwwqzBpon\n", "fqhhxcdeaintxhwcfcasgwfvqnymebymlsnkumifgnjb\n", "RtsuOGKRAQKyJtKtAxLOOEMQJ\n", "Dufhhnq\n", "RVPUyTxSBDIJDOLAURLFATCFwVTNDzKyAEwGRz\n" ]
1
stdio
Let's call a set of positive integers a_1, a_2, ..., a_k quadratic if the product of the factorials of its elements is a square of an integer, i. e. ∏_{i=1}^{k} a_i! = m^2, for some integer m. You are given a positive integer n. Your task is to find a quadratic subset of a set 1, 2, ..., n of maximum size. If there a...
[ "8580\n", "11431\n", "29403\n", "867\n", "27\n", "7563\n", "13273\n", "11643\n", "1644\n", "5\n" ]
[ "8579\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 1...
1
stdio
Theofanis really likes sequences of positive integers, thus his teacher (Yeltsa Kcir) gave him a problem about a sequence that consists of only special numbers. Let's call a positive number special if it can be written as a sum of different non-negative powers of $n$. For example, for $n = 4$ number $17$ is special, b...
[ "3\n3 4\n2 12\n105 564\n", "3\n3 4\n2 6\n105 564\n", "3\n1 4\n2 6\n105 564\n", "3\n0 4\n2 6\n105 564\n", "3\n0 8\n0 6\n105 564\n", "3\n1 8\n0 6\n105 564\n", "3\n1 7\n0 6\n105 564\n", "3\n1 7\n0 6\n105 984\n", "3\n1 10\n0 6\n105 984\n", "3\n6 4\n2 12\n105 564\n" ]
[ "9\n12\n3595374\n", "9\n6\n3595374\n", "1\n6\n3595374\n", "0\n6\n3595374\n", "0\n0\n3595374\n", "1\n0\n3595374\n", "3\n0\n3595374\n", "3\n0\n713307087\n", "2\n0\n713307087\n", "36\n12\n3595374\n" ]
1
stdio
A breakthrough among computer games, "Civilization XIII", is striking in its scale and elaborate details. Let's take a closer look at one of them. The playing area in the game is split into congruent cells that are regular hexagons. The side of each cell is equal to 1. Each unit occupies exactly one cell of the playin...
[ "10264\n", "217\n", "7\n", "777777\n", "47248\n", "13\n", "301\n", "1034\n", "6\n", "6486\n" ]
[ "127364821\n", "56425\n", "43\n", "731487842995\n", "2699275123\n", "175\n", "108847\n", "1290385\n", "31\n", "50854039\n" ]
1
stdio
It's bonus time in the big city! The fatcats are rubbing their paws in anticipation... but who is going to make the most money? Build a function that takes in two arguments (salary, bonus). Salary will be an integer, and bonus a boolean. If bonus is true, the salary should be multiplied by 10. If bonus is false, the...
[]
[]
1
stdio
Given an array of numbers, return a string made up of four parts: a) a four character 'word', made up of the characters derived from the first two and last two numbers in the array. order should be as read left to right (first, second, second last, last), b) the same as above, post sorting the array into ascending or...
[]
[]
1
stdio
This is a follow up from my kata Insert Dashes. Write a function ```insertDashII(num)``` that will insert dashes ('-') between each two odd numbers and asterisk ('\*') between each even numbers in ```num``` For example: ```insertDashII(454793)``` --> 4547-9-3 ```insertDashII(1012356895)``` --> 10123-56*89-5 Zero...
[]
[]
1
stdio
One day Nikita found the string containing letters "a" and "b" only. Nikita thinks that string is beautiful if it can be cut into 3 strings (possibly empty) without changing the order of the letters, where the 1-st and the 3-rd one contain only letters "a" and the 2-nd contains only letters "b". Nikita wants to make...
[ "abba\n", "bab\n", "bbabbbaabbbb\n", "bbabbbbbaaba\n", "bbabbbababaa\n", "aabbaababbab\n", "a\n", "b\n", "ab\n", "ba\n" ]
[ "4", "2", "9", "10", "9", "8", "1", "1", "2", "2" ]
1
stdio
Ksusha is a beginner coder. Today she starts studying arrays. She has array a_1, a_2, ..., a_{n}, consisting of n positive integers. Her university teacher gave her a task. Find such number in the array, that all array elements are divisible by it. Help her and find the number! -----Input----- The first line contai...
[ "3\n2 2 4\n", "5\n2 1 3 1 6\n", "3\n2 3 5\n", "1\n331358794\n", "5\n506904227 214303304 136194869 838256937 183952885\n", "2\n500000000 1000000000\n", "2\n4 6\n", "5\n10 8 6 4 2\n", "2\n6 10\n", "1\n1000000000\n" ]
[ "2\n", "1\n", "-1\n", "331358794\n", "-1\n", "500000000\n", "-1\n", "2\n", "-1\n", "1000000000\n" ]
1
stdio
In this Kata your task will be to return the count of pairs that have consecutive numbers as follows: ```Haskell pairs([1,2,5,8,-4,-3,7,6,5]) = 3 The pairs are selected as follows [(1,2),(5,8),(-4,-3),(7,6),5] --the first pair is (1,2) and the numbers in the pair are consecutive; Count = 1 --the second pair is (5,8) an...
[]
[]
1
stdio
A positive integer number n is written on a blackboard. It consists of not more than 105 digits. You have to transform it into a beautiful number by erasing some of the digits, and you want to erase as few digits as possible. The number is called beautiful if it consists of at least one digit, doesn't have leading zer...
[ "100020001\n", "100000000000000000222\n", "8008\n", "10000555\n", "20020201\n", "7\n", "10001\n", "2000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002\n", "8059\n", "100000001\n" ]
[ "10002000\n", "1000000000000000002\n", "0\n", "100005\n", "2002020\n", "-1\n", "0\n", "0\n", "9\n", "0\n" ]
1
stdio