info
stringlengths
120
50k
question
stringlengths
504
10.4k
avg@8_qwen3_4b_instruct_2507
float64
0
0.88
{"tests": "{\"inputs\": [[\"dog\", \"car\"], [\"dog\", \"god\"], [\"dog\", \"cog\"], [\"dog\", \"cod\"], [\"dog\", \"bog\"], [\"dog\", \"dog\"], [\"abcde\", \"abcde\"], [\"same\", \"same\"], [\"z\", \"z\"]], \"outputs\": [[0], [1], [2], [1], [2], [3], [5], [4], [1]]}", "source": "primeintellect"}
Consider a game, wherein the player has to guess a target word. All the player knows is the length of the target word. To help them in their goal, the game will accept guesses, and return the number of letters that are in the correct position. Write a method that, given the correct word and the player's guess, return...
0
{"tests": "{\"inputs\": [\"1 1 4\\n\", \"4 972 4\\n\", \"1 512 9\\n\", \"1 961 2\\n\", \"0 3 6\\n\", \"-3 -768 8\\n\", \"1 625 4\\n\", \"4 972 1\\n\", \"1 1000 1\\n\", \"3 0 4\\n\", \"7 175 1\\n\", \"-4 0 1\\n\", \"-5 3 4\\n\", \"10 0 6\\n\", \"-5 -5 6\\n\", \"1 1000 3\\n\", \"-1 0 4\\n\", \"-373 373 3\\n\", \"-5 -5 9\...
A long time ago in some far country lived king Copa. After the recent king's reform, he got so large powers that started to keep the books by himself. The total income A of his kingdom during 0-th year is known, as well as the total income B during n-th year (these numbers can be negative — it means that there was a l...
0.625
{"tests": "{\"inputs\": [[[78, 56, 232, 12, 11, 43]], [[78, 56, -2, 12, 8, -33]], [[0, -18446744073709551615, 18446744073709551616]], [[-133, -5666, -89, -12341, -321423, 18446744073709551616]], [[0, 18446744073709551616, -18446744073709551617, 18446744073709551616, 18446744073709551616]], [[1, 2, 3, 4, 5, 6, 7, 8, 9, ...
Given an array of integers your solution should find the smallest integer. For example: - Given `[34, 15, 88, 2]` your solution will return `2` - Given `[34, -345, -1, 100]` your solution will return `-345` You can assume, for the purpose of this kata, that the supplied array will not be empty. Write your solution...
0
{"tests": "{\"inputs\": [\"10 1 200\\nolahgjusovchbowjxtwzvjakrktyjqcgkqmcxknjchzxcvbnkbakwnxdouebomyhjsrfsicmzsgdweabbuipbzrhuqfpynybaohzquqbbsqpoaskccszzsmnfleevtasmjuwqgcqtvysohvyutqipnvuhjumwwyytkeuebbncxsnpavwdkoxyycqrhcidf\\n\", \"15 2 5\\nkddainaviqrjsesrhhdnbuisennbgcxseeyxqtmautpoobtpfigcpgagcixmyzsntmgzwmiczs...
Anfisa the monkey learns to type. She is yet unfamiliar with the "space" key and can only type in lower-case Latin letters. Having typed for a fairly long line, Anfisa understood that it would be great to divide what she has written into k lines not shorter than a and not longer than b, for the text to resemble human s...
0
{"tests": "{\"inputs\": [[[]], [[\"hello\"]], [[\"hello\", \"world\"]], [[\"hello\", \"amazing\", \"world\"]], [[\"this\", \"is\", \"a\", \"really\", \"long\", \"sentence\"]]], \"outputs\": [[\"\"], [\"hello\"], [\"hello world\"], [\"hello amazing world\"], [\"this is a really long sentence\"]]}", "source": "primeintel...
# Sentence Smash Write a function that takes an array of words and smashes them together into a sentence and returns the sentence. You can ignore any need to sanitize words or add punctuation, but you should add spaces between each word. **Be careful, there shouldn't be a space at the beginning or the end of the sente...
0
{"tests": "{\"inputs\": [[\"\"], [\"WAlly\"], [\"wAlly\"], [\"DWally\"], [\".Wally\"], [\"Wallyd\"], [\"wally mollyWally Wallybrolly 'Wally\"], [\"Walley ,Wally -Wally ;Wally +Wally :Wally\"], [\"Walley Wally, Wally- Wally: Wally+ Wally:\"], [\"12Wally Wally01 W.ally\"], [\"Where's Waldo\"], [\"Wally\"], [\"Wally Wally...
Write a function that returns the index of the first occurence of the word "Wally". "Wally" must not be part of another word, but it can be directly followed by a punctuation mark. If no such "Wally" exists, return -1. Examples: "Wally" => 0 "Where's Wally" => 8 "Where's Waldo" => -1 "DWally Wallyd .Wally" => -...
0
{"tests": "{\"inputs\": [\"13 18 27 13\\n1 1\\n1 2\\n1 3\\n1 4\\n1 17\\n2 5\\n2 1\\n3 6\\n3 2\\n5 14\\n5 3\\n4 4\\n6 9\\n6 3\\n7 8\\n7 3\\n8 7\\n8 9\\n10 11\\n10 18\\n11 10\\n11 15\\n11 11\\n9 12\\n9 11\\n12 10\\n13 15\\n6 8\\n6 14\\n6 1\\n6 17\\n6 18\\n11 12\\n11 18\\n11 9\\n11 17\\n1 18\\n1 12\\n1 7\\n1 14\\n\", \"2 ...
Sagheer is working at a kindergarten. There are n children and m different toys. These children use well-defined protocols for playing with the toys: * Each child has a lovely set of toys that he loves to play with. He requests the toys one after another at distinct moments of time. A child starts playing if and onl...
0
{"tests": "{\"inputs\": [[\"When I miss few days of gym\"], [\"Squad probably think I am fake\"], [\"Whole squad probably bigger than me now\"], [\"No selfie to post on Instagram either\"], [\"Gym crush probably found someone else\"], [\"What if I die fat\"], [\"What if I do not fit in my clothes now\"], [\"Going to fe...
# RegExp Fun #1 - When I miss few days of gym ## Disclaimer The background story of this Kata is 100% fiction. Any resemblance to real people or real events is **nothing more than a coincidence** and should be regarded as such. ## Background Story You are a person who loves to go to the gym everyday with the squad...
0
{"tests": "{\"inputs\": [\"2\\n1 2\\n3 4\\n\", \"3\\n10 10 10\\n10 0 10\\n10 10 10\\n\", \"3\\n1000000000 1000000000 1000000000\\n1000000000 1000000000 1000000000\\n1000000000 1000000000 1000000000\\n\", \"3\\n0 0 1000000000\\n0 1000000000 0\\n1000000000 0 0\\n\", \"3\\n1000000000 1000000000 1\\n1000000000 1 1000000000...
You are given a square grid with $n$ rows and $n$ columns, where each cell has a non-negative integer written in it. There is a chip initially placed at the top left cell (the cell with coordinates $(1, 1)$). You need to move the chip to the bottom right cell (the cell with coordinates $(n, n)$). In one step, you can ...
0
{"tests": "{\"inputs\": [\"3\\n0 ( 10\\n10 ) 5\\n10 ( 5\", \"3\\n-1 ( 10\\n10 ) 5\\n10 ) 5\", \"3\\n-1 ( 9\\n10 ) 9\\n20 ( 4\", \"3\\n-1 ) 0\\n8 ( 19\\n4 ' 2\", \"3\\n-2 ) 0\\n7 ) 0\\n4 ( 11\", \"3\\n-1 ( 0\\n10 ) 4\\n20 ( 4\", \"3\\n0 ) 0\\n7 * 0\\n1 ( 0\", \"3\\n0 ) 10\\n10 ( 5\\n10 ( 7\", \"3\\n-1 ( 10\\n10 ) 5\\n10...
International Carpenters Professionals Company (ICPC) is a top construction company with a lot of expert carpenters. What makes ICPC a top company is their original language. The syntax of the language is simply given in CFG as follows: S -> SS | (S) | )S( | ε In other words, a right parenthesis can be closed by a...
0.75
{"tests": "{\"inputs\": [\"5\\n7 12\\n1 2 3 4 9 10 11\\nR R L L R R R\\n2 10\\n1 6\\nR R\\n2 10\\n1 3\\nL L\\n1 10\\n5\\nR\\n7 8\\n6 1 7 2 3 5 4\\nR L R L L L L\\n\", \"1\\n10 20\\n2 3 7 9 10 13 14 16 17 18\\nL L R L L R R R L L\\n\", \"1\\n20 50\\n4 6 8 9 10 13 14 16 18 20 23 25 30 32 33 38 42 43 45 46\\nL L L L L L L...
There are $n$ robots driving along an OX axis. There are also two walls: one is at coordinate $0$ and one is at coordinate $m$. The $i$-th robot starts at an integer coordinate $x_i~(0 < x_i < m)$ and moves either left (towards the $0$) or right with the speed of $1$ unit per second. No two robots start at the same co...
0
{"tests": "{\"inputs\": [[0], [-6], [8], [32], [75], [63], [134], [180], [970], [565757]], \"outputs\": [[\"00:00\"], [\"00:00\"], [\"00:08\"], [\"00:32\"], [\"01:15\"], [\"01:03\"], [\"02:14\"], [\"03:00\"], [\"16:10\"], [\"9429:17\"]]}", "source": "primeintellect"}
This kata requires you to convert minutes (`int`) to hours and minutes in the format `hh:mm` (`string`). If the input is `0` or negative value, then you should return `"00:00"` **Hint:** use the modulo operation to solve this challenge. The modulo operation simply returns the remainder after a division. For example t...
0
{"tests": "{\"inputs\": [\"4\\n8 4 7\\n1 2\\n2 3\\n1 4\\n4 5\\n4 6\\n1 7\\n7 8\\n4 3 2\\n4 3\\n1 2\\n2 3\\n9 3 5\\n1 2\\n2 3\\n3 4\\n1 5\\n5 6\\n6 7\\n1 8\\n8 9\\n16 15 12\\n1 2\\n2 3\\n1 4\\n4 5\\n5 6\\n6 7\\n4 8\\n8 9\\n8 10\\n10 11\\n11 12\\n11 13\\n13 14\\n10 15\\n15 16\\n\", \"4\\n8 4 7\\n1 2\\n2 3\\n1 4\\n4 5\\n4...
There is an undirected tree of $n$ vertices, connected by $n-1$ bidirectional edges. There is also a snake stuck inside of this tree. Its head is at vertex $a$ and its tail is at vertex $b$. The snake's body occupies all vertices on the unique simple path between $a$ and $b$. The snake wants to know if it can reverse ...
0
{"tests": "{\"inputs\": [\"4\\n-100000 -100000\\n-99999 -99999\\n100000 99999\\n0 -100\\n\", \"4\\n0 0\\n1 100\\n100 0\\n1 -100\\n\", \"4\\n-1000000000 1000000000\\n1000000000 500000000\\n1000000000 -1000000000\\n-500000000 -1000000000\\n\", \"4\\n-10000 -10000\\n-9999 -9999\\n10000 9999\\n0 -1000\\n\", \"4\\n-10000000...
You are given a convex polygon P with n distinct vertices p1, p2, ..., pn. Vertex pi has coordinates (xi, yi) in the 2D plane. These vertices are listed in clockwise order. You can choose a real number D and move each vertex of the polygon a distance of at most D from their original positions. Find the maximum value ...
0.25
{"tests": "{\"inputs\": [\"10 5 1000000000\\n1 1 1 2 2 1 2 2 2 2\\n\", \"5 3 3\\n1 2 2 1 1\\n\", \"2 4 1\\n1 1\\n\", \"1 1000000000 1000000000\\n100000\\n\", \"5 3 2\\n1 1 2 1 1\\n\", \"5 2 4\\n1 2 3 2 1\\n\", \"1 10 10\\n1\\n\", \"2 4 1\\n1 0\\n\", \"5 3 2\\n1 1 3 1 1\\n\", \"1 7 10\\n1\\n\", \"4 2 5\\n1 2 4 1\\n\", \...
This time the Berland Team Olympiad in Informatics is held in a remote city that can only be reached by one small bus. Bus has n passenger seats, seat i can be occupied only by a participant from the city ai. Today the bus has completed m trips, each time bringing n participants. The participants were then aligned in ...
0
{"tests": "{\"inputs\": [[[1, 2, 3, 4, 5, 6, 7, 8], 3], [[\"a\", \"b\", \"c\"], \"d\"], [[\"a\", \"b\", \"c\"], \"c\"], [\"testing\", \"t\"], [\"Hello!\", \"o\"], [\"Hello!\", \"!\"], [\"Hello!\", \"x\"]], \"outputs\": [[4], [null], [null], [\"e\"], [\"!\"], [null], [null]]}", "source": "primeintellect"}
Given a sequence of items and a specific item in that sequence, return the item immediately following the item specified. If the item occurs more than once in a sequence, return the item after the first occurence. This should work for a sequence of any type. When the item isn't present or nothing follows it, the funct...
0
{"tests": "{\"inputs\": [\"1 6 3\", \"1000 100 000\", \"2 1 -1\", \"1 6 5\", \"1010 100 000\", \"3 1 0\", \"2 6 5\", \"1010 000 000\", \"6 1 0\", \"2 0 5\", \"1010 010 000\", \"1 1 0\", \"2 0 10\", \"1110 010 000\", \"2 0 -1\", \"2 0 20\", \"1110 011 000\", \"2 1 20\", \"1110 001 000\", \"3 1 20\", \"1110 101 000\", \"...
There are N balls and N+1 holes in a line. Balls are numbered 1 through N from left to right. Holes are numbered 1 through N+1 from left to right. The i-th ball is located between the i-th hole and (i+1)-th hole. We denote the distance between neighboring items (one ball and one hole) from left to right as d_i (1 \leq ...
0
{"tests": "{\"inputs\": [[3, 2], [19, 2], [10, 2], [34, 7], [27, 5]], \"outputs\": [[1], [1], [0], [6], [2]]}", "source": "primeintellect"}
## Task Write a method `remainder` which takes two integer arguments, `dividend` and `divisor`, and returns the remainder when dividend is divided by divisor. Do NOT use the modulus operator (%) to calculate the remainder! #### Assumption Dividend will always be `greater than or equal to` divisor. #### Notes Make ...
0
{"tests": "{\"inputs\": [[\"EBG13 rknzcyr.\"], [\"How can you tell an extrovert from an\\nintrovert at NSA? Va gur ryringbef,\\ngur rkgebireg ybbxf ng gur BGURE thl'f fubrf.\"], [\"123\"], [\"Guvf vf npghnyyl gur svefg xngn V rire znqr. Gunaxf sbe svavfuvat vg! :)\"], [\"@[`{\"]], \"outputs\": [[\"ROT13 example.\"], [\...
How can you tell an extrovert from an introvert at NSA? Va gur ryringbef, gur rkgebireg ybbxf ng gur BGURE thl'f fubrf. I found this joke on USENET, but the punchline is scrambled. Maybe you can decipher it? According to Wikipedia, ROT13 (http://en.wikipedia.org/wiki/ROT13) is frequently used to obfuscate jokes on USE...
0
{"tests": "{\"inputs\": [\"1\\n1\\n2 1\\n\", \"22\\n488943077 290998271 852584973 786860017 964602359 374433568 813129205 475010862 41067202 967591690 240784159 919167142 791355038 494235116 152467900 187619570 933100341 42564459 304249492 605073760 894993417 917201696\\n681131419 406058366\\n\", \"1\\n693639663\\n5522...
Lunar New Year is approaching, and Bob received a gift from his friend recently — a recursive sequence! He loves this sequence very much and wants to play with it. Let f_1, f_2, …, f_i, … be an infinite sequence of positive integers. Bob knows that for i > k, f_i can be obtained by the following recursive equation: $...
0
{"tests": "{\"inputs\": [[\"n!!ice!!123\"], [\"de?=?=tttes!!t\"], [\"\"], [\"!@#$%^&`~.\"], [\"u_n_d_e_r__S_C_O_R_E\"]], \"outputs\": [[7], [8], [0], [0], [10]]}", "source": "primeintellect"}
Bob is a lazy man. He needs you to create a method that can determine how many ```letters``` and ```digits``` are in a given string. Example: "hel2!lo" --> 6 "wicked .. !" --> 6 "!?..A" --> 1 Write your solution by modifying this code: ```python def count_letters_and_digits(s): ``` Your solution should imp...
0
{"tests": "{\"inputs\": [\"5\\n10101011011\\n0000\\n11111\\n110\\n1100\\n\", \"1\\n0000011111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111100\\n\", \"9\\n11\\n11\\n11\\n11\\n11\\n11\\n11\\n11\\n11\\n\", \"9\\n11\\n11\\n11\\n11\\n11\\n11\\n11\\n11\\n11\\n\", \"1\\n00000111111111...
You are given a string $s$, consisting only of characters '0' or '1'. Let $|s|$ be the length of $s$. You are asked to choose some integer $k$ ($k > 0$) and find a sequence $a$ of length $k$ such that: $1 \le a_1 < a_2 < \dots < a_k \le |s|$; $a_{i-1} + 1 < a_i$ for all $i$ from $2$ to $k$. The characters at positi...
0
{"tests": "{\"inputs\": [\"a+b+c\\n(a+b)+c\\na- (b-c)+2\\n.\\n4ab\\n(a - b) (0-b+a) - 1a ^ 2 - b ^ 2\\n2 b 2 a\\n.\\n169 a\\n2 2 3 3 3 a\\n4 a^1 27\\n.\\n.\", \"a+b+c\\n(a+b)+c\\na- (b-c)+2\\n.\\n4ab\\n(a - b) (0-b+a) - 1a ^ 2 - b ^ 3\\n2 b 2 a\\n.\\n108 a\\n2 2 3 3 3 a\\n4 a^1 27\\n.\\n.\", \"a+b+c\\n(a+b)+c\\na- (b-c...
Mr. Simpson got up with a slight feeling of tiredness. It was the start of another day of hard work. A bunch of papers were waiting for his inspection on his desk in his office. The papers contained his students' answers to questions in his Math class, but the answers looked as if they were just stains of ink. His hea...
0
{"tests": "{\"inputs\": [\"34 53\\n9 6\\n25 28\\n27 24\\n15 18\\n34 33\\n27 30\\n1 4\\n4 7\\n11 9\\n11 8\\n30 26\\n15 12\\n26 23\\n17 15\\n29 26\\n11 15\\n7 10\\n14 12\\n5 9\\n8 5\\n2 1\\n24 21\\n3 5\\n14 17\\n23 20\\n25 22\\n32 29\\n8 6\\n3 6\\n33 31\\n5 2\\n21 18\\n16 19\\n19 22\\n17 21\\n14 11\\n23 27\\n3 1\\n34 32\...
The Berland road network consists of n cities and of m bidirectional roads. The cities are numbered from 1 to n, where the main capital city has number n, and the culture capital — number 1. The road network is set up so that it is possible to reach any city from any other one by the roads. Moving on each road in any d...
0
{"tests": "{\"inputs\": [\"2 2\", \"1 3\", \"0 6\", \"1 10\", \"1 1\", \"0 9\", \"2 5\", \"0 4\", \"-1 11\", \"-1 0\", \"-1 8\", \"-1 7\", \"-1 12\", \"-2 -1\", \"-4 -2\", \"-8 -3\", \"-11 -4\", \"-13 -5\", \"-8 -6\", \"-23 -12\", \"-9 -7\", \"-26 -9\", \"-74 -8\", \"2 3\", \"0 3\", \"1 6\", \"0 10\", \"-1 3\", \"0 2\"...
problem Given the lengths of $ 2 $ sides that are not the hypotenuse of a right triangle, $ A $ and $ B $. The side of length $ A $ overlaps the $ x $ axis, and the side of length $ B $ overlaps the $ y $ axis. Do the following: 1. Rotate the triangle around the $ x $ axis. 2. Rotate the shape created by performing ...
0
{"tests": "{\"inputs\": [[[[\"08:14\", \"11:34\"], [\"08:16\", \"08:18\"], [\"13:48\", \"01:14\"], [\"09:30\", \"10:32\"], [\"04:23\", \"05:11\"], [\"11:48\", \"13:48\"], [\"01:12\", \"01:14\"], [\"01:13\", \"08:15\"]]], [[[\"00:00\", \"00:05\"], [\"16:37\", \"18:19\"], [\"12:07\", \"12:12\"], [\"00:30\", \"02:49\"], [...
###Instructions A time period starting from ```'hh:mm'``` lasting until ```'hh:mm'``` is stored in an array: ``` ['08:14', '11:34'] ``` A set of different time periods is then stored in a 2D Array like so, each in its own sub-array: ``` [['08:14','11:34'], ['08:16','08:18'], ['22:18','01:14'], ['09:30','10:32'], ['04:...
0
{"tests": "{\"inputs\": [[\"Jędrzej Błądziński\"], [\"Lech Wałęsa\"], [\"Maria Skłodowska-Curie\"], [\"Władysław Reymont\"], [\"Mikołaj Kopernik\"], [\"Józef Piłsudski\"], [\"Czesław Miłosz\"], [\"Agnieszka Radwańska\"], [\"Wojciech Szczęsny\"], [\"Zażółć gęślą jaźń\"], [\"Wół go pyta: 'Panie chrząszczu,Po co pan tak b...
There are 32 letters in the Polish alphabet: 9 vowels and 23 consonants. Your task is to change the letters with diacritics: ``` ą -> a, ć -> c, ę -> e, ł -> l, ń -> n, ó -> o, ś -> s, ź -> z, ż -> z ``` and print out the string without the use of the Polish letters. For example: ``` "Jędrzej Błądziński" --> "J...
0
{"tests": "{\"inputs\": [[12, 50, 1000], [17, 10, 500], [24, 35, 3000], [1400, 35, 10000], [700, 26, 7000]], \"outputs\": [[166], [294], [357], [20], [38]]}", "source": "primeintellect"}
The purpose of this kata is to work out just how many bottles of duty free whiskey you would have to buy such that the saving over the normal high street price would effectively cover the cost of your holiday. You will be given the high street price (normPrice), the duty free discount (discount) and the cost of the h...
0
{"tests": "{\"inputs\": [\"81 10683\\n3 52 265 294 213 242 185 151 27 165 128 237 124 14 43 147 104 162 124 103 233 156 288 57 289 195 129 77 97 138 153 289 203 126 34 5 97 35 224 120 200 203 222 94 171 294 293 108 145 193 227 206 34 295 1 233 258 7 246 34 60 232 58 169 77 150 272 279 171 228 168 84 114 229 149 97 66 2...
You are given an array of positive integers a1, a2, ..., an × T of length n × T. We know that for any i > n it is true that ai = ai - n. Find the length of the longest non-decreasing sequence of the given array. Input The first line contains two space-separated integers: n, T (1 ≤ n ≤ 100, 1 ≤ T ≤ 107). The second li...
0
{"tests": "{\"inputs\": [\"4\\n6 4 2\\n2 9 2 3 8 7\\n4 4 1\\n2 13 60 4\\n4 1 3\\n1 2 2 1\\n2 2 0\\n1 2\\n\", \"4\\n6 4 2\\n2 9 2 3 8 7\\n4 4 1\\n2 13 60 4\\n4 1 3\\n1 2 2 1\\n2 2 1\\n1 2\\n\", \"4\\n6 4 2\\n2 9 2 5 8 4\\n4 4 1\\n2 13 60 4\\n4 2 3\\n1 2 2 1\\n2 2 1\\n1 2\\n\", \"4\\n6 4 2\\n2 9 2 5 8 4\\n4 4 1\\n2 13 60...
You and your n - 1 friends have found an array of integers a_1, a_2, ..., a_n. You have decided to share it in the following way: All n of you stand in a line in a particular order. Each minute, the person at the front of the line chooses either the first or the last element of the array, removes it, and keeps it for h...
0
{"tests": "{\"inputs\": [\"3\\n\", \"4\\n\", \"100\\n\", \"1337\\n\", \"1000\\n\", \"500\\n\", \"42\\n\", \"13\\n\", \"69\\n\", \"5000\\n\", \"3000\\n\", \"4500\\n\"], \"outputs\": [\"6\\n\", \"50\\n\", \"878752271\\n\", \"520628749\\n\", \"756980810\\n\", \"39656147\\n\", \"934067958\\n\", \"456092424\\n\", \"24248178...
The only difference between the easy and the hard version is the constraint on $n$. You are given an undirected complete graph on $n$ vertices. A complete graph is a graph where each pair of vertices is connected by an edge. You have to paint the edges of the graph into two colors, red and blue (each edge will have on...
0
{"tests": "{\"inputs\": [\"8\\natuongih\\n\", \"5\\nholfz\", \"100\\ngkdydttzjmwafeftbyuiancgugsrxynxsystmcxjxftaaiwryselgychxufdplwvvcasvtjzfnelbegxjdujbcfcblyhwbporyst\", \"1400\\nhkyecfkhkymiltabvburwjamqlwnokfhdllppmgednjpnrpkdpwbeayqcyemjmmnarbohcaeqqeodmvwxhnnnrdxbgpgrkirtomkpwajdqqonqiguycpuhmrhfqwwnwnuowoenofvj...
In the world of Latin Alphabets, there seemed to be a catastrophe! All the vowels went missing. The other alphabets got disturbed and began the search operation. While searching they stumbled upon a garbage of letters. Can you help them find if the this garbage contains ALL the vowels ? Input: FIrst line contains N ...
0
{"tests": "{\"inputs\": [[10000, 7], [5000, 7], [10000, 4], [8000, 4], [5000, 3], [10000, 3]], \"outputs\": [[1], [0], [2], [1], [1], [2]]}", "source": "primeintellect"}
The number `1035` is the smallest integer that exhibits a non frequent property: one its multiples, `3105 = 1035 * 3`, has its same digits but in different order, in other words, `3105`, is one of the permutations of `1035`. The number `125874` is the first integer that has this property when the multiplier is `2`, th...
0
{"tests": "{\"inputs\": [\"4\\n4 18\\n2 1 9 2\\n3 2 4 1\\n4 1 2 2\\n3 20\\n2 1 8 1\\n3 1 7 2\\n5 50\\n1 3 100 1\\n1 5 10 2\\n2 3 123 2\\n5 4 55 1\\n2 100\\n1 2 409 2\\n\", \"4\\n4 18\\n2 1 9 2\\n3 2 4 1\\n4 1 2 2\\n3 20\\n2 1 8 1\\n3 1 7 2\\n5 50\\n1 3 100 1\\n1 5 10 2\\n2 3 123 2\\n5 4 55 1\\n2 100\\n1 2 409 1\\n\", \...
Easy and hard versions are actually different problems, so we advise you to read both statements carefully. You are given a weighted rooted tree, vertex 1 is the root of this tree. Also, each edge has its own cost. A tree is a connected graph without cycles. A rooted tree has a special vertex called the root. A paren...
0
{"tests": "{\"inputs\": [\"3 4 3\\n1 0 1 1\\n0 1 0 0\\n1 0 1 1\\n0 0 0\", \"3 4 6\\n1 0 1 1\\n0 1 0 0\\n1 0 1 1\\n0 0 0\", \"3 4 8\\n1 0 1 1\\n0 1 0 0\\n1 0 1 1\\n0 0 0\", \"3 4 8\\n1 0 1 1\\n0 0 0 0\\n1 0 1 1\\n0 0 0\", \"3 4 4\\n1 0 1 1\\n0 1 0 0\\n1 0 1 1\\n0 0 0\", \"3 4 9\\n1 0 1 1\\n0 1 0 0\\n1 0 1 1\\n0 0 0\", \...
problem One day, Taro, who lives in JOI town, decided to take a walk as a daily routine to improve his health. In JOI town, where Taro lives, he runs in the east-west direction as shown in the figure (H + 1). The road and the north-south direction (W + 1) run through the road in a grid pattern. Taro's house is at the ...
0
{"tests": "{\"inputs\": [\"5\\n00001\\n4\", \"5\\n00000\\n3\", \"5\\n00001\\n1\", \"5\\n10001\\n1\", \"5\\n10001\\n2\", \"5\\n10001\\n4\", \"5\\n10000\\n1\", \"5\\n00010\\n1\", \"5\\n00001\\n0\", \"5\\n00010\\n0\", \"5\\n01100\\n0\", \"5\\n00011\\n0\", \"5\\n00011\\n2\", \"5\\n11101\\n3\", \"5\\n01000\\n0\", \"5\\n0000...
Problem statement There is an unsigned $ 2 $ decimal integer $ X $ with $ N $ in digits including Leading-zeros. Output the largest non-negative integer that can be expressed in $ 2 $ base in $ N $ digits where the Hamming distance from $ X $ is $ D $. The Hamming distance between integers expressed in $ 2 $ is the n...
0.75
{"tests": "{\"inputs\": [\"5\\n7\\n4\\n11\\n1\\n15\", \"5\\n7\\n4\\n11\\n1\\n28\", \"5\\n7\\n7\\n11\\n1\\n15\", \"5\\n7\\n6\\n11\\n1\\n28\", \"5\\n9\\n11\\n11\\n2\\n15\", \"5\\n11\\n4\\n11\\n1\\n15\", \"5\\n7\\n4\\n17\\n1\\n28\", \"5\\n7\\n6\\n11\\n1\\n23\", \"5\\n7\\n22\\n11\\n1\\n15\", \"5\\n3\\n3\\n11\\n1\\n28\", \"...
Every great chef knows that lucky numbers are positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Our chef has recently returned from the Lucky country. He observed that every restaurant in the Lucky country had a l...
0
{"tests": "{\"inputs\": [\"wtwwttwttwwwwwwwwtwtwwwwwtwwtwwtwwwwwtwtwtwtwwtwwwtwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwtwwwwwwwwwwwtwwwwwtwttwwwwtwwwwwwwwwwwwwwwwwtwwwwtwwwwwwwwwwwwwttwtwwwwwtwwtwwwwwwwtwwttttwwwwwwwwwwwwwwwwwwwtwwwttwtwwtwwtwwtwwwwtwwtwtwwtwwwwwwwwwwtwwww\\n\", \"rrrvjurvrrsukrsrvxskrrrrbrapyrmrmvprmrseuak...
You are given a string s, consisting of small Latin letters. Let's denote the length of the string as |s|. The characters in the string are numbered starting from 1. Your task is to find out if it is possible to rearrange characters in string s so that for any prime number p ≤ |s| and for any integer i ranging from 1...
0
{"tests": "{\"inputs\": [\"2\\n101\\n010\\n1111\\n1010\\n\", \"2\\n101\\n011\\n1111\\n1010\", \"2\\n001\\n111\\n1111\\n1010\", \"2\\n111\\n110\\n1111\\n1010\", \"2\\n110\\n110\\n1111\\n1010\", \"2\\n110\\n110\\n1011\\n1010\", \"2\\n010\\n110\\n0011\\n1010\", \"2\\n000\\n110\\n0011\\n1010\", \"2\\n001\\n110\\n0011\\n101...
Today is Chef's birthday. His mom decided to surprise him with a truly fantastic gift: his favourite binary string B. But, unfortunately, all the stocks of binary string B have been sold out, and only a binary string A (A ≠ B) is available in the market. She purchases the string A and tries to convert it to string B by...
0
{"tests": "{\"inputs\": [\"5 2\\nbacba\", \"10 2\\nbbbabbbaaa\", \"10 3\\nbbaabbbaab\", \"5 2\\nbacaa\", \"10 2\\nbaabbbaabb\", \"10 2\\nbaabbaaabb\", \"10 2\\nbbaaabbbab\", \"5 1\\nbabba\", \"10 2\\nbabbbbaabb\", \"10 1\\nbaabbaaabb\", \"5 1\\nbabbb\", \"10 2\\nbbaabbbbab\", \"10 1\\nbbaaabbaab\", \"8 5\\nbbaaabbbab\"...
Takahashi has a string S of length N consisting of lowercase English letters. On this string, he will perform the following operation K times: * Let T be the string obtained by reversing S, and U be the string obtained by concatenating S and T in this order. * Let S' be some contiguous substring of U with length N, an...
0
{"tests": "{\"inputs\": [\"7\\n2 1\\n2 2\\n3 1\\n3 2\\n3 3\\n5 5\\n69 1337\\n\", \"1\\n999199999 999999999\\n\", \"1\\n999199999 999999999\\n\", \"1\\n730170941 999999999\\n\", \"7\\n2 1\\n2 2\\n3 1\\n3 2\\n3 3\\n5 5\\n69 1154\\n\", \"1\\n645073426 999999999\\n\", \"7\\n2 1\\n2 2\\n3 1\\n3 2\\n5 3\\n5 5\\n69 1154\\n\",...
Suppose you are living with two cats: A and B. There are $n$ napping spots where both cats usually sleep. Your cats like to sleep and also like all these spots, so they change napping spot each hour cyclically: Cat A changes its napping place in order: $n, n - 1, n - 2, \dots, 3, 2, 1, n, n - 1, \dots$ In other words...
0
{"tests": "{\"inputs\": [\"5 5 5\\nuuuuuyyyyybbbbbqqqqqkkkkk\\n\", \"10 9 2\\nskpjgpwrqajrdnynybnsmybttmhkboiqlndqtghvqyorholdzwasytnvteawhahjfhjknhfobiifrtfrlbjkqyxgnc\\n\", \"10 1 3\\navdtkzddkk\\n\", \"3 2 2\\nabcdef\\n\", \"1 10 1\\nlduuukmwxx\\n\", \"9 1 9\\neeeeeeeee\\n\", \"9 10 5\\nafdfhplzplgrnrgzpzplbdhnulrxp...
Lucy likes letters. She studied the definition of the lexicographical order at school and plays with it. At first, she tried to construct the lexicographically smallest word out of given letters. It was so easy! Then she tried to build multiple words and minimize one of them. This was much harder! Formally, Lucy want...
0
{"tests": "{\"inputs\": [\"6\\n7\\nabacaba\\n7\\n???????\\n11\\naba?abacaba\\n11\\nabacaba?aba\\n15\\nasdf???f???qwer\\n11\\nabacabacaba\\n\", \"1\\n13\\nabacab?bacaba\\n\", \"1\\n13\\nabacab?bacab`\\n\", \"6\\n7\\nabacaba\\n7\\n???????\\n11\\naba?abacaba\\n11\\nabacaba>aba\\n15\\nasdf???f???qwer\\n11\\nabacabacaba\\n\...
Acacius is studying strings theory. Today he came with the following problem. You are given a string $s$ of length $n$ consisting of lowercase English letters and question marks. It is possible to replace question marks with lowercase English letters in such a way that a string "abacaba" occurs as a substring in a res...
0
{"tests": "{\"inputs\": [\"3\\n2 1 3 4\\n7 6\\n1 1 2 3\\n1\\n1 1 2 2\\n3\\n\", \"10\\n6 5 4 5\\n2 3 2 3 1 3\\n1 5 2 3\\n10\\n4 4 2 3\\n8 10 8 5\\n2 2 1 4\\n8 5\\n3 5 3 5\\n9 2 10\\n4 5 5 5\\n2 10 4 2\\n2 3 1 4\\n1 10\\n3 1 5 3\\n9 8 7\\n2 5 4 5\\n8 8\\n3 5 1 4\\n5 5 10\\n\", \"10\\n2 2 3 5\\n4 5\\n2 1 1 1\\n1 2\\n7 1 2...
The Red Kingdom is attacked by the White King and the Black King! The Kingdom is guarded by $n$ castles, the $i$-th castle is defended by $a_i$ soldiers. To conquer the Red Kingdom, the Kings have to eliminate all the defenders. Each day the White King launches an attack on one of the castles. Then, at night, the fo...
0
{"tests": "{\"inputs\": [\"3\\n2 2 1\\n3 3 2\\n1 5 12\", \"3\\n2 2 1\\n3 1 2\\n1 5 12\", \"3\\n2 2 2\\n3 2 2\\n1 5 12\", \"3\\n2 2 2\\n4 2 2\\n1 5 2\", \"3\\n2 7 2\\n4 2 2\\n1 9 0\", \"3\\n2 2 2\\n4 2 2\\n2 5 12\", \"3\\n2 7 2\\n4 2 2\\n1 9 4\", \"3\\n2 9 2\\n4 2 2\\n1 9 -1\", \"3\\n2 1 2\\n5 2 2\\n1 5 2\", \"3\\n2 4 2...
Chef likes rectangles. Among all possible rectangles, he loves rectangles that can be drawn like a grid, such that they have N rows and M columns. Grids are common in Byteland. Hence, Chef has drawn such a rectangle and plans on moving around in it. The rows of the rectangle are labeled from 1 to N from top to bottom....
0.5
{"tests": "{\"inputs\": [\"1 20\\nGGGGWGGGGWWWWGGGWGGG\\n\", \"10 10\\nGGGGGGGGGG\\nGGGGGGGGGG\\nGGGGGGGGGG\\nGGGGGGGGGG\\nGGGGGGGGGG\\nGGGGGGGGGG\\nGGGGGGGGGG\\nGGGGGGGGGG\\nGGGGGGGGGG\\nGGGGGGGGGG\\n\", \"1 150\\nGGWGGGGGGGGGGGGGGGGGGGWGGGGGGWGGGGGGWGGGGGGGGGGGGGGGGGGGGGGGGGGGGWGGGWGGGGGGGGGGGGGGGGGGGGWGGGGGGGGGGGGGG...
You have a garden consisting entirely of grass and weeds. Your garden is described by an n × m grid, with rows numbered 1 to n from top to bottom, and columns 1 to m from left to right. Each cell is identified by a pair (r, c) which means that the cell is located at row r and column c. Each cell may contain either gras...
0
{"tests": "{\"inputs\": [\"4\\nA\\nAND\\nCAT\\nDOG\\nZ XUW ZVX Z YZT.\\n2\\nAZ\\nAY\\nZA.\\n2\\nAA\\nBB\\nCC.\\n16\\nA\\nB\\nC\\nD\\nE\\nF\\nG\\nH\\nI\\nJ\\nK\\nL\\nM\\nN\\nO\\nONMLKJIHGFEDCBA\\nA B C D E F G H I J K L M N O ABCDEFGHIJKLMNO.\\n0\", \"4\\nA\\nAND\\nCAT\\nDOG\\nZ XUW ZVX Z YZT.\\n2\\nZA\\nAY\\nZA.\\n2\\n...
The committee members of the Kitoshima programming contest had decided to use crypto-graphic software for their secret communication. They had asked a company, Kodai Software, to develop cryptographic software that employed a cipher based on highly sophisticated mathematics. According to reports on IT projects, many p...
0
{"tests": "{\"inputs\": [\"2\\n29 49\\n\", \"2\\n38 38\\n\", \"8\\n12 35 58 58 39 41 41 20\\n\", \"3\\n-1 -1 -1\\n\", \"2\\n24 -1\\n\", \"37\\n52 52 66 149 149 130 47 47 26 110 185 -1 73 73 65 -1 -1 130 -1 -1 -1 94 97 190 -1 -1 49 49 54 -1 92 92 5 25 48 79 79\\n\", \"5\\n1 -1 -1 4 2\\n\", \"5\\n1 3 4 1 1\\n\", \"15\\n-...
Ivan unexpectedly saw a present from one of his previous birthdays. It is array of n numbers from 1 to 200. Array is old and some numbers are hard to read. Ivan remembers that for all elements at least one of its neighbours ls not less than it, more formally: a_{1} ≤ a_{2}, a_{n} ≤ a_{n-1} and a_{i} ≤ max(a_{i-1}, ...
0
{"tests": "{\"inputs\": [\"10\\n447979281 447979282 447979281 447979280 447979279 447979280 447979279 447979278 447979279 447979280\\n\", \"6\\n1 2 3 2 1 0\\n\", \"10\\n-1 0 -1 -2 -3 -2 -1 0 1 0\\n\", \"10\\n1 2 3 4 5 4 3 2 1 0\\n\", \"10\\n1 2 1 0 -1 0 -1 -2 -1 0\\n\", \"10\\n-426734852 -426734851 -426734852 -42673485...
This is an interactive problem. Imur Ishakov decided to organize a club for people who love to play the famous game «The hat». The club was visited by n students, where n is even. Imur arranged them all in a circle and held a draw to break the students in pairs, but something went wrong. The participants are numbered ...
0
{"tests": "{\"inputs\": [[5, 12, 13], [2, 3, 4], [6, 8, 10], [7, 15, 20], [17, 17, 30], [7, 10, 12], [6, 11, 12], [25, 25, 45], [13, 37, 30], [6, 25, 29], [10, 11, 18], [73, 9, 80], [12, 35, 37], [120, 109, 13], [9, 10, 17]], \"outputs\": [[true], [false], [true], [true], [false], [false], [false], [false], [false], [t...
A triangle is called an equable triangle if its area equals its perimeter. Return `true`, if it is an equable triangle, else return `false`. You will be provided with the length of sides of the triangle. Happy Coding! Write your solution by modifying this code: ```python def equable_triangle(a,b,c): ``` Your solut...
0
{"tests": "{\"inputs\": [\"3 228385\\n2 307 733 43 78\\n2 252 801 157 169\\n3 86 346 133 886 467 173\\n\", \"9 81812\\n8 31 410 547 18 22 77 449 5 491 8 10 382 746 21 61 523\\n1 452 181\\n1 724 113\\n1 113 724\\n1 226 362\\n46 5 257 2 126 373 6 6 491 9 7 137 23 93 73 163 13 17 106 3 100 5 415 270 2 7 723 597 4 176 3 27...
Today s kilometer long auto race takes place in Berland. The track is represented by a straight line as long as s kilometers. There are n cars taking part in the race, all of them start simultaneously at the very beginning of the track. For every car is known its behavior — the system of segments on each of which the s...
0.125
{"tests": "{\"inputs\": [\"2 2 5\\n\", \"9 9 1000000000\\n\", \"3 17 999999997\\n\", \"3 3 64\\n\", \"5 1 64\\n\", \"29 2 1000000000\\n\", \"1010 1 1000000000\\n\", \"3 2 27\\n\", \"1 1 60\\n\", \"2 4 64\\n\", \"2 2 64\\n\", \"3 4 1000\\n\", \"2 3 64\\n\", \"2 1 536870912\\n\", \"2 2 17\\n\", \"117 1 13689\\n\", \"2 5 ...
You all know the Dirichlet principle, the point of which is that if n boxes have no less than n + 1 items, that leads to the existence of a box in which there are at least two items. Having heard of that principle, but having not mastered the technique of logical thinking, 8 year olds Stas and Masha invented a game. T...
0
{"tests": "{\"inputs\": [\"6 6\\nS.1..4\\n5..3..\\n..4.1.\\n4....5\\n.2.32.\\n5.1..G\\n3 2\\n...\\nS.G\\n0 0\", \"6 6\\nS.1..4\\n3..5..\\n..4.1.\\n4...5.\\n.2.32.\\n5.1..G\\n3 2\\n...\\nS.G\\n0 0\", \"6 6\\nS.1..4\\n4..5..\\n..4.1.\\n4....5\\n.2.32.\\n5.1..G\\n3 2\\n...\\nS.G\\n0 0\", \"6 6\\nS.1..4\\n3..5..\\n..4.1.\\...
A popular game in a certain country, Pachimon Creature, has been remade and released in Japan. If you love games, after playing this game many times, you've come to think about how you can clear it the fastest. However, no matter how much you think about it, you didn't know the fastest way to capture it, so you decided...
0
{"tests": "{\"inputs\": [\"82 69 103\", \"3 2 1\", \"82 69 114\", \"3 2 0\", \"98 69 114\", \"560118409912468 316250877917599 681260158257385\", \"5 1 5\", \"82 69 30\", \"82 69 73\", \"82 78 114\", \"98 69 148\", \"560118409912468 316250877917599 21421406777778\", \"5 0 5\", \"82 69 59\", \"82 69 38\", \"82 78 104\", ...
Problem If you bring an empty bottle of $ a $ milk, you can exchange it for a new bottle of $ b $ milk. How many bottles of milk can Mr. Kawabayashi, who initially has a bottle of $ x $ milk, drink? Output the remainder after dividing by $ 1000000007 $. Constraints The input satisfies the following conditions. * $ ...
0.25
{"tests": "{\"inputs\": [\"3\\nCyan Yellow Red Magenta Green Blue\\nCyan Yellow Red Magenta Green Blue\\nRed Yellow Magenta Blue Green Cyan\\n4\\nRed Mahenta Blue Green Yellow Cyan\\nRed Yellow Magenta Blue Green Cyan\\nMagenta Green Red Cyan Yellow Blue\\nCyan Green Yellow Blue Magenta Red\\n0\", \"3\\nCyan Yellow Red...
Artist Shinagawa was asked to exhibit n works. Therefore, I decided to exhibit the six sides of the cube colored with paint as a work. The work uses all six colors, Red, Yellow, Blue, Magenta, Green, and Cyan, and each side is filled with one color. Shinagawa changed the arrangement of colors even for cubic works with ...
0
{"tests": "{\"inputs\": [\"5\\n1 2 3 4 5\\n5 4 3 2 0\\n\", \"6\\n1 2 3 10 20 30\\n6 5 4 3 2 0\\n\", \"6\\n2 2 3 10 20 30\\n6 5 4 3 2 0\\n\", \"5\\n1 4 3 4 5\\n5 4 3 2 0\\n\", \"6\\n1 2 3 10 20 25\\n6 5 4 3 2 0\\n\", \"6\\n1 1 2 10 20 25\\n6 5 4 3 2 0\\n\", \"5\\n1 2 3 4 5\\n9 4 3 2 0\\n\", \"5\\n1 2 3 4 5\\n6 4 3 2 0\\...
Kalila and Dimna are two jackals living in a huge jungle. One day they decided to join a logging factory in order to make money. The manager of logging factory wants them to go to the jungle and cut n trees with heights a_1, a_2, ..., a_{n}. They bought a chain saw from a shop. Each time they use the chain saw on the...
0
{"tests": "{\"inputs\": [[\"00:00:00\"], [\"01:02:03\"], [\"01:02:60\"], [\"01:60:03\"], [\"99:59:59\"], [\"0:00:00\"], [\"00:0:00\"], [\"00:00:0\"], [\"00:00:00\\n\"], [\"\\n00:00:00\"], [\"100:59:59\"], [\"09:059:59\"], [\"09:159:59\"], [\"09:59:059\"], [\"09:59:159\"]], \"outputs\": [[0], [3723], [null], [null], [35...
Implement a class/function, which should parse time expressed as `HH:MM:SS`, or `null/nil/None` otherwise. Any extra characters, or minutes/seconds higher than 59 make the input invalid, and so should return `null/nil/None`. Write your solution by modifying this code: ```python def to_seconds(time): ``` Your solu...
0
{"tests": "{\"inputs\": [[1, 0], [1, 10], [1, 11], [0, 11], [1, 20], [21, 30]], \"outputs\": [[0], [0], [2], [0], [4], [448]]}", "source": "primeintellect"}
Following from the previous kata and taking into account how cool psionic powers are compare to the Vance spell system (really, the idea of slots to dumb down the game sucks, not to mention that D&D became a smash hit among geeks, so...), your task in this kata is to create a function that returns how many power points...
0
{"tests": "{\"inputs\": [\"4 7 12 15\\n\", \"1 463129088 536870913 1000000000\\n\", \"1 4 4 7\\n\", \"1 2 3 3\\n\", \"1 1 2 1000000000\\n\", \"8136 12821 10573 15189\\n\", \"169720415 312105195 670978284 671296539\\n\", \"654444727 988815385 77276659 644738371\\n\", \"26733 47464 19138 46248\\n\", \"42765 7043311 39308...
Polycarpus analyzes a string called abracadabra. This string is constructed using the following algorithm: * On the first step the string consists of a single character "a". * On the k-th step Polycarpus concatenates two copies of the string obtained on the (k - 1)-th step, while inserting the k-th character of ...
0
{"tests": "{\"inputs\": [[\"A fast-food resteraunt down the street was grumbling my tummy but I could not go.\"], [\"apparently\"], [\"and\"], [\"but\"], [\"but apparently\"], [\"and apparently\"], [\"but but but and and and\"], [\"\"], [\"but and apparently apparently apparently apparently\"], [\"and apparentlybutactu...
For every string, after every occurrence of `'and'` and `'but'`, insert the substring `'apparently'` directly after the occurrence. If input does not contain 'and' or 'but', return the original string. If a blank string, return `''`. If substring `'apparently'` is already directly after an `'and'` and/or `'but'`, do ...
0
{"tests": "{\"inputs\": [\"10\\n3 5 7 0 2 8 9 6 1 4\\n4 3 8 7 9 6 0 5 2 1\\n\", \"8\\n2 3 0 5 4 7 6 1\\n6 3 2 5 0 4 7 1\\n\", \"8\\n5 2 4 6 1 0 3 7\\n7 4 3 0 2 6 1 5\\n\", \"10\\n7 4 6 1 0 9 2 8 5 3\\n4 7 0 5 2 8 9 6 1 3\\n\", \"9\\n8 5 0 1 6 7 4 2 3\\n6 5 0 8 7 1 4 3 2\\n\", \"75\\n71 69 34 23 13 68 19 45 40 6 74 11 5...
Let's define the sum of two permutations p and q of numbers 0, 1, ..., (n - 1) as permutation <image>, where Perm(x) is the x-th lexicographically permutation of numbers 0, 1, ..., (n - 1) (counting from zero), and Ord(p) is the number of permutation p in the lexicographical order. For example, Perm(0) = (0, 1, ..., n...
0
{"tests": "{\"inputs\": [\"48145 89209 5\\n3 1\\n3 2\\n3 3\\n2 3\\n1 3\\n\", \"2 2 2\\n1 2\\n2 2\\n\", \"10 10 46\\n5 4\\n3 5\\n5 3\\n3 2\\n6 6\\n3 7\\n7 5\\n3 6\\n6 3\\n10 3\\n5 7\\n5 6\\n10 7\\n7 6\\n5 5\\n4 5\\n7 4\\n10 2\\n10 6\\n6 7\\n10 1\\n6 4\\n7 7\\n3 3\\n3 8\\n4 3\\n7 8\\n8 2\\n4 4\\n10 5\\n10 9\\n6 2\\n4 8\\...
Alice got a new doll these days. It can even walk! Alice has built a maze for the doll and wants to test it. The maze is a grid with n rows and m columns. There are k obstacles, the i-th of them is on the cell (x_i, y_i), which means the cell in the intersection of the x_i-th row and the y_i-th column. However, the d...
0
{"tests": "{\"inputs\": [[20, 27], [12, 39], [17, 34], [34, 17], [35, 10], [64, 27]], \"outputs\": [[true], [false], [false], [false], [false], [true]]}", "source": "primeintellect"}
Write a program to determine if two numbers are coprime. A pair of numbers are coprime if their greatest shared factor is 1. For example: ``` 20 and 27 Factors of 20: 1, 2, 4, 5, 10, 20 Factors of 27: 1, 3, 9, 27 Greatest shared factor: 1 20 and 27 are coprime``` An example of two numbers that are not coprime: ``` 12 a...
0
{"tests": "{\"inputs\": [[[\"super\"]], [[\"super\", \"hot\"]], [[\"super\", \"hot\", \"guacamole\"]], [[\"super\", \"guacamole\", \"super\", \"super\", \"hot\", \"guacamole\"]], [[\"testing\", \"testing\", \"testing\"]]], \"outputs\": [[[\"super\"]], [[\"super hot\", \"hot super\"]], [[\"super hot guacamole\", \"super...
**This Kata is intended as a small challenge for my students** All Star Code Challenge #19 You work for an ad agency and your boss, Bob, loves a catchy slogan. He's always jumbling together "buzz" words until he gets one he likes. You're looking to impress Boss Bob with a function that can do his job for him. Create...
0
{"tests": "{\"inputs\": [[[2, 8, 121, 42, 222, 23]], [[239]], [[100, 101, 111]], [[100, 23, 42, 239, 22339, 9999999, 456, 78, 228, 1488]], [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]]], \"outputs\": [[3], [1], [2], [10], [10]]}", "source": "primeintellect"}
# Task Let's call `product(x)` the product of x's digits. Given an array of integers a, calculate `product(x)` for each x in a, and return the number of distinct results you get. # Example For `a = [2, 8, 121, 42, 222, 23]`, the output should be `3`. Here are the products of the array's elements: ``` 2: product(2...
0
{"tests": "{\"inputs\": [[\"zodiac\"], [\"chruschtschov\"], [\"khrushchev\"], [\"strength\"], [\"catchphrase\"], [\"twelfthstreet\"], [\"mischtschenkoana\"]], \"outputs\": [[26], [80], [38], [57], [73], [103], [80]]}", "source": "primeintellect"}
Given a lowercase string that has alphabetic characters only and no spaces, return the highest value of consonant substrings. Consonants are any letters of the alphabet except `"aeiou"`. We shall assign the following values: `a = 1, b = 2, c = 3, .... z = 26`. For example, for the word "zodiacs", let's cross out the...
0
{"tests": "{\"inputs\": [\"1\\nA00\\n\", \"1\\na00\\n\", \"1\\n825\\n\", \"1\\nNV641\\n\", \"1\\naAbAcDeF\\n\", \"1\\n000\\n\", \"6\\n11b\\n4bh\\nBeh\\nTuY\\n1YJ\\nP28\\n\", \"1\\nM62H\\n\", \"3\\nafd\\n142\\nTRE\\n\", \"2\\nabcDCE\\nhtQw27\\n\", \"4\\nYtG3\\n33Yo\\n123n\\nm23m\\n\", \"1\\n0a0\\n\", \"1\\nWK7S\\n\", \"...
Vasya came up with a password to register for EatForces — a string s. The password in EatForces should be a string, consisting of lowercase and uppercase Latin letters and digits. But since EatForces takes care of the security of its users, user passwords must contain at least one digit, at least one uppercase Latin l...
0
{"tests": "{\"inputs\": [[100, 1], [11, 2], [20, 2], [101, 2], [10001, 2], [10001000, 2], [500309160, 2], [10000000000000000000000, 3], [10000000000000000000000, 21], [1203, 4]], \"outputs\": [[19], [1], [9], [82], [487], [1729], [2604], [1122660], [2407217760893271902598], [81]]}", "source": "primeintellect"}
You are given 2 numbers is `n` and `k`. You need to find the number of integers between 1 and n (inclusive) that contains exactly `k` non-zero digit. Example1 ` almost_everywhere_zero(100, 1) return 19` by following condition we have 19 numbers that have k = 1 digits( not count zero ) ` [1,2,3,4,5,6,7,8,9,10,20,30...
0
{"tests": "{\"inputs\": [\"19\\n 1 +x 1 +y +z 3 +z\\n 3 +y -z +x +y -z -x +z 2 +z\\n 2 +y\\n19\\n 1 +x 1 +x +z 3 +y -z +x +y -z -x +z 2 +y\\n 3 +z\\n 2 +z\\n19\\n 1 +x 1 +y +z 3 +z\\n 3 +y -z +x +y -z -x +z 2 +y\\n 2 +z\\n18\\n 1 -y\\n 1 +y -z +x\\n 1 +z +y +x +z +y -x -y 2 -y\\n 2 +z\\n3 +x +y +z\\n3 +y +...
Professor Tsukuba invented a mysterious jewelry box that can be opened with a special gold key whose shape is very strange. It is composed of gold bars joined at their ends. Each gold bar has the same length and is placed parallel to one of the three orthogonal axes in a three dimensional space, i.e., x-axis, y-axis an...
0
{"tests": "{\"inputs\": [\"1\\n1\", \"21\\n0 0 0 0 0 0 0 1 1 0 1 1 1 1 0 0 0 1 0 0 1\\n1 1 1 0 1 1 0 0 0 1 0 0 0 0 1 1 1 0 1 1 0\\n0 0 1 1 1 1 0 1 1 0 0 1 0 0 1 1 0 0 0 1 1\\n0 1 1 0 1 1 0 1 0 1 0 0 1 0 0 0 0 0 1 1 0\\n1 1 0 0 1 0 1 0 0 1 1 1 1 0 0 0 0 0 0 0 0\\n0 1 1 0 1 1 1 0 1 1 1 0 0 0 1 1 1 1 0 0 1\\n0 1 0 0 0 1 0...
There are N men and N women, both numbered 1, 2, \ldots, N. For each i, j (1 \leq i, j \leq N), the compatibility of Man i and Woman j is given as an integer a_{i, j}. If a_{i, j} = 1, Man i and Woman j are compatible; if a_{i, j} = 0, they are not. Taro is trying to make N pairs, each consisting of a man and a woman...
0.5
{"tests": "{\"inputs\": [\"3\\n3\\n110\\n2\\n00\\n4\\n1010\\n\", \"3\\n3\\n110\\n2\\n00\\n4\\n1011\\n\", \"3\\n3\\n010\\n2\\n00\\n4\\n0011\\n\", \"3\\n3\\n110\\n2\\n00\\n4\\n0110\\n\", \"3\\n3\\n010\\n2\\n00\\n4\\n1001\\n\", \"3\\n3\\n110\\n2\\n00\\n4\\n0011\\n\", \"3\\n3\\n110\\n2\\n00\\n4\\n0010\\n\", \"3\\n3\\n000\\...
The only difference between the easy and hard versions is that the given string $s$ in the easy version is initially a palindrome, this condition is not always true for the hard version. A palindrome is a string that reads the same left to right and right to left. For example, "101101" is a palindrome, while "0101" is...
0
{"tests": "{\"inputs\": [\"5\\n3 2\\n1 1 1\\n1 2\\n2 3\\n5 5\\n1 0 0 0 0\\n1 2\\n2 3\\n3 4\\n4 5\\n1 5\\n10 11\\n998244353 0 0 0 998244353 0 0 0 0 0\\n1 2\\n2 3\\n3 4\\n4 5\\n5 6\\n6 7\\n7 8\\n8 9\\n9 10\\n1 3\\n7 9\\n5 6\\n1293 1145 9961 9961 1919\\n1 2\\n2 3\\n3 4\\n5 4\\n1 4\\n2 4\\n6 9\\n10 10 10 10 10 10\\n1 2\\n1...
Cirno has a DAG (Directed Acyclic Graph) with $n$ nodes and $m$ edges. The graph has exactly one node that has no out edges. The $i$-th node has an integer $a_i$ on it. Every second the following happens: Let $S$ be the set of nodes $x$ that have $a_x > 0$. For all $x \in S$, $1$ is subtracted from $a_x$, and then f...
0
{"tests": "{\"inputs\": [\"7\\n3 3 2\\n2 1 10\\n6 3 10\\n6 4 10\\n100 1 1\\n4 4 0\\n69 4 20\\n\", \"1\\n2000 2000 1000000006\\n\", \"1\\n2000 1139 818658270\\n\", \"2\\n1398 1034 726329524\\n602 156 640769482\\n\", \"3\\n763 499 769431935\\n827 50 784148915\\n410 241 11071818\\n\", \"4\\n182 35 698699275\\n261 76 28953...
This is the easy version of the problem. The difference is the constraints on $n$, $m$ and $t$. You can make hacks only if all versions of the problem are solved. Alice and Bob are given the numbers $n$, $m$ and $k$, and play a game as follows: The game has a score that Alice tries to maximize, and Bob tries to minim...
0
{"tests": "{\"inputs\": [\"4\\n3 3\\nabc\\nbcd\\n4 2\\nabba\\nazza\\n2 1\\nzz\\naa\\n6 2\\naaabba\\nddddcc\\n\", \"4\\n1 3\\nabc\\nbcd\\n4 2\\nabba\\nazza\\n2 1\\nzz\\naa\\n6 2\\naaabba\\nddddcc\\n\", \"4\\n3 3\\nabc\\nbcd\\n4 2\\nabba\\nazza\\n2 1\\nzz\\naa\\n6 2\\naaabba\\nedddcc\\n\", \"4\\n3 3\\nabb\\nacd\\n4 2\\na...
Ashish has two strings $a$ and $b$, each of length $n$, and an integer $k$. The strings only contain lowercase English letters. He wants to convert string $a$ into string $b$ by performing some (possibly zero) operations on $a$. In one move, he can either choose an index $i$ ($1 \leq i\leq n-1$) and swap $a_i$ and $...
0
{"tests": "{\"inputs\": [\"5\\n4 1\\n0 1 3 4\\n3 1\\n0 1 4\\n3 0\\n0 1 4\\n3 2\\n0 1 2\\n3 2\\n1 2 3\\n\", \"7\\n5 1000000000\\n4 2 3 0 1\\n4 0\\n5 2 0 1\\n3 0\\n100 0 1\\n6 1234567\\n1 2 3 4 5 0\\n3 114514\\n8 0 4\\n1 1000000\\n0\\n1 10000000\\n1\\n\", \"1\\n1 0\\n0\\n\", \"1\\n6 2\\n0 1 2 3 6 8\\n\", \"1\\n3 1\\n1 2 ...
You are given a multiset $S$ initially consisting of $n$ distinct non-negative integers. A multiset is a set, that can contain some elements multiple times. You will perform the following operation $k$ times: Add the element $\lceil\frac{a+b}{2}\rceil$ (rounded up) into $S$, where $a = \operatorname{mex}(S)$ and $b =...
0.125
{"tests": "{\"inputs\": [[\"s2324\"], [\"-234.4\"], [\"3 4\"], [\"3-4\"], [\"3 4 \"], [\"34.65\"], [\"-0\"], [\"0.0\"], [\"\"], [\" \"]], \"outputs\": [[false], [true], [false], [false], [false], [true], [true], [true], [false], [false]]}", "source": "primeintellect"}
Given a string s, write a method (function) that will return true if its a valid single integer or floating number or false if its not. Valid examples, should return true: should return false: Write your solution by modifying this code: ```python def isDigit(string): ``` Your solution should implemented in the f...
0
{"tests": "{\"inputs\": [[\"ooo\"], [\"ioioio\"], [\"idoiido\"], [\"isoisoiso\"], [\"codewars\"]], \"outputs\": [[[0, 0, 0]], [[1, 2, 3]], [[0, 1]], [[1, 4, 25]], [[0]]]}", "source": "primeintellect"}
Write a simple parser that will parse and run Deadfish. Deadfish has 4 commands, each 1 character long: * `i` increments the value (initially `0`) * `d` decrements the value * `s` squares the value * `o` outputs the value into the return array Invalid characters should be ignored. ```python parse("iiisdoso") ==> ...
0
{"tests": "{\"inputs\": [\"1\\n1\\n\", \"3\\n1 4 2\\n\", \"7\\n2 12 4 8 18 3 6\\n\", \"30\\n3 1 3 2 3 1 1 3 2 1 1 3 3 3 3 3 2 1 2 1 3 2 2 1 3 1 3 1 2 3\\n\", \"3\\n1 1000000000 2\\n\"], \"outputs\": [\"1 \", \"1 1 2 \", \"0 1 1 1 2 2 2 \", \"0 1 1 1 1 2 3 3 3 4 5 5 5 6 6 6 6 7 7 8 8 8 9 10 10 11 11 12 12 12 \", \"1 1 2...
New Year is just around the corner, which means that in School 179, preparations for the concert are in full swing. There are $n$ classes in the school, numbered from $1$ to $n$, the $i$-th class has prepared a scene of length $a_i$ minutes. As the main one responsible for holding the concert, Idnar knows that if a c...
0
{"tests": "{\"inputs\": [\"3\\n0110?11\\n6\\n5 1\\n6 ?\\n7 ?\\n2 ?\\n5 ?\\n1 1\\n\", \"3\\n0110?11\\n6\\n5 1\\n6 ?\\n6 ?\\n1 ?\\n5 ?\\n1 1\\n\", \"3\\n11?0110\\n6\\n5 1\\n6 ?\\n7 ?\\n2 ?\\n5 ?\\n1 1\\n\", \"3\\n0110?11\\n6\\n5 1\\n7 ?\\n7 ?\\n2 ?\\n5 ?\\n1 1\\n\", \"3\\n0110?11\\n1\\n5 1\\n6 ?\\n7 @\\n2 ?\\n5 ?\\n1 1\\...
2^k teams participate in a playoff tournament. The tournament consists of 2^k - 1 games. They are held as follows: first of all, the teams are split into pairs: team 1 plays against team 2, team 3 plays against team 4 (exactly in this order), and so on (so, 2^{k-1} games are played in that phase). When a team loses a g...
0
{"tests": "{\"inputs\": [[3, 5], [\"hello\", 3], [67, \"bye\"], [true, true], [314, 107], [1, 32], [-1, -1], [19483, 9], [\"hello\", {}], [[], \"pippi\"]], \"outputs\": [[5], [false], [false], [false], [207], [1], [0], [16], [false], [false]]}", "source": "primeintellect"}
# Fix the Bugs (Syntax) - My First Kata ## Overview Hello, this is my first Kata so forgive me if it is of poor quality. In this Kata you should fix/create a program that ```return```s the following values: - ```false/False``` if either a or b (or both) are not numbers - ```a % b``` plus ```b % a``` if both argum...
0
{"tests": "{\"inputs\": [\"2\\n4\\n1\\n1\\n2\\n3\\n9\\n1\\n1\\n1\\n2\\n2\\n1\\n2\\n1\\n2\\n\", \"7\\n1\\n1\\n2\\n1\\n1\\n2\\n1\\n2\\n3\\n1\\n1\\n1\\n3\\n1\\n1\\n2\\n3\\n1\\n2\\n1\\n3\\n1\\n2\\n3\\n\", \"10\\n4\\n1\\n1\\n1\\n1\\n4\\n1\\n1\\n1\\n2\\n4\\n1\\n1\\n2\\n1\\n4\\n1\\n1\\n2\\n2\\n4\\n1\\n1\\n2\\n3\\n4\\n1\\n2\\n...
William is a huge fan of planning ahead. That is why he starts his morning routine by creating a nested list of upcoming errands. A valid nested list is any list which can be created from a list with one item "1" by applying some operations. Each operation inserts a new item into the list, on a new line, just after on...
0
{"tests": "{\"inputs\": [[[1, 2, 3, 4, 5], [2, 3, 4, 1, 5]], [[1, 2, 3, 3, 3, 4, 5], [2, 3, 4, 1, 5]], [[1, 2, 3, 3, 3, 5], [2, 3, 4, 1, 5]], [[1, 2, 3, 3, 3, 5], [3, 4, 5, 6, 9, 11, 12, 13, 1, 7, 8, 2, 10]], [[\"a\", \"a\", \"b\", \"f\", \"d\", \"a\"], [\"c\", \"a\", \"d\", \"b\", \"e\", \"f\"]]], \"outputs\": [[[2, 3...
Given an Array and an Example-Array to sort to, write a function that sorts the Array following the Example-Array. Assume Example Array catalogs all elements possibly seen in the input Array. However, the input Array does not necessarily have to have all elements seen in the Example. Example: Arr: [1,3,4,4,4,4,5] E...
0
{"tests": "{\"inputs\": [\"2015 3 2 2015 3 13\", \"1045 2 14 2015 3 15\", \"1234 5 4 789012345678901234 5 6\", \"2015 3 3 2015 2 13\", \"2015 3 6 3448 2 13\", \"2015 2 6 3448 3 13\", \"2015 2 6 3516 3 13\", \"3203 2 2 3516 3 13\", \"1045 2 14 2015 3 5\", \"1045 4 14 3098 3 13\", \"1045 4 20 3641 3 13\", \"2015 3 6 3590...
Problem "Ritsumeikan University Competitive Programming Camp" will be held this year as well. I am very much looking forward to this annual training camp. However, I couldn't stand my desires and splurged before the training camp, so I couldn't afford it. So I decided to use the cheapest Seishun 18 Ticket to get to Mi...
0
{"tests": "{\"inputs\": [\"5 1 1\", \"1010000 100000 200000\", \"4 4 6\", \"10 0 1\", \"1010000 100001 200000\", \"5 2 2\", \"1011000 100001 200000\", \"1011001 100001 200000\", \"0100111 001111 35243\", \"5 2 3\", \"1000000 110000 200000\", \"16 4 6\", \"7 1 2\", \"1010000 100001 160629\", \"1001001 000001 167964\", \...
We have two indistinguishable pieces placed on a number line. Both pieces are initially at coordinate 0. (They can occupy the same position.) We can do the following two kinds of operations: * Choose a piece and move it to the right (the positive direction) by 1. * Move the piece with the smaller coordinate to the po...
0
{"tests": "{\"inputs\": [\"3 \\n40 40 100\\n45 45 90\\n180 1 1\\n\\n\", \"3 \\n30 40 110\\n12 45 90\\n180 0 0\", \"3 \\n30 40 111\\n12 45 90\\n180 0 0\", \"3 \\n30 77 110\\n45 45 90\\n180 0 0\", \"3 \\n30 40 111\\n9 45 90\\n180 0 0\", \"3 \\n16 40 111\\n9 45 90\\n180 0 0\", \"3 \\n16 77 111\\n9 45 90\\n180 0 0\", \"3 \...
Write a program to check whether a triangle is valid or not, when the three angles of the triangle are the inputs. A triangle is valid if the sum of all the three angles is equal to 180 degrees. -----Input----- The first line contains an integer T, the total number of testcases. Then T lines follow, each line contain...
0
{"tests": "{\"inputs\": [[{\"name\": \"Jeremy\"}], [{\"name\": \"Jeremy\", \"age\": 24}], [{\"name\": \"Jeremy\", \"age\": 24, \"role\": \"Software Engineer\"}], [{\"product\": \"CodeWars\", \"power_level_over\": 9000}], [{}]], \"outputs\": [[[[\"name\", \"Jeremy\"]]], [[[\"age\", 24], [\"name\", \"Jeremy\"]]], [[[\"ag...
Convert a hash into an array. Nothing more, Nothing less. ``` {name: 'Jeremy', age: 24, role: 'Software Engineer'} ``` should be converted into ``` [["name", "Jeremy"], ["age", 24], ["role", "Software Engineer"]] ``` ```if:python,javascript,crystal **Note**: The output array should be sorted alphabetically. ``` Goo...
0
{"tests": "{\"inputs\": [[1], [2], [3], [4], [12], [37], [311], [999]], \"outputs\": [[[\"one\", \"three\", \"five\", \"four\"]], [[\"two\", \"three\", \"five\", \"four\"]], [[\"three\", \"five\", \"four\"]], [[\"four\"]], [[\"onetwo\", \"six\", \"three\", \"five\", \"four\"]], [[\"threeseven\", \"onezero\", \"seven\",...
If we write out the digits of "60" as English words we get "sixzero"; the number of letters in "sixzero" is seven. The number of letters in "seven" is five. The number of letters in "five" is four. The number of letters in "four" is four: we have reached a stable equilibrium. Note: for integers larger than 9, write ou...
0
{"tests": "{\"inputs\": [\"3\\n2 2 3\\n4 3 7\\n10 1 9\\n\", \"3\\n2 2 3\\n4 3 7\\n7 1 9\\n\", \"3\\n2 2 3\\n4 3 9\\n7 1 9\\n\", \"3\\n2 2 3\\n6 1 9\\n7 1 1\\n\", \"3\\n2 1 3\\n6 1 9\\n7 0 2\\n\", \"3\\n2 0 3\\n3 1 9\\n13 0 2\\n\", \"3\\n4 0 3\\n3 1 9\\n13 0 2\\n\", \"3\\n7 0 0\\n3 1 5\\n22 0 2\\n\", \"3\\n1 0 0\\n5 0 5...
Mikhail walks on a Cartesian plane. He starts at the point $(0, 0)$, and in one move he can go to any of eight adjacent points. For example, if Mikhail is currently at the point $(0, 0)$, he can go to any of the following points in one move: $(1, 0)$; $(1, 1)$; $(0, 1)$; $(-1, 1)$; $(-1, 0)$; $(-1, -1)$; $(0, -...
0
{"tests": "{\"inputs\": [\"2\\n1 2\\n\", \"8\\n10 4 3 6 5 10 7 5\\n\", \"10\\n20 1 15 17 11 2 15 3 16 3\\n\", \"50\\n499 780 837 984 481 526 944 482 862 136 265 605 5 631 974 967 574 293 969 467 573 845 102 224 17 873 648 120 694 996 244 313 404 129 899 583 541 314 525 496 443 857 297 78 575 2 430 137 387 319\\n\", \"5...
You are creating a level for a video game. The level consists of $n$ rooms placed in a circle. The rooms are numbered $1$ through $n$. Each room contains exactly one exit: completing the $j$-th room allows you to go the $(j+1)$-th room (and completing the $n$-th room allows you to go the $1$-st room). You are given th...
0
{"tests": "{\"inputs\": [\"4\\n6 4 2\\n2 9 2 3 8 5\\n4 4 1\\n2 13 60 4\\n4 1 3\\n1 2 2 1\\n2 2 0\\n1 2\\n\", \"4\\n6 4 2\\n2 9 2 3 8 5\\n4 4 1\\n2 13 60 4\\n4 1 3\\n1 2 1 1\\n2 2 0\\n1 2\\n\", \"4\\n6 4 2\\n2 9 2 3 8 5\\n4 4 1\\n2 13 60 4\\n4 2 3\\n1 2 2 1\\n2 2 0\\n1 2\\n\", \"4\\n6 3 2\\n2 9 2 3 8 5\\n4 4 1\\n2 13 60...
You and your $n - 1$ friends have found an array of integers $a_1, a_2, \dots, a_n$. You have decided to share it in the following way: All $n$ of you stand in a line in a particular order. Each minute, the person at the front of the line chooses either the first or the last element of the array, removes it, and keeps ...
0
{"tests": "{\"inputs\": [\"3\\n10 -3\\n50 4\\n101 -5\", \"3\\n2 18\\n3 -20\\n6 15\", \"5\\n56 114834\\n72 -134386\\n100 190757\\n192 -132693\\n240 133108\", \"3\\n10 -3\\n91 4\\n101 -5\", \"3\\n18 -3\\n91 4\\n101 1\", \"5\\n92 114834\\n125 -176641\\n100 13125\\n192 -68478\\n240 133108\", \"5\\n42 114834\\n125 -176641\\...
Consider an infinite sequence a_1, a_2, … Initially, the values of all the terms are 0, and from this state we will sequentially perform Q operations. The i-th operation (1 ≤ i ≤ Q) is as follows: * For every positive integer j, add x_i to the value of a_{j × m_i}. Find the value of the largest term after these Q o...
0.125
{"tests": "{\"inputs\": [\"6\\n1 2 3 4 5 6\\n\", \"5\\n-1000 -100 -10 0 10\\n\", \"10\\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000\\n\", \"27\\n18 -28 18 28 -45 90 -45 23 -53 60 28 -74 -71 35 -26 -62 49 -77 57 24 -70 -93 69 -99 59 57 -49\\n\", \"27\\n18...
Given is an integer sequence A_1, ..., A_N of length N. We will choose exactly \left\lfloor \frac{N}{2} \right\rfloor elements from this sequence so that no two adjacent elements are chosen. Find the maximum possible sum of the chosen elements. Here \lfloor x \rfloor denotes the greatest integer not greater than x. --...
0.375
{"tests": "{\"inputs\": [\"2\\n8\\n0\", \"2\\n6\\n0\", \"2\\n2\\n0\", \"2\\n0\\n0\", \"2\\n14\\n0\", \"2\\n12\\n0\", \"2\\n10\\n0\", \"2\\n18\\n0\", \"2\\n24\\n0\", \"2\\n0\\n1\", \"2\\n0\\n-1\", \"2\\n0\\n-2\", \"2\\n0\\n2\", \"2\\n0\\n4\", \"2\\n0\\n-4\", \"2\\n0\\n0\", \"2\\n0\\n-1\", \"2\\n0\\n-2\", \"2\\n6\\n0\", ...
Dr. Hedro is astonished. According to his theory, we can make sludge that can dissolve almost everything on the earth. Now he's trying to produce the sludge to verify his theory. The sludge is produced in a rectangular solid shaped tank whose size is N × N × 2. Let coordinate of two corner points of tank be (-N/2, -N/...
0
{"tests": "{\"inputs\": [\"(B&B&f)|(~d&~i&i)|(~v&i&~V)|(&g&~e&o)|(~f&d&~v)|(d&~i&o)|(g&i&~B)|(~i&f&d)|(e&~i~~V)|(~v&f&~d)\\n(S&X&~X)\\n#\", \"(B&B&f)|(~d&~i&i)|(~v&i&~V)|(&g&~e&o)|(~f&d&~v)|(d&~i&o)|(g&i&~B)|(~i&f&d)|(e&~i~~V)|(~v&f&~d)\\n(S&X&~W)\\n#\", \"(B&B&f)|(~d&~i&i)|(~u&i&~V)|(&g&~e&o)|(~f&d&~v)|(d&~i&o)|(g&i&~...
She was worried. The grades are not good. Although she forced her parents to enroll in a dormitory school, her talent never blossomed. Or maybe he didn't have the talent in the first place, but it was possible that he didn't want to think about it as much as possible. So she relied on the dubious brain training materi...
0
{"tests": "{\"inputs\": [\"100 100\\n50 50\\n\", \"13 23\\n19 63\\n\", \"5 23\\n12 17\\n\", \"65 8\\n73 25\\n\", \"100 3\\n4 1\\n\", \"2 25\\n8 24\\n\", \"19 17\\n5 8\\n\", \"24 43\\n96 39\\n\", \"11 17\\n6 4\\n\", \"25 9\\n16 12\\n\", \"58 86\\n40 46\\n\", \"100 1\\n4 1\\n\", \"82 60\\n100 38\\n\", \"9 21\\n13 16\\n\"...
Statistics claims that students sleep no more than three hours a day. But even in the world of their dreams, while they are snoring peacefully, the sense of impending doom is still upon them. A poor student is dreaming that he is sitting the mathematical analysis exam. And he is examined by the most formidable profess...
0
{"tests": "{\"inputs\": [\"6\\n2 2 2 1 1 1\\n\", \"2\\n1 2\\n\", \"200\\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...
A dragon symbolizes wisdom, power and wealth. On Lunar New Year's Day, people model a dragon with bamboo strips and clothes, raise them with rods, and hold the rods high and low to resemble a flying dragon. A performer holding the rod low is represented by a 1, while one holding it high is represented by a 2. Thus, th...
0
{"tests": "{\"inputs\": [\"b\", \"axbax\", \"`b\", \"xxxo\", \"tpxt\", \"c\", \"bxbax\", \"b`\", \"yxxo\", \"d\", \"bxbbx\", \"ba\", \"oxxy\", \"e\", \"xxbbb\", \"bb\", \"oxyx\", \"f\", \"xxabb\", \"cb\", \"oxyy\", \"g\", \"xyabb\", \"bc\", \"oxzy\", \"h\", \"bbayx\", \"db\", \"oxzz\", \"i\", \"bb`yx\", \"bd\", \"zzxo\...
We have a string s consisting of lowercase English letters. Snuke can perform the following operation repeatedly: * Insert a letter `x` to any position in s of his choice, including the beginning and end of s. Snuke's objective is to turn s into a palindrome. Determine whether the objective is achievable. If it is ...
0.75
{"tests": "{\"inputs\": [[\"123\"], [\"0x123\"], [\"0o123\"], [\"0123\"], [\"123 \"], [\" 123\"], [\"0b1010\"], [\"+123\"], [\"-123\"], [\"0B1010\"], [\"0b12\"], [\"-0x123\"], [\"-0o123\"], [\"-0123\"], [\"123\\n\"], [\"\\n123\"], [\"-0b1010\"], [\"0xDEADbeef\"], [\"0X123\"], [\"0O123\"], [\"0o18\"]], \"outputs\": [[12...
Implement a function/class, which should return an integer if the input string is in one of the formats specified below, or `null/nil/None` otherwise. Format: * Optional `-` or `+` * Base prefix `0b` (binary), `0x` (hexadecimal), `0o` (octal), or in case of no prefix decimal. * Digits depending on base Any extra char...
0
{"tests": "{\"inputs\": [[900, \"abcdef\"], [56, \"ifkhchlhfd\"], [256, \"aaaaaddddr\"], [333, \"jfmgklfhglbe\"], [12, \"jaam\"], [808, \"alfbpmmpz\"], [660, \"zyxsqwh\"], [651, \"hmgoltyy\"], [349, \"nxls\"], [958, \"hovzfsxbmwu\"], [301, \"doda\"], [383, \"zwwl\"], [871, \"gnlyvknjga\"], [583, \"slhacx\"], [0, \"jpip...
It's your Birthday. Your colleagues buy you a cake. The numbers of candles on the cake is provided (x). Please note this is not reality, and your age can be anywhere up to 1,000. Yes, you would look a mess. As a surprise, your colleagues have arranged for your friend to hide inside the cake and burst out. They pretend...
0
{"tests": "{\"inputs\": [[36], [103], [0], [2], [151]], \"outputs\": [[{\"Bike\": \"104.60 to go!\"}], [{\"Bike\": \"37.60 to go!\"}], [\"Starting Line... Good Luck!\"], [{\"Swim\": \"138.60 to go!\"}], [\"You're done! Stop running!\"]]}", "source": "primeintellect"}
An Ironman Triathlon is one of a series of long-distance triathlon races organized by the World Triathlon Corporaion (WTC). It consists of a 2.4-mile swim, a 112-mile bicycle ride and a marathon (26.2-mile) (run, raced in that order and without a break. It hurts... trust me. Your task is to take a distance that an ath...
0