info stringlengths 120 50k | question stringlengths 504 10.4k | avg@8_qwen3_4b_instruct_2507 float64 0 0.88 |
|---|---|---|
{"tests": "{\"inputs\": [[\"Sample text\"], [\"Simple transposition\"], [\"All that glitters is not gold\"], [\"The better part of valor is discretion\"], [\"Conscience does make cowards of us all\"], [\"Imagination is more important than knowledge\"]], \"outputs\": [[\"Sml etapetx\"], [\"Sml rnpstoipetasoiin\"], [\"Al... | Simple transposition is a basic and simple cryptography technique. We make 2 rows and put first a letter in the Row 1, the second in the Row 2, third in Row 1 and so on until the end. Then we put the text from Row 2 next to the Row 1 text and thats it.
Complete the function that receives a string and encrypt it with t... | 0 |
{"tests": "{\"inputs\": [\"5 1\\n1 1856513539 999999998 999999999 1000000000\", \"16 10\\n1 7 12 27 52 75 731 13856 395504 534840 1276551 903860 9384806 19108104 82684732 535447408\", \"2 100\\n1 13\", \"10 8851025\\n38 87 668 4845 22601 65499 90236 790604 4290609 4894746\", \"16 10\\n1 7 12 27 52 75 731 18298 395504 5... | Snuke has decided to use a robot to clean his room.
There are N pieces of trash on a number line. The i-th piece from the left is at position x_i. We would like to put all of them in a trash bin at position 0.
For the positions of the pieces of trash, 0 < x_1 < x_2 < ... < x_{N} \leq 10^{9} holds.
The robot is initi... | 0 |
{"tests": "{\"inputs\": [\"3 3 2\\n1 1\\n1..\\n...\\n..2\\n\", \"3 4 4\\n1 1 1 1\\n....\\n#...\\n1234\\n\", \"3 4 2\\n1 1\\n....\\n1..2\\n....\\n\", \"3 4 2\\n2 1\\n....\\n1..2\\n....\\n\", \"4 4 2\\n1 1000000000\\n....\\n....\\n..2.\\n...1\\n\", \"4 4 2\\n1 1000000000\\n....\\n....\\n..1.\\n...2\\n\", \"1 1 1\\n1\\n1\... | Kilani is playing a game with his friends. This game can be represented as a grid of size $n \times m$, where each cell is either empty or blocked, and every player has one or more castles in some cells (there are no two castles in one cell).
The game is played in rounds. In each round players expand turn by turn: fir... | 0.25 |
{"tests": "{\"inputs\": [\"6\\n4 4 2 5 2 3\\n\", \"9\\n5 1 3 1 5 2 4 2 5\\n\", \"5\\n1558 4081 3591 1700 3232\\n\", \"10\\n3838 1368 4825 2068 4755 2048 1342 4909 2837 4854\\n\", \"10\\n4764 4867 2346 1449 1063 2002 2577 2089 1566 614\\n\", \"10\\n689 3996 3974 4778 1740 3481 2916 2744 294 1376\\n\", \"100\\n1628 4511 ... | Vladik often travels by trains. He remembered some of his trips especially well and I would like to tell you about one of these trips:
Vladik is at initial train station, and now n people (including Vladik) want to get on the train. They are already lined up in some order, and for each of them the city code a_{i} is k... | 0 |
{"tests": "{\"inputs\": [\"7 3 2\\n1 2 1\\n\", \"10 1 11\\n1\\n\", \"10 1 5\\n2\\n\", \"1000 3 9\\n106 118 99\\n\", \"1000 20 8\\n3 6 3 4 3 5 3 5 5 5 3 1 3 8 2 4 4 5 3 2\\n\", \"1000 16 2\\n20 13 16 13 22 10 18 21 18 20 20 16 19 9 11 22\\n\", \"5 1 2\\n1\\n\", \"1 1 1\\n1\\n\", \"2 1 1\\n1\\n\", \"4 1 2\\n1\\n\", \"15 ... | There is a river of width $n$. The left bank of the river is cell $0$ and the right bank is cell $n + 1$ (more formally, the river can be represented as a sequence of $n + 2$ cells numbered from $0$ to $n + 1$). There are also $m$ wooden platforms on a river, the $i$-th platform has length $c_i$ (so the $i$-th platform... | 0.25 |
{"tests": "{\"inputs\": [[542, 5], [1750, 6], [14990, 7], [3456, 4], [30500, 3], [62550, 5], [568525, 7], [9567100, 8]], \"outputs\": [[547], [1799], [14996], [3462], [30501], [62557], [568531], [9567115]]}", "source": "taco"} | We define the function `f1(n,k)`, as the least multiple of `n` that has all its digits less than `k`.
We define the function `f2(n,k)`, as the least multiple of `n` that has all the digits that are less than `k`.
Each digit may occur more than once in both values of `f1(n,k)` and `f2(n,k)`.
The possible values for ... | 0 |
{"tests": "{\"inputs\": [\"3\\n111 SET c 1\\n12 SUB c c 4\\n777 SET a 4\", \"3\\n10 SET c 1\\n193 IF c 10\\n20 HALT\", \"6\\n10 SET c 1\\n20 SET h 5\\n100 ADD s s i\\n110 SUB i i c\\n120 IF i 100\\n200 HALT\", \"3\\n10 SET c 1\\n193 IF c 11\\n20 HALT\", \"3\\n10 SET c 0\\n193 IF c 11\\n20 HALT\", \"3\\n111 SET c 1\\n12... | Have you ever had an infinite loop when you ran a hard-working program? It would be convenient to be able to determine in advance whether a program will stop executing without having to execute it.
Unfortunately, it is not possible to make such a decision for any program in the programming language you normally use. H... | 0 |
{"tests": "{\"inputs\": [\"5\\n9 3 5 7 3\\n5 8 1 4 5\\n\", \"3\\n1 2 9\\n10 1 1\\n\", \"1\\n7\\n4\\n\", \"5\\n3 10 9 10 6\\n4 3 3 6 9\\n\", \"1\\n5\\n8\\n\", \"1\\n5\\n1\\n\", \"5\\n1 7 6 9 1\\n6 1 1 7 10\\n\", \"5\\n7 3 3 1 8\\n7 2 1 1 2\\n\", \"100\\n4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1... | Finally, a basketball court has been opened in SIS, so Demid has decided to hold a basketball exercise session. $2 \cdot n$ students have come to Demid's exercise session, and he lined up them into two rows of the same size (there are exactly $n$ people in each row). Students are numbered from $1$ to $n$ in each row in... | 0.875 |
{"tests": "{\"inputs\": [\"5 8\\n.#.#..#.\\n.....#..\\n.#.#..#.\\n#.#....#\\n.....#..\\n\", \"5 5\\n..#..\\n..#..\\n#####\\n..#..\\n..#..\\n\", \"5 9\\n........#\\n#........\\n..##.#...\\n.......#.\\n....#.#.#\\n\", \"9 5\\n.....\\n#....\\n..#..\\n.....\\n.#..#\\n...#.\\n.#...\\n....#\\n.....\\n\", \"10 10\\n............. | There is a rectangular grid of n rows of m initially-white cells each.
Arkady 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 in R_{i} and each column c in C_{i}, the intersection ... | 0.375 |
{"tests": "{\"inputs\": [\"1\\n2\\n3\\n390\\n216\\n1546\\n314159265358979323\\n0\", \"1\\n2\\n2\\n390\\n1124\\n1546\\n314159265358979323\\n0\", \"1\\n2\\n3\\n390\\n216\\n1546\\n31125328462643205\\n0\", \"1\\n2\\n2\\n390\\n1124\\n1546\\n211760204581026131\\n0\", \"1\\n2\\n3\\n104\\n216\\n1546\\n31125328462643205\\n0\", ... | Number of tanka
Wishing to die in the spring under the flowers
This is one of the famous tanka poems that Saigyo Hoshi wrote. Tanka is a type of waka poem that has been popular in Japan for a long time, and most of it consists of five phrases and thirty-one sounds of 5, 7, 5, 7, and 7.
By the way, the number 57577 c... | 0 |
{"tests": "{\"inputs\": [\"5 1\\n1 1\\n1 -1\\n-1 1\\n-1 -1\\n2 0\\n\", \"5 2\\n1 1\\n1 -1\\n-1 1\\n-1 -1\\n2 0\\n\", \"1 1000000\\n1000000 -1000000\\n\", \"1 1000000\\n1000000 -1000000\\n\", \"5 2\\n1 1\\n1 -1\\n-1 1\\n-1 -2\\n2 0\\n\", \"5 1\\n1 1\\n1 -1\\n-1 1\\n-1 0\\n2 0\\n\", \"5 1\\n1 1\\n1 -2\\n-1 1\\n-1 0\\n2 0... | The Cybermen solved that first test much quicker than the Daleks. Luckily for us, the Daleks were angry (shocking!) and they destroyed some of the Cybermen.
After the fighting stopped, Heidi gave them another task to waste their time on.
There are $n$ points on a plane. Given a radius $r$, find the maximum number of ... | 0.125 |
{"tests": "{\"inputs\": [[9, 10, 11], [12, 12, 13], [13, 10, 15], [14, 9, 14], [15, 8, 12], [20, 21, 1], [21, 21, 6], [17, 15, 3], [0, 22, 1], [1, 22, 1], [3, 23, 2], [20, 0, 23], [14, 2, 9], [9, 20, 11], [23, 23, 0], [11, 2, 9], [0, 20, 23], [4, 0, 3], [6, 2, 10]], \"outputs\": [[false], [true], [true], [false], [fals... | As a strict big brother, I do limit my young brother Vasya on time he spends on computer games. I define a prime-time as a time period till which Vasya have a permission to play computer games. I specify start hour and end hour as pair of integers.
I need a function which will take three numbers - a present moment (cu... | 0 |
{"tests": "{\"inputs\": [\"1 3000\\n2006 226621946\\n\", \"10 2\\n1 1\\n1 1\\n1 1\\n1 1\\n1 1\\n2 1\\n2 1\\n2 1\\n2 1\\n2 1\\n\", \"10 10\\n1 73\\n2 8\\n3 88\\n1 5\\n2 100\\n1 29\\n1 57\\n3 37\\n7 46\\n3 21\\n\", \"5 5\\n1 3\\n1 6\\n5 4\\n3 7\\n2 10\\n\", \"1 3000\\n918 548706881\\n\", \"10 10\\n7 29\\n10 31\\n9 40\\n5... | As you know, majority of students and teachers of Summer Informatics School live in Berland for the most part of the year. Since corruption there is quite widespread, the following story is not uncommon.
Elections are coming. You know the number of voters and the number of parties — n and m respectively. For each vote... | 0 |
{"tests": "{\"inputs\": [\"24\\n1 2 3 4\\n1 2 4 3\\n1 3 2 4\\n1 3 4 2\\n1 4 1 3\\n1 4 3 2\\n2 1 3 4\\n2 1 4 3\\n2 3 1 4\\n2 3 4 1\\n2 4 1 3\\n2 4 3 1\\n3 1 2 4\\n3 1 4 2\\n3 2 1 4\\n3 2 4 1\\n3 4 1 2\\n3 4 2 1\\n4 1 2 3\\n4 1 3 2\\n4 2 1 3\\n4 2 3 1\\n4 3 1 2\\n4 3 2 1\", \"14\\n9 7 5 9\\n9 7 6 9\\n14 10 7 12\\n14 10 8... | Ringo Mart, a convenience store, sells apple juice.
On the opening day of Ringo Mart, there were A cans of juice in stock in the morning. Snuke buys B cans of juice here every day in the daytime. Then, the manager checks the number of cans of juice remaining in stock every night. If there are C or less cans, D new can... | 0 |
{"tests": "{\"inputs\": [\"6\\nADD 1\\nACCEPT 1\\nADD 2\\nACCEPT 2\\nADD 3\\nACCEPT 3\\n\", \"4\\nADD 1\\nADD 2\\nADD 3\\nACCEPT 2\\n\", \"7\\nADD 1\\nADD 2\\nADD 3\\nADD 4\\nADD 5\\nACCEPT 3\\nACCEPT 5\\n\", \"6\\nADD 10\\nADD 7\\nADD 13\\nADD 15\\nADD 12\\nACCEPT 10\\n\", \"8\\nADD 10\\nADD 7\\nADD 13\\nADD 15\\nADD ... | Let's consider a simplified version of order book of some stock. The order book is a list of orders (offers) from people that want to buy or sell one unit of the stock, each order is described by direction (BUY or SELL) and price.
At every moment of time, every SELL offer has higher price than every BUY offer.
In th... | 0 |
{"tests": "{\"inputs\": [\"2\\nSRRRSSSSR\", \"1\\nRRS\", \"1\\nSRR\", \"2\\nRSSSSRSRR\", \"1\\nSSR\", \"2\\nSRSRSRSSR\", \"1\\nRSR\", \"2\\nSSSSSRSRR\", \"2\\nSRSRSRSRR\", \"3\\nRRRRSRRRSRRSRS\", \"2\\nRSSRRSSSR\", \"2\\nSRRRRSSSR\", \"2\\nRRSRSRSSR\", \"2\\nRRSRSRSRS\", \"3\\nRSRRSRRRSRRSRR\", \"2\\nRSSSRRSSR\", \"2\\... | There are 3^N people dancing in circle. We denote with 0,1,\dots, 3^{N}-1 the positions in the circle, starting from an arbitrary position and going around clockwise. Initially each position in the circle is occupied by one person.
The people are going to dance on two kinds of songs: salsa and rumba.
* When a salsa i... | 0 |
{"tests": "{\"inputs\": [\"6\\n4 1\\n2 3 5 4\\n5 6\\n1 1 3 4 4\\n1 10\\n2\\n2 10\\n11 9\\n2 10\\n12 11\\n5 18\\n81 324 218 413 324\\n\", \"3\\n5 15\\n5 15 8 10 10\\n6 5\\n2 3 15 4 15 7\\n8 7\\n12 14 9 7 15 14 8 3\\n\", \"3\\n5 15\\n5 15 8 10 10\\n6 5\\n2 3 15 4 15 7\\n8 7\\n12 14 9 7 15 14 8 3\\n\", \"3\\n5 15\\n5 15 8... | You are given a sequence $a$ consisting of $n$ integers $a_1, a_2, \dots, a_n$, and an integer $x$. Your task is to make the sequence $a$ sorted (it is considered sorted if the condition $a_1 \le a_2 \le a_3 \le \dots \le a_n$ holds).
To make the sequence sorted, you may perform the following operation any number of t... | 0.375 |
{"tests": "{\"inputs\": [\"5 1\\nAABBB\\n\", \"5 1\\nABABB\\n\", \"26 1\\nABCDEFGHIJKLMNOPQRSTUVWXYZ\\n\", \"27 1\\nABCDEFGHIJKLMNOPQRSTUVWXYZA\\n\", \"5 2\\nABACA\\n\", \"6 2\\nABCABC\\n\", \"8 3\\nABCBCDCA\\n\", \"73 2\\nDEBECECBBADAADEAABEAEEEAEBEAEBCDDBABBAEBACCBEEBBAEADEECACEDEEDABACDCDBBBD\\n\", \"44 15\\nHGJIFCG... | [Image]
It's the end of July – the time when a festive evening is held at Jelly Castle! Guests from all over the kingdom gather here to discuss new trends in the world of confectionery. Yet some of the things discussed here are not supposed to be disclosed to the general public: the information can cause discord in t... | 0.875 |
{"tests": "{\"inputs\": [\"8\\n2 4 1 3 4 2 1 2\\n\", \"5\\n1 1 2 1 2\\n\", \"98\\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 8... | You have an array $a_1, a_2, \dots, a_n$.
Let's call some subarray $a_l, a_{l + 1}, \dots , a_r$ of this array a subpermutation if it contains all integers from $1$ to $r-l+1$ exactly once. For example, array $a = [2, 2, 1, 3, 2, 3, 1]$ contains $6$ subarrays which are subpermutations: $[a_2 \dots a_3]$, $[a_2 \dots ... | 0.5 |
{"tests": "{\"inputs\": [\"5 5 2\\n1 2 100\\n2 3 100\\n3 4 100\\n4 5 20\\n2 5 5\\n5 50\\n4 1\\n\", \"2 1 5\\n1 2 4\\n2 3\\n2 5\\n2 4\\n2 4\\n2 5\\n\", \"3 3 6\\n1 2 499999999\\n2 3 500000000\\n1 3 999999999\\n2 499999999\\n2 500000000\\n2 499999999\\n3 999999999\\n3 1000000000\\n3 1000000000\\n\", \"2 1 1\\n1 2 1\\n2 1... | Jzzhu is the president of country A. There are n cities numbered from 1 to n in his country. City 1 is the capital of A. Also there are m roads connecting the cities. One can go from city ui to vi (and vise versa) using the i-th road, the length of this road is xi. Finally, there are k train routes in the country. One ... | 0 |
{"tests": "{\"inputs\": [\"2 1\\n1 2\\n1 1 0\\n1 2 0\\n\", \"1 0\\n1 1 0\\n1 1 0\\n\", \"2 1\\n1 2\\n1 1 0\\n1 2 1\\n\", \"6 5\\n1 2\\n2 3\\n3 4\\n3 5\\n2 6\\n1 4 3\\n5 6 3\\n\", \"9 9\\n1 2\\n2 3\\n2 4\\n4 5\\n5 7\\n5 6\\n3 8\\n8 9\\n9 6\\n1 7 4\\n3 6 3\\n\", \"10 11\\n1 3\\n2 3\\n3 4\\n4 5\\n4 6\\n3 7\\n3 8\\n4 9\\n4... | In some country there are exactly n cities and m bidirectional roads connecting the cities. Cities are numbered with integers from 1 to n. If cities a and b are connected by a road, then in an hour you can go along this road either from city a to city b, or from city b to city a. The road network is such that from any ... | 0.375 |
{"tests": "{\"inputs\": [[[15, 24, 12], 4], [[26, 23, 19], 3], [[11, 25, 36], 1], [[22, 9, 24], 5], [[8, 11, 4], 10], [[17, 31, 21], 2], [[34, 25, 36], 1], [[35, 35, 29], 0], [[35, 35, 30], 0], [[35, 35, 31], 0]], \"outputs\": [[\"No match!\"], [\"Match!\"], [\"No match!\"], [\"Match!\"], [\"Match!\"], [\"No match!\"],... | It is 2050 and romance has long gone, relationships exist solely for practicality.
MatchMyHusband is a website that matches busy working women with perfect house husbands. You have been employed by MatchMyHusband to write a function that determines who matches!!
The rules are... a match occurs providing the husband's... | 0 |
{"tests": "{\"inputs\": [\"9\\n\", \"20\\n\", \"30\\n\", \"5\\n\", \"0\\n\", \"1\\n\", \"2\\n\", \"3\\n\", \"4\\n\", \"6\\n\", \"7\\n\", \"8\\n\", \"10\\n\", \"11\\n\", \"12\\n\", \"13\\n\", \"14\\n\", \"15\\n\", \"16\\n\", \"17\\n\", \"18\\n\", \"19\\n\", \"21\\n\", \"22\\n\", \"23\\n\", \"24\\n\", \"25\\n\", \"26\\n\... | The final round of Bayan Programming Contest will be held in Tehran, and the participants will be carried around with a yellow bus. The bus has 34 passenger seats: 4 seats in the last row and 3 seats in remaining rows. [Image]
The event coordinator has a list of k participants who should be picked up at the airport.... | 0 |
{"tests": "{\"inputs\": [\"4\\n3\\n1 4 2\\n1 3 1\\n2\\n2 4\\n2 3\\n2\\n1 1000000000\\n1 1000000000\\n4\\n3 10 5 8\\n2 5 2 4\\n\", \"4\\n3\\n1 4 2\\n1 3 1\\n2\\n2 4\\n2 3\\n2\\n1 1100000000\\n1 1000000000\\n4\\n3 10 5 8\\n2 5 2 4\\n\", \"4\\n3\\n1 6 2\\n1 3 1\\n2\\n2 4\\n2 3\\n2\\n1 1100000000\\n1 1000000000\\n4\\n3 10 ... | Consider an infinite triangle made up of layers. Let's number the layers, starting from one, from the top of the triangle (from top to bottom). The $k$-th layer of the triangle contains $k$ points, numbered from left to right. Each point of an infinite triangle is described by a pair of numbers $(r, c)$ ($1 \le c \le r... | 0 |
{"tests": "{\"inputs\": [\"314159265 7\\n21662711\\n77271666\\n89022761\\n156626166\\n160332356\\n166902656\\n453863319\", \"6 6\\n1\\n2\\n3\\n6\\n7\\n9\", \"10 3\\n2\\n7\\n17\", \"391985414 7\\n21662711\\n77271666\\n89022761\\n156626166\\n160332356\\n166902656\\n453863319\", \"10 3\\n2\\n7\\n20\", \"10 3\\n2\\n7\\n29\... | Takahashi Lake has a perimeter of L. On the circumference of the lake, there is a residence of the lake's owner, Takahashi. Each point on the circumference of the lake has a coordinate between 0 and L (including 0 but not L), which is the distance from the Takahashi's residence, measured counter-clockwise.
There are N... | 0 |
{"tests": "{\"inputs\": [\"1\\n-751115 -925948\\n\", \"1\\n-751115 -1566406\\n\", \"3\\n-1 -1\\n0 2\\n1 0\\n\", \"3\\n0 -1\\n0 2\\n2 0\\n\", \"1\\n-751115 -2469241\\n\", \"3\\n-1 -1\\n0 2\\n2 0\\n\", \"1\\n-751115 -4760337\\n\", \"1\\n-751115 -4345366\\n\", \"3\\n0 -1\\n0 2\\n1 0\\n\", \"1\\n-751115 -8685961\\n\", \"3\... | Recently Vasya learned that, given two points with different x coordinates, you can draw through them exactly one parabola with equation of type y = x^2 + bx + c, where b and c are reals. Let's call such a parabola an U-shaped one.
Vasya drew several distinct points with integer coordinates on a plane and then drew an... | 0.75 |
{"tests": "{\"inputs\": [[\"1234 5678\"], [\"2359 1478\"], [\"85748475\"], [\"3857 4756\"], [\"sklfjsdklfjsf\"], [\" 1234 5678 \"], [\"abcd efgh\"], [\"9684 2396\"], [\"836g 2986\"], [\"0000 0000\"], [\"123456789\"], [\" 987 634 \"], [\" 6 \"], [\"8A65 2986\"], [\"8368 2aE6\"], [\"8c65 2i86\"]], \"outputs\... | # Valid HK Phone Number
## Overview
In Hong Kong, a valid phone number has the format ```xxxx xxxx``` where ```x``` is a decimal digit (0-9). For example:
## Task
Define two functions, ```isValidHKPhoneNumber``` and ```hasValidHKPhoneNumber```, that ```return```s whether a given string is a valid HK phone number a... | 0 |
{"tests": "{\"inputs\": [\"1 2 3 2 5 6\\n6 5 4 3 2 1\", \"1 2 3 2 5 6\\n6 1 4 3 2 1\", \"1 2 3 2 5 6\\n6 0 4 3 2 1\", \"1 2 3 2 5 6\\n6 0 4 3 4 1\", \"1 2 3 2 7 6\\n6 0 4 3 4 1\", \"1 2 3 2 7 3\\n6 0 4 3 4 1\", \"1 2 2 2 7 6\\n6 0 4 3 4 1\", \"1 2 2 2 7 9\\n6 0 4 3 4 1\", \"1 2 2 2 7 9\\n6 0 4 5 4 1\", \"1 0 2 2 7 9\\n... | Write a program which reads the two dices constructed in the same way as Dice I, and determines whether these two dices are identical. You can roll a dice in the same way as Dice I, and if all integers observed from the six directions are the same as that of another dice, these dices can be considered as identical.
Co... | 0.375 |
{"tests": "{\"inputs\": [\"8 4\\n7 1 1\\n2 1 1\\n4 0 1\\n8 1 1\\n1 0 1\\n1 1 1\\n1 0 1\\n3 0 0\\n\", \"5 2\\n6 0 0\\n9 0 0\\n1 0 1\\n2 1 1\\n5 1 0\\n\", \"5 3\\n3 0 0\\n2 1 0\\n3 1 0\\n5 0 1\\n3 0 1\\n\", \"3 1\\n3 0 1\\n3 1 0\\n3 0 0\\n\", \"2 1\\n7 1 1\\n2 1 1\\n\", \"5 1\\n2 1 0\\n2 0 1\\n1 0 1\\n1 1 0\\n1 0 1\\n\",... | Easy and hard versions are actually different problems, so read statements of both problems completely and carefully.
Summer vacation has started so Alice and Bob want to play and joy, but... Their mom doesn't think so. She says that they have to read some amount of books before all entertainments. Alice and Bob will ... | 0 |
{"tests": "{\"inputs\": [\"1 2\\n\", \"2 3\\n\", \"3 6\\n\", \"10 1024\\n\", \"10 577\\n\", \"11 550\\n\", \"19 12783\\n\", \"28 72803174\\n\", \"39 457181784666\\n\", \"12 955\\n\", \"13 154\\n\", \"14 2334\\n\", \"15 15512\\n\", \"16 21395\\n\", \"17 80239\\n\", \"18 153276\\n\", \"20 589266\\n\", \"21 1687606\\n\", ... | Amr bought a new video game "Guess Your Way Out!". The goal of the game is to find an exit from the maze that looks like a perfect binary tree of height h. The player is initially standing at the root of the tree and the exit from the tree is located at some leaf node.
Let's index all the leaf nodes from the left to ... | 0 |
{"tests": "{\"inputs\": [\"5\\n3\\n1 6\\n1 7\\n1 5\\n2\\n1 4\\n1 3\\n3\\n1 10\\n3 5\\n2 3\\n3\\n1 15\\n2 4\\n1 10\\n1\\n1 100\\n\", \"5\\n3\\n1 1\\n1 1\\n1 1\\n3\\n1 1\\n1 1\\n1 1\\n3\\n1 1\\n1 1\\n1 1\\n3\\n1 1\\n1 1\\n1 1\\n3\\n1 100\\n1 1\\n1 1\\n\", \"1\\n4\\n1 1\\n1 1\\n2 2\\n3 4\\n\", \"5\\n3\\n1 1\\n1 1\\n1 1\\n... | You are playing a computer card game called Splay the Sire. Currently you are struggling to defeat the final boss of the game.
The boss battle consists of $n$ turns. During each turn, you will get several cards. Each card has two parameters: its cost $c_i$ and damage $d_i$. You may play some of your cards during each ... | 0 |
{"tests": "{\"inputs\": [[1], [2], [13], [19], [41], [93]], \"outputs\": [[[1]], [[3, 5]], [[157, 159, 161, 163, 165, 167, 169, 171, 173, 175, 177, 179, 181]], [[343, 345, 347, 349, 351, 353, 355, 357, 359, 361, 363, 365, 367, 369, 371, 373, 375, 377, 379]], [[1641, 1643, 1645, 1647, 1649, 1651, 1653, 1655, 1657, 1659,... | Given a triangle of consecutive odd numbers:
```
1
3 5
7 9 11
13 15 17 19
21 23 25 27 29
...
```
find the triangle's row knowing its index (the rows are 1-indexed), e.g.:
```
odd_row(1) == [1]
odd_row(2) == [3, 5]
odd_row(3) == [7, 9, 11]
```
**... | 0 |
{"tests": "{\"inputs\": [\"3 2\\n2 1\\n2 2\\n\", \"9 3\\n1 2 3\\n2 8\\n1 4 5\\n\", \"10 0\\n\", \"10 2\\n1 1 2\\n1 8 9\\n\", \"9 3\\n1 4 5\\n1 1 2\\n1 6 7\\n\", \"7 2\\n2 3\\n1 5 6\\n\", \"81 28\\n1 77 78\\n1 50 51\\n2 9\\n1 66 67\\n1 12 13\\n1 20 21\\n1 28 29\\n1 34 35\\n1 54 55\\n2 19\\n1 70 71\\n1 45 46\\n1 36 37\\n... | Sereja is a coder and he likes to take part in Codesorfes rounds. However, Uzhland doesn't have good internet connection, so Sereja sometimes skips rounds.
Codesorfes has rounds of two types: Div1 (for advanced coders) and Div2 (for beginner coders). Two rounds, Div1 and Div2, can go simultaneously, (Div1 round cannot... | 0 |
{"tests": "{\"inputs\": [\"4\\n0 10 5 15\\n\", \"4\\n0 15 5 10\\n\", \"5\\n0 1000 2000 3000 1500\\n\", \"5\\n-724093 710736 -383722 -359011 439613\\n\", \"50\\n384672 661179 -775591 -989608 611120 442691 601796 502406 384323 -315945 -934146 873993 -156910 -94123 -930137 208544 816236 466922 473696 463604 794454 -872433... | Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework.
The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them... | 0.375 |
{"tests": "{\"inputs\": [\"0 2\\n\", \"2 0\\n\", \"2 2\\n\", \"2000 2000\\n\", \"0 0\\n\", \"11 2\\n\", \"1 4\\n\", \"5 13\\n\", \"60 59\\n\", \"27 16\\n\", \"1134 1092\\n\", \"756 1061\\n\", \"953 1797\\n\", \"76 850\\n\", \"24 1508\\n\", \"1087 1050\\n\", \"149 821\\n\", \"983 666\\n\", \"45 1323\\n\", \"1994 1981\\n... | Natasha's favourite numbers are $n$ and $1$, and Sasha's favourite numbers are $m$ and $-1$. One day Natasha and Sasha met and wrote down every possible array of length $n+m$ such that some $n$ of its elements are equal to $1$ and another $m$ elements are equal to $-1$. For each such array they counted its maximal pref... | 0 |
{"tests": "{\"inputs\": [[\"142784\"], [\"642784\"], [\"111\"], [\"1111111\"], [\"AA5590\"], [\"\"], [\"\\n245980\"], [\"245980\\n\"], [\"245980a\"], [\"24598a\"], [\" 310587 \"], [\"555555\"], [\"775255\"], [\"875555\"], [\"012345\"], [\"968345\"], [\"@68345\"]], \"outputs\": [[true], [true], [false], [false], [false]... | You should write a simple function that takes string as input and checks if it is a valid Russian postal code, returning `true` or `false`.
A valid postcode should be 6 digits with no white spaces, letters or other symbols. Empty string should also return false.
Please also keep in mind that a valid post code **cann... | 0 |
{"tests": "{\"inputs\": [\"5\\n1 1 1 1 1\\n\", \"3\\n1 2 3\\n\", \"5\\n1 2 3 2 2\\n\", \"1\\n10\\n\", \"2\\n1 100\\n\", \"2\\n2 2\\n\", \"10\\n2 2 4 4 3 1 1 2 3 2\\n\", \"10\\n32 48 20 20 15 2 11 5 10 34\\n\", \"10\\n99 62 10 47 53 9 83 33 15 24\\n\", \"10\\n1 2 3 4 5 6 7 8 9 10\\n\", \"10\\n5 1 6 2 8 3 4 10 9 7\\n\", ... | Welcome to Innopolis city. Throughout the whole year, Innopolis citizens suffer from everlasting city construction.
From the window in your room, you see the sequence of n hills, where i-th of them has height a_{i}. The Innopolis administration wants to build some houses on the hills. However, for the sake of city ap... | 0 |
{"tests": "{\"inputs\": [\"1 1 2\\n\", \"3 4 5\\n\", \"4 1 1\\n\", \"1 1 1\\n\", \"1000000 1000000 1000000\\n\", \"3 11 8\\n\", \"8 5 12\\n\", \"1000000 500000 1\\n\", \"1000000 500000 2\\n\", \"2 2 2\\n\", \"3 3 3\\n\", \"4 4 4\\n\", \"2 4 2\\n\", \"10 5 14\\n\", \"10 5 15\\n\", \"10 4 16\\n\", \"3 3 6\\n\", \"9 95 90... | Mad scientist Mike is busy carrying out experiments in chemistry. Today he will attempt to join three atoms into one molecule.
A molecule consists of atoms, with some pairs of atoms connected by atomic bonds. Each atom has a valence number — the number of bonds the atom must form with other atoms. An atom can form one... | 0.75 |
{"tests": "{\"inputs\": [\"bbabb\\nbababbbbab\\n\", \"ab\\nbbbba\\n\", \"xzzxxxzxzzzxzzzxxzzxzzxzxzxxzxxzxxzxzzxxzxxzxxxzxzxzxxzzxxxxzxzzzxxxzxzxxxzzxxzxxzxxzzxxzxxzxzxzzzxzzzzxzxxzzxzxxzxxzzxzxzx\\nzzx\\n\", \"a\\nb\\n\", \"zxzxzxzxzxzxzx\\nd\\n\", \"pfdempfohomnpgbeegikfmflnalbbajpnpgeacaicoehopgnabnklheepnlnflohjegc... | One day Polycarpus got hold of two non-empty strings s and t, consisting of lowercase Latin letters. Polycarpus is quite good with strings, so he immediately wondered, how many different pairs of "x y" are there, such that x is a substring of string s, y is a subsequence of string t, and the content of x and y is the s... | 0.625 |
{"tests": "{\"inputs\": [\"7 3\\n4 4\\n5 4\\n2 4\\n\", \"10 3\\n7 10\\n8 7\\n5 5\\n\", \"2 2\\n1 2\\n2 2\\n\", \"2 1\\n2 2\\n\", \"100 50\\n11 28\\n11 1\\n98 58\\n38 27\\n24 27\\n67 37\\n90 48\\n91 14\\n43 29\\n3 64\\n24 6\\n53 19\\n97 65\\n13 27\\n75 53\\n37 82\\n69 75\\n94 99\\n1 26\\n95 60\\n45 27\\n100 82\\n71 49\\... | The employees of the F company have lots of ways to entertain themselves. Today they invited a famous magician who shows a trick with plastic cups and a marble.
The point is to trick the spectator's attention. Initially, the spectator stands in front of a line of n plastic cups. Then the magician places a small marble... | 0 |
{"tests": "{\"inputs\": [\"2\\n1 3 3 1\\n-10 0 0 1\", \"2\\n1 4 3 1\\n-14 0 0 1\", \"2\\n1 3 5 1\\n-10 0 0 0\", \"2\\n1 3 9 1\\n-10 0 1 0\", \"2\\n1 4 3 0\\n-1 0 1 1\", \"2\\n1 1 3 1\\n-10 -1 0 0\", \"2\\n1 4 3 0\\n-1 -1 1 1\", \"2\\n1 4 3 0\\n-1 0 0 0\", \"2\\n1 4 3 0\\n-1 0 1 0\", \"2\\n2 4 3 0\\n-1 0 1 0\", \"2\\n1 ... | Description
Since the cubic equation: ax ^ 3 + bx ^ 2 + cx + d = 0 is given, please check the number of positive real roots and the number of negative real roots, respectively.
The number of roots shall be counted including the multiple roots.
Input
The input consists of multiple test cases, and the number is rec... | 0 |
{"tests": "{\"inputs\": [\"4\\n3 3 1\\n1\\n7 3 3\\n1 5 7\\n10 5 3\\n4 5 6\\n13 7 7\\n1 3 5 7 9 11 12\\n\", \"4\\n3 3 1\\n1\\n7 3 3\\n1 5 7\\n10 5 3\\n4 5 6\\n13 7 7\\n2 3 5 7 9 11 12\\n\", \"4\\n3 5 1\\n1\\n8 3 3\\n1 5 7\\n10 5 3\\n4 5 6\\n13 7 7\\n2 3 5 7 9 11 12\\n\", \"4\\n3 5 1\\n1\\n7 3 3\\n1 3 7\\n15 5 3\\n4 5 6\... | Let's denote the median of a sequence $s$ with odd length as the value in the middle of $s$ if we sort $s$ in non-decreasing order. For example, let $s = [1, 2, 5, 7, 2, 3, 12]$. After sorting, we get sequence $[1, 2, 2, \underline{3}, 5, 7, 12]$, and the median is equal to $3$.
You have a sequence of $n$ integers $[1... | 0.125 |
{"tests": "{\"inputs\": [\"3 3 2 3\\n 1 1 1\\n0 0 0 0\\n 1 1 1\\n0 0 0 0\\n 1 1 1\\n0 0 0 0\\n 1 1 1\\n3 3 2 2\\n 1 0 1\\n1 0 1 1\\n 1 0 0\\n0 0 0 0\\n 0 0 1\\n1 1 0 1\\n 1 0 1\\n1 3 1 1\\n 1 1 1\\n1 0 0 1\\n 1 0 1\\n2 2 1 1\\n 1 0\\n1 0 0\\n 0 0\\n0 0 0\\n 0 0\\n0 0 0 0\", \"3 3 2 2\\n 1 1 1\\n0 0 0 0\\n 1 1 1\\n0 0 0... | Alternate Escape
Alice House
Alice and Bob are playing board games. This board game is played using a board with squares in rows H and columns and one frame. In this game, the upper left square of the board is set as the 1st row and 1st column, and the rows are counted downward and the columns are counted to the righ... | 0 |
{"tests": "{\"inputs\": [\"4\\n3\\n2 3 7 12 2\\n4\\n9 1 7 1 6 5\\n5\\n18 2 2 3 2 9 2\\n3\\n2 6 9 2 1\\n\", \"1\\n10\\n500000000 500000000 500000000 500000000 500000000 500000000 500000000 500000000 500000000 500000000 705032704 705032704\\n\", \"1\\n12\\n500000000 500000000 500000000 500000000 147483648 500000000 50000... | You are given a number $n$ and an array $b_1, b_2, \ldots, b_{n+2}$, obtained according to the following algorithm:
some array $a_1, a_2, \ldots, a_n$ was guessed;
array $a$ was written to array $b$, i.e. $b_i = a_i$ ($1 \le i \le n$);
The $(n+1)$-th element of the array $b$ is the sum of the numbers in the array $a... | 0 |
{"tests": "{\"inputs\": [\"0110011\\n01100110\\n\", \"11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\\n11\\n\", \"1\\n0\\n\", \"11111\\n111111\\n\", \"1\\n11000000000000000000... | You are fishing with polar bears Alice and Bob. While waiting for the fish to bite, the polar bears get bored. They come up with a game. First Alice and Bob each writes a 01-string (strings that only contain character "0" and "1") a and b. Then you try to turn a into b using two types of operations:
* Write parity(a... | 0 |
{"tests": "{\"inputs\": [[\"10001\"], [\"1001\"], [\"00000\"], [\"0000\"], [\"01000\"], [\"00010\"], [\"10000\"], [\"1\"], [\"0\"], [\"10\"], [\"110\"], [\"1011000001\"]], \"outputs\": [[1], [0], [3], [2], [1], [1], [2], [0], [1], [0], [-1], [-1]]}", "source": "taco"} | # How many urinals are free?
In men's public toilets with urinals, there is this unwritten rule that you leave at least one urinal free
between you and the next person peeing.
For example if there are 3 urinals and one person is already peeing in the left one, you will choose the
urinal on the right and not the one in... | 0.125 |
{"tests": "{\"inputs\": [\"6\\nD 3\\nH 2\\nD 1\\nS 3\\nC 2\\nC 1\", \"6\\nD 3\\nH 2\\nD 1\\nS 3\\nC 2\\nC 2\", \"6\\nD 3\\nH 2\\nC 1\\nS 3\\nC 2\\nC 2\", \"6\\nD 5\\nH 2\\nC 1\\nS 3\\nC 2\\nC 2\", \"6\\nD 5\\nH 2\\nC 2\\nS 3\\nC 2\\nC 2\", \"6\\nD 5\\nH 0\\nC 2\\nS 3\\nC 2\\nC 1\", \"2\\nS 1\\nH 2\", \"6\\nD 3\\nH 2\\n... | Let's arrange a deck of cards. Your task is to sort totally n cards. A card consists of a part of a suit (S, H, C or D) and an number. Write a program which sorts such cards based on the following pseudocode:
Partition(A, p, r)
1 x = A[r]
2 i = p-1
3 for j = p to r-1
4 do if A[j] <= x
5 then i = i+1
6 ... | 0 |
{"tests": "{\"inputs\": [\"2 1 1\\n10 15\\n6 1\\n\", \"3 0 3\\n10 8\\n7 11\\n5 2\\n\", \"1 0 0\\n2 1\\n\", \"1 0 200000\\n1 2\\n\", \"7 5 7\\n29 25\\n84 28\\n34 34\\n14 76\\n85 9\\n40 57\\n99 88\\n\", \"7 6 7\\n11 75\\n61 90\\n22 14\\n100 36\\n29 48\\n69 52\\n16 3\\n\", \"7 8 7\\n88 29\\n30 44\\n14 1\\n83 95\\n73 88\\n... | Recently Max has got himself into popular CCG "BrainStone". As "BrainStone" is a pretty intellectual game, Max has to solve numerous hard problems during the gameplay. Here is one of them:
Max owns n creatures, i-th of them can be described with two numbers — its health hp_{i} and its damage dmg_{i}. Max also has two ... | 0 |
{"tests": "{\"inputs\": [\"2+3\\n\", \"9-7\\n\", \"1+1+1\\n\", \"1+11+111\\n\", \"111-11-1\\n\", \"1+1-1+1-1+1-1+1-1+1\\n\", \"9+1\\n\", \"10-1\\n\", \"31+49+49+71-51-61+59-111+51\\n\", \"255+255+255+255+255-255-255-255-255-255\\n\", \"100+100+10+10+10+10+10+5\\n\", \"255-255+255-255+255-255+255-255+255\\n\", \"0-255-2... | In this problem you will write a simple generator of Brainfuck (https://en.wikipedia.org/wiki/Brainfuck) calculators.
You are given an arithmetic expression consisting of integers from 0 to 255 and addition/subtraction signs between them. Output a Brainfuck program which, when executed, will print the result of evalua... | 0 |
{"tests": "{\"inputs\": [\"5\\n2 1 3 0 1\\n\", \"9\\n0 2 3 4 1 1 0 2 2\\n\", \"4\\n0 2 1 1\\n\", \"5\\n1 0 2 1 0\\n\", \"1\\n0\\n\", \"5\\n3 0 4 1 2\\n\", \"3\\n1 0 0\\n\", \"7\\n3 0 0 4 2 2 1\\n\", \"10\\n1 0 2 3 3 0 4 4 2 5\\n\", \"7\\n2 4 3 5 1 6 0\\n\", \"10\\n6 2 8 1 4 5 7 3 9 3\\n\", \"5\\n2 0 3 1 1\\n\", \"7\\n2... | On February, 30th n students came in the Center for Training Olympiad Programmers (CTOP) of the Berland State University. They came one by one, one after another. Each of them went in, and before sitting down at his desk, greeted with those who were present in the room by shaking hands. Each of the students who came in... | 0 |
{"tests": "{\"inputs\": [\"3 2\\n1 2 4\\n\", \"5 2\\n3 -5 3 -5 3\\n\", \"6 3\\n4 3 4 3 2 5\\n\", \"2 1\\n1 100\\n\", \"4 3\\n1 2 4 8\\n\", \"5 2\\n1 2 8 8 16\\n\", \"10 3\\n-999999914 -999999976 -999999966 -999999952 29 54 -999999963 -999999959 -999999974 48\\n\", \"30 2\\n-999999924 -499999902 500000091 -999999998 500... | You've got array A, consisting of n integers and a positive integer k. Array A is indexed by integers from 1 to n.
You need to permute the array elements so that value $\sum_{i = 1}^{n - k}|A [ i ] - A [ i + k ]|$ became minimal possible. In particular, it is allowed not to change order of elements at all.
-----Inpu... | 0 |
{"tests": "{\"inputs\": [\"C>A\\nC<B\\nB>A\\n\", \"C<B\\nB<A\\nC>A\\n\", \"C<B\\nB>A\\nA<C\\n\", \"A>C\\nC>B\\nB<A\\n\", \"C<B\\nC<A\\nB<A\\n\", \"A>B\\nC>B\\nA<C\\n\", \"A>C\\nC<B\\nB>A\\n\", \"B>A\\nC<A\\nC>B\\n\", \"B<A\\nC>B\\nC>A\\n\", \"A>B\\nC>A\\nB<C\\n\", \"B>A\\nC<B\\nC>A\\n\", \"C>A\\nA<B\\nC>B\\n\", \"B>C\\... | One day Vasya came across three Berland coins. They didn't have any numbers that's why Vasya didn't understand how their denominations differ. He supposed that if one coin is heavier than the other one, then it should be worth more. Vasya weighed all the three pairs of coins on pan balance scales and told you the resul... | 0 |
{"tests": "{\"inputs\": [\"3 1\\n1 2\\n\", \"3 1\\n1 3\\n\", \"400 1\\n1 400\\n\", \"3 0\\n\", \"20 1\\n20 1\\n\", \"3 3\\n1 2\\n2 3\\n3 1\\n\", \"5 4\\n1 2\\n3 2\\n3 4\\n5 4\\n\", \"3 2\\n2 3\\n3 1\\n\", \"381 0\\n\", \"2 1\\n1 2\\n\", \"100 1\\n100 1\\n\", \"4 5\\n1 3\\n2 1\\n3 4\\n4 2\\n2 3\\n\", \"4 1\\n1 4\\n\", \... | In Absurdistan, there are n towns (numbered 1 through n) and m bidirectional railways. There is also an absurdly simple road network — for each pair of different towns x and y, there is a bidirectional road between towns x and y if and only if there is no railway between them. Travelling to a different town using one r... | 0 |
{"tests": "{\"inputs\": [\"3 3\\n5 9 2\\n3 6 9\", \"0 2\\n4 3\\n3 4\", \"14 13\\n158 167 181 147 178 151 179 182 176 169 180 129 175 168\\n181 73 178 179 167 180 176 169 182 177 175 159 173\", \"2 2\\n6 4\\n4 4\", \"3 3\\n5 9 2\\n0 6 9\", \"2 2\\n6 4\\n5 4\", \"0 2\\n8 3\\n3 4\", \"3 3\\n5 9 2\\n0 8 9\", \"2 2\\n6 1\\n... | Consider writing each of the integers from 1 to N \times M in a grid with N rows and M columns, without duplicates. Takahashi thinks it is not fun enough, and he will write the numbers under the following conditions:
* The largest among the values in the i-th row (1 \leq i \leq N) is A_i.
* The largest among the value... | 0 |
{"tests": "{\"inputs\": [\"9 4\\n2\\n2 4\\n\", \"9 4\\n3\\n2 3 1\\n\", \"9 4\\n3\\n1 2 4\\n\", \"39088169 24157817\\n36\\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2\\n\", \"39088169 24157817\\n36\\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 4\\n\", \"6130579072161... | A continued fraction of height n is a fraction of form $a_{1} + \frac{1}{a_{2} + \frac{1}{\ldots + \frac{1}{a_{n}}}}$. You are given two rational numbers, one is represented as [Image] and the other one is represented as a finite fraction of height n. Check if they are equal.
-----Input-----
The first line contains ... | 0 |
{"tests": "{\"inputs\": [\"3\\n7\\n1 1 1 3 3 3 2\\n5\\n1 3 1 1 1\\n4\\n5 5 5 5\", \"3\\n7\\n1 1 1 3 3 3 2\\n5\\n1 3 1 1 2\\n4\\n5 5 5 5\", \"3\\n7\\n1 1 1 3 3 3 3\\n5\\n1 3 1 1 2\\n4\\n5 5 5 5\", \"3\\n7\\n1 1 1 3 3 3 2\\n5\\n1 0 1 1 1\\n4\\n5 5 5 5\", \"3\\n7\\n1 1 1 3 3 3 2\\n5\\n1 3 1 1 2\\n4\\n9 5 5 5\", \"3\\n7\\n... | Read problems statements in Mandarin Chinese and Russian.
Chef is judging a game called "Broken telephone". There are total N players taking part in the game. They are all sitting in a line. In the start of the game, first player is given a secret message written on a sheet of paper. Then they keep sending the messa... | 0 |
{"tests": "{\"inputs\": [\"6\\n0 1 0 3 0 2\\n\", \"5\\n0 1 2 1 2\\n\", \"5\\n0 1 1 2 2\\n\", \"1\\n0\\n\", \"100\\n0 1 2 2 3 0 1 5 6 6 0 0 8 7 1 9 9 4 10 11 12 2 12 12 12 12 9 13 14 8 15 15 15 19 15 7 17 17 18 19 9 10 21 0 22 9 2 24 24 4 24 7 25 14 5 8 28 29 30 31 31 31 0 3 15 31 8 33 6 35 35 35 36 36 37 37 38 39 28 0 ... | Arkady decides to observe a river for n consecutive days. The river's water level on each day is equal to some real value.
Arkady goes to the riverside each day and makes a mark on the side of the channel at the height of the water level, but if it coincides with a mark made before, no new mark is created. The water d... | 0 |
{"tests": "{\"inputs\": [\"10 5\\n0 0 1 0 2 0 0 1 0\\n\", \"10 3\\n1 1 1 1 2 1 1 1 1\\n\", \"2 1\\n0\\n\", \"2 1\\n5\\n\", \"10 4\\n0 0 6 2 7 1 6 4 0\\n\", \"100 15\\n0 0 1 1 1 0 1 1 1 1 0 1 1 1 0 1 0 0 1 0 1 1 1 0 0 1 1 0 0 1 0 0 1 0 0 1 0 1 0 1 0 1 1 0 0 0 1 0 0 0 0 0 1 0 1 1 1 1 1 0 1 0 1 0 1 0 0 0 0 1 1 0 1 1 0 0 1... | A lot of frogs want to cross a river. A river is $w$ units width, but frogs can only jump $l$ units long, where $l < w$. Frogs can also jump on lengths shorter than $l$. but can't jump longer. Hopefully, there are some stones in the river to help them.
The stones are located at integer distances from the banks. There ... | 0 |
{"tests": "{\"inputs\": [\"1 26\\nz\\n\", \"100 26\\njysrixyptvsesnapfljeqkytlpeepjopspmkviqdqbdkylvfiawhdjjdvqqvcjmmsgfdmpjwahuwhgsyfcgnefzmqlvtvqqfbfsf\\n\", \"15 3\\nabababababababa\\n\", \"100 27\\njysrixyptvsesnapfljeqkytlpeepjopspmkviqdqbdkylvfiawhdjjdvqqvcjmmsgfdmpjwahuwhgsyfcgnefzmqlvtvqqfbfsf\\n\", \"3 6\\naab... | You are given a string S of length n with each character being one of the first m lowercase English letters.
Calculate how many different strings T of length n composed from the first m lowercase English letters exist such that the length of LCS (longest common subsequence) between S and T is n - 1.
Recall that LCS ... | 0 |
{"tests": "{\"inputs\": [\"8 10\\n1 2 1\\n2 3 2\\n2 4 5\\n1 4 2\\n6 3 3\\n6 1 3\\n3 5 2\\n3 7 1\\n4 8 1\\n6 2 4\\n\", \"4 3\\n2 1 3\\n4 3 4\\n2 4 1\\n\", \"3 3\\n1 2 1\\n2 3 2\\n1 3 3\\n\", \"3 3\\n1 2 1\\n2 3 3\\n1 3 3\\n\", \"1 0\\n\", \"5 6\\n1 2 2\\n2 3 1\\n4 5 3\\n2 4 2\\n1 4 2\\n1 5 3\\n\", \"4 4\\n1 2 3\\n2 3 4\... | You are given an undirected weighted connected graph with $n$ vertices and $m$ edges without loops and multiple edges.
The $i$-th edge is $e_i = (u_i, v_i, w_i)$; the distance between vertices $u_i$ and $v_i$ along the edge $e_i$ is $w_i$ ($1 \le w_i$). The graph is connected, i. e. for any pair of vertices, there is ... | 0.125 |
{"tests": "{\"inputs\": [\"8 5\\n8 6 2 1 4 5 7 5\\n6 3 3 2 6 2 3 2\\n2 8\\n1 4\\n4 7\\n3 4\\n6 10\\n\", \"6 6\\n6 6 6 6 6 6\\n6 66 666 6666 66666 666666\\n1 6\\n2 6\\n3 6\\n4 6\\n5 6\\n6 66\\n\", \"6 6\\n6 6 6 6 6 6\\n6 66 666 6666 66666 666666\\n1 6\\n2 13\\n3 6\\n4 11\\n5 6\\n6 6\\n\", \"1 1\\n411017\\n129875\\n1 816... | Lunar New Year is approaching, and Bob is planning to go for a famous restaurant — "Alice's".
The restaurant "Alice's" serves $n$ kinds of food. The cost for the $i$-th kind is always $c_i$. Initially, the restaurant has enough ingredients for serving exactly $a_i$ dishes of the $i$-th kind. In the New Year's Eve, $m$... | 0 |
{"tests": "{\"inputs\": [\"3\\n1 1\\n3 4\\n6 0\\n\\n7\\n0 0\\n10 10\\n0 20\\n10 33\\n0 40\\n100 40\\n100 0\\n\\n0\", \"3\\n1 1\\n3 4\\n6 0\\n\\n7\\n0 0\\n10 10\\n0 20\\n10 33\\n0 40\\n110 40\\n100 0\\n\\n0\", \"3\\n1 1\\n3 4\\n6 0\\n\\n7\\n0 0\\n10 10\\n0 20\\n10 30\\n0 40\\n100 40\\n100 1\\n\\n0\", \"3\\n1 1\\n3 4\\n6... | Polygons are the most fundamental objects in geometric processing. Complex figures are often represented and handled as polygons with many short sides. If you are interested in the processing of geometric data, you'd better try some programming exercises about basic operations on polygons.
Your job in this problem is ... | 0 |
{"tests": "{\"inputs\": [\"2\\n1 2\\n2 1\\n\", \"2\\n2 1\\n1 2\\n\", \"2\\n1 2\\n1 2\\n\", \"10\\n7 10 1 8 3 9 2 4 6 5\\n7 6 5 3 8 10 4 1 9 2\\n\", \"2\\n2 1\\n2 1\\n\", \"2\\n1 2\\n2 2\\n\", \"3\\n3 2 1\\n1 2 1\\n\", \"2\\n1 2\\n1 1\\n\", \"6\\n2 3 6 1 5 4\\n5 2 1 4 6 6\\n\", \"10\\n7 10 1 8 3 9 2 4 6 5\\n7 6 5 3 8 10... | You are given a permutation, p_1, p_2, …, p_n.
Imagine that some positions of the permutation contain bombs, such that there exists at least one position without a bomb.
For some fixed configuration of bombs, consider the following process. Initially, there is an empty set, A.
For each i from 1 to n:
* Add p_i to... | 0.125 |
{"tests": "{\"inputs\": [\"2 1 2 2\\n\", \"4 7 7 4\\n\", \"20 0 7 22\\n\", \"80 100 83 97\\n\", \"80 100 77 103\\n\", \"55000 60000 55003 60100\\n\", \"100000 100000 100000 99999\\n\", \"100000 99999 100000 100000\\n\", \"0 100000 100000 99999\\n\", \"0 100000 99999 100000\\n\", \"0 90000 89999 89999\\n\", \"0 1 0 2\\n... | Polycarp and Vasiliy love simple logical games. Today they play a game with infinite chessboard and one pawn for each player. Polycarp and Vasiliy move in turns, Polycarp starts. In each turn Polycarp can move his pawn from cell (x, y) to (x - 1, y) or (x, y - 1). Vasiliy can move his pawn from (x, y) to one of cells: ... | 0 |
{"tests": "{\"inputs\": [\"abbabbaaababbbbbbabbbbaabbabaababaababbbabbbaaaaaabbabbabbaabbbbaaaabbabaababbbabbaabaabbbaabaaaabbbbbabbbbbaababbabaabaababbbbbbbaaaababbabbaababbabaabbbbbabbbbaabaaabbbababaaabbbbabaaaabbbbbbbbbabbbbababababbbbaabbababaaabbabbaaaabaaabbbbabbbaaaabbabbaabaaaabaaaaabaaabbbbaaabababaaabbbaabba... | Two people play the following string game. Initially the players have got some string s. The players move in turns, the player who cannot make a move loses.
Before the game began, the string is written on a piece of paper, one letter per cell.
<image> An example of the initial situation at s = "abacaba"
A player's ... | 0 |
{"tests": "{\"inputs\": [\"2\\n2 5\\n4 2\", \"2\\n2 1\\n4 2\", \"2\\n2 0\\n4 2\", \"2\\n1 4\\n4 2\", \"2\\n2 0\\n4 0\", \"2\\n2 0\\n4 1\", \"2\\n1 8\\n4 2\", \"2\\n2 0\\n3 0\", \"2\\n2 0\\n1 1\", \"2\\n1 8\\n4 0\", \"2\\n4 0\\n1 1\", \"2\\n1 8\\n8 0\", \"2\\n2 0\\n2 1\", \"2\\n1 2\\n8 0\", \"2\\n1 0\\n2 1\", \"2\\n2 4\... | There is a bus route as shown in Figure 1. There are 10 stops, each numbered 0-9. The bus turns back at stop 0, but the other side is a circulation route, which circulates in the order of 5 → 6 → 7 → 8 → 9 → 5 as shown in the figure.
<image>
For this bus route, create a program that inputs the stop to get on and the... | 0 |
{"tests": "{\"inputs\": [\"99085 7738 98097 -6487\\n\", \"1 2 2 1\\n\", \"93430 5720 93581 -2371\\n\", \"97530 -7728 92184 -755\\n\", \"93564 -4520 99118 -52061\\n\", \"100000 100 100000 70000\\n\", \"98405 -62879 99461 -33688\\n\", \"5 4 3 -2\\n\", \"93564 8371 99118 6409\\n\", \"91125 7374 92925 -5261\\n\", \"98445 1... | Last year the world's largest square was built in Berland. It is known that the square can be represented as an infinite plane with an introduced Cartesian system of coordinates. On that square two sets of concentric circles were painted. Let's call the set of concentric circles with radii 1, 2, ..., K and the center i... | 0 |
{"tests": "{\"inputs\": [\"2 2 1 1\\n\", \"1 2 1 2\\n\", \"485 117 386829368 748204956\\n\", \"564 558 305171115 960941497\\n\", \"692 210 44175861 843331069\\n\", \"741 806 424647372 965259389\\n\", \"461 650 18427925 104278996\\n\", \"589 790 462465375 766499149\\n\", \"13 635 761278633 941090619\\n\", \"140 713 7113... | Alice has got addicted to a game called Sirtet recently.
In Sirtet, player is given an $n \times m$ grid. Initially $a_{i,j}$ cubes are stacked up in the cell $(i,j)$. Two cells are called adjacent if they share a side. Player can perform the following operations: stack up one cube in two adjacent cells; stack up t... | 0.375 |
{"tests": "{\"inputs\": [\"5 7 1 3 2 2\\n\", \"5 5 2 3 1 1\\n\", \"1 1 1 1 1 1\\n\", \"23000 15500 100 333 9 1\\n\", \"33999 99333 33000 99000 3 9\\n\", \"5 7 1 3 1 2\\n\", \"1 100 1 50 1 50\\n\", \"1000 1 1 1 1 500\\n\", \"304 400 12 20 4 4\\n\", \"1000000 1000000 1000000 1000000 1000000 1000000\\n\", \"1000000 99999 ... | Dima and Inna are doing so great! At the moment, Inna is sitting on the magic lawn playing with a pink pony. Dima wanted to play too. He brought an n × m chessboard, a very tasty candy and two numbers a and b.
Dima put the chessboard in front of Inna and placed the candy in position (i, j) on the board. The boy said h... | 0 |
{"tests": "{\"inputs\": [\"7\\n1 2 5\\n2 3 2\\n3 4 3\\n2 5 3\\n5 6 5\\n5 7 8\\n0\", \"7\\n1 2 5\\n2 3 2\\n3 4 3\\n2 5 0\\n5 6 10\\n5 7 7\\n0\", \"7\\n1 2 5\\n1 3 2\\n6 4 3\\n2 5 3\\n5 6 5\\n5 7 8\\n0\", \"7\\n1 2 5\\n2 3 3\\n3 4 3\\n2 5 3\\n5 6 5\\n5 7 8\\n0\", \"7\\n1 2 5\\n1 3 2\\n3 4 3\\n2 5 3\\n5 6 5\\n6 7 8\\n0\",... | Under the command "Save Sergeant Ryan," Aiz's rescue team fought fierce battles with enemy forces in the floating city of Lee, Germany. They successfully joined the sergeant, but there were many enemy tanks and they could not call a rescue herio. So, in order to confuse the enemy tanks, they decided to carry out an ope... | 0 |
{"tests": "{\"inputs\": [\"22\\n33 2 19 26 18 13 27 9 25 35 6 24 20 22 11 5 1 30 17 15 7 29\\n\", \"22\\n133295371 188010892 71730560 209842234 193069109 184556873 87395258 234247052 230809052 211444018 148989732 17810977 158722706 11753932 100093528 1000000000 43672080 61357581 171830832 13873487 34865589 114340079\\n... | You are given an array a with n distinct integers. Construct an array b by permuting a such that for every non-empty subset of indices S = {x1, x2, ..., xk} (1 ≤ xi ≤ n, 0 < k < n) the sums of elements on that positions in a and b are different, i. e.
<image>
Input
The first line contains one integer n (1 ≤ n ≤ 22)... | 0 |
{"tests": "{\"inputs\": [\"003512\\n021\\n\", \"199966633300\\n63\\n\", \"01\\n0\\n\", \"0000454312911\\n9213544\\n\", \"13\\n3\\n\", \"00010454312921\\n9213544\\n\", \"11317110\\n01\\n\", \"1516532320120301262110112013012410838210025280432402042406224604110031740090203024020012\\n0126064\\n\", \"2331211222726521435040... | Vasya decided to pass a very large integer n to Kate. First, he wrote that number as a string, then he appended to the right integer k — the number of digits in n.
Magically, all the numbers were shuffled in arbitrary order while this note was passed to Kate. The only thing that Vasya remembers, is a non-empty substr... | 0 |
{"tests": "{\"inputs\": [\"abbbbbbbabbbbbbbbbbbbbbbbbbbbbbbabbabbbbbabbbbbbbbbbbabbbbbbbbabbabbbbbbbbbbbbbbabbabbbaababbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbabbbbbbbbbbbbbbbbabbbbabbbbbbbbbbbbbbbabbbbbbbbbaababbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbabbabbbbbbbbbbbbbbbbabbbabbbbbaabbabbbbbbbbbbbbbbbbbb... | You are given a non-empty string s consisting of lowercase English letters. You have to pick exactly one non-empty substring of s and shift all its letters 'z' <image> 'y' <image> 'x' <image> 'b' <image> 'a' <image> 'z'. In other words, each character is replaced with the previous character of English alphabet and 'a' ... | 0.125 |
{"tests": "{\"inputs\": [[\"abba\", [\"aabb\", \"abcd\", \"bbaa\", \"dada\"]], [\"racer\", [\"crazer\", \"carer\", \"racar\", \"caers\", \"racer\"]], [\"a\", [\"a\", \"b\", \"c\", \"d\"]], [\"ab\", [\"cc\", \"ac\", \"bc\", \"cd\", \"ab\", \"ba\", \"racar\", \"caers\", \"racer\"]], [\"abba\", [\"a\", \"b\", \"c\", \"d\"... | What is an anagram? Well, two words are anagrams of each other if they both contain the same letters. For example:
```
'abba' & 'baab' == true
'abba' & 'bbaa' == true
'abba' & 'abbba' == false
'abba' & 'abca' == false
```
Write a function that will find all the anagrams of a word from a list. You will be given two... | 0 |
{"tests": "{\"inputs\": [\"7 1\\n6 2 1\", \"2 1\\n0 0 1000000010\", \"5 3\\n0 0 10\\n0 2 10\\n0 4 10\", \"9 1\\n6 2 1\", \"5 3\\n0 0 10\\n0 3 10\\n0 4 10\", \"9 1\\n7 2 1\", \"9 1\\n5 2 1\", \"7 1\\n5 4 1\", \"2 1\\n0 0 0000000000\", \"5 3\\n0 1 10\\n1 2 10\\n0 4 10\", \"2 1\\n1 0 1000000010\", \"9 1\\n6 2 0\", \"2 1\\... | We have a graph with N vertices, numbered 0 through N-1. Edges are yet to be added.
We will process Q queries to add edges. In the i-th (1≦i≦Q) query, three integers A_i, B_i and C_i will be given, and we will add infinitely many edges to the graph as follows:
* The two vertices numbered A_i and B_i will be connected... | 0.375 |
{"tests": "{\"inputs\": [\"8\\n20 1000\\n32 37\\n40 1000\\n45 50\\n16 16\\n16 16\\n14 1000\\n2 1000\\n\", \"7\\n4 4\\n4 4\\n4 4\\n4 4\\n4 4\\n4 4\\n5 5\\n\", \"7\\n14000000003 1000000000000000000\\n81000000000 88000000000\\n5000000000 7000000000\\n15000000000 39000000000\\n46000000000 51000000000\\n0 1000000000\\n0 0\\... | One tradition of ACM-ICPC contests is that a team gets a balloon for every solved problem. We assume that the submission time doesn't matter and teams are sorted only by the number of balloons they have. It means that one's place is equal to the number of teams with more balloons, increased by 1. For example, if there ... | 0 |
{"tests": "{\"inputs\": [\"3 4\\n0\\n\", \"3 4\\n2\\n1 1\\n1 3\\n\", \"10 10\\n0\\n\", \"100 100\\n0\\n\", \"1000 1000\\n0\\n\", \"10000 10000\\n1\\n1 1\\n\", \"200000 200000\\n0\\n\", \"200000 2\\n0\\n\", \"200000 20\\n0\\n\", \"200000 200\\n0\\n\", \"133742 69\\n0\\n\", \"2 200000\\n0\\n\", \"200 200000\\n0\\n\", \"2... | Monocarp plays a computer game. There are $n$ different sets of armor and $m$ different weapons in this game. If a character equips the $i$-th set of armor and wields the $j$-th weapon, their power is usually equal to $i + j$; but some combinations of armor and weapons synergize well. Formally, there is a list of $q$ o... | 0 |
{"tests": "{\"inputs\": [[4, 1], [4, 2], [4, 3], [10, 3], [10, 4], [20, 2], [4, 0], [4, 4], [4, 5]], \"outputs\": [[8], [6], [0], [222480], [55650], [447507315596451070], [9], [1], [0]]}", "source": "taco"} | We have an integer array with unique elements and we want to do the permutations that have an element fixed, in other words, these permutations should have a certain element at the same position than the original.
These permutations will be called: **permutations with one fixed point**.
Let's see an example with an a... | 0.5 |
{"tests": "{\"inputs\": [\"2 3 3\\n2 4\\n3 3\", \"4 3 3\\n1 1\\n0 3\\n3 1\\n3 3\", \"2 4 6\\n2 2\\n2 3\", \"1 4 4\\n2 2\\n3 3\", \"4 3 3\\n1 1\\n1 3\\n6 1\\n3 2\", \"2 4 6\\n2 2\\n0 3\", \"4 3 3\\n1 1\\n1 3\\n3 1\\n3 6\", \"4 6 3\\n1 1\\n0 3\\n3 1\\n3 3\", \"2 4 3\\n2 2\\n2 3\", \"4 3 3\\n1 1\\n1 3\\n3 1\\n3 2\", \"1 4... | There is a grid of size W × H surrounded by walls. Some cells in the grid are occupied by slimes. The slimes want to unite with each other and become a "King Slime".
In each move, a slime can move to east, west, south and north direction until it enters a cell occupied by another slime or hit the surrounding wall. If ... | 0.125 |
{"tests": "{\"inputs\": [\"4\\n-2 -1 2 2\\n-2 0 0 1\\n1 -2 2 -1\\n\", \"5\\n150684603 -262756669 -629261226 393751321 700168705\\n853551233 -595914191 -266257139 165068700 494943072\\n328547487 63141018 -951406530 -212389249 -69164259\\n\", \"1\\n1\\n1\\n1\\n\", \"3\\n1 1 1\\n-1 1 1\\n-1 1 1\\n\", \"20\\n16 82 25 21 -6... | You are given a rectangular table 3 × n. Each cell contains an integer. You can move from one cell to another if they share a side.
Find such path from the upper left cell to the bottom right cell of the table that doesn't visit any of the cells twice, and the sum of numbers written in the cells of this path is maximu... | 0 |
{"tests": "{\"inputs\": [\"5\\n1 2 5 1 4\\n1 2\\n1 3\\n2 4\\n2 5\\n\", \"5\\n2 1 1 3 1\\n1 2\\n1 3\\n3 4\\n4 5\\n\", \"5\\n2 2 3 5 3\\n1 2\\n2 3\\n3 4\\n4 5\\n\", \"12\\n4 1 6 1 7 1 1 3 2 5 3 2\\n1 2\\n2 10\\n1 3\\n3 4\\n7 9\\n3 5\\n5 7\\n7 8\\n1 11\\n11 12\\n3 6\\n\", \"5\\n4 2 1 2 3\\n2 1\\n3 1\\n4 2\\n5 3\\n\", \"4\... | You are given a tree with n vertices. Each vertex i has a value a_i associated with it.
Let us root the tree at some vertex v. The vertex v is called a distinctive root if the following holds: in all paths that start at v and end at some other node, all the values encountered are distinct. Two different paths may have... | 0.25 |
{"tests": "{\"inputs\": [\"4\\n4\\n-><-\\n5\\n>>>>>\\n3\\n<--\\n2\\n<>\\n\", \"36\\n2\\n--\\n2\\n>-\\n2\\n<-\\n2\\n->\\n2\\n>>\\n2\\n<>\\n2\\n-<\\n2\\n><\\n2\\n<<\\n3\\n---\\n3\\n>--\\n3\\n<--\\n3\\n->-\\n3\\n>>-\\n3\\n<>-\\n3\\n-<-\\n3\\n><-\\n3\\n<<-\\n3\\n-->\\n3\\n>->\\n3\\n<->\\n3\\n->>\\n3\\n>>>\\n3\\n<>>\\n3\\n-... | In the snake exhibition, there are $n$ rooms (numbered $0$ to $n - 1$) arranged in a circle, with a snake in each room. The rooms are connected by $n$ conveyor belts, and the $i$-th conveyor belt connects the rooms $i$ and $(i+1) \bmod n$. In the other words, rooms $0$ and $1$, $1$ and $2$, $\ldots$, $n-2$ and $n-1$, $... | 0 |
{"tests": "{\"inputs\": [\"4 3\\n#..#\\n#.#.\\n....\\n.###\\n\", \"10 4\\n#....##...\\n.#...#....\\n..#..#..#.\\n...#.#....\\n.#..##.#..\\n.....#...#\\n...#.##...\\n.#...#.#..\\n.....#..#.\\n...#.#...#\\n\", \"19 6\\n##..............###\\n#......#####.....##\\n.....#########.....\\n....###########....\\n...############... | Arkady is playing Battleship. The rules of this game aren't really important.
There is a field of $n \times n$ cells. There should be exactly one $k$-decker on the field, i. e. a ship that is $k$ cells long oriented either horizontally or vertically. However, Arkady doesn't know where it is located. For each cell Arka... | 0.875 |
{"tests": "{\"inputs\": [\"14\\n.L.R...LR..L..\\n\", \"5\\nR....\\n\", \"1\\n.\\n\", \"1\\nL\\n\", \"1\\nR\\n\", \"2\\nL.\\n\", \"2\\nRL\\n\", \"2\\n..\\n\", \"10\\nR........L\\n\", \"9\\nR.......L\\n\", \"6\\n..L.RL\\n\", \"34\\n..R...L..RL..RLRLR...L....R....L..\\n\", \"2\\nLR\\n\", \"2\\n.R\\n\", \"3\\n...\\n\", \"2... | Little Chris knows there's no fun in playing dominoes, he thinks it's too random and doesn't require skill. Instead, he decided to play with the dominoes and make a "domino show".
Chris arranges n dominoes in a line, placing each piece vertically upright. In the beginning, he simultaneously pushes some of the dominoes... | 0 |
{"tests": "{\"inputs\": [[2, 6, 2], [1, 5, 1], [1, 5, 3], [-1, -5, -3], [16, 15, 3], [-24, -2, 22], [-2, 4, 658], [780, 6851543, 5], [9383, 71418, 2], [20, 673388797, 5]], \"outputs\": [[12], [15], [5], [-5], [0], [-26], [-2], [4694363402480], [1253127200], [45345247259849570]]}", "source": "taco"} | As the title suggests, this is the hard-core version of another neat kata.
The task is simple to explain: simply sum all the numbers from the first parameter being the beginning to the second parameter being the upper limit (possibly included), going in steps expressed by the third parameter:
```python
sequence_sum(... | 0 |
{"tests": "{\"inputs\": [\"5\\n12 1\\n13 1\\n13 2\\n13 3\\n13 4\", \"5\\n12 1\\n13 1\\n13 3\\n13 3\\n13 4\", \"5\\n12 1\\n13 1\\n13 1\\n13 3\\n13 4\", \"5\\n12 1\\n13 1\\n6 1\\n13 3\\n13 4\", \"5\\n12 1\\n13 1\\n6 1\\n13 0\\n13 4\", \"5\\n12 1\\n13 1\\n6 1\\n13 0\\n13 7\", \"5\\n0 1\\n13 1\\n6 0\\n13 0\\n13 2\", \"5\\n... | Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
Chef's team is going to participate at the legendary math battles. One of the main task in the competition is to calculate the number of ways to create a number by adding some Chefonacci numbers. A number is called a Chefonacci number if it... | 0.25 |
{"tests": "{\"inputs\": [\"10 4 4\\n3 5\\n5 8\\n6 3\\n8 4\\n\", \"16 5 2\\n8 2\\n5 1\\n\", \"400000000 400000000 3\\n1 139613\\n19426 13509\\n246298622 343529\\n\", \"229 123 2\\n170 270968\\n76 734741\\n\", \"153 105 1\\n96 83995\\n\", \"281 12 23\\n178 650197\\n129 288456\\n34 924882\\n43 472160\\n207 957083\\n103 72... | Johnny drives a truck and must deliver a package from his hometown to the district center. His hometown is located at point 0 on a number line, and the district center is located at the point d.
Johnny's truck has a gas tank that holds exactly n liters, and his tank is initially full. As he drives, the truck consumes ... | 0.125 |
{"tests": "{\"inputs\": [[\"Appleby Arrows vs Montrose Magpies\", \"Montrose Magpies: Quaffle goal, Montrose Magpies: Quaffle goal, Appleby Arrows: Quaffle goal, Appleby Arrows: Quaffle goal, Montrose Magpies: Haverstacking foul, Appleby Arrows: Quaffle goal, Appleby Arrows: Quaffle goal, Appleby Arrows: Quaffle goal, ... | Your wizard cousin works at a Quidditch stadium and wants you to write a function that calculates the points for the Quidditch scoreboard!
# Story
Quidditch is a sport with two teams. The teams score goals by throwing the Quaffle through a hoop, each goal is worth **10 points**.
The referee also deducts 30 points (... | 0 |
{"tests": "{\"inputs\": [[\"1c0111001f010100061a024b53535009181c\", \"686974207468652062756c6c277320657965\"], [\"aadf\", \"bce2\"], [\"ab3f\", \"ac\"], [\"\", \"\"], [\"c611d9bdd9de38b9eb\", \"23a0745505d4d25494\"], [\"7d1e875da9d5e89b54c7eaf\", \"3541599be591709795cebd5\"], [\"785a6677b3e52f0e7\", \"a8d97da7441\"], [... | ## Fixed xor
Write a function that takes two hex strings as input and XORs them against each other. If the strings are different lengths the output should be the length of the shortest string.
Hint: The strings would first need to be converted to binary to be XOR'd.
## Note:
If the two strings are of different leng... | 0 |
{"tests": "{\"inputs\": [\"5 10 1\\n132 0 4 7\\n803 0 2 8\\n280 3 0 5\\n175 4 0 6\\n196 1 0 7\\n801 0 4 6\\n320 0 5 7\\n221 0 4 6\\n446 4 0 8\\n699 0 5 9\\n\", \"1 2 1\\n5 0 1 91\\n1 1 0 87\\n\", \"7 10 1\\n369 6 0 9\\n86 7 0 9\\n696 0 4 8\\n953 6 0 7\\n280 4 0 9\\n244 0 2 9\\n645 6 0 8\\n598 7 0 6\\n598 0 7 8\\n358 0 ... | Country of Metropolia is holding Olympiad of Metrpolises soon. It mean that all jury members of the olympiad should meet together in Metropolis (the capital of the country) for the problem preparation process.
There are n + 1 cities consecutively numbered from 0 to n. City 0 is Metropolis that is the meeting point for... | 0 |
{"tests": "{\"inputs\": [\"1\\n0\\n1\\n1\\n1\\n1 0\\n\", \"4\\n0 0 0 0\\n2\\n2 3\\n1\\n2\\n3\\n2 4 1\\n4\\n3 1 2 2\\n6\\n1 0\\n2 0\\n3 -1\\n4 -2\\n1 1\\n1 5\\n\", \"4\\n4 -5 -3 -1\\n2\\n2 3\\n1\\n2\\n3\\n2 4 1\\n4\\n3 1 2 1\\n6\\n1 0\\n3 0\\n3 -1\\n4 -2\\n1 1\\n1 5\\n\", \"4\\n0 0 0 0\\n2\\n2 3\\n1\\n2\\n3\\n2 4 1\\n4\... | Gildong is experimenting with an interesting machine Graph Traveler. In Graph Traveler, there is a directed graph consisting of n vertices numbered from 1 to n. The i-th vertex has m_i outgoing edges that are labeled as e_i[0], e_i[1], …, e_i[m_i-1], each representing the destination vertex of the edge. The graph can h... | 0 |
{"tests": "{\"inputs\": [\"3 3 2\\n12 578 1435\\n59 471605241352156968 431565444592236940\\n0 0 0\", \"3 3 2\\n12 578 1954\\n59 471605241352156968 431565444592236940\\n0 0 0\", \"3 3 2\\n12 785 2214\\n59 471605241352156968 431565444592236940\\n0 0 0\", \"4 3 2\\n12 578 1954\\n59 471605241352156968 431565444592236940\\n... | Folding a Ribbon
Think of repetitively folding a very long and thin ribbon. First, the ribbon is spread out from left to right, then it is creased at its center, and one half of the ribbon is laid over the other. You can either fold it from the left to the right, picking up the left end of the ribbon and laying it ove... | 0 |
{"tests": "{\"inputs\": [\"2\\n3\\n3 2 1\\n6\\n3 1 4 1 5 9\\n\", \"4\\n7\\n6 6 8 8 6 6 6\\n1\\n2\\n5\\n4 5 9 8 7\\n7\\n1 2 7 1 6 10 2\\n\", \"2\\n5\\n5 5 5 5 5\\n3\\n1 2 5\\n\", \"2\\n5\\n1 2 3 4 5\\n4\\n2 3 4 5\\n\", \"1\\n3\\n1 1 274005660\\n\", \"2\\n2\\n1 1\\n1\\n1\\n\", \"2\\n4\\n1 3 3 3\\n3\\n1 2 3\\n\", \"2\\n3\... | Ehab has an array $a$ of length $n$. He has just enough free time to make a new array consisting of $n$ copies of the old array, written back-to-back. What will be the length of the new array's longest increasing subsequence?
A sequence $a$ is a subsequence of an array $b$ if $a$ can be obtained from $b$ by deletion o... | 0.75 |
{"tests": "{\"inputs\": [\"6 3\\n1 1 1 0 1 0\\n\", \"5 2\\n0 0 0 1 0\\n\", \"1 1\\n1\\n\", \"1 1\\n0\\n\", \"9 3\\n1 1 1 1 1 1 1 1 0\\n\", \"9 5\\n1 0 1 0 1 0 1 0 1\\n\", \"20 17\\n1 1 0 1 1 1 1 0 1 0 1 1 1 0 1 1 0 0 0 0\\n\", \"100 60\\n1 1 1 1 1 1 0 1 0 0 1 1 0 1 1 1 1 1 0 0 1 1 0 0 0 0 0 1 0 1 1 0 1 0 1 0 1 0 1 1 0 ... | There are n cities in Bearland, numbered 1 through n. Cities are arranged in one long row. The distance between cities i and j is equal to |i - j|.
Limak is a police officer. He lives in a city a. His job is to catch criminals. It's hard because he doesn't know in which cities criminals are. Though, he knows that ther... | 0.75 |
{"tests": "{\"inputs\": [\"5 4\\n1 4 2 3 5\\n\", \"8 4\\n4 2 4 2 4 2 4 2\\n\", \"10 7\\n14 15 92 65 35 89 79 32 38 46\\n\", \"5 1\\n1 4 2 3 5\", \"10 7\\n14 15 101 65 35 89 79 32 38 46\", \"10 8\\n14 26 111 65 35 89 95 32 38 46\", \"10 3\\n14 26 111 65 35 89 95 32 38 46\", \"5 8\\n1 4 2 3 5\", \"10 7\\n18 15 92 65 35 8... | Given are a sequence of N positive integers A_1, A_2, \ldots, A_N, and a positive integer K.
Find the number of non-empty contiguous subsequences in A such that the remainder when dividing the sum of its elements by K is equal to the number of its elements. We consider two subsequences different if they are taken from ... | 0.875 |
{"tests": "{\"inputs\": [\"4\\n2 1 2 1\\n\", \"5\\n0 -1 -1 -1 -1\\n\", \"2\\n10 8\\n\", \"5\\n-14 -2 0 -19 -12\\n\", \"6\\n-15 2 -19 20 0 9\\n\", \"3\\n17 4 -1\\n\", \"4\\n20 3 -15 7\\n\", \"1\\n11\\n\", \"1\\n-10\\n\", \"7\\n-8 9 0 -10 -20 -8 3\\n\", \"9\\n2 4 -4 15 1 11 15 -7 -20\\n\", \"10\\n-20 0 3 -5 -18 15 -3 -9 ... | There are $n$ slimes in a row. Each slime has an integer value (possibly negative or zero) associated with it.
Any slime can eat its adjacent slime (the closest slime to its left or to its right, assuming that this slime exists).
When a slime with a value $x$ eats a slime with a value $y$, the eaten slime disappears... | 0 |
{"tests": "{\"inputs\": [\"5\\n0 1 1 3\\n0 0 0 1 1\\n\", \"2\\n0\\n1 0\\n\", \"100\\n0 0 2 2 0 3 5 0 6 2 0 4 0 2 3 7 8 3 15 19 13 8 18 19 3 14 23 9 6 3 6 17 26 24 20 6 4 27 8 5 14 5 35 31 27 3 41 25 20 14 25 31 49 40 0 1 10 5 50 13 29 58 1 6 8 1 40 52 30 15 50 8 66 52 29 71 25 68 36 7 80 60 6 2 11 43 62 27 84 86 71 38 ... | Appleman has a tree with n vertices. Some of the vertices (at least one) are colored black and other vertices are colored white.
Consider a set consisting of k (0 ≤ k < n) edges of Appleman's tree. If Appleman deletes these edges from the tree, then it will split into (k + 1) parts. Note, that each part will be a tree... | 0 |
{"tests": "{\"inputs\": [\"4\\n1 2 3 4\\n1 2\\n2 3\\n1 4\", \"10\\n3 4 9 6 1 5 -1 10 -10 -20\\n7 4\\n5 6\\n8 1\\n9 5\\n7 1\\n10 3\\n2 8\\n4 10\\n9 2\", \"10\\n3 4 9 6 1 10 -1 10 -10 -10\\n7 4\\n5 6\\n8 1\\n9 5\\n7 1\\n10 3\\n2 8\\n4 10\\n9 2\", \"8\\n-2 3 6 -2 -2 -5 3 2\\n1 4\\n7 6\\n6 2\\n8 2\\n5 3\\n1 8\\n3 7\", \"10... | The server in company A has a structure where N devices numbered 1, 2, ..., N are connected with N - 1 cables. The i-th cable connects Device U_i and Device V_i. Any two different devices are connected through some number of cables.
Each device v (1 \leq v \leq N) has a non-zero integer A_v, which represents the follo... | 0.375 |
{"tests": "{\"inputs\": [\"20\\n17592722915328 137438953728 0 549755822096 2251800350556160 70368744185856 0 2251804108652544 0 1099511628288 17592186045440 8864812498944 79164837199872 0 68719477760 1236950581248 549755814400 0 17179869456 21474836480\\n\", \"5\\n292733975779082240 18014398509482240 306244774661193728... | You are given n integer numbers a_1, a_2, ..., a_n. Consider graph on n nodes, in which nodes i, j (i≠ j) are connected if and only if, a_i AND a_j≠ 0, where AND denotes the [bitwise AND operation](https://en.wikipedia.org/wiki/Bitwise_operation#AND).
Find the length of the shortest cycle in this graph or determine th... | 0.375 |
{"tests": "{\"inputs\": [\"1\\n6 9 9 9 9\\n5\\n5 9 5 2 9\\n5 5 6 9 9\\n4 6 3 6 9\\n3 3 2 9 9\\n2 2 1 1 1\\n10\\n3 5 6 5 6\\n2 2 2 8 3\\n6 2 5 9 2\\n7 7 7 6 1\\n4 6 6 4 9\\n8 9 1 1 8\\n5 6 1 8 1\\n6 8 2 1 2\\n9 6 3 3 5\\n5 3 8 8 8\\n5\\n1 2 3 4 5\\n6 7 8 9 1\\n2 3 4 5 6\\n7 8 9 1 2\\n3 4 5 6 7\\n3\\n2 2 8 7 4\\n6 5 7 7 ... | Chain Disappearance Puzzle
We are playing a puzzle. An upright board with H rows by 5 columns of cells, as shown in the figure below, is used in this puzzle. A stone engraved with a digit, one of 1 through 9, is placed in each of the cells. When three or more stones in horizontally adjacent cells are engraved with the... | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.