think_length
int64
270
30.9k
response_length
int64
135
3.21k
conversations
listlengths
2
2
9,857
858
[ { "from": "human", "value": "You are given two integers $a$ and $b$. Moreover, you are given a sequence $s_0, s_1, \\dots, s_{n}$. All values in $s$ are integers $1$ or $-1$. It's known that sequence is $k$-periodic and $k$ divides $n+1$. In other words, for each $k \\leq i \\leq n$ it's satisfied that $s_{...
4,407
652
[ { "from": "human", "value": "Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.\n\nYou are given a set of q possible operat...
1,416
432
[ { "from": "human", "value": "Least Distance\nMr. John has a habit of implementing new programming methods. This time he needs your help to solve a problem. He needs a method such that it accepts a series of numbers (all in single digits) and returns a typical answer. The answer must be the least distance be...
7,453
566
[ { "from": "human", "value": "You are the kingpin of a large network of criminal hackers. Legend has it there has never been a richer criminal than you. Not just because you are the smartest, but also because you are the stingiest.\n\nThe police have been after you for years, but they have never been able to...
11,521
936
[ { "from": "human", "value": "The Playfair cipher is a manual symmetric encryption technique and was the first digraph substitution cipher. The scheme was invented in 1854 by Charles Wheatstone, but bears the name of Lord Playfair who promoted the use of the cipher.\n\nThe Playfair cipher uses a $5$ by $5$ t...
1,459
443
[ { "from": "human", "value": "Given two strings S1 and S2 in lowercase, the task is to make them anagram. The only allowed operation is to remove a character from any string. Find the minimum number of characters to be deleted to make both the strings anagram. Two strings are called anagram of each other if ...
6,305
636
[ { "from": "human", "value": "Given two numbers n and x, find out the total number of ways n can be expressed as the sum of the Xth power of unique natural numbers. As the total number of ways can be very large, so return the number of ways modulo 10^{9 }+ 7. \nExample 1:\nInput: \nn = 10, x = 2\nOutput: \n1...
1,108
409
[ { "from": "human", "value": "Write a function \n\n`titleToNumber(title) or title_to_number(title) or titleToNb title ...`\n\n(depending on the language)\n\nthat given a column title as it appears in an Excel sheet, returns its corresponding column number. All column titles will be uppercase.\n\nExamples:\n`...
2,013
502
[ { "from": "human", "value": "On a shiny day, kindergarten kids are going to the picnic. All the kids bought some candies with them. As all of them bought different number of candies, soon quarrel started among them. Teacher decided to collect all the candies. Soon a huge heap of candies is created on the ta...
8,571
829
[ { "from": "human", "value": "Given a directed flow network where each edge has a capacity of flow it could allow, find the maximum flow over the network from source(S) to sink(T).\n\nNetwork will follow these rules:\nOnly one source(S) and only one sink(T).\nOther than source and sink, nodes are represented...
21,467
820
[ { "from": "human", "value": "You are given $n$ pairs of integers $(a_1, b_1), (a_2, b_2), \\ldots, (a_n, b_n)$. All of the integers in the pairs are distinct and are in the range from $1$ to $2 \\cdot n$ inclusive.\n\nLet's call a sequence of integers $x_1, x_2, \\ldots, x_{2k}$ good if either $x_1 < x_2 ...
2,429
512
[ { "from": "human", "value": "Jarvis is weak in computing palindromes for Alphanumeric characters.\nWhile Ironman is busy fighting Thanos, he needs to activate sonic punch but Jarvis is stuck in computing palindromes.\nYou are given a string S containing alphanumeric characters. Find out whether the string i...
3,182
513
[ { "from": "human", "value": "# Task\n Initially a number `1` is written on a board. It is possible to do the following operations with it:\n```\nmultiply the number by 3;\nincrease the number by 5.```\nYour task is to determine that using this two operations step by step, is it possible to obtain number `n`...
15,990
528
[ { "from": "human", "value": "Problem Description \n\nYou are an army personnel in the great army of the Zorin race, where you are a part of a team of n people.\nUnfortunately, your army has lost a war to an intergalactic species, genetically much advanced than yours.\nTheir captain Bruno have kept all your ...
8,340
705
[ { "from": "human", "value": "You are given an undirected graph with weighted edges. The length of some path between two vertices is the bitwise xor of weights of all edges belonging to this path (if some edge is traversed more than once, then it is included in bitwise xor the same number of times). You have...
17,602
1,355
[ { "from": "human", "value": "You are given an undirected graph consisting of $n$ vertices and $n$ edges, where $n$ is divisible by $6$. Each edge has a weight, which is a positive (greater than zero) integer.\n\nThe graph has the following structure: it is split into $\\frac{n}{3}$ triples of vertices, the ...
6,499
484
[ { "from": "human", "value": "Maxim wants to buy an apartment in a new house at Line Avenue of Metropolis. The house has n apartments that are numbered from 1 to n and are arranged in a row. Two apartments are adjacent if their indices differ by 1. Some of the apartments can already be inhabited, others are ...
11,516
804
[ { "from": "human", "value": "I'm afraid you're in a rather unfortunate situation. You've injured your leg, and are unable to walk, and a number of zombies are shuffling towards you, intent on eating your brains. Luckily, you're a crack shot, and have your trusty rifle to hand.\n\nThe zombies start at `range...
13,424
847
[ { "from": "human", "value": "Chef is going to organize a hill jumping competition and he is going to be one of the judges in it. In this competition there are N hills in a row, and the initial height of i-th hill is Ai. Participants are required to demonstrate their jumping skills by doing what the judges t...
3,358
623
[ { "from": "human", "value": "International Women's Day is coming soon! Polycarp is preparing for the holiday.\n\nThere are $n$ candy boxes in the shop for sale. The $i$-th box contains $d_i$ candies.\n\nPolycarp wants to prepare the maximum number of gifts for $k$ girls. Each gift will consist of exactly tw...
17,680
717
[ { "from": "human", "value": "<image>\n\n\nYou know the merry-go-round in the amusement park. Vehicles such as horses and carriages are fixed on a large disk, and it is a standard playset that the vehicle swings up and down at the same time as the disk rotates. A merry-go-round in an amusement park has two f...
1,393
502
[ { "from": "human", "value": "Read problem statements in [Mandarin], [Bengali], and [Russian] as well.\n\nChef has N slippers, L of which are left slippers and the rest are right slippers. Slippers must always be sold in pairs, where each pair contains one left and one right slipper. If each pair of slippers...
1,234
360
[ { "from": "human", "value": "Suppose you are a car driver and you have to drive a car on a track divided into \"N\" number of sub-tracks. You are also given the value of \"K\" i.e. the total kilometers the car can drive on each sub-track. If the car can't cover a sub-track, you can add any unit of Petrol to...
4,567
538
[ { "from": "human", "value": "Given the current exchange rate between the USD and the EUR is 1.1363636 write a function that will accept the Curency type to be returned and a list of the amounts that need to be converted.\n\nDon't forget this is a currency so the result will need to be rounded to the second ...
6,918
575
[ { "from": "human", "value": "# Task\n\nYou are given an array `a` of positive integers a. You may choose some integer `X` and update `a` several times, where to update means to perform the following operations:\n```\npick a contiguous subarray of length not greater than the given k;\nreplace all elements in...
14,090
773
[ { "from": "human", "value": "Given below is a binary tree. The task is to print the top view of binary tree. Top view of a binary tree is the set of nodes visible when the tree is viewed from the top. For the given below tree\n 1\n / \\\n 2 3\n / \\ / \\\n4 5 6 7\nTop view ...
3,151
704
[ { "from": "human", "value": "You are on your way to your first job interview as a program tester, and you are already late. The interview is in a skyscraper and you are currently in floor $s$, where you see an elevator. Upon entering the elvator, you learn that it has only two buttons, marked \"UP $u$\" and...
6,030
670
[ { "from": "human", "value": "We have a S cm long stick.It can be broken only at certain\npositions.Sarah wants to calculate the number of GOOD Pairs.\nIt satisfies the following conditions\nA good pair consists of 2 distinct positions where the stick can be\n broken.\nWhen the stick is broken at these two...
12,678
753
[ { "from": "human", "value": "Per is repairing roads. The job is concentrated on roads with one lane in each direction. Thus, when Per closes down the lane in one direction, all traffic has to go through the other lane. This is done by allowing only one direction of travel at any time. Per is often assigned ...
2,059
616
[ { "from": "human", "value": "Little Joty has got a task to do. She has a line of n tiles indexed from 1 to n. She has to paint them in a strange pattern.\n\nAn unpainted tile should be painted Red if it's index is divisible by a and an unpainted tile should be painted Blue if it's index is divisible by b. S...
2,029
576
[ { "from": "human", "value": "On a clear night, a boy, Campanella looked up at the sky, there were many stars which have different colors such as red, yellow, green, blue, purple, etc. He was watching the stars and just lost track of time. Presently, he wondered,\n\n| <image>\n---|---\n\n\"There are many st...
5,070
496
[ { "from": "human", "value": "Developers often face with regular expression patterns. A pattern is usually defined as a string consisting of characters and metacharacters that sets the rules for your search. These patterns are most often used to check whether a particular string meets the certain rules.\n\nI...
5,450
683
[ { "from": "human", "value": "Famil Door wants to celebrate his birthday with his friends from Far Far Away. He has *n* friends and each of them can come to the party in a specific range of days of the year from *a**i* to *b**i*. Of course, Famil Door wants to have as many friends celebrating together with h...
19,959
2,157
[ { "from": "human", "value": "You just finished participating in a programming contest with your friend. Unfortunately, you were unable to All Kill the contest (i.e., solve all of the problems), but you are now wondering if there might be some strategy that would have solved all of the problems.\n\nSolving a...
13,314
761
[ { "from": "human", "value": "Chef wants to impress Chefina by giving her the maximum number of gifts possible.\n\nChef is in a gift shop having N items where the cost of the i^{th} item is equal to A_{i}.\nChef has K amount of money and a 50 \\% off discount coupon that he can use for at most one of the ite...
1,102
393
[ { "from": "human", "value": "=====Function Descriptions=====\nzeros\n\nThe zeros tool returns a new array with a given shape and type filled with 0's.\n\nimport numpy\n\nprint numpy.zeros((1,2)) #Default type is float\n#Output : [[ 0. 0.]] \n\nprint numpy.zeros((1,2), dtype = numpy.int) ...
10,525
689
[ { "from": "human", "value": "Elon Musk has succesfully built an automated staircase from Earth to Mars. Many people want to go to Mars, but that's not possible due to limited capacity of the staircase and logistics involved. Hence, Elon asks interested candidates to solve a tough challenge. If they solve it...
2,448
379
[ { "from": "human", "value": "Write\n\n```python\nfunction combine()\n```\n\nthat combines arrays by alternatingly taking elements passed to it.\n\nE.g\n\n```python\ncombine(['a', 'b', 'c'], [1, 2, 3]) == ['a', 1, 'b', 2, 'c', 3]\ncombine(['a', 'b', 'c'], [1, 2, 3, 4, 5]) == ['a', 1, 'b', 2, 'c', 3, 4, 5]\nc...
26,419
1,681
[ { "from": "human", "value": "Many countries have such a New Year or Christmas tradition as writing a letter to Santa including a wish list for presents. Vasya is an ordinary programmer boy. Like all ordinary boys, he is going to write the letter to Santa on the New Year Eve (we Russians actually expect Sant...
20,710
921
[ { "from": "human", "value": "Given a single positive integer x, we will write an expression of the form x (op1) x (op2) x (op3) x ... where each operator op1, op2, etc. is either addition, subtraction, multiplication, or division (+, -, *, or /).  For example, with x = 3, we might write 3 * 3 / 3 + 3 - 3 wh...
5,449
592
[ { "from": "human", "value": "A tennis tournament is about to take place with $N$ players participating in it.\nEvery player plays with every other player exactly once and there are no ties. That is, every match has a winner and a loser. \nWith Naman's birthday approaching, he wants to make sure that each pl...
2,652
692
[ { "from": "human", "value": "Given a Binary Tree of size N. The task is to complete the function sumLeaf(), that should return the sum of all the leaf nodes of the given binary tree.\nInput:\nFirst line of input contains number of testcases T. For each testcase, there will be two lines, first of which conta...
13,542
639
[ { "from": "human", "value": "Bash likes playing with arrays. He has an array *a*1,<=*a*2,<=... *a**n* of *n* integers. He likes to guess the greatest common divisor (gcd) of different segments of the array. Of course, sometimes the guess is not correct. However, Bash will be satisfied if his guess is almost...
1,038
459
[ { "from": "human", "value": "Write a function, `persistence`, that takes in a positive parameter `num` and returns its multiplicative persistence, which is the number of times you must multiply the digits in `num` until you reach a single digit.\n\nFor example:\n\n```python\n persistence(39) => 3 # Because...
2,534
537
[ { "from": "human", "value": "Once N boys and M girls attended a party. You are given a matrix A of N rows and M columns where Aij is 1 if the i-th boy likes the j-th girl, otherwise it will be 0. Note that it is not necessary that if a boy x likes girl y, then girl y should like boy x.\nYou know that if the...
5,664
428
[ { "from": "human", "value": "Compare two strings by comparing the sum of their values (ASCII character code).\n\n* For comparing treat all letters as UpperCase\n* `null/NULL/Nil/None` should be treated as empty strings\n* If the string contains other characters than letters, treat the whole string as it wou...
4,677
539
[ { "from": "human", "value": "Valera runs a 24/7 fast food cafe. He magically learned that next day n people will visit his cafe. For each person we know the arrival time: the i-th person comes exactly at hi hours mi minutes. The cafe spends less than a minute to serve each client, but if a client comes in a...
1,460
452
[ { "from": "human", "value": "There is a hacker named \"Vijay\" who has developed a method to check whether an id at some social networking site is fake or real using its username.\nHis method includes: if the number of distinct consonent characters in one's user name is odd, then the user is a male, otherwi...
3,016
424
[ { "from": "human", "value": "Given five positive integers, find the minimum and maximum values that can be calculated by summing exactly four of the five integers. Then print the respective minimum and maximum values as a single line of two space-separated long integers. \n\nExample \n\n$arr=[1,3,5,7,9]$\n...
6,349
742
[ { "from": "human", "value": "It is the Indian version of the famous heist \"The Italian Job\". N robbers have already broken into the National Museum and are just about to get inside the main vault which is full of jewels. They were lucky that just as they broke into the museum, the guard was leaving the mu...
15,409
1,043
[ { "from": "human", "value": "Disclaimer: there are lots of untranslateable puns in the Russian version of the statement, so there is one more reason for you to learn Russian :)\n\nRick and Morty like to go to the ridge High Cry for crying loudly — there is an extraordinary echo. Recently they discovered an ...
9,740
1,013
[ { "from": "human", "value": "problem\n\nJOI City will hold a large-scale exposition.\n\nThere are two themes for this exposition, and each of the N exhibition facilities in JOI City will exhibit on one of the two themes.\n\nThe location of the facility is represented by plane coordinates (x, y). To move fro...
441
353
[ { "from": "human", "value": "Write a function that takes a string which has integers inside it separated by spaces, and your task is to convert each integer in the string into an integer and return their sum.\n\n### Example\n```python\nsummy(\"1 2 3\") ==> 6\n```\n\nGood luck!" }, { "from": "gpt", ...
3,354
650
[ { "from": "human", "value": "The squarefree part of a positive integer is the largest divisor of that integer which itself has no square factors (other than 1). For example, the squareefree part of 12 is 6, since the only larger divisor is 12, and 12 has a square factor (namely, 4).\n\nYour challenge, shoul...
6,271
534
[ { "from": "human", "value": "You are given an integer $n$ and an integer $k$.\n\nIn one step you can do one of the following moves: decrease $n$ by $1$; divide $n$ by $k$ if $n$ is divisible by $k$. \n\nFor example, if $n = 27$ and $k = 3$ you can do the following steps: $27 \\rightarrow 26 \\rightarrow ...
15,102
532
[ { "from": "human", "value": "Little penguin Polo loves his home village. The village has n houses, indexed by integers from 1 to n. Each house has a plaque containing an integer, the i-th house has a plaque containing integer pi (1 ≤ pi ≤ n).\n\nLittle penguin Polo loves walking around this village. The wal...
3,508
670
[ { "from": "human", "value": "In Berland the opposition is going to arrange mass walking on the boulevard. The boulevard consists of *n* tiles that are lain in a row and are numbered from 1 to *n* from right to left. The opposition should start walking on the tile number 1 and the finish on the tile number *...
1,057
420
[ { "from": "human", "value": "Given a series of numbers 2, 10, 30, 68, 130.., Identify the pattern in the series. You are given an integer X you need to find out the X'th number in the series.\nExample 1:\nInput:\nX = 1\nOutput:\n2\nExplanation:\n2 is the first number in the series.\nExample 2:\nInput:\nX = ...
18,064
1,565
[ { "from": "human", "value": "Alice: How can it be?\n\n Rabbit: Trust me Alice. It always takes the same time. When I go from my home up the road to Queen of Hearts' Castle, my watch counts nine hours. However, if I continue down to Mad Hatter's House, my watch counts just two hours in total. Isn't that grea...
17,782
636
[ { "from": "human", "value": "You are given an array $a$ of $n$ integers. Initially there is only one copy of the given array.\n\nYou can do operations of two types:\n\nChoose any array and clone it. After that there is one more copy of the chosen array.\n\nSwap two elements from any two copies (maybe in the...
4,418
576
[ { "from": "human", "value": "Michael and Joe are playing a game. The game is played on a grid with $n$ rows and $m$ columns, filled with distinct integers. We denote the square on the $i$-th ($1\\le i\\le n$) row and $j$-th ($1\\le j\\le m$) column by $(i, j)$ and the number there by $a_{ij}$.\n\nMichael st...
12,233
1,022
[ { "from": "human", "value": "Lena is playing with matches. The natural question arising in the head of any child playing with matches is whether it's possible to set a tree on fire with a matches, or not.\n\nLet's say, that the tree is a connected graph without cycles and the vertices are labeled with integ...
3,578
556
[ { "from": "human", "value": "Aureole the Techno-cultural fest of JEC thought of conducting a workshop on big data, as the topic is hot everyone wants to take part but due to limited seats in the Jashan Auditorium there is a selection criteria, a problem is given.\nthe problem states a string is to be compre...
1,758
560
[ { "from": "human", "value": "Given an array A of n positive numbers. The task is to find the first Equilibrium Point in an array. \nEquilibrium Point in an array is a position such that the sum of elements before it is equal to the sum of elements after it.\nNote: Retun the index of Equilibrium point. (1-ba...
4,584
775
[ { "from": "human", "value": "Congratulations! You are now the judge of a programming contest! You've been put in charge of a problem, and since your problem may not have unique correct output, you've got to write an output checker for it.\n\nYour problem is called \"Good as Goldbach\", and it's based on the...
5,675
706
[ { "from": "human", "value": "Polycarp has n coins, the value of the i-th coin is a_i. It is guaranteed that all the values are integer powers of 2 (i.e. a_i = 2^d for some non-negative integer number d).\n\nPolycarp wants to know answers on q queries. The j-th query is described as integer number b_j. The a...
839
379
[ { "from": "human", "value": "Vasya is very upset that many people on the Net mix uppercase and lowercase letters in one word. That's why he decided to invent an extension for his favorite browser that would change the letters' register in every word so that it either only consisted of lowercase letters or, ...
7,886
622
[ { "from": "human", "value": "Problem A: Swap crypto\n\nA 2D enthusiast at R University, he often writes embarrassing sentences that blush when seen by people. Therefore, in order for a third party to not be able to see the text he is writing, he encrypts the text using a method called swap encryption that h...
2,158
534
[ { "from": "human", "value": "Given an integer N, find the sum of odd numbers and even numbers from 1 to N.\n \nExample 1:\nInput: 5\nOutput: 9 6\nExplanation: Odd numbers upto 5 are 1, 3, 5\nand their sum = 1 + 3 + 5 = 9.Even numbers\nupto 5 are 2 and 4 and their sum = 2 + 4 = 6.\nExample 1:\nInput: 6\nOutp...
1,774
467
[ { "from": "human", "value": "# Task\n Suppose there are `n` people standing in a circle and they are numbered 1 through n in order. \n \n Person 1 starts off with a sword and kills person 2. He then passes the sword to the next person still standing, in this case person 3. Person 3 then uses the sword to ki...
4,175
460
[ { "from": "human", "value": "# Task\n Given string `s`, which contains only letters from `a to z` in lowercase.\n\n A set of alphabet is given by `abcdefghijklmnopqrstuvwxyz`.\n \n 2 sets of alphabets mean 2 or more alphabets.\n \n Your task is to find the missing letter(s). You may need to output them by t...
2,061
479
[ { "from": "human", "value": "You are given the array a consisting of n positive (greater than zero) integers.\n\nIn one move, you can choose two indices i and j (i ≠ j) such that the absolute difference between a_i and a_j is no more than one (|a_i - a_j| ≤ 1) and remove the smallest of these two elements. ...
15,820
607
[ { "from": "human", "value": "Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.\n\nChef has a sequence $A_{1}, A_{2}, \\ldots, A_{N}$. The sequence is circular, i.e. for each valid $i$, elements $A_{i}$ and $A_{i+1}$ are considered adjacent, and elements ...
12,310
952
[ { "from": "human", "value": "Chef came across a new online judge that has N problems, and decided that he wants to solve them.\n\nChef takes A_{i} consecutive minutes to solve the i-th problem, and will take a break of B_{i} minutes immediately after solving it. \nThat is, Chef will solve a problem, then...
6,110
536
[ { "from": "human", "value": "There is a new attraction in Singapore Zoo: The Infinite Zoo.\n\nThe Infinite Zoo can be represented by a graph with an infinite number of vertices labeled 1,2,3,…. There is a directed edge from vertex u to vertex u+v if and only if u\\&v=v, where \\& denotes the [bitwise AND op...
5,323
556
[ { "from": "human", "value": "There is a robot staying at X=0 on the Ox axis. He has to walk to X=n. You are controlling this robot and controlling how he goes. The robot has a battery and an accumulator with a solar panel.\n\nThe i-th segment of the path (from X=i-1 to X=i) can be exposed to sunlight or not...
1,354
480
[ { "from": "human", "value": "Andrew likes meatballs very much.\nHe has N plates of meatballs, here the i^{th} plate contains P_{i} meatballs. You need to find the minimal number of plates Andrew needs to take to his trip to Las Vegas, if he wants to eat there at least M meatballs. Note that each plate is al...
8,097
723
[ { "from": "human", "value": "# Story\n\nYou and a group of friends are earning some extra money in the school holidays by re-painting the numbers on people's letterboxes for a small fee.\n\nSince there are 10 of you in the group each person just concentrates on painting one digit! For example, somebody will...
12,074
1,029
[ { "from": "human", "value": "\"Balloons should be captured efficiently\", the game designer says. He is designing an oldfashioned game with two dimensional graphics. In the game, balloons fall onto the ground one after another, and the player manipulates a robot vehicle on the ground to capture the balloons...
8,924
610
[ { "from": "human", "value": "Given a string S and a string T, count the number of distinct subsequences of S which equals T.\n\nA subsequence of a string is a new string which is formed from the original string by deleting some (can be none) of the characters without disturbing the relative positions of the...
15,391
894
[ { "from": "human", "value": "Let's tell you the legendary story of two famous kings William and Harold . Both were sworn enemies of each other & William want to conquer the Harold's city . But first William has to defeat Harold's army.\n\nHarold has an army not a huge one but a tactical one. He has got team...
10,878
968
[ { "from": "human", "value": "Read problems statements in Mandarin Chinese and Russian. \n\nTime flies fast, Chef's sons are getting older, stronger and higher. Chef has got two sons and they don't go well with each other. Their relations are getting worse day by day. Concerned Chef has now decided to separ...
9,634
903
[ { "from": "human", "value": "Ayoub had an array $a$ of integers of size $n$ and this array had two interesting properties: All the integers in the array were between $l$ and $r$ (inclusive). The sum of all the elements was divisible by $3$. \n\nUnfortunately, Ayoub has lost his array, but he remembers th...
20,421
545
[ { "from": "human", "value": "Limak is a little polar bear. He doesn't have many toys and thus he often plays with polynomials.\n\nHe considers a polynomial valid if its degree is n and its coefficients are integers not exceeding k by the absolute value. More formally:\n\nLet a_0, a_1, ..., a_{n} denote the ...
15,932
535
[ { "from": "human", "value": "Given a sorted array arr of n distinct elements and an integer k. The array elements denote positions of points on 1-D number line, find the maximum size of subset of points that can have consecutive values of points which can be formed by placing another k points on the number ...
8,590
1,322
[ { "from": "human", "value": "You are given circular array *a*0,<=*a*1,<=...,<=*a**n*<=-<=1. There are two types of operations with it: \n - *inc*(*lf*,<=*rg*,<=*v*) — this operation increases each element on the segment [*lf*,<=*rg*] (inclusively) by *v*; - *rmq*(*lf*,<=*rg*) — this operation returns mini...
7,227
815
[ { "from": "human", "value": "Define S = [s,n] as the string S which consists of n connected strings s. For example, [\"abc\", 3] =\"abcabcabc\". \nOn the other hand, we define that string s1 can be obtained from string s2 if we can remove some characters from s2 such that it becomes s1. For example, \"abc\"...
12,406
1,349
[ { "from": "human", "value": "Russian translation\n\nLet's consider some weird country with N cities and M bidirectional roads of 3 types. It's weird because of some unusual rules about using these roads: men can use roads of types 1 and 3 only and women can use roads of types 2 and 3 only. Please answer the...
2,463
554
[ { "from": "human", "value": "Let's say that in a hypothetical platform that resembles Codewars there is a clan with 2 warriors. The 2nd one in ranking (lets call him **D**) wants to at least reach the honor score of his ally (lets call her **M**). \n*(Let's say that there is no antagonism here, he just want...
5,358
750
[ { "from": "human", "value": "Given a boolean 2D array of n x m dimensions where each row is sorted. Find the 0-based index of the first row that has the maximum number of 1's.\nExample 1:\nInput: \nN = 4 , M = 4\nArr[][] = {{0, 1, 1, 1},\n {0, 0, 1, 1},\n {1, 1, 1, 1},\n {0, 0,...
15,535
937
[ { "from": "human", "value": "Voritex a big data scientist collected huge amount of big data having structure of two rows and n columns.\nVoritex is storing all the valid data for manipulations and pressing invalid command when data not satisfying the constraints.\nVoritex likes brute force method and he cal...
2,777
713
[ { "from": "human", "value": "Dreamoon is standing at the position 0 on a number line. Drazil is sending a list of commands through Wi-Fi to Dreamoon's smartphone and Dreamoon follows them.\n\nEach command is one of the following two types: \n 1. Go 1 unit towards the positive direction, denoted as '+' 1. ...
15,729
823
[ { "from": "human", "value": "In the autumn of this year, two Russian teams came into the group stage of the most prestigious football club competition in the world — the UEFA Champions League. Now, these teams have already started to play in the group stage and are fighting for advancing to the playoffs. In...
8,791
785
[ { "from": "human", "value": "Given a string S with repeated characters. The task is to rearrange characters in a string such that no two adjacent characters are the same.\nNote: The string has only lowercase English alphabets and it can have multiple solutions. Return any one of them.\nExample 1:\nInput : s...
8,224
894
[ { "from": "human", "value": "Given a number N , calculate total number of permutations of it and also the sum of all permutations including that number itself.\n \nExample 1:\nInput: N = 5\nOutput: 1 5\nExplanation: There is only one permutation\nof 5 and sum of this permutaion is 5.\nExample 2:\nInput: N =...
2,107
456
[ { "from": "human", "value": "Many cats live on the campus of a school. Natsume's daily routine is to pet those cats. However, the cats may be capricious and go for a walk off campus.\n\nThe campus site is a rectangle with each side parallel to the x-axis or y-axis and is surrounded by a fence except for the...
3,001
461
[ { "from": "human", "value": "Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.\n\nChef recently visited ShareChat Cafe and was highly impressed by the food. Being a food enthusiast, he decided to enquire about the ingredients of each dish.\n\nThere are $...
13,844
890
[ { "from": "human", "value": "You love array, don't you?\n\nYou are given two integer N and M, along with an array B of length N containing pairwise distinct integers. You have to find the number of array A of length N satisfying the follow conditions:\n\n1. 1 ≤ A_{i} ≤ M.\n2. A_{i} \\neq A_{j} for all 1 ≤ i...
1,942
371
[ { "from": "human", "value": "Problem Statement \nUnseen gang is the team of most wanted criminal. Unseen gang has planted bombs in different street and corner of the city. Gang members are sitting in the other part of the city, far away from the bomb site. They are controlling the bomb by sending the activa...
3,753
811
[ { "from": "human", "value": "There is a cube which consists of n × n × n small cubes. Small cubes have marks on their surfaces. An example where n = 4 is shown in the following figure.\n\n\n<image>\n\n\nThen, as shown in the figure above (right), make a hole that penetrates horizontally or vertically from t...