info stringlengths 120 50k | question stringlengths 504 10.4k | avg@8_qwen3_4b_instruct_2507 float64 0 0.88 |
|---|---|---|
{"tests": "{\"inputs\": [\"4\\n1 2\\n2 3\\n2 3\", \"4\\n1 2\\n1 3\\n2 4\", \"3\\n1 2\\n1 3\", \"4\\n1 2\\n2 3\\n2 2\", \"4\\n1 2\\n2 3\\n2 0\", \"4\\n0 2\\n2 3\\n2 2\", \"4\\n1 2\\n2 3\\n0 0\", \"3\\n0 2\\n2 3\", \"6\\n2 2\\n2 3\\n3 4\\n2 5\\n5 6\", \"4\\n1 2\\n2 3\\n0 2\", \"4\\n1 1\\n2 3\\n2 0\", \"4\\n0 2\\n2 4\\n2 ... | There is a tree with N vertices numbered 1 through N. The i-th of the N-1 edges connects vertices a_i and b_i.
Initially, each vertex is uncolored.
Takahashi and Aoki is playing a game by painting the vertices. In this game, they alternately perform the following operation, starting from Takahashi:
* Select a vertex... | 0.125 |
{"tests": "{\"inputs\": [\"3 2 W\\nOO\\nWW\\nWW\\n\", \"10 10 T\\nCCEEEKKKHJ\\nCCRRRRRRHJ\\nCC..XFFOOO\\nZZZZZFFOOO\\n..PTTFFOOO\\nAAATTFFOOO\\nAAATTYYYYY\\nAAATTYYYYY\\nAAAMMYYYYY\\nAAA..YYYYY\\n\", \"2 2 W\\nKW\\nKW\\n\", \"1 1 C\\nC\\n\", \"8 10 B\\n..BBBBEEEE\\n..BBBBEEEE\\n..BBBBEEEE\\n..BBBBEEEE\\nJJJJYYYY..\\nJJ... | President of Berland has a very vast office-room, where, apart from him, work his subordinates. Each subordinate, as well as President himself, has his own desk of a unique colour. Each desk is rectangular, and its sides are parallel to the office walls. One day President decided to establish an assembly, of which all ... | 0 |
{"tests": "{\"inputs\": [\"13 5 6\\n1 3 35902\\n4 6 19698\\n4 6 73389\\n3 6 3031\\n3 1 4771\\n1 4 4784\\n2 1 36357\\n2 1 24830\\n5 6 50219\\n4 6 22645\\n0 2 30739\\n1 4 68417\\n1 5 78537\", \"6 2 2\\n2 2 2\\n1 1 8\\n1 1 5\\n1 2 9\\n1 2 2\\n2 1 4\", \"13 5 6\\n1 3 35902\\n4 6 19698\\n4 6 73389\\n3 6 3031\\n3 1 4771\\n1 ... | There are N cards placed on a grid with H rows and W columns of squares.
The i-th card has an integer A_i written on it, and it is placed on the square at the R_i-th row from the top and the C_i-th column from the left.
Multiple cards may be placed on the same square.
You will first pick up at most one card from eac... | 0 |
{"tests": "{\"inputs\": [\"3\\n1 2 0\", \"3\\n3 2 1\", \"4\\n1 2 4 11\", \"3\\n0 2 0\", \"4\\n0 2 4 11\", \"3\\n0 1 0\", \"4\\n0 4 4 11\", \"3\\n0 1 -1\", \"4\\n0 4 4 20\", \"3\\n1 2 1\", \"4\\n0 4 1 20\", \"3\\n2 2 1\", \"4\\n0 4 1 33\", \"4\\n0 4 1 63\", \"3\\n3 4 1\", \"4\\n0 4 1 39\", \"3\\n3 7 1\", \"4\\n0 4 1 0\"... | Snuke has N hats. The i-th hat has an integer a_i written on it.
There are N camels standing in a circle. Snuke will put one of his hats on each of these camels.
If there exists a way to distribute the hats to the camels such that the following condition is satisfied for every camel, print `Yes`; otherwise, print `No... | 0.375 |
{"tests": "{\"inputs\": [[[6, 6]], [[5, 6, 4]], [[3, 15, 8, 20]], [[6]], [[3, 3]], [[20]], [[3, 6]]], \"outputs\": [[3], [5], [44], [0], [0], [1], [0]]}", "source": "taco"} | With one die of 6 sides we will have six different possible results:``` 1, 2, 3, 4, 5, 6``` .
With 2 dice of six sides, we will have 36 different possible results:
```
(1,1),(1,2),(2,1),(1,3),(3,1),(1,4),(4,1),(1,5),
(5,1), (1,6),(6,1),(2,2),(2,3),(3,2),(2,4),(4,2),
(2,5),(5,2)(2,6),(6,2),(3,3),(3,4),(4,3),(3,5),(5,... | 0 |
{"tests": "{\"inputs\": [\"1000000\\n\", \"100\\n\", \"300000\\n\", \"300\\n\", \"9\\n\", \"1\\n\", \"3\\n\", \"3000\\n\", \"6\\n\", \"8\\n\", \"1500\\n\", \"10000\\n\", \"15\\n\", \"900\\n\", \"30\\n\", \"31\\n\", \"99999\\n\", \"100000\\n\", \"4000000\\n\", \"10000000\\n\", \"10\\n\", \"9999999\\n\", \"800000\\n\", \... | You are given a tetrahedron. Let's mark its vertices with letters A, B, C and D correspondingly.
<image>
An ant is standing in the vertex D of the tetrahedron. The ant is quite active and he wouldn't stay idle. At each moment of time he makes a step from one vertex to another one along some edge of the tetrahedron. T... | 0.875 |
{"tests": "{\"inputs\": [\"3\\n2 2 2\\n\", \"2\\n2 3\\n\", \"3\\n1 1 1\\n\", \"1\\n1000000000\\n\", \"10\\n10 10 7 9 8 3 3 10 7 3\\n\", \"100\\n23 39 85 46 97 72 41 70 37 18 8 40 33 61 12 79 51 78 61 66 85 97 78 14 70 47 100 40 15 40 61 52 19 30 14 91 82 56 10 6 68 24 97 61 31 78 18 45 88 6 37 38 51 86 37 42 58 30 79 5... | You are given an array of $n$ positive integers $a_1, a_2, \ldots, a_n$. Your task is to calculate the number of arrays of $n$ positive integers $b_1, b_2, \ldots, b_n$ such that:
$1 \le b_i \le a_i$ for every $i$ ($1 \le i \le n$), and
$b_i \neq b_{i+1}$ for every $i$ ($1 \le i \le n - 1$).
The number of such array... | 0 |
{"tests": "{\"inputs\": [\"2\\n1 2 3 6\\n3 4 7 8\\n\", \"3\\n1 3 2 4\\n4 5 6 7\\n3 4 5 5\\n\", \"6\\n1 5 2 9\\n2 4 5 8\\n3 6 7 11\\n7 10 12 16\\n8 11 13 17\\n9 12 14 18\\n\", \"1\\n21044762 968128997 570202182 610619156\\n\", \"2\\n4 4 4 5\\n4 5 1 2\\n\", \"2\\n311374951 311375694 79710796 79710890\\n311374081 31137467... | Filled with optimism, Hyunuk will host a conference about how great this new year will be!
The conference will have $n$ lectures. Hyunuk has two candidate venues $a$ and $b$. For each of the $n$ lectures, the speaker specified two time intervals $[sa_i, ea_i]$ ($sa_i \le ea_i$) and $[sb_i, eb_i]$ ($sb_i \le eb_i$). If... | 0.625 |
{"tests": "{\"inputs\": [\"2\\n1 31\\n\", \"2\\n1 0\\n\", \"10\\n450661 128600 993228 725823 293549 33490 843121 903634 556169 448234\\n\", \"1\\n1\\n\", \"5\\n1 3 5 7 9\\n\", \"6\\n524 529 5249 524 529 529\\n\", \"3\\n1 2 3\\n\", \"2\\n0 1\\n\", \"55\\n0 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 2 3 4 5 6 7 8 9 3 4 5 6 7 8 ... | Jzzhu have n non-negative integers a1, a2, ..., an. We will call a sequence of indexes i1, i2, ..., ik (1 ≤ i1 < i2 < ... < ik ≤ n) a group of size k.
Jzzhu wonders, how many groups exists such that ai1 & ai2 & ... & aik = 0 (1 ≤ k ≤ n)? Help him and print this number modulo 1000000007 (109 + 7). Operation x & y deno... | 0.375 |
{"tests": "{\"inputs\": [\"4 3\\n2\\n6\\n8\\n1\\n2\\n9\\n3\", \"2 2\\n3\\n6\\n2\\n7\", \"0 3\\n2\\n6\\n8\\n1\\n2\\n9\\n3\", \"2 2\\n3\\n9\\n2\\n7\", \"0 3\\n2\\n6\\n13\\n1\\n2\\n9\\n3\", \"2 2\\n3\\n16\\n2\\n7\", \"2 2\\n3\\n32\\n2\\n7\", \"2 2\\n0\\n32\\n2\\n7\", \"0 3\\n1\\n6\\n8\\n1\\n2\\n9\\n0\", \"2 2\\n-1\\n32\\n... | On an xy plane, in an area satisfying 0 ≤ x ≤ W, 0 ≤ y ≤ H, there is one house at each and every point where both x and y are integers.
There are unpaved roads between every pair of points for which either the x coordinates are equal and the difference between the y coordinates is 1, or the y coordinates are equal and... | 0 |
{"tests": "{\"inputs\": [\"512 4\\n\", \"1000000000 9\\n\", \"131203 11\\n\", \"999999999 50\\n\", \"999999999 49\\n\", \"131203 9\\n\", \"900000000 16\\n\", \"909090909 50\\n\", \"1001 2\\n\", \"5 2\\n\", \"2 1\\n\", \"900000000 16\\n\", \"131203 11\\n\", \"131203 9\\n\", \"999999999 50\\n\", \"909090909 50\\n\", \"99... | Little girl Tanya is learning how to decrease a number by one, but she does it wrong with a number consisting of two or more digits. Tanya subtracts one from a number by the following algorithm: if the last digit of the number is non-zero, she decreases the number by one; if the last digit of the number is zero, she ... | 0.875 |
{"tests": "{\"inputs\": [\"10\\n1 1 0 0 0 0 1 1 1 0\", \"10\\n1 1 0 0 0 0 1 1 1 1\", \"10\\n1 1 0 0 0 0 1 2 1 1\", \"10\\n1 1 0 0 -1 0 1 2 1 1\", \"10\\n1 1 0 0 -1 1 1 2 1 1\", \"10\\n1 1 0 0 -1 2 1 2 1 2\", \"10\\n-1 1 1 1 1 -1 -21 1 1 15\", \"10\\n1 1 0 0 -1 1 1 2 1 2\", \"10\\n1 1 0 0 -1 2 1 4 1 2\", \"10\\n0 1 0 0 ... | Illumination
Illuminations are displayed in the corridors every year at the JOI High School Cultural Festival. The illuminations consist of N light bulbs, which are lined up in a row from the west side to the east side of the corridor. Each light bulb is either on or off.
A machine that operates a light bulb is sleep... | 0.5 |
{"tests": "{\"inputs\": [\"a\\naa\\n\", \"a\\na\\n\", \"vnssnssnssnssnssnssnssnssnssnssnssnssnssnssnssnssn\\nnssnssns\\n\", \"ababababab\\nabab\\n\", \"a\\nb\\n\", \"vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv\\nvvvvvvvv\\n\", \"kpjmawawawawawawawawawawawawawawawawawawawawawawaw\\nwawawawa\\n\", \"a\\na`\\n\", \... | Hamed has recently found a string t and suddenly became quite fond of it. He spent several days trying to find all occurrences of t in other strings he had. Finally he became tired and started thinking about the following problem. Given a string s how many ways are there to extract k ≥ 1 non-overlapping substrings from... | 0 |
{"tests": "{\"inputs\": [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11], [12], [20], [35], [36], [37], [100], [101], [102], [103], [104], [105], [190], [2890], [38890], [488890], [5888890], [3678608], [3678609], [3678610], [3678611], [3678612], [3678613], [3678614], [3897249], [3897189], [3897309], [3897369], ... | Ho ho! So you think you know integers, do you? Well then, young wizard, tell us what the Nth digit of the [Champernowne constant](https://en.wikipedia.org/wiki/Champernowne_constant) is!
The constant proceeds like this: `0.12345678910111213141516...`
I hope you see the pattern!
Conjure a function that will accept an... | 0 |
{"tests": "{\"inputs\": [\"5\\n13 199 1\\n93 1000 1\\n37 350 10\\n27 300 2\\n99 200 1000\", \"3\\n9 100 1\\n13 200 20\\n12 300 3\", \"2\\n2 100 1\\n2 200 2\", \"5\\n13 199 1\\n93 1000 1\\n37 350 10\\n27 300 2\\n82 200 1000\", \"3\\n9 100 1\\n13 200 20\\n19 300 3\", \"5\\n13 199 1\\n93 1000 1\\n37 350 10\\n27 300 2\\n12... | The phantom thief "Lupin IV" is told by the beautiful "Fujiko Mine", a descendant of the Aizu clan, that the military funds left by the Aizu clan are sleeping in Aizuwakamatsu city. According to a report by Lupine's longtime companion, "Ishikawa Koshiemon," military funds are stored in several warehouses in a Senryobak... | 0.25 |
{"tests": "{\"inputs\": [\"9\\n5 5\\n..*..\\n..*..\\n*****\\n..*..\\n..*..\\n3 4\\n****\\n.*..\\n.*..\\n4 3\\n***\\n*..\\n*..\\n*..\\n5 5\\n*****\\n*.*.*\\n*****\\n..*.*\\n..***\\n1 4\\n****\\n5 5\\n.....\\n..*..\\n.***.\\n..*..\\n.....\\n5 3\\n...\\n.*.\\n.*.\\n***\\n.*.\\n3 3\\n.*.\\n*.*\\n.*.\\n4 4\\n*.**\\n....\\n*... | You are given a picture consisting of $n$ rows and $m$ columns. Rows are numbered from $1$ to $n$ from the top to the bottom, columns are numbered from $1$ to $m$ from the left to the right. Each cell is painted either black or white.
You think that this picture is not interesting enough. You consider a picture to be... | 0.25 |
{"tests": "{\"inputs\": [\"5 4\\n4 5 1 2 3\\n3 2 1 5 4\", \"3 1\\n1 2 3\\n3 2 1\", \"5 8\\n4 5 1 2 3\\n3 2 1 5 4\", \"5 11\\n4 5 1 2 3\\n3 2 1 5 4\", \"5 2\\n4 5 1 2 3\\n3 2 1 5 4\", \"3 6\\n1 2 3\\n3 2 1\", \"5 20\\n4 5 1 2 3\\n3 2 1 5 4\", \"5 14\\n4 5 1 2 3\\n3 2 1 5 4\", \"3 17\\n2 1 3\\n3 2 1\", \"3 10\\n2 1 3\\n3... | For two permutations p and q of the integers from 1 through N, let f(p,q) be the permutation that satisfies the following:
* The p_i-th element (1 \leq i \leq N) in f(p,q) is q_i. Here, p_i and q_i respectively denote the i-th element in p and q.
You are given two permutations p and q of the integers from 1 through... | 0 |
{"tests": "{\"inputs\": [[5, 1], [8, 3], [75, 34], [82, 49], [73, 38], [86, 71], [61, 17], [42, 38], [29, 5], [64, 49], [61, 20], [88, 52]], \"outputs\": [[[5, 24]], [[7, 51]], [[35, 4238]], [[48, 5091]], [[61, 3996]], [[10, 6275]], [[26, 3000]], [[12, 1578]], [[28, 740]], [[43, 3327]], [[32, 2922]], [[59, 5856]]]}", "... | # Task
The game starts with `n` people standing in a circle. The presenter counts `m` people starting with the first one, and gives `1` coin to each of them. The rest of the players receive `2` coins each. After that, the last person who received `1` coin leaves the circle, giving everything he had to the next partici... | 0 |
{"tests": "{\"inputs\": [\"6\\n10\\n10\\n10\\n01\\n10\\n10\\n\", \"4\\n01\\n01\\n10\\n10\\n\", \"1\\n10\\n\", \"2\\n01\\n10\\n\", \"2\\n10\\n10\\n\", \"3\\n10\\n01\\n10\\n\", \"1\\n01\\n\", \"2\\n01\\n01\\n\", \"2\\n10\\n01\\n\", \"3\\n01\\n01\\n01\\n\", \"3\\n10\\n10\\n01\\n\", \"3\\n01\\n10\\n10\\n\", \"115\\n10\\n10... | Mad scientist Mike entertains himself by arranging rows of dominoes. He doesn't need dominoes, though: he uses rectangular magnets instead. Each magnet has two poles, positive (a "plus") and negative (a "minus"). If two magnets are put together at a close distance, then the like poles will repel each other and the oppo... | 0 |
{"tests": "{\"inputs\": [\"5\\n100\\n12\\n8\\n2021\\n10000\\n\", \"2\\n999999999\\n1000000000\\n\", \"1\\n721156322\\n\", \"1\\n721156322\\n\", \"2\\n999999999\\n1000000000\\n\", \"1\\n1156079886\\n\", \"2\\n836671254\\n1000000000\\n\", \"5\\n110\\n12\\n8\\n2021\\n10000\\n\", \"1\\n1668987868\\n\", \"2\\n817117042\\n10... | Alice has just learned addition. However, she hasn't learned the concept of "carrying" fully — instead of carrying to the next column, she carries to the column two columns to the left.
For example, the regular way to evaluate the sum $2039 + 2976$ would be as shown:
However, Alice evaluates it as shown:
In particul... | 0 |
{"tests": "{\"inputs\": [\"8587340257\\n\", \"9\\n\", \"81\\n\", \"27\\n\", \"1408514752349\\n\", \"25\\n\", \"49380563\\n\", \"266418\\n\", \"319757451841\\n\", \"6599669076000\\n\", \"8\\n\", \"1000000000000\\n\", \"30971726\\n\", \"274875809788\\n\", \"64\\n\", \"34280152201\\n\", \"236\\n\", \"472670214391\\n\", \"... | You can't possibly imagine how cold our friends are this winter in Nvodsk! Two of them play the following game to warm up: initially a piece of paper has an integer q. During a move a player should write any integer number that is a non-trivial divisor of the last written number. Then he should run this number of circl... | 0 |
{"tests": "{\"inputs\": [[\"13:00\"], [\"13:09\"], [\"13:15\"], [\"13:29\"], [\"13:30\"], [\"13:31\"], [\"13:45\"], [\"13:59\"], [\"00:48\"], [\"00:08\"], [\"12:00\"], [\"00:00\"], [\"19:01\"], [\"07:01\"], [\"01:59\"], [\"12:01\"], [\"00:01\"], [\"11:31\"], [\"23:31\"], [\"11:45\"], [\"11:59\"], [\"23:45\"], [\"23:59\... | Given time in 24-hour format, convert it to words.
```
For example:
13:00 = one o'clock
13:09 = nine minutes past one
13:15 = quarter past one
13:29 = twenty nine minutes past one
13:30 = half past one
13:31 = twenty nine minutes to two
13:45 = quarter to two
00:48 = twelve minutes to one
00:08 = eight minutes p... | 0 |
{"tests": "{\"inputs\": [[\"ArNran u rstm5twob e ePb\"], [\"ArNran u rstm8twob e ePc\"], [\"92287a76 585a2y0\"], [\" a29068686a275y5\"], [\"8a 55y0y0y5a7 78\"], [\"9y98a877a95976a758726a89a5659957ya y\"], [\"aa297625 88a02670997 86ya880 00a9067\"], [\"826a976a508a9a 687600a2800 895055y a\"], [\" a702a067629y022ay865... | Student A and student B are giving each other test answers during a test.
They don't want to be caught so they are sending each other coded messages.
Student A is sending student B the message: `Answer to Number 5 Part b`.
He starts of with a square grid (in this example the grid = 5x5).
He writes the message do... | 0 |
{"tests": "{\"inputs\": [\"3\\n4\\n1 3 2 4\\n3\\n1 2 3\\n5\\n2 1 4 5 3\\n\", \"1\\n8\\n6 2 3 1 8 4 5 7\\n\", \"1\\n8\\n6 2 3 1 8 4 5 7\\n\", \"1\\n8\\n6 0 3 1 8 4 5 7\\n\", \"3\\n4\\n1 3 2 7\\n3\\n1 2 3\\n5\\n2 1 4 5 3\\n\", \"1\\n8\\n5 2 2 1 0 0 2 8\\n\", \"1\\n6\\n6 0 3 1 8 4 5 7\\n\", \"1\\n8\\n6 2 6 1 8 4 5 7\\n\",... | You are given a permutation $a$ consisting of $n$ numbers $1$, $2$, ..., $n$ (a permutation is an array in which each element from $1$ to $n$ occurs exactly once).
You can perform the following operation: choose some subarray (contiguous subsegment) of $a$ and rearrange the elements in it in any way you want. But this... | 0.375 |
{"tests": "{\"inputs\": [\"10 17\\n8 2 166387394\\n1 6 237498837\\n6 9 99779164\\n4 7 525284035\\n5 3 354857458\\n5 4 957219660\\n4 8 447860623\\n4 2 765484117\\n4 1 862758183\\n6 10 141683709\\n6 3 249157457\\n4 3 868580407\\n4 10 509806549\\n2 5 163095060\\n6 4 653748301\\n9 4 804011952\\n7 6 240252621\\n\", \"10 22\... | After a successful field test, Heidi is considering deploying a trap along some Corridor, possibly not the first one. She wants to avoid meeting the Daleks inside the Time Vortex, so for abundance of caution she considers placing the traps only along those Corridors that are not going to be used according to the curren... | 0 |
{"tests": "{\"inputs\": [[\"hello world!\", \"hello\"], [\"hello world!\", \"HELLO\"], [\"nowai\", \"nowaisir\"], [\"\", \"\"], [\"abc\", \"\"], [\"\", \"abc\"]], \"outputs\": [[true], [false], [false], [true], [true], [false]]}", "source": "taco"} | Challenge:
Given two null-terminated strings in the arguments "string" and "prefix", determine if "string" starts with the "prefix" string. Return 1 (or any other "truthy" value) if true, 0 if false.
Example:
```
startsWith("hello world!", "hello"); // should return 1.
startsWith("hello world!", "HELLO"); // should re... | 0 |
{"tests": "{\"inputs\": [\"8\\n2\\nomura\\ntoshio\\nraku\\ntanaka\\ninura\\nyoshoi\\nhayashi\\nmiura\\n3\\n1\\ntasaka\\nnakata\\ntanaka\\n1\\n1\\nfoo\\n5\\n2\\npsqt\\nabcdef\\nabzdefa\\npqrst\\nabdxcef\\n0\", \"8\\n2\\nomura\\ntoshio\\nraku\\nt`naka\\nioura\\nyoshoi\\nhayashi\\nmiura\\n3\\n1\\ntasaka\\nnakata\\ntanaka\... | Meikyokan University is very famous for its research and education in the area of computer science. This university has a computer center that has advanced and secure computing facilities including supercomputers and many personal computers connected to the Internet.
One of the policies of the computer center is to le... | 0 |
{"tests": "{\"inputs\": [\"9 9 1\\n1 2\\n1 3\\n2 3\\n1 5\\n5 6\\n6 1\\n1 8\\n9 8\\n7 1\\n\", \"5 4 5\\n1 2\\n2 3\\n3 4\\n4 1\\n\", \"5000 0 2956\\n\", \"2 0 2\\n\", \"2 1 1\\n1 2\\n\", \"2 1 2\\n1 2\\n\", \"2 2 2\\n1 2\\n2 1\\n\", \"5000 2 238\\n3212 238\\n238 3212\\n\", \"5000 2 3810\\n3225 1137\\n1137 3225\\n\", \"10... | There are $n$ cities and $m$ roads in Berland. Each road connects a pair of cities. The roads in Berland are one-way.
What is the minimum number of new roads that need to be built to make all the cities reachable from the capital?
New roads will also be one-way.
-----Input-----
The first line of input consists of ... | 0 |
{"tests": "{\"inputs\": [\"1 3\\n3 4\\n3 5\\n3 6\\n4 6\\n4 7\\n4 7\\n5 6\\n6 7\\n5 8\\n5 8\\n3 8\\n6 9\\n7 9\\n8 9\\n9 2\\n0 0\\n1 3\\n3 4\\n3 4\\n4 2\\n0 0\", \"1 3\\n3 4\\n3 5\\n3 6\\n4 6\\n4 7\\n4 7\\n5 6\\n6 7\\n5 8\\n1 8\\n3 8\\n6 9\\n7 9\\n8 9\\n9 2\\n0 0\\n1 3\\n3 4\\n3 4\\n4 2\\n1 0\", \"1 3\\n3 4\\n3 5\\n3 6\\... | In 1862, the lord of Aizu was ordered to serve as a guardian of Kyoto. The Kyoto Shugoshoku is an important role to protect Kyoto at the end of the Edo period when security has deteriorated. You have to patrol the city by sharing it with the shogunate and other clan. However, when it came time to decide the sharing rou... | 0 |
{"tests": "{\"inputs\": [[1, 2, 3], [5.5, 4.5, 10], [7, 3, 2], [5, 10, 5], [3, 3, 0], [3, 3, 1], [5, 5, 5], [122.14, 222.11, 250], [8, 5, 7], [100000, 100005, 111111], [3, 4, 5], [21, 220, 221], [8.625, 33.625, 32.5], [65, 56, 33], [68000, 285000, 293000], [2, 4, 5], [105, 100, 6], [102, 200, 250], [65, 55, 33], [7, 8,... | In this kata, you should calculate type of triangle with three given sides ``a``, ``b`` and ``c`` (given in any order).
If all angles are less than ``90°``, this triangle is ``acute`` and function should return ``1``.
If one angle is strictly ``90°``, this triangle is ``right`` and function should return ``2``.
If o... | 0 |
{"tests": "{\"inputs\": [[\"74/3\"], [\"9999/24\"], [\"74/30\"], [\"13/5\"], [\"5/3\"], [\"1/1\"], [\"10/10\"], [\"900/10\"], [\"9920/124\"], [\"6/2\"], [\"9/77\"], [\"96/100\"], [\"12/18\"], [\"6/36\"], [\"1/18\"], [\"-64/8\"], [\"-6/8\"], [\"-9/78\"], [\"-504/26\"], [\"-47/2\"], [\"-21511/21\"]], \"outputs\": [[\"24 ... | In Math, an improper fraction is a fraction where the numerator (the top number) is greater than or equal to the denominator (the bottom number) For example: ```5/3``` (five third).
A mixed numeral is a whole number and a fraction combined into one "mixed" number. For example: ```1 1/2``` (one and a half) is a mixed n... | 0.625 |
{"tests": "{\"inputs\": [\"6 3 1\\n\", \"100 1 2\\n\", \"6 3 2\\n\", \"60 34 30\\n\", \"8 4 1\\n\", \"100 100 100\\n\", \"100 51 100\\n\", \"60 31 29\\n\", \"100 18 82\\n\", \"100 52 50\\n\", \"100 51 51\\n\", \"8 4 4\\n\", \"4 2 2\\n\", \"100 19 99\\n\", \"2 1 1\\n\", \"6 3 3\\n\", \"6 4 4\\n\", \"100 1 8\\n\", \"4 3 ... | Little Petya loves playing with squares. Mum bought him a square 2n × 2n in size. Petya marked a cell inside the square and now he is solving the following task.
The task is to draw a broken line that would go along the grid lines and that would cut the square into two equal parts. The cutting line should not have any... | 0 |
{"tests": "{\"inputs\": [\"2\\nP 1\\nP 2\\n2\\nP 2\\nM -2\\n0\", \"2\\nP 1\\nP 2\\n\\n2\\nP 0\\nM -2\\n\\n0\", \"2\\nP 1\\nP 4\\n\\n2\\nP 0\\nM -2\\n\\n0\", \"2\\nQ 1\\nP 4\\n\\n2\\nP -1\\nM -2\\n\\n0\", \"2\\nQ 1\\nP 4\\n\\n2\\nP -1\\nM -3\\n\\n0\", \"2\\nQ 2\\nP 4\\n\\n0\\nP 0\\nM -2\\n\\n0\", \"2\\nQ 2\\nP 8\\n\\n2\... | Did you ever hear about 'crossing the bridge noodle' ? Let me tell you that it's not some kind of bridge made of noodles. It's a dish, a kind of rice noodle soup. Mr.Ping makes the best noodle soup and his son Po is eagerly waiting for the user reviews in his father's blog. Users can vote with a (+) or a (-) and accord... | 0 |
{"tests": "{\"inputs\": [[153, 8], [255, 8], [256, 8], [1534, 32], [364334, 32], [2, 64], [164345, 64], [23, 128], [256245645346, 128], [6423, 256], [988847589347589798345, 256], [98, 512], [9827498275894278943758934789347, 512], [111, 1024], [859983475894789589772983457982345896389458937589738945435, 1024], [983458734... | In computing, there are two primary byte order formats: big-endian and little-endian. Big-endian is used primarily for networking (e.g., IP addresses are transmitted in big-endian) whereas little-endian is used mainly by computers with microprocessors.
Here is an example (using 32-bit integers in hex format):
Little-... | 0.25 |
{"tests": "{\"inputs\": [[\"\"], [{}], [\"abc\"], [\"2d6+3 abc\"], [\"abc 2d6+3\"], [\"2d6++4\"]], \"outputs\": [[false], [false], [false], [false], [false], [false]]}", "source": "taco"} | # The die is cast!
Your task in this kata is to write a "dice roller" that interprets a subset of [dice notation](http://en.wikipedia.org/wiki/Dice_notation).
# Description
In most role-playing games, die rolls required by the system are given in the form `AdX`. `A` and `X` are variables, separated by the letter **d... | 0.5 |
{"tests": "{\"inputs\": [\"3\\n\", \"4\\n\", \"100\\n\", \"5\\n\", \"6\\n\", \"11\\n\", \"18\\n\", \"26\\n\", \"50\\n\", \"90\\n\", \"97\\n\", \"98\\n\", \"99\\n\", \"5\", \"6\", \"8\", \"15\", \"12\", \"9\", \"14\", \"7\", \"13\", \"20\", \"10\", \"11\", \"24\", \"26\", \"23\", \"16\", \"25\", \"28\", \"41\", \"36\", ... | You are given an integer N. Find the number of strings of length N that satisfy the following conditions, modulo 10^9+7:
- The string does not contain characters other than A, C, G and T.
- The string does not contain AGC as a substring.
- The condition above cannot be violated by swapping two adjacent characters on... | 0 |
{"tests": "{\"inputs\": [\"6\\n9 english\\n6 mathematics\\n8 geography\\n-1\\n3 graphics\\n-1\", \"6\\n9 english\\n6 mathematics\\n14 geography\\n-1\\n3 graphics\\n-1\", \"6\\n9 english\\n9 lathematics\\n14 reoggaphy\\n-1\\n3 graphics\\n-1\", \"6\\n9 english\\n9 lathematics\\n14 reoggaphy\\n-1\\n3 scihparg\\n-1\", \"6\... | Harry is a bright student. To prepare thoroughly for exams, he completes all the exercises in his book! Now that the exams are approaching fast, he is doing book exercises day and night. He writes down and keeps updating the remaining number of exercises on the back cover of each book.
Harry has a lot of books messed o... | 0 |
{"tests": "{\"inputs\": [\"8\\n1 2 3\\n123 321 456\\n5 10 15\\n15 18 21\\n100 100 101\\n1 22 29\\n3 19 38\\n6 30 46\\n\", \"1\\n137 10000 10000\\n\", \"1\\n1 137 10000\\n\", \"1\\n73 10000 10000\\n\", \"1\\n1667 3334 10000\\n\", \"1\\n256 4096 10000\\n\", \"1\\n1 1667 10000\\n\", \"2\\n1 137 10000\\n1 1429 10000\\n\", ... | You are given three integers $a \le b \le c$.
In one move, you can add $+1$ or $-1$ to any of these integers (i.e. increase or decrease any number by one). You can perform such operation any (possibly, zero) number of times, you can even perform this operation several times with one number. Note that you cannot make n... | 0 |
{"tests": "{\"inputs\": [\"2 5\\n0 1 0 1 0\\n1 0 0 0 1\\n3 6\\n1 0 1 0 1 0\\n1 1 1 0 1 0\\n1 0 1 1 0 1\\n0 0\", \"2 5\\n0 1 1 1 0\\n1 0 0 0 1\\n3 6\\n1 0 0 0 1 0\\n1 1 1 0 1 0\\n1 0 1 1 0 1\\n0 0\", \"2 5\\n0 1 0 1 0\\n1 0 0 0 1\\n3 6\\n1 0 0 0 1 1\\n1 1 1 0 1 0\\n1 0 1 1 0 1\\n0 0\", \"2 5\\n1 1 1 1 0\\n1 0 0 1 1\\n3 ... | problem
At IOI Confectionery, rice crackers are baked using the traditional method since the company was founded. This traditional method is to bake the front side for a certain period of time with charcoal, turn it over when the front side is baked, and bake the back side for a certain period of time with charcoal. W... | 0.625 |
{"tests": "{\"inputs\": [\"5\\n1 2 3 5 4\\n1 5 3 2 4\\n\", \"5\\n1 4 3 2 5\\n-3 4 -10 2 7\\n\", \"2\\n2 1\\n-2 -3\\n\", \"10\\n4 7 3 2 5 1 9 10 6 8\\n-4 40 -46 -8 -16 4 -10 41 12 3\\n\", \"25\\n12 13 15 20 24 16 7 10 3 2 14 23 18 8 21 5 6 4 1 11 19 9 22 25 17\\n-2 -46 -23 -13 -46 -9 -5 -4 -10 -40 -36 -31 -45 -50 -47 -2... | Alice is visiting New York City. To make the trip fun, Alice will take photos of the city skyline and give the set of photos as a present to Bob. However, she wants to find the set of photos with maximum beauty and she needs your help.
There are $n$ buildings in the city, the $i$-th of them has positive height $h_i$. ... | 0.125 |
{"tests": "{\"inputs\": [[2], [3], [4], [5], [6], [7], [8], [9], [10], [20], [30], [40], [50], [11], [24], [37], [19], [48], [59], [65], [73], [83], [64], [99], [100], [10000], [1500], [1534], [1978], [2763], [9999], [2673], [4578], [9876], [2659], [7777], [9364], [7280], [4998], [9283], [8234], [7622], [800], [782], [... | # Summary:
Given a number, `num`, return the shortest amount of `steps` it would take from 1, to land exactly on that number.
# Description:
A `step` is defined as either:
- Adding 1 to the number: `num += 1`
- Doubling the number: `num *= 2`
You will always start from the number `1` and you will have to return the s... | 0 |
{"tests": "{\"inputs\": [\"3\\n1 -1\\n-1 4\\n-1 6\\n\", \"2\\n1 4\\n2 3\\n\", \"2\\n4 1\\n2 4\\n\", \"2\\n3 -1\\n-1 2\\n\", \"6\\n6 10\\n5 9\\n1 2\\n11 12\\n4 8\\n3 7\\n\", \"1\\n1 2\\n\", \"98\\n17 49\\n139 171\\n-1 114\\n147 179\\n26 58\\n-1 50\\n11 43\\n1 2\\n74 106\\n134 166\\n157 189\\n67 99\\n33 -1\\n155 187\\n25... | There is a building with 2N floors, numbered 1, 2, \ldots, 2N from bottom to top.
The elevator in this building moved from Floor 1 to Floor 2N just once.
On the way, N persons got on and off the elevator. Each person i (1 \leq i \leq N) got on at Floor A_i and off at Floor B_i. Here, 1 \leq A_i < B_i \leq 2N, and just ... | 0 |
{"tests": "{\"inputs\": [\"7\\n6 4\\n4 2\\n3 5\\n7 1\\n2 7\\n5 3\\n1 6\", \"4\\n2 4\\n1 3\\n3 1\\n4 2\", \"4\\n2 4\\n1 3\\n3 2\\n4 1\", \"4\\n1 4\\n2 3\\n3 2\\n4 1\", \"4\\n1 4\\n2 2\\n3 1\\n4 3\", \"4\\n2 4\\n1 2\\n3 1\\n4 3\", \"7\\n6 4\\n4 3\\n3 5\\n7 1\\n2 6\\n5 2\\n1 7\", \"4\\n2 4\\n1 3\\n3 1\\n4 2\", \"4\\n2 4\\... | There are N cities on a 2D plane. The coordinate of the i-th city is (x_i, y_i). Here (x_1, x_2, \dots, x_N) and (y_1, y_2, \dots, y_N) are both permuations of (1, 2, \dots, N).
For each k = 1,2,\dots,N, find the answer to the following question:
Rng is in City k. Rng can perform the following move arbitrarily many t... | 0 |
{"tests": "{\"inputs\": [\"4\\n1 2 3\\n10 20 30\\n10\\n1 2 2 1 5 5 1 8 8\\n10 1 1 20 2 1 30 1 1\\n3\\n1 1\\n1 1\\n0\", \"4\\n1 2 3\\n10 20 30\\n10\\n1 2 2 1 5 5 1 8 8\\n10 1 1 20 1 1 0 1 1\\n3\\n1 1\\n1 1\\n0\", \"4\\n1 2 3\\n10 20 30\\n10\\n1 2 2 1 5 5 1 8 8\\n10 2 1 20 2 1 30 1 1\\n3\\n1 1\\n1 1\\n0\", \"4\\n1 2 3\\n... | Bridge Removal
ICPC islands once had been a popular tourist destination. For nature preservation, however, the government decided to prohibit entrance to the islands, and to remove all the man-made structures there. The hardest part of the project is to remove all the bridges connecting the islands.
There are n islan... | 0 |
{"tests": "{\"inputs\": [[null, 0], [\"\", 0], [\"This is a test!\", 0], [\"This is a test!\", 1], [\"This is a test!\", 3], [\"This is a test!\", 4], [\"This is a test!\", -1], [\"This is a test!\", -5], [\"Brrrr\", 99], [\"AEIOUaeiou\", 1]], \"outputs\": [[null], [\"\"], [\"This is a test!\"], [\"Thes is i tast!\"], ... | You get a "text" and have to shift the vowels by "n" positions to the right.
(Negative value for n should shift to the left.)
"Position" means the vowel's position if taken as one item in a list of all vowels within the string.
A shift by 1 would mean, that every vowel shifts to the place of the next vowel.
Shifting ov... | 0 |
{"tests": "{\"inputs\": [\"7 2\\n1 2\\n1 3\\n1 4\\n3 5\\n3 6\\n3 7\\n2 7\\n\", \"6 4\\n1 2\\n2 3\\n2 4\\n4 5\\n4 6\\n2 4 5 6\\n\", \"2 1\\n2 1\\n1\\n\", \"1 1\\n1\\n\", \"10 2\\n6 9\\n6 2\\n1 6\\n4 10\\n3 7\\n9 4\\n9 5\\n6 7\\n2 8\\n7 6\\n\", \"15 2\\n7 12\\n13 11\\n6 8\\n2 15\\n10 9\\n5 1\\n13 5\\n5 4\\n14 3\\n8 9\\n8... | Ari the monster is not an ordinary monster. She is the hidden identity of Super M, the Byteforces’ superhero. Byteforces is a country that consists of n cities, connected by n - 1 bidirectional roads. Every road connects exactly two distinct cities, and the whole road system is designed in a way that one is able to go ... | 0 |
{"tests": "{\"inputs\": [\"3\\n1 4 6\\n\", \"4\\n2 3 6 6\\n\", \"3\\n6 15 10\\n\", \"4\\n2 3 5 7\\n\", \"6\\n10 8 75 6 7 35\\n\", \"1\\n1\\n\", \"2\\n1 1\\n\", \"2\\n8 32\\n\", \"1\\n97969\\n\", \"2\\n313 313\\n\", \"2\\n97969 97969\\n\", \"8\\n6 15 35 77 143 221 34 26\\n\", \"1\\n998\\n\", \"3\\n2 2 2\\n\", \"2\\n313 ... | You are given an array $a$ of length $n$ that has a special condition: every element in this array has at most 7 divisors. Find the length of the shortest non-empty subsequence of this array product of whose elements is a perfect square.
A sequence $a$ is a subsequence of an array $b$ if $a$ can be obtained from $b$ b... | 0.25 |
{"tests": "{\"inputs\": [\"5 3 6 9\\n9 1 5 3 1\", \"21 10 0 4\\n5 2 13 -1 0\", \"21 7 1 4\\n0 2 23 -1 2\", \"9 3 1 9\\n22 2 6 2 0\", \"21 14 1 4\\n2 2 0 -1 2\", \"5 3 6 9\\n9 1 6 3 1\", \"8 3 6 9\\n9 1 6 3 1\", \"8 3 6 9\\n15 1 6 3 1\", \"8 3 6 9\\n15 0 6 3 1\", \"8 3 6 9\\n22 0 6 3 1\", \"11 3 6 9\\n22 0 6 3 1\", \"11... | Problem statement
AOR Ika got a cabbage with $ N $ leaves. The leaves of this cabbage are numbered $ 1, \ ldots, N $ in order from the outside, and the dirtiness of the $ i $ th leaf is $ D_i $. The larger this value is, the worse the degree of dirt is. AOR Ika-chan decided to use the cabbage leaves for cooking, so sh... | 0 |
{"tests": "{\"inputs\": [[\"hello world!\", \" |\"], [\"hello world!\", \"o|rl\"], [\"hello world!\", \"ello| \"], [\"hello world!\", \"hello wo|rld!\"], [\"hello world!\", \"h|ello world!\"], [\"hello world! hello world!\", \" |\"], [\"hello world! hello world!\", \"o|rl\"], [\"hello world! hello world!\", \"ello| \"]... | Most languages have a `split` function that lets you turn a string like `“hello world”` into an array like`[“hello”, “world”]`. But what if we don't want to lose the separator? Something like `[“hello”, “ world”]`.
#### Task:
Your job is to implement a function, (`split_without_loss` in Ruby/Crystal, and `splitWithou... | 0 |
{"tests": "{\"inputs\": [[[2, 10, 9, 3]], [[3, 4, 5, 7]], [[0, 2, 19, 4, 4]], [[3, 2, 1, 0]], [[3, 2, 10, 4, 1, 6]], [[1, 1, 8, 3, 1, 1]], [[0, 1, 2, 3]], [[1, 2, 3, 4]], [[0, -1, 1]], [[0, 2, 3]], [[0]], [[]], [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], [[0, 1, 3, -2, 5, 4]], [[0, -1, -2, -3, -4]], [[1, -1, 3]], [[1, -1, 2, -2,... | A `Nice array` is defined to be an array where for every value `n` in the array, there is also an element `n-1` or `n+1` in the array.
example:
```
[2,10,9,3] is Nice array because
2=3-1
10=9+1
3=2+1
9=10-1
```
Write a function named `isNice`/`IsNice` that returns `true` if its array argument is a Nice array, else `... | 0 |
{"tests": "{\"inputs\": [[1, [0, 0]], [2, [1, 0]], [2, [1, 1]], [3, [1, 0]], [5, [4, 0]], [6, [5, 0]], [7, [6, 0]]], \"outputs\": [[0], [2], [1], [3], [70], [252], [924]]}", "source": "taco"} | Happy traveller [Part 1]
There is a play grid NxN; Always square!
0 1 2 3
0 [o, o, o, X]
1 [o, o, o, o]
2 [o, o, o, o]
3 [o, o, o, o]
You start from a random point. I mean, you are given the coordinates of your start position in format (row, col).
And your TASK is to define the number of unique paths to re... | 0 |
{"tests": "{\"inputs\": [\"1\\n1\\n\", \"20\\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2\\n\", \"1\\n1000000000000\\n\", \"96\\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 8 8 8 8 8 8 8 8 8 8 8 9 12 12 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 1... | It can be shown that any positive integer x can be uniquely represented as x = 1 + 2 + 4 + ... + 2k - 1 + r, where k and r are integers, k ≥ 0, 0 < r ≤ 2k. Let's call that representation prairie partition of x.
For example, the prairie partitions of 12, 17, 7 and 1 are:
12 = 1 + 2 + 4 + 5,
17 = 1 + 2 + 4 + 8 + 2,
... | 0 |
{"tests": "{\"inputs\": [\"6\\n12345\\n54321\\n10901\\n211011\\n7\\n90\", \"6\\n12345\\n43634\\n10901\\n211011\\n7\\n90\", \"6\\n12345\\n43634\\n21427\\n211011\\n7\\n90\", \"6\\n12345\\n43634\\n21427\\n211011\\n7\\n166\", \"6\\n23325\\n43634\\n21427\\n211011\\n7\\n166\", \"6\\n23325\\n43634\\n21427\\n211011\\n1\\n166\"... | For any positive integer, we define a digit rotation as either moving the first digit
to the end of the number (left digit rotation), or the last digit to the front of the number (right digit rotation).
For example, the number 12345 could be left digit rotated to 23451, or right digit rotated to 51234.
If there are any... | 0 |
{"tests": "{\"inputs\": [[0, 1], [1, 2], [5, -1], [505, 4], [321, 123], [0, -1], [-50, 0], [-1, -5], [-5, -5], [-505, 4], [-321, 123], [0, 0], [-5, -1], [5, 1], [-17, -17], [17, 17]], \"outputs\": [[1], [3], [14], [127759], [44178], [-1], [-1275], [-15], [-5], [-127755], [-44055], [0], [-15], [15], [-17], [17]]}", "sou... | Given two integers `a` and `b`, which can be positive or negative, find the sum of all the numbers between including them too and return it. If the two numbers are equal return `a` or `b`.
**Note:** `a` and `b` are not ordered!
## Examples
```python
get_sum(1, 0) == 1 // 1 + 0 = 1
get_sum(1, 2) == 3 // 1 + 2 = 3... | 0 |
{"tests": "{\"inputs\": [[[0, 0], [1, 1]], [[2, 6], [-2, -6]], [[10, -10], [-10, 10]], [[1, -35], [-12, 1]], [[1000, 15], [-7, -214]], [[0, 0], [0, 0]]], \"outputs\": [[[2, 2]], [[-6, -18]], [[-30, 30]], [[-25, 37]], [[-1014, -443]], [[0, 0]]]}", "source": "taco"} | "Point reflection" or "point symmetry" is a basic concept in geometry where a given point, P, at a given position relative to a mid-point, Q has a corresponding point, P1, which is the same distance from Q but in the opposite direction.
## Task
Given two points P and Q, output the symmetric point of point P about Q.
... | 0 |
{"tests": "{\"inputs\": [\"10\\n10 8\\n3 2\\n9 7\\n1 5\\n5 3\\n7 6\\n8 4\\n10 9\\n2 6\\nqbilfkqcll\\n\", \"20\\n10 9\\n15 14\\n11 12\\n2 3\\n15 16\\n2 1\\n18 19\\n20 19\\n8 9\\n7 6\\n8 7\\n12 13\\n5 6\\n4 3\\n13 14\\n18 17\\n11 10\\n16 17\\n5 4\\naabbccddeeffgghhiijj\\n\", \"5\\n3 1\\n3 5\\n5 4\\n5 2\\nticdm\\n\", \"10... | You are given a tree (a connected acyclic undirected graph) of n vertices. Vertices are numbered from 1 to n and each vertex is assigned a character from a to t.
A path in the tree is said to be palindromic if at least one permutation of the labels in the path is a palindrome.
For each vertex, output the number of pa... | 0 |
{"tests": "{\"inputs\": [\"5\\n3 4\\n3 2\\n3 1\\n13 7\\n1010000 9999999\\n\", \"1\\n1 1\\n\", \"1\\n632934461 955818012\\n\", \"1\\n632934461 955818012\\n\", \"1\\n1 1\\n\", \"1\\n632934461 286939621\\n\", \"1\\n1 2\\n\", \"5\\n3 4\\n3 2\\n3 1\\n13 7\\n1010000 14106652\\n\", \"1\\n632934461 107730378\\n\", \"1\\n2 2\\n... | A competitive eater, Alice is scheduling some practices for an eating contest on a magical calendar. The calendar is unusual because a week contains not necessarily $7$ days!
In detail, she can choose any integer $k$ which satisfies $1 \leq k \leq r$, and set $k$ days as the number of days in a week.
Alice is going t... | 0 |
{"tests": "{\"inputs\": [\"4\\n1 1\\n1 2\\n2 1\\n2 2\\n\", \"2\\n-1 -1\\n0 1\\n\", \"1\\n0 0\\n\", \"9\\n1 1\\n2 2\\n3 3\\n1 2\\n2 1\\n3 1\\n1 3\\n3 2\\n2 3\\n\", \"10\\n504155727 -77293021\\n-155983273 -43296260\\n-548837441 -43296260\\n88335251 -77293021\\n970294418 -43296260\\n-155983273 850521645\\n-852404258 -7729... | You are given n distinct points on a plane with integral coordinates. For each point you can either draw a vertical line through it, draw a horizontal line through it, or do nothing.
You consider several coinciding straight lines as a single one. How many distinct pictures you can get? Print the answer modulo 10^9 + 7... | 0 |
{"tests": "{\"inputs\": [\"5 4\\n2 4 8 2 4\\n8\\n5\\n14\\n10\\n\", \"3 3\\n1 1 1\\n1\\n2\\n3\\n\", \"4 1\\n2 4 16 32\\n14\\n\", \"1 10\\n8\\n1\\n2\\n3\\n4\\n5\\n6\\n7\\n8\\n9\\n16\\n\", \"1 10\\n4\\n1\\n2\\n3\\n4\\n5\\n6\\n7\\n8\\n9\\n16\\n\", \"1 10\\n2\\n1\\n2\\n3\\n4\\n5\\n6\\n7\\n8\\n9\\n16\\n\", \"1 10\\n1\\n1\\n2... | Polycarp has $n$ coins, the value of the $i$-th coin is $a_i$. It is guaranteed that all the values are integer powers of $2$ (i.e. $a_i = 2^d$ for some non-negative integer number $d$).
Polycarp wants to know answers on $q$ queries. The $j$-th query is described as integer number $b_j$. The answer to the query is the... | 0 |
{"tests": "{\"inputs\": [\"4 40 6\\n92 21 82 46\\n3 56\\n1 72\\n4 28\\n1 97\\n3 49\\n2 88\\n\", \"5 1 5\\n3 5 1 4 2\\n1 9\\n2 4\\n3 6\\n4 7\\n5 2\\n\", \"4 40 6\\n92 21 82 40\\n3 56\\n1 72\\n4 28\\n1 97\\n3 49\\n2 88\\n\", \"5 1 5\\n3 5 1 4 2\\n1 9\\n2 4\\n3 6\\n5 7\\n5 2\\n\", \"4 40 6\\n92 17 82 40\\n3 56\\n1 72\\n4 ... | There are n cells, numbered 1,2,..., n from left to right. You have to place a robot at any cell initially. The robot must make exactly k moves.
In one move, the robot must move one cell to the left or right, provided that it doesn't move out of bounds. In other words, if the robot was in the cell i, it must move to e... | 0 |
{"tests": "{\"inputs\": [\"1\\n10\\n7 7 7 7 7 7 7 7 7 7\\n\", \"1\\n12\\n1 1 1 1 1 6 6 6 6 6 6 7\\n\", \"1\\n10\\n7 7 7 7 7 7 2 7 7 7\\n\", \"3\\n4\\n2 1 4 18\\n6\\n1 2 3 4 5 6\\n5\\n11 19 1 1 3\\n\", \"3\\n4\\n2 1 4 4\\n6\\n1 1 3 4 5 6\\n5\\n11 8 1 1 3\\n\", \"3\\n4\\n3 1 4 4\\n6\\n1 1 3 4 5 6\\n5\\n8 8 1 1 1\\n\", \"... | You are given an array a consisting of n positive integers, numbered from 1 to n. You can perform the following operation no more than 3n times:
1. choose three integers i, j and x (1 ≤ i, j ≤ n; 0 ≤ x ≤ 10^9);
2. assign a_i := a_i - x ⋅ i, a_j := a_j + x ⋅ i.
After each operation, all elements of the array s... | 0 |
{"tests": "{\"inputs\": [\"1\\n2 3\\nRRGG\\nGGRB\\nBRRR\\nBRRR\", \"2\\n4 5\\n1 1\\nRRRR\\nRRGR\\nRBRR\\nRRRR\", \"2\\n4 5\\n2 1\\nRRRR\\nRRGR\\nRBRR\\nRRRR\", \"1\\n2 1\\nRRGG\\nGGRB\\nBRRR\\nBRRR\", \"1\\n2 1\\nGGRR\\nGGRB\\nBRRR\\nBRRR\", \"1\\n1 1\\nGGRR\\nGGRB\\nBRRR\\nBRRR\", \"1\\n2 3\\nRRGG\\nGGRB\\nBRRR\\nRRBR... | Training is indispensable for achieving good results at ICPC. Rabbit wants to win at ICPC, so he decided to practice today as well.
Today's training is to increase creativity by drawing pictures. Let's draw a pattern well using a square stamp.
I want to use stamps of various sizes to complete the picture of the red, ... | 0 |
{"tests": "{\"inputs\": [[\"aa_bb_cc_dd_bb_e\", \"bb\"], [\"aaabbbcccc\", \"bbb\"], [\"aaacccbbbcccc\", \"cc\"], [\"aaa\", \"aa\"], [\"aaa\", \"aa\", false], [\"aaabbbaaa\", \"bb\", false], [\"a\", \"\"], [\"\", \"a\"], [\"\", \"\"], [\"\", \"\", false]], \"outputs\": [[2], [1], [5], [2], [1], [1], [0], [0], [0], [0]]}... | Complete the solution so that it returns the number of times the search_text is found within the full_text.
```python
search_substr( fullText, searchText, allowOverlap = true )
```
so that overlapping solutions are (not) counted. If the searchText is empty, it should return `0`. Usage examples:
```python
search_subs... | 0 |
{"tests": "{\"inputs\": [\"82\\n\", \"720\\n\", \"1239\\n\", \"9999\\n\", \"4938\\n\", \"9562\\n\", \"6143\\n\", \"7274\\n\", \"30\\n\", \"3112\\n\", \"28\\n\", \"8865\\n\", \"5\\n\", \"2023\\n\", \"1936\\n\", \"9998\\n\", \"9798\\n\", \"4999\\n\", \"1\\n\", \"513\\n\", \"9146\\n\", \"9648\\n\", \"9409\\n\", \"1521\\n\... | Vladik and Chloe decided to determine who of them is better at math. Vladik claimed that for any positive integer n he can represent fraction <image> as a sum of three distinct positive fractions in form <image>.
Help Vladik with that, i.e for a given n find three distinct positive integers x, y and z such that <image... | 0.125 |
{"tests": "{\"inputs\": [\"(()((\\n\", \")(\\n\", \"(()())\\n\", \"()\\n\", \"()()()()()()()(\\n\", \"()\\n\", \"())((\\n\", \"))()((\\n\", \"(())(\\n\", \")))(((\\n\", \"(()()(\\n\", \"()))((\\n\", \"()(()(\\n\", \"((()()))()()()(\\n\", \"()(((\\n\", \"(())))\\n\", \"()()()()))()(((\\n\", \"()()()())(()(((\\n\", \")()... | Now that Kuroni has reached 10 years old, he is a big boy and doesn't like arrays of integers as presents anymore. This year he wants a Bracket sequence as a Birthday present. More specifically, he wants a bracket sequence so complex that no matter how hard he tries, he will not be able to remove a simple subsequence!
... | 0 |
{"tests": "{\"inputs\": [\"1 2 3 4 5 6\\n3\\n4 5\\n1 3\\n3 2\", \"1 2 3 4 5 6\\n3\\n4 5\\n1 3\\n6 2\", \"1 2 3 4 5 6\\n3\\n4 5\\n2 3\\n6 2\", \"1 2 3 4 5 6\\n3\\n6 5\\n2 3\\n6 2\", \"1 2 3 4 5 6\\n3\\n6 3\\n1 3\\n3 2\", \"1 2 3 4 5 6\\n3\\n4 2\\n1 3\\n3 2\", \"1 2 3 4 5 6\\n3\\n4 5\\n2 3\\n4 2\", \"1 2 3 4 5 6\\n3\\n6 ... | Construct a dice from a given sequence of integers in the same way as Dice I.
You are given integers on the top face and the front face after the dice was rolled in the same way as Dice I. Write a program to print an integer on the right side face.
<image>
Constraints
* $0 \leq $ the integer assigned to a face $ ... | 0 |
{"tests": "{\"inputs\": [\"8 1 1\\n\", \"8 1 10\\n\", \"10 62 99\\n\", \"88 417 591\\n\", \"57 5289 8444\\n\", \"382 81437847 324871127\\n\", \"244 575154303 436759189\\n\", \"85 902510038 553915152\\n\", \"1926 84641582 820814219\\n\", \"3768 561740421 232937477\\n\", \"2313 184063453 204869248\\n\", \"35896 278270961... | zscoder wants to generate an input file for some programming competition problem.
His input is a string consisting of n letters 'a'. He is too lazy to write a generator so he will manually generate the input in a text editor.
Initially, the text editor is empty. It takes him x seconds to insert or delete a letter 'a'... | 0 |
{"tests": "{\"inputs\": [\"14 9\\n5 5 6 8 8 4 3 2 2 7 3 9 5 4\\n\", \"14 11\\n10 8 6 1 7 2 9 5 5 10 3 5 11 3\\n\", \"1 1\\n1\\n\", \"3 3\\n2 2 2\\n\", \"10 4\\n1 4 2 3 1 3 3 4 1 3\\n\", \"3 4\\n1 2 4\\n\", \"10 5\\n2 2 4 4 3 1 1 2 3 2\\n\", \"19 5\\n1 1 2 2 2 2 3 3 3 3 3 3 3 4 4 4 4 5 5\\n\", \"2 2\\n1 2\\n\", \"3 4\\n... | You are playing a game of Jongmah. You don't need to know the rules to solve this problem. You have n tiles in your hand. Each tile has an integer between 1 and m written on it.
To win the game, you will need to form some number of triples. Each triple consists of three tiles, such that the numbers written on the tile... | 0 |
{"tests": "{\"inputs\": [\"1\\n\", \"4\\n\", \"3\\n\", \"8\\n\", \"10\\n\", \"100000000000000000\\n\", \"99999999999999999\\n\", \"50031545098999707\\n\", \"16677181699666569\\n\", \"72900000000000\\n\", \"99999999999999997\\n\", \"58061299250691018\\n\", \"49664023559436051\\n\", \"66708726798666276\\n\", \"2944243188... | Gerald has been selling state secrets at leisure. All the secrets cost the same: n marks. The state which secrets Gerald is selling, has no paper money, only coins. But there are coins of all positive integer denominations that are powers of three: 1 mark, 3 marks, 9 marks, 27 marks and so on. There are no coins of oth... | 0 |
{"tests": "{\"inputs\": [\"3\\n2\\n6\\n10\", \"3\\n2\\n4\\n10\", \"3\\n2\\n6\\n12\", \"3\\n4\\n6\\n12\", \"3\\n4\\n6\\n19\", \"3\\n2\\n4\\n19\", \"3\\n2\\n3\\n12\", \"3\\n4\\n11\\n12\", \"3\\n4\\n5\\n19\", \"3\\n2\\n2\\n19\", \"3\\n2\\n3\\n21\", \"3\\n4\\n7\\n19\", \"3\\n2\\n2\\n23\", \"3\\n2\\n3\\n7\", \"3\\n4\\n7\\n1... | Recently Johnny have learned bogosort sorting algorithm. He thought that it is too ineffective. So he decided to improve it. As you may know this algorithm shuffles the sequence randomly until it is sorted. Johnny decided that we don't need to shuffle the whole sequence every time. If after the last shuffle several fir... | 0 |
{"tests": "{\"inputs\": [[100, 200, 10], [123, 456, 5], [99, 501, 5], [99, 234, 1], [99, 234, 19], [99, 5001, 27], [99, 5001, 28], [2000, 7000, 3]], \"outputs\": [[[109, 190]], [[131, 410]], [[104, 500]], [[100, 100]], [[199, 199]], [[999, 4995]], [[1999, 4996]], [[2001, 3000]]]}", "source": "taco"} | # Task
You are given three integers `l, d and x`. Your task is:
```
• determine the minimal integer n
such that l ≤ n ≤ d, and the sum of its digits equals x.
• determine the maximal integer m
such that l ≤ m ≤ d, and the sum of its digits equals x.
```
It is guaranteed that such numbers always exist.
# Inp... | 0.875 |
{"tests": "{\"inputs\": [\"4 3\\naaa\\nbbb\\nccb\\nddd\\n\", \"6 1\\na\\na\\nb\\nb\\nc\\nc\\n\", \"1 1\\na\\n\", \"10 10\\naaaaarpppp\\nbbbbsssssu\\ncciiiiiiqq\\nddmmgggggg\\neeebbbbbbb\\nfffffqoooo\\ngxxxxrrrrr\\nhhfuuuuuuu\\niiillqqqqq\\njjjjjppwww\\n\", \"10 10\\naaaaaaaaaa\\nbbbbbbbbbb\\ncccccccccc\\ndddddddddd\\ne... | Innokenty works at a flea market and sells some random stuff rare items. Recently he found an old rectangular blanket. It turned out that the blanket is split in $n \cdot m$ colored pieces that form a rectangle with $n$ rows and $m$ columns.
The colored pieces attracted Innokenty's attention so he immediately came up... | 0 |
{"tests": "{\"inputs\": [\"6 5\\n1 2 200 10\\n1 4 400 15\\n1 3 250 25\\n2 4 100 10\\n4 5 150 20\\n3 5 300 30\\n2\\n1 5 0\\n1 5 1\\n0 0\", \"6 5\\n1 2 200 10\\n1 4 400 22\\n1 3 250 25\\n2 4 100 10\\n4 5 150 20\\n3 3 300 30\\n2\\n1 5 0\\n1 5 1\\n0 0\", \"6 5\\n1 2 200 10\\n1 4 158 22\\n1 3 250 25\\n2 4 100 10\\n4 5 150 2... | Taro is planning a long trip by train during the summer vacation. However, in order for Taro, who is a high school student, to travel as far as possible during the summer vacation, which has only one month, he cannot make a good plan unless he finds the cheapest and the fastest way. Let's create a program to help Taro'... | 0 |
{"tests": "{\"inputs\": [[3, 5, 4, 10], [4, 5, 4, 10], [0, 0, 4, 10], [3, 2, 4, 10], [3.9, 2, 4, 10], [5, 6, 4, 10], [3, 2, 4, 0], [3, 2, 2, 10]], \"outputs\": [[200], [200], [\"error\"], [80], [80], [\"error\"], [0], [60]]}", "source": "taco"} | A carpet shop sells carpets in different varieties. Each carpet can come in a different roll width and can have a different price per square meter.
Write a function `cost_of_carpet` which calculates the cost (rounded to 2 decimal places) of carpeting a room, following these constraints:
* The carpeting has to be don... | 0 |
{"tests": "{\"inputs\": [[\"3\", \"AH KH QH TH JH\", \"KH 5S 3C 5C 7D\", \"QH QD 2S QC 2C\"], \"3\\nAH KH QH TH JH\\nKH 5S 3D 5C 7D\\nQH QD 2S QC 2C\", \"3\\nAH KH QH TH JH\\nKH 5S 3C 5C 7D\\nQH QD 3S QC 2C\", \"3\\nAH KH QH TH JH\\nKH 4S 3C 5C 8D\\nQH QD 2S QC 2C\", \"3\\nAH KH QH TH JH\\nJH 6S 3C 5C 7D\\nQH QD 4S QC ... | In poker, you have 5 cards. There are 10 kinds of poker hands (from highest to lowest):
- royal flush - ace, king, queen, jack and ten, all in the same suit
- straight flush - five cards of the same suit in sequence, such
as 10,9,8,7,6 of clubs; ace can be counted both as the highest card or as the
lowest card - A,... | 0.25 |
{"tests": "{\"inputs\": [[\"a-(b)\"], [\"a-(-b)\"], [\"a+(b)\"], [\"a+(-b)\"], [\"(((((((((-((-(((n))))))))))))))\"], [\"(((a-((((-(-(f)))))))))\"], [\"((((-(-(-(-(m-g))))))))\"], [\"(((((((m-(-(((((t)))))))))))))\"], [\"-x\"], [\"-(-(x))\"], [\"-((-x))\"], [\"-(-(-x))\"], [\"-(-(x-y))\"], [\"-(x-y)\"], [\"x-(y+z)\"], ... | In this Kata, you will be given a mathematical string and your task will be to remove all braces as follows:
```Haskell
solve("x-(y+z)") = "x-y-z"
solve("x-(y-z)") = "x-y+z"
solve("u-(v-w-(x+y))-z") = "u-v+w+x+y-z"
solve("x-(-y-z)") = "x+y+z"
```
There are no spaces in the expression. Only two operators are given: `"... | 0 |
{"tests": "{\"inputs\": [\"3 2\\n\", \"1 3\\n\", \"4 3\\n\", \"1000000000000000000 1000000000000000000\\n\", \"59 576460752303423489\\n\", \"1234567891234 100005\\n\", \"2 4\\n\", \"59 576460752303423488\\n\", \"2016 2016\\n\", \"2016 2017\\n\", \"468804735183774830 244864585447548924\\n\", \"172714899512474455 4145149... | ZS the Coder has recently found an interesting concept called the Birthday Paradox. It states that given a random set of 23 people, there is around 50% chance that some two of them share the same birthday. ZS the Coder finds this very interesting, and decides to test this with the inhabitants of Udayland.
In Udayland,... | 0 |
{"tests": "{\"inputs\": [\"6\\n7 2 3 1 5 6\\n\", \"10\\n424238336 649760493 681692778 714636916 719885387 804289384 846930887 957747794 596516650 189641422\\n\", \"50\\n804289384 846930887 681692778 714636916 957747794 424238336 719885387 649760493 596516650 189641422 25202363 350490028 783368691 102520060 44897764 967... | DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | 0 |
{"tests": "{\"inputs\": [\"2 2 1\\nH 1\\n\", \"200000 200000 1\\nH 1\\n\", \"2 2 2\\nH 1\\nV 1\\n\", \"10 10 10\\nV 6\\nH 8\\nV 4\\nV 8\\nH 2\\nH 5\\nV 9\\nH 7\\nH 3\\nV 7\\n\", \"2 2 1\\nV 1\\n\", \"2 2 2\\nV 1\\nH 1\\n\", \"2 4 1\\nH 2\\n\", \"2 3 1\\nH 1\\n\", \"5 15 10\\nH 8\\nH 9\\nV 1\\nH 2\\nH 6\\nH 4\\nH 1\\nV ... | Leonid wants to become a glass carver (the person who creates beautiful artworks by cutting the glass). He already has a rectangular w mm × h mm sheet of glass, a diamond glass cutter and lots of enthusiasm. What he lacks is understanding of what to carve and how.
In order not to waste time, he decided to practice t... | 0.75 |
{"tests": "{\"inputs\": [[50.0, 130.0, [[-1.0, 120.0], [-1.5, 120.0]]], [50.0, 110.0, [[1.0, 120.0], [1.5, 125.0]]], [50.0, 120.0, [[-1.0, 115.0], [-1.5, 110.0], [1.0, 130.0], [1.5, 130.0]]], [30.0, 100.0, [[-1.0, 110.0], [-0.7, 102.0], [-1.5, 108.0]]], [30.0, 130.0, [[1.0, 120.0], [0.7, 125.0], [1.5, 110.0]]], [50.0, ... | # Back-Story
Every day I travel on the freeway.
When I am more bored than usual I sometimes like to play the following counting game I made up:
* As I join the freeway my count is ```0```
* Add ```1``` for every car that I overtake
* Subtract ```1``` for every car that overtakes me
* Stop counting when I reach my ex... | 0 |
{"tests": "{\"inputs\": [\"7 4\\n9R2A993\\n0E314A0\\n8A900DE\\n820R037\\n6 7\\nJH03HE\\nID7722\\n0DA1AH\\n30C9G5\\n99971A\\nCA7EAI\\nAHLBEM\\n20 2\\nHGEDBC4321987654321A\\nBDEDF908034265091499\\n0 0\", \"7 4\\n9R2A993\\n0E314A0\\n8A900DE\\n820R037\\n6 7\\nJI03HE\\nID7722\\n0DA1AH\\n30C9G5\\n99971A\\nCA7EAI\\nAHLBEM\\n2... | Your job is to find out the secret number hidden in a matrix, each of whose element is a digit ('0'-'9') or a letter ('A'-'Z'). You can see an example matrix in Figure 1.
<image>
Figure 1: A Matrix
The secret number and other non-secret ones are coded in a matrix as sequences of digits in a decimal format. You shoul... | 0.875 |
{"tests": "{\"inputs\": [\"14 8\\n1 2\\n2 7\\n3 4\\n6 3\\n5 7\\n3 8\\n6 8\\n11 12\\n\", \"200000 3\\n7 9\\n9 8\\n4 5\\n\", \"3 1\\n1 3\\n\", \"200000 1\\n1 200000\\n\", \"500 5\\n100 300\\n200 400\\n420 440\\n430 450\\n435 460\\n\", \"500 5\\n100 300\\n200 400\\n420 440\\n430 450\\n435 460\\n\", \"200000 1\\n1 200000\\... | You're given an undirected graph with $n$ nodes and $m$ edges. Nodes are numbered from $1$ to $n$.
The graph is considered harmonious if and only if the following property holds: For every triple of integers $(l, m, r)$ such that $1 \le l < m < r \le n$, if there exists a path going from node $l$ to node $r$, then th... | 0 |
{"tests": "{\"inputs\": [\"3\\n1 2\\n2 1\\n3 3\\n\", \"2\\n4 3\\n1 2\\n\", \"6\\n0 4\\n1 5\\n2 1\\n3 2\\n4 3\\n5 0\\n\", \"1\\n5 2\\n\", \"4\\n2 4\\n1 2\\n0 0\\n-2 -4\\n\", \"10\\n0 5\\n1 0\\n2 3\\n3 2\\n4 6\\n5 9\\n6 1\\n7 8\\n8 4\\n9 7\\n\", \"9\\n-1000000 -500000\\n-750000 250000\\n-500000 1000000\\n-250000 -250000\... | You are given a set of n points on the plane. A line containing the origin is called good, if projection of the given set to this line forms a symmetric multiset of points. Find the total number of good lines.
Multiset is a set where equal elements are allowed.
Multiset is called symmetric, if there is a point P on t... | 0 |
{"tests": "{\"inputs\": [\"4 10\\n3 1\", \"6 10\\n3 1\", \"2 14\\n3 1\", \"2 25\\n10 0\", \"2 4\\n10 0\", \"3 10\\n0 1\", \"3 14\\n10 3\", \"3 10\\n2 1\", \"2 9\\n3 1\", \"2 14\\n2 1\", \"3 22\\n10 3\", \"3 20\\n3 1\", \"2 20\\n2 1\", \"5 23\\n3 2\", \"2 0\\n2 1\", \"2 1\\n2 1\", \"5 33\\n3 1\", \"0 13\\n2 2\", \"4 13\... | Consider a sequence of n numbers using integers from 0 to 9 k1, k2, ..., kn. Read the positive integers n and s,
k1 + 2 x k2 + 3 x k3 + ... + n x kn = s
Create a program that outputs how many rows of n numbers such as. However, the same number does not appear more than once in one "n sequence of numbers".
Input
T... | 0.875 |
{"tests": "{\"inputs\": [\"5\\n2\\n01\\n10\\n5\\n01011\\n11100\\n2\\n01\\n01\\n10\\n0110011011\\n1000110100\\n1\\n0\\n1\\n\", \"5\\n2\\n01\\n10\\n5\\n01011\\n11110\\n2\\n01\\n01\\n10\\n0110011011\\n1000110100\\n1\\n0\\n1\\n\", \"5\\n2\\n01\\n10\\n5\\n01001\\n11100\\n2\\n01\\n01\\n10\\n0110011011\\n1000110100\\n1\\n0\\n... | This is the easy version of the problem. The difference between the versions is the constraint on n and the required number of operations. You can make hacks only if all versions of the problem are solved.
There are two binary strings a and b of length n (a binary string is a string consisting of symbols 0 and 1). In ... | 0 |
{"tests": "{\"inputs\": [\"?&?&?|?|?&?\", \"?|?&?|?&?&?\", \"?&?&?|?&?|?\", \"?&?|?|?&?&?\", \"?|?|?&?&?&?\", \"?&?&?&?|?|?\", \"?|?&?&?|?&?\", \"?&?|?&?&?|?\", \"?|?|?&?&??&\", \"?|?&?&?&?|?\", \"?|?&?|?&??&\", \"?&?|?|?&??&\", \"?|?|?&??&?&\", \"?|?|?&?&?&?\", \"?&?&?&?|?|?\", \"?|?&?&?|?&?\", \"?&?|?&?&?|?\", \"?&?&... | C: Short-circuit evaluation
problem
Naodai-kun and Hokkaido University-kun are playing games. Hokkaido University first generates the following logical formula represented by BNF.
<formula> :: = <or-expr>
<or-expr> :: = <and-expr>
| <or-expr> "|" <and-expr>
<and-expr> :: = <term>
| <and-expr> "&" <term>
<term> :: =... | 0 |
{"tests": "{\"inputs\": [\"1\\nx eazqyp pnop pngtg ye obmpngt xmybp mr lygw\", \"1\\nx pyqzae pnop pngtg ye obmpngt xmybp mr lygw\", \"1\\nx pyqzae pnop pngtg ye onmpbgt xmybp mr lygw\", \"1\\nx pyqzae pnop pngtg ye pnmobgt xmybp mr lygw\", \"1\\nx pyqzae pnop pngtg ye pnmobgt xmybp rm lygw\", \"1\\nx pyqzae pnop pngtg... | One of the simple ciphers is the affine cipher. First, replace the letters a to z with the numbers a = 0, b = 1, c = 2, ..., x = 23, y = 24, z = 25 and 0 to 25. Then replace the original alphabet with the following formula.
$ F (\ gamma) = (\ alpha \ cdot \ gamma + \ beta) $ mod $ 26 $
However, mod 26 represents the ... | 0.75 |
{"tests": "{\"inputs\": [\"O O .\\n O O . .\\n. . . . .\\n . . . .\\n . O .\\n\", \". . O\\n . O O .\\nO . O . O\\n O O O O\\n . . O\\n\", \". . .\\n . O . .\\n. O O . .\\n . . O .\\n . O .\\n\", \"O O O\\n O O . O\\nO . O O O\\n O . O O\\n O O .\\n\", \"O O O\\n O O . O\\nO . O O O\\n O O O O\\n . O O\\n\", \"O O... | Karlsson has visited Lillebror again. They found a box of chocolates and a big whipped cream cake at Lillebror's place. Karlsson immediately suggested to divide the sweets fairly between Lillebror and himself. Specifically, to play together a game he has just invented with the chocolates. The winner will get the cake a... | 0 |
{"tests": "{\"inputs\": [\"6 9\\n9 9 9 9 9 9\\n\", \"3 2\\n6 2 6\\n\", \"2 1\\n1 2\\n\", \"1 1\\n500000\\n\", \"1 500000\\n500000\\n\", \"9 2\\n1 2 1 2 1 2 1 3 3\\n\", \"29 3\\n1 4 3 4 3 3 4 1 1 3 4 1 3 3 4 1 3 1 2 3 1 4 2 2 3 4 2 4 2\\n\", \"18 1\\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\\n\", \"18 1\\n2 2 2 2 1 1 1 1 2 1... | You are given array $a$ of length $n$. You can choose one segment $[l, r]$ ($1 \le l \le r \le n$) and integer value $k$ (positive, negative or even zero) and change $a_l, a_{l + 1}, \dots, a_r$ by $k$ each (i.e. $a_i := a_i + k$ for each $l \le i \le r$).
What is the maximum possible number of elements with value $c$... | 0 |
{"tests": "{\"inputs\": [\"5\\n0 0\\n0 1\\n1 1\\n1 -1\\n2 2\\n\", \"5\\n0 0\\n1 0\\n2 1\\n1 1\\n2 3\\n\", \"1\\n-1000000000 1000000000\\n\", \"5\\n2 -1\\n-4 1\\n0 -9\\n5 -9\\n9 -10\\n\", \"5\\n6 1\\n10 5\\n10 -2\\n-2 -10\\n-4 -9\\n\", \"5\\n-10 3\\n4 -5\\n-9 5\\n-5 -3\\n-4 -6\\n\", \"5\\n2 9\\n-1 -4\\n-3 -8\\n-4 8\\n7 ... | You are given n points on Cartesian plane. Every point is a lattice point (i. e. both of its coordinates are integers), and all points are distinct.
You may draw two straight lines (not necessarily distinct). Is it possible to do this in such a way that every point lies on at least one of these lines?
-----Input----... | 0.375 |
{"tests": "{\"inputs\": [\"3\\n1 1\\n1 1\\n1 1\\n\", \"4\\n1 2\\n2 1\\n3 5\\n5 3\\n\", \"1\\n5 6\\n\", \"3\\n2 3\\n2 2\\n1 1\\n\", \"4\\n1 4\\n0 3\\n4 3\\n2 4\\n\", \"5\\n5 0\\n4 2\\n2 0\\n5 2\\n3 0\\n\", \"10\\n3 3\\n3 5\\n6 9\\n3 1\\n7 3\\n2 10\\n8 2\\n5 1\\n3 2\\n0 2\\n\", \"1\\n901418150 815121916\\n\", \"1\\n99999... | You invited $n$ guests to dinner! You plan to arrange one or more circles of chairs. Each chair is going to be either occupied by one guest, or be empty. You can make any number of circles.
Your guests happen to be a little bit shy, so the $i$-th guest wants to have a least $l_i$ free chairs to the left of his chair,... | 0 |
{"tests": "{\"inputs\": [\"1 1\\n0 0\\n2 3\\n\", \"2 3\\n1 6\\n6 1\\n10 1\\n1 10\\n7 7\\n\", \"1 2\\n0 0\\n0 0\\n0 0\\n\", \"7 3\\n0 8\\n3 8\\n2 7\\n0 10\\n5 5\\n7 0\\n3 5\\n6 6\\n3 11\\n11 5\\n\", \"1 1\\n0 0\\n0 0\\n\", \"2 1\\n0 0\\n0 0\\n0 0\\n\", \"1 1\\n279 365\\n566 88\\n\", \"1 2\\n244 520\\n590 781\\n867 704\\... | There are $n$ robbers at coordinates $(a_1, b_1)$, $(a_2, b_2)$, ..., $(a_n, b_n)$ and $m$ searchlight at coordinates $(c_1, d_1)$, $(c_2, d_2)$, ..., $(c_m, d_m)$.
In one move you can move each robber to the right (increase $a_i$ of each robber by one) or move each robber up (increase $b_i$ of each robber by one). N... | 0.5 |
{"tests": "{\"inputs\": [\"4 5 1 1 2\\n1 3 5 7\\n1 2 3 9 10\\n\", \"2 2 4 4 2\\n1 10\\n10 20\\n\", \"4 3 2 3 1\\n1 999999998 999999999 1000000000\\n3 4 1000000000\\n\", \"1 1 1 1 1\\n1\\n2\\n\", \"5 10 20 10 3\\n7 9 18 19 20\\n3 6 7 8 9 10 14 15 16 17\\n\", \"10 5 17 10 3\\n6 7 8 10 15 16 17 19 20 21\\n1 5 8 16 17\\n\"... | Arkady bought an air ticket from a city A to a city C. Unfortunately, there are no direct flights, but there are a lot of flights from A to a city B, and from B to C.
There are $n$ flights from A to B, they depart at time moments $a_1$, $a_2$, $a_3$, ..., $a_n$ and arrive at B $t_a$ moments later.
There are $m$ fligh... | 0 |
{"tests": "{\"inputs\": [\"3\\n3\\n1 5\\n2 10\\n2 8\\n7\\n0 1\\n3 1\\n1 1\\n6 1\\n1 1\\n4 1\\n4 1\\n6\\n2 6\\n2 3\\n2 8\\n2 7\\n4 4\\n5 5\\n\", \"3\\n3\\n1 5\\n2 10\\n2 4\\n7\\n0 1\\n3 1\\n1 1\\n6 1\\n1 1\\n4 1\\n4 1\\n6\\n2 6\\n2 3\\n2 8\\n2 7\\n4 4\\n5 5\\n\", \"3\\n3\\n1 5\\n2 10\\n2 8\\n7\\n0 1\\n1 1\\n1 1\\n6 1\\n... | The only difference between easy and hard versions is constraints.
Now elections are held in Berland and you want to win them. More precisely, you want everyone to vote for you.
There are $n$ voters, and two ways to convince each of them to vote for you. The first way to convince the $i$-th voter is to pay him $p_i$ ... | 0 |
{"tests": "{\"inputs\": [\"6 4 3 1\\n\", \"9 3 8 10\\n\", \"9 4 3 10\\n\", \"9 8 2 10\\n\", \"1 1 1 1\\n\", \"10 7 2 7\\n\", \"8 2 6 10\\n\", \"8 1 2 10\\n\", \"6 1 4 10\\n\", \"1000000 951981 612086 60277\\n\", \"1000000 587964 232616 62357\\n\", \"1000000 948438 69861 89178\\n\", \"1000000000 504951981 646612086 6027... | Mr. Bender has a digital table of size n × n, each cell can be switched on or off. He wants the field to have at least c switched on squares. When this condition is fulfilled, Mr Bender will be happy.
We'll consider the table rows numbered from top to bottom from 1 to n, and the columns — numbered from left to right f... | 0 |
{"tests": "{\"inputs\": [\"xoxoxoxoxoxoxo\", \"oxoxowoxoxoxox\", \"oxoxowoooxoxxx\", \"xxxoxooowoxoxo\", \"xoxoxooxwoxoxo\", \"xoxoyoxoxoxoxo\", \"xxxoxoooooxwxo\", \"xoxowooxwoxoxo\", \"oxoxoxoxoyoxox\", \"xoxoxoxoxoyoxo\", \"xxxoxooovoxoxo\", \"xoxowooxwoxowo\", \"oxoxoyoxoyoxox\", \"oxoyoxoxoxoxox\", \"oxoxovoooxoxx... | Takahashi is competing in a sumo tournament. The tournament lasts for 15 days, during which he performs in one match per day. If he wins 8 or more matches, he can also participate in the next tournament.
The matches for the first k days have finished. You are given the results of Takahashi's matches as a string S cons... | 0.875 |
{"tests": "{\"inputs\": [\"3 3\\n\", \"4 2\\n\", \"5 5\\n\", \"6 4\\n\", \"100 1\\n\", \"76 48\\n\", \"100 90\\n\", \"90 100\\n\", \"1 98\\n\", \"1 100\\n\", \"56 98\\n\", \"89 89\\n\", \"18 94\\n\", \"84 27\\n\", \"1 1\\n\", \"1 2\\n\", \"2 1\\n\", \"1 34\\n\", \"46 2\\n\", \"99 3\\n\", \"10 100\\n\", \"100 100\\n\", ... | There are n boys and m girls studying in the class. They should stand in a line so that boys and girls alternated there as much as possible. Let's assume that positions in the line are indexed from left to right by numbers from 1 to n + m. Then the number of integers i (1 ≤ i < n + m) such that positions with indexes i... | 0 |
{"tests": "{\"inputs\": [\"4 5 1 3 4\\n1 2 5\\n2 3 9\\n2 4 5\\n1 3 8\\n1 4 8\\n0 0 0 0 0\", \"4 5 1 3 4\\n1 2 5\\n2 3 9\\n2 4 5\\n1 3 3\\n1 4 8\\n0 0 0 0 0\", \"6 5 1 3 4\\n1 2 5\\n4 3 5\\n2 3 5\\n1 3 8\\n1 4 8\\n0 0 0 0 0\", \"4 5 1 3 4\\n1 2 5\\n2 3 5\\n2 4 5\\n1 3 8\\n2 4 8\\n0 0 0 0 0\", \"4 5 1 3 4\\n0 2 5\\n2 3 9... | In 21XX, humanity finally began a plan to relocate to Mars. Selected as the first group of immigrants to Mars, you are assigned to the Administrative Center of Mars to deal with various problems that occur on Mars. The biggest problem at the moment of the Central Bureau is securing an independent supply and demand cycl... | 0 |
{"tests": "{\"inputs\": [\"[+c[+a[^bd]]]\\n0404\\n[*b[*[*cd]a]]\\n7777\\n[^[^ab][^cd]]\\n2570\\na\\n9876\\n[^dd]\\n9090\\n.\", \"[+c[*a[^bd]]]\\n0404\\n[*b[*[*cd]a]]\\n7777\\n[^[^ab][^cd]]\\n2570\\na\\n9876\\n[^dd]\\n9090\\n.\", \"[+c[^a[+bd]]]\\n0404\\n[*b[*[*cd]a]]\\n7777\\n[^[^ab][^cd]]\\n1295\\na\\n9876\\n[^dd]\\n9... | Proof of knowledge
The entrance door of the apartment you live in has a password-type lock. This password consists of exactly four digits, ranging from 0 to 9, and you always use the password P given to you by the apartment manager to unlock this door.
One day, you wondered if all the residents of the apartment were ... | 0 |
{"tests": "{\"inputs\": [\"3 1\\n1 1 2 2\\n2 2 3 3\\n3 3 4 4\\n\", \"4 1\\n1 1 2 2\\n1 9 2 10\\n9 9 10 10\\n9 1 10 2\\n\", \"3 0\\n1 1 2 2\\n1 1 1000000000 1000000000\\n1 3 8 12\\n\", \"11 8\\n9 1 11 5\\n2 2 8 12\\n3 8 23 10\\n2 1 10 5\\n7 1 19 5\\n1 8 3 10\\n1 5 3 9\\n1 2 3 4\\n1 2 3 4\\n4 2 12 16\\n8 5 12 9\\n\", \"2... | Edo has got a collection of n refrigerator magnets!
He decided to buy a refrigerator and hang the magnets on the door. The shop can make the refrigerator with any size of the door that meets the following restrictions: the refrigerator door must be rectangle, and both the length and the width of the door must be posit... | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.