messages
listlengths
1
1
ground_truth
stringlengths
156
726k
dataset
stringclasses
2 values
[ { "content": "The store sells $n$ items, the price of the $i$-th item is $p_i$. The store's management is going to hold a promotion: if a customer purchases at least $x$ items, $y$ cheapest of them are free.\n\nThe management has not yet decided on the exact values of $x$ and $y$. Therefore, they ask you to pro...
[{"input": "13 3\n5 3 1 5 2 5 3 1 5 2 5 3 1\n3 2\n1 1\n5 3\n", "output": "10\n5\n15\n"}, {"input": "5 3\n100 200 300 400 500\n2 1\n1 1\n3 2\n", "output": "400\n500\n700\n"}, {"input": "5 3\n100 200 300 400 500\n1 1\n3 2\n2 2\n", "output": "500\n700\n900\n"}, {"input": "5 2\n100 200 300 400 500\n1 1\n3 2\n", "output": "...
code_stdio
[ { "content": "Alena has successfully passed the entrance exams to the university and is now looking forward to start studying.\n\nOne two-hour lesson at the Russian university is traditionally called a pair, it lasts for two academic hours (an academic hour is equal to 45 minutes).\n\nThe University works in su...
[{"input": "100\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n", "output": "100\n"}, {"input": "100\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...
code_stdio
[ { "content": "Given is an integer sequence A_1, ..., A_N of length N.\nWe will choose exactly \\left\\lfloor \\frac{N}{2} \\right\\rfloor elements from this sequence so that no two adjacent elements are chosen.\nFind the maximum possible sum of the chosen elements.\nHere \\lfloor x \\rfloor denotes the greatest...
[{"input": "10\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000\n", "output": "5000000000\n"}, {"input": "10\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 0000000000 1000000000 1000000000 1000000000", "output": "5000000000\n"}, {"input":...
code_stdio
[ { "content": "There are n cities numbered from 1 to n in Berland. Some of them are connected by two-way roads. Each road has its own length β€” an integer number from 1 to 1000. It is known that from each city it is possible to get to any other city by existing roads. Also for each pair of cities it is known the ...
[{"input": "5\n0 954 1255 266 751\n954 0 1677 688 1173\n1255 1677 0 989 504\n266 688 989 0 485\n751 1173 504 485 0\n5\n5 2 1509\n3 4 692\n3 5 756\n3 1 151\n2 5 262\n", "output": "8742 7851 7851 6398 5111 "}, {"input": "5\n0 954 1255 266 751\n954 0 1677 688 1173\n1255 1677 0 989 504\n266 688 989 0 485\n751 1173 504 485 ...
code_stdio
[ { "content": "Emuskald is an avid horticulturist and owns the world's longest greenhouse β€” it is effectively infinite in length.\n\nOver the years Emuskald has cultivated n plants in his greenhouse, of m different plant species numbered from 1 to m. His greenhouse is very narrow and can be viewed as an infinite...
[{"input": "20 15\n7 8720.017100830131\n2 13067.215819731118\n8 58623.690996\n9 184322.3412850205\n6 227999.61123331118\n2 279836.330518\n9 282807.34217112145\n2 311057.23684687156\n1 312315.562927\n5 459200.373445\n14 563454.265947\n11 647366.9355815595\n13 679761.613732\n4 684192.647497\n3 733121.2686885264\n4 748638...
code_stdio
[ { "content": "Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. \n\nLittle Egor is a huge movie fan. He likes watching different kinds of movies: from drama movies to comedy movies, from teen movies to horror movies. He is planning to visit cinema this weekend, but he's not sure whic...
[{"input": "2\n2\n2 2\n3 2\n3\n-1 1 4 1\n1 4 1 4", "output": "1\n2\n"}, {"input": "2\n2\n2 2\n3 2\n3\n-1 1 2 1\n1 4 1 4", "output": "1\n2\n"}, {"input": "2\n2\n1 2\n2 1\n4\n1 2 1 1\n2 10 1 3", "output": "1\n2\n"}, {"input": "2\n1\n2 3\n2 1\n4\n2 1 4 1\n2 10 1 4", "output": "1\n2\n"}, {"input": "2\n2\n1 2\n2 1\n4\n1 4 1...
code_stdio
[ { "content": "Yukiya, the owner of Aizuyama Ski Resort, has prepared a course for advanced skiers with obstacles and jumping hills. There are various ways to slide on the course, and users who can slide in all patterns during the season will be given a gift.\n\nLet's create a program for the oil tree shop that ...
[{"input": "5 5\n0 0 0 0 1\n2 1 0 2 0\n1 0 0 1 1\n0 2 1 2 0\n0 1 -1 0 0\n5 5\n0 0 1 0 0\n2 1 0 2 0\n1 0 0 0 1\n0 2 1 2 0\n0 1 0 0 0\n15 15\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 1 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0 0 0 0...
code_stdio
[ { "content": "There are N one-off jobs available. If you take the i-th job and complete it, you will earn the reward of B_i after A_i days from the day you do it.\nYou can take and complete at most one of these jobs in a day.\nHowever, you cannot retake a job that you have already done.\nFind the maximum total ...
[{"input": "7791 7791\n7791 7707\n7789 2110\n7791 1594\n7791 2921\n7791 9233\n7791 9612\n7789 8647\n7790 5898\n7791 5096\n7789 9048\n7791 1635\n7790 623\n7790 7404\n7791 5805\n7790 9498\n7789 2644\n7791 1482\n7791 5994\n7791 1562\n7790 120\n7789 5327\n7789 9548\n7790 6224\n7791 5478\n7789 6056\n7789 1262\n7790 6328\n77...
code_stdio
[ { "content": "You are given two positive integers $a$ and $b$. In one move you can increase $a$ by $1$ (replace $a$ with $a+1$). Your task is to find the minimum number of moves you need to do in order to make $a$ divisible by $b$. It is possible, that you have to make $0$ moves, as $a$ is already divisible by ...
[{"input": "21\n1 3218\n28 10924\n908802 141084\n82149 7374\n893257 19784\n3535315 802705\n2857 176\n691 227749\n1 3218\n28 10924\n436302 141084\n82149 9274\n893257 10248\n4004924 1003579\n2857 142\n114 209385\n1 1131\n28 10924\n1144405 141084\n132660 9274\n2346605 10248\n", "output": "3217\n10896\n78786\n6339\n16807\n...
code_stdio
[ { "content": "Dr. Hedro is astonished. According to his theory, we can make sludge that can dissolve almost everything on the earth. Now he's trying to produce the sludge to verify his theory.\n\nThe sludge is produced in a rectangular solid shaped tank whose size is N Γ— N Γ— 2. Let coordinate of two corner poin...
[{"input": "2\n14\n0", "output": "24\n328\n"}, {"input": "2\n12\n0", "output": "24\n264\n"}, {"input": "2\n10\n0", "output": "24\n216\n"}, {"input": "2\n18\n0", "output": "24\n440\n"}, {"input": "2\n24\n0", "output": "24\n608\n"}, {"input": "2\n10\n0", "output": "24\n216\n"}, {"input": "2\n12\n0", "output": "24\n264\n"...
code_stdio
[ { "content": "Ujan has a lot of numbers in his boxes. He likes order and balance, so he decided to reorder the numbers.\n\nThere are $k$ boxes numbered from $1$ to $k$. The $i$-th box contains $n_i$ integer numbers. The integers can be negative. All of the integers are distinct. \n\nUjan is lazy, so he will do ...
[{"input": "5\n10 -251 650 475 -114 364 -75754 -982 -532 -151 -484\n10 -623 -132 -317561 -438 20 -275 -323 -530089 -311 -587\n10 450900 -519 903 -401 -789 -606529 277 -267 -682 -161\n10 -246 873 -641 838 719 234 789 -74 -287288 -772972\n10 186 741 -927 -866 -855 578 -1057019 202 162962 -458\n", "output": "Yes\n650 3\n-...
code_stdio
[ { "content": "Kamil likes streaming the competitive programming videos. His MeTube channel has recently reached $100$ million subscribers. In order to celebrate this, he posted a video with an interesting problem he couldn't solve yet. Can you help him?\n\nYou're given a tree β€” a connected undirected graph cons...
[{"input": "32\n402528994560 0 0 0 0 0 0 932646223872 893192888700 0 813583026900 0 0 0 0 143521875000 0 177570054144 186624000000 0 517655600000 202145625000 341007975000 0 116252718750 0 148561875000 0 304819200000 248474688000 0 103125000000\n29 25\n20 24\n8 21\n23 3\n32 14\n29 30\n31 24\n28 12\n7 10\n18 1\n11 7\n29...
code_stdio
[ { "content": "Anastasia loves going for a walk in Central Uzhlyandian Park. But she became uninterested in simple walking, so she began to collect Uzhlyandian pebbles. At first, she decided to collect all the pebbles she could find in the park.\n\nShe has only two pockets. She can put at most k pebbles in each ...
[{"input": "9 13\n132 166 200 62 168 51 185 192 118\n", "output": "51\n"}, {"input": "9 13\n132 166 200 62 168 58 185 192 118\n", "output": "52\n"}, {"input": "9 13\n132 166 200 62 168 58 106 192 118\n", "output": "49\n"}, {"input": "9 13\n132 166 200 62 168 58 299 192 118\n", "output": "56\n"}, {"input": "9 13\n186 16...
code_stdio
[ { "content": "There are N blocks arranged in a row. Let us paint these blocks.\nWe will consider two ways to paint the blocks different if and only if there is a block painted in different colors in those two ways.\nFind the number of ways to paint the blocks under the following conditions:\n - For each block, ...
[{"input": "200000 200000 199999\n", "output": "703273590\n"}, {"input": "178720 187658 129518\n", "output": "963607179\n"}, {"input": "189770 199455 133747\n", "output": "971381227\n"}, {"input": "189992 49130 122242\n", "output": "956044281\n"}, {"input": "146600 147466 95872\n", "output": "932390522\n"}, {"input": "...
code_stdio
[ { "content": "Vasya plays a computer game with ninjas. At this stage Vasya's ninja should get out of a deep canyon.\n\nThe canyon consists of two vertical parallel walls, their height is n meters. Let's imagine that we split these walls into 1 meter-long areas and number them with positive integers from 1 to n ...
[{"input": "101 1\n----------------------------------------------------------------------------------------------------X\n----------------------------------------------------------------------------------------------------X\n", "output": "NO\n"}, {"input": "100 10\n-X------XXX--XXX-XXXXXX---XXX---X-XX--XXX----------XX-...
code_stdio
[ { "content": "You will be given a string S of length 3 representing the weather forecast for three days in the past.\nThe i-th character (1 \\leq i \\leq 3) of S represents the forecast for the i-th day. S, C, and R stand for sunny, cloudy, and rainy, respectively.\nYou will also be given a string T of length 3...
[{"input": "CSS\nCSR\n", "output": "2\n"}, {"input": "SSR\nSSR\n", "output": "3\n"}, {"input": "RRR\nSSS\n", "output": "0\n"}, {"input": "SSS\nSSS\n", "output": "3\n"}, {"input": "CCC\nSSS\n", "output": "0\n"}, {"input": "RSC\nRCS\n", "output": "1\n"}, {"input": "CCC\nSCS\n", "output": "1\n"}, {"input": "RRC\nCRS\n", "...
code_stdio
[ { "content": "This is the easy version of this problem. The only difference is the constraint on $k$ β€” the number of gifts in the offer. In this version: $k=2$.\n\nVasya came to the store to buy goods for his friends for the New Year. It turned out that he was very luckyΒ β€” today the offer \"$k$ of goods for the...
[{"input": "8\n5 11 2\n2 4 3 5 14\n5 11 2\n2 4 3 5 7\n3 3 3\n4 2 6\n5 2 3\n10 1 3 9 2\n2 10000 2\n10100 10000\n2 9999 2\n10000 10000\n4 6 4\n3 2 3 2\n5 5 3\n1 2 2 1 2\n", "output": "4\n4\n1\n2\n1\n0\n4\n5\n"}, {"input": "8\n5 11 2\n2 3 3 5 13\n5 11 2\n2 4 3 5 7\n3 2 3\n4 2 6\n5 2 6\n10 1 3 9 2\n2 10000 2\n10100 10000\n...
code_stdio
[ { "content": "Polycarp is a beginner programmer. He is studying how to use a command line.\n\nPolycarp faced the following problem. There are n files in a directory and he needs to delete some of them. Polycarp wants to run a single delete command with filename pattern as an argument. All the files to be delete...
[{"input": "2 1\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaac\n1\n", "output": "Yes\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
code_stdio
[ { "content": "You are given a string S of length 3 consisting of a, b and c. Determine if S can be obtained by permuting abc.\n\n-----Constraints-----\n - |S|=3\n - S consists of a, b and c.\n\n-----Input-----\nInput is given from Standard Input in the following format:\nS\n\n-----Output-----\nIf S can be obtai...
[{"input": "bac\n", "output": "Yes\n"}, {"input": "abc\n", "output": "Yes\n"}, {"input": "bab\n", "output": "No\n"}, {"input": "aaa\n", "output": "No\n"}, {"input": "cab", "output": "Yes\n"}, {"input": "acb", "output": "Yes\n"}, {"input": "cba", "output": "Yes\n"}, {"input": "bca", "output": "Yes\n"}, {"input": "bba", ...
code_stdio
[ { "content": "Statistics claims that students sleep no more than three hours a day. But even in the world of their dreams, while they are snoring peacefully, the sense of impending doom is still upon them.\n\nA poor student is dreaming that he is sitting the mathematical analysis exam. And he is examined by the...
[{"input": "100 100\n50 50\n", "output": "NO\n"}, {"input": "82 60\n100 38\n", "output": "YES\n"}, {"input": "100 100\n36 50\n", "output": "NO\n"}, {"input": "82 60\n100 64\n", "output": "YES\n"}, {"input": "150 35\n53 79\n", "output": "YES\n"}, {"input": "82 60\n100 52\n", "output": "YES\n"}, {"input": "166 12\n87 103...
code_stdio
[ { "content": "Kate and Michael want to buy a pizza and share it. Depending on the price of the pizza, they are going to divide the costs:\n\n* If the pizza is less than €5,- Michael invites Kate, so Michael pays the full price.\n* Otherwise Kate will contribute 1/3 of the price, but no more than €10 (she's brok...
[{"input": "28.789", "output": "[19.19]", "fn_name": "michael_pays"}, {"input": "5.9181", "output": "[3.95]", "fn_name": "michael_pays"}, {"input": "4.325", "output": "[4.33]", "fn_name": "michael_pays"}, {"input": "4.99", "output": "[4.99]", "fn_name": "michael_pays"}, {"input": "22", "output": "[14.67]", "fn_name": "...
code_functional
[ { "content": "Numbers $1, 2, 3, \\dots n$ (each integer from $1$ to $n$ once) are written on a board. In one operation you can erase any two numbers $a$ and $b$ from the board and write one integer $\\frac{a + b}{2}$ rounded up instead.\n\nYou should perform the given operation $n - 1$ times and make the result...
[{"input": "1\n275\n", "output": "2\n275 274\n275 273\n274 272\n273 271\n272 270\n271 269\n270 268\n269 267\n268 266\n267 265\n266 264\n265 263\n264 262\n263 261\n262 260\n261 259\n260 258\n259 257\n258 256\n257 255\n256 254\n255 253\n254 252\n253 251\n252 250\n251 249\n250 248\n249 247\n248 246\n247 245\n246 244\n245 ...
code_stdio
[ { "content": "You are given a rectangular field of n Γ— m cells. Each cell is either empty or impassable (contains an obstacle). Empty cells are marked with '.', impassable cells are marked with '*'. Let's call two empty cells adjacent if they share a side.\n\nLet's call a connected component any non-extendible ...
[{"input": "10 10\n*.*...*.**\n..*...*.**\n.**.***...\n....*.*.**\n***....***\n.*..*...*.\n.***.*..*.\n.*****.*.*\n*.***.*...\n..*..*....\n", "output": "9.9...5.71\n..9...5.77\n.99.997...\n....9.5.77\n299....513\n.2..0...1.\n.490.0..9.\n.71120.7.1\n7.434.8...\n..6..2....\n"}, {"input": "10 10\n*.*...*.**\n..*...*.**\n....
code_stdio
[ { "content": "Input\n\nThe only line of input contains three integers a1, a2, a3 (1 ≀ a1, a2, a3 ≀ 20), separated by spaces.\n\nOutput\n\nOutput a single integer.\n\nExamples\n\nInput\n\n2 3 2\n\n\nOutput\n\n5\n\n\nInput\n\n13 14 1\n\n\nOutput\n\n14\n\n\nInput\n\n14 5 9\n\n\nOutput\n\n464\n\n\nInput\n\n17 18 3\...
[{"input": "20 20 20\n", "output": "218920\n"}, {"input": "1 19 20\n", "output": "132716\n"}, {"input": "10 11 15\n", "output": "10480\n"}, {"input": "10 11 12\n", "output": "2474\n"}, {"input": "12 9 18\n", "output": "42420\n"}, {"input": "1 19 15\n", "output": "11967\n"}, {"input": "1 19 17\n", "output": "31330\n"}, ...
code_stdio
[ { "content": "Leha somehow found an array consisting of n integers. Looking at it, he came up with a task. Two players play the game on the array. Players move one by one. The first player can choose for his move a subsegment of non-zero length with an odd sum of numbers and remove it from the array, after that...
[{"input": "4\n1000000000 1000000000 1000000000 99999999\n", "output": "First\n"}, {"input": "4\n1000000000 1000000000 1000000000 99999999\n", "output": "First\n"}, {"input": "4\n1000000000 1000000001 1000000000 99999999\n", "output": "First\n"}, {"input": "4\n1000000000 1000000001 1000000000 80256192\n", "output": "Fi...
code_stdio
[ { "content": "There are $n$ consecutive seat places in a railway carriage. Each place is either empty or occupied by a passenger.\n\nThe university team for the Olympiad consists of $a$ student-programmers and $b$ student-athletes. Determine the largest number of students from all $a+b$ students, which you can ...
[{"input": "64 59 2\n.*.***......****.*..**..**..****.*.*.*.**...**..***.***.*..*..*.\n", "output": "23\n"}, {"input": "64 59 2\n.*.***......****.*..**..**..****.*.*.*.**...**..***.***.*..*..*.\n", "output": "23\n"}, {"input": "64 59 3\n.*.***......****.*..**..**..****.*.*.*.**...**..***.***.*..*..*.\n", "output": "24\...
code_stdio
[ { "content": "A dragon symbolizes wisdom, power and wealth. On Lunar New Year's Day, people model a dragon with bamboo strips and clothes, raise them with rods, and hold the rods high and low to resemble a flying dragon.\n\nA performer holding the rod low is represented by a 1, while one holding it high is repr...
[{"input": "200\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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": "You've got string s, consisting of only lowercase English letters. Find its lexicographically maximum subsequence.\n\nWe'll call a non-empty string s[p1p2... pk] = sp1sp2... spk(1 ≀ p1 < p2 < ... < pk ≀ |s|) a subsequence of string s = s1s2... s|s|.\n\nString x = x1x2... x|x| is lexicographically ...
[{"input": "zyxzxzwyxywxxwabcdabdacdbcacdbcacabaaba\n", "output": "zzzyyxxwddddccbba\n"}, {"input": "zyxzxzwyxybxxwabcdawdacdccacdbcacabaaba\n", "output": "zzzyyxxwwdddccbba\n"}, {"input": "thankstosamarasauteddybearsforthiscontest\n", "output": "yttt\n"}, {"input": "thamkstosamarasauteddybearsforthiscontest\n", "outpu...
code_stdio
[ { "content": "A string $s$ of length $n$ ($1 \\le n \\le 26$) is called alphabetical if it can be obtained using the following algorithm:\n\nfirst, write an empty string to $s$ (i.e. perform the assignment $s$ := \"\");\n\nthen perform the next step $n$ times;\n\nat the $i$-th step take $i$-th lowercase letter ...
[{"input": "11\na\nba\nab\nbac\nihfcbadeg\nz\naa\nca\nacb\nxyz\nddcba\n", "output": "YES\nYES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO\n"}, {"input": "11\na\nba\nab\ncac\nihfcbadeg\nz\nab\nca\nbca\nxyz\nddcba\n", "output": "YES\nYES\nYES\nNO\nYES\nNO\nYES\nNO\nNO\nNO\nNO\n"}, {"input": "11\na\nba\nab\nbac\nihfcbadeg\nz\n...
code_stdio
[ { "content": "Write a function \n```javascript \ntripledouble(num1,num2)\n```\n```python\ntriple_double(num1, num2)\n```\nwhich takes numbers `num1` and `num2` and returns `1` if there is a straight triple of a number at any place in `num1` and also a straight double of the **same** number in `num2`.\n\nIf this...
[{"input": "451999277\n41177722899", "output": "[1]", "fn_name": "triple_double"}, {"input": "666789\n12345667", "output": "[1]", "fn_name": "triple_double"}, {"input": "1222345\n12345", "output": "[0]", "fn_name": "triple_double"}, {"input": "10560002\n100", "output": "[1]", "fn_name": "triple_double"}, {"input": "123...
code_functional
[ { "content": "There are many anime that are about \"love triangles\": Alice loves Bob, and Charlie loves Bob as well, but Alice hates Charlie. You are thinking about an anime which has n characters. The characters are labeled from 1 to n. Every pair of two characters can either mutually love each other or mutua...
[{"input": "28567 13\n28079 24675 1\n18409 26720 1\n980 10815 1\n20794 16571 1\n7376 19861 1\n11146 706 1\n4255 16391 1\n27376 18263 1\n10019 28444 1\n6574 28053 1\n5036 16610 1\n3543 7122 1\n512 9554 1\n", "output": " 928433852\n"}, {"input": "28567 13\n28079 24675...
code_stdio
[ { "content": "You are given a sequence of integers $a_1, a_2, \\dots, a_n$. You need to paint elements in colors, so that: If we consider any color, all elements of this color must be divisible by the minimal element of this color. The number of used colors must be minimized. \n\nFor example, it's fine to pa...
[{"input": "100\n94 83 55 57 63 89 73 59 75 97 77 54 77 81 70 81 99 52 88 76 98 88 79 67 76 80 89 50 60 60 53 83 96 87 75 99 61 91 75 85 88 80 90 54 84 88 98 93 69 97 93 54 83 59 57 92 88 78 53 55 99 63 60 70 61 52 60 55 100 85 80 58 53 97 59 61 50 90 75 85 86 63 91 96 67 68 86 96 79 98 51 83 82 92 65 100 76 83 57 100\...
code_stdio
[ { "content": "International Abbreviation Olympiad takes place annually starting from 1989. Each year the competition receives an abbreviation of form IAO'y, where y stands for some number of consequent last digits of the current year. Organizers always pick an abbreviation with non-empty string y that has never...
[{"input": "9\nIAO'0\nIAO'00\nIAO'000\nIAO'0000\nIAO'00000\nIAO'000000\nIAO'0000000\nIAO'00000000\nIAO'000000000\n", "output": "1990\n2000\n3000\n10000\n100000\n1000000\n10000000\n100000000\n1000000000\n"}, {"input": "5\nIAO'15\nIAO'2015\nIAO'1\nIAO'9\nIAO'0\n", "output": "2015\n12015\n1991\n1989\n1990\n"}, {"input": "...
code_stdio
[ { "content": "You are given a garland consisting of $n$ lamps. States of the lamps are represented by the string $s$ of length $n$. The $i$-th character of the string $s_i$ equals '0' if the $i$-th lamp is turned off or '1' if the $i$-th lamp is turned on. You are also given a positive integer $k$.\n\nIn one mo...
[{"input": "6\n9 2\n010001010\n9 3\n111100000\n7 4\n1111111\n10 3\n1001110101\n1 1\n1\n1 1\n0\n", "output": "1\n2\n5\n4\n0\n0\n"}, {"input": "6\n9 2\n010001010\n9 3\n111100000\n7 4\n1111111\n10 3\n1001110101\n1 1\n0\n1 1\n0\n", "output": "1\n2\n5\n4\n0\n0\n"}, {"input": "6\n9 2\n010001010\n9 5\n111100000\n7 4\n1111111\...
code_stdio
[ { "content": "Kolya loves putting gnomes at the circle table and giving them coins, and Tanya loves studying triplets of gnomes, sitting in the vertexes of an equilateral triangle.\n\nMore formally, there are 3n gnomes sitting in a circle. Each gnome can have from 1 to 3 coins. Let's number the places in the or...
[{"input": "100000\n", "output": "192156836"}, {"input": "100000\n", "output": "192156836"}, {"input": "100000\n", "output": "192156836"}, {"input": "10701\n", "output": "198227529\n"}, {"input": "10010\n", "output": "495680028\n"}, {"input": "62113\n", "output": "786955632\n"}, {"input": "48613\n", "output": "33515912...
code_stdio
[ { "content": "You are given a problemset consisting of $n$ problems. The difficulty of the $i$-th problem is $a_i$. It is guaranteed that all difficulties are distinct and are given in the increasing order.\n\nYou have to assemble the contest which consists of some problems of the given problemset. In other wor...
[{"input": "9\n4 6 9 12 100 150 200 400 800\n", "output": "5\n"}, {"input": "9\n4 6 9 12 100 150 200 400 800\n", "output": "5\n"}, {"input": "9\n4 6 9 12 100 150 200 400 612\n", "output": "5\n"}, {"input": "9\n4 2 9 12 100 150 200 400 612\n", "output": "5\n"}, {"input": "10\n1 2 5 11 12 24 25 26 27 28\n", "output": "7\...
code_stdio
[ { "content": "One company of IT City decided to create a group of innovative developments consisting from 5 to 7 people and hire new employees for it. After placing an advertisment the company received n resumes. Now the HR department has to evaluate each possible group composition and select one of them. Your ...
[{"input": "700\n", "output": "16017044425409540\n"}, {"input": "776\n", "output": "33019955679376860\n"}, {"input": "666\n", "output": "11292070960994226\n"}, {"input": "777\n", "output": "33319741730082870\n"}, {"input": "756\n", "output": "27490983258573432\n"}, {"input": "666\n", "output": "11292070960994226"}, {"i...
code_stdio
[ { "content": "You are given an integer $n$ and an integer $k$.\n\nIn one step you can do one of the following moves: decrease $n$ by $1$; divide $n$ by $k$ if $n$ is divisible by $k$. \n\nFor example, if $n = 27$ and $k = 3$ you can do the following steps: $27 \\rightarrow 26 \\rightarrow 25 \\rightarrow 24 ...
[{"input": "93\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\...
code_stdio
[ { "content": "# Task\nN lamps are placed in a line, some are switched on and some are off. What is the smallest number of lamps that need to be switched so that on and off lamps will alternate with each other? \n\nYou are given an array `a` of zeros and ones - `1` mean switched-on lamp and `0` means switched-of...
[{"input": "[1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1]", "output": "[5]", "fn_name": "lamps"}, {"input": "[1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0]", "output": "[5]", "fn_name": "lamps"}, {"input": "[1, 0, 1, 0, 0, 1, 0, 1]", "output": "[4]", "fn_name": "lamps"}, {"input": "[0, 1, 0, 1, 0]", "output": "[0]", "fn_name": "lamps"}, {"inpu...
code_functional
[ { "content": "Given a string, capitalize the letters that occupy even indexes and odd indexes separately, and return as shown below. Index `0` will be considered even.\n\nFor example, `capitalize(\"abcdef\") = ['AbCdEf', 'aBcDeF']`. See test cases for more examples.\n\nThe input will be a lowercase string with ...
[{"input": "\"codingisafunactivity\"", "output": "[[\"CoDiNgIsAfUnAcTiViTy\", \"cOdInGiSaFuNaCtIvItY\"]]", "fn_name": "capitalize"}, {"input": "\"indexinglessons\"", "output": "[[\"InDeXiNgLeSsOnS\", \"iNdExInGlEsSoNs\"]]", "fn_name": "capitalize"}, {"input": "\"codewarriors\"", "output": "[[\"CoDeWaRrIoRs\", \"cOdEwAr...
code_functional
[ { "content": "Dr. Sato, a botanist, invented a number of special fertilizers for seedlings. When you give the fertilizer to the seedlings, the size of the seedlings changes in a blink of an eye. However, it was found that fertilizer has the following side effects.\n\n* The size of the seedlings does not change ...
[{"input": "3 3\n1.8036677694351575 3.7376015310643522 0.9359006248557373\n4.789021816134845 2.456993805979323 1.0\n3.0 1.470921439035275 1.5624820640788264\n2 7\n1.2643980385584639 1.3805003041132355\n2.3877376705228617 1.9499455465451372\n0 0", "output": "17.90\n67.31\n"}, {"input": "3 3\n1.8036677694351575 3.6908040...
code_stdio
[ { "content": "Ayush is a cashier at the shopping center. Recently his department has started a ''click and collect\" service which allows users to shop online. \n\nThe store contains k items. n customers have already used the above service. Each user paid for m items. Let a_{ij} denote the j-th item in the i-th...
[{"input": "10 1 100\n1 55 67 75 40 86 24 84 82 26 81 23 70 79 51 54 21 78 31 98 68 93 66 88 99 65 20 52 35 85 16 12 94 100 59 56 18 33 47 46 71 8 38 57 2 92 3 95 6 4 87 22 48 80 15 29 11 45 72 76 44 60 91 90 39 74 41 36 13 27 53 83 32 10 30 63 89 64 49 17 9 97 69 14 50 77 37 96 10 42 28 34 61 19 73 7 62 43 58 25\n33\n...
code_stdio
[ { "content": "Consider an array containing cats and dogs. Each dog can catch only one cat, but cannot catch a cat that is more than `n` elements away. Your task will be to return the maximum number of cats that can be caught.\n\nFor example:\n```Haskell\nsolve(['D','C','C','D','C'], 2) = 2, because the dog at i...
[{"input": "[\"C\", \"C\", \"C\", \"D\", \"D\", \"D\", \"C\", \"D\", \"D\", \"D\", \"C\", \"D\", \"C\", \"C\"]\n2", "output": "[5]", "fn_name": "solve"}, {"input": "[\"C\", \"C\", \"D\", \"D\", \"C\", \"D\"]\n2", "output": "[3]", "fn_name": "solve"}, {"input": "[\"C\", \"C\", \"D\", \"D\", \"C\", \"D\"]\n1", "output": ...
code_functional
[ { "content": "There are n animals in the queue to Dr. Dolittle. When an animal comes into the office, the doctor examines him, gives prescriptions, appoints tests and may appoint extra examination. Doc knows all the forest animals perfectly well and therefore knows exactly that the animal number i in the queue ...
[{"input": "150 2476\n70 21 114 127 22 11 29 59 51 59 35 3 53 88 5 8 44 4 12 100 1 27 1 25 27 56 48 22 23 103 85 66 14 58 20 7 176 11 19 26 154 97 83 3 29 30 52 92 59 11 135 37 59 8 66 20 47 19 143 16 93 18 57 71 1 13 141 1 119 6 2 87 40 68 28 22 20 53 31 19 15 33 32 9 70 63 16 26 77 7 45 52 73 25 22 21 68 79 16 3 164 ...
code_stdio
[ { "content": "You are given n segments on the coordinate axis Ox and the number k. The point is satisfied if it belongs to at least k segments. Find the smallest (by the number of segments) set of segments on the coordinate axis Ox which contains all satisfied points and no others.\n\nInput\n\nThe first line co...
[{"input": "10 1\n-260424665 -168566709\n299109864 663179811\n769984405 942516913\n-998905510 -707148023\n-167958021 60599275\n658861231 718845364\n79407402 279078536\n13652788 79756488\n-676213666 -339118351\n-349156760 -258185154\n", "output": "5\n-998905510 -707148023\n-676213666 -168566709\n-167958021 279078536\n29...
code_stdio
[ { "content": "There are a number of ways to shuffle a deck of cards. Riffle shuffle is one such example. The following is how to perform riffle shuffle.\n\nThere is a deck of n cards. First, we divide it into two decks; deck A which consists of the top half of it and deck B of the bottom half. Deck A will have ...
[{"input": "17 1\n1\n28 4\n1 1 6 4", "output": "16\n19\n"}, {"input": "17 1\n1\n28 4\n1 2 6 4", "output": "16\n12\n"}, {"input": "6 1\n3\n18 4\n2 1 11 11", "output": "2\n13\n"}, {"input": "10 1\n3\n18 4\n2 2 12 4", "output": "4\n13\n"}, {"input": "16 1\n3\n11 4\n1 2 6 4", "output": "7\n10\n"}, {"input": "14 1\n2\n11 4\...
code_stdio
[ { "content": "There is enough money available on ATM in nominal value 10, 20, 50, 100, 200 and 500 dollars.\n\nYou are given money in nominal value of `n` with `1<=n<=1500`.\n\nTry to find minimal number of notes that must be used to repay in dollars, or output -1 if it is impossible.\n\nGood Luck!!!\n\nWrite P...
[{"input": "1250", "output": "[4]", "fn_name": "solve"}, {"input": "125", "output": "[-1]", "fn_name": "solve"}, {"input": "666", "output": "[-1]", "fn_name": "solve"}, {"input": "770", "output": "[4]", "fn_name": "solve"}, {"input": "550", "output": "[2]", "fn_name": "solve"}, {"input": "42", "output": "[-1]", "fn_nam...
code_functional
[ { "content": "Mr. Bender has a digital table of size n Γ— n, each cell can be switched on or off. He wants the field to have at least c switched on squares. When this condition is fulfilled, Mr Bender will be happy.\n\nWe'll consider the table rows numbered from top to bottom from 1 to n, and the columns β€” numbe...
[{"input": "1000000000 999999938 999999936 384381709\n", "output": "27600\n"}, {"input": "1000000000 999999946 999999941 715189365\n", "output": "37707\n"}, {"input": "1000000000 999999916 999999940 857945620\n", "output": "41279\n"}, {"input": "1000000000 504951981 646612086 602763371\n", "output": "17360\n"}, {"input...
code_stdio
[ { "content": "You are given an array $a$ consisting of $n$ integers. Let's denote monotonic renumeration of array $a$ as an array $b$ consisting of $n$ integers such that all of the following conditions are met:\n\n $b_1 = 0$; for every pair of indices $i$ and $j$ such that $1 \\le i, j \\le n$, if $a_i = a_j...
[{"input": "200\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 7 7 7 7 7 7 7 7 7 7 7 7 7 7 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8...
code_stdio
[ { "content": "Luba has to do n chores today. i-th chore takes a_{i} units of time to complete. It is guaranteed that for every $i \\in [ 2 . . n ]$ the condition a_{i} β‰₯ a_{i} - 1 is met, so the sequence is sorted.\n\nAlso Luba can work really hard on some chores. She can choose not more than k any chores and d...
[{"input": "100 1 99\n100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 10...
code_stdio
[ { "content": "We have a string s consisting of lowercase English letters. Snuke can perform the following operation repeatedly:\n\n* Insert a letter `x` to any position in s of his choice, including the beginning and end of s.\n\n\n\nSnuke's objective is to turn s into a palindrome. Determine whether the object...
[{"input": "bxbax", "output": "-1\n"}, {"input": "xxabb", "output": "-1\n"}, {"input": "xyabb", "output": "-1\n"}, {"input": "bbayx", "output": "-1\n"}, {"input": "bb`yx", "output": "-1\n"}, {"input": "bb`xx", "output": "-1\n"}, {"input": "bc`xx", "output": "-1\n"}, {"input": "cc`xx", "output": "-1\n"}, {"input": "xx`c...
code_stdio
[ { "content": "Polycarp urgently needs a shovel! He comes to the shop and chooses an appropriate one. The shovel that Policarp chooses is sold for k burles. Assume that there is an unlimited number of such shovels in the shop.\n\nIn his pocket Polycarp has an unlimited number of \"10-burle coins\" and exactly on...
[{"input": "1000 12\n", "output": "1\n"}, {"input": "1000 18\n", "output": "1\n"}, {"input": "1000 19\n", "output": "1\n"}, {"input": "1100 19\n", "output": "1\n"}, {"input": "1010 13\n", "output": "1\n"}, {"input": "1100 22\n", "output": "1\n"}, {"input": "0010 13\n", "output": "1\n"}, {"input": "1000 3\n", "output": ...
code_stdio
[ { "content": "A schoolboy named Vasya loves reading books on programming and mathematics. He has recently read an encyclopedia article that described the method of median smoothing (or median filter) and its many applications in science and engineering. Vasya liked the idea of the method very much, and he decid...
[{"input": "168\n0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 0 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 1 0 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1...
code_stdio
[ { "content": "Chef has learned a new technique for comparing two recipes. A recipe contains a list of ingredients in increasing order of the times they will be processed. An ingredient is represented by a letter 'a'-'z'. The i-th letter in a recipe denotes the i-th ingredient. An ingredient can be used multiple...
[{"input": "3\nelax axle\nesidarap djapers\nalice bob", "output": "YES\nYES\nYES\n"}, {"input": "3\nelax ayle\nesidarap djapers\nalice bob", "output": "YES\nYES\nYES\n"}, {"input": "3\nelax ayle\nesidarap srepajd\nalice bob", "output": "YES\nYES\nYES\n"}, {"input": "3\nelax ayle\netidarap srepajd\nalice bob", "output":...
code_stdio
[ { "content": "You are given a keyboard that consists of $26$ keys. The keys are arranged sequentially in one row in a certain order. Each key corresponds to a unique lowercase Latin letter.\n\nYou have to type the word $s$ on this keyboard. It also consists only of lowercase Latin letters.\n\nTo type a word, yo...
[{"input": "5\nabcdefghijklmnopqrstuvwxyz\nnlleh\nabcxefghijklmnopqrstuvwdyz\ni\nabcdefghhjllmnzpqrstuvwxyo\ncodeforecs\nmnbvcxzlkjhefdsapoiuytrgwq\nqqqqqqqpqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq\nqwertyuiopasdfghjklzxcvbnm\nabacaba\n", "output": "12\n0\n106\n18\n74\n"}, {"input": "5\nabcdefghijklmnopqrstuvwxyz\nhe...
code_stdio
[ { "content": "This is the hard version of the problem. The difference between versions is the constraints on $n$ and $a_i$. You can make hacks only if all versions of the problem are solved.\n\nFirst, Aoi came up with the following idea for the competitive programming problem:\n\nYuzu is a girl who collecting c...
[{"input": "87 83\n40 6 7 50 16 65 47 90 94 65 79 29 41 76 80 13 87 37 92 71 54 53 93 79 14 53 71 78 50 50 74 40 30 92 66 86 94 60 37 65 82 14 61 48 68 71 91 99 74 88 89 34 57 74 25 2 79 72 92 37 61 16 32 85 29 74 6 69 50 74 76 48 31 42 40 95 29 27 28 31 38 60 52 45 14 78 59\n", "output": "75\n17 18 19 20 21 22 23 24 2...
code_stdio
[ { "content": "Given is a string S consisting of lowercase English letters. Find the maximum positive integer K that satisfies the following condition:\n\n* There exists a partition of S into K non-empty strings S=S_1S_2...S_K such that S_i \\neq S_{i+1} (1 \\leq i \\leq K-1).\n\n\n\nHere S_1S_2...S_K represents...
[{"input": "aaaccacabaababb", "output": "11\n"}, {"input": "abbccacabaababa", "output": "13\n"}, {"input": "abbccaaabaababc", "output": "12\n"}, {"input": "`abab`cbbba`c`b", "output": "14\n"}, {"input": "`_b`ab`_babcdba", "output": "15\n"}, {"input": "aabccacabaababb", "output": "11\n"}, {"input": "bbabaabacaccbaa", "o...
code_stdio
[ { "content": "n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≀ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any...
[{"input": "1000000000 1000000000 1000000000\n", "output": "1\n"}, {"input": "100000000 999834114 93836827\n", "output": "29998\n"}, {"input": "1000000000 1000000000 1000000000\n", "output": "1\n"}, {"input": "100000000 999834114 93836827\n", "output": "29998\n"}, {"input": "1000000000 1000000010 1000000000\n", "output...
code_stdio
[ { "content": "problem\n\nJOI decided to make a signboard for the store.\n\nThere are N old signboards with letters written at equal intervals. JOI makes a sign by erasing some letters from the old sign. I want the remaining characters to be the name of the store, and the remaining characters to be evenly spaced...
[{"input": "4\nbar\nabracadabra\nbear\nbar\nbbraxbara", "output": "3\n"}, {"input": "4\nrab\nabracadabra\nbear\nbar\nbbraxbara", "output": "1\n"}, {"input": "4\nrab\nabracadabra\nbear\nbar\narabxarbb", "output": "2\n"}, {"input": "4\nqab\nabracadabra\nbear\nbar\narabxarbb", "output": "0\n"}, {"input": "4\nqab\nabracada...
code_stdio
[ { "content": "A wise king declared a new calendar. \"Tomorrow shall be the first day of the calendar, that is, the day 1 of the month 1 of the year 1. Each year consists of 10 months, from month 1 through month 10, and starts from a big month. A common year shall start with a big month, followed by small months...
[{"input": "8\n-1 1 1\n344 4 0\n738 4 2\n182 9 5\n992 5 6\n344 5 26\n696 6 19\n231 8 25", "output": "196865\n128957\n51469\n160715\n1492\n128912\n59672\n151076\n"}, {"input": "8\n-1 1 1\n344 3 0\n738 4 2\n182 9 5\n998 5 7\n344 5 26\n696 6 19\n231 10 25", "output": "196865\n128977\n51469\n160715\n311\n128912\n59672\n151...
code_stdio
[ { "content": "problem\n\nA city in Canada where JOI lives is divided into a grid pattern by w roads that extend straight in the north-south direction and h roads that extend straight in the east-west direction.\n\nThe w roads in the north-south direction are numbered 1, 2, ..., w in order from the west. In addi...
[{"input": "10 4\n13 70\n0 0", "output": "26\n55422\n"}, {"input": "10 4\n13 80\n0 0", "output": "26\n77629\n"}, {"input": "4 5\n13 34\n0 0", "output": "11\n61707\n"}, {"input": "8 4\n15 33\n0 0", "output": "20\n41241\n"}, {"input": "4 7\n12 40\n0 0", "output": "17\n43422\n"}, {"input": "6 5\n13 38\n0 0", "output": "26...
code_stdio
[ { "content": "Alexey, a merry Berland entrant, got sick of the gray reality and he zealously wants to go to university. There are a lot of universities nowadays, so Alexey is getting lost in the diversity β€” he has not yet decided what profession he wants to get. At school, he had bad grades in all subjects, and...
[{"input": "50\n69 6 6\n22 1 1\n23 3 3\n60 13 13\n13 3 3\n7 4 7\n6 1 1\n49 7 9\n68 8 8\n20 2 2\n34 1 1\n143 5 5\n22 1 1\n77 58 65\n10 3 3\n72 5 5\n47 1 1\n82 3 3\n92 8 8\n34 1 1\n42 9 10\n63 14 14\n10 3 3\n38 2 2\n80 6 6\n79 5 5\n53 5 5\n44 7 7\n85 2 2\n24 2 2\n57 3 3\n95 29 145\n77 6 6\n24 1 1\n33 4 4\n93 6 6\n55 22 2...
code_stdio
[ { "content": "problem\n\nAOR Ika is studying to pass the test.\n\nAOR Ika-chan solved the $ N $ question. After that, round the solved problem according to the following procedure.\n\n1. Check the correctness of the answer.\n2. If the answer is correct, write a circle mark, and if it is incorrect, write a cross...
[{"input": "3\nnxx", "output": "2\n"}, {"input": "3\nnwx", "output": "3\n"}, {"input": "3\nxxo", "output": "1\n"}, {"input": "3\nxwn", "output": "3\n"}, {"input": "3\nowx", "output": "3\n"}, {"input": "3\npxx", "output": "2\n"}, {"input": "3\npyx", "output": "3\n"}, {"input": "3\npzx", "output": "3\n"}, {"input": "3\np...
code_stdio
[ { "content": "A bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters Β«+Β» and Β«1Β» into this sequence. For example, sequences Β«(())()Β», Β«()Β» and Β«(()(()))Β» are regular, while Β«)(Β», Β«(()Β» and Β«(()))(Β» are not.\n\nOne day Johnny got bracket sequence. H...
[{"input": "))())))))))())))))()()))()()))))())))))()))))))))))))(()))())(()))))(()))))())))((((()()))))()))()))\n", "output": "48\n"}, {"input": ")))()))()))))()((((())))()))))(()))))(())()))(()))))))))))))())))))()))))()()))()())))))())))))))())\n", "output": "48\n"}, {"input": ")))()))()))))()((((())))()))))(()))))(...
code_stdio
[ { "content": "Tomya is a girl. She loves Chef Ciel very much.\n\nTomya like a positive integer p, and now she wants to get a receipt of Ciel's restaurant whose total price is exactly p.\nThe current menus of Ciel's restaurant are shown the following table.\nName of Menupriceeel flavored water1deep-fried eel bon...
[{"input": "4\n10\n1012\n255\n4096", "output": "2\n7\n8\n2\n"}, {"input": "4\n12\n379\n297\n6095", "output": "2\n7\n4\n11\n"}, {"input": "4\n10\n376\n255\n4096", "output": "2\n5\n8\n2\n"}, {"input": "4\n10\n376\n255\n3088", "output": "2\n5\n8\n3\n"}, {"input": "4\n11\n376\n255\n3088", "output": "3\n5\n8\n3\n"}, {"input...
code_stdio
[ { "content": "Student Vladislav came to his programming exam completely unprepared as usual. He got a question about some strange algorithm on a graph β€” something that will definitely never be useful in real life. He asked a girl sitting next to him to lend him some cheat papers for this questions and found the...
[{"input": "10 15\n900000007 1\n900000002 1\n900000004 0\n900000002 1\n900000006 1\n900000000 1\n900000006 1\n900000008 1\n900000002 0\n1419868175 0\n900000002 0\n900000005 0\n900000001 0\n900000000 1\n900000008 1\n", "output": "1 8\n1 4\n2 5\n1 5\n1 6\n1 2\n1 7\n1 9\n2 4\n4 5\n3 4\n3 5\n2 3\n1 3\n1 10\n"}, {"input": "...
code_stdio
[ { "content": "Fox Ciel is playing a card game with her friend Jiro.\n\nJiro has n cards, each one has two attributes: position (Attack or Defense) and strength. Fox Ciel has m cards, each one has these two attributes too. It's known that position of all Ciel's cards is Attack.\n\nNow is Ciel's battle phase, Cie...
[{"input": "36 30\nATK 116\nATK 120\nATK 122\nATK 120\nATK 116\nATK 118\nATK 123\nDEF 2564\nATK 123\nDEF 1810\nATK 124\nATK 120\nDEF 2598\nATK 119\nDEF 2103\nATK 123\nATK 118\nATK 118\nATK 123\nDEF 1988\nATK 122\nATK 120\nDEF 2494\nATK 122\nATK 124\nATK 117\nATK 121\nATK 118\nATK 117\nATK 122\nATK 119\nATK 122\nDEF 248...
code_stdio
[ { "content": "Mad scientist Mike is building a time machine in his spare time. To finish the work, he needs a resistor with a certain resistance value.\n\nHowever, all Mike has is lots of identical resistors with unit resistance R0 = 1. Elements with other resistance can be constructed from these resistors. In ...
[{"input": "999999999999999999 1000000000000000000\n", "output": "1000000000000000000\n"}, {"input": "999999999999999991 1000000000000000000\n", "output": "111111111111111120\n"}, {"input": "999999999999999993 999999999999999991\n", "output": "499999999999999998\n"}, {"input": "999999999999999999 1010000000000000000\n"...
code_stdio
[ { "content": "There is a frog staying to the left of the string $s = s_1 s_2 \\ldots s_n$ consisting of $n$ characters (to be more precise, the frog initially stays at the cell $0$). Each character of $s$ is either 'L' or 'R'. It means that if the frog is staying at the $i$-th cell and the $i$-th character is '...
[{"input": "6\nLRLRRLL\nL\nLLR\nRRRR\nLLLLLL\nR\n", "output": "3\n2\n3\n1\n7\n1\n"}, {"input": "6\nRRLRLLL\nL\nLLR\nRRRR\nLLLLLL\nR\n", "output": "4\n2\n3\n1\n7\n1\n"}, {"input": "6\nMRLRRLL\nL\nLLR\nRRRR\nLLLLLL\nR\n", "output": "3\n2\n3\n1\n7\n1\n"}, {"input": "6\nLLLRLRR\nL\nLRL\nRRRR\nLLLLLL\nR\n", "output": "4\n2\...
code_stdio
[ { "content": "Snuke is making sugar water in a beaker.\nInitially, the beaker is empty. Snuke can perform the following four types of operations any number of times. He may choose not to perform some types of operations.\n - Operation 1: Pour 100A grams of water into the beaker.\n - Operation 2: Pour 100B grams...
[{"input": "17 19 22 26 55 2802\n", "output": "2634 934\n"}, {"input": "28 29 22 26 55 4180", "output": "4180 1380\n"}, {"input": "41 29 22 26 55 4180", "output": "4180 1280\n"}, {"input": "17 19 22 26 55 3359", "output": "2944 1044\n"}, {"input": "26 19 22 26 55 2802", "output": "2802 902\n"}, {"input": "26 29 22 26 5...
code_stdio
[ { "content": "The most important part of a GSM network is so called Base Transceiver Station (BTS). These transceivers form the areas called cells (this term gave the name to the cellular phone) and every phone connects to the BTS with the strongest signal (in a little simplified view). Of course, BTSes need so...
[{"input": "6\n3\n175\n101\n1057\n17888\n11057064", "output": "0\n43\n24\n262\n4469\n2764261\n"}, {"input": "6\n3\n175\n111\n1057\n17888\n11057064", "output": "0\n43\n26\n262\n4469\n2764261\n"}, {"input": "6\n1\n60\n100\n1526\n23456\n17396335", "output": "0\n14\n24\n380\n5861\n4349078\n"}, {"input": "6\n3\n117\n111\n97...
code_stdio
[ { "content": "Как извСстно, Π² Ρ‚Π΅ΠΏΠ»ΡƒΡŽ ΠΏΠΎΠ³ΠΎΠ΄Ρƒ ΠΌΠ½ΠΎΠ³ΠΈΠ΅ ΠΆΠΈΡ‚Π΅Π»ΠΈ ΠΊΡ€ΡƒΠΏΠ½Ρ‹Ρ… Π³ΠΎΡ€ΠΎΠ΄ΠΎΠ² ΠΏΠΎΠ»ΡŒΠ·ΡƒΡŽΡ‚ΡΡ сСрвисами городского Π²Π΅Π»ΠΎΠΏΡ€ΠΎΠΊΠ°Ρ‚Π°. Π’ΠΎΡ‚ ΠΈ Аркадий сСгодня Π±ΡƒΠ΄Π΅Ρ‚ Π΄ΠΎΠ±ΠΈΡ€Π°Ρ‚ΡŒΡΡ ΠΎΡ‚ ΡˆΠΊΠΎΠ»Ρ‹ Π΄ΠΎ Π΄ΠΎΠΌΠ°, ΠΈΡΠΏΠΎΠ»ΡŒΠ·ΡƒΡ городскиС вСлосипСды.\n\nΠ¨ΠΊΠΎΠ»Π° ΠΈ Π΄ΠΎΠΌ находятся Π½Π° ΠΎΠ΄Π½ΠΎΠΉ прямой ΡƒΠ»ΠΈΡ†Π΅, ΠΊΡ€ΠΎΠΌΠ΅ Ρ‚ΠΎΠ³ΠΎ, Π½Π° Ρ‚ΠΎΠΉ ΠΆΠ΅ ΡƒΠ»ΠΈΡ†Π΅ Π΅ΡΡ‚ΡŒ n Ρ‚ΠΎΡ‡Π΅ΠΊ, Π³Π΄Π΅ ΠΌΠΎΠΆΠ½ΠΎ взят...
[{"input": "50 15001\n1269 1580 5431 5916 6642 14145 15760 19922 20589 22062 24138 33454 33505 35916 37012 42577 43140 49457 54720 55188 56205 56639 56870 57997 58379 59088 59297 61805 61861 63005 64013 68848 71182 71497 72715 73008 75616 76042 76614 80690 83089 85033 86408 92392 92763 93833 95085 95815 97152 99379\n",...
code_stdio
[ { "content": "Given are strings s and t of length N each, both consisting of lowercase English letters.\nLet us form a new string by alternating the characters of S and the characters of T, as follows: the first character of S, the first character of T, the second character of S, the second character of T, ...,...
[{"input": "100\naernvaoeiuraxmueiwovioxmuaioervuaionuxiaomuahlhakaqduwbuvpgrrgreiufwuiaubewobsjdhfbajkslfhjcaklyuwee aibfaeqpwidbcuoifnydukfbavysknxyualdyksayfkjdafqiryekucyuwepaasfdasdfiocaudmiovuandksfucnaldsfumioxa\n", "output": "aaeirbnfvaaeoqepiwuirdabxcmuuoeiifwnoyvdiuokxfmbuaaviyosekrnvxuyauiaolnduyxkisaaoymfuk...
code_stdio
[ { "content": "Read problems statements in Mandarin Chinese and Russian as well. \n\nGiven n words w[1..n], which originate from the same stem (e.g. grace, graceful, disgraceful, gracefully), we are interested in the original stem. To simplify the problem, we define the stem as the longest consecutive substring ...
[{"input": "1\n4\ngrace gracefuk disgraceful gracefully", "output": "grace\n"}, {"input": "1\n4\ngrace graceful disgraceful gracefully", "output": "grace\n"}, {"input": "1\n4\ngrace graceful disgraceful gracefully", "output": "grace"}, {"input": "1\n4\ngracd gracefuk disgraceful gracefully", "output": "grac\n"}, {"inpu...
code_stdio
[ { "content": "This is the hard version of the problem. The difference is the constraint on the sum of lengths of strings and the number of test cases. You can make hacks only if you solve all versions of this task.\n\nYou are given a string $s$, consisting of lowercase English letters. Find the longest string, ...
[{"input": "10\nu\nxqpczgnzazxyrvx\ncfjgfhxmzqmjgzzjthziuomldylspyfuxvjlgdc\nooydbldio\nyvaamavy\nrzjjebcgotjffuzr\nhtfkwvihzuwxczopzqujdnaorgxibjfcmlzntskawxhyoymwynitukttewfpajuph\nfactnjajntcaf\nywowyovhrgradhtrqkgurkjpudnrrqhmmwiaqicfxnoyejdsmmurusdzqgjjntocryhqsgr\nqq\n", "output": "u\nxqx\ncfc\nooo\nyvaaavy\nrzjj...
code_stdio
[ { "content": "For a dynamic array $A = \\\\{a_0, a_1, ...\\\\}$ of integers, perform a sequence of the following operations:\n\n* push($d$, $x$): Add element $x$ at the begining of $A$, if $d = 0$. Add element $x$ at the end of $A$, if $d = 1$.\n* randomAccess($p$): Print element $a_p$.\n* pop($d$): Delete the ...
[{"input": "11\n0 1 0\n0 0 2\n0 1 3\n1 1\n1 1\n1 0\n2 -1\n1 1\n0 1 4\n1 0\n1 0", "output": "0\n0\n2\n0\n2\n2\n"}, {"input": "11\n0 1 1\n0 0 2\n0 1 3\n1 1\n1 1\n1 0\n2 0\n1 1\n0 0 4\n1 0\n1 0", "output": "1\n1\n2\n3\n4\n4\n"}, {"input": "11\n0 0 1\n0 0 3\n0 1 3\n1 0\n1 1\n1 0\n2 0\n1 1\n0 0 4\n1 0\n1 1", "output": "3\n1...
code_stdio
[ { "content": "There is a sequence of length N: a = (a_1, a_2, ..., a_N). Here, each a_i is a non-negative integer.\n\nSnuke can repeatedly perform the following operation:\n\n* Let the XOR of all the elements in a be x. Select an integer i (1 ≀ i ≀ N) and replace a_i with x.\n\n\n\nSnuke's objective is to match...
[{"input": "4\n-1 0 3 -1\n2 -1 1 4", "output": "-1\n"}, {"input": "4\n-1 2 5 -1\n2 0 0 4", "output": "-1\n"}, {"input": "4\n-1 2 5 -1\n2 0 1 4", "output": "-1\n"}, {"input": "4\n-1 2 7 -1\n2 0 1 4", "output": "-1\n"}, {"input": "4\n-1 3 2 0\n2 -1 1 4", "output": "-1\n"}, {"input": "4\n-1 3 3 0\n2 -1 1 4", "output": "-1...
code_stdio
[ { "content": "Implement a function/class, which should return an integer if the input string is in one of the formats specified below, or `null/nil/None` otherwise.\n\nFormat:\n* Optional `-` or `+`\n* Base prefix `0b` (binary), `0x` (hexadecimal), `0o` (octal), or in case of no prefix decimal.\n* Digits depend...
[{"input": "\"0xDEADbeef\"", "output": "[3735928559]", "fn_name": "to_integer"}, {"input": "\"0B1010\"", "output": "[null]", "fn_name": "to_integer"}, {"input": "\"-0x123\"", "output": "[-291]", "fn_name": "to_integer"}, {"input": "\"-0b1010\"", "output": "[-10]", "fn_name": "to_integer"}, {"input": "\"-0o123\"", "outp...
code_functional
[ { "content": "In this kata, you'll be given an integer of range `0 <= x <= 99` and have to return that number spelt out in English. A few examples:\n\n```python\nname_that_number(4) # returns \"four\"\nname_that_number(19) # returns \"nineteen\"\nname_that_number(99) # returns \"ninety nine\"\n```\n\nWords ...
[{"input": "23", "output": "[\"twenty three\"]", "fn_name": "name_that_number"}, {"input": "99", "output": "[\"ninety nine\"]", "fn_name": "name_that_number"}, {"input": "53", "output": "[\"fifty three\"]", "fn_name": "name_that_number"}, {"input": "76", "output": "[\"seventy six\"]", "fn_name": "name_that_number"}, {"...
code_functional
[ { "content": "It's your Birthday. Your colleagues buy you a cake. The numbers of candles on the cake is provided (x). Please note this is not reality, and your age can be anywhere up to 1,000. Yes, you would look a mess.\n\nAs a surprise, your colleagues have arranged for your friend to hide inside the cake and...
[{"input": "871\n\"gnlyvknjga\"", "output": "[\"That was close!\"]", "fn_name": "cake"}, {"input": "900\n\"abcdef\"", "output": "[\"That was close!\"]", "fn_name": "cake"}, {"input": "583\n\"slhacx\"", "output": "[\"That was close!\"]", "fn_name": "cake"}, {"input": "0\n\"jpipe\"", "output": "[\"That was close!\"]", "f...
code_functional
[ { "content": "There is a matrix A of size x Γ— y filled with integers. For every $i \\in [ 1 . . x ]$, $j \\in [ 1 . . y ]$ A_{i}, j = y(i - 1) + j. Obviously, every integer from [1..xy] occurs exactly once in this matrix. \n\nYou have traversed some path in this matrix. Your path can be described as a sequence ...
[{"input": "10\n999999999 999999998 999999997 999999996 999999995 999999994 999999993 999999992 999999991 62465930\n", "output": "YES\n1000000000 937534061"}, {"input": "10\n999999999 999999998 999999997 999999996 999999995 999999994 999999993 999999992 999999991 999999990\n", "output": "YES\n1000000000 1\n"}, {"input"...
code_stdio
[ { "content": "You are given N real values A_1, A_2, \\ldots, A_N. Compute the number of pairs of indices (i, j) such that i < j and the product A_i \\cdot A_j is integer.\n\nConstraints\n\n* 2 \\leq N \\leq 200\\,000\n* 0 < A_i < 10^4\n* A_i is given with at most 9 digits after the decimal.\n\nInput\n\nInput is...
[{"input": "11\n0.9\n1\n1\n1.25\n2.7527267588296525\n5\n70\n0.000000001\n9999.999999999\n0.999999999\n1.7676771981771382", "output": "7\n"}, {"input": "11\n0.9\n1\n1\n1.25\n2.30000\n5\n70\n0.000000001\n9999.999999999\n0.999999999\n1.7676771981771382", "output": "8\n"}, {"input": "5\n14.596573229675469\n11.6891813242635...
code_stdio
[ { "content": "You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively.\nAn example of a trapezoid\nFind the area of this trapezoid.\n\n-----Constraints-----\n - 1≦a≦100\n - 1≦b≦100\n - 1≦h≦100\n - All input values are integers.\n - h is even.\n\n-----Input-...
[{"input": "3\n1\n-135", "output": "-270\n"}, {"input": "3\n2\n-135", "output": "-338\n"}, {"input": "3\n10\n-65", "output": "-423\n"}, {"input": "3\n5\n-103", "output": "-412\n"}, {"input": "3\n5\n-107", "output": "-428\n"}, {"input": "3\n5\n-168", "output": "-672\n"}, {"input": "3\n1\n-168", "output": "-336\n"}, {"in...
code_stdio
[ { "content": "Counting sort can be used for sorting elements in an array which each of the n input elements is an integer in the range 0 to k. The idea of counting sort is to determine, for each input element x, the number of elements less than x as C[x]. This information can be used to place element x directly...
[{"input": "7\n4 11 2 3 4 3 1", "output": "1 2 3 3 4 4 11\n"}, {"input": "7\n8 9 2 0 12 3 3", "output": "0 2 3 3 8 9 12\n"}, {"input": "7\n10 9 3 0 6 3 3", "output": "0 3 3 3 6 9 10\n"}, {"input": "7\n6 5 3 0 12 3 3", "output": "0 3 3 3 5 6 12\n"}, {"input": "7\n4 11 2 3 4 6 1", "output": "1 2 3 4 4 6 11\n"}, {"input":...
code_stdio
[ { "content": "You have a string S consisting of N uppercase English letters. You are allowed to perform at most one operation of following kind: Choose any position in the string, remove the character at that position and insert it back to any other place in the string.\n\nFind the lexicographically smallest ...
[{"input": "2\n4\nDCBA\n7\nXYZZYZY", "output": "ADCB\nXYYZZYZ\n"}, {"input": "2\n4\nDCBA\n7\nXZZZYZZ", "output": "ADCB\nXYZZZZZ\n"}, {"input": "2\n4\nABCD\n7\nXYZZYZY", "output": "ABCD\nXYYZZYZ\n"}, {"input": "2\n4\nCBAD\n7\nXYZZYZY", "output": "ACBD\nXYYZZYZ\n"}, {"input": "2\n4\nCBAD\n7\nYZYZZYX", "output": "ACBD\nXY...
code_stdio
[ { "content": "International Women's Day is coming soon! Polycarp is preparing for the holiday.\n\nThere are $n$ candy boxes in the shop for sale. The $i$-th box contains $d_i$ candies.\n\nPolycarp wants to prepare the maximum number of gifts for $k$ girls. Each gift will consist of exactly two boxes. The girls ...
[{"input": "8 2\n1 2 2 3 2 4 6 10\n", "output": "8\n"}, {"input": "8 2\n2 2 2 2 2 4 6 10\n", "output": "8\n"}, {"input": "8 2\n1 2 2 2 2 4 6 10\n", "output": "6\n"}, {"input": "8 2\n2 2 2 2 2 4 7 10\n", "output": "6\n"}, {"input": "8 2\n1 2 2 3 3 4 6 10\n", "output": "6\n"}, {"input": "8 2\n1 4 2 2 2 4 6 10\n", "output...
code_stdio
[ { "content": "Problem\n\nGiven the strings $ s $, $ t $.\nFirst, let the string set $ A = $ {$ s $}, $ B = \\ phi $.\nAt this time, I want to perform the following operations as much as possible.\n\noperation\n\nstep1\n\nPerform the following processing for all $ u ∊ A $.\n\n1. From all subsequences of $ u $ (n...
[{"input": "abaabbabaab`abbabbabaabbab\nab", "output": "2\n"}, {"input": "abaabbbbaab`abbabbabaabaab\nab", "output": "2\n"}, {"input": "abaabbbbaab`abbabbabaabaab\n`b", "output": "1\n"}, {"input": "abaabbbbaaa`abbabbabbabaab\n`b", "output": "1\n"}, {"input": "abaabbbaaab`abbabbabbabaab\n`b", "output": "1\n"}, {"input":...
code_stdio
[ { "content": "You've gotten an n Γ— m sheet of squared paper. Some of its squares are painted. Let's mark the set of all painted squares as A. Set A is connected. Your task is to find the minimum number of squares that we can delete from set A to make it not connected.\n\nA set of painted squares is called conne...
[{"input": "20 20\n.....######.........\n.....#....#.........\n.....#....#.........\n.....#....#.........\n.....############...\n.........##.....#...\n..........#.....#...\n..........#.....#...\n..........###...#...\n............#...#...\n............#...#...\n............#...#...\n............#...#...\n............###...
code_stdio
[ { "content": "There are $n$ persons who initially don't know each other. On each morning, two of them, who were not friends before, become friends.\n\nWe want to plan a trip for every evening of $m$ days. On each trip, you have to select a group of people that will go on the trip. For every person, one of the f...
[{"input": "16 20 2\n10 4\n5 3\n10 5\n12 7\n7 6\n9 12\n9 6\n1 10\n11 16\n11 1\n16 3\n10 2\n14 4\n15 14\n4 13\n13 15\n1 8\n7 15\n1 7\n8 15\n", "output": "0\n0\n0\n0\n0\n0\n4\n4\n4\n4\n10\n10\n10\n10\n10\n14\n14\n14\n14\n15\n"}, {"input": "16 20 2\n10 4\n5 3\n10 5\n12 7\n7 6\n9 12\n9 6\n1 10\n11 16\n11 1\n16 3\n10 3\n14 ...
code_stdio
[ { "content": "Two people are playing a game with a string $s$, consisting of lowercase latin letters. \n\nOn a player's turn, he should choose two consecutive equal letters in the string and delete them. \n\nFor example, if the string is equal to \"xaax\" than there is only one possible turn: delete \"aa\", so ...
[{"input": "pogfjssywv\n", "output": "Yes\n"}, {"input": "axxxxbbaaa\n", "output": "Yes\n"}, {"input": "axxxxbbaaa\n", "output": "Yes\n"}, {"input": "pogfjssywv\n", "output": "Yes\n"}, {"input": "aaabbxxxxa\n", "output": "Yes\n"}, {"input": "pogfjssywu\n", "output": "Yes\n"}, {"input": "axabbxaxxa\n", "output": "Yes\n"...
code_stdio
[ { "content": "When Valera has got some free time, he goes to the library to read some books. Today he's got t free minutes to read. That's why Valera took n books in the library and for each book he estimated the time he is going to need to read it. Let's number the books by integers from 1 to n. Valera needs a...
[{"input": "100 100\n75 92 18 7 81 67 7 92 100 65 57 32 50 131 85 31 80 91 84 63 39 52 92 81 1 98 24 12 84 48 17 86 51 72 48 95 81 50 12 66 19 79 49 89 34 1 193 75 20 33 96 27 42 23 133 71 93 1 85 19 66 14 13 13 20 39 36 33 42 61 56 64 23 91 37 99 40 74 13 18 98 85 74 39 62 84 46 74 50 23 38 11 83 14 9 25 66 100 25 52\...
code_stdio
[ { "content": "Om Nom is the main character of a game \"Cut the Rope\". He is a bright little monster who likes visiting friends living at the other side of the park. However the dark old parks can scare even somebody as fearless as Om Nom, so he asks you to help him. [Image] \n\nThe park consists of 2^{n} + 1 -...
[{"input": "6\n87 62 58 32 81 92 12 50 23 27 38 39 64 74 16 35 84 59 91 87 14 48 90 47 44 95 64 45 31 11 67 5 80 60 36 15 91 3 21 2 40 24 37 69 5 50 23 37 49 19 68 21 49 9 100 94 45 41 22 31 31 48 25 70 25 25 95 88 82 1 37 53 49 31 57 74 94 45 55 93 43 37 13 85 59 72 15 68 3 90 96 55 100 64 63 69 43 33 66 84 57 97 87 3...
code_stdio
[ { "content": "Vlad enjoys listening to music. He lives in Sam's Town. A few days ago he had a birthday, so his parents gave him a gift: MP3-player! Vlad was the happiest man in the world! Now he can listen his favorite songs whenever he wants!\nVlad built up his own playlist. The playlist consists of N songs, e...
[{"input": "3\n4\n-1 16 14 1\n2\n5\n1 4 0 17 8\n3\n5\n-1 1 -1 18 4 \n0", "output": "4\n1\n4\n"}, {"input": "3\n4\n0 4 5 2\n-1\n5\n1 1 5 11 4\n-1\n5\n1 2 3 9 -1 \n2", "output": "4\n5\n3\n"}, {"input": "3\n4\n1 3 11 2\n2\n5\n1 2 -1 6 4\n-1\n5\n1 2 0 9 4 \n2", "output": "3\n5\n3\n"}, {"input": "3\n4\n1 3 4 2\n-1\n5\n0 2 -...
code_stdio
[ { "content": "One day n cells of some array decided to play the following game. Initially each cell contains a number which is equal to it's ordinal number (starting from 1). Also each cell determined it's favourite number. On it's move i-th cell can exchange it's value with the value of some other j-th cell, i...
[{"input": "82\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 59 17 18 19 20 21 22 23 24 25 26 27 28 29 61 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 16 60 30 79 63 64 65 66 67 68 69 70 71 72 73 74 75 76 82 78 62 80 81 77\n8 79 66 53 45 15 70 17 53 28 30 70 14 49 51 43 45 14 27 30 37 51 2...
code_stdio
[ { "content": "You are given three sticks with positive integer lengths of a, b, and c centimeters. You can increase length of some of them by some positive integer number of centimeters (different sticks can be increased by a different length), but in total by at most l centimeters. In particular, it is allowed...
[{"input": "300000 300000 300000 300000\n", "output": "4500090000549998\n"}, {"input": "300000 300000 300000 300000\n", "output": "4500090000549998\n"}, {"input": "300000 300000 300000 300000\n", "output": "4500090000549998\n"}, {"input": "300000 300000 433625 300000\n", "output": "4400668305451891\n"}, {"input": "5355...
code_stdio
[ { "content": "You are given three words s_1, s_2 and s_3, each composed of lowercase English letters, with spaces in between.\nPrint the acronym formed from the uppercased initial letters of the words.\n\n-----Constraints-----\n - s_1, s_2 and s_3 are composed of lowercase English letters.\n - 1 ≀ |s_i| ≀ 10 (1...
[{"input": "atcoder beginner contest\n", "output": "ABC\n"}, {"input": "resident register number\n", "output": "RRN\n"}, {"input": "resident retsiger number", "output": "RRN\n"}, {"input": "atcoder beginner contdst", "output": "ABC\n"}, {"input": "resident setsiger nuebmr", "output": "RSN\n"}, {"input": "resident setsi...
code_stdio
[ { "content": "The Smart Beaver from ABBYY came up with another splendid problem for the ABBYY Cup participants! This time the Beaver invites the contest participants to check out a problem on sorting documents by their subjects. Let's describe the problem:\n\nYou've got some training set of documents. For each ...
[{"input": "24000\nN.Y. BANK DISCOUNT BORROWINGS 169 MLN DLRS\nNEW YORK, April 9 - The eight major New York City banks had\ndaily average borrowings of 169 mln dlrs from the Federal\nReserve in the week ended April 8, a Fed spokesman said.\nA Fed spokesman said that all of the borrowings were made\nyesterday by fewer t...
code_stdio
[ { "content": "How to make a cake you'll never eat.\n\nIngredients. \n\n * 2 carrots\n * 0 calories\n * 100 g chocolate spread\n * 1 pack of flour\n * 1 egg\n\n\n\nMethod. \n\n 1. Put calories into the mixing bowl.\n 2. Take carrots from refrigerator.\n 3. Chop carrots.\n 4. Take chocolate spread from r...
[{"input": "100 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1010 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000...
code_stdio
[ { "content": "Furik loves math lessons very much, so he doesn't attend them, unlike Rubik. But now Furik wants to get a good mark for math. For that Ms. Ivanova, his math teacher, gave him a new task. Furik solved the task immediately. Can you?\n\nYou are given a set of digits, your task is to find the maximum ...
[{"input": "12\n3 1 2 3 2 0 2 2 3 0 2 1\n", "output": "333222221100\n"}, {"input": "12\n3 1 2 3 2 0 2 2 2 0 2 3\n", "output": "33322222200\n"}, {"input": "12\n3 1 2 3 2 0 2 2 3 0 2 3\n", "output": "33332222100\n"}, {"input": "12\n0 1 4 4 2 1 7 7 1 2 5 1\n", "output": "77544211110\n"}, {"input": "12\n3 1 4 3 2 0 2 2 3 0...
code_stdio
[ { "content": "## Description\nYour job is to create a simple password validation function, as seen on many websites. \n\nThe rules for a valid password are as follows:\n- There needs to be at least 1 uppercase letter.\n- There needs to be at least 1 lowercase letter.\n- There needs to be at least 1 number.\n- T...
[{"input": "\"AbcdefGhijKlmnopQRsTuvwxyZ1234567890\"", "output": "[true]", "fn_name": "password"}, {"input": "\"Ab1!@#$%^&*()-_+={}[]|\\\\:;?/>.<,\"", "output": "[true]", "fn_name": "password"}, {"input": "\"!@#$%^&*()-_+={}[]|\\\\:;?/>.<,\"", "output": "[false]", "fn_name": "password"}, {"input": "\"abcd1234\"", "outp...
code_functional