info
stringlengths
120
50k
question
stringlengths
504
10.4k
avg@8_qwen3_4b_instruct_2507
float64
0
0.88
{"tests": "{\"inputs\": [\"2\\n\\n00010010\\n00000100\\n10001001\\n00100010\\n01000000\\n00001000\\n10100010\\n01010010\\n2\\n5\\n\\n00010010\\n00000100\\n10001001\\n00100010\\n01000000\\n00001000\\n10100000\\n01010010\\n2\\n5\", \"2\\n\\n00010010\\n00000100\\n00001001\\n00100010\\n01000000\\n00001000\\n10100010\\n0101...
There is a plane like Figure 1 with 8 vertical and 8 horizontal squares. There are several bombs on that plane. Figure 2 shows an example (● = bomb). | □ | □ | □ | □ | □ | □ | □ | □ --- | --- | --- | --- | --- | --- | --- | --- □ | □ | □ | □ | □ | □ | □ | □ □ | □ | □ | □ | □ | □ | □ | □ □ | □ | □ | □ | □ | □ | □ | □ □...
0
{"tests": "{\"inputs\": [[\"LOL\"], [\"HOW R U\"], [\"WHERE DO U WANT 2 MEET L8R\"], [\"lol\"], [\"0\"], [\"ZER0\"], [\"1\"], [\"IS NE1 OUT THERE\"], [\"#\"], [\"#codewars #rocks\"]], \"outputs\": [[9], [13], [47], [9], [2], [11], [1], [31], [1], [36]]}", "source": "taco"}
Prior to having fancy iPhones, teenagers would wear out their thumbs sending SMS messages on candybar-shaped feature phones with 3x4 numeric keypads. ------- ------- ------- | | | ABC | | DEF | | 1 | | 2 | | 3 | ------- ------- ------- ------- ------- ------- | GHI | | JKL | | MNO | ...
0
{"tests": "{\"inputs\": [\"10000\\n5000 3150\\n5000 5000\\n0 0\\n5000 1050\\n5000 3980\\n5000 210\\n5000 5000\\n5000 5000\\n0 0\\n5000 2100\\n5000 2100\\n5000 2100\\n29170\\n100000 100000\\n100000 100000\\n100000 100000\\n100000 100000\\n100000 100000\\n100000 100000\\n100000 100000\\n100000 101000\\n100000 100000\\n10...
You want to go on a trip with a friend. However, friends who have a habit of spending money cannot easily save travel expenses. I don't know when my friends will go on a trip if they continue their current lives. So, if you want to travel early, you decide to create a program to help your friends save in a planned mann...
0
{"tests": "{\"inputs\": [\"4 1\\n(\\n\", \"4 4\\n(())\\n\", \"4 3\\n(((\\n\", \"875 50\\n)))((())()))((()(())))))())))((((((()))))))()(((((\\n\", \"1980 464\\n))(()()))(((((((((()))))))(()(((()((()))()()())()))()))(()))))))(())((())))()())()((())())()())))(())()(()))(()())()((((()))())()(())))))(()()(()(((((()(()()))((...
As Famil Door’s birthday is coming, some of his friends (like Gabi) decided to buy a present for him. His friends are going to buy a string consisted of round brackets since Famil Door loves string of brackets of length n more than any other strings! The sequence of round brackets is called valid if and only if: the...
0
{"tests": "{\"inputs\": [\"4 5\\n1 3 5\\n3 4 6\\n4 2 7\\n2 1 18\\n2 3 17\", \"4 5\\n1 3 5\\n3 4 6\\n4 2 7\\n2 1 6\\n2 3 17\", \"4 5\\n1 3 5\\n3 2 6\\n4 2 7\\n2 1 18\\n2 3 12\", \"4 5\\n1 3 5\\n3 4 6\\n4 2 13\\n2 1 6\\n2 3 17\", \"4 1\\n1 3 5\\n3 2 6\\n4 2 7\\n2 1 18\\n2 3 12\", \"8 5\\n1 3 5\\n3 4 6\\n4 2 7\\n2 1 18\\n...
Problem F Pizza Delivery Alyssa is a college student, living in New Tsukuba City. All the streets in the city are one-way. A new social experiment starting tomorrow is on alternative traffic regulation reversing the one-way directions of street sections. Reversals will be on one single street section between two adjac...
0
{"tests": "{\"inputs\": [\"9\\n487264 453898 452366 383095 172725 168148 164570 141228 1\\n\", \"28\\n434419 433070 431479 424448 423449 392416 368998 367310 329030 316399 311541 302510 283863 262469 257928 248272 242310 217371 183364 172064 164154 131734 131169 117466 23544 19990 11006 1\\n\", \"58\\n3000000 2511334 2...
Billy investigates the question of applying greedy algorithm to different spheres of life. At the moment he is studying the application of greedy algorithm to the problem about change. There is an amount of n coins of different face values, and the coins of each value are not limited in number. The task is to collect t...
0
{"tests": "{\"inputs\": [\"0101011\\n0101\\n\", \"00010000111010011101110110010110100010001101001110\\n1011111000111010111001111\\n\", \"10100110\\n10\\n\", \"10000111\\n10101\\n\", \"11111111111111111111111111111111111111111111111111\\n11111111111111111111111111111111111111111111111110\\n\", \"111111111111111111111111...
The new camp by widely-known over the country Spring Programming Camp is going to start soon. Hence, all the team of friendly curators and teachers started composing the camp's schedule. After some continuous discussion, they came up with a schedule s, which can be represented as a binary string, in which the i-th symb...
0
{"tests": "{\"inputs\": [\"2\\n2 3\\n5\\n2 1 1\\n2 2 1\\n1 1 1\\n2 1 2\\n2 2 0\\n\", \"2\\n4 4\\n9\\n1 1 1\\n1 2 1\\n1 3 1\\n2 1 2\\n2 2 2\\n2 3 2\\n2 3 1\\n2 2 1\\n2 1 1\\n\", \"3\\n2 1 1\\n4\\n1 1 1\\n1 1 2\\n1 1 3\\n1 1 0\\n\", \"3\\n3 1 1\\n6\\n1 1 1\\n1 2 1\\n1 2 2\\n1 1 2\\n1 1 3\\n1 2 3\\n\", \"1\\n30\\n1\\n1 26...
Bob is playing a game of Spaceship Solitaire. The goal of this game is to build a spaceship. In order to do this, he first needs to accumulate enough resources for the construction. There are $n$ types of resources, numbered $1$ through $n$. Bob needs at least $a_i$ pieces of the $i$-th resource to build the spaceship....
0
{"tests": "{\"inputs\": [\"5 2 7\\n1 1\\n1 2\\n1 3\\n2 3\\n2 4\\n4 0\\n5 2\", \"5 2 7\\n1 1\\n1 2\\n1 3\\n3 3\\n2 4\\n4 4\\n5 2\", \"5 6 5\\n1 1\\n1 3\\n1 3\\n2 3\\n2 4\\n4 0\\n5 3\", \"5 8 7\\n2 1\\n1 2\\n1 3\\n5 3\\n2 7\\n4 4\\n5 2\", \"5 8 7\\n2 1\\n1 2\\n0 3\\n5 3\\n2 7\\n4 4\\n5 2\", \"5 6 5\\n0 1\\n1 3\\n1 3\\n2 ...
Emergency Evacuation The Japanese government plans to increase the number of inbound tourists to forty million in the year 2020, and sixty million in 2030. Not only increasing touristic appeal but also developing tourism infrastructure further is indispensable to accomplish such numbers. One possible enhancement on t...
0
{"tests": "{\"inputs\": [[[1, 2, 3, 4, 7], 5], [[1, 2, 3, 4, 7], 0], [[1, 1, 2, 2, 2], 2], [[1, 2, 3, 4], 5], [[1, 2, 3, 4], -1], [[1, 2, 3, 4], 2], [[1, 2, 3, 4], 0], [[1, 2, 3, 4], 1], [[1, 2, 3, 4], 3], [[], 1], [[], 0], [[1, 1, 1, 1], 2], [[1, 1, 1, 1], 1], [[1, 1, 1, 1], 0], [[1, 3, 5, 6], 0], [[1, 3, 5, 6], 2], [...
#### Task: Your job here is to write a function (`keepOrder` in JS/CoffeeScript, `keep_order` in Ruby/Crystal/Python, `keeporder` in Julia), which takes a sorted array `ary` and a value `val`, and returns the lowest index where you could insert `val` to maintain the sorted-ness of the array. The input array will alway...
0
{"tests": "{\"inputs\": [\"2\\n\", \"233\\n\", \"0\\n\", \"39393\\n\", \"14514\\n\", \"25252\\n\", \"4\\n\", \"82944\\n\", \"7\\n\", \"5\\n\", \"418\\n\", \"831\\n\", \"99998\\n\", \"1926\\n\", \"10\\n\", \"9\\n\", \"99681\\n\", \"100000\\n\", \"8\\n\", \"11\\n\", \"1\\n\", \"6\\n\", \"1317\\n\", \"161\\n\", \"68979\\n...
From beginning till end, this message has been waiting to be conveyed. For a given unordered multiset of n lowercase English letters ("multi" means that a letter may appear more than once), we treat all letters as strings of length 1, and repeat the following operation n - 1 times: * Remove any two elements s and t...
0
{"tests": "{\"inputs\": [\"2 4 1\\n1 2\\n6 3 4 5\\n5\\n\", \"3 2 2\\n7 5 4\\n2 9\\n7 1\\n\", \"3 3 3\\n1000 1000 1000\\n1000 1000 1000\\n1 1 1\\n\", \"3 3 1\\n2 3 4\\n4 5 6\\n5\\n\", \"3 3 1\\n2 3 4\\n4 5 6\\n5\\n\", \"3 3 3\\n1000 1000 1000\\n1000 1000 1000\\n1 1 1\\n\", \"3 3 1\\n2 3 4\\n4 7 6\\n5\\n\", \"3 3 3\\n100...
You are given three bags. Each bag contains a non-empty multiset of numbers. You can perform a number of operations on these bags. In one operation, you can choose any two non-empty bags, and choose one number from each of the bags. Let's say that you choose number $a$ from the first bag and number $b$ from the second ...
0
{"tests": "{\"inputs\": [[2, 6, 2], [1, 5, 1], [1, 5, 3], [0, 15, 3], [16, 15, 3], [2, 24, 22], [2, 2, 2], [2, 2, 1], [1, 15, 3], [15, 1, 3]], \"outputs\": [[12], [15], [5], [45], [0], [26], [2], [2], [35], [0]]}", "source": "taco"}
Your task is to make function, which returns the sum of a sequence of integers. The sequence is defined by 3 non-negative values: **begin**, **end**, **step**. If **begin** value is greater than the **end**, function should returns **0** *Examples* ~~~if-not:nasm ~~~ This is the first kata in the series: 1) Sum ...
0
{"tests": "{\"inputs\": [\"4 3\\n\", \"6 6\\n\", \"5 2\\n\", \"3 2\\n\", \"10 2\\n\", \"26 13\\n\", \"100 2\\n\", \"100 10\\n\", \"3 3\\n\", \"6 3\\n\", \"10 3\\n\", \"50 3\\n\", \"90 2\\n\", \"6 2\\n\", \"99 3\\n\", \"4 2\\n\", \"100 3\\n\", \"40 22\\n\", \"13 8\\n\", \"16 15\\n\", \"17 17\\n\", \"19 4\\n\", \"100 26\...
Innokentiy decides to change the password in the social net "Contact!", but he is too lazy to invent a new password by himself. That is why he needs your help. Innokentiy decides that new password should satisfy the following conditions: the length of the password must be equal to n, the password should consist onl...
0.125
{"tests": "{\"inputs\": [[[\":D\", \"T_T\", \":D\", \":(\"], true], [[\"T_T\", \":D\", \":(\", \":(\"], true], [[\":)\", \"T_T\", \":)\", \":D\", \":D\"], true], [[\":D\", \"T_T\", \":D\", \":(\"], false], [[\"T_T\", \":D\", \":(\", \":(\"], false], [[\":)\", \"T_T\", \":)\", \":D\", \":D\"], false], [[], false], [[], ...
## Emotional Sort ( ︶︿︶) You'll have a function called "**sortEmotions**" that will return an array of **emotions** sorted. It has two parameters, the first parameter called "**arr**" will expect an array of **emotions** where an **emotion** will be one of the following: - **:D** -> Super Happy - **:)** -> Happy - **...
0.125
{"tests": "{\"inputs\": [\"eternalalexandersookeustzeouuanisafqaqautomaton\\nnoiol\\n\", \"acacdddadaddcbbbbdacb\\nbabbbcadddacacdaddbdc\\n\", \"yz\\nzy\\n\", \"tqlrrtidhfpgevosrsya\\nysrsvgphitrrqtldfeoa\\n\", \"babbaaababbbbabbaaaababbbaabababbaabbaababbaaabaabbabaabbaababababbaabaaabaaaaababbaabaaaaabaabbabaaababbbb...
Kaavi, the mysterious fortune teller, deeply believes that one's fate is inevitable and unavoidable. Of course, she makes her living by predicting others' future. While doing divination, Kaavi believes that magic spells can provide great power for her to see the future. <image> Kaavi has a string T of length m and a...
0
{"tests": "{\"inputs\": [\"4 5\\n1 3 5 6 7\\n3 0 7 0 9\\n5 0 0 0 10\\n8 9 10 11 12\\n\", \"3 3\\n1 2 3\\n2 0 4\\n4 5 6\\n\", \"3 3\\n1 2 3\\n3 0 4\\n4 5 6\\n\", \"3 3\\n1 2 3\\n2 3 4\\n3 4 2\\n\", \"3 3\\n733 1305 1980\\n1283 1780 2328\\n2136 2791 3586\\n\", \"3 3\\n2999 3000 4000\\n3000 0 5000\\n4000 6000 8000\\n\", \...
In this problem, a $n \times m$ rectangular matrix $a$ is called increasing if, for each row of $i$, when go from left to right, the values strictly increase (that is, $a_{i,1}<a_{i,2}<\dots<a_{i,m}$) and for each column $j$, when go from top to bottom, the values strictly increase (that is, $a_{1,j}<a_{2,j}<\dots<a_{n...
0.25
{"tests": "{\"inputs\": [[\"\"], [\"A\"], [\"AA\"], [\"AAAABBBCCDAABBB\"], [\"AADD\"], [\"AAD\"], [\"ADD\"], [\"ABBCcAD\"], [[1, 2, 3, 3]], [[\"a\", \"b\", \"b\"]]], \"outputs\": [[[]], [[\"A\"]], [[\"A\"]], [[\"A\", \"B\", \"C\", \"D\", \"A\", \"B\"]], [[\"A\", \"D\"]], [[\"A\", \"D\"]], [[\"A\", \"D\"]], [[\"A\", \"B...
Implement the function unique_in_order which takes as argument a sequence and returns a list of items without any elements with the same value next to each other and preserving the original order of elements. For example: ```python unique_in_order('AAAABBBCCDAABBB') == ['A', 'B', 'C', 'D', 'A', 'B'] unique_in_order('...
0
{"tests": "{\"inputs\": [\"3\\n3 4 1\", \"5\\n2 1 2 1 2\", \"5\\n2 1 1 1 2\", \"5\\n3 1 1 1 1\", \"3\\n1 3 4\", \"3\\n3 5 1\", \"5\\n2 1 2 2 2\", \"3\\n3 5 2\", \"5\\n3 1 2 2 2\", \"3\\n3 5 3\", \"5\\n6 1 2 2 2\", \"3\\n3 7 3\", \"5\\n1 1 2 2 2\", \"3\\n3 1 3\", \"5\\n1 1 2 1 2\", \"5\\n1 1 2 1 4\", \"3\\n3 3 1\", \"5\...
There are N strings arranged in a row. It is known that, for any two adjacent strings, the string to the left is lexicographically smaller than the string to the right. That is, S_1<S_2<...<S_N holds lexicographically, where S_i is the i-th string from the left. At least how many different characters are contained in ...
0
{"tests": "{\"inputs\": [\"2 1\\n1 2\\n\", \"8 1\\n8 2\\n2 5\\n5 1\\n7 2\\n2 4\\n3 5\\n5 6\\n\", \"5 1\\n4 1\\n3 1\\n5 1\\n1 2\\n\", \"25 2\\n1 2\\n1 3\\n1 4\\n2 5\\n2 6\\n2 7\\n3 8\\n3 9\\n3 10\\n4 11\\n4 12\\n4 13\\n4 14\\n14 15\\n14 16\\n14 17\\n4 18\\n18 19\\n18 20\\n18 21\\n1 22\\n22 23\\n22 24\\n22 25\\n\", \"33 ...
Someone give a strange birthday present to Ivan. It is hedgehog — connected undirected graph in which one vertex has degree at least 3 (we will call it center) and all other vertices has degree 1. Ivan thought that hedgehog is too boring and decided to make himself k-multihedgehog. Let us define k-multihedgehog as fol...
0.625
{"tests": "{\"inputs\": [\"4\\nRURD\\n\", \"6\\nRRULDD\\n\", \"26\\nRRRULURURUULULLLDLDDRDRDLD\\n\", \"3\\nRLL\\n\", \"4\\nLRLR\\n\", \"5\\nLRDLR\\n\", \"10\\nDDRDUULUDD\\n\", \"1\\nD\\n\", \"5\\nLRDLR\\n\", \"10\\nDDRDUULUDD\\n\", \"1\\nD\\n\", \"5\\nLRRLD\\n\", \"6\\nDDLURR\\n\", \"5\\nRLDRL\\n\", \"10\\nLDRDUUDUDD\\...
Santa Claus has Robot which lives on the infinite grid and can move along its lines. He can also, having a sequence of m points p_1, p_2, ..., p_{m} with integer coordinates, do the following: denote its initial location by p_0. First, the robot will move from p_0 to p_1 along one of the shortest paths between them (pl...
0
{"tests": "{\"inputs\": [\"7\\n1\\n2\\n6\\n13\\n14\\n3620\\n10000\\n\", \"100\\n1\\n2\\n3\\n4\\n5\\n6\\n7\\n8\\n9\\n10\\n11\\n12\\n13\\n14\\n15\\n16\\n17\\n18\\n19\\n20\\n21\\n22\\n23\\n24\\n25\\n26\\n27\\n28\\n29\\n30\\n31\\n32\\n33\\n34\\n35\\n36\\n37\\n38\\n39\\n40\\n41\\n42\\n43\\n44\\n45\\n46\\n47\\n48\\n49\\n50\\...
The only difference between easy and hard versions is the maximum value of $n$. You are given a positive integer number $n$. You really love good numbers so you want to find the smallest good number greater than or equal to $n$. The positive integer is called good if it can be represented as a sum of distinct powers ...
0
{"tests": "{\"inputs\": [\"2\\n3\\n1 2 3\\n4\\n1 1 3 2\", \"2\\n3\\n1 2 3\\n4\\n2 1 3 2\", \"2\\n3\\n1 2 1\\n7\\n2 1 3 2\", \"2\\n3\\n1 2 2\\n1\\n1 0 3 3\", \"2\\n5\\n1 2 3\\n4\\n2 1 3 2\", \"2\\n2\\n1 2 1\\n7\\n1 1 3 2\", \"2\\n3\\n1 2 1\\n8\\n1 1 3 3\", \"2\\n5\\n2 2 2\\n7\\n1 1 3 3\", \"2\\n4\\n1 2 2\\n7\\n1 0 3 3\"...
Little Elephant from the Zoo of Lviv likes cards. He has N cards, each of which has one of 1000 colors. The colors are numbered from 1 to 1000. Little Elephant and Big Hippo are playing the following game. At first Little Elephant takes some subset of cards, and Big Hippo takes the rest of them. Here, Little Elephant c...
0.375
{"tests": "{\"inputs\": [\"10\\njcfdh 1000000\\nchk 1000000\\nkga 1000000\\nbeh 1000000\\ngeg 1000000\\nhaj 1000000\\nagah 1000000\\ndhk 1000000\\nhj 1000000\\ndb 1000000\\n5\\n1000000 1000000 1000000 1000000 1000000\\ndb\\n\", \"5\\nteamc 8\\nteamd 7\\nteame 15\\nteama 3\\nteamb 21\\n3\\n1 2 3\\nteamb\\n\", \"20\\ng 1...
Vasya plays the Need For Brake. He plays because he was presented with a new computer wheel for birthday! Now he is sure that he will win the first place in the championship in his favourite racing computer game! n racers take part in the championship, which consists of a number of races. After each race racers are a...
0
{"tests": "{\"inputs\": [[30], [15], [9999], [35353], [100], [1000000243], [142042158218941532125212890], [2679388715912901287113185885289513476], [640614569414659959863091616350016384446719891887887380], [2579111107964987025047536361483312385374008248282655401675211033926782006920415224913494809688581314878892733564]]...
# Fourier transformations are hard. Fouriest transformations are harder. This Kata is based on the SMBC Comic on fourier transformations. A fourier transformation on a number is one that converts the number to a base in which it has more `4`s ( `10` in base `6` is `14`, which has `1` four as opposed to none, hence, f...
0
{"tests": "{\"inputs\": [[432, 3554, 291, 28, 2], [5, 76, 4, 1, 0], [48, 192, 19, 2, 3], [1, 2, 1, 1, 0], [34, 172, 20, 1, 1], [10, 17, 2, 0, 1]], \"outputs\": [[112.2], [158.3], [39.6], [118.8], [69.7], [0.0]]}", "source": "taco"}
Passer ratings are the generally accepted standard for evaluating NFL quarterbacks. I knew a rating of 100 is pretty good, but never knew what makes up the rating. So out of curiosity I took a look at the wikipedia page and had an idea or my first kata: https://en.wikipedia.org/wiki/Passer_rating ## Formula There are...
0
{"tests": "{\"inputs\": [\"4 6\\n1 3 2\\n7 13 10\\n18 20 13\\n3 4 2\\n0\\n1\\n2\\n3\\n5\\n8\\n\", \"4 6\\n1 3 2\\n7 13 1\\n18 20 13\\n3 4 2\\n0\\n1\\n2\\n3\\n5\\n8\", \"4 6\\n1 4 2\\n8 13 1\\n18 20 12\\n3 4 2\\n0\\n1\\n2\\n3\\n5\\n8\", \"4 5\\n1 4 2\\n8 13 1\\n18 20 12\\n3 4 2\\n0\\n1\\n2\\n3\\n5\\n8\", \"4 5\\n1 4 0\\...
There is an infinitely long street that runs west to east, which we consider as a number line. There are N roadworks scheduled on this street. The i-th roadwork blocks the point at coordinate X_i from time S_i - 0.5 to time T_i - 0.5. Q people are standing at coordinate 0. The i-th person will start the coordinate 0 at...
0.75
{"tests": "{\"inputs\": [[\"LOVE\"], [\"love\"], [\"abcd\"], [\"ebcd\"], [\"Hello World!\"], [\"jrvz,\"]], \"outputs\": [[\"EVOL\"], [\"EVOL\"], [\"LOVE\"], [\"LOVE\"], [\"ELEEV VVOEE!\"], [\"OOOO,\"]]}", "source": "taco"}
### Task Yes, your eyes are no problem, this is toLoverCase (), not toLowerCase (), we want to make the world full of love. ### What do we need to do? You need to add a prototype function to the String, the name is toLoverCase. Function can convert the letters in the string, converted to "L", "O", "V", "E", ...
0
{"tests": "{\"inputs\": [\"1 1\\n1\\n\", \"2 2\\n1\\n2\\n\", \"3 5\\n1\\n4\\n20\\n50\\n300\\n\", \"4 5\\n2\\n4\\n30\\n100\\n1000\\n\", \"5 6\\n1\\n2\\n3\\n4\\n5\\n6\\n\", \"6 6\\n10\\n20\\n30\\n40\\n50\\n60\\n\", \"990 1\\n990\\n\", \"7 10\\n100\\n200\\n300\\n400\\n500\\n600\\n700\\n800\\n900\\n1000\\n\", \"8 10\\n50\\...
Jon Snow is on the lookout for some orbs required to defeat the white walkers. There are k different types of orbs and he needs at least one of each. One orb spawns daily at the base of a Weirwood tree north of the wall. The probability of this orb being of any kind is equal. As the north of wall is full of dangers, he...
0
{"tests": "{\"inputs\": [\"4 1\\n1 3 -1 -1 -1\\n1 2 -1 -1\\n1 4 -1 -1 -1 -1\\n1 3 -1 -1 -1\\n\", \"2 1\\n1 3 -1 1 -1\\n1 5 -1 -1 -1 -1 -1\\n\", \"5 4\\n1 2 2 -1\\n2 2 1 -1\\n3 4 4 4 4 -1\\n4 3 -1 -1 -1\\n3 5 -1 -1 -1 -1 -1\\n\", \"4 3\\n1 2 1 -1\\n2 1 -1\\n3 2 2 -1\\n3 2 1 -1\\n\", \"6 3\\n1 3 -1 2 -1\\n1 2 1 -1\\n2 3 ...
Piegirl has found a monster and a book about monsters and pies. When she is reading the book, she found out that there are n types of monsters, each with an ID between 1 and n. If you feed a pie to a monster, the monster will split into some number of monsters (possibly zero), and at least one colorful diamond. Monster...
0
{"tests": "{\"inputs\": [\"1001\", \"0111101111\", \"1000\", \"0111001111\", \"1010\", \"1010011111\", \"0010001111\", \"0010\", \"0010001011\", \"0001\", \"0010001001\", \"0110001001\", \"0010001000\", \"0010001100\", \"0000\", \"0110011100\", \"0010111110\", \"0010110111\", \"0110110011\", \"0001010011\", \"000001100...
Takahashi has an empty string S and a variable x whose initial value is 0. Also, we have a string T consisting of `0` and `1`. Now, Takahashi will do the operation with the following two steps |T| times. * Insert a `0` or a `1` at any position of S of his choice. * Then, increment x by the sum of the digits in the o...
0
{"tests": "{\"inputs\": [[0, 1, 0], [0, 1, 1], [0, 1, 2], [0, 0, 0], [0, 2, 1], [0, 0, 1], [0, 0, 2], [0, 2, 0], [0, 2, 2], [1, 0, 0], [1, 0, 1], [1, 0, 2], [1, 1, 0], [1, 1, 1], [1, 1, 2], [1, 2, 0], [1, 2, 1], [1, 2, 2], [2, 0, 0], [2, 0, 1], [2, 0, 2], [2, 1, 0], [2, 1, 1], [2, 1, 2], [2, 2, 0], [2, 2, 1], [2, 2, 2]...
Given 2 elevators (named "left" and "right") in a building with 3 floors (numbered `0` to `2`), write a function `elevator` accepting 3 arguments (in order): - `left` - The current floor of the left elevator - `right` - The current floor of the right elevator - `call` - The floor that called an elevator It should re...
0.25
{"tests": "{\"inputs\": [[45, 51], [1, 2], [-3, 2], [1, 1], [100, 100], [100, 80], [20, 19]], \"outputs\": [[\"45 is smaller than 51\"], [\"1 is smaller than 2\"], [\"-3 is smaller than 2\"], [\"1 is equal to 1\"], [\"100 is equal to 100\"], [\"100 is greater than 80\"], [\"20 is greater than 19\"]]}", "source": "taco"...
Write a function that accepts two parameters (a and b) and says whether a is smaller than, bigger than, or equal to b. Here is an example code: var noIfsNoButs = function (a,b) { if(a > b) return a + " is greater than " + b else if(a < b) return a + " is smaller than " + b else if(a == b) return a + " is equal t...
0
{"tests": "{\"inputs\": [\"3\\n2 3\\n1 3\\n\", \"5\\n2 3\\n5 3\\n4 3\\n1 3\\n\", \"5\\n2 1\\n3 2\\n4 3\\n5 4\\n\", \"10\\n5 3\\n9 2\\n7 1\\n3 8\\n4 1\\n1 9\\n10 1\\n8 9\\n6 2\\n\", \"3\\n2 1\\n3 2\\n\", \"10\\n2 7\\n8 2\\n9 8\\n1 9\\n4 1\\n3 4\\n6 3\\n10 6\\n5 10\\n\", \"5\\n4 2\\n3 1\\n3 4\\n3 5\\n\", \"7\\n3 6\\n3 1\...
Andryusha goes through a park each day. The squares and paths between them look boring to Andryusha, so he decided to decorate them. The park consists of n squares connected with (n - 1) bidirectional paths in such a way that any square is reachable from any other using these paths. Andryusha decided to hang a colored...
0
{"tests": "{\"inputs\": [\"sippuu\\n\", \"iphone\\n\", \"coffee\\n\", \"dceett\\n\", \"otjjmm\\n\", \"zkrrcc\\n\", \"mdihxy\\n\", \"xuquqw\\n\", \"ilvegx\\n\", \"tcdrzv\\n\", \"abccde\\n\", \"abcdee\\n\", \"abcccc\\n\", \"cofgee\", \"sjppvv\", \"uuppis\", \"ephoni\", \"cofgef\", \"uvppis\", \"eohoni\", \"fegfoc\", \"si...
A string of length 6 consisting of lowercase English letters is said to be coffee-like if and only if its 3-rd and 4-th characters are equal and its 5-th and 6-th characters are also equal. Given a string S, determine whether it is coffee-like. -----Constraints----- - S is a string of length 6 consisting of lowercas...
0.875
{"tests": "{\"inputs\": [\"11 3 2\\nooxxxoxxxoo\\n\", \"5 2 3\\nooxoo\\n\", \"5 1 0\\nooooo\\n\", \"16 4 3\\nooxxoxoxxxoxoxxo\\n\", \"11 3 1\\nooxxxoxxxoo\", \"11 3 1\\nooxxxooxxox\", \"11 3 1\\nxoxxooxxxoo\", \"16 4 3\\nooxxoxoxxyoxoxxo\", \"16 4 3\\noxxoxoxxxoxoxxoo\", \"11 3 1\\nxxxxoooxxoo\", \"16 4 3\\nooxxoxoxxyo...
Takahashi has decided to work on K days of his choice from the N days starting with tomorrow. You are given an integer C and a string S. Takahashi will choose his workdays as follows: - After working for a day, he will refrain from working on the subsequent C days. - If the i-th character of S is x, he will not work ...
0
{"tests": "{\"inputs\": [\"13\\n\", \"396\\n\", \"998\\n\", \"23333\\n\", \"8\\n\", \"49997\\n\", \"33\\n\", \"5\\n\", \"831\\n\", \"3939\\n\", \"10492\\n\", \"12\\n\", \"30000\\n\", \"20\\n\", \"1000\\n\", \"17\\n\", \"11\\n\", \"10001\\n\", \"49999\\n\", \"10000\\n\", \"14\\n\", \"99\\n\", \"1317\\n\", \"418\\n\", \"...
The Floral Clock has been standing by the side of Mirror Lake for years. Though unable to keep time, it reminds people of the passage of time and the good old days. On the rim of the Floral Clock are 2n flowers, numbered from 1 to 2n clockwise, each of which has a colour among all n possible ones. For each colour, the...
0
{"tests": "{\"inputs\": [[3], [5], [8], [-3], [-11], [-25], [0]], \"outputs\": [[\" 123\\n 123 \\n123 \"], [\" 12345\\n 12345 \\n 12345 \\n 12345 \\n12345 \"], [\" 12345678\\n 12345678 \\n 12345678 \\n 12345678 \\n 12345678 \\n 12345678 \\n 12345678 \\n12345678 \"...
###Task: You have to write a function **pattern** which returns the following Pattern(See Examples) upto n rows, where n is parameter. ####Rules/Note: * If the Argument is 0 or a Negative Integer then it should return "" i.e. empty string. * The length of each line = (2n-1). * Range of n is (-∞,100] ###Examples: pa...
0
{"tests": "{\"inputs\": [[\"1,2,3,4,5\"], [\"21,12,23,34,45\"], [\"-1,-2,3,-4,-5\"], [\"1,2,3,,,4,,5,,,\"], [\",,,,,1,2,3,,,4,,5,,,\"], [\"\"], [\",,,,,,,,\"]], \"outputs\": [[[1, 2, 3, 4, 5]], [[21, 12, 23, 34, 45]], [[-1, -2, 3, -4, -5]], [[1, 2, 3, 4, 5]], [[1, 2, 3, 4, 5]], [[]], [[]]]}", "source": "taco"}
Given a string containing a list of integers separated by commas, write the function string_to_int_list(s) that takes said string and returns a new list containing all integers present in the string, preserving the order. For example, give the string "-1,2,3,4,5", the function string_to_int_list() should return [-1,2,...
0
{"tests": "{\"inputs\": [\"3\\n1 1\\n3 1 2\\n\", \"3\\n1 1\\n3 1 3\\n\", \"3\\n1 1\\n2 0 0\\n\", \"2\\n1\\n487981126 805590708\\n\", \"5\\n1 1 1 4\\n28 0 0 0 0\\n\", \"2\\n1\\n91 0\\n\", \"10\\n1 1 1 1 1 1 1 1 1\\n64 0 0 0 0 0 0 0 0 0\\n\", \"50\\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 ...
Bandits appeared in the city! One of them is trying to catch as many citizens as he can. The city consists of $n$ squares connected by $n-1$ roads in such a way that it is possible to reach any square from any other square. The square number $1$ is the main square. After Sunday walk all the roads were changed to one-...
0.125
{"tests": "{\"inputs\": [\"3 3\\n###\\n#.#\\n###\\n\", \"3 3\\n###\\n###\\n###\\n\", \"4 3\\n###\\n###\\n###\\n###\\n\", \"5 7\\n.......\\n.#####.\\n.#.#.#.\\n.#####.\\n.......\\n\", \"3 4\\n####\\n#.##\\n####\\n\", \"5 8\\n........\\n.######.\\n.######.\\n.######.\\n........\\n\", \"3 3\\n...\\n...\\n...\\n\", \"8 8\\...
Student Andrey has been skipping physical education lessons for the whole term, and now he must somehow get a passing grade on this subject. Obviously, it is impossible to do this by legal means, but Andrey doesn't give up. Having obtained an empty certificate from a local hospital, he is going to use his knowledge of ...
0
{"tests": "{\"inputs\": [\"3\\n7 10 2\\n\", \"1\\n4\\n\", \"7\\n9 0 7 6 5 6 6\\n\", \"9\\n817044745 436084671 891247464 3109902 841573457 970042015 521926123 412995388 852139532\\n\", \"5\\n638276462 315720570 182863609 770736280 493952628\\n\", \"13\\n1 3 1 0 0 1 0 2 4 1 4 1 2\\n\", \"3\\n0 1 0\\n\", \"1\\n477717775\\...
Danny, the local Math Maniac, is fascinated by circles, Omkar's most recent creation. Help him solve this circle problem! You are given $n$ nonnegative integers $a_1, a_2, \dots, a_n$ arranged in a circle, where $n$ must be odd (ie. $n-1$ is divisible by $2$). Formally, for all $i$ such that $2 \leq i \leq n$, the ele...
0
{"tests": "{\"inputs\": [\"10 4 5\\n3 5 7 10\\n\", \"13 4 5\\n7 8 9 10\\n\", \"1 1 1\\n1\\n\", \"11 7 3\\n2 3 4 5 6 7 11\\n\", \"13 9 4\\n1 2 3 6 7 8 11 12 13\\n\", \"16 7 5\\n2 3 4 5 6 15 16\\n\", \"10 5 5\\n2 3 4 5 6\\n\", \"1000000000 2 1000000000\\n1 1000000000\\n\", \"1000000000000000000 2 1\\n1 100000000000000000...
Recently, Tokitsukaze found an interesting game. Tokitsukaze had $n$ items at the beginning of this game. However, she thought there were too many items, so now she wants to discard $m$ ($1 \le m \le n$) special items of them. These $n$ items are marked with indices from $1$ to $n$. In the beginning, the item with ind...
0.25
{"tests": "{\"inputs\": [\"3 1\\n0\", \"6 2\\n1\\n6\", \"6 2\\n2\\n6\", \"3 0\\n0\", \"3 0\\n-1\", \"6 2\\n4\\n6\", \"6 2\\n5\\n6\", \"6 1\\n5\\n6\", \"6 1\\n3\\n6\", \"6 1\\n3\\n0\", \"7 1\\n3\\n0\", \"7 1\\n3\\n1\", \"7 1\\n5\\n1\", \"7 1\\n5\\n0\", \"7 2\\n5\\n0\", \"5 1\\n1\", \"6 2\\n0\\n5\", \"4 2\\n1\\n4\", \"6 ...
You are a secret agent from the Intelligence Center of Peacemaking Committee. You've just sneaked into a secret laboratory of an evil company, Automated Crime Machines. Your mission is to get a confidential document kept in the laboratory. To reach the document, you need to unlock the door to the safe where it is kept...
0.875
{"tests": "{\"inputs\": [\"5\\n0 0 0 0 1\\n0 1 2 3 4\\n\", \"5\\n0 0 1 0 1\\n0 1 2 2 4\\n\", \"4\\n1 0 0 0\\n2 3 4 2\\n\", \"10\\n0 0 0 0 0 0 0 0 0 1\\n4 0 8 4 7 8 5 5 7 2\\n\", \"50\\n0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 1 1 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 1 1 0 0 0 1 0\\n28 4 33 22 4 35 36 31 42 25 50 33...
Valera's finally decided to go on holiday! He packed up and headed for a ski resort. Valera's fancied a ski trip but he soon realized that he could get lost in this new place. Somebody gave him a useful hint: the resort has n objects (we will consider the objects indexed in some way by integers from 1 to n), each obje...
0
{"tests": "{\"inputs\": [\"2\\n3 3\\n3 1 2\\n3 2 1\\n7 2\\n2 1 7 3 4 5 6\\n3 1\\n\", \"2\\n3 3\\n3 1 2\\n3 2 1\\n7 2\\n4 1 7 3 4 5 6\\n3 1\\n\", \"2\\n3 3\\n3 1 2\\n3 2 1\\n7 2\\n2 1 7 3 4 5 6\\n6 1\\n\", \"2\\n3 3\\n3 1 2\\n3 2 1\\n7 2\\n2 1 7 3 4 5 6\\n4 1\\n\", \"2\\n3 3\\n3 1 2\\n3 2 1\\n7 2\\n2 1 7 3 5 7 6\\n2 1\\...
Santa has to send presents to the kids. He has a large stack of $n$ presents, numbered from $1$ to $n$; the topmost present has number $a_1$, the next present is $a_2$, and so on; the bottom present has number $a_n$. All numbers are distinct. Santa has a list of $m$ distinct presents he has to send: $b_1$, $b_2$, ...,...
0
{"tests": "{\"inputs\": [\"10\\n99999954 99999947 99999912 99999920 99999980 99999928 99999908 99999999 99999927 99999957\\n15 97 18 8 82 21 73 15 28 75\\n\", \"50\\n1 2 7 8 4 9 1 8 3 6 7 2 10 10 4 2 1 7 9 10 10 1 4 7 5 6 1 6 6 2 5 4 5 10 9 9 7 5 5 7 1 3 9 6 2 3 9 10 6 3\\n29 37 98 68 71 45 20 38 88 34 85 33 55 80 99 2...
You need to execute several tasks, each associated with number of processors it needs, and the compute power it will consume. You have sufficient number of analog computers, each with enough processors for any task. Each computer can execute up to one task at a time, and no more than two tasks total. The first task ca...
0
{"tests": "{\"inputs\": [\"2 2\\n5 5\\n2 2\\n\", \"2 2\\n5 6\\n2 2\\n\", \"4 1\\n4 1 10 1\\n3 2 10 1\\n\", \"53 3\\n2 3 1 2 2 6 1 5 6 1 5 3 1 1 6 4 3 2 4 1 1 4 4 3 5 6 1 2 2 1 2 2 2 5 4 2 1 4 2 5 3 1 3 6 6 4 4 5 2 1 2 2 1\\n5 2 6 3 5 5 1 1 2 4 6 1 4 2 4 1 4 4 5 3 6 4 6 5 6 3 4 4 3 1 1 5 5 1 1 2 4 4 3 1 2 2 3 2 3 2 2 4 ...
Vova has taken his summer practice this year and now he should write a report on how it went. Vova has already drawn all the tables and wrote down all the formulas. Moreover, he has already decided that the report will consist of exactly $n$ pages and the $i$-th page will include $x_i$ tables and $y_i$ formulas. The p...
0
{"tests": "{\"inputs\": [[[1, 2, 3, 4, 5]], [[1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1]], [[1, 5, 2, 3, 1, 5, 2, 3, 1]], [[1, 5, 4, 8, 7, 11, 10, 14, 13]], [[0, 1]], [[4, 5, 6, 8, 3, 4, 5, 6, 8, 3, 4, 5, 6, 8, 3, 4]], [[4, 5, 3, -2, -1, 0, -2, -7, -6]], [[4, 5, 6, 5, 3, 2, 3, 4, 5, 6, 5, 3, 2, 3, 4, 5, 6, 5, 3...
In this kata, your task is to identify the pattern underlying a sequence of numbers. For example, if the sequence is [1, 2, 3, 4, 5], then the pattern is [1], since each number in the sequence is equal to the number preceding it, plus 1. See the test cases for more examples. A few more rules : pattern may contain neg...
0
{"tests": "{\"inputs\": [\"3\\n1 3\\n2 2\\n3 1\\n\", \"3\\n1 3\\n2 1\\n3 2\\n\", \"1\\n39 52\\n\", \"2\\n25 56\\n94 17\\n\", \"5\\n39 21\\n95 89\\n73 90\\n9 55\\n85 32\\n\", \"12\\n70 11\\n74 27\\n32 11\\n26 83\\n57 18\\n97 28\\n75 43\\n75 21\\n84 29\\n16 2\\n89 63\\n21 88\\n\", \"2\\n100 68\\n38 80\\n\", \"12\\n70 11\...
Duff is addicted to meat! Malek wants to keep her happy for n days. In order to be happy in i-th day, she needs to eat exactly a_{i} kilograms of meat. [Image] There is a big shop uptown and Malek wants to buy meat for her from there. In i-th day, they sell meat for p_{i} dollars per kilogram. Malek knows all numbers...
0.875
{"tests": "{\"inputs\": [[12, 0, \"am\"], [12, 1, \"am\"], [12, 2, \"am\"], [12, 3, \"am\"], [12, 4, \"am\"], [12, 5, \"am\"], [12, 6, \"am\"], [12, 7, \"am\"], [12, 8, \"am\"], [12, 9, \"am\"], [12, 10, \"am\"], [12, 11, \"am\"], [12, 12, \"am\"], [12, 13, \"am\"], [12, 14, \"am\"], [12, 15, \"am\"], [12, 16, \"am\"],...
Converting a normal (12-hour) time like "8:30 am" or "8:30 pm" to 24-hour time (like "0830" or "2030") sounds easy enough, right? Well, let's see if you can do it! You will have to define a function named "to24hourtime", and you will be given an hour (always in the range of 1 to 12, inclusive), a minute (always in th...
0.875
{"tests": "{\"inputs\": [[0], [1], [2], [3], [4], [5], [9], [10], [11], [100]], \"outputs\": [[0], [100], [200], [300], [400], [475], [855], [900], [990], [9000]]}", "source": "taco"}
In JavaScript, ```if..else``` is the most basic condition statement, it consists of three parts:```condition, statement1, statement2```, like this: ```python if condition: statementa else: statementb ``` It means that if the condition is true, then execute the statementa, otherwise execute the statementb.If the...
0
{"tests": "{\"inputs\": [\"3 2 4 10\\n1 2 3\\n4 5 6\\n7 8 9\\n1 2 3\\n6 5 4\\n7 8 9\\n11\\n4\\n7\\n5\\n10\\n9\\n2\\n1\\n3\\n8\", \"3 3 4 11\\n1 2 3\\n8 5 6\\n7 8 9\\n1 2 3\\n8 5 4\\n7 8 9\\n11\\n4\\n7\\n5\\n10\\n9\\n3\\n1\\n3\\n8\", \"3 5 4 11\\n1 2 3\\n8 5 6\\n7 8 9\\n1 2 3\\n8 5 4\\n7 8 9\\n11\\n4\\n7\\n5\\n10\\n9\\n...
Rabbits and cats are competing. The rules are as follows. First, each of the two animals wrote n2 integers on a piece of paper in a square with n rows and n columns, and drew one card at a time. Shuffle two cards and draw them one by one alternately. Each time a card is drawn, the two will mark it if the same number a...
0
{"tests": "{\"inputs\": [\"5\\n2 1 1 2 5\\n\", \"3\\n4 5 3\\n\", \"2\\n10 10\\n\", \"3\\n1 2 3\\n\", \"10\\n1 9 7 6 2 4 7 8 1 3\\n\", \"1\\n1\\n\", \"1\\n2\\n\", \"3\\n2 1 2\\n\", \"2\\n1 2\\n\", \"5\\n1 2 2 1 2\\n\", \"5\\n5 2 5 2 6\\n\", \"4\\n3 3 3 4\\n\", \"3\\n1 1 1\\n\", \"5\\n2 1 1 2 1\\n\", \"2\\n99999999 99999...
Vova's family is building the Great Vova Wall (named by Vova himself). Vova's parents, grandparents, grand-grandparents contributed to it. Now it's totally up to Vova to put the finishing touches. The current state of the wall can be respresented by a sequence $a$ of $n$ integers, with $a_i$ being the height of the $i...
0
{"tests": "{\"inputs\": [\"1 7\\n0000000\\n\", \"2 5\\n0010010\\n0010010\\n\", \"3 5\\n0100001\\n1001001\\n1010011\\n\", \"10 0\\n0111010\\n1101111\\n1111011\\n0111010\\n1101011\\n1101011\\n1110111\\n1010010\\n1111111\\n0010010\\n\", \"10 10\\n0101111\\n0000000\\n1111011\\n1011011\\n1011011\\n1111011\\n0010010\\n101001...
Denis, after buying flowers and sweets (you will learn about this story in the next task), went to a date with Nastya to ask her to become a couple. Now, they are sitting in the cafe and finally... Denis asks her to be together, but ... Nastya doesn't give any answer. The poor boy was very upset because of that. He w...
0
{"tests": "{\"inputs\": [\"2 3 5 8\\n\", \"4 6 7 13\\n\", \"233 233 10007 1\\n\", \"338792 190248 339821 152634074578\\n\", \"629260 663548 739463 321804928248\\n\", \"656229 20757 818339 523535590429\\n\", \"1000002 1000002 1000003 1000000000000\\n\", \"345 2746 1000003 5000000\\n\", \"802942 824238 836833 60550382432...
Given an integer $x$. Your task is to find out how many positive integers $n$ ($1 \leq n \leq x$) satisfy $$n \cdot a^n \equiv b \quad (\textrm{mod}\;p),$$ where $a, b, p$ are all known constants. -----Input----- The only line contains four integers $a,b,p,x$ ($2 \leq p \leq 10^6+3$, $1 \leq a,b < p$, $1 \leq x \leq...
0
{"tests": "{\"inputs\": [\"3 2\\n0 0\\n0 0\\n0 0\\n\", \"2 3\\n7 7 7\\n7 7 10\\n\", \"1 1\\n706\\n\", \"1 1\\n0\\n\", \"1 1\\n20\\n\", \"1 2\\n0 682\\n\", \"2 1\\n287\\n287\\n\", \"2 1\\n287\\n341\\n\", \"2 2\\n383 383\\n383 665\\n\", \"2 2\\n383 383\\n383 383\\n\", \"2 2\\n383 129\\n66 592\\n\", \"1 249\\n0 0 0 0 0 0 ...
Student Dima from Kremland has a matrix $a$ of size $n \times m$ filled with non-negative integers. He wants to select exactly one integer from each row of the matrix so that the bitwise exclusive OR of the selected integers is strictly greater than zero. Help him! Formally, he wants to choose an integers sequence $c...
0.875
{"tests": "{\"inputs\": [[153], [370], [371], [407], [1634], [8208], [9474], [54748], [92727], [93084], [548834], [1741725], [4210818], [9800817], [9926315], [24678050], [88593477], [146511208], [472335975], [534494836], [912985153], [4679307774], [115132219018763992565095597973971522401]], \"outputs\": [[true], [true]...
A Narcissistic Number is a number of length n in which the sum of its digits to the power of n is equal to the original number. If this seems confusing, refer to the example below. Ex: 153, where n = 3 (number of digits in 153) 1^(3) + 5^(3) + 3^(3) = 153 Write a method is_narcissistic(i) (in Haskell: isNarcissistic ...
0
{"tests": "{\"inputs\": [\"5\\n1 2\\n2 3\\n2 4\\n4 5\\nWBBWW\\n\", \"6\\n3 1\\n4 5\\n2 6\\n6 1\\n3 4\\nWWBWBB\\n\", \"1\\nB\\n\", \"20\\n2 19\\n5 13\\n6 4\\n15 6\\n12 19\\n13 19\\n3 11\\n8 3\\n3 20\\n16 13\\n7 14\\n3 17\\n7 8\\n10 20\\n11 9\\n8 18\\n8 2\\n10 1\\n6 13\\nWBWBWBBWWWBBWWBBBBBW\\n\", \"6\\n3 1\\n4 5\\n2 6\\...
There is a tree with N vertices numbered 1 through N. The i-th edge connects Vertex x_i and y_i. Each vertex is painted white or black. The initial color of Vertex i is represented by a letter c_i. c_i = W represents the vertex is white; c_i = B represents the vertex is black. A cat will walk along this tree. More spec...
0
{"tests": "{\"inputs\": [\"8\\n3 5 3 3 2 1 4 3\\n\", \"100\\n9 9 72 55 14 8 55 58 35 67 3 18 73 92 41 49 15 60 18 66 9 26 97 47 43 88 71 97 19 34 48 96 79 53 8 24 69 49 12 23 77 12 21 88 66 9 29 13 61 69 54 77 41 13 4 68 37 74 7 6 29 76 55 72 89 4 78 27 29 82 18 83 12 4 32 69 89 85 66 13 92 54 38 5 26 56 17 55 29 4 17 ...
Vasya has a multiset s consisting of n integer numbers. Vasya calls some number x nice if it appears in the multiset exactly once. For example, multiset \{1, 1, 2, 3, 3, 3, 4\} contains nice numbers 2 and 4. Vasya wants to split multiset s into two multisets a and b (one of which may be empty) in such a way that the q...
0
{"tests": "{\"inputs\": [\"10 1000000\\n307196 650096 355966 710719 99165 959865 500346 677478 614586 6538\\n\", \"4 0\\n1 4 4 4\\n\", \"3 4\\n1 2 7\\n\", \"10 20\\n6 4 7 10 4 5 5 3 7 10\\n\", \"2 0\\n182 2\\n\", \"4 100\\n1 1 10 10\\n\", \"4 42\\n1 1 1 1000000000\\n\", \"123 54564\\n38 44 41 42 59 3 95 15 45 32 44 69 ...
We all know the impressive story of Robin Hood. Robin Hood uses his archery skills and his wits to steal the money from rich, and return it to the poor. There are n citizens in Kekoland, each person has ci coins. Each day, Robin Hood will take exactly 1 coin from the richest person in the city and he will give it to t...
0
{"tests": "{\"inputs\": [\"6 8\\n....*...\\n...**...\\n..*****.\\n...**...\\n....*...\\n........\\n\", \"5 5\\n.*...\\n****.\\n.****\\n..**.\\n.....\\n\", \"5 5\\n.*...\\n***..\\n.*...\\n.*...\\n.....\\n\", \"3 3\\n*.*\\n.*.\\n*.*\\n\", \"3 3\\n.*.\\n***\\n**.\\n\", \"3 3\\n.*.\\n***\\n.*.\\n\", \"3 3\\n**.\\n***\\n.*....
A star is a figure of the following type: an asterisk character '*' in the center of the figure and four rays (to the left, right, top, bottom) of the same positive length. The size of a star is the length of its rays. The size of a star must be a positive number (i.e. rays of length $0$ are not allowed). Let's consid...
0
{"tests": "{\"inputs\": [\"3\\n2 2 2\\n1 1 1\\n\", \"1\\n100000000 100000000 100000000\\n100000000\\n\", \"1\\n100000000 100000000 100000000\\n1\\n\", \"4\\n6 7 8\\n8 8 8 12\\n\", \"1\\n1 1 1\\n100000000\\n\", \"3\\n1 1 1\\n2 2 2\\n\", \"9\\n10 20 30\\n5 5 5 5 5 5 45 45 45\\n\", \"20\\n43 36 6\\n6 49 22 40 17 48 44 19 ...
Do you know the story about the three musketeers? Anyway, you must help them now. Richelimakieu is a cardinal in the city of Bearis. He found three brave warriors and called them the three musketeers. Athos has strength a, Borthos strength b, and Caramis has strength c. The year 2015 is almost over and there are stil...
0
{"tests": "{\"inputs\": [\"10\\n1 -311 -186\\n1 -1070 -341\\n1 -1506 -634\\n1 688 1698\\n2 2 4\\n1 70 1908\\n2 1 2\\n2 2 4\\n1 -1053 1327\\n2 5 4\\n\", \"20\\n1 1208 1583\\n1 -258 729\\n1 -409 1201\\n1 194 1938\\n1 -958 1575\\n1 -1466 1752\\n2 1 2\\n2 1 2\\n2 6 5\\n1 -1870 1881\\n1 -2002 2749\\n1 -2002 2984\\n1 -2002 3...
In this problem at each moment you have a set of intervals. You can move from interval (a, b) from our set to interval (c, d) from our set if and only if c < a < d or c < b < d. Also there is a path from interval I1 from our set to interval I2 from our set if there is a sequence of successive moves starting from I1 so ...
0.375
{"tests": "{\"inputs\": [\"4 2 10\\n17:05:53\\n17:05:58\\n17:06:01\\n22:39:47\\n\", \"1 2 86400\\n00:00:00\\n\", \"5 2 40000\\n06:30:57\\n07:27:25\\n09:10:21\\n11:05:03\\n12:42:37\\n\", \"7 4 30000\\n05:08:54\\n05:35:53\\n06:03:20\\n06:17:50\\n09:29:46\\n11:35:29\\n14:49:02\\n\", \"10 3 30000\\n00:06:54\\n00:42:06\\n03...
Polycarpus got an internship in one well-known social network. His test task is to count the number of unique users who have visited a social network during the day. Polycarpus was provided with information on all user requests for this time period. For each query, we know its time... and nothing else, because Polycarp...
0
{"tests": "{\"inputs\": [\"3\\n4 6\\n.R....\\n......\\n......\\n.W....\\n4 4\\n.R.W\\n....\\n....\\n....\\n5 1\\nR\\nW\\nR\\nW\\nR\\n\", \"1\\n3 1\\n.\\nR\\n.\\n\", \"1\\n1 1\\n.\\n\", \"1\\n5 5\\n.....\\n.....\\n.....\\n.....\\n....W\\n\", \"1\\n5 5\\n.....\\n.....\\n.....\\n.....\\n....W\\n\", \"1\\n1 1\\n.\\n\", \"1...
Today we will be playing a red and white colouring game (no, this is not the Russian Civil War; these are just the colours of the Canadian flag). You are given an $n \times m$ grid of "R", "W", and "." characters. "R" is red, "W" is white and "." is blank. The neighbours of a cell are those that share an edge with it ...
0.125
{"tests": "{\"inputs\": [[[2, 4, 8, 1, 1, 15]], [[2, 2, 4, 8, 1, 1, 15]], [[2, 4, 8, 1, 1, 15, 15, 7, 7, 7, 7, 7, 7, 7]], [[2, 4, 8, 1, 1, 30, 30, 15, 15, 7, 7]], [[2, 4, 8, 1, 1, 119, 30, 30, 15, 15, 7, 7]], [[2, 4, 8, 1, 1, 32, 8, 8, 64, 30, 30, 15, 15, 7, 7]]], \"outputs\": [[16], [16], [30], [60], [119], [128]]}", ...
# Task CodeBots decided to make a gift for CodeMaster's birthday. They got a pack of candies of various sizes from the store, but instead of giving the whole pack they are trying to make the biggest possible candy from them. On each turn it is possible: ``` to pick any two candies of the same size and merge them ...
0
{"tests": "{\"inputs\": [[\"abba\"], [\"abaazaba\"], [\"abccba\"], [\"adfa\"], [\"ae\"], [\"abzy\"], [\"ababbaba\"], [\"sq\"], [\"kxbkwgyydkcbtjcosgikfdyhuuprubpwthgflucpyylbofvqxkkvqthmdnywpaunfihvupbwpruwfybdmgeuocltdaidyyewmbzm\"]], \"outputs\": [[true], [false], [true], [true], [false], [false], [true], [true], [tr...
Consider the string `"adfa"` and the following rules: ```Pearl a) each character MUST be changed either to the one before or the one after in alphabet. b) "a" can only be changed to "b" and "z" to "y". ``` From our string, we get: ```Pearl "adfa" -> ["begb","beeb","bcgb","bceb"] Another example: "bd" -> ["ae","ac","...
0
{"tests": "{\"inputs\": [\"3\\n3 1 2\\n\", \"4\\n-227347 -573134 -671045 11011\\n\", \"1\\n-895376\\n\", \"5\\n834472 -373089 441294 -633071 -957672\\n\", \"2\\n7 8\\n\", \"3\\n-771740 -255752 -300809\\n\", \"2\\n166442 61629\\n\", \"3\\n3 1 1\\n\", \"4\\n-227347 -573134 -1145358 11011\\n\", \"5\\n834472 -373089 441294...
The sequence is called ordered if it is non-decreasing or non-increasing. For example, sequnces [3, 1, 1, 0] and [1, 2, 3, 100] are ordered, but the sequence [1, 3, 3, 1] is not. You are given a sequence of numbers. You are to find it's shortest subsequence which is not ordered. A subsequence is a sequence that can be...
0
{"tests": "{\"inputs\": [\"8\\n1 1 2 2 3 4 5 8\\n\", \"6\\n1 1 1 2 2 2\\n\", \"5\\n1 2 4 4 4\\n\", \"20\\n1 1 1 1 2 2 2 2 4 4 4 4 8 8 8 8 8 10 10 11\\n\", \"20\\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2\\n\", \"25\\n1 1 1 1 2 2 2 2 4 4 4 4 8 8 8 8 13 15 16 16 31 32 36 41 55\\n\", \"25\\n1 1 1 1 2 2 2 2 4 4 4 4 8 8 8 9 1...
It can be shown that any positive integer x can be uniquely represented as x = 1 + 2 + 4 + ... + 2^{k} - 1 + r, where k and r are integers, k ≥ 0, 0 < r ≤ 2^{k}. Let's call that representation prairie partition of x. For example, the prairie partitions of 12, 17, 7 and 1 are: 12 = 1 + 2 + 4 + 5, 17 = 1 + 2 + 4 + 8 +...
0
{"tests": "{\"inputs\": [\"24 32 6 2 7 4\\n\", \"45 62 28 48 28 50\\n\", \"100 32 71 12 71 22\\n\", \"57 85 29 40 29 69\\n\", \"95 28 50 12 50 13\\n\", \"5 4 1 1 5 4\\n\", \"100 100 1 1 100 100\\n\", \"51 76 50 5 45 76\\n\", \"37 100 33 13 32 30\\n\", \"47 91 36 61 32 63\\n\", \"28 7 17 5 11 6\\n\", \"1 2 1 1 1 2\\n\",...
Two players play a game. The game is played on a rectangular board with n × m squares. At the beginning of the game two different squares of the board have two chips. The first player's goal is to shift the chips to the same square. The second player aims to stop the first one with a tube of superglue. We'll describe ...
0
{"tests": "{\"inputs\": [[\"pippi\", 3], [\"Peter Piper picked a peck of pickled peppers\", 14], [\"A-tisket a-tasket A green and yellow basket\", 43], [\"A-tisket a-tasket A green and yellow basket\", 45], [\"A-\", 1], [\"Chingel loves his Angel so much!!!\", 27], [\"I like ice-cream.Do you?\", 19], [\"Seems like you ...
Truncate the given string (first argument) if it is longer than the given maximum length (second argument). Return the truncated string with a `"..."` ending. Note that inserting the three dots to the end will add to the string length. However, if the given maximum string length num is less than or equal to 3, then t...
0.75
{"tests": "{\"inputs\": [[\"cat\", 1], [\"cat\", 0], [\"cat\", 4], [\"Amanda\", -2], [\"Amanda\", 0], [\"Amanda\", 2]], \"outputs\": [[true], [false], [false], [false], [true], [true]]}", "source": "taco"}
Check if it is a vowel(a, e, i, o, u,) on the ```n``` position in a string (the first argument). Don't forget about uppercase. A few cases: ``` { checkVowel('cat', 1) -> true // 'a' is a vowel checkVowel('cat', 0) -> false // 'c' is not a vowel checkVowel('cat', 4) -> false // this position doesn't exist } `...
0.875
{"tests": "{\"inputs\": [\"4 6 3\\n1 1 2 3\\n2 6 1 2\\n2 6 2 4\\n\", \"2 3 5\\n2 3 1 2\\n2 3 2 3\\n1 1 1 1\\n1 2 1 2\\n2 1 2 1\\n\", \"1 1 10\\n1 1 1 1\\n1 1 1 1\\n1 1 2 1\\n1 1 1 1\\n2 1 2 1\\n2 1 1 1\\n1 1 2 1\\n1 1 2 1\\n2 1 1 1\\n2 1 1 1\\n\", \"999999937 999999929 1\\n2 501178581 1 294328591\\n\", \"999999929 9999...
Amugae is in a very large round corridor. The corridor consists of two areas. The inner area is equally divided by $n$ sectors, and the outer area is equally divided by $m$ sectors. A wall exists between each pair of sectors of same area (inner or outer), but there is no wall between the inner area and the outer area. ...
0
{"tests": "{\"inputs\": [\"5\\n4 1 1 1 1\\n\", \"100\\n3 4 4 4 3 3 3 3 3 4 4 4 3 3 3 4 3 4 4 4 3 4 3 4 3 4 3 3 4 4 3 4 4 3 4 4 4 4 4 3 4 3 3 3 4 3 3 4 3 4 3 4 3 3 4 4 4 3 3 3 3 3 4 4 3 4 4 3 4 3 3 3 4 4 3 3 3 3 3 4 3 4 4 3 3 4 3 4 3 4 4 4 3 3 3 4 4 4 4 3\\n\", \"100\\n1 1 1 2 2 2 2 2 2 1 1 1 2 0 2 2 0 0 0 0 0 2 0 0 2 2...
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
0.125
{"tests": "{\"inputs\": [\"2 2\\n\", \"4 2\\n\", \"5 1\\n\", \"64 49\\n\", \"24 6\\n\", \"91 39\\n\", \"87 87\\n\", \"72 36\\n\", \"4237 4112\\n\", \"1815 1371\\n\", \"5000 1628\\n\", \"5000 3531\\n\", \"5000 2895\\n\", \"5000 539\\n\", \"5000 3576\\n\", \"3474 3427\\n\", \"3400 1203\\n\", \"4345 1015\\n\", \"2944 2468...
Finished her homework, Nastya decided to play computer games. Passing levels one by one, Nastya eventually faced a problem. Her mission is to leave a room, where a lot of monsters live, as quickly as possible. There are $n$ manholes in the room which are situated on one line, but, unfortunately, all the manholes are c...
0
{"tests": "{\"inputs\": [\"8\\n-7 9 6 9\\n-5 5 6 5\\n-10 -5 10 -5\\n-6 9 -9 -1\\n6 9 9 -6\\n-1 -2 -3 10\\n1 -2 3 10\\n-2 -3 2 -3\\n8\\n-7 9 5 7\\n-5 5 6 5\\n-10 -5 10 -5\\n-6 9 -9 -6\\n6 9 9 -6\\n-1 -2 -3 10\\n1 -2 3 10\\n-2 -3 2 -3\\n0\", \"8\\n-7 9 6 9\\n1 5 12 5\\n-10 -5 12 -5\\n-6 9 -9 -1\\n6 9 9 -1\\n-1 -2 -4 10\\...
Once upon a time when people still believed in magic, there was a great wizard Aranyaka Gondlir. After twenty years of hard training in a deep forest, he had finally mastered ultimate magic, and decided to leave the forest for his home. Arriving at his home village, Aranyaka was very surprised at the extraordinary des...
0
{"tests": "{\"inputs\": [\"4\\n2 5 6 8\\n\", \"3\\n1 2 3\\n\", \"5\\n1 2 4 6 20\\n\", \"2\\n6 9\\n\", \"5\\n3 4 7 8 8\\n\", \"5\\n4 9 11 12 16\\n\", \"7\\n4 13 14 19 29 61 92\\n\", \"8\\n1 1 2 4 8 14 15 31\\n\", \"23\\n1 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 65536 131072 262144 524288 1048576 209...
Arkady owns a non-decreasing array $a_1, a_2, \ldots, a_n$. You are jealous of its beauty and want to destroy this property. You have a so-called XOR-gun that you can use one or more times. In one step you can select two consecutive elements of the array, let's say $x$ and $y$, remove them from the array and insert th...
0
{"tests": "{\"inputs\": [\"4\\n2 6 7 8\\n\", \"1\\n0\\n\", \"100\\n75 78 155 169 264 333 369 416 439 486 503 541 557 635 726 745 814 845 899 914 943 1016 1090 1132 1191 1199 1258 1323 1423 1491 1557 1562 1583 1663 1707 1711 1729 1767 1819 1894 1916 1926 1953 2022 2042 2055 2061 2125 2135 2170 2183 2215 2310 2338 2377 2...
Omkar is standing at the foot of Celeste mountain. The summit is $n$ meters away from him, and he can see all of the mountains up to the summit, so for all $1 \leq j \leq n$ he knows that the height of the mountain at the point $j$ meters away from himself is $h_j$ meters. It turns out that for all $j$ satisfying $1 \l...
0
{"tests": "{\"inputs\": [\"5\\n40\\n220\\n222220\\n44033055505550666011011111090666077705550301110\\n000555555550000330000444000080000200004440000\", \"5\\n40\\n30\\n222220\\n44033055505550666011011111090666077705550301110\\n000555555550000330000444000080000200004440000\", \"5\\n10\\n220\\n222220\\n44033055505550666011...
Alice wants to send an email to Miku on her mobile phone. The only buttons that can be used for input on mobile phones are number buttons. Therefore, in order to input characters, the number buttons are pressed several times to input characters. The following characters are assigned to the number buttons of the mobile...
0.125
{"tests": "{\"inputs\": [\"A221033\\n\", \"A223635\\n\", \"A232726\\n\", \"A102210\\n\", \"A231010\\n\", \"A222222\\n\", \"A555555\\n\", \"A102222\\n\", \"A234567\\n\", \"A987654\\n\", \"A101010\\n\", \"A246810\\n\", \"A210210\\n\", \"A458922\\n\", \"A999999\\n\", \"A888888\\n\", \"A232232\\n\", \"A222210\\n\", \"A7102...
-----Input----- The only line of the input is a string of 7 characters. The first character is letter A, followed by 6 digits. The input is guaranteed to be valid (for certain definition of "valid"). -----Output----- Output a single integer. -----Examples----- Input A221033 Output 21 Input A223635 Output 22 I...
0
{"tests": "{\"inputs\": [\"2\\nabdc\\n3\\nbacb\\n2\", \"2\\nabdc\\n3\\nbcab\\n2\", \"2\\ncdba\\n3\\nbcab\\n2\", \"2\\ncdba\\n3\\nbcba\\n2\", \"2\\ncdba\\n3\\nbcba\\n1\", \"2\\ncdba\\n3\\nbcbb\\n1\", \"2\\nbdca\\n3\\nbcbb\\n1\", \"2\\nacdb\\n3\\nbcbb\\n1\", \"2\\naddb\\n3\\nbcbb\\n1\", \"2\\nbdda\\n3\\nbcbb\\n1\", \"2\\...
Read problems statements in Mandarin Chinese , Russian and Vietnamese as well. Akhil comes across a string S of length N. He started wondering about the smallest lexicographical subsequence of string S of length K. A subsequence of a string is formed by deleting some characters (possibly none) from it's original strin...
0.25
{"tests": "{\"inputs\": [\"2 3\\n0 0 0\\n-1 1 0\", \"2 3\\n0 0 -1\\n-1 1 0\", \"1 3\\n0 0 -1\\n-1 1 0\", \"2 2\\n1 1\\n1 0\", \"1 2\\n-1 0 -1\\n-1 0 0\", \"1 0\\n-1 0 -1\\n-1 0 0\", \"1 1\\n-1 1 -4\\n0 1 2\", \"1 3\\n-1 0 -1\\n-1 1 0\", \"1 3\\n-1 0 -1\\n-1 1 1\", \"1 3\\n-1 1 -1\\n-1 1 1\", \"1 3\\n-1 1 -1\\n-1 1 0\",...
There is a square grid with N rows and M columns. Each square contains an integer: 0 or 1. The square at the i-th row from the top and the j-th column from the left contains a_{ij}. Among the 2^{N+M} possible pairs of a subset A of the rows and a subset B of the columns, find the number of the pairs that satisfy the f...
0
{"tests": "{\"inputs\": [\"4\\n+\\n+\\n- 2\\n+\\n- 3\\n+\\n- 1\\n- 4\\n\", \"1\\n- 1\\n+\\n\", \"3\\n+\\n+\\n+\\n- 2\\n- 1\\n- 3\\n\", \"1\\n+\\n- 1\\n\", \"10\\n+\\n- 3\\n+\\n+\\n+\\n+\\n- 1\\n- 7\\n- 9\\n- 10\\n+\\n+\\n+\\n- 4\\n- 5\\n- 8\\n+\\n- 6\\n+\\n- 2\\n\", \"10\\n+\\n- 3\\n+\\n+\\n+\\n+\\n- 1\\n- 7\\n- 9\\n- ...
Tenten runs a weapon shop for ninjas. Today she is willing to sell $n$ shurikens which cost $1$, $2$, ..., $n$ ryo (local currency). During a day, Tenten will place the shurikens onto the showcase, which is empty at the beginning of the day. Her job is fairly simple: sometimes Tenten places another shuriken (from the a...
0
{"tests": "{\"inputs\": [[\"MSRSLLLRFLLFLLLLPPLP\", [\"M\"]], [\"MSRSLLLRFLLFLLLLPPLP\", [\"M\", \"L\"]], [\"MSRSLLLRFLLFLLLLPPLP\", [\"F\", \"S\", \"L\"]], [\"MSRSLLLRFLLFLLLLPPLP\"], [\"RLMADDFFGQTLMAAAAAAQERRR\", [\"A\"]], [\"RLMADDFFGQTLMAAAAAAQERRR\", [\"A\", \"R\", \"D\"]], [\"RLMADDFFGQTLMAAAAAAQERRR\"], [\"PLPP...
You are a biologist working on the amino acid composition of proteins. Every protein consists of a long chain of 20 different amino acids with different properties. Currently, you are collecting data on the percentage, various amino acids make up a protein you are working on. As manually counting the occurences of am...
0
{"tests": "{\"inputs\": [\"1 2 10\\n01\\n4 1 5 2\\n1 2 1 4\\n3 4 3 5\\n1 3 1 5\\n4 3 5 5\\n1 1 3 3\\n1 3 4 5\\n3 2 3 4\\n3 1 5 2\\n3 1 3 5\\n\", \"1 2 10\\n01\\n4 1 5 1\\n1 2 1 4\\n3 4 3 5\\n1 3 1 5\\n4 3 5 5\\n1 1 3 3\\n1 3 4 5\\n3 2 3 4\\n3 1 5 2\\n3 1 3 5\\n\", \"2 2 5\\n10\\n11\\n1 1 8 8\\n2 4 5 6\\n1 2 7 8\\n3 3 6...
Vus the Cossack has a field with dimensions n × m, which consists of "0" and "1". He is building an infinite field from this field. He is doing this in this way: 1. He takes the current field and finds a new inverted field. In other words, the new field will contain "1" only there, where "0" was in the current field...
0.125
{"tests": "{\"inputs\": [[7, \"Armenian Dram\"], [322, \"Armenian Dram\"], [25, \"Bangladeshi Taka\"], [730, \"Bangladeshi Taka\"], [37, \"Croatian Kuna\"], [40, \"Croatian Kuna\"], [197, \"Czech Koruna\"], [333, \"Czech Koruna\"], [768, \"Dominican Peso\"], [983, \"Dominican Peso\"]], \"outputs\": [[\"You now have 334...
You are currently in the United States of America. The main currency here is known as the United States Dollar (USD). You are planning to travel to another country for vacation, so you make it today's goal to convert your USD (all bills, no cents) into the appropriate currency. This will help you be more prepared for w...
0
{"tests": "{\"inputs\": [\"100 3\\n45 1 2 3 4 5 6 7 8 9 19 21 24 27 28 30 34 35 37 39 40 41 42 43 46 47 48 51 52 55 58 59 61 63 64 66 69 71 76 80 85 86 88 89 94 99\\n26 10 11 15 18 23 29 31 33 36 38 44 49 54 56 60 62 65 75 78 82 83 84 95 96 97 98\\n29 12 13 14 16 17 20 22 25 26 32 45 50 53 57 67 68 70 72 73 74 77 79 81...
Andrewid the Android is a galaxy-famous detective. He is now investigating the case of vandalism at the exhibition of contemporary art. The main exhibit is a construction of n matryoshka dolls that can be nested one into another. The matryoshka dolls are numbered from 1 to n. A matryoshka with a smaller number can be ...
0
{"tests": "{\"inputs\": [\"3\\n0 0 100 101\\n60 100 50\\n100 100 10\\n80 80 50\\n4\\n0 0 100 100\\n50 50 50\\n150 50 50\\n50 150 50\\n150 150 50\\n0\", \"3\\n0 0 100 101\\n60 100 50\\n100 110 10\\n25 80 50\\n4\\n0 0 100 100\\n50 50 50\\n150 50 50\\n50 150 50\\n150 150 50\\n0\", \"3\\n0 0 100 101\\n60 100 50\\n100 110 1...
Maki is a house cat. One day she fortunately came at a wonderful-looking dried fish. Since she felt not hungry on that day, she put it up in her bed. However there was a problem; a rat was living in her house, and he was watching for a chance to steal her food. To secure the fish during the time she is asleep, she deci...
0
{"tests": "{\"inputs\": [[[1, 2, 3, 4, 5], 3], [[5, 4, 3, 2, 1], 3], [[1, 2, 3, 1, 2], 3], [[1, 2, 3, -4, 0], 3], [[1, 2, 3, 4, 5], 0], [[1, 2, 3, 4, 5], 5], [[1, 2, 3, 4, 2], 4], [[2, 1, 2, 3, 4, 2], 2], [[2, 1, 2, 3, 4, 2], 3], [[2, 1, 2, 3, 4, 2], 4]], \"outputs\": [[[1, 2, 3]], [[3, 2, 1]], [[1, 2, 1]], [[1, -4, 0]...
Your task is to write a function that does just what the title suggests (so, fair warning, be aware that you are not getting out of it just throwing a lame bas sorting method there) with an array/list/vector of integers and the expected number `n` of smallest elements to return. Also: * the number of elements to be r...
0
{"tests": "{\"inputs\": [\"5 1\\n1 2 3 4 5\\n1 2\\n2 3\\n3 4\\n3 5\\n\", \"7 2\\n2 1 2 1 2 1 1\\n6 4\\n1 5\\n3 1\\n2 3\\n7 5\\n7 4\\n\", \"14 2\\n3 2 3 1 2 3 4 2 3 1 4 2 1 3\\n12 10\\n2 7\\n13 12\\n14 11\\n10 5\\n1 2\\n11 4\\n4 9\\n14 8\\n12 4\\n7 9\\n13 6\\n10 3\\n\", \"5 3\\n1 5 2 4 3\\n5 2\\n3 2\\n1 4\\n2 1\\n\", \"...
You are given a tree, which consists of $n$ vertices. Recall that a tree is a connected undirected graph without cycles. [Image] Example of a tree. Vertices are numbered from $1$ to $n$. All vertices have weights, the weight of the vertex $v$ is $a_v$. Recall that the distance between two vertices in the tree is th...
0
{"tests": "{\"inputs\": [\"1\\n\", \"7\\n\", \"13\\n\", \"3\\n\", \"8\\n\", \"16\\n\", \"11\\n\", \"2\\n\", \"5\\n\", \"10\\n\", \"9\\n\", \"15\\n\", \"4\\n\", \"12\\n\", \"6\\n\", \"14\\n\", \"2\\n\", \"11\\n\", \"15\\n\", \"13\\n\", \"14\\n\", \"16\\n\", \"12\\n\", \"5\\n\", \"9\\n\", \"8\\n\", \"4\\n\", \"6\\n\", \"...
Little Petya wanted to give an April Fools Day present to some scientists. After some hesitation he decided to give them the array that he got as a present in Codeforces Round #153 (Div.2). The scientists rejoiced at the gift and decided to put some important facts to this array. Here are the first few of the facts: Th...
0
{"tests": "{\"inputs\": [\"5\\noxxxx\\nx...x\\nx...x\\nx...x\\nxxxxo\\n\", \"6\\n.x.x..\\nx.x.x.\\n.xo..x\\nx..ox.\\n.x.x.x\\n..x.x.\\n\", \"3\\no.x\\noxx\\no.x\\n\", \"1\\no\\n\", \"2\\nox\\n.o\\n\", \"5\\n.xxo.\\n..oxo\\nx.oxo\\no..xo\\noooox\\n\", \"8\\n..xox.xo\\n..xxx.xx\\n........\\n........\\n........\\n...........
Igor has been into chess for a long time and now he is sick of the game by the ordinary rules. He is going to think of new rules of the game and become world famous. Igor's chessboard is a square of size n × n cells. Igor decided that simple rules guarantee success, that's why his game will have only one type of piece...
0
{"tests": "{\"inputs\": [[1, 1], [5, 1], [3, 4], [5, 6], [10, 10], [100, 3], [123, 456]], \"outputs\": [[2], [6], [35], [462], [184756], [176851], [448843261729071620474858205566477025894357385375655014634306680560209909590802545266425906052279365647506075241055256064119806400]]}", "source": "taco"}
You have a grid with `$m$` rows and `$n$` columns. Return the number of unique ways that start from the top-left corner and go to the bottom-right corner. You are only allowed to move right and down. For example, in the below grid of `$2$` rows and `$3$` columns, there are `$10$` unique paths: ``` o----o----o----o | ...
0
{"tests": "{\"inputs\": [\"3 3\\n1 1\\n3 1\\n2 2\\n\", \"5 2\\n1 5\\n5 1\\n\", \"100000 1\\n300 400\\n\", \"10 4\\n2 8\\n1 8\\n9 8\\n6 9\\n\", \"30 30\\n3 13\\n27 23\\n18 24\\n18 19\\n14 20\\n7 10\\n27 13\\n20 27\\n11 1\\n21 10\\n2 9\\n28 12\\n29 19\\n28 27\\n27 29\\n30 12\\n27 2\\n4 5\\n8 19\\n21 2\\n24 27\\n14 22\\n2...
Vasya has the square chessboard of size n × n and m rooks. Initially the chessboard is empty. Vasya will consequently put the rooks on the board one after another. The cell of the field is under rook's attack, if there is at least one rook located in the same row or in the same column with this cell. If there is a roo...
0.625
{"tests": "{\"inputs\": [\"1\\n1 1 1 1\", \"2\\n2 4 25 104\\n1 9 7 321\", \"2\\n2 4 25 28\\n1 9 13 321\", \"2\\n2 4 4 51\\n1 4 13 252\", \"2\\n3 4 4 51\\n2 4 13 335\", \"2\\n3 4 4 51\\n2 4 13 360\", \"2\\n2 4 24 306\\n1 9 7 321\", \"8\\n2 9 297 297\\n8 6 359 211\\n8 16 28 233\\n7 9 113 143\\n3 18 315 190\\n10 18 277 30...
Problem Neat lives on the world line for a total of 360 days until the 30th of every month for 1 year and 12 months. In that world, N consecutive holidays with the same schedule were applied to people all over the world every year. Consecutive holidays i are consecutive Vi days starting from Mi month Di day. NEET is ...
0
{"tests": "{\"inputs\": [\"4\\n1 2 2 1\\n\", \"5\\n1 3 2 2 5\\n\", \"1\\n1\\n\", \"10\\n1 1 1 1 1 1 1 1 1 1\\n\", \"10\\n1 9 7 6 2 4 7 8 1 3\\n\", \"100\\n82 51 81 14 37 17 78 92 64 15 8 86 89 8 87 77 66 10 15 12 100 25 92 47 21 78 20 63 13 49 41 36 41 79 16 87 87 69 3 76 80 60 100 49 70 59 72 8 38 71 45 97 71 14 76 54...
A student of z-school found a kind of sorting called z-sort. The array a with n elements are z-sorted if two conditions hold: a_{i} ≥ a_{i} - 1 for all even i, a_{i} ≤ a_{i} - 1 for all odd i > 1. For example the arrays [1,2,1,2] and [1,1,1,1] are z-sorted while the array [1,2,3,4] isn’t z-sorted. Can you make t...
0
{"tests": "{\"inputs\": [\"7\\nshf\\nsells\\nsea\\nshells\\nby\\nthe\\nseashore\", \"7\\nshf\\nsells\\nsea\\nshells\\nby\\nteh\\nseashore\", \"7\\nshf\\nsells\\nsea\\nshells\\nby\\nthd\\nseashore\", \"7\\nshf\\nsells\\nsea\\nshells\\nbx\\nthd\\nseashore\", \"7\\nshf\\nsells\\naes\\nshells\\nbx\\nthd\\nseashore\", \"7\\...
Problem Here is a list of strings. Let's take a break and play with shiritori. Shiritori is performed according to the following rules. 1. First of all, select one of your favorite strings from the list and exclude that string from the list. 2. Next, select one character string from the list in which the last charact...
0.125
{"tests": "{\"inputs\": [\"87654\\n30\\n\", \"87654\\n138\\n\", \"87654\\n45678\\n\", \"31415926535\\n1\\n\", \"1\\n31415926535\\n\", \"100000000000\\n1\\n\", \"100000000000\\n100000000000\\n\", \"100000000000\\n2\\n\", \"100000000000\\n3\\n\", \"100000000000\\n50000000000\\n\", \"100000000000\\n50000000001\\n\", \"100...
For integers b (b \geq 2) and n (n \geq 1), let the function f(b,n) be defined as follows: - f(b,n) = n, when n < b - f(b,n) = f(b,\,{\rm floor}(n / b)) + (n \ {\rm mod} \ b), when n \geq b Here, {\rm floor}(n / b) denotes the largest integer not exceeding n / b, and n \ {\rm mod} \ b denotes the remainder of n divid...
0.375
{"tests": "{\"inputs\": [\"9\\n2\\n3\\n1\\n\", \"5\\n5\\n2\\n20\\n\", \"19\\n3\\n4\\n2\\n\", \"1845999546\\n999435865\\n1234234\\n2323423\\n\", \"1604353664\\n1604353665\\n9993432\\n1\\n\", \"777888456\\n1\\n98\\n43\\n\", \"1162261467\\n3\\n1\\n2000000000\\n\", \"1000000000\\n1999999999\\n789987\\n184569875\\n\", \"200...
Right now she actually isn't. But she will be, if you don't solve this problem. You are given integers n, k, A and B. There is a number x, which is initially equal to n. You are allowed to perform two types of operations: Subtract 1 from x. This operation costs you A coins. Divide x by k. Can be performed only if x...
0