messages listlengths 1 1 | ground_truth stringlengths 88 726k | dataset stringclasses 2
values |
|---|---|---|
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere are n cities in Bearland, numbered 1 through n. Cities are arranged in one long row. The distance between cities i and j is equal to |i - j|.\n\nLimak is a police officer. He lives in a city a. His job is to catch c... | [{"type": "stdin_stdout", "input": "100 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"}, {"type": "stdin_stdout", "input": "100 60\n1 1 1 1 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nWhen Masha came to math classes today, she saw two integer sequences of length $n - 1$ on the blackboard. Let's denote the elements of the first sequence as $a_i$ ($0 \\le a_i \\le 3$), and the elements of the second sequ... | [{"type": "stdin_stdout", "input": "100\n2 2 2 2 3 3 3 3 3 3 1 3 3 2 3 3 0 3 3 3 2 3 3 3 3 1 3 3 3 3 3 3 3 1 1 2 2 2 2 2 1 3 3 2 2 1 3 3 3 2 3 3 3 1 1 2 3 1 0 0 1 3 3 3 1 3 2 2 2 2 3 3 2 2 2 3 3 2 2 3 1 1 1 1 3 3 3 3 3 3 3 3 3 3 3 2 3 3 3\n0 0 0 2 2 1 0 0 0 0 0 0 2 2 2 0 0 0 3 2 2 2 2 2 1 1 1 3 3 1 0 2 1 1 0 0 2 2 2 0 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nOm 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 ... | [{"type": "stdin_stdout", "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 6... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nEverybody knows that the Berland citizens are keen on health, especially students. Berland students are so tough that all they drink is orange juice!\n\nYesterday one student, Vasya and his mates made some barbecue and th... | [{"type": "stdin_stdout", "input": "2000\naabaaabaabababbbbbbabbbbb\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "6\naaaaaaaaaaaaaaaa\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "7\nabbbaaabbbaaaab\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "9\naaaabaaaaa\n", "output": "1\n"}, {"type... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThis task will exclusively concentrate only on the arrays where all elements equal 1 and/or 2.\n\nArray a is k-period if its length is divisible by k and there is such array b of length k, that a is represented by array b... | [{"type": "stdin_stdout", "input": "100 20\n2 2 2 1 1 2 1 2 1 2 1 1 2 2 2 2 2 1 2 1 2 2 2 2 1 2 1 2 1 1 1 1 2 2 2 2 1 2 1 1 2 2 2 2 1 2 1 2 1 2 1 1 2 1 2 2 2 1 2 2 2 2 2 2 2 2 1 2 1 1 1 1 2 2 2 2 2 1 1 2 2 1 2 2 1 2 1 2 1 2 1 1 2 2 1 2 2 1 1 1\n", "output": "13\n"}, {"type": "stdin_stdout", "input": "100 25\n2 2 1 2 2 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nManao is trying to open a rather challenging lock. The lock has n buttons on it and to open it, you should press the buttons in a certain order to open the lock. When you push some button, it either stays pressed into the... | [{"type": "stdin_stdout", "input": "2000\n", "output": "1333335000\n"}, {"type": "stdin_stdout", "input": "1999\n", "output": "1331335999\n"}, {"type": "stdin_stdout", "input": "1837\n", "output": "1033182073\n"}, {"type": "stdin_stdout", "input": "1747\n", "output": "888644743\n"}, {"type": "stdin_stdout", "input": "1... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given a set of n elements indexed from 1 to n. The weight of i-th element is w_{i}. The weight of some subset of a given set is denoted as $W(S) =|S|\\cdot \\sum_{i \\in S} w_{i}$. The weight of some partition R o... | [{"type": "stdin_stdout", "input": "6 2\n2578 6301 8624 6020 8513 9486\n", "output": "4401332\n"}, {"type": "stdin_stdout", "input": "6 3\n4759 5555 7401 8003 2501 6345\n", "output": "7431260\n"}, {"type": "stdin_stdout", "input": "6 1\n3100 7048 8360 9845 7229 5331\n", "output": "245478\n"}, {"type": "stdin_stdout", "... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nLittle Elephant loves magic squares very much.\n\nA magic square is a 3 × 3 table, each cell contains some positive integer. At that the sums of integers in all rows, columns and diagonals of the table are equal. The figu... | [{"type": "stdin_stdout", "input": "0 100000 100000\n100000 0 100000\n100000 100000 0\n", "output": "100000 100000 100000\n100000 100000 100000\n100000 100000 100000\n"}, {"type": "stdin_stdout", "input": "0 98721 99776\n99575 0 99123\n98922 99977 0\n", "output": "99550 98721 99776\n99575 99349 99123\n98922 99977 99148... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nInitially Ildar has an empty array. He performs $n$ steps. On each step he takes a subset of integers already added to the array and appends the mex of this subset to the array. \n\nThe mex of an multiset of integers is t... | [{"type": "stdin_stdout", "input": "3\n0 1 1000000000\n", "output": "3"}, {"type": "stdin_stdout", "input": "2\n0 1000000000\n", "output": "2"}, {"type": "stdin_stdout", "input": "1\n1000000000\n", "output": "1"}, {"type": "stdin_stdout", "input": "5\n0 0 0 0 0\n", "output": "-1"}, {"type": "stdin_stdout", "input": "4\... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nPasha is participating in a contest on one well-known website. This time he wants to win the contest and will do anything to get to the first place!\n\nThis contest consists of n problems, and Pasha solves ith problem in ... | [{"type": "stdin_stdout", "input": "44\n750 672 846 969 981 698 380 968 813 587 156 28 446 917 849 449 173 764 226 958 335 622 236 782 416 689 113 728 452 265 585 217 707 50 520 712 946 275 423 123 175 268 583 528\n4\n869 870\n1353 1354\n1683 1685\n2532 2540\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "42\... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are a rebel leader and you are planning to start a revolution in your country. But the evil Government found out about your plans and set your punishment in the form of correctional labor.\n\nYou must paint a fence wh... | [{"type": "stdin_stdout", "input": "5\n1 1000000000 999999998\n1 1000000000 999999999\n1 1000000000 1000000000\n1000000000 1000000000 2\n1000000000 1000000000 1000000000\n", "output": "REBEL\nREBEL\nOBEY\nOBEY\nOBEY\n"}, {"type": "stdin_stdout", "input": "3\n3 7 2\n2 9 2\n999999937 999999929 2\n", "output": "REBEL\nREB... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYet another Armageddon is coming! This time the culprit is the Julya tribe calendar. \n\nThe beavers in this tribe knew math very well. Smart Beaver, an archaeologist, got a sacred plate with a magic integer on it. The tr... | [{"type": "stdin_stdout", "input": "1000000\n", "output": "128207"}, {"type": "stdin_stdout", "input": "258634\n", "output": "35024"}, {"type": "stdin_stdout", "input": "12343\n", "output": "1778"}, {"type": "stdin_stdout", "input": "11010\n", "output": "1568"}, {"type": "stdin_stdout", "input": "47320\n", "output": "6... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are going to hold a competition of one-to-one game called AtCoder Janken. (Janken is the Japanese name for Rock-paper-scissors.)N players will participate in this competition, and they are given distinct integers from... | [{"type": "stdin_stdout", "input": "146037 73018\n", "output": "146037 73018\n"}, {"type": "stdin_stdout", "input": "179651 89825\n", "output": "179651 89825\n"}, {"type": "stdin_stdout", "input": "104070 52034\n", "output": "104070 52034\n"}, {"type": "stdin_stdout", "input": "137684 68841\n", "output": "137684 68841\... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nConsider sequences \\{A_1,...,A_N\\} of length N consisting of integers between 1 and K (inclusive).\nThere are K^N such sequences. Find the sum of \\gcd(A_1, ..., A_N) over all of them.\nSince this sum can be enormous, p... | [{"type": "stdin_stdout", "input": "100000 100000\n", "output": "742202979\n"}, {"type": "stdin_stdout", "input": "99991 99989\n", "output": "215961669\n"}, {"type": "stdin_stdout", "input": "23857 50338\n", "output": "123598436\n"}, {"type": "stdin_stdout", "input": "86918 71567\n", "output": "531753154\n"}, {"type": ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nSnuke had N cards numbered 1 through N.\nEach card has an integer written on it; written on Card i is a_i.\nSnuke did the following procedure:\n - Let X and x be the maximum and minimum values written on Snuke's cards, re... | [{"type": "stdin_stdout", "input": "7961\n570641734 802212645 776309598 809873412 803841293 359931843 792939994 233099102 401692872 600486353 217303985 108107734 560874418 799955982 883190766 630019949 636623822 273032982 235540677 331099668 777155291 724397459 613181400 534080974 922902142 15555595 732730818 469781636... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere are N piles of stones. The i-th pile has A_i stones.\nAoki and Takahashi are about to use them to play the following game:\n - Starting with Aoki, the two players alternately do the following operation:\n - Operatio... | [{"type": "stdin_stdout", "input": "300\n384661649102 749740371860 182994067519 635480054507 188947792922 485525176794 78108687147 989617350189 631154348796 697481765405 265428579953 267391231487 298335916571 638840284853 801747319246 75872927591 763161973616 67416808051 855953652500 952149595553 120076702790 865269978... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nLet us denote by f(x, m) the remainder of the Euclidean division of x by m.\nLet A be the sequence that is defined by the initial value A_1=X and the recurrence relation A_{n+1} = f(A_n^2, M).\nFind \\displaystyle{\\sum_{... | [{"type": "stdin_stdout", "input": "10000000000 99201 99975\n", "output": "992010000000000\n"}, {"type": "stdin_stdout", "input": "9999999995 82382 99996\n", "output": "309280000028478\n"}, {"type": "stdin_stdout", "input": "9999999997 38566 99996\n", "output": "309280000067758\n"}, {"type": "stdin_stdout", "input": "9... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nEveryone knows that agents in Valorant decide, who will play as attackers, and who will play as defenders. To do that Raze and Breach decided to play $t$ matches of a digit game...\n\nIn each of $t$ matches of the digit g... | [{"type": "stdin_stdout", "input": "1\n33\n200000000000000000000000000000022\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "4\n1\n2\n1\n3\n4\n2068\n4\n2069\n", "output": "2\n1\n2\n2\n"}, {"type": "stdin_stdout", "input": "4\n1\n2\n1\n3\n3\n102\n4\n2069\n", "output": "2\n1\n1\n2\n"}, {"type": "stdin_stdout", "... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nOne industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the... | [{"type": "stdin_stdout", "input": "100000 100000\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "32768 65536\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "65535 65536\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "98812 100000\n", "output": "No\n"}, {"type": "stdin_stdout", "input":... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given n points on a line with their coordinates x_{i}. Find the point x so the sum of distances to the given points is minimal.\n\n\n-----Input-----\n\nThe first line contains integer n (1 ≤ n ≤ 3·10^5) — the numb... | [{"type": "stdin_stdout", "input": "100\n457 827 807 17 871 935 907 -415 536 170 551 -988 865 758 -457 -892 -875 -488 684 19 0 555 -807 -624 -239 826 318 811 20 -732 -91 460 551 -610 555 -493 -154 442 -141 946 -913 -104 704 -380 699 32 106 -455 -518 214 -464 -861 243 -798 -472 559 529 -844 -32 871 -459 236 387 626 -318... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nIvan is a student at Berland State University (BSU). There are n days in Berland week, and each of these days Ivan might have some classes at the university.\n\nThere are m working hours during each Berland day, and each ... | [{"type": "stdin_stdout", "input": "4 113 370\n01110100100010110100110000000011001111110000100111111001011001110111110111001011010110000110110010101010110001000\n01101001111110001010001100101100111100111001001001001101110101100110110110001110100010111011101011101110011110100\n0110011000100111101000001010110011110001111... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nArthur and Alexander are number busters. Today they've got a competition. \n\nArthur took a group of four integers a, b, w, x (0 ≤ b < w, 0 < x < w) and Alexander took integer с. Arthur and Alexander use distinct approach... | [{"type": "stdin_stdout", "input": "200000000 794 1000 117 2000000000\n", "output": "2038505096\n"}, {"type": "stdin_stdout", "input": "20000000 280 1000 25 2000000000\n", "output": "2030769231\n"}, {"type": "stdin_stdout", "input": "19999 346 1000 141 2000000000\n", "output": "2328265426\n"}, {"type": "stdin_stdout", ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThis problem uses a simplified network topology model, please read the problem statement carefully and use it as a formal document as you develop the solution.\n\nPolycarpus continues working as a system administrator in ... | [{"type": "stdin_stdout", "input": "10 14\n3 2\n7 2\n6 4\n8 1\n3 9\n5 6\n6 3\n4 1\n2 5\n7 10\n9 5\n7 1\n8 10\n3 4\n", "output": "unknown topology\n"}, {"type": "stdin_stdout", "input": "10 9\n10 1\n10 2\n10 3\n10 4\n10 5\n10 6\n10 7\n10 8\n10 9\n", "output": "star topology\n"}, {"type": "stdin_stdout", "input": "10 10\... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAndrew often reads articles in his favorite magazine 2Char. The main feature of these articles is that each of them uses at most two distinct letters. Andrew decided to send an article to the magazine, but as he hasn't wr... | [{"type": "stdin_stdout", "input": "31\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\n", "output": "0"}, {"type": "stdin_stdout", "input": "7\npavel\nerika\nalexxxxxxx\ngracio\nzhenya\nsudarev\nchelyaba\n", "out... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nArkady decides to observe a river for n consecutive days. The river's water level on each day is equal to some real value.\n\nArkady goes to the riverside each day and makes a mark on the side of the channel at the height... | [{"type": "stdin_stdout", "input": "100\n0 1 2 2 3 0 1 5 6 6 0 0 8 7 1 9 9 4 10 11 12 2 12 12 12 12 9 13 14 8 15 15 15 19 15 7 17 17 18 19 9 10 21 0 22 9 2 24 24 4 24 7 25 14 5 8 28 29 30 31 31 31 0 3 15 31 8 33 6 35 35 35 36 36 37 37 38 39 28 0 2 23 41 9 9 0 6 25 41 41 12 42 43 43 36 44 51 45 43 4\n", "output": "761\n... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nPolycarp is mad about coding, that is why he writes Sveta encoded messages. He calls the median letter in a word the letter which is in the middle of the word. If the word's length is even, the median letter is the left o... | [{"type": "stdin_stdout", "input": "501\noilesjbgowlnayckhpoaitijewsyhgavnthycaecwnvzpxgjqfjyxnjcjknvvsmjbjwtcoyfbegmnnheeamvtfjkigqoanhvgdfrjchdqgowrstlmrjmcsuuwvvoeucfyhnxivosrxblfoqwikfxjnnyejdiihpenfcahtjwcnzwvxxseicvdfgqhtvefswznuyohmmljlnxubhevywpmnitnkhecsgccpstxkmdzabsnwxkokdfsogzbpnfvgudvqlstxojzfzugxbfrozveai... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nCalculate the value of the sum: n mod 1 + n mod 2 + n mod 3 + ... + n mod m. As the result can be very large, you should print the value modulo 10^9 + 7 (the remainder when divided by 10^9 + 7).\n\nThe modulo operator a m... | [{"type": "stdin_stdout", "input": "10000000000000 10000000000000\n", "output": "869957328\n"}, {"type": "stdin_stdout", "input": "7244641009859 6300054748096\n", "output": "955368330\n"}, {"type": "stdin_stdout", "input": "3483524125987 5259923264237\n", "output": "953462184\n"}, {"type": "stdin_stdout", "input": "972... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAfter returned from forest, Alyona started reading a book. She noticed strings s and t, lengths of which are n and m respectively. As usual, reading bored Alyona and she decided to pay her attention to strings s and t, wh... | [{"type": "stdin_stdout", "input": "120 362 6\ncaaccbbbabbbcbaacbaccacaaccacaaababccaccaabaccacccbbaaaaababbccbbacccaacabacbaaacabbacbabcccbccbcbbcaabaaabaabcccaabacbb\nabcbbaaccbbcabbcbbcacbabaacbaaacabcbabcabbabccbcaaacaccaaabbcbaacccccbcabacaacabbbcabaabcbbccabacbaaaacbbbbbccabccccbababcbacbbbcbbaabcaabcacbaaaaaccba... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nMemory is performing a walk on the two-dimensional plane, starting at the origin. He is given a string s with his directions for motion: An 'L' indicates he should move one unit left. An 'R' indicates he should move one ... | [{"type": "stdin_stdout", "input": "RDDLLDLUUUDDRDRURLUUURLLDDLRLUURRLLRRLDRLLUDRLRULLDLRRLRLRLRUDUUDLULURLLDUURULURLLRRRURRRDRUUDLDRLRDRLRRDDLDLDLLUDRUDRLLLLDRDUULRUURRDLULLULDUDULRURRDDDLLUDRLUDDLDDDRRDDDULLLLDLDRLRRLRRDDRLULURRUDRDUUUULDURUDRDLDDUDUDRRURDULRRUDRLRRDLUURURDLDRLRDUDDDLDDDURURLUULRDUUULRURUDUDRRUDULLLU... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nOmkar is building a house. He wants to decide how to make the floor plan for the last floor.\n\nOmkar's floor starts out as $n$ rows of $m$ zeros ($1 \\le n,m \\le 100$). Every row is divided into intervals such that ever... | [{"type": "stdin_stdout", "input": "21 16\n6\n1 7\n8 8\n9 9\n10 12\n13 15\n16 16\n3\n1 1\n2 8\n9 16\n2\n1 13\n14 16\n3\n1 9\n10 13\n14 16\n3\n1 2\n3 15\n16 16\n2\n1 15\n16 16\n4\n1 6\n7 11\n12 13\n14 16\n4\n1 1\n2 10\n11 15\n16 16\n4\n1 7\n8 9\n10 13\n14 16\n3\n1 2\n3 10\n11 16\n2\n1 9\n10 16\n2\n1 2\n3 16\n3\n1 2\n3 5... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAre you going to Scarborough Fair?\n\nParsley, sage, rosemary and thyme.\n\nRemember me to one who lives there.\n\nHe once was the true love of mine.\n\nWillem is taking the girl to the highest building in island No.28, h... | [{"type": "stdin_stdout", "input": "67 39\nacbcbccccbabaabcabcaaaaaaccbcbbcbaaaacbbcccbcbabbcacccbbabbabbabaac\n4 36 a b\n25 38 a a\n3 44 b c\n35 57 b a\n4 8 a c\n20 67 c a\n30 66 b b\n27 40 a a\n2 56 a b\n10 47 c a\n22 65 c b\n29 42 a b\n1 46 c b\n57 64 b c\n20 29 b a\n14 51 c a\n12 55 b b\n20 20 a c\n2 57 c a\n22 60 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nRecently you've discovered a new shooter. They say it has realistic game mechanics.\n\nYour character has a gun with magazine size equal to $k$ and should exterminate $n$ waves of monsters. The $i$-th wave consists of $a_... | [{"type": "stdin_stdout", "input": "10 79\n2 2 70\n2 10 35\n10 10 76\n11 11 66\n12 12 75\n12 14 88\n15 16 76\n17 18 97\n19 20 105\n20 20 46\n", "output": "862\n"}, {"type": "stdin_stdout", "input": "10 85\n3 5 57\n6 8 86\n9 10 46\n11 11 19\n11 12 37\n12 12 62\n14 14 60\n15 15 78\n16 16 69\n19 20 50\n", "output": "629\n... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nIn 2013, the writers of Berland State University should prepare problems for n Olympiads. We will assume that the Olympiads are numbered with consecutive integers from 1 to n. For each Olympiad we know how many members of... | [{"type": "stdin_stdout", "input": "40\n10 23 54 73\n11 10 58 84\n11 9 65 84\n11 20 45 92\n11 11 35 96\n11 6 66 16\n11 12 1 13\n11 15 8 18\n11 18 72 86\n10 24 62 38\n10 27 79 12\n11 11 24 59\n11 14 6 99\n11 6 33 100\n11 10 37 60\n11 10 67 8\n11 6 73 25\n11 8 91 3\n10 28 45 32\n11 14 64 37\n11 21 15 79\n10 29 79 53\n11 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nVasya wrote down two strings s of length n and t of length m consisting of small English letters 'a' and 'b'. What is more, he knows that string t has a form \"abab...\", namely there are letters 'a' on odd positions and ... | [{"type": "stdin_stdout", "input": "340\nbaa?b?abab??ab??aaabaa???bbbb??abaaaba?a?b?bb?ab?bbaa??aaaa???aaa?b???ba?a??b?bb?bbbabb?bb?a?a?bbbabbba?b?ababbb?b?a??bbb??bb?ababb?abbbbba??aabbaab?aaa??a???bbaa?bb?bb?babaa?bb?a???b?abbb???bb?a?a??b?b?abbba?b??a?bab??baa?aabaabb?abbbab?aa???bbaab?bbab?ba?aab?b?baabb???aaa??bb?... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nColonel has n badges. He wants to give one badge to every of his n soldiers. Each badge has a coolness factor, which shows how much it's owner reached. Coolness factor can be increased by one for the cost of one coin. \n\... | [{"type": "stdin_stdout", "input": "50\n50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50\n", "output": "1225"}, {"type": "stdin_stdout", "input": "50\n49 37 30 2 18 48 14 48 50 27 1 43 46 5 21 28 44 2 24 17 41 38 25 18 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nVasya wants to turn on Christmas lights consisting of m bulbs. Initially, all bulbs are turned off. There are n buttons, each of them is connected to some set of bulbs. Vasya can press any of these buttons. When the butto... | [{"type": "stdin_stdout", "input": "1 100\n100 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 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 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nWhile Vasya finished eating his piece of pizza, the lesson has already started. For being late for the lesson, the teacher suggested Vasya to solve one interesting problem. Vasya has an array a and integer x. He should fi... | [{"type": "stdin_stdout", "input": "100 2 1\n1 2 2 2 1 2 1 2 2 2 2 1 2 1 1 2 1 2 2 1 1 2 1 1 2 2 1 1 2 1 2 2 2 2 2 1 1 1 2 1 2 1 2 1 2 1 2 2 1 2 2 2 1 1 1 2 2 1 1 2 2 1 1 1 1 1 1 2 2 1 1 2 2 1 2 2 1 2 1 2 2 1 2 1 1 1 2 2 1 1 2 1 2 2 1 1 2 2 2 1\n", "output": "5200\n"}, {"type": "stdin_stdout", "input": "5 1000000000 1\... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nCaptain Marmot wants to prepare a huge and important battle against his enemy, Captain Snake. For this battle he has n regiments, each consisting of 4 moles.\n\nInitially, each mole i (1 ≤ i ≤ 4n) is placed at some positi... | [{"type": "stdin_stdout", "input": "3\n-2248 6528 -2144 6181\n-2245 6663 -2100 7054\n-4378 7068 -4061 7516\n-4274 6026 -3918 5721\n4942 -6793 5014 -6807\n3463 -5170 3112 -5181\n2870 -6992 3038 -6567\n5688 -4318 5358 -4744\n5249 7233 5016 6863\n4312 7385 4162 7383\n5965 9138 5607 8728\n4053 8349 4124 8389\n", "output": ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAn atom of element X can exist in n distinct states with energies E_1 < E_2 < ... < E_{n}. Arkady wants to build a laser on this element, using a three-level scheme. Here is a simplified description of the scheme. \n\nThr... | [{"type": "stdin_stdout", "input": "50 64\n257 258 350 375 1014 1017 1051 1097 1169 1177 1223 1836 1942 1983 2111 2131 2341 2418 2593 2902 2948 3157 3243 3523 3566 4079 4499 4754 5060 5624 6279 6976 7011 7071 7278 7366 7408 7466 7526 7837 7934 8532 8577 8680 9221 9271 9327 9411 9590 9794\n", "output": "0.91891891891891... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nRamesses came to university to algorithms practice, and his professor, who is a fairly known programmer, gave him the following task.\n\nYou are given two matrices $A$ and $B$ of size $n \\times m$, each of which consists... | [{"type": "stdin_stdout", "input": "10 10\n1 1 1 0 1 1 0 0 0 1\n1 1 1 1 0 0 0 0 0 1\n0 1 0 0 0 0 0 0 1 0\n0 0 0 0 0 1 0 0 0 0\n0 1 1 1 0 1 1 1 0 0\n0 0 0 1 1 1 0 1 0 0\n0 0 0 0 1 1 0 0 1 1\n0 0 0 1 1 0 1 1 1 1\n1 1 0 1 1 0 1 1 0 0\n1 0 0 0 0 0 0 0 1 0\n0 1 0 1 0 1 1 1 0 0\n0 1 1 0 0 0 0 0 0 1\n0 1 0 0 0 1 0 0 0 0\n0 1 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nHacker Zhorik wants to decipher two secret messages he intercepted yesterday. Yeah message is a sequence of encrypted blocks, each of them consists of several bytes of information.\n\nZhorik knows that each of the message... | [{"type": "stdin_stdout", "input": "50 50\n5733 740 547 3647 5382 5109 6842 7102 5879 1502 3574 1628 7905 4357 8569 9564 8268 3542 2487 8532 425 7713 2585 925 6458 2697 2844 69 324 9030 495 4428 6724 3524 3304 4874 1303 2098 1136 1048 2464 7316 274 9586 534 2450 2368 8060 7795 70692\n1918 4122 6806 4914 6517 6278 9842 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nVanya smashes potato in a vertical food processor. At each moment of time the height of the potato in the processor doesn't exceed h and the processor smashes k centimeters of potato each second. If there are less than k ... | [{"type": "stdin_stdout", "input": "25 1000000000 1\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 100... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nWe often go to supermarkets to buy some fruits or vegetables, and on the tag there prints the price for a kilo. But in some supermarkets, when asked how much the items are, the clerk will say that $a$ yuan for $b$ kilos (... | [{"type": "stdin_stdout", "input": "50 37\n78 49\n96 4\n86 62\n28 4\n19 2\n79 43\n79 92\n95 35\n33 60\n54 84\n90 25\n2 25\n53 21\n86 52\n72 25\n6 78\n41 46\n3 68\n42 89\n33 35\n57 43\n99 45\n1 82\n38 62\n11 50\n55 84\n1 97\n12 67\n51 96\n51 7\n1 100\n79 61\n66 54\n97 93\n52 75\n80 54\n98 73\n29 28\n73 96\n24 73\n3 25\n... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\n\"We've tried solitary confinement, waterboarding and listening to Just In Beaver, to no avail. We need something extreme.\"\n\n\"Little Alena got an array as a birthday present...\"\n\nThe array b of length n is obtained... | [{"type": "stdin_stdout", "input": "98\n-99 -98 -95 -90 97 93 96 95 98 98 -94 -92 -99 -92 -91 -87 -83 -84 -87 -88 -90 -79 -79 -82 -77 -76 92 82 91 91 90 91 -69 -72 -65 -68 -65 -58 -59 -63 -56 -57 -59 -53 -55 -45 -51 -52 73 81 75 71 77 72 67 70 60 70 61 64 -34 -41 -41 -41 -37 -39 -36 -33 -36 -36 -33 -36 54 49 53 51 50 -... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given a sequence $a_1, a_2, \\dots, a_n$ consisting of $n$ non-zero integers (i.e. $a_i \\ne 0$). \n\nYou have to calculate two following values: the number of pairs of indices $(l, r)$ $(l \\le r)$ such that $a_... | [{"type": "stdin_stdout", "input": "10\n-27433367 -21216390 1 303383863 -799030648 -1 160141051 -1 -342089574 -215298491\n", "output": "28 27\n"}, {"type": "stdin_stdout", "input": "10\n4 2 -4 3 1 2 -4 3 2 3\n", "output": "28 27\n"}, {"type": "stdin_stdout", "input": "2\n1000000000 -1000000000\n", "output": "2 1\n"}, {... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThe king's birthday dinner was attended by $k$ guests. The dinner was quite a success: every person has eaten several dishes (though the number of dishes was the same for every person) and every dish was served alongside ... | [{"type": "stdin_stdout", "input": "100 100\n97 64 64 35 35 97 39 83 26 97 92 97 83 11 83 97 97 64 23 97 97 11 26 11 11 39 64 11 23 39 64 26 26 97 39 39 39 64 83 26 83 97 64 11 64 64 64 83 64 92 64 26 83 26 27 64 11 83 92 92 23 11 11 97 92 64 97 64 97 83 64 27 83 23 11 26 11 92 83 64 83 11 11 11 97 83 97 26 26 97 23 23... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nEvery person likes prime numbers. Alice is a person, thus she also shares the love for them. Bob wanted to give her an affectionate gift but couldn't think of anything inventive. Hence, he will be giving her a graph. How ... | [{"type": "stdin_stdout", "input": "25\n", "output": "29\n1 25\n1 2\n2 3\n3 4\n4 5\n5 6\n6 7\n7 8\n8 9\n9 10\n10 11\n11 12\n12 13\n13 14\n14 15\n15 16\n16 17\n17 18\n18 19\n19 20\n20 21\n21 22\n22 23\n23 24\n24 25\n1 13\n2 14\n3 15\n4 16\n"}, {"type": "stdin_stdout", "input": "24\n", "output": "29\n1 24\n1 2\n2 3\n3 4\... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given string s consists of opening and closing brackets of four kinds <>, {}, [], (). There are two types of brackets: opening and closing. You can replace any bracket by another of the same type. For example, you... | [{"type": "stdin_stdout", "input": "<(([)]<[}>{)>][[(<()({{{>>((]<}<{{<>}><<[)}[[)([[)[)}<]<{(<>){([)><{[([[][({])})<][(}]}>>[){)[({>){(}[}})>}>]>)]}))})>}]\n", "output": "45\n"}, {"type": "stdin_stdout", "input": "(<[([(<({>(}{]>[(})])}])()<<}{]{[>]>(>>[(>>}[){(}<[{(()]{{<(<{][[{<><{<{)<>>]}}}{)(}{})}[<))>>}((({>){({}... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nHasan loves playing games and has recently discovered a game called TopScore. In this soccer-like game there are $p$ players doing penalty shoot-outs. Winner is the one who scores the most. In case of ties, one of the top... | [{"type": "stdin_stdout", "input": "93 2364 1182\n", "output": "952630216\n"}, {"type": "stdin_stdout", "input": "83 2813 123\n", "output": "758958584\n"}, {"type": "stdin_stdout", "input": "100 5000 30\n", "output": "860412292\n"}, {"type": "stdin_stdout", "input": "45 2315 860\n", "output": "256332294\n"}, {"type": "... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nVasily exited from a store and now he wants to recheck the total price of all purchases in his bill. The bill is a string in which the names of the purchases and their prices are printed in a row without any spaces. Check... | [{"type": "stdin_stdout", "input": "amhppqxei543.370.32o544.196nocwgxticn776.562nm212.195dcftrrg635.773n646.814.94vrfmjjsgoi405.114k821.983.12rb749.955.62jifmdlgs615.101hg42.083.41gdqififg908.729qrrgopyn684.451avcjul727.150s864.068bcd196.732.37jd349.984.25ghn379.763.11dw881.650.19eysthrm790.534.68gilg546.048qs648.876pd... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given array a with n integers and m queries. The i-th query is given with three integers l_{i}, r_{i}, x_{i}.\n\nFor the i-th query find any position p_{i} (l_{i} ≤ p_{i} ≤ r_{i}) so that a_{p}_{i} ≠ x_{i}.\n\n\n-... | [{"type": "stdin_stdout", "input": "10 10\n318890 307761 832732 700511 820583 522866 130891 914566 128429 739710\n4 9 178864\n6 9 741003\n4 9 172997\n4 6 314469\n1 4 694802\n8 8 401658\n7 10 376243\n7 8 508771\n3 5 30038\n2 10 591490\n", "output": "9\n9\n9\n6\n4\n8\n10\n8\n5\n10\n"}, {"type": "stdin_stdout", "input": "... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAfter a long day, Alice and Bob decided to play a little game. The game board consists of $n$ cells in a straight line, numbered from $1$ to $n$, where each cell contains a number $a_i$ between $1$ and $n$. Furthermore, n... | [{"type": "stdin_stdout", "input": "40\n5 40 6 27 39 37 17 34 3 30 28 13 12 8 11 10 31 4 1 16 38 22 29 35 33 23 7 9 24 14 18 26 19 21 15 36 2 20 32 25\n", "output": "ABABBBABABAAAAAABAAABBBBBBAAAABABBABABBB\n"}, {"type": "stdin_stdout", "input": "16\n14 15 3 11 5 4 7 8 1 6 10 2 12 9 13 16\n", "output": "BBBBBAAAAAAAABA... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nTomorrow is a difficult day for Polycarp: he has to attend $a$ lectures and $b$ practical classes at the university! Since Polycarp is a diligent student, he is going to attend all of them.\n\nWhile preparing for the univ... | [{"type": "stdin_stdout", "input": "8\n80 72 20 12 10\n81 72 20 12 11\n80 73 20 12 11\n81 73 20 12 12\n80 73 20 12 10\n3 99 5 1 100\n99 1 1 4 100\n53 37 13 3 17\n", "output": "4 6\n5 6\n4 7\n5 7\n-1\n1 99\n99 1\n-1\n"}, {"type": "stdin_stdout", "input": "3\n7 5 4 5 8\n7 5 4 5 2\n20 53 45 26 4\n", "output": "7 1\n-1\n1 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nDisclaimer: there are lots of untranslateable puns in the Russian version of the statement, so there is one more reason for you to learn Russian :)\n\nRick and Morty like to go to the ridge High Cry for crying loudly — th... | [{"type": "stdin_stdout", "input": "228\n1 3 1 7 1 3 1 15 1 3 1 7 1 3 1 31 1 3 1 7 1 3 1 15 1 3 1 7 1 3 1 63 1 3 1 7 1 3 1 15 1 3 1 7 1 3 1 31 1 3 1 7 1 3 1 15 1 3 1 7 1 3 1 127 1 3 1 7 1 3 1 15 1 3 1 7 1 3 1 31 1 3 1 7 1 3 1 15 1 3 1 7 1 3 1 63 1 3 1 7 1 3 1 15 1 3 1 7 1 3 1 31 1 3 1 7 1 3 1 15 1 3 1 7 1 3 1 255 1 3 1... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nVasya has got an undirected graph consisting of $n$ vertices and $m$ edges. This graph doesn't contain any self-loops or multiple edges. Self-loop is an edge connecting a vertex to itself. Multiple edges are a pair of edg... | [{"type": "stdin_stdout", "input": "100000 3950493829\n", "output": "0 11111\n"}, {"type": "stdin_stdout", "input": "18889 138011083\n", "output": "0 2274\n"}, {"type": "stdin_stdout", "input": "100000 4999950000\n", "output": "0 0\n"}, {"type": "stdin_stdout", "input": "100000 49997\n", "output": "6 99683\n"}, {"type"... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYour friend gave you a dequeue D as a birthday present.\nD is a horizontal cylinder that contains a row of N jewels.\nThe values of the jewels are V_1, V_2, ..., V_N from left to right. There may be jewels with negative v... | [{"type": "stdin_stdout", "input": "50 100\n-10000000 -10000000 -10000000 -10000000 -10000000 -10000000 -10000000 -10000000 -10000000 -10000000 -10000000 -10000000 -10000000 -10000000 -10000000 -10000000 -10000000 -10000000 -10000000 -10000000 -10000000 -10000000 -10000000 -10000000 -10000000 -10000000 -10000000 -10000... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nN players will participate in a tennis tournament. We will call them Player 1, Player 2, \\ldots, Player N.\nThe tournament is round-robin format, and there will be N(N-1)/2 matches in total.\nIs it possible to schedule t... | [{"type": "stdin_stdout", "input": "171\n158 2 11 40 53 51 26 89 135 78 167 25 123 157 100 152 72 35 39 126 124 119 68 105 162 150 84 82 59 109 28 70 34 110 85 136 57 145 134 47 99 20 83 95 154 98 73 138 48 29 120 116 66 58 96 18 102 24 153 127 125 61 32 129 16 131 50 46 10 113 91 75 13 86 65 45 146 133 122 103 128 93 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nGiven 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 seq... | [{"type": "stdin_stdout", "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 2... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nWe will create an artwork by painting black some squares in a white square grid with 10^9 rows and N columns.\n\nThe current plan is as follows: for the i-th column from the left, we will paint the H_i bottommost squares ... | [{"type": "stdin_stdout", "input": "300 150\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nIn late autumn evening n robots gathered in the cheerful company of friends. Each robot has a unique identifier — an integer from 1 to 10^9.\n\nAt some moment, robots decided to play the game \"Snowball\". Below there are... | [{"type": "stdin_stdout", "input": "4 3\n5 1000000000 999999999 12\n", "output": "1000000000\n"}, {"type": "stdin_stdout", "input": "4 5\n5 1000000000 999999999 12\n", "output": "1000000000\n"}, {"type": "stdin_stdout", "input": "4 8\n5 1000000000 999999999 12\n", "output": "1000000000\n"}, {"type": "stdin_stdout", "in... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nVasya is sitting on an extremely boring math class. To have fun, he took a piece of paper and wrote out n numbers on a single line. After that, Vasya began to write out different ways to put pluses (\"+\") in the line bet... | [{"type": "stdin_stdout", "input": "200 100\n56988719755815575893282254081467698462485803782142631369385180999746639622554559884281193367342283559238834106917388166048020056852911293394377949964185368886333934084399980368238188117302968424219707\n", "output": "295455656"}, {"type": "stdin_stdout", "input": "200 99\n999... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nRyouko 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 hea... | [{"type": "stdin_stdout", "input": "100 100\n28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nPaul is at the orchestra. The string section is arranged in an r × c rectangular grid and is filled with violinists with the exception of n violists. Paul really likes violas, so he would like to take a picture including ... | [{"type": "stdin_stdout", "input": "10 10 10 1\n8 10\n2 9\n1 10\n3 1\n8 5\n10 1\n4 10\n10 2\n5 3\n9 3\n", "output": "1787\n"}, {"type": "stdin_stdout", "input": "10 10 10 1\n1 10\n10 8\n7 4\n7 2\n1 3\n6 6\n10 1\n2 7\n9 3\n3 10\n", "output": "1991\n"}, {"type": "stdin_stdout", "input": "10 10 10 1\n8 2\n9 10\n6 8\n10 7\... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nDreamoon is a big fan of the Codeforces contests.\n\nOne day, he claimed that he will collect all the places from $1$ to $54$ after two more rated contests. It's amazing!\n\nBased on this, you come up with the following p... | [{"type": "stdin_stdout", "input": "5\n6 2\n3 1 1 5 7 10\n1 100\n100\n11 1\n1 1 1 1 1 1 1 1 1 1 1\n1 1\n1\n4 57\n80 60 40 20\n", "output": "5\n101\n2\n2\n60\n"}, {"type": "stdin_stdout", "input": "5\n1 1\n2\n2 1\n1 1\n4 1\n3 1 3 1\n1 100\n1\n1 100\n2\n", "output": "2\n2\n3\n101\n101\n"}, {"type": "stdin_stdout", "input... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nRecently, Anton has found a set. The set consists of small English letters. Anton carefully wrote out all the letters from the set in one line, separated by a comma. He also added an opening curved bracket at the beginnin... | [{"type": "stdin_stdout", "input": "{a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThe new ITone 6 has been released recently and George got really keen to buy it. Unfortunately, he didn't have enough money, so George was going to work as a programmer. Now he faced the following problem at the work.\n\n... | [{"type": "stdin_stdout", "input": "141 12 6\n66 53 86 91 12 27 5 74 79 50 33 2 100 26 2 73 16 14 50 86 75 9 66 48 19 34 25 1 22 50 63 39 38 42 98 71 76 27 80 16 74 21 36 1 32 20 65 28 68 40 41 6 0 77 65 84 0 34 60 0 42 65 2 16 25 85 35 57 74 66 26 33 39 14 0 6 2 15 87 99 47 67 75 63 72 32 93 7 5 63 35 99 89 61 18 25 7... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nGiven an integer N, find two permutations: Permutation p of numbers from 1 to N such that p_{i} ≠ i and p_{i} & i = 0 for all i = 1, 2, ..., N. Permutation q of numbers from 1 to N such that q_{i} ≠ i and q_{i} & i ≠ 0 ... | [{"type": "stdin_stdout", "input": "129\n", "output": "NO\nYES\n7 3 6 5 1 2 4 9 10 11 12 13 14 15 8 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 16 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 32 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 9... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nHeidi the Cow is aghast: cracks in the northern Wall? Zombies gathering outside, forming groups, preparing their assault? This must not happen! Quickly, she fetches her HC^2 (Handbook of Crazy Constructions) and looks for... | [{"type": "stdin_stdout", "input": "350000 140000\n", "output": "453366\n"}, {"type": "stdin_stdout", "input": "350000 160000\n", "output": "155549\n"}, {"type": "stdin_stdout", "input": "350000 180000\n", "output": "708073\n"}, {"type": "stdin_stdout", "input": "350000 200000\n", "output": "504934\n"}, {"type": "stdin... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nIn order to make the \"Sea Battle\" game more interesting, Boris decided to add a new ship type to it. The ship consists of two rectangles. The first rectangle has a width of $w_1$ and a height of $h_1$, while the second ... | [{"type": "stdin_stdout", "input": "100000000 100000000 100000000 100000000\n", "output": "600000004\n"}, {"type": "stdin_stdout", "input": "100000000 100000000 99999999 100000000\n", "output": "600000004\n"}, {"type": "stdin_stdout", "input": "98948781 84140283 95485812 84557929\n", "output": "535293990\n"}, {"type": ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nUnlike Knights of a Round Table, Knights of a Polygonal Table deprived of nobility and happy to kill each other. But each knight has some power and a knight can kill another knight if and only if his power is greater than... | [{"type": "stdin_stdout", "input": "11 10\n1 2 3 4 5 6 7 8 9 10 11\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000\n", "output": "1000000000 2000000000 3000000000 4000000000 5000000000 6000000000 7000000000 8000000000 9000000000 10000000000 11000... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given a permutation of n numbers p_1, p_2, ..., p_{n}. We perform k operations of the following type: choose uniformly at random two indices l and r (l ≤ r) and reverse the order of the elements p_{l}, p_{l} + 1, ... | [{"type": "stdin_stdout", "input": "6 1\n5 3 4 6 2 1\n", "output": "10.142857142857142\n"}, {"type": "stdin_stdout", "input": "6 1\n4 2 5 1 3 6\n", "output": "6.380952380952381\n"}, {"type": "stdin_stdout", "input": "6 2\n1 4 6 5 2 3\n", "output": "6.954648526077097\n"}, {"type": "stdin_stdout", "input": "6 1\n5 2 3 4 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThe R1 company wants to hold a web search championship. There were n computers given for the competition, each of them is connected to the Internet. The organizers believe that the data transfer speed directly affects the... | [{"type": "stdin_stdout", "input": "80 50\n15160 6853 20254 11358 19535 27691 2983 31650 9219 11833 32053 31695 21511 4320 4384 24843 1454 31543 18796 13815 1546 27926 16276 14315 12542 25370 24890 29647 3584 17867 12446 15072 19852 30207 16361 7964 5343 398 10837 31114 9252 12767 15098 22562 32637 31823 8160 12658 642... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nLet's define the sum of two permutations p and q of numbers 0, 1, ..., (n - 1) as permutation [Image], where Perm(x) is the x-th lexicographically permutation of numbers 0, 1, ..., (n - 1) (counting from zero), and Ord(p)... | [{"type": "stdin_stdout", "input": "84\n83 4 68 34 24 2 48 38 22 51 5 62 31 67 66 53 49 70 9 71 46 41 30 8 50 17 28 79 15 80 32 43 14 74 29 42 81 60 56 65 23 0 77 76 58 78 1 11 37 27 75 35 18 73 54 20 57 33 36 6 61 69 64 55 39 10 3 45 13 26 59 82 21 25 63 52 16 44 47 72 19 12 7 40\n63 41 80 52 36 45 17 69 22 66 37 21 4... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nFrom \"ftying rats\" to urban saniwation workers - can synthetic biology tronsform how we think of pigeons? \n\nThe upiquitous pigeon has long been viewed as vermin - spleading disease, scavenging through trush, and defec... | [{"type": "stdin_stdout", "input": "10\n9 16 19 23 7 14 21 15 14 6\n", "output": "23\n"}, {"type": "stdin_stdout", "input": "10\n5 20 18 1 12 17 22 20 26 4\n", "output": "21\n"}, {"type": "stdin_stdout", "input": "9\n17 16 8 13 6 29 22 27 18\n", "output": "16\n"}, {"type": "stdin_stdout", "input": "8\n22 27 29 29 27 26... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nEach employee of the \"Blake Techologies\" company uses a special messaging app \"Blake Messenger\". All the stuff likes this app and uses it constantly. However, some important futures are missing. For example, many user... | [{"type": "stdin_stdout", "input": "28 7\n1-a 1-b 1-c 1-d 1-e 1-f 1-t 1-a 1-b 1-c 1-d 1-e 1-f 1-j 1-a 1-b 1-c 1-d 1-e 1-f 1-g 1-a 1-b 1-c 1-d 1-e 1-f 2-g\n1-a 1-b 1-c 1-d 1-e 1-f 1-g\n", "output": "2"}, {"type": "stdin_stdout", "input": "15 7\n1-b 1-a 1-b 1-c 1-b 1-a 1-b 1-c 1-b 1-a 1-b 1-c 1-b 1-a 1-b\n1-b 1-a 1-b 1-c... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nGame \"Minesweeper 1D\" is played on a line of squares, the line's height is 1 square, the line's width is n squares. Some of the squares contain bombs. If a square doesn't contain a bomb, then it contains a number from 0... | [{"type": "stdin_stdout", "input": "?2*?2*??1*2**?2*1???*2???100?????*???*?*????0????2?*?*?1??1??*?01**2**1001??**??**??1*?*???00??**??*\n", "output": "147483634\n"}, {"type": "stdin_stdout", "input": "21?20*0000?2?22??0001*?1??12?20020200?**0*12?*221*0*1200*?0*11?022*110*2*2022120*2*2100*0?0*02?012?1\n", "output": "0\... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nSince you are the best Wraith King, Nizhniy Magazin «Mir» at the centre of Vinnytsia is offering you a discount.\n\nYou are given an array a of length n and an integer c. \n\nThe value of some array b of length k is the s... | [{"type": "stdin_stdout", "input": "100 20\n9149 9142 7686 5769 1871 4565 5670 8587 663 637 3421 4267 6884 8142 7634 5748 936 316 9300 771 6906 9230 8994 9690 7155 9393 6274 3183 932 7460 1611 6122 4031 6922 5466 1499 5290 4907 4673 5665 9744 1602 9891 8260 6351 4640 9930 9756 5242 3752 82 3287 824 6897 5579 9095 883 6... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nA Christmas party in city S. had n children. All children came in mittens. The mittens can be of different colors, but each child had the left and the right mitten of the same color. Let's say that the colors of the mitte... | [{"type": "stdin_stdout", "input": "100 10\n6 8 4 4 6 6 4 1 4 1 6 1 4 6 1 10 1 4 6 10 6 1 6 1 6 4 4 1 4 9 1 6 1 1 4 6 4 4 6 6 4 6 1 1 1 1 6 4 1 6 1 6 1 1 6 4 1 8 6 4 6 4 2 4 6 4 4 6 4 6 6 1 6 1 4 1 4 6 4 10 1 1 6 1 6 6 4 1 6 1 1 4 3 4 4 4 4 4 4 5\n", "output": "100\n4 6\n4 6\n4 6\n3 4\n9 4\n4 6\n6 1\n1 4\n1 4\n1 4\n4 6... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere are n points on a straight line, and the i-th point among them is located at x_{i}. All these coordinates are distinct.\n\nDetermine the number m — the smallest number of points you should add on the line to make th... | [{"type": "stdin_stdout", "input": "10\n711183437 845779129 -106125616 -481773790 66231250 -183390793 -711197523 -196001897 -440633306 -873649505\n", "output": "156311685\n"}, {"type": "stdin_stdout", "input": "7\n996073710 -246878649 34663194 35526441 634003254 -704646201 -905166147\n", "output": "15411\n"}, {"type": ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nPolycarp is in really serious trouble — his house is on fire! It's time to save the most valuable items. Polycarp estimated that it would take t_{i} seconds to save i-th item. In addition, for each item, he estimated the ... | [{"type": "stdin_stdout", "input": "50\n5 289 6\n16 126 16\n12 16 13\n12 71 8\n4 6 5\n9 57 4\n13 120 16\n3 54 17\n5 374 3\n7 345 9\n18 74 6\n10 17 6\n11 38 8\n19 40 2\n8 49 12\n20 6 1\n14 159 19\n6 90 10\n8 24 15\n12 2 18\n17 215 13\n8 91 19\n15 60 20\n14 247 14\n5 177 20\n11 90 9\n2 107 17\n11 8 10\n16 66 9\n15 2 7\n1... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nTwo semifinals have just been in the running tournament. Each semifinal had n participants. There are n participants advancing to the finals, they are chosen as follows: from each semifinal, we choose k people (0 ≤ 2k ≤ n... | [{"type": "stdin_stdout", "input": "8\n100 101\n200 201\n300 301\n310 400\n320 500\n330 600\n340 700\n350 800\n", "output": "11111000\n11110000\n"}, {"type": "stdin_stdout", "input": "4\n9900 9850\n9940 9930\n10000 10020\n10060 10110\n", "output": "1100\n1100\n"}, {"type": "stdin_stdout", "input": "4\n9840 9920\n9860 9... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nWhile sailing on a boat, Inessa noticed a beautiful water lily flower above the lake's surface. She came closer and it turned out that the lily was exactly $H$ centimeters above the water surface. Inessa grabbed the flowe... | [{"type": "stdin_stdout", "input": "1 1000000\n", "output": "499999999999.5000000000000\n"}, {"type": "stdin_stdout", "input": "65634 756534\n", "output": "4327298.8938659839332\n"}, {"type": "stdin_stdout", "input": "7882 399082\n", "output": "10099233.4940370470285\n"}, {"type": "stdin_stdout", "input": "91306 947926... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given a set of n points on the plane. A line containing the origin is called good, if projection of the given set to this line forms a symmetric multiset of points. Find the total number of good lines.\n\nMultiset... | [{"type": "stdin_stdout", "input": "50\n-38 -107\n-34 -75\n-200 -143\n-222 -139\n-34 55\n-102 -79\n48 -99\n2 -237\n-118 -167\n-56 -41\n10 17\n68 -89\n-32 41\n-100 -93\n84 -1\n86 -15\n46 -145\n-58 -117\n8 31\n-36 -61\n-12 21\n-116 79\n88 -205\n70 -103\n-78 -37\n106 -5\n-96 -201\n-60 -103\n-54 45\n-138 -177\n-178 -47\n-1... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nNowadays, most of the internet advertisements are not statically linked to a web page. Instead, what will be shown to the person opening a web page is determined within 100 milliseconds after the web page is opened. Usual... | [{"type": "stdin_stdout", "input": "5\n3778 9170\n2657 6649\n4038 9722\n3392 7255\n4890 8961\n", "output": "6938.4627241727\n"}, {"type": "stdin_stdout", "input": "5\n2194 6947\n2062 8247\n4481 8430\n3864 9409\n3784 5996\n", "output": "6373.5390940730\n"}, {"type": "stdin_stdout", "input": "5\n4787 9531\n3133 9597\n175... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nWhile Farmer John rebuilds his farm in an unfamiliar portion of Bovinia, Bessie is out trying some alternative jobs. In her new gig as a reporter, Bessie needs to know about programming competition results as quickly as p... | [{"type": "stdin_stdout", "input": "13 78\n10 2\n6 5\n5 7\n10 3\n6 13\n4 7\n4 13\n1 12\n13 2\n1 7\n10 5\n10 13\n12 2\n10 6\n5 3\n10 8\n9 11\n6 1\n4 5\n12 3\n6 7\n8 2\n1 9\n4 11\n5 8\n6 3\n9 5\n5 2\n13 11\n10 4\n12 7\n5 13\n12 8\n10 12\n6 12\n5 11\n1 8\n7 8\n12 4\n10 7\n1 5\n1 2\n10 11\n2 11\n12 13\n9 7\n8 3\n12 9\n9 2\... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nBerland National Library has recently been built in the capital of Berland. In addition, in the library you can take any of the collected works of Berland leaders, the library has a reading room.\n\nToday was the pilot la... | [{"type": "stdin_stdout", "input": "50\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n+ 100\n- 100\n... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nVus the Cossack has $n$ real numbers $a_i$. It is known that the sum of all numbers is equal to $0$. He wants to choose a sequence $b$ the size of which is $n$ such that the sum of all numbers is $0$ and each $b_i$ is eit... | [{"type": "stdin_stdout", "input": "12\n186.62750\n627.48262\n-10.75090\n-421.01607\n-276.10237\n-330.00000\n-301.09007\n571.50722\n976.10893\n-335.61496\n-535.76625\n-151.38565\n", "output": "187\n628\n-10\n-421\n-276\n-330\n-301\n571\n976\n-336\n-536\n-152\n"}, {"type": "stdin_stdout", "input": "14\n-2.79549\n1.19725... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere are n sharks who grow flowers for Wet Shark. They are all sitting around the table, such that sharks i and i + 1 are neighbours for all i from 1 to n - 1. Sharks n and 1 are neighbours too.\n\nEach shark will grow s... | [{"type": "stdin_stdout", "input": "20 999999937\n999999936 999999937\n999999937 999999938\n999999936 999999937\n999999937 999999938\n999999936 999999937\n999999937 999999938\n999999936 999999937\n999999937 999999938\n999999936 999999937\n999999937 999999938\n999999936 999999937\n999999937 999999938\n999999936 99999993... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nDima has a hamsters farm. Soon N hamsters will grow up on it and Dima will sell them in a city nearby.\n\nHamsters should be transported in boxes. If some box is not completely full, the hamsters in it are bored, that's w... | [{"type": "stdin_stdout", "input": "947264836 50\n977141206 956777871 186433588 538218068 759102378 327484438 88827268 266300062 670616672 756092978 414181331 913675814 898008516 343057716 99416265 236586817 52751842 550467703 684435578 844649988 917709231 550467703 493542638 707106470 414181331 198095018 913675814 994... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThe R1 company has recently bought a high rise building in the centre of Moscow for its main office. It's time to decorate the new office, and the first thing to do is to write the company's slogan above the main entrance... | [{"type": "stdin_stdout", "input": "15 3\n!..!?!,!,..,?!.\n", "output": "LEFT\nLEFT\nPRINT !\nRIGHT\nPRINT .\nRIGHT\nPRINT .\nRIGHT\nPRINT !\nRIGHT\nPRINT ?\nRIGHT\nPRINT !\nRIGHT\nPRINT ,\nRIGHT\nPRINT !\nRIGHT\nPRINT ,\nRIGHT\nPRINT .\nRIGHT\nPRINT .\nRIGHT\nPRINT ,\nRIGHT\nPRINT ?\nRIGHT\nPRINT !\nRIGHT\nPRINT .\n"}... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nChouti is working on a strange math problem.\n\nThere was a sequence of $n$ positive integers $x_1, x_2, \\ldots, x_n$, where $n$ is even. The sequence was very special, namely for every integer $t$ from $1$ to $n$, $x_1+... | [{"type": "stdin_stdout", "input": "82\n24 192 896 1568 2907 4840 7475 9775 11109 29939 22475 45951 46552 36859 66787 106329 85211 94423 65627 147436 143259 128699 139277 167743 178063 192167 150133 162719 177103 160732 139859 157301 176681 199291 152867 182611 199632 199535 199905 199959 23333\n", "output": "No\n"}, {... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou have a given integer $n$. Find the number of ways to fill all $3 \\times n$ tiles with the shape described in the picture below. Upon filling, no empty spaces are allowed. Shapes cannot overlap. $\\square$ This pictur... | [{"type": "stdin_stdout", "input": "60\n", "output": "1073741824"}, {"type": "stdin_stdout", "input": "56\n", "output": "268435456"}, {"type": "stdin_stdout", "input": "44\n", "output": "4194304"}, {"type": "stdin_stdout", "input": "36\n", "output": "262144"}, {"type": "stdin_stdout", "input": "18\n", "output": "512"},... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nStepan likes to repeat vowel letters when he writes words. For example, instead of the word \"pobeda\" he can write \"pobeeeedaaaaa\".\n\nSergey does not like such behavior, so he wants to write a program to format the wo... | [{"type": "stdin_stdout", "input": "200\nmmffggzvuuzzlkafduueqocuybiiaaeeoiioouaaurccuqoouuooooooyjjtyyxxiipneeueyuuoyxxhhkaaooooyaaauuoppzabuuoiiuuggcciissuugejjiirruummsiifaauyypauwoofiemzaeeeeeeiioozzttyyidaaaiggizzerkooooeeepueeauuppthhb\n", "output": "mmffggzvuzzlkafdueqocuybiaeeoioouaurccuqoouoyjjtyxxipneeueyuoyx... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given two arrays of integers a and b. For each element of the second array b_{j} you should find the number of elements in array a that are less than or equal to the value b_{j}.\n\n\n-----Input-----\n\nThe first ... | [{"type": "stdin_stdout", "input": "20 22\n858276994 -568758442 -918490847 -983345984 -172435358 389604931 200224783 486556113 413281867 -258259500 -627945379 -584563643 444685477 -602481243 -370745158 965672503 630955806 -626138773 -997221880 633102929\n-61330638 -977252080 -212144219 385501731 669589742 954357160 563... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nVova, the Ultimate Thule new shaman, wants to build a pipeline. As there are exactly n houses in Ultimate Thule, Vova wants the city to have exactly n pipes, each such pipe should be connected to the water supply. A pipe ... | [{"type": "stdin_stdout", "input": "499999998500000001 1000000000\n", "output": "999955279\n"}, {"type": "stdin_stdout", "input": "499999998500000000 1000000000\n", "output": "999955279\n"}, {"type": "stdin_stdout", "input": "499999999500000000 1000000000\n", "output": "999999998\n"}, {"type": "stdin_stdout", "input": ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nWhile playing yet another strategy game, Mans has recruited $n$ Swedish heroes, whose powers which can be represented as an array $a$.\n\nUnfortunately, not all of those mighty heroes were created as capable as he wanted,... | [{"type": "stdin_stdout", "input": "11\n559227829 -118401759 491756598 -50857099 491152214 -500410377 141179566 -414122877 144131087 -460846619 791017750\n", "output": "3779030445\n"}, {"type": "stdin_stdout", "input": "9\n286474128 -767346318 14465977 -736068092 594841463 -281215614 214724210 -313802706 43797330\n", "... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given an undirected graph consisting of n vertices and $\\frac{n(n - 1)}{2} - m$ edges. Instead of giving you the edges that exist in the graph, we give you m unordered pairs (x, y) such that there is no edge betw... | [{"type": "stdin_stdout", "input": "12 58\n1 2\n1 3\n1 4\n1 5\n1 6\n1 7\n1 8\n1 10\n1 11\n1 12\n2 3\n2 4\n2 5\n2 6\n2 7\n2 8\n2 9\n2 10\n2 11\n2 12\n3 4\n3 5\n3 6\n3 7\n3 8\n3 9\n3 10\n3 11\n3 12\n4 5\n4 6\n4 8\n4 11\n4 12\n5 6\n5 7\n5 8\n5 9\n5 10\n5 11\n6 7\n6 8\n6 9\n6 10\n6 11\n6 12\n7 8\n7 9\n7 10\n7 11\n7 12\n8 9... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nNian is a monster which lives deep in the oceans. Once a year, it shows up on the land, devouring livestock and even people. In order to keep the monster away, people fill their villages with red colour, light, and cracki... | [{"type": "stdin_stdout", "input": "24 24\n299931317 581208095 975349898 832722683 817690798 482251493 336949323 145902930 573001018 802990442 898055771 253410043 150981561 225791789 53290960 405421751 723296526 565432511 256399554 374970926 22699716 104391316 121063780 149329252\n-295118728 -830122321 -294539299 -9059... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nA positive integer X is said to be a lunlun number if and only if the following condition is satisfied:\n - In the base ten representation of X (without leading zeros), for every pair of two adjacent digits, the absolute ... | [{"type": "stdin_stdout", "input": "100000\n", "output": "3234566667\n"}, {"type": "stdin_stdout", "input": "94598\n", "output": "2345654334\n"}, {"type": "stdin_stdout", "input": "91278\n", "output": "2332345676\n"}, {"type": "stdin_stdout", "input": "97979\n", "output": "3223456555\n"}, {"type": "stdin_stdout", "inpu... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nGiven is a permutation P of \\{1, 2, \\ldots, N\\}.\nFor a pair (L, R) (1 \\le L \\lt R \\le N), let X_{L, R} be the second largest value among P_L, P_{L+1}, \\ldots, P_R.\nFind \\displaystyle \\sum_{L=1}^{N-1} \\sum_{R=L... | [{"type": "stdin_stdout", "input": "95\n41 7 46 26 89 2 78 92 8 16 45 57 17 6 35 62 91 95 63 48 19 79 74 52 1 77 28 93 56 31 25 54 40 64 9 34 53 11 10 55 94 24 67 58 27 60 90 87 18 73 50 80 20 21 61 42 88 14 44 76 39 70 51 66 83 32 30 81 23 82 72 65 15 68 75 71 69 13 4 3 85 84 49 59 22 33 5 47 12 37 29 36 38 86 43\n", ... | code_stdio |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.