messages listlengths 1 1 | ground_truth stringlengths 156 726k | dataset stringclasses 2
values |
|---|---|---|
[
{
"content": "\"Point reflection\" or \"point symmetry\" is a basic concept in geometry where a given point, P, at a given position relative to a mid-point, Q has a corresponding point, P1, which is the same distance from Q but in the opposite direction.\n\n## Task\n\nGiven two points P and Q, output the symmet... | [{"input": "[1000, 15]\n[-7, -214]", "output": "[[-1014, -443]]", "fn_name": "symmetric_point"}, {"input": "[10, -10]\n[-10, 10]", "output": "[[-30, 30]]", "fn_name": "symmetric_point"}, {"input": "[1, -35]\n[-12, 1]", "output": "[[-25, 37]]", "fn_name": "symmetric_point"}, {"input": "[2, 6]\n[-2, -6]", "output": "[[-6... | code_functional |
[
{
"content": "Parmida is a clever girl and she wants to participate in Olympiads this year. Of course she wants her partner to be clever too (although he's not)! Parmida has prepared the following test problem for Pashmak.\n\nThere is a sequence a that consists of n integers a_1, a_2, ..., a_{n}. Let's denote f... | [{"input": "24\n1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4\n", "output": "114\n"}, {"input": "24\n1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4\n", "output": "114\n"}, {"input": "24\n1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 1 4\n", "output": "114\n"}, {"input": "24\n1 2 3 4 1 2 3 2 1 2 3 4 1 2 3 4 1 2 3 4 1 2... | code_stdio |
[
{
"content": "You are given a tree (a connected acyclic undirected graph) of n vertices. Vertices are numbered from 1 to n and each vertex is assigned a character from a to t.\n\nA path in the tree is said to be palindromic if at least one permutation of the labels in the path is a palindrome.\n\nFor each verte... | [{"input": "20\n10 9\n15 14\n11 12\n2 3\n15 16\n2 1\n18 19\n20 19\n8 9\n7 6\n8 7\n12 13\n5 6\n4 3\n13 14\n18 17\n11 10\n16 17\n5 4\naabbccddeeffgghhiijj\n", "output": "20 29 45 52 64 69 77 80 84 85 85 84 80 77 69 64 52 45 29 20\n"}, {"input": "20\n10 9\n15 14\n11 12\n2 3\n15 16\n2 1\n18 19\n20 19\n8 9\n7 6\n8 7\n12 13\... | code_stdio |
[
{
"content": "Vasya is studying number theory. He has denoted a function f(a, b) such that: f(a, 0) = 0; f(a, b) = 1 + f(a, b - gcd(a, b)), where gcd(a, b) is the greatest common divisor of a and b. \n\nVasya has two numbers x and y, and he wants to calculate f(x, y). He tried to do it by himself, but found o... | [{"input": "999999999989 999999999988\n", "output": "999999999988\n"}, {"input": "414654652183 366894205623\n", "output": "366894205623\n"}, {"input": "999999999958 999999999957\n", "output": "499999999979\n"}, {"input": "999999999989 999999999988\n", "output": "999999999988\n"}, {"input": "999999999958 999999999957\n"... | code_stdio |
[
{
"content": "A competitive eater, Alice is scheduling some practices for an eating contest on a magical calendar. The calendar is unusual because a week contains not necessarily $7$ days!\n\nIn detail, she can choose any integer $k$ which satisfies $1 \\leq k \\leq r$, and set $k$ days as the number of days in... | [{"input": "5\n5 4\n2 4\n5 1\n13 9\n1010000 14106652\n", "output": "10\n2\n1\n45\n510049495001\n"}, {"input": "5\n6 4\n3 2\n3 1\n13 7\n1010000 14106652\n", "output": "10\n3\n1\n28\n510049495001\n"}, {"input": "5\n5 4\n2 4\n5 1\n13 9\n1010000 12964098\n", "output": "10\n2\n1\n45\n510049495001\n"}, {"input": "5\n3 4\n3 2... | code_stdio |
[
{
"content": "A string is called bracket sequence if it does not contain any characters other than \"(\" and \")\". A bracket sequence is called regular if it it is possible to obtain correct arithmetic expression by inserting characters \"+\" and \"1\" into this sequence. For example, \"\", \"(())\" and \"()()... | [{"input": "1000000000\n1000000000\n1000000000\n1000000000\n", "output": "1\n"}, {"input": "1000000000\n1000000000\n1000000000\n1000000000\n", "output": "1\n"}, {"input": "1000000000\n1000000000\n1000000000\n999999999\n", "output": "0\n"}, {"input": "1000000000\n999999999\n1000000000\n1000000000\n", "output": "1\n"}, {... | code_stdio |
[
{
"content": "Given an array of 4 integers \n```[a,b,c,d]``` representing two points ```(a, b)``` and ```(c, d)```, return a string representation of the slope of the line joining these two points. \n\nFor an undefined slope (division by 0), return ```undefined``` . Note that the \"undefined\" is case-sensit... | [{"input": "[15, -3, 15, -3]", "output": "[\"undefined\"]", "fn_name": "find_slope"}, {"input": "[-6, 57, -6, 84]", "output": "[\"undefined\"]", "fn_name": "find_slope"}, {"input": "[17, -3, 17, 8]", "output": "[\"undefined\"]", "fn_name": "find_slope"}, {"input": "[90, 54, 90, 2]", "output": "[\"undefined\"]", "fn_nam... | code_functional |
[
{
"content": "Masha has three sticks of length $a$, $b$ and $c$ centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.\n\nWhat is the minimum number of minutes she needs to spend increasing the stick's length in o... | [{"input": "100 100 100\n", "output": "0\n"}, {"input": "100 100 100\n", "output": "0\n"}, {"input": "100 10 10\n", "output": "81\n"}, {"input": "100 100 99\n", "output": "0\n"}, {"input": "100 100 99\n", "output": "0\n"}, {"input": "100 10 10\n", "output": "81\n"}, {"input": "12 34 56\n", "output": "11\n"}, {"input": ... | code_stdio |
[
{
"content": "HQ9+ is a joke programming language which has only four one-character instructions:\n\n * \"H\" prints \"Hello, World!\",\n * \"Q\" prints the source code of the program itself,\n * \"9\" prints the lyrics of \"99 Bottles of Beer\" song, \n * \"+\" increments the value stored in the internal a... | [{"input": "mzbmweyydiadtlcouegmdbyfwurpwbpuvhifnuapwyndmhtqvkgkbhtytszotwflegsjzzszfwtzfpnscguemwrczqxycivdqnkH\n", "output": "YES\n"}, {"input": "Qzbmweyydiadtlcouegmdbyfwurpwbpuvhifnuapwyndmhtqvkgkbhtytszotwflegsjzzszfwtzfpnscguemwrczqxycivdqnky\n", "output": "YES\n"}, {"input": "mzbmweyydiadtlcouegmdbyfwurpwb9uvhif... | code_stdio |
[
{
"content": "You are given n distinct points on a plane with integral coordinates. For each point you can either draw a vertical line through it, draw a horizontal line through it, or do nothing.\n\nYou consider several coinciding straight lines as a single one. How many distinct pictures you can get? Print th... | [{"input": "10\n504155727 -77293021\n-155983273 -43296260\n-548837441 -43296260\n87058696 -80040028\n1006418476 -43296260\n-155983273 850521645\n-852404258 -125749655\n518823261 -77293021\n-89661323 -21885159\n-155983273 -406914114\n", "output": "11907\n"}, {"input": "10\n504155727 -77293021\n-155983273 -43296260\n-548... | code_stdio |
[
{
"content": "Polycarp has $n$ coins, the value of the $i$-th coin is $a_i$. It is guaranteed that all the values are integer powers of $2$ (i.e. $a_i = 2^d$ for some non-negative integer number $d$).\n\nPolycarp wants to know answers on $q$ queries. The $j$-th query is described as integer number $b_j$. The an... | [{"input": "1 10\n8\n1\n2\n3\n4\n5\n6\n7\n13\n17\n16\n", "output": "-1\n-1\n-1\n-1\n-1\n-1\n-1\n-1\n-1\n-1\n"}, {"input": "1 10\n8\n1\n2\n3\n4\n5\n6\n7\n13\n9\n16\n", "output": "-1\n-1\n-1\n-1\n-1\n-1\n-1\n-1\n-1\n-1\n"}, {"input": "1 10\n8\n1\n2\n3\n4\n5\n6\n7\n13\n9\n30\n", "output": "-1\n-1\n-1\n-1\n-1\n-1\n-1\n-1\n... | code_stdio |
[
{
"content": "There are n cells, numbered 1,2,..., n from left to right. You have to place a robot at any cell initially. The robot must make exactly k moves.\n\nIn one move, the robot must move one cell to the left or right, provided that it doesn't move out of bounds. In other words, if the robot was in the c... | [{"input": "4 40 6\n92 17 150 12\n2 60\n1 109\n4 39\n1 10\n3 49\n4 88\n", "output": "650858966\n287799503\n711175657\n825463104\n568011727\n521546223\n"}, {"input": "4 40 6\n100 17 82 40\n2 56\n1 72\n4 149\n1 97\n3 49\n2 88\n", "output": "668794504\n266774789\n938922959\n405011984\n182280345\n610383754\n"}, {"input": "... | code_stdio |
[
{
"content": "You are given an array a consisting of n positive integers, numbered from 1 to n. You can perform the following operation no more than 3n times:\n\n 1. choose three integers i, j and x (1 ≤ i, j ≤ n; 0 ≤ x ≤ 10^9); \n 2. assign a_i := a_i - x ⋅ i, a_j := a_j + x ⋅ i. \n\n\n\nAfter each operation... | [{"input": "1\n12\n1 1 1 1 1 6 6 6 6 6 6 7\n", "output": "32\n1 2 1\n2 1 1\n1 3 2\n3 1 1\n1 4 3\n4 1 1\n1 5 4\n5 1 1\n6 1 1\n1 7 1\n7 1 1\n1 8 2\n8 1 1\n1 9 3\n9 1 1\n1 10 4\n10 1 1\n1 11 5\n11 1 1\n1 12 5\n12 1 1\n1 2 4\n1 3 4\n1 4 4\n1 5 4\n1 6 4\n1 7 4\n1 8 4\n1 9 4\n1 10 4\n1 11 4\n1 12 4\n"}, {"input": "1\n10\n7 7... | code_stdio |
[
{
"content": "Training is indispensable for achieving good results at ICPC. Rabbit wants to win at ICPC, so he decided to practice today as well.\n\nToday's training is to increase creativity by drawing pictures. Let's draw a pattern well using a square stamp.\n\nI want to use stamps of various sizes to complet... | [{"input": "2\n1 3\n1 1\nRRRR\nRRGR\nRBRR\nRRRR", "output": "10\n"}, {"input": "2\n2 0\n1 1\nRRRR\nRRGR\nRBRR\nRRRR", "output": "16\n"}, {"input": "2\n2 0\n2 1\nRRRR\nRRGR\nRBRR\nRRRR", "output": "10\n"}, {"input": "2\n2 -1\n3 2\nRRRR\nRRGR\nRBRR\nRRRR", "output": "6\n"}, {"input": "2\n3 -1\n3 2\nRRRR\nRRGR\nRBRR\nRRRR... | code_stdio |
[
{
"content": "Complete the solution so that it returns the number of times the search_text is found within the full_text.\n\n```python\nsearch_substr( fullText, searchText, allowOverlap = true )\n```\n\nso that overlapping solutions are (not) counted. If the searchText is empty, it should return `0`. Usage exam... | [{"input": "\"aa_bb_cc_dd_bb_e\"\n\"bb\"", "output": "[2]", "fn_name": "search_substr"}, {"input": "\"aaabbbaaa\"\n\"bb\"\nfalse", "output": "[1]", "fn_name": "search_substr"}, {"input": "\"aaacccbbbcccc\"\n\"cc\"", "output": "[5]", "fn_name": "search_substr"}, {"input": "\"aaabbbcccc\"\n\"bbb\"", "output": "[1]", "fn_... | code_functional |
[
{
"content": "In the official contest this problem has a different statement, for which jury's solution was working incorrectly, and for this reason it was excluded from the contest. This mistake have been fixed and the current given problem statement and model solution corresponds to what jury wanted it to be ... | [{"input": "20\n1306340891 192811911 592111899 609607891 585084800 601258511 223103775 164258550 858003275 230837577 971499807 312977833 344314550 397998873 558637732 216574673 913028292 1360238301 464376621 61315042\n", "output": "384683838\n"}, {"input": "20\n713900269 192811911 592111899 609607891 585084800 60125851... | code_stdio |
[
{
"content": "There exists an island called Arpa’s land, some beautiful girls live there, as ugly ones do.\n\nMehrdad wants to become minister of Arpa’s land. Arpa has prepared an exam. Exam has only one question, given n, print the last digit of 1378^{n}. \n\n [Image] \n\nMehrdad has become quite confused and ... | [{"input": "1000000000\n", "output": "6\n"}, {"input": "1902349577\n", "output": "8\n"}, {"input": "0000000000\n", "output": "1\n"}, {"input": "1065810635\n", "output": "2\n"}, {"input": "1760197508\n", "output": "6\n"}, {"input": "1603265602\n", "output": "4\n"}, {"input": "0001000000\n", "output": "6\n"}, {"input": "... | code_stdio |
[
{
"content": "Vladik and Chloe decided to determine who of them is better at math. Vladik claimed that for any positive integer n he can represent fraction <image> as a sum of three distinct positive fractions in form <image>.\n\nHelp Vladik with that, i.e for a given n find three distinct positive integers x, ... | [{"input": "10000\n", "output": "10000 10001 100010000 "}, {"input": "17554\n", "output": "17554 17555 308160470\n"}, {"input": "10023\n", "output": "10023 10024 100470552\n"}, {"input": "19176\n", "output": "19176 19177 367738152\n"}, {"input": "14118\n", "output": "14118 14119 199332042\n"}, {"input": "12693\n", "out... | code_stdio |
[
{
"content": "In a factory, there are N robots placed on a number line. Robot i is placed at coordinate X_i and can extend its arms of length L_i in both directions, positive and negative.\n\nWe want to remove zero or more robots so that the movable ranges of arms of no two remaining robots intersect. Here, for... | [{"input": "5\n10 1\n2 2\n1 1\n10 1\n8 2", "output": "2\n"}, {"input": "5\n10 1\n2 2\n4 1\n6 1\n8 1", "output": "4\n"}, {"input": "5\n18 1\n2 1\n4 1\n6 1\n8 1", "output": "5\n"}, {"input": "5\n10 1\n2 2\n4 1\n6 1\n8 2", "output": "3\n"}, {"input": "5\n10 1\n2 2\n0 1\n6 1\n8 2", "output": "3\n"}, {"input": "4\n4 16\n4 3... | code_stdio |
[
{
"content": "Now 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 sequence so complex that no matter how hard he tries, he will not be able to remove ... | [{"input": "((()((()()))))(\n", "output": "1\n12\n1 2 3 5 6 7 8 10 11 12 13 14\n"}, {"input": "(((((())()))()(\n", "output": "1\n12\n1 2 3 4 5 6 7 8 10 11 12 14\n"}, {"input": "((()(())()))()(\n", "output": "1\n10\n1 2 3 5 6 8 10 11 12 14\n"}, {"input": "((()((()()))()(\n", "output": "1\n10\n1 2 3 5 6 8 10 11 12 14\n"}... | code_stdio |
[
{
"content": "Construct a dice from a given sequence of integers in the same way as Dice I.\n\nYou are given integers on the top face and the front face after the dice was rolled in the same way as Dice I. Write a program to print an integer on the right side face.\n\n\n<image>\n\n\nConstraints\n\n* $0 \\leq $ ... | [{"input": "1 2 3 4 14 -1\n3\n1 3\n1 4\n3 2", "output": "14\n2\n-1\n"}, {"input": "1 2 3 4 5 12\n3\n3 2\n1 3\n3 2", "output": "12\n5\n12\n"}, {"input": "1 2 3 4 5 16\n3\n3 2\n1 3\n3 2", "output": "16\n5\n16\n"}, {"input": "1 2 3 4 5 12\n3\n4 2\n1 3\n3 2", "output": "1\n5\n12\n"}, {"input": "1 2 3 4 5 10\n3\n4 2\n1 5\n3... | code_stdio |
[
{
"content": "The on-board computer on Polycarp's car measured that the car speed at the beginning of some section of the path equals v_1 meters per second, and in the end it is v_2 meters per second. We know that this section of the route took exactly t seconds to pass.\n\nAssuming that at each of the seconds ... | [{"input": "100 100\n100 10\n", "output": "34500\n"}, {"input": "100 100\n100 10\n", "output": "34500"}, {"input": "100 100\n100 0\n", "output": "10000\n"}, {"input": "100 100\n100 1\n", "output": "12450\n"}, {"input": "100 101\n100 1\n", "output": "12500\n"}, {"input": "100 111\n100 1\n", "output": "12970\n"}, {"input... | code_stdio |
[
{
"content": "zscoder wants to generate an input file for some programming competition problem.\n\nHis input is a string consisting of n letters 'a'. He is too lazy to write a generator so he will manually generate the input in a text editor.\n\nInitially, the text editor is empty. It takes him x seconds to ins... | [{"input": "4528217 187553422 956731625\n", "output": "21178755627\n"}, {"input": "9999999 987654321 123456789\n", "output": "11728395036\n"}, {"input": "7186329 608148870 290497442\n", "output": "12762929866\n"}, {"input": "7789084 807239576 813643932\n", "output": "25165322688\n"}, {"input": "9999999 1516835495 20283... | code_stdio |
[
{
"content": "You are given a sequence of positive integers of length N, A=a_1,a_2,…,a_{N}, and an integer K.\nHow many contiguous subsequences of A satisfy the following condition?\n - (Condition) The sum of the elements in the contiguous subsequence is at least K.\nWe consider two contiguous subsequences diff... | [{"input": "36 320641\n1039 4886 56224 3736 39132 60247 35771 31922 18818 92028 9791 31159 86363 16541 65981 53487 95561 6303 46808 55427 22512 73795 55807 31335 65754 84343 69866 69648 66544 89829 16458 3890 91183 52351 91315 40851\n", "output": "465\n"}, {"input": "29 888655\n98896 43712 73112 68378 65614 15800 83921... | code_stdio |
[
{
"content": "You are given a string $t$ and a set $S$ of $N$ different strings. You need to separate $t$ such that each part is included in $S$.\n\nFor example, the following 4 separation methods satisfy the condition when $t = abab$ and $S = \\\\{a, ab, b\\\\}$.\n\n* $a,b,a,b$\n* $a,b,ab$\n* $ab,a,b$\n* $ab,a... | [{"input": "10\na\naa\naaa\naaaa\naaaaa\naaaaaa\naaaaaaa\na`aaaaaa\naaaaaaaaa\naaaaaabaaa\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "output": "633900632\n"}, {"input": "10\na\naa\naaa\naaaa\naaa`a\naaaaaa\naaaaaaa\na`aaaaaa\naaaaaaaaa\naaaaaabaaa\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "output": "630934097\n"}, {... | code_stdio |
[
{
"content": "The Duck song\n\nFor simplicity, we'll assume that there are only three types of grapes: green grapes, purple grapes and black grapes.\n\nAndrew, Dmitry and Michal are all grapes' lovers, however their preferences of grapes are different. To make all of them happy, the following should happen: And... | [{"input": "100000 100000 100000\n100000 100000 100000\n", "output": "YES\n"}, {"input": "100000 100000 100000\n100000 100000 100000\n", "output": "YES\n"}, {"input": "99999 100000 100000\n100000 100000 100000\n", "output": "YES\n"}, {"input": "100000 99999 100000\n100000 100000 100000\n", "output": "YES\n"}, {"input":... | code_stdio |
[
{
"content": "You are playing a game of Jongmah. You don't need to know the rules to solve this problem. You have n tiles in your hand. Each tile has an integer between 1 and m written on it.\n\nTo win the game, you will need to form some number of triples. Each triple consists of three tiles, such that the num... | [{"input": "100 10\n7 4 5 5 10 10 5 8 5 7 4 5 4 6 8 8 2 6 3 3 10 7 10 8 6 2 7 3 9 7 7 2 4 5 2 4 9 5 10 1 10 5 10 4 1 3 4 2 6 9 9 9 10 6 2 5 6 1 8 10 4 10 3 4 10 5 5 4 10 4 5 3 7 10 2 7 3 6 9 6 1 6 5 5 4 6 6 4 4 1 5 1 6 6 6 8 8 6 2 6\n", "output": "33\n"}, {"input": "100 10\n7 4 5 5 10 10 5 8 5 7 4 5 4 6 8 8 2 6 3 3 10 ... | code_stdio |
[
{
"content": "Gerald has been selling state secrets at leisure. All the secrets cost the same: n marks. The state which secrets Gerald is selling, has no paper money, only coins. But there are coins of all positive integer denominations that are powers of three: 1 mark, 3 marks, 9 marks, 27 marks and so on. The... | [{"input": "108\n", "output": " 2"}, {"input": "243\n", "output": " 1"}, {"input": "81\n", "output": " 1"}, {"input": "10\n", "output"... | code_stdio |
[
{
"content": "Recently Johnny have learned bogosort sorting algorithm. He thought that it is too ineffective. So he decided to improve it. As you may know this algorithm shuffles the sequence randomly until it is sorted. Johnny decided that we don't need to shuffle the whole sequence every time. If after the la... | [{"input": "3\n3\n6\n42", "output": "10/3\n1826/189\n3861289540035137932590423886961807813592751894315116939644306/8913121775113966157962800372668924735854723781840323828125\n"}, {"input": "3\n3\n5\n42", "output": "10/3\n149/21\n3861289540035137932590423886961807813592751894315116939644306/89131217751139661579628003726... | code_stdio |
[
{
"content": "# Task\n You are given three integers `l, d and x`. Your task is:\n```\n• determine the minimal integer n \n such that l ≤ n ≤ d, and the sum of its digits equals x.\n• determine the maximal integer m \n such that l ≤ m ≤ d, and the sum of its digits equals x.\n```\nIt is guaranteed that suc... | [{"input": "2000\n7000\n3", "output": "[[2001, 3000]]", "fn_name": "min_and_max"}, {"input": "99\n5001\n28", "output": "[[1999, 4996]]", "fn_name": "min_and_max"}, {"input": "99\n5001\n27", "output": "[[999, 4995]]", "fn_name": "min_and_max"}, {"input": "100\n200\n10", "output": "[[109, 190]]", "fn_name": "min_and_max"... | code_functional |
[
{
"content": "Switch/Case - Bug Fixing #6\n\nOh no! Timmy's evalObject function doesn't work. He uses Switch/Cases to evaluate the given properties of an object, can you fix timmy's function?\n\nWrite Python code to solve this problem. Define a top-level function named `eval_object` that takes the input argumen... | [{"input": "{\"a\": 1, \"b\": 1, \"operation\": \"**\"}", "output": "[1]", "fn_name": "eval_object"}, {"input": "{\"a\": 1, \"b\": 1, \"operation\": \"+\"}", "output": "[2]", "fn_name": "eval_object"}, {"input": "{\"a\": 1, \"b\": 1, \"operation\": \"-\"}", "output": "[0]", "fn_name": "eval_object"}, {"input": "{\"a\":... | code_functional |
[
{
"content": "Innokenty works at a flea market and sells some random stuff rare items. Recently he found an old rectangular blanket. It turned out that the blanket is split in $n \\cdot m$ colored pieces that form a rectangle with $n$ rows and $m$ columns. \n\nThe colored pieces attracted Innokenty's attention ... | [{"input": "10 10\naaaaarpppp\nbbbbsssssu\ncciiiiiiqq\nddmmgggggg\neeebbbbbbb\nfffffqoooo\ngxxxxrrrrr\nhhfuuuuuuu\niiillqqqqq\njjjjjppwww\n", "output": "138\n"}, {"input": "10 10\naaaaaaaaaa\nbbbbbbbbbb\ncccccccccc\ndddddddddd\neeeeeeeeee\nffffffffff\ngggggggggg\nhhhhhhhhhh\niiiiiiiiii\njjjjjjjjjj\n", "output": "440\n"... | code_stdio |
[
{
"content": "You are given $4n$ sticks, the length of the $i$-th stick is $a_i$.\n\nYou have to create $n$ rectangles, each rectangle will consist of exactly $4$ sticks from the given set. The rectangle consists of four sides, opposite sides should have equal length and all angles in it should be right. Note t... | [{"input": "5\n1\n1 1 10 10\n2\n10 5 2 10 1 1 2 5\n2\n10 5 1 10 5 1 1 1\n2\n1 1 1 1 1 1 1 1\n1\n10000 10000 10000 10000\n", "output": "YES\nYES\nNO\nYES\nYES\n"}, {"input": "5\n1\n1 1 10 10\n2\n10 5 2 10 1 1 2 5\n2\n10 5 1 10 5 1 1 1\n2\n1 1 1 1 1 1 1 1\n1\n10000 10000 10000 10000\n", "output": "YES\nYES\nNO\nYES\nYES\... | code_stdio |
[
{
"content": "Taro is planning a long trip by train during the summer vacation. However, in order for Taro, who is a high school student, to travel as far as possible during the summer vacation, which has only one month, he cannot make a good plan unless he finds the cheapest and the fastest way. Let's create a... | [{"input": "6 5\n1 2 200 12\n1 4 400 15\n1 5 250 25\n2 4 100 10\n4 5 150 20\n3 5 300 21\n2\n1 5 0\n1 5 0\n0 0", "output": "250\n250\n"}, {"input": "6 14\n1 2 200 10\n2 4 103 22\n2 3 250 13\n2 3 100 10\n4 5 178 10\n3 3 300 30\n2\n2 5 0\n1 5 1\n0 0", "output": "281\n42\n"}, {"input": "6 5\n1 2 200 10\n1 4 400 15\n1 3 250... | code_stdio |
[
{
"content": "A carpet shop sells carpets in different varieties. Each carpet can come in a different roll width and can have a different price per square meter. \n\nWrite a function `cost_of_carpet` which calculates the cost (rounded to 2 decimal places) of carpeting a room, following these constraints:\n\n* T... | [{"input": "0\n0\n4\n10", "output": "[\"error\"]", "fn_name": "cost_of_carpet"}, {"input": "5\n6\n4\n10", "output": "[\"error\"]", "fn_name": "cost_of_carpet"}, {"input": "3.9\n2\n4\n10", "output": "[80]", "fn_name": "cost_of_carpet"}, {"input": "3\n5\n4\n10", "output": "[200]", "fn_name": "cost_of_carpet"}, {"input": ... | code_functional |
[
{
"content": "DZY loves chessboard, and he enjoys playing with it.\n\nHe has a chessboard of n rows and m columns. Some cells of the chessboard are bad, others are good. For every good cell, DZY wants to put a chessman on it. Each chessman is either white or black. After putting all chessmen, DZY wants that no ... | [{"input": "8 35\n......................-............\n...-..........-........-...........\n...........-.......................\n-..................................\n...................................\n...........-............-.........-\n.........-.........-.--............\n.........................-.........\n", "ou... | code_stdio |
[
{
"content": "In poker, you have 5 cards. There are 10 kinds of poker hands (from highest to lowest):\n\n- royal flush - ace, king, queen, jack and ten, all in the same suit\n\n- straight flush - five cards of the same suit in sequence, such\nas 10,9,8,7,6 of clubs; ace can be counted both as the highest card... | [{"input": "3\nAH KH QH TH JH\nJH 6S 3C 5C 7D\nQH QD 4S QC 2C", "output": "royal flush\nhigh card\nthree of a kind\n"}, {"input": "3\nAH KH QH TH JH\nKH 6S 2D 5C 7D\nQH QD 4S QC 2C", "output": "royal flush\nhigh card\nthree of a kind\n"}, {"input": "3\nAH KH QH TH JH\nKH 5S 3D 4C 8D\nQH QD 3S QC 2C", "output": "royal f... | code_stdio |
[
{
"content": "Description\n\nKMC sells CDs every year at a coterie spot sale called Comic Market. F was supposed to sell CDs at the comic market, but due to the popularity of F, the KMC sales floor was flooded with people, and the calculation of change could not keep up. So F decided to write a program that wou... | [{"input": "500 1000\n100 10000\n400 1006\n1029 5000\n10000 10000\n0 0", "output": "0 1 0\n4 1 9\n1 1 0\n4 1 3\n0 0 0\n"}, {"input": "500 1001\n001 10100\n400 1047\n429 5000\n10000 10000\n0 0", "output": "0 1 0\n0 0 10\n1 1 0\n0 1 4\n0 0 0\n"}, {"input": "500 1001\n001 11100\n400 1047\n429 5000\n10000 10000\n0 0", "out... | code_stdio |
[
{
"content": "You've got a string s = s1s2... s|s| of length |s|, consisting of lowercase English letters. There also are q queries, each query is described by two integers li, ri (1 ≤ li ≤ ri ≤ |s|). The answer to the query is the number of substrings of string s[li... ri], which are palindromes.\n\nString s[l... | [{"input": "ccca\n100\n2 4\n1 2\n1 1\n2 3\n3 4\n3 4\n2 2\n3 3\n1 2\n1 4\n2 2\n1 3\n1 4\n4 4\n1 2\n2 3\n3 4\n1 3\n3 4\n2 3\n1 1\n2 4\n1 4\n1 2\n2 2\n2 2\n1 1\n3 3\n1 2\n2 3\n2 3\n1 2\n1 4\n4 4\n2 2\n2 2\n4 4\n1 4\n1 1\n1 2\n4 4\n2 3\n2 4\n3 3\n1 4\n2 4\n2 3\n4 4\n4 4\n3 4\n2 2\n1 2\n1 1\n1 2\n3 3\n2 4\n1 3\n2 4\n1 1\n3 ... | code_stdio |
[
{
"content": "In this Kata, you will be given a mathematical string and your task will be to remove all braces as follows:\n\n```Haskell\nsolve(\"x-(y+z)\") = \"x-y-z\"\nsolve(\"x-(y-z)\") = \"x-y+z\"\nsolve(\"u-(v-w-(x+y))-z\") = \"u-v+w+x+y-z\"\nsolve(\"x-(-y-z)\") = \"x+y+z\"\n```\n\nThere are no spaces in t... | [{"input": "\"v-(l+s)-(t+y)-(c+f)+(b-(n-p))\"", "output": "[\"v-l-s-t-y-c-f+b-n+p\"]", "fn_name": "solve"}, {"input": "\"x-(-((-((((-((-(-(-y)))))))))))\"", "output": "[\"x-y\"]", "fn_name": "solve"}, {"input": "\"q+(s-(x-o))-(t-(w-a))\"", "output": "[\"q+s-x+o-t+w-a\"]", "fn_name": "solve"}, {"input": "\"(((((((m-(-((... | code_functional |
[
{
"content": "Polycarp has a cat and his cat is a real gourmet! Dependent on a day of the week he eats certain type of food: on Mondays, Thursdays and Sundays he eats fish food; on Tuesdays and Saturdays he eats rabbit stew; on other days of week he eats chicken stake. \n\nPolycarp plans to go on a trip and ... | [{"input": "700000000 700000000 700000000\n", "output": "1633333336\n"}, {"input": "600025643 600010745 600014575\n", "output": "1400059835\n"}, {"input": "600019415 600004367 600015718\n", "output": "1400045303\n"}, {"input": "650439292 352470919 347331093\n", "output": "1215658828\n"}, {"input": "690005222 690012314 ... | code_stdio |
[
{
"content": "Petya loves hockey very much. One day, as he was watching a hockey match, he fell asleep. Petya dreamt of being appointed to change a hockey team's name. Thus, Petya was given the original team name w and the collection of forbidden substrings s1, s2, ..., sn. All those strings consist of uppercas... | [{"input": "100\nqn\nBE\nyN\nep\nPq\nXz\nLM\nEZ\ndb\nMn\nbn\nFe\nqA\nzc\nyq\npC\nyA\nWk\nYq\nrs\noD\nvD\nzW\nxZ\nbl\nur\nkf\ndf\nLS\nUW\nMy\nhR\nsh\nNh\nog\nCW\nor\nzo\nrO\nao\nXH\nDq\nKa\nlL\nYQ\nOh\nRZ\nAx\nta\nko\nDn\nNg\nNy\nDB\nYD\njO\nAp\nFT\noB\nNc\nwB\nHO\neW\nAc\nDr\nMt\nDf\nbF\nFP\nRa\nnF\nhF\nXC\nnG\nan\nZY\... | code_stdio |
[
{
"content": "ZS the Coder has recently found an interesting concept called the Birthday Paradox. It states that given a random set of 23 people, there is around 50% chance that some two of them share the same birthday. ZS the Coder finds this very interesting, and decides to test this with the inhabitants of U... | [{"input": "1000000000000000010 1000000000000000000\n", "output": "954414 954414\n"}, {"input": "1000000000000000000 1000000000000000000\n", "output": "906300 906300"}, {"input": "1000000000000000000 1000000000000000000\n", "output": "906300 906300"}, {"input": "1002926547994558173 397746475431992189\n", "output": "145... | code_stdio |
[
{
"content": "DZY has a sequence a, consisting of n integers.\n\nWe'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.\n\nYour task is to find the longest subsegment of a, such that it is possible to change ... | [{"input": "50\n804289384 846930887 681692778 714636916 957747794 424238336 719885387 649760493 596516650 189641422 25202363 350490028 783368691 102520060 44897764 967513927 365180541 540383427 304089173 303455737 35005212 521595369 294702568 726956430 336465783 861021531 59961394 89018457 101513930 125898168 131176230... | code_stdio |
[
{
"content": "Let's denote as L(x, p) an infinite sequence of integers y such that gcd(p, y) = 1 and y > x (where gcd is the greatest common divisor of two integer numbers), sorted in ascending order. The elements of L(x, p) are 1-indexed; for example, 9, 13 and 15 are the first, the second and the third elemen... | [{"input": "5\n42 42 42\n43 43 43\n44 44 44\n45 45 45\n46 46 46\n", "output": "187\n87\n139\n128\n141\n"}, {"input": "5\n42 42 42\n43 43 43\n44 44 44\n45 45 45\n46 46 68\n", "output": "187\n87\n139\n128\n187\n"}, {"input": "5\n42 42 42\n43 43 43\n44 44 44\n45 45 45\n84 46 68\n", "output": "187\n87\n139\n128\n225\n"}, {... | code_stdio |
[
{
"content": "Leonid wants to become a glass carver (the person who creates beautiful artworks by cutting the glass). He already has a rectangular w mm × h mm sheet of glass, a diamond glass cutter and lots of enthusiasm. What he lacks is understanding of what to carve and how.\n\nIn order not to waste time, ... | [{"input": "10 19 10\nV 6\nH 8\nV 4\nV 8\nH 2\nH 5\nV 9\nH 7\nH 3\nV 7\n", "output": "114\n66\n44\n44\n44\n44\n44\n44\n44\n44\n"}, {"input": "15 5 10\nV 13\nV 6\nV 3\nH 4\nV 12\nV 7\nV 2\nH 1\nV 4\nH 3\n", "output": "65\n35\n35\n28\n24\n20\n20\n15\n15\n10\n"}, {"input": "5 25 10\nH 8\nH 9\nV 1\nH 2\nH 6\nH 4\nH 1\nV 2\... | code_stdio |
[
{
"content": "Giga Tower is the tallest and deepest building in Cyberland. There are 17 777 777 777 floors, numbered from - 8 888 888 888 to 8 888 888 888. In particular, there is floor 0 between floor - 1 and floor 1. Every day, thousands of tourists come to this place to enjoy the wonderful view. \n\nIn Cyb... | [{"input": "-1000000000\n", "output": "2\n"}, {"input": "-1000000000\n", "output": "2\n"}, {"input": "-1325769607\n", "output": "9\n"}, {"input": "-1737641826\n", "output": "1\n"}, {"input": "-410058385\n", "output": "1\n"}, {"input": "-586825624\n", "output": "1\n"}, {"input": "-408490162\n", "output": "1\n"}, {"input... | code_stdio |
[
{
"content": "You received a notebook which is called Death Note. This notebook has infinite number of pages. A rule is written on the last page (huh) of this notebook. It says: \"You have to write names in this notebook during $n$ consecutive days. During the $i$-th day you have to write exactly $a_i$ names.\"... | [{"input": "16 2\n999999999 999999999 999999999 856501885 1080831631 999999999 768581442 1196229362 999999999 999999999 1341911334 1890212075 1581621479 999999999 999999999 999999999\n", "output": "499999999 500000000 499999999 428250943 540415815 500000000 384290721 598114681 499999999 500000000 670955667 945106037 79... | code_stdio |
[
{
"content": "Edward Leven loves multiples of eleven very much. When he sees a number, he always tries to find consecutive subsequences (or substrings) forming multiples of eleven. He calls such subsequences as 11-sequences. For example, he can find an 11-sequence 781 in a number 17819.\n\nHe thinks a number wh... | [{"input": "17819\n1011\n11011\n1234567891011121314151617181920\n0", "output": "1\n1\n4\n38\n"}, {"input": "17819\n1010\n11011\n1234567891011121314151617181920\n0", "output": "1\n0\n4\n38\n"}, {"input": "17819\n1011\n11011\n1300831114838731654212402340246\n0", "output": "1\n1\n4\n32\n"}, {"input": "17819\n1010\n01011\n... | code_stdio |
[
{
"content": "# Back-Story\n\nEvery day I travel on the freeway.\n\nWhen I am more bored than usual I sometimes like to play the following counting game I made up:\n\n* As I join the freeway my count is ```0```\n* Add ```1``` for every car that I overtake\n* Subtract ```1``` for every car that overtakes me\n* S... | [{"input": "50.0\n120.0\n[[-1.0, 115.0], [-1.5, 110.0], [1.0, 130.0], [1.5, 130.0]]", "output": "[0]", "fn_name": "freeway_game"}, {"input": "50.0\n110.0\n[[-1.0, 110.0], [0.5, 110.0], [1.0, 110.0], [1.5, 110.0]]", "output": "[0]", "fn_name": "freeway_game"}, {"input": "30.0\n100.0\n[[-1.0, 110.0], [-0.7, 102.0], [-1.5... | code_functional |
[
{
"content": "In programming, hexadecimal notation is often used.\nIn hexadecimal notation, besides the ten digits 0, 1, ..., 9, the six letters A, B, C, D, E and F are used to represent the values 10, 11, 12, 13, 14 and 15, respectively.\nIn this problem, you are given two letters X and Y. Each X and Y is A, B... | [{"input": "A B\n", "output": "<\n"}, {"input": "E C\n", "output": ">\n"}, {"input": "F F\n", "output": "=\n"}, {"input": "E F", "output": "<\n"}, {"input": "A A", "output": "=\n"}, {"input": "E B", "output": ">\n"}, {"input": "D F", "output": "<\n"}, {"input": "A C", "output": "<\n"}, {"input": "E A", "output": ">\n"}... | code_stdio |
[
{
"content": "SaMer has written the greatest test case of all time for one of his problems. For a given array of integers, the problem asks to find the minimum number of groups the array can be divided into, such that the product of any pair of integers in the same group is a perfect square. \n\nEach integer mu... | [{"input": "80\n8861 -8846 -3257 8263 -8045 4549 9626 -6582 5755 -3559 5813 -7411 9151 -1847 2441 4201 2381 4651 -6571 199 -6737 -6333 -9433 -4967 9041 -9319 6801 5813 -2731 -8599 7681 -1303 -7333 6067 -1847 -6333 6047 -7907 -7333 8677 -937 829 2441 -5702 -8045 -3037 -4882 -7703 9001 -5702 -2039 -7493 9173 -6047 6046 5... | code_stdio |
[
{
"content": "A new e-mail service \"Berlandesk\" is going to be opened in Berland in the near future. The site administration wants to launch their project as soon as possible, that's why they ask you to help. You're suggested to implement the prototype of site registration system. The system should work on th... | [{"input": "10\nzzzzzzzzzzzzzzzzzzzzzzzzzzz\nzzzzzzzzzzzzzzzzzzzzzzzzzzz\nzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\nzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\nzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\nzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\nzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\nzzzzzzzzzzzzzzzzzzzzzzzzzzz\nzzzzzzzzzzzzzzzzzzzzzzzzzzz\nzzzzzzzzzzzzzzzzzz... | code_stdio |
[
{
"content": "Your job is to find out the secret number hidden in a matrix, each of whose element is a digit ('0'-'9') or a letter ('A'-'Z'). You can see an example matrix in Figure 1.\n\n<image>\n\nFigure 1: A Matrix\n\nThe secret number and other non-secret ones are coded in a matrix as sequences of digits in... | [{"input": "7 4\n399A2R9\n0A413E0\n8A800DE\n820R037\n6 7\nJI03HE\nI277D2\n0DA1AH\n30C9G5\n99178A\nCA7EAI\nAHLBEM\n20 2\nA1234567891234CBDEHH\nBDEDF908034265091499\n0 0", "output": "3994800037\n2771978\n12345908034265091499\n"}, {"input": "7 4\n9R2A993\n0E314A0\n8A900DE\n820R037\n6 7\nJI03HD\n2277DI\n0DA1AH\n30C9G5\n991... | code_stdio |
[
{
"content": "Jamie loves sleeping. One day, he decides that he needs to wake up at exactly hh: mm. However, he hates waking up, so he wants to make waking up less painful by setting the alarm at a lucky time. He will then press the snooze button every x minutes until hh: mm is reached, and only then he will wa... | [{"input": "42\n15 44\n", "output": "12\n"}, {"input": "26\n04 58\n", "output": "26\n"}, {"input": "35\n15 25\n", "output": "13\n"}, {"input": "50\n01 59\n", "output": "10\n"}, {"input": "46\n06 16\n", "output": "17\n"}, {"input": "14\n03 30\n", "output": "41\n"}, {"input": "20\n15 52\n", "output": "24\n"}, {"input": "... | code_stdio |
[
{
"content": "You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.\n\nYou are given a time in format HH:MM that is currently ... | [{"input": "24\n17:30\n", "output": "17:30\n"}, {"input": "12\n17:30\n", "output": "07:30\n"}, {"input": "24\n99:99\n", "output": "09:09\n"}, {"input": "12\n05:54\n", "output": "05:54\n"}, {"input": "12\n00:05\n", "output": "01:05\n"}, {"input": "24\n23:80\n", "output": "23:00\n"}, {"input": "24\n73:16\n", "output": "0... | code_stdio |
[
{
"content": "You're given an undirected graph with $n$ nodes and $m$ edges. Nodes are numbered from $1$ to $n$.\n\nThe graph is considered harmonious if and only if the following property holds: For every triple of integers $(l, m, r)$ such that $1 \\le l < m < r \\le n$, if there exists a path going from nod... | [{"input": "1460 5\n100 300\n200 735\n420 117\n559 450\n435 900\n", "output": "795\n"}, {"input": "1460 5\n101 300\n200 735\n420 117\n559 450\n435 900\n", "output": "794\n"}, {"input": "1460 5\n100 300\n200 735\n420 117\n559 450\n435 460\n", "output": "630\n"}, {"input": "1460 5\n100 300\n200 735\n420 117\n234 450\n435... | code_stdio |
[
{
"content": "You are given a set of n points on the plane. A line containing the origin is called good, if projection of the given set to this line forms a symmetric multiset of points. Find the total number of good lines.\n\nMultiset is a set where equal elements are allowed.\n\nMultiset is called symmetric, ... | [{"input": "50\n-38 -107\n-34 -75\n-200 -143\n-222 -139\n-34 55\n-102 -79\n48 -99\n2 -237\n-118 -167\n-56 -41\n10 17\n68 -89\n-32 41\n-100 -93\n84 -1\n86 -15\n46 -145\n-101 -117\n8 31\n-36 -61\n-12 21\n-116 79\n88 -205\n70 -103\n-78 -37\n106 -5\n-96 -201\n-60 -103\n-54 45\n-138 -177\n-178 -47\n-154 -5\n-138 83\n44 -131... | code_stdio |
[
{
"content": "Tak performed the following action N times: rolling two dice.\nThe result of the i-th roll is D_{i,1} and D_{i,2}.\nCheck if doublets occurred at least three times in a row.\nSpecifically, check if there exists at lease one i such that D_{i,1}=D_{i,2}, D_{i+1,1}=D_{i+1,2} and D_{i+2,1}=D_{i+2,2} h... | [{"input": "100\n3 3\n1 1\n5 5\n4 4\n1 1\n3 3\n3 3\n5 5\n2 2\n3 3\n2 2\n2 2\n3 3\n3 3\n5 5\n3 3\n1 1\n3 3\n4 4\n1 1\n4 4\n3 3\n3 3\n4 4\n6 6\n5 5\n2 2\n6 6\n3 3\n1 1\n6 6\n4 4\n3 3\n3 3\n6 6\n2 2\n5 5\n5 5\n1 1\n1 1\n5 5\n6 6\n6 6\n4 4\n6 6\n6 6\n5 5\n3 3\n2 2\n1 1\n1 1\n4 4\n6 6\n5 5\n3 3\n2 2\n3 3\n6 6\n2 2\n1 1\n4 4... | code_stdio |
[
{
"content": "Consider a sequence of n numbers using integers from 0 to 9 k1, k2, ..., kn. Read the positive integers n and s,\n\nk1 + 2 x k2 + 3 x k3 + ... + n x kn = s\n\nCreate a program that outputs how many rows of n numbers such as. However, the same number does not appear more than once in one \"n sequen... | [{"input": "3 14\n10 3", "output": "14\n0\n"}, {"input": "3 22\n10 3", "output": "24\n0\n"}, {"input": "5 33\n3 1", "output": "119\n0\n"}, {"input": "4 53\n0 0", "output": "131\n0\n"}, {"input": "4 34\n3 2", "output": "100\n0\n"}, {"input": "2 25\n10 0", "output": "2\n0\n"}, {"input": "3 20\n3 1", "output": "22\n0\n"},... | code_stdio |
[
{
"content": "An uppercase or lowercase English letter \\alpha will be given as input.\nIf \\alpha is uppercase, print A; if it is lowercase, print a.\n\n-----Constraints-----\n - \\alpha is an uppercase (A - Z) or lowercase (a - z) English letter.\n\n-----Input-----\nInput is given from Standard Input in the f... | [{"input": "B\n", "output": "A\n"}, {"input": "a\n", "output": "a\n"}, {"input": "A\n", "output": "A\n"}, {"input": "G\n", "output": "A\n"}, {"input": "Y\n", "output": "A\n"}, {"input": "Z\n", "output": "A\n"}, {"input": "b\n", "output": "a\n"}, {"input": "r\n", "output": "a\n"}, {"input": "x\n", "output": "a\n"}, {"in... | code_stdio |
[
{
"content": "There is the faculty of Computer Science in Berland. In the social net \"TheContact!\" for each course of this faculty there is the special group whose name equals the year of university entrance of corresponding course of students at the university. \n\nEach of students joins the group of his cou... | [{"input": "5\n2043 2042 2041 2044 2040\n", "output": "2042\n"}, {"input": "5\n2012 2013 2014 2015 2016\n", "output": "2014\n"}, {"input": "5\n2011 2014 2012 2013 2010\n", "output": "2012\n"}, {"input": "5\n2014 2013 2011 2012 2015\n", "output": "2013\n"}, {"input": "5\n2021 2023 2024 2020 2022\n", "output": "2022\n"},... | code_stdio |
[
{
"content": "This is the easy version of the problem. The difference between the versions is the constraint on n and the required number of operations. You can make hacks only if all versions of the problem are solved.\n\nThere are two binary strings a and b of length n (a binary string is a string consisting ... | [{"input": "5\n2\n01\n10\n5\n01011\n11000\n2\n01\n01\n10\n0111011011\n1000110100\n1\n0\n0\n", "output": "3 1 2 1 \n5 1 5 1 3 1 \n0 \n11 1 10 8 7 6 1 5 4 1 3 1 \n0 \n"}, {"input": "5\n2\n01\n10\n5\n01101\n11100\n2\n01\n01\n10\n0111011011\n1000110100\n1\n0\n0\n", "output": "3 1 2 1 \n5 1 5 3 1 2 \n0 \n11 1 10 8 7 6 1 5 4... | code_stdio |
[
{
"content": "C: Short-circuit evaluation\n\nproblem\n\nNaodai-kun and Hokkaido University-kun are playing games. Hokkaido University first generates the following logical formula represented by BNF.\n\n\n<formula> :: = <or-expr>\n<or-expr> :: = <and-expr>\n| <or-expr> \"|\" <and-expr>\n<and-expr> :: = <term>\n... | [{"input": "?&?&?|?|?&?", "output": "3 2\n"}, {"input": "?|?&?|?&?&?", "output": "3 1\n"}, {"input": "?&?&?|?&?|?", "output": "3 3\n"}, {"input": "?&?|?|?&?&?", "output": "3 2\n"}, {"input": "?|?|?&?&?&?", "output": "3 1\n"}, {"input": "?&?&?&?|?|?", "output": "3 2\n"}, {"input": "?|?&?&?|?&?", "output": "3 1\n"}, {"in... | code_stdio |
[
{
"content": "JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.\n\nFirst, he splits the Banh-mi into $n$ parts, places them on a row and numbers them from $1$ throu... | [{"input": "10 8\n0110000110\n3 3\n1 10\n4 4\n1 8\n1 2\n9 10\n2 10\n3 9\n", "output": "1\n960\n0\n224\n2\n2\n480\n112\n"}, {"input": "10 8\n0110000110\n3 3\n1 10\n4 4\n1 8\n1 2\n9 10\n2 10\n3 9\n", "output": "1\n960\n0\n224\n2\n2\n480\n112\n"}, {"input": "10 8\n0110000110\n3 3\n2 10\n4 4\n1 8\n1 2\n9 10\n2 10\n3 9\n", ... | code_stdio |
[
{
"content": "One of the simple ciphers is the affine cipher. First, replace the letters a to z with the numbers a = 0, b = 1, c = 2, ..., x = 23, y = 24, z = 25 and 0 to 25. Then replace the original alphabet with the following formula.\n\n$ F (\\ gamma) = (\\ alpha \\ cdot \\ gamma + \\ beta) $ mod $ 26 $\n\n... | [{"input": "1\nx eazqyp pnop pngtg ye obmpngt xmybp mr lygw", "output": "p submit that there is another point of view\n"}, {"input": "1\nx pyqzae pnop pngtg ye obmpngt xmybp mr lygw", "output": "p timbus that there is another point of view\n"}, {"input": "1\nx pyqzae pnop pngtg ye onmpbgt xmybp mr lygw", "output": "p t... | code_stdio |
[
{
"content": "You are given sequence a_1, a_2, ..., a_{n} and m queries l_{j}, r_{j} (1 ≤ l_{j} ≤ r_{j} ≤ n). For each query you need to print the minimum distance between such pair of elements a_{x} and a_{y} (x ≠ y), that: both indexes of the elements lie within range [l_{j}, r_{j}], that is, l_{j} ≤ x, y ≤ ... | [{"input": "10 6\n4 2 1 5 12 7 9 8 10 4\n1 3\n1 10\n2 10\n2 9\n5 5\n2 8\n", "output": "-1\n9\n-1\n-1\n-1\n-1\n"}, {"input": "10 6\n4 2 1 5 6 7 9 8 10 4\n1 3\n1 10\n2 10\n2 9\n5 5\n2 8\n", "output": "-1\n9\n-1\n-1\n-1\n-1\n"}, {"input": "10 6\n4 2 1 5 6 4 12 8 10 4\n1 2\n1 10\n2 10\n2 9\n5 5\n2 8\n", "output": "-1\n4\n4... | code_stdio |
[
{
"content": "We will buy a product for N yen (the currency of Japan) at a shop.\nIf we use only 1000-yen bills to pay the price, how much change will we receive?\nAssume we use the minimum number of bills required.\n\n-----Constraints-----\n - 1 \\leq N \\leq 10000\n - N is an integer.\n\n-----Input-----\nInpu... | [{"input": "1900\n", "output": "100\n"}, {"input": "1001\n", "output": "999\n"}, {"input": "4575\n", "output": "425\n"}, {"input": "6426\n", "output": "574\n"}, {"input": "9445\n", "output": "555\n"}, {"input": "8772\n", "output": "228\n"}, {"input": "3447\n", "output": "553\n"}, {"input": "3497\n", "output": "503\n"},... | code_stdio |
[
{
"content": "I: Ravage\n\nSanta Claus was caught in the illuminations of the city and broke it.\n\nThere are N light bulbs in the illumination, and the $ i $ th light bulb only comes on when the voltage is above $ A_i $ and below $ B_i $.\n\nThe voltage should be the same everywhere in the illumination.\n\nFin... | [{"input": "4\n-1 2\n3 2\n-1 4\n-1 15", "output": "3\n"}, {"input": "4\n-4 2\n0 10\n3 7\n-2 2", "output": "3\n"}, {"input": "4\n-4 2\n0 10\n3 2\n-2 2", "output": "3\n"}, {"input": "4\n-4 2\n0 10\n3 2\n-4 2", "output": "3\n"}, {"input": "4\n-1 0\n3 6\n3 7\n-2 10", "output": "3\n"}, {"input": "4\n-1 2\n3 2\n-1 4\n-1 8", ... | code_stdio |
[
{
"content": "Find a cycle in a directed graph G(V, E).\n\nConstraints\n\n* 1 ≤ |V| ≤ 100\n* 0 ≤ |E| ≤ 1,000\n* si ≠ ti\n\nInput\n\nA directed graph G is given in the following format:\n\n\n|V| |E|\ns0 t0\ns1 t1\n:\ns|E|-1 t|E|-1\n\n\n|V| is the number of nodes and |E| is the number of edges in the graph. The g... | [{"input": "10 0\n0 6\n-1 2\n4 0", "output": "0\n"}, {"input": "10 0\n0 5\n-1 2\n4 0", "output": "0\n"}, {"input": "10 1\n0 5\n-1 2\n4 0", "output": "0\n"}, {"input": "10 1\n0 5\n-1 2\n2 0", "output": "0\n"}, {"input": "10 1\n0 5\n-1 2\n1 0", "output": "0\n"}, {"input": "11 3\n0 1\n0 2\n1 2", "output": "0\n"}, {"input"... | code_stdio |
[
{
"content": "On a number axis directed from the left rightwards, n marbles with coordinates x1, x2, ..., xn are situated. Let's assume that the sizes of the marbles are infinitely small, that is in this task each of them is assumed to be a material point. You can stick pins in some of them and the cost of stic... | [{"input": "15\n-241250505 -2\n-241250503 0\n-241250502 -5\n-241250501 -1\n-241250500 -3\n-241250499 2\n-241250498 -2\n-241250497 6\n-241250496 0\n-241250495 0\n-241250494 8\n-241250493 -5\n-241250492 7\n-241250491 -7\n-241250490 2\n", "output": "-20\n"}, {"input": "15\n-241250505 -2\n-241250503 0\n-241250502 -5\n-2412... | code_stdio |
[
{
"content": "Write a program which reads a word W and a text T, and prints the number of word W which appears in text T\n\nT consists of string Ti separated by space characters and newlines. Count the number of Ti which equals to W. The word and text are case insensitive.\n\nConstraints\n\n* The length of W ≤ ... | [{"input": "computer\nNurtures computer scientists and highly-skilled computer engineers\nwho will create and exploit \"knowledge\" for the enw era.\nProvides an outstanding computer environment.\nEND_OF_TEXT", "output": "3\n"}, {"input": "comquter\nNurtures computer scientists and highly-skilled computer engineers\nwh... | code_stdio |
[
{
"content": "Karlsson has visited Lillebror again. They found a box of chocolates and a big whipped cream cake at Lillebror's place. Karlsson immediately suggested to divide the sweets fairly between Lillebror and himself. Specifically, to play together a game he has just invented with the chocolates. The winn... | [{"input": "O O .\n O O . .\n. . . . .\n . . . .\n . O .\n", "output": "Lillebror\n"}, {"input": ". . O\n . O O .\nO . O . O\n O O O O\n . . O\n", "output": "Lillebror\n"}, {"input": "O O O\n O . O .\nO . . O O\n O . O O\n O O O\n", "output": "Lillebror\n"}, {"input": "O O O\n O O O O\nO . O O .\n . O O O\n O O O\n... | code_stdio |
[
{
"content": "The solution of $ x ^ 3 = q $ is to calculate the recurrence formula $ x_ {n + 1} = x_n-\\ frac {x_ {n} ^ 3 --q} {3x_ {n} ^ 2} $ It can be calculated approximately with.\n\nPut a positive number $ \\ frac {q} {2} $ in $ x_1 $\n\n$ x_2 = x_1-\\ frac {x_ {1} ^ 3 --q} {3x_ {1} ^ 2} $, $ x_3 = x_2-\\ ... | [{"input": "15\n153\n-1", "output": "2.466212\n5.348481\n"}, {"input": "15\n123\n-1", "output": "2.466212\n4.973190\n"}, {"input": "15\n194\n-1", "output": "2.466212\n5.788963\n"}, {"input": "15\n103\n-1", "output": "2.466212\n4.687549\n"}, {"input": "15\n116\n-1", "output": "2.466212\n4.877008\n"}, {"input": "15\n196\... | code_stdio |
[
{
"content": "For the given sequence with n different elements find the number of increasing subsequences with k + 1 elements. It is guaranteed that the answer is not greater than 8·1018.\n\nInput\n\nFirst line contain two integer values n and k (1 ≤ n ≤ 105, 0 ≤ k ≤ 10) — the length of sequence and the number ... | [{"input": "100 7\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n31\n32\n33\n34\n35\n36\n37\n38\n39\n40\n41\n42\n43\n44\n45\n46\n47\n48\n49\n50\n51\n52\n53\n54\n55\n56\n57\n58\n59\n60\n61\n62\n63\n64\n65\n66\n67\n68\n69\n70\n71\n72\n73\n74\n75\n76\n77\n78... | code_stdio |
[
{
"content": "YouKn0wWho has an integer sequence a_1, a_2, …, a_n. He will perform the following operation until the sequence becomes empty: select an index i such that 1 ≤ i ≤ |a| and a_i is not divisible by (i + 1), and erase this element from the sequence. Here |a| is the length of sequence a at the moment o... | [{"input": "5\n3\n1 4 3\n1\n1\n2\n7 11\n10\n384836991 191890310 576823355 183520469 404011431 1289917932 954291757 278929746 155374934 1531647833\n8\n5 73 1379 69130 598267 6969696 114587927 1145009244\n", "output": "YES\nYES\nYES\nYES\nYES\n"}, {"input": "5\n3\n1 4 3\n1\n1\n2\n13 11\n10\n384836991 191890310 576823355 ... | code_stdio |
[
{
"content": "There are literally dozens of snooker competitions held each year, and team Jinotega tries to attend them all (for some reason they prefer name \"snookah\")! When a competition takes place somewhere far from their hometown, Ivan, Artsem and Konstantin take a flight to the contest and back.\n\nJino... | [{"input": "50\nPFH\nJFV->PFH\nBVP->PFH\nPFH->BVP\nPFH->JFV\nPFH->ETQ\nPFH->LQJ\nZTO->PFH\nPFH->BVP\nPFH->RXO\nPFH->ZTO\nHWL->PFH\nPFH->HIV\nPFH->AFP\nPFH->HWL\nOBB->PFH\nHIV->PFH\nPFH->LSR\nAFP->PFH\nLQJ->PFH\nHWL->PFH\nETQ->PFH\nPFH->HWL\nLSR->PFH\nWBR->PFH\nBNZ->PFH\nHQR->PFH\nZTO->PFH\nPFH->WBR\nPFH->BYJ\nRXO->PFH\... | code_stdio |
[
{
"content": "You are given array $a$ of length $n$. You can choose one segment $[l, r]$ ($1 \\le l \\le r \\le n$) and integer value $k$ (positive, negative or even zero) and change $a_l, a_{l + 1}, \\dots, a_r$ by $k$ each (i.e. $a_i := a_i + k$ for each $l \\le i \\le r$).\n\nWhat is the maximum possible num... | [{"input": "39 1\n4 2 1 1 3 5 1 5 1 1 3 3 4 3 1 1 4 5 1 5 2 3 3 1 5 1 2 1 1 4 1 1 5 2 2 1 1 2 4\n", "output": "19\n"}, {"input": "39 1\n4 2 1 1 3 5 1 5 1 1 3 3 4 3 1 1 4 5 1 5 2 3 3 1 5 1 2 1 1 4 1 1 5 2 2 1 1 2 4\n", "output": "19\n"}, {"input": "39 1\n4 2 1 1 3 5 1 5 1 1 3 3 4 3 1 1 4 5 1 5 3 3 3 1 5 1 2 1 1 4 1 1 5 ... | code_stdio |
[
{
"content": "There are N integers X_1, X_2, \\cdots, X_N, and we know that A_i \\leq X_i \\leq B_i.\nFind the number of different values that the median of X_1, X_2, \\cdots, X_N can take.\n\n-----Notes-----\nThe median of X_1, X_2, \\cdots, X_N is defined as follows. Let x_1, x_2, \\cdots, x_N be the result o... | [{"input": "3\n111 110\n111 11100\n-2 1111011010", "output": "10990\n"}, {"input": "3\n011 110\n111 11100\n-2 1111011010", "output": "11090\n"}, {"input": "3\n010 110\n111 11100\n-2 1111011010", "output": "11091\n"}, {"input": "3\n000 010\n010 11100\n-2 0111011011", "output": "11101\n"}, {"input": "3\n000 011\n2 10000\... | code_stdio |
[
{
"content": "Convert integers to binary as simple as that. You would be given an integer as a argument and you have to return its binary form.\nTo get an idea about how to convert a decimal number into a binary number, visit here.\n\n**Notes**: negative numbers should be handled as two's complement; assume all... | [{"input": "-999999", "output": "[\"11111111111100001011110111000001\"]", "fn_name": "to_binary"}, {"input": "-1000", "output": "[\"11111111111111111111110000011000\"]", "fn_name": "to_binary"}, {"input": "-15", "output": "[\"11111111111111111111111111110001\"]", "fn_name": "to_binary"}, {"input": "-3", "output": "[\"1... | code_functional |
[
{
"content": "# How many ways can you make the sum of a number?\n\nFrom wikipedia: https://en.wikipedia.org/wiki/Partition_(number_theory)#\n\n>In number theory and combinatorics, a partition of a positive integer *n*, also called an *integer partition*, is a way of writing n as a sum of positive integers. Two ... | [{"input": "275", "output": "[1520980492851175]", "fn_name": "exp_sum"}, {"input": "200", "output": "[3972999029388]", "fn_name": "exp_sum"}, {"input": "90", "output": "[56634173]", "fn_name": "exp_sum"}, {"input": "70", "output": "[4087968]", "fn_name": "exp_sum"}, {"input": "60", "output": "[966467]", "fn_name": "exp... | code_functional |
[
{
"content": "It's the year 4527 and the tanks game that we all know and love still exists. There also exists Great Gena's code, written in 2016. The problem this code solves is: given the number of tanks that go into the battle from each country, find their product. If it is turns to be too large, then the ser... | [{"input": "6\n1000000000000000000000000000000000000 11965651543 1000000000000000000000000000000000000 1000000000000000000000000000000000000 1000000000000000000000000000000000000 1000000000000000000000000000000000000\n", "output": "1196565154300000000000000000000000000000000000000000000000000000000000000000000000000000... | code_stdio |
[
{
"content": "You are given n points on Cartesian plane. Every point is a lattice point (i. e. both of its coordinates are integers), and all points are distinct.\n\nYou may draw two straight lines (not necessarily distinct). Is it possible to do this in such a way that every point lies on at least one of these... | [{"input": "59\n1 0\n0 2\n0 3\n0 4\n0 5\n6 0\n7 0\n8 0\n9 0\n10 0\n0 11\n12 0\n13 0\n14 0\n15 0\n0 16\n0 17\n18 0\n19 0\n20 0\n21 0\n0 22\n23 0\n24 0\n0 25\n26 0\n27 0\n0 28\n0 29\n30 0\n31 0\n0 32\n33 0\n34 0\n0 35\n0 36\n37 0\n0 38\n39 0\n40 0\n0 41\n42 0\n0 43\n0 44\n0 45\n0 46\n47 0\n0 48\n0 49\n50 0\n0 51\n0 52\n5... | code_stdio |
[
{
"content": "We have N ID cards, and there are M gates.\nWe can pass the i-th gate if we have one of the following ID cards: the L_i-th, (L_i+1)-th, ..., and R_i-th ID cards.\nHow many of the ID cards allow us to pass all the gates alone?\n\n-----Constraints-----\n - All values in input are integers.\n - 1 \\l... | [{"input": "100000 1\n1 100000\n", "output": "100000\n"}, {"input": "101000 1\n1 100000", "output": "100000\n"}, {"input": "101000 1\n1 100100", "output": "100100\n"}, {"input": "101000 1\n1 100110", "output": "100110\n"}, {"input": "101000 1\n1 100010", "output": "100010\n"}, {"input": "101100 1\n2 100110", "output": ... | code_stdio |
[
{
"content": "Polycarp has $n$ friends, the $i$-th of his friends has $a_i$ candies. Polycarp's friends do not like when they have different numbers of candies. In other words they want all $a_i$ to be the same. To solve this, Polycarp performs the following set of actions exactly once:\n\nPolycarp chooses $k$ ... | [{"input": "1\n52\n0 1 1 1 1 -1 0 1 2 1 2 1 1 1 1 1 1 1 0 1 3 0 2 0 1 0 1 4 -1 2 1 1 -1 3 2 1 1 2 0 -1 2 1 2 0 1 2 2 1 1 1 1 0\n", "output": "13\n"}, {"input": "1\n52\n0 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 2 1 1 0 1 2 -1 2 0 0 -1 3 2 1 1 1 0 1 2 1 2 0 1 2 2 1 1 1 1 1\n", "output": "10\n"}, {"input": "1\n52\n0 1 1... | code_stdio |
[
{
"content": "You are given a positive integer $n$, written without leading zeroes (for example, the number 04 is incorrect). \n\nIn one operation you can delete any digit of the given integer so that the result remains a positive integer without leading zeros.\n\nDetermine the minimum number of operations that... | [{"input": "2000000000\n", "output": "-1\n"}, {"input": "2000000000\n", "output": "-1\n"}, {"input": "1881388645\n", "output": "6\n"}, {"input": "1059472069\n", "output": "3\n"}, {"input": "1354124829\n", "output": "4\n"}, {"input": "1999967841\n", "output": "0\n"}, {"input": "1999431225\n", "output": "0\n"}, {"input":... | code_stdio |
[
{
"content": "Problem statement\n\nJOI decided to start a new social game from tomorrow.\n\nIn this social game, you can log in up to once a day, and you will get A coins each time you log in.\n\nAlso, if you log in for 7 consecutive days from Monday to Sunday, you will get an additional B coins each time.\n\nN... | [{"input": "0 1 163", "output": "1141\n"}, {"input": "0 1 146", "output": "1022\n"}, {"input": "0 1 241", "output": "1687\n"}, {"input": "1 -1 229", "output": "267\n"}, {"input": "14 -2 229", "output": "17\n"}, {"input": "0 1 216", "output": "1512\n"}, {"input": "1 -1 163", "output": "190\n"}, {"input": "4 -3 502", "ou... | code_stdio |
[
{
"content": "You invited $n$ guests to dinner! You plan to arrange one or more circles of chairs. Each chair is going to be either occupied by one guest, or be empty. You can make any number of circles. \n\nYour guests happen to be a little bit shy, so the $i$-th guest wants to have a least $l_i$ free chairs t... | [{"input": "10\n1000000000 1000000000\n1000000000 1000000000\n1000000000 1000000000\n1000000000 1000000000\n1000000000 1000000000\n1000000000 1000000000\n1000000000 1000000000\n1000000000 1000000000\n1000000000 1000000000\n1000000000 1000000000\n", "output": "10000000010\n"}, {"input": "10\n1000000000 1000000000\n10000... | code_stdio |
[
{
"content": "There are $n$ robbers at coordinates $(a_1, b_1)$, $(a_2, b_2)$, ..., $(a_n, b_n)$ and $m$ searchlight at coordinates $(c_1, d_1)$, $(c_2, d_2)$, ..., $(c_m, d_m)$. \n\nIn one move you can move each robber to the right (increase $a_i$ of each robber by one) or move each robber up (increase $b_i$ o... | [{"input": "7 3\n0 8\n3 8\n2 7\n0 10\n5 5\n7 0\n3 5\n6 6\n3 11\n11 5\n", "output": "6\n"}, {"input": "7 3\n0 8\n3 8\n2 7\n0 10\n5 5\n7 0\n3 5\n6 1\n3 11\n11 5\n", "output": "6\n"}, {"input": "7 3\n0 8\n3 8\n2 7\n0 10\n5 5\n7 0\n3 5\n6 0\n3 11\n11 5\n", "output": "6\n"}, {"input": "7 3\n0 8\n3 8\n2 7\n0 10\n5 5\n7 0\n3 ... | code_stdio |
[
{
"content": "You want to arrange n integers a_1, a_2, ..., a_{n} in some order in a row. Let's define the value of an arrangement as the sum of differences between all pairs of adjacent integers.\n\nMore formally, let's denote some arrangement as a sequence of integers x_1, x_2, ..., x_{n}, where sequence x is... | [{"input": "100\n-790 341 910 905 -779 279 696 -375 525 -21 -2 751 -887 764 520 -844 850 -537 -882 -183 139 -397 561 -420 -991 691 587 -93 -701 -957 -89 227 233 545 934 309 -26 454 -336 -994 -135 -840 -320 -387 -943 650 628 -583 701 -708 -881 287 -932 -265 -312 -757 695 985 -165 -329 -4 -462 -627 798 -124 -539 843 -492... | code_stdio |
[
{
"content": "Arkady bought an air ticket from a city A to a city C. Unfortunately, there are no direct flights, but there are a lot of flights from A to a city B, and from B to C.\n\nThere are $n$ flights from A to B, they depart at time moments $a_1$, $a_2$, $a_3$, ..., $a_n$ and arrive at B $t_a$ moments lat... | [{"input": "10 11 4 5 10\n1 2 3 4 5 6 7 8 9 10\n16 17 18 19 20 21 22 23 24 25 26\n", "output": "-1\n"}, {"input": "10 11 4 5 10\n1 2 3 4 5 6 7 8 9 10\n16 17 18 19 20 21 22 23 24 25 26\n", "output": "-1\n"}, {"input": "4 3 2 3 1\n1 999999998 999999999 1000000000\n3 4 1000000000\n", "output": "1000000003\n"}, {"input": "... | code_stdio |
[
{
"content": "There are n people and k keys on a straight line. Every person wants to get to the office which is located on the line as well. To do that, he needs to reach some point with a key, take the key and then go to the office. Once a key is taken by somebody, it couldn't be taken by anybody else.\n\nYou... | [{"input": "50 55 2000\n9518 9743 9338 9956 9827 9772 9094 9644 9242 9292 9148 9205 9907 9860 9530 9814 9662 9482 9725 9227 9105 9424 9268 9427 9470 9578 9808 9976 9143 9070 9079 9896 9367 9235 9925 9009 9619 9012 9669 9077 9870 9766 9479 9598 9055 9988 9792 9197 9377 9610\n828 656 345 412 69 506 274 994 384 766 587 12... | code_stdio |
[
{
"content": "The only difference between easy and hard versions is constraints.\n\nNow elections are held in Berland and you want to win them. More precisely, you want everyone to vote for you.\n\nThere are $n$ voters, and two ways to convince each of them to vote for you. The first way to convince the $i$-th ... | [{"input": "3\n3\n1 5\n2 10\n2 15\n7\n0 1\n3 1\n1 1\n6 1\n1 1\n4 1\n4 1\n6\n2 6\n2 3\n2 15\n2 7\n4 4\n5 5\n", "output": "10\n0\n7\n"}, {"input": "3\n3\n1 5\n2 10\n2 4\n7\n0 1\n3 1\n1 1\n6 1\n1 1\n4 1\n4 1\n6\n2 6\n2 3\n2 14\n2 1\n4 4\n5 5\n", "output": "4\n0\n4\n"}, {"input": "3\n3\n1 5\n2 5\n2 4\n7\n0 1\n3 0\n1 1\n6 1... | code_stdio |
[
{
"content": "AtCoDeer the deer has N square tiles. The tiles are numbered 1 through N, and the number given to each tile is written on one side of the tile. Also, each corner of each tile is painted in one of the 1000 colors, which are represented by the integers 0 between 999. The top-left, top-right, bottom-... | [{"input": "400\n196 345 527 695\n685 207 136 831\n303 497 409 762\n464 670 120 403\n867 799 702 490\n986 9 287 852\n519 89 617 973\n291 551 957 275\n329 210 75 744\n685 560 225 510\n568 429 313 112\n94 659 30 204\n51 891 791 326\n890 977 807 600\n203 468 753 791\n738 279 376 58\n377 694 954 955\n436 875 436 104\n942 1... | code_stdio |
[
{
"content": "The academic year has just begun, but lessons and olympiads have already occupied all the free time. It is not a surprise that today Olga fell asleep on the Literature. She had a dream in which she was on a stairs. \n\nThe stairs consists of n steps. The steps are numbered from bottom to top, it m... | [{"input": "50\nUUUUUUUUUUUUUUUUUUUUUUUUUDDDDDDDDDDDDDDDDDDDDDDDDD\n", "output": "51 102 153 204 255 306 357 408 459 510 561 612 663 714 765 816 867 918 969 1020 1071 1122 1173 1224 1275 1275 1224 1173 1122 1071 1020 969 918 867 816 765 714 663 612 561 510 459 408 357 306 255 204 153 102 51 "}, {"input": "50\nUUUUUUUUU... | code_stdio |
[
{
"content": "Mr. Bender has a digital table of size n × n, each cell can be switched on or off. He wants the field to have at least c switched on squares. When this condition is fulfilled, Mr Bender will be happy.\n\nWe'll consider the table rows numbered from top to bottom from 1 to n, and the columns — numbe... | [{"input": "1000000000 504951981 646612086 602763371\n", "output": "17360\n"}, {"input": "1000000000 999999946 999999941 715189365\n", "output": "37707\n"}, {"input": "1000000000 999999916 999999940 857945620\n", "output": "41279\n"}, {"input": "1000000000 999999946 999999916 423654797\n", "output": "28970\n"}, {"input... | code_stdio |
[
{
"content": "Takahashi is competing in a sumo tournament. The tournament lasts for 15 days, during which he performs in one match per day. If he wins 8 or more matches, he can also participate in the next tournament.\n\nThe matches for the first k days have finished. You are given the results of Takahashi's ma... | [{"input": "xoxoxoxoxoxoxo", "output": "YES\n"}, {"input": "oxoxowoxoxoxox", "output": "YES\n"}, {"input": "oxoxowoooxoxxx", "output": "YES\n"}, {"input": "xxxoxooowoxoxo", "output": "YES\n"}, {"input": "xoxoxooxwoxoxo", "output": "YES\n"}, {"input": "xoxoyoxoxoxoxo", "output": "YES\n"}, {"input": "xxxoxoooooxwxo", "ou... | code_stdio |
[
{
"content": "Snuke lives in another world, where slimes are real creatures and kept by some people. Slimes come in N colors. Those colors are conveniently numbered 1 through N. Snuke currently has no slime. His objective is to have slimes of all the colors together.\n\nSnuke can perform the following two actio... | [{"input": "3 130\n011 10 101", "output": "122\n"}, {"input": "3 130\n111 10 101", "output": "222\n"}, {"input": "3 130\n111 10 100", "output": "221\n"}, {"input": "3 130\n011 10 100", "output": "121\n"}, {"input": "3 83\n011 10 101", "output": "114\n"}, {"input": "3 130\n111 7 100", "output": "218\n"}, {"input": "3 13... | code_stdio |
[
{
"content": "John has just bought a new car and is planning a journey around the country. Country has N cities, some of which are connected by bidirectional roads. There are N - 1 roads and every city is reachable from any other city. Cities are labeled from 1 to N.\n\nJohn first has to select from which city ... | [{"input": "4\n1 2\n2 3\n3 4\n", "output": "24\n"}, {"input": "4\n1 2\n2 3\n3 4\n", "output": "24\n"}, {"input": "4\n1 2\n1 3\n3 4\n", "output": "24\n"}, {"input": "4\n1 2\n2 3\n2 4\n", "output": "14\n"}, {"input": "4\n1 4\n2 3\n3 4\n", "output": "24\n"}, {"input": "4\n1 4\n2 1\n3 4\n", "output": "24\n"}, {"input": "4\... | code_stdio |
[
{
"content": "There 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 numbers from 1 to n + m. Then the number of integers i (1 ≤ i < n + m) such that po... | [{"input": "1 852\n", "output": "GBGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG... | code_stdio |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.