messages listlengths 1 1 | ground_truth stringlengths 156 726k | dataset stringclasses 2
values |
|---|---|---|
[
{
"content": "Mike is given a matrix A, N and M are numbers of rows and columns respectively. A1, 1 is the number in the top left corner. All the numbers in A are non-negative integers. He also has L pairs of integers (ik, jk). His task is to calculate Ai1, j1 + Ai2, j2 + ... + AiL, jL.\n\nUnfortunately, Mike f... | [{"input": "3 2\n2 2\n4 1\n7 -1\n2\n1 2\n2 2", "output": "5\n"}, {"input": "3 2\n2 2\n7 0\n7 -1\n2\n1 2\n2 2", "output": "7\n"}, {"input": "3 2\n1 2\n3 5\n7 0\n2\n2 2\n2 2", "output": "10\n"}, {"input": "3 2\n1 2\n3 6\n7 0\n2\n2 2\n2 2", "output": "12\n"}, {"input": "3 2\n2 2\n4 0\n7 -1\n2\n1 2\n2 2", "output": "4\n"},... | code_stdio |
[
{
"content": "The year of 2012 is coming...\n\nAccording 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 mount... | [{"input": "22\nCleo likes Snowy\nCleo likes Troll\nChapay likes Dracul\nSnowy likes Troll\nDracul likes Chapay\nDracul likes Snowy\nChapay likes Cleo\nSnowy likes Chapay\nDracul likes Troll\nAnka likes Hexadecimal\nSnowy likes Anka\nHexadecimal likes Cleo\nHexadecimal likes Troll\nDracul likes Anka\nCleo likes Hexadec... | code_stdio |
[
{
"content": "Andrewid the Android is a galaxy-famous detective. He is now investigating the case of vandalism at the exhibition of contemporary art.\n\nThe 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 ... | [{"input": "100 19\n6 62 72 83 91 94 97\n3 61 84 99\n1 63\n5 46 53 56 69 78\n5 41 43 49 74 89\n5 55 57 79 85 87\n3 47 59 98\n3 64 76 82\n3 48 66 75\n2 60 88\n2 67 77\n4 40 51 73 95\n41 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 44 71 81\n4 58 65 90 93\n1 100... | code_stdio |
[
{
"content": "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 seg... | [{"input": "11\n63 106\n87 143\n102 132\n115 169\n74 145\n41 177\n56 130\n28 102\n19 124\n0 156\n22 183", "output": "Impossible\n"}, {"input": "11\n63 106\n87 143\n102 132\n115 169\n74 145\n41 177\n56 130\n28 102\n19 124\n0 294\n22 183", "output": "Impossible\n"}, {"input": "11\n63 106\n87 143\n102 132\n115 169\n74 145... | code_stdio |
[
{
"content": "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.\n\n* 3 Play the game.\n* The person who gets 11 points first wins the game.\n* The first serve of... | [{"input": "AABBAAABABAABBBAABA\nAABBBABBABBAAABABABAAB\nBABAABAABABABBAAAB\nAABABAAABBAABBBABAA\nAAAAAAAAAAA\nABBBBBBBBBB\n0", "output": "11 8\n10 12\n11 7\n11 8\n11 0\n0 11\n"}, {"input": "ABAABBBAABABAAABBAA\nAABBBABBABBAAABABABAAB\nBABAABAABABABBAAAB\nAABABAAABBAABBBABAA\nAAAAAAAAAAA\nABBBBBABBBB\n0", "output": "11... | code_stdio |
[
{
"content": "Mike and Ann are sitting in the classroom. The lesson is boring, so they decided to play an interesting game. Fortunately, all they need to play this game is a string $s$ and a number $k$ ($0 \\le k < |s|$).\n\nAt the beginning of the game, players are given a substring of $s$ with left border $l$... | [{"input": "wfyjbwcuxjrvmunfbrhethdmepeampvjcypavwoolteucetnqntytdfstvunnfyvngydjcohnwgtfddcnvuewxcafwureiupfeljqydwtickfbokoytlxtuwmvmvflemfvcksszlwgcwtamzovectkzxuzdtvbujyfpvcruvzvgglozwktwawcbkkwkookmuhjlcyjvfrnzmgpglvnbrujtbvtwrsqbulusfwzulxnadaqbijfrsvteqqoirfaolhfbgorxdwigwxcydbfxhvhqzjqirtznnwcjlcbakbitsjwocfgwc... | code_stdio |
[
{
"content": "Chef has a nice complete binary tree in his garden. Complete means that each node has exactly two sons, so the tree is infinite. Yesterday he had enumerated the nodes of the tree in such a way: \n- Let's call the nodes' level a number of nodes that occur on the way to this node from the root, incl... | [{"input": "4\nrll\nrll\nr\nlllr", "output": "14\n14\n4\n13\n"}, {"input": "4\nlrl\nrll\nr\nrlll", "output": "10\n14\n4\n27\n"}, {"input": "4\nlrl\nrll\nr\nllrl", "output": "10\n14\n4\n15\n"}, {"input": "4\nrll\nrll\nr\nllrl", "output": "14\n14\n4\n15\n"}, {"input": "4\nrll\nrll\nr\nrlll", "output": "14\n14\n4\n27\n"},... | code_stdio |
[
{
"content": "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. \n\nYou have to answer q queries. Each query is described by a s... | [{"input": "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\n2 10\n1 11\n1 12\n2 2\n2 3\n2 4\n2 5\n2 6\n2 7\n2 8\n3 9\n2 10\n2 11\n2 12\n3 3\n3 4\n3 5\n3 6\n4 7\n3 8\n3 9\n3 10\n3 11\n3 12\n4 4\n4 5\n4 6\n4 7\n4 8\n4 10\n4 10\n4 11\n4 12\n5 5\n5... | code_stdio |
[
{
"content": "Jeff's got n cards, each card contains either digit 0, or digit 5. Jeff can choose several cards and put them in a line so that he gets some number. What is the largest possible number divisible by 90 Jeff can make from the cards he's got?\n\nJeff must make the number without leading zero. At that... | [{"input": "214\n5 0 5 0 5 0 0 0 5 5 0 5 0 5 5 0 5 0 0 0 0 5 5 0 0 5 5 0 0 0 0 5 5 5 5 0 5 0 0 0 0 0 0 5 0 0 0 5 0 0 5 0 0 5 5 0 0 5 5 0 0 0 0 0 5 0 5 0 5 5 0 5 0 0 5 5 5 0 5 0 5 0 5 5 0 5 0 0 0 5 5 0 5 0 5 5 5 5 5 0 0 0 0 0 0 5 0 5 5 0 5 0 5 0 5 5 0 0 0 0 5 0 5 0 5 0 0 5 0 0 5 5 5 5 5 0 0 5 0 0 5 0 0 5 0 0 5 0 0 5 0 5... | code_stdio |
[
{
"content": "There are H rows and W columns of white square cells.\nYou will choose h of the rows and w of the columns, and paint all of the cells contained in those rows or columns.\nHow many white cells will remain?\nIt can be proved that this count does not depend on what rows and columns are chosen.\n\n---... | [{"input": "21 -1\n-5 -5", "output": "104\n"}, {"input": "39 -1\n-5 -5", "output": "176\n"}, {"input": "13 13\n8 10\n", "output": "15\n"}, {"input": "20 20\n19 19\n", "output": "1\n"}, {"input": "19 19\n5 3\n", "output": "224\n"}, {"input": "20 20\n1 1\n", "output": "361\n"}, {"input": "20 20\n20 20\n", "output": "0\n"... | code_stdio |
[
{
"content": "You've purchased a ready-meal from the supermarket.\n\nThe packaging says that you should microwave it for 4 minutes and 20 seconds, based on a 600W microwave.\n\nOh no, your microwave is 800W! How long should you cook this for?!\n\n___\n\n# Input\n\nYou'll be given 4 arguments:\n\n## 1. needed po... | [{"input": "\"600W\"\n4\n20\n\"800W\"", "output": "[\"3 minutes 15 seconds\"]", "fn_name": "cooking_time"}, {"input": "\"100W\"\n8\n45\n\"50W\"", "output": "[\"17 minutes 30 seconds\"]", "fn_name": "cooking_time"}, {"input": "\"450W\"\n3\n25\n\"950W\"", "output": "[\"1 minutes 38 seconds\"]", "fn_name": "cooking_time"}... | code_functional |
[
{
"content": "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 ... | [{"input": "100000 99999\n", "output": "50000\n"}, {"input": "100000 23458\n", "output": "38272\n"}, {"input": "100000 23457\n", "output": "11729\n"}, {"input": "92480 43074\n", "output": "24704\n"}, {"input": "85766 64050\n", "output": "10859\n"}, {"input": "67808 61809\n", "output": "30905\n"}, {"input": "80124 68695... | code_stdio |
[
{
"content": "A permutation of length n is an array containing each integer from 1 to n exactly once. For example, q = [4, 5, 1, 2, 3] is a permutation. For the permutation q the square of permutation is the permutation p that p[i] = q[q[i]] for each i = 1... n. For example, the square of q = [4, 5, 1, 2, 3] is... | [{"input": "100\n94 22 24 99 58 97 20 29 67 30 38 64 77 50 15 44 92 88 39 42 25 70 2 76 84 6 37 49 17 71 31 19 26 79 10 35 65 63 32 95 5 8 52 27 83 18 53 93 13 81 48 68 54 82 34 60 87 23 16 86 55 40 61 45 28 7 74 41 14 91 3 72 33 11 98 89 90 69 78 36 80 59 56 21 43 1 75 46 47 12 96 73 57 51 4 85 9 100 66 62\n", "output... | code_stdio |
[
{
"content": "Anya has bought a new smartphone that uses Berdroid operating system. The smartphone menu has exactly n applications, each application has its own icon. The icons are located on different screens, one screen contains k icons. The icons from the first to the k-th one are located on the first screen... | [{"input": "71 96 75634\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71\n27 26 27 26 27 26 27 26 27 26 27 26 27 26 27 26 27 26 27 26 27 26 27 26 27 26 27 26 27 26 ... | code_stdio |
[
{
"content": "Example\n\nInput\n\n4 3\n1000 1\n2000 2\n3000 3\n\n\nOutput\n\n2 3 4 4\n\nWrite Python code to solve this problem. Your program should read the input from stdin and write the output to stdout. Enclose your complete solution in a single ```python code block.",
"role": "user"
}
] | [{"input": "25 1\n1010 1\n3784 7\n3000 6", "output": "2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n"}, {"input": "25 2\n1011 2\n2889 1\n308 2", "output": "3 3 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n"}, {"input": "20 3\n0010 1\n4107 3\n4267 4", "output": "2 2 2 3 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n"}, {"inpu... | code_stdio |
[
{
"content": "There is a data which provides heights (in meter) of mountains. The data is only for ten mountains.\n\nWrite a program which prints heights of the top three mountains in descending order.\n\nConstraints\n\n0 β€ height of mountain (integer) β€ 10,000\n\nInput\n\n\nHeight of mountain 1\nHeight of moun... | [{"input": "1819\n2003\n1094\n2489\n1723\n492\n4419\n2848\n2834\n1724", "output": "4419\n2848\n2834\n"}, {"input": "1819\n2003\n1094\n2489\n1142\n492\n4419\n4289\n2834\n1724", "output": "4419\n4289\n2834\n"}, {"input": "1819\n2003\n876\n2840\n1723\n1799\n3776\n2848\n1592\n922", "output": "3776\n2848\n2840\n"}, {"input"... | code_stdio |
[
{
"content": "One day Jeff got hold of an integer sequence a_1, a_2, ..., a_{n} of length n. The boy immediately decided to analyze the sequence. For that, he needs to find all values of x, for which these conditions hold:\n\n x occurs in sequence a. Consider all positions of numbers x in the sequence a (such... | [{"input": "12\n10 19 7 3 1 8 15 17 14 9 4 5\n", "output": "12\n1 0\n3 0\n4 0\n5 0\n7 0\n8 0\n9 0\n10 0\n14 0\n15 0\n17 0\n19 0\n"}, {"input": "12\n10 19 7 3 1 8 15 17 14 15 4 5\n", "output": "11\n1 0\n3 0\n4 0\n5 0\n7 0\n8 0\n10 0\n14 0\n15 3\n17 0\n19 0\n"}, {"input": "12\n10 19 7 3 3 8 15 17 14 9 4 5\n", "output": "... | code_stdio |
[
{
"content": "You are given N points (x_i,y_i) located on a two-dimensional plane.\nConsider a subset S of the N points that forms a convex polygon.\nHere, 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 inte... | [{"input": "200\n6961 9533\n1847 2184\n9391 1072\n8146 7944\n3403 1703\n2280 4570\n8872 8035\n9417 8677\n8552 1719\n6602 3237\n6223 2519\n654 7141\n8494 2638\n7204 8528\n1352 3164\n1638 4388\n1102 7239\n3795 5213\n6836 786\n9662 2985\n6241 9368\n1325 8963\n1237 5004\n8000 5104\n9833 4105\n8543 3581\n9753 6278\n7003 822... | code_stdio |
[
{
"content": "Remove the parentheses\n=\nIn this kata you are given a string for example:\n\n```python\n\"example(unwanted thing)example\"\n```\n\nYour task is to remove everything inside the parentheses as well as the parentheses themselves.\n\nThe example above would return:\n\n```python\n\"exampleexample\"\n... | [{"input": "\"hello example (words(more words) here) something\"", "output": "[\"hello example something\"]", "fn_name": "remove_parentheses"}, {"input": "\"example (unwanted thing) example\"", "output": "[\"example example\"]", "fn_name": "remove_parentheses"}, {"input": "\"example(unwanted thing)example\"", "output... | code_functional |
[
{
"content": "Given a string s, write a method (function) that will return true if its a valid single integer or floating number or false if its not.\n\nValid examples, should return true:\n\nshould return false:\n\nWrite Python code to solve this problem. Define a top-level function named `isDigit` that takes ... | [{"input": "\"3 4 \"", "output": "[false]", "fn_name": "isDigit"}, {"input": "\"s2324\"", "output": "[false]", "fn_name": "isDigit"}, {"input": "\"-234.4\"", "output": "[true]", "fn_name": "isDigit"}, {"input": "\"34.65\"", "output": "[true]", "fn_name": "isDigit"}, {"input": "\"3 4\"", "output": "[false]", "fn_name"... | code_functional |
[
{
"content": "ATMs of a well-known bank of a small country are arranged so that they can not give any amount of money requested by the user. Due to the limited size of the bill dispenser (the device that is directly giving money from an ATM) and some peculiarities of the ATM structure, you can get at most k bil... | [{"input": "58 5\n1 6 9 18 34 41 82 99 164 179 183 204 240 396 636 1224 2023 2856 4488 4705 5712 9180 9266 18360 18850 20270 23086 60810 190701 197064 211140 214200 222970 243240 263510 314442 425670 486480 708288 789888 1009800 1025349 1054040 1094580 1325184 1579776 1748076 2050698 2635100 2895984 2918880 3975552 428... | code_stdio |
[
{
"content": "The aim of this Kata is to write a function which will reverse the case of all consecutive duplicate letters in a string. That is, any letters that occur one after the other and are identical.\n\nIf the duplicate letters are lowercase then they must be set to uppercase, and if they are uppercase ... | [{"input": "\"parallel universe\"", "output": "[\"paraLLel universe\"]", "fn_name": "reverse"}, {"input": "\"hello world\"", "output": "[\"heLLo world\"]", "fn_name": "reverse"}, {"input": "\"HELLO WORLD\"", "output": "[\"HEllO WORLD\"]", "fn_name": "reverse"}, {"input": "\"HeLlo World\"", "output": "[\"HeLlo World\"]"... | code_functional |
[
{
"content": "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.\n\nYou are given an array $a$ of $n$ integers (the given array can contain equal elements). You can perform the followi... | [{"input": "9\n5\n4 7 2 2 10\n5\n5 0 2 1 11\n5\n1 2 2 4 0\n2\n0 1\n3\n0 1 0\n4\n0 2 0 0\n4\n0 1 0 1\n4\n0 1 0 2\n20\n16 15 1 10 0 14 0 10 3 16 0 5 4 5 17 13 14 14 1 9\n", "output": "2\n3\n1\n0\n1\n1\n1\n1\n15\n"}, {"input": "9\n5\n4 7 2 2 10\n5\n5 0 2 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 ... | code_stdio |
[
{
"content": "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.\n\nR... | [{"input": "[10, 20, 1, 2, 3]\n5\n2", "output": "[11]", "fn_name": "roundRobin"}, {"input": "[10, 20, 1, 2, 3]\n5\n0", "output": "[21]", "fn_name": "roundRobin"}, {"input": "[10, 20, 1, 2, 3]\n4\n3", "output": "[11]", "fn_name": "roundRobin"}, {"input": "[10, 20, 1, 2, 3]\n4\n2", "output": "[9]", "fn_name": "roundRobin... | code_functional |
[
{
"content": "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 ... | [{"input": "100\n4 1 5 3 2 1 1 1 4 1 1 2 1 1 1 4 1 1 3 1 3 1 1 1 1 4 5 1 5 2 5 3 1 1 1 1 1 1 1 3 2 1 1 3 1 1 3 4 3 2 4 1 1 4 1 1 2 2 4 1 4 1 2 5 1 2 2 1 5 3 1 5 4 2 1 1 2 5 5 1 4 4 2 3 1 4 1 3 2 1 1 1 4 1 3 1 1 5 1\n0 18 10 2 1 9 9 0 9 5 6 8 11 6 28 11 29 50 25 15 9 4 3 51 13 4 68 31 4 6 2 5 26 1 21 7 3 4 9 7 40 3 0 7 ... | code_stdio |
[
{
"content": "The elections to Berland parliament are happening today. Voting is in full swing!\n\nTotally 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.\n\nAfter the end of the voting the number of votes for each ... | [{"input": "100 100 100 100\n71 22 92 3 19 90 1 16 88 56 62 37 56 84 52 46 4 64 21 19 37 54 21 81 56 33 71 57 86 75 62 42 79 67 14 8 66 30 13 38 20 71 36 66 46 55 4 99 18 37 7 24 72 46 32 86 87 7 90 93 96 94 21 23 62 53 16 11 11 83 21 81 68 50 85 9 94 60 47 41 34 82 11 12 95 81 61 81 86 85 64 36 57 62 86 3 16 90 73 91\... | code_stdio |
[
{
"content": "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.\n\nHere are some interesting facts about XXX: XXX consists of n cities, k of whose (just imagine!) are capital cities. ... | [{"input": "76 24\n6814 3834 1131 6256 2598 850 7353 1702 5773 1699 35 5103 1368 2258 7891 7455 8546 7316 7428 8864 6536 5750 8455 2624 7326 2197 8239 3806 3016 7126 85 3249 1138 6783 9684 4417 7417 3660 6334 7324 9760 9755 7605 9891 3676 8784 8739 8266 3272 9250 5875 939 4130 6540 7813 6867 9148 781 6190 964 5612 1864... | code_stdio |
[
{
"content": "<image>\n\n\nThis figure shows railway tracks for reshuffling cars. The rail tracks end in the bottom and the top-left rail track is used for the entrace and the top-right rail track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks.\n\nWe can simula... | [{"input": "1\n6\n-1\n13\n10\n0\n0\n0", "output": "10\n13\n-1\n"}, {"input": "1\n20\n0\n20\n11\n0\n0\n1", "output": "20\n11\n20\n"}, {"input": "1\n38\n0\n20\n11\n0\n0\n1", "output": "38\n11\n20\n"}, {"input": "1\n10\n0\n20\n11\n0\n0\n1", "output": "10\n11\n20\n"}, {"input": "1\n10\n0\n20\n14\n0\n0\n1", "output": "10\n1... | code_stdio |
[
{
"content": "# Task\n You are given an array of integers. Your task is to determine the minimum number of its elements that need to be changed so that elements of the array will form an arithmetic progression. Note that if you swap two elements, you're changing both of them, for the purpose of this kata.\n\n H... | [{"input": "[-10, -21, -20, -25, -13, 14, 2, 6, -50, -55, -60, -65, -70, -75, -80, -85, -90, -95, -100, -105, -110, -115, -120, -125, -130, 12, -24, -15, -150, 7, -160, -165, -170, -175, -180, -185, -190, -195, -200, -3, -6, -215, -220, -225, -230, -235, -240, -20, -250, -255, -260, 23, -270, -275, -280, -7, -290, -295... | code_functional |
[
{
"content": "Weβve all seen katas that ask for conversion from snake-case to camel-case, from camel-case to snake-case, or from camel-case to kebab-case β the possibilities are endless.\n\nBut if we donβt know the case our inputs are in, these are not very helpful.\n\n### Task:\n\nSo the task here is to implem... | [{"input": "\"hello-to-the-world\"", "output": "[\"kebab\"]", "fn_name": "case_id"}, {"input": "\"hello_to_the_world\"", "output": "[\"snake\"]", "fn_name": "case_id"}, {"input": "\"hello-To-The-World\"", "output": "[\"none\"]", "fn_name": "case_id"}, {"input": "\"hello_To_The_World\"", "output": "[\"none\"]", "fn_name... | code_functional |
[
{
"content": "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).... | [{"input": "3\n0110?11\n6\n5 1\n6 ?\n7 ?\n1 ?\n5 ?\n1 1\n", "output": "\n1\n2\n3\n3\n5\n4\n"}, {"input": "3\n0110?11\n6\n5 1\n6 ?\n7 ?\n2 ?\n5 ?\n1 1\n", "output": "1\n2\n3\n4\n5\n5\n"}, {"input": "3\n0110?11\n6\n5 1\n6 ?\n6 ?\n1 ?\n5 ?\n1 1\n", "output": "1\n2\n2\n2\n2\n2\n"}, {"input": "3\n11?0110\n6\n5 1\n6 ?\n7 ?\n... | code_stdio |
[
{
"content": "Given an integer, if the length of it's digits is a perfect square, return a square block of sqroot(length) * sqroot(length). If not, simply return \"Not a perfect square!\".\n\nExamples:\n\n1212 returns:\n\n>1212 \n\nNote: 4 digits so 2 squared (2x2 perfect square). 2 digits on each line.\n\n123... | [{"input": "11137980416513326753900366614118127597534595333758924261793440915871873756952319756649737238032191522372673120386100703535104754039588400552740678721535237244611848291138569327958593044675614468557005002330545247507161735907754581937618290513118338573433800934507948491646900563507252698934433726005748974840... | code_functional |
[
{
"content": "As Sherlock Holmes was investigating a crime, he identified n suspects. He knows for sure that exactly one of them committed the crime. To find out which one did it, the detective lines up the suspects and numbered them from 1 to n. After that, he asked each one: \"Which one committed the crime?\"... | [{"input": "64 28\n+54\n+44\n+55\n-3\n+33\n-54\n-54\n-7\n+33\n+54\n+54\n+26\n-54\n+14\n-54\n-47\n+25\n-54\n-54\n-54\n-52\n+54\n+54\n+54\n+54\n+20\n+7\n+54\n+4\n+32\n+46\n-54\n-47\n+15\n+32\n-54\n+7\n+62\n-16\n-54\n+3\n+54\n+54\n+54\n+54\n-54\n+54\n-54\n+54\n-52\n+27\n-7\n+54\n-5\n-54\n-18\n+1\n+58\n+28\n-46\n+61\n-54\n... | code_stdio |
[
{
"content": "You are given a book with n chapters.\n\nEach chapter has a specified list of other chapters that need to be understood in order to understand this chapter. To understand a chapter, you must read it after you understand every chapter on its required list.\n\nCurrently you don't understand any of t... | [{"input": "5\n4\n1 2\n0\n2 1 4\n1 3\n5\n1 5\n1 1\n1 1\n1 1\n1 4\n5\n0\n0\n2 1 2\n1 2\n2 2 1\n4\n2 2 3\n0\n0\n2 3 2\n5\n1 2\n1 3\n1 4\n1 3\n0\n", "output": "-1\n-1\n1\n2\n-1\n"}, {"input": "5\n4\n1 2\n0\n2 1 4\n1 2\n5\n1 5\n1 1\n1 1\n1 1\n1 4\n5\n0\n0\n2 1 2\n1 2\n2 2 1\n4\n2 2 4\n0\n0\n2 3 1\n5\n1 2\n1 3\n1 4\n1 3\n0\... | code_stdio |
[
{
"content": "You are given a function $f$ written in some basic language. The function accepts an integer value, which is immediately written into some variable $x$. $x$ is an integer variable and can be assigned values from $0$ to $2^{32}-1$. The function contains three types of commands:\n\n for $n$ β for l... | [{"input": "83\nadd\nfor 58\nend\nadd\nadd\nfor 36\nfor 84\nadd\nadd\nfor 86\nadd\nadd\nend\nend\nadd\nadd\nadd\nadd\nfor 23\nadd\nadd\nadd\nfor 70\nadd\nadd\nend\nfor 24\nfor 58\nend\nadd\nend\nend\nend\nfor 41\nfor 51\nend\nfor 22\nfor 39\nend\nfor 94\nfor 47\nadd\nfor 57\nend\nadd\nend\nfor 55\nadd\nfor 75\nfor 90\n... | code_stdio |
[
{
"content": "Snuke loves puzzles.\n\nToday, he is working on a puzzle using `S`- and `c`-shaped pieces. In this puzzle, you can combine two `c`-shaped pieces into one `S`-shaped piece, as shown in the figure below:\n\n9b0bd546db9f28b4093d417b8f274124.png\n\nSnuke decided to create as many `Scc` groups as possi... | [{"input": "12345 267141", "output": "72957\n"}, {"input": "12345 263982", "output": "72168\n"}, {"input": "10389 263982", "output": "71190\n"}, {"input": "10389 232248", "output": "63256\n"}, {"input": "12345 678901", "output": "175897"}, {"input": "5656 263982", "output": "68823\n"}, {"input": "10389 85698", "output"... | code_stdio |
[
{
"content": "As you know, Bob's brother lives in Flatland. In Flatland there are n cities, connected by n - 1 two-way roads. The cities are numbered from 1 to n. You can get from one city to another moving along the roads.\n\nThe Β«Two PathsΒ» company, where Bob's brother works, has won a tender to repair two pa... | [{"input": "50\n7 34\n5 34\n5 11\n11 23\n42 5\n41 11\n12 41\n41 49\n1 49\n12 6\n7 15\n17 42\n20 6\n17 46\n20 19\n46 22\n49 40\n44 40\n43 46\n22 8\n17 29\n44 18\n31 18\n46 9\n7 16\n32 11\n13 41\n20 36\n34 25\n46 28\n39 34\n30 42\n11 47\n45 15\n37 17\n4 23\n35 17\n17 48\n2 17\n34 24\n1 10\n21 5\n2 3\n50 16\n33 5\n20 14\n... | code_stdio |
[
{
"content": "Vasya works as a watchman in the gallery. Unfortunately, one of the most expensive paintings was stolen while he was on duty. He doesn't want to be fired, so he has to quickly restore the painting. He remembers some facts about it. The painting is a square 3 Γ 3, each cell contains a single integ... | [{"input": "100000 100000 100000 100000 100000\n", "output": "10000000000\n"}, {"input": "100000 100000 100000 100000 100000\n", "output": "10000000000"}, {"input": "100000 83958 32567 91083 110780\n", "output": "1466200000\n"}, {"input": "100000 80015 84290 50777 30497\n", "output": "1696900000\n"}, {"input": "100000 ... | code_stdio |
[
{
"content": "# Fix the Bugs (Syntax) - My First Kata\n\n## Overview\n\nHello, this is my first Kata so forgive me if it is of poor quality.\n\nIn this Kata you should fix/create a program that ```return```s the following values:\n\n - ```false/False``` if either a or b (or both) are not numbers\n - ```a % b```... | [{"input": "\"hello\"\n{}", "output": "[false]", "fn_name": "my_first_kata"}, {"input": "[]\n\"pippi\"", "output": "[false]", "fn_name": "my_first_kata"}, {"input": "\"hello\"\n3", "output": "[false]", "fn_name": "my_first_kata"}, {"input": "true\ntrue", "output": "[false]", "fn_name": "my_first_kata"}, {"input": "67\n... | code_functional |
[
{
"content": "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.\n\nLet \"-\" be a unary operator (i.e. a symbol representing one argu... | [{"input": "(Q*P)\n(--R+(Q*R))\n(P+-Q)\n2\n-1\n(-1+(((---P+Q)*(--Q+---R))+(-R+-P)))\n.", "output": "3\n9\n15\n27\n0\n19\n"}, {"input": "(P*Q)\n(--R+(P*Q))\n(P*-P)\n2\n2\n(-1+(((---P+Q)*(--Q+---R))*(-R+-P)))\n.", "output": "3\n11\n0\n27\n27\n7\n"}, {"input": "(P*R)\n(--R*(P*R))\n(P+-P)\n0\n2\n(-1+(((---P+Q)*(--Q+---P))*... | code_stdio |
[
{
"content": "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).\n\nMr. 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.\n\nMr. Aoki found the grid... | [{"input": "2 3\n5\n2 1 0\n1 2 10\n1 3 20\n2 1 30\n2 3 40", "output": "No\n"}, {"input": "2 3\n5\n2 1 0\n1 2 10\n1 3 37\n2 1 30\n2 3 40", "output": "No\n"}, {"input": "4 3\n5\n2 1 0\n1 2 10\n1 3 20\n2 1 30\n2 3 40", "output": "No\n"}, {"input": "2 3\n5\n1 1 0\n1 2 10\n1 3 20\n2 1 33\n2 3 40", "output": "No\n"}, {"input... | code_stdio |
[
{
"content": "# ASC Week 1 Challenge 5 (Medium #2)\n\nCreate 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. \n\nNote: the function should also work with negative numbers and floats.\n\n##... | [{"input": "[[2, 3, 9, 10, 7], [12, 6, 89, 45, 3], [9, 12, 56, 10, 34], [67, 23, 1, 88, 34]]", "output": "[[22.5, 11, 38.75, 38.25, 19.5]]", "fn_name": "avg_array"}, {"input": "[[1.2, 8.521, 0.4, 3.14, 1.9], [2, 4.5, 3.75, 0.987, 1.0]]", "output": "[[1.6, 6.5105, 2.075, 2.0635, 1.45]]", "fn_name": "avg_array"}, {"input... | code_functional |
[
{
"content": "A company has N members, who are assigned ID numbers 1, ..., N.\nEvery member, except the member numbered 1, has exactly one immediate boss with a smaller ID number.\nWhen a person X is the immediate boss of a person Y, the person Y is said to be an immediate subordinate of the person X.\nYou are ... | [{"input": "10\n1 1 1 1 1 1 1 1 1\n", "output": "9\n0\n0\n0\n0\n0\n0\n0\n0\n0\n"}, {"input": "10\n1 1 1 1 1 2 1 1 1", "output": "8\n1\n0\n0\n0\n0\n0\n0\n0\n0\n"}, {"input": "10\n1 1 1 2 1 2 1 1 1", "output": "7\n2\n0\n0\n0\n0\n0\n0\n0\n0\n"}, {"input": "10\n1 1 1 2 1 2 1 1 2", "output": "6\n3\n0\n0\n0\n0\n0\n0\n0\n0\n"... | code_stdio |
[
{
"content": "Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.\n\nOne day Petya dreamt of a lexicographically k-th permutation of integers fro... | [{"input": "1000000000 1000000000\n", "output": "1022"}, {"input": "852355975 1000000000\n", "output": "1022\n"}, {"input": "444747744 1000000000\n", "output": "554"}, {"input": "70407598 1000000000\n", "output": "382\n"}, {"input": "77777779 1000000000\n", "output": "508"}, {"input": "1577407 95554455\n", "output": "1... | code_stdio |
[
{
"content": "Sean is trying to save a large file to a USB flash drive. He has n USB flash drives with capacities equal to a_1, a_2, ..., a_{n} megabytes. The file size is equal to m megabytes. \n\nFind the minimum number of USB flash drives needed to write Sean's file, if he can split the file between drives.\... | [{"input": "100\n32630\n548\n21\n756\n138\n56\n719\n97\n140\n599\n531\n464\n137\n737\n239\n626\n179\n170\n271\n335\n178\n298\n597\n616\n104\n190\n216\n333\n606\n621\n310\n70\n286\n593\n655\n472\n556\n77\n625\n744\n395\n487\n762\n316\n469\n258\n475\n596\n651\n180\n737\n101\n511\n708\n163\n713\n475\n557\n649\n705\n583\n9... | code_stdio |
[
{
"content": "Little walrus Fangy loves math very much. That's why when he is bored he plays with a number performing some operations.\n\nFangy takes some positive integer x and wants to get a number one from it. While x is not equal to 1, Fangy repeats the following action: if x is odd, then he adds 1 to it, o... | [{"input": "1000101100110000000001111010110000000010001001111110011011000011101011001001010010111\n", "output": "133\n"}, {"input": "1000101100100000000001111010110000000010001001111110011011000011101011001001010010111\n", "output": "134\n"}, {"input": "100010110010000000000111101010000000001000100111111001101100001110... | code_stdio |
[
{
"content": "You've got an undirected graph, consisting of n vertices and m edges. We will consider the graph's vertices numbered with integers from 1 to n. Each vertex of the graph has a color. The color of the i-th vertex is an integer c_{i}.\n\nLet's consider all vertices of the graph, that are painted some... | [{"input": "50 47\n21 17 47 15 50 47 47 41 28 18 27 47 29 28 32 26 16 26 8 22 27 10 45 21 17 30 31 38 14 8 9 40 29 35 41 24 22 14 40 46 44 34 40 31 48 40 8 50 1 28\n10 5\n34 2\n42 5\n36 28\n8 44\n36 3\n40 15\n33 18\n5 50\n1 6\n25 20\n39 24\n45 35\n14 27\n14 39\n17 47\n19 49\n28 10\n7 13\n34 3\n22 26\n5 6\n8 17\n32 18\n... | code_stdio |
[
{
"content": "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 ... | [{"input": "100\nWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWB\n", "output": "50\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 "}, {"input": "100\nWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBW... | code_stdio |
[
{
"content": "You are given positive integers A and B.\nIf A is a divisor of B, print A + B; otherwise, print B - A.\n\n-----Constraints-----\n - All values in input are integers.\n - 1 \\leq A \\leq B \\leq 20\n\n-----Input-----\nInput is given from Standard Input in the following format:\nA B\n\n-----Output--... | [{"input": "10 111", "output": "101\n"}, {"input": "110 40", "output": "-70\n"}, {"input": "111 40", "output": "-71\n"}, {"input": "111 62", "output": "-49\n"}, {"input": "111 68", "output": "-43\n"}, {"input": "101 68", "output": "-33\n"}, {"input": "111 90", "output": "-21\n"}, {"input": "20 20\n", "output": "40\n"},... | code_stdio |
[
{
"content": "Positive integer $x$ is called divisor of positive integer $y$, if $y$ is divisible by $x$ without remainder. For example, $1$ is a divisor of $7$ and $3$ is not divisor of $8$.\n\nWe gave you an integer $d$ and asked you to find the smallest positive integer $a$, such that\n\n$a$ has at least $4$... | [{"input": "2\n14\n100\n", "output": "527\n21311\n"}, {"input": "2\n14\n110\n", "output": "527\n25199\n"}, {"input": "2\n14\n111\n", "output": "527\n25651\n"}, {"input": "2\n60\n25\n", "output": "7747\n1711\n"}, {"input": "2\n22\n29\n", "output": "1081\n1891\n"}, {"input": "2\n40\n31\n", "output": "3403\n2627\n"}, {"in... | code_stdio |
[
{
"content": "For the New Year, Polycarp decided to send postcards to all his $n$ friends. He wants to make postcards with his own hands. For this purpose, he has a sheet of paper of size $w \\times h$, which can be cut into pieces.\n\nPolycarp can cut any sheet of paper $w \\times h$ that he has in only two ca... | [{"input": "16\n8192 8192 67108864\n8192 8192 67108865\n8192 8192 70000000\n8192 8192 67108863\n1 1 1\n13 13 1\n1000 1000 100\n100 15 16\n157 185 95\n1992 1895 12\n1888 4984 164\n1564 8917 15\n150 15 2\n1500 10 40\n1 10000 1000\n1 10000 10000\n", "output": "YES\nNO\nNO\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nYES\nNO\nYES\nNO\n... | code_stdio |
[
{
"content": "There is a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region. The front and back sides of these cards can be distinguished, and initially every card faces up.\n\nWe will ... | [{"input": "1495 932", "output": "1388490\n"}, {"input": "582 1592", "output": "922200\n"}, {"input": "1018 932", "output": "944880\n"}, {"input": "1018 374", "output": "377952\n"}, {"input": "314 1692", "output": "527280\n"}, {"input": "218 1592", "output": "343440\n"}, {"input": "582 1178", "output": "682080\n"}, {"i... | code_stdio |
[
{
"content": "Problem\n\n\"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 Seis... | [{"input": "1234 5 4 789012345678901234 5 6", "output": "1357101234567708000\n"}, {"input": "2017 4 2 789012345678901234 5 6", "output": "1357101234567706652\n"}, {"input": "2684 2 6 699116447311015755 5 1", "output": "1202480289374942482\n"}, {"input": "2152 4 2 789012345678901234 5 6", "output": "1357101234567706421\... | code_stdio |
[
{
"content": "Sereja has two sequences a and b and number p. Sequence a consists of n integers a1, a2, ..., an. Similarly, sequence b consists of m integers b1, b2, ..., bm. As usual, Sereja studies the sequences he has. Today he wants to find the number of positions q (q + (m - 1)Β·p β€ n; q β₯ 1), such that sequ... | [{"input": "82 50 1\n4 2 2 4 4 3 2 2 3 3 4 3 4 1 4 1 4 3 5 3 4 2 4 4 5 2 5 4 2 4 2 5 3 2 3 4 2 5 4 3 3 4 3 4 1 1 5 2 4 1 3 3 2 4 1 2 2 5 4 4 5 3 3 1 2 3 4 5 3 1 2 3 3 5 5 2 4 1 4 2 3 1\n4 3 3 3 4 1 4 4 5 5 5 2 5 4 1 2 2 1 3 3 3 3 2 5 3 2 4 3 2 2 4 4 4 3 4 2 1 2 3 2 1 1 5 2 3 5 4 5 3 4\n", "output": "2\n24 28 "}, {"inpu... | code_stdio |
[
{
"content": "Little Vlad is fond of popular computer game Bota-2. Recently, the developers announced the new add-on named Bota-3. Of course, Vlad immediately bought only to find out his computer is too old for the new game and needs to be updated.\n\nThere are n video cards in the shop, the power of the i-th v... | [{"input": "100\n955 479 355 759 257 497 690 598 275 446 439 787 257 326 584 713 322 5 253 781 434 307 164 154 241 381 38 942 771 906 240 11 431 478 628 1892 346 74 493 964 455 1105 950 41 585 549 892 687 264 41 487 676 63 453 861 980 620 844 80 907 285 506 772 748 773 743 44 925 529 685 845 313 419 504 770 324 2 559 4... | code_stdio |
[
{
"content": "Gregor is learning about RSA cryptography, and although he doesn't understand how RSA works, he is now fascinated with prime numbers and factoring them.\n\nGregor's favorite prime number is $P$. Gregor wants to find two bases of $P$. Formally, Gregor is looking for two integers $a$ and $b$ which s... | [{"input": "5\n5\n11\n11\n13\n19\n", "output": "2 4\n2 10\n2 10\n2 12\n2 18\n"}, {"input": "5\n5\n7\n11\n13\n19\n", "output": "2 4\n2 6\n2 10\n2 12\n2 18\n"}, {"input": "5\n5\n7\n11\n13\n19\n", "output": "2 4\n2 6\n2 10\n2 12\n2 18\n"}, {"input": "5\n5\n7\n13\n13\n19\n", "output": "2 4\n2 6\n2 12\n2 12\n2 18\n"}, {"inp... | code_stdio |
[
{
"content": "This is a hard version of the problem. The actual problems are different, but the easy version is almost a subtask of the hard version. Note that the constraints and the output format are different.\n\nYou are given a string $s$ consisting of $n$ lowercase Latin letters.\n\nYou have to color all i... | [{"input": "500\nhvmmnbwnblqfvwwrcbzkccvcdrhoxbvzwkopagpwntjwwqppduunnenopvyjumjotgcnkoorjcbzctddppezypklfhmxcmufnhcuwxhzbpumlevwdufpyasriaupqdjhpccvtxwqkjseqpsatgbkihgteuclmpaamloxpbtbxhekgpbjvndelmrenhtotvuaymrzpyhmlaujjttwrrlamijsxyegcwagncdscpbvprkwgpwdikdsbqrpkecilprocbyzsupmanekspjzoebjqvmjxjggleinlhipqtbxduimcol... | code_stdio |
[
{
"content": "Bleatrix Trotter the sheep has devised a strategy that helps her fall asleep faster. First, she picks a number N. Then she starts naming N, 2 Γ N, 3 Γ N, and so on.\nWhenever she names a number, she thinks about all of the digits in that number. She keeps track of which digits (0, 1, 2, 3, 4, 5, 6... | [{"input": "1250000", "output": "[90000000]", "fn_name": "trotter"}, {"input": "459923", "output": "[4139307]", "fn_name": "trotter"}, {"input": "691520", "output": "[2074560]", "fn_name": "trotter"}, {"input": "163444", "output": "[653776]", "fn_name": "trotter"}, {"input": "206929", "output": "[620787]", "fn_name": "... | code_functional |
[
{
"content": "Let's define a split of $n$ as a nonincreasing sequence of positive integers, the sum of which is $n$. \n\nFor example, the following sequences are splits of $8$: $[4, 4]$, $[3, 3, 2]$, $[2, 2, 1, 1, 1, 1]$, $[5, 2, 1]$.\n\nThe following sequences aren't splits of $8$: $[1, 7]$, $[5, 4]$, $[11, -3... | [{"input": "1000000000\n", "output": "500000001\n"}, {"input": "1000000000\n", "output": "500000001\n"}, {"input": "1223796969\n", "output": "611898485\n"}, {"input": "1074371686\n", "output": "537185844\n"}, {"input": "1141423649\n", "output": "570711825\n"}, {"input": "1000100000\n", "output": "500050001\n"}, {"input... | code_stdio |
[
{
"content": "In this Kata, you will be given two numbers, n and k and your task will be to return the k-digit array that sums to n and has the maximum possible GCD.\n\nFor example, given `n = 12, k = 3`, there are a number of possible `3-digit` arrays that sum to `12`, such as `[1,2,9], [2,3,7], [2,4,6], ...` ... | [{"input": "276\n12", "output": "[[3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 78]]", "fn_name": "solve"}, {"input": "24\n6", "output": "[[1, 2, 3, 4, 5, 9]]", "fn_name": "solve"}, {"input": "24\n5", "output": "[[1, 2, 3, 4, 14]]", "fn_name": "solve"}, {"input": "18\n5", "output": "[[1, 2, 3, 4, 8]]", "fn_name": "solve"},... | code_functional |
[
{
"content": "We have two indistinguishable pieces placed on a number line. Both pieces are initially at coordinate 0. (They can occupy the same position.)\n\nWe can do the following two kinds of operations:\n\n* Choose a piece and move it to the right (the positive direction) by 1.\n* Move the piece with the s... | [{"input": "1010000 100000 200000", "output": "489638142\n"}, {"input": "1010000 100001 200000", "output": "645079609\n"}, {"input": "1011000 100001 200000", "output": "150445035\n"}, {"input": "1011001 100001 200000", "output": "160610610\n"}, {"input": "1000000 110000 200000", "output": "385341624\n"}, {"input": "101... | code_stdio |
[
{
"content": "Recently Anton found a box with digits in his room. There are k_2 digits 2, k_3 digits 3, k_5 digits 5 and k_6 digits 6.\n\nAnton's favorite integers are 32 and 256. He decided to compose this integers from digits he has. He wants to make the sum of these integers as large as possible. Help him so... | [{"input": "5000000 5000000 5000000 5000000\n", "output": "1280000000\n"}, {"input": "4759823 3520376 4743363 4743363\n", "output": "1214827648\n"}, {"input": "4759823 3520376 4743363 4743363\n", "output": "1214827648\n"}, {"input": "5000000 5000000 5000000 5000000\n", "output": "1280000000\n"}, {"input": "4288078 3520... | code_stdio |
[
{
"content": "Polycarp has interviewed Oleg and has written the interview down without punctuation marks and spaces to save time. Thus, the interview is now a string s consisting of n lowercase English letters.\n\nThere is a filler word ogo in Oleg's speech. All words that can be obtained from ogo by adding go ... | [{"input": "100\nggogogoooggogooggoggogggggogoogoggooooggooggoooggogoooggoggoogggoogoggogggoooggoggoggogggogoogggoooo\n", "output": "gg***oogg***oggoggoggggg******ggooooggooggooogg***ooggoggoogggo***ggogggoooggoggoggoggg***ogggoooo\n"}, {"input": "100\nggogogoooggogooggoggogggggogoogoggooooggooggoooggogoooggoggoogggoog... | code_stdio |
[
{
"content": "In Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east.\nA company called AtCoder Express possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i).\nTakahashi the king is interested in the foll... | [{"input": "10 10 10\n1 6\n2 9\n4 5\n4 7\n4 7\n5 8\n6 6\n6 7\n7 9\n10 10\n1 8\n1 9\n1 10\n2 8\n2 9\n2 10\n3 8\n3 9\n3 10\n1 10\n", "output": "7\n9\n10\n6\n8\n9\n6\n7\n8\n10\n"}, {"input": "10 10 10\n1 6\n2 9\n4 5\n4 7\n4 7\n5 8\n6 6\n6 7\n7 9\n10 10\n1 8\n1 9\n1 10\n2 8\n2 10\n3 10\n3 8\n3 9\n3 10\n1 10", "output": "7\... | code_stdio |
[
{
"content": "International Abbreviation Olympiad takes place annually starting from 1989. Each year the competition receives an abbreviation of form IAO'y, where y stands for some number of consequent last digits of the current year. Organizers always pick an abbreviation with non-empty string y that has never... | [{"input": "9\nIAO'0\nIAO'00\nIAO'000\nIAO'0000\nIAO'00000\nIAO'000000\nIAO'0000000\nIAO'00000000\nIAO'000000000\n", "output": "1990\n2000\n3000\n10000\n100000\n1000000\n10000000\n100000000\n1000000000\n"}, {"input": "9\nIAO'0\nIAO'00\nIAO'000\nIAO'0000\nIAO'00000\nIAO'000000\nIAO'0000000\nIAO'00000000\nIAO'000000000\n... | code_stdio |
[
{
"content": "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.\n\nThe teacher gave Andrew an array of n numbers a_1, ..., a_{n}. After that he asked Andrew for each k from... | [{"input": "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 0 2 2 2 2 1 1 1 0 2 1 0 0 0 0 0 1 0 2 -1 1 0 0 2 0 2 2 1 0 2 2 0 2 0 2 1 2 1 1 1 0 2 1 0 2 1 1 2 1 2 0 1 2 2\n", "output": "36 30 38 35 35 33 34 31 28 22 22 23 19 16 19 20 22 23 24 25 25 26 26 27 26 26 26 26 25 ... | code_stdio |
[
{
"content": "Snuke has two boards, each divided into a grid with N rows and N columns. For both of these boards, the square at the i-th row from the top and the j-th column from the left is called Square (i,j).\n\nThere is a lowercase English letter written in each square on the first board. The letter written... | [{"input": "5\nabcde\nfghij\nklmno\npqrst\nuvvxy", "output": "0\n"}, {"input": "5\nabcde\nfghij\nonmlk\npqrst\nuvwxy", "output": "0\n"}, {"input": "5\nedcba\nfghij\nonmlk\npqrst\nuvwxy", "output": "0\n"}, {"input": "5\nedcba\njihgf\nonmlk\npqrst\nuvwxy", "output": "0\n"}, {"input": "5\nedcba\njihfg\nonmlk\npqrst\nuvwxy... | code_stdio |
[
{
"content": "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.\n\nFor simplification, in this kata, we will consider pandigital numbers in *base 10* and ... | [{"input": "-9999999999\n25", "output": "[[1023456789, 1023456798, 1023456879, 1023456897, 1023456978, 1023456987, 1023457689, 1023457698, 1023457869, 1023457896, 1023457968, 1023457986, 1023458679, 1023458697, 1023458769, 1023458796, 1023458967, 1023458976, 1023459678, 1023459687, 1023459768, 1023459786, 1023459867, 1... | code_functional |
[
{
"content": "There is a card game called \"Durak\", which means \"Fool\" in Russian. The game is quite popular in the countries that used to form USSR. The problem does not state all the game's rules explicitly β you can find them later yourselves if you want.\n\nTo play durak you need a pack of 36 cards. Each... | [{"input": "D\n9S 8S\n", "output": "YES\n"}, {"input": "H\nTH 8H\n", "output": "YES\n"}, {"input": "H\nAH KH\n", "output": "YES\n"}, {"input": "H\nAD KD\n", "output": "YES\n"}, {"input": "H\nAC QC\n", "output": "YES\n"}, {"input": "H\n7D 6D\n", "output": "YES\n"}, {"input": "H\nJS TS\n", "output": "YES\n"}, {"input": "... | code_stdio |
[
{
"content": "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.\n\n-----Input-----\n\nThe first line contains an integer T, the total number of testcases. Then T lines... | [{"input": "3 \n30 40 110\n45 45 90\n180 0 0", "output": "YES\nYES\nNO\n"}, {"input": "3 \n30 40 110\n12 45 90\n180 0 0", "output": "YES\nNO\nNO\n"}, {"input": "3 \n30 77 110\n45 45 90\n180 0 0", "output": "NO\nYES\nNO\n"}, {"input": "3 \n30 40 110\n12 56 90\n180 0 0", "output": "YES\nNO\nNO\n"}, {"input": "3 \n30 77 0... | code_stdio |
[
{
"content": "Boboniu likes bit operations. He wants to play a game with you.\n\nBoboniu gives you two sequences of non-negative integers $a_1,a_2,\\ldots,a_n$ and $b_1,b_2,\\ldots,b_m$.\n\nFor each $i$ ($1\\le i\\le n$), you're asked to choose a $j$ ($1\\le j\\le m$) and let $c_i=a_i\\& b_j$, where $\\&$ denot... | [{"input": "30 55\n194 478 207 22 344 507 374 462 107 506 317 299 326 308 459 396 330 317 138 342 126 473 423 180 41 165 435 72 53 71\n44 229 106 350 420 462 412 115 452 364 452 294 280 171 325 250 94 266 33 329 197 384 50 36 495 464 67 283 83 3 335 62 101 307 474 296 484 388 315 444 203 304 110 97 70 169 170 369 384 3... | code_stdio |
[
{
"content": "You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.\n\n-----Constraints-----\n - 1\\leq A\\leq B\\leq 10^{18}\n - 1\\leq C,D\\leq 10^9\n - All values in input are integers.\n\n-----Input-----\nInput is g... | [{"input": "123456789987654321 987654321123456789 999999999 1000000000\n", "output": "864197529407407405\n"}, {"input": "314159265358979323 846264338327950288 419716939 937510582\n", "output": "532105071133627368\n"}, {"input": "827191816666888190 908822776155224411 1000000000 300000000\n", "output": "81630959161812384... | code_stdio |
[
{
"content": "Thor is getting used to the Earth. As a gift Loki gave him a smartphone. There are n applications on this phone. Thor is fascinated by this phone. He has only one minor issue: he can't count the number of unread notifications generated by those applications (maybe Loki put a curse on it so he can'... | [{"input": "10 85\n2 2\n1 10\n1 1\n2 6\n1 2\n1 4\n1 7\n2 1\n1 1\n3 3\n1 9\n1 6\n1 8\n1 10\n1 8\n2 8\n1 6\n1 3\n1 9\n1 6\n1 3\n1 8\n1 1\n1 6\n1 10\n2 1\n2 10\n1 10\n1 1\n1 10\n1 6\n1 2\n1 8\n1 3\n1 4\n1 9\n1 5\n1 5\n2 2\n2 4\n1 7\n1 1\n2 4\n1 9\n2 1\n1 7\n1 8\n3 33\n1 10\n2 2\n1 3\n1 10\n1 6\n3 32\n2 3\n1 5\n2 10\n2 2\n... | code_stdio |
[
{
"content": "Berland State University has received a new update for the operating system. Initially it is installed only on the $1$-st computer.\n\nUpdate files should be copied to all $n$ computers. The computers are not connected to the internet, so the only way to transfer update files from one computer to ... | [{"input": "13\n576460752303423486 576460752303423486\n576460752303423487 576460752303423487\n576460752303423488 576460752303423488\n576460752303423489 576460752303423489\n576460752303423490 576460752303423490\n576460752303423488 288230376151711743\n576460752303423488 288230376151711744\n576460752303423488 288230376151... | code_stdio |
[
{
"content": "Long long ago, there was a thief. Looking for treasures, he was running about all over the world. One day, he heard a rumor that there were islands that had large amount of treasures, so he decided to head for there.\n\nFinally he found n islands that had treasures and one island that had nothing.... | [{"input": "3\n2 5\n-1 13\n2 2\n3\n2 0\n3 6\n2 3\n0", "output": "Yes\nNo\n"}, {"input": "3\n3 5\n-1 13\n2 2\n3\n2 0\n3 6\n2 3\n0", "output": "Yes\nNo\n"}, {"input": "3\n2 5\n0 8\n2 2\n3\n2 -1\n3 10\n2 2\n0", "output": "Yes\nNo\n"}, {"input": "3\n2 4\n0 8\n2 2\n3\n2 -1\n3 10\n2 2\n0", "output": "Yes\nNo\n"}, {"input": "... | code_stdio |
[
{
"content": "You are given two arrays $a$ and $b$ of positive integers, with length $n$ and $m$ respectively. \n\nLet $c$ be an $n \\times m$ matrix, where $c_{i,j} = a_i \\cdot b_j$. \n\nYou 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... | [{"input": "235 1\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 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... | code_stdio |
[
{
"content": "The stardate is 1977 and the science and art of detecting Death Stars is in its infancy. Princess Heidi has received information about the stars in the nearby solar system from the Rebel spies and now, to help her identify the exact location of the Death Star, she needs to know whether this inform... | [{"input": "10\nXXXOOOOXOX\nOOOXXXOXXO\nXOXXXXOOXX\nXOOOXXOXOO\nOOXOOOOOOX\nXXXXOXOOOO\nXXXOOXOXOX\nOOOOXOXOXX\nXOXXOXOOXO\nOOOOOXOOOO\nXXXOOOOXOX\nOOOXXXOXXO\nXOXXXXOOXX\nXOOOXXOXOO\nOOXOOOOOOX\nXXXXOXOOOO\nXXXOOXOXOX\nOOOOXOXOXX\nXOXXOXOOXO\nOOOOOXOOOO\n", "output": "Yes\n"}, {"input": "10\nXXOXXOXOOX\nOOOOXOOXXO\nOX... | code_stdio |
[
{
"content": "Vasya lives in a round building, whose entrances are numbered sequentially by integers from 1 to n. Entrance n and entrance 1 are adjacent.\n\nToday Vasya got bored and decided to take a walk in the yard. Vasya lives in entrance a and he decided that during his walk he will move around the house b... | [{"input": "100 37 -100\n", "output": "37\n"}, {"input": "100 37 -100\n", "output": "37\n"}, {"input": "100 37 -124\n", "output": "13\n"}, {"input": "145 38 106\n", "output": "144\n"}, {"input": "100 54 100\n", "output": "54\n"}, {"input": "100 54 100\n", "output": "54\n"}, {"input": "100 54 101\n", "output": "55\n"}, ... | code_stdio |
[
{
"content": "Two deer, AtCoDeer and TopCoDeer, are playing a game called Honest or Dishonest.\nIn this game, an honest player always tells the truth, and an dishonest player always tell lies.\nYou are given two characters a and b as the input. Each of them is either H or D, and carries the following informatio... | [{"input": "H H\n", "output": "H\n"}, {"input": "D H\n", "output": "D\n"}, {"input": "D D\n", "output": "H\n"}, {"input": "H 14", "output": "D\n"}, {"input": "H 15", "output": "D\n"}, {"input": "H 23", "output": "D\n"}, {"input": "H 17", "output": "D\n"}, {"input": "H 13", "output": "D\n"}, {"input": "H 12", "output": ... | code_stdio |
[
{
"content": "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.\n\nNote: ... | [{"input": "999", "output": "[[\"nineninenine\", \"onetwo\", \"six\", \"three\", \"five\", \"four\"]]", "fn_name": "numbers_of_letters"}, {"input": "311", "output": "[[\"threeoneone\", \"oneone\", \"six\", \"three\", \"five\", \"four\"]]", "fn_name": "numbers_of_letters"}, {"input": "37", "output": "[[\"threeseven\", \... | code_functional |
[
{
"content": "You are given N non-negative integers A_1, A_2, ..., A_N and another non-negative integer K.\nFor a integer X between 0 and K (inclusive), let f(X) = (X XOR A_1) + (X XOR A_2) + ... + (X XOR A_N).\nHere, for non-negative integers a and b, a XOR b denotes the bitwise exclusive OR of a and b.\nFind ... | [{"input": "1 0\n1000000000000\n", "output": "1000000000000\n"}, {"input": "4 9\n7 4 0 3\n", "output": "46\n"}, {"input": "3 7\n1 6 3\n", "output": "14\n"}] | code_stdio |
[
{
"content": "You are given an array $a$ consisting of $n$ integers $a_1, a_2, \\dots , a_n$.\n\nIn one operation you can choose two elements of the array and replace them with the element equal to their sum (it does not matter where you insert the new element). For example, from the array $[2, 1, 4]$ you can o... | [{"input": "2\n5\n3 1 10 4 1\n7\n1 0 1 1 1 2 2\n", "output": "2\n3\n"}, {"input": "2\n5\n3 1 10 5 1\n7\n1 0 1 1 1 2 2\n", "output": "2\n3\n"}, {"input": "2\n5\n3 1 10 5 1\n7\n1 0 1 1 1 2 4\n", "output": "2\n3\n"}, {"input": "2\n5\n3 1 10 5 1\n7\n1 0 1 1 0 2 4\n", "output": "2\n4\n"}, {"input": "2\n5\n3 1 10 5 1\n7\n1 0... | code_stdio |
[
{
"content": "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 ... | [{"input": "50 50 50 50\n", "output": "Second\n"}, {"input": "48 50 12 11\n", "output": "Second\n"}, {"input": "49 50 11 12\n", "output": "Second\n"}, {"input": "50 50 50 50\n", "output": "Second\n"}, {"input": "48 50 12 11\n", "output": "Second\n"}, {"input": "49 50 11 12\n", "output": "Second\n"}, {"input": "50 50 87... | code_stdio |
[
{
"content": "There is a robot in a warehouse and $n$ packages he wants to collect. The warehouse can be represented as a coordinate grid. Initially, the robot stays at the point $(0, 0)$. The $i$-th package is at the point $(x_i, y_i)$. It is guaranteed that there are no two packages at the same point. It is a... | [{"input": "3\n5\n1 3\n1 2\n3 3\n5 5\n4 3\n2\n1 0\n0 1\n1\n4 3\n", "output": "YES\nRUUURRRRUU\nNO\nYES\nRRRRUUU\n"}, {"input": "3\n5\n1 3\n1 2\n3 3\n5 5\n2 3\n2\n1 0\n0 1\n1\n4 3\n", "output": "YES\nRUUURRRRUU\nNO\nYES\nRRRRUUU\n"}, {"input": "3\n5\n1 3\n1 0\n3 3\n5 5\n4 3\n2\n1 0\n0 1\n1\n4 3\n", "output": "YES\nRUUUR... | code_stdio |
[
{
"content": "On the competitive programming platform CodeCook, every person has a rating graph described by an array of integers $a$ of length $n$. You are now updating the infrastructure, so you've created a program to compress these graphs.\n\nThe program works as follows. Given an integer parameter $k$, the... | [{"input": "5\n5\n1 5 3 4 2\n4\n1 3 2 1\n5\n1 3 3 3 1\n10\n1 2 3 4 5 10 7 8 9 10\n3\n3 3 2\n", "output": "10111\n0001\n00001\n0000011111\n000\n"}, {"input": "5\n5\n2 5 3 4 2\n4\n1 3 2 1\n5\n1 3 3 3 2\n10\n1 1 1 4 10 6 2 8 9 10\n3\n3 3 2\n", "output": "00000\n0001\n00111\n0000000001\n000\n"}, {"input": "5\n5\n1 5 3 4 2\... | code_stdio |
[
{
"content": "ATMs of a well-known bank of a small country are arranged so that they can not give any amount of money requested by the user. Due to the limited size of the bill dispenser (the device that is directly giving money from an ATM) and some peculiarities of the ATM structure, you can get at most k bil... | [{"input": "58 5\n1 6 9 18 34 41 82 99 164 179 183 204 240 396 636 1224 2023 2856 4488 4705 5712 9180 9266 18360 18850 20270 23086 60810 190701 197064 211140 214200 222970 243240 263510 314442 425670 486480 708288 789888 1009800 1025349 1054040 1094580 1325184 1579776 1748076 2050698 2635100 2895984 2918880 3975552 428... | code_stdio |
[
{
"content": "Is it rated?\n\nHere it is. The Ultimate Question of Competitive Programming, Codeforces, and Everything. And you are here to answer it.\n\nAnother Codeforces round has been conducted. No two participants have the same number of points. For each participant, from the top to the bottom of the stand... | [{"input": "10\n4078 4078\n2876 2876\n1061 1061\n3721 3721\n143 143\n2992 2992\n3279 3279\n3389 3389\n1702 1702\n1110 1110\n", "output": "unrated\n"}, {"input": "10\n4078 4078\n2876 2876\n1061 1061\n3721 3721\n143 143\n2992 2992\n3279 3279\n3389 3389\n1702 1702\n1110 1110\n", "output": "unrated\n"}, {"input": "10\n4078... | code_stdio |
[
{
"content": "##Overview\n\nWrite 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'.\n```python\nto_pretty(0) => \"just now\"\n\nto_pretty(40000) => \"11 hours ago\"\n```\n##Specifics\n - The output will be an amount of time, t, i... | [{"input": "10000000", "output": "[\"16 weeks ago\"]", "fn_name": "to_pretty"}, {"input": "40000", "output": "[\"11 hours ago\"]", "fn_name": "to_pretty"}, {"input": "1000000", "output": "[\"a week ago\"]", "fn_name": "to_pretty"}, {"input": "30", "output": "[\"30 seconds ago\"]", "fn_name": "to_pretty"}, {"input": "18... | code_functional |
[
{
"content": "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)$... | [{"input": "3\n7 0 0\n3 1 0\n22 0 2\n", "output": "-1\n-1\n-1\n"}, {"input": "3\n1 1 1\n9 -1 5\n35 0 1\n", "output": "1\n-1\n-1\n"}, {"input": "3\n2 2 3\n6 2 18\n10 0 1\n", "output": "1\n18\n-1\n"}, {"input": "3\n1 0 1\n9 -1 5\n35 0 1\n", "output": "0\n-1\n-1\n"}, {"input": "3\n1 0 1\n9 0 5\n35 -1 1\n", "output": "0\n-... | code_stdio |
[
{
"content": "Let $s$ be some string consisting of symbols \"0\" or \"1\". Let's call a string $t$ a substring of string $s$, if there exists such number $1 \\leq l \\leq |s| - |t| + 1$ that $t = s_l s_{l+1} \\ldots s_{l + |t| - 1}$. Let's call a substring $t$ of string $s$ unique, if there exist only one such ... | [{"input": "99985 45273\n", "output": "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000... | code_stdio |
[
{
"content": "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 ro... | [{"input": "50\n499 1400 1621 123 72 526 944 482 862 136 265 605 5 616 974 967 713 187 969 467 573 845 71 224 17 873 648 120 239 1722 438 574 404 129 899 583 632 314 525 496 443 857 241 78 575 2 430 137 387 911\n", "output": "459200194 19968654 978281891 778632355 119790684 519088159 339403985 279509183 259544188 47915... | code_stdio |
[
{
"content": "Ayoub thinks that he is a very smart person, so he created a function $f(s)$, where $s$ is a binary string (a string which contains only symbols \"0\" and \"1\"). The function $f(s)$ is equal to the number of substrings in the string $s$ that contains at least one symbol, that is equal to \"1\".\n... | [{"input": "5\n6 4\n5 2\n3 2\n2 1\n10 2\n", "output": "19\n12\n5\n2\n40\n"}, {"input": "5\n6 4\n5 2\n4 2\n2 1\n10 2\n", "output": "19\n12\n8\n2\n40\n"}, {"input": "5\n6 1\n0 0\n5 0\n16 1\n8 1\n", "output": "12\n0\n0\n72\n20\n"}, {"input": "5\n6 4\n5 2\n4 2\n2 2\n10 2\n", "output": "19\n12\n8\n3\n40\n"}, {"input": "5\n6... | code_stdio |
[
{
"content": "A and B are preparing themselves for programming contests.\n\nTo train their logical thinking and solve problems better, A and B decided to play chess. During the game A wondered whose position is now stronger.\n\nFor each chess piece we know its weight: the queen's weight is 9, the rook's weig... | [{"input": "...QK...\n........\n........\n........\n........\n........\n........\n...rk...\n", "output": "White\n"}, {"input": "rppppppr\n...k....\n........\n........\n........\n........\nK...Q...\n........\n", "output": "Black\n"}, {"input": "....bQ.K\n.B......\n.....P..\n........\n........\n........\n...N.P..\n.....R... | code_stdio |
[
{
"content": "We have a permutation of the integers from 1 through N, p_1, p_2, .., p_N. We also have M pairs of two integers between 1 and N (inclusive), represented as (x_1,y_1), (x_2,y_2), .., (x_M,y_M). AtCoDeer the deer is going to perform the following operation on p as many times as desired so that the n... | [{"input": "10 8\n10 3 6 8 7 10 9 1 2 4\n2 1\n4 1\n5 9\n4 2\n6 2\n3 5\n8 9\n7 9", "output": "2\n"}, {"input": "10 8\n10 3 6 8 7 10 9 1 2 4\n2 1\n3 1\n5 9\n4 2\n6 2\n3 5\n8 9\n7 9", "output": "7\n"}, {"input": "10 8\n10 3 6 8 7 10 9 1 2 4\n2 1\n4 1\n5 9\n4 2\n6 1\n3 5\n8 9\n7 9", "output": "2\n"}, {"input": "10 8\n5 3 6... | code_stdio |
[
{
"content": "Theater stage is a rectangular field of size n Γ m. The director gave you the stage's plan which actors will follow. For each cell it is stated in the plan if there would be an actor in this cell or not.\n\nYou are to place a spotlight on the stage in some good position. The spotlight will project... | [{"input": "10 20\n0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n0 1 1 1 1 1 1 ... | code_stdio |
[
{
"content": "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.\n\nThe maze is organized as follows. Each room of the maze has two one-way portals. Let's ... | [{"input": "129\n1 1 3 3 1 3 7 4 3 5 8 11 3 9 15 4 11 15 1 6 18 9 11 13 17 22 8 18 26 13 16 20 3 16 35 26 23 28 27 30 39 29 43 8 14 6 17 32 26 31 2 18 3 47 52 21 57 1 35 35 53 47 16 26 30 65 48 2 1 11 10 5 4 1 4 53 71 21 53 8 58 49 17 6 19 80 1 49 43 60 12 60 35 25 86 45 47 97 69 74 10 91 93 31 69 41 80 90 67 4 111 100... | code_stdio |
[
{
"content": "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... | [{"input": "100000 100000 10000\n", "output": "308343288\n"}, {"input": "100000 100000 10000\n", "output": "308343288\n"}, {"input": "100000 100000 1000\n", "output": "402115033\n"}, {"input": "100000 100000 1000\n", "output": "402115033\n"}, {"input": "100000 100000 1001\n", "output": "500272705\n"}, {"input": "100000... | code_stdio |
[
{
"content": "Read problems statements in Russian here \nChef 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... | [{"input": "1\n57 0 -2", "output": "000000000000000000000000000000000000000000000000000000000\n"}, {"input": "1\n51 2 0", "output": "000000000000000000000000000000000000000000000000000\n"}, {"input": "1\n51 2 1", "output": "000000000000000000000000000000000000000000000000011\n"}, {"input": "1\n43 0 -2", "output": "0000... | code_stdio |
[
{
"content": "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,... | [{"input": "4\n6 3 2\n4 16 1 3 8 5\n4 4 1\n2 13 60 4\n4 2 3\n1 -1 2 2\n2 2 0\n2 2\n", "output": "16\n4\n2\n2\n"}, {"input": "4\n6 3 2\n2 9 2 3 10 5\n4 4 1\n2 13 60 4\n4 2 3\n1 2 2 1\n2 2 0\n1 2\n", "output": "10\n4\n2\n1\n"}, {"input": "4\n6 3 2\n2 9 2 3 10 5\n4 4 1\n2 13 60 4\n4 3 3\n1 2 2 1\n2 2 0\n2 2\n", "output": ... | code_stdio |
[
{
"content": "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:\n\n* For every positive integer j, add x_i to the value of a_{j Γ m_i}.\n\n\n\nFind the value of the ... | [{"input": "5\n56 114834\n72 -134386\n100 190757\n192 -132693\n240 133108", "output": "438699\n"}, {"input": "5\n56 114834\n72 -134386\n100 190757\n192 -132693\n240 261716", "output": "567307\n"}, {"input": "5\n92 114834\n125 -176641\n100 13125\n192 -68478\n240 133108", "output": "261067\n"}, {"input": "5\n42 114834\n1... | code_stdio |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.