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\nInternational Women's Day is coming soon! Polycarp is preparing for the holiday.\n\nThere are $n$ candy boxes in the shop for sale. The $i$-th box contains $d_i$ candies.\n\nPolycarp wants to prepare the maximum number of...
[{"type": "stdin_stdout", "input": "8 2\n1 2 2 3 2 4 6 10\n", "output": "8\n"}, {"type": "stdin_stdout", "input": "7 2\n1 2 2 3 2 4 10\n", "output": "6\n"}, {"type": "stdin_stdout", "input": "7 3\n1 2 2 3 2 4 5\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "3 1\n1 1 1\n", "output": "2\n"}, {"type": "stdin_std...
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 A, B and C, and an integer K which is between 1 and N (inclusive).\nPrint the string S after lowercasing the K-th character in it.\n\n-----Constraints-----\n - 1 ≀ N ≀ 50...
[{"type": "stdin_stdout", "input": "50 27\nACBCABCCCAACACCBBBACCBCBBBCCBAAAABAACACAAACCACCCCA\n", "output": "ACBCABCCCAACACCBBBACCBCBBBcCBAAAABAACACAAACCACCCCA\n"}, {"type": "stdin_stdout", "input": "50 50\nCABABCBBCBABCAACBCBBAAAACBCBCBBABBABBBCCBAACCAACAB\n", "output": "CABABCBBCBABCAACBCBBAAAACBCBCBBABBABBBCCBAACCAA...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTakahashi has K 500-yen coins. (Yen is the currency of Japan.)\nIf these coins add up to X yen or more, print Yes; otherwise, print No.\n\n-----Constraints-----\n - 1 \\leq K \\leq 100\n - 1 \\leq X \\leq 10^5\n\n-----Inp...
[{"type": "stdin_stdout", "input": "100 100000\n", "output": "No\n"}, {"type": "stdin_stdout", "input": "84 42001\n", "output": "No\n"}, {"type": "stdin_stdout", "input": "13 6498\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "4 2000\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "2 900\n", "outp...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSnuke has a fair N-sided die that shows the integers from 1 to N with equal probability and a fair coin. He will play the following game with them:\n - Throw the die. The current score is the result of the die.\n - As lon...
[{"type": "stdin_stdout", "input": "10000 100000\n", "output": "0.036463721466\n"}, {"type": "stdin_stdout", "input": "3904 16384\n", "output": "0.081316166237\n"}, {"type": "stdin_stdout", "input": "100000 5\n", "output": "0.999973749998\n"}, {"type": "stdin_stdout", "input": "97392 33\n", "output": "0.999781007423\n"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGiven is a string S representing the day of the week today.\nS is SUN, MON, TUE, WED, THU, FRI, or SAT, for Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday, respectively.\nAfter how many days is the nex...
[{"type": "stdin_stdout", "input": "SAT\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "SUN\n", "output": "7\n"}, {"type": "stdin_stdout", "input": "FRI\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "MON\n", "output": "6\n"}, {"type": "stdin_stdout", "input": "THU\n", "output": "3\n"}, {"type": "stdi...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe development of algae in a pond is as follows.\nLet the total weight of the algae at the beginning of the year i be x_i gram. For iβ‰₯2000, the following formula holds:\n - x_{i+1} = rx_i - D\nYou are given r, D and x_{2...
[{"type": "stdin_stdout", "input": "5 1 200\n", "output": "999\n4994\n24969\n124844\n624219\n3121094\n15605469\n78027344\n390136719\n1950683594\n"}, {"type": "stdin_stdout", "input": "4 49 188\n", "output": "703\n2763\n11003\n43963\n175803\n703163\n2812603\n11250363\n45001403\n180005563\n"}, {"type": "stdin_stdout", "i...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an array $d_1, d_2, \\dots, d_n$ consisting of $n$ integer numbers.\n\nYour task is to split this array into three parts (some of which may be empty) in such a way that each element of the array belongs to e...
[{"type": "stdin_stdout", "input": "1\n1000000000\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "5\n1 3 1 1 4\n", "output": "5\n"}, {"type": "stdin_stdout", "input": "5\n1 3 2 1 4\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "5\n1 3 5 4 5\n", "output": "9\n"}, {"type": "stdin_stdout", "input": "3\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given three positive (i.e. strictly greater than zero) integers $x$, $y$ and $z$.\n\nYour task is to find positive integers $a$, $b$ and $c$ such that $x = \\max(a, b)$, $y = \\max(a, c)$ and $z = \\max(b, c)$, or...
[{"type": "stdin_stdout", "input": "5\n3 2 3\n100 100 100\n50 49 49\n10 30 20\n1 1000000000 1000000000\n", "output": "YES\n2 2 3\nYES\n100 100 100\nNO\nNO\nYES\n1 1 1000000000\n"}, {"type": "stdin_stdout", "input": "1\n127869 127869 127869\n", "output": "YES\n127869 127869 127869\n"}, {"type": "stdin_stdout", "input": ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRecently, Norge found a string $s = s_1 s_2 \\ldots s_n$ consisting of $n$ lowercase Latin letters. As an exercise to improve his typing speed, he decided to type all substrings of the string $s$. Yes, all $\\frac{n (n + ...
[{"type": "stdin_stdout", "input": "200 13\nvgfjhgkgwkftaeqejmbgildembgxdbskxfndwmcckjfkbeekxkgakmcjhclqsecpnkaigcxxhfghgegfadjktckftdhtifriemfifakygoesjfginnddjjklwiwlbjsgftwhtjdxmcadpvhaeddxwnmguwhetwbmffbmvdvuhecgjckddrbikgwkrfwfhdhqolidgkfm\na b c d e f g h i j k l m\n", "output": "578\n"}, {"type": "stdin_stdout",...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRecall that the sequence $b$ is a a subsequence of the sequence $a$ if $b$ can be derived from $a$ by removing zero or more elements without changing the order of the remaining elements. For example, if $a=[1, 2, 1, 3, 1,...
[{"type": "stdin_stdout", "input": "10\n10\n-1 5 6 2 -8 -7 -6 5 -3 -1\n10\n1 2 3 4 5 6 7 8 9 10\n1\n6\n1\n-7\n11\n5 -4 1 2 3 -5 -7 -10 -2 1 12\n4\n-4 -5 -6 1\n7\n1 2 6 3 2 -6 -2\n5\n-1 -5 4 -2 -9\n1\n9\n3\n1 -1 1\n", "output": "3\n10\n6\n-7\n14\n-3\n4\n1\n9\n1\n"}, {"type": "stdin_stdout", "input": "4\n5\n1 2 3 -1 -2\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an undirected unweighted connected graph consisting of $n$ vertices and $m$ edges. It is guaranteed that there are no self-loops or multiple edges in the given graph.\n\nYour task is to find any spanning tre...
[{"type": "stdin_stdout", "input": "8 9\n1 2\n2 3\n2 5\n1 6\n3 4\n6 5\n4 5\n2 7\n5 8\n", "output": "4 3\n7 2\n5 8\n5 2\n6 1\n2 3\n1 2\n"}, {"type": "stdin_stdout", "input": "5 6\n1 5\n2 5\n3 5\n4 5\n2 3\n1 2\n", "output": "5 3\n1 5\n4 5\n5 2\n"}, {"type": "stdin_stdout", "input": "5 6\n2 1\n2 3\n2 4\n2 5\n3 4\n3 5\n", ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a board of size $n \\times n$, where $n$ is odd (not divisible by $2$). Initially, each cell of the board contains one figure.\n\nIn one move, you can select exactly one figure presented in some cell and mov...
[{"type": "stdin_stdout", "input": "3\n5\n3005\n3005\n", "output": "40\n9045074040\n9045074040\n"}, {"type": "stdin_stdout", "input": "3\n1\n5\n499993\n", "output": "0\n40\n41664916690999888\n"}, {"type": "stdin_stdout", "input": "1\n499999\n", "output": "41666416667000000\n"}, {"type": "stdin_stdout", "input": "1\n214...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given one integer number $n$. Find three distinct integers $a, b, c$ such that $2 \\le a, b, c$ and $a \\cdot b \\cdot c = n$ or say that it is impossible to do it.\n\nIf there are several answers, you can print a...
[{"type": "stdin_stdout", "input": "21\n719\n5039\n39916801\n479001599\n28657\n514229\n433494437\n66047\n263167\n16785407\n999999757\n999999761\n999999797\n999999883\n999999893\n999999929\n999999937\n991026973\n985062919\n979134757\n971230541\n", "output": "NO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nNikolay got a string $s$ of even length $n$, which consists only of lowercase Latin letters 'a' and 'b'. Its positions are numbered from $1$ to $n$.\n\nHe wants to modify his string so that every its prefix of even length...
[{"type": "stdin_stdout", "input": "8\nbbbabbba\n", "output": "2\nabbaabba\n"}, {"type": "stdin_stdout", "input": "8\nbbabbbaa\n", "output": "3\nabababba\n"}, {"type": "stdin_stdout", "input": "6\nababab\n", "output": "0\nababab\n"}, {"type": "stdin_stdout", "input": "6\nbbbbba\n", "output": "2\nababba\n"}, {"type": "s...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMaksim walks on a Cartesian plane. Initially, he stands at the point $(0, 0)$ and in one move he can go to any of four adjacent points (left, right, up, down). For example, if Maksim is currently at the point $(0, 0)$, he...
[{"type": "stdin_stdout", "input": "39\n27 47\n30 9\n18 28\n49 16\n10 12\n25 13\n44 11\n13 9\n3 8\n30 2\n8 30\n38 32\n7 29\n38 43\n27 37\n6 13\n21 25\n31 18\n17 26\n51 52\n27 40\n10 43\n50 27\n41 41\n2 11\n38 45\n37 43\n20 52\n36 11\n43 46\n4 39\n22 32\n42 11\n8 37\n9 17\n38 8\n41 1\n24 50\n47 7\n", "output": "861\n"},...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTakahashi is solving quizzes. He has easily solved all but the last one.\nThe last quiz has three choices: 1, 2, and 3.\nWith his supernatural power, Takahashi has found out that the choices A and B are both wrong.\nPrint...
[{"type": "stdin_stdout", "input": "3\n1\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "1\n2\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "1\n3\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "3\n2\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "2\n1\n", "output": "3\n"}, {"type": ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGiven is a positive integer L.\nFind the maximum possible volume of a rectangular cuboid whose sum of the dimensions (not necessarily integers) is L.\n\n-----Constraints-----\n - 1 ≀ L ≀ 1000\n - L is an integer.\n\n-----...
[{"type": "stdin_stdout", "input": "1000\n", "output": "37037037.037037037313\n"}, {"type": "stdin_stdout", "input": "999\n", "output": "36926037.000000000000\n"}, {"type": "stdin_stdout", "input": "430\n", "output": "2944703.703703703824\n"}, {"type": "stdin_stdout", "input": "392\n", "output": "2230973.629629629664\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn 2020, AtCoder Inc. with an annual sales of more than one billion yen (the currency of Japan) has started a business in programming education.\n\nOne day, there was an exam where a one-year-old child must write a progra...
[{"type": "stdin_stdout", "input": "1\n", "output": "Hello World\n"}, {"type": "stdin_stdout", "input": "2\n8\n5\n", "output": "13\n"}, {"type": "stdin_stdout", "input": "2\n9\n9\n", "output": "18\n"}, {"type": "stdin_stdout", "input": "2\n5\n6\n", "output": "11\n"}, {"type": "stdin_stdout", "input": "2\n3\n5\n", "outp...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGiven are 1-digit positive integers a and b. Consider these two strings: the concatenation of b copies of the digit a, and the concatenation of a copies of the digit b. Which of these is lexicographically smaller?\n\n----...
[{"type": "stdin_stdout", "input": "9 1\n", "output": "111111111\n"}, {"type": "stdin_stdout", "input": "6 8\n", "output": "66666666\n"}, {"type": "stdin_stdout", "input": "7 7\n", "output": "7777777\n"}, {"type": "stdin_stdout", "input": "5 4\n", "output": "44444\n"}, {"type": "stdin_stdout", "input": "4 3\n", "output...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGiven is a lowercase English letter C that is not z. Print the letter that follows C in alphabetical order.\n\n-----Constraints-----\n - C is a lowercase English letter that is not z.\n\n-----Input-----\nInput is given fr...
[{"type": "stdin_stdout", "input": "a\n", "output": "b\n"}, {"type": "stdin_stdout", "input": "y\n", "output": "z\n"}, {"type": "stdin_stdout", "input": "c\n", "output": "d\n"}, {"type": "stdin_stdout", "input": "p\n", "output": "q\n"}, {"type": "stdin_stdout", "input": "d\n", "output": "e\n"}, {"type": "stdin_stdout",...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGiven are two strings S and T consisting of lowercase English letters. Concatenate T and S in this order, without space in between, and print the resulting string.\n\n-----Constraints-----\n - S and T are strings consisti...
[{"type": "stdin_stdout", "input": "oekdkfjdjgjknbfkwnfnhaoekdkfjdjgjknbfkwnfnhahjekkengkfoekdkfjdjgjknbfkwnfnhaoekdkfjdjgjknbfkwnfnhahj yowkymbmhkkgjjeokdlakbndkkworqotkfnblgpnkkrogjrfnvmbjisnbkzvmbnrrrigeoibgpefjobvmovpqosqoqrgrkengrlk\n", "output": "yowkymbmhkkgjjeokdlakbndkkworqotkfnblgpnkkrogjrfnvmbjisnbkzvmbnrrri...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPolycarp has an array $a$ consisting of $n$ integers.\n\nHe wants to play a game with this array. The game consists of several moves. On the first move he chooses any element and deletes it (after the first move the array...
[{"type": "stdin_stdout", "input": "2\n1000000 1000000\n", "output": "1000000\n"}, {"type": "stdin_stdout", "input": "6\n5 1 2 4 6 3\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "5\n1 5 7 8 2\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "5\n2 1 1 1 1\n", "output": "2\n"}, {"type": "stdin_stdout", ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are $n$ monsters standing in a row numbered from $1$ to $n$. The $i$-th monster has $h_i$ health points (hp). You have your attack power equal to $a$ hp and your opponent has his attack power equal to $b$ hp.\n\nYou...
[{"type": "stdin_stdout", "input": "6 2 3 3\n7 10 50 12 1 8\n", "output": "5\n"}, {"type": "stdin_stdout", "input": "7 4 2 1\n1 3 5 4 2 7 6\n", "output": "6\n"}, {"type": "stdin_stdout", "input": "2 1 100 2\n1 101\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "1 1 100 99\n100\n", "output": "1\n"}, {"type": "s...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an array consisting of $n$ integers $a_1, a_2, \\dots, a_n$, and a positive integer $m$. It is guaranteed that $m$ is a divisor of $n$.\n\nIn a single move, you can choose any position $i$ between $1$ and $n...
[{"type": "stdin_stdout", "input": "100 25\n6745 2075 7499 7517 1776 5164 2335 2745 4465 1457 7565 2232 2486 9025 8059 9646 8017 7662 9690 3352 2306 366 7422 1073 7169 8966 4506 8225 5614 8628 2908 7452 9625 9332 7097 353 1043 8118 5794 4486 626 971 6731 6618 887 6354 4814 7307 7681 6160 9351 2579 411 3436 5570 2812 27...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe only difference between easy and hard versions is constraints.\n\nIvan plays a computer game that contains some microtransactions to make characters look cooler. Since Ivan wants his character to be really cool, he wa...
[{"type": "stdin_stdout", "input": "78 36\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0\n1 52\n2 6\n9 43\n10 52\n4 63\n9 35\n10 67\n9 17\n3 43\n4 38\n1 27\n9 44\n6 74\n7 3\n8 18\n1 52\n1 68\n5 51\n5 2\n7 50\n1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are $n$ students at your university. The programming skill of the $i$-th student is $a_i$. As a coach, you want to divide them into teams to prepare them for the upcoming ICPC finals. Just imagine how good this univ...
[{"type": "stdin_stdout", "input": "10\n716243820 716243820 716243820 716243820 716243820 716243820 716243820 716243820 716243820 716243820\n", "output": "0 1\n1 1 1 1 1 1 1 1 1 1 \n"}, {"type": "stdin_stdout", "input": "10\n1 2 5 129 185 581 1041 1909 1580 8150\n", "output": "7486 3\n3 3 3 2 2 2 2 1 1 1 \n"}, {"type":...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA positive (strictly greater than zero) integer is called round if it is of the form d00...0. In other words, a positive integer is round if all its digits except the leftmost (most significant) are equal to zero. In part...
[{"type": "stdin_stdout", "input": "5\n5009\n7\n9876\n10000\n10\n", "output": "2\n9 5000 \n1\n7 \n4\n6 70 800 9000 \n1\n10000 \n1\n10 \n"}, {"type": "stdin_stdout", "input": "7\n1\n1\n1\n1\n1\n1\n1\n", "output": "1\n1 \n1\n1 \n1\n1 \n1\n1 \n1\n1 \n1\n1 \n1\n1 \n"}, {"type": "stdin_stdout", "input": "2\n9999\n52\n", "ou...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe only difference between easy and hard versions is constraints.\n\nThere are $n$ kids, each of them is reading a unique book. At the end of any day, the $i$-th kid will give his book to the $p_i$-th kid (in case of $i ...
[{"type": "stdin_stdout", "input": "20\n10\n3 8 1 4 9 6 10 2 7 5\n10\n10 4 8 6 5 3 1 2 9 7\n1\n1\n2\n2 1\n10\n2 5 3 6 9 7 4 10 8 1\n10\n1 7 4 6 9 10 8 2 3 5\n8\n3 8 1 7 6 4 2 5\n8\n7 4 5 2 8 1 6 3\n5\n1 2 4 3 5\n6\n4 2 5 6 3 1\n5\n5 3 2 4 1\n5\n4 3 5 1 2\n7\n6 5 1 7 4 2 3\n6\n6 2 4 1 5 3\n3\n3 1 2\n4\n1 3 4 2\n3\n3 1 2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are both a shop keeper and a shop assistant at a small nearby shop. You have $n$ goods, the $i$-th good costs $a_i$ coins.\n\nYou got tired of remembering the price of each product when customers ask for it, thus you ...
[{"type": "stdin_stdout", "input": "3\n5\n1 2 3 4 5\n3\n1 2 3\n2\n777 778\n", "output": "3\n2\n778\n"}, {"type": "stdin_stdout", "input": "3\n5\n1 2 3 4 5\n3\n1 2 2\n4\n1 1 1 1\n", "output": "3\n2\n1\n"}, {"type": "stdin_stdout", "input": "1\n1\n2441139\n", "output": "2441139\n"}, {"type": "stdin_stdout", "input": "1\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn BerSoft $n$ programmers work, the programmer $i$ is characterized by a skill $r_i$.\n\nA programmer $a$ can be a mentor of a programmer $b$ if and only if the skill of the programmer $a$ is strictly greater than the sk...
[{"type": "stdin_stdout", "input": "10 35\n322022227 751269818 629795150 369443545 344607287 250044294 476897672 184054549 986884572 917181121\n6 3\n7 3\n1 9\n7 9\n10 7\n3 4\n8 6\n7 4\n6 10\n7 2\n3 5\n6 9\n3 10\n8 7\n6 5\n8 1\n8 5\n1 7\n8 10\n8 2\n1 5\n10 4\n6 7\n4 6\n2 6\n5 4\n9 10\n9 2\n4 8\n5 9\n4 1\n3 2\n2 1\n4 2\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAuthors have come up with the string $s$ consisting of $n$ lowercase Latin letters.\n\nYou are given two permutations of its indices (not necessary equal) $p$ and $q$ (both of length $n$). Recall that the permutation is t...
[{"type": "stdin_stdout", "input": "6 5\n5 6 1 2 3 4\n6 5 1 2 3 4\n", "output": "YES\nbcdeaa\n"}, {"type": "stdin_stdout", "input": "5 2\n5 2 4 3 1\n5 4 3 1 2\n", "output": "YES\nbbbba\n"}, {"type": "stdin_stdout", "input": "5 4\n1 3 2 4 5\n2 3 5 1 4\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "3 2\n1 2 3\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRecently Vasya decided to improve his pistol shooting skills. Today his coach offered him the following exercise. He placed $n$ cans in a row on a table. Cans are numbered from left to right from $1$ to $n$. Vasya has to ...
[{"type": "stdin_stdout", "input": "5\n13 16 20 18 11\n", "output": "138\n3 4 2 1 5 \n"}, {"type": "stdin_stdout", "input": "6\n5 4 5 4 4 5\n", "output": "69\n6 1 3 5 2 4 \n"}, {"type": "stdin_stdout", "input": "4\n10 10 10 10\n", "output": "64\n2 1 4 3 \n"}, {"type": "stdin_stdout", "input": "3\n20 10 20\n", "output":...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a sequence of positive integers of length N, a = (a_1, a_2, ..., a_N).\nYour objective is to remove some of the elements in a so that a will be a good sequence.\nHere, an sequence b is a good sequence when t...
[{"type": "stdin_stdout", "input": "8\n2 7 1 8 2 8 1 8\n", "output": "5\n"}, {"type": "stdin_stdout", "input": "6\n1 2 2 3 3 3\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "1\n1000000000\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "5\n2 4 1 4 2\n", "output": "2\n"}, {"type": "stdin_stdout", "inpu...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWe have five variables x_1, x_2, x_3, x_4, and x_5.\nThe variable x_i was initially assigned a value of i.\nSnuke chose one of these variables and assigned it 0.\nYou are given the values of the five variables after this ...
[{"type": "stdin_stdout", "input": "0 2 3 4 5\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "1 2 0 4 5\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "1 0 3 4 5\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "1 2 3 0 5\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "1 2 3 4 0\n", "o...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWe have a sequence of length N, a = (a_1, a_2, ..., a_N).\nEach a_i is a positive integer.\nSnuke's objective is to permute the element in a so that the following condition is satisfied:\n - For each 1 ≀ i ≀ N - 1, the pr...
[{"type": "stdin_stdout", "input": "6\n2 7 1 8 2 8\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "3\n1 10 100\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "4\n1 2 3 4\n", "output": "No\n"}, {"type": "stdin_stdout", "input": "3\n1 4 1\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "2\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWe ask you to select some number of positive integers, and calculate the sum of them.\nIt is allowed to select as many integers as you like, and as large integers as you wish.\nYou have to follow these, however: each sele...
[{"type": "stdin_stdout", "input": "1 100 97\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "40 98 58\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "77 42 36\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "7 5 1\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "2 2 1\n", "outpu...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere is a farm whose length and width are A yard and B yard, respectively. A farmer, John, made a vertical road and a horizontal road inside the farm from one border to another, as shown below: (The gray part represents ...
[{"type": "stdin_stdout", "input": "100 100\n", "output": "9801\n"}, {"type": "stdin_stdout", "input": "91 61\n", "output": "5400\n"}, {"type": "stdin_stdout", "input": "22 15\n", "output": "294\n"}, {"type": "stdin_stdout", "input": "5 7\n", "output": "24\n"}, {"type": "stdin_stdout", "input": "2 2\n", "output": "1\n"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWe have a long seat of width X centimeters.\nThere are many people who wants to sit here. A person sitting on the seat will always occupy an interval of length Y centimeters.\nWe would like to seat as many people as possi...
[{"type": "stdin_stdout", "input": "64146 123 456\n", "output": "110\n"}, {"type": "stdin_stdout", "input": "64145 123 456\n", "output": "109\n"}, {"type": "stdin_stdout", "input": "100000 1 1\n", "output": "49999\n"}, {"type": "stdin_stdout", "input": "13 3 1\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "12...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOn a two-dimensional plane, there are N red points and N blue points.\nThe coordinates of the i-th red point are (a_i, b_i), and the coordinates of the i-th blue point are (c_i, d_i).\nA red point and a blue point can for...
[{"type": "stdin_stdout", "input": "5\n0 0\n7 3\n2 2\n4 8\n1 6\n8 5\n6 9\n5 4\n9 1\n3 7\n", "output": "5\n"}, {"type": "stdin_stdout", "input": "5\n0 0\n1 1\n5 5\n6 6\n7 7\n2 2\n3 3\n4 4\n8 8\n9 9\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "3\n2 0\n3 1\n1 3\n4 2\n0 4\n5 5\n", "output": "2\n"}, {"type": "st...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn a public bath, there is a shower which emits water for T seconds when the switch is pushed.\nIf the switch is pushed when the shower is already emitting water, from that moment it will be emitting water for T seconds.\...
[{"type": "stdin_stdout", "input": "4 1000000000\n0 1000 1000000 1000000000\n", "output": "2000000000\n"}, {"type": "stdin_stdout", "input": "9 10\n0 3 5 7 100 110 200 300 311\n", "output": "67\n"}, {"type": "stdin_stdout", "input": "2 4\n0 3\n", "output": "7\n"}, {"type": "stdin_stdout", "input": "2 4\n0 5\n", "output...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA Little Elephant from the Zoo of Lviv likes lucky strings, i.e., the strings that consist only of the lucky digits 4 and 7.\nThe Little Elephant calls some string T of the length M balanced if there exists at least one i...
[{"type": "stdin_stdout", "input": "4\n47\n74\n477\n4747477", "output": "2\n2\n3\n23\n"}, {"type": "stdin_stdout", "input": "4\n47\n47\n477\n4747477", "output": "2\n2\n3\n23\n"}, {"type": "stdin_stdout", "input": "4\n44\n74\n477\n4747477", "output": "3\n2\n3\n23\n"}, {"type": "stdin_stdout", "input": "4\n47\n44\n477\n4...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are n persons who initially don't know each other. On each morning, two of them, who were not friends before, become friends.\n\nWe want to plan a trip for every evening of m days. On each trip, you have to select a...
[{"type": "stdin_stdout", "input": "16 20 2\n10 4\n5 3\n10 5\n12 7\n7 6\n9 12\n9 6\n1 10\n11 16\n11 1\n16 3\n10 2\n14 4\n15 14\n4 13\n13 15\n1 8\n7 15\n1 7\n8 15\n", "output": "0\n0\n0\n0\n0\n0\n4\n4\n4\n4\n10\n10\n10\n10\n10\n14\n14\n14\n14\n15\n"}, {"type": "stdin_stdout", "input": "16 20 2\n10 4\n5 3\n10 5\n12 7\n7 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet's call a string a phone number if it has length 11 and fits the pattern \"8xxxxxxxxxx\", where each \"x\" is replaced by a digit.\n\nFor example, \"80123456789\" and \"80000000000\" are phone numbers, while \"80123456...
[{"type": "stdin_stdout", "input": "100\n10073026040057460848727605087211482331696312132261702754626166388448133087167204984955299978572844873\n", "output": "9\n"}, {"type": "stdin_stdout", "input": "100\n12214470388509637187316171407185732399094381485438987303313809772379863936872280956215437122989955784\n", "output":...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given q queries in the following form:\n\nGiven three integers l_i, r_i and d_i, find minimum positive integer x_i such that it is divisible by d_i and it does not belong to the segment [l_i, r_i].\n\nCan you answ...
[{"type": "stdin_stdout", "input": "30\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 100000...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nNote that this is the first problem of the two similar problems. You can hack this problem only if you solve both problems.\n\nYou are given a tree with n nodes. In the beginning, 0 is written on all edges. In one operati...
[{"type": "stdin_stdout", "input": "60\n26 6\n59 30\n31 12\n31 3\n38 23\n59 29\n53 9\n38 56\n53 54\n29 21\n17 55\n59 38\n26 16\n24 59\n24 25\n17 35\n24 41\n30 15\n31 27\n8 44\n26 5\n26 48\n8 32\n53 17\n3 34\n3 51\n30 28\n47 10\n53 60\n36 42\n24 53\n59 22\n53 40\n26 52\n36 4\n59 8\n29 37\n36 20\n17 47\n53 18\n3 50\n30 2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAn array of integers p_{1},p_{2}, …,p_{n} is called a permutation if it contains each number from 1 to n exactly once. For example, the following arrays are permutations: [3,1,2], [1], [1,2,3,4,5] and [4,3,1,2]. The follo...
[{"type": "stdin_stdout", "input": "100\n0 0 57 121 57 0 19 251 19 301 19 160 57 578 664 57 19 50 0 621 91 5 263 34 5 96 713 649 22 22 22 5 108 198 1412 1147 84 1326 1777 0 1780 132 2000 479 1314 525 68 690 1689 1431 1288 54 1514 1593 1037 1655 807 465 1674 1747 1982 423 837 139 1249 1997 1635 1309 661 334 3307 2691 21...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThis is the easier version of the problem. In this version 1 ≀ n, m ≀ 100. You can hack this problem only if you solve and lock both problems.\n\nYou are given a sequence of integers a=[a_1,a_2,...,a_n] of length n. Its s...
[{"type": "stdin_stdout", "input": "5\n3 1 4 1 2\n15\n5 5\n5 4\n5 3\n5 2\n5 1\n4 4\n4 3\n4 2\n4 1\n3 3\n3 2\n3 1\n2 2\n2 1\n1 1\n", "output": "2\n1\n4\n1\n3\n2\n4\n1\n3\n2\n4\n3\n4\n3\n4\n"}, {"type": "stdin_stdout", "input": "5\n3 1 4 2 2\n15\n5 5\n5 4\n5 3\n5 2\n5 1\n4 4\n4 3\n4 2\n4 1\n3 3\n3 2\n3 1\n2 2\n2 1\n1 1\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are n lamps on a line, numbered from 1 to n. Each one has an initial state off (0) or on (1).\n\nYou're given k subsets A_1, …, A_k of \\{1, 2, ..., n\\}, such that the intersection of any three subsets is empty. In...
[{"type": "stdin_stdout", "input": "19 5\n1001001001100000110\n2\n2 3\n2\n5 6\n2\n8 9\n5\n12 13 14 15 16\n1\n19\n", "output": "0\n1\n1\n1\n2\n2\n2\n3\n3\n3\n3\n4\n4\n4\n4\n4\n4\n4\n5\n"}, {"type": "stdin_stdout", "input": "8 6\n00110011\n3\n1 3 8\n5\n1 2 5 6 7\n2\n6 8\n2\n3 5\n2\n4 7\n1\n2\n", "output": "1\n1\n1\n1\n1\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are n points on a coordinate axis OX. The i-th point is located at the integer point x_i and has a speed v_i. It is guaranteed that no two points occupy the same coordinate. All n points move with the constant speed...
[{"type": "stdin_stdout", "input": "5\n2 1 4 3 5\n2 2 2 3 4\n", "output": "19\n"}, {"type": "stdin_stdout", "input": "5\n2 1 4 3 5\n0 2 2 3 4\n", "output": "18\n"}, {"type": "stdin_stdout", "input": "3\n1 3 2\n-100 2 10\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "3\n1 3 2\n-100 2 3\n", "output": "3\n"}, {"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops.\n\nYou should find such a cycle in K_n that visits every...
[{"type": "stdin_stdout", "input": "1\n132 8 1257\n", "output": "5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 32 1 33 1 34 1 35 1 36 1 37 1 38 1 39 1 40 1 41 1 42 1 43 1 44 1 45 1 46 1 47 1 48 1 49 1 50 1 51 1 52 1 53 1 54 1 55 1 56 1 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's...
[{"type": "stdin_stdout", "input": "16 14\n15 15\n17 13\n", "output": "9 7\n6 8\n"}, {"type": "stdin_stdout", "input": "12 14\n11 15\n9 17\n", "output": "3 9\n8 6\n"}, {"type": "stdin_stdout", "input": "12 12\n14 10\n16 8\n", "output": "9 3\n5 7\n"}, {"type": "stdin_stdout", "input": "11 11\n17 5\n12 10\n", "output": "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou may know that Euclid was a mathematician. Well, as it turns out, Morpheus knew it too. So when he wanted to play a mean trick on Euclid, he sent him an appropriate nightmare. \n\nIn his bad dream Euclid has a set S of...
[{"type": "stdin_stdout", "input": "50 500000\n2 57 94\n2 1 10\n2 97 98\n2 15 86\n2 66 84\n2 40 100\n2 8 27\n2 14 43\n2 55 75\n2 25 90\n2 22 69\n2 9 12\n2 32 34\n2 24 48\n2 54 88\n2 13 50\n2 30 56\n2 38 77\n2 4 70\n2 39 92\n2 23 72\n2 17 36\n2 20 29\n2 6 51\n2 11 87\n2 21 68\n2 59 80\n2 52 61\n2 26 42\n2 2 37\n2 45 62\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPolycarp was dismantling his attic and found an old floppy drive on it. A round disc was inserted into the drive with n integers written on it.\n\nPolycarp wrote the numbers from the disk into the a array. It turned out t...
[{"type": "stdin_stdout", "input": "3\n3 3\n0 -5 4\n1 5 4\n2 2\n-4 0\n1 2\n2 2\n0 0\n1 2\n", "output": "-1 -1 -1\n-1 -1\n-1 -1\n"}, {"type": "stdin_stdout", "input": "3\n3 3\n1 -3 4\n1 5 2\n2 2\n-2 0\n1 2\n2 2\n0 1\n1 2\n", "output": "\n0 6 2 \n-1 -1 \n1 3 \n"}, {"type": "stdin_stdout", "input": "3\n3 3\n0 -3 4\n1 5 2\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an integer n. You have to apply m operations to it.\n\nIn a single operation, you must replace every digit d of the number with the decimal representation of integer d + 1. For example, 1912 becomes 21023 af...
[{"type": "stdin_stdout", "input": "5\n178 170\n26 25\n64 84\n19 12\n20 136\n", "output": "764520\n12\n1015\n6\n32483\n"}, {"type": "stdin_stdout", "input": "5\n178 170\n26 25\n64 84\n19 12\n38 136\n", "output": "764520\n12\n1015\n6\n46148\n"}, {"type": "stdin_stdout", "input": "5\n178 170\n26 25\n64 84\n19 6\n20 136\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThis is the easy version of the problem. The only difference is that in this version q = 1. You can make hacks only if both versions of the problem are solved.\n\nThere is a process that takes place on arrays a and b of l...
[{"type": "stdin_stdout", "input": "100\n45 21 34 56 15 0 46 59 40 39 78 83 29 77 19 30 60 39 90 64 11 47 10 47 35 79 30 13 21 31 26 68 0 67 52 43 29 94 100 76 16 61 74 34 62 63 4 41 78 31 77 21 90 2 43 70 53 15 53 29 47 87 33 20 23 30 55 57 13 25 19 89 10 17 92 24 47 6 4 91 52 9 11 25 81 14 82 75 46 49 66 62 28 84 88 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an equation: \n\nAx2 + Bx + C = 0. \n\nYour task is to find the number of distinct roots of the equation and print all of them in ascending order.\n\nInput\n\nThe first line contains three integer numbers A,...
[{"type": "stdin_stdout", "input": "-50000 110001 -1028\n", "output": "2\n0.009385408263686695\n2.1906345917363135\n"}, {"type": "stdin_stdout", "input": "50000 110001 10338\n", "output": "2\n-2.1016396721343673\n-0.09838032786563272\n"}, {"type": "stdin_stdout", "input": "-50000 100001 -50000\n", "output": "2\n0.99553...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA recently found Ancient Prophesy is believed to contain the exact Apocalypse date. The prophesy is a string that only consists of digits and characters \"-\".\n\nWe'll say that some date is mentioned in the Prophesy if t...
[{"type": "stdin_stdout", "input": "12-12-201312-12-201312-12-201313--12-201313--12-201313--12-201313--12-201313--12-201313--12-201313--12-201313--12-2013\n", "output": "12-12-2013\n"}, {"type": "stdin_stdout", "input": "12-12-211312-12-201312-12-201313--12-201313--02-201313--12-201313--12-201313--12-201313--12-201313-...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are n cows playing poker at a table. For the current betting phase, each player's status is either \"ALLIN\", \"IN\", or \"FOLDED\", and does not change throughout the phase. To increase the suspense, a player whose...
[{"type": "stdin_stdout", "input": "100\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n", "output": "100"}, {"type": "stdin_stdout", "input": "10\nAAAAAAAAAA\n", "output": "10"}, {"type": "stdin_stdout", "input": "8\nIFFFIAAI\n", "output": "0\n"}, {"type": "stdin_...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasily the Programmer loves romance, so this year he decided to illuminate his room with candles.\n\nVasily has a candles.When Vasily lights up a new candle, it first burns for an hour and then it goes out. Vasily is smar...
[{"type": "stdin_stdout", "input": "1000 1000\n", "output": "1001\n"}, {"type": "stdin_stdout", "input": "1000 3\n", "output": "1499\n"}, {"type": "stdin_stdout", "input": "1000 2\n", "output": "1999\n"}, {"type": "stdin_stdout", "input": "1000 4\n", "output": "1333\n"}, {"type": "stdin_stdout", "input": "777 17\n", "o...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPetya studies positional notations. He has already learned to add and subtract numbers in the systems of notations with different radices and has moved on to a more complicated action β€” multiplication. To multiply large n...
[{"type": "stdin_stdout", "input": "10\n", "output": "1 2 3 4 5 6 7 8 9 \n2 4 6 8 10 12 14 16 18 \n3 6 9 12 15 18 21 24 27 \n4 8 12 16 20 24 28 32 36 \n5 10 15 20 25 30 35 40 45 \n6 12 18 24 30 36 42 48 54 \n7 14 21 28 35 42 49 56 63 \n8 16 24 32 40 48 56 64 72 \n9 18 27 36 45 54 63 72 81 \n"}, {"type": "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTo celebrate the opening of the Winter Computer School the organizers decided to buy in n liters of cola. However, an unexpected difficulty occurred in the shop: it turned out that cola is sold in bottles 0.5, 1 and 2 lit...
[{"type": "stdin_stdout", "input": "10000 5000 5000 5000\n", "output": "6253751\n"}, {"type": "stdin_stdout", "input": "10000 4534 2345 4231\n", "output": "2069003\n"}, {"type": "stdin_stdout", "input": "8765 2432 2789 4993\n", "output": "1697715\n"}, {"type": "stdin_stdout", "input": "8987 4000 2534 4534\n", "output":...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA and B are preparing themselves for programming contests.\n\nB loves to debug his code. But before he runs the solution and starts debugging, he has to first compile the code.\n\nInitially, the compiler displayed n compi...
[{"type": "stdin_stdout", "input": "10\n460626451 802090732 277246428 661369649 388684428 784303821 376287098 656422756 9301599 25720377\n277246428 388684428 661369649 460626451 656422756 802090732 9301599 784303821 376287098\n376287098 802090732 388684428 9301599 656422756 784303821 460626451 277246428\n", "output": "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLittle Susie listens to fairy tales before bed every day. Today's fairy tale was about wood cutters and the little girl immediately started imagining the choppers cutting wood. She imagined the situation that is described...
[{"type": "stdin_stdout", "input": "67\n1 1\n3 8\n4 10\n7 8\n9 2\n10 1\n11 5\n12 8\n13 4\n16 6\n18 3\n19 3\n22 5\n24 6\n27 5\n28 3\n29 3\n30 5\n32 5\n33 10\n34 7\n35 8\n36 5\n41 3\n42 2\n43 5\n46 4\n48 4\n49 9\n52 4\n53 9\n55 1\n56 4\n59 7\n68 7\n69 4\n71 9\n72 10\n74 5\n76 4\n77 9\n80 7\n81 9\n82 5\n83 5\n84 9\n85 7\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nEvery day Ruslan tried to count sheep to fall asleep, but this didn't help. Now he has found a more interesting thing to do. First, he thinks of some set of circles on a plane, and then tries to choose a beautiful set of ...
[{"type": "stdin_stdout", "input": "50\n48 45 42\n32 45 8\n15 41 47\n32 29 38\n7 16 48\n19 9 21\n18 40 5\n39 40 7\n37 0 6\n42 15 37\n9 33 37\n40 41 33\n25 43 2\n23 21 38\n30 20 32\n28 15 5\n47 9 19\n47 22 26\n26 9 18\n24 23 24\n11 29 5\n38 44 9\n49 22 42\n1 15 32\n18 25 21\n8 48 39\n48 7 26\n3 30 26\n34 21 47\n34 14 4\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasya wants to turn on Christmas lights consisting of m bulbs. Initially, all bulbs are turned off. There are n buttons, each of them is connected to some set of bulbs. Vasya can press any of these buttons. When the butto...
[{"type": "stdin_stdout", "input": "1 100\n100 1 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 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a rebus of form ? + ? - ? + ? = n, consisting of only question marks, separated by arithmetic operation '+' and '-', equality and positive integer n. The goal is to replace each question mark with some posit...
[{"type": "stdin_stdout", "input": "? - ? + ? + ? + ? + ? - ? - ? - ? - ? + ? - ? - ? - ? + ? - ? + ? + ? + ? - ? + ? + ? + ? - ? + ? + ? - ? + ? - ? + ? - ? - ? + ? + ? + ? + ? + ? + ? + ? - ? + ? + ? + ? + ? - ? - ? - ? + ? - ? - ? - ? - ? - ? - ? + ? - ? + ? + ? - ? - ? - ? - ? + ? - ? - ? + ? + ? - ? + ? + ? - ? - ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nNick has n bottles of soda left after his birthday. Each bottle is described by two values: remaining amount of soda ai and bottle volume bi (ai ≀ bi).\n\nNick has decided to pour all remaining soda into minimal number of...
[{"type": "stdin_stdout", "input": "90\n4 2 21 69 53 39 2 2 8 58 7 5 2 82 7 9 13 10 2 44 1 7 2 1 50 42 36 17 14 46 19 1 50 20 51 46 9 59 73 61 76 4 19 22 1 43 53 2 5 5 32 7 5 42 30 14 32 6 6 15 20 24 13 8 5 19 9 9 7 20 7 2 55 36 5 33 64 20 22 22 9 30 67 38 68 2 13 19 2 9\n48 4 39 85 69 70 11 42 65 77 61 6 60 84 67 15 9...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOur beloved detective, Sherlock is currently trying to catch a serial killer who kills a person each day. Using his powers of deduction, he came to know that the killer has a strategy for selecting his next victim.\n\nThe...
[{"type": "stdin_stdout", "input": "bwyplnjn zkms\n26\nzkms nzmcsytxh\nnzmcsytxh yujsb\nbwyplnjn gtbzhudpb\ngtbzhudpb hpk\nyujsb xvy\nhpk wrwnfokml\nwrwnfokml ndouuikw\nndouuikw ucgrja\nucgrja tgfmpldz\nxvy nycrfphn\nnycrfphn quvs\nquvs htdy\nhtdy k\ntgfmpldz xtdpkxm\nxtdpkxm suwqxs\nk fv\nsuwqxs qckllwy\nqckllwy diun\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere is little time left before the release of the first national operating system BerlOS. Some of its components are not finished yet β€” the memory manager is among them. According to the developers' plan, in the first r...
[{"type": "stdin_stdout", "input": "47 43\nerase 1\nalloc 95\nalloc 53\nerase 2\ndefragment\nalloc 100\nerase 4\nerase 2\nerase -849472053\ndefragment\nerase -638355221\nalloc 90\nerase 3\nerase 2\ndefragment\nalloc 17\nerase 5\ndefragment\nerase 6\ndefragment\nerase 3\ndefragment\ndefragment\nalloc 99\nalloc 69\nalloc...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSome time ago Mister B detected a strange signal from the space, which he started to study.\n\nAfter some transformation the signal turned out to be a permutation p of length n or its cyclic shift. For the further investi...
[{"type": "stdin_stdout", "input": "108\n1 102 33 99 6 83 4 20 61 100 76 71 44 9 24 87 57 2 81 82 90 85 12 30 66 53 47 36 43 29 31 64 96 84 77 23 93 78 58 68 42 55 13 70 62 19 92 14 10 65 63 75 91 48 11 105 37 50 32 94 18 26 52 89 104 106 86 97 80 95 17 72 40 22 79 103 25 101 35 51 15 98 67 5 34 69 54 27 45 88 56 16 46...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIgor is a post-graduate student of chemistry faculty in Berland State University (BerSU). He needs to conduct a complicated experiment to write his thesis, but laboratory of BerSU doesn't contain all the materials require...
[{"type": "stdin_stdout", "input": "11\n1 1 1 1 1 1 1 1 1 1 1\n1 1000000001 1000000001 1000000001 1000000001 1000000001 1000000001 1000000001 1000000001 1000000001 1000000001\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n", "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAs technologies develop, manufacturers are making the process of unlocking a phone as user-friendly as possible. To unlock its new phone, Arkady's pet dog Mu-mu has to bark the password once. The phone represents a passwo...
[{"type": "stdin_stdout", "input": "bn\n100\ndf\nyb\nze\nml\nyr\nof\nnw\nfm\ndw\nlv\nzr\nhu\nzt\nlw\nld\nmo\nxz\ntp\nmr\nou\nme\npx\nvp\nes\nxi\nnr\nbx\nqc\ngm\njs\nkn\ntw\nrq\nkz\nuc\nvc\nqr\nab\nna\nro\nya\nqy\ngu\nvk\nqk\ngs\nyq\nop\nhw\nrj\neo\nlz\nbh\nkr\nkb\nma\nrd\nz`\nuf\nhq\nmc\nmn\nti\nwn\nsh\nax\nsi\nnd\ntz\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRecenlty Luba got a credit card and started to use it. Let's consider n consecutive days Luba uses the card.\n\nShe starts with 0 money on her account.\n\nIn the evening of i-th day a transaction ai occurs. If ai > 0, the...
[{"type": "stdin_stdout", "input": "20 23036\n-1 1 -1 -1 -1 -1 1 -1 -1 0 0 1 1 0 -1 1 0 1 -1 -1\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "20 23036\n-1 1 -1 -1 -1 -1 1 -1 -2 0 0 1 1 0 -1 1 0 1 -1 -1\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "20 23036\n-1 1 -1 -1 -1 -1 1 -1 -2 0 0 1 1 0 -1 1 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLuba thinks about watering her garden. The garden can be represented as a segment of length k. Luba has got n buckets, the i-th bucket allows her to water some continuous subsegment of garden of length exactly ai each hou...
[{"type": "stdin_stdout", "input": "100 100\n2 46 24 18 86 90 31 38 84 49 58 28 15 80 14 24 87 56 62 87 41 87 55 71 87 32 41 56 91 32 24 75 43 42 35 30 72 53 31 26 54 61 87 85 36 75 44 31 7 38 77 57 61 54 70 77 45 96 39 57 11 8 91 42 52 15 42 30 92 41 27 26 34 27 3 80 32 86 26 97 63 91 30 75 14 7 19 23 45 11 8 43 44 73...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou and your friend are participating in a TV show \"Run For Your Prize\".\n\nAt the start of the show n prizes are located on a straight line. i-th prize is located at position ai. Positions of all prizes are distinct. Y...
[{"type": "stdin_stdout", "input": "10\n3934 38497 42729 45023 51842 68393 77476 82414 91465 98055\n", "output": "98054\n"}, {"type": "stdin_stdout", "input": "6\n2 3 500000 999997 999998 999999\n", "output": "499999\n"}, {"type": "stdin_stdout", "input": "4\n999996 999997 999998 999999\n", "output": "4\n"}, {"type": "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a tree (a graph with n vertices and n - 1 edges in which it's possible to reach any vertex from any other vertex using only its edges).\n\nA vertex can be destroyed if this vertex has even degree. If you des...
[{"type": "stdin_stdout", "input": "121\n110 31 57 33 45 33 33 33 91 102 79 33 61 72 107 101 117 10 118 33 33 64 24 94 117 76 33 23 33 49 5 52 95 78 33 39 33 92 17 33 25 33 56 33 3 88 33 108 62 15 28 111 67 33 33 11 96 33 36 70 46 98 80 104 33 19 60 33 112 51 33 2 33 33 121 59 33 41 50 81 105 33 115 34 33 18 84 32 33 3...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAdilbek's house is located on a street which can be represented as the OX axis. This street is really dark, so Adilbek wants to install some post lamps to illuminate it. Street has n positions to install lamps, they corre...
[{"type": "stdin_stdout", "input": "20 16 16\n1 2 3 4 5 6 8 9 10 11 13 14 15 16 18 19\n2 1 1 1 1 1 3 3 2 2 1 3 3 3 3 2\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "20 16 16\n1 2 3 4 5 6 8 9 10 11 13 14 15 16 18 19\n2 1 1 1 1 1 3 1 2 2 1 3 3 3 3 2\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "11 4...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAs you know Appu created aversion to Maths after that maths problem given by his teacher.So he stopped studying and began to do farming. He has some land where he starts growing sugarcane. At the end of the season he grew...
[{"type": "stdin_stdout", "input": "50\n558017747 707412184 571476824 27885972 347137128 534455142 266330082 293791105 475845546 506551897 225052521 672800684 64370521 756181857 592652322 228887401 599530996 111233973 330484393 490574767 309080152 39589626 763859303 515779418 857884239 413041773 131315151 512215539 928...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn the previous problem Chandu bought some unsorted arrays and sorted them (in non-increasing order). Now, he has many sorted arrays to give to his girlfriend. But, the number of sorted arrays are very large so Chandu dec...
[{"type": "stdin_stdout", "input": "4\n439 79\n991800654 985952720 985538124 983840231 983710443 982377023 981242112 980217433 978715835 975066351 971156452 970695839 967865836 966899150 964806897 962947103 961994537 961659306 950186818 949581998 947844082 945819757 943009670 939958230 934022730 933536137 933069759 930...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGolu is given a task of clearing coins fallen down on floor. Naughty being his modus operandi, he thought of playing a game while clearing coins. He arranges the coins like an M X N matrix with random heads (1) and tails...
[{"type": "stdin_stdout", "input": "4 6\n1 -1 -1 0 -1 1 \n0 0 1 1 1 0 \n0 -1 1 1 2 2 \n1 0 -1 2 2 1", "output": "0\n"}, {"type": "stdin_stdout", "input": "4 6\n1 0 -1 0 -1 1 \n0 0 1 1 1 0 \n1 -1 1 1 2 2 \n0 0 -1 2 2 1", "output": "0\n"}, {"type": "stdin_stdout", "input": "4 6\n2 0 -1 0 -1 1 \n0 0 1 1 1 0 \n1 -1 1 1 2 2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA certain business maintains a list of all its customers' names. The list is arranged in order of importance, with the last customer in the list being the most important. Now, he want to create a new list sorted alphabeti...
[{"type": "stdin_stdout", "input": "4\n10\nAlan\naLan\nalAn\nalaN\nALan\nAlAn\nAlaN\naLAn\naLaN\nalAN\n4\nabcdefghijklmnop T\nabccefghijklmnop T\nt tt ttt tttt\nTTTT TTT TT T\n4\nKenny G\nKenny Gee\nA DeForest Hoar\nC A R Hoare\n3\nk a\nm b\nk a", "output": "alAN \naLaN \naLAn \nAlaN \nAlAn \nALan \nalaN \nalAn \naLan ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRoy is going through the dark times of his life. Recently his girl friend broke up with him and to overcome the pain of acute misery he decided to restrict himself to Eat-Sleep-Code life cycle. For N days he did nothing b...
[{"type": "stdin_stdout", "input": "4\nSESSEEEECCBDESCCCC\nCCCCCCSSSEEESCCBSS\nSCCCCCCCSSEEESSSSS\nEESSSSCCCCCCSSEEEESAMPLE", "output": "7 10\n"}, {"type": "stdin_stdout", "input": "4\nSESSEEEECCBDESCCCC\nCCCCCCSSSEEESCCASS\nSCCCCCCCSSEEESSSSS\nEESSSSCCCCCCSSEEEESAMPLE", "output": "7 10\n"}, {"type": "stdin_stdout", "i...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn this problem, we only consider strings consisting of lowercase English letters.\n\nStrings s and t are said to be isomorphic when the following conditions are satisfied:\n\n* |s| = |t| holds.\n* For every pair i, j, on...
[{"type": "stdin_stdout", "input": "8", "output": "aaaaaaaa\naaaaaaab\naaaaaaba\naaaaaabb\naaaaaabc\naaaaabaa\naaaaabab\naaaaabac\naaaaabba\naaaaabbb\naaaaabbc\naaaaabca\naaaaabcb\naaaaabcc\naaaaabcd\naaaabaaa\naaaabaab\naaaabaac\naaaababa\naaaababb\naaaababc\naaaabaca\naaaabacb\naaaabacc\naaaabacd\naaaabbaa\naaaabbab\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nHaving learned the multiplication table, Takahashi can multiply two integers between 1 and 9 (inclusive) together. He cannot do any other calculation.\n\nGiven are two integers A and B.\n\nIf Takahashi can calculate A \\t...
[{"type": "stdin_stdout", "input": "33 106", "output": "-1\n"}, {"type": "stdin_stdout", "input": "12 29", "output": "-1\n"}, {"type": "stdin_stdout", "input": "19 29", "output": "-1\n"}, {"type": "stdin_stdout", "input": "19 57", "output": "-1\n"}, {"type": "stdin_stdout", "input": "37 57", "output": "-1\n"}, {"type":...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.\n\nConstraints\n\n* 1 ≀ a,b ≀ 10000\n* a and b are integers.\n\nInput\n\nInput is given from Standard Input ...
[{"type": "stdin_stdout", "input": "-1 -2", "output": "Even\n"}, {"type": "stdin_stdout", "input": "-2 -2", "output": "Even\n"}, {"type": "stdin_stdout", "input": "-2 -1", "output": "Even\n"}, {"type": "stdin_stdout", "input": "-4 -1", "output": "Even\n"}, {"type": "stdin_stdout", "input": "-6 -1", "output": "Even\n"},...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are N students and M checkpoints on the xy-plane.\nThe coordinates of the i-th student (1 \\leq i \\leq N) is (a_i,b_i), and the coordinates of the checkpoint numbered j (1 \\leq j \\leq M) is (c_j,d_j).\nWhen the t...
[{"type": "stdin_stdout", "input": "5 5\n-100000000 -100000000\n-100000000 010000000\n100000000 -100000000\n100000000 100000000\n0 0\n-1 -1\n100000000 100001000\n100000000 -100000000\n-100000000 100000000\n-100000000 -11926256", "output": "5\n5\n3\n2\n1\n"}, {"type": "stdin_stdout", "input": "5 5\n-100000000 -100000000...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTwo students of AtCoder Kindergarten are fighting over candy packs.\n\nThere are three candy packs, each of which contains a, b, and c candies, respectively.\n\nTeacher Evi is trying to distribute the packs between the tw...
[{"type": "stdin_stdout", "input": "30 30 000", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "106 25 31", "output": "No\n"}, {"type": "stdin_stdout", "input": "30 47 100", "output": "No\n"}, {"type": "stdin_stdout", "input": "30 26 100", "output": "No\n"}, {"type": "stdin_stdout", "input": "30 16 100", "output...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\n4 different points on the plane Read the coordinates of $ A (x_a, y_a) $, $ B (x_b, y_b) $, $ C (x_c, y_c) $, $ D (x_d, y_d) $ and read those 4 points Create a program that outputs YES if there is no dent in the quadrangl...
[{"type": "stdin_stdout", "input": "1.0,0.0,0.1,0.1,0.0,0.1,0.0,0.0\n0.3,0.1,0.1,1.1,0.0,0.3,0.0,0.0", "output": "YES\nYES\n"}, {"type": "stdin_stdout", "input": "0.0,0.0,1.0,0.0,1.0,1.0,0.0,0.1\n0.3,0.1,0.1,1.1,0.0,0.3,0.0,0.0", "output": "YES\nYES\n"}, {"type": "stdin_stdout", "input": "0.0,0.0,1.0,0.0,1.0,1.0,0.0,0....
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSorting algorithms for sorting data are basic algorithms indispensable in computer science. For example, as shown in the figure below, the operation of \"sorting the elements of an array of integer values ​​in ascending o...
[{"type": "stdin_stdout", "input": "5\n5\n1\n2\n-1\n0\n4\n1\n6\n2\n4\n4\n22\n3\n4\n1\n-1\n0", "output": "8\n2\n5\n0\n"}, {"type": "stdin_stdout", "input": "5\n10\n1\n4\n-1\n0\n8\n0\n3\n9\n7\n5\n22\n3\n4\n1\n-1\n0", "output": "8\n11\n0\n"}, {"type": "stdin_stdout", "input": "5\n5\n1\n2\n-1\n0\n8\n1\n6\n2\n4\n5\n22\n3\n4...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPCK, which recycles Aizu's precious metal, Aizunium, has a network all over the country and collects Aizunium with many collection vehicles. This company standardizes the unit of weight and number of lumps for efficient p...
[{"type": "stdin_stdout", "input": "3\n12 1\n-3 5\n16 1", "output": "2 0\n13 0\n17 0\n"}, {"type": "stdin_stdout", "input": "3\n12 1\n-3 5\n16 2", "output": "2 0\n13 0\n18 0\n"}, {"type": "stdin_stdout", "input": "3\n12 1\n-3 5\n16 0", "output": "2 0\n13 0\n16 0\n"}, {"type": "stdin_stdout", "input": "3\n12 0\n-3 5\n16...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are the God of Wind.\n\nBy moving a big cloud around, you can decide the weather: it invariably rains under the cloud, and the sun shines everywhere else.\n\nBut you are a benign God: your goal is to give enough rain ...
[{"type": "stdin_stdout", "input": "1\n0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0\n7\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n1 0 0 0 0 0 1 0 0 0 0 1 1 0 0 1\n0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 1\n0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0\n0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0\n1 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1\n0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0\n7\n0 0 0 0 0 0...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nShort Phrase\n\nA Short Phrase (aka. Tanku) is a fixed verse, inspired by Japanese poetry Tanka and Haiku. It is a sequence of words, each consisting of lowercase letters 'a' to 'z', and must satisfy the following conditi...
[{"type": "stdin_stdout", "input": "9\ndo\nhte\nbest\nand\nenjoy\ntoday\nat\nacm\nicpc\n14\noh\nyes\nby\nfar\nit\nis\nwow\nso\nbad\nto\nme\nyou\nknow\nhey\n15\nabcde\nfghijkl\nmnopq\nrstuvwx\nyzz\nabcde\nfghijkl\nmnopq\nrstuvwx\nyz\nabcde\nfghijkl\nmnopq\nrstuvwx\nyz\n0", "output": "1\n2\n6\n"}, {"type": "stdin_stdout"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nI have n tickets for a train with a rabbit. Each ticket is numbered from 0 to n βˆ’ 1, and you can use the k ticket to go to pβ‹…ak + qβ‹…bk station.\n\nRabbit wants to go to the all-you-can-eat carrot shop at the station m sta...
[{"type": "stdin_stdout", "input": "6 279 2 5 26 14", "output": "117\n"}, {"type": "stdin_stdout", "input": "17 256 2 3 10 9", "output": "67\n"}, {"type": "stdin_stdout", "input": "6 323 2 12 8 9", "output": "182\n"}, {"type": "stdin_stdout", "input": "6 279 2 5 46 14", "output": "57\n"}, {"type": "stdin_stdout", "inpu...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTaro is an elementary school student who has just learned multiplication. Somehow, he likes multiplication, so when he sees numbers, he wants to multiply. He seems to like to do the following for integers greater than or ...
[{"type": "stdin_stdout", "input": "2\n999999\n1000100", "output": "12\n2\n"}, {"type": "stdin_stdout", "input": "2\n999999\n1010100", "output": "12\n3\n"}, {"type": "stdin_stdout", "input": "2\n999999\n1010110", "output": "12\n5\n"}, {"type": "stdin_stdout", "input": "2\n999999\n1101100", "output": "12\n4\n"}, {"type"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nStep up and down\n\nKazuki, commonly known as Kerr, who attends JAG University, was invited by your friend this summer to participate in the ICPC (International Collegiate Potchari Contest). ICPC is a sports contest and r...
[{"type": "stdin_stdout", "input": "4\nlu ru ld rd\n4\nlu ld lu ru\n1\nlu\n10\nru lu ld rd ru rd ru lu rd ld\n0", "output": "2\n1\n0\n4"}, {"type": "stdin_stdout", "input": "4\nlu ru ld rd\n4\nlu ld lu ru\n0\nlu\n10\nur lu ld rd ru rd ru lu rd ld\n-1", "output": "2\n1\n"}, {"type": "stdin_stdout", "input": "4\nlu ru ld...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTaro is going to play a card game. However, now he has only n cards, even though there should be 52 cards (he has no Jokers).\n\nThe 52 cards include 13 ranks of each of the four suits: spade, heart, club and diamond.\n\n...
[{"type": "stdin_stdout", "input": "47\nS 10\nS 11\nS 12\nS 13\nH 1\nH 2\nS 6\nS 7\nS 8\nS 9\nH 6\nH 8\nH 9\nH 10\nH 11\nH 4\nH 7\nS 2\nS 3\nS 4\nS 5\nH 12\nH 13\nC 1\nC 2\nD 1\nD 2\nD 3\nD 4\nD 5\nD 6\nD 7\nC 3\nC 4\nC 5\nC 6\nC 7\nC 8\nC 9\nC 10\nC 11\nC 13\nD 9\nD 10\nD 11\nD 12\nD 13", "output": "S 1\nH 3\nH 5\nC 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAt a geometry lesson Gerald was given a task: to get vector B out of vector A. Besides, the teacher permitted him to perform the following operations with vector А:\n\n * Turn the vector by 90 degrees clockwise.\n * Add...
[{"type": "stdin_stdout", "input": "-95534030 -14392539\n-89751090 79655267\n-77491839 40745315\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "92141071 -48275413\n-47968469 -13277723\n-15839680 51548907\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "-79956125 -88524398\n10949698 32312326\n-7602470...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAwruk is taking part in elections in his school. It is the final round. He has only one opponent β€” Elodreip. The are n students in the school. Each student has exactly k votes and is obligated to use all of them. So Awruk...
[{"type": "stdin_stdout", "input": "100\n100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a binary matrix A of size n Γ— n. Let's denote an x-compression of the given matrix as a matrix B of size n/x Γ— n/x such that for every i ∈ [1, n], j ∈ [1, n] the condition A[i][j] = B[⌈ i/x βŒ‰][⌈ j/x βŒ‰] is me...
[{"type": "stdin_stdout", "input": "16\nFFC0\nFFC0\nFFC0\nFFC0\nFFC0\nFFD0\nFFC0\nFFC0\nFFC0\nFFC0\nFFC0\nFFC0\nFFC0\nFFC0\nFFC0\nFFC0\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "16\nFFC0\nFFC0\nFFC0\nFFC0\nFFC0\nFFD0\nFFC0\nFFC0\nFFC0\nFFC0\n0CFF\nFFC0\nFFC0\nFFC0\nFFC0\nFFC0\n", "output": "1\n"}, {"type"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAt the big break Nastya came to the school dining room. There are n pupils in the school, numbered from 1 to n. Unfortunately, Nastya came pretty late, so that all pupils had already stood in the queue, i.e. Nastya took t...
[{"type": "stdin_stdout", "input": "20 47\n4 6 11 15 9 17 3 1 19 14 12 8 2 5 7 20 16 18 13 10\n18 10\n6 3\n15 17\n18 7\n4 5\n19 10\n6 7\n11 3\n1 10\n17 3\n6 14\n7 10\n19 5\n12 10\n1 8\n6 11\n18 5\n6 8\n12 12\n1 5\n20 11\n16 8\n3 10\n20 19\n17 8\n19 10\n2 5\n19 8\n6 9\n16 3\n16 10\n19 7\n17 16\n10 13\n8 9\n12 5\n17 10\n...
code_stdio