messages listlengths 1 1 | ground_truth stringlengths 156 726k | dataset stringclasses 2
values |
|---|---|---|
[
{
"content": "You want to make change for $ n $ cents. Assuming that you have infinite supply of coins of 1, 5, 10 and / or 25 cents coins respectively, find the minimum number of coins you need.\n\nConstraints\n\n* $ 1 \\ le n \\ le 10 ^ 9 $\n\nInput\n\n\n$ n $\n\n\nThe integer $ n $ is given in a line.\n\nout... | [{"input": "251195", "output": "10049\n"}, {"input": "467454", "output": "18702\n"}, {"input": "698278", "output": "27934\n"}, {"input": "323456", "output": "12940\n"}, {"input": "164898", "output": "6600\n"}, {"input": "122288", "output": "4895\n"}, {"input": "111927", "output": "4479\n"}, {"input": "163537", "output"... | code_stdio |
[
{
"content": "You are given strings s and t, consisting of lowercase English letters.\nYou will create a string s' by freely rearranging the characters in s.\nYou will also create a string t' by freely rearranging the characters in t.\nDetermine whether it is possible to satisfy s' < t' for the lexicographic or... | [{"input": "ratcode\natlas\n", "output": "Yes\n"}, {"input": "ratcode\nsalta", "output": "Yes\n"}, {"input": "ratcode\nsalt`", "output": "Yes\n"}, {"input": "rdtcoae\nsalt`", "output": "Yes\n"}, {"input": "eaoctdr\nsalt`", "output": "Yes\n"}, {"input": "rdtcoae\nsalta", "output": "Yes\n"}, {"input": "rdtcoae\natlas", "... | code_stdio |
[
{
"content": "This year in Equestria was a year of plenty, so Applejack has decided to build some new apple storages. According to the advice of the farm designers, she chose to build two storages with non-zero area: one in the shape of a square and another one in the shape of a rectangle (which possibly can be... | [{"input": "1\n1\n34\n- 1\n+ 1\n+ 1\n+ 1\n+ 1\n+ 1\n+ 1\n+ 1\n+ 1\n+ 1\n- 1\n- 1\n- 1\n- 1\n- 1\n+ 2\n+ 2\n+ 2\n+ 2\n- 1\n+ 2\n+ 2\n- 1\n+ 2\n- 1\n+ 3\n+ 3\n+ 1\n- 1\n- 2\n- 2\n- 2\n+ 1\n+ 3\n", "output": "NO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nYES\nNO\nNO\nYES\nYES\nYES\nNO\nNO\nYES... | code_stdio |
[
{
"content": "Your task is to shuffle a deck of n cards, each of which is marked by a alphabetical letter.\n\nA single shuffle action takes out h cards from the bottom of the deck and moves them to the top of the deck.\n\nThe deck of cards is represented by a string as follows.\n\n\nabcdeefab\n\n\nThe first cha... | [{"input": "caaa\n3\n1\n-1\n2\nvwxyz\n2\n3\n4\n-", "output": "aaca\nxyzvw\n"}, {"input": "caaa\n3\n1\n-2\n2\nwwxyz\n2\n3\n4\n-", "output": "aaac\nxyzww\n"}, {"input": "caaa\n3\n1\n-2\n2\nwwxyz\n2\n4\n4\n-", "output": "aaac\nyzwwx\n"}, {"input": "caaa\n3\n0\n0\n2\nvxxyz\n2\n1\n10\n-", "output": "aaca\nxxyzv\n"}, {"input... | code_stdio |
[
{
"content": "Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. \n\nYou are given two integer arrays A and B each of size N. Let us define interaction of arrays A and B to be the sum of A[i] * B[i] for each i from 1 to N.\n\nYou want to maximize the value of interaction of the arrays... | [{"input": "2\n2 2\n2 2\n-4 6\n3 9\n1 2 -3\n-2 -1 -4", "output": "16\n44\n"}, {"input": "2\n2 4\n0 2\n-1 10\n3 3\n1 2 -3\n-4 3 -5", "output": "60\n32\n"}, {"input": "2\n2 4\n0 2\n-1 10\n3 1\n1 2 -3\n-4 3 -5", "output": "60\n22\n"}, {"input": "2\n2 4\n0 2\n-1 10\n3 1\n1 3 -3\n-4 3 -5", "output": "60\n25\n"}, {"input": "... | code_stdio |
[
{
"content": "Your friend is developing a computer game. He has already decided how the game world should look like β it should consist of n locations connected by m two-way passages. The passages are designed in such a way that it should be possible to get from any location to any other location.\n\nOf course,... | [{"input": "50 72\n35 38\n19 46\n35 12\n27 30\n23 41\n50 16\n31 6\n20 33\n38 1\n10 35\n13 43\n29 25\n25 4\n1 13\n4 20\n36 29\n13 47\n48 5\n30 21\n30 38\n28 50\n41 45\n25 43\n40 36\n19 47\n31 32\n26 28\n8 13\n43 24\n27 35\n14 29\n14 38\n50 9\n34 49\n12 34\n43 42\n41 15\n46 29\n48 11\n48 7\n40 29\n48 21\n18 26\n15 11\n12... | code_stdio |
[
{
"content": "Sometimes Mister B has free evenings when he doesn't know what to do. Fortunately, Mister B found a new game, where the player can play against aliens.\n\nAll characters in this game are lowercase English letters. There are two players: Mister B and his competitor.\n\nInitially the players have a ... | [{"input": "12 12 876543210 1000000000\n", "output": "13\n"}, {"input": "12 12 876543210 1000000000\n", "output": "13"}, {"input": "10 12 220000011 220000032\n", "output": "11\n"}, {"input": "5 10 1000000000 1000000000\n", "output": "1\n"}, {"input": "11 3 378541409 1077499882\n", "output": "19\n"}, {"input": "10 12 22... | code_stdio |
[
{
"content": "<image>\n\n\nThere used to be a game called Joseph's potatoes. Let's say n people are participating. Participants form a circle facing the center and are numbered starting from 1. One hot potato is given to participant n (the large number 30 inside the figure on the left). Participants who are giv... | [{"input": "44 3\n45 10\n0 0", "output": "40\n33\n"}, {"input": "75 2\n16 14\n0 0", "output": "23\n10\n"}, {"input": "18 3\n45 10\n0 0", "output": "14\n33\n"}, {"input": "26 3\n45 10\n0 0", "output": "17\n33\n"}, {"input": "75 2\n16 17\n0 0", "output": "23\n12\n"}, {"input": "13 2\n16 17\n0 0", "output": "11\n12\n"}, {... | code_stdio |
[
{
"content": "There is a straight snowy road, divided into n blocks. The blocks are numbered from 1 to n from left to right. If one moves from the i-th block to the (i + 1)-th block, he will leave a right footprint on the i-th block. Similarly, if one moves from the i-th block to the (i - 1)-th block, he will l... | [{"input": "17\n.......RRRRR.....\n", "output": "8 13\n"}, {"input": "17\n.....RRRRR.......\n", "output": "6 11\n"}, {"input": "17\n......RRRRR......\n", "output": "7 12\n"}, {"input": "13\n....LLLLLL...\n", "output": "10 4\n"}, {"input": "13\n...LLLLLL....\n", "output": "9 3\n"}, {"input": "11\n.RRRLLLLL..\n", "output... | code_stdio |
[
{
"content": "You have a new professor of graph theory and he speaks very quickly. You come up with the following plan to keep up with his lecture and make notes.\n\nYou know two languages, and the professor is giving the lecture in the first one. The words in both languages consist of lowercase English charact... | [{"input": "10 22\nazbrll oen\ngh vdyayei\njphveblohx vfglv\nmfyxib jepnvhcuwo\nrpikazqj uam\nl rx\nokjenof qpnyi\nj tixqrno\nod itozmfct\nikkdxmirx ev\nqexftojc p\nkdazb zjs\nmbk ykvqjrxaxu\nhbcwhouzq pwt\nmirpsz zfaegpl\nuhkkvcj rlvwj\nef iqnnwtolrc\npjzfcpmeag ecdayth\nsa qcthz\ncbfhfxi qrnbvdryz\nwqel tj\natx smkbi... | code_stdio |
[
{
"content": "Write a function to calculate compound tax using the following table:\n\nFor $10 and under, the tax rate should be 10%.\nFor $20 and under, the tax rate on the first $10 is %10, and the tax on the rest is 7%.\nFor $30 and under, the tax rate on the first $10 is still %10, the rate for the next $10... | [{"input": "1000000", "output": "[30001.3]", "fn_name": "tax_calculator"}, {"input": "30.49", "output": "[2.21]", "fn_name": "tax_calculator"}, {"input": "\"monkey\"", "output": "[0]", "fn_name": "tax_calculator"}, {"input": "11", "output": "[1.07]", "fn_name": "tax_calculator"}, {"input": "15", "output": "[1.35]", "fn... | code_functional |
[
{
"content": "In music, if you double (or halve) the pitch of any note you will get to the same note again.\n\n\"Concert A\" is fixed at 440 Hz, and every other note is defined based on that. 880 Hz is also an A, as is 1760 Hz, as is 220 Hz.\n\nThere are 12 notes in Western music: A, A#, B, C, C#, D, D#, E, F, ... | [{"input": "261.625", "output": "[\"C\"]", "fn_name": "get_note"}, {"input": "523.25", "output": "[\"C\"]", "fn_name": "get_note"}, {"input": "1046.5", "output": "[\"C\"]", "fn_name": "get_note"}, {"input": "440", "output": "[\"A\"]", "fn_name": "get_note"}, {"input": "220", "output": "[\"A\"]", "fn_name": "get_note"},... | code_functional |
[
{
"content": "Iβm planning to have a party on my birthday. Many of my friends will come to the party. Some of them will come with one or more pieces of cakes, but it is not certain if the number of the cakes is a multiple of the number of people coming.\n\nI wish to enjoy the cakes equally among the partiers. S... | [{"input": "0 5\n11 7 4 -1 15", "output": "36\n"}, {"input": "0 1\n15 0 -1 -1 1", "output": "15\n"}, {"input": "0 1\n45 -3 -1 1 2", "output": "45\n"}, {"input": "0 2\n56 -3 -1 1 2", "output": "53\n"}, {"input": "0 5\n11 7 4 0 15", "output": "37\n"}, {"input": "0 1\n11 7 4 0 15", "output": "11\n"}, {"input": "0 3\n-2 97... | code_stdio |
[
{
"content": "There are N bags, each containing two white balls. The i-th box contains two balls with integers x_i and y_i written on them, respectively.\nFor each of these bags, you will paint one of the balls red, and paint the other blue.\nAfterwards, the 2N balls will be classified according to color.\nThen... | [{"input": "2\n1 1\n1000000000 1000000000\n", "output": "999999998000000001\n"}, {"input": "2\n1 1\n1000000000 1000000100", "output": "1000000097999999901\n"}, {"input": "2\n1 1\n1000000000 1000100100", "output": "1000100097999899901\n"}, {"input": "2\n1 1\n1100000000 1000000000", "output": "1099999997900000001\n"}, {"... | code_stdio |
[
{
"content": "Moamen and Ezzat are playing a game. They create an array $a$ of $n$ non-negative integers where every element is less than $2^k$.\n\nMoamen wins if $a_1 \\,\\&\\, a_2 \\,\\&\\, a_3 \\,\\&\\, \\ldots \\,\\&\\, a_n \\ge a_1 \\oplus a_2 \\oplus a_3 \\oplus \\ldots \\oplus a_n$.\n\nHere $\\&$ denotes... | [{"input": "5\n200000 200000\n200000 200000\n200000 200000\n200000 200000\n200000 200000\n", "output": "226490044\n226490044\n226490044\n226490044\n226490044\n"}, {"input": "5\n200000 200000\n200000 200000\n200000 200000\n200000 200000\n200000 200000\n", "output": "226490044\n226490044\n226490044\n226490044\n226490044\... | code_stdio |
[
{
"content": "Given is a positive integer N. Consider repeatedly applying the operation below on N:\n - First, choose a positive integer z satisfying all of the conditions below:\n - z can be represented as z=p^e, where p is a prime number and e is a positive integer;\n - z divides N;\n - z is different from al... | [{"input": "1000000000000\n", "output": "8\n"}, {"input": "200560490130\n", "output": "11\n"}, {"input": "755827200000\n", "output": "10\n"}, {"input": "366735600000\n", "output": "10\n"}, {"input": "997764507000\n", "output": "7\n"}, {"input": "549755813888\n", "output": "8\n"}, {"input": "999999999989\n", "output": "... | code_stdio |
[
{
"content": "In the evening Polycarp decided to analyze his today's travel expenses on public transport.\n\nThe bus system in the capital of Berland is arranged in such a way that each bus runs along the route between two stops. Each bus has no intermediate stops. So each of the buses continuously runs along t... | [{"input": "27 8 1 0 1\nBcd A\nA b\nb BcDc\ndc dbaC\ndbaC dcCB\nB d\nd BbAc\nCBC b\nDBDca d\ncAbb AA\nAA Ba\ncAccb DBDca\ncb DdaB\nAAcBc Ba\nBa dc\ndc DDCd\nbcBDA da\nbDD ADD\nAA b\nb cb\ncb CCBbd\nCCBbd bcDdb\nbcDdb ddc\nddc C\nC Adc\nAdc BbAc\nBbAc DD\n", "output": "111\n"}, {"input": "27 8 1 0 1\nBcd A\nA b\nb BcDc\... | code_stdio |
[
{
"content": "Evlampiy has found one more cool application to process photos. However the application has certain limitations.\n\nEach photo i has a contrast v_{i}. In order for the processing to be truly of high quality, the application must receive at least k photos with contrasts which differ as little as po... | [{"input": "101 9\n3 2 2 1 4 1 3 2 3 4 3 2 3 1 4 4 1 1 4 1 3 3 4 1 2 1 1 3 1 2 2 4 3 1 4 3 1 1 4 4 1 2 1 1 4 2 3 4 1 2 1 4 4 1 4 3 1 4 2 1 2 1 4 3 4 3 4 2 2 4 3 2 1 3 4 3 2 2 4 3 3 2 4 1 3 2 2 4 1 3 4 2 1 3 3 2 2 1 1 3 1\n", "output": "0\n"}, {"input": "101 9\n3 2 2 1 4 1 3 2 3 4 3 2 3 1 4 4 1 1 4 1 3 3 4 1 2 1 1 3 1 2... | code_stdio |
[
{
"content": "Vladimir would like to prepare a present for his wife: they have an anniversary! He decided to buy her exactly $n$ flowers.\n\nVladimir went to a flower shop, and he was amazed to see that there are $m$ types of flowers being sold there, and there is unlimited supply of flowers of each type. Vladi... | [{"input": "1\n7 7\n873108721 195635452\n42649954 997221147\n873108721 1003477544\n1087176458 873108721\n1130734166 858693746\n1309378041 372607189\n1000000000 427003887\n", "output": "7410830018\n"}, {"input": "1\n7 7\n873108721 195635452\n66631086 997221147\n1700956320 1570665517\n1087176458 779474384\n596405150 5023... | code_stdio |
[
{
"content": "Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. \nZombies zombies everywhere!!Β \nIn a parallel world of zombies, there are N zombies. There are infinite number of unused cars, each of same model only differentiated by the their colors. The cars are of K colors.\n\nA z... | [{"input": "2\n2 6\n16 17", "output": "30\n118740505\n"}, {"input": "2\n2 6\n19 17", "output": "30\n361105078\n"}, {"input": "2\n2 6\n29 17", "output": "30\n684841218\n"}, {"input": "2\n2 6\n19 34", "output": "30\n525446287\n"}, {"input": "2\n3 6\n9 17", "output": "150\n14443521\n"}, {"input": "2\n1 6\n16 17", "output"... | code_stdio |
[
{
"content": "Write a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.\n\nConstraints\n\n* $0 \\leq S \\leq 86400$\n\nInput\n\nAn integer $S$ is given in a line.\n\nOutput\n\nPrint $h$, $m$ an... | [{"input": "71983", "output": "19:59:43\n"}, {"input": "-1025", "output": "-1:42:55\n"}, {"input": "-144", "output": "-1:57:36\n"}, {"input": "-274", "output": "-1:55:26\n"}, {"input": "-399", "output": "-1:53:21\n"}, {"input": "-694", "output": "-1:48:26\n"}, {"input": "-650", "output": "-1:49:10\n"}, {"input": "-469"... | code_stdio |
[
{
"content": "You are given four integer values $a$, $b$, $c$ and $m$.\n\nCheck if there exists a string that contains:\n\n$a$ letters 'A';\n\n$b$ letters 'B';\n\n$c$ letters 'C';\n\nno other letters;\n\nexactly $m$ pairs of adjacent equal letters (exactly $m$ such positions $i$ that the $i$-th letter is equal ... | [{"input": "3\n2 2 1 0\n2 1 1 1\n1 2 3 2\n", "output": "YES\nYES\nYES\n"}, {"input": "3\n2 2 1 0\n1 1 1 1\n1 2 3 2\n", "output": "YES\nNO\nYES\n"}, {"input": "3\n3 2 1 0\n1 1 1 1\n1 2 3 2\n", "output": "YES\nNO\nYES\n"}, {"input": "3\n3 2 1 0\n1 1 1 1\n1 2 3 3\n", "output": "YES\nNO\nYES\n"}, {"input": "3\n2 2 1 0\n1 1... | code_stdio |
[
{
"content": "Your mission in this problem is to write a computer program that manipulates molecular for- mulae in virtual chemistry. As in real chemistry, each molecular formula represents a molecule consisting of one or more atoms. However, it may not have chemical reality.\n\nThe following are the definition... | [{"input": "H 1\neI 5\nC 12\nO 16\nF 22\nNe 24\nEu 64\nCc 241\nEND_OF_FIRST_PART\nG2C\n(MhF)2As\nCu(OH)2\nH((CO)2F)99\n0", "output": "UNKNOWN\nUNKNOWN\nUNKNOWN\n7723\n"}, {"input": "H 0\nHe 4\nC 12\nO 26\nF 2\nOe 36\nvC 64\nCc 603\nEND_OF_FIRST_PART\nH2B\n(MgF)2As\nBu(OH)2\nH((CO)2F)99\n0", "output": "UNKNOWN\nUNKNOWN\... | code_stdio |
[
{
"content": "Valera is a lazy student. He has m clean bowls and k clean plates. \n\nValera has made an eating plan for the next n days. As Valera is lazy, he will eat exactly one dish per day. At that, in order to eat a dish, he needs exactly one clean plate or bowl. We know that Valera can cook only two types... | [{"input": "233 100 1\n2 2 1 1 1 2 2 2 2 1 1 2 2 2 1 2 2 1 1 1 2 2 1 1 1 1 2 1 2 2 1 1 2 2 1 2 2 1 2 1 2 1 2 2 2 1 1 1 1 2 1 2 1 1 2 1 1 2 2 1 2 1 2 1 1 1 1 1 1 1 1 1 2 1 2 2 2 1 1 2 2 1 1 1 1 2 1 1 2 1 2 2 2 1 1 1 2 2 2 1 1 1 1 2 1 2 1 1 1 1 2 2 2 1 1 2 1 2 1 1 1 1 1 2 1 1 1 1 1 2 1 1 2 2 1 2 1 1 2 2 1 1 2 2 1 1 1 2 2... | code_stdio |
[
{
"content": "You are making your very own boardgame. The game is played by two opposing players, featuring a 6 x 6 tile system, with the players taking turns to move their pieces (similar to chess). The design is finished, now it's time to actually write and implement the features. Being the good programmer yo... | [{"input": "\"k\"\n\"A\"", "output": "[\"k\"]", "fn_name": "fight_resolve"}, {"input": "\"K\"\n\"a\"", "output": "[\"K\"]", "fn_name": "fight_resolve"}, {"input": "\"K\"\n\"A\"", "output": "[-1]", "fn_name": "fight_resolve"}, {"input": "\"S\"\n\"A\"", "output": "[-1]", "fn_name": "fight_resolve"}, {"input": "\"k\"\n\"s... | code_functional |
[
{
"content": "Vasya is currently at a car rental service, and he wants to reach cinema. The film he has bought a ticket for starts in t minutes. There is a straight road of length s from the service to the cinema. Let's introduce a coordinate system so that the car rental service is at the point 0, and the cine... | [{"input": "4 13 400 600\n13 30\n1 19\n1 160\n1 113\n58 73 15 319 194 362 128 157 336 162 77 90 96\n", "output": "1\n"}, {"input": "4 13 400 600\n13 30\n1 19\n1 160\n1 113\n58 73 15 319 209 362 128 157 336 162 77 90 96\n", "output": "1\n"}, {"input": "4 13 400 600\n13 30\n1 19\n2 160\n1 113\n58 73 15 319 209 362 128 15... | code_stdio |
[
{
"content": "Burenka came to kindergarden. This kindergarten is quite strange, so each kid there receives two fractions ($\\frac{a}{b}$ and $\\frac{c}{d}$) with integer numerators and denominators. Then children are commanded to play with their fractions.\n\nBurenka is a clever kid, so she noticed that when sh... | [{"input": "7\n1000000000 999999999 999999999 999999998\n999999997 999999996 999999996 999999995\n999999994 999999993 999999993 999999992\n999999991 999999990 999999990 999999989\n999999988 999999987 999999987 999999986\n999999985 999999984 999999984 999999983\n999999982 999999981 999999981 999999980\n", "output": "2\n... | code_stdio |
[
{
"content": "Shuseki Kingdom is the world's leading nation for innovation and technology. There are n cities in the kingdom, numbered from 1 to n.\n\nThanks to Mr. Kitayuta's research, it has finally become possible to construct teleportation pipes between two cities. A teleportation pipe will connect two citi... | [{"input": "7 13\n6 1\n7 2\n3 7\n6 5\n3 6\n7 4\n3 5\n4 1\n3 1\n1 5\n1 6\n4 2\n2 4\n", "output": "7\n"}, {"input": "7 13\n6 1\n7 2\n3 7\n6 5\n3 6\n7 4\n3 7\n4 1\n3 1\n1 5\n1 6\n4 2\n2 4\n", "output": "7\n"}, {"input": "7 13\n6 1\n7 2\n3 7\n6 5\n3 6\n7 4\n3 4\n4 1\n3 1\n1 5\n1 6\n4 2\n2 4\n", "output": "7\n"}, {"input": ... | code_stdio |
[
{
"content": "Find the price of a product before tax such that, when the consumption tax rate is 8 percent and 10 percent, the amount of consumption tax levied on it is A yen and B yen, respectively. (Yen is the currency of Japan.)\nHere, the price before tax must be a positive integer, and the amount of consum... | [{"input": "80 100\n", "output": "1000\n"}, {"input": "68 85\n", "output": "850\n"}, {"input": "24 30\n", "output": "300\n"}, {"input": "25 32\n", "output": "320\n"}, {"input": "27 34\n", "output": "340\n"}, {"input": "56 71\n", "output": "710\n"}, {"input": "58 72\n", "output": "725\n"}, {"input": "34 43\n", "output":... | code_stdio |
[
{
"content": "Every year, hundreds of people come to summer camps, they learn new algorithms and solve hard problems.\n\nThis is your first year at summer camp, and you are asked to solve the following problem. All integers starting with 1 are written in one line. The prefix of these line is \"12345678910111213... | [{"input": "1000\n", "output": "3\n"}, {"input": "1000\n", "output": "3\n"}, {"input": "999\n", "output": "9\n"}, {"input": "100\n", "output": "5\n"}, {"input": "123\n", "output": "6\n"}, {"input": "157\n", "output": "3\n"}, {"input": "289\n", "output": "1\n"}, {"input": "179\n", "output": "4\n"}, {"input": "942\n", "o... | code_stdio |
[
{
"content": "A sequence a0, a1, ..., at - 1 is called increasing if ai - 1 < ai for each i: 0 < i < t.\n\nYou are given a sequence b0, b1, ..., bn - 1 and a positive integer d. In each move you may choose one element of the given sequence and add d to it. What is the least number of moves required to make the ... | [{"input": "100 3\n329 226 331 909 962 112 837 1005 194 818 506 416 125 648 367 459 400 582 989 547 329 438 234 121 272 226 821 376 834 427 718 164 834 113 654 177 737 212 169 696 744 180 89 944 233 147 667 990 809 1072 1085 1093 814 265 1067 312 833 572 303 901 1032 504 185 817 389 158 613 723 239 269 911 352 769 404 ... | code_stdio |
[
{
"content": "AtCoDeer the deer recently bought three paint cans.\nThe color of the one he bought two days ago is a, the color of the one he bought yesterday is b, and the color of the one he bought today is c.\nHere, the color of each paint can is represented by an integer between 1 and 100, inclusive.\nSince ... | [{"input": "11 12 -1", "output": "3\n"}, {"input": "11 20 -1", "output": "3\n"}, {"input": "3 3 33\n", "output": "2\n"}, {"input": "5 -1 33", "output": "3\n"}, {"input": "5 -2 33", "output": "3\n"}, {"input": "3 17 -1", "output": "3\n"}, {"input": "3 12 -1", "output": "3\n"}, {"input": "6 12 -1", "output": "3\n"}, {"in... | code_stdio |
[
{
"content": "Peter Parker wants to play a game with Dr. Octopus. The game is about cycles. Cycle is a sequence of vertices, such that first one is connected with the second, second is connected with third and so on, while the last one is connected with the first one again. Cycle may consist of a single isolate... | [{"input": "10\n1378238141 598196518 640274071 983359971 23484317 96204862 799843967 446173607 613537551 402690754\n", "output": "2\n1\n1\n1\n1\n2\n2\n2\n2\n1\n"}, {"input": "10\n1378238141 870151580 640274071 983359971 42771579 67907111 799843967 446173607 613537551 402690754\n", "output": "2\n1\n1\n1\n1\n1\n1\n1\n1\n... | code_stdio |
[
{
"content": "There are N towns on a plane. The i-th town is located at the coordinates (x_i,y_i). There may be more than one town at the same coordinates.\n\nYou can build a road between two towns at coordinates (a,b) and (c,d) for a cost of min(|a-c|,|b-d|) yen (the currency of Japan). It is not possible to b... | [{"input": "6\n7 0\n0 4\n14 51\n2 1\n19 4\n4 20", "output": "10\n"}, {"input": "6\n1 -1\n4 5\n14 54\n1 2\n38 0\n4 5", "output": "14\n"}, {"input": "6\n7 0\n0 5\n14 31\n2 1\n19 4\n4 20", "output": "11\n"}, {"input": "6\n7 0\n0 5\n14 51\n2 1\n19 4\n4 20", "output": "11\n"}, {"input": "6\n13 0\n0 4\n14 51\n2 1\n19 4\n4 20... | code_stdio |
[
{
"content": "You've decided to carry out a survey in the theory of prime numbers. Let us remind you that a prime number is a positive integer that has exactly two distinct positive integer divisors.\n\nConsider positive integers a, a + 1, ..., b (a β€ b). You want to find the minimum integer l (1 β€ l β€ b - a + ... | [{"input": "100000 1000000 7821\n", "output": "108426\n"}, {"input": "10000 1000000 60000\n", "output": "793662\n"}, {"input": "10000 1000000 60000\n", "output": "793662"}, {"input": "100000 1000000 7821\n", "output": "108426"}, {"input": "100000 1000000 8225\n", "output": "114000"}, {"input": "100001 1000000 8225\n", ... | code_stdio |
[
{
"content": "Oleg the client and Igor the analyst are good friends. However, sometimes they argue over little things. Recently, they started a new company, but they are having trouble finding a name for the company.\n\nTo settle this problem, they've decided to play a game. The company name will consist of n l... | [{"input": "tinkoff\nzscoder\n", "output": "fzfsirk\n"}, {"input": "tinkoff\nzscoder\n", "output": "fzfsirk\n"}, {"input": "tinkogf\nzscoder\n", "output": "fzgsirk"}, {"input": "thnkogf\nzscoder\n", "output": "fzgshrk"}, {"input": "ffoknht\nzscoder\n", "output": "fzfshrk"}, {"input": "ffojnht\nzscoder\n", "output": "fz... | code_stdio |
[
{
"content": "Vasya likes to solve equations. Today he wants to solve $(x~\\mathrm{div}~k) \\cdot (x \\bmod k) = n$, where $\\mathrm{div}$ and $\\mathrm{mod}$ stand for integer division and modulo operations (refer to the Notes below for exact definition). In this equation, $k$ and $n$ are positive integer para... | [{"input": "999983 1000\n", "output": "999983001\n"}, {"input": "999995 1000\n", "output": "199999005\n"}, {"input": "1709131 435\n", "output": "743471986\n"}, {"input": "232207 1179\n", "output": "273772054\n"}, {"input": "652411 1010\n", "output": "658935111\n"}, {"input": "1000000 1000\n", "output": "1250800\n"}, {"... | code_stdio |
[
{
"content": "Little C loves number Β«3Β» very much. He loves all things about it.\n\nNow he has a positive integer $n$. He wants to split $n$ into $3$ positive integers $a,b,c$, such that $a+b+c=n$ and none of the $3$ integers is a multiple of $3$. Help him to find a solution.\n\n\n-----Input-----\n\nA single li... | [{"input": "1582786060\n", "output": "1 1 1582786058\n"}, {"input": "1000100000\n", "output": "1 2 1000099997\n"}, {"input": "1000071476\n", "output": "1 2 1000071473\n"}, {"input": "1042579470\n", "output": "1 1 1042579468\n"}, {"input": "1187564933\n", "output": "1 2 1187564930\n"}, {"input": "1455962944\n", "output"... | code_stdio |
[
{
"content": "The R1 company wants to hold a web search championship. There were n computers given for the competition, each of them is connected to the Internet. The organizers believe that the data transfer speed directly affects the result. The higher the speed of the Internet is, the faster the participant ... | [{"input": "80 50\n15160 6853 20254 11358 19535 27691 2983 31650 9219 11833 32053 31695 21511 4320 4384 24843 1454 31543 18796 13815 1546 27926 16276 14315 12542 25370 24890 29647 3584 17867 12446 15072 19852 30207 16361 7964 5343 398 10837 31114 9252 12767 15098 22562 32637 31823 8160 12658 6422 19142 12448 6765 7373 ... | code_stdio |
[
{
"content": "Problem\n\nMr. ukuku1333 is a little sloppy, so when I expanded the product of the linear expressions of x, I couldn't figure out the original linear expression.\nGiven the nth degree polynomial of x, factor it into the product of the original linear expressions of x.\n\nThe nth degree polynomial ... | [{"input": "x^5+15x^4+85x^3+225x^2+274x+120", "output": "(x+1)(x+2)(x+3)(x+4)(x+5)"}, {"input": "x^3-81x^2-1882x-1800", "output": "(x-100)(x+1)(x+18)"}, {"input": "x^2+4x+3", "output": "(x+1)(x+3)\n"}, {"input": "x^2+3x+2", "output": "(x+1)(x+2)"}, {"input": "x^2-4", "output": "(x-2)(x+2)\n"}, {"input": "x^2-4", "outpu... | code_stdio |
[
{
"content": "When a boy was cleaning up after his grand father passing, he found an old paper:\n\n<image>\n\n\n\nIn addition, other side of the paper says that \"go ahead a number of steps equivalent to the first integer, and turn clockwise by degrees equivalent to the second integer\".\n\nHis grand mother say... | [{"input": "56,65\n97,54\n64,-4\n55,76\n42,-27\n43,80\n87,-86\n55,-6\n89,34\n5,59\n0,0", "output": "181\n-212\n"}, {"input": "56,65\n97,54\n64,-4\n55,76\n42,-27\n43,80\n77,-86\n55,-6\n89,34\n95,5\n0,0", "output": "180\n-297\n"}, {"input": "56,65\n97,54\n64,-4\n65,76\n42,-27\n43,80\n77,-86\n55,-6\n89,34\n95,5\n0,0", "ou... | code_stdio |
[
{
"content": "Problem Statement\n\n\"Everlasting -One-\" is an award-winning online game launched this year. This game has rapidly become famous for its large number of characters you can play.\n\nIn this game, a character is characterized by attributes. There are $N$ attributes in this game, numbered $1$ throu... | [{"input": "12 2\n2 2\n4 12\n6 0\n100000 0\n0 0", "output": "2049\n64\n607723520\n"}, {"input": "12 2\n1 2\n4 3\n6 0\n100000 0\n0 0", "output": "1025\n64\n607723520\n"}, {"input": "12 2\n2 2\n4 3\n6 0\n100000 0\n0 0", "output": "2049\n64\n607723520\n"}, {"input": "4 0\n4 1\n2 3\n7 0\n100000 0\n0 0", "output": "16\n9\n1... | code_stdio |
[
{
"content": "One day Vasya got hold of information on the Martian dollar course in bourles for the next n days. The buying prices and the selling prices for one dollar on day i are the same and are equal to ai. Vasya has b bourles. He can buy a certain number of dollars and then sell it no more than once in n ... | [{"input": "93 867\n131 1270 616 1027 1685 27 1662 947 1480 20 1394 1528 191 1348 37 1694 1772 1706 1394 49 1391 878 1474 307 101 1129 1064 116 143 1239 261 651 1534 1348 1604 636 793 1188 1293 36 1729 1204 1656 1579 1644 661 1470 341 1709 1860 1081 1539 5 1892 1732 1049 419 25 1086 1263 967 1284 1229 1013 1348 1046 92... | code_stdio |
[
{
"content": "Toad Rash has a binary string s. A binary string consists only of zeros and ones.\n\nLet n be the length of s.\n\nRash needs to find the number of such pairs of integers l, r that 1 β€ l β€ r β€ n and there is at least one pair of integers x, k such that 1 β€ x, k β€ n, l β€ x < x + 2k β€ r, and s_x = s_... | [{"input": "1101111000011110111111110101100111111110111100001111011010111001101100010110000001010101101010111000\n", "output": "4672\n"}, {"input": "1101111000011110111111110101100111111110111100001111011010111001101100010110000001010101101010101000\n", "output": "4669\n"}, {"input": "1101111000001110111111110101100011... | code_stdio |
[
{
"content": "To get money for a new aeonic blaster, ranger Qwerty decided to engage in trade for a while. He wants to buy some number of items (or probably not to buy anything at all) on one of the planets, and then sell the bought items on another planet. Note that this operation is not repeated, that is, the... | [{"input": "5 10 15\nDdunkjly\n13 12 4\n83 26 1\n63 42 3\n83 22 2\n57 33 0\n59 10 1\n89 31 1\n57 17 2\n98 79 5\n46 41 3\nFbpbc\n28 21 0\n93 66 5\n66 21 0\n68 58 0\n59 17 3\n57 23 1\n72 71 1\n55 51 2\n58 40 5\n70 67 2\nKeiotmh\n73 44 4\n98 14 0\n19 7 0\n55 10 5\n30 25 4\n66 48 2\n66 51 4\n82 79 3\n73 63 4\n87 46 5\nNksd... | code_stdio |
[
{
"content": "You are given a Young diagram. \n\nGiven diagram is a histogram with n columns of lengths a_1, a_2, β¦, a_n (a_1 β₯ a_2 β₯ β¦ β₯ a_n β₯ 1).\n\n<image> Young diagram for a=[3,2,2,2,1].\n\nYour goal is to find the largest number of non-overlapping dominos that you can draw inside of this histogram, a domi... | [{"input": "100\n1980 1932 1906 1898 1892 1883 1877 1858 1842 1833 1777 1710 1689 1678 1660 1653 1648 1647 1644 1639 1635 1635 1593 1571 1534 1470 1440 1435 1389 1272 1269 1268 1263 1255 1249 1237 1174 1174 1128 1069 1067 981 979 979 951 915 911 906 863 826 810 810 802 785 764 752 743 710 705 696 676 661 639 619 616 57... | code_stdio |
[
{
"content": "~~~if-not:ruby,python\nReturn `1` when *any* odd bit of `x` equals 1; `0` otherwise.\n~~~\n~~~if:ruby,python\nReturn `true` when *any* odd bit of `x` equals 1; `false` otherwise.\n~~~\n\nAssume that:\n* `x` is an unsigned, 32-bit integer;\n* the bits are zero-indexed (the least significant bit is ... | [{"input": "2863311530", "output": "[true]", "fn_name": "any_odd"}, {"input": "24082", "output": "[true]", "fn_name": "any_odd"}, {"input": "1024", "output": "[false]", "fn_name": "any_odd"}, {"input": "1365", "output": "[false]", "fn_name": "any_odd"}, {"input": "128", "output": "[true]", "fn_name": "any_odd"}, {"inpu... | code_functional |
[
{
"content": "Young Timofey has a birthday today! He got kit of n cubes as a birthday present from his parents. Every cube has a number a_{i}, which is written on it. Timofey put all the cubes in a row and went to unpack other presents.\n\nIn this time, Timofey's elder brother, Dima reordered the cubes using th... | [{"input": "42\n-557774624 828320986 -345782722 -62979938 -681259411 -945983652 -139095040 832293378 -82572118 432027535 88438103 568183540 961782904 73543295 615958219 -5050584 322982437 -146046730 759453379 129267920 -819827396 -348156048 805080102 390723009 -771277251 -79011872 -592313207 528489973 656201270 -127795... | code_stdio |
[
{
"content": "Define a function that takes one integer argument and returns logical value `true` or `false` depending on if the integer is a prime.\n\nPer Wikipedia, a prime number (or a prime) is a natural number greater than 1 that has no positive divisors other than 1 and itself.\n\n## Requirements\n\n* You ... | [{"input": "75", "output": "[false]", "fn_name": "is_prime"}, {"input": "-1", "output": "[false]", "fn_name": "is_prime"}, {"input": "0", "output": "[false]", "fn_name": "is_prime"}, {"input": "1", "output": "[false]", "fn_name": "is_prime"}, {"input": "73", "output": "[true]", "fn_name": "is_prime"}, {"input": "2", "o... | code_functional |
[
{
"content": "You are given an undirected tree consisting of $n$ vertices. An undirected tree is a connected undirected graph with $n - 1$ edges.\n\nYour task is to add the minimum number of edges in such a way that the length of the shortest path from the vertex $1$ to any other vertex is at most $2$. Note tha... | [{"input": "7\n1 2\n2 3\n2 4\n4 5\n4 6\n5 7\n", "output": "2\n"}, {"input": "7\n1 2\n1 3\n2 4\n2 5\n3 6\n1 7\n", "output": "0\n"}, {"input": "7\n1 2\n2 3\n3 4\n3 5\n3 6\n3 7\n", "output": "1\n"}, {"input": "7\n1 2\n2 3\n2 4\n2 5\n3 6\n1 7\n", "output": "1\n"}, {"input": "7\n1 2\n2 3\n2 4\n2 5\n2 6\n1 7\n", "output": "0... | code_stdio |
[
{
"content": "Emacs is a text editor which is widely used by many programmers.\n\nThe advantage of Emacs is that we can move a cursor without arrow keys and the mice. For example, the cursor can be moved right, left, down, and up by pushing f, b, n, p with the Control Key respectively. In addition, cut-and-past... | [{"input": "hyo\nnh\nEND_OF_TEXT\ne\nd\nf\nf\nk\np\np\ne\ny\na\nk\ny\ny\nn\ny\n-", "output": "hyonhhyonhhyonh\n"}, {"input": "hyn\nnh\nEND_OF_TEXT\ne\nd\nf\nf\nk\np\np\ne\nx\na\nk\ny\ny\nn\ny\n-", "output": "hynnhhynnhhynnh\n"}, {"input": "oyh\nni\nEND_OF_TEXT\nf\nd\nf\nf\nk\np\np\ne\ny\na\nk\ny\ny\nn\ny\n-", "output":... | code_stdio |
[
{
"content": "Santa Claus likes palindromes very much. There was his birthday recently. k of his friends came to him to congratulate him, and each of them presented to him a string s_{i} having the same length n. We denote the beauty of the i-th string by a_{i}. It can happen that a_{i} is negativeΒ β that means... | [{"input": "10 20\njvyxocgomfmrtllgmagp 13\ngvtjnyaofrswcnnifzfq 17\nqisxpseggpjfoijmqnel -5\nlenqmjiofjpggespxsiq 14\nqfzfinncwsrfoaynjtvg 14\ncaayidazlylxyisihdhx 14\npgamglltrmfmogcoxyvj 11\nxhdhisiyxlylzadiyaac 2\ntbirihfpjgbbtclpxwhv 19\nvhwxplctbbgjpfhiribt 10\n", "output": "109\n"}, {"input": "10 20\njvyxocgomfm... | code_stdio |
[
{
"content": "Alice lives on a line. Today, she will travel to some place in a mysterious vehicle.\nInitially, the distance between Alice and her destination is D. When she input a number x to the vehicle, it will travel in the direction of the destination by a distance of x if this move would shorten the dista... | [{"input": "6 15\n4 3 5 4 0 1\n6\n1 2 1 4 4 6", "output": "YES\nYES\nYES\nYES\nYES\nYES\n"}, {"input": "6 15\n4 3 5 4 0 1\n6\n1 2 3 4 5 6", "output": "YES\nYES\nYES\nYES\nNO\nYES\n"}, {"input": "6 15\n4 3 5 8 2 1\n6\n1 3 3 0 5 5", "output": "YES\nYES\nYES\nNO\nYES\nYES\n"}, {"input": "6 15\n4 3 5 4 0 1\n6\n1 2 0 4 4 6"... | code_stdio |
[
{
"content": "Read problems statements in Mandarin Chinese and Russian. \n\nSuraj, the Chief Prankster is back in action now and this time he has stolen the valentine's day gift given by Ashi (the love of Chef) to the Chef and ran away with it to Byteland.\nByteland is a not a regular place like Chef's town. T... | [{"input": "3\n10\n2 1 4 16 2\n0\n12\n2 1 0 8 17\n0\n10\n2 2 2 3 3\n10 2 2 1 4 3 2 9 1 1", "output": "7\n18\n5\n"}, {"input": "3\n10\n2 1 4 16 2\n0\n10\n2 1 0 8 11\n0\n10\n2 2 2 3 4\n10 2 2 1 4 3 2 9 1 0", "output": "7\n12\n6\n"}, {"input": "3\n10\n2 1 1 8 0\n0\n10\n2 0 3 13 7\n0\n10\n2 1 4 3 15\n3 0 2 1 5 5 2 9 1 1", ... | code_stdio |
[
{
"content": "There are n stone quarries in Petrograd.\n\nEach quarry owns mi dumpers (1 β€ i β€ n). It is known that the first dumper of the i-th quarry has xi stones in it, the second dumper has xi + 1 stones in it, the third has xi + 2, and the mi-th dumper (the last for the i-th quarry) has xi + mi - 1 stones... | [{"input": "30\n53 12\n13 98\n21 60\n76 58\n39 5\n62 58\n73 80\n13 75\n37 45\n44 86\n1 85\n13 33\n17 50\n12 26\n97 48\n52 40\n2 71\n95 79\n38 76\n24 54\n91 39\n97 92\n94 80\n50 61\n33 56\n22 91\n39 94\n31 56\n28 16\n20 44\n", "output": "tolik\n"}, {"input": "30\n53 12\n13 98\n21 60\n76 58\n39 5\n62 58\n73 80\n13 75\n37... | code_stdio |
[
{
"content": "You are given an array of integers $a$ of length $n$. The elements of the array can be either different or the same.\n\nEach element of the array is colored either blue or red. There are no unpainted elements in the array. One of the two operations described below can be applied to an array in a s... | [{"input": "8\n4\n1 2 5 2\nBRBR\n2\n1 2\nBB\n5\n3 1 4 2 5\nBRRBR\n5\n4 1 3 1 4\nRBRRB\n5\n5 1 5 1 10\nRBRRA\n4\n2 2 2 2\nBRBR\n2\n1 -3\nBR\n4\n-2 -1 4 0\nRRRR\n", "output": "YES\nYES\nYES\nYES\nNO\nYES\nYES\nYES\n"}, {"input": "8\n4\n1 2 5 2\nBRBR\n2\n1 2\nBB\n5\n3 1 4 2 5\nBRRBR\n5\n4 1 5 1 4\nRBRRB\n5\n5 1 5 1 10\nRB... | code_stdio |
[
{
"content": "D: Arrow / Arrow\n\nproblem\n\nrodea is in a one-dimensional coordinate system and stands at x = 0. From this position, throw an arrow of positive integer length that always moves at speed 1 towards the target at x = N. However, rodea is powerless, so we have decided to put a total of M blowers in... | [{"input": "11 1\n11\n1\n16", "output": "1\n"}, {"input": "11 1\n11\n1\n6", "output": "-1\n"}, {"input": "15 1\n3\n1\n2", "output": "13\n"}, {"input": "15 1\n6\n1\n5", "output": "10\n"}, {"input": "15 1\n3\n1\n3", "output": "12\n"}, {"input": "15 1\n1\n1\n0", "output": "15\n"}, {"input": "15 1\n1\n1\n1", "output": "14\... | code_stdio |
[
{
"content": "Given a set of $N$ axis-aligned rectangles in the plane, find the area of regions which are covered by at least one rectangle.\n\nConstraints\n\n* $ 1 \\leq N \\leq 2000 $\n* $ β10^9 \\leq x1_i < x2_i\\leq 10^9 $\n* $ β10^9 \\leq y1_i < y2_i\\leq 10^9 $\n\nInput\n\nThe input is given in the follow... | [{"input": "4\n0 0 3 1\n-1 0 1 3\n-1 2 4 3\n3 0 3 3", "output": "11\n"}, {"input": "4\n0 0 3 1\n-1 0 1 3\n-1 0 4 3\n2 0 3 2", "output": "15\n"}, {"input": "4\n0 0 3 2\n-1 0 1 3\n-1 0 8 3\n2 0 3 2", "output": "27\n"}, {"input": "4\n0 -1 3 2\n0 2 1 5\n-1 0 0 5\n2 0 3 0", "output": "17\n"}, {"input": "4\n0 0 3 1\n0 0 0 3\... | code_stdio |
[
{
"content": "There are three cells on an infinite 2-dimensional grid, labeled $A$, $B$, and $F$. Find the length of the shortest path from $A$ to $B$ if:\n\nin one move you can go to any of the four adjacent cells sharing a side;\n\nvisiting the cell $F$ is forbidden (it is an obstacle).\n\n\n-----Input-----\n... | [{"input": "7\n\n2 2\n0 3\n-1 2\n\n2 5\n2 2\n0 3\n\n1000 144\n1000 2\n1000 0000\n\n0 2\n3 10\n2 10\n\n0 13\n12 8\n2 10\n\n0 1\n4 1\n1 2\n\n2 413\n0 10\n1 0\n", "output": "3\n3\n142\n11\n17\n4\n405\n"}, {"input": "7\n\n2 2\n1 3\n-1 2\n\n2 5\n2 1\n2 3\n\n1000 144\n1000 1\n1000 0000\n\n0 2\n3 10\n2 10\n\n0 13\n12 8\n2 7\n... | code_stdio |
[
{
"content": "After a team finished their training session on Euro football championship, Valeric was commissioned to gather the balls and sort them into baskets. Overall the stadium has n balls and m baskets. The baskets are positioned in a row from left to right and they are numbered with numbers from 1 to m,... | [{"input": "10894 92356\n", "output": "46178\n46179\n46177\n46180\n46176\n46181\n46175\n46182\n46174\n46183\n46173\n46184\n46172\n46185\n46171\n46186\n46170\n46187\n46169\n46188\n46168\n46189\n46167\n46190\n46166\n46191\n46165\n46192\n46164\n46193\n46163\n46194\n46162\n46195\n46161\n46196\n46160\n46197\n46159\n46198\n4... | code_stdio |
[
{
"content": "You are given a rooted tree with vertices numerated from $1$ to $n$. A tree is a connected graph without cycles. A rooted tree has a special vertex named root.\n\nAncestors of the vertex $i$ are all vertices on the path from the root to the vertex $i$, except the vertex $i$ itself. The parent of t... | [{"input": "8\n2 1\n-1 0\n1 1\n1 1\n1 1\n4 0\n5 1\n7 1\n", "output": "1 3 5 7 8\n"}, {"input": "8\n2 1\n-1 0\n1 1\n1 1\n1 1\n4 0\n5 1\n7 0\n", "output": "1 3 5\n"}, {"input": "8\n2 1\n-1 0\n1 0\n1 1\n2 1\n4 0\n5 1\n7 1\n", "output": "5 7 8\n"}, {"input": "8\n2 0\n-1 0\n1 1\n1 1\n1 1\n4 0\n2 1\n7 0\n", "output": "3 5\n"... | code_stdio |
[
{
"content": "Takahashi has N balls with positive integers written on them. The integer written on the i-th ball is A_i. He would like to form some number of pairs such that the sum of the integers written on each pair of balls is a power of 2. Note that a ball cannot belong to multiple pairs. Find the maximum ... | [{"input": "5\n3 24 14 10 13", "output": "1\n"}, {"input": "5\n3 24 16 10 13", "output": "1\n"}, {"input": "5\n3 36 16 10 13", "output": "1\n"}, {"input": "5\n3 36 16 14 13", "output": "1\n"}, {"input": "5\n3 34 14 10 13", "output": "1\n"}, {"input": "5\n3 24 16 16 13", "output": "2\n"}, {"input": "5\n3 36 18 14 13", "... | code_stdio |
[
{
"content": "This is the easy version of the problem. The only difference is the constraints on $n$ and $k$. You can make hacks only if all versions of the problem are solved.\n\nYou have a string $s$, and you can do two types of operations on it:\n\nDelete the last character of the string.\n\nDuplicate the st... | [{"input": "8 20\nccaccaca\n", "output": "ccaccacaccaccacaccac\n"}, {"input": "8 16\ndbcadabc\n", "output": "dbcadabcdbcadabc\n"}, {"input": "5 10\ndcdcd\n", "output": "dcdcdcdcdc\n"}, {"input": "5 10\ncbcbc\n", "output": "cbcbcbcbcb\n"}, {"input": "4 11\nddcd\n", "output": "ddcddcddcdd\n"}, {"input": "4 11\nzzaz\n", "... | code_stdio |
[
{
"content": "Today Sonya learned about long integers and invited all her friends to share the fun. Sonya has an initially empty multiset with integers. Friends give her t queries, each of one of the following type:\n\n 1. + ai β add non-negative integer ai to the multiset. Note, that she has a multiset, thus... | [{"input": "10\n+ 870566619432760298\n+ 869797178280285214\n+ 609920823721618090\n+ 221159591436767023\n+ 730599542279836538\n? 101001100111001011\n? 001111010101010011\n? 100010100011101110\n? 100110010110001100\n? 110000011101110011\n", "output": "0\n0\n0\n0\n0\n"}, {"input": "10\n+ 870566619432760298\n+ 869797178280... | code_stdio |
[
{
"content": "The objective is to disambiguate two given names: the original with another\n\nThis kata is slightly more evolved than the previous one: [Author Disambiguation: to the point!](https://www.codewars.com/kata/580a429e1cb4028481000019).\n\nThe function ```could_be``` is still given the original name a... | [{"input": "\"Carlos Ray Norris\"\n\"Carlos. Ray; Norris,\"", "output": "[true]", "fn_name": "could_be"}, {"input": "\"Carlos-Ray Norris\"\n\"Carlos-Ray Norris:\"", "output": "[true]", "fn_name": "could_be"}, {"input": "\"Carlos Ray-Norris\"\n\"Carlos? Ray-Norris\"", "output": "[true]", "fn_name": "could_be"}, {"input"... | code_functional |
[
{
"content": "In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures.\nCity i is established in year Y_i and belongs to Prefecture P_i.\nYou can assume that there are no multiple cities that are established in the same year.\nIt is decided to allocate a 12-digi... | [{"input": "75634 912\n18125 601244640\n58230 951349939\n4017 753730550\n23636 124912128\n45120 23758881\n51811 316477853\n19326 139861106\n48018 406348942\n68864 391719264\n1850 712458521\n2796 385027567\n12731 564315721\n43367 828330253\n30104 102450015\n64351 340641907\n19781 414658282\n53502 122572188\n11063 262174... | code_stdio |
[
{
"content": "Prof. Hachioji has devised a new numeral system of integral numbers with four lowercase letters \"m\", \"c\", \"x\", \"i\" and with eight digits \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\". He doesn't use digit \"0\" nor digit \"1\" in this system.\n\nThe letters \"m\", \"c\", \"x\" and... | [{"input": "10\nxi x8i\ni 9i\nc2x2i 5c9x8i\nm2ci 4m7c9x8i\n8c9x8i i\ni 9m9c9x8i\nm i\ni m\nm9i i\n8m9c7xi c1x8i", "output": "2x9i\nx\n7c2x\n5m9c9x9i\n8c9x9i\n9m9c9x9i\nmi\nmi\nmx\n9m8x9i\n"}, {"input": "10\nxi x8i\ni 9i\nc2x3i 5c8x8i\nm2ci 4m7c9x8i\n9c8x9i i\ni 9m9c9x8i\nm i\ni m\nm9i i\n9m8c7xi c2x8i", "output": "2x9i... | code_stdio |
[
{
"content": "Problem statement\n\nThere are rectangles with vertical and horizontal lengths of h and w, and square squares with a side length of 1 are spread inside. If the upper left cell is (0,0) and the cell to the right of j below (0,0) is represented as (i, j), (i, j) is i + j. If is even, it is painted r... | [{"input": "3\n1 11\n5 11\n4 5", "output": "6 5\n28 27\n1 1\n"}, {"input": "3\n1 11\n5 11\n3 5", "output": "6 5\n28 27\n8 7\n"}, {"input": "3\n2 11\n5 11\n3 5", "output": "1 1\n28 27\n8 7\n"}, {"input": "3\n3 12\n13 7\n1 4", "output": "1 1\n46 45\n1 1\n"}, {"input": "3\n1 8\n3 11\n4 3", "output": "1 1\n17 16\n1 1\n"}, ... | code_stdio |
[
{
"content": "Let's solve the geometric problem\n\nMr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems.\n\nFloating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal nu... | [{"input": "128 205", "output": "205\n"}, {"input": "110 161", "output": "161\n"}, {"input": "13 204", "output": "102\n"}, {"input": "11 251", "output": "251\n"}, {"input": "10 103", "output": "103\n"}, {"input": "23 217", "output": "217\n"}, {"input": "23 193", "output": "193\n"}, {"input": "21 440", "output": "110\n"... | code_stdio |
[
{
"content": "You have a long fence which consists of $n$ sections. Unfortunately, it is not painted, so you decided to hire $q$ painters to paint it. $i$-th painter will paint all sections $x$ such that $l_i \\le x \\le r_i$.\n\nUnfortunately, you are on a tight budget, so you may hire only $q - 2$ painters. O... | [{"input": "48 47\n34 44\n24 45\n21 36\n29 38\n17 29\n20 29\n30 32\n23 40\n47 48\n36 43\n2 37\n27 42\n11 17\n26 47\n4 16\n24 35\n32 47\n8 22\n28 46\n17 26\n36 43\n1 26\n26 40\n26 47\n5 38\n20 33\n6 27\n9 33\n2 7\n17 35\n12 18\n20 36\n20 43\n22 45\n13 44\n3 7\n1 33\n7 45\n20 36\n33 41\n10 11\n29 35\n17 21\n10 24\n39 41\... | code_stdio |
[
{
"content": "Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. \nAfter a long time, Chef has finally decided to renovate his house. Chef's house has N rooms in it numbered from 1 to N. Each room is currently painted in one of the red, blue or green colors. Your are given configurati... | [{"input": "3\n3\nRGR\n3\nRRR\n3\nGRB", "output": "1\n0\n2\n"}, {"input": "3\n3\nGRR\n3\nRRR\n3\nGRB", "output": "1\n0\n2\n"}, {"input": "3\n3\nRGR\n3\nRRR\n3\nRBG", "output": "1\n0\n2\n"}, {"input": "3\n3\nGRR\n3\nRRR\n3\nBRG", "output": "1\n0\n2\n"}, {"input": "3\n3\nRRG\n3\nRRR\n3\nRGB", "output": "1\n0\n2\n"}, {"in... | code_stdio |
[
{
"content": "There are league games and tournament games in sports competitions. In soccer league games, points are given to each of the wins, losses, and draws, and the rankings are competed based on the points. The points are win (3 points), negative (0 points), and draw (1 point), respectively.\n\nEnter the... | [{"input": "4\nJapan 1 0 2\nEgypt 1 3 -1\nCanada 0 2 1\nSpain 1 0 1\n3\nJndia -1 2 0\nPoland 1 1 1\nItalx 1 -1 1\n0", "output": "Japan,5\nSpain,4\nEgypt,2\nCanada,1\n\nPoland,4\nItalx,4\nJndia,-3\n"}, {"input": "4\nnapaJ 1 0 0\nEgzpt 0 2 -1\naDaadn 0 2 3\nnibpS 2 0 0\n3\nioIda 0 0 -6\nPoland 1 0 3\nItaly 2 0 1\n0", "ou... | code_stdio |
[
{
"content": "problem\n\nAOR Ika and you came to the tournament-style table tennis tournament singles section for reconnaissance. For AOR Ika-chan, who wants to record all the games, you decide to ask for the number of games that will be played in this tournament.\n\nThere are $ N $ players in the tournament, e... | [{"input": "66 -51", "output": "116\n"}, {"input": "66 -87", "output": "152\n"}, {"input": "66 -49", "output": "114\n"}, {"input": "96 -49", "output": "144\n"}, {"input": "96 -45", "output": "140\n"}, {"input": "96 -10", "output": "105\n"}, {"input": "96 -13", "output": "108\n"}, {"input": "96 -11", "output": "106\n"},... | code_stdio |
[
{
"content": "Ryouko is an extremely forgetful girl, she could even forget something that has just happened. So in order to remember, she takes a notebook with her, called Ryouko's Memory Note. She writes what she sees and what she hears on the notebook, and the notebook became her memory.\n\nThough Ryouko is f... | [{"input": "100 100\n28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28... | code_stdio |
[
{
"content": "There are N apple trees in a row. People say that one of them will bear golden apples.\nWe want to deploy some number of inspectors so that each of these trees will be inspected.\nEach inspector will be deployed under one of the trees. For convenience, we will assign numbers from 1 through N to th... | [{"input": "14 3\n", "output": "2\n"}, {"input": "20 4\n", "output": "3\n"}, {"input": "15 2\n", "output": "3\n"}, {"input": "20 2\n", "output": "4\n"}, {"input": "17 8\n", "output": "1\n"}, {"input": "15 3\n", "output": "3\n"}, {"input": "17 4\n", "output": "2\n"}, {"input": "20 1\n", "output": "7\n"}, {"input": "1 20... | code_stdio |
[
{
"content": "The Romans have attacked again. This time they are much more than the Persians but Shapur is ready to defeat them. He says: \"A lion is never afraid of a hundred sheep\". \n\nNevertheless Shapur has to find weaknesses in the Roman army to defeat them. So he gives the army a weakness number.\n\nIn ... | [{"input": "97\n800 771 66 126 231 306 981 96 196 229 253 35 903 739 461 962 979 347 152 424 934 586 225 838 103 178 524 400 156 149 560 629 697 417 717 738 181 430 611 513 754 595 847 464 356 640 24 854 138 481 98 371 142 460 194 288 220 41 999 581 441 407 301 651 271 226 457 393 980 166 272 250 900 337 358 359 80 904... | code_stdio |
[
{
"content": "This is a very simply formulated task. Let's call an integer number `N` 'green' if `NΒ²` ends with all of the digits of `N`. Some examples:\n\n`5` is green, because `5Β² = 25` and `25` ends with `5`.\n\n`11` is not green, because `11Β² = 121` and `121` does not end with `11`.\n\n`376` is green, becau... | [{"input": "110", "output": "[9580863811000557423423230896109004106619977392256259918212890625]", "fn_name": "green"}, {"input": "100", "output": "[6188999442576576769103890995893380022607743740081787109376]", "fn_name": "green"}, {"input": "12", "output": "[2890625]", "fn_name": "green"}, {"input": "13", "output": "[7... | code_functional |
[
{
"content": "There are n students who have taken part in an olympiad. Now it's time to award the students.\n\nSome of them will receive diplomas, some wiil get certificates, and others won't receive anything. Students with diplomas and certificates are called winners. But there are some rules of counting the n... | [{"input": "2106623580587 109123020071\n", "output": "9 982107180639 1124516399939 "}, {"input": "1000000000000 499999999999\n", "output": "1 499999999999 500000000000\n"}, {"input": "1000000000000 1000\n", "output": "499500499 499500499000 500000000501\n"}, {"input": "1000000000000 32416187567\n", "output": "15 486242... | code_stdio |
[
{
"content": "Write a program which reads a list of student test scores and evaluates the performance for each student.\n\nThe test scores for a student include scores of the midterm examination m (out of 50), the final examination f (out of 50) and the makeup examination r (out of 100). If the student does not... | [{"input": "92 101 -1\n16 30 -1\n0 2 -1\n-1 -1 -1", "output": "A\nD\nF\n"}, {"input": "150 64 -2\n16 30 -1\n1 0 -1\n-1 -1 -1", "output": "A\nD\nF\n"}, {"input": "116 100 -1\n16 50 -1\n1 1 0\n-1 -1 -1", "output": "A\nB\nF\n"}, {"input": "92 111 -1\n16 30 -1\n0 2 -1\n-1 -1 -1", "output": "A\nD\nF\n"}, {"input": "150 64 -... | code_stdio |
[
{
"content": "The description is rather long but it tries to explain what a financing plan is. \n\nThe fixed monthly payment for a fixed rate mortgage is the amount paid by the borrower every month that ensures \nthat the loan is paid off in full with interest at the end of its term. \n\nThe monthly payment for... | [{"input": "9.0\n187174\n60\n12", "output": "[\"num_payment 12 c 3885 princ 2694 int 1191 balance 156135\"]", "fn_name": "amort"}, {"input": "1.9\n182840\n48\n18", "output": "[\"num_payment 18 c 3959 princ 3769 int 189 balance 115897\"]", "fn_name": "amort"}, {"input": "7.0\n168742\n48\n16", "output": "[\"num_payment 1... | code_functional |
[
{
"content": "PolandBall has such a convex polygon with n veritces that no three of its diagonals intersect at the same point. PolandBall decided to improve it and draw some red segments. \n\nHe chose a number k such that gcd(n, k) = 1. Vertices of the polygon are numbered from 1 to n in a clockwise way. Poland... | [{"input": "2633 717\n", "output": "2 3 4 6 9 12 15 19 24 29 34 40 47 54 62 71 80 89 99 110 121 132 144 157 170 184 199 214 229 245 262 279 296 314 333 352 372 393 414 435 457 480 503 526 550 575 600 626 653 680 707 735 764 793 822 852 883 914 946 979 1012 1045 1079 1114 1149 1184 1220 1257 1294 1332 1371 1410 1449 148... | code_stdio |
[
{
"content": "Chef loves games! But he likes to invent his own. Now he plays game \"Digit Jump\". Chef has a sequence of digits $S_{1}, S_{2}, \\ldots , S_{N}$. He is staying in the first digit $S_{1}$ and wants to reach the last digit $S_{N}$ in the minimal number of jumps. \nWhile staying in some index $i$ Ch... | [{"input": "012134444444443", "output": "4\n"}, {"input": "20776892991725", "output": "2\n"}, {"input": "10353326888495", "output": "4\n"}, {"input": "14708953637626", "output": "5\n"}, {"input": "6858574858270", "output": "5\n"}, {"input": "2595212919780", "output": "6\n"}, {"input": "1149262658611", "output": "1\n"},... | code_stdio |
[
{
"content": "A sequence a_1,a_2,... ,a_n is said to be /\\/\\/\\/ when the following conditions are satisfied:\n - For each i = 1,2,..., n-2, a_i = a_{i+2}.\n - Exactly two different numbers appear in the sequence.\nYou are given a sequence v_1,v_2,...,v_n whose length is even.\nWe would like to make this sequ... | [{"input": "34\n84822 84822 84822 84822 84822 84822 84822 84822 84822 84822 84822 84822 84822 84822 84822 84822 84822 84822 84822 84822 84822 84822 84822 84822 84822 84822 84822 84822 84822 84822 84822 84822 84822 84822\n", "output": "17\n"}, {"input": "6\n105 119 105 119 105 119\n", "output": "0\n"}, {"input": "4\n3 1... | code_stdio |
[
{
"content": "Polycarp has n different binary words. A word called binary if it contains only characters '0' and '1'. For example, these words are binary: \"0001\", \"11\", \"0\" and \"0011100\".\n\nPolycarp wants to offer his set of n binary words to play a game \"words\". In this game, players name words and ... | [{"input": "4\n4\n0001\n1000\n0011\n0111\n3\n010\n111\n0\n2\n00000\n00001\n4\n01\n001\n0001\n00001\n", "output": "1\n3\n-1\n0\n\n2\n1 2\n"}, {"input": "4\n4\n0001\n0000\n0011\n0111\n3\n010\n111\n1\n2\n00000\n00001\n4\n01\n001\n0001\n00001\n", "output": "1\n1\n-1\n0\n\n2\n1 2\n"}, {"input": "4\n4\n0001\n0000\n0011\n0111... | code_stdio |
[
{
"content": "## Number pyramid\n\nNumber pyramid is a recursive structure where each next row is constructed by adding adjacent values of the current row. For example:\n\n```\nRow 1 [1 2 3 4]\nRow 2 [3 5 7]\nRow 3 [8 12]\nRow 4 [20]\n```\n\n___\n\n## Task... | [{"input": "[13, 76, 21, 42, 63]", "output": "[674]", "fn_name": "reduce_pyramid"}, {"input": "[13, 1, 21, 9]", "output": "[88]", "fn_name": "reduce_pyramid"}, {"input": "[5, 6, 7, 8]", "output": "[52]", "fn_name": "reduce_pyramid"}, {"input": "[3, 9, 4]", "output": "[25]", "fn_name": "reduce_pyramid"}, {"input": "[3, ... | code_functional |
[
{
"content": "Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down.\n\nThere is a cursor pointing at some symbol of th... | [{"input": "198 10\ntuxqalctjyegbvouezfiqoeoazizhmjhpcmvyvjkyrgxkeupwcmvzcosdrrfgtdmxwfttxjxsbaspjwftgpnvsfyfqsrmyjmypdwonbzwsftepwtjlgbilhcsqyfzfzrfvrvfqiwoemthwvqpvqnflqqspvqrnmvucnspexpijnivqpavqxjyucufculletaedlvut\n", "output": "695\n"}, {"input": "198 14\ntuxqalctjyegbvouezfiqoeoazizhmjhpcmvyvjkyrgxkeupwcmvzcosdr... | code_stdio |
[
{
"content": "You are both a shop keeper and a shop assistant at a small nearby shop. You have $n$ goods, the $i$-th good costs $a_i$ coins.\n\nYou got tired of remembering the price of each product when customers ask for it, thus you decided to simplify your life. More precisely you decided to set the same pri... | [{"input": "3\n5\n1 2 6 4 5\n3\n1 2 3\n2\n777 2131\n", "output": "4\n2\n1454\n"}, {"input": "3\n5\n1 2 3 4 5\n3\n1 2 3\n2\n777 1089\n", "output": "3\n2\n933\n"}, {"input": "3\n5\n1 2 6 4 5\n3\n1 2 3\n2\n777 1089\n", "output": "4\n2\n933\n"}, {"input": "3\n5\n0 3 3 16 5\n3\n2 2 3\n2\n777 778\n", "output": "6\n3\n778\n"}... | code_stdio |
[
{
"content": "One day, Snuke was given a permutation of length N, a_1, a_2, ..., a_N, from his friend.\n\nFind the following:\n\n<image>\n\nConstraints\n\n* 1 β¦ N β¦ 200,000\n* (a_1, a_2, ..., a_N) is a permutation of (1, 2, ..., N).\n\nInput\n\nThe input is given from Standard Input in the following format:\n\n... | [{"input": "8\n5 3 8 1 2 6 7 4", "output": "84\n"}, {"input": "8\n4 5 8 1 2 6 7 3", "output": "86\n"}, {"input": "8\n5 4 8 1 2 6 7 3", "output": "85"}, {"input": "4\n2 3 1 4", "output": "17\n"}, {"input": "4\n1 3 4 2", "output": "20\n"}, {"input": "4\n3 2 4 1", "output": "19\n"}, {"input": "4\n2 3 4 1", "output": "20\n... | code_stdio |
[
{
"content": "You are given an integer N. Among the divisors of N! (= 1 \\times 2 \\times ... \\times N), how many Shichi-Go numbers (literally \"Seven-Five numbers\") are there?\nHere, a Shichi-Go number is a positive integer that has exactly 75 divisors.\n\n-----Note-----\nWhen a positive integer A divides a ... | [{"input": "100\n", "output": "543\n"}, {"input": "52\n", "output": "123\n"}, {"input": "54\n", "output": "131\n"}, {"input": "77\n", "output": "323\n"}, {"input": "78\n", "output": "324\n"}, {"input": "90\n", "output": "384\n"}, {"input": "91\n", "output": "391\n"}, {"input": "92\n", "output": "491\n"}, {"input": "94\... | code_stdio |
[
{
"content": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two ... | [{"input": "200\n2 1 1 2 2 2 2 1 1 2 2 2 1 1 2 2 2 2 1 1 1 2 2 2 2 2 2 1 2 2 1 1 1 1 2 1 2 2 1 2 2 2 2 1 2 2 1 1 1 1 2 2 1 1 1 1 1 2 2 2 2 1 2 1 2 2 2 2 1 1 1 2 1 2 2 2 2 1 1 1 1 1 1 2 2 2 1 2 2 2 1 2 2 2 1 1 1 2 2 1 1 1 1 2 2 1 2 1 1 1 2 2 1 1 2 2 2 1 2 2 0 1 2 1 1 2 2 2 1 2 2 1 1 1 2 2 2 1 2 1 2 1 2 1 1 2 2 1 1 1 1 1... | code_stdio |
[
{
"content": "You are given two lists of non-zero digits.\n\nLet's call an integer pretty if its (base 10) representation has at least one digit from the first list and at least one digit from the second list. What is the smallest positive pretty integer?\n\n\n-----Input-----\n\nThe first line contains two inte... | [{"input": "9 9\n5 4 3 2 1 6 7 8 9\n3 2 1 5 4 7 8 9 6\n", "output": "1\n"}, {"input": "9 9\n1 2 3 4 5 6 7 8 9\n1 2 3 4 5 6 7 8 9\n", "output": "1\n"}, {"input": "9 9\n1 2 3 4 5 6 7 8 9\n9 8 7 6 5 4 3 2 1\n", "output": "1\n"}, {"input": "9 9\n9 8 7 6 5 4 3 2 1\n1 2 3 4 5 6 7 8 9\n", "output": "1\n"}, {"input": "9 9\n9 8... | code_stdio |
[
{
"content": "Polycarp is a frequent user of the very popular messenger. He's chatting with his friends all the time. He has $n$ friends, numbered from $1$ to $n$.\n\nRecall that a permutation of size $n$ is an array of size $n$ such that each integer from $1$ to $n$ occurs exactly once in this array.\n\nSo his... | [{"input": "100 100\n82 51 81 14 37 17 78 92 64 15 8 86 89 8 87 77 66 10 15 12 100 25 92 47 21 78 20 63 13 49 41 36 41 79 16 87 87 69 1 76 80 60 100 49 70 59 72 8 38 71 15 97 71 14 76 90 81 4 59 46 39 28 92 3 28 22 53 99 59 52 74 43 92 43 42 23 44 9 82 47 7 48 12 12 3 55 37 71 46 22 84 52 98 41 21 77 63 17 62 91\n", "o... | code_stdio |
[
{
"content": "Snuke has a blackboard and a set S consisting of N integers. The i-th element in S is S_i.\n\nHe wrote an integer X on the blackboard, then performed the following operation N times:\n\n* Choose one element from S and remove it.\n* Let x be the number written on the blackboard now, and y be the in... | [{"input": "10 100000\n13715 50001 13306 50003 50004 59986 50006 110740 62164 36071", "output": "491699060\n"}, {"input": "10 100000\n13715 50001 13306 50003 50004 59986 50006 110740 62439 36071", "output": "380819060\n"}, {"input": "10 100000\n13715 50001 13306 50003 50004 59986 50006 110740 49261 36071", "output": "6... | code_stdio |
[
{
"content": "An architect, Devunky, who lives in Water Deven, has been asked to renovate an old large hospital.\n\nIn some countries, people don't want to use numbers that are disliked as numerophobia (4 and 9 are famous in Japan). However, the room numbers in this hospital were numbered from 1 regardless of t... | [{"input": "15\n100\n1000000000\n1\n0", "output": "19\n155\n9358757000\n1\n"}, {"input": "15\n110\n1000000000\n1\n0", "output": "19\n178\n9358757000\n1\n"}, {"input": "15\n101\n1000000000\n3\n0", "output": "19\n157\n9358757000\n3\n"}, {"input": "15\n101\n1001000000\n3\n0", "output": "19\n157\n9372508100\n3\n"}, {"input... | code_stdio |
[
{
"content": "Jzzhu has a big rectangular chocolate bar that consists of n Γ m unit squares. He wants to cut this bar exactly k times. Each cut must meet the following requirements:\n\n * each cut should be straight (horizontal or vertical); \n * each cut should go along edges of unit squares (it is prohibite... | [{"input": "1000000000 1000000000 999999999\n", "output": "1000000000\n"}, {"input": "1000000000 1000000000 220000000\n", "output": "4000000000\n"}, {"input": "1000000000 1000000000 123456\n", "output": "8099000000000\n"}, {"input": "1000000000 1000000000 1\n", "output": "500000000000000000\n"}, {"input": "1000000000 1... | code_stdio |
[
{
"content": "Dark is going to attend Motarack's birthday. Dark decided that the gift he is going to give to Motarack is an array $a$ of $n$ non-negative integers.\n\nDark created that array $1000$ years ago, so some elements in that array disappeared. Dark knows that Motarack hates to see an array that has two... | [{"input": "7\n5\n-1 3 -1 24 -1\n5\n-1 40 14 -1 35\n6\n-1 -1 6 -1 0 -1\n2\n-1 -1\n2\n0 -1\n4\n1 -1 3 -1\n7\n1 -1 7 10 0 0 10\n", "output": "11 13\n26 27\n3 3\n0 0\n0 0\n1 2\n10 4\n"}, {"input": "7\n5\n-1 10 -1 20 -1\n5\n-1 22 35 -1 35\n6\n-1 -1 9 -1 3 -1\n2\n-1 -1\n2\n0 -1\n4\n1 -1 3 -1\n7\n0 -1 12 5 2 -1 0\n", "output... | code_stdio |
[
{
"content": "Chef has a binary tree. The binary tree consists of 1 or more nodes. Each node has a unique integer id. Each node has up to 2 children, which are identified by their ids, and each node is the child of at most 1 other node. A node X is considered to be an ancestor of node Y if node Y is a child of ... | [{"input": "2\n1\n10 0\n6\n1 5\n2 0\n3 0\n4 0\n5 5\n10 5", "output": "10\n10\n"}, {"input": "2\n1\n4 0\n6\n1 11\n2 0\n4 0\n8 -1\n5 5\n-1 5", "output": "4\n-1\n"}, {"input": "2\n1\n4 0\n6\n1 11\n2 0\n4 0\n8 -1\n5 5\n-2 5", "output": "4\n-2\n"}, {"input": "2\n1\n16 0\n6\n-1 8\n1 1\n3 0\n7 0\n0 3\n6 5", "output": "16\n-1\... | code_stdio |
[
{
"content": "AtCoDeer the deer is going on a trip in a two-dimensional plane.\nIn his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i.\nIf AtCoDeer is at point (x, y) at time t, he can be at one of the following points at ... | [{"input": "2\n-3 4 1\n111 4 -1", "output": "No\n"}, {"input": "2\n5 1 1\n100 1 1\n", "output": "No\n"}, {"input": "2\n5 2 3\n100 0 0", "output": "Yes\n"}, {"input": "2\n5 2 2\n100 1 -1", "output": "No\n"}, {"input": "2\n5 2 1\n111 1 0", "output": "Yes\n"}, {"input": "2\n2 1 1\n100 1 1", "output": "Yes\n"}, {"input": "... | code_stdio |
[
{
"content": "Each of you probably has your personal experience of riding public transportation and buying tickets. After a person buys a ticket (which traditionally has an even number of digits), he usually checks whether the ticket is lucky. Let us remind you that a ticket is lucky if the sum of digits in its... | [{"input": "100\n11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111112222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222\n", "output": "YES\n"}, {"input": "100\n77183123282838517843664381789267288922656323541699343586762218... | code_stdio |
[
{
"content": "Mr. Chanek is currently participating in a science fair that is popular in town. He finds an exciting puzzle in the fair and wants to solve it.\n\nThere are $N$ atoms numbered from $1$ to $N$. These atoms are especially quirky. Initially, each atom is in normal state. Each atom can be in an excite... | [{"input": "6 1\n1 10 10 5 20 100\n1000000 1 10 10 100 1000000\n", "output": "144\n"}, {"input": "6 1\n1 10 10 20 5 100\n1000000 1 10 100 10 1000000\n", "output": "144\n"}, {"input": "6 1\n1 10 10 5 20 100\n1000000 1 10 10 100 1000000\n", "output": "144\n"}, {"input": "6 1\n1 10 10 20 5 100\n1000000 1 10 100 10 1000000... | code_stdio |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.