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
031a5f9561db33a5
There are n points on a straight line, and the i-th point among them is located at xi. All these coordinates are distinct. Determine the number m — the smallest number of points you should add on the line to make the distances between all neighboring points equal. Input The first line contains a single integer n (3...
[["3\n-5 10 5\n", "1\n"], ["4\n10 9 0 -1\n", "8\n"], ["6\n100 200 400 300 600 500\n", "0\n"], ["3\n1 4 7\n", "0\n"], ["3\n-1000000000 999999999 1000000000\n", "1999999998\n"], ["4\n1 2 3 4\n", "0\n"], ["3\n-1000000000 -999999999 1000000000\n", "1999999998\n"], ["5\n-1000000000 1000000000 1 2 -30000\n", "1999999996\n"],...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00002-of-00005.parquet#1328"}
031b498f2f2a44d4
One day the Codeforces round author sat exams. He had n exams and he needed to get an integer from 2 to 5 for each exam. He will have to re-sit each failed exam, i.e. the exam that gets mark 2. The author would need to spend too much time and effort to make the sum of his marks strictly more than k. That could have s...
[["44 173\n", "0\n"], ["13 32\n", "7\n"], ["50 234\n", "0\n"], ["25 106\n", "0\n"], ["16 70\n", "0\n"], ["13 57\n", "0\n"], ["45 104\n", "31\n"], ["50 250\n", "0\n"], ["36 99\n", "9\n"], ["1 2\n", "1\n"], ["50 100\n", "50\n"], ["20 69\n", "0\n"], ["47 128\n", "13\n"], ["7 20\n", "1\n"], ["29 116\n", "0\n"], ["17 73\n",...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#499"}
031cfb29549c1e8c
While Mahmoud and Ehab were practicing for IOI, they found a problem which name was Longest common subsequence. They solved it, and then Ehab challenged Mahmoud with another problem. Given two strings a and b, find the length of their longest uncommon subsequence, which is the longest string that is a subsequence of o...
[["abcd\ndefgh\n", "5\n"], ["a\na\n", "-1\n"], ["aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaacccccccccccccccccccccccccccccccccccccccccccccccccc\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaadddddddddddddddddddddddddddddddddddddddddddddddddd\n", "100\n"], ["aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#1596"}
032c42f1435e1573
You are going out for a walk, when you suddenly encounter N monsters. Each monster has a parameter called health, and the health of the i-th monster is h_i at the moment of encounter. A monster will vanish immediately when its health drops to 0 or below. Fortunately, you are a skilled magician, capable of causing explo...
[["4 5 3\n8\n7\n4\n2\n", "2\n"], ["2 10 4\n20\n20\n", "4\n"], ["5 2 1\n900000000\n900000000\n1000000000\n1000000000\n1000000000\n", "800000000\n"], ["5 2 1\n187174154\n900000000\n1000000000\n1000000000\n1000000000", "780000000\n"], ["4 5 3\n8\n7\n6\n2", "2\n"], ["2 10 4\n20\n37", "5\n"], ["5 2 1\n187174154\n900000000\n...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#56"}
0346ec1e8a2af2ff
You have N cards. On the i-th card, an integer A_i is written. For each j = 1, 2, ..., M in this order, you will perform the following operation once: Operation: Choose at most B_j cards (possibly zero). Replace the integer written on each chosen card with C_j. Find the maximum possible sum of the integers written o...
[["10 3\n1 8 5 7 100 4 52 33 13 5\n3 10\n4 30\n1 4", "338"], ["3 2\n5 1 4\n2 3\n1 5", "14"], ["3 2\n100 100 100\n3 99\n3 99", "300"], ["11 3\n1 1 1 1 1 1 1 1 1 1 1\n3 1000000000\n4 1000000000\n3 1000000000", "10000000001"], ["10 3\n1 8 5 7 100 4 7 33 13 5\n3 10\n4 30\n1 4", "296\n"], ["3 2\n5 1 1\n2 3\n1 5", "13\n"], [...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00002-of-00005.parquet#2157"}
034802bc226ae9f5
We have an integer sequence of length N: A_0,A_1,\cdots,A_{N-1}. Find the following sum (\mathrm{lcm}(a, b) denotes the least common multiple of a and b): * \sum_{i=0}^{N-2} \sum_{j=i+1}^{N-1} \mathrm{lcm}(A_i,A_j) Since the answer may be enormous, compute it modulo 998244353. Constraints * 1 \leq N \leq 200000 ...
[["3\n1 4 6", "22\n"], ["8\n1 4 3 4 6 8 12 12", "327\n"], ["10\n356822 296174 484500 710640 610703 888250 259161 609120 592348 713644", "963903348\n"], ["3\n2 3 6", "18\n"], ["8\n1 8 3 4 6 8 12 12", "383\n"], ["10\n356822 296174 484500 710640 231537 888250 259161 609120 592348 713644", "669101188\n"], ["3\n2 1 6", "14\...
4
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#331"}
034d7af839381d1e
You are given a program you want to execute as a set of tasks organized in a dependency graph. The dependency graph is a directed acyclic graph: each task can depend on results of one or several other tasks, and there are no directed circular dependencies between tasks. A task can only be executed if all tasks it depen...
[["4 3\n1 1 1 0\n0 1\n0 2\n3 0\n", "1"], ["4 3\n0 1 0 1\n0 1\n1 2\n2 3\n", "2"], ["2 1\n0 1\n0 1\n", "1"], ["10 14\n1 1 0 0 1 0 1 0 1 1\n0 1\n0 2\n0 4\n0 9\n1 3\n2 5\n3 4\n3 6\n3 8\n4 9\n5 6\n6 7\n7 8\n7 9\n", "3"], ["10 19\n0 0 0 0 0 0 0 0 1 1\n0 1\n0 3\n0 4\n1 2\n1 3\n1 4\n1 5\n1 7\n1 8\n1 9\n2 3\n2 4\n3 4\n3 5\n4 6\...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00001-of-00005.parquet#301"}
034f897c94b3bb8e
Vova plays a computer game known as Mages and Monsters. Vova's character is a mage. Though as he has just started, his character knows no spells. Vova's character can learn new spells during the game. Every spell is characterized by two values x_{i} and y_{i} — damage per second and mana cost per second, respectively....
[["3 100\n1 4 9\n2 19 49\n2 19 49\n", "YES\nNO\n"], ["10 442006988299\n2 10 47\n1 9 83\n1 15 24\n2 19 47\n2 75 99\n2 85 23\n2 8 33\n2 9 82\n1 86 49\n2 71 49\n", "NO\nYES\nYES\nYES\nYES\nYES\nYES\n"], ["2 424978864039\n2 7 3\n2 10 8\n", "NO\nNO\n"], ["2 1000000000000\n1 235726 255577\n1 959304 206090\n", ""], ["3 10\n1 ...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00003-of-00004.parquet#747"}
034fb1a8ee0dfcc6
We have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N. We will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7). -----Constraints----- - 1 \leq N \leq 2\times 10^5 - 1 \leq K \leq N+1 - All values in input are integers. -----Input----- I...
[["3 2\n", "10\n"], ["200000 200001\n", "1\n"], ["141421 35623\n", "220280457\n"], ["1 1\n", "3\n"], ["1 2\n", "1\n"], ["200000 2\n", "324066529\n"], ["200000 1\n", "324266530\n"], ["154242 56347\n", "520400358\n"], ["123333 101429\n", "175623902\n"], ["105711 80705\n", "801552417\n"], ["1447 717\n", "256934074\n"], ["...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00002-of-00004.parquet#883"}
0356914be2c8330c
Vasya has a string $s$ of length $n$. He decides to make the following modification to the string: Pick an integer $k$, ($1 \leq k \leq n$). For $i$ from $1$ to $n-k+1$, reverse the substring $s[i:i+k-1]$ of $s$. For example, if string $s$ is qwer and $k = 2$, below is the series of transformations the string goes t...
[["6\n4\nabab\n6\nqwerty\n5\naaaaa\n6\nalaska\n9\nlfpbavjsm\n1\np\n", "abab\n1\nertyqw\n3\naaaaa\n1\naksala\n6\navjsmbpfl\n5\np\n1\n"], ["1\n440\ntcjbjlbtjfmvzdqutuwzvmgqrqtrvxwrdacxcowbmbwvwssihttgdsjntiawqavwspzmybakxmwpbcgaffpyhvjrulqsorkcuozvtdbkkmasxtemrrbhqnmkpgewwphdvcyhxmatrfjkesacujihmtyqtqcjfqhpsjhgzimegvkjyl...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00003-of-00004.parquet#615"}
0367b40a0d9e85c2
E-training Nene is writing a program to look up $ N $ integers $ V_1, V_2, V_3, \ cdots, V_N $ for programming training. As told by his instructor, Umiko, Nene wrote a program to look up multiples of 2, 3, and 6. Multiples of 2 were $ A $, multiples of 3 were $ B $, and multiples of 6 were $ C $. Umiko told me to l...
[["6 5 2 1", "0\n"], ["9 5 2 1", "3\n"], ["12 5 2 1", "6\n"], ["0 5 2 1", "-6\n"], ["-1 5 2 1", "-7\n"], ["-1 0 2 0", "-3\n"], ["-1 0 1 0", "-2\n"], ["-2 0 2 0", "-4\n"], ["-2 0 8 0", "-10\n"], ["0 -2 2 -1", "-1\n"], ["0 -2 1 0", "1\n"], ["2 -1 0 -1", "2\n"], ["2 -1 -1 0", "4\n"], ["2 -2 -1 0", "5\n"], ["2 -2 -2 1", "7...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00003-of-00004.parquet#710"}
03698f1ccf5605f5
AquaMoon has n friends. They stand in a row from left to right, and the i-th friend from the left wears a T-shirt with a number a_i written on it. Each friend has a direction (left or right). In the beginning, the direction of each friend is right. AquaMoon can make some operations on friends. On each operation, AquaM...
[["1\n64\n8 7 7 2 4 9 3 7 9 4 7 10 6 7 6 4 9 9 10 2 2 2 10 3 8 9 3 1 5 10 6 5 7 4 3 5 7 10 7 5 8 4 5 7 10 7 10 8 2 3 8 10 1 3 8 3 9 2 9 2 5 10 5 5\n", "NO\n"], ["1\n2\n4 3\n", "NO\n"], ["1\n5\n1 1 1 3 2\n", "NO\n"], ["2\n6\n3 2 3 2 3 2\n6\n1 1 4 5 1 4\n", "NO\nYES\n"], ["1\n6\n9 1 9 1 9 1\n", "NO\n"], ["1\n10\n4 1 4 1 ...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#1125"}
0369ce80c939bfc2
Taro Aizu's company has a boss who hates being indivisible. When Taro goes out to eat with his boss, he pays by splitting the bill, but when the payment amount is not divisible by the number of participants, his boss always pays for it. One day, Taro became the secretary of the dinner party. Mr. Taro, who has little m...
[["4 15000\n305\n260\n136\n500\n3 400\n10\n1\n30\n3 337371\n5\n1\n12\n0 0", "14983\n397\n337369\n"], ["4 11033\n305\n24\n129\n177\n3 547\n6\n20\n30\n3 200909\n5\n9\n32\n0 0", "11027\nNA\n200909\n"], ["4 11232\n305\n188\n129\n304\n3 400\n10\n20\n30\n3 200909\n5\n9\n12\n0 0", "11213\nNA\n200909\n"], ["4 15000\n305\n24\n1...
1.45
{"source": "deepcoder/taco", "upstream_id": "taco/train-00003-of-00004.parquet#296"}
036cc18022966686
Snuke has a calculator. It has a display and two buttons. Initially, the display shows an integer x. Snuke wants to change this value into another integer y, by pressing the following two buttons some number of times in arbitrary order: * Button A: When pressed, the value on the display is incremented by 1. * Button ...
[["15 20", "5\n"], ["-10 -3", "7\n"], ["19 -10", "10\n"], ["-10 -2", "8\n"], ["8 -10", "3\n"], ["28 0", "29\n"], ["28 2", "28\n"], ["9 -14", "6\n"], ["28 3", "27\n"], ["1 -14", "14\n"], ["53 3", "52\n"], ["1 -20", "20\n"], ["53 6", "49\n"], ["0 -20", "21\n"], ["53 0", "54\n"], ["84 0", "85\n"], ["137 0", "138\n"], ["25...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00000-of-00004.parquet#1208"}
03807fb691841829
Give you N cards. Only one natural number is written on each card. However, the same number is never written. From now on, as a question, I will say an appropriate natural number. Please answer the largest remainder you get when you divide the number on the card you have by the number I said. For example, suppose you...
[["3 3\n9 3 8\n6\n6\n5", "3\n3\n4\n"], ["3 3\n9 3 10\n6\n6\n5", "4\n4\n4\n"], ["3 3\n9 3 8\n4\n6\n3", "3\n3\n2\n"], ["3 3\n9 3 8\n6\n6\n2", "3\n3\n1\n"], ["3 2\n1 3 8\n4\n6\n3", "3\n3\n"], ["3 3\n9 2 8\n4\n6\n5", "2\n3\n4\n"], ["3 3\n12 3 8\n6\n6\n5", "3\n3\n3\n"], ["3 3\n9 3 8\n4\n6\n1", "3\n3\n0\n"], ["3 3\n9 3 8\n12...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00000-of-00004.parquet#655"}
038d9cb5ff2e0c7a
Kilani is playing a game with his friends. This game can be represented as a grid of size $n \times m$, where each cell is either empty or blocked, and every player has one or more castles in some cells (there are no two castles in one cell). The game is played in rounds. In each round players expand turn by turn: fir...
[["3 3 2\n1 1\n1..\n...\n..2\n", "6 3 \n"], ["3 4 4\n1 1 1 1\n....\n#...\n1234\n", "1 4 3 3 \n"], ["3 4 2\n1 1\n....\n1..2\n....\n", "6 6 \n"], ["3 4 2\n2 1\n....\n1..2\n....\n", "9 3 \n"], ["4 4 2\n1 1000000000\n....\n....\n..2.\n...1\n", "3 13 \n"], ["4 4 2\n1 1000000000\n....\n....\n..1.\n...2\n", "15 1 \n"], ["1 1 ...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00003-of-00004.parquet#967"}
03a6b33b74d71ad6
You are given an integer $N$ and a string consisting of '+' and digits. You are asked to transform the string into a valid formula whose calculation result is smaller than or equal to $N$ by modifying some characters. Here, you replace one character with another character any number of times, and the converted string s...
[["2000\n0234++7890", "3\n"], ["1\n46", "-1\n"], ["100\n66", "0\n"], ["10\n239", "2\n"], ["10\n151", "1\n"], ["10\n3363", "4\n"], ["10\n++0+", "3\n"], ["2000\n0987++4320", "3\n"], ["1\n83", "-1\n"], ["100\n61", "0\n"], ["10\n437", "2\n"], ["2000\n0947++8320", "3\n"], ["1\n27", "-1\n"], ["100\n25", "0\n"], ["2000\n0947+...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00000-of-00004.parquet#1285"}
03a7a7a1ef05cde7
Here, we want to solve path planning for a mobile robot cleaning a rectangular room floor with furniture. Consider the room floor paved with square tiles whose size fits the cleaning robot (1 × 1). There are 'clean tiles' and 'dirty tiles', and the robot can change a 'dirty tile' to a 'clean tile' by visiting the tile...
[["7 5\n.......\n.o...*.\n.......\n.*...*.\n.......\n15 13\n.......x.......\n...o...x....*..\n.......x.......\n.......x.......\n.......x.......\n.-.............\nxxxxx.....xxxxx\n...............\n.......x.......\n.......x.......\n.......x.......\n..*....x....*..\n.......x.......\n10 10\n..........\n..o.......\n...........
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#1422"}
03b0151dc8932dfe
Dawid has four bags of candies. The $i$-th of them contains $a_i$ candies. Also, Dawid has two friends. He wants to give each bag to one of his two friends. Is it possible to distribute the bags in such a way that each friend receives the same amount of candies in total? Note, that you can't keep bags for yourself or ...
[["1 7 11 5\n", "YES\n"], ["7 3 2 5\n", "NO\n"], ["3 14 36 53\n", "YES\n"], ["30 74 41 63\n", "YES\n"], ["92 69 83 97\n", "NO\n"], ["26 52 7 19\n", "YES\n"], ["72 52 62 62\n", "YES\n"], ["1 1 1 1\n", "YES\n"], ["70 100 10 86\n", "NO\n"], ["14 10 18 24\n", "NO\n"], ["20 14 37 71\n", "YES\n"], ["1 1 2 1\n", "NO\n"], ["2 ...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00003-of-00004.parquet#1653"}
03b845428a6edb03
There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n. The presenter has m chips. The presenter...
[["36 6218\n", "14"], ["46 7262\n", "35"], ["44 7888\n", "12"], ["17 4248\n", "12"], ["4 7455\n", "2"], ["29 7772\n", "26"], ["32 6864\n", "0"], ["50 50\n", "5"], ["25 9712\n", "11"], ["50 1\n", "0"], ["45 9465\n", "14"], ["50 9555\n", "0"], ["1 9058\n", "0"], ["50 10000\n", "40"], ["9 7601\n", "5"], ["36 880\n", "4"],...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00003-of-00004.parquet#499"}
03c5b216aaf21ebd
Polycarpus has postcards and photos hung in a row on the wall. He decided to put them away to the closet and hang on the wall a famous painter's picture. Polycarpus does it like that: he goes from the left to the right and removes the objects consecutively. As Polycarpus doesn't want any mix-ups to happen, he will not ...
[["P\n", "1\n"], ["PPPPPPPPPPPPPPPPPPPPPPPCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCPPPPPCCCPPPPCCCCCPCC\n", "23\n"], ["CPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCP\n", "100\n"], ["CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00000-of-00004.parquet#1732"}
03ca54977cd7532a
Hr0d1y has $q$ queries on a binary string $s$ of length $n$. A binary string is a string containing only characters '0' and '1'. A query is described by a pair of integers $l_i$, $r_i$ $(1 \leq l_i \lt r_i \leq n)$. For each query, he has to determine whether there exists a good subsequence in $s$ that is equal to th...
[["2\n6 3\n001000\n2 4\n1 3\n3 5\n4 2\n1111\n1 4\n2 3\n", "YES\nNO\nYES\nNO\nYES\n"], ["2\n6 3\n001000\n2 4\n1 3\n3 5\n4 2\n1111\n1 4\n1 3\n", "YES\nNO\nYES\nNO\nYES\n"], ["2\n6 3\n001000\n2 5\n1 3\n3 5\n4 2\n1111\n1 4\n1 3\n", "YES\nNO\nYES\nNO\nYES\n"], ["2\n6 3\n001000\n2 5\n1 3\n3 5\n4 2\n1011\n1 4\n1 3\n", "YES\nN...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00000-of-00004.parquet#375"}
03d177a05598cb77
Nowadays the one-way traffic is introduced all over the world in order to improve driving safety and reduce traffic jams. The government of Berland decided to keep up with new trends. Formerly all n cities of Berland were connected by n two-way roads in the ring, i. e. each city was connected directly to exactly two ot...
[["5\n5 3 89\n2 3 43\n4 2 50\n1 4 69\n1 5 54\n", "143\n"], ["10\n1 8 16\n6 1 80\n6 5 27\n5 7 86\n7 9 72\n4 9 20\n4 3 54\n3 2 57\n10 2 61\n8 10 90\n", "267\n"], ["22\n18 22 46\n18 21 87\n5 21 17\n5 10 82\n10 12 81\n17 12 98\n16 17 17\n16 13 93\n4 13 64\n4 11 65\n15 11 18\n6 15 35\n6 7 61\n7 19 12\n19 1 65\n8 1 32\n8 2 4...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#963"}
03d574ddca818655
Taro and Hanako decided to play hit-and-blow. The hit-and-blow rules are as follows. * Separated into questioners and respondents. * The questioner decides a 4-digit number (correct answer) that does not include duplicate numbers. * Respondents guess the 4-digit number (answer). * For the answer, the questioner gives ...
[["1234 10660\n1234 1354\n1234 1234\n1230 1023\n0123 1234\n0 0", "1 0\n2 1\n4 0\n1 3\n0 3\n"], ["1234 10660\n1964 1354\n1234 1234\n1230 1023\n0123 1234\n0 0", "1 0\n2 0\n4 0\n1 3\n0 3\n"], ["1234 10660\n2242 1354\n1234 1234\n1230 1023\n0123 1234\n0 0", "1 0\n0 1\n4 0\n1 3\n0 3\n"], ["1234 5678\n1234 1354\n1234 1200\n12...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#170"}
03fa7530d3acb596
In Aizu prefecture, we decided to create a new town to increase the population. To that end, we decided to cultivate a new rectangular land and divide this land into squares of the same size. The cost of developing this land is proportional to the number of plots, but the prefecture wants to minimize this cost. Create...
[["9 6 1", "6\n"], ["10 20 9", "18\n"], ["10 20 16", "32\n"], ["4 11 1", "44\n"], ["8 20 16", "160\n"], ["6 11 1", "66\n"], ["8 20 11", "110\n"], ["3 11 1", "33\n"], ["2 1 11", "22\n"], ["3 3 1", "1\n"], ["2 0 11", "0\n"], ["3 3 2", "2\n"], ["2 -1 18", "-36\n"], ["2 -1 23", "-46\n"], ["2 -1 43", "-86\n"], ["3 -1 43", "...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#804"}
04006cae9602ce05
JAG-channel Nathan O. Davis operates an electronic bulletin board called JAG-channel. He is currently working on adding a new feature called Thread View. Like many other electronic bulletin boards, JAG-channel is thread-based. Here, a thread refers to a group of conversations consisting of a series of posts. There ar...
[["6\nhoge\n.fuga\n..foobar\n..jagjag\n...zigzag\n.piyo\n8\njagjag\n.hogehoge\n..fugafuga\n...ponyoponyo\n....evaeva\n....pokemon\n...nowawa\n.buhihi\n8\nhello\n.goodmorning\n..howareyou\n.goodafternoon\n..letshavealunch\n.goodevening\n.goodnight\n..gotobed\n3\ncaution\n.themessagelengthislessthanorequaltofifty\n..soth...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#1512"}
04047d0d9514759a
The whole world got obsessed with robots,and to keep pace with the progress, great Berland's programmer Draude decided to build his own robot. He was working hard at the robot. He taught it to walk the shortest path from one point to another, to record all its movements, but like in many Draude's programs, there was a ...
[["DDUL\n", "BUG\n"], ["LLLLLLLLRRRRDDDDDDDUUUUUU\n", "BUG\n"], ["UULLDLUR\n", "BUG\n"], ["URRRLULUURURLRLLLLULLRLRURLULRLULLULRRUU\n", "BUG\n"], ["RDRLL\n", "BUG\n"], ["RRRRRRRRRRRDDDDDDDDDDDDDDDDDDDRRRRRRRRRRRRRRRRRRRUUUUUUUUUUUUUUUUUUULLLLLLLLLLLLLLLLLLUUUUUUUUUUU\n", "BUG\n"], ["DDDLLLLLLLDDDDDDDRRRRRRRUUUUUURRR\n"...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00002-of-00004.parquet#1692"}
040e4c66dafe0240
Gildong has an interesting machine that has an array $a$ with $n$ integers. The machine supports two kinds of operations: Increase all elements of a suffix of the array by $1$. Decrease all elements of a suffix of the array by $1$. A suffix is a subsegment (contiguous elements) of the array that contains $a_n$. In o...
[["7\n2\n1 1\n3\n-1 0 2\n4\n99 96 97 95\n4\n-3 -5 -2 1\n6\n1 4 3 2 4 1\n5\n5 0 0 0 5\n9\n-367741579 319422997 -415264583 -125558838 -300860379 420848004 294512916 -383235489 425814447\n", "0\n1\n3\n4\n6\n5\n2847372102\n"], ["1\n2\n9 -10\n", "0\n"], ["1\n2\n9 -10\n", "0\n"], ["1\n2\n9 -7\n", "0\n"], ["7\n2\n1 1\n3\n-1 0...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00003-of-00004.parquet#1109"}
041af31d0bee376a
A dragon symbolizes wisdom, power and wealth. On Lunar New Year's Day, people model a dragon with bamboo strips and clothes, raise them with rods, and hold the rods high and low to resemble a flying dragon. A performer holding the rod low is represented by a 1, while one holding it high is represented by a 2. Thus, th...
[["6\n2 2 2 1 1 1\n", "6\n"], ["2\n1 2\n", "2\n"], ["200\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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-00001-of-00004.parquet#1267"}
041ca13c76467cc1
There are infinitely many cards, numbered 1, 2, 3, ... Initially, Cards x_1, x_2, ..., x_N are face up, and the others are face down. Snuke can perform the following operation repeatedly: - Select a prime p greater than or equal to 3. Then, select p consecutive cards and flip all of them. Snuke's objective is to have ...
[["2\n4 5\n", "2\n"], ["9\n1 2 3 4 5 6 7 8 9\n", "3\n"], ["2\n1 10000000\n", "4\n"], ["1\n1\n", "3\n"], ["2\n1 2\n", "2\n"], ["2\n2 3\n", "2\n"], ["100\n1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 97 99 101 103 105 107 109 11...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00000-of-00005.parquet#2149"}
0433a17ad91d266a
We will call a string obtained by arranging the characters contained in a string a in some order, an anagram of a. For example, `greenbin` is an anagram of `beginner`. As seen here, when the same character occurs multiple times, that character must be used that number of times. Given are N strings s_1, s_2, \ldots, s...
[["5\nabaaaaaaaa\noneplustwo\naaaaaaaaba\ntwoplusone\naaaabaaaaa", "4"], ["2\noneplustwo\nninemodsix", "0"], ["3\nacornistnt\npeanutbomb\nconstraint", "1"], ["5\nabaaaaaaaa\noweplustno\naaaaaaaaba\ntwoplusone\naaaabaaaaa", "4\n"], ["2\noneplustwo\nnioemodsix", "0\n"], ["3\nacornistnt\npeaoutbnmb\nconstraint", "1\n"], [...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00002-of-00005.parquet#1335"}
043555b09ffef85a
Create a program that converts the date expressed in the Christian era to the Japanese calendar using the era name and outputs the date. The input is three integers, as shown in the example, in the order year, month, and day. Convert this as shown in the sample output. If the date before the Meiji era is entered, pleas...
[["2005 5 3\n1868 12 2\n1868 9 7", "heisei 17 5 3\nmeiji 1 12 2\npre-meiji\n"], ["2005 5 3\n1868 12 2\n1868 9 9", "heisei 17 5 3\nmeiji 1 12 2\nmeiji 1 9 9\n"], ["2005 7 3\n1868 12 2\n1868 9 9", "heisei 17 7 3\nmeiji 1 12 2\nmeiji 1 9 9\n"], ["2005 9 3\n1868 12 3\n1868 9 7", "heisei 17 9 3\nmeiji 1 12 3\npre-meiji\n"],...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00000-of-00004.parquet#318"}
043f52edcd9e0dba
Little Alyona is celebrating Happy Birthday! Her mother has an array of n flowers. Each flower has some mood, the mood of i-th flower is ai. The mood can be positive, zero or negative. Let's define a subarray as a segment of consecutive flowers. The mother suggested some set of subarrays. Alyona wants to choose severa...
[["4 3\n1 2 3 4\n1 3\n2 4\n1 1\n", "16\n"], ["5 4\n1 -2 1 3 -4\n1 2\n4 5\n3 4\n1 4\n", "7\n"], ["2 2\n-1 -2\n1 1\n1 2\n", "0\n"], ["3 3\n1 -1 3\n1 2\n2 3\n1 3\n", "5\n"], ["16 44\n32 23 -27 -2 -10 -42 32 -14 -13 4 9 -2 19 35 16 22\n6 12\n8 11\n13 15\n12 12\n3 10\n9 13\n7 15\n2 11\n1 13\n5 6\n9 14\n3 16\n10 13\n3 15\n6 ...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00000-of-00005.parquet#3202"}
045b82ec98f0c929
As we all know, Max is the best video game player among her friends. Her friends were so jealous of hers, that they created an actual game just to prove that she's not the best at games. The game is played on a directed acyclic graph (a DAG) with n vertices and m edges. There's a character written on each edge, a lower...
[["5 8\n5 3 h\n1 2 c\n3 1 c\n3 2 r\n5 1 r\n4 3 z\n5 4 r\n5 2 h\n", "BABBB\nBBBBB\nAABBB\nAAABA\nAAAAB\n"], ["4 4\n1 2 b\n1 3 a\n2 4 c\n3 4 b\n", "BAAA\nABAA\nBBBA\nBBBB\n"], ["100 1\n92 93 p\n", "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\nBBBBBBBBBBBBBBBBBBBBBB...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00001-of-00005.parquet#2673"}
0463b24b7963f15e
Paul is at the orchestra. The string section is arranged in an r × c rectangular grid and is filled with violinists with the exception of n violists. Paul really likes violas, so he would like to take a picture including at least k of them. Paul can take a picture of any axis-parallel rectangle in the orchestra. Count ...
[["7 5 3 1\n5 5\n4 5\n1 4\n", "135\n"], ["6 4 10 2\n2 3\n2 1\n1 2\n6 1\n1 4\n4 4\n2 4\n1 1\n6 3\n4 2\n", "103\n"], ["10 10 10 10\n5 6\n4 4\n8 9\n5 7\n9 2\n6 4\n7 3\n6 10\n10 3\n3 8\n", "6\n"], ["10 10 10 1\n4 5\n9 6\n3 6\n6 10\n5 2\n1 7\n4 9\n10 8\n8 1\n2 9\n", "2082\n"], ["10 10 10 10\n8 2\n1 4\n9 9\n5 2\n1 7\n1 5\n3 ...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00002-of-00004.parquet#1272"}
04747837064dffe7
Bizon the Champion isn't just charming, he also is very smart. While some of us were learning the multiplication table, Bizon the Champion had fun in his own manner. Bizon the Champion painted an n × m multiplication table, where the element on the intersection of the i-th row and j-th column equals i·j (the rows and ...
[["2 2 2\n", "2\n"], ["10 1 7\n", "7\n"], ["3 3 5\n", "3\n"], ["3 3 8\n", "6\n"], ["2 2 4\n", "4\n"], ["3 48 30\n", "17\n"], ["1 454 340\n", "340\n"], ["1 3304 218\n", "218\n"], ["3 4175 661\n", "361\n"], ["5 353491 107977\n", "47290\n"], ["38 127 1330\n", "404\n"], ["27 24692 71714\n", "18432\n"], ["264 3 775\n", "741...
4
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#665"}
04782661a22311a7
Yaroslav, Andrey and Roman can play cubes for hours and hours. But the game is for three, so when Roman doesn't show up, Yaroslav and Andrey play another game. Roman leaves a word for each of them. Each word consists of 2·n binary characters "0" or "1". After that the players start moving in turns. Yaroslav moves fir...
[["4\n01011011\n10101110\n", "Draw"], ["2\n0000\n1110\n", "Second"], ["4\n10110011\n01011111\n", "Draw"], ["4\n01011011\n01010010\n", "First"], ["4\n01010100\n10011111\n", "Second"], ["4\n01111011\n01001011\n", "First"], ["4\n01101111\n10111101\n", "Draw"], ["4\n00110110\n10000100\n", "First"], ["4\n11011111\n10110110\...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00004-of-00005.parquet#2590"}
04825ecb71e0a3fb
There are n cities in the country where the Old Peykan lives. These cities are located on a straight line, we'll denote them from left to right as c_1, c_2, ..., c_{n}. The Old Peykan wants to travel from city c_1 to c_{n} using roads. There are (n - 1) one way roads, the i-th road goes from city c_{i} to city c_{i} + ...
[["4 6\n1 2 5 2\n2 3 3 4\n", "10\n"], ["2 3\n5 6\n5 5\n", "14\n"], ["24 3\n11 8 8 12 17 4 4 25 39 37 31 32 38 34 29 29 34 39 39 39 17 9 24 6\n3 5 4 3 3 3 4 3 4 3 3 3 3 4 3 3 4 3 4 3 3 3 3 3\n", "862\n"], ["43 5\n6 7 15 12 15 7 22 33 38 15 7 23 31 21 26 41 25 14 26 33 5 28 22 6 35 17 19 32 41 27 20 25 5 32 37 19 40 9 25...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00000-of-00004.parquet#611"}
048c68aad4868b83
You are given a sequence a, initially consisting of n integers. You want to transform this sequence so that all elements in it are equal (i. e. it contains several occurrences of the same element). To achieve this, you choose some integer x that occurs at least once in a, and then perform the following operation any ...
[["5\n3\n1 1 1\n5\n1 2 3 4 5\n5\n1 2 3 2 1\n7\n1 2 3 1 2 3 1\n11\n2 2 1 2 3 2 1 2 3 1 2\n", "\n0\n1\n1\n2\n3\n"], ["1\n17\n1 1 2 1 2 1 2 1 3 1 3 1 3 1 3 1 1\n", "4\n"], ["1\n13\n12 12 12 12 12 12 12 12 12 12 12 12 13\n", "1\n"], ["1\n13\n12 12 12 12 12 12 12 12 3 12 12 12 13\n", "1\n"], ["1\n13\n12 12 12 13 12 5 12 12 ...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00002-of-00005.parquet#2987"}
048f0bedbe66a05b
Ikta, who hates to lose, has recently been enthusiastic about playing games using the Go board. However, neither Go nor Gomoku can beat my friends at all, so I decided to give a special training to the lesser-known game Phutball. This game is a difficult game, so I decided to give special training so that I could win ...
[["...............\n...............\n...............\n...............\n...............\n.........../...\n...............\n...............\n...............\n...............\n...............\n...............\n...............\n...............\n...............\n...............\n.....XX........\n.....XXXO......\n......X.......
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00002-of-00004.parquet#1781"}
0491b17f39188cc9
Do the following for a four-digit number N consisting of numbers 0-9. 1. Let L be the number obtained as a result of arranging the numerical values ​​of each of the N digits in descending order. 2. Let S be the number obtained as a result of arranging the numerical values ​​of each of the N digits in ascending order. ...
[["6174\n3985\n3333\n0000", "0\n3\nNA\n"], ["6174\n1779\n3333\n0000", "0\n6\nNA\n"], ["6174\n1779\n2211\n0000", "0\n6\n4\n"], ["6174\n2012\n3078\n0000", "0\n3\n2\n"], ["6174\n3985\n5889\n0000", "0\n3\n4\n"], ["6174\n2012\n3639\n0000", "0\n3\n3\n"], ["6174\n1794\n3333\n0000", "0\n5\nNA\n"], ["6174\n1779\n1275\n0000", "0...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00002-of-00004.parquet#1189"}
04a7af0e21c44b89
Dima's got a staircase that consists of n stairs. The first stair is at height a1, the second one is at a2, the last one is at an (1 ≤ a1 ≤ a2 ≤ ... ≤ an). Dima decided to play with the staircase, so he is throwing rectangular boxes at the staircase from above. The i-th box has width wi and height hi. Dima throws eac...
[["7\n8 13 19 21 25 30 32\n3\n5 4\n6 5\n1 2\n", "25\n30\n35\n"], ["3\n1 6 8\n5\n3 4\n3 9\n3 3\n1 2\n1 6\n", "8\n12\n21\n24\n26\n"], ["2\n1 6\n5\n2 6\n1 2\n1 1\n1 2\n1 7\n", "6\n12\n14\n15\n17\n"], ["1\n9\n8\n1 4\n1 10\n1 9\n1 9\n1 7\n1 1\n1 9\n1 2\n", "9\n13\n23\n32\n41\n48\n49\n58\n"], ["1\n1\n1\n1 1\n", "1\n"], ["5\n...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00003-of-00004.parquet#1713"}
04c16c95de5e62d1
Where do odds begin, and where do they end? Where does hope emerge, and will they ever break? Given an integer sequence a_1, a_2, ..., a_{n} of length n. Decide whether it is possible to divide it into an odd number of non-empty subsegments, the each of which has an odd length and begins and ends with odd numbers. A ...
[["3\n1 3 5\n", "Yes\n"], ["5\n1 0 1 5 1\n", "Yes\n"], ["3\n4 3 1\n", "No\n"], ["4\n3 9 9 3\n", "No\n"], ["1\n1\n", "Yes\n"], ["5\n100 99 100 99 99\n", "No\n"], ["100\n100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 ...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00003-of-00004.parquet#199"}
04c3c679e2266065
"Hey, it's homework time" — thought Polycarpus and of course he started with his favourite subject, IT. Polycarpus managed to solve all tasks but for the last one in 20 minutes. However, as he failed to solve the last task after some considerable time, the boy asked you to help him. The sequence of n integers is calle...
[["100\n340 14 3275 2283 2673 1107 817 2243 1226 32 2382 3638 4652 418 68 4962 387 764 4647 159 1846 225 2760 4904 3150 403 3 2439 91 4428 92 4705 75 348 1566 1465 69 6 49 4 62 4643 564 1090 3447 1871 2255 139 24 99 2669 969 86 61 4550 158 4537 3993 1589 872 2907 1888 401 80 1825 1483 63 1 2264 4068 4113 2548 41 885 48...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00002-of-00004.parquet#914"}
04f92c478f9a92d8
In Omkar's last class of math, he learned about the least common multiple, or $LCM$. $LCM(a, b)$ is the smallest positive integer $x$ which is divisible by both $a$ and $b$. Omkar, having a laudably curious mind, immediately thought of a problem involving the $LCM$ operation: given an integer $n$, find positive intege...
[["3\n4\n6\n9\n", "2 2\n3 3\n3 6\n"], ["3\n4\n5\n2\n", "2 2\n1 4\n1 1\n"], ["8\n527\n622\n63\n423\n147\n791\n838\n903\n", "31 496\n311 311\n21 42\n141 282\n49 98\n113 678\n419 419\n301 602\n"], ["6\n861605021\n68328580\n877214985\n692261986\n3399371\n684035729\n", "1 861605020\n34164290 34164290\n292404995 584809990\n3...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#1742"}
05011a98ac27d352
Petya was late for the lesson too. The teacher gave him an additional task. For some array a Petya should find the number of different ways to select non-empty subset of elements from it in such a way that their product is equal to a square of some integer. Two ways are considered different if sets of indexes of eleme...
[["4\n1 1 1 1\n", "15\n"], ["4\n2 2 2 2\n", "7\n"], ["5\n1 2 4 5 8\n", "7\n"], ["10\n5 66 19 60 34 27 15 27 42 51\n", "7\n"], ["5\n2 2 2 2 2\n", "15\n"], ["7\n53 59 56 9 13 1 28\n", "3\n"], ["10\n38 58 51 41 61 12 17 47 18 24\n", "3\n"], ["7\n4 9 16 25 36 49 64\n", "127\n"], ["6\n1 2 3 4 5 6\n", "7\n"], ["17\n44 57 54 ...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00002-of-00005.parquet#2831"}
05025fb8177456d4
Imagine that you have a twin brother or sister. Having another person that looks exactly like you seems very unusual. It's hard to say if having something of an alter ego is good or bad. And if you do have a twin, then you very well know what it's like. Now let's imagine a typical morning in your family. You haven't w...
[["100\n5 5 4 3 5 1 2 5 1 1 3 5 4 4 1 1 1 1 5 4 4 5 1 5 5 1 2 1 3 1 5 1 3 3 3 2 2 2 1 1 5 1 3 4 1 1 3 2 5 2 2 5 5 4 4 1 3 4 3 3 4 5 3 3 3 1 2 1 4 2 4 4 1 5 1 3 5 5 5 5 3 4 4 3 1 2 5 2 3 5 4 2 4 5 3 2 4 2 4 3\n", "33\n"], ["5\n2 2 2 4 4\n", "2\n"], ["100\n85 50 17 89 65 89 5 20 86 26 16 21 85 14 44 31 87 31 6 2 48 67 8 ...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#200"}
050facd7f410f54d
Recently, Mike was very busy with studying for exams and contests. Now he is going to chill a bit by doing some sight seeing in the city. City consists of n intersections numbered from 1 to n. Mike starts walking from his house located at the intersection number 1 and goes along some sequence of intersections. Walking...
[["5\n1 2 3 4 5\n", "0 1 2 3 4\n"], ["7\n4 4 4 4 7 7 7\n", "0 1 2 1 2 3 3\n"], ["3\n2 2 3\n", "0 1 2\n"], ["4\n2 3 3 4\n", "0 1 2 3\n"], ["91\n4 6 23 23 23 23 23 28 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 47 47 47 54 54 54 54 54 54 54 58 58 58 58 58 58 69 69 69 69 69 69 69 69 69 69 69 69 70 70...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00002-of-00005.parquet#3060"}
05190c6ee9d951d4
Let's call a positive integer $n$ ordinary if in the decimal notation all its digits are the same. For example, $1$, $2$ and $99$ are ordinary numbers, but $719$ and $2021$ are not ordinary numbers. For a given number $n$, find the number of ordinary numbers among the numbers from $1$ to $n$. -----Input----- The fi...
[["6\n1\n2\n3\n4\n5\n100\n", "1\n2\n3\n4\n5\n18\n"], ["1\n999999999\n", "81\n"], ["1\n69696969\n", "69\n"], ["1\n69696969\n", "69\n"], ["1\n999999999\n", "81\n"], ["1\n124545606\n", "73\n"], ["6\n1\n2\n3\n4\n8\n100\n", "1\n2\n3\n4\n8\n18\n"], ["1\n35666167\n", "66\n"], ["1\n55658120\n", "68\n"], ["1\n55372544\n", "67\n...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00000-of-00004.parquet#604"}
0519f1d4c52ec1a0
We have N cards. A number a_i is written on the i-th card. Alice and Bob will play a game using these cards. In this game, Alice and Bob alternately take one card. Alice goes first. The game ends when all the cards are taken by the two players, and the score of each player is the sum of the numbers written on the car...
[["2\n3 1\n", "2\n"], ["3\n2 7 4\n", "5\n"], ["4\n20 18 2 18\n", "18\n"], ["4\n20 18 2 12", "12\n"], ["2\n2 1", "1\n"], ["3\n3 7 4", "6\n"], ["4\n20 1 2 12", "9\n"], ["2\n2 0", "2\n"], ["3\n3 9 4", "8\n"], ["4\n20 1 4 12", "11\n"], ["2\n2 -1", "3\n"], ["2\n4 -1", "5\n"], ["4\n20 2 0 12", "10\n"], ["2\n5 -2", "7\n"], ["...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#182"}
0526848f59d178c5
Nuske has a grid with N rows and M columns of squares. The rows are numbered 1 through N from top to bottom, and the columns are numbered 1 through M from left to right. Each square in the grid is painted in either blue or white. If S_{i,j} is 1, the square at the i-th row and j-th column is blue; if S_{i,j} is 0, the ...
[["3 4 4\n1101\n0110\n1101\n1 1 3 4\n1 1 3 1\n2 2 3 4\n1 2 3 4", "3\n2\n2\n3\n"], ["5 5 6\n11010\n01110\n10101\n11101\n01010\n1 1 5 5\n1 2 4 5\n2 3 3 5\n3 3 3 3\n3 1 3 5\n1 1 3 4", "3\n2\n2\n1\n3\n2\n"], ["5 5 6\n11010\n01110\n10101\n11101\n01010\n1 1 5 5\n1 2 4 5\n2 3 3 5\n5 3 3 3\n3 1 3 5\n1 1 3 4", "3\n2\n2\n0\n3\n2...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00000-of-00004.parquet#1276"}
0539bfd86bc995cb
Vasya the programmer lives in the middle of the Programming subway branch. He has two girlfriends: Dasha and Masha, who live at the different ends of the branch, each one is unaware of the other one's existence. When Vasya has some free time, he goes to one of his girlfriends. He descends into the subway at some time,...
[["716249 716248\n", "Equal\n"], ["99087 99090\n", "Equal\n"], ["929061 929052\n", "Equal\n"], ["8 75\n", "Dasha\n"], ["461363 256765\n", "Masha\n"], ["4982 2927\n", "Masha\n"], ["999983 999979\n", "Masha\n"], ["782250 782252\n", "Equal\n"], ["9886 8671\n", "Masha\n"], ["20393 86640\n", "Dasha\n"], ["52 53\n", "Equal\n...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00000-of-00004.parquet#1819"}
0539dc362e7309e7
Andrey needs one more problem to conduct a programming contest. He has n friends who are always willing to help. He can ask some of them to come up with a contest problem. Andrey knows one value for each of his fiends — the probability that this friend will come up with a problem if Andrey asks him. Help Andrey choose...
[["4\n0.1 0.2 0.3 0.8\n", "0.800000000000\n"], ["2\n0.1 0.2\n", "0.260000000000\n"], ["1\n0.217266\n", "0.217266000000\n"], ["2\n0.608183 0.375030\n", "0.608183000000\n"], ["3\n0.388818 0.399762 0.393874\n", "0.478724284024\n"], ["4\n0.801024 0.610878 0.808545 0.732504\n", "0.808545000000\n"], ["5\n0.239482 0.686259 0....
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00003-of-00005.parquet#336"}
05435eeb18d5c966
In the State of Takahashi in AtCoderian Federation, there are N cities, numbered 1, 2, ..., N. M bidirectional roads connect these cities. The i-th road connects City A_i and City B_i. Every road connects two distinct cities. Also, for any two cities, there is at most one road that directly connects them. One day, it w...
[["5 5\n1 2\n1 3\n3 4\n3 5\n4 5\n", "4\n"], ["5 1\n1 2\n", "-1\n"], ["4 3\n1 2\n1 3\n2 3\n", "3\n"], ["10 39\n7 2\n7 1\n5 6\n5 8\n9 10\n2 8\n8 7\n3 10\n10 1\n8 10\n2 3\n7 4\n3 9\n4 10\n3 4\n6 1\n6 7\n9 5\n9 7\n6 9\n9 4\n4 6\n7 5\n8 3\n2 5\n9 2\n10 7\n8 6\n8 9\n7 3\n5 3\n4 5\n6 3\n2 10\n5 10\n4 2\n6 2\n8 4\n10 6\n", "21...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#775"}
0547aa03703eb869
You are given an array a consisting of positive integers and q queries to this array. There are two types of queries: * 1 l r x — for each index i such that l ≤ i ≤ r set ai = x. * 2 l r — find the minimum among such ai that l ≤ i ≤ r. We decided that this problem is too easy. So the array a is given in a co...
[["3 1\n1 2 3\n3\n2 1 3\n1 1 2 4\n2 1 3\n", "1\n3\n"], ["3 2\n1 2 3\n5\n2 4 4\n1 4 4 5\n2 4 4\n1 1 6 1\n2 6 6\n", "1\n5\n1\n"], ["10 10\n4 2 3 8 1 2 1 7 5 4\n10\n2 63 87\n2 2 48\n2 5 62\n2 33 85\n2 30 100\n2 38 94\n2 7 81\n2 13 16\n2 26 36\n2 64 96\n", "1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n"], ["10 10\n10 8 10 9 2 2 4 6 10 1\...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00001-of-00005.parquet#1475"}
054d6422834849ec
A festival will be held in a town's main street. There are n sections in the main street. The sections are numbered 1 through n from left to right. The distance between each adjacent sections is 1. In the festival m fireworks will be launched. The i-th (1 ≤ i ≤ m) launching is on time t_{i} at section a_{i}. If you ar...
[["50 3 1\n49 1 1\n26 1 4\n6 1 10\n", "-31\n"], ["10 2 1\n1 1000 4\n9 1000 4\n", "1992\n"], ["30 8 2\n15 97 3\n18 64 10\n20 14 20\n16 18 36\n10 23 45\n12 60 53\n17 93 71\n11 49 85\n", "418\n"], ["100 20 5\n47 93 3\n61 49 10\n14 69 10\n88 2 14\n35 86 18\n63 16 20\n39 49 22\n32 45 23\n66 54 25\n77 2 36\n96 85 38\n33 28 4...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00003-of-00004.parquet#1484"}
055f5aad3cb834de
On the well-known testing system MathForces, a draw of $n$ rating units is arranged. The rating will be distributed according to the following algorithm: if $k$ participants take part in this event, then the $n$ rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawin...
[["4\n5\n11\n1\n3\n", "4\n0 1 2 5 \n6\n0 1 2 3 5 11 \n2\n0 1 \n3\n0 1 3 \n"], ["3\n990\n94\n848\n", "62\n0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 33 34 35 36 38 39 41 43 45 47 49 52 55 58 61 66 70 76 82 90 99 110 123 141 165 198 247 330 495 990 \n19\n0 1 2 3 4 5 6 7 8 9 10 1...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00003-of-00005.parquet#824"}
05602610afd51341
There are n heroes fighting in the arena. Initially, the i-th hero has a_i health points. The fight in the arena takes place in several rounds. At the beginning of each round, each alive hero deals 1 damage to all other heroes. Hits of all heroes occur simultaneously. Heroes whose health is less than 1 at the end of t...
[["271 208\n", "80367024\n"], ["6 26\n", "37929526\n"], ["13 337\n", "434551606\n"], ["164 500\n", "411608690\n"], ["10 500\n", "263020220\n"], ["26 178\n", "373528200\n"], ["411 77\n", "525290835\n"], ["6 478\n", "28573939\n"], ["383 477\n", "158983764\n"], ["111 222\n", "460833105\n"], ["500 333\n", "736893443\n"], [...
4
{"source": "deepcoder/taco", "upstream_id": "taco/train-00000-of-00004.parquet#303"}
0562a152d6f74ef6
Read problems statements in Russian here Chef has a special affection for sets of binary strings of equal length which have same numbers of 1's. Given three integers n, k and m, your task is to find the the lexicographically m^{th} smallest string among strings which have length n and have k 1's. If no such string e...
[["1\n3 2 2", "101"], ["1\n3 2 3", "110\n"], ["1\n3 3 3", "-1\n"], ["1\n6 3 3", "001101\n"], ["1\n6 4 3", "011011\n"], ["1\n6 4 6", "100111\n"], ["1\n3 1 3", "100\n"], ["1\n9 3 3", "000001101\n"], ["1\n6 5 3", "110111\n"], ["1\n8 4 6", "00100111\n"], ["1\n12 3 3", "000000001101\n"], ["1\n8 2 6", "00001100\n"], ["1\n3 1...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#1238"}
0568e945de06bcb9
You are given a rooted tree on n vertices, its root is the vertex number 1. The i-th vertex contains a number w_i. Split it into the minimum possible number of vertical paths in such a way that each path contains no more than L vertices and the sum of integers w_i on each path does not exceed S. Each vertex should belo...
[["3 1 3\n1 2 3\n1 1\n", "3\n"], ["3 3 6\n1 2 3\n1 1\n", "2\n"], ["1 1 10000\n10001\n", "-1\n"], ["3 3 2200000000\n1000000000 1000000000 1000000000\n1 2\n", "2\n"], ["6 3 100\n1 100 1 1 1 1\n1 1 2 3 3\n", "4\n"], ["2 100000 1000000000000000000\n1000000000 1000000000\n1\n", "1\n"], ["1 100000 1\n1\n", "1\n"], ["3 2 3\n1...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00002-of-00005.parquet#1248"}
0574d2ff6d3e7e45
Julia is going to cook a chicken in the kitchen of her dormitory. To save energy, the stove in the kitchen automatically turns off after k minutes after turning on. During cooking, Julia goes to the kitchen every d minutes and turns on the stove if it is turned off. While the cooker is turned off, it stays warm. The s...
[["963276084 698548036 1000000000\n", "1036723916.0\n"], ["18036 47899 1000000000\n", "1452914012.0\n"], ["200 10 979220166595737684\n", "9.792201665957377e+17\n"], ["740 251 930540301905511549\n", "9.38642796161889e+17\n"], ["1000 1000 1000000000000000000\n", "1e+18\n"], ["9999999999 33333 1000000000\n", "1000000000.0...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00003-of-00005.parquet#1372"}
057d22fb5034789e
This is the easy version of the problem. The difference is the constraints on $n$, $m$ and $t$. You can make hacks only if all versions of the problem are solved. Alice and Bob are given the numbers $n$, $m$ and $k$, and play a game as follows: The game has a score that Alice tries to maximize, and Bob tries to minim...
[["7\n3 3 2\n2 1 10\n6 3 10\n6 4 10\n100 1 1\n4 4 0\n69 4 20\n", "6\n5\n375000012\n500000026\n958557139\n0\n49735962\n"], ["1\n2000 2000 1000000006\n", "999998007\n"], ["1\n2000 1139 818658270\n", "523403915\n"], ["2\n1398 1034 726329524\n602 156 640769482\n", "656360164\n969738279\n"], ["3\n763 499 769431935\n827 50 7...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#1130"}
059448ad869dd050
Given is a positive integer N. Consider repeatedly applying the operation below on N: - First, choose a positive integer z satisfying all of the conditions below: - z can be represented as z=p^e, where p is a prime number and e is a positive integer; - z divides N; - z is different from all integers chosen in previ...
[["1\n", "0\n"], ["1000000007\n", "1\n"], ["997764507000\n", "7\n"], ["1000000000000\n", "8\n"], ["32\n", "2\n"], ["128\n", "3\n"], ["1024\n", "4\n"], ["1048576\n", "5\n"], ["268435456\n", "7\n"], ["34359738368\n", "7\n"], ["549755813888\n", "8\n"], ["999999999989\n", "1\n"], ["999999999961\n", "1\n"], ["999999999959\n...
1.08
{"source": "deepcoder/taco", "upstream_id": "taco/train-00003-of-00004.parquet#1238"}
05972924fb0818d6
Recently, the Fair Nut has written $k$ strings of length $n$, consisting of letters "a" and "b". He calculated $c$ — the number of strings that are prefixes of at least one of the written strings. Every string was counted only one time. Then, he lost his sheet with strings. He remembers that all written strings were l...
[["2 4\naa\nbb\n", "6\n"], ["3 3\naba\nbba\n", "8\n"], ["4 5\nabbb\nbaaa\n", "8\n"], ["1 1\na\na\n", "1"], ["1 1000000000\na\na\n", "1"], ["10 1\nbbbaaaabbb\nbbbbaaabbb\n", "10\n"], ["10 10\naabaaaabba\naabbaaabba\n", "52\n"], ["10 100\naabaaaaaab\naabbaaabab\n", "144\n"], ["10 1\nbaaabaaaaa\nbaaabaaaab\n", "10\n"], ["...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#1357"}
05975b9fe3b0eaab
You are given a string S of length N consisting of A, B and C, and an integer K which is between 1 and N (inclusive). Print the string S after lowercasing the K-th character in it. -----Constraints----- - 1 ≤ N ≤ 50 - 1 ≤ K ≤ N - S is a string of length N consisting of A, B and C. -----Input----- Input is given fr...
[["3 1\nABC\n", "aBC\n"], ["4 3\nCABA\n", "CAbA\n"], ["20 15\nBBBBAAACBCABBCAACAAC\n", "BBBBAAACBCABBCaACAAC\n"], ["40 38\nBCCACCBCACABBBBBCBABCCCABBAACBBBAAABACCA\n", "BCCACCBCACABBBBBCBABCCCABBAACBBBAAABAcCA\n"], ["1 1\nA\n", "a\n"], ["50 27\nACBCABCCCAACACCBBBACCBCBBBCCBAAAABAACACAAACCACCCCA\n", "ACBCABCCCAACACCBBBA...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00000-of-00004.parquet#1015"}
059a49da8e700210
Some country is populated by wizards. They want to organize a demonstration. There are n people living in the city, x of them are the wizards who will surely go to the demonstration. Other city people (n - x people) do not support the wizards and aren't going to go to the demonstration. We know that the city administr...
[["7879 2590 2818\n", "219441\n"], ["78 28 27\n", "0\n"], ["9178 2255 7996\n", "731618\n"], ["6571 6449 8965\n", "582642\n"], ["6151 6148 3746\n", "224269\n"], ["6487 5670 8\n", "0\n"], ["4890 1112 5\n", "0\n"], ["4909 2111 8860\n", "432827\n"], ["10000 10000 10000\n", "990000\n"], ["78 55 96\n", "20\n"], ["3271 5 50\n...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00002-of-00004.parquet#1625"}
05a39bf3c417b014
Consider a billiard table of rectangular size $n \times m$ with four pockets. Let's introduce a coordinate system with the origin at the lower left corner (see the picture). [Image] There is one ball at the point $(x, y)$ currently. Max comes to the table and strikes the ball. The ball starts moving along a line tha...
[["4 3 2 2 -1 1\n", "0 0"], ["4 4 2 0 1 1\n", "-1"], ["10 10 10 1 -1 0\n", "-1"], ["1000000000 1000000000 1 1000000000 0 1\n", "-1"], ["2 1 1 0 -1 -1\n", "0 1"], ["5 3 4 3 1 -1\n", "0 3"], ["15 9 1 1 1 1\n", "15 9"], ["15 9 1 1 -1 -1\n", "0 0"], ["15 9 2 1 1 1\n", "-1"], ["1000000000 999999999 999999998 999999999 -1 -1...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00002-of-00004.parquet#191"}
05a50c3dd5a71b32
Read problems statements in Mandarin Chinese and Russian. For positive integer x let define function F(x) = 1 * (1! + x) + 2 * (2! + x) + .. + x * (x! + x). "k!" means factorial: k! = 1 * 2 * .. * k Chef wants to calculate F(p_{1}) + F(p_{2}) + ... + F(p_{n}). As answer could be large, help him, calculate value ...
[["5 7\n1 2 3 4 5", "6"], ["5 7\n1 2 3 4 4", "1\n"], ["5 13\n1 2 3 4 4", "8\n"], ["5 13\n1 2 0 4 4", "6\n"], ["5 7\n1 2 3 4 3", "2\n"], ["5 13\n1 4 3 4 4", "0\n"], ["5 13\n1 3 0 4 4", "10\n"], ["5 13\n1 3 0 4 6", "11\n"], ["5 7\n1 0 0 5 4", "3\n"], ["5 6\n0 2 4 4 6", "4\n"], ["1 13\n1 17 0 4 6", "9\n"], ["5 17\n1 6 0 4...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00002-of-00004.parquet#989"}
05accded52da1170
2^k teams participate in a playoff tournament. The tournament consists of 2^k - 1 games. They are held as follows: first of all, the teams are split into pairs: team 1 plays against team 2, team 3 plays against team 4 (exactly in this order), and so on (so, 2^{k-1} games are played in that phase). When a team loses a g...
[["3\n0110?11\n6\n5 1\n6 ?\n7 ?\n2 ?\n5 ?\n1 1\n", "1\n2\n3\n4\n5\n5\n"], ["3\n0110?11\n6\n5 1\n6 ?\n6 ?\n1 ?\n5 ?\n1 1\n", "1\n2\n2\n2\n2\n2\n"], ["3\n11?0110\n6\n5 1\n6 ?\n7 ?\n2 ?\n5 ?\n1 1\n", "1\n1\n4\n5\n6\n6\n"], ["3\n0110?11\n6\n5 1\n7 ?\n7 ?\n2 ?\n5 ?\n1 1\n", "1\n2\n2\n3\n4\n4\n"], ["3\n0110?11\n1\n5 1\n6 ?\n...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#1171"}
05b612ebfcf2b019
There is an infinite sequence consisting of all positive integers in the increasing order: p = {1, 2, 3, ...}. We performed n swap operations with this sequence. A swap(a, b) is an operation of swapping the elements of the sequence on positions a and b. Your task is to find the number of inversions in the resulting seq...
[["3\n1 6\n3 4\n2 5\n", "15"], ["2\n4 2\n1 4\n", "4"], ["5\n2 5\n6 3\n4 6\n5 4\n2 5\n", "5"], ["30\n1 200000\n2 199999\n3 199998\n4 199997\n5 199996\n200001 399996\n200002 399997\n200003 399998\n200004 399999\n200005 400000\n400001 599998\n400002 599999\n400003 600000\n400004 599996\n400005 599995\n600001 800000\n60000...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00001-of-00005.parquet#2344"}
05b7d8d1781110d0
Given an integer N, find the base -2 representation of N. Here, S is the base -2 representation of N when the following are all satisfied: - S is a string consisting of 0 and 1. - Unless S = 0, the initial character of S is 1. - Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \tim...
[["-9\n", "1011\n"], ["123456789\n", "11000101011001101110100010101\n"], ["0\n", "0\n"], ["-84\n", "11111100\n"], ["-60\n", "11000100\n"], ["-41\n", "101011\n"], ["-100\n", "11101100\n"], ["8\n", "11000\n"], ["586260100\n", "1100111001101101110001110000100\n"], ["-192321079\n", "110101100111101011111011011001\n"], ["95...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00002-of-00004.parquet#1372"}
05bc687471ff40c7
Hierarchical Democracy The presidential election in Republic of Democratia is carried out through multiple stages as follows. 1. There are exactly two presidential candidates. 2. At the first stage, eligible voters go to the polls of his/her electoral district. The winner of the district is the candidate who takes a ...
[["6\n[[133][4567][89]]\n[[5][3][7][3][9]]\n[[[99][59][63][85][51]][[1539][7995][467]][[51][57][79][99][3][91][59]]]\n[[[37][95][31][77][15]][[43][5][5][5][85]][[71][3][51][89][29]][[57][95][5][69][31]][[99][59][65][73][31]]]\n[[[[9][7][3]][[3][5][7]][[7][9][5]]][[[9][9][3]][[5][9][9]][[7][7][3]]][[[5][9][7]][[3][9][3]...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00003-of-00004.parquet#513"}
05d07f440a4011fd
Takahashi, who works at DISCO, is standing before an iron bar. The bar has N-1 notches, which divide the bar into N sections. The i-th section from the left has a length of A_i millimeters. Takahashi wanted to choose a notch and cut the bar at that point into two parts with the same length. However, this may not be po...
[["3\n2 5 3", "4\n"], ["12\n100 104 102 105 103 103 100 105 104 102 104 101", "1\n"], ["3\n2 8 3", "7\n"], ["12\n100 104 102 105 103 103 100 117 104 102 104 101", "11\n"], ["3\n2 8 2", "8\n"], ["12\n101 104 102 105 103 103 100 117 104 102 104 101", "10\n"], ["12\n101 104 102 105 103 103 100 117 104 102 104 111", "20\n"...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#1758"}
05d3f179604c27b1
One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were x details in the factory storage, then by the end of the day the factory has to produce <image> (remainder after dividing x by m) more details. Unfortunately, no c...
[["1 5\n", "No\n"], ["3 6\n", "Yes\n"], ["32768 65536\n", "Yes\n"], ["2 3\n", "No\n"], ["1 100000\n", "No\n"], ["65535 65536\n", "Yes\n"], ["1 99989\n", "No\n"], ["1 1\n", "Yes\n"], ["100 24\n", "No\n"], ["1 8\n", "Yes\n"], ["99961 99971\n", "No\n"], ["3 65536\n", "Yes\n"], ["6 8\n", "Yes\n"], ["512 2\n", "Yes\n"], ["1...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00002-of-00005.parquet#2289"}
05d611c71698f646
Taro's Shopping Mammy decided to give Taro his first shopping experience. Mammy tells him to choose any two items he wants from those listed in the shopping catalogue, but Taro cannot decide which two, as all the items look attractive. Thus he plans to buy the pair of two items with the highest price sum, not exceedin...
[["3 45\n17 20 30\n6 10\n1 2 5 8 9 11\n7 100\n11 34 83 47 59 29 70\n4 100\n80 70 60 50\n4 20\n10 5 10 16\n0 0", "37\n10\n99\nNONE\n20\n"], ["3 45\n17 20 30\n6 10\n1 2 5 8 4 11\n7 000\n11 34 83 47 59 29 70\n4 100\n80 70 62 50\n4 20\n10 5 10 16\n0 0", "37\n10\nNONE\nNONE\n20\n"], ["3 45\n2 20 30\n6 10\n1 2 5 8 4 11\n7 10...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00003-of-00004.parquet#1426"}
05dd9f465e1c2af5
There are five people playing a game called "Generosity". Each person gives some non-zero number of coins b as an initial bet. After all players make their bets of b coins, the following operation is repeated for several times: a coin is passed from one player to some other player. Your task is to write a program that...
[["2 5 4 0 4\n", "3\n"], ["4 5 9 2 1\n", "-1\n"], ["0 0 0 0 0\n", "-1\n"], ["1 2 1 2 3\n", "-1\n"], ["100 0 0 0 0\n", "20\n"], ["2 3 4 5 6\n", "4\n"], ["1 1 1 1 1\n", "1\n"], ["0 1 2 3 4\n", "2\n"], ["100 100 100 100 100\n", "100\n"], ["93 100 99 90 98\n", "96\n"], ["99 99 99 99 99\n", "99\n"], ["99 98 98 99 100\n", "-...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#1451"}
05ea01ed05ff288f
Zookeeper is playing a game. In this game, Zookeeper must use bombs to bomb a string that consists of letters 'A' and 'B'. He can use bombs to bomb a substring which is either "AB" or "BB". When he bombs such a substring, the substring gets deleted from the string and the remaining parts of the string get concatenated....
[["3\nAAA\nBABA\nAABBBABBBB\n", "3\n2\n0\n"], ["3\nAAA\nAABA\nAABBBABBBB\n", "3\n2\n0\n"], ["3\nAAB\nBABA\nAABBBABBBB\n", "1\n2\n0\n"], ["3\nAAB\nBABA\nBBBBABBBAA\n", "1\n2\n2\n"], ["3\nAAB\nBAAA\nBBBBABBBAA\n", "1\n4\n2\n"], ["3\nAAA\nBABB\nAABBBABBBB\n", "3\n0\n0\n"], ["3\nAAB\nABAB\nBBBBABBBAA\n", "1\n0\n2\n"], ["3\...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00002-of-00004.parquet#81"}
05f4e6dec0aba7f4
You are given a positive integer X. Find the largest perfect power that is at most X. Here, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2. -----Constraints----- - 1 ≤ X ≤ 1000 - X is an integer. -----Input----- Input is given ...
[["10\n", "9\n"], ["1\n", "1\n"], ["999\n", "961\n"], ["20", "16\n"], ["610", "576\n"], ["38", "36\n"], ["159", "144\n"], ["107", "100\n"], ["72", "64\n"], ["136", "128\n"], ["217", "216\n"], ["261", "256\n"], ["011", "9\n"], ["001", "1\n"], ["7", "4\n"], ["689", "676\n"], ["747", "729\n"], ["52", "49\n"], ["83", "81\n...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00000-of-00004.parquet#1134"}
05f6cf06691f5ad9
Xenia the beginner programmer has a sequence a, consisting of 2^{n} non-negative integers: a_1, a_2, ..., a_2^{n}. Xenia is currently studying bit operations. To better understand how they work, Xenia decided to calculate some value v for a. Namely, it takes several iterations to calculate value v. At the first iterat...
[["2 4\n1 6 3 5\n1 4\n3 4\n1 2\n1 2\n", "1\n3\n3\n3\n"], ["1 1\n1 1\n1 1\n", "1\n"], ["1 10\n6 26\n1 11\n1 9\n1 31\n1 10\n2 12\n1 8\n2 10\n2 4\n2 18\n1 31\n", "27\n27\n31\n26\n14\n12\n10\n12\n26\n31\n"], ["1 10\n22 17\n2 15\n2 12\n1 6\n1 16\n2 24\n1 21\n2 19\n2 25\n2 19\n2 1\n", "31\n30\n14\n28\n24\n29\n23\n29\n23\n21\...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00003-of-00004.parquet#16"}
05fe3199f94a43d5
You will be given a string S of length 3 representing the weather forecast for three days in the past. The i-th character (1 \leq i \leq 3) of S represents the forecast for the i-th day. `S`, `C`, and `R` stand for sunny, cloudy, and rainy, respectively. You will also be given a string T of length 3 representing the ...
[["CSS\nCSR", "2"], ["RRR\nSSS", "0"], ["SSR\nSSR", "3"], ["CSS\nBSR", "1\n"], ["SRR\nSSR", "2\n"], ["SSR\nRTS", "0\n"], ["STR\nSTR", "3\n"], ["RSR\nSSS", "1\n"], ["SSC\nBSR", "1\n"], ["RSR\nSSR", "2\n"], ["SSR\nRSS", "1\n"], ["SSC\nRSB", "1\n"], ["RTR\nSSR", "1\n"], ["CSS\nRSB", "1\n"], ["RTR\nSTR", "2\n"], ["SSR\nRTR...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00002-of-00005.parquet#954"}
060947a924f66c63
Soroush and Keshi each have a labeled and rooted tree on n vertices. Both of their trees are rooted from vertex 1. Soroush and Keshi used to be at war. After endless decades of fighting, they finally became allies to prepare a Codeforces round. To celebrate this fortunate event, they decided to make a memorial graph o...
[["4\n4\n1 2 3\n1 2 3\n5\n1 2 3 4\n1 1 1 1\n6\n1 2 1 1 2\n1 2 1 2 2\n7\n1 1 3 4 4 5\n1 2 1 4 2 5\n", "1\n4\n1\n3\n"], ["4\n4\n1 2 3\n1 2 3\n5\n1 2 3 4\n1 1 1 1\n6\n1 2 1 1 2\n1 2 1 2 2\n7\n1 1 3 4 4 5\n1 2 1 4 4 5\n", "1\n4\n1\n2\n"], ["4\n4\n1 2 3\n1 2 3\n5\n1 4 3 4\n1 1 1 1\n6\n1 1 1 1 2\n1 2 1 2 2\n7\n1 1 3 4 4 5\n1...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#160"}
060fd1f594b5f8f4
This is the harder version of the problem. In this version, $1 \le n \le 10^6$ and $0 \leq a_i \leq 10^6$. You can hack this problem if you locked it. But you can hack the previous problem only if you locked both problems Christmas is coming, and our protagonist, Bob, is preparing a spectacular present for his long-ti...
[["3\n4 8 5\n", "9\n"], ["5\n3 10 2 1 5\n", "2\n"], ["4\n0 5 15 10\n", "0\n"], ["1\n1\n", "-1\n"], ["3\n0 0 17\n", "0\n"], ["3\n0 0 1\n", "-1\n"], ["1\n2103\n", "0\n"], ["10\n3 3 3 5 6 9 3 1 7 3\n", "90\n"], ["100\n61 28 67 53 13 6 70 5 79 82 60 60 84 17 80 25 82 82 69 76 81 43 58 86 18 78 4 25 8 30 33 87 91 18 90 26 6...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00003-of-00004.parquet#35"}
061fd4e1658c6334
Once Vasya played bricks. All the bricks in the set had regular cubical shape. Vasya vas a talented architect, however the tower he built kept falling apart. Let us consider the building process. Vasya takes a brick and puts it on top of the already built tower so that the sides of the brick are parallel to the sides ...
[["7\n4 6 1 9\n-1 4 6 11\n8 13 -3 2\n-5 0 45 50\n-2 50 45 3\n45 50 -4 1\n45 50 -1 4\n", "3"], ["11\n12 12 -12 -12\n11 8 -11 -14\n-15 -11 -3 1\n-16 -3 -14 -1\n-7 -8 -21 6\n37 -6 -19 50\n-21 -12 41 50\n48 -13 -15 50\n48 -14 -16 50\n-21 -18 47 50\n40 50 -15 -5\n", "4"], ["20\n9 -3 16 4\n11 2 14 -1\n6 -6 19 7\n16 -3 9 4\n5...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00002-of-00004.parquet#597"}
062731eefbb6305d
Books are indexed. Write a program which reads a list of pairs of a word and a page number, and prints the word and a list of the corresponding page numbers. You can assume that a word consists of at most 30 characters, and the page number is less than or equal to 1000. The number of pairs of a word and a page number ...
[["style 12\neven 25\nintroduction 3\neasy 9\nstyle 9\ndocument 13\nstyle 21\neven 18", "document\n13\neasy\n9\neven\n18 25\nintroduction\n3\nstyle\n9 12 21\n"], ["style 12\neven 25\nintroduction 3\neasy 9\nstyle 9\ntnemucod 13\nstyle 21\neven 18", "easy\n9\neven\n18 25\nintroduction\n3\nstyle\n9 12 21\ntnemucod\n13\n"...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#600"}
0631411d2f22e865
A tree is an undirected connected graph without cycles. The distance between two vertices is the number of edges in a simple path between them. Limak is a little polar bear. He lives in a tree that consists of n vertices, numbered 1 through n. Limak recently learned how to jump. He can jump from a vertex to any verte...
[["6 2\n1 2\n1 3\n2 4\n2 5\n4 6\n", "20\n"], ["13 3\n1 2\n3 2\n4 2\n5 2\n3 6\n10 6\n6 7\n6 13\n5 8\n5 9\n9 11\n11 12\n", "114\n"], ["3 5\n2 1\n3 1\n", "3\n"], ["2 1\n1 2\n", "1\n"], ["2 5\n2 1\n", "1\n"], ["15 1\n12 9\n13 7\n1 3\n10 4\n9 2\n2 15\n11 4\n2 14\n10 8\n6 7\n12 5\n8 7\n3 10\n10 2\n", "346\n"], ["4 2\n3 4\n2 ...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00002-of-00004.parquet#1546"}
0634cedd713b0c79
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. Phantasialand boasts of its famous theme park. The park is frequently visited. It is quite large park that some tourists visit it more than once to fully appreciate its offerings. One day, our Chefs decided to visit the park. There are tota...
[["2\n3 1", "2"], ["4\n1 2 3 3", "5"], ["2\n4 1", "3\n"], ["4\n1 2 5 3", "6\n"], ["2\n3 0", "2\n"], ["4\n1 2 8 3", "7\n"], ["4\n1 0 12 4", "9\n"], ["4\n1 0 12 6", "10\n"], ["4\n1 0 1 6", "4\n"], ["4\n1 0 1 7", "5\n"], ["4\n1 0 11 4", "8\n"], ["4\n1 -1 12 11", "12\n"], ["4\n2 0 -1 25", "13\n"], ["4\n1 -2 12 11", "11\n"]...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00002-of-00004.parquet#234"}
063d0b3f283d0e00
Vanya walks late at night along a straight street of length l, lit by n lanterns. Consider the coordinate system with the beginning of the street corresponding to the point 0, and its end corresponding to the point l. Then the i-th lantern is at the point ai. The lantern lights all points of the street that are at the ...
[["7 15\n15 5 3 7 9 14 0\n", "2.5\n"], ["2 5\n2 5\n", "2.0\n"], ["46 615683844\n431749087 271781274 274974690 324606253 480870261 401650581 13285442 478090364 266585394 425024433 588791449 492057200 391293435 563090494 317950 173675329 473068378 356306865 311731938 192959832 321180686 141984626 578985584 512026637 1758...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00002-of-00005.parquet#2876"}
063f80b5b6226113
At a geometry lesson Bob learnt that a triangle is called right-angled if it is nondegenerate and one of its angles is right. Bob decided to draw such a triangle immediately: on a sheet of paper he drew three points with integer coordinates, and joined them with segments of straight lines, then he showed the triangle t...
[["30 8 49 13 25 27\n", "RIGHT\n"], ["-67 49 89 -76 -37 87\n", "NEITHER\n"], ["34 74 -2 -95 63 -33\n", "NEITHER\n"], ["-66 24 8 -29 17 62\n", "NEITHER\n"], ["-10 -11 62 6 -12 -3\n", "ALMOST\n"], ["49 -7 19 -76 26 3\n", "RIGHT\n"], ["0 0 1 0 4 1\n", "NEITHER\n"], ["-50 -1 0 50 0 -50\n", "ALMOST\n"], ["0 0 1 0 2 1\n", "A...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00003-of-00004.parquet#896"}
0640205c8bf2be20
Slime and his $n$ friends are at a party. Slime has designed a game for his friends to play. At the beginning of the game, the $i$-th player has $a_i$ biscuits. At each second, Slime will choose a biscuit randomly uniformly among all $a_1 + a_2 + \ldots + a_n$ biscuits, and the owner of this biscuit will give it to a ...
[["2\n1 1\n", "1\n"], ["5\n0 0 0 0 35\n", "0\n"], ["5\n8 4 2 0 1\n", "801604029\n"], ["2\n0 1\n", "0\n"], ["100\n4364 698 1003 1128 1513 39 4339 969 7452 3415 1154 1635 6649 136 1442 50 834 1680 107 978 983 3176 4017 1692 1113 1504 1118 396 1975 2053 2366 3022 3007 167 610 4649 14659 2331 4565 318 7232 204 7131 6122 28...
4
{"source": "deepcoder/taco", "upstream_id": "taco/train-00002-of-00004.parquet#1345"}
0646fecf9743e61d
Blake is a CEO of a large company called "Blake Technologies". He loves his company very much and he thinks that his company should be the best. That is why every candidate needs to pass through the interview that consists of the following problem. We define function f(x, l, r) as a bitwise OR of integers x_{l}, x_{l}...
[["5\n1 2 4 3 2\n2 3 3 12 1\n", "22"], ["10\n13 2 7 11 8 4 9 8 5 1\n5 7 18 9 2 3 0 11 8 6\n", "46"], ["25\n12 30 38 109 81 124 80 33 38 48 29 78 96 48 96 27 80 77 102 65 80 113 31 118 35\n25 64 95 13 12 6 111 80 85 16 61 119 23 65 73 65 20 95 124 18 28 79 125 106 116\n", "254"], ["20\n64 64 64 64 64 64 64 64 64 64 64 6...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00000-of-00004.parquet#1093"}
064d9676c529ab25
There are N cities numbered 1 to N, connected by M railroads. You are now at City 1, with 10^{100} gold coins and S silver coins in your pocket. The i-th railroad connects City U_i and City V_i bidirectionally, and a one-way trip costs A_i silver coins and takes B_i minutes. You cannot use gold coins to pay the fare. T...
[["3 2 1\n1 2 1 2\n1 3 2 4\n1 11\n1 2\n2 5\n", "2\n14\n"], ["4 4 1\n1 2 1 5\n1 3 4 4\n2 4 2 2\n3 4 1 1\n3 1\n3 1\n5 2\n6 4\n", "5\n5\n7\n"], ["50 98 49\n12 13 38 966876944\n35 47 5 419053521\n20 23 39 513566946\n43 45 31 973756616\n11 39 45 339701654\n8 12 34 119183522\n5 16 50 644322683\n37 44 42 476275226\n3 4 41 832...
4
{"source": "deepcoder/taco", "upstream_id": "taco/train-00001-of-00004.parquet#90"}
064dfbf2bb62265f
A game is played on a strip consisting of N cells consecutively numbered from 1 to N. Alice has her token on cell A. Borys has his token on a different cell B. Players take turns, Alice moves first. The moving player must shift his or her token from its current cell X to the neighboring cell on the left, cell X-1, or...
[["9 23 42", "Borys\n"], ["8 2 4", "Alice\n"], ["3 1 2", "Borys\n"], ["9 23 18", "Borys\n"], ["3 2 2", "Alice\n"], ["8 2 3", "Borys\n"], ["9 23 23", "Alice\n"], ["0 2 2", "Alice\n"], ["7 2 3", "Borys\n"], ["9 44 23", "Borys\n"], ["0 2 1", "Borys\n"], ["7 2 5", "Borys\n"], ["9 44 0", "Alice\n"], ["0 0 1", "Borys\n"], ["...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00003-of-00004.parquet#1852"}
064e1a64493ca50b
Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank. The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.) Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above...
[["103\n", "3\n"], ["1000000000000000000\n", "3760\n"], ["1333333333\n", "1706\n"], ["822981260158260822\n", "3740\n"], ["28316250877914975\n", "3402\n"], ["779547116602436626\n", "3735\n"], ["578223540024980345\n", "3705\n"], ["335408917861649372\n", "3650\n"], ["150803184066\n", "2181\n"], ["2008788901\n", "1747\n"],...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00002-of-00004.parquet#1858"}
0665ee0b4cae53dd
A boy named Ayrat lives on planet AMI-1511. Each inhabitant of this planet has a talent. Specifically, Ayrat loves running, moreover, just running is not enough for him. He is dreaming of making running a real art. First, he wants to construct the running track with coating t. On planet AMI-1511 the coating of the tra...
[["abc\ncbaabc\n", "2\n3 1\n1 3\n"], ["aaabrytaaa\nayrat\n", "3\n1 1\n6 5\n8 7\n"], ["ami\nno\n", "-1\n"], ["r\nr\n", "1\n1 1\n"], ["r\nb\n", "-1\n"], ["randb\nbandr\n", "3\n5 5\n2 4\n1 1\n"], ["aaaaaa\naaaaa\n", "1\n1 5\n"], ["aaaaaa\naaaaaaa\n", "2\n1 6\n1 1\n"], ["qwerty\nywertyrewqqq\n", "5\n6 6\n2 6\n4 1\n1 1\n1 1...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00002-of-00004.parquet#503"}
0669d6bbdec67ccd
Kizahashi, who was appointed as the administrator of ABC at National Problem Workshop in the Kingdom of AtCoder, got too excited and took on too many jobs. Let the current time be time 0. Kizahashi has N jobs numbered 1 to N. It takes A_i units of time for Kizahashi to complete Job i. The deadline for Job i is time B...
[["3\n334 1000\n334 1000\n334 1000", "No"], ["5\n2 4\n1 9\n1 8\n4 9\n3 12", "Yes"], ["30\n384 8895\n1725 9791\n170 1024\n4 11105\n2 6\n578 1815\n702 3352\n143 5141\n1420 6980\n24 1602\n849 999\n76 7586\n85 5570\n444 4991\n719 11090\n470 10708\n1137 4547\n455 9003\n110 9901\n15 8578\n368 3692\n104 1286\n3 4\n366 12143\n...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00002-of-00005.parquet#419"}
067510a63c9d784c
There is a circle with a circumference of L. Each point on the circumference has a coordinate value, which represents the arc length from a certain reference point clockwise to the point. On this circumference, there are N ants. These ants are numbered 1 through N in order of increasing coordinate, and ant i is at coor...
[["3 8 3\n0 2\n3 2\n6 1", "0\n1\n5\n"], ["4 20 18\n7 2\n9 1\n12 1\n18 1", "10\n16\n7\n9\n"], ["2 8 3\n0 1\n3 2\n6 1", "0\n3\n"], ["3 8 3\n1 2\n3 2\n6 1", "0\n1\n6\n"], ["4 20 18\n3 2\n9 1\n12 1\n18 1", "10\n16\n5\n7\n"], ["1 8 3\n1 2\n3 2\n6 1", "6\n"], ["1 8 0\n1 2\n3 4\n6 1", "1\n"], ["1 8 1\n1 2\n3 4\n6 1", "0\n"], ...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00003-of-00004.parquet#1628"}
06909fa65ea53687
Vova's family is building the Great Vova Wall (named by Vova himself). Vova's parents, grandparents, grand-grandparents contributed to it. Now it's totally up to Vova to put the finishing touches. The current state of the wall can be respresented by a sequence $a$ of $n$ integers, with $a_i$ being the height of the $i...
[["5\n2 1 1 2 5\n", "YES\n"], ["3\n4 5 3\n", "NO\n"], ["2\n10 10\n", "YES\n"], ["4\n1 2 2 1\n", "NO\n"], ["6\n3 2 3 3 2 3\n", "NO\n"], ["1\n1\n", "YES\n"], ["14\n7 7 7 4 3 3 4 5 4 4 5 7 7 7\n", "YES\n"], ["10\n1 9 7 6 2 4 7 8 1 3\n", "NO\n"], ["6\n1 1 1 1 2 1\n", "NO\n"], ["7\n1 1 2 2 3 3 1\n", "NO\n"], ["4\n2 2 2 3\n"...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00003-of-00004.parquet#400"}
069103beb27d7a4e
Problem There are $ M $ type characters. Use them to create a string of length $ N $. How many strings are used that have $ K $ or more? Find too much divided by $ 998244353 $. Here, the difference between two strings of length $ N $ is defined as follows. * If the two strings are $ S = S_1S_2 \ ldots S_N $, $ T = T...
[["10 8 3", "99988560\n"], ["1000000000000000000 1000000000000000000 1001", "824796085\n"], ["5 2 3", "0\n"], ["10 8 6", "58968000\n"], ["2 2 2", "2\n"], ["1 10 1", "1\n"], ["10 6 6", "151200\n"], ["2 3 2", "6\n"], ["2 10 2", "1022\n"], ["2 11 2", "2046\n"], ["3 5 3", "150\n"], ["6 5 3", "7320\n"], ["6 5 2", "7770\n"],...
1.26
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00003-of-00005.parquet#2644"}
06991dda0d4fe84e
Read problems statements in Russian also. Chef plays with the sequence of N numbers. During a single move Chef is able to choose a non-decreasing subsequence of the sequence and to remove it from the sequence. Help him to remove all the numbers in the minimal number of moves. ------ Input ------ The first line of ...
[["3 \n1 2 3", "1"], ["4\n4 1 2 3", "2"], ["3 \n1 2 5", "1\n"], ["4\n4 1 3 3", "2\n"], ["3 \n5 1 0", "3\n"], ["4\n20 -1 -2 -4", "4\n"], ["3 \n1 2 8", "1\n"], ["4\n4 1 5 3", "2\n"], ["3 \n1 1 8", "1\n"], ["4\n4 0 5 3", "2\n"], ["3 \n1 1 16", "1\n"], ["4\n4 -1 5 3", "2\n"], ["3 \n2 1 16", "2\n"], ["4\n4 -1 5 4", "2\n"], ...
1
{"source": "deepcoder/taco", "upstream_id": "taco/train-00003-of-00004.parquet#451"}
069bd9bbf878cd7e
A remote island chain contains n islands, labeled 1 through n. Bidirectional bridges connect the islands to form a simple cycle — a bridge connects islands 1 and 2, islands 2 and 3, and so on, and additionally a bridge connects islands n and 1. The center of each island contains an identical pedestal, and all but one o...
[["3\n1 0 2\n2 0 1\n", "YES"], ["2\n1 0\n0 1\n", "YES"], ["4\n1 2 3 0\n0 3 2 1\n", "NO"], ["10\n4 1 9 7 0 2 6 3 5 8\n6 4 2 9 1 8 5 3 0 7\n1 4\n1 7\n9 5\n6 1\n1 2\n1 9\n3 1\n10 1\n8 4\n", "NO"], ["10\n0 7 4 1 6 3 5 8 9 2\n4 7 1 2 3 9 5 6 0 8\n5 9\n4 1\n1 7\n10 1\n1 6\n8 4\n1 5\n2 1\n3 1\n", "NO"], ["10\n0 9 4 5 7 2 1 6 ...
1
{"source": "deepcoder/primeintellect", "upstream_id": "primeintellect/train-00001-of-00005.parquet#2038"}