messages listlengths 1 1 | ground_truth stringlengths 156 726k | dataset stringclasses 2
values |
|---|---|---|
[
{
"content": "Pinkie Pie has bought a bag of patty-cakes with different fillings! But it appeared that not all patty-cakes differ from one another with filling. In other words, the bag contains some patty-cakes with the same filling.\n\nPinkie Pie eats the patty-cakes one-by-one. She likes having fun so she dec... | [{"input": "4\n7\n1 7 1 6 4 4 6\n8\n1 1 4 6 4 6 4 7\n3\n3 3 3\n6\n2 5 2 3 1 4\n", "output": "3\n2\n0\n4\n"}, {"input": "4\n7\n1 7 1 6 4 7 6\n8\n1 1 4 6 4 6 4 7\n3\n3 3 3\n6\n2 5 2 3 1 4\n", "output": "3\n2\n0\n4\n"}, {"input": "4\n7\n1 7 1 6 4 7 6\n8\n1 1 4 6 4 6 4 7\n3\n3 3 1\n6\n2 5 2 3 1 4\n", "output": "3\n2\n1\n4\... | code_stdio |
[
{
"content": "At the foot of Liyushan Mountain, n tents will be carefully arranged to provide accommodation for those who are willing to experience the joy of approaching nature, the tranquility of the night, and the bright starry sky.\n\nThe i-th tent is located at the point of (x_i, y_i) and has a weight of w... | [{"input": "10\n-535541974 -572774963 229181417\n-535541973 -590337106 348212269\n-535541972 -572774962 413415882\n-535541973 -717839722 657120913\n-535541975 -572774961 155042637\n-535541975 -706888442 81575270\n-535541971 -572774961 888834471\n-535541974 -721151373 899782743\n-535541971 -1600858205 614959267\n-535541... | code_stdio |
[
{
"content": "# Task\n Initially a number `1` is written on a board. It is possible to do the following operations with it:\n```\nmultiply the number by 3;\nincrease the number by 5.```\nYour task is to determine that using this two operations step by step, is it possible to obtain number `n`?\n\n# Example\n\n ... | [{"input": "12345", "output": "[false]", "fn_name": "number_increasing"}, {"input": "54321", "output": "[true]", "fn_name": "number_increasing"}, {"input": "100", "output": "[false]", "fn_name": "number_increasing"}, {"input": "101", "output": "[true]", "fn_name": "number_increasing"}, {"input": "2", "output": "[false]... | code_functional |
[
{
"content": "Recall that a binary search tree is a rooted binary tree, whose nodes each store a key and each have at most two distinguished subtrees, left and right. The key in each node must be greater than any key stored in the left subtree, and less than any key stored in the right subtree.\n\nThe depth of ... | [{"input": "1000000\n", "output": "0\n"}, {"input": "360561\n", "output": "0\n"}, {"input": "699049\n", "output": "1\n"}, {"input": "699047\n", "output": "0\n"}, {"input": "699050\n", "output": "1\n"}, {"input": "699048\n", "output": "0\n"}, {"input": "786432\n", "output": "0\n"}, {"input": "750096\n", "output": "0\n"}... | code_stdio |
[
{
"content": "This is an interactive problem. Refer to the Interaction section below for better understanding.\n\nIthea and Chtholly want to play a game in order to determine who can use the kitchen tonight.\n\n<image>\n\nInitially, Ithea puts n clear sheets of paper in a line. They are numbered from 1 to n fro... | [{"input": "10 120 15\n6\n11\n9\n11\n3\n12\n11\n12\n2\n8\n3\n11\n13\n5\n12\n11\n9\n3\n10\n9\n9\n13\n13\n5\n6\n11\n3\n15\n8\n8\n10\n13\n7\n6\n4\n14\n9\n10\n5\n13\n4\n1\n8\n6\n13\n1\n3\n4\n9\n12\n2\n7\n3\n3\n7\n2\n2\n9\n2\n4\n2\n2\n11\n12\n15\n13\n6\n2\n11\n1\n8\n3\n13\n6\n15\n6\n4\n3\n4\n15\n15\n9\n5\n8\n3\n6\n14\n14\n5... | code_stdio |
[
{
"content": "In Finite Encyclopedia of Integer Sequences (FEIS), all integer sequences of lengths between 1 and N (inclusive) consisting of integers between 1 and K (inclusive) are listed.\nLet the total number of sequences listed in FEIS be X. Among those sequences, find the (X/2)-th (rounded up to the neares... | [{"input": "0 39", "output": "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n"}, {"input": "0 28", "output": "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n"}, {"input": "13 27", "output": "7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 6 8\n"}, {"input": "2 27", "output": ... | code_stdio |
[
{
"content": "William has a favorite bracket sequence. Since his favorite sequence is quite big he provided it to you as a sequence of positive integers $c_1, c_2, \\dots, c_n$ where $c_i$ is the number of consecutive brackets \"(\" if $i$ is an odd number or the number of consecutive brackets \")\" if $i$ is a... | [{"input": "50\n980145241 167620437 937571657 683888733 687342940 596264451 470954757 312707590 782743417 441517678 539214535 498906886 521201165 581866343 987986939 770597138 136540061 812371324 567649512 704604401 873600670 364129557 600605741 459396557 173915633 607977424 480952533 834953681 878054436 827935116 4130... | code_stdio |
[
{
"content": "A recently found Ancient Prophesy is believed to contain the exact Apocalypse date. The prophesy is a string that only consists of digits and characters \"-\".\n\nWe'll say that some date is mentioned in the Prophesy if there is a substring in the Prophesy that is the date's record in the format \... | [{"input": "12-12-201312-12-201312-12-201313--12-201313--12-201313--12-201313--12-201313--12-201313--12-201313--12-201313--12-2013\n", "output": "12-12-2013\n"}, {"input": "12-12-211312-12-201312-12-201313--12-201313--02-201313--12-201313--12-201313--12-201313--12-201313--12-201313--12-2013\n", "output": "12-12-2013\n"... | code_stdio |
[
{
"content": "In some game by Playrix it takes t minutes for an oven to bake k carrot cakes, all cakes are ready at the same moment t minutes after they started baking. Arkady needs at least n cakes to complete a task, but he currently don't have any. However, he has infinitely many ingredients and one oven. Mo... | [{"input": "1000 1000 1000 1000\n", "output": "NO\n"}, {"input": "1000 1000 1000 1000\n", "output": "NO\n"}, {"input": "1000 1000 1001 1000\n", "output": "NO\n"}, {"input": "1000 1000 1 1000\n", "output": "YES\n"}, {"input": "1000 1000 1 1000\n", "output": "YES\n"}, {"input": "1000 1001 1 1000\n", "output": "YES\n"}, {... | code_stdio |
[
{
"content": "— Oh my sweet Beaverette, would you fancy a walk along a wonderful woodland belt with me? \n\n— Of course, my Smart Beaver! Let us enjoy the splendid view together. How about Friday night? \n\nAt this point the Smart Beaver got rushing. Everything should be perfect by Friday, so he needed to prepa... | [{"input": "20\n-808998072 733614990 579897311 -337992089 579897311 120800519 -337992089 -354825441 733614990 -686536765 733614990 -803027570 -803027570 733614990 120800519 -1246630624 -686536765 579897311 -808998072 -686536765\n", "output": "4215055101 13\n1 4 7 8 10 12 13 15 16 17 18 19 20\n"}, {"input": "20\n-808998... | code_stdio |
[
{
"content": "Little chief has his own restaurant in the city. There are N workers there. Each worker has his own salary. The salary of the i-th worker equals to W_{i} (i = 1, 2, ..., N). Once, chief decided to equalize all workers, that is, he wants to make salaries of all workers to be equal. But for this goa... | [{"input": "2\n3\n0 -2 -1\n2\n75 42", "output": "3\n33\n"}, {"input": "2\n3\n0 -3 -1\n2\n75 42", "output": "5\n33\n"}, {"input": "2\n3\n1 -2 -1\n2\n60 42", "output": "4\n18\n"}, {"input": "2\n3\n0 -3 -1\n2\n75 16", "output": "5\n59\n"}, {"input": "2\n3\n1 -4 -1\n2\n75 42", "output": "8\n33\n"}, {"input": "2\n3\n0 -2 0\... | code_stdio |
[
{
"content": "Takahashi and Aoki are playing a stone-taking game. Initially, there are N piles of stones, and the i-th pile contains A_i stones and has an associated integer K_i.\nStarting from Takahashi, Takahashi and Aoki take alternate turns to perform the following operation:\n - Choose a pile. If the i-th ... | [{"input": "200\n48018902 1000000000\n671608134 1000000000\n821230959 1000000000\n839046240 1000000000\n871451860 1000000000\n201326387 1000000000\n95653264 1000000000\n118998199 1000000000\n661381768 1000000000\n265950246 1000000000\n443323091 1000000000\n621558889 1000000000\n486583499 1000000000\n185518031 100000000... | code_stdio |
[
{
"content": "Automatons, or Finite State Machines (FSM), are extremely useful to programmers when it comes to software design. You will be given a simplistic version of an FSM to code for a basic TCP session.\n\nThe outcome of this exercise will be to return the correct state of the TCP FSM based on the array ... | [{"input": "[\"APP_PASSIVE_OPEN\", \"RCV_SYN\", \"RCV_ACK\", \"APP_CLOSE\", \"RCV_FIN_ACK\", \"APP_TIMEOUT\", \"APP_ACTIVE_OPEN\", \"RCV_SYN\", \"APP_CLOSE\", \"RCV_FIN\", \"RCV_ACK\"]", "output": "[\"TIME_WAIT\"]", "fn_name": "traverse_TCP_states"}, {"input": "[\"APP_ACTIVE_OPEN\", \"RCV_SYN\", \"APP_CLOSE\", \"RCV_FI... | code_functional |
[
{
"content": "The research center Q has developed a new multi-core processor. The processor consists of n cores and has k cells of cache memory. Consider the work of this processor.\n\nAt each cycle each core of the processor gets one instruction: either do nothing, or the number of the memory cell (the core wi... | [{"input": "100 1 100\n59\n37\n53\n72\n37\n15\n8\n93\n92\n74\n11\n11\n68\n16\n92\n40\n76\n20\n10\n86\n76\n5\n9\n95\n5\n81\n44\n57\n10\n24\n22\n2\n57\n6\n26\n67\n48\n95\n34\n97\n55\n33\n70\n66\n51\n70\n74\n65\n35\n85\n37\n9\n27\n43\n65\n6\n5\n57\n54\n27\n22\n41\n8\n29\n10\n50\n9\n68\n78\n9\n92\n30\n88\n62\n30\n5\n80\n58... | code_stdio |
[
{
"content": "Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. \nLittle Egor likes to play with positive integers and their divisors. Bigger the number to play with, more the fun! The boy asked you to come up with an algorithm, that could play the following game: \nLet's define f(n)... | [{"input": "2\n1 18\n76 209", "output": "139\n15682\n"}, {"input": "2\n1 16\n76 209", "output": "108\n15682\n"}, {"input": "2\n1 7\n114 127", "output": "25\n1447\n"}, {"input": "2\n1 7\n76 209", "output": "25\n15682\n"}, {"input": "2\n1 9\n76 209", "output": "39\n15682\n"}, {"input": "2\n2 18\n42 82", "output": "138\n2... | code_stdio |
[
{
"content": "You are given a string S of length N consisting of A, B and C, and an integer K which is between 1 and N (inclusive).\nPrint the string S after lowercasing the K-th character in it.\n\n-----Constraints-----\n - 1 ≤ N ≤ 50\n - 1 ≤ K ≤ N\n - S is a string of length N consisting of A, B and C.\n\n---... | [{"input": "50 27\nACBCABCCCAACACCBBBACCBCBBBCCBAAAABAACACAAACCACCCCA\n", "output": "ACBCABCCCAACACCBBBACCBCBBBcCBAAAABAACACAAACCACCCCA\n"}, {"input": "50 50\nCABABCBBCBABCAACBCBBAAAACBCBCBBABBABBBCCBAACCAACAB\n", "output": "CABABCBBCBABCAACBCBBAAAACBCBCBBABBABBBCCBAACCAACAb\n"}, {"input": "40 38\nBCCACCBCACABBBBBCBABC... | code_stdio |
[
{
"content": "When you want to get the square of a binomial of two variables x and y, you will have:\n\n`$(x+y)^2 = x^2 + 2xy + y ^2$`\n\nAnd the cube:\n\n`$(x+y)^3 = x^3 + 3x^2y + 3xy^2 +y^3$`\n\nIt is known from many centuries ago that for an exponent n, the result of a binomial x + y raised to the n-th power... | [{"input": "10", "output": "[[1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2047]]", "fn_name": "f"}, {"input": "6", "output": "[[1, 2, 4, 8, 16, 32, 64, 127]]", "fn_name": "f"}, {"input": "3", "output": "[[1, 2, 4, 8, 15]]", "fn_name": "f"}, {"input": "2", "output": "[[1, 2, 4, 7]]", "fn_name": "f"}, {"input": "1", "ou... | code_functional |
[
{
"content": "problem\n\nIn the area where Kazakhstan is now located, there used to be a trade route called the \"Silk Road\".\n\nThere are N + 1 cities on the Silk Road, numbered from west as city 0, city 1, ..., city N. The distance between city i -1 and city i (1 ≤ i ≤ N) is Di.\n\nJOI, a trader, decided to ... | [{"input": "3 5\n10\n25\n15\n50\n30\n15\n12\n30", "output": "855\n"}, {"input": "3 5\n10\n38\n18\n50\n30\n6\n40\n30", "output": "1068\n"}, {"input": "3 5\n10\n38\n18\n50\n30\n6\n40\n34", "output": "1140\n"}, {"input": "3 5\n10\n38\n18\n50\n27\n6\n40\n34", "output": "1110\n"}, {"input": "3 5\n10\n38\n28\n50\n27\n6\n40\n... | code_stdio |
[
{
"content": "There was a big bank robbery in Tablecity. In order to catch the thief, the President called none other than Albert – Tablecity’s Chief of Police. Albert does not know where the thief is located, but he does know how he moves.\n\nTablecity can be represented as 1000 × 2 grid, where every cell repr... | [{"input": "\u0412 \u044d\u0442\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435 \u043d\u0435\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u0432\u0432\u043e\u0434\u0430-\u0432\u044b\u0432\u043e\u0434\u0430.\nThis problem doesn't have sample inout and output.", "output": "2000\n1 1 1 2\n2 1 2 2\n3 1 3 2\n4 1 ... | code_stdio |
[
{
"content": "Your task is to write a function which counts the number of squares contained in an ASCII art picture.\n\nThe input pictures contain rectangles---some of them squares---drawn with the characters `-`, `|`, and `+`, where `-` and `|` are used to represent horizontal and vertical sides, and `+` is us... | [{"input": "[\"+---------+--+\", \"| +---+ | |\", \"| | | | |\", \"| | | +--+\", \"| | | |\", \"| +---+ |\", \"| |\", \"| |\", \"| |\", \"| |\", \"| +---+---+\", \"| | | |\", \"| | | |\", \"+----+---+---+\", \" +---+\"]", "output":... | code_functional |
[
{
"content": "Note that the memory limit is unusual.\n\nYou are given an integer n and two sequences a_1, a_2, ..., a_n and b_1, b_2, ..., b_n.\n\nLet's call a set of integers S such that S ⊆ \\{1, 2, 3, ..., n\\} strange, if, for every element i of S, the following condition is met: for every j ∈ [1, i - 1], i... | [{"input": "20\n27 6 6 60 47 97 62 25 67 28 41 93 65 32 16 56 57 53 66 61\n84392 -11227 -93200 -52089 4854 -99982 -81560 95957 -35579 -91088 31023 -68447 -41338 -27132 43558 23876 35055 -36267 77633 -94930\n", "output": "294839\n"}, {"input": "20\n27 6 6 60 47 97 62 25 67 28 41 93 65 32 16 56 57 53 66 61\n84392 -11227 ... | code_stdio |
[
{
"content": "You are given a colored permutation $p_1, p_2, \\dots, p_n$. The $i$-th element of the permutation has color $c_i$.\n\nLet's define an infinite path as infinite sequence $i, p[i], p[p[i]], p[p[p[i]]] \\dots$ where all elements have same color ($c[i] = c[p[i]] = c[p[p[i]]] = \\dots$).\n\nWe can als... | [{"input": "3\n4\n1 3 4 2\n1 1 2 3\n5\n2 3 4 5 1\n1 2 5 10 3\n8\n7 4 5 6 1 8 3 2\n5 3 4 4 12 5 8 9\n", "output": "1\n5\n4\n"}, {"input": "3\n4\n1 3 4 2\n1 2 2 3\n5\n2 3 4 5 1\n1 2 10 4 5\n8\n7 4 5 6 1 8 3 2\n5 3 6 4 7 5 8 4\n", "output": "1\n5\n2\n"}, {"input": "3\n4\n1 3 4 2\n1 1 2 3\n5\n2 3 4 5 1\n1 2 5 10 4\n8\n7 4 ... | code_stdio |
[
{
"content": "Professor Vasechkin is studying evolution of worms. Recently he put forward hypotheses that all worms evolve by division. There are n forms of worms. Worms of these forms have lengths a1, a2, ..., an. To prove his theory, professor needs to find 3 different forms that the length of the first form ... | [{"input": "100\n804 510 266 304 788 178 862 888 408 82 414 470 777 991 729 229 1767 406 601 1 596 720 608 706 432 361 527 548 59 548 474 515 4 991 263 568 681 24 117 563 576 587 281 643 904 521 891 106 842 884 943 54 605 1567 504 757 311 374 335 192 447 652 633 410 455 402 382 150 432 836 413 819 669 875 638 925 217 8... | code_stdio |
[
{
"content": "Ichihime is the current priestess of the Mahjong Soul Temple. She claims to be human, despite her cat ears.\n\nThese days the temple is holding a math contest. Usually, Ichihime lacks interest in these things, but this time the prize for the winner is her favorite — cookies. Ichihime decides to at... | [{"input": "14\n2374453 2374454 8591131 23094546\n5813291 5813292 9709163 35032815\n4280399 23049698 23049701 34728360\n15184184 18688462 22400847 22400849\n24397371 31462070 33936330 33936331\n21376685 28241116 38909200 38909202\n29491847 31628480 31628482 45225214\n15144763 15414479 36902879 36902881\n36023581 388899... | code_stdio |
[
{
"content": "JAG mock qualifying practice session\n\nThe ACM-ICPC OB / OG Association (Japanese Alumni Group; JAG) has N questions in stock of questions to be asked in the mock contest, and each question is numbered with an integer from 1 to N. Difficulty evaluation and recommendation voting are conducted for ... | [{"input": "5 3\n1 1\n2 3\n3 2\n3 17\n2 1\n4 2\n1 7\n2 1\n1 3\n2 5\n6 1\n1 3\n1 2\n1 8\n1 2\n1 7\n1 6\n20 9\n4 10\n2 6\n8 3\n1 6\n6 3\n7 4\n8 10\n4 12\n7 5\n1 8\n5 7\n1 5\n4 6\n9 9\n5 8\n6 7\n1 4\n6 4\n7 10\n3 5\n19 6\n4 2\n6 5\n5 10\n1 10\n3 10\n3 6\n2 3\n1 4\n2 10\n1 8\n3 4\n3 1\n5 4\n1 10\n1 3\n5 10\n5 2\n1 10\n2 3\... | code_stdio |
[
{
"content": "Vasya wants to turn on Christmas lights consisting of m bulbs. Initially, all bulbs are turned off. There are n buttons, each of them is connected to some set of bulbs. Vasya can press any of these buttons. When the button is pressed, it turns on all the bulbs it's connected to. Can Vasya light up... | [{"input": "1 100\n100 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100\n", "... | code_stdio |
[
{
"content": "Digory Kirke and Polly Plummer are two kids living next door to each other. The attics of the two houses are connected to each other through a passage. Digory's Uncle Andrew has been secretly doing strange things in the attic of his house, and he always ensures that the room is locked. Being curio... | [{"input": "4\n####\n#..#.##\n##..#.#\n##.#....#", "output": "0\n1\n1\n2\n"}, {"input": "4\n####\n#..#.##\n#.#..##\n##.#....#", "output": "0\n1\n2\n2\n"}, {"input": "4\n####\n##.#..#\n#.#..##\n##.#....#", "output": "0\n2\n2\n2\n"}, {"input": "4\n####\n##.#..#\n#.#..##\n#....#.##", "output": "0\n2\n2\n1\n"}, {"input": "... | code_stdio |
[
{
"content": "Ringo is giving a present to Snuke.\n\nRingo has found out that Snuke loves yakiniku (a Japanese term meaning grilled meat. yaki: grilled, niku: meat). He supposes that Snuke likes grilled things starting with `YAKI` in Japanese, and does not like other things.\n\nYou are given a string S represen... | [{"input": "UKINIKAY", "output": "No\n"}, {"input": "UAKOYAKI", "output": "No\n"}, {"input": "NKIUIKAY", "output": "No\n"}, {"input": "IKAYOKAU", "output": "No\n"}, {"input": "NKIUAKIY", "output": "No\n"}, {"input": "AAKOYUKI", "output": "No\n"}, {"input": "OKIUAKIY", "output": "No\n"}, {"input": "AAKPYUKI", "output": ... | code_stdio |
[
{
"content": "Write a program which reads two integers x and y, and prints them in ascending order.\n\nConstraints\n\n* 0 ≤ x, y ≤ 10000\n* the number of datasets ≤ 3000\n\nInput\n\nThe input consists of multiple datasets. Each dataset consists of two integers x and y separated by a single space.\n\nThe input e... | [{"input": "3 0\n-1 2\n15 3\n0 0", "output": "0 3\n-1 2\n3 15\n"}, {"input": "3 -1\n0 2\n27 3\n0 0", "output": "-1 3\n0 2\n3 27\n"}, {"input": "4 -1\n0 2\n27 3\n0 0", "output": "-1 4\n0 2\n3 27\n"}, {"input": "4 -1\n0 2\n18 3\n0 0", "output": "-1 4\n0 2\n3 18\n"}, {"input": "4 -1\n0 2\n18 5\n0 0", "output": "-1 4\n0 2\... | code_stdio |
[
{
"content": "Today, Yasser and Adel are at the shop buying cupcakes. There are $n$ cupcake types, arranged from $1$ to $n$ on the shelf, and there are infinitely many of each type. The tastiness of a cupcake of type $i$ is an integer $a_i$. There are both tasty and nasty cupcakes, so the tastiness can be posit... | [{"input": "12\n3\n7 -4 5\n3\n7 -5 4\n3\n4 -5 7\n3\n5 -4 7\n4\n5 -5 -6 6\n5\n100 100 100 -50 50\n10\n11 5 -12 7 -10 20 30 -10 50 60\n10\n10 5 -14 7 -7 20 30 -50 50 60\n2\n1 1\n2\n-1 -1\n3\n1000000000 1010000000 1000000000\n3\n-1000000000 -1000000000 -1000000000\n", "output": "YES\nNO\nNO\nYES\nNO\nNO\nYES\nYES\nYES\nNO... | code_stdio |
[
{
"content": "Gildong was hiking a mountain, walking by millions of trees. Inspired by them, he suddenly came up with an interesting idea for trees in data structures: What if we add another edge in a tree?\n\nThen he found that such tree-like graphs are called 1-trees. Since Gildong was bored of solving too ma... | [{"input": "14\n4 9\n3 7\n4 1\n3 2\n14 9\n7 6\n10 13\n8 7\n5 7\n7 10\n1 3\n12 3\n7 11\n20\n13 6 14 9 1\n6 4 3 7 9\n9 3 6 13 7\n6 11 11 5 9\n14 5 2 3 4\n13 12 4 2 7\n13 14 7 3 2\n9 5 13 13 6\n8 9 7 3 7\n14 10 11 12 7\n6 12 13 1 1\n8 13 8 10 8\n1 5 13 10 7\n1 4 13 2 6\n1 5 6 4 10\n6 9 11 8 5\n9 7 14 7 9\n12 5 6 8 9\n14 1... | code_stdio |
[
{
"content": "A common problem in number theory is to find x given a such that:\n\na * x = 1 mod [n] \n\nThen x is called the inverse of a modulo n. \n\nYour goal is to code a function inverseMod wich take a and n as parameters and return x.\n\nYou may be interested by these pages:\n\nhttp://en.wikipedia.org/wi... | [{"input": "156435434\n3543432125", "output": "[1056765589]", "fn_name": "inverseMod"}, {"input": "101014\n125445", "output": "[7969]", "fn_name": "inverseMod"}, {"input": "61965\n17408", "output": "[null]", "fn_name": "inverseMod"}, {"input": "48\n733", "output": "[168]", "fn_name": "inverseMod"}, {"input": "229\n101"... | code_functional |
[
{
"content": "Imagine a city with n horizontal streets crossing m vertical streets, forming an (n - 1) × (m - 1) grid. In order to increase the traffic flow, mayor of the city has decided to make each street one way. This means in each horizontal street, the traffic moves only from west to east or only from eas... | [{"input": "20 20\n><<><<<<<<<>>><>>><<\n^^^^^^^^vvvv^vv^vvvv\n", "output": "YES\n"}, {"input": "20 20\n<>>>>>>>><>>><>><<<>\nvv^^vv^^^^v^vv^v^^^^\n", "output": "YES\n"}, {"input": "20 20\n>>><<<<<>>><><><<><<\n^^^vvv^^^v^^v^^v^vvv\n", "output": "YES\n"}, {"input": "20 20\n<<><<<<<<>>>>><<<>>>\nvvvvvv^v^vvv^^^^^^^^\n",... | code_stdio |
[
{
"content": "When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l.\n\nYou are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, t... | [{"input": "6\n5 -1 -1 -1 13 -1", "output": "-1\n-1\n-1\n-1\n-1\n-1\n"}, {"input": "6\n5 -1 -1 -1 13 0", "output": "-1\n0\n0\n0\n-1\n-1\n"}, {"input": "6\n5 -2 -1 0 15 -2", "output": "-1\n0\n0\n-1\n-1\n0\n"}, {"input": "6\n5 -2 -1 1 15 -2", "output": "-1\n1\n1\n-1\n-1\n1\n"}, {"input": "6\n4 4 -1 -1 4 -7", "output": "-... | code_stdio |
[
{
"content": "An NBA game runs 48 minutes (Four 12 minute quarters). Players do not typically play the full game, subbing in and out as necessary. Your job is to extrapolate a player's points per game if they played the full 48 minutes.\n\nWrite a function that takes two arguments, ppg (points per game) and mpg... | [{"input": "16\n27", "output": "[28.4]", "fn_name": "nba_extrap"}, {"input": "11\n19", "output": "[27.8]", "fn_name": "nba_extrap"}, {"input": "14\n33", "output": "[20.4]", "fn_name": "nba_extrap"}, {"input": "1\n7.5", "output": "[6.4]", "fn_name": "nba_extrap"}, {"input": "6\n13", "output": "[22.2]", "fn_name": "nba_e... | code_functional |
[
{
"content": "Childan is making up a legendary story and trying to sell his forgery — a necklace with a strong sense of \"Wu\" to the Kasouras. But Mr. Kasoura is challenging the truth of Childan's story. So he is going to ask a few questions about Childan's so-called \"personal treasure\" necklace.\n\nThis \"p... | [{"input": "12 1 1\n0 1 2 3 2 5 6 11 0 10 10 17\n001010001000\n001010001000 100\n", "output": "1\n"}, {"input": "12 1 1\n0 1 2 3 2 6 6 11 0 10 10 17\n001010001000\n001010001000 100\n", "output": "1\n"}, {"input": "12 1 1\n0 1 2 3 2 2 6 11 0 10 10 17\n001010001000\n001010001000 100\n", "output": "1\n"}, {"input": "12 1 ... | code_stdio |
[
{
"content": "Petya and Vasya decided to play a little. They found n red cubes and m blue cubes. The game goes like that: the players take turns to choose a cube of some color (red or blue) and put it in a line from left to right (overall the line will have n + m cubes). Petya moves first. Petya's task is to ge... | [{"input": "100000 100000\n", "output": "99999 100000\n"}, {"input": "100000 100000\n", "output": "99999 100000\n"}, {"input": "10000 100010\n", "output": "100009 10000\n"}, {"input": "10000 110010\n", "output": "110009 10000\n"}, {"input": "110881 42754\n", "output": "110880 42754\n"}, {"input": "25938 152750\n", "out... | code_stdio |
[
{
"content": "Let's denote that some array $b$ is bad if it contains a subarray $b_l, b_{l+1}, \\dots, b_{r}$ of odd length more than $1$ ($l < r$ and $r - l + 1$ is odd) such that $\\forall i \\in \\{0, 1, \\dots, r - l\\}$ $b_{l + i} = b_{r - i}$.\n\nIf an array is not bad, it is good.\n\nNow you are given an... | [{"input": "10 11\n-1 11 -1 -1 -1 -1 10 -1 -1 -1\n", "output": "100000000\n"}, {"input": "10 11\n-1 11 -1 -1 -1 -1 10 -1 -1 -1\n", "output": "100000000\n"}, {"input": "10 17\n-1 11 -1 -1 -1 -1 10 -1 -1 -1\n", "output": "301989884\n"}, {"input": "10 11\n-1 1 -1 -1 -1 -1 10 -1 -1 -1\n", "output": "100000000\n"}, {"input"... | code_stdio |
[
{
"content": "In the 17th century, Fermat wrote that he proved for any integer $n \\geq 3$, there exist no positive integers $x$, $y$, $z$ such that $x^n + y^n = z^n$. However he never disclosed the proof. Later, this claim was named Fermat's Last Theorem or Fermat's Conjecture.\n\nIf Fermat's Last Theorem hold... | [{"input": "6\n3\n13\n0", "output": "27\n11\n126\n"}, {"input": "6\n25\n12\n0", "output": "27\n64\n54\n"}, {"input": "6\n6\n15\n0", "output": "27\n27\n119\n"}, {"input": "6\n15\n2\n0", "output": "27\n119\n6\n"}, {"input": "6\n14\n4\n0", "output": "27\n16\n10\n"}, {"input": "6\n25\n4\n0", "output": "27\n64\n10\n"}, {"in... | code_stdio |
[
{
"content": "You are solving the crossword problem K from IPSC 2014. You solved all the clues except for one: who does Eevee evolve into? You are not very into pokemons, but quick googling helped you find out, that Eevee can evolve into eight different pokemons: Vaporeon, Jolteon, Flareon, Espeon, Umbreon, Lea... | [{"input": "8\n.a.o.e.n\n", "output": "vaporeon\n"}, {"input": "8\n........\n", "output": "vaporeon\n"}, {"input": "8\n..p.....\n", "output": "vaporeon\n"}, {"input": "8\n..p.....\n", "output": "vaporeon\n"}, {"input": "8\n.a.o.e.n\n", "output": "vaporeon\n"}, {"input": "8\n........\n", "output": "vaporeon\n"}, {"input... | code_stdio |
[
{
"content": "Sig has built his own keyboard. Designed for ultimate simplicity, this keyboard only has 3 keys on it: the 0 key, the 1 key and the backspace key.\nTo begin with, he is using a plain text editor with this keyboard. This editor always displays one string (possibly empty). Just after the editor is l... | [{"input": "01B0\n", "output": "00\n"}, {"input": "B010", "output": "010\n"}, {"input": "B110", "output": "110\n"}, {"input": "B011", "output": "011\n"}, {"input": "B101", "output": "101\n"}, {"input": "B111", "output": "111\n"}, {"input": "B100", "output": "100\n"}, {"input": "B001", "output": "001\n"}, {"input": "B00... | code_stdio |
[
{
"content": "Kolya Gerasimov loves kefir very much. He lives in year 1984 and knows all the details of buying this delicious drink. One day, as you probably know, he found himself in year 2084, and buying kefir there is much more complicated.\n\nKolya is hungry, so he went to the nearest milk shop. In 2084 you... | [{"input": "1000000000000000000\n999999998000000000\n999999999000000000\n999999998000000000\n", "output": " 3\n"}, {"input": "1\n1000000000000000000\n1000000000\n999999999\n", "output": " 0\n"}, {... | code_stdio |
[
{
"content": "In this Kata you are a game developer and have programmed the #1 MMORPG(Massively Multiplayer Online Role Playing Game) worldwide!!! Many suggestions came across you to make the game better, one of which you are interested in and will start working on at once.\n\nPlayers in the game have levels fr... | [{"input": "769832696988485\n170", "output": "[\"You have already reached level 170.\"]", "fn_name": "xp_to_target_lvl"}, {"input": "10396\n11", "output": "[\"You have already reached level 11.\"]", "fn_name": "xp_to_target_lvl"}, {"input": "2017\n4", "output": "[\"You have already reached level 4.\"]", "fn_name": "xp_... | code_functional |
[
{
"content": "## Task\n\nGiven a positive integer `n`, calculate the following sum: \n\n```\nn + n/2 + n/4 + n/8 + ...\n``` \n\nAll elements of the sum are the results of integer division.\n\n## Example\n\n```\n25 => 25 + 12 + 6 + 3 + 1 = 47\n```\n\nWrite Python code to solve this problem. Define a top-level ... | [{"input": "127", "output": "[247]", "fn_name": "halving_sum"}, {"input": "320", "output": "[638]", "fn_name": "halving_sum"}, {"input": "101", "output": "[198]", "fn_name": "halving_sum"}, {"input": "257", "output": "[512]", "fn_name": "halving_sum"}, {"input": "25", "output": "[47]", "fn_name": "halving_sum"}, {"inpu... | code_functional |
[
{
"content": "You are given strings S and T consisting of lowercase English letters.\nYou can perform the following operation on S any number of times:\nOperation: Choose two distinct lowercase English letters c_1 and c_2, then replace every occurrence of c_1 with c_2, and every occurrence of c_2 with c_1.\nDet... | [{"input": "yiizlygglzgpypipzllbzpwgblzziigpgpgywpggbpylpylzlzplwypgwizgpgbywiwwzpygzpgillgbzyiwpwzgppwlbpwzilwilbbbybgzlppgwgyypybbpgbwplzbbzpzbzzzzzzppbwipyzzylyyyibwipyzbyzpygppggibzzlgpzwyglglbywwiglyggbzyzwgpzillgybypbywygzpwzligpwlzwizbpwbzzybzyyglbplpzlgzzipplizbgpgpggylgzybplwyyggyiybppzzibzlpgwplilwigbypzzipgy... | code_stdio |
[
{
"content": "As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find in stores at reasonable prices.\n\nOne day, a group of three good friends living in the Matsunaga housin... | [{"input": "4 2\n50 40 100 80\n7 3\n400 139 100 700 200 600 500\n0 0", "output": "150\n2000\n"}, {"input": "4 2\n50 40 100 80\n7 3\n400 300 100 700 116 600 500\n0 0", "output": "150\n2100\n"}, {"input": "4 3\n50 40 100 80\n7 3\n400 290 000 1162 352 600 57\n0 0", "output": "220\n2404\n"}, {"input": "4 3\n97 59 100 113\n... | code_stdio |
[
{
"content": "A piece of paper contains an array of n integers a1, a2, ..., an. Your task is to find a number that occurs the maximum number of times in this array.\n\nHowever, before looking for such number, you are allowed to perform not more than k following operations — choose an arbitrary element from the ... | [{"input": "100 1000\n-281 191 -27 -286 -497 462 0 889 0 -350 -720 -507 916 0 -648 -942 -140 0 0 -877 66 576 -278 410 -792 -607 713 712 296 -828 -488 -129 508 -106 470 -263 -865 -506 -604 334 591 -40 220 0 0 198 -435 374 -34 254 970 0 549 100 555 326 91 0 -361 -835 472 823 -663 -456 0 91 295 126 383 141 476 609 518 545... | code_stdio |
[
{
"content": "Two neighboring kingdoms decided to build a wall between them with some gates to enable the citizens to go from one kingdom to another. Each time a citizen passes through a gate, he has to pay one silver coin.\n\nThe world can be represented by the first quadrant of a plane and the wall is built a... | [{"input": "100\nRUURUURRUURUUUUURRUUURRRRUURRURRURRRRUUUUUURRUURRRRURUUURUURURRRRRURUURRUURUURRUUURUUUUUURRUUUURUUUR\n", "output": "3\n"}, {"input": "100\nRUURUURRUURUUUUURRUUURRRRUURRURRURRRRUUUUUURRUURRRRURUUURUURURRRRRURUURRUURUURRUUURUUUUUURRUUUURUUUR\n", "output": "3\n"}, {"input": "100\nRUUURUUUURRUUUUUURUUURRUU... | code_stdio |
[
{
"content": "Little boy Gerald studies at school which is quite far from his house. That's why he has to go there by bus every day. The way from home to school is represented by a segment of a straight line; the segment contains exactly n + 1 bus stops. All of them are numbered with integers from 0 to n in the... | [{"input": "68 74\n51 54\n3 22\n12 24\n3 27\n32 42\n36 55\n60 64\n1 4\n4 23\n11 64\n54 62\n50 56\n21 34\n27 63\n15 54\n28 61\n13 57\n39 53\n12 32\n32 40\n33 67\n55 61\n33 67\n30 37\n15 49\n27 45\n21 41\n8 42\n24 63\n40 48\n28 41\n30 67\n0 4\n7 15\n27 59\n60 62\n25 65\n30 31\n38 67\n24 43\n14 64\n26 46\n8 12\n34 41\n32 ... | code_stdio |
[
{
"content": "Cyael is a teacher at a very famous school in Byteland and she is known by her students for being very polite to them and also to encourage them to get good marks on their tests.\nThen, if they get good marks she will reward them with candies :) However, she knows they are all very good at Mathema... | [{"input": "2\n17 0\n100 1", "output": "0 17\n100 0\n"}, {"input": "2\n17 0\n101 0", "output": "0 17\n0 101\n"}, {"input": "2\n17 0\n101 1", "output": "0 17\n101 0\n"}, {"input": "2\n10 0\n101 3", "output": "0 10\n33 2\n"}, {"input": "2\n18 0\n101 3", "output": "0 18\n33 2\n"}, {"input": "2\n18 0\n111 3", "output": "0 ... | code_stdio |
[
{
"content": "Let's define a good tree:It is a tree with k * n nodes labeled from 0 to k * n - 1\nNode i and node j are not adjacent, for all 0 ≤ i, j < k * n such that i div k = j div k (here div means integer division. E.g. 7 div 2 = 3)\n\nGiven n and k, how many different good trees are there?\n\n------ Inp... | [{"input": "11 11", "output": "459104785\n"}, {"input": "11 14", "output": "737454094\n"}, {"input": "11 28", "output": "685943622\n"}, {"input": "4 10", "output": "994788518\n"}, {"input": "6 10", "output": "835647629\n"}, {"input": "6 13", "output": "865042129\n"}, {"input": "2 13", "output": "748239339\n"}, {"input"... | code_stdio |
[
{
"content": "# Task\n Given a sorted array of integers `A`, find such an integer x that the value of `abs(A[0] - x) + abs(A[1] - x) + ... + abs(A[A.length - 1] - x)`\nis the smallest possible (here abs denotes the `absolute value`).\n\n If there are several possible answers, output the smallest one.\n\n# Examp... | [{"input": "[-10, -10, -10, -10, -10, -9, -9, -9, -8, -8, -7, -6, -5, -4, -3, -2, -1, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]", "output": "[15]", "fn_name": ... | code_functional |
[
{
"content": "At the first holiday in spring, the town Shortriver traditionally conducts a flower festival. Townsfolk wear traditional wreaths during these festivals. Each wreath contains exactly $k$ flowers.\n\nThe work material for the wreaths for all $n$ citizens of Shortriver is cut from the longest flowere... | [{"input": "100 15 6 10\n6 9 1 7 6 4 1 9 3 2 4 6 2 5 3 10 9 2 9 1 6 5 6 2 3 10 7 10 7 4 5 4 4 4 4 7 1 10 8 4 8 3 10 10 7 4 4 10 6 1 8 5 4 6 2 3 10 3 2 5 7 5 6 10 10 3 4 5 4 3 3 1 7 8 10 10 10 10 8 3 7 4 2 1 8 6 5 6 5 8 7 9 2 1 5 2 4 6 10 8\n6 9 7 8 7 1 4 3 5 8\n", "output": "2\n76 77 \n"}, {"input": "100 15 6 10\n3 2 3... | code_stdio |
[
{
"content": "Snuke has decided to construct a string that starts with A and ends with Z, by taking out a substring of a string s (that is, a consecutive part of s).\nFind the greatest length of the string Snuke can construct. Here, the test set guarantees that there always exists a substring of s that starts w... | [{"input": "HASFJGHOGAKZZFEGA\n", "output": "12\n"}, {"input": "HASFJGHOGAK[ZFEGA", "output": "12\n"}, {"input": "IBAG[IHNGFKKZSFGB", "output": "11\n"}, {"input": "AIEFZGKAFOFGJZSAH", "output": "14\n"}, {"input": "ICAF[IHNGFKZKSFGB", "output": "10\n"}, {"input": "AGEFZJG@GNHHZFSAK", "output": "13\n"}, {"input": "HASFEH... | code_stdio |
[
{
"content": "There are two cameras which observe the up line and the down line respectively on the double lane (please see the following figure). These cameras are located on a line perpendicular to the lane, and we call the line 'monitoring line.' (the red line in the figure)\n\n\n<image>\n\n\nMonitoring syst... | [{"input": "4 5\n20 35 110 70\n15 30 40 84 113\n3 2\n10 20 30\n81 60\n0 1\n100\n1 1\n10\n83\n0 0", "output": "30\n30\n100\n73\n"}, {"input": "4 5\n20 60 110 70\n15 30 40 84 113\n3 2\n10 20 30\n42 60\n0 1\n100\n1 1\n10\n83\n0 0", "output": "26\n18\n100\n73\n"}, {"input": "4 5\n4 35 110 134\n15 30 40 84 113\n3 2\n10 20 3... | code_stdio |
[
{
"content": "Given is a positive even number N.\n\nFind the number of strings s of length N consisting of `A`, `B`, and `C` that satisfy the following condition:\n\n* s can be converted to the empty string by repeating the following operation:\n* Choose two consecutive characters in s and erase them. However, ... | [{"input": "1100000", "output": "298228697\n"}, {"input": "0110000", "output": "784164463\n"}, {"input": "0110010", "output": "189920713\n"}, {"input": "1100010", "output": "865187132\n"}, {"input": "0100100", "output": "545699273\n"}, {"input": "1110010", "output": "816062167\n"}, {"input": "0110110", "output": "97385... | code_stdio |
[
{
"content": "Alice, the president of club FCB, wants to build a team for the new volleyball tournament. The team should consist of p players playing in p different positions. She also recognizes the importance of audience support, so she wants to select k people as part of the audience.\n\nThere are n people i... | [{"input": "6 2 3\n78 93 9 17 13 78\n80 97\n30 52\n49 17\n56 68\n60 36\n84 55\n", "output": "377\n"}, {"input": "6 2 3\n78 93 9 17 13 78\n80 12\n30 52\n49 17\n56 68\n60 36\n84 55\n", "output": "377\n"}, {"input": "6 2 3\n78 93 9 17 13 78\n80 97\n30 52\n26 17\n56 68\n60 36\n84 55\n", "output": "377"}, {"input": "3 2 1\n... | code_stdio |
[
{
"content": "A number is self-descriptive when the n'th digit describes the amount n appears in the number.\n\nE.g. 21200:\n\nThere are two 0's in the number, so the first digit is 2.\n\nThere is one 1 in the number, so the second digit is 1.\n\nThere are two 2's in the number, so the third digit is 2.\n\nTher... | [{"input": "6210001000", "output": "[true]", "fn_name": "self_descriptive"}, {"input": "51120111", "output": "[false]", "fn_name": "self_descriptive"}, {"input": "42101000", "output": "[true]", "fn_name": "self_descriptive"}, {"input": "3211000", "output": "[true]", "fn_name": "self_descriptive"}, {"input": "21230", "o... | code_functional |
[
{
"content": "This version of the problem differs from the next one only in the constraint on n.\n\nNote that the memory limit in this problem is lower than in others.\n\nYou have a vertical strip with n cells, numbered consecutively from 1 to n from top to bottom.\n\nYou also have a token that is initially pla... | [{"input": "162685 187160003\n", "output": "175888140\n"}, {"input": "200000 316925344\n", "output": "253547906\n"}, {"input": "140750 887458748\n", "output": "669831877\n"}, {"input": "197426 364348492\n", "output": "289708472\n"}, {"input": "199862 999999937\n", "output": "750469605"}, {"input": "124953 922406879\n",... | code_stdio |
[
{
"content": "Limak and Radewoosh are going to compete against each other in the upcoming algorithmic contest. They are equally skilled but they won't solve problems in the same order.\n\nThere will be n problems. The i-th problem has initial score p_{i} and it takes exactly t_{i} minutes to solve it. Problems ... | [{"input": "50 1\n6 17 44 82 94 127 134 156 187 211 212 252 256 292 294 303 352 355 379 380 398 409 424 434 480 524 584 594 631 714 745 756 777 778 789 793 799 821 841 849 859 878 879 895 925 932 944 952 958 990\n15 16 40 42 45 71 143 100 117 120 174 181 186 318 221 268 289 332 376 394 403 409 411 444 471 487 499 539 5... | code_stdio |
[
{
"content": "# Background\n\nMy pet bridge-maker ants are marching across a terrain from left to right.\n\nIf they encounter a gap, the first one stops and then next one climbs over him, then the next, and the next, until a bridge is formed across the gap. \n\nWhat clever little things they are!\n\nNow all the... | [{"input": "\"JIHGFEDCBA\"\n\"--........------.-........-........---....-----\"", "output": "[\"GFEDCBAJIH\"]", "fn_name": "ant_bridge"}, {"input": "\"JIHGFEDCBA\"\n\"-.....------........-.......-.......----\"", "output": "[\"CBAJIHGFED\"]", "fn_name": "ant_bridge"}, {"input": "\"JIHGFEDCBA\"\n\"-------.......-.......-... | code_functional |
[
{
"content": "There is an N-car train.\nYou are given an integer i. Find the value of j such that the following statement is true: \"the i-th car from the front of the train is the j-th car from the back.\"\n\n-----Constraints-----\n - 1 \\leq N \\leq 100\n - 1 \\leq i \\leq N\n\n-----Input-----\nInput is given... | [{"input": "-108 -1", "output": "-106\n"}, {"input": "-108 71", "output": "-178\n"}, {"input": "-159 71", "output": "-229\n"}, {"input": "-116 71", "output": "-186\n"}, {"input": "-74 36", "output": "-109\n"}, {"input": "-74 71", "output": "-144\n"}, {"input": "-93 71", "output": "-163\n"}, {"input": "-97 71", "output"... | code_stdio |
[
{
"content": "As 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 coming. You know the number of voters and the number of parties — $n$ and $m$... | [{"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"}, {"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"}, {"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"}, {"input": "10 10... | code_stdio |
[
{
"content": "A triangular number is the number of dots in an equilateral triangle uniformly filled with dots. For example, three dots can be arranged in a triangle; thus three is a triangular number. The n-th triangular number is the number of dots in a triangle with n dots on a side. <image>. You can learn mo... | [{"input": "300\n", "output": "YES\n"}, {"input": "406\n", "output": "YES\n"}, {"input": "253\n", "output": "YES\n"}, {"input": "276\n", "output": "YES\n"}, {"input": "496\n", "output": "YES\n"}, {"input": "351\n", "output": "YES\n"}, {"input": "378\n", "output": "YES\n"}, {"input": "153\n", "output": "YES\n"}, {"input... | code_stdio |
[
{
"content": "Takahashi has come to an integer shop to buy an integer.\nThe shop sells the integers from 1 through 10^9. The integer N is sold for A \\times N + B \\times d(N) yen (the currency of Japan), where d(N) is the number of digits in the decimal notation of N.\nFind the largest integer that Takahashi c... | [{"input": "1000000000 1000000000 1000000000000000000\n", "output": "999999991\n"}, {"input": "773361868 125660016 773361869833880887\n", "output": "1000000000\n"}, {"input": "839296263 462224593 839296268591205063\n", "output": "1000000000\n"}, {"input": "450968417 430302156 443135970740411047\n", "output": "982631931... | code_stdio |
[
{
"content": "Read problems statements in Mandarin Chinese and Russian as well. \n\nPetr, Nikita G. and Nikita are the most influential music critics in Saint-Petersburg. They have recently downloaded their favorite band's new album and going to listen to it. Nikita claims that the songs of entire album should ... | [{"input": "3\n6\n6\n6", "output": "14.7\n14.7\n14.7\n"}, {"input": "3\n1\n6\n6", "output": "1.0\n14.7\n14.7\n"}, {"input": "3\n2\n6\n6", "output": "3.0\n14.7\n14.7\n"}, {"input": "3\n6\n1\n6", "output": "14.7\n1.0\n14.7\n"}, {"input": "3\n6\n2\n6", "output": "14.7\n3.0\n14.7\n"}, {"input": "3\n3\n6\n6", "output": "5.5... | code_stdio |
[
{
"content": "Devu and his brother love each other a lot. As they are super geeks, they only like to play with arrays. They are given two arrays a and b by their father. The array a is given to Devu and b to his brother. \n\nAs Devu is really a naughty kid, he wants the minimum value of his array a should be at... | [{"input": "10 10\n23 101 38 38 73 54 59 69 44 150\n100 100 100 100 100 100 100 100 100 100\n", "output": "402\n"}, {"input": "10 10\n23 101 38 38 73 54 59 69 44 150\n100 100 100 100 100 100 100 101 100 100\n", "output": "403\n"}, {"input": "10 10\n23 100 38 74 73 54 59 69 44 139\n100 100 100 100 110 100 100 100 100 10... | code_stdio |
[
{
"content": "VK news recommendation system daily selects interesting publications of one of $n$ disjoint categories for each user. Each publication belongs to exactly one category. For each category $i$ batch algorithm selects $a_i$ publications.\n\nThe latest A/B test suggests that users are reading recommend... | [{"input": "40\n19 20 8 13 13 17 1 14 15 20 14 17 2 9 9 10 19 16 6 12 9 7 20 5 12 2 4 4 12 5 4 11 8 1 2 8 11 19 18 4\n52258 5648 46847 9200 63940 79328 118413 54479 1788 60107 8234 64215 15419 84411 50307 78075 92548 17867 43456 7970 1390 99373 97297 90662 82950 678 79356 51351 2794 82477 16508 19254 81295 9711 72350 1... | code_stdio |
[
{
"content": "We have a permutation p = {p_1,\\ p_2,\\ ...,\\ p_n} of {1,\\ 2,\\ ...,\\ n}.\nPrint the number of elements p_i (1 < i < n) that satisfy the following condition:\n - p_i is the second smallest number among the three numbers p_{i - 1}, p_i, and p_{i + 1}.\n\n-----Constraints-----\n - All values in ... | [{"input": "20\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20\n", "output": "18\n"}, {"input": "20\n20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1\n", "output": "18\n"}, {"input": "20\n1 20 2 19 3 18 4 17 5 16 6 15 7 14 8 13 9 12 10 11\n", "output": "0\n"}, {"input": "20\n20 1 2 19 3 18 4 17 5 16 6 15 7 14 8 1... | code_stdio |
[
{
"content": "Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from $1$ to $9$). In this problem, we use one digit and one lowercase le... | [{"input": "1s 2s 3s\n", "output": "0\n"}, {"input": "9m 9m 9m\n", "output": "0\n"}, {"input": "3p 9m 2p\n", "output": "1\n"}, {"input": "8p 2s 9m\n", "output": "2\n"}, {"input": "5s 8m 5s\n", "output": "1\n"}, {"input": "9s 4s 3m\n", "output": "2\n"}, {"input": "4p 8m 9s\n", "output": "2\n"}, {"input": "8s 5s 7p\n", "... | code_stdio |
[
{
"content": "Fox Ciel is developing an artificial intelligence (AI) for a game. This game is described as a game tree T with n vertices. Each node in the game has an evaluation value which shows how good a situation is. This value is the same as maximum value of child nodes’ values multiplied by -1. Values on ... | [{"input": "3\n-1 2 -1\n2 2 3\n0\n1", "output": "2 2\n"}, {"input": "3\n-2 4 -1\n2 2 3\n0\n0", "output": "2 2\n"}, {"input": "3\n-2 4 -2\n2 2 3\n0\n0", "output": "2 2\n"}, {"input": "3\n-2 2 -1\n2 2 3\n0\n1", "output": "2 2\n"}, {"input": "3\n-4 4 -1\n2 2 3\n0\n0", "output": "2 2\n"}, {"input": "3\n-1 -1 0\n2 2 3\n0\n1... | code_stdio |
[
{
"content": "We have N locked treasure boxes, numbered 1 to N.\nA shop sells M keys. The i-th key is sold for a_i yen (the currency of Japan), and it can unlock b_i of the boxes: Box c_{i1}, c_{i2}, ..., c_{i{b_i}}. Each key purchased can be used any number of times.\nFind the minimum cost required to unlock a... | [{"input": "12 1000\n100000 12\n1 2 3 4 5 6 7 8 9 10 11 12\n100000 12\n1 2 3 4 5 6 7 8 9 10 11 12\n100000 12\n1 2 3 4 5 6 7 8 9 10 11 12\n100000 12\n1 2 3 4 5 6 7 8 9 10 11 12\n100000 12\n1 2 3 4 5 6 7 8 9 10 11 12\n100000 12\n1 2 3 4 5 6 7 8 9 10 11 12\n100000 12\n1 2 3 4 5 6 7 8 9 10 11 12\n100000 12\n1 2 3 4 5 6 7 8... | code_stdio |
[
{
"content": "You're given an array $a$ of length $n$. You can perform the following operation on it as many times as you want: Pick two integers $i$ and $j$ $(1 \\le i,j \\le n)$ such that $a_i+a_j$ is odd, then swap $a_i$ and $a_j$. \n\nWhat is lexicographically the smallest array you can obtain?\n\nAn array... | [{"input": "36\n398353608 662365068 456456182 594572278 958026500 524977116 903404403 382220192 142092809 137516115 522872496 527845939 116437661 423289717 907151540 961740613 981968938 143206666 773454188 691188206 95402302 602570397 986508327 617421132 46091276 866348540 485487643 843511039 768135914 68050875 2627811... | code_stdio |
[
{
"content": "There are n children in Jzzhu's school. Jzzhu is going to give some candies to them. Let's number all the children from 1 to n. The i-th child wants to get at least a_{i} candies.\n\nJzzhu asks children to line up. Initially, the i-th child stands at the i-th place of the line. Then Jzzhu start di... | [{"input": "100 20\n21 19 61 70 54 97 98 14 61 72 25 94 24 56 55 25 12 80 76 11 35 17 80 26 11 94 52 47 84 61 10 2 74 25 10 21 2 79 55 50 30 75 10 64 44 5 60 96 52 16 74 41 20 77 20 44 8 86 74 36 49 61 99 13 54 64 19 99 50 43 12 73 48 48 83 55 72 73 63 81 30 27 95 9 97 82 24 3 89 90 33 14 47 88 22 78 12 75 58 67\n", "o... | code_stdio |
[
{
"content": "Create a function that transforms any positive number to a string representing the number in words. The function should work for all numbers between 0 and 999999.\n\n### Examples\n\n```\nnumber2words(0) ==> \"zero\"\nnumber2words(1) ==> \"one\"\nnumber2words(9) ==> \"nine\"\nnumber2words(10... | [{"input": "888887", "output": "[\"eight hundred eighty-eight thousand eight hundred eighty-seven\"]", "fn_name": "number2words"}, {"input": "99997", "output": "[\"ninety-nine thousand nine hundred ninety-seven\"]", "fn_name": "number2words"}, {"input": "7217", "output": "[\"seven thousand two hundred seventeen\"]", "f... | code_functional |
[
{
"content": "Vasya follows a basketball game and marks the distances from which each team makes a throw. He knows that each successful throw has value of either 2 or 3 points. A throw is worth 2 points if the distance it was made from doesn't exceed some value of d meters, and a throw is worth 3 points if the ... | [{"input": "18\n450 3726 12063 42865 29689 35320 33937 4067 45951 80313 53004 59541 75551 75836 151186 81297 93876 96211\n47\n3393 11375 6494 7645 9549 8499 11145 13121 14801 15578 24104 24125 25871 31280 35036 38969 29966 41342 42708 46033 47491 25404 49152 51905 55002 9827 56565 57901 104645 37176 66075 87521 68397 1... | code_stdio |
[
{
"content": "Adilbek was assigned to a special project. For Adilbek it means that he has $n$ days to run a special program and provide its results. But there is a problem: the program needs to run for $d$ days to calculate the results.\n\nFortunately, Adilbek can optimize the program. If he spends $x$ ($x$ is ... | [{"input": "50\n1000000000 1000000000\n999999999 1000000000\n999999998 1000000000\n999999997 1000000000\n999999996 1000000000\n999999995 1000000000\n999999994 1000000000\n999999900 1000000000\n1 11\n2 11\n3 11\n4 11\n5 11\n6 11\n7 11\n8 11\n9 11\n10 11\n11 11\n4 18\n4 20\n3 19\n3 18\n3 167\n3 15\n3 14\n3 13\n3 12\n3 11... | code_stdio |
[
{
"content": "You are given a string S of length n with each character being one of the first m lowercase English letters. \n\nCalculate how many different strings T of length n composed from the first m lowercase English letters exist such that the length of LCS (longest common subsequence) between S and T is ... | [{"input": "100 26\njysrixyptvsesnapfljeqkytlpeepjopspmkviqdqbdkylvfiawhdjjdvqqvcjmmsgfdmpjwahuwhgsyfcgnefzmqlvtvqqfbfsf\n", "output": "237400\n"}, {"input": "100 26\njysrixyptvsesnapfljeqkytlpeepjopspmkviqdqbdkylvfiawhdjjdvqqvcjmmsgfdmpjwahuwhgsyfcgnefzmqlvtvqqfbfsf\n", "output": "237400\n"}, {"input": "100 26\njysrix... | code_stdio |
[
{
"content": "Read problems statements in Mandarin Chinese and Russian as well. \n\nEuler's phi function for a positive integer N is usually denoted as φ(N) and defined as the number of positive integers less than or equal to N that are coprime with N. Let's call a positive integer N a super number if N can b... | [{"input": "3\n2 1\n229 975\n12 34", "output": "0\n12\n5\n"}, {"input": "3\n2 1\n229 975\n6 62", "output": "0\n12\n10\n"}, {"input": "3\n3 10\n48 237\n18 32", "output": "3\n11\n3\n"}, {"input": "3\n1 10\n48 237\n18 32", "output": "5\n11\n3\n"}, {"input": "3\n2 1\n396 1220\n3 12", "output": "0\n10\n4\n"}, {"input": "3\n... | code_stdio |
[
{
"content": "In cryptography, Caesar cipher is one of the simplest and most widely known encryption method. Caesar cipher is a type of substitution cipher in which each letter in the text is replaced by a letter some fixed number of positions down the alphabet. For example, with a shift of 1, 'a' would be repl... | [{"input": "xlmw mw xli tmgxyvi xlex m xsso mr ilx xvmt.", "output": "this is the picture that i took in eht trip.\n"}, {"input": "xlmw mw xli tmgxyvi xlex m ossx mr ilx xvmt.", "output": "this is the picture that i koot in eht trip.\n"}, {"input": "xlmw mw xli tmgxyvi xlex m ossx mr ilx xwmt.", "output": "this is the ... | code_stdio |
[
{
"content": "One day, early in the morning, you decided to buy yourself a bag of chips in the nearby store. The store has chips of $n$ different flavors. A bag of the $i$-th flavor costs $a_i$ burles.\n\nThe store may run out of some flavors, so you'll decide which one to buy after arriving there. But there ar... | [{"input": "4\n1\n1337\n3\n31 7 1\n5\n0 2 2 6 10\n3\n9 143 1515\n", "output": "446\n11\n4\n506\n"}, {"input": "4\n1\n1337\n3\n10 2 1\n5\n2 2 3 4 5\n3\n10 115 1546\n", "output": "446\n5\n3\n516\n"}, {"input": "4\n1\n1337\n3\n31 7 1\n5\n0 2 2 6 10\n3\n9 105 940\n", "output": "446\n11\n4\n314\n"}, {"input": "4\n1\n1337\n3... | code_stdio |
[
{
"content": "You are given a string $s$ consisting of exactly $n$ characters, and each character is either '0', '1' or '2'. Such strings are called ternary strings.\n\nYour task is to replace minimum number of characters in this string with other characters to obtain a balanced ternary string (balanced ternary... | [{"input": "69\n000000000000000000000000000000000000000000000000000000000000000000000\n", "output": "000000000000000000000001111111111111111111111122222222222222222222222\n"}, {"input": "69\n000000000000000000000000000000000000000000000000000000000000000000000\n", "output": "00000000000000000000000111111111111111111111... | code_stdio |
[
{
"content": "You are given an array $a$ of length $2n$. Consider a partition of array $a$ into two subsequences $p$ and $q$ of length $n$ each (each element of array $a$ should be in exactly one subsequence: either in $p$ or in $q$).\n\nLet's sort $p$ in non-decreasing order, and $q$ in non-increasing order, w... | [{"input": "16\n998244362 998244362 1545401713 998244362 998244362 998244362 998244362 998244362 1483557929 998244362 998244362 356870606 998244362 998244362 998244362 998244362 998244363 998244363 998244363 998244363 998244363 998244363 998244363 998244363 998244363 998244363 998244363 998244363 1290068308 998244363 9... | code_stdio |
[
{
"content": "Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. \n\nInspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and whi... | [{"input": "wwwbbwbbbwbwbwwbwwbbbwbwbwwbbbwbwwwbwwbwbbbbwwbwwwwwbwwwwwwwwbbwwwwbbbbbwbwbbwwbbbbbwbwbbwbwwwbbwwbbbwwwbbwwbwwbbbbwwbwbbwbwwbbwbwbwbbwwbwwwbwbwbbbwwwwwwbwwbbbwwbwwbwbwwwbbwwwwwwwwwbwwbwbbbwbwwwwbwwbbwbbwbwwbwwbwwbbwbbwwwwbwwwbwwwbwbwwwbbwwbbwwbwbwwwwwwbwbwwwwbbwwwbwbwwwbbwwwwwbwwbwbbbbbwbwwbbbbbbbwbbwbbwww... | code_stdio |
[
{
"content": "Alice and Bob are controlling a robot. They each have one switch that controls the robot.\n\nAlice started holding down her button A second after the start-up of the robot, and released her button B second after the start-up.\n\nBob started holding down his button C second after the start-up, and ... | [{"input": "56 100 33 100\n", "output": "44\n"}, {"input": "0 100 0 100\n", "output": "100\n"}, {"input": "0 75 25 100\n", "output": "50\n"}, {"input": "10 90 20 80\n", "output": "60\n"}, {"input": "77 88 34 96\n", "output": "11\n"}, {"input": "0 100 99 100\n", "output": "1\n"}, {"input": "0 148 36 100", "output": "64\... | code_stdio |
[
{
"content": "There's a new security company in Paris, and they decided to give their employees an algorithm to make first name recognition faster. In the blink of an eye, they can now detect if a string is a first name, no matter if it is a one-word name or an hyphenated name. They're given this documentation ... | [{"input": "\"Bernard-Henry-Levy\"", "output": "[true]", "fn_name": "show_me"}, {"input": "\"Jean-Luc-Picard-\"", "output": "[false]", "fn_name": "show_me"}, {"input": "\"A-a-a-a----a-a\"", "output": "[false]", "fn_name": "show_me"}, {"input": "\"Z-------------\"", "output": "[false]", "fn_name": "show_me"}, {"input": ... | code_functional |
[
{
"content": "You a captain of a ship. Initially you are standing in a point $(x_1, y_1)$ (obviously, all positions in the sea can be described by cartesian plane) and you want to travel to a point $(x_2, y_2)$. \n\nYou know the weather forecast — the string $s$ of length $n$, consisting only of letters U, D, L... | [{"input": "0 0\n1000000000 1000000000\n2\nDR\n", "output": "2000000000\n"}, {"input": "0 0\n1000000000 1000000000\n2\nDR\n", "output": "2000000000\n"}, {"input": "0 0\n1000000010 1000000000\n2\nDR\n", "output": "2000000010\n"}, {"input": "1 0\n1010000000 1000000000\n2\nDR\n", "output": "2010000000\n"}, {"input": "0 0\... | code_stdio |
[
{
"content": "You are policeman and you are playing a game with Slavik. The game is turn-based and each turn consists of two phases. During the first phase you make your move and during the second phase Slavik makes his move.\n\nThere are $n$ doors, the $i$-th door initially has durability equal to $a_i$.\n\nDu... | [{"input": "100 2 2\n1 73456 13268 11914 2 1 2 1 1 2 1 1 87480 65464 2 40468 7016 70750 28675 92808 74100 22702 47484 22345 61255 1 104206 62017 89058 61094 76626 1 171051 98876 97451 18228 2 2 1 38979 1 144831 1 43289 73591 2 1 91061 89577 13598 1 2 2 57020 2 82044 24974 1 1 958 8399 1 98709 10870 1 66150 2 79527 2 2 ... | code_stdio |
[
{
"content": "Gennady is one of the best child dentists in Berland. Today n children got an appointment with him, they lined up in front of his office.\n\nAll children love to cry loudly at the reception at the dentist. We enumerate the children with integers from 1 to n in the order they go in the line. Every ... | [{"input": "10\n9 8 8\n2 9 33\n10 7 42\n7 2 18\n3 5 82\n9 9 25\n3 2 86\n1 5 49\n5 3 72\n4 4 71\n", "output": "10\n1 2 3 4 5 6 7 8 9 10 "}, {"input": "10\n9 8 8\n2 9 33\n10 7 42\n7 2 18\n3 4 82\n9 9 25\n3 2 86\n1 5 49\n5 3 72\n4 4 71\n", "output": "10\n1 2 3 4 5 6 7 8 9 10 "}, {"input": "10\n9 8 8\n2 9 33\n10 7 42\n8 2 ... | code_stdio |
[
{
"content": "Tree is a connected graph without cycles. A leaf of a tree is any vertex connected with exactly one other vertex.\n\nYou are given a tree with n vertices and a root in the vertex 1. There is an ant in each leaf of the tree. In one second some ants can simultaneously go to the parent vertex from th... | [{"input": "12\n1 2\n1 3\n1 4\n2 5\n2 6\n3 7\n3 12\n3 9\n8 10\n8 11\n8 12\n", "output": "5\n"}, {"input": "12\n1 2\n1 3\n1 4\n2 5\n2 6\n5 7\n3 8\n3 9\n8 10\n8 11\n8 12\n", "output": "5\n"}, {"input": "12\n1 2\n2 3\n1 4\n2 5\n2 6\n5 7\n3 8\n3 9\n8 10\n8 11\n8 12\n", "output": "7\n"}, {"input": "12\n1 2\n1 3\n1 4\n2 5\n3... | code_stdio |
[
{
"content": "Luke Skywalker gave Chewbacca an integer number x. Chewbacca isn't good at numbers but he loves inverting digits in them. Inverting digit t means replacing it with digit 9 - t. \n\nHelp Chewbacca to transform the initial number x to the minimum possible positive number by inverting some (possibly,... | [{"input": "1000000000000000000\n", "output": "1000000000000000000\n"}, {"input": "1000000000000000000\n", "output": "1000000000000000000\n"}, {"input": "1000001000000000000\n", "output": "1000001000000000000\n"}, {"input": "1000001000000000010\n", "output": "1000001000000000010\n"}, {"input": "1010001000000000010\n", ... | code_stdio |
[
{
"content": "Let f(A, B), where A and B are positive integers, be the string satisfying the following conditions:\n\n* f(A, B) has length A + B;\n* f(A, B) contains exactly A letters `A` and exactly B letters `B`;\n* The length of the longest substring of f(A, B) consisting of equal letters (ex., `AAAAA` or `B... | [{"input": "5\n2 3 1 5\n6 7 1 10\n2 3 1 4\n6 12 2 10\n8 10 10 14", "output": "BABAB\nBABABABABA\nBABA\nBBABBABBA\nABBAB\n"}, {"input": "5\n2 3 1 5\n6 7 1 10\n2 3 1 4\n6 12 3 10\n8 10 10 14", "output": "BABAB\nBABABABABA\nBABA\nBABBABBA\nABBAB\n"}, {"input": "5\n2 3 1 5\n6 7 1 10\n2 3 1 4\n6 12 3 7\n8 10 6 14", "output"... | code_stdio |
[
{
"content": "The cities of Byteland and Berland are located on the axis $Ox$. In addition, on this axis there are also disputed cities, which belong to each of the countries in their opinion. Thus, on the line $Ox$ there are three types of cities: the cities of Byteland, the cities of Berland, disputed citi... | [{"input": "15\n-9518 R\n-6858 P\n-6726 B\n-6486 R\n-4496 P\n-4191 P\n-772 B\n-258 R\n-194 P\n1035 R\n2297 P\n4816 B\n5779 R\n9342 B\n9713 B\n", "output": "25088\n"}, {"input": "15\n-9518 R\n-6858 P\n-6726 B\n-6486 R\n-4496 P\n-4191 P\n-772 B\n-258 R\n-194 P\n1035 R\n2297 P\n4816 B\n5779 R\n9342 B\n9713 B\n", "output":... | code_stdio |
[
{
"content": "Blake is a CEO of a large company called \"Blake Technologies\". He loves his company very much and he thinks that his company should be the best. That is why every candidate needs to pass through the interview that consists of the following problem.\n\nWe define function f(x, l, r) as a bitwise O... | [{"input": "25\n12 30 47 109 81 124 80 33 38 48 29 78 96 48 96 27 80 77 102 65 80 113 31 194 35\n25 64 177 13 12 6 111 80 85 16 61 119 23 65 73 65 20 95 124 18 28 79 125 106 116\n", "output": "510\n"}, {"input": "25\n12 30 47 109 81 124 80 33 38 48 29 78 96 48 96 27 80 77 102 65 80 113 31 194 35\n25 64 177 13 12 6 111 ... | code_stdio |
[
{
"content": "Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.\n\nPetya calls a number almost lucky if it could be evenly divided by some luck... | [{"input": "1000\n", "output": "YES\n"}, {"input": "477\n", "output": "YES\n"}, {"input": "124\n", "output": "YES\n"}, {"input": "480\n", "output": "YES\n"}, {"input": "141\n", "output": "YES\n"}, {"input": "882\n", "output": "YES\n"}, {"input": "799\n", "output": "YES\n"}, {"input": "444\n", "output": "YES\n"}, {"inpu... | code_stdio |
[
{
"content": "Let's introduce the designation <image>, where x is a string, n is a positive integer and operation \" + \" is the string concatenation operation. For example, [abc, 2] = abcabc.\n\nWe'll say that string s can be obtained from string t, if we can remove some characters from string t and obtain str... | [{"input": "10000000 10000000\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n", "output": "1\n"}, {"input": "10000000 1\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa... | code_stdio |
[
{
"content": "Your task is to create a new implementation of `modpow` so that it computes `(x^y)%n` for large `y`. The problem with the current implementation is that the output of `Math.pow` is so large on our inputs that it won't fit in a 64-bit float.\n\nYou're also going to need to be efficient, because we'... | [{"input": "31\n902938423012\n1023", "output": "[961]", "fn_name": "power_mod"}, {"input": "29\n1013293125\n492", "output": "[161]", "fn_name": "power_mod"}, {"input": "13\n81230123\n22", "output": "[19]", "fn_name": "power_mod"}, {"input": "5\n100000000\n19", "output": "[5]", "fn_name": "power_mod"}, {"input": "11\n10... | code_functional |
[
{
"content": "Anadi has a set of dominoes. Every domino has two parts, and each part contains some dots. For every $a$ and $b$ such that $1 \\leq a \\leq b \\leq 6$, there is exactly one domino with $a$ dots on one half and $b$ dots on the other half. The set contains exactly $21$ dominoes. Here is an exact ill... | [{"input": "7 21\n1 2\n1 3\n1 4\n1 5\n1 6\n1 7\n2 3\n2 4\n2 5\n2 6\n2 7\n3 4\n3 5\n3 6\n3 7\n4 5\n4 6\n4 7\n5 6\n5 7\n6 7\n", "output": "16\n"}, {"input": "7 21\n3 5\n7 2\n2 3\n6 5\n5 2\n4 7\n2 6\n2 4\n6 7\n5 1\n1 4\n4 5\n5 7\n4 6\n3 1\n1 2\n3 4\n7 1\n3 7\n6 1\n3 6\n", "output": "16\n"}, {"input": "7 21\n3 5\n7 2\n2 3\... | code_stdio |
[
{
"content": "How many integer sequences A_1,A_2,\\ldots,A_N of length N satisfy all of the following conditions?\n - 0 \\leq A_i \\leq 9\n - There exists some i such that A_i=0 holds.\n - There exists some i such that A_i=9 holds.\nThe answer can be very large, so output it modulo 10^9 + 7.\n\n-----Constraints... | [{"input": "1000000\n", "output": "787616419\n"}, {"input": "260522\n", "output": "765255076\n"}, {"input": "914575\n", "output": "875983450\n"}, {"input": "436426\n", "output": "851976198\n"}, {"input": "979445\n", "output": "664003445\n"}, {"input": "648772\n", "output": "256544986\n"}, {"input": "690081\n", "output"... | code_stdio |
[
{
"content": "We have N voting papers. The i-th vote (1 \\leq i \\leq N) has the string S_i written on it.\nPrint all strings that are written on the most number of votes, in lexicographical order.\n\n-----Constraints-----\n - 1 \\leq N \\leq 2 \\times 10^5\n - S_i (1 \\leq i \\leq N) are strings consisting of ... | [{"input": "8\nfubfalo\nbuefalo\nbuffamo\nolaffub\nouafflb\nomaffub\nbuffalo\nbuofalf", "output": "buefalo\nbuffalo\nbuffamo\nbuofalf\nfubfalo\nolaffub\nomaffub\nouafflb\n"}, {"input": "8\nfubfalo\nbuefola\nbuffamo\nolaffub\nouafflb\nomaffub\nbuffalo\nbuofalf", "output": "buefola\nbuffalo\nbuffamo\nbuofalf\nfubfalo\nol... | code_stdio |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.