think_length int64 270 30.9k | response_length int64 135 3.21k | conversations listlengths 2 2 |
|---|---|---|
18,208 | 617 | [
{
"from": "human",
"value": "People in the Tomskaya region like magic formulas very much. You can see some of them below.\n\nImagine you are given a sequence of positive integer numbers p_1, p_2, ..., p_{n}. Lets write down some magic formulas:$q_{i} = p_{i} \\oplus(i \\operatorname{mod} 1) \\oplus(i \\oper... |
1,223 | 503 | [
{
"from": "human",
"value": "Write a function that takes an integer and returns an array `[A, B, C]`, where `A` is the number of multiples of 3 (but not 5) below the given integer, `B` is the number of multiples of 5 (but not 3) below the given integer and `C` is the number of multiples of 3 and 5 below the... |
3,114 | 471 | [
{
"from": "human",
"value": "Dawid has four bags of candies. The i-th of them contains a_i candies. Also, Dawid has two friends. He wants to give each bag to one of his two friends. Is it possible to distribute the bags in such a way that each friend receives the same amount of candies in total?\n\nNote, th... |
1,748 | 475 | [
{
"from": "human",
"value": "Given an array of N positive integers, find GCD of all the array elements.\nExample 1:\nInput: N = 3, arr[] = {2, 4, 6}\nOutput: 2\nExplanation: GCD of 2,4,6 is 2.\nExample 2:\nInput: N = 1, arr[] = {1}\nOutput: 1\nExplanation: Greatest common divisor of\nall the numbers is 1.\n... |
9,357 | 517 | [
{
"from": "human",
"value": "Permutation p is an ordered set of integers p1, p2, ..., pn, consisting of n distinct positive integers not larger than n. We'll denote as n the length of permutation p1, p2, ..., pn.\n\nYour task is to find such permutation p of length n, that the group of numbers |p1 - p2|, |p... |
15,759 | 478 | [
{
"from": "human",
"value": "Bomboslav likes to look out of the window in his room and watch lads outside playing famous shell game. The game is played by two persons: operator and player. Operator takes three similar opaque shells and places a ball beneath one of them. Then he shuffles the shells by swappi... |
914 | 387 | [
{
"from": "human",
"value": "You are given two arrays A and B of equal length N. Your task is to pair each element of array A to an element in array B, such that the sum of the absolute differences of all the pairs is minimum.\nExample 1:\nInput:\nN = 4\nA = {4,1,8,7}\nB = {2,3,6,5}\nOutput:\n6\nExplanation... |
21,268 | 737 | [
{
"from": "human",
"value": "You are given n non-decreasing arrays of non-negative numbers. \n\nVasya repeats the following operation k times: \n\n * Selects a non-empty array. \n * Puts the first element of the selected array in his pocket. \n * Removes the first element from the selected array. \n\n\n\... |
3,424 | 511 | [
{
"from": "human",
"value": "Chef likes problems involving arrays. Unfortunately, the last one he tried to solve didn't quite get solved.\n\n\nChef has an array A of N positive numbers. He wants to find the number of subarrays for which the sum and product of elements are equal.\n\n\nPlease help Chef find t... |
13,110 | 1,023 | [
{
"from": "human",
"value": "Theta has been learning about powers of $2$ in school. She notices that some numbers when written out contain powers of $2$ in their digit representation: for instance, $12560$ contains $256$ which is a power of $2$. She has been wondering how many such numbers there are.\n\nCan... |
11,258 | 670 | [
{
"from": "human",
"value": "Can the greatest common divisor and bitwise operations have anything in common? It is time to answer this question.\n\nSuppose you are given a positive integer $a$. You want to choose some integer $b$ from $1$ to $a - 1$ inclusive in such a way that the greatest common divisor (... |
5,104 | 548 | [
{
"from": "human",
"value": "Misha hacked the Codeforces site. Then he decided to let all the users change their handles. A user can now change his handle any number of times. But each new handle must not be equal to any handle that is already used or that was used at some point.\n\nMisha has a list of hand... |
4,901 | 451 | [
{
"from": "human",
"value": "Problem description\nTris (or as her parents call her Beatrice) is going through a series of training and evaluation to get into top 10 and remain in Dauntless Faction. She is currently placed 12th and will become faction-less if she fails, today. \nFour (or Tobias) gives Tris a... |
17,088 | 921 | [
{
"from": "human",
"value": "The ugliness of a sequence of size N is defined as the number of pairs of neighboring elements which are not equal to each other. Formally, the ugliness of a sequence increase by 1 if for a value of i, 2 β€ i β€ N, the following condition holds true:\nA_{i} \\neq A_{i-1}.\n\nExamp... |
2,650 | 740 | [
{
"from": "human",
"value": "Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order.\n\nExample 1:\n\n\nInput:\n[\n [ 1, 2, 3 ],\n [ 4, 5, 6 ],\n [ 7, 8, 9 ]\n]\nOutput: [1,2,3,6,9,8,7,4,5]\n\n\nExample 2:\n\nInput:\n[\n [1, 2, 3, 4],\n [5, 6, 7, 8],\n [9,... |
2,933 | 409 | [
{
"from": "human",
"value": "You will receive 3 points for solving this problem.\n\nManao is designing the genetic code for a new type of algae to efficiently produce fuel. Specifically, Manao is focusing on a stretch of DNA that encodes one protein. The stretch of DNA is represented by a string containing ... |
2,313 | 409 | [
{
"from": "human",
"value": "Write a function which reduces fractions to their simplest form! Fractions will be presented as an array/tuple (depending on the language), and the reduced fraction must be returned as an array/tuple:\n\n```\ninput: [numerator, denominator]\noutput: [newNumerator, newDenomina... |
1,654 | 570 | [
{
"from": "human",
"value": "Vanya got an important task β he should enumerate books in the library and label each book with its number. Each of the *n* books should be assigned with a number from 1 to *n*. Naturally, distinct books should be assigned distinct numbers.\n\nVanya wants to know how many digits... |
1,881 | 503 | [
{
"from": "human",
"value": "Count the given numbers on your fingers and find the correct finger on which the number ends.\n\tThe first number starts from the thumb, second on the index finger, third on the middle finger, fourth on the ring finger and fifth on the little finger.\n\tAgain six comes on the ri... |
4,820 | 704 | [
{
"from": "human",
"value": "Musicians of a popular band \"Flayer\" have announced that they are going to \"make their exit\" with a world tour. Of course, they will visit Berland as well.\n\nThere are *n* cities in Berland. People can travel between cities using two-directional train routes; there are exac... |
890 | 404 | [
{
"from": "human",
"value": "You are in charge of the cake for a child's birthday. You have decided the cake will have one candle for each year of their total age. They will only be able to blow out the tallest of the candles. Count how many candles are tallest. \n\nExample \n\n$candles=[4,4,1,3]$\n\nThe ... |
3,153 | 535 | [
{
"from": "human",
"value": "Given aΒ string s and an array of integers cost where cost[i]Β is the cost of deleting the ith character in s.\nReturn the minimum cost of deletions such that there are no two identical letters next to each other.\nNotice that you will delete the chosen characters at the same time... |
21,542 | 1,400 | [
{
"from": "human",
"value": "Read problems statements in Mandarin chinese, Russian and Vietnamese as well. \n\nYou are given N red points and M blue points on a 2D plane.\n\nYou are required to delete the minimum number of points(the deleted points can be of both colors) so that it's possible to draw a line... |
7,427 | 508 | [
{
"from": "human",
"value": "Given an array of size n which contains all elements occurring in multiples of K, except one element which doesn't occur in multiple of K. Find that unique element.\n \nExample 1:\nInput : \nn = 7, k = 3\narr[] = {6, 2, 5, 2, 2, 6, 6}\nOutput : \n5\nExplanation:\nEvery element a... |
8,050 | 626 | [
{
"from": "human",
"value": "A regular octagon with vertices X1, X2,..., X8 is provided. A frog starts jumping from the vertex X1. It may jump to any of the two adjacent vertices in one jump except from X5. When it reaches X5, it stops and stays there. Let P(n) be the number of distinct paths of exactly n j... |
5,108 | 600 | [
{
"from": "human",
"value": "The Government of Greedistan has just found out that there is a lot of gold beneath some land area in their country. They quickly surveyed the land area and found that some people are living there, and surprisingly the houses are organized in a M x N grid, each cell having exact... |
3,618 | 652 | [
{
"from": "human",
"value": "Sherlock Holmes suspects his archenemy Professor Moriarty is once again plotting something diabolical. Sherlock's companion, Dr. Watson, suggests Moriarty may be responsible for MI6's recent issues with their supercomputer, The Beast. \n\nShortly after resolving to investigate, ... |
1,863 | 492 | [
{
"from": "human",
"value": "Everybody knows that opposites attract. That is the key principle of the \"Perfect Matching\" dating agency. The \"Perfect Matching\" matchmakers have classified each registered customer by his interests and assigned to the i-th client number ti ( - 10 β€ ti β€ 10). Of course, one... |
1,082 | 479 | [
{
"from": "human",
"value": "In order to write a string, Atilla needs to first learn all letters that are contained in the string.\n\nAtilla needs to write a message which can be represented as a string $s$. He asks you what is the minimum alphabet size required so that one can write this message.\n\nThe al... |
2,305 | 529 | [
{
"from": "human",
"value": "collections.Counter() \n\n A counter is a container that stores elements as dictionary keys, and their counts are stored as dictionary values.\n\n Sample Code \n\n>>> from collections import Counter\n>>> \n>>> myList = [1,1,2,3,4,5,3,2,3,4,2,1,2,3]\n>>> print Counter(myList)\nCo... |
1,175 | 486 | [
{
"from": "human",
"value": "A new school year is approaching, which also means students will be taking tests. \n\nThe tests in this kata are to be graded in different ways. A certain number of points will be given for each correct answer and a certain number of points will be deducted for each incorrect an... |
18,448 | 677 | [
{
"from": "human",
"value": "There is a universal library, where there is a big waiting room with seating capacity for maximum $m$ people, each of whom completes reading $n$ books sequentially. Reading each book requires one unit of time. \nUnfortunately, reading service is provided sequentially. After all ... |
8,861 | 922 | [
{
"from": "human",
"value": "Cherry has a binary matrix $A$ consisting of $N$ rows and $M$ columns. The rows are numbered from $1$ to $N$, columns are numbered from $1$ to $M$. Element at row $i$ ($1$ββ€β$i$ββ€β$N$) and column $j$ ($1$ββ€β$j$ββ€ $M$) is denoted as $A_{ij}$. All elements of $A$ are either $0$ or... |
4,436 | 523 | [
{
"from": "human",
"value": "We'll define S(n) for positive integer n as follows: the number of the n's digits in the decimal base. For example, S(893) = 3, S(114514) = 6.\n\nYou want to make a consecutive integer sequence starting from number m (m, m + 1, ...). But you need to pay S(n)Β·k to add the number ... |
5,502 | 626 | [
{
"from": "human",
"value": "#### Task:\n\nYour job here is to implement a method, `approx_root` in Ruby/Python/Crystal and `approxRoot` in JavaScript/CoffeeScript, that takes one argument, `n`, and returns the approximate square root of that number, rounded to the nearest hundredth and computed in the foll... |
13,360 | 978 | [
{
"from": "human",
"value": "Vasya plays the LionAge II. He was bored of playing with a stupid computer, so he installed this popular MMORPG, to fight with his friends. Vasya came up with the name of his character β non-empty string *s*, consisting of a lowercase Latin letters. However, in order not to put ... |
2,106 | 517 | [
{
"from": "human",
"value": "The Monk is trying to explain to its users that even a single unit of time can be extremely important and to demonstrate this particular fact he gives them a challenging task. \n\nThere are N processes to be completed by you, the chosen one, since you're Monk's favorite student... |
12,116 | 849 | [
{
"from": "human",
"value": "Maheshmati and Sangu are playing a game. First, Maheshmati gives Sangu a sequence of $N$ distinct integers $a_1, a_2, \\dots, a_N$ (not necessarily sorted) and an integer $K$. Sangu has to create all subsequences of this sequence with length $K$. For each subsequence, he has to ... |
4,995 | 721 | [
{
"from": "human",
"value": "Chef loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.\n\nLet F_{d}(x) equals to the number of digits d in decimal r... |
1,963 | 422 | [
{
"from": "human",
"value": "As a Swede, you hold a deep love for the traditional Thursday lunch of pea soup and pancakes. You love it so much, in fact, that you will eat it any meal it is available. You find yourself looking at the menus for all your favorite restaurants every day to see if this combinatio... |
11,851 | 609 | [
{
"from": "human",
"value": "You are given an array d_1, d_2, ..., d_n consisting of n integer numbers.\n\nYour task is to split this array into three parts (some of which may be empty) in such a way that each element of the array belongs to exactly one of the three parts, and each of the parts forms a cons... |
9,876 | 889 | [
{
"from": "human",
"value": "Let us call two integers $x$ and $y$ adjacent if $\\frac{lcm(x, y)}{gcd(x, y)}$ is a perfect square. For example, $3$ and $12$ are adjacent, but $6$ and $9$ are not.\n\nHere $gcd(x, y)$ denotes the greatest common divisor (GCD) of integers $x$ and $y$, and $lcm(x, y)$ denotes th... |
3,520 | 694 | [
{
"from": "human",
"value": "Your task is to write a program which reads a date (from 2004/1/1 to 2004/12/31) and prints the day of the date. Jan. 1, 2004, is Thursday. Note that 2004 is a leap year and we have Feb. 29.\n\n\n\nInput\n\nThe input is a sequence of datasets. The end of the input is indicated b... |
1,582 | 342 | [
{
"from": "human",
"value": "Pushkar is very good in Number Theory. He takes two numbers $A\\ and\\ B$ and declares them a Pushkar Pair. Pushkar Pair has a property that $A$ has a $Modular\\ Inverse$ modulo $B$. \nHe asks you to tell him the largest number $L$ that divides both of them. \n\n-----Input:---... |
7,713 | 796 | [
{
"from": "human",
"value": "You are given an integer, $N$. Your task is to print an alphabet rangoli of size $N$.\n(Rangoli is a form of Indian folk art based on creation of patterns.)\n\nDifferent sizes of alphabet rangoli are shown below:\n\n#size 3\n\n----c----\n--c-b-c--\nc-b-a-b-c\n--c-b-c--\n----c---... |
9,229 | 776 | [
{
"from": "human",
"value": "Find the largest basin size in a given matrix. \n 9 9 9 8 8 8 \n 8 8 8 7 7 7 \n 7 7 7 7 7 7 \n 8 8 8 8 9 9 \n 5 5 5 5 6 3 \n 5 5 5 3 3 3 \nFor the above example, the Bold values form the maximum size... |
3,153 | 615 | [
{
"from": "human",
"value": "# Introduction\n\nThere is a war and nobody knows - the alphabet war! \nThere are two groups of hostile letters. The tension between left side letters and right side letters was too high and the war began. The letters called airstrike to help them in war - dashes and dots are s... |
2,554 | 534 | [
{
"from": "human",
"value": "Given the array of integers nums, you will choose two different indices i and j of that array. Return the maximum value of (nums[i]-1)*(nums[j]-1).\nΒ \nExample 1:\nInput: nums = [3,4,5,2]\nOutput: 12 \nExplanation: If you choose the indices i=1 and j=2 (indexed from 0), you will... |
3,729 | 733 | [
{
"from": "human",
"value": "Jabber ID on the national Berland service Β«BabberΒ» has a form <username>@<hostname>[/resource], where \n\n * <username> β is a sequence of Latin letters (lowercase or uppercase), digits or underscores characters Β«_Β», the length of <username> is between 1 and 16, inclusive. \n ... |
7,519 | 1,333 | [
{
"from": "human",
"value": "Recently Irina arrived to one of the most famous cities of BerlandΒ β the Berlatov city. There are *n* showplaces in the city, numbered from 1 to *n*, and some of them are connected by one-directional roads. The roads in Berlatov are designed in a way such that there are no cycli... |
9,503 | 913 | [
{
"from": "human",
"value": "There is a rectangular grid of *n* rows of *m* initially-white cells each.\n\nArkady performed a certain number (possibly zero) of operations on it. In the *i*-th operation, a non-empty subset of rows *R**i* and a non-empty subset of columns *C**i* are chosen. For each row *r* i... |
636 | 339 | [
{
"from": "human",
"value": "```if-not:julia,racket\nWrite a function that returns the total surface area and volume of a box as an array: `[area, volume]`\n```\n```if:julia\nWrite a function that returns the total surface area and volume of a box as a tuple: `(area, volume)`\n```\n```if:racket\nWrite a fun... |
2,322 | 340 | [
{
"from": "human",
"value": "Draw a rectangle which has a height of H cm and a width of W cm. Draw a 1-cm square by single '#'.\n\nConstraints\n\n* 1 β€ H β€ 300\n* 1 β€ W β€ 300\n\nInput\n\nThe input consists of multiple datasets. Each dataset consists of two integers H and W separated by a single space.\n\nTh... |
6,171 | 839 | [
{
"from": "human",
"value": "You came to a brand-new aqua park. In this aqua park you are not sliding like in most of aqua parks, but falling.\nThere are N objects. Each object is non-horizontal and non-vertical segment. When you fall on the segment you start sliding on it and when you reach its lowest poin... |
16,026 | 1,456 | [
{
"from": "human",
"value": "Russian version of the problem can be read here.\n\nThere are two cats playing, and each of them has a set of strings consisted of lower case English letters.\n\nThe first cat has N strings, while the second one has M strings. Both the first and the second cat will choose one of... |
22,124 | 880 | [
{
"from": "human",
"value": "Kiteretsu goes to his Chemistry Lab to perform the perfect reaction.\nIn his lab, he found N reagents numbered 1 to N. The i^{th} reagent has two properties - A_{i} and B_{i}.\n\nA reaction can be performed between the reagents i and j only if A_{i} β€ j.\n \nIf a reaction is per... |
11,002 | 963 | [
{
"from": "human",
"value": "You are given a sequence of N$N$ powers of an integer k$k$; let's denote the i$i$-th of these powers by kAi$k^{A_i}$. You should partition this sequence into two non-empty contiguous subsequences; each element of the original sequence should appear in exactly one of these subseq... |
2,414 | 515 | [
{
"from": "human",
"value": "Chef hates unoptimized codes and people who write such codes. One fine day he decided to look through the kitchen's codebase and found a function whose pseudo-code is given here:\n\ninput: integer N, list X[1, 2, ..., N], list Y[1, 2, ..., N]\n\noutput: integer res\n\nfunction:\... |
18,076 | 1,131 | [
{
"from": "human",
"value": "Vasiliy has an exam period which will continue for *n* days. He has to pass exams on *m* subjects. Subjects are numbered from 1 to *m*.\n\nAbout every day we know exam for which one of *m* subjects can be passed on that day. Perhaps, some day you can't pass any exam. It is not a... |
2,352 | 404 | [
{
"from": "human",
"value": "Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. \n\nChef has a number D containing only digits 0's and 1's. He wants to make the number to have all the digits same. For that, he will change exactly one digit, i.e. from 0 to 1 or from 1 to 0. If it i... |
11,325 | 499 | [
{
"from": "human",
"value": "A policeman wants to catch a thief. Both the policeman and the thief can only move on a line on integer coordinates between $0$ and $N$ (inclusive).\nInitially, the policeman is at a coordinate $x$ and the thief is at a coordinate $y$. During each second, each of them must move ... |
14,984 | 912 | [
{
"from": "human",
"value": "Suppose there is a h Γ w grid consisting of empty or full cells. Let's make some definitions:\n\n * r_{i} is the number of consecutive full cells connected to the left side in the i-th row (1 β€ i β€ h). In particular, r_i=0 if the leftmost cell of the i-th row is empty. \n * c_... |
1,717 | 558 | [
{
"from": "human",
"value": "Steve and Josh are bored and want to play something. They don't want to think too much, so they come up with a really simple game. Write a function called winner and figure out who is going to win.\n\nThey are dealt the same number of cards. They both flip the card on the top of... |
10,712 | 763 | [
{
"from": "human",
"value": "Polycarp found the string $s$ and the permutation $p$. Their lengths turned out to be the same and equal to $n$.\n\nA permutation of $n$ elements β is an array of length $n$, in which every integer from $1$ to $n$ occurs exactly once. For example, $[1, 2, 3]$ and $[4, 3, 5, 1, 2... |
4,182 | 463 | [
{
"from": "human",
"value": "The image shows how we can obtain the Harmonic Conjugated Point of three aligned points A, B, C.\n\n- We choose any point L, that is not in the line with A, B and C. We form the triangle ABL\n\n- Then we draw a line from point C that intersects the sides of this triangle at poin... |
2,163 | 592 | [
{
"from": "human",
"value": "Given a number N, count total number of divisors of N!.\nExample 1:\nInput : N = 4\nOutput: 8\nExplaination: 4! is 24. Divisors of 24 are \n1, 2, 3, 4, 6, 8, 12 and 24.\nExample 2:\nInput : N = 5\nOutput : 16\nExplaination: 5! is 120. Divisors of 120 are \n1, 2, 3, 4, 5, 6, 8, 1... |
9,209 | 933 | [
{
"from": "human",
"value": "You are given an array A consisting of N positive integers.\n\nSuppose F(B,X) gives the minimum positive integer Y such that:\nX divides Y \\cdot B_{i} for all (1 β€ i β€ |B|).\n\nFind the value of F(A,A_{i}) for all (1 β€ i β€ N). \n\n------ Input Format ------ \n\n- The first line... |
8,149 | 577 | [
{
"from": "human",
"value": "In a far away kingdom lived the King, the Prince, the Shoemaker, the Dressmaker and many other citizens. They lived happily until great trouble came into the Kingdom. The ACMers settled there.\n\nMost damage those strange creatures inflicted upon the kingdom was that they loved ... |
7,147 | 808 | [
{
"from": "human",
"value": "In a country popular for train travel, youΒ have planned some train travelling one year in advance.Β The days of the year that you will travel is given as an array days.Β Each day is an integer from 1 to 365.\nTrain tickets are sold in 3 different ways:\n\na 1-day pass is sold fo... |
3,671 | 519 | [
{
"from": "human",
"value": "Alex, Bob and Carl will soon participate in a team chess tournament. Since they are all in the same team, they have decided to practise really hard before the tournament. But it's a bit difficult for them because chess is a game for two players, not three.\n\nSo they play with e... |
4,365 | 504 | [
{
"from": "human",
"value": "Grigoriy, like the hero of one famous comedy film, found a job as a night security guard at the museum. At first night he received embosser and was to take stock of the whole exposition.\n\nEmbosser is a special devise that allows to \"print\" the text of a plastic tape. Text is... |
12,370 | 1,193 | [
{
"from": "human",
"value": "Chef has a sequence $A_1, A_2, \\ldots, A_N$; each element of this sequence is either $0$ or $1$. Appy gave him a string $S$ with length $Q$ describing a sequence of queries. There are two types of queries:\n- '!': right-shift the sequence $A$, i.e. replace $A$ by another sequen... |
6,292 | 588 | [
{
"from": "human",
"value": "Hr0d1y has q queries on a binary string s of length n. A binary string is a string containing only characters '0' and '1'.\n\nA query is described by a pair of integers l_i, r_i (1 β€ l_i < r_i β€ n). \n\nFor each query, he has to determine whether there exists a good subsequence ... |
1,479 | 449 | [
{
"from": "human",
"value": "Professor GukiZ likes programming contests. He especially likes to rate his students on the contests he prepares. Now, he has decided to prepare a new contest. \n\nIn total, *n* students will attend, and before the start, every one of them has some positive integer rating. Stude... |
5,048 | 855 | [
{
"from": "human",
"value": "The polar bears are going fishing. They plan to sail from (*s**x*,<=*s**y*) to (*e**x*,<=*e**y*). However, the boat can only sail by wind. At each second, the wind blows in one of these directions: east, south, west or north. Assume the boat is currently at (*x*,<=*y*).\n - If ... |
8,962 | 614 | [
{
"from": "human",
"value": "The year 2015 is almost over.\n\nLimak is a little polar bear. He has recently learnt about the binary system. He noticed that the passing year has exactly one zero in its representation in the binary systemΒ β 201510<==<=111110111112. Note that he doesn't care about the number o... |
4,377 | 454 | [
{
"from": "human",
"value": "You have $r$ red and $b$ blue beans. You'd like to distribute them among several (maybe, one) packets in such a way that each packet:\n\nhas at least one red bean (or the number of red beans $r_i \\ge 1$);\n\nhas at least one blue bean (or the number of blue beans $b_i \\ge 1$);... |
4,150 | 602 | [
{
"from": "human",
"value": "In this task you have to code process planner.\n\nYou will be given initial thing, target thing and a set of processes to turn one thing into another (in the form of _[process\\_name, start\\_thing, end\\_thing]_). You must return names of shortest sequence of processes to turn... |
7,894 | 738 | [
{
"from": "human",
"value": "There are three cells on an infinite 2-dimensional grid, labeled $A$, $B$, and $F$. Find the length of the shortest path from $A$ to $B$ if:\n\nin one move you can go to any of the four adjacent cells sharing a side;\n\nvisiting the cell $F$ is forbidden (it is an obstacle).\n\n... |
19,115 | 3,137 | [
{
"from": "human",
"value": "Ujan has a lot of numbers in his boxes. He likes order and balance, so he decided to reorder the numbers.\n\nThere are k boxes numbered from 1 to k. The i-th box contains n_i integer numbers. The integers can be negative. All of the integers are distinct.\n\nUjan is lazy, so he ... |
2,855 | 576 | [
{
"from": "human",
"value": "Given a range [m..n]. You task is to find the number of integers divisible by either a or b in the given range. \n \nExample 1:\nInput:\nm = 5, n = 11, a = 4, b = 6\nOutput:\n2\nExplanation:\n6 and 8 lie in the range and are also\neither divisible by 4 or 6.\nExample 2:\nInput:\... |
14,311 | 660 | [
{
"from": "human",
"value": "Read problems statements in Mandarin Chinese and Russian as well. \n\nChef has recently learnt about sequences of parentheses. These are special sequences that contain only the characters '(' and ')'.\nA regular parentheses sequence follows the following definition: \n\nAn empt... |
5,429 | 469 | [
{
"from": "human",
"value": "Little Petya was given this problem for homework:\n\nYou are given function <image> (here <image> represents the operation of taking the remainder). His task is to count the number of integers x in range [a;b] with property f(x) = x.\n\nIt is a pity that Petya forgot the order i... |
15,599 | 727 | [
{
"from": "human",
"value": "You are the owner of a restaurant, and you are serving for N customers seating in a round table.\n\nYou will distribute M menus to them. Each customer receiving a menu will make the order of plates, and then pass the menu to the customer on the right unless he or she has not mak... |
2,493 | 484 | [
{
"from": "human",
"value": "You have probably registered on Internet sites many times. And each time you should enter your invented password. Usually the registration form automatically checks the password's crypt resistance. If the user's password isn't complex enough, a message is displayed. Today your t... |
2,694 | 520 | [
{
"from": "human",
"value": "Stannis borathean is attacking kings landing from three gates.To defend the city Tyrion again comes up with a fair solution. Tyrion has N soldier troops with given strengths. Tyrion wants to divide army into 3 sets such that the sum of strengths in these three sets are as equal ... |
1,822 | 629 | [
{
"from": "human",
"value": "Kuriyama Mirai has killed many monsters and got many (namely n) stones. She numbers the stones from 1 to n. The cost of the i-th stone is vi. Kuriyama Mirai wants to know something about these stones so she will ask you two kinds of questions:\n\n 1. She will tell you two numbe... |
1,114 | 372 | [
{
"from": "human",
"value": "You will be given a vector of strings. You must sort it alphabetically (case-sensitive, and based on the ASCII values of the chars) and then return the first value.\n\nThe returned value must be a string, and have `\"***\"` between each of its letters.\n\nYou should not remove o... |
24,629 | 1,289 | [
{
"from": "human",
"value": "You have a grid G containing R rows (numbered from 1 to R, top to bottom) and C columns (numbered from 1 to C, left to right) of uppercase characters. The character in the r^{th} row and the c^{th} column is denoted by G_{r, c}. You also have Q strings containing uppercase chara... |
3,678 | 544 | [
{
"from": "human",
"value": "Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. \n\nChef likes problems involving arrays. Unfortunately, the last one he tried to solve didn't quite get solved.\n\nChef has an array A of N positive numbers. He wants to find the number of subarrays f... |
2,539 | 538 | [
{
"from": "human",
"value": "# Right in the Center\n\n_This is inspired by one of Nick Parlante's exercises on the [CodingBat](https://codingbat.com/java) online code practice tool._\n\nGiven a sequence of characters, does `\"abc\"` appear in the CENTER of the sequence?\n\nThe sequence of characters could c... |
15,714 | 834 | [
{
"from": "human",
"value": "Let's call an array of non-negative integers a_1, a_2, β¦, a_n a k-extension for some non-negative integer k if for all possible pairs of indices 1 β€ i, j β€ n the inequality k β
|i - j| β€ min(a_i, a_j) is satisfied. The expansion coefficient of the array a is the maximal integer ... |
1,275 | 452 | [
{
"from": "human",
"value": "Soma is a fashionable girl. She absolutely loves shiny stones that she can put on as jewellery accessories. She has been collecting stones since her childhood - now she has become really good with identifying which ones are fake and which ones are not. Her King requested for he... |
7,954 | 665 | [
{
"from": "human",
"value": "One of Chef's friends offered him a deal: during $D$ days, they are going to exchange money. For each $i$ ($1 \\le i \\le D$), on the $i$-th day, Chef's friend would give Chef $A$ rupees, while Chef would give his friend $2^{i-1}$ rupees ($1$ rupee on day $1$, $2$ rupees on day ... |
13,558 | 1,477 | [
{
"from": "human",
"value": "This is an interactive problem.\n\nAlice and Bob are playing a game on the chessboard of size n Γ m where n and m are even. The rows are numbered from 1 to n and the columns are numbered from 1 to m. There are two knights on the chessboard. A white one initially is on the positi... |
3,787 | 496 | [
{
"from": "human",
"value": "Given two integers X and K. The task is to find smallest K-digit number divisible by X.\nNote: It is given that number of digits in X is always smaller or equal to K.\n \nExample 1:\nInput:\nX = 6, K = 1\nOutput:\n6\nExplanation:\n6 is the smallest 1 digit number\nwhich is divi... |
8,408 | 1,059 | [
{
"from": "human",
"value": "problem\n\nThe island where JOI lives has been invaded by zombies. JOI decided to escape to the shelter, which is set as the safest shelter on the island.\n\nThe island where JOI lives consists of N towns from town 1 to town N, and the towns are connected by roads. There are M r... |
5,716 | 614 | [
{
"from": "human",
"value": "I am a pipe tie craftsman. As long as you get the joints and pipes that connect the pipes, you can connect any pipe. Every day, my master gives me pipes and joints, which I connect and give to my master. But if you have too many pipes, you can't connect them all in one day. Even... |
7,413 | 531 | [
{
"from": "human",
"value": "You are given an unsorted permutation P of size N. An operation is defined as:\n\nSwap P_{i} and P_{i+K} for any i in the range [1,N-K].\n\nFind the maximum value of K, such that, the permutation P can be sorted by applying any finite number of operations.\n\nNote that, a permut... |
14,233 | 917 | [
{
"from": "human",
"value": "Nikita has a row of $N$ white tiles indexed from $\\mbox{1}$ to $N$. This time, she's painting them green! \n\nFind the number of ways Nikita can paint certain tiles in green so that the indices of the green tiles form an Arithmetic Progression. As this value can be quite large,... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.