messages listlengths 1 1 | ground_truth stringlengths 156 726k | dataset stringclasses 2
values |
|---|---|---|
[
{
"content": "This problem consists of three subproblems: for solving subproblem C1 you will receive 4 points, for solving subproblem C2 you will receive 4 points, and for solving subproblem C3 you will receive 8 points.\n\nManao decided to pursue a fighter's career. He decided to begin with an ongoing tourname... | [{"input": "40 3\n1 62395\n5 40319\n4 165445\n10 137479\n10 47829\n8 9741\n5 148106\n10 25494\n18 162856\n2 106581\n0 194523\n9 148086\n1 100862\n6 147600\n6 107486\n6 166873\n7 16721\n4 22192\n0 8827\n1 197146\n10 8949\n0 150443\n9 148348\n3 143935\n1 139371\n7 128821\n10 107760\n4 141821\n1 35852\n9 107522\n10 54717\... | code_stdio |
[
{
"content": "# Task\n\nElections are in progress!\n\nGiven an array of numbers representing votes given to each of the candidates, and an integer which is equal to the number of voters who haven't cast their vote yet, find the number of candidates who still have a chance to win the election.\n\nThe winner of t... | [{"input": "[1, 3, 3, 1, 1]\n0", "output": "[0]", "fn_name": "elections_winners"}, {"input": "[5, 1, 3, 4, 1]\n0", "output": "[1]", "fn_name": "elections_winners"}, {"input": "[3, 1, 1, 3, 1]\n2", "output": "[2]", "fn_name": "elections_winners"}, {"input": "[2, 3, 5, 2]\n3", "output": "[2]", "fn_name": "elections_winne... | code_functional |
[
{
"content": "**Getting Familiar:**\nLEET: (sometimes written as \"1337\" or \"l33t\"), also known as eleet or leetspeak, is another alphabet for the English language that is used mostly on the internet. It uses various combinations of ASCII characters to replace Latinate letters. For example, leet spellings of... | [{"input": "\"Do you also think these quotes are conflicting each other?\"", "output": "[\"\\u03b4\\u03b8 \\u03b3\\u03b8\\u03bc \\u03b1ls\\u03b8 \\u03c4h\\u03b9\\u03b7\\u03ba \\u03c4h\\u03b5s\\u03b5 q\\u03bc\\u03b8\\u03c4\\u03b5s \\u03b1\\u03c0\\u03b5 c\\u03b8\\u03b7fl\\u03b9c\\u03c4\\u03b9\\u03b7g \\u03b5\\u03b1ch \\u... | code_functional |
[
{
"content": "Our Chef is catering for a big corporate office party and is busy preparing different mouth watering dishes. The host has insisted that he serves his delicious cupcakes for dessert. \n\nOn the day of the party, the Chef was over-seeing all the food arrangements as well, ensuring that every item wa... | [{"input": "4\n38\n13\n31\n2", "output": "17\n12\n30\n1\n"}, {"input": "4\n38\n13\n16\n2", "output": "17\n12\n0\n1\n"}, {"input": "4\n131\n14\n1\n4", "output": "130\n5\n0\n0\n"}, {"input": "4\n19\n13\n16\n2", "output": "18\n12\n0\n1\n"}, {"input": "4\n131\n14\n1\n8", "output": "130\n5\n0\n2\n"}, {"input": "4\n34\n13\n1... | code_stdio |
[
{
"content": "You're looking through different hex codes, and having trouble telling the difference between #000001 and #100000 \n\nWe need a way to tell which is red, and which is blue!\n\nThat's where you create ```hex_color()```!\n\nIt should read an RGB input, and return whichever value (red, blue, or gr... | [{"input": "\"212 103 212\"", "output": "[\"magenta\"]", "fn_name": "hex_color"}, {"input": "\"101 101 092\"", "output": "[\"yellow\"]", "fn_name": "hex_color"}, {"input": "\"000 000 000\"", "output": "[\"black\"]", "fn_name": "hex_color"}, {"input": "\"021 021 021\"", "output": "[\"white\"]", "fn_name": "hex_color"}, ... | code_functional |
[
{
"content": "Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.\n\nOne day Petya encountered a tree with n vertexes. Besides, the tree was weig... | [{"input": "10\n4 7 480392999\n3 4 32525297\n9 7 417904789\n6 2 836294777\n5 3 616099185\n1 7 1310915575\n8 10 838073755\n5 10 547050646\n2 1 12607780\n", "output": "0\n"}, {"input": "10\n4 7 480392999\n3 4 32525297\n9 7 417904789\n6 2 836294777\n5 3 616099185\n1 7 1310915575\n8 10 838073755\n5 10 508595582\n2 1 126077... | code_stdio |
[
{
"content": "Lenny is playing a game on a 3 × 3 grid of lights. In the beginning of the game all lights are switched on. Pressing any of the lights will toggle it and all side-adjacent lights. The goal of the game is to switch all the lights off. We consider the toggling as follows: if the light was switched o... | [{"input": "62 74 119\n116 74 189\n2 47 95\n", "output": "101\n110\n010\n"}, {"input": "68 79 52\n51 39 100\n29 14 26\n", "output": "110\n000\n111\n"}, {"input": "68 79 52\n51 39 100\n29 14 26\n", "output": "110\n000\n111\n"}, {"input": "68 79 52\n67 39 100\n29 14 26\n", "output": "110\n000\n111\n"}, {"input": "13 148 ... | code_stdio |
[
{
"content": "problem\n\nThe island where JOI lives has been invaded by zombies. JOI decided to escape to the shelter, which is set as the safest shelter on the island.\n\nThe island where JOI lives consists of N towns from town 1 to town N, and the towns are connected by roads. There are M roads on the island,... | [{"input": "13 21 1 1\n1001 6000\n11\n4 2\n3 7\n2 4\n8 8\n8 4\n2 10\n3 4\n6 7\n7 10\n10 11\n5 9\n11 10\n3 6\n4 5\n1 6\n13 12\n6 7\n8 11\n6 13\n7 8\n2 12", "output": "1001\n"}, {"input": "13 21 1 1\n1010 10247\n7\n1 2\n3 7\n2 4\n5 8\n8 9\n2 5\n3 4\n4 7\n9 10\n10 11\n9 9\n7 12\n3 6\n5 5\n1 3\n11 12\n6 7\n8 11\n6 13\n7 8\... | code_stdio |
[
{
"content": "Vasya decided to go to the grocery store. He found in his wallet $a$ coins of $1$ burle and $b$ coins of $2$ burles. He does not yet know the total cost of all goods, so help him find out $s$ ($s > 0$): the minimum positive integer amount of money he cannot pay without change or pay at all using o... | [{"input": "7\n1 1\n4 0\n0 2\n0 0\n2314 2374\n0 0\n1 1\n", "output": "4\n5\n1\n1\n7063\n1\n4\n"}, {"input": "5\n1 1\n4 0\n0 2\n0 0\n2314 2374\n", "output": "4\n5\n1\n1\n7063\n"}, {"input": "1\n1123112 1221133\n", "output": "3565379\n"}, {"input": "1\n1223111 133212\n", "output": "1489536\n"}, {"input": "1\n112311 11332... | code_stdio |
[
{
"content": "You have a digit sequence S of length 4. You are wondering which of the following formats S is in:\n - YYMM format: the last two digits of the year and the two-digit representation of the month (example: 01 for January), concatenated in this order\n - MMYY format: the two-digit representation of t... | [{"input": "0112\n", "output": "AMBIGUOUS\n"}, {"input": "0101\n", "output": "AMBIGUOUS\n"}, {"input": "1211", "output": "AMBIGUOUS\n"}, {"input": "1204", "output": "AMBIGUOUS\n"}, {"input": "0112", "output": "AMBIGUOUS"}, {"input": "1905\n", "output": "YYMM\n"}, {"input": "1312\n", "output": "YYMM\n"}, {"input": "0348... | code_stdio |
[
{
"content": "This program tests the life of an\nevaporator containing a gas. \n\nWe know the content of the evaporator (content in ml),\nthe percentage of foam or gas lost every day (evap_per_day)\nand the threshold (threshold) in percentage beyond which\nthe evaporator is no longer useful.\nAll numbers are st... | [{"input": "10\n10\n10", "output": "[22]", "fn_name": "evaporator"}, {"input": "47.5\n8\n8", "output": "[31]", "fn_name": "evaporator"}, {"input": "100\n1\n1", "output": "[459]", "fn_name": "evaporator"}, {"input": "100\n1\n5", "output": "[299]", "fn_name": "evaporator"}, {"input": "10\n10\n5", "output": "[29]", "fn_na... | code_functional |
[
{
"content": "Read problems statements in Mandarin Chinese and Russian. \n\nRupsa recently started to intern under Chef. He gave her N type of ingredients of varying quantity A_{1}, A_{2}, ..., A_{N} respectively to store it. But as she is lazy to arrange them she puts them all in a storage box.\n\nChef comes... | [{"input": "2\n-1\n3 111\n-1\n9", "output": "113\n2\n"}, {"input": "2\n-1\n3 101\n-1\n9", "output": "103\n2\n"}, {"input": "2\n-2\n2 25\n-2\n16", "output": "27\n2\n"}, {"input": "2\n-1\n3 12\n-1\n9", "output": "14\n2\n"}, {"input": "2\n-1\n2 24\n0\n1", "output": "26\n-1\n"}, {"input": "2\n-1\n2 32\n0\n1", "output": "34... | code_stdio |
[
{
"content": "In Republic of AtCoder, Snuke Chameleons (Family: Chamaeleonidae, Genus: Bartaberia) are very popular pets. Ringo keeps N Snuke Chameleons in a cage.\n\nA Snuke Chameleon that has not eaten anything is blue. It changes its color according to the following rules:\n\n* A Snuke Chameleon that is blue... | [{"input": "29001 234567", "output": "246712986\n"}, {"input": "29001 137176", "output": "790285595\n"}, {"input": "18209 234567", "output": "750285457\n"}, {"input": "24437 137176", "output": "159086230\n"}, {"input": "123456 234567", "output": "857617983"}, {"input": "25732 234567", "output": "80550073\n"}, {"input":... | code_stdio |
[
{
"content": "According to a new ISO standard, a flag of every country should have a chequered field n × m, each square should be of one of 10 colours, and the flag should be «striped»: each horizontal row of the flag should contain squares of the same colour, and the colours of adjacent horizontal rows should ... | [{"input": "20 19\n1111111111111111111\n8247715032316286876\n0000001000000000000\n4784876473600342372\n1111111111111111111\n2222222222222222222\n4444444444444444444\n5555555555555555555\n0000000000000000010\n4444444444444444444\n0000000000000000000\n5555555555555555555\n11500026576261848309\n9999999999999999999\n222222... | code_stdio |
[
{
"content": "After finishing eating her bun, Alyona came up with two integers n and m. She decided to write down two columns of integers — the first column containing integers from 1 to n and the second containing integers from 1 to m. Now the girl wants to count how many pairs of integers she can choose, one ... | [{"input": "1000000 1000000\n", "output": "200000000000\n"}, {"input": "1000000 1000000\n", "output": "200000000000\n"}, {"input": "1000010 1000000\n", "output": "200002000000\n"}, {"input": "1000000 1892547\n", "output": "378509400000\n"}, {"input": "1000000 999999\n", "output": "199999800000\n"}, {"input": "1000000 9... | code_stdio |
[
{
"content": "When you play the game of thrones, you win, or you die. There is no middle ground.\n\nCersei Lannister, A Game of Thrones by George R. R. Martin\n\nThere are n nobles, numbered from 1 to n. Noble i has a power of i. There are also m \"friendships\". A friendship between nobles a and b is always mu... | [{"input": "20 53\n1 2\n1 4\n1 5\n1 6\n1 7\n1 8\n1 20\n2 3\n2 6\n2 16\n2 17\n3 6\n3 18\n3 20\n4 6\n4 7\n4 8\n4 18\n4 14\n4 18\n5 11\n5 16\n5 17\n2 18\n5 19\n6 8\n6 13\n7 8\n7 10\n7 15\n7 17\n14 18\n8 15\n8 16\n4 10\n17 15\n10 11\n10 17\n10 20\n11 15\n11 17\n12 14\n12 15\n12 16\n16 19\n14 16\n14 19\n16 17\n16 19\n16 20\... | code_stdio |
[
{
"content": "You are given strings $S$ and $T$, consisting of lowercase English letters. It is guaranteed that $T$ is a permutation of the string abc.\n\nFind string $S'$, the lexicographically smallest permutation of $S$ such that $T$ is not a subsequence of $S'$.\n\nString $a$ is a permutation of string $b$ ... | [{"input": "7\nabacaba\nabc\ncccba\nacb\ndbsic\nbac\nabracadabra\nabc\ndddddddddddd\ncba\nbbc\nabc\nac\nabc\n", "output": "aaaacbb\nabccc\nbcdis\naaaaacbbdrr\ndddddddddddd\nbbc\nac\n"}, {"input": "7\nabacaba\nabc\ncccba\nacb\ndbsic\nbac\nabracadabra\nabc\ndddddddddddd\ncba\nbbc\nabd\nac\nabc\n", "output": "aaaacbb\nabc... | code_stdio |
[
{
"content": "Create a program that calculates and outputs the surface distance by inputting the north latitude and east longitude of two cities on the earth. However, the earth is a sphere with a radius of 6,378.1 km, and the surface distance between two points is the shortest distance along this sphere. Also,... | [{"input": "35.997652258458864 139.77 51.15 361.449066466584\n1.6512558665331527 105.35573273382599 41.78 272.61282853754\n51.62303215206055 360.59086045680647 -34.03891385785915 302.61951676416413\n-1 -1 -1 -1", "output": "9516\n15035\n11082\n"}, {"input": "36.419905643051294 140.79075983005347 51.9267392966014 359.97... | code_stdio |
[
{
"content": "Vova promised himself that he would never play computer games... But recently Firestorm — a well-known game developing company — published their newest game, World of Farcraft, and it became really popular. Of course, Vova started playing it.\n\nNow he tries to solve a quest. The task is to come t... | [{"input": "10 5\n1 6 2 11 3 8 4 9 5 10\n1 2\n3 5\n5 6\n7 10\n9 10\n", "output": "27\n"}, {"input": "10 3\n1 6 2 27 1 8 1 9 5 1\n1 2\n3 1\n10 6\n7 8\n17 10\n", "output": "45\n"}, {"input": "10 3\n1 6 2 17 1 8 1 9 5 1\n1 2\n3 1\n10 6\n7 8\n17 10\n", "output": "35\n"}, {"input": "10 3\n1 6 2 17 1 8 1 9 5 1\n1 2\n3 1\n10 ... | code_stdio |
[
{
"content": "Given are an integer X and an integer sequence of length N: p_1, \\ldots, p_N.\nAmong the integers not contained in the sequence p_1, \\ldots, p_N (not necessarily positive), find the integer nearest to X, that is, find the integer whose absolute difference with X is the minimum. If there are mult... | [{"input": "51 100\n70 94 98 62 63 19 59 50 36 48 97 82 53 5 3 96 51 13 64 79 65 23 75 72 74 87 100 43 81 42 71 34 57 88 60 77 31 12 10 52 29 92 66 1 61 90 21 55 22 30 14 35 41 2 78 37 15 73 69 58 25 67 28 16 99 38 85 33 20 95 32 24 80 40 4 45 11 83 7 17 91 89 54 18 26 56 9 27 68 47 76 93 39 84 8 49 86 6 44 46\n", "out... | code_stdio |
[
{
"content": "Ivan recently bought a detective book. The book is so interesting that each page of this book introduces some sort of a mystery, which will be explained later. The $i$-th page contains some mystery that will be explained on page $a_i$ ($a_i \\ge i$).\n\nIvan wants to read the whole book. Each day,... | [{"input": "17\n15 4 3 6 5 11 8 8 9 10 15 12 13 14 17 16 17\n", "output": "1\n"}, {"input": "17\n16 4 3 6 7 6 10 8 9 10 11 12 13 14 15 16 17\n", "output": "2\n"}, {"input": "17\n9 4 3 6 7 6 10 8 9 10 11 12 13 14 15 16 17\n", "output": "8\n"}, {"input": "17\n15 4 3 6 7 6 8 8 9 10 15 12 13 14 17 16 17\n", "output": "1\n"... | code_stdio |
[
{
"content": "In this kata, the number 0 is infected. You are given a list. Every turn, any item in the list that is adjacent to a 0 becomes infected and transforms into a 0. How many turns will it take for the whole list to become infected?\n\n```\n[0,1,1,0] ==> [0,0,0,0] \nAll infected in 1 turn.\n\n[1,1,0,1,... | [{"input": "[0, 1, 1, 1, 0]", "output": "[2]", "fn_name": "infected_zeroes"}, {"input": "[1, 1, 0, 1, 1]", "output": "[2]", "fn_name": "infected_zeroes"}, {"input": "[0, 1, 1, 0]", "output": "[1]", "fn_name": "infected_zeroes"}, {"input": "[0, 1, 1, 1]", "output": "[3]", "fn_name": "infected_zeroes"}, {"input": "[1, 1,... | code_functional |
[
{
"content": "Let x be a string of length at least 1.\nWe will call x a good string, if for any string y and any integer k (k \\geq 2), the string obtained by concatenating k copies of y is different from x.\nFor example, a, bbc and cdcdc are good strings, while aa, bbbb and cdcdcd are not.\nLet w be a string o... | [{"input": "bcbc\n", "output": "2\n3\n"}, {"input": "aab\n", "output": "1\n1\n"}, {"input": "ddd\n", "output": "3\n1\n"}, {"input": "adad", "output": "2\n3\n"}, {"input": "bbcc", "output": "1\n1\n"}, {"input": "ccbb", "output": "1\n1\n"}, {"input": "ccbc", "output": "1\n1\n"}, {"input": "cbbc", "output": "1\n1\n"}, {"i... | code_stdio |
[
{
"content": "problem\n\nThere is one bar-shaped candy with a length of N mm (where N is an even number). Two JOI officials decided to cut this candy into multiple pieces and divide them into a total of N / 2 mm. did.\n\nFor unknown reasons, this candy has different ease of cutting depending on the location. Th... | [{"input": "6\n-1\n0\n14\n-1\n6", "output": "-2\n"}, {"input": "6\n-1\n0\n14\n-2\n6", "output": "-3\n"}, {"input": "6\n0\n0\n14\n-4\n6", "output": "-4\n"}, {"input": "6\n0\n0\n5\n-1\n1", "output": "-1\n"}, {"input": "6\n1\n14\n11\n3\n2", "output": "4\n"}, {"input": "6\n2\n12\n11\n7\n3", "output": "9\n"}, {"input": "6\n... | code_stdio |
[
{
"content": "Kolya got an integer array $a_1, a_2, \\dots, a_n$. The array can contain both positive and negative integers, but Kolya doesn't like $0$, so the array doesn't contain any zeros.\n\nKolya doesn't like that the sum of some subsegments of his array can be $0$. The subsegment is some consecutive segm... | [{"input": "100\n-6 2 8 -9 -9 3 -3 -2 7 3 2 -2 -9 -7 -10 -9 10 4 5 -9 8 -5 7 -2 6 -2 4 4 -2 -5 6 4 8 -8 9 7 -4 2 -3 7 4 -10 -7 -4 8 2 10 -8 -3 -8 -5 -5 -10 -6 -8 -5 7 -1 7 -5 9 10 3 5 10 -7 -3 -7 1 -5 -8 5 1 -1 4 10 2 6 -4 9 3 10 -5 -10 -10 -2 1 9 10 1 10 2 8 -3 -3 -1 7 -5 8 -4\n", "output": "11\n"}, {"input": "100\n-6... | code_stdio |
[
{
"content": "All cinema halls in Berland are rectangles with K rows of K seats each, and K is an odd number. Rows and seats are numbered from 1 to K. For safety reasons people, who come to the box office to buy tickets, are not allowed to choose seats themselves. Formerly the choice was made by a cashier, but ... | [{"input": "100 67\n66 12 2 49 62 63 59 14 13 26 15 25 22 16 33 17 15 14 13 33 9 10 53 28 17 27 18 39 35 64 1 59 33 24 66 64 4 2 4 5 22 9 52 36 44 57 62 3 52 21 62 55 25 2 65 18 20 40 8 30 27 28 47 19 67 67 42 6 53 17 36 38 57 37 45 13 58 12 31 24 15 67 9 18 56 20 34 8 20 31 13 19 42 12 16 15 54 35 20 33\n", "output": ... | code_stdio |
[
{
"content": "It's hard times now. Today Petya needs to score 100 points on Informatics exam. The tasks seem easy to Petya, but he thinks he lacks time to finish them all, so he asks you to help with one..\n\nThere is a glob pattern in the statements (a string consisting of lowercase English letters, characters... | [{"input": "k\n*\n89\nb\ncbbbc\ncabac\nbccbb\nccc\ncabaa\nabbaa\nccbaa\nccccb\ncabbb\nbbcbc\nbac\naaac\nabb\nbcbb\ncb\nbacc\nbbaba\nb\nacc\nbaac\naaba\nbcbba\nbaa\nbc\naaccb\nb\nab\nc\nbbbb\nabbcb\nacbb\ncba\nc\nbac\nc\nac\ncc\nb\nbbc\nbaab\nc\nbbc\nab\nb\nc\naa\naab\nab\naccbc\nacbaa\na\nccc\ncba\nb\nb\nbcccb\nca\naca... | code_stdio |
[
{
"content": "Alice and Bob like games. And now they are ready to start a new game. They have placed n chocolate bars in a line. Alice starts to eat chocolate bars one by one from left to right, and Bob — from right to left. For each chocololate bar the time, needed for the player to consume it, is known (Alice... | [{"input": "13\n4 18 16 10 10 13 24 2 4 9 2 10 13\n", "output": "6 7\n"}, {"input": "13\n4 18 16 10 10 13 17 2 4 9 2 9 13\n", "output": "5 8\n"}, {"input": "13\n4 18 16 10 10 13 24 2 4 9 2 9 13\n", "output": "6 7\n"}, {"input": "13\n4 18 16 10 10 14 24 2 4 9 2 9 13\n", "output": "6 7\n"}, {"input": "13\n4 18 16 10 7 14... | code_stdio |
[
{
"content": "From \"ftying rats\" to urban saniwation workers - can synthetic biology tronsform how we think of pigeons? \n\nThe upiquitous pigeon has long been viewed as vermin - spleading disease, scavenging through trush, and defecating in populous urban spases. Yet they are product of selextive breeding fo... | [{"input": "10\n9 16 19 23 7 14 21 15 14 6\n", "output": "23\n"}, {"input": "10\n5 20 18 1 12 17 22 20 26 4\n", "output": "21\n"}, {"input": "10\n9 16 19 23 7 14 21 15 14 6\n", "output": "23\n"}, {"input": "10\n5 20 18 1 12 17 22 20 26 4\n", "output": "21\n"}, {"input": "10\n9 16 19 23 7 14 21 15 1 6\n", "output": "20\... | code_stdio |
[
{
"content": "Given is an integer sequence of length N: A_1, A_2, \\cdots, A_N.\nAn integer sequence X, which is also of length N, will be chosen randomly by independently choosing X_i from a uniform distribution on the integers 1, 2, \\ldots, A_i for each i (1 \\leq i \\leq N).\nCompute the expected value of t... | [{"input": "6\n680824625 680824626 680824626 680824624 680824626 680824624\n", "output": "655804632\n"}, {"input": "6\n612348318 612348320 612348320 612348319 612348318 612348317\n", "output": "110656261\n"}, {"input": "6\n101617840 101617840 101617841 101617840 101617843 101617842\n", "output": "943012313\n"}, {"input... | code_stdio |
[
{
"content": "Oleg the bank client checks share prices every day. There are n share prices he is interested in. Today he observed that each second exactly one of these prices decreases by k rubles (note that each second exactly one price changes, but at different seconds different prices can change). Prices can... | [{"input": "100 18\n489 42 300 366 473 105 220 448 70 488 201 396 168 281 67 235 324 291 313 387 407 223 39 144 224 233 72 318 229 377 62 171 448 119 354 282 147 447 260 384 172 199 67 326 311 431 337 142 281 202 404 468 38 120 90 437 33 420 249 372 367 253 255 411 309 333 103 176 162 120 203 41 352 478 216 498 224 31 ... | code_stdio |
[
{
"content": "The only difference between easy and hard versions is the number of elements in the array.\n\nYou are given an array $a$ consisting of $n$ integers. In one move you can choose any $a_i$ and divide it by $2$ rounding down (in other words, in one move you can set $a_i := \\lfloor\\frac{a_i}{2}\\rflo... | [{"input": "50 25\n199970 199997 199998 199988 199999 199981 200000 199990 199974 199985 199932 200000 199966 199999 199999 199951 199983 199975 199974 199996 199974 199992 199979 199995 199955 199989 199960 199975 199983 199990 199950 199952 199999 199999 199962 199939 199979 199977 199962 199996 199910 199997 199976 ... | code_stdio |
[
{
"content": "The courier charges for a courier company are set according to size and weight as shown in the table below.\n\nA size | B size | C size | D size | E size | F size\n--- | --- | --- | --- | --- | --- | ---\nSize | 60 cm or less | 80 cm or less | 100 cm or less | 120 cm or less | 140 cm or less | 160... | [{"input": "2\n86 25 5 5\n135 60 10 30\n3\n10 8 25 24\n5 16 13 9\n30 30 30 14\n0", "output": "1200\n3800\n"}, {"input": "2\n51 0 5 15\n107 60 3 30\n3\n10 15 25 47\n2 12 12 3\n30 30 11 11\n0", "output": "1200\n2000\n"}, {"input": "2\n50 34 5 5\n80 60 10 30\n3\n10 15 25 24\n5 8 12 5\n30 30 30 18\n0", "output": "1000\n380... | code_stdio |
[
{
"content": "Carving the cake 2 (Cake 2)\n\nJOI-kun and IOI-chan are twin brothers and sisters. JOI has been enthusiastic about making sweets lately, and JOI tried to bake a cake and eat it today, but when it was baked, IOI who smelled it came, so we decided to divide the cake. became.\n\nThe cake is round. We... | [{"input": "5\n-1\n3\n2\n132\n24", "output": "134\n"}, {"input": "5\n2\n27\n-1\n12\n87", "output": "113\n"}, {"input": "5\n2\n27\n-1\n12\n88", "output": "114\n"}, {"input": "5\n-1\n6\n2\n101\n27", "output": "106\n"}, {"input": "5\n3\n16\n-1\n18\n35", "output": "50\n"}, {"input": "5\n3\n16\n-2\n15\n35", "output": "49\n"... | code_stdio |
[
{
"content": "In this Kata, we are going to determine if the count of each of the characters in a string can be equal if we remove a single character from that string.\n\nFor example:\n```\nsolve('abba') = false -- if we remove any character, the count of each character will not be equal.\nsolve('abbba') = true... | [{"input": "\"aabbccddd\"", "output": "[true]", "fn_name": "solve"}, {"input": "\"aaabcde\"", "output": "[false]", "fn_name": "solve"}, {"input": "\"aabbcc\"", "output": "[false]", "fn_name": "solve"}, {"input": "\"aaaabb\"", "output": "[false]", "fn_name": "solve"}, {"input": "\"abbccc\"", "output": "[false]", "fn_nam... | code_functional |
[
{
"content": "Vlad likes to eat in cafes very much. During his life, he has visited cafes n times. Unfortunately, Vlad started to feel that his last visits are not any different from each other. To fix that Vlad had a small research.\n\nFirst of all, Vlad assigned individual indices to all cafes. Then, he wrote... | [{"input": "8\n200000 1 200000 1 200000 1 200000 2\n", "output": "1\n"}, {"input": "8\n200000 1 200000 1 200000 1 200000 2\n", "output": "1\n"}, {"input": "5\n100 1000 1000 1000 1000\n", "output": "100\n"}, {"input": "5\n100 1000 1000 1000 1000\n", "output": "100\n"}, {"input": "5\n100 1000 1000 1100 1000\n", "output":... | code_stdio |
[
{
"content": "AquaMoon has $n$ friends. They stand in a row from left to right, and the $i$-th friend from the left wears a T-shirt with a number $a_i$ written on it. Each friend has a direction (left or right). In the beginning, the direction of each friend is right.\n\nAquaMoon can make some operations on fri... | [{"input": "10\n10\n6 2 1 1 1 10 10 2 10 5\n8\n1 3 1 1 4 5 4 4\n9\n14 6 9 9 2 8 7 2 2\n10\n9 4 3 3 5 4 3 10 4 5\n9\n7 5 1 7 5 5 5 5 6\n8\n8 8 4 4 7 6 2 8\n10\n6 8 1 6 8 8 5 6 8 4\n10\n5 5 5 8 3 4 3 3 10 10\n8\n1 1 3 6 6 7 1 2\n8\n4 1 3 5 3 1 3 3\n", "output": "NO\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nNO\n"}, {"input... | code_stdio |
[
{
"content": "The Two-dimensional kingdom is going through hard times... This morning the Three-Dimensional kingdom declared war on the Two-dimensional one. This (possibly armed) conflict will determine the ultimate owner of the straight line.\n\nThe Two-dimensional kingdom has a regular army of n people. Each ... | [{"input": "33 23 17 2\n1 1 2 2 2 3 3 3 3 3 3 4 4 4 4 4 5 5 5 6 6 7 7 7 8 8 8 8 8 9 9 10 10\n1 1 3 3 4 4 4 5 5 6 6 6 7 8 8 8 8 8 8 9 9 10 10\n", "output": "23\n1 1\n2 2\n3 3\n4 4\n5 5\n6 6\n7 7\n8 8\n9 9\n12 10\n13 11\n14 12\n17 13\n20 14\n21 15\n22 16\n23 17\n24 18\n25 19\n26 20\n27 21\n28 22\n29 23\n"}, {"input": "20... | code_stdio |
[
{
"content": "In some other world, today is the day before Christmas Eve.\nMr. Takaha is buying N items at a department store. The regular price of the i-th item (1 \\leq i \\leq N) is p_i yen (the currency of Japan).\nHe has a discount coupon, and can buy one item with the highest price for half the regular pr... | [{"input": "10\n10000\n10000\n10000\n10000\n10000\n10000\n10000\n10000\n10000\n10000\n", "output": "95000\n"}, {"input": "10\n8830\n106\n9248\n6388\n3562\n7160\n8452\n3486\n5802\n9228\n", "output": "57638\n"}, {"input": "9\n6126\n5482\n9198\n9274\n2166\n2424\n1954\n2018\n1226\n", "output": "35231\n"}, {"input": "8\n346... | code_stdio |
[
{
"content": "There are $n$ students standing in a row. Two coaches are forming two teams — the first coach chooses the first team and the second coach chooses the second team.\n\nThe $i$-th student has integer programming skill $a_i$. All programming skills are distinct and between $1$ and $n$, inclusive.\n\nF... | [{"input": "100 10\n19 55 91 50 31 23 60 84 38 1 22 51 27 76 28 98 11 44 61 63 15 93 52 3 66 16 53 36 18 62 35 85 78 37 73 64 87 74 46 26 82 69 49 33 83 89 56 67 71 25 39 94 96 17 21 6 47 68 34 42 57 81 13 10 54 2 48 80 20 77 4 5 59 30 90 95 45 75 8 88 24 41 40 14 97 32 7 9 65 70 100 99 72 58 92 29 79 12 86 43\n", "out... | code_stdio |
[
{
"content": "Find the largest integer that can be formed with exactly N matchsticks, under the following conditions:\n - Every digit in the integer must be one of the digits A_1, A_2, ..., A_M (1 \\leq A_i \\leq 9).\n - The number of matchsticks used to form digits 1, 2, 3, 4, 5, 6, 7, 8, 9 should be 2, 5, 5, ... | [{"input": "10000 9\n1 2 3 4 5 6 7 8 9\n", "output": "11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111... | code_stdio |
[
{
"content": "# Scenario \n\nWith **_Cereal crops_** like wheat or rice, before we can eat the grain kernel, we need to remove that inedible hull, or *to separate the wheat from the chaff*.\n___\n\n# Task\n\n**_Given_** a *sequence of n integers* , **_separate_** *the negative numbers (chaff) from positive ones... | [{"input": "[-16, 44, -7, -31, 9, -43, -44, -18, 50, 39, -46, -24, 3, -34, -27]", "output": "[[-16, -27, -7, -31, -34, -43, -44, -18, -24, -46, 39, 50, 3, 9, 44]]", "fn_name": "wheat_from_chaff"}, {"input": "[-17, 7, -12, 10, 4, -8, -19, -24, 40, 31, -29, 21, -45, 1]", "output": "[[-17, -45, -12, -29, -24, -8, -19, 4, ... | code_functional |
[
{
"content": "Snuke has a string x of length N. Initially, every character in x is `0`.\n\nSnuke can do the following two operations any number of times in any order:\n\n* Choose A consecutive characters in x and replace each of them with `0`.\n* Choose B consecutive characters in x and replace each of them wit... | [{"input": "1000 101 10", "output": "631009281\n"}, {"input": "1100 101 10", "output": "915151017\n"}, {"input": "1100 111 10", "output": "890861662\n"}, {"input": "1100 100 10", "output": "725819821\n"}, {"input": "1100 101 19", "output": "724720670\n"}, {"input": "1000 100 17", "output": "719982564\n"}, {"input": "11... | code_stdio |
[
{
"content": "Problem\n\nTaro decided to watch one movie every day at a nearby movie theater during the summer vacation. (Taro has 31 days of summer vacation from August 1st to August 31st.)\n\nThe theater is set to show n movies during the summer vacation. Each movie is assigned a number from 1 to n, and the i... | [{"input": "5\n1 18\n10 20\n20 21\n22 31\n10 15", "output": "1800\n"}, {"input": "5\n1 18\n10 20\n20 21\n22 31\n11 15", "output": "1800\n"}, {"input": "5\n1 18\n10 20\n20 21\n22 31\n10 25", "output": "1800\n"}, {"input": "5\n1 18\n16 20\n20 21\n22 31\n11 15", "output": "1800\n"}, {"input": "5\n1 10\n10 20\n20 21\n22 31... | code_stdio |
[
{
"content": "Mahmoud has an array a consisting of n integers. He asked Ehab to find another array b of the same length such that:\n\n b is lexicographically greater than or equal to a. b_{i} ≥ 2. b is pairwise coprime: for every 1 ≤ i < j ≤ n, b_{i} and b_{j} are coprime, i. e. GCD(b_{i}, b_{j}) = 1, where ... | [{"input": "10\n5 3 2 2 3 3 3 4 2 5\n", "output": "5 3 2 7 11 13 17 19 23 29 "}, {"input": "10\n5 3 2 2 3 3 3 4 2 5\n", "output": "5 3 2 7 11 13 17 19 23 29 "}, {"input": "10\n5 3 4 2 3 3 3 4 2 5\n", "output": "5 3 4 7 11 13 17 19 23 29\n"}, {"input": "7\n23 11 6 14 7 17 20\n", "output": "23 11 6 17 5 7 13\n"}, {"input... | code_stdio |
[
{
"content": "You are given two positive integers ```a``` and ```b```.\n\nYou can perform the following operations on ```a``` so as to obtain ```b``` :\n```\n(a-1)/2 (if (a-1) is divisible by 2)\na/2 (if a is divisible by 2)\na*2\n```\n```b``` will always be a power of 2.\n\nYou are to write a function ... | [{"input": "4\n16", "output": "[2]", "fn_name": "operation"}, {"input": "1\n1", "output": "[0]", "fn_name": "operation"}, {"input": "2\n4", "output": "[1]", "fn_name": "operation"}, {"input": "3\n8", "output": "[4]", "fn_name": "operation"}, {"input": "4\n1", "output": "[2]", "fn_name": "operation"}, {"input": "1\n4", ... | code_functional |
[
{
"content": "Dreamoon likes sequences very much. So he created a problem about the sequence that you can't find in OEIS: \n\nYou are given two integers d, m, find the number of arrays a, satisfying the following constraints:\n\n * The length of a is n, n ≥ 1 \n * 1 ≤ a_1 < a_2 < ... < a_n ≤ d \n * Define an... | [{"input": "10\n1 1100000000\n2 1587398050\n4 99999998\n4 9999997\n5 999996\n10 99995\n9 9994\n8 1104\n12 92\n19 1\n", "output": "1\n3\n11\n11\n17\n119\n89\n59\n87\n0\n"}, {"input": "10\n1 1100000000\n2 1587398050\n3 99999998\n4 9999997\n5 999996\n18 99995\n9 9994\n8 1104\n12 92\n36 1\n", "output": "1\n3\n5\n11\n17\n10... | code_stdio |
[
{
"content": "Welcome to PC Koshien, players. Physical condition management is important to participate in the event. It is said that at the turn of the season when the temperature fluctuates greatly, it puts a strain on the body and it is easy to catch a cold. The day you should be careful about is the day whe... | [{"input": "30 20\n55 0\n32 18\n2 23\n43 21\n34 10\n20 -13", "output": "10\n55\n14\n-21\n22\n24\n33\n"}, {"input": "30 19\n39 20\n19 18\n4 20\n22 21\n23 10\n10 -10", "output": "11\n19\n1\n-16\n1\n13\n20\n"}, {"input": "30 19\n39 20\n19 18\n4 20\n22 21\n23 10\n15 -10", "output": "11\n19\n1\n-16\n1\n13\n25\n"}, {"input":... | code_stdio |
[
{
"content": "Little Chris is a huge fan of linear algebra. This time he has been given a homework about the unusual square of a square matrix.\n\nThe dot product of two integer number vectors x and y of size n is the sum of the products of the corresponding components of the vectors. The unusual square of an n... | [{"input": "5\n1 0 1 0 1\n0 1 0 1 0\n1 0 1 0 1\n0 1 0 1 0\n1 0 1 0 1\n7\n3\n2 4\n1 3\n3\n2 5\n1 2\n3\n", "output": "111\n"}, {"input": "5\n1 0 1 1 1\n0 1 0 1 0\n1 0 1 1 1\n0 1 0 1 0\n1 0 1 0 0\n7\n3\n2 4\n1 3\n3\n2 5\n1 1\n3\n", "output": "000\n"}, {"input": "5\n1 0 1 0 1\n0 1 0 1 0\n1 0 1 0 1\n0 1 0 1 0\n1 0 1 0 1\n7\... | code_stdio |
[
{
"content": "A calculator scholar has discovered a strange life form called an electronic fly that lives in electronic space. While observing the behavior of the electronic flies, the electronic flies at the (x, y, z) point in this space then move to (x', y', z') indicated by the following rules. I found out.\... | [{"input": "2 5 6 7 6 13\n517 1389 746 11867 4303 3125\n0 0 0 0 0 0", "output": "12\n3426307500\n"}, {"input": "2 5 6 7 6 25\n517 1389 746 11867 4303 3125\n0 0 0 0 0 0", "output": "20\n3426307500\n"}, {"input": "2 5 3 7 6 13\n913 1354 746 12979 4303 1361\n0 0 0 0 0 0", "output": "12\n1491431760\n"}, {"input": "2 5 5 7 ... | code_stdio |
[
{
"content": "King Mercer is the king of ACM kingdom. There are one capital and some cities in his kingdom. Amazingly, there are no roads in the kingdom now. Recently, he planned to construct roads between the capital and the cities, but it turned out that the construction cost of his plan is much higher than e... | [{"input": "3 3\n1 2 1 4\n2 3 2 1\n3 1 3 2\n5 5\n1 3 2 2\n2 3 1 1\n1 4 1 1\n4 5 1 1\n5 3 2 1\n5 10\n1 2 32 10\n1 3 43 43\n1 4 12 77\n1 5 84 23\n2 3 58 42\n2 4 86 163\n2 3 57 133\n3 4 11 32\n3 5 75 41\n4 5 17 43\n5 10\n1 2 1 53\n1 5 0 65\n2 4 1 24\n1 5 1 76\n2 3 2 19\n2 4 1 46\n2 5 1 25\n3 4 1 13\n3 5 1 65\n4 5 1 34\n0 ... | code_stdio |
[
{
"content": "Consider a sequence generation that follows the following steps. We will store removed values in variable `res`. Assume `n = 25`:\n```Haskell\n-> [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] Let's remove the first number => res = [1]. We get..\n-> [2,3,4,5,6,7,8,9,10,11,12,1... | [{"input": "10000", "output": "[4721110]", "fn_name": "solve"}, {"input": "1000", "output": "[63589]", "fn_name": "solve"}, {"input": "100", "output": "[993]", "fn_name": "solve"}, {"input": "25", "output": "[107]", "fn_name": "solve"}, {"input": "50", "output": "[304]", "fn_name": "solve"}, {"input": "7", "output": "[... | code_functional |
[
{
"content": "Let's call a non-empty sequence of positive integers a_1, a_2... a_{k} coprime if the greatest common divisor of all elements of this sequence is equal to 1.\n\nGiven an array a consisting of n positive integers, find the number of its coprime subsequences. Since the answer may be very large, prin... | [{"input": "100\n881 479 355 759 257 497 690 598 275 446 439 787 257 326 584 713 322 5 253 781 434 307 164 154 241 381 38 942 680 906 240 11 431 478 628 959 346 74 493 964 455 746 950 41 585 549 892 687 264 41 487 676 63 453 861 980 477 901 80 907 285 506 619 748 773 743 56 925 651 685 845 313 419 504 770 324 2 559 405... | code_stdio |
[
{
"content": "The only difference between easy and hard versions is the number of elements in the array.\n\nYou are given an array $a$ consisting of $n$ integers. In one move you can choose any $a_i$ and divide it by $2$ rounding down (in other words, in one move you can set $a_i := \\lfloor\\frac{a_i}{2}\\rflo... | [{"input": "50 25\n199970 199997 199998 199988 199999 199981 200000 199990 199974 199985 199932 200000 199966 199999 199999 199951 199983 199975 199974 199996 199974 199992 199979 199995 199955 199989 199960 199975 199983 199990 199950 199952 199999 199999 199962 199939 199979 199977 199962 199996 199910 199997 199976 ... | code_stdio |
[
{
"content": "Squirrel Liss is interested in sequences. She also has preferences of integers. She thinks n integers a_1, a_2, ..., a_{n} are good.\n\nNow she is interested in good sequences. A sequence x_1, x_2, ..., x_{k} is called good if it satisfies the following three conditions: The sequence is strictly ... | [{"input": "49\n10 34 58 72 126 166 176 180 198 200 208 228 238 248 302 332 340 344 350 354 380 406 418 428 438 442 482 532 536 544 546 554 596 626 642 682 684 704 714 792 804 820 862 880 906 946 954 966 970\n", "output": "49\n"}, {"input": "49\n10 34 58 72 126 166 176 180 198 200 208 228 238 248 302 332 340 344 350 35... | code_stdio |
[
{
"content": "You are given an array $a_1, a_2, \\dots , a_n$, which is sorted in non-decreasing order ($a_i \\le a_{i + 1})$. \n\nFind three indices $i$, $j$, $k$ such that $1 \\le i < j < k \\le n$ and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to... | [{"input": "3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n", "output": "1 2 7\n-1\n1 2 3\n"}, {"input": "3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n", "output": "1 2 7\n-1\n1 2 3\n"}, {"input": "3\n7\n4 6 11 11 15 18 34\n4\n10 10 10 11\n3\n1 1 1000000000\n", "output": "1 2 7\n-1\n1 2 3\... | code_stdio |
[
{
"content": "This is the harder version of the problem. In this version, $1 \\le n, m \\le 2\\cdot10^5$. You can hack this problem if you locked it. But you can hack the previous problem only if you locked both problems.\n\nYou are given a sequence of integers $a=[a_1,a_2,\\dots,a_n]$ of length $n$. Its subseq... | [{"input": "5\n3 1 4 1 2\n15\n5 5\n5 4\n5 3\n5 2\n5 1\n4 4\n4 3\n4 2\n4 1\n3 3\n3 2\n3 1\n2 2\n2 1\n1 1\n", "output": "2\n1\n4\n1\n3\n2\n4\n1\n3\n2\n4\n3\n4\n3\n4\n"}, {"input": "5\n3 1 4 1 2\n15\n5 5\n5 4\n5 3\n5 2\n5 1\n4 4\n4 3\n4 2\n4 1\n3 3\n3 2\n3 1\n2 2\n2 1\n1 1\n", "output": "2\n1\n4\n1\n3\n2\n4\n1\n3\n2\n4\n3... | code_stdio |
[
{
"content": "The Bitlandians are quite weird people. They do everything differently. They have a different alphabet so they have a different definition for a string.\n\nA Bitlandish string is a string made only of characters \"0\" and \"1\".\n\nBitHaval (the mayor of Bitland) loves to play with Bitlandish stri... | [{"input": "1000000000000000000000000000000000000011111111000000000000\n0111111111100000000000111111111000000000000000111111110001\n", "output": "YES\n"}, {"input": "1000000000000000000000000000000000000011111111000000000000\n0111111111100000000000111111111000000000000000111111110001\n", "output": "YES\n"}, {"input": "... | code_stdio |
[
{
"content": "There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N.\nOn this sequence, Snuke can perform the following operation:\n - Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value amo... | [{"input": "7635 1737\n1 4336 5028 2246 3376 4632 3484 5018 6851 5712 6421 1045 4582 6443 5762 2211 5622 2385 1213 6493 6742 4499 7581 6655 2974 2212 2861 4283 5757 1316 4008 2602 5971 4098 5433 1398 4622 7224 93 4338 1998 1188 853 2588 2210 7123 3903 1360 1308 3213 3437 2333 6285 2126 3228 2323 7477 34 3187 3914 1128 ... | code_stdio |
[
{
"content": "The customer telephone support center of the computer sales company called JAG is now in- credibly confused. There are too many customers who request the support, and they call the support center all the time. So, the company wants to figure out how many operators needed to handle this situation.\... | [{"input": "3 300\n100 46 150\n100 50 150\n101 50 148\n3 300\n110 50 150\n100 50 150\n200 50 150\n9 18\n5 1 1\n3 1 1\n3 1 1\n4 100 1\n5 100 1\n5 100 1\n10 5 5\n10 5 5\n2 7 1000\n10 18\n1 2 6\n2 3 1\n3 4 5\n4 5 6\n5 6 7\n6 7 8\n7 8 9\n12 9 10\n9 10 11\n18 11 12\n0 0", "output": "2\n3\n5\n10\n"}, {"input": "3 300\n100 46... | code_stdio |
[
{
"content": "Given a sorted array of numbers, return the summary of its ranges.\n\n## Examples\n```python\nsummary_ranges([1, 2, 3, 4]) == [\"1->4\"]\nsummary_ranges([1, 1, 1, 1, 1]) == [\"1\"]\nsummary_ranges([0, 1, 2, 5, 6, 9]) == [\"0->2\", \"5->6\", \"9\"]\nsummary_ranges([0, 1, 2, 3, 3, 3, 4, 5, 6, 7]) ==... | [{"input": "[-2, 0, 1, 2, 3, 4, 5, 6, 7, 9, 10, 12]", "output": "[[\"-2\", \"0->7\", \"9->10\", \"12\"]]", "fn_name": "summary_ranges"}, {"input": "[0, 1, 2, 3, 4, 5, 6, 7, 9, 10]", "output": "[[\"0->7\", \"9->10\"]]", "fn_name": "summary_ranges"}, {"input": "[0, 1, 2, 5, 6, 9]", "output": "[[\"0->2\", \"5->6\", \"9\"]... | code_functional |
[
{
"content": "You are given two integers $n$ and $m$. You have to construct the array $a$ of length $n$ consisting of non-negative integers (i.e. integers greater than or equal to zero) such that the sum of elements of this array is exactly $m$ and the value $\\sum\\limits_{i=1}^{n-1} |a_i - a_{i+1}|$ is the ma... | [{"input": "5\n1 100\n2 -1\n5 5\n2 1000000000\n1000100000 1000000000\n", "output": "0\n-1\n10\n1000000000\n2000000000\n"}, {"input": "5\n1 100\n2 2\n5 5\n2 1000000000\n1000000000 1000000000\n", "output": "0\n2\n10\n1000000000\n2000000000\n"}, {"input": "5\n1 100\n2 0\n5 5\n2 1000000000\n1000000000 1000000000\n", "outpu... | code_stdio |
[
{
"content": "The preferred way to generate user login in Polygon is to concatenate a prefix of the user's first name and a prefix of their last name, in that order. Each prefix must be non-empty, and any of the prefixes can be the full name. Typically there are multiple possible logins for each person.\n\nYou ... | [{"input": "asdfghjkli ware\n", "output": "asdfghjkliw\n"}, {"input": "asdfghjkli ware\n", "output": "asdfghjkliw\n"}, {"input": "asdfghkkli ware\n", "output": "asdfghkkliw\n"}, {"input": "ilkkhgfdsa ware\n", "output": "ilkkhgfdsaw\n"}, {"input": "aaaaaaaaaz york\n", "output": "aaaaaaaaay\n"}, {"input": "aaaaaaaaaz yor... | code_stdio |
[
{
"content": "# Feynman's squares\nRichard Phillips Feynman was a well-known American physicist and a recipient of the Nobel Prize in Physics. He worked in theoretical physics and pioneered the field of quantum computing.\n\nRecently, an old farmer found some papers and notes that are believed to have belonged ... | [{"input": "15", "output": "[1240]", "fn_name": "count_squares"}, {"input": "8", "output": "[204]", "fn_name": "count_squares"}, {"input": "3", "output": "[14]", "fn_name": "count_squares"}, {"input": "5", "output": "[55]", "fn_name": "count_squares"}, {"input": "1", "output": "[1]", "fn_name": "count_squares"}, {"inpu... | code_functional |
[
{
"content": "There are N cells arranged in a row, numbered 1, 2, \\ldots, N from left to right.\nTak lives in these cells and is currently on Cell 1. He is trying to reach Cell N by using the procedure described below.\nYou are given an integer K that is less than or equal to 10, and K non-intersecting segment... | [{"input": "200000 10\n195313 197047\n198503 199144\n199910 200000\n193793 195312\n186922 193792\n199860 199909\n199145 199570\n197048 198502\n1 186921\n199571 199859\n", "output": "946746535\n"}, {"input": "199993 10\n23896 23905\n92651 92660\n184931 184940\n101332 101341\n126813 126822\n52635 52644\n9715 9724\n58620 ... | code_stdio |
[
{
"content": "Final kata of the series (highly recommended to compute [layers](https://www.codewars.com/kata/progressive-spiral-number-position/) and [branch](https://www.codewars.com/kata/progressive-spiral-number-branch/) first to get a good idea), this is a blatant ripoff of [the one offered on AoC](http://a... | [{"input": "306", "output": "[17]", "fn_name": "distance"}, {"input": "307", "output": "[18]", "fn_name": "distance"}, {"input": "308", "output": "[17]", "fn_name": "distance"}, {"input": "25", "output": "[4]", "fn_name": "distance"}, {"input": "30", "output": "[5]", "fn_name": "distance"}, {"input": "96", "output": "[... | code_functional |
[
{
"content": "You are given two integer sequences S and T of length N and M, respectively, both consisting of integers between 1 and 10^5 (inclusive).\nIn how many pairs of a subsequence of S and a subsequence of T do the two subsequences are the same in content?\nHere the subsequence of A is a sequence obtaine... | [{"input": "1989 1986\n84234 80908 59749 63761 63761 49034 63761 64697 84234 84234 64697 64697 49034 80908 80908 63761 66200 59749 59749 80908 84234 63761 80908 80908 66200 92283 84234 63761 80908 63761 92283 59749 49034 78052 53613 49034 92283 80908 53613 59749 49034 49034 59749 80908 66200 80908 63761 64697 92283 490... | code_stdio |
[
{
"content": "There are N+1 towns. The i-th town is being attacked by A_i monsters.\nWe have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters.\nWhat is the maximum total number of monsters the heroes can cooperate to defeat?\n\n-----Constraints... | [{"input": "1611\n999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 99... | code_stdio |
[
{
"content": "An integer N is a multiple of 9 if and only if the sum of the digits in the decimal representation of N is a multiple of 9.\nDetermine whether N is a multiple of 9.\n\n-----Constraints-----\n - 0 \\leq N < 10^{200000}\n - N is an integer.\n\n-----Input-----\nInput is given from Standard Input in t... | [{"input": "33813819154164361588118768953262516554574111032083043031384286303065210509562262038973079975476396016546146039303789823110933080134565927492314604458575884820133400398416950126075966048913496870281342656762187821939147033106717650124502612019109078419691362651717290499399798948652832533487239630898917216407... | code_stdio |
[
{
"content": "There are N non-negative integers written on a blackboard. The i-th integer is A_i.\nTakahashi can perform the following two kinds of operations any number of times in any order:\n - Select one integer written on the board (let this integer be X). Write 2X on the board, without erasing the selecte... | [{"input": "6 111011100000010010101101010101101010001000000101011101000101001110110110011101000000000000011110011100110111011101100111111011000100110111111010000100100110110100110000001000011110010001001110011100001101101010010000010111001001111111101000101111011111011111011101001001011000101011110101010111101101010100... | code_stdio |
[
{
"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 c_{i}. 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... | [{"input": "50\n22 19 14 22 20 11 16 28 23 15 3 23 6 16 30 15 15 10 24 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 23 15 3 23 6 16 30 15 15 10 24 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": "The spring is coming and it means that a lot of fruits appear on the counters. One sunny day little boy Valera decided to go shopping. He made a list of m fruits he wanted to buy. If Valera want to buy more than one fruit of some kind, he includes it into the list several times. \n\nWhen he came t... | [{"input": "24 24\n25 69 103 18 40 8 78 14 14 10 27 61 75 140 10 69 80 71 102 8 91 14 15 10\nswtcofrcpeys{ydwkrg\nszyd\ndyzsyep\nrcpeyszydwkrgfj\nfgrkwdyzsyfp\ndwyz\nsmzginydyrtua\nj\nk\ntzwsw\ngfj\nmsplnqossy\ninydyrtuatzw\ninxdy\nlpsmzginydyrtuatzwswtcofrcpeyszy\nyssoqnlpsm\npeyszyd\nysosqnlpsm\ninydy\ndyztyep\ninywy... | code_stdio |
[
{
"content": "Think of New York as a rectangular grid consisting of N vertical avenues numerated from 1 to N and M horizontal streets numerated 1 to M. C friends are staying at C hotels located at some street-avenue crossings. They are going to celebrate birthday of one of them in the one of H restaurants also ... | [{"input": "100 100\n10\n53 20\n97 6\n12 74\n48 92\n97 13\n47 96\n123 32\n69 21\n95 75\n1 54\n10\n36 97\n41 1\n1 87\n39 23\n27 44\n73 97\n1 1\n6 26\n48 3\n5 69\n", "output": "108\n4\n"}, {"input": "100 100\n10\n53 20\n97 6\n12 74\n48 92\n97 13\n47 96\n123 32\n69 21\n95 75\n1 54\n10\n36 97\n18 1\n1 87\n39 23\n27 44\n73 ... | code_stdio |
[
{
"content": "In this Kata, you will be given a number and your task will be to return the nearest prime number. \n\n```Haskell\nsolve(4) = 3. The nearest primes are 3 and 5. If difference is equal, pick the lower one. \nsolve(125) = 127\n```\n\nWe'll be testing for numbers up to `1E10`. `500` tests.\n\nMore ex... | [{"input": "10000000000", "output": "[10000000019]", "fn_name": "solve"}, {"input": "3500000", "output": "[3499999]", "fn_name": "solve"}, {"input": "350000", "output": "[350003]", "fn_name": "solve"}, {"input": "35000", "output": "[34981]", "fn_name": "solve"}, {"input": "1110", "output": "[1109]", "fn_name": "solve"}... | code_functional |
[
{
"content": "On some square in the lowest row of a chessboard a stands a pawn. It has only two variants of moving: upwards and leftwards or upwards and rightwards. The pawn can choose from which square of the lowest row it can start its journey. On each square lay from 0 to 9 peas. The pawn wants to reach the ... | [{"input": "100 3 4\n644\n861\n478\n250\n560\n998\n141\n162\n386\n778\n123\n811\n602\n533\n391\n515\n898\n215\n965\n556\n446\n883\n256\n195\n573\n889\n515\n240\n179\n339\n258\n593\n930\n730\n735\n949\n522\n067\n549\n366\n452\n405\n473\n188\n488\n994\n000\n046\n930\n217\n897\n580\n509\n032\n343\n722\n176\n925\n728\n717\... | code_stdio |
[
{
"content": "There are N rabbits, numbered 1 through N.\n\nThe i-th (1≤i≤N) rabbit likes rabbit a_i. Note that no rabbit can like itself, that is, a_i≠i.\n\nFor a pair of rabbits i and j (i<j), we call the pair (i,j) a friendly pair if the following condition is met.\n\n* Rabbit i likes rabbit j and rabbit j l... | [{"input": "5\n5 5 5 -1 2", "output": "1\n"}, {"input": "5\n5 5 5 -2 2", "output": "1\n"}, {"input": "5\n3 5 5 -1 1", "output": "0\n"}, {"input": "5\n5 5 5 -1 1", "output": "1\n"}, {"input": "5\n3 3 5 -1 1", "output": "0\n"}, {"input": "5\n0 5 1 -1 2", "output": "1\n"}, {"input": "5\n5 3 5 -1 0", "output": "0\n"}, {"in... | code_stdio |
[
{
"content": "A sequence of non-negative integers a1, a2, ..., an of length n is called a wool sequence if and only if there exists two integers l and r (1 ≤ l ≤ r ≤ n) such that <image>. In other words each wool sequence contains a subsequence of consecutive elements with xor equal to 0.\n\nThe expression <ima... | [{"input": "100000 100000\n", "output": "738698541\n"}, {"input": "50000 100000\n", "output": "821709120\n"}, {"input": "21857 94145\n", "output": "689996210\n"}, {"input": "50664 46559\n", "output": "425318276\n"}, {"input": "25063 54317\n", "output": "735545216\n"}, {"input": "62600 39199\n", "output": "366778414\n"}... | code_stdio |
[
{
"content": "Vova's family is building the Great Vova Wall (named by Vova himself). Vova's parents, grandparents, grand-grandparents contributed to it. Now it's totally up to Vova to put the finishing touches.\n\nThe current state of the wall can be respresented by a sequence $a$ of $n$ integers, with $a_i$ be... | [{"input": "20\n10 5 2 3 5 7 7 9 4 9 9 4 9 7 7 5 3 2 5 10\n", "output": "NO\n"}, {"input": "20\n10 5 2 3 5 7 7 9 4 9 9 4 9 7 7 5 3 2 5 10\n", "output": "NO\n"}, {"input": "20\n10 1 2 3 5 7 7 9 4 9 9 4 9 7 7 5 3 2 5 10\n", "output": "NO\n"}, {"input": "20\n16 1 2 3 5 7 7 9 4 9 9 4 9 7 7 5 3 2 5 10\n", "output": "NO\n"},... | code_stdio |
[
{
"content": "There are $n$ programmers that you want to split into several non-empty teams. The skill of the $i$-th programmer is $a_i$. You want to assemble the maximum number of teams from them. There is a restriction for each team: the number of programmers in the team multiplied by the minimum skill among ... | [{"input": "3\n5 10\n13 11 2 14 1\n4 8\n2 4 2 1\n4 8\n1 3 3 7\n", "output": "3\n0\n1\n"}, {"input": "3\n5 10\n14 11 4 5 1\n4 11\n2 7 2 1\n4 8\n1 4 3 2\n", "output": "2\n0\n0\n"}, {"input": "3\n5 17\n7 11 2 9 5\n4 8\n2 1 2 3\n4 11\n1 3 3 11\n", "output": "1\n0\n1\n"}, {"input": "3\n5 10\n11 11 4 9 2\n4 15\n2 4 2 1\n4 9\... | code_stdio |
[
{
"content": "There are n railway stations in Berland. They are connected to each other by n-1 railway sections. The railway network is connected, i.e. can be represented as an undirected tree.\n\nYou have a map of that network, so for each railway section you know which stations it connects.\n\nEach of the n-1... | [{"input": "10\n9 4\n5 7\n2 1\n3 4\n2 10\n6 3\n2 5\n1 3\n4 8\n8\n6 8 3\n10 5 3\n2 10 3\n3 5 2\n8 4 3\n1 9 3\n9 5 2\n3 10 2\n", "output": "3 1 2 3 3 3 3 3 3 \n"}, {"input": "10\n3 6\n3 2\n4 1\n1 10\n3 8\n5 2\n6 7\n2 1\n6 9\n7\n9 10 3\n5 7 1\n9 10 3\n7 4 1\n3 10 4\n3 6 4\n5 1 4\n", "output": "4 4 1 4 1 4 1 4 3 \n"}, {"in... | code_stdio |
[
{
"content": "Find the edit distance between given two words s1 and s2.\n\nThe disntace is the minimum number of single-character edits required to change one word into the other. The edits including the following operations:\n\n* insertion: Insert a character at a particular position.\n* deletion: Delete a cha... | [{"input": "icpc\nipcc", "output": "2\n"}, {"input": "icpb\ncbio", "output": "4\n"}, {"input": "cpci\nipcc", "output": "2\n"}, {"input": "cpci\nccpi", "output": "2\n"}, {"input": "icpc\nccpi", "output": "2\n"}, {"input": "ibpc\nccpi", "output": "3\n"}, {"input": "icpb\nccpi", "output": "2\n"}, {"input": "icpb\nccip", "... | code_stdio |
[
{
"content": "Problem\n\nThere are $ 2 $ teams, Team UKU and Team Ushi. Initially, Team UKU has $ N $ people and Team Uku has $ M $ people. Team UKU and Team Ushi decided to play a game called \"U & U\". \"U & U\" has a common score for $ 2 $ teams, and the goal is to work together to minimize the common score.... | [{"input": "1000000000000000000 1000000000010000000", "output": "4\n"}, {"input": "1000000001000000000 1000000000010000000", "output": "2\n"}, {"input": "1000001001000000000 1000000000010000000", "output": "2\n"}, {"input": "1000001001001000000 1000000000010000000", "output": "2\n"}, {"input": "1000001001001000010 1000... | code_stdio |
[
{
"content": "AtCoDeer the deer has N cards with positive integers written on them. The number on the i-th card (1≤i≤N) is a_i.\nBecause he loves big numbers, he calls a subset of the cards good when the sum of the numbers written on the cards in the subset, is K or greater.\nThen, for each card i, he judges wh... | [{"input": "6 20\n10 4 3 10 25 2\n", "output": "3\n"}, {"input": "6 20\n10 4 5 10 25 2", "output": "0\n"}, {"input": "6 20\n10 4 5 10 25 3", "output": "0\n"}, {"input": "6 20\n10 4 3 10 25 2", "output": "3"}, {"input": "1 586\n-1 2 1 -2 5", "output": "1\n"}, {"input": "1 988\n-1 2 1 -2 5", "output": "1\n"}, {"input": "... | code_stdio |
[
{
"content": "You have two strings A = A_1 A_2 ... A_n and B = B_1 B_2 ... B_n of the same length consisting of 0 and 1.\n\nYou can transform A using the following operations in any order and as many times as you want:\n\n* Shift A by one character to the left (i.e., if A = A_1 A_2 ... A_n, replace A with A_2 A... | [{"input": "0100100\n1111101", "output": "4\n"}, {"input": "0100100\n1100000", "output": "5\n"}, {"input": "0100100\n0000001", "output": "6\n"}, {"input": "0100100\n0111111", "output": "4\n"}, {"input": "0100100\n0101111", "output": "3\n"}, {"input": "0100100\n0101110", "output": "2\n"}, {"input": "0100100\n0101100", "... | code_stdio |
[
{
"content": "Simply find the closest value to zero from the list. Notice that there are negatives in the list.\n\nList is always not empty and contains only integers. Return ```None``` if it is not possible to define only one of such values. And of course, we are expecting 0 as closest value to zero.\n\nExampl... | [{"input": "[28, -36, 49, 39, -33, 22, -5, 23, -24, 47, -47, -30, -20, -18, 40, -21, -45, 10, -48, -26, -12, -21, 48, 16, 26, 21, -9, 33, 8, -49]", "output": "[-5]", "fn_name": "closest"}, {"input": "[20, 26, 13, -47, -35, 39, 24, 46, -16, 5, 46, -30, -33, -38, -47, 23, 10, -39, -36, 41, 5, -24, 28, -30, 40, -24, -28, ... | code_functional |
[
{
"content": "Problem\n\nIn 1333, the greatest scientist in human history, Dr. Ushishi, developed an artificial intelligence with an ID of ai1333 in order to pass on his wisdom to posterity. For the next 100 years, ai1333 brought great benefits to humankind, but on the 100th anniversary of its birth, it created... | [{"input": "200", "output": "ai133333\n"}, {"input": "300", "output": "ai1333333"}, {"input": "100", "output": "ai13333\n"}, {"input": "-12", "output": "ai1333\n"}, {"input": "-22", "output": "ai1333\n"}, {"input": "-21", "output": "ai1333\n"}, {"input": "-32", "output": "ai1333\n"}, {"input": "-10", "output": "ai1333\... | code_stdio |
[
{
"content": "You are given two integer sequences of length N: a_1,a_2,..,a_N and b_1,b_2,..,b_N. Determine if we can repeat the following operation zero or more times so that the sequences a and b become equal.\n\nOperation: Choose two integers i and j (possibly the same) between 1 and N (inclusive), then perf... | [{"input": "5\n-1 -1 -1 18 1\n1 1 1 0 0", "output": "No\n"}, {"input": "5\n-1 -1 -1 18 1\n1 2 1 0 0", "output": "No\n"}, {"input": "5\n-1 -1 -1 12 1\n1 2 1 0 0", "output": "No\n"}, {"input": "5\n7 2 8 2 14\n1 7 2 -1 10", "output": "No\n"}, {"input": "5\n7 2 8 2 11\n1 7 2 -1 10", "output": "No\n"}, {"input": "5\n7 2 8 2... | code_stdio |
[
{
"content": "It is the hard version of the problem. The only difference is that in this version $1 \\le n \\le 300$.\n\nIn the cinema seats can be represented as the table with $n$ rows and $m$ columns. The rows are numbered with integers from $1$ to $n$. The seats in each row are numbered with consecutive int... | [{"input": "7\n1 2\n1 1\n3 2\n1 1 2 2 4 6\n3 3\n3 4 4 1 1 1 1 1 5\n2 2\n2 1 2 1\n4 2\n50 50 50 50 3 50 56 50\n4 2\n6 6 6 10 2 2 9 6\n2 9\n1 3 2 3 3 6 1 1 3 2 3 1 1 6 3 1 1 3\n", "output": "0\n1\n2\n0\n0\n0\n12\n"}, {"input": "7\n1 2\n1 1\n3 2\n1 1 2 4 4 6\n3 3\n3 4 4 1 1 1 1 1 5\n2 2\n2 1 2 1\n4 2\n50 50 50 50 3 50 56 ... | code_stdio |
[
{
"content": "Your task is to define a function that understands basic mathematical expressions and solves them.\nFor example:\n\n```python\ncalculate(\"1 + 1\") # => 2\ncalculate(\"18 + 4*6\") # => 42\ncalculate(\"245 - 826\") # => -581\ncalculate(\"09 + 000482\") # => 491\ncalculate(\"8 / 4 + 6... | [{"input": "\"123 * 987 * 135 * 246\"", "output": "[4031727210]", "fn_name": "calculate"}, {"input": "\"1*2*3/1/2/3+1+2+3-1-2-3\"", "output": "[1]", "fn_name": "calculate"}, {"input": "\"1 + 2 + 3 + 4 + 5 + 6\"", "output": "[21]", "fn_name": "calculate"}, {"input": "\"5*2/3*9/10*123/8\"", "output": "[46.125]", "fn_name... | code_functional |
[
{
"content": "On a planet far, far away, M languages are spoken. They are conveniently numbered 1 through M.\n\nFor CODE FESTIVAL 20XX held on this planet, N participants gathered from all over the planet.\n\nThe i-th (1≦i≦N) participant can speak K_i languages numbered L_{i,1}, L_{i,2}, ..., L_{i,{}K_i}.\n\nTw... | [{"input": "4 6\n3 2 3 3\n2 4 2\n2 4 6\n1 6", "output": "YES\n"}, {"input": "4 6\n3 2 3 4\n2 4 2\n2 4 6\n1 6", "output": "YES\n"}, {"input": "4 6\n3 2 3 4\n2 4 4\n2 4 6\n1 6", "output": "YES\n"}, {"input": "4 6\n3 0 3 4\n2 4 4\n2 4 6\n1 6", "output": "YES\n"}, {"input": "4 6\n3 0 2 3\n2 4 2\n2 4 6\n1 6", "output": "YES... | code_stdio |
[
{
"content": "In programming languages like C/C++, a goto statement provides an unconditional jump from the \"goto\" to a labeled statement. For example, a statement \"goto CHECK_NUM;\" is executed, control of the program jumps to CHECK_NUM. Using these constructs, you can implement, for example, loops.\n\nNote... | [{"input": "430", "output": " 3 6 9 12 13 15 18 21 23 24 27 30 31 32 33 34 35 36 37 38 39 42 43 45 48 51 53 54 57 60 63 66 69 72 73 75 78 81 83 84 87 90 93 96 99 102 103 105 108 111 113 114 117 120 123 126 129 130 131 132 133 134 135 136 137 138 139 141 143 144 147 150 153 156 159 162 163 165 168 171 173 174 177 180 18... | code_stdio |
[
{
"content": "We need a function ```prime_bef_aft()``` that gives the largest prime below a certain given value ```n```, \n\n```befPrime or bef_prime``` (depending on the language), \n\nand the smallest prime larger than this value, \n\n```aftPrime/aft_prime``` (depending on the language).\n\nThe result should ... | [{"input": "120", "output": "[[113, 127]]", "fn_name": "prime_bef_aft"}, {"input": "130", "output": "[[127, 131]]", "fn_name": "prime_bef_aft"}, {"input": "100", "output": "[[97, 101]]", "fn_name": "prime_bef_aft"}, {"input": "101", "output": "[[97, 103]]", "fn_name": "prime_bef_aft"}, {"input": "97", "output": "[[89, ... | code_functional |
[
{
"content": "A little boy Gerald entered a clothes shop and found out something very unpleasant: not all clothes turns out to match. For example, Gerald noticed that he looks rather ridiculous in a smoking suit and a baseball cap.\n\nOverall the shop sells n clothing items, and exactly m pairs of clothing item... | [{"input": "6 11\n95 81 74 94 60 69\n3 2\n1 4\n4 2\n3 4\n1 5\n5 2\n5 3\n1 6\n2 6\n3 6\n4 6\n", "output": "215"}, {"input": "6 10\n29 5 55 24 55 74\n1 4\n2 3\n3 4\n5 1\n5 2\n5 3\n4 5\n6 2\n6 3\n6 5\n", "output": "108\n"}, {"input": "6 10\n17 5 55 24 55 74\n1 3\n2 3\n3 4\n5 1\n5 2\n5 3\n4 5\n6 2\n6 3\n6 5\n", "output": "... | code_stdio |
[
{
"content": "Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options:\n\n on this day ... | [{"input": "100\n0 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 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n", "output": "100\n"}, {"input": "100\n0 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... | code_stdio |
[
{
"content": "The reciprocal of all non-zero real numbers is real, but the reciprocal of an integer is not necessarily an integer. This is the reason why 3/2 * 2 = 2 even though 3.0 / 2.0 * 2.0 = 3.0 in C language. However, if you consider integers with the same remainder after dividing by a prime number as the... | [{"input": "5: 2 - 3\n17: 1 + 3 * (2 + 3 / 5 * 2) + 7\n11: 1 / 8 - 5 - 8 * 2\n19: 8 / (2 - 1 * 7)\n1153: 10 * 3 / 7 + ( 50 + 151 / 22 ) + 11\n0:", "output": "2-3 = 4 (mod 5)\n1+3*(2+3/5*2)+7 = 4 (mod 17)\n1/8-5-8*2 = 8 (mod 11)\n8/(2-1*7) = 6 (mod 19)\n10*3/7+(50+151/22)+11 = 1023 (mod 1153)\n"}, {"input": "5: 3 - 3\n1... | code_stdio |
[
{
"content": "There are N turkeys. We number them from 1 through N.\n\nM men will visit here one by one. The i-th man to visit will take the following action:\n\n* If both turkeys x_i and y_i are alive: selects one of them with equal probability, then eats it.\n* If either turkey x_i or y_i is alive (but not bo... | [{"input": "14 1\n5 9\n2 13\n7 6\n4 9\n4 8\n2 13\n0 12\n3 3\n3 1\n3 10", "output": "90\n"}, {"input": "16 1\n8 9\n2 8\n4 6\n4 9\n7 8\n2 11\n1 8\n3 4\n6 4\n3 7", "output": "119\n"}, {"input": "24 1\n8 9\n2 8\n5 6\n4 9\n7 3\n2 11\n1 8\n3 4\n1 4\n3 7", "output": "275\n"}, {"input": "24 2\n8 9\n2 8\n5 5\n4 9\n7 3\n2 11\n1 ... | code_stdio |
[
{
"content": "An IPv6-address is a 128-bit number. For convenience, this number is recorded in blocks of 16 bits in hexadecimal record, the blocks are separated by colons — 8 blocks in total, each block has four hexadecimal digits. Here is an example of the correct record of a IPv6 address: \"0124:5678:90ab:cde... | [{"input": "20\n0:0:9e39:9:b21:c9b:c:0\n0:0:0:0:0:a27:6b:cb0a\n2:7:4d:b:0:3:2:f401\n17:2dc6::0:89e3:0:dc:0\nca:4:0:0:d6:b999:e:0\n4af:553:b29:dd7:2:5b:0:7\n0:c981:8f:a4d:0:d4:0:f61\n0:0:1:0:dc33:0:1964:0\n84:da:0:6d6:0ecc:1:f:0\n4:fb:4d37:0:8c:4:4a52:24\nc:e:a:0:0:0:e:0\n0:3761:72ed:b7:3b0:ff7:fc:102\n5ae:8ca7:10::0:9b... | code_stdio |
[
{
"content": "Vasya often uses public transport. The transport in the city is of two types: trolleys and buses. The city has n buses and m trolleys, the buses are numbered by integers from 1 to n, the trolleys are numbered by integers from 1 to m.\n\nPublic transport is not free. There are 4 types of tickets: ... | [{"input": "680 871 347 800\n10 100\n872 156 571 136 703 201 832 213 15 333\n465 435 870 173 660 237 694 594 423 405 27 866 325 490 255 989 128 345 278 125 708 210 771 848 961 448 871 190 745 343 532 174 103 999 874 221 252 500 886 129 185 208 137 425 758 34 696 15 198 981 91 50 545 885 194 583 475 415 162 712 116 911 ... | code_stdio |
[
{
"content": "Write a function that takes a number or a string and gives back the number of **permutations without repetitions** that can generated using all of its element.; more on permutations [here](https://en.wikipedia.org/wiki/Permutation).\n\nFor example, starting with:\n```\n1\n45\n115\n\"abc\"\n```\n\n... | [{"input": "76853", "output": "[120]", "fn_name": "perms"}, {"input": "1397", "output": "[24]", "fn_name": "perms"}, {"input": "\"abc\"", "output": "[6]", "fn_name": "perms"}, {"input": "66666", "output": "[1]", "fn_name": "perms"}, {"input": "\"ab\"", "output": "[2]", "fn_name": "perms"}, {"input": "342", "output": "[... | code_functional |
[
{
"content": "You have got a shelf and want to put some books on it.\n\nYou are given $q$ queries of three types: L $id$ — put a book having index $id$ on the shelf to the left from the leftmost existing book; R $id$ — put a book having index $id$ on the shelf to the right from the rightmost existing book; ?... | [{"input": "10\nL 100\nR 100000\nR 123\nL 101\n? 123\nL 10\nR 115\n? 100\nR 110\n? 115\n", "output": "0\n2\n1\n"}, {"input": "10\nL 100\nR 101000\nR 123\nL 101\n? 123\nL 10\nR 115\n? 100\nR 110\n? 115\n", "output": "0\n2\n1\n"}, {"input": "10\nL 100\nR 100000\nR 123\nL 101\n? 123\nL 17\nR 115\n? 100\nR 110\n? 115\n", "... | code_stdio |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.