messages listlengths 1 1 | ground_truth stringlengths 156 726k | dataset stringclasses 1
value |
|---|---|---|
[
{
"content": "Read problems statements in Mandarin Chinese and Russian. \n\nChef is playing a game. Currently in the game, he is at a field full of stones. There are total N kinds of \nstones. There is unlimited supply of each kind of stone. \n\nChef knows that one stone of kind i needs A_{i} minutes to pick ... | [{"input": "1\n3 16\n1 4 4\n8 -1 1", "output": "128\n"}, {"input": "1\n3 10\n3 1 5\n4 8 -1", "output": "80\n"}, {"input": "1\n2 10\n10 1 5\n7 -1 0", "output": "7\n"}, {"input": "1\n3 16\n1 4 4\n4 -1 1", "output": "64\n"}, {"input": "1\n1 1\n10 13 4\n6 3 -1", "output": "0\n"}, {"input": "1\n1 1\n10 11 4\n4 3 -5", "outpu... | code_stdio |
[
{
"content": "In 20XX AD, a school competition was held. The tournament has finally left only the final competition. You are one of the athletes in the competition.\n\nThe competition you participate in is to compete for the time it takes to destroy all the blue objects placed in the space. Athletes are allowed... | [{"input": "5 5\n-38 -71 -293 75 1\n-158 -38 -405 66 1\n-236 -303 157 266 1\n316 26 411 190 1\n207 -312 -27 196 1\n-50 292 -375 -401 389 -389\n460 278 409 -329 -303 411\n215 -220 -200 309 -474 300\n310 -494 -87 -300 123 -463\n386 378 486 -443 -64 299", "output": "0\n2\n1\n3\n0\n"}, {"input": "5 5\n-38 -71 -293 75 1\n-1... | code_stdio |
[
{
"content": "There 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 current status is not \"FOLDED\" may show his/her hand to the table. However... | [{"input": "100\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n", "output": "100\n"}, {"input": "100\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n", "output": "100"}, {"input": "10\nAAAAAAAAAA\n", "output":... | code_stdio |
[
{
"content": "For an array b of length m we define the function f as \n\n f(b) = \\begin{cases} b[1] & if m = 1 \\\\\\ f(b[1] β b[2],b[2] β b[3],...,b[m-1] β b[m]) & otherwise, \\end{cases} \n\nwhere β is [bitwise exclusive OR](https://en.wikipedia.org/wiki/Bitwise_operation#XOR).\n\nFor example, f(1,2,4,... | [{"input": "6\n1 2 1 14 16 32\n4\n1 6\n3 5\n1 6\n1 2\n", "output": "63\n30\n63\n3\n"}, {"input": "6\n1 2 4 10 16 32\n4\n1 6\n1 5\n3 6\n1 1\n", "output": "62\n28\n62\n1\n"}, {"input": "6\n1 0 1 14 16 32\n4\n1 6\n3 5\n1 6\n1 2\n", "output": "63\n30\n63\n1\n"}, {"input": "6\n1 0 1 17 16 32\n4\n1 6\n3 5\n1 6\n1 2\n", "outp... | code_stdio |
[
{
"content": "There is a deck of $n$ cards. The $i$-th card has a number $a_i$ on the front and a number $b_i$ on the back. Every integer between $1$ and $2n$ appears exactly once on the cards.\n\nA deck is called sorted if the front values are in increasing order and the back values are in decreasing order. Th... | [{"input": "20\n24 12\n37 1\n5 35\n36 19\n22 6\n25 4\n26 17\n15 31\n39 8\n28 16\n11 29\n21 18\n14 34\n30 10\n32 2\n20 27\n33 13\n23 9\n40 7\n3 38\n", "output": "-1\n"}, {"input": "20\n7 29\n4 34\n40 2\n39 10\n33 5\n1 37\n20 23\n14 21\n22 9\n8 28\n19 24\n26 13\n32 6\n30 16\n11 38\n36 3\n35 12\n15 31\n17 27\n18 25\n", "o... | code_stdio |
[
{
"content": "Snuke has a large collection of cards. Each card has an integer between 1 and N, inclusive, written on it. He has A_i cards with an integer i.\n\nTwo cards can form a pair if the absolute value of the difference of the integers written on them is at most 1.\n\nSnuke wants to create the maximum num... | [{"input": "8\n1\n0\n2\n13\n1\n12\n5\n1", "output": "17\n"}, {"input": "8\n1\n0\n2\n18\n1\n12\n5\n1", "output": "19\n"}, {"input": "8\n1\n0\n2\n13\n1\n21\n5\n1", "output": "21\n"}, {"input": "8\n1\n1\n0\n24\n4\n3\n10\n1", "output": "22\n"}, {"input": "8\n1\n0\n2\n16\n1\n21\n5\n1", "output": "23\n"}, {"input": "8\n1\n0\... | code_stdio |
[
{
"content": "There are K blue balls and N-K red balls. The balls of the same color cannot be distinguished. Snuke and Takahashi are playing with these balls.\nFirst, Snuke will arrange the N balls in a row from left to right.\nThen, Takahashi will collect only the K blue balls. In one move, he can collect any ... | [{"input": "2000 849\n", "output": "1152\n562203648\n76583517\n109459402\n109338043\n155329001\n569751853\n393930605\n30668610\n172729191\n403640438\n424478909\n110785606\n354376031\n327302764\n297759221\n904322614\n38970179\n642408789\n12623313\n462072120\n718075856\n776805328\n371215178\n754737053\n296999830\n5315477... | code_stdio |
[
{
"content": "A function $f : R \\rightarrow R$ is called Lipschitz continuous if there is a real constant K such that the inequality |f(x) - f(y)| β€ KΒ·|x - y| holds for all $x, y \\in R$. We'll deal with a more... discrete version of this term.\n\nFor an array $h [ 1 . . n ]$, we define it's Lipschitz constant... | [{"input": "3 6\n48261735 26888803 75904937\n1 2\n1 3\n2 3\n1 2\n2 3\n1 3\n", "output": "21372932\n119405200\n49016134\n21372932\n49016134\n119405200\n"}, {"input": "3 6\n48261735 26888803 75904937\n1 2\n1 3\n2 3\n1 2\n2 3\n1 3\n", "output": "21372932\n119405200\n49016134\n21372932\n49016134\n119405200\n"}, {"input": "... | code_stdio |
[
{
"content": "Read problems statements in Mandarin Chinese and Russian as well. \n\nYou had an array of integer numbers. You also had a beautiful operations called \"Copy-Paste\" which allowed you to copy any contiguous subsequence of your array and paste it in any position of your array. For example, if you ha... | [{"input": "2\n5\n1 0 1 1 1\n5\n1 2 10 2 2", "output": "2\n3\n"}, {"input": "2\n5\n1 0 1 1 1\n5\n1 2 10 0 2", "output": "2\n4\n"}, {"input": "2\n5\n1 0 1 1 1\n5\n1 2 10 0 4", "output": "2\n5\n"}, {"input": "2\n5\n1 1 1 1 1\n5\n1 2 6 1 2", "output": "1\n3\n"}, {"input": "2\n5\n1 0 1 1 1\n5\n1 3 3 1 2", "output": "2\n3\n... | code_stdio |
[
{
"content": "A median of an array of integers of length $n$ is the number standing on the $\\lceil {\\frac{n}{2}} \\rceil$ (rounding up) position in the non-decreasing ordering of its elements. Positions are numbered starting with $1$. For example, a median of the array $[2, 6, 4, 1, 3, 5]$ is equal to $3$. Th... | [{"input": "6\n2 4\n0 24 37 58 62 64 69 78\n2 2\n27 61 81 91\n4 3\n0 4 16 18 21 27 36 53 82 91 92 95\n3 4\n1 11 12 22 33 35 38 67 69 71 94 99\n2 1\n11 41\n3 3\n1 2 1 1 1 1 1 1 -1\n", "output": "168\n108\n145\n234\n11\n3\n"}, {"input": "6\n2 4\n0 24 25 58 62 64 69 78\n2 2\n27 61 81 91\n4 3\n0 4 16 18 21 27 36 53 82 91 9... | code_stdio |
[
{
"content": "A big company decided to launch a new series of rectangular displays, and decided that the display must have exactly n pixels. \n\nYour task is to determine the size of the rectangular display β the number of lines (rows) of pixels a and the number of columns of pixels b, so that:\n\n there are e... | [{"input": "1000000\n", "output": "1000 1000\n"}, {"input": "1000000\n", "output": "1000 1000\n"}, {"input": "1100000\n", "output": "1000 1100\n"}, {"input": "1235799\n", "output": "549 2251\n"}, {"input": "1401914\n", "output": "214 6551\n"}, {"input": "1256957\n", "output": "403 3119\n"}, {"input": "1426666\n", "outp... | code_stdio |
[
{
"content": "You are given an array of n integer numbers. Let sum(l, r) be the sum of all numbers on positions from l to r non-inclusive (l-th element is counted, r-th element is not counted). For indices l and r holds 0 β€ l β€ r β€ n. Indices in array are numbered from 0. \n\nFor example, if a = [ - 5, 3, 9, 4]... | [{"input": "100\n2 1 -2 -1 -2 0 -1 -2 1 2 0 1 0 -2 -1 -2 0 2 0 1 -2 -2 2 0 -2 2 -2 0 2 -1 2 0 -1 0 -2 2 -1 -1 -2 -1 0 -2 2 0 -2 -2 -2 -1 1 0 -2 -1 2 -1 -4 0 -1 1 1 2 -2 1 -2 1 2 2 -2 1 -2 0 -1 -1 -2 -2 1 0 -1 -1 2 0 2 0 -1 2 1 -1 2 0 2 1 1 1 -1 -1 1 -2 0 0 -2 0\n", "output": "2 78 92\n"}, {"input": "100\n2 1 -2 -1 -2 0... | code_stdio |
[
{
"content": "Valera has got n domino pieces in a row. Each piece consists of two halves β the upper one and the lower one. Each of the halves contains a number from 1 to 6. Valera loves even integers very much, so he wants the sum of the numbers on the upper halves and the sum of the numbers on the lower halve... | [{"input": "100\n2 3\n2 4\n3 3\n1 4\n5 2\n5 4\n6 6\n3 4\n1 1\n4 2\n5 1\n5 5\n5 3\n3 6\n4 1\n1 6\n1 1\n3 2\n4 5\n6 1\n6 4\n1 1\n3 4\n3 3\n2 2\n1 1\n4 4\n6 4\n3 2\n5 2\n6 4\n3 2\n3 5\n4 4\n1 4\n5 2\n3 4\n1 4\n2 2\n5 6\n3 5\n6 1\n5 5\n1 6\n6 3\n1 4\n1 5\n5 5\n4 1\n3 2\n4 1\n5 5\n5 5\n1 5\n1 2\n6 4\n1 3\n3 6\n4 3\n3 5\n6 4... | code_stdio |
[
{
"content": "You are given n rectangles. The corners of rectangles have integer coordinates and their edges are parallel to the Ox and Oy axes. The rectangles may touch each other, but they do not overlap (that is, there are no points that belong to the interior of more than one rectangle). \n\nYour task is to... | [{"input": "5\n20421 5189 23141 12511\n16414 10436 17880 12511\n17880 10436 20421 12511\n15819 10436 16414 12511\n15819 5189 20421 10436\n", "output": "YES\n"}, {"input": "5\n20421 5189 23141 12511\n16414 10436 17880 12511\n17880 10436 20421 12511\n15819 10436 16414 12511\n15819 5189 20421 10436\n", "output": "YES\n"},... | code_stdio |
[
{
"content": "We have N logs of lengths A_1,A_2,\\cdots A_N.\nWe can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0<t<L), it becomes two logs of lengths t and L-t.\nFind the shortest possible length of the longest log after at most... | [{"input": "10 10\n158260522 877914575 602436426 24979445 861648772 623690081 433933447 476190629 262703497 211047202\n", "output": "292638192\n"}, {"input": "10 10\n158260522 877914575 1013896555 24979445 861648772 623690081 433933447 476190629 262703497 374010847", "output": "337965519\n"}, {"input": "10 10\n15826052... | code_stdio |
[
{
"content": "Given an array of $n$ positive integers $a_1, a_2, \\dots, a_n$ ($1 \\le a_i \\le 1000$). Find the maximum value of $i + j$ such that $a_i$ and $a_j$ are coprime,$^{\\dagger}$ or $-1$ if no such $i$, $j$ exist.\n\nFor example consider the array $[1, 3, 5, 2, 4, 7, 7]$. The maximum value of $i + j$... | [{"input": "9\n19\n146 637 288 867 647 705 297 414 541 951 238 806 73 916 781 371 937 343 985\n6\n289 797 286 446 650 296\n15\n670 558 11 473 388 270 231 981 580 180 834 882 212 233 547\n16\n461 336 815 510 720 169 999 580 367 47 992 786 671 522 25 24\n8\n732 710 651 518 287 789 347 14\n4\n697 206 722 759\n20\n241 854 ... | code_stdio |
[
{
"content": "We have a grid with N rows and M columns of squares. Initially, all the squares are white.\n\nThere is a button attached to each row and each column. When a button attached to a row is pressed, the colors of all the squares in that row are inverted; that is, white squares become black and vice ver... | [{"input": "1 13 1", "output": "Yes\n"}, {"input": "1 13 0", "output": "Yes\n"}, {"input": "7 17 0", "output": "Yes\n"}, {"input": "1 20 0", "output": "Yes\n"}, {"input": "1 21 3", "output": "Yes\n"}, {"input": "1 30 0", "output": "Yes\n"}, {"input": "1 34 8", "output": "Yes\n"}, {"input": "4 2 2", "output": "Yes\n"}, ... | code_stdio |
[
{
"content": "You are given n points on a plane. All points are different.\n\nFind the number of different groups of three points (A, B, C) such that point B is the middle of segment AC. \n\nThe groups of three points are considered unordered, that is, if point B is the middle of segment AC, then groups (A, B, ... | [{"input": "40\n-8 24\n2 -1\n1 -18\n72 -70\n5 -4\n-308 436\n-19 40\n36 -35\n-178 265\n-1 2\n-7 30\n-1 0\n3 -2\n200 -285\n17 -16\n-35 74\n0 -4\n-86 106\n-1 4\n-7 6\n0 1\n-5 4\n-2 3\n6 -5\n-4 5\n181 -262\n76 -118\n0 0\n-7 18\n-58 104\n-5 6\n-6 12\n-3 4\n1 0\n11 -10\n-86 130\n-3 6\n153 -236\n-183 270\n-33 64\n", "output":... | code_stdio |
[
{
"content": "<image>\n\n\nYou know the merry-go-round in the amusement park. Vehicles such as horses and carriages are fixed on a large disk, and it is a standard playset that the vehicle swings up and down at the same time as the disk rotates. A merry-go-round in an amusement park has two four-seater carriage... | [{"input": "0 3 1 1 0 -1 -1 2\n1 1 5 3 -1 3 0 -1", "output": "1 4 1 2 1 2 1 4\n1 2 1 4 1 4 1 2\n"}, {"input": "0 2 0 1 0 -1 -1 2\n1 1 5 3 -1 3 0 -1", "output": "1 2 1 2 1 4 1 4\n1 2 1 4 1 4 1 2\n"}, {"input": "0 2 1 1 0 -1 -1 2\n1 1 5 3 -1 0 0 -1", "output": "1 2 1 2 1 4 1 4\n2 1 4 1 4 1 2 1\n"}, {"input": "4 7 2 1 1 -... | code_stdio |
[
{
"content": "You are given positive integer number n. You should create such strictly increasing sequence of k positive numbers a_1, a_2, ..., a_{k}, that their sum is equal to n and greatest common divisor is maximal.\n\nGreatest common divisor of sequence is maximum of such numbers that every element of sequ... | [{"input": "10000000000 5000\n", "output": "640 1280 1920 2560 3200 3840 4480 5120 5760 6400 7040 7680 8320 8960 9600 10240 10880 11520 12160 12800 13440 14080 14720 15360 16000 16640 17280 17920 18560 19200 19840 20480 21120 21760 22400 23040 23680 24320 24960 25600 26240 26880 27520 28160 28800 29440 30080 30720 3136... | code_stdio |
[
{
"content": "Problem\n\nThere are $ N $ streetlights on a two-dimensional square of $ W \\ times H $.\nGaccho wants to start with $ (1,1) $ and go to $ (W, H) $.\nGaccho is afraid of dark places, so he only wants to walk in the squares that are brightened by the streetlights.\nInitially, all streetlights only ... | [{"input": "43 16 2\n4 7\n-1 8\n10 0", "output": "48\n"}, {"input": "19 21 2\n0 3\n-1 11\n1 1", "output": "30\n"}, {"input": "12 31 1\n5 2\n-1 1\n14 0", "output": "36\n"}, {"input": "34 50 1\n9 1\n0 1\n-2 -1", "output": "74\n"}, {"input": "12 16 1\n5 9\n-1 5\n5 0", "output": "14\n"}, {"input": "12 31 1\n5 9\n-1 5\n7 0"... | code_stdio |
[
{
"content": "We have a square grid with N rows and M columns. Takahashi will write an integer in each of the squares, as follows:\n\n* First, write 0 in every square.\n* For each i=1,2,...,N, choose an integer k_i (0\\leq k_i\\leq M), and add 1 to each of the leftmost k_i squares in the i-th row.\n* For each j... | [{"input": "314159 217986", "output": "153191328\n"}, {"input": "180944 374453", "output": "571894029\n"}, {"input": "180944 102049", "output": "764553516\n"}, {"input": "180944 191217", "output": "826993365\n"}, {"input": "180944 138776", "output": "166821642\n"}, {"input": "180944 221497", "output": "413854937\n"}, {... | code_stdio |
[
{
"content": "The sequence of integers $a_1, a_2, \\dots, a_k$ is called a good array if $a_1 = k - 1$ and $a_1 > 0$. For example, the sequences $[3, -1, 44, 0], [1, -99]$ are good arrays, and the sequences $[3, 7, 8], [2, 5, 4, 1], [0]$ β are not.\n\nA sequence of integers is called good if it can be divided i... | [{"input": "4\n-2 0 4 -1\n", "output": "0\n"}, {"input": "4\n-2 0 1 -1\n", "output": "1\n"}, {"input": "4\n-2 1 5 0\n", "output": "2\n"}, {"input": "4\n-1 0 4 1\n", "output": "0\n"}, {"input": "4\n-2 0 4 1\n", "output": "0\n"}, {"input": "4\n-2 0 4 0\n", "output": "0\n"}, {"input": "4\n-2 0 5 0\n", "output": "0\n"}, {"... | code_stdio |
[
{
"content": "Mahmoud and Ehab continue their adventures! As everybody in the evil land knows, Dr. Evil likes bipartite graphs, especially trees.\n\nA tree is a connected acyclic graph. A bipartite graph is a graph, whose vertices can be partitioned into 2 sets in such a way, that for each edge (u, v) that belo... | [{"input": "10\n7 6\n2 10\n7 1\n8 5\n9 3\n2 3\n8 7\n10 8\n10 4\n", "output": "15\n"}, {"input": "10\n7 6\n2 7\n4 1\n8 5\n9 4\n5 3\n8 7\n10 8\n10 4\n", "output": "16\n"}, {"input": "10\n2 6\n3 7\n8 4\n4 10\n6 9\n9 7\n3 10\n1 2\n5 8\n", "output": "16\n"}, {"input": "10\n7 6\n2 7\n4 1\n8 5\n9 4\n5 3\n8 7\n10 8\n10 4\n", "... | code_stdio |
[
{
"content": "A: A-Z Cat / A-Z Cat\n\nstory\n\nAizunyan is a second-year student who belongs to the programming contest club of Wakagamatsu High School, commonly known as the Prokon club. It's so cute. Aizu Nyan was asked by her friend Joy to take care of her cat. It is a rare cat called A-Z cat. Aizunyan named... | [{"input": "AOZUNYANPERIPERO", "output": "AZ\n"}, {"input": "OREQIRMQEAYNUYOA", "output": "-1\n"}, {"input": "OREPIREPNAYNUZOA", "output": "AZ\n"}, {"input": "OREPIRNPEAYNUZOA", "output": "AZ\n"}, {"input": "OREQIRNPEAYNUZOA", "output": "AZ\n"}, {"input": "OREQIRMPEAYNUZOA", "output": "AZ\n"}, {"input": "AOZUNYAEPMRIQE... | code_stdio |
[
{
"content": "Recently a dog was bought for Polycarp. The dog's name is Cormen. Now Polycarp has a lot of troubles. For example, Cormen likes going for a walk. \n\nEmpirically Polycarp learned that the dog needs at least k walks for any two consecutive days in order to feel good. For example, if k = 5 and yeste... | [{"input": "100 500\n64 140 15 221 24 106 73 30 275 97 296 55 5 30 47 199 130 44 72 170 7 204 359 40 128 117 45 192 344 112 0 11 196 78 73 53 222 93 88 151 99 283 60 71 4 87 226 46 66 74 23 89 77 60 397 181 0 101 358 54 124 155 19 218 9 140 161 130 308 85 103 85 300 128 19 108 225 136 100 54 30 24 129 245 128 88 160 12... | code_stdio |
[
{
"content": "There are N participants in the CODE FESTIVAL 2016 Qualification contests. The participants are either students in Japan, students from overseas, or neither of these.\n\nOnly Japanese students or overseas students can pass the Qualification contests. The students pass when they satisfy the conditi... | [{"input": "12 14 3\ncaababaccaba", "output": "No\nYes\nYes\nYes\nYes\nYes\nYes\nNo\nNo\nYes\nYes\nYes\n"}, {"input": "12 14 3\nabaccababaac", "output": "Yes\nYes\nYes\nNo\nNo\nYes\nYes\nYes\nYes\nYes\nYes\nNo\n"}, {"input": "12 16 2\ncabbabaacaaa", "output": "No\nYes\nYes\nYes\nYes\nNo\nYes\nYes\nNo\nYes\nYes\nYes\n"}... | code_stdio |
[
{
"content": "Let's call a positive integer $n$ ordinary if in the decimal notation all its digits are the same. For example, $1$, $2$ and $99$ are ordinary numbers, but $719$ and $2021$ are not ordinary numbers.\n\nFor a given number $n$, find the number of ordinary numbers among the numbers from $1$ to $n$.\n... | [{"input": "6\n2\n2\n3\n8\n10\n100\n", "output": "2\n2\n3\n8\n9\n18\n"}, {"input": "6\n2\n2\n3\n4\n10\n100\n", "output": "2\n2\n3\n4\n9\n18\n"}, {"input": "6\n1\n2\n3\n4\n5\n100\n", "output": "\n1\n2\n3\n4\n5\n18\n"}, {"input": "6\n1\n2\n3\n4\n5\n100\n", "output": "1\n2\n3\n4\n5\n18\n"}, {"input": "6\n1\n2\n3\n4\n8\n10... | code_stdio |
[
{
"content": "Appleman and Toastman play a game. Initially Appleman gives one group of n numbers to the Toastman, then they start to complete the following tasks:\n\n * Each time Toastman gets a group of numbers, he sums up all the numbers and adds this sum to the score. Then he gives the group to the Appleman... | [{"input": "10\n1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000\n", "output": "64000000\n"}, {"input": "10\n171308 397870 724672 431255 228496 892002 542924 718337 888642 161821\n", "output": "40204082\n"}, {"input": "10\n888642 724672 724672 431255 431255 397870 397870 397870 397870 228... | code_stdio |
[
{
"content": "Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.\n\nIn the given sequence moving up is described by character U and moving right is described by character R... | [{"input": "100\nUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU\n", "output": "100\n"}, {"input": "100\nUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU\n", "output": "100\n"}, {"input": "100\nRRURRUUUURURRRURRRRUR... | code_stdio |
[
{
"content": "Consider the set of all nonnegative integers: ${0, 1, 2, \\dots}$. Given two integers $a$ and $b$ ($1 \\le a, b \\le 10^4$). We paint all the numbers in increasing number first we paint $0$, then we paint $1$, then $2$ and so on.\n\nEach number is painted white or black. We paint a number $i$ acco... | [{"input": "4\n10 10\n1 10\n6 9\n7 3\n", "output": "Infinite\nFinite\nInfinite\nFinite\n"}, {"input": "4\n10 10\n1 10\n3 9\n7 3\n", "output": "Infinite\nFinite\nInfinite\nFinite\n"}, {"input": "4\n10 10\n1 10\n6 9\n7 3\n", "output": "Infinite\nFinite\nInfinite\nFinite\n"}, {"input": "4\n10 8\n1 10\n6 9\n7 3\n", "output... | code_stdio |
[
{
"content": "Takahashi bought a piece of apple pie at ABC Confiserie. According to his memory, he paid N yen (the currency of Japan) for it.\n\nThe consumption tax rate for foods in this shop is 8 percent. That is, to buy an apple pie priced at X yen before tax, you have to pay X \\times 1.08 yen (rounded down... | [{"input": "1101", "output": "1020\n"}, {"input": "1111", "output": "1029\n"}, {"input": "1100", "output": "1019\n"}, {"input": "1011", "output": "937\n"}, {"input": "239", "output": "222\n"}, {"input": "442", "output": "410\n"}, {"input": "452", "output": "419\n"}, {"input": "192", "output": "178\n"}, {"input": "322",... | code_stdio |
[
{
"content": "problem\n\nGiven the squares of $ R * C $. Each square is either an empty square or a square with a hole. The given square meets the following conditions.\n\n* The cells with holes are connected. (You can move a square with a hole in the cross direction to any square with a hole)\n* Empty cells ar... | [{"input": "3 5\n.....\n.#.#.\n.###.\n.#.#.\n.....", "output": "3\n"}, {"input": "3 1\n.....\n.#.#.\n.###.\n.#.#.\n.....", "output": "0\n"}, {"input": "2 5\n.....\n.#.#.\n.###.\n.#.#.\n.....", "output": "2\n"}, {"input": "4 2\n.....\n.#.#/\n.###.\n.#.#.\n.....", "output": "1\n"}, {"input": "0 1\n.....\n.#.#.\n.###.\n.#... | code_stdio |
[
{
"content": "There are n cities in the country where the Old Peykan lives. These cities are located on a straight line, we'll denote them from left to right as c_1, c_2, ..., c_{n}. The Old Peykan wants to travel from city c_1 to c_{n} using roads. There are (n - 1) one way roads, the i-th road goes from city ... | [{"input": "100 6\n15 20 32 8 29 10 33 15 9 26 28 21 34 7 41 23 9 17 16 15 14 29 25 31 24 26 13 18 19 40 9 16 36 32 39 11 4 31 37 28 32 40 7 18 45 21 15 45 6 15 27 22 27 41 28 7 22 43 25 40 6 7 32 31 36 14 5 27 31 28 23 9 13 14 7 25 28 33 40 22 44 9 29 26 41 30 16 15 31 42 13 40 36 44 17 29 32 29 38 13\n4 4 3 4 3 4 3 3... | code_stdio |
[
{
"content": "There is a very secret base in Potatoland where potato mash is made according to a special recipe. The neighbours from Porridgia decided to seize this recipe and to sell it to Pilauland. For this mission they have been preparing special agent Pearlo for many years. When, finally, Pearlo learned al... | [{"input": "...\nX.X\n...\n", "output": "YES\n"}, {"input": "X.X\n.X.\nX.X\n", "output": "YES\n"}, {"input": "...\nXXX\n...\n", "output": "YES\n"}, {"input": "X..\n.X.\n..X\n", "output": "YES\n"}, {"input": "XXX\nX.X\nXXX\n", "output": "YES\n"}, {"input": "...\n.X.\n...\n", "output": "YES\n"}, {"input": "XXX\n.X.\nXXX\... | code_stdio |
[
{
"content": "Niwango has N cards, numbered 1,2,\\ldots,N. He will now arrange these cards in a row.\n\nNiwango wants to know if there is a way to arrange the cards while satisfying all the N conditions below. To help him, determine whether such a way exists. If the answer is yes, also find the lexicographicall... | [{"input": "13\n4 3 4 0 12 4 11 5 4 11 13 13 12", "output": "1 2 4 3 5 6 7 8 9 10 13 11 12\n"}, {"input": "13\n4 3 2 0 12 4 8 10 4 11 13 13 12", "output": "1 2 4 3 5 6 7 9 8 11 12 10 13\n"}, {"input": "13\n2 3 2 0 12 4 8 10 4 11 13 13 12", "output": "1 3 4 2 5 6 7 9 8 11 12 10 13\n"}, {"input": "13\n4 3 4 0 12 3 11 5 4... | code_stdio |
[
{
"content": "Given are two sequences a=\\{a_0,\\ldots,a_{N-1}\\} and b=\\{b_0,\\ldots,b_{N-1}\\} of N non-negative integers each.\nSnuke will choose an integer k such that 0 \\leq k < N and an integer x not less than 0, to make a new sequence of length N, a'=\\{a_0',\\ldots,a_{N-1}'\\}, as follows:\n - a_i'= a... | [{"input": "5\n0 0 0 0 0\n2 2 2 2 2\n", "output": "0 2\n1 2\n2 2\n3 2\n4 2\n"}, {"input": "5\n0 0 0 0 0\n2 2 2 2 2", "output": "0 2\n1 2\n2 2\n3 2\n4 2"}, {"input": "6\n0 1 3 7 6 4\n1 5 4 6 2 3\n", "output": "2 2\n5 5\n"}, {"input": "6\n0 1 3 7 6 4\n1 5 4 6 2 3", "output": "2 2\n5 5"}, {"input": "6\n0 1 2 7 6 4\n1 5 4 ... | code_stdio |
[
{
"content": "Theofanis has a riddle for you and if you manage to solve it, he will give you a Cypriot snack halloumi for free (Cypriot cheese).\n\nYou are given an integer $n$. You need to find two integers $l$ and $r$ such that $-10^{18} \\le l < r \\le 10^{18}$ and $l + (l + 1) + \\ldots + (r - 1) + r = n$.\... | [{"input": "7\n1\n3\n20\n2\n110\n23\n4838829180358\n", "output": "0 1\n-2 3\n-19 20\n-1 2\n-109 110\n-22 23\n-4838829180357 4838829180358\n"}, {"input": "7\n1\n2\n12\n2\n101\n56\n3000000000000\n", "output": "0 1\n-1 2\n-11 12\n-1 2\n-100 101\n-55 56\n-2999999999999 3000000000000\n"}, {"input": "7\n1\n3\n32\n2\n110\n23\... | code_stdio |
[
{
"content": "Example\n\nInput\n\n4\nDurett 7\nGayles 3\nFacenda 6\nDaughtery 0\n1\n+ Mccourtney 2\n\n\nOutput\n\nMccourtney is not working now.\nDurett is working hard now.\n\nWrite Python code to solve this problem. Your program should read the input from stdin and write the output to stdout. Enclose your com... | [{"input": "4\nDurett 10\nGayles 4\nF`cenda 10\nyrethguaD 0\n1\n+ Mccourtney 1", "output": "Mccourtney is not working now.\nF`cenda is working hard now.\n"}, {"input": "4\nDurett 10\nGaxles 4\nFacenda 10\nyrethguaD 0\n1\n+ yentruoccM 2", "output": "yentruoccM is not working now.\nFacenda is working hard now.\n"}, {"inp... | code_stdio |
[
{
"content": "Petya has noticed that when he types using a keyboard, he often presses extra buttons and adds extra letters to the words. Of course, the spell-checking system underlines the words for him and he has to click every word and choose the right variant. Petya got fed up with correcting his mistakes hi... | [{"input": "qybldcgfhdhhhhhhhhhhopqkhuczzytzluiahwbqjltgafvvoecititchjwdoljiehubngmtjckqymldhoncgtqhxnqvoagnrmur\nqybldcgfhdhhhhhhhhhopqkhuczzytzluiahwbqjltgafvvoecititchjwdoljiehubngmtjckqymldhoncgtqhxnqvoagnrmur\n", "output": "10\n11 12 13 14 15 16 17 18 19 20 "}, {"input": "aaaaaaaaaaa\naaaaaaaaaa\n", "output": "11\... | code_stdio |
[
{
"content": "Ujan has a lot of useless stuff in his drawers, a considerable part of which are his math notebooks: it is time to sort them out. This time he found an old dusty graph theory notebook with a description of a graph.\n\nIt is an undirected weighted graph on n vertices. It is a complete graph: each p... | [{"input": "15 10\n2 3\n5 4\n5 12\n5 7\n3 8\n3 10\n11 12\n12 13\n13 14\n14 15\n", "output": "0\n"}, {"input": "15 10\n2 3\n6 4\n5 12\n5 7\n3 8\n3 10\n11 12\n12 13\n13 14\n14 15\n", "output": "0\n"}, {"input": "15 10\n2 3\n5 8\n5 6\n5 7\n3 8\n3 10\n11 12\n12 13\n13 14\n14 15\n", "output": "0\n"}, {"input": "15 10\n2 3\n... | code_stdio |
[
{
"content": "Once Bob needed to find the second order statistics of a sequence of integer numbers. Lets choose each number from the sequence exactly once and sort them. The value on the second position is the second order statistics of the given sequence. In other words it is the smallest element strictly grea... | [{"input": "99\n10 -84 -100 -100 73 -64 -100 -94 33 -100 -100 -100 -100 71 64 24 7 -100 -32 -100 -100 77 -100 62 -12 55 45 -100 -100 -80 -100 -100 -100 -100 -100 -100 -100 -100 -100 -39 -48 -100 -34 47 -100 -100 -100 -100 -100 -77 -100 -100 -100 -100 -100 -100 -52 40 -55 -100 -44 -100 72 33 70 -100 -100 -78 -100 -3 100... | code_stdio |
[
{
"content": "You are given two arrays $a$ and $b$, both of length $n$.\n\nYou can perform the following operation any number of times (possibly zero): select an index $i$ ($1 \\leq i \\leq n$) and swap $a_i$ and $b_i$.\n\nLet's define the cost of the array $a$ as $\\sum_{i=1}^{n} \\sum_{j=i + 1}^{n} (a_i + a_j... | [{"input": "1\n100\n77 18 18 20 58 11 45 18 21 15 44 87 77 65 94 83 68 73 43 84 75 100 66 39 63 44 60 16 100 4 83 53 37 11 95 71 38 57 66 31 40 60 36 37 92 79 30 55 46 25 54 45 85 38 29 82 60 11 11 69 30 1 53 100 62 61 17 75 99 9 31 8 100 53 57 8 11 26 95 72 50 77 90 88 80 84 53 50 23 3 78 27 76 82 4 7 36 13 63 100\n1 ... | code_stdio |
[
{
"content": "BerOilGasDiamondBank has branches in n cities, at that n is an even number. The bank management wants to publish a calendar with the names of all those cities written in two columns: the calendar should consist of exactly n / 2 lines of strictly equal length, each of which contains exactly two nam... | [{"input": "58\nesgdfmf\nxfkluadj\nqhvh\njwhuyhm\nmgi\nysgc\nvhhenku\npb\ntr\nu\njyrpjnpd\nkluadjo\nopb\ncopb\ngcyhceo\nr\ndjo\nxfklu\neo\nadjo\nfkluadjo\nybe\nwljwh\nqhvhh\nrhgotp\nyhceo\nuyhm\nvdd\nyhm\nysgcyhc\nvddrhg\nril\nwljwhu\nx\nqh\nhceo\ntfcopb\nmgitfc\nvddrh\nmgitfco\nxf\nmgitf\ncyoybe\notp\no\nljwhuyhm\nysg... | code_stdio |
[
{
"content": "The only difference between easy and hard versions are constraints on $n$ and $k$.\n\nYou are messaging in one of the popular social networks via your smartphone. Your smartphone can show at most $k$ most recent conversations with your friends. Initially, the screen is empty (i.e. the number of di... | [{"input": "10 4\n2 3 3 1 1 4 1 2 3 3\n", "output": "4\n4 1 3 2\n"}, {"input": "10 4\n2 3 3 1 1 2 1 2 5 3\n", "output": "4\n5 1 3 2\n"}, {"input": "10 4\n2 3 3 2 1 4 1 2 3 3\n", "output": "4\n4 1 3 2\n"}, {"input": "10 4\n2 3 3 1 1 3 1 4 3 3\n", "output": "4\n4 1 3 2\n"}, {"input": "10 4\n2 3 3 2 2 3 1 4 3 3\n", "outpu... | code_stdio |
[
{
"content": "Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom.\n\nA bar of chocolate can be presented as an n Γ n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to... | [{"input": "20 10\n10 11 U\n12 9 U\n6 15 L\n17 4 U\n11 10 L\n7 14 L\n4 17 U\n2 19 L\n8 13 L\n14 7 U\n", "output": "11\n9\n6\n4\n1\n7\n2\n2\n8\n7\n"}, {"input": "20 10\n10 11 U\n12 9 U\n6 15 L\n17 4 U\n11 10 L\n7 14 L\n4 17 U\n2 19 L\n8 13 L\n14 7 U\n", "output": "11\n9\n6\n4\n1\n7\n2\n2\n8\n7\n"}, {"input": "10 10\n5 6... | code_stdio |
[
{
"content": "An extension of a complex number is called a quaternion. It is a convenient number that can be used to control the arm of a robot because it is convenient for expressing the rotation of an object. Quaternions are $ using four real numbers $ x $, $ y $, $ z $, $ w $ and special numbers (extended im... | [{"input": "2\n2 0 2 1 89 0 26 7\n13 11 25 8 -1 3 0 -2\n0", "output": "119 -12 230 103\n-30 -22 21 -109\n"}, {"input": "2\n2 0 2 5 89 0 26 4\n7 11 25 8 -1 3 0 -2\n0", "output": "106 -122 230 453\n-24 -40 21 -97\n"}, {"input": "2\n2 0 2 5 89 0 26 4\n7 11 25 8 -1 3 1 -2\n0", "output": "106 -122 230 453\n-49 -48 28 -86\n"... | code_stdio |
[
{
"content": "Vasya has recently finished writing a book. Now he faces the problem of giving it the title. Vasya wants the title to be vague and mysterious for his book to be noticeable among others. That's why the title should be represented by a single word containing at least once each of the first k Latin l... | [{"input": "26\nabcdefghijklmnopqrstuvwxyzfgvnsltvvohywvqhuhtydghtthgdythuhqvwyhovvtlsnvgfzyxwvutsrqponmlkjihgfedcba\n", "output": "abcdefghijklmnopqrstuvwxyzfgvnsltvvohywvqhuhtydghtthgdythuhqvwyhovvtlsnvgfzyxwvutsrqponmlkjihgfedcba\n"}, {"input": "26\nab?defg??j??mnopqrs?uv?x???u?vpd??s?s??s?t?v?vp?is?iqp??v??ush?s??a... | code_stdio |
[
{
"content": "There are N squares arranged in a row, numbered 1 to N from left to right. Takahashi will stack building blocks on these squares, on which there are no blocks yet.\n\nHe wants to stack blocks on the squares evenly, so he will repeat the following operation until there are H blocks on every square:... | [{"input": "118261 6796 8504", "output": "331359071\n"}, {"input": "118261 3351 8683", "output": "422737594\n"}, {"input": "194739 3351 8683", "output": "984464655\n"}, {"input": "31415 14324 4472", "output": "527193753\n"}, {"input": "197694 6796 8504", "output": "116621440\n"}, {"input": "118261 6796 4795", "output":... | code_stdio |
[
{
"content": "This contest is `CODEFESTIVAL`, which can be shortened to the string `CF` by deleting some characters.\n\nMr. Takahashi, full of curiosity, wondered if he could obtain `CF` from other strings in the same way.\n\nYou are given a string s consisting of uppercase English letters. Determine whether th... | [{"input": "CODDFESTIVAL", "output": "Yes\n"}, {"input": "EDOCLAVFTSEI", "output": "Yes\n"}, {"input": "ECOFLAVDTSEI", "output": "Yes\n"}, {"input": "DOECSDKSIVAF", "output": "Yes\n"}, {"input": "DOECRDKSIVAF", "output": "Yes\n"}, {"input": "DOFCRDKSIVAF", "output": "Yes\n"}, {"input": "DOFCQDKSIVAF", "output": "Yes\n"... | code_stdio |
[
{
"content": "You 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 positive integer from 1 to n, such that equality holds.\n\nInput\n\nThe only line ... | [{"input": "? + ? + ? - ? + ? - ? - ? - ? - ? - ? + ? - ? + ? + ? - ? + ? - ? + ? + ? - ? + ? - ? + ? + ? + ? - ? - ? - ? + ? - ? - ? + ? - ? - ? + ? - ? + ? + ? - ? + ? - ? - ? + ? + ? - ? - ? - ? + ? - ? - ? - ? + ? - ? - ? - ? + ? - ? - ? - ? - ? - ? - ? - ? + ? - ? - ? - ? - ? - ? - ? - ? - ? + ? - ? + ? - ? - ? + ... | code_stdio |
[
{
"content": "Vasilisa the Wise from a far away kingdom got a present from her friend Helga the Wise from a farther away kingdom. The present is a surprise box, yet Vasilisa the Wise doesn't know yet what the surprise actually is because she cannot open the box. She hopes that you can help her in that.\n\nThe b... | [{"input": "BYOVRR\n", "output": "15\n"}, {"input": "OVBRYG\n", "output": "30\n"}, {"input": "RRYOGB\n", "output": "15\n"}, {"input": "VOBYGO\n", "output": "15\n"}, {"input": "GRBYVO\n", "output": "30\n"}, {"input": "YROVBG\n", "output": "30\n"}, {"input": "GYYBRO\n", "output": "15\n"}, {"input": "RYGOBG\n", "output": ... | code_stdio |
[
{
"content": "Example\n\nInput\n\n3\n0 2 7\n2 0 4\n5 8 0\n\n\nOutput\n\n11\n\nWrite Python code to solve this problem. Your program should read the input from stdin and write the output to stdout. Enclose your complete solution in a single ```python code block.",
"role": "user"
}
] | [{"input": "3\n0 3 10\n1 0 4\n19 11 0", "output": "15\n"}, {"input": "3\n0 6 13\n4 0 3\n24 12 0", "output": "20\n"}, {"input": "3\n0 12 13\n6 0 6\n27 8 0", "output": "25\n"}, {"input": "3\n0 12 18\n6 0 6\n27 8 0", "output": "30\n"}, {"input": "3\n0 3 10\n4 0 4\n19 11 0", "output": "17\n"}, {"input": "3\n0 3 10\n7 0 4\n... | code_stdio |
[
{
"content": "You are given a string S of length 2N consisting of lowercase English letters.\n\nThere are 2^{2N} ways to color each character in S red or blue. Among these ways, how many satisfy the following condition?\n\n* The string obtained by reading the characters painted red from left to right is equal t... | [{"input": "18\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "output": "9075135300"}, {"input": "18\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa`aaaa", "output": "0\n"}, {"input": "18\naaaaaaaaaaaaaaaaaaaaaaabaaaaaaa`aaaa", "output": "0\n"}, {"input": "18\naaaaaaaaaaaaaaaaaaaaaaabbaaaaaa`aaaa", "output": "0\n"}, {"input": "18\naaaa`aaaa... | code_stdio |
[
{
"content": "Today's Random Number\n\nE869120 You ran a campaign called \"Today's Random Numbers\" for N days. This is a project to generate a random number once a day and post the value on Twitter.\n\nThe \"random numbers of the day\" on day $ 1, 2, 3, \\ dots, N $ were $ A_1, A_2, A_3, \\ dots, A_N $, respec... | [{"input": "5\n15 -1 21 0 20", "output": "2\n"}, {"input": "5\n15 -1 21 0 22", "output": "2\n"}, {"input": "5\n-2 -1 -1 14 2", "output": "2\n"}, {"input": "5\n-2 -1 -1 21 2", "output": "2\n"}, {"input": "5\n-2 -1 -2 21 2", "output": "2\n"}, {"input": "5\n-2 -1 -2 35 2", "output": "2\n"}, {"input": "5\n-3 -1 -2 35 2", "... | code_stdio |
[
{
"content": "Currently Tiny is learning Computational Geometry. When trying to solve a problem called \"The Closest Pair Of Points In The Plane\", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.\n\nThe problem is the follows. Given n points in the plane, fin... | [{"input": "3119 2029631\n", "output": "0 0\n0 1\n0 2\n0 3\n0 4\n0 5\n0 6\n0 7\n0 8\n0 9\n0 10\n0 11\n0 12\n0 13\n0 14\n0 15\n0 16\n0 17\n0 18\n0 19\n0 20\n0 21\n0 22\n0 23\n0 24\n0 25\n0 26\n0 27\n0 28\n0 29\n0 30\n0 31\n0 32\n0 33\n0 34\n0 35\n0 36\n0 37\n0 38\n0 39\n0 40\n0 41\n0 42\n0 43\n0 44\n0 45\n0 46\n0 47\n0 ... | code_stdio |
[
{
"content": "Turbulent times are coming, so you decided to buy sugar in advance. There are $n$ shops around that sell sugar: the $i$-th shop sells one pack of sugar for $a_i$ coins, but only one pack to one customer each day. So in order to buy several packs, you need to visit several shops.\n\nAnother problem... | [{"input": "1\n100 37\n29 33 45 64 95 33 45 76 86 5 52 16 27 24 80 5 44 19 96 8 77 67 21 17 22 56 28 3 84 27 39 12 60 35 75 6 68 71 81 5 76 85 73 54 8 4 58 4 22 5 11 51 72 31 67 93 38 94 96 22 73 34 33 84 21 60 89 88 30 21 44 57 5 16 11 65 20 68 68 41 25 78 43 96 61 10 40 98 55 35 19 79 21 4 62 41 63 2 80 44\n", "outpu... | code_stdio |
[
{
"content": "You can not just take the file and send it. When Polycarp trying to send a file in the social network \"Codehorses\", he encountered an unexpected problem. If the name of the file contains three or more \"x\" (lowercase Latin letters \"x\") in a row, the system considers that the file content does... | [{"input": "100\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n", "output": "98\n"}, {"input": "100\nuxxxxxlmexxxxxxxwnxxexxxxxcxxfydxxxxxxvmdxxxxxxisxxxxxxxxidkxxxpxxxxxxxxmnuxxxxjxxxqcxxwmxxxxxxxxmrx\n", "output": "41\n"}, {"input": "100\nxxxxxxxxxxxjtxxxxxxxxcx... | code_stdio |
[
{
"content": "Recently a Golden Circle of Beetlovers was found in Byteland. It is a circle route going through $n \\cdot k$ cities. The cities are numerated from $1$ to $n \\cdot k$, the distance between the neighboring cities is exactly $1$ km.\n\nSergey does not like beetles, he loves burgers. Fortunately for... | [{"input": "100000 100000\n50000 6424\n", "output": "1250000000 1250000000\n"}, {"input": "100000 101000\n50000 6424\n", "output": "39453125 1262500000\n"}, {"input": "98752 97209\n41218 39020\n", "output": "21427641 3199861056\n"}, {"input": "98752 97209\n41218 39020\n", "output": "21427641 3199861056\n"}, {"input": "... | code_stdio |
[
{
"content": "Sereja has an n Γ m rectangular table a, each cell of the table contains a zero or a number one. Sereja wants his table to meet the following requirement: each connected component of the same values forms a rectangle with sides parallel to the sides of the table. Rectangles should be filled with c... | [{"input": "21 10 8\n1 1 1 0 0 1 1 1 1 1\n1 1 1 0 0 1 1 1 1 1\n1 1 1 0 0 1 1 1 1 1\n1 1 1 0 0 1 1 1 1 1\n1 1 1 0 0 1 1 1 1 1\n0 0 1 1 1 0 0 0 0 0\n0 0 0 1 1 0 0 0 0 0\n1 1 1 0 0 1 1 1 1 1\n0 0 0 1 1 0 0 0 0 0\n1 1 1 0 0 1 1 1 1 1\n1 1 1 0 0 1 1 1 1 1\n0 0 0 1 1 0 0 0 0 0\n1 0 1 0 0 1 1 1 1 1\n0 1 0 1 1 0 0 0 0 0\n0 0 0... | code_stdio |
[
{
"content": "You are given an array a consisting of n integers. We denote the subarray a[l..r] as the array [a_l, a_{l + 1}, ..., a_r] (1 β€ l β€ r β€ n).\n\nA subarray is considered good if every integer that occurs in this subarray occurs there exactly thrice. For example, the array [1, 2, 2, 2, 1, 1, 2, 2, 2] ... | [{"input": "100\n79 79 79 97 97 97 64 64 64 2 2 2 38 38 38 65 65 65 10 10 10 25 24 25 53 53 53 73 73 73 11 11 11 29 29 29 93 93 93 73 73 73 89 89 89 72 72 72 49 49 49 78 78 78 92 92 92 90 90 90 95 95 95 92 92 92 12 12 12 65 65 65 81 81 81 5 5 5 21 21 21 94 94 94 51 51 51 44 44 44 55 55 55 47 47 47 24 24 24 79\n", "outp... | code_stdio |
[
{
"content": "After Fox Ciel won an onsite round of a programming contest, she took a bus to return to her castle. The fee of the bus was 220 yen. She met Rabbit Hanako in the bus. They decided to play the following game because they got bored in the bus.\n\n * Initially, there is a pile that contains x 100-ye... | [{"input": "1481100 701689\n", "output": "Hanako\n"}, {"input": "1616877 635412\n", "output": "Hanako\n"}, {"input": "232743 679597\n", "output": "Hanako\n"}, {"input": "1000000 1000001\n", "output": "Ciel\n"}, {"input": "497151 208819\n", "output": "Hanako\n"}, {"input": "552196 895657\n", "output": "Hanako\n"}, {"inp... | code_stdio |
[
{
"content": "On Bertown's main street n trees are growing, the tree number i has the height of ai meters (1 β€ i β€ n). By the arrival of the President of Berland these trees were decided to be changed so that their heights formed a beautiful sequence. This means that the heights of trees on ends (the 1st one an... | [{"input": "10\n73905 73906 73907 85732 73909 73909 73908 73907 73906 73905\n", "output": "1\n"}, {"input": "10\n60718 99414 65042 65043 65044 38495 95782 65042 65041 65040\n", "output": "4\n"}, {"input": "10\n60718 99414 65042 89001 65044 38495 95782 65042 65041 65040\n", "output": "5\n"}, {"input": "10\n60718 99414 1... | code_stdio |
[
{
"content": "We start with a string s consisting only of the digits 1, 2, or 3. The length of s is denoted by |s|. For each i from 1 to |s|, the i-th character of s is denoted by s_i. \n\nThere is one cursor. The cursor's location β is denoted by an integer in \\{0, β¦, |s|\\}, with the following meaning: \n\n ... | [{"input": "9\n1500\n1212\n1500\n1221\n1500\n122\n1500\n12121\n1500\n22\n1500\n1111112111111112\n1500\n1111111111221111111\n1500\n111111122\n1500\n11111121111121111111\n", "output": "1504\n1599\n1502\n1598\n1502\n1510\n1657\n1502\n1763\n"}, {"input": "9\n1676\n1212\n1500\n1221\n1500\n122\n1500\n12121\n1500\n22\n1500\n1... | code_stdio |
[
{
"content": "In this task Anna and Maria play the following game. Initially they have a checkered piece of paper with a painted n Γ m rectangle (only the border, no filling). Anna and Maria move in turns and Anna starts. During each move one should paint inside the last-painted rectangle a new lesser rectangle... | [{"input": "1000 1000 250\n", "output": "263321201\n"}, {"input": "580 1000 203\n", "output": "693824000\n"}, {"input": "1000 1000 20\n", "output": "155086097\n"}, {"input": "1000 1000 100\n", "output": "58573582\n"}, {"input": "1000 1000 39\n", "output": "227950512\n"}, {"input": "840 474 207\n", "output": "895622621\... | code_stdio |
[
{
"content": "For an integer n not less than 0, let us define f(n) as follows:\n - f(n) = 1 (if n < 2)\n - f(n) = n f(n-2) (if n \\geq 2)\nGiven is an integer N. Find the number of trailing zeros in the decimal notation of f(N).\n\n-----Constraints-----\n - 0 \\leq N \\leq 10^{18}\n\n-----Input-----\nInput is g... | [{"input": "1000000000000000000\n", "output": "124999999999999995\n"}, {"input": "999003990299500294\n", "output": "124875498787437525\n"}, {"input": "1000000000010000000", "output": "125000000001249993\n"}, {"input": "1000000000010001000", "output": "125000000001250117\n"}, {"input": "1010000000010001000", "output": "... | code_stdio |
[
{
"content": "Matrix of given integers\n\n\na1,1 a1,2 ... a1, n\na2,1 a2,2 ... a2, n\n::\nan, 1 an, 2 ... an, n\n\n\nThen, create a program that outputs the maximum value of the sum of one or more consecutive terms (submatrix) in the vertical and horizontal directions and ends.\n\n\n\nInput\n\nThe input data is... | [{"input": "4\n1 3 -9 2\n2 7 -1 5\n-8 3 2 -1\n5 -1 -3 1", "output": "15\n"}, {"input": "4\n1 3 -9 0\n2 7 -1 5\n-8 3 2 -2\n3 -1 -3 1", "output": "14\n"}, {"input": "4\n1 3 -9 2\n2 4 -1 5\n-8 3 2 -1\n5 -1 -6 1", "output": "12\n"}, {"input": "4\n1 3 -9 2\n2 4 -1 5\n-8 3 0 -1\n5 -1 -6 1", "output": "10\n"}, {"input": "4\n1... | code_stdio |
[
{
"content": "One day, Yuhao came across a problem about checking if some bracket sequences are correct bracket sequences.\n\nA bracket sequence is any non-empty sequence of opening and closing parentheses. A bracket sequence is called a correct bracket sequence if it's possible to obtain a correct arithmetic e... | [{"input": "30\n)(((())()())()(\n))(()()()(\n))()((\n)())(()\n())())((\n((((())\n(((()))(\n(())\n)()(((()(()\n((())))(\n)()()())((\n))))(()\n()(((()\n)()()(\n(())())\n(()()(())(\n)()((\n)(()(())))\n))))(())((\n)()(()(((((\n(()))((\n()())\n((()()()))\n()((((((((()\n)(()(\n)(((())(()\n)((((()(\n(((()()((\n())()(\n)))()()... | code_stdio |
[
{
"content": "Rng has a connected undirected graph with N vertices. Currently, there are M edges in the graph, and the i-th edge connects Vertices A_i and B_i.\n\nRng will add new edges to the graph by repeating the following operation:\n\n* Operation: Choose u and v (u \\neq v) such that Vertex v can be reache... | [{"input": "16 5\n1 2\n2 3\n3 3\n0 14\n0 6", "output": "115\n"}, {"input": "69 5\n1 2\n3 3\n1 3\n4 4\n5 8", "output": "2341\n"}, {"input": "71 5\n1 2\n3 3\n1 3\n4 4\n5 8", "output": "2480\n"}, {"input": "46 5\n1 2\n3 3\n1 3\n0 4\n5 8", "output": "1030\n"}, {"input": "15 5\n1 2\n2 3\n3 3\n0 5\n4 2", "output": "100\n"}, ... | code_stdio |
[
{
"content": "Alice likes snow a lot! Unfortunately, this year's winter is already over, and she can't expect to have any more of it. Bob has thus bought her a gift β a large snow maker. He plans to make some amount of snow every day. On day i he will make a pile of snow of volume Vi and put it in her garden.\n... | [{"input": "13\n1 1 1 1 1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1 1 1 1 1\n", "output": "1 1 1 1 1 1 1 1 1 1 1 1 1 "}, {"input": "13\n1 1 1 1 1 1 1 1 1 2 1 1 1\n1 1 1 1 1 1 1 1 1 1 1 1 1\n", "output": "1 1 1 1 1 1 1 1 1 1 2 1 1\n"}, {"input": "13\n1 1 1 1 1 1 1 1 1 2 1 2 1\n1 1 1 1 1 1 1 1 1 1 1 1 1\n", "output": "1 1 1 1 1... | code_stdio |
[
{
"content": "Squid loves painting vertices in graphs.\n\nThere is a simple undirected graph consisting of N vertices numbered 1 through N, and M edges. Initially, all the vertices are painted in color 0. The i-th edge bidirectionally connects two vertices a_i and b_i. The length of every edge is 1.\n\nSquid pe... | [{"input": "14 10\n1 4\n9 12\n7 11\n2 10\n14 7\n14 3\n6 14\n8 14\n5 13\n8 1\n2\n8 7 4\n14 7 85\n6 1 6\n6 11 5\n10 3 1\n20 9 4\n10 2 12\n8 4 3", "output": "85\n0\n85\n85\n0\n85\n85\n85\n0\n0\n85\n0\n0\n85\n"}, {"input": "14 10\n1 4\n9 12\n7 11\n2 10\n14 7\n14 3\n6 14\n8 14\n5 13\n8 1\n3\n8 7 4\n14 7 85\n6 1 6\n6 11 5\n1... | code_stdio |
[
{
"content": "Your task is to write a program of a simple dictionary which implements the following instructions:\n\n* insert str: insert a string str in to the dictionary\n* find str: if the distionary contains str, then print 'yes', otherwise print 'no'\n\nNotes\n\nTemplate in C\n\nConstraints\n\n* A string c... | [{"input": "13\ninsert AAA\ninsert AAC\ninsert AGA\ninsert AGF\ninsert TTT\nfind AAA\nfind CCC\nfind CCC\ninsert CCC\nfind CCC\ninsert T\nfind TTT\nfind T", "output": "yes\nno\nno\nyes\nyes\nyes\n"}, {"input": "13\ninsert AAA\ninsert CAA\ninsert AGA\ninsert AGG\ninsert TTT\nfind AAA\nfind CCC\nfind CCC\ninsert CCC\nfin... | code_stdio |
[
{
"content": "Small, but very brave, mouse Brain was not accepted to summer school of young villains. He was upset and decided to postpone his plans of taking over the world, but to become a photographer instead.\n\nAs you may know, the coolest photos are on the film (because you can specify the hashtag #film f... | [{"input": "5 5\nW G B W G\nG B W G B\nB W G B W\nW G B W G\nG B W G B\n", "output": "#Black&White\n"}, {"input": "5 5\nW G B W G\nG B W G B\nB W G B W\nW G B W G\nG B W G B\n", "output": "#Black&White"}, {"input": "5 5\nW G B Y M\nG B Y M C\nB Y M C W\nY M C W G\nM C W G B\n", "output": "#Color\n"}, {"input": "5 5\nW ... | code_stdio |
[
{
"content": "The busses in Berland are equipped with a video surveillance system. The system records information about changes in the number of passengers in a bus after stops.\n\nIf $x$ is the number of passengers in a bus just before the current bus stop and $y$ is the number of passengers in the bus just af... | [{"input": "102 1\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n", "output": "0\n"}, {"input": "102 1\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1... | code_stdio |
[
{
"content": "Give you N cards. Only one natural number is written on each card. However, the same number is never written.\n\nFrom now on, as a question, I will say an appropriate natural number. Please answer the largest remainder you get when you divide the number on the card you have by the number I said.\n... | [{"input": "3 3\n9 3 10\n12\n6\n1", "output": "10\n4\n0\n"}, {"input": "3 3\n6 2 16\n20\n7\n2", "output": "16\n6\n0\n"}, {"input": "3 3\n2 1 21\n20\n12\n2", "output": "2\n9\n1\n"}, {"input": "3 3\n9 3 8\n12\n12\n2", "output": "9\n9\n1\n"}, {"input": "3 3\n9 5 8\n12\n11\n1", "output": "9\n9\n0\n"}, {"input": "3 3\n6 2 2... | code_stdio |
[
{
"content": "Problem\n\nJennifer and Marian presented Carla with the string S.\nHowever, Carla is not happy to receive the string S.\nI wanted the string T.\nThe three decided to work together to change the string S to the string T.\n\n\nJennifer first sorts the letters in any order.\n\nMarian then exchanges t... | [{"input": "5\naaabb\nxywyz", "output": "2\n"}, {"input": "5\naaacb\nxywyz", "output": "1\n"}, {"input": "5\nbcaaa\nxywyz", "output": "1\n"}, {"input": "5\nbcaaa\nxywyy", "output": "0\n"}, {"input": "5\nbcaba\nxywyy", "output": "1\n"}, {"input": "5\ncbaba\nxywyy", "output": "1\n"}, {"input": "5\ncbbba\nxywyy", "output"... | code_stdio |
[
{
"content": "Read problems statements in Mandarin Chinese and Russian. \n\nChef has a box full of infinite number of identical coins. One day while playing, he made N piles each containing equal number of coins. Chef suddenly remembered an important task and left the room for sometime. While he was away, his ... | [{"input": "1\n4\n1 -1 2 2", "output": "2\n"}, {"input": "1\n4\n1 1 -1 4", "output": "2\n"}, {"input": "1\n4\n1 2 2 -1", "output": "2\n"}, {"input": "1\n4\n0 2 2 -1", "output": "2\n"}, {"input": "1\n4\n1 -1 2 3", "output": "3\n"}, {"input": "1\n4\n-1 2 0 4", "output": "3\n"}, {"input": "1\n4\n1 -1 1 5", "output": "2\n"... | code_stdio |
[
{
"content": "problem\n\nYou have to play a darts game with the following rules.\n\nYou can throw up to four arrows towards the target. You don't have to throw all four, you don't have to throw one. The target is divided into N parts. The score P1, ..., PN is written in each part. The total score S of the place... | [{"input": "4 67\n12\n28\n28\n11\n3 21\n10\n11\n3\n0 0", "output": "67\n21\n"}, {"input": "4 67\n12\n41\n28\n20\n3 21\n10\n11\n3\n0 0", "output": "65\n21\n"}, {"input": "4 102\n2\n39\n13\n11\n3 14\n5\n11\n4\n0 0", "output": "102\n14\n"}, {"input": "4 58\n12\n14\n28\n11\n3 21\n5\n11\n3\n0 0", "output": "56\n21\n"}, {"in... | code_stdio |
[
{
"content": "There are N mountains ranging from east to west, and an ocean to the west.\nAt the top of each mountain, there is an inn. You have decided to choose where to stay from these inns.\nThe height of the i-th mountain from the west is H_i.\nYou can certainly see the ocean from the inn at the top of the... | [{"input": "20\n100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100\n", "output": "20\n"}, {"input": "20\n54 53 68 68 35 35 62 61 74 73 94 94 94 94 86 85 65 64 68 68\n", "output": "8\n"}, {"input": "20\n8 12 14 17 23 26 38 41 45 46 48 56 60 66 69 85 86 94 98 99\n", "output": "20\n"}, {"input... | code_stdio |
[
{
"content": "CODE FESTIVAL 2016 is going to be held. For the occasion, Mr. Takahashi decided to make a signboard.\n\nHe intended to write `CODEFESTIVAL2016` on it, but he mistakenly wrote a different string S. Fortunately, the string he wrote was the correct length.\n\nSo Mr. Takahashi decided to perform an op... | [{"input": "EDOC6102LAVITSEF", "output": "16\n"}, {"input": "1DO2LAVI6REGE0TC", "output": "15\n"}, {"input": "VT0EGER6ICAL2OD0", "output": "10\n"}, {"input": "VV1EFFR7ICAK2OD0", "output": "11\n"}, {"input": "VW1EFFR7ICAK3OD0", "output": "12\n"}, {"input": "107DFFRV3CALWODI", "output": "13\n"}, {"input": "D6OV>JT1DJEC20... | code_stdio |
[
{
"content": "n people came to a party. Then those, who had no friends among people at the party, left. Then those, who had exactly 1 friend among those who stayed, left as well. Then those, who had exactly 2, 3, ..., n - 1 friends among those who stayed by the moment of their leaving, did the same.\n\nWhat is ... | [{"input": "1\n108\n", "output": "106\n"}, {"input": "1\n157\n", "output": "155\n"}, {"input": "1\n168\n", "output": "166\n"}, {"input": "1\n299\n", "output": "297\n"}, {"input": "1\n111\n", "output": "109\n"}, {"input": "1\n140\n", "output": "138\n"}, {"input": "1\n266\n", "output": "264\n"}, {"input": "1\n372\n", "ou... | code_stdio |
[
{
"content": "Bear Limak wants to become the largest of bears, or at least to become larger than his brother Bob.\n\nRight now, Limak and Bob weigh a and b respectively. It's guaranteed that Limak's weight is smaller than or equal to his brother's weight.\n\nLimak eats a lot and his weight is tripled after ever... | [{"input": "10 10\n", "output": "1\n"}, {"input": "10 10\n", "output": "1\n"}, {"input": "10 10\n", "output": "1\n"}, {"input": "11 12\n", "output": "1\n"}, {"input": "1 43\n", "output": "10\n"}, {"input": "11 15\n", "output": "1\n"}, {"input": "11 16\n", "output": "1\n"}, {"input": "15 15\n", "output": "1\n"}, {"input... | code_stdio |
[
{
"content": "One day Vasya heard a story: \"In the city of High Bertown a bus number 62 left from the bus station. It had n grown-ups and m kids...\"\n\nThe latter events happen to be of no importance to us. Vasya is an accountant and he loves counting money. So he wondered what maximum and minimum sum of mone... | [{"input": "100000 100000\n", "output": "100000 199999\n"}, {"input": "100000 100001\n", "output": "100001 200000\n"}, {"input": "110000 100001\n", "output": "110000 210000\n"}, {"input": "127948 126156\n", "output": "127948 254103\n"}, {"input": "117241 111295\n", "output": "117241 228535\n"}, {"input": "120119 80236\... | code_stdio |
[
{
"content": "Read problems statements in Mandarin Chinese and Russian. \n\nIn a far away dystopian world, the measure of the quality of a personβs life is the numbers of likes he gets for an article about their life. For a person to stay alive, he has to acquire at least L number of likes before D days pass.\... | [{"input": "2\n5 2 10 1\n13 3 3 2", "output": "ALIVE AND KICKING\nALIVE AND KICKING\n"}, {"input": "2\n5 2 10 1\n25 3 3 2", "output": "ALIVE AND KICKING\nALIVE AND KICKING\n"}, {"input": "2\n5 2 10 1\n25 3 3 4", "output": "ALIVE AND KICKING\nALIVE AND KICKING\n"}, {"input": "2\n5 2 10 1\n15 3 3 4", "output": "ALIVE AND... | code_stdio |
[
{
"content": "Gildong's town has a train system that has $100$ trains that travel from the bottom end to the top end and $100$ trains that travel from the left end to the right end. The trains starting from each side are numbered from $1$ to $100$, respectively, and all trains have the same speed. Let's take a ... | [{"input": "3\n1 2\n1\n3 4\n3 2\n2 3 11\n2 1\n9 14\n2 12 16 28 42 57 59 86 99\n3 9 14 19 25 26 20 35 41 59 85 87 99 100\n", "output": "0\n1\n2\n"}, {"input": "3\n1 2\n1\n1 4\n3 2\n1 3 4\n2 4\n9 14\n2 14 16 28 33 57 59 92 99\n3 9 14 19 25 26 28 35 41 59 85 87 99 100\n", "output": "1\n1\n4\n"}, {"input": "3\n1 2\n1\n3 4\... | code_stdio |
[
{
"content": "There are $n$ chips arranged in a circle, numbered from $1$ to $n$. \n\nInitially each chip has black or white color. Then $k$ iterations occur. During each iteration the chips change their colors according to the following rules. For each chip $i$, three chips are considered: chip $i$ itself and ... | [{"input": "101 2\nBWBWBWWWBWBWBWWWBWWWBWWWBWBBBBBWBWBBBWBWBWWBBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWWWBWBWBWB\n", "output": "BBBWWWWWWWBWWWWWWWWWWWWWWBBBBBBBBBBBBBBWWWWBBBBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWWWWWWWBWBBB\n"}, {"input": "101 2\nBWBWBWBWWWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBBW... | code_stdio |
[
{
"content": "problem\n\nMobiles are widely known as moving works of art. The IOI Japan Committee has decided to create mobiles to publicize JOI. JOI public relations mobiles are sticks, strings, and weights. It is constructed as follows using the three types of elements of.\n\n* One end of the bar is painted b... | [{"input": "1\n7 22 0 0\n4\n2 2 0 4\n1 3 0 0\n9 10 2 1\n3 2 0 0\n0", "output": "29\n190\n"}, {"input": "1\n7 11 0 0\n4\n2 2 0 4\n1 3 0 0\n3 8 2 1\n3 2 0 0\n0", "output": "18\n110\n"}, {"input": "1\n7 22 0 0\n4\n2 2 0 4\n1 3 0 0\n3 8 2 1\n3 2 0 0\n0", "output": "29\n110\n"}, {"input": "1\n6 10 0 0\n4\n3 5 0 4\n1 6 0 0\n... | code_stdio |
[
{
"content": "Reading books is one of Sasha's passions. Once while he was reading one book, he became acquainted with an unusual character. The character told about himself like that: \"Many are my names in many countries. Mithrandir among the Elves, TharkΓ»n to the Dwarves, OlΓ³rin I was in my youth in the West ... | [{"input": "tttdddssstttssstttdddddddddttttttdddsssdddtttsssdddsssssstttddddddtttdddssstttsssttttttdddtttsssssstttssssssssstttsssssstttssstttdddddddddsssdddssssssdddssstttsssdddssstttdddttttttdddddddddsssssstttdddtttssssssdddddddddttttttdddtttsssdddssstttsssdddssssssdddsssdddddddddtttssstttsssssstttssssssssstttsssssstt... | code_stdio |
[
{
"content": "Vasya is currently at a car rental service, and he wants to reach cinema. The film he has bought a ticket for starts in t minutes. There is a straight road of length s from the service to the cinema. Let's introduce a coordinate system so that the car rental service is at the point 0, and the cine... | [{"input": "4 13 400 600\n13 30\n1 19\n1 160\n1 113\n58 73 15 319 194 362 128 157 336 162 77 90 96\n", "output": "1\n"}, {"input": "4 13 400 600\n13 30\n1 19\n1 160\n1 113\n58 73 15 319 194 362 128 157 336 162 77 90 96\n", "output": "1\n"}, {"input": "4 13 400 600\n13 30\n1 19\n1 160\n1 113\n58 73 15 319 194 362 200 15... | code_stdio |
[
{
"content": "In Python, code blocks don't have explicit begin/end or curly braces to mark beginning and end of the block. Instead, code blocks are defined by indentation.\n\nWe will consider an extremely simplified subset of Python with only two types of statements.\n\nSimple statements are written in a single... | [{"input": "156\nf\ns\nf\ns\nf\ns\ns\ns\ns\nf\ns\ns\nf\nf\ns\nf\nf\nf\nf\ns\ns\ns\nf\ns\ns\nf\nf\nf\nf\nf\nf\ns\ns\ns\ns\nf\ns\nf\ns\nf\ns\nf\nf\nf\nf\ns\ns\nf\nf\ns\ns\ns\ns\nf\ns\nf\ns\nf\ns\nf\ns\ns\ns\nf\ns\ns\nf\ns\nf\nf\ns\ns\ns\nf\nf\nf\nf\ns\ns\nf\nf\nf\nf\nf\nf\nf\ns\nf\ns\ns\ns\nf\nf\ns\ns\ns\ns\ns\nf\nf\nf\n... | code_stdio |
[
{
"content": "Example\n\nInput\n\n3\n3 0 1\n\n\nOutput\n\n2\n\nWrite Python code to solve this problem. Your program should read the input from stdin and write the output to stdout. Enclose your complete solution in a single ```python code block.",
"role": "user"
}
] | [{"input": "3\n152 -3 2", "output": "0\n"}, {"input": "3\n-1 -1 1", "output": "0\n"}, {"input": "3\n13 -2 3", "output": "0\n"}, {"input": "3\n25 -2 3", "output": "0\n"}, {"input": "3\n25 -2 4", "output": "0\n"}, {"input": "3\n25 -2 1", "output": "0\n"}, {"input": "3\n25 -3 1", "output": "0\n"}, {"input": "3\n33 -3 1", ... | code_stdio |
[
{
"content": "The territory of Berland is represented by a rectangular field n Γ m in size. The king of Berland lives in the capital, located on the upper left square (1, 1). The lower right square has coordinates (n, m). One day the king decided to travel through the whole country and return back to the capita... | [{"input": "101 100\n", "output": "0\n1 1\n2 1\n3 1\n4 1\n5 1\n6 1\n7 1\n8 1\n9 1\n10 1\n11 1\n12 1\n13 1\n14 1\n15 1\n16 1\n17 1\n18 1\n19 1\n20 1\n21 1\n22 1\n23 1\n24 1\n25 1\n26 1\n27 1\n28 1\n29 1\n30 1\n31 1\n32 1\n33 1\n34 1\n35 1\n36 1\n37 1\n38 1\n39 1\n40 1\n41 1\n42 1\n43 1\n44 1\n45 1\n46 1\n47 1\n48 1\n49 ... | code_stdio |
[
{
"content": "A: four tea\n\nproblem\n\nTea is indispensable for programming contests. Tea has the effect of relieving constant tension [citation needed]\n\nThere are N players participating in the contest, so I would like to prepare tea for this number of people. There are four types of tea packages, A, B, C, ... | [{"input": "10\n1 2 10 2\n0 0 0 15", "output": "2\n"}, {"input": "10\n1 1 3 2\n0 2 3 16", "output": "2\n"}, {"input": "10\n0 1 3 2\n1 2 3 16", "output": "0\n"}, {"input": "10\n0 1 6 1\n0 0 1 50", "output": "1\n"}, {"input": "10\n1 1 6 2\n1 1 2 1", "output": "10\n"}, {"input": "10\n0 3 0 3\n0 2 0 2", "output": "15\n"}, ... | code_stdio |
[
{
"content": "There is a tree with N vertices numbered 1 through N. The i-th of the N-1 edges connects vertices a_i and b_i.\n\nInitially, each vertex is uncolored.\n\nTakahashi and Aoki is playing a game by painting the vertices. In this game, they alternately perform the following operation, starting from Tak... | [{"input": "6\n2 1\n2 3\n3 4\n2 5\n5 6", "output": "Second\n"}, {"input": "6\n1 2\n2 3\n6 4\n1 5\n5 6", "output": "Second\n"}, {"input": "6\n1 2\n1 3\n2 4\n1 5\n5 6", "output": "Second\n"}, {"input": "6\n2 1\n2 3\n1 4\n2 5\n5 6", "output": "Second\n"}, {"input": "6\n1 1\n2 3\n1 4\n2 5\n5 6", "output": "Second\n"}, {"in... | code_stdio |
[
{
"content": "Problem\n\nBeans are popular at Otsu University. N beans are lined up in a straight line. Each is numbered from 0 to N-1, and the hardness of the i-th bean is ai.\n\nCyan considers the ideal bean hardness to be D. However, Cyan doesn't want to go get the beans that are too far away because he is t... | [{"input": "10\n4 5 1 21 9 000 12 17 0 6\n5\n2 3 20\n2 2 101\n8 9 9\n5 5 10\n0 9 20", "output": "1\n100\n3\n10\n1\n"}, {"input": "10\n4 5 0 42 9 000 12 9 0 6\n5\n0 2 20\n2 5 101\n8 9 9\n5 5 17\n0 1 20", "output": "15\n59\n3\n17\n15\n"}, {"input": "10\n4 5 0 42 9 000 12 9 0 6\n5\n0 2 20\n2 5 101\n8 9 14\n5 5 23\n0 9 20"... | code_stdio |
[
{
"content": "President of Berland has a very vast office-room, where, apart from him, work his subordinates. Each subordinate, as well as President himself, has his own desk of a unique colour. Each desk is rectangular, and its sides are parallel to the office walls. One day President decided to establish an a... | [{"input": "24 11 N\n.NNNNNNNNNN\n.NNNNNNNNNN\n........RRR\n........RRR\n........RRR\n..MMMMMMRRR\n..MMMMMMRRR\n..MMMMMMRRR\n..MMMMMM...\n....XXXXXXX\n...........\n.....CCCCCC\n.....CCCCCC\n.HHHHHHHHHH\n..VVVVV....\n..VVVVV....\n..VVVVV....\n..VVVVV.I..\n..VVVVV.I..\n..VVVVV.I..\n..VVVVV.I..\n..VVVVV....\n..VVVVV....\n... | code_stdio |
[
{
"content": "There are N cards placed on a grid with H rows and W columns of squares.\n\nThe i-th card has an integer A_i written on it, and it is placed on the square at the R_i-th row from the top and the C_i-th column from the left.\n\nMultiple cards may be placed on the same square.\n\nYou will first pick ... | [{"input": "13 5 6\n1 3 36945\n4 6 19698\n4 6 73389\n3 6 3031\n3 1 4771\n1 4 4784\n2 1 36357\n2 -1 24830\n5 6 160809\n4 6 36941\n0 2 30739\n1 4 68417\n-1 5 78537", "output": "556519\n"}, {"input": "13 5 6\n1 3 36945\n4 6 19698\n4 6 73389\n3 6 3031\n3 1 4771\n1 4 4784\n2 1 36357\n2 -1 24830\n5 6 84109\n4 6 36941\n0 2 30... | code_stdio |
[
{
"content": "You are given two integer arrays a_0, a_1, ..., a_{N - 1} and b_0, b_1, ..., b_{M - 1}. Calculate the array c_0, c_1, ..., c_{(N - 1) + (M - 1)}, defined by c_i = \\sum_{j = 0}^i a_j b_{i - j} \\bmod 998244353.\n\nConstraints\n\n* 1 \\leq N, M \\leq 524288\n* 0 \\leq a_i, b_i < 998244353\n* All va... | [{"input": "4 5\n1 4 3 2\n-1 0 43 8 2", "output": "998244352 998244349 40 178 163 118 22 4\n"}, {"input": "4 5\n2 2 3 4\n5 0 12 13 18", "output": "10 10 39 70 98 123 106 72\n"}, {"input": "4 5\n2 2 3 3\n5 1 12 13 18", "output": "10 12 41 68 101 111 93 54\n"}, {"input": "4 5\n1 2 3 5\n2 -1 23 8 30", "output": "2 3 27 61... | code_stdio |
[
{
"content": "Snuke has N hats. The i-th hat has an integer a_i written on it.\n\nThere are N camels standing in a circle. Snuke will put one of his hats on each of these camels.\n\nIf there exists a way to distribute the hats to the camels such that the following condition is satisfied for every camel, print `... | [{"input": "4\n2 -5 -1 2", "output": "No\n"}, {"input": "4\n1 2 4 11", "output": "No\n"}, {"input": "4\n0 2 4 11", "output": "No\n"}, {"input": "4\n0 4 4 11", "output": "No\n"}, {"input": "4\n0 4 4 20", "output": "No\n"}, {"input": "4\n0 4 1 20", "output": "No\n"}, {"input": "4\n0 4 1 33", "output": "No\n"}, {"input": ... | code_stdio |
[
{
"content": "There are two types of burgers in your restaurant β hamburgers and chicken burgers! To assemble a hamburger you need two buns and a beef patty. To assemble a chicken burger you need two buns and a chicken cutlet. \n\nYou have $b$ buns, $p$ beef patties and $f$ chicken cutlets in your restaurant. Y... | [{"input": "7\n2 1 1\n1 1\n100 101 100\n101 100\n2 101 110\n000 111\n010 3 1\n101 100\n010 77 14\n110 99\n010 001 3\n100 99\n362 51 11\n011 165\n", "output": "1\n5050\n111\n403\n550\n397\n2376\n"}, {"input": "7\n2 1 2\n1 1\n100 100 000\n101 110\n2 101 000\n011 110\n010 3 1\n101 100\n010 77 14\n110 126\n110 001 6\n100 9... | code_stdio |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.