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\nAlice has just learnt about primeStrings. A string is a primeString if the number of distinct alphabets used in the string is a prime and also the number of occurrences of each alphabet in the string is also a prime.\nGiv...
[{"type": "stdin_stdout", "input": "3\naabbb\nbabba\naabbccdd\n\nEAMOSL", "output": "YES\nYES\nNO\n"}, {"type": "stdin_stdout", "input": "3\nbbaba\nabcbc\nccbcbbaa\n\nSM>OLD", "output": "YES\nNO\nYES\n"}, {"type": "stdin_stdout", "input": "3\naabbb\nabbab\naabbccdd\n\nEAMOSL", "output": "YES\nYES\nNO\n"}, {"type": "std...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAli baba did a trick on the forty thieves and was able to trap them inside a big cave which was the home of wild wolves. The thieves are without any weapons, only the chief of the thieves has knife. With no weapons they w...
[{"type": "stdin_stdout", "input": "4\n13\n13\n104\n45412902\n\nEMPLAR", "output": "11\n11\n81\n23716941\n"}, {"type": "stdin_stdout", "input": "4\n13\n25\n104\n45412902\n\nEMPLAR", "output": "11\n19\n81\n23716941\n"}, {"type": "stdin_stdout", "input": "4\n23\n13\n104\n45412902\n\nEMPLAR", "output": "15\n11\n81\n237169...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou have a sequence A composed of N positive integers: A_{1}, A_{2}, \\cdots, A_{N}.\n\nYou will now successively do the following Q operations:\n\n* In the i-th operation, you replace every element whose value is B_{i} w...
[{"type": "stdin_stdout", "input": "2\n1 2\n3\n1 100\n2 000\n100 1000", "output": "102\n100\n1000\n"}, {"type": "stdin_stdout", "input": "2\n1 2\n3\n1 100\n2 001\n100 1000", "output": "102\n101\n1001\n"}, {"type": "stdin_stdout", "input": "2\n1 2\n3\n1 100\n1 001\n100 1000", "output": "102\n102\n1002\n"}, {"type": "std...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIf there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print `-1`.\n\n* The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. ...
[{"type": "stdin_stdout", "input": "3 1\n1 7\n3 2\n0 28", "output": "700\n"}, {"type": "stdin_stdout", "input": "3 3\n1 14\n3 2\n1 7", "output": "-1\n"}, {"type": "stdin_stdout", "input": "3 3\n1 7\n3 4\n1 7", "output": "704\n"}, {"type": "stdin_stdout", "input": "3 3\n0 2\n3 2\n1 1", "output": "102\n"}, {"type": "stdi...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWe have N switches with \"on\" and \"off\" state, and M bulbs. The switches are numbered 1 to N, and the bulbs are numbered 1 to M.\n\nBulb i is connected to k_i switches: Switch s_{i1}, s_{i2}, ..., and s_{ik_i}. It is l...
[{"type": "stdin_stdout", "input": "15 0\n0 6 1\n0 1\n0 -1\n2 1 -2", "output": "32768\n"}, {"type": "stdin_stdout", "input": "13 0\n0 7 1\n0 1\n0 -1\n2 1 -2", "output": "8192\n"}, {"type": "stdin_stdout", "input": "6 0\n-4 0 2\n-1 4\n1 0\n0 0 -2", "output": "64\n"}, {"type": "stdin_stdout", "input": "4 0\n0 2 2\n0 2\n2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet S(n) denote the sum of the digits in the decimal notation of n. For example, S(123) = 1 + 2 + 3 = 6.\n\nWe will call an integer n a Snuke number when, for all positive integers m such that m > n, \\frac{n}{S(n)} \\leq...
[{"type": "stdin_stdout", "input": "263", "output": "1\n2\n3\n4\n5\n6\n7\n8\n9\n19\n29\n39\n49\n59\n69\n79\n89\n99\n199\n299\n399\n499\n599\n699\n799\n899\n999\n1099\n1199\n1299\n1399\n1499\n1599\n1699\n1799\n1899\n1999\n2999\n3999\n4999\n5999\n6999\n7999\n8999\n9999\n10999\n11999\n12999\n13999\n14999\n15999\n16999\n17...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe postal code in Atcoder Kingdom is A+B+1 characters long, its (A+1)-th character is a hyphen `-`, and the other characters are digits from `0` through `9`.\n\nYou are given a string S. Determine whether it follows the ...
[{"type": "stdin_stdout", "input": "3 4\n269-6650", "output": "Yes"}, {"type": "stdin_stdout", "input": "6 4\n269-6650", "output": "No\n"}, {"type": "stdin_stdout", "input": "6 8\n269-6650", "output": "No\n"}, {"type": "stdin_stdout", "input": "6 1\n269-6650", "output": "No\n"}, {"type": "stdin_stdout", "input": "6 2\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWe have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer.\n\nSnuke's objective is to permute the element in a so that the following condition is satisfied:\n\n* For each 1 ≤ i ≤ N - 1, the ...
[{"type": "stdin_stdout", "input": "6\n4 7 0 -1 6 4", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "6\n2 7 2 12 2 8", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "6\n4 7 2 8 2 10", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "6\n2 7 2 8 2 8", "output": "Yes\n"}, {"type": "stdin_stdout", "in...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere is a tree T with N vertices, numbered 1 through N. For each 1 ≤ i ≤ N - 1, the i-th edge connects vertices a_i and b_i.\n\nSnuke is constructing a directed graph T' by arbitrarily assigning direction to each edge in...
[{"type": "stdin_stdout", "input": "10\n2 4\n2 5\n8 3\n10 7\n1 7\n2 8\n9 10\n8 6\n10 8", "output": "220\n"}, {"type": "stdin_stdout", "input": "10\n1 4\n2 5\n1 3\n10 1\n1 6\n4 8\n9 8\n7 10\n10 2", "output": "122\n"}, {"type": "stdin_stdout", "input": "10\n2 4\n2 5\n2 3\n10 7\n1 6\n2 10\n9 5\n8 7\n10 6", "output": "194\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are N balls placed in a row. AtCoDeer the deer is painting each of these in one of the K colors of his paint cans. For aesthetic reasons, any two adjacent balls must be painted in different colors.\n\nFind the numbe...
[{"type": "stdin_stdout", "input": "-10 -2", "output": "1.1290058539e-05\n"}, {"type": "stdin_stdout", "input": "-3 -6", "output": "-0.00249895876718\n"}, {"type": "stdin_stdout", "input": "-3 -2", "output": "-0.0246913580247\n"}, {"type": "stdin_stdout", "input": "-5 9", "output": "3.43322753906e-05\n"}, {"type": "std...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAssume that a, b, and n are all positive integers. Let f (i) be the i-th fraction of the fraction a / b (0 ≤ f (i) ≤ 9). At this time, let s be the sum of f (i) from i = 1 to n.\n\ns = f (1) + f (2) + ... + f (n)\n\n\nCre...
[{"type": "stdin_stdout", "input": "2 3 2\n2 7 3\n13 3 5\n4 6 2", "output": "12\n15\n15\n12\n"}, {"type": "stdin_stdout", "input": "1 3 2\n2 7 3\n13 3 5\n4 6 2", "output": "6\n15\n15\n12\n"}, {"type": "stdin_stdout", "input": "2 3 2\n2 7 3\n13 3 5\n4 4 2", "output": "12\n15\n15\n0\n"}, {"type": "stdin_stdout", "input":...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTsuruga Castle, a symbol of Aizuwakamatsu City, was named \"Tsuruga Castle\" after Gamo Ujisato built a full-scale castle tower. You can overlook the Aizu basin from the castle tower. On a clear day, you can see Tsuruga C...
[{"type": "stdin_stdout", "input": "8\n106\n29\n127\n11\n41\n39\n2\n5\n4\n67\n81\n78\n65\n0", "output": "2\n1\n1\n1\n1\n0\n2\n0\n0\n0\n0\n0\n0\n4\n"}, {"type": "stdin_stdout", "input": "8\n001\n21\n127\n11\n41\n39\n2\n5\n4\n67\n81\n78\n65\n0", "output": "3\n1\n1\n1\n1\n0\n1\n0\n0\n0\n0\n0\n0\n4\n"}, {"type": "stdin_std...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe educational program (AHK Education) of the Aiz Broadcasting Association broadcasts a handicraft program for children, \"Play with Tsukuro\". Today is the time to make a rectangle with sticks, but I would like to see i...
[{"type": "stdin_stdout", "input": "-1 -2 1 11", "output": "no\n"}, {"type": "stdin_stdout", "input": "-1 -2 1 19", "output": "no\n"}, {"type": "stdin_stdout", "input": "-2 -2 1 1", "output": "yes\n"}, {"type": "stdin_stdout", "input": "-1 4 4 10", "output": "no\n"}, {"type": "stdin_stdout", "input": "-1 1 4 10", "outp...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nproblem\n\nIn the area where Kazakhstan is now located, there used to be a trade route called the \"Silk Road\".\n\nThere are N + 1 cities on the Silk Road, numbered from west as city 0, city 1, ..., city N. The distance ...
[{"type": "stdin_stdout", "input": "3 5\n10\n25\n15\n50\n30\n15\n40\n30", "output": "1125"}, {"type": "stdin_stdout", "input": "3 5\n10\n25\n15\n50\n30\n15\n12\n30", "output": "855\n"}, {"type": "stdin_stdout", "input": "3 5\n10\n38\n18\n50\n30\n6\n40\n30", "output": "1068\n"}, {"type": "stdin_stdout", "input": "3 5\n1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn the good old Hachioji railroad station located in the west of Tokyo, there are several parking lines, and lots of freight trains come and go every day.\n\nAll freight trains travel at night, so these trains containing ...
[{"type": "stdin_stdout", "input": "3 5\n0W 1W\n0W 2W\n0W 2E\n0E 1E\n1E 2E\naabbcdcee\n-\n-\n-\n-\nbbaadeecc\n3 3\n0E 1W\n1E 2W\n2E 0W\naabb\nbbcc\naa\nbbbb\ncc\naaaa\n3 4\n0E 1W\n0E 2E\n1E 2W\n2E 0W\nababab\n-\n-\naaabbb\n-\n-\n0 0", "output": "5\n2\n5\n"}, {"type": "stdin_stdout", "input": "3 5\n0W 1W\n0W 2W\n0W 2E\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nShortest Common Non-Subsequence\n\nA subsequence of a sequence $P$ is a sequence that can be derived from the original sequence $P$ by picking up some or no elements of $P$ preserving the order. For example, \"ICPC\" is a...
[{"type": "stdin_stdout", "input": "0101\n1101001", "output": "0000\n"}, {"type": "stdin_stdout", "input": "0101\n1101000", "output": "0001\n"}, {"type": "stdin_stdout", "input": "0101\n0011001", "output": "1000\n"}, {"type": "stdin_stdout", "input": "0101\n0110001", "output": "0010\n"}, {"type": "stdin_stdout", "input...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA Garden with Ponds\n\nMr. Gardiner is a modern garden designer who is excellent at utilizing the terrain features. His design method is unique: he first decides the location of ponds and design them with the terrain feat...
[{"type": "stdin_stdout", "input": "3 3\n0 0 2\n0 1 2\n2 3 1\n3 5\n0 3 7 3 3\n4 1 0 2 3\n3 3 4 0 2\n7 7\n2 1 1 1 1 0 0\n1 0 0 0 1 0 0\n1 0 1 1 1 1 1\n1 0 0 0 2 0 1\n1 1 1 1 1 0 1\n0 0 2 1 0 1 1\n0 0 1 1 1 2 -1\n6 6\n1 1 1 1 2 2\n1 0 0 2 0 2\n1 0 -1 2 1 2\n3 3 3 15 13 9\n3 0 0 18 -1 9\n2 6 3 9 9 2\n0 0", "output": "0\n0...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA convex polygon consisting of N vertices is given. The coordinates of each vertex are represented counterclockwise by (X1, Y1), (X2, Y2), ……, (XN, YN). No matter what straight line passes through the point P, find the co...
[{"type": "stdin_stdout", "input": "4\n100 100\n0 100\n0 0\n100 0", "output": "50.00000 50.00000"}, {"type": "stdin_stdout", "input": "4\n111 100\n-2 110\n0 -2\n110 -1", "output": "NA\n"}, {"type": "stdin_stdout", "input": "4\n111 110\n-2 110\n0 -2\n110 -1", "output": "NA\n"}, {"type": "stdin_stdout", "input": "4\n111 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nProblem Statement\n\nLet's consider operations on monochrome images that consist of hexagonal pixels, each of which is colored in either black or white. Because of the shape of pixels, each of them has exactly six neighbo...
[{"type": "stdin_stdout", "input": "00000000111111110000000011111111000000001111111100000000111111110000000011111111000000001111111100000000111111110000000111111111\n10000000111111110000000011111111000000001111111100000000111111110000000011111111000000001111111100000000111111110000000011111111\n010101010101010101010101...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nC: Namo .. Cut\n\nproblem\n\n-Defeat the mysterious giant jellyfish, codenamed \"Nari\"-\n\n\"Nari\" has a very strong vitality, so if you don't keep cutting quickly, it will be revived in a blink of an eye. We are making...
[{"type": "stdin_stdout", "input": "3\n2 2\n1 3\n2 1\n2\n2 3", "output": "1\n1\n"}, {"type": "stdin_stdout", "input": "3\n1 2\n1 3\n2 3\n2\n2 3", "output": "2\n2\n"}, {"type": "stdin_stdout", "input": "3\n1 1\n1 3\n2 3\n2\n2 3", "output": "1\n1\n"}, {"type": "stdin_stdout", "input": "3\n2 1\n1 3\n2 3\n2\n2 3", "output"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nProblem\n\nThe popular video posting site \"ZouTube\" is now in the midst of an unprecedented \"virtual ZouTuber\" boom. Among them, the one that has been attracting particular attention recently is the junior virtual Zou...
[{"type": "stdin_stdout", "input": "110000", "output": "110000\n"}, {"type": "stdin_stdout", "input": "100010", "output": "100000\n"}, {"type": "stdin_stdout", "input": "121470", "output": "121000\n"}, {"type": "stdin_stdout", "input": "101101", "output": "101000\n"}, {"type": "stdin_stdout", "input": "113193", "output...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given $n$ integers $w_i (i = 0, 1, ..., n-1)$ to be sorted in ascending order. You can swap two integers $w_i$ and $w_j$. Each swap operation has a cost, which is the sum of the two integers $w_i + w_j$. You can p...
[{"type": "stdin_stdout", "input": "5\n0 91 14 2 11", "output": "120\n"}, {"type": "stdin_stdout", "input": "5\n0 91 14 3 11", "output": "122\n"}, {"type": "stdin_stdout", "input": "5\n1 25 13 2 11", "output": "55\n"}, {"type": "stdin_stdout", "input": "5\n0 91 9 2 11", "output": "106\n"}, {"type": "stdin_stdout", "inp...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA state with $n$ flags of ON or OFF can be represented by a sequence of bits where $0, 1, ..., n-1$ -th flag corresponds to 1 (ON) or 0 (OFF). The state can be managed by the corresponding decimal integer, because the seq...
[{"type": "stdin_stdout", "input": "14\n1 1\n0 1\n1 4\n0 0\n0 0\n0 0\n0 2\n0 3\n4 0\n1\n5\n6\n4\n8", "output": "1\n0\n0\n0\n0\n0\n0\n1\n1\n0\n0\n18\n"}, {"type": "stdin_stdout", "input": "14\n2 1\n0 1\n1 4\n0 0\n0 0\n0 0\n0 2\n0 3\n4 0\n1\n5\n6\n4\n8", "output": "0\n0\n0\n0\n0\n0\n0\n0\n1\n0\n0\n16\n"}, {"type": "stdin...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a rectangular parallelepiped with sides of positive integer lengths A, B and C. \n\nFind the number of different groups of three integers (a, b, c) such that 1≤ a≤ b≤ c and parallelepiped A× B× C can be pave...
[{"type": "stdin_stdout", "input": "10\n2 10 8\n5 5 2\n16 9 1\n2 7 4\n6 4 10\n1 1 8\n2 8 1\n10 6 1\n7 5 2\n9 5 4\n", "output": "24\n6\n15\n10\n39\n4\n7\n15\n8\n18\n"}, {"type": "stdin_stdout", "input": "10\n9 6 8\n6 5 2\n8 9 2\n2 7 9\n6 4 10\n1 1 8\n2 8 1\n10 11 3\n7 5 3\n9 5 6\n", "output": "41\n14\n21\n12\n39\n4\n7\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWhen Masha came to math classes today, she saw two integer sequences of length n - 1 on the blackboard. Let's denote the elements of the first sequence as a_i (0 ≤ a_i ≤ 3), and the elements of the second sequence as b_i ...
[{"type": "stdin_stdout", "input": "100\n2 2 2 2 3 3 3 3 3 3 1 3 3 2 3 3 0 3 3 3 2 3 3 3 3 1 3 3 3 3 3 3 3 1 1 2 2 2 2 2 1 3 3 2 2 1 3 3 3 2 3 3 3 1 1 2 3 1 0 0 1 3 3 3 1 3 2 2 2 2 3 3 2 2 2 3 3 2 2 3 1 1 1 1 3 3 3 3 3 3 3 3 3 3 3 2 3 3 3\n0 0 0 2 2 1 0 0 0 0 0 0 2 2 2 0 0 0 3 2 2 2 2 2 1 1 1 3 3 1 0 2 1 1 0 0 2 2 2 0 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nInitially Ildar has an empty array. He performs n steps. On each step he takes a subset of integers already added to the array and appends the mex of this subset to the array. \n\nThe mex of an multiset of integers is the...
[{"type": "stdin_stdout", "input": "3\n0 1 1000000000\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "3\n1 1 1000000000\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "3\n1 0 1000000000\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "3\n1 0 0000000000\n", "output": "1\n"}, {"type": "stdin_std...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an integer number n. The following algorithm is applied to it:\n\n 1. if n = 0, then end algorithm; \n 2. find the smallest prime divisor d of n; \n 3. subtract d from n and go to step 1. \n\n\n\nDetermin...
[{"type": "stdin_stdout", "input": "10000000000\n", "output": "5000000000\n"}, {"type": "stdin_stdout", "input": "10000000010\n", "output": "5000000005\n"}, {"type": "stdin_stdout", "input": "10010000010\n", "output": "5005000005\n"}, {"type": "stdin_stdout", "input": "10010000110\n", "output": "5005000055\n"}, {"type"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPetr has just bought a new car. He's just arrived at the most known Petersburg's petrol station to refuel it when he suddenly discovered that the petrol tank is secured with a combination lock! The lock has a scale of 360...
[{"type": "stdin_stdout", "input": "15\n168\n168\n168\n168\n168\n168\n168\n168\n168\n168\n168\n168\n168\n168\n168\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "15\n180\n180\n180\n180\n180\n180\n180\n180\n180\n180\n180\n180\n180\n180\n180\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "15\n297\n16...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a connected undirected graph consisting of n vertices and m edges. There are no self-loops or multiple edges in the given graph.\n\nYou have to direct its edges in such a way that the obtained directed graph...
[{"type": "stdin_stdout", "input": "10 10\n1 3\n9 6\n4 5\n1 9\n8 6\n1 7\n3 2\n5 7\n5 3\n10 5\n", "output": "YES\n1001010110\n"}, {"type": "stdin_stdout", "input": "10 10\n4 3\n6 8\n5 3\n8 1\n2 9\n9 8\n3 6\n10 2\n9 3\n6 3\n", "output": "YES\n1110010111\n"}, {"type": "stdin_stdout", "input": "10 10\n1 5\n9 6\n4 5\n1 9\n8...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given two arrays a and b, both of length n.\n\nLet's define a function f(l, r) = ∑_{l ≤ i ≤ r} a_i ⋅ b_i.\n\nYour task is to reorder the elements (choose an arbitrary order of elements) of the array b to minimize ...
[{"type": "stdin_stdout", "input": "5\n1 11 7 6 5\n9 11 2 18 3\n", "output": "1162\n"}, {"type": "stdin_stdout", "input": "5\n1 11 7 6 5\n9 11 2 9 3\n", "output": "1077\n"}, {"type": "stdin_stdout", "input": "5\n1 11 7 6 5\n9 11 3 6 3\n", "output": "1021\n"}, {"type": "stdin_stdout", "input": "5\n1 11 7 2 5\n9 11 3 10 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe Third Doctor Who once correctly said that travel between parallel universes is \"like travelling sideways\". However, he incorrectly thought that there were infinite parallel universes, whereas in fact, as we now all ...
[{"type": "stdin_stdout", "input": "18 16 20 4\n0 0\n0 1\n1 7\n1 7\n", "output": "18 16\n17 15\n18 16\n19 17\n"}, {"type": "stdin_stdout", "input": "18 16 20 4\n0 0\n0 1\n1 7\n1 6\n", "output": "18 16\n17 15\n18 16\n19 17\n"}, {"type": "stdin_stdout", "input": "18 8 20 4\n1 1\n0 1\n1 7\n1 7\n", "output": "19 9\n18 8\n1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDemonstrative competitions will be held in the run-up to the 20NN Berlatov Olympic Games. Today is the day for the running competition!\n\nBerlatov team consists of 2n runners which are placed on two running tracks; n run...
[{"type": "stdin_stdout", "input": "10101 82934069\n", "output": " 76527701\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nNow that Kuroni has reached 10 years old, he is a big boy and doesn't like arrays of integers as presents anymore. This year he wants a Bracket sequence as a Birthday present. More specifically, he wants a bracket sequenc...
[{"type": "stdin_stdout", "input": "((()((()()))))(\n", "output": "1\n12\n1 2 3 5 6 7 8 10 11 12 13 14\n"}, {"type": "stdin_stdout", "input": "(((((())()))()(\n", "output": "1\n12\n1 2 3 4 5 6 7 8 10 11 12 14\n"}, {"type": "stdin_stdout", "input": "((()(())()))()(\n", "output": "1\n10\n1 2 3 5 6 8 10 11 12 14\n"}, {"ty...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSlime and his n friends are at a party. Slime has designed a game for his friends to play.\n\nAt the beginning of the game, the i-th player has a_i biscuits. At each second, Slime will choose a biscuit randomly uniformly ...
[{"type": "stdin_stdout", "input": "100\n4364 698 1003 1128 1513 39 4339 969 7452 3415 1154 1635 6649 136 1442 50 834 1680 107 978 983 3176 4017 1692 1113 1504 1118 396 1975 2053 2366 3022 3007 167 610 4649 14659 2331 4565 318 7232 204 7131 6122 2885 5748 1998 3833 6799 4219 8454 8698 4964 1736 1554 1665 2425 4227 1967...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLittle Petya very much likes computers. Recently he has received a new \"Ternatron IV\" as a gift from his mother. Unlike other modern computers, \"Ternatron IV\" operates with ternary and not binary logic. Petya immediat...
[{"type": "stdin_stdout", "input": "274842194 1000000000\n", "output": "1162261466\n"}, {"type": "stdin_stdout", "input": "274842194 1000100000\n", "output": "1162105233\n"}, {"type": "stdin_stdout", "input": "387420489 225159023\n", "output": "1000000001\n"}, {"type": "stdin_stdout", "input": "922263603 387506683\n", ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nBeing stuck at home, Ray became extremely bored. To pass time, he asks Lord Omkar to use his time bending power: Infinity Clock! However, Lord Omkar will only listen to mortals who can solve the following problem:\n\nYou ...
[{"type": "stdin_stdout", "input": "5\n20 809014\n289 -254 1 -109 -167 93 23 -37 -31 -109 204 59 296 49 132 0 -28 35 -197 -266\n20 458494\n113 218 -292 -298 179 258 -257 -20 296 76 -145 93 -282 -261 -159 -45 255 -107 171 63\n14 876161\n69 74 12 2 177 -113 103 93 38 -48 282 169 205 145\n26 731742\n76 190 -227 -81 -293 2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are n piranhas with sizes a_1, a_2, …, a_n in the aquarium. Piranhas are numbered from left to right in order they live in the aquarium.\n\nScientists of the Berland State University want to find if there is dominan...
[{"type": "stdin_stdout", "input": "6\n5\n6 3 4 4 5\n3\n1 1 1\n5\n4 4 3 4 4\n5\n5 5 4 3 2\n3\n1 1 1\n5\n5 4 3 5 5\n", "output": "1\n-1\n2\n2\n-1\n1\n"}, {"type": "stdin_stdout", "input": "6\n5\n5 3 4 4 5\n3\n1 1 1\n5\n4 4 3 4 4\n5\n5 5 4 3 2\n3\n1 1 2\n5\n5 4 3 5 5\n", "output": "1\n-1\n2\n2\n3\n1\n"}, {"type": "stdin_...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are n glasses on the table numbered 1, …, n. The glass i can hold up to a_i units of water, and currently contains b_i units of water.\n\nYou would like to choose k glasses and collect as much water in them as possi...
[{"type": "stdin_stdout", "input": "100\n1 0\n1 0\n1 0\n1 0\n1 0\n1 1\n1 0\n1 0\n1 0\n1 1\n1 0\n1 0\n1 0\n1 0\n1 0\n1 0\n1 0\n1 0\n1 1\n1 0\n1 0\n1 0\n1 0\n1 1\n1 0\n1 1\n1 0\n1 1\n1 1\n1 0\n1 0\n1 0\n1 1\n1 0\n1 0\n1 0\n1 1\n1 1\n1 0\n1 1\n1 0\n1 1\n1 1\n1 0\n1 0\n2 0\n1 0\n1 1\n1 0\n1 0\n1 0\n1 0\n1 1\n1 0\n1 0\n1 1\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAfter reaching your destination, you want to build a new colony on the new planet. Since this planet has many mountains and the colony must be built on a flat surface you decided to flatten the mountains using boulders (y...
[{"type": "stdin_stdout", "input": "20\n5 166\n11 21 31 41 51\n5 37\n11 21 31 41 51\n5 231\n11 21 31 41 51\n5 58\n11 21 31 41 51\n5 157\n11 21 31 41 51\n5 179\n11 21 31 41 51\n5 150\n11 21 31 41 51\n5 122\n11 20 27 37 47\n5 204\n11 21 31 41 51\n5 62\n3 13 23 8 43\n5 136\n43 58 51 86 34\n5 42\n31 25 62 45 100\n5 36\n20 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAs a teacher, Riko Hakozaki often needs to help her students with problems from various subjects. Today, she is asked a programming task which goes as follows.\n\nYou are given an undirected complete graph with n nodes, w...
[{"type": "stdin_stdout", "input": "6 12\n1 3 16656021\n1 4 8763000\n1 5 8763000\n1 6 16307467\n2 3 8763000\n2 4 1\n2 5 8763000\n2 6 1\n3 5 8763000\n3 6 8763000\n4 5 8763000\n4 6 2\n", "output": "8603110\n"}, {"type": "stdin_stdout", "input": "6 12\n1 3 16656021\n1 4 8763000\n1 5 8763000\n1 6 8763000\n2 3 8763000\n2 4 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThis is an interactive problem.\n\nLittle Dormi was faced with an awkward problem at the carnival: he has to guess the edges of an unweighted tree of n nodes! The nodes of the tree are numbered from 1 to n.\n\nThe game ma...
[{"type": "stdin_stdout", "input": "10\n7 5\n1 17\n6 25\n3 1\n18 0\n3 17\n7 -1\n-1 -1\n1 0\n", "output": "? 1\n? 5\n? 9\n? 10\n\n!\n1 3\n1 8\n5 7\n"}, {"type": "stdin_stdout", "input": "10\n7 2\n1 17\n6 25\n3 1\n13 0\n3 17\n7 -1\n-1 -1\n1 0\n", "output": "? 1\n? 2\n? 5\n? 10\n\n!\n1 3\n1 8\n2 7\n"}, {"type": "stdin_std...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given n points on a plane. All points are different.\n\nFind the number of different groups of three points (A, B, C) such that point B is the middle of segment AC. \n\nThe groups of three points are considered un...
[{"type": "stdin_stdout", "input": "40\n-8 24\n2 -1\n1 -18\n72 -70\n5 -4\n-308 436\n-19 40\n36 -35\n-178 265\n-1 2\n-7 30\n-1 0\n3 -2\n200 -285\n17 -16\n-35 74\n0 -4\n-86 106\n-1 4\n-7 6\n0 1\n-5 4\n-2 3\n6 -5\n-4 5\n181 -262\n76 -118\n0 0\n-7 18\n-58 104\n-5 6\n-6 12\n-3 4\n1 0\n11 -10\n-86 130\n-3 6\n153 -236\n-183 2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe Little Elephant has found a ragged old black-and-white string s on the attic.\n\nThe characters of string s are numbered from the left to the right from 1 to |s|, where |s| is the length of the string. Let's denote th...
[{"type": "stdin_stdout", "input": "300 7\nXXWXWWXXWWWBBXXXWWBWBWXWWWXXWBXXBXWWXXXWXWXBXWBWWWXBBWBXBXWXWBBBBXWBXWBBBXBXXXXBWXXXWBBXWXXBBWBBXBBXWXBXWBWXBWXXXXWXBWBBWXWXWXWWBWWWXXWWBBBXBXBWXBXXWWWBWWWBXWWXXWXWBWWWBWWWXXBBWXWXWXXWXXXXBWBXXBXBBBXBBWWXWBBXXWBBXBBXXBWXXWBWWBXWXXWWXXBXBWBWXWBBBWXXWXXWBWBBXWWBBWXXXBBWWXXXXBBBB...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are n boys and m girls studying in the class. They should stand in a line so that boys and girls alternated there as much as possible. Let's assume that positions in the line are indexed from left to right by number...
[{"type": "stdin_stdout", "input": "1 852\n", "output": "GBGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nComing up with a new problem isn't as easy as many people think. Sometimes it is hard enough to name it. We'll consider a title original if it doesn't occur as a substring in any titles of recent Codeforces problems. \n\n...
[{"type": "stdin_stdout", "input": "30\nwaiphwcqrrinr\no\nqiqehzmgsjdoqd\nkjexeesevrlowxhghq\njudikhzkj\nz\nxo\nlsdzypkfqro\nsshgcxsky\ngecntpcmoojfwp\nsvmytmcfhc\njrsrvsvbaiumlmkptn\ns\nwpcsovfjlyspviflk\nktvyzvddgllht\nszahigtmklglrcocbo\nznligfxkgxzkcfeu\nliryvzmqwhr\nxgrxkgiehxztv\netrjxdczppafly\njrdgajschhwsci\nd...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are n kangaroos with pockets. Each kangaroo has a size (integer number). A kangaroo can go into another kangaroo's pocket if and only if the size of kangaroo who hold the kangaroo is at least twice as large as the s...
[{"type": "stdin_stdout", "input": "100\n154\n60\n97\n638\n139\n150\n570\n579\n601\n647\n804\n237\n245\n549\n288\n347\n778\n282\n916\n441\n974\n145\n957\n886\n655\n702\n930\n618\n132\n520\n972\n48\n94\n54\n682\n433\n896\n134\n845\n636\n242\n842\n125\n141\n240\n130\n409\n666\n948\n938\n604\n110\n474\n484\n364\n40\n807\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nImagine you have an infinite 2D plane with Cartesian coordinate system. Some of the integral points are blocked, and others are not. Two integral points A and B on the plane are 4-connected if and only if:\n\n * the Eucl...
[{"type": "stdin_stdout", "input": "18855321\n", "output": "106661800\n"}, {"type": "stdin_stdout", "input": "34609610\n", "output": "195781516\n"}, {"type": "stdin_stdout", "input": "40000000\n", "output": "226274168\n"}, {"type": "stdin_stdout", "input": "38450759\n", "output": "217510336\n"}, {"type": "stdin_stdout"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPolycarpus develops an interesting theory about the interrelation of arithmetic progressions with just everything in the world. His current idea is that the population of the capital of Berland changes over time like an a...
[{"type": "stdin_stdout", "input": "20\n-1 32 37 -1 -1 -1 57 -1 -1 40 31 33 -1 -1 39 47 43 -1 35 32\n", "output": "5\n"}, {"type": "stdin_stdout", "input": "19\n23 26 -1 -1 35 38 41 -1 -1 -1 53 -1 59 62 6 7 8 9 -1\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "18\n21 19 -1 -1 -1 48 50 -1 54 -1 5 1 -1 -1 -1 37...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nKolya got string s for his birthday, the string consists of small English letters. He immediately added k more characters to the right of the string.\n\nThen Borya came and said that the new string contained a tandem repe...
[{"type": "stdin_stdout", "input": "wqlvwkiiqfmesejedhyjjfgzqfmiqyaiqefzaywrdundcmbfvhdflrpvkitbltbrzedvozltptkaanbpmjvsdnpthcepfydrdlscexczxwzyatupzlxdhnezdsipeyjqmbvoavsgeuulkqkexpwpttvxeovcjrqnzdeiaatzglvwkiiqfmesejedhyjjfgzqfmiqyaiq\n141\n", "output": "334\n"}, {"type": "stdin_stdout", "input": "nemtbujbscvkgxnbqbo...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPaul hates palindromes. He assumes that string s is tolerable if each its character is one of the first p letters of the English alphabet and s doesn't contain any palindrome contiguous substring of length 2 or more.\n\nP...
[{"type": "stdin_stdout", "input": "302 4\nabdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdcbdc...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe Berland State University is hosting a ballroom dance in celebration of its 100500-th anniversary! n boys and m girls are already busy rehearsing waltz, minuet, polonaise and quadrille moves.\n\nWe know that several bo...
[{"type": "stdin_stdout", "input": "100\n4 1 1 1 3 3 2 5 1 2 1 2 1 1 1 6 1 3 1 1 1 1 2 4 1 1 4 2 2 8 2 2 1 8 2 4 3 3 8 1 3 2 3 2 1 3 8 2 2 3 1 1 2 2 5 1 4 3 1 1 3 1 3 1 7 1 1 1 3 2 1 2 2 3 7 2 1 4 3 2 1 1 3 4 1 1 3 5 1 8 4 1 1 1 3 10 2 2 1 2\n100\n1 1 5 2 13 2 2 3 6 12 1 13 8 1 1 16 1 1 5 6 2 4 6 4 2 7 4 1 7 3 3 9 5 3 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTwo players play a simple game. Each player is provided with a box with balls. First player's box contains exactly n1 balls and second player's box contains exactly n2 balls. In one move first player can take from 1 to k1...
[{"type": "stdin_stdout", "input": "50 50 50 50\n", "output": "Second\n"}, {"type": "stdin_stdout", "input": "48 50 12 11\n", "output": "Second\n"}, {"type": "stdin_stdout", "input": "49 50 11 12\n", "output": "Second\n"}, {"type": "stdin_stdout", "input": "50 50 87 50\n", "output": "Second\n"}, {"type": "stdin_stdout"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDeveloping tools for creation of locations maps for turn-based fights in a new game, Petya faced the following problem.\n\nA field map consists of hexagonal cells. Since locations sizes are going to be big, a game designe...
[{"type": "stdin_stdout", "input": "-1000000000 -1000000000 1000000000 1000000000\n", "output": "2000000002000000001"}, {"type": "stdin_stdout", "input": "-1000000000 -999999999 1000000000 999999999\n", "output": "2000000000000000000"}, {"type": "stdin_stdout", "input": "-999999999 -1000000000 999999999 1000000000\n", ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAnd while Mishka is enjoying her trip...\n\nChris is a little brown bear. No one knows, where and when he met Mishka, but for a long time they are together (excluding her current trip). However, best friends are important...
[{"type": "stdin_stdout", "input": "10 1000 998 596\n1681 18\n2048 59\n2110 98\n2201 185\n2282 327\n2250 743\n3529 893\n1844 999\n1618 960\n1564 934\n", "output": "1.6778523489932886\n"}, {"type": "stdin_stdout", "input": "10 1001 458 393\n826 363\n1241 4\n1402 9\n1441 18\n1800 417\n1804 555\n1248 997\n1207 990\n1116 9...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet’s define a grid to be a set of tiles with 2 rows and 13 columns. Each tile has an English letter written in it. The letters don't have to be unique: there might be two or more tiles with the same letter written on the...
[{"type": "stdin_stdout", "input": "ABCDEFGHIJKLMNOPQRSGTUVWXYZ\n", "output": "ABCDEFGHIJKLM\nZYXWVUTSRQPON\n"}, {"type": "stdin_stdout", "input": "MKBGVNDJRAWUEHFSYLIZCOPTXKQ\n", "output": "MKBGVNDJRAWUE\nQXTPOCZILYSFH\n"}, {"type": "stdin_stdout", "input": "ABACDEFGHIJKLMNOPQRSTUVWXYZ\n", "output": "OPQRSTUVWXYZA\nNM...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are n servers in a laboratory, each of them can perform tasks. Each server has a unique id — integer from 1 to n.\n\nIt is known that during the day q tasks will come, the i-th of them is characterized with three in...
[{"type": "stdin_stdout", "input": "1 10\n4 1 1\n9 1 1\n10 1 1\n12 1 1\n13 1 1\n15 1 1\n16 1 1\n18 1 1\n19 1 1\n20 1 1\n", "output": "1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n"}, {"type": "stdin_stdout", "input": "4 10\n1 1 1\n3 1 2\n4 1 2\n6 1 2\n8 1 2\n13 1 2\n16 1 1\n17 1 2\n19 3 1\n20 1 1\n", "output": "1\n1\n2\n1\n1\n1\n1\n1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOleg the client and Igor the analyst are good friends. However, sometimes they argue over little things. Recently, they started a new company, but they are having trouble finding a name for the company.\n\nTo settle this ...
[{"type": "stdin_stdout", "input": "tinkoff\nzscoder\n", "output": "fzfsirk\n"}, {"type": "stdin_stdout", "input": "tinkogf\nzscoder\n", "output": "fzgsirk"}, {"type": "stdin_stdout", "input": "thnkogf\nzscoder\n", "output": "fzgshrk"}, {"type": "stdin_stdout", "input": "ffoknht\nzscoder\n", "output": "fzfshrk"}, {"typ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nKaren has just arrived at school, and she has a math test today!\n\n<image>\n\nThe test is about basic addition and subtraction. Unfortunately, the teachers were too busy writing tasks for Codeforces rounds, and had no ti...
[{"type": "stdin_stdout", "input": "19\n519879446 764655030 680293934 914539062 744988123 317088317 653721289 239862203 605157354 943428394 261437390 821695238 312192823 432992892 547139308 408916833 829654733 223751525 672158759\n", "output": "\n265109293\n"}, {"type": "stdin_stdout", "input": "19\n519879446 764655030...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe All-Berland National Olympiad in Informatics has just ended! Now Vladimir wants to upload the contest from the Olympiad as a gym to a popular Codehorses website.\n\nUnfortunately, the archive with Olympiad's data is a...
[{"type": "stdin_stdout", "input": "20\nphp8vy 1\nkeeona 0\n8 0\nwzf4eb 0\n16 1\n9 0\nf2548d 0\n11 0\nyszsig 0\nyyf4q2 0\n1pon1p 1\njvpwuo 0\nd9stsx 0\ne14bkx 1\n5 0\n17 0\nsbklx4 0\nsfms2u 1\n6 0\n18 1\n", "output": "16\nmove 16 1\nmove 18 2\nmove 5 10\nmove 6 12\nmove 1pon1p 3\nmove e14bkx 4\nmove php8vy 5\nmove sfms...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAbsent-minded Masha got set of n cubes for her birthday.\n\nAt each of 6 faces of each cube, there is exactly one digit from 0 to 9. Masha became interested what is the largest natural x such she can make using her new cu...
[{"type": "stdin_stdout", "input": "3\n0 1 3 5 6 8\n1 2 4 5 7 8\n2 3 4 6 7 9\n", "output": "98\n"}, {"type": "stdin_stdout", "input": "3\n0 1 2 3 4 5\n6 7 8 9 0 1\n2 3 4 5 6 7\n", "output": "87\n"}, {"type": "stdin_stdout", "input": "3\n5 1 2 9 6 4\n9 0 6 4 2 8\n4 6 2 8 3 7\n", "output": "10\n"}, {"type": "stdin_stdout...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasya and Kolya play a game with a string, using the following rules. Initially, Kolya creates a string s, consisting of small English letters, and uniformly at random chooses an integer k from a segment [0, len(s) - 1]. ...
[{"type": "stdin_stdout", "input": "jkeaagakbifeaechkifkdghcjcgighidcgdccgbdbcackfgaebkddabgijkhjkaffkabacekdkjekeccegbecbkecbgbgcacgdackcdfjefaifgbigahkbedidfhjbikejdhejcgideaeejdcefeeccaefbddejkbdkfagfcdjbikbidfggkidcdcic\n", "output": "0.44919786096256686\n"}, {"type": "stdin_stdout", "input": "jkeaagakbifeaechkifkd...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMishka received a gift of multicolored pencils for his birthday! Unfortunately he lives in a monochrome world, where everything is of the same color and only saturation differs. This pack can be represented as a sequence ...
[{"type": "stdin_stdout", "input": "10 5 293149357\n79072863 760382815 358896034 663269192 233367425 32795628 837363300 46932461 179556769 763342555\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "18 2 86\n665 408 664 778 309 299 138 622 229 842 498 389 140 976 456 265 963 777\n", "output": "YES\n"}, {"type":...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRhezo and his friend Vanya love problem solving. They have a problem set containing N problems, with points assigned to each. Rhezo wants to solve problems in such a way that he gets the maximum number of points. Rhezo ha...
[{"type": "stdin_stdout", "input": "4\n-1 -1 -5 21\n\nAQTMHT", "output": "16\n"}, {"type": "stdin_stdout", "input": "4\n-1 -3 22 -2\n\nTIXTL?", "output": "20\n"}, {"type": "stdin_stdout", "input": "4\n10 0 -1 24\n\nMNASGR", "output": "23\n"}, {"type": "stdin_stdout", "input": "4\n0 -1 -1 40\n\nMNASGR", "output": "39\n"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nN persons are standing in a row. The height of the i-th person from the front is A_i.\n\nWe want to have each person stand on a stool of some heights - at least zero - so that the following condition is satisfied for ever...
[{"type": "stdin_stdout", "input": "5\n49 10 1 -4 -1", "output": "190\n"}, {"type": "stdin_stdout", "input": "5\n49 10 2 -4 -1", "output": "189\n"}, {"type": "stdin_stdout", "input": "5\n49 10 0 -4 -1", "output": "191\n"}, {"type": "stdin_stdout", "input": "5\n4 -1 107 3 0", "output": "216\n"}, {"type": "stdin_stdout",...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are N children standing in a line from left to right. The activeness of the i-th child from the left is A_i.\n\nYou can rearrange these children just one time in any order you like.\n\nWhen a child who originally oc...
[{"type": "stdin_stdout", "input": "6\n16 10 33 1 2 1", "output": "196\n"}, {"type": "stdin_stdout", "input": "6\n16 10 66 1 2 1", "output": "295\n"}, {"type": "stdin_stdout", "input": "6\n16 10 48 1 2 1", "output": "241\n"}, {"type": "stdin_stdout", "input": "6\n16 18 66 1 2 1", "output": "313\n"}, {"type": "stdin_std...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWe have N integers. The i-th integer is A_i.\n\nFind \\sum_{i=1}^{N-1}\\sum_{j=i+1}^{N} (A_i \\mbox{ XOR } A_j), modulo (10^9+7).\n\nWhat is \\mbox{ XOR }?\n\nThe XOR of integers A and B, A \\mbox{ XOR } B, is defined as ...
[{"type": "stdin_stdout", "input": "10\n1 14 159 2653 58979 323846 2643383 27950288 419716939 9375105820", "output": "103715608\n"}, {"type": "stdin_stdout", "input": "10\n1 14 159 2653 58979 376446 2643383 27950288 419716939 9375105820", "output": "104328928\n"}, {"type": "stdin_stdout", "input": "10\n1 14 159 2653 58...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given three strings A, B and C. Check whether they form a word chain.\n\nMore formally, determine whether both of the following are true:\n\n* The last character in A and the initial character in B are the same.\n...
[{"type": "stdin_stdout", "input": "baaaa`aaaa aabaaaaaaa aaaaa`aaab", "output": "YES\n"}, {"type": "stdin_stdout", "input": "baaaaaaa`` `aaaaaabaa aaaaa`aaab", "output": "YES\n"}, {"type": "stdin_stdout", "input": "baaabaaa`` `aaaaaabaa aaaaa`aaab", "output": "YES\n"}, {"type": "stdin_stdout", "input": "baaabaaa`` `aa...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a permutation P_1 ... P_N of the set {1, 2, ..., N}.\n\nYou can apply the following operation to this permutation, any number of times (possibly zero):\n\n* Choose two indices i,j (1 ≦ i < j ≦ N), such that ...
[{"type": "stdin_stdout", "input": "8 2\n4 5 7 8 3 1 2 6", "output": "1\n2\n3\n6\n5\n4\n7\n8\n"}, {"type": "stdin_stdout", "input": "8 6\n4 5 7 8 3 1 2 6", "output": "4\n5\n7\n8\n3\n1\n2\n6\n"}, {"type": "stdin_stdout", "input": "8 5\n4 5 7 8 3 1 2 6", "output": "4\n5\n6\n8\n3\n1\n2\n7\n"}, {"type": "stdin_stdout", "in...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDr .: Peter. I did.\n\nPeter: See you again? What kind of silly invention is this time?\n\nDr .: You invented the detector for that phantom elementary particle axion.\n\nPeter: Speaking of Axion, researchers such as the E...
[{"type": "stdin_stdout", "input": "1\n0 1 0 0 0 0 0 0 0 0\n1 1 1 0 0 0 0 0 0 0\n0 1 0 0 0 0 0 0 0 0\n0 0 0 0 0 1 0 0 0 0\n0 0 0 1 0 0 1 0 0 0\n0 0 0 0 1 1 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 1 0\n0 0 0 0 0 0 0 1 1 1\n0 0 0 0 0 0 0 0 1 0", "output": "0 0 0 0 1 0 1 0 0 0\n0 1 0 1 1 0 1 1 0 0\n0 0 1 0 1 0 1 0 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nI decided to move and decided to leave this place. There is nothing wrong with this land itself, but there is only one thing to worry about. It's a plum tree planted in the garden. I was looking forward to this plum bloom...
[{"type": "stdin_stdout", "input": "6 3\n2 1\n0 2\n5 8\n1 3\n1 5\n-2 2\n1 1 1 59 30 16\n3 -4\n-3 0\n2 -2\n45 11\n90 6\n135 1\n2 1\n1 3\n5 2\n0 1 1 124 30 22\n-3 0\n1 -2\n37 2\n0 0", "output": "1 2 3 4 5\nNA\n"}, {"type": "stdin_stdout", "input": "6 3\n2 1\n1 2\n5 3\n1 2\n1 5\n-2 3\n1 1 1 90 30 45\n3 -4\n-3 0\n2 -2\n45 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nproblem\n\nGiven two strings, find the longest of the strings contained in both strings and write a program that answers that length.\n\nHere, the string s included in the string t means that s appears consecutively in t....
[{"type": "stdin_stdout", "input": "ABRACADAARA\nECADADABRBCRDARA\nUPWJCIRUCAXIIRGL\nSBQNYBSBZDFNEV", "output": "4\n0\n"}, {"type": "stdin_stdout", "input": "DBRACAAAARA\nECADADBBRBCRDARA\nLCRIIXACURIGJWPU\nSBQNYBSBZDFOEV", "output": "3\n0\n"}, {"type": "stdin_stdout", "input": "DBRACAAAARA\nECADADBBRBBRDARA\nLCRIIXACU...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nProblem Statement\n\nThere is a maze which can be described as a W \\times H grid. The upper-left cell is denoted as (1, 1), and the lower-right cell is (W, H). You are now at the cell (1, 1) and have to go to the cell (W...
[{"type": "stdin_stdout", "input": "3 3\nac#\nb#C\n.BA\n3 3\naaZ\na#Z\naZZ\n3 3\n..#\n.#.\n#..\n1 50\nabcdefghijklmnopqrstuvwxyYXWVUTSRQPONMLKJIHGFEDCBA\n1 50\naAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyY\n1 50\nabcdefghijklmnopqrstuvwxyABCDEFGHIJKLMNOPQRSTUVWXY\n1 50\naaaaaaaaaabbbbbbbbbbcccccCCCCCBBBBBBBBBBAAAA...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nProblem statement\n\nThere is a positive integer sequence $ a_1, a_2, \\ ldots, a_N $ of length $ N $.\n\nConsider the following game, which uses this sequence and is played by $ 2 $ players on the play and the play.\n\n*...
[{"type": "stdin_stdout", "input": "2\n10 -2", "output": "Second\n"}, {"type": "stdin_stdout", "input": "2\n-1 10", "output": "First\n"}, {"type": "stdin_stdout", "input": "2\n-2 2", "output": "Second\n"}, {"type": "stdin_stdout", "input": "2\n-2 4", "output": "Second\n"}, {"type": "stdin_stdout", "input": "2\n-2 8", "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given n segments on a coordinate line; each endpoint of every segment has integer coordinates. Some segments can degenerate to points. Segments can intersect with each other, be nested in each other or even coinci...
[{"type": "stdin_stdout", "input": "1\n1 1000000000000000000\n", "output": "1000000000000000000 \n"}, {"type": "stdin_stdout", "input": "1\n0 1000000000000000000\n", "output": "1000000000000000001\n"}, {"type": "stdin_stdout", "input": "1\n2 1000000000000000000\n", "output": "999999999999999999 \n"}, {"type": "stdin_st...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDima the hamster enjoys nibbling different things: cages, sticks, bad problemsetters and even trees!\n\nRecently he found a binary search tree and instinctively nibbled all of its edges, hence messing up the vertices. Dim...
[{"type": "stdin_stdout", "input": "36\n3 41 82 123 174 216 432 864 1080 1228 2149 4298 8596 11052 22104 33156 35919 71838 179595 359190 431028 862056 994680 1315440 1753920 3507840 7015680 10523520 21047040 26500200 53000400 106000800 132501000 176668000 353336000 530004000\n", "output": "Yes\n"}, {"type": "stdin_stdo...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIvan places knights on infinite chessboard. Initially there are n knights. If there is free cell which is under attack of at least 4 knights then he places new knight in this cell. Ivan repeats this until there are no suc...
[{"type": "stdin_stdout", "input": "2163\n", "output": "0 1\n0 2\n0 3\n0 4\n0 5\n0 6\n0 7\n0 8\n0 9\n0 10\n0 11\n0 12\n0 13\n0 14\n0 15\n0 16\n0 17\n0 18\n0 19\n0 20\n0 21\n0 22\n0 23\n0 24\n0 25\n0 26\n0 27\n0 28\n0 29\n0 30\n0 31\n0 32\n0 33\n0 34\n0 35\n0 36\n0 37\n0 38\n0 39\n0 40\n0 41\n0 42\n0 43\n0 44\n0 45\n0 4...
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": "99994\n", "output": "abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabc...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are n students and m clubs in a college. The clubs are numbered from 1 to m. Each student has a potential p_i and is a member of the club with index c_i. Initially, each student is a member of exactly one club. A te...
[{"type": "stdin_stdout", "input": "20 20\n0 0 3 2 1 2 2 3 2 2 1 1 0 3 0 0 1 1 1 3\n15 1 20 13 6 12 16 8 3 14 10 5 18 17 4 9 2 11 7 19\n20\n2\n10\n7\n4\n6\n5\n14\n8\n9\n18\n13\n11\n19\n1\n16\n20\n17\n12\n15\n3\n", "output": "4\n4\n4\n4\n4\n4\n4\n4\n2\n2\n2\n2\n2\n2\n2\n2\n2\n1\n0\n0\n"}, {"type": "stdin_stdout", "input...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given two arrays a and b, both of length n. All elements of both arrays are from 0 to n-1.\n\nYou can reorder elements of the array b (if you want, you may leave the order of elements as it is). After that, let ar...
[{"type": "stdin_stdout", "input": "10\n6 3 0 5 4 5 5 5 8 5\n3 8 2 9 5 4 1 0 3 6\n", "output": "0 1 0 0 0 4 6 7 1 8 "}, {"type": "stdin_stdout", "input": "10\n6 3 0 5 4 5 5 4 8 5\n3 8 2 9 5 4 1 0 3 6\n", "output": "0 1 0 0 0 4 6 6 1 8\n"}, {"type": "stdin_stdout", "input": "10\n6 3 0 5 6 5 5 5 8 5\n3 8 2 9 5 4 1 0 3 6\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a graph with 3 ⋅ n vertices and m edges. You are to find a matching of n edges, or an independent set of n vertices.\n\nA set of edges is called a matching if no two edges share an endpoint.\n\nA set of vert...
[{"type": "stdin_stdout", "input": "1\n5 39\n1 2\n3 4\n5 6\n7 8\n1 9\n3 10\n3 11\n5 12\n5 13\n7 14\n7 15\n9 2\n10 2\n11 2\n12 2\n13 2\n14 2\n15 2\n9 4\n10 4\n11 4\n12 4\n13 4\n14 4\n15 4\n9 6\n10 6\n11 6\n12 6\n13 6\n14 6\n15 6\n9 8\n10 8\n11 8\n12 8\n13 8\n14 8\n15 8\n", "output": "IndSet\n9 10 11 12 13 \n"}, {"type":...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a sequence a_1, a_2, ..., a_n consisting of n non-zero integers (i.e. a_i ≠ 0). \n\nYou have to calculate two following values:\n\n 1. the number of pairs of indices (l, r) (l ≤ r) such that a_l ⋅ a_{l + 1}...
[{"type": "stdin_stdout", "input": "10\n-27433367 -21216390 1 303383863 -799030648 -1 160141051 -1 -342089574 -215298491\n", "output": "28 27\n"}, {"type": "stdin_stdout", "input": "10\n4 2 -11 4 1 3 -4 9 2 3\n", "output": "28 27\n"}, {"type": "stdin_stdout", "input": "10\n4 2 -4 3 1 2 -4 3 2 3\n", "output": "28 27\n"}...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe string t_1t_2 ... t_k is good if each letter of this string belongs to at least one palindrome of length greater than 1.\n\nA palindrome is a string that reads the same backward as forward. For example, the strings A,...
[{"type": "stdin_stdout", "input": "7\nAAABABB\n", "output": "15\n"}, {"type": "stdin_stdout", "input": "7\nBBABAAA\n", "output": "15\n"}, {"type": "stdin_stdout", "input": "7\nBAAAABB\n", "output": "12\n"}, {"type": "stdin_stdout", "input": "7\nABABAAB\n", "output": "14\n"}, {"type": "stdin_stdout", "input": "7\nBBAAA...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAfter years of hard work scientists invented an absolutely new e-reader display. The new display has a larger resolution, consumes less energy and its production is cheaper. And besides, one can bend it. The only inconven...
[{"type": "stdin_stdout", "input": "10\n1101010101\n1110101010\n0111010101\n1011101010\n0101110101\n1010111010\n0101011101\n1010101110\n0101010111\n1010101011\n", "output": "100\n"}, {"type": "stdin_stdout", "input": "10\n1111100000\n0010100000\n0110111000\n0000001000\n1011001010\n0010100001\n0010111000\n0011001010\n00...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nCalculate the number of ways to place n rooks on n × n chessboard so that both following conditions are met:\n\n * each empty cell is under attack; \n * exactly k pairs of rooks attack each other. \n\n\n\nAn empty cell ...
[{"type": "stdin_stdout", "input": "200000 199998\n", "output": "508670650\n"}, {"type": "stdin_stdout", "input": "200000 100000\n", "output": "668585001\n"}, {"type": "stdin_stdout", "input": "200000 132521\n", "output": "660798392\n"}, {"type": "stdin_stdout", "input": "200000 89177\n", "output": "773611800\n"}, {"ty...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a deck of n cards numbered from 1 to n (not necessarily in this order in the deck). You have to sort the deck by repeating the following operation. \n\n * Choose 2 ≤ k ≤ n and split the deck in k nonempty c...
[{"type": "stdin_stdout", "input": "51\n51 50 16 48 47 46 45 44 43 42 41 40 39 38 37 33 35 34 36 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 49 15 14 13 12 11 10 4 8 7 6 5 9 3 2 1\n", "output": "51\n2 50 1\n2 1 50\n4 48 1 1 1\n5 1 1 1 43 5\n6 3 44 1 1 1 1\n6 1 1 1 1 1 46\n8 44 1 1 1 1 1 1 1\n8 1 1 1 1 1 1 1 44\n9 4...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOn the competitive programming platform CodeCook, every person has a rating graph described by an array of integers a of length n. You are now updating the infrastructure, so you've created a program to compress these gra...
[{"type": "stdin_stdout", "input": "5\n5\n1 5 3 4 2\n4\n1 3 2 1\n5\n1 3 3 3 2\n10\n1 2 3 4 5 6 7 8 9 10\n3\n3 3 2\n", "output": "\n10111\n0001\n00111\n1111111111\n000\n"}, {"type": "stdin_stdout", "input": "5\n5\n1 5 3 4 2\n4\n1 3 2 1\n5\n1 3 3 3 1\n10\n1 2 3 4 5 10 7 8 9 10\n3\n3 3 2\n", "output": "10111\n0001\n00001\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPositive integer x is called divisor of positive integer y, if y is divisible by x without remainder. For example, 1 is a divisor of 7 and 3 is not divisor of 8.\n\nWe gave you an integer d and asked you to find the small...
[{"type": "stdin_stdout", "input": "2\n14\n100\n", "output": "527\n21311\n"}, {"type": "stdin_stdout", "input": "2\n14\n110\n", "output": "527\n25199\n"}, {"type": "stdin_stdout", "input": "2\n14\n111\n", "output": "527\n25651\n"}, {"type": "stdin_stdout", "input": "2\n60\n25\n", "output": "7747\n1711\n"}, {"type": "st...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSergey attends lessons of the N-ish language. Each lesson he receives a hometask. This time the task is to translate some sentence to the N-ish language. Sentences of the N-ish language can be represented as strings consi...
[{"type": "stdin_stdout", "input": "ttspivgoupgupvgpusvppogsseueusuglpiugssviuutlvgvugtpovuvspvpipggooplgvgugpogvesppulovugsvuougveiivgvslllviogpvtolepglguuellotpvgevspvoiiggiiplppgosuguvtstttpielteuglspgeoeeuivtptggltoltpgliviotsospvitupiopisoetupvvspooilsopslpoloptigstspoiuutiuvvuvlpplvioitsuvlpvtleveslslovolloogsgpv...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe Smart Beaver from ABBYY invented a new message encryption method and now wants to check its performance. Checking it manually is long and tiresome, so he decided to ask the ABBYY Cup contestants for help.\n\nA message...
[{"type": "stdin_stdout", "input": "80 6 99\n48 97 9 77 73 21 86 78 48 5 71 16 42 67 90 27 30 52 41 86 53 4 60 17 66 38 94 46 51 51 70 11 1 16 74 53 17 12 82 95 51 33 83 70 45 27 90 57 67 2 68 15 20 61 47 90 11 5 95 33 69 35 79 51 95 45 10 17 12 88 93 43 31 31 85 68 85 81 70 43\n47 92 59 85 73 38\n", "output": "95 38 9...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou've got a list of program warning logs. Each record of a log stream is a string in this format: \n\n\"2012-MM-DD HH:MM:SS:MESSAGE\" (without the quotes). \n\nString \"MESSAGE\" consists of spaces, uppercase and lowerca...
[{"type": "stdin_stdout", "input": "60 3\n2012-03-16 16:15:25: Disk size is\n2012-03-16 16:15:25: Network failute\n2012-03-16 16:16:29: Cant write varlog\n2012-03-16 16:16:42: Unable to start process\n2012-03-16 16:16:43: Disk size is too small\n2012-03-16 16:16:53: Timeout detected\n", "output": "2012-03-16 16:16:43\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nEmuskald is an avid horticulturist and owns the world's longest greenhouse — it is effectively infinite in length.\n\nOver the years Emuskald has cultivated n plants in his greenhouse, of m different plant species numbere...
[{"type": "stdin_stdout", "input": "20 15\n7 8720.017100830131\n2 13067.215819731118\n8 58623.690996\n9 184322.3412850205\n6 227999.61123331118\n2 279836.330518\n9 282807.34217112145\n2 311057.23684687156\n1 312315.562927\n5 459200.373445\n14 563454.265947\n11 647366.9355815595\n13 679761.613732\n4 684192.647497\n3 733...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nShaass has decided to hunt some birds. There are n horizontal electricity wires aligned parallel to each other. Wires are numbered 1 to n from top to bottom. On each wire there are some oskols sitting next to each other. ...
[{"type": "stdin_stdout", "input": "100\n54 15 25 18 64 62 23 59 70 137 50 26 87 35 75 86 0 22 6 60 70 41 21 9 75 50 25 3 69 14 39 68 64 46 59 99 2 0 21 76 90 12 61 42 12 91 36 39 47 41 93 81 66 57 70 36 68 89 52 1 19 93 67 22 76 20 8 81 123 18 100 73 61 93 75 80 53 72 40 20 2 86 33 70 27 16 11 26 55 44 47 55 94 58 2 5...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasya and Petya wrote down all integers from 1 to n to play the \"powers\" game (n can be quite large; however, Vasya and Petya are not confused by this fact).\n\nPlayers choose numbers in turn (Vasya chooses first). If s...
[{"type": "stdin_stdout", "input": "1000000000\n", "output": "Vasya\n"}, {"type": "stdin_stdout", "input": "1000000001\n", "output": "Vasya\n"}, {"type": "stdin_stdout", "input": "0000000001\n", "output": "Vasya\n"}, {"type": "stdin_stdout", "input": "947039074\n", "output": "Vasya\n"}, {"type": "stdin_stdout", "input"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet's call a number k-good if it contains all digits not exceeding k (0, ..., k). You've got a number k and an array a containing n numbers. Find out how many k-good numbers are in a (count each number every time it occur...
[{"type": "stdin_stdout", "input": "10 6\n1234560\n1234560\n1234560\n1234560\n1234560\n1234560\n1234560\n1234560\n1234560\n1234560\n", "output": "10\n"}, {"type": "stdin_stdout", "input": "10 6\n2416023\n1234560\n1234560\n1234560\n1234560\n1234560\n1234560\n1234560\n1234560\n1234560\n", "output": "9\n"}, {"type": "stdi...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSalve, mi amice.\n\nEt tu quidem de lapis philosophorum. Barba non facit philosophum. Labor omnia vincit. Non potest creatio ex nihilo. Necesse est partibus.\n\nRp:\n\nI Aqua Fortis\n\nI Aqua Regia\n\nII Amalgama\n\nVII M...
[{"type": "stdin_stdout", "input": "100 100 100 100 100\n", "output": "14\n"}, {"type": "stdin_stdout", "input": "100 110 100 100 100\n", "output": "14\n"}, {"type": "stdin_stdout", "input": "100 110 100 110 100\n", "output": "15\n"}, {"type": "stdin_stdout", "input": "60 120 82 71 53\n", "output": "10\n"}, {"type": "s...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPashmak's homework is a problem about graphs. Although he always tries to do his homework completely, he can't solve this problem. As you know, he's really weak at graph theory; so try to help him in solving the problem.\...
[{"type": "stdin_stdout", "input": "10 12\n1 2 2\n2 1 2\n1 3 1\n3 1 1\n1 4 1\n4 1 1\n2 3 1\n3 2 1\n2 4 1\n4 2 1\n3 4 2\n4 3 2\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "4 12\n1 2 2\n2 1 2\n1 3 1\n3 1 1\n1 4 1\n4 1 1\n2 3 1\n3 2 1\n2 4 1\n4 2 1\n3 4 2\n4 3 2\n", "output": "2\n"}, {"type": "stdin_stdout", "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nShuseki Kingdom is the world's leading nation for innovation and technology. There are n cities in the kingdom, numbered from 1 to n.\n\nThanks to Mr. Kitayuta's research, it has finally become possible to construct telep...
[{"type": "stdin_stdout", "input": "7 13\n6 1\n7 2\n3 7\n6 5\n3 6\n7 4\n3 5\n4 1\n3 1\n1 5\n1 6\n4 2\n2 4\n", "output": "7\n"}, {"type": "stdin_stdout", "input": "7 13\n6 1\n7 2\n3 7\n6 5\n3 6\n7 4\n3 7\n4 1\n3 1\n1 5\n1 6\n4 2\n2 4\n", "output": "7\n"}, {"type": "stdin_stdout", "input": "7 13\n6 1\n7 2\n3 7\n6 5\n3 6\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are many anime that are about \"love triangles\": Alice loves Bob, and Charlie loves Bob as well, but Alice hates Charlie. You are thinking about an anime which has n characters. The characters are labeled from 1 to...
[{"type": "stdin_stdout", "input": "28567 13\n28079 24675 1\n18409 26720 1\n980 10815 1\n20794 16571 1\n7376 19861 1\n10805 706 1\n4255 16391 1\n27376 18263 1\n10019 28444 1\n6574 28053 1\n5036 16610 1\n3543 7122 1\n512 9554 1\n", "output": "928433852\n"}, {"type": "stdin_stdout", "input": "28567 13\n28079 24675 1\n184...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWhen Kefa came to the restaurant and sat at a table, the waiter immediately brought him the menu. There were n dishes. Kefa knows that he needs exactly m dishes. But at that, he doesn't want to order the same dish twice t...
[{"type": "stdin_stdout", "input": "18 17 16\n298794979 56088167 220017066 212013239 193074498 269869999 238524920 107690830 236214025 114513789 305713075 41451289 198089336 246759776 267311824 142373649 312495533 217782770\n9 4 70536531\n13 14 235114377\n18 4 38527037\n3 7 39141694\n1 17 15392162\n6 17 35451325\n17 14...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn Absurdistan, there are n towns (numbered 1 through n) and m bidirectional railways. There is also an absurdly simple road network — for each pair of different towns x and y, there is a bidirectional road between towns ...
[{"type": "stdin_stdout", "input": "4 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "10 5\n2 5\n1 2\n1 4\n1 3\n3 2\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "5 5\n4 2\n3 5\n4 5\n5 1\n1 2\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "4 5\n1 3\n2 1\n3 4...
code_stdio