messages listlengths 1 1 | ground_truth stringlengths 156 726k | dataset stringclasses 1
value |
|---|---|---|
[
{
"content": "One day Squidward, Spongebob and Patrick decided to go to the beach. Unfortunately, the weather was bad, so the friends were unable to ride waves. However, they decided to spent their time building sand castles.\n\nAt the end of the day there were n castles built by friends. Castles are numbered f... | [{"input": "101\n1 50 170 269 214 153 132 234 181 188 180 225 226 200 197 122 181 168 160 220 223 160 235 94 257 145 199 235 102 146 119 60 109 134 209 260 210 191 180 271 236 195 155 169 166 143 106 102 208 137 278 269 156 251 198 165 111 198 151 213 256 121 276 163 179 285 104 99 139 122 188 184 215 242 244 115 304 2... | code_stdio |
[
{
"content": "Problem H: Squid Multiplication\n\nSquid Eiko loves mathematics. Especially she loves to think about integer. One day, Eiko found a math problem from a website.\n\n\"A sequence b ={ai + aj | i < j } is generated from a sequence a ={a0 , ... , an | ai is even if i is 0, otherwise ai is odd}. Given ... | [{"input": "3\n6 10 26 15 27 35\n2\n30 42 35\n0", "output": "2\n3 5 13\n6\n5 7\n"}, {"input": "3\n6 10 28 15 31 35\n2\n30 42 35\n0", "output": "2\n3 5 14\n6\n5 7\n"}, {"input": "3\n6 10 26 15 27 43\n2\n30 42 35\n0", "output": "2\n3 5 13\n6\n5 7\n"}, {"input": "3\n6 10 14 15 27 35\n2\n30 42 35\n0", "output": "2\n3 5 7\n... | code_stdio |
[
{
"content": "This is a story of a world somewhere far from the earth. In this world, the land is parted into a number of countries ruled by empires. This world is not very peaceful: they have been involved in army race.\n\nThey are competing in production of missiles in particular. Nevertheless, no countries h... | [{"input": "3 3\n3 4 1 1\n2 1 5\n2 3 3\n3 6\n3 2 5 1\n2 1 5\n2 3 3\n0 0", "output": "Yes\nYes\n"}, {"input": "3 6\n3 8 1 1\n2 2 6\n2 2 3\n3 3\n3 2 5 1\n2 1 11\n2 3 3\n0 0", "output": "Yes\nNo\n"}, {"input": "3 2\n3 11 1 1\n2 2 8\n2 2 3\n3 5\n3 4 5 1\n2 0 11\n2 3 3\n0 0", "output": "No\nNo\n"}, {"input": "3 3\n3 4 1 1\n... | code_stdio |
[
{
"content": "Because of budget cuts one IT company established new non-financial reward system instead of bonuses.\n\nTwo kinds of actions are rewarded: fixing critical bugs and suggesting new interesting features. A man who fixed a critical bug gets \"I fixed a critical bug\" pennant on his table. A man who s... | [{"input": "444\n", "output": "2159776046970635520\n"}, {"input": "498\n", "output": "5392730685240975000"}, {"input": "500\n", "output": "5567867859752100000"}, {"input": "500\n", "output": "5567867859752100000"}, {"input": "498\n", "output": "5392730685240975000"}, {"input": "308\n", "output": "117307091246785440\n"}... | code_stdio |
[
{
"content": "Roma is playing a new expansion for his favorite game World of Darkraft. He made a new character and is going for his first grind.\n\nRoma has a choice to buy exactly one of n different weapons and exactly one of m different armor sets. Weapon i has attack modifier a_i and is worth ca_i coins, and... | [{"input": "10 10 10\n51 87\n68 743\n82 1284\n73 936\n55 242\n89 1554\n58 357\n66 666\n62 512\n51 87\n92 1670\n56 280\n56 280\n91 1631\n77 1091\n89 1554\n61 473\n98 1901\n77 1091\n77 1091\n86 15 386\n43 58 386\n68 33 386\n39 62 386\n95 6 386\n74 27 386\n94 7 386\n17 84 386\n97 4 386\n45 56 386\n", "output": "212\n"}, {... | code_stdio |
[
{
"content": "We guessed some integer number $x$. You are given a list of almost all its divisors. Almost all means that there are all divisors except $1$ and $x$ in the list.\n\nYour task is to find the minimum possible integer $x$ that can be the guessed number, or say that the input data is contradictory and... | [{"input": "25\n2\n999389 999917\n2\n999307 999613\n2\n999529 999611\n2\n999221 999853\n2\n999683 999433\n2\n999907 999749\n2\n999653 999499\n2\n999769 999931\n2\n999809 999287\n2\n999233 999239\n2\n999553 999599\n2\n999371 999763\n2\n999491 999623\n2\n999961 999773\n2\n999671 999269\n2\n999883 999437\n2\n999953 999331... | code_stdio |
[
{
"content": "According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most d centimeters. Captain Bob has n soldiers in his detachment. Their heights are a1, a2, ..., an centimete... | [{"input": "100 100\n51 93 101 960 2 477 213 129 663 925 254 78 1486 274 160 481 132 156 589 372 3 57 210 298 1771 7 359 468 254 406 202 929 221 366 552 97 555 29 634 118 539 140 992 854 7 163 134 103 940 30 409 1003 564 43 555 79 107 40 23 103 643 171 310 382 770 288 18 189 570 177 29 54 855 171 451 291 563 935 620 18... | code_stdio |
[
{
"content": "Given are a sequence of N integers A_1, A_2, \\ldots, A_N and a positive integer S.\n\nFor a pair of integers (L, R) such that 1\\leq L \\leq R \\leq N, let us define f(L, R) as follows:\n\n - f(L, R) is the number of sequences of integers (x_1, x_2, \\ldots , x_k) such that L \\leq x_1 < x_2 < \\... | [{"input": "2896 1518\n498 2010 1723 2089 76 1224 1972 612 465 880 283 143 1538 372 841 1998 292 2096 423 728 2199 807 2325 1185 1664 2349 531 40 1039 2006 2179 1842 2954 2847 2540 1045 2697 2112 1625 2062 631 2136 544 2420 1199 2592 2820 802 1157 383 1164 617 1513 2876 2625 947 1720 1640 1772 2137 282 754 1325 2663 27... | code_stdio |
[
{
"content": "Alyona's mother wants to present an array of n non-negative integers to Alyona. The array should be special. \n\nAlyona is a capricious girl so after she gets the array, she inspects m of its subarrays. Subarray is a set of some subsequent elements of the array. The i-th subarray is described with... | [{"input": "15 10\n1 9\n4 8\n4 8\n5 9\n1 9\n3 5\n1 6\n1 9\n2 6\n6 9\n", "output": "3\n0 1 2 0 1 2 0 1 2 0 1 2 0 1 2\n"}, {"input": "15 10\n1 9\n4 8\n4 8\n5 9\n1 9\n3 5\n1 6\n1 9\n4 6\n6 9\n", "output": "3\n0 1 2 0 1 2 0 1 2 0 1 2 0 1 2\n"}, {"input": "15 10\n1 9\n4 8\n4 8\n5 9\n1 9\n3 5\n1 6\n1 9\n1 6\n6 9\n", "output"... | code_stdio |
[
{
"content": "Polycarpus has postcards and photos hung in a row on the wall. He decided to put them away to the closet and hang on the wall a famous painter's picture. Polycarpus does it like that: he goes from the left to the right and removes the objects consecutively. As Polycarpus doesn't want any mix-ups t... | [{"input": "CPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCP\n", "output": "100\n"}, {"input": "PPPPPPPPPPPPPPPPPPPPPPPCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCPPPPPCCCPPPPCCCCCPCC\n", "output": "23\n"}, {"input": "CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC... | code_stdio |
[
{
"content": "There is a square painted on a piece of paper, the square's side equals n meters. John Doe draws crosses on the square's perimeter. John paints the first cross in the lower left corner of the square. Then John moves along the square's perimeter in the clockwise direction (first upwards, then to th... | [{"input": "8\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 13\n", "output": "4000000001\n4000000001\n4000000001\n4000000001\n4000000001\n4000000001\n4000000001\n27\n"}, {"input": "8\n1000000000 1000000000 1000000000 1000000100 1000000000 1000000000 1000000000 13\n", "output": "400000000... | code_stdio |
[
{
"content": "[INSPION FullBand Master - INSPION](https://www.youtube.com/watch?v=kwsciXm_7sA)\n\n[INSPION - IOLITE-SUNSTONE](https://www.youtube.com/watch?v=kwsciXm_7sA)\n\nOn another floor of the A.R.C. Markland-N, the young man Simon \"Xenon\" Jackson, takes a break after finishing his project early (as alwa... | [{"input": "50\n21 10\n30 22\n3 37\n37 32\n4 27\n18 10\n2 30\n29 19\n6 37\n12 39\n47 25\n41 49\n45 9\n25 48\n16 14\n10 7\n33 28\n3 31\n34 16\n35 37\n27 40\n45 16\n29 44\n16 15\n26 3\n1 12\n2 13\n15 21\n43 14\n9 33\n44 15\n46 1\n38 5\n15 5\n1 32\n42 35\n20 27\n23 12\n1 16\n15 17\n36 50\n13 8\n49 45\n11 2\n24 4\n36 15\n1... | code_stdio |
[
{
"content": "You are given an array $a$ of $n$ integers and an integer $s$. It is guaranteed that $n$ is odd.\n\nIn one operation you can either increase or decrease any single element by one. Calculate the minimum number of operations required to make the median of the array being equal to $s$.\n\nThe median ... | [{"input": "7 33\n21 15 12 11 20 19 12\n", "output": "57\n"}, {"input": "7 20\n2 15 12 11 20 19 12\n", "output": "14\n"}, {"input": "7 20\n1 15 12 11 29 20 12\n", "output": "13\n"}, {"input": "7 20\n1 13 12 11 29 20 12\n", "output": "15\n"}, {"input": "7 20\n1 13 10 15 29 20 12\n", "output": "12\n"}, {"input": "7 20\n1... | code_stdio |
[
{
"content": "For a given weighted graph $G = (V, E)$, find the shortest path from a source to each vertex. For each vertex $u$, print the total weight of edges on the shortest path from vertex $0$ to $u$.\n\nConstraints\n\n* $1 \\leq n \\leq 10,000$\n* $0 \\leq c_i \\leq 100,000$\n* $|E| < 500,000$\n* All vert... | [{"input": "5\n0 3 2 4 3 1 1 2\n1 2 3 3 3 4\n2 3 0 3 3 2 4 1\n3 4 0 1 0 -1 1 0 3 3\n4 2 0 1 3 3", "output": "0 0\n1 1\n2 4\n3 1\n4 5\n"}, {"input": "5\n0 3 2 4 3 1 1 2\n1 2 1 4 3 4\n2 3 0 10 3 0 4 1\n3 4 0 1 0 1 1 1 1 3\n4 2 2 1 3 3", "output": "0 0\n1 2\n2 4\n3 1\n4 5\n"}, {"input": "5\n0 3 2 3 3 2 1 0\n1 2 0 5 4 4\n2... | code_stdio |
[
{
"content": "Dima is a beginner programmer. During his working process, he regularly has to repeat the following operation again and again: to remove every second element from the array. One day he has been bored with easy solutions of this problem, and he has come up with the following extravagant algorithm.\... | [{"input": "15 12\n2\n10\n5\n2\n8\n2\n8\n6\n4\n10\n12\n1\n", "output": "12\n13\n3\n12\n10\n12\n10\n14\n9\n13\n11\n1\n"}, {"input": "15 12\n9\n10\n5\n2\n8\n2\n8\n6\n4\n10\n12\n1\n", "output": "5\n13\n3\n12\n10\n12\n10\n14\n9\n13\n11\n1\n"}, {"input": "15 12\n9\n10\n5\n2\n7\n2\n8\n6\n4\n10\n12\n1\n", "output": "5\n13\n3\... | code_stdio |
[
{
"content": "Given is a three-digit integer N. Does N contain the digit 7?\nIf so, print Yes; otherwise, print No.\n\n-----Constraints-----\n - 100 \\leq N \\leq 999\n\n-----Input-----\nInput is given from Standard Input in the following format:\nN\n\n-----Output-----\nIf N contains the digit 7, print Yes; oth... | [{"input": "117\n", "output": "Yes\n"}, {"input": "777\n", "output": "Yes\n"}, {"input": "974\n", "output": "Yes\n"}, {"input": "477\n", "output": "Yes\n"}, {"input": "758\n", "output": "Yes\n"}, {"input": "767\n", "output": "Yes\n"}, {"input": "779\n", "output": "Yes\n"}, {"input": "1760", "output": "Yes\n"}, {"input"... | code_stdio |
[
{
"content": "You are given two binary strings $x$ and $y$, which are binary representations of some two integers (let's denote these integers as $f(x)$ and $f(y)$). You can choose any integer $k \\ge 0$, calculate the expression $s_k = f(x) + f(y) \\cdot 2^k$ and write the binary representation of $s_k$ in rev... | [{"input": "4\n1010\n11\n10001\n110\n1\n1\n1010101010101\n11110000\n", "output": "1\n3\n0\n0\n"}, {"input": "4\n1010\n11\n10001\n110\n1\n1\n1010101010100\n11110000\n", "output": "1\n3\n0\n0\n"}, {"input": "4\n1010\n11\n10001\n110\n1\n1\n1010101010100\n11100000\n", "output": "1\n3\n0\n1\n"}, {"input": "4\n1010\n11\n1000... | code_stdio |
[
{
"content": "You are given an image, that can be represented with a 2-d n by m grid of pixels. Each pixel of the image is either on or off, denoted by the characters \"0\" or \"1\", respectively. You would like to compress this image. You want to choose an integer k > 1 and split the image into k by k blocks. ... | [{"input": "3 5\n00100\n10110\n11001\n", "output": "5\n"}, {"input": "3 5\n00100\n00110\n11001\n", "output": "4\n"}, {"input": "3 5\n00100\n00110\n11011\n", "output": "5\n"}, {"input": "3 5\n00100\n00110\n01001\n", "output": "3\n"}, {"input": "3 5\n00100\n00110\n11111\n", "output": "6\n"}, {"input": "3 5\n00110\n00110\... | code_stdio |
[
{
"content": "Let's assume that v(n) is the largest prime number, that does not exceed n;\n\n u(n) is the smallest prime number strictly greater than n. \n\nFind $\\sum_{i = 2}^{n} \\frac{1}{v(i) u(i)}$.\n\n\n-----Input-----\n\nThe first line contains integer t (1 ≤ t ≤ 500) — the number of testscases. \n\nEa... | [{"input": "6\n885\n419\n821\n635\n63\n480\n", "output": "781453/1566442\n175559/352798\n674039/1351366\n403199/808942\n3959/8174\n232303/466546\n"}, {"input": "6\n885\n419\n821\n635\n63\n480\n", "output": "781453/1566442\n175559/352798\n674039/1351366\n403199/808942\n3959/8174\n232303/466546\n"}, {"input": "6\n1656\n4... | code_stdio |
[
{
"content": "There is little time left before the release of the first national operating system BerlOS. Some of its components are not finished yet — the memory manager is among them. According to the developers' plan, in the first release the memory manager will be very simple and rectilinear. It will suppor... | [{"input": "47 43\nerase 1\nalloc 95\nalloc 53\nerase 2\ndefragment\nalloc 100\nerase 4\nerase 2\nerase -849472053\ndefragment\nerase -638355221\nalloc 90\nerase 3\nerase 2\ndefragment\nalloc 17\nerase 5\ndefragment\nerase 6\ndefragment\nerase 3\ndefragment\ndefragment\nalloc 99\nalloc 69\nalloc 80\nerase 9\nerase 5\nd... | code_stdio |
[
{
"content": "Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. \n\nArrays have fallen out of Chef's good books, and he plans to destroy all arrays he possesses. He is left with the last array A, consisting of N positive integers. In order to destroy the array, he can perform the fo... | [{"input": "3\n2\n1 1\n2\n1 1\n3\n1 2 -1", "output": "2\n2\n2\n"}, {"input": "3\n2\n1 1\n2\n1 2\n3\n1 2 -1", "output": "2\n1\n2\n"}, {"input": "3\n2\n1 2\n2\n1 1\n3\n1 2 -1", "output": "1\n2\n2\n"}, {"input": "3\n2\n2 2\n2\n1 1\n3\n1 2 -1", "output": "2\n2\n2\n"}, {"input": "3\n2\n1 1\n2\n0 2\n3\n1 2 -1", "output": "2\... | code_stdio |
[
{
"content": "Thanos sort is a supervillain sorting algorithm, which works as follows: if the array is not sorted, snap your fingers* to remove the first or the second half of the items, and repeat the process.\n\nGiven an input array, what is the size of the longest sorted array you can obtain from it using Th... | [{"input": "16\n12 17 18 51 49 54 107 59 68 74 88 91 98 100 66 49\n", "output": "4\n"}, {"input": "16\n12 17 18 51 52 54 56 59 68 74 88 91 98 100 66 49\n", "output": "8\n"}, {"input": "16\n12 17 18 51 52 54 56 59 68 74 88 91 98 100 66 49\n", "output": "8\n"}, {"input": "16\n12 17 18 51 49 54 56 59 68 74 88 91 98 100 66... | code_stdio |
[
{
"content": "Write a program that takes in a letterclass ID of a ship and display the equivalent string class description of the given ID. Use the table below.\n\nClass ID Ship ClassB or bBattleShipC or cCruiserD or dDestroyerF or fFrigate\n\n-----Input-----\n\nThe first line contains an integer T, the total n... | [{"input": "3 \nB\nb\nB", "output": "BattleShip\nBattleShip\nBattleShip\n"}, {"input": "3 \nD\nb\nB", "output": "Destroyer\nBattleShip\nBattleShip\n"}, {"input": "3 \nB\nb\nD", "output": "BattleShip\nBattleShip\nDestroyer\n"}, {"input": "3 \nB\nd\nB", "output": "BattleShip\nDestroyer\nBattleShip\n"}, {"input": "3 \nB\n... | code_stdio |
[
{
"content": "You are given a text of single-space separated words, consisting of small and capital Latin letters.\n\nVolume of the word is number of capital letters in the word. Volume of the text is maximum volume of all words in the text.\n\nCalculate the volume of the given text.\n\n\n-----Input-----\n\nThe... | [{"input": "200\nLBmJKQLCKUgtTxMoDsEerwvLOXsxASSydOqWyULsRcjMYDWdDCgaDvBfATIWPVSXlbcCLHPYahhxMEYUiaxoCebghJqvmRnaNHYTKLeOiaLDnATPZAOgSNfBzaxLymTGjfzvTegbXsAthTxyDTcmBUkqyGlVGZhoazQzVSoKbTFcCRvYsgSCwjGMxBfWEwMHuagTBxkz\n", "output": "105\n"}, {"input": "200\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA... | code_stdio |
[
{
"content": "Dima loves Inna very much. He decided to write a song for her. Dima has a magic guitar with n strings and m frets. Dima makes the guitar produce sounds like that: to play a note, he needs to hold one of the strings on one of the frets and then pull the string. When Dima pulls the i-th string holdi... | [{"input": "11 11 9 11\n1 1 1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 2 2 1\n1 1 1 1 1 1 1 1 3 1 1\n1 1 1 1 1 1 1 3 1 1 1\n1 1 1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1 1 1\n1 1 1 2 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1 1 1\n3 3 3 3 3 3 3 3 3 2 2\n", "output": "14\n"}... | code_stdio |
[
{
"content": "Snuke has decided to play with a six-sided die. Each of its six sides shows an integer 1 through 6, and two numbers on opposite sides always add up to 7.\nSnuke will first put the die on the table with an arbitrary side facing upward, then repeatedly perform the following operation:\n - Operation:... | [{"input": "999999999999990\n", "output": "181818181818180\n"}, {"input": "999999999999991\n", "output": "181818181818181\n"}, {"input": "999999999999996\n", "output": "181818181818181\n"}, {"input": "999999999999997\n", "output": "181818181818182\n"}, {"input": "49247635594153\n", "output": "8954115562574\n"}, {"input... | code_stdio |
[
{
"content": "We have a 3 \\times 3 grid. A number c_{i, j} is written in the square (i, j), where (i, j) denotes the square at the i-th row from the top and the j-th column from the left.\n\nAccording to Takahashi, there are six integers a_1, a_2, a_3, b_1, b_2, b_3 whose values are fixed, and the number writt... | [{"input": "19 -1 0\n2 3 6\n4 -4 -1", "output": "No\n"}, {"input": "12 -1 3\n2 2 3\n2 -4 2", "output": "No\n"}, {"input": "12 -1 0\n2 2 3\n2 -4 2", "output": "No\n"}, {"input": "12 -1 0\n2 2 3\n4 -4 2", "output": "No\n"}, {"input": "12 -1 0\n2 2 3\n4 -4 0", "output": "No\n"}, {"input": "12 -1 0\n2 2 3\n4 -4 1", "output... | code_stdio |
[
{
"content": "Mr. Kitayuta has kindly given you a string s consisting of lowercase English letters. You are asked to insert exactly one lowercase English letter into s to make it a palindrome. A palindrome is a string that reads the same forward and backward. For example, \"noon\", \"testset\" and \"a\" are all... | [{"input": "lsdijfjisl\n", "output": "lsdijfjidsl\n"}, {"input": "lsdijfjisl\n", "output": "lsdijfjidsl\n"}, {"input": "lsdijfjisl\n", "output": "lsdijfjidsl\n"}, {"input": "lsdijgjisl\n", "output": "lsdijgjidsl\n"}, {"input": "nqwcvcwqn\n", "output": "nqwcvvcwqn\n"}, {"input": "jewiiwefj\n", "output": "jfewiiwefj\n"},... | code_stdio |
[
{
"content": "Prize\n\nSegtree entered a programming contest with a team of $ N $ and won a $ K $ yen prize! I'm trying to distribute this prize now.\n\nEach $ N $ team member, including Segtree, is numbered from $ 1 $ to $ N $ in order of ability. Segtree is $ 1 $.\n\nIf the prize amount of $ i $'s teammate $ ... | [{"input": "48 109", "output": "56\n"}, {"input": "12 100", "output": "51\n"}, {"input": "1 100", "output": "100\n"}, {"input": "8 203", "output": "103\n"}, {"input": "1 110", "output": "110\n"}, {"input": "11 152", "output": "78\n"}, {"input": "1 173", "output": "173\n"}, {"input": "8 253", "output": "127\n"}, {"input... | code_stdio |
[
{
"content": "There was a powerful school where powerful people gathered. At the athletic meet of the powerful school, powerful people march in a formation.\n\nWhile the powerhouses always want to show off their power, most of them don't want to walk on their own. So I thought that some of them would be at the ... | [{"input": "3\n156 120\n100 50\n80 100", "output": "1\n"}, {"input": "3\n156 120\n100 50\n80 000", "output": "1\n"}, {"input": "3\n156 159\n100 50\n80 000", "output": "1\n"}, {"input": "3\n156 22\n100 50\n152 000", "output": "1\n"}, {"input": "3\n156 11\n100 50\n80 000", "output": "1\n"}, {"input": "3\n156 22\n100 50\n... | code_stdio |
[
{
"content": "Petya is a big fan of mathematics, especially its part related to fractions. Recently he learned that a fraction $\\frac{a}{b}$ is called proper iff its numerator is smaller than its denominator (a < b) and that the fraction is called irreducible if its numerator and its denominator are coprime (t... | [{"input": "1000\n", "output": "499 501\n"}, {"input": "1000\n", "output": "499 501\n"}, {"input": "1120\n", "output": "559 561\n"}, {"input": "1010\n", "output": "503 507\n"}, {"input": "1200\n", "output": "599 601\n"}, {"input": "1764\n", "output": "881 883\n"}, {"input": "1729\n", "output": "864 865\n"}, {"input": "... | code_stdio |
[
{
"content": "Snuke, who loves animals, built a zoo.\nThere are N animals in this zoo. They are conveniently numbered 1 through N, and arranged in a circle.\nThe animal numbered i (2≤i≤N-1) is adjacent to the animals numbered i-1 and i+1. Also, the animal numbered 1 is adjacent to the animals numbered 2 and N, ... | [{"input": "10\noxooxoxoox\n", "output": "SSWWSSSWWS\n"}, {"input": "10\nxooxoxooxo", "output": "SWWSSSWWSS\n"}, {"input": "10\nxxooxoxooo", "output": "SWSWWWSSSS\n"}, {"input": "10\noxooooxxox", "output": "SSWWSWWWWS\n"}, {"input": "10\nxoxxooooxo", "output": "SWWWWSWWSS\n"}, {"input": "10\noooxoxooxx", "output": "SSS... | code_stdio |
[
{
"content": "To make a paper airplane, one has to use a rectangular piece of paper. From a sheet of standard size you can make $s$ airplanes.\n\nA group of $k$ people decided to make $n$ airplanes each. They are going to buy several packs of paper, each of them containing $p$ sheets, and then distribute the sh... | [{"input": "10000 10000 1 1\n", "output": "100000000\n"}, {"input": "10000 10000 1 1\n", "output": "100000000\n"}, {"input": "10000 10000 3 2\n", "output": "16670000\n"}, {"input": "10000 10000 3 2\n", "output": "16670000\n"}, {"input": "10000 10000 2 4\n", "output": "12500000\n"}, {"input": "10000 10000 1 4\n", "outpu... | code_stdio |
[
{
"content": "Fox Ciel is playing a game. In this game there is an infinite long tape with cells indexed by integers (positive, negative and zero). At the beginning she is standing at the cell 0.\n\nThere are also n cards, each card has 2 attributes: length l_{i} and cost c_{i}. If she pays c_{i} dollars then s... | [{"input": "35\n512 268435456 8 128 134217728 8192 33554432 33554432 536870912 512 65536 1048576 32768 512 524288 1024 536870912 536870912 16 32 33554432 134217728 2 16 16777216 8192 262144 65536 33554432 128 4096 2097152 33554432 2097152 2\n36157 67877 79710 63062 12683 36255 61053 83828 93590 74236 5281 28143 7350 45... | code_stdio |
[
{
"content": "<!--\n\nProblem B\n\n-->\n\nOn-Screen Keyboard\n\nYou are to input a string with an OSK (on-screen keyboard). A remote control with five buttons, four arrows and an OK (Fig. B-1), is used for the OSK. Find the minimum number of button presses required to input a given string with the given OSK.\n\... | [{"input": "3 9\nABCDEFGHI\nJKLMNOPQR\nSTUVWXYZ_\nICPC\n5 11\n___________\n____A______\n________M__\n___________\n_C_________\nACM\n4 21\n1_2_3_4_5_6_7_8_9_0_-\nQqWwEeRrTtYyUuIiOoPp@\nAaSsDdFfGgHhJjKkLl;^:\nZzXxCcVvBbNnMm,_._/__\nICPC2019,AsiaYokohamaRegional,QualificationRound\n0 0", "output": "28\n23\n493\n"}, {"inpu... | code_stdio |
[
{
"content": "There is a house with $n$ flats situated on the main street of Berlatov. Vova is watching this house every night. The house can be represented as an array of $n$ integer numbers $a_1, a_2, \\dots, a_n$, where $a_i = 1$ if in the $i$-th flat the light is on and $a_i = 0$ otherwise.\n\nVova thinks t... | [{"input": "100\n0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 -1 1 0\n", "output": "24\n"}, {"input": "100\n0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0... | code_stdio |
[
{
"content": "10^{10^{10}} participants, including Takahashi, competed in two programming contests. In each contest, all participants had distinct ranks from first through 10^{10^{10}}-th.\n\nThe score of a participant is the product of his/her ranks in the two contests.\n\nProcess the following Q queries:\n\n*... | [{"input": "8\n1 4\n10 5\n3 3\n4 11\n8 9\n22 11\n8 36\n314159265 358979323", "output": "1\n12\n4\n11\n14\n29\n31\n671644785\n"}, {"input": "8\n1 4\n10 5\n3 3\n4 20\n8 9\n22 40\n8 36\n314159265 358979323", "output": "1\n12\n4\n15\n14\n57\n31\n671644785\n"}, {"input": "8\n1 4\n10 5\n3 3\n4 11\n8 9\n22 11\n8 18\n314159265... | code_stdio |
[
{
"content": "Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thus, by converting the number 475 from decimal to hexad... | [{"input": "2\n110111100000101101101011001110100111011001000000000000000000\n", "output": "1000000000000000000"}, {"input": "2\n110111100000101101101011001110100111011001000000000000000000\n", "output": "1000000000000000000"}, {"input": "2\n1110110101111000010001011110101001011001110000000010110010\n", "output": "26736... | code_stdio |
[
{
"content": "Little penguin Polo loves his home village. The village has n houses, indexed by integers from 1 to n. Each house has a plaque containing an integer, the i-th house has a plaque containing integer pi (1 ≤ pi ≤ n).\n\nLittle penguin Polo loves walking around this village. The walk looks like that. ... | [{"input": "1000 8\n", "output": "339760446\n"}, {"input": "1000 6\n", "output": "834332109\n"}, {"input": "1000 1\n", "output": "760074701\n"}, {"input": "1000 5\n", "output": "583047503\n"}, {"input": "1000 2\n", "output": "675678679\n"}, {"input": "1000 4\n", "output": "660270610\n"}, {"input": "1000 3\n", "output":... | code_stdio |
[
{
"content": "Some dwarves that are finishing the StUDY (State University for Dwarven Youngsters) Bachelor courses, have been told \"no genome, no degree\". That means that all dwarves should write a thesis on genome. Dwarven genome is far from simple. It is represented by a string that consists of lowercase La... | [{"input": "aaaabcccca\naaaadccccb\n", "output": "NO\n"}, {"input": "aaaabcccca\naaaadccdcb\n", "output": "NO\n"}, {"input": "accccbaaaa\naaaadccdcb\n", "output": "NO\n"}, {"input": "rtfabanpc\natfabrnpc\n", "output": "YES\n"}, {"input": "rtfabanpc\natfrbanpc\n", "output": "YES\n"}, {"input": "qxolmbkkt\naovlajmlf\n", ... | code_stdio |
[
{
"content": "Takahashi is hosting an sports meet. There are N people who will participate. These people are conveniently numbered 1 through N. Also, there are M options of sports for this event. These sports are numbered 1 through M. Among these options, Takahashi will select one or more sports (possibly all) ... | [{"input": "2 5\n5 1 3 4 2\n2 5 3 1 4\n2 3 1 10 10\n2 5 4 3 1", "output": "1\n"}, {"input": "2 5\n5 1 3 4 2\n2 5 3 1 4\n2 3 1 6 10\n2 5 4 3 1", "output": "1\n"}, {"input": "2 5\n5 1 3 4 2\n2 5 3 1 4\n2 3 1 6 10\n2 5 4 2 1", "output": "1\n"}, {"input": "2 5\n5 1 3 4 2\n2 5 3 1 4\n2 3 1 6 10\n2 5 3 3 1", "output": "1\n"}... | code_stdio |
[
{
"content": "The Bubble Cup hypothesis stood unsolved for $130$ years. Who ever proves the hypothesis will be regarded as one of the greatest mathematicians of our time! A famous mathematician Jerry Mao managed to reduce the hypothesis to this problem:\n\nGiven a number $m$, how many polynomials $P$ with coeff... | [{"input": "100\n891 894 462 899 163 868 418 903 31 333 670 32 705 561 505 920 414 81 723 603 513 25 896 879 703 415 799 271 440 8 596 207 296 116 458 646 781 842 963 174 157 747 207 996 361 371 721 447 566 438 566 449 522 176 79 740 757 156 436 296 23 704 542 572 455 886 962 194 219 301 437 315 122 513 299 468 760 133... | code_stdio |
[
{
"content": "Little Susie listens to fairy tales before bed every day. Today's fairy tale was about wood cutters and the little girl immediately started imagining the choppers cutting wood. She imagined the situation that is described below.\n\nThere are n trees located along the road at points with coordinate... | [{"input": "67\n1 1\n3 8\n4 10\n7 8\n9 2\n10 1\n11 5\n12 8\n13 4\n16 6\n18 3\n19 3\n22 5\n24 6\n27 5\n28 3\n29 3\n30 5\n32 5\n33 10\n34 7\n35 8\n36 5\n41 3\n42 2\n43 5\n46 4\n48 4\n49 9\n52 4\n53 9\n55 1\n56 4\n59 7\n68 7\n69 4\n71 9\n72 10\n74 5\n76 4\n77 9\n80 7\n81 9\n82 5\n83 5\n84 9\n85 7\n86 9\n87 4\n88 7\n89 10\... | code_stdio |
[
{
"content": "Kaavi, the mysterious fortune teller, deeply believes that one's fate is inevitable and unavoidable. Of course, she makes her living by predicting others' future. While doing divination, Kaavi believes that magic spells can provide great power for her to see the future. [Image] \n\nKaavi has a str... | [{"input": "babbaaababbbbabbaaaababbbaabababbaabbaababbaaabaabbabaabbaababababbaabaaabaaaaababbaabaaaaabaabbabaaababbbb\nbbaabbbbabbbbaaaaaababbbabaaabbbbabababbbaabbbbbabaababbaabaaabaabbababababaaaaabaabbabaaabaaaaaaaaaaaaabbb\n", "output": "284471294\n"}, {"input": "babbaaababbbbabbaaaababbbaabababbaabbaababbaaabaab... | code_stdio |
[
{
"content": "This winter is so cold in Nvodsk! A group of n friends decided to buy k bottles of a soft drink called \"Take-It-Light\" to warm up a bit. Each bottle has l milliliters of the drink. Also they bought c limes and cut each of them into d slices. After that they found p grams of salt.\n\nTo make a to... | [{"input": "115 1000 1000 1000 1000 1000 17 15\n", "output": "0\n"}, {"input": "1 1000 1000 1000 1000 1000 1 1\n", "output": "1000\n"}, {"input": "1 1000 1001 1000 1000 1000 1 1\n", "output": "1000\n"}, {"input": "82 1000 1000 1000 1000 1000 17 15\n", "output": "0\n"}, {"input": "82 1010 1000 1000 1000 1000 17 15\n", "... | code_stdio |
[
{
"content": "Two chess pieces, a rook and a knight, stand on a standard chessboard 8 × 8 in size. The positions in which they are situated are known. It is guaranteed that none of them beats the other one.\n\nYour task is to find the number of ways to place another knight on the board so that none of the three... | [{"input": "c1\nd2\n", "output": "42\n"}, {"input": "g1\ne6\n", "output": "39\n"}, {"input": "h8\ng2\n", "output": "43\n"}, {"input": "a8\nf1\n", "output": "42\n"}, {"input": "e4\nc1\n", "output": "37\n"}, {"input": "b6\ng7\n", "output": "39\n"}, {"input": "a4\nd1\n", "output": "42\n"}, {"input": "h6\na1\n", "output": ... | code_stdio |
[
{
"content": "Example\n\nInput\n\n1\n\n\nOutput\n\n)(\n\nWrite Python code to solve this problem. Your program should read the input from stdin and write the output to stdout. Enclose your complete solution in a single ```python code block.",
"role": "user"
}
] | [{"input": "321", "output": ")))))))))))))))))))))())))((((((((((((((((((((((((\n"}, {"input": "222", "output": "))))))))))))()))))))))((((((((((((((((((((\n"}, {"input": "193", "output": ")))()))))))))))))))))(((((((((((((((((((\n"}, {"input": "180", "output": ")))))))))())))))))))((((((((((((((((((\n"}, {"input": "17... | code_stdio |
[
{
"content": "And where the are the phone numbers?\n\nYou are given a string s consisting of lowercase English letters and an integer k. Find the lexicographically smallest string t of length k, such that its set of letters is a subset of the set of letters of s and s is lexicographically smaller than t.\n\nIt'... | [{"input": "3 99948\nttt\n", "output": "tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt... | code_stdio |
[
{
"content": "You have given an array $a$ of length $n$ and an integer $x$ to a brand new robot. What the robot does is the following: it iterates over the elements of the array, let the current element be $q$. If $q$ is divisible by $x$, the robot adds $x$ copies of the integer $\\frac{q}{x}$ to the end of the... | [{"input": "1\n20 9\n288 279 252 279 288 207 261 270 297 288 276 265 209 217 214 300 227 221 215 271\n", "output": "7833\n"}, {"input": "1\n20 9\n288 279 252 279 288 207 261 270 297 288 276 265 209 217 214 300 227 221 215 271\n", "output": "7833\n"}, {"input": "1\n20 9\n288 279 252 279 288 207 261 270 297 288 276 265 2... | code_stdio |
[
{
"content": "Write a program which performs the following operations to a binary search tree $T$ by adding delete operation to B: Binary Search Tree II.\n\n* insert $k$: Insert a node containing $k$ as key into $T$.\n* find $k$: Report whether $T$ has a node containing $k$.\n* delete $k$: Delete a node contai... | [{"input": "18\ninsert 13\ninsert 2\ninsert 3\ninsert 7\ninsert 22\ninsert 1\nfind 1\nfind 2\nfind 3\nfind 13\nfind 5\nfind 6\nfind 4\nfind 7\nprint\ndelete 3\ndelete 7\nprint", "output": "yes\nyes\nyes\nyes\nno\nno\nno\nyes\n 1 2 3 7 13 22\n 13 2 1 3 7 22\n 1 2 13 22\n 13 2 1 22\n"}, {"input": "18\ninsert 16\ninsert 2... | code_stdio |
[
{
"content": "At the school where Vasya is studying, preparations are underway for the graduation ceremony. One of the planned performances is a ball, which will be attended by pairs of boys and girls.\n\nEach class must present two couples to the ball. In Vasya's class, $a$ boys and $b$ girls wish to participa... | [{"input": "3\n12 6 4\n2 1 2 4\n1 1 2 3\n2 1 1\n1\n1\n3 15 4\n1 1 2 2\n1 2 1 2\n", "output": "4\n0\n2\n"}, {"input": "3\n12 6 4\n2 1 2 4\n1 1 3 3\n2 1 1\n1\n1\n3 15 4\n1 1 2 2\n1 2 1 2\n", "output": "3\n0\n2\n"}, {"input": "3\n12 6 4\n2 1 2 7\n1 1 3 3\n2 1 1\n1\n1\n3 15 4\n1 1 2 2\n1 2 1 2\n", "output": "3\n0\n2\n"}, {... | code_stdio |
[
{
"content": "You are given an array $a$ consisting of $n$ integers.\n\nIn one move, you can choose two indices $1 \\le i, j \\le n$ such that $i \\ne j$ and set $a_i := a_j$. You can perform such moves any number of times (possibly, zero). You can choose different indices in different operations. The operation... | [{"input": "5\n2\n0 3\n4\n2 0 13 1\n3\n3 3 3\n4\n5 10 5 4\n4\n2 1 1 2\n", "output": "YES\nYES\nYES\nYES\nYES\n"}, {"input": "5\n2\n0 3\n4\n2 0 25 1\n3\n3 3 3\n4\n5 10 5 4\n4\n2 1 1 2\n", "output": "YES\nYES\nYES\nYES\nYES\n"}, {"input": "5\n2\n0 3\n4\n2 0 25 1\n3\n3 3 3\n4\n5 10 1 4\n4\n2 1 1 2\n", "output": "YES\nYES\... | code_stdio |
[
{
"content": "Niwango-kun, an employee of Dwango Co., Ltd., likes Niconico TV-chan, so he collected a lot of soft toys of her and spread them on the floor.\n\nNiwango-kun has N black rare soft toys of Niconico TV-chan and they are spread together with ordinary ones. He wanted these black rare soft toys to be cl... | [{"input": "17 2\n0 5\n2 3\n1 0\n1 2\n3 1\n3 1\n3 5\n5 1\n5 4\n7 4\n8 4\n6 1\n1 2\n6 1\n8 1\n11 0\n11 0\n11 -1\n7 0", "output": "5\n"}, {"input": "17 3\n0 5\n2 3\n1 0\n1 2\n3 1\n3 1\n3 5\n5 1\n5 4\n7 4\n8 4\n6 1\n1 2\n6 1\n8 1\n11 1\n11 0\n11 -1\n7 1", "output": "6\n"}, {"input": "17 2\n1 5\n2 3\n1 0\n1 2\n3 1\n3 1\n3 ... | code_stdio |
[
{
"content": "Problem D: Mr. Rito Post Office\n\nYou are a programmer working at a post office on a remote island. The area you live in consists of multiple islands. There is one or more port towns on each island. There may be other towns and villages in addition to them. You have to use a boat to go from one i... | [{"input": "3 3\n1 2 10 L\n1 2 7 S\n2 3 11 S\n3\n1 2 1\n5 5\n1 2 15 L\n2 3 10 L\n4 5 7 L\n1 4 30 S\n3 5 100 S\n5\n1 3 5 4 1\n0 0", "output": "14\n124\n"}, {"input": "3 3\n1 2 5 L\n1 2 7 S\n2 3 11 S\n3\n1 2 3\n5 5\n1 2 15 L\n2 3 10 L\n4 5 12 L\n1 3 30 S\n3 5 100 S\n5\n1 3 5 4 1\n0 0", "output": "18\n279\n"}, {"input": "... | code_stdio |
[
{
"content": "The king of a country loves prime numbers and gambling. The unit of currency in this country is called prime. As of November 1, 2007, Prime's cross-yen rate was just prime at 9973, so the King is overjoyed. Subsidiary coins with 1/101 prime as one subprime are used in this country.\n\nThe governme... | [{"input": "4\n3 -1\n14 4\n3 24\n8 4\n1\n955049 29\n0", "output": "10\n4\n"}, {"input": "4\n0 -1\n13 1\n3 10\n8 3\n1\n964394 20\n0", "output": "6\n-1\n"}, {"input": "4\n0 -1\n18 2\n3 24\n8 4\n1\n190049 29\n0", "output": "10\n3\n"}, {"input": "4\n2 -1\n14 0\n3 24\n8 7\n1\n144232 29\n0", "output": "10\n5\n"}, {"input": "... | code_stdio |
[
{
"content": "The Chef's latest idea is that some cooks might work better in pairs. So, he is going to experiment by pairing up some of his employees to see if the quality of the food prepared in his kitchen increases. However, only some pairs of employees are compatible. Two employees that are not compatible c... | [{"input": "2\n4 5\n-1 0\n2 3\n0 1\n2 1\n1 0\n4 2\n0 1\n2 3\n2 0", "output": "1 4\n0 1\n"}, {"input": "2\n11 5\n0 2\n1 1\n1 3\n1 6\n3 0\n4 3\n0 -1\n0 -1\n2 0", "output": "3 4\n2\n"}, {"input": "2\n11 5\n0 4\n1 1\n1 3\n1 6\n3 0\n4 3\n0 -1\n0 -1\n2 0", "output": "3 4\n2\n"}, {"input": "2\n6 5\n0 1\n1 2\n2 3\n1 3\n3 0\n8 ... | code_stdio |
[
{
"content": "Let's introduce the designation <image>, where x is a string, n is a positive integer and operation \" + \" is the string concatenation operation. For example, [abc, 2] = abcabc.\n\nWe'll say that string s can be obtained from string t, if we can remove some characters from string t and obtain str... | [{"input": "10000000 1\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n", "output": "10000000\n"}, {"input": "10000000 10000000\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa... | code_stdio |
[
{
"content": "Petya has equal wooden bars of length n. He wants to make a frame for two equal doors. Each frame has two vertical (left and right) sides of length a and one top side of length b. A solid (i.e. continuous without breaks) piece of bar is needed for each side.\n\nDetermine a minimal number of wooden... | [{"input": "1000\n1000\n1000\n", "output": "6\n"}, {"input": "1000\n1000\n1000\n", "output": "6"}, {"input": "800\n401\n400\n", "output": "5\n"}, {"input": "828\n468\n726\n", "output": "6\n"}, {"input": "956\n153\n941\n", "output": "3\n"}, {"input": "676\n175\n514\n", "output": "4\n"}, {"input": "713\n150\n591\n", "out... | code_stdio |
[
{
"content": "DevuLand is a very strange place. There are n villages in it. Some of the villages are occupied by dinosaurs while the remaining ones by villagers.\n\tYou are given the information of DevuLand \n\tby an array D of size n. If D[i] is non-negative, it means that there are D[i] villagers in that vill... | [{"input": "3\n2\n5 -5\n2\n-5 5\n3\n-1 3 -2", "output": "5\n5\n3\n"}, {"input": "3\n1\n5 -5\n2\n-5 5\n3\n1 2 -3", "output": "5\n5\n4\n"}, {"input": "3\n2\n5 -5\n2\n-5 5\n3\n0 3 -3", "output": "5\n5\n3\n"}, {"input": "3\n1\n5 -5\n1\n-5 5\n2\n1 3 -4", "output": "5\n5\n5\n"}, {"input": "3\n1\n5 -5\n2\n-8 8\n2\n1 2 -3", "o... | code_stdio |
[
{
"content": "Let a and b be some non-negative integers. Let's define strange addition of a and b as following:\n\n 1. write down the numbers one under another and align them by their least significant digit; \n 2. add them up digit by digit and concatenate the respective sums together. \n\n\n\nAssume that bo... | [{"input": "2 3\n14\n2 4\n2 1\n1 1\n", "output": "15\n12\n12\n"}, {"input": "2 3\n14\n2 4\n2 1\n2 0\n", "output": "15\n12\n11\n"}, {"input": "2 3\n11\n2 8\n2 2\n2 0\n", "output": "19\n13\n11\n"}, {"input": "2 3\n11\n2 8\n2 2\n2 1\n", "output": "19\n13\n12\n"}, {"input": "2 3\n11\n2 8\n2 2\n2 2\n", "output": "19\n13\n13... | code_stdio |
[
{
"content": "Given are three integers A_1, A_2, and A_3.\nIf A_1+A_2+A_3 is greater than or equal to 22, print bust; otherwise, print win.\n\n-----Constraints-----\n - 1 \\leq A_i \\leq 13 \\ \\ (i=1,2,3)\n - All values in input are integers.\n\n-----Input-----\nInput is given from Standard Input in the follow... | [{"input": "13 13 13\n", "output": "bust\n"}, {"input": "1 10 11\n", "output": "bust\n"}, {"input": "6 13 10\n", "output": "bust\n"}, {"input": "115 -5 1", "output": "bust\n"}, {"input": "-2 -10 -1", "output": "win\n"}, {"input": "-4 -10 -1", "output": "win\n"}, {"input": "-4 -13 -1", "output": "win\n"}, {"input": "-4 ... | code_stdio |
[
{
"content": "You are given N points in the xy-plane. You have a circle of radius one and move it on the xy-plane, so as to enclose as many of the points as possible. Find how many points can be simultaneously enclosed at the maximum. A point is considered enclosed by a circle when it is inside or on the circle... | [{"input": "3\n6.834942604239939 7.69628\n6.04723928846506 4.859878448884584\n7.439438773048666 6.914350092484497\n6\n7.260024632937995 4.220572316804344\n7.2301779956102665 2.69466\n5.977411451010016 4.7893139817742\n5.771323891387089 5.033018424848772\n7.097650770216692 5.940611762552271\n8.514204260774932 5.46523993... | code_stdio |
[
{
"content": "The process of mammoth's genome decoding in Berland comes to its end!\n\nOne of the few remaining tasks is to restore unrecognized nucleotides in a found chain s. Each nucleotide is coded with a capital letter of English alphabet: 'A', 'C', 'G' or 'T'. Unrecognized nucleotides are coded by a quest... | [{"input": "252\n???????GCG??T??TT?????T?C???C?CCG???GA???????AC??A???AAC?C?CC??CCC??A??TA?CCC??T???C??CA???CA??G????C?C?C????C??C??A???C?T????C??ACGC??CC?A?????A??CC?C??C?CCG?C??C??A??CG?A?????A?CT???CC????CCC?CATC?G??????????A???????????????TCCCC?C?CA??AC??GC????????\n", "output": "AAAAAAAGCGAATAATTAAAAATACAAACACCGAA... | code_stdio |
[
{
"content": "We consider a positive integer perfect, if and only if the sum of its digits is exactly $10$. Given a positive integer $k$, your task is to find the $k$-th smallest perfect positive integer.\n\n\n-----Input-----\n\nA single line with a positive integer $k$ ($1 \\leq k \\leq 10\\,000$).\n\n\n-----O... | [{"input": "10000\n", "output": "10800100\n"}, {"input": "9999\n", "output": "10800010\n"}, {"input": "9139\n", "output": "10134010\n"}, {"input": "9859\n", "output": "10422001\n"}, {"input": "8888\n", "output": "10110061\n"}, {"input": "9411\n", "output": "10214200\n"}, {"input": "8515\n", "output": "10030114\n"}, {"i... | code_stdio |
[
{
"content": "Convenience store Deven Eleven is planning to open its first store in Aizuwakamatsu City to expand its business. There are already many other convenience stores in Aizuwakamatsu, so the place to open a new store is likely to be the key to success. Under the premise that \"customers use the conveni... | [{"input": "10 12\n6\n2 1\n6 1\n6 2\n1 5\n0 6\n5 6\n2\n1 3\n5 3\n11 6\n6\n3 3\n3 4\n6 1\n1 1\n1 6\n5 6\n2\n0 3\n6 4\n0 0", "output": "6\n18\n"}, {"input": "10 12\n6\n1 1\n6 1\n6 2\n1 5\n0 6\n5 6\n2\n1 3\n5 3\n11 6\n6\n3 3\n3 4\n6 2\n1 1\n1 5\n1 6\n2\n0 3\n6 4\n0 0", "output": "8\n20\n"}, {"input": "6 6\n6\n1 1\n4 2\n3 ... | code_stdio |
[
{
"content": "You play a computer game. In this game, you lead a party of $m$ heroes, and you have to clear a dungeon with $n$ monsters. Each monster is characterized by its power $a_i$. Each hero is characterized by his power $p_i$ and endurance $s_i$.\n\nThe heroes clear the dungeon day by day. In the beginni... | [{"input": "2\n6\n2 3 11 14 1 8\n2\n3 2\n000 1\n5\n3 5 100 2 3\n2\n30 5\n90 1\n", "output": "-1\n-1\n"}, {"input": "2\n6\n1 3 11 14 1 10\n2\n3 2\n100 1\n5\n3 5 100 2 3\n2\n30 5\n11 1\n", "output": "5\n-1\n"}, {"input": "2\n6\n1 3 11 16 1 10\n2\n3 2\n100 1\n5\n3 5 100 2 3\n2\n30 5\n11 1\n", "output": "5\n-1\n"}, {"input... | code_stdio |
[
{
"content": "In this problem MEX of a certain array is the smallest positive integer not contained in this array.\n\nEveryone knows this definition, including Lesha. But Lesha loves MEX, so he comes up with a new problem involving MEX every day, including today.\n\nYou are given an array $a$ of length $n$. Les... | [{"input": "100\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100\n", "output... | code_stdio |
[
{
"content": "As a New Year's gift, Dolphin received a string s of length 19.\nThe string s has the following format: `[five lowercase English letters],[seven lowercase English letters],[five lowercase English letters]`.\nDolphin wants to convert the comma-separated string s into a space-separated string.\nWrit... | [{"input": "gaiku,atcoder,tasks", "output": "gaiku atcoder tasks\n"}, {"input": "abgde,fchihgf,edcba", "output": "abgde fchihgf edcba\n"}, {"input": "ha,pypnewyear,enjoy", "output": "ha pypnewyear enjoy\n"}, {"input": "gaiku,atcoeer,tasks", "output": "gaiku atcoeer tasks\n"}, {"input": "abcde,fghihcf,edgba", "output": ... | code_stdio |
[
{
"content": "Vanya is managed to enter his favourite site Codehorses. Vanya uses n distinct passwords for sites at all, however he can't remember which one exactly he specified during Codehorses registration.\n\nVanya will enter passwords in order of non-decreasing their lengths, and he will enter passwords of... | [{"input": "20 5\nvSyC787KlIL8kZ2Uv5sw\nWKWOP\n7i8J3E8EByIq\nNW2VyGweL\nmyR2sRNu\nmXusPP0\nf4jgGxra\n4wHRzRhOCpEt\npPz9kybGb\nOtSpePCRoG5nkjZ2VxRy\nwHYsSttWbJkg\nKBOP9\nQfiOiFyHPPsw3GHo8J8\nxB8\nqCpehZEeEhdq\niOLjICK6\nQ91\nHmCsfMGTFKoFFnv238c\nJKjhg\ngkEUh\nKBOP9\n", "output": "3 11\n"}, {"input": "20 5\nvSyC787KlIL8k... | code_stdio |
[
{
"content": "In Berland a bus travels along the main street of the capital. The street begins from the main square and looks like a very long segment. There are n bus stops located along the street, the i-th of them is located at the distance a_{i} from the central square, all distances are distinct, the stops... | [{"input": "6\n2 3 5 7 9 11\n11\n1 2 2 3 3 4 4 5 5 5 6\n", "output": " 18\n"}, {"input": "6\n2 3 5 7 11 13\n9\n1 2 2 3 3 4 5 5 6\n", "output": " 16\n"}, {"input": "4\n2 3 5 7\n9\n1 1 2 2 2 3 3 3 4\n... | code_stdio |
[
{
"content": "Ms. Iyo Kiffa-Australis has a balance and only two kinds of weights to measure a dose of medicine.\n\nFor example, to measure 200mg of aspirin using 300mg weights and 700mg weights, she can put one 700mg weight on the side of the medicine and three 300mg weights on the opposite side (Figure 1). Al... | [{"input": "700 300 200\n993 200 300\n244 200 500\n275 111 330\n275 010 385\n694 375 1747\n3 1 10010\n0 0 0", "output": "1 3\n100 495\n25 28\n21 55\n1 11\n163 297\n3336 2\n"}, {"input": "700 300 200\n500 283 300\n349 200 500\n275 110 330\n275 010 385\n1067 344 4002\n3 1 10001\n0 0 0", "output": "1 3\n56 100\n100 172\n0... | code_stdio |
[
{
"content": "There are n TV shows you want to watch. Suppose the whole time is split into equal parts called \"minutes\". The i-th of the shows is going from l_i-th to r_i-th minute, both ends inclusive.\n\nYou need a TV to watch a TV show and you can't watch two TV shows which air at the same time on the same... | [{"input": "10 798547896 459313948\n40312491 40315265\n40299842 40315264\n40296035 40315263\n40282844 40315262\n40304824 40315261\n40280414 40315260\n40299203 40315259\n40301967 40315258\n40276169 40315257\n40286575 40315256\n", "output": "236433977\n"}, {"input": "4 288243228 34715941\n996451829 999802844\n921286045 9... | code_stdio |
[
{
"content": "Print the K-th element of the following sequence of length 32:\n\n\n1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51\n\nConstraints\n\n* 1 \\leq K \\leq 32\n* All values in input are integers.\n\nInput\n\nInput is given from Standard Input in the fo... | [{"input": "16", "output": "14\n"}, {"input": "24", "output": "15\n"}, {"input": "32", "output": "51\n"}, {"input": "-22", "output": "2\n"}, {"input": "-27", "output": "1\n"}, {"input": "-13", "output": "1\n"}, {"input": "-20", "output": "5\n"}, {"input": "001", "output": "1\n"}, {"input": "32", "output": "51\n"}, {"in... | code_stdio |
[
{
"content": "In the spring of 2014, a student successfully passed the university and started living alone. The problem here is what to do with the supper. He decided to plan a supper for the next N days.\n\nHe wants to maximize the total happiness he gets in N days. Of course, the more delicious or favorite yo... | [{"input": "3 1 -10\n-19\n-10\n-10", "output": "-27\n"}, {"input": "2 1 -10\n-19\n-10\n-10", "output": "-19\n"}, {"input": "3 1 -19\n-19\n-10\n-10", "output": "-39\n"}, {"input": "3 1 -19\n-19\n-10\n-18", "output": "-47\n"}, {"input": "2 1 -10\n-35\n-10\n-10", "output": "-19\n"}, {"input": "2 1 -10\n-35\n-3\n-10", "out... | code_stdio |
[
{
"content": "The name of one small but proud corporation consists of n lowercase English letters. The Corporation has decided to try rebranding — an active marketing strategy, that includes a set of measures to change either the brand (both for the company and the goods it produces) or its components: the name... | [{"input": "10 10\nlellelleel\ne l\ne l\ne l\ne l\ne l\ne e\nl l\nl e\nl l\ne e\n", "output": "lellelleel\n"}, {"input": "10 10\nlellelleel\ne l\ne l\ne l\ne l\ne l\ne e\nl l\nl e\nl l\ne e\n", "output": "lellelleel\n"}, {"input": "10 10\nlellelleel\ne l\ne l\ne l\ne l\ne l\ne e\nl l\nl e\nl l\ne f\n", "output": "lfllf... | code_stdio |
[
{
"content": "Victor and Peter are playing hide-and-seek. Peter has hidden, and Victor is to find him. In the room where they are playing, there is only one non-transparent wall and one double-sided mirror. Victor and Peter are points with coordinates (xv, yv) and (xp, yp) respectively. The wall is a segment jo... | [{"input": "-7366 1446\n-7727 -1428\n-2680 -3822 -5191 -5553\n-7304 -6313 -9229 1377\n", "output": "YES\n"}, {"input": "-4752 -3262\n-4582 6436\n-8997 -6490 -4630 1426\n-9865 -6697 -2371 -5622\n", "output": "YES"}, {"input": "-4752 -3262\n-4582 6436\n-8997 -6490 -4630 1426\n-9865 -3168 -2371 -5622\n", "output": "NO\n"}... | code_stdio |
[
{
"content": "You have a card deck of $n$ cards, numbered from top to bottom, i. e. the top card has index $1$ and bottom card — index $n$. Each card has its color: the $i$-th card has color $a_i$.\n\nYou should process $q$ queries. The $j$-th query is described by integer $t_j$. For each query you should:\n\nf... | [{"input": "5 15\n1 2 3 4 5\n5 5 5 5 5 5 5 5 5 5 5 5 5 5 5\n", "output": "5 1 1 1 1 1 1 1 1 1 1 1 1 1 1 "}, {"input": "5 15\n1 2 3 4 5\n5 5 5 5 5 5 5 5 5 5 5 5 5 5 5\n", "output": "5 1 1 1 1 1 1 1 1 1 1 1 1 1 1 "}, {"input": "5 15\n1 2 3 4 5\n5 5 5 5 5 5 5 5 2 5 5 5 5 5 5\n", "output": "5 1 1 1 1 1 1 1 3 2 1 1 1 1 1 "}... | code_stdio |
[
{
"content": "Limak is a little bear who loves to play. Today he is playing by destroying block towers. He built n towers in a row. The i-th tower is made of hi identical blocks. For clarification see picture for the first sample.\n\nLimak will repeat the following operation till everything is destroyed.\n\nBlo... | [{"input": "170\n1 2 1 2 1 1 1 1 2 3 2 1 1 2 2 1 2 1 2 1 1 2 3 3 2 1 1 1 1 1 1 1 1 2 1 2 3 3 2 1 2 2 1 2 3 2 1 1 2 3 2 1 2 1 1 1 2 3 3 2 1 2 1 2 1 1 1 2 1 2 1 1 2 2 1 1 2 1 2 2 1 2 1 2 2 1 2 1 2 3 2 1 1 2 3 4 4 3 2 1 2 1 2 1 2 3 3 2 1 2 1 1 1 1 1 1 1 2 2 1 1 2 1 1 1 1 2 1 1 2 3 2 1 2 2 1 2 1 1 1 2 2 1 2 1 2 3 2 1 2 1 1... | code_stdio |
[
{
"content": "You are given an integer $n$ from $1$ to $10^{18}$ without leading zeroes.\n\nIn one move you can swap any two adjacent digits in the given number in such a way that the resulting number will not contain leading zeroes. In other words, after each move the number you have cannot contain any leading... | [{"input": "574196831896431419\n", "output": "33\n"}, {"input": "1000000000000000000\n", "output": "0\n"}, {"input": "213716413141380147\n", "output": "-1\n"}, {"input": "250070000011111111\n", "output": "16\n"}, {"input": "502727272727272727\n", "output": "18\n"}, {"input": "700777111111222222\n", "output": "30\n"}, {... | code_stdio |
[
{
"content": "Given a string $s$ of length $n$ and integer $k$ ($1 \\le k \\le n$). The string $s$ has a level $x$, if $x$ is largest non-negative integer, such that it's possible to find in $s$: $x$ non-intersecting (non-overlapping) substrings of length $k$, all characters of these $x$ substrings are the sa... | [{"input": "92 5\nwwwwwwwwwwwwwwwwwgggggggggggggggbbbbyyyyyyyyyyyyyyjjjjjjjjjjjuuuuuuuuaaaaaaaaaaaafooooooooig\n", "output": "3\n"}, {"input": "92 5\nwwwwwwwwwwwwwwwwwgggggggggggggggbbbbyyyyyyyyyyyyyyjjjjjjjjjjjuuuuuuuuaaaaaaaaaaaafooooooooig\n", "output": "3\n"}, {"input": "92 6\nwwwwwwwwwwwwwwwwwgggggggggggggggbbbbyy... | code_stdio |
[
{
"content": "You are the planning manager of an animation production company. What animation production companies produce these days is not limited to animation itself. Related products, such as figures of characters and character song CDs, are also important sources of revenue. How much this profit can be inc... | [{"input": "4\nakzakr 2 1 8\nfnmyi 5 2 3 4 6 9\ntsnukk 5 2 3 4 7 9\nyskwcnt 6 3 4 7 8 9 10\n4\nakzakr 1 2\nfnmyi 3 10 11 12\ntsnukk 2 1 8\nyskwcnt 2 1 8\n5\nknmmdk 2 13 19\nakmhmr 4 13 15 19 22\nmksyk 6 3 7 12 13 15 19\nskrkyk 3 1 4 8\ntmemm 3 1 17 24\n5\nknmmdk 5 5 6 16 18 26\nakmhmr 9 3 4 7 11 14 15 17 18 20\nmksyk 5... | 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 34 28 28 28 40 28 28 28 28 28 28 28 28 28 28 28 28 28 28 47 28 28 28 28 28 28 28 28 28 28 28 28 28 19 28 28 28 28 28 28 28 28 28 28 28 28 28 46 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 49 28 28 28 28 28 28 28 31 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 pieces of source code. The characteristics of the i-th code is represented by M integers A_{i1}, A_{i2}, ..., A_{iM}.\nAdditionally, you are given integers B_1, B_2, ..., B_M and C.\nThe i-th code correctly solves this problem if and only if A_{i1} B_1 + A_{i2} B_2 + ... + A_{iM} B_M +... | [{"input": "20 20 1\n-100 -100 -100 100 100 -100 100 100 100 -100 100 100 -100 100 100 -100 -100 -100 100 100\n-100 -100 100 -100 100 100 -100 100 100 100 -100 100 100 -100 100 -100 -100 -100 -100 100\n-100 -100 100 100 100 100 -100 100 -100 100 -100 100 100 100 100 100 100 -100 100 -100\n-100 -100 100 100 -100 100 100... | code_stdio |
[
{
"content": "Vasya the programmer lives in the middle of the Programming subway branch. He has two girlfriends: Dasha and Masha, who live at the different ends of the branch, each one is unaware of the other one's existence.\n\nWhen Vasya has some free time, he goes to one of his girlfriends. He descends into ... | [{"input": "999999 1000000\n", "output": "Equal\n"}, {"input": "1000000 999993\n", "output": "Masha\n"}, {"input": "999997 1000000\n", "output": "Dasha\n"}, {"input": "459973 1000000\n", "output": "Dasha\n"}, {"input": "1000001 999993\n", "output": "Masha\n"}, {"input": "1001001 999993\n", "output": "Masha\n"}, {"input... | code_stdio |
[
{
"content": "The flag of Berland is such rectangular field n × m that satisfies following conditions:\n\n Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exac... | [{"input": "15 28\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\nG... | code_stdio |
[
{
"content": "Let's consider equation:x^2 + s(x)·x - n = 0, \n\nwhere x, n are positive integers, s(x) is the function, equal to the sum of digits of number x in the decimal number system.\n\nYou are given an integer n, find the smallest positive integer root of equation x, or else determine that there are no ... | [{"input": "160000001600000000\n", "output": "400000000\n"}, {"input": "250000002500000000\n", "output": "500000000\n"}, {"input": "360000003600000000\n", "output": "600000000\n"}, {"input": "490000004900000000\n", "output": "700000000\n"}, {"input": "640000006400000000\n", "output": "800000000\n"}, {"input": "81000000... | code_stdio |
[
{
"content": "There are N boxes arranged in a circle. The i-th box contains A_i stones.\n\nDetermine whether it is possible to remove all the stones from the boxes by repeatedly performing the following operation:\n\n* Select one box. Let the box be the i-th box. Then, for each j from 1 through N, remove exactl... | [{"input": "5\n12 26 12 10 8", "output": "NO\n"}, {"input": "5\n6 11 12 10 8", "output": "NO\n"}, {"input": "5\n6 16 12 10 8", "output": "NO\n"}, {"input": "5\n6 26 12 10 8", "output": "NO\n"}, {"input": "5\n12 6 12 10 8", "output": "NO\n"}, {"input": "5\n12 2 12 10 8", "output": "NO\n"}, {"input": "5\n12 3 12 10 8", "... | code_stdio |
[
{
"content": "The $\\text{$gcdSum$}$ of a positive integer is the $gcd$ of that integer with its sum of digits. Formally, $\\text{$gcdSum$}(x) = gcd(x, \\text{ sum of digits of } x)$ for a positive integer $x$. $gcd(a, b)$ denotes the greatest common divisor of $a$ and $b$ — the largest integer $d$ such that bo... | [{"input": "3\n17\n110\n182\n", "output": "18\n110\n183\n"}, {"input": "3\n17\n110\n359\n", "output": "18\n110\n360\n"}, {"input": "3\n17\n100\n359\n", "output": "18\n102\n360\n"}, {"input": "3\n33\n100\n359\n", "output": "33\n102\n360\n"}, {"input": "3\n42\n101\n359\n", "output": "42\n102\n360\n"}, {"input": "3\n17\n1... | code_stdio |
[
{
"content": "As shown in the following figure, there is a paper consisting of a grid structure where each cell is indicated by (x, y) coordinate system.\n\nWe are going to put drops of ink on the paper. A drop comes in three different sizes: Large, Medium, and Small. From the point of fall, the ink sinks into ... | [{"input": "2,5,3\n3,6,1\n3,4,2\n4,5,2\n3,6,3\n1,4,1", "output": "75\n5\n"}, {"input": "2,5,3\n1,6,3\n3,4,2\n4,5,2\n3,6,3\n2,4,1", "output": "73\n5\n"}, {"input": "2,5,3\n3,6,1\n2,4,2\n4,5,2\n3,6,3\n1,4,1", "output": "76\n5\n"}, {"input": "2,5,3\n3,6,1\n3,4,2\n5,5,2\n3,6,3\n1,4,1", "output": "72\n4\n"}, {"input": "2,5,... | code_stdio |
[
{
"content": "Mr. A wants to get to the destination on the Yamanote line.\n\nAfter getting on the train, Mr. A gets up for a minute and sleeps for b minutes repeatedly. It is c minutes after boarding to the destination, and you can get off if you are awake at this time, but on the contrary, if you are sleeping,... | [{"input": "196 2 133", "output": "133\n"}, {"input": "128 12 16", "output": "16\n"}, {"input": "134 22 13", "output": "13\n"}, {"input": "134 22 21", "output": "21\n"}, {"input": "50 40 68", "output": "128\n"}, {"input": "36 18 39", "output": "219\n"}, {"input": "128 22 23", "output": "23\n"}, {"input": "134 22 26", "... | code_stdio |
[
{
"content": "Maxim wants to buy some games at the local game shop. There are $n$ games in the shop, the $i$-th game costs $c_i$.\n\nMaxim has a wallet which can be represented as an array of integers. His wallet contains $m$ bills, the $j$-th bill has value $a_j$.\n\nGames in the shop are ordered from left to ... | [{"input": "6 4\n4 8 15 16 23 42\n1000 1000 1000 1000\n", "output": "4\n"}, {"input": "6 4\n4 8 15 16 23 42\n1000 1000 1000 1010\n", "output": "4\n"}, {"input": "6 4\n4 8 17 16 23 42\n1000 1000 1000 1010\n", "output": "4\n"}, {"input": "6 4\n4 8 15 16 23 42\n1000 1000 1000 1000\n", "output": "4\n"}, {"input": "5 1\n100... | code_stdio |
[
{
"content": "Vasya's telephone contains n photos. Photo number 1 is currently opened on the phone. It is allowed to move left and right to the adjacent photo by swiping finger over the screen. If you swipe left from the first photo, you reach photo n. Similarly, by swiping right from the last photo you reach p... | [{"input": "100 20 100 10202\nwwwwhhwhhwhhwhhhhhwwwhhhwwwhwwhwhhwwhhwwwhwwhwwwhwhwhwwhhhwhwhhwhwwhhwhwhwwwhwwwwhwhwwwwhwhhhwhwhwww\n", "output": "100\n"}, {"input": "100 20 100 19121\nwwwwhhwhhwhhwhhhhhwwwhhhwwwhwwhwhhwwhhwwwhwwhwwwhwhwhwwhhhwhwhhwhwwhhwhwhwwwhwwwwhwhwwwwhwhhhwhwhwww\n", "output": "100\n"}, {"input": "... | code_stdio |
[
{
"content": "You are given a weighted undirected graph. The vertices are enumerated from 1 to n. Your task is to find the shortest path between the vertex 1 and the vertex n.\n\nInput\n\nThe first line contains two integers n and m (2 ≤ n ≤ 105, 0 ≤ m ≤ 105), where n is the number of vertices and m is the numb... | [{"input": "10 10\n1 5 12\n2 4 140\n2 10 149\n3 6 154\n3 7 17\n3 8 226\n3 10 132\n4 10 55\n5 8 33\n7 8 173\n", "output": "1 5 8 7 3 10\n"}, {"input": "10 10\n1 5 12\n2 4 140\n2 10 149\n3 6 154\n2 7 17\n3 8 226\n3 10 136\n4 10 55\n5 8 33\n7 8 173\n", "output": "1 5 8 7 2 10\n"}, {"input": "10 10\n1 5 12\n2 4 140\n2 10 1... | code_stdio |
[
{
"content": "The cake shop made a lot of roll cakes of various sizes. You have been tasked with arranging this cake in a box.\n\nThe roll cake is so soft that it will collapse if another roll cake is on top. Therefore, as shown in Fig. (A), all roll cakes must be arranged so that they touch the bottom of the b... | [{"input": "30 4 5 6\n8 5 5 5\n50 3 3 3 10 10\n49 3 3 3 10 10", "output": "OK\nNA\nOK\nNA\n"}, {"input": "30 3 5 6\n6 5 5 5\n50 3 3 3 13 10\n49 3 3 3 10 10", "output": "OK\nNA\nNA\nNA\n"}, {"input": "30 4 5 6\n30 5 5 5\n50 3 3 3 10 10\n49 3 3 3 4 10", "output": "OK\nOK\nOK\nOK\n"}, {"input": "53 4 5 6\n7 5 2 2\n73 3 0 ... | code_stdio |
[
{
"content": "Ilya the Lion wants to help all his friends with passing exams. They need to solve the following problem to pass the IT exam.\n\nYou've got string s = s_1s_2... s_{n} (n is the length of the string), consisting only of characters \".\" and \"#\" and m queries. Each query is described by a pair of ... | [{"input": "#..##...#.\n7\n5 9\n6 10\n1 7\n2 10\n2 5\n2 10\n3 4\n", "output": "2\n2\n3\n4\n2\n4\n0\n"}, {"input": "#..##...#.\n7\n5 9\n6 10\n1 7\n2 10\n3 5\n2 10\n3 4\n", "output": "2\n2\n3\n4\n1\n4\n0\n"}, {"input": "#..##...#/\n7\n5 9\n6 10\n1 7\n2 10\n3 5\n2 10\n3 4\n", "output": "2\n2\n3\n4\n1\n4\n0\n"}, {"input": ... | code_stdio |
[
{
"content": "A set of four prime numbers arranged like (a, a + 2, a + 6, a + 8) is called a quadruplet prime number. Of the four prime numbers that make up a quadruplet prime, the largest number is called the size of the quadruplet prime. For example, the smallest prime quadruplet is a set of (5, 7, 11, 13), w... | [{"input": "13\n14\n15\n16\n17\n18\n19\n20\n10010\n0", "output": "13\n13\n13\n13\n13\n13\n19\n19\n9439\n"}, {"input": "13\n14\n15\n16\n17\n36\n19\n20\n10000\n0", "output": "13\n13\n13\n13\n13\n19\n19\n19\n9439\n"}, {"input": "13\n14\n15\n16\n27\n36\n19\n20\n10000\n0", "output": "13\n13\n13\n13\n19\n19\n19\n19\n9439\n"}... | code_stdio |
[
{
"content": "Let $n$ be a positive integer. Let $a, b, c$ be nonnegative integers such that $a + b + c = n$.\n\nAlice and Bob are gonna play rock-paper-scissors $n$ times. Alice knows the sequences of hands that Bob will play. However, Alice has to play rock $a$ times, paper $b$ times, and scissors $c$ times.\... | [{"input": "7\n2\n1 1 0\nRR\n2\n2 0 0\nSS\n2\n2 0 0\nRR\n3\n1 2 0\nRRR\n3\n2 1 0\nRRR\n1\n1 0 0\nP\n1\n1 0 0\nS\n", "output": "YES\nPR\nYES\nRR\nNO\nYES\nPPR\nNO\nNO\nYES\nR\n"}, {"input": "7\n2\n1 1 0\nRR\n2\n2 0 0\nSS\n2\n2 0 0\nRR\n3\n1 2 0\nRRR\n3\n2 1 0\nRRR\n1\n1 0 0\nP\n1\n1 0 0\nS\n", "output": "YES\nPR\nYES\nR... | code_stdio |
[
{
"content": "Snuke loves \"paper cutting\": he cuts out characters from a newspaper headline and rearranges them to form another string.\nHe will receive a headline which contains one of the strings S_1,...,S_n tomorrow.\nHe is excited and already thinking of what string he will create.\nSince he does not know... | [{"input": "3\ncbaa\ndaacc\nacacac\n", "output": "aac\n"}, {"input": "3\ncacb\nccabe\n`cacbc", "output": "abcc\n"}, {"input": "3\ncaaa\ndaacc\nacacac", "output": "aac\n"}, {"input": "3\ncaca\ncca`d\nacacac", "output": "acc\n"}, {"input": "3\nacba\nda`cb\nacacbc", "output": "abc\n"}, {"input": "3\nbcac\ncc`be\nacacbc", ... | code_stdio |
[
{
"content": "You are the gym teacher in the school.\n\nThere are $n$ students in the row. And there are two rivalling students among them. The first one is in position $a$, the second in position $b$. Positions are numbered from $1$ to $n$ from left to right.\n\nSince they are rivals, you want to maximize the ... | [{"input": "22\n100 100 100 1\n100 100 1 100\n100 0 100 1\n100 0 1 100\n2 0 1 2\n2 100 1 2\n2 0 2 1\n2 100 2 1\n100 0 1 2\n100 98 1 2\n100 97 1 2\n100 0 2 1\n100 98 2 1\n100 97 2 1\n100 0 99 100\n100 98 99 100\n100 97 99 100\n100 0 100 99\n100 98 100 99\n100 97 100 99\n100 0 13 37\n100 0 66 11\n", "output": "99\n99\n99... | code_stdio |
[
{
"content": "Professor Abacus has just built a new computing engine for making numerical tables. It was designed to calculate the values of a polynomial function in one variable at several points at a time. With the polynomial function f(x) = x2 + 2x + 1, for instance, a possible expected calculation result is... | [{"input": "2\n1.0\n4.0\n14.21446074361601\n16.0\n25.0\n1\n-30.5893962764\n6.055835197262627\n39.3853798058\n74.3727663177\n0\n42.56611822314588\n79.5420238202\n28.0282396675\n-30.3627807522\n-49.34987576252381\n-25.34819013612247\n7.58575761381\n0\n-21.42163030108298\n-47.94509062430888\n-23.354080083023813\n-2.110808... | code_stdio |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.