info
stringlengths
120
50k
question
stringlengths
504
10.4k
avg@8_qwen3_4b_instruct_2507
float64
0
0.88
{"tests": "{\"inputs\": [\"47 16\\n-13 -52\\n-253 -324\\n\", \"635167 -889045\\n1429362 -1770135\\n2223557 -2651225\\n\", \"-1000000000 0\\n0 0\\n0 1000000000\\n\", \"0 994599799\\n0 0\\n-999999928 0\\n\", \"-22 -84\\n-117 8\\n-25 103\\n\", \"8662 -907734\\n-73417 -1195869\\n-401733 -2348409\\n\", \"0 0\\n100000007 0\\...
Trouble came from the overseas lands: a three-headed dragon Gorynych arrived. The dragon settled at point C and began to terrorize the residents of the surrounding villages. A brave hero decided to put an end to the dragon. He moved from point A to fight with Gorynych. The hero rode from point A along a straight road ...
0.75
{"tests": "{\"inputs\": [[1, 0], [1, 10], [1, 11], [0, 11], [1, 20], [21, 30]], \"outputs\": [[0], [0], [2], [0], [4], [448]]}", "source": "taco"}
Following from the previous kata and taking into account how cool psionic powers are compare to the Vance spell system (really, the idea of slots to dumb down the game sucks, not to mention that D&D became a smash hit among geeks, so...), your task in this kata is to create a function that returns how many power points...
0
{"tests": "{\"inputs\": [\"5\\n82195\\n64723\\n\", \"12\\n102021090898\\n010212908089\\n\", \"1\\n8\\n1\\n\", \"2\\n83\\n57\\n\", \"10\\n0728592530\\n1362615763\\n\", \"100\\n4176196363694273682807653052945037727131821799902563705176501742060696655282954944720643131654235909\\n345991208492215450591028749987997565929823...
Scrooge McDuck keeps his most treasured savings in a home safe with a combination lock. Each time he wants to put there the treasures that he's earned fair and square, he has to open the lock. [Image] The combination lock is represented by n rotating disks with digits from 0 to 9 written on them. Scrooge McDuck has...
0.875
{"tests": "{\"inputs\": [\"4 7 12 15\\n\", \"1 463129088 536870913 1000000000\\n\", \"1 4 4 7\\n\", \"1 2 3 3\\n\", \"1 1 2 1000000000\\n\", \"8136 12821 10573 15189\\n\", \"169720415 312105195 670978284 671296539\\n\", \"654444727 988815385 77276659 644738371\\n\", \"26733 47464 19138 46248\\n\", \"42765 7043311 39308...
Polycarpus analyzes a string called abracadabra. This string is constructed using the following algorithm: * On the first step the string consists of a single character "a". * On the k-th step Polycarpus concatenates two copies of the string obtained on the (k - 1)-th step, while inserting the k-th character of ...
0
{"tests": "{\"inputs\": [\"4\\nmail\\nai\\nlru\\ncf\\n\", \"3\\nkek\\npreceq\\ncheburek\\n\", \"1\\nz\\n\", \"2\\nab\\nba\\n\", \"2\\nac\\nbc\\n\", \"2\\ncd\\nce\\n\", \"2\\nca\\ncb\\n\", \"2\\ndc\\nec\\n\", \"26\\nhw\\nwb\\nba\\nax\\nxl\\nle\\neo\\nod\\ndj\\njt\\ntm\\nmq\\nqf\\nfk\\nkn\\nny\\nyz\\nzr\\nrg\\ngv\\nvc\\n...
A substring of some string is called the most frequent, if the number of its occurrences is not less than number of occurrences of any other substring. You are given a set of strings. A string (not necessarily from this set) is called good if all elements of the set are the most frequent substrings of this string. Res...
0
{"tests": "{\"inputs\": [\"4\\n5 7\\n3 3 4 1\\n\", \"3\\n2 3\\n1 3 1\\n\", \"3\\n3 3\\n2 2 2\\n\", \"6\\n12 3\\n1 4 1 4 1 4\\n\", \"5\\n10 7\\n1 2 3 1 3\\n\", \"5\\n4 8\\n1 1 1 2 2\\n\", \"6\\n10 11\\n1 1 12 1 1 1\\n\", \"9\\n5 24\\n1 6 1 6 1 6 1 6 1\\n\", \"10\\n10 13\\n2 3 4 4 2 3 1 4 4 2\\n\", \"20\\n13 10\\n1 4 3 2...
Vasya should paint a fence in front of his own cottage. The fence is a sequence of n wooden boards arranged in a single row. Each board is a 1 centimeter wide rectangle. Let's number the board fence using numbers 1, 2, ..., n from left to right. The height of the i-th board is h_{i} centimeters. Vasya has a 1 centimet...
0
{"tests": "{\"inputs\": [[\"A fast-food resteraunt down the street was grumbling my tummy but I could not go.\"], [\"apparently\"], [\"and\"], [\"but\"], [\"but apparently\"], [\"and apparently\"], [\"but but but and and and\"], [\"\"], [\"but and apparently apparently apparently apparently\"], [\"and apparentlybutactu...
For every string, after every occurrence of `'and'` and `'but'`, insert the substring `'apparently'` directly after the occurrence. If input does not contain 'and' or 'but', return the original string. If a blank string, return `''`. If substring `'apparently'` is already directly after an `'and'` and/or `'but'`, do ...
0
{"tests": "{\"inputs\": [\"6\\n0 0 0 0 0\\n1 0 0 0 0\\n0 1 0 0 0\\n0 0 1 0 0\\n0 0 0 1 0\\n0 0 0 0 1\\n\", \"3\\n0 0 1 2 0\\n0 0 9 2 0\\n0 0 5 9 0\\n\", \"1\\n0 0 0 0 0\\n\", \"2\\n0 1 2 3 4\\n5 6 7 8 9\\n\", \"10\\n0 -110 68 -51 -155\\n-85 -110 68 -51 -155\\n85 -70 51 68 -230\\n0 -40 51 68 75\\n0 5 -51 -68 -190\\n85 0...
You are given set of n points in 5-dimensional space. The points are labeled from 1 to n. No two points coincide. We will call point a bad if there are different points b and c, not equal to a, from the given set such that angle between vectors $\vec{ab}$ and $\vec{ac}$ is acute (i.e. strictly less than $90^{\circ}$)....
0.875
{"tests": "{\"inputs\": [\"10\\n3 5 7 0 2 8 9 6 1 4\\n4 3 8 7 9 6 0 5 2 1\\n\", \"8\\n2 3 0 5 4 7 6 1\\n6 3 2 5 0 4 7 1\\n\", \"8\\n5 2 4 6 1 0 3 7\\n7 4 3 0 2 6 1 5\\n\", \"10\\n7 4 6 1 0 9 2 8 5 3\\n4 7 0 5 2 8 9 6 1 3\\n\", \"9\\n8 5 0 1 6 7 4 2 3\\n6 5 0 8 7 1 4 3 2\\n\", \"75\\n71 69 34 23 13 68 19 45 40 6 74 11 5...
Let's define the sum of two permutations p and q of numbers 0, 1, ..., (n - 1) as permutation <image>, where Perm(x) is the x-th lexicographically permutation of numbers 0, 1, ..., (n - 1) (counting from zero), and Ord(p) is the number of permutation p in the lexicographical order. For example, Perm(0) = (0, 1, ..., n...
0
{"tests": "{\"inputs\": [\"48145 89209 5\\n3 1\\n3 2\\n3 3\\n2 3\\n1 3\\n\", \"2 2 2\\n1 2\\n2 2\\n\", \"10 10 46\\n5 4\\n3 5\\n5 3\\n3 2\\n6 6\\n3 7\\n7 5\\n3 6\\n6 3\\n10 3\\n5 7\\n5 6\\n10 7\\n7 6\\n5 5\\n4 5\\n7 4\\n10 2\\n10 6\\n6 7\\n10 1\\n6 4\\n7 7\\n3 3\\n3 8\\n4 3\\n7 8\\n8 2\\n4 4\\n10 5\\n10 9\\n6 2\\n4 8\\...
Alice got a new doll these days. It can even walk! Alice has built a maze for the doll and wants to test it. The maze is a grid with n rows and m columns. There are k obstacles, the i-th of them is on the cell (x_i, y_i), which means the cell in the intersection of the x_i-th row and the y_i-th column. However, the d...
0
{"tests": "{\"inputs\": [\"4 2\\n1 3\\n1 4\\n\", \"7 8\\n1 6\\n2 6\\n3 5\\n3 6\\n4 3\\n5 1\\n5 2\\n5 3\\n\", \"2 2\\n1 2\\n2 1\\n\", \"1000000000 9\\n1 2\\n3 1\\n3 2\\n999999998 999999999\\n999999998 1000000000\\n999999999 999999999\\n999999999 999999997\\n1000000000 999999996\\n1000000000 999999997\\n\", \"1000000000 ...
Iahub got lost in a very big desert. The desert can be represented as a n × n square matrix, where each cell is a zone of the desert. The cell (i, j) represents the cell at row i and column j (1 ≤ i, j ≤ n). Iahub can go from one cell (i, j) only down or right, that is to cells (i + 1, j) or (i, j + 1). Also, there a...
0
{"tests": "{\"inputs\": [\"1\\nA00\\n\", \"1\\na00\\n\", \"1\\n825\\n\", \"1\\nNV641\\n\", \"1\\naAbAcDeF\\n\", \"1\\n000\\n\", \"6\\n11b\\n4bh\\nBeh\\nTuY\\n1YJ\\nP28\\n\", \"1\\nM62H\\n\", \"3\\nafd\\n142\\nTRE\\n\", \"2\\nabcDCE\\nhtQw27\\n\", \"4\\nYtG3\\n33Yo\\n123n\\nm23m\\n\", \"1\\n0a0\\n\", \"1\\nWK7S\\n\", \"...
Vasya came up with a password to register for EatForces — a string s. The password in EatForces should be a string, consisting of lowercase and uppercase Latin letters and digits. But since EatForces takes care of the security of its users, user passwords must contain at least one digit, at least one uppercase Latin l...
0
{"tests": "{\"inputs\": [\"4\\n5\\n231\\n7\\n2323\\n6\\n333\\n24\\n133321333\\n\", \"9\\n1500\\n1212\\n1500\\n1221\\n1500\\n122\\n1500\\n12121\\n1500\\n22\\n1500\\n1111112111111112\\n1500\\n1111111111221111111\\n1500\\n111111122\\n1500\\n11111121111121111111\\n\", \"1\\n1000000\\n22\\n\", \"1\\n1000000\\n221\\n\", \"1\...
We start with a string $s$ consisting only of the digits $1$, $2$, or $3$. The length of $s$ is denoted by $|s|$. For each $i$ from $1$ to $|s|$, the $i$-th character of $s$ is denoted by $s_i$. There is one cursor. The cursor's location $\ell$ is denoted by an integer in $\{0, \ldots, |s|\}$, with the following mean...
0
{"tests": "{\"inputs\": [\"6 1\\n1 2\\n3 2\\n4 2\\n1 6\\n5 6\", \"6 7\\n1 2\\n3 2\\n4 2\\n1 6\\n5 6\", \"6 2\\n1 2\\n3 2\\n4 2\\n1 6\\n5 2\", \"6 2\\n1 3\\n3 2\\n4 2\\n1 6\\n5 6\", \"6 2\\n0 3\\n3 2\\n4 2\\n1 6\\n5 6\", \"6 0\\n1 3\\n6 2\\n4 2\\n1 6\\n5 6\", \"6 7\\n1 2\\n3 4\\n4 2\\n1 6\\n5 6\", \"6 5\\n1 3\\n3 2\\n4 ...
Given an undirected tree, let the distance between vertices u and v be the number of edges on the simple path from u to v. The diameter of a tree is the maximum among the distances between any two vertices. We will call a tree good if and only if its diameter is at most K. You are given an undirected tree with N verti...
0
{"tests": "{\"inputs\": [[100, 1], [11, 2], [20, 2], [101, 2], [10001, 2], [10001000, 2], [500309160, 2], [10000000000000000000000, 3], [10000000000000000000000, 21], [1203, 4]], \"outputs\": [[19], [1], [9], [82], [487], [1729], [2604], [1122660], [2407217760893271902598], [81]]}", "source": "taco"}
You are given 2 numbers is `n` and `k`. You need to find the number of integers between 1 and n (inclusive) that contains exactly `k` non-zero digit. Example1 ` almost_everywhere_zero(100, 1) return 19` by following condition we have 19 numbers that have k = 1 digits( not count zero ) ` [1,2,3,4,5,6,7,8,9,10,20,30...
0.375
{"tests": "{\"inputs\": [\"19\\n 1 +x 1 +y +z 3 +z\\n 3 +y -z +x +y -z -x +z 2 +z\\n 2 +y\\n19\\n 1 +x 1 +x +z 3 +y -z +x +y -z -x +z 2 +y\\n 3 +z\\n 2 +z\\n19\\n 1 +x 1 +y +z 3 +z\\n 3 +y -z +x +y -z -x +z 2 +y\\n 2 +z\\n18\\n 1 -y\\n 1 +y -z +x\\n 1 +z +y +x +z +y -x -y 2 -y\\n 2 +z\\n3 +x +y +z\\n3 +y +...
Professor Tsukuba invented a mysterious jewelry box that can be opened with a special gold key whose shape is very strange. It is composed of gold bars joined at their ends. Each gold bar has the same length and is placed parallel to one of the three orthogonal axes in a three dimensional space, i.e., x-axis, y-axis an...
0
{"tests": "{\"inputs\": [\"6 8\\n....*...\\n...**...\\n..*****.\\n...**...\\n....*...\\n........\\n\", \"5 5\\n.*...\\n****.\\n.****\\n..**.\\n.....\\n\", \"5 5\\n.*...\\n***..\\n.*...\\n.*...\\n.....\\n\", \"3 3\\n*.*\\n.*.\\n*.*\\n\", \"3 3\\n.*.\\n***\\n**.\\n\", \"3 3\\n.*.\\n***\\n.*.\\n\", \"3 3\\n**.\\n***\\n.*....
A star is a figure of the following type: an asterisk character '*' in the center of the figure and four rays (to the left, right, top, bottom) of the same positive length. The size of a star is the length of its rays. The size of a star must be a positive number (i.e. rays of length $0$ are not allowed). Let's consid...
0.5
{"tests": "{\"inputs\": [\"24 8\\n1 17\\n2\\n1 -10\\n2\\n2\\n2\\n2\\n1 19\\n\", \"6 9\\n2\\n1 -2\\n2\\n1 -6\\n1 -6\\n1 4\\n2\\n1 -1\\n2\\n\", \"10 10\\n1 2\\n1 -10\\n1 -5\\n2\\n2\\n1 -4\\n2\\n2\\n1 -10\\n1 -9\\n\", \"364 57\\n1 -101\\n1 110\\n1 -76\\n1 329\\n2\\n2\\n2\\n1 -191\\n1 97\\n1 189\\n1 305\\n1 -313\\n1 312\\n...
Little Artem is fond of dancing. Most of all dances Artem likes rueda — Cuban dance that is danced by pairs of boys and girls forming a circle and dancing together. More detailed, there are n pairs of boys and girls standing in a circle. Initially, boy number 1 dances with a girl number 1, boy number 2 dances with a g...
0.5
{"tests": "{\"inputs\": [\"3\\n3\\n110\\n2\\n00\\n4\\n1010\\n\", \"3\\n3\\n110\\n2\\n00\\n4\\n1011\\n\", \"3\\n3\\n010\\n2\\n00\\n4\\n0011\\n\", \"3\\n3\\n110\\n2\\n00\\n4\\n0110\\n\", \"3\\n3\\n010\\n2\\n00\\n4\\n1001\\n\", \"3\\n3\\n110\\n2\\n00\\n4\\n0011\\n\", \"3\\n3\\n110\\n2\\n00\\n4\\n0010\\n\", \"3\\n3\\n000\\...
The only difference between the easy and hard versions is that the given string $s$ in the easy version is initially a palindrome, this condition is not always true for the hard version. A palindrome is a string that reads the same left to right and right to left. For example, "101101" is a palindrome, while "0101" is...
0
{"tests": "{\"inputs\": [[[2, 3, 4]], [[1, 3, 4]], [[1, 2, 4]], [[1, 2, 3]], [[]], [[1]], [[2]]], \"outputs\": [[1], [2], [3], [4], [1], [2], [1]]}", "source": "taco"}
# Background: You're working in a number zoo, and it seems that one of the numbers has gone missing! Zoo workers have no idea what number is missing, and are too incompetent to figure it out, so they're hiring you to do it for them. In case the zoo loses another number, they want your program to work regardless of h...
0
{"tests": "{\"inputs\": [[[[\"09:30\", \"10:15\"], [\"12:20\", \"15:50\"]], \"10:00\"], [[[\"09:30\", \"10:15\"], [\"12:20\", \"15:50\"]], \"11:00\"], [[[\"09:30\", \"10:15\"], [\"12:20\", \"15:50\"]], \"10:15\"], [[], \"10:15\"], [[[\"12:13\", \"23:50\"]], \"10:15\"], [[[\"12:13\", \"23:50\"]], \"23:55\"], [[[\"12:13\...
# The Problem Dan, president of a Large company could use your help. He wants to implement a system that will switch all his devices into offline mode depending on his meeting schedule. When he's at a meeting and somebody texts him, he wants to send an automatic message informing that he's currently unavailable and th...
0
{"tests": "{\"inputs\": [\"8\\nwood 3000\\nstring 800\\nrice 36\\nwater 0\\nracket 5000\\nmicrophone 4961\\nonigiri 140\\nguitar 98000\\n3\\nracket 2 wood string\\nonigiri 2 rice water\\nguitar 3 racket microphone onigiri\\nguitar\\n1\\ncomputer 300000\\n0\\ncomputer\\n0\", \"8\\nwood 5003\\nstring 800\\nrice 36\\nwate...
You finally got a magic pot, an alchemy pot. You can create a new item by putting multiple items in the alchemy pot. Newly created items can also be placed in alchemy pots to make other items. A list of items needed to make an item will be called an alchemy recipe. The following three are examples of alchemy recipes. ...
0
{"tests": "{\"inputs\": [\"7\\n3 3 2\\n2 1 10\\n6 3 10\\n6 4 10\\n100 1 1\\n4 4 0\\n69 4 20\\n\", \"1\\n2000 2000 1000000006\\n\", \"1\\n2000 1139 818658270\\n\", \"2\\n1398 1034 726329524\\n602 156 640769482\\n\", \"3\\n763 499 769431935\\n827 50 784148915\\n410 241 11071818\\n\", \"4\\n182 35 698699275\\n261 76 28953...
This is the easy version of the problem. The difference is the constraints on $n$, $m$ and $t$. You can make hacks only if all versions of the problem are solved. Alice and Bob are given the numbers $n$, $m$ and $k$, and play a game as follows: The game has a score that Alice tries to maximize, and Bob tries to minim...
0
{"tests": "{\"inputs\": [\"4\\n1 2\\n1 3\\n1 4\\n\", \"4\\n1 2\\n2 3\\n3 4\\n\", \"2\\n2 1\\n\", \"3\\n2 1\\n3 2\\n\", \"10\\n2 3\\n3 9\\n6 3\\n9 8\\n9 10\\n4 8\\n3 1\\n3 5\\n7 1\\n\", \"10\\n2 3\\n3 9\\n6 3\\n9 8\\n9 10\\n4 8\\n3 1\\n3 5\\n7 1\\n\", \"3\\n2 1\\n3 2\\n\", \"2\\n2 1\\n\", \"4\\n1 2\\n1 3\\n3 4\\n\", \"1...
Sergey Semyonovich is a mayor of a county city N and he used to spend his days and nights in thoughts of further improvements of Nkers' lives. Unfortunately for him, anything and everything has been done already, and there are no more possible improvements he can think of during the day (he now prefers to sleep at nigh...
0
{"tests": "{\"inputs\": [\"5\\n4 1\\n0 1 3 4\\n3 1\\n0 1 4\\n3 0\\n0 1 4\\n3 2\\n0 1 2\\n3 2\\n1 2 3\\n\", \"7\\n5 1000000000\\n4 2 3 0 1\\n4 0\\n5 2 0 1\\n3 0\\n100 0 1\\n6 1234567\\n1 2 3 4 5 0\\n3 114514\\n8 0 4\\n1 1000000\\n0\\n1 10000000\\n1\\n\", \"1\\n1 0\\n0\\n\", \"1\\n6 2\\n0 1 2 3 6 8\\n\", \"1\\n3 1\\n1 2 ...
You are given a multiset $S$ initially consisting of $n$ distinct non-negative integers. A multiset is a set, that can contain some elements multiple times. You will perform the following operation $k$ times: Add the element $\lceil\frac{a+b}{2}\rceil$ (rounded up) into $S$, where $a = \operatorname{mex}(S)$ and $b =...
0.125
{"tests": "{\"inputs\": [\"6\\nAnka likes Troll\\nTroll likes Chapay\\nTroll likes Hexadecimal\\nHexadecimal likes Cleo\\nSnowy likes Hexadecimal\\nChapay likes Troll\\n740076959 230477703 987799796\\n\", \"12\\nAnka likes Dracul\\nDracul likes Troll\\nCleo likes Troll\\nSnowy likes Hexadecimal\\nHexadecimal likes Chap...
The year of 2012 is coming... According to an ancient choradrican legend in this very year, in 2012, Diablo and his brothers Mephisto and Baal will escape from hell, and innumerable hordes of demons will enslave the human world. But seven brave heroes have already gathered on the top of a mountain Arreat to protect us...
0
{"tests": "{\"inputs\": [\"3 2\\n2 1 2\\n1 3\\n\", \"7 3\\n3 1 3 7\\n2 2 5\\n2 4 6\\n\", \"1 1\\n1 1\\n\", \"3 2\\n1 2\\n2 1 3\\n\", \"5 3\\n1 4\\n3 1 2 3\\n1 5\\n\", \"8 5\\n2 1 2\\n2 3 4\\n1 5\\n2 6 7\\n1 8\\n\", \"10 10\\n1 5\\n1 4\\n1 10\\n1 3\\n1 7\\n1 1\\n1 8\\n1 6\\n1 9\\n1 2\\n\", \"20 6\\n3 8 9 13\\n3 4 14 20\...
Andrewid the Android is a galaxy-famous detective. He is now investigating the case of vandalism at the exhibition of contemporary art. The main exhibit is a construction of n matryoshka dolls that can be nested one into another. The matryoshka dolls are numbered from 1 to n. A matryoshka with a smaller number can be ...
0
{"tests": "{\"inputs\": [\"4\\n0 1\\n1 1\\n1 2\\n3 2\", \"11\\n63 106\\n87 143\\n102 132\\n115 169\\n74 145\\n41 177\\n56 130\\n28 102\\n19 124\\n0 156\\n22 183\", \"4\\n0 2\\n1 1\\n1 2\\n3 2\", \"11\\n63 106\\n87 143\\n102 132\\n115 169\\n74 145\\n41 177\\n56 130\\n28 102\\n19 124\\n0 294\\n22 183\", \"4\\n0 2\\n1 1\\...
Sunake is in the form of a polygonal line consisting of n vertices (without self-intersection). First, Sunake-kun's i-th vertex is at (xi, yi). You can move continuously by translating or rotating, but you cannot deform (change the length of the polygonal line or the angle between the two line segments). y = 0 is the w...
0
{"tests": "{\"inputs\": [\"AABBAAABABAABBBAABA\\nAABBBABBABBAAABABABAAB\\nBABAABAABABABBAAAB\\nAABABAAABBAABBBABAA\\nAAAAAAAAAAA\\nABBBBBBBBBB\\n0\", \"ABAABBBAABABAAABBAA\\nAABBBABBABBAAABABABAAB\\nBABAABAABABABBAAAB\\nAABABAAABBAABBBABAA\\nAAAAAAAAAAA\\nABBBBBABBBB\\n0\", \"ABAABBBAABABAAABBAA\\nAABBBABBABBAAABABABAA...
It's been a while since I played with A, B, and C. Mr. A and Mr. B became players, and Mr. C became a referee and played a badminton singles game. The rules decided by the three people are as follows. * 3 Play the game. * The person who gets 11 points first wins the game. * The first serve of the first game starts wit...
0
{"tests": "{\"inputs\": [\"12 12\\n5 1\\n5 11\\n1 11\\n8 11\\n8 9\\n5 12\\n6 9\\n7 11\\n9 3\\n9 10\\n4 12\\n10 2\\n78\\n1 1\\n1 2\\n1 3\\n1 4\\n1 5\\n1 6\\n1 7\\n1 8\\n1 9\\n1 10\\n1 11\\n1 12\\n2 2\\n2 3\\n2 4\\n2 5\\n2 6\\n2 7\\n2 8\\n2 9\\n2 10\\n2 11\\n2 12\\n3 3\\n3 4\\n3 5\\n3 6\\n3 7\\n3 8\\n3 9\\n3 10\\n3 11\\n...
You are given an undirected graph with n vertices. There are no edge-simple cycles with the even length in it. In other words, there are no cycles of even length that pass each edge at most once. Let's enumerate vertices from 1 to n. You have to answer q queries. Each query is described by a segment of vertices [l; r...
0.125
{"tests": "{\"inputs\": [\"4 2\\n\", \"8 5\\n\", \"2 1\\n\", \"2 2\\n\", \"10 1\\n\", \"10 10\\n\", \"100000 100000\\n\", \"100000 2\\n\", \"100000 3\\n\", \"100000 99999\\n\", \"100 100\\n\", \"3000 34\\n\", \"2000 1\\n\", \"100000 1\\n\", \"24842 1038\\n\", \"1628 274\\n\", \"16186 337\\n\", \"24562 2009\\n\", \"9456...
The main street of Berland is a straight line with n houses built along it (n is an even number). The houses are located at both sides of the street. The houses with odd numbers are at one side of the street and are numbered from 1 to n - 1 in the order from the beginning of the street to the end (in the picture: from ...
0.625
{"tests": "{\"inputs\": [\"4\\n0 0\\n0 1\\n1 0\\n1 1\\n\", \"5\\n0 0\\n0 1\\n0 2\\n0 3\\n1 1\\n\", \"1\\n3141 2718\\n\", \"2\\n11 22\\n31 45\\n\", \"3\\n0 0\\n9998 9999\\n9997 9998\\n\", \"125\\n1364 2136\\n4530 5609\\n8555 7238\\n7151 4606\\n6464 8941\\n9723 9780\\n2138 3308\\n3013 3268\\n372 7398\\n7906 6497\\n8085 2...
You are given N points (x_i,y_i) located on a two-dimensional plane. Consider a subset S of the N points that forms a convex polygon. Here, we say a set of points S forms a convex polygon when there exists a convex polygon with a positive area that has the same set of vertices as S. All the interior angles of the polyg...
0
{"tests": "{\"inputs\": [[\"example(unwanted thing)example\"], [\"example (unwanted thing) example\"], [\"a (bc d)e\"], [\"a(b(c))\"], [\"hello example (words(more words) here) something\"], [\"(first group) (second group) (third group)\"]], \"outputs\": [[\"exampleexample\"], [\"example example\"], [\"a e\"], [\"a\"]...
Remove the parentheses = In this kata you are given a string for example: ```python "example(unwanted thing)example" ``` Your task is to remove everything inside the parentheses as well as the parentheses themselves. The example above would return: ```python "exampleexample" ``` Other than parentheses only letters...
0
{"tests": "{\"inputs\": [\"9\\n5\\n4 7 2 2 9\\n5\\n3 5 8 1 7\\n5\\n1 2 2 4 5\\n2\\n0 1\\n3\\n0 1 0\\n4\\n0 1 0 0\\n4\\n0 1 0 1\\n4\\n0 1 0 2\\n20\\n16 15 1 10 0 14 0 10 3 9 2 5 4 5 17 9 10 20 0 9\\n\", \"9\\n5\\n4 7 2 2 9\\n5\\n3 5 8 1 7\\n5\\n1 2 2 4 0\\n2\\n0 1\\n3\\n0 1 0\\n4\\n0 1 0 0\\n4\\n0 1 0 1\\n4\\n0 1 0 2\\n...
This is a hard version of the problem. In this version, the given array can contain equal elements and the constraints on $n$ are greater than in the easy version of the problem. You are given an array $a$ of $n$ integers (the given array can contain equal elements). You can perform the following operations on array e...
0
{"tests": "{\"inputs\": [[[10], 4, 0], [[10, 20], 5, 0], [[10, 20, 1, 2, 3], 5, 2], [[10, 20, 1, 2, 3], 5, 0], [[10, 20, 1, 2, 3], 4, 2], [[10, 20, 1, 2, 3], 4, 3]], \"outputs\": [[10], [15], [11], [21], [9], [11]]}", "source": "taco"}
Scheduling is how the processor decides which jobs (processes) get to use the processor and for how long. This can cause a lot of problems. Like a really long process taking the entire CPU and freezing all the other processes. One solution is Round-Robin, which today you will be implementing. Round-Robin works by queu...
0
{"tests": "{\"inputs\": [\"1\\n\\n4\\n2\\n\", \"2\\n1\\n4 4\\n2\\n\", \"3\\n3 3\\n10 10 10\\n17\\n\", \"2\\n2\\n200000 100000\\n34567\\n\", \"20\\n2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2\\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 299981\\n1234567890\\n\", \"20\\n2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2\\n299981 1 1 1 1 1 1 1 1...
There are n types of coins in Byteland. Conveniently, the denomination of the coin type k divides the denomination of the coin type k + 1, the denomination of the coin type 1 equals 1 tugrick. The ratio of the denominations of coin types k + 1 and k equals a_{k}. It is known that for each x there are at most 20 coin ty...
0
{"tests": "{\"inputs\": [\"3 1 5 4\\n1 2 1 3\\n\", \"3 1 5 3\\n1 3 1\\n\", \"3 2 5 3\\n1 3 1\\n\", \"1 1 1 1\\n1\\n\", \"1 1 1 1\\n1\\n\", \"1 1 2 2\\n1 1\\n\", \"1 1 2 1\\n1\\n\", \"1 1 1 1\\n1\\n\", \"1 1 3 3\\n1 1 1\\n\", \"1 1 1 1\\n1\\n\", \"1 1 3 3\\n1 1 1\\n\", \"1 1 5 4\\n1 1 1 1\\n\", \"1 1 4 2\\n1 1\\n\", \"1...
The elections to Berland parliament are happening today. Voting is in full swing! Totally there are n candidates, they are numbered from 1 to n. Based on election results k (1 ≤ k ≤ n) top candidates will take seats in the parliament. After the end of the voting the number of votes for each candidate is calculated. I...
0
{"tests": "{\"inputs\": [\"4 1\\n2 3 1 2\\n3\", \"5 2\\n3 5 2 2 4\\n1 4\", \"7 7\\n6 9 2 7 4 8 7\\n1 2 3 4 5 6 7\\n\", \"73 27\\n651 944 104 639 369 961 338 573 516 690 889 227 480 160 299 783 270 331 793 796 64 712 649 88 695 550 829 303 965 780 570 374 371 506 954 632 660 987 986 253 144 993 708 710 890 257 303 651 9...
Little Mishka is a great traveller and she visited many countries. After thinking about where to travel this time, she chose XXX — beautiful, but little-known northern country. Here are some interesting facts about XXX: XXX consists of n cities, k of whose (just imagine!) are capital cities. All of cities in the cou...
0
{"tests": "{\"inputs\": [\"3\\n0110?11\\n6\\n5 1\\n6 ?\\n7 ?\\n2 ?\\n5 ?\\n1 1\\n\", \"3\\n0110?11\\n6\\n5 1\\n6 ?\\n6 ?\\n1 ?\\n5 ?\\n1 1\\n\", \"3\\n11?0110\\n6\\n5 1\\n6 ?\\n7 ?\\n2 ?\\n5 ?\\n1 1\\n\", \"3\\n0110?11\\n6\\n5 1\\n7 ?\\n7 ?\\n2 ?\\n5 ?\\n1 1\\n\", \"3\\n0110?11\\n1\\n5 1\\n6 ?\\n7 @\\n2 ?\\n5 ?\\n1 1\\...
2^k teams participate in a playoff tournament. The tournament consists of 2^k - 1 games. They are held as follows: first of all, the teams are split into pairs: team 1 plays against team 2, team 3 plays against team 4 (exactly in this order), and so on (so, 2^{k-1} games are played in that phase). When a team loses a g...
0
{"tests": "{\"inputs\": [[3, 5], [\"hello\", 3], [67, \"bye\"], [true, true], [314, 107], [1, 32], [-1, -1], [19483, 9], [\"hello\", {}], [[], \"pippi\"]], \"outputs\": [[5], [false], [false], [false], [207], [1], [0], [16], [false], [false]]}", "source": "taco"}
# Fix the Bugs (Syntax) - My First Kata ## Overview Hello, this is my first Kata so forgive me if it is of poor quality. In this Kata you should fix/create a program that ```return```s the following values: - ```false/False``` if either a or b (or both) are not numbers - ```a % b``` plus ```b % a``` if both argum...
0
{"tests": "{\"inputs\": [\"(P*Q)\\n(--R+(P*R))\\n(P*-P)\\n2\\n1\\n(-1+(((---P+Q)*(--Q+---R))*(-R+-P)))\\n.\", \"(P*Q)\\n(--R+(P*Q))\\n(P*-P)\\n1\\n1\\n(-1+(((---P+Q)*(--Q+---R))*(-R+-P)))\\n.\", \"(P*Q)\\n(--R+(P*R))\\n(P*-P)\\n1\\n0\\n(-1+(((---P+Q)*(--Q+---R))*(-R+-P)))\\n.\", \"(P*Q)\\n(--R+(P*Q))\\n(P*-P)\\n1\\n2\\...
Three-valued logic is a logic system that has, in addition to "true" and "false", "unknown" as a valid value. In the following, logical values "false", "unknown" and "true" are represented by 0, 1 and 2 respectively. Let "-" be a unary operator (i.e. a symbol representing one argument function) and let both "*" and "+...
0
{"tests": "{\"inputs\": [\"2 4\\n4\\n1 1 0\\n1 2 10\\n2 1 30\\n2 2 20\", \"2 2\\n3\\n1 1 0\\n1 2 10\\n2 1 22\", \"3 3\\n4\\n1 2 0\\n1 3 10\\n3 1 10\\n3 3 20\", \"2 2\\n3\\n2 1 20\\n1 2 10\\n2 1 0\", \"2 4\\n4\\n1 1 0\\n2 2 10\\n2 1 30\\n2 2 20\", \"3 3\\n4\\n1 2 1\\n1 3 10\\n3 1 10\\n3 3 20\", \"3 3\\n4\\n1 2 1\\n1 3 1...
There is a grid with R rows and C columns. We call the cell in the r-th row and c-th column (r,c). Mr. Takahashi wrote non-negative integers into N of the cells, that is, he wrote a non-negative integer a_i into (r_i,c_i) for each i (1≤i≤N). After that he fell asleep. Mr. Aoki found the grid and tries to surprise Mr....
0
{"tests": "{\"inputs\": [[[[1, 2, 3, 4], [5, 6, 7, 8]]], [[[2, 3, 9, 10, 7], [12, 6, 89, 45, 3], [9, 12, 56, 10, 34], [67, 23, 1, 88, 34]]], [[[2, 5, 4, 3, 19], [2, 5, 6, 7, 10]]], [[[1.2, 8.521, 0.4, 3.14, 1.9], [2, 4.5, 3.75, 0.987, 1.0]]], [[[2, 5, -4, 3, -19], [-2, -5, 6, 7, 10]]], [[[-2, -18, -45, -10], [0, -45, -...
# ASC Week 1 Challenge 5 (Medium #2) Create a function that takes a 2D array as an input, and outputs another array that contains the average values for the numbers in the nested arrays at the corresponding indexes. Note: the function should also work with negative numbers and floats. ## Examples ``` [ [1, 2, 3, 4]...
0
{"tests": "{\"inputs\": [\"3\\nBBW\\n\", \"5\\nBWBWB\\n\", \"4\\nWWWW\\n\", \"4\\nBBBB\\n\", \"13\\nWBBBBWWBWBBBW\\n\", \"1\\nB\\n\", \"2\\nBB\\n\", \"100\\nWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWB\\n\", \"1\\nW\\n\", \"2\\nWW\\n\", \"2\\nWB\\n\", \"2\\nBW\\n\...
Recently Adaltik discovered japanese crosswords. Japanese crossword is a picture, represented as a table sized a × b squares, and each square is colored white or black. There are integers to the left of the rows and to the top of the columns, encrypting the corresponding row or column. The number of integers represents...
0.875
{"tests": "{\"inputs\": [\"4 12\\n\", \"8 20\\n\", \"1 1\\n\", \"2 6\\n\", \"6 12\\n\", \"1 12\\n\", \"7 9\\n\", \"1 19\\n\", \"1 20\\n\", \"20 20\\n\", \"19 20\\n\", \"1 12\", \"4 20\", \"1 0\", \"1 2\", \"4 24\", \"1 -1\", \"6 24\", \"6 36\", \"6 10\", \"6 17\", \"6 32\", \"5 32\", \"5 52\", \"5 10\", \"2 16\", \"1 1...
You are given positive integers A and B. If A is a divisor of B, print A + B; otherwise, print B - A. -----Constraints----- - All values in input are integers. - 1 \leq A \leq B \leq 20 -----Input----- Input is given from Standard Input in the following format: A B -----Output----- If A is a divisor of B, print A ...
0.875
{"tests": "{\"inputs\": [\"2015 3 2 2015 3 13\", \"1045 2 14 2015 3 15\", \"1234 5 4 789012345678901234 5 6\", \"2015 3 3 2015 2 13\", \"2015 3 6 3448 2 13\", \"2015 2 6 3448 3 13\", \"2015 2 6 3516 3 13\", \"3203 2 2 3516 3 13\", \"1045 2 14 2015 3 5\", \"1045 4 14 3098 3 13\", \"1045 4 20 3641 3 13\", \"2015 3 6 3590...
Problem "Ritsumeikan University Competitive Programming Camp" will be held this year as well. I am very much looking forward to this annual training camp. However, I couldn't stand my desires and splurged before the training camp, so I couldn't afford it. So I decided to use the cheapest Seishun 18 Ticket to get to Mi...
0
{"tests": "{\"inputs\": [\"5 1 1\", \"1010000 100000 200000\", \"4 4 6\", \"10 0 1\", \"1010000 100001 200000\", \"5 2 2\", \"1011000 100001 200000\", \"1011001 100001 200000\", \"0100111 001111 35243\", \"5 2 3\", \"1000000 110000 200000\", \"16 4 6\", \"7 1 2\", \"1010000 100001 160629\", \"1001001 000001 167964\", \...
We have two indistinguishable pieces placed on a number line. Both pieces are initially at coordinate 0. (They can occupy the same position.) We can do the following two kinds of operations: * Choose a piece and move it to the right (the positive direction) by 1. * Move the piece with the smaller coordinate to the po...
0
{"tests": "{\"inputs\": [\"5\\n1 5 4 3 2\\n\", \"6\\n2 2 2 2 2 2\\n\", \"2\\n0 0\\n\", \"2\\n1 2\\n\", \"2\\n10 -1\\n\", \"5\\n934 235 171 111 197\\n\", \"100\\n0 1 1 1 0 0 0 2 1 2 2 1 2 2 2 0 0 2 1 2 0 1 1 0 2 0 1 2 2 0 2 0 1 0 1 2 0 2 1 1 0 1 0 1 0 0 1 2 2 2 2 1 1 1 0 2 1 0 0 0 0 0 1 0 2 0 1 0 0 2 0 2 2 1 0 2 2 0 2 0...
Andrew skipped lessons on the subject 'Algorithms and Data Structures' for the entire term. When he came to the final test, the teacher decided to give him a difficult task as a punishment. The teacher gave Andrew an array of n numbers a_1, ..., a_{n}. After that he asked Andrew for each k from 1 to n - 1 to build a k...
0.375
{"tests": "{\"inputs\": [[0, 5], [5432160879, 3], [9876543000, 5], [9999999999, 1], [-123456789, 1], [-9999999999, 25]], \"outputs\": [[[1023456789, 1023456798, 1023456879, 1023456897, 1023456978]], [[5432160879, 5432160897, 5432160978]], [[9876543012, 9876543021, 9876543102, 9876543120, 9876543201]], [[]], [[102345678...
In mathematics, a **pandigital number** is a number that in a given base has among its significant digits each digit used in the base at least once. For example, 1234567890 is a pandigital number in base 10. For simplification, in this kata, we will consider pandigital numbers in *base 10* and with all digits used *ex...
0
{"tests": "{\"inputs\": [[\"3 \", \"40 40 100\", \"45 45 90\", \"180 1 1\", \"\"], \"3 \\n30 40 110\\n12 45 90\\n180 0 0\", \"3 \\n30 40 111\\n12 45 90\\n180 0 0\", \"3 \\n30 77 110\\n45 45 90\\n180 0 0\", \"3 \\n30 40 111\\n9 45 90\\n180 0 0\", \"3 \\n16 40 111\\n9 45 90\\n180 0 0\", \"3 \\n16 77 111\\n9 45 90\\n180 0...
Write a program to check whether a triangle is valid or not, when the three angles of the triangle are the inputs. A triangle is valid if the sum of all the three angles is equal to 180 degrees. -----Input----- The first line contains an integer T, the total number of testcases. Then T lines follow, each line contain...
0
{"tests": "{\"inputs\": [\"3 3\\n1 2 3\\n1 2 3\\n9\\n\", \"5 1\\n5 4 2 4 5\\n2\\n5\\n\", \"1 1\\n1\\n1\\n1\\n\", \"5 5\\n816 1061 1639 1627 1007\\n45 104 1091 592 1881\\n84465\\n\", \"5 5\\n816 1061 1639 1627 1007\\n45 104 1091 592 1881\\n36719\\n\", \"5 5\\n816 1061 1639 1627 1007\\n45 104 1091 592 1881\\n165947710\\n...
You are given two arrays $a$ and $b$ of positive integers, with length $n$ and $m$ respectively. Let $c$ be an $n \times m$ matrix, where $c_{i,j} = a_i \cdot b_j$. You need to find a subrectangle of the matrix $c$ such that the sum of its elements is at most $x$, and its area (the total number of elements) is the ...
0.875
{"tests": "{\"inputs\": [[1], [2], [3], [4], [12], [37], [311], [999]], \"outputs\": [[[\"one\", \"three\", \"five\", \"four\"]], [[\"two\", \"three\", \"five\", \"four\"]], [[\"three\", \"five\", \"four\"]], [[\"four\"]], [[\"onetwo\", \"six\", \"three\", \"five\", \"four\"]], [[\"threeseven\", \"onezero\", \"seven\",...
If we write out the digits of "60" as English words we get "sixzero"; the number of letters in "sixzero" is seven. The number of letters in "seven" is five. The number of letters in "five" is four. The number of letters in "four" is four: we have reached a stable equilibrium. Note: for integers larger than 9, write ou...
0
{"tests": "{\"inputs\": [\"2 2 1 2\\n\", \"2 1 1 1\\n\", \"5 7 4 1\\n\", \"5 7 1 4\\n\", \"5 7 10 10\\n\", \"5 7 1 10\\n\", \"1 1 1 1\\n\", \"50 50 50 50\\n\", \"50 49 1 2\\n\", \"50 48 3 1\\n\", \"48 50 12 11\\n\", \"49 50 11 12\\n\", \"49 49 4 1\\n\", \"49 49 3 3\\n\", \"1 50 1 50\\n\", \"1 50 50 50\\n\", \"50 1 1 1\...
Two players play a simple game. Each player is provided with a box with balls. First player's box contains exactly n_1 balls and second player's box contains exactly n_2 balls. In one move first player can take from 1 to k_1 balls from his box and throw them away. Similarly, the second player can take from 1 to k_2 bal...
0.125
{"tests": "{\"inputs\": [[0], [1], [30], [90], [180], [4000], [40000], [140000], [400000], [1000000], [10000000]], \"outputs\": [[\"just now\"], [\"a second ago\"], [\"30 seconds ago\"], [\"a minute ago\"], [\"3 minutes ago\"], [\"an hour ago\"], [\"11 hours ago\"], [\"a day ago\"], [\"4 days ago\"], [\"a week ago\"], ...
##Overview Write a helper function that takes in a Time object and converts it to a more human-readable format. You need only go up to '_ weeks ago'. ```python to_pretty(0) => "just now" to_pretty(40000) => "11 hours ago" ``` ##Specifics - The output will be an amount of time, t, included in one of the following phr...
0.875
{"tests": "{\"inputs\": [\"3\\n2 2 3\\n4 3 7\\n10 1 9\\n\", \"3\\n2 2 3\\n4 3 7\\n7 1 9\\n\", \"3\\n2 2 3\\n4 3 9\\n7 1 9\\n\", \"3\\n2 2 3\\n6 1 9\\n7 1 1\\n\", \"3\\n2 1 3\\n6 1 9\\n7 0 2\\n\", \"3\\n2 0 3\\n3 1 9\\n13 0 2\\n\", \"3\\n4 0 3\\n3 1 9\\n13 0 2\\n\", \"3\\n7 0 0\\n3 1 5\\n22 0 2\\n\", \"3\\n1 0 0\\n5 0 5...
Mikhail walks on a Cartesian plane. He starts at the point $(0, 0)$, and in one move he can go to any of eight adjacent points. For example, if Mikhail is currently at the point $(0, 0)$, he can go to any of the following points in one move: $(1, 0)$; $(1, 1)$; $(0, 1)$; $(-1, 1)$; $(-1, 0)$; $(-1, -1)$; $(0, -...
0
{"tests": "{\"inputs\": [\"2\\n1 2\\n\", \"8\\n10 4 3 6 5 10 7 5\\n\", \"10\\n20 1 15 17 11 2 15 3 16 3\\n\", \"50\\n499 780 837 984 481 526 944 482 862 136 265 605 5 631 974 967 574 293 969 467 573 845 102 224 17 873 648 120 694 996 244 313 404 129 899 583 541 314 525 496 443 857 297 78 575 2 430 137 387 319\\n\", \"5...
You are creating a level for a video game. The level consists of $n$ rooms placed in a circle. The rooms are numbered $1$ through $n$. Each room contains exactly one exit: completing the $j$-th room allows you to go the $(j+1)$-th room (and completing the $n$-th room allows you to go the $1$-st room). You are given th...
0
{"tests": "{\"inputs\": [\"3\\n1 1 3\\n\", \"102\\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\\n\", \"10\\n1 1 3 2 2 1 3 4 7 5\\n\", \"31\\n1 1 1 1 1 1 1 1 1 1...
One day, little Vasya found himself in a maze consisting of (n + 1) rooms, numbered from 1 to (n + 1). Initially, Vasya is at the first room and to get out of the maze, he needs to get to the (n + 1)-th one. The maze is organized as follows. Each room of the maze has two one-way portals. Let's consider room number i (...
0
{"tests": "{\"inputs\": [\"1 1 1\\n\", \"1 2 1\\n\", \"6 5 7\\n\", \"12 12 24\\n\", \"20 12 32\\n\", \"21 32 10\\n\", \"30 12 20\\n\", \"23 22 14\\n\", \"589 505 50\\n\", \"499 599 100\\n\", \"40000 40000 40000\\n\", \"40000 40000 4000\\n\", \"4346 1611 880\\n\", \"546 1895 4881\\n\", \"4138 4245 30\\n\", \"1454 4484 2...
Tarly has two different type of items, food boxes and wine barrels. There are f food boxes and w wine barrels. Tarly stores them in various stacks and each stack can consist of either food boxes or wine barrels but not both. The stacks are placed in a line such that no two stacks of food boxes are together and no two s...
0.125
{"tests": "{\"inputs\": [\"1\\n3 2 2\", \"1\\n3 2 3\", \"1\\n3 3 3\", \"1\\n6 3 3\", \"1\\n6 4 3\", \"1\\n6 4 6\", \"1\\n3 1 3\", \"1\\n9 3 3\", \"1\\n6 5 3\", \"1\\n8 4 6\", \"1\\n12 3 3\", \"1\\n8 2 6\", \"1\\n3 1 2\", \"1\\n12 3 0\", \"1\\n8 2 8\", \"1\\n8 3 8\", \"1\\n12 4 1\", \"1\\n8 1 8\", \"1\\n12 7 1\", \"1\\n...
Read problems statements in Russian here Chef has a special affection for sets of binary strings of equal length which have same numbers of 1's. Given three integers n, k and m, your task is to find the the lexicographically m^{th} smallest string among strings which have length n and have k 1's. If no such string e...
0
{"tests": "{\"inputs\": [\"4\\n6 4 2\\n2 9 2 3 8 5\\n4 4 1\\n2 13 60 4\\n4 1 3\\n1 2 2 1\\n2 2 0\\n1 2\\n\", \"4\\n6 4 2\\n2 9 2 3 8 5\\n4 4 1\\n2 13 60 4\\n4 1 3\\n1 2 1 1\\n2 2 0\\n1 2\\n\", \"4\\n6 4 2\\n2 9 2 3 8 5\\n4 4 1\\n2 13 60 4\\n4 2 3\\n1 2 2 1\\n2 2 0\\n1 2\\n\", \"4\\n6 3 2\\n2 9 2 3 8 5\\n4 4 1\\n2 13 60...
You and your $n - 1$ friends have found an array of integers $a_1, a_2, \dots, a_n$. You have decided to share it in the following way: All $n$ of you stand in a line in a particular order. Each minute, the person at the front of the line chooses either the first or the last element of the array, removes it, and keeps ...
0
{"tests": "{\"inputs\": [\"3\\n10 -3\\n50 4\\n101 -5\", \"3\\n2 18\\n3 -20\\n6 15\", \"5\\n56 114834\\n72 -134386\\n100 190757\\n192 -132693\\n240 133108\", \"3\\n10 -3\\n91 4\\n101 -5\", \"3\\n18 -3\\n91 4\\n101 1\", \"5\\n92 114834\\n125 -176641\\n100 13125\\n192 -68478\\n240 133108\", \"5\\n42 114834\\n125 -176641\\...
Consider an infinite sequence a_1, a_2, … Initially, the values of all the terms are 0, and from this state we will sequentially perform Q operations. The i-th operation (1 ≤ i ≤ Q) is as follows: * For every positive integer j, add x_i to the value of a_{j × m_i}. Find the value of the largest term after these Q o...
0.125
{"tests": "{\"inputs\": [\"5\\n0 1 0 1 1\\n\", \"7\\n1 0 1 0 0 1 0\\n\", \"1\\n0\\n\", \"1\\n1\\n\", \"2\\n0 0\\n\", \"2\\n0 1\\n\", \"2\\n1 0\\n\", \"2\\n1 1\\n\", \"10\\n0 0 0 0 0 0 0 0 0 0\\n\", \"9\\n1 1 1 1 1 1 1 1 1\\n\", \"11\\n0 0 0 0 0 0 0 0 0 0 1\\n\", \"12\\n1 0 0 0 0 0 0 0 0 0 0 0\\n\", \"20\\n1 1 0 1 1 1 1...
Alena has successfully passed the entrance exams to the university and is now looking forward to start studying. One two-hour lesson at the Russian university is traditionally called a pair, it lasts for two academic hours (an academic hour is equal to 45 minutes). The University works in such a way that every day it...
0.125
{"tests": "{\"inputs\": [\"6\\n1 2 3 4 5 6\\n\", \"5\\n-1000 -100 -10 0 10\\n\", \"10\\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000\\n\", \"27\\n18 -28 18 28 -45 90 -45 23 -53 60 28 -74 -71 35 -26 -62 49 -77 57 24 -70 -93 69 -99 59 57 -49\\n\", \"27\\n18...
Given is an integer sequence A_1, ..., A_N of length N. We will choose exactly \left\lfloor \frac{N}{2} \right\rfloor elements from this sequence so that no two adjacent elements are chosen. Find the maximum possible sum of the chosen elements. Here \lfloor x \rfloor denotes the greatest integer not greater than x. --...
0.25
{"tests": "{\"inputs\": [\"2\\n8\\n0\", \"2\\n6\\n0\", \"2\\n2\\n0\", \"2\\n0\\n0\", \"2\\n14\\n0\", \"2\\n12\\n0\", \"2\\n10\\n0\", \"2\\n18\\n0\", \"2\\n24\\n0\", \"2\\n0\\n1\", \"2\\n0\\n-1\", \"2\\n0\\n-2\", \"2\\n0\\n2\", \"2\\n0\\n4\", \"2\\n0\\n-4\", \"2\\n0\\n0\", \"2\\n0\\n-1\", \"2\\n0\\n-2\", \"2\\n6\\n0\", ...
Dr. Hedro is astonished. According to his theory, we can make sludge that can dissolve almost everything on the earth. Now he's trying to produce the sludge to verify his theory. The sludge is produced in a rectangular solid shaped tank whose size is N × N × 2. Let coordinate of two corner points of tank be (-N/2, -N/...
0
{"tests": "{\"inputs\": [\"4\\n3 1 7 4\\n2 3 2\\n2 8 5\\n1 10\\n\", \"2\\n2 3 -2\\n2 -1 5\\n\", \"2\\n2 -10 10\\n2 0 -20\\n\", \"1\\n1 0\\n\", \"3\\n1 20\\n2 30 40\\n3 50 60 80\\n\", \"3\\n3 1 3 100\\n2 4 104\\n2 2 102\\n\", \"4\\n3 80 1 10\\n3 52 19 24\\n3 27 46 29\\n3 74 13 25\\n\", \"2\\n5 -1000000000 999999999 -999...
Ujan has a lot of numbers in his boxes. He likes order and balance, so he decided to reorder the numbers. There are $k$ boxes numbered from $1$ to $k$. The $i$-th box contains $n_i$ integer numbers. The integers can be negative. All of the integers are distinct. Ujan is lazy, so he will do the following reordering o...
0
{"tests": "{\"inputs\": [\"5\\n4 5 6 0 8\\n1 2\\n1 3\\n1 4\\n4 5\\n\", \"7\\n0 2 3 0 0 0 0\\n1 2\\n1 3\\n2 4\\n2 5\\n3 6\\n3 7\\n\", \"2\\n0 0\\n2 1\\n\", \"2\\n123456789234 987654321432\\n1 2\\n\", \"2\\n987987987987 987987987987\\n2 1\\n\", \"32\\n402528994560 0 0 0 0 0 0 932646223872 893192888700 0 813583026900 0 0 ...
Kamil likes streaming the competitive programming videos. His MeTube channel has recently reached $100$ million subscribers. In order to celebrate this, he posted a video with an interesting problem he couldn't solve yet. Can you help him? You're given a tree — a connected undirected graph consisting of $n$ vertices c...
0.125
{"tests": "{\"inputs\": [\"6\\n5 6 2\\n2 4 3 5 7\\n5 11 2\\n2 4 3 5 7\\n2 10000 2\\n10000 10000\\n2 9999 2\\n10000 10000\\n5 13 2\\n8 2 8 2 5\\n3 18 2\\n1 2 3\\n\", \"2\\n2 1 2\\n1 1\\n2 2000000000 2\\n1 1\\n\", \"8\\n5 6 2\\n2 4 3 5 7\\n5 11 2\\n2 4 3 5 7\\n3 2 3\\n4 2 6\\n5 2 3\\n10 1 3 9 2\\n2 10000 2\\n10000 10000\...
This is the easy version of this problem. The only difference is the constraint on $k$ — the number of gifts in the offer. In this version: $k=2$. Vasya came to the store to buy goods for his friends for the New Year. It turned out that he was very lucky — today the offer "$k$ of goods for the price of one" is held in...
0.125
{"tests": "{\"inputs\": [\"100 100\\n50 50\\n\", \"13 23\\n19 63\\n\", \"5 23\\n12 17\\n\", \"65 8\\n73 25\\n\", \"100 3\\n4 1\\n\", \"2 25\\n8 24\\n\", \"19 17\\n5 8\\n\", \"24 43\\n96 39\\n\", \"11 17\\n6 4\\n\", \"25 9\\n16 12\\n\", \"58 86\\n40 46\\n\", \"100 1\\n4 1\\n\", \"82 60\\n100 38\\n\", \"9 21\\n13 16\\n\"...
Statistics claims that students sleep no more than three hours a day. But even in the world of their dreams, while they are snoring peacefully, the sense of impending doom is still upon them. A poor student is dreaming that he is sitting the mathematical analysis exam. And he is examined by the most formidable profess...
0
{"tests": "{\"inputs\": [\"5 1 1\\n*...*\\n\", \"6 2 3\\n*...*.\\n\", \"11 3 10\\n.*....**.*.\\n\", \"3 2 3\\n***\\n\", \"9 5 3\\n*...*...*\\n\", \"9 2 4\\n*...*...*\\n\", \"9 2 200000\\n*...*...*\\n\", \"1 0 1\\n.\\n\", \"20 5 5\\n.*.*.........*......\\n\", \"14 3 7\\n.*.......*..*.\\n\", \"6 1 3\\n*....*\\n\", \"9 2 ...
There are $n$ consecutive seat places in a railway carriage. Each place is either empty or occupied by a passenger. The university team for the Olympiad consists of $a$ student-programmers and $b$ student-athletes. Determine the largest number of students from all $a+b$ students, which you can put in the railway carri...
0
{"tests": "{\"inputs\": [\"6\\n2 2 2 1 1 1\\n\", \"2\\n1 2\\n\", \"200\\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...
A dragon symbolizes wisdom, power and wealth. On Lunar New Year's Day, people model a dragon with bamboo strips and clothes, raise them with rods, and hold the rods high and low to resemble a flying dragon. A performer holding the rod low is represented by a 1, while one holding it high is represented by a 2. Thus, th...
0
{"tests": "{\"inputs\": [[451999277, 41177722899], [1222345, 12345], [12345, 12345], [666789, 12345667], [10560002, 100], [1112, 122]], \"outputs\": [[1], [0], [0], [1], [1], [0]]}", "source": "taco"}
Write a function ```javascript tripledouble(num1,num2) ``` ```python triple_double(num1, num2) ``` which takes numbers `num1` and `num2` and returns `1` if there is a straight triple of a number at any place in `num1` and also a straight double of the **same** number in `num2`. If this isn't the case, return `0` ##...
0
{"tests": "{\"inputs\": [\"3 0\\n\", \"4 4\\n1 2 1\\n2 3 1\\n3 4 0\\n4 1 0\\n\", \"4 4\\n1 2 1\\n2 3 1\\n3 4 0\\n4 1 1\\n\", \"100000 0\\n\", \"100 3\\n1 2 0\\n2 3 0\\n3 1 0\\n\", \"9 2\\n1 2 0\\n2 3 0\\n\", \"28567 13\\n28079 24675 1\\n18409 26720 1\\n980 10815 1\\n20794 16571 1\\n7376 19861 1\\n11146 706 1\\n4255 163...
There are many anime that are about "love triangles": Alice loves Bob, and Charlie loves Bob as well, but Alice hates Charlie. You are thinking about an anime which has n characters. The characters are labeled from 1 to n. Every pair of two characters can either mutually love each other or mutually hate each other (the...
0
{"tests": "{\"inputs\": [\"1000000000 44 30 891773002\\n\", \"1000000000 999999938 999999936 384381709\\n\", \"1000000000 999999946 60 715189365\\n\", \"1000000000 999999946 999999941 715189365\\n\", \"1000000 951981 612086 60277\\n\", \"1000000000 6 999999904 272656295\\n\", \"1000000000 85 999999940 857945620\\n\", \...
Mr. Bender has a digital table of size n × n, each cell can be switched on or off. He wants the field to have at least c switched on squares. When this condition is fulfilled, Mr Bender will be happy. We'll consider the table rows numbered from top to bottom from 1 to n, and the columns — numbered from left to right f...
0
{"tests": "{\"inputs\": [\"5\\n1 2 1 2 3\\n\", \"2\\n100 1\\n\", \"4\\n1 3 3 7\\n\", \"100\\n23 39 85 46 97 72 41 70 37 18 8 40 33 61 12 79 51 78 61 66 85 97 78 14 70 47 100 40 15 40 61 52 19 30 14 91 82 56 10 6 68 24 97 61 31 78 18 45 88 6 37 38 51 86 37 42 58 30 79 56 50 14 61 18 13 20 57 3 93 15 24 74 32 21 71 93 2 ...
You are given an array $a$ consisting of $n$ integers. Let's denote monotonic renumeration of array $a$ as an array $b$ consisting of $n$ integers such that all of the following conditions are met: $b_1 = 0$; for every pair of indices $i$ and $j$ such that $1 \le i, j \le n$, if $a_i = a_j$, then $b_i = b_j$ (note ...
0
{"tests": "{\"inputs\": [\"b\", \"axbax\", \"`b\", \"xxxo\", \"tpxt\", \"c\", \"bxbax\", \"b`\", \"yxxo\", \"d\", \"bxbbx\", \"ba\", \"oxxy\", \"e\", \"xxbbb\", \"bb\", \"oxyx\", \"f\", \"xxabb\", \"cb\", \"oxyy\", \"g\", \"xyabb\", \"bc\", \"oxzy\", \"h\", \"bbayx\", \"db\", \"oxzz\", \"i\", \"bb`yx\", \"bd\", \"zzxo\...
We have a string s consisting of lowercase English letters. Snuke can perform the following operation repeatedly: * Insert a letter `x` to any position in s of his choice, including the beginning and end of s. Snuke's objective is to turn s into a palindrome. Determine whether the objective is achievable. If it is ...
0.5
{"tests": "{\"inputs\": [\"4\\n0 1 0 1\\n\", \"3\\n1 1 0\\n\", \"3\\n1 0 1\\n\", \"3\\n0 1 1\\n\", \"3\\n0 0 0\\n\", \"168\\n0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0...
A schoolboy named Vasya loves reading books on programming and mathematics. He has recently read an encyclopedia article that described the method of median smoothing (or median filter) and its many applications in science and engineering. Vasya liked the idea of the method very much, and he decided to try it in practi...
0.125
{"tests": "{\"inputs\": [\"3 4\\n15 20\\n0 0\", \"3 4\\n15 24\\n0 0\", \"3 4\\n15 34\\n0 0\", \"4 4\\n15 34\\n0 0\", \"3 4\\n15 16\\n0 0\", \"3 5\\n15 34\\n0 0\", \"4 4\\n12 34\\n0 0\", \"1 4\\n15 16\\n0 0\", \"2 4\\n12 34\\n0 0\", \"2 1\\n12 34\\n0 0\", \"4 2\\n22 34\\n0 0\", \"4 3\\n22 34\\n0 0\", \"4 3\\n13 34\\n0 0...
problem A city in Canada where JOI lives is divided into a grid pattern by w roads that extend straight in the north-south direction and h roads that extend straight in the east-west direction. The w roads in the north-south direction are numbered 1, 2, ..., w in order from the west. In addition, h roads in the east-...
0
{"tests": "{\"inputs\": [\"5 9\\n1 1\\n2 1\\n3 0\\n4 1\\n5 0\\n6 0\\n7 0\\n8 1\\n9 0\\n\", \"4 6\\n1 1\\n3 1\\n2 0\\n2 1\\n3 0\\n3 0\\n\", \"4 6\\n2 1\\n4 0\\n3 0\\n1 1\\n4 1\\n5 0\\n\", \"4 5\\n7 0\\n3 0\\n1 1\\n5 1\\n7 1\\n\", \"4 6\\n2 1\\n7 1\\n3 0\\n1 1\\n7 0\\n6 0\\n\", \"10 15\\n752087443 1\\n537185872 1\\n43989...
Student Vladislav came to his programming exam completely unprepared as usual. He got a question about some strange algorithm on a graph — something that will definitely never be useful in real life. He asked a girl sitting next to him to lend him some cheat papers for this questions and found there the following defin...
0
{"tests": "{\"inputs\": [\"2 3\\nATK 2000\\nDEF 1700\\n2500\\n2500\\n2500\\n\", \"3 4\\nATK 10\\nATK 100\\nATK 1000\\n1\\n11\\n101\\n1001\\n\", \"2 4\\nDEF 0\\nATK 0\\n0\\n0\\n1\\n1\\n\", \"1 1\\nATK 100\\n99\\n\", \"4 8\\nDEF 100\\nDEF 200\\nDEF 300\\nATK 100\\n100\\n101\\n201\\n301\\n1\\n1\\n1\\n1\\n\", \"3 4\\nDEF 1...
Fox Ciel is playing a card game with her friend Jiro. Jiro has n cards, each one has two attributes: position (Attack or Defense) and strength. Fox Ciel has m cards, each one has these two attributes too. It's known that position of all Ciel's cards is Attack. Now is Ciel's battle phase, Ciel can do the following ope...
0
{"tests": "{\"inputs\": [\"36 316049483082136289\\n\", \"1 923438\\n\", \"999999999999999999 2\\n\", \"2 999999999999999999\\n\", \"3 1000000000000000000\\n\", \"60236007668635342 110624799949034113\\n\", \"4 5\\n\", \"288565475053 662099878640\\n\", \"8944394323791464 5527939700884757\\n\", \"4052739537881 65574703198...
Mad scientist Mike is building a time machine in his spare time. To finish the work, he needs a resistor with a certain resistance value. However, all Mike has is lots of identical resistors with unit resistance R0 = 1. Elements with other resistance can be constructed from these resistors. In this problem, we will co...
0.75
{"tests": "{\"inputs\": [\"6\\nLRLRRLL\\nL\\nLLR\\nRRRR\\nLLLLLL\\nR\\n\", \"6\\nRRLRLLL\\nL\\nLLR\\nRRRR\\nLLLLLL\\nR\\n\", \"6\\nMRLRRLL\\nL\\nLLR\\nRRRR\\nLLLLLL\\nR\\n\", \"6\\nLLLRLRR\\nL\\nLRL\\nRRRR\\nLLLLLL\\nR\\n\", \"6\\nLRLRLRL\\nL\\nLLR\\nRRRR\\nLLLLLL\\nR\\n\", \"6\\nLLLLRRR\\nL\\nLRL\\nRRRR\\nLLLLLL\\nR\\...
There is a frog staying to the left of the string $s = s_1 s_2 \ldots s_n$ consisting of $n$ characters (to be more precise, the frog initially stays at the cell $0$). Each character of $s$ is either 'L' or 'R'. It means that if the frog is staying at the $i$-th cell and the $i$-th character is 'L', the frog can jump o...
0.125
{"tests": "{\"inputs\": [\"1 2 10 20 15 200\\n\", \"1 2 1 2 100 1000\\n\", \"17 19 22 26 55 2802\\n\", \"1 2 10 20 15 179\", \"26 19 22 26 55 2802\", \"1 2 5 20 15 179\", \"26 29 22 26 55 2802\", \"1 1 5 20 27 179\", \"17 19 22 47 55 2802\", \"14 29 22 26 55 2802\", \"1 3 10 20 15 243\", \"5 31 22 26 55 2802\", \"2 1 1...
Snuke is making sugar water in a beaker. Initially, the beaker is empty. Snuke can perform the following four types of operations any number of times. He may choose not to perform some types of operations. - Operation 1: Pour 100A grams of water into the beaker. - Operation 2: Pour 100B grams of water into the beaker...
0
{"tests": "{\"inputs\": [\"5\\na\\nabcdfdcecba\\nabbaxyzyx\\ncodeforces\\nacbba\\n\", \"10\\nu\\nxqpczgnzazxyrvx\\ncfjgfhxmzqmjgzzjthziuomldylspyfuxvjlgdc\\nooydbldio\\nyvaamavy\\nrzjjebcgotjffuzr\\nhtfkwvihzuwxczopzqujdnaorgxibjfcmlzntskawxhyoymwynitukttewfpajuph\\nfactnjajntcaf\\nywowyovhrgradhtrqkgurkjpudnrrqhmmwiaq...
This is the hard version of the problem. The difference is the constraint on the sum of lengths of strings and the number of test cases. You can make hacks only if you solve all versions of this task. You are given a string $s$, consisting of lowercase English letters. Find the longest string, $t$, which satisfies the...
0
{"tests": "{\"inputs\": [\"3\\n0 1 2\\n3 1 1\", \"3\\n0 0 1\\n1 0 0\", \"3\\n1 -3 1\\n-3 -3 1\", \"4\\n0 1 2 3\\n1 0 3 4\", \"3\\n0 2 2\\n0 1 2\", \"2\\n1 1\\n-1 0\", \"3\\n0 1 2\\n3 0 0\", \"4\\n0 1 2 0\\n1 0 3 4\", \"3\\n0 2 4\\n0 1 2\", \"2\\n2 1\\n-1 0\", \"3\\n0 1 2\\n5 0 0\", \"4\\n0 1 3 0\\n1 0 3 4\", \"3\\n0 4 ...
There is a sequence of length N: a = (a_1, a_2, ..., a_N). Here, each a_i is a non-negative integer. Snuke can repeatedly perform the following operation: * Let the XOR of all the elements in a be x. Select an integer i (1 ≤ i ≤ N) and replace a_i with x. Snuke's objective is to match a with another sequence b = (...
0.125
{"tests": "{\"inputs\": [[\"123\"], [\"0x123\"], [\"0o123\"], [\"0123\"], [\"123 \"], [\" 123\"], [\"0b1010\"], [\"+123\"], [\"-123\"], [\"0B1010\"], [\"0b12\"], [\"-0x123\"], [\"-0o123\"], [\"-0123\"], [\"123\\n\"], [\"\\n123\"], [\"-0b1010\"], [\"0xDEADbeef\"], [\"0X123\"], [\"0O123\"], [\"0o18\"]], \"outputs\": [[12...
Implement a function/class, which should return an integer if the input string is in one of the formats specified below, or `null/nil/None` otherwise. Format: * Optional `-` or `+` * Base prefix `0b` (binary), `0x` (hexadecimal), `0o` (octal), or in case of no prefix decimal. * Digits depending on base Any extra char...
0
{"tests": "{\"inputs\": [[900, \"abcdef\"], [56, \"ifkhchlhfd\"], [256, \"aaaaaddddr\"], [333, \"jfmgklfhglbe\"], [12, \"jaam\"], [808, \"alfbpmmpz\"], [660, \"zyxsqwh\"], [651, \"hmgoltyy\"], [349, \"nxls\"], [958, \"hovzfsxbmwu\"], [301, \"doda\"], [383, \"zwwl\"], [871, \"gnlyvknjga\"], [583, \"slhacx\"], [0, \"jpip...
It's your Birthday. Your colleagues buy you a cake. The numbers of candles on the cake is provided (x). Please note this is not reality, and your age can be anywhere up to 1,000. Yes, you would look a mess. As a surprise, your colleagues have arranged for your friend to hide inside the cake and burst out. They pretend...
0
{"tests": "{\"inputs\": [\"8\\n1 2 3 6 9 8 5 2\\n\", \"6\\n1 2 1 2 5 3\\n\", \"2\\n1 10\\n\", \"3\\n1 2 2\\n\", \"1\\n1\\n\", \"1\\n6\\n\", \"2\\n2 3\\n\", \"2\\n1000000000 1\\n\", \"4\\n3 2 4 2\\n\", \"5\\n1 2 5 4 3\\n\", \"2\\n1 1\\n\", \"3\\n1 3 4\\n\", \"1\\n1000000000\\n\", \"6\\n1 4 5 6 3 2\\n\", \"8\\n1 2 3 6 9 ...
There is a matrix A of size x × y filled with integers. For every $i \in [ 1 . . x ]$, $j \in [ 1 . . y ]$ A_{i}, j = y(i - 1) + j. Obviously, every integer from [1..xy] occurs exactly once in this matrix. You have traversed some path in this matrix. Your path can be described as a sequence of visited cells a_1, a_2,...
0
{"tests": "{\"inputs\": [\"abaabbabaab`abbabbabaabbab\\nab\", \"AABABCAC\\nB\", \"AbCdEfG\\naBcDeFh\", \"abaabbbbaab`abbabbabaabaab\\nab\", \"AACABCAC\\nB\", \"AbGdEfC\\naBcDeFh\", \"abaabbbbaab`abbabbabaabaab\\n`b\", \"AACABCAC\\nC\", \"AbGdEfC\\naBcDhFe\", \"abaabbbbaaa`abbabbabbabaab\\n`b\", \"AACAACAC\\nC\", \"AbGd...
Problem Given the strings $ s $, $ t $. First, let the string set $ A = $ {$ s $}, $ B = \ phi $. At this time, I want to perform the following operations as much as possible. operation step1 Perform the following processing for all $ u ∊ A $. 1. From all subsequences of $ u $ (not necessarily contiguous), choose ...
0
{"tests": "{\"inputs\": [\"10 10\\n..........\\n.#####....\\n.#........\\n.#.###....\\n.#.###....\\n.#.###....\\n.#..##....\\n.#####....\\n..........\\n..........\\n\", \"5 3\\n###\\n###\\n.#.\\n###\\n###\\n\", \"5 5\\n.....\\n.....\\n..#..\\n..#..\\n.....\\n\", \"9 9\\n#########\\n#.......#\\n#.#####.#\\n#.#.#.#.#\\n#...
You've gotten an n × m sheet of squared paper. Some of its squares are painted. Let's mark the set of all painted squares as A. Set A is connected. Your task is to find the minimum number of squares that we can delete from set A to make it not connected. A set of painted squares is called connected, if for every two s...
0
{"tests": "{\"inputs\": [\"4 4 2\\n2 3\\n1 2\\n1 3\\n1 4\\n\", \"5 8 2\\n2 1\\n4 2\\n5 4\\n5 2\\n4 3\\n5 1\\n4 1\\n3 2\\n\", \"5 7 2\\n1 5\\n3 2\\n2 5\\n3 4\\n1 2\\n5 3\\n1 3\\n\", \"2 1 1\\n2 1\\n\", \"16 20 2\\n10 3\\n5 3\\n10 5\\n12 7\\n7 6\\n9 12\\n9 6\\n1 10\\n11 16\\n11 1\\n16 2\\n10 2\\n14 4\\n15 14\\n4 13\\n13 ...
There are $n$ persons who initially don't know each other. On each morning, two of them, who were not friends before, become friends. We want to plan a trip for every evening of $m$ days. On each trip, you have to select a group of people that will go on the trip. For every person, one of the following should hold: ...
0.375
{"tests": "{\"inputs\": [\"2\\n1 2 3 4 5 6\\n\", \"2\\n1 2 3 3 2 2\\n\", \"1\\n39 52\\n\", \"2\\n59 96 34 48 8 72\\n\", \"3\\n87 37 91 29 58 45 51 74 70 71 47 38 91 89\\n\", \"5\\n39 21 95 89 73 90 9 55 85 32 30 21 68 59 82 91 20 64 52 70 6 88 53 47 30 47 34 14 11 22 42 15 28 54 37 48 29 3 14 13 18 77 90 58 54 38 94 49...
Om Nom is the main character of a game "Cut the Rope". He is a bright little monster who likes visiting friends living at the other side of the park. However the dark old parks can scare even somebody as fearless as Om Nom, so he asks you to help him. [Image] The park consists of 2^{n} + 1 - 1 squares connected by ro...
0
{"tests": "{\"inputs\": [\"20 228 779 225 819 142 849 24 494 45 172 95 207 908 510 424 78 100 166 869 456\\n\", \"4 220 380 729 969\\n\", \"23 486 261 249 312 592 411 874 397 18 70 417 512 338 679 517 997 938 328 418 793 522 745 59\\n\", \"17 644 532 255 57 108 413 51 284 364 300 597 646 712 470 42 730 231\\n\", \"16 2...
How to make a cake you'll never eat. Ingredients. * 2 carrots * 0 calories * 100 g chocolate spread * 1 pack of flour * 1 egg Method. 1. Put calories into the mixing bowl. 2. Take carrots from refrigerator. 3. Chop carrots. 4. Take chocolate spread from refrigerator. 5. Put chocolate spread ...
0.375
{"tests": "{\"inputs\": [[\"Abcd1234\"], [\"Abcd123\"], [\"abcd1234\"], [\"AbcdefGhijKlmnopQRsTuvwxyZ1234567890\"], [\"ABCD1234\"], [\"Ab1!@#$%^&*()-_+={}[]|\\\\:;?/>.<,\"], [\"!@#$%^&*()-_+={}[]|\\\\:;?/>.<,\"], [\"\"], [\" aA1----\"], [\"4aA1----\"]], \"outputs\": [[true], [false], [false], [true], [false], [true], [...
## Description Your job is to create a simple password validation function, as seen on many websites. The rules for a valid password are as follows: - There needs to be at least 1 uppercase letter. - There needs to be at least 1 lowercase letter. - There needs to be at least 1 number. - The password needs to be at le...
0
{"tests": "{\"inputs\": [\"9 1 3 7 6\\n.#..#..\", \"15 1 3 15 11\\n...#.#...#.#...\", \"4 1 3 7 6\\n.#..#..\", \"8 1 3 7 6\\n.#..#..\", \"15 0 3 15 13\\n...#.#...#.#...\", \"15 0 3 15 11\\n...#.#...#.#...\", \"1 1 3 7 6\\n.#..#..\", \"15 1 3 15 7\\n...#.#...#.#...\", \"8 1 4 7 6\\n.#..#..\", \"15 0 6 15 13\\n...#.#...#...
There are N squares arranged in a row, numbered 1, 2, ..., N from left to right. You are given a string S of length N consisting of `.` and `#`. If the i-th character of S is `#`, Square i contains a rock; if the i-th character of S is `.`, Square i is empty. In the beginning, Snuke stands on Square A, and Fnuke stand...
0.125
{"tests": "{\"inputs\": [\"4 5\\n1 1\\n4 4\\n4 3\\n3 2\\n2 4\\n\", \"5 4\\n2 1\\n4 2\\n3 3\\n3 4\\n\", \"1 1\\n1 1\\n\", \"2 4\\n1 1\\n2 1\\n1 2\\n2 2\\n\", \"1 1\\n1 1\\n\", \"2 4\\n1 1\\n2 1\\n1 2\\n2 2\\n\", \"2 4\\n1 1\\n2 2\\n1 2\\n2 2\\n\", \"5 4\\n2 1\\n4 4\\n3 3\\n3 4\\n\", \"4 5\\n2 1\\n4 4\\n4 3\\n3 2\\n2 4\\...
You are given a chessboard of size $n \times n$. It is filled with numbers from $1$ to $n^2$ in the following way: the first $\lceil \frac{n^2}{2} \rceil$ numbers from $1$ to $\lceil \frac{n^2}{2} \rceil$ are written in the cells with even sum of coordinates from left to right from top to bottom. The rest $n^2 - \lceil...
0.125
{"tests": "{\"inputs\": [\"2\\n1 2 3 1\\n\", \"3\\n10 71 84 33 6 47 23 25\\n\", \"4\\n75 26 45 72 81 47 97 97 2 2 25 82 84 17 56 32\\n\", \"2\\n1 2 3 2\", \"3\\n10 71 84 33 6 32 23 25\", \"4\\n75 26 45 72 81 47 97 97 2 2 25 95 84 17 56 32\", \"2\\n0 2 3 2\", \"3\\n10 71 155 33 6 32 23 25\", \"4\\n75 26 45 112 81 47 97 ...
There is an integer sequence of length 2^N: A_0, A_1, ..., A_{2^N-1}. (Note that the sequence is 0-indexed.) For every integer K satisfying 1 \leq K \leq 2^N-1, solve the following problem: - Let i and j be integers. Find the maximum value of A_i + A_j where 0 \leq i < j \leq 2^N-1 and (i or j) \leq K. Here, or denote...
0.875
{"tests": "{\"inputs\": [\"4\\n4\\n1 5\\n2 4\\n2 3\\n3 4\\n5\\n1 5\\n2 3\\n2 5\\n3 5\\n2 2\\n3\\n1 3\\n2 4\\n2 3\\n7\\n1 10\\n2 8\\n2 5\\n3 4\\n4 4\\n6 8\\n7 7\\n\", \"1\\n1\\n1 200000\\n\", \"1\\n1\\n100000 100001\\n\", \"1\\n1\\n100000 100001\\n\", \"1\\n1\\n1 200000\\n\", \"1\\n1\\n1 99274\\n\", \"4\\n4\\n1 5\\n2 4\...
You are given $n$ segments on a coordinate axis $OX$. The $i$-th segment has borders $[l_i; r_i]$. All points $x$, for which $l_i \le x \le r_i$ holds, belong to the $i$-th segment. Your task is to choose the maximum by size (the number of segments) subset of the given set of segments such that each pair of segments i...
0
{"tests": "{\"inputs\": [\"3\\n4\\n3 4 3 3\\n-1 1 2 2\\n-1 2 2 3\\n2\\n5 6\\n-1 5\\n-1 1\\n3\\n3 5 2\\n-1 1 1\\n-1 3 5\\n\", \"3\\n4\\n3 4 3 3\\n-1 1 2 2\\n-1 2 2 3\\n2\\n5 6\\n-1 5\\n0 1\\n3\\n3 5 2\\n-1 1 1\\n-1 3 5\\n\", \"3\\n4\\n3 4 3 3\\n-1 1 2 2\\n-1 2 2 3\\n2\\n5 9\\n-1 5\\n0 1\\n3\\n3 5 2\\n-1 1 1\\n-1 3 5\\n\...
You have $n$ chains, the $i$-th chain consists of $c_i$ vertices. Vertices in each chain are numbered independently from $1$ to $c_i$ along the chain. In other words, the $i$-th chain is the undirected graph with $c_i$ vertices and $(c_i - 1)$ edges connecting the $j$-th and the $(j + 1)$-th vertices for each $1 \le j ...
0
{"tests": "{\"inputs\": [\"915 72\\n\", \"967 4\\n\", \"997 997\\n\", \"998 999\\n\", \"1 991\\n\", \"757 210\\n\", \"1 865\\n\", \"995 2\\n\", \"862 330\\n\", \"1 999\\n\", \"953 874\\n\", \"2 348\\n\", \"998 998\\n\", \"1 1000\\n\", \"555 349\\n\", \"993 2\\n\", \"936 759\\n\", \"44 343\\n\", \"991 2\\n\", \"1 744\\n...
Once upon a time in the Kingdom of Far Far Away lived Sir Lancelot, the chief Royal General. He was very proud of his men and he liked to invite the King to come and watch drill exercises which demonstrated the fighting techniques and tactics of the squad he was in charge of. But time went by and one day Sir Lancelot h...
0
{"tests": "{\"inputs\": [\"4\\n5 2 6 10 8 3\\n1 7\\n2 10 4\\n2 9 5\\n\", \"5\\n3 12 10 19\\n5 1 4 18 11 13\\n4 17 15 2 6\\n4 3 12 18 10\\n4 2 8 5 9\\n\", \"10\\n1 77966\\n1 79480\\n1 94920\\n1 53920\\n1 15585\\n1 57339\\n1 1585\\n1 91802\\n1 27934\\n1 20354\\n\", \"5\\n3 2 4 10\\n2 1 6\\n2 8 7\\n3 2 4 10\\n2 1 6\\n\", ...
Paw the Spider is making a web. Web-making is a real art, Paw has been learning to do it his whole life. Let's consider the structure of the web. <image> There are n main threads going from the center of the web. All main threads are located in one plane and divide it into n equal infinite sectors. The sectors are in...
0.625