messages
listlengths
1
1
ground_truth
stringlengths
88
726k
dataset
stringclasses
1 value
[ { "content": "Solve the following coding problem using the programming language python:\n\nA: Flick input\n\nA college student who loves 2D, commonly known as 2D, replaced his long-used Galapagos mobile phone with a smartphone. 2D, who operated the smartphone for the first time, noticed that the character input...
[{"type": "stdin_stdout", "input": "5R3D", "output": "neso\n"}, {"type": "stdin_stdout", "input": "5D2R", "output": "noke\n"}, {"type": "stdin_stdout", "input": "5T2D", "output": "nako\n"}, {"type": "stdin_stdout", "input": "5D3R", "output": "nose\n"}, {"type": "stdin_stdout", "input": "5U2D", "output": "nuko\n"}, {"ty...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nExample\n\nInput\n\n7\n>>\n\n\nOutput\n\n7\n\nThe input will be given via stdin and the output should be printed to stdout by your code.\n\nNow solve the problem by providing the code.\n\nWrite Python code to solve this p...
[{"type": "stdin_stdout", "input": "7\n>=", "output": "7\n"}, {"type": "stdin_stdout", "input": "7\n=>", "output": "7\n"}, {"type": "stdin_stdout", "input": "7\n?=", "output": "7\n"}, {"type": "stdin_stdout", "input": "7\n=?", "output": "7\n"}, {"type": "stdin_stdout", "input": "7\n<?", "output": "7\n"}, {"type": "stdi...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nProblem\n\nTaro has N character strings, each of which is L in length. Taro loves palindromes, so I want to make palindromes as long as possible by selecting some of the N character strings and arranging them in any order...
[{"type": "stdin_stdout", "input": "4 2\npi\nip\nrr\nrr", "output": "iprrrrpi\n"}, {"type": "stdin_stdout", "input": "4 3\noi\nio\nsr\nrs", "output": "iorssroi\n"}, {"type": "stdin_stdout", "input": "4 2\noi\nio\nrr\nrr", "output": "iorrrroi"}, {"type": "stdin_stdout", "input": "4 2\noi\nio\nrr\nsr", "output": "iorroi\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are $ n $ acitivities with start times $ \\\\ {s_i \\\\} $ and finish times $ \\\\ {t_i \\\\} $. Assuming that a person can only work on a single activity at a time, find the maximum number of activities that can be...
[{"type": "stdin_stdout", "input": "5\n1 2\n10 2\n-1 4\n1 2\n3 12", "output": "3\n"}, {"type": "stdin_stdout", "input": "5\n1 2\n10 2\n-2 4\n1 2\n3 12", "output": "3\n"}, {"type": "stdin_stdout", "input": "5\n1 2\n12 2\n-2 4\n1 2\n3 12", "output": "3\n"}, {"type": "stdin_stdout", "input": "5\n1 2\n10 2\n0 4\n1 2\n3 12"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLittle C loves number «3» very much. He loves all things about it.\n\nNow he has a positive integer n. He wants to split n into 3 positive integers a,b,c, such that a+b+c=n and none of the 3 integers is a multiple of 3. H...
[{"type": "stdin_stdout", "input": "1582786060\n", "output": "1 1 1582786058\n"}, {"type": "stdin_stdout", "input": "1000100000\n", "output": "1 2 1000099997\n"}, {"type": "stdin_stdout", "input": "1000071476\n", "output": "1 2 1000071473\n"}, {"type": "stdin_stdout", "input": "1042579470\n", "output": "1 1 1042579468\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere is a colony of villains with several holes aligned in a row, where each hole contains exactly one villain.\n\nEach colony arrangement can be expressed as a string of even length, where the i-th character of the stri...
[{"type": "stdin_stdout", "input": "sYDMlMKcqjyzmIKKjjcNyUgaixfaNUJYXjHXRHiRzNyHysnxTt\n68\n19 15\n46 34\n38 30\n50 39\n22 11\n4 14\n23 2\n10 47\n42 15\n9 5\n38 40\n43 16\n11 46\n29 46\n49 5\n28 1\n33 22\n48 8\n5 33\n8 34\n31 4\n49 3\n22 21\n31 22\n13 48\n17 50\n48 41\n7 9\n23 16\n18 12\n42 20\n17 43\n25 23\n34 30\n47 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nEach day in Berland consists of n hours. Polycarp likes time management. That's why he has a fixed schedule for each day — it is a sequence a_1, a_2, ..., a_n (each a_i is either 0 or 1), where a_i=0 if Polycarp works dur...
[{"type": "stdin_stdout", "input": "23\n1 1 1 1 1 0 1 1 1 0 1 0 1 0 1 0 1 0 1 1 1 1 1\n", "output": "10\n"}, {"type": "stdin_stdout", "input": "23\n1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "23\n1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 1 1\n", "output": "4\n"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA company has n employees numbered from 1 to n. Each employee either has no immediate manager or exactly one immediate manager, who is another employee with a different number. An employee A is said to be the superior of ...
[{"type": "stdin_stdout", "input": "77\n53\n-1\n48\n-1\n51\n-1\n54\n43\n70\n19\n64\n31\n45\n58\n6\n61\n41\n56\n34\n-1\n54\n-1\n66\n65\n74\n16\n38\n1\n2\n61\n-1\n34\n-1\n-1\n7\n19\n57\n13\n61\n42\n-1\n34\n65\n16\n31\n61\n6\n5\n34\n15\n-1\n13\n4\n22\n74\n7\n-1\n70\n38\n61\n45\n53\n46\n22\n-1\n65\n34\n19\n43\n48\n33\n58\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 × n tiles with the shape described in the picture below. Upon filling, no empty spaces are allowed. Shapes cannot overlap.\n\n<image> This picture describe...
[{"type": "stdin_stdout", "input": "60\n", "output": "1073741824"}, {"type": "stdin_stdout", "input": "54\n", "output": "134217728\n"}, {"type": "stdin_stdout", "input": "58\n", "output": "536870912\n"}, {"type": "stdin_stdout", "input": "56\n", "output": "268435456"}, {"type": "stdin_stdout", "input": "50\n", "output"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA sequence a0, a1, ..., at - 1 is called increasing if ai - 1 < ai for each i: 0 < i < t.\n\nYou are given a sequence b0, b1, ..., bn - 1 and a positive integer d. In each move you may choose one element of the given sequ...
[{"type": "stdin_stdout", "input": "100 3\n329 226 331 909 962 112 837 1005 194 818 506 416 125 648 367 459 400 582 989 547 329 438 234 121 272 226 821 376 834 427 718 164 834 113 654 177 737 212 169 696 744 180 89 944 233 147 667 990 809 1072 1085 1093 814 265 1067 312 833 572 303 901 1032 504 185 817 389 158 613 723 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are an environmental activist at heart but the reality is harsh and you are just a cashier in a cinema. But you can still do something!\n\nYou have n tickets to sell. The price of the i-th ticket is p_i. As a teller, ...
[{"type": "stdin_stdout", "input": "4\n1\n100\n50 2\n49 1\n100\n8\n100 200 100 200 100 200 100 100\n16 2\n15 3\n107\n3\n1000000000 1000000000 1000000000\n50 1\n50 1\n4850788900\n5\n200 100 100 100 100\n105 5\n31 1\n90\n", "output": "-1\n6\n-1\n2\n"}, {"type": "stdin_stdout", "input": "4\n1\n100\n50 2\n49 1\n100\n8\n100...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given two integers a and b. You may perform any number of operations on them (possibly zero).\n\nDuring each operation you should choose any positive integer x and set a := a - x, b := b - 2x or a := a - 2x, b := ...
[{"type": "stdin_stdout", "input": "3\n0 0\n2 1\n2 -1\n", "output": "YES\nYES\nNO\n"}, {"type": "stdin_stdout", "input": "3\n11 2\n-1 0\n1 2\n", "output": "NO\nNO\nYES\n"}, {"type": "stdin_stdout", "input": "3\n2 14\n2 1\n-1 0\n", "output": "NO\nYES\nNO\n"}, {"type": "stdin_stdout", "input": "3\n0 0\n2 1\n-1 0\n", "out...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThis is the hard version of this problem. The only difference is the constraint on k — the number of gifts in the offer. In this version: 2 ≤ k ≤ n.\n\nVasya came to the store to buy goods for his friends for the New Year...
[{"type": "stdin_stdout", "input": "8\n5 6 2\n2 4 3 5 12\n5 5 2\n2 4 3 5 10\n3 1 1\n4 2 6\n5 2 5\n10 1 3 9 2\n2 10000 2\n10000 10000\n2 9999 2\n10000 10000\n4 6 4\n3 2 2 2\n5 5 3\n1 2 2 1 2\n", "output": "3\n2\n0\n1\n2\n0\n4\n5\n"}, {"type": "stdin_stdout", "input": "8\n5 6 2\n2 4 3 5 12\n5 5 2\n2 4 1 5 10\n3 1 1\n4 2 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a permutation p_1, p_2, …, p_n of integers from 1 to n and an integer k, such that 1 ≤ k ≤ n. A permutation means that every number from 1 to n is contained in p exactly once.\n\nLet's consider all partition...
[{"type": "stdin_stdout", "input": "100 77\n59 92 18 16 45 82 63 43 50 68 19 13 53 79 48 28 94 49 25 77 54 8 61 66 40 100 99 20 35 14 52 56 22 17 57 36 23 90 4 65 84 42 30 27 3 15 87 32 93 74 46 91 41 9 34 12 11 7 10 86 78 72 81 73 51 55 58 97 39 31 5 24 29 88 95 6 44 37 60 62 83 33 47 21 2 38 26 98 71 75 96 70 76 69 6...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA card pyramid of height 1 is constructed by resting two cards against each other. For h>1, a card pyramid of height h is constructed by placing a card pyramid of height h-1 onto a base. A base consists of h pyramids of h...
[{"type": "stdin_stdout", "input": "50\n11833308\n5211498\n64660\n9077929\n2699416\n2432035\n234901\n1337830\n8457191\n10523566\n5722429\n5452712\n5511654\n8587879\n348160\n3141182\n2661936\n395300\n6950223\n2119926\n4407089\n3559060\n10228325\n5752720\n1607500\n647047\n8904557\n1954681\n698061\n9852830\n1972893\n13760...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAlice guesses the strings that Bob made for her.\n\nAt first, Bob came up with the secret string a consisting of lowercase English letters. The string a has a length of 2 or more characters. Then, from string a he builds ...
[{"type": "stdin_stdout", "input": "10\nabbaac\nac\nbccddaaf\nzzzzzzzzzz\nabbaac\nac\nbccddaaf\nzzzzzzzzzz\nbccddaaf\nzzzzzzzzzz\n", "output": "abac\nac\nbcdaf\nzzzzzz\nabac\nac\nbcdaf\nzzzzzz\nbcdaf\nzzzzzz\n"}, {"type": "stdin_stdout", "input": "11\nabbaac\nabbaac\nabbaac\nabbaac\nabbaac\nabbaac\nabbaac\nabbaac\nac\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDespite his bad reputation, Captain Flint is a friendly person (at least, friendly to animals). Now Captain Flint is searching worthy sailors to join his new crew (solely for peaceful purposes). A sailor is considered as ...
[{"type": "stdin_stdout", "input": "7\n7\n23\n31\n36\n44\n100\n258\n", "output": "NO\nNO\nYES\n6 10 14 1\nYES\n6 10 15 5\nYES\n6 10 15 13\nYES\n6 10 14 70\nYES\n6 10 14 228\n"}, {"type": "stdin_stdout", "input": "7\n7\n23\n31\n36\n44\n100\n258\n", "output": "NO\nNO\nYES\n6 10 14 1\nY...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOnce upon a time in the Kingdom of Far Far Away lived Sir Lancelot, the chief Royal General. He was very proud of his men and he liked to invite the King to come and watch drill exercises which demonstrated the fighting t...
[{"type": "stdin_stdout", "input": "1000 1000\n", "output": "500000\n"}, {"type": "stdin_stdout", "input": "997 1000\n", "output": "498500\n"}, {"type": "stdin_stdout", "input": "999 1000\n", "output": "499500\n"}, {"type": "stdin_stdout", "input": "1000 999\n", "output": "499500\n"}, {"type": "stdin_stdout", "input": ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are n + 1 cities, numbered from 0 to n. n roads connect these cities, the i-th road connects cities i - 1 and i (i ∈ [1, n]).\n\nEach road has a direction. The directions are given by a string of n characters such t...
[{"type": "stdin_stdout", "input": "2\n6\nLRRRLL\n3\nLRL\n", "output": "\n1 3 2 3 1 3 2\n1 4 1 4\n"}, {"type": "stdin_stdout", "input": "2\n6\nLLRRRL\n3\nLRL\n", "output": "1 2 3 2 3 1 3\n1 4 1 4\n"}, {"type": "stdin_stdout", "input": "2\n6\nLLRRRL\n3\nRLL\n", "output": "1 2 3 2 3 1 3\n3 1 3 2\n"}, {"type": "stdin_stdo...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOnce upon a time, Oolimry saw a suffix array. He wondered how many strings can produce this suffix array. \n\nMore formally, given a suffix array of length n and having an alphabet size k, count the number of strings that...
[{"type": "stdin_stdout", "input": "73 95\n4 53 37 9 45 54 16 34 12 10 13 24 2 36 33 48 50 43 15 11 47 42 46 30 27 52 67 72 66 19 56 61 69 21 68 1 70 49 64 62 3 51 44 65 29 25 38 28 8 5 39 59 17 6 26 20 63 7 41 23 22 32 40 14 57 60 55 31 35 58 18 0 71\n", "output": "423380456"}, {"type": "stdin_stdout", "input": "7 129...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasya is writing an operating system shell, and it should have commands for working with directories. To begin with, he decided to go with just two commands: cd (change the current directory) and pwd (display the current ...
[{"type": "stdin_stdout", "input": "11\npwd\ncd /home/vasya\npwd\ncd ..\npwd\ncd vasya/../../petya\npwd\ncd /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/a/a/a/a\npwd\ncd ..\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMad scientist Mike has just finished constructing a new device to search for extraterrestrial intelligence! He was in such a hurry to launch it for the first time that he plugged in the power wires without giving it a pro...
[{"type": "stdin_stdout", "input": "+--+--+------+++++++-+-+++--++---+--+-+---+--+++-+++-------+++++-+-++++--+-+-+++++++----+----+++----+-+++-+++-----+++-+-++-+-+++++-+--++----+--+-++-----+-+-++++---+++---+-+-+-++++--+--+++---+++++-+---+-----+++-++--+++---++-++-+-+++-+-+-+---+++--+--++++-+-+--++-------+--+---++-----+++...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nInna is a great piano player and Dima is a modest guitar player. Dima has recently written a song and they want to play it together. Of course, Sereja wants to listen to the song very much. \n\nA song is a sequence of not...
[{"type": "stdin_stdout", "input": "10\n2 2 2 4 10 6 7 16 9 17\n1 2 3 5 5 6 7 8 18 10\n", "output": "157\n"}, {"type": "stdin_stdout", "input": "10\n1 2 0 4 10 4 7 16 9 17\n1 2 3 5 5 6 7 8 18 10\n", "output": "154\n"}, {"type": "stdin_stdout", "input": "10\n1 2 2 4 10 6 7 16 9 17\n1 2 3 5 5 6 7 8 18 10\n", "output": "1...
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": "100 50\n5B2N,CXCWOIWH71XV!HCFEUCN3U88JDRIFRO2VHY?!N.RGH.?W14X5S.Y00RIY6YA19BPD0T,WECXYI,O2RF1U4NX9,F5AVLPOYK\n", "output": "LEFT\nLEFT\nLEFT\nLEFT\nLEFT\nLEFT\nLEFT\nLEFT\nLEFT\nLEFT\nLEFT\nLEFT\nLEFT\nLEFT\nLEFT\nLEFT\nLEFT\nLEFT\nLEFT\nLEFT\nLEFT\nLEFT\nLEFT\nLEFT\nLEFT\nLEFT\nLEFT...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWhile dad was at work, a little girl Tanya decided to play with dad's password to his secret database. Dad's password is a string consisting of n + 2 characters. She has written all the possible n three-letter continuous ...
[{"type": "stdin_stdout", "input": "100\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\naaa\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe GCD table G of size n × n for an array of positive integers a of length n is defined by formula \n\n<image>\n\nLet us remind you that the greatest common divisor (GCD) of two positive integers x and y is the greatest ...
[{"type": "stdin_stdout", "input": "5\n537163 537163 537163 537163 537163 537163 1074326 537163 537163 537163 515139317 1074326 537163 537163 537163 539311652 321760637 170817834 537163 537163 537163 537163 537163 537163 392666153\n", "output": "539311652 515139317 392666153 321760637 170817834 "}, {"type": "stdin_stdo...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMikhail the Freelancer dreams of two things: to become a cool programmer and to buy a flat in Moscow. To become a cool programmer, he needs at least p experience points, and a desired flat in Moscow costs q dollars. Mikha...
[{"type": "stdin_stdout", "input": "10 468662 93838\n589910 727627\n279516 867207\n470524 533177\n467834 784167\n295605 512137\n104422 629804\n925609 728473\n922365 964620\n998983 958315\n425628 935048\n", "output": "0.4691391144794256\n"}, {"type": "stdin_stdout", "input": "10 326330 93838\n589910 727627\n279516 86720...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasya's telephone contains n photos. Photo number 1 is currently opened on the phone. It is allowed to move left and right to the adjacent photo by swiping finger over the screen. If you swipe left from the first photo, y...
[{"type": "stdin_stdout", "input": "100 20 100 15061\nwwwwhhwhhwhhwhhhhhwwwhhhwwwhwwhwhhwwhhwwwhwwhwwwhwhwhwwhhhwwwhhwhwwhhwhwhwwwhwwwwhwhwwwwhwhhhwhwhwwh\n", "output": "100\n"}, {"type": "stdin_stdout", "input": "100 20 110 15061\nwwwwhhwhhwhhwhhhhhwwwhhhwwwhwwhwhhwwhhwwwhwwhwwwhwhwhwwhhhwwwhhwhwwhhwhwhwwwhwwwwhwhwwww...
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\nPresident of Berland has a very vast office-room, where, apart from him, work his subordinates. Each subordinate, as well as President himself, has his own desk of a unique colour. Each desk is rectangular, and its sides ...
[{"type": "stdin_stdout", "input": "24 11 N\n.NNNNNNNNNN\n.NNNNNNNNNN\n........RRR\n........RRR\n........RRR\n..MMMMMMRRR\n..MMMMMMRRR\n..MMMMMMRRR\n..MMMMMM...\n....XXXXXXX\n...........\n.....CCCCCC\n.....CCCCCC\n.HHHHHHHHHH\n..VVVVV....\n..VVVVV....\n..VVVVV....\n..VVVVV.I..\n..VVVVV.I..\n..VVVVV.I..\n..VVVVV.I..\n.....
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRecently Maxim has found an array of n integers, needed by no one. He immediately come up with idea of changing it: he invented positive integer x and decided to add or subtract it from arbitrary array elements. Formally,...
[{"type": "stdin_stdout", "input": "100 5 100\n-45 -36 -55 -96 -49 8 -88 -87 -82 51 27 -33 -65 0 -1 -42 -58 -19 -11 77 -54 14 -49 -90 -35 -9 -2 -48 0 -21 44 22 37 -32 -81 64 28 85 -77 44 18 -74 -50 62 8 -74 41 -15 -91 -93 -2 57 -12 2 -2 -90 84 6 -92 -14 72 85 86 -71 -59 57 -89 -4 78 56 56 24 -15 -78 27 -30 -31 -32 -92 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nChloe, the same as Vladik, is a competitive programmer. She didn't have any problems to get to the olympiad like Vladik, but she was confused by the task proposed on the olympiad.\n\nLet's consider the following algorithm...
[{"type": "stdin_stdout", "input": "50 844424930131968\n", "output": "49\n"}, {"type": "stdin_stdout", "input": "49 351843720888320\n", "output": "47\n"}, {"type": "stdin_stdout", "input": "48 133865540681728\n", "output": "39\n"}, {"type": "stdin_stdout", "input": "50 1125899906842623\n", "output": "1\n"}, {"type": "s...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMahmoud wants to write a new dictionary that contains n words and relations between them. There are two types of relations: synonymy (i. e. the two words mean the same) and antonymy (i. e. the two words mean the opposite)...
[{"type": "stdin_stdout", "input": "8 4 12\nhello hi welcome goaway hateyou mmmm momo mana\n1 hello hi\n1 hi welcome\n2 goaway welcome\n2 hateyou hi\nhateyou goaway\nhateyou hi\nhateyou hi\nhateyou welcome\nmmmm momo\nwelcome hi\nwelcome hateyou\nhateyou goaway\nhello goaway\nhello goaway\nhello hateyou\ngoaway mmmm\n"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe flag of Berland is such rectangular field n × m that satisfies following conditions:\n\n * Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. \n * Flag consists of three equal in width and h...
[{"type": "stdin_stdout", "input": "15 28\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\nBBBBBBB...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA sum of p rubles is charged from Arkady's mobile phone account every day in the morning. Among the following m days, there are n days when Arkady will top up the account: in the day di he will deposit ti rubles on his mo...
[{"type": "stdin_stdout", "input": "10 1 10\n1 1000000000\n2 1000000000\n3 1000000000\n4 1000000000\n5 1000000000\n6 1000000000\n7 1000000000\n8 1000000000\n9 1000000000\n10 1000000000\n", "output": " 0"}, {"type": "stdin_stdout", "input": "14 4115 100\n18 7...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAlice decides to challenge Bob to a problem. She gives him a number. \n\nBob can rearrange the digits of this number by applying pair-wise swaps between any 2 digits in the number as many times as he wants. Now Alice asks...
[{"type": "stdin_stdout", "input": "10\n9699845986115288644154449969375578463311146124654217164226835725255676242441727218631546924475239861698217274382299442628518127964469554694458444938229418553749514796627711773489739492876115633143647794765425336871894747423586549472121441495652824789216899777352396915598187239911...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThis problem of Oz is very straight forward. You are given N distinct prime integers i.e p1, p2,..., pN and an interval [L,R]. Calculate number of integers in this interval that are divisible by at least one of the given ...
[{"type": "stdin_stdout", "input": "10\n1 1 1000000000000000000\n3\n1 1000010000000000000 1000000000000000000\n3\n10 1 1000100000000000000\n3 2 7 5 10 11 19 17 29 23\n5 44 18509\n178 67 13 31 83\n5 26501 45670\n69 61 11 83 53\n3 11479 40837\n83 42 3\n1 24465 975\n37\n2 23282 40109\n43 41\n3 492 3487\n47 37 7\n2 4828 20...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou will be given a set of distinct numbers. Your task is to find that even length subset which will give you a maximum value of P % (10^9 + 7). This value of P for a subset of length N is defined as below :\n\n ...
[{"type": "stdin_stdout", "input": "2\n2\n2 11\n3\n1 11 14\n\nEMPLAS", "output": "500000009\n454545459\n"}, {"type": "stdin_stdout", "input": "2\n2\n2 11\n3\n2 11 14\n\nEMPLAS", "output": "500000009\n500000009\n"}, {"type": "stdin_stdout", "input": "2\n2\n2 11\n3\n2 18 14\n\nEMPLAS", "output": "500000009\n285714289\n"}...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nCampus Ambassador has organized a Coding Contest in his college. Contest has multiple rounds, in each round a participant may gain or lose few points. At the end, there is only one participant with the maximum points. In ...
[{"type": "stdin_stdout", "input": "15\n_hjm -4\njibl -1\nzcjjw -1\nvimk^ -34\nppqkc 2\nhrdkbq -1\n`muija 2\naoinqib 4\niasanhm 0\nl_ile -1\ndasrhit 0\nqaulh 0\nicmi 10\nlvxci 2\nansinag -35", "output": "icmi\n"}, {"type": "stdin_stdout", "input": "15\n`hjm -3\nlahj 0\nvkkcz 1\nvink^ -59\npoqjc 6\nqbldrh -1\n`mtika 6\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDo you remember the game of Snakes and Ladders ? We have removed all the snakes from the board. However to compensate for the loss of trouble, we have enlarged the board from a maximum limit (Target Square) of 100 to a ma...
[{"type": "stdin_stdout", "input": "1\n11025 64\n297 345\n3266 10057\n5366 9583\n1815 5123\n1255 1449\n315 1580\n160 513\n2557 3726\n452 4632\n560 3339\n6643 9342\n2591 5273\n1473 5777\n826 10203\n1572 3833\n101 323\n2311 5011\n2124 5492\n6325 6700\n7925 9037\n5995 6129\n1157 3090\n463 3925\n2823 5693\n7447 10803\n1077...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGiven is an integer S. Find how many sequences there are whose terms are all integers greater than or equal to 3, and whose sum is equal to S. The answer can be very large, so output it modulo 10^9 + 7.\n\nConstraints\n\n...
[{"type": "stdin_stdout", "input": "1175", "output": "531468532\n"}, {"type": "stdin_stdout", "input": "1729", "output": "294867501"}, {"type": "stdin_stdout", "input": "333", "output": "223377764\n"}, {"type": "stdin_stdout", "input": "106", "output": "759001237\n"}, {"type": "stdin_stdout", "input": "192", "output": ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA bracket sequence is a string that is one of the following:\n\n1. An empty string;\n2. The concatenation of `(`, A, and `)` in this order, for some bracket sequence A ;\n3. The concatenation of A and B in this order, for...
[{"type": "stdin_stdout", "input": "4\n((()))\n((((((\n))))))\n)()()(", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "4\n)))(((\n((((((\n))))))\n)()()(", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "4\n((())(\n(()(()\n))))))\n)((()(", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "4\n())(((\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFor two sequences S and T of length N consisting of 0 and 1, let us define f(S, T) as follows:\n\n* Consider repeating the following operation on S so that S will be equal to T. f(S, T) is the minimum possible total cost ...
[{"type": "stdin_stdout", "input": "5\n52 103 72 25 79", "output": "292096\n"}, {"type": "stdin_stdout", "input": "5\n63 103 72 25 79", "output": "306176\n"}, {"type": "stdin_stdout", "input": "5\n20 67 72 25 79", "output": "227072\n"}, {"type": "stdin_stdout", "input": "5\n2 124 30 25 55", "output": "171520\n"}, {"typ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWe have two bottles for holding water.\n\nBottle 1 can hold up to A milliliters of water, and now it contains B milliliters of water.\n\nBottle 2 contains C milliliters of water.\n\nWe will transfer water from Bottle 2 to...
[{"type": "stdin_stdout", "input": "6 113 -1", "output": "106\n"}, {"type": "stdin_stdout", "input": "6 228 -1", "output": "221\n"}, {"type": "stdin_stdout", "input": "2 228 -1", "output": "225\n"}, {"type": "stdin_stdout", "input": "2 396 -1", "output": "393\n"}, {"type": "stdin_stdout", "input": "2 666 -1", "output":...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a string S of length N consisting of `A`, `C`, `G` and `T`. Answer the following Q queries:\n\n* Query i (1 \\leq i \\leq Q): You will be given integers l_i and r_i (1 \\leq l_i < r_i \\leq N). Consider the ...
[{"type": "stdin_stdout", "input": "8 3\nACACTABG\n6 3\n4 6\n2 1", "output": "-1\n0\n-1\n"}, {"type": "stdin_stdout", "input": "8 3\nACACTACG\n3 7\n4 3\n1 2", "output": "2\n-1\n1\n"}, {"type": "stdin_stdout", "input": "8 3\nACACTACG\n3 7\n8 5\n1 6", "output": "2\n-1\n2\n"}, {"type": "stdin_stdout", "input": "8 3\nACACT...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn programming, hexadecimal notation is often used.\n\nIn hexadecimal notation, besides the ten digits 0, 1, ..., 9, the six letters `A`, `B`, `C`, `D`, `E` and `F` are used to represent the values 10, 11, 12, 13, 14 and ...
[{"type": "stdin_stdout", "input": "E F", "output": "<\n"}, {"type": "stdin_stdout", "input": "A A", "output": "=\n"}, {"type": "stdin_stdout", "input": "E B", "output": ">\n"}, {"type": "stdin_stdout", "input": "D F", "output": "<\n"}, {"type": "stdin_stdout", "input": "A C", "output": "<\n"}, {"type": "stdin_stdout",...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an integer sequence of length N, a = {a_1, a_2, …, a_N}, and an integer K.\n\na has N(N+1)/2 non-empty contiguous subsequences, {a_l, a_{l+1}, …, a_r} (1 ≤ l ≤ r ≤ N). Among them, how many have an arithmetic...
[{"type": "stdin_stdout", "input": "7 26\n10\n20\n30\n43\n30\n20\n10", "output": "13\n"}, {"type": "stdin_stdout", "input": "7 26\n10\n20\n30\n40\n30\n20\n10", "output": "13"}, {"type": "stdin_stdout", "input": "1 26\n10\n20\n30\n43\n30\n20\n10", "output": "0\n"}, {"type": "stdin_stdout", "input": "1 26\n10\n20\n30\n12...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are N pinholes on the xy-plane. The i-th pinhole is located at (x_i,y_i).\n\nWe will denote the Manhattan distance between the i-th and j-th pinholes as d(i,j)(=|x_i-x_j|+|y_i-y_j|).\n\nYou have a peculiar pair of c...
[{"type": "stdin_stdout", "input": "8 1 2\n1 5\n4 3\n8 2\n5 7\n11 8\n3 3\n6 5\n4 8", "output": "8"}, {"type": "stdin_stdout", "input": "8 1 2\n1 5\n4 3\n8 2\n4 7\n8 8\n3 3\n6 6\n4 8", "output": "7"}, {"type": "stdin_stdout", "input": "8 1 2\n1 5\n4 3\n8 2\n4 7\n7 8\n3 3\n6 6\n4 8", "output": "6"}, {"type": "stdin_stdou...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSnuke got an integer sequence from his mother, as a birthday present. The sequence has N elements, and the i-th of them is i. Snuke performs the following Q operations on this sequence. The i-th operation, described by a ...
[{"type": "stdin_stdout", "input": "28 2\n7\n17\n4\n8\n10\n2\n8\n19\n33\n143", "output": "3\n3\n3\n2\n2\n2\n2\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n"}, {"type": "stdin_stdout", "input": "27 12\n16\n19\n21\n7\n10\n4\n9\n0\n22\n0", "output": "0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAn extension of a complex number is called a quaternion. It is a convenient number that can be used to control the arm of a robot because it is convenient for expressing the rotation of an object. Quaternions are $ using ...
[{"type": "stdin_stdout", "input": "2\n2 0 2 1 89 0 26 7\n13 11 25 8 -1 3 0 -2\n0", "output": "119 -12 230 103\n-30 -22 21 -109\n"}, {"type": "stdin_stdout", "input": "2\n2 0 2 5 89 0 26 4\n7 11 25 8 -1 3 0 -2\n0", "output": "106 -122 230 453\n-24 -40 21 -97\n"}, {"type": "stdin_stdout", "input": "2\n2 0 2 5 89 0 26 4\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAdvanced Creative Mobile (ACM) has decided to develop a GUI application to be installed in a new portable computer.\n\nAs shown in the figure below, the GUI has a nested structure in which it has one main panel, several p...
[{"type": "stdin_stdout", "input": "5\n<main>10,10,190,150<menu>20,20,70,140</menu><primary>80,20,180,140</primary></main>\n9 10\n0 17\n40 190\n2 3\n130 80\n0", "output": "OUT OF MAIN PANEL 1\nOUT OF MAIN PANEL 1\nOUT OF MAIN PANEL 1\nOUT OF MAIN PANEL 1\nprimary 0\n"}, {"type": "stdin_stdout", "input": "5\n<main>10,10...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA decimal representation of an integer can be transformed to another integer by rearranging the order of digits. Let us make a sequence using this fact.\n\nA non-negative integer a0 and the number of digits L are given fi...
[{"type": "stdin_stdout", "input": "2012 8\n83268 3\n1112 9\n0 1\n20 2\n0 0", "output": "13 86526432 3\n5 74943 4\n5 954197541 14\n0 0 1\n2 63 5\n"}, {"type": "stdin_stdout", "input": "245 9\n83268 23\n821 3\n0 0\n99 1\n0 -1", "output": "3 863098632 14\n12 98765433331976666543211 5\n3 495 1\n"}, {"type": "stdin_stdout"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDr. Jimbo, an applied mathematician, needs to calculate matrices all day for solving his own problems. In his laboratory, he uses an excellent application program for manipulating matrix expressions, however, he cannot us...
[{"type": "stdin_stdout", "input": "1\nA=[1 2 3;4 5 6].\n1\nA=[[1 2 3;4 5 6] [7 8;9 10] [11;12];13 14 15 16 17 18].\n3\nB=[3 -2 1;-9 8 7].\nC=([1 2 3;4 5 6]+B)(2,3).\nD=([1 0 3;4 5 6]+B)([1 2],[2 3]).\n5\nA=2*[1 2;-3 4]'.\nB=A([2 1 2],[2 1]).\nA=[1 2;3 4]*3.\nA=[2]*[1 3;2 4].\nA=[1 2;3 4]*[3].\n2\nA=[11 12 13;0 22 23;0...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe sales department of Japanese Ancient Giant Corp. is visiting a hot spring resort for their recreational trip. For deepening their friendships, they are staying in one large room of a Japanese-style hotel called a ryok...
[{"type": "stdin_stdout", "input": "4\n0 0 x\n2 0 x\n0 1 x\n2 1 x\n4\n1 0 x\n0 1 x\n3 1 x\n1 2 x\n4\n0 0 x\n2 0 y\n0 1 y\n1 2 x\n0", "output": "Yes\nYes\nYes\n"}, {"type": "stdin_stdout", "input": "4\n0 0 x\n2 0 x\n0 1 x\n2 1 x\n4\n1 0 x\n0 1 x\n3 1 x\n1 2 x\n4\n0 0 x\n2 0 y\n0 1 y\n2 2 x\n0", "output": "Yes\nYes\nYes\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWrite a program which manipulates a sequence A = {a1, a2, . . . , an} with the following operations:\n\n* add(i, x): add x to ai.\n* getSum(s, t): print the sum of as, as+1,...,at.\n\n\n\nNote that the initial values of a...
[{"type": "stdin_stdout", "input": "4 5\n0 1 1\n0 2 10\n1 2 3\n1 1 2\n1 1 3", "output": "10\n11\n11\n"}, {"type": "stdin_stdout", "input": "4 5\n1 1 1\n1 4 3\n0 3 3\n1 1 2\n1 2 3", "output": "0\n0\n0\n3\n"}, {"type": "stdin_stdout", "input": "4 5\n0 1 1\n1 2 3\n1 2 3\n1 1 2\n1 2 2", "output": "0\n0\n1\n0\n"}, {"type": ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDevu is a class teacher of a class of n students. One day, in the morning prayer of the school, all the students of his class were standing in a line. You are given information of their arrangement by a string s. The stri...
[{"type": "stdin_stdout", "input": "8\n-1\nBB\n0\nBG\n1\nGBGB\n2\nBGG\n2\nBGGB\n1\nBBBGG\n2\nBBGG\n2\nBGB", "output": "-1\n0\n0\n1\n1\n3\n1\n0\n"}, {"type": "stdin_stdout", "input": "8\n1\nBB\n0\nBG\n0\nBBGG\n1\nAGG\n0\nBGGB\n1\nBBBGG\n2\nBBGG\n2\nBGB", "output": "-1\n0\n1\n-1\n1\n3\n1\n0\n"}, {"type": "stdin_stdout", ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThis is an interactive problem.\n\nBob lives in a square grid of size n × n, with rows numbered 1 through n from top to bottom, and columns numbered 1 through n from left to right. Every cell is either allowed or blocked,...
[{"type": "stdin_stdout", "input": "10\n..........\n..........\n..........\n..........\n..........\n..........\n..........\n..........\n..........\n..........\n", "output": "? 2 1 10 10\n? 2 2 10 10\n? 2 3 10 10\n? 2 4 10 10\n? 2 5 10 10\n? 2 6 10 10\n? 2 7 10 10\n? 2 8 10 10\n? 2 9 10 10\n? 1 1 10 9\n? 1 1 9 9\n? 1 1 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe German University in Cairo (GUC) dorm houses are numbered from 1 to n. Underground water pipes connect these houses together. Each pipe has certain direction (water can flow only in this direction and not vice versa),...
[{"type": "stdin_stdout", "input": "44 42\n4 37 166\n34 25 47\n28 19 367\n20 14 811\n8 3 878\n39 1 925\n35 9 206\n32 18 841\n16 44 503\n5 20 426\n22 34 896\n44 43 471\n17 33 577\n40 22 317\n24 31 818\n37 11 292\n21 39 888\n6 8 983\n43 36 170\n11 21 662\n36 17 942\n18 7 356\n2 32 220\n12 5 774\n19 27 193\n13 40 63\n15 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nReading books is one of Sasha's passions. Once while he was reading one book, he became acquainted with an unusual character. The character told about himself like that: \"Many are my names in many countries. Mithrandir a...
[{"type": "stdin_stdout", "input": "tttdddssstttssstttdddddddddttttttdddsssdddtttsssdddsssssstttddddddtttdddssstttsssttttttdddtttsssssstttssssssssstttsssssstttssstttdddddddddsssdddssssssdddssstttsssdddssstttdddttttttdddddddddsssssstttdddtttssssssdddddddddttttttdddtttsssdddssstttsssdddssssssdddsssdddddddddtttssstttsssss...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet's analyze a program written on some strange programming language. The variables in this language have names consisting of 1 to 4 characters, and each character is a lowercase or an uppercase Latin letter, or a digit. ...
[{"type": "stdin_stdout", "input": "9\nc111=a&b\nd=b^a\ne=c111#d\nd=d\nf=f\nf=c111$d\ng=e$f\nh=e#f\nres=g^h\n", "output": "7\naaaa=a&b\naaab=b^a\naaac=aaaa#aaab\naaad=aaaa$aaab\naaae=aaac$aaad\naaaf=aaac#aaad\nres=aaae^aaaf\n"}, {"type": "stdin_stdout", "input": "9\nc=a$b\ne=c#c\nf=c$c\nh=a$b\nx=h$h\nh#h=y\nz=x^y\ng=f^...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRecently, on the course of algorithms and data structures, Valeriy learned how to use a deque. He built a deque filled with n elements. The i-th element is a_i (i = 1, 2, …, n). He gradually takes the first two leftmost e...
[{"type": "stdin_stdout", "input": "71 57\n9 26 80 2 65 60 63 1 15 109 114 1 58 27 41 97 42 9 42 56 87 22 10 28 34 90 13 70 71 56 65 21 0 78 47 96 56 77 32 83 28 16 10 41 0 18 118 12 27 112 4 67 21 41 111 20 21 52 74 10 83 74 43 123 2 15 0 63 68 7 72\n81\n47\n81\n81\n5\n9\n41\n76\n81\n92\n95\n94\n78\n93\n47\n30\n152\n3...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a sorted array a_1, a_2, ..., a_n (for each index i > 1 condition a_i ≥ a_{i-1} holds) and an integer k.\n\nYou are asked to divide this array into k non-empty consecutive subarrays. Every element in the arr...
[{"type": "stdin_stdout", "input": "7 6\n-3 0 -1 -2 -2 -4 -1\n", "output": "-2\n"}, {"type": "stdin_stdout", "input": "8 1\n1 1 2 3 5 8 13 21\n", "output": "20\n"}, {"type": "stdin_stdout", "input": "5 3\n99 101 103 105 107\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "8 2\n1 1 2 3 5 8 13 21\n", "output": "1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAll of us love treasures, right? That's why young Vasya is heading for a Treasure Island.\n\nTreasure Island may be represented as a rectangular table n × m which is surrounded by the ocean. Let us number rows of the fiel...
[{"type": "stdin_stdout", "input": "2 250\n..........................................................................................................................................................................................................................................................\n............................
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThis is the harder version of the problem. In this version, 1 ≤ n ≤ 10^6 and 0 ≤ a_i ≤ 10^6. You can hack this problem if you locked it. But you can hack the previous problem only if you locked both problems\n\nChristmas ...
[{"type": "stdin_stdout", "input": "100\n61 28 67 53 13 6 70 5 79 82 60 60 84 17 80 25 82 82 69 76 81 43 58 86 18 78 4 25 8 30 33 87 91 18 90 26 62 11 28 66 9 33 58 66 47 48 108 38 25 57 4 84 79 71 54 84 63 32 97 62 26 68 5 69 54 93 25 26 100 73 24 94 80 39 30 45 95 80 0 29 57 98 92 15 17 76 69 11 57 56 48 10 28 7 63 6...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYeah, we failed to make up a New Year legend for this problem.\n\nA permutation of length n is an array of n integers such that every integer from 1 to n appears in it exactly once. \n\nAn element y of permutation p is re...
[{"type": "stdin_stdout", "input": "5\n3 1\n15 21\n4 13\n13 2\n8 1\n", "output": "1 2 3\n1 2 3 4 5 6 7 8 9 10 15 13 14 11 12\n-1\n1 2 3 4 5 6 7 8 9 10 11 13 12\n1 2 3 4 5 6 7 8\n"}, {"type": "stdin_stdout", "input": "5\n3 2\n10 21\n4 13\n13 2\n8 1\n", "output": "1 3 2\n1 2 3 4 5 10 8 9 6 7\n-1\n1 2 3 4 5 6 7 8 9 10 11 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn this task Anna and Maria play a game with a very unpleasant rival. Anna and Maria are in the opposite squares of a chessboard (8 × 8): Anna is in the upper right corner, and Maria is in the lower left one. Apart from t...
[{"type": "stdin_stdout", "input": "S..SSS.A\nS.S.SSSS\nSSSSSSSS\n...SS...\nS.SSSSSS\nSS..SS.S\nSS..S.S.\nMSS..SSS\n", "output": "LOSE\n"}, {"type": "stdin_stdout", "input": ".SSSSSSA\n.SSSSSSS\n.SSSSSSS\n.SSSSSSS\n.SSSSSSS\n.SSSSSSS\nSSSSSSS.\nMSSSSSSS\n", "output": "LOSE\n"}, {"type": "stdin_stdout", "input": ".SSSS....
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIf the girl doesn't go to Denis, then Denis will go to the girl. Using this rule, the young man left home, bought flowers and went to Nastya. \n\nOn the way from Denis's house to the girl's house is a road of n lines. Thi...
[{"type": "stdin_stdout", "input": "30 8\n0 1 7 10 23 24 26 30\n40 13\n", "output": "30\n"}, {"type": "stdin_stdout", "input": "30 8\n0 1 7 10 23 24 26 30\n40 7\n", "output": "30\n"}, {"type": "stdin_stdout", "input": "30 8\n0 1 7 12 23 24 26 30\n40 7\n", "output": "30\n"}, {"type": "stdin_stdout", "input": "30 8\n0 2 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAshish has a tree consisting of n nodes numbered 1 to n rooted at node 1. The i-th node in the tree has a cost a_i, and binary digit b_i is written in it. He wants to have binary digit c_i written in the i-th node in the ...
[{"type": "stdin_stdout", "input": "10\n64 0 0\n10 0 0\n17 0 1\n90 1 1\n97 1 1\n19 1 0\n26 1 1\n95 1 1\n46 0 0\n86 0 0\n5 4\n7 1\n9 5\n6 8\n1 6\n7 5\n8 10\n3 7\n3 2\n", "output": "128"}, {"type": "stdin_stdout", "input": "10\n92 0 1\n19 1 0\n46 1 0\n53 1 0\n13 1 0\n63 0 1\n3 0 1\n67 1 0\n20 0 1\n82 0 1\n6 5\n9 1\n3 7\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe length of the longest common prefix of two strings s = s_1 s_2 … s_n and t = t_1 t_2 … t_m is defined as the maximum integer k (0 ≤ k ≤ min(n,m)) such that s_1 s_2 … s_k equals t_1 t_2 … t_k.\n\nKoa the Koala initiall...
[{"type": "stdin_stdout", "input": "1\n100\n47 48 49 47 48 49 47 48 48 49 47 48 91 47 47 49 49 49 49 47 49 47 47 47 49 47 48 49 48 47 49 49 47 47 49 48 47 48 49 47 49 47 49 47 49 47 47 47 92 49 48 49 48 48 47 48 47 47 49 48 49 48 48 47 49 48 47 77 48 47 48 48 49 47 48 48 48 49 47 48 47 48 47 49 48 47 49 48 47 47 48 48 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou're given an array a of n integers, such that a_1 + a_2 + ⋅⋅⋅ + a_n = 0.\n\nIn one operation, you can choose two different indices i and j (1 ≤ i, j ≤ n), decrement a_i by one and increment a_j by one. If i < j this op...
[{"type": "stdin_stdout", "input": "7\n4\n-3 5 -3 1\n2\n1 -1\n4\n-3 2 -3 4\n4\n-1 1 1 -1\n7\n-5 7 -6 -4 17 -13 4\n6\n-1000000000 -1000000000 -1000000000 1000000000 1000000000 1000000000\n1\n0\n", "output": "3\n0\n4\n1\n8\n3000000000\n0\n"}, {"type": "stdin_stdout", "input": "1\n6\n4 -4 -4 3 2 -1\n", "output": "4\n"}, {...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nKolya got an integer array a_1, a_2, ..., a_n. The array can contain both positive and negative integers, but Kolya doesn't like 0, so the array doesn't contain any zeros.\n\nKolya doesn't like that the sum of some subseg...
[{"type": "stdin_stdout", "input": "100\n-6 2 8 -9 -9 3 -3 -2 7 3 2 -2 -9 -7 -10 -9 10 4 5 -9 8 -5 7 -2 6 -2 4 4 -2 -5 6 4 8 -8 9 7 -4 2 -3 7 4 -10 -7 -4 8 2 10 -8 -3 -8 -5 -5 -10 -6 -8 -5 7 -1 7 -5 9 10 3 5 10 -7 -3 -7 1 -5 -8 5 1 -1 4 10 2 6 -4 9 3 10 -5 -10 -10 -2 1 9 10 1 10 2 8 -3 -3 -1 7 -5 8 -4\n", "output": "11...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA string t is called an anagram of the string s, if it is possible to rearrange letters in t so that it is identical to the string s. For example, the string \"aab\" is an anagram of the string \"aba\" and the string \"aa...
[{"type": "stdin_stdout", "input": "??fb???a??\ndeeefc\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "??fb???a??\ndedefc\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "??fb???a??\ndedefd\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "??a???bf??\ndedefd\n", "output": "0\n"}, {"type": "stdin...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given two strings x and y, both consist only of lowercase Latin letters. Let |s| be the length of string s.\n\nLet's call a sequence a a merging sequence if it consists of exactly |x| zeros and exactly |y| ones in...
[{"type": "stdin_stdout", "input": "justamassivetesttocheck\nhowwellyouhandlemodulooperations\n", "output": "\n667387032\n"}, {"type": "stdin_stdout", "input": "justamassivetestsocheck\nhowwellyouhandlemodulooperations\n", "output": "732028571\n"}, {"type": "stdin_stdout", "input": "kcehcostsetevissamatsuj\nhowwellyouh...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThis is an interactive problem!\n\nNastia has a hidden permutation p of length n consisting of integers from 1 to n. You, for some reason, want to figure out the permutation. To do that, you can give her an integer t (1 ≤...
[{"type": "stdin_stdout", "input": "24\n4\n3 2 1 4\n4\n4 2 1 3\n4\n1 2 3 4\n4\n4 3 1 2\n4\n1 3 4 2\n4\n3 1 2 4\n4\n1 3 2 4\n4\n2 1 4 3\n4\n4 2 3 1\n4\n4 1 2 3\n4\n1 2 4 3\n4\n1 4 2 3\n4\n3 4 2 1\n4\n2 4 1 3\n5\n1 4 3 2\n4\n2 4 3 1\n4\n3 1 4 2\n4\n3 2 4 1\n4\n2 3 1 4\n4\n4 3 2 1\n4\n2 1 3 4\n4\n4 1 3 2\n4\n2 3 4 1\n4\n3...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSuppose you have two points p = (x_p, y_p) and q = (x_q, y_q). Let's denote the Manhattan distance between them as d(p, q) = |x_p - x_q| + |y_p - y_q|.\n\nLet's say that three points p, q, r form a bad triple if d(p, r) =...
[{"type": "stdin_stdout", "input": "3\n4\n2 4 1 3\n5\n6 9 1 18 12\n2\n13 37\n", "output": "10\n13\n3\n"}, {"type": "stdin_stdout", "input": "3\n4\n2 4 1 3\n5\n6 9 2 18 12\n2\n13 37\n", "output": "10\n13\n3\n"}, {"type": "stdin_stdout", "input": "3\n4\n2 4 1 3\n5\n0 9 2 18 12\n2\n13 37\n", "output": "10\n13\n3\n"}, {"ty...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou'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...
[{"type": "stdin_stdout", "input": "zyxzxzwyxywxxwabcdabdacdbcacdbcacabaaba\n", "output": "zzzyyxxwddddccbba\n"}, {"type": "stdin_stdout", "input": "zyxzxzwyxybxxwabcdawdacdccacdbcacabaaba\n", "output": "zzzyyxxwwdddccbba\n"}, {"type": "stdin_stdout", "input": "thankstosamarasauteddybearsforthiscontest\n", "output": "y...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOnce Bob decided to lay a parquet floor in his living room. The living room is of size n × m metres. Bob had planks of three types: a planks 1 × 2 meters, b planks 2 × 1 meters, and c planks 2 × 2 meters. Help Bob find ou...
[{"type": "stdin_stdout", "input": "100 100 10000 10000 10000\n", "output": "aabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabb\naabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabb\nbbaabbaabbaabbaabbaabbaabbaabbaabbaabba...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWe often have to copy large volumes of information. Such operation can take up many computer resources. Therefore, in this problem you are advised to come up with a way to copy some part of a number array into another one...
[{"type": "stdin_stdout", "input": "20 30\n5 6 -6 10 10 -6 10 7 0 -20 3 1 -7 -13 1 -7 5 1 -1 1\n2 10 -10 -1 -9 3 9 -9 6 5 10 -2 -5 -14 1 5 -4 -1 -8 -7\n2 14\n1 8 11 1\n2 7\n1 6 11 1\n1 9 2 7\n1 12 1 7\n2 20\n2 5\n1 14 8 3\n1 8 17 4\n2 4\n1 11 12 9\n2 8\n2 3\n2 2\n1 17 13 2\n1 3 18 1\n2 11\n1 5 12 6\n1 12 13 1\n2 16\n2 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSmart Beaver recently got interested in a new word game. The point is as follows: count the number of distinct good substrings of some string s. To determine if a string is good or not the game uses rules. Overall there a...
[{"type": "stdin_stdout", "input": "hrsszhjvrbsszvqesessiqbzeqijjerqirhhjsehiehezvzihzssivhvihrivrhizeqvvhejvibhqrbbqjrjsessvrhijzsrqirvsqqbibzhrzseijesszsrzhjjbqsrjrsrizivvhsjvqz\n3\nrzzevhiibziqiirhsebebrvrvvjihsjhvjjrejvqezireqevqeszrrseriijijijveqzbsbrezqhrrhbshqrhzshjervqjjzveeqsisrbevvjvjhbzvbjrrvizh 0 122\niqqqj...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIahub is a big fan of tourists. He wants to become a tourist himself, so he planned a trip. There are n destinations on a straight road that Iahub wants to visit. Iahub starts the excursion from kilometer 0. The n destina...
[{"type": "stdin_stdout", "input": "50\n3987477 8934938 4067156 6712855 7269334 5039822 9533601 9335400 5992073 2619268 438734 8620973 4347619 4307947 2249161 815221 7615258 8244100 8341666 5908546 6646952 4812769 6215114 7479369 6290438 5623785 6466133 9953199 3525873 4326034 3510072 8117068 2342953 1717542 9766539 65...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGeorge loves graphs. Most of all, he loves interesting graphs. We will assume that a directed graph is interesting, if it meets the following criteria: \n\n * The graph doesn't contain any multiple arcs; \n * There is v...
[{"type": "stdin_stdout", "input": "5 25\n4 2\n1 4\n5 2\n2 2\n3 1\n4 5\n2 1\n2 5\n2 4\n1 2\n4 1\n4 4\n1 1\n1 5\n4 3\n5 1\n3 3\n1 3\n5 5\n2 3\n5 3\n3 5\n3 2\n5 4\n3 4\n", "output": "12\n"}, {"type": "stdin_stdout", "input": "500 12\n129 135\n47 22\n382 193\n17 381\n325 499\n70 192\n266 250\n116 430\n429 428\n451 65\n104...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOnce little Vasya read an article in a magazine on how to make beautiful handmade garland from colored paper. Vasya immediately went to the store and bought n colored sheets of paper, the area of each sheet is 1 square me...
[{"type": "stdin_stdout", "input": "hvewdvwdwudrwarwmddwnazmwauzatrmwptwwevavpmwrtruwnpwantewrnwmepdwvtmnveanunrvrtwpvhhnuhnmpptdttzmmndtvudmzhhannmmnahdpzamuvhzaavnhtnumwrwvttdetvuewaaennddwuvzvaptdzrzhtetwwzmzedrwuvrwznprhdvnavrruvvhzuwpdtmpwmzrwvermrhdamv\nuvzhwtpuputnahwwarduzddhpnwwvettprwavdmnztdnrddmarmvuevtdezn...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn this problem, your task is to use ASCII graphics to paint a cardiogram. \n\nA cardiogram is a polyline with the following corners:\n\n<image>\n\nThat is, a cardiogram is fully defined by a sequence of positive integers...
[{"type": "stdin_stdout", "input": "23\n33 42 55 36 73 42 36 39 35 38 38 65 31 33 26 40 20 32 45 32 31 35 36\n", "output": " ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasya trains to compose crossword puzzles. He can only compose crosswords of a very simplе type so far. All of them consist of exactly six words; the words can be read only from top to bottom vertically and from the left ...
[{"type": "stdin_stdout", "input": "ABBAAAABBBB\nBBABAAAABAABAB\nBAABABBBABBBBBAAA\nBABABAAABBAAABBAAAAB\nABAAAABBBBBABAABABBAAAAABBBBBB\nBBBBAABBAABBBBABAAABAABBAABBAA\n", "output": "BAABABBBABBBBBAAA.............\nA...............B.............\nB...............A.............\nA...............A.............\nB..........
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLeonid wants to become a glass carver (the person who creates beautiful artworks by cutting the glass). He already has a rectangular w mm × h mm sheet of glass, a diamond glass cutter and lots of enthusiasm. What he lac...
[{"type": "stdin_stdout", "input": "10 19 10\nV 6\nH 8\nV 4\nV 8\nH 2\nH 5\nV 9\nH 7\nH 3\nV 7\n", "output": "114\n66\n44\n44\n44\n44\n44\n44\n44\n44\n"}, {"type": "stdin_stdout", "input": "15 5 10\nV 13\nV 6\nV 3\nH 4\nV 12\nV 7\nV 2\nH 1\nV 4\nH 3\n", "output": "65\n35\n35\n28\n24\n20\n20\n15\n15\n10\n"}, {"type": "s...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nChris the Rabbit has been interested in arrays ever since he was a child. At the moment he is researching arrays with the length of n, containing only integers from 1 to n. He is not good at math, that's why some simple t...
[{"type": "stdin_stdout", "input": "100000\n", "output": "879367333\n"}, {"type": "stdin_stdout", "input": "99925\n", "output": "414342728\n"}, {"type": "stdin_stdout", "input": "54904\n", "output": "917915735\n"}, {"type": "stdin_stdout", "input": "57500\n", "output": "540890446\n"}, {"type": "stdin_stdout", "input": ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA function <image> is called Lipschitz continuous if there is a real constant K such that the inequality |f(x) - f(y)| ≤ K·|x - y| holds for all <image>. We'll deal with a more... discrete version of this term.\n\nFor an ...
[{"type": "stdin_stdout", "input": "3 6\n48261735 26888803 75904937\n1 2\n1 3\n2 3\n1 2\n2 3\n1 3\n", "output": "21372932\n119405200\n49016134\n21372932\n49016134\n119405200\n"}, {"type": "stdin_stdout", "input": "3 6\n48261735 26888803 95582211\n1 2\n1 3\n2 3\n1 2\n2 3\n1 3\n", "output": "21372932\n158759748\n68693408...
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\nA wise man told Kerem \"Different is good\" once, so Kerem wants all things in his life to be different. \n\nKerem recently got a string s consisting of lowercase English letters. Since Kerem likes it when things are diff...
[{"type": "stdin_stdout", "input": "45\naaabbbcccdddeeefffgghhiijjkkkkkkkkkkkkkkkkkkk\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "45\naaabbbcccdedeeefffgghhiijjkkkkkkkkkkkkkkkkkkk\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "45\naaabbbcccdedeeefffgghhijjjkkkkkkkkkkkkkkkkkkk\n", "output": "-1\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nBarney lives in country USC (United States of Charzeh). USC has n cities numbered from 1 through n and n - 1 roads between them. Cities and roads of USC form a rooted tree (Barney's not sure why it is rooted). Root of the...
[{"type": "stdin_stdout", "input": "85\n1 1 2 2 4 6 1 3 6 3 3 11 9 14 12 5 8 11 16 19 12 17 2 19 1 24 6 2 6 6 24 3 20 1 1 1 17 8 4 25 31 32 39 12 35 23 31 26 46 9 37 7 5 23 41 41 39 9 11 54 36 54 28 15 25 58 56 18 23 70 68 18 3 48 57 70 15 65 22 35 25 13 49 34\n", "output": "1.000000 28.500000 27.000000 38.000000 38.50...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasya plays the Need For Brake. He plays because he was presented with a new computer wheel for birthday! Now he is sure that he will win the first place in the championship in his favourite racing computer game! \n\nn ra...
[{"type": "stdin_stdout", "input": "20\ng 1000000\nibb 1000000\nidj 1000000\nkccg 1000000\nbbe 1000000\nhjf 1000000\na 1000000\nf 1000000\niij 1000000\nakgf 1000000\nkdkhj 1000000\ne 1000000\nh 1000000\nhb 1000000\nfaie 1000000\nj 1000000\ni 1000000\nhgg 1000000\nfi 1000000\nicf 1000000\n12\n1000000 1000000 1000000 100...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nApart from having lots of holidays throughout the year, residents of Berland also have whole lucky years. Year is considered lucky if it has no more than 1 non-zero digit in its number. So years 100, 40000, 5 are lucky an...
[{"type": "stdin_stdout", "input": "1000000000\n", "output": "1000000000\n"}, {"type": "stdin_stdout", "input": "100000000\n", "output": "100000000\n"}, {"type": "stdin_stdout", "input": "900000000\n", "output": "100000000\n"}, {"type": "stdin_stdout", "input": "703450474\n", "output": "96549526\n"}, {"type": "stdin_st...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIt's hard times now. Today Petya needs to score 100 points on Informatics exam. The tasks seem easy to Petya, but he thinks he lacks time to finish them all, so he asks you to help with one..\n\nThere is a glob pattern in...
[{"type": "stdin_stdout", "input": "k\n*\n89\nb\ncbbbc\ncabac\nbccbb\nccc\ncabaa\nabbaa\nccbaa\nccccb\ncabbb\nbbcbc\nbac\naaac\nabb\nbcbb\ncb\nbacc\nbbaba\nb\nacc\nbaac\naaba\nbcbba\nbaa\nbc\naaccb\nb\nab\nc\nbbbb\nabbcb\nacbb\ncba\nc\nbac\nc\nac\ncc\nb\nbbc\nbaab\nc\nbbc\nab\nb\nc\naa\naab\nab\naccbc\nacbaa\na\nccc\nc...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOlya loves energy drinks. She loves them so much that her room is full of empty cans from energy drinks.\n\nFormally, her room can be represented as a field of n × m cells, each cell of which is empty or littered with can...
[{"type": "stdin_stdout", "input": "10 10 1000\n..........\n..........\n..........\n..........\n..........\n...-......\n..........\n........./\n..........\n..........\n10 10 1 3\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "10 10 1000\n..........\n..........\n..........\n..........\n..........\n......-...\n....
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAlice has a very important message M consisting of some non-negative integers that she wants to keep secret from Eve. Alice knows that the only theoretically secure cipher is one-time pad. Alice generates a random key K o...
[{"type": "stdin_stdout", "input": "10\n331415699 278745619 998190004 423175621 42983144 166555524 843586353 802130100 337889448 685310951\n226011312 266003835 342809544 504667531 529814910 684873393 817026985 844010788 993949858 1031395667\n", "output": "\n128965467 \n243912600 \n4281110 \n112029883 \n223689619 \n7692...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nKatie, Kuro and Shiro are best friends. They have known each other since kindergarten. That's why they often share everything with each other and work together on some very hard problems.\n\nToday is Shiro's birthday. She...
[{"type": "stdin_stdout", "input": "1000000000000000000\n", "output": "1000000000000000001\n"}, {"type": "stdin_stdout", "input": "1043714136496022950\n", "output": "1043714136496022951\n"}, {"type": "stdin_stdout", "input": "1837625121252532586\n", "output": "1837625121252532587\n"}, {"type": "stdin_stdout", "input": ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA string s of length n can be encrypted by the following algorithm:\n\n * iterate over all divisors of n in decreasing order (i.e. from n to 1), \n * for each divisor d, reverse the substring s[1 ... d] (i.e. the substr...
[{"type": "stdin_stdout", "input": "100\noooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo\n", "output": "oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo\n"}, {"type": "stdin_stdout", "input": "100\nedykhvzcntljuuoqg...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nView Russian Translation\n\nLittle pig Benny has just taken a shower. Now she is going to buy some gifts for her relatives. But the problem is that Benny doesn't know how to reach to the gift shop. Her friend Mike has cre...
[{"type": "stdin_stdout", "input": "DDURLDRRUURDRLRDUDUDDUURULLUDRLUDUURDURRURDDRLDLRDURURDLDDDRRRLLURDUURRDLDDDDUDLDLULRRLLUDRLDRRRLDLRULULLLRRLDUDRRUDLUULLDRURULLRULRDLUDDDLDDLRLLUDLRLUULRDDULRRDRRLLRDLRDLRLDLRRDRUUDUUDRRDULUDUDLLRLUDLRRLRDULLRLLULURRUDRRRRLUDDLRURRRLLDDDUDRRDLURLRLDLRRLDRDDDRLULLDDLUDULDDRUULRUDULRU...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMr. Hahn, our very own DJ, was seeing Chester and Mike fighting over such questions lately. Being a geek himself, he thought of showing off his skills and gave the both of them a question. \n\nHe gave them a single positi...
[{"type": "stdin_stdout", "input": "1\n\nSANPLE", "output": "7 3\n"}, {"type": "stdin_stdout", "input": "1\n\nSANQLE", "output": "7 3\n"}, {"type": "stdin_stdout", "input": "1\n\nSNAQLE", "output": "7 3\n"}, {"type": "stdin_stdout", "input": "1\n\nSEAQLN", "output": "7 3\n"}, {"type": "stdin_stdout", "input": "1\n\nSEA...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nProblem Statement:\nYou are one of the organizers of Pragyan.Having worked so hard to ensure\nsuccess of the event, you are able to spot the word \"pragyan\" in any text.\nYou are given a stream of character strings and y...
[{"type": "stdin_stdout", "input": "Far\nout\nin\nthe\nuncharted\nbackwaters\nof\nthe\nunfashionable\nend\nof\nthe\nwestern\nspiral\nPRAGYAN\narm\nof\nthe\nGalaxy\nlies\na\nsmall\nunregarded\nyellow\nsun", "output": "Far\nout\nin\nthe\nuncharted\nbackwaters\nof\nthe\nunfashionable\nend\nof\nthe\nwestern\nspiral\nPRAGYA...
code_stdio