messages listlengths 1 1 | ground_truth stringlengths 88 726k | dataset stringclasses 2
values |
|---|---|---|
[
{
"content": "Solve the following coding problem using the programming language python:\n\nLinear Kingdom has exactly one tram line. It has `n` stops, numbered from 1 to n in the order of tram's movement. At the i-th stop ai passengers exit the tram, while bi passengers enter it. The tram is empty before it arr... | [{"input": "10\n[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n[9, 8, 7, 6, 5, 4, 3, 2, 1, 0]", "output": "[25]", "fn_name": "tram"}, {"input": "5\n[0, 2, 4, 14, 2]\n[3, 5, 14, 0, 0]", "output": "[16]", "fn_name": "tram"}, {"input": "4\n[0, 2, 4, 4]\n[3, 5, 2, 0]", "output": "[6]", "fn_name": "tram"}, {"input": "2\n[0, 2, 4, 4]\n[3, ... | code_functional |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nGiven simple (without self-intersections) n-gon. It is not necessary convex. Also you are given m lines. For each line find the length of common part of the line and the n-gon.\n\nThe boundary of n-gon belongs to polygon.... | [{"type": "stdin_stdout", "input": "3 8\n-100000 -100000\n100000 100000\n1 0\n-100000 -100000 100000 -80000\n-100000 -100000 100000 -99000\n-100000 -100000 100000 -99990\n-100000 -100000 100000 -99999\n-100000 -100000 100000 -99999.99\n-100000 -100000 100000 100000\n-100000 -100000 100000 99999.99\n-100000 100000 10000... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAfter lessons Nastya decided to read a book. The book contains $n$ chapters, going one after another, so that one page of the book belongs to exactly one chapter and each chapter contains at least one page.\n\nYesterday e... | [{"type": "stdin_stdout", "input": "49\n1 17\n18 115\n116 211\n212 269\n270 345\n346 404\n405 441\n442 467\n468 526\n527 583\n584 664\n665 757\n758 794\n795 802\n803 882\n883 920\n921 960\n961 962\n963 1006\n1007 1081\n1082 1112\n1113 1149\n1150 1217\n1218 1282\n1283 1287\n1288 1365\n1366 1374\n1375 1379\n1380 1478\n14... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAs you have noticed, there are lovely girls in Arpa’s land.\n\nPeople in Arpa's land are numbered from 1 to n. Everyone has exactly one crush, i-th person's crush is person with the number crushi.\n\n<image>\n\nSomeday Ar... | [{"type": "stdin_stdout", "input": "100\n84 94 72 32 61 90 61 2 76 42 35 82 90 29 51 27 65 99 38 41 44 73 100 58 56 64 54 31 14 58 57 64 90 49 73 80 74 19 31 86 73 44 39 43 28 95 23 5 85 5 74 81 34 44 86 30 50 57 94 56 53 42 53 87 92 78 53 49 78 60 37 63 41 19 15 68 25 77 87 48 23 100 54 27 68 84 43 92 76 55 2 94 100 2... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nConvexity of a set of points on the plane is the size of the largest subset of points that form a convex polygon. Your task is to build a set of n points with the convexity of exactly m. Your set of points should not cont... | [{"type": "stdin_stdout", "input": "278 100\n", "output": "0 100000\n1 100001\n2 100004\n3 100009\n4 100016\n5 100025\n6 100036\n7 100049\n8 100064\n9 100081\n10 100100\n11 100121\n12 100144\n13 100169\n14 100196\n15 100225\n16 100256\n17 100289\n18 100324\n19 100361\n20 100400\n21 100441\n22 100484\n23 100529\n24 1005... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAt the school where the twins Ami and Mami attend, the summer vacation has already begun, and a huge amount of homework has been given this year as well. However, the two of them were still trying to go out without doing ... | [{"type": "stdin_stdout", "input": "4\n1 2\n3 1\n4 1\n2 1\n3\n10 4\n1 2\n1 2\n1\n1000 1000\n10\n5 62\n10 68\n15 132\n20 73\n25 75\n30 77\n35 79\n40 82\n45 100\n815 283\n6\n106 21\n53 55\n118 77\n19 13\n83 42\n2 1\n0", "output": "15\n24\n3000\n2072\n590\n"}, {"type": "stdin_stdout", "input": "4\n1 2\n3 1\n4 1\n2 2\n3\n1... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nSasha and Dima want to buy two $n$-tier cakes. Each cake should consist of $n$ different tiers: from the size of $1$ to the size of $n$. Tiers should go in order from the smallest to the biggest (from top to bottom).\n\nT... | [{"type": "stdin_stdout", "input": "10\n8 8 3 9 7 1 9 6 10 6 4 2 7 3 4 10 5 5 1 2\n", "output": "123\n"}, {"type": "stdin_stdout", "input": "10\n8 8 3 9 7 1 9 6 10 6 4 2 7 3 4 10 5 5 1 2\n", "output": "123\n"}, {"type": "stdin_stdout", "input": "9\n1 3 6 1 4 9 2 8 3 4 8 7 5 7 2 5 9 6\n", "output": "89\n"}, {"type": "st... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nExample\n\nInput\n\n2 2 2 0 0 0 5\n\n\nOutput\n\n1 3 3 1 0\n\nThe input will be stdin and you should print your solution to stdout\n\n\nNow solve the problem and return the code.\n\nWrite Python code to solve this problem... | [{"type": "stdin_stdout", "input": "2 2 4 1 0 1 35", "output": "1 4 6 4 1 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"}, {"type": "stdin_stdout", "input": "1 1 4 0 0 0 24", "output": "1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n"}, {"type": "stdin_stdout", "input": "1 1 4 0 0 1 24", "output": "1 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nFafa owns a company that works on huge projects. There are n employees in Fafa's company. Whenever the company has a new project to start working on, Fafa has to divide the tasks of this project among all the employees.\n... | [{"type": "stdin_stdout", "input": "100000\n", "output": "35\n"}, {"type": "stdin_stdout", "input": "83160\n", "output": "127\n"}, {"type": "stdin_stdout", "input": "127925\n", "output": "23\n"}, {"type": "stdin_stdout", "input": "99999\n", "output": "11\n"}, {"type": "stdin_stdout", "input": "65536\n", "output": "16\n... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nCreate a function that accepts dimensions, of Rows x Columns, as parameters in order to create a multiplication table sized according to the given dimensions. **The return value of the function must be an array, and the ... | [{"input": "4\n4", "output": "[[[1, 2, 3, 4], [2, 4, 6, 8], [3, 6, 9, 12], [4, 8, 12, 16]]]", "fn_name": "multiplication_table"}, {"input": "3\n4", "output": "[[[1, 2, 3, 4], [2, 4, 6, 8], [3, 6, 9, 12]]]", "fn_name": "multiplication_table"}, {"input": "2\n5", "output": "[[[1, 2, 3, 4, 5], [2, 4, 6, 8, 10]]]", "fn_name... | code_functional |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nA Madhav array has the following property:\n\n```a[0] = a[1] + a[2] = a[3] + a[4] + a[5] = a[6] + a[7] + a[8] + a[9] = ...```\n\nComplete the function/method that returns `true` if the given array is a Madhav array, other... | [{"input": "[6, 2, 4, 2, 2, 2, 1, 5, 0, 0, -12, 13, -5, 4, 1]", "output": "[false]", "fn_name": "is_madhav_array"}, {"input": "[6, 2, 4, 2, 2, 2, 1, 5, 0, 0, -12, 13, -5, 4, 6]", "output": "[true]", "fn_name": "is_madhav_array"}, {"input": "[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, -2, -1]", "output": "[true]", "fn_name"... | code_functional |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nRead problems statements in Mandarin Chinese and Russian. \n\nAditi recently discovered a new magic trick. First, she gives you an integer N and asks you to think an integer between 1 and N. Then she gives you a bundle o... | [{"type": "stdin_stdout", "input": "2\n12\n191", "output": "5\n11\n"}, {"type": "stdin_stdout", "input": "2\n14\n108", "output": "6\n10\n"}, {"type": "stdin_stdout", "input": "2\n21\n114", "output": "7\n10\n"}, {"type": "stdin_stdout", "input": "2\n25\n193", "output": "7\n11\n"}, {"type": "stdin_stdout", "input": "2\n3... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given an undirected connected weighted graph consisting of $n$ vertices and $m$ edges. Let's denote the length of the shortest path from vertex $1$ to vertex $i$ as $d_i$. \n\nYou have to erase some edges of the g... | [{"type": "stdin_stdout", "input": "9 9 7\n1 2 1000000000\n7 9 1000000000\n9 4 1000000000\n2 6 1000000000\n2 3 1000000000\n3 7 1000000000\n6 8 1000000000\n8 4 1000000000\n4 5 1000000000\n", "output": "7\n1 5 4 6 7 8 2 \n"}, {"type": "stdin_stdout", "input": "9 9 7\n1 2 1000000000\n7 9 1000000000\n9 4 1000000000\n2 6 10... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThe sales department of Japanese Ancient Giant Corp. is visiting a hot spring resort for their recreational trip. For deepening their friendships, they are staying in one large room of a Japanese-style hotel called a ryok... | [{"type": "stdin_stdout", "input": "4\n0 0 x\n2 0 x\n0 1 x\n2 1 x\n4\n1 0 x\n0 1 x\n3 1 x\n1 2 x\n4\n0 0 x\n2 0 y\n0 1 y\n1 2 x\n0", "output": "Yes\nYes\nYes\n"}, {"type": "stdin_stdout", "input": "4\n0 0 x\n2 0 x\n0 1 x\n2 1 x\n4\n1 0 x\n0 1 x\n3 1 x\n1 2 x\n4\n0 0 x\n2 0 y\n0 1 y\n2 2 x\n0", "output": "Yes\nYes\nYes\... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nPeter likes to travel by train. He likes it so much that on the train he falls asleep. \n\nOnce in summer Peter was going by train from city A to city B, and as usual, was sleeping. Then he woke up, started to look throug... | [{"type": "stdin_stdout", "input": "aababaaababaabbaabababaaababaabababbaabbabaabababaabbabbbababbababababababaabababaababaaaabababaabab\nabaabababaa\nabaabbaa\n", "output": "backward\n"}, {"type": "stdin_stdout", "input": "aababaaababaabbaabababaaababaabababbaabbabaabababaabbabbbababbababababababaabababaababaaaabababa... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nA permutation of size n is an array of size n such that each integer from 1 to n occurs exactly once in this array. An inversion in a permutation p is a pair of indices (i, j) such that i > j and a_{i} < a_{j}. For exampl... | [{"type": "stdin_stdout", "input": "1\n1\n10\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n", "output": "even\neven\neven\neven\neven\neven\neven\neven\neven\neven\n"}, {"type": "stdin_stdout", "input": "1\n1\n10\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n", "output": "even\neven\neven\neven\neven\neven\ne... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nDima is a beginner programmer. During his working process, he regularly has to repeat the following operation again and again: to remove every second element from the array. One day he has been bored with easy solutions o... | [{"type": "stdin_stdout", "input": "12 12\n10\n11\n5\n3\n11\n2\n8\n6\n4\n4\n12\n1\n", "output": "9\n6\n3\n2\n6\n7\n12\n8\n10\n10\n11\n1\n"}, {"type": "stdin_stdout", "input": "12 12\n9\n11\n5\n3\n11\n2\n8\n4\n4\n4\n12\n1\n", "output": "5\n6\n3\n2\n6\n7\n12\n10\n10\n10\n11\n1\n"}, {"type": "stdin_stdout", "input": "12 1... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\n# How much is the fish! (- Scooter )\nThe ocean is full of colorful fishes. We as programmers want to know the hexadecimal value of these fishes.\n\n## Task\nTake all hexadecimal valid characters (a,b,c,d,e,f) of the give... | [{"input": "\"African glass catfish\"", "output": "[0]", "fn_name": "fisHex"}, {"input": "\"Airbreathing catfish\"", "output": "[12]", "fn_name": "fisHex"}, {"input": "\"Australasian salmon\"", "output": "[10]", "fn_name": "fisHex"}, {"input": "\"Atlantic silverside\"", "output": "[1]", "fn_name": "fisHex"}, {"input": ... | code_functional |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nLimak is a little polar bear. He loves connecting with other bears via social networks. He has n friends and his relation with the i-th of them is described by a unique integer t_{i}. The bigger this value is, the better ... | [{"type": "stdin_stdout", "input": "20 2 15\n1744261 55128070 116962690 156763505 188535242 194018601 134662359 428710623 442819431 483000923 516768937 552903993 633087286 373594646 415184994 714291344 717660646 846508634 879748146 937368929\n2 20\n1 2\n2 2\n1 19\n1 12\n2 2\n2 18\n2 11\n1 16\n2 1\n2 3\n2 19\n1 17\n2 9\... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nFor a given sequence $A = \\\\{a_0, a_1, ... a_{n-1}\\\\}$, the number of pairs $(i, j)$ where $a_i > a_j$ and $i < j$, is called the number of inversions. The number of inversions is equal to the number of swaps of Bubbl... | [{"type": "stdin_stdout", "input": "5\n3 -13 7 -1 -4", "output": "6\n"}, {"type": "stdin_stdout", "input": "5\n3 -13 10 0 -4", "output": "6\n"}, {"type": "stdin_stdout", "input": "5\n3 -13 10 0 -5", "output": "6\n"}, {"type": "stdin_stdout", "input": "5\n2 -13 10 0 -5", "output": "6\n"}, {"type": "stdin_stdout", "input... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere are $n$ detachments on the surface, numbered from $1$ to $n$, the $i$-th detachment is placed in a point with coordinates $(x_i, y_i)$. All detachments are placed in different points.\n\nBrimstone should visit each ... | [{"type": "stdin_stdout", "input": "23\n-1000000000 -964752353\n-967012509 -1000000000\n34021744 1000000000\n-931956512 -34021744\n-1034253 967204159\n-1034253 -34021744\n-1034253 -1000000000\n-931956512 -1000000000\n-967012509 1000000000\n964944003 1225903\n1000000000 1225903\n-967012509 1225903\n-1034253 -964752353\n... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou've got an array a, consisting of n integers. The array elements are indexed from 1 to n. Let's determine a two step operation like that:\n\n 1. First we build by the array a an array s of partial sums, consisting of ... | [{"type": "stdin_stdout", "input": "42 42\n42 42 42 42 74 42 42 42 3 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 59 42 42 42 42 42\n", "output": "42 1806 39732 595980 6853802 64426782 515432400 608248315 553670947 820980301 784579711 753219887 714714707 805611691 208784644 262712997... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou've just entered a programming contest and have a chance to win a million dollars. This is the last question you have to solve, so your victory (and your vacation) depend on it. Can you guess the function just by looki... | [{"input": "123\n456", "output": "[1419]", "fn_name": "code"}, {"input": "200\n100", "output": "[1698]", "fn_name": "code"}, {"input": "100\n200", "output": "[1698]", "fn_name": "code"}, {"input": "12\n8", "output": "[88]", "fn_name": "code"}, {"input": "3\n2", "output": "[13]", "fn_name": "code"}, {"input": "1\n1", "o... | code_functional |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nA balance scale tips to the left if L>R, where L is the total weight of the masses on the left pan and R is the total weight of the masses on the right pan. Similarly, it balances if L=R, and tips to the right if L<R.\nTa... | [{"type": "stdin_stdout", "input": "3 4 5 2\n", "output": "Balanced\n"}, {"type": "stdin_stdout", "input": "0 8 7 1", "output": "Balanced\n"}, {"type": "stdin_stdout", "input": "4 3 5 2", "output": "Balanced\n"}, {"type": "stdin_stdout", "input": "8 3 8 3", "output": "Balanced\n"}, {"type": "stdin_stdout", "input": "12... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\n# Task\n\nJohn won the championship of a TV show. He can get some bonuses.\n\nHe needs to play a game to determine the amount of his bonus.\n\nHere are some cards in a row. A number is written on each card.\n\nIn each tur... | [{"input": "[4, 10, 2, 3, 1, 3, 1, 6, 9]", "output": "[6722]", "fn_name": "calc"}, {"input": "[1, 2, 5]", "output": "[50]", "fn_name": "calc"}, {"input": "[1, 2, 1]", "output": "[22]", "fn_name": "calc"}, {"input": "[1, 1]", "output": "[6]", "fn_name": "calc"}, {"input": "[1]", "output": "[2]", "fn_name": "calc"}] | code_functional |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nGematria is an Assyro-Babylonian-Greek system of code and numerology later adopted into Jewish culture. The system assigns numerical value to a word or a phrase in the belief that words or phrases with identical numerical... | [{"input": "\"Coding is fun\"", "output": "[458]", "fn_name": "gematria"}, {"input": "\"jaels\"", "output": "[716]", "fn_name": "gematria"}, {"input": "\"JAELS\"", "output": "[716]", "fn_name": "gematria"}, {"input": "\"Devil\"", "output": "[738]", "fn_name": "gematria"}, {"input": "\"love\"", "output": "[775]", "fn_na... | code_functional |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nIn the school computer room there are n servers which are responsible for processing several computing tasks. You know the number of scheduled tasks for each server: there are m_{i} tasks assigned to the i-th server.\n\nI... | [{"type": "stdin_stdout", "input": "10\n19999 19999 20000 20000 29860 20000 12103 20000 19999 17191\n", "output": "10536\n"}, {"type": "stdin_stdout", "input": "10\n19999 19999 20000 39539 29860 20000 12103 20000 19999 17191\n", "output": "25661\n"}, {"type": "stdin_stdout", "input": "10\n11328 19999 20000 39539 29860 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nA permutation of length n is an integer sequence such that each integer from 0 to (n - 1) appears exactly once in it. For example, sequence [0, 2, 1] is a permutation of length 3 while both [0, 2, 2] and [1, 2, 3] are not... | [{"type": "stdin_stdout", "input": "100\n99 5 40 32 4 31 38 57 94 47 26 16 89 72 9 80 55 86 78 90 42 41 46 74 56 97 21 48 66 27 93 85 88 59 64 95 10 45 12 22 84 60 8 98 62 51 14 65 39 30 11 71 92 19 76 43 87 54 15 53 37 6 25 18 96 35 13 91 2 3 0 23 1 7 49 75 81 33 50 52 63 44 69 36 17 61 24 20 68 34 73 29 70 83 58 79 8... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou have N items that you want to put them into a knapsack. Item i has value vi and weight wi.\n\nYou want to find a subset of items to put such that:\n\n* The total value of the items is as large as possible.\n* The item... | [{"type": "stdin_stdout", "input": "4 3\n4 0\n5 2\n2 1\n13 1", "output": "22\n"}, {"type": "stdin_stdout", "input": "4 6\n4 0\n5 2\n2 1\n13 1", "output": "24\n"}, {"type": "stdin_stdout", "input": "4 5\n0 2\n5 2\n2 1\n8 3", "output": "13\n"}, {"type": "stdin_stdout", "input": "4 5\n4 2\n5 2\n2 0\n8 3", "output": "15\n"... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nEugeny loves listening to music. He has n songs in his play list. We know that song number i has the duration of t_{i} minutes. Eugeny listens to each song, perhaps more than once. He listens to song number i c_{i} times.... | [{"type": "stdin_stdout", "input": "10 10\n3 1\n2 7\n5 1\n7 2\n9 10\n9 5\n2 5\n4 8\n9 9\n1 9\n26 34 37 141 146 201 239 245 296 299\n", "output": "4\n4\n5\n6\n6\n8\n9\n9\n10\n10\n"}, {"type": "stdin_stdout", "input": "10 10\n3 1\n2 7\n5 1\n7 2\n9 10\n9 5\n2 5\n4 10\n9 15\n1 9\n26 34 37 141 146 201 239 245 296 299\n", "o... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nI need to save some money to buy a gift. I think I can do something like that:\n\nFirst week (W0) I save nothing on Sunday, 1 on Monday, 2 on Tuesday... 6 on Saturday,\nsecond week (W1) 2 on Monday... 7 on Saturday and so... | [{"input": "4000", "output": "[32024004000]", "fn_name": "finance"}, {"input": "5000", "output": "[62537505000]", "fn_name": "finance"}, {"input": "2000", "output": "[4006002000]", "fn_name": "finance"}, {"input": "730", "output": "[195308580]", "fn_name": "finance"}, {"input": "999", "output": "[499999500]", "fn_name"... | code_functional |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nSnuke built an online judge to hold a programming contest.\n\nWhen a program is submitted to the judge, the judge returns a verdict, which is a two-character string that appears in the string S as a contiguous substring. ... | [{"type": "stdin_stdout", "input": "ACABA", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "ACBAA", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "ACAAA", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "AAACA", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "AAAC@", "output": "Yes\n"}, {"ty... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nToday Vasya visited a widely known site and learned that the continuation of his favourite game Codecraft II will appear after exactly k months. He looked at the calendar and learned that at the moment is the month number... | [{"type": "stdin_stdout", "input": "September\n0\n", "output": "September\n"}, {"type": "stdin_stdout", "input": "November\n46\n", "output": "September\n"}, {"type": "stdin_stdout", "input": "December\n240\n", "output": "December\n"}, {"type": "stdin_stdout", "input": "December\n81\n", "output": "September\n"}, {"type"... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nFor a set $S$ of integers, perform a sequence of the following operations. Note that multiple elements can have equivalent values in $S$.\n\n* insert($x$): Insert $x$ to $S$ and report the number of elements in $S$ after ... | [{"type": "stdin_stdout", "input": "10\n0 1\n0 1\n0 2\n0 3\n2 2\n1 1\n0 2\n1 3\n0 4\n3 1 4", "output": "1\n2\n3\n4\n2\n4\n1\n5\n1\n1\n2\n3\n4\n"}, {"type": "stdin_stdout", "input": "10\n0 1\n0 1\n0 2\n0 3\n2 2\n1 1\n1 1\n1 3\n0 4\n3 1 4", "output": "1\n2\n3\n4\n2\n2\n1\n4\n1\n1\n3\n4\n"}, {"type": "stdin_stdout", "inpu... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAs you may know, once some people pass their teens, they jokingly only celebrate their 20th or 21st birthday, forever. With some maths skills, that's totally possible - you only need to select the correct number base!\n\n... | [{"input": "32", "output": "[\"32? That's just 20, in base 16!\"]", "fn_name": "womens_age"}, {"input": "39", "output": "[\"39? That's just 21, in base 19!\"]", "fn_name": "womens_age"}, {"input": "22", "output": "[\"22? That's just 20, in base 11!\"]", "fn_name": "womens_age"}, {"input": "65", "output": "[\"65? That's... | code_functional |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nGiven is a string S of length N consisting of lowercase English letters.\nSnuke can do this operation any number of times: remove fox occurring as a substring from s and concatenate the remaining parts of s.\nWhat is the ... | [{"type": "stdin_stdout", "input": "90585\nfohfoxuvgjxpybcfoxmefomtzopbsprupidgsybejhphoymfoxxaobhdxbmfoxqioqjzehbmufpownifoxhwlrybqsqijgkdmbpfoxzlobcfoxfpdznrbcqqjqglhqgnuooojywfoxfsqesfoxagdfmfoxlzlhjxrfkwmrktsintfocipouajpsqucpoydkfogknyjffoxddeqsrdeupfownwreitzyflusfoxrhmoffoxqfoxsmyurkfotmlxhekuksfotxukcdfopfoxrcr... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nMadoka decided to entrust the organization of a major computer game tournament \"OSU\"!\n\nIn this tournament, matches are held according to the \"Olympic system\". In other words, there are $2^n$ participants in the tour... | [{"type": "stdin_stdout", "input": "100000 1000000000\n", "output": "607723520\n"}, {"type": "stdin_stdout", "input": "100000 53228\n", "output": "871774727\n"}, {"type": "stdin_stdout", "input": "11994 11995\n", "output": "685385528\n"}, {"type": "stdin_stdout", "input": "87532 32150\n", "output": "165162987\n"}, {"ty... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nDo you know a story about the three musketeers? Anyway, you will learn about its origins now.\n\nRichelimakieu is a cardinal in the city of Bearis. He is tired of dealing with crime by himself. He needs three brave warrio... | [{"type": "stdin_stdout", "input": "987 50\n221 959\n221 553\n959 695\n553 959\n819 437\n371 295\n695 553\n959 347\n595 699\n652 628\n553 347\n868 589\n695 221\n282 714\n351 703\n104 665\n755 436\n556 511\n695 347\n221 347\n243 874\n695 847\n863 501\n583 145\n786 221\n38 286\n72 397\n808 658\n724 437\n911 548\n405 759\... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere are $n$ models in the shop numbered from $1$ to $n$, with sizes $s_1, s_2, \\ldots, s_n$.\n\nOrac will buy some of the models and will arrange them in the order of increasing numbers (i.e. indices, but not sizes).\n... | [{"type": "stdin_stdout", "input": "4\n23\n3198 4895 1585 3916 2650 5552 876 2731 1971 126 2152 6910 1096 4103 1074 2594 2897 3983 3830 3460 729 576 3281\n1\n0000000010\n2\n1 1\n100\n1 2 3 4 5 2 7 10 9 14 11 12 13 14 24 16 17 33 19 20 21 22 23 24 25 26 27 28 29 41 31 32 56 34 35 36 37 38 39 40 41 42 43 44 45 46 54 48 2... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nA permutation p of size n is the sequence p1, p2, ..., pn, consisting of n distinct integers, each of them is from 1 to n (1 ≤ pi ≤ n).\n\nA lucky permutation is such permutation p, that any integer i (1 ≤ i ≤ n) meets th... | [{"type": "stdin_stdout", "input": "17877\n", "output": "2 17877 4 17875 6 17873 8 17871 10 17869 12 17867 14 17865 16 17863 18 17861 20 17859 22 17857 24 17855 26 17853 28 17851 30 17849 32 17847 34 17845 36 17843 38 17841 40 17839 42 17837 44 17835 46 17833 48 17831 50 17829 52 17827 54 17825 56 17823 58 17821 60 178... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nConsider the prime number `23`. If we sum the square of its digits we get:\n`2^2 + 3^2 = 13`, then for `13: 1^2 + 3^2 = 10`, and finally for `10: 1^2 + 0^2 = 1`. \n\nSimilarly, if we start with prime number `7`, the seque... | [{"input": "100\n1000", "output": "[28]", "fn_name": "solve"}, {"input": "100\n2000", "output": "[47]", "fn_name": "solve"}, {"input": "100\n3000", "output": "[65]", "fn_name": "solve"}, {"input": "100\n4000", "output": "[95]", "fn_name": "solve"}, {"input": "1\n25", "output": "[4]", "fn_name": "solve"}] | code_functional |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nLet's call an array $a$ of $m$ integers $a_1, a_2, \\ldots, a_m$ Decinc if $a$ can be made increasing by removing a decreasing subsequence (possibly empty) from it.\n\nFor example, if $a = [3, 2, 4, 1, 5]$, we can remove ... | [{"type": "stdin_stdout", "input": "20\n2 1 13 10 12 18 15 19 5 14 16 9 3 8 17 11 7 20 6 4\n", "output": "90\n"}, {"type": "stdin_stdout", "input": "10\n7 10 1 8 3 9 2 4 6 5\n", "output": "39\n"}, {"type": "stdin_stdout", "input": "6\n4 5 2 6 1 3\n", "output": "19\n"}, {"type": "stdin_stdout", "input": "3\n2 3 1\n", "o... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nHearing that energy drinks increase rating in those sites, Takahashi decides to buy up M cans of energy drinks.\nThere are N stores that sell energy drinks. In the i-th store, he can buy at most B_i cans of energy drinks ... | [{"type": "stdin_stdout", "input": "1 100000\n1000000000 100000\n", "output": "100000000000000\n"}, {"type": "stdin_stdout", "input": "1 100000\n1000000100 100000", "output": "100000010000000\n"}, {"type": "stdin_stdout", "input": "1 100000\n1000000110 100010", "output": "100000011000000\n"}, {"type": "stdin_stdout", "... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nPetya 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\... | [{"type": "stdin_stdout", "input": "10\n4 8 480392999\n3 4 32525297\n9 7 417904789\n6 2 836294777\n5 3 616099185\n1 7 830574407\n8 10 838073755\n6 10 547050646\n2 1 12607780\n", "output": "0"}, {"type": "stdin_stdout", "input": "5\n1 2 1000000000\n2 3 747774\n3 4 4\n4 5 8447854\n", "output": " ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nPig is visiting a friend.\n\nPig's house is located at point 0, and his friend's house is located at point m on an axis.\n\nPig can use teleports to move along the axis.\n\nTo use a teleport, Pig should come to a certain ... | [{"type": "stdin_stdout", "input": "70 100\n0 99\n1 87\n1 94\n1 4\n2 72\n3 39\n3 69\n4 78\n5 85\n7 14\n8 59\n12 69\n14 15\n14 76\n17 17\n19 53\n19 57\n19 21\n21 35\n21 83\n24 52\n24 33\n27 66\n27 97\n30 62\n30 74\n30 64\n32 63\n35 49\n37 60\n40 99\n40 71\n41 83\n42 66\n42 46\n45 83\n51 76\n53 69\n54 82\n54 96\n54 88\n5... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nIn graph theory, a graph is a collection of nodes with connections between them.\nAny node can be connected to any other node exactly once, and can be connected to no nodes, to some nodes, or to every other node.\nNodes c... | [{"input": "[[1], [0, 2, 3], [1], [1], [5], [4, 6, 7], [5], [5]]", "output": "[false]", "fn_name": "isTree"}, {"input": "[[1], [0, 2], [1, 3, 5], [2, 4], [3, 5], [4, 2]]", "output": "[false]", "fn_name": "isTree"}, {"input": "[[1, 2], [0, 3], [0, 3], [1, 2, 4], [3]]", "output": "[false]", "fn_name": "isTree"}, {"input"... | code_functional |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nIvan had string s consisting of small English letters. However, his friend Julia decided to make fun of him and hid the string s. Ivan preferred making a new string to finding the old one. \n\nIvan knows some information ... | [{"type": "stdin_stdout", "input": "18\nabacab 2 329 401\nabadabacabae 1 293\nbacab 1 2\nabacabadabacabaga 1 433\nc 1 76\nbaca 1 26\ndab 1 72\nabagabaca 1 445\nabaea 1 397\ndabac 1 280\nab 2 201 309\nca 1 396\nabacabadab 1 497\nac 1 813\ncaba 1 444\nad 1 167\nbadab 1 358\naba 1 421\n", "output": "abacabaaaaaaaaaaaaaaaa... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nKolya is developing an economy simulator game. His most favourite part of the development process is in-game testing. Once he was entertained by the testing so much, that he found out his game-coin score become equal to 0... | [{"type": "stdin_stdout", "input": "1000000000\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "1000000000\n", "output": "YES"}, {"type": "stdin_stdout", "input": "999129999\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "917261049\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "80321920... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere are N cities and M roads.\nThe i-th road (1≤i≤M) connects two cities a_i and b_i (1≤a_i,b_i≤N) bidirectionally.\nThere may be more than one road that connects the same pair of two cities.\nFor each city, how many ro... | [{"type": "stdin_stdout", "input": "17 1\n2 8\n3 4\n1 5\n2 8\n4 7\n8 2\n4 1\n0 14", "output": "0\n1\n0\n0\n0\n0\n0\n1\n0\n0\n0\n0\n0\n0\n0\n0\n0\n"}, {"type": "stdin_stdout", "input": "13 7\n2 4\n3 4\n1 5\n2 8\n3 7\n5 2\n4 1\n6 8", "output": "2\n3\n2\n3\n2\n0\n1\n1\n0\n0\n0\n0\n0\n"}, {"type": "stdin_stdout", "input": ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nNaturally, the magical girl is very good at performing magic. She recently met her master wizard Devu, who gifted her R potions of red liquid, \nB potions of blue liquid, and G potions of green liquid.\n\n- \nThe red liqu... | [{"type": "stdin_stdout", "input": "3\n0 0 0 1\n2\n0\n0\n0 -1 -1 0\n3\n4\n-1\n3 1 2 1\n2 1 0\n1 12\n0 15", "output": "1\n4\n12\n"}, {"type": "stdin_stdout", "input": "3\n0 0 0 1\n2\n0\n0\n0 -1 -1 0\n3\n5\n-1\n3 1 2 1\n2 1 0\n1 12\n0 15", "output": "1\n5\n12\n"}, {"type": "stdin_stdout", "input": "3\n0 0 1 0\n1\n0\n0\n2... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nNastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task.\n\nTwo matrices $A$ and $B$ are given, each of them has size $n \\times m$. Nastya can perfo... | [{"type": "stdin_stdout", "input": "4 9\n1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "4 9\n1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1\n1 1 1 1... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nGiven an array of numbers (in string format), you must return a string. The numbers correspond to the letters of the alphabet in reverse order: a=26, z=1 etc. You should also account for `'!'`, `'?'` and `' '` that are re... | [{"input": "[\"25\", \"7\", \"8\", \"4\", \"14\", \"23\", \"8\", \"25\", \"23\", \"29\", \"16\", \"16\", \"4\"]", "output": "[\"btswmdsbd kkw\"]", "fn_name": "switcher"}, {"input": "[\"12\", \"28\", \"25\", \"21\", \"25\", \"7\", \"11\", \"22\", \"15\"]", "output": "[\"o?bfbtpel\"]", "fn_name": "switcher"}, {"input": "... | code_functional |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nFor an array of non-negative integers $a$ of size $n$, we construct another array $d$ as follows: $d_1 = a_1$, $d_i = |a_i - a_{i - 1}|$ for $2 \\le i \\le n$.\n\nYour task is to restore the array $a$ from a given array $... | [{"type": "stdin_stdout", "input": "69\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\n## Task\n\nComplete the function that receives an array of strings (`arr`) as an argument and returns all the valid Roman numerals.\n\nBasic Roman numerals are denoted as:\n\n```\nI: 1, V: 5, X: 10, L: 50, C: 100, D: 500,... | [{"input": "[\"MMCDXVIII\", \"\", \"MMMCCXXXIV\", \"MMMMDCLXXXI\", \"MMMCMXIL\", \"MMMMCLXI\"]", "output": "[[\"MMCDXVIII\", \"MMMCCXXXIV\", \"MMMMDCLXXXI\", \"MMMMCLXI\"]]", "fn_name": "valid_romans"}, {"input": "[\"MMMMCCCXXXII\", \"MMDCCCXXVCD\", \"MMCCCXLV\", \"DCCLXVIIICD\", \"MMMMCXII\"]", "output": "[[\"MMMMCCCX... | code_functional |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nGiven an integer a as input, print the value a + a^2 + a^3.\n\n-----Constraints-----\n - 1 \\leq a \\leq 10\n - a is an integer.\n\n-----Input-----\nInput is given from Standard Input in the following format:\na\n\n-----O... | [{"type": "stdin_stdout", "input": "1109", "output": "1365169019\n"}, {"type": "stdin_stdout", "input": "488", "output": "116452904\n"}, {"type": "stdin_stdout", "input": "762", "output": "443032134\n"}, {"type": "stdin_stdout", "input": "767", "output": "451806719\n"}, {"type": "stdin_stdout", "input": "853", "output"... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nNearly each project of the F company has a whole team of developers working on it. They often are in different rooms of the office in different cities and even countries. To keep in touch and track the results of the proj... | [{"type": "stdin_stdout", "input": "110 5\n- 60\n- 58\n+ 25\n- 32\n+ 86\n", "output": "105\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 26 27 28 29 30 31 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 59 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nMichael and Joe are playing a game. The game is played on a grid with $n$ rows and $m$ columns, filled with distinct integers. We denote the square on the $i$-th ($1\\le i\\le n$) row and $j$-th ($1\\le j\\le m$) column b... | [{"type": "stdin_stdout", "input": "18\n1 1\n-37\n1 2\n47 0\n1 2\n-48 -7\n2 1\n37\n-8\n2 1\n-3\n27\n2 2\n46 36\n-33 -9\n2 2\n-20 24\n-6 -33\n2 2\n-50 -45\n50 10\n2 2\n-38 -12\n1 8\n3 3\n42 4 -29\n-27 28 -16\n-35 -13 26\n3 3\n-46 40 -27\n-32 28 -24\n37 13 -13\n3 3\n-38 -17 30\n22 -50 7\n-26 18 -3\n3 3\n-2 26 29\n41 11 2... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nDuring a recent research Berland scientists found out that there were n cities in Ancient Berland, joined by two-way paths. Any two cities are joined by no more than one path. No path joins a city with itself. According t... | [{"type": "stdin_stdout", "input": "183\n", "output": "8372\n1 92\n1 93\n1 94\n1 95\n1 96\n1 97\n1 98\n1 99\n1 100\n1 101\n1 102\n1 103\n1 104\n1 105\n1 106\n1 107\n1 108\n1 109\n1 110\n1 111\n1 112\n1 113\n1 114\n1 115\n1 116\n1 117\n1 118\n1 119\n1 120\n1 121\n1 122\n1 123\n1 124\n1 125\n1 126\n1 127\n1 128\n1 129\n1... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThor is getting used to the Earth. As a gift Loki gave him a smartphone. There are n applications on this phone. Thor is fascinated by this phone. He has only one minor issue: he can't count the number of unread notificat... | [{"type": "stdin_stdout", "input": "10 85\n2 2\n1 10\n1 1\n2 6\n1 2\n1 4\n1 7\n2 1\n1 1\n3 3\n1 9\n1 6\n1 8\n1 10\n3 8\n2 8\n1 6\n1 3\n1 9\n1 6\n1 3\n1 8\n1 1\n1 6\n1 10\n2 1\n2 10\n1 10\n1 1\n1 10\n1 6\n2 2\n1 8\n1 3\n1 4\n1 9\n1 5\n1 5\n2 2\n2 4\n1 7\n1 1\n2 4\n2 9\n1 1\n1 7\n1 8\n3 14\n1 10\n2 2\n1 3\n1 10\n1 6\n3 3... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThe employees of the F company have lots of ways to entertain themselves. Today they invited a famous magician who shows a trick with plastic cups and a marble.\n\nThe point is to trick the spectator's attention. Initiall... | [{"type": "stdin_stdout", "input": "100 50\n11 28\n11 1\n98 58\n38 27\n24 27\n67 37\n90 48\n91 14\n43 29\n3 64\n24 6\n53 19\n97 65\n13 27\n75 53\n37 82\n69 75\n94 99\n1 26\n95 60\n45 27\n100 82\n71 49\n86 99\n74 58\n88 68\n39 63\n38 23\n22 39\n29 58\n62 83\n62 1\n61 58\n2 30\n41 48\n83 90\n1 17\n73 81\n23 53\n71 16\n43... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\n### self_converge\n`Goal`: Given a number (with a minimum of 3 digits), return the number of iterations it takes to arrive at a derived number that converges on to itself, as per the following [Kaprekar][Kaprekar] routine... | [{"input": "992299229", "output": "[22]", "fn_name": "self_converge"}, {"input": "90900", "output": "[9]", "fn_name": "self_converge"}, {"input": "4321", "output": "[4]", "fn_name": "self_converge"}, {"input": "2111", "output": "[6]", "fn_name": "self_converge"}, {"input": "211", "output": "[7]", "fn_name": "self_conve... | code_functional |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given an array consisting of all integers from $[l, r]$ inclusive. For example, if $l = 2$ and $r = 5$, the array would be $[2, 3, 4, 5]$. What's the minimum number of elements you can delete to make the bitwise A... | [{"type": "stdin_stdout", "input": "5\n1 1\n1 8\n7 10\n1 10\n100000 186611\n", "output": "0\n4\n1\n5\n31072\n"}, {"type": "stdin_stdout", "input": "5\n1 2\n1 13\n4 5\n4 10\n110000 200000\n", "output": "1\n6\n0\n3\n21072\n"}, {"type": "stdin_stdout", "input": "5\n1 2\n1 13\n4 5\n1 10\n110000 200000\n", "output": "1\n6\n... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nLet's denote the median of a sequence $s$ with odd length as the value in the middle of $s$ if we sort $s$ in non-decreasing order. For example, let $s = [1, 2, 5, 7, 2, 3, 12]$. After sorting, we get sequence $[1, 2, 2, ... | [{"type": "stdin_stdout", "input": "4\n3 5 1\n1\n13 3 3\n1 4 7\n15 5 3\n2 5 10\n17 18 7\n2 3 5 7 5 11 12\n", "output": "NO\nYES\nYES\nNO\n"}, {"type": "stdin_stdout", "input": "4\n3 5 1\n1\n11 3 3\n1 3 7\n15 5 3\n4 5 6\n13 7 7\n2 3 5 7 9 11 12\n", "output": "NO\nYES\nYES\nYES\n"}, {"type": "stdin_stdout", "input": "4\n... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAlternate Escape\n\nAlice House\n\nAlice and Bob are playing board games. This board game is played using a board with squares in rows H and columns and one frame. In this game, the upper left square of the board is set a... | [{"type": "stdin_stdout", "input": "3 3 2 2\n 1 1 1\n0 0 0 0\n 1 1 1\n0 0 0 0\n 1 1 1\n0 0 0 0\n 1 1 1\n3 3 2 1\n 1 0 1\n1 0 1 1\n 1 0 0\n0 0 0 0\n 0 0 1\n1 1 0 1\n 1 0 1\n1 3 1 1\n 1 1 1\n1 0 0 1\n 1 0 1\n2 2 1 1\n 1 0\n1 0 0\n 0 0\n0 0 0\n 0 0\n0 0 0 0", "output": "Yes\nYes\nYes\nNo\n"}, {"type": "stdin_stdout", "inp... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nIn the beginning, Takahashi has A cookies, and Aoki has B cookies. They will perform the following operation alternately, starting from Takahashi:\n\n* If the number of cookies in his hand is odd, eat one of those cookies... | [{"type": "stdin_stdout", "input": "231274241 358979323 84", "output": "393502366 196751183\n"}, {"type": "stdin_stdout", "input": "377378637 358979323 84", "output": "490905292 245452646\n"}, {"type": "stdin_stdout", "input": "7425724 358979323 157", "output": "122135010 244270020\n"}, {"type": "stdin_stdout", "input"... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nKaren is getting ready for a new school day!\n\n [Image] \n\nIt is currently hh:mm, given in a 24-hour format. As you know, Karen loves palindromes, and she believes that it is good luck to wake up when the time is a pali... | [{"type": "stdin_stdout", "input": "05:51\n", "output": "250\n"}, {"type": "stdin_stdout", "input": "15:52\n", "output": "250\n"}, {"type": "stdin_stdout", "input": "06:59\n", "output": "182\n"}, {"type": "stdin_stdout", "input": "17:31\n", "output": "151\n"}, {"type": "stdin_stdout", "input": "07:59\n", "output": "122... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nDuring the archaeological research in the Middle East you found the traces of three ancient religions: First religion, Second religion and Third religion. You compiled the information on the evolution of each of these bel... | [{"type": "stdin_stdout", "input": "2 12\naa\n+ 1 a\n+ 2 a\n+ 3 a\n- 1\n+ 1 a\n- 2\n+ 2 a\n- 3\n+ 3 a\n+ 2 a\n- 1\n- 3\n", "output": "YES\nYES\nNO\nYES\nNO\nYES\nNO\nYES\nNO\nNO\nNO\nYES\n"}, {"type": "stdin_stdout", "input": "2 12\naa\n+ 1 a\n+ 2 a\n+ 3 a\n- 1\n+ 1 a\n- 2\n+ 2 a\n- 3\n+ 3 a\n+ 2 a\n- 1\n- 3\n", "outpu... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nWe have a string S of length N consisting of uppercase English letters.\nHow many times does ABC occur in S as contiguous subsequences (see Sample Inputs and Outputs)?\n\n-----Constraints-----\n - 3 \\leq N \\leq 50\n - S... | [{"type": "stdin_stdout", "input": "50\nABCABCABCABCABCABCABCABCABCABCABCABCABCABCABCABCAB\n", "output": "16\n"}, {"type": "stdin_stdout", "input": "50\nBMZBMWEYYDIADTLCOUEGMDBYFWURPWBPUVHIFNUAPWYNDMHTQV\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "50\nKGKBHTYTSZOTWFLEGSJZZSZFWTZFPNSCGUEMWRCZQXYCIVDQNK\n", ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nDreamoon is a big fan of the Codeforces contests.\n\nOne day, he claimed that he will collect all the places from $1$ to $54$ after two more rated contests. It's amazing!\n\nBased on this, you come up with the following p... | [{"type": "stdin_stdout", "input": "5\n6 2\n3 1 1 5 7 10\n1 100\n100\n11 1\n1 1 1 1 1 1 1 1 1 1 1\n1 1\n1\n4 57\n80 60 40 20\n", "output": "5\n101\n2\n2\n60\n"}, {"type": "stdin_stdout", "input": "5\n6 2\n3 1 1 5 7 10\n1 100\n100\n11 1\n1 1 1 1 1 1 1 1 1 1 1\n1 1\n1\n4 57\n61 60 40 20\n", "output": "5\n101\n2\n2\n61\n"... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nReminder: the median of the array $[a_1, a_2, \\dots, a_{2k+1}]$ of odd number of elements is defined as follows: let $[b_1, b_2, \\dots, b_{2k+1}]$ be the elements of the array in the sorted order. Then median of this ar... | [{"type": "stdin_stdout", "input": "3\n1\n1 1\n3\n6 5 4 1 2 3\n5\n13 4 10 22 2 5 10 3 16 16\n", "output": "0\n1\n0\n"}, {"type": "stdin_stdout", "input": "3\n1\n-1 2\n3\n11 1 0 2 2 5\n5\n13 2 7 13 1 5 1 3 23 14\n", "output": "3\n0\n2\n"}, {"type": "stdin_stdout", "input": "3\n1\n1 2\n3\n6 5 4 1 2 1\n5\n13 4 7 14 2 10 1... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nDark Assembly is a governing body in the Netherworld. Here sit the senators who take the most important decisions for the player. For example, to expand the range of the shop or to improve certain characteristics of the c... | [{"type": "stdin_stdout", "input": "8 1 8109\n1944 40\n9732 40\n9214 80\n1770 40\n7837 50\n7430 100\n1753 30\n3991 60\n", "output": "0.6441514424\n"}, {"type": "stdin_stdout", "input": "8 3 6395\n8159 90\n4143 50\n6954 50\n5011 20\n9872 10\n7689 90\n8811 70\n2058 10\n", "output": "0.5175644027\n"}, {"type": "stdin_stdo... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nGiven a string, swap the case for each of the letters.\n\ne.g. CodEwArs --> cODeWaRS\n\n### Examples\n\n```\n\"\" -> \"\"\n\"CodeWars\" -> \"cODEwARS\"\n\"abc\" -> \"ABC\"\n\"ABC\" -> \"a... | [{"input": "\"ThIs iS A l0NG sENTence witH nUMbERs in IT 123 456\"", "output": "[\"tHiS Is a L0ng SentENCE WITh NumBerS IN it 123 456\"]", "fn_name": "swap"}, {"input": "\"H_E_l-l_0 WO|||Rld\"", "output": "[\"h_e_L-L_0 wo|||rLD\"]", "fn_name": "swap"}, {"input": "\"EeEEeeEEEeee\"", "output": "[\"eEeeEEeeeEEE\"]", "fn_n... | code_functional |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAs a big fan of Formula One, Charlie is really happy with the fact that he has to organize ticket sells for the next Grand Prix race in his own city. Unfortunately, the finacial crisis is striking everywhere and all the b... | [{"type": "stdin_stdout", "input": "100000 100000 1\n", "output": "3.999900002193968e-05\n"}, {"type": "stdin_stdout", "input": "15566 14608 0\n", "output": "0.061604676559388505\n"}, {"type": "stdin_stdout", "input": "100000 100000 10\n", "output": "0.00120926220494\n"}, {"type": "stdin_stdout", "input": "100000 10000... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThe Smart Beaver from ABBYY began to develop a new educational game for children. The rules of the game are fairly simple and are described below.\n\nThe playing field is a sequence of n non-negative integers ai numbered ... | [{"type": "stdin_stdout", "input": "120\n242 524 420 973 816 432 247 666 134 849 145 366 1119 930 613 315 863 628 97 109 65 704 741 314 736 17 872 971 559 648 223 771 171 327 782 837 303 393 292 339 730 834 794 868 540 251 789 893 23 305 116 220 699 863 580 992 861 393 98 253 544 171 336 207 348 496 316 285 286 727 613... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given a matrix of size $n \\times n$ filled with lowercase English letters. You can change no more than $k$ letters in this matrix.\n\nConsider all paths from the upper left corner to the lower right corner that m... | [{"type": "stdin_stdout", "input": "7 6\nypnxnnp\npnxonpm\nnxanpou\nxnnpmud\nnhtdudu\nnpmuduh\npmutsnz\n", "output": "aaaaaaadudsnz\n"}, {"type": "stdin_stdout", "input": "7 6\nypnxnnp\npnxonpm\nnxanpou\nxnnpmud\nnhtdudu\nhudumpn\npmutsnz\n", "output": "aaaaaaadudpnz\n"}, {"type": "stdin_stdout", "input": "7 6\nypnxpnn... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are now in a bookshop with your friend Alice to buy a book, \"The Winning Strategy for the Programming Koshien Contest,” just released today. As you definitely want to buy it, you are planning to borrow some money fro... | [{"type": "stdin_stdout", "input": "0111 12618 3831", "output": "3720\n"}, {"type": "stdin_stdout", "input": "0101 15626 3831", "output": "3730\n"}, {"type": "stdin_stdout", "input": "0110 15626 3831", "output": "3721\n"}, {"type": "stdin_stdout", "input": "0111 27455 5699", "output": "5588\n"}, {"type": "stdin_stdout"... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nLet S be the sum of divisors of an integer N excluding the number itself. When N = S, N is called a perfect number, when N> S, N is called a defendant number, and when N <S, N is called an abundant number. Create a progra... | [{"type": "stdin_stdout", "input": "1\n2\n2\n1\n1\n14\n16\n27\n66290451\n187711252\n124798312\n100001000\n0", "output": "deficient number\ndeficient number\ndeficient number\ndeficient number\ndeficient number\ndeficient number\ndeficient number\ndeficient number\ndeficient number\ndeficient number\ndeficient number\na... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere are N lines in the xy-plane. The i-th line is represented by A_ix+B_iy=C_i. Any two lines among the N+2 lines, the above N lines plus the x-axis and y-axis, cross each other at exactly one point.\n\nFor each pair 1 ... | [{"type": "stdin_stdout", "input": "7\n1 7 8\n-2 4 9\n3 -8 -5\n9 2 -14\n6 7 5\n-8 -9 3\n3 8 10", "output": "-1.722222222222222 1.325000000000000"}, {"type": "stdin_stdout", "input": "7\n1 7 9\n-2 4 9\n3 -8 -5\n17 2 -14\n4 11 5\n-8 -9 3\n1 8 10", "output": "-1.027777778 1.210526316\n"}, {"type": "stdin_stdout", "input":... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nRecently Max has got himself into popular CCG \"BrainStone\". As \"BrainStone\" is a pretty intellectual game, Max has to solve numerous hard problems during the gameplay. Here is one of them:\n\nMax owns n creatures, i-t... | [{"type": "stdin_stdout", "input": "10 9 0\n620118469 704168608\n528098892 341451371\n15150469 449838744\n960504540 722185004\n271837337 344050133\n940943201 419522619\n85569623 788965215\n161962866 563795701\n943389281 445744350\n610994199 473866838\n", "output": "5253588583\n"}, {"type": "stdin_stdout", "input": "10 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given n segments on the Ox-axis. You can drive a nail in any integer point on the Ox-axis line nail so, that all segments containing this point, are considered nailed down. If the nail passes through endpoint of s... | [{"type": "stdin_stdout", "input": "35\n-47 61\n-73 -15\n9 43\n43 -4\n13 -6\n48 -65\n49 -84\n-6 76\n40 6\n-41 11\n-63 -42\n-7 -7\n47 -98\n-17 61\n79 99\n47 -98\n61 31\n85 72\n-50 -17\n-67 45\n14 -50\n-45 61\n-6 -96\n-47 -83\n56 -58\n-24 -15\n14 20\n-95 -82\n47 93\n-4 -7\n70 9\n91 -18\n-71 31\n55 -20\n81 -8\n", "output"... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given a string of words (x), for each word within the string you need to turn the word 'inside out'. By this I mean the internal letters will move out, and the external letters move toward the centre. \n\nIf the w... | [{"input": "\"what time are we climbing up the volcano\"", "output": "[\"hwta item are we milcgnib up the lovcona\"]", "fn_name": "inside_out"}, {"input": "\"massage yes massage yes massage\"", "output": "[\"samsega yes samsega yes samsega\"]", "fn_name": "inside_out"}, {"input": "\"take bintang and a dance please\"", ... | code_functional |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nTake a string and return a hash with all the ascii values of the characters in the string.\nReturns nil if the string is empty.\nThe key is the character, and the value is the ascii value of the character.\nRepeated chara... | [{"input": "\"hello world\"", "output": "[{\"h\": 104, \"e\": 101, \"l\": 108, \"o\": 111, \"w\": 119, \"r\": 114, \"d\": 100}]", "fn_name": "char_to_ascii"}, {"input": "\"ABaa ^\"", "output": "[{\"A\": 65, \"B\": 66, \"a\": 97}]", "fn_name": "char_to_ascii"}, {"input": "\"aaa\"", "output": "[{\"a\": 97}]", "fn_name": ... | code_functional |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nOn February, 30th n students came in the Center for Training Olympiad Programmers (CTOP) of the Berland State University. They came one by one, one after another. Each of them went in, and before sitting down at his desk,... | [{"type": "stdin_stdout", "input": "185\n28 4 4 26 15 21 14 35 22 28 26 24 2 35 21 34 1 23 35 10 6 16 31 0 30 9 18 33 1 22 24 26 22 10 8 27 14 33 16 16 26 22 1 28 32 1 35 12 31 0 21 6 6 5 29 27 1 29 23 22 30 19 37 17 2 2 2 25 3 23 28 0 3 31 34 5 2 23 27 7 26 25 33 27 15 31 31 4 3 21 1 1 23 30 0 13 24 33 26 5 1 17 23 25... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAn abundant number or excessive number is a number for which the sum of its proper divisors is greater than the number itself. \n\nThe integer 12 is the first abundant number. Its proper divisors are 1, 2, 3, 4 and 6 for ... | [{"input": "14771", "output": "[false]", "fn_name": "abundant_number"}, {"input": "11410", "output": "[true]", "fn_name": "abundant_number"}, {"input": "11690", "output": "[true]", "fn_name": "abundant_number"}, {"input": "118", "output": "[false]", "fn_name": "abundant_number"}, {"input": "5830", "output": "[true]", "... | code_functional |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nWe have five variables x_1, x_2, x_3, x_4, and x_5.\nThe variable x_i was initially assigned a value of i.\nSnuke chose one of these variables and assigned it 0.\nYou are given the values of the five variables after this ... | [{"type": "stdin_stdout", "input": "0 2 3 4 5\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "1 2 0 4 5\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "1 0 3 4 5\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "1 2 3 0 5\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "1 2 3 4 0\n", "o... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nOne day Vasya came across three Berland coins. They didn't have any numbers that's why Vasya didn't understand how their denominations differ. He supposed that if one coin is heavier than the other one, then it should be ... | [{"type": "stdin_stdout", "input": "A>B\nC<B\nC;tg&A\n", "output": "Impossible\n"}, {"type": "stdin_stdout", "input": "A<:B\nB>C\nC>A\n", "output": "Impossible\n"}, {"type": "stdin_stdout", "input": "&Agt;B\nC<B\nC;tg&A\n", "output": "Impossible\n"}, {"type": "stdin_stdout", "input": "B:tl&A\nB>C\nC... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou have an array a consisting of n distinct positive integers, numbered from 1 to n. Define p_k as $$$p_k = ∑_{1 ≤ i, j ≤ k} a_i mod a_j, where x \\bmod y denotes the remainder when x is divided by y. You have to find an... | [{"type": "stdin_stdout", "input": "100\n15 37 41 48 50 55 62 81 82 101 129 139 141 143 146 154 163 169 170 218 220 237 240 247 249 258 266 271 281 286 288 295 308 328 330 332 338 341 349 392 394 396 408 424 436 440 443 451 452 463 465 469 472 483 484 496 506 512 524 542 550 551 570 574 586 604 610 612 618 629 635 637 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nVery simple, given a number, find its opposite.\n\nExamples:\n```\n1: -1\n14: -14\n-34: 34\n```\n\n~~~if:sql\nYou will be given a table: `opposite`, with a column: `number`. Return a table with a column: `res`.\n~~~\n\nWr... | [{"input": "-95858588225", "output": "[95858588225]", "fn_name": "opposite"}, {"input": "1425.2222", "output": "[-1425.2222]", "fn_name": "opposite"}, {"input": "-3.1458", "output": "[3.1458]", "fn_name": "opposite"}, {"input": "25.6", "output": "[-25.6]", "fn_name": "opposite"}, {"input": "1", "output": "[-1]", "fn_na... | code_functional |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nIn Absurdistan, there are n towns (numbered 1 through n) and m bidirectional railways. There is also an absurdly simple road network — for each pair of different towns x and y, there is a bidirectional road between towns ... | [{"type": "stdin_stdout", "input": "4 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "10 5\n2 5\n1 2\n1 4\n1 3\n3 2\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "4 5\n1 3\n2 1\n3 4\n4 2\n2 3\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "5 5\n2 5\n1 2\n1 4... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nA continued fraction of height n is a fraction of form $a_{1} + \\frac{1}{a_{2} + \\frac{1}{\\ldots + \\frac{1}{a_{n}}}}$. You are given two rational numbers, one is represented as [Image] and the other one is represented... | [{"type": "stdin_stdout", "input": "633468529243155234 4\n90\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "742143496299253703 2... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nNeko loves divisors. During the latest number theory lesson, he got an interesting exercise from his math teacher.\n\nNeko has two integers $a$ and $b$. His goal is to find a non-negative integer $k$ such that the least c... | [{"type": "stdin_stdout", "input": "1000000000 264865600\n", "output": "102701600\n"}, {"type": "stdin_stdout", "input": "1000000000 264865600\n", "output": "102701600"}, {"type": "stdin_stdout", "input": "999999973 800000007\n", "output": "199999823\n"}, {"type": "stdin_stdout", "input": "159488527 938932258\n", "outp... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nMike has n strings s1, s2, ..., sn each consisting of lowercase English letters. In one move he can choose a string si, erase the first character and append it to the end of the string. For example, if he has the string \... | [{"type": "stdin_stdout", "input": "33\nnkgcmrfvxe\nvxenkgcmrf\nrfvxenkgcm\nvxenkgcmrf\nxenkgcmrfv\nenkgcmrfvx\nenkgcmrfvx\nnkgcmrfvxe\nkgcmrfvxen\ncmrfvxenkg\ncmrfvxenkg\nxenkgcmrfv\nrfvxenkgcm\nrfvxenkgcm\nnkgcmrfvxe\nxenkgcmrfv\nrfvxenkgcm\nxenkgcmrfv\nxenkgcmrfv\ngcmrfvxenk\nmrfvxenkgc\nfvxenkgcmr\nvxenkgcmrf\nenkg... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nArkady decides to observe a river for n consecutive days. The river's water level on each day is equal to some real value.\n\nArkady goes to the riverside each day and makes a mark on the side of the channel at the height... | [{"type": "stdin_stdout", "input": "100\n0 1 2 2 3 0 1 5 6 6 0 0 8 7 1 9 9 4 10 11 12 2 12 12 12 12 9 13 14 8 15 15 15 19 15 7 17 17 18 19 9 10 21 0 22 9 2 24 24 4 24 7 25 14 5 8 28 29 30 31 31 31 0 3 15 31 8 33 6 35 35 35 36 36 37 37 38 39 28 0 2 23 75 9 9 0 6 25 41 41 12 42 43 43 36 44 51 45 43 4\n", "output": "2385\... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nToday Adilbek is taking his probability theory test. Unfortunately, when Adilbek arrived at the university, there had already been a long queue of students wanting to take the same test. Adilbek has estimated that he will... | [{"type": "stdin_stdout", "input": "20 25\n1 1 1 1 1 1 2 2 1 1 2 1 2 2 1 2 1 1 2 2\n", "output": "846324940\n"}, {"type": "stdin_stdout", "input": "20 26\n1 2 1 1 1 2 1 1 2 2 2 1 2 1 2 1 1 2 2 1\n", "output": "509799974\n"}, {"type": "stdin_stdout", "input": "20 27\n1 2 1 2 1 2 1 2 2 1 2 2 1 2 2 2 1 1 2 1\n", "output":... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nA lot of frogs want to cross a river. A river is $w$ units width, but frogs can only jump $l$ units long, where $l < w$. Frogs can also jump on lengths shorter than $l$. but can't jump longer. Hopefully, there are some st... | [{"type": "stdin_stdout", "input": "100 34\n16 0 10 11 12 13 0 5 4 14 6 15 4 9 1 20 19 14 1 7 14 11 10 20 6 9 12 8 3 19 20 4 17 17 8 11 14 18 5 20 17 0 3 18 14 12 11 12 5 5 11 7 9 17 4 8 4 10 0 0 12 9 15 3 15 14 19 12 6 8 17 19 4 18 19 3 8 3 9 1 6 15 4 16 1 18 13 16 3 5 20 11 10 9 9 17 20 15 12\n", "output": "312\n"}, ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nPolycarp has recently got himself a new job. He now earns so much that his old wallet can't even store all the money he has.\n\nBerland bills somehow come in lots of different sizes. However, all of them are shaped as rec... | [{"type": "stdin_stdout", "input": "69\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given an undirected weighted connected graph with $n$ vertices and $m$ edges without loops and multiple edges.\n\nThe $i$-th edge is $e_i = (u_i, v_i, w_i)$; the distance between vertices $u_i$ and $v_i$ along the... | [{"type": "stdin_stdout", "input": "8 10\n1 2 1\n2 3 2\n2 4 5\n1 4 2\n6 3 3\n6 1 3\n3 5 2\n3 7 1\n4 8 1\n6 2 4\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "8 10\n1 2 1\n2 3 4\n2 4 5\n1 4 2\n6 3 3\n6 1 3\n3 5 2\n3 7 1\n4 8 1\n6 2 4\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "8 10\n1 2 1\n2 3 2\n... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nProblem\n\nGiven $ N $ a pair of non-negative integers $ (a_i, b_i) $ and non-negative integers $ A $, $ B $.\nI want to do as many of the following operations as possible.\n\n\n* $ | a_i --b_i | \\ leq A $ or $ B \\ leq ... | [{"type": "stdin_stdout", "input": "10 1 12\n15 70\n36 -1\n18 43\n26 46\n33 20\n58 10\n0 -1\n80 5\n98 32\n23 84", "output": "1\n"}, {"type": "stdin_stdout", "input": "10 1 12\n15 70\n36 -1\n18 43\n26 46\n33 20\n58 10\n0 -1\n80 5\n98 32\n23 30", "output": "1\n"}, {"type": "stdin_stdout", "input": "10 1 12\n15 70\n58 -1\... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nOverall there are m actors in Berland. Each actor has a personal identifier — an integer from 1 to m (distinct actors have distinct identifiers). Vasya likes to watch Berland movies with Berland actors, and he has k favor... | [{"type": "stdin_stdout", "input": "50 25\n8 18 41 25 16 39 2 47 49 37 40 23 3 35 15 7 11 28 22 48 10 17 38 46 44\n4\nswyzirxhx\n28\n43 32 14 5 0 17 25 39 0 0 36 0 0 34 27 22 6 13 26 0 0 41 12 16 0 0 0 23\nzyn\n3\n36 12 47\np\n33\n38 0 35 0 6 20 43 9 15 37 17 23 2 0 0 0 0 0 34 0 28 10 33 0 5 4 7 12 36 46 0 0 45\nycaqpk... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nGildong has an interesting machine that has an array $a$ with $n$ integers. The machine supports two kinds of operations:\n\nIncrease all elements of a suffix of the array by $1$.\n\nDecrease all elements of a suffix of t... | [{"type": "stdin_stdout", "input": "7\n2\n0 1\n3\n-1 0 2\n4\n110 133 106 95\n4\n-3 -5 -2 1\n6\n1 8 3 8 4 1\n5\n5 0 0 0 5\n9\n-367741579 319422997 -415264583 -125558838 -300860379 721691728 294512916 -383235489 425814447\n", "output": "0\n1\n15\n4\n14\n5\n3449059550\n"}, {"type": "stdin_stdout", "input": "7\n2\n0 1\n3\n... | code_stdio |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.