messages listlengths 1 1 | ground_truth stringlengths 156 726k | dataset stringclasses 1
value |
|---|---|---|
[
{
"content": "This is the easy version of the problem. The only difference is that in this version q = 1. You can make hacks only if both versions of the problem are solved.\n\nThere is a process that takes place on arrays a and b of length n and length n-1 respectively. \n\nThe process is an infinite sequence ... | [{"input": "100\n45 21 34 56 15 0 46 59 40 39 78 83 29 77 19 30 60 39 90 64 11 47 10 47 35 79 30 13 21 31 26 68 0 67 52 43 29 94 100 76 16 61 74 34 62 63 4 41 78 31 77 21 90 2 43 70 53 15 53 29 47 87 33 20 23 30 55 57 13 25 19 89 10 17 92 24 47 6 4 91 52 9 11 25 81 14 82 75 46 49 66 62 28 84 88 101 0 19 34 94\n0 0 0 0 ... | code_stdio |
[
{
"content": "Polycarp must pay exactly $n$ burles at the checkout. He has coins of two nominal values: $1$ burle and $2$ burles. Polycarp likes both kinds of coins equally. So he doesn't want to pay with more coins of one type than with the other.\n\nThus, Polycarp wants to minimize the difference between the ... | [{"input": "6\n1001\n42\n0\n131\n1000101010\n12\n", "output": "333 334\n14 14\n0 0\n43 44\n333367004 333367003\n4 4\n"}, {"input": "6\n1001\n42\n0\n131\n1000101010\n0\n", "output": "333 334\n14 14\n0 0\n43 44\n333367004 333367003\n0 0\n"}, {"input": "6\n1000\n30\n1\n32\n1000000000\n5\n", "output": "334 333\n10 10\n1 0\... | code_stdio |
[
{
"content": "Gaius Julius Caesar, a famous general, loved to line up his soldiers. Overall the army had n1 footmen and n2 horsemen. Caesar thought that an arrangement is not beautiful if somewhere in the line there are strictly more that k1 footmen standing successively one after another, or there are strictly... | [{"input": "100 99 10 10\n", "output": "65210983\n"}, {"input": "100 100 9 10\n", "output": "67740290\n"}, {"input": "99 100 10 10\n", "output": "65210983\n"}, {"input": "100 100 10 10\n", "output": "950492\n"}, {"input": "100 99 10 4\n", "output": "41571840\n"}, {"input": "78 21 10 1\n", "output": "96098560\n"}, {"inp... | code_stdio |
[
{
"content": "You have been blessed as a child of Omkar. To express your gratitude, please solve this problem for Omkar!\n\nAn array a of length n is called complete if all elements are positive and don't exceed 1000, and for all indices x,y,z (1 ≤ x,y,z ≤ n), a_{x}+a_{y} ≠ a_{z} (not necessarily distinct).\n\n... | [{"input": "2\n1412\n721\n", "output": "1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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": "Vova decided to clean his room. The room can be represented as the coordinate axis $OX$. There are $n$ piles of trash in the room, coordinate of the $i$-th pile is the integer $p_i$. All piles have different coordinates.\n\nLet's define a total cleanup as the following process. The goal of this pr... | [{"input": "5 8\n5 1 2 4 3\n0 1\n0 2\n0 3\n0 4\n0 5\n1 1000000000\n1 1\n1 500000000\n", "output": "3\n2\n1\n0\n0\n0\n0\n0\n499999999\n"}, {"input": "5 8\n5 1 2 4 3\n0 1\n0 2\n0 3\n0 4\n0 5\n1 1000000000\n1 1\n1 500000000\n", "output": "3\n2\n1\n0\n0\n0\n0\n0\n499999999\n"}, {"input": "5 4\n5 1 2 4 3\n0 1\n0 2\n0 3\n0 4... | code_stdio |
[
{
"content": "You are a coach of a group consisting of $n$ students. The $i$-th student has programming skill $a_i$. All students have distinct programming skills. You want to divide them into teams in such a way that: No two students $i$ and $j$ such that $|a_i - a_j| = 1$ belong to the same team (i.e. skills... | [{"input": "10\n5\n3 4 1 5 2\n2\n2 1\n4\n4 1 3 2\n5\n2 3 1 5 4\n2\n1 2\n4\n1 2 3 4\n2\n1 2\n4\n3 4 2 1\n3\n3 2 1\n1\n1\n", "output": "2\n2\n2\n2\n2\n2\n2\n2\n2\n1\n"}, {"input": "10\n5\n3 4 1 5 2\n2\n2 1\n4\n4 1 3 2\n5\n2 3 1 5 4\n2\n1 2\n4\n1 2 3 4\n2\n1 2\n4\n3 4 2 1\n3\n3 2 1\n1\n1\n", "output": "2\n2\n2\n2\n2\n2\n2... | code_stdio |
[
{
"content": "This is an easier version of the next problem. In this version, $q = 0$.\n\nA sequence of integers is called nice if its elements are arranged in blocks like in $[3, 3, 3, 4, 1, 1]$. Formally, if two elements are equal, everything in between must also be equal.\n\nLet's define difficulty of a sequ... | [{"input": "100 0\n6 7 100 8 5 61 5 75 59 65 51 47 83 37 34 54 87 46 4 26 21 87 12 97 86 68 60 11 62 76 14 83 29 31 91 62 57 80 47 75 85 97 62 77 91 86 14 25 48 77 83 65 39 61 78 77 45 46 90 74 100 91 86 98 55 5 84 42 91 69 100 4 74 98 60 37 75 44 41 12 15 34 36 1 99 16 7 87 36 26 79 42 41 84 17 98 72 16 38 55\n", "out... | code_stdio |
[
{
"content": "Vasya likes taking part in Codeforces contests. When a round is over, Vasya follows all submissions in the system testing tab.\n\nThere are $n$ solutions, the $i$-th of them should be tested on $a_i$ tests, testing one solution on one test takes $1$ second. The solutions are judged in the order fr... | [{"input": "100 10\n3 114 77 78 105 87 6 122 141 100 75 118 64 18 88 37 109 72 31 101 36 10 62 18 52 17 149 115 22 150 138 48 46 42 104 8 63 21 117 58 87 80 7 131 125 118 67 13 144 43 59 67 74 13 124 77 86 148 107 11 51 9 87 52 147 22 7 22 143 12 121 123 17 35 33 87 91 140 92 38 106 10 66 26 40 100 121 42 134 127 116 1... | code_stdio |
[
{
"content": "The game of Berland poker is played with a deck of $n$ cards, $m$ of which are jokers. $k$ players play this game ($n$ is divisible by $k$).\n\nAt the beginning of the game, each player takes $\\frac{n}{k}$ cards from the deck (so each card is taken by exactly one player). The player who has the m... | [{"input": "4\n8 3 2\n4 2 4\n12 6 3\n42 0 7\n", "output": "3\n0\n3\n0\n"}, {"input": "4\n12 3 2\n4 2 4\n9 6 3\n42 0 7\n", "output": "3\n0\n1\n0\n"}, {"input": "4\n8 1 2\n4 2 4\n12 6 3\n66 0 7\n", "output": "1\n0\n3\n0\n"}, {"input": "4\n8 5 2\n4 2 4\n12 11 3\n7 0 9\n", "output": "3\n0\n0\n0\n"}, {"input": "4\n8 3 2\n4 ... | code_stdio |
[
{
"content": "Jou and Yae are a good couple. Jou is collecting prizes for capsule toy vending machines (Gachapon), and even when they go out together, when they find Gachapon, they seem to get so hot that they try it several times. Yae was just looking at Jou, who looked happy, but decided to give him a Gachapo... | [{"input": "2\n1 0\n3\n1 1 0\n1\n0000\n0", "output": "NA\nNA\nNA\n"}, {"input": "2\n3 2\n3\n0 1 1\n1\n0000\n0", "output": "3\nNA\nNA\n"}, {"input": "2\n1 0\n3\n0 1 1\n1\n1000\n0", "output": "NA\nNA\n2\n"}, {"input": "2\n1 0\n3\n0 4 0\n1\n0000\n0", "output": "NA\n2\nNA\n"}, {"input": "2\n1 0\n3\n2 1 0\n1\n0000\n0", "out... | code_stdio |
[
{
"content": "There is a long plate s containing n digits. Iahub wants to delete some digits (possibly none, but he is not allowed to delete all the digits) to form his \"magic number\" on the plate, a number that is divisible by 5. Note that, the resulting number may contain leading zeros.\n\nNow Iahub wants t... | [{"input": "27755776656210607832788619414635535178188775623838313967013958143619017005079991285469853503718562504927535176713879737569375166451462839457844835806559098448980069427607\n151\n", "output": "319271478\n"}, {"input": "2775577665621060783278861941463553517818877562383831396701395814361901700507999128546985350... | code_stdio |
[
{
"content": "One day, Chef prepared D brand new dishes. He named the i-th dish by a string Si. After the cooking, he decided to categorize each of these D dishes as special or not.\n\nA dish Si is called special if it's name (i.e. the string Si) can be represented in the form of a double string by removing at ... | [{"input": "3\ncdd\n_a_a\n_ed[", "output": "YES\nYES\nNO\n"}, {"input": "3\naba\nabac\naacd", "output": "YES\nNO\nNO\n"}, {"input": "3\nfda\n`a`a\nb`Ze", "output": "NO\nYES\nNO\n"}, {"input": "3\naba\nabac\ndaca", "output": "YES\nNO\nNO\n"}, {"input": "3\naba\nabac\ndaac", "output": "YES\nNO\nNO\n"}, {"input": "3\naba\... | code_stdio |
[
{
"content": "A sequence of square brackets is regular if by inserting symbols \"+\" and \"1\" into it, you can get a regular mathematical expression from it. For example, sequences \"[[]][]\", \"[]\" and \"[[][[]]]\" — are regular, at the same time \"][\", \"[[]\" and \"[[]]][\" — are irregular. \n\nDraw the g... | [{"input": "100\n[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]\n", "output": "+- -+\n|+- ... | code_stdio |
[
{
"content": "Given is a string S consisting of L and R.\nLet N be the length of S. There are N squares arranged from left to right, and the i-th character of S from the left is written on the i-th square from the left.\nThe character written on the leftmost square is always R, and the character written on the ... | [{"input": "RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR... | code_stdio |
[
{
"content": "In a building where Polycarp lives there are equal number of flats on each floor. Unfortunately, Polycarp don't remember how many flats are on each floor, but he remembers that the flats are numbered from 1 from lower to upper floors. That is, the first several flats are on the first floor, the ne... | [{"input": "50 70\n3 3\n80 80\n23 23\n11 11\n87 87\n7 7\n63 63\n61 61\n67 67\n53 53\n9 9\n43 43\n55 55\n27 27\n5 5\n1 1\n99 99\n65 65\n37 37\n60 60\n32 32\n38 38\n81 81\n2 2\n34 34\n17 17\n82 82\n26 26\n71 71\n4 4\n16 16\n19 19\n39 39\n51 51\n6 6\n49 49\n64 64\n83 83\n10 10\n56 56\n30 30\n76 76\n90 90\n42 42\n47 47\n91... | code_stdio |
[
{
"content": "Read problems statements in Mandarin Chinese and Russian. \n\nYesterday Chef had a great party and doesn't remember the way he celebreated it. But he found a strange paper in his kitchen containing n digits (lets give them indices from 1 to n and name them a_{1}, a_{2} ... a_{N}). \nChef remember... | [{"input": "10 3\n0324152397\n2\n3\n10", "output": "3\n3\n38\n"}, {"input": "10 3\n0324152397\n4\n3\n10", "output": "7\n3\n38\n"}, {"input": "10 3\n0324152397\n1\n3\n10", "output": "0\n3\n38\n"}, {"input": "10 3\n0324152397\n1\n4\n10", "output": "0\n7\n38\n"}, {"input": "10 3\n0324152397\n7\n3\n10", "output": "9\n3\n38... | code_stdio |
[
{
"content": "There are n cities situated along the main road of Berland. Cities are represented by their coordinates — integer numbers a_1, a_2, ..., a_{n}. All coordinates are pairwise distinct.\n\nIt is possible to get from one city to another only by bus. But all buses and roads are very old, so the Ministe... | [{"input": "20\n105619866 106083760 106090730 105809555 106115212 105155938 105979518 106075627 106145216 105637844 105925719 105498536 105927000 106155938 106134226 106125969 106130588 105464813 106145509 106114971\n", "output": "241 1\n"}, {"input": "20\n105619866 106083760 106090730 105809555 106115212 105155938 105... | code_stdio |
[
{
"content": "A correct expression of the form a+b=c was written; a, b and c are non-negative integers without leading zeros. In this expression, the plus and equally signs were lost. The task is to restore the expression. In other words, one character '+' and one character '=' should be inserted into given seq... | [{"input": "100277221476489181970323375139380435110027722147648918197032337513938043511002772214764891819703233751393804351100277221476489181970323375139380435120055444295297836394064675027876087022005544429529783639406467502787608702\n", "output": "1002772214764891819703233751393804351100277221476489181970323375139380... | code_stdio |
[
{
"content": "Polycarp lives on a coordinate line at the point $x = 0$. He goes to his friend that lives at the point $x = a$. Polycarp can move only from left to right, he can pass one unit of length each second.\n\nNow it's raining, so some segments of his way are in the rain. Formally, it's raining on $n$ no... | [{"input": "100 50 1\n1 2\n3 4\n5 6\n7 8\n9 10\n11 12\n13 14\n15 16\n17 18\n19 20\n21 22\n23 24\n25 26\n27 28\n29 30\n31 32\n33 34\n35 36\n37 38\n39 40\n41 42\n43 44\n45 46\n47 48\n49 50\n51 52\n53 54\n55 56\n57 58\n59 60\n61 62\n63 64\n65 66\n67 68\n69 70\n71 72\n73 74\n75 76\n77 78\n79 80\n81 82\n83 84\n85 86\n87 88\... | code_stdio |
[
{
"content": "Daruma Otoshi\n\nYou are playing a variant of a game called \"Daruma Otoshi (Dharma Block Striking)\".\n\nAt the start of a game, several wooden blocks of the same size but with varying weights are stacked on top of each other, forming a tower. Another block symbolizing Dharma is placed atop. You ... | [{"input": "4\n1 2 3 4\n4\n1 2 3 1\n5\n5 0 3 3 6\n14\n11 7 1 4 3 5 0 1 6 13 10 4 11 5\n5\n1 3 5 2 3\n0", "output": "4\n4\n2\n6\n2\n"}, {"input": "4\n1 2 3 4\n4\n1 2 3 1\n5\n5 0 3 3 6\n14\n11 7 1 4 3 5 4 1 6 13 10 4 6 5\n5\n1 3 5 2 3\n0", "output": "4\n4\n2\n10\n2\n"}, {"input": "4\n1 2 3 4\n4\n1 2 3 1\n5\n5 0 3 3 6\n14... | code_stdio |
[
{
"content": "Methodius received an email from his friend Polycarp. However, Polycarp's keyboard is broken, so pressing a key on it once may cause the corresponding symbol to appear more than once (if you press a key on a regular keyboard, it prints exactly one symbol).\n\nFor example, as a result of typing the... | [{"input": "10\naaaa\naaaab\naaaa\nbaaaa\na\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\na\nb\naaaaa\naaaa\nabcdefghijklmnopqrstuvwxyz\nzabcdefghijklmnopqrstuvwxyz\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaba\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\... | code_stdio |
[
{
"content": "Sunuke received a d-dimensional hypercube with a side length of l1 × ... × ld as a birthday present. Sunuke placed this rectangular parallelepiped so that the range of the i-th coordinate was 0 or more and li or less, and ate the part that satisfied x1 + ... + xd ≤ s. However, xi represents the i-... | [{"input": "5\n12\n27\n15\n17\n149\n123", "output": "867510000\n"}, {"input": "5\n12\n34\n15\n17\n149\n119", "output": "998784000\n"}, {"input": "5\n12\n34\n15\n23\n149\n119", "output": "300622393\n"}, {"input": "5\n12\n27\n15\n22\n149\n151", "output": "449835161\n"}, {"input": "5\n12\n34\n56\n17\n90\n123", "output": "... | code_stdio |
[
{
"content": "As you have noticed, there are lovely girls in Arpa’s land.\n\nPeople in Arpa's land are numbered from 1 to n. Everyone has exactly one crush, i-th person's crush is person with the number crush_{i}. [Image] \n\nSomeday Arpa shouted Owf loudly from the top of the palace and a funny game started in... | [{"input": "100\n84 94 72 32 61 90 61 2 76 42 35 82 90 29 51 27 65 99 38 41 44 73 100 58 56 64 54 31 14 58 57 64 90 49 73 80 74 19 31 86 73 44 39 43 28 95 23 5 85 5 74 81 34 44 86 30 50 57 94 56 53 42 53 87 92 78 53 49 78 60 37 63 41 19 15 68 25 77 87 48 23 100 54 27 68 84 43 92 76 55 2 94 100 20 92 18 76 83 100 99\n",... | code_stdio |
[
{
"content": "Yuki made a sugoroku so that everyone can play at the children's association event. In this sugoroku, squares are lined up in a ring, and each square has an integer of 1 or more written on it.\n\nThe player chooses a square as a starting point and places his piece. Advance the pieces clockwise by ... | [{"input": "8\n2 -1 3 -1 1 4 -1 0", "output": "5\n"}, {"input": "8\n3 -1 3 -1 1 4 -1 0", "output": "6\n"}, {"input": "8\n3 -1 3 -1 2 4 -1 0", "output": "6\n"}, {"input": "8\n3 -1 3 -1 0 4 -1 0", "output": "7\n"}, {"input": "8\n3 -1 3 -1 0 4 -1 1", "output": "6\n"}, {"input": "8\n1 1 1 2 11 1 -2 1", "output": "8\n"}, {"... | code_stdio |
[
{
"content": "Anatoly lives in the university dorm as many other students do. As you know, cockroaches are also living there together with students. Cockroaches might be of two colors: black and red. There are n cockroaches living in Anatoly's room.\n\nAnatoly just made all his cockroaches to form a single line... | [{"input": "166\nrbbbbbbbbbbbbrbrrbbrbbbrbbbbbbbbbbrbbbbbbrbbbrbbbbbrbbbbbbbrbbbbbbbrbbrbbbbbbbbrbbbbbbbbbbbbbbrrbbbrbbbbbbbbbbbbbbrbrbbbbbbbbbbbrbbbbbbbbbbbbbbrbbbbbbbbbbbbbbbbbbbbbb\n", "output": "70\n"}, {"input": "166\nrbbbbbbbbbbbbrbrrbbrbbbrbbbbbbbbbbrbbbbbbrbbbrbbbbbrbbbbbbbrbbbbbbbrbbrbbbbbbbbrbbbbbbbbbbbbbbrrb... | code_stdio |
[
{
"content": "We have a tree with N vertices. The vertices are numbered 0 through N - 1, and the i-th edge (0 ≤ i < N - 1) comnnects Vertex a_i and b_i. For each pair of vertices u and v (0 ≤ u, v < N), we define the distance d(u, v) as the number of edges in the path u-v.\n\nIt is expected that one of the vert... | [{"input": "10\n2 8\n6 0\n4 1\n7 6\n2 3\n8 6\n6 9\n2 4\n5 8", "output": "3"}, {"input": "5\n0 1\n0 2\n1 3\n3 4", "output": "1"}, {"input": "5\n0 1\n0 2\n0 3\n3 4", "output": "2"}, {"input": "2\n0 18", "output": "1"}, {"input": "2\n0 12", "output": "1"}, {"input": "2\n0 17", "output": "1"}, {"input": "2\n1 17", "output"... | code_stdio |
[
{
"content": "You are fishing with polar bears Alice and Bob. While waiting for the fish to bite, the polar bears get bored. They come up with a game. First Alice and Bob each writes a 01-string (strings that only contain character \"0\" and \"1\") a and b. Then you try to turn a into b using two types of opera... | [{"input": "0\n00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000... | code_stdio |
[
{
"content": "The north country is conquered by the great shogun-sama (which means king). Recently many beautiful dice which were made by order of the great shogun-sama were given to all citizens of the country. All citizens received the beautiful dice with a tear of delight. Now they are enthusiastically playi... | [{"input": "1 2\n10 8\n0 0\n0 1\n3 3\n1 3 5\n2 13 1\n1 0 2\n0 0\n0 2\n3 3\n1 2 4\n4 8 10\n1 1 2\n0 0\n1 2\n2 2\n1 2\n5 4\n1 0\n0 1\n2 3\n1 2 3\n5 5 6\n0 0\n1 2\n0 0", "output": "24\n14\n30\n11\n21\n"}, {"input": "1 2\n10 8\n0 0\n0 1\n3 3\n1 3 5\n2 13 1\n1 0 2\n0 0\n0 2\n3 3\n1 2 4\n4 8 10\n1 1 2\n0 0\n1 2\n2 2\n1 2\n3 ... | code_stdio |
[
{
"content": "Petya is having a party soon, and he has decided to invite his $n$ friends.\n\nHe wants to make invitations in the form of origami. For each invitation, he needs two red sheets, five green sheets, and eight blue sheets. The store sells an infinite number of notebooks of each color, but each notebo... | [{"input": "100000000 1\n", "output": "1500000000\n"}, {"input": "100000000 1\n", "output": "1500000000\n"}, {"input": "100000010 1\n", "output": "1500000150\n"}, {"input": "100010010 1\n", "output": "1500150150\n"}, {"input": "103616972 10575\n", "output": "146976\n"}, {"input": "100000000 3\n", "output": "500000001\n... | code_stdio |
[
{
"content": "Your program fails again. This time it gets \"Wrong answer on test 233\".\n\nThis is the harder version of the problem. In this version, $1 \\le n \\le 2\\cdot10^5$. You can hack this problem if you locked it. But you can hack the previous problem only if you locked both problems.\n\nThe problem i... | [{"input": "100 100\n82 51 14 14 37 17 78 92 64 15 8 86 89 8 87 77 30 15 15 12 100 25 161 47 21 78 20 63 13 49 41 36 41 79 16 87 87 69 3 76 80 60 100 49 70 59 72 8 38 71 45 148 71 14 76 54 81 4 59 46 39 29 92 3 49 22 53 99 118 52 74 31 92 43 70 23 44 9 82 47 7 40 12 9 3 55 37 85 46 22 84 52 98 41 11 47 40 17 62 91\n", ... | code_stdio |
[
{
"content": "Bad news came to Mike's village, some thieves stole a bunch of chocolates from the local factory! Horrible! \n\nAside from loving sweet things, thieves from this area are known to be very greedy. So after a thief takes his number of chocolates for himself, the next thief will take exactly k times ... | [{"input": "1000000000000000\n", "output": "4949100894494448\n"}, {"input": "1000000000000000\n", "output": "4949100894494448\n"}, {"input": "999999999999997\n", "output": "4949100894494440\n"}, {"input": "999999999999996\n", "output": "4949100894494432\n"}, {"input": "999999999999995\n", "output": "4949100894494424\n"... | code_stdio |
[
{
"content": "You are given an array $a$ of length $n$. The array is called 3SUM-closed if for all distinct indices $i$, $j$, $k$, the sum $a_i + a_j + a_k$ is an element of the array. More formally, $a$ is 3SUM-closed if for all integers $1 \\leq i < j < k \\leq n$, there exists some integer $1 \\leq l \\leq n... | [{"input": "4\n3\n-1 0 1\n5\n1 -2 -2 1 -3\n6\n0 0 0 0 0 0\n4\n-1 2 -3 4\n", "output": "YES\nNO\nYES\nNO\n"}, {"input": "1\n3\n0 65536 65536\n", "output": "NO\n"}, {"input": "1\n4\n-3 -1 1 1\n", "output": "YES\n"}, {"input": "1\n4\n3 -3 -3 9\n", "output": "YES\n"}, {"input": "1\n4\n-1 -4 2 3\n", "output": "NO\n"}, {"inp... | code_stdio |
[
{
"content": "Nauuo is a girl who loves playing cards.\n\nOne day she was playing cards but found that the cards were mixed with some empty ones.\n\nThere are n cards numbered from 1 to n, and they were mixed with another n empty cards. She piled up the 2n cards and drew n of them. The n cards in Nauuo's hands ... | [{"input": "20\n15 10 6 0 0 11 19 17 0 0 0 0 0 1 14 0 3 4 0 12\n20 7 0 0 0 0 0 0 5 8 2 16 18 0 0 13 9 0 0 0\n", "output": "30\n"}, {"input": "20\n0 0 0 0 5 6 7 8 0 0 11 12 13 14 15 16 17 18 0 0\n20 9 19 0 0 0 0 0 0 10 0 0 0 0 0 0 1 2 3 4\n", "output": "37\n"}, {"input": "19\n0 0 0 0 0 0 0 0 0 18 17 16 15 14 13 12 11 10... | code_stdio |
[
{
"content": "Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?\n\nConstraints\n\n* 1 ≤ N,A,B ≤ 10^9\n* A and B are integers.\n\nInput\n\nInput is given from Standard Input in the following for... | [{"input": "13 -10 2", "output": "133\n"}, {"input": "125 -2 0", "output": "247\n"}, {"input": "109 0 1", "output": "108\n"}, {"input": "109 0 2", "output": "215\n"}, {"input": "19 -7 -2", "output": "86\n"}, {"input": "48 -1 2", "output": "139\n"}, {"input": "69 -1 2", "output": "202\n"}, {"input": "36 -1 2", "output":... | code_stdio |
[
{
"content": "As we know, DZY loves playing games. One day DZY decided to play with a n × m matrix. To be more precise, he decided to modify the matrix with exactly k operations.\n\nEach modification is one of the following:\n\n 1. Pick some row of the matrix and decrease each element of the row by p. This ope... | [{"input": "10 10 50 80\n529 349 889 455 946 983 312 179 590 907\n436 940 407 1064 26 963 181 789 461 437\n367 505 888 521 449 741 900 994 342 629\n605 374 112 829 212 329 295 416 181 435\n661 647 676 144 436 629 660 282 545 470\n392 555 351 969 102 178 588 578 696 592\n837 115 669 760 324 680 584 822 909 75\n575 89 56... | code_stdio |
[
{
"content": "Polo, the Penguin, likes numbers. He says that the goodness of a number is itself multiplied by the number of digits in it's decimal representation. For example, the goodness of the integer 474 is 474*3 = 1422.\nHelp him to count the sum of goodness of all integers from L to R, inclusive. Since th... | [{"input": "1\n13 393", "output": "227157\n"}, {"input": "1\n15 149", "output": "28365\n"}, {"input": "1\n15 260", "output": "96630\n"}, {"input": "1\n13 260", "output": "96684\n"}, {"input": "1\n13 130", "output": "20439\n"}, {"input": "1\n1 345", "output": "174060\n"}, {"input": "1\n2 345", "output": "174059\n"}, {"i... | code_stdio |
[
{
"content": "There are $n$ people sitting in a circle, numbered from $1$ to $n$ in the order in which they are seated. That is, for all $i$ from $1$ to $n-1$, the people with id $i$ and $i+1$ are adjacent. People with id $n$ and $1$ are adjacent as well.\n\nThe person with id $1$ initially has a ball. He picks... | [{"input": "735134400\n", "output": "1 367567202 735134403 1102701604 1470268805 1837836006 2205403207 2572970408 2940537609 3308104810 3675672011 4043239212 4410806413 4778373614 5145940815 5513508016 5881075217 6248642418 6983776820 7351344021 7718911222 8454045624 8821612825 9189180026 9556747227 9924314428 10659448... | code_stdio |
[
{
"content": "Little Tanya decided to present her dad a postcard on his Birthday. She has already created a message — string s of length n, consisting of uppercase and lowercase English letters. Tanya can't write yet, so she found a newspaper and decided to cut out the letters and glue them into the postcard to... | [{"input": "DpiNBmCRFWxpdbfGOzvvOcemjructoAdEwegTvbVbfWWRPGyEAxGdDRWVlqNyGWMWHMrHAIZpyxvgaflrsVZhhZRouvpxrKXFZam\nwwPLFtNfPtJXvMLuHjKfYyaRhreNSWSzOvDpqHCGcqllACNPGHxReeFUCmAqIKXYytsSQwIxJzNiiUtgebVuwRmWpRALLyKAzyDPvgIGxALSaeeTIqm\n", "output": "66 12\n"}, {"input": "DpiNBmCRFWxpdbfGOzvvOcemjructoAdEwegTvbVbfWWRPGyEAxGd... | code_stdio |
[
{
"content": "It is Borya's eleventh birthday, and he has got a great present: n cards with numbers. The i-th card has the number a_{i} written on it. Borya wants to put his cards in a row to get one greater number. For example, if Borya has cards with numbers 1, 31, and 12, and he puts them in a row in this or... | [{"input": "4\n2\n1 1\n3\n2 31 12\n3\n21646 67 98\n9\n1 2 3 14 4 11 7 8 9\n", "output": "2\n0\n1\n36288\n"}, {"input": "4\n2\n1 1\n3\n1 31 12\n3\n12345 67 84\n9\n1 2 3 4 5 1 7 8 16\n", "output": "2\n2\n2\n36288\n"}, {"input": "4\n2\n1 1\n3\n1 20 12\n3\n32697 67 98\n9\n1 2 3 4 13 6 7 8 6\n", "output": "2\n2\n0\n31104\n"... | code_stdio |
[
{
"content": "Roma works in a company that sells TVs. Now he has to prepare a report for the last year.\n\nRoma has got a list of the company's incomes. The list is a sequence that consists of n integers. The total income of the company is the sum of all integers in sequence. Roma decided to perform exactly k c... | [{"input": "78 13\n-9961 -9922 -9817 -9813 -9521 -9368 -9361 -9207 -9153 -9124 -9008 -8981 -8951 -8911 -8551 -8479 -8245 -8216 -7988 -7841 -7748 -7741 -7734 -7101 -6846 -6804 -6651 -6526 -6519 -6463 -6297 -6148 -6090 -5845 -5209 -5201 -5161 -5061 -4537 -4529 -4433 -4370 -4266 -4189 -4125 -3945 -3843 -3777 -3751 -3476 -... | code_stdio |
[
{
"content": "-----Problem Statement-----\nChef studies combinatorics. He tries to group objects by their rang (a positive integer associated with each object). He also gives the formula for calculating the number of different objects with rang N as following:\n\nthe number of different objects with rang N = F(... | [{"input": "4\n1 1 2 -1\n1\n3 1 0 0\n5\n0 1 1 0\n12\n1 4 1 7\n12", "output": "3\n342\n187771\n636400412\n"}, {"input": "4\n1 2 2 -1\n1\n3 1 0 0\n5\n0 1 1 0\n12\n1 4 1 7\n12", "output": "4\n342\n187771\n636400412\n"}, {"input": "4\n1 1 2 -1\n1\n5 1 0 0\n5\n0 1 2 0\n6\n1 4 0 7\n12", "output": "3\n1100\n2618\n549147970\n"... | code_stdio |
[
{
"content": "Given are 1-digit positive integers a and b. Consider these two strings: the concatenation of b copies of the digit a, and the concatenation of a copies of the digit b. Which of these is lexicographically smaller?\n\n-----Constraints-----\n - 1 \\leq a \\leq 9\n - 1 \\leq b \\leq 9\n - a and b are... | [{"input": "96 1", "output": "111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\n"}, {"input": "10 40", "output": "10101010101010101010101010101010101010101010101010101010101010101010101010101010\n"}, {"input": "80 1", "output": "1111111111111111111111111111111111111111111... | code_stdio |
[
{
"content": "A TV program called \"Saizo\" is popular in a certain country. In this program, participants challenge field athletics and get a prize if they successfully capture it.\n\nField athletics are made by arranging blocks of different heights in a row, and how to climb up and down the steps is important... | [{"input": "5\n5\n10 101 5 50 390\n2\n20 101\n2\n100 30\n3\n22 86 50\n7\n123 82 678 1617 272 971 1573", "output": "340 96\n81 0\n0 70\n64 36\n939 1345\n"}, {"input": "5\n5\n10 101 5 50 390\n2\n20 101\n2\n100 30\n3\n22 86 50\n7\n123 82 678 1617 106 971 1573", "output": "340 96\n81 0\n0 70\n64 36\n939 1511\n"}, {"input":... | code_stdio |
[
{
"content": "It's now 260 AD. Shapur, being extremely smart, became the King of Persia. He is now called Shapur, His majesty King of kings of Iran and Aniran.\n\nRecently the Romans declared war on Persia. They dreamed to occupy Armenia. In the recent war, the Romans were badly defeated. Now their senior army ... | [{"input": "17 17\n00000000000000000000000000000000000000000000000000000000000000000000000000000\n", "output": "0\n"}, {"input": "34 17\n00000000000000000000000000000000000000000000000000000000000000000000000000000\n", "output": "0\n"}, {"input": "4 2\n112233030100132210003330\n", "output": "101101011110011000100000111... | code_stdio |
[
{
"content": "We have a board with H horizontal rows and W vertical columns of squares. There is a bishop at the top-left square on this board. How many squares can this bishop reach by zero or more movements?\n\nHere the bishop can only move diagonally. More formally, the bishop can move from the square at the... | [{"input": "1001000000 1000000000", "output": "500500000000000000\n"}, {"input": "1001000000 1100000000", "output": "550550000000000000\n"}, {"input": "1001000010 1100000000", "output": "550550005500000000\n"}, {"input": "1001000010 1100100000", "output": "550600055500500000\n"}, {"input": "1001000011 1100100000", "out... | code_stdio |
[
{
"content": "The goal of 8 Queens Problem is to put eight queens on a chess-board such that none of them threatens any of others. A queen threatens the squares in the same row, in the same column, or on the same diagonals as shown in the following figure.\n\n<image>\n\n\nFor a given chess board where $k$ queen... | [{"input": "2\n1 4\n5 3", "output": "..Q.....\n....Q...\n.Q......\n.......Q\n.....Q..\n...Q....\n......Q.\nQ.......\n"}, {"input": "2\n0 4\n5 3", "output": "....Q...\n.Q......\n.....Q..\nQ.......\n......Q.\n...Q....\n.......Q\n..Q.....\n"}, {"input": "2\n0 4\n5 2", "output": "....Q...\n.Q......\n...Q....\n.....Q..\n...... | code_stdio |
[
{
"content": "Snuke has N integers: 1,2,\\ldots,N. He will choose K of them and give those to Takahashi.\n\nHow many ways are there to choose K consecutive integers?\n\nConstraints\n\n* All values in input are integers.\n* 1 \\leq K \\leq N \\leq 50\n\nInput\n\nInput is given from Standard Input in the followin... | [{"input": "1 -159", "output": "161\n"}, {"input": "119 -1", "output": "121\n"}, {"input": "2 -107", "output": "110\n"}, {"input": "0 -159", "output": "160\n"}, {"input": "112 -1", "output": "114\n"}, {"input": "0 -103", "output": "104\n"}, {"input": "112 -2", "output": "115\n"}, {"input": "-1 -29", "output": "29\n"}, ... | code_stdio |
[
{
"content": "Sasha grew up and went to first grade. To celebrate this event her mother bought her a multiplication table $M$ with $n$ rows and $n$ columns such that $M_{ij}=a_i \\cdot a_j$ where $a_1, \\dots, a_n$ is some sequence of positive integers.\n\nOf course, the girl decided to take it to school with h... | [{"input": "10\n0 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000\n1000000000 0 1 1 1 1 1 1 1 1\n1000000000 1 0 1 1 1 1 1 1 1\n1000000000 1 1 0 1 1 1 1 1 1\n1000000000 1 1 1 0 1 1 1 1 1\n1000000000 1 1 1 1 0 1 1 1 1\n1000000000 1 1 1 1 1 0 1 1 1\n1000000000 1 1 1 1 1 1... | code_stdio |
[
{
"content": "You are given a program that consists of $n$ instructions. Initially a single variable $x$ is assigned to $0$. Afterwards, the instructions are of two types:\n\nincrease $x$ by $1$;\n\ndecrease $x$ by $1$.\n\nYou are given $m$ queries of the following format:\n\nquery $l$ $r$ — how many distinct v... | [{"input": "2\n8 4\n-+--+--+\n1 8\n2 8\n2 5\n1 1\n4 10\n+-++\n1 1\n1 2\n2 2\n1 3\n2 3\n3 3\n1 4\n2 4\n3 4\n4 4\n", "output": "\n1\n2\n4\n4\n3\n3\n4\n2\n3\n2\n1\n2\n2\n2\n"}, {"input": "2\n8 4\n-+--+--+\n1 8\n2 8\n2 5\n1 1\n4 10\n+-++\n1 1\n1 2\n2 2\n1 3\n2 3\n3 3\n1 4\n2 4\n3 4\n4 4\n", "output": "1\n2\n4\n4\n3\n3\n4\n... | code_stdio |
[
{
"content": "Developers often face with regular expression patterns. A pattern is usually defined as a string consisting of characters and metacharacters that sets the rules for your search. These patterns are most often used to check whether a particular string meets the certain rules.\n\nIn this task, a patt... | [{"input": "100\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\n?b\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\nb?\... | code_stdio |
[
{
"content": "Fedya studies in a gymnasium. Fedya's maths hometask is to calculate the following expression:(1^{n} + 2^{n} + 3^{n} + 4^{n}) mod 5\n\nfor given value of n. Fedya managed to complete the task. Can you? Note that given number n can be extremely large (e.g. it can exceed any integer type of your pro... | [{"input": "124356983594583453458888889\n", "output": "0\n"}, {"input": "124356983594583453458888889\n", "output": "0\n"}, {"input": "1134974\n", "output": "0\n"}, {"input": "1236642\n", "output": "0\n"}, {"input": "1068905\n", "output": "0\n"}, {"input": "1528132\n", "output": "4\n"}, {"input": "1580332\n", "output": ... | code_stdio |
[
{
"content": "Kuroni is very angry at the other setters for using him as a theme! As a punishment, he forced them to solve the following problem:\n\nYou have an array $a$ consisting of $n$ positive integers. An operation consists of choosing an element and either adding $1$ to it or subtracting $1$ from it, suc... | [{"input": "10\n648137704891 648137704891 648137704891 648137704891 648137704891 648137704891 648137704891 648137704891 648137704891 724560300002\n", "output": "2\n"}, {"input": "5\n169999847 169999847 169999847 300469729580 169999847\n", "output": "3\n"}, {"input": "5\n8082488 169999847 169999847 300469729580 16999984... | code_stdio |
[
{
"content": "You have multiset of n strings of the same length, consisting of lowercase English letters. We will say that those strings are easy to remember if for each string there is some position i and some letter c of the English alphabet, such that this string is the only string in the multiset that has l... | [{"input": "3 20\naaaaaaaaaaaaaaaaaaaa\naaaaaaaaaaaaaaaaaaaa\naaaaaaaaaaaaaaaaaaaa\n127368 467778 376749 367872 201445 632491 733098 177711 678142 3202 840006 769776 381139 365553 457474 206005 99000 226191 795686 589632\n785172 213443 482364 357721 191016 596022 882906 601573 917829 966436 129825 285602 706196 722082 ... | code_stdio |
[
{
"content": "Sonya decided to organize an exhibition of flowers. Since the girl likes only roses and lilies, she decided that only these two kinds of flowers should be in this exhibition.\n\nThere are $n$ flowers in a row in the exhibition. Sonya can put either a rose or a lily in the $i$-th position. Thus eac... | [{"input": "1582 10\n587 646\n1148 843\n326 875\n439 485\n465 521\n330 387\n405 480\n477 115\n572 376\n715 771\n", "output": "01010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101... | code_stdio |
[
{
"content": "Long ago, when Petya was a schoolboy, he was very much interested in the Petr# language grammar. During one lesson Petya got interested in the following question: how many different continuous substrings starting with the sbegin and ending with the send (it is possible sbegin = send), the given st... | [{"input": "bgphoaomnjcjhgkgbflfclbjmkbfonpbmkdomjmkahaoclcbijdjlllnpfkbilgiiidbabgojbbfmliemhicaanadbaahagmfdldbbklelkihlcbkhchlikhefeeafbhkabfdlhnnjnlimbhneafcfeapcbeifgcnaijdnkjpikedmdbhahhgcijddfmamdiaapaeimdhfblpkedamifbbdndmmljmdcffcpmanndeeclnpnkdoieiahchdnkdmfnbocnimclgckdcbp\npcbeifgcnaijdnkjpikedmdbhahhgcijdd... | code_stdio |
[
{
"content": "Let's denote a m-free matrix as a binary (that is, consisting of only 1's and 0's) matrix such that every square submatrix of size m × m of this matrix contains at least one zero. \n\nConsider the following problem:\n\nYou are given two integers n and m. You have to construct an m-free square matr... | [{"input": "3\n21\n0\n1\n", "output": "5 2\n1 1\n-1\n"}, {"input": "3\n21\n0\n1\n", "output": "5 2\n1 1\n-1\n"}, {"input": "1\n297540\n", "output": "546 22\n"}, {"input": "1\n297540\n", "output": "546 22\n"}, {"input": "1\n1015463691\n", "output": "-1\n"}, {"input": "1\n420441920\n", "output": "-1\n"}, {"input": "1\n42... | code_stdio |
[
{
"content": "In Aizuwakamatsu City, there is a first city called \"Tokaichi\" on January 10th every year. This Tokaichi has a history of about 600 years and is the largest first city in the Aizu region. It is also well known that Okiagari-koboshi, a familiar lucky charm, is sold in the Aizu region. Okiagari-ko... | [{"input": "1593 4311\n4321 2155\n1256 11201\n5310 1455\n2152 5421\n1928 3386\n4528 1578\n1234 4321\n3330 3109\n2739 2199\n0 0", "output": "C 12457\nD 6439\n"}, {"input": "1593 4311\n4321 2155\n1256 12219\n5310 1455\n2152 5421\n1549 3288\n4528 3719\n1234 4321\n3330 2166\n2759 2199\n0 0", "output": "C 13475\nB 8247\n"},... | code_stdio |
[
{
"content": "Patrick has just finished writing a message to his sweetheart Stacey when he noticed that the message didn't look fancy. Patrick was nervous while writing the message, so some of the letters there were lowercase and some of them were uppercase.\n\nPatrick believes that a message is fancy if any up... | [{"input": "MMVESdOCALHJCTBTUWWQRGUUVTTTABKKAAdIINAdKLRLLVLODHDXDPMcQfUhPNHFBJSDRGsHZNORSCPNvKOOIuZnZAmTPUCoPNlR\n", "output": "13\n"}, {"input": "MMbJIBhgFXPVpdQHLkWJkAHFIfJSpITTCRzRCzvRPRYECCheOknfINZWuKATDBOrEVKTcWXiYPjtzQMGUSGPNTMCUrvYCSWQHqAi\n", "output": "27\n"}, {"input": "mnAkOBuKxaiJwXhKnlcCvjxYXGXDoIqfUYkiLr... | code_stdio |
[
{
"content": "There are N people (with different names) and K clubs. For each club you know the list of members (so you have K unordered lists). Each person can be a member of many clubs (and also 0 clubs) and two different clubs might have exactly the same members. The value of the number K is the minimum poss... | [{"input": "119107271329329921", "output": "-1\n"}, {"input": "33213408621377322", "output": "-1\n"}, {"input": "26939847318901699", "output": "-1\n"}, {"input": "12809773843701327", "output": "-1\n"}, {"input": "15368855316243065", "output": "-1\n"}, {"input": "123456789123456789", "output": "-1"}, {"input": "54520540... | code_stdio |
[
{
"content": "Mike received an array $a$ of length $n$ as a birthday present and decided to test how pretty it is.\n\nAn array would pass the $i$-th prettiness test if there is a way to get an array with a sum of elements totaling $s_i$, using some number (possibly zero) of slicing operations.\n\nAn array slici... | [{"input": "2\n5 5\n1 2 3 4 5\n1\n5\n9\n12\n6\n5 5\n6 1 3 2 3\n1\n2\n3\n15\n11\n", "output": "Yes\nYes\nYes\nNo\nYes\nYes\nYes\nYes\nYes\nNo\n"}, {"input": "2\n5 5\n1 2 3 4 5\n1\n5\n3\n12\n6\n5 5\n6 1 3 2 3\n1\n2\n3\n15\n11\n", "output": "Yes\nYes\nYes\nNo\nYes\nYes\nYes\nYes\nYes\nNo\n"}, {"input": "2\n5 5\n1 2 3 4 5\... | code_stdio |
[
{
"content": "Given is a connected undirected graph with N vertices and M edges. The vertices are numbered 1 to N, and the edges are described by a grid of characters S. If S_{i,j} is `1`, there is an edge connecting Vertex i and j; otherwise, there is no such edge.\n\nDetermine whether it is possible to divide... | [{"input": "6\n010111\n101001\n010100\n101000\n100000\n010000", "output": "-1\n"}, {"input": "6\n010110\n101001\n010100\n101000\n100100\n010000", "output": "-1\n"}, {"input": "6\n010110\n001001\n010100\n101000\n100100\n010000", "output": "-1\n"}, {"input": "6\n010110\n001001\n010100\n101000\n000100\n010000", "output": ... | code_stdio |
[
{
"content": "You like playing chess tournaments online.\n\nIn your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if you have won also the previous game you ge... | [{"input": "8\n5 2\nWLWLL\n6 5\nLLLWWL\n7 4\nLWLWLWL\n15 5\nWWWLLLWWWLLLWWW\n40 38\nLLWLWLWWWLWLLWLWWWLWLLWLLWLLLLWLLWWWLWWL\n1 0\nL\n1 0\nL\n6 0\nWLLWLW\n", "output": "7\n11\n13\n26\n79\n0\n0\n3\n"}, {"input": "8\n5 2\nWLWLL\n6 5\nLLLWWL\n7 4\nLWLWLWL\n15 2\nWWWLLLWWWLLLWWW\n40 38\nLLWLWLWWWLWLLWLWWWLWLLWLLWLLLLWLLWWW... | code_stdio |
[
{
"content": "Vasya commutes by train every day. There are n train stations in the city, and at the i-th station it's possible to buy only tickets to stations from i + 1 to a_{i} inclusive. No tickets are sold at the last station.\n\nLet ρ_{i}, j be the minimum number of tickets one needs to buy in order to get... | [{"input": "10\n2 10 8 7 8 8 10 9 10\n", "output": "63\n"}, {"input": "10\n2 10 8 7 8 8 10 9 10\n", "output": "63\n"}, {"input": "10\n2 10 8 7 8 9 10 9 10\n", "output": "62\n"}, {"input": "10\n3 10 8 7 8 9 10 9 10\n", "output": "61\n"}, {"input": "10\n2 10 8 6 8 8 10 9 10\n", "output": "66\n"}, {"input": "9\n2 9 7 6 9 ... | code_stdio |
[
{
"content": "After many years of research, Ikta has acquired the ability to predict the future! The time and money he spent on this research was enormous, but it's finally time to be rewarded. To get the money back, Ikta decided to start investing in stocks.\n\nIkta does not currently own any shares, but owns ... | [{"input": "3 3 10\n18 1 13\n15 3 3\n5 10 0", "output": "100\n"}, {"input": "3 3 10\n10 14 13\n14 2 6\n5 4 1", "output": "28\n"}, {"input": "3 3 10\n18 4 13\n15 3 3\n5 11 1", "output": "34\n"}, {"input": "3 3 10\n18 4 13\n15 5 3\n5 11 1", "output": "24\n"}, {"input": "3 3 18\n10 14 13\n14 3 3\n5 4 1", "output": "29\n"}... | code_stdio |
[
{
"content": "Programmer Vasya is studying a new programming language &K*. The &K* language resembles the languages of the C family in its syntax. However, it is more powerful, which is why the rules of the actual C-like languages are unapplicable to it. To fully understand the statement, please read the langua... | [{"input": "10\ntypedef &void**** youdyfpinzk\ntypeof &youdyfpinzk***\ntypedef &&&&youdyfpinzk****** nfbsgpjzhxzskmxc\ntypeof nfbsgpjzhxzskmxc***\ntypedef &&&void*** puerqioirikxej\ntypeof &puerqioirikxej********\ntypedef &puerqioirikxej******** xzgzsamjdufuyxz\ntypeof &xzgzsamjdufuyxz******\ntypedef &&&&xzgzsamjdufuyx... | code_stdio |
[
{
"content": "AtCoDeer the deer found two rectangles lying on the table, each with height 1 and width W.\nIf we consider the surface of the desk as a two-dimensional plane, the first rectangle covers the vertical range of [0,1] and the horizontal range of [a,a+W], and the second rectangle covers the vertical ra... | [{"input": "-1 -1 100", "output": "102\n"}, {"input": "-1 -1 101", "output": "103\n"}, {"input": "-1 -1 111", "output": "113\n"}, {"input": "0 -116 -1", "output": "115\n"}, {"input": "-2 -1 111", "output": "114\n"}, {"input": "2 -160 -1", "output": "157\n"}, {"input": "0 -155 -1", "output": "154\n"}, {"input": "0 -191 ... | code_stdio |
[
{
"content": "Adam Ivan is working as a system administrator at Soy Group, Inc. He is now facing at a big trouble: a number of computers under his management have been infected by a computer virus. Unfortunately, anti-virus system in his company failed to detect this virus because it was very new.\n\nAdam has i... | [{"input": "4 2\n1 1 3\n-1 2 -1\n5 2\n0 3 1\n1 0 0\n0 0", "output": "2\n1\n"}, {"input": "4 2\n0 1 3\n-1 2 -1\n5 2\n0 3 1\n1 0 0\n0 0", "output": "2\n1\n"}, {"input": "4 2\n0 1 3\n-1 2 -1\n6 2\n0 3 1\n1 0 0\n0 0", "output": "2\n1\n"}, {"input": "3 2\n0 1 3\n-1 2 -1\n6 2\n0 3 1\n1 0 0\n0 0", "output": "2\n1\n"}, {"input... | code_stdio |
[
{
"content": "Student Valera is an undergraduate student at the University. His end of term exams are approaching and he is to pass exactly n exams. Valera is a smart guy, so he will be able to pass any exam he takes on his first try. Besides, he can take several exams on one day, and in any order.\n\nAccording... | [{"input": "1\n1001000000 999999999\n", "output": "999999999\n"}, {"input": "1\n1101010000 523461264\n", "output": "523461264\n"}, {"input": "1\n1101000000 193606579\n", "output": "193606579\n"}, {"input": "1\n1101000000 142743309\n", "output": "142743309\n"}, {"input": "1\n1101000000 121903142\n", "output": "121903142... | code_stdio |
[
{
"content": "Consider a football tournament where n teams participate. Each team has two football kits: for home games, and for away games. The kit for home games of the i-th team has color x_{i} and the kit for away games of this team has color y_{i} (x_{i} ≠ y_{i}).\n\nIn the tournament, each team plays exac... | [{"input": "30\n25 8\n25 4\n21 9\n25 1\n7 16\n23 21\n22 17\n27 29\n7 29\n20 3\n13 23\n7 13\n16 18\n25 14\n13 17\n28 15\n10 23\n25 18\n2 3\n23 13\n30 8\n13 15\n20 15\n11 29\n10 23\n5 16\n4 14\n4 30\n7 20\n11 1\n", "output": "29 29\n31 27\n29 29\n29 29\n30 28\n30 28\n29 29\n29 29\n29 29\n29 29\n31 27\n32 26\n29 29\n29 29... | code_stdio |
[
{
"content": "Прошло много лет, и на вечеринке снова встретились n друзей. С момента последней встречи техника шагнула далеко вперёд, появились фотоаппараты с автоспуском, и теперь не требуется, чтобы один из друзей стоял с фотоаппаратом, и, тем самым, оказывался не запечатлённым на снимке.\n\nУпрощенно процесс... | [{"input": "42\n13 62\n114 242\n265 839\n756 349\n298 476\n533 704\n348 277\n554 573\n654 112\n429 836\n574 766\n909 415\n163 891\n532 983\n873 457\n719 117\n1 302\n170 634\n166 585\n721 231\n208 609\n128 246\n845 726\n604 119\n859 110\n568 515\n656 913\n113 166\n794 566\n834 860\n983 596\n545 819\n167 9\n960 73\n260 6... | code_stdio |
[
{
"content": "You are given n segments on a number line, numbered from 1 to n. The i-th segments covers all integer points from l_i to r_i and has a value w_i.\n\nYou are asked to select a subset of these segments (possibly, all of them). Once the subset is selected, it's possible to travel between two integer ... | [{"input": "45 100\n86 90 344\n67 71 63\n84 87 423\n96 98 297\n85 86 144\n75 80 489\n24 25 17\n75 78 363\n1 3 349\n17 19 146\n35 38 39\n90 93 236\n34 35 463\n59 64 259\n97 100 185\n71 75 214\n80 84 124\n63 67 324\n85 88 204\n47 51 420\n22 24 38\n30 34 41\n94 96 42\n3 6 312\n51 56 440\n84 85 337\n10 14 3\n30 31 390\n46 ... | code_stdio |
[
{
"content": "Another programming contest is over. You got hold of the contest's final results table. The table has the following data. For each team we are shown two numbers: the number of problems and the total penalty time. However, for no team we are shown its final place.\n\nYou know the rules of comparing... | [{"input": "50 50\n50 50\n50 50\n50 50\n50 50\n50 50\n50 50\n50 50\n50 50\n50 50\n50 50\n50 50\n50 50\n50 50\n50 50\n50 50\n50 50\n50 50\n50 50\n50 50\n50 50\n50 50\n50 50\n50 50\n50 50\n50 50\n50 50\n50 50\n50 50\n50 50\n50 50\n50 50\n50 50\n50 50\n50 50\n50 50\n50 50\n50 50\n50 50\n50 50\n50 50\n50 50\n50 50\n50 50\n... | code_stdio |
[
{
"content": "A guy named Vasya attends the final grade of a high school. One day Vasya decided to watch a match of his favorite hockey team. And, as the boy loves hockey very much, even more than physics, he forgot to do the homework. Specifically, he forgot to complete his physics tasks. Next day the teacher ... | [{"input": "44\n52 -54 -29\n-82 -5 -94\n-54 43 43\n91 16 71\n7 80 -91\n3 15 29\n-99 -6 -77\n-3 -77 -64\n73 67 34\n25 -10 -18\n-29 91 63\n-72 86 -16\n-68 85 -81\n-3 36 44\n-74 -14 -80\n34 -96 -97\n-76 -78 -33\n-24 44 -58\n98 12 77\n95 -63 -6\n-51 3 -90\n-92 -10 72\n7 3 -68\n57 -53 71\n29 57 -48\n35 -60 10\n79 -70 -61\n-... | code_stdio |
[
{
"content": "Given a string consisting of only numbers from 0 to 9, consider the operation of creating a new string from that string according to the following rules. Read the given string one character at a time from the left end. Go, if the same number a continues r, write the number r and the number a in th... | [{"input": "5\n28\n14\n1\n0", "output": "11131221121113122118\n311311222113111231131112132112311321322112111312211312111322212311322113212221\n"}, {"input": "5\n23\n14\n1\n0", "output": "11131221121113122113\n311311222113111231131112132112311321322112111312211312111322212311322113212221\n"}, {"input": "5\n19\n11\n0\n0"... | code_stdio |
[
{
"content": "After the lessons n groups of schoolchildren went outside and decided to visit Polycarpus to celebrate his birthday. We know that the i-th group consists of si friends (1 ≤ si ≤ 4), and they want to go to Polycarpus together. They decided to get there by taxi. Each car can carry at most four passe... | [{"input": "78\n2 2 2 2 3 3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 2 2 3 2 2 2 2 2 2 2 1 1 2 2 2 2 2 2 2 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2\n", "output": "39\n"}, {"input": "78\n2 2 2 2 3 3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 4 2 2 2 2 2 1 2 2 3 2 2 2 2 2 2 2 1 1 2 2 2 2 2 2 ... | code_stdio |
[
{
"content": "Suppose you have two points $p = (x_p, y_p)$ and $q = (x_q, y_q)$. Let's denote the Manhattan distance between them as $d(p, q) = |x_p - x_q| + |y_p - y_q|$.\n\nLet's say that three points $p$, $q$, $r$ form a bad triple if $d(p, r) = d(p, q) + d(q, r)$.\n\nLet's say that an array $b_1, b_2, \\dot... | [{"input": "3\n4\n2 4 1 3\n5\n6 9 1 18 12\n2\n13 37\n", "output": "10\n13\n3\n"}, {"input": "3\n4\n2 4 1 3\n5\n6 9 2 18 12\n2\n13 37\n", "output": "10\n13\n3\n"}, {"input": "3\n4\n2 4 1 3\n5\n0 9 2 18 12\n2\n13 37\n", "output": "10\n13\n3\n"}, {"input": "3\n4\n2 4 1 3\n5\n0 9 2 18 12\n2\n20 37\n", "output": "10\n13\n3\... | code_stdio |
[
{
"content": "Gag\n\nSegtree has $ N $ of \"gags\", each with a value of $ V_i $.\n\nSegtree decided to publish all the gags in any order.\n\nHere, the \"joy\" you get when you publish the $ i $ th gag to the $ j $ th is expressed as $ V_i --j $.\n\nFind the maximum sum of the \"joy\" you can get.\n\ninput\n\nI... | [{"input": "1\n114525", "output": "114524\n"}, {"input": "1\n105905", "output": "105904\n"}, {"input": "1\n196252", "output": "196251\n"}, {"input": "1\n127413", "output": "127412\n"}, {"input": "1\n318416", "output": "318415\n"}, {"input": "1\n26794", "output": "26793\n"}, {"input": "1\n22977", "output": "22976\n"}, {... | code_stdio |
[
{
"content": "Your task is to write a program which reads a sequence of integers and prints mode values of the sequence. The mode value is the element which occurs most frequently.\n\n\n\nInput\n\nA sequence of integers ai (1 ≤ ai ≤ 100). The number of integers is less than or equals to 100.\n\nOutput\n\nPrint ... | [{"input": "5\n11\n3\n5\n8\n10\n11\n8\n29\n1\n3\n2", "output": "3\n5\n8\n11\n"}, {"input": "5\n11\n4\n10\n4\n-1\n20\n8\n20\n2\n8\n0", "output": "4\n8\n20\n"}, {"input": "5\n11\n2\n11\n1\n-2\n20\n8\n22\n2\n6\n1", "output": "1\n2\n11\n"}, {"input": "5\n11\n1\n5\n8\n0\n11\n8\n51\n1\n3\n2", "output": "1\n5\n8\n11\n"}, {"in... | code_stdio |
[
{
"content": "B: Ebi-chan and Integer Sequences-\n\nproblem\n\nEbi-chan likes sequences. I especially like arithmetic progressions. This time, I decided to create a sequence that meets the following conditions.\n\n* Arithmetic progression of length n\n* When the i-th element of the sequence is defined as s_i, a... | [{"input": "2 36", "output": "1369\n"}, {"input": "11 54", "output": "305\n"}, {"input": "2 52", "output": "2809\n"}, {"input": "10 54", "output": "337\n"}, {"input": "2 58", "output": "3481\n"}, {"input": "2 39", "output": "1600\n"}, {"input": "2 13", "output": "196\n"}, {"input": "2 10", "output": "121\n"}, {"input":... | code_stdio |
[
{
"content": "Vasya's house is situated in a forest, and there is a mushroom glade near it. The glade consists of two rows, each of which can be divided into n consecutive cells. For each cell Vasya knows how fast the mushrooms grow in this cell (more formally, how many grams of mushrooms grow in this cell each... | [{"input": "6\n4 1 11 9 3 11\n12 32 19 12 19 11\n", "output": "1035\n"}, {"input": "6\n4 1 11 6 3 11\n12 32 19 12 19 11\n", "output": "1026\n"}, {"input": "6\n4 1 11 6 3 18\n12 32 19 12 19 11\n", "output": "1061\n"}, {"input": "6\n4 1 12 9 3 11\n12 20 19 12 19 11\n", "output": "917\n"}, {"input": "6\n4 1 12 9 3 11\n12 ... | code_stdio |
[
{
"content": "Roy and Biv have a set of n points on the infinite number line.\n\nEach point has one of 3 colors: red, green, or blue.\n\nRoy and Biv would like to connect all the points with some edges. Edges can be drawn between any of the two of the given points. The cost of an edge is equal to the distance b... | [{"input": "4\n1 G\n123123 R\n987987987 B\n1000000000 G\n", "output": "1012135134\n"}, {"input": "4\n1 G\n123123 R\n987987987 B\n1000000100 G\n", "output": "1012135334\n"}, {"input": "4\n2 G\n123123 R\n987987987 B\n1000000000 G\n", "output": "1012135132\n"}, {"input": "4\n1 G\n123123 R\n179925707 B\n1000000100 G\n", "o... | code_stdio |
[
{
"content": "Perhaps many have heard that the World Biathlon Championship has finished. Although our hero Valera was not present at this spectacular event himself and only watched it on TV, it excited him so much that he decided to enroll in a biathlon section.\n\nOf course, biathlon as any sport, proved very ... | [{"input": "15\n17 5\n-19 5\n-8 3\n27 2\n45 3\n36 2\n-32 2\n49 1\n-3 2\n-41 2\n-35 1\n-46 1\n-29 1\n33 1\n0 1\n50\n24 -4\n41 3\n37 3\n9 2\n38 -4\n-30 2\n-41 -5\n-9 -5\n-33 3\n0 2\n-20 -3\n-49 -4\n34 1\n-38 -2\n17 -1\n-33 3\n-17 4\n16 3\n-49 2\n-3 -4\n-9 2\n35 3\n37 -5\n0 0\n-46 -5\n48 1\n-22 -4\n-29 -5\n-41 4\n-11 0\n-... | code_stdio |
[
{
"content": "Snuke is going to open a contest named \"AtCoder s Contest\".\nHere, s is a string of length 1 or greater, where the first character is an uppercase English letter, and the second and subsequent characters are lowercase English letters.\nSnuke has decided to abbreviate the name of the contest as \... | [{"input": "AtCoder Beginner Contest\n", "output": "ABC\n"}, {"input": "AtCoder Befinner Contest", "output": "ABC\n"}, {"input": "AtCoder sennifeB Cpntest", "output": "AsC\n"}, {"input": "AtCoder rennigeB Contest", "output": "ArC\n"}, {"input": "AtCoder Aeifnnes Cpnsest", "output": "AAC\n"}, {"input": "AtCoder fBfinnes... | code_stdio |
[
{
"content": "Monocarp has got two strings $s$ and $t$ having equal length. Both strings consist of lowercase Latin letters \"a\" and \"b\". \n\nMonocarp wants to make these two strings $s$ and $t$ equal to each other. He can do the following operation any number of times: choose an index $pos_1$ in the string ... | [{"input": "101\nbabbbbabbbbaabbbbbbbabbbababababbbbbbbbabaababbababbaaabbababbbbbbbbbaabbbababbbbbabbbbbabbbaabbbaabb\nbbabbbbbbabbbbbbbbbbbabbbbbbbbbbabbabbbbbbbbbbbabbababbbabbabbbbbbbbbbbbbaabbbabbbbabbabbbbababbbbbab\n", "output": "20\n2 7\n12 13\n21 25\n27 29\n31 40\n42 43\n45 50\n54 55\n58 70\n71 77\n83 89\n93 9... | code_stdio |
[
{
"content": "Permutation p is an ordered set of integers p1, p2, ..., pn, consisting of n distinct positive integers not larger than n. We'll denote as n the length of permutation p1, p2, ..., pn.\n\nYour task is to find such permutation p of length n, that the group of numbers |p1 - p2|, |p2 - p3|, ..., |pn -... | [{"input": "18247 939\n", "output": "1 940 2 939 3 938 4 937 5 936 6 935 7 934 8 933 9 932 10 931 11 930 12 929 13 928 14 927 15 926 16 925 17 924 18 923 19 922 20 921 21 920 22 919 23 918 24 917 25 916 26 915 27 914 28 913 29 912 30 911 31 910 32 909 33 908 34 907 35 906 36 905 37 904 38 903 39 902 40 901 41 900 42 89... | code_stdio |
[
{
"content": "Who's interested in football?\nRayne Wooney has been one of the top players for his football club for the last few years. But unfortunately, he got injured during a game a few months back and has been out of play ever since.\nHe's got proper treatment and is eager to go out and play for his team a... | [{"input": "3\n4\n3 7 1 4 2 4\n5\n7 4 3 3 1\n5\n4 3 2 2 0", "output": "4\nUNFIT\nUNFIT\n"}, {"input": "3\n6\n1 1 -1 4 2 4\n5\n4 4 3 2 1\n5\n4 3 1 2 3", "output": "5\nUNFIT\n2\n"}, {"input": "3\n6\n1 1 -1 4 2 1\n5\n4 4 3 2 1\n5\n4 0 1 2 3", "output": "5\nUNFIT\n3\n"}, {"input": "3\n6\n3 7 1 4 2 4\n5\n5 4 3 2 1\n5\n4 3 1... | code_stdio |
[
{
"content": "The only difference between easy and hard versions is constraints.\n\nIvan plays a computer game that contains some microtransactions to make characters look cooler. Since Ivan wants his character to be really cool, he wants to use some of these microtransactions — and he won't start playing until... | [{"input": "78 36\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0\n1 52\n2 6\n9 43\n10 52\n4 63\n9 35\n10 67\n9 17\n3 43\n4 38\n1 27\n9 44\n6 74\n7 3\n8 18\n1 52\n1 68\n5 51\n5 2\n11 50\n1 72\n1 37\n8 64\n10 30\... | code_stdio |
[
{
"content": "Mike has a sequence A = [a1, a2, ..., an] of length n. He considers the sequence B = [b1, b2, ..., bn] beautiful if the gcd of all its elements is bigger than 1, i.e. <image>. \n\nMike wants to change his sequence in order to make it beautiful. In one move he can choose an index i (1 ≤ i < n), del... | [{"input": "9\n57 30 28 81 88 32 3 42 25\n", "output": "YES\n8\n"}, {"input": "9\n57 12 28 81 88 32 3 42 25\n", "output": "YES\n8\n"}, {"input": "9\n57 12 29 81 88 32 3 42 37\n", "output": "YES\n7\n"}, {"input": "9\n57 12 28 81 88 32 3 42 37\n", "output": "YES\n8\n"}, {"input": "9\n57 2 29 81 88 32 3 42 37\n", "output"... | code_stdio |
[
{
"content": "Peter is a person with erratic sleep habits. He goes to sleep at twelve o'lock every midnight. He gets up just after one hour of sleep on some days; he may even sleep for twenty-three hours on other days. His sleeping duration changes in a cycle, where he always sleeps for only one hour on the fir... | [{"input": "2\n-1 23\n3\n1 1\n1 1\n3 -1\n0", "output": "0\n"}, {"input": "2\n1 23\n3\n2 1\n10 1\n3 1\n0", "output": "3\n"}, {"input": "2\n-1 23\n3\n1 1\n2 0\n5 2\n0", "output": "2\n"}, {"input": "2\n-1 13\n3\n1 2\n2 1\n3 1\n0", "output": "2\n"}, {"input": "2\n-1 13\n3\n2 2\n2 1\n3 1\n0", "output": "2\n"}, {"input": "2\... | code_stdio |
[
{
"content": "Fox Ciel has a robot on a 2D plane. Initially it is located in (0, 0). Fox Ciel code a command to it. The command was represented by string s. Each character of s is one move operation. There are four move operations at all:\n\n * 'U': go up, (x, y) → (x, y+1); \n * 'D': go down, (x, y) → (x... | [{"input": "-1000000000 -1000000000\nDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDL\n", "output": "Yes\n"}, {"input": "1000000000 1000000000\nRURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURU\n", "output": "Yes\n"},... | code_stdio |
[
{
"content": "You are given an expression of the form $a{+}b$, where $a$ and $b$ are integers from $0$ to $9$. You have to evaluate it and print the result.\n\n\n-----Input-----\n\nThe first line contains one integer $t$ ($1 \\le t \\le 100$) — the number of test cases.\n\nEach test case consists of one line co... | [{"input": "100\n0+0\n0+1\n0+2\n0+3\n0+4\n0+5\n0+6\n0+7\n0+8\n0+9\n1+0\n1+1\n1+2\n1+3\n1+4\n1+5\n1+6\n1+7\n1+8\n1+9\n2+0\n2+1\n2+2\n2+3\n2+4\n2+5\n2+6\n2+7\n2+8\n2+9\n3+0\n3+1\n3+2\n3+3\n3+4\n3+5\n3+6\n3+7\n3+8\n3+9\n4+0\n4+1\n4+2\n4+3\n4+4\n4+5\n4+6\n4+7\n4+8\n4+9\n5+0\n5+1\n5+2\n5+3\n5+4\n5+5\n5+6\n5+7\n5+8\n5+9\n6+0... | code_stdio |
[
{
"content": "Leha decided to move to a quiet town Vičkopolis, because he was tired by living in Bankopolis. Upon arrival he immediately began to expand his network of hacked computers. During the week Leha managed to get access to n computers throughout the town. Incidentally all the computers, which were hack... | [{"input": "10\n877105545 939360757 849826701 845946140 733167691 265756841 967305000 1281921930 921301848 971203310\n", "output": "490950129\n"}, {"input": "10\n877105545 939360757 849826701 845946140 803128820 926787996 967305000 904694971 921301848 971203310\n", "output": "861364152\n"}, {"input": "10\n877105545 939... | code_stdio |
[
{
"content": "As we all know Barney's job is \"PLEASE\" and he has not much to do at work. That's why he started playing \"cups and key\". In this game there are three identical cups arranged in a line from left to right. Initially key to Barney's heart is under the middle cup. [Image] \n\nThen at one turn Barn... | [{"input": "12\n254904759290707697 475737283258450340 533306428548398547 442127134828578937 779740159015946254 272877594683860919 93000149670491971 632184275887310175 498293278222136720 551099726729989816 149940343283925029 989425634209891686\n", "output": "461895893/385687671\n"}, {"input": "12\n254904759290707697 475... | code_stdio |
[
{
"content": "You are given string $s$ of length $n$ consisting of 0-s and 1-s. You build an infinite string $t$ as a concatenation of an infinite number of strings $s$, or $t = ssss \\dots$ For example, if $s =$ 10010, then $t =$ 100101001010010...\n\nCalculate the number of prefixes of $t$ with balance equal ... | [{"input": "1\n439 -6100238\n100011110101001111000100101001001100010100010101001011100000110000000010011011111100010011100100000010011000110100111010100100100101101101100111100001010000010110000111011100000001110111100111110011110001001001100010110101100101011111010110010110101111001011000111010000101110100011010101101... | code_stdio |
[
{
"content": "Nauuo is a girl who loves writing comments.\n\nOne day, she posted a comment on Codeforces, wondering whether she would get upvotes or downvotes.\n\nIt's known that there were $x$ persons who would upvote, $y$ persons who would downvote, and there were also another $z$ persons who would vote, but ... | [{"input": "000 100 100\n", "output": "?\n"}, {"input": "100 100 100\n", "output": "?"}, {"input": "100 100 100\n", "output": "?"}, {"input": "101 0 100\n", "output": "+\n"}, {"input": "25 24 100\n", "output": "?\n"}, {"input": "123 29 43\n", "output": "+\n"}, {"input": "100 110 0\n", "output": "-\n"}, {"input": "60 11... | code_stdio |
[
{
"content": "The construction of subway in Bertown is almost finished! The President of Berland will visit this city soon to look at the new subway himself.\n\nThere are n stations in the subway. It was built according to the Bertown Transport Law:\n\n For each station i there exists exactly one train that go... | [{"input": "100\n98 52 63 2 18 96 31 58 84 40 41 45 66 100 46 71 26 48 81 20 73 91 68 76 13 93 17 29 64 95 79 21 55 75 19 85 54 51 89 78 15 87 43 59 36 1 90 35 65 56 62 28 86 5 82 49 3 99 33 9 92 32 74 69 27 22 77 16 44 94 34 6 57 70 23 12 61 25 8 11 67 47 83 88 10 14 30 7 97 60 42 37 24 38 53 50 4 80 72 39\n", "output... | code_stdio |
[
{
"content": "Bessie is out grazing on the farm, which consists of $n$ fields connected by $m$ bidirectional roads. She is currently at field $1$, and will return to her home at field $n$ at the end of the day.\n\nThe Cowfederation of Barns has ordered Farmer John to install one extra bidirectional road. The fa... | [{"input": "42 41 20\n8 34 12 13 38 3 9 10 18 16 2 26 24 17 32 21 4 27 15 39\n1 35\n35 8\n1 31\n31 34\n1 40\n40 12\n1 30\n30 13\n1 33\n33 38\n1 37\n37 3\n1 22\n22 9\n1 20\n20 10\n1 25\n25 18\n1 14\n14 16\n1 42\n42 7\n7 2\n42 11\n11 26\n42 29\n29 24\n42 36\n36 17\n42 41\n41 32\n42 23\n23 21\n42 28\n28 4\n42 5\n5 27\n42 ... | code_stdio |
[
{
"content": "There is a game that uses numbers called \"Fizz Buzz\". In this game, multiple players count the numbers one by one, starting with 1, and each player says only one number after the previous player. At that time, you must say \"Fizz\" if it is divisible by 3, \"Buzz\" if it is divisible by 5, and \... | [{"input": "5 7\n1\n-1\nFizz\n2\nzuzB\n5\n2\n16 5\n1\n4\n5\n7\n8\n0 0", "output": "3\n1 6 7 8 9 10 11 12 13 14 15 16\n"}, {"input": "14 7\n1\n0\nzzFi\n4\nBuzz\n11\n1\n3 5\n-1\n3\n8\n4\n3\n0 0", "output": "1 4 5 8 9 10 11 12 13 14\n3\n"}, {"input": "14 7\n1\n0\nzzFi\n4\nAuzz\n11\n1\n3 5\n-1\n3\n8\n4\n3\n0 0", "output": ... | code_stdio |
[
{
"content": "Chouti was doing a competitive programming competition. However, after having all the problems accepted, he got bored and decided to invent some small games.\n\nHe came up with the following game. The player has a positive integer $n$. Initially the value of $n$ equals to $v$ and the player is abl... | [{"input": "1000000000\n", "output": "1\n"}, {"input": "1000000000\n", "output": "1\n"}, {"input": "1236540828\n", "output": "1\n"}, {"input": "1102703100\n", "output": "1\n"}, {"input": "1266106036\n", "output": "1\n"}, {"input": "1000000010\n", "output": "1\n"}, {"input": "1709258177\n", "output": "1\n"}, {"input": "... | code_stdio |
[
{
"content": "It is said that a legendary treasure left by Mr. Yao is sleeping somewhere in Hachioji long ago. The treasure map, which is said to show its whereabouts, has been handed down by Yao's n descendants, divided into several pieces.\n\nNow, the descendants of Mr. Yao were trying to cooperate to obtain ... | [{"input": "4\n1 1\n2 0 -1\n2 4 2\n3 2 16 10\n0", "output": "-1\n"}, {"input": "4\n1 1\n2 0 0\n2 4 2\n3 2 16 10\n0", "output": "-1\n"}, {"input": "4\n1 1\n2 0 -1\n2 4 2\n3 2 16 2\n0", "output": "-1\n"}, {"input": "4\n1 1\n2 -1 3\n2 1 2\n3 3 4 10\n0", "output": "-1\n"}, {"input": "4\n1 1\n2 -1 3\n2 2 2\n3 3 4 10\n0", "o... | code_stdio |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.