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
0e72565efc8de81b
Polycarp calls an array dense if the greater of any two adjacent elements is not more than twice bigger than the smaller. More formally, for any $i$ ($1 \le i \le n-1$), this condition must be satisfied: $$\frac{\max(a[i], a[i+1])}{\min(a[i], a[i+1])} \le 2$$ For example, the arrays $[1, 2, 3, 4, 3]$, $[1, 1, 1]$ and ...
[["6\n4\n4 2 10 1\n2\n1 3\n2\n6 1\n3\n1 4 2\n5\n1 2 3 4 3\n12\n4 31 25 50 30 20 34 46 42 16 15 16\n", "5\n1\n2\n1\n0\n3\n"], ["6\n4\n4 2 10 1\n2\n1 3\n2\n6 1\n3\n1 4 2\n5\n1 2 3 4 3\n12\n4 27 25 50 30 20 34 46 42 16 15 16\n", "5\n1\n2\n1\n0\n3\n"], ["6\n4\n4 2 10 1\n2\n1 3\n2\n6 1\n3\n1 4 2\n5\n1 2 3 4 3\n12\n4 27 25 5...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00002-of-00004.parquet#1313"}
0e72d98b2d8e6115
Given is a string S. Each character in S is either a digit (0, ..., 9) or ?. Among the integers obtained by replacing each occurrence of ? with a digit, how many have a remainder of 5 when divided by 13? An integer may begin with 0. Since the answer can be enormous, print the count modulo 10^9+7. -----Constraints-----...
[["??2??5\n", "768\n"], ["?44\n", "1\n"], ["?6?42???8??2??06243????9??3???7258??5??7???????774????4?1??17???9?5?70???76???\n", "153716888\n"], ["???0??78282200?56??4??92?1??6??6?????3?8?578???2?3?5????9???????????8???8???80???????049??????414????3???330??59?????90?0???6?14??8??98??77??1??4?833??12???????9??7???3?89?7??...
4
{"source": "deepcoder/taco", "upstream_id": "taco/train-00002-of-00004.parquet#941"}
0e7d35e0a725691d
Several months later Alex finally got his brother Bob's creation by post. And now, in his turn, Alex wants to boast about something to his brother. He thought for a while, and came to the conclusion that he has no ready creations, and decided to write a program for rectangles detection. According to his plan, the progr...
[["2 -1 -2 -1\n2 -1 2 -1\n2 -1 -2 -1\n2 -1 2 -1\n", "NO\n"], ["0 0 0 1\n0 1 0 1\n0 1 0 0\n0 1 0 1\n", "NO\n"], ["0 0 2 2\n0 0 2 0\n2 2 2 2\n0 2 0 2\n", "NO\n"], ["130120899 550158649 130120899 831843953\n130120899 550158649 130120899 831843953\n130120899 550158649 434006978 831843953\n434006978 550158649 434006978 5501...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#1452"}
0e83420a03b49bfd
Alex, Bob and Carl will soon participate in a team chess tournament. Since they are all in the same team, they have decided to practise really hard before the tournament. But it's a bit difficult for them because chess is a game for two players, not three. So they play with each other according to following rules: ...
[["2\n1\n2\n", "NO\n"], ["3\n1\n1\n2\n", "YES\n"], ["99\n1\n3\n2\n2\n3\n1\n1\n3\n3\n3\n3\n3\n3\n1\n1\n3\n3\n3\n3\n1\n1\n3\n2\n1\n1\n1\n1\n1\n1\n1\n3\n2\n2\n2\n1\n3\n3\n1\n1\n3\n2\n1\n3\n3\n1\n2\n3\n3\n3\n1\n2\n2\n2\n3\n3\n3\n3\n3\n3\n2\n2\n2\n2\n3\n3\n3\n1\n1\n3\n2\n1\n1\n2\n2\n2\n3\n3\n2\n1\n1\n2\n2\n1\n3\n2\n1\n1\n2\...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00000-of-00005.parquet#2883"}
0e9b8a6a9fabb281
You are planning to build housing on a street. There are $n$ spots available on the street on which you can build a house. The spots are labeled from $1$ to $n$ from left to right. In each spot, you can build a house with an integer height between $0$ and $h$. In each spot, if a house has height $a$, you will gain $a^...
[["3 3 3\n1 1 1\n2 2 3\n3 3 2\n", "14\n"], ["4 10 2\n2 3 8\n3 4 7\n", "262\n"], ["50 50 1\n1 50 0\n", "0\n"], ["50 50 50\n17 40 12\n33 36 47\n8 43 35\n25 29 42\n18 36 6\n25 35 18\n36 48 47\n17 40 13\n20 27 37\n32 32 28\n17 20 13\n4 14 6\n13 18 47\n18 45 28\n3 50 45\n6 6 6\n3 25 36\n28 48 42\n14 34 32\n28 41 35\n29 35 2...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00000-of-00005.parquet#953"}
0eaacd376083c4fa
The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by $s$ liters of k...
[["3 3\n4 3 5\n", "3\n"], ["3 4\n5 3 4\n", "2\n"], ["3 7\n1 2 3\n", "-1\n"], ["1 1\n1\n", "0\n"], ["1 2\n1\n", "-1\n"], ["5 10\n10 10 10 10 10\n", "8\n"], ["1 1000000000\n1000000000\n", "0\n"], ["1 1000000000000\n42\n", "-1\n"], ["3 2\n1 1 5\n", "1\n"], ["2 1\n1 100\n", "1\n"], ["3 1\n5 10 15\n", "5\n"], ["2 1\n1 1000\...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00000-of-00004.parquet#407"}
0eab6da5412ff043
Dima got into number sequences. Now he's got sequence a_1, a_2, ..., a_{n}, consisting of n positive integers. Also, Dima has got a function f(x), which can be defined with the following recurrence: f(0) = 0; f(2·x) = f(x); f(2·x + 1) = f(x) + 1. Dima wonders, how many pairs of indexes (i, j) (1 ≤ i < j ≤ n) are t...
[["3\n1 2 4\n", "3\n"], ["3\n5 3 1\n", "1\n"], ["2\n469264357 996569493\n", "0\n"], ["6\n396640239 62005863 473635171 329666981 510631133 207643327\n", "2\n"], ["8\n851991424 32517099 310793856 776130403 342626527 58796623 49544509 517126753\n", "2\n"], ["7\n481003311 553247971 728349004 258700257 916143165 398096105 4...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00002-of-00004.parquet#1441"}
0eaec686c7000ea3
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation a_{i}x + b_{i}y + c_{i} = 0, where a_{i} and b_{i} are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an interse...
[["1 1\n-1 -1\n2\n0 1 0\n1 0 0\n", "2\n"], ["1 1\n-1 -1\n3\n1 0 0\n0 1 0\n1 1 -3\n", "2\n"], ["841746 527518\n595261 331297\n10\n-946901 129987 670374\n-140388 -684770 309555\n-302589 415564 -387435\n-565799 -72069 -395358\n-523453 -511446 854898\n-846967 -749453 -341866\n-622388 434663 264157\n-638453 625357 344195\n-...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#177"}
0eb480836aab8c24
You are given a book with n chapters. Each chapter has a specified list of other chapters that need to be understood in order to understand this chapter. To understand a chapter, you must read it after you understand every chapter on its required list. Currently you don't understand any of the chapters. You are going...
[["5\n4\n1 2\n0\n2 1 4\n1 2\n5\n1 5\n1 1\n1 1\n1 3\n1 4\n5\n0\n0\n2 1 2\n1 2\n2 2 1\n4\n2 2 3\n0\n0\n2 3 2\n5\n1 2\n1 3\n1 4\n1 5\n0\n", "2\n-1\n1\n2\n5\n"], ["5\n4\n1 2\n0\n2 1 4\n1 2\n5\n1 5\n1 1\n1 1\n1 3\n1 4\n5\n0\n0\n2 1 2\n1 2\n2 2 1\n4\n2 2 3\n0\n0\n2 3 2\n5\n1 2\n1 3\n1 4\n1 3\n0\n", "2\n-1\n1\n2\n-1\n"], ["5\...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#1174"}
0ebd5f116fc6e9ff
For a given polygon g, computes the area of the polygon. g is represented by a sequence of points p1, p2,..., pn where line segments connecting pi and pi+1 (1 ≤ i ≤ n-1) are sides of g. The line segment connecting pn and p1 is also a side of the polygon. Note that the polygon is not necessarily convex. Constraints ...
[["4\n0 0\n1 1\n1 2\n-1 2", "2.5\n"], ["4\n0 0\n1 1\n1 2\n-1 4", "3.5\n"], ["3\n1 0\n2 4\n-1 1", "4.5\n"], ["4\n0 0\n1 1\n2 2\n-1 4", "5.0\n"], ["3\n2 0\n2 2\n-1 1", "3.0\n"], ["3\n3 0\n2 2\n-1 0", "4.0\n"], ["4\n0 -1\n0 1\n1 2\n-1 1", "1.5\n"], ["3\n3 0\n2 2\n-2 -1", "5.5\n"], ["3\n3 0\n2 2\n-2 -2", "6.0\n"], ["4\n0 -...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00002-of-00004.parquet#103"}
0ecbf832269203da
Polycarpus analyzes a string called abracadabra. This string is constructed using the following algorithm: * On the first step the string consists of a single character "a". * On the k-th step Polycarpus concatenates two copies of the string obtained on the (k - 1)-th step, while inserting the k-th character of ...
[["4 7 12 15\n", "4\n"], ["1 463129088 536870913 1000000000\n", "463129088\n"], ["1 4 4 7\n", "3\n"], ["1 2 3 3\n", "1\n"], ["1 1 2 1000000000\n", "1\n"], ["8136 12821 10573 15189\n", "2901\n"], ["169720415 312105195 670978284 671296539\n", "207899\n"], ["654444727 988815385 77276659 644738371\n", "334370659\n"], ["267...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#1068"}
0ed52ced13072846
There are N cards placed face down in a row. On each card, an integer 1 or 2 is written. Let A_i be the integer written on the i-th card. Your objective is to guess A_1, A_2, ..., A_N correctly. You know the following facts: - For each i = 1, 2, ..., M, the value A_{X_i} + A_{Y_i} + Z_i is an even number. You are a ma...
[["3 1\n1 2 1\n", "2\n"], ["6 5\n1 2 1\n2 3 2\n1 3 3\n4 5 4\n5 6 5\n", "2\n"], ["100000 1\n1 100000 100\n", "99999\n"], ["63054 14575\n13010 13816 30\n4541 60485 6\n47545 47782 73\n20505 33165 20\n11329 41690 82\n8824 12440 90\n8389 17267 48\n36437 45146 76\n52293 61306 39\n34059 38647 54\n9708 52130 28\n23428 40988 78...
1.03
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#952"}
0ee33bbe42df4b04
There are X+Y+Z people, conveniently numbered 1 through X+Y+Z. Person i has A_i gold coins, B_i silver coins and C_i bronze coins. Snuke is thinking of getting gold coins from X of those people, silver coins from Y of the people and bronze coins from Z of the people. It is not possible to get two or more different col...
[["1 2 1\n2 4 4\n0 2 1\n7 6 7\n5 2 3", "18\n"], ["6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 38...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00000-of-00004.parquet#5"}
0ef070db67939db8
You are given a bracket sequence s (not necessarily a regular one). A bracket sequence is a string containing only characters '(' and ')'. A regular bracket sequence is a bracket sequence that can be transformed into a correct arithmetic expression by inserting characters '1' and '+' between the original characters of...
[["3\n(()\n", "4\n"], ["5\n()))()\n", "5\n"], ["9\n(\n", "4862\n"], ["100\n((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((()))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))\n", "3\n"], ["100\n))\n", "558488486\n"], ["15...
2.84
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00001-of-00005.parquet#3241"}
0ef0be00901ac4bf
Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all a...
[["1\n", "1\n"], ["2\n", "2\n"], ["3\n", "2 1\n"], ["8\n", "4\n"], ["100000\n", "17 16 11 10 8 6\n"], ["12345\n", "14 13 6 5 4 1\n"], ["32\n", "6\n"], ["70958\n", "17 13 11 9 6 4 3 2\n"], ["97593\n", "17 15 14 13 12 11 9 6 5 4 1\n"], ["91706\n", "17 15 14 11 10 6 5 4 2\n"], ["85371\n", "17 15 12 11 9 7 6 5 4 2 1\n"], [...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00003-of-00004.parquet#452"}
0ef5b5916e6d690d
You are a mayor of Berlyatov. There are $n$ districts and $m$ two-way roads between them. The $i$-th road connects districts $x_i$ and $y_i$. The cost of travelling along this road is $w_i$. There is some path between each pair of districts, so the city is connected. There are $k$ delivery routes in Berlyatov. The $i$...
[["6 5 2\n1 2 5\n2 3 7\n2 4 4\n4 5 2\n4 6 8\n1 6\n5 3\n", "22\n"], ["5 5 4\n1 2 5\n2 3 4\n1 4 3\n4 3 7\n3 5 2\n1 5\n1 3\n3 3\n1 5\n", "13\n"], ["6 5 2\n1 2 10\n2 3 7\n2 4 4\n4 5 2\n4 6 8\n1 6\n5 3\n", "25\n"], ["6 5 2\n1 2 10\n2 3 7\n2 4 4\n4 5 2\n4 6 10\n1 6\n5 3\n", "27\n"], ["6 5 2\n1 2 10\n2 3 7\n2 4 4\n4 5 2\n4 6 ...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#116"}
0f02570ee4ad2984
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters. Vasya can change no more than k characters of the original string. W...
[["4 2\nabba\n", "4\n"], ["8 1\naabaabaa\n", "5\n"], ["1 0\na\n", "1\n"], ["1 1\nb\n", "1\n"], ["1 0\nb\n", "1\n"], ["1 1\na\n", "1\n"], ["10 10\nbbbbbbbbbb\n", "10\n"], ["10 2\nbbbbbbbbbb\n", "10\n"], ["10 1\nbbabbabbba\n", "6\n"], ["10 10\nbbabbbaabb\n", "10\n"], ["10 9\nbabababbba\n", "10\n"], ["10 4\nbababbaaab\n",...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00002-of-00004.parquet#60"}
0f253d73ebbcd260
Snuke is interested in strings that satisfy the following conditions: * The length of the string is at least N. * The first N characters equal to the string s. * The last N characters equal to the string t. Find the length of the shortest string that satisfies the conditions. Constraints * 1≤N≤100 * The lengths o...
[["3\nabc\ncce", "5\n"], ["1\na\n{", "2\n"], ["4\nexpr\nexpq", "8\n"], ["3\ncba\ncec", "6\n"], ["4\nexpr\nrxep", "7\n"], ["3\nabc\ncec", "5\n"], ["1\n`\nz", "2\n"], ["4\nexpr\nepxq", "8\n"], ["1\n`\n{", "2\n"], ["4\nexpr\npexq", "8\n"], ["3\nbca\ncec", "6\n"], ["1\n`\n|", "2\n"], ["4\nexpr\nqxep", "8\n"], ["3\nbcb\ncec...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#1523"}
0f2a6327725b643e
Takahashi found an undirected connected graph with N vertices and M edges. The vertices are numbered 1 through N. The i-th edge connects vertices a_i and b_i, and has a weight of c_i. He will play Q rounds of a game using this graph. In the i-th round, two vertices S_i and T_i are specified, and he will choose a subse...
[["4 6\n1 3 5\n4 1 10\n2 4 6\n3 2 2\n3 4 5\n2 1 4\n1\n2 3", "9\n"], ["4 6\n1 3 5\n4 1 11\n2 4 6\n3 2 2\n3 4 5\n2 1 4\n1\n2 1", "7\n"], ["4 6\n1 3 5\n4 2 10\n2 4 6\n3 2 2\n3 4 5\n2 1 3\n1\n2 3", "8\n"], ["4 6\n1 3 5\n4 1 10\n2 4 6\n3 2 2\n2 4 8\n2 1 4\n1\n2 3", "10\n"], ["4 6\n1 3 5\n4 2 10\n2 4 3\n3 2 2\n2 4 5\n1 2 3\n...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00002-of-00004.parquet#951"}
0f313d946a96cfb7
In order to celebrate Twice's 5th anniversary, Tzuyu and Sana decided to play a game. Tzuyu gave Sana two integers $a$ and $b$ and a really important quest. In order to complete the quest, Sana has to output the smallest possible value of ($a \oplus x$) + ($b \oplus x$) for any given $x$, where $\oplus$ denotes the b...
[["6\n6 12\n4 9\n59 832\n28 14\n4925 2912\n1 1\n", "10\n13\n891\n18\n6237\n0\n"], ["6\n6 12\n4 9\n59 832\n28 14\n4925 2912\n2 1\n", "10\n13\n891\n18\n6237\n3\n"], ["6\n6 12\n4 5\n59 832\n28 14\n4925 2912\n2 1\n", "10\n1\n891\n18\n6237\n3\n"], ["6\n6 12\n4 2\n59 832\n28 14\n4925 2912\n2 1\n", "10\n6\n891\n18\n6237\n3\n"...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00003-of-00004.parquet#771"}
0f31fb20b9e94e86
Berland has n cities connected by m bidirectional roads. No road connects a city to itself, and each pair of cities is connected by no more than one road. It is not guaranteed that you can get from any city to any other one, using only the existing roads. The President of Berland decided to make changes to the road sy...
[["5 5\n2 1\n1 3\n2 3\n2 5\n4 3\n", "0"], ["4 3\n2 1\n1 3\n4 3\n", "1"], ["6 5\n1 2\n2 3\n4 5\n4 6\n5 6\n", "1"], ["10 45\n3 5\n2 3\n4 8\n2 5\n6 8\n5 7\n2 1\n3 7\n5 10\n6 1\n9 4\n3 6\n9 10\n6 7\n1 7\n7 9\n6 9\n9 3\n4 2\n2 6\n5 6\n5 8\n3 4\n10 8\n7 8\n4 6\n9 1\n5 9\n7 4\n1 10\n9 2\n2 8\n6 10\n9 8\n1 5\n7 2\n10 3\n3 8\n4...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00002-of-00005.parquet#3178"}
0f377d5af58c92af
problem Taro often shop at JOI general stores. At JOI general stores, there are enough coins of 500 yen, 100 yen, 50 yen, 10 yen, 5 yen, and 1 yen, and we always pay the change so that the number of coins is the smallest. Create a program to find the number of coins included in the change you receive when Taro goes sh...
[["380\n0\n0", "4\n"], ["380\n2\n0", "4\n14\n"], ["380\n-1\n0", "4\n3\n"], ["380\n-2\n0", "4\n4\n"], ["380\n3\n0", "4\n13\n"], ["380\n4\n0", "4\n12\n"], ["380\n-4\n0", "4\n6\n"], ["380\n5\n0", "4\n11\n"], ["380\n-7\n0", "4\n5\n"], ["380\n10\n0", "4\n10\n"], ["380\n-9\n0", "4\n7\n"], ["380\n43\n0", "4\n9\n"], ["380\n48\...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00004-of-00005.parquet#1242"}
0f38662888dbd4f0
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row. Let's enumerate all the houses from left to right, starting with one. A house is considered to be luxurious if the number of floors in it is strictly greater than in all...
[["5\n1 2 3 1 2\n", " 3 2 0 2 0 "], ["4\n3 2 1 4\n", " 2 ...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00002-of-00005.parquet#2032"}
0f40fa94cc513b8e
Snuke loves "paper cutting": he cuts out characters from a newspaper headline and rearranges them to form another string. He will receive a headline which contains one of the strings S_1,...,S_n tomorrow. He is excited and already thinking of what string he will create. Since he does not know the string on the headlin...
[["3\ncbaa\ndaacc\nacacac", "aac"], ["3\na\naa\nb", ""], ["3\ncaaa\ndaacc\nacacac", "aac\n"], ["3\ncaaa\nd`acc\nacacac", "ac\n"], ["3\naaca\nbdb`c\nacacac", "c\n"], ["3\na\naa\na", "a\n"], ["3\ncaca\ncca`d\nacacac", "acc\n"], ["3\nacba\nda`cb\nacacbc", "abc\n"], ["3\n_a_b\nc_bcb\nabcada", "b\n"], ["3\naad_\nbdb_c\nabab...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00002-of-00005.parquet#2682"}
0f45af1777f4a844
problem To the west of the Australian continent is the wide Indian Ocean. Marine researcher JOI is studying the properties of N species of fish in the Indian Ocean. For each type of fish, a rectangular parallelepiped habitat range is determined in the sea. Fish can move anywhere in their habitat, including boundaries...
[["3 2\n10 50 0 50 70 100\n10 20 20 70 90 60\n40 60 20 90 90 70", "65000\n"], ["3 2\n10 50 0 50 70 100\n10 20 20 70 90 60\n40 60 20 90 90 98", "67800\n"], ["3 2\n10 50 0 50 70 000\n10 20 20 70 90 60\n40 60 20 90 90 98", "36000\n"], ["3 2\n20 50 0 50 70 000\n10 35 20 70 90 60\n40 111 20 102 90 131", "0\n"], ["3 2\n30 50...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00002-of-00004.parquet#1131"}
0f53f599707fbebc
Count the pairs of length-N sequences consisting of integers between 1 and M (inclusive), A_1, A_2, \cdots, A_{N} and B_1, B_2, \cdots, B_{N}, that satisfy all of the following conditions: - A_i \neq B_i, for every i such that 1\leq i\leq N. - A_i \neq A_j and B_i \neq B_j, for every (i, j) such that 1\leq i < j\leq ...
[["2 2\n", "2\n"], ["2 3\n", "18\n"], ["141421 356237\n", "881613484\n"], ["1 1\n", "0\n"], ["1 500000\n", "999498257\n"], ["1 414575\n", "872014853\n"], ["436426 479445\n", "710501305\n"], ["148772 190081\n", "685499830\n"], ["190629 433447\n", "627318091\n"], ["47202 203497\n", "374125316\n"], ["1 2", "2\n"], ["2 6",...
3.99
{"source": "deepcoder/taco", "upstream_id": "taco/train-00000-of-00004.parquet#933"}
0f59de9648fd2909
Smart Beaver decided to be not only smart, but also a healthy beaver! And so he began to attend physical education classes at school X. In this school, physical education has a very creative teacher. One of his favorite warm-up exercises is throwing balls. Students line up. Each one gets a single ball in the beginning....
[["5\n1 2 2 1 2\n", "120\n"], ["8\n1 2 2 1 2 1 1 2\n", "16800\n"], ["1\n2\n", "1\n"], ["1\n1\n", "1\n"], ["2\n2 2\n", "2\n"], ["2\n1 2\n", "2\n"], ["2\n1 1\n", "2\n"], ["10\n2 2 2 2 2 2 1 2 1 1\n", "2419200\n"], ["10\n2 1 1 2 1 2 1 2 2 1\n", "786240\n"], ["10\n1 1 1 1 1 1 1 1 1 1\n", "9496\n"], ["10\n1 1 1 1 2 1 1 1 1 ...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00003-of-00004.parquet#198"}
0f678979a9c652a5
[3R2 - Standby for Action](https://www.youtube.com/watch?v=P2ZVC9aoiKo) Our dear Cafe's owner, JOE Miller, will soon take part in a new game TV-show "1 vs. n"! The game goes in rounds, where in each round the host asks JOE and his opponents a common question. All participants failing to answer are eliminated. The sho...
[["1\n", "1.0\n"], ["2\n", "1.5\n"], ["8212\n", "9.590628328312143\n"], ["99998\n", "12.090126129763334\n"], ["12\n", "3.103210678210678\n"], ["43\n", "4.349998620601827\n"], ["19\n", "3.547739657143682\n"], ["99999\n", "12.090136129863335\n"], ["5\n", "2.283333333333333\n"], ["696\n", "7.123283544012139\n"], ["368\n",...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00002-of-00005.parquet#2920"}
0f70bbc2615abfbe
A guy named Vasya attends the final grade of a high school. One day Vasya decided to watch a match of his favorite hockey team. And, as the boy loves hockey very much, even more than physics, he forgot to do the homework. Specifically, he forgot to complete his physics tasks. Next day the teacher got very angry at Vasy...
[["14\n43 23 17\n4 17 44\n5 -5 -16\n-43 -7 -6\n47 -48 12\n50 47 -45\n2 14 43\n37 -30 15\n4 -17 -11\n17 9 -45\n-50 -3 -8\n-50 0 0\n-50 0 0\n-16 0 0\n", "YES\n"], ["3\n1 2 3\n3 2 1\n0 0 0\n", "NO\n"], ["44\n52 -54 -29\n-82 -5 -94\n-54 43 43\n91 16 71\n7 80 -91\n3 15 29\n-99 -6 -77\n-3 -77 -64\n73 67 34\n25 -10 -18\n-29 9...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#296"}
0f743738ade6f161
Given is a positive integer N. How many tuples (A,B,C) of positive integers satisfy A \times B + C = N? Constraints * 2 \leq N \leq 10^6 * All values in input are integers. Input Input is given from Standard Input in the following format: N Output Print the answer. Examples Input 3 Output 3 Input 100 ...
[["3", "3"], ["100", "473"], ["1000000", "13969985"], ["4", "5\n"], ["101", "482\n"], ["5", "8\n"], ["001", "0\n"], ["8", "16\n"], ["6", "10\n"], ["2", "1\n"], ["110", "530\n"], ["10", "23\n"], ["13", "35\n"], ["111", "538\n"], ["12", "29\n"], ["17", "50\n"], ["9", "20\n"], ["7", "14\n"], ["14", "37\n"], ["16", "45\n"]...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00000-of-00005.parquet#2989"}
0f7c01217d9996ae
Consider a currency system in which there are notes of six denominations, namely, Rs. 1, Rs. 2, Rs. 5, Rs. 10, Rs. 50, Rs. 100. If the sum of Rs. N is input, write a program to computer smallest number of notes that will combine to give Rs. N. -----Input----- The first line contains an integer T, total number of test...
[["3\n1200\n500\n242\n", "12\n5\n7\n"], ["3 \n1200\n360\n242", "12\n5\n7\n"], ["3 \n1200\n360\n255", "12\n5\n4\n"], ["3 \n1200\n493\n380", "12\n11\n7\n"], ["3 \n1200\n806\n380", "12\n10\n7\n"], ["3 \n1200\n32\n380", "12\n4\n7\n"], ["3 \n1200\n30\n380", "12\n3\n7\n"], ["3 \n1200\n30\n99", "12\n3\n8\n"], ["3 \n1200\n30\n...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00003-of-00005.parquet#1748"}
0f7f3b25b1e90050
Given are two strings s and t consisting of lowercase English letters. Determine if there exists an integer i satisfying the following condition, and find the minimum such i if it exists. * Let s' be the concatenation of 10^{100} copies of s. t is a subsequence of the string {s'}_1{s'}_2\ldots{s'}_i (the first i chara...
[["contest\nsentence", "33"], ["contest\nson", "10"], ["contest\nprogramming", "-1"], ["toncest\nsentence", "33\n"], ["csnteot\nson", "10\n"], ["contest\nprogrammhng", "-1\n"], ["vtaletn\ntnn", "14\n"], ["ntelatv\ntnn", "15\n"], ["mlstvdc\nmsm", "8\n"], ["toncest\nsentemce", "-1\n"], ["csnoett\nson", "10\n"], ["eontcst...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00002-of-00005.parquet#685"}
0f878e033e70e47e
Koto Municipal Subway Koto Municipal Subway Koto City is a famous city whose roads are in a grid pattern, as shown in the figure below. The roads extending from north to south and the roads extending from east to west are lined up at intervals of 1 km each. Let Koto station at the southwestern intersection of Koto ci...
[["2 1\n7 6\n7 6\n7 7\n76 5\n8 41\n0 0", "0.414213562373\n0.0827625302982\n0.0827625302982\n0.0\n48.7401153702\n33.0\n"], ["1 1\n7 5\n7 6\n7 7\n76 5\n8 41\n0 0", "0.0\n0.0\n0.0827625302982\n0.0\n48.7401153702\n33.0\n"], ["2 1\n7 6\n7 6\n7 7\n76 3\n8 41\n0 0", "0.414213562373\n0.0827625302982\n0.0827625302982\n0.0\n50.7...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00004-of-00005.parquet#2070"}
0f93d3d2acbb2190
AtCoDeer the deer has found two positive integers, a and b. Determine whether the concatenation of a and b in this order is a square number. -----Constraints----- - 1 ≤ a,b ≤ 100 - a and b are integers. -----Input----- Input is given from Standard Input in the following format: a b -----Output----- If the concaten...
[["1 21\n", "Yes\n"], ["100 100\n", "No\n"], ["12 10\n", "No\n"], ["2 21", "No\n"], ["000 001", "Yes\n"], ["5 10", "No\n"], ["110 100", "No\n"], ["2 22", "No\n"], ["7 10", "No\n"], ["101 100", "No\n"], ["4 22", "No\n"], ["7 16", "No\n"], ["101 101", "No\n"], ["8 22", "No\n"], ["7 20", "No\n"], ["101 111", "No\n"], ["14...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#48"}
0f94776aeb32ef04
The Rebel fleet is on the run. It consists of m ships currently gathered around a single planet. Just a few seconds ago, the vastly more powerful Empire fleet has appeared in the same solar system, and the Rebels will need to escape into hyperspace. In order to spread the fleet, the captain of each ship has independent...
[["4\n(99+98)/97\n(26+4)/10\n(12+33)/15\n(5+1)/7\n", "1 2 2 1 "], ["10\n(44+98)/19\n(36+58)/47\n(62+74)/68\n(69+95)/82\n(26+32)/29\n(32+46)/39\n(32+24)/28\n(47+61)/54\n(39+13)/26\n(98+98)/98\n", "1 9 9 9 9 9 9 9 9 9 "], ["30\n(89+76)/87\n(81+78)/18\n(60+97)/32\n(41+14)/48\n(55+65)/27\n(29+15)/95\n(64+13)/96\n(78+30)/75...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#37"}
0f97288a6a3f4b90
Vova again tries to play some computer card game. The rules of deck creation in this game are simple. Vova is given an existing deck of n cards and a magic number k. The order of the cards in the deck is fixed. Each card has a number written on it; number a_{i} is written on the i-th card in the deck. After receiving...
[["3 4\n6 2 8\n", "4\n"], ["3 6\n9 1 14\n", "1\n"], ["5 1\n1 3 1 3 1\n", "15\n"], ["5 1\n5 5 5 5 5\n", "15\n"], ["5 1\n5 4 4 4 4\n", "15\n"], ["100 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
{"source": "deepcoder/taco", "upstream_id": "taco/train-00000-of-00004.parquet#977"}
0fa6a9379e904174
Vlad has $n$ friends, for each of whom he wants to buy one gift for the New Year. There are $m$ shops in the city, in each of which he can buy a gift for any of his friends. If the $j$-th friend ($1 \le j \le n$) receives a gift bought in the shop with the number $i$ ($1 \le i \le m$), then the friend receives $p_{ij}...
[["5\n\n2 2\n1 2\n3 4\n\n4 3\n1 3 1\n3 1 1\n1 2 2\n1 1 3\n\n2 3\n5 3 4\n2 5 1\n\n4 2\n7 9\n8 1\n9 6\n10 8\n\n2 4\n6 5 2 1\n7 9 7 2\n", "3\n2\n4\n8\n2\n"], ["5\n\n2 2\n1 2\n3 4\n\n4 3\n1 3 1\n3 1 1\n1 2 2\n1 1 3\n\n2 3\n5 3 4\n2 5 1\n\n4 2\n7 9\n8 1\n9 6\n10 8\n\n2 4\n6 5 2 1\n7 3 7 2\n", "3\n2\n4\n8\n2\n"], ["5\n\n2 2\...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00003-of-00004.parquet#597"}
0fbd40075570376b
In the capital city of Berland, Bertown, demonstrations are against the recent election of the King of Berland. Berland opposition, led by Mr. Ovalny, believes that the elections were not fair enough and wants to organize a demonstration at one of the squares. Bertown has n squares, numbered from 1 to n, they are numb...
[["10 9\n624\n47 56 60 51 88 82 77 83 89 100\n", "1\n"], ["10 2\n1523\n661 230 363 300 28 72 676 741 837 984\n", "8\n"], ["100 10\n9199\n89 409 428 408 309 400 259 393 212 273 472 654 533 774 663 484 695 801 587 518 521 578 767 644 532 785 500 944 582 680 899 882 589 601 614 633 877 543 770 614 852 715 932 627 639 658 ...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#879"}
0fc097bfd828962b
Chef has a nice complete binary tree in his garden. Complete means that each node has exactly two sons, so the tree is infinite. Yesterday he had enumerated the nodes of the tree in such a way: - Let's call the nodes' level a number of nodes that occur on the way to this node from the root, including this node. This w...
[["4\nlrl\nrll\nr\nlllr\n\n", "10\n14\n4\n13\n"], ["4\nrll\nrll\nr\nlllr", "14\n14\n4\n13\n"], ["4\nlrl\nrll\nr\nrlll", "10\n14\n4\n27\n"], ["4\nlrl\nrll\nr\nllrl", "10\n14\n4\n15\n"], ["4\nrll\nllr\nr\nlllr", "14\n8\n4\n13\n"], ["4\nrll\nrll\nr\nllrl", "14\n14\n4\n15\n"], ["4\nrll\nllr\nr\nrlll", "14\n8\n4\n27\n"], ["...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00003-of-00005.parquet#309"}
0fcadd80c374895a
Vasya has an array a consisting of positive integer numbers. Vasya wants to divide this array into two non-empty consecutive parts (the prefix and the suffix) so that the sum of all elements in the first part equals to the sum of elements in the second part. It is not always possible, so Vasya will move some element be...
[["3\n1 3 2\n", "YES\n"], ["5\n1 2 3 4 5\n", "NO\n"], ["5\n2 2 3 4 5\n", "YES\n"], ["5\n72 32 17 46 82\n", "NO\n"], ["6\n26 10 70 11 69 57\n", "NO\n"], ["7\n4 7 10 7 5 5 1\n", "NO\n"], ["8\n9 5 5 10 4 9 5 8\n", "NO\n"], ["10\n9 6 8 5 5 2 8 9 2 2\n", "YES\n"], ["15\n4 8 10 3 1 4 5 9 3 2 1 7 7 3 8\n", "NO\n"], ["20\n71 8...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#784"}
0fd502ed368f9fd0
You are given an array $a_1, a_2, \dots , a_n$ and two integers $m$ and $k$. You can choose some subarray $a_l, a_{l+1}, \dots, a_{r-1}, a_r$. The cost of subarray $a_l, a_{l+1}, \dots, a_{r-1}, a_r$ is equal to $\sum\limits_{i=l}^{r} a_i - k \lceil \frac{r - l + 1}{m} \rceil$, where $\lceil x \rceil$ is the least i...
[["7 3 10\n2 -4 15 -3 4 8 3\n", "7\n"], ["5 2 1000\n-13 -4 -9 -20 -11\n", "0\n"], ["5 10 10\n1000000000 1000000000 1000000000 1000000000 1000000000\n", "4999999990\n"], ["1 1 1\n2\n", "1\n"], ["5 10 10\n1000000000 1000000000 -1000000000 1000000000 1000000000\n", "2999999990\n"], ["6 2 5\n2 2 2 2 2 2\n", "0\n"], ["1 10 ...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#31"}
0fe77bba0749fdb9
There are many freight trains departing from Kirnes planet every day. One day on that planet consists of $h$ hours, and each hour consists of $m$ minutes, where $m$ is an even number. Currently, there are $n$ freight trains, and they depart every day at the same time: $i$-th train departs at $h_i$ hours and $m_i$ minut...
[["2 24 60 15\n16 0\n17 15\n", "0 0\n\n"], ["2 24 60 16\n16 0\n17 15\n", "1 0\n2 \n"], ["10 24 60 8\n10 59\n21 56\n0 42\n21 27\n5 24\n5 53\n16 5\n5 22\n10 11\n10 46\n", "1 5\n1 \n"], ["9 3 24 9\n1 15\n0 6\n0 22\n2 22\n2 7\n1 7\n1 23\n2 14\n0 14\n", "5 7\n1 2 7 8 9 \n"], ["9 24 60 21\n1 36\n2 35\n2 16\n2 55\n1 16\n0 35\...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#835"}
10250b12568c1aee
Chef is good at making pancakes. Generally he gets requests to serve N pancakes at once. He serves them in the form of a stack. A pancake can be treated as a circular disk with some radius. Chef needs to take care that when he places a pancake on the top of the stack the radius of the pancake should not exceed the rad...
[["2\n1\n2", "1\n2"], ["2\n0\n2", "0\n2\n"], ["2\n0\n4", "0\n15\n"], ["2\n0\n11", "0\n678570\n"], ["2\n0\n29", "0\n665114805\n"], ["2\n0\n8", "0\n4140\n"], ["2\n0\n0", "0\n0\n"], ["2\n1\n1", "1\n1\n"], ["2\n4\n1", "15\n1\n"], ["2\n0\n16", "0\n480142077\n"], ["2\n2\n5", "2\n52\n"], ["2\n2\n16", "2\n480142077\n"], ["2\n0...
1.09
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#862"}
102737e794a58fff
Guy-Manuel and Thomas have an array $a$ of $n$ integers [$a_1, a_2, \dots, a_n$]. In one step they can add $1$ to any element of the array. Formally, in one step they can choose any integer index $i$ ($1 \le i \le n$) and do $a_i := a_i + 1$. If either the sum or the product of all elements in the array is equal to ze...
[["4\n3\n2 -1 -1\n4\n-1 0 0 1\n2\n-1 2\n3\n0 -2 1\n", "1\n2\n0\n2\n"], ["1\n1\n0\n", "1\n"], ["1\n100\n64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 6...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00002-of-00004.parquet#10"}
102857fd6f825d1f
You are given a problemset consisting of $n$ problems. The difficulty of the $i$-th problem is $a_i$. It is guaranteed that all difficulties are distinct and are given in the increasing order. You have to assemble the contest which consists of some problems of the given problemset. In other words, the contest you have...
[["10\n1 2 5 6 7 10 21 23 24 49\n", "4\n"], ["5\n2 10 50 110 250\n", "1\n"], ["6\n4 7 12 100 150 199\n", "3\n"], ["1\n1000000000\n", "1\n"], ["2\n1 2\n", "2\n"], ["4\n1 2 4 8\n", "4\n"], ["5\n1 2 3 4 5\n", "5\n"], ["3\n2 4 8\n", "3\n"], ["10\n1 2 5 11 12 24 25 26 27 28\n", "7\n"], ["9\n1 2 3 7 8 20 21 22 23\n", "4\n"],...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#1276"}
102a743b062f7b39
Last week, Hamed learned about a new type of equations in his math class called Modular Equations. Lets define i modulo j as the remainder of division of i by j and denote it by $i \operatorname{mod} j$. A Modular Equation, as Hamed's teacher described, is an equation of the form $a \operatorname{mod} x = b$ in which a...
[["21 5\n", "2\n"], ["9435152 272\n", "282\n"], ["10 10\n", "infinity\n"], ["0 1000000000\n", "0\n"], ["11 2\n", "2\n"], ["1 0\n", "1\n"], ["0 0\n", "infinity\n"], ["121 0\n", "3\n"], ["772930485 686893955\n", "0\n"], ["257424 24\n", "127\n"], ["295138437 589952171\n", "0\n"], ["223093836 966\n", "399\n"], ["233758336 ...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00002-of-00004.parquet#26"}
103d45eb7ee6c2f6
Little Petya very much likes playing with little Masha. Recently he has received a game called "Zero-One" as a gift from his mother. Petya immediately offered Masha to play the game with him. Before the very beginning of the game several cards are lain out on a table in one line from the left to the right. Each card c...
[["??????????????????????????????????????????????????????????????????????????????????????0\n", "00\n10\n11\n"], ["1011110101010001110000110111011011101011010100001001101?101010101110010110001101110111110100001100010000111001010111000111111001001001100111001010000111101110100110110101101111110100000000010101001000001110...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00000-of-00004.parquet#1599"}
104e95c2820dded6
Thanos wants to destroy the avengers base, but he needs to destroy the avengers along with their base. Let we represent their base with an array, where each position can be occupied by many avengers, but one avenger can occupy only one position. Length of their base is a perfect power of $2$. Thanos wants to destroy t...
[["2 2 1 2\n1 3\n", "6\n"], ["3 2 1 2\n1 7\n", "8\n"], ["3 2 5 1\n7 8\n", "12\n"], ["3 2 7 1\n7 8\n", "15\n"], ["3 3 10000 5\n1 4 5\n", "40\n"], ["3 3 5 10000\n1 4 5\n", "30020\n"], ["1 1 5 6\n1\n", "11\n"], ["5 3 10000 3241\n5 12 2\n", "58892\n"], ["5 3 3521 10000\n5 12 2\n", "58168\n"], ["5 1 34 241\n22\n", "411\n"],...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00002-of-00004.parquet#961"}
1052b1435af1ae96
Polycarp has $n$ friends, the $i$-th of his friends has $a_i$ candies. Polycarp's friends do not like when they have different numbers of candies. In other words they want all $a_i$ to be the same. To solve this, Polycarp performs the following set of actions exactly once: Polycarp chooses $k$ ($0 \le k \le n$) arbitr...
[["5\n4\n4 5 2 5\n2\n0 4\n5\n10 8 5 1 4\n1\n10000\n7\n1 1 1 1 1 1 1\n", "2\n1\n-1\n0\n0\n"], ["1\n52\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n", "0\n"], ["1\n52\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
{"source": "deepcoder/taco", "upstream_id": "taco/train-00000-of-00004.parquet#884"}
10571139517469c2
A necklace can be described as a string of links ('-') and pearls ('o'), with the last link or pearl connected to the first one. $0$ You can remove a link or a pearl and insert it between two other existing links or pearls (or between a link and a pearl) on the necklace. This process can be repeated as many times as ...
[["-o-o--\n", "YES\n"], ["-o---\n", "YES\n"], ["-o---o-\n", "NO\n"], ["ooo\n", "YES\n"], ["---\n", "YES\n"], ["--o-o-----o----o--oo-o-----ooo-oo---o--\n", "YES\n"], ["-o--o-oo---o-o-o--o-o----oo------oo-----o----o-o-o--oo-o--o---o--o----------o---o-o-oo---o--o-oo-o--\n", "NO\n"], ["-ooo--\n", "YES\n"], ["---o--\n", "YE...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00000-of-00005.parquet#395"}
1060afb5fe2df496
In the Kingdom of AtCoder, people use a language called Taknese, which uses lowercase English letters. In Taknese, the plural form of a noun is spelled based on the following rules: * If a noun's singular form does not end with `s`, append `s` to the end of the singular form. * If a noun's singular form ends with `s`...
[["box", "boxs"], ["bus", "buses"], ["apple", "apples"], ["aox", "aoxs\n"], ["bsu", "bsus\n"], ["aeplp", "aeplps\n"], ["xoa", "xoas\n"], ["bsv", "bsvs\n"], ["eaplp", "eaplps\n"], ["xo`", "xo`s\n"], ["csv", "csvs\n"], ["daplp", "daplps\n"], ["xp`", "xp`s\n"], ["crv", "crvs\n"], ["d`plp", "d`plps\n"], ["px`", "px`s\n"], ...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00001-of-00005.parquet#1429"}
1065fff8bb0be54d
You are walking through a parkway near your house. The parkway has $n+1$ benches in a row numbered from $1$ to $n+1$ from left to right. The distance between the bench $i$ and $i+1$ is $a_i$ meters. Initially, you have $m$ units of energy. To walk $1$ meter of distance, you spend $1$ unit of your energy. You can't wal...
[["3\n3 1\n1 2 1\n4 5\n3 3 5 2\n5 16\n1 2 3 4 5\n", "3\n8\n0\n"], ["1\n2 1\n99 99\n", "197\n"], ["1\n5 100\n1 99 99 80 5\n", "184\n"], ["1\n100 7773\n100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 10...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#948"}
106b7b70a93c5641
Example Input 2 3 1 3 1 0 Output 2
[["2 3 1 3 1 1", "2\n"], ["1 4 1 3 0 1", "1\n"], ["1 4 1 3 0 2", "0\n"], ["4 3 1 3 0 1", "4\n"], ["2 3 1 0 0 1", "3\n"], ["4 3 0 5 0 3", "5\n"], ["8 3 0 5 0 3", "9\n"], ["8 5 0 5 0 3", "12\n"], ["4 73 0 1 1 0", "79\n"], ["8 9 0 7 0 3", "25\n"], ["4 73 0 2 1 0", "84\n"], ["8 11 0 7 0 3", "29\n"], ["4 12 1 0 0 1", "22\n"...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00000-of-00004.parquet#1497"}
109183452d6fe23c
It is the easy version of the problem. The difference is that in this version, there are no nodes with already chosen colors. Theofanis is starving, and he wants to eat his favorite food, sheftalia. However, he should first finish his homework. Can you help him with this problem? You have a perfect binary tree of $2^...
[["3\n", "24576\n"], ["14\n", "934234\n"], ["1\n", "6\n"], ["2\n", "96\n"], ["60\n", "937481864\n"], ["50\n", "902552662\n"], ["59\n", "950618124\n"], ["58\n", "166788441\n"], ["4\n", "610612729\n"], ["10\n", "153616455\n"], ["20\n", "61556388\n"], ["30\n", "686170158\n"], ["40\n", "622757975\n"], ["57\n", "690506414\n...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00002-of-00004.parquet#627"}
109a4696cd653b77
Read problems statements in Mandarin Chinese and Russian. Chef is judging a game called "Broken telephone". There are total N players taking part in the game. They are all sitting in a line. In the start of the game, first player is given a secret message written on a sheet of paper. Then they keep sending the messa...
[["3\n7\n1 1 1 3 3 3 2\n5\n1 3 1 1 1\n4\n5 5 5 5", "4\n3\n0"], ["3\n7\n1 1 1 3 3 3 2\n5\n1 3 1 1 2\n4\n5 5 5 5", "4\n5\n0\n"], ["3\n7\n1 1 1 3 3 3 3\n5\n1 3 1 1 2\n4\n5 5 5 5", "2\n5\n0\n"], ["3\n7\n1 1 1 3 3 3 2\n5\n1 0 1 1 1\n4\n5 5 5 5", "4\n3\n0\n"], ["3\n7\n1 1 1 3 3 3 2\n5\n1 3 1 1 2\n4\n9 5 5 5", "4\n5\n2\n"], [...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00003-of-00004.parquet#1096"}
10acc1e73477948e
After Vitaly was expelled from the university, he became interested in the graph theory. Vitaly especially liked the cycles of an odd length in which each vertex occurs at most once. Vitaly was wondering how to solve the following problem. You are given an undirected graph consisting of n vertices and m edges, not ne...
[["4 4\n1 2\n1 3\n4 2\n4 3\n", "1 2\n"], ["3 3\n1 2\n2 3\n3 1\n", "0 1\n"], ["3 0\n", "3 1\n"], ["6 3\n1 2\n4 3\n6 5\n", "2 12\n"], ["100000 0\n", "3 166661666700000\n"], ["5 4\n1 2\n1 3\n1 4\n1 5\n", "1 6\n"], ["6 3\n1 2\n2 3\n4 5\n", "1 1\n"], ["5 5\n1 2\n2 3\n3 4\n4 5\n5 1\n", "0 1\n"], ["59139 0\n", "3 344705845594...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#797"}
10ae4dc9e0148323
Draw a chessboard which has a height of H cm and a width of W cm. For example, the following figure shows a chessboard which has a height of 6 cm and a width of 10 cm. .#.#.#.#. .#.#.#.#.# .#.#.#.#. .#.#.#.#.# .#.#.#.#. .#.#.#.#.# Note that the top left corner should be drawn by '#'. Constraints * 1 ≤ H ≤ 300 * 1...
[["3 4\n5 6\n3 3\n2 2\n1 0\n0 0", "#.#.\n.#.#\n#.#.\n\n#.#.#.\n.#.#.#\n#.#.#.\n.#.#.#\n#.#.#.\n\n#.#\n.#.\n#.#\n\n#.\n.#\n\n\n\n"], ["3 7\n5 6\n3 3\n2 2\n1 0\n0 0", "#.#.#.#\n.#.#.#.\n#.#.#.#\n\n#.#.#.\n.#.#.#\n#.#.#.\n.#.#.#\n#.#.#.\n\n#.#\n.#.\n#.#\n\n#.\n.#\n\n\n\n"], ["3 7\n5 6\n3 0\n2 2\n1 0\n0 0", "#.#.#.#\n.#.#....
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00002-of-00004.parquet#1568"}
10af9506296ebada
Pak Chanek has a grid that has $N$ rows and $M$ columns. Each row is numbered from $1$ to $N$ from top to bottom. Each column is numbered from $1$ to $M$ from left to right. Each tile in the grid contains a number. The numbers are arranged as follows: Row $1$ contains integers from $1$ to $M$ from left to right. Row...
[["3 4\n", "9\n"], ["2 1\n", "1\n"], ["1 1\n", "0\n"], ["1 2\n", "1\n"], ["2 2\n", "2\n"], ["1 1000000000\n", "999999999\n"], ["1 999999997\n", "999999996\n"], ["1 589284012\n", "589284011\n"], ["1000000000 1\n", "999999999\n"], ["999999999 1\n", "999999998\n"], ["636562060 1\n", "636562059\n"], ["2 1000000000\n", "199...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#1017"}
10b6b2b7d12ce796
IT City company developing computer games invented a new way to reward its employees. After a new game release users start buying it actively, and the company tracks the number of sales with precision to each transaction. Every time when the next number of sales is divisible by all numbers from 2 to 10 every developer ...
[["3000\n", "1"], ["2520\n", "1"], ["2519\n", "0"], ["2521\n", "1"], ["1\n", "0"], ["314159265\n", "124666"], ["718281828459045235\n", "285032471610732"], ["1000000000000000000\n", "396825396825396"], ["987654321234567890\n", "391926317950225"], ["3628800\n", "1440"], ["504000000000000000\n", "200000000000000"], ["2519...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00000-of-00004.parquet#1292"}
10b713bac7fc6814
As a German University in Cairo (GUC) student and a basketball player, Herr Wafa was delighted once he heard the news. GUC is finally participating in the Annual Basketball Competition (ABC). A team is to be formed of n players, all of which are GUC students. However, the team might have players belonging to differen...
[["14 9 9\n9 4 7 2 1 2 4 3 9\n", "0.9711321228349092126181909464\n"], ["51 153 26\n19 32 28 7 25 50 22 31 29 39 5 4 28 26 24 1 19 23 36 2 50 50 33 28 15 17 31 35 10 40 16 7 6 43 50 29 20 25 31 37 10 18 38 38 44 30 36 47 37 6 16 48 41 49 14 16 30 7 29 42 36 8 31 37 26 15 43 42 32 3 46 12 16 37 33 12 18 16 15 14 46 11 2 ...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00003-of-00005.parquet#2456"}
10c45166388621e5
We have a board with a 2 \times N grid. Snuke covered the board with N dominoes without overlaps. Here, a domino can cover a 1 \times 2 or 2 \times 1 square. Then, Snuke decided to paint these dominoes using three colors: red, cyan and green. Two dominoes that are adjacent by side should be painted by different colors....
[["3\naab\nccb\n", "6\n"], ["1\nZ\nZ\n", "3\n"], ["52\nRvvttdWIyyPPQFFZZssffEEkkaSSDKqcibbeYrhAljCCGGJppHHn\nRLLwwdWIxxNNQUUXXVVMMooBBaggDKqcimmeYrhAljOOTTJuuzzn\n", "958681902\n"], ["1\nX\nX\n", "3\n"], ["20\nqqhhYOayyfmrooRKKWWZ\nSSeeYOaNNfmrggRCCMMZ\n", "6912\n"], ["30\nqrwwcooUGDDIflZVVbbFaittmRKPPv\nqrOOcQQUGHHIfl...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#95"}
10c9c7f22284a5cd
There are N students and M checkpoints on the xy-plane. The coordinates of the i-th student (1 \leq i \leq N) is (a_i,b_i), and the coordinates of the checkpoint numbered j (1 \leq j \leq M) is (c_j,d_j). When the teacher gives a signal, each student has to go to the nearest checkpoint measured in Manhattan distance. T...
[["3 4\n10 10\n-10 -10\n3 3\n1 2\n2 3\n3 5\n3 5", "3\n1\n2"], ["2 2\n2 0\n0 0\n-1 0\n1 0", "2\n1"], ["5 5\n-100000000 -100000000\n-100000000 100000000\n100000000 -100000000\n100000000 100000000\n0 0\n0 0\n100000000 100000000\n100000000 -100000000\n-100000000 100000000\n-100000000 -100000000", "5\n4\n3\n2\n1"], ["3 4\n1...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00000-of-00005.parquet#2785"}
10d253a42f0ec43b
You are given an array of positive integers $a = [a_0, a_1, \dots, a_{n - 1}]$ ($n \ge 2$). In one step, the array $a$ is replaced with another array of length $n$, in which each element is the greatest common divisor (GCD) of two neighboring elements (the element itself and its right neighbor; consider that the right...
[["5\n4\n16 24 10 5\n4\n42 42 42 42\n3\n4 6 4\n5\n1 2 3 4 5\n6\n9 9 27 9 9 63\n", "3\n0\n2\n1\n1\n"], ["1\n97\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\n", "0\n"], ["1...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00003-of-00004.parquet#1795"}
10e0d3930b91d76c
Problem You brought a flat, holeless donut with a $ W $ horizontal $ H $ vertical $ H $ rectangle for ACPC. Place this donut on the $ 2 $ dimension plane coordinate $ (0,0) $ with the center of the donut so that the side of length H and the $ y $ axis are parallel. On the ACPC $ 1 $ day you ate a donut that was in t...
[["6000 5000 20 2 400 300", "0.7500000000\n"], ["6000 5000 20 2 400 204", "0.5100000000\n"], ["6000 5000 20 2 499 204", "0.4088176353\n"], ["274 5000 28 1 499 204", "0.6559485531\n"], ["274 4268 28 0 499 209", "0.6720257235\n"], ["274 8140 32 0 499 209", "0.6741935484\n"], ["274 14753 32 0 499 132", "0.4258064516\n"], ...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00003-of-00005.parquet#1542"}
10e5b58af2ce53b2
Vasya has an array of integers of length n. Vasya performs the following operations on the array: on each step he finds the longest segment of consecutive equal integers (the leftmost, if there are several such segments) and removes it. For example, if Vasya's array is [13, 13, 7, 7, 7, 2, 2, 2], then after one operat...
[["8\n4 4 4 2 2 100 100 100\n", "3"], ["4\n2 5 5 2\n", "2"], ["5\n6 3 4 1 5\n", "5"], ["6\n10 10 50 10 50 50\n", "4"], ["100\n45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00001-of-00005.parquet#1203"}
10ed616350ce0524
One day Squidward, Spongebob and Patrick decided to go to the beach. Unfortunately, the weather was bad, so the friends were unable to ride waves. However, they decided to spent their time building sand castles. At the end of the day there were n castles built by friends. Castles are numbered from 1 to n, and the heig...
[["3\n1 2 3\n", "3\n"], ["4\n2 1 3 2\n", "2\n"], ["17\n1 45 22 39 28 23 23 100 500 778 777 778 1001 1002 1005 1003 1005\n", "10\n"], ["101\n1 50 170 148 214 153 132 234 181 188 180 225 226 200 197 122 181 168 87 220 223 160 235 94 257 145 199 235 102 146 119 60 109 134 209 260 210 191 180 271 236 195 155 169 166 143 24...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00000-of-00004.parquet#1723"}
1104a52619b0064d
The University of Aizu has a park covered with grass, and there are no trees or buildings that block the sunlight. On sunny summer days, sprinklers installed in the park operate to sprinkle water on the lawn. The frog Pyonkichi lives in this park. Pyonkichi is not good at hot weather, and on summer days when the sun is...
[["6 1\n10\n6 4 3 3 1 2 0 5 4 6 1 8 5 9 7 7 8 6 8 3\n6 1\n10\n6 4 3 3 1 2 0 5 4 6 1 8 5 7 7 7 8 6 9 0\n0 0", "OK\nNA\n"], ["6 1\n10\n6 4 3 3 1 2 0 5 4 6 1 8 5 9 7 7 8 6 3 3\n6 1\n10\n6 4 3 3 1 2 0 5 4 6 1 8 5 7 7 7 8 6 9 0\n0 0", "NA\nNA\n"], ["6 1\n10\n6 4 3 3 1 2 0 5 4 6 1 8 5 9 7 7 8 6 3 3\n6 1\n10\n6 4 3 3 1 2 0 10...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00002-of-00004.parquet#562"}
1115d26b4d00e111
Dima liked the present he got from Inna very much. He liked the present he got from Seryozha even more. Dima felt so grateful to Inna about the present that he decided to buy her n hares. Inna was very happy. She lined up the hares in a row, numbered them from 1 to n from left to right and started feeding them with c...
[["7\n8 5 7 6 1 8 9\n2 7 9 5 4 3 1\n2 3 3 4 1 1 3\n", "44\n"], ["4\n1 2 3 4\n4 3 2 1\n0 1 1 0\n", "13\n"], ["3\n1 1 1\n1 2 1\n1 1 1\n", "4\n"], ["1\n100000\n100000\n100000\n", "100000\n"], ["1\n0\n1\n4\n", "0\n"], ["2\n3 5\n9 8\n4 0\n", "14\n"], ["6\n1 2 0 1 6 4\n0 6 1 8 9 8\n4 1 4 3 9 8\n", "33\n"], ["8\n7 3 3 5 9 9 8...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00002-of-00005.parquet#718"}
11389e947073fe80
At Akabeko Elementary School, all the students participate in a slightly unusual jogging. Students run their own lap courses at their own pace. After going around each of your courses, you will be returned to elementary school. How many laps do they all meet at the same time in elementary school after they all start el...
[["2\n4 3\n8 4\n5\n789 289\n166 46\n9 4\n617 252\n972 303\n2\n8 5\n32 20\n0", "3\n2\n1598397732\n1209243492\n1939462992\n1782294192\n1360317793\n1\n1\n"], ["2\n4 3\n9 4\n5\n789 289\n166 46\n9 4\n617 252\n972 303\n2\n8 5\n32 20\n0", "27\n16\n1598397732\n1209243492\n1939462992\n1782294192\n1360317793\n1\n1\n"], ["2\n4 3\...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00002-of-00004.parquet#828"}
113d1daf6823cd82
Alice and Bob play a game. They have a binary string $s$ (a string such that each character in it is either $0$ or $1$). Alice moves first, then Bob, then Alice again, and so on. During their move, the player can choose any number (not less than one) of consecutive equal characters in $s$ and delete them. For example...
[["5\n01111001\n0000\n111111\n101010101\n011011110111\n", "4\n0\n6\n3\n6\n"], ["5\n01111101\n0000\n111111\n101010101\n011011110111\n", "5\n0\n6\n3\n6\n"], ["5\n01111101\n0000\n111111\n101010101\n011001110111\n", "5\n0\n6\n3\n5\n"], ["5\n01111101\n0000\n111111\n101010101\n011001111111\n", "5\n0\n6\n3\n7\n"], ["5\n111111...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00003-of-00004.parquet#213"}
1144165c28e766d3
There are three positive integers A, B and C written on a blackboard. E869120 performs the following operation K times: - Choose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n. What is the largest possible sum of the integers written on the blackboard after K ...
[["5 3 11\n1\n", "30\n"], ["3 3 4\n2\n", "22\n"], ["7 3 11\n1", "32\n"], ["3 3 4\n4", "70\n"], ["7 5 11\n1", "34\n"], ["3 3 4\n0", "10\n"], ["7 5 11\n0", "23\n"], ["4 3 4\n0", "11\n"], ["10 5 11\n0", "26\n"], ["4 3 1\n0", "8\n"], ["10 5 21\n0", "36\n"], ["4 1 1\n0", "6\n"], ["17 5 21\n0", "43\n"], ["3 1 1\n0", "5\n"], ...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00002-of-00004.parquet#1612"}
115c7d84544de51e
For given integers m and n, compute mn (mod 1,000,000,007). Here, A (mod M) is the remainder when A is divided by M. Constraints * 1 ≤ m ≤ 100 * 1 ≤ n ≤ 109 Input m n Two integers m and n are given in a line. Output Print mn (mod 1,000,000,007) in a line. Examples Input 2 3 Output 8 Input 5 8 Output...
[["2 1", "2\n"], ["5 9", "1953125\n"], ["2 2", "4\n"], ["7 9", "40353607\n"], ["3 3", "27\n"], ["13 9", "604499303\n"], ["1 3", "1\n"], ["13 1", "13\n"], ["12 1", "12\n"], ["3 1", "3\n"], ["0 1", "0\n"], ["4 3", "64\n"], ["5 15", "517577915\n"], ["6 9", "10077696\n"], ["2 4", "16\n"], ["2 9", "512\n"], ["3 4", "81\n"],...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00000-of-00004.parquet#1462"}
118c8e61c6f6e3d1
You are given a system of pipes. It consists of two rows, each row consists of $n$ pipes. The top left pipe has the coordinates $(1, 1)$ and the bottom right — $(2, n)$. There are six types of pipes: two types of straight pipes and four types of curved pipes. Here are the examples of all six types: [Image] Types of ...
[["6\n7\n2323216\n1615124\n1\n3\n4\n2\n13\n24\n2\n12\n34\n3\n536\n345\n2\n46\n54\n", "YES\nYES\nYES\nNO\nYES\nNO\n"], ["6\n7\n2323216\n1615124\n1\n3\n4\n2\n14\n24\n2\n12\n34\n3\n536\n345\n2\n46\n54\n", "YES\nYES\nYES\nNO\nYES\nNO\n"], ["6\n7\n2323216\n1615124\n1\n3\n4\n2\n13\n24\n2\n12\n34\n3\n536\n525\n2\n46\n54\n", "...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#672"}
11acad9d8f65cf54
Limak and Radewoosh are going to compete against each other in the upcoming algorithmic contest. They are equally skilled but they won't solve problems in the same order. There will be n problems. The i-th problem has initial score pi and it takes exactly ti minutes to solve it. Problems are sorted by difficulty — it'...
[["3 2\n50 85 250\n10 15 25\n", "Limak\n"], ["3 6\n50 85 250\n10 15 25\n", "Radewoosh\n"], ["8 1\n10 20 30 40 50 60 70 80\n8 10 58 63 71 72 75 76\n", "Tie\n"], ["1 36\n312\n42\n", "Tie\n"], ["5 1\n256 275 469 671 842\n7 9 14 17 26\n", "Limak\n"], ["1 10\n546\n45\n", "Tie\n"], ["50 10\n11 15 25 71 77 83 95 108 143 150 1...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00001-of-00005.parquet#1811"}
11c6f0e3a16c9de1
Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly a_{i} feet high. [Image] A group of bears is a non-empty contiguous segment of the line. The siz...
[["10\n1 2 3 4 5 4 3 2 1 6\n", "6 4 4 3 3 2 2 1 1 1 \n"], ["3\n524125987 923264237 374288891\n", "923264237 524125987 374288891 \n"], ["5\n585325539 365329221 412106895 291882089 564718673\n", "585325539 365329221 365329221 291882089 291882089 \n"], ["20\n452405440 586588704 509061481 552472140 16115810 148658854 66743...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00002-of-00004.parquet#1379"}
11de92f79c7e2adb
There is a tree T with N vertices, numbered 1 through N. For each 1 ≤ i ≤ N - 1, the i-th edge connects vertices a_i and b_i. Snuke is constructing a directed graph T' by arbitrarily assigning direction to each edge in T. (There are 2^{N - 1} different ways to construct T'.) For a fixed T', we will define d(s,\ t) fo...
[["10\n2 4\n2 5\n1 3\n10 7\n1 6\n2 8\n9 5\n8 6\n10 6", "52\n"], ["4\n1 2\n1 3\n2 4", "6\n"], ["10\n2 4\n2 5\n1 3\n3 7\n1 6\n2 8\n9 5\n8 6\n10 6", "256\n"], ["10\n2 4\n2 5\n8 3\n10 7\n1 6\n2 8\n9 7\n8 6\n10 6", "62\n"], ["10\n2 4\n2 5\n1 3\n10 7\n1 6\n2 8\n9 5\n8 6\n10 2", "56\n"], ["10\n2 4\n2 5\n8 3\n10 7\n1 6\n2 8\n9...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00002-of-00004.parquet#1504"}
11ecf06a950f4c67
Polycarp has $n$ coins, the value of the $i$-th coin is $a_i$. It is guaranteed that all the values are integer powers of $2$ (i.e. $a_i = 2^d$ for some non-negative integer number $d$). Polycarp wants to know answers on $q$ queries. The $j$-th query is described as integer number $b_j$. The answer to the query is the...
[["5 4\n2 4 8 2 4\n8\n5\n14\n10\n", "1\n-1\n3\n2\n"], ["3 3\n1 1 1\n1\n2\n3\n", "1\n2\n3\n"], ["4 1\n2 4 16 32\n14\n", "-1\n"], ["1 10\n8\n1\n2\n3\n4\n5\n6\n7\n8\n9\n16\n", "-1\n-1\n-1\n-1\n-1\n-1\n-1\n1\n-1\n-1\n"], ["1 10\n4\n1\n2\n3\n4\n5\n6\n7\n8\n9\n16\n", "-1\n-1\n-1\n1\n-1\n-1\n-1\n-1\n-1\n-1\n"], ["1 10\n2\n1\n...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00000-of-00004.parquet#810"}
11f4ce30e9e70b2c
You are given two strings a and b. You have to remove the minimum possible number of consecutive (standing one after another) characters from string b in such a way that it becomes a subsequence of string a. It can happen that you will not need to remove any characters at all, or maybe you will have to remove all of th...
[["hi\nbob\n", "-\n"], ["abca\naccepted\n", "ac\n"], ["abacaba\nabcdcba\n", "abcba\n"], ["lo\neuhaqdhhzlnkmqnakgwzuhurqlpmdm\n", "-\n"], ["aaeojkdyuilpdvyewjfrftkpcobhcumwlaoiocbfdtvjkhgda\nmlmarpivirqbxcyhyerjoxlslyfzftrylpjyouypvk\n", "ouypvk\n"], ["npnkmawey\nareakefvowledfriyjejqnnaeqheoh\n", "a\n"], ["fdtffutxkujf...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00000-of-00004.parquet#1192"}
11ff8adcedc7e27f
There are n kangaroos with pockets. Each kangaroo has a size (integer number). A kangaroo can go into another kangaroo's pocket if and only if the size of kangaroo who hold the kangaroo is at least twice as large as the size of kangaroo who is held. Each kangaroo can hold at most one kangaroo, and the kangaroo who is ...
[["8\n2\n5\n7\n6\n9\n8\n4\n2\n", "5\n"], ["8\n9\n1\n6\n2\n6\n5\n8\n3\n", "5\n"], ["12\n3\n99\n24\n46\n75\n63\n57\n55\n10\n62\n34\n52\n", "7\n"], ["12\n55\n75\n1\n98\n63\n64\n9\n39\n82\n18\n47\n9\n", "6\n"], ["100\n678\n771\n96\n282\n135\n749\n168\n668\n17\n658\n979\n446\n998\n331\n606\n756\n37\n515\n538\n205\n647\n547\...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#139"}
1205384f191e5126
A boy PCK is playing with N electric metronomes. The i-th metronome is set to tick every t_i seconds. He started all of them simultaneously. He noticed that, even though each metronome has its own ticking interval, all of them tick simultaneously from time to time in certain intervals. To explore this interesting phen...
[["3\n5\n6\n8", "5\n"], ["2\n10\n4", "1\n"], ["3\n5\n5\n8", "6\n"], ["2\n10\n6", "4\n"], ["3\n8\n5\n8", "3\n"], ["2\n10\n2", "0\n"], ["2\n18\n4", "2\n"], ["2\n34\n4", "13\n"], ["2\n34\n8", "9\n"], ["2\n35\n15", "20\n"], ["2\n4\n57", "15\n"], ["2\n4\n43", "39\n"], ["2\n5\n43", "38\n"], ["2\n5\n62", "26\n"], ["2\n5\n17",...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00002-of-00004.parquet#129"}
120811ddbd94f930
Valera takes part in the Berland Marathon. The marathon race starts at the stadium that can be represented on the plane as a square whose lower left corner is located at point with coordinates (0, 0) and the length of the side equals a meters. The sides of the square are parallel to coordinate axes. As the length of t...
[["2 5\n2\n", "1.0000000000 2.0000000000\n2.0000000000 0.0000000000\n"], ["4.147 2.8819\n6\n", "2.8819000000 0.0000000000\n4.1470000000 1.6168000000\n3.7953000000 4.1470000000\n0.9134000000 4.1470000000\n0.0000000000 2.1785000000\n0.7034000000 0.0000000000\n"], ["16904.8597 21646.2846\n10\n", "16904.8597000000 4741.424...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00003-of-00005.parquet#1653"}
1208b3d30c9ab1a5
Alice guesses the strings that Bob made for her. At first, Bob came up with the secret string $a$ consisting of lowercase English letters. The string $a$ has a length of $2$ or more characters. Then, from string $a$ he builds a new string $b$ and offers Alice the string $b$ so that she can guess the string $a$. Bob b...
[["4\nabbaac\nac\nbccddaaf\nzzzzzzzzzz\n", "abac\nac\nbcdaf\nzzzzzz\n"], ["1\nassaad\n", "asad\n"], ["6\nabbaac\nabbaac\nabbaac\nac\nbccddaaf\nzzzzzzzzzz\n", "abac\nabac\nabac\nac\nbcdaf\nzzzzzz\n"], ["1\nsaallaammddookkhhj\n", "salamdokhj\n"], ["11\nabbaac\nabbaac\nabbaac\nabbaac\nabbaac\nabbaac\nabbaac\nabbaac\nac\nb...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00003-of-00004.parquet#976"}
120ffd005e155e2d
Arkady owns a non-decreasing array $a_1, a_2, \ldots, a_n$. You are jealous of its beauty and want to destroy this property. You have a so-called XOR-gun that you can use one or more times. In one step you can select two consecutive elements of the array, let's say $x$ and $y$, remove them from the array and insert th...
[["4\n2 5 6 8\n", "1\n"], ["3\n1 2 3\n", "-1\n"], ["5\n1 2 4 6 20\n", "2\n"], ["2\n6 9\n", "-1\n"], ["5\n3 4 7 8 8\n", "1\n"], ["5\n4 9 11 12 16\n", "1\n"], ["7\n4 13 14 19 29 61 92\n", "1\n"], ["8\n1 1 2 4 8 14 15 31\n", "1\n"], ["23\n1 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 65536 131072 262144 5...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#1853"}
121412217a39c8bc
There is an infinite 2-dimensional grid. The robot stands in cell $(0, 0)$ and wants to reach cell $(x, y)$. Here is a list of possible commands the robot can execute: move north from cell $(i, j)$ to $(i, j + 1)$; move east from cell $(i, j)$ to $(i + 1, j)$; move south from cell $(i, j)$ to $(i, j - 1)$; move wes...
[["5\n5 5\n3 4\n7 1\n0 0\n2 0\n", "10\n7\n13\n0\n3\n"], ["100\n0 0\n0 1\n1 0\n1 1\n0 2\n1 2\n2 0\n2 1\n2 2\n0 3\n1 3\n2 3\n3 0\n3 1\n3 2\n3 3\n0 4\n1 4\n2 4\n3 4\n4 0\n4 1\n4 2\n4 3\n4 4\n0 5\n1 5\n2 5\n3 5\n4 5\n5 0\n5 1\n5 2\n5 3\n5 4\n5 5\n0 6\n1 6\n2 6\n3 6\n4 6\n5 6\n6 0\n6 1\n6 2\n6 3\n6 4\n6 5\n6 6\n0 7\n1 7\n2 ...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00002-of-00004.parquet#1718"}
121bddff5659844a
AtCoder Inc. has decided to lock the door of its office with a 3-digit PIN code. The company has an N-digit lucky number, S. Takahashi, the president, will erase N-3 digits from S and concatenate the remaining 3 digits without changing the order to set the PIN code. How many different PIN codes can he set this way? ...
[["19\n5546189040285140044", "273\n"], ["19\n4753841743850076999", "311\n"], ["19\n9039528710159876563", "412\n"], ["19\n3616863455241776042", "322\n"], ["19\n2785343766571511696", "239\n"], ["19\n2922045480066417189", "281\n"], ["19\n7230040539071200180", "292\n"], ["19\n1036710694297327965", "364\n"], ["19\n145550661...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00003-of-00004.parquet#572"}
1225ef2b7ae0ac4d
Example Input 8 -10 0 -10 5 -5 5 -5 0 10 0 10 -5 5 -5 5 0 Output 50
[["8\n-10 0\n-10 5\n-5 5\n-5 -1\n10 0\n10 -5\n5 -5\n5 0", "53\n"], ["8\n-10 0\n-10 10\n-5 5\n-5 -1\n10 0\n10 -5\n5 -5\n5 0", "65\n"], ["8\n-10 0\n-10 10\n-5 5\n-5 -1\n10 0\n4 -5\n5 -5\n5 0", "55\n"], ["8\n-10 0\n-15 10\n-5 5\n-5 -1\n10 0\n4 -5\n5 -5\n5 0", "68\n"], ["8\n-10 0\n-10 5\n-5 5\n-5 0\n10 0\n10 -5\n7 -5\n5 0"...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#1679"}
1228ed817896bfe9
Polycarp has recently created a new level in this cool new game Berlio Maker 85 and uploaded it online. Now players from all over the world can try his level. All levels in this game have two stats to them: the number of plays and the number of clears. So when a player attempts the level, the number of plays increases...
[["1\n2\n5 2\n8 6\n", "NO\n"], ["1\n2\n100 0\n101 2\n", "NO\n"], ["1\n3\n2 1\n4 1\n5 3\n", "NO\n"], ["1\n4\n0 0\n0 0\n2 1\n3 3\n", "NO\n"], ["1\n2\n10 1\n12 7\n", "NO\n"], ["1\n2\n10 3\n13 8\n", "NO\n"], ["1\n2\n10 0\n11 2\n", "NO\n"], ["1\n2\n765 432\n767 436\n", "NO\n"], ["1\n99\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 ...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00002-of-00004.parquet#1224"}
1245ab33d468fc99
Lenny is playing a game on a 3 × 3 grid of lights. In the beginning of the game all lights are switched on. Pressing any of the lights will toggle it and all side-adjacent lights. The goal of the game is to switch all the lights off. We consider the toggling as follows: if the light was switched on then it will be swit...
[["1 0 0\n0 0 0\n0 0 1\n", "001\n010\n100\n"], ["1 0 1\n8 8 8\n2 0 3\n", "010\n011\n100\n"], ["13 85 77\n25 50 45\n65 79 9\n", "000\n010\n000\n"], ["96 95 5\n8 84 74\n67 31 61\n", "011\n011\n101\n"], ["24 54 37\n60 63 6\n1 84 26\n", "110\n101\n011\n"], ["23 10 40\n15 6 40\n92 80 77\n", "101\n100\n000\n"], ["62 74 80\n9...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00003-of-00004.parquet#329"}
125869958ded530c
Bees Alice and Alesya gave beekeeper Polina famous card game "Set" as a Christmas present. The deck consists of cards that vary in four features across three options for each kind of feature: number of shapes, shape, shading, and color. In this game, some combinations of three cards are said to make up a set. For every...
[["3 3\nSET\nETS\nTSE\n", "1"], ["3 4\nSETE\nETSE\nTSES\n", "0"], ["5 4\nSETT\nTEST\nEEET\nESTE\nSTES\n", "2"], ["2 2\nES\nTE\n", "0"], ["1 1\nT\n", "0"], ["3 1\nE\nS\nT\n", "1"], ["10 3\nTSS\nSEE\nESS\nSES\nSTS\nTET\nTEE\nSSE\nETS\nTSE\n", "2"], ["10 3\nTSS\nSEE\nESS\nSES\nSTS\nTET\nEES\nEEE\nTTS\nTSE\n", "5"], ["24 4...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00002-of-00004.parquet#1787"}
1265979749a336a6
problem JOI Pizza sells pizza home delivery along the d-meter-long ring road that runs through the city center. JOI Pizza has n stores S1, ..., Sn on the loop line. The head office is S1. The distance from S1 to Si when moving the loop line clockwise is set to di meters. D2 , ..., dn is an integer greater than or equ...
[["8\n3\n2\n3\n1\n4\n6\n20\n4\n4\n10\n8\n16\n7\n7\n11\n8\n0", "3\n3\n"], ["8\n3\n2\n3\n1\n4\n6\n20\n4\n4\n12\n8\n16\n7\n7\n4\n8\n0", "3\n6\n"], ["8\n3\n2\n3\n1\n4\n6\n20\n4\n4\n14\n8\n16\n7\n7\n11\n8\n0", "3\n5\n"], ["8\n3\n2\n3\n1\n7\n7\n12\n4\n4\n12\n8\n16\n7\n7\n4\n8\n0", "2\n6\n"], ["8\n3\n2\n3\n1\n7\n6\n20\n4\n4\n...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#626"}
128383530800b822
You have a bag of size $n$. Also you have $m$ boxes. The size of $i$-th box is $a_i$, where each $a_i$ is an integer non-negative power of two. You can divide boxes into two parts of equal size. Your goal is to fill the bag completely. For example, if $n = 10$ and $a = [1, 1, 32]$ then you have to divide the box of s...
[["3\n10 3\n1 32 1\n23 4\n16 1 4 1\n20 5\n2 1 16 1 8\n", "2\n-1\n0\n"], ["3\n8 3\n1 32 1\n23 4\n16 1 4 1\n20 5\n2 1 16 1 8\n", "2\n-1\n0\n"], ["3\n14 3\n1 32 1\n23 4\n16 1 4 1\n20 5\n2 1 16 2 8\n", "3\n-1\n0\n"], ["3\n14 3\n1 32 1\n14 4\n16 1 4 1\n26 5\n2 1 16 2 8\n", "3\n1\n0\n"], ["3\n8 3\n1 32 1\n23 4\n16 1 4 1\n6 5...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00003-of-00004.parquet#107"}
128678756a33c3e5
Given is an integer N. Find the number of positive integers less than or equal to N that have an odd number of digits (in base ten without leading zeros). -----Constraints----- - 1 \leq N \leq 10^5 -----Input----- Input is given from Standard Input in the following format: N -----Output----- Print the number of pos...
[["11\n", "9\n"], ["136\n", "46\n"], ["100000\n", "90909\n"], ["1\n", "1\n"], ["9\n", "9\n"], ["10\n", "9\n"], ["99\n", "9\n"], ["100\n", "10\n"], ["3124\n", "909\n"], ["10000\n", "910\n"], ["45901\n", "36811\n"], ["99924\n", "90834\n"], ["99999\n", "90909\n"], ["2", "2\n"], ["100010", "90909\n"], ["36", "9\n"], ["3", ...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00003-of-00004.parquet#1516"}
12a7cb3b4c451a81
X and A are integers between 0 and 9 (inclusive). If X is less than A, print 0; if X is not less than A, print 10. Constraints * 0 \leq X, A \leq 9 * All values in input are integers. Input Input is given from Standard Input in the following format: X A Output If X is less than A, print 0; if X is not less th...
[["6 6", "10"], ["7 5", "10"], ["3 5", "0"], ["0 6", "0\n"], ["7 0", "10\n"], ["3 0", "10\n"], ["0 8", "0\n"], ["11 0", "10\n"], ["0 0", "10\n"], ["0 3", "0\n"], ["11 -1", "10\n"], ["0 -1", "10\n"], ["-1 3", "0\n"], ["9 0", "10\n"], ["1 -1", "10\n"], ["-2 3", "0\n"], ["6 0", "10\n"], ["1 0", "10\n"], ["-2 6", "0\n"], [...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00002-of-00005.parquet#2458"}
12aa3dfadd571ab8
You and your friend are participating in a TV show "Run For Your Prize". At the start of the show n prizes are located on a straight line. i-th prize is located at position ai. Positions of all prizes are distinct. You start at position 1, your friend — at position 106 (and there is no prize in any of these two positi...
[["2\n2 999995\n", "5\n"], ["3\n2 3 9\n", "8\n"], ["3\n500000 500001 500002\n", "499999\n"], ["1\n505050\n", "494950\n"], ["2\n999998 999999\n", "2\n"], ["2\n500000 500001\n", "499999\n"], ["1\n999995\n", "5\n"], ["1\n753572\n", "246428\n"], ["2\n2 999999\n", "1\n"], ["1\n999998\n", "2\n"], ["4\n2 3 4 5\n", "4\n"], ["1...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00000-of-00005.parquet#2774"}
12aa8e91f3a6f237
<image> As shown in the figure above, cut a convex polygon g by a line p1p2 and print the area of the cut polygon which is on the left-hand side of the line. g is represented by a sequence of points p1, p2,..., pn where line segments connecting pi and pi+1 (1 ≤ i ≤ n−1) are sides of the convex polygon. The line segm...
[["4\n1 1\n4 1\n4 3\n1 3\n2\n2 0 2 5\n2 4 2 0", "2.000000000\n4.000000000\n"], ["4\n1 1\n4 1\n4 3\n0 3\n2\n2 0 2 5\n2 4 2 0", "3.000000000\n4.000000000\n"], ["4\n1 1\n4 2\n4 3\n0 3\n2\n2 0 2 5\n2 4 2 0", "2.833333333\n2.666666667\n"], ["4\n1 1\n4 2\n4 3\n0 3\n2\n2 0 2 5\n0 4 2 0", "2.833333333\n4.535714286\n"], ["4\n1 ...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00003-of-00005.parquet#2761"}
12af7be2c79d8e58
Dr .: Peter. I did. Peter: See you again? What kind of silly invention is this time? Dr .: You invented the detector for that phantom elementary particle axion. Peter: Speaking of Axion, researchers such as the European Organization for Nuclear Research (CERN) are chasing with a bloody eye, aren't they? Is that true...
[["1\n0 1 0 0 0 0 0 0 0 0\n1 1 1 0 0 0 0 0 0 0\n0 1 0 0 0 0 0 0 0 0\n0 0 0 0 0 1 0 0 0 0\n0 0 0 1 0 0 1 0 0 0\n0 0 0 0 1 1 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 1 0\n0 0 0 0 0 0 0 1 1 1\n0 0 0 0 0 0 0 0 1 0", "0 0 0 0 1 0 1 0 0 0\n0 1 0 1 1 0 1 1 0 0\n0 0 1 0 1 0 1 0 1 0\n0 1 1 1 0 0 0 1 1 1\n1 0 0 0 0 1 0 0 0 ...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00002-of-00004.parquet#1158"}
12bb02278a9278e6
Anton likes to play chess. Also he likes to do programming. No wonder that he decided to attend chess classes and programming classes. Anton has n variants when he will attend chess classes, i-th variant is given by a period of time (l_{1, }i, r_{1, }i). Also he has m variants when he will attend programming classes, ...
[["3\n1 5\n2 6\n2 3\n2\n2 4\n6 8\n", "3\n"], ["3\n1 5\n2 6\n3 7\n2\n2 4\n1 4\n", "0\n"], ["20\n13 141\n57 144\n82 124\n16 23\n18 44\n64 65\n117 133\n84 117\n77 142\n40 119\n105 120\n71 92\n5 142\n48 132\n106 121\n5 80\n45 92\n66 81\n7 93\n27 71\n3\n75 96\n127 140\n54 74\n", "104\n"], ["10\n16 16\n20 20\n13 13\n31 31\n4...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00000-of-00005.parquet#1020"}
12c102fbc32de4e0
Vasya has a sequence of cubes and exactly one integer is written on each cube. Vasya exhibited all his cubes in a row. So the sequence of numbers written on the cubes in the order from the left to the right equals to a_1, a_2, ..., a_{n}. While Vasya was walking, his little brother Stepan played with Vasya's cubes and...
[["5 2 4\n3 4 2 3 1\n3 2 3 4 1\n", "TRUTH\n"], ["3 1 2\n1 2 3\n3 1 2\n", "LIE\n"], ["4 2 4\n1 1 1 1\n1 1 1 1\n", "TRUTH\n"], ["5 1 3\n2 2 2 1 2\n2 2 2 1 2\n", "TRUTH\n"], ["7 1 4\n2 5 5 5 4 3 4\n2 5 5 5 4 3 4\n", "TRUTH\n"], ["10 1 10\n6 7 6 1 10 10 9 5 3 9\n7 10 9 6 1 5 9 3 10 6\n", "TRUTH\n"], ["1 1 1\n1\n1\n", "TRUT...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00002-of-00004.parquet#1064"}
12c5100cbabf1e3d
Draw a rectangle which has a height of H cm and a width of W cm. Draw a 1-cm square by single '#'. Constraints * 1 ≤ H ≤ 300 * 1 ≤ W ≤ 300 Input The input consists of multiple datasets. Each dataset consists of two integers H and W separated by a single space. The input ends with two 0 (when both H and W are zero)...
[["3 4\n5 6\n2 3\n0 0", "####\n####\n####\n\n######\n######\n######\n######\n######\n\n###\n###\n\n"], ["3 4\n5 6\n2 0\n0 0", "####\n####\n####\n\n######\n######\n######\n######\n######\n\n\n\n\n"], ["3 4\n5 6\n2 4\n0 0", "####\n####\n####\n\n######\n######\n######\n######\n######\n\n####\n####\n\n"], ["4 4\n5 6\n2 0\n...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00003-of-00004.parquet#218"}
12c818e5732e9611
Three years have passes and nothing changed. It is still raining in London, and Mr. Black has to close all the doors in his home in order to not be flooded. Once, however, Mr. Black became so nervous that he opened one door, then another, then one more and so on until he opened all the doors in his house. There are ex...
[["5\n0 0 1 0 0\n", "3\n"], ["4\n1 0 0 1\n", "3\n"], ["5\n1 1 0 0 0\n", "2\n"], ["3\n0 1 0\n", "2\n"], ["16\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0\n", "15\n"], ["250\n1 0 1 1 0 1 0 1 1 1 1 1 1 0 0 1 1 1 0 1 0 0 1 1 1 1 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 0 1 0 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 1 0 0 1 0 0 0 1 1 1 0 0 0 1 0 1 1 0...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00000-of-00004.parquet#485"}