messages
listlengths
1
1
ground_truth
stringlengths
156
726k
dataset
stringclasses
2 values
[ { "content": "AtCoder currently hosts three types of contests: ABC, ARC, and AGC. As the number of users has grown, in order to meet the needs of more users, AtCoder has decided to increase the number of contests to 26 types, from AAC to AZC. For convenience, we number these 26 types as type 1 through type 26. ...
[{"input": "5\n86 90 69 51 2 96 71 47 88 34 45 46 89 34 31 38 97 84 41 80 14 4 50 83 7 82\n19771 12979 18912 10432 10544 12928 13403 3047 10527 9740 8100 92 2856 14730 1396 15905 6534 4650 11469 3628 8433 2994 10899 16396 18355 11424\n6674 17707 13855 16407 12232 2886 11908 1705 5000 1537 10440 10711 4917 10770 17272 1...
code_stdio
[ { "content": "The 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 to the building.\n\nThe slogan of the company consists of n characters, so t...
[{"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\nLEFT\nLEFT\nLEFT\nLEFT...
code_stdio
[ { "content": "Tomash keeps wandering off and getting lost while he is walking along the streets of Berland. It's no surprise! In his home town, for any pair of intersections there is exactly one way to walk from one intersection to the other one. The capital of Berland is very different!\n\nTomash has noticed t...
[{"input": "8 56\n1 2\n1 3\n1 4\n1 5\n1 6\n1 7\n1 8\n2 1\n2 3\n2 4\n2 5\n2 6\n2 7\n2 8\n3 1\n3 2\n3 4\n3 5\n3 6\n3 7\n3 8\n4 1\n4 2\n4 3\n4 5\n4 6\n4 7\n4 8\n5 1\n5 2\n5 3\n5 4\n5 6\n5 7\n5 8\n6 1\n6 2\n6 3\n6 4\n6 5\n6 7\n6 8\n7 1\n7 2\n7 3\n7 4\n7 5\n7 6\n7 8\n8 1\n8 2\n8 3\n8 4\n8 5\n8 6\n8 7\n", "output": "840\n"},...
code_stdio
[ { "content": "Katie, 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 really loves pizza so she wants to invite her friends to the pizza restauran...
[{"input": "1000000000000000000\n", "output": "1000000000000000001\n"}, {"input": "1043714136496022950\n", "output": "1043714136496022951\n"}, {"input": "1837625121252532586\n", "output": "1837625121252532587\n"}, {"input": "1568485437674580780\n", "output": "1568485437674580781\n"}, {"input": "1000000000000010000\n", ...
code_stdio
[ { "content": "String can be called correct if it consists of characters \"0\" and \"1\" and there are no redundant leading zeroes. Here are some examples: \"0\", \"10\", \"1001\".\n\nYou are given a correct string s.\n\nYou can perform two different operations on this string: swap any pair of adjacent charact...
[{"input": "100\n1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "output": "1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n"}, {"input": "100\n10000000000000000000000000000000000000000000000000000000000000000...
code_stdio
[ { "content": "As you might know, cooking is the process of taking a food item and subjecting it to various processes(like heating, roasting, baking etc).\nA food item gets prepared after it has been subjected to exactly N processes.\nThe order in which the processes are applied matters(heating and then baking i...
[{"input": "3\n-2 2\n5 10\n1 11", "output": "2\n555841676\n110\n"}, {"input": "3\n-2 2\n4 15\n1 12", "output": "2\n286982263\n132\n"}, {"input": "3\n-16 2\n10 13\n1 6", "output": "2\n131267026\n30\n"}, {"input": "3\n-8 2\n10 13\n1 5", "output": "2\n131267026\n20\n"}, {"input": "3\n-16 2\n10 13\n1 3", "output": "2\n1312...
code_stdio
[ { "content": "Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. \n\nString p is called a substring of string s if you can read it starting from some position in the string s. For example, string \"aba\" has six substrings: \"a\", \"b\", \"a\", \"ab\", \"ba\", \"aba\".\n\nDr. Moriart...
[{"input": "ksmbytfyhhnstlecripupiwdhbkhfpfmimrbqgszohcqnezcybvwasxmkxfupvuecsctcpadccnqexsglwaiyxcoyheefcjmdedesgjqdtqgrvfjonzesffousooutsjumrxl\nhgjqihcfbnmgufonaiudbjegexexthrzcdkuimwogpbyovemztzcmqnrbhabxyyxyfuzpyhjgnioexbezzupcxlyzuuncstiiqsjzdtqppqhxilvqimlpjejiqbwpeekzweeyvthvjffgfvqauqrugajjjzibgzhxphcvtncjzecb...
code_stdio
[ { "content": "Calculate the number of items in a vector that appear at the same index in each vector, with the same value. \n\n```python\n vector_affinity([1, 2, 3, 4, 5], [1, 2, 2, 4, 3]) # => 0.6\n vector_affinity([1, 2, 3], [1, 2, 3]) # => 1.0\n```\n\nAffinity value should be realized on a scale of 0.0 t...
[{"input": "[6, 6, 6, 6, 6, 6]\n[6, null, null, 6, 6, null]", "output": "[0.5]", "fn_name": "vector_affinity"}, {"input": "[6]\n[6, 6, 6, 6, 6, 6]", "output": "[0.16666666666666666]", "fn_name": "vector_affinity"}, {"input": "[1, 2, 3, 4]\n[1, 2, 3, 5]", "output": "[0.75]", "fn_name": "vector_affinity"}, {"input": "[1,...
code_functional
[ { "content": "In order to put away old things and welcome a fresh new year, a thorough cleaning of the house is a must.\n\nLittle Tommy finds an old polynomial and cleaned it up by taking it modulo another. But now he regrets doing this...\n\nGiven two integers p and k, find a polynomial f(x) with non-negative ...
[{"input": "1000000000000000000 2\n", "output": "61\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 1 0 0 0 1 1 1 1 1 0 0 1 0 1 1 1 1 1 1 0 1 0 0 1 1 1 0 0 0 0 1 0 0 0 1 0 0 1 \n"}, {"input": "1000000000000000000 2\n", "output": "61\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 1 0 0 0 1 1 1 1 1 0 0 1 0 1 1 1 1 1 1 0 1...
code_stdio
[ { "content": "Stick n circular stickers with a radius of 1 on a square origami paper with a side length of 10. The stickers can be stacked. Create a program that reads the coordinates of the position where the stickers are to be attached and outputs the number of stickers at the place where the stickers overlap...
[{"input": "15\n3.13979,8.51743\n2.39506,3.84915\n2.68432,5.39095\n5.61904,9.16332\n7.85653,4.75593\n2.84021,5.41511\n1.79500,8.59211\n7.55389,8.17604\n4.70665,4.66125\n1.63470,4.42538\n7.34959,4.61981\n5.09003,8.11122\n5.24373,1.30066\n0.13517,1.83659\n7.57313,1.58150\n0", "output": "4\n"}, {"input": "15\n3.13979,8.51...
code_stdio
[ { "content": "This is the harder version of the problem. In this version, 1 ≤ n, m ≤ 2⋅10^5. You can hack this problem if you locked it. But you can hack the previous problem only if you locked both problems.\n\nYou are given a sequence of integers a=[a_1,a_2,...,a_n] of length n. Its subsequence is obtained by...
[{"input": "5\n3 1 4 1 2\n15\n5 5\n5 4\n5 3\n5 2\n5 1\n4 4\n4 3\n4 2\n4 1\n3 3\n3 2\n3 1\n2 2\n2 1\n1 1\n", "output": "2\n1\n4\n1\n3\n2\n4\n1\n3\n2\n4\n3\n4\n3\n4\n"}, {"input": "5\n3 1 4 1 2\n15\n5 5\n5 4\n5 3\n5 3\n5 1\n4 4\n4 3\n4 2\n4 1\n3 3\n3 2\n3 1\n2 2\n2 1\n1 1\n", "output": "2\n1\n4\n4\n3\n2\n4\n1\n3\n2\n4\n3...
code_stdio
[ { "content": "Recently, Anton has found a set. The set consists of small English letters. Anton carefully wrote out all the letters from the set in one line, separated by a comma. He also added an opening curved bracket at the beginning of the line and a closing curved bracket at the end of the line. \n\nUnfort...
[{"input": "{a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a}\n", "ou...
code_stdio
[ { "content": "Valera the horse lives on a plane. The Cartesian coordinate system is defined on this plane. Also an infinite spiral is painted on the plane. The spiral consists of segments: [(0, 0), (1, 0)], [(1, 0), (1, 1)], [(1, 1), ( - 1, 1)], [( - 1, 1), ( - 1, - 1)], [( - 1, - 1), (2, - 1)], [(2, - 1), ...
[{"input": "37 -100\n", "output": "400\n"}, {"input": "100 100\n", "output": "397\n"}, {"input": "-96 -96\n", "output": "383\n"}, {"input": "100 100\n", "output": "397\n"}, {"input": "37 -100\n", "output": "400\n"}, {"input": "-96 -96\n", "output": "383\n"}, {"input": "56 -100\n", "output": "400\n"}, {"input": "99 100\...
code_stdio
[ { "content": "In this Kata, you will implement a function `count` that takes an integer and returns the number of digits in `factorial(n)`. \n\nFor example, `count(5) = 3`, because `5! = 120`, and `120` has `3` digits. \n\nMore examples in the test cases. \n\nBrute force is not possible. A little research will...
[{"input": "50000000", "output": "[363233781]", "fn_name": "count"}, {"input": "5000000", "output": "[31323382]", "fn_name": "count"}, {"input": "500000", "output": "[2632342]", "fn_name": "count"}, {"input": "50000", "output": "[213237]", "fn_name": "count"}, {"input": "5000", "output": "[16326]", "fn_name": "count"},...
code_functional
[ { "content": "Polycarp loves geometric progressions — he collects them. However, as such progressions occur very rarely, he also loves the sequences of numbers where it is enough to delete a single element to get a geometric progression.\n\nIn this task we shall define geometric progressions as finite sequences...
[{"input": "10\n-10000 -10000 -10000 -10000 10000 -10000 -10000 -10000 -10000 10000\n", "output": "2\n"}, {"input": "10\n-10000 -10000 -10000 -10000 10000 -10000 -10000 -10000 -12453 10000\n", "output": "2\n"}, {"input": "14\n-1 -2 -4 -8 -16 -32 -64 -128 -256 -512 -1024 -2048 -4096 -8192\n", "output": "0\n"}, {"input":...
code_stdio
[ { "content": "In computer science, cycle detection is the algorithmic problem of finding a cycle in a sequence of iterated function values.\n\nFor any function ƒ, and any initial value x0 in S, the sequence of iterated function values\n\n x0,x1=f(x0), x2=f(x1), ...,xi=f(x{i-1}),...\n\nmay eventually use the ...
[{"input": "[1, 1, 1, 1, 1, 1, 1, 1]", "output": "[[0, 1]]", "fn_name": "cycle"}, {"input": "[1, 2, 3, 4, 2, 3, 4]", "output": "[[1, 3]]", "fn_name": "cycle"}, {"input": "[2, 3, 4, 2, 3, 4]", "output": "[[0, 3]]", "fn_name": "cycle"}, {"input": "[1, 2, 3, 4]", "output": "[[]]", "fn_name": "cycle"}, {"input": "[7]", "ou...
code_functional
[ { "content": "Create a program to determine the positional relationship between a triangle and a circle on a plane. All target figures shall include boundaries. The triangle is given the position of three vertices, and the circle is given the position of the center and the radius. The position is given by a set...
[{"input": "1 1\n6 0\n3 3\n3 0\n3\n3 11\n1 3\n11 16\n12 4\n5\n15 4\n17 12\n22 5\n7 22\n3\n5 13\n16 2\n16 9\n5 3\n1\n0 0", "output": "b\nd\nd\nd\n"}, {"input": "1 1\n6 0\n3 3\n3 2\n3\n3 11\n1 3\n11 16\n12 7\n5\n15 3\n17 7\n22 5\n7 12\n4\n5 13\n13 2\n16 9\n5 3\n2\n0 0", "output": "c\nd\nd\nd\n"}, {"input": "3 2\n3 1\n3 3...
code_stdio
[ { "content": "This problem is an extension of the problem \"Wonderful Coloring - 1\". It has quite many differences, so you should read this statement completely.\n\nRecently, Paul and Mary have found a new favorite sequence of integers $a_1, a_2, \\dots, a_n$. They want to paint it using pieces of chalk of $k$...
[{"input": "12\n10 3\n3 1 1 1 1 3 3 10 10 2\n4 4\n1 1 1 2\n1 1\n1\n13 1\n5 1 4 1 5 9 2 11 1 3 5 8 9\n13 2\n3 1 4 1 5 9 2 6 5 3 4 7 9\n13 3\n3 1 4 1 5 9 2 6 5 3 5 8 9\n10 3\n3 1 1 1 1 10 3 10 10 2\n4 4\n1 1 1 1\n1 1\n1\n13 1\n5 1 4 1 10 9 2 11 5 3 5 8 9\n13 2\n3 1 4 1 5 9 2 6 5 3 5 8 9\n13 3\n3 1 4 1 5 9 2 8 5 3 5 8 9\n...
code_stdio
[ { "content": "I always thought that my old friend John was rather richer than he looked, but I never knew exactly how much money he actually had. One day (as I was plying him with questions) he said:\n\n* \"Imagine I have between `m` and `n` Zloty...\" (or did he say Quetzal? I can't remember!)\n* \"If I were t...
[{"input": "0\n200", "output": "[[[\"M: 37\", \"B: 5\", \"C: 4\"], [\"M: 100\", \"B: 14\", \"C: 11\"], [\"M: 163\", \"B: 23\", \"C: 18\"]]]", "fn_name": "howmuch"}, {"input": "20000\n20100", "output": "[[[\"M: 20008\", \"B: 2858\", \"C: 2223\"], [\"M: 20071\", \"B: 2867\", \"C: 2230\"]]]", "fn_name": "howmuch"}, {"inpu...
code_functional
[ { "content": "Berland annual chess tournament is coming!\n\nOrganizers have gathered 2·n chess players who should be divided into two teams with n people each. The first team is sponsored by BerOil and the second team is sponsored by BerMobile. Obviously, organizers should guarantee the win for the team of BerO...
[{"input": "100\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...
code_stdio
[ { "content": "The mobile application store has a new game called \"Subway Roller\".\n\nThe protagonist of the game Philip is located in one end of the tunnel and wants to get out of the other one. The tunnel is a rectangular field consisting of three rows and n columns. At the beginning of the game the hero is ...
[{"input": "1\n100 26\ns................PPPP.CCCCC..UUUUUU.........YYYQQQQQQQ...GGGGG............MMM.....JJJJ..............\n.OOOOOO....EEE....................................................SSSSSS........LLLLLL......NNNIIII.\n......FFFFFF...VVVV..ZZZBBB...KKKKK..WWWWWWWXXX..RRRRRRR......AAAAADDDDDDD.HHH............TTT...
code_stdio
[ { "content": "You are given names of two days of the week.\n\nPlease, determine whether it is possible that during some non-leap year the first day of some month was equal to the first day of the week you are given, while the first day of the next month was equal to the second day of the week you are given. Bot...
[{"input": "wednesday\nwednesday\n", "output": "YES\n"}, {"input": "wednesday\nwednesday\n", "output": "YES\n"}, {"input": "wednesday\nsaturday\n", "output": "YES\n"}, {"input": "wednesday\nsaturday\n", "output": "YES\n"}, {"input": "wednesday\nsaturday\n", "output": "YES\n"}, {"input": "wednesday\nthursday\n", "output...
code_stdio
[ { "content": "You are given three piles of casino chips: white, green and black chips:\n\n* the first pile contains only white chips\n* the second pile contains only green chips\n* the third pile contains only black chips\n\nEach day you take exactly two chips of different colors and head to the casino. You can...
[{"input": "[12, 12, 12]", "output": "[18]", "fn_name": "solve"}, {"input": "[7, 4, 10]", "output": "[10]", "fn_name": "solve"}, {"input": "[1, 23, 2]", "output": "[3]", "fn_name": "solve"}, {"input": "[1, 1, 1]", "output": "[1]", "fn_name": "solve"}, {"input": "[1, 2, 1]", "output": "[2]", "fn_name": "solve"}, {"input...
code_functional
[ { "content": "# It's too hot, and they can't even…\n\nOne hot summer day Pete and his friend Billy decided to buy watermelons. They chose the biggest crate. They rushed home, dying of thirst, and decided to divide their loot, however they faced a hard problem.\n\nPete and Billy are great fans of even numbers, t...
[{"input": "100", "output": "[true]", "fn_name": "divide"}, {"input": "67", "output": "[false]", "fn_name": "divide"}, {"input": "99", "output": "[false]", "fn_name": "divide"}, {"input": "2", "output": "[false]", "fn_name": "divide"}, {"input": "5", "output": "[false]", "fn_name": "divide"}, {"input": "88", "output": ...
code_functional
[ { "content": "Mr. A came to Aizu for sightseeing. You can overlook the Aizu Basin from the window of the hotel where you stayed. As I was looking at the scenery, I noticed a piece of the photo on the floor. Apparently I took the outside view from the window. \"Which area did you take?\" A asked, holding the pho...
[{"input": "8 4\n2 1 3 1 1 5 1 3\n2 3 2 4 1 0 2 1\n0 3 -1 2 1 1 4 2\n1 2 3 2 1 1 5 4\n0 2 0 1 1 3 2 1\n1 3 1 2 2 4 3 2\n5 1 2 1 4 1 1 5\n4 1 1 -1 1 2 2 1\n2 -1 -1 -1\n0 3 -1 -1\n-1 2 2 4\n-1 1 -1 1\n5 3\n1 0 2 3 5\n2 3 7 2 1\n2 5 4 2 2\n8 9 0 3 3\n3 6 0 4 7\n-1 -1 2\n-1 3 5\n0 4 -1\n0 0", "output": "4 2\nNA\n"}, {"inp...
code_stdio
[ { "content": "There are N strings of lowercase alphabet only. The i-th string is S_i. Every string is unique.\n\nProvide answers for the Q queries below. The i-th query has the following format:\n\nQuery: An integer k_i and a string p_{i,1}p_{i,2}...p_{i,26} that results from permuting {`a`,`b`,...,`z`} are giv...
[{"input": "8\nabrakatabra\nabadaba\nabracadabra\natcoder\ngrand\ncontest\nababa\na\n6\n3 abcdefghijklmnopqrstuvwxyz\n6 qwertyuiopasdfhgjklzxcvbnm\n8 poiuytrewqlkjhgfdsamnbvcxz\n2 qazwsxedcrfvtgbyhnujmikolp\n1 plokmijnuhbygvtfcrdxeszwaq\n4 mnbvcxzasdfghjklpoiuytrewq", "output": "4\n8\n2\n3\n4\n7\n"}, {"input": "8\nabra...
code_stdio
[ { "content": "To become a millionaire, M-kun has decided to make money by trading in the next N days. Currently, he has 1000 yen and no stocks - only one kind of stock is issued in the country where he lives.\n\nHe is famous across the country for his ability to foresee the future. He already knows that the pri...
[{"input": "7\n100 130 243 130 115 115 150", "output": "3165\n"}, {"input": "7\n100 130 243 130 115 115 271", "output": "5706\n"}, {"input": "7\n110 130 243 130 115 115 271", "output": "5161\n"}, {"input": "7\n110 130 136 130 115 115 271", "output": "2794\n"}, {"input": "7\n100 130 130 130 11 115 150", "output": "17702...
code_stdio
[ { "content": "Takahashi loves the number 7 and multiples of K.\nWhere is the first occurrence of a multiple of K in the sequence 7,77,777,\\ldots? (Also see Output and Sample Input/Output below.)\nIf the sequence contains no multiples of K, print -1 instead.\n\n-----Constraints-----\n - 1 \\leq K \\leq 10^6\n -...
[{"input": "999983\n", "output": "999982\n"}, {"input": "999863\n", "output": "999862\n"}, {"input": "999953\n", "output": "999952\n"}, {"input": "531441\n", "output": "531441\n"}, {"input": "823543\n", "output": "100842\n"}, {"input": "823543\n", "output": "100842\n"}, {"input": "224593\n", "output": "111194\n"}, {"in...
code_stdio
[ { "content": "Little penguin Polo adores strings. But most of all he adores strings of length n.\n\nOne day he wanted to find a string that meets the following conditions: The string consists of n lowercase English letters (that is, the string's length equals n), exactly k of these letters are distinct. No tw...
[{"input": "93563 25\n", "output": "abababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababab...
code_stdio
[ { "content": "Little girl Tanya climbs the stairs inside a multi-storey building. Every time Tanya climbs a stairway, she starts counting steps from $1$ to the number of steps in this stairway. She speaks every number aloud. For example, if she climbs two stairways, the first of which contains $3$ steps, and th...
[{"input": "48\n1 2 3 4 1 2 3 1 1 2 3 1 2 3 4 1 1 2 3 4 1 2 3 4 1 2 3 4 1 1 1 1 2 1 2 1 1 2 1 2 1 2 3 1 1 1 2 1\n", "output": "22\n4 3 1 3 4 1 4 4 4 1 1 1 2 2 1 2 2 3 1 1 2 1 "}, {"input": "48\n1 2 3 4 1 2 3 1 1 2 1 1 2 3 4 1 1 2 3 4 1 2 3 4 1 2 3 4 1 1 2 1 2 1 2 1 1 1 1 2 1 2 3 1 2 1 2 1\n", "output": "22\n4 3 1 2 1 4...
code_stdio
[ { "content": "Given are two strings s and t consisting of lowercase English letters. Determine if the number of non-negative integers i satisfying the following condition is finite, and find the maximum value of such i if the number is finite.\n - There exists a non-negative integer j such that the concatenatio...
[{"input": "aa\naaaaaaa\n", "output": "-1\n"}, {"input": "abcabab\nab\n", "output": "3\n"}, {"input": "aba\nbaaab\n", "output": "0\n"}, {"input": "aa\naaaaaaa", "output": "-1"}, {"input": "aa\nabaaaaa", "output": "0"}, {"input": "abcaabb\nab", "output": "1"}, {"input": "aa\naaaaaba", "output": "0"}, {"input": "accaabb\...
code_stdio
[ { "content": "Read problems statements in Mandarin Chinese and Russian as well. \n\nChef wants to implement wildcard pattern matching supporting only the wildcard '?'. The wildcard character '?' can be substituted by any single lower case English letter for matching. He has two strings X and Y of equal length, ...
[{"input": "2\ns?o?r\nsco??\nstor?\nsco??", "output": "Yes\nNo\n"}, {"input": "2\ns?or?\nsco??\nstor?\nsco??", "output": "Yes\nNo\n"}, {"input": "2\ns?or?\nsco??\nstor?\nsco??", "output": "Yes\nNo"}, {"input": "2\nr?o?s\nsco??\nstor?\nsco??", "output": "No\nNo\n"}, {"input": "2\nr?o?s\nsco??\n?rots\nsco??", "output": "...
code_stdio
[ { "content": "Your friend recently came up with a card game called UT-Rummy.\n\nThe cards used in this game are numbered red, green, or blue and any number from 1 to 9. Each player in this game has 9 cards in his or her hand, chooses one from his or her hand, discards it, and draws one from the deck instead. In...
[{"input": "5\n1 2 3 6 4 5 7 13 7\nR R R R R R G G G\n1 2 2 3 4 4 4 4 5\nR R R R R Q R R R\n1 3 3 4 4 4 5 5 5\nR R B R R R R R R\n1 1 1 3 4 5 6 6 10\nR R B G G G R R S\n2 2 2 3 3 3 1 1 2\nR G B R G B R G B", "output": "0\n0\n0\n0\n0\n"}, {"input": "5\n1 2 3 6 4 5 7 13 7\nR R R R R R G G G\n1 2 2 3 4 4 4 4 5\nQ R R R R ...
code_stdio
[ { "content": "Dwarfs have planted a very interesting plant, which is a triangle directed \"upwards\". This plant has an amusing feature. After one year a triangle plant directed \"upwards\" divides into four triangle plants: three of them will point \"upwards\" and one will point \"downwards\". After another ye...
[{"input": "1000000000000000000\n", "output": "899770636\n"}, {"input": "1221245149414588849\n", "output": "459720998\n"}, {"input": "1033757552205836488\n", "output": "556130197\n"}, {"input": "1365148398628465905\n", "output": "906250341\n"}, {"input": "1000000000001000000\n", "output": "351480341\n"}, {"input": "115...
code_stdio
[ { "content": "You are given an array $a$ consisting of $n$ integers. Indices of the array start from zero (i. e. the first element is $a_0$, the second one is $a_1$, and so on).\n\nYou can reverse at most one subarray (continuous subsegment) of this array. Recall that the subarray of $a$ with borders $l$ and $r...
[{"input": "4\n8\n1 3 3 4 11 6 2 9\n5\n1 2 1 2 1\n10\n5 13 6 5 14 0 4 9 13 5\n4\n0 1 2 1\n", "output": "24\n5\n50\n3\n"}, {"input": "4\n8\n0 4 3 6 11 6 2 9\n5\n1 2 1 2 1\n10\n5 13 6 5 14 0 4 9 13 5\n4\n0 1 2 1\n", "output": "25\n5\n50\n3\n"}, {"input": "4\n8\n1 3 3 6 11 6 2 9\n5\n1 2 1 2 1\n10\n5 13 6 5 14 0 4 9 13 5\n...
code_stdio
[ { "content": "You are given a directed acyclic graph, consisting of $n$ vertices and $m$ edges. The vertices are numbered from $1$ to $n$. There are no multiple edges and self-loops.\n\nLet $\\mathit{in}_v$ be the number of incoming edges (indegree) and $\\mathit{out}_v$ be the number of outgoing edges (outdegr...
[{"input": "10 45\n3 8\n3 7\n3 5\n3 2\n3 1\n3 4\n3 10\n3 6\n3 9\n8 7\n8 5\n8 2\n8 1\n8 4\n8 10\n8 6\n8 9\n7 5\n7 2\n7 1\n7 4\n7 10\n7 6\n7 9\n5 2\n5 1\n5 4\n5 10\n5 6\n5 9\n2 1\n2 4\n2 10\n2 6\n2 9\n1 4\n1 10\n1 6\n1 9\n4 10\n4 6\n4 9\n10 6\n10 9\n6 9\n", "output": "8\n"}, {"input": "200000 12\n137434 3309\n195674 1635...
code_stdio
[ { "content": "Kuro and Shiro are playing with a board composed of n squares lining up in a row.\nThe squares are numbered 1 to n from left to right, and Square s has a mark on it.\nFirst, for each square, Kuro paints it black or white with equal probability, independently from other squares. Then, he puts on Sq...
[{"input": "7775\n", "output": "499126064\n499126064\n796234435\n114971967\n891826170\n38460928\n746758804\n102098624\n582205169\n762199467\n509915249\n602954502\n392594249\n215817236\n170876474\n643293880\n150463555\n628074695\n355316779\n513918741\n157394975\n757039573\n277888730\n825789360\n896475652\n681510732\n825...
code_stdio
[ { "content": "Example\n\nInput\n\n3\ny 7\ny 6\nn 5\n\n\nOutput\n\n1\n\nWrite Python code to solve this problem. Your program should read the input from stdin and write the output to stdout. Enclose your complete solution in a single ```python code block.", "role": "user" } ]
[{"input": "3\ny 11\ny 3\nn 10", "output": "1\n"}, {"input": "3\ny 11\nx 3\nn 10", "output": "1\n"}, {"input": "3\nx 2\ny 10\nn 10", "output": "1\n"}, {"input": "3\ny 11\nw 3\nn 10", "output": "1\n"}, {"input": "3\nx 0\ny 10\nn 10", "output": "1\n"}, {"input": "3\ny 0\ny 10\nn 10", "output": "1\n"}, {"input": "3\ny 11\...
code_stdio
[ { "content": "A bow adorned with nameless flowers that bears the earnest hopes of an equally nameless person.\n\nYou have obtained the elegant bow known as the Windblume Ode. Inscribed in the weapon is an array of n (n ≥ 3) positive distinct integers (i.e. different, no duplicates are allowed).\n\nFind the larg...
[{"input": "4\n3\n8 0 2\n4\n6 9 7 2\n9\n1 2 3 4 5 1 7 8 9\n3\n39 242 165\n", "output": "3\n1 2 3\n4\n1 2 3 4\n9\n1 2 3 4 5 6 7 8 9\n3\n1 2 3\n"}, {"input": "4\n3\n8 1 2\n4\n6 9 4 6\n9\n1 2 3 4 5 1 7 8 13\n3\n200 199 198\n", "output": "2\n1 3\n4\n1 2 3 4\n9\n1 2 3 4 5 6 7 8 9\n3\n1 2 3\n"}, {"input": "4\n3\n8 1 2\n4\n6 ...
code_stdio
[ { "content": "Fukushima Prefecture is also famous for producing fruits, and among them, peaches and apples boast one of the highest production volumes in Japan. By the way, when I made a print manuscript of an English pamphlet for sale, I mistakenly wrote the description about apples and the description about p...
[{"input": "the cost of one peach is higher than th`t of one apple.", "output": "the cost of one apple is higher than th`t of one peach.\n"}, {"input": "the cost of ooe peach is higher than th`t of one apple.", "output": "the cost of ooe apple is higher than th`t of one peach.\n"}, {"input": "the cost of ooe peach is h...
code_stdio
[ { "content": "Akaki, a patissier, can make N kinds of doughnut using only a certain powder called \"Okashi no Moto\" (literally \"material of pastry\", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she ne...
[{"input": "5 3000\n150\n130\n150\n130\n110\n", "output": "26\n"}, {"input": "5 3000\n150\n130\n150\n130\n100", "output": "28\n"}, {"input": "5 3000\n236\n130\n150\n130\n100", "output": "27\n"}, {"input": "5 3000\n150\n173\n150\n212\n101", "output": "26\n"}, {"input": "5 3000\n50\n130\n150\n130\n100", "output": "53\n"}...
code_stdio
[ { "content": "Let's pretend your company just hired your friend from college and paid you a referral bonus. Awesome! To celebrate, you're taking your team out to the terrible dive bar next door and using the referral bonus to buy, and build, the largest three-dimensional beer can pyramid you can. And then proba...
[{"input": "21\n1.5", "output": "[3]", "fn_name": "beeramid"}, {"input": "454\n5", "output": "[5]", "fn_name": "beeramid"}, {"input": "455\n5", "output": "[6]", "fn_name": "beeramid"}, {"input": "10\n2", "output": "[2]", "fn_name": "beeramid"}, {"input": "11\n2", "output": "[2]", "fn_name": "beeramid"}, {"input": "-1\n...
code_functional
[ { "content": "# Your Task\nThe city of Darkishland has a strange hotel with infinite rooms. The groups that come to this hotel follow the following rules:\n\n* At the same time only members of one group can rent the hotel.\n\n* Each group comes in the morning of the check-in day and leaves the hotel in the even...
[{"input": "10\n900000000000000000", "output": "[1341640786]", "fn_name": "group_size"}, {"input": "10000\n1000000000000000", "output": "[44721361]", "fn_name": "group_size"}, {"input": "2\n20000000000000", "output": "[6324555]", "fn_name": "group_size"}, {"input": "234234\n6577", "output": "[234234]", "fn_name": "grou...
code_functional
[ { "content": "You are given an array $a$ consisting of $n$ positive integers.\n\nYou are allowed to perform this operation any number of times (possibly, zero):\n\nchoose an index $i$ ($2 \\le i \\le n$), and change $a_i$ to $a_i - a_{i-1}$.\n\nIs it possible to make $a_i=0$ for all $2\\le i\\le n$?\n\n\n-----I...
[{"input": "1\n100\n1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2\n", "output": "YES\n"}, {"input": "10\n2\n1 1\n10\n1 2 3 4 5 6 7 8 9 10\n2\n1000000000 1\n2\n1000000...
code_stdio
[ { "content": "A [Mersenne prime](https://en.wikipedia.org/wiki/Mersenne_prime) is a prime number that can be represented as:\nMn = 2^(n) - 1. Therefore, every Mersenne prime is one less than a power of two. \n\nWrite a function that will return whether the given integer `n` will produce a Mersenne prime or not....
[{"input": "221", "output": "[false]", "fn_name": "valid_mersenne"}, {"input": "1279", "output": "[true]", "fn_name": "valid_mersenne"}, {"input": "11", "output": "[false]", "fn_name": "valid_mersenne"}, {"input": "21", "output": "[false]", "fn_name": "valid_mersenne"}, {"input": "23", "output": "[false]", "fn_name": "...
code_functional
[ { "content": "In a new version of the famous Pinball game, one of the most important parts of the game field is a sequence of n bumpers. The bumpers are numbered with integers from 1 to n from left to right. There are two types of bumpers. They are denoted by the characters '<' and '>'. When the ball hits the b...
[{"input": "100\n<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n", "output": "100\n"}, {"input": "100\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n", "output": "100\n"}, {"input": "100\n<<<<<<<<<<<<<<<<<<<<<...
code_stdio
[ { "content": "You are given two integers a and b. In one turn, you can do one of the following operations: \n\n * Take an integer c (c > 1 and a should be divisible by c) and replace a with a/c; \n * Take an integer c (c > 1 and b should be divisible by c) and replace b with b/c. \n\n\n\nYour goal is to make ...
[{"input": "8\n36 48 2\n36 48 3\n36 48 4\n2 8 1\n2 8 2\n1000000000 1000000000 1000000000\n1 2 1\n2 2 2\n", "output": "YES\nYES\nYES\nYES\nYES\nNO\nYES\nYES\n"}, {"input": "8\n36 48 2\n36 48 3\n36 48 4\n2 8 1\n2 8 2\n1000000000 1000000000 1000100000\n1 2 1\n2 1 1\n", "output": "YES\nYES\nYES\nYES\nYES\nNO\nYES\nYES\n"},...
code_stdio
[ { "content": "Kuro has recently won the \"Most intelligent cat ever\" contest. The three friends then decided to go to Katie's home to celebrate Kuro's winning. After a big meal, they took a small break then started playing games.\n\nKuro challenged Katie to create a game with only a white paper, a pencil, a pa...
[{"input": "50 1\n-1 -1 -1 -1 -1 0 -1 -1 -1 0 1 0 -1 0 1 -1 -1 -1 1 0 1 -1 0 1 0 1 0 0 1 1 -1 1 -1 -1 1 1 -1 -1 0 -1 -1 1 -1 1 -1 1 1 0 0 -1\n", "output": "279519499\n"}, {"input": "50 1\n-1 -1 -1 -1 -1 0 -1 -1 -1 0 1 0 -1 0 1 -1 -1 -1 1 0 1 -1 0 1 0 1 0 0 0 1 -1 1 -1 -1 1 1 -1 -1 0 -1 -1 1 -1 1 -1 1 1 0 0 -1\n", "outp...
code_stdio
[ { "content": "Valera has array a, consisting of n integers a_0, a_1, ..., a_{n} - 1, and function f(x), taking an integer from 0 to 2^{n} - 1 as its single argument. Value f(x) is calculated by formula $f(x) = \\sum_{i = 0}^{n - 1} a_{i} \\cdot b i t(i)$, where value bit(i) equals one if the binary representati...
[{"input": "43\n761 2165 6131 8874 8980 119 8300 9006 6278 7582 4740 6321 10042 6869 3788 17625 1707 5070 3809 335 2494 8255 1123 1430 190 5712 7313 3286 15423 133 1032 3067 8043 5297 5398 12168 13897 2141 1436 10227 362 8438 2300\n0111011100100011110010011110011011010001101\n", "output": "235367\n"}, {"input": "43\n76...
code_stdio
[ { "content": "AtCoDeer is thinking of painting an infinite two-dimensional grid in a checked pattern of side K.\nHere, a checked pattern of side K is a pattern where each square is painted black or white so that each connected component of each color is a K × K square.\nBelow is an example of a checked pattern ...
[{"input": "6 2\n1 2 B\n2 1 W\n2 2 B\n1 0 B\n0 6 W\n4 5 W\n", "output": "4\n"}, {"input": "6 2\n0 2 B\n2 1 W\n0 2 B\n1 0 B\n0 6 W\n-1 5 W", "output": "4\n"}, {"input": "3 2\n0 2 B\n2 1 W\n0 2 B\n1 0 B\n0 6 W\n-1 5 W", "output": "3\n"}, {"input": "6 2\n1 2 B\n2 1 W\n0 2 B\n1 0 B\n0 6 W\n4 5 W", "output": "3\n"}, {"input...
code_stdio
[ { "content": "You are given a sequence of length N: A_1, A_2, ..., A_N.\nFor each integer i between 1 and N (inclusive), answer the following question:\n - Find the maximum value among the N-1 elements other than A_i in the sequence.\n\n-----Constraints-----\n - 2 \\leq N \\leq 200000\n - 1 \\leq A_i \\leq 2000...
[{"input": "2\n200000\n1\n", "output": "1\n200000\n"}, {"input": "3\n-1\n0\n13", "output": "13\n13\n0\n"}, {"input": "3\n-2\n0\n16", "output": "16\n16\n0\n"}, {"input": "3\n0\n1\n13", "output": "13\n13\n1\n"}, {"input": "3\n0\n1\n12", "output": "12\n12\n1\n"}, {"input": "3\n1\n2\n12", "output": "12\n12\n2\n"}, {"input"...
code_stdio
[ { "content": "We arrange the numbers between 1 and N (1 <= N <= 10000) in increasing order and decreasing order like this:\n\n\n1 2 3 4 5 6 7 8 9 . . . N\nN . . . 9 8 7 6 5 4 3 2 1\n\n\nTwo numbers faced each other form a pair. Your task is to compute the number of pairs P such that both numbers in the pairs ar...
[{"input": "1\n10\n13\n373", "output": "0\n0\n3\n20\n"}, {"input": "1\n175\n19\n12", "output": "0\n14\n4\n2\n"}, {"input": "1\n175\n19\n16", "output": "0\n14\n4\n0\n"}, {"input": "1\n12\n7\n115", "output": "0\n2\n2\n12\n"}, {"input": "1\n12\n9\n115", "output": "0\n2\n3\n12\n"}, {"input": "1\n10\n7\n189", "output": "0\n...
code_stdio
[ { "content": "Given is a string S representing the day of the week today.\nS is SUN, MON, TUE, WED, THU, FRI, or SAT, for Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday, respectively.\nAfter how many days is the next Sunday (tomorrow or later)?\n\n-----Constraints-----\n - S is SUN, MON, TUE...
[{"input": "SAT\n", "output": "1\n"}, {"input": "SUN\n", "output": "7\n"}, {"input": "FRI\n", "output": "2\n"}, {"input": "MON\n", "output": "6\n"}, {"input": "THU\n", "output": "3\n"}, {"input": "TUE\n", "output": "5\n"}, {"input": "WED\n", "output": "4\n"}, {"input": "SUN", "output": "7"}, {"input": "SAT", "output": ...
code_stdio
[ { "content": "Given is a positive integer N.\nHow many tuples (A,B,C) of positive integers satisfy A \\times B + C = N?\n\n-----Constraints-----\n - 2 \\leq N \\leq 10^6\n - All values in input are integers.\n\n-----Input-----\nInput is given from Standard Input in the following format:\nN\n\n-----Output-----\...
[{"input": "1000000\n", "output": "13969985\n"}, {"input": "877046\n", "output": "12137262\n"}, {"input": "999931\n", "output": "13968881\n"}, {"input": "999901\n", "output": "13968459\n"}, {"input": "999927\n", "output": "13968843\n"}, {"input": "105008\n", "output": "1230314\n"}, {"input": "333589\n", "output": "4293...
code_stdio
[ { "content": "Polycarp loves lowercase letters and dislikes uppercase ones. Once he got a string s consisting only of lowercase and uppercase Latin letters.\n\nLet A be a set of positions in the string. Let's call it pretty if following conditions are met: letters on positions from A in the string are all dist...
[{"input": "200\nrsgraosldglhdoorwhkrsehjpuxrjuwgeanjgezhekprzarelduuaxdnspzjuooguuwnzkowkuhzduakdrzpnslauejhrrkalwpurpuuswdgeadlhjwzjgegwpknepazwwleulppwrlgrgedlwdzuodzropsrrkxusjnuzshdkjrxxpgzanzdrpnggdwxarpwohxdepJ\n", "output": "17\n"}, {"input": "200\nMkuxcDWdcnqsrlTsejehQKrTwoOBRCUAywqSnZkDLRmVBDVoOqdZHbrInQQyeRF...
code_stdio
[ { "content": "Vitaly is a very weird man. He's got two favorite digits a and b. Vitaly calls a positive integer good, if the decimal representation of this integer only contains digits a and b. Vitaly calls a good number excellent, if the sum of its digits is a good number.\n\nFor example, let's say that Vitaly...
[{"input": "3 6 1000000\n", "output": "786609214\n"}, {"input": "8 9 1000000\n", "output": "573697309\n"}, {"input": "1 2 1000000\n", "output": "786609214\n"}, {"input": "1 2 1000000\n", "output": "786609214\n"}, {"input": "8 9 1000000\n", "output": "573697309\n"}, {"input": "3 6 1000000\n", "output": "786609214\n"}, {...
code_stdio
[ { "content": "## Nova polynomial add\n\nThis kata is from a series on polynomial handling. ( [#1](http://www.codewars.com/kata/nova-polynomial-1-add-1) [#2](http://www.codewars.com/kata/570eb07e127ad107270005fe) [#3](http://www.codewars.com/kata/5714041e8807940ff3001140 ) [#4](http://www.codewars.com/kata/571a2...
[{"input": "[1, 2, 3, 4, 5, 6]\n[]", "output": "[[1, 2, 3, 4, 5, 6]]", "fn_name": "poly_add"}, {"input": "[]\n[1, 2, 3, 4, 5, 6]", "output": "[[1, 2, 3, 4, 5, 6]]", "fn_name": "poly_add"}, {"input": "[1, 2, 3, 4]\n[4, 3, 2, 1]", "output": "[[5, 5, 5, 5]]", "fn_name": "poly_add"}, {"input": "[1, 2]\n[1]", "output": "[[2...
code_functional
[ { "content": "Given are positive integers A and B.\nLet us choose some number of positive common divisors of A and B.\nHere, any two of the chosen divisors must be coprime.\nAt most, how many divisors can we choose?Definition of common divisor\nAn integer d is said to be a common divisor of integers x and y whe...
[{"input": "1000000000000 1000000000000\n", "output": "3\n"}, {"input": "642507465600 642507465600\n", "output": "10\n"}, {"input": "963761198400 963761198400\n", "output": "10\n"}, {"input": "200560490130 200560490130\n", "output": "12\n"}, {"input": "698726868840 271727115660\n", "output": "11\n"}, {"input": "2508779...
code_stdio
[ { "content": "Your program fails again. This time it gets \"Wrong answer on test 233\".\n\nThis is the easier version of the problem. In this version $1 \\le n \\le 2000$. You can hack this problem only if you solve and lock both problems.\n\nThe problem is about a test containing $n$ one-choice-questions. Each...
[{"input": "98 102\n79 30 51 48 80 91 32 16 39 54 79 17 48 24 8 66 9 94 45 14 85 82 54 89 44 92 26 62 47 5 75 33 102 24 63 39 91 31 33 55 81 63 81 87 26 19 41 108 46 56 91 97 67 30 94 81 40 5 22 8 23 34 5 77 43 66 67 15 7 154 26 22 19 71 26 82 69 52 40 4 98 27 63 74 68 74 55 75 25 51 18 100 22 66 50 38 43 43\n", "outpu...
code_stdio
[ { "content": "problem\n\nA mysterious $ X $ [cm] plant grows in one place. This plant has the following mysterious properties.\n\n* Say \"nobiro\" to this plant and it will grow $ A $ [cm].\n* Say \"tidime\" to this plant and it will grow $ B $ [cm].\n* If you say \"karero\" to this plant, it will be $ 0 $ [cm]...
[{"input": "109 30 5\n0\norioan\nnobiro\nuifimd", "output": "109\n"}, {"input": "112 30 9\n0\norioan\nniboro\ntieimd", "output": "112\n"}, {"input": "84 122 10\n0\noobrjn\nonciro\nudfimi", "output": "84\n"}, {"input": "17 122 12\n0\nnjrbop\nnndiro\nudfimi", "output": "17\n"}, {"input": "20 122 12\n0\nnjrbop\nnndiro\nud...
code_stdio
[ { "content": "Nick's company employed n people. Now Nick needs to build a tree hierarchy of «supervisor-surbodinate» relations in the company (this is to say that each employee, except one, has exactly one supervisor). There are m applications written in the following form: «employee ai is ready to become a sup...
[{"input": "7\n10 0 4 7 3 8 6\n10\n3 2 4\n6 4 3\n6 5 1\n1 2 1\n6 7 6\n7 3 9\n1 6 3\n3 2 1\n6 4 4\n1 4 4\n", "output": "23\n"}, {"input": "7\n10 0 4 7 3 8 6\n10\n3 2 4\n6 4 3\n6 5 1\n1 2 1\n6 7 6\n7 3 9\n1 6 3\n3 2 1\n6 4 7\n1 4 4\n", "output": "23\n"}, {"input": "6\n10 2 4 3 1 6\n10\n1 4 10\n1 6 9\n6 4 1\n4 2 5\n4 5 7\...
code_stdio
[ { "content": "There are $b$ boys and $g$ girls participating in Olympiad of Metropolises. There will be a board games tournament in the evening and $n$ participants have accepted the invitation. The organizers do not know how many boys and girls are among them.\n\nOrganizers are preparing red badges for girls a...
[{"input": "100\n200\n150\n", "output": "101\n"}, {"input": "300\n299\n300\n", "output": "300\n"}, {"input": "199\n199\n199\n", "output": "200\n"}, {"input": "297\n297\n298\n", "output": "297\n"}, {"input": "299\n259\n300\n", "output": "259\n"}, {"input": "288\n188\n300\n", "output": "177\n"}, {"input": "300\n299\n300\...
code_stdio
[ { "content": "Alice and Bob begin their day with a quick game. They first choose a starting number X0 ≥ 3 and try to reach one million by the process described below. \n\nAlice goes first and then they take alternating turns. In the i-th turn, the player whose turn it is selects a prime number smaller than the ...
[{"input": "1000000\n", "output": "998677\n"}, {"input": "908209\n", "output": "453632\n"}, {"input": "999958\n", "output": "250008\n"}, {"input": "570570\n", "output": "285282\n"}, {"input": "959878\n", "output": "239978\n"}, {"input": "959806\n", "output": "239958\n"}, {"input": "959818\n", "output": "239958\n"}, {"i...
code_stdio
[ { "content": "problem\n\nGiven a sequence $ a_i $ of length $ N $. Output all integers $ K (1 \\ le K \\ le N) $ that satisfy the following conditions.\n\nCondition: Well sorted $ a_1, \\ cdots, a_K $ matches $ a_ {N-K + 1}, \\ cdots, a_N $.\n\n\n\n\n\nExample\n\nInput\n\n8\n5 2 4 9 4 9 2 5\n\n\nOutput\n\n1 2 4...
[{"input": "8\n0 1 1 -24 -1 1 1 0", "output": "1 2 3 5 6 7 8\n"}, {"input": "8\n-1 0 12 16 3 1 0 -1", "output": "1 2 6 7 8\n"}, {"input": "8\n-1 0 12 8 3 1 0 -1", "output": "1 2 6 7 8\n"}, {"input": "8\n5 2 4 4 4 14 2 5", "output": "1 2 6 7 8\n"}, {"input": "8\n5 2 4 9 4 9 2 5", "output": "1 2 4 6 7 8"}, {"input": "8\n...
code_stdio
[ { "content": "Takahashi is doing a research on sets of points in a plane. Takahashi thinks a set S of points in a coordinate plane is a good set when S satisfies both of the following conditions:\n\n* The distance between any two points in S is not \\sqrt{D_1}.\n* The distance between any two points in S is not...
[{"input": "33 4 2", "output": "0 0\n0 1\n0 4\n0 5\n0 8\n0 9\n0 12\n0 13\n0 16\n0 17\n0 20\n0 21\n0 24\n0 25\n0 28\n0 29\n0 32\n0 33\n0 36\n0 37\n0 40\n0 41\n0 44\n0 45\n0 48\n0 49\n0 52\n0 53\n0 56\n0 57\n0 60\n0 61\n0 64\n0 65\n2 2\n2 3\n2 6\n2 7\n2 10\n2 11\n2 14\n2 15\n2 18\n2 19\n2 22\n2 23\n2 26\n2 27\n2 30\n2 31...
code_stdio
[ { "content": "Write\n```python\nword_pattern(pattern, string)\n```\nthat given a ```pattern``` and a string ```str```, find if ```str``` follows the same sequence as ```pattern```. \n\nFor example:\n```python\nword_pattern('abab', 'truck car truck car') == True\nword_pattern('aaaa', 'dog dog dog dog') == True\n...
[{"input": "\"aafggiilp\"\n\"cow cow fly rooster pig sheep sheep chicken aardvark\"", "output": "[false]", "fn_name": "word_pattern"}, {"input": "\"aafggiilp\"\n\"cow cow fly pig pig sheep sheep chicken aardvark\"", "output": "[true]", "fn_name": "word_pattern"}, {"input": "\"abcdef\"\n\"apple banana cat donkey elephan...
code_functional
[ { "content": "Let's consider one interesting word game. In this game you should transform one word into another through special operations. \n\nLet's say we have word w, let's split this word into two non-empty parts x and y so, that w = xy. A split operation is transforming word w = xy into word u = yx. For ex...
[{"input": "dkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjij\ndddkikjjidkkidijjjjkkjjikjdikiidijjikikjijjiijdikkjjjiddjjijkkkjkiijijkijdjjikikdjjjijdddjkjjdij...
code_stdio
[ { "content": "Sometimes Mister B has free evenings when he doesn't know what to do. Fortunately, Mister B found a new game, where the player can play against aliens.\n\nAll characters in this game are lowercase English letters. There are two players: Mister B and his competitor.\n\nInitially the players have a ...
[{"input": "12 12 876543210 1000000000\n", "output": "13"}, {"input": "10 12 220000011 220000032\n", "output": "11"}, {"input": "3 10 498103029 1063506054\n", "output": "4\n"}, {"input": "13 8 654321109 654321126\n", "output": "13\n"}, {"input": "5 6 1000000000 1000001000\n", "output": "6\n"}, {"input": "3 12 498103029...
code_stdio
[ { "content": "You 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, you have a possibility to select the order in which the tickets will be...
[{"input": "4\n1\n100\n50 1\n49 1\n100\n8\n100 200 100 200 100 200 100 100\n10 2\n15 3\n107\n3\n1000000000 1000000000 1000000000\n50 1\n50 1\n3000000000\n5\n200 100 100 100 100\n69 5\n31 2\n90\n", "output": "-1\n6\n3\n4\n"}, {"input": "4\n1\n100\n50 1\n49 1\n100\n8\n100 200 100 200 100 200 100 100\n10 2\n15 3\n107\n3\n...
code_stdio
[ { "content": "There are 2N balls, N white and N black, arranged in a row. The integers from 1 through N are written on the white balls, one on each ball, and they are also written on the black balls, one on each ball.\nThe integer written on the i-th ball from the left (1 ≤ i ≤ 2N) is a_i, and the color of this...
[{"input": "2000\nB 1731\nW 1129\nW 285\nB 1447\nW 1836\nW 1278\nW 1648\nW 1593\nW 710\nB 470\nW 264\nW 1693\nW 103\nW 1622\nW 1883\nW 824\nB 1337\nB 115\nW 1645\nB 1682\nW 245\nW 453\nW 606\nW 996\nW 394\nW 1795\nW 1930\nB 809\nB 1761\nW 1552\nW 656\nB 1527\nB 74\nB 1269\nW 527\nB 422\nW 1387\nW 1020\nB 206\nB 815\nW ...
code_stdio
[ { "content": "Monocarp has got an array $a$ consisting of $n$ integers. Let's denote $k$ as the mathematic mean of these elements (note that it's possible that $k$ is not an integer).\n\nThe mathematic mean of an array of $n$ elements is the sum of elements divided by the number of these elements (i. e. sum div...
[{"input": "4\n4\n8 8 12 14\n3\n50 25 10\n5\n1 4 7 3 5\n7\n-1 2 3 4 1 0 7\n", "output": "0\n0\n2\n0\n"}, {"input": "4\n4\n8 8 12 14\n3\n44 25 10\n5\n1 4 7 3 5\n7\n-1 2 3 4 1 0 7\n", "output": "0\n0\n2\n0\n"}, {"input": "4\n4\n8 8 18 14\n3\n44 25 10\n5\n1 4 7 3 5\n7\n-1 2 3 4 1 0 7\n", "output": "0\n0\n2\n0\n"}, {"input...
code_stdio
[ { "content": "There are $n$ candles on a Hanukkah menorah, and some of its candles are initially lit. We can describe which candles are lit with a binary string $s$, where the $i$-th candle is lit if and only if $s_i=1$.\n\nInitially, the candle lights are described by a string $a$. In an operation, you select ...
[{"input": "5\n5\n10010\n11010\n2\n01\n11\n3\n110\n111\n9\n100010111\n111101100\n4\n001011011\n011010111\n", "output": "-1\n1\n-1\n-1\n-1\n"}, {"input": "5\n5\n11000\n01000\n2\n01\n10\n3\n000\n101\n9\n100011111\n101101100\n9\n001001000\n011000101\n", "output": "-1\n2\n-1\n-1\n-1\n"}, {"input": "5\n5\n11000\n11010\n2\n0...
code_stdio
[ { "content": "You are given a directed graph of $n$ vertices and $m$ edges. Vertices are numbered from $1$ to $n$. There is a token in vertex $1$.\n\nThe following actions are allowed: Token movement. To move the token from vertex $u$ to vertex $v$ if there is an edge $u \\to v$ in the graph. This action take...
[{"input": "50 49\n1 3\n6 46\n47 25\n11 49\n47 10\n26 10\n12 38\n45 38\n24 39\n34 22\n36 3\n21 16\n43 44\n45 23\n2 31\n26 13\n28 42\n43 30\n12 27\n32 44\n24 25\n28 20\n15 19\n6 48\n41 7\n15 17\n8 9\n2 48\n33 5\n33 23\n4 19\n40 31\n11 9\n40 39\n35 27\n14 37\n32 50\n41 20\n21 13\n14 42\n18 30\n35 22\n36 5\n18 7\n4 49\n29...
code_stdio
[ { "content": "Relative B came to Mr. A's house. He is 3 years old and loves blocks. The block he has is shaped like Figure 1.\n\n<image>\n\nFigure 1\n\nMr. B is laying blocks on the board. When I asked him, \"What are you making?\", He replied cheerfully, \"Maze !!\". The maze he says is the arrangement of bloc...
[{"input": "20 21\n1 0\n14 8\n7\n4 0 1 1\n6 -1 1 3\n2 0 3 3\n1 0 5 0\n5 1 7 3\n2 -1 2 7\n2 -1 6 8\n20 20\n9 9\n1 1\n6\n2 0 1 1\n1 0 5 0\n2 1 1 4\n5 0 1 0\n4 1 6 10\n4 0 8 5\n0 0", "output": "NG\nNG\n"}, {"input": "20 21\n1 0\n14 8\n7\n4 0 1 1\n6 -1 1 3\n2 0 3 3\n1 0 5 0\n5 1 7 3\n2 -1 2 7\n2 -1 4 8\n20 20\n9 9\n1 1\n6\...
code_stdio
[ { "content": "There is BMI (Body Mass Index) as an index showing the degree of obesity. The BMI value is calculated using the following formula.\n\nBMI = weight (kg) / (height (m)) 2\n\nThe closer the BMI value is to the standard value, the more \"ideal body shape\" is considered. Therefore, if the standard val...
[{"input": "6\n2 165 27\n-1 317 60\n2 68 72\n11 160 75\n7 185 001\n10 182 113\n3\n3 37 105\n0 229 6\n2 204 75\n0", "output": "11\n2\n"}, {"input": "6\n2 95 27\n-1 317 60\n2 68 72\n11 160 75\n7 185 101\n10 182 113\n3\n3 37 105\n0 229 6\n1 204 75\n0", "output": "11\n1\n"}, {"input": "6\n2 179 27\n-1 317 107\n2 50 72\n11 ...
code_stdio
[ { "content": "In Aramic language words can only represent objects.\n\nWords in Aramic have special properties: A word is a root if it does not contain the same letter more than once. A root and all its permutations represent the same object. The root $x$ of a word $y$ is the word that contains all letters t...
[{"input": "10\nbda bbb cda dca dda dcb bcd dcb ada ddd\n", "output": "6\n"}, {"input": "10\ncda bbb cda dca dda dcb bcd dcb ada ddd\n", "output": "5\n"}, {"input": "10\nbda bbb cda dca dda dcb bcd dcb ada edd\n", "output": "6\n"}, {"input": "10\nbda bbb adc dca dda dcb bcd dcb ada edd\n", "output": "6\n"}, {"input": "...
code_stdio
[ { "content": "In this Kata, you will be given an array of numbers and a number `n`, and your task will be to determine if `any` array elements, when summed (or taken individually), are divisible by `n`. \n\nFor example:\n\n * `solve([1,3,4,7,6],9) == true`, because `3 + 6` is divisible by `9`\n * `solve([1,2,...
[{"input": "[1, 2, 3, 4, 5]\n10", "output": "[true]", "fn_name": "solve"}, {"input": "[1, 2, 3, 4, 5]\n15", "output": "[true]", "fn_name": "solve"}, {"input": "[1, 2, 3, 4, 5]\n8", "output": "[true]", "fn_name": "solve"}, {"input": "[7, 2, 8, 5]\n16", "output": "[false]", "fn_name": "solve"}, {"input": "[3, 1, 5, 7]\n1...
code_functional
[ { "content": "International Coding Procedures Company (ICPC) writes all its code in Jedi Script (JS) programming language. JS does not get compiled, but is delivered for execution in its source form. Sources contain comments, extra whitespace (including trailing and leading spaces), and other non-essential feat...
[{"input": "8\n< > << >> in out fun in>>out\n6\n# let's rock\nin>>out in >> out inout>>outin bin>>out # yay!\nfun>>in>>out funin>>out out>>in <in> > <out>\nin> >> >>> >>>> >>>>>out\n# what's going on here?\n<> <> <> <> <fun> <funfun> <not so fun>\n", "output": "in>>outin>> out a>>b c>>out fun>>in>>outd>>out out>>in<in>...
code_stdio
[ { "content": "n! = n × (n − 1) × (n − 2) × ... × 3 × 2 × 1\n\nIs called the factorial of n. For example, the factorial of 12\n\n12! = 12 x 11 x 10 x 9 x 8 x 7 x 6 x 5 x 4 x 3 x 2 x 1 = 479001600\n\nAnd there are two consecutive 0s at the end.\n\nWrite a program that inputs the integer n and outputs the number o...
[{"input": "2\n51\n11000\n0", "output": "0\n12\n2748\n"}, {"input": "2\n58\n10011\n0", "output": "0\n13\n2501\n"}, {"input": "2\n59\n10111\n0", "output": "0\n13\n2525\n"}, {"input": "2\n62\n10110\n0", "output": "0\n14\n2525\n"}, {"input": "2\n50\n10101\n0", "output": "0\n12\n2523\n"}, {"input": "2\n80\n11010\n0", "outp...
code_stdio
[ { "content": "The Tower of Hanoi is a well-known mathematical puzzle. It consists of three rods, and a number of disks of different sizes which can slide onto any rod. The puzzle starts with the disks in a neat stack in ascending order of size on one rod, the smallest at the top, thus making a conical shape.\n\...
[{"input": "0 10000 10000\n10000 0 10000\n10000 10000 0\n40\n", "output": "10995116277750000\n"}, {"input": "0 10000 10000\n10000 0 10000\n10000 10000 0\n40\n", "output": "10995116277750000\n"}, {"input": "0 00000 10000\n10000 0 10000\n10000 10000 0\n40\n", "output": "8551757104850000\n"}, {"input": "0 4499 7885\n10073...
code_stdio
[ { "content": "You are given an integer m as a product of integers a1, a2, ... an <image>. Your task is to find the number of distinct decompositions of number m into the product of n ordered positive integers.\n\nDecomposition into n products, given in the input, must also be considered in the answer. As the an...
[{"input": "50\n675 25000 2025 50 450 31250 3750 225 1350 250 72 187500 12000 281250 187500 30000 45000 90000 90 1200 9000 56250 5760 270000 3125 3796875 2250 101250 40 2500 175781250 1250000 45000 2250 3000 31250 46875 135000 421875000 36000 360 140625000 13500 1406250 229 250 75000 62500 150 6\n", "output": "60487335...
code_stdio
[ { "content": "Arpa is researching the Mexican wave.\n\nThere are n spectators in the stadium, labeled from 1 to n. They start the Mexican wave at time 0. \n\n At time 1, the first spectator stands. At time 2, the second spectator stands. ... At time k, the k-th spectator stands. At time k + 1, the (k + 1)-...
[{"input": "1000000000 1000000000 1000000000\n", "output": "1000000000\n"}, {"input": "1000000000 1000000000 1000000000\n", "output": "1000000000\n"}, {"input": "1000000000 1000000000 1400000000\n", "output": "600000000\n"}, {"input": "1000000000 1000000000 1400000000\n", "output": "600000000\n"}, {"input": "1100000000...
code_stdio
[ { "content": "A robot is standing at the origin of the infinite two-dimensional plane. Each second the robot moves exactly $1$ meter in one of the four cardinal directions: north, south, west, and east. For the first step the robot can choose any of the four directions, but then at the end of every second it ha...
[{"input": "1000\n", "output": "251001\n"}, {"input": "1000\n", "output": "251001\n"}, {"input": "777\n", "output": "303420\n"}, {"input": "998\n", "output": "250000\n"}, {"input": "999\n", "output": "501000\n"}, {"input": "777\n", "output": "303420\n"}, {"input": "999\n", "output": "501000\n"}, {"input": "998\n", "out...
code_stdio
[ { "content": "As a tradition, every year before IOI all the members of Natalia Fan Club are invited to Malek Dance Club to have a fun night together. Malek Dance Club has 2^{n} members and coincidentally Natalia Fan Club also has 2^{n} members. Each member of MDC is assigned a unique id i from 0 to 2^{n} - 1. T...
[{"input": "0110011110111000001101001010101000011011101001001101000000111101010101111101010011101001111010111001\n", "output": "416862683\n"}, {"input": "0111001111110010000001111100110100111110001100100001111111110000010010111010010010010111000110001111\n", "output": "777947548\n"}, {"input": "100000000110101010101111...
code_stdio
[ { "content": "Polycarp takes part in a math show. He is given n tasks, each consists of k subtasks, numbered 1 through k. It takes him t_{j} minutes to solve the j-th subtask of any task. Thus, time required to solve a subtask depends only on its index, but not on the task itself. Polycarp can solve subtasks in...
[{"input": "12 45 2290987\n50912 189025 5162 252398 298767 154151 164139 185891 121047 227693 93549 284244 312843 313833 285436 131672 135248 324541 194905 205729 241315 32044 131902 305884 263 27717 173077 81428 285684 66470 220938 282471 234921 316283 30485 244283 170631 224579 72899 87066 6727 161661 40556 89162 314...
code_stdio
[ { "content": "Demiurges Shambambukli and Mazukta love to watch the games of ordinary people. Today, they noticed two men who play the following game.\n\nThere is a rooted tree on n nodes, m of which are leaves (a leaf is a nodes that does not have any children), edges of the tree are directed from parent to chi...
[{"input": "50\n1 2\n2 3\n3 4\n4 5\n5 6\n6 7\n7 8\n8 9\n9 10\n10 11\n11 12\n12 13\n13 14\n14 15\n15 16\n16 17\n17 18\n18 19\n19 20\n20 21\n21 22\n22 23\n23 24\n24 25\n25 26\n26 27\n27 28\n28 29\n29 30\n30 31\n31 32\n32 33\n33 34\n34 35\n35 36\n36 37\n37 38\n38 39\n39 40\n40 41\n41 42\n42 43\n43 44\n44 45\n45 46\n46 47\...
code_stdio
[ { "content": "We have N non-negative integers: A_1, A_2, ..., A_N.\nConsider painting at least one and at most N-1 integers among them in red, and painting the rest in blue.\nLet the beauty of the painting be the \\mbox{XOR} of the integers painted in red, plus the \\mbox{XOR} of the integers painted in blue.\n...
[{"input": "20\n1008288677408720767 539403903321871999 1044301017184589821 215886900497862655 504277496111605629 972104334925272829 792625803473366909 972333547668684797 467386965442856573 755861732751878143 1151846447448561405 467257771752201853 683930041385277311 432010719984459389 319104378117934975 6114512914442339...
code_stdio
[ { "content": "Create a function which checks a number for three different properties.\n\n- is the number prime?\n- is the number even?\n- is the number a multiple of 10?\n\nEach should return either true or false, which should be given as an array. Remark: The Haskell variant uses `data Property`.\n\n### Exampl...
[{"input": "179424693", "output": "[[false, false, false]]", "fn_name": "number_property"}, {"input": "179424691", "output": "[[true, false, false]]", "fn_name": "number_property"}, {"input": "25", "output": "[[false, false, false]]", "fn_name": "number_property"}, {"input": "131", "output": "[[true, false, false]]", "...
code_functional
[ { "content": "The girl Taylor has a beautiful calendar for the year y. In the calendar all days are given with their days of week: Monday, Tuesday, Wednesday, Thursday, Friday, Saturday and Sunday.\n\nThe calendar is so beautiful that she wants to know what is the next year after y when the calendar will be exa...
[{"input": "105311\n", "output": "105322\n"}, {"input": "99999\n", "output": "100010\n"}, {"input": "99988\n", "output": "100016\n"}, {"input": "99996\n", "output": "100024\n"}, {"input": "50501\n", "output": "50507\n"}, {"input": "50000\n", "output": "50028\n"}, {"input": "99900\n", "output": "99906\n"}, {"input": "12...
code_stdio
[ { "content": "Note that girls in Arpa’s land are really attractive.\n\nArpa loves overnight parties. In the middle of one of these parties Mehrdad suddenly appeared. He saw n pairs of friends sitting around a table. i-th pair consisted of a boy, sitting on the ai-th chair, and his girlfriend, sitting on the bi-...
[{"input": "26\n8 10\n52 21\n2 33\n18 34\n30 51\n5 19\n22 32\n36 28\n42 16\n13 49\n11 17\n31 39\n43 37\n50 15\n29 20\n35 46\n47 23\n3 1\n44 7\n9 27\n6 48\n40 24\n26 14\n45 4\n12 25\n41 38\n", "output": "2 1\n1 2\n2 1\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n2 1\n1 2\n1 2\n1 2\n2 1\n2 1\n2 1\n2 1\n2 1\n2 1\n2 1\n2 1\n1 2\n2 1\n2 ...
code_stdio
[ { "content": "For a set $S$ of integers, perform a sequence of the following operations. Note that each value in $S$ must be unique.\n\n* insert($x$): Insert $x$ to $S$ and report the number of elements in $S$ after the operation.\n* find($x$): Report the number of $x$ in $S$ (0 or 1).\n\nConstraints\n\n* $1 \\...
[{"input": "7\n0 -1\n0 2\n0 6\n1 2\n0 -1\n0 -1\n1 20", "output": "1\n2\n3\n1\n3\n3\n0\n"}, {"input": "7\n0 -1\n0 2\n0 5\n1 2\n0 -1\n1 0\n1 20", "output": "1\n2\n3\n1\n3\n0\n0\n"}, {"input": "7\n0 -1\n0 2\n0 6\n1 2\n0 -1\n0 0\n1 20", "output": "1\n2\n3\n1\n3\n4\n0\n"}, {"input": "7\n0 -2\n0 2\n0 6\n1 2\n0 -1\n0 0\n1 20"...
code_stdio
[ { "content": "Maria participates in a bicycle race.\n\nThe speedway takes place on the shores of Lake Lucerne, just repeating its contour. As you know, the lake shore consists only of straight sections, directed to the north, south, east or west.\n\nLet's introduce a system of coordinates, directing the Ox axis...
[{"input": "24\n-10000 -10000\n-10000 9998\n9998 9998\n9998 -10000\n-6364 -10000\n-6364 6362\n6362 6362\n6362 -6364\n-2728 -6364\n-2728 2726\n2726 2726\n2726 -910\n908 -910\n908 908\n-910 908\n-910 -4546\n4544 -4546\n4544 4544\n-4546 4544\n-4546 -8182\n8180 -8182\n8180 8180\n-8182 8180\n-8182 -10000\n-10000 -10000\n", ...
code_stdio
[ { "content": "You've got a robot, its task is destroying bombs on a square plane. Specifically, the square plane contains n bombs, the i-th bomb is at point with coordinates (x_{i}, y_{i}). We know that no two bombs are at the same point and that no bomb is at point with coordinates (0, 0). Initially, the robot...
[{"input": "24\n-2 -2\n-1 1\n0 1\n1 1\n0 2\n1 -1\n2 -2\n1 -4\n-1 1\n0 -2\n0 -2\n-2 0\n-2 -1\n2 -1\n2 2\n-1 -2\n-2 1\n2 0\n-1 2\n1 2\n-1 -1\n1 0\n2 1\n-2 2\n", "output": "130\n1 1 U\n2\n1 1 D\n3\n1 1 R\n2\n1 1 L\n3\n1 1 L\n1 1 U\n2\n1 1 R\n1 1 D\n3\n1 1 R\n1 1 U\n2\n1 1 L\n1 1 D\n3\n1 2 U\n2\n1 2 D\n3\n1 1 R\n1 1 D\n2\n...
code_stdio
[ { "content": "Let $f(x)$ be the sum of digits of a decimal number $x$.\n\nFind the smallest non-negative integer $x$ such that $f(x) + f(x + 1) + \\dots + f(x + k) = n$.\n\n\n-----Input-----\n\nThe first line contains one integer $t$ ($1 \\le t \\le 150$) — the number of test cases.\n\nEach test case consists o...
[{"input": "7\n1 0\n2 1\n42 7\n1 9\n64 0\n99 0\n99 2\n", "output": "1\n-1\n4\n-1\n19999999\n99999999999\n7997\n"}, {"input": "7\n1 0\n1 1\n42 7\n1 9\n64 0\n99 0\n99 2\n", "output": "1\n0\n4\n-1\n19999999\n99999999999\n7997\n"}, {"input": "7\n1 0\n1 1\n42 7\n13 7\n99 1\n99 0\n99 2\n", "output": "1\n0\n4\n-1\n599998\n999...
code_stdio
[ { "content": "Almost every text editor has a built-in function of center text alignment. The developers of the popular in Berland text editor «Textpad» decided to introduce this functionality into the fourth release of the product.\n\nYou are to implement the alignment in the shortest possible time. Good luck!\...
[{"input": "8\n\n\n\ny\nW\n\n\n\n3B\n\nw\nV\n\n\n\nL\nSr\n\n\nV\n\n5\n\nAq\n\n\n\nJ\nR\n\n04\nJ\nv\nUh\n\n\n\nY\nG\n4\n\nG\nb\n\n\n9\n\n6\nd\n\n2\n\n\nE\n7\n\nr\n\n\n\n\nKC\ns\nE\n\nab\n4\nx\n\n\n\n\n\nEe\n4\n\nl\n\np\n\nG\nM\n\n\nn\n\n\nm0\n\nw\n\n\nP\n\n\n\n0\n\n\n", "output": "****\n*8 *\n* *\n* *\n* *\n* y*\n*W ...
code_stdio
[ { "content": "The hero of justice, the Spider, can pull a rope out of his arm and jump from building to building. However, due to the short rope, you can only move to buildings that are less than 50 distances from you. To move to a building farther away, you have to jump to another building.\n\n\n<image>\n\n\n\...
[{"input": "4\n1 -2 0\n2 30 0\n3 33 40\n4 1 60\n2\n1 3\n1 4\n22\n1 0 0\n2 150 40\n3 30 20\n4 180 150\n5 40 80\n6 130 130\n7 72 28\n8 172 118\n9 50 50\n10 160 82\n11 90 105\n12 218 131\n13 130 64\n14 80 140\n15 36 117\n16 190 90\n17 60 100\n18 100 70\n19 130 100\n20 71 69\n21 200 110\n22 120 150\n1\n1 22\n0", "output": ...
code_stdio
[ { "content": "< PREVIOUS KATA\nNEXT KATA >\n\n## Task:\n\nYou have to write a function `pattern` which returns the following Pattern(See Examples) upto desired number of rows. \n\n* Note:```Returning``` the pattern is not the same as ```Printing``` the pattern.\n\n### Parameters:\n \n pattern( n ...
[{"input": "10\n-2999", "output": "[\"1 1\\n 2 2 \\n 3 3 \\n 4 4 \\n 5 5 \\n 6 6 \\n 7 7 \\n 8 8 \\n 9 9 \\n 0 \\n 9 9 \\n 8 8 \\n 7 7 ...
code_functional
[ { "content": "You are given a grid, consisting of $2$ rows and $n$ columns. Each cell of this grid should be colored either black or white.\n\nTwo cells are considered neighbours if they have a common border and share the same color. Two cells $A$ and $B$ belong to the same component if they are neighbours, or ...
[{"input": "1000 1000\n", "output": "987824894\n"}, {"input": "1000 1100\n", "output": "961685369\n"}, {"input": "1000 1110\n", "output": "720640362\n"}, {"input": "1000 1010\n", "output": "841013797\n"}, {"input": "1000 500\n", "output": "805290096\n"}, {"input": "1000 1000\n", "output": "987824894"}, {"input": "1000 ...
code_stdio
[ { "content": "You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens.\nThere are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i.\nA...
[{"input": "32\n3 1 8 1 5 9 4 2 3 3 9 8 11 7 16 4 2 4 8 2 4 4 7 7 3 3 30 4 4 7 2 8", "output": "13\n"}, {"input": "32\n3 1 8 1 5 2 7 2 3 3 9 8 11 7 16 4 2 4 8 2 4 4 7 7 3 3 30 4 4 7 2 8", "output": "12\n"}, {"input": "32\n3 1 4 1 8 11 8 6 5 3 5 8 9 7 9 3 2 3 8 4 6 2 6 4 3 3 8 3 3 7 2 14", "output": "20\n"}, {"input": "...
code_stdio
[ { "content": "Let's say take 2 strings, A and B, and define the similarity of the strings to be the length of the longest prefix common to both strings. For example, the similarity of strings `abc` and `abd` is 2, while the similarity of strings `aaa` and `aaab` is 3.\n\nwrite a function that calculates the sum...
[{"input": "\"ababaa\"", "output": "[11]", "fn_name": "string_suffix"}, {"input": "\"aaaaaa\"", "output": "[21]", "fn_name": "string_suffix"}, {"input": "\"aaaaa\"", "output": "[15]", "fn_name": "string_suffix"}, {"input": "\"mnsomn\"", "output": "[8]", "fn_name": "string_suffix"}, {"input": "\"aaaa\"", "output": "[10]...
code_functional