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\nIlya lives in a beautiful city of Chordalsk.\n\nThere are $n$ houses on the street Ilya lives, they are numerated from $1$ to $n$ from left to right; the distance between every two neighboring houses is equal to $1$ unit.... | [{"type": "stdin_stdout", "input": "41\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 1\n", "output": "39\n"}, {"type": "stdin_stdout", "input": "41\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 1\n", "outpu... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAn bydrocarbon is an organic compound which contains only carbons and hydrogens. An isomer is a compound that has the same number of carbons but different structures. Heptane, for example, is a hydrocarbon with 7 carbons.... | [{"type": "stdin_stdout", "input": "1\n30", "output": "1\n14348906\n"}, {"type": "stdin_stdout", "input": "1\n30", "output": "1\n14348906\n"}, {"type": "stdin_stdout", "input": "1\n25", "output": "1\n1062881\n"}, {"type": "stdin_stdout", "input": "1\n29", "output": "1\n9565937\n"}, {"type": "stdin_stdout", "input": "1\... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given an array $a$ consisting of $n$ integers.\n\nYou can remove at most one element from this array. Thus, the final length of the array is $n-1$ or $n$.\n\nYour task is to calculate the maximum possible length o... | [{"type": "stdin_stdout", "input": "12\n123654 1 2 3 4 5 6 7 16 9 10 11\n", "output": "10\n"}, {"type": "stdin_stdout", "input": "12\n123654 1 2 3 4 5 6 7 8 9 10 11\n", "output": "11\n"}, {"type": "stdin_stdout", "input": "12\n123654 1 2 6 4 5 6 7 16 9 10 11\n", "output": "7\n"}, {"type": "stdin_stdout", "input": "12\n... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nFor a non-negative integer K, we define a fractal of level K as follows:\n\n* A fractal of level 0 is a grid with just one white square.\n* When K > 0, a fractal of level K is a 3^K \\times 3^K grid. If we divide this gri... | [{"type": "stdin_stdout", "input": "2\n3 2 7 8\n12 3 1 15", "output": "10\n23\n"}, {"type": "stdin_stdout", "input": "2\n0 2 7 8\n12 3 1 15", "output": "13\n23\n"}, {"type": "stdin_stdout", "input": "2\n0 2 10 8\n6 3 1 15", "output": "16\n17\n"}, {"type": "stdin_stdout", "input": "2\n15 2 4 4\n7 6 1 26", "output": "13\... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nWe saw the little game Marmot made for Mole's lunch. Now it's Marmot's dinner time and, as we all know, Marmot eats flowers. At every dinner he eats some red and white flowers. Therefore a dinner can be represented as a s... | [{"type": "stdin_stdout", "input": "3 1\n1 3\n2 3\n4 10\n", "output": "14\n12\n2032\n"}, {"type": "stdin_stdout", "input": "3 1\n1 3\n2 3\n4 6\n", "output": "14\n12\n112\n"}, {"type": "stdin_stdout", "input": "3 1\n2 6\n1 3\n4 4\n", "output": "124\n14\n16\n"}, {"type": "stdin_stdout", "input": "3 1\n1 3\n2 5\n1 6\n", "... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nVasya and Petya wrote down all integers from 1 to n to play the \"powers\" game (n can be quite large; however, Vasya and Petya are not confused by this fact).\n\nPlayers choose numbers in turn (Vasya chooses first). If s... | [{"type": "stdin_stdout", "input": "1000000000\n", "output": "Vasya\n"}, {"type": "stdin_stdout", "input": "1000000000\n", "output": "Vasya\n"}, {"type": "stdin_stdout", "input": "1000000001\n", "output": "Vasya\n"}, {"type": "stdin_stdout", "input": "0000000001\n", "output": "Vasya\n"}, {"type": "stdin_stdout", "input... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nWhat are you doing at the end of the world? Are you busy? Will you save us?\n\n<image>\n\nNephren is playing a game with little leprechauns.\n\nShe gives them an infinite array of strings, f0... ∞.\n\nf0 is \"What are you... | [{"type": "stdin_stdout", "input": "10\n100000 873326525630182716\n100000 620513733919162415\n100000 482953375281256917\n100000 485328193417229962\n100000 353549227094721271\n100000 367447590857326107\n100000 627193846053528323\n100000 243833127760837417\n100000 287297493528203749\n100000 70867563577617188\n", "output"... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThe cows have just learned what a primitive root is! Given a prime p, a primitive root $\\operatorname{mod} p$ is an integer x (1 ≤ x < p) such that none of integers x - 1, x^2 - 1, ..., x^{p} - 2 - 1 are divisible by p, ... | [{"type": "stdin_stdout", "input": "1583\n", "output": "672\n"}, {"type": "stdin_stdout", "input": "1987\n", "output": "660\n"}, {"type": "stdin_stdout", "input": "1993\n", "output": "656\n"}, {"type": "stdin_stdout", "input": "1997\n", "output": "996\n"}, {"type": "stdin_stdout", "input": "1999\n", "output": "648\n"},... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nProblem Statement\n\nIn the headquarter building of ICPC (International Company of Plugs & Connectors), there are $M$ light bulbs and they are controlled by $N$ switches. Each light bulb can be turned on or off by exactly... | [{"type": "stdin_stdout", "input": "3 10 3\n000 0000000000\n110 0000001011\n101 1111111100\n2 6 0\n1 2 0\n2 1 1\n01 1\n11 11 10\n10000000000 10000000000\n11000000000 00000000000\n01100000000 00100000000\n00110000000 00010000000\n00011000000 00001000000\n00001100000 00000100000\n01000110000 00000010000\n00000011000 0000... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere is data that records the altitude of mountains that have been climbed so far. Create a program that reads this data and outputs the elevation difference between the highest and lowest mountains.\n\n\n\nInput\n\nThe ... | [{"type": "stdin_stdout", "input": "3783.6109384455353\n1821.5992049377405\n649.3237125101873\n2008.8147615323267\n1214.1371939030753", "output": "3134.28722594\n"}, {"type": "stdin_stdout", "input": "3784.5476877206565\n1821.5992049377405\n649.3237125101873\n2008.8147615323267\n1214.1371939030753", "output": "3135.223... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere are n workers in a company, each of them has a unique id from 1 to n. Exaclty one of them is a chief, his id is s. Each worker except the chief has exactly one immediate superior.\n\nThere was a request to each of t... | [{"type": "stdin_stdout", "input": "10 6\n3 0 0 0 0 0 0 1 0 0\n", "output": "7\n"}, {"type": "stdin_stdout", "input": "10 6\n3 1 0 0 0 0 0 1 0 0\n", "output": "6\n"}, {"type": "stdin_stdout", "input": "10 6\n3 0 1 0 0 0 0 1 0 1\n", "output": "5\n"}, {"type": "stdin_stdout", "input": "10 6\n3 0 0 0 0 0 0 1 0 1\n", "outp... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nIn Wolf town there are 2 big markets S and T. The distance between these markets is D. Chef Ciel would like to run 2 restaurants in Wolf town, where the first restaurant will be supplied by the market S and the second one... | [{"type": "stdin_stdout", "input": "4\n15 15 50\n15 15 18\n43 88 200\n2013 2013 2013", "output": "20.000\n0.0\n69.00000\n0"}, {"type": "stdin_stdout", "input": "4\n15 15 50\n15 15 18\n43 88 200\n2013 2013 2013", "output": "20.0\n0\n69.0\n0\n"}, {"type": "stdin_stdout", "input": "4\n2 25 50\n15 12 28\n11 88 200\n2715 17... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThis is an interactive problem.\n\nYou are given a sorted in increasing order singly linked list. You should find the minimum integer in the list which is greater than or equal to x.\n\nMore formally, there is a singly li... | [{"type": "stdin_stdout", "input": "10 3 632584719\n378382911 9\n978367651 -1\n176599346 7\n557138623 8\n441019502 4\n823417558 2\n244832688 10\n702148024 6\n385598339 5\n357778234 1\n", "output": "? 3\n? 9\n! 978367651\n"}, {"type": "stdin_stdout", "input": "10 3 632584719\n378382911 9\n978367651 -1\n176599346 7\n5571... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nWe have a string S consisting of lowercase English letters.\nIf the length of S is at most K, print S without change.\nIf the length of S exceeds K, extract the first K characters in S, append ... to the end of them, and ... | [{"type": "stdin_stdout", "input": "99\nlbyhybgfptdyuqnlszvxoggbjhrjopbevyrzytfhiabtoozntnxxcvmhckjlwxnzniwzzxzvmfiztyirssfeauzncyosgrmsgull\n", "output": "lbyhybgfptdyuqnlszvxoggbjhrjopbevyrzytfhiabtoozntnxxcvmhckjlwxnzniwzzxzvmfiztyirssfeauzncyosgrmsgul...\n"}, {"type": "stdin_stdout", "input": "100\nvefcekrnrodmjprt... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nKavi has 2n points lying on the OX axis, i-th of which is located at x = i.\n\nKavi considers all ways to split these 2n points into n pairs. Among those, he is interested in good pairings, which are defined as follows:\n... | [{"type": "stdin_stdout", "input": "1000000\n", "output": "126330412"}, {"type": "stdin_stdout", "input": "372544\n", "output": "214345447\n"}, {"type": "stdin_stdout", "input": "315936\n", "output": "256195953\n"}, {"type": "stdin_stdout", "input": "446167\n", "output": "461428149\n"}, {"type": "stdin_stdout", "input"... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given an array of integers. Vasya can permute (change order) its integers. He wants to do it so that as many as possible integers will become on a place where a smaller integer used to stand. Help Vasya find the m... | [{"type": "stdin_stdout", "input": "6\n300000000 200000000 300000000 200000000 1000000000 300000000\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "6\n300000000 200000000 300000000 200000000 1000000000 300000000\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "6\n506233607 200000000 300000000 200000000... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nHave you ever tasted Martian food? Well, you should.\n\nTheir signature dish is served on a completely black plate with the radius of R, flat as a pancake.\n\nFirst, they put a perfectly circular portion of the Golden Hon... | [{"type": "stdin_stdout", "input": "2\n4 3 1\n5 2 2\n", "output": "0.9230769231\n0.6521739130\n"}, {"type": "stdin_stdout", "input": "2\n8 3 1\n4 2 2\n", "output": "2.4489795918\n0.6666666667\n"}, {"type": "stdin_stdout", "input": "2\n9 3 1\n4 2 2\n", "output": "2.5714285714\n0.6666666667\n"}, {"type": "stdin_stdout", ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are a given an array $a$ of length $n$. Find a subarray $a[l..r]$ with length at least $k$ with the largest median.\n\nA median in an array of length $n$ is an element which occupies position number $\\lfloor \\frac{n... | [{"type": "stdin_stdout", "input": "100 16\n14 94 97 89 73 165 11 78 10 30 54 57 88 57 44 6 33 40 17 26 69 100 92 67 22 59 80 67 17 29 76 69 133 7 86 45 1 98 99 25 65 102 94 91 7 24 53 40 53 91 59 32 67 24 25 157 55 46 68 53 2 15 92 5 53 37 76 40 49 94 4 8 76 12 50 2 54 86 49 95 81 5 34 28 21 47 97 73 96 56 32 78 71 38... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nSnuke lives at position x on a number line.\nOn this line, there are two stores A and B, respectively at position a and b, that offer food for delivery.\nSnuke decided to get food delivery from the closer of stores A and ... | [{"type": "stdin_stdout", "input": "1 999 1000\n", "output": "A\n"}, {"type": "stdin_stdout", "input": "1 1455 0000", "output": "B\n"}, {"type": "stdin_stdout", "input": "1 1200 0101", "output": "B\n"}, {"type": "stdin_stdout", "input": "1 999 0000", "output": "B\n"}, {"type": "stdin_stdout", "input": "1 381 1110", "ou... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nExample\n\nInput\n\n2 2 2 1\n0 0 0\n\n\nOutput\n\n24\n\nThe input will be stdin and you should print your solution to stdout\n\n\nNow solve the problem and return the code.\n\nWrite Python code to solve this problem. Your... | [{"type": "stdin_stdout", "input": "26 2 22 0\n-1 2 0", "output": "1336\n"}, {"type": "stdin_stdout", "input": "36 2 22 0\n-1 2 0", "output": "1816\n"}, {"type": "stdin_stdout", "input": "36 2 43 0\n-1 2 0", "output": "3412\n"}, {"type": "stdin_stdout", "input": "3 8 88 0\n-2 8 -1", "output": "1984\n"}, {"type": "stdin... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nRecently Vova found $n$ candy wrappers. He remembers that he bought $x$ candies during the first day, $2x$ candies during the second day, $4x$ candies during the third day, $\\dots$, $2^{k-1} x$ candies during the $k$-th ... | [{"type": "stdin_stdout", "input": "53\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n", "output": "1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given a string of length N. Calculate the number of distinct substrings of S.\n\nConstraints\n\n* 1 \\leq N \\leq 500,000\n* S consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input ... | [{"type": "stdin_stdout", "input": "mjssissippi", "output": "57\n"}, {"type": "stdin_stdout", "input": "mjssisrippi", "output": "61\n"}, {"type": "stdin_stdout", "input": "mjssisripph", "output": "62\n"}, {"type": "stdin_stdout", "input": "hppirsitsjm", "output": "63\n"}, {"type": "stdin_stdout", "input": "mjsthspiroh"... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nSnuke has decided to use a robot to clean his room.\n\nThere are N pieces of trash on a number line. The i-th piece from the left is at position x_i. We would like to put all of them in a trash bin at position 0.\n\nFor t... | [{"type": "stdin_stdout", "input": "16 10\n1 12 12 27 52 132 731 18298 395504 534840 1276551 903860 9384806 19108104 82684732 535447408", "output": "3248775590\n"}, {"type": "stdin_stdout", "input": "16 10\n0 12 12 27 52 132 731 18298 395504 534840 1276551 903860 9384806 19108104 82684732 535447408", "output": "3248775... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThe winner of the card game popular in Berland \"Berlogging\" is determined according to the following rules. If at the end of the game there is only one player with the maximum number of points, he is the winner. The sit... | [{"type": "stdin_stdout", "input": "12\natrtthfpcvishmqbakprquvnejr 185\natrtthfpcvishmqbakprquvnejr -699\natrtthfpcvishmqbakprquvnejr -911\natrtthfpcvishmqbakprquvnejr -220\nfcgslzkicjrpbqaifgweyzreajjfdo 132\nfcgslzkicjrpbqaifgweyzreajjfdo -242\nm 177\nm -549\natrtthfpcvishmqbakprquvnejr -242\nm 38\natrtthfpcvishmqba... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nProblem statement\n\n2D, who is good at cooking, is trying to make lunch. Cooking requires all N ingredients a_ {0}, a_ {1},…, a_ {N−1}.\n\nNow, 2D's refrigerator doesn't contain any ingredients, so I have to go to the su... | [{"type": "stdin_stdout", "input": "2\npaks 0\naxii -1\n-1\nnkua hx`j", "output": "-1\n"}, {"type": "stdin_stdout", "input": "2\ntako -1\njiay -1\n0\npuja yakh", "output": "-2\n"}, {"type": "stdin_stdout", "input": "2\npaks -2\nayhi -1\n0\nmauk j`xh", "output": "-3\n"}, {"type": "stdin_stdout", "input": "2\npaks 1\naxi... | 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\nA permutation p of size n is an array such that every integer from 1 to n occurs exactly once in this array.\n\nLet's call a permutation an almost identity permutation iff there exist at least n - k indices i (1 ≤ i ≤ n) ... | [{"type": "stdin_stdout", "input": "1000 4\n", "output": "373086956251\n"}, {"type": "stdin_stdout", "input": "1000 4\n", "output": "373086956251\n"}, {"type": "stdin_stdout", "input": "800 4\n", "output": "152620985001\n"}, {"type": "stdin_stdout", "input": "800 4\n", "output": "152620985001\n"}, {"type": "stdin_stdou... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nproblem\n\nYou are a traveler traveling on the JOI Highway. The JOI Highway is a road that extends straight from east to west, and there are n post towns on the JOI Highway. Numbered. The westernmost post town on the JOI ... | [{"type": "stdin_stdout", "input": "7 5\n2\n0\n1\n1\n2\n-1\n2\n-1\n2\n2\n-3", "output": "10\n"}, {"type": "stdin_stdout", "input": "7 0\n1\n-1\n1\n3\n1\n-1\n3\n-2\n-1\n1\n0", "output": "0\n"}, {"type": "stdin_stdout", "input": "7 0\n1\n-1\n1\n2\n1\n-1\n3\n-2\n-1\n1\n0", "output": "0\n"}, {"type": "stdin_stdout", "input... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nPetya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.\... | [{"type": "stdin_stdout", "input": "100000 77777\n", "output": "177777\n"}, {"type": "stdin_stdout", "input": "150234 77777\n", "output": "177777\n"}, {"type": "stdin_stdout", "input": "77777 77777\n", "output": "177777\n"}, {"type": "stdin_stdout", "input": "47774 47774\n", "output": "147774\n"}, {"type": "stdin_stdou... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nKilani is playing a game with his friends. This game can be represented as a grid of size $n \\times m$, where each cell is either empty or blocked, and every player has one or more castles in some cells (there are no two... | [{"type": "stdin_stdout", "input": "4 7 2\n13 1\n....###\n.#..1..\n.#.###.\n2#.....\n", "output": "18 1 \n"}, {"type": "stdin_stdout", "input": "4 7 2\n13 1\n###....\n..1..#.\n.###.#.\n.....#2\n", "output": "18 1 \n"}, {"type": "stdin_stdout", "input": "4 7 2\n13 1\n###....\n..1..#.\n.###.#.\n.....#2\n", "output": "18 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nOur master carpenter is designing a condominium called Bange Hills Mansion. The condominium is constructed by stacking up floors of the same height. The height of each floor is designed so that the total height of the sta... | [{"type": "stdin_stdout", "input": "000 12 208", "output": "197\n"}, {"type": "stdin_stdout", "input": "000 9 208", "output": "200\n"}, {"type": "stdin_stdout", "input": "000 4 120", "output": "117\n"}, {"type": "stdin_stdout", "input": "000 16 106", "output": "91\n"}, {"type": "stdin_stdout", "input": "000 26 106", "o... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nVladik often travels by trains. He remembered some of his trips especially well and I would like to tell you about one of these trips:\n\nVladik is at initial train station, and now n people (including Vladik) want to get... | [{"type": "stdin_stdout", "input": "100\n931 4584 2116 3004 3813 62 2819 2998 2080 4906 3198 2443 2952 3793 1958 3864 3985 3169 3134 4011 4525 995 4163 308 4362 1148 4906 3092 1647 244 1370 1424 2753 84 2997 1197 2606 425 3501 2606 683 4747 3884 4787 2166 3017 3080 4303 3352 1667 2636 3994 757 2388 870 1788 988 1303 0 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThe Smart Beaver from ABBYY decided to have a day off. But doing nothing the whole day turned out to be too boring, and he decided to play a game with pebbles. Initially, the Beaver has n pebbles. He arranges them in a eq... | [{"type": "stdin_stdout", "input": "1000000000\n", "output": "1998535156\n"}, {"type": "stdin_stdout", "input": "999161856\n", "output": "1998319610\n"}, {"type": "stdin_stdout", "input": "999936000\n", "output": "1999743134\n"}, {"type": "stdin_stdout", "input": "999999948\n", "output": "1833697140\n"}, {"type": "stdi... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nOur world is one-dimensional, and ruled by two empires called Empire A and Empire B.\nThe capital of Empire A is located at coordinate X, and that of Empire B is located at coordinate Y.\nOne day, Empire A becomes incline... | [{"type": "stdin_stdout", "input": "99 99 -22 62\n-9 -54 -13 -39 -79 -88 -6 -14 -41 -29 -2 -69 -30 -20 -33 -8 -24 -80 -19 -87 -32 -60 -40 -59 -44 -52 -3 -67 -18 -51 -56 -12 -7 -31 -48 -27 -68 -78 -21 -11 -49 -93 -1 -64 -82 -66 -70 -58 -84 -26 -57 -37 -53 -89 -50 -34 -61 -46 -92 -95 -99 -63 -65 -28 -10 -16 -73 -55 -98 -... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nLet's call an array $a$ consisting of $n$ positive (greater than $0$) integers beautiful if the following condition is held for every $i$ from $1$ to $n$: either $a_i = 1$, or at least one of the numbers $a_i - 1$ and $a_... | [{"type": "stdin_stdout", "input": "4\n1\n12\n13\n35\n", "output": "1\n4\n4\n6\n"}, {"type": "stdin_stdout", "input": "4\n1\n12\n11\n14\n", "output": "1\n4\n4\n4\n"}, {"type": "stdin_stdout", "input": "4\n1\n12\n22\n35\n", "output": "1\n4\n5\n6\n"}, {"type": "stdin_stdout", "input": "4\n2\n12\n11\n14\n", "output": "2\n... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nPermutation $p$ is a sequence of integers $p=[p_1, p_2, \\dots, p_n]$, consisting of $n$ distinct (unique) positive integers between $1$ and $n$, inclusive. For example, the following sequences are permutations: $[3, 4, 1... | [{"type": "stdin_stdout", "input": "4\n5\n1 3 4 5 5\n4\n1 1 3 4\n2\n2 2\n1\n1\n", "output": "1 3 4 5 2 \n-1\n2 1 \n1 \n"}, {"type": "stdin_stdout", "input": "4\n5\n1 3 4 5 5\n4\n1 1 3 4\n2\n2 2\n1\n1\n", "output": "1 3 4 5 2 \n-1\n2 1 \n1 \n"}, {"type": "stdin_stdout", "input": "4\n5\n2 3 4 5 5\n4\n1 1 3 4\n2\n2 2\n1\n... | 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... | [{"type": "stdin_stdout", "input": "11\nabbaac\nabbaac\nabbaac\nabbaac\nabbaac\nabbaac\nabbaac\nabbaac\nac\nbccddaaf\nzzzzzzzzzz\n", "output": "abac\nabac\nabac\nabac\nabac\nabac\nabac\nabac\nac\nbcdaf\nzzzzzz\n"}, {"type": "stdin_stdout", "input": "10\nabbaac\nac\nbccddaaf\nzzzzzzzzzz\nabbaac\nac\nbccddaaf\nzzzzzzzzzz... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nMashmokh's boss, Bimokh, didn't like Mashmokh. So he fired him. Mashmokh decided to go to university and participate in ACM instead of finding a new job. He wants to become a member of Bamokh's team. In order to join he w... | [{"type": "stdin_stdout", "input": "2000 2000\n", "output": "585712681"}, {"type": "stdin_stdout", "input": "1544 1794\n", "output": "933285446"}, {"type": "stdin_stdout", "input": "1639 1056\n", "output": "467464129"}, {"type": "stdin_stdout", "input": "2000 1000\n", "output": "228299266"}, {"type": "stdin_stdout", "i... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nHave you ever had an infinite loop when you ran a hard-working program? It would be convenient to be able to determine in advance whether a program will stop executing without having to execute it.\n\nUnfortunately, it is... | [{"type": "stdin_stdout", "input": "6\n10 SET d 1\n20 SET h 5\n100 ADD s s i\n110 SUB i i c\n120 IF i 100\n124 HALT", "output": "c=0\nd=1\nh=5\ni=0\ns=0\n"}, {"type": "stdin_stdout", "input": "6\n10 SET c 1\n20 SET h 5\n100 ADD s s i\n110 SUB i i c\n209 IF j 100\n200 HALT", "output": "c=1\nh=5\ni=0\nj=0\ns=0\n"}, {"typ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nFinally, a basketball court has been opened in SIS, so Demid has decided to hold a basketball exercise session. $2 \\cdot n$ students have come to Demid's exercise session, and he lined up them into two rows of the same s... | [{"type": "stdin_stdout", "input": "100\n4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1\n1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere is a rectangular grid of n rows of m initially-white cells each.\n\nArkady performed a certain number (possibly zero) of operations on it. In the i-th operation, a non-empty subset of rows R_{i} and a non-empty subs... | [{"type": "stdin_stdout", "input": "50 8\n.....#..\n........\n........\n.....#..\n.....#..\n........\n........\n........\n........\n...#....\n...#....\n........\n...#....\n#.#.#...\n...#....\n...#....\n........\n...#....\n...#....\n...#....\n........\n#.#.#...\n.....#..\n........\n#.#.#...\n#.#.#...\n#.#.#...\n...#....... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nTakahashi is standing on a two-dimensional plane, facing north. Find the minimum positive integer K such that Takahashi will be at the starting position again after he does the following action K times:\n\n* Go one meter ... | [{"type": "stdin_stdout", "input": "1329", "output": "120\n"}, {"type": "stdin_stdout", "input": "1162", "output": "180\n"}, {"type": "stdin_stdout", "input": "1369", "output": "360\n"}, {"type": "stdin_stdout", "input": "1527", "output": "120\n"}, {"type": "stdin_stdout", "input": "1874", "output": "180\n"}, {"type": ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nNumber of tanka\n\nWishing to die in the spring under the flowers\n\nThis is one of the famous tanka poems that Saigyo Hoshi wrote. Tanka is a type of waka poem that has been popular in Japan for a long time, and most of ... | [{"type": "stdin_stdout", "input": "1\n1\n3\n1531\n2317\n714\n225725068861419081\n0", "output": "10\n10\n13\n55955\n155155\n7277\n3223333233333322222322232232233222323233333233223332\n"}, {"type": "stdin_stdout", "input": "1\n1\n4\n1531\n2317\n714\n225725068861419081\n0", "output": "10\n10\n14\n55955\n155155\n7277\n322... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nPaladin Manao caught the trail of the ancient Book of Evil in a swampy area. This area contains n settlements numbered from 1 to n. Moving through the swamp is very difficult, so people tramped exactly n - 1 paths. Each o... | [{"type": "stdin_stdout", "input": "50 2 5\n9 14\n46 34\n40 35\n44 30\n32 16\n1 38\n48 2\n17 14\n50 25\n6 1\n45 19\n21 15\n22 11\n15 33\n8 28\n2 32\n10 22\n37 3\n43 39\n25 16\n9 19\n16 3\n28 32\n20 45\n24 32\n4 18\n49 39\n13 45\n26 4\n11 33\n14 37\n42 19\n31 45\n38 3\n34 8\n18 29\n35 34\n29 16\n7 46\n19 28\n27 33\n30 9... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nPolycarp has found a table having an infinite number of rows and columns. The rows are numbered from $1$, starting from the topmost one. The columns are numbered from $1$, starting from the leftmost one.\n\nInitially, the... | [{"type": "stdin_stdout", "input": "100\n1\n2\n2\n3\n4\n5\n6\n13\n15\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n35\n20\n21\n22\n23\n24\n25\n26\n27\n28\n23\n30\n31\n32\n33\n34\n35\n36\n19\n38\n60\n40\n41\n42\n43\n44\n119\n46\n47\n77\n49\n44\n51\n45\n53\n54\n55\n56\n57\n58\n87\n60\n61\n42\n63\n64\n65\n66\n67\n68\n69\n70\n12... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThe Little Elephant loves chess very much. \n\nOne day the Little Elephant and his friend decided to play chess. They've got the chess pieces but the board is a problem. They've got an 8 × 8 checkered board, each square i... | [{"type": "stdin_stdout", "input": "WBWBWBWB\nBWBWBWBW\nBWBWBWBW\nBWBWBWBW\nWBWBWBWB\nWBWBWBWB\nBWBWBWBW\nWBWBWBWB\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "BWBWBWBW\nWBWBWBWB\nBWBWBWBW\nBWBWBWBW\nWBWBWBWB\nWBWBWBWB\nWBWBWBWB\nWBWBWBWB\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "BWBWBWBW... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThe semester is already ending, so Danil made an effort and decided to visit a lesson on harmony analysis to know how does the professor look like, at least. Danil was very bored on this lesson until the teacher gave the ... | [{"type": "stdin_stdout", "input": "8\n", "output": "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n+*+*+*+*+... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nEvery Codeforces user has rating, described with one integer, possibly negative or zero. Users are divided into two divisions. The first division is for users with rating 1900 or higher. Those with rating 1899 or lower be... | [{"type": "stdin_stdout", "input": "50\n67 1\n89 2\n83 1\n-26 1\n88 2\n-22 2\n-98 2\n-83 1\n58 2\n26 2\n-37 1\n-51 2\n29 1\n47 2\n-70 1\n81 2\n36 1\n52 2\n93 2\n-12 2\n-12 1\n5 2\n91 1\n3 1\n-27 1\n18 1\n-60 1\n-15 1\n17 1\n-33 1\n-74 2\n5 2\n-62 2\n72 1\n-22 1\n-58 1\n-9 1\n57 1\n-18 2\n-11 1\n-103 2\n74 2\n-20 2\n21 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nReca company makes monitors, the most popular of their models is AB999 with the screen size a × b centimeters. Because of some production peculiarities a screen parameters are integer numbers. Recently the screen sides ra... | [{"type": "stdin_stdout", "input": "2000000000 2000000000 1999999998 1999999999\n", "output": "1999999998 1999999999"}, {"type": "stdin_stdout", "input": "2000000000 2000000000 1999999999 1999999998\n", "output": "1999999999 1999999998"}, {"type": "stdin_stdout", "input": "1688112099 1875662241 198852947 116042960\n", ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nRecall that the permutation is an array consisting of $n$ distinct integers from $1$ to $n$ in arbitrary order. For example, $[2,3,1,5,4]$ is a permutation, but $[1,2,2]$ is not a permutation ($2$ appears twice in the arr... | [{"type": "stdin_stdout", "input": "250000 993244853\n", "output": "872048421\n"}, {"type": "stdin_stdout", "input": "244435 994838543\n", "output": "634651929\n"}, {"type": "stdin_stdout", "input": "234324 994631069\n", "output": "720229385\n"}, {"type": "stdin_stdout", "input": "249996 997202249\n", "output": "633673... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThe Cybermen solved that first test much quicker than the Daleks. Luckily for us, the Daleks were angry (shocking!) and they destroyed some of the Cybermen.\n\nAfter the fighting stopped, Heidi gave them another task to w... | [{"type": "stdin_stdout", "input": "5 0\n2 1\n-2 -1\n-1 1\n-2 -2\n2 2\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "5 1\n1 1\n-1 -1\n-1 1\n-2 -2\n2 0\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "5 1\n2 1\n-1 -1\n-1 1\n-2 -2\n2 0\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "5 1\n2 1\n-... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nProgrammer Sasha has recently begun to study data structures. His coach Stas told him to solve the problem of finding a minimum on the segment of the array in <image>, which Sasha coped with. For Sasha not to think that h... | [{"type": "stdin_stdout", "input": "10 3\n-20\n-63\n-64\n45\n-84\n-13\n79\n-31\n70\n-100\n", "output": "-20\n45\n45\n45\n79\n79\n79\n70\n"}, {"type": "stdin_stdout", "input": "10 3\n-20\n-52\n-64\n45\n-139\n-13\n79\n-31\n89\n-100\n", "output": "-20\n45\n45\n45\n79\n79\n89\n89"}, {"type": "stdin_stdout", "input": "10 3\... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nDivision of Big Integers\n\nGiven two integers $A$ and $B$, compute the quotient, $\\frac{A}{B}$. Round down to the nearest decimal.\n\nInput\n\nTwo integers $A$ and $B$ separated by a space character are given in a line.... | [{"type": "stdin_stdout", "input": "12 -1", "output": "-12\n"}, {"type": "stdin_stdout", "input": "10 -1", "output": "-10\n"}, {"type": "stdin_stdout", "input": "20 -1", "output": "-20\n"}, {"type": "stdin_stdout", "input": "11 -1", "output": "-11\n"}, {"type": "stdin_stdout", "input": "15 -1", "output": "-15\n"}, {"ty... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nVasya has n items lying in a line. The items are consecutively numbered by numbers from 1 to n in such a way that the leftmost item has number 1, the rightmost item has number n. Each item has a weight, the i-th item weig... | [{"type": "stdin_stdout", "input": "2 100 100 10000 10000\n100 100\n", "output": "20000\n"}, {"type": "stdin_stdout", "input": "2 110 100 10000 10000\n100 100\n", "output": "21000\n"}, {"type": "stdin_stdout", "input": "2 110 100 10000 11101\n100 000\n", "output": "11000\n"}, {"type": "stdin_stdout", "input": "2 110 10... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nRng is going to a festival.\n\nThe name of the festival is given to you as a string S, which ends with `FESTIVAL`, from input. Answer the question: \"Rng is going to a festival of what?\" Output the answer.\n\nHere, assum... | [{"type": "stdin_stdout", "input": "CODEFESTIVALFERTIVAL", "output": "CODEFESTIVAL\n"}, {"type": "stdin_stdout", "input": "CODEFESTIWALFESTIWAL", "output": "CODEFESTIWAL\n"}, {"type": "stdin_stdout", "input": "LAWITSEFLAWITSEFEDOC", "output": "LAWITSEFLAWI\n"}, {"type": "stdin_stdout", "input": "CODEFWSTIWALFESTIEAL", ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nproblem\n\nI want to put as many rectangular tiles as possible on a rectangular wall with a size of $ h $ in height and $ w $ in width, and a size of $ a $ in height and $ b $ in width.\n\nThe following conditions must be... | [{"type": "stdin_stdout", "input": "87 15\n12 66", "output": "1305\n"}, {"type": "stdin_stdout", "input": "87 29\n12 66", "output": "2523\n"}, {"type": "stdin_stdout", "input": "27 27\n16 16", "output": "473\n"}, {"type": "stdin_stdout", "input": "27 32\n16 16", "output": "352\n"}, {"type": "stdin_stdout", "input": "-1... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given three integers $a$, $b$, and $c$. Determine if one of them is the sum of the other two.\n\n\n-----Input-----\n\nThe first line contains a single integer $t$ ($1 \\leq t \\leq 9261$) — the number of test case... | [{"type": "stdin_stdout", "input": "47\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAs you know, majority of students and teachers of Summer Informatics School live in Berland for the most part of the year. Since corruption there is quite widespread, the following story is not uncommon.\n\nElections are ... | [{"type": "stdin_stdout", "input": "10 10\n7 29\n10 31\n9 40\n5 17\n5 30\n6 85\n2 53\n7 23\n4 57\n10 9\n", "output": "49\n"}, {"type": "stdin_stdout", "input": "10 10\n5 81\n7 68\n7 48\n1 10\n5 37\n7 97\n8 54\n7 41\n7 56\n5 21\n", "output": "110\n"}, {"type": "stdin_stdout", "input": "10 10\n7 29\n10 54\n9 40\n5 17\n5 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given a rectangular board of M × N squares. Also you are given an unlimited number of standard domino pieces of 2 × 1 squares. You are allowed to rotate the pieces. You are asked to place as many dominoes as possi... | [{"type": "stdin_stdout", "input": "14 16\n", "output": "112\n"}, {"type": "stdin_stdout", "input": "15 16\n", "output": "120\n"}, {"type": "stdin_stdout", "input": "16 16\n", "output": "128\n"}, {"type": "stdin_stdout", "input": "14 15\n", "output": "105\n"}, {"type": "stdin_stdout", "input": "15 15\n", "output": "112... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nJack decides to invite Emma out for a dinner. Jack is a modest student, he doesn't want to go to an expensive restaurant. Emma is a girl with high taste, she prefers elite places.\n\nMunhattan consists of n streets and m ... | [{"type": "stdin_stdout", "input": "10 10\n256 72 455 45 912 506 235 68 951 92\n246 305 45 212 788 621 449 876 459 899\n732 107 230 357 370 610 997 669 61 192\n131 93 481 527 983 920 825 540 435 54\n777 682 984 20 337 480 264 137 249 502\n51 467 479 228 923 752 714 436 199 973\n3 91 612 571 631 212 751 84 886 948\n252 ... | 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\nToday there is going to be an unusual performance at the circus — hamsters and tigers will perform together! All of them stand in circle along the arena edge and now the trainer faces a difficult task: he wants to swap th... | [{"type": "stdin_stdout", "input": "178\nTTTTTTHTHHHTHHTHHHHTTTHTHTTHTHHHTHTTTTHHTTHHHTTHHTTHHTTHHHHHTHHTTHTHHTTHHTTTTTTTTTHTHTTHTHHTHHHHHHTTTHTHHHHTHHTTHHHHTTTTTTTTHHHTHHHTHTHHHTTTTTHTHTTTHTHHTTHTTTHHHHHTTHTTHTTTHTHHHT\n", "output": "40\n"}, {"type": "stdin_stdout", "input": "178\nTTTTTTHTHHHTHHTHHHHTTTHTHTTHTHHHTHTTT... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou need to find if a number can be expressed as sum of two perfect powers. That is, given x find if there exists non negative integers a, b, m, n such that a^m + b^n = x. \n\nInput\nFirst line of the input contains numbe... | [{"type": "stdin_stdout", "input": "20\n9783\n879497\n203664\n981484\n588099\n299151\n782262\n108971\n368524\n643461\n815444\n33663\n479878\n908619\n879890\n768921\n703812\n628957\n849817\n569957\n", "output": "Yes\nNo\nYes\nYes\nYes\nNo\nNo\nYes\nNo\nYes\nNo\nYes\nYes\nYes\nNo\nNo\nYes\nYes\nYes\nNo\n"}, {"type": "std... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nA smelt fishing tournament was held at Lake Hibara. The winner is the one who wins the most smelt.\n\nCreate a program that reads the list of participant numbers and the number of fish caught and outputs the number of win... | [{"type": "stdin_stdout", "input": "6\n1 14\n2 17\n3 131\n4 11\n4 61\n6 66", "output": "3 131\n"}, {"type": "stdin_stdout", "input": "6\n1 14\n2 25\n3 126\n4 11\n4 40\n6 66", "output": "3 126\n"}, {"type": "stdin_stdout", "input": "6\n1 14\n2 17\n3 169\n4 11\n4 61\n6 66", "output": "3 169\n"}, {"type": "stdin_stdout", ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou have a garden consisting entirely of grass and weeds. Your garden is described by an n × m grid, with rows numbered 1 to n from top to bottom, and columns 1 to m from left to right. Each cell is identified by a pair (... | [{"type": "stdin_stdout", "input": "3 150\nGGGWGGGGWWGGGGGGGGGGGGGWGGWGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGWGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGWGGGGGGGWGGGGGGGGGGGGGGGGGWGGGGGGGGGGGGGGGGGGW\nGGGGGGGGGGGGWGGGGGGGGGWGGGGGGGGGGGGWGGGGGWGGGGGGGWGGGGGGGWGGGGGWGGGGGGGGGGGGGGGGGGGGGGGGWGGGGWGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nSomething happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found tha... | [{"type": "stdin_stdout", "input": "100\n23 64 60 -45 -36 -64 -59 15 -75 69 -30 -7 -20 17 -77 58 93 -76 -121 -34 -31 16 -50 6 -20 -85 1 64 -88 -8 -15 -6 -57 25 91 10 2 -90 74 -66 -42 73 28 49 -85 30 96 79 -25 49 -59 -89 -75 14 -96 -33 -65 -8 -100 -81 17 99 -91 -5 7 -21 1 85 63 86 -26 85 -31 11 -75 35 -82 15 98 93 -55 2... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYour task is to calculate the distance between two $n$ dimensional vectors $x = \\\\{x_1, x_2, ..., x_n\\\\}$ and $y = \\\\{y_1, y_2, ..., y_n\\\\}$.\n\nThe Minkowski's distance defined below is a metric which is a genera... | [{"type": "stdin_stdout", "input": "3\n109 25 10\n-1 -3 -3", "output": "151.000000\n114.249726\n110.661278\n110.000000\n"}, {"type": "stdin_stdout", "input": "3\n109 25 10\n0 -3 -3", "output": "150.000000\n113.287246\n109.673356\n109.000000\n"}, {"type": "stdin_stdout", "input": "3\n109 25 10\n-1 -3 0", "output": "148.... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nLet's consider a simplified version of order book of some stock. The order book is a list of orders (offers) from people that want to buy or sell one unit of the stock, each order is described by direction (BUY or SELL) a... | [{"type": "stdin_stdout", "input": "15\nADD 14944938\nADD 40032655\nACCEPT 14944938\nACCEPT 40032655\nADD 79373162\nACCEPT 79373162\nADD 55424250\nACCEPT 55424250\nADD 67468892\nACCEPT 67468892\nADD 51815959\nADD 13976252\nADD 2040654\nADD 74300637\nACCEPT 51815959\n", "output": "32\n"}, {"type": "stdin_stdout", "input... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThe cat Snuke wants to play a popular Japanese game called ÅtCoder, so Iroha has decided to teach him Japanese.\nWhen counting pencils in Japanese, the counter word \"本\" follows the number. The pronunciation of this word... | [{"type": "stdin_stdout", "input": "183\n", "output": "bon\n"}, {"type": "stdin_stdout", "input": "999\n", "output": "hon\n"}, {"type": "stdin_stdout", "input": "440\n", "output": "pon\n"}, {"type": "stdin_stdout", "input": "438\n", "output": "pon\n"}, {"type": "stdin_stdout", "input": "575\n", "output": "hon\n"}, {"ty... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given a sequence $a$ consisting of $n$ integers $a_1, a_2, \\dots, a_n$, and an integer $x$. Your task is to make the sequence $a$ sorted (it is considered sorted if the condition $a_1 \\le a_2 \\le a_3 \\le \\dot... | [{"type": "stdin_stdout", "input": "6\n4 1\n2 3 5 4\n5 6\n1 1 3 4 4\n1 10\n2\n2 10\n11 9\n2 10\n12 11\n5 18\n81 324 218 413 324\n", "output": "\n3\n0\n0\n-1\n1\n3\n"}, {"type": "stdin_stdout", "input": "6\n4 1\n2 3 5 4\n5 6\n1 1 3 4 4\n1 10\n2\n2 10\n11 9\n2 10\n12 11\n5 18\n81 324 218 413 324\n", "output": "3\n0\n0\n-... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\n[Image] \n\nIt's the end of July – the time when a festive evening is held at Jelly Castle! Guests from all over the kingdom gather here to discuss new trends in the world of confectionery. Yet some of the things discusse... | [{"type": "stdin_stdout", "input": "433 3\nFZDDHMJGBZCHFUXBBPIEBBEFDWOMXXEPOMDGSMPIUZOMRZQNSJAVNATGIWPDFISKFQXJNVFXPHOZDAEZFDAHDXXQKZMGNSGKQNWGNGJGJZVVITKNFLVCPMZSDMCHBTVAWYVZLIXXIADXNYILEYNIQHKMOGMVOCWGHCWIYMPEPADSJAAKEGTUSEDWAHMNYJDIHBKHVUHLYGNGZDBULRXLSAJHPCMNWCEAAPYMHDTYWPADOTJTXTXUKLCHWKUSZRHEKQEFPVJEJJHRWCKYOIWAL... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nTo get money for a new aeonic blaster, ranger Qwerty decided to engage in trade for a while. He wants to buy some number of items (or probably not to buy anything at all) on one of the planets, and then sell the bought it... | [{"type": "stdin_stdout", "input": "5 10 15\nDdunkjly\n13 12 4\n83 26 1\n63 42 3\n83 22 2\n57 33 0\n59 10 1\n89 31 1\n57 17 2\n98 79 5\n46 41 3\nFbpbc\n28 21 0\n93 66 5\n66 21 0\n68 58 0\n59 17 3\n57 23 1\n72 71 1\n55 51 2\n58 40 5\n70 67 2\nKeiotmh\n73 44 4\n98 14 0\n19 7 0\n55 10 5\n30 25 4\n66 48 2\n66 51 4\n82 79 3... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given a table consisting of n rows and m columns.\n\nNumbers in each row form a permutation of integers from 1 to m.\n\nYou are allowed to pick two elements in one row and swap them, but no more than once for each... | [{"type": "stdin_stdout", "input": "20 8\n4 3 2 1 5 6 7 8\n1 2 3 4 8 7 6 5\n1 2 3 4 5 6 7 8\n1 2 3 4 5 6 7 8\n1 2 3 4 5 6 7 8\n1 2 3 4 5 6 7 8\n1 2 3 4 5 6 7 8\n1 2 3 4 5 6 7 8\n1 2 3 4 5 6 7 8\n1 2 3 4 5 6 7 8\n1 2 3 4 5 6 7 8\n1 2 3 4 5 6 7 8\n1 2 3 4 5 6 7 8\n1 2 3 4 5 6 7 8\n1 2 3 4 5 6 7 8\n1 2 3 4 5 6 7 8\n1 2 3 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou have an array $a_1, a_2, \\dots, a_n$. \n\nLet's call some subarray $a_l, a_{l + 1}, \\dots , a_r$ of this array a subpermutation if it contains all integers from $1$ to $r-l+1$ exactly once. For example, array $a = [... | [{"type": "stdin_stdout", "input": "99\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 9... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nJzzhu is the president of country A. There are n cities numbered from 1 to n in his country. City 1 is the capital of A. Also there are m roads connecting the cities. One can go from city ui to vi (and vise versa) using t... | [{"type": "stdin_stdout", "input": "3 3 6\n1 2 499999999\n2 3 500000000\n1 3 948187054\n2 499999999\n2 500000000\n2 499999999\n3 999999999\n3 1000000000\n3 1000000000\n", "output": "6\n"}, {"type": "stdin_stdout", "input": "3 3 6\n1 2 499999999\n2 3 500000000\n1 2 999999999\n2 499999999\n2 500000000\n2 499999999\n3 999... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nGiven a set of $N$ axis-aligned rectangular seals, find the number of overlapped seals on the region which has the maximum number of overlapped seals.\n\nConstraints\n\n* $ 1 \\leq N \\leq 100000 $\n* $ 0 \\leq x1_i < x2_... | [{"type": "stdin_stdout", "input": "3\n0 0 1 2\n0 0 2 2\n0 0 2 2", "output": "3\n"}, {"type": "stdin_stdout", "input": "3\n0 0 2 4\n0 0 2 2\n0 0 2 2", "output": "3\n"}, {"type": "stdin_stdout", "input": "3\n0 0 1 2\n0 0 2 3\n0 0 2 2", "output": "3\n"}, {"type": "stdin_stdout", "input": "3\n0 1 2 4\n0 0 2 2\n0 0 2 2", "... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given an array of integers $a_1, a_2, \\ldots, a_n$ and an integer $x$.\n\nYou need to select the maximum number of elements in the array, such that for every subsegment $a_l, a_{l + 1}, \\ldots, a_r$ containing s... | [{"type": "stdin_stdout", "input": "10\n3\n-54528 42942 -6804\n-54528\n3\n18649 67840 -26344\n43244\n3\n13902 51617 -4691\n32759\n3\n77397 -38549 -51828\n-45188\n3\n21750 -55472 -47700\n-55472\n3\n59264 11044 -311\n35154\n3\n-13132 88555 -52791\n-13132\n3\n-82155 25593 -3193\n-28281\n3\n-1405 586 77255\n586\n3\n30756 8... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nConsider an infinite triangle made up of layers. Let's number the layers, starting from one, from the top of the triangle (from top to bottom). The $k$-th layer of the triangle contains $k$ points, numbered from left to r... | [{"type": "stdin_stdout", "input": "4\n3\n1 10 2\n1 3 1\n2\n4 7\n2 2\n2\n1 1000000000\n1 1000000000\n4\n3 18 5 8\n2 4 2 4\n", "output": "3\n2\n999999999\n7\n"}, {"type": "stdin_stdout", "input": "4\n3\n1 10 2\n1 3 1\n2\n3 2\n2 2\n2\n1 1000000000\n1 1000000000\n4\n3 18 5 9\n2 4 2 4\n", "output": "3\n1\n999999999\n7\n"},... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nTakahashi Lake has a perimeter of L. On the circumference of the lake, there is a residence of the lake's owner, Takahashi. Each point on the circumference of the lake has a coordinate between 0 and L (including 0 but not... | [{"type": "stdin_stdout", "input": "314159265 7\n35438742\n77271666\n139044510\n156626166\n160332356\n331169608\n453863319", "output": "1023255587\n"}, {"type": "stdin_stdout", "input": "314159265 7\n35438742\n77271666\n122238627\n156626166\n160332356\n331169608\n453863319", "output": "1040061470\n"}, {"type": "stdin_s... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nRecently Vasya learned that, given two points with different x coordinates, you can draw through them exactly one parabola with equation of type y = x^2 + bx + c, where b and c are reals. Let's call such a parabola an U-s... | [{"type": "stdin_stdout", "input": "5\n1 0\n1 -1\n0 -1\n-1 0\n-1 -1\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "1\n-751115 -16747294\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "1\n-751115 -11499666\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "1\n-751115 -14990265\n", "output": "0\n... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nTakahashi received otoshidama (New Year's money gifts) from N of his relatives.\nYou are given N values x_1, x_2, ..., x_N and N strings u_1, u_2, ..., u_N as input. Each string u_i is either JPY or BTC, and x_i and u_i r... | [{"type": "stdin_stdout", "input": "10\n100.00000000 BTC\n100.00000000 BTC\n100.00000000 BTC\n100.00000000 BTC\n100.00000000 BTC\n100.00000000 BTC\n100.00000000 BTC\n100.00000000 BTC\n100.00000000 BTC\n100.00000000 BTC\n", "output": "380000000.0\n"}, {"type": "stdin_stdout", "input": "10\n22.49891780 BTC\n59.00375526 B... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nWrite a program which reads the two dices constructed in the same way as Dice I, and determines whether these two dices are identical. You can roll a dice in the same way as Dice I, and if all integers observed from the s... | [{"type": "stdin_stdout", "input": "-2 2 -3 -1 461 1\n3 0 4 0 13 -1", "output": "No\n"}, {"type": "stdin_stdout", "input": "-1 2 -3 -1 461 1\n3 0 4 0 13 -1", "output": "No\n"}, {"type": "stdin_stdout", "input": "-1 2 -3 -1 461 1\n3 0 6 0 13 -1", "output": "No\n"}, {"type": "stdin_stdout", "input": "-1 2 -3 -1 461 2\n3 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nLittle Artyom decided to study probability theory. He found a book with a lot of nice exercises and now wants you to help him with one of them.\n\nConsider two dices. When thrown each dice shows some integer from 1 to n i... | [{"type": "stdin_stdout", "input": "8\n0.09597231 0.11315755 0.32077119 0.22643005 0.03791746 0.04296694 0.10284494 0.05993956\n0.52402769 0.19814245 0.20452881 0.06686995 0.00468254 0.00103306 0.00055506 0.00016044\n", "output": "0.29869999999999886 0.07920000000000116 0.32760000000000133 0.0734999999999989 0.02229999... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nPolycarp has a checkered sheet of paper of size n × m. Polycarp painted some of cells with black, the others remained white. Inspired by Malevich's \"Black Square\", Polycarp wants to paint minimum possible number of whit... | [{"type": "stdin_stdout", "input": "20 10\nWWBWWWBBWW\nWWWWWBWWWW\nWWWWWWWWWW\nWWWWWWWWWW\nWWWBBBWWWW\nWWWWWWWWWW\nWWWWWWWWWW\nWWWWWWWWWW\nWBWWWWWBWW\nWBWWBWWWBW\nWWBWBWWWWW\nWWWBWWBBWW\nWWBBWBWBWW\nBBWWWWWBWW\nWWBWWBBBWW\nWWWBWBBWWW\nWWWBBWBWWW\nWWWWWWWWWW\nWWWBWWWWWW\nWWWWWWWWWW\n", "output": "-1\n"}, {"type": "stdin... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are playing a computer card game called Splay the Sire. Currently you are struggling to defeat the final boss of the game.\n\nThe boss battle consists of $n$ turns. During each turn, you will get several cards. Each c... | [{"type": "stdin_stdout", "input": "5\n3\n1 1\n1 1\n1 1\n3\n1 1\n1 1\n1 1\n3\n1 1\n1 1\n1 1\n3\n1 1\n1 1\n1 1\n3\n1 100\n1 1\n1 1\n", "output": "211\n"}, {"type": "stdin_stdout", "input": "5\n3\n1 1\n1 1\n1 1\n3\n1 1\n1 1\n1 1\n3\n1 1\n1 1\n1 1\n3\n1 1\n1 1\n1 1\n3\n1 100\n1 1\n1 1\n", "output": "211\n"}, {"type": "std... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nSereja is a coder and he likes to take part in Codesorfes rounds. However, Uzhland doesn't have good internet connection, so Sereja sometimes skips rounds.\n\nCodesorfes has rounds of two types: Div1 (for advanced coders)... | [{"type": "stdin_stdout", "input": "1122 54\n2 1031\n1 363 364\n1 14 15\n1 902 903\n1 1052 1053\n2 170\n2 36\n2 194\n1 340 341\n1 1018 1019\n1 670 671\n1 558 559\n2 431\n2 351\n2 201\n1 1104 1105\n2 1056\n2 823\n1 274 275\n2 980\n1 542 543\n1 807 808\n2 157\n2 895\n1 505 506\n2 658\n1 484 485\n1 533 534\n1 384 385\n2 7... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThis problem is different from the hard version. In this version Ujan makes exactly one exchange. You can hack this problem only if you solve both problems.\n\nAfter struggling and failing many times, Ujan decided to try ... | [{"type": "stdin_stdout", "input": "10\n11\nartiovnldnp\nartiovsldsp\n2\naa\nzz\n2\naa\nxy\n2\nab\nba\n2\nza\nzz\n3\nabc\nbca\n16\naajjhdsjfdsfkadf\naajjhjsjfdsfkajf\n2\nix\nii\n2\noo\nqo\n2\npp\npa\n", "output": "Yes\nYes\nNo\nNo\nNo\nNo\nYes\nNo\nNo\nNo\n"}, {"type": "stdin_stdout", "input": "10\n11\nartiovnldnp\nart... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given a permutation $p_1, p_2, \\ldots, p_n$ of integers from $1$ to $n$ and an integer $k$, such that $1 \\leq k \\leq n$. A permutation means that every number from $1$ to $n$ is contained in $p$ exactly once.\n... | [{"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\nDima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework.\n\nThe teacher gave Seryo... | [{"type": "stdin_stdout", "input": "50\n384672 661179 -775591 -989608 611120 442691 601796 502406 384323 -315945 -934146 873993 -156910 -94123 -930137 208544 816236 466922 473696 463604 794454 -872433 -149791 -858684 -467655 -555239 623978 -217138 -408658 493342 -733576 -350871 711210 884148 -426172 519986 -356885 5271... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given an array a consisting of n positive integers. You pick two integer numbers l and r from 1 to n, inclusive (numbers are picked randomly, equiprobably and independently). If l > r, then you swap values of l an... | [{"type": "stdin_stdout", "input": "20\n49 33 9 8 50 21 12 44 23 39 24 10 17 4 17 40 24 19 27 21\n", "output": "7.010000\n"}, {"type": "stdin_stdout", "input": "20\n128 33 9 1 50 37 12 44 26 69 24 10 17 4 17 41 11 26 10 14\n", "output": "7.005\n"}, {"type": "stdin_stdout", "input": "20\n49 33 9 8 50 21 12 44 23 39 24 1... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nNatasha's favourite numbers are $n$ and $1$, and Sasha's favourite numbers are $m$ and $-1$. One day Natasha and Sasha met and wrote down every possible array of length $n+m$ such that some $n$ of its elements are equal t... | [{"type": "stdin_stdout", "input": "2000 2000\n", "output": "674532367\n"}, {"type": "stdin_stdout", "input": "1134 1092\n", "output": "134680101\n"}, {"type": "stdin_stdout", "input": "1087 1050\n", "output": "973930225\n"}, {"type": "stdin_stdout", "input": "1994 1981\n", "output": "596939902\n"}, {"type": "stdin_std... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nWelcome to Innopolis city. Throughout the whole year, Innopolis citizens suffer from everlasting city construction. \n\nFrom the window in your room, you see the sequence of n hills, where i-th of them has height a_{i}. T... | [{"type": "stdin_stdout", "input": "100\n1777 339 1249 1644 785 810 228 549 1892 464 1067 639 65 1653 981 1858 863 1980 1174 427 1710 345 309 826 31 1898 255 661 1836 443 802 195 177 752 979 1842 1689 399 568 1906 129 1571 1263 696 911 810 1877 1932 1389 1128 112 619 184 434 22 1269 386 324 1635 1440 705 300 455 1635 1... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nMad scientist Mike is busy carrying out experiments in chemistry. Today he will attempt to join three atoms into one molecule.\n\nA molecule consists of atoms, with some pairs of atoms connected by atomic bonds. Each atom... | [{"type": "stdin_stdout", "input": "1000000 1000000 1000000\n", "output": "500000 500000 500000\n"}, {"type": "stdin_stdout", "input": "1000000 1000000 1000000\n", "output": "500000 500000 500000\n"}, {"type": "stdin_stdout", "input": "688348 726472 442198\n", "output": "486311 240161 202037\n"}, {"type": "stdin_stdout... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nA remote island chain contains n islands, labeled 1 through n. Bidirectional bridges connect the islands to form a simple cycle — a bridge connects islands 1 and 2, islands 2 and 3, and so on, and additionally a bridge co... | [{"type": "stdin_stdout", "input": "12\n0 1 2 3 4 5 6 7 8 9 10 11\n1 2 9 8 6 4 5 10 3 7 0 11\n1 2\n2 3\n3 4\n4 5\n4 6\n6 7\n3 8\n8 9\n9 10\n2 11\n11 12\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "12\n0 1 2 3 4 5 6 7 8 9 10 11\n1 2 9 8 6 4 5 10 3 7 0 11\n1 2\n2 3\n3 4\n4 5\n4 6\n6 7\n3 8\n8 9\n9 10\n8 11\n... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nOne day Polycarpus got hold of two non-empty strings s and t, consisting of lowercase Latin letters. Polycarpus is quite good with strings, so he immediately wondered, how many different pairs of \"x y\" are there, such t... | [{"type": "stdin_stdout", "input": "pfdempfohomnpgbeegikfmflnalbbajpnpgeacaicoehopgnabnklheepnlnflohjegcciflmfjhachnhekckfjgoffhkblncidn\nidlhklpclcghngeggpjdgefccihndpoikojdjnbkdfjgaanoolfmnifnmbpeeghpicehjdiipnlfnjpglidpnnnjfmjfhbcogojkcfflmmfcgajbjbfaikhmjofbnjnaolbcdkelcieeodbfjcfiblhhmeelmpcmmcdhjcnnfklgedjjbaljnd... | code_stdio |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.