info
stringlengths
120
50k
question
stringlengths
504
10.4k
avg@8_qwen3_4b_instruct_2507
float64
0
0.88
{"tests": "{\"inputs\": [\"5\\n2 3\\n4 5\\n2 5\\n1 3\\n0 2 1 4 3\\n\", \"5\\n3 1\\n2 4\\n3 4\\n2 5\\n0 -3 -1 2 4\\n\", \"12\\n1 6\\n10 1\\n4 1\\n7 1\\n1 2\\n5 1\\n1 8\\n1 11\\n3 1\\n12 1\\n9 1\\n580660007 861441526 -264928594 488291045 253254575 -974301934 709266786 926718320 87511873 514836444 -702876508 848928657\\n\...
A tree is a graph with n vertices and exactly n - 1 edges; this graph should meet the following condition: there exists exactly one shortest (by number of edges) path between any pair of its vertices. A subtree of a tree T is a tree with both vertices and edges as subsets of vertices and edges of T. You're given a tr...
0
{"tests": "{\"inputs\": [\"1\\n4\\nPPAP\\n\", \"3\\n12\\nAPPAPPPAPPPP\\n3\\nAAP\\n3\\nPPA\\n\", \"10\\n1\\nA\\n1\\nP\\n2\\nAP\\n2\\nPA\\n8\\nPPPPAPPP\\n8\\nPPPPPPPA\\n8\\nAPPPPPPP\\n8\\nPPPPPPAP\\n8\\nPPPPPAPP\\n8\\nPPPAPPPP\\n\", \"16\\n4\\nPPPP\\n4\\nAPPP\\n4\\nPAPP\\n4\\nAAPP\\n4\\nPPAP\\n4\\nAPAP\\n4\\nPAAP\\n4\\nA...
It's a walking tour day in SIS.Winter, so $t$ groups of students are visiting Torzhok. Streets of Torzhok are so narrow that students have to go in a row one after another. Initially, some students are angry. Let's describe a group of students by a string of capital letters "A" and "P": "A" corresponds to an angry s...
0.625
{"tests": "{\"inputs\": [\"6\\n11 6\\n10 4\\n01 3\\n00 3\\n00 7\\n00 9\\n\", \"5\\n11 1\\n01 1\\n00 100\\n10 1\\n01 1\\n\", \"6\\n11 19\\n10 22\\n00 18\\n00 29\\n11 29\\n10 28\\n\", \"3\\n00 5000\\n00 5000\\n00 5000\\n\", \"1\\n00 1\\n\", \"1\\n00 4\\n\", \"1\\n11 15\\n\", \"2\\n00 1\\n10 1\\n\", \"2\\n00 2\\n11 1\\n\"...
Elections in Berland are coming. There are only two candidates — Alice and Bob. The main Berland TV channel plans to show political debates. There are $n$ people who want to take part in the debate as a spectator. Each person is described by their influence and political views. There are four kinds of political views:...
0.125
{"tests": "{\"inputs\": [\"1\\n10\\n1 2\\n1 3\\n1 4\\n2 5\\n2 6\\n3 7\\n3 8\\n4 9\\n4 10\\n\", \"1\\n10\\n1 2\\n1 3\\n1 4\\n2 5\\n2 6\\n3 7\\n3 8\\n4 9\\n7 10\\n\", \"1\\n10\\n1 2\\n1 3\\n2 4\\n2 5\\n2 6\\n3 7\\n3 8\\n4 9\\n4 10\\n\", \"1\\n10\\n1 2\\n1 3\\n4 4\\n2 5\\n2 6\\n3 7\\n3 8\\n6 9\\n4 10\\n\", \"1\\n3\\n1 2\\...
Assume that you have $k$ one-dimensional segments $s_1, s_2, \dots s_k$ (each segment is denoted by two integers — its endpoints). Then you can build the following graph on these segments. The graph consists of $k$ vertexes, and there is an edge between the $i$-th and the $j$-th vertexes ($i \neq j$) if and only if the...
0
{"tests": "{\"inputs\": [\"2012.12.31\\n2.12.16.14.14\\n7138.5.13\\n10.5.5.1.2\\n10000000.12.31\\n#\", \"2012.12.31\\n2.12.16.14.14\\n7138.5.13\\n10.2.5.1.5\\n10000000.12.31\\n#\", \"2012.12.31\\n2.12.16.14.14\\n6138.5.13\\n10.5.2.1.5\\n10000000.12.31\\n#\", \"2012.12.31\\n2.12.16.04.14\\n7138.5.13\\n10.5.5.1.2\\n10000...
Shinya watched a program on TV called "Maya's Great Prophecy! Will the World End in 2012?" After all, I wasn't sure if the world would end, but I was interested in Maya's "long-term calendar," which was introduced in the program. The program explained as follows. The Maya long-term calendar is a very long calendar con...
0
{"tests": "{\"inputs\": [\"4 2\\n1 2\\n1 3\\n2 4\\n1 3\\n1 4\\n\", \"4 2\\n1 2\\n2 3\\n3 4\\n4 1 2 3 4\\n1 1\\n\", \"2 2\\n2 1\\n1 2\\n1 1\\n\", \"2 2\\n2 1\\n1 1\\n2 1 2\\n\", \"10 2\\n5 6\\n4 7\\n7 1\\n8 2\\n6 9\\n4 8\\n10 5\\n9 2\\n3 5\\n5 5 1 3 2 7\\n3 7 8 4\\n\", \"10 10\\n9 1\\n5 4\\n4 6\\n2 7\\n1 4\\n8 3\\n10 8\...
Cirno_9baka has a tree with $n$ nodes. He is willing to share it with you, which means you can operate on it. Initially, there are two chess pieces on the node $1$ of the tree. In one step, you can choose any piece, and move it to the neighboring node. You are also given an integer $d$. You need to ensure that the dis...
0
{"tests": "{\"inputs\": [\"5 5\\n3 1 2 2 4\\n\", \"4 5\\n2 3 4 5\\n\", \"2 2\\n1 1\\n\", \"5 5\\n5 5 5 5 5\\n\", \"5 20\\n5 5 5 5 5\\n\", \"2 3\\n2 2\\n\", \"4 5\\n2 2 2 2\\n\", \"5 6\\n2 2 2 2 7\\n\", \"1 1\\n1\\n\", \"5 5\\n1 1 1 1 1\\n\", \"3 3\\n10 10 10\\n\", \"2 3\\n5 5\\n\", \"1 100\\n1\\n\", \"1 4\\n1\\n\", \"4...
There is a toy building consisting of $n$ towers. Each tower consists of several cubes standing on each other. The $i$-th tower consists of $h_i$ cubes, so it has height $h_i$. Let's define operation slice on some height $H$ as following: for each tower $i$, if its height is greater than $H$, then remove some top cube...
0.875
{"tests": "{\"inputs\": [\"4\\nIcosahedron\\nCube\\nTetrahedron\\nDodecahedron\\n\", \"3\\nDodecahedron\\nOctahedron\\nOctahedron\\n\", \"25\\nIcosahedron\\nOctahedron\\nTetrahedron\\nDodecahedron\\nCube\\nIcosahedron\\nOctahedron\\nCube\\nTetrahedron\\nIcosahedron\\nIcosahedron\\nTetrahedron\\nOctahedron\\nDodecahedro...
Anton's favourite geometric figures are regular polyhedrons. Note that there are five kinds of regular polyhedrons: Tetrahedron. Tetrahedron has 4 triangular faces. Cube. Cube has 6 square faces. Octahedron. Octahedron has 8 triangular faces. Dodecahedron. Dodecahedron has 12 pentagonal faces. Icosahedron. Icos...
0.875
{"tests": "{\"inputs\": [\"3\\n9\\niredppipe\\npiedpiper\\n4\\nestt\\ntest\\n4\\ntste\\ntest\\n\", \"4\\n1\\na\\nz\\n5\\nadhas\\ndasha\\n5\\naashd\\ndasha\\n5\\naahsd\\ndasha\\n\", \"6\\n7\\ncontest\\nntecost\\n7\\ncontest\\nnstteco\\n7\\ncontest\\ntnsteco\\n7\\ncontest\\ncotestn\\n7\\ncontest\\ncontest\\n7\\nontestc\\...
The problem was inspired by Pied Piper story. After a challenge from Hooli's compression competitor Nucleus, Richard pulled an all-nighter to invent a new approach to compression: middle-out. You are given two strings $s$ and $t$ of the same length $n$. Their characters are numbered from $1$ to $n$ from left to right ...
0
{"tests": "{\"inputs\": [\"VEEMU:VEEMU:GTE:GTE:KZZEDTUECE:VEEMU:GTE:CGOZKO:CGOZKO:GTE:ZZNAY.,GTE:MHMBC:GTE:VEEMU:CGOZKO:VEEMU:VEEMU.,CGOZKO:ZZNAY..................\\n\", \"V:V:V.,V.,V.,V.,V.,V.,V.,V.,V.,V.,V.,V.,V.,V.,V.,V.,V.,V.,V..,V:V.,V.,V.,V..,V:V.,V.,V.,V.,V..,V:V.,V.,V..,V:V..,V:V.,V..,V.,V:V..,V.,V.,V.,V.,V.,V....
The Beroil corporation structure is hierarchical, that is it can be represented as a tree. Let's examine the presentation of this structure as follows: * employee ::= name. | name:employee1,employee2, ... ,employeek. * name ::= name of an employee That is, the description of each employee consists of his name,...
0
{"tests": "{\"inputs\": [\"5 2 3\\n3\\n5\\n1\\n2\\n3\\n3 100 100\\n3\\n3\\n4\\n20 3 8\\n3\\n2\\n6\\n1\\n9\\n1\\n8\\n4\\n2\\n2\\n8\\n1\\n8\\n8\\n2\\n6\\n3\\n4\\n3\\n8\\n7 2 2\\n0\\n2\\n5\\n2\\n5\\n2\\n1\\n0 0 0\", \"5 2 3\\n3\\n5\\n1\\n2\\n3\\n3 100 100\\n3\\n3\\n4\\n20 3 8\\n3\\n2\\n6\\n1\\n9\\n1\\n0\\n4\\n2\\n2\\n8\\n...
coastline Waves rush to the beach every second. There is data that observes and records how many meters the wave rushed beyond the reference point P every second for only T seconds. The data consists of T integers x1, ..., xT, and for each i (1 ≤ i ≤ T), a wave from point P to the point exactly xi m rushes in i second...
0
{"tests": "{\"inputs\": [\"AA\\n\", \"A\\n\", \"ABCDEF\\n\", \"BA\\n\", \"CC\\n\", \"B\\n\", \"FEDCBA\\n\", \"CBWBB\\n\", \"BBWBWB\\n\", \"BVWB\\n\", \"WWWOONOOOWWW\\n\", \"AB\\n\", \"C\\n\", \"EEDCBA\\n\", \"BBWBC\\n\", \"BBWBWA\\n\", \"BVXB\\n\", \"WWWOONOOOVWW\\n\", \"AC\\n\", \"D\\n\", \"DEECBA\\n\", \"BBWCB\\n\", ...
Balph is learning to play a game called Buma. In this game, he is given a row of colored balls. He has to choose the color of one new ball and the place to insert it (between two balls, or to the left of all the balls, or to the right of all the balls). When the ball is inserted the following happens repeatedly: if so...
0.5
{"tests": "{\"inputs\": [\"4\\n2\\n-1 -2 0 0 0 0\\n-1 -2 0 0 0 0\\n3\\n1 5 1 1 1 1\\n2 5 0 1 0 1\\n3 5 1 0 0 0\\n2\\n1337 1337 0 1 1 1\\n1336 1337 1 1 0 1\\n1\\n3 5 1 1 1 1\\n\", \"4\\n2\\n-1 -2 0 0 0 0\\n-1 -2 0 0 0 0\\n3\\n1 5 1 1 1 1\\n2 5 0 0 0 1\\n3 5 1 0 0 0\\n2\\n1337 1337 0 1 1 1\\n1336 1337 1 1 0 1\\n1\\n3 5 1...
$n$ robots have escaped from your laboratory! You have to find them as soon as possible, because these robots are experimental, and their behavior is not tested yet, so they may be really dangerous! Fortunately, even though your robots have escaped, you still have some control over them. First of all, you know the loc...
0
{"tests": "{\"inputs\": [\"4 2\\n4 3\\n5 3\\n0 0\", \"2 2\\n4 3\\n5 3\\n0 0\", \"2 2\\n5 3\\n5 3\\n0 0\", \"2 1\\n4 3\\n5 3\\n0 0\", \"2 1\\n4 2\\n5 3\\n0 0\", \"2 2\\n5 5\\n5 2\\n0 0\", \"2 1\\n3 2\\n5 3\\n0 0\", \"2 2\\n5 0\\n5 3\\n0 0\", \"2 1\\n4 6\\n5 3\\n0 0\", \"2 2\\n0 5\\n5 3\\n0 0\", \"2 1\\n5 5\\n5 2\\n0 0\"...
Given a square table sized NxN (3 ≤ N ≤ 5,000; rows and columns are indexed from 1) with a robot on it. The robot has a mission of moving from cell (1, 1) to cell (N, N) using only the directions "right" or "down". You are requested to find the number of different ways for the robot using exactly K turns (we define a "...
0
{"tests": "{\"inputs\": [\"4\\n-6 9\\n9 5\\n-7 4\\n0 9\\n\", \"6\\n20 39\\n38 13\\n-25 48\\n-22 38\\n13 39\\n90 54\\n\", \"5\\n-47 19\\n-43 14\\n83 27\\n-67 46\\n-58 98\\n\", \"3\\n6 7\\n2 9\\n-6 10\\n\", \"10\\n34 9\\n-41 26\\n-62 32\\n1 10\\n77 14\\n92 7\\n-45 35\\n75 19\\n-23 2\\n-46 8\\n\", \"4\\n-6 9\\n1 5\\n-7 4\...
Vasya is interested in arranging dominoes. He is fed up with common dominoes and he uses the dominoes of different heights. He put n dominoes on the table along one axis, going from left to right. Every domino stands perpendicular to that axis so that the axis passes through the center of its base. The i-th domino has ...
0
{"tests": "{\"inputs\": [\"2\\nwhite 10\\nblack 10\\n4\\nblack\\nwhite\", \"3\\nwgite 10\\nerd 40\\nwhite 30\\n2\\nwhite\\nerd\\nwhite\", \"2\\nwhite 20\\nblack 10\\n2\\nkcalb\\norange\", \"2\\nwhite 20\\nblack 10\\n2\\nblack\\nhwite\", \"4\\nred 3444\\nred 3018\\nred 3098\\nred 3319\\n4\\nred\\nred\\nrec\\nred\", \"3\...
In the Jambo Amusement Garden (JAG), you sell colorful drinks consisting of multiple color layers. This colorful drink can be made by pouring multiple colored liquids of different density from the bottom in order. You have already prepared several colored liquids with various colors and densities. You will receive a d...
0
{"tests": "{\"inputs\": [[1, 1, 2], [2, 0, 3], [423, 100, 150], [1, 2, 0], [1, 2, 2], [-1.0, 2, 2]], \"outputs\": [[[2, 6]], [[0, 4, 12, 24]], [[4272300, 4357746, 4444038, 4531176, 4619160, 4707990, 4797666, 4888188, 4979556, 5071770, 5164830, 5258736, 5353488, 5449086, 5545530, 5642820, 5740956, 5839938, 5939766, 6040...
Quantum mechanics tells us that a molecule is only allowed to have specific, discrete amounts of internal energy. The 'rigid rotor model', a model for describing rotations, tells us that the amount of rotational energy a molecule can have is given by: `E = B * J * (J + 1)`, where J is the state the molecule is in...
0
{"tests": "{\"inputs\": [\"10 15\\nSNCZWRCEWB\\nB R\\nR R\\nE R\\nW R\\nZ L\\nS R\\nQ L\\nW L\\nB R\\nC L\\nA L\\nN L\\nE R\\nZ L\\nR L\", \"3 4\\nACB\\nA L\\nB L\\nB R\\nA R\", \"8 3\\nAABBBDBA\\nA L\\nB R\\nA R\", \"3 3\\nACB\\nB L\\nB L\\nA R\\n@ S\", \"3 3\\nBCA\\nB L\\nB L\\nA R\\n@ S\", \"8 0\\nAABCBDBA\\nA L\\nB...
There are N squares numbered 1 to N from left to right. Each square has a character written on it, and Square i has a letter s_i. Besides, there is initially one golem on each square. Snuke cast Q spells to move the golems. The i-th spell consisted of two characters t_i and d_i, where d_i is `L` or `R`. When Snuke ca...
0.125
{"tests": "{\"inputs\": [\"2\\n0 2\", \"2\\n-1 4\", \"2\\n0 4\", \"2\\n0 1\", \"2\\n1 0\", \"2\\n0 7\", \"2\\n-1 2\", \"2\\n2 0\", \"2\\n-1 10\", \"2\\n-2 2\", \"2\\n2 -1\", \"2\\n-2 4\", \"2\\n4 -1\", \"2\\n-2 8\", \"2\\n4 0\", \"2\\n-2 5\", \"2\\n5 0\", \"2\\n1 1\", \"2\\n2 2\", \"2\\n2 4\", \"2\\n4 4\", \"2\\n0 0\",...
Problem statement There is a positive integer sequence $ a_1, a_2, \ ldots, a_N $ of length $ N $. Consider the following game, which uses this sequence and is played by $ 2 $ players on the play and the play. * Alternately select one of the following operations for the first move and the second move. * Select a pos...
0
{"tests": "{\"inputs\": [\"5 4 5\\n0 1 1 0\\n1 0 0 1\\n0 1 1 0\\n1 0 0 1\\n0 0 0 0\\n1 1\\n1 4\\n1 1\\n4 2\\n4 3\\n\", \"2 2 10\\n1 1\\n0 1\\n1 1\\n2 1\\n1 1\\n2 2\\n1 1\\n2 1\\n2 2\\n2 2\\n1 1\\n1 1\\n\", \"2 2 10\\n1 1\\n0 1\\n2 2\\n2 2\\n1 1\\n2 1\\n2 1\\n1 1\\n1 1\\n2 1\\n1 1\\n2 1\\n\", \"5 5 30\\n0 1 1 1 0\\n1 1 ...
Mike and some bears are playing a game just for fun. Mike is the judge. All bears except Mike are standing in an n × m grid, there's exactly one bear in each cell. We denote the bear standing in column number j of row number i by (i, j). Mike's hands are on his ears (since he's the judge) and each bear standing in the ...
0.875
{"tests": "{\"inputs\": [\"2 900\\n\", \"1 501\\n\", \"4 2000\\n\", \"100 100000\\n\", \"1 500\\n\", \"84 42001\\n\", \"13 6498\\n\", \"0 501\", \"4 1282\", \"0 900\", \"0 588\", \"8 1282\", \"0 50\", \"0 192\", \"13 1282\", \"-1 50\", \"0 379\", \"10 1282\", \"0 88\", \"1 379\", \"10 333\", \"0 165\", \"2 379\", \"10 ...
Takahashi has K 500-yen coins. (Yen is the currency of Japan.) If these coins add up to X yen or more, print Yes; otherwise, print No. -----Constraints----- - 1 \leq K \leq 100 - 1 \leq X \leq 10^5 -----Input----- Input is given from Standard Input in the following format: K X -----Output----- If the coins add up ...
0.875
{"tests": "{\"inputs\": [\"5\\n0 1 0 1 0\\n1 1 0 0 1\\n1 0 1 0 1\\n0 0 1 1 0\\n\", \"3\\n1 0 0\\n0 0 0\\n0 0 0\\n0 0 0\\n\", \"1\\n0\\n1\\n1\\n0\\n\", \"7\\n1 0 0 1 1 0 1\\n1 0 0 0 1 1 1\\n1 1 1 0 0 1 0\\n0 1 1 1 0 0 0\\n\", \"7\\n0 0 1 0 1 0 1\\n0 0 0 0 0 0 1\\n0 1 0 1 0 1 0\\n1 0 0 0 0 0 0\\n\", \"7\\n0 0 0 0 0 0 0\\...
Pupils Alice and Ibragim are best friends. It's Ibragim's birthday soon, so Alice decided to gift him a new puzzle. The puzzle can be represented as a matrix with $2$ rows and $n$ columns, every element of which is either $0$ or $1$. In one move you can swap two values in neighboring cells. More formally, let's number...
0
{"tests": "{\"inputs\": [[[1, 2]], [[1, 3]], [[1, 5]], [[]], [[0]], [[0, 1]], [[1, 3, 5, 7]], [[2, 4]], [[-1]], [[-1, -1]], [[-1, 0, 1]], [[-3, 3]], [[-5, 3]]], \"outputs\": [[1], [3], [null], [null], [0], [1], [7], [null], [-1], [null], [-1], [3], [null]]}", "source": "taco"}
Integral numbers can be even or odd. Even numbers satisfy `n = 2m` ( with `m` also integral ) and we will ( completely arbitrarily ) think of odd numbers as `n = 2m + 1`. Now, some odd numbers can be more odd than others: when for some `n`, `m` is more odd than for another's. Recursively. :] Even numbers are just ...
0
{"tests": "{\"inputs\": [\"3\\n2 3 4\\n2 1\\n5\\n-1 1 1 -100000 100000\\n\", \"3\\n2 3 4\\n2 1\\n5\\n-1 2 1 -100000 100100\\n\", \"3\\n2 3 4\\n2 1\\n5\\n-2 2 1 -100000 100100\\n\", \"3\\n1 3 4\\n2 1\\n5\\n-2 2 1 -100000 100100\\n\", \"3\\n1 3 4\\n2 0\\n5\\n-2 2 1 -100000 100100\\n\", \"3\\n2 3 4\\n2 1\\n5\\n-1 0 1 -962...
This is the hard version of the problem. The only difference is that in this version 1 ≤ q ≤ 10^5. You can make hacks only if both versions of the problem are solved. There is a process that takes place on arrays a and b of length n and length n-1 respectively. The process is an infinite sequence of operations. Each...
0
{"tests": "{\"inputs\": [[5, 6, [1, 2, 3, 10]], [1, 6, [1, 2, 3, 10]], [5, 5, [1, 2, 3, 10]], [2, 2, [1, 2, 3, 10]], [2, 2, [2, 3, 4, 10]], [5, 4, [1, 2, 3, 10]], [5, 4, [2, 3, 4, 5]], [1, 6, [0, 0, 0, 0]], [1, 6, [0, 2, 0, 0]], [1, 6, [20, 0, 10, 0]]], \"outputs\": [[12], [0], [11], [8], [10], [12], [20], [0], [0], [0...
# Task John is a programmer. He treasures his time very much. He lives on the `n` floor of a building. Every morning he will go downstairs as quickly as possible to begin his great work today. There are two ways he goes downstairs: walking or taking the elevator. When John uses the elevator, he will go through the f...
0
{"tests": "{\"inputs\": [\"9 2 5\\n\", \"3 2 1\\n\", \"7 4 4\\n\", \"1000000 999998 3\\n\", \"1 1 1\\n\", \"390612 20831 55790\\n\", \"505383 77277 99291\\n\", \"201292 78188 62600\\n\", \"726152 70146 71567\\n\", \"383151 97630 81017\\n\", \"663351 51961 83597\\n\", \"422699 52145 56717\\n\", \"432316 96424 86324\\n\"...
For a permutation P[1... N] of integers from 1 to N, function f is defined as follows: $f(i, j) = \left\{\begin{array}{ll}{P [ i ]} & {\text{if} j = 1} \\{f(P [ i ], j - 1)} & {\text{otherwise}} \end{array} \right.$ Let g(i) be the minimum positive integer j such that f(i, j) = i. We can show such j always exists. ...
0.875
{"tests": "{\"inputs\": [\"341143514535\\n158\\n143565553551655311343411652235654535651124615163\\n551544654451431564\\n4\\n3411\\n6363636363\\n153414\", \"341143514535\\n314\\n10141283183115209195186599000583233654691126402\\n551544654451431564\\n4\\n3411\\n6363636363\\n153414\", \"341143514535\\n158\\n143565553551655...
One day, Taro received a strange email with only the number "519345213244" in the text. The email was from my cousin, who was 10 years older than me, so when I called and asked, "Oh, I sent it with a pocket bell because I was in a hurry. It's convenient. Nice to meet you!" I got it. You know this cousin, who is always ...
0
{"tests": "{\"inputs\": [[6, 11, 2], [11, 345, 17], [0, 1, 7], [20, 20, 2], [20, 20, 8], [19, 20, 2], [0, 10, 1], [11, 14, 2], [101, 9999999999999999999999999999999999999999999, 11], [1005, 9999999999999999999999999999999999999999999, 109]], \"outputs\": [[3], [20], [1], [1], [0], [1], [11], [2], [909090909090909090909...
Complete the function that takes 3 numbers `x, y and k` (where `x ≤ y`), and returns the number of integers within the range `[x..y]` (both ends included) that are divisible by `k`. More scientifically: `{ i : x ≤ i ≤ y, i mod k = 0 }` ## Example Given ```x = 6, y = 11, k = 2``` the function should return `3`, bec...
0
{"tests": "{\"inputs\": [\"0 1 1 0 0 0 0 0 0 7 0 0 0 0\\n\", \"5 1 1 1 1 0 0 0 0 0 0 0 0 0\\n\", \"10001 10001 10001 10001 10001 10001 10001 10001 10001 10001 10001 10001 10001 1\\n\", \"0 0 0 0 0 0 0 0 0 0 0 0 0 15\\n\", \"1 0 0 0 0 1 0 0 0 0 1 0 0 0\\n\", \"5 5 1 1 1 3 3 3 5 7 5 3 7 5\\n\", \"787 393 649 463 803 365 ...
Mancala is a game famous in the Middle East. It is played on a board that consists of 14 holes. [Image] Initially, each hole has $a_i$ stones. When a player makes a move, he chooses a hole which contains a positive number of stones. He takes all the stones inside it and then redistributes these stones one by one in ...
0
{"tests": "{\"inputs\": [\"2 4\\n5 2\\n2 1\\n\", \"1 5\\n2 3\\n\", \"2 5\\n2 1\\n1 3\\n\", \"1 2\\n1000000000 1\\n\", \"1 5\\n999999999 1\\n\", \"1 5\\n2 2\\n\", \"1 5\\n5 0\\n\", \"4 8\\n11 5\\n1 4\\n1 4\\n1 6\\n\", \"3 9\\n8 1\\n6 3\\n6 3\\n\", \"3 5\\n1 5\\n5 0\\n3 1\\n\", \"3 5\\n2 2\\n1 1\\n4 1\\n\", \"3 5\\n0 4\\...
Phoenix is picking berries in his backyard. There are $n$ shrubs, and each shrub has $a_i$ red berries and $b_i$ blue berries. Each basket can contain $k$ berries. But, Phoenix has decided that each basket may only contain berries from the same shrub or berries of the same color (red or blue). In other words, all berr...
0
{"tests": "{\"inputs\": [\"4\\n1 2\\n1 3\\n2 4\\n1 2 3 4\\n\", \"4\\n1 2\\n1 3\\n2 4\\n1 2 4 3\\n\", \"6\\n1 2\\n1 5\\n2 3\\n2 4\\n5 6\\n1 2 5 3 4 6\\n\", \"6\\n1 2\\n1 5\\n2 3\\n2 4\\n5 6\\n1 5 2 3 4 6\\n\", \"6\\n1 2\\n1 5\\n2 3\\n2 4\\n5 6\\n1 2 5 3 6 4\\n\", \"7\\n1 2\\n1 5\\n2 3\\n2 4\\n5 6\\n5 7\\n1 2 5 6 7 3 4\\...
The BFS algorithm is defined as follows. Consider an undirected graph with vertices numbered from $1$ to $n$. Initialize $q$ as a new queue containing only vertex $1$, mark the vertex $1$ as used. Extract a vertex $v$ from the head of the queue $q$. Print the index of vertex $v$. Iterate in arbitrary order through ...
0
{"tests": "{\"inputs\": [\"2\\n2\\n3\\n\", \"5\\n2\\n5\\n10\\n1000000000000000000\\n1000000000000000000\\n\", \"75\\n22\\n1968854689373829\\n87153\\n51936214827607\\n174306\\n89708007429503\\n37408239098102751\\n5282\\n89708007429503\\n57\\n417\\n28328844451422\\n311617288965642\\n822981260158260522\\n14164422225711\\n...
We have N clocks. The hand of the i-th clock (1≤i≤N) rotates through 360° in exactly T_i seconds. Initially, the hand of every clock stands still, pointing directly upward. Now, Dolphin starts all the clocks simultaneously. In how many seconds will the hand of every clock point directly upward again? -----Constrain...
0.875
{"tests": "{\"inputs\": [\"4\\n2\\n1 2\\n3\\n5 5 5\\n4\\n1 3 3 7\\n6\\n3 4 2 1 3 3\\n\", \"1\\n74\\n9 3 10 8 6 6 1 6 9 3 7 3 2 8 1 5 8 4 6 4 1 6 5 6 10 3 6 6 6 4 9 5 8 7 2 1 6 2 4 9 10 9 5 4 7 5 7 2 10 10 1 5 2 4 1 7 7 3 8 10 2 5 8 4 3 9 2 9 9 8 6 8 4 1\\n\", \"1\\n3\\n11 11 154\\n\", \"1\\n3\\n11 11 154\\n\", \"1\\n74...
$n$ people gathered to hold a jury meeting of the upcoming competition, the $i$-th member of the jury came up with $a_i$ tasks, which they want to share with each other. First, the jury decides on the order which they will follow while describing the tasks. Let that be a permutation $p$ of numbers from $1$ to $n$ (an ...
0
{"tests": "{\"inputs\": [[\"2\", \"2\", \"7 2\", \"3\", \"2 2 4\"], \"2\\n2\\n7 2\\n3\\n3 2 4\", \"2\\n2\\n7 2\\n3\\n6 2 4\", \"2\\n2\\n6 2\\n3\\n2 2 4\", \"2\\n2\\n6 2\\n3\\n2 3 4\", \"2\\n2\\n7 2\\n2\\n6 2 4\", \"2\\n2\\n7 1\\n2\\n6 2 4\", \"2\\n2\\n7 4\\n3\\n6 2 4\", \"2\\n2\\n7 2\\n1\\n6 2 4\", \"2\\n1\\n6 2\\n3\\n...
Given an array A1,A2...AN, you have to print the size of the largest contiguous subarray such that GCD of all integers in that subarray is 1. Formally, For a subarray Ai,Ai+1...Aj where 1 ≤ i < j ≤ N to be valid: GCD(Ai,Ai+1...Aj) should be 1. You have to print the size of the largest valid subarray. If no valid suba...
0.625
{"tests": "{\"inputs\": [\"500 3\\n2002 1 1\\n2003 500 500\\n2004 500 500\\n\", \"2 3\\n1 1 1\\n100 2 2\\n10000 1 1\\n\", \"500 2\\n950 500 500\\n3000 1 1\\n\", \"500 1\\n26969 164 134\\n\", \"4 3\\n851 4 3\\n1573 1 4\\n2318 3 4\\n\", \"500 2\\n2000 1 1\\n4000 1 1\\n\", \"10 3\\n26 10 9\\n123 2 2\\n404 5 6\\n\", \"727 ...
You are a paparazzi working in Manhattan. Manhattan has r south-to-north streets, denoted by numbers 1, 2,…, r in order from west to east, and r west-to-east streets, denoted by numbers 1,2,…,r in order from south to north. Each of the r south-to-north streets intersects each of the r west-to-east streets; the interse...
0.625
{"tests": "{\"inputs\": [\"helloworld\\nehoolwlroz\\n\", \"hastalavistababy\\nhastalavistababy\\n\", \"merrychristmas\\nchristmasmerry\\n\", \"kusyvdgccw\\nkusyvdgccw\\n\", \"bbbbbabbab\\naaaaabaaba\\n\", \"zzzzzzzzzzzzzzzzzzzzz\\nqwertyuiopasdfghjklzx\\n\", \"accdccdcdccacddbcacc\\naccbccbcbccacbbdcacc\\n\", \"giiibdb...
Santa Claus decided to disassemble his keyboard to clean it. After he returned all the keys back, he suddenly realized that some pairs of keys took each other's place! That is, Santa suspects that each key is either on its place, or on the place of another key, which is located exactly where the first key should be. ...
0
{"tests": "{\"inputs\": [\"6\\nAIZU 10\\nLINER 6\\nLINE 4\\nALL 2\\nAS 1\\nCIEL 10\\nASLA\\nCILI\\nIRZN\\nUELE\\n21\", \"6\\nAIZU 10\\nLINER 6\\nLHNE 4\\nALL 2\\nAS 1\\nCIEL 10\\nASLA\\nCILI\\nIRZN\\nUELE\\n21\", \"6\\nAIZU 10\\nLINER 6\\nLHNE 3\\nALL 2\\nAS 1\\nCIEL 10\\nBSLA\\nCILI\\nIRZN\\nUELE\\n21\", \"6\\nUZI@ 4\...
Problem Statement Mr. Takatsuki, who is planning to participate in the Aizu training camp, is enthusiastic about studying and has been studying English recently. She tries to learn as many English words as possible by playing the following games on her mobile phone. The mobile phone she has is a touch panel type that ...
0
{"tests": "{\"inputs\": [\"8\\n3\\n1 5\\n3 0\\n6 4\\n3\\n1 5\\n2 4\\n10 -5\\n5\\n2 -5\\n3 1\\n4 1\\n5 1\\n6 1\\n4\\n3 3\\n5 -3\\n9 2\\n12 0\\n8\\n1 1\\n2 -6\\n7 2\\n8 3\\n12 -9\\n14 2\\n18 -1\\n23 9\\n5\\n1 -4\\n4 -7\\n6 -1\\n7 -3\\n8 -7\\n2\\n1 2\\n2 -2\\n6\\n3 10\\n5 5\\n8 0\\n12 -4\\n14 -7\\n19 -5\\n\", \"1\\n2\\n1 ...
You have a robot that can move along a number line. At time moment $0$ it stands at point $0$. You give $n$ commands to the robot: at time $t_i$ seconds you command the robot to go to point $x_i$. Whenever the robot receives a command, it starts moving towards the point $x_i$ with the speed of $1$ unit per second, and...
0
{"tests": "{\"inputs\": [\"6 4 10\\n3 1 1 1 2 2\\n7\\n8\\n9\\n10\\n11\\n12\\n13\\n14\\n15\\n16\\n\", \"4 5 4\\n4 4 5 1\\n15\\n9\\n13\\n6\\n\", \"1 1 20\\n1\\n2\\n5\\n200\\n199\\n198\\n24\\n123\\n100\\n101\\n100\\n3\\n6\\n200\\n193\\n191\\n24\\n123\\n78\\n109\\n13\\n\", \"1 100 20\\n5\\n2\\n3\\n4\\n5\\n100\\n101\\n102\\...
Misha was interested in water delivery from childhood. That's why his mother sent him to the annual Innovative Olympiad in Irrigation (IOI). Pupils from all Berland compete there demonstrating their skills in watering. It is extremely expensive to host such an olympiad, so after the first $n$ olympiads the organizers i...
0
{"tests": "{\"inputs\": [\"2 -1 -2 -1\\n2 -1 2 -1\\n2 -1 -2 -1\\n2 -1 2 -1\\n\", \"0 0 0 1\\n0 1 0 1\\n0 1 0 0\\n0 1 0 1\\n\", \"0 0 2 2\\n0 0 2 0\\n2 2 2 2\\n0 2 0 2\\n\", \"130120899 550158649 130120899 831843953\\n130120899 550158649 130120899 831843953\\n130120899 550158649 434006978 831843953\\n434006978 550158649...
Several months later Alex finally got his brother Bob's creation by post. And now, in his turn, Alex wants to boast about something to his brother. He thought for a while, and came to the conclusion that he has no ready creations, and decided to write a program for rectangles detection. According to his plan, the progr...
0.75
{"tests": "{\"inputs\": [[4183059834009], [24723578342962], [135440716410000], [40539911473216], [26825883955641], [41364076483082], [9541025211025], [112668204662785], [79172108332642], [1788719004901], [131443152397956], [1801879360282], [18262169777476], [11988186060816], [826691919076], [36099801072722], [171814395...
Your task is to construct a building which will be a pile of n cubes. The cube at the bottom will have a volume of n^3, the cube above will have volume of (n-1)^3 and so on until the top which will have a volume of 1^3. You are given the total volume m of the building. Being given m can you find the number n of cube...
0.875
{"tests": "{\"inputs\": [\"1 1\\n5 7 2\\n\", \"3 1\\n1 3 2 3 1 3 1\\n\", \"24 7\\n3 4 2 4 1 4 3 4 3 5 1 3 1 3 0 3 0 3 1 4 0 3 0 1 0 1 0 3 2 3 2 3 1 2 1 3 2 5 1 3 0 1 0 2 0 3 1 3 1\\n\", \"3 1\\n0 1 0 1 0 2 0\\n\", \"3 2\\n0 4 3 5 2 5 2\\n\", \"3 1\\n8 10 9 10 3 5 1\\n\", \"40 2\\n0 3 1 2 1 2 0 1 0 2 1 3 0 2 0 3 0 3 0 1...
Little Bolek has found a picture with n mountain peaks painted on it. The n painted peaks are represented by a non-closed polyline, consisting of 2n segments. The segments go through 2n + 1 points with coordinates (1, y1), (2, y2), ..., (2n + 1, y2n + 1), with the i-th segment connecting the point (i, yi) and the point...
0.125
{"tests": "{\"inputs\": [\"((()[8]())[2]())[5](((()[2]())[6](()[3]()))[1]())\\n(()[4]())[3](((()[2]())[1]())[8](()[3]()*)\", \"((()[8]())[2]())[5](((()[3]())[6](()[3]()))[1]())\\n(()[4]())[3](((()[2]())[1]())[8](()[3]()))\", \"((()[8]())[2]())[5](((()[2]())[6](()[3]()))[1]())\\n(()[4]())[3](((()[2]())[0]())[8](()[3]'))...
C --Misawa's rooted tree Problem Statement You noticed that your best friend Misawa's birthday was near, and decided to give him a rooted binary tree as a gift. Here, the rooted binary tree has the following graph structure. (Figure 1) * Each vertex has exactly one vertex called the parent of that vertex, which is c...
0
{"tests": "{\"inputs\": [\"3\\n7\\n0\", \"3\\n3\\n0\", \"3\\n0\\n0\", \"3\\n1\\n0\", \"3\\n2\\n0\", \"3\\n-1\\n0\", \"3\\n5\\n0\", \"3\\n8\\n0\", \"3\\n6\\n0\", \"3\\n9\\n0\", \"3\\n0\\n-1\", \"3\\n0\\n1\", \"3\\n0\\n-2\", \"3\\n0\\n2\", \"3\\n0\\n-4\", \"3\\n0\\n-5\", \"3\\n0\\n3\", \"3\\n0\\n-3\", \"3\\n0\\n4\", \"3\...
The fundamental idea in the JPEG compression algorithm is to sort coeffi- cient of given image by zigzag path and encode it. In this problem, we don’t discuss about details of the algorithm, but you are asked to make simple pro- gram. You are given single integer N , and you must output zigzag path on a matrix where si...
0
{"tests": "{\"inputs\": [\"5 1\\n5 10 7 3 20\\n\", \"6 2\\n100 1 10 40 10 40\\n\", \"3 0\\n1 2 3\\n\", \"2 0\\n2 1\\n\", \"10 5\\n10 1 11 2 12 3 13 4 14 5\\n\", \"100 4\\n2 57 70 8 44 10 88 67 50 44 93 79 72 50 69 19 21 9 71 47 95 13 46 10 68 72 54 40 15 83 57 92 58 25 4 22 84 9 8 55 87 0 16 46 86 58 5 21 32 28 10 46 1...
The bear decided to store some raspberry for the winter. He cunningly found out the price for a barrel of honey in kilos of raspberry for each of the following n days. According to the bear's data, on the i-th (1 ≤ i ≤ n) day, the price for one barrel of honey is going to is x_{i} kilos of raspberry. Unfortunately, th...
0.875
{"tests": "{\"inputs\": [[\"Welcome.\"], [\"If a man does not keep pace with his companions, perhaps it is because he hears a different drummer.\"], [\"As Grainier drove along in the wagon behind a wide, slow, sand-colored mare, clusters of orange butterflies exploded off the purple blackish piles of bear sign and wink...
In this kata you will have to modify a sentence so it meets the following rules: convert every word backwards that is: longer than 6 characters OR has 2 or more 'T' or 't' in it convert every word uppercase that is: exactly 2 characters long OR before a comma convert every word to a "0" tha...
0
{"tests": "{\"inputs\": [\"1\\n1 1\\nA\\n\", \"1\\n2 2\\nAA\\nAA\\n\", \"1\\n3 3\\nAAA\\nAAA\\nAAA\\n\", \"1\\n4 4\\nAAAA\\nAAAA\\nAAAA\\nAAAA\\n\", \"4\\n7 8\\nAAPAAAAA\\nAAAAPPPP\\nPPPPAAAA\\nAPAAPPPP\\nAPAPPAPP\\nAAAAPPAP\\nAAAAPPAA\\n6 5\\nAAAAA\\nAAAAA\\nAAPAA\\nAAPAP\\nAAAPP\\nAAAPP\\n4 4\\nPPPP\\nPPPP\\nPPPP\\nP...
You are an all-powerful being and you have created a rectangular world. In fact, your world is so bland that it could be represented by a r × c grid. Each cell on the grid represents a country. Each country has a dominant religion. There are only two religions in your world. One of the religions is called Beingawesomei...
0
{"tests": "{\"inputs\": [\"2\\n5 10\\n6\\n1 1 4\\n2 1\\n1 2 5\\n1 1 4\\n2 1\\n2 2\\n\", \"3\\n5 10 8\\n6\\n1 1 12\\n2 2\\n1 1 6\\n1 3 2\\n2 2\\n2 3\\n\", \"10\\n71 59 88 55 18 98 38 73 53 58\\n20\\n1 5 93\\n1 7 69\\n2 3\\n1 1 20\\n2 10\\n1 6 74\\n1 7 100\\n1 9 14\\n2 3\\n2 4\\n2 7\\n1 3 31\\n2 4\\n1 6 64\\n2 2\\n2 2\\n...
There is a system of n vessels arranged one above the other as shown in the figure below. Assume that the vessels are numbered from 1 to n, in the order from the highest to the lowest, the volume of the i-th vessel is a_{i} liters. [Image] Initially, all the vessels are empty. In some vessels water is poured. All the...
0.25
{"tests": "{\"inputs\": [\"4\", \"1026\", \"1000000001000000000\", \"0\", \"530\", \"1100000001000000000\", \"1\", \"706\", \"1100000001000010000\", \"2\", \"152\", \"1100000001001010000\", \"7\", \"192\", \"1100000011001010000\", \"5\", \"292\", \"1100000001001010010\", \"271\", \"1101000001001010010\", \"266\", \"110...
You are given a positive integer N. Find the number of the pairs of integers u and v (0≦u,v≦N) such that there exist two non-negative integers a and b satisfying a xor b=u and a+b=v. Here, xor denotes the bitwise exclusive OR. Since it can be extremely large, compute the answer modulo 10^9+7. Constraints * 1≦N≦10^{18...
0
{"tests": "{\"inputs\": [\"5 2\\n1 3 1\\n1 5 1\\n\", \"3 2\\n1 3 1\\n1 2 1\\n\", \"10 3\\n4 7 2\\n1 10 3\\n8 9 1\\n\", \"2 1\\n1 2 1\\n\", \"3 1\\n1 2 2\\n\", \"3 1\\n1 3 2\\n\", \"100 1\\n1 100 99\\n\", \"100 1\\n1 100 100\\n\", \"100 1\\n1 100 98\\n\", \"100 2\\n1 100 49\\n1 99 49\\n\", \"10 2\\n3 7 4\\n6 10 1\\n\", ...
Petya studies at university. The current academic year finishes with $n$ special days. Petya needs to pass $m$ exams in those special days. The special days in this problem are numbered from $1$ to $n$. There are three values about each exam: $s_i$ — the day, when questions for the $i$-th exam will be published, $d_...
0
{"tests": "{\"inputs\": [\"10\\n5 6\\n1 1 1 1 1\\n8 32\\n100 52 13 6 9 4 100 35\\n1 1\\n5\\n4 5\\n4 3 2 1\\n5 9\\n2 3 1 4 1\\n5 8\\n2 3 1 4 1\\n4 3\\n2 3 4 1\\n4 9\\n5 4 3 3\\n2 14\\n7 5\\n5 600000000\\n500000000 400000000 300000000 200000000 100000000\\n\", \"1\\n5 5\\n7 7 9 1 1\\n\", \"1\\n10 5\\n100 100 100 100 100 ...
The only difference between the easy and hard versions are the locations you can teleport to. Consider the points $0,1,\dots,n+1$ on the number line. There is a teleporter located on each of the points $1,2,\dots,n$. At point $i$, you can do the following: Move left one unit: it costs $1$ coin. Move right one unit: ...
0
{"tests": "{\"inputs\": [\"5 4 3\\n\", \"6 8 2\\n\", \"5673 9835 437\\n\", \"0 0 1\\n\", \"0 1 1\\n\", \"1 0 1\\n\", \"13240 34544 3\\n\", \"132940 345844 5\\n\", \"108342 203845 62321\\n\", \"2778787205 1763925790 48326734\\n\", \"44649078746 130022042506 981298434\\n\", \"582426543750017 789023129080207 4395672028302...
Soon after the Chunga-Changa island was discovered, it started to acquire some forms of civilization and even market economy. A new currency arose, colloquially called "chizhik". One has to pay in chizhiks to buy a coconut now. Sasha and Masha are about to buy some coconuts which are sold at price $z$ chizhiks per coc...
0.5
{"tests": "{\"inputs\": [[1, -35, -23], [6, 0, -24], [-5, 21, 0], [6, 4, 8], [1, 5, -24], [3, 11, 6], [2, 2, 9], [1, -1.6666666666666667, -26], [1, 6, 10], [7, -2, -5], [1, 8, 20], [2, 3, -2], [1, 4, 12], [3, -2, -5], [3, 4, 9], [5, 4, 0], [4, -5, 0], [1, 4, 9], [1, 0, -49], [2, 8, 8], [1, 0, -0.16], [1, 6, 12], [1, 0,...
Implement function which will return sum of roots of a quadratic equation rounded to 2 decimal places, if there are any possible roots, else return **None/null/nil/nothing**. If you use discriminant,when discriminant = 0, x1 = x2 = root => return sum of both roots. There will always be valid arguments. Quadratic equa...
0
{"tests": "{\"inputs\": [[[12, \"Central\", \"Circle\", 21]], [[\"Piccidilly\", 56]], [[\"Northern\", \"Central\", \"Circle\"]], [[\"Piccidilly\", 56, 93, 243]], [[386, 56, 1, 876]], [[]]], \"outputs\": [[\"£7.80\"], [\"£3.90\"], [\"£7.20\"], [\"£5.40\"], [\"£3.00\"], [\"£0.00\"]]}", "source": "taco"}
You are given a sequence of a journey in London, UK. The sequence will contain bus **numbers** and TFL tube names as **strings** e.g. ```python ['Northern', 'Central', 243, 1, 'Victoria'] ``` Journeys will always only contain a combination of tube names and bus numbers. Each tube journey costs `£2.40` and each bus jou...
0
{"tests": "{\"inputs\": [\"4\\n7\\n0101000\\n1101100\\n5\\n01100\\n10101\\n2\\n01\\n01\\n6\\n000000\\n111111\\n\", \"4\\n7\\n0101000\\n1101100\\n5\\n01100\\n10101\\n2\\n01\\n01\\n6\\n000100\\n111111\\n\", \"4\\n7\\n0101000\\n1101100\\n5\\n01000\\n10101\\n2\\n01\\n01\\n6\\n000000\\n111111\\n\", \"4\\n7\\n0101000\\n11001...
A binary string is a string that consists of characters $0$ and $1$. A bi-table is a table that has exactly two rows of equal length, each being a binary string. Let $\operatorname{MEX}$ of a bi-table be the smallest digit among $0$, $1$, or $2$ that does not occur in the bi-table. For example, $\operatorname{MEX}$ fo...
0
{"tests": "{\"inputs\": [\"3 1 3 1 2\\n\", \"7 2 3 1 3\\n\", \"1000 1 1000 1 1000\\n\", \"10 3 4 2 5\\n\", \"1000 1 68 1 986\\n\", \"1000 1 934 8 993\\n\", \"1000 1 80 2 980\\n\", \"1000 1 467 4 942\\n\", \"1000 739 920 1 679\\n\", \"1000 340 423 2 935\\n\", \"1 1 1 1 1\\n\", \"522 155 404 151 358\\n\", \"81 7 60 34 67...
There are N people, conveniently numbered 1 through N. We want to divide them into some number of groups, under the following two conditions: - Every group contains between A and B people, inclusive. - Let F_i be the number of the groups containing exactly i people. Then, for all i, either F_i=0 or C≤F_i≤D holds. Fin...
0
{"tests": "{\"inputs\": [\"20 50\\n+ 5\\n+ 11\\n- 5\\n+ 6\\n- 16\\n- 13\\n+ 5\\n+ 7\\n- 8\\n- 7\\n- 10\\n+ 10\\n- 20\\n- 19\\n+ 17\\n- 2\\n+ 2\\n+ 19\\n+ 18\\n- 2\\n- 6\\n- 5\\n+ 6\\n+ 4\\n- 14\\n+ 14\\n- 9\\n+ 15\\n- 17\\n- 15\\n+ 2\\n+ 5\\n- 2\\n+ 9\\n- 11\\n+ 2\\n- 19\\n+ 7\\n+ 12\\n+ 16\\n+ 19\\n- 18\\n- 2\\n+ 18\\...
Nearly each project of the F company has a whole team of developers working on it. They often are in different rooms of the office in different cities and even countries. To keep in touch and track the results of the project, the F company conducts shared online meetings in a Spyke chat. One day the director of the F ...
0
{"tests": "{\"inputs\": [\"6\\n000000\\n000000\\n012100\\n024200\\n012100\\n000000\\n\", \"6\\n000000\\n012210\\n024420\\n012210\\n000000\\n000000\\n\", \"6\\n000100\\n001210\\n002420\\n001210\\n000000\\n000000\\n\", \"10\\n0000000000\\n0122210000\\n0244420100\\n0122210000\\n0000000000\\n0000000000\\n0000000000\\n00000...
The zombies are gathering in their secret lair! Heidi will strike hard to destroy them once and for all. But there is a little problem... Before she can strike, she needs to know where the lair is. And the intel she has is not very good. Heidi knows that the lair can be represented as a rectangle on a lattice, with si...
0.5
{"tests": "{\"inputs\": [\"3 3 5\\n\", \"2 4 4\\n\", \"1 1 1\\n\", \"1 1000000000 1000000000\\n\", \"8 7 5\\n\", \"1000000000 1 1\\n\", \"1000000000 1000000000 1000000000\\n\", \"800000003 7 7\\n\", \"11 7 7\\n\", \"1000000000 1 1\\n\", \"100000 100 1000\\n\", \"1000000000 6000 1000000\\n\", \"1 1000000000 1000000000\\...
The start of the new academic year brought about the problem of accommodation students into dormitories. One of such dormitories has a a × b square meter wonder room. The caretaker wants to accommodate exactly n students there. But the law says that there must be at least 6 square meters per student in a room (that is,...
0
{"tests": "{\"inputs\": [\"3\\n1 0\\n0 8\\n7 1\", \"3\\n1 0\\n0 8\\n7 2\", \"3\\n1 0\\n0 10\\n7 2\", \"3\\n1 0\\n0 17\\n7 2\", \"3\\n1 1\\n0 17\\n7 2\", \"3\\n1 1\\n0 4\\n7 2\", \"3\\n1 0\\n0 4\\n7 2\", \"3\\n1 0\\n0 4\\n7 1\", \"3\\n1 0\\n0 3\\n7 1\", \"3\\n1 1\\n0 8\\n7 2\", \"3\\n1 0\\n0 27\\n7 2\", \"3\\n1 0\\n0 4\...
N programmers are going to participate in the preliminary stage of DDCC 20XX. Due to the size of the venue, however, at most 9 contestants can participate in the finals. The preliminary stage consists of several rounds, which will take place as follows: * All the N contestants will participate in the first round. * W...
0
{"tests": "{\"inputs\": [\"30\\n9 1\\n1 6\\n2 10\\n6 8\\n5 5\\n5 10\\n8 6\\n10 8\\n7 7\\n8 5\\n6 4\\n1 5\\n8 4\\n4 6\\n7 3\\n5 1\\n9 2\\n5 6\\n5 9\\n10 9\\n7 8\\n5 2\\n6 3\\n10 5\\n9 8\\n10 2\\n3 5\\n7 10\\n10 6\\n2 6\\n\", \"35\\n8 1\\n6 8\\n4 1\\n1 2\\n1 4\\n5 10\\n10 8\\n9 1\\n9 9\\n10 2\\n6 5\\n8 8\\n7 6\\n10 6\\n9...
There are n points on the plane, the i-th of which is at (x_i, y_i). Tokitsukaze wants to draw a strange rectangular area and pick all the points in the area. The strange area is enclosed by three lines, x = l, y = a and x = r, as its left side, its bottom side and its right side respectively, where l, r and a can be ...
0
{"tests": "{\"inputs\": [\"100\\n1\\n2\\n3\\n4\\n5\\n6\\n7\\n8\\n9\\n10\\n11\\n12\\n13\\n14\\n15\\n16\\n17\\n18\\n19\\n20\\n21\\n22\\n23\\n24\\n25\\n26\\n27\\n28\\n29\\n30\\n31\\n32\\n33\\n34\\n35\\n36\\n37\\n38\\n39\\n40\\n41\\n42\\n43\\n44\\n45\\n46\\n47\\n48\\n49\\n50\\n51\\n52\\n53\\n54\\n55\\n56\\n57\\n58\\n59\\n6...
Karl is developing a key storage service. Each user has a positive integer key. Karl knows that storing keys in plain text is bad practice. So, instead of storing a key, he decided to store a fingerprint of a key. However, using some existing fingerprint algorithm looked too boring to him, so he invented his own one. ...
0
{"tests": "{\"inputs\": [\"4\\n\", \"7\\n\", \"77\\n\", \"4\\n\", \"474744\\n\", \"777774\\n\", \"447\\n\", \"774\\n\", \"4\\n\", \"4447747\\n\", \"7747474\\n\", \"4444\\n\", \"4447\\n\", \"7\\n\", \"4\\n\", \"4447744\\n\", \"77474\\n\", \"7747\\n\", \"444\\n\", \"7\\n\", \"7774477\\n\", \"4477774\\n\", \"7444\\n\", \"...
Once again Tavas started eating coffee mix without water! Keione told him that it smells awful, but he didn't stop doing that. That's why Keione told his smart friend, SaDDas to punish him! SaDDas took Tavas' headphones and told him: "If you solve the following problem, I'll return it to you." [Image] The problem is:...
0.375
{"tests": "{\"inputs\": [[0], [1], [2], [10], [100], [1000], [10000], [100000], [1000000], [10000000]], \"outputs\": [[0], [1], [2], [6], [20], [118], [720], [11108], [114952], [1153412]]}", "source": "taco"}
*This kata is based on [Project Euler Problem #349](https://projecteuler.net/problem=349). You may want to start with solving [this kata](https://www.codewars.com/kata/langtons-ant) first.* --- [Langton's ant](https://en.wikipedia.org/wiki/Langton%27s_ant) moves on a regular grid of squares that are coloured either b...
0
{"tests": "{\"inputs\": [\"2\\n1 2 2 2\\n1 1 2 2\\n\", \"1\\n69 69 69 69\\n\", \"5\\n1 1 1000000000 1000000000\\n1 1 1000000000 1000000000\\n1 1 1000000000 1000000000\\n1 1 1000000000 1000000000\\n1 1 65537 65537\\n\", \"1\\n1 1 131073 131073\\n\", \"1\\n69 69 69 69\\n\", \"1\\n3 2 4 7\\n\", \"5\\n1 1 1000000000 100000...
Wabbit is trying to move a box containing food for the rest of the zoo in the coordinate plane from the point $(x_1,y_1)$ to the point $(x_2,y_2)$. He has a rope, which he can use to pull the box. He can only pull the box if he stands exactly $1$ unit away from the box in the direction of one of two coordinate axes. H...
0.125
{"tests": "{\"inputs\": [\"1\\n100000\\n\", \"3\\n0 0 3\\n\", \"1\\n100010\\n\", \"5\\n0 11 1 13 14\\n\", \"5\\n0 12 1 13 14\\n\", \"3\\n0 3 3\\n\", \"3\\n0 1 2\\n\", \"4\\n2 1 0 1\\n\", \"4\\n0 6 0 6\\n\", \"4\\n4 0 0 0\\n\", \"5\\n1 3 0 13 48\\n\", \"5\\n0 1 3 3 13\\n\", \"3\\n0 2 3\\n\", \"4\\n0 6 0 4\\n\", \"1\\n00...
An array is called beautiful if all the elements in the array are equal. You can transform an array using the following steps any number of times: 1. Choose two indices i and j (1 ≤ i,j ≤ n), and an integer x (1 ≤ x ≤ a_i). Let i be the source index and j be the sink index. 2. Decrease the i-th element by x, an...
0
{"tests": "{\"inputs\": [[[12, 10, 8, 12, 7, 6, 4, 10, 12]], [[12, 10, 8, 12, 7, 6, 4, 10, 10]], [[12, 10, 8, 12, 7, 6, 4, 10, 12, 10]], [[12, 10, 8, 8, 3, 3, 3, 3, 2, 4, 10, 12, 10]], [[1, 2, 3]], [[1, 1, 2, 3]], [[1, 1, 2, 2, 3]]], \"outputs\": [[12], [10], [12], [3], [3], [1], [2]]}", "source": "taco"}
Complete the method which returns the number which is most frequent in the given input array. If there is a tie for most frequent number, return the largest number among them. Note: no empty arrays will be given. ## Examples ``` [12, 10, 8, 12, 7, 6, 4, 10, 12] --> 12 [12, 10, 8, 12, 7, 6, 4, 10, 12, ...
0
{"tests": "{\"inputs\": [[[1, 2, 3, 4], [5, 6, 7, 8]], [[10, 8, 6, 4, 2], [9, 7, 5, 3, 1]], [[-20, 35, 36, 37, 39, 40], [-10, -5, 0, 6, 7, 8, 9, 10, 25, 38, 50, 62]], [[5, 6, 7, 8, 9, 10], [20, 18, 15, 14, 13, 12, 11, 4, 3, 2]], [[45, 30, 20, 15, 12, 5], [9, 10, 18, 25, 35, 50]], [[-8, -3, -2, 4, 5, 6, 7, 15, 42, 90, 1...
You are given two sorted arrays that contain only integers. Your task is to find a way to merge them into a single one, sorted in **ascending order**. Complete the function `mergeArrays(arr1, arr2)`, where `arr1` and `arr2` are the original sorted arrays. You don't need to worry about validation, since `arr1` and `arr...
0
{"tests": "{\"inputs\": [\"8679647744\\n\", \"9070901003919040000887091134838800004472724709967020097067025050205000220352709096100405900207957128\\n\", \"3311314413231141411421432122343321141133112122342341334443214\\n\", \"1099\\n\", \"993522733475817\\n\", \"346762409573609367635944363650432097309\\n\", \"3037225037...
Andrey's favourite number is n. Andrey's friends gave him two identical numbers n as a New Year present. He hung them on a wall and watched them adoringly. Then Andrey got bored from looking at the same number and he started to swap digits first in one, then in the other number, then again in the first number and so o...
0
{"tests": "{\"inputs\": [\"3\\n4 5\\n4 5\\n4 10\\n\", \"4\\n1 100\\n100 1\\n1 100\\n100 1\\n\", \"3\\n1 1\\n100 100\\n1 1\\n\", \"10\\n21005 10850\\n27020 13372\\n28183 3724\\n22874 13564\\n27446 11493\\n22522 10012\\n24819 11529\\n24166 11084\\n24539 9211\\n24152 9235\\n\", \"1\\n1 0\\n\", \"1\\n1 1000000\\n\", \"1\\n...
Mayor of city S just hates trees and lawns. They take so much space and there could be a road on the place they occupy! The Mayor thinks that one of the main city streets could be considerably widened on account of lawn nobody needs anyway. Moreover, that might help reduce the car jams which happen from time to time o...
0.125
{"tests": "{\"inputs\": [\"5\\n1 - 2 + 2 - 4 + 5\", \"5\\n1 - 38 - 13 + 14 - 5\", \"5\\n1 - 45 - 13 + 14 - 5\", \"5\\n2 - 45 - 13 + 14 - 5\", \"5\\n2 - 80 - 13 + 14 - 5\", \"5\\n2 - 57 - 13 + 14 - 5\", \"5\\n2 - 39 - 13 + 9 - 5\", \"5\\n1 - 2 + 0 - 4 + 5\", \"5\\n1 - 6 - 13 + 14 - 5\", \"5\\n2 - 45 - 7 + 14 - 5\", \"5\...
Joisino has a formula consisting of N terms: A_1 op_1 A_2 ... op_{N-1} A_N. Here, A_i is an integer, and op_i is an binary operator either `+` or `-`. Because Joisino loves large numbers, she wants to maximize the evaluated value of the formula by inserting an arbitrary number of pairs of parentheses (possibly zero) in...
0
{"tests": "{\"inputs\": [\"abcdd\\n\", \"abbcdddeaaffdfouurtytwoo\\n\", \"g\\n\", \"tt\\n\", \"go\\n\", \"eefffffffkkkkxxxx\\n\", \"jjjjjjjjkkdddddiirg\\n\", \"nnnnnnwwwwwwxll\\n\", \"kkkkkccaaaaaqqqqqqqq\\n\", \"iiiiilleeeeeejjjjjjn\\n\", \"xxxxxxxxxxxxxxtttttt\\n\", \"iiiiiitttttyyyyyyyyp\\n\", \"arexjrujgilmbbao\\n\...
Some time ago Lesha found an entertaining string $s$ consisting of lowercase English letters. Lesha immediately developed an unique algorithm for this string and shared it with you. The algorithm is as follows. Lesha chooses an arbitrary (possibly zero) number of pairs on positions $(i, i + 1)$ in such a way that the ...
0
{"tests": "{\"inputs\": [[4, 3], [4, 2], [4, 4], [4, 1], [4, 0], [4, 5], [20, 8]], \"outputs\": [[6], [7], [1], [1], [0], [\"It cannot be possible!\"], [15170932662679]]}", "source": "taco"}
You have a set of four (4) balls labeled with different numbers: ball_1 (1), ball_2 (2), ball_3 (3) and ball(4) and we have 3 equal boxes for distribute them. The possible combinations of the balls, without having empty boxes, are: ``` (1) (2) (3)(4) ______ ______ _______ ```...
0
{"tests": "{\"inputs\": [\"1 2\", \"6 3\", \"1 3\", \"6 6\", \"2 3\", \"10 6\", \"2 6\", \"10 8\", \"4 6\", \"12 8\", \"8 6\", \"8 8\", \"8 3\", \"10 14\", \"5 3\", \"13 6\", \"5 4\", \"13 1\", \"7 4\", \"3 1\", \"2 4\", \"6 1\", \"2 2\", \"9 1\", \"4 2\", \"1 1\", \"4 1\", \"6 2\", \"1 6\", \"10 4\", \"4 3\", \"15 6\"...
Today, Snuke will eat B pieces of black chocolate and W pieces of white chocolate for an afternoon snack. He will repeat the following procedure until there is no piece left: * Choose black or white with equal probability, and eat a piece of that color if it exists. For each integer i from 1 to B+W (inclusive), fi...
0
{"tests": "{\"inputs\": [\"5 2\\n1 2\\n2 3\\n\", \"100 3\\n1 2\\n2 1\\n3 1\\n\", \"1 2\\n1 1\\n2 100\\n\", \"25 29\\n82963 53706\\n63282 73962\\n14996 48828\\n84392 31903\\n96293 41422\\n31719 45448\\n46772 17870\\n9668 85036\\n36704 83323\\n73674 63142\\n80254 1548\\n40663 44038\\n96724 39530\\n8317 42191\\n44289 1041...
Let's call an array consisting of n integer numbers a_1, a_2, ..., a_{n}, beautiful if it has the following property: consider all pairs of numbers x, y (x ≠ y), such that number x occurs in the array a and number y occurs in the array a; for each pair x, y must exist some position j (1 ≤ j < n), such that at least...
0
{"tests": "{\"inputs\": [\"386 20 29 30\\n1 349\\n2 482\\n1 112\\n1 93\\n2 189\\n1 207\\n2 35\\n2 -5\\n1 422\\n1 442\\n1 402\\n2 238\\n3 258\\n3 54\\n2 369\\n2 290\\n2 329\\n3 74\\n3 -62\\n2 170\\n1 462\\n2 15\\n2 222\\n1 309\\n3 150\\n1 -25\\n3 130\\n1 271\\n1 -43\\n351 250 91 102 0 286 123 93 100 205 328 269 188 83 7...
Motorist Kojiro spent 10 years saving up for his favorite car brand, Furrari. Finally Kojiro's dream came true! Kojiro now wants to get to his girlfriend Johanna to show off his car to her. Kojiro wants to get to his girlfriend, so he will go to her along a coordinate line. For simplicity, we can assume that Kojiro is...
0
{"tests": "{\"inputs\": [\"5\\n1 2 3 4 5\\n\", \"3\\n1 2 4\\n\", \"3\\n1 20 22\\n\", \"10\\n109070199 215498062 361633800 406156967 452258663 530571268 670482660 704334662 841023955 967424642\\n\", \"30\\n61 65 67 71 73 75 77 79 129 131 135 137 139 141 267 520 521 522 524 526 1044 1053 6924600 32125372 105667932 109158...
Vasily the bear has got a sequence of positive integers a_1, a_2, ..., a_{n}. Vasily the Bear wants to write out several numbers on a piece of paper so that the beauty of the numbers he wrote out was maximum. The beauty of the written out numbers b_1, b_2, ..., b_{k} is such maximum non-negative integer v, that numbe...
0
{"tests": "{\"inputs\": [\"15 38\", \"0 1\", \"16 38\", \"16 57\", \"16 94\", \"12 94\", \"12 28\", \"19 28\", \"6 27\", \"12 25\", \"9 48\", \"12 39\", \"26 38\", \"24 94\", \"6 42\", \"30 32\", \"14 68\", \"5 37\", \"31 48\", \"22 79\", \"21 38\", \"21 94\", \"24 51\", \"18 58\", \"21 63\", \"12 51\", \"0 0\", \"1 51...
Today is August 24, one of the five Product Days in a year. A date m-d (m is the month, d is the date) is called a Product Day when d is a two-digit number, and all of the following conditions are satisfied (here d_{10} is the tens digit of the day and d_1 is the ones digit of the day): * d_1 \geq 2 * d_{10} \geq 2 *...
0.375
{"tests": "{\"inputs\": [\"3\\n\", \"5\\n\", \"13\\n\", \"1\\n\", \"2\\n\", \"4\\n\", \"6\\n\", \"15\\n\", \"16\\n\", \"7\\n\", \"8\\n\", \"9\\n\", \"10\\n\", \"11\\n\", \"12\\n\", \"14\\n\", \"9\\n\", \"11\\n\", \"14\\n\", \"7\\n\", \"16\\n\", \"8\\n\", \"15\\n\", \"6\\n\", \"10\\n\", \"4\\n\", \"12\\n\", \"1\\n\", \"...
Permutation p is an ordered set of integers p_1, p_2, ..., p_{n}, consisting of n distinct positive integers, each of them doesn't exceed n. We'll denote the i-th element of permutation p as p_{i}. We'll call number n the size or the length of permutation p_1, p_2, ..., p_{n}. Petya decided to introduce the sum ...
0
{"tests": "{\"inputs\": [\"oXoxoXo\\n\", \"bod\\n\", \"ER\\n\", \"o\\n\", \"a\\n\", \"opo\\n\", \"HCMoxkgbNb\\n\", \"vMhhXCMWDe\\n\", \"iIcamjTRFH\\n\", \"WvoWvvWovW\\n\", \"WXxAdbAxXW\\n\", \"vqMTUUTMpv\\n\", \"iii\\n\", \"AAWW\\n\", \"ss\\n\", \"i\\n\", \"ii\\n\", \"mm\\n\", \"LJ\\n\", \"m\\n\", \"ioi\\n\", \"OA\\n\"...
Let's call a string "s-palindrome" if it is symmetric about the middle of the string. For example, the string "oHo" is "s-palindrome", but the string "aa" is not. The string "aa" is not "s-palindrome", because the second half of it is not a mirror reflection of the first half. [Image] English alphabet You are given...
0.25
{"tests": "{\"inputs\": [\"1 1\\n\", \"3 2\\n\", \"5 3\\n\", \"12 4\\n\", \"20 5\\n\", \"522 4575\\n\", \"1426 4445\\n\", \"81 3772\\n\", \"629 3447\\n\", \"2202 3497\\n\", \"2775 4325\\n\", \"3982 4784\\n\", \"2156 3417\\n\", \"902 1932\\n\", \"728 3537\\n\", \"739 3857\\n\", \"1918 4211\\n\", \"3506 4679\\n\", \"1000...
You have a team of N people. For a particular task, you can pick any non-empty subset of people. The cost of having x people for the task is x^{k}. Output the sum of costs over all non-empty subsets of people. -----Input----- Only line of input contains two integers N (1 ≤ N ≤ 10^9) representing total number of pe...
0
{"tests": "{\"inputs\": [\"5 10 4 16\\n.#####....\\n##..#..##.\\n.#..##.#..\\n##..#####.\\n...#.##..#\\n\", \"1 1 1 2\\n.\\n\", \"6 3 1 4\\n##.\\n#..\\n#..\\n..#\\n.#.\\n#.#\\n\", \"69 1 1 2\\n#\\n.\\n#\\n#\\n.\\n#\\n#\\n.\\n.\\n#\\n.\\n.\\n#\\n.\\n#\\n#\\n.\\n#\\n#\\n#\\n#\\n#\\n.\\n#\\n.\\n.\\n#\\n#\\n#\\n.\\n.\\n.\\...
You've got an n × m pixel picture. Each pixel can be white or black. Your task is to change the colors of as few pixels as possible to obtain a barcode picture. A picture is a barcode if the following conditions are fulfilled: * All pixels in each column are of the same color. * The width of each monochrome ver...
0
{"tests": "{\"inputs\": [\"4\\n13 12 20 12\\n**.*\\n....\\n***.\\n*.**\\n\", \"4\\n1 1 1 1\\n....\\n....\\n....\\n....\\n\", \"6\\n2 2 2 1\\n*.****\\n.*....\\n.*.***\\n*.***.\\n\", \"6\\n8 2 11 9\\n.*.***\\n..**.*\\n.**.**\\n*.****\\n\", \"5\\n9 19 10 7\\n.....\\n*.*.*\\n.*.**\\n..**.\\n\", \"6\\n1 2 2 1\\n...*.*\\n.**...
You are given a matrix f with 4 rows and n columns. Each element of the matrix is either an asterisk (*) or a dot (.). You may perform the following operation arbitrary number of times: choose a square submatrix of f with size k × k (where 1 ≤ k ≤ 4) and replace each element of the chosen submatrix with a dot. Choosin...
0
{"tests": "{\"inputs\": [\"6\\n5\\n1 2\\n1 3\\n3 4\\n2 3\\n4 5\\n6\\n5\\n2 3\\n3 4\\n4 5\\n5 6\\n2 6\\n0\\n0\", \"6\\n5\\n1 2\\n1 3\\n3 4\\n2 3\\n4 5\\n6\\n5\\n2 3\\n3 4\\n1 5\\n5 6\\n2 6\\n0\\n0\", \"6\\n5\\n1 2\\n1 3\\n3 5\\n2 3\\n4 5\\n6\\n5\\n2 3\\n3 4\\n1 5\\n6 6\\n2 6\\n0\\n0\", \"6\\n5\\n1 2\\n1 3\\n3 5\\n2 3\\n...
problem You decide to invite your friends of the school and your friends of a friend to the Christmas party. The number of students in your school is n, and each student is assigned a number from 1 to n. Your number is 1. You have a list of who and who are your friends. Based on this list, create a program that asks f...
0.25
{"tests": "{\"inputs\": [\"0111 1\", \"01000110 2\", \"1101010010101101110111100011011111011000111101110111010010101010101 20\", \"0111 0\", \"01000110 4\", \"1101010010101101110111100011011111011000111101110111010010101010101 17\", \"0011 1\", \"01100110 4\", \"110001001010110111011110001101111101100011110111011101001...
Given is a string S consisting of `0` and `1`. Find the number of strings, modulo 998244353, that can result from applying the following operation on S between 0 and K times (inclusive): * Choose a pair of integers i, j (1\leq i < j\leq |S|) such that the i-th and j-th characters of S are `0` and `1`, respectively. Re...
0
{"tests": "{\"inputs\": [\"1 -1\\n1 1\\n1 2\\n\", \"-1 -1\\n-1 3\\n4 3\\n\", \"1 1\\n2 3\\n3 2\\n\", \"1000000000 -1000000000\\n1000000000 1000000000\\n-1000000000 -1000000000\\n\", \"-510073119 -991063686\\n583272581 -991063686\\n623462417 -991063686\\n\", \"-422276230 -422225325\\n-422276230 -544602611\\n-282078856 -...
There are three points marked on the coordinate plane. The goal is to make a simple polyline, without self-intersections and self-touches, such that it passes through all these points. Also, the polyline must consist of only segments parallel to the coordinate axes. You are to find the minimum number of segments this p...
0
{"tests": "{\"inputs\": [[\"\"], [\"0\"], [\"0oO0oO\"], [\"1234567890\"], [\"abcdefghijklmnopqrstuvwxyz\"], [\"()\"], [\"E\"], [\"aA\"], [\"BRA\"], [\"%%\"]], \"outputs\": [[0], [1], [6], [5], [8], [1], [0], [1], [3], [4]]}", "source": "taco"}
Gigi is a clever monkey, living in the zoo, his teacher (animal keeper) recently taught him some knowledge of "0". In Gigi's eyes, "0" is a character contains some circle(maybe one, maybe two). So, a is a "0",b is a "0",6 is also a "0",and 8 have two "0" ,etc... Now, write some code to count how many "0"s in the tex...
0
{"tests": "{\"inputs\": [[[1, 2, 3, 4, 5, 8, 7, 8, 9]], [[2, 8, 6, 7, 4, 3, 1, 5, 9]], [[1, 2, 3, 4, 5, 6, 7, 8, 9]], [[0, 1, 2, 3, 4, 5, 6, 7, 8]], [[1, 3, 5, 7, 9, 11, 13, 15]], [[1, 3, 5, 7, 8, 12, 14, 16]], [[0, 1, 1, 2, 3, 5, 8, 13, 21, 34]], [[0, 2, 4, 6, 8]], [[2, 4, 6, 8, 10]], [[2, 4, 6, 8, 10, 12, 14, 16, 18,...
Create a function that will return true if all numbers in the sequence follow the same counting pattern. If the sequence of numbers does not follow the same pattern, the function should return false. Sequences will be presented in an array of varied length. Each array will have a minimum of 3 numbers in it. The seque...
0
{"tests": "{\"inputs\": [\"15 15 15\\n1 10 1\\n2 11 0\\n2 6 4\\n1 1 0\\n1 7 5\\n1 14 3\\n1 3 1\\n1 4 2\\n1 9 0\\n2 10 1\\n1 12 1\\n2 2 0\\n1 5 3\\n2 3 0\\n2 4 2\\n\", \"5 20 20\\n1 15 3\\n2 15 3\\n2 3 1\\n2 1 0\\n1 16 4\\n\", \"3 4 5\\n1 3 9\\n2 1 9\\n1 2 8\\n\", \"20 50000 50000\\n2 45955 55488\\n1 19804 29337\\n2 376...
Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size w × h, represented by a rectangle with corners (0, 0), (w, 0), (w, h) and (0, h). It can be seen that no collisions will happen before one enters the stage. On the sides of t...
0
{"tests": "{\"inputs\": [\"3\\n0 2 2\\n1 1 0\\n\", \"2\\n1 1\\n1 0\\n\", \"10\\n0 1 2 3 5 5 6 7 8 5\\n9 8 7 1 5 4 3 2 0 0\\n\", \"5\\n0 0 1 4 2\\n0 2 0 1 0\\n\", \"1\\n1\\n0\\n\", \"10\\n1 1 1 0 3 0 6 2 4 5\\n7 6 2 3 5 1 2 0 1 0\\n\", \"10\\n1 0 2 2 5 0 0 0 2 7\\n4 3 1 0 4 3 3 2 1 0\\n\", \"19\\n1 1 3 4 5 3 5 7 0 6 5 3...
Frog Gorf is traveling through Swamp kingdom. Unfortunately, after a poor jump, he fell into a well of $n$ meters depth. Now Gorf is on the bottom of the well and has a long way up. The surface of the well's walls vary in quality: somewhere they are slippery, but somewhere have convenient ledges. In other words, if Go...
0
{"tests": "{\"inputs\": [\"1 1\\n.\\n\", \"2 3\\n...\\n..R\\n\", \"4 4\\n...R\\n.RR.\\n.RR.\\nR...\\n\", \"1 3\\n.R.\\n\", \"2 2\\n.R\\nR.\\n\", \"10 10\\n..........\\n..........\\n..........\\n..........\\n..........\\n..........\\n..........\\n..........\\n..........\\n..........\\n\", \"1 3\\n.R.\\n\", \"2 2\\n.R\\n...
You are at the top left cell $(1, 1)$ of an $n \times m$ labyrinth. Your goal is to get to the bottom right cell $(n, m)$. You can only move right or down, one cell per step. Moving right from a cell $(x, y)$ takes you to the cell $(x, y + 1)$, while moving down takes you to the cell $(x + 1, y)$. Some cells of the la...
0
{"tests": "{\"inputs\": [\"20\\n4 13\\n17 7\\n19 10\\n18 1\\n5 15\\n2 6\\n11 7\\n3 6\\n5 1\\n20 16\\n12 5\\n10 17\\n14 18\\n8 13\\n13 15\\n19 1\\n9 19\\n6 13\\n17 20\\n14 12 4 2 3 9 8 11 16\\n\", \"37\\n27 3\\n27 35\\n6 8\\n12 21\\n4 7\\n32 27\\n27 17\\n24 14\\n1 10\\n3 23\\n20 8\\n12 4\\n16 33\\n2 34\\n15 36\\n5 31\\n...
Connected undirected graph without cycles is called a tree. Trees is a class of graphs which is interesting not only for people, but for ants too. An ant stands at the root of some tree. He sees that there are n vertexes in the tree, and they are connected by n - 1 edges so that there is a path between any pair of ver...
0.25
{"tests": "{\"inputs\": [[1965], [1938], [1998], [2016], [1924], [1968], [2162], [6479], [3050], [6673], [6594], [9911], [2323], [3448], [1972]], \"outputs\": [[\"Wood Snake\"], [\"Earth Tiger\"], [\"Earth Tiger\"], [\"Fire Monkey\"], [\"Wood Rat\"], [\"Earth Monkey\"], [\"Water Dog\"], [\"Earth Goat\"], [\"Metal Dog\"...
The [Chinese zodiac](https://en.wikipedia.org/wiki/Chinese_zodiac) is a repeating cycle of 12 years, with each year being represented by an animal and its reputed attributes. The lunar calendar is divided into cycles of 60 years each, and each year has a combination of an animal and an element. There are 12 animals and...
0.125
{"tests": "{\"inputs\": [\"3 9\\n500\\n300\\n800\\n200\\n100\\n600\\n900\\n700\\n400\\n4 3\\n1000\\n1000\\n1010\\n0 0\", \"3 9\\n500\\n311\\n800\\n335\\n100\\n600\\n900\\n700\\n400\\n4 3\\n1000\\n1000\\n1010\\n0 0\", \"3 9\\n559\\n311\\n800\\n335\\n100\\n563\\n900\\n700\\n400\\n4 3\\n1000\\n1000\\n1010\\n0 0\", \"3 9\\...
Taro is addicted to a novel. The novel has n volumes in total, and each volume has a different thickness. Taro likes this novel so much that he wants to buy a bookshelf dedicated to it. However, if you put a large bookshelf in the room, it will be quite small, so you have to devise to make the width of the bookshelf as...
0.375
{"tests": "{\"inputs\": [\"3 3 3\\n1 2 3\\n2 3 3\\n1 3 8\\n12 12 2010\\n1 2 0\\n2 3 3000\\n3 4 0\\n4 5 3000\\n5 6 3000\\n6 12 2010\\n2 7 100\\n7 8 200\\n8 9 300\\n9 10 400\\n10 11 500\\n11 6 512\\n10 18 1\\n1 2 7\\n1 3 2\\n1 4 6\\n2 5 0\\n2 6 10\\n2 7 2\\n3 5 10\\n3 6 3\\n3 7 10\\n4 7 6\\n5 8 10\\n6 8 2\\n6 9 11\\n7 9 ...
You are a judge of a programming contest. You are preparing a dataset for a graph problem to seek for the cost of the minimum cost path. You've generated some random cases, but they are not interesting. You want to produce a dataset whose answer is a desired value such as the number representing this year 2010. So you ...
0
{"tests": "{\"inputs\": [\"6\\n6 3\\nabcbac\\n3 6\\naaa\\n7 1000\\nabczgyo\\n5 4\\nababa\\n20 10\\naaebdbabdbbddaadaadc\\n20 5\\necbedececacbcbccbdec\\n\", \"1\\n7 1782\\nabcabca\\n\", \"1\\n7 1782\\nabcabca\\n\", \"1\\n364 1485\\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbc...
The store sells $n$ beads. The color of each bead is described by a lowercase letter of the English alphabet ("a"–"z"). You want to buy some beads to assemble a necklace from them. A necklace is a set of beads connected in a circle. For example, if the store sells beads "a", "b", "c", "a", "c", "c", then you can asse...
0.75
{"tests": "{\"inputs\": [[\"body p\", \"div\"], [\"body\", \"html\"], [\"p a\", \"span\"], [\"div p span a\", \"div p span a b\"], [\"strong\", \"p b\"], [\".first\", \".last\"], [\".foo.bar\", \".x .y\"], [\".x .y\", \".foo.bar\"], [\".red.apple\", \".red\"], [\".test1 .test2.test3\", \".test1 .test4 .test5 .test6\"],...
Cascading Style Sheets (CSS) is a style sheet language used for describing the look and formatting of a document written in a markup language. A style sheet consists of a list of rules. Each rule or rule-set consists of one or more selectors, and a declaration block. Selector describes which element it matches. Someti...
0
{"tests": "{\"inputs\": [[100, \"C\", \"F\"], [-30, \"De\", \"K\"], [40, \"Re\", \"C\"], [60, \"De\", \"F\"], [373.15, \"K\", \"N\"], [666, \"K\", \"K\"], [60, \"C\", \"F\"], [60, \"De\", \"C\"], [128.25, \"Ro\", \"C\"], [-273.15, \"C\", \"R\"], [0, \"K\", \"R\"]], \"outputs\": [[212], [393], [50], [140], [33], [666], ...
Write a function ```convert_temp(temp, from_scale, to_scale)``` converting temperature from one scale to another. Return converted temp value. Round converted temp value to an integer(!). Reading: http://en.wikipedia.org/wiki/Conversion_of_units_of_temperature ``` possible scale inputs: "C" for Celsius "F...
0.125
{"tests": "{\"inputs\": [\"5\\n3\\nTMT\\n3\\nMTT\\n6\\nTMTMTT\\n6\\nTMTTTT\\n6\\nTTMMTT\\n\", \"5\\n3\\nTMT\\n3\\nMTT\\n6\\nTMTMTT\\n6\\nMTTTTT\\n6\\nTTMMTT\\n\", \"5\\n3\\nTMT\\n3\\nMTT\\n6\\nTMTMTT\\n6\\nMTTTTT\\n6\\nTTMTTM\\n\", \"5\\n3\\nTMT\\n3\\nMTT\\n6\\nTTTMMT\\n6\\nTMTTTT\\n6\\nTTMMTT\\n\", \"5\\n3\\nTTM\\n3\\...
The student council has a shared document file. Every day, some members of the student council write the sequence TMT (short for Towa Maji Tenshi) in it. However, one day, the members somehow entered the sequence into the document at the same time, creating a jumbled mess. Therefore, it is Suguru Doujima's task to fig...
0
{"tests": "{\"inputs\": [\"22\\n697 556 -538 879 -623 73 -293 -401 -491 -7 -144 853 -319 395 785 248 -585 0 -420 -830 -720 75 411 -397 746 828 -83 -833 -847 709 181 967 314 -633 -322 415 -450 433 -459 438 508 -870 -949\\n\", \"27\\n-401 -840 -583 -612 -298 -384 798 366 -922 -443 -972 -271 127 -201 992 -748 -351 925 -17...
Yaroslav has an array, consisting of (2·n - 1) integers. In a single operation Yaroslav can change the sign of exactly n elements in the array. In other words, in one operation Yaroslav can select exactly n array elements, and multiply each of them by -1. Yaroslav is now wondering: what maximum sum of array elements c...
0.375