messages
listlengths
1
1
ground_truth
stringlengths
88
726k
dataset
stringclasses
1 value
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasya participates in a ski race along the X axis. The start is at point 0, and the finish is at L, that is, at a distance L meters from the start in the positive direction of the axis. Vasya has been training so hard tha...
[{"type": "stdin_stdout", "input": "15 30\n9 3 32 1\n0 16 38 2\n1 8 50 2\n16 14 21 2\n5 18 68 3\n25 2 49 1\n17 6 52 2\n17 3 94 1\n1 25 40 2\n27 1 49 2\n29 1 31 3\n19 3 30 1\n20 4 17 3\n18 9 66 2\n8 20 78 3\n", "output": "30\n0\n"}, {"type": "stdin_stdout", "input": "15 30\n9 3 32 1\n0 16 38 2\n1 8 50 2\n16 14 21 2\n5 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou have a robot that can move along a number line. At time moment 0 it stands at point 0.\n\nYou give n commands to the robot: at time t_i seconds you command the robot to go to point x_i. Whenever the robot receives a c...
[{"type": "stdin_stdout", "input": "8\n3\n1 5\n3 0\n6 4\n3\n1 5\n2 4\n10 -5\n5\n2 -5\n3 1\n4 1\n5 1\n6 1\n4\n3 3\n5 -3\n9 2\n12 0\n8\n1 1\n2 -6\n7 2\n8 3\n12 -9\n14 2\n18 -1\n23 9\n5\n1 -4\n4 -7\n6 -1\n7 -3\n8 -7\n2\n1 2\n2 -2\n6\n3 10\n5 5\n8 0\n12 -4\n14 -7\n19 -5\n", "output": "\n1\n2\n0\n2\n1\n1\n0\n2\n"}, {"type":...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\n«Next please», — the princess called and cast an estimating glance at the next groom.\n\nThe princess intends to choose the most worthy groom, this is, the richest one. Whenever she sees a groom who is more rich than each...
[{"type": "stdin_stdout", "input": "110 29 15\n", "output": "1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 32769 32770 32771 32772 32773 32774 32775 32776 32777 32778 32779 32780 32781 32782 32783 32784 32785 32786 32787 32788 32789 32790 32791 32792 32793 32794 32795 32796 32797 1 1 1 1 1 1 1 1 1 1 1 1 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an array a consisting of n (n ≥ 3) positive integers. It is known that in this array, all the numbers except one are the same (for example, in the array [4, 11, 4, 4] all numbers except one are equal to 4).\...
[{"type": "stdin_stdout", "input": "4\n4\n11 13 11 11\n5\n1 4 4 4 4\n10\n3 3 3 3 10 3 3 3 3 3\n3\n20 20 10\n", "output": "\n2\n1\n5\n3\n"}, {"type": "stdin_stdout", "input": "4\n4\n11 20 11 11\n5\n1 4 4 4 4\n10\n3 3 3 3 10 3 3 3 3 3\n3\n20 20 10\n", "output": "2\n1\n5\n3\n"}, {"type": "stdin_stdout", "input": "4\n4\n11...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou've got another geometrical task. You are given two non-degenerate polygons A and B as vertex coordinates. Polygon A is strictly convex. Polygon B is an arbitrary polygon without any self-intersections and self-touches...
[{"type": "stdin_stdout", "input": "3\n-1000000000 1000000000\n1000000000 0\n1000 -1000000000\n3\n1000 -999999999\n1000 0\n1001 0\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "6\n2 4\n4 2\n3 -1\n-1 -3\n-3 0\n-2 3\n12\n0 3\n0 2\n1 2\n2 3\n3 2\n1 1\n2 0\n0 -2\n0 0\n-1 -1\n-2 0\n-1 1\n", "output": "YES\n"}, {...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasya works as a DJ in the best Berland nightclub, and he often uses dubstep music in his performance. Recently, he has decided to take a couple of old songs and make dubstep remixes from them.\n\nLet's assume that a song...
[{"type": "stdin_stdout", "input": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA@AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n", "output": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nJohn Doe has an n × m table. John Doe can paint points in some table cells, not more than one point in one table cell. John Doe wants to use such operations to make each square subtable of size n × n have exactly k points...
[{"type": "stdin_stdout", "input": "100 1000000000000000000 5000\n", "output": "824224847\n"}, {"type": "stdin_stdout", "input": "100 1000000000000000000 1221\n", "output": "43180268\n"}, {"type": "stdin_stdout", "input": "79 1000000000000000000 3107\n", "output": "631080535\n"}, {"type": "stdin_stdout", "input": "100 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe Little Elephant has an integer a, written in the binary notation. He wants to write this number on a piece of paper.\n\nTo make sure that the number a fits on the piece of paper, the Little Elephant ought to delete ex...
[{"type": "stdin_stdout", "input": "11100010010010000110101101101100111111001010001101101001001111010110010111001011010000001100110101000101111000001111101111110010000010101110011110101101010110001100011101111011100010011101100111110010111111100110101000000111101000000000110100100101111101000110101010101101001110001110...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe 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...
[{"type": "stdin_stdout", "input": "1000000000000000000000000000000000000011111111000000000000\n0111111111100000000000111111111000000000000000111111110001\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "1000000000000000000000000000000000000011111111000000000000\n0011111111100000000000111111111000000000000000...
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 <image>. You are given two rational numbers, one is represented as <image> and the other one is represented as a finite fraction of height n. Check if they are equal....
[{"type": "stdin_stdout", "input": "550736960584023286 3\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 2 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": "633468529243155234 4...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nValera has got n domino pieces in a row. Each piece consists of two halves — the upper one and the lower one. Each of the halves contains a number from 1 to 6. Valera loves even integers very much, so he wants the sum of ...
[{"type": "stdin_stdout", "input": "100\n2 3\n2 4\n3 3\n1 4\n5 2\n5 4\n6 6\n3 4\n1 1\n4 2\n5 1\n5 5\n5 3\n3 6\n4 1\n1 6\n1 1\n3 2\n4 5\n6 1\n6 4\n1 1\n3 4\n3 3\n2 2\n1 1\n4 4\n6 4\n3 2\n5 2\n6 4\n3 2\n3 5\n4 4\n1 4\n5 2\n3 4\n1 4\n2 2\n5 6\n3 5\n6 1\n5 5\n1 6\n6 3\n1 4\n1 5\n5 5\n4 1\n3 2\n4 1\n5 5\n5 5\n1 5\n1 2\n6 4\...
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\nBizon the Champion isn't just attentive, he also is very hardworking.\n\nBizon the Champion decided to paint his old fence his favorite color, orange. The fence is represented as n vertical planks, put in a row. Adjacent ...
[{"type": "stdin_stdout", "input": "30\n1 4 5 3 9 7 8 4 5 9 2 3 4 2 3 4 5 5 6 8 1 2 9 4 3 7 2 6 5 4\n", "output": "26\n"}, {"type": "stdin_stdout", "input": "30\n1 4 5 3 9 7 8 4 5 1 2 3 4 2 3 4 5 5 6 8 1 2 9 4 3 7 2 6 5 4\n", "output": "25\n"}, {"type": "stdin_stdout", "input": "30\n1 4 5 3 9 7 8 3 5 1 2 3 4 2 3 4 5 5 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nNowadays it is becoming increasingly difficult to park a car in cities successfully. Let's imagine a segment of a street as long as L meters along which a parking lot is located. Drivers should park their cars strictly pa...
[{"type": "stdin_stdout", "input": "50 3 1\n30\n1 9\n2 1\n1 6\n1 5\n1 8\n1 1\n2 6\n1 7\n2 3\n2 8\n1 7\n2 4\n2 5\n2 11\n1 2\n2 15\n1 6\n1 3\n2 17\n1 9\n1 3\n2 18\n1 3\n2 23\n2 21\n1 8\n1 2\n2 27\n1 8\n2 29\n", "output": "0\n0\n9\n17\n28\n28\n0\n0\n0\n9\n15\n0\n6\n0\n11\n27\n"}, {"type": "stdin_stdout", "input": "50 3 2\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe country has n cities and n - 1 bidirectional roads, it is possible to get from every city to any other one if you move only along the roads. The cities are numbered with integers from 1 to n inclusive.\n\nAll the road...
[{"type": "stdin_stdout", "input": "150\n1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 14 15 15 15 16 16 16 17 17 17 18 18 18 19 19 19 20 20 20 21 21 9 22 22 22 23 23 23 24 24 24 25 25 25 26 26 26 27 27 27 28 28 28 28 29 29 29 29 30 30 30 30 31 31 31 3...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe country of Byalechinsk is running elections involving n candidates. The country consists of m cities. We know how many people in each city voted for each candidate.\n\nThe electoral system in the country is pretty unu...
[{"type": "stdin_stdout", "input": "100 1\n439 158 619 538 187 153 973 781 610 475 94 1829 449 531 220 51 788 118 189 501 54 434 465 902 280 635 688 214 737 327 682 690 683 519 261 923 254 388 529 659 662 276 376 735 976 664 521 285 42 147 187 259 407 977 879 465 522 17 550 701 114 921 577 265 668 812 232 267 135 371 4...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA team of furry rescue rangers was sitting idle in their hollow tree when suddenly they received a signal of distress. In a few moments they were ready, and the dirigible of the rescue chipmunks hit the road.\n\nWe assume...
[{"type": "stdin_stdout", "input": "-10000 -10000 10000 10000\n1000 1000\n-454 -891\n-454 -891\n", "output": "17933348.203209478"}, {"type": "stdin_stdout", "input": "-10000 10000 10000 -10000\n1001 1000\n-891 454\n-891 454\n", "output": "26861.169046541258\n"}, {"type": "stdin_stdout", "input": "-10000 -10000 10010 10...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLesha plays the recently published new version of the legendary game hacknet. In this version character skill mechanism was introduced. Now, each player character has exactly n skills. Each skill is represented by a non-n...
[{"type": "stdin_stdout", "input": "5 5 10 20 50\n0 0 0 0 0\n", "output": " 150\n 5 5 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMr. Santa asks all the great programmers of the world to solve a trivial problem. He gives them an integer m and asks for the number of positive integers n, such that the factorial of n ends with exactly m zeroes. Are you...
[{"type": "stdin_stdout", "input": "43857\n", "output": "5 \n 175440 175441 175442 175443 175444\n"}, {"type": "stdin_stdout", "input": "27438\n", "output": "5 \n 109760 109761 109762 109763 109764\n"}, {"type": "stdin_stdout", "input": "31693\n", "output": "5 \n 126785 126786 126787 126788 126789\n"}, {"type": "stdin_...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nStepan has a very big positive integer.\n\nLet's consider all cyclic shifts of Stepan's integer (if we look at his integer like at a string) which are also integers (i.e. they do not have leading zeros). Let's call such s...
[{"type": "stdin_stdout", "input": "8460711003592660299377170851036141857177105821455679225940496548902563144980707248030407967017317182\n6886527\n", "output": "136104\n"}, {"type": "stdin_stdout", "input": "8460711003592660299377170851036141857177105821455679225940496548902563144980707248030407967017317182\n13315371\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPolycarp is a great fan of television.\n\nHe wrote down all the TV programs he is interested in for today. His list contains n shows, i-th of them starts at moment li and ends at moment ri.\n\nPolycarp owns two TVs. He ca...
[{"type": "stdin_stdout", "input": "5\n15 18\n23 24\n23 28\n26 24\n15 19\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "5\n15 18\n23 24\n23 11\n26 24\n15 19\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "5\n15 18\n23 24\n23 28\n22 24\n15 19\n", "output": "NO\n"}, {"type": "stdin_stdout", "input"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPetya and Vasya arranged a game. The game runs by the following rules. Players have a directed graph consisting of n vertices and m edges. One of the vertices contains a chip. Initially the chip is located at vertex s. Pl...
[{"type": "stdin_stdout", "input": "92 69\n1 76\n1 14\n1 15\n0\n1 46\n1 80\n0\n0\n1 77\n0\n1 53\n1 81\n1 61\n1 40\n0\n1 20\n1 71\n1 24\n1 54\n1 82\n1 23\n0\n1 63\n1 25\n1 38\n1 68\n0\n1 65\n0\n1 76\n1 55\n1 87\n1 1\n1 37\n1 68\n1 30\n1 17\n1 19\n0\n1 16\n1 69\n0\n1 60\n1 86\n0\n1 44\n1 32\n1 10\n1 8\n0\n0\n0\n0\n0\n1 2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a set of n elements indexed from 1 to n. The weight of i-th element is wi. The weight of some subset of a given set is denoted as <image>. The weight of some partition R of a given set into k subsets is <ima...
[{"type": "stdin_stdout", "input": "6 2\n2578 6301 8624 6020 8513 9486\n", "output": "4401332\n"}, {"type": "stdin_stdout", "input": "6 3\n4759 5555 7401 8003 2501 6345\n", "output": "7431260\n"}, {"type": "stdin_stdout", "input": "6 2\n2578 6301 8624 6020 7152 9486\n", "output": "4257066\n"}, {"type": "stdin_stdout", ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasilisa the Wise from a far away kingdom got a present from her friend Helga the Wise from a farther away kingdom. The present is a surprise box, yet Vasilisa the Wise doesn't know yet what the surprise actually is becau...
[{"type": "stdin_stdout", "input": "ROYGBV\n", "output": "30\n"}, {"type": "stdin_stdout", "input": "BYOVRR\n", "output": "15\n"}, {"type": "stdin_stdout", "input": "OVBRYG\n", "output": "30\n"}, {"type": "stdin_stdout", "input": "RRYOGB\n", "output": "15\n"}, {"type": "stdin_stdout", "input": "VOBYGO\n", "output": "15...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVivek and Sita are in a relationship. Both of them love playing with numbers and treat each other with puzzles every now and then.\n\nWhen Sita visits her class she comes to see that there is a gift packed in a wooden bo...
[{"type": "stdin_stdout", "input": "13\n1\n7\n3\n2\n3\n4\n8\n4\n13\n14\n22\n6\n14", "output": "1024\n953349816\n466737221\n1024\n466737221\n466737221\n953349816\n466737221\n996023990\n996023990\n946217050\n904322927\n996023990\n"}, {"type": "stdin_stdout", "input": "13\n1\n7\n3\n2\n3\n4\n8\n4\n13\n14\n16\n6\n14", "outp...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nNew AtCoder City has an infinite grid of streets, as follows:\n\n* At the center of the city stands a clock tower. Let (0, 0) be the coordinates of this point.\n* A straight street, which we will call East-West Main Stree...
[{"type": "stdin_stdout", "input": "8\n2 2 286017\n3 1 262355\n2 -2 213815\n1 -3 224435\n-2 -2 136860\n-3 -1 239338\n-2 1 217647\n-1 3 141903", "output": "2359062 1359398 868031 503198 278763 136860 0 0 0 "}, {"type": "stdin_stdout", "input": "8\n2 2 456035\n3 1 262355\n2 -2 213815\n1 -3 224435\n-2 -2 136860\n-3 -1 239...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nConsider a grid with H rows and W columns of squares. Let (r, c) denote the square at the r-th row from the top and the c-th column from the left. Each square is painted black or white.\n\nThe grid is said to be good if a...
[{"type": "stdin_stdout", "input": "5 5\n.#.#.\n.#.#\n.#.#.\n.#.#\n.#.#.", "output": "4"}, {"type": "stdin_stdout", "input": "3 13\n..##\n...\n.\n.", "output": "0\n"}, {"type": "stdin_stdout", "input": "3 13\n..##\n/..\n.\n.", "output": "0\n"}, {"type": "stdin_stdout", "input": "3 13\n..##\n/..\n-\n.", "output": "0\n"}...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are N points in a two-dimensional plane. The initial coordinates of the i-th point are (x_i, y_i). Now, each point starts moving at a speed of 1 per second, in a direction parallel to the x- or y- axis. You are give...
[{"type": "stdin_stdout", "input": "20\n8 -10 R\n-4 -9 U\n9 6 D\n-3 -2 R\n0 12 D\n4 5 D\n10 -10 U\n-1 -8 U\n10 -6 D\n8 -5 U\n6 4 D\n-1 3 D\n19 9 R\n9 -4 R\n3 10 D\n1 9 U\n1 -6 U\n9 -8 R\n9 6 D\n7 -3 D", "output": "502.250000000000\n"}, {"type": "stdin_stdout", "input": "20\n8 -10 R\n-4 -9 U\n9 5 D\n-3 -2 R\n0 7 D\n4 5 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA programming competition site AtCode regularly holds programming contests.\n\nThe next contest on AtCode is called ABC, which is rated for contestants with ratings less than 1200.\n\nThe contest after the ABC is called A...
[{"type": "stdin_stdout", "input": "2343", "output": "ARC\n"}, {"type": "stdin_stdout", "input": "4178", "output": "AGC\n"}, {"type": "stdin_stdout", "input": "-118", "output": "ABC\n"}, {"type": "stdin_stdout", "input": "-129", "output": "ABC\n"}, {"type": "stdin_stdout", "input": "1199", "output": "ABC"}, {"type": "s...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a rooted tree with N vertices. The vertices are numbered 0, 1, ..., N-1. The root is Vertex 0, and the parent of Vertex i (i = 1, 2, ..., N-1) is Vertex p_i.\n\nInitially, an integer a_i is written in Vertex...
[{"type": "stdin_stdout", "input": "5\n0 1 2 2\n2 4 0 1 3", "output": "5\n3\n4\n2\n2\n3\n"}, {"type": "stdin_stdout", "input": "5\n0 1 0 1\n2 4 0 1 3", "output": "5\n2\n4\n1\n3\n1\n"}, {"type": "stdin_stdout", "input": "5\n0 1 0 2\n2 4 0 1 3", "output": "5\n4\n4\n1\n3\n1\n"}, {"type": "stdin_stdout", "input": "5\n0 0 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet us consider the following operations on a string consisting of `A` and `B`:\n\n1. Select a character in a string. If it is `A`, replace it with `BB`. If it is `B`, replace with `AA`.\n2. Select a substring that is equ...
[{"type": "stdin_stdout", "input": "AAAAABBBBAAABBBBAAAA\nBBBBAAABBBBBBAAAAABB\n10\n2 15 2 13\n2 13 6 16\n1 13 2 20\n4 20 3 20\n1 18 9 19\n2 14 1 11\n3 20 3 15\n6 16 1 19\n4 18 8 20\n7 20 3 14", "output": "YES\nYES\nYES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\n"}, {"type": "stdin_stdout", "input": "AAAAABBBBAAABBBBAAAA\nBBBBAAA...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAs shown in the following figure, there is a paper consisting of a grid structure where each cell is indicated by (x, y) coordinate system.\n\nWe are going to put drops of ink on the paper. A drop comes in three different...
[{"type": "stdin_stdout", "input": "2,5,3\n3,6,1\n3,4,2\n4,5,2\n3,6,3\n1,4,1", "output": "75\n5\n"}, {"type": "stdin_stdout", "input": "2,5,3\n1,6,3\n3,4,2\n4,5,2\n3,6,3\n2,4,1", "output": "73\n5\n"}, {"type": "stdin_stdout", "input": "2,5,3\n3,6,1\n2,4,2\n4,5,2\n3,6,3\n1,4,1", "output": "76\n5\n"}, {"type": "stdin_std...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\n<image>\n\nMatryoshka is a wooden doll in the shape of a female figure and is a typical Russian folk craft. Matryoshka has a nested structure in which smaller dolls are contained inside a large doll, and is composed of mu...
[{"type": "stdin_stdout", "input": "6\n1 1\n1 3\n6 0\n8 6\n10 10\n14 14\n5\n2 2\n5 4\n6 6\n9 8\n15 10\n4\n1 1\n4 3\n1 5\n12 10\n3\n2 2\n7 4\n9 6\n4\n1 2\n4 3\n6 5\n14 0\n4\n10 10\n12 11\n18 15\n24 20\n0", "output": "7\n6\n7\n"}, {"type": "stdin_stdout", "input": "6\n1 1\n4 3\n6 0\n8 6\n20 10\n14 14\n5\n2 4\n5 4\n6 6\n9...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA programming contest will be held at White Tiger University this year as well. There are several questions in the contest, each of which is assigned a score according to the difficulty level.\n\nThe executive committee d...
[{"type": "stdin_stdout", "input": "7\n-1 -1 19 1 0 4 -2", "output": "2\n"}, {"type": "stdin_stdout", "input": "7\n-1 -1 19 2 0 4 -2", "output": "2\n"}, {"type": "stdin_stdout", "input": "7\n-1 1 19 2 2 4 -1", "output": "2\n"}, {"type": "stdin_stdout", "input": "7\n-1 1 19 2 3 4 -1", "output": "3\n"}, {"type": "stdin_s...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere is a long-established secondhand bookstore called JOI secondhand bookstore in your town, and you often use the JOI secondhand bookstore. Each book has a standard price, and you can buy it at that price if you go to ...
[{"type": "stdin_stdout", "input": "7 7\n4 1\n13 2\n18 3\n64 3\n13 2\n16 10\n11 2", "output": "147\n"}, {"type": "stdin_stdout", "input": "7 7\n4 1\n13 2\n12 3\n48 3\n8 2\n16 10\n11 2", "output": "120\n"}, {"type": "stdin_stdout", "input": "7 5\n4 1\n13 3\n12 3\n48 3\n8 3\n16 10\n11 2", "output": "109\n"}, {"type": "st...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are n wizards. They are numbered from 1 to n, and the i-th wizard has the magical power ri (1 ≤ i ≤ n). Now they are confronting a powerful wizard, whose enemy's magical power is S. n Wizards are good at fighting to...
[{"type": "stdin_stdout", "input": "3 11\n0\n3\n10\n0 0", "output": "1\n"}, {"type": "stdin_stdout", "input": "3 11\n0\n3\n18\n0 0", "output": "2\n"}, {"type": "stdin_stdout", "input": "3 11\n0\n3\n20\n0 0", "output": "2\n"}, {"type": "stdin_stdout", "input": "3 13\n1\n3\n10\n0 0", "output": "0\n"}, {"type": "stdin_std...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nExample\n\nInput\n\n201\n\n\nOutput\n\n701\n\nThe input will be given via stdin and the output should be printed to stdout by your code.\n\nNow solve the problem by providing the code.\n\nWrite Python code to solve this p...
[{"type": "stdin_stdout", "input": "148", "output": "648\n"}, {"type": "stdin_stdout", "input": "106", "output": "605\n"}, {"type": "stdin_stdout", "input": "145", "output": "645\n"}, {"type": "stdin_stdout", "input": "225", "output": "725\n"}, {"type": "stdin_stdout", "input": "171", "output": "671\n"}, {"type": "stdi...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou want to make change for $ n $ cents. Assuming that you have infinite supply of coins of 1, 5, 10 and / or 25 cents coins respectively, find the minimum number of coins you need.\n\nConstraints\n\n* $ 1 \\ le n \\ le 1...
[{"type": "stdin_stdout", "input": "251195", "output": "10049\n"}, {"type": "stdin_stdout", "input": "467454", "output": "18702\n"}, {"type": "stdin_stdout", "input": "698278", "output": "27934\n"}, {"type": "stdin_stdout", "input": "323456", "output": "12940\n"}, {"type": "stdin_stdout", "input": "164898", "output": "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLeha is playing a very interesting game. The game will be played on a rectangular grid consisting of N rows and M columns. Initially all the cells of the grid are uncolored. \nLeha's initial score is zero. At each turn, h...
[{"type": "stdin_stdout", "input": "1\n16 -10", "output": "-326\n"}, {"type": "stdin_stdout", "input": "1\n32 -10", "output": "-662\n"}, {"type": "stdin_stdout", "input": "1\n23 -10", "output": "-473\n"}, {"type": "stdin_stdout", "input": "1\n23 -20", "output": "-923\n"}, {"type": "stdin_stdout", "input": "1\n17 -20", ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given n segments on a number line; each endpoint of every segment has integer coordinates. Some segments can degenerate to points. Segments can intersect with each other, be nested in each other or even coincide.\...
[{"type": "stdin_stdout", "input": "6\n2 4\n3 6\n2 6\n2 5\n1 4\n1 4\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "6\n2 4\n3 5\n2 5\n1 6\n2 4\n3 6\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "6\n1 5\n1 4\n1 6\n2 5\n2 6\n2 6\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "6\n6 6\n3 4\n3 5\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe average miner Vaganych took refresher courses. As soon as a miner completes the courses, he should take exams. The hardest one is a computer test called \"Testing Pants for Sadness\".\n\nThe test consists of n questio...
[{"type": "stdin_stdout", "input": "50\n515844718 503470143 928669067 209884122 322869098 241621928 844696197 105586164 552680307 968792756 135928721 842094825 298782438 829020472 791637138 285482545 811025527 428952878 887796419 11883658 546401594 6272027 100292274 308219869 372132044 955814846 644008184 521195760 919...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an array a of length n that consists of zeros and ones.\n\nYou can perform the following operation multiple times. The operation consists of two steps: \n\n 1. Choose three integers 1 ≤ x < y < z ≤ n, that ...
[{"type": "stdin_stdout", "input": "125\n1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0\n", "output": "YES\n23\n120 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given two n × m matrices containing integers. A sequence of integers is strictly increasing if each next number is greater than the previous one. A row is strictly increasing if all numbers from left to right are ...
[{"type": "stdin_stdout", "input": "20 1\n66723051\n192052119\n224590623\n285234278\n167627491\n337383819\n374082795\n457862809\n434684264\n480651568\n509016946\n108218500\n577998249\n647547233\n737914492\n753247062\n687137696\n799938346\n957366563\n986223900\n47472129\n101178650\n145468869\n145519928\n311820460\n20856...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPolycarp knows that if the sum of the digits of a number is divisible by 3, then the number itself is divisible by 3. He assumes that the numbers, the sum of the digits of which is divisible by 4, are also somewhat intere...
[{"type": "stdin_stdout", "input": "1000\n", "output": "1003\n"}, {"type": "stdin_stdout", "input": "997\n", "output": "1003\n"}, {"type": "stdin_stdout", "input": "999\n", "output": "1003\n"}, {"type": "stdin_stdout", "input": "432\n", "output": "435\n"}, {"type": "stdin_stdout", "input": "237\n", "output": "237\n"}, ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGildong is playing a video game called Block Adventure. In Block Adventure, there are n columns of blocks in a row, and the columns are numbered from 1 to n. All blocks have equal heights. The height of the i-th column is...
[{"type": "stdin_stdout", "input": "1\n30 0 0\n-1 1 0 -1 1 0 0 0 0 0 0 -1 2 1 -1 -1 0 -1 0 0 0 1 1 -2 2 0 -1 2 0 -1 -2 -1 0 1 0 0 1 1 -1 1 0 0 1 1 0 0 1 0 0 0 0 1 0 -1 2 0 1 1 1 0 0 1 -1 0 1 -1 1 -1 -2 -1 0 0 0 0 -1 0 2 0 0 0 -1 -2 0 1 1 -1 1 1 0 1 -1 -1 -1 -4 -2 0 0\n", "output": "NO\n"}, {"type": "stdin_stdout", "inp...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThis is the easier version of the problem. In this version 1 ≤ n, m ≤ 100. You can hack this problem only if you solve and lock both problems.\n\nYou are given a sequence of integers a=[a_1,a_2,...,a_n] of length n. Its s...
[{"type": "stdin_stdout", "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"}, {"type": "stdin_stdout", "input": "5\n3 1 4 2 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...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThis is a hard version of the problem. In this version, the given array can contain equal elements and the constraints on n are greater than in the easy version of the problem.\n\nYou are given an array a of n integers (t...
[{"type": "stdin_stdout", "input": "9\n5\n4 7 2 2 10\n5\n5 0 2 1 11\n5\n1 2 2 4 0\n2\n0 1\n3\n0 1 0\n4\n0 2 0 0\n4\n0 1 0 1\n4\n0 1 0 2\n20\n16 15 1 10 0 14 0 10 3 16 0 5 4 5 17 13 14 14 1 9\n", "output": "2\n3\n1\n0\n1\n1\n1\n1\n15\n"}, {"type": "stdin_stdout", "input": "9\n5\n4 7 2 2 10\n5\n5 0 2 1 7\n5\n1 2 2 4 0\n2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an array a_1, a_2, ..., a_n, consisting of n positive integers. \n\nInitially you are standing at index 1 and have a score equal to a_1. You can perform two kinds of moves: \n\n 1. move right — go from your...
[{"type": "stdin_stdout", "input": "4\n5 4 0\n1 5 4 3 2\n5 4 1\n1 5 7 3 2\n5 4 4\n10 20 30 40 78\n10 7 3\n4 6 12 2 9 12 14 4 10 9\n", "output": "15\n25\n178\n71\n"}, {"type": "stdin_stdout", "input": "4\n5 4 0\n1 5 4 3 2\n5 4 1\n1 5 7 3 2\n5 4 4\n10 20 30 40 50\n10 7 3\n4 6 8 2 9 12 14 4 10 9\n", "output": "15\n25\n150...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are n points on a plane. The i-th point has coordinates (x_i, y_i). You have two horizontal platforms, both of length k. Each platform can be placed anywhere on a plane but it should be placed horizontally (on the s...
[{"type": "stdin_stdout", "input": "4\n7 1\n1 5 0 2 1 10 7\n1 3 6 7 2 5 4\n1 1\n1000000000\n1000001000\n5 10\n10 7 5 15 12\n38 199 192 219 1904\n10 10\n12 19 8 29 20 10 9 2 10 19\n12 4 0 17 1 15 7 18 14 3\n", "output": "4\n1\n5\n10\n"}, {"type": "stdin_stdout", "input": "4\n7 1\n1 5 0 2 1 10 7\n1 3 6 7 0 5 4\n1 1\n1000...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nNumbers 1, 2, 3, ... n (each integer from 1 to n once) are written on a board. In one operation you can erase any two numbers a and b from the board and write one integer (a + b)/(2) rounded up instead.\n\nYou should perf...
[{"type": "stdin_stdout", "input": "1\n275\n", "output": "2\n275 274\n275 273\n274 272\n273 271\n272 270\n271 269\n270 268\n269 267\n268 266\n267 265\n266 264\n265 263\n264 262\n263 261\n262 260\n261 259\n260 258\n259 257\n258 256\n257 255\n256 254\n255 253\n254 252\n253 251\n252 250\n251 249\n250 248\n249 247\n248 246...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGildong is playing with his dog, Badugi. They're at a park that has n intersections and n-1 bidirectional roads, each 1 meter in length and connecting two intersections with each other. The intersections are numbered from...
[{"type": "stdin_stdout", "input": "3\n3\n1 2\n1 3\n4\n1 2\n2 3\n3 4\n8\n1 2\n2 3\n3 4\n1 5\n5 6\n6 7\n5 8\n", "output": "\n2\n3\n3\n"}, {"type": "stdin_stdout", "input": "3\n3\n1 2\n2 3\n4\n1 2\n2 3\n3 4\n5\n1 2\n2 3\n3 4\n4 5\n3 6\n6 7\n5 13\n", "output": "2\n3\n4\n"}, {"type": "stdin_stdout", "input": "3\n3\n1 2\n2 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA palindrome is a string that reads the same backward as forward. For example, the strings \"z\", \"aaa\", \"aba\", and \"abccba\" are palindromes, but \"codeforces\" and \"ab\" are not. You hate palindromes because they ...
[{"type": "stdin_stdout", "input": "6\ncbabc\nab\nzza\nba\na\nnutforajaroftuna\n", "output": "\nYES\ncbabac\nYES\naab\nYES\nzaza\nYES\nbaa\nNO\nYES\nnutforajarofatuna\n"}, {"type": "stdin_stdout", "input": "6\ncbabc\nab\nzza\nba\na\nnutforajaroftuna\n", "output": "YES\ncbabca\nYES\naab\nYES\nzzaa\nYES\nbaa\nNO\nYES\nnu...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA widely known among some people Belarusian sport programmer Yura possesses lots of information about cars. That is why he has been invited to participate in a game show called \"Guess That Car!\".\n\nThe game show takes ...
[{"type": "stdin_stdout", "input": "10 10\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 1585 1564 3603 1095 1364 1029 3189 1331\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 1749\n0 3495 1540 641 1093 702 2249 983 1218 2108\n0 1397 1105 3119 1194 839 1286 2979 2941 1911\n0 1818 2264...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAn expedition group flew from planet ACM-1 to Earth in order to study the bipedal species (its representatives don't even have antennas on their heads!).\n\nThe flying saucer, on which the brave pioneers set off, consists...
[{"type": "stdin_stdout", "input": "1050034174 1181487066\n", "output": "544888754\n"}, {"type": "stdin_stdout", "input": "880162386 1131317357\n", "output": "508228391\n"}, {"type": "stdin_stdout", "input": "1511923181 994962872\n", "output": "797030938\n"}, {"type": "stdin_stdout", "input": "596386879 1071021379\n", ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou received as a gift a very clever robot walking on a rectangular board. Unfortunately, you understood that it is broken and behaves rather strangely (randomly). The board consists of N rows and M columns of cells. The ...
[{"type": "stdin_stdout", "input": "1000 1000\n162 276\n", "output": "3351.9999999997744\n"}, {"type": "stdin_stdout", "input": "1000 1000\n153 276\n", "output": "3387.9999999997344\n"}, {"type": "stdin_stdout", "input": "1000 1000\n162 234\n", "output": "3351.999999903682\n"}, {"type": "stdin_stdout", "input": "663 90...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe polar bears are going fishing. They plan to sail from (sx, sy) to (ex, ey). However, the boat can only sail by wind. At each second, the wind blows in one of these directions: east, south, west or north. Assume the bo...
[{"type": "stdin_stdout", "input": "39 -1000000000 -1000000000 -999999997 -1000000000\nENEENWSWSSWESNSSEESNSESWSWNSWESNENWNWEE\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "51 -1000000000 -1000000000 -999999997 -1000000000\nENEENWSWSSWESNSSEESNSESWSWNSWESNENWNWEE\n", "output": "4\n"}, {"type": "stdin_stdout"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nValera loves to participate in competitions. Especially in programming contests. Today he has participated in the contest with his team, consisting of n students (including Valera). This contest was an individual competit...
[{"type": "stdin_stdout", "input": "1000 1000 1 1000 1000000 1000000\n", "output": "1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe R2 company has n employees working for it. The work involves constant exchange of ideas, sharing the stories of success and upcoming challenging. For that, R2 uses a famous instant messaging program Spyke.\n\nR2 has m...
[{"type": "stdin_stdout", "input": "7 6 5\n0 1 0 1 1 1\n0 1 1 0 1 1\n1 0 1 1 1 0\n1 0 1 1 1 1\n1 1 1 1 1 0\n1 1 1 0 1 0\n1 0 1 0 0 0\n4 1\n2 6\n7 3\n7 1\n5 3\n", "output": "1 2 4 4 3 4 2 \n"}, {"type": "stdin_stdout", "input": "7 6 5\n0 1 0 1 1 1\n0 1 1 0 1 1\n1 0 1 1 1 0\n1 0 0 1 1 1\n1 1 1 1 1 0\n1 1 1 0 1 0\n1 0 1 0...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe territory of Berland is represented by a rectangular field n × m in size. The king of Berland lives in the capital, located on the upper left square (1, 1). The lower right square has coordinates (n, m). One day the k...
[{"type": "stdin_stdout", "input": "101 100\n", "output": "0\n1 1\n2 1\n3 1\n4 1\n5 1\n6 1\n7 1\n8 1\n9 1\n10 1\n11 1\n12 1\n13 1\n14 1\n15 1\n16 1\n17 1\n18 1\n19 1\n20 1\n21 1\n22 1\n23 1\n24 1\n25 1\n26 1\n27 1\n28 1\n29 1\n30 1\n31 1\n32 1\n33 1\n34 1\n35 1\n36 1\n37 1\n38 1\n39 1\n40 1\n41 1\n42 1\n43 1\n44 1\n45 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nToastman came up with a very easy task. He gives it to Appleman, but Appleman doesn't know how to solve it. Can you help him?\n\nGiven a n × n checkerboard. Each cell of the board has either character 'x', or character 'o...
[{"type": "stdin_stdout", "input": "19\noxoxoxoxooxoooxxoox\nxxxxxxxxoxxoxoooooo\noxoxoxooxxxooxxxooo\nxxoxxxooxooxxxoxxox\noxoxooxxxooooxxoxox\nxxxoooxoxxoxxoxxxoo\noxooxxxoooooxxoooxo\nxxooxooxoxxoxxoxxoo\noxxxxooooxxxooooxxx\nooxooxoxxoxxoxooxoo\nxxxooooxxxooooxoxox\noooxoxooxxoxooxooxx\nxxoooxxxooooxxoooxo\nooxxxoo...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWhen Sasha was studying in the seventh grade, he started listening to music a lot. In order to evaluate which songs he likes more, he introduced the notion of the song's prettiness. The title of the song is a word consist...
[{"type": "stdin_stdout", "input": "ZUBQNDCHHKWNWRVSDSRRRTGZDDPNTVJFKTCNGWND\n", "output": "7.53208608\n"}, {"type": "stdin_stdout", "input": "DNWGNBTKNJVTNPDDZGTRRRSDSVRDFWKHHBWNQBUY\n", "output": "11.8106291\n"}, {"type": "stdin_stdout", "input": "DNWGNBTKNJVTNQDDZGTRRRSDSVRDFWKHHBWNQBUY\n", "output": "11.8106291\n"}...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGerald got a very curious hexagon for his birthday. The boy found out that all the angles of the hexagon are equal to <image>. Then he measured the length of its sides, and found that each of them is equal to an integer n...
[{"type": "stdin_stdout", "input": "1000 1000 1000 1000 1000 1000\n", "output": "6000000\n"}, {"type": "stdin_stdout", "input": "718 466 729 470 714 481\n", "output": "2102808\n"}, {"type": "stdin_stdout", "input": "888 888 888 887 889 887\n", "output": "4729487\n"}, {"type": "stdin_stdout", "input": "677 303 685 288 6...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nStudent Vladislav came to his programming exam completely unprepared as usual. He got a question about some strange algorithm on a graph — something that will definitely never be useful in real life. He asked a girl sitti...
[{"type": "stdin_stdout", "input": "10 15\n900000007 1\n900000002 1\n900000004 0\n900000002 1\n900000006 1\n900000000 1\n900000006 1\n900000008 1\n900000002 0\n1419868175 0\n900000002 0\n900000005 0\n900000001 0\n900000000 1\n900000008 1\n", "output": "1 8\n1 4\n2 5\n1 5\n1 6\n1 2\n1 7\n1 9\n2 4\n4 5\n3 4\n3 5\n2 3\n1 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nConsider the decimal presentation of an integer. Let's call a number d-magic if digit d appears in decimal presentation of the number on even positions and nowhere else.\n\nFor example, the numbers 1727374, 17, 1 are 7-ma...
[{"type": "stdin_stdout", "input": "1286 4\n1886373541983002858974907276497223649072414883083336663541044958378875954171855070620868427474284001\n4050983123791059817478363830631049287126338893626273758612677264947268375965600848751800494833017145\n", "output": "820371303\n"}, {"type": "stdin_stdout", "input": "516 4\n1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA tree is an undirected connected graph without cycles. The distance between two vertices is the number of edges in a simple path between them.\n\nLimak is a little polar bear. He lives in a tree that consists of n vertic...
[{"type": "stdin_stdout", "input": "15 1\n12 9\n13 7\n1 3\n10 4\n9 2\n2 15\n11 2\n2 14\n10 8\n6 12\n12 5\n8 7\n3 10\n10 2\n", "output": "336\n"}, {"type": "stdin_stdout", "input": "15 1\n12 9\n13 7\n1 3\n10 4\n9 2\n2 15\n11 4\n2 14\n10 8\n6 7\n12 5\n8 7\n3 10\n10 2\n", "output": "346\n"}, {"type": "stdin_stdout", "inpu...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSagheer is walking in the street when he comes to an intersection of two roads. Each road can be represented as two parts where each part has 3 lanes getting into the intersection (one for each direction) and 3 lanes gett...
[{"type": "stdin_stdout", "input": "1 0 0 1\n0 0 0 0\n0 0 -1 0\n0 -1 0 0\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "0 1 0 0\n0 0 0 -1\n0 0 0 1\n0 0 0 0\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "1 1 0 1\n0 -1 0 0\n0 0 0 0\n0 0 0 0\n", "output": "YES\n"}, {"type": "stdin_stdout", "input":...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are times you recall a good old friend and everything you've come through together. Luckily there are social networks — they store all your message history making it easy to know what you argued over 10 years ago.\n...
[{"type": "stdin_stdout", "input": "100 7\n0 1 1 1 0 5 6 6 8 8 9 11 12 11 8 0 0 14 6 16 7 21 15 23 15 24 0 0 0 28 0 29 26 27 19 1 0 21 37 32 40 30 37 34 39 38 34 38 0 0 41 24 45 47 0 33 46 26 31 0 21 57 57 18 63 63 20 59 65 56 68 0 30 55 55 0 70 43 59 49 59 79 66 74 0 11 65 0 80 63 0 84 73 49 73 81 0 86 76 20\n", "outp...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFor long time scientists study the behavior of sharks. Sharks, as many other species, alternate short movements in a certain location and long movements between locations.\n\nMax is a young biologist. For n days he watche...
[{"type": "stdin_stdout", "input": "127\n64 96 63 112 62 95 61 120 60 94 59 111 58 93 57 124 56 92 55 110 54 91 53 119 52 90 51 109 50 89 49 126 48 88 47 108 46 87 45 118 44 86 43 107 42 85 41 123 40 84 39 106 38 83 37 117 36 82 35 105 34 81 33 127 32 80 31 104 30 79 29 116 28 78 27 103 26 77 25 122 24 76 23 102 22 75 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou have an n by m grid. Each grid square has a certain value associated with it. This is given by the numbers vi,j.\n\nYou can capture grid squares in two different ways.\nYou can directly capture a grid square. This cos...
[{"type": "stdin_stdout", "input": "7 6\n69643 55071 5858 44695 62932 3239\n7289 67064 13616 56175 35174 13049\n90224 32314 88004 72464 30985 93260\n85104 29513 58719 49870 40702 91003\n23897 37609 51811 98033 32514 16572\n37067 55914 52235 67308 64574 59347\n80215 47399 10799 60300 99056 45747\n24554 43574 21601 81404...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nQuan_Lank loves awsome numbers. Awsome numbers are the positive integers whose decimal representations contain only the awsome digits 4 and 7. For example, numbers 7, 74, 4 are awsome and 5, 137, 4467 are not. Unfortunate...
[{"type": "stdin_stdout", "input": "34\n40047\n7747774\n1000000000000000000\n7\n4\n474404774\n4744000695826\n10000000004744744\n446486416781684178\n999999999\n7777\n87414417444\n111222333444555667\n1\n4700\n3794555488744477\n444444444444444444\n474447447774444774\n777777777777777\n34777745021000000\n963\n85547444885478...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are enthusiastically participating in Virtual Boot Camp-14 and want to seriously learn programming. To be a good programmer you not only need to solve a problem, but also need to solve it as quickly as possible. \n\nY...
[{"type": "stdin_stdout", "input": "-1 -13 1 101101000\n\nS@FPLO", "output": "2022016341\n"}, {"type": "stdin_stdout", "input": "9 -1 -1 100000000\n\nNLPEAS", "output": "2000011459\n"}, {"type": "stdin_stdout", "input": "11 -1 0 100001000\n\nNLPEAS", "output": "2000034340\n"}, {"type": "stdin_stdout", "input": "11 -1 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a grid of N rows and M columns. The square at the i-th row and j-th column will be denoted as (i,j). Some of the squares contain an object. All the remaining squares are empty. The state of the grid is repre...
[{"type": "stdin_stdout", "input": "7 0\n$/.\n.#-\n.//", "output": "0\n$/.\n.#-\n.//\n\n\n\n\n"}, {"type": "stdin_stdout", "input": "7 0\n$/.\n-#.\n.//", "output": "0\n$/.\n-#.\n.//\n\n\n\n\n"}, {"type": "stdin_stdout", "input": "7 0\n$//\n-#.\n.//", "output": "0\n$//\n-#.\n.//\n\n\n\n\n"}, {"type": "stdin_stdout", "in...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere is a game that involves three variables, denoted A, B, and C.\n\nAs the game progresses, there will be N events where you are asked to make a choice. Each of these choices is represented by a string s_i. If s_i is `...
[{"type": "stdin_stdout", "input": "8 14 18 1\nAC\nBC\nAB\nBC\nAC\nBC\nAB\nAB", "output": "Yes\nC\nC\nA\nC\nC\nC\nA\nB\n"}, {"type": "stdin_stdout", "input": "8 15 10 1\nAC\nBC\nAB\nBC\nAC\nBC\nAB\nAB", "output": "Yes\nC\nC\nB\nC\nC\nC\nB\nB\n"}, {"type": "stdin_stdout", "input": "8 14 18 1\nAC\nBC\nAB\nBC\nBC\nBC\nAB\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTakahashi has come to a party as a special guest. There are N ordinary guests at the party. The i-th ordinary guest has a power of A_i.\n\nTakahashi has decided to perform M handshakes to increase the happiness of the par...
[{"type": "stdin_stdout", "input": "9 73\n67597 102019 5828 66249 138664 64141 11513 192153 16076", "output": "11787970\n"}, {"type": "stdin_stdout", "input": "9 73\n67597 52981 5828 66249 138664 64141 11513 192153 16076", "output": "10905286\n"}, {"type": "stdin_stdout", "input": "9 73\n67597 52981 5828 66249 138664 6...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWe have two distinct integers A and B.\n\nPrint the integer K such that |A - K| = |B - K|.\n\nIf such an integer does not exist, print `IMPOSSIBLE` instead.\n\nConstraints\n\n* All values in input are integers.\n* 0 \\leq...
[{"type": "stdin_stdout", "input": "2563528379 13118121", "output": "1288323250\n"}, {"type": "stdin_stdout", "input": "899758294 99824435", "output": "IMPOSSIBLE\n"}, {"type": "stdin_stdout", "input": "1349313191 99824435", "output": "724568813\n"}, {"type": "stdin_stdout", "input": "2563528379 6197513", "output": "12...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWhen Mr. X is away from home, he has decided to use his smartwatch to search the best route to go back home, to participate in ABC.\n\nYou, the smartwatch, has found N routes to his home.\n\nIf Mr. X uses the i-th of thes...
[{"type": "stdin_stdout", "input": "5 9\n25 8\n5 9\n4 10\n0000 1000\n6 1", "output": "5\n"}, {"type": "stdin_stdout", "input": "4 -1\n-1 0101\n-1 6\n1 1010\n-1 -2", "output": "-1\n"}, {"type": "stdin_stdout", "input": "5 9\n25 8\n5 9\n4 10\n0100 1000\n6 1", "output": "5\n"}, {"type": "stdin_stdout", "input": "-2 -4\n0 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a grid with 2 rows and 3 columns of squares. The color of the square at the i-th row and j-th column is represented by the character C_{ij}.\n\nWrite a program that prints `YES` if this grid remains the same...
[{"type": "stdin_stdout", "input": "spp\npps", "output": "YES\n"}, {"type": "stdin_stdout", "input": "pot\ntop", "output": "YES"}, {"type": "stdin_stdout", "input": "tbb\nbet", "output": "NO\n"}, {"type": "stdin_stdout", "input": "eye\nele", "output": "NO\n"}, {"type": "stdin_stdout", "input": "pos\ntop", "output": "NO...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nKenus, the organizer of International Euclidean Olympiad, is seeking a pair of two integers that requires many steps to find its greatest common divisor using the Euclidean algorithm.\n\nYou are given Q queries. The i-th ...
[{"type": "stdin_stdout", "input": "10\n1 1\n2 2\n6 1100000000000000000\n9 3\n1 185979974422876752\n23847657 23458792534\n111111101 001111111\n5 14\n4 19\n9 10", "output": "1 1 1 4 4 460000013 3 2 1 121016941 35 37447 29 132 4 2 3 9 4 2 "}, {"type": "stdin_stdout", "input": "10\n1 1\n2 2\n6 1100000000000000000\n9 3\n1 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOn the xy-plane, Snuke is going to travel from the point (x_s, y_s) to the point (x_t, y_t). He can move in arbitrary directions with speed 1. Here, we will consider him as a point without size.\n\nThere are N circular ba...
[{"type": "stdin_stdout", "input": "12 -2 -11 0\n1\n-1 -14 2\n4 -1 -2\n-2 9 1", "output": "23.0867927612\n"}, {"type": "stdin_stdout", "input": "24 -2 -11 -1\n1\n-1 -7 2\n4 -1 -2\n-2 9 1", "output": "33.1570013577\n"}, {"type": "stdin_stdout", "input": "12 -2 -11 0\n1\n-1 -7 2\n4 -1 -2\n-2 9 1", "output": "22.134943892...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSig has built his own keyboard. Designed for ultimate simplicity, this keyboard only has 3 keys on it: the `0` key, the `1` key and the backspace key.\n\nTo begin with, he is using a plain text editor with this keyboard. ...
[{"type": "stdin_stdout", "input": "B010", "output": "010\n"}, {"type": "stdin_stdout", "input": "B110", "output": "110\n"}, {"type": "stdin_stdout", "input": "B011", "output": "011\n"}, {"type": "stdin_stdout", "input": "B101", "output": "101\n"}, {"type": "stdin_stdout", "input": "B111", "output": "111\n"}, {"type": ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere is a rectangular maze with square squares lined up vertically and horizontally. In this maze, while moving to the adjacent squares in the north, south, east and west, the starting square S departs and the goal squar...
[{"type": "stdin_stdout", "input": "5 5\n.X.S.\n.X#..\n.XX##\n.#XG.\n..X..\n7 3\nSXX.XXG\nX.#.#X.\nXXX.XX#\n4 4\nS...\nX.X.\nGX..\n...X\n10 10\n..XXXXX.XX\n.X.#.#X.XX\nSX.#X.X..X\n#X.##.X.XX\n..XXXX#.XX\n##.##.##XX\n....X.YX#X\n.##X..#X#X\n....XX#..X\n...#XXG..X\n0 0", "output": "11\n10\n10\n33\n"}, {"type": "stdin_std...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nI have a plan to go on a school trip at a school. I conducted a questionnaire survey for that purpose. Students have student numbers from 1 to n, and the locations of travel candidates are represented by numbers from 1 to...
[{"type": "stdin_stdout", "input": "4 6\n0 0 1 0 1 1\n2 2 0 1 0 0\n1 1 2 0 2 1\n1 0 1 -1 1 0\n4 6\n1 0 1 0 1 1\n0 1 -1 2 -1 0\n1 1 1 0 -1 0\n1 0 1 0 1 0\n0 0", "output": "1 3 5 2 6 4\n1 2 3 4 6 5\n"}, {"type": "stdin_stdout", "input": "4 6\n1 0 1 0 1 1\n2 2 0 1 0 0\n1 1 2 0 2 1\n1 0 1 -1 0 0\n4 6\n1 0 1 0 1 1\n0 1 -1 2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nICPC Ranking\n\nYour mission in this problem is to write a program which, given the submission log of an ICPC (International Collegiate Programming Contest), determines team rankings.\n\nThe log is a sequence of records o...
[{"type": "stdin_stdout", "input": "300 19 8 5\n50 5 2 1\n70 5 2 0\n75 1 1 0\n100 3 1 0\n150 2 2 0\n240 5 5 7\n50 1 1 0\n60 2 2 0\n41 2 3 0\n90 1 3 0\n120 3 5 0\n196 4 1 0\n150 2 4 1\n180 3 5 4\n15 2 2 1\n20 2 2 1\n25 2 2 0\n60 1 1 0\n120 5 5 4\n15 5 4 1\n20 5 4 0\n40 1 1 0\n40 2 2 0\n120 2 3 4\n30 1 1 0\n40 2 1 0\n13 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRecent improvements in information and communication technology have made it possible to provide municipal service to a wider area more quickly and with less costs. Stimulated by this, and probably for saving their not su...
[{"type": "stdin_stdout", "input": "3\nFUKUOKA\nOKAYAMA\nIGCUGAMAY\n3\nFUKUOKA\nFUYUKAMA\nOKAYAMA\n2\nBBCDE\nDDCDA\n4\nG@\nDEFG\nDDDE\nABCD\n2\nABCDE\nC\n14\nAAAAA\nBBBBB\nCCCCB\nDDDDD\nEEEED\nFFFFF\nGGGGG\nHHGHH\nIIIHI\nJJJJJ\nKKLKK\nLLLLL\nMMMMM\nNNNNN\n0", "output": "20\n19\n10\n10\n5\n68\n"}, {"type": "stdin_stdout...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nProblem statement\n\nReal variables $ x_1, x_2, ..., x_N $ satisfy the following conditions.\n\n1. $ 0 \\ leq x_i \\ leq 1 $ ($ 1 \\ leq i \\ leq N $)\n2. $ w_1x_1 + w_2x_2 + ... + w_Nx_N \\ leq W $\n\n\n\nAt this time, f...
[{"type": "stdin_stdout", "input": "2 1\n-1 0\n3 10", "output": "6.66666666667\n"}, {"type": "stdin_stdout", "input": "2 1\n-1 -3\n3 10", "output": "3.666667"}, {"type": "stdin_stdout", "input": "1 1\n3 2", "output": "0.666666666667\n"}, {"type": "stdin_stdout", "input": "1 2\n6 1", "output": "0.333333333333\n"}, {"typ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nProblem Statement\n\nMr. Takatsuki, who is planning to participate in the Aizu training camp, is enthusiastic about studying and has been studying English recently. She tries to learn as many English words as possible by ...
[{"type": "stdin_stdout", "input": "6\nZI?U -1\nLINFR 14\nKNGE -1\nLCL -1\n@S 2\nKFHD 15\nBSKA\nILIC\nPZRH\nEDLU\n1", "output": "0\n"}, {"type": "stdin_stdout", "input": "6\n[I?U -1\nLINFR 14\nKNGE -1\nLCL -1\n@S 2\nKFHD 15\nBSKA\nILIC\nPZRH\nEDLU\n1", "output": "0\n"}, {"type": "stdin_stdout", "input": "6\n[I?U -1\nRF...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nE: Jam\n\nproblem\n\nThere are N cities in a country, numbered 1, \\ 2, \\ ..., \\ N. These cities are connected in both directions by M roads, and the i-th road allows you to travel between the cities u_i and v_i in time...
[{"type": "stdin_stdout", "input": "4 4 3\n3 12 1 6\n1 1 2 3\n10 1 9 5\n1 2 1\n2 3 1\n1 3 1\n1 4 1", "output": "20\n18\n13\n"}, {"type": "stdin_stdout", "input": "4 4 3\n3 12 1 6\n1 1 2 3\n10 1 9 5\n1 2 0\n2 3 1\n1 3 1\n1 4 1", "output": "22\n19\n15\n"}, {"type": "stdin_stdout", "input": "4 4 3\n3 12 1 6\n1 1 2 3\n10 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOranges on Cans\n\nsquare1001 You put a $ N $ can of aluminum on the table.\n\nE869120 You put $ M $ of oranges on each aluminum can on the table.\n\nHow many oranges are on the aluminum can?\n\ninput\n\nInput is given fr...
[{"type": "stdin_stdout", "input": "-17 16", "output": "-272\n"}, {"type": "stdin_stdout", "input": "-17 30", "output": "-510\n"}, {"type": "stdin_stdout", "input": "-17 44", "output": "-748\n"}, {"type": "stdin_stdout", "input": "-2 125", "output": "-250\n"}, {"type": "stdin_stdout", "input": "-1 111", "output": "-111...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWrite a program which manipulates a sequence $A$ = {$a_0, a_1, ..., a_{n-1}$} with the following operations:\n\n* $add(s, t, x)$ : add $x$ to $a_s, a_{s+1}, ..., a_t$.\n* $find(s, t)$ : report the minimum value in $a_s, a...
[{"type": "stdin_stdout", "input": "6 17\n0 0 6 1\n0 2 4 -2\n1 0 5\n1 0 2\n0 3 5 3\n1 3 4\n1 0 5", "output": "-1\n-1\n2\n-1\n-1\n-1\n-1\n-1\n-1\n-1\n-1\n-1\n-1\n-1\n"}, {"type": "stdin_stdout", "input": "6 17\n0 0 6 1\n0 2 4 -2\n1 0 5\n1 0 1\n0 3 5 3\n1 3 4\n1 0 5", "output": "-1\n1\n2\n-1\n-1\n-1\n-1\n-1\n-1\n-1\n-1\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAfter a long and successful day of preparing food for the banquet, it is time to clean up. There is a list of n jobs to do before the kitchen can be closed for the night. These jobs are indexed from 1 to n.\n\n\nMost of t...
[{"type": "stdin_stdout", "input": "3\n17 3\n2 6 1\n6 2\n1 4\n8 2\n6 8", "output": "3 5 8 10 12 14 16\n4 7 9 11 13 15 17\n2 5\n3 6\n1 3 5\n2 4 7\n"}, {"type": "stdin_stdout", "input": "3\n17 3\n2 12 1\n6 2\n1 4\n8 2\n6 8", "output": "3 5 7 9 11 14 16\n4 6 8 10 13 15 17\n2 5\n3 6\n1 3 5\n2 4 7\n"}, {"type": "stdin_stdou...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWrite a program to find the remainder when two given numbers are divided.\n\n\nInput\nThe first line contains an integer T, total number of test cases. Then follow T lines, each line contains two Integers A and B.\n\n\nOu...
[{"type": "stdin_stdout", "input": "3 \n1 4\n111 1167\n12 36", "output": "1\n111\n12\n"}, {"type": "stdin_stdout", "input": "3 \n1 4\n111 1167\n20 36", "output": "1\n111\n20\n"}, {"type": "stdin_stdout", "input": "3 \n2 4\n111 1167\n20 65", "output": "2\n111\n20\n"}, {"type": "stdin_stdout", "input": "3 \n1 2\n100 200\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn this problem, you will be given a polynomial, you have to print what it becomes after differentiation.\n\n\nFollowing are the rules for differentiation:\n\nFor a polynomial f(x), its differentiation is defined as f'(x)...
[{"type": "stdin_stdout", "input": "2\n1\n1 4\n3\n1 3\n3 2\n3 -4", "output": "4x^3\n3x^2 + 6x^1 + -12x^-5\n"}, {"type": "stdin_stdout", "input": "2\n1\n1 8\n3\n1 3\n3 2\n3 -4", "output": "8x^7\n3x^2 + 6x^1 + -12x^-5\n"}, {"type": "stdin_stdout", "input": "2\n1\n1 4\n3\n4 3\n3 2\n3 -1", "output": "4x^3\n12x^2 + 6x^1 + -...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAlice and Bob are playing chess on a huge chessboard with dimensions n × n. Alice has a single piece left — a queen, located at (a_x, a_y), while Bob has only the king standing at (b_x, b_y). Alice thinks that as her quee...
[{"type": "stdin_stdout", "input": "1000\n114 372\n112 350\n113 352\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "1000\n500 500\n498 504\n498 505\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "1000\n114 350\n113 372\n113 352\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "1000\n600 6...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe only difference between easy and hard versions is the constraints.\n\nVova likes pictures with kittens. The news feed in the social network he uses can be represented as an array of n consecutive pictures (with kitten...
[{"type": "stdin_stdout", "input": "25 4 15\n172043124 384297369 650214870 426077944 587045971 576701397 865475689 261462255 763837593 285228401 629011531 611623799 456424430 820020943 166915939 903479811 357808031 561107351 177427070 14589838 994169358 1227795556 193684940 439658261 237500762\n", "output": "1051264450...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA frog is initially at position 0 on the number line. The frog has two positive integers a and b. From a position k, it can either jump to position k+a or k-b.\n\nLet f(x) be the number of distinct integers the frog can r...
[{"type": "stdin_stdout", "input": "997674659 11231 35496\n", "output": "497677363010575988\n"}, {"type": "stdin_stdout", "input": "881706694 5710 46369\n", "output": "388703347089502553\n"}, {"type": "stdin_stdout", "input": "952549276 31416 33000\n", "output": "1718466614644254\n"}, {"type": "stdin_stdout", "input": ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe only difference between easy and hard versions is the length of the string. You can hack this problem if you solve it. But you can hack the previous problem only if you solve both problems.\n\nKirk has a binary string...
[{"type": "stdin_stdout", "input": "0111001100111111101000\n", "output": "0011001100000011101000\n"}, {"type": "stdin_stdout", "input": "0111011100111111101000\n", "output": "0001001100000011101000\n"}, {"type": "stdin_stdout", "input": "0111011100111101101000\n", "output": "0001001100001101101000\n"}, {"type": "stdin_...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou may have already known that a standard ICPC team consists of exactly three members. The perfect team however has more restrictions. A student can have some specialization: coder or mathematician. She/he can have no sp...
[{"type": "stdin_stdout", "input": "6\n0 1 1\n0 24 -1\n0 0 1\n0 0 2\n17 1 10\n4 4 1\n", "output": "0\n0\n0\n0\n1\n3\n"}, {"type": "stdin_stdout", "input": "6\n0 1 1\n0 24 -1\n0 0 1\n0 0 2\n17 1 10\n4 4 0\n", "output": "0\n0\n0\n0\n1\n2\n"}, {"type": "stdin_stdout", "input": "6\n0 1 2\n0 28 -1\n0 0 1\n0 0 4\n17 1 10\n4 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are n people in this world, conveniently numbered 1 through n. They are using burles to buy goods and services. Occasionally, a person might not have enough currency to buy what he wants or needs, so he borrows mone...
[{"type": "stdin_stdout", "input": "12 20\n1 3 1000000000\n3 2 1000000000\n1 4 1000000000\n4 2 1000000000\n1 5 1000000000\n5 2 1000000000\n1 6 1000000010\n6 2 1000000000\n1 7 1000000000\n7 2 1000000000\n1 8 1000000000\n8 4 1000000000\n1 9 1000000000\n9 2 1000000000\n1 10 1000000000\n10 2 1000000000\n1 11 1000000000\n11...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\n There was once young lass called Mary, \n Whose jokes were occasionally scary. \n On this April's Fool \n Fixed limerick rules \n Allowed her to trip the unwary. \n \n Can she fill all...
[{"type": "stdin_stdout", "input": "502\n", "output": "2251\n"}, {"type": "stdin_stdout", "input": "202\n", "output": "2101\n"}, {"type": "stdin_stdout", "input": "446\n", "output": "2223\n"}, {"type": "stdin_stdout", "input": "949\n", "output": "1373\n"}, {"type": "stdin_stdout", "input": "718\n", "output": "2359\n"},...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA competitive eater, Alice is scheduling some practices for an eating contest on a magical calendar. The calendar is unusual because a week contains not necessarily 7 days!\n\nIn detail, she can choose any integer k which...
[{"type": "stdin_stdout", "input": "5\n5 4\n2 4\n5 1\n13 9\n1010000 14106652\n", "output": "10\n2\n1\n45\n510049495001\n"}, {"type": "stdin_stdout", "input": "5\n6 4\n3 2\n3 1\n13 7\n1010000 14106652\n", "output": "10\n3\n1\n28\n510049495001\n"}, {"type": "stdin_stdout", "input": "5\n5 4\n2 4\n5 1\n13 9\n1010000 129640...
code_stdio