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\nNiwel is a little golden bear. As everyone knows, bears live in forests, but Niwel got tired of seeing all the trees so he decided to move to the city.\n\nIn the city, Niwel took on a job managing bears to deliver goods. ...
[{"type": "stdin_stdout", "input": "7 15 10\n1 3 776124\n6 7 769968\n2 1 797048\n4 3 53774\n2 7 305724\n4 1 963904\n4 6 877656\n4 5 971901\n1 4 803781\n3 1 457050\n3 7 915891\n1 7 8626\n5 7 961155\n3 4 891456\n5 4 756977\n", "output": "1552248.00000000000000000\n"}, {"type": "stdin_stdout", "input": "7 15 10\n1 3 77612...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe map of Berland is a rectangle of the size n × m, which consists of cells of size 1 × 1. Each cell is either land or water. The map is surrounded by the ocean. \n\nLakes are the maximal regions of water cells, connecte...
[{"type": "stdin_stdout", "input": "50 3 4\n***\n*.*\n*.*\n*.*\n***\n***\n*.*\n***\n.**\n***\n..*\n***\n***\n*.*\n***\n*.*\n***\n***\n*.*\n***\n*.*\n*.*\n*.*\n*.*\n***\n*.*\n*.*\n*.*\n*.*\n***\n***\n*.*\n*.*\n*.*\n*.*\n*.*\n***\n***\n***\n*.*\n***\n***\n***\n*.*\n*.*\n*.*\n***\n***\n***\n***\n", "output": "8\n***\n***\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nHongcow is ruler of the world. As ruler of the world, he wants to make it easier for people to travel by road within their own countries.\n\nThe world can be modeled as an undirected graph with n nodes and m edges. k of t...
[{"type": "stdin_stdout", "input": "24 38 2\n4 13\n7 1\n24 1\n2 8\n17 2\n2 18\n22 2\n23 3\n5 9\n21 5\n6 7\n6 19\n6 20\n11 7\n7 20\n13 8\n16 8\n9 10\n14 9\n21 9\n12 10\n10 13\n23 10\n17 11\n11 24\n20 12\n13 16\n13 23\n15 14\n17 14\n14 20\n19 16\n17 20\n17 23\n18 22\n18 23\n22 19\n21 20\n23 24\n", "output": "215\n"}, {"t...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSam has been teaching Jon the Game of Stones to sharpen his mind and help him devise a strategy to fight the white walkers. The rules of this game are quite simple: \n\n * The game starts with n piles of stones indexed f...
[{"type": "stdin_stdout", "input": "124\n34\n44\n21\n55\n1\n36\n53\n31\n58\n59\n11\n40\n20\n32\n43\n48\n16\n5\n35\n20\n21\n36\n15\n2\n11\n56\n58\n2\n40\n47\n29\n21\n4\n21\n1\n25\n51\n55\n17\n40\n56\n35\n51\n1\n34\n18\n54\n44\n1\n43\n16\n28\n21\n14\n57\n53\n29\n44\n59\n54\n47\n21\n43\n41\n11\n37\n30\n4\n39\n47\n40\n50\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nT is a complete binary tree consisting of n vertices. It means that exactly one vertex is a root, and each vertex is either a leaf (and doesn't have children) or an inner node (and has exactly two children). All leaves of...
[{"type": "stdin_stdout", "input": "1125899906842623 1\n1\nUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUULLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLRRRRRRRRRRRRRRRRRRRRRR...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPasha is participating in a contest on one well-known website. This time he wants to win the contest and will do anything to get to the first place!\n\nThis contest consists of n problems, and Pasha solves ith problem in ...
[{"type": "stdin_stdout", "input": "44\n750 672 846 969 981 698 380 587 813 587 156 28 446 917 1550 449 142 764 226 1406 349 622 236 782 416 689 113 325 452 265 585 217 707 50 520 712 1869 275 423 123 175 160 415 528\n4\n869 1568\n1353 1354\n1683 1685\n2532 2540\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou may have heard of the pie rule before. It states that if two people wish to fairly share a slice of pie, one person should cut the slice in half, and the other person should choose who gets which slice. Alice and Bob ...
[{"type": "stdin_stdout", "input": "50\n100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA one-dimensional Japanese crossword can be represented as a binary string of length x. An encoding of this crossword is an array a of size n, where n is the number of segments formed completely of 1's, and ai is the leng...
[{"type": "stdin_stdout", "input": "10 1\n5 78 3 87 4 9 5 8 9 1235\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "10 1\n5 24 3 87 4 9 5 8 9 1235\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "10 1\n5 24 3 0 4 9 5 8 9 1235\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "10 0\n5 24 3 0 4 9...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA newspaper is published in Walrusland. Its heading is s1, it consists of lowercase Latin letters. Fangy the little walrus wants to buy several such newspapers, cut out their headings, glue them one to another in order to...
[{"type": "stdin_stdout", "input": "ehfjaabjfedhddejjfcfijagefhjeahjcddhchahjbagi\nfbfdjbjhibjgjgaaajgdbcfdbhjcajcbbieijhcjgajhgaa\n", "output": "10\n"}, {"type": "stdin_stdout", "input": "ehfjaabjfedhddejjfcfihagefhjeahjcddjchahjbagi\nfbfdjbjhibjgjgaaajgdbcfdbhjcajcbbieijhcjgajhgaa\n", "output": "10\n"}, {"type": "std...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe Resistance is trying to take control over all planets in a particular solar system. This solar system is shaped like a tree. More precisely, some planets are connected by bidirectional hyperspace tunnels in such a way...
[{"type": "stdin_stdout", "input": "10\n4 3\n2 10\n10 1\n5 7\n9 8\n10 6\n5 10\n1 3\n2 9\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "10\n4 1\n2 10\n10 1\n5 7\n3 8\n10 6\n5 9\n1 3\n1 9\n", "output": "5\n"}, {"type": "stdin_stdout", "input": "10\n4 3\n2 10\n10 1\n5 7\n5 8\n10 6\n5 9\n1 3\n1 9\n", "output": "5...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou work in a big office. It is a 9 floor building with an elevator that can accommodate up to 4 people. It is your responsibility to manage this elevator.\n\nToday you are late, so there are queues on some floors already...
[{"type": "stdin_stdout", "input": "50\n7 1\n4 8\n9 3\n9 3\n2 4\n5 9\n1 5\n1 4\n7 6\n4 8\n3 6\n2 8\n5 1\n8 9\n7 4\n7 2\n2 4\n7 9\n8 7\n3 8\n1 7\n4 5\n7 2\n6 4\n6 1\n4 8\n5 6\n4 3\n6 5\n6 4\n6 9\n2 5\n9 3\n3 4\n3 4\n9 3\n7 9\n5 8\n1 6\n5 1\n8 3\n7 4\n1 8\n5 2\n1 7\n6 1\n9 6\n3 1\n6 5\n9 7\n", "output": "274\n"}, {"type"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGiven a string S of length N consisting of only lower-case English alphabets, you will be asked to process Q queries over it . In each query you will be given two lower case characters X and Y. Your task is to find out th...
[{"type": "stdin_stdout", "input": "5\naacbb\n2\na c\na b\n\nSAMPLE", "output": "2\n4\n"}, {"type": "stdin_stdout", "input": "5\naacbb\n2\nb c\na b\n\nSAMPLE", "output": "2\n4\n"}, {"type": "stdin_stdout", "input": "5\naacbb\n2\na b\na b\n\nSAMPLE", "output": "4\n4\n"}, {"type": "stdin_stdout", "input": "5\naacbb\n2\nb...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAbhimanyu simply drew two triangles, as shown in the picture below:\n\nHe says this, Amazing painting 1.\n\nThen he drew two more triangles, as shown in the picture below:\n\nHe says this, Amazing painting 2.\n\nSimilarly...
[{"type": "stdin_stdout", "input": "1\n2\n-5 -12 -1 2 -2 0 -1 -1 1 32 5 -1 -58 1 0 -10 2 -2 -1 2 0 1 0 -1 -1 -11\n\nVNLBPI", "output": "-49\n"}, {"type": "stdin_stdout", "input": "1\n2\n-5 -12 -1 2 -2 0 -1 -1 1 32 5 -1 -89 1 0 -10 2 -2 -1 2 0 1 0 -1 -1 -11\n\nVNLBPI", "output": "-80\n"}, {"type": "stdin_stdout", "input...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nJiva is a self driven car and is out on its very first drive. It aims to earn some revenue by serving as taxi driver.\nIt starts its journey from a point and travels in a line for 100 Km. It picks and drops passenger on t...
[{"type": "stdin_stdout", "input": "10\n1000 218\n4 34\n98 98\n82 97\n65 66\n40 60\n92 98\n22 43\n94 97\n76 96\n39 64\n26 99\n88 90\n49 75\n90 92\n41 72\n94 96\n49 75\n67 94\n85 88\n42 97\n31 73\n18 23\n91 95\n14 48\n18 59\n39 96\n25 45\n60 85\n25 57\n43 87\n46 71\n78 100\n57 81\n94 96\n34 86\n29 51\n26 87\n66 86\n26 6...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nChester Bennington, being a skinny kid as we all know, is always bullied since he was a child. This time its just unacceptable. Mike Shinoda, the second vocalist to his band, tried to bully him. Chester was never a bright...
[{"type": "stdin_stdout", "input": "30\n4799\n3797\n2237\n7963\n4993\n8431\n1091\n3181\n659\n4931\n1531\n8231\n7211\n1741\n2297\n4073\n191\n6703\n9949\n9059\n6269\n6481\n6883\n5653\n1877\n9463\n4243\n5659\n3623\n5449", "output": "5 7 13 19 31 43 61 73 103 109 139 151 181 193 199 229 241 271 283 313 349 421 433 463 523 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAgon Packers and Movers specialize in moving large number luggages from one place to another.\n\nThe luggages are packed by the Packers, and after they're done with the job, the Movers take over.\n\nFirst, the Packers put...
[{"type": "stdin_stdout", "input": "11\n250\n344 269 1731 643 897 539 640 337 759 64 279 250 936 121 886 781 1266 124 864 737 802 401 381 1034 86 988 199 134 38 520 656 970 514 457 912 871 1195 173 452 756 712 503 390 1113 656 704 750 5 845 713 7 48 50 819 576 711 1404 121 325 873 24 406 724 165 619 440 204 768 990 434...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a string of length N. Calculate the number of distinct substrings of S.\n\nConstraints\n\n* 1 \\leq N \\leq 500,000\n* S consists of lowercase English letters.\n\nInput\n\nInput is given from Standard Input ...
[{"type": "stdin_stdout", "input": "mjssissippi", "output": "57\n"}, {"type": "stdin_stdout", "input": "mjssisrippi", "output": "61\n"}, {"type": "stdin_stdout", "input": "mjssisripph", "output": "62\n"}, {"type": "stdin_stdout", "input": "hppirsitsjm", "output": "63\n"}, {"type": "stdin_stdout", "input": "mjsthspiroh"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGiven is an integer S. Find a combination of six integers X_1,Y_1,X_2,Y_2,X_3, and Y_3 that satisfies all of the following conditions:\n\n* 0 \\leq X_1,Y_1,X_2,Y_2,X_3,Y_3 \\leq 10^9\n* The area of the triangle in a two-d...
[{"type": "stdin_stdout", "input": "311114770564041497", "output": "314159265 358979323 846264338 327950288 419716939 937510582"}, {"type": "stdin_stdout", "input": "158461871566595116", "output": "0 0 1000000000 1 433404884 158461872\n"}, {"type": "stdin_stdout", "input": "186455597317386972", "output": "0 0 100000000...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA serious incident happened at Taro's house, which loves steamed buns. One of the three steamed buns offered at the Buddhist altar in the Japanese-style room was gone. When Taro, who was aiming for a snack someday, starte...
[{"type": "stdin_stdout", "input": "6\n7\n1 4\n0 2\n2 6\n22 -1\n1 2\n0 0\n1 6", "output": "1\n2\n6\n5\n4\n3\n"}, {"type": "stdin_stdout", "input": "6\n7\n5 2\n0 2\n0 5\n22 3\n0 6\n0 4\n0 4", "output": "6\n5\n4\n3\n2\n1\n"}, {"type": "stdin_stdout", "input": "6\n7\n5 4\n0 2\n1 5\n22 3\n0 6\n0 0\n0 4", "output": "6\n1\n5...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTo get on the Shinkansen, you need two tickets, a \"ticket\" and a \"limited express ticket\". These are separate tickets because some of the routes may not use the Shinkansen, but for routes that use only the Shinkansen,...
[{"type": "stdin_stdout", "input": "0 0 0", "output": "Close\n"}, {"type": "stdin_stdout", "input": "1 0 0", "output": "Close\n"}, {"type": "stdin_stdout", "input": "0 1 0", "output": "Close\n"}, {"type": "stdin_stdout", "input": "0 0 0", "output": "Close\n"}, {"type": "stdin_stdout", "input": "0 1 0", "output": "Close...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nproblem\n\nYou are in charge of quality control at a machine manufacturing plant. This machine requires a power supply, a motor, and a cable as parts. The manufacturing plant has a power supply, b motors, and c cables, nu...
[{"type": "stdin_stdout", "input": "2 2 8\n4\n1 1 1 0\n5 3 4 0\n1 4 0 0\n1 3 0 0\n0 0 0", "output": "2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n"}, {"type": "stdin_stdout", "input": "1 2 8\n4\n4 1 1 0\n5 0 5 0\n-1 4 0 0\n1 3 2 0\n0 0 0", "output": "2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n"}, {"type": "stdin_stdout", "input": "4 2 4\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn order to participate in the Asian Regional Qualifiers of the International Collegiate Programming Contest held every year in Japan, we must break through the strict domestic qualifiers.\n\nEven though it is a universit...
[{"type": "stdin_stdout", "input": "6\n1 1 6 200\n2 1 11 300\n3 0 1 400\n4 0 5 1200\n5 0 5 1674\n10 4 4 6\n3\n1015 1 5 84\n1343 2 4 20\n123 3 6 500\n2\n4 1 3 100\n1 1 1 100\n0", "output": "2\n1\n4\n5\n10\n3\n123\n1015\n1343\n4\n1\n"}, {"type": "stdin_stdout", "input": "6\n1 1 6 200\n2 1 11 300\n3 0 1 400\n4 0 5 1200\n5...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTax Rate Changed\n\nVAT (value-added tax) is a tax imposed at a certain rate proportional to the sale price.\n\nOur store uses the following rules to calculate the after-tax prices.\n\n* When the VAT rate is x%, for an it...
[{"type": "stdin_stdout", "input": "5 8 105\n8 5 105\n1 2 24\n99 98 24\n12 13 26\n1 22 23\n1 19 201\n13 16 112\n2 24 50\n1 82 61\n1 84 125\n1 99 999\n99 1 3106\n98 99 999\n1 99 11\n99 2 12\n0 0 0", "output": "109\n103\n24\n24\n26\n27\n237\n116\n62\n111\n230\n1972\n1576\n1004\n20\n7\n"}, {"type": "stdin_stdout", "input"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWe will define Ginkgo numbers and multiplication on Ginkgo numbers.\n\nA Ginkgo number is a pair <m, n> where m and n are integers. For example, <1, 1>, <-2, 1> and <-3,-1> are Ginkgo numbers.\n\nThe multiplication on Gin...
[{"type": "stdin_stdout", "input": "8\n10 -1\n-2 12\n1 3\n6 -1\n1 -40\n-8 0\n-4 1\n2 -1", "output": "P\nC\nC\nP\nP\nC\nP\nP\n"}, {"type": "stdin_stdout", "input": "8\n10 -1\n0 2\n-1 2\n4 0\n0 -25\n-4 0\n-2 -1\n2 -1", "output": "P\nC\nP\nC\nC\nC\nP\nP\n"}, {"type": "stdin_stdout", "input": "8\n10 -1\n-1 4\n0 3\n6 -1\n2 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nBackground\n\nThe site of Mr. A's house, which lives in a certain city, is surrounded by white walls. Feeling unsatisfied with the wall, Mr. A decided to invite the children in the neighborhood to paint the wall freely. A...
[{"type": "stdin_stdout", "input": "10 3\n0 1\n7 1\n13 2", "output": "2 1\n1 2\n"}, {"type": "stdin_stdout", "input": "10 3\n0 1\n4 1\n9 2", "output": "2 1\n1 1\n"}, {"type": "stdin_stdout", "input": "8 3\n4 1\n8 1\n11 3", "output": "3 1\n1 1\n"}, {"type": "stdin_stdout", "input": "10 3\n0 1\n4 1\n9 4", "output": "4 1\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nEverlasting Sa-Ga, a new, hot and very popular role-playing game, is out on October 19, 2008. Fans have been looking forward to a new title of Everlasting Sa-Ga.\n\nLittle Jimmy is in trouble. He is a seven-year-old boy, ...
[{"type": "stdin_stdout", "input": "10 24\n30 20\n0 0", "output": "a\nb\n"}, {"type": "stdin_stdout", "input": "19 24\n30 20\n0 0", "output": "a\nb\n"}, {"type": "stdin_stdout", "input": "10 3\n11 106\n0 0", "output": "b\nb\n"}, {"type": "stdin_stdout", "input": "10 3\n11 150\n0 0", "output": "b\na\n"}, {"type": "stdin...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWhen Mr. Kay was browsing a certain SNS as usual, the problem that \"there are people who can solve IQ150 or more\" came to the timeline. Mr. Kay has an IQ of over 150, so he solved the problem in an instant without even ...
[{"type": "stdin_stdout", "input": "2286", "output": "3\n"}, {"type": "stdin_stdout", "input": "1020", "output": "2\n"}, {"type": "stdin_stdout", "input": "1809", "output": "1\n"}, {"type": "stdin_stdout", "input": "2465", "output": "0\n"}, {"type": "stdin_stdout", "input": "4598", "output": "2\n"}, {"type": "stdin_std...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nJAG mock qualifying practice session\n\nThe ACM-ICPC OB / OG Association (Japanese Alumni Group; JAG) has N questions in stock of questions to be asked in the mock contest, and each question is numbered with an integer fr...
[{"type": "stdin_stdout", "input": "5 3\n1 1\n2 3\n3 2\n3 17\n2 1\n4 2\n1 7\n2 1\n1 3\n2 5\n6 1\n1 3\n1 2\n1 8\n1 2\n1 7\n1 6\n20 9\n4 10\n2 6\n8 3\n1 6\n6 3\n7 4\n8 10\n4 12\n7 5\n1 8\n5 7\n1 5\n4 6\n9 9\n5 8\n6 7\n1 4\n6 4\n7 10\n3 5\n19 6\n4 2\n6 5\n5 10\n1 10\n3 10\n3 6\n2 3\n1 4\n2 10\n1 8\n3 4\n3 1\n5 4\n1 10\n1 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAuction\n\nsquare1001 You were watching a certain auction.\n\nAn auction is a transaction in which when there are a large number of buyers and the number of items is limited, the one with the highest price is given the ri...
[{"type": "stdin_stdout", "input": "5\n-1 -1 -2 -2 3", "output": "4\n5\n"}, {"type": "stdin_stdout", "input": "5\n-1 -1 -3 -2 3", "output": "3\n5\n"}, {"type": "stdin_stdout", "input": "5\n-1 -1 -3 -1 3", "output": "3\n5\n"}, {"type": "stdin_stdout", "input": "5\n-1 -1 -6 -1 3", "output": "3\n5\n"}, {"type": "stdin_std...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFor a given array $a_1, a_2, a_3, ... , a_N$ of $N$ elements and an integer $L$, find the minimum of each possible sub-arrays with size $L$ and print them from the beginning. For example, for an array $\\\\{1, 7, 7, 4, 8,...
[{"type": "stdin_stdout", "input": "8 1\n1 1 1 4 1 2 12", "output": "1 1 1 4 1 2 12 0\n"}, {"type": "stdin_stdout", "input": "8 1\n1 1 1 4 1 3 12", "output": "1 1 1 4 1 3 12 0\n"}, {"type": "stdin_stdout", "input": "8 1\n0 1 1 4 1 3 12", "output": "0 1 1 4 1 3 12 0\n"}, {"type": "stdin_stdout", "input": "8 1\n0 1 1 4 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe Head Chef has received his id from the Association of Byteland . He wants to know the numerical rank of his number among the numbers that can be formed by the exact same digits ( i.e. among numbers having same number ...
[{"type": "stdin_stdout", "input": "2\n1580\n1100", "output": "10\n6\n"}, {"type": "stdin_stdout", "input": "2\n1580\n1000", "output": "10\n4\n"}, {"type": "stdin_stdout", "input": "2\n1218\n6547", "output": "3\n15\n"}, {"type": "stdin_stdout", "input": "2\n276\n1240", "output": "2\n10\n"}, {"type": "stdin_stdout", "in...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPanic is rising in the committee for doggo standardization — the puppies of the new brood have been born multi-colored! In total there are 26 possible colors of puppies in the nature and they are denoted by letters from '...
[{"type": "stdin_stdout", "input": "27\nabcdefghijklmnopqrstuvwxyza\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "27\nmnpsweykjdvaxyiqtgcuzhbfrlo\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "27\nazyxwvutsrqponmlkjihgfedcba\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "27\nmbpswey...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA conglomerate consists of n companies. To make managing easier, their owners have decided to merge all companies into one. By law, it is only possible to merge two companies, so the owners plan to select two companies, m...
[{"type": "stdin_stdout", "input": "20\n1 1228\n7 957 657 854 608 621 874 617\n6 159 43 19 122 116 194\n7 813 984 847 953 808 801 900\n2 693 844\n12 903 910 764 949 990 959 987 884 876 743 838 1017\n1 636\n8 107 201 935 203 159 67 550 948\n1 919\n14 934 742 1000 707 801 958 889 980 799 841 927 676 918 841\n7 590 569 48...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou went to the store, selling n types of chocolates. There are a_i chocolates of type i in stock.\n\nYou have unlimited amount of cash (so you are not restricted by any prices) and want to buy as many chocolates as possi...
[{"type": "stdin_stdout", "input": "19\n11 10 2 12 1 1 9 13 8 40 16 27 18 22 33 1 14 32 12\n", "output": "34\n"}, {"type": "stdin_stdout", "input": "19\n11 10 2 12 1 1 9 13 8 40 8 27 18 22 33 1 14 32 12\n", "output": "34\n"}, {"type": "stdin_stdout", "input": "19\n11 10 6 11 2 1 6 13 8 38 8 27 9 22 18 7 14 20 12\n", "o...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given two integers x and y (it is guaranteed that x > y). You may choose any prime integer p and subtract it any number of times from x. Is it possible to make x equal to y?\n\nRecall that a prime number is a posi...
[{"type": "stdin_stdout", "input": "69\n2 1\n2 1\n2 1\n2 1\n2 1\n2 1\n2 1\n2 1\n2 1\n2 1\n2 1\n2 1\n2 1\n2 1\n2 1\n2 1\n2 1\n2 1\n2 1\n4 1\n2 1\n2 1\n2 1\n2 1\n2 1\n2 1\n2 1\n2 1\n2 1\n2 1\n2 1\n2 1\n2 1\n2 1\n2 1\n2 1\n2 1\n2 1\n2 1\n2 1\n2 1\n2 1\n2 1\n2 1\n2 1\n2 1\n2 1\n2 1\n2 1\n2 1\n2 1\n2 1\n2 1\n2 1\n2 1\n2 1\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a permutation of length n. Recall that the permutation is an array consisting of n distinct integers from 1 to n in arbitrary order. For example, [2, 3, 1, 5, 4] is a permutation, but [1, 2, 2] is not a perm...
[{"type": "stdin_stdout", "input": "4\n5\n5 4 1 3 2\n4\n1 2 4 3\n1\n1\n4\n4 3 2 1\n", "output": "1 5 2 4 3 \n1 2 3 4 \n1 \n1 4 3 2 \n"}, {"type": "stdin_stdout", "input": "4\n5\n5 4 1 3 2\n4\n1 2 4 3\n1\n1\n4\n4 3 1 2\n", "output": "1 5 2 4 3\n1 2 3 4\n1\n1 4 2 3\n"}, {"type": "stdin_stdout", "input": "4\n5\n5 4 1 3 2\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere is a very secret base in Potatoland where potato mash is made according to a special recipe. The neighbours from Porridgia decided to seize this recipe and to sell it to Pilauland. For this mission they have been pr...
[{"type": "stdin_stdout", "input": "XX.\n...\n.XX\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "...\nX.X\n...\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "X.X\n.X.\nX.X\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "...\nXXX\n...\n", "output": "YES\n"}, {"type": "stdin_stdout", "i...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA bracketed sequence is called correct (regular) if by inserting \"+\" and \"1\" you can get a well-formed mathematical expression from it. For example, sequences \"(())()\", \"()\" and \"(()(()))\" are correct, while \")...
[{"type": "stdin_stdout", "input": "100\n)()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()(\n", "output": "100\n"}, {"type": "stdin_stdout", "input": "101\n(())))))()))()())(()))((())))((())(()()()(()()((()()((()((())))((()))()(())(()(())((()))(()))()(((()(\n", "output"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGiven a permutation p of length n, find its subsequence s_1, s_2, …, s_k of length at least 2 such that:\n\n * |s_1-s_2|+|s_2-s_3|+…+|s_{k-1}-s_k| is as big as possible over all subsequences of p with length at least 2. ...
[{"type": "stdin_stdout", "input": "2\n3\n3 4 1\n4\n1 12 4 6\n", "output": "3\n3 4 1\n4\n1 12 4 6\n"}, {"type": "stdin_stdout", "input": "2\n3\n3 4 1\n4\n1 12 3 6\n", "output": "3\n3 4 1\n4\n1 12 3 6\n"}, {"type": "stdin_stdout", "input": "2\n3\n5 14 1\n4\n1 5 16 2\n", "output": "3\n5 14 1\n3\n1 16 2\n"}, {"type": "std...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nNote that the only difference between String Transformation 1 and String Transformation 2 is in the move Koa does. In this version the letter y Koa selects must be strictly greater alphabetically than x (read statement fo...
[{"type": "stdin_stdout", "input": "10\n1\na\nb\n1\nb\na\n3\nabc\ndef\n1\nt\nt\n2\nrt\ntr\n2\nrt\ntt\n2\nrt\nrr\n3\nasd\nqrt\n1\ns\nt\n1\nr\nt\n", "output": "1\n-1\n3\n0\n-1\n1\n-1\n-1\n1\n1\n"}, {"type": "stdin_stdout", "input": "10\n1\na\nb\n1\nb\na\n3\nacb\ndef\n1\nt\nt\n2\nrt\ntr\n2\nrt\ntt\n2\nrt\nrr\n3\nasd\nqrt\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an array of n integers a_1,a_2,...,a_n.\n\nYou have to create an array of n integers b_1,b_2,...,b_n such that: \n\n * The array b is a rearrangement of the array a, that is, it contains the same values and...
[{"type": "stdin_stdout", "input": "1\n50\n-27 27 -27 27 -27 27 -27 27 -27 27 -27 27 -27 27 -27 27 -27 27 -27 27 -27 27 -27 27 -27 27 -27 27 -27 27 -27 27 -27 27 -27 27 -27 27 -6 27 -27 27 -27 27 -27 -4 -27 -47 -27 27\n", "output": "YES\n-47 -27 -27 -27 -27 -27 -27 -27 -27 -27 -27 -27 -27 -27 -27 -27 -27 -27 -27 -27 -2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA string b is a subsequence of a string a if b can be obtained from a by deletion of several (possibly, zero or all) characters. For example, \"xy\" is a subsequence of \"xzyw\" and \"xy\", but not \"yx\".\n\nYou are give...
[{"type": "stdin_stdout", "input": "1\n200\ntbyrguruybtgtybugryrtbugbrgyutruygbtyrgtubrtgybubguytrbtyrugtyugrbuygrtbtrguybybrutgtbgurybygrtugytubrtuyrbgytbugrtrgyburtbygubygtrurbugyttuygbrutbgyrubgrtytugybrytbgurugrbtygtybrurbygutrtgbyubuyrtgrb\n", "output": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbgggggggggggggggggggggggggg...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nNote that the memory limit is unusual.\n\nYou are given an integer n and two sequences a_1, a_2, ..., a_n and b_1, b_2, ..., b_n.\n\nLet's call a set of integers S such that S ⊆ \\{1, 2, 3, ..., n\\} strange, if, for ever...
[{"type": "stdin_stdout", "input": "20\n27 6 6 60 47 97 62 25 67 28 41 93 65 32 16 56 57 53 66 61\n84392 -11227 -93200 -52089 4854 -99982 -81560 95957 -35579 -91088 31023 -68447 -41338 -27132 43558 23876 35055 -36267 77633 -94930\n", "output": "294839\n"}, {"type": "stdin_stdout", "input": "20\n27 6 6 60 47 97 62 25 67...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWhat joy! Petya's parents went on a business trip for the whole year and the playful kid is left all by himself. Petya got absolutely happy. He jumped on the bed and threw pillows all day long, until... \n\nToday Petya op...
[{"type": "stdin_stdout", "input": "100\n100 100 100 100 100 100 100 100 100 100 100 100\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "100\n100 100 100 100 110 100 100 100 100 100 100 100\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "100\n100 100 100 100 110 100 100 100 100 100 101 100\n", "output...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\n<image>\n\nWilliam really likes the cellular automaton called \"Game of Life\" so he decided to make his own version. For simplicity, William decided to define his cellular automaton on an array containing n cells, with e...
[{"type": "stdin_stdout", "input": "4\n10 1\n1111111111\n9 4\n000000000\n9 4\n000000000\n9 4\n000000000\n", "output": "1111111111\n000000000\n000000000\n000000000\n"}, {"type": "stdin_stdout", "input": "4\n10 1\n1111111111\n9 4\n010000000\n9 4\n000000000\n9 4\n000000000\n", "output": "1111111111\n111111000\n000000000\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe Smart Beaver from ABBYY decided to have a day off. But doing nothing the whole day turned out to be too boring, and he decided to play a game with pebbles. Initially, the Beaver has n pebbles. He arranges them in a eq...
[{"type": "stdin_stdout", "input": "1000000000\n", "output": "1998535156\n"}, {"type": "stdin_stdout", "input": "1000001000\n", "output": "1906011808\n"}, {"type": "stdin_stdout", "input": "1549355491\n", "output": "1559780582\n"}, {"type": "stdin_stdout", "input": "1292236879\n", "output": "1292236880\n"}, {"type": "s...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nQwerty the Ranger took up a government job and arrived on planet Mars. He should stay in the secret lab and conduct some experiments on bacteria that have funny and abnormal properties. The job isn't difficult, but the sa...
[{"type": "stdin_stdout", "input": "1000000 1000000 1000000 1000000\n", "output": "1000000\n"}, {"type": "stdin_stdout", "input": "1000000 1001000 1000000 1000000\n", "output": "1000000\n"}, {"type": "stdin_stdout", "input": "100000 100000 1000010 1000000\n", "output": "1000009\n"}, {"type": "stdin_stdout", "input": "1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe Little Elephant loves numbers. \n\nHe has a positive integer x. The Little Elephant wants to find the number of positive integers d, such that d is the divisor of x, and x and d have at least one common (the same) dig...
[{"type": "stdin_stdout", "input": "1010000000\n", "output": "117\n"}, {"type": "stdin_stdout", "input": "1011000000\n", "output": "171\n"}, {"type": "stdin_stdout", "input": "654885000\n", "output": "698\n"}, {"type": "stdin_stdout", "input": "1000000000\n", "output": "91\n"}, {"type": "stdin_stdout", "input": "101871...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIahub is a big fan of tourists. He wants to become a tourist himself, so he planned a trip. There are n destinations on a straight road that Iahub wants to visit. Iahub starts the excursion from kilometer 0. The n destina...
[{"type": "stdin_stdout", "input": "50\n3987477 8934938 4067156 6712855 7269334 5039822 9533601 9335400 5992073 2619268 438734 8620973 4347619 4307947 2249161 815221 7615258 8244100 8341666 5908546 6646952 4812769 6215114 7479369 6290438 5623785 6466133 9953199 3525873 4326034 3510072 8117068 2342953 1717542 9766539 65...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFox Ciel wants to write a task for a programming contest. The task is: \"You are given a simple undirected graph with n vertexes. Each its edge has unit length. You should calculate the number of shortest paths between ve...
[{"type": "stdin_stdout", "input": "2691939\n", "output": "277\nNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe hero of the Cut the Rope game is a little monster named Om Nom. He loves candies. And what a coincidence! He also is the hero of today's problem.\n\n<image>\n\nOne day, Om Nom visited his friend Evan. Evan has n candi...
[{"type": "stdin_stdout", "input": "10 2\n0 2 3\n1 5 2\n0 7 3\n1 15 2\n0 14 3\n1 19 1\n1 5 3\n0 2 2\n0 10 2\n0 10 3\n", "output": "9"}, {"type": "stdin_stdout", "input": "10 2\n0 2 3\n1 5 2\n0 7 3\n1 15 2\n0 3 3\n1 19 1\n1 5 3\n0 2 2\n0 10 2\n0 10 3\n", "output": "9\n"}, {"type": "stdin_stdout", "input": "7 1\n0 1 99\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nStudent Valera is an undergraduate student at the University. His end of term exams are approaching and he is to pass exactly n exams. Valera is a smart guy, so he will be able to pass any exam he takes on his first try. ...
[{"type": "stdin_stdout", "input": "1\n1001000000 999999999\n", "output": "999999999\n"}, {"type": "stdin_stdout", "input": "1\n1101010000 523461264\n", "output": "523461264\n"}, {"type": "stdin_stdout", "input": "1\n1101000000 193606579\n", "output": "193606579\n"}, {"type": "stdin_stdout", "input": "1\n1101000000 142...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOhana Matsumae is trying to clean a room, which is divided up into an n by n grid of squares. Each square is initially either clean or dirty. Ohana can sweep her broom over columns of the grid. Her broom is very strange: ...
[{"type": "stdin_stdout", "input": "20\n10101011101000011010\n11111010001100110101\n01011100010000001111\n10110100000101010011\n11010001110111101101\n00100110011011101010\n01000110101011001100\n01101100111101101101\n10111010010100111100\n00010010110001101110\n10111110010000101010\n10010111110100100100\n1101011100111111...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nKefa decided to make some money doing business on the Internet for exactly n days. He knows that on the i-th day (1 ≤ i ≤ n) he makes ai money. Kefa loves progress, that's why he wants to know the length of the maximum no...
[{"type": "stdin_stdout", "input": "100\n1 838 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 605 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 10...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOne day student Vasya was sitting on a lecture and mentioned a string s1s2... sn, consisting of letters \"a\", \"b\" and \"c\" that was written on his desk. As the lecture was boring, Vasya decided to complete the picture...
[{"type": "stdin_stdout", "input": "15 84\n11 9\n3 11\n13 10\n2 12\n5 9\n1 7\n14 4\n14 2\n14 1\n11 8\n1 8\n14 10\n4 15\n10 5\n5 12\n13 11\n6 14\n5 7\n12 11\n9 1\n10 15\n2 6\n7 15\n14 9\n9 7\n11 14\n8 15\n12 7\n13 6\n2 9\n9 6\n15 3\n12 15\n6 15\n4 6\n4 1\n9 12\n10 7\n6 1\n11 10\n2 3\n5 2\n13 2\n13 3\n12 6\n4 3\n5 8\n12 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nEvery summer Vitya comes to visit his grandmother in the countryside. This summer, he got a huge wart. Every grandma knows that one should treat warts when the moon goes down. Thus, Vitya has to catch the moment when the ...
[{"type": "stdin_stdout", "input": "92\n13 12 11 10 9 8 7 6 5 4 3 2 1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 14 13 12\n", "output": "DOWN"}, {"type": "stdin_stdout", "input": "92\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasya has an array a consisting of positive integer numbers. Vasya wants to divide this array into two non-empty consecutive parts (the prefix and the suffix) so that the sum of all elements in the first part equals to th...
[{"type": "stdin_stdout", "input": "100\n27 95 57 29 91 85 83 36 72 86 39 5 79 61 78 93 100 97 73 23 82 66 41 92 38 92 100 96 48 23 66 47 5 32 69 13 95 23 46 62 99 83 57 66 98 82 81 57 37 37 81 64 45 76 72 43 99 76 86 22 37 39 93 80 99 36 53 83 3 32 52 9 78 34 47 100 33 72 19 40 29 56 77 32 79 72 15 88 100 98 56 50 22 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPetya learned a new programming language CALPAS. A program in this language always takes one non-negative integer and returns one non-negative integer as well.\n\nIn the language, there are only three commands: apply a bi...
[{"type": "stdin_stdout", "input": "10\n^ 160\n& 1021\n& 510\n^ 470\n& 1022\n& 251\n& 760\n& 1016\n| 772\n| 515\n", "output": "3\n& 1023\n| 775\n^ 112\n"}, {"type": "stdin_stdout", "input": "10\n^ 218\n& 150\n| 935\n& 61\n| 588\n& 897\n| 411\n| 584\n^ 800\n| 704\n", "output": "3\n& 763\n| 763\n^ 0\n"}, {"type": "stdin_...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an undirected graph with n vertices. There are no edge-simple cycles with the even length in it. In other words, there are no cycles of even length that pass each edge at most once. Let's enumerate vertices ...
[{"type": "stdin_stdout", "input": "12 12\n5 1\n5 11\n1 11\n8 11\n8 9\n5 12\n6 9\n7 11\n9 3\n9 10\n4 12\n10 2\n78\n1 1\n1 2\n1 3\n1 4\n1 5\n1 6\n1 7\n1 8\n1 9\n2 10\n1 11\n1 12\n2 2\n2 3\n2 4\n2 5\n2 6\n2 7\n2 8\n3 9\n2 10\n2 11\n2 12\n3 3\n3 4\n3 5\n3 6\n4 7\n3 8\n3 9\n3 10\n3 11\n3 12\n4 4\n4 5\n4 6\n4 7\n4 8\n4 10\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are n cities and m roads in Berland. Each road connects a pair of cities. The roads in Berland are one-way.\n\nWhat is the minimum number of new roads that need to be built to make all the cities reachable from the ...
[{"type": "stdin_stdout", "input": "39 40 38\n4 8\n24 28\n16 17\n7 25\n4 29\n34 35\n16 24\n21 10\n23 36\n36 14\n28 16\n34 19\n15 21\n22 38\n22 37\n37 27\n28 33\n3 29\n32 22\n12 30\n9 15\n5 19\n23 27\n19 17\n25 17\n24 11\n39 10\n6 20\n16 6\n3 18\n34 21\n15 38\n11 19\n11 3\n32 4\n15 13\n16 11\n11 7\n33 7\n3 33\n", "outpu...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are N cities numbered 1 through N, and M bidirectional roads numbered 1 through M. Road i connects City A_i and City B_i.\n\nSnuke can perform the following operation zero or more times:\n\n* Choose two distinct cit...
[{"type": "stdin_stdout", "input": "103 1\n6 8", "output": "101\n"}, {"type": "stdin_stdout", "input": "164 1\n6 8", "output": "162\n"}, {"type": "stdin_stdout", "input": "109 1\n5 9", "output": "107\n"}, {"type": "stdin_stdout", "input": "56 1\n12 11", "output": "54\n"}, {"type": "stdin_stdout", "input": "129 1\n4 6",...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a string S of length N consisting of lowercase English letters, and an integer K. Print the string obtained by replacing every character in S that differs from the K-th character of S, with `*`.\n\nConstrain...
[{"type": "stdin_stdout", "input": "9\nedtbiuaon\n-2", "output": "******a**\n"}, {"type": "stdin_stdout", "input": "9\neducation\n4", "output": "***c*****\n"}, {"type": "stdin_stdout", "input": "9\nedubation\n4", "output": "***b*****\n"}, {"type": "stdin_stdout", "input": "9\nedubation\n6", "output": "*****t***\n"}, {"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere is a string S consisting of digits `1`, `2`, ..., `9`. Lunlun, the Dachshund, will take out three consecutive digits from S, treat them as a single integer X and bring it to her master. (She cannot rearrange the dig...
[{"type": "stdin_stdout", "input": "1110111111", "output": "642\n"}, {"type": "stdin_stdout", "input": "1011001000", "output": "643\n"}, {"type": "stdin_stdout", "input": "1010001010", "output": "652\n"}, {"type": "stdin_stdout", "input": "1000100100", "output": "653\n"}, {"type": "stdin_stdout", "input": "1111111111",...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are three positive integers A, B and C written on a blackboard. E869120 performs the following operation K times:\n\n* Choose one integer written on the blackboard and let the chosen integer be n. Replace the chosen...
[{"type": "stdin_stdout", "input": "-1 0 -1\n-1", "output": "-2.0\n"}, {"type": "stdin_stdout", "input": "-1 0 0\n-1", "output": "-1.0\n"}, {"type": "stdin_stdout", "input": "13 5 21\n2", "output": "102\n"}, {"type": "stdin_stdout", "input": "12 10 25\n0", "output": "47\n"}, {"type": "stdin_stdout", "input": "5 8 2\n10...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSnuke has N dogs and M monkeys. He wants them to line up in a row.\n\nAs a Japanese saying goes, these dogs and monkeys are on bad terms. (\"ken'en no naka\", literally \"the relationship of dogs and monkeys\", means a re...
[{"type": "stdin_stdout", "input": "001010 001011", "output": "931093537\n"}, {"type": "stdin_stdout", "input": "000101 000101", "output": "414723868\n"}, {"type": "stdin_stdout", "input": "000110 000111", "output": "399920258\n"}, {"type": "stdin_stdout", "input": "001111 001110", "output": "292820538\n"}, {"type": "s...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDolphin resides in two-dimensional Cartesian plane, with the positive x-axis pointing right and the positive y-axis pointing up.\nCurrently, he is located at the point (sx,sy). In each second, he can move up, down, left o...
[{"type": "stdin_stdout", "input": "-49 -32 -1 -4", "output": "UUUUUUUUUUUUUUUUUUUUUUUUUUUURRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRDDDDDDDDDDDDDDDDDDDDDDDDDDDDLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLUUUUUUUUUUUUUUUUUUUUUUUUUUUUURRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRDRDDDDDDDDDDDDDDDDDDDDDDDD...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere is a game that uses numbers called \"Fizz Buzz\". In this game, multiple players count the numbers one by one, starting with 1, and each player says only one number after the previous player. At that time, you must ...
[{"type": "stdin_stdout", "input": "5 7\n1\n-1\nFizz\n2\nzuzB\n5\n2\n16 5\n1\n4\n5\n7\n8\n0 0", "output": "3\n1 6 7 8 9 10 11 12 13 14 15 16\n"}, {"type": "stdin_stdout", "input": "14 7\n1\n0\nzzFi\n4\nBuzz\n11\n1\n3 5\n-1\n3\n8\n4\n3\n0 0", "output": "1 4 5 8 9 10 11 12 13 14\n3\n"}, {"type": "stdin_stdout", "input": ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nChief Judge's log, stardate 48642.5. We have decided to make a problem from elementary number theory. The problem looks like finding all prime factors of a positive integer, but it is not.\n\nA positive integer whose rema...
[{"type": "stdin_stdout", "input": "205920\n34152\n262200\n279936\n152244\n1", "output": "205920: 6 8 13 15 20 22 55 99\n34152: 6 8 4269 5692\n262200: 6 8 15 20 50 57 69 76 92 190 230 475 575 874 2185\n279936: 6 8 27\n152244: 6 4229\n"}, {"type": "stdin_stdout", "input": "205920\n262144\n262200\n9766\n81220\n1", "outpu...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDo you know \"sed,\" a tool provided with Unix? Its most popular use is to substitute every occurrence of a string contained in the input string (actually each input line) with another string β. More precisely, it procee...
[{"type": "stdin_stdout", "input": "2\na bb\nb aa\nb\nbbbbbbbb\n1\nb aa\nb\naaaaa\n3\nbb aab\nabc aadc\nad dee\nabc\ndeeeeeeeec\n10\na acb\nb bai\nc acf\nd bec\ne bbh\nf fag\ng abe\nh bag\ni aaj\nj bbb\na\nabaceaabe\n0", "output": "-1\n-1\n-1\n-1\n"}, {"type": "stdin_stdout", "input": "2\na bb\nb aa\nb\nbbbbbbbb\n1\nb ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOsaki\n\nOsaki\n\nEnglish text is not available in this practice contest.\n\nThe Yamanote Line is a circular railway line laid in the 23 wards of Tokyo. The total route distance is 34.5km, and one lap takes about one hour...
[{"type": "stdin_stdout", "input": "3\n05:47:15 04:45:90\n12:12:59 12:13:00\n16:30:20 21:18:53\n6\n00:00:00 03:00:00\n01:00:00 03:00:00\n02:00:00 03:00:00\n03:00:00 04:00:00\n03:00:00 05:00:00\n03:00:00 06:00:00\n0", "output": "1\n3\n"}, {"type": "stdin_stdout", "input": "3\n05:47:15 09:54:40\n12:12:59 12:13:00\n16:30:...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOpen Binary and Object Group organizes a programming contest every year. Mr. Hex belongs to this group and joins the judge team of the contest. This year, he created a geometric problem with its solution for the contest. ...
[{"type": "stdin_stdout", "input": "9\n-1 1\n0 1\n1 1\n-1 0\n0 0\n1 0\n-1 -1\n0 -2\n1 -1", "output": "No\n"}, {"type": "stdin_stdout", "input": "9\n-1 1\n0 1\n1 1\n-1 0\n0 0\n1 0\n-1 -1\n0 -1\n1 -1", "output": "No"}, {"type": "stdin_stdout", "input": "4\n0 1\n1 -1\n0 -1\n1 1", "output": "Yes\n"}, {"type": "stdin_stdout...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe Quarkgo Empire Expeditionary Force is an evil organization that plans to invade the Earth. In keeping with the tradition of the invaders, they continued to send monsters at a pace of one every week, targeting the area...
[{"type": "stdin_stdout", "input": "1204648530", "output": "20\n"}, {"type": "stdin_stdout", "input": "3727082973", "output": "21\n"}, {"type": "stdin_stdout", "input": "1369610954", "output": "20\n"}, {"type": "stdin_stdout", "input": "2281056559", "output": "20\n"}, {"type": "stdin_stdout", "input": "2000000000", "ou...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn 20XX AD, a school competition was held. The tournament has finally left only the final competition. You are one of the athletes in the competition.\n\nThe competition you participate in is to compete for the time it ta...
[{"type": "stdin_stdout", "input": "5 5\n-38 -71 -293 75 1\n-158 -38 -405 66 1\n-236 -303 157 266 1\n316 26 411 190 1\n207 -312 -27 196 1\n-50 292 -375 -401 389 -389\n460 278 409 -329 -303 411\n215 -220 -200 309 -474 300\n310 -494 -87 -300 123 -463\n386 378 486 -443 -64 299", "output": "0\n2\n1\n3\n0\n"}, {"type": "std...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nProblem statement\n\nYou and AOR Ika are preparing for a graph problem in competitive programming. Generating input cases is AOR Ika-chan's job. The input case for that problem is a directed graph of the $ N $ vertices. T...
[{"type": "stdin_stdout", "input": "3\n1 2 0 0\n1 2 0 0", "output": "YES\n0 1 0\n0 0 1\n0 0 0"}, {"type": "stdin_stdout", "input": "3\n2 -2 0 -1\n2 2 0 -1", "output": "NO\n"}, {"type": "stdin_stdout", "input": "3\n2 -2 0 -1\n2 3 0 -1", "output": "NO\n"}, {"type": "stdin_stdout", "input": "3\n1 1 1 -1\n2 2 -1 1", "outpu...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA: Information Search\n\nproblem\n\nThe posting list is a list in which there is a correspondence between the search term and the appearing document ID. For example\n\n* Hokkaido: 1, 2, 4, 9\n* Sightseeing: 1, 3, 4, 7\n\n...
[{"type": "stdin_stdout", "input": "4 4\n0 2 10 11\n1 2 4 14", "output": "1 7\n2\n0\n1\n2\n4\n10\n11\n14\n"}, {"type": "stdin_stdout", "input": "4 4\n1 2 5 12\n2 3 4 13", "output": "1 7\n2\n1\n2\n3\n4\n5\n12\n13\n"}, {"type": "stdin_stdout", "input": "4 4\n1 2 4 12\n2 3 4 13", "output": "2 6\n2\n4\n1\n2\n3\n4\n12\n13\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFor a dictionary $M$ that stores elements formed by a pair of a string key and an integer value, perform a sequence of the following operations. Note that each key in $M$ must be unique.\n\n* insert($key$, $x$): Insert an...
[{"type": "stdin_stdout", "input": "9\n0 ulbe 4\n0 red 1\n0 white 10\n1 red\n1 blue\n2 ree\n1 bladk\n1 red\n3 w z", "output": "1\n0\n0\n1\nwhite 10\n"}, {"type": "stdin_stdout", "input": "9\n0 blue 4\n0 der 1\n0 white 11\n1 rdd\n1 blve\n2 erd\n1 balck\n1 red\n3 w z", "output": "0\n0\n0\n0\nwhite 11\n"}, {"type": "stdin...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGiven two binary strings, A (of length 10) and B (of length 5), \n\noutput 1 if B is a substring of A and 0 otherwise.\n\n\n\nInput\n\nThe first line contains the number of test cases n. This is followed by n lines each c...
[{"type": "stdin_stdout", "input": "1\n1010110010 10110", "output": "1\n"}, {"type": "stdin_stdout", "input": "1\n1010110110 10110", "output": "1\n"}, {"type": "stdin_stdout", "input": "1\n1010100110 10110", "output": "0\n"}, {"type": "stdin_stdout", "input": "1\n0010100110 10110", "output": "0\n"}, {"type": "stdin_std...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGiven an array of n non-negative integers: A1, A2, …, AN. Your mission is finding a pair of integers Au, Av (1 ≤ u < v ≤ N) such that (Au and Av) is as large as possible.\nAnd is a bit-wise operation which is correspondi...
[{"type": "stdin_stdout", "input": "4\n1\n11\n23\n11", "output": "11\n"}, {"type": "stdin_stdout", "input": "4\n4\n11\n18\n16", "output": "16\n"}, {"type": "stdin_stdout", "input": "4\n1\n15\n17\n14", "output": "14\n"}, {"type": "stdin_stdout", "input": "4\n13\n10\n3\n13", "output": "13\n"}, {"type": "stdin_stdout", "i...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThis is an interactive problem.\n\nNatasha is going to fly to Mars. Finally, Natasha sat in the rocket. She flies, flies... but gets bored. She wishes to arrive to Mars already! So she decides to find something to occupy ...
[{"type": "stdin_stdout", "input": "1000000000 30 1000000000\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\n", "output": "1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n500000000\n750000000\n875000000\n937500000\n968750000\n984375000\n992187500\n996093750\n99804...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPetya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.\n\...
[{"type": "stdin_stdout", "input": "987654215 1000000000 9854874 854888120 270\n", "output": "3.1951405575880256686e-08"}, {"type": "stdin_stdout", "input": "777777776 778777777 777777775 1000000000 1\n", "output": "2.013495963778572506e-06"}, {"type": "stdin_stdout", "input": "987654215 1000000000 5640296 854888120 27...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe letters shop showcase is a string s, consisting of n lowercase Latin letters. As the name tells, letters are sold in the shop.\n\nLetters are sold one by one from the leftmost to the rightmost. Any customer can only b...
[{"type": "stdin_stdout", "input": "100\nwjtwxtttttxjjwxtjtttwxjwjjwjxtwwxxwwwtwttwxjxxjxwxwjtjjwxxxxwwtwtxjxwtwtjjjxwjxjtwwwwtjtttjjtxtwtxjw\n10\nxwjxjwxtwwj\nwxjxxjxjx\nwtjxxxjxjxtwt\njwwxj\njtwjtxjxttxwtw\nwtwxjjjttjx\nwwwjtxw\ntjxjwtjwtw\ntjwtjjxtxjwt\nwxwtxtjw\n", "output": "21\n29\n29\n12\n15\n17\n21\n14\n17\n14\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are a coach of a group consisting of n students. The i-th student has programming skill a_i. All students have distinct programming skills. You want to divide them into teams in such a way that:\n\n * No two students...
[{"type": "stdin_stdout", "input": "10\n5\n3 4 1 5 2\n2\n2 1\n4\n4 1 3 2\n5\n2 3 1 5 4\n2\n1 2\n4\n1 2 3 4\n2\n1 2\n4\n3 4 2 1\n3\n3 2 1\n1\n1\n", "output": "2\n2\n2\n2\n2\n2\n2\n2\n2\n1\n"}, {"type": "stdin_stdout", "input": "10\n1\n1\n1\n1\n1\n1\n4\n2 1 4 3\n3\n1 3 2\n1\n1\n3\n1 2 3\n5\n1 4 2 5 3\n5\n4 5 2 3 1\n4\n4 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn this task Anna and Maria play a game with a very unpleasant rival. Anna and Maria are in the opposite squares of a chessboard (8 × 8): Anna is in the upper right corner, and Maria is in the lower left one. Apart from t...
[{"type": "stdin_stdout", "input": "S......A\n.SS..S..\nS....S..\nSSS...S.\n.SS.STS.\n.S.SS...\n..S..S..\nM.SS....\n", "output": "LOSE\n"}, {"type": "stdin_stdout", "input": "SSSSSSSA\n......S.\n/.....S.\n.....SS.\n....SS..\n...SS...\n..SS....\nMSS.....\n", "output": "LOSE\n"}, {"type": "stdin_stdout", "input": "S..SSS...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA positive integer is called composite if it can be represented as a product of two positive integers, both greater than 1. For example, the following numbers are composite: 6, 4, 120, 27. The following numbers aren't: 1,...
[{"type": "stdin_stdout", "input": "3\n3\n6 10 15\n2\n4 9\n23\n171 519 865 808 909 391 194 291 237 395 323 365 511 497 781 737 871 559 731 697 779 841 961\n", "output": "2\n1 1 2 \n2\n1 2 \n10\n2 2 3 1 2 7 1 2 2 3 7 3 4 4 5 5 6 6 7 7 8 9 10 \n"}, {"type": "stdin_stdout", "input": "3\n3\n6 10 28\n2\n4 9\n23\n171 519 865...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPay attention to the non-standard memory limit in this problem.\n\nIn order to cut off efficient solutions from inefficient ones in this problem, the time limit is rather strict. Prefer to use compiled statically typed la...
[{"type": "stdin_stdout", "input": "7\n2\n1 1\n2\n1 2\n2\n2 1\n2\n2 2\n12\n5 8 10 1 1 10 7 3 12 3 3 7\n5\n2 1 3 1 3\n4\n4 3 4 3\n", "output": "0\n0\n0\n0\n3\n2\n0\n"}, {"type": "stdin_stdout", "input": "7\n2\n1 1\n2\n1 2\n2\n2 1\n2\n2 2\n12\n5 8 10 1 1 10 7 3 12 3 3 7\n5\n4 1 3 1 3\n4\n4 3 4 3\n", "output": "0\n0\n0\n0...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPatrick likes to play baseball, but sometimes he will spend so many hours hitting home runs that his mind starts to get foggy! Patrick is sure that his scores across n sessions follow the identity permutation (ie. in the ...
[{"type": "stdin_stdout", "input": "5\n5\n1 3 4 2 5\n4\n2 1 3 4\n5\n2 1 3 5 4\n7\n3 2 4 1 5 7 6\n6\n3 2 1 6 5 4\n", "output": "1\n1\n2\n2\n2\n"}, {"type": "stdin_stdout", "input": "5\n5\n1 3 4 2 5\n4\n2 1 3 4\n5\n2 1 3 5 4\n7\n3 2 4 1 5 7 6\n6\n3 2 1 6 5 1\n", "output": "1\n1\n2\n2\n2\n"}, {"type": "stdin_stdout", "inp...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an array of n integers a_1, a_2, ..., a_n, and a set b of k distinct integers from 1 to n.\n\nIn one operation, you may choose two integers i and x (1 ≤ i ≤ n, x can be any integer) and assign a_i := x. This...
[{"type": "stdin_stdout", "input": "100 2\n96 58 6 51 50 14 42 14 8 23 50 87 18 38 66 12 60 34 67 79 73 79 100 94 89 73 4 13 30 3 34 26 41 65 18 71 29 3 40 65 77 83 51 20 38 45 43 64 7 12 97 42 88 32 62 61 92 17 83 14 3 23 5 58 3 64 17 35 23 86 65 22 44 81 30 95 62 63 17 85 3 3 17 56 26 94 59 84 3 88 70 53 52 74 12 47 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA Pythagorean triple is a triple of integer numbers (a, b, c) such that it is possible to form a right triangle with the lengths of the first cathetus, the second cathetus and the hypotenuse equal to a, b and c, respectiv...
[{"type": "stdin_stdout", "input": "3\n2131\n21165\n6666\n", "output": "32\n102\n57\n"}, {"type": "stdin_stdout", "input": "3\n2131\n38301\n6666\n", "output": "32\n137\n57\n"}, {"type": "stdin_stdout", "input": "3\n1625\n38301\n6666\n", "output": "28\n137\n57\n"}, {"type": "stdin_stdout", "input": "3\n2570\n38301\n6666...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are an upcoming movie director, and you have just released your first movie. You have also launched a simple review site with two buttons to press — upvote and downvote.\n\nHowever, the site is not so simple on the in...
[{"type": "stdin_stdout", "input": "9\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n", "output": "1\n1\n1\n1\n1\n1\n1\n1\n1\n"}, {"type": "stdin_stdout", "input": "9\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n2\n1\n1\n1\n1\n", "output": "1\n1\n1\n1\n1\n1\n0\n1\n1\n"}, {"type": "stdin_stdout", "input": "9\n1\n1\n1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given two integers l and r, where l < r. We will add 1 to l until the result is equal to r. Thus, there will be exactly r-l additions performed. For each such addition, let's look at the number of digits that will...
[{"type": "stdin_stdout", "input": "4\n1 9\n9 10\n10 20\n1 1000000000\n", "output": "\n8\n2\n11\n1111111110\n"}, {"type": "stdin_stdout", "input": "4\n0 9\n0 10\n10 23\n2 1010000000\n", "output": "9\n11\n14\n1122222220\n"}, {"type": "stdin_stdout", "input": "4\n1 18\n8 10\n10 12\n1 1000000000\n", "output": "18\n3\n2\n1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOne day Vasya painted a Cartesian coordinate system on a piece of paper and marked some set of points (x1, y1), (x2, y2), ..., (xn, yn). Let's define neighbors for some fixed point from the given set (x, y): \n\n * point...
[{"type": "stdin_stdout", "input": "30\n507 836\n525 836\n-779 196\n507 -814\n525 -814\n525 42\n525 196\n525 -136\n-779 311\n507 -360\n525 300\n507 578\n507 311\n-779 836\n507 300\n525 -360\n525 311\n-779 -360\n-779 578\n-779 300\n507 42\n525 578\n-779 379\n507 196\n525 379\n507 379\n-779 -814\n-779 42\n-779 -136\n507 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nEach year in the castle of Dwarven King there is a competition in growing mushrooms among the dwarves. The competition is one of the most prestigious ones, and the winner gets a wooden salad bowl. This year's event brough...
[{"type": "stdin_stdout", "input": "10 6 1 48\n239 632\n976 315\n797 112\n1 835\n938 862\n531 884\n422 607\n152 331\n413 677\n622 978\n", "output": "5 3788.56\n10 3673.36\n2 3360.12\n6 3289.08\n4 2606.20\n3 2598.64\n9 2525.24\n7 2315.84\n1 2210.84\n8 1184.72\n"}, {"type": "stdin_stdout", "input": "10 6 1 41\n239 632\n9...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe Smart Beaver from ABBYY came up with another splendid problem for the ABBYY Cup participants! This time the Beaver invites the contest participants to check out a problem on sorting documents by their subjects. Let's ...
[{"type": "stdin_stdout", "input": "21000\nSWISS OT LAHNCU NEW SERIES OF MONEY MARKET PEPAR\nZURICH, April 9 - The Svirs Federal tndmnrevoG lliw launch\na ndw series fo three mhnto mondx market setatificrec totallhng\nauornd 150 mln iwSss fraocs, dht National Bank said.\nSubscriptions close lirpA 14 and paynent date hs...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given three positive integers x, y, n. Your task is to find the nearest fraction to fraction <image> whose denominator is no more than n. \n\nFormally, you should find such pair of integers a, b (1 ≤ b ≤ n; 0 ≤ a)...
[{"type": "stdin_stdout", "input": "43003 70913 108889\n", "output": "43003/70913\n"}, {"type": "stdin_stdout", "input": "76730 157792 71438\n", "output": "33069/68005\n"}, {"type": "stdin_stdout", "input": "43003 75615 108889\n", "output": "43003/75615\n"}, {"type": "stdin_stdout", "input": "76730 157792 50090\n", "ou...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn mathematics, the Pythagorean theorem — is a relation in Euclidean geometry among the three sides of a right-angled triangle. In terms of areas, it states:\n\nIn any right-angled triangle, the area of the square whose ...
[{"type": "stdin_stdout", "input": "10000\n", "output": "12471"}, {"type": "stdin_stdout", "input": "9999\n", "output": "12467"}, {"type": "stdin_stdout", "input": "1201\n", "output": "1096"}, {"type": "stdin_stdout", "input": "1590\n", "output": "1520"}, {"type": "stdin_stdout", "input": "1195\n", "output": "1091"}, {...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nJeff's friends know full well that the boy likes to get sequences and arrays for his birthday. Thus, Jeff got sequence p1, p2, ..., pn for his birthday.\n\nJeff hates inversions in sequences. An inversion in sequence a1, ...
[{"type": "stdin_stdout", "input": "53\n-3 2 -3 -5 -2 7 0 -2 1 6 -1 2 5 -3 3 -6 -2 -5 -3 -6 4 -4 -2 6 1 -7 -6 -4 0 2 -5 -1 -2 -6 2 2 7 -2 -3 1 0 -4 3 4 -2 7 -3 7 1 3 -10 -5 3\n", "output": "298\n"}, {"type": "stdin_stdout", "input": "53\n-3 2 -3 -5 -2 7 0 -2 1 6 -1 2 5 -3 3 -6 -2 -5 -3 -6 4 -4 -2 6 1 -3 -6 -4 0 2 -5 -1...
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\nDZY loves collecting special strings which only contain lowercase letters. For each lowercase letter c DZY knows its value wc. For each special string s = s1s2... s|s| (|s| is the length of the string) he represents its v...
[{"type": "stdin_stdout", "input": "pplkqmluhfympkjfjnfdkwrkpumgdmbkfbbldpepicbbmdgafttpopzdxsevlqbtywzkoxyviglbbxsohycbdqksrhlumsldiwzjmednbkcjishkiekfrchzuztkcxnvuykhuenqojrmzaxlaoxnljnvqgnabtmcftisaazzgbmubmpsorygyusmeonrhrgphnfhlaxrvyhuxsnnezjxmdoklpquzpvjbxgbywppmegzxknhfzyygrmejleesoqfwheulmqhonqaukyuejtwxskjldpl...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLittle X used to play a card game called \"24 Game\", but recently he has found it too easy. So he invented a new game.\n\nInitially you have a sequence of n integers: 1, 2, ..., n. In a single step, you can pick two of t...
[{"type": "stdin_stdout", "input": "1000\n", "output": "YES\n1 * 2 = 2\n2 * 3 = 6\n6 * 4 = 24\n6 - 5 = 1\n24 * 1 = 24\n8 - 7 = 1\n24 * 1 = 24\n10 - 9 = 1\n24 * 1 = 24\n12 - 11 = 1\n24 * 1 = 24\n14 - 13 = 1\n24 * 1 = 24\n16 - 15 = 1\n24 * 1 = 24\n18 - 17 = 1\n24 * 1 = 24\n20 - 19 = 1\n24 * 1 = 24\n22 - 21 = 1\n24 * 1 = ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThink of New York as a rectangular grid consisting of N vertical avenues numerated from 1 to N and M horizontal streets numerated 1 to M. C friends are staying at C hotels located at some street-avenue crossings. They are...
[{"type": "stdin_stdout", "input": "100 100\n10\n53 20\n97 6\n12 74\n48 92\n97 13\n47 96\n123 32\n69 21\n95 75\n1 54\n10\n36 97\n41 1\n1 87\n39 23\n27 44\n73 97\n1 1\n6 26\n48 3\n5 69\n", "output": "108\n4\n"}, {"type": "stdin_stdout", "input": "100 100\n10\n53 20\n97 6\n12 74\n48 92\n97 13\n47 96\n123 32\n69 21\n95 75...
code_stdio