question
stringlengths
29
1.88k
test_input
listlengths
0
10
test_output
listlengths
0
10
test_time_limit
int64
1
1
test_method
stringclasses
1 value
While playing with geometric figures Alex has accidentally invented a concept of a $n$-th order rhombus in a cell grid. A $1$-st order rhombus is just a square $1 \times 1$ (i.e just a cell). A $n$-th order rhombus for all $n \geq 2$ one obtains from a $n-1$-th order rhombus adding all cells which have a common side ...
[ "1\n", "2\n", "3\n", "11\n", "21\n", "31\n", "41\n", "51\n", "100\n", "34\n" ]
[ "1", "5", "13", "221", "841", "1861", "3281", "5101", "19801", "2245" ]
1
stdio
VK news recommendation system daily selects interesting publications of one of n disjoint categories for each user. Each publication belongs to exactly one category. For each category i batch algorithm selects a_i publications. The latest A/B test suggests that users are reading recommended publications more actively ...
[ "5\n1000000000 1000000000 1000000000 1000000000 1000000000\n100000 100000 100000 100000 100000\n", "10\n14 31 50 67 42 44 86 82 35 63\n76 17 26 44 60 54 50 73 71 70\n", "10\n4 4 1 2 2 2 5 4 1 5\n28 81 36 44 2 40 39 43 36 33\n", "10\n69564153 558821634 273092444 121621442 354953668 157021146 918149509 90215990...
[ "1000000\n", "0\n", "593\n", "0\n", "0\n", "0\n", "0\n", "0\n", "66248\n", "0\n" ]
1
stdio
You are given three strings A, B and C. Check whether they form a word chain. More formally, determine whether both of the following are true: - The last character in A and the initial character in B are the same. - The last character in B and the initial character in C are the same. If both are true, print YES. Othe...
[ "rng gorilla apple\n", "yakiniku unagi sushi\n", "a a a\n", "aaaaaaaaab aaaaaaaaaa aaaaaaaaab\n", "a a `", "baaaa`aaaa aabaaaaaaa aaaaa`aaab", "rnh gorilla apple", "aaaaaaaaab aaaaaaaaaa aaaaa`aaab", "ybkiniku unagi sushi", "a b a" ]
[ "YES\n", "NO\n", "YES\n", "NO\n", "NO\n", "YES\n", "NO\n", "NO\n", "NO\n", "NO\n" ]
1
stdio
I assume most of you are familiar with the ancient legend of the rice (but I see wikipedia suggests [wheat](https://en.wikipedia.org/wiki/Wheat_and_chessboard_problem), for some reason) problem, but a quick recap for you: a young man asks as a compensation only `1` grain of rice for the first square, `2` grains for the...
[]
[]
1
stdio
# Task Elections are in progress! Given an array of numbers representing votes given to each of the candidates, and an integer which is equal to the number of voters who haven't cast their vote yet, find the number of candidates who still have a chance to win the election. The winner of the election must secure stri...
[]
[]
1
stdio
You have a digit sequence S of length 4. You are wondering which of the following formats S is in: - YYMM format: the last two digits of the year and the two-digit representation of the month (example: 01 for January), concatenated in this order - MMYY format: the two-digit representation of the month and the last tw...
[ "1905\n", "0112\n", "1700\n", "0101\n", "1312\n", "0348\n", "9999\n", "0001\n", "0000\n", "0100\n" ]
[ "YYMM\n", "AMBIGUOUS\n", "NA\n", "AMBIGUOUS\n", "YYMM\n", "MMYY\n", "NA\n", "YYMM\n", "NA\n", "MMYY\n" ]
1
stdio
This program tests the life of an evaporator containing a gas. We know the content of the evaporator (content in ml), the percentage of foam or gas lost every day (evap_per_day) and the threshold (threshold) in percentage beyond which the evaporator is no longer useful. All numbers are strictly positive. The program...
[]
[]
1
stdio
According to a new ISO standard, a flag of every country should have a chequered field n × m, each square should be of one of 10 colours, and the flag should be «striped»: each horizontal row of the flag should contain squares of the same colour, and the colours of adjacent horizontal rows should be different. Berland'...
[ "10 10\n2222222222\n5555555555\n0000000000\n4444444444\n1111111111\n3333333393\n3333333333\n5555555555\n0000000000\n8888888888\n", "100 1\n3\n6\n4\n3\n0\n2\n8\n7\n3\n2\n1\n7\n1\n3\n2\n3\n6\n9\n0\n8\n5\n9\n7\n9\n2\n1\n4\n5\n1\n9\n2\n5\n1\n4\n6\n4\n9\n1\n0\n2\n1\n4\n7\n1\n4\n8\n0\n9\n2\n1\n6\n2\n8\n6\n9\n5\n8\n6\n4...
[ "NO\n", "YES\n", "YES\n", "NO\n", "YES\n", "YES\n", "YES\n", "NO\n", "NO\n", "YES\n" ]
1
stdio
Ivan recently bought a detective book. The book is so interesting that each page of this book introduces some sort of a mystery, which will be explained later. The $i$-th page contains some mystery that will be explained on page $a_i$ ($a_i \ge i$). Ivan wants to read the whole book. Each day, he reads the first page ...
[ "9\n1 3 3 6 7 6 8 8 9\n", "1\n1\n", "10\n1 3 4 5 5 6 7 8 9 10\n", "10\n4 9 4 10 6 8 9 8 9 10\n", "15\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n", "17\n9 4 3 6 7 6 8 8 9 10 11 12 13 14 15 16 17\n", "13\n1 2 3 4 5 6 7 8 9 10 11 12 13\n", "12\n1 2 3 4 5 6 7 8 9 10 11 12\n", "11\n1 2 3 4 5 6 7 8 9 10 11\n",...
[ "4\n", "1\n", "7\n", "1\n", "15\n", "9\n", "13\n", "12\n", "11\n", "3\n" ]
1
stdio
In this kata, the number 0 is infected. You are given a list. Every turn, any item in the list that is adjacent to a 0 becomes infected and transforms into a 0. How many turns will it take for the whole list to become infected? ``` [0,1,1,0] ==> [0,0,0,0] All infected in 1 turn. [1,1,0,1,1] --> [1,0,0,0,1] --> [0,0,...
[]
[]
1
stdio
Gargari got bored to play with the bishops and now, after solving the problem about them, he is trying to do math homework. In a math book he have found k permutations. Each of them consists of numbers 1, 2, ..., n in some order. Now he should find the length of the longest common subsequence of these permutations. Can...
[ "4 3\n1 4 2 3\n4 1 2 3\n1 2 4 3\n", "6 3\n2 5 1 4 6 3\n5 1 4 3 2 6\n5 4 2 6 3 1\n", "41 4\n24 15 17 35 13 41 4 14 23 5 8 16 21 18 30 36 6 22 11 29 26 1 40 31 7 3 32 10 28 38 12 20 39 37 34 19 33 27 2 25 9\n22 13 25 24 38 35 29 12 15 8 11 37 3 19 4 23 18 32 30 40 36 21 16 34 27 9 5 41 39 2 14 17 31 33 26 7 1 10 ...
[ "3\n", "3\n", "4\n", "1\n", "3\n", "4\n", "4\n", "7\n", "4", "3" ]
1
stdio
Failed Filter - Bug Fixing #3 Oh no, Timmy's filter doesn't seem to be working? Your task is to fix the FilterNumber function to remove all the numbers from the string. Write your solution by modifying this code: ```python def filter_numbers(string): ``` Your solution should implemented in the function "filter_num...
[]
[]
1
stdio
From "ftying rats" to urban saniwation workers - can synthetic biology tronsform how we think of pigeons? The upiquitous pigeon has long been viewed as vermin - spleading disease, scavenging through trush, and defecating in populous urban spases. Yet they are product of selextive breeding for purposes as diverse as r...
[ "5\n1 2 3 4 5\n", "6\n6 12 3 15 9 18\n", "6\n28 4 13 29 17 8\n", "9\n23 1 2 26 9 11 23 10 26\n", "7\n18 29 23 23 1 14 5\n", "5\n22 19 19 16 14\n", "9\n17 16 8 13 6 29 22 27 18\n", "6\n12 12 29 10 30 32\n", "7\n31 1 19 3 11 20 31\n", "5\n27 30 8 32 3\n" ]
[ "4\n", "2\n", "11\n", "5\n", "24\n", "31\n", "16\n", "25\n", "20\n", "13\n" ]
1
stdio
The only difference between easy and hard versions is the number of elements in the array. You are given an array $a$ consisting of $n$ integers. In one move you can choose any $a_i$ and divide it by $2$ rounding down (in other words, in one move you can set $a_i := \lfloor\frac{a_i}{2}\rfloor$). You can perform such...
[ "5 3\n1 2 2 4 5\n", "5 3\n1 2 3 4 5\n", "5 3\n1 2 3 3 3\n", "1 1\n1337\n", "50 2\n72548 51391 1788 171949 148789 151619 19225 8774 52484 74830 20086 51129 151145 87650 108005 112019 126739 124087 158096 59027 34500 87415 115058 194160 171792 136832 1114 112592 171746 199013 101484 182930 185656 154861 19145...
[ "1\n", "2\n", "0\n", "0\n", "12\n", "0\n", "0\n", "79\n", "3\n", "7\n" ]
1
stdio
In this Kata, we are going to determine if the count of each of the characters in a string can be equal if we remove a single character from that string. For example: ``` solve('abba') = false -- if we remove any character, the count of each character will not be equal. solve('abbba') = true -- if we remove one b, the...
[]
[]
1
stdio
In some other world, today is the day before Christmas Eve. Mr. Takaha is buying N items at a department store. The regular price of the i-th item (1 \leq i \leq N) is p_i yen (the currency of Japan). He has a discount coupon, and can buy one item with the highest price for half the regular price. The remaining N-1 ite...
[ "3\n4980\n7980\n6980\n", "4\n4320\n4320\n4320\n4320\n", "2\n100\n100\n", "10\n10000\n10000\n10000\n10000\n10000\n10000\n10000\n10000\n10000\n10000\n", "5\n958\n5068\n2200\n8118\n4030\n", "6\n798\n3972\n7548\n2966\n4556\n1280\n", "7\n7132\n5170\n808\n8052\n806\n3680\n3820\n", "8\n3468\n1436\n912\n5896\...
[ "15950\n", "15120\n", "150\n", "95000\n", "16315\n", "17346\n", "25442\n", "23132\n", "35231\n", "57638\n" ]
1
stdio
Welcome young Jedi! In this Kata you must create a function that takes an amount of US currency in `cents`, and returns a dictionary/hash which shows the least amount of coins used to make up that amount. The only coin denominations considered in this exercise are: `Pennies (1¢), Nickels (5¢), Dimes (10¢) and Quarters ...
[]
[]
1
stdio
Mahmoud has an array a consisting of n integers. He asked Ehab to find another array b of the same length such that: b is lexicographically greater than or equal to a. b_{i} ≥ 2. b is pairwise coprime: for every 1 ≤ i < j ≤ n, b_{i} and b_{j} are coprime, i. e. GCD(b_{i}, b_{j}) = 1, where GCD(w, z) is the greates...
[ "5\n2 3 5 4 13\n", "3\n10 3 7\n", "5\n7 10 2 5 5\n", "7\n20 9 7 6 7 9 15\n", "10\n5 3 2 2 3 3 3 4 2 5\n", "3\n3 18 2\n", "3\n3 18 2\n", "7\n20 9 7 6 7 9 15\n", "5\n7 10 2 5 5\n", "10\n5 3 2 2 3 3 3 4 2 5\n" ]
[ "2 3 5 7 11 ", "10 3 7 ", "7 10 3 11 13 ", "20 9 7 11 13 17 19 ", "5 3 2 7 11 13 17 19 23 29 ", "3 19 2 ", "3 19 2 ", "20 9 7 11 13 17 19 ", "7 10 3 11 13 ", "5 3 2 7 11 13 17 19 23 29 " ]
1
stdio
You are given two positive integers ```a``` and ```b```. You can perform the following operations on ```a``` so as to obtain ```b``` : ``` (a-1)/2 (if (a-1) is divisible by 2) a/2 (if a is divisible by 2) a*2 ``` ```b``` will always be a power of 2. You are to write a function ```operation(a,b)``` that effici...
[]
[]
1
stdio
Dreamoon likes sequences very much. So he created a problem about the sequence that you can't find in OEIS: You are given two integers d, m, find the number of arrays a, satisfying the following constraints: * The length of a is n, n ≥ 1 * 1 ≤ a_1 < a_2 < ... < a_n ≤ d * Define an array b of length n as foll...
[ "10\n1 1000000000\n2 999999999\n3 99999998\n4 9999997\n5 999996\n10 99995\n7 9994\n8 993\n9 92\n10 1\n", "10\n1 1000000000\n2 999999999\n3 99999998\n4 9999997\n5 999996\n10 99995\n7 9994\n8 993\n12 92\n19 1\n", "10\n1 1000000000\n2 999999999\n3 99999998\n4 9999997\n5 999996\n6 99995\n5 9994\n8 993\n9 92\n10 1\n...
[ "1\n3\n5\n11\n17\n119\n29\n59\n89\n0\n", "1\n3\n5\n11\n17\n119\n29\n59\n87\n0\n", "1\n3\n5\n11\n17\n23\n17\n59\n89\n0\n", "1\n3\n5\n11\n89\n119\n29\n59\n89\n0\n", "1\n3\n5\n11\n17\n119\n89\n59\n87\n0\n", "1\n3\n5\n11\n17\n119\n11\n59\n89\n0\n", "1\n3\n5\n11\n17\n119\n11\n179\n89\n0\n", "1\n3\n5\n11\n1...
1
stdio
Welcome to PC Koshien, players. Physical condition management is important to participate in the event. It is said that at the turn of the season when the temperature fluctuates greatly, it puts a strain on the body and it is easy to catch a cold. The day you should be careful about is the day when the difference betwe...
[ "30 19\n39 20\n19 18\n4 20\n22 21\n23 10\n10 -10", "30 19\n39 20\n19 18\n4 20\n22 21\n23 10\n15 -10", "30 19\n39 1\n19 18\n4 20\n22 21\n23 10\n15 -10", "30 19\n39 1\n19 18\n2 20\n22 21\n23 10\n15 -10", "30 19\n39 1\n19 18\n2 20\n43 21\n23 10\n15 -10", "30 31\n39 1\n19 18\n2 20\n43 21\n23 10\n15 -10", "3...
[ "11\n19\n1\n-16\n1\n13\n20\n", "11\n19\n1\n-16\n1\n13\n25\n", "11\n38\n1\n-16\n1\n13\n25\n", "11\n38\n1\n-18\n1\n13\n25\n", "11\n38\n1\n-18\n22\n13\n25\n", "-1\n38\n1\n-18\n22\n13\n25\n", "-1\n38\n1\n-18\n22\n13\n28\n", "-1\n37\n1\n-18\n22\n13\n28\n", "-1\n37\n1\n-21\n22\n13\n28\n", "-1\n39\n1\n-2...
1
stdio
The only difference between easy and hard versions is the number of elements in the array. You are given an array $a$ consisting of $n$ integers. In one move you can choose any $a_i$ and divide it by $2$ rounding down (in other words, in one move you can set $a_i := \lfloor\frac{a_i}{2}\rfloor$). You can perform such...
[ "5 3\n1 2 2 4 5\n", "5 3\n1 2 3 4 5\n", "5 3\n1 2 3 3 3\n", "1 1\n1337\n", "50 2\n72548 51391 1788 171949 148789 151619 19225 8774 52484 74830 20086 51129 151145 87650 108005 112019 126739 124087 158096 59027 34500 87415 115058 194160 171792 136832 1114 112592 171746 199013 101484 182930 185656 154861 19145...
[ "1\n", "2\n", "0\n", "0\n", "12\n", "0\n", "0\n", "79\n", "3\n", "7\n" ]
1
stdio
Many people choose to obfuscate their email address when displaying it on the Web. One common way of doing this is by substituting the `@` and `.` characters for their literal equivalents in brackets. Example 1: ``` user_name@example.com => user_name [at] example [dot] com ``` Example 2: ``` af5134@borchmore.edu => a...
[]
[]
1
stdio
Check your arrows You have a quiver of arrows, but some have been damaged. The quiver contains arrows with an optional range information (different types of targets are positioned at different ranges), so each item is an arrow. You need to verify that you have some good ones left, in order to prepare for battle: ```py...
[]
[]
1
stdio
In this Kata, you will sort elements in an array by decreasing frequency of elements. If two elements have the same frequency, sort them by increasing value. More examples in test cases. Good luck! Please also try [Simple time difference](https://www.codewars.com/kata/5b76a34ff71e5de9db0000f2) Write your solutio...
[]
[]
1
stdio
The Bitlandians are quite weird people. They do everything differently. They have a different alphabet so they have a different definition for a string. A Bitlandish string is a string made only of characters "0" and "1". BitHaval (the mayor of Bitland) loves to play with Bitlandish strings. He takes some Bitlandish ...
[ "11\n10\n", "1\n01\n", "000\n101\n", "1101\n1111\n", "11000001\n00000001\n", "01\n10\n", "0000\n1110\n", "010101\n101010\n", "0\n1\n", "1\n1\n" ]
[ "YES\n", "NO\n", "NO\n", "YES\n", "YES\n", "YES\n", "NO\n", "YES\n", "NO\n", "YES\n" ]
1
stdio
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: - Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements. ...
[ "4 3\n2 3 1 4\n", "3 3\n1 2 3\n", "8 3\n7 3 1 8 4 6 2 5\n", "41705 41588\n7198 23692 39349 9892 1877 19724 36302 33493 22770 36290 5198 7205 28563 39786 15777 6040 35953 7875 28544 11079 6640 25135 16516 12101 34504 35587 31865 11502 20848 24646 18981 22184 14365 11667 22002 35354 29276 38560 34643 32439 3470...
[ "2\n", "1\n", "4\n", "2\n", "4\n", "3\n", "55080\n", "48352\n", "1\n", "1\n" ]
1
stdio
Given a sorted array of numbers, return the summary of its ranges. ## Examples ```python summary_ranges([1, 2, 3, 4]) == ["1->4"] summary_ranges([1, 1, 1, 1, 1]) == ["1"] summary_ranges([0, 1, 2, 5, 6, 9]) == ["0->2", "5->6", "9"] summary_ranges([0, 1, 2, 3, 3, 3, 4, 5, 6, 7]) == ["0->7"] summary_ranges([0, 1, 2, 3, 3...
[]
[]
1
stdio
The preferred way to generate user login in Polygon is to concatenate a prefix of the user's first name and a prefix of their last name, in that order. Each prefix must be non-empty, and any of the prefixes can be the full name. Typically there are multiple possible logins for each person. You are given the first and ...
[ "harry potter\n", "tom riddle\n", "a qdpinbmcrf\n", "wixjzniiub ssdfodfgap\n", "z z\n", "ertuyivhfg v\n", "asdfghjkli ware\n", "udggmyop ze\n", "fapkdme rtzxovx\n", "mybiqxmnqq l\n" ]
[ "hap\n", "tomr\n", "aq\n", "wis\n", "zz\n", "ertuv\n", "asdfghjkliw\n", "udggmyopz\n", "fapkdmer\n", "ml\n" ]
1
stdio
# Feynman's squares Richard Phillips Feynman was a well-known American physicist and a recipient of the Nobel Prize in Physics. He worked in theoretical physics and pioneered the field of quantum computing. Recently, an old farmer found some papers and notes that are believed to have belonged to Feynman. Among notes a...
[]
[]
1
stdio
An integer N is a multiple of 9 if and only if the sum of the digits in the decimal representation of N is a multiple of 9. Determine whether N is a multiple of 9. -----Constraints----- - 0 \leq N < 10^{200000} - N is an integer. -----Input----- Input is given from Standard Input in the following format: N -----Ou...
[ "123456789\n", "0\n", "31415926535897932384626433832795028841971693993751058209749445923078164062862089986280\n", "1\n", "845410686144136511766870859775922809470967375409140663034349040140125188651172413937318920019664667953295078213144836814997819687095284094776471908733234531157216900474939162928952648128...
[ "Yes\n", "Yes\n", "No\n", "No\n", "No\n", "No\n", "No\n", "No\n", "Yes\n", "Yes\n" ]
1
stdio
Think of New York as a rectangular grid consisting of N vertical avenues numerated from 1 to N and M horizontal streets numerated 1 to M. C friends are staying at C hotels located at some street-avenue crossings. They are going to celebrate birthday of one of them in the one of H restaurants also located at some street...
[ "10 10\n2\n1 1\n3 3\n2\n1 10\n4 4\n", "100 100\n10\n53 20\n97 6\n12 74\n48 92\n97 13\n47 96\n75 32\n69 21\n95 75\n1 54\n10\n36 97\n41 1\n1 87\n39 23\n27 44\n73 97\n1 1\n6 26\n48 3\n5 69\n", "100 100\n10\n86 72\n25 73\n29 84\n34 33\n29 20\n84 83\n41 80\n22 22\n16 89\n77 49\n1\n4 23\n", "100 100\n1\n66 77\n10\n...
[ "6\n2\n", "108\n4\n", "140\n1\n", "9\n6\n", "1999999998\n1\n", "1111110585\n1\n", "657332378\n1\n", "576261778\n1\n", "0\n1\n", "0\n1\n" ]
1
stdio
In this Kata, you will be given a number and your task will be to return the nearest prime number. ```Haskell solve(4) = 3. The nearest primes are 3 and 5. If difference is equal, pick the lower one. solve(125) = 127 ``` We'll be testing for numbers up to `1E10`. `500` tests. More examples in test cases. Good lu...
[]
[]
1
stdio
There are N rabbits, numbered 1 through N. The i-th (1≤i≤N) rabbit likes rabbit a_i. Note that no rabbit can like itself, that is, a_i≠i. For a pair of rabbits i and j (i<j), we call the pair (i,j) a friendly pair if the following condition is met. * Rabbit i likes rabbit j and rabbit j likes rabbit i. Calculate ...
[ "3\n3 3 1", "5\n3 5 5 5 1", "5\n5 4 5 2 1", "5\n5 5 5 5 2", "5\n5 5 5 1 1", "4\n3 1 4 3", "5\n5 3 5 1 1", "4\n4 1 4 3", "5\n5 3 5 2 1", "5\n5 5 5 2 1" ]
[ "1\n", "0\n", "2\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n" ]
1
stdio
A string is called diverse if it contains consecutive (adjacent) letters of the Latin alphabet and each letter occurs exactly once. For example, the following strings are diverse: "fced", "xyz", "r" and "dabcef". The following string are not diverse: "az", "aa", "bad" and "babc". Note that the letters 'a' and 'z' are n...
[ "8\nfced\nxyz\nr\ndabcef\naz\naa\nbad\nbabc\n", "44\nops\ntest\nyes\nno\nac\nbc\ncb\nz\na\nq\nr\nu\nqq\nop\npo\nxu\nux\nxy\nyx\na\nab\nabc\nabcd\nabcde\nabcdef\nabcdefg\nbcdefg\ncdefg\ndefg\nefgd\nefef\nabacaba\nabz\naoi\nioi\ncodeforces\nklmn\nnmlk\nkln\nklmnl\nkmn\nkklmn\nklmnn\naklkmn\n", "1\nf\n", "1\nsho...
[ "Yes\nYes\nYes\nYes\nNo\nNo\nNo\nNo\n", "No\nNo\nNo\nYes\nNo\nYes\nYes\nYes\nYes\nYes\nYes\nYes\nNo\nYes\nYes\nNo\nNo\nYes\nYes\nYes\nYes\nYes\nYes\nYes\nYes\nYes\nYes\nYes\nYes\nYes\nNo\nNo\nNo\nNo\nNo\nNo\nYes\nYes\nNo\nNo\nNo\nNo\nNo\nNo\n", "Yes\n", "No\n", "Yes\nYes\nYes\nYes\nYes\nYes\nYes\nYes\nYes\n...
1
stdio
Tranform of input array of zeros and ones to array in which counts number of continuous ones: [1, 1, 1, 0, 1] -> [3,1] Write your solution by modifying this code: ```python def ones_counter(input): ``` Your solution should implemented in the function "ones_counter". The inputs will be passed to it and it should r...
[]
[]
1
stdio
Find the edit distance between given two words s1 and s2. The disntace is the minimum number of single-character edits required to change one word into the other. The edits including the following operations: * insertion: Insert a character at a particular position. * deletion: Delete a character at a particular posi...
[ "icpc\nipcc", "`cac\nacm", "icpb\ncbio", "cpci\nipcc", "`cad\nacm", "cpci\nccpi", "`cac\nbcm", "icpc\nccpi", "`cac\nmcb", "ibpc\nccpi" ]
[ "2\n", "3\n", "4\n", "2\n", "3\n", "2\n", "3\n", "2\n", "3\n", "3\n" ]
1
stdio
# Task Given a rectangular `matrix` and integers `a` and `b`, consider the union of the ath row and the bth (both 0-based) column of the `matrix`. Return sum of all elements of that union. # Example For ``` matrix = [[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3]] a = 1 and b = 3 ``` the output shou...
[]
[]
1
stdio
Simply find the closest value to zero from the list. Notice that there are negatives in the list. List is always not empty and contains only integers. Return ```None``` if it is not possible to define only one of such values. And of course, we are expecting 0 as closest value to zero. Examples: ```code [2, 4, -1, -3]...
[]
[]
1
stdio
Write a function that takes a number or a string and gives back the number of **permutations without repetitions** that can generated using all of its element.; more on permutations [here](https://en.wikipedia.org/wiki/Permutation). For example, starting with: ``` 1 45 115 "abc" ``` You could respectively generate: `...
[]
[]
1
stdio
We have N integers A_1, A_2, ..., A_N. There are \frac{N(N-1)}{2} ways to choose two of them and form a pair. If we compute the product of each of those pairs and sort the results in ascending order, what will be the K-th number in that list? -----Constraints----- - All values in input are integers. - 2 \leq N \leq ...
[ "4 3\n3 3 -4 -2\n", "10 40\n5 4 3 2 -1 0 0 0 0 0\n", "30 413\n-170202098 -268409015 537203564 983211703 21608710 -443999067 -937727165 -97596546 -372334013 398994917 -972141167 798607104 -949068442 -959948616 37909651 0 886627544 -20098238 0 -948955241 0 -214720580 277222296 -18897162 834475626 0 -425610555 110...
[ "-6\n", "6\n", "448283280358331064\n", "6\n", "-12\n", "528184831018109492\n", "0\n", "476299476577366816\n", "517956905402467891\n", "474217893515068178\n" ]
1
stdio
Joisino is working as a receptionist at a theater. The theater has 100000 seats, numbered from 1 to 100000. According to her memo, N groups of audiences have come so far, and the i-th group occupies the consecutive seats from Seat l_i to Seat r_i (inclusive). How many people are sitting at the theater now? -----Constr...
[ "1\n24 30\n", "2\n6 8\n3 3\n", "1\n0 30", "2\n6 12\n3 3", "1\n1 30", "2\n6 12\n0 3", "1\n2 30", "2\n6 10\n0 3", "1\n2 0", "2\n6 10\n0 1" ]
[ "7\n", "4\n", "31\n", "8\n", "30\n", "11\n", "29\n", "9\n", "-1\n", "7\n" ]
1
stdio
`late_clock` function receive an array with 4 digits and should return the latest time that can be built with those digits. The time should be in `HH:MM` format. Examples: ``` [1, 9, 8, 3] => 19:38 [9, 1, 2, 5] => 21:59 ``` You can suppose the input is correct and you can build from it a correct 24-hour time. Write ...
[]
[]
1
stdio
There are N stones arranged in a row. The i-th stone from the left is painted in the color C_i. Snuke will perform the following operation zero or more times: * Choose two stones painted in the same color. Repaint all the stones between them, with the color of the chosen stones. Find the number of possible final s...
[ "6\n4\n2\n2\n4\n2\n4", "5\n1\n4\n1\n2\n2", "6\n4\n2\n2\n1\n2\n4", "6\n4\n1\n2\n1\n2\n4", "7\n1\n2\n1\n2\n3\n3\n2", "6\n3\n2\n2\n2\n2\n4", "7\n1\n3\n1\n2\n1\n3\n2", "7\n1\n3\n1\n2\n4\n3\n2", "7\n1\n3\n1\n2\n2\n3\n2", "6\n4\n2\n5\n4\n2\n1" ]
[ "5\n", "2\n", "3\n", "4\n", "6\n", "1\n", "7\n", "5\n", "5\n", "3\n" ]
1
stdio
Eugeny has array a = a_1, a_2, ..., a_{n}, consisting of n integers. Each integer a_{i} equals to -1, or to 1. Also, he has m queries: Query number i is given as a pair of integers l_{i}, r_{i} (1 ≤ l_{i} ≤ r_{i} ≤ n). The response to the query will be integer 1, if the elements of array a can be rearranged so as the...
[ "2 3\n1 -1\n1 1\n1 2\n2 2\n", "5 5\n-1 1 1 1 -1\n1 1\n2 3\n3 5\n2 5\n1 5\n", "3 3\n1 1 1\n2 2\n1 1\n1 1\n", "4 4\n-1 -1 -1 -1\n1 3\n1 2\n1 2\n1 1\n", "5 5\n-1 -1 -1 -1 -1\n1 1\n1 1\n3 4\n1 1\n1 4\n", "6 6\n-1 -1 1 -1 -1 1\n1 1\n3 4\n1 1\n1 1\n1 3\n1 4\n", "7 7\n-1 -1 -1 1 -1 -1 -1\n1 1\n2 7\n1 3\n1 5\n4...
[ "0\n1\n0\n", "0\n1\n0\n1\n0\n", "0\n0\n0\n", "0\n0\n0\n0\n", "0\n0\n0\n0\n0\n", "0\n1\n0\n0\n0\n1\n", "0\n0\n0\n0\n0\n0\n1\n", "0\n0\n0\n0\n0\n0\n0\n0\n", "0\n1\n0\n0\n0\n0\n0\n1\n0\n", "1\n1\n1\n0\n0\n1\n1\n0\n0\n0\n" ]
1
stdio
Read problems statements in Russian also. Chef plays with the sequence of N numbers. During a single move Chef is able to choose a non-decreasing subsequence of the sequence and to remove it from the sequence. Help him to remove all the numbers in the minimal number of moves. ------ Input ------ The first line of ...
[ "3 \n1 2 3", "4\n4 1 2 3", "3 \n1 2 5", "4\n4 1 3 3", "3 \n5 1 0", "4\n20 -1 -2 -4", "3 \n1 2 8", "4\n4 1 5 3", "3 \n1 1 8", "4\n4 0 5 3" ]
[ "1", "2", "1\n", "2\n", "3\n", "4\n", "1\n", "2\n", "1\n", "2\n" ]
1
stdio
>When no more interesting kata can be resolved, I just choose to create the new kata, to solve their own, to enjoy the process --myjinxin2015 said # Description: Given a string `str` that contains some "(" or ")". Your task is to find the longest substring in `str`(all brackets in the substring are closed). The resu...
[]
[]
1
stdio
Once a Mathematician was trapped by military people during a world war with his forty colleagues. The colleagues were without any weapons, only the mathematician had a knife. And with no weapons they were not able to fight with the military, so they decided to kill themselves rather than being killed by military. They ...
[ "934\n48171068\n63138680\n25597136\n5610719\n22559303\n19374620\n52609147\n76485130\n4119341\n84687324\n74124384\n29214349\n76525070\n27296334\n62086857\n7062292\n70121510\n32711240\n40766945\n75911566\n64205975\n68575226\n83591193\n54443307\n63540837\n4289505\n8767969\n70478582\n7243533\n39723966\n78096030\n726371...
[ "29233273\n59168497\n17639841\n2832831\n11564175\n5194809\n38109431\n18752533\n4044379\n35156921\n14031041\n24874267\n18832413\n21038237\n57064851\n5735977\n6025293\n31868049\n14425027\n17605405\n61303087\n2932725\n32964659\n41777751\n59972811\n190403\n758723\n6739437\n6098459\n12339069\n21974333\n11056593\n1762582...
1
stdio
Write a function to split a string and convert it into an array of words. For example: ```python "Robin Singh" ==> ["Robin", "Singh"] "I love arrays they are my favorite" ==> ["I", "love", "arrays", "they", "are", "my", "favorite"] ``` Write your solution by modifying this code: ```python def string_to_array(s): ...
[]
[]
1
stdio
There are n points on a straight line, and the i-th point among them is located at x_{i}. All these coordinates are distinct. Determine the number m — the smallest number of points you should add on the line to make the distances between all neighboring points equal. -----Input----- The first line contains a singl...
[ "3\n-5 10 5\n", "6\n100 200 400 300 600 500\n", "4\n10 9 0 -1\n", "3\n1 4 7\n", "3\n1 4 6\n", "3\n1 2 6\n", "3\n1 3 6\n", "4\n1 2 3 4\n", "3\n-1000000000 -999999999 1000000000\n", "3\n-1000000000 999999999 1000000000\n" ]
[ "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "3\n", "0\n", "1999999998\n", "1999999998\n" ]
1
stdio
Your task is to return the number of visible dots on a die after it has been rolled(that means the total count of dots that would not be touching the table when rolled) 6, 8, 10, 12, 20 sided dice are the possible inputs for "numOfSides" topNum is equal to the number that is on top, or the number that was rolled. f...
[]
[]
1
stdio
For a dictionary $M$ that stores elements formed by a pair of a string key and an integer value, perform a sequence of the following operations. Note that each key in $M$ must be unique. * insert($key$, $x$): Insert an element formed by a pair of $key$ and $x$ to $M$. If there is an element with $key$, replace the cor...
[ "7\n0 blue 4\n0 red 1\n0 white 5\n1 red\n1 blue\n0 black 16\n1 black", "7\n0 blue 4\n0 red 1\n0 white 3\n1 red\n1 blue\n0 black 8\n1 black", "7\n0 blue 5\n0 red 1\n0 white 5\n1 red\n1 blue\n0 black 16\n1 black", "7\n0 blue 4\n0 red 1\n0 white 5\n1 red\n1 blue\n0 black 11\n1 black", "7\n0 blue 4\n0 red 1\n0 ...
[ "1\n4\n16\n", "1\n4\n8\n", "1\n5\n16\n", "1\n4\n11\n", "1\n4\n5\n", "1\n4\n13\n", "1\n4\n6\n", "1\n7\n16\n", "1\n4\n", "2\n4\n" ]
1
stdio
It is September 9 in Japan now. You are given a two-digit integer N. Answer the question: Is 9 contained in the decimal notation of N? -----Constraints----- - 10≤N≤99 -----Input----- Input is given from Standard Input in the following format: N -----Output----- If 9 is contained in the decimal notation of N, print ...
[ "29\n", "72\n", "91\n", "1", "69", "115", "84", "0", "181", "168" ]
[ "Yes\n", "No\n", "Yes\n", "No\n", "Yes\n", "No\n", "No\n", "No\n", "No\n", "No\n" ]
1
stdio
Harry Potter has a difficult homework. Given a rectangular table, consisting of n × m cells. Each cell of the table contains the integer. Harry knows how to use two spells: the first spell change the sign of the integers in the selected row, the second — in the selected column. Harry's task is to make non-negative the ...
[ "20 10\n-6 8 -4 -1 3 10 2 5 4 7\n6 9 9 8 -8 3 7 9 7 3\n0 10 10 1 -3 -4 5 -1 10 10\n8 9 10 4 7 10 10 3 9 10\n3 0 8 -5 0 5 7 8 -5 4\n9 -6 7 10 -4 -2 7 0 -5 9\n-10 7 -4 5 10 8 3 7 1 8\n-3 -6 0 3 2 1 5 9 8 9\n4 -3 5 3 4 -6 9 5 3 4\n2 -4 0 -5 -2 0 5 5 9 7\n-4 -1 5 1 10 9 4 -8 6 6\n2 3 6 8 9 6 5 -7 -2 -5\n6 4 -1 4 4 2 7 ...
[ "0 \n0 \n", "1 1 \n0 \n", "0 \n22 5 6 8 9 11 13 16 18 20 27 29 30 36 37 40 45 46 47 52 55 64 65 \n", "6 2 3 4 7 8 10 \n1 1 \n", "2 1 4 \n4 5 6 8 10 \n", "19 3 5 9 14 24 30 34 36 39 40 41 44 48 50 51 54 56 63 67 \n0 \n", "0 \n0 \n", "0 \n0 \n", "0 \n22 5 6 8 9 11 13 16 18 20 27 29 30 36 37 40 45 46 4...
1
stdio
You are given two positive integers $n$ and $k$. Print the $k$-th positive integer that is not divisible by $n$. For example, if $n=3$, and $k=7$, then all numbers that are not divisible by $3$ are: $1, 2, 4, 5, 7, 8, 10, 11, 13 \dots$. The $7$-th number among them is $10$. -----Input----- The first line contains a...
[ "6\n3 7\n4 12\n2 1000000000\n7 97\n1000000000 1000000000\n2 1\n", "7\n2 1\n2 1\n2 1\n2 1\n2 1\n2 1\n2 1\n", "1\n841 4832526\n", "7\n2 1\n2 1\n2 1\n2 1\n2 1\n2 1\n2 1\n", "1\n841 4832526\n", "1\n870 4832526\n", "6\n2 7\n4 12\n2 1000000000\n7 97\n1000000000 1000000000\n2 1\n", "1\n1718 4832526\n", "6\...
[ "10\n15\n1999999999\n113\n1000000001\n1\n", "1\n1\n1\n1\n1\n1\n1\n", "4838279\n", "1\n1\n1\n1\n1\n1\n1\n", "4838279\n", "\n4838087\n", "\n13\n\n15\n\n1999999999\n\n113\n\n1000000001\n\n1\n", "\n4835340\n", "\n13\n\n15\n\n1333333333\n\n113\n\n1000000001\n\n1\n", "\n3126275\n" ]
1
stdio
Santosh has a farm at Byteland. He has a very big family to look after. His life takes a sudden turn and he runs into a financial crisis. After giving all the money he has in his hand, he decides to sell his plots. The speciality of his land is that it is rectangular in nature. Santosh comes to know that he will get m...
[ "2\n10 15\n4 6\n", "2\n10 15\n4 1", "2\n10 28\n4 1", "2\n15 28\n4 1", "2\n8 28\n4 1", "2\n8 12\n8 1", "2\n8 12\n3 1", "2\n8 12\n2 1", "2\n9 12\n2 1", "2\n9 12\n2 2" ]
[ "6\n6\n", "6\n4\n", "70\n4\n", "420\n4\n", "14\n4\n", "6\n8\n", "6\n3\n", "6\n2\n", "12\n2\n", "12\n1\n" ]
1
stdio
There are N squares aligned in a row. The i-th square from the left contains an integer a_i. Initially, all the squares are white. Snuke will perform the following operation some number of times: * Select K consecutive squares. Then, paint all of them white, or paint all of them black. Here, the colors of the squares...
[ "1 1\n-16", "5 3\n-10 10 -18 10 -10", "4 2\n7 -10 -10 10", "4 2\n7 -6 -10 12", "4 2\n7 -6 -10 20", "4 2\n9 -1 -10 20", "4 2\n13 -1 -10 20", "4 2\n3 -1 -10 20", "4 3\n3 -1 -10 20", "4 3\n3 -1 -1 20" ]
[ "0\n", "10\n", "17\n", "19\n", "27\n", "29\n", "33\n", "23\n", "20\n", "21\n" ]
1
stdio
Long ago, when Petya was a schoolboy, he was very much interested in the Petr# language grammar. During one lesson Petya got interested in the following question: how many different continuous substrings starting with the sbegin and ending with the send (it is possible sbegin = send), the given string t has. Substrings...
[ "abcdefghijklmnopqrstuvwxyz\nabc\nxyz\n", "fcgbeabagggfdbacgcaagfbdddefdbcfccfacfffebdgececdabfceadecbgdgdbdadcgfbbaaabcccdefabdfefadfdccbbefbfgcfdadeggggbdadfeadafbaccefdfcbbbadgegbbbcebfbdcfaabddeafbedagbgfdagcccafbddcfafdfaafgefcdceaabggfbaebeaccdfbeeegfdddgfdaagcbdddggcaceadgbddcbdcfddbcddfaebdgcebcbgcacgdeab...
[ "1\n", "12\n", "14\n", "0\n", "1\n", "0\n", "1\n", "0\n", "1\n", "68\n" ]
1
stdio
Example Input 4 5 8 58 85 Output 2970.000000000
[ "4\n5\n8\n58\n152", "4\n5\n8\n55\n152", "4\n5\n20\n55\n152", "4\n5\n15\n58\n85", "4\n5\n8\n58\n171", "4\n5\n9\n55\n152", "4\n2\n11\n55\n152", "4\n5\n17\n55\n152", "4\n5\n15\n58\n7", "4\n5\n10\n58\n171" ]
[ "5181.000000000000000\n", "4945.500000000000000\n", "5887.500000000000000\n", "3285.000000000000000\n", "5808.000000000000000\n", "5024.000000000000000\n", "5082.000000000000000\n", "5652.000000000000000\n", "693.000000000000000\n", "5984.000000000000000\n" ]
1
stdio
Limak is an old brown bear. He often plays poker with his friends. Today they went to a casino. There are n players (including Limak himself) and right now all of them have bids on the table. i-th of them has bid with size ai dollars. Each player can double his bid any number of times and triple his bid any number of ...
[ "2\n49 42\n", "20\n958692492 954966768 77387000 724664764 101294996 614007760 202904092 555293973 707655552 108023967 73123445 612562357 552908390 914853758 915004122 466129205 122853497 814592742 373389439 818473058\n", "3\n335544320 71744535 71744535\n", "18\n2 3 5 7 11 13 17 19 23 29 31 37 43 47 53 59 67 7...
[ "No", "No", "Yes", "No", "Yes", "Yes", "No", "Yes", "No", "Yes" ]
1
stdio
Let's call a string adorable if its letters can be realigned in such a way that they form two consequent groups of equal symbols (note that different groups must contain different symbols). For example, ababa is adorable (you can transform it to aaabb, where the first three letters form a group of a-s and others — a gr...
[ "ababa\n", "zzcxx\n", "yeee\n", "a\n", "bbab\n", "abcd\n", "abc\n", "abcdaaaa\n", "aaaaaaaaaaaaaaa\n", "adb\n" ]
[ "Yes\n", "Yes\n", "No\n", "No\n", "No\n", "Yes\n", "No\n", "Yes\n", "No\n", "No\n" ]
1
stdio
Takahashi is drawing a segment on grid paper. From a certain square, a square that is x squares to the right and y squares above, is denoted as square (x, y). When Takahashi draws a segment connecting the lower left corner of square (A, B) and the lower left corner of square (C, D), find the number of the squares cro...
[ "1 2 3 4", "3 3 10 7", "1 2 6 4", "3 3 10 5", "6 3 10 5", "1 0 11 4", "1 0 15 4", "6 6 3 5", "1 1 15 2", "6 16 3 5" ]
[ "2\n", "10\n", "6\n", "8\n", "4\n", "12\n", "16\n", "3\n", "14\n", "13\n" ]
1
stdio
You are given two positive integers d and s. Find minimal positive integer n which is divisible by d and has sum of digits equal to s. Input The first line contains two positive integers d and s (1 ≤ d ≤ 500, 1 ≤ s ≤ 5000) separated by space. Output Print the required number or -1 if it doesn't exist. Examples In...
[ "2 5000\n", "3 5000\n", "182 6\n", "364 4\n", "1 5000\n", "72 72\n", "5 1\n", "500 5000\n", "75 16\n", "212 14\n" ]
[ "699999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999...
1
stdio
A histogram is made of a number of contiguous bars, which have same width. For a given histogram with $N$ bars which have a width of 1 and a height of $h_i$ = $h_1, h_2, ... , h_N$ respectively, find the area of the largest rectangular area. Constraints * $1 \leq N \leq 10^5$ * $0 \leq h_i \leq 10^9$ Input The inp...
[ "8\n2 1 3 5 3 7 2 1", "3\n3 0 1", "8\n2 1 3 5 3 7 3 1", "3\n5 0 0", "3\n0 0 0", "8\n2 2 3 5 4 7 3 2", "3\n0 0 1", "8\n3 6 3 6 4 7 0 4", "8\n3 6 4 6 4 7 0 4", "3\n2 0 2" ]
[ "12\n", "3\n", "15\n", "5\n", "0\n", "16\n", "1\n", "18\n", "20\n", "2\n" ]
1
stdio
You are given two set of points. The first set is determined by the equation A1x + B1y + C1 = 0, and the second one is determined by the equation A2x + B2y + C2 = 0. Write the program which finds the number of points in the intersection of two given sets. Input The first line of the input contains three integer numb...
[ "1 -1 1\n0 0 0\n", "-1 0 0\n-2 1 2\n", "-1 -1 1\n1 1 0\n", "2 2 1\n1 2 0\n", "-1 1 1\n0 1 1\n", "0 -1 -1\n-2 -2 -1\n", "-2 -1 1\n-1 1 1\n", "1 0 0\n0 1 0\n", "1 1 -1\n-1 0 -1\n", "-2 -1 0\n-2 2 2\n" ]
[ "-1", "1", "0", "1", "1", "1", "1", "1", "1", "1" ]
1
stdio
Ivan has got an array of n non-negative integers a_1, a_2, ..., a_{n}. Ivan knows that the array is sorted in the non-decreasing order. Ivan wrote out integers 2^{a}_1, 2^{a}_2, ..., 2^{a}_{n} on a piece of paper. Now he wonders, what minimum number of integers of form 2^{b} (b ≥ 0) need to be added to the piece of p...
[ "4\n0 1 1 1\n", "1\n3\n", "1\n0\n", "1\n2000000000\n", "1\n1\n", "26\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 2\n", "1\n2000000000\n", "26\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 2\n", "1\n0\n", "1\n1\n" ]
[ "0\n", "3\n", "0\n", "2000000000\n", "1\n", "5\n", "2000000000\n", "5\n", "0\n", "1\n" ]
1
stdio
You are given two integers K and S. Three variable X, Y and Z takes integer values satisfying 0≤X,Y,Z≤K. How many different assignments of values to X, Y and Z are there such that X + Y + Z = S? Constraints * 2≤K≤2500 * 0≤S≤3K * K and S are integers. Input The input is given from Standard Input in the following for...
[ "3 2", "5 7", "3 3", "4 7", "3 4", "1 7", "2 5", "4 0", "6 7", "17 4" ]
[ "6\n", "27\n", "10\n", "18\n", "12\n", "0\n", "3\n", "1\n", "33\n", "15\n" ]
1
stdio
Gerald got a very curious hexagon for his birthday. The boy found out that all the angles of the hexagon are equal to $120^{\circ}$. Then he measured the length of its sides, and found that each of them is equal to an integer number of centimeters. There the properties of the hexagon ended and Gerald decided to draw on...
[ "1 1 1 1 1 1\n", "1 2 1 2 1 2\n", "2 4 5 3 3 6\n", "45 19 48 18 46 21\n", "66 6 65 6 66 5\n", "7 5 4 8 4 5\n", "3 2 1 4 1 2\n", "7 1 7 3 5 3\n", "9 2 9 3 8 3\n", "1 6 1 5 2 5\n" ]
[ "6\n", "13\n", "83\n", "6099\n", "5832\n", "175\n", "25\n", "102\n", "174\n", "58\n" ]
1
stdio
There are N stones, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), the height of Stone i is h_i. There is a frog who is initially on Stone 1. He will repeat the following action some number of times to reach Stone N: * If the frog is currently on Stone i, jump to Stone i + 1 or Stone i + 2. Here, a cost of |...
[ "6\n30 10 60 10 60 57", "4\n10 14 40 20", "2\n18 10", "4\n5 14 40 20", "2\n33 10", "6\n30 12 60 10 60 9", "2\n9 10", "6\n30 12 60 17 60 9", "2\n9 18", "6\n30 12 60 33 60 9" ]
[ "33\n", "10\n", "8\n", "15\n", "23\n", "21\n", "1\n", "31\n", "9\n", "63\n" ]
1
stdio
###Task: You have to write a function `pattern` which creates the following pattern (see examples) up to the desired number of rows. * If the Argument is 0 or a Negative Integer then it should return "" i.e. empty string. * If any even number is passed as argument then the pattern should last upto the largest odd nu...
[]
[]
1
stdio
You have stumbled across the divine pleasure that is owning a dog and a garden. Now time to pick up all the cr@p! :D Given a 2D array to represent your garden, you must find and collect all of the dog cr@p - represented by '@'. You will also be given the number of bags you have access to (bags), and the capactity of ...
[]
[]
1
stdio
# Task Find the integer from `a` to `b` (included) with the greatest number of divisors. For example: ``` divNum(15, 30) ==> 24 divNum(1, 2) ==> 2 divNum(0, 0) ==> 0 divNum(52, 156) ==> 120 ``` If there are several numbers that have the same (maximum) number of divisors, the smallest among them should be ...
[]
[]
1
stdio
Johnny needs to make a rectangular box for his physics class project. He has bought P cm of wire and S cm^{2} of special paper. He would like to use all the wire (for the 12 edges) and paper (for the 6 sides) to make the box. What is the largest volume of the box that Johnny can make? ------ Input ------ The first l...
[ "2\n20 14\n20 16", "2\n20 14\n20 14", "2\n32 14\n20 14", "2\n20 14\n36 14", "2\n20 8\n36 14", "2\n28 8\n36 14", "2\n20 16\n20 14", "2\n32 20\n20 14", "2\n20 14\n20 10", "2\n20 16\n20 10" ]
[ "3.00\n4.15", "3.0\n3.0\n", "1.63\n3.0\n", "3.0\n1.43\n", "0.88\n1.43\n", "0.6\n1.43\n", "4.15\n3.0\n", "3.43\n3.0\n", "3.0\n1.42\n", "4.15\n1.42\n" ]
1
stdio
Alice became interested in periods of integer numbers. We say positive $X$ integer number is periodic with length $L$ if there exists positive integer number $P$ with $L$ digits such that $X$ can be written as $PPPP…P$. For example: $X = 123123123$ is periodic number with length $L = 3$ and $L = 9$ $X = 42424242$ is ...
[ "3\n123456\n", "3\n12345\n", "3\n776554554\n", "3\n145023023\n", "3\n3021001003\n", "10\n6277\n", "10\n9969441321\n", "3\n352474474\n", "3\n220330330\n", "3\n29939939929\n" ]
[ "124124\n", "100100\n", "776776776\n", "145145145\n", "100100100100\n", "1000000000\n", "9969441322\n", "353353353\n", "221221221\n", "100100100100\n" ]
1
stdio
# Introduction The first century spans from the **year 1** *up to* and **including the year 100**, **The second** - *from the year 101 up to and including the year 200*, etc. # Task : Given a year, return the century it is in. Write your solution by modifying this code: ```python def century(year): ``` Your sol...
[]
[]
1
stdio
Given some positive integers, I wish to print the integers such that all take up the same width by adding a minimum number of leading zeroes. No leading zeroes shall be added to the largest integer. For example, given `1, 23, 2, 17, 102`, I wish to print out these numbers as follows: ```python 001 023 002 017 102 ```...
[]
[]
1
stdio
"Contestant who earns a score equal to or greater than the k-th place finisher's score will advance to the next round, as long as the contestant earns a positive score..." — an excerpt from contest rules. A total of n participants took part in the contest (n ≥ k), and you already know their scores. Calculate how many ...
[ "8 3\n10 9 8 7 7 7 5 5\n", "8 7\n10 9 8 7 7 7 5 5\n", "50 25\n2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n", "49 8\n99 98 98 96 92 92 90 89 89 86 86 85 83 80 79 76 74 69 67 67 58 56 55 51 49 47 47 46 45 41 41 40 39 34 34 33 25 23 18 15 13 13 11 9 5 4 3 ...
[ "3\n", "8\n", "26\n", "9\n", "6\n", "0\n", "14\n", "2\n", "1\n", "12\n" ]
1
stdio
In mathematics, a [Diophantine equation](https://en.wikipedia.org/wiki/Diophantine_equation) is a polynomial equation, usually with two or more unknowns, such that only the integer solutions are sought or studied. In this kata we want to find all integers `x, y` (`x >= 0, y >= 0`) solutions of a diophantine equation o...
[]
[]
1
stdio
Find the largest square number not exceeding N. Here, a square number is an integer that can be represented as the square of an integer. -----Constraints----- - 1 \leq N \leq 10^9 - N is an integer. -----Input----- Input is given from Standard Input in the following format: N -----Output----- Print the largest squ...
[ "10\n", "81\n", "271828182\n", "70", "12", "115087508", "135", "167542739", "7", "16" ]
[ "9\n", "81\n", "271821169\n", "64\n", "9\n", "115068529\n", "121\n", "167521249\n", "4\n", "16\n" ]
1
stdio
Given two integer arrays where the second array is a shuffled duplicate of the first array with one element missing, find the missing element. Please note, there may be duplicates in the arrays, so checking if a numerical value exists in one and not the other is not a valid solution. ``` find_missing([1, 2, 2, 3], [1...
[]
[]
1
stdio
Normally, we decompose a number into binary digits by assigning it with powers of 2, with a coefficient of `0` or `1` for each term: `25 = 1*16 + 1*8 + 0*4 + 0*2 + 1*1` The choice of `0` and `1` is... not very binary. We shall perform the *true* binary expansion by expanding with powers of 2, but with a coefficient o...
[]
[]
1
stdio
It’s still hot every day, but September has already come. It’s autumn according to the calendar. Looking around, I see two red dragonflies at rest on the wall in front of me. It’s autumn indeed. When two red dragonflies’ positional information as measured from the end of the wall is given, make a program to calculate ...
[ "50 12", "25 13", "27 30", "50 0", "25 17", "27 22", "58 0", "25 11", "27 37", "26 0" ]
[ "38\n", "12\n", "3\n", "50\n", "8\n", "5\n", "58\n", "14\n", "10\n", "26\n" ]
1
stdio
Shichi-Go-San (literally "Seven-Five-Three") is a traditional event in a certain country to celebrate the growth of seven-, five- and three-year-old children. Takahashi is now X years old. Will his growth be celebrated in Shichi-Go-San this time? -----Constraints----- - 1 ≤ X ≤ 9 - X is an integer. -----Input----- ...
[ "5\n", "6\n", "1\n", "2\n", "3\n", "4\n", "7\n", "8\n", "9\n", "11" ]
[ "YES\n", "NO\n", "NO\n", "NO\n", "YES\n", "NO\n", "YES\n", "NO\n", "NO\n", "NO\n" ]
1
stdio
Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note t...
[ "10 30 20\n", "30 30 100\n", "56 25 31\n", "106 25 31", "4 24 20", "10 29 20", "30 47 100", "8 25 31", "4 29 20", "30 26 100" ]
[ "Yes\n", "No\n", "Yes\n", "No\n", "Yes\n", "No\n", "No\n", "No\n", "No\n", "No\n" ]
1
stdio
Complete the function which returns the weekday according to the input number: * `1` returns `"Sunday"` * `2` returns `"Monday"` * `3` returns `"Tuesday"` * `4` returns `"Wednesday"` * `5` returns `"Thursday"` * `6` returns `"Friday"` * `7` returns `"Saturday"` * Otherwise returns `"Wrong, please enter a number betwee...
[]
[]
1
stdio
On her way to programming school tiger Dasha faced her first test — a huge staircase! [Image] The steps were numbered from one to infinity. As we know, tigers are very fond of all striped things, it is possible that it has something to do with their color. So on some interval of her way she calculated two values — th...
[ "2 3\n", "3 1\n", "5 4\n", "9 9\n", "85 95\n", "0 1\n", "89 25\n", "74 73\n", "62 39\n", "57 57\n" ]
[ "YES\n", "NO\n", "YES\n", "YES\n", "NO\n", "YES\n", "NO\n", "YES\n", "NO\n", "YES\n" ]
1
stdio
Given an integer `n`, find two integers `a` and `b` such that: ```Pearl A) a >= 0 and b >= 0 B) a + b = n C) DigitSum(a) + Digitsum(b) is maximum of all possibilities. ``` You will return the digitSum(a) + digitsum(b). ``` For example: solve(29) = 11. If we take 15 + 14 = 29 and digitSum = 1 + 5 + 1 + 4 = 11. There...
[]
[]
1
stdio
Takahashi is going to set a 3-character password. How many possible passwords are there if each of its characters must be a digit between 1 and N (inclusive)? -----Constraints----- - 1 \leq N \leq 9 - N is an integer. -----Input----- Input is given from Standard Input in the following format: N -----Output----- Pr...
[ "2\n", "1\n", "3\n", "4\n", "5\n", "6\n", "7\n", "8\n", "9\n", "4" ]
[ "8\n", "1\n", "27\n", "64\n", "125\n", "216\n", "343\n", "512\n", "729\n", "64\n" ]
1
stdio
Given a sequence of numbers a1, a2, a3, ..., an, find the maximum sum of a contiguous subsequence of those numbers. Note that, a subsequence of one element is also a contiquous subsequence. Input The input consists of multiple datasets. Each data set consists of: n a1 a2 . . an You can assume that 1 ≤ n ≤ 5000 ...
[ "7\n-5\n-2\n6\n4\n9\n-6\n-7\n13\n1\n2\n3\n2\n-2\n-1\n1\n2\n3\n2\n1\n-2\n1\n3\n1000\n-200\n201\n0", "7\n-5\n-2\n6\n4\n9\n-6\n-7\n13\n1\n2\n3\n2\n-2\n-1\n1\n1\n3\n2\n1\n-2\n1\n3\n1000\n-200\n201\n0", "7\n-5\n-2\n6\n8\n9\n-6\n-7\n13\n1\n2\n3\n2\n-2\n-1\n1\n1\n3\n2\n1\n-2\n1\n3\n1000\n-200\n201\n0", "7\n-5\n-2\n6...
[ "19\n14\n1001\n", "19\n13\n1001\n", "23\n13\n1001\n", "23\n13\n1000\n", "19\n12\n1001\n", "19\n14\n1000\n", "18\n13\n1001\n", "19\n12\n1000\n", "23\n12\n1000\n", "19\n15\n1001\n" ]
1
stdio
We have A balls with the string S written on each of them and B balls with the string T written on each of them. From these balls, Takahashi chooses one with the string U written on it and throws it away. Find the number of balls with the string S and balls with the string T that we have now. -----Constraints----- ...
[ "red blue\n3 4\nred\n", "red blue\n5 5\nblue\n", "a b\n1 3\na\n", "aaa bbb\n10 10\nbbb\n", "abc arc\n3 6\nabc\n", "zzz xxx\n6 10\nxxx\n", "abcdeabcde opqrsopqrs\n7 2\nabcdeabcde\n", "length depth\n3 1\nlength\n", "rice bread\n3 6\nbread\n", "tea coffee\n4 4\ncoffee\n" ]
[ "2 4\n", "5 4\n", "0 3\n", "10 9\n", "2 6\n", "6 9\n", "6 2\n", "2 1\n", "3 5\n", "4 3\n" ]
1
stdio
Create a function that takes a positive integer and returns the next bigger number that can be formed by rearranging its digits. For example: ``` 12 ==> 21 513 ==> 531 2017 ==> 2071 ``` If the digits can't be rearranged to form a bigger number, return `-1` (or `nil` in Swift): ``` 9 ==> -1 111 ==> -1 531 ==> -1 ``` ...
[]
[]
1
stdio
Alice and Bob have participated to a Rock Off with their bands. A jury of true metalheads rates the two challenges, awarding points to the bands on a scale from 1 to 50 for three categories: Song Heaviness, Originality, and Members' outfits. For each one of these 3 categories they are going to be awarded one point, sh...
[]
[]
1
stdio
Imagine you have an infinite 2D plane with Cartesian coordinate system. Some of the integral points are blocked, and others are not. Two integral points A and B on the plane are 4-connected if and only if: * the Euclidean distance between A and B is one unit and neither A nor B is blocked; * or there is some inte...
[ "11\n", "0\n", "17\n", "18855321\n", "34609610\n", "25\n", "9\n", "40000000\n", "17464436\n", "38450759\n" ]
[ "60\n", "1\n", "96\n", "106661800\n", "195781516\n", "140\n", "48\n", "226274168\n", "98793768\n", "217510336\n" ]
1
stdio
Write a function that takes a positive integer n, sums all the cubed values from 1 to n, and returns that sum. Assume that the input n will always be a positive integer. Examples: ```python sum_cubes(2) > 9 # sum of the cubes of 1 and 2 is 1 + 8 ``` Write your solution by modifying this code: ```python def sum_cu...
[]
[]
1
stdio
AtCoder Inc. has decided to lock the door of its office with a 3-digit PIN code. The company has an N-digit lucky number, S. Takahashi, the president, will erase N-3 digits from S and concatenate the remaining 3 digits without changing the order to set the PIN code. How many different PIN codes can he set this way? ...
[ "19\n5546189040285140044", "19\n4753841743850076999", "19\n9039528710159876563", "19\n3616863455241776042", "19\n2785343766571511696", "19\n2922045480066417189", "19\n7230040539071200180", "19\n1036710694297327965", "19\n1455506616048969060", "19\n3356521006821128568" ]
[ "273\n", "311\n", "412\n", "322\n", "239\n", "281\n", "292\n", "364\n", "172\n", "210\n" ]
1
stdio
Gru has not been in the limelight for a long time and is, therefore, planning something particularly nefarious. Frustrated by his minions' incapability which has kept him away from the limelight, he has built a transmogrifier — a machine which mutates minions. Each minion has an intrinsic characteristic value (similar...
[ "1\n5 10\n2 4 1 35 1\n", "1\n5 10\n2 4 1 62 1", "1\n5 2\n0 4 1 3 1", "1\n5 20\n2 4 1 62 1", "1\n5 0\n0 4 0 7 1", "1\n5 0\n1 0 0 0 0", "1\n5 10\n2 4 1 3 1", "1\n5 3\n2 4 1 3 1", "1\n5 3\n2 4 0 3 1", "1\n5 3\n0 4 0 3 1" ]
[ "1\n", "1\n", "0\n", "2\n", "3\n", "4\n", "1\n", "1\n", "1\n", "1\n" ]
1
stdio
Given an array $a$ of length $n$, find another array, $b$, of length $n$ such that: for each $i$ $(1 \le i \le n)$ $MEX(\{b_1$, $b_2$, $\ldots$, $b_i\})=a_i$. The $MEX$ of a set of integers is the smallest non-negative integer that doesn't belong to this set. If such array doesn't exist, determine this. -----In...
[ "3\n1 2 3\n", "4\n0 0 0 2\n", "3\n1 1 3\n", "7\n0 0 2 2 5 5 6\n", "10\n1 2 3 4 4 4 7 7 7 10\n", "1\n1\n", "1\n0\n", "7\n0 0 2 2 5 5 6\n", "1\n1\n", "10\n1 2 3 4 4 4 7 7 7 10\n" ]
[ "0 1 2 ", "1 3 4 0 ", "0 2 1 ", "1 3 0 4 2 7 5 ", "0 1 2 3 5 6 4 8 9 7 ", "0 ", "1 ", "1 3 0 4 2 7 5\n", "0\n", "0 1 2 3 5 6 4 8 9 7\n" ]
1
stdio
An `non decreasing` number is one containing no two consecutive digits (left to right), whose the first is higer than the second. For example, 1235 is an non decreasing number, 1229 is too, but 123429 isn't. Write a function that finds the number of non decreasing numbers up to `10**N` (exclusive) where N is the input...
[]
[]
1
stdio
The magic sum of 3s is calculated on an array by summing up odd numbers which include the digit `3`. Write a function `magic_sum` which accepts an array of integers and returns the sum. *Example:* `[3, 12, 5, 8, 30, 13]` results in `16` (`3` + `13`) If the sum cannot be calculated, `0` should be returned. Write your...
[]
[]
1
stdio
Limak is a little bear who loves to play. Today he is playing by destroying block towers. He built n towers in a row. The i-th tower is made of h_{i} identical blocks. For clarification see picture for the first sample. Limak will repeat the following operation till everything is destroyed. Block is called internal i...
[ "6\n2 1 4 6 2 2\n", "7\n3 3 3 1 3 3 3\n", "7\n5128 5672 5805 5452 5882 5567 5032\n", "10\n1 2 2 3 5 5 5 4 2 1\n", "14\n20 20 20 20 20 20 3 20 20 20 20 20 20 20\n", "50\n3 2 4 3 5 3 4 5 3 2 3 3 3 4 5 4 2 2 3 3 4 4 3 2 3 3 2 3 4 4 5 2 5 2 3 5 4 4 2 2 3 5 2 5 2 2 5 4 5 4\n", "1\n1\n", "1\n1000000000\n", ...
[ "3\n", "2\n", "4\n", "5\n", "5\n", "4\n", "1\n", "1\n", "1\n", "1\n" ]
1
stdio