problem_id
stringlengths
16
16
statement
stringlengths
29
9.15k
tests_json
stringlengths
70
5.27M
time_limit_s
float64
1
10
origin_json
stringlengths
82
233
12d3b2f6ae015d26
You are given an image, that can be represented with a 2-d n by m grid of pixels. Each pixel of the image is either on or off, denoted by the characters "0" or "1", respectively. You would like to compress this image. You want to choose an integer k > 1 and split the image into k by k blocks. If n and m are not divisib...
[["3 5\n00100\n10110\n11001\n", "5\n"], ["3 5\n00100\n00110\n11001\n", "4\n"], ["3 5\n00100\n00110\n11011\n", "5\n"], ["3 5\n00100\n00110\n01001\n", "3\n"], ["3 5\n00100\n00110\n11111\n", "6\n"], ["3 5\n00110\n00110\n01001\n", "2\n"], ["3 5\n00000\n00110\n11111\n", "7\n"], ["3 5\n00110\n00110\n01000\n", "1\n"], ["3 5\n...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00000-of-00004.parquet#1740"}
12e504cd280f0352
Gennady is one of the best child dentists in Berland. Today n children got an appointment with him, they lined up in front of his office. All children love to cry loudly at the reception at the dentist. We enumerate the children with integers from 1 to n in the order they go in the line. Every child is associated with...
[["5\n4 2 2\n4 1 2\n5 2 4\n3 3 5\n5 1 2\n", "2\n1 3 "], ["5\n4 5 1\n5 3 9\n4 1 2\n2 1 8\n4 1 9\n", "4\n1 2 4 5 "], ["10\n10 7 10\n3 6 11\n8 4 10\n10 1 11\n7 3 13\n7 2 13\n7 6 14\n3 4 17\n9 4 20\n5 2 24\n", "3\n1 2 5 "], ["10\n5 6 3\n7 4 10\n9 1 17\n2 8 23\n9 10 24\n6 8 18\n3 2 35\n7 6 6\n1 3 12\n9 9 5\n", "6\n1 2 3 4 5...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#706"}
12f280038b4419fc
Recently, on the course of algorithms and data structures, Valeriy learned how to use a deque. He built a deque filled with $n$ elements. The $i$-th element is $a_i$ ($i$ = $1, 2, \ldots, n$). He gradually takes the first two leftmost elements from the deque (let's call them $A$ and $B$, respectively), and then does th...
[["5 3\n1 2 3 4 5\n1\n2\n10\n", "1 2\n2 3\n5 2\n"], ["2 0\n0 0\n", ""], ["2 1\n1 2\n1\n", "1 2\n"], ["3 2\n1000000 999999 999998\n98\n999999999999\n", "1000000 999998\n1000000 999999\n"], ["5 10\n5728 41414 457879 94 1\n1\n100\n10000\n1000000\n100000000\n10000000000\n1000000000000\n100000000000000\n10000000000000000\n1...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00002-of-00004.parquet#1465"}
12f3aadb5abba29a
Square1001 has seen an electric bulletin board displaying the integer 1. He can perform the following operations A and B to change this value: * Operation A: The displayed value is doubled. * Operation B: The displayed value increases by K. Square1001 needs to perform these operations N times in total. Find the min...
[["10\n10", "76"], ["4\n3", "10"], ["10\n17", "117\n"], ["4\n4", "12\n"], ["10\n15", "106\n"], ["4\n7", "15\n"], ["10\n11", "82\n"], ["4\n2", "8\n"], ["10\n14", "100\n"], ["4\n0", "1\n"], ["10\n24", "152\n"], ["4\n-1", "-4\n"], ["10\n9", "70\n"], ["4\n-2", "-12\n"], ["10\n4", "36\n"], ["4\n-4", "-28\n"], ["10\n1", "11\...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00001-of-00005.parquet#1544"}
130cde00b033e4a7
Let S(n) denote the number that represents the digits of n in sorted order. For example, S(1) = 1, S(5) = 5, S(50394) = 3459, S(353535) = 333555. Given a number X, compute <image> modulo 109 + 7. Input The first line of input will contain the integer X (1 ≤ X ≤ 10700). Output Print a single integer, the answer to ...
[["33340691714056185860211260984431382156326935244157\n", "683387308"], ["446490140549710812136081378174660462546524926277418604782585582063971131982328238598703638210071884764059516110693472996891702400239790481987117450115427742681790553110130540730751761227556434833802489996576492114599977662210723991035799774097708...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00004-of-00005.parquet#1450"}
132295dfd446df49
Consider a sequence of integers $a_1, a_2, \ldots, a_n$. In one move, you can select any element of the sequence and delete it. After an element is deleted, all elements to the right are shifted to the left by $1$ position, so there are no empty spaces in the sequence. So after you make a move, the sequence's length de...
[["4\n7 6\n1 1 2 3 4 5 6\n5 2\n5 1 3 2 3\n5 2\n5 5 5 5 4\n8 4\n1 2 3 3 2 2 5 5\n", "1\n2\n-1\n2\n"], ["2\n15 6\n10 7 6 7 9 7 7 10 10 7 9 12 11 12 7\n8 1\n1 3 6 3 7 2 4 8\n", "-1\n0\n"], ["2\n15 6\n10 7 6 7 9 7 7 10 10 7 9 12 11 12 7\n8 1\n1 3 6 3 7 2 4 8\n", "-1\n0\n"], ["2\n15 6\n10 7 3 7 9 7 7 10 10 7 9 12 11 12 7\n8...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00000-of-00004.parquet#1596"}
1326292475463fad
A restaurant received n orders for the rental. Each rental order reserve the restaurant for a continuous period of time, the i-th order is characterized by two time values — the start time li and the finish time ri (li ≤ ri). Restaurant management can accept and reject orders. What is the maximal number of orders the ...
[["6\n4 8\n1 5\n4 7\n2 5\n1 3\n6 8\n", "2\n"], ["5\n1 2\n2 3\n3 4\n4 5\n5 6\n", "3\n"], ["2\n7 11\n4 7\n", "1\n"], ["16\n4 80\n16 46\n15 16\n60 63\n8 54\n18 49\n67 99\n72 80\n1 8\n19 64\n1 54\n46 94\n2 89\n67 78\n21 47\n5 29\n", "5\n"], ["15\n1 58\n15 21\n53 55\n59 90\n68 71\n29 51\n52 81\n32 52\n38 44\n57 59\n47 60\n2...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00002-of-00005.parquet#723"}
1328517f5f3824a1
Let's solve the puzzle by programming. The numbers n x n are arranged in a grid pattern. Some of the numbers are circled and we will call them the starting point. The rules of the puzzle are as follows: * Draw one line that goes vertically and horizontally from each starting point (cannot be drawn diagonally). * Exte...
[["3\n-3 1 1\n2 -4 1\n2 1 -1\n3\n-4 1 1\n1 1 -6\n1 -5 3\n4\n-8 6 -2 1\n2 -7 -2 1\n1 -1 1 1\n1 1 1 -5\n6\n2 2 3 -7 3 2\n1 -10 1 1 3 2\n2 6 5 2 -6 0\n3 4 -23 2 2 5\n3 3 -6 2 3 7\n-7 2 3 2 -5 -13\n6\n2 2 3 -7 3 2\n1 -10 1 1 3 2\n2 6 5 2 -6 1\n3 4 -23 2 2 5\n3 3 -6 2 3 7\n-7 2 3 2 -5 -12\n0", "YES\nNO\nNO\nNO\nNO\n"], ["3\...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#431"}
132aca4f7bf68ba0
You are an experienced Codeforces user. Today you found out that during your activity on Codeforces you have made y submissions, out of which x have been successful. Thus, your current success rate on Codeforces is equal to x / y. Your favorite rational number in the [0;1] range is p / q. Now you wonder: what is the s...
[["4\n3 10 1 2\n7 14 3 8\n20 70 2 7\n5 6 1 1\n", "4\n10\n0\n-1\n"], ["8\n0 1 0 1\n0 2 1 2\n0 3 1 1\n1 2 0 1\n1 2 1 1\n2 2 0 1\n3 3 1 2\n4 4 1 1\n", "0\n2\n-1\n-1\n-1\n-1\n3\n0\n"], ["5\n1 1000000000 1 2\n1 1000000000 1 2\n1 1000000000 1 2\n1 1000000000 1 2\n1 1000000000 1 2\n", "999999998\n999999998\n999999998\n9999999...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00000-of-00004.parquet#723"}
132f87bd0e4f98a0
You've got string s, consisting of small English letters. Some of the English letters are good, the rest are bad. A substring s[l...r] (1 ≤ l ≤ r ≤ |s|) of string s = s_1s_2...s_{|}s| (where |s| is the length of string s) is string s_{l}s_{l} + 1...s_{r}. The substring s[l...r] is good, if among the letters s_{l}...
[["ababab\n01000000000000000000000000\n1\n", "5\n"], ["acbacbacaa\n00000000000000000000000000\n2\n", "8\n"], ["a\n00000000000000000000000000\n0\n", "0\n"], ["aaaa\n00000000000000000000000000\n0\n", "0\n"], ["aaaaaa\n00000000000000000000000000\n1\n", "1\n"], ["bbbbbbbbba\n01000000000000000000000000\n0\n", "9\n"], ["bbbb...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#1515"}
133f1679a06f810a
The city park of IT City contains n east to west paths and n north to south paths. Each east to west path crosses each north to south path, so there are n2 intersections. The city funded purchase of five benches. To make it seems that there are many benches it was decided to place them on as many paths as possible. Ob...
[["5\n", "120\n"], ["7\n", "52920\n"], ["100\n", "680185280130048000\n"], ["83\n", "101159538130177920\n"], ["72\n", "23491596420472320\n"], ["6\n", "4320\n"], ["15\n", "1082161080\n"], ["99\n", "613867215317368320\n"], ["17\n", "4594961280\n"], ["95\n", "402852449038723320\n"], ["38\n", "30233492563680\n"], ["9\n", "1...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00002-of-00005.parquet#2503"}
13409e3b6e12d6a3
You got a box with a combination lock. The lock has a display showing n digits. There are two buttons on the box, each button changes digits on the display. You have quickly discovered that the first button adds 1 to all the digits (all digits 9 become digits 0), and the second button shifts all the digits on the displ...
[["3\n579\n", "024\n"], ["4\n2014\n", "0142\n"], ["1\n1\n", "0\n"], ["3\n039\n", "014\n"], ["4\n4444\n", "0000\n"], ["5\n46802\n", "02468\n"], ["10\n4447444444\n", "0000000003\n"], ["10\n5810438174\n", "0147609473\n"], ["30\n027027027027027027027027027027\n", "027027027027027027027027027027\n"], ["50\n41012516454101251...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00003-of-00004.parquet#495"}
1345a9a64ec44259
There is little time left before the release of the first national operating system BerlOS. Some of its components are not finished yet — the memory manager is among them. According to the developers' plan, in the first release the memory manager will be very simple and rectilinear. It will support three operations: ...
[["3 1\nerase -1\nerase 0\nerase -2147483648\n", "ILLEGAL_ERASE_ARGUMENT\nILLEGAL_ERASE_ARGUMENT\nILLEGAL_ERASE_ARGUMENT\n"], ["26 25\ndefragment\nerase 1\nerase -1560200883\nalloc 44\ndefragment\nalloc 75\nalloc 22\ndefragment\nerase 4\ndefragment\nalloc 57\nalloc 53\nerase 4\nerase -1639632026\nerase -2121605039\nera...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00000-of-00004.parquet#1742"}
135ecf550afc0144
There is a directed graph with N vertices and M edges. The i-th edge (1≤i≤M) points from vertex a_i to vertex b_i, and has a weight c_i. We will play the following single-player game using this graph and a piece. Initially, the piece is placed at vertex 1, and the score of the player is set to 0. The player can move th...
[["3 3\n1 2 4\n2 3 3\n1 3 5\n", "7\n"], ["2 2\n1 2 1\n2 1 1\n", "inf\n"], ["6 5\n1 2 -1000000000\n2 3 -1000000000\n3 4 -1000000000\n4 5 -1000000000\n5 6 -1000000000\n", "-5000000000\n"], ["3 3\n1 2 4\n2 2 3\n1 3 5", "5\n"], ["6 5\n1 2 -1000000000\n2 3 -1000000000\n3 5 -1000000000\n4 5 -1000000000\n5 6 -1000000000", "-4...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00000-of-00004.parquet#766"}
137a7c8529f5ce03
Anya has bought a new smartphone that uses Berdroid operating system. The smartphone menu has exactly n applications, each application has its own icon. The icons are located on different screens, one screen contains k icons. The icons from the first to the k-th one are located on the first screen, from the (k + 1)-th ...
[["8 3 3\n1 2 3 4 5 6 7 8\n7 8 1\n", "7\n"], ["5 4 2\n3 1 5 2 4\n4 4 4 4\n", "8\n"], ["10 10 3\n1 2 3 4 5 6 7 8 9 10\n2 3 4 5 6 7 8 9 10 1\n", "25\n"], ["10 12 3\n6 1 2 9 3 10 8 5 7 4\n3 9 9 4 8 2 3 8 10 8 3 4\n", "29\n"], ["16 12 8\n6 11 12 5 1 10 16 3 13 15 9 4 8 2 14 7\n6 13 8 12 8 15 12 16 8 11 3 16\n", "18\n"], ["...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#1154"}
137dad7162cc338b
You are playing a game and your goal is to maximize your expected gain. At the beginning of the game, a pawn is put, uniformly at random, at a position p\in\\{1,2,\dots, N\\}. The N positions are arranged on a circle (so that 1 is between N and 2). The game consists of turns. At each turn you can either end the game, ...
[["10\n470606482521 533212137322 116718867454 746976621474 457112271419 815899162072 641324977314 88281100571 9231169966 455007126951\n26 83 30 59 000 88 84 91 54 61", "815899161169.399999976158\n"], ["14\n2094 5400 6231 5800 6001 5200 6350 7133 7986 8012 7537 7013 6477 5912\n34 54 61 32 52 61 21 43 65 12 45 21 1 4", "...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00004-of-00005.parquet#1903"}
13825f510c28a341
Joisino is planning to open a shop in a shopping street. Each of the five weekdays is divided into two periods, the morning and the evening. For each of those ten periods, a shop must be either open during the whole period, or closed during the whole period. Naturally, a shop must be open during at least one of those ...
[["1\n1 1 0 1 0 0 0 1 0 1\n3 4 5 6 7 8 9 -2 -3 4 -2", "8"], ["3\n1 1 1 1 1 1 0 0 1 1\n0 1 0 1 1 1 1 0 1 0\n1 0 1 1 0 1 0 1 0 1\n-8 6 -2 -8 -8 4 8 7 -6 2 2\n-9 2 0 1 7 -5 0 -2 -6 5 5\n6 -6 7 -9 6 -5 8 0 -9 -7 -7", "23"], ["2\n1 1 1 1 1 0 0 0 0 0\n0 0 0 0 0 1 1 1 1 1\n0 -2 -2 -2 -2 -2 -1 -1 -1 -1 -1\n0 -2 -2 -2 -2 -2 -1 ...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00000-of-00005.parquet#2839"}
138c06d80273d790
Sensation, sensation in the two-dimensional kingdom! The police have caught a highly dangerous outlaw, member of the notorious "Pihters" gang. The law department states that the outlaw was driving from the gang's headquarters in his car when he crashed into an ice cream stall. The stall, the car, and the headquarters e...
[["10\nUR\nDR\nUL\nDR\nUL\nULDR\nUR\nUL\nULDR\nUL\n", "45\n"], ["6\nUL\nDL\nDL\nUL\nUL\nDL\n", "16\n"], ["1\nDR\n", "2\n"], ["1\nUR\n", "2\n"], ["1\nULDR\n", "4\n"], ["1\nUL\n", "2\n"], ["4\nULDR\nUR\nULDR\nUR\n", "15\n"], ["10\nUL\nUL\nUL\nUL\nUL\nUL\nUL\nUL\nUL\nUL\n", "11\n"], ["10\nUL\nUR\nUR\nDR\nDR\nDR\nDL\nDL\nD...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00000-of-00004.parquet#1616"}
13941e7226ae7937
Roy is going through the dark times of his life. Recently his girl friend broke up with him and to overcome the pain of acute misery he decided to restrict himself to Eat-Sleep-Code life cycle. For N days he did nothing but eat, sleep and code. A close friend of Roy kept an eye on him for last N days. For every sing...
[["4\nSSSSEEEECCCCEECCCC\nCCCCCSSSSEEECCCCSS\nSSSSSEEESSCCCCCCCS\nEESSSSCCCCCCSSEEEESAMPLE", "7 9\n"], ["4\nSSSSEEEECCCCEECCCC\nCCCCCSSSSEEECCCCSS\nSCCCCCCCSSEEESSSSS\nEESSSSCCCCCCSSEEEESAMPLE", "7 9\n"], ["4\nCCCCEECBCCEEEESSSS\nCCCCCSSSSEEECCCCSS\nSSSSSEEESSCCCCCCCS\nEESSSSCCCCCCSSEEEESAMPLE", "7 7\n"], ["4\nSSSSEEEE...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00000-of-00005.parquet#2781"}
139f6fa2361028ed
You are given an integer N. Find the number of strings of length N that satisfy the following conditions, modulo 10^9+7: * The string does not contain characters other than `A`, `C`, `G` and `T`. * The string does not contain `AGC` as a substring. * The condition above cannot be violated by swapping two adjacent chara...
[["4", "230"], ["3", "61"], ["100", "388130742"], ["5", "865\n"], ["6", "3247\n"], ["8", "45719\n"], ["15", "478366600\n"], ["12", "9058467\n"], ["9", "171531\n"], ["14", "127504505\n"], ["7", "12185\n"], ["13", "33985227\n"], ["20", "580025381\n"], ["10", "643550\n"], ["11", "2414454\n"], ["24", "604119499\n"], ["26",...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00002-of-00005.parquet#467"}
13a26b193db95574
You are given an array of integers $a_1, a_2, \ldots, a_n$ and an integer $x$. You need to select the maximum number of elements in the array, such that for every subsegment $a_l, a_{l + 1}, \ldots, a_r$ containing strictly more than one element $(l < r)$, either: At least one element on this subsegment is not select...
[["4\n5\n1 2 3 4 5\n2\n10\n2 4 2 4 2 4 2 4 2 4\n3\n3\n-10 -5 -10\n-8\n3\n9 9 -3\n5\n", "4\n8\n2\n2\n"], ["1\n10\n5 -9 -1 6 -6 5 -6 -8 5 3\n0\n", "6\n"], ["10\n1\n62169\n62169\n1\n49900\n49900\n1\n-45220\n-45220\n1\n45734\n45734\n1\n-77581\n-77581\n1\n-48287\n-48287\n1\n53304\n53304\n1\n13558\n13558\n1\n18202\n18202\n1\...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00004-of-00005.parquet#3223"}
13a6369bb0937161
A country called Berland consists of n cities, numbered with integer numbers from 1 to n. Some of them are connected by bidirectional roads. Each road has some length. There is a path from each city to any other one by these roads. According to some Super Duper Documents, Berland is protected by the Super Duper Missile...
[["10 45 9\n2 1 428\n3 1 610\n3 2 357\n4 1 855\n4 2 528\n4 3 508\n5 1 425\n5 2 185\n5 3 349\n5 4 845\n6 1 206\n6 2 969\n6 3 153\n6 4 854\n6 5 640\n7 1 87\n7 2 250\n7 3 953\n7 4 456\n7 5 742\n7 6 588\n8 1 641\n8 2 898\n8 3 396\n8 4 960\n8 5 654\n8 6 410\n8 7 640\n9 1 707\n9 2 707\n9 3 707\n9 4 707\n9 5 707\n9 6 707\n9 7...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00002-of-00004.parquet#1018"}
13a72d6672b624fa
Polycarp lives on the coordinate axis $Ox$ and travels from the point $x=a$ to $x=b$. It moves uniformly rectilinearly at a speed of one unit of distance per minute. On the axis $Ox$ at the point $x=c$ the base station of the mobile operator is placed. It is known that the radius of its coverage is $r$. Thus, if Polyc...
[["9\n1 10 7 1\n3 3 3 0\n8 2 10 4\n8 2 10 100\n-10 20 -17 2\n-3 2 2 0\n-3 1 2 0\n2 3 2 3\n-1 3 -2 2\n", "7\n0\n4\n0\n30\n5\n4\n0\n3\n"], ["9\n1 10 7 1\n3 3 3 0\n8 2 10 4\n8 2 10 100\n-10 20 -17 2\n-3 1 2 0\n-3 1 2 0\n2 3 2 3\n-1 3 -2 2\n", "7\n0\n4\n0\n30\n4\n4\n0\n3\n"], ["9\n1 10 7 1\n3 3 3 0\n8 2 10 4\n8 2 10 100\n-...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00003-of-00004.parquet#294"}
13adcc73cb7dd561
In 40XX, the Earth was invaded by aliens! Already most of the Earth has been dominated by aliens, leaving Tsuruga Castle Fortress as the only remaining defense base. Suppression units are approaching the Tsuruga Castle Fortress one after another. <image> But hope remains. The ultimate defense force weapon, the ultra...
[["100 5\n101 101 5 5\n110 110 2 3\n-112 -100 9 11\n-208 160 82 90\n-110 108 10 2\n10 11\n15 0 5 1\n25 0 5 1\n35 0 5 1\n45 0 5 1\n55 0 5 1\n65 0 5 1\n75 0 5 1\n85 0 5 1\n95 0 5 1\n-19 0 5 20\n-30 0 500 5\n0 0", "1\n1\n"], ["100 5\n101 101 5 5\n110 110 2 3\n-112 -100 5 11\n-208 160 82 90\n-110 108 10 2\n10 11\n15 0 5 1\...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00003-of-00004.parquet#464"}
13b0e72368b7c5ee
Let's define the following recurrence: $$$a_{n+1} = a_{n} + minDigit(a_{n}) ⋅ maxDigit(a_{n}).$$$ Here minDigit(x) and maxDigit(x) are the minimal and maximal digits in the decimal representation of x without leading zeroes. For examples refer to notes. Your task is calculate a_{K} for given a_{1} and K. Input The ...
[["8\n1 4\n487 1\n487 2\n487 3\n487 4\n487 5\n487 6\n487 7\n", "42\n487\n519\n528\n544\n564\n588\n628\n"], ["1\n1 333\n", "50\n"], ["1\n1 589\n", "50\n"], ["8\n1 4\n487 1\n487 2\n487 3\n487 4\n487 5\n487 6\n487 1\n", "42\n487\n519\n528\n544\n564\n588\n487\n"], ["1\n3 98\n", "102\n"], ["1\n3 7\n", "62\n"], ["1\n4 7\n", ...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00002-of-00005.parquet#3104"}
13b9c46466f29f8e
Finished her homework, Nastya decided to play computer games. Passing levels one by one, Nastya eventually faced a problem. Her mission is to leave a room, where a lot of monsters live, as quickly as possible. There are $n$ manholes in the room which are situated on one line, but, unfortunately, all the manholes are c...
[["2 2\n", "6\n"], ["4 2\n", "13\n"], ["5 1\n", "15\n"], ["64 49\n", "207\n"], ["24 6\n", "77\n"], ["91 39\n", "311\n"], ["87 87\n", "261\n"], ["72 36\n", "251\n"], ["4237 4112\n", "12836\n"], ["1815 1371\n", "5889\n"], ["5000 1628\n", "16627\n"], ["5000 3531\n", "16469\n"], ["5000 2895\n", "17105\n"], ["5000 539\n", "...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#1847"}
13bb1ae0e5e0a54c
You are given $n$ rectangles, each of height $1$. Each rectangle's width is a power of $2$ (i. e. it can be represented as $2^x$ for some non-negative integer $x$). You are also given a two-dimensional box of width $W$. Note that $W$ may or may not be a power of $2$. Moreover, $W$ is at least as large as the width of ...
[["2\n5 16\n1 2 8 4 8\n6 10\n2 8 8 2 2 8\n", "2\n3\n"], ["2\n5 13\n1 2 8 4 8\n6 10\n2 8 8 2 2 8\n", "2\n3\n"], ["2\n5 13\n1 2 8 2 8\n6 10\n4 8 8 2 2 8\n", "2\n4\n"], ["2\n5 12\n1 4 8 4 8\n6 10\n2 8 8 2 2 8\n", "3\n3\n"], ["2\n5 8\n1 2 8 2 8\n6 11\n4 8 8 2 2 8\n", "3\n4\n"], ["2\n5 12\n1 2 8 4 8\n6 12\n2 2 8 2 2 8\n", "...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00000-of-00004.parquet#949"}
13c04507d56b2b68
Let us consider sets of positive integers less than or equal to n. Note that all elements of a set are different. Also note that the order of elements doesn't matter, that is, both {3, 5, 9} and {5, 9, 3} mean the same set. Specifying the number of set elements and their sum to be k and s, respectively, sets satisfyin...
[["9 3 23\n9 3 22\n10 3 28\n16 10 107\n20 8 102\n20 8 105\n20 20 155\n3 5 3\n4 2 11\n0 0 0", "1\n2\n0\n20\n1542\n1095\n0\n0\n0\n"], ["9 3 23\n9 3 22\n10 3 28\n16 10 107\n26 8 102\n20 10 105\n20 10 2\n3 4 3\n4 2 11\n0 0 0", "1\n2\n0\n20\n32200\n5448\n0\n0\n0\n"], ["4 3 23\n9 3 22\n10 5 28\n16 10 107\n20 8 102\n20 8 105\...
3.95
{"source": "deepcoder/taco", "upstream_id": "taco/train-00003-of-00004.parquet#1642"}
13d3efca9c17ed96
A railroad running from west to east in Atcoder Kingdom is now complete. There are N stations on the railroad, numbered 1 through N from west to east. Tomorrow, the opening ceremony of the railroad will take place. On this railroad, for each integer i such that 1≤i≤N-1, there will be trains that run from Station i t...
[["3\n6 5 1\n1 10 1", "12\n11\n0"], ["4\n12 13 1\n44 17 17\n66 4096 64", "4162\n4162\n4162\n0"], ["4\n12 24 6\n52 16 4\n99 2 2", "187\n167\n101\n0"], ["3\n6 6 1\n1 10 1", "13\n11\n0\n"], ["4\n1 13 1\n44 17 17\n66 4096 64", "4162\n4162\n4162\n0\n"], ["4\n11 24 6\n52 16 4\n99 2 2", "187\n167\n101\n0\n"], ["3\n6 1 1\n1 10...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00001-of-00005.parquet#1318"}
13d7655c3b12629f
Write a program which reads a rectangle and a circle, and determines whether the circle is arranged inside the rectangle. As shown in the following figures, the upper right coordinate $(W, H)$ of the rectangle and the central coordinate $(x, y)$ and radius $r$ of the circle are given. Circle inside a rectangle Cons...
[["2 4 2 2 1", "No\n"], ["2 8 2 0 0", "Yes\n"], ["5 4 2 0 1", "No\n"], ["2 4 2 2 2", "No\n"], ["5 8 2 0 1", "No\n"], ["2 6 2 2 2", "No\n"], ["2 8 2 0 1", "No\n"], ["3 6 2 2 2", "No\n"], ["0 6 2 2 2", "No\n"], ["2 8 1 0 0", "Yes\n"], ["0 10 2 2 2", "No\n"], ["2 12 1 0 0", "Yes\n"], ["0 10 2 2 0", "No\n"], ["0 12 1 0 0",...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00003-of-00004.parquet#698"}
13dbdd51c2352b76
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required. -----Constraints----- - 1 \leq N \leq 10000 - N is an integer. -----Input----- Input is given from Standard Input in...
[["1900\n", "100\n"], ["3000\n", "0\n"], ["1\n", "999\n"], ["999\n", "1\n"], ["1001\n", "999\n"], ["1000\n", "0\n"], ["10000\n", "0\n"], ["522\n", "478\n"], ["4575\n", "425\n"], ["6426\n", "574\n"], ["9445\n", "555\n"], ["8772\n", "228\n"], ["81\n", "919\n"], ["3447\n", "553\n"], ["629\n", "371\n"], ["3497\n", "503\n"]...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00000-of-00004.parquet#867"}
13e402f55bfe91b1
Appleman has n cards. Each card has an uppercase letter written on it. Toastman must choose k cards from Appleman's cards. Then Appleman should give Toastman some coins depending on the chosen cards. Formally, for each Toastman's card i you should calculate how much Toastman's cards have the letter equal to letter on i...
[["15 10\nDZFDFZDFDDDDDDF\n", "82\n"], ["6 4\nYJSNPI\n", "4\n"], ["5 3\nAOWBY\n", "3\n"], ["1 1\nV\n", "1\n"], ["2 1\nWT\n", "1\n"], ["2 2\nBL\n", "2\n"], ["5 1\nFACJT\n", "1\n"], ["5 5\nMJDIJ\n", "7\n"], ["15 5\nAZBIPTOFTJCJJIK\n", "13\n"], ["100 1\nEVEEVEEEGGECFEHEFVFVFHVHEEEEEFCVEEEEEEVFVEEVEEHEEVEFEVVEFEEEFEVECEHGH...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#1127"}
13e442d4fcc02790
The World Programming Olympics Medal is a metal disk, consisting of two parts: the first part is a ring with outer radius of r1 cm, inner radius of r2 cm, (0 < r2 < r1) made of metal with density p1 g/cm3. The second part is an inner disk with radius r2 cm, it is made of metal with density p2 g/cm3. The disk is nested ...
[["2 1 2\n3 3 1 2\n2 2 3\n306 406\n", "1.6316540938\n"], ["2 3 2\n3 2 3 1\n2 2 1\n733 883\n", "2.6550666782\n"], ["1 5000\n1 5000\n1 1\n1 5000\n", "4999.9999000000\n"], ["1 5\n1 3\n1 7\n515 892\n", "3.2636130585\n"], ["3 1 2 3\n1 2\n3 3 2 1\n52 56\n", "2.4791816116\n"], ["2 1 2\n3 2 3 1\n2 1 3\n452 219\n", "1.539383784...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00004-of-00005.parquet#1167"}
13f9aee7e4adbc76
After a long day, Alice and Bob decided to play a little game. The game board consists of $n$ cells in a straight line, numbered from $1$ to $n$, where each cell contains a number $a_i$ between $1$ and $n$. Furthermore, no two cells contain the same number. A token is placed in one of the cells. They take alternating...
[["8\n3 6 5 4 2 7 1 8\n", "BAAAABAB\n"], ["15\n3 11 2 5 10 9 7 13 15 8 4 12 6 1 14\n", "ABAAAABBBAABAAB\n"], ["1\n1\n", "B\n"], ["2\n1 2\n", "AB\n"], ["2\n2 1\n", "BA\n"], ["10\n1 2 3 4 5 6 7 8 9 10\n", "AAAAABBBBB\n"], ["40\n5 40 6 27 39 37 17 34 3 30 28 13 12 8 11 10 31 4 1 16 38 22 29 35 33 23 7 9 24 14 18 26 19 21 ...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00004-of-00005.parquet#1191"}
13fdfd0b641d1bd4
As the students are back in hostel after a long time, the gamers have decided to have a LAN gaming competition to find out who has utilized his time in gaming during vacations. They play "Counter ATOD". However, the scoring of this game is weird. There are N players and there are M rounds. Initially, each player has 0 ...
[["3 5\nMurliwala 5\nMithaiwala 4\nMithaiwala 4\nMithaiwala -2\nMirchiwala 8\n\nSAMPLE", "Mithaiwala"], ["3 4\nvinay 1\nvinay 2\nvinay -4\nSID 3", "vinay"], ["3 4\nvinay 1\nvinay 2\nvinay -4\nSID 4", "SID"], ["1 3\nvinay 5\nvinay -15\nvinay -1000", "vinay"], ["3 4\nvinay 1\nvinay 2\nvinay -4\nSID 5", "SID\n"], ["1 3\nv...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00002-of-00005.parquet#2726"}
1404121c07bba5da
Given are integers a,b,c and d. If x and y are integers and a \leq x \leq b and c\leq y \leq d hold, what is the maximum possible value of x \times y? -----Constraints----- - -10^9 \leq a \leq b \leq 10^9 - -10^9 \leq c \leq d \leq 10^9 - All values in input are integers. -----Input----- Input is given from Standa...
[["1 2 1 1\n", "2\n"], ["3 5 -4 -2\n", "-6\n"], ["-1000000000 0 -1000000000 0\n", "1000000000000000000\n"], ["0 0 0 0\n", "0\n"], ["-1000000000 1000000000 -1000000000 1000000000\n", "1000000000000000000\n"], ["-253230108 363756450 712662868 735867677\n", "267676613855266650\n"], ["193944314 586260100 -192321079 9583412...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00000-of-00004.parquet#229"}
1408f6e26940b4ab
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 during the contest. V...
[["6\n0 1 3 7 15 31\n", "7\n"], ["2\n73 37\n", "36\n"], ["2\n0 1000000000\n", "1000000000\n"], ["8\n729541013 135019377 88372488 319157478 682081360 558614617 258129110 790518782\n", "470242129\n"], ["2\n0 1\n", "1\n"], ["8\n552283832 997699491 89302459 301640204 288141798 31112026 710831619 862166501\n", "521171806\n"...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00000-of-00004.parquet#815"}
141f15c82a971af5
Vasya plays the sleuth with his friends. The rules of the game are as follows: those who play for the first time, that is Vasya is the sleuth, he should investigate a "crime" and find out what is happening. He can ask any questions whatsoever that can be answered with "Yes" or "No". All the rest agree beforehand to ans...
[["iehvZNQXDGCuVmJPOEysLyUryTdfaIxIuTzTadDbqRQGoCLXkxnyfWSGoLXebNnQQNTqAQJebbyYvHOfpUnXeWdjx?\n", "NO"], ["hh?\n", "NO"], ["j ?\n", "NO"], ["J ?\n", "NO"], ["o ?\n", "YES"], ["T ?\n", "NO"], ["GlEm...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00003-of-00004.parquet#1450"}
142965de53e00a95
There are 2000001 stones placed on a number line. The coordinates of these stones are -1000000, -999999, -999998, \ldots, 999999, 1000000. Among them, some K consecutive stones are painted black, and the others are painted white. Additionally, we know that the stone at coordinate X is painted black. Print all coordinat...
[["3 7\n", "5 6 7 8 9\n"], ["4 0\n", "-3 -2 -1 0 1 2 3\n"], ["1 100\n", "100\n"], ["1 0\n", "0\n"], ["100 0\n", "-99 -98 -97 -96 -95 -94 -93 -92 -91 -90 -89 -88 -87 -86 -85 -84 -83 -82 -81 -80 -79 -78 -77 -76 -75 -74 -73 -72 -71 -70 -69 -68 -67 -66 -65 -64 -63 -62 -61 -60 -59 -58 -57 -56 -55 -54 -53 -52 -51 -50 -49 -48...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#585"}
1431819484430c2a
As you know Appu created aversion to Maths after that maths problem given by his teacher.So he stopped studying and began to do farming. He has some land where he starts growing sugarcane. At the end of the season he grew N sugarcanes. Is Appu satisfied??. No, He wants all his sugar canes to be of the same height. He g...
[["2\n1 23\n\nSAMPLE", "NO\n"], ["47\n169884146 730277703 8645016 732791141 331583052 25104065 895622218 478600214 924154067 813310590 389843997 977252329 338578814 512086554 953548504 508435813 602216502 773835133 194230149 661387945 354427757 690709868 320153566 468158534 287696464 210587004 734620117 534953438 70915...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00000-of-00005.parquet#2777"}
144416be29b5afcd
There was once young lass called Mary, Whose jokes were occasionally scary. On this April's Fool Fixed limerick rules Allowed her to trip the unwary. Can she fill all the lines To work at all times? On juggling the words Right around two-thirds She ne...
[["391\n", "1723"], ["57\n", "319"], ["35\n", "57"], ["4\n", "22\n"], ["58\n", "229\n"], ["14\n", "27\n"], ["502\n", "2251\n"], ["10\n", "25\n"], ["202\n", "2101\n"], ["85\n", "517\n"], ["39\n", "313\n"], ["22\n", "211\n"], ["9\n", "33\n"], ["21\n", "37\n"], ["25\n", "55\n"], ["15\n", "35\n"], ["6\n", "23\n"], ["158\n"...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00001-of-00005.parquet#2549"}
145f34d68f0dff1c
There are N towns on a plane. The i-th town is located at the coordinates (x_i,y_i). There may be more than one town at the same coordinates. You can build a road between two towns at coordinates (a,b) and (c,d) for a cost of min(|a-c|,|b-d|) yen (the currency of Japan). It is not possible to build other types of road...
[["6\n8 3\n4 9\n12 19\n2 1\n13 5\n7 6", "7\n"], ["3\n0 5\n3 9\n7 8", "4\n"], ["6\n8 3\n4 9\n12 19\n2 1\n15 5\n7 6", "9\n"], ["3\n0 8\n3 9\n7 8", "1\n"], ["6\n8 3\n4 9\n12 19\n2 2\n15 5\n7 6", "8\n"], ["6\n8 3\n4 9\n12 19\n2 4\n12 5\n7 6", "5\n"], ["6\n8 3\n4 5\n12 19\n2 4\n12 5\n7 6", "3\n"], ["6\n7 3\n4 5\n12 19\n2 4\...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00003-of-00004.parquet#1256"}
146b20dd5b9aa98e
There are n walruses standing in a queue in an airport. They are numbered starting from the queue's tail: the 1-st walrus stands at the end of the queue and the n-th walrus stands at the beginning of the queue. The i-th walrus has the age equal to ai. The i-th walrus becomes displeased if there's a younger walrus stan...
[["13\n16 14 12 9 11 28 30 21 35 30 32 31 43\n", "3 2 1 -1 -1 1 0 -1 2 -1 0 -1 -1 "], ["13\n18 9 8 9 23 20 18 18 33 25 31 37 36\n", "2 0 -1 -1 2 1 -1 -1 1 -1 -1 0 -1 "], ["2\n1 1000000000\n", "-1 -1 "], ["2\n1000000000 1\n", "0 -1 "], ["15\n18 6 18 21 14 20 13 9 18 20 28 13 19 25 21\n", "10 -1 8 8 6 6 0 -1 2 2 3 -1 -1 ...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00000-of-00004.parquet#91"}
146cc39ca5d1b926
Anna and Maria are in charge of the math club for junior students. When the club gathers together, the students behave badly. They've brought lots of shoe laces to the club and got tied with each other. Specifically, each string ties together two students. Besides, if two students are tied, then the lace connects the f...
[["9 33\n5 7\n5 9\n9 6\n9 1\n7 4\n3 5\n7 8\n8 6\n3 6\n8 2\n3 8\n1 6\n1 8\n1 4\n4 2\n1 2\n2 5\n3 4\n8 5\n2 6\n3 1\n1 5\n1 7\n3 2\n5 4\n9 4\n3 9\n7 3\n6 4\n9 8\n7 9\n8 4\n6 5\n", "0\n"], ["51 23\n46 47\n31 27\n1 20\n49 16\n2 10\n29 47\n13 27\n34 26\n31 2\n28 20\n17 40\n39 4\n29 26\n28 44\n3 39\n50 12\n19 1\n30 21\n41 23\...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00000-of-00004.parquet#334"}
149691952b71f9ef
Two experienced climbers are planning a first-ever attempt: they start at two points of the equal altitudes on a mountain range, move back and forth on a single route keeping their altitudes equal, and finally meet with each other at a point on the route. A wise man told them that if a route has no point lower than the...
[["6\n0 0\n3 4\n9 12\n17 6\n21 0\n33 0\n5\n0 0\n10 0\n20 0\n30 0\n40 0\n10\n0 0\n1 2\n3 0\n6 3\n9 0\n11 2\n13 0\n15 2\n16 2\n18 0\n7\n0 0\n150 997\n300 1\n450 999\n600 2\n750 998\n900 0\n0", "44.211102550928\n40.000000000000\n30.335620930469\n10078.072814085803\n"], ["6\n0 -1\n3 4\n9 12\n17 6\n21 9\n33 0\n5\n0 0\n10 0\...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00003-of-00005.parquet#1678"}
149a83b0beceb7cc
At the school where the twins Ami and Mami attend, the summer vacation has already begun, and a huge amount of homework has been given this year as well. However, the two of them were still trying to go out without doing any homework today. It is obvious that you will see crying on the last day of summer vacation as it...
[["4\n1 1\n3 1\n4 1\n2 1\n3\n5 2\n1 2\n1 2\n1\n1000 1000\n10\n5 62\n10 68\n15 72\n20 73\n25 75\n30 77\n35 79\n40 82\n45 100\n815 283\n6\n74 78\n53 55\n77 77\n12 13\n39 42\n1 1\n0", "14\n14\n3000\n2013\n522\n"], ["4\n1 1\n3 1\n4 1\n2 1\n3\n5 2\n1 2\n1 2\n1\n1000 1001\n10\n5 62\n10 68\n15 72\n20 73\n25 75\n30 77\n35 79\n...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00003-of-00004.parquet#433"}
14a2d85f32dc6093
Polycarp likes numbers that are divisible by 3. He has a huge number $s$. Polycarp wants to cut from it the maximum number of numbers that are divisible by $3$. To do this, he makes an arbitrary number of vertical cuts between pairs of adjacent digits. As a result, after $m$ such cuts, there will be $m+1$ parts in tot...
[["3121\n", "2\n"], ["6\n", "1\n"], ["1000000000000000000000000000000000\n", "33\n"], ["201920181\n", "4\n"], ["4\n", "0\n"], ["10\n", "1\n"], ["11\n", "0\n"], ["12\n", "1\n"], ["13\n", "1\n"], ["31\n", "1\n"], ["14139582796\n", "6\n"], ["1670000\n", "5\n"], ["604500\n", "5\n"], ["40041\n", "2\n"], ["10000170\n", "5\n"...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00002-of-00004.parquet#750"}
14b0d0a635baeed2
Tanechka is shopping in the toy shop. There are exactly $n$ toys in the shop for sale, the cost of the $i$-th toy is $i$ burles. She wants to choose two toys in such a way that their total cost is $k$ burles. How many ways to do that does she have? Each toy appears in the shop exactly once. Pairs $(a, b)$ and $(b, a)$...
[["8 5\n", "2\n"], ["8 15\n", "1\n"], ["7 20\n", "0\n"], ["1000000000000 1000000000001\n", "500000000000\n"], ["1 1\n", "0\n"], ["44999999999177 100000000000000\n", "0\n"], ["100000000000000 100000000000000\n", "49999999999999\n"], ["99999999999999 65536\n", "32767\n"], ["1010101010 1010101010\n", "505050504\n"], ["100...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00003-of-00004.parquet#1849"}
14b12fa998fb6080
Peter is a senior manager of Agile Change Management (ACM) Inc., where each employee is a member of one or more task groups. Since ACM is agile, task groups are often reorganized and their members frequently change, so membership management is his constant headache. Peter updates the membership information whenever an...
[["2\ndevelopment:alice,bob,design,eve.\ndesign:carol,alice.\n3\none:another.\nanother:yetanother.\nxetanother:dave.\n3\nfriends:alice,bob,bestfriends,carol,fran,badcompany.\nbestfriends:eve,alice.\nbadcompany:dave,carol.\n5\na:b,c,d,e.\nb:c,d,e,f.\nc:d,e,f,g.\nd:e,f,g,h.\ne:f,g,h,i.\n4\naa:bb.\ncc:dd,ee.\nff:gg.\nbb:c...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00003-of-00004.parquet#1417"}
14cd8ec464682d13
While Mike was walking in the subway, all the stuff in his back-bag dropped on the ground. There were several fax messages among them. He concatenated these strings in some order and now he has string s. [Image] He is not sure if this is his own back-bag or someone else's. He remembered that there were exactly k me...
[["saba\n2\n", "NO\n"], ["saddastavvat\n2\n", "YES\n"], ["aaaaaaaaaa\n3\n", "NO\n"], ["aaaaaa\n3\n", "YES\n"], ["abaacca\n2\n", "NO\n"], ["a\n1\n", "YES\n"], ["princeofpersia\n1\n", "NO\n"], ["xhwbdoryfiaxglripavycmxmcejbcpzidrqsqvikfzjyfnmedxrvlnusavyhillaxrblkynwdrlhthtqzjktzkullgrqsolqssocpfwcaizhovajlhmeibhiuwtxplj...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00002-of-00004.parquet#1156"}
14d0971b9cddb647
Write a program which replace all the lower-case letters of a given text with the corresponding captital letters. Input A text including lower-case letters, periods, and space is given in a line. The number of characters in the text is less than or equal to 200. Output Print the converted text. Example Input t...
[["this is b pen.", "THIS IS B PEN.\n"], ["tiis is b pen.", "TIIS IS B PEN.\n"], ["tiis is a pen.", "TIIS IS A PEN.\n"], ["tiis it a pen.", "TIIS IT A PEN.\n"], ["tiis it a pem.", "TIIS IT A PEM.\n"], ["tiis it a .mep", "TIIS IT A .MEP\n"], ["tiis it b .mep", "TIIS IT B .MEP\n"], ["tiis it b pem.", "TIIS IT B PEM.\n"],...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00002-of-00004.parquet#5"}
14d2c0d765cdef4a
Jeff's friends know full well that the boy likes to get sequences and arrays for his birthday. Thus, Jeff got sequence p1, p2, ..., pn for his birthday. Jeff hates inversions in sequences. An inversion in sequence a1, a2, ..., an is a pair of indexes i, j (1 ≤ i < j ≤ n), such that an inequality ai > aj holds. Jeff c...
[["9\n-2 0 -1 0 -1 2 1 0 -1\n", "6"], ["2\n2 1\n", "0"], ["50\n-6 1 -3 7 -5 -5 4 0 3 -5 1 2 -1 0 7 0 6 3 -5 4 4 3 -7 -1 4 4 -5 3 7 1 4 2 6 -4 0 3 -3 -2 -3 1 -5 3 -4 2 -2 7 -1 3 -7 4\n", "260"], ["1\n0\n", "0"], ["24\n-1 -1 2 2 0 -2 2 -1 0 0 2 -2 3 0 2 -3 0 -3 -1 1 0 0 -1 -2\n", "55"], ["5\n1 0 1 -2 1\n", "1"], ["8\n0 1...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00002-of-00005.parquet#395"}
14e6f0620943abaf
You are given a sequence with N integers: A = \{ A_1, A_2, \cdots, A_N \}. For each of these N integers, we will choose a color and paint the integer with that color. Here the following condition must be satisfied: - If A_i and A_j (i < j) are painted with the same color, A_i < A_j. Find the minimum number of colors r...
[["5\n2\n1\n4\n5\n3\n", "2\n"], ["4\n0\n0\n0\n0\n", "4\n"], ["4\n0\n-1\n0\n0", "3\n"], ["4\n1\n0\n0\n0", "4\n"], ["5\n10\n-1\n1\n13\n3", "2\n"], ["5\n0\n0\n0\n0\n0", "5\n"], ["5\n1\n4\n5\n7\n14", "1\n"], ["5\n4\n1\n4\n5\n3", "3\n"], ["4\n1\n-1\n0\n0", "3\n"], ["5\n4\n1\n4\n9\n3", "3\n"], ["5\n7\n1\n4\n9\n3", "3\n"], ["...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00000-of-00004.parquet#1123"}
14fee4f79069384a
In the Kingdom of AtCoder, only banknotes are used as currency. There are 10^{100}+1 kinds of banknotes, with the values of 1, 10, 10^2, 10^3, \dots, 10^{(10^{100})}. You have come shopping at a mall and are now buying a takoyaki machine with a value of N. (Takoyaki is the name of a Japanese snack.) To make the payment...
[["36\n", "8\n"], ["91\n", "3\n"], ["314159265358979323846264338327950288419716939937551058209749445923078164062862089986280348253421170\n", "243\n"], ["30", "3\n"], ["476640020082194381531155118436783393866726953614433851622190777875571135215042541028243752681838573", "259\n"], ["22", "4\n"], ["41", "5\n"], ["40241905...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00003-of-00004.parquet#1832"}
15031bb942ccb402
The problem statement looms below, filling you with determination. Consider a grid in which some cells are empty and some cells are filled. Call a cell in this grid exitable if, starting at that cell, you can exit the grid by moving up and left through only empty cells. This includes the cell itself, so all filled in ...
[["4 5\n..XXX\n...X.\n...X.\n...X.\n5\n1 3\n3 3\n4 5\n5 5\n1 5\n", "YES\nYES\nNO\nYES\nNO\n"], ["1 1\nX\n1\n1 1\n", "YES\n"], ["1 1\n.\n1\n1 1\n", "YES\n"], ["3 3\n..X\n.X.\nX..\n10\n1 3\n1 3\n1 3\n2 3\n1 3\n1 2\n1 3\n2 2\n2 3\n2 2\n", "NO\nNO\nNO\nNO\nNO\nNO\nNO\nYES\nNO\nYES\n"], ["3 3\n...\nXXX\nXX.\n10\n2 3\n1 2\n2...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00003-of-00004.parquet#459"}
150fed3a377ac37f
A group of n cities is connected by a network of roads. There is an undirected road between every pair of cities, so there are <image> roads in total. It takes exactly y seconds to traverse any single road. A spanning tree is a set of roads containing exactly n - 1 roads such that it's possible to travel between any t...
[["5 3 2\n1 2\n1 3\n3 4\n5 3\n", "8"], ["5 2 3\n1 2\n1 3\n3 4\n5 3\n", "9"], ["5 2 2\n1 2\n1 3\n1 4\n1 5\n", "8"], ["2 3 4\n1 2\n", "3"], ["4 100 1\n1 2\n2 3\n3 4\n", "3"], ["50 23129 410924\n18 28\n17 23\n21 15\n18 50\n50 11\n32 3\n44 41\n50 31\n50 34\n5 14\n36 13\n22 40\n20 9\n9 43\n19 47\n48 40\n20 22\n33 45\n35 22\...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00002-of-00005.parquet#724"}
1518b940ba9b068b
Theofanis decided to visit his uncle's farm. There are $s$ animals and $n$ animal pens on the farm. For utility purpose, animal pens are constructed in one row. Uncle told Theofanis that a farm is lucky if you can distribute all animals in all pens in such a way that there are no empty pens and there is at least one c...
[["4\n1 1 1\n1 1 2\n100 50 200\n56220 47258 14497\n", "YES\nNO\nNO\nYES\n"], ["1\n1000000000000000000 500000000000000000 2\n", "NO\n"], ["1\n1000000000000000000 483271866988016482 2\n", "NO\n"], ["4\n1 1 1\n1 0 2\n100 50 200\n56220 47258 14497\n", "YES\nNO\nNO\nYES\n"], ["1\n1000000000000000000 639232692548497767 2\n",...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00002-of-00004.parquet#1057"}
1522d52938dc0d33
We conducted a survey on newspaper subscriptions. More specifically, we asked each of the N respondents the following two questions: * Question 1: Are you subscribing to Newspaper X? * Question 2: Are you subscribing to Newspaper Y? As the result, A respondents answered "yes" to Question 1, and B respondents answer...
[["10 2 5", "2 0\n"], ["100 100 000", "0 0\n"], ["10 1 5", "1 0\n"], ["101 110 000", "0 9\n"], ["101 110 100", "100 109\n"], ["101 100 100", "100 99\n"], ["100 110 100", "100 110\n"], ["000 110 100", "100 210\n"], ["0 2 1", "1 3\n"], ["000 100 100", "100 200\n"], ["0 3 1", "1 4\n"], ["16 1 22", "1 7\n"], ["000 100 000"...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00003-of-00004.parquet#1336"}
152e040c4529cbaf
You are given an undirected unweighted graph consisting of n vertices and m edges. You have to write a number on each vertex of the graph. Each number should be 1, 2 or 3. The graph becomes beautiful if for each edge the sum of numbers on vertices connected by this edge is odd. Calculate the number of possible ways t...
[["2\n2 1\n1 2\n4 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4\n", "4\n0\n"], ["12\n8 7\n2 3\n3 4\n4 5\n5 2\n6 7\n7 8\n8 6\n1 0\n2 1\n1 2\n3 3\n1 2\n2 3\n1 3\n3 2\n2 3\n3 1\n4 4\n1 2\n2 3\n3 4\n4 1\n4 4\n1 2\n2 3\n3 1\n4 1\n6 9\n1 4\n1 5\n1 6\n2 4\n2 5\n2 6\n3 4\n3 5\n3 6\n100000 0\n1000 5\n55 56\n56 57\n57 58\n58 59\n59 55\n11 11\...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00001-of-00005.parquet#2227"}
152e89bd16f3b931
All cities of Lineland are located on the Ox coordinate axis. Thus, each city is associated with its position xi — a coordinate on the Ox axis. No two cities are located at a single point. Lineland residents love to send letters to each other. A person may send a letter only if the recipient lives in another city (bec...
[["2\n-1 1\n", "2 2\n2 2\n"], ["4\n-5 -2 2 7\n", "3 12\n3 9\n4 7\n5 12\n"], ["3\n-1000000000 0 1000000000\n", "1000000000 2000000000\n1000000000 1000000000\n1000000000 2000000000\n"], ["5\n-2 -1 0 1 2\n", "1 4\n1 3\n1 2\n1 3\n1 4\n"], ["10\n-876779400 -829849659 -781819137 -570920213 18428128 25280705 121178189 2191472...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00001-of-00005.parquet#704"}
1531a66b03fb9615
Fukushima Prefecture is also famous for producing fruits, and among them, peaches and apples boast one of the highest production volumes in Japan. By the way, when I made a print manuscript of an English pamphlet for sale, I mistakenly wrote the description about apples and the description about peaches in reverse. Yo...
[["the cost of one peach is higher than th`t of one apple.", "the cost of one apple is higher than th`t of one peach.\n"], ["the cost of ooe peach is higher than th`t of one apple.", "the cost of ooe apple is higher than th`t of one peach.\n"], ["the cost of ooe peach is higher than th`t of eno apple.", "the cost of oo...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00000-of-00004.parquet#1339"}
15350ff2322059ee
Karen has just arrived at school, and she has a math test today! [Image] The test is about basic addition and subtraction. Unfortunately, the teachers were too busy writing tasks for Codeforces rounds, and had no time to make an actual test. So, they just put one question in the test that is worth all the points. Th...
[["5\n3 6 9 12 15\n", "36\n"], ["4\n3 7 5 2\n", "1000000006\n"], ["1\n1\n", "1\n"], ["16\n985629174 189232688 48695377 692426437 952164554 243460498 173956955 210310239 237322183 96515847 678847559 682240199 498792552 208770488 736004147 176573082\n", "347261016\n"], ["18\n341796022 486073481 86513380 593942288 6060616...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00002-of-00004.parquet#603"}
154694c59964998b
Peter has a sequence of integers a_1, a_2, ..., a_{n}. Peter wants all numbers in the sequence to equal h. He can perform the operation of "adding one on the segment [l, r]": add one to all elements of the sequence with indices from l to r (inclusive). At that, Peter never chooses any element as the beginning of the se...
[["3 2\n1 1 1\n", "4\n"], ["5 1\n1 1 1 1 1\n", "1\n"], ["4 3\n3 2 1 1\n", "0\n"], ["1 2000\n2000\n", "1\n"], ["3 2\n2 1 1\n", "2\n"], ["3 4\n4 3 2\n", "0\n"], ["10 6\n5 4 4 4 5 4 4 4 4 5\n", "972\n"], ["10 6\n5 4 4 4 5 4 4 4 4 5\n", "972\n"], ["7 4\n3 3 4 4 4 3 3\n", "4\n"], ["3 6\n5 6 5\n", "1\n"], ["3 2\n1 0 1\n", "2...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00003-of-00004.parquet#915"}
155ad69c5caa8b24
You are given a permutation $p$ of $n$ integers $1$, $2$, ..., $n$ (a permutation is an array where each element from $1$ to $n$ occurs exactly once). Let's call some subsegment $p[l, r]$ of this permutation special if $p_l + p_r = \max \limits_{i = l}^{r} p_i$. Please calculate the number of special subsegments. --...
[["5\n3 4 1 5 2\n", "2\n"], ["3\n1 3 2\n", "1\n"], ["3\n2 3 1\n", "1\n"], ["3\n3 2 1\n", "0\n"], ["5\n4 5 1 3 2\n", "2\n"], ["3\n2 1 3\n", "0\n"], ["3\n1 2 3\n", "0\n"], ["5\n5 4 1 3 2\n", "1\n"], ["5\n3 4 2 5 1\n", "1\n"], ["3\n3 1 2\n", "0\n"], ["3\n1 3 2\n", "1"], ["5\n3 4 1 5 2\n", "2"]]
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#1698"}
156bf1397d2e46da
You are given two integers $a$ and $b$. In one move, you can choose some integer $k$ from $1$ to $10$ and add it to $a$ or subtract it from $a$. In other words, you choose an integer $k \in [1; 10]$ and perform $a := a + k$ or $a := a - k$. You may use different values of $k$ in different moves. Your task is to find ...
[["6\n5 5\n13 42\n18 4\n1337 420\n123456789 1000000000\n100500 9000\n", "0\n3\n2\n92\n87654322\n9150\n"], ["1\n5 5\n", "0\n"], ["11\n5 5\n13 42\n18 4\n1337 420\n123456789 1000000000\n100500 9000\n5 5\n13 42\n18 4\n1337 420\n123456789 1000000000\n", "0\n3\n2\n92\n87654322\n9150\n0\n3\n2\n92\n87654322\n"], ["2\n5 5\n5 5\...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#527"}
156d94bc25c941a3
There are N people numbered 1 to N. Each of them is either an honest person whose testimonies are always correct or an unkind person whose testimonies may be correct or not. Person i gives A_i testimonies. The j-th testimony by Person i is represented by two integers x_{ij} and y_{ij}. If y_{ij} = 1, the testimony says...
[["3\n1\n2 1\n1\n1 1\n1\n2 0\n", "2\n"], ["3\n2\n2 1\n3 0\n2\n3 1\n1 0\n2\n1 1\n2 0\n", "0\n"], ["2\n1\n2 0\n1\n1 0\n", "1\n"], ["15\n14\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\n14\n1 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\n14\n1 1\n2 1\n4 1\n5 1\n6 ...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00003-of-00004.parquet#1792"}
1587d38d7be6600b
You have an array a consisting of n integers. Each integer from 1 to n appears exactly once in this array. For some indices i (1 ≤ i ≤ n - 1) it is possible to swap i-th element with (i + 1)-th, for other indices it is not possible. You may perform any number of swapping operations any order. There is no limit on the ...
[["6\n1 2 5 3 4 6\n01110\n", "YES\n"], ["6\n1 2 5 3 4 6\n01010\n", "NO\n"], ["6\n1 6 3 4 5 2\n01110\n", "NO\n"], ["6\n1 2 3 4 6 5\n00001\n", "YES\n"], ["6\n6 1 2 3 4 5\n10001\n", "NO\n"], ["11\n1 2 3 4 5 6 7 8 9 10 11\n0000000000\n", "YES\n"], ["5\n1 4 5 2 3\n1011\n", "NO\n"], ["4\n2 4 3 1\n011\n", "NO\n"], ["6\n1 5 3 ...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00002-of-00005.parquet#514"}
158b1c0b491329a8
Olya loves energy drinks. She loves them so much that her room is full of empty cans from energy drinks. Formally, her room can be represented as a field of n × m cells, each cell of which is empty or littered with cans. Olya drank a lot of energy drink, so now she can run k meters per second. Each second she chooses...
[["3 4 4\n....\n###.\n....\n1 1 3 1\n", "3"], ["2 2 1\n.#\n#.\n1 1 2 2\n", "-1\n"], ["3 4 1\n....\n###.\n....\n1 1 3 1\n", "8"], ["4 4 4\n...#\n.#.#\n....\n##..\n1 1 3 4\n", "2"], ["10 10 1\n##########\n#.........\n#.#######.\n#.#.....#.\n#.#.###.#.\n#.#.#.#.#.\n#.#.#.#.#.\n#.#.#...#.\n#.#.#####.\n#.#.......\n6 6 10 2\...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00002-of-00005.parquet#193"}
158fd6b17d357182
Captain Flint and his crew keep heading to a savage shore of Byteland for several months already, drinking rum and telling stories. In such moments uncle Bogdan often remembers his nephew Denis. Today, he has told a story about how Denis helped him to come up with an interesting problem and asked the crew to solve it. ...
[["2\n1\n3\n", "8\n998\n"], ["1\n2\n", "98\n"], ["1\n2\n", "98\n"], ["1\n4\n", "9998\n"], ["1\n5\n", "99988\n"], ["1\n1\n", "8\n"], ["2\n5649\n1961\n", "99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00003-of-00004.parquet#1854"}
159e3cd84b520353
Little Chris is bored during his physics lessons (too easy), so he has built a toy box to keep himself occupied. The box is special, since it has the ability to change gravity. There are n columns of toy cubes in the box arranged in a line. The i-th column contains a_{i} cubes. At first, the gravity in the box is pull...
[["4\n3 2 1 2\n", "1 2 2 3 \n"], ["3\n2 3 8\n", "2 3 8 \n"], ["5\n2 1 2 1 2\n", "1 1 2 2 2 \n"], ["1\n1\n", "1 \n"], ["2\n4 3\n", "3 4 \n"], ["6\n100 40 60 20 1 80\n", "1 20 40 60 80 100 \n"], ["10\n10 8 6 7 5 3 4 2 9 1\n", "1 2 3 4 5 6 7 8 9 10 \n"], ["10\n1 2 3 4 5 6 7 8 9 10\n", "1 2 3 4 5 6 7 8 9 10 \n"], ["100\n82...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00000-of-00004.parquet#189"}
15af466fd32b3702
Allen and Bessie are playing a simple number game. They both know a function f: \{0, 1\}^n → R, i. e. the function takes n binary arguments and returns a real value. At the start of the game, the variables x_1, x_2, ..., x_n are all set to -1. Each round, with equal probability, one of Allen or Bessie gets to make a mo...
[["2 0\n1 1 0 1\n", "0.75\n"], ["2 2\n0 1 2 3\n2 1\n0 4\n", "1.5\n1.25\n2.25\n"], ["1 0\n2 1\n", "1.5\n"], ["2 0\n1 0 0 1\n", "0.5\n"], ["2 2\n0 1 2 4\n2 1\n0 4\n", "1.75\n1.5\n2.5\n"], ["2 2\n0 1 2 4\n3 1\n0 4\n", "1.75\n1.0\n2.0\n"], ["2 2\n0 1 0 4\n3 1\n0 4\n", "1.25\n0.5\n1.5\n"], ["2 2\n0 1 0 4\n2 1\n0 4\n", "1.25...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00004-of-00005.parquet#1753"}
15bac643c0b5d383
This problem is same as the next one, but has smaller constraints. It was a Sunday morning when the three friends Selena, Shiro and Katie decided to have a trip to the nearby power station (do not try this at home). After arriving at the power station, the cats got impressed with a large power transmission system cons...
[["4\n0 0\n1 1\n0 3\n1 2", "14\n"], ["4\n0 0\n0 2\n0 4\n2 0\n", "6\n"], ["3\n-1 -1\n1 0\n3 1", "0\n"], ["2\n10000 10000\n-10000 -10000\n", "0\n"], ["5\n-8893 8986\n-3629 9045\n-7719 -6470\n-258 4491\n-6902 -6866\n", "45\n"], ["25\n1964 -4517\n5939 -4080\n9503 -7541\n-5037 -6950\n-9914 5015\n-435 7555\n-9321 -2202\n-503...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#529"}
15c72ec592356e85
There are $n$ points on a plane. The $i$-th point has coordinates $(x_i, y_i)$. You have two horizontal platforms, both of length $k$. Each platform can be placed anywhere on a plane but it should be placed horizontally (on the same $y$-coordinate) and have integer borders. If the left border of the platform is $(x, y)...
[["4\n7 1\n1 5 2 3 1 5 4\n1 3 6 7 2 5 4\n1 1\n1000000000\n1000000000\n5 10\n10 7 5 15 8\n20 199 192 219 1904\n10 10\n15 19 8 17 20 10 9 2 10 19\n12 13 6 17 1 14 7 9 19 3\n", "6\n1\n5\n10\n"], ["4\n1 1000000000\n1\n123456\n1 1000000000\n21345\n987654321\n1 1000000000\n1000000000\n1000000000\n1 1000000000\n1000000000\n1\...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#564"}
15c96d31f9063774
For a dynamic array $A = \\{a_0, a_1, ...\\}$ of integers, perform a sequence of the following operations: * push($d$, $x$): Add element $x$ at the begining of $A$, if $d = 0$. Add element $x$ at the end of $A$, if $d = 1$. * randomAccess($p$): Print element $a_p$. * pop($d$): Delete the first element of $A$, if $d = ...
[["11\n0 0 1\n0 0 2\n0 1 3\n1 0\n1 1\n1 0\n2 0\n2 1\n0 0 4\n1 0\n1 1", "2\n1\n2\n4\n1\n"], ["11\n0 0 1\n0 0 2\n0 1 3\n1 0\n1 1\n1 0\n2 0\n2 1\n0 0 4\n1 0\n2 1", "2\n1\n2\n4\n"], ["11\n0 0 1\n0 0 3\n0 1 3\n1 0\n1 1\n1 0\n2 0\n2 1\n0 0 4\n1 0\n2 1", "3\n1\n3\n4\n"], ["11\n0 0 1\n0 0 3\n0 1 3\n1 0\n1 1\n1 0\n2 0\n2 1\n0 0...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#1316"}
15d54e388fd25217
Recall that MEX of an array is a minimum non-negative integer that does not belong to the array. Examples: for the array $[0, 0, 1, 0, 2]$ MEX equals to $3$ because numbers $0, 1$ and $2$ are presented in the array and $3$ is the minimum non-negative integer not presented in the array; for the array $[1, 2, 3, 4]$ ME...
[["7 3\n0\n1\n2\n2\n0\n0\n10\n", "1\n2\n3\n3\n4\n4\n7\n"], ["4 3\n1\n2\n1\n2\n", "0\n0\n0\n0\n"], ["4 3\n1\n2\n1\n3\n", "0\n0\n0\n3\n"], ["3 3\n0\n1\n2\n2\n0\n0\n10\n", "1\n2\n3\n"], ["4 2\n1\n2\n1\n0\n", "0\n2\n2\n4\n"], ["4 2\n1\n3\n1\n0\n", "0\n0\n0\n2\n"], ["4 2\n1\n3\n2\n0\n", "0\n0\n2\n4\n"], ["4 2\n0\n3\n2\n0\n"...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00002-of-00004.parquet#303"}
15d6f78f1306b05a
Given is a string S of length N-1. Each character in S is `<` or `>`. A sequence of N non-negative integers, a_1,a_2,\cdots,a_N, is said to be good when the following condition is satisfied for all i (1 \leq i \leq N-1): * If S_i= `<`: a_i<a_{i+1} * If S_i= `>`: a_i>a_{i+1} Find the minimum possible sum of the ele...
[[">><", "4\n"], ["<>>><<<<<><<>>><", "29\n"], ["><>", "2\n"], ["<>>>><<<<><<<>><", "28\n"], ["<>><<<><<<<>>>><", "26\n"], ["<<>><<><<<<>>>><", "24\n"], ["<>>>><<<<><<>><<", "27\n"], ["<>>>>><<<><<<><<", "30\n"], ["<>>><>><<><<<><<", "21\n"], ["<<><<<><<>><>>><", "20\n"], ["<<>>>><<<><><><<", "22\n"], ["<>>>>><<<><<<<<...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00002-of-00004.parquet#955"}
15da5113f2e20c8d
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can ca...
[["4 0 0\n1 1\n2 2\n2 0\n-1 -1\n", "2\n"], ["2 1 2\n1 1\n1 0\n", "1\n"], ["1 1 1\n0 0\n", "1\n"], ["2 0 0\n10000 -10000\n-10000 10000\n", "1\n"], ["2 0 0\n10000 -10000\n10000 10000\n", "2\n"], ["10 -4 -4\n2 -4\n2 0\n-4 2\n5 -4\n-3 -5\n1 4\n-4 2\n-3 5\n0 -3\n2 4\n", "8\n"], ["10 5 -3\n1 1\n2 -1\n2 2\n1 -2\n4 -5\n1 4\n0 ...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00003-of-00004.parquet#469"}
15eaf067db37b295
We have a tree with N vertices and N-1 edges, respectively numbered 1, 2,\cdots, N and 1, 2, \cdots, N-1. Edge i connects Vertex u_i and v_i. For integers L, R (1 \leq L \leq R \leq N), let us define a function f(L, R) as follows: - Let S be the set of the vertices numbered L through R. f(L, R) represents the number o...
[["3\n1 3\n2 3\n", "7\n"], ["2\n1 2\n", "3\n"], ["10\n5 3\n5 7\n8 9\n1 9\n9 10\n8 4\n7 4\n6 10\n7 2\n", "113\n"], ["2\n0 2", "4\n"], ["10\n5 3\n5 7\n8 9\n0 9\n9 10\n8 4\n7 4\n6 10\n7 2", "115\n"], ["3\n1 3\n0 3", "9\n"], ["10\n5 3\n5 7\n8 9\n0 9\n12 10\n8 4\n7 4\n6 10\n7 2", "134\n"], ["2\n-1 1", "6\n"], ["10\n5 3\n5 7...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00003-of-00004.parquet#1660"}
15f1b1a38da5e359
Little Petya likes permutations a lot. Recently his mom has presented him permutation q_1, q_2, ..., q_{n} of length n. A permutation a of length n is a sequence of integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ n), all integers there are distinct. There is only one thing Petya likes more than permutations: playing with...
[["4 1\n2 3 4 1\n1 2 3 4\n", "NO\n"], ["4 1\n4 3 1 2\n3 4 2 1\n", "YES\n"], ["4 3\n4 3 1 2\n3 4 2 1\n", "YES\n"], ["4 2\n4 3 1 2\n2 1 4 3\n", "YES\n"], ["4 1\n4 3 1 2\n2 1 4 3\n", "NO\n"], ["4 3\n4 3 1 2\n2 1 4 3\n", "NO\n"], ["4 3\n2 1 4 3\n4 3 1 2\n", "NO\n"], ["4 1\n2 1 4 3\n2 1 4 3\n", "YES\n"], ["4 2\n2 1 4 3\n2 1...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#30"}
160212b5adc306b2
Gennady owns a small hotel in the countryside where he lives a peaceful life. He loves to take long walks, watch sunsets and play cards with tourists staying in his hotel. His favorite game is called "Mau-Mau". To play Mau-Mau, you need a pack of $52$ cards. Each card has a suit (Diamonds — D, Clubs — C, Spades — S, o...
[["AS\n2H 4C TH JH AD\n", "YES\n"], ["2H\n3D 4C AC KD AS\n", "NO\n"], ["4D\nAS AC AD AH 5H\n", "YES\n"], ["3D\n8S 4S 2C AS 6H\n", "NO\n"], ["7H\nTC 4C KC AD 9S\n", "NO\n"], ["KH\n3C QD 9S KS 8D\n", "YES\n"], ["4H\nJH QC 5H 9H KD\n", "YES\n"], ["9H\nKC 6D KD 4C 2S\n", "NO\n"], ["AD\nQC 5S 4H JH 2S\n", "NO\n"], ["QC\nQD ...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00002-of-00004.parquet#754"}
1608223ef82ffb5d
Chef likes rectangles. Among all possible rectangles, he loves rectangles that can be drawn like a grid, such that they have N rows and M columns. Grids are common in Byteland. Hence, Chef has drawn such a rectangle and plans on moving around in it. The rows of the rectangle are labeled from 1 to N from top to bottom....
[["3\n2 2 1\n3 3 2\n1 5 12", "1\n1\n12"], ["3\n2 2 1\n3 1 2\n1 5 12", "1\n2\n12\n"], ["3\n2 2 2\n3 2 2\n1 5 12", "1\n1\n12\n"], ["3\n2 2 2\n4 2 2\n1 5 2", "1\n1\n2\n"], ["3\n2 7 2\n4 2 2\n1 9 0", "1\n1\n0\n"], ["3\n2 2 2\n4 2 2\n2 5 12", "1\n1\n6\n"], ["3\n2 7 2\n4 2 2\n1 9 4", "1\n1\n4\n"], ["3\n2 9 2\n4 2 2\n1 9 -1",...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#1005"}
1609a4483969fb9c
There is a colony of villains with several holes aligned in a row, where each hole contains exactly one villain. Each colony arrangement can be expressed as a string of even length, where the i-th character of the string represents the type of villain in the i-th hole. Iron Man can destroy a colony only if the colon...
[["abcd\n1\n1 3\n", "8\n"], ["abba\n2\n1 4\n1 2\n", "2\n0\n"], ["AAaa\n2\n1 2\n1 3\n", "2\n0\n"], ["sYDMlMKcqjyzmIKKjjcNyUgaixfaNUJYXjHXRHiRzNyHysnxTt\n68\n19 15\n46 34\n38 30\n50 39\n22 11\n4 14\n23 2\n10 47\n42 15\n9 5\n38 40\n43 16\n11 46\n29 46\n49 5\n28 1\n33 22\n48 8\n5 33\n8 34\n31 4\n49 3\n22 21\n31 22\n13 48\n...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00002-of-00005.parquet#105"}
161c3c3599cb8253
There is a rectangular grid of size $n \times m$. Each cell has a number written on it; the number on the cell ($i, j$) is $a_{i, j}$. Your task is to calculate the number of paths from the upper-left cell ($1, 1$) to the bottom-right cell ($n, m$) meeting the following constraints: You can move to the right or to t...
[["3 3 11\n2 1 5\n7 10 0\n12 6 4\n", "3\n"], ["3 4 2\n1 3 3 3\n0 3 3 2\n3 0 1 1\n", "5\n"], ["3 4 1000000000000000000\n1 3 3 3\n0 3 3 2\n3 0 1 1\n", "0\n"], ["1 1 1000000000000000000\n1000000000000000000\n", "1\n"], ["1 1 1000000000000000000\n999999999999999999\n", "0\n"], ["1 1 1\n1\n", "1\n"], ["1 2 3\n1 2\n", "1\n"]...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00002-of-00004.parquet#1744"}
16273c458ea6559f
Dora loves adventures quite a lot. During some journey she encountered an amazing city, which is formed by $n$ streets along the Eastern direction and $m$ streets across the Southern direction. Naturally, this city has $nm$ intersections. At any intersection of $i$-th Eastern street and $j$-th Southern street there is ...
[["2 3\n1 2 1\n2 1 2\n", "2 2 2 \n2 2 2 \n"], ["2 2\n1 2\n3 4\n", "2 3 \n3 2 \n"], ["1 1\n1543\n", "1 \n"], ["2 1\n179\n1329\n", "2 \n2 \n"], ["1 2\n66 699\n", "2 2 \n"], ["2 2\n2 2\n2 2\n", "1 1 \n1 1 \n"], ["2 2\n1 1000000000\n1 1000000000\n", "2 2 \n2 2 \n"], ["1 4\n1 5 4 3\n", "4 4 4 4 \n"], ["3 1\n1\n7\n9\n", "3 \...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00003-of-00005.parquet#1984"}
162c45bb675e6418
Mr. Dango's family has extremely huge number of members. Once it had about 100 members, and now it has as many as population of a city. It is jokingly guessed that the member might fill this planet in near future. They all have warm and gracious personality and are close each other. They usually communicate by a phone...
[["3\n1 1 2 3\n0 1 2 2\n1 2 0 3\n7\n1 2 2 1\n0 2 3 2\n0 1 3 1\n2 1 1 2\n5 3 4 2\n4 3 6 1\n4 2 5 1\n0", "1\n2\n"], ["3\n1 2 2 3\n0 1 2 2\n1 2 0 3\n7\n1 2 0 1\n0 2 3 1\n0 0 3 1\n2 1 1 2\n5 3 4 2\n4 3 6 0\n4 -1 5 1\n0", "1\n1\n"], ["3\n1 2 2 3\n0 1 2 2\n1 2 0 3\n7\n1 2 0 1\n0 2 3 2\n0 0 3 2\n2 2 1 2\n5 3 4 2\n4 3 6 1\n4 0...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00002-of-00004.parquet#55"}
162dd5519f97b23a
"QAQ" is a word to denote an expression of crying. Imagine "Q" as eyes with tears and "A" as a mouth. Now Diamond has given Bort a string consisting of only uppercase English letters of length n. There is a great number of "QAQ" in the string (Diamond is so cute!). $8$ illustration by 猫屋 https://twitter.com/nekoyaliu ...
[["QAQAQYSYIOIWIN\n", "4\n"], ["QAQQQZZYNOIWIN\n", "3\n"], ["QA\n", "0\n"], ["IAQVAQZLQBQVQFTQQQADAQJA\n", "24\n"], ["QQAAQASGAYAAAAKAKAQIQEAQAIAAIAQQQQQ\n", "378\n"], ["AMVFNFJIAVNQJWIVONQOAOOQSNQSONOASONAONQINAONAOIQONANOIQOANOQINAONOQINAONOXJCOIAQOAOQAQAQAQAQWWWAQQAQ\n", "1077\n"], ["AAQQAXBQQBQQXBNQRJAQKQNAQNQVDQAS...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00002-of-00004.parquet#1115"}
1633741b22f260d7
I have a sequence defined as follows: * All even-numbered terms are equal to the previous term multiplied by 2. * All odd-numbered terms are equal to the previous term divided by 3. Create a program that reads the first term a of this sequence and outputs the sum s (10) from the first term to the tenth term. Inp...
[["1.0\n2.0\n3.0275795971873247", "7.81481481481\n15.6296296296\n23.6599738891\n"], ["1.0\n2.0\n3.649719120761334", "7.81481481481\n15.6296296296\n28.5218790548\n"], ["1.0\n2.783489291479195\n3.649719120761334", "7.81481481481\n21.7524533519\n28.5218790548\n"], ["1.0\n2.783489291479195\n4.155640422734946", "7.814814814...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00004-of-00005.parquet#391"}
163cc593731ff39b
There are b blocks of digits. Each one consisting of the same n digits, which are given to you in the input. Wet Shark must choose exactly one digit from each block and concatenate all of those digits together to form one large integer. For example, if he chooses digit 1 from the first block and digit 2 from the second...
[["12 1 5 10\n3 5 6 7 8 9 5 1 1 1 1 5\n", "3\n"], ["3 2 1 2\n6 2 2\n", "0\n"], ["3 2 1 2\n3 1 2\n", "6\n"], ["3 2 1 2\n6 3 2\n", "3\n"], ["3 2 1 2\n3 6 3\n", "6\n"], ["3 2 0 2\n3 3 9\n", "0\n"], ["3 2 0 2\n4 5 1\n", "3\n"], ["3 2 0 2\n1 3 2\n", "3\n"], ["3 2 1 2\n5 9 3\n", "9\n"], ["3 2 1 2\n7 2 4\n", "3\n"], ["6 5 2 1...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00000-of-00004.parquet#1150"}
16409ff821836cc1
There is a game that uses numbers called "Fizz Buzz". In this game, multiple players count the numbers one by one, starting with 1, and each player says only one number after the previous player. At that time, you must say "Fizz" if it is divisible by 3, "Buzz" if it is divisible by 5, and "FizzBuzz" if it is divisible...
[["5 7\n1\n0\nFizz\n4\nBuzz\n6\n7\n3 5\n1\n2\n3\n4\n5\n0 0", "3 4 5\n1\n"], ["5 7\n1\n0\nFizz\n4\nBuzz\n6\n2\n3 5\n1\n2\n3\n4\n5\n0 0", "4 5\n1\n"], ["5 7\n1\n0\nFizz\n2\nBuzz\n6\n2\n3 5\n1\n2\n4\n4\n8\n0 0", "5\n1\n"], ["5 7\n1\n0\nFizz\n2\nzuzB\n6\n2\n3 5\n1\n2\n4\n4\n8\n0 0", "3\n1\n"], ["5 7\n1\n2\nFizz\n4\nBuzz\n6...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#327"}
164130bced573862
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 that is forgotten, in t...
[["nolon\n", "2\n"], ["otto\n", "1\n"], ["qqqq\n", "Impossible\n"], ["kinnikkinnik\n", "1\n"], ["nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnznnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00000-of-00004.parquet#669"}
165118b39bae2b3c
Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'. You are given a set of q possible operations. Limak can perform them in any order, ...
[["6 2\nbb a\nba a\n", "0\n"], ["2 8\naf e\ndc d\ncc f\nbc b\nda b\neb a\nbb b\nff c\n", "1\n"], ["3 5\nab a\ncc c\nca a\nee c\nff d\n", "4\n"], ["6 36\nac a\naf a\ndb a\nab a\ncb a\nef a\nad a\nbd a\nfe a\nde a\nbe a\nbb a\naa a\nae a\ndf a\nbc a\nbf a\nce a\nba a\nfd a\ndc a\neb a\ncd a\nca a\nee a\ncc a\ncf a\ndd a\...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00001-of-00005.parquet#2615"}
1659c622c38a8cb1
Cheaterius is a famous in all the Berland astrologist, magician and wizard, and he also is a liar and a cheater. One of his latest inventions is Cheaterius' amulets! They bring luck and wealth, but are rather expensive. Cheaterius makes them himself. The technology of their making is kept secret. But we know that throu...
[["4\n36\n44\n**\n32\n46\n**\n66\n41\n**\n64\n34\n", "3\n"], ["3\n14\n54\n**\n45\n41\n**\n12\n22\n", "2\n"], ["7\n21\n33\n**\n33\n12\n**\n32\n31\n**\n21\n33\n**\n33\n12\n**\n32\n31\n**\n13\n23\n", "1\n"], ["3\n63\n63\n**\n66\n33\n**\n36\n36\n", "1\n"], ["4\n56\n61\n**\n31\n31\n**\n33\n11\n**\n11\n33\n", "2\n"], ["3\n11...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#557"}
165ab0d6924202e3
There are a number of ways to shuffle a deck of cards. Hanafuda shuffling for Japanese card game 'Hanafuda' is one such example. The following is how to perform Hanafuda shuffling. There is a deck of n cards. Starting from the p-th card from the top of the deck, c cards are pulled out and put on the top of the deck, a...
[["5 2\n3 1\n3 1\n10 3\n1 10\n10 1\n8 0\n0 0", "4\n1\n"], ["5 0\n3 1\n3 1\n10 3\n1 10\n10 1\n8 0\n0 0", "5\n1\n1\n"], ["5 0\n3 1\n3 1\n10 2\n1 10\n10 1\n11 0\n0 0", "5\n1\n1\n11\n"], ["5 2\n3 1\n3 1\n10 3\n1 11\n10 1\n8 3\n0 0", "4\n4\n"], ["6 2\n3 1\n3 1\n10 3\n1 10\n10 1\n8 0\n0 0", "5\n1\n"], ["5 0\n3 1\n3 1\n10 3\n...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00000-of-00004.parquet#1637"}
16689a0ec7ada61a
In Chelyabinsk lives a much respected businessman Nikita with a strange nickname "Boss". Once Nikita decided to go with his friend Alex to the Summer Biathlon World Cup. Nikita, as a very important person, received a token which allows to place bets on each section no more than on one competitor. To begin with friends...
[["20 30\n5 10 38 50\n17 18 86 42\n4 13 91 90\n20 20 45 31\n3 3 16 11\n16 16 80 66\n19 19 96 26\n15 20 7 84\n9 18 45 36\n5 19 89 6\n9 9 4 58\n9 14 97 31\n6 12 74 90\n4 5 84 2\n12 19 92 48\n16 16 92 55\n9 15 88 38\n6 14 8 66\n14 17 71 91\n20 20 58 20\n8 18 5 47\n7 19 67 43\n19 19 88 80\n9 12 35 86\n4 4 82 22\n7 8 72 82\...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00002-of-00004.parquet#1248"}
16750633eb006473
Makoto has a big blackboard with a positive integer $n$ written on it. He will perform the following action exactly $k$ times: Suppose the number currently written on the blackboard is $v$. He will randomly pick one of the divisors of $v$ (possibly $1$ and $v$) and replace $v$ with this divisor. As Makoto uses his fam...
[["6 1\n", "3\n"], ["6 2\n", "875000008\n"], ["60 5\n", "237178099\n"], ["55 5\n", "789062507\n"], ["935 9\n", "658825880\n"], ["1 10000\n", "1\n"], ["120 1\n", "500000026\n"], ["1000000000000000 10000\n", "215514159\n"], ["671058194037157 8673\n", "298638658\n"], ["128973636102142 5521\n", "99152648\n"], ["99999999999...
3.59
{"source": "deepcoder/taco", "upstream_id": "taco/train-00002-of-00004.parquet#251"}
168155afbc13ca3f
Stellar history 2005.11.5. You are about to engage an enemy spacecraft as the captain of the UAZ Advance spacecraft. Fortunately, the enemy spaceship is still unnoticed. In addition, the space coordinates of the enemy are already known, and the "feather cannon" that emits a powerful straight beam is ready to launch. Af...
[["-10 6 6\n10 2 6\n0 10 0\n0 10 10\n0 0 10", "MISS\n"], ["-10 0 0\n10 0 0\n0 10 0\n0 10 10\n0 1 10", "HIT\n"], ["-10 6 6\n20 2 6\n0 10 0\n0 10 10\n0 0 10", "MISS\n"], ["-10 0 0\n10 0 0\n0 10 0\n0 0 10\n0 1 10", "HIT\n"], ["-10 6 6\n20 2 6\n0 10 1\n0 10 10\n0 0 10", "MISS\n"], ["-10 -1 0\n10 0 0\n0 10 0\n0 0 10\n0 1 10...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00002-of-00004.parquet#1292"}
16830377e68df802
There are N items, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), Item i has a weight of w_i and a value of v_i. Taro has decided to choose some of the N items and carry them home in a knapsack. The capacity of the knapsack is W, which means that the sum of the weights of items taken must be at most W. Find ...
[["1 1000000000\n0000000000 10", "10\n"], ["6 15\n6 5\n5 6\n3 4\n6 6\n3 5\n7 2", "17\n"], ["3 8\n3 30\n4 35\n5 60", "90\n"], ["3 8\n3 30\n4 35\n5 78", "108\n"], ["6 15\n6 5\n0 6\n3 4\n6 6\n3 5\n7 3", "22\n"], ["3 8\n3 30\n0 35\n5 78", "143\n"], ["2 8\n3 30\n4 50\n5 60", "80\n"], ["1 1000000000\n0000000000 7", "7\n"], [...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00002-of-00004.parquet#1299"}
1684f932c4d83466
Given is a positive integer N. We will choose an integer K between 2 and N (inclusive), then we will repeat the operation below until N becomes less than K. - Operation: if K divides N, replace N with N/K; otherwise, replace N with N-K. In how many choices of K will N become 1 in the end? -----Constraints----- - 2 \...
[["6\n", "3\n"], ["3141\n", "13\n"], ["314159265358\n", "9\n"], ["1000000000000\n", "266\n"], ["642507465600\n", "12\n"], ["2\n", "1\n"], ["4294967296\n", "37\n"], ["260522\n", "9\n"], ["914575\n", "8\n"], ["436426\n", "37\n"], ["540024979445\n", "12\n"], ["917861648772\n", "7\n"], ["962623690081\n", "96\n"], ["5239689...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00003-of-00004.parquet#1826"}
169685b047f0e062
There are two infinite sources of water: * hot water of temperature h; * cold water of temperature c (c < h). You perform the following procedure of alternating moves: 1. take one cup of the hot water and pour it into an infinitely deep barrel; 2. take one cup of the cold water and pour it into an infin...
[["3\n30 10 20\n41 15 30\n18 13 18\n", "2\n7\n1\n"], ["1\n999855 999262 999557\n", "2\n"], ["1\n114515 114514 114514\n", "2\n"], ["1\n1138 4 643\n", "7\n"], ["1\n159385 114514 114514\n", "2\n"], ["3\n30 10 20\n41 15 26\n18 13 18\n", "2\n2\n1\n"], ["1\n1138 4 431\n", "2\n"], ["1\n1437 4 431\n", "2\n"], ["1\n1437 5 431\n...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00001-of-00005.parquet#1733"}
16abe4023045a350
Limak is a little polar bear. He has n balls, the i-th ball has size t_{i}. Limak wants to give one ball to each of his three friends. Giving gifts isn't easy — there are two rules Limak must obey to make friends happy: No two friends can get balls of the same size. No two friends can get balls of sizes that differ ...
[["4\n18 55 16 17\n", "YES\n"], ["6\n40 41 43 44 44 44\n", "NO\n"], ["8\n5 972 3 4 1 4 970 971\n", "YES\n"], ["3\n959 747 656\n", "NO\n"], ["4\n1 2 2 3\n", "YES\n"], ["50\n998 30 384 289 505 340 872 223 663 31 929 625 864 699 735 589 676 399 745 635 963 381 75 97 324 612 597 797 103 382 25 894 219 458 337 572 201 355 2...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00000-of-00004.parquet#1668"}