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\nDrazil is playing a math game with Varda.\n\nLet's define <image> for positive integer x as a product of factorials of its digits. For example, <image>.\n\nFirst, they choose a decimal number a consisting of n digits that... | [{"type": "stdin_stdout", "input": "15\n989898989898989\n", "output": "777777777777777333333333333333322222222222222222222222222222\n"}, {"type": "stdin_stdout", "input": "15\n999999999999990\n", "output": "77777777777777333333333333333333333333333322222222222222\n"}, {"type": "stdin_stdout", "input": "15\n997953296764... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThe famous global economic crisis is approaching rapidly, so the states of Berman, Berance and Bertaly formed an alliance and allowed the residents of all member states to freely pass through the territory of any of them.... | [{"type": "stdin_stdout", "input": "10 10\n###..#.#.#\n#....####.\n##1###.#.#\n#.11######\n##11#####.\n..#####..#\n####...#.3\n.#.#..2223\n#####..#33\n#.########\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "10 10\n##.#..#.#2\n...###....\n#..#....##\n.....#....\n.#........\n.....#####\n...#..#...\n....###..... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nHDD hard drives group data by sectors. All files are split to fragments and each of them are written in some sector of hard drive. Note the fragments can be written in sectors in arbitrary order.\n\nOne of the problems of... | [{"type": "stdin_stdout", "input": "100\n11 9 35 34 51 74 16 67 26 21 14 80 84 79 7 61 28 3 53 43 42 5 56 36 69 30 22 88 1 27 65 91 46 31 59 50 17 96 25 18 64 55 78 2 63 24 95 48 93 13 38 76 89 94 15 90 45 81 52 87 83 73 44 49 23 82 85 75 86 33 47 19 58 97 37 20 40 10 92 4 6 68 77 54 71 12 62 60 100 39 41 99 72 29 57 8... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAlice and Bob are playing a game. The game involves splitting up game pieces into two teams. There are n pieces, and the i-th piece has a strength pi.\n\nThe way to split up game pieces is split into several steps:\n\n 1... | [{"type": "stdin_stdout", "input": "100\n591 417 888 251 792 847 685 3 182 461 102 348 555 956 771 901 712 878 580 631 342 333 285 899 525 725 537 718 929 653 84 788 104 355 624 803 253 853 201 995 536 184 65 205 540 652 549 777 248 405 677 950 431 580 600 846 328 429 134 983 526 103 500 963 400 23 276 704 570 757 410 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nFor a sequence a of n integers between 1 and m, inclusive, denote f(a) as the number of distinct subsequences of a (including the empty subsequence).\n\nYou are given two positive integers n and m. Let S be the set of all... | [{"type": "stdin_stdout", "input": "1000000 1000000\n", "output": "247171672\n"}, {"type": "stdin_stdout", "input": "500 500\n", "output": "383255233\n"}, {"type": "stdin_stdout", "input": "1000000 1\n", "output": "1000001\n"}, {"type": "stdin_stdout", "input": "1 1000000\n", "output": "2000000\n"}, {"type": "stdin_std... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nKatya studies in a fifth grade. Recently her class studied right triangles and the Pythagorean theorem. It appeared, that there are triples of positive integers such that you can construct a right triangle with segments o... | [{"type": "stdin_stdout", "input": "1471603981\n", "output": "1082809138447524180 1082809138447524181\n"}, {"type": "stdin_stdout", "input": "1593985157\n", "output": "1270394340368157324 1270394340368157325\n"}, {"type": "stdin_stdout", "input": "1253161456\n", "output": "392603408701009983 392603408701009985\n"}, {"t... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nMike has always been thinking about the harshness of social inequality. He's so obsessed with it that sometimes it even affects him while solving problems. At the moment, Mike has two sequences of positive integers A = [a... | [{"type": "stdin_stdout", "input": "100\n1 1 1 1 1 1 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 7 7 7 7 7 7 7 7 8 8 8 8 8 8 8 9 9 9 9 9 9 10 10 10 10 10 10 10 10 10 10 10 10 10\n10 10 10 10 10 10 10 10 10 10 10 10 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nIvan is developing his own computer game. Now he tries to create some levels for his game. But firstly for each level he needs to draw a graph representing the structure of the level.\n\nIvan decided that there should be ... | [{"type": "stdin_stdout", "input": "10\n2\n2\n3\n4\n5\n3\n11\n8\n9\n10\n", "output": "1\n1\n2\n3\n4\n2\n13\n8\n10\n12\n"}, {"type": "stdin_stdout", "input": "10\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n", "output": "0\n1\n2\n3\n4\n6\n7\n8\n10\n12\n"}, {"type": "stdin_stdout", "input": "10\n1\n2\n3\n4\n5\n3\n7\n8\n9\n10\n", "out... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given n Γ m table. Each cell of the table is colored white or black. Find the number of non-empty sets of cells such that:\n\n 1. All cells in a set have the same color. \n 2. Every two cells in a set share row ... | [{"type": "stdin_stdout", "input": "5 50\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\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\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 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nProgrammer Vasya is studying a new programming language &K*. The &K* language resembles the languages of the C family in its syntax. However, it is more powerful, which is why the rules of the actual C-like languages are ... | [{"type": "stdin_stdout", "input": "10\ntypedef &void**** youdyfpinzk\ntypeof &youdyfpinzk***\ntypedef &&&&youdyfpinzk****** nfbsgpjzhxzskmxc\ntypeof nfbsgpjzhxzskmxc***\ntypedef &&&void*** puerqioirikxej\ntypeof &puerqioirikxej********\ntypedef &puerqioirikxej******** xzgzsamjdufuyxz\ntypeof &xzgzsamjdufuyxz******\nty... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nConsider a rooted tree. A rooted tree has one special vertex called the root. All edges are directed from the root. Vertex u is called a child of vertex v and vertex v is called a parent of vertex u if there exists a dire... | [{"type": "stdin_stdout", "input": "20\n1\n1\n1\n1\n2\n2\n2\n3\n3\n3\n4\n4\n4\n5\n5\n5\n1\n1\n1\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "20\n1\n1\n1\n1\n4\n2\n2\n3\n3\n3\n4\n4\n4\n10\n5\n5\n1\n1\n1\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "20\n1\n1\n1\n1\n4\n2\n2\n3\n3\n3\n4\n4\n4\n5\n... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nTwo neighboring kingdoms decided to build a wall between them with some gates to enable the citizens to go from one kingdom to another. Each time a citizen passes through a gate, he has to pay one silver coin.\n\nThe worl... | [{"type": "stdin_stdout", "input": "100\nRUURUURRUURUUUUURRUUURRRRUURRURRURRRRUUUUUURRUURRRRURUUURUURURRRRRURUURRUURUURRUUURUUUUUURRUUUURUUUR\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "100\nRUUURUUUURRUUUUUURUUURRUURUURRUURURRRRRURUURUUURURRRRUURRUUUUUURRRRURRURRUURRRRUUURRUUUUURUURRUURUUR\n", "output": "... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given a following process. \n\nThere is a platform with n columns. 1 Γ 1 squares are appearing one after another in some columns on this platform. If there are no squares in the column, a square will occupy the bo... | [{"type": "stdin_stdout", "input": "1000 10\n999 999 998 34 454 546 343 35 34 1000\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "1000 10\n999 999 998 34 454 546 343 69 34 1000\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "1000 10\n999 999 998 34 454 546 343 67 34 1000\n", "output": "0\n"}, {"type"... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nPolycarp lives on a coordinate line at the point x = 0. He goes to his friend that lives at the point x = a. Polycarp can move only from left to right, he can pass one unit of length each second.\n\nNow it's raining, so s... | [{"type": "stdin_stdout", "input": "100 50 1\n1 2\n3 4\n5 6\n7 8\n9 10\n11 12\n13 14\n15 16\n17 18\n19 20\n21 22\n23 24\n25 26\n27 28\n29 30\n31 32\n33 34\n35 36\n37 38\n39 40\n41 42\n43 44\n45 46\n47 48\n49 50\n51 52\n53 54\n55 56\n57 58\n59 60\n61 62\n63 64\n65 66\n67 68\n69 70\n71 72\n73 74\n75 76\n77 78\n79 80\n81 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThe Monk learned about priority queues recently and asked his teacher for an interesting problem. So his teacher came up with a simple problem. He now has an integer array A. For each index i, he wants to find the product... | [{"type": "stdin_stdout", "input": "10\n3 10 9 1 27 2 12 18 3 5", "output": "-1\n-1\n270\n270\n2430\n2430\n3240\n5832\n5832\n5832\n"}, {"type": "stdin_stdout", "input": "10\n2 8 9 1 27 2 10 13 3 5", "output": "-1\n-1\n144\n144\n1944\n1944\n2430\n3510\n3510\n3510\n"}, {"type": "stdin_stdout", "input": "10\n3 8 9 1 27 2 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nRecently in a class of Computer Networks, little Roy learned to calculate Hamming Distance between two strings of equal length.\n\nDuring practical session, Roy's teacher gave him a string of length L with all distinct ch... | [{"type": "stdin_stdout", "input": "10\n<=>?@ABCDE", "output": "1334961\n"}, {"type": "stdin_stdout", "input": "10\nEDCBA@?>=<", "output": "1334961\n"}, {"type": "stdin_stdout", "input": "10\nEDBBA@?>=<", "output": "1334961\n"}, {"type": "stdin_stdout", "input": "10\n<=>?@ABBDE", "output": "1334961\n"}, {"type": "stdin... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nWe have N logs of lengths A_1,A_2,\\cdots A_N.\n\nWe can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0<t<L), it becomes two logs of lengths... | [{"type": "stdin_stdout", "input": "10 10\n158260522 877914575 1013896555 24979445 861648772 623690081 433933447 476190629 262703497 374010847", "output": "337965519\n"}, {"type": "stdin_stdout", "input": "10 10\n158260522 877914575 1013896555 25358811 861648772 623690081 825664159 476190629 262703497 374010847", "outp... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nWe have N+M balls, each of which has an integer written on it.\nIt is known that:\n\n* The numbers written on N of the balls are even.\n* The numbers written on M of the balls are odd.\n\n\n\nFind the number of ways to ch... | [{"type": "stdin_stdout", "input": "-1 -173", "output": "15052\n"}, {"type": "stdin_stdout", "input": "-1 -295", "output": "43661\n"}, {"type": "stdin_stdout", "input": "560 1", "output": "156520\n"}, {"type": "stdin_stdout", "input": "-1 -118", "output": "7022\n"}, {"type": "stdin_stdout", "input": "0 -295", "output":... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere is a knight - the chess piece - at the origin (0, 0) of a two-dimensional grid.\n\nWhen the knight is at the square (i, j), it can be moved to either (i+1,j+2) or (i+2, j+1).\n\nIn how many ways can the knight reach... | [{"type": "stdin_stdout", "input": "1279413 999999", "output": "825914746\n"}, {"type": "stdin_stdout", "input": "593126 1184107", "output": "321508604\n"}, {"type": "stdin_stdout", "input": "728601 999999", "output": "197453690\n"}, {"type": "stdin_stdout", "input": "123395 134890", "output": "905248722\n"}, {"type": ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nKizahashi, who was appointed as the administrator of ABC at National Problem Workshop in the Kingdom of AtCoder, got too excited and took on too many jobs.\n\nLet the current time be time 0. Kizahashi has N jobs numbered ... | [{"type": "stdin_stdout", "input": "30\n384 8895\n1725 9791\n170 1024\n4 11105\n2 6\n578 1815\n702 3352\n143 5141\n1420 11731\n24 1602\n849 999\n76 7586\n85 5570\n444 4991\n719 11090\n470 10708\n1137 4547\n455 9003\n110 9901\n15 8578\n718 3692\n104 1286\n3 4\n366 12143\n7 6649\n610 2374\n152 7324\n4 7042\n292 11386\n33... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nWe will play a one-player game using a number line and N pieces.\n\nFirst, we place each of these pieces at some integer coordinate.\n\nHere, multiple pieces can be placed at the same coordinate.\n\nOur objective is to vi... | [{"type": "stdin_stdout", "input": "3 7\n-10 -1 0 9 -100 2 17", "output": "18\n"}, {"type": "stdin_stdout", "input": "3 7\n-10 -3 0 9 -100 2 18", "output": "19\n"}, {"type": "stdin_stdout", "input": "2 7\n-8 -1 0 18 -100 2 17", "output": "26\n"}, {"type": "stdin_stdout", "input": "2 7\n-10 -2 0 9 -100 2 17", "output": ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nMr. Infinity has a string S consisting of digits from `1` to `9`. Each time the date changes, this string changes as follows:\n\n* Each occurrence of `2` in S is replaced with `22`. Similarly, each `3` becomes `333`, `4` ... | [{"type": "stdin_stdout", "input": "299792458\n16007747457388278", "output": "2\n"}, {"type": "stdin_stdout", "input": "299792458\n16265126384663115", "output": "2\n"}, {"type": "stdin_stdout", "input": "299792458\n27784678339588086", "output": "2\n"}, {"type": "stdin_stdout", "input": "299792458\n11289796998184320", "... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nWrite a program which replace all the lower-case letters of a given text with the corresponding captital letters.\n\n\n\nInput\n\nA text including lower-case letters, periods, and space is given in a line. The number of c... | [{"type": "stdin_stdout", "input": "this is b pen.", "output": "THIS IS B PEN.\n"}, {"type": "stdin_stdout", "input": "tiis is b pen.", "output": "TIIS IS B PEN.\n"}, {"type": "stdin_stdout", "input": "tiis is a pen.", "output": "TIIS IS A PEN.\n"}, {"type": "stdin_stdout", "input": "tiis it a pen.", "output": "TIIS IT... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nproblem\n\nYou are a traveler traveling on the JOI Highway. The JOI Highway is a road that extends straight from east to west, and there are n post towns on the JOI Highway. Numbered. The westernmost post town on the JOI ... | [{"type": "stdin_stdout", "input": "7 5\n2\n0\n1\n1\n2\n-1\n2\n-1\n2\n2\n-3", "output": "10\n"}, {"type": "stdin_stdout", "input": "7 0\n1\n-1\n1\n3\n1\n-1\n3\n-2\n-1\n1\n0", "output": "0\n"}, {"type": "stdin_stdout", "input": "7 0\n1\n-1\n1\n2\n1\n-1\n3\n-2\n-1\n1\n0", "output": "0\n"}, {"type": "stdin_stdout", "input... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nCosmic market, commonly known as Kozumike, is the largest coterie spot sale in the universe. Doujin lovers of all genres gather at Kozumike. In recent years, the number of visitors to Kozumike has been increasing. If ever... | [{"type": "stdin_stdout", "input": "5 5 4\n0 0 1\n0 0 0\n0 2 0\n1 1 1\n1 0 0\n5 5 5\n1 4 0\n0 1 1\n0 4 1\n1 3 0\n0 3 1\n5 5 5\n1 0 0\n0 3 1\n1 2 1\n0 4 0\n1 1 1\n0 0 0", "output": "5\n0\n13\n12\n"}, {"type": "stdin_stdout", "input": "5 14 5\n2 0 2\n0 0 0\n0 0 1\n1 2 1\n1 0 0\n5 5 5\n1 4 1\n0 1 1\n1 1 1\n1 3 0\n1 3 0\n5... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nNicholas Y. Alford was a cat lover. He had a garden in a village and kept many cats in his garden. The cats were so cute that people in the village also loved them.\n\nOne day, an evil witch visited the village. She envie... | [{"type": "stdin_stdout", "input": "6 7\n2 0\n6 -1\n13 2\n6 3\n0 5\n1 7\n1 3\n2 3\n3 4\n4 1\n5 1\n5 4\n5 6", "output": "10.385164807135\n"}, {"type": "stdin_stdout", "input": "6 7\n2 0\n6 -1\n13 2\n6 3\n0 5\n1 7\n1 3\n2 3\n3 4\n5 1\n5 1\n5 4\n5 6", "output": "10.770329614269\n"}, {"type": "stdin_stdout", "input": "6 7\... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nProblem Statement\n\nYou are now participating in the Summer Training Camp for Programming Contests with your friend Jiro, who is an enthusiast of the ramen chain SIRO. Since every SIRO restaurant has its own tasteful ram... | [{"type": "stdin_stdout", "input": "2 1 1 1 10\n1 2 2\n2 4\n2 1 1 1 12\n1 2 3\n2 0\n4 2 2 4 50\n1 2 5\n3 4 5\n2 15\n3 15\n4 6 3 1 29\n1 2 20\n3 2 13\n4 1 5\n3 1 5\n2 4 3\n3 0 4\n2 1\n4 5\n3 3\n0 0 0 0 0", "output": "1\n1\n1\n2\n"}, {"type": "stdin_stdout", "input": "2 1 1 1 10\n0 2 2\n2 4\n2 1 1 1 12\n1 2 3\n2 0\n4 2 2... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nPoints:10\nThe Indian Heights School believes that learning with the aid of technology is the fastest way to do so. It is a pioneer in innovation and virtual classrooms in the country. Keeping in accordance with its pract... | [{"type": "stdin_stdout", "input": "2\n2 1\n52 34", "output": "2\n42671977361650\n"}, {"type": "stdin_stdout", "input": "2\n1 4\n39 20", "output": "1\n68923264410\n"}, {"type": "stdin_stdout", "input": "2\n2 1\n34 15", "output": "2\n1855967520\n"}, {"type": "stdin_stdout", "input": "2\n1 4\n39 13", "output": "1\n812242... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere are n points on the plane, (x_1,y_1), (x_2,y_2), β¦, (x_n,y_n).\n\nYou need to place an isosceles triangle with two sides on the coordinate axis to cover all points (a point is covered if it lies inside the triangle ... | [{"type": "stdin_stdout", "input": "10\n100 34\n27 17\n17 73\n12 60\n53 25\n46 31\n61 86\n22 91\n82 91\n8 41\n", "output": "173\n"}, {"type": "stdin_stdout", "input": "10\n100 34\n27 17\n17 73\n12 60\n53 25\n46 31\n51 86\n22 91\n82 91\n8 41\n", "output": "173\n"}, {"type": "stdin_stdout", "input": "10\n110 34\n27 17\n1... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nPolycarp took n videos, the duration of the i-th video is a_i seconds. The videos are listed in the chronological order, i.e. the 1-st video is the earliest, the 2-nd video is the next, ..., the n-th video is the last.\n\... | [{"type": "stdin_stdout", "input": "6 3\n3 3 1 4 1 6\n", "output": "Yes\n2 3 1 \n"}, {"type": "stdin_stdout", "input": "3 3\n1 1 1\n", "output": "Yes\n1 1 1 \n"}, {"type": "stdin_stdout", "input": "3 1\n1 10 100\n", "output": "Yes\n3 \n"}, {"type": "stdin_stdout", "input": "6 3\n5 3 1 4 1 6\n", "output": "No\n"}, {"typ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given a tree consisting exactly of n vertices. Tree is a connected undirected graph with n-1 edges. Each vertex v of this tree has a value a_v assigned to it.\n\nLet dist(x, y) be the distance between the vertices... | [{"type": "stdin_stdout", "input": "8\n9 4 1 7 10 1 1 10\n1 2\n2 3\n1 4\n1 5\n5 6\n5 7\n5 8\n", "output": "121\n"}, {"type": "stdin_stdout", "input": "8\n9 4 1 8 10 1 1 10\n1 2\n2 3\n1 4\n1 5\n5 6\n5 7\n5 8\n", "output": "124\n"}, {"type": "stdin_stdout", "input": "8\n9 3 1 8 10 1 1 10\n1 2\n2 3\n1 4\n1 5\n5 6\n5 7\n5 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAn array of integers p_1, p_2, ..., p_n is called a permutation if it contains each number from 1 to n exactly once. For example, the following arrays are permutations: [3, 1, 2], [1], [1, 2, 3, 4, 5] and [4, 3, 1, 2]. Th... | [{"type": "stdin_stdout", "input": "5\n-1 2 -3 -1\n", "output": "4 3 5 2 1 "}, {"type": "stdin_stdout", "input": "5\n-4 1 2 -1\n", "output": "5 1 2 4 3 "}, {"type": "stdin_stdout", "input": "5\n3 -2 1 -3\n", "output": "2 5 3 4 1 "}, {"type": "stdin_stdout", "input": "5\n1 1 -3 4\n", "output": "2 3 4 1 5 "}, {"type": "s... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou have a garden consisting entirely of grass and weeds. Your garden is described by an n Γ m grid, with rows numbered 1 to n from top to bottom, and columns 1 to m from left to right. Each cell is identified by a pair (... | [{"type": "stdin_stdout", "input": "3 150\nGGGWGGGGWWGGGGGGGGGGGGGWGGWGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGWGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGWGGGGGGGWGGGGGGGGGGGGGGGGGWGGGGGGGGGGGGGGGGGGW\nGGGGGGGGGGGGWGGGGGGGGGWGGGGGGGGGGGGWGGGGGWGGGGGGGWGGGGGGGWGGGGGWGGGGGGGGGGGGGGGGGGGGGGGGWGGGGWGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou have a given picture with size w Γ h. Determine if the given picture has a single \"+\" shape or not. A \"+\" shape is described below:\n\n * A \"+\" shape has one center nonempty cell. \n * There should be some (at... | [{"type": "stdin_stdout", "input": "10 10\n..........\n..........\n....*.....\n....*.....\n.*******..\n....*.....\n....*.....\n..........\n....*.....\n..........\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "10 10\n..........\n..........\n....*.....\n....*.....\n.*******..\n....*.....\n....*.....\n............ | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nJack is working on his jumping skills recently. Currently he's located at point zero of the number line. He would like to get to the point x. In order to train, he has decided that he'll first jump by only one unit, and e... | [{"type": "stdin_stdout", "input": "-1000000000\n", "output": "44723\n"}, {"type": "stdin_stdout", "input": "-1028109475\n", "output": "45346\n"}, {"type": "stdin_stdout", "input": "-1050321888\n", "output": "45835\n"}, {"type": "stdin_stdout", "input": "-245245154\n", "output": "22147\n"}, {"type": "stdin_stdout", "in... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nLet's define a balanced multiset the following way. Write down the sum of all elements of the multiset in its decimal representation. For each position of that number check if the multiset includes at least one element su... | [{"type": "stdin_stdout", "input": "10 20\n13 41 38 21 33 19 50 3 18 32\n1 2 44\n2 4 7\n1 8 35\n1 8 47\n2 4 4\n1 9 10\n1 9 47\n2 5 9\n2 2 2\n2 6 9\n1 3 24\n2 1 10\n2 1 7\n2 2 10\n2 2 10\n1 10 29\n1 2 23\n1 6 36\n2 6 8\n1 1 14\n", "output": "40\n-1\n52\n-1\n66\n32\n32\n40\n40\n83\n"}, {"type": "stdin_stdout", "input": "... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are a rebel leader and you are planning to start a revolution in your country. But the evil Government found out about your plans and set your punishment in the form of correctional labor.\n\nYou must paint a fence wh... | [{"type": "stdin_stdout", "input": "5\n1 1000000000 999999998\n1 1000000000 999999999\n1 1000000000 1000000000\n1000000000 1000000000 2\n1000000000 1000000000 1000000000\n", "output": "REBEL\nREBEL\nOBEY\nOBEY\nOBEY\n"}, {"type": "stdin_stdout", "input": "5\n1 1000000000 999999998\n1 1000000001 999999999\n1 1000000000 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nPetya has come to the math exam and wants to solve as many problems as possible. He prepared and carefully studied the rules by which the exam passes.\n\nThe exam consists of n problems that can be solved in T minutes. Th... | [{"type": "stdin_stdout", "input": "10\n3 5 1 3\n0 0 1\n2 1 4\n2 5 2 3\n1 0\n3 2\n1 20 2 4\n0\n16\n6 20 2 5\n1 1 0 1 0 0\n0 8 2 9 11 6\n4 12 3 6\n1 0 1 1\n8 3 5 6\n6 20 3 12\n0 1 0 0 1 0\n20 11 3 20 16 17\n7 17 1 6\n1 1 0 1 0 0 0\n1 8 0 11 15 15 10\n6 17 2 6\n0 0 1 0 0 1\n7 11 2 7 10 12\n5 17 2 5\n1 1 1 1 0\n17 11 10 6... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThis is the easy version of the problem. The difference is the constraint on the sum of lengths of strings and the number of test cases. You can make hacks only if you solve all versions of this task.\n\nYou are given a s... | [{"type": "stdin_stdout", "input": "2\nbyklvkupcupkhibyklvkupcupkhibyklvkupcupkhiihkpucpukvlkybihkpucpukvlkybihkpucpukvlkybbyklvkupcupkhibyklvkupcupkhiihkpucpukvlkybihkpucpukvlkybihkpucpukvlkybbyklvkupcupkhibyklvkupcupkhiihkpucpukvlkybihkpucpukvlkybihkpucpukvlkybihkpucpukvlkybihkpucpukvlkybihkpucpukvlkybihkpucpukvlkybb... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nHilbert's Hotel is a very unusual hotel since the number of rooms is infinite! In fact, there is exactly one room for every integer, including zero and negative integers. Even stranger, the hotel is currently at full capa... | [{"type": "stdin_stdout", "input": "10\n3\n-15 -40 79\n16\n45 -62 19 85 69 -64 93 -101 0 -53 2 -52 -55 66 33 -60\n2\n28 -2\n4\n-65 -76 5 25\n5\n55 -33 63 -66 -35\n5\n-87 59 78 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 34 43 -83 57 8 -86 62 -25 96 22 -44\n", "output": "NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n"}, {"type": ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given an array a[0 β¦ n-1] of length n which consists of non-negative integers. Note that array indices start from zero.\n\nAn array is called good if the parity of each index matches the parity of the element at t... | [{"type": "stdin_stdout", "input": "4\n4\n6 4 7 6\n3\n3 2 6\n1\n7\n3\n4 14 2 1 18 3 0\n", "output": "-1\n1\n-1\n-1\n"}, {"type": "stdin_stdout", "input": "4\n4\n3 2 0 6\n3\n6 4 4\n1\n7\n7\n7 7 2 1 18 1 2\n", "output": "-1\n-1\n-1\n-1\n"}, {"type": "stdin_stdout", "input": "4\n4\n3 2 7 8\n3\n6 2 8\n1\n7\n7\n6 13 2 1 19 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nCaptain Flint and his crew keep heading to a savage shore of Byteland for several months already, drinking rum and telling stories. In such moments uncle Bogdan often remembers his nephew Denis. Today, he has told a story... | [{"type": "stdin_stdout", "input": "2\n11405\n58469\n", "output": "9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAutumn came late to the kingdom of Far Far Away. The harvest was exuberant and it is now time to get ready for the winter. As most people celebrate the Harvest festival, Simon the Caretaker tries to solve a very non-trivi... | [{"type": "stdin_stdout", "input": "9 9\n", "output": "13\nAAA.BCCC.\n.ABBB.CD.\n.AE.BFCD.\nEEEFFFDDD\nG.E.HFIII\nGGGJHHHI.\nGK.JHL.IM\n.KJJJLMMM\nKKK.LLL.M\n"}, {"type": "stdin_stdout", "input": "9 8\n", "output": "12\nAAA.BCCC\n.ABBBDC.\nEA.FBDC.\nEEEFDDDG\nEHFFFGGG\n.HHHIIIG\nJHKKKIL.\nJJJK.IL.\nJ..K.LLL\n"}, {"type... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThis is an interactive problem.\n\nAlice and Bob are playing a game. There is nΓ n grid, initially empty. We refer to the cell in row i and column j by (i, j) for 1β€ i, jβ€ n. There is an infinite supply of tokens that com... | [{"type": "stdin_stdout", "input": "10\n1 2 1 1 1 2 2 3 1 1 2 1 2 3 3 1 1 1 1 1 1 3 1 1 2 3 1 1 1 1 1 1 1 1 1 2 1 1 1 1 3 1 1 1 1 1 1 2 2 3 3 1 2 2 1 2 2 2 3 1 3 3 2 3 1 3 2 2 1 1 1 2 1 1 1 1 1 3 1 3 1 3 1 1 1 2 1 2 1 1 3 3 1 3 1 1 1 1 1 1\n", "output": "2 1 2\n1 1 1\n2 1 4\n2 1 6\n2 1 8\n1 1 3\n1 1 5\n1 1 7\n2 1 10\n2... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThe Berland University is preparing to celebrate the 256-th anniversary of its founding! A specially appointed Vice Rector for the celebration prepares to decorate the campus. In the center of the campus n ice sculptures ... | [{"type": "stdin_stdout", "input": "97\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -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\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "97\n0 0 0 0 0 0 0 0 0 0 0 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nLittle Vasya loves orange juice very much. That's why any food and drink in his kitchen necessarily contains orange juice. There are n drinks in his fridge, the volume fraction of orange juice in the i-th drink equals pi ... | [{"type": "stdin_stdout", "input": "100\n100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 101 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nA dice is a cube, its faces contain distinct integers from 1 to 6 as black points. The sum of numbers at the opposite dice faces always equals 7. Please note that there are only two dice (these dices are mirror of each ot... | [{"type": "stdin_stdout", "input": "100\n3\n6 5\n1 5\n2 1\n5 1\n6 5\n5 1\n6 2\n1 2\n6 5\n5 1\n5 1\n1 5\n2 6\n6 2\n5 6\n1 2\n1 5\n5 6\n1 5\n1 2\n2 6\n1 2\n6 2\n1 5\n6 2\n2 6\n1 5\n6 2\n6 5\n5 6\n1 5\n5 6\n5 1\n5 1\n2 1\n1 2\n5 6\n6 5\n1 5\n5 1\n1 2\n1 5\n1 2\n2 6\n5 1\n2 6\n2 6\n5 6\n2 6\n6 5\n6 5\n1 5\n2 1\n5 6\n5 6\n1... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nIn the evenings Donkey would join Shrek to look at the stars. They would sit on a log, sipping tea and they would watch the starry sky. The sky hung above the roof, right behind the chimney. Shrek's stars were to the righ... | [{"type": "stdin_stdout", "input": "5\n27/18 27/17\n91659 76441\n96317 38081\n99805 94867\n79758 84753\n96445 53616\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "5\n27/18 27/17\n27746 42830\n22071 47985\n44242 62799\n16038 48367\n85158 21622\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "5\n27/18 2... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nIt is known that there are k fish species in the polar ocean, numbered from 1 to k. They are sorted by non-decreasing order of their weight, which is a positive number. Let the weight of the i-th type of fish be wi, then ... | [{"type": "stdin_stdout", "input": "100 50 10\n7 8 7 1 6 7 9 2 4 6 7 7 3 9 4 5 1 7 8 10 4 1 3 6 8 10 4 6 6 1 6 12 7 4 10 3 10 1 3 2 10 6 9 9 5 2 9 2 9 8 10 2 10 3 3 2 3 8 6 2 7 10 7 2 7 2 8 9 6 2 5 4 4 5 3 3 9 10 9 4 9 3 9 5 3 6 6 1 3 6 10 3 10 2 6 10 10 10 4 8\n3 3 2 9 4 4 10 2 7 3 3 2 6 3 3 4 7 4 1 2 3 8 1 6 7 7 2 10... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere is a new TV game on BerTV. In this game two players get a number A consisting of 2n digits. Before each turn players determine who will make the next move. Each player should make exactly n moves. On it's turn i-th ... | [{"type": "stdin_stdout", "input": "18\n112233445566778899112233445566778899\n", "output": "HHHHHHHHHHHHHHHHMMHHMMMMMMMMMMMMMMMM\n"}, {"type": "stdin_stdout", "input": "18\n101011411002041200101000000000001000\n", "output": "HHHHHHMHHHHHHMHMHHMHMHHMMMMMMMMMMMMM\n"}, {"type": "stdin_stdout", "input": "18\n78999876889668... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nSereja has an array a, consisting of n integers a1, a2, ..., an. The boy cannot sit and do nothing, he decided to study an array. Sereja took a piece of paper and wrote out m integers l1, l2, ..., lm (1 β€ li β€ n). For eac... | [{"type": "stdin_stdout", "input": "10 10\n1 2 3 4 1 2 3 4 100000 99999\n1\n2\n3\n4\n5\n6\n7\n7\n9\n10\n", "output": "6\n6\n6\n6\n6\n5\n4\n4\n2\n1\n"}, {"type": "stdin_stdout", "input": "10 10\n1 2 3 4 1 2 3 6 100000 99999\n1\n2\n3\n4\n5\n6\n7\n7\n9\n10\n", "output": "7\n7\n7\n7\n6\n5\n4\n4\n2\n1\n"}, {"type": "stdin_s... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nInna loves sweets very much. She has n closed present boxes lines up in a row in front of her. Each of these boxes contains either a candy (Dima's work) or nothing (Sereja's work). Let's assume that the boxes are numbered... | [{"type": "stdin_stdout", "input": "10 3 6\n0010010010\n1 3\n4 6\n7 9\n1 6\n4 9\n1 9\n", "output": "0\n0\n0\n0\n0\n0\n"}, {"type": "stdin_stdout", "input": "10 3 6\n0010010110\n1 3\n4 6\n7 9\n1 6\n4 9\n1 9\n", "output": "0\n0\n1\n0\n1\n1\n"}, {"type": "stdin_stdout", "input": "10 3 6\n1010010010\n1 3\n4 6\n7 9\n1 6\n4 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThe R1 company wants to hold a web search championship. There were n computers given for the competition, each of them is connected to the Internet. The organizers believe that the data transfer speed directly affects the... | [{"type": "stdin_stdout", "input": "80 50\n15160 6853 20254 11358 19535 27691 2983 31650 9219 11833 32053 31695 21511 4320 4384 24843 1454 31543 18796 13815 1546 27926 16276 14315 12542 25370 24890 29647 1730 17867 12446 15072 19852 30207 16361 7964 5343 398 10837 31114 9252 12767 15098 22562 32637 31823 8160 12658 642... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nDevu and his brother love each other a lot. As they are super geeks, they only like to play with arrays. They are given two arrays a and b by their father. The array a is given to Devu and b to his brother. \n\nAs Devu is... | [{"type": "stdin_stdout", "input": "10 10\n23 101 38 38 73 54 59 69 44 150\n100 100 100 100 100 100 100 100 100 100\n", "output": "402\n"}, {"type": "stdin_stdout", "input": "10 10\n23 101 38 38 73 54 59 69 44 150\n100 100 100 100 100 100 100 101 100 100\n", "output": "403\n"}, {"type": "stdin_stdout", "input": "10 10\... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nNotice that the memory limit is non-standard.\n\nRecently Arthur and Sasha have studied correct bracket sequences. Arthur understood this topic perfectly and become so amazed about correct bracket sequences, so he even go... | [{"type": "stdin_stdout", "input": "50\n97 97\n61 61\n59 59\n29 29\n13 13\n7 7\n5 5\n3 3\n1 1\n3 3\n1 1\n13 13\n11 11\n9 9\n3 3\n1 1\n1 1\n1 1\n27 27\n25 25\n1 1\n21 21\n19 19\n17 17\n15 15\n5 5\n1 1\n1 1\n7 7\n1 1\n3 3\n1 1\n15 15\n13 13\n1 1\n9 9\n7 7\n5 5\n3 3\n1 1\n15 15\n5 5\n1 1\n1 1\n3 3\n1 1\n1 1\n1 1\n1 1\n1 1... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nOne Big Software Company has n employees numbered from 1 to n. The director is assigned number 1. Every employee of the company except the director has exactly one immediate superior. The director, of course, doesn't have... | [{"type": "stdin_stdout", "input": "20\n-1 100\n1 35\n2 22\n3 28\n3 2\n4 8\n3 17\n2 50\n5 37\n5 25\n4 29\n9 21\n10 16\n10 39\n11 41\n9 28\n9 30\n12 36\n13 26\n19 17\n", "output": "459\n"}, {"type": "stdin_stdout", "input": "20\n-1 100\n1 1\n2 22\n3 28\n3 2\n4 8\n3 17\n2 50\n5 37\n5 25\n4 29\n9 21\n10 16\n10 39\n11 41\n... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given an array of positive integers a1, a2, ..., an Γ T of length n Γ T. We know that for any i > n it is true that ai = ai - n. Find the length of the longest non-decreasing sequence of the given array.\n\nInput\... | [{"type": "stdin_stdout", "input": "100 10000000\n300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 30... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nVladik and Chloe decided to determine who of them is better at math. Vladik claimed that for any positive integer n he can represent fraction <image> as a sum of three distinct positive fractions in form <image>.\n\nHelp ... | [{"type": "stdin_stdout", "input": "10000\n", "output": "10000 10001 100010000 "}, {"type": "stdin_stdout", "input": "17554\n", "output": "17554 17555 308160470\n"}, {"type": "stdin_stdout", "input": "10023\n", "output": "10023 10024 100470552\n"}, {"type": "stdin_stdout", "input": "19176\n", "output": "19176 19177 367... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nA breakthrough among computer games, \"Civilization XIII\", is striking in its scale and elaborate details. Let's take a closer look at one of them.\n\nThe playing area in the game is split into congruent cells that are r... | [{"type": "stdin_stdout", "input": "1000000\n", "output": "1209197264797\n"}, {"type": "stdin_stdout", "input": "1010000\n", "output": "1233502153639\n"}, {"type": "stdin_stdout", "input": "1010100\n", "output": "1233746427001\n"}, {"type": "stdin_stdout", "input": "999811\n", "output": "1208740231393\n"}, {"type": "st... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAt regular competition Vladik and Valera won a and b candies respectively. Vladik offered 1 his candy to Valera. After that Valera gave Vladik 2 his candies, so that no one thought that he was less generous. Vladik for sa... | [{"type": "stdin_stdout", "input": "1000000000 1000000000\n", "output": "Vladik\n"}, {"type": "stdin_stdout", "input": "1000000000 1387445955\n", "output": "Vladik\n"}, {"type": "stdin_stdout", "input": "1000000000 1000000001\n", "output": "Vladik\n"}, {"type": "stdin_stdout", "input": "1000000000 1214716107\n", "outpu... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nOne very important person has a piece of paper in the form of a rectangle a Γ b.\n\nAlso, he has n seals. Each seal leaves an impression on the paper in the form of a rectangle of the size xi Γ yi. Each impression must be... | [{"type": "stdin_stdout", "input": "30 100 101\n60 34\n29 82\n89 77\n39 1\n100 100\n82 12\n57 87\n93 43\n78 50\n38 55\n37 9\n67 5\n100 100\n100 100\n82 47\n3 71\n100 100\n19 26\n25 94\n89 5\n100 100\n32 1\n100 100\n34 3\n40 99\n100 100\n36 12\n100 100\n100 100\n100 100\n", "output": "10039\n"}, {"type": "stdin_stdout",... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nPolycarpus takes part in the \"Field of Wonders\" TV show. The participants of the show have to guess a hidden word as fast as possible. Initially all the letters of the word are hidden.\n\nThe game consists of several tu... | [{"type": "stdin_stdout", "input": "42\n*****o*******t********************oo******\n10\nvcrccobltkeidtxhsxhccaslkjhfyeqsetoowaemso\nuimjsoxifamvctkgqmrwhyjrgmlydczzqjoobnnwch\nuvmjsoqizfavctkxemrpaycngmlyemzzqjoobszwbh\nusmjsoviskzvctkljmrlmylugmlydfzzqvoobzawgh\nfeqweodinkhiatqmfokaxwcmlmbmvskssyookgcrax\ntackfosjhxeq... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nA flower shop has got n bouquets, and the i-th bouquet consists of ai flowers. Vasya, the manager of the shop, decided to make large bouquets from these bouquets. \n\nVasya thinks that a bouquet is large if it is made of ... | [{"type": "stdin_stdout", "input": "25\n742168 377547 485672 437223 96307 902863 759104 747933 512899 410317 588598 666688 823202 257684 520631 910066 168864 71499 899972 565350 764848 754913 929040 864132 289976\n", "output": "10\n"}, {"type": "stdin_stdout", "input": "25\n742168 755062 391542 437223 96307 902863 7591... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAarav has just graduated from the university. Now he is going to travel along his country. More precisely: there are N cities with integer coordinates. His plan is to travel between each pair of the cities. \n\nThe distan... | [{"type": "stdin_stdout", "input": "37\n7 -14\n18 -6\n-20 -20\n-15 12\n5 18\n6 7\n-10 -2\n-17 -17\n9 -8\n-14 -16\n12 -4\n17 -2\n-7 -2\n-13 19\n20 -9\n18 5\n19 -4\n3 -4\n-20 1\n9 19\n-14 5\n18 -4\n-18 -8\n-14 2\n-14 14\n20 -19\n-11 6\n18 15\n13 14\n9 -12\n-20 10\n-9 -11\n-19 12\n-16 14\n2 -13\n12 6\n-18 8", "output": "2... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nEach digit of a number is represented by a cluster of adjacent X, with spaces between neighboring clusters. The digit is determined by the number of X in the cluster. For example, the number 243 would be represented by th... | [{"type": "stdin_stdout", "input": "2\n-XX-XXXX-XXX-\n-XX--XXXX---XXX-\n\nSAMPLE", "output": "243\n204003\n"}, {"type": "stdin_stdout", "input": "2\n-XXXXX-X-XXX-\n-XX--XXXX---XXX-\n\nSAMPLE", "output": "513\n204003\n"}, {"type": "stdin_stdout", "input": "2\n-XXXXX-X-XXX-\n-XXX---XXXX--XX-\n\nSAMPLE", "output": "513\n3... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere are N points on the 2D plane, i-th of which is located on (x_i, y_i). There can be multiple points that share the same coordinate. What is the maximum possible Manhattan distance between two distinct points?\n\nHere... | [{"type": "stdin_stdout", "input": "3\n-2 -2\n2 -1\n-29 1", "output": "33\n"}, {"type": "stdin_stdout", "input": "3\n-1 -4\n1 -1\n-23 4", "output": "30\n"}, {"type": "stdin_stdout", "input": "3\n-1 -4\n1 -1\n-23 0", "output": "26\n"}, {"type": "stdin_stdout", "input": "3\n-2 -2\n-2 0\n11 3", "output": "18\n"}, {"type":... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nGiven is an integer N. Find the number of positive integers less than or equal to N that have an odd number of digits (in base ten without leading zeros).\n\nConstraints\n\n* 1 \\leq N \\leq 10^5\n\nInput\n\nInput is give... | [{"type": "stdin_stdout", "input": "100010", "output": "90909\n"}, {"type": "stdin_stdout", "input": "100000", "output": "90909"}, {"type": "stdin_stdout", "input": "339", "output": "249\n"}, {"type": "stdin_stdout", "input": "312", "output": "222\n"}, {"type": "stdin_stdout", "input": "359", "output": "269\n"}, {"type... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given an integer N. Find the number of strings of length N that satisfy the following conditions, modulo 10^9+7:\n\n* The string does not contain characters other than `A`, `C`, `G` and `T`.\n* The string does not... | [{"type": "stdin_stdout", "input": "100", "output": "388130742"}, {"type": "stdin_stdout", "input": "15", "output": "478366600\n"}, {"type": "stdin_stdout", "input": "14", "output": "127504505\n"}, {"type": "stdin_stdout", "input": "20", "output": "580025381\n"}, {"type": "stdin_stdout", "input": "24", "output": "60411... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nWe have a directed weighted graph with N vertices. Each vertex has two integers written on it, and the integers written on Vertex i are A_i and B_i.\n\nIn this graph, there is an edge from Vertex x to Vertex y for all pai... | [{"type": "stdin_stdout", "input": "6\n43 35\n97 26\n77 48\n133 16\n110 5\n154 15", "output": "140\n"}, {"type": "stdin_stdout", "input": "6\n43 35\n97 26\n77 48\n133 31\n110 5\n154 15", "output": "155\n"}, {"type": "stdin_stdout", "input": "6\n43 35\n97 26\n77 48\n133 36\n110 5\n154 15", "output": "160\n"}, {"type": "... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nWe have a long seat of width X centimeters. There are many people who wants to sit here. A person sitting on the seat will always occupy an interval of length Y centimeters.\n\nWe would like to seat as many people as poss... | [{"type": "stdin_stdout", "input": "100010 0 -1", "output": "-100011\n"}, {"type": "stdin_stdout", "input": "100010 1 0", "output": "100010\n"}, {"type": "stdin_stdout", "input": "110010 1 0", "output": "110010\n"}, {"type": "stdin_stdout", "input": "108320 205 44", "output": "434\n"}, {"type": "stdin_stdout", "input":... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere is a frequency operation in the conversion operation of a finite number sequence. The conversion result of the sequence $ S = \\\\ {s_1, s_2, ... s_n \\\\} $ is a sequence of the same length. If the result is $ C = ... | [{"type": "stdin_stdout", "input": "10\n2 5 1 -1 3 4 27 0 -2 6\n0", "output": "2\n10 10 10 10 10 10 10 10 10 10\n"}, {"type": "stdin_stdout", "input": "10\n2 1 0 0 3 5 0 0 0 12\n0", "output": "3\n10 10 10 10 10 10 10 10 10 10\n"}, {"type": "stdin_stdout", "input": "10\n2 5 1 0 3 4 27 0 -2 10\n0", "output": "2\n8 8 8 2 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nMobile phones are equipped with a function that displays input candidates in order to efficiently input texts such as emails. This records frequently used words and presents words that have the entered letters as initial ... | [{"type": "stdin_stdout", "input": "1\nben mikes bananas eht best among many fruits bec`use bananas are sweet and cheao\nb\n1\nwinners get to visit aizu and eht uvinersity of ahuz amd maje amnx friends as wlel\na\n3\nask alex about\nthe answer for the\nassignmdnt pn diordn` `pps\na\n2\ngnimmargorp si both\na sport aod ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nTwo players, A and B, play the game using cards with numbers from 0 to 9. First, the two arrange the given n cards face down in a horizontal row. After that, the two players turn their cards face up one by one from the le... | [{"type": "stdin_stdout", "input": "3\n13 1\n1 4\n1 4\n3\n20 1\n6 7\n1 1\n3\n15 1\n5 5\n1 8\n0", "output": "14 10\n22 14\n21 14\n"}, {"type": "stdin_stdout", "input": "3\n13 1\n1 4\n1 4\n3\n20 1\n6 8\n1 1\n3\n15 1\n5 5\n1 8\n0", "output": "14 10\n22 15\n21 14\n"}, {"type": "stdin_stdout", "input": "3\n13 1\n1 4\n0 4\n3... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nProfessor Random, known for his research on randomized algorithms, is now conducting an experiment on biased dice. His experiment consists of dropping a number of dice onto a plane, one after another from a fixed position... | [{"type": "stdin_stdout", "input": "4\n6 4\n6 4\n6 4\n6 4\n2\n5 3\n5 3\n1\n4 2\n4 2\n4 2\n6 2\n4 2\n4 2\n4 2\n4 2\n6\n4 6\n1 5\n2 3\n6 3\n2 4\n4 2\n0", "output": "0 1 1 0 0 1\n1 0 0 0 1 0\n0 0 0 1 0 0\n2 1 0 0 0 0\n1 0 0 1 0 0\n2 1 1 1 0 0\n"}, {"type": "stdin_stdout", "input": "4\n6 4\n6 4\n6 4\n6 4\n2\n5 3\n5 3\n1\n4... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThe goddess of programming is reviewing a thick logbook, which is a yearly record of visitors to her holy altar of programming. The logbook also records her visits at the altar.\n\nThe altar attracts programmers from all ... | [{"type": "stdin_stdout", "input": "14\n04/21 09:00 I 000\n04/21 09:00 I 001\n04/21 09:15 I 002\n04/21 90:30 O 001\n04/21 09:45 O 000\n12/40 10:00 O 002\n04/28 09:00 I 003\n04/28 09:15 I 000\n04/28 09:30 I 004\n04/28 09:45 P 004\n04/28 10:00 O 000\n04/28 10:15 O 003\n04/29 20:00 I 002\n04/29 21:30 O 002\n20\n06/01 09:0... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nNathan O. Davis is challenging a kind of shooter game. In this game, enemies emit laser beams from outside of the screen. A laser beam is a straight line with a certain thickness. Nathan moves a circular-shaped machine wi... | [{"type": "stdin_stdout", "input": "100 100 1 1\n78 1 50 100 21\n640 295 1 2\n1 -1 640 480 100\n0 0 0 0", "output": "Yes\nYes\n"}, {"type": "stdin_stdout", "input": "100 100 1 0\n78 1 50 100 21\n640 295 1 2\n1 -1 640 480 100\n0 0 0 0", "output": "Yes\nYes\n"}, {"type": "stdin_stdout", "input": "100 100 1 0\n78 1 50 100... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThe range search problem consists of a set of attributed records S to determine which records from S intersect with a given range.\n\nFor n points on a plane, report a set of points which are within in a given range. Note... | [{"type": "stdin_stdout", "input": "6\n0 1\n4 0\n5 0\n6 4\n3 2\n11 6\n2\n-1 4 -1 2\n0 8 0 5", "output": "0\n1\n4\n\n0\n1\n2\n3\n4\n\n"}, {"type": "stdin_stdout", "input": "6\n2 1\n2 2\n4 2\n4 2\n3 3\n5 4\n2\n2 4 0 4\n4 10 2 5", "output": "0\n1\n2\n3\n4\n\n2\n3\n5\n\n"}, {"type": "stdin_stdout", "input": "6\n0 1\n4 2\n5... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nVasya has got a magic matrix a of size n Γ m. The rows of the matrix are numbered from 1 to n from top to bottom, the columns are numbered from 1 to m from left to right. Let a_{ij} be the element in the intersection of t... | [{"type": "stdin_stdout", "input": "13 8\n3 2 1 4 8 2 5 9\n8 2 10 8 9 3 2 8\n3 6 8 3 11 7 6 4\n4 2 10 5 7 5 1 3\n10 9 3 6 4 10 10 2\n10 3 7 1 4 5 7 10\n5 3 1 6 1 10 3 6\n10 7 6 8 1 8 4 1\n7 8 1 10 8 5 3 6\n3 8 10 6 7 6 5 5\n1 5 9 8 4 8 5 10\n6 9 10 7 5 10 5 4\n3 9 2 4 8 2 5 4\n8 1\n", "output": "140693813\n"}, {"type":... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou stumbled upon a new kind of chess puzzles. The chessboard you are given is not necesserily 8 Γ 8, but it still is N Γ N. Each square has some number written on it, all the numbers are from 1 to N^2 and all the numbers... | [{"type": "stdin_stdout", "input": "10\n16 92 81 8 70 28 72 91 87 13\n32 17 93 83 5 69 27 74 89 88\n43 31 22 99 79 4 65 26 71 90\n50 41 29 15 98 80 9 68 24 73\n59 51 38 35 18 96 82 6 67 25\n57 60 49 45 37 19 97 85 7 66\n76 53 61 46 40 36 14 95 86 3\n11 75 55 58 48 44 34 20 94 84\n2 10 77 56 62 52 39 30 23 100\n64 1 12 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou're given an array a. You should repeat the following operation k times: find the minimum non-zero element in the array, print it, and then subtract it from all the non-zero elements of the array. If all the elements a... | [{"type": "stdin_stdout", "input": "50 48\n26 87 99 27 2 2 94 10 21 9 6 7 85 10 66 56 16 55 101 51 16 151 100 28 93 70 33 84 50 87 55 36 93 84 63 94 119 2 42 84 37 54 34 76 38 78 14 21 6 4\n", "output": "2\n2\n2\n1\n2\n1\n4\n2\n5\n5\n1\n1\n5\n1\n2\n1\n1\n4\n8\n1\n3\n1\n1\n7\n3\n4\n6\n2\n6\n1\n2\n6\n1\n5\n1\n1\n18\n32\n... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nToday at the lesson of mathematics, Petya learns about the digital root.\n\nThe digital root of a non-negative integer is the single digit value obtained by an iterative process of summing digits, on each iteration using ... | [{"type": "stdin_stdout", "input": "3\n2 1\n5 6\n4 1\n", "output": "10\n42\n28\n"}, {"type": "stdin_stdout", "input": "3\n2 1\n5 6\n4 2\n", "output": "10\n42\n29\n"}, {"type": "stdin_stdout", "input": "3\n2 3\n5 5\n9 1\n", "output": "12\n41\n73\n"}, {"type": "stdin_stdout", "input": "3\n2 1\n2 6\n4 2\n", "output": "10\... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nFinished her homework, Nastya decided to play computer games. Passing levels one by one, Nastya eventually faced a problem. Her mission is to leave a room, where a lot of monsters live, as quickly as possible.\n\nThere ar... | [{"type": "stdin_stdout", "input": "4291 2145\n", "output": "15017\n"}, {"type": "stdin_stdout", "input": "5000 3378\n", "output": "16622\n"}, {"type": "stdin_stdout", "input": "5000 2653\n", "output": "17347\n"}, {"type": "stdin_stdout", "input": "3068 1534\n", "output": "10737\n"}, {"type": "stdin_stdout", "input": "... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere are n shovels in the nearby shop. The i-th shovel costs a_i bourles.\n\nMisha has to buy exactly k shovels. Each shovel can be bought no more than once.\n\nMisha can buy shovels by several purchases. During one purc... | [{"type": "stdin_stdout", "input": "9 4 8\n12 13 5 1 12 1 2 2 2\n9 4\n8 4\n5 3\n9 7\n", "output": "28\n"}, {"type": "stdin_stdout", "input": "9 4 8\n6 13 5 1 10 1 1 2 1\n9 4\n8 4\n5 3\n9 7\n", "output": "19\n"}, {"type": "stdin_stdout", "input": "9 4 8\n6 13 5 1 12 1 1 2 2\n9 4\n8 4\n5 3\n9 5\n", "output": "21\n"}, {"t... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAuthors guessed an array a consisting of n integers; each integer is not less than 2 and not greater than 2 β
10^5. You don't know the array a, but you know the array b which is formed from it with the following sequence ... | [{"type": "stdin_stdout", "input": "100\n3 3 2 2 3 2 3 2 2 2 2 3 3 2 2 2 2 2 3 3 3 2 3 3 3 2 2 2 3 3 2 3 2 2 3 2 3 2 2 2 3 2 3 3 3 2 3 3 3 2 2 3 3 3 3 3 2 3 2 2 2 3 3 3 2 3 3 3 3 2 2 3 2 3 2 3 2 3 3 2 3 2 3 3 3 2 2 2 2 3 2 2 3 2 3 2 3 3 2 2 3 2 3 3 2 2 2 2 3 2 3 2 2 2 3 3 2 3 3 3 3 2 2 3 2 3 3 2 3 3 3 2 3 2 3 2 2 3 2 2... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nFinally, a basketball court has been opened in SIS, so Demid has decided to hold a basketball exercise session. 2 β
n students have come to Demid's exercise session, and he lined up them into two rows of the same size (th... | [{"type": "stdin_stdout", "input": "100\n1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4\n4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou're given an undirected graph with n nodes and m edges. Nodes are numbered from 1 to n.\n\nThe graph is considered harmonious if and only if the following property holds:\n\n * For every triple of integers (l, m, r) s... | [{"type": "stdin_stdout", "input": "1460 5\n100 300\n200 735\n420 117\n559 450\n435 900\n", "output": "795\n"}, {"type": "stdin_stdout", "input": "1460 5\n101 300\n200 735\n420 117\n559 450\n435 900\n", "output": "794\n"}, {"type": "stdin_stdout", "input": "1460 5\n100 300\n200 735\n420 117\n559 450\n435 460\n", "outpu... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given a non-empty string s=s_1s_2... s_n, which consists only of lowercase Latin letters. Polycarp does not like a string if it contains at least one string \"one\" or at least one string \"two\" (or both at the s... | [{"type": "stdin_stdout", "input": "10\nonetwonetwooneooonetwooo\ntwo\none\ntwooooo\nttttwo\nttwwoo\neoono\nonnne\noneeeee\noneeeeeeetwooooo\n", "output": "6\n2 6 10 13 18 21 \n1\n2 \n1\n2 \n1\n2 \n1\n5 \n0\n\n0\n\n0\n\n1\n2 \n2\n2 11 \n"}, {"type": "stdin_stdout", "input": "10\nonetwonetwooneooonetwooo\nuwo\none\ntwoo... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nIn this problem, we will deal with binary strings. Each character of a binary string is either a 0 or a 1. We will also deal with substrings; recall that a substring is a contiguous subsequence of a string. We denote the ... | [{"type": "stdin_stdout", "input": "50\n01110100101100100100011001100001110010010000000101\n50\n27 18 7\n22 35 2\n50 35 1\n41 16 1\n27 5 5\n11 6 33\n7 19 2\n9 12 33\n14 37 4\n1 22 8\n22 3 5\n50 42 1\n50 38 1\n29 20 2\n20 34 17\n20 4 29\n16 21 3\n11 43 3\n15 45 1\n12 28 3\n31 34 13\n43 1 8\n3 41 1\n18 3 13\n29 44 6\n47 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nUnary is a minimalistic Brainfuck dialect in which programs are written using only one token. \n\nBrainfuck programs use 8 commands: \"+\", \"-\", \"[\", \"]\", \"<\", \">\", \".\" and \",\" (their meaning is not importan... | [{"type": "stdin_stdout", "input": ",]+>.],,+->+>-[]][><,-]><]++<.,-[.>.<+.[.<,[-,,[<]+>]->>]>]-+-+<][].,.]+][[<,-.+][+<<-+.],,,<,.]-].-\n", "output": "859903\n"}, {"type": "stdin_stdout", "input": ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n", "output": "20887... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere is an undirected tree of n vertices, connected by n-1 bidirectional edges. There is also a snake stuck inside of this tree. Its head is at vertex a and its tail is at vertex b. The snake's body occupies all vertices... | [{"type": "stdin_stdout", "input": "4\n8 4 7\n1 2\n2 3\n1 4\n4 5\n4 6\n1 7\n7 8\n4 3 2\n4 3\n1 2\n2 3\n9 3 5\n1 2\n2 3\n3 4\n1 5\n5 6\n6 7\n1 8\n8 9\n16 15 12\n1 2\n2 3\n1 4\n4 5\n5 6\n6 7\n4 8\n10 9\n8 13\n10 11\n11 12\n11 13\n13 14\n10 15\n15 16\n", "output": "YES\nNO\nNO\nYES\n"}, {"type": "stdin_stdout", "input": "... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere is a square of size 10^6 Γ 10^6 on the coordinate plane with four points (0, 0), (0, 10^6), (10^6, 0), and (10^6, 10^6) as its vertices.\n\nYou are going to draw segments on the plane. All segments are either horizo... | [{"type": "stdin_stdout", "input": "3 3\n2 3 1000000\n4 0 4\n3 0 1000000\n4 0 1\n2 0 5\n3 1 1000000\n", "output": "7\n"}, {"type": "stdin_stdout", "input": "3 3\n2 3 1000000\n4 0 4\n3 0 1000000\n4 0 1\n2 0 5\n3 2 1000000\n", "output": "7\n"}, {"type": "stdin_stdout", "input": "3 3\n2 3 1000000\n7 0 4\n3 0 1000000\n4 0 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nFor a given sequence of distinct non-negative integers (b_1, b_2, ..., b_k) we determine if it is good in the following way:\n\n * Consider a graph on k nodes, with numbers from b_1 to b_k written on them.\n * For every... | [{"type": "stdin_stdout", "input": "109\n74 18 237 179 195 112 156 11 72 68 173 202 78 250 224 251 107 55 186 144 57 62 28 210 132 64 93 6 211 0 174 163 248 226 167 246 46 102 253 180 121 56 151 35 150 254 168 201 242 118 190 158 196 30 75 116 187 96 215 244 192 73 12 175 33 222 131 256 181 230 114 165 128 234 63 90 44... | 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 and a positive integer m.\n\nYou should divide elements of this array into some arrays. You can order the elements in the new arrays as you want.\n... | [{"type": "stdin_stdout", "input": "4\n6 6\n2 4 8 22 10 2\n10 16\n1 2 1 2 2 4 5 8 10 7\n1 1\n884\n2 4\n2 4\n", "output": "1\n10\n1\n2\n"}, {"type": "stdin_stdout", "input": "4\n6 5\n1 2 8 3 11 6\n10 13\n1 1 1 6 3 3 4 8 6 13\n1 1\n1131\n2 2\n4 4\n", "output": "4\n10\n1\n1\n"}, {"type": "stdin_stdout", "input": "4\n6 6\n... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere are three cells on an infinite 2-dimensional grid, labeled A, B, and F. Find the length of the shortest path from A to B if: \n\n * in one move you can go to any of the four adjacent cells sharing a side; \n * vis... | [{"type": "stdin_stdout", "input": "7\n\n2 2\n0 3\n-1 2\n\n2 5\n2 2\n0 3\n\n1000 144\n1000 2\n1000 0000\n\n0 2\n3 10\n2 10\n\n0 13\n12 8\n2 10\n\n0 1\n4 1\n1 2\n\n2 413\n0 10\n1 0\n", "output": "3\n3\n142\n11\n17\n4\n405\n"}, {"type": "stdin_stdout", "input": "7\n\n2 2\n1 3\n-1 2\n\n2 5\n2 1\n2 3\n\n1000 144\n1000 1\n1... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nPolycarpus is an amateur programmer. Now he is analyzing a friend's program. He has already found there the function rangeIncrement(l, r), that adds 1 to each element of some array a for all indexes in the segment [l, r].... | [{"type": "stdin_stdout", "input": "20\n5 9 11 12 13 13 13 13 13 13 13 13 13 6 12 11 11 8 6 4\n", "output": "19\n5 13\n4 13\n3 13\n3 13\n2 13\n2 13\n2 13\n15 15\n15 17\n15 17\n15 17\n15 18\n15 18\n2 19\n1 19\n1 20\n1 20\n1 20\n1 20\n"}, {"type": "stdin_stdout", "input": "20\n5 9 11 12 13 13 13 13 13 13 13 13 13 6 12 11... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nPetya and Vasya are tossing a coin. Their friend Valera is appointed as a judge. The game is very simple. First Vasya tosses a coin x times, then Petya tosses a coin y times. If the tossing player gets head, he scores one... | [{"type": "stdin_stdout", "input": "100 100 1 1\n", "output": "4950\n2 1\n3 1\n3 2\n4 1\n4 2\n4 3\n5 1\n5 2\n5 3\n5 4\n6 1\n6 2\n6 3\n6 4\n6 5\n7 1\n7 2\n7 3\n7 4\n7 5\n7 6\n8 1\n8 2\n8 3\n8 4\n8 5\n8 6\n8 7\n9 1\n9 2\n9 3\n9 4\n9 5\n9 6\n9 7\n9 8\n10 1\n10 2\n10 3\n10 4\n10 5\n10 6\n10 7\n10 8\n10 9\n11 1\n11 2\n11 3\... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou have a set of dominoes. Each domino is a rectangular tile with a line dividing its face into two square ends. Can you put all dominoes in a line one by one from left to right so that any two dominoes touched with the ... | [{"type": "stdin_stdout", "input": "96\n1 2\n2 3\n3 4\n4 5\n5 6\n6 1\n1 2\n2 3\n3 4\n4 5\n5 6\n6 1\n1 2\n2 3\n3 4\n4 5\n5 6\n6 1\n1 2\n2 3\n3 4\n4 5\n5 6\n6 1\n1 2\n2 3\n3 4\n4 5\n5 6\n6 1\n1 2\n2 3\n3 4\n4 5\n5 6\n6 1\n1 2\n2 3\n3 4\n4 5\n5 6\n6 1\n1 2\n2 3\n3 4\n4 5\n5 6\n6 1\n1 2\n2 3\n3 4\n4 5\n5 6\n6 1\n1 2\n2 3\n... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nSpecial Agent Smart Beaver works in a secret research department of ABBYY. He's been working there for a long time and is satisfied with his job, as it allows him to eat out in the best restaurants and order the most expe... | [{"type": "stdin_stdout", "input": "1023456789??????????????????????????????????????ABCDIFGHIJ\n", "output": "362880000000000000000000000000000000000000000"}, {"type": "stdin_stdout", "input": "?GJ??\n", "output": "81000\n"}, {"type": "stdin_stdout", "input": "BA?C?\n", "output": "64800\n"}, {"type": "stdin_stdout", "i... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nConsider a table G of size n Γ m such that G(i, j) = GCD(i, j) for all 1 β€ i β€ n, 1 β€ j β€ m. GCD(a, b) is the greatest common divisor of numbers a and b.\n\nYou have a sequence of positive integer numbers a1, a2, ..., ak.... | [{"type": "stdin_stdout", "input": "1000000000000 1000000000000 116\n1587924000 7 2 3 4 5 6 1 56 9 10 1 12 13 2 105 16 1 18 1 620 3 14 1 24 25 26 27 4 203 30 1 32 3 2 5 252 1 2 39 40 1 6 7 4 45 2 1 48 1 350 93 52 1 54 5 8 21 58 1 60 1 2 9 224 65 6 1 4 3 10 7 72 1 2 75 4 1 546 1 80 81 62 1 12 35 2 87 8 1 90 13 28 3 2 5 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nLevko loves tables that consist of n rows and n columns very much. He especially loves beautiful tables. A table is beautiful to Levko if the sum of elements in each row and column of the table equals k.\n\nUnfortunately,... | [{"type": "stdin_stdout", "input": "100 1000\n", "output": "1000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n0 1000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ... | code_stdio |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.