info stringlengths 120 50k | question stringlengths 504 10.4k | avg@8_qwen3_4b_instruct_2507 float64 0 0.88 |
|---|---|---|
{"tests": "{\"inputs\": [\"4\\n3 2\\n3 1\\n8 6\\n8 7 6 5 3 2\\n9 6\\n9 8 5 4 3 1\\n1 1\\n1\\n\", \"28\\n8 4\\n8 7 6 3\\n8 5\\n8 7 6 3 1\\n8 5\\n8 7 6 3 2\\n8 6\\n8 7 6 3 2 1\\n8 4\\n8 7 6 4\\n8 5\\n8 7 6 4 1\\n8 5\\n8 7 6 4 2\\n8 6\\n8 7 6 4 2 1\\n8 5\\n8 7 6 4 3\\n8 6\\n8 7 6 4 3 1\\n8 6\\n8 7 6 4 3 2\\n8 7\\n8 7 6 4 ... | You are playing a game where your character should overcome different obstacles. The current problem is to come down from a cliff. The cliff has height $h$, and there is a moving platform on each height $x$ from $1$ to $h$.
Each platform is either hidden inside the cliff or moved out. At first, there are $n$ moved out... | 0 |
{"tests": "{\"inputs\": [\"7330105816139991597267787581532092408135003429259616955239761315950805521264994021242873979309182812\\n\", \"126\\n\", \"2147483649\\n\", \"4596620932866717074931903995027173085744596193421095444317407919730992986418713478580824584919587030\\n\", \"6911378\\n\", \"9223372036854775807\\n\", \"... | Little Petya has recently started attending a programming club. Naturally he is facing the problem of choosing a programming language. After long considerations he realized that Java is the best choice. The main argument in favor of choosing Java was that it has a very large integer data type, called BigInteger.
But h... | 0.875 |
{"tests": "{\"inputs\": [\"1\\n\", \"2\\n\", \"4\\n\", \"14\\n\", \"41\\n\", \"51\\n\", \"776\\n\", \"116\\n\", \"972\\n\", \"3517\\n\", \"3776\\n\", \"4035\\n\", \"35997\\n\", \"61669\\n\", \"87341\\n\", \"398223\\n\", \"772168\\n\", \"423353776\\n\", \"999950884\\n\", \"1000000000\\n\", \"408636\\n\", \"4205340\\n\",... | Little Sofia is in fourth grade. Today in the geometry lesson she learned about segments and squares. On the way home, she decided to draw $n$ squares in the snow with a side length of $1$. For simplicity, we assume that Sofia lives on a plane and can draw only segments of length $1$, parallel to the coordinate axes, w... | 0 |
{"tests": "{\"inputs\": [\"5\\n2 6 8 7 4\\n\", \"8\\n1 2 3 4 5 6 7 8\\n\", \"4\\n1 2 4 8\\n\", \"2\\n3 4\\n\", \"7\\n1 2 4 6 8 10 12\\n\", \"7\\n1 2 3 4 5 6 8\\n\", \"7\\n1 2 4 8 10 12 6\\n\", \"7\\n3 8 1 4 2 5 6\\n\", \"10\\n5 5 5 5 5 5 5 5 5 5\\n\", \"10\\n5 5 5 5 5 5 3 5 5 5\\n\", \"8\\n3 1 4 1 5 9 2 6\\n\", \"5\\n1... | A sequence $a_1, a_2, \dots, a_k$ is called an arithmetic progression if for each $i$ from $1$ to $k$ elements satisfy the condition $a_i = a_1 + c \cdot (i - 1)$ for some fixed $c$.
For example, these five sequences are arithmetic progressions: $[5, 7, 9, 11]$, $[101]$, $[101, 100, 99]$, $[13, 97]$ and $[5, 5, 5, 5, ... | 0 |
{"tests": "{\"inputs\": [\"5\\n4\\n1 2 -1 2\\n3\\n1 1 -2\\n5\\n2 0 -2 2 -1\\n3\\n-2 -1 -1\\n3\\n-1 -2 -2\\n\", \"1\\n1\\n1\\n\", \"1\\n100\\n2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2... | You are given an array $a$ consisting of $n$ integers. For each $i$ ($1 \le i \le n$) the following inequality is true: $-2 \le a_i \le 2$.
You can remove any number (possibly $0$) of elements from the beginning of the array and any number (possibly $0$) of elements from the end of the array. You are allowed to delete... | 0 |
{"tests": "{\"inputs\": [\"3\\n5\\n2 1 2 1 1\\n4\\n11 2 2 2\\n1\\n998244353\\n\", \"3\\n5\\n1 1 2 1 1\\n4\\n11 2 2 2\\n1\\n998244353\\n\", \"3\\n5\\n2 2 2 1 1\\n4\\n11 2 2 2\\n1\\n998244353\\n\", \"3\\n5\\n1 1 1 1 1\\n4\\n11 2 3 2\\n1\\n998244353\\n\", \"3\\n5\\n1 1 0 1 1\\n4\\n11 2 2 3\\n1\\n998244353\\n\", \"3\\n5\\n... | In the 2050 Conference, some people from the competitive programming community meet together and are going to take a photo. The n people form a line. They are numbered from 1 to n from left to right. Each of them either holds a cardboard with the letter 'C' or a cardboard with the letter 'P'.
Let C=\\{c_1,c_2,...,c_m\... | 0 |
{"tests": "{\"inputs\": [\"10 2\\n10 -1 2 2 2 2 2 2 -1 10\\n\", \"5 10\\n-1 -1 -1 -1 -1\\n\", \"18 1\\n166 788 276 -103 -491 195 -960 389 376 369 630 285 3 575 315 -987 820 466\\n\", \"29 6\\n-21 486 -630 -433 -123 -387 618 110 -203 55 -123 524 -168 662 432 378 -155 -136 -162 811 457 -157 -215 861 -565 -506 557 348 -7\... | As usual, Sereja has array a, its elements are integers: a[1], a[2], ..., a[n]. Let's introduce notation:
$f(a, l, r) = \sum_{i = l}^{r} a [ i ] ; m(a) = \operatorname{max}_{1 \leq l \leq r \leq n} f(a, l, r)$
A swap operation is the following sequence of actions:
choose two indexes i, j (i ≠ j); perform assignme... | 0 |
{"tests": "{\"inputs\": [\"4\\n5 6 7 8\\n\", \"5\\n4 -5 9 -2 1\\n\", \"5\\n9 3 7 4 6\\n\", \"3\\n4 -5 1\\n\", \"3\\n98 56 99\\n\", \"1\\n11\\n\", \"2\\n86 5\\n\", \"6\\n-69 -71 51 18 27 36\\n\", \"5\\n-32 57 44 -34 66\\n\", \"5\\n-56 101 87 0 -24\\n\", \"5\\n2 -86 61 -3 -50\\n\", \"6\\n72 91 46 -72 -36 -25\\n\", \"11\\... | While playing yet another strategy game, Mans has recruited $n$ Swedish heroes, whose powers which can be represented as an array $a$.
Unfortunately, not all of those mighty heroes were created as capable as he wanted, so that he decided to do something about it. In order to accomplish his goal, he can pick two consec... | 0 |
{"tests": "{\"inputs\": [\"4\\n2\\n4\\n2\\n1\", \"4\\n2\\n4\\n6\\n1\", \"4\\n0\\n13\\n10\\n1\", \"4\\n2\\n4\\n2\\n0\", \"4\\n2\\n4\\n8\\n1\", \"4\\n2\\n4\\n10\\n1\", \"4\\n2\\n4\\n13\\n1\", \"5\\n10\\n8\\n5\\n6\\n2\", \"4\\n2\\n4\\n11\\n1\", \"4\\n2\\n5\\n10\\n1\", \"5\\n10\\n8\\n10\\n6\\n2\", \"4\\n0\\n4\\n11\\n1\", \... | Snuke got an integer sequence of length N from his mother, as a birthday present. The i-th (1 ≦ i ≦ N) element of the sequence is a_i. The elements are pairwise distinct. He is sorting this sequence in increasing order. With supernatural power, he can perform the following two operations on the sequence in any order:
... | 0 |
{"tests": "{\"inputs\": [[4], [7], [11], [30], [-5], [0], [3]], \"outputs\": [[\" A \\n A A \\n A A A \\nA A\"], [\" A \\n A A \\n A A \\n A A A A \\n A A \\nA A\"], [\" A \\n A A \\n A A \\n A A \\n A A ... | - Input: Integer `n`
- Output: String
Example:
`a(4)` prints as
```
A
A A
A A A
A A
```
`a(8)` prints as
```
A
A A
A A
A A
A A A A A
A A
A A
A A
```
`a(12)` prints as
```
A
A A... | 0 |
{"tests": "{\"inputs\": [[1], [0], [-1], [\"test\"], [null], [[]], [2], [100], [3], [7]], \"outputs\": [[false], [false], [false], [false], [false], [false], [\"□ ■\\n■ □\"], [\"□ ■ □ ■ □ ■ □ ■ □ ■ □ ■ □ ■ □ ■ □ ■ □ ■ □ ■ □ ■ □ ■ □ ■ □ ■ □ ■ □ ■ □ ■ □ ■ □ ■ □ ■ □ ■ □ ■ □ ■ □ ■ □ ■ □ ■ □ ■ □ ■ □ ■ □ ■ □ ■ □ ■ □ ■ □ ■ □ ... | Write a function which takes one parameter representing the dimensions of a checkered board. The board will always be square, so 5 means you will need a 5x5 board.
The dark squares will be represented by a unicode white square, while the light squares will be represented by a unicode black square (the opposite colours... | 0 |
{"tests": "{\"inputs\": [\"3\\n0 1 1\", \"3\\n2 -1 2\", \"3\\n2 0 2\", \"3\\n2 0 1\", \"3\\n2 1 1\", \"3\\n2 1 2\", \"3\\n1 1 -1\", \"3\\n2 2 2\", \"3\\n3 2 2\", \"3\\n3 1 0\", \"3\\n1 -2 2\", \"3\\n2 -1 3\", \"3\\n3 0 2\", \"3\\n4 1 1\", \"3\\n4 2 1\", \"3\\n1 -2 1\", \"3\\n2 4 2\", \"3\\n3 3 2\", \"3\\n1 -2 4\", \"3\... | There are N integers, A_1, A_2, ..., A_N, written on a blackboard.
We will repeat the following operation N-1 times so that we have only one integer on the blackboard.
* Choose two integers x and y on the blackboard and erase these two integers. Then, write a new integer x-y.
Find the maximum possible value of the... | 0 |
{"tests": "{\"inputs\": [\"5\\nba\\na\\nabab\\na\\naba\\nbaba\\nab\\naba\\n\", \"3\\na\\naa\\naa\\na\\n\", \"2\\na\\nc\\n\", \"2\\nz\\nz\\n\", \"5\\nba\\na\\nbaba\\na\\naba\\nabab\\nab\\naba\\n\", \"5\\nb\\nb\\nba\\nab\\nbab\\nbab\\nabab\\nbaba\\n\", \"5\\nc\\ncd\\ncdc\\ncdcc\\nb\\ncb\\nccb\\ndccb\\n\", \"3\\nba\\nab\\... | Ivan wants to play a game with you. He picked some string $s$ of length $n$ consisting only of lowercase Latin letters.
You don't know this string. Ivan has informed you about all its improper prefixes and suffixes (i.e. prefixes and suffixes of lengths from $1$ to $n-1$), but he didn't tell you which strings are pre... | 0 |
{"tests": "{\"inputs\": [[0], [9], [99], [999], [9999], [99999], [-5], [-54], [-543], [-5432], [-54321], [0.5], [0.25], [0.125], [0.0625], [0.03125], [10], [14], [18], [20], [24], [50], [100], [110], [111], [-10], [-14], [-18], [-20], [-100], [-110], [-111], [1000], [10000], [10306], [10006], [10006.005], [-10306.005],... | Create a function that takes a Number as its argument and returns a Chinese numeral string. You don't need to validate the input argument, it will always be a Number in the range `[-99999.999, 99999.999]`, rounded to 8 decimal places.
Simplified Chinese numerals have characters representing each number from 0 to 9 and... | 0 |
{"tests": "{\"inputs\": [\"hi\\nbob\\n\", \"abca\\naccepted\\n\", \"abacaba\\nabcdcba\\n\", \"lo\\neuhaqdhhzlnkmqnakgwzuhurqlpmdm\\n\", \"aaeojkdyuilpdvyewjfrftkpcobhcumwlaoiocbfdtvjkhgda\\nmlmarpivirqbxcyhyerjoxlslyfzftrylpjyouypvk\\n\", \"npnkmawey\\nareakefvowledfriyjejqnnaeqheoh\\n\", \"fdtffutxkujflswyddvhusfcook\... | You are given two strings a and b. You have to remove the minimum possible number of consecutive (standing one after another) characters from string b in such a way that it becomes a subsequence of string a. It can happen that you will not need to remove any characters at all, or maybe you will have to remove all of th... | 0.75 |
{"tests": "{\"inputs\": [\"3 5\\n12 8 25 19 44\\n9 13 16 0 17\\n20 14 16 10 22\\n17 27 18 16\\n9 7 0\\n19 5\\n21\\n0 0\", \"3 5\\n12 15 70 19 44\\n9 13 16 0 17\\n20 14 16 10 22\\n17 27 18 16\\n9 7 0\\n19 5\\n21\\n0 0\", \"3 5\\n12 8 25 19 23\\n9 13 16 0 17\\n20 9 16 10 22\\n17 27 18 16\\n1 7 0\\n19 5\\n21\\n0 0\", \"3 ... | The Aizu Wakamatsu city office decided to lay a hot water pipeline covering the whole area of the city to heat houses. The pipeline starts from some hot springs and connects every district in the city. The pipeline can fork at a hot spring or a district, but no cycle is allowed. The city office wants to minimize the le... | 0 |
{"tests": "{\"inputs\": [\"2\\n1000000000 1000000000\\n\", \"3\\n5 1 3\\n\", \"5\\n1 2 5 3 4\\n\", \"3\\n5 3 5\\n\", \"3\\n100 5 10\\n\", \"8\\n1 2 3 4 1 5 6 7\\n\", \"10\\n17 99 23 72 78 36 5 43 95 9\\n\", \"6\\n2 3 5 5 6 7\\n\", \"4\\n1 4 3 4\\n\", \"4\\n5 1 2 3\\n\", \"6\\n1 2 1 2 4 5\\n\", \"1\\n42\\n\", \"5\\n1 5 ... | DZY has a sequence a, consisting of n integers.
We'll call a sequence ai, ai + 1, ..., aj (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 one numb... | 0 |
{"tests": "{\"inputs\": [[\"0\"], [\"3/4\"], [\"12/4\"], [\"4/5\"], [\"0.66\"], [\"22/23\"], [\"1001/3456\"], [\"16/17\"], [\"30/45\"], [\"1.25\"], [\"75/3\"], [\"2/8\"], [\"0.9\"]], \"outputs\": [[[]], [[\"1/2\", \"1/4\"]], [[\"3\"]], [[\"1/2\", \"1/4\", \"1/20\"]], [[\"1/2\", \"1/7\", \"1/59\", \"1/5163\", \"1/533079... | Given a rational number n
``` n >= 0, with denominator strictly positive```
- as a string (example: "2/3" in Ruby, Python, Clojure, JS, CS, Go)
- or as two strings (example: "2" "3" in Haskell, Java, CSharp, C++, Swift)
- or as a rational or decimal number (example: 3/4, 0.67 in R)
- or two integers (Fortran)
d... | 0 |
{"tests": "{\"inputs\": [\"1\\n\", \"3\\n\", \"2\\n\", \"4\\n\", \"5\\n\", \"6\\n\", \"7\\n\", \"8\\n\", \"9\\n\", \"10\\n\", \"11\\n\", \"12\\n\", \"13\\n\", \"14\\n\", \"15\\n\", \"16\\n\", \"17\\n\", \"18\\n\", \"19\\n\", \"20\\n\", \"99\\n\", \"100\\n\", \"9999\\n\", \"21736\\n\", \"873467\\n\", \"4124980\\n\", \"5... | Way to go! Heidi now knows how many brains there must be for her to get one. But throwing herself in the midst of a clutch of hungry zombies is quite a risky endeavor. Hence Heidi wonders: what is the smallest number of brains that must be in the chest for her to get out at all (possibly empty-handed, but alive)?
The ... | 0 |
{"tests": "{\"inputs\": [\"3\\n000\\n000\\n000\\n\", \"10\\n1111100000\\n0010100000\\n0110111000\\n0000001000\\n1011001010\\n0010100001\\n0010111000\\n0011001010\\n0000110010\\n0000001100\\n\", \"10\\n1101010101\\n1110101010\\n0111010101\\n1011101010\\n0101110101\\n1010111010\\n0101011101\\n1010101110\\n0101010111\\n10... | After years of hard work scientists invented an absolutely new e-reader display. The new display has a larger resolution, consumes less energy and its production is cheaper. And besides, one can bend it. The only inconvenience is highly unusual management. For that very reason the developers decided to leave the e-read... | 0 |
{"tests": "{\"inputs\": [\"4\\n3 13\\n0 1 2\\n2 777\\n0 4\\n3 255\\n0 1 3\\n10 1000000000\\n0 1 2 3 4 5 6 7 8 9\\n\", \"4\\n3 13\\n0 1 2\\n2 777\\n0 2\\n3 255\\n0 1 3\\n10 1000000000\\n0 1 2 3 4 5 6 7 8 9\\n\", \"4\\n3 14\\n0 1 2\\n2 777\\n0 2\\n3 255\\n0 1 3\\n10 1000000000\\n0 1 2 3 4 5 6 7 8 9\\n\", \"4\\n3 13\\n0 1... | In Berland, $n$ different types of banknotes are used. Banknotes of the $i$-th type have denomination $10^{a_i}$ burles (burles are the currency used in Berland); the denomination of banknotes of the first type is exactly $1$.
Let's denote $f(s)$ as the minimum number of banknotes required to represent exactly $s$ bur... | 0 |
{"tests": "{\"inputs\": [\"3 3\\n1 2\\n2 3\\n1 3\\n4 3\\n1 2\\n1 3\\n1 4\\n4 6\\n1 2\\n1 3\\n1 2\\n2 3\\n3 4\\n2 4\\n0 0\", \"3 3\\n2 2\\n2 3\\n2 3\\n4 3\\n1 2\\n1 3\\n1 4\\n4 6\\n1 4\\n1 3\\n1 4\\n2 3\\n3 4\\n2 4\\n0 0\", \"3 3\\n2 2\\n2 3\\n2 3\\n4 3\\n1 2\\n1 3\\n1 4\\n6 6\\n1 4\\n1 3\\n1 4\\n2 3\\n3 4\\n2 4\\n0 0\"... | Gift Exchange Party
A gift exchange party will be held at a school in TKB City.
For every pair of students who are close friends, one gift must be given from one to the other at this party, but not the other way around. It is decided in advance the gift directions, that is, which student of each pair receives a gift.... | 0.125 |
{"tests": "{\"inputs\": [\"9 13\\n1 2\\n1 3\\n2 9\\n3 4\\n3 5\\n3 6\\n4 9\\n5 8\\n6 7\\n6 8\\n7 9\\n8 9\\n9 1\", \"9 13\\n1 2\\n1 3\\n1 9\\n1 4\\n3 5\\n5 6\\n4 9\\n5 7\\n6 7\\n8 8\\n7 9\\n5 9\\n9 1\", \"9 1\\n1 1\\n1 3\\n1 9\\n1 4\\n3 5\\n5 6\\n4 9\\n5 7\\n6 7\\n6 8\\n7 9\\n5 9\\n9 1\", \"9 10\\n1 2\\n1 3\\n2 9\\n1 4\\... | J - Tree Reconstruction
Problem Statement
You have a directed graph. Some non-negative value is assigned on each edge of the graph. You know that the value of the graph satisfies the flow conservation law That is, for every node v, the sum of values on edges incoming to v equals to the sum of values of edges outgoing... | 0 |
{"tests": "{\"inputs\": [[[50, 2, 1, 9]], [[3655, 89]], [[8]], [[12, 13, 89, 155, 8, 26, 0]], [[76, 4, 3, 81, 514, 6, 716]], [[817, 6879, 163, 348, 8, 22, 47]], [[411, 742, 89, 691, 284]], [[587, 625, 638, 898, 122]], [[797, 535, 210, 87]], [[5, 2, 1, 9, 50, 56]], [[197, 853, 819]], [[23044, 2, 7626, 914, 7800]], [[451... | Create a function that takes a list of one or more non-negative integers, and arranges them such that they form the largest possible number.
Examples:
`largestArrangement([4, 50, 8, 145])` returns 8504145 (8-50-4-145)
`largestArrangement([4, 40, 7])` returns 7440 (7-4-40)
`largestArrangement([4, 46, 7])` returns 74... | 0 |
{"tests": "{\"inputs\": [\"4\\na b c d\\n1\\n10 b c a b a d d d a a\\n\", \"1\\na\\n4\\n2 c t\\n2 n v\\n2 n v\\n2 g o\\n\", \"4\\na b c d\\n10\\n8 c yy d vm a dh b bt\\n8 b bx d yi a qp c qd\\n8 c uk d ys b dv a cg\\n8 b of a wh d gj c cr\\n8 a qn b na d hh c ak\\n8 a zq d rs c zj b lc\\n8 a et b oj c zf d xt\\n8 d mq ... | A widely known among some people Belarusian sport programmer Lesha decided to make some money to buy a one square meter larger flat. To do this, he wants to make and carry out a Super Rated Match (SRM) on the site Torcoder.com. But there's a problem — a severe torcoder coordinator Ivan does not accept any Lesha's probl... | 0 |
{"tests": "{\"inputs\": [\"3\\n3\\n1 4 3\\n1\\n15\\n2\\n3 5\\n\", \"1\\n2\\n1 1\\n\", \"14\\n1\\n2\\n1\\n1\\n2\\n2 2\\n2\\n2 1\\n2\\n1 2\\n2\\n1 1\\n3\\n2 2 2\\n3\\n2 2 1\\n3\\n2 1 2\\n3\\n2 1 1\\n3\\n1 2 2\\n3\\n1 2 1\\n3\\n1 1 2\\n3\\n1 1 1\\n\", \"1\\n2\\n1 1\\n\", \"14\\n1\\n2\\n1\\n1\\n2\\n2 2\\n2\\n2 1\\n2\\n1 2\... | You are given an array $a$ consisting of $n$ positive integers. Find a non-empty subset of its elements such that their sum is even (i.e. divisible by $2$) or determine that there is no such subset.
Both the given array and required subset may contain equal values.
-----Input-----
The first line contains a single i... | 0 |
{"tests": "{\"inputs\": [\"5\\n1 5 7 10 21\\n8\\n2 4 17 10 22 21 100 35\", \"5\\n1 5 7 3 21\\n8\\n2 4 17 10 22 21 100 42\", \"5\\n1 5 7 3 21\\n8\\n0 4 17 10 22 21 100 42\", \"5\\n1 5 7 3 21\\n8\\n0 4 17 11 22 21 010 42\", \"5\\n0 5 7 3 21\\n8\\n0 4 17 11 22 21 010 42\", \"5\\n0 5 10 3 21\\n8\\n0 4 17 11 22 14 010 42\",... | Write a program which reads a sequence A of n elements and an integer M, and outputs "yes" if you can make M by adding elements in A, otherwise "no". You can use an element only once.
You are given the sequence A and q questions where each question contains Mi.
Notes
You can solve this problem by a Burte Force appro... | 0 |
{"tests": "{\"inputs\": [\"3\\n3\\n1 2\\n1 3\\n4\\n1 2\\n2 3\\n3 4\\n8\\n1 2\\n2 3\\n3 4\\n1 5\\n5 6\\n6 7\\n5 8\\n\", \"3\\n3\\n1 2\\n2 3\\n4\\n1 2\\n2 3\\n3 4\\n8\\n1 2\\n2 3\\n3 4\\n1 5\\n5 6\\n6 7\\n5 8\\n\", \"3\\n3\\n1 2\\n2 3\\n4\\n1 2\\n2 3\\n3 4\\n8\\n1 2\\n2 3\\n3 4\\n1 7\\n5 6\\n6 7\\n5 8\\n\", \"3\\n3\\n1 2... | Gildong is playing with his dog, Badugi. They're at a park that has $n$ intersections and $n-1$ bidirectional roads, each $1$ meter in length and connecting two intersections with each other. The intersections are numbered from $1$ to $n$, and for every $a$ and $b$ ($1 \le a, b \le n$), it is possible to get to the $b$... | 0 |
{"tests": "{\"inputs\": [\"3\\n2 5\\n4 2\\n6 3\", \"6\\n19 92\\n64 64\\n78 48\\n57 33\\n142 6\\n95 73\", \"4\\n1 5\\n2 6\\n0 7\\n4 8\", \"3\\n1 5\\n4 4\\n6 3\", \"6\\n19 92\\n64 64\\n29 48\\n57 33\\n142 6\\n95 73\", \"4\\n1 5\\n0 6\\n0 7\\n4 8\", \"6\\n19 92\\n64 64\\n29 48\\n57 33\\n142 6\\n95 15\", \"4\\n1 3\\n0 6\\n... | We have a directed weighted graph with N vertices. Each vertex has two integers written on it, and the integers written on Vertex i are A_i and B_i.
In this graph, there is an edge from Vertex x to Vertex y for all pairs 1 \leq x,y \leq N, and its weight is {\rm min}(A_x,B_y).
We will consider a directed cycle in thi... | 0 |
{"tests": "{\"inputs\": [\"5\\n()\\n(?)\\n(??)\\n??()\\n)?(?\\n\", \"12\\n(??)\\n(??)\\n(??)\\n(??)\\n(??)\\n(??)\\n(??)\\n(??)\\n(??)\\n(??)\\n(??)\\n(??)\\n\", \"1\\n???????????????????()???????????????????\\n\", \"12\\n()\\n()\\n()\\n()\\n()\\n()\\n()\\n()\\n()\\n()\\n()\\n()\\n\", \"12\\n()\\n()\\n()\\n()\\n(??????... | A bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters + and 1 into this sequence. For example, sequences (())(), () and (()(())) are regular, while )(, (() and (()))( are not. Let's call a regular bracket sequence "RBS".
You are given a sequence $s$ of $... | 0.625 |
{"tests": "{\"inputs\": [[\"12:30 am\"], [\"12:02 pm\"], [\"01:00 pm\"], [\"11:12 am\"], [\"05:20 pm\"], [\"04:20 am\"]], \"outputs\": [[[false, false, true]], [[false, true, false]], [[true, false, false]], [[false, false, true]], [[false, false, true]], [[false, true, false]]]}", "source": "taco"} | # Task
You are given a `moment` in time and space. What you must do is break it down into time and space, to determine if that moment is from the past, present or future.
`Time` is the sum of characters that increase time (i.e. numbers in range ['1'..'9'].
`Space` in the number of characters which do not increase... | 0 |
{"tests": "{\"inputs\": [\"5 4\\n1 2\\n2 3\\n3 4\\n4 5\\n4 6\\n1 2\\n1 3\\n1 4\\n2 4\\n2 4\\n3 4\\n5 0\\n0 0\", \"5 4\\n1 2\\n2 3\\n3 4\\n5 5\\n4 6\\n1 2\\n1 3\\n1 4\\n2 4\\n2 4\\n3 4\\n5 0\\n0 0\", \"5 4\\n2 2\\n2 3\\n3 4\\n5 5\\n4 6\\n1 2\\n1 3\\n1 4\\n1 4\\n1 4\\n3 4\\n0 0\\n0 0\", \"5 4\\n2 1\\n2 3\\n3 4\\n4 5\\n4 ... | A witch named Marie lived deep in a remote forest. Since she is a witch, she magically covers everything she needs to live, such as food, water, and fuel.
Her magic is activated by drawing a magic circle using some magical stones and strings. This magic circle is drawn by placing stones and tying several pairs of ston... | 0.375 |
{"tests": "{\"inputs\": [\"9\\nBEWPVCRWH\\nZQNZYIJX\\nBAVREA\\nPA\\nHJMYITEOX\\nBCJHMRMNK\\nBP\\nQVFABZ\\nPRGKSPUNA\", \"7\\nEBBYBAR\\nJOZ\\nBMHQUVA\\nBPA\\nISU\\nMCMABAOBHZ\\nSZMEHMA\", \"3\\nABCA\\nXBAZ\\nBAE\", \"3\\nACBA\\nZABX\\nAEB\", \"3\\n@DBA\\nZAAX\\nAEB\", \"9\\nBEWPVCRWH\\nZQNZYIJX\\nAERVAB\\nPA\\nHJMYITEOX... | Snuke has N strings. The i-th string is s_i.
Let us concatenate these strings into one string after arranging them in some order. Find the maximum possible number of occurrences of `AB` in the resulting string.
Constraints
* 1 \leq N \leq 10^{4}
* 2 \leq |s_i| \leq 10
* s_i consists of uppercase English letters.
In... | 0 |
{"tests": "{\"inputs\": [\"3 3 2\\n3 5 1\\n\", \"5 10 3\\n12 8 18 25 1\\n\", \"7 7 2\\n7 3 4 1 6 5 2\\n\", \"2 2 2\\n1 3\\n\", \"1 4 1\\n1\\n\", \"2 3 1\\n1 2\\n\", \"5 4 2\\n7 2 4 5 6\\n\", \"7 5 3\\n11 3 13 19 5 18 17\\n\", \"10 7 2\\n30 9 1 40 34 4 35 27 11 3\\n\", \"13 10 4\\n5 28 67 70 68 3 84 4 30 82 96 37 49\\n\... | Every evening Vitalya sets n alarm clocks to wake up tomorrow. Every alarm clock rings during exactly one minute and is characterized by one integer a_{i} — number of minute after midnight in which it rings. Every alarm clock begins ringing at the beginning of the minute and rings during whole minute.
Vitalya will de... | 0 |
{"tests": "{\"inputs\": [\"4 2\\n0101\\n\", \"6 1\\n010101\\n\", \"6 5\\n010101\\n\", \"4 1\\n0011\\n\", \"1 1\\n1\\n\", \"1 1\\n0\\n\", \"2 1\\n11\\n\", \"2 1\\n00\\n\", \"2 2\\n01\\n\", \"2 1\\n10\\n\", \"20 17\\n01001001101010111011\\n\", \"10 10\\n0111010011\\n\", \"10 5\\n0001000000\\n\", \"10 2\\n0000011000\\n\",... | "Duel!"
Betting on the lovely princess Claris, the duel between Tokitsukaze and Quailty has started.
There are $n$ cards in a row. Each card has two sides, one of which has color. At first, some of these cards are with color sides facing up and others are with color sides facing down. Then they take turns flipping ca... | 0 |
{"tests": "{\"inputs\": [[\"hello\"], [\"ciao bella!\"], [\"salut\"], [\"hallo, salut\"], [\"hombre! Hola!\"], [\"Hallo, wie geht's dir?\"], [\"AHOJ!\"], [\"czesc\"], [\"meh\"], [\"Ahoj\"]], \"outputs\": [[true], [true], [true], [true], [true], [true], [true], [true], [false], [true]]}", "source": "taco"} | You received a whatsup message from an unknown number. Could it be from that girl/boy with a foreign accent you met yesterday evening?
Write a simple regex to check if the string contains the word hallo in different languages.
These are the languages of the possible people you met the night before:
* hello - english... | 0 |
{"tests": "{\"inputs\": [\"20289\\n\", \"31775\\n\", \"1\\n\", \"82801\\n\", \"32866\\n\", \"99996\\n\", \"99997\\n\", \"43670\\n\", \"79227\\n\", \"3\\n\", \"86539\\n\", \"5188\\n\", \"99998\\n\", \"100000\\n\", \"4\\n\", \"99999\\n\", \"31809\\n\", \"77859\\n\", \"53022\\n\", \"4217\\n\", \"60397\\n\", \"12802\\n\", ... | A few years ago Sajjad left his school and register to another one due to security reasons. Now he wishes to find Amir, one of his schoolmates and good friends.
There are n schools numerated from 1 to n. One can travel between each pair of them, to do so, he needs to buy a ticket. The ticker between schools i and j co... | 0.375 |
{"tests": "{\"inputs\": [\"5\\n1 2 3 2 1\\n\", \"3\\n10 6 8\\n\", \"7\\n1 2 1 2 1 2 1\\n\", \"7\\n1 2 1 2 1 3 1\\n\", \"5\\n1 1 4 2 2\\n\", \"6\\n1 3 4 3 5 4\\n\", \"1\\n1\\n\", \"7\\n6 2 2 6 5 7 7\\n\", \"7\\n2 4 1 2 3 1 2\\n\", \"7\\n2 1 2 1 2 2 1\\n\", \"7\\n5 2 4 2 4 1 1\\n\", \"6\\n3 2 1 7 3 7\\n\", \"100\\n82 51 ... | This is a harder version of the problem. In this version $n \le 500\,000$
The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the c... | 0 |
{"tests": "{\"inputs\": [\"9\\n7 4 4 5 0 6 5 4 10\\n4\\n5 2 10 9\\n\", \"13\\n55 160 86 99 92 148 81 36 216 191 214 127 44\\n85\\n92 12 64 21 221 225 119 243 147 47 244 112 212 237 209 121 81 239 43 104 3 254 52 13 1 210 28 18 199 75 251 146 77 28 253 211 50 35 42 160 157 104 155 37 241 78 42 190 150 228 193 96 190 178... | This problem differs from one which was on the online contest.
The sequence a1, a2, ..., an is called increasing, if ai < ai + 1 for i < n.
The sequence s1, s2, ..., sk is called the subsequence of the sequence a1, a2, ..., an, if there exist such a set of indexes 1 ≤ i1 < i2 < ... < ik ≤ n that aij = sj. In other wo... | 0.375 |
{"tests": "{\"inputs\": [\"3\\n2 2\\n3 4\\n5 6\", \"3\\n-10 1\\n3 7\\n-4 -2\", \"5\\n-4 0\\n-2 0\\n7 8\\n9 10\\n-2 -1\", \"3\\n2 2\\n3 4\\n10 6\", \"3\\n-10 1\\n5 7\\n-4 -2\", \"3\\n3 2\\n3 4\\n20 6\", \"3\\n3 4\\n3 4\\n20 6\", \"3\\n-10 1\\n2 7\\n0 -2\", \"3\\n3 4\\n3 4\\n28 6\", \"5\\n-3 0\\n0 -1\\n7 8\\n9 11\\n-1 -1... | Takahashi and Aoki will play a game with a number line and some segments. Takahashi is standing on the number line and he is initially at coordinate 0. Aoki has N segments. The i-th segment is [L_i,R_i], that is, a segment consisting of points with coordinates between L_i and R_i (inclusive).
The game has N steps. The... | 0 |
{"tests": "{\"inputs\": [\"11 3\\n\", \"11 6\\n\", \"20 20\\n\", \"14 5\\n\", \"1000000 100\\n\", \"1 1\\n\", \"2 1\\n\", \"100 4\\n\", \"502333439 2047\\n\", \"773014587697599 31\\n\", \"946338791423 262143\\n\", \"1000000000 4\\n\", \"13 2\\n\", \"1073741821 2\\n\", \"1000000000 100\\n\", \"1000000000 1000000000\\n\"... | At first, let's define function $f(x)$ as follows: $$ \begin{matrix} f(x) & = & \left\{ \begin{matrix} \frac{x}{2} & \mbox{if } x \text{ is even} \\ x - 1 & \mbox{otherwise } \end{matrix} \right. \end{matrix} $$
We can see that if we choose some value $v$ and will apply function $f$ to it, then apply $f$ to $f(v)$, an... | 0 |
{"tests": "{\"inputs\": [\"NEAT\\n\", \"WORD\\n\", \"CODER\\n\", \"APRILFOOL\\n\", \"AI\\n\", \"JUROR\\n\", \"YES\\n\", \"Q\\n\", \"PUG\\n\", \"SOURPUSS\\n\", \"CROUP\\n\", \"BURG\\n\", \"DODO\\n\", \"WET\\n\", \"MAYFLY\\n\", \"VITALIZE\\n\", \"KHAKI\\n\", \"WAXY\\n\", \"WEEVIL\\n\", \"THIAMINE\\n\", \"ALKALINITY\\n\",... | -----Input-----
The input consists of a single string of uppercase letters A-Z. The length of the string is between 1 and 10 characters, inclusive.
-----Output-----
Output "YES" or "NO".
-----Examples-----
Input
NEAT
Output
YES
Input
WORD
Output
NO
Input
CODER
Output
NO
Input
APRILFOOL
Output
NO
Input
AI
... | 0 |
{"tests": "{\"inputs\": [\"1 3\\n\", \"10 15\\n\", \"1 100\\n\", \"100 10000\\n\", \"213 221442\\n\", \"1 1000000\\n\", \"1000000 1000000\\n\", \"222145 353252\\n\", \"2 1000000\\n\", \"1 999999\\n\", \"192 200\\n\", \"222145 353252\\n\", \"1 100\\n\", \"192 200\\n\", \"213 221442\\n\", \"100 10000\\n\", \"1000000 1000... | Once Max found an electronic calculator from his grandfather Dovlet's chest. He noticed that the numbers were written with seven-segment indicators (https://en.wikipedia.org/wiki/Seven-segment_display). [Image]
Max starts to type all the values from a to b. After typing each number Max resets the calculator. Find the... | 0.875 |
{"tests": "{\"inputs\": [[[1, 0, 1]], [[1, 1]], [[1]], [[0]], [[1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0]], [[1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0]]], \"outputs\": [[[1, 1, 1]], [[1, 0]], [[... | Gray code is a form of binary encoding where transitions between consecutive numbers differ by only one bit. This is a useful encoding for reducing hardware data hazards with values that change rapidly and/or connect to slower hardware as inputs. It is also useful for generating inputs for Karnaugh maps.
Here is an ex... | 0 |
{"tests": "{\"inputs\": [\"5 16\\n1 1 2 2 3\\n\", \"10 90\\n1 1 1 1 1 1 1 1 1 2\\n\", \"3 3\\n1 1 2\\n\", \"5 15\\n1 1 1 2 2\\n\", \"100 4755\\n5 4 3 5 1 2 5 1 1 3 5 4 4 1 1 1 1 5 4 4 5 1 5 5 1 2 1 3 1 5 1 3 3 3 2 2 2 1 1 5 1 3 4 1 1 3 2 5 2 2 5 5 4 4 1 3 4 3 3 4 5 3 3 3 1 2 1 4 2 4 4 1 5 1 3 5 5 5 5 3 4 4 3 1 2 5 2 3 ... | You've got another problem dealing with arrays. Let's consider an arbitrary sequence containing n (not necessarily different) integers a1, a2, ..., an. We are interested in all possible pairs of numbers (ai, aj), (1 ≤ i, j ≤ n). In other words, let's consider all n2 pairs of numbers, picked from the given array.
For e... | 0 |
{"tests": "{\"inputs\": [\"3 4 4\\n1101\\n0110\\n1101\\n1 1 3 4\\n1 1 3 1\\n2 2 3 4\\n1 2 3 4\", \"5 5 6\\n11010\\n01110\\n10101\\n11101\\n01010\\n1 1 5 5\\n1 2 4 5\\n2 3 3 5\\n3 3 3 3\\n3 1 3 5\\n1 1 3 4\", \"5 5 6\\n11010\\n01110\\n10101\\n11101\\n01010\\n1 1 5 5\\n1 2 4 5\\n2 3 3 5\\n5 3 3 3\\n3 1 3 5\\n1 1 3 4\", \... | Nuske has a grid with N rows and M columns of squares. The rows are numbered 1 through N from top to bottom, and the columns are numbered 1 through M from left to right. Each square in the grid is painted in either blue or white. If S_{i,j} is 1, the square at the i-th row and j-th column is blue; if S_{i,j} is 0, the ... | 0 |
{"tests": "{\"inputs\": [\"5\\n3 4\\n0 0 0 0\\n0 1 0 0\\n-1 0 0 0\\n2 2\\n3 0\\n0 0\\n2 2\\n0 0\\n0 0\\n2 3\\n0 0 0\\n0 4 0\\n4 4\\n0 0 0 0\\n0 2 0 1\\n0 0 0 0\\n0 0 0 0\\n\", \"5\\n3 4\\n0 0 0 0\\n0 1 0 0\\n-1 0 0 0\\n2 2\\n3 0\\n0 0\\n2 2\\n0 0\\n0 0\\n2 3\\n-1 0 0\\n0 0 0\\n4 4\\n0 0 0 -1\\n0 2 0 2\\n0 1 0 0\\n0 0 0... | You are given a grid with n rows and m columns, where each cell has a non-negative integer written on it. We say the grid is good if for each cell the following condition holds: if it has a number k > 0 written on it, then exactly k of its neighboring cells have a number greater than 0 written on them. Note that if the... | 0 |
{"tests": "{\"inputs\": [\"5\\nbb?a?\\n1\\n\", \"9\\nab??ab???\\n3\\n\", \"6\\nab??ab\\n4\\n\", \"14\\n?abaa?abb?b?a?\\n3\\n\", \"17\\nb??a?abbbaaababba\\n4\\n\", \"1\\nb\\n1\\n\", \"3\\nb?a\\n1\\n\", \"12\\naba?bbaaabbb\\n1\\n\", \"43\\n????aabaababa?aaaa?abbbabbb?ab??baabbbbbabb\\n5\\n\", \"36\\nbbaa??aab?aabbb?ba?b?... | Vasya wrote down two strings s of length n and t of length m consisting of small English letters 'a' and 'b'. What is more, he knows that string t has a form "abab...", namely there are letters 'a' on odd positions and letters 'b' on even positions.
Suddenly in the morning, Vasya found that somebody spoiled his string... | 0 |
{"tests": "{\"inputs\": [\"2 1 0\", \"1 1 0\", \"0 2 0\", \"1 0 1\", \"2 0 0\", \"1 0 0\", \"2 2 1\", \"2 0 1\", \"3 2 0\", \"3 0 1\", \"3 3 0\", \"3 1 1\", \"6 3 0\", \"2 1 1\", \"6 3 1\", \"4 1 1\", \"6 3 2\", \"4 2 1\", \"6 0 2\", \"5 2 1\", \"6 0 1\", \"7 2 1\", \"7 4 1\", \"7 7 1\", \"7 7 2\", \"7 7 3\", \"10 7 3\... | For a string S, let f(S) be the lexicographically smallest cyclic shift of S. For example, if S = `babca`, f(S) = `ababc` because this is the smallest among all cyclic shifts (`babca`, `abcab`, `bcaba`, `cabab`, `ababc`).
You are given three integers X, Y, and Z. You want to construct a string T that consists of exact... | 0 |
{"tests": "{\"inputs\": [\"13 1\\n761.044449428\\n\", \"35 8\\n984227318.2031144444444444494637612\\n\", \"31 15\\n2707786.24030444444444444724166\\n\", \"3 1\\n0.1\\n\", \"9 2\\n23999.448\\n\", \"12 5\\n872.04488525\\n\", \"320 142\\n2704701300865535.43222331223343411413001111322010242013132301034414420112430314444444... | Efim just received his grade for the last test. He studies in a special school and his grade can be equal to any positive decimal fraction. First he got disappointed, as he expected a way more pleasant result. Then, he developed a tricky plan. Each second, he can ask his teacher to round the grade at any place after th... | 0 |
{"tests": "{\"inputs\": [\"5 1 2\\n9 7 11 15 5\\n\", \"2 100000 569\\n605 986\\n\", \"10 10 98\\n1 58 62 71 55 4 20 17 25 29\\n\", \"100 100 96\\n11 79 47 73 77 66 50 32 26 38 8 58 45 86 35 49 63 13 35 61 52 44 16 80 32 18 8 4 49 90 78 83 72 3 86 71 96 93 97 60 43 74 58 61 21 96 43 92 31 23 64 60 14 77 27 45 71 27 49 4... | Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need to improve. Jon now t... | 0.125 |
{"tests": "{\"inputs\": [\"2000\\n0234++7890\", \"1\\n46\", \"100\\n66\", \"10\\n239\", \"10\\n151\", \"10\\n3363\", \"10\\n++0+\", \"2000\\n0987++4320\", \"1\\n83\", \"100\\n61\", \"10\\n437\", \"2000\\n0947++8320\", \"1\\n27\", \"100\\n25\", \"2000\\n0947++3820\", \"1\\n54\", \"100\\n45\", \"10\\n64\", \"2000\\n0947+... | You are given an integer $N$ and a string consisting of '+' and digits. You are asked to transform the string into a valid formula whose calculation result is smaller than or equal to $N$ by modifying some characters. Here, you replace one character with another character any number of times, and the converted string s... | 0 |
{"tests": "{\"inputs\": [\"7\\n3\\n237\\n5\\n44444\\n3\\n221\\n2\\n35\\n3\\n773\\n1\\n4\\n30\\n626221626221626221626221626221\\n\", \"1\\n2\\n77\\n\", \"1\\n2\\n77\\n\", \"1\\n2\\n83\\n\", \"1\\n2\\n27\\n\", \"1\\n2\\n31\\n\", \"1\\n2\\n22\\n\", \"1\\n2\\n42\\n\", \"7\\n3\\n237\\n5\\n44444\\n3\\n221\\n2\\n35\\n3\\n773\... | During the hypnosis session, Nicholas suddenly remembered a positive integer $n$, which doesn't contain zeros in decimal notation.
Soon, when he returned home, he got curious: what is the maximum number of digits that can be removed from the number so that the number becomes not prime, that is, either composite or equ... | 0.375 |
{"tests": "{\"inputs\": [\"1 5\\n5 2\\n\", \"0 1\\n0 0\\n\", \"-100 -100\\n100 100\\n\", \"-100 -100\\n-100 100\\n\", \"-100 -100\\n100 -100\\n\", \"100 -100\\n-100 -100\\n\", \"100 -100\\n-100 100\\n\", \"100 -100\\n100 100\\n\", \"-100 100\\n-100 -100\\n\", \"-100 100\\n100 -100\\n\", \"-100 100\\n100 100\\n\", \"100... | Polycarp takes part in a quadcopter competition. According to the rules a flying robot should:
start the race from some point of a field, go around the flag, close cycle returning back to the starting point.
Polycarp knows the coordinates of the starting point (x_1, y_1) and the coordinates of the point where th... | 0 |
{"tests": "{\"inputs\": [\"1 2\\nST\\n\", \"3 3\\n**T\\n*S*\\n***\\n\", \"2 2\\nTS\\n.*\\n\", \"2 2\\nS.\\n.T\\n\", \"3 3\\nT.*\\n*.*\\n*S*\\n\", \"3 3\\n*..\\n...\\nTS.\\n\", \"2 2\\n.T\\nS*\\n\", \"2 2\\nST\\n*.\\n\", \"7 7\\n.S.****\\n...*.*.\\n.****..\\n.*.**.*\\n..T*...\\n***..*.\\n*******\\n\", \"3 1\\nS\\n*\\nT\... | Woken up by the alarm clock Igor the financial analyst hurried up to the work. He ate his breakfast and sat in his car. Sadly, when he opened his GPS navigator, he found that some of the roads in Bankopolis, the city where he lives, are closed due to road works. Moreover, Igor has some problems with the steering wheel,... | 0.625 |
{"tests": "{\"inputs\": [\"5 4\\n1 2\\n2 3\\n1 4\\n4 3\\n\", \"4 12\\n1 2\\n1 3\\n1 4\\n2 1\\n2 3\\n2 4\\n3 1\\n3 2\\n3 4\\n4 1\\n4 2\\n4 3\\n\", \"1 0\\n\", \"10 20\\n6 10\\n4 2\\n1 5\\n6 1\\n8 9\\n1 3\\n2 6\\n9 7\\n4 5\\n3 7\\n9 2\\n3 9\\n4 8\\n1 10\\n6 9\\n8 5\\n7 6\\n1 8\\n8 10\\n5 6\\n\", \"3000 0\\n\", \"1 0\\n\"... | Tomash keeps wandering off and getting lost while he is walking along the streets of Berland. It's no surprise! In his home town, for any pair of intersections there is exactly one way to walk from one intersection to the other one. The capital of Berland is very different!
Tomash has noticed that even simple cases of... | 0.25 |
{"tests": "{\"inputs\": [\"4\\n1001\\n\", \"1\\n1\\n\", \"100\\n1110111100001111011111111010110011111111011110000111101101011100110110001011000000101010110101011100\\n\", \"100\\n1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\\n\", \"100\\n11111111111111111111111111... | String can be called correct if it consists of characters "0" and "1" and there are no redundant leading zeroes. Here are some examples: "0", "10", "1001".
You are given a correct string s.
You can perform two different operations on this string: swap any pair of adjacent characters (for example, "101" $\rightarrow... | 0.625 |
{"tests": "{\"inputs\": [\"3\\n2 2\\n2 3\\n1 3\", \"3\\n0 2\\n2 3\\n1 3\", \"3\\n0 2\\n2 3\\n1 5\", \"3\\n0 2\\n2 5\\n1 5\", \"3\\n0 2\\n2 10\\n1 5\", \"3\\n0 2\\n2 10\\n1 7\", \"3\\n2 2\\n2 3\\n2 3\", \"3\\n0 2\\n2 4\\n1 5\", \"3\\n0 1\\n2 5\\n1 5\", \"3\\n0 2\\n2 10\\n2 5\", \"3\\n-1 2\\n2 10\\n1 0\", \"3\\n-2 2\\n4 ... | As you might know, cooking is the process of taking a food item and subjecting it to various processes(like heating, roasting, baking etc).
A food item gets prepared after it has been subjected to exactly N processes.
The order in which the processes are applied matters(heating and then baking is different from baking ... | 0.25 |
{"tests": "{\"inputs\": [[[1, 2, 3], [1, 2, 3, 4, 5]], [[1, 2, 3, 4], [1, 2, 3, 5]], [[1, 2, 3, 4, 5], []], [[1, 2, 3], [1, 2, 3]], [[6, 6, 6, 6, 6, 6], [6, null, null, 6, 6, null]], [[6], [6, 6, 6, 6, 6, 6]], [[], []], [[null], [null]]], \"outputs\": [[0.6], [0.75], [0.0], [1.0], [0.5], [0.16666666666666666], [1.0], [... | Calculate the number of items in a vector that appear at the same index in each vector, with the same value.
```python
vector_affinity([1, 2, 3, 4, 5], [1, 2, 2, 4, 3]) # => 0.6
vector_affinity([1, 2, 3], [1, 2, 3]) # => 1.0
```
Affinity value should be realized on a scale of 0.0 to 1.0, with 1.0 being absolut... | 0 |
{"tests": "{\"inputs\": [\"15\\n3.13979,8.51743\\n2.39506,3.84915\\n2.68432,5.39095\\n5.61904,9.16332\\n7.85653,4.75593\\n2.84021,5.41511\\n1.79500,8.59211\\n7.55389,8.17604\\n4.70665,4.66125\\n1.63470,4.42538\\n7.34959,4.61981\\n5.09003,8.11122\\n5.24373,1.30066\\n0.13517,1.83659\\n7.57313,1.58150\\n0\", \"15\\n3.1397... | Stick n circular stickers with a radius of 1 on a square origami paper with a side length of 10. The stickers can be stacked. Create a program that reads the coordinates of the position where the stickers are to be attached and outputs the number of stickers at the place where the stickers overlap most on the origami p... | 0 |
{"tests": "{\"inputs\": [\"1\\n1\\n3\\n1 1\\n1 1\\n1 1\\n\", \"1\\n1000000000\\n1\\n1 1\\n\", \"2\\n1 10\\n3\\n2 2\\n2 1\\n1 1\\n\", \"2\\n3922 3922\\n3\\n2 2\\n2 1\\n1 1\\n\", \"5\\n3 1 4 1 2\\n15\\n5 5\\n5 4\\n5 3\\n5 2\\n5 1\\n4 4\\n4 3\\n4 2\\n4 1\\n3 3\\n3 2\\n3 1\\n2 2\\n2 1\\n1 1\\n\", \"2\\n392222 322\\n3\\n2 2... | This is the harder version of the problem. In this version, 1 ≤ n, m ≤ 2⋅10^5. You can hack this problem if you locked it. But you can hack the previous problem only if you locked both problems.
You are given a sequence of integers a=[a_1,a_2,...,a_n] of length n. Its subsequence is obtained by removing zero or more e... | 0.25 |
{"tests": "{\"inputs\": [\"5\\n1 -10 100 -1000 -10000\\n\", \"2\\n0 -17\\n\", \"2\\n7 0\\n\", \"5\\n5 0 5 5 5\\n\", \"14\\n1 1 -2 4 -8 16 -32 64 -128 256 -512 1024 -2048 4096\\n\", \"8\\n729 243 81 27 9 9 3 1\\n\", \"4\\n-1 -1 -1 1\\n\", \"2\\n-17 -527\\n\", \"14\\n1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192\\n\",... | Polycarp loves geometric progressions — he collects them. However, as such progressions occur very rarely, he also loves the sequences of numbers where it is enough to delete a single element to get a geometric progression.
In this task we shall define geometric progressions as finite sequences of numbers a1, a2, ...,... | 0 |
{"tests": "{\"inputs\": [\"1 1\\n3 1\\n3 3\\n3 2\\n3\\n3 12\\n9 3\\n11 12\\n8 7\\n5\\n15 3\\n17 7\\n22 5\\n7 6\\n5\\n6 11\\n8 2\\n16 9\\n10 8\\n2\\n0 0\", \"2 1\\n3 1\\n3 3\\n3 2\\n3\\n3 12\\n9 3\\n11 12\\n8 7\\n5\\n15 3\\n17 7\\n22 5\\n7 6\\n5\\n6 11\\n8 2\\n16 9\\n15 8\\n0\\n0 0\", \"2 1\\n3 1\\n3 3\\n3 2\\n3\\n3 12\... | Create a program to determine the positional relationship between a triangle and a circle on a plane. All target figures shall include boundaries. The triangle is given the position of three vertices, and the circle is given the position of the center and the radius. The position is given by a set of two integers in a ... | 0 |
{"tests": "{\"inputs\": [\"1\\n100 26\\ns................PPPP.CCCCC..UUUUUU.........YYYQQQQQQQ...GGGGG............MMM.....JJJJ..............\\n.OOOOOO....EEE....................................................SSSSSS........LLLLLL......NNNIIII.\\n......FFFFFF...VVVV..ZZZBBB...KKKKK..WWWWWWWXXX..RRRRRRR......AAAAADDDDDDD... | The mobile application store has a new game called "Subway Roller".
The protagonist of the game Philip is located in one end of the tunnel and wants to get out of the other one. The tunnel is a rectangular field consisting of three rows and n columns. At the beginning of the game the hero is in some cell of the leftmo... | 0 |
{"tests": "{\"inputs\": [\"8 4\\n2 1 3 1 1 5 1 3\\n2 3 2 4 1 0 2 1\\n0 3 0 2 1 1 4 2\\n1 2 3 2 1 1 5 4\\n0 2 0 1 1 3 2 1\\n1 3 1 2 2 4 3 2\\n5 1 2 1 4 1 1 5\\n4 1 1 0 1 2 2 1\\n2 -1 -1 -1\\n0 3 -1 -1\\n-1 2 2 4\\n-1 1 -1 1\\n5 3\\n1 0 2 3 5\\n2 3 7 2 1\\n2 5 4 2 2\\n8 9 0 3 3\\n3 6 0 4 7\\n-1 -1 2\\n-1 3 5\\n0 4 -1\\n... | Mr. A came to Aizu for sightseeing. You can overlook the Aizu Basin from the window of the hotel where you stayed. As I was looking at the scenery, I noticed a piece of the photo on the floor. Apparently I took the outside view from the window. "Which area did you take?" A asked, holding the photo so that the view outs... | 0 |
{"tests": "{\"inputs\": [\"abcabab\\nab\\n\", \"aa\\naaaaaaa\\n\", \"aba\\nbaaab\\n\", \"aa\\nabaaaaa\", \"abcaabb\\nab\", \"aba\\naaaab\", \"aa\\naaaaaba\", \"aba\\naa`ab\", \"accaabb\\nab\", \"ab\\naaaaaba\", \"`ba\\naa`ab\", \"acdaabb\\nab\", \"ab\\nabaaaaa\", \"`ab\\naa`ab\", \"acda`bb\\nab\", \"ab\\nabaaaba\", \"a... | Given are two strings s and t consisting of lowercase English letters. Determine if the number of non-negative integers i satisfying the following condition is finite, and find the maximum value of such i if the number is finite.
- There exists a non-negative integer j such that the concatenation of i copies of t is a... | 0 |
{"tests": "{\"inputs\": [\"3 3\\n1 2\\n2 3\\n1 3\\n\", \"5 0\\n\", \"7 8\\n7 1\\n1 3\\n6 2\\n2 3\\n7 2\\n2 4\\n7 3\\n6 3\\n\", \"5 6\\n3 2\\n2 1\\n1 4\\n4 5\\n3 1\\n1 5\\n\", \"10 11\\n4 10\\n8 10\\n1 3\\n8 9\\n5 9\\n5 6\\n5 1\\n1 6\\n10 5\\n7 5\\n10 1\\n\", \"20 23\\n8 6\\n20 12\\n18 2\\n6 19\\n2 20\\n19 1\\n3 13\\n12... | You are given a directed acyclic graph, consisting of $n$ vertices and $m$ edges. The vertices are numbered from $1$ to $n$. There are no multiple edges and self-loops.
Let $\mathit{in}_v$ be the number of incoming edges (indegree) and $\mathit{out}_v$ be the number of outgoing edges (outdegree) of vertex $v$.
You ar... | 0 |
{"tests": "{\"inputs\": [\"1\\n3\\n2 3 1\\n\", \"3\\n7\\n2 3 6 4 1 10 11\\n3\\n4 1 12\\n5\\n1 4 7 9 2\\n\", \"3\\n7\\n2 3 6 4 1 10 11\\n3\\n4 1 12\\n5\\n0 4 7 9 2\\n\", \"3\\n7\\n2 3 4 4 1 10 11\\n3\\n4 1 12\\n5\\n0 4 7 9 2\\n\", \"1\\n3\\n4 3 1\\n\", \"4\\n3\\n8 1 2\\n4\\n6 9 4 2\\n9\\n1 2 3 4 5 1 7 8 9\\n3\\n200 199 ... | A bow adorned with nameless flowers that bears the earnest hopes of an equally nameless person.
You have obtained the elegant bow known as the Windblume Ode. Inscribed in the weapon is an array of n (n ≥ 3) positive distinct integers (i.e. different, no duplicates are allowed).
Find the largest subset (i.e. having th... | 0 |
{"tests": "{\"inputs\": [\"the cost of one peach is higher than th`t of one apple.\", \"the cost of ooe peach is higher than th`t of one apple.\", \"the cost of ooe peach is higher than th`t of eno apple.\", \"the cpst of ooe peach is higher than th`t of eno apple.\", \"the cpst of ooe peach is higher than t`ht of eno ... | Fukushima Prefecture is also famous for producing fruits, and among them, peaches and apples boast one of the highest production volumes in Japan. By the way, when I made a print manuscript of an English pamphlet for sale, I mistakenly wrote the description about apples and the description about peaches in reverse.
Yo... | 0.125 |
{"tests": "{\"inputs\": [[9, 2], [10, 2], [11, 2], [21, 1.5], [454, 5], [455, 5], [4, 4], [3, 4], [0, 4], [-1, 4]], \"outputs\": [[1], [2], [2], [3], [5], [6], [1], [0], [0], [0]]}", "source": "taco"} | Let's pretend your company just hired your friend from college and paid you a referral bonus. Awesome! To celebrate, you're taking your team out to the terrible dive bar next door and using the referral bonus to buy, and build, the largest three-dimensional beer can pyramid you can. And then probably drink those beers,... | 0 |
{"tests": "{\"inputs\": [\"1\\n1048576 2097152 35\\n\", \"1\\n131072 262144 33\\n\", \"1\\n1048576 2097152 18\\n\", \"1\\n131072 262144 46\\n\", \"8\\n36 48 2\\n36 48 3\\n36 48 4\\n2 8 1\\n2 8 2\\n1000000000 1000000000 1000100000\\n1 2 1\\n2 2 1\\n\", \"8\\n36 48 2\\n36 48 3\\n36 48 4\\n2 8 1\\n2 8 2\\n1000000000 10000... | You are given two integers a and b. In one turn, you can do one of the following operations:
* Take an integer c (c > 1 and a should be divisible by c) and replace a with a/c;
* Take an integer c (c > 1 and b should be divisible by c) and replace b with b/c.
Your goal is to make a equal to b using exactly k ... | 0.125 |
{"tests": "{\"inputs\": [\"3 1\\n-1 0 1\\n\", \"2 1\\n1 0\\n\", \"1 1\\n-1\\n\", \"1 0\\n-1\\n\", \"1 1\\n0\\n\", \"5 1\\n-1 -1 -1 -1 -1\\n\", \"5 0\\n-1 -1 -1 -1 -1\\n\", \"10 1\\n1 1 1 1 0 0 0 1 0 0\\n\", \"50 1\\n-1 -1 1 0 1 1 0 -1 1 0 -1 -1 0 0 -1 -1 0 1 1 -1 1 0 -1 1 1 -1 -1 -1 1 -1 -1 0 -1 0 -1 0 0 -1 -1 0 1 -1 0... | Kuro has recently won the "Most intelligent cat ever" contest. The three friends then decided to go to Katie's home to celebrate Kuro's winning. After a big meal, they took a small break then started playing games.
Kuro challenged Katie to create a game with only a white paper, a pencil, a pair of scissors and a lot o... | 0 |
{"tests": "{\"inputs\": [\"4 3\\n0 1 W\\n1 2 W\\n5 3 B\\n5 4 B\\n\", \"2 1000\\n0 0 B\\n0 1 W\\n\", \"6 2\\n1 2 B\\n2 1 W\\n2 2 B\\n1 0 B\\n0 6 W\\n4 5 W\\n\", \"6 2\\n1 2 B\\n2 1 W\\n0 2 B\\n1 0 B\\n0 6 W\\n4 5 W\", \"4 3\\n0 1 W\\n1 0 W\\n5 3 B\\n5 4 B\", \"2 1000\\n1 0 B\\n0 1 W\", \"2 0001\\n1 -1 B\\n0 1 X\", \"0 0... | AtCoDeer is thinking of painting an infinite two-dimensional grid in a checked pattern of side K.
Here, a checked pattern of side K is a pattern where each square is painted black or white so that each connected component of each color is a K × K square.
Below is an example of a checked pattern of side 3:
AtCoDeer has ... | 0 |
{"tests": "{\"inputs\": [[[1], [1]], [[1, 2], [1]], [[1, 2, 3, 4], [4, 3, 2, 1]], [[], []], [[1, 2, 3, 4, 5, 6], []], [[], [1, 2, 3, 4, 5, 6]]], \"outputs\": [[[2]], [[2, 2]], [[5, 5, 5, 5]], [[]], [[1, 2, 3, 4, 5, 6]], [[1, 2, 3, 4, 5, 6]]]}", "source": "taco"} | ## Nova polynomial add
This kata is from a series on polynomial handling. ( [#1](http://www.codewars.com/kata/nova-polynomial-1-add-1) [#2](http://www.codewars.com/kata/570eb07e127ad107270005fe) [#3](http://www.codewars.com/kata/5714041e8807940ff3001140 ) [#4](http://www.codewars.com/kata/571a2e2df24bdfd4e20001f5) )
... | 0 |
{"tests": "{\"inputs\": [\"12\\n\", \"908209\\n\", \"999958\\n\", \"6\\n\", \"1452\\n\", \"570570\\n\", \"959878\\n\", \"15\\n\", \"959806\\n\", \"959818\\n\", \"16\\n\", \"896809\\n\", \"974859\\n\", \"9\\n\", \"665280\\n\", \"166320\\n\", \"974931\\n\", \"720721\\n\", \"974847\\n\", \"4\\n\", \"81\\n\", \"531440\\n\"... | Alice and Bob begin their day with a quick game. They first choose a starting number X0 ≥ 3 and try to reach one million by the process described below.
Alice goes first and then they take alternating turns. In the i-th turn, the player whose turn it is selects a prime number smaller than the current number, and anno... | 0 |
{"tests": "{\"inputs\": [[\"abab\", \"apple banana apple banana\"], [\"abba\", \"car truck truck car\"], [\"abab\", \"apple banana banana apple\"], [\"aaaa\", \"cat cat cat cat\"], [\"aaaa\", \"cat cat dog cat\"], [\"bbbabcb\", \"c# c# c# javascript c# python c#\"], [\"abcdef\", \"apple banana cat donkey elephant flowe... | Write
```python
word_pattern(pattern, string)
```
that given a ```pattern``` and a string ```str```, find if ```str``` follows the same sequence as ```pattern```.
For example:
```python
word_pattern('abab', 'truck car truck car') == True
word_pattern('aaaa', 'dog dog dog dog') == True
word_pattern('abab', 'apple bana... | 0 |
{"tests": "{\"inputs\": [\"6 1 654321100 654321115\\n\", \"10 7 987654339 987654340\\n\", \"7 8 305686738 573739036\\n\", \"10 1 100 1000000000\\n\", \"3 12 987654345 987654347\\n\", \"1 1 1 1000000000\\n\", \"2 2 987654333 987654335\\n\", \"3 3 240953737 404170887\\n\", \"11 4 987654330 987654343\\n\", \"2 1 1 1000000... | Sometimes Mister B has free evenings when he doesn't know what to do. Fortunately, Mister B found a new game, where the player can play against aliens.
All characters in this game are lowercase English letters. There are two players: Mister B and his competitor.
Initially the players have a string s consisting of the... | 0 |
{"tests": "{\"inputs\": [\"5\\n5\\n11010\\n11010\\n2\\n01\\n11\\n3\\n000\\n101\\n9\\n100010111\\n101101100\\n9\\n001011011\\n011010101\\n\", \"5\\n5\\n11000\\n11010\\n2\\n01\\n11\\n3\\n000\\n101\\n9\\n100010111\\n101101100\\n9\\n001011011\\n011010101\\n\", \"5\\n5\\n11010\\n11010\\n2\\n01\\n11\\n3\\n100\\n101\\n9\\n100... | There are $n$ candles on a Hanukkah menorah, and some of its candles are initially lit. We can describe which candles are lit with a binary string $s$, where the $i$-th candle is lit if and only if $s_i=1$.
Initially, the candle lights are described by a string $a$. In an operation, you select a candle that is current... | 0 |
{"tests": "{\"inputs\": [\"4 4\\n1 2\\n2 3\\n3 4\\n4 1\\n\", \"4 3\\n2 1\\n2 3\\n4 3\\n\", \"10 20\\n2 1\\n7 9\\n10 2\\n4 9\\n3 1\\n6 4\\n3 6\\n2 9\\n5 2\\n3 9\\n6 8\\n8 7\\n10 4\\n7 4\\n8 5\\n3 4\\n6 7\\n2 6\\n10 6\\n3 8\\n\", \"10 9\\n8 5\\n3 5\\n3 7\\n10 6\\n4 6\\n8 1\\n9 2\\n4 2\\n9 7\\n\", \"50 49\\n1 3\\n6 46\\n4... | You are given a directed graph of $n$ vertices and $m$ edges. Vertices are numbered from $1$ to $n$. There is a token in vertex $1$.
The following actions are allowed: Token movement. To move the token from vertex $u$ to vertex $v$ if there is an edge $u \to v$ in the graph. This action takes $1$ second. Graph tran... | 0.625 |
{"tests": "{\"inputs\": [\"20 20\\n1 1\\n9 9\\n7\\n2 0 1 1\\n5 1 1 3\\n2 1 3 3\\n1 1 5 2\\n5 1 7 3\\n2 0 2 7\\n2 0 6 8\\n20 20\\n9 9\\n1 1\\n6\\n2 0 1 1\\n1 0 5 1\\n2 1 1 3\\n5 0 1 7\\n3 1 6 5\\n4 1 8 5\\n0 0\", \"20 20\\n1 1\\n9 9\\n7\\n2 0 1 1\\n5 1 1 3\\n2 1 3 3\\n1 1 5 2\\n5 1 7 3\\n2 0 4 7\\n2 -1 6 8\\n20 20\\n9 9... | Relative B came to Mr. A's house. He is 3 years old and loves blocks. The block he has is shaped like Figure 1.
<image>
Figure 1
Mr. B is laying blocks on the board. When I asked him, "What are you making?", He replied cheerfully, "Maze !!". The maze he says is the arrangement of blocks that are in contact with each... | 0.375 |
{"tests": "{\"inputs\": [\"16\\nfun while return var { } ( ) , ; > = + ++ - --\\n9\\nfun fib(num) { # compute fibs\\n var return_value = 1, prev = 0, temp;\\n while (num > 0) {\\n temp = return_value; return_value = return_value + prev;\\n prev = temp;\\n num--;\\n }\\n return return_value;\\n}\\n\", \"10\... | International Coding Procedures Company (ICPC) writes all its code in Jedi Script (JS) programming language. JS does not get compiled, but is delivered for execution in its source form. Sources contain comments, extra whitespace (including trailing and leading spaces), and other non-essential features that make them qu... | 0 |
{"tests": "{\"inputs\": [\"0 1 1\\n1 0 1\\n1 1 0\\n3\\n\", \"0 2 2\\n1 0 100\\n1 2 0\\n3\\n\", \"0 2 1\\n1 0 100\\n1 2 0\\n5\\n\", \"0 5835 1487\\n6637 0 9543\\n6961 6820 0\\n7\\n\", \"0 3287 5433\\n6796 0 5787\\n1445 6158 0\\n26\\n\", \"0 4449 3122\\n6816 0 8986\\n1048 1468 0\\n4\\n\", \"0 913 8129\\n8352 0 4408\\n907... | The Tower of Hanoi is a well-known mathematical puzzle. It consists of three rods, and a number of disks of different sizes which can slide onto any rod. The puzzle starts with the disks in a neat stack in ascending order of size on one rod, the smallest at the top, thus making a conical shape.
The objective of the pu... | 0 |
{"tests": "{\"inputs\": [\"1\\n111546435\\n\", \"10\\n6295 3400 4042 2769 3673 264 5932 4977 1776 5637\\n\", \"5\\n387420489 244140625 387420489 387420489 1\\n\", \"2\\n5 10\\n\", \"20\\n16777216 1048576 524288 8192 8192 524288 2097152 8388608 1048576 67108864 16777216 1048576 4096 8388608 134217728 67108864 1048576 53... | You are given an integer m as a product of integers a1, a2, ... an <image>. Your task is to find the number of distinct decompositions of number m into the product of n ordered positive integers.
Decomposition into n products, given in the input, must also be considered in the answer. As the answer can be very large, ... | 0.375 |
{"tests": "{\"inputs\": [\"3 4 11\\n1 2 3 4\\n\", \"5 5 10\\n1 2 4 8 16\\n\", \"1 1 0\\n2\\n\", \"1 1 1\\n1\\n\", \"2 1 0\\n2\\n\", \"2 2 2\\n2 3\\n\", \"4 2 15\\n1 4\\n\", \"24 42 126319796\\n318996 157487 174813 189765 259136 406743 138997 377982 244813 16862 95438 346702 454882 274633 67361 387756 61951 448901 42727... | Polycarp takes part in a math show. He is given n tasks, each consists of k subtasks, numbered 1 through k. It takes him t_{j} minutes to solve the j-th subtask of any task. Thus, time required to solve a subtask depends only on its index, but not on the task itself. Polycarp can solve subtasks in any order.
By solvin... | 0.125 |
{"tests": "{\"inputs\": [\"5\\n1 2\\n1 3\\n2 4\\n2 5\\n\", \"6\\n1 2\\n1 3\\n3 4\\n1 5\\n5 6\\n\", \"1\\n\", \"2\\n1 2\\n\", \"3\\n1 2\\n1 3\\n\", \"10\\n1 2\\n1 3\\n3 4\\n3 5\\n4 6\\n1 7\\n3 8\\n2 9\\n6 10\\n\", \"50\\n1 2\\n2 3\\n3 4\\n4 5\\n5 6\\n6 7\\n7 8\\n8 9\\n9 10\\n10 11\\n11 12\\n12 13\\n13 14\\n14 15\\n15 16... | Demiurges Shambambukli and Mazukta love to watch the games of ordinary people. Today, they noticed two men who play the following game.
There is a rooted tree on n nodes, m of which are leaves (a leaf is a nodes that does not have any children), edges of the tree are directed from parent to children. In the leaves of ... | 0 |
{"tests": "{\"inputs\": [[0], [2], [5], [25], [131], [1], [100], [179424691], [179424693]], \"outputs\": [[[false, true, true]], [[true, true, false]], [[true, false, false]], [[false, false, false]], [[true, false, false]], [[false, false, false]], [[false, true, true]], [[true, false, false]], [[false, false, false]]... | Create a function which checks a number for three different properties.
- is the number prime?
- is the number even?
- is the number a multiple of 10?
Each should return either true or false, which should be given as an array. Remark: The Haskell variant uses `data Property`.
### Examples
```python
number_property(7... | 0.625 |
{"tests": "{\"inputs\": [\"4\\n2 8\\n3 5\\n4 7\\n1 6\\n\", \"15\\n16 22\\n4 17\\n27 3\\n23 24\\n18 20\\n15 21\\n9 7\\n2 28\\n29 19\\n8 30\\n14 10\\n6 26\\n25 11\\n12 1\\n13 5\\n\", \"17\\n3 14\\n34 22\\n24 9\\n16 17\\n6 30\\n33 12\\n5 10\\n21 8\\n32 2\\n26 23\\n31 27\\n19 15\\n29 4\\n7 18\\n25 13\\n20 28\\n1 11\\n\", \... | Note that girls in Arpa’s land are really attractive.
Arpa loves overnight parties. In the middle of one of these parties Mehrdad suddenly appeared. He saw n pairs of friends sitting around a table. i-th pair consisted of a boy, sitting on the ai-th chair, and his girlfriend, sitting on the bi-th chair. The chairs wer... | 0 |
{"tests": "{\"inputs\": [\"6\\n0 0\\n0 1\\n1 1\\n1 2\\n2 2\\n2 0\\n0 0\\n\", \"16\\n1 1\\n1 5\\n3 5\\n3 7\\n2 7\\n2 9\\n6 9\\n6 7\\n5 7\\n5 3\\n4 3\\n4 4\\n3 4\\n3 2\\n5 2\\n5 1\\n1 1\\n\", \"4\\n-10000 -10000\\n-10000 10000\\n10000 10000\\n10000 -10000\\n-10000 -10000\\n\", \"4\\n6 8\\n6 9\\n7 9\\n7 8\\n6 8\\n\", \"8\... | Maria participates in a bicycle race.
The speedway takes place on the shores of Lake Lucerne, just repeating its contour. As you know, the lake shore consists only of straight sections, directed to the north, south, east or west.
Let's introduce a system of coordinates, directing the Ox axis from west to east, and th... | 0.125 |
{"tests": "{\"inputs\": [\"2\\n1 1\\n-1 -1\\n\", \"3\\n5 0\\n0 5\\n1 0\\n\", \"1\\n-277226476 314722425\\n\", \"2\\n-404192496 -968658337\\n556071553 -256244640\\n\", \"1\\n-277226476 314722425\\n\", \"24\\n-2 -2\\n-1 1\\n0 1\\n1 1\\n0 2\\n1 -1\\n2 -2\\n1 -2\\n-1 0\\n0 -2\\n0 -1\\n-2 0\\n-2 -1\\n2 -1\\n2 2\\n-1 -2\\n-2... | You've got a robot, its task is destroying bombs on a square plane. Specifically, the square plane contains n bombs, the i-th bomb is at point with coordinates (x_{i}, y_{i}). We know that no two bombs are at the same point and that no bomb is at point with coordinates (0, 0). Initially, the robot is at point with coor... | 0 |
{"tests": "{\"inputs\": [\"7\\n1 0\\n1 1\\n42 7\\n13 7\\n99 1\\n99 0\\n99 2\\n\", \"2\\n13 9\\n17 9\\n\", \"2\\n13 9\\n17 9\\n\", \"2\\n13 9\\n27 9\\n\", \"7\\n1 0\\n1 1\\n42 7\\n13 7\\n64 1\\n99 0\\n99 2\\n\", \"2\\n17 9\\n47 9\\n\", \"7\\n1 0\\n1 1\\n42 7\\n1 9\\n64 0\\n99 0\\n99 2\\n\", \"7\\n1 0\\n2 1\\n42 7\\n1 9\... | Let $f(x)$ be the sum of digits of a decimal number $x$.
Find the smallest non-negative integer $x$ such that $f(x) + f(x + 1) + \dots + f(x + k) = n$.
-----Input-----
The first line contains one integer $t$ ($1 \le t \le 150$) — the number of test cases.
Each test case consists of one line containing two integers... | 0 |
{"tests": "{\"inputs\": [\"4\\n1 -1 0\\n2 30 0\\n3 60 40\\n4 0 60\\n2\\n1 3\\n1 4\\n22\\n1 0 0\\n2 150 40\\n3 30 20\\n4 180 150\\n5 40 80\\n6 130 130\\n7 72 28\\n8 172 118\\n9 50 50\\n10 160 82\\n11 90 105\\n12 144 131\\n13 130 64\\n14 80 140\\n15 38 117\\n16 190 90\\n17 60 100\\n18 100 70\\n19 130 100\\n20 71 69\\n21 ... | The hero of justice, the Spider, can pull a rope out of his arm and jump from building to building. However, due to the short rope, you can only move to buildings that are less than 50 distances from you. To move to a building farther away, you have to jump to another building.
<image>
Create a program that inputs... | 0 |
{"tests": "{\"inputs\": [[4, 2, 3], [3, -29, 4], [5, -28, 0], [7, 2], [10, -2999], [5], [4, 2, 3, 5, 7, -8], [-3, -5, 0], [-11, 1, 3], [-25, 5, -9], [-25, -11, 9], [-3, -5], [-11, 3], [-9999999], [-25, 5, -9, 55, -8, -7, 8], [0, 1, 2], [0, -1, 0], [0, -1, 2], [0, 1, -2], [0, 1], [0, -1], [0], [0, -5, 8, -7, 10]], \"out... | < PREVIOUS KATA
NEXT KATA >
## Task:
You have to write a function `pattern` which returns the following Pattern(See Examples) upto desired number of rows.
* Note:```Returning``` the pattern is not the same as ```Printing``` the pattern.
### Parameters:
pattern( n , x , y... | 0 |
{"tests": "{\"inputs\": [\"3 4\\n\", \"4 1\\n\", \"1 2\\n\", \"1 1\\n\", \"10 15\\n\", \"23 3\\n\", \"1000 2000\\n\", \"1000 1\\n\", \"1000 1000\\n\", \"1000 500\\n\", \"718 234\\n\", \"1000 1999\\n\", \"653 1305\\n\", \"816 2\\n\", \"1000 1000\\n\", \"1000 1999\\n\", \"23 3\\n\", \"1000 2000\\n\", \"1000 1\\n\", \"1 1... | You are given a grid, consisting of $2$ rows and $n$ columns. Each cell of this grid should be colored either black or white.
Two cells are considered neighbours if they have a common border and share the same color. Two cells $A$ and $B$ belong to the same component if they are neighbours, or if there is a neighbour ... | 0 |
{"tests": "{\"inputs\": [\"6 11\\n1 2\\n1 3\\n1 4\\n1 5\\n1 6\\n2 4\\n2 5\\n2 6\\n3 4\\n3 5\\n3 6\\n\", \"4 6\\n1 2\\n1 3\\n1 4\\n2 3\\n2 4\\n3 4\\n\", \"3 0\\n\", \"3 3\\n1 2\\n2 3\\n1 3\\n\", \"6 9\\n1 4\\n1 5\\n1 6\\n2 4\\n2 5\\n2 6\\n3 4\\n3 5\\n3 6\\n\", \"3 0\\n\", \"4 3\\n1 4\\n2 4\\n3 4\\n\", \"5 4\\n1 3\\n1 4\... | You have a simple undirected graph consisting of $n$ vertices and $m$ edges. The graph doesn't contain self-loops, there is at most one edge between a pair of vertices. The given graph can be disconnected.
Let's make a definition.
Let $v_1$ and $v_2$ be two some nonempty subsets of vertices that do not intersect. Let... | 0.125 |
{"tests": "{\"inputs\": [\"4 12\\n20 30 70 90\\n\", \"4 3\\n10000 1000 100 10\\n\", \"4 3\\n10 100 1000 10000\\n\", \"5 787787787\\n123456789 234567890 345678901 456789012 987654321\\n\", \"30 792520535\\n528145579 682850171 79476920 178914057 180053263 538638086 433143781 299775597 723428544 177615223 959893339 639448... | A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity.
Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c... | 0 |
{"tests": "{\"inputs\": [\"3\\n7\\n1 4 2 2 2 2 2\\n2\\n2 3\\n5\\n1 1 1 1 1\\n\", \"1\\n1\\n69\\n\", \"1\\n1\\n69\\n\", \"1\\n1\\n67\\n\", \"3\\n7\\n2 4 2 2 2 2 2\\n2\\n2 3\\n5\\n1 1 1 1 1\\n\", \"1\\n1\\n12\\n\", \"3\\n7\\n2 4 2 2 2 2 2\\n2\\n2 3\\n5\\n1 1 1 2 1\\n\", \"1\\n1\\n9\\n\", \"1\\n1\\n14\\n\", \"1\\n1\\n26\\... | There is a trampoline park with $n$ trampolines in a line. The $i$-th of which has strength $S_i$.
Pekora can jump on trampolines in multiple passes. She starts the pass by jumping on any trampoline of her choice.
If at the moment Pekora jumps on trampoline $i$, the trampoline will launch her to position $i + S_i$, a... | 0 |
{"tests": "{\"inputs\": [\"4 2 3\\n0 1 3 1\\n1 1 4 1\\n2 0 2 2\\n\", \"2 2 4\\n0 0 2 2\\n2 0 0 1\\n0 2 1 2\\n1 1 2 1\\n\", \"5 5 7\\n0 0 2 4\\n2 3 4 5\\n3 5 5 2\\n5 5 5 4\\n0 3 5 1\\n2 2 4 4\\n0 5 4 1\\n\", \"1 1 2\\n0 0 1 1\\n1 0 0 1\\n\", \"4 3 3\\n0 1 3 1\\n1 1 4 1\\n2 0 2 2\", \"2 2 4\\n0 0 2 2\\n2 0 0 1\\n0 2 1 2\... | Snuke is playing a puzzle game.
In this game, you are given a rectangular board of dimensions R × C, filled with numbers. Each integer i from 1 through N is written twice, at the coordinates (x_{i,1},y_{i,1}) and (x_{i,2},y_{i,2}).
The objective is to draw a curve connecting the pair of points where the same integer is... | 0 |
{"tests": "{\"inputs\": [\"3 3\\n1 2 x+2\\n2 2 2x+1\\n3 1 x+1\\n2 0\\n3 2\\n1 2 x\\n2 3 2\\n4 3\\n1 2 x^3+2x^2+3x+4\\n2 3 x^2+2x+3\\n3 4 x+2\\n0 0\", \"3 3\\n1 2 x+2\\n2 2 2x+1\\n3 1 x+1\\n2 0\\n3 2\\n1 2 x\\n2 3 1\\n4 3\\n1 2 x^3+2x^2+3x+4\\n2 3 x^2+2x+3\\n3 4 x+2\\n0 0\", \"3 3\\n1 2 x+2\\n2 2 2x+1\\n3 1 x+1\\n2 0\\n... | The trafic on the Internet is increasing these days due to smartphones. The wireless carriers have to enhance their network infrastructure.
The network of a wireless carrier consists of a number of base stations and lines. Each line connects two base stations bi-directionally. The bandwidth of a line increases every y... | 0 |
{"tests": "{\"inputs\": [\"13\\naizualgorithm\\n9\\ncomp 1 1 4 5\\ncomp 2 6 1 5\\nset 15 12 b\\ncomp 9 9 10 10\\ncomp 5 8 1 4\\nset 1 10 z\\nset 11 13 x\\ncomp 8 10 1 5\\ncomp 1 5 1 5\", \"13\\naizualgorithm\\n9\\ncomp 1 1 4 5\\ncomp 2 6 1 5\\nset 9 12 b\\ncomp 9 9 10 10\\ncomp 5 8 1 4\\nset 1 10 z\\nset 11 6 x\\ncomp ... | You gave the twins Ai and Zu a program of games using strings. In this game, Ai and Zu each select a substring from the character string, compare them, and the person who chooses the smaller one will get points. The two competed and played the game many times. However, I got tired of playing games for the same string m... | 0 |
{"tests": "{\"inputs\": [[\"Sarah Connor\"], [\"Sara Conar\"], [\"Serah Coner\"], [\"Sarh Connor\"], [\"Sayra Cunnarr\"], [\"Tim\"], [\"Joe\"], [\"Bob\"], [\"Robert\"], [\"Rupert\"], [\"Rubin\"], [\"Ashcraft\"], [\"Ashcroft\"], [\"Tymczak\"], [\"Pfister\"], [\"zxqurlwbx\"], [\"uryrtkzp\"]], \"outputs\": [[\"S600 C560\"... | # A History Lesson
Soundex is an interesting phonetic algorithm developed nearly 100 years ago for indexing names as they are pronounced in English. The goal is for homophones to be encoded to the same representation so that they can be matched despite minor differences in spelling.
Reference: https://en.wikipedia.or... | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.