category
stringclasses
1 value
license
stringclasses
1 value
reasoning
stringclasses
1 value
generator
stringclasses
1 value
used_in_training
stringclasses
1 value
version
stringclasses
1 value
system_prompt
stringclasses
1 value
conversations
listlengths
2
2
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "Polar bears like unique arrays — that is, arrays without repeated elements.\n\nYou have got a unique array s with length n containing non-negative integers. Since you are good friends with Alice and Bob, you decide to split the array in two. Precisely, you need to construct two a...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "Furlo and Rublo play a game. The table has n piles of coins lying on it, the i-th pile has ai coins. Furlo and Rublo move in turns, Furlo moves first. In one move you are allowed to:\n\n * choose some pile, let's denote the current number of coins in it as x; \n * choose some i...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "A plane contains a not necessarily convex polygon without self-intersections, consisting of n vertexes, numbered from 1 to n. There is a spider sitting on the border of the polygon, the spider can move like that:\n\n 1. Transfer. The spider moves from the point p1 with coordinat...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any friend to be sad, so he would ens...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "As everyone knows, bears love fish. But Mike is a strange bear; He hates fish! The even more strange thing about him is he has an infinite number of blue and red fish. \n\n<image>\n\nHe has marked n distinct points in the plane. i-th point is point (xi, yi). He wants to put exact...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "Julia is conducting an experiment in her lab. She placed several luminescent bacterial colonies in a horizontal testtube. Different types of bacteria can be distinguished by the color of light they emit. Julia marks types of bacteria with small Latin letters \"a\", ..., \"z\".\n\...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "You are given a directed graph G with n vertices and m arcs (multiple arcs and self-loops are allowed). You have to paint each vertex of the graph into one of the k (k ≤ n) colors in such way that for all arcs of the graph leading from a vertex u to vertex v, vertex v is painted ...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "Once Bob saw a string. It contained so many different letters, that the letters were marked by numbers, but at the same time each letter could be met in the string at most 10 times. Bob didn't like that string, because it contained repeats: a repeat of length x is such a substrin...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "You have matrix a of size n × n. Let's number the rows of the matrix from 1 to n from top to bottom, let's number the columns from 1 to n from left to right. Let's use aij to represent the element on the intersection of the i-th row and the j-th column. \n\nMatrix a meets the fol...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "You are given an infinite periodic array a0, a1, ..., an - 1, ... with the period of length n. Formally, <image>. A periodic subarray (l, s) (0 ≤ l < n, 1 ≤ s < n) of array a is an infinite periodic array with a period of length s that is a subsegment of array a, starting with po...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "++++++++[>+>++>+++>++++>+++++>++++++>+++++++>++++++++>+++++++++>++++++++++>+\n\t++++++++++>++++++++++++>+++++++++++++>++++++++++++++>+++++++++++++++>+++++++\n\t+++++++++<<<<<<<<<<<<<<<<-]>>>>>>>>>>.<<<<<<<<<<>>>>>>>>>>>>>>++.--<<<<<<<<<\n\t<<<<<>>>>>>>>>>>>>+.-<<<<<<<<<<<<<>>>>>>...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "You are given a positive integer n. Let's build a graph on vertices 1, 2, ..., n in such a way that there is an edge between vertices u and v if and only if <image>. Let d(u, v) be the shortest distance between u and v, or 0 if there is no path between them. Compute the sum of va...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "I have an undirected graph consisting of n nodes, numbered 1 through n. Each node has at most two incident edges. For each pair of nodes, there is at most an edge connecting them. No edge connects a node to itself.\n\nI would like to create a new graph in such a way that: \n\n *...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "This winter is so... well, you've got the idea :-) The Nvodsk road system can be represented as n junctions connected with n - 1 bidirectional roads so that there is a path between any two junctions. The organizers of some event want to choose a place to accommodate the participa...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "Monocarp is playing a game \"Assimilation IV\". In this game he manages a great empire: builds cities and conquers new lands.\n\nMonocarp's empire has n cities. In order to conquer new lands he plans to build one Monument in each city. The game is turn-based and, since Monocarp i...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "The scientists have recently discovered wormholes — objects in space that allow to travel very long distances between galaxies and star systems. \n\nThe scientists know that there are n galaxies within reach. You are in the galaxy number 1 and you need to get to the galaxy number...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "Andrew and Eugene are playing a game. Initially, Andrew has string s, consisting of digits. Eugene sends Andrew multiple queries of type \"di → ti\", that means \"replace all digits di in string s with substrings equal to ti\". For example, if s = 123123, then query \"2 → 00\" tr...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.\n\nPetya brought home string s with the length of n. The st...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "Jeel and Ashish play a game on an n × m matrix. The rows are numbered 1 to n from top to bottom and the columns are numbered 1 to m from left to right. They play turn by turn. Ashish goes first.\n\nInitially, each cell of the matrix contains a non-negative integer. Each turn, a p...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "A remote island chain contains n islands, with some bidirectional bridges between them. The current bridge network forms a tree. In other words, a total of n - 1 bridges connect pairs of islands in a way that it's possible to reach any island from any other island using the bridg...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "You are given a sequence of positive integers x1, x2, ..., xn and two non-negative integers a and b. Your task is to transform a into b. To do that, you can perform the following moves:\n\n * subtract 1 from the current a; \n * subtract a mod xi (1 ≤ i ≤ n) from the current a. ...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "Carousel Boutique is busy again! Rarity has decided to visit the pony ball and she surely needs a new dress, because going out in the same dress several times is a sign of bad manners. First of all, she needs a dress pattern, which she is going to cut out from the rectangular pie...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "There are some rabbits in Singapore Zoo. To feed them, Zookeeper bought n carrots with lengths a_1, a_2, a_3, …, a_n. However, rabbits are very fertile and multiply very quickly. Zookeeper now has k rabbits and does not have enough carrots to feed all of them. To solve this probl...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "A tree is a connected undirected graph consisting of n vertices and n - 1 edges. Vertices are numbered 1 through n.\n\nLimak is a little polar bear. He once had a tree with n vertices but he lost it. He still remembers something about the lost tree though.\n\nYou are given m pair...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "Let's call the roundness of the number the number of zeros to which it ends.\n\nYou have an array of n numbers. You need to choose a subset of exactly k numbers so that the roundness of the product of the selected numbers will be maximum possible.\nInput\n\nThe first line contain...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "In this problem you have to build tournament graph, consisting of n vertices, such, that for any oriented pair of vertices (v, u) (v ≠ u) there exists a path from vertex v to vertex u consisting of no more then two edges.\n\nA directed graph without self-loops is a tournament, if...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "In the Isle of Guernsey there are n different types of coins. For each i (1 ≤ i ≤ n), coin of type i is worth ai cents. It is possible that ai = aj for some i and j (i ≠ j). \n\nBessie has some set of these coins totaling t cents. She tells Jessie q pairs of integers. For each i ...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "Drazil likes heap very much. So he created a problem with heap:\n\nThere is a max heap with a height h implemented on the array. The details of this heap are the following:\n\nThis heap contains exactly 2^h - 1 distinct positive non-zero integers. All integers are distinct. These...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "I'm the Map, I'm the Map! I'm the MAP!!!\n\nMap\n\nIn anticipation of new adventures Boots wanted to do a good deed. After discussion with the Map and Backpack, they decided to gift Dora a connected graph. After a long search, Boots chose t graph's variants, which Dora might like...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "Arkady decided to buy roses for his girlfriend.\n\nA flower shop has white, orange and red roses, and the total amount of them is n. Arkady thinks that red roses are not good together with white roses, so he won't buy a bouquet containing both red and white roses. Also, Arkady wo...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "Convexity of a set of points on the plane is the size of the largest subset of points that form a convex polygon. Your task is to build a set of n points with the convexity of exactly m. Your set of points should not contain three points that lie on a straight line.\nInput\n\nThe...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "This problem is different with hard version only by constraints on total answers length\n\nIt is an interactive problem\n\nVenya joined a tour to the madhouse, in which orderlies play with patients the following game. Orderlies pick a string s of length n, consisting only of lowe...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "There is a square grid of size n × n. Some cells are colored in black, all others are colored in white. In one operation you can select some rectangle and color all its cells in white. It costs max(h, w) to color a rectangle of size h × w. You are to make all cells white for mini...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "It is the year 2969. 1000 years have passed from the moon landing. Meanwhile, the humanity colonized the Hyperspace™ and lived in harmony.\n\nUntil we realized that we were not alone.\n\nNot too far away from the Earth, the massive fleet of aliens' spaceships is preparing to atta...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "One day Vasya got hold of a sheet of checkered paper n × m squares in size. Our Vasya adores geometrical figures, so he painted two rectangles on the paper. The rectangles' sides are parallel to the coordinates' axes, also the length of each side of each rectangle is no less than...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "There are n positive integers written on the blackboard. Also, a positive number k ≥ 2 is chosen, and none of the numbers on the blackboard are divisible by k. In one operation, you can choose any two integers x and y, erase them and write one extra number f(x + y), where f(x) is...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "Alice and Bob play a game on a grid with n rows and infinitely many columns. In each row, there are three tokens, blue, white and red one. Before the game starts and after every move, the following two conditions must hold: \n\n * Any two tokens are not in the same cell. \n * I...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "This is an interactive problem.\n\nMisha likes to play cooperative games with incomplete information. Today he suggested ten his friends to play a cooperative game \"Lake\".\n\nMisha has already come up with a field for the upcoming game. The field for this game is a directed gra...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "Marina plays a new rogue-like game. In this game, there are n different character species and m different classes. The game is played in runs; for each run, Marina has to select a species and a class for her character. If she selects the i-th species and the j-th class, she will ...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "A company of n friends wants to order exactly two pizzas. It is known that in total there are 9 pizza ingredients in nature, which are denoted by integers from 1 to 9.\n\nEach of the n friends has one or more favorite ingredients: the i-th of friends has the number of favorite in...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "Polycarp studies in Berland State University. Soon he will have to take his exam. He has to pass exactly n exams.\n\nFor the each exam i there are known two days: a_i — day of the first opportunity to pass the exam, b_i — day of the second opportunity to pass the exam (a_i < b_i)...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "There are n friends living on a circular street. The friends and their houses are numbered clockwise from 0 to n-1.\n\nInitially person i has a_i stones. The friends want to make the distribution of stones among them perfectly balanced: everyone should possess the same number of ...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "Meka-Naruto plays a computer game. His character has the following ability: given an enemy hero, deal a instant damage to him, and then heal that enemy b health points at the end of every second, for exactly c seconds, starting one second after the ability is used. That means tha...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "Some programming website is establishing a secure communication protocol. For security reasons, they want to choose several more or less random strings.\n\nInitially, they have a string s consisting of lowercase English letters. Now they want to choose q strings using the followi...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "You are given two integers n and k.\n\nYou need to construct k regular polygons having same [circumcircle](https://en.wikipedia.org/wiki/Circumscribed_circle), with distinct number of sides l between 3 and n. \n\n<image> Illustration for the first example.\n\nYou can rotate them ...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "Niyaz has a tree with n vertices numerated from 1 to n. A tree is a connected graph without cycles.\n\nEach edge in this tree has strictly positive integer weight. A degree of a vertex is the number of edges adjacent to this vertex.\n\nNiyaz does not like when vertices in the tre...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "After several latest reforms many tourists are planning to visit Berland, and Berland people understood that it's an opportunity to earn money and changed their jobs to attract tourists. Petya, for example, left the IT corporation he had been working for and started to sell souve...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "This is an interactive problem.\n\nKhanh has n points on the Cartesian plane, denoted by a_1, a_2, …, a_n. All points' coordinates are integers between -10^9 and 10^9, inclusive. No three points are collinear. He says that these points are vertices of a convex polygon; in other w...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "Phoenix is picking berries in his backyard. There are n shrubs, and each shrub has a_i red berries and b_i blue berries.\n\nEach basket can contain k berries. But, Phoenix has decided that each basket may only contain berries from the same shrub or berries of the same color (red ...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "Fedya loves problems involving data structures. Especially ones about different queries on subsegments. Fedya had a nice array a_1, a_2, … a_n and a beautiful data structure. This data structure, given l and r, 1 ≤ l ≤ r ≤ n, could find the greatest integer d, such that d divides...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "You are given array ai of length n. You may consecutively apply two operations to this array:\n\n * remove some subsegment (continuous subsequence) of length m < n and pay for it m·a coins; \n * change some elements of the array by at most 1, and pay b coins for each change. \n...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "Denis came to Nastya and discovered that she was not happy to see him... There is only one chance that she can become happy. Denis wants to buy all things that Nastya likes so she will certainly agree to talk to him. \n\nThe map of the city where they live has a lot of squares, s...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "An electrical grid in Berland palaces consists of 2 grids: main and reserve. Wires in palaces are made of expensive material, so selling some of them would be a good idea!\n\nEach grid (main and reserve) has a head node (its number is 1). Every other node gets electricity from th...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "There are n parrots standing in a circle. Each parrot has a certain level of respect among other parrots, namely r_i. When a parrot with respect level x starts chattering, x neighbours to the right and to the left of it start repeating the same words in 1 second. Their neighbours...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "Polycarpus has a finite sequence of opening and closing brackets. In order not to fall asleep in a lecture, Polycarpus is having fun with his sequence. He is able to perform two operations:\n\n * adding any bracket in any position (in the beginning, the end, or between any two e...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "You are given two strings s and t, each of length n and consisting of lowercase Latin alphabets. You want to make s equal to t. \n\nYou can perform the following operation on s any number of times to achieve it — \n\n * Choose any substring of s and rotate it clockwise once, tha...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "Thanks to the Doctor's help, the rebels managed to steal enough gold to launch a full-scale attack on the Empire! However, Darth Vader is looking for revenge and wants to take back his gold.\n\nThe rebels have hidden the gold in various bases throughout the galaxy. Darth Vader an...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "One very experienced problem writer decided to prepare a problem for April Fools Day contest. The task was very simple - given an arithmetic expression, return the result of evaluating this expression. However, looks like there is a bug in the reference solution...\nInput\n\nThe ...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "John Doe offered his sister Jane Doe find the gcd of some set of numbers a.\n\nGcd is a positive integer g, such that all number from the set are evenly divisible by g and there isn't such g' (g' > g), that all numbers of the set are evenly divisible by g'.\n\nUnfortunately Jane ...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "Nastia has an unweighted tree with n vertices and wants to play with it!\n\nThe girl will perform the following operation with her tree, as long as she needs:\n\n 1. Remove any existing edge. \n 2. Add an edge between any pair of vertices. \n\n\n\nWhat is the minimum number of ...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "This is an interactive problem. Remember to flush your output while communicating with the testing program. You may use fflush(stdout) in C++, system.out.flush() in Java, stdout.flush() in Python or flush(output) in Pascal to flush the output. If you use some other programming la...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "The coronation of King Berl XXII is soon! The whole royal family, including n daughters of Berl XXII, will be present.\n\nThe King has ordered his jeweler to assemble n beautiful necklaces, so each of the princesses could wear exactly one necklace during the ceremony — and now th...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "A function <image> is called Lipschitz continuous if there is a real constant K such that the inequality |f(x) - f(y)| ≤ K·|x - y| holds for all <image>. We'll deal with a more... discrete version of this term.\n\nFor an array <image>, we define it's Lipschitz constant <image> as...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "Catherine received an array of integers as a gift for March 8. Eventually she grew bored with it, and she started calculated various useless characteristics for it. She succeeded to do it for each one she came up with. But when she came up with another one — xor of all pairwise s...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "Let's call an integer array a_1, a_2, ..., a_n good if a_i ≠ i for each i.\n\nLet F(a) be the number of pairs (i, j) (1 ≤ i < j ≤ n) such that a_i + a_j = i + j.\n\nLet's say that an array a_1, a_2, ..., a_n is excellent if: \n\n * a is good; \n * l ≤ a_i ≤ r for each i; \n * ...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "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.\nInput\nThe first line of each test case cont...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "One day Kefa the parrot was walking down the street as he was on the way home from the restaurant when he saw something glittering by the road. As he came nearer he understood that it was a watch. He decided to take it to the pawnbroker to earn some money. \n\nThe pawnbroker said...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "The new pedestrian zone in Moscow city center consists of n squares connected with each other by n - 1 footpaths. We define a simple path as a sequence of squares such that no square appears in this sequence twice and any two adjacent squares in this sequence are directly connect...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "The Little Elephant has array a, consisting of n positive integers, indexed from 1 to n. Let's denote the number with index i as ai.\n\nThe Little Elephant wants to count, how many pairs of integers l and r are there, such that 1 ≤ l < r ≤ n and sequence b = a1a2... alarar + 1......
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "A permutation p of length n is a sequence p_1, p_2, …, p_n consisting of n distinct integers, each of which from 1 to n (1 ≤ p_i ≤ n) .\n\nLet's call the subsegment [l,r] of the permutation good if all numbers from the minimum on it to the maximum on this subsegment occur among t...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "A schoolboy Petya studies square equations. The equations that are included in the school curriculum, usually look simple: \n\nx2 + 2bx + c = 0 where b, c are natural numbers.\n\nPetya noticed that some equations have two real roots, some of them have only one root and some equat...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "Petya's been bored at work and he is killing the time by watching the parking lot at the office. The parking lot looks from above like an n × m table (a cell of the table corresponds to a single parking spot). Some spots in the parking lot are taken, others are empty.\n\nPetya wa...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "We call a function good if its domain of definition is some set of integers and if in case it's defined in x and x-1, f(x) = f(x-1) + 1 or f(x) = f(x-1).\n\nTanya has found n good functions f_{1}, …, f_{n}, which are defined on all integers from 0 to 10^{18} and f_i(0) = 0 and f_...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "Berlanders like to eat cones after a hard day. Misha Square and Sasha Circle are local authorities of Berland. Each of them controls its points of cone trade. Misha has n points, Sasha — m. Since their subordinates constantly had conflicts with each other, they decided to build a...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "As a big fan of Formula One, Charlie is really happy with the fact that he has to organize ticket sells for the next Grand Prix race in his own city. Unfortunately, the finacial crisis is striking everywhere and all the banknotes left in his country are valued either 10 euros or ...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "After one of celebrations there is a stack of dirty plates in Nikita's kitchen. Nikita has to wash them and put into a dryer. In dryer, the plates should be also placed in a stack also, and the plates sizes should increase down up. The sizes of all plates are distinct.\n\nNikita ...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "What walks on four feet in the morning, two in the afternoon, and three at night?\n\nThis is an interactive problem. This problem doesn't support hacks.\n\nSphinx's duty is to guard the city of Thebes by making sure that no unworthy traveler crosses its gates. Only the ones who a...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "Iahub is playing an uncommon game. Initially, he has n boxes, numbered 1, 2, 3, ..., n. Each box has some number of candies in it, described by a sequence a1, a2, ..., an. The number ak represents the number of candies in box k. \n\nThe goal of the game is to move all candies int...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "A set of points on a plane is called good, if for any two points at least one of the three conditions is true:\n\n * those two points lie on same horizontal line; \n * those two points lie on same vertical line; \n * the rectangle, with corners in these two points, contains in...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "Smart Beaver recently got interested in a new word game. The point is as follows: count the number of distinct good substrings of some string s. To determine if a string is good or not the game uses rules. Overall there are n rules. Each rule is described by a group of three (p, ...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "Little Chris is having a nightmare. Even in dreams all he thinks about is math.\n\nChris dreams about m binary strings of length n, indexed with numbers from 1 to m. The most horrifying part is that the bits of each string are ordered in either ascending or descending order. For ...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "As everyone knows, bears love fish. But Mike is a strange bear; He hates fish! The even more strange thing about him is he has an infinite number of blue and red fish. \n\n<image>\n\nHe has marked n distinct points in the plane. i-th point is point (xi, yi). He wants to put exact...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "Princess Vlada enjoys springing in the meadows and walking in the forest. One day — wonderful, sunny day — during her walk Princess found out with astonishment that her shadow was missing! \"Blimey!\", — she thought and started her search of the shadow in the forest.\n\nNormally ...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "This is an interactive problem.\n\nJohn and his imaginary friend play a game. There are n lamps arranged in a circle. Lamps are numbered 1 through n in clockwise order, that is, lamps i and i + 1 are adjacent for any i = 1, …, n - 1, and also lamps n and 1 are adjacent. Initially...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "Nikita and Sasha play a computer game where you have to breed some magical creatures. Initially, they have k creatures numbered from 1 to k. Creatures have n different characteristics.\n\nSasha has a spell that allows to create a new creature from two given creatures. Each of its...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "Pieguy and Piegirl are playing a game. They have a rooted binary tree, that has a property that each node is either a leaf or has exactly two children. Each leaf has a number associated with it.\n\nOn his/her turn a player can choose any two leafs that share their immediate paren...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "Smart Beaver decided to be not only smart, but also a healthy beaver! And so he began to attend physical education classes at school X. In this school, physical education has a very creative teacher. One of his favorite warm-up exercises is throwing balls. Students line up. Each ...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "Emuskald considers himself a master of flow algorithms. Now he has completed his most ingenious program yet — it calculates the maximum flow in an undirected graph. The graph consists of n vertices and m edges. Vertices are numbered from 1 to n. Vertices 1 and n being the source ...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "<image>\n\nRecently, a wild Krakozyabra appeared at Jelly Castle. It is, truth to be said, always eager to have something for dinner.\n\nIts favorite meal is natural numbers (typically served with honey sauce), or, to be more precise, the zeros in their corresponding decimal repr...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "Alice and Bob are playing a game (yet again).\n\nThey have two sequences of segments of the coordinate axis: a sequence of n initial segments: [l_1, r_1], [l_2, r_2], ..., [l_n, r_n], and a sequence of m terminal segments: [L_1, R_1], [L_2, R_2], ..., [L_m, R_m]. At the beginning...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "Vasya tries to break in a safe. He knows that a code consists of n numbers, and every number is a 0 or a 1. Vasya has made m attempts to enter the code. After each attempt the system told him in how many position stand the right numbers. It is not said in which positions the wron...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "Old MacDonald has a farm and a large potato field, (1010 + 1) × (1010 + 1) square meters in size. The field is divided into square garden beds, each bed takes up one square meter.\n\nOld McDonald knows that the Colorado potato beetle is about to invade his farm and can destroy th...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "The good times at Heidi's library are over. Marmots finally got their internet connections and stopped coming to the library altogether. Not only that, but the bookstore has begun charging extortionate prices for some books. Namely, whereas in the previous versions each book coul...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "You come home and fell some unpleasant smell. Where is it coming from?\n\nYou are given an array a. You have to answer the following queries: \n\n 1. You are given two integers l and r. Let ci be the number of occurrences of i in al: r, where al: r is the subarray of a from l-th...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "Polycarpus works as a programmer in a start-up social network. His boss gave his a task to develop a mechanism for determining suggested friends. Polycarpus thought much about the task and came to the folowing conclusion. \n\nLet's say that all friendship relationships in a socia...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "Berland has a long and glorious history. To increase awareness about it among younger citizens, King of Berland decided to compose an anthem.\n\nThough there are lots and lots of victories in history of Berland, there is the one that stand out the most. King wants to mention it i...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "After Misha's birthday he had many large numbers left, scattered across the room. Now it's time to clean up and Misha needs to put them in a basket. He ordered this task to his pet robot that agreed to complete the task at certain conditions. Before the robot puts a number x to t...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "Vasya plays the Power Defence. \n\nHe must pass the last level of the game. In order to do this he must kill the Main Villain, who moves in a straight line at speed 1 meter per second from the point ( - ∞, 0) to the point ( + ∞, 0) of the game world. In the points (x, 1) and (x, ...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "<image> <image>\n\n*The two images are equivalent, feel free to use either one.\nInput\n\nThe input contains a single integer a (-100 ≤ a ≤ 100).\n\nOutput\n\nOutput the result – an integer number.\n\nExample\n\nInput\n\n\n1\n\n\nOutput\n\n\n1" }, { "from": "assistant", ...
code
cc-by-4.0
on
DeepSeek-R1
Ultra, Nano
v1.1
detailed thinking on
[ { "from": "user", "value": "One day Qwerty the Ranger witnessed two transport ships collide with each other. As a result, all contents of their cargo holds scattered around the space. And now Qwerty wants to pick as many lost items as possible to sell them later.\n\nThe thing is, both ships had lots of new ...