messages listlengths 1 1 | ground_truth stringlengths 156 726k | dataset stringclasses 2
values |
|---|---|---|
[
{
"content": "Ibis is fighting with a monster.\nThe health of the monster is H.\nIbis can cast N kinds of spells. Casting the i-th spell decreases the monster's health by A_i, at the cost of B_i Magic Points.\nThe same spell can be cast multiple times. There is no way other than spells to decrease the monster's... | [{"input": "1832 947\n4182 1443\n3979 4739\n5500 1039\n9994 9474\n7064 5254\n3587 2902\n6074 3873\n3865 9760\n8970 4251\n6222 8535\n9192 643\n5820 6677\n9711 4431\n9112 6134\n8614 2404\n9041 3356\n7574 5999\n9710 6045\n2463 3743\n7637 6723\n7802 9816\n5829 2411\n8800 3617\n9653 7\n6034 1399\n5178 9084\n7630 9624\n2005 ... | code_stdio |
[
{
"content": "# Making Change\n\nComplete the method that will determine the minimum number of coins needed to make change for a given amount in American currency.\n\nCoins used will be half-dollars, quarters, dimes, nickels, and pennies, worth 50¢, 25¢, 10¢, 5¢ and 1¢, respectively. They'll be represented by t... | [{"input": "91", "output": "[{\"H\": 1, \"Q\": 1, \"D\": 1, \"N\": 1, \"P\": 1}]", "fn_name": "make_change"}, {"input": "239", "output": "[{\"H\": 4, \"Q\": 1, \"D\": 1, \"P\": 4}]", "fn_name": "make_change"}, {"input": "43", "output": "[{\"Q\": 1, \"D\": 1, \"N\": 1, \"P\": 3}]", "fn_name": "make_change"}, {"input": "... | code_functional |
[
{
"content": "Write a program which reverses a given string str.\n\n\n\nInput\n\nstr (the size of str ≤ 20) is given in a line.\n\nOutput\n\nPrint the reversed str in a line.\n\nExample\n\nInput\n\nw32nimda\n\n\nOutput\n\nadmin23w\n\nWrite Python code to solve this problem. Your program should read the input fr... | [{"input": "w32njmda", "output": "admjn23w\n"}, {"input": "admjn23w", "output": "w32njmda\n"}, {"input": "acmjn23w", "output": "w32njmca\n"}, {"input": "3cmjn2aw", "output": "wa2njmc3\n"}, {"input": "3dmjn2aw", "output": "wa2njmd3\n"}, {"input": "wa2njmd3", "output": "3dmjn2aw\n"}, {"input": "xa2njmd3", "output": "3dmj... | code_stdio |
[
{
"content": "Joe has been hurt on the Internet. Now he is storming around the house, destroying everything in his path.\n\nJoe's house has n floors, each floor is a segment of m cells. Each cell either contains nothing (it is an empty cell), or has a brick or a concrete wall (always something one of three). It... | [{"input": "20 20\n..+#+.+++.+++#+..#++\n..####+++#..++#+.+.+\n+.+..+++..#.++++++++\n+##++..+.##..#+++.++\n++.+.+.+.++++.+++.++\n.+++++.+#+++++...+#+\n.++.#+++++++++.++.++\n...+.++++++.++#...++\n+++.+++.+....#....+.\n.++++++.+.+..++.++##\n.+..+..++#.+..++++++\n+..#+++++..+##+#++.+\n+.+#+#....+.#+++#+.+\n++.+.+++.++.+.#... | code_stdio |
[
{
"content": "There are $n + 2$ towns located on a coordinate line, numbered from $0$ to $n + 1$. The $i$-th town is located at the point $i$.\n\nYou build a radio tower in each of the towns $1, 2, \\dots, n$ with probability $\\frac{1}{2}$ (these events are independent). After that, you want to set the signal ... | [{"input": "200000\n", "output": "\n202370013\n"}, {"input": "200000\n", "output": "202370013\n"}, {"input": "199999\n", "output": "503231359\n"}, {"input": "199998\n", "output": "801261687\n"}, {"input": "199998\n", "output": "801261687\n"}, {"input": "199999\n", "output": "503231359\n"}, {"input": "103835\n", "output... | code_stdio |
[
{
"content": "Introduction\n\nIt's been more than 20 minutes since the negligent waiter has taken your order for the house special prime tofu steak with a side of chili fries.\n\nOut of boredom, you start fiddling around with the condiments tray. To be efficient, you want to be familiar with the choice of sauce... | [{"input": "1735", "output": "[1398915]", "fn_name": "toothpick"}, {"input": "1757", "output": "[1443119]", "fn_name": "toothpick"}, {"input": "1974", "output": "[2038207]", "fn_name": "toothpick"}, {"input": "2048", "output": "[2796203]", "fn_name": "toothpick"}, {"input": "1038", "output": "[699451]", "fn_name": "too... | code_functional |
[
{
"content": "A sequence a=\\{a_1,a_2,a_3,......\\} is determined as follows:\n - The first term s is given as input.\n - Let f(n) be the following function: f(n) = n/2 if n is even, and f(n) = 3n+1 if n is odd.\n - a_i = s when i = 1, and a_i = f(a_{i-1}) when i > 1.\nFind the minimum integer m that satisfies ... | [{"input": "54\n", "output": "114\n"}, {"input": "100\n", "output": "27\n"}, {"input": "97\n", "output": "120\n"}, {"input": "95\n", "output": "107\n"}, {"input": "27\n", "output": "113\n"}, {"input": "108", "output": "115\n"}, {"input": "107", "output": "102\n"}, {"input": "161", "output": "100\n"}, {"input": "220", "... | code_stdio |
[
{
"content": "At the beginning of the new semester there is new schedule in the Berland State University. According to this schedule, n groups have lessons at the room 31. For each group the starting time of the lesson and the finishing time of the lesson are known. It has turned out that it is impossible to ho... | [{"input": "16\n203671 381501\n58867 59732\n817520 962123\n125391 163027\n601766 617692\n381501 444610\n761937 817520\n16 10551\n21096 38291\n718073 761937\n583868 601766\n554859 731755\n678098 718073\n962123 992003\n163027 203671\n87917 96397\n", "output": "1\n12 "}, {"input": "11\n717170 795210\n866429 970764\n163324... | code_stdio |
[
{
"content": "You are given two strings x and y, both consist only of lowercase Latin letters. Let |s| be the length of string s.\n\nLet's call a sequence a a merging sequence if it consists of exactly |x| zeros and exactly |y| ones in some order.\n\nA merge z is produced from a sequence a by the following rule... | [{"input": "justamassivetesttocheck\nhowwellyouhandlemodulooperations\n", "output": "\n667387032\n"}, {"input": "justamassivetestsocheck\nhowwellyouhandlemodulooperations\n", "output": "732028571\n"}, {"input": "kcehcostsetevissamatsuj\nhowwellyouhandlemodulooperations\n", "output": "957292014\n"}, {"input": "kcehcosts... | code_stdio |
[
{
"content": "The educational program (AHK Education) of the Aiz Broadcasting Association broadcasts a handicraft program for children, \"Play with Tsukuro\". This time I will make a box with sticks, but I would like to see if I can make a rectangular parallelepiped using the 12 sticks I prepared. However, the ... | [{"input": "0 1 1 4 11 16 3 2 0 0 5 13", "output": "no\n"}, {"input": "0 1 1 4 11 16 6 2 0 0 5 13", "output": "no\n"}, {"input": "0 1 1 4 11 16 6 2 1 0 5 13", "output": "no\n"}, {"input": "0 1 1 4 2 20 6 2 2 0 13 13", "output": "no\n"}, {"input": "0 1 1 4 2 20 6 2 3 0 13 13", "output": "no\n"}, {"input": "0 1 1 4 2 20 ... | code_stdio |
[
{
"content": "# Definition \n\nA number is a **_Special Number_** *if it’s digits only consist 0, 1, 2, 3, 4 or 5*\n\n**_Given_** a number *determine if it special number or not* . \n\n\n\n# Warm-up (Highly recommended)\n\n# [Playing With Numbers Series](https://www.codewars.com/collections/playing-with-number... | [{"input": "11350224", "output": "[\"Special!!\"]", "fn_name": "special_number"}, {"input": "23", "output": "[\"Special!!\"]", "fn_name": "special_number"}, {"input": "32", "output": "[\"Special!!\"]", "fn_name": "special_number"}, {"input": "55", "output": "[\"Special!!\"]", "fn_name": "special_number"}, {"input": "2"... | code_functional |
[
{
"content": "There is a n × n grid D where each cell contains either 1 or 0.\n\nYour task is to create a program that takes the gird data as input and computes the greatest number of consecutive 1s in either vertical, horizontal, or diagonal direction.\n\nFor example, the consecutive 1s with greatest number in... | [{"input": "5\n00011\n00101\n01000\n10101\n00010\n8\n11000001\n10110111\n01100111\n01111010\n11111111\n01001010\n10100010\n10000001\n2\n01\n00\n3\n000\n000\n000\n0", "output": "4\n8\n1\n0\n"}, {"input": "5\n00011\n00101\n01000\n10101\n00010\n8\n11000001\n10110111\n01100111\n01111010\n11111111\n01001010\n10100010\n10000... | code_stdio |
[
{
"content": "You are given an array $a$ consisting of $n$ positive integers.\n\nInitially, you have an integer $x = 0$. During one move, you can do one of the following two operations: Choose exactly one $i$ from $1$ to $n$ and increase $a_i$ by $x$ ($a_i := a_i + x$), then increase $x$ by $1$ ($x := x + 1$).... | [{"input": "5\n4 3\n1 2 1 3\n10 6\n8 7 1 8 3 7 1 10 8 9\n5 13\n20 100 74 20 100500\n10 25\n24 39 19 24 24 87 24 24 24 10\n8 8\n1 2 3 4 5 7 7 12\n", "output": "6\n24\n20\n127\n13\n"}, {"input": "5\n4 3\n1 2 1 3\n10 6\n8 7 1 8 3 7 0 10 8 9\n5 13\n20 100 50 20 100500\n10 25\n24 24 19 24 24 40 24 24 24 10\n8 8\n1 2 3 4 5 7... | code_stdio |
[
{
"content": "A queen is the strongest chess piece. In modern chess the queen can move any number of squares in any horizontal, vertical or diagonal direction (considering that there're no other pieces on its way). The queen combines the options given to the rook and the bishop.\n\nThere are m queens on a squar... | [{"input": "10 20\n6 10\n3 10\n10 4\n5 3\n9 4\n10 1\n10 3\n10 7\n8 5\n7 2\n4 7\n5 1\n2 9\n5 5\n6 6\n9 8\n2 10\n9 10\n1 4\n7 4\n", "output": "0 0 4 9 4 1 2 0 0\n"}, {"input": "100 10\n97 5\n53 35\n92 86\n54 95\n98 13\n36 23\n55 56\n96 94\n25 96\n49 31\n", "output": "6 4 0 0 0 0 0 0 0\n"}, {"input": "100 10\n97 5\n53 35\... | code_stdio |
[
{
"content": "When new students come to the Specialized Educational and Scientific Centre (SESC) they need to start many things from the beginning. Sometimes the teachers say (not always unfairly) that we cannot even count. So our teachers decided to teach us arithmetics from the start. And what is the best way... | [{"input": "|||||||||||||||||||||||||||||||||||||||||||||||||||+|||||||||||||||||||||||||||||||||||||||||||||||||||=||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||\n", "output": "||||||||||||||||||||||||||||||||||||||||||||||||||+|||||||||||||||||||||||||||||||||||||... | code_stdio |
[
{
"content": "Print all the integers that satisfies the following in ascending order:\n - Among the integers between A and B (inclusive), it is either within the K smallest integers or within the K largest integers.\n\n-----Constraints-----\n - 1 \\leq A \\leq B \\leq 10^9\n - 1 \\leq K \\leq 100\n - All values... | [{"input": "0 32 110", "output": "0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n31\n32\n"}, {"input": "8 35 011", "output": "8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n25\n26\n27\n28\n29\n30\n31\n32\n33\n34\n35\n"}, {"input": "8 39 011", "output": "8\n9... | code_stdio |
[
{
"content": "You are given an array a of length n. We define f_{a} the following way:\n\n Initially f_{a} = 0, M = 1; for every 2 ≤ i ≤ n if a_{M} < a_{i} then we set f_{a} = f_{a} + a_{M} and then set M = i. \n\nCalculate the sum of f_{a} over all n! permutations of the array a modulo 10^9 + 7.\n\nNote: two... | [{"input": "9\n347223417 807654168 573530036 826123287 366028010 257025851 15406743 784063803 132844347\n", "output": "932879531\n"}, {"input": "9\n347223417 807654168 573530036 826123287 366028010 257025851 15406743 784063803 138878790\n", "output": "655212093\n"}, {"input": "9\n347223417 807654168 573530036 826123287... | code_stdio |
[
{
"content": "A line on the plane is described by an equation Ax + By + C = 0. You are to find any point on this line, whose coordinates are integer numbers from - 5·1018 to 5·1018 inclusive, or to find out that such points do not exist.\n\nInput\n\nThe first line contains three integers A, B and C ( - 2·109 ≤... | [{"input": "-1548994394 -1586527767 -1203252104\n", "output": "-878123061596147680 857348814150663048\n"}, {"input": "1999999993 1999999991 -1999999997\n", "output": "-1999999987000000015 1999999989000000012\n"}, {"input": "-1516373701 -584304312 -746376800\n", "output": "202167007852295200 -524659372900676000\n"}, {"i... | code_stdio |
[
{
"content": "You are given three integers k, p_{a} and p_{b}.\n\nYou will construct a sequence with the following algorithm: Initially, start with the empty sequence. Each second, you do the following. With probability p_{a} / (p_{a} + p_{b}), add 'a' to the end of the sequence. Otherwise (with probability p_{... | [{"input": "1000 123456 654321\n", "output": "977760856\n"}, {"input": "1000 123456 654321\n", "output": "977760856\n"}, {"input": "305 337309 378395\n", "output": "174667130\n"}, {"input": "108 531040 908573\n", "output": "145579983\n"}, {"input": "781 817338 452871\n", "output": "711597307\n"}, {"input": "270 967166 ... | code_stdio |
[
{
"content": "In an embassy of a well-known kingdom an electronic queue is organised. Every person who comes to the embassy, needs to make the following three actions: show the ID, pay money to the cashier and be fingerprinted. Besides, the actions should be performed in the given order.\n\nFor each action seve... | [{"input": "2 7 1\n10 3 10\n100\n3 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... | code_stdio |
[
{
"content": "A holiday weekend is coming up,\nand Hotel Bytelandia needs to find out if it has enough rooms to accommodate all potential guests.\nA number of guests have made reservations.\nEach reservation consists of an arrival time, and a departure time.\nThe hotel management has hired you to calculate the ... | [{"input": "3\n3\n1 2 3\n4 5 7\n5\n1 2 3 4 1\n2 4 4 5 6\n7\n13 6 5 8 2 10 12\n19 18 6 16 9 11 15", "output": "3\n3\n4\n"}, {"input": "3\n3\n1 2 3\n4 5 7\n5\n1 2 3 4 1\n2 4 4 5 6\n7\n13 6 5 8 1 10 12\n19 18 6 16 9 11 15", "output": "3\n3\n4\n"}, {"input": "3\n3\n1 2 3\n4 5 7\n5\n1 2 3 4 1\n3 4 4 5 6\n7\n13 6 5 8 1 10 12... | code_stdio |
[
{
"content": "The Holmes children are fighting over who amongst them is the cleverest.\n\nMycroft asked Sherlock and Eurus to find value of f(n), where f(1) = 1 and for n ≥ 2, f(n) is the number of distinct ordered positive integer pairs (x, y) that satisfy x + y = n and gcd(x, y) = 1. The integer gcd(a, b) is ... | [{"input": "1000000000000 1000000000000\n", "output": "1"}, {"input": "1000000000000 1000000000000\n", "output": "1"}, {"input": "331725641503 465583326659\n", "output": "1\n"}, {"input": "594243639083 188040404706\n", "output": "1\n"}, {"input": "892726102335 265691489675\n", "output": "1\n"}, {"input": "483154390901 ... | code_stdio |
[
{
"content": "Recently Lynyrd and Skynyrd went to a shop where Lynyrd bought a permutation $p$ of length $n$, and Skynyrd bought an array $a$ of length $m$, consisting of integers from $1$ to $n$. \n\nLynyrd and Skynyrd became bored, so they asked you $q$ queries, each of which has the following form: \"does th... | [{"input": "3 6 3\n2 1 3\n1 2 3 1 2 3\n1 5\n2 6\n3 5\n", "output": "110\n"}, {"input": "3 6 3\n2 1 3\n1 1 3 1 2 3\n1 5\n2 6\n3 5\n", "output": "110\n"}, {"input": "3 6 3\n2 1 3\n1 2 3 1 2 3\n1 5\n3 6\n3 5\n", "output": "100\n"}, {"input": "3 6 3\n2 1 3\n1 1 3 1 3 3\n1 5\n2 6\n3 5\n", "output": "000\n"}, {"input": "3 6 ... | code_stdio |
[
{
"content": "This kata is part of the collection [Mary's Puzzle Books](https://www.codewars.com/collections/marys-puzzle-books).\n\nMary brought home a \"spot the differences\" book. The book is full of a bunch of problems, and each problem consists of two strings that are similar. However, in each string ther... | [{"input": "\"abcdefghijklmnopqrstuvwxyz\"\n\"zyxwvutsrqponmlkjihgfedcba\"", "output": "[[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]]", "fn_name": "spot_diff"}, {"input": "\"Congratulations! You did it!\"\n\"Conglaturations! U did this!\"", "output": "[[4, 8, 17, 18, 1... | code_functional |
[
{
"content": "Heidi and Doctor Who hopped out of the TARDIS and found themselves at EPFL in 2018. They were surrounded by stormtroopers and Darth Vader was approaching. Miraculously, they managed to escape to a nearby rebel base but the Doctor was very confused. Heidi reminded him that last year's HC2 theme was... | [{"input": "1 2\n1156621358\n561572949 6885\n312543334 3629\n", "output": "10514\n"}, {"input": "1 2\n458828651\n209599643 7592\n208642144 8751\n", "output": "16343\n"}, {"input": "1 2\n754725914\n561572949 6885\n312543334 3629\n", "output": "10514\n"}, {"input": "1 2\n458828651\n209599643 7611\n208642144 8751\n", "out... | code_stdio |
[
{
"content": "# Summation Of Primes\n\nThe sum of the primes below or equal to 10 is **2 + 3 + 5 + 7 = 17**. Find the sum of all the primes **_below or equal to the number passed in_**.\n\nFrom Project Euler's [Problem #10](https://projecteuler.net/problem=10 \"Project Euler - Problem 10\").\n\nWrite Python cod... | [{"input": "25000", "output": "[32405717]", "fn_name": "summationOfPrimes"}, {"input": "4000", "output": "[1013507]", "fn_name": "summationOfPrimes"}, {"input": "5000", "output": "[1548136]", "fn_name": "summationOfPrimes"}, {"input": "2000", "output": "[277050]", "fn_name": "summationOfPrimes"}, {"input": "3000", "out... | code_functional |
[
{
"content": "Write a program which judges wheather given length of three side form a right triangle. Print \"YES\" if the given sides (integers) form a right triangle, \"NO\" if not so.\n\nConstraints\n\n* 1 ≤ length of the side ≤ 1,000\n* N ≤ 1,000\n\nInput\n\nInput consists of several data sets. In the first... | [{"input": "3\n-1 -2 0\n0 1 -1\n-2 0 2", "output": "NO\nYES\nYES\n"}, {"input": "3\n-1 -2 -1\n0 1 0\n-2 0 2", "output": "NO\nNO\nYES\n"}, {"input": "3\n1 1 0\n29 1 -1\n0 1 -1", "output": "YES\nNO\nYES\n"}, {"input": "3\n2 2 -2\n-1 5 -1\n3 15 -1", "output": "NO\nNO\nNO\n"}, {"input": "3\n2 2 -2\n-1 5 -1\n3 11 -1", "outp... | code_stdio |
[
{
"content": "# Task\n Mr.Nam has `n` candies, he wants to put one candy in each cell of a table-box. The table-box has `r` rows and `c` columns.\n\n Each candy was labeled by its cell number. The cell numbers are in range from 1 to N and the direction begins from right to left and from bottom to top.\n\n Nam w... | [{"input": "15\n3\n3\n18", "output": "[[-1, -1, -1]]", "fn_name": "get_candy_position"}, {"input": "6\n2\n2\n7", "output": "[[-1, -1, -1]]", "fn_name": "get_candy_position"}, {"input": "15\n3\n3\n14", "output": "[[2, 1, 1]]", "fn_name": "get_candy_position"}, {"input": "15\n3\n3\n1", "output": "[[1, 2, 2]]", "fn_name":... | code_functional |
[
{
"content": "Let's call a positive integer extremely round if it has only one non-zero digit. For example, $5000$, $4$, $1$, $10$, $200$ are extremely round integers; $42$, $13$, $666$, $77$, $101$ are not.\n\nYou are given an integer $n$. You have to calculate the number of extremely round integers $x$ such t... | [{"input": "5\n9\n42\n13\n100\n111\n", "output": "9\n13\n10\n19\n19\n"}, {"input": "1\n707951\n", "output": "52\n"}, {"input": "1\n99889\n", "output": "45\n"}, {"input": "1\n9123\n", "output": "36\n"}, {"input": "1\n9999\n", "output": "36\n"}, {"input": "1\n9998\n", "output": "36\n"}, {"input": "1\n9997\n", "output": "... | code_stdio |
[
{
"content": "Seen from above, there is a grid-like square shaped like Figure 1. The presence or absence of \"walls\" on each side of this grid is represented by a sequence of 0s and 1s. Create a program that stands at point A, puts your right hand on the wall, keeps walking in the direction of the arrow, and o... | [{"input": "1111\n00001\n0110\n11111\n1010\n00011\n1010\n01011\n1111", "output": "RRRRDDDDLLLLRULRDRRULRULULDLUDRURRDDDRUUUULLLL\n"}, {"input": "1111\n01001\n0010\n11101\n1110\n00111\n1110\n10001\n1110", "output": "RRRRDDDDUUUULLLDDRURLDRDLLLDRRRLLLURRULLUDRUUL\n"}, {"input": "1111\n00010\n1001\n10110\n1111\n00100\n011... | code_stdio |
[
{
"content": "Two children are playing tag on a number line. (In the game of tag, the child called \"it\" tries to catch the other child.) The child who is \"it\" is now at coordinate A, and he can travel the distance of V per second. The other child is now at coordinate B, and she can travel the distance of W ... | [{"input": "11 -1\n-1 -1\n9", "output": "NO\n"}, {"input": "14 -1\n-1 -1\n9", "output": "NO\n"}, {"input": "2 -1\n-1 -2\n5", "output": "YES\n"}, {"input": "3 -1\n-1 -2\n5", "output": "YES\n"}, {"input": "3 -1\n-2 -2\n5", "output": "YES\n"}, {"input": "1 1\n-1 12\n19", "output": "NO\n"}, {"input": "1 0\n-1 12\n19", "out... | code_stdio |
[
{
"content": "After a long party Petya decided to return home, but he turned out to be at the opposite end of the town from his home. There are $n$ crossroads in the line in the town, and there is either the bus or the tram station at each crossroad.\n\nThe crossroads are represented as a string $s$ of length $... | [{"input": "5\n3 1 1\nBC\n1 0 0\nAB\n4 1 11\nAABBBBAABB\n1 3 1\nBBBBB\n6 1 1\nABABAB\n", "output": "1\n2\n1\n5\n6\n"}, {"input": "5\n2 1 1\nBB\n1 1 1\nAB\n3 2 0\nAABBBBAABB\n5 3 4\nBBBBB\n2 1 1\nABABAB\n", "output": "1\n1\n10\n1\n6\n"}, {"input": "5\n3 1 1\nBC\n1 0 1\nAB\n4 1 11\nAABBBBAABB\n1 3 1\nBBBBB\n6 1 1\nABABAB... | code_stdio |
[
{
"content": "Highway 201 is the most busy street in Rockport. Traffic cars cause a lot of hindrances to races, especially when there are a lot of them. The track which passes through this highway can be divided into $n$ sub-tracks. You are given an array $a$ where $a_i$ represents the number of traffic cars in... | [{"input": "3\n3\n1 2 3\n4\n0 1 1 0\n10\n10 3 1 11 5 2 1 7 19 4\n", "output": "0\n4\n21\n"}, {"input": "3\n3\n1 2 3\n4\n0 1 1 0\n10\n10 3 1 11 5 2 1 7 10 4\n", "output": "0\n4\n24\n"}, {"input": "3\n3\n1 1 3\n4\n1 1 1 0\n10\n16 3 6 11 0 2 1 3 10 4\n", "output": "2\n3\n24\n"}, {"input": "3\n3\n1 1 3\n4\n1 1 1 0\n10\n16 ... | code_stdio |
[
{
"content": "Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.\n\nPetya has two strings a and b of the same length n. The strings consist on... | [{"input": "44447774444474477747774774477777474774744744477444447777477477744747477774744444744777777777747777477447744774744444747477744744\n77777474477477747774777777474474477444474777477747747777477747747744474474747774747747444777474444744744444477477777747744747477\n", "output": "37\n"}, {"input": "774774747744474... | code_stdio |
[
{
"content": "Create a program that inputs the test result data of the visual acuity test and outputs the number of people who apply to each judgment based on the following visual acuity judgment table for each of the left and right eyesight.\n\nJudgment | Sight\n--- | ---\nA | 1.1 or above\nB | 0.6 or more and... | [{"input": "1.4450818768746183 1.8412288178078728\n2.6983178051647414 1.5471720124202895\n2.573217216239934 0.8500864926517523\n4.9346769267643475 2.1903643288076555", "output": "4 3\n0 1\n0 0\n0 0\n"}, {"input": "1.4450818768746183 2.8044369815893004\n2.6983178051647414 1.5471720124202895\n2.573217216239934 0.85008649... | code_stdio |
[
{
"content": "The Little Elephant loves numbers. \n\nHe has a positive integer x. The Little Elephant wants to find the number of positive integers d, such that d is the divisor of x, and x and d have at least one common (the same) digit in their decimal representations. \n\nHelp the Little Elephant to find the... | [{"input": "1010000000\n", "output": "117\n"}, {"input": "1011000000\n", "output": "171\n"}, {"input": "654885000\n", "output": "698\n"}, {"input": "1000000000\n", "output": "91\n"}, {"input": "101871000\n", "output": "460\n"}, {"input": "211768200\n", "output": "244\n"}, {"input": "901800900\n", "output": "639\n"}, {"... | code_stdio |
[
{
"content": "Recently, you found a bot to play \"Rock paper scissors\" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string $s = s_1 s_2 \\dots s_{n}$ of length $n$ where each letter is either R, S or P.\n\nWhile initializing, the bot is choosing a starting index $pos$ ($1 \\le p... | [{"input": "3\nRRRR\nRSP\nS\n", "output": "PPPP\nPPP\nR\n"}, {"input": "3\nRRRR\nRSP\nS\n", "output": "PPPP\nPPP\nR\n"}, {"input": "3\nRRRR\nSSP\nS\n", "output": "PPPP\nRRR\nR\n"}, {"input": "3\nQRRR\nRSP\nS\n", "output": "PPPP\nPPP\nR\n"}, {"input": "3\nRRRR\nSSP\nR\n", "output": "PPPP\nRRR\nP\n"}, {"input": "3\nQRRR\... | code_stdio |
[
{
"content": "You are given an array consisting of $n$ integers $a_1, a_2, \\dots, a_n$, and a positive integer $m$. It is guaranteed that $m$ is a divisor of $n$.\n\nIn a single move, you can choose any position $i$ between $1$ and $n$ and increase $a_i$ by $1$.\n\nLet's calculate $c_r$ ($0 \\le r \\le m-1)$ —... | [{"input": "100 25\n6745 2075 7499 7517 1776 5164 2335 2745 4465 1457 7565 2232 2486 9025 8059 9646 8017 7662 9690 3352 2306 366 7422 1073 7169 8966 4506 8225 5614 8628 2908 7452 9625 9332 7097 353 1043 8118 5794 4486 626 971 6731 6618 887 6354 4814 7307 7681 6160 9351 2579 411 3436 5570 2812 2726 4433 3220 577 5891 38... | code_stdio |
[
{
"content": "Recently in Divanovo, a huge river locks system was built. There are now $n$ locks, the $i$-th of them has the volume of $v_i$ liters, so that it can contain any amount of water between $0$ and $v_i$ liters. Each lock has a pipe attached to it. When the pipe is open, $1$ liter of water enters the ... | [{"input": "50\n3 60 52 60 60 84 63 40 50 21 39 59 40 15 59 54 5 84 63 23 11 69 27 65 64 8 39 4 89 19 10 45 51 66 69 60 82 25 82 66 86 35 24 64 43 67 35 25 39 82\n50\n57\n46\n44\n70\n74\n98\n36\n48\n76\n52\n86\n40\n28\n56\n73\n64\n78\n21\n37\n54\n33\n93\n16\n18\n66\n75\n62\n77\n81\n96\n31\n41\n68\n24\n80\n67\n50\n72\n9... | code_stdio |
[
{
"content": "There are N monsters, numbered 1, 2, ..., N.\nInitially, the health of Monster i is A_i.\nBelow, a monster with at least 1 health is called alive.\nUntil there is only one alive monster, the following is repeated:\n - A random alive monster attacks another random alive monster.\n - As a result, th... | [{"input": "3\n1000000000 1000000000 1000000000\n", "output": "1000000000\n"}, {"input": "3\n1000000000 1000000000 1000000000", "output": "1000000000"}, {"input": "3\n1000000100 1000000000 1000000000", "output": "100\n"}, {"input": "3\n1000000100 1000100000 1000000000", "output": "100\n"}, {"input": "3\n1100000100 0100... | code_stdio |
[
{
"content": "Pak Chanek plans to build a garage. He wants the garage to consist of a square and a right triangle that are arranged like the following illustration.\n\nDefine $a$ and $b$ as the lengths of two of the sides in the right triangle as shown in the illustration. An integer $x$ is suitable if and only... | [{"input": "1000000000\n", "output": "1333333336\n"}, {"input": "999999999\n", "output": "1333333335\n"}, {"input": "999999998\n", "output": "1333333333\n"}, {"input": "999999997\n", "output": "1333333332\n"}, {"input": "767928734\n", "output": "1023904981\n"}, {"input": "999993999\n", "output": "1333325335\n"}, {"inpu... | code_stdio |
[
{
"content": "problem\n\nThere are $ N $ islands numbered from $ 1 $ to $ N $.\nEach island has $ N-1 $ bridges, allowing any $ 2 $ island to move to each other across several bridges.\nEach bridge has durability, and the durability of the $ i $ th bridge given the input is $ w_i $.\nThere are $ 1 $ treasures o... | [{"input": "4 10 1 4\n1 2 45\n2 3 68\n3 4 121", "output": "Yes\n"}, {"input": "4 10 1 4\n1 2 52\n1 3 134\n3 4 17", "output": "Yes\n"}, {"input": "4 10 1 4\n1 2 45\n2 3 68\n3 4 113", "output": "Yes\n"}, {"input": "4 16 1 4\n1 2 45\n2 3 68\n3 4 121", "output": "Yes\n"}, {"input": "4 10 1 4\n1 2 20\n2 3 68\n3 4 113", "out... | code_stdio |
[
{
"content": "Vasya's birthday is approaching and Lena decided to sew a patterned handkerchief to him as a present. Lena chose digits from 0 to n as the pattern. The digits will form a rhombus. The largest digit n should be located in the centre. The digits should decrease as they approach the edges. For exampl... | [{"input": "9\n", "output": " 0\n 0 1 0\n 0 1 2 1 0\n 0 1 2 3 2 1 0\n 0 1 2 3 4 3 2 1 0\n 0 1 2 3 4 5 4 3 2 1 0\n 0 1 2 3 4 5 6 5 4 3 2 1 0\n 0 1 2 3 4 5 6 7 6 5 4 3 2 1 0\n 0 1 2 3 4 5 6 7 8 7 6 5 4 3 2 1 0\n0 1 2 3 4 5 6 7 8 9 8 7 6 5 4 ... | code_stdio |
[
{
"content": "The Super Duper Secret Meeting of the Super Duper Secret Military Squad takes place in a Super Duper Secret Place. The place is an infinite plane with introduced Cartesian coordinate system. The meeting table is represented as a rectangle whose sides are parallel to the coordinate axes and whose v... | [{"input": "-565 -444 -419 -421\n30\n363 -249 790\n704 57 999\n-316 -305 119\n-778 -543 373\n-589 466 190\n516 -174 893\n-742 -662 390\n-382 825 1000\n520 -732 909\n-220 -985 555\n-49 -697 396\n-701 -882 520\n-105 227 691\n-113 -470 231\n-503 98 1088\n236 69 759\n150 393 951\n414 381 1000\n1096 3 999\n-357 485 905\n432... | code_stdio |
[
{
"content": "You have m = n·k wooden staves. The i-th stave has length a_{i}. You have to assemble n barrels consisting of k staves each, you can use any k staves to construct a barrel. Each stave must belong to exactly one barrel.\n\nLet volume v_{j} of barrel j be equal to the length of the minimal stave in ... | [{"input": "10 3 726\n277 706 1241 812 692 1291 196 507 911 111 498 704 573 381 463 1095 704 36 443 640 326 405 47 834 962 521 1296 740 520 622\n", "output": "5072\n"}, {"input": "10 3 726\n277 706 1241 812 692 1291 196 507 911 111 498 704 573 381 463 1095 704 36 693 640 326 405 47 834 962 521 1296 740 520 622\n", "out... | code_stdio |
[
{
"content": "People in the Tomskaya region like magic formulas very much. You can see some of them below.\n\nImagine you are given a sequence of positive integer numbers p_1, p_2, ..., p_{n}. Lets write down some magic formulas:$q_{i} = p_{i} \\oplus(i \\operatorname{mod} 1) \\oplus(i \\operatorname{mod} 2) \\... | [{"input": "25\n39226529 640445129 936289624 364461191 1096077769 573427707 1919403410 950067229 1217479531 455229458 1574949468 397268319 1267289585 995220637 1920919164 501015483 1815262670 1197059269 86947741 1137410885 667368575 733666398 1536581408 611239452 947487746\n", "output": "259654661\n"}, {"input": "25\n3... | code_stdio |
[
{
"content": "You are given two very long integers a, b (leading zeroes are allowed). You should check what number a or b is greater or determine that they are equal.\n\nThe input size is very large so don't use the reading of symbols one by one. Instead of that use the reading of a whole line or token.\n\nAs i... | [{"input": "00011111111111111111111111111111111111000000000000000000000000000000000000000000000000000210000000000000000000000000000000000000000011000\n11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111112091\n", "output": "<\n"}, {"input": "0... | code_stdio |
[
{
"content": "Today, Wet Shark is given n bishops on a 1000 by 1000 grid. Both rows and columns of the grid are numbered from 1 to 1000. Rows are numbered from top to bottom, while columns are numbered from left to right.\n\nWet Shark thinks that two bishops attack each other if they share the same diagonal. No... | [{"input": "10\n646 171\n816 449\n375 934\n950 299\n702 232\n657 81\n885 306\n660 304\n369 371\n798 657\n", "output": "0\n"}, {"input": "10\n646 171\n816 449\n375 934\n950 299\n702 232\n657 81\n885 306\n660 304\n369 371\n798 657\n", "output": "0\n"}, {"input": "10\n646 171\n816 449\n375 934\n950 299\n702 232\n657 81\n8... | code_stdio |
[
{
"content": "Vasya has recently found out what a digital root of a number is and he decided to share his knowledge with you.\n\nLet's assume that S(n) is the sum of digits of number n, for example, S(4098) = 4 + 0 + 9 + 8 = 21. Then the digital root of number n equals to: \n\n 1. dr(n) = S(n), if S(n) < 10; \... | [{"input": "4898 3\n", "output": "3000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000... | code_stdio |
[
{
"content": "You are given an array $a$ of $n$ integers. You are asked to find out if the inequality $$\\max(a_i, a_{i + 1}, \\ldots, a_{j - 1}, a_{j}) \\geq a_i + a_{i + 1} + \\dots + a_{j - 1} + a_{j}$$ holds for all pairs of indices $(i, j)$, where $1 \\leq i \\leq j \\leq n$.\n\n\n-----Input-----\n\nEach t... | [{"input": "5\n19\n1 1 -1 -1 -1 0 -1 -1 1 -1 -1 1 0 1 0 -1 0 -1 -1\n11\n1 0 1 0 -1 1 -1 -1 -1 1 0\n58\n1 0 0 -1 -1 0 1 0 1 0 1 -1 1 1 0 0 1 -1 -1 1 -1 1 -1 -1 1 -1 0 1 0 0 0 0 -1 -1 0 0 0 1 0 0 1 -1 0 0 0 -1 0 0 1 -1 0 -1 1 1 -1 0 0 1\n2\n0 0\n10\n0 -1 1 -1 1 -1 0 0 1 0\n", "output": "NO\nNO\nNO\nYES\nYES\n"}, {"input"... | code_stdio |
[
{
"content": "Developing tools for creation of locations maps for turn-based fights in a new game, Petya faced the following problem.\n\nA field map consists of hexagonal cells. Since locations sizes are going to be big, a game designer wants to have a tool for quick filling of a field part with identical enemy... | [{"input": "-1000000000 -1000000000 1000000000 1000000000\n", "output": "2000000002000000001"}, {"input": "-1000000000 -1000000000 1000000000 1000000000\n", "output": "2000000002000000001"}, {"input": "-1000000000 -999999999 1000000000 999999999\n", "output": "2000000000000000000"}, {"input": "-999999999 -1000000000 99... | code_stdio |
[
{
"content": "Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. \n\nThe Head Chef is receiving a lot of orders for cooking the best of the problems lately. For this, he organized an hiring event to hire some talented Chefs. He gave the following problem to test the skills of the part... | [{"input": "2\n1\n210", "output": "0\n2628\n"}, {"input": "2\n1\n198", "output": "0\n2484\n"}, {"input": "2\n1\n175", "output": "0\n2288\n"}, {"input": "2\n2\n175", "output": "2\n2288\n"}, {"input": "2\n2\n278", "output": "2\n4204\n"}, {"input": "2\n2\n114", "output": "2\n846\n"}, {"input": "2\n3\n112", "output": "4\n8... | code_stdio |
[
{
"content": "Complete the code which should return `true` if the given object is a single ASCII letter (lower or upper case), `false` otherwise.\n\nWrite Python code to solve this problem. Define a top-level function named `is_letter` that takes the input arguments described above and returns the answer direct... | [{"input": "\"a\\n\"", "output": "[false]", "fn_name": "is_letter"}, {"input": "\"ab\"", "output": "[false]", "fn_name": "is_letter"}, {"input": "\"7\"", "output": "[false]", "fn_name": "is_letter"}, {"input": "\"_\"", "output": "[false]", "fn_name": "is_letter"}, {"input": "\"\"", "output": "[false]", "fn_name": "is_l... | code_functional |
[
{
"content": "It's pretty straightforward. Your goal is to create a function that removes the first and last characters of a string. You're given one parameter, the original string. You don't have to worry with strings with less than two characters.\n\nWrite Python code to solve this problem. Define a top-leve... | [{"input": "\"eloquent\"", "output": "[\"loquen\"]", "fn_name": "remove_char"}, {"input": "\"country\"", "output": "[\"ountr\"]", "fn_name": "remove_char"}, {"input": "\"ooopsss\"", "output": "[\"oopss\"]", "fn_name": "remove_char"}, {"input": "\"person\"", "output": "[\"erso\"]", "fn_name": "remove_char"}, {"input": "... | code_functional |
[
{
"content": "IT City company developing computer games decided to upgrade its way to reward its employees. Now it looks the following way. After a new game release users start buying it actively, and the company tracks the number of sales with precision to each transaction. Every time when the next number of s... | [{"input": "1000000000000000000\n", "output": "228571428571428571\n"}, {"input": "1000000010000000000\n", "output": "228571430857142858\n"}, {"input": "1334196189585702396\n", "output": "304959129048160547\n"}, {"input": "1369783456377690936\n", "output": "313093361457757928\n"}, {"input": "1000000010000000100\n", "out... | code_stdio |
[
{
"content": "The ancient Berlanders believed that the longer the name, the more important its bearer is. Thus, Berland kings were famous for their long names. But long names are somewhat inconvenient, so the Berlanders started to abbreviate the names of their kings. They called every king by the first letters ... | [{"input": "50\nagecd\ncghafi\nfiide\niecc\njbdcfjhgd\ndiee\nhfeg\nehc\ngfijgjh\ngacaifebg\ndicbbddc\nhjgciaei\njjcdh\ng\ngc\ncf\nhfdjhd\nc\nicidbec\nji\neeh\ncgeejggc\nacfd\njjg\najefdj\neghhebiic\nbih\ngbb\njjaa\nidc\ngafi\necg\ndbigbjiehj\ncedif\nahidfaaajg\nhfhhiccbgb\ndgegjgieif\nhgjebhfdc\nj\nahehd\nahdah\nbijbhh... | code_stdio |
[
{
"content": "Vasiliy has an exam period which will continue for n days. He has to pass exams on m subjects. Subjects are numbered from 1 to m.\n\nAbout every day we know exam for which one of m subjects can be passed on that day. Perhaps, some day you can't pass any exam. It is not allowed to pass more than on... | [{"input": "100 10\n1 1 6 6 6 2 5 7 6 5 3 7 10 10 8 9 7 6 9 2 6 7 8 6 7 5 2 5 10 1 10 1 8 10 2 9 7 1 6 8 3 10 9 4 4 8 8 6 6 1 5 5 6 5 6 6 6 9 4 7 5 4 6 6 1 1 2 1 8 10 6 2 1 7 2 1 8 10 9 2 7 3 1 5 10 2 8 10 10 10 8 9 5 4 6 10 8 9 6 6\n2 4 10 11 5 2 6 7 2 15\n", "output": "74\n"}, {"input": "100 10\n1 1 6 6 6 2 5 7 6 5 3... | code_stdio |
[
{
"content": "Old timers of Summer Informatics School can remember previous camps in which each student was given a drink of his choice on the vechorka (late-evening meal). Or may be the story was more complicated?\n\nThere are $n$ students living in a building, and for each of them the favorite drink $a_i$ is ... | [{"input": "20 4\n1\n1\n1\n1\n1\n2\n2\n2\n2\n2\n3\n3\n3\n3\n3\n4\n4\n4\n4\n4\n", "output": "18\n"}, {"input": "20 4\n1\n1\n1\n1\n1\n2\n2\n2\n2\n2\n3\n3\n3\n3\n3\n4\n4\n4\n4\n4\n", "output": "18\n"}, {"input": "16 12\n1\n1\n1\n2\n2\n4\n3\n3\n3\n4\n4\n4\n5\n5\n6\n6\n", "output": "15\n"}, {"input": "16 12\n1\n1\n1\n2\n2\n... | code_stdio |
[
{
"content": "You are given a directed graph with $n$ vertices and $m$ directed edges without self-loops or multiple edges.\n\nLet's denote the $k$-coloring of a digraph as following: you color each edge in one of $k$ colors. The $k$-coloring is good if and only if there no cycle formed by edges of same color.\... | [{"input": "18 74\n12 17\n6 3\n7 5\n11 13\n13 12\n16 2\n15 3\n10 6\n18 1\n6 1\n10 18\n3 16\n16 5\n14 12\n12 1\n9 6\n13 11\n11 17\n13 1\n1 7\n18 12\n6 8\n11 15\n2 9\n9 12\n7 4\n8 15\n6 9\n11 9\n11 18\n3 6\n5 7\n1 16\n2 6\n17 11\n4 8\n14 1\n7 13\n18 14\n7 16\n15 5\n11 2\n18 17\n9 16\n4 13\n17 5\n8 6\n18 6\n6 4\n17 10\n10... | code_stdio |
[
{
"content": "You've got two numbers. As long as they are both larger than zero, they go through the same operation: subtract the lesser number from the larger one. If they equal substract one number from the another. For example, one operation transforms pair (4,17) to pair (4,13), it transforms (5,5) to (0,5)... | [{"input": "20\n1000000000 999999999\n1000000000 999999999\n1000000000 999999999\n1000000000 999999999\n1000000000 999999999\n1000000000 999999999\n1000000000 999999999\n1000000000 999999999\n1000000000 999999999\n1000000000 999999999\n1000000000 999999999\n1000000000 999999999\n1000000000 999999999\n1000000000 9999999... | code_stdio |
[
{
"content": "A string $s$ of length $n$, consisting of lowercase letters of the English alphabet, is given.\n\nYou must choose some number $k$ between $0$ and $n$. Then, you select $k$ characters of $s$ and permute them however you want. In this process, the positions of the other $n-k$ characters remain uncha... | [{"input": "4\n3\nlol\n10\nfecrosedoc\n5\naaaab\n4\nddca\n", "output": "2\n10\n0\n4\n"}, {"input": "4\n3\nnlm\n10\nfecrosedoc\n5\naaaab\n4\nddca\n", "output": "3\n10\n0\n4\n"}, {"input": "4\n3\nlol\n10\ncodeforces\n5\naaaaa\n4\ndcba\n", "output": "2\n6\n0\n4\n"}, {"input": "4\n3\nlol\n10\ncodeforces\n5\nbaaaa\n4\ndcba\... | code_stdio |
[
{
"content": "There is a staircase with N steps. Takahashi is now standing at the foot of the stairs, that is, on the 0-th step.\nHe can climb up one or two steps at a time.\nHowever, the treads of the a_1-th, a_2-th, a_3-th, \\ldots, a_M-th steps are broken, so it is dangerous to set foot on those steps.\nHow ... | [{"input": "16090 15931\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n31\n32\n33\n34\n35\n36\n37\n38\n39\n40\n41\n42\n43\n44\n45\n46\n47\n48\n49\n50\n51\n52\n53\n54\n55\n56\n57\n58\n59\n60\n61\n62\n63\n64\n65\n66\n67\n68\n69\n70\n71\n72\n73\n74\n75\n76\n... | code_stdio |
[
{
"content": "This is a harder version of the problem. In this version, $n \\le 50\\,000$.\n\nThere are $n$ distinct points in three-dimensional space numbered from $1$ to $n$. The $i$-th point has coordinates $(x_i, y_i, z_i)$. The number of points $n$ is even.\n\nYou'd like to remove all $n$ points using a se... | [{"input": "8\n-100000000 -100000000 -100000000\n100000000 100000000 100000000\n-100000000 100000000 100000000\n-100000000 -100000000 100000000\n100000000 100000000 -100000000\n100000000 -100000000 -100000000\n-100000000 100000000 -100000000\n100000000 -100000000 100000000\n", "output": "1 4\n7 3\n6 8\n5 2\n"}, {"input... | code_stdio |
[
{
"content": "Ivan has $n$ songs on his phone. The size of the $i$-th song is $a_i$ bytes. Ivan also has a flash drive which can hold at most $m$ bytes in total. Initially, his flash drive is empty.\n\nIvan wants to copy all $n$ songs to the flash drive. He can compress the songs. If he compresses the $i$-th so... | [{"input": "1 1364355877\n1000000000 1343571090\n", "output": "0\n"}, {"input": "1 1000000000\n1000000000 999999999\n", "output": "0\n"}, {"input": "1 1000000000\n1000000000 999999999\n", "output": "0\n"}, {"input": "1 1992779579\n1000000000 999999999\n", "output": "0\n"}, {"input": "1 1992779579\n1000000010 999999999\... | code_stdio |
[
{
"content": "Reading books is one of Sasha's passions. Once while he was reading one book, he became acquainted with an unusual character. The character told about himself like that: \"Many are my names in many countries. Mithrandir among the Elves, Tharkûn to the Dwarves, Olórin I was in my youth in the West ... | [{"input": "tttdddssstttssstttdddddddddttttttdddsssdddtttsssdddsssssstttddddddtttdddssstttsssttttttdddtttsssssstttssssssssstttsssssstttssstttdddddddddsssdddssssssdddssstttsssdddssstttdddttttttdddddddddsssssstttdddtttssssssdddddddddttttttdddtttsssdddssstttsssdddssssssdddsssdddddddddtttssstttsssssstttssssssssstttsssssstt... | code_stdio |
[
{
"content": "Taro is not good at hide-and-seek. As soon as you hide, you will find it, and it will be difficult to find the hidden child. My father, who couldn't see it, made an ultra-high performance location search system. You can use it to know exactly where your friends are, including your own. Once you be... | [{"input": "3\n6 6 3\n19 19 6\n42 10 1\n6\n5 2 2 11\n12 7 2 11\n11 9 1 11\n14 2 22 5\n17 9 20 5\n20 10 20 5\n0", "output": "Safe\nDanger\nDanger\nDanger\nDanger\nDanger\n"}, {"input": "3\n6 2 16\n40 7 8\n42 8 1\n6\n5 3 4 11\n12 4 2 15\n16 2 0 11\n28 2 31 5\n17 9 41 5\n24 10 30 10\n0", "output": "Danger\nDanger\nDanger\... | code_stdio |
[
{
"content": "Anton has the integer x. He is interested what positive integer, which doesn't exceed x, has the maximum sum of digits.\n\nYour task is to help Anton and to find the integer that interests him. If there are several such integers, determine the biggest of them. \n\n\n-----Input-----\n\nThe first li... | [{"input": "1000000000000000000\n", "output": "999999999999999999\n"}, {"input": "1000000000000000000\n", "output": "999999999999999999\n"}, {"input": "978916546899999999\n", "output": "899999999999999999\n"}, {"input": "999999999999999999\n", "output": "999999999999999999\n"}, {"input": "999999999999990999\n", "output... | code_stdio |
[
{
"content": "There are n schoolchildren, boys and girls, lined up in the school canteen in front of the bun stall. The buns aren't ready yet and the line is undergoing some changes.\n\nEach second all boys that stand right in front of girls, simultaneously swap places with the girls (so that the girls could go... | [{"input": "MFFFMMFMFMFMFFFMMMFFMMMMMMFMMFFMMMFMMFMFFFMMFMMMFFMMFFFFFMFMFFFMMMFFFMFMFMFMFFFMMMMFMMFMMFFMMMMMMFFM\n", "output": "54\n"}, {"input": "MMMMMFFMFMFMFMMFMMFFMMFMFFFFFFFMFFFMMMMMMFFMMMFMFMMFMFFMMFMMMFFFFFMMMMMFMMMMFMMMFFMFFMFFFMFFMFFMMFFM\n", "output": "58\n"}, {"input": "MMMMFMMMMMFFMMFMFMMMFMMFMFMMFFFMMFMMMF... | code_stdio |
[
{
"content": "Let N be a positive even number.\nWe have a permutation of (1, 2, ..., N), p = (p_1, p_2, ..., p_N).\nSnuke is constructing another permutation of (1, 2, ..., N), q, following the procedure below.\nFirst, let q be an empty sequence.\nThen, perform the following operation until p becomes empty:\n -... | [{"input": "8\n2 6 5 2 1 4 -1 1", "output": "-1 1 1 4 2 2 6 5 "}, {"input": "8\n4 6 3 2 8 5 7 1\n", "output": "3 1 2 7 4 6 8 5\n"}, {"input": "8\n4 6 5 2 8 5 7 1", "output": "4 1 2 7 6 5 8 5 "}, {"input": "8\n4 6 5 2 8 5 0 1", "output": "0 1 4 2 6 5 8 5 "}, {"input": "8\n2 6 5 2 8 5 0 1", "output": "0 1 2 2 6 5 8 5 "},... | code_stdio |
[
{
"content": "A sequence $(b_1, b_2, \\ldots, b_k)$ is called strange, if the absolute difference between any pair of its elements is greater than or equal to the maximum element in the sequence. Formally speaking, it's strange if for every pair $(i, j)$ with $1 \\le i<j \\le k$, we have $|a_i-a_j|\\geq MAX$, w... | [{"input": "6\n4\n-1 -2 -1 1\n7\n-3 2 -2 0 -4 7 1\n5\n0 5 -3 2 -5\n3\n2 0 1\n4\n-3 -1 2 0\n6\n-3 -2 -1 1 1 1\n", "output": "3\n5\n4\n2\n3\n4\n"}, {"input": "6\n4\n-1 -2 -1 1\n7\n-3 2 -2 0 -4 7 1\n5\n0 5 -3 1 -5\n3\n2 0 1\n4\n-3 -1 2 0\n6\n-3 -2 -2 1 1 1\n", "output": "3\n5\n4\n2\n3\n3\n"}, {"input": "6\n4\n-1 -2 0 1\n7... | code_stdio |
[
{
"content": "You are given three integers A, B and C.\n\nDetermine if there exists an equilateral triangle whose sides have lengths A, B and C.\n\nConstraints\n\n* All values in input are integers.\n* 1 \\leq A,B,C \\leq 100\n\nInput\n\nInput is given from Standard Input in the following format:\n\n\nA B C\n\n... | [{"input": "-1 -1 -1", "output": "Yes\n"}, {"input": "-2 -1 -1", "output": "No\n"}, {"input": "-2 -1 -2", "output": "No\n"}, {"input": "-3 10 -1", "output": "No\n"}, {"input": "-3 1 -11", "output": "No\n"}, {"input": "-3 1 -21", "output": "No\n"}, {"input": "-5 1 -21", "output": "No\n"}, {"input": "-9 1 -21", "output":... | code_stdio |
[
{
"content": "Dima liked the present he got from Inna very much. He liked the present he got from Seryozha even more. \n\nDima felt so grateful to Inna about the present that he decided to buy her n hares. Inna was very happy. She lined up the hares in a row, numbered them from 1 to n from left to right and sta... | [{"input": "8\n7 3 3 10 9 9 8 1\n8 2 6 6 0 3 8 0\n1 2 5 1 9 4 7 8\n", "output": "52\n"}, {"input": "8\n7 3 3 10 9 9 8 1\n8 2 4 6 0 3 8 0\n1 2 5 1 9 4 7 8\n", "output": "52\n"}, {"input": "8\n7 3 3 10 9 9 6 1\n8 2 4 6 0 3 8 0\n1 2 5 1 9 4 7 8\n", "output": "52\n"}, {"input": "8\n7 3 3 10 9 9 6 1\n8 2 4 8 0 3 8 0\n1 2 5 ... | code_stdio |
[
{
"content": "Little Dima has two sequences of points with integer coordinates: sequence (a1, 1), (a2, 2), ..., (an, n) and sequence (b1, 1), (b2, 2), ..., (bn, n).\n\nNow Dima wants to count the number of distinct sequences of points of length 2·n that can be assembled from these sequences, such that the x-coo... | [{"input": "100\n2 2 10 3 5 6 4 7 9 8 2 7 5 5 1 7 5 9 2 2 10 3 6 10 9 9 10 7 3 9 7 8 8 3 9 3 9 3 3 6 3 7 9 9 7 10 9 1 1 3 6 2 9 5 9 9 6 2 6 5 6 8 2 10 1 1 6 8 8 4 5 2 6 8 8 5 9 2 3 3 7 7 10 5 4 2 10 6 7 6 5 4 10 6 10 3 9 9 1 5\n3 5 6 4 2 3 2 9 3 8 3 1 10 7 4 3 6 9 3 5 9 5 3 10 4 7 9 7 4 3 3 6 9 8 1 1 10 9 1 6 8 8 8 2 1... | code_stdio |
[
{
"content": "Inna loves digit 9 very much. That's why she asked Dima to write a small number consisting of nines. But Dima must have misunderstood her and he wrote a very large number a, consisting of digits from 1 to 9.\n\nInna wants to slightly alter the number Dima wrote so that in the end the number contai... | [{"input": "44444444444444544444444445444444444444444444444444554444444444444444444444444444444444444444455444444444444444444444444444444444444444545444444444444444444444444444444444444445444444444444444444444444444444444444544444444444444444444444444444444444444444444544444444444444444444444444444444445666666666666666... | code_stdio |
[
{
"content": "I bought food at the store to make a lunch box to eat at lunch. At the store, I only got an elongated bag to put food in, so I had to stack all the food vertically and put it in the bag. I want to pack the bag with the heavy ones down so that it won't fall over, but some foods are soft and will co... | [{"input": "4\nsandwich 30 120\nelppa 50 200\ncheese 20 40\ncake 100 100\n9\nonigiri 80 300\nonigiri 80 300\nanpan 70 280\nmikan 50 80\nkanzume 101 500\nchocolate 50 350\niookce 30 132\npurin 40 400\ncracker 40 154\n0", "output": "cake\nelppa\nsandwich\ncheese\nkanzume\npurin\nchocolate\nonigiri\nonigiri\nanpan\nmikan\... | code_stdio |
[
{
"content": "problem\n\nFor the integer n (1 ≤ n), let Pn be a string of n + 1 I's and n O's starting with I and alternating, where I and O are the uppercase Ai and O, respectively. is there.\n\n\nP1 | IOI\n--- | ---\nP2 | IOIOI\nP3 | IOIOIOI\n|. |\n|. |\n|. |\nPn | IOIOIO ... OI (n O)\n\n\n\nFigure 1-1 Charac... | [{"input": "1\n119\nOOJOIOIOIIOII\n1\n14\nKIOIIOIOIOJOO\n0", "output": "3\n3\n"}, {"input": "1\n13\nOIIOIOIOIIOIO\n2\n13\nOOIOIOIOIIOII\n0", "output": "4\n2\n"}, {"input": "1\n13\nOOIOIOIOIIOII\n3\n13\nOOIOIOIOIIOII\n0", "output": "4\n1\n"}, {"input": "1\n25\nOOIOIOIOIIOII\n3\n13\nOOJOIOIOIIOIJ\n0", "output": "4\n0\n"}... | code_stdio |
[
{
"content": "Gottfried learned about binary number representation. He then came up with this task and presented it to you.\n\nYou are given a collection of $n$ non-negative integers $a_1, \\ldots, a_n$. You are allowed to perform the following operation: choose two distinct indices $1 \\leq i, j \\leq n$. If b... | [{"input": "37\n1048575 327657 1046479 686078 513773 589787 387035 736754 1038077 1048056 59263 753353 784318 647131 519679 294910 185560 604141 456668 849789 521404 782287 6137 1047551 849874 523933 521721 278491 1042415 581468 1013705 439526 1011709 917469 655311 327646 917499\n", "output": "24197296011217\n"}, {"inp... | code_stdio |
[
{
"content": "The goal of the matrix-chain multiplication problem is to find the most efficient way to multiply given $n$ matrices $M_1, M_2, M_3,...,M_n$.\n\nWrite a program which reads dimensions of $M_i$, and finds the minimum number of scalar multiplications to compute the maxrix-chain multiplication $M_1M_... | [{"input": "6\n30 35\n35 15\n15 5\n5 10\n10 20\n20 29", "output": "16125\n"}, {"input": "6\n30 35\n35 15\n15 5\n5 10\n10 20\n20 27", "output": "15625\n"}, {"input": "6\n30 35\n35 15\n15 5\n5 10\n10 20\n20 47", "output": "20625\n"}, {"input": "6\n30 35\n35 15\n15 5\n5 10\n10 20\n20 14", "output": "12375\n"}, {"input": "... | code_stdio |
[
{
"content": "There are $n$ athletes in front of you. Athletes are numbered from $1$ to $n$ from left to right. You know the strength of each athlete — the athlete number $i$ has the strength $s_i$.\n\nYou want to split all athletes into two teams. Each team must have at least one athlete, and each athlete must... | [{"input": "5\n5\n3 1 2 10 4\n6\n2 1 3 4 4 3\n4\n14 9 3 1\n2\n0 1000\n3\n110 150 200\n", "output": "1\n0\n2\n1000\n40\n"}, {"input": "5\n5\n3 1 2 10 4\n6\n2 1 3 4 4 3\n4\n14 9 3 1\n2\n0 1000\n3\n100 150 200\n", "output": "1\n0\n2\n1000\n50\n"}, {"input": "5\n5\n3 1 2 10 4\n6\n2 1 3 4 4 3\n4\n7 9 3 1\n2\n0 1000\n3\n100 ... | code_stdio |
[
{
"content": "# A History Lesson\n\nThe Pony Express was a mail service operating in the US in 1859-60.\n\n\n\n\n\nIt reduced the time for messages to travel between the Atlantic and Pacific coasts to about 10 days, before it was made obsolete by the transcontinental telegraph.\n\n# How it worked\n\nThere were ... | [{"input": "[6, 24, 6, 8, 28, 8, 23, 47, 17, 29, 37, 18, 40, 49]\n2", "output": "[5]", "fn_name": "riders"}, {"input": "[33, 8, 16, 47, 30, 30, 46]\n5", "output": "[5]", "fn_name": "riders"}, {"input": "[50, 100, 25, 50, 26]\n3", "output": "[6]", "fn_name": "riders"}, {"input": "[50, 50, 25, 50, 24]\n3", "output": "[3]... | code_functional |
[
{
"content": "Your security guard friend recently got a new job at a new security company. The company requires him to patrol an area of the city encompassing exactly N city blocks, but they let him choose which blocks. That is, your friend must walk the perimeter of a region whose area is exactly N blocks. You... | [{"input": "1000000\n", "output": "4000\n"}, {"input": "1000000\n", "output": "4000\n"}, {"input": "999000\n", "output": "3998\n"}, {"input": "999001\n", "output": "4000\n"}, {"input": "999999\n", "output": "4000\n"}, {"input": "933206\n", "output": "3866\n"}, {"input": "718351\n", "output": "3392\n"}, {"input": "60744... | code_stdio |
[
{
"content": "Logical quantifiers are very useful tools for expressing claims about a set. For this problem, let's focus on the set of real numbers specifically. The set of real numbers includes zero and negatives. There are two kinds of quantifiers: universal ($\\forall$) and existential ($\\exists$). You can ... | [{"input": "100 50\n55 13\n84 2\n22 63\n100 91\n2 18\n98 64\n1 86\n93 11\n17 6\n24 97\n14 35\n24 74\n22 3\n42 5\n63 79\n31 89\n81 22\n86 88\n77 51\n81 34\n19 55\n41 54\n34 57\n45 9\n55 72\n67 61\n41 84\n39 32\n51 89\n58 74\n32 79\n65 6\n86 64\n63 42\n100 57\n46 39\n100 9\n23 58\n26 81\n61 49\n71 83\n66 2\n79 74\n30 27\... | code_stdio |
[
{
"content": "Kawashiro Nitori is a girl who loves competitive programming.\n\nOne day she found a string and an integer. As an advanced problem setter, she quickly thought of a problem.\n\nGiven a string $s$ and a parameter $k$, you need to check if there exist $k+1$ non-empty strings $a_1,a_2...,a_{k+1}$, suc... | [{"input": "7\n5 2\nrwrwq\n2 0\nac\n3 1\nioi\n4 0\nibdp\n22 0\ndokidoktliteraiureclub\n19 0\necilbiahgaahsmnetmi\n6 2\naaaaaa\n", "output": "NO\nYES\nYES\nYES\nYES\nYES\nYES\n"}, {"input": "7\n5 1\nqwqwq\n2 0\nab\n3 1\nioi\n4 2\nipcc\n22 0\ncokidokiliteratureclub\n19 11\nimtdamshanghaialice\n6 2\naaaaaa\n", "output": "... | code_stdio |
[
{
"content": "Students in a class are making towers of blocks. Each student makes a (non-zero) tower by stacking pieces lengthwise on top of each other. n of the students use pieces made of two blocks and m of the students use pieces made of three blocks.\n\nThe students don’t want to use too many blocks, but t... | [{"input": "1000000 1000000\n", "output": "3000000\n"}, {"input": "1000000 1000000\n", "output": "3000000\n"}, {"input": "1000000 999999\n", "output": "2999998\n"}, {"input": "999999 1000000\n", "output": "3000000\n"}, {"input": "1000000 666667\n", "output": "2500000\n"}, {"input": "1000000 999999\n", "output": "299999... | code_stdio |
[
{
"content": "You are given a string S as input. This represents a valid date in the year 2019 in the yyyy/mm/dd format. (For example, April 30, 2019 is represented as 2019/04/30.)\nWrite a program that prints Heisei if the date represented by S is not later than April 30, 2019, and prints TBD otherwise.\n\n---... | [{"input": "2019/04/30\n", "output": "Heisei\n"}, {"input": "2019/01/01\n", "output": "Heisei\n"}, {"input": "2019/02/28\n", "output": "Heisei\n"}, {"input": "2019/04/29\n", "output": "Heisei\n"}, {"input": "2019/03/30", "output": "Heisei\n"}, {"input": "2019/04/20", "output": "Heisei\n"}, {"input": "1019/04/30", "outp... | code_stdio |
[
{
"content": "This contest, AtCoder Beginner Contest, is abbreviated as ABC.\nWhen we refer to a specific round of ABC, a three-digit number is appended after ABC. For example, ABC680 is the 680th round of ABC.\nWhat is the abbreviation for the N-th round of ABC? Write a program to output the answer.\n\n-----Co... | [{"input": "1530", "output": "ABC1530\n"}, {"input": "2825", "output": "ABC2825\n"}, {"input": "5621", "output": "ABC5621\n"}, {"input": "-105", "output": "ABC-105\n"}, {"input": "-136", "output": "ABC-136\n"}, {"input": "-215", "output": "ABC-215\n"}, {"input": "-111", "output": "ABC-111\n"}, {"input": "-104", "output... | code_stdio |
[
{
"content": "Complete the solution so that it returns true if it contains any duplicate argument values. Any number of arguments may be passed into the function.\n\nThe array values passed in will only be strings or numbers. The only valid return values are `true` and `false`.\n\nExamples:\n```\nsolution(1, 2,... | [{"input": "\"a\"\n\"b\"\n\"c\"\n\"d\"\n\"e\"\n\"f\"\n\"f\"\n\"b\"", "output": "[true]", "fn_name": "solution"}, {"input": "\"a\"\n\"b\"\n\"c\"\n\"d\"", "output": "[false]", "fn_name": "solution"}, {"input": "1\n2\n42\n3\n4\n5\n42", "output": "[true]", "fn_name": "solution"}, {"input": "\"a\"\n\"b\"\n\"c\"\n\"c\"", "ou... | code_functional |
[
{
"content": "## Description\n\nGiven an array X of positive integers, its elements are to be transformed by running the following operation on them as many times as required:\n\n```if X[i] > X[j] then X[i] = X[i] - X[j]```\n\nWhen no more transformations are possible, return its sum (\"smallest possible sum\")... | [{"input": "[71, 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, 71]", "output": "[923]", "fn_name": "solution"}, {"input": "[60, 12, 96, 48, 60, 24, 72, 36, 72, 72, 48]", "output": "[132]", "fn_name": "solution"}, {"input": "[3, 13, 23, 7, 83]", "output": "[5]", "fn_name": "solution"}, {"input": "[4, 16, 24]", "output": "... | code_functional |
[
{
"content": "Genos recently installed the game Zuma on his phone. In Zuma there exists a line of n gemstones, the i-th of which has color ci. The goal of the game is to destroy all the gemstones in the line as quickly as possible.\n\nIn one second, Genos is able to choose exactly one continuous substring of co... | [{"input": "50\n22 19 14 22 20 11 16 28 23 15 3 23 6 16 30 15 15 10 43 28 19 19 22 30 28 1 27 12 12 14 17 30 17 26 21 26 27 1 11 23 9 30 18 19 17 29 11 20 29 24\n", "output": "25\n"}, {"input": "50\n22 19 14 22 20 11 16 28 38 15 3 23 6 16 30 15 15 10 43 28 19 19 22 30 28 1 27 12 12 14 17 30 17 26 21 26 27 1 11 23 9 30 ... | code_stdio |
[
{
"content": "Little Chris is bored during his physics lessons (too easy), so he has built a toy box to keep himself occupied. The box is special, since it has the ability to change gravity.\n\nThere are n columns of toy cubes in the box arranged in a line. The i-th column contains a_{i} cubes. At first, the gr... | [{"input": "100\n100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100... | code_stdio |
[
{
"content": "We want to know the index of the vowels in a given word, for example, there are two vowels in the word super (the second and fourth letters). \n\nSo given a string \"super\", we should return a list of [2, 4].\n\n Some examples:\n Mmmm => []\n Super => [2,4]\n Apple =>... | [{"input": "\"supercalifragilisticexpialidocious\"", "output": "[[2, 4, 7, 9, 12, 14, 16, 19, 21, 24, 25, 27, 29, 31, 32, 33]]", "fn_name": "vowel_indices"}, {"input": "\"narboonnee\"", "output": "[[2, 5, 6, 9, 10]]", "fn_name": "vowel_indices"}, {"input": "\"UNDISARMED\"", "output": "[[1, 4, 6, 9]]", "fn_name": "vowel... | code_functional |
[
{
"content": "Koa the Koala and her best friend want to play a game.\n\nThe game starts with an array a of length n consisting of non-negative integers. Koa and her best friend move in turns and each have initially a score equal to 0. Koa starts.\n\nLet's describe a move in the game:\n\n * During his move, a p... | [{"input": "4\n5\n4 1 5 1 4\n4\n1 0 0 12\n1\n0\n2\n5 4\n", "output": "LOSE\nWIN\nDRAW\nWIN\n"}, {"input": "4\n5\n2 1 3 1 0\n4\n1 0 1 6\n1\n0\n2\n5 4\n", "output": "LOSE\nWIN\nDRAW\nWIN\n"}, {"input": "4\n5\n4 1 5 1 4\n4\n1 0 1 12\n1\n1\n2\n5 4\n", "output": "LOSE\nWIN\nWIN\nWIN\n"}, {"input": "4\n5\n4 1 5 1 3\n4\n1 0 0... | code_stdio |
[
{
"content": "The King of a little Kingdom on a little island in the Pacific Ocean frequently has childish ideas. One day he said, “You shall make use of a message relaying game when you inform me of something.” In response to the King’s statement, six servants were selected as messengers whose names were Mr. J... | [{"input": "5\nAJMP\naB33d\nE\n86AE\nAM\n-1\nMPJE\nWaEaETC302Q\nCP\nrTurnAGumdam1isdefferentf", "output": "33Bad\nAE86\n2-\nEC302QTWaEa\nTurnAGumdam0isdefferentfr\n"}, {"input": "5\nAJMP\naB33d\nE\n86AE\nMA\n-1\nMPJE\nWaEaETC302Q\nCP\nftnereffedsi1madmuGAnruTr", "output": "33Bad\nAE86\n2-\nEC302QTWaEa\ntnereffedsi0madm... | code_stdio |
[
{
"content": "One day, little Vasya found himself in a maze consisting of (n + 1) rooms, numbered from 1 to (n + 1). Initially, Vasya is at the first room and to get out of the maze, he needs to get to the (n + 1)-th one.\n\nThe maze is organized as follows. Each room of the maze has two one-way portals. Let's ... | [{"input": "129\n1 1 3 3 1 4 7 4 3 5 8 11 3 9 15 4 11 17 1 6 18 9 11 13 17 22 8 18 26 13 16 20 3 16 35 26 23 28 27 30 39 29 43 8 14 6 17 32 26 31 2 18 3 47 52 21 57 1 35 35 53 47 16 26 30 65 48 2 32 11 10 5 4 1 4 53 71 21 53 8 58 49 17 6 19 80 1 49 43 60 12 60 35 25 86 45 47 97 52 74 10 91 93 31 69 41 80 90 67 4 94 92 ... | code_stdio |
[
{
"content": "$2^n$ teams participate in a playoff tournament. The tournament consists of $2^n - 1$ games. They are held as follows: in the first phase of the tournament, the teams are split into pairs: team $1$ plays against team $2$, team $3$ plays against team $4$, and so on (so, $2^{n-1}$ games are played i... | [{"input": "7\n1011011\n", "output": "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 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 11... | code_stdio |
[
{
"content": "You are given a table consisting of n rows and m columns. Each cell of the table contains a number, 0 or 1. In one move we can choose some row of the table and cyclically shift its values either one cell to the left, or one cell to the right.\n\nTo cyclically shift a table row one cell to the righ... | [{"input": "10 10\n0000000000\n0000001000\n0000000100\n0101000100\n0000000000\n0000000000\n1000110000\n1011010010\n0000100000\n0000001001\n", "output": "-1\n"}, {"input": "10 10\n0000000000\n0000000010\n0010000000\n0111000010\n1000000000\n0000000100\n0000000100\n0000100100\n0010000000\n0000100000\n", "output": "-1\n"},... | code_stdio |
[
{
"content": "You are given integers A and B, each between 1 and 3 (inclusive).\nDetermine if there is an integer C between 1 and 3 (inclusive) such that A \\times B \\times C is an odd number.\n\n-----Constraints-----\n - All values in input are integers.\n - 1 \\leq A, B \\leq 3\n\n-----Input-----\nInput is g... | [{"input": "-1 -1", "output": "Yes\n"}, {"input": "-3 -1", "output": "Yes\n"}, {"input": "-1 -3", "output": "Yes\n"}, {"input": "-5 -1", "output": "Yes\n"}, {"input": "-1 -5", "output": "Yes\n"}, {"input": "-3 -3", "output": "Yes\n"}, {"input": "-12 -2", "output": "No\n"}, {"input": "3 1\n", "output": "Yes\n"}, {"input... | code_stdio |
[
{
"content": "You are given an array of integers. Your task is to sort odd numbers within the array in ascending order, and even numbers in descending order.\n\nNote that zero is an even number. If you have an empty array, you need to return it.\n\n\nFor example:\n```\n[5, 3, 2, 8, 1, 4] --> [1, 3, 8, 4, 5, 2... | [{"input": "[1, 2, 3, 4, 5, 6, 7, 8, 9, 0]", "output": "[[1, 8, 3, 6, 5, 4, 7, 2, 9, 0]]", "fn_name": "sort_array"}, {"input": "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]", "output": "[[8, 1, 6, 3, 4, 5, 2, 7, 0, 9]]", "fn_name": "sort_array"}, {"input": "[0, 1, 2, 3, 4, 9, 8, 7, 6, 5]", "output": "[[8, 1, 6, 3, 4, 5, 2, 7, 0, 9]]... | code_functional |
[
{
"content": "Greatest common divisor GCD(a, b) of two positive integers a and b is equal to the biggest integer d such that both integers a and b are divisible by d. There are many efficient algorithms to find greatest common divisor GCD(a, b), for example, Euclid algorithm. \n\nFormally, find the biggest inte... | [{"input": "10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "output": "10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000... | code_stdio |
[
{
"content": "One day student Vasya was sitting on a lecture and mentioned a string s1s2... sn, consisting of letters \"a\", \"b\" and \"c\" that was written on his desk. As the lecture was boring, Vasya decided to complete the picture by composing a graph G with the following properties: \n\n * G has exactly ... | [{"input": "15 84\n11 9\n3 11\n13 10\n2 12\n5 9\n1 7\n14 4\n14 2\n14 1\n11 8\n1 8\n14 10\n4 15\n10 5\n5 12\n13 11\n6 14\n5 7\n12 11\n9 1\n10 15\n2 6\n7 15\n14 9\n9 7\n11 14\n8 15\n12 7\n13 6\n2 9\n9 6\n15 3\n12 15\n6 15\n4 6\n4 1\n9 12\n10 7\n6 1\n11 10\n2 3\n5 2\n13 2\n13 3\n12 6\n4 3\n5 8\n12 1\n9 15\n14 5\n12 14\n10... | code_stdio |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.