prompt
listlengths
1
1
data_source
stringclasses
1 value
ability
stringclasses
1 value
reward_model
null
extra_info
dict
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Iris and Game on the Tree\ntime_limit_ms: 2000\nmemory_limit_mb: 256\nDescription: Iris has a tree rooted at vertex $1$. Each vertex has a value of $\\mathtt 0$ or $\\mathtt 1$.\n\nLet's consider a leaf of the tree (the vertex $1$ is never considered a leaf) and define its weight. Construct a string formed by the values of the vertices on the path starting at the root and ending in this leaf. Then the weight of the leaf is the difference between the number of occurrences of $\\mathtt{10}$ and $\\mathtt{01}$ substrings in it.\n\nTake the following tree as an example. Green vertices have a value of $\\mathtt 1$ while white vertices have a value of $\\mathtt 0$.\n\n![](CDN_BASE_URL/712e8f1acc71d0401cf5eb23441e53a5)\n\n * Let's calculate the weight of the leaf $5$: the formed string is $\\mathtt{10110}$. The number of occurrences of substring $\\mathtt{10}$ is $2$, the number of occurrences of substring $\\mathtt{01}$ is $1$, so the difference is $2 - 1 = 1$. * Let's calculate the weight of the leaf $6$: the formed string is $\\mathtt{101}$. The number of occurrences of substring $\\mathtt{10}$ is $1$, the number of occurrences of substring $\\mathtt{01}$ is $1$, so the difference is $1 - 1 = 0$.\n\nThe score of a tree is defined as the number of leaves with non-zero weight in the tree.\n\nBut the values of some vertices haven't been decided and will be given to you as $\\texttt{?}$. Filling the blanks would be so boring, so Iris is going to invite Dora to play a game. On each turn, one of the girls chooses any of the remaining vertices with value $\\texttt{?}$ and changes its value to $\\mathtt{0}$ or $\\mathtt{1}$, with Iris going first. The game continues until there are no vertices with value $\\mathtt{?}$ left in the tree. Iris aims to maximize the score of the tree, while Dora aims to minimize that.\n\nAssuming that both girls play optimally, please determine the final score of the tree.\n\nInput: Each test consists of multiple test cases. The first line contains a single integer $t$ ($1 \\leq t \\leq 5\\cdot 10^4$) β€” the number of test cases. The description of the test cases follows.\n\nThe first line of each test case contains a single integer $n$ ($2 \\leq n \\leq 10^5$) β€” the number of vertices in the tree.\n\nThe following $n - 1$ lines each contain two integers $u$ and $v$ ($1 \\leq u, v \\leq n$) β€” denoting an edge between vertices $u$ and $v$.\n\nIt's guaranteed that the given edges form a tree.\n\nThe last line contains a string $s$ of length $n$. The $i$-th character of $s$ represents the value of vertex $i$. It's guaranteed that $s$ only contains characters $\\mathtt{0}$, $\\mathtt{1}$ and $\\mathtt{?}$.\n\nIt is guaranteed that the sum of $n$ over all test cases doesn't exceed $2\\cdot 10^5$.\n\nOutput: For each test case, output a single integer β€” the final score of the tree.\n\nExamples:\ninput:\n6\n4\n1 2\n1 3\n4 1\n0101\n4\n1 2\n3 2\n2 4\n???0\n5\n1 2\n1 3\n2 4\n2 5\n?1?01\n6\n1 2\n2 3\n3 4\n5 3\n3 6\n?0????\n5\n1 2\n1 3\n1 4\n1 5\n11?1?\n2\n2 1\n??\noutput:\n2\n1\n1\n2\n1\n0\n\nNote: In the first test case, all the values of the vertices have been determined. There are three different paths from the root to a leaf:\n\n * From vertex $1$ to vertex $2$. The string formed by the path is $\\mathtt{01}$, so the weight of the leaf is $0-1=-1$. * From vertex $1$ to vertex $3$. The string formed by the path is $\\mathtt{00}$, so the weight of the leaf is $0-0=0$. * From vertex $1$ to vertex $4$. The string formed by the path is $\\mathtt{01}$, so the weight of the leaf is $0-1=-1$. \n\nThus, there are two leaves with non-zero weight, so the score of the tree is $2$.\n\nIn the second test case, one of the sequences of optimal choices for the two players can be:\n\n * Iris chooses to change the value of the vertex $3$ to $\\mathtt 1$. * Dora chooses to change the value of the vertex $1$ to $\\mathtt 0$. * Iris chooses to change the value of the vertex $2$ to $\\mathtt 0$. \n\nThe final tree is as follows:\n\n![](CDN_BASE_URL/c8e20d0cf352b7905e60a7b371f053d6)\n\nThe only leaf with non-zero weight is $3$, so the score of the tree is $1$. Note that this may not be the only sequence of optimal choices for Iris and Dora.\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "2006A", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Iris and the Tree\ntime_limit_ms: 3000\nmemory_limit_mb: 256\nDescription: Given a rooted tree with the root at vertex $1$. For any vertex $i$ ($1 < i \\leq n$) in the tree, there is an edge connecting vertices $i$ and $p_i$ ($1 \\leq p_i < i$), with a weight equal to $t_i$.\n\nIris does not know the values of $t_i$, but she knows that $\\displaystyle\\sum_{i=2}^n t_i = w$ and each of the $t_i$ is a non- negative integer.\n\nThe vertices of the tree are numbered in a special way: the numbers of the vertices in each subtree are consecutive integers. In other words, the vertices of the tree are numbered in the order of a depth-first search.\n\n![](CDN_BASE_URL/274244c032854fe172d47861e2eb9c02) The tree in this picture satisfies the condition. For example, in the subtree of vertex $2$, the vertex numbers are $2, 3, 4, 5$, which are consecutive integers. ![](CDN_BASE_URL/83174231191d329be697a6e3f67b5eb3) The tree in this picture does not satisfy the condition, as in the subtree of vertex $2$, the vertex numbers $2$ and $4$ are not consecutive integers.\n\nWe define $\\operatorname{dist}(u, v)$ as the length of the simple path between vertices $u$ and $v$ in the tree.\n\nNext, there will be $n - 1$ events:\n\n * Iris is given integers $x$ and $y$, indicating that $t_x = y$. \n\nAfter each event, Iris wants to know the maximum possible value of $\\operatorname{dist}(i, i \\bmod n + 1)$ independently for each $i$ ($1\\le i\\le n$). She only needs to know the sum of these $n$ values. Please help Iris quickly get the answers.\n\nNote that when calculating the maximum possible values of $\\operatorname{dist}(i, i \\bmod n + 1)$ and $\\operatorname{dist}(j, j \\bmod n + 1)$ for $i \\ne j$, the unknown edge weights may be different.\n\nInput: Each test consists of multiple test cases. The first line contains a single integer $t$ ($1 \\leq t \\leq 10^4$) β€” the number of test cases. The description of the test cases follows.\n\nThe first line of each test case contains two integers $n$ and $w$ ($2 \\le n \\le 2 \\cdot 10^5$, $0 \\leq w \\leq 10^{12}$) β€” the number of vertices in the tree and the sum of the edge weights.\n\nThe second line of each test case contains $n - 1$ integers $p_2, p_3, \\ldots, p_n$ ($1 \\leq p_i < i$) β€” the description of the edges of the tree.\n\nThen follow $n-1$ lines indicating the events. Each line contains two integers $x$ and $y$ ($2 \\leq x \\leq n$, $0 \\leq y \\leq w$), indicating that $t_x = y$.\n\nIt is guaranteed that all $x$ in the events are distinct. It is also guaranteed that the sum of all $y$ equals $w$.\n\nIt is guaranteed that the sum of $n$ over all test cases does not exceed $2 \\cdot 10^5$.\n\nOutput: For each test case, output one line containing $n-1$ integers, each representing the answer after each event.\n\nExamples:\ninput:\n4\n2 1000000000000\n1\n2 1000000000000\n4 9\n1 1 1\n2 2\n4 4\n3 3\n6 100\n1 2 3 2 1\n6 17\n3 32\n2 4\n4 26\n5 21\n10 511\n1 2 2 4 2 1 1 8 8\n3 2\n6 16\n10 256\n9 128\n2 1\n5 8\n8 64\n4 4\n7 32\noutput:\n2000000000000\n25 18 18\n449 302 247 200 200\n4585 4473 2681 1567 1454 1322 1094 1022 1022\n\nNote: In the first test case, $\\operatorname{dist}(1, 2) = \\operatorname{dist}(2, 1) = t_2 = w = 10^{12}$, so $\\operatorname{dist}(1, 2) + \\operatorname{dist}(2, 1) = 2 \\cdot 10^{12}$.\n\nIn the second test case, the tree after Iris found out all $t_x$ is shown below:\n\n![](CDN_BASE_URL/2f461ea7db7bb0cda4536a2a78190c2f)\n\n$\\operatorname{dist}(1, 2) = t_2$, $\\operatorname{dist}(2, 3) = t_2 + t_3$, $\\operatorname{dist}(3, 4) = t_3 + t_4$, $\\operatorname{dist}(4, 1) = t_4$. After the first event, she found out that $t_2 = 2$, so $\\operatorname{dist}(1, 2) = 2$. At the same time:\n\n * $\\operatorname{dist}(2, 3)$ is maximized if $t_3 = 7$, $t_4 = 0$. Then $\\operatorname{dist}(2, 3) = 9$. * $\\operatorname{dist}(3, 4)$ and $\\operatorname{dist}(4, 1)$ are maximized if $t_3 = 0$, $t_4 = 7$. Then $\\operatorname{dist}(3, 4) = \\operatorname{dist}(4, 1) = 7$. \n\nThus, the answer is $2 + 9 + 7 + 7 = 25$.\n\nAfter the second event, she found out that $t_4 = 4$, then $t_3 = w - t_2 - t_4 = 4$. $\\operatorname{dist}(1, 2) = 2$, $\\operatorname{dist}(2, 3) = 2 + 3 = 5$, $\\operatorname{dist}(3, 4) = 3 + 4 = 7$, $\\operatorname{dist}(4, 1) = 4$. Thus, the answer is $2 + 5 + 7 + 4 = 18$.\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "2006B", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Eri and Expanded Sets\ntime_limit_ms: 3000\nmemory_limit_mb: 512\nDescription: Let there be a set that contains distinct positive integers. To expand the set to contain as many integers as possible, Eri can choose two integers $x\\neq y$ from the set such that their average $\\frac{x+y}2$ is still a positive integer and isn't contained in the set, and add it to the set. The integers $x$ and $y$ remain in the set.\n\nLet's call the set of integers consecutive if, after the elements are sorted, the difference between any pair of adjacent elements is $1$. For example, sets $\\\\{2\\\\}$, $\\\\{2, 5, 4, 3\\\\}$, $\\\\{5, 6, 8, 7\\\\}$ are consecutive, while $\\\\{2, 4, 5, 6\\\\}$, $\\\\{9, 7\\\\}$ are not.\n\nEri likes consecutive sets. Suppose there is an array $b$, then Eri puts all elements in $b$ into the set. If after a finite number of operations described above, the set can become consecutive, the array $b$ will be called brilliant.\n\nNote that if the same integer appears in the array multiple times, we only put it into the set once, as a set always contains distinct positive integers.\n\nEri has an array $a$ of $n$ positive integers. Please help him to count the number of pairs of integers $(l,r)$ such that $1 \\leq l \\leq r \\leq n$ and the subarray $a_l, a_{l+1}, \\ldots, a_r$ is brilliant.\n\nInput: Each test consists of multiple test cases. The first line contains a single integer $t$ ($1 \\leq t \\leq 10^4$) β€” the number of test cases. The description of the test cases follows.\n\nThe first line of each test case contains a single integer $n$ ($1 \\leq n \\leq 4 \\cdot 10^5$) β€” length of the array $a$.\n\nThe second line of each test case contains $n$ integers $a_1, a_2, \\ldots a_n$ ($1 \\leq a_i \\leq 10^9$) β€” the elements of the array $a$.\n\nIt is guaranteed that the sum of $n$ over all test cases doesn't exceed $4 \\cdot 10^5$.\n\nOutput: For each test case, output a single integer β€” the number of brilliant subarrays.\n\nExamples:\ninput:\n6\n2\n2 2\n6\n1 3 6 10 15 21\n5\n6 30 18 36 9\n1\n1000000000\n6\n1 1 4 5 1 4\n12\n70 130 90 90 90 108 612 500 451 171 193 193\noutput:\n3\n18\n5\n1\n18\n53\n\nNote: In the first test case, the array $a = [2, 2]$ has $3$ subarrays: $[2]$, $[2]$, and $[2, 2]$. For all of them, the set only contains a single integer $2$, therefore it's always consecutive. All these subarrays are brilliant, so the answer is $3$.\n\nIn the second test case, let's consider the subarray $[3, 6, 10]$. We can do operations as follows:\n\n$$\\\\{3,6,10\\\\} \\xrightarrow{x=6,y=10} \\\\{3,6,8,10\\\\} \\xrightarrow{x=6,y=8} \\\\{3,6,7,8,10\\\\} \\xrightarrow{x=3,y=7} \\\\{3,5,6,7,8,10\\\\}$$ $$\\xrightarrow{x=3,y=5} \\\\{3,4,5,6,7,8,10\\\\} \\xrightarrow{x=8,y=10} \\\\{3,4,5,6,7,8,9,10\\\\}$$\n\n$\\\\{3,4,5,6,7,8,9,10\\\\}$ is a consecutive set, so the subarray $[3, 6, 10]$ is brilliant.\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "2006C", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Cards Partition\ntime_limit_ms: 2000\nmemory_limit_mb: 256\nDescription: [DJ Genki vs Gram - Einherjar Joker](https://soundcloud.com/leon- hwang-368077289/einherjar-joker-dj-genki-vs-gram)\n\nβ €\n\nYou have some cards. An integer between $1$ and $n$ is written on each card: specifically, for each $i$ from $1$ to $n$, you have $a_i$ cards which have the number $i$ written on them.\n\nThere is also a shop which contains unlimited cards of each type. You have $k$ coins, so you can buy at most $k$ new cards in total, and the cards you buy can contain any integer between $\\mathbf{1}$ and $\\mathbf{n}$, inclusive.\n\nAfter buying the new cards, you must partition all your cards into decks, according to the following rules:\n\n * all the decks must have the same size; * there are no pairs of cards with the same value in the same deck. \n\nFind the maximum possible size of a deck after buying cards and partitioning them optimally.\n\nInput: Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \\le t \\le 10^4$). The description of the test cases follows.\n\nThe first line of each test case contains two integers $n$, $k$ ($1 \\leq n \\leq 2 \\cdot 10^5$, $0 \\leq k \\leq 10^{16}$) β€” the number of distinct types of cards and the number of coins.\n\nThe second line of each test case contains $n$ integers $a_1, a_2, \\ldots, a_n$ ($0 \\leq a_i \\leq 10^{10}$, $\\sum a_i \\geq 1$) β€” the number of cards of type $i$ you have at the beginning, for each $1 \\leq i \\leq n$.\n\nIt is guaranteed that the sum of $n$ over all test cases does not exceed $2 \\cdot 10^5$.\n\nOutput: For each test case, output a single integer: the maximum possible size of a deck if you operate optimally.\n\nExamples:\ninput:\n9\n3 1\n3 2 2\n5 4\n2 6 1 2 4\n2 100\n1410065408 10000000000\n10 8\n7 4 6 6 9 3 10 2 8 7\n2 12\n2 2\n2 70\n0 1\n1 0\n1\n3 0\n2 1 2\n3 1\n0 3 3\noutput:\n2\n3\n1\n7\n2\n2\n1\n1\n2\n\nNote: In the first test case, you can buy one card with the number $1$, and your cards become $[1, 1, 1, 1, 2, 2, 3, 3]$. You can partition them into the decks $[1, 2], [1, 2], [1, 3], [1, 3]$: they all have size $2$, and they all contain distinct values. You can show that you cannot get a partition with decks of size greater than $2$, so the answer is $2$.\n\nIn the second test case, you can buy two cards with the number $1$ and one card with the number $3$, and your cards become $[1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 4, 4, 5, 5, 5, 5]$, which can be partitioned into $[1, 2, 3], [1, 2, 4], [1, 2, 5], [1, 2, 5], [2, 3, 5], [2, 4, 5]$. You can show that you cannot get a partition with decks of size greater than $3$, so the answer is $3$.\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "2018A", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Speedbreaker\ntime_limit_ms: 2000\nmemory_limit_mb: 256\nDescription: [Djjaner - Speedbreaker](https://soundcloud.com/luciano- ferrari-151560131/speedbreaker)\n\nβ €\n\nThere are $n$ cities in a row, numbered $1, 2, \\ldots, n$ left to right.\n\n * At time $1$, you conquer exactly one city, called the starting city. * At time $2, 3, \\ldots, n$, you can choose a city adjacent to the ones conquered so far and conquer it. \n\nYou win if, for each $i$, you conquer city $i$ at a time no later than $a_i$. A winning strategy may or may not exist, also depending on the starting city. How many starting cities allow you to win?\n\nInput: Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \\le t \\le 10^4$). The description of the test cases follows.\n\nThe first line of each test case contains a single integer $n$ ($1 \\le n \\le 2 \\cdot 10^5$) β€” the number of cities.\n\nThe second line of each test case contains $n$ integers $a_1, a_2, \\ldots, a_n$ ($1 \\le a_i \\le n$) β€” the deadlines for conquering the cities.\n\nIt is guaranteed that the sum of $n$ over all test cases does not exceed $2 \\cdot 10^5$.\n\nOutput: For each test case, output a single integer: the number of starting cities that allow you to win.\n\nExamples:\ninput:\n3\n6\n6 3 3 3 5 5\n6\n5 6 4 1 4 5\n9\n8 6 4 2 1 3 5 7 9\noutput:\n3\n0\n1\n\nNote: In the first test case, cities $2$, $3$, and $4$ are good starting cities.\n\nIn the second test case, there are no good starting cities.\n\nIn the third test case, the only good starting city is city $5$.\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "2018B", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Tree Pruning\ntime_limit_ms: 3000\nmemory_limit_mb: 256\nDescription: [t+pazolite, ginkiha, Hommarju - Paved Garden](https://soundcloud.com/fractalex-gd/ginkiha-paved-garden-little)\n\nβ €\n\nYou are given a tree with $n$ nodes, rooted at node $1$. In this problem, a leaf is a non-root node with degree $1$.\n\nIn one operation, you can remove a leaf and the edge adjacent to it (possibly, new leaves appear). What is the minimum number of operations that you have to perform to get a tree, also rooted at node $1$, where all the leaves are at the same distance from the root?\n\nInput: Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \\le t \\le 10^4$). The description of the test cases follows.\n\nThe first line of each test case contains a single integer $n$ ($3 \\leq n \\leq 5 \\cdot 10^5$) β€” the number of nodes.\n\nEach of the next $n-1$ lines contains two integers $u$, $v$ ($1 \\leq u, v \\leq n$, $u \\neq v$), describing an edge that connects $u$ and $v$. It is guaranteed that the given edges form a tree.\n\nIt is guaranteed that the sum of $n$ over all test cases does not exceed $5 \\cdot 10^5$.\n\nOutput: For each test case, output a single integer: the minimum number of operations needed to achieve your goal.\n\nExamples:\ninput:\n3\n7\n1 2\n1 3\n2 4\n2 5\n4 6\n4 7\n7\n1 2\n1 3\n1 4\n2 5\n3 6\n5 7\n15\n12 9\n1 6\n6 14\n9 11\n8 7\n3 5\n13 5\n6 10\n13 15\n13 6\n14 12\n7 2\n8 1\n1 4\noutput:\n2\n2\n5\n\nNote: In the first two examples, the tree is as follows:\n\n![](CDN_BASE_URL/754511fbdb88995aaa49733a1fe75dfc)\n\nIn the first example, by removing edges $(1, 3)$ and $(2, 5)$, the resulting tree has all leaves (nodes $6$ and $7$) at the same distance from the root (node $1$), which is $3$. The answer is $2$, as it is the minimum number of edges that need to be removed to achieve the goal.\n\nIn the second example, removing edges $(1, 4)$ and $(5, 7)$ results in a tree where all leaves (nodes $4$ and $5$) are at the same distance from the root (node $1$), which is $2$.\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "2018C", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Max Plus Min Plus Size\ntime_limit_ms: 2000\nmemory_limit_mb: 256\nDescription: [EnV - The Dusty Dragon Tavern](https://soundcloud.com/envyofficial/env-the- dusty-dragon-tavern)\n\nβ €\n\nYou are given an array $a_1, a_2, \\ldots, a_n$ of positive integers.\n\nYou can color some elements of the array red, but there cannot be two adjacent red elements (i.e., for $1 \\leq i \\leq n-1$, at least one of $a_i$ and $a_{i+1}$ must not be red).\n\nYour score is the maximum value of a red element, plus the minimum value of a red element, plus the number of red elements. Find the maximum score you can get.\n\nInput: Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \\le t \\le 10^4$). The description of the test cases follows.\n\nThe first line of each test case contains a single integer $n$ ($1 \\le n \\le 2 \\cdot 10^5$) β€” the length of the array.\n\nThe second line of each test case contains $n$ integers $a_1, a_2, \\ldots, a_n$ ($1 \\le a_i \\le 10^9$) β€” the given array.\n\nIt is guaranteed that the sum of $n$ over all test cases does not exceed $2 \\cdot 10^5$.\n\nOutput: For each test case, output a single integer: the maximum possible score you can get after coloring some elements red according to the statement.\n\nExamples:\ninput:\n4\n3\n5 4 5\n3\n4 5 4\n10\n3 3 3 3 4 1 2 3 5 4\n10\n17 89 92 42 29 41 92 14 70 45\noutput:\n12\n11\n12\n186\n\nNote: In the first test case, you can color the array as follows: $[\\color{red}{5}, 4, \\color{red}{5}]$. Your score is $\\max([5, 5]) + \\min([5, 5]) + \\text{size}([5, 5]) = 5+5+2 = 12$. This is the maximum score you can get.\n\nIn the second test case, you can color the array as follows: $[4, \\color{red}{5}, 4]$. Your score is $\\max([5]) + \\min([5]) + \\text{size}([5]) = 5+5+1 = 11$. This is the maximum score you can get.\n\nIn the third test case, you can color the array as follows: $[\\color{red}{3}, 3, \\color{red}{3}, 3, \\color{red}{4}, 1, 2, \\color{red}{3}, 5, \\color{red}{4}]$. Your score is $\\max([3, 3, 4, 3, 4]) + \\min([3, 3, 4, 3, 4]) + \\text{size}([3, 3, 4, 3, 4]) = 4+3+5 = 12$. This is the maximum score you can get.\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "2018D", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Skipping\ntime_limit_ms: 2000\nmemory_limit_mb: 256\nDescription: It is already the year $3024$, ideas for problems have long run out, and the olympiad now takes place in a modified individual format. The olympiad consists of $n$ problems, numbered from $1$ to $n$. The $i$-th problem has its own score $a_i$ and a certain parameter $b_i$ ($1 \\le b_i \\le n$).\n\nInitially, the testing system gives the participant the first problem. When the participant is given the $i$-th problem, they have two options:\n\n * They can submit the problem and receive $a_i$ points; * They can skip the problem, in which case they will never be able to submit it. \n\nThen, the testing system selects the next problem for the participant from problems with indices $j$, such that:\n\n * If he submitted the $i$-th problem, it looks at problems with indices $j < i$; * If he skipped the $i$-th problem, it looks at problems with indices $j \\leq b_i$. \n\nAmong these problems, it selects the problem with the maximum index that it has not previously given to the participant (he has neither submitted nor skipped it before). If there is no such problem, then the competition for the participant ends, and their result is equal to the sum of points for all submitted problems. In particular, if the participant submits the first problem, then the competition for them ends. Note that the participant receives each problem at most once.\n\nProkhor has prepared thoroughly for the olympiad, and now he can submit any problem. Help him determine the maximum number of points he can achieve.\n\nInput: Each test consists of multiple test cases. The first line contains a single integer $t$ ($1 \\leq t \\leq 10^5$) β€” the number of test cases. The description of the test cases follows.\n\nThe first line of each test case contains a single integer $n$ ($1 \\leq n \\leq 4 \\cdot 10^5$) β€” the number of problems in the olympiad.\n\nThe second line of each test case contains $n$ integers $a_1, a_2, \\ldots, a_n$ ($1 \\leq a_i \\leq 10^9$) β€” the scores of the problems.\n\nThe third line of each test case contains $n$ integers $b_1, b_2, \\ldots, b_n$ ($1 \\leq b_i \\leq n$) β€” the parameters of the problems.\n\nIt is guaranteed that the sum of $n$ over all test cases does not exceed $4 \\cdot 10^5$.\n\nOutput: For each test case, output a single integer β€” the maximum number of points that Prokhor can achieve.\n\nExamples:\ninput:\n4\n2\n15 16\n2 1\n5\n10 10 100 100 1000\n3 4 1 1 1\n3\n100 49 50\n3 2 2\n4\n100 200 300 1000\n2 3 4 1\noutput:\n16\n200\n100\n1000\n\nNote: In the first test case, Prokhor can skip the first problem; then he will receive the problem with index $b_1 = 2$. Prokhor can submit it and receive $a_2 = 16$ points. After that, the competition will end because Prokhor has already received all problems. Note that if Prokhor submits the first problem, he will receive $a_1 = 15$ points, but the competition will end immediately.\n\nIn the second test case, Prokhor can skip the first problem; then he will receive the problem with index $b_1 = 3$. Prokhor can submit it and receive $a_3 = 100$ points. After that, Prokhor will receive the second problem, which he can skip to receive the problem with index $b_2 = 4$. Prokhor can submit the fourth problem and receive another $a_4 = 100$ points. After that, the competition ends because Prokhor has already received all problems with indices not exceeding $4$. Thus, Prokhor will receive a total of $200$ points.\n\nIn the third test case, Prokhor can submit the first problem and receive $100$ points, after which the competition will end immediately.\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "2023B", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: C+K+S\ntime_limit_ms: 3000\nmemory_limit_mb: 256\nDescription: You are given two strongly connected$^{\\dagger}$ directed graphs, each with exactly $n$ vertices, but possibly different numbers of edges. Upon closer inspection, you noticed an important feature β€” the length of any cycle in these graphs is divisible by $k$.\n\nEach of the $2n$ vertices belongs to exactly one of two types: incoming or outgoing. For each vertex, its type is known to you.\n\nYou need to determine whether it is possible to draw exactly $n$ directed edges between the source graphs such that the following four conditions are met:\n\n * The ends of any added edge lie in different graphs. * From each outgoing vertex, exactly one added edge originates. * Into each incoming vertex, exactly one added edge enters. * In the resulting graph, the length of any cycle is divisible by $k$. \n\n$^{\\dagger}$A strongly connected graph is a graph in which there is a path from every vertex to every other vertex.\n\nInput: Each test consists of multiple test cases. The first line contains a single integer $t$ ($1 \\le t \\le 10^4$) β€” the number of test cases. The description of the test cases follows.\n\nThe first line of each test case contains two integers $n$ and $k$ ($2 \\le k \\le n \\le 2 \\cdot 10^5$) β€” the number of vertices in each graph and the value by which the length of each cycle is divisible.\n\nThe second line of each test case contains $n$ integers $a_1, a_2, \\ldots, a_n$ ($a_i \\in \\\\{0, 1\\\\}$). If $a_i = 0$, then vertex $i$ of the first graph is incoming. If $a_i = 1$, then vertex $i$ of the first graph is outgoing.\n\nThe third line of each test case contains a single integer $m_1$ ($1 \\le m_1 \\le 5 \\cdot 10^5$) β€” the number of edges in the first graph.\n\nThe next $m_1$ lines contain descriptions of the edges of the first graph. The $i$-th of them contains two integers $v_i$ and $u_i$ ($1 \\le v_i, u_i \\le n$) β€” an edge in the first graph leading from vertex $v_i$ to vertex $u_i$.\n\nNext, in the same format, follows the description of the second graph.\n\nThe next line contains $n$ integers $b_1, b_2, \\ldots, b_n$ ($b_i \\in \\\\{0, 1\\\\}$). If $b_i = 0$, then vertex $i$ of the second graph is incoming. If $b_i = 1$, then vertex $i$ of the second graph is outgoing.\n\nThe next line contains a single integer $m_2$ ($1 \\le m_2 \\le 5 \\cdot 10^5$) β€” the number of edges in the second graph.\n\nThe next $m_2$ lines contain descriptions of the edges of the second graph. The $i$-th of them contains two integers $v_i$ and $u_i$ ($1 \\le v_i, u_i \\le n$) β€” an edge in the second graph leading from vertex $v_i$ to vertex $u_i$.\n\nIt is guaranteed that both graphs are strongly connected, and the lengths of all cycles are divisible by $k$.\n\nIt is guaranteed that the sum of $n$ over all test cases does not exceed $2 \\cdot 10^5$. It is guaranteed that the sum of $m_1$ and the sum of $m_2$ over all test cases does not exceed $5 \\cdot 10^5$.\n\nOutput: For each test case, output \"YES\" (without quotes) if it is possible to draw $n$ new edges such that all conditions are met, and \"NO\" (without quotes) otherwise.\n\nYou may output the answer in any case (for example, the strings \"yEs\", \"yes\", \"Yes\", and \"YES\" will be recognized as a positive answer).\n\nExamples:\ninput:\n3\n4 2\n1 0 0 1\n4\n1 2\n2 3\n3 4\n4 1\n1 0 0 1\n4\n1 3\n3 2\n2 4\n4 1\n3 3\n0 0 0\n3\n1 2\n2 3\n3 1\n1 1 0\n3\n1 2\n2 3\n3 1\n4 2\n1 1 1 1\n4\n1 2\n2 3\n3 4\n4 1\n0 0 0 0\n6\n1 2\n2 1\n1 3\n3 1\n1 4\n4 1\noutput:\nYES\nNO\nYES\n\nNote: In the first test case, it is possible to draw edges from the first graph to the second graph as $(1, 3)$ and $(4, 2)$ (the first number in the pair is the vertex number in the first graph, and the second number in the pair is the vertex number in the second graph), and from the second graph to the first graph as $(1, 2)$, $(4, 3)$ (the first number in the pair is the vertex number in the second graph, and the second number in the pair is the vertex number in the first graph).\n\nIn the second test case, there are a total of $4$ incoming vertices and $2$ outgoing vertices, so it is not possible to draw $3$ edges.\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "2023C", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Question Marks\ntime_limit_ms: 1000\nmemory_limit_mb: 256\nDescription: Tim is doing a test consisting of $4n$ questions; each question has $4$ options: 'A', 'B', 'C', and 'D'. For each option, there are exactly $n$ correct answers corresponding to that option β€” meaning there are $n$ questions with the answer 'A', $n$ questions with the answer 'B', $n$ questions with the answer 'C', and $n$ questions with the answer 'D'.\n\nFor each question, Tim wrote his answer on the answer sheet. If he could not figure out the answer, he would leave a question mark '?' for that question.\n\nYou are given his answer sheet of $4n$ characters. What is the maximum number of correct answers Tim can get?\n\nInput: The first line contains a single integer $t$ ($1 \\le t \\le 1000$) β€” the number of test cases.\n\nThe first line of each test case contains an integer $n$ ($1 \\le n \\le 100$).\n\nThe second line of each test case contains a string $s$ of $4n$ characters ($s_i \\in \\\\{\\texttt{A}, \\texttt{B}, \\texttt{C}, \\texttt{D}, \\texttt{?}\\\\}$) β€” Tim's answers for the questions.\n\nOutput: For each test case, print a single integer β€” the maximum score that Tim can achieve.\n\nExamples:\ninput:\n6\n1\nABCD\n2\nAAAAAAAA\n2\nAAAABBBB\n2\n????????\n3\nABCABCABCABC\n5\nACADC??ACAC?DCAABC?C\noutput:\n4\n2\n4\n0\n9\n13\n\nNote: In the first test case, there is exactly one question with each answer 'A', 'B', 'C', and 'D'; so it's possible that Tim gets all his answers correct.\n\nIn the second test case, there are only two correct answers 'A' which makes him get exactly $2$ points in any case.\n\nIn the third test case, Tim can get at most $2$ correct answers with option 'A' and $2$ correct answers with option 'B'. For example, he would get $4$ points if the answers were 'AACCBBDD'.\n\nIn the fourth test case, he refuses to answer any question at all, which makes him get $0$ points.\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "1993A", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Magnitude (Easy Version)\ntime_limit_ms: 2000\nmemory_limit_mb: 256\nDescription: The two versions of the problem are different. You may want to read both versions. You can make hacks only if both versions are solved.\n\nYou are given an array $a$ of length $n$. Start with $c = 0$. Then, for each $i$ from $1$ to $n$ (in increasing order) do exactly one of the following:\n\n * Option $1$: set $c$ to $c + a_i$. * Option $2$: set $c$ to $|c + a_i|$, where $|x|$ is the absolute value of $x$. \n\nLet the maximum final value of $c$ after the procedure described above be equal to $k$. Find $k$.\n\nInput: The first line contains a single integer $t$ ($1 \\leq t \\leq 10^4$) β€” the number of test cases.\n\nThe first line of each test case contains a single integer $n$ ($2 \\leq n \\leq 2 \\cdot 10^5$).\n\nThe second line of each case contains $n$ integers $a_1$, $a_2$, $a_3$, $\\ldots$, $a_n$ ($-10^9 \\leq a_i \\leq 10^9$).\n\nThe sum of $n$ over all test cases does not exceed $3 \\cdot 10^5$.\n\nOutput: For each test case, output a single integer β€” the value of $k$.\n\nExamples:\ninput:\n5\n4\n10 -9 -3 4\n8\n1 4 3 4 1 4 3 4\n3\n-1 -2 -3\n4\n-1000000000 1000000000 1000000000 1000000000\n4\n1 9 8 4\noutput:\n6\n24\n6\n4000000000\n22\n\nNote: In the first test case, if we set $c$ to its absolute value every time we add to it, we end up with $6$. It can be shown that this is the maximum result.\n\nIn the second test case, taking the absolute value will never change anything, so we can just sum the array without doing anything to get $24$.\n\nIn the third test case, it is optimal to wait until the end to set $c$ to its absolute value, resulting in an answer of $6$.\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "1984C1", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Cat, Fox and the Lonely Array\ntime_limit_ms: 2000\nmemory_limit_mb: 256\nDescription: Today, Cat and Fox found an array $a$ consisting of $n$ non-negative integers.\n\nDefine the loneliness of $a$ as the smallest positive integer $k$ ($1 \\le k \\le n$) such that for any two positive integers $i$ and $j$ ($1 \\leq i, j \\leq n - k +1$), the following holds: $$a_i | a_{i+1} | \\ldots | a_{i+k-1} = a_j | a_{j+1} | \\ldots | a_{j+k-1},$$ where $x | y$ denotes the [bitwise OR](https://en.wikipedia.org/wiki/Bitwise_operation#OR) of $x$ and $y$. In other words, for every $k$ consecutive elements, their bitwise OR should be the same. Note that the loneliness of $a$ is well-defined, because for $k = n$ the condition is satisfied.\n\nCat and Fox want to know how lonely the array $a$ is. Help them calculate the loneliness of the found array.\n\nInput: Each test consists of multiple test cases. The first line contains a single integer $t$ ($1 \\leq t \\leq 10^4 $) β€” the number of test cases. The description of the test cases follows.\n\nThe first line of each test case contains one integer $n$ ($1 \\leq n \\leq 10^5$) β€” the length of the array $a$.\n\nThe second line of each test case contains $n$ integers $a_1, a_2, \\ldots, a_n$ ($0 \\leq a_i < 2^{20}$) β€” the elements of the array.\n\nIt is guaranteed that the sum of $n$ over all test cases doesn't exceed $10^5$.\n\nOutput: For each test case, print one integer β€” the loneliness of the given array.\n\nExamples:\ninput:\n7\n1\n0\n3\n2 2 2\n3\n1 0 2\n5\n3 0 1 4 2\n5\n2 0 4 0 2\n7\n0 0 0 0 1 2 4\n8\n0 1 3 2 2 1 0 3\noutput:\n1\n1\n3\n4\n4\n7\n3\n\nNote: In the first example, the loneliness of an array with a single element is always $1$, so the answer is $1$.\n\nIn the second example, the OR of each subarray of length $k = 1$ is $2$, so the loneliness of the whole array is $1$.\n\nIn the seventh example, it's true that $(0 | 1 | 3) = (1 | 3 | 2) = (3 | 2 | 2) = (2 | 2 | 1) = (2 | 1 | 0) = (1 | 0 | 3) = 3$, so the condition is satisfied for $k = 3$. We can verify that the condition is not true for any smaller $k$, so the answer is indeed $3$.\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "1973B", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: The Endspeaker (Hard Version)\ntime_limit_ms: 2000\nmemory_limit_mb: 256\nDescription: This is the hard version of this problem. The only difference is that you need to also output the number of optimal sequences in this version. You must solve both versions to be able to hack.\n\nYou're given an array $a$ of length $n$, and an array $b$ of length $m$ ($b_i > b_{i+1}$ for all $1 \\le i < m$). Initially, the value of $k$ is $1$. Your aim is to make the array $a$ empty by performing one of these two operations repeatedly:\n\n * Type $1$ β€” If the value of $k$ is less than $m$ and the array $a$ is not empty, you can increase the value of $k$ by $1$. This does not incur any cost. * Type $2$ β€” You remove a non-empty prefix of array $a$, such that its sum does not exceed $b_k$. This incurs a cost of $m - k$. \n\nYou need to minimize the total cost of the operations to make array $a$ empty. If it's impossible to do this through any sequence of operations, output $-1$. Otherwise, output the minimum total cost of the operations, and the number of sequences of operations which yield this minimum cost modulo $10^9 + 7$.\n\nTwo sequences of operations are considered different if you choose a different type of operation at any step, or the size of the removed prefix is different at any step.\n\nInput: Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \\le t \\le 1000$). The description of the test cases follows.\n\nThe first line of each test case contains two integers $n$ and $m$ ($1 \\le n, m \\le 3 \\cdot 10^5$, $\\boldsymbol{1 \\le n \\cdot m \\le 3 \\cdot 10^5}$).\n\nThe second line of each test case contains $n$ integers $a_1, a_2, \\ldots, a_n$ ($1 \\le a_i \\le 10^9$).\n\nThe third line of each test case contains $m$ integers $b_1, b_2, \\ldots, b_m$ ($1 \\le b_i \\le 10^9$).\n\nIt is also guaranteed that $b_i > b_{i+1}$ for all $1 \\le i < m$.\n\nIt is guaranteed that the sum of $\\boldsymbol{n \\cdot m}$ over all test cases does not exceed $3 \\cdot 10^5$.\n\nOutput: For each test case, if it's possible to make $a$ empty, then output two integers. The first should be the minimum total cost of the operations, and the second should be the number of sequences of operations which achieve this minimum cost, modulo $10^9 + 7$.\n\nIf there is no possible sequence of operations which makes $a$ empty, then output a single integer $-1$.\n\nExamples:\ninput:\n5\n4 2\n9 3 4 3\n11 7\n1 2\n20\n19 18\n10 2\n2 5 2 1 10 3 2 9 9 6\n17 9\n10 11\n2 2 2 2 2 2 2 2 2 2\n20 18 16 14 12 10 8 6 4 2 1\n1 6\n10\n32 16 8 4 2 1\noutput:\n1 3\n-1\n2 11\n10 42\n4 1\n\nNote: In the first test case, there are $3$ optimal sequences of operations which yield a total cost of $1$:\n\n * All $3$ sequences begin with a type $2$ operation, removing the prefix $[9]$ to make $a = [3, 4, 3]$, incurring a cost of $1$. Then, we perform a type $1$ operation to increase the value of $k$ by $1$. All subsequent operations now incur a cost of $0$. * One sequence continues by removing the prefixes $[3, 4]$ then $[3]$. * Another sequence continues by removing the prefixes $[3]$ then $[4, 3]$. * Another sequence continues by removing the prefixes $[3]$ then $[4]$ then $[3]$. \n\nIn the second test case, it's impossible to remove any prefix of the array since $a_1 > b_1$, so array $a$ cannot be made empty by any sequence of operations.\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "2027D2", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Dyn-scripted Robot (Easy Version)\ntime_limit_ms: 3000\nmemory_limit_mb: 256\nDescription: This is the easy version of the problem. The only difference is that in this version $k \\le n$. You can make hacks only if both versions of the problem are solved. Given a $w \\times h$ rectangle on the $Oxy$ plane, with points $(0, 0)$ at the bottom-left and $(w, h)$ at the top-right of the rectangle.\n\nYou also have a robot initially at point $(0, 0)$ and a script $s$ of $n$ characters. Each character is either L, R, U, or D, which tells the robot to move left, right, up, or down respectively.\n\nThe robot can only move inside the rectangle; otherwise, it will change the script $s$ as follows:\n\n * If it tries to move outside a vertical border, it changes all L characters to R's (and vice versa, all R's to L's). * If it tries to move outside a horizontal border, it changes all U characters to D's (and vice versa, all D's to U's). \n\nThen, it will execute the changed script starting from the character which it couldn't execute.\n\n![](CDN_BASE_URL/ff5ae9758c965c2d8398c936e9581dab) An example of the robot's movement process, $s = \\texttt{\"ULULURD\"}$\n\nThe script $s$ will be executed for $k$ times continuously. All changes to the string $s$ will be retained even when it is repeated. During this process, how many times will the robot move to the point $(0, 0)$ in total? Note that the initial position does NOT count.\n\nInput: The first line contains a single integer $t$ ($1 \\le t \\le 10^4$) β€” the number of test cases.\n\nThe first line of each test case contains four integers $n$, $k$, $w$, and $h$ ($1 \\le n, w, h \\le 10^6$; $1 \\le k \\le n$).\n\nThe second line contains a single string $s$ of size $n$ ($s_i \\in \\\\{\\texttt{L}, \\texttt{R}, \\texttt{U}, \\texttt{D}\\\\}$) β€” the script to be executed.\n\nIt is guaranteed that the sum of $n$ over all test cases does not exceed $10^6$.\n\nOutput: For each test case, print a single integer β€” the number of times the robot reaches $(0, 0)$ when executing script $s$ for $k$ times continuously.\n\nExamples:\ninput:\n5\n2 2 2 2\nUR\n4 2 1 1\nLLDD\n6 3 3 1\nRLRRRL\n5 5 3 3\nRUURD\n7 5 3 4\nRRDLUUU\noutput:\n0\n4\n3\n0\n1\n\nNote: In the first test case, the robot only moves up and right. In the end, it occupies the position $(2, 2)$ but never visits $(0, 0)$. So the answer is $0$.\n\nIn the second test case, each time executing the script the robot visits the origin twice. And since $k=2$, it visits the origin $2 \\cdot 2 = 4$ times overall.\n\n![](CDN_BASE_URL/ea799abf84f8a212d5a0d782be4d5e9c)\n\nIn the third test case, the visualization is shown as below:\n\n![](CDN_BASE_URL/c6a5be14982b3d57a5103783598d4683)\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "1993F1", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Mad MAD Sum\ntime_limit_ms: 2000\nmemory_limit_mb: 256\nDescription: We define the $\\operatorname{MAD}$ (Maximum Appearing Duplicate) in an array as the largest number that appears at least twice in the array. Specifically, if there is no number that appears at least twice, the $\\operatorname{MAD}$ value is $0$.\n\nFor example, $\\operatorname{MAD}([1, 2, 1]) = 1$, $\\operatorname{MAD}([2, 2, 3, 3]) = 3$, $\\operatorname{MAD}([1, 2, 3, 4]) = 0$.\n\nYou are given an array $a$ of size $n$. Initially, a variable $sum$ is set to $0$.\n\nThe following process will be executed in a sequential loop until all numbers in $a$ become $0$:\n\n 1. Set $sum := sum + \\sum_{i=1}^{n} a_i$; 2. Let $b$ be an array of size $n$. Set $b_i :=\\ \\operatorname{MAD}([a_1, a_2, \\ldots, a_i])$ for all $1 \\le i \\le n$, and then set $a_i := b_i$ for all $1 \\le i \\le n$. \n\nFind the value of $sum$ after the process.\n\nInput: The first line contains an integer $t$ ($1 \\leq t \\leq 2 \\cdot 10^4$) β€” the number of test cases.\n\nFor each test case:\n\n * The first line contains an integer $n$ ($1 \\leq n \\leq 2 \\cdot 10^5$) β€” the size of the array $a$; * The second line contains $n$ integers $a_1, a_2, \\ldots, a_n$ ($1 \\leq a_i \\leq n$) β€” the elements of the array. \n\nIt is guaranteed that the sum of $n$ over all test cases will not exceed $2 \\cdot 10^5$.\n\nOutput: For each test case, output the value of $sum$ in a new line.\n\nExamples:\ninput:\n4\n1\n1\n3\n2 2 3\n4\n2 1 1 2\n4\n4 4 4 4\noutput:\n1\n13\n9\n40\n\nNote: In the first test case, $a=[1]$ initially.\n\nIn the first loop:\n\n 1. Set $sum := sum + a_1 = 0+1=1$; 2. Set $b_1 :=\\ \\operatorname{MAD}([a_1])=\\ \\operatorname{MAD}([1])=0$, and then set $a_1 := b_1$. \n\nAfter the first loop, $a=[0]$ and the process ends. The value of $sum$ after the process is $1$.\n\nIn the second test case, $a=[2,2,3]$ initially.\n\nAfter the first loop, $a=[0,2,2]$ and $sum=7$.\n\nAfter the second loop, $a=[0,0,2]$ and $sum=11$.\n\nAfter the third loop, $a=[0,0,0]$ and $sum=13$. Then the process ends.\n\nThe value of $sum$ after the process is $13$.\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "1990C", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: My First Sorting Problem\ntime_limit_ms: 1000\nmemory_limit_mb: 256\nDescription: You are given two integers $x$ and $y$.\n\nOutput two integers: the minimum of $x$ and $y$, followed by the maximum of $x$ and $y$.\n\nInput: The first line contains a single integer $t$ ($1 \\leq t \\leq 100$) β€” the number of test cases.\n\nThe only line of each test case contains two space-separated integers $x$ and $y$ ($0 \\leq x, y \\leq 9$).\n\nOutput: For each test case, output two integers: the minimum of $x$ and $y$, followed by the maximum of $x$ and $y$.\n\nExamples:\ninput:\n10\n1 9\n8 4\n1 4\n3 4\n2 0\n2 4\n6 9\n3 3\n0 0\n9 9\noutput:\n1 9\n4 8\n1 4\n3 4\n0 2\n2 4\n6 9\n3 3\n0 0\n9 9\n\nNote: \n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "1971A", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Hungry Games\ntime_limit_ms: 2000\nmemory_limit_mb: 256\nDescription: Yaroslav is playing a computer game, and at one of the levels, he encountered $n$ mushrooms arranged in a row. Each mushroom has its own level of toxicity; the $i$-th mushroom from the beginning has a toxicity level of $a_i$. Yaroslav can choose two integers $1 \\le l \\le r \\le n$, and then his character will take turns from left to right to eat mushrooms from this subsegment one by one, i.e., the mushrooms with numbers $l, l+1, l+2, \\ldots, r$.\n\nThe character has a toxicity level $g$, initially equal to $0$. The computer game is defined by the number $x$ β€” the maximum toxicity level at any given time. When eating a mushroom with toxicity level $k$, the following happens:\n\n 1. The toxicity level of the character is increased by $k$. 2. If $g \\leq x$, the process continues; otherwise, $g$ becomes zero and the process continues. \n\nYaroslav became interested in how many ways there are to choose the values of $l$ and $r$ such that the final value of $g$ is not zero. Help Yaroslav find this number!\n\nInput: Each test consists of multiple test cases. The first line contains an integer $t$ ($1 \\le t \\le 10^{4}$) β€” the number of test cases. Then follows the description of the test cases.\n\nThe first line of each test case contains two integers $n$, $x$ ($1 \\leq n \\leq 2 \\cdot 10^5, 1 \\le x \\le 10^9$) β€” the number of mushrooms and the maximum toxicity level.\n\nThe second line of each test case contains $n$ numbers $a_1, a_2, \\ldots, a_n$ ($1 \\leq a_i \\leq 10^9$).\n\nIt is guaranteed that the sum of $n$ over all test cases does not exceed $2 \\cdot 10^5$.\n\nOutput: For each test case, output a single number β€” the number of subsegments such that the final value of $g$ will not be zero.\n\nExamples:\ninput:\n5\n4 2\n1 1 1 1\n3 2\n1 2 3\n1 6\n10\n6 3\n1 2 1 4 3 8\n5 999999999\n999999999 999999998 1000000000 1000000000 500000000\noutput:\n8\n2\n0\n10\n7\n\nNote: In the first test case, the subsegments $(1, 1)$, $(1, 2)$, $(1, 4)$, $(2, 2)$, $(2, 3)$, $(3, 3)$, $(3, 4)$ and $(4, 4)$ are suitable.\n\nIn the second test case, non-zero $g$ will remain only on the subsegments $(1, 1)$ and $(2, 2)$.\n\nIn the third test case, on the only possible subsegment, $g$ will be zero.\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "1994C", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Tree of Life\ntime_limit_ms: 2000\nmemory_limit_mb: 512\nDescription: In the heart of an ancient kingdom grows the legendary Tree of Life β€” the only one of its kind and the source of magical power for the entire world. The tree consists of $n$ nodes. Each node of this tree is a magical source, connected to other such sources through magical channels (edges). In total, there are $n-1$ channels in the tree, with the $i$-th channel connecting nodes $v_i$ and $u_i$. Moreover, there exists a unique simple path through the channels between any two nodes in the tree.\n\nHowever, the magical energy flowing through these channels must be balanced; otherwise, the power of the Tree of Life may disrupt the natural order and cause catastrophic consequences. The sages of the kingdom discovered that when two magical channels converge at a single node, a dangerous \"magical resonance vibration\" occurs between them. To protect the Tree of Life and maintain its balance, it is necessary to select several paths and perform special rituals along them. A path is a sequence of distinct nodes $v_1, v_2, \\ldots, v_k$, where each pair of adjacent nodes $v_i$ and $v_{i+1}$ is connected by a channel. When the sages perform a ritual along such a path, the resonance vibration between the channels $(v_i, v_{i+1})$ and $(v_{i+1}, v_{i+2})$ is blocked for each $1 \\leq i \\leq k - 2$.\n\nThe sages' task is to select the minimum number of paths and perform rituals along them to block all resonance vibrations. This means that for every pair of channels emanating from a single node, there must exist at least one selected path that contains both of these channels.\n\nHelp the sages find the minimum number of such paths so that the magical balance of the Tree of Life is preserved, and its power continues to nourish the entire world!\n\nInput: Each test consists of multiple test cases. The first line contains a single integer $t$ ($1 \\leq t \\leq 4 \\cdot 10^4$) β€” the number of test cases. The description of the test cases follows.\n\nThe first line of each test case contains a single integer $n$ ($2 \\leq n \\leq 5 \\cdot 10^5$) β€” the number of nodes in the Tree of Life.\n\nThe $i$-th of the following $n - 1$ lines of each test case contains two integers $v_i$ and $u_i$ ($1 \\leq v_i < u_i \\leq n$) β€” the channel connecting nodes $v_i$ and $u_i$.\n\nIt is guaranteed that there exists a unique simple path through the channels between any two nodes.\n\nIt is guaranteed that the sum of $n$ over all test cases does not exceed $5 \\cdot 10^5$.\n\nOutput: For each test case, output a single integer β€” the minimum number of paths that the sages need to select to prevent a catastrophe.\n\nExamples:\ninput:\n5\n4\n1 2\n2 3\n3 4\n2\n1 2\n4\n1 2\n1 3\n1 4\n8\n3 7\n2 4\n1 2\n2 5\n3 6\n1 3\n3 8\n6\n2 3\n1 2\n3 6\n1 5\n1 4\noutput:\n1\n0\n3\n7\n3\n\nNote: In the first test case, there are two pairs of channels emanating from a single node: $(1, 2)$ and $(2, 3)$, $(2, 3)$ and $(3, 4)$. It is sufficient to perform the ritual along the path $1-2-3-4$. Thus, the answer is $1$.\n\nIn the second test case, there are no pairs of channels emanating from a single node, so the answer is $0$.\n\nIn the third test case, rituals can be performed along the paths $2-1-3$, $2-1-4$, and $3-1-4$.\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "2023E", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Binary Cut\ntime_limit_ms: 2000\nmemory_limit_mb: 256\nDescription: You are given a binary string$^{\\dagger}$. Please find the minimum number of pieces you need to cut it into, so that the resulting pieces can be rearranged into a sorted binary string.\n\n![](CDN_BASE_URL/f49d41e3510eec9591123a65ee9389ab)\n\nNote that:\n\n * each character must lie in exactly one of the pieces; * the pieces must be contiguous substrings of the original string; * you must use all the pieces in the rearrangement. \n\n$^{\\dagger}$ A binary string is a string consisting of characters $\\texttt{0}$ and $\\texttt{1}$. A sorted binary string is a binary string such that all characters $\\texttt{0}$ come before all characters $\\texttt{1}$.\n\nInput: The first line contains a single integer $t$ ($1 \\leq t \\leq 500$) β€” the number of test cases.\n\nThe only line of each test case contains a single string $s$ ($1 \\leq |s| \\leq 500$) consisting of characters $\\texttt{0}$ and $\\texttt{1}$, where $|s|$ denotes the length of the string $s$.\n\nOutput: For each test case, output a single integer β€” the minimum number of pieces needed to be able to rearrange the string into a sorted binary string.\n\nExamples:\ninput:\n6\n11010\n00000000\n1\n10\n0001111\n0110\noutput:\n3\n1\n1\n2\n1\n2\n\nNote: The first test case is pictured in the statement. It can be proven that you can't use fewer than $3$ pieces.\n\nIn the second and third test cases, the binary string is already sorted, so only $1$ piece is needed.\n\nIn the fourth test case, you need to make a single cut between the two characters and rearrange them to make the string $\\texttt{01}$.\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "1971D", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Permutation Counting\ntime_limit_ms: 2000\nmemory_limit_mb: 256\nDescription: You have some cards. An integer between $1$ and $n$ is written on each card: specifically, for each $i$ from $1$ to $n$, you have $a_i$ cards which have the number $i$ written on them.\n\nThere is also a shop which contains unlimited cards of each type. You have $k$ coins, so you can buy $k$ new cards in total, and the cards you buy can contain any integer between $1$ and $n$.\n\nAfter buying the new cards, you rearrange all your cards in a line. The score of a rearrangement is the number of (contiguous) subarrays of length $n$ which are a permutation of $[1, 2, \\ldots, n]$. What's the maximum score you can get?\n\nInput: Each test contains multiple test cases. The first line contains the number of test cases $t\\ (1\\le t\\le 100)$. The description of the test cases follows.\n\nThe first line of each test case contains two integers $n$, $k$ ($1\\le n \\le 2 \\cdot 10^5$, $0\\le k \\le 10^{12}$) β€” the number of distinct types of cards and the number of coins.\n\nThe second line of each test case contains $n$ integers $a_1, a_2, \\ldots, a_n$ ($1 \\le a_i \\le 10^{12}$) β€” the number of cards of type $i$ you have at the beginning.\n\nIt is guaranteed that the sum of $n$ over all test cases does not exceed $5 \\cdot 10^5$.\n\nOutput: For each test case, output a single line containing an integer: the maximum score you can get.\n\nExamples:\ninput:\n8\n1 10\n1\n2 4\n8 4\n3 4\n6 1 8\n3 9\n7 6 2\n5 3\n6 6 7 4 6\n9 7\n7 6 1 7 6 2 4 3 3\n10 10\n1 3 1 2 1 9 3 5 7 5\n9 8\n5 8 7 5 1 3 2 9 8\noutput:\n11\n15\n15\n22\n28\n32\n28\n36\n\nNote: In the first test case, the final (and only) array we can get is $[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]$ (including $11$ single $1$s), which contains $11$ subarrays consisting of a permutation of $[1]$.\n\nIn the second test case, we can buy $0$ cards of type $1$ and $4$ cards of type $2$, and then we rearrange the cards as following: $[1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]$. There are $8$ subarrays equal to $[1, 2]$ and $7$ subarrays equal to $[2, 1]$, which make a total of $15$ subarrays which are a permutation of $[1, 2]$. It can also be proved that this is the maximum score we can get.\n\nIn the third test case, one of the possible optimal rearrangements is $[3, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 3]$.\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "1972C", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: New Bakery\ntime_limit_ms: 1000\nmemory_limit_mb: 256\nDescription: Bob decided to open a bakery. On the opening day, he baked $n$ buns that he can sell. The usual price of a bun is $a$ coins, but to attract customers, Bob organized the following promotion:\n\n * Bob chooses some integer $k$ ($0 \\le k \\le \\min(n, b)$). * Bob sells the first $k$ buns at a modified price. In this case, the price of the $i$-th ($1 \\le i \\le k$) sold bun is $(b - i + 1)$ coins. * The remaining $(n - k)$ buns are sold at $a$ coins each.\n\nNote that $k$ can be equal to $0$. In this case, Bob will sell all the buns at $a$ coins each.\n\nHelp Bob determine the maximum profit he can obtain by selling all $n$ buns.\n\nInput: Each test consists of multiple test cases. The first line contains a single integer $t$ ($1 \\le t \\le 10^4$) β€” the number of test cases. The description of the test cases follows.\n\nThe only line of each test case contains three integers $n$, $a$, and $b$ ($1 \\le n, a, b \\le 10^9$) β€” the number of buns, the usual price of a bun, and the price of the first bun to be sold at a modified price.\n\nOutput: For each test case, output a single integer β€” the maximum profit that Bob can obtain.\n\nExamples:\ninput:\n7\n4 4 5\n5 5 9\n10 10 5\n5 5 11\n1000000000 1000000000 1000000000\n1000000000 1000000000 1\n1000 1 1000\noutput:\n17\n35\n100\n45\n1000000000000000000\n1000000000000000000\n500500\n\nNote: In the first test case, it is optimal for Bob to choose $k = 1$. Then he will sell one bun for $5$ coins, and three buns at the usual price for $4$ coins each. Then the profit will be $5 + 4 + 4 + 4 = 17$ coins.\n\nIn the second test case, it is optimal for Bob to choose $k = 5$. Then he will sell all the buns at the modified price and obtain a profit of $9 + 8 + 7 + 6 + 5 = 35$ coins.\n\nIn the third test case, it is optimal for Bob to choose $k = 0$. Then he will sell all the buns at the usual price and obtain a profit of $10 \\cdot 10 = 100$ coins.\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "1978B", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Manhattan Circle\ntime_limit_ms: 2000\nmemory_limit_mb: 256\nDescription: Given a $n$ by $m$ grid consisting of '.' and '#' characters, there exists a whole manhattan circle on the grid. The top left corner of the grid has coordinates $(1,1)$, and the bottom right corner has coordinates $(n, m)$.\n\nPoint ($a, b$) belongs to the manhattan circle centered at ($h, k$) if $|h - a| + |k - b| < r$, where $r$ is a positive constant.\n\nOn the grid, the set of points that are part of the manhattan circle is marked as '#'. Find the coordinates of the center of the circle.\n\nInput: The first line contains $t$ ($1 \\leq t \\leq 1000$) β€” the number of test cases.\n\nThe first line of each test case contains $n$ and $m$ ($1 \\leq n \\cdot m \\leq 2 \\cdot 10^5$) β€” the height and width of the grid, respectively.\n\nThe next $n$ lines contains $m$ characters '.' or '#'. If the character is '#', then the point is part of the manhattan circle.\n\nIt is guaranteed the sum of $n \\cdot m$ over all test cases does not exceed $2 \\cdot 10^5$, and there is a whole manhattan circle on the grid.\n\nOutput: For each test case, output the two integers, the coordinates of the center of the circle.\n\nExamples:\ninput:\n6\n5 5\n.....\n.....\n..#..\n.....\n.....\n5 5\n..#..\n.###.\n#####\n.###.\n..#..\n5 6\n......\n......\n.#....\n###...\n.#....\n1 1\n#\n5 6\n...#..\n..###.\n.#####\n..###.\n...#..\n2 10\n..........\n...#......\noutput:\n3 3\n3 3\n4 2\n1 1\n3 4\n2 4\n\nNote: \n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "1985D", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: World is Mine\ntime_limit_ms: 2000\nmemory_limit_mb: 256\nDescription: Alice and Bob are playing a game. Initially, there are $n$ cakes, with the $i$-th cake having a tastiness value of $a_i$.\n\nAlice and Bob take turns eating them, with Alice starting first:\n\n * In her turn, Alice chooses and eats any remaining cake whose tastiness is strictly greater than the maximum tastiness of any of the cakes she's eaten before that. Note that on the first turn, she can choose any cake. * In his turn, Bob chooses any remaining cake and eats it. \n\nThe game ends when the current player can't eat a suitable cake. Let $x$ be the number of cakes that Alice ate. Then, Alice wants to maximize $x$, while Bob wants to minimize $x$.\n\nFind out how many cakes Alice will eat if both players play optimally.\n\nInput: Each test contains multiple test cases. The first line of input contains a single integer $t$ ($1 \\le t \\le 500$) β€” the number of test cases. The description of the test cases follows.\n\nThe first line of each test case contains a single integer $n$ ($1 \\le n \\le 5000$) β€” the number of cakes.\n\nThe second line of each test case contains $n$ integers $a_1, a_2, \\ldots, a_n$ ($1 \\le a_i \\le n$) β€” the tastiness values of the cakes.\n\nIt is guaranteed that the sum of $n$ over all test cases does not exceed $5000$.\n\nOutput: For each test case, output a single integer β€” the number of cakes Alice will eat if both players play optimally.\n\nExamples:\ninput:\n9\n4\n1 4 2 3\n3\n1 1 1\n5\n1 4 2 3 4\n4\n3 4 1 4\n1\n1\n8\n4 3 2 5 6 8 3 4\n7\n6 1 1 3 5 3 1\n11\n6 11 6 8 7 5 3 11 2 3 5\n17\n2 6 5 3 9 1 6 2 5 6 3 2 3 9 6 1 6\noutput:\n2\n1\n3\n2\n1\n3\n2\n4\n4\n\nNote: In the first test case, one possible sequence of turns is:\n\n 1. Alice eats a cake with a tastiness value of $1$. The remaining cakes are $[4, 2, 3]$. 2. Bob eats a cake with a tastiness value of $2$. The remaining cakes are $[4, 3]$. 3. Alice eats a cake with a tastiness of $3$. The remaining cakes are $[4]$. 4. Bob eats a cake with a tastiness value of $4$. The remaining cakes are $[]$. 5. Since there are no more cakes left, the game ends. \n\nIn the second test case, one possible sequence of turns is:\n\n 1. Alice eats a cake with a tastiness value of $1$. The remaining cakes are $[1, 1]$. 2. Bob eats a cake with a tastiness value of $1$. The remaining cakes are $[1]$. 3. Since Alice has already eaten a cake with a tastiness value of $1$, she cannot make a turn, so the game ends.\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "1987D", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Problem Generator\ntime_limit_ms: 1000\nmemory_limit_mb: 256\nDescription: Vlad is planning to hold $m$ rounds next month. Each round should contain one problem of difficulty levels 'A', 'B', 'C', 'D', 'E', 'F', and 'G'.\n\nVlad already has a bank of $n$ problems, where the $i$-th problem has a difficulty level of $a_i$. There may not be enough of these problems, so he may have to come up with a few more problems.\n\nVlad wants to come up with as few problems as possible, so he asks you to find the minimum number of problems he needs to come up with in order to hold $m$ rounds.\n\nFor example, if $m=1$, $n = 10$, $a=$ 'BGECDCBDED', then he needs to come up with two problems: one of difficulty level 'A' and one of difficulty level 'F'.\n\nInput: The first line contains a single integer $t$ ($1 \\le t \\le 1000$) β€” the number of test cases.\n\nThe first line of each test case contains two integers $n$ and $m$ ($1 \\le n \\le 50$, $1 \\le m \\le 5$) β€” the number of problems in the bank and the number of upcoming rounds, respectively.\n\nThe second line of each test case contains a string $a$ of $n$ characters from 'A' to 'G' β€” the difficulties of the problems in the bank.\n\nOutput: For each test case, output a single integer β€” the minimum number of problems that need to come up with to hold $m$ rounds.\n\nExamples:\ninput:\n3\n10 1\nBGECDCBDED\n10 2\nBGECDCBDED\n9 1\nBBCDEFFGG\noutput:\n2\n5\n1\n\nNote: \n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "1980A", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Magnitude (Hard Version)\ntime_limit_ms: 2000\nmemory_limit_mb: 256\nDescription: The two versions of the problem are different. You may want to read both versions. You can make hacks only if both versions are solved.\n\nYou are given an array $a$ of length $n$. Start with $c = 0$. Then, for each $i$ from $1$ to $n$ (in increasing order) do exactly one of the following:\n\n * Option $1$: set $c$ to $c + a_i$. * Option $2$: set $c$ to $|c + a_i|$, where $|x|$ is the absolute value of $x$. \n\nLet the maximum final value of $c$ after the procedure described above be equal to $k$. Find the number of unique procedures that result in $c = k$. Two procedures are different if at any index $i$, one procedure chose option $1$ and another chose option $2$, even if the value of $c$ is equal for both procedures after that turn.\n\nSince the answer may be large, output it modulo $998\\,244\\,353$.\n\nInput: The first line contains a single integer $t$ ($1 \\leq t \\leq 10^4$) β€” the number of test cases.\n\nThe first line of each test case contains a single integer $n$ ($2 \\leq n \\leq 2 \\cdot 10^5$).\n\nThe second line of each test case contains $n$ integers $a_1, a_2, \\ldots, a_n$ ($-10^9 \\leq a_i \\leq 10^9$).\n\nThe sum of $n$ over all test cases does not exceed $3 \\cdot 10^5$.\n\nOutput: For each test case, output a single integer β€” the number of unique procedures that result in $c = k$, modulo $998\\,244\\,353$.\n\nExamples:\ninput:\n5\n4\n2 -5 3 -3\n8\n1 4 3 4 1 4 3 4\n3\n-1 -2 -3\n4\n-1000000000 1000000000 1000000000 1000000000\n4\n1 9 8 4\noutput:\n12\n256\n1\n8\n16\n\nNote: In the first test case, it can be shown that our maximal final value of $c$ is $3$. There are $12$ ways to achieve this because in order to get $3$, we have to take absolute value at indices $2$ or $4$, or both, resulting in $3$ ways. For the other two indices, it doesn't change the value whether we take absolute value or not, so we have $2 \\cdot 2 = 4$ ways for them. In total, we have $3 \\cdot 4 = 12$ ways.\n\nIn the second test case, taking the absolute value will never change anything, so we can either take absolute value or not, for every index. This gives us $2^8 = 256$ possible ways.\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "1984C2", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Invertible Bracket Sequences\ntime_limit_ms: 2000\nmemory_limit_mb: 256\nDescription: 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 the sequence. For example:\n\n * bracket sequences \"()()\" and \"(())\" are regular (the resulting expressions are: \"(1)+(1)\" and \"((1+1)+1)\"); * bracket sequences \")(\", \"(\" and \")\" are not. \n\nLet's define the inverse of the bracket sequence as follows: replace all brackets '(' with ')', and vice versa (all brackets ')' with '('). For example, strings \"()((\" and \")())\" are inverses of each other.\n\nYou are given a regular bracket sequence $s$. Calculate the number of pairs of integers $(l,r)$ ($1 \\le l \\le r \\le |s|$) such that if you replace the substring of $s$ from the $l$-th character to the $r$-th character (inclusive) with its inverse, $s$ will still be a regular bracket sequence.\n\nInput: The first line contains a single integer $t$ ($1 \\le t \\le 10^4$) β€” the number of test cases.\n\nThe only line of each test case contains a non-empty regular bracket sequence; it consists only of characters '(' and/or ')'.\n\nAdditional constraint on the input: the total length of the regular bracket sequences over all test cases doesn't exceed $2 \\cdot 10^5$.\n\nOutput: For each test case, print a single integer β€” the number of pairs $(l,r)$ meeting the conditions from the statement.\n\nExamples:\ninput:\n4\n(())\n()\n()()()\n(()())(())\noutput:\n1\n0\n3\n13\n\nNote: In the first example, there is only one pair:\n\n * $(2, 3)$: (()) $\\rightarrow$ ()(). \n\nIn the second example, there are no pairs.\n\nIn the third example, there are three pairs:\n\n * $(2, 3)$: ()()() $\\rightarrow$ (())(); * $(4, 5)$: ()()() $\\rightarrow$ ()(()); * $(2, 5)$: ()()() $\\rightarrow$ (()());\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "1976D", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Court Blue (Easy Version)\ntime_limit_ms: 3000\nmemory_limit_mb: 512\nDescription: This is the easy version of the problem. In this version, $n=m$ and the time limit is lower. You can make hacks only if both versions of the problem are solved.\n\nIn the court of the Blue King, Lelle and Flamm are having a performance match. The match consists of several rounds. In each round, either Lelle or Flamm wins.\n\nLet $W_L$ and $W_F$ denote the number of wins of Lelle and Flamm, respectively. The Blue King considers a match to be successful if and only if:\n\n * after every round, $\\gcd(W_L,W_F)\\le 1$; * at the end of the match, $W_L\\le n, W_F\\le m$. \n\nNote that $\\gcd(0,x)=\\gcd(x,0)=x$ for every non-negative integer $x$.\n\nLelle and Flamm can decide to stop the match whenever they want, and the final score of the performance is $l \\cdot W_L + f \\cdot W_F$.\n\nPlease help Lelle and Flamm coordinate their wins and losses such that the performance is successful, and the total score of the performance is maximized.\n\nInput: The first line contains an integer $t$ ($1\\leq t \\leq 10^3$) β€” the number of test cases.\n\nThe only line of each test case contains four integers $n$, $m$, $l$, $f$ ($2\\leq n\\leq m \\leq 2\\cdot 10^7$, $1\\leq l,f \\leq 10^9$, $\\bf{n=m}$): $n$, $m$ gives the upper bound on the number of Lelle and Flamm's wins, $l$ and $f$ determine the final score of the performance.\n\nUnusual additional constraint: it is guaranteed that, for each test, there are no pairs of test cases with the same pair of $n$, $m$.\n\nOutput: For each test case, output a single integer β€” the maximum total score of a successful performance.\n\nExamples:\ninput:\n8\n3 3 2 5\n4 4 1 4\n6 6 2 2\n7 7 2 3\n9 9 9 1\n2 2 1 4\n5 5 1 4\n8 8 6 7\noutput:\n19\n17\n18\n33\n86\n9\n24\n86\n\ninput:\n1\n20000000 20000000 1341 331\noutput:\n33439999007\n\ninput:\n2\n1984 1984 19 84\n9982 9982 44 35\noutput:\n204143\n788403\n\nNote: In the first test case, a possible performance is as follows:\n\n * Flamm wins, $\\gcd(0,1)=1$. * Lelle wins, $\\gcd(1,1)=1$. * Flamm wins, $\\gcd(1,2)=1$. * Flamm wins, $\\gcd(1,3)=1$. * Lelle wins, $\\gcd(2,3)=1$. * Lelle and Flamm agree to stop the match. \n\nThe final score is $2\\cdot2+3\\cdot5=19$.\n\nIn the third test case, a possible performance is as follows:\n\n * Flamm wins, $\\gcd(0,1)=1$. * Lelle wins, $\\gcd(1,1)=1$. * Lelle wins, $\\gcd(2,1)=1$. * Lelle wins, $\\gcd(3,1)=1$. * Lelle wins, $\\gcd(4,1)=1$. * Lelle wins, $\\gcd(5,1)=1$. * Flamm wins, $\\gcd(5,2)=1$. * Flamm wins, $\\gcd(5,3)=1$. * Flamm wins, $\\gcd(5,4)=1$. * Lelle and Flamm agree to stop the match. \n\nThe final score is $5\\cdot2+4\\cdot2=18$. Note that Lelle and Flamm can stop the match even if neither of them has $n$ wins.\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "2002F1", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Stalin Sort\ntime_limit_ms: 1000\nmemory_limit_mb: 256\nDescription: Stalin Sort is a humorous sorting algorithm designed to eliminate elements which are out of place instead of bothering to sort them properly, lending itself to an $\\mathcal{O}(n)$ time complexity.\n\nIt goes as follows: starting from the second element in the array, if it is strictly smaller than the previous element (ignoring those which have already been deleted), then delete it. Continue iterating through the array until it is sorted in non-decreasing order. For example, the array $[1, 4, 2, 3, 6, 5, 5, 7, 7]$ becomes $[1, 4, 6, 7, 7]$ after a Stalin Sort.\n\nWe define an array as vulnerable if you can sort it in non-increasing order by repeatedly applying a Stalin Sort to any of its subarrays$^{\\text{βˆ—}}$, as many times as is needed.\n\nGiven an array $a$ of $n$ integers, determine the minimum number of integers which must be removed from the array to make it vulnerable.\n\n$^{\\text{βˆ—}}$An array $a$ is a subarray of an array $b$ if $a$ can be obtained from $b$ by the deletion of several (possibly, zero or all) elements from the beginning and several (possibly, zero or all) elements from the end.\n\nInput: Each test consists of several test cases. The first line contains a single integer $t$ ($1 \\le t \\le 500$) β€” the number of test cases. This is followed by descriptions of the test cases.\n\nThe first line of each test case contains a single integer $n$ ($1 \\le n \\le 2000$) β€” the size of the array.\n\nThe second line of each test case contains $n$ integers $a_1, a_2, \\ldots, a_n$ ($1 \\le a_i \\le 10^9$).\n\nIt is guaranteed that the sum of $n$ over all test cases does not exceed $2000$.\n\nOutput: For each test case, output a single integer β€” the minimum number of integers which must be removed from the array to make it vulnerable.\n\nExamples:\ninput:\n6\n7\n3 6 4 9 2 5 2\n5\n5 4 4 2 2\n8\n2 2 4 4 6 6 10 10\n1\n1000\n9\n6 8 9 10 12 9 7 5 4\n7\n300000000 600000000 400000000 900000000 200000000 400000000 200000000\noutput:\n2\n0\n6\n0\n4\n2\n\nNote: In the first test case, the optimal answer is to remove the numbers $3$ and $9$. Then we are left with $a = [6, 4, 2, 5, 2]$. To show this array is vulnerable, we can first apply a Stalin Sort on the subarray $[4, 2, 5]$ to get $a = [6, 4, 5, 2]$ and then apply a Stalin Sort on the subarray $[6, 4, 5]$ to get $a = [6, 2]$, which is non-increasing.\n\nIn the second test case, the array is already non-increasing, so we don't have to remove any integers.\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "2027B", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Sorting Problem Again\ntime_limit_ms: 2500\nmemory_limit_mb: 256\nDescription: You have an array $a$ of $n$ elements. There are also $q$ modifications of the array. Before the first modification and after each modification, you would like to know the following:\n\nWhat is the minimum length subarray that needs to be sorted in non-decreasing order in order for the array $a$ to be completely sorted in non-decreasing order?\n\nMore formally, you want to select a subarray of the array $(l, r)$ with the minimum value of $r - l + 1$. After that, you will sort the elements $a_{l}, a_{l + 1}, \\ldots, a_{r}$ and want the condition $a_{i} \\le a_{i + 1}$ to hold for all $1 \\le i < n$. If the array is already sorted in non-decreasing order, then $l$ and $r$ should be considered as equal to $-1$.\n\nNote that finding such $(l, r)$ does not change the array in any way. The modifications themselves take the form: assign $a_{pos} = x$ for given $pos$ and $x$.\n\nInput: Each test consists of several test cases. The first line contains an integer $t$ ($1 \\le t \\le 10$) β€” the number of test cases. Then follows the description of test cases.\n\nThe first line of each test case contains a single integer $n$ ($1 \\le n \\le 5 \\cdot 10^{5}$).\n\nThe second line of each test case contains $n$ integers $a_{i}$ ($0 \\le |a_{i}| \\le 10^{9}$) β€” the initial elements of the array $a$.\n\nThe third line of each test case contains a number $q$ ($0 \\le q \\le 5 \\cdot 10^{5}$) β€” the number of modifications to the array.\n\nThe following $q$ lines of each test case contain two integers $pos_{i}$ ($1 \\le pos_{i} \\le n$) and $val_{i}$ ($0 \\le |val_{i}| \\le 10^{9}$) β€” this means that for the $i$-th modification, $a_{pos_{i}}$ is assigned the value $val_{i}$.\n\nIt is guaranteed that the sum of $n$ and the sum of $q$ for all test cases does not exceed $5 \\cdot 10^{5}$.\n\nOutput: For each test case, output $q + 1$ lines. Each line should contain $2$ integers $l, r$ β€” the boundaries of the minimum subarray, such that sorting it will make the array $a$ completely sorted. If $a$ is already sorted, then output $l = -1$, $r = -1$.\n\nExamples:\ninput:\n2\n5\n2 2 3 4 5\n3\n2 1\n4 1\n1 1\n5\n1 2 3 4 5\n9\n1 4\n2 3\n5 2\n3 1\n1 1\n5 1\n4 1\n3 1\n2 1\noutput:\n-1 -1\n1 2\n1 4\n3 4\n-1 -1\n1 3\n1 3\n1 5\n1 5\n2 5\n2 5\n2 5\n2 5\n-1 -1\n\nNote: Let's consider the first test case:\n\n * Initially, the array is sorted in non-decreasing order: $[2, 2, 3, 4, 5]$ * After the first query, the array looks like this: $[\\color{red}{2}, \\color{red}{1}, 3, 4, 5]$. * After the second query, the array looks like this: $[\\color{red}{2}, \\color{red}{1}, \\color{red}{3}, \\color{red}{1}, 5]$. * After the third query, the array looks like this: $[1, 1, \\color{red}{3}, \\color{red}{1}, 5]$. \n\nThe red segments indicate the subarrays that need to be sorted in order for the entire array to be sorted in non-decreasing order.\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "1982F", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Angry Monk\ntime_limit_ms: 2000\nmemory_limit_mb: 256\nDescription: To celebrate his recovery, k1o0n has baked an enormous $n$ metres long potato casserole.\n\nTurns out, Noobish_Monk just can't stand potatoes, so he decided to ruin k1o0n's meal. He has cut it into $k$ pieces, of lengths $a_1, a_2, \\dots, a_k$ meters.\n\nk1o0n wasn't keen on that. Luckily, everything can be fixed. In order to do that, k1o0n can do one of the following operations:\n\n * Pick a piece with length $a_i \\ge 2$ and divide it into two pieces with lengths $1$ and $a_i - 1$. As a result, the number of pieces will increase by $1$; * Pick a slice $a_i$ and another slice with length $a_j=1$ ($i \\ne j$) and merge them into one piece with length $a_i+1$. As a result, the number of pieces will decrease by $1$. \n\nHelp k1o0n to find the minimum number of operations he needs to do in order to merge the casserole into one piece with length $n$.\n\nFor example, if $n=5$, $k=2$ and $a = [3, 2]$, it is optimal to do the following:\n\n 1. Divide the piece with length $2$ into two pieces with lengths $2-1=1$ and $1$, as a result $a = [3, 1, 1]$. 2. Merge the piece with length $3$ and the piece with length $1$, as a result $a = [4, 1]$. 3. Merge the piece with length $4$ and the piece with length $1$, as a result $a = [5]$.\n\nInput: Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \\le t \\le 10^4$).\n\nDescription of each test case consists of two lines. The first line contains two integers $n$ and $k$ ($2 \\le n \\le 10^9$, $2 \\le k \\le 10^5$) β€” length of casserole and the number of pieces.\n\nThe second line contains $k$ integers $a_1, a_2, \\ldots, a_k$ ($1 \\le a_i \\le n - 1$, $\\sum a_i = n$) β€” lengths of pieces of casserole, which Noobish_Monk has cut.\n\nIt is guaranteed that the sum of $k$ over all $t$ test cases doesn't exceed $2 \\cdot 10^5$.\n\nOutput: For each test case, output the minimum number of operations K1o0n needs to restore his pie after the terror of Noobish_Monk.\n\nExamples:\ninput:\n4\n5 3\n3 1 1\n5 2\n3 2\n11 4\n2 3 1 5\n16 6\n1 6 1 1 1 6\noutput:\n2\n3\n9\n15\n\nNote: \n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "1992B", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Beautiful Triple Pairs\ntime_limit_ms: 4000\nmemory_limit_mb: 256\nDescription: Polycarp was given an array $a$ of $n$ integers. He really likes triples of numbers, so for each $j$ ($1 \\le j \\le n - 2$) he wrote down a triple of elements $[a_j, a_{j + 1}, a_{j + 2}]$.\n\nPolycarp considers a pair of triples $b$ and $c$ beautiful if they differ in exactly one position, that is, one of the following conditions is satisfied:\n\n * $b_1 \\ne c_1$ and $b_2 = c_2$ and $b_3 = c_3$; * $b_1 = c_1$ and $b_2 \\ne c_2$ and $b_3 = c_3$; * $b_1 = c_1$ and $b_2 = c_2$ and $b_3 \\ne c_3$. \n\nFind the number of beautiful pairs of triples among the written triples $[a_j, a_{j + 1}, a_{j + 2}]$.\n\nInput: The first line contains a single integer $t$ ($1 \\le t \\le 10^4$) β€” the number of test cases.\n\nThe first line of each test case contains a single integer $n$ ($3 \\le n \\le 2 \\cdot 10^5$) β€” the length of the array $a$.\n\nThe second line of each test case contains $n$ integers $a_1, a_2, \\dots, a_n$ ($1 \\le a_i \\le 10^6$) β€” the elements of the array.\n\nIt is guaranteed that the sum of the values of $n$ for all test cases in the test does not exceed $2 \\cdot 10^5$.\n\nOutput: For each test case, output a single integer β€” the number of beautiful pairs of triples among the pairs of the form $[a_j, a_{j + 1}, a_{j + 2}]$.\n\nNote that the answer may not fit into 32-bit data types.\n\nExamples:\ninput:\n8\n5\n3 2 2 2 3\n5\n1 2 1 2 1\n8\n1 2 3 2 2 3 4 2\n4\n2 1 1 1\n8\n2 1 1 2 1 1 1 1\n7\n2 1 1 1 1 1 1\n6\n2 1 1 1 1 1\n5\n2 1 1 1 1\noutput:\n2\n0\n3\n1\n8\n4\n3\n2\n\nNote: In the first example, $a = [3, 2, 2, 2, 3]$, Polycarp will write the following triples:\n\n 1. $[3, 2, 2]$; 2. $[2, 2, 2]$; 3. $[2, 2, 3]$. \n\nThe beautiful pairs are triple $1$ with triple $2$ and triple $2$ with triple $3$.\n\nIn the third example, $a = [1, 2, 3, 2, 2, 3, 4, 2]$, Polycarp will write the following triples:\n\n 1. $[1, 2, 3]$; 2. $[2, 3, 2]$; 3. $[3, 2, 2]$; 4. $[2, 2, 3]$; 5. $[2, 3, 4]$; 6. $[3, 4, 2]$; \n\nThe beautiful pairs are triple $1$ with triple $4$, triple $2$ with triple $5$, and triple $3$ with triple $6$.\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "1974C", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Maximize Mex\ntime_limit_ms: 1000\nmemory_limit_mb: 256\nDescription: You are given an array $a$ of $n$ positive integers and an integer $x$. You can do the following two-step operation any (possibly zero) number of times:\n\n 1. Choose an index $i$ ($1 \\leq i \\leq n$). 2. Increase $a_i$ by $x$, in other words $a_i := a_i + x$. \n\nFind the maximum value of the $\\operatorname{MEX}$ of $a$ if you perform the operations optimally.\n\nThe $\\operatorname{MEX}$ (minimum excluded value) of an array is the smallest non-negative integer that is not in the array. For example:\n\n * The $\\operatorname{MEX}$ of $[2,2,1]$ is $0$ because $0$ is not in the array. * The $\\operatorname{MEX}$ of $[3,1,0,1]$ is $2$ because $0$ and $1$ are in the array but $2$ is not. * The $\\operatorname{MEX}$ of $[0,3,1,2]$ is $4$ because $0$, $1$, $2$ and $3$ are in the array but $4$ is not.\n\nInput: Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \\le t \\le 5000$). The description of the test cases follows.\n\nThe first line of each test case contains two integers $n$ and $x$ ($1 \\le n \\le 2 \\cdot 10^5$; $1 \\le x \\le 10^9$) β€” the length of the array and the integer to be used in the operation.\n\nThe second line of each test case contains $n$ integers $a_1, a_2, \\ldots, a_n$ ($0 \\le a_i \\le 10^9$) β€” the given array.\n\nIt is guaranteed that the sum of $n$ over all test cases does not exceed $2 \\cdot 10^5$.\n\nOutput: For each test case, output a single integer: the maximum $\\operatorname{MEX}$ of $a$ if you perform the operations optimally.\n\nExamples:\ninput:\n3\n6 3\n0 3 2 1 5 2\n6 2\n1 3 4 1 0 2\n4 5\n2 5 10 3\noutput:\n4\n6\n0\n\nNote: In the first test case, the $\\operatorname{MEX}$ of $a$ is $4$ without performing any operations, which is the maximum.\n\nIn the second test case, the $\\operatorname{MEX}$ of $a$ is $5$ without performing any operations. If we perform two operations both with $i=1$, we will have the array $a=[5,3,4,1,0,2]$. Then, the $\\operatorname{MEX}$ of $a$ will become $6$, which is the maximum.\n\nIn the third test case, the $\\operatorname{MEX}$ of $a$ is $0$ without performing any operations, which is the maximum.\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "2021B", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Maximum GCD Sum Queries\ntime_limit_ms: 5000\nmemory_limit_mb: 512\nDescription: For $k$ positive integers $x_1, x_2, \\ldots, x_k$, the value $\\gcd(x_1, x_2, \\ldots, x_k)$ is the greatest common divisor of the integers $x_1, x_2, \\ldots, x_k$ β€” the largest integer $z$ such that all the integers $x_1, x_2, \\ldots, x_k$ are divisible by $z$.\n\nYou are given three arrays $a_1, a_2, \\ldots, a_n$, $b_1, b_2, \\ldots, b_n$ and $c_1, c_2, \\ldots, c_n$ of length $n$, containing positive integers.\n\nYou also have a machine that allows you to swap $a_i$ and $b_i$ for any $i$ ($1 \\le i \\le n$). Each swap costs you $c_i$ coins.\n\nFind the maximum possible value of $$\\gcd(a_1, a_2, \\ldots, a_n) + \\gcd(b_1, b_2, \\ldots, b_n)$$ that you can get by paying in total at most $d$ coins for swapping some elements. The amount of coins you have changes a lot, so find the answer to this question for each of the $q$ possible values $d_1, d_2, \\ldots, d_q$.\n\nInput: There are two integers on the first line β€” the numbers $n$ and $q$ ($1 \\leq n \\leq 5 \\cdot 10^5$, $1 \\leq q \\leq 5 \\cdot 10^5$).\n\nOn the second line, there are $n$ integers β€” the numbers $a_1, a_2, \\ldots, a_n$ ($1 \\leq a_i \\leq 10^8$).\n\nOn the third line, there are $n$ integers β€” the numbers $b_1, b_2, \\ldots, b_n$ ($1 \\leq b_i \\leq 10^8$).\n\nOn the fourth line, there are $n$ integers β€” the numbers $c_1, c_2, \\ldots, c_n$ ($1 \\leq c_i \\leq 10^9$).\n\nOn the fifth line, there are $q$ integers β€” the numbers $d_1, d_2, \\ldots, d_q$ ($0 \\leq d_i \\leq 10^{15}$).\n\nOutput: Print $q$ integers β€” the maximum value you can get for each of the $q$ possible values $d$.\n\nExamples:\ninput:\n3 4\n1 2 3\n4 5 6\n1 1 1\n0 1 2 3\noutput:\n2 3 3 3\n\ninput:\n5 5\n3 4 6 8 4\n8 3 4 9 3\n10 20 30 40 50\n5 55 13 1000 113\noutput:\n2 7 3 7 7\n\ninput:\n1 1\n3\n4\n5\n0\noutput:\n7\n\nNote: In the first query of the first example, we are not allowed to do any swaps at all, so the answer is $\\gcd(1, 2, 3) + \\gcd(4, 5, 6) = 2$. In the second query, one of the ways to achieve the optimal value is to swap $a_2$ and $b_2$, then the answer is $\\gcd(1, 5, 3) + \\gcd(4, 2, 6) = 3$.\n\nIn the second query of the second example, it's optimal to perform swaps on positions $1$ and $3$, then the answer is $\\gcd(3, 3, 6, 9, 3) + \\gcd(8, 4, 4, 8, 4) = 7$ and we have to pay $40$ coins in total.\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "1973F", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Final Boss\ntime_limit_ms: 2000\nmemory_limit_mb: 256\nDescription: You are facing the final boss in your favorite video game. The boss enemy has $h$ health. Your character has $n$ attacks. The $i$'th attack deals $a_i$ damage to the boss but has a cooldown of $c_i$ turns, meaning the next time you can use this attack is turn $x + c_i$ if your current turn is $x$. Each turn, you can use all attacks that are not currently on cooldown, all at once. If all attacks are on cooldown, you do nothing for the turn and skip to the next turn.\n\nInitially, all attacks are not on cooldown. How many turns will you take to beat the boss? The boss is beaten when its health is $0$ or less.\n\nInput: The first line contains $t$ ($1 \\leq t \\leq 10^4$) – the number of test cases.\n\nThe first line of each test case contains two integers $h$ and $n$ ($1 \\leq h, n \\leq 2 \\cdot 10^5$) – the health of the boss and the number of attacks you have.\n\nThe following line of each test case contains $n$ integers $a_1, a_2, ..., a_n$ ($1 \\leq a_i \\leq 2 \\cdot 10^5$) – the damage of your attacks.\n\nThe following line of each test case contains $n$ integers $c_1, c_2, ..., c_n$ ($1 \\leq c_i \\leq 2 \\cdot 10^5$) – the cooldown of your attacks.\n\nIt is guaranteed that the sum of $h$ and $n$ over all test cases does not exceed $2 \\cdot 10^5$.\n\nOutput: For each test case, output an integer, the minimum number of turns required to beat the boss.\n\nExamples:\ninput:\n8\n3 2\n2 1\n2 1\n5 2\n2 1\n2 1\n50 3\n5 6 7\n5 6 7\n50 3\n2 2 2\n3 3 3\n90000 2\n200000 200000\n1 1\n100000 1\n1\n200000\n6 7\n3 2 3 2 3 1 2\n6 5 9 5 10 7 7\n21 6\n1 1 1 1 1 1\n5 5 8 10 7 6\noutput:\n1\n3\n15\n25\n1\n19999800001\n1\n21\n\nNote: For the first test case, you can use attacks $1$ and $2$ on the first turn, dealing $3$ damage in total, and slaying the boss.\n\nFor the second case, you can beat the boss in $3$ turns by using the following attacks:\n\nTurn $1$: Use attacks $1$ and $2$, dealing $3$ damage to the boss. The boss now has $2$ health left.\n\nTurn $2$: Use attack $2$, dealing $1$ damage to the boss. The boss now has $1$ health left.\n\nTurn $3$: Use attack $1$, dealing $2$ damage to the boss. The boss now has $-1$ health left. Since its health is less than or equal to $0$, you beat the boss.\n\nFor the sixth test case: remember to use 64-bit integers as the answer can get large.\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "1985F", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Alice's Adventures in Addition\ntime_limit_ms: 3000\nmemory_limit_mb: 32\nDescription: Note that the memory limit is unusual.\n\nThe Cheshire Cat has a riddle for Alice: given $n$ integers $a_1, a_2, \\ldots, a_n$ and a target $m$, is there a way to insert $+$ and $\\times$ into the circles of the expression $$a_1 \\circ a_2 \\circ \\cdots \\circ a_n = m$$ to make it true? We follow the usual order of operations: $\\times$ is done before $+$.\n\nAlthough Alice is excellent at chess, she is not good at math. Please help her so she can find a way out of Wonderland!\n\nInput: Each test contains multiple test cases. The first line of input contains a single integer $t$ ($1 \\le t \\le 10^4$) β€” the number of test cases. The description of the test cases follows.\n\nThe first line of each test case contains two integers $n, m$ ($1\\le n\\le 2\\cdot 10^5$; $1\\le m\\le 10^4$) β€” the number of integers and the target, respectively.\n\nThe second line of each test case contains $n$ integers $a_1, a_2, \\ldots, a_n$ ($0\\le a_i\\le 10^4$) β€” the elements of the array $a$.\n\nThe sum of $n$ over all test cases does not exceed $2\\cdot 10^5$.\n\nOutput: For each test case, output \"YES\" without quotes if it is possible to get the target by inserting $+$ or $\\times$ and \"NO\" otherwise.\n\nYou can output each letter in any case (for example, the strings \"yEs\", \"yes\", \"Yes\", and \"YES\" will be recognized as a positive answer).\n\nExamples:\ninput:\n6\n5 4\n2 1 1 1 2\n5 5\n2 1 1 1 2\n5 6\n2 1 1 1 2\n5 7\n2 1 1 1 2\n5 8\n2 1 1 1 2\n5 6\n2 0 2 2 3\noutput:\nYES\nYES\nYES\nYES\nNO\nYES\n\nNote: Possible solutions for the first four test cases are shown below. $$\\begin{align*} 2 \\times 1 + 1 \\times 1 \\times 2 &= 4 \\\\\\ 2 \\times 1 + 1 + 1 \\times 2 &= 5 \\\\\\ 2 \\times 1 + 1 + 1 \\times 2 &= 6 \\\\\\ 2 + 1 + 1 + 1 + 2 &= 7 \\\\\\ \\end{align*}$$ It is impossible to get a result of $8$ in the fifth test case.\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "2028F", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Update Queries\ntime_limit_ms: 2000\nmemory_limit_mb: 256\nDescription: Let's consider the following simple problem. You are given a string $s$ of length $n$, consisting of lowercase Latin letters, as well as an array of indices $ind$ of length $m$ ($1 \\leq ind_i \\leq n$) and a string $c$ of length $m$, consisting of lowercase Latin letters. Then, in order, you perform the update operations, namely, during the $i$-th operation, you set $s_{ind_i} = c_i$. Note that you perform all $m$ operations from the first to the last.\n\nOf course, if you change the order of indices in the array $ind$ and/or the order of letters in the string $c$, you can get different results. Find the lexicographically smallest string $s$ that can be obtained after $m$ update operations, if you can rearrange the indices in the array $ind$ and the letters in the string $c$ as you like.\n\nA string $a$ is lexicographically less than a string $b$ if and only if one of the following conditions is met:\n\n * $a$ is a prefix of $b$, but $a \\neq b$; * in the first position where $a$ and $b$ differ, the symbol in string $a$ is earlier in the alphabet than the corresponding symbol in string $b$.\n\nInput: Each test consists of several sets of input data. The first line contains a single integer $t$ ($1 \\leq t \\leq 10^4$) β€” the number of sets of input data. Then follows their description.\n\nThe first line of each set of input data contains two integers $n$ and $m$ ($1 \\leq n, m \\leq 10^5$) β€” the length of the string $s$ and the number of updates.\n\nThe second line of each set of input data contains a string $s$ of length $n$, consisting of lowercase Latin letters.\n\nThe third line of each set of input data contains $m$ integers $ind_1, ind_2, \\ldots, ind_m$ ($1 \\leq ind_i \\leq n$) β€” the array of indices $ind$.\n\nThe fourth line of each set of input data contains a string $c$ of length $m$, consisting of lowercase Latin letters.\n\nIt is guaranteed that the sum of $n$ over all sets of input data does not exceed $2 \\cdot 10^5$. Similarly, the sum of $m$ over all sets of input data does not exceed $2 \\cdot 10^5$.\n\nOutput: For each set of input data, output the lexicographically smallest string $s$ that can be obtained by rearranging the indices in the array $ind$ and the letters in the string $c$ as you like.\n\nExamples:\ninput:\n4\n1 2\na\n1 1\ncb\n4 4\nmeow\n1 2 1 4\nzcwz\n7 4\nabacaba\n1 3 5 7\ndamn\n7 10\ntraktor\n7 6 5 4 3 2 1 6 4 2\ncodeforces\noutput:\nb\ncwoz\nabdcmbn\nccdeefo\n\nNote: In the first set of input data, you can leave the array $ind$ and the string $c$ unchanged and simply perform all operations in that order.\n\nIn the second set of input data, you can set the array $ind = [1, 1, 4, 2]$ and $c =$ \"zczw\". Then the string $s$ will change as follows: $meow \\rightarrow zeow \\rightarrow ceow \\rightarrow ceoz \\rightarrow cwoz$.\n\nIn the third set of input data, you can leave the array $ind$ unchanged and set $c = $ \"admn\". Then the string $s$ will change as follows: $abacaba \\rightarrow abacaba \\rightarrow abdcaba \\rightarrow abdcmba \\rightarrow abdcmbn$.\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "1986C", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Card Game\ntime_limit_ms: 2000\nmemory_limit_mb: 512\nDescription: In the most popular card game in Berland, a deck of $n \\times m$ cards is used. Each card has two parameters: suit and rank. Suits in the game are numbered from $1$ to $n$, and ranks are numbered from $1$ to $m$. There is exactly one card in the deck for each combination of suit and rank.\n\nA card with suit $a$ and rank $b$ can beat a card with suit $c$ and rank $d$ in one of two cases:\n\n * $a = 1$, $c \\ne 1$ (a card of suit $1$ can beat a card of any other suit); * $a = c$, $b > d$ (a card can beat any other card of the same suit but of a lower rank). \n\nTwo players play the game. Before the game starts, they receive exactly half of the deck each. The first player wins if for every card of the second player, he can choose his card that can beat it, and there is no card that is chosen twice (i. e. there exists a matching of the first player's cards with the second player's cards such that in each pair the first player's card beats the second player's card). Otherwise, the second player wins.\n\nYour task is to calculate the number of ways to distribute the cards so that the first player wins. Two ways are considered different if there exists a card such that in one way it belongs to the first player and in the other way it belongs to the second player. The number of ways can be very large, so print it modulo $998244353$.\n\nInput: The only line contains two integers $n$ and $m$ ($1 \\le n, m \\le 500$).\n\nAdditional constraint on the input: $m$ is even.\n\nOutput: Print a single integer β€” the number of ways to distribute the cards so that the first player wins, taken modulo $998244353$.\n\nExamples:\ninput:\n1 4\noutput:\n2\n\ninput:\n2 2\noutput:\n2\n\ninput:\n3 6\noutput:\n1690\n\ninput:\n5 4\noutput:\n568\n\ninput:\n500 500\noutput:\n84693741\n\nNote: \n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "2025E", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Substring and Subsequence\ntime_limit_ms: 2000\nmemory_limit_mb: 256\nDescription: You are given two strings $a$ and $b$, both consisting of lowercase Latin letters.\n\nA subsequence of a string is a string which can be obtained by removing several (possibly zero) characters from the original string. A substring of a string is a contiguous subsequence of that string.\n\nFor example, consider the string abac:\n\n * a, b, c, ab, aa, ac, ba, bc, aba, abc, aac, bac and abac are its subsequences; * a, b, c, ab, ba, ac, aba, bac and abac are its substrings. \n\nYour task is to calculate the minimum possible length of the string that contains $a$ as a substring and $b$ as a subsequence.\n\nInput: The first line contains a single integer $t$ ($1 \\le t \\le 10^3$) β€” the number of test cases.\n\nThe first line of each test case contains a string $a$ ($1 \\le |a| \\le 100$), consisting of lowercase Latin letters.\n\nThe second line of each test case contains a string $b$ ($1 \\le |b| \\le 100$), consisting of lowercase Latin letters.\n\nOutput: For each test case, print a single integer β€” the minimum possible length of the string that contains $a$ as a substring and $b$ as a subsequence.\n\nExamples:\ninput:\n5\naba\ncb\ner\ncf\nmmm\nmmm\ncontest\ntest\ncde\nabcefg\noutput:\n4\n4\n3\n7\n7\n\nNote: In the examples below, the characters that correspond to the subsequence equal to $b$ are bolded.\n\nIn the first example, one of the possible answers is caba.\n\nIn the second example, one of the possible answers is ercf.\n\nIn the third example, one of the possible answers is mmm.\n\nIn the fourth example, one of the possible answers is contest.\n\nIn the fifth example, one of the possible answers is abcdefg.\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "1989B", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Non-academic Problem\ntime_limit_ms: 2000\nmemory_limit_mb: 256\nDescription: You are given a connected undirected graph, the vertices of which are numbered with integers from $1$ to $n$. Your task is to minimize the number of pairs of vertices $1 \\leq u < v \\leq n$ between which there exists a path in this graph. To achieve this, you can remove exactly one edge from the graph.\n\nFind the smallest number of pairs of vertices!\n\nInput: Each test consists of several sets of input data. The first line contains a single integer $t$ ($1 \\leq t \\leq 10^4$) β€” the number of sets of input data. Then follows their description.\n\nThe first line of each set of input data contains two integers $n$ and $m$ ($2 \\leq n \\leq 10^5$, $n - 1 \\leq m \\leq \\min(10^5, \\frac{n \\cdot (n - 1)}{2})$) β€” the number of vertices in the graph and the number of edges.\n\nEach of the next $m$ lines contains two integers $u$ and $v$ ($1 \\leq u, v \\leq n, u \\neq v$), indicating that there is an undirected edge in the graph between vertices $u$ and $v$.\n\nIt is guaranteed that the given graph is connected and without multiple edges.\n\nIt is guaranteed that the sum of $n$ and the sum of $m$ over all sets of input data does not exceed $2 \\cdot 10^5$.\n\nOutput: For each set of input data, output the smallest number of pairs of reachable vertices, if exactly one edge can be removed.\n\nExamples:\ninput:\n6\n2 1\n1 2\n3 3\n1 2\n2 3\n1 3\n5 5\n1 2\n1 3\n3 4\n4 5\n5 3\n6 7\n1 2\n1 3\n2 3\n3 4\n4 5\n4 6\n5 6\n5 5\n1 2\n1 3\n2 3\n2 4\n3 5\n10 12\n1 2\n1 3\n2 3\n2 4\n4 5\n5 6\n6 7\n7 4\n3 8\n8 9\n9 10\n10 8\noutput:\n0\n3\n4\n6\n6\n21\n\nNote: In the first set of input data, we will remove the single edge $(1, 2)$ and the only pair of vertices $(1, 2)$ will become unreachable from each other.\n\nIn the second set of input data, no matter which edge we remove, all vertices will be reachable from each other.\n\nIn the fourth set of input data, the graph looks like this initially.\n\n![](CDN_BASE_URL/c00467697f2843fb1ecf4e292e93aa87)\n\nWe will remove the edge $(3, 4)$ and then the only reachable pairs of vertices will be $(1, 2)$, $(1, 3)$, $(2, 3)$, $(4, 5)$, $(4, 6)$, $(5, 6)$.\n\n![](CDN_BASE_URL/9d2fd2df4094f1654c448ff596e16eb3)\n\nIn the sixth set of input data, the graph looks like this initially.\n\n![](CDN_BASE_URL/a18a02e5685863de8060f83f96c068e2)\n\nAfter removing the edge $(2, 4)$, the graph will look like this. Thus, there will be $21$ pairs of reachable vertices.\n\n![](CDN_BASE_URL/f53901ac967e9f60a7423e8ea66c67e4)\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "1986F", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Money Buys Happiness\ntime_limit_ms: 3000\nmemory_limit_mb: 256\nDescription: Being a physicist, Charlie likes to plan his life in simple and precise terms.\n\nFor the next $m$ months, starting with no money, Charlie will work hard and earn $x$ pounds per month. For the $i$-th month $(1 \\le i \\le m)$, there'll be a single opportunity of paying cost $c_i$ pounds to obtain happiness $h_i$.\n\nBorrowing is not allowed. Money earned in the $i$-th month can only be spent in a later $j$-th month ($j>i$).\n\nSince physicists don't code, help Charlie find the maximum obtainable sum of happiness.\n\nInput: The first line of input contains a single integer $t$ ($1 \\le t \\le 1000$) β€” the number of test cases.\n\nThe first line of each test case contains two integers, $m$ and $x$ ($1 \\le m \\le 50$, $1 \\le x \\le 10^8$) β€” the total number of months and the monthly salary.\n\nThe $i$-th of the following $m$ lines contains two integers, $c_i$ and $h_i$ ($0 \\le c_i \\le 10^8$, $1 \\le h_i \\le 10^3$) β€” the cost and happiness on offer for the $i$-th month. Note that some happiness may be free ($c_i=0$ for some $i$'s).\n\nIt is guaranteed that the sum of $\\sum_i h_i$ over all test cases does not exceed $10^5$.\n\nOutput: For each test case, print a single integer, the maximum sum of happiness Charlie could obtain.\n\nExamples:\ninput:\n7\n1 10\n1 5\n2 80\n0 10\n200 100\n3 100\n70 100\n100 200\n150 150\n5 8\n3 1\n5 3\n3 4\n1 5\n5 3\n2 5\n1 5\n2 1\n5 3\n2 5\n2 4\n4 1\n5 1\n3 4\n5 2\n2 1\n1 2\n3 5\n3 2\n3 2\noutput:\n0\n10\n200\n15\n1\n9\n9\n\nNote: In the first test case, Charlie only gets paid at the end of the month, so is unable to afford anything.\n\nIn the second test case, Charlie obtains the free happiness in the first month.\n\nIn the third test case, it's optimal for Charlie to buy happiness in the second month. Even with money left at the end, Charlie could not go back in time to obtain the happiness on offer in the first month.\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "1974E", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Distance to Different\ntime_limit_ms: 2000\nmemory_limit_mb: 512\nDescription: Consider an array $a$ of $n$ integers, where every element is from $1$ to $k$, and every integer from $1$ to $k$ appears at least once.\n\nLet the array $b$ be constructed as follows: for the $i$-th element of $a$, $b_i$ is the distance to the closest element in $a$ which is not equal to $a_i$. In other words, $b_i = \\min \\limits_{j \\in [1, n], a_j \\ne a_i} |i - j|$.\n\nFor example, if $a = [1, 1, 2, 3, 3, 3, 3, 1]$, then $b = [2, 1, 1, 1, 2, 2, 1, 1]$.\n\nCalculate the number of different arrays $b$ you can obtain if you consider all possible arrays $a$, and print it modulo $998244353$.\n\nInput: The only line of the input contains two integers $n$ and $k$ ($2 \\le n \\le 2 \\cdot 10^5$; $2 \\le k \\le \\min(n, 10)$).\n\nOutput: Print one integer β€” the number of different arrays $b$ you can obtain, taken modulo $998244353$.\n\nExamples:\ninput:\n2 2\noutput:\n1\n\ninput:\n4 3\noutput:\n3\n\ninput:\n6 2\noutput:\n20\n\ninput:\n6 5\noutput:\n3\n\ninput:\n133 7\noutput:\n336975971\n\nNote: \n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "1989E", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Kosuke's Sloth\ntime_limit_ms: 1000\nmemory_limit_mb: 256\nDescription: Kosuke is too lazy. He will not give you any legend, just the task:\n\nFibonacci numbers are defined as follows:\n\n * $f(1)=f(2)=1$. * $f(n)=f(n-1)+f(n-2)$ $(3\\le n)$ \n\nWe denote $G(n,k)$ as an index of the $n$-th Fibonacci number that is divisible by $k$. For given $n$ and $k$, compute $G(n,k)$.\n\nAs this number can be too big, output it by modulo $10^9+7$.\n\nFor example: $G(3,2)=9$ because the $3$-rd Fibonacci number that is divisible by $2$ is $34$. $[1,1,\\textbf{2},3,5,\\textbf{8},13,21,\\textbf{34}]$.\n\nInput: The first line of the input data contains a single integer $t$ ($1 \\le t \\le 10^4$) β€” the number of test cases.\n\nThe first and only line contains two integers $n$ and $k$ ($1 \\le n \\le 10^{18}$, $1 \\le k \\le 10^5$).\n\nIt is guaranteed that the sum of $k$ across all test cases does not exceed $10^6$.\n\nOutput: For each test case, output the only number: the value $G(n,k)$ taken by modulo $10^9+7$.\n\nExamples:\ninput:\n3\n3 2\n100 1\n1000000000000 1377\noutput:\n9\n100\n999244007\n\nNote: \n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "2033F", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Subtangle Game (Easy Version)\ntime_limit_ms: 2000\nmemory_limit_mb: 256\nDescription: This is the easy version of the problem. The differences between the two versions are the constraints on all the variables. You can make hacks only if both versions of the problem are solved.\n\nTsovak and Narek are playing a game. They have an array $a$ and a matrix $b$ of integers with $n$ rows and $m$ columns, numbered from $1$. The cell in the $i$-th row and the $j$-th column is $(i, j)$.\n\nThey are looking for the elements of $a$ in turns; Tsovak starts first. Each time a player looks for a cell in the matrix containing the current element of $a$ (Tsovak looks for the first, then Narek looks for the second, etc.). Let's say a player has chosen the cell $(r, c)$. The next player has to choose his cell in the submatrix starting at $(r + 1, c + 1)$ and ending in $(n, m)$ (the submatrix can be empty if $r=n$ or $c=m$). If a player cannot find such a cell (or the remaining submatrix is empty) or the array ends (the previous player has chosen the last element), then he loses.\n\nYour task is to determine the winner if the players play optimally.\n\nInput: The first line of the input contains $t$ ($1 \\le t \\le 300$) – the number of test cases.\n\nThe first line of each test case contains three integers $l$, $n$, and $m$ ($1 \\le l, n, m \\le 300$) – the size of the array and the sizes of the matrix.\n\nThe second line contains $l$ integers $a_1, a_2, a_3, \\ldots a_l$ ($1 \\le a_i \\le \\min(7, n \\cdot m)$) – the elements of the array $a$.\n\nThe $i$-th of the last $n$ lines contains $m$ integers $b_{i,1}, b_{i,2}, b_{i,3}, \\ldots b_{i,m}$ ($1 \\le b_{i,j} \\le \\min(7, n \\cdot m)$) – representing the $i$-th row of the matrix.\n\nIt is guaranteed that the sum of $n \\cdot m$ over all test cases does not exceed $10^5$.\n\nIt is guaranteed that the sum of $l$ over all test cases does not exceed $300$.\n\nOutput: You should output $t$ lines, the $i$-th of them containing a character representing the answer of the $i$-th test case: \"T\" if Tsovak wins or \"N\", otherwise (without quotes).\n\nExamples:\ninput:\n3\n2 2 3\n1 2\n1 3 5\n4 5 2\n2 2 4\n1 2\n1 1 3 2\n4 2 5 1\n2 4 2\n1 2\n3 4\n5 5\n5 5\n5 5\noutput:\nN\nT\nN\n\nNote: In the first example, Tsovak starts by looking for $1$. There is only one occurrence of $1$ at $(1,1)$, so he chooses it. Then Narek needs to look for $2$ in the submatrix of $(2, 2)$, which consists of just the last two elements: $5$ and $2$. He chooses $2$, and then Tsovak loses since the array has ended.\n\nIn the second example, Tsovak needs to choose $1$. There is a $1$ at the cell $(n,m)$, so he chooses that cell. Then, since the submatrix of $(n + 1, m + 1)$ is empty, Narek cannot find $2$, so he loses.\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "2005E1", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Turtle and Paths on a Tree\ntime_limit_ms: 4000\nmemory_limit_mb: 1024\nDescription: Note the unusual definition of $\\text{MEX}$ in this problem.\n\nPiggy gave Turtle a binary tree$^{\\dagger}$ with $n$ vertices and a sequence $a_1, a_2, \\ldots, a_n$ on his birthday. The binary tree is rooted at vertex $1$.\n\nIf a set of paths $P = \\\\{(x_i, y_i)\\\\}$ in the tree covers each edge exactly once, then Turtle will think that the set of paths is good. Note that a good set of paths can cover a vertex twice or more.\n\nTurtle defines the value of a set of paths as $\\sum\\limits_{(x, y) \\in P} f(x, y)$, where $f(x, y)$ denotes the $\\text{MEX}^{\\ddagger}$ of all $a_u$ such that vertex $u$ is on the simple path from $x$ to $y$ in the tree (including the starting vertex $x$ and the ending vertex $y$).\n\nTurtle wonders the minimum value over all good sets of paths. Please help him calculate the answer!\n\n$^{\\dagger}$A binary tree is a tree where every non-leaf vertex has at most $2$ sons.\n\n$^{\\ddagger}\\text{MEX}$ of a collection of integers $c_1, c_2, \\ldots, c_k$ is defined as the smallest positive integer $x$ which does not occur in the collection $c$. For example, $\\text{MEX}$ of $[3, 3, 1, 4]$ is $2$, $\\text{MEX}$ of $[2, 3]$ is $1$.\n\nInput: Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \\le t \\le 10^4$). The description of the test cases follows.\n\nThe first line of each test case contains a single integer $n$ ($2 \\le n \\le 2.5 \\cdot 10^4$) β€” the number of vertices in the tree.\n\nThe second line of each test case contains $n$ integers $a_1, a_2, \\ldots, a_n$ ($1 \\le a_i \\le 10^9$) β€” the elements of the sequence $a$.\n\nThe third line of each test case contains $n - 1$ integers $p_2, p_3, \\ldots, p_n$ ($1 \\le p_i < i$) β€” the parent of each vertex in the tree.\n\nAdditional constraint on the input: the given tree is a binary tree, that is, every non-leaf vertex has at most $2$ sons.\n\nIt is guaranteed that the sum of $n$ over all test cases does not exceed $10^5$.\n\nOutput: For each test case, output a single integer β€” the minimum value over all good sets of paths.\n\nExamples:\ninput:\n5\n5\n3 2 2 1 1\n1 1 2 2\n5\n3 2 1 1 1\n1 1 2 2\n6\n1 2 1 2 1 3\n1 2 3 3 4\n7\n2 1 2 3 1 2 1\n1 1 2 2 3 3\n10\n1 2 2 1 4 2 3 1 2 1\n1 1 2 2 3 3 4 5 5\noutput:\n4\n6\n6\n6\n7\n\nNote: In the first test case, the tree is as follows. The number in brackets denotes the weight of the vertex:\n\n![](CDN_BASE_URL/45a1635df0fcab1b711d2165163f0dfb)\n\nThe good set of paths with the minimum value is $\\\\{(2, 3), (4, 5)\\\\}$.\n\nNote that in this test case $\\\\{(4, 5)\\\\}$ and $\\\\{(3, 4), (4, 5)\\\\}$ are not good sets of paths because each edge should be covered exactly once.\n\nIn the second test case, the tree is as follows:\n\n![](CDN_BASE_URL/a41b8a69adf0471a8353a08785fa6375)\n\nThe set of good paths with the minimum value is $\\\\{(1, 2), (1, 3), (4, 5)\\\\}$.\n\nIn the third test case, the tree is as follows:\n\n![](CDN_BASE_URL/7e62b6f397447336b5c5732c0d915ebd)\n\nThe set of good paths with the minimum value is $\\\\{(1, 6), (3, 5)\\\\}$.\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "1981F", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Everyone Loves Tres\ntime_limit_ms: 1000\nmemory_limit_mb: 256\nDescription: There are 3 heroes and 3 villains, so 6 people in total.\n\nGiven a positive integer $n$. Find the smallest integer whose decimal representation has length $n$ and consists only of $3$s and $6$s such that it is divisible by both $33$ and $66$. If no such integer exists, print $-1$.\n\nInput: The first line contains a single integer $t$ ($1\\le t\\le 500$) β€” the number of test cases.\n\nThe only line of each test case contains a single integer $n$ ($1\\le n\\le 500$) β€” the length of the decimal representation.\n\nOutput: For each test case, output the smallest required integer if such an integer exists and $-1$ otherwise.\n\nExamples:\ninput:\n6\n1\n2\n3\n4\n5\n7\noutput:\n-1\n66\n-1\n3366\n36366\n3336366\n\nNote: For $n=1$, no such integer exists as neither $3$ nor $6$ is divisible by $33$.\n\nFor $n=2$, $66$ consists only of $6$s and it is divisible by both $33$ and $66$.\n\nFor $n=3$, no such integer exists. Only $363$ is divisible by $33$, but it is not divisible by $66$.\n\nFor $n=4$, $3366$ and $6666$ are divisible by both $33$ and $66$, and $3366$ is the smallest.\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "2035B", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Cat, Fox and Swaps\ntime_limit_ms: 2000\nmemory_limit_mb: 256\nDescription: Fox has found an array $p_1, p_2, \\ldots, p_n$, that is a permutation of length $n^\\dagger$ of the numbers $1, 2, \\ldots, n$. She wants to sort the elements in increasing order. Cat wants to help her β€” he is able to swap any two numbers $x$ and $y$ in the array, but only if $l \\leq x + y \\leq r$ (note that the constraint is imposed on the values of the elements, not their positions). He can make such swaps any number of times.\n\nThey don't know the numbers $l$, $r$ yet, they only know that it's true that $1 \\leq l \\leq r \\leq 2 \\cdot n$.\n\nYou are given the number $n$ and the array $p_1, p_2, \\ldots, p_n$. Determine how many pairs $(l, r)$ satisfying the conditions are there such that you can sort the permutation if you can only swap two number $(x, y)$ such that $l \\leq x + y \\leq r$ (arbitrary number of times, possibly $0$).\n\n$^\\dagger$ A permutation of length $n$ is an array consisting of $n$ distinct integers from $1$ to $n$ in arbitrary order. For example, $[2,3,1,5,4]$ is a permutation, but $[1,2,2]$ is not a permutation ($2$ appears twice in the array), and $[1,3,4]$ is also not a permutation ($n=3$ but there is $4$ in the array).\n\nInput: Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \\le t \\le 10^4$). The description of the test cases follows.\n\nDescription of each test case consists of two lines. The first line contains one integer $n$ ($1 \\leq n \\leq 10^5$).\n\nThe second line contains $n$ integers: the array $p_1, p_2, \\ldots, p_n$ ($1 \\le p_i \\le n$). It is guaranteed that this array is a permutation of length $n$.\n\nIt is guaranteed that the sum of $n$ over all test cases does not exceed $10^5$.\n\nOutput: For each test case, print the number of pairs of integers $(l, r)$ such that $1 \\leq l \\leq r \\leq 2 \\cdot n$, and you can sort the array under the constraints.\n\nExamples:\ninput:\n7\n2\n2 1\n3\n3 1 2\n4\n3 2 1 4\n5\n5 3 1 2 4\n5\n1 2 3 4 5\n6\n3 2 1 5 4 6\n6\n1 3 2 4 5 6\noutput:\n6\n11\n23\n29\n55\n46\n58\n\nNote: In the first example, we need to be able to swap $1$ and $2$, so we must be able to swap numbers with sum $3$. There are exactly $6$ pairs satisfying the condition: $(1, 3), (2, 3), (3, 3), (1, 4), (2, 4)$ and $(3, 4)$, so the answer is $6$.\n\nIn the second example, the $11$ pairs satisfying the condition are $(1, 4), (1, 5), (1, 6), (2, 4), (2, 5), (2, 6), (3, 4), (3, 5), (3, 6), (4, 5)$ and $(4, 6)$. For example, if we pick the pair $(3, 4)$ we can first swap the numbers $1$ and $2$ and then the numbers $1$ and $3$, after this, the permutation is sorted.\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "1973E", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Balanced Problem\ntime_limit_ms: 3000\nmemory_limit_mb: 1024\nDescription: There is an array $a$ consisting of $n$ integers. Initially, all elements of $a$ are equal to $0$.\n\nKevin can perform several operations on the array. Each operation is one of the following two types:\n\n * Prefix addition β€” Kevin first selects an index $x$ ($1\\le x\\le n$), and then for each $1\\le j\\le x$, increases $a_j$ by $1$; * Suffix addition β€” Kevin first selects an index $x$ ($1\\le x\\le n$), and then for each $x\\le j\\le n$, increases $a_j$ by $1$.\n\nIn the country of KDOI, people think that the integer $v$ is balanced. Thus, Iris gives Kevin an array $c$ consisting of $n$ integers and defines the beauty of the array $a$ as follows:\n\n * Initially, set $b=0$; * For each $1\\le i\\le n$, if $a_i=v$, add $c_i$ to $b$; * The beauty of $a$ is the final value of $b$.\n\nKevin wants to maximize the beauty of $a$ after all the operations. However, he had already performed $m$ operations when he was sleepy. Now, he can perform an arbitrary number (possibly zero) of new operations.\n\nYou have to help Kevin find the maximum possible beauty if he optimally performs the new operations.\n\nHowever, to make sure that you are not just rolling the dice, Kevin gives you an integer $V$, and you need to solve the problem for each $1\\le v\\le V$.\n\nInput: Each test contains multiple test cases. The first line of the input contains a single integer $t$ ($1\\le t\\le 1000$) β€” the number of test cases. The description of test cases follows.\n\nThe first line of each test case contains three integers $n$, $m$, and $V$ ($1\\le n, m\\le 2\\cdot 10^5$, $1\\le V\\le 2000$) β€” the length of the array $a$, the number of initial operations, and the number that Kevin gives you.\n\nThe second line contains $n$ integers $c_1, c_2, \\ldots, c_n$ ($1\\le c_i\\le 10^9$) β€” the elements in the array $c$.\n\nThen $m$ lines follow, the $i$-th line containing a character $op$ and an integer $x$ ($op=\\mathtt{L}$ or $\\mathtt{R}$, $1\\le x\\le n$) β€” the type of the $i$-th operation and the selected index.\n\n * If $op=\\mathtt{L}$, this operation is a prefix addition on index $x$; * If $op=\\mathtt{R}$, this operation is a suffix addition on index $x$. \n\nIt is guaranteed that:\n\n * the sum of $n$ over all test cases does not exceed $2\\cdot 10^5$; * the sum of $m$ over all test cases does not exceed $2\\cdot 10^5$; * the sum of $V^2$ over all test cases does not exceed $4\\cdot 10^6$.\n\nOutput: For each test case, output $V$ integers in a single line, the $i$-th integer denoting the maximum possible beauty after Kevin performs some new operations when $v=i$.\n\nExamples:\ninput:\n5\n3 3 2\n1 2 4\nL 3\nR 3\nL 1\n3 3 2\n5 1 4\nL 3\nR 3\nL 1\n5 4 5\n1 1 1 1 1\nL 3\nR 2\nL 5\nL 4\n10 12 9\n10 9 8 7 6 5 4 3 2 1\nL 2\nL 4\nR 4\nR 4\nL 6\nR 8\nL 3\nL 2\nR 1\nR 10\nL 8\nL 1\n1 1 4\n1000000000\nL 1\noutput:\n2 6\n1 9\n0 1 3 5 5\n0 0 0 6 25 32 35 44 51\n1000000000 1000000000 1000000000 1000000000\n\nNote: In the first test case, the array $a$ changes as follows for the initial operations: $[0, 0, 0] \\xrightarrow{\\mathtt{L}\\ 3} [1, 1, 1] \\xrightarrow{\\mathtt{R}\\ 3} [1, 1, 2] \\xrightarrow{\\mathtt{L}\\ 1} [2, 1, 2]$.\n\n * For $v=1$, it is optimal to not perform any new operations, and the beauty is $b=c_2=2$; * For $v=2$, it is optimal to perform a prefix addition operation on index $2$. After that, $a$ becomes $[3,2,2]$, and the beauty is $b=c_2+c_3=6$. \n\nIn the second test case, for both $v=1$ and $v=2$, it is optimal to not perform any new operations.\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "2029G", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Collatz Conjecture\ntime_limit_ms: 1000\nmemory_limit_mb: 256\nDescription: Recently, the first-year student Maxim learned about the Collatz conjecture, but he didn't pay much attention during the lecture, so he believes that the following process is mentioned in the conjecture:\n\nThere is a variable $x$ and a constant $y$. The following operation is performed $k$ times:\n\n * increase $x$ by $1$, then * while the number $x$ is divisible by $y$, divide it by $y$. \n\nNote that both of these actions are performed sequentially within one operation.\n\nFor example, if the number $x = 16$, $y = 3$, and $k = 2$, then after one operation $x$ becomes $17$, and after another operation $x$ becomes $2$, because after adding one, $x = 18$ is divisible by $3$ twice.\n\nGiven the initial values of $x$, $y$, and $k$, Maxim wants to know what is the final value of $x$.\n\nInput: Each test consists of multiple test cases. The first line contains an integer $t$ ($1 \\le t \\le 10^{4}$) β€” the number of test cases. Then follows the description of the test cases.\n\nThe only line of each test case contains three integers $x$, $y$, and $k$ ($1 \\le x, k \\le 10^{9}$, $2 \\le y \\le 10^{9}$) β€” the initial variable, constant and the number of operations.\n\nOutput: For each test case, output a single integer β€” the number obtained after applying $k$ operations.\n\nExamples:\ninput:\n13\n1 3 1\n2 3 1\n24 5 5\n16 3 2\n2 2 1\n1337 18 1\n1 2 144133\n12345678 3 10\n998244353 2 998244353\n998244353 123456789 998244352\n998244354 998241111 998244352\n998244355 2 9982443\n1000000000 1000000000 1000000000\noutput:\n2\n1\n1\n2\n3\n1338\n1\n16936\n1\n21180097\n6486\n1\n2\n\nNote: In the first test case, there is only one operation applied to $x = 1$, resulting in $x$ becoming $2$.\n\nIn the second test case, for $x = 2$, within one operation, one is added to $x$ and it's divided by $y = 3$, resulting in $x$ becoming $1$.\n\nIn the third test case, $x$ changes as follows:\n\n * After the first operation, $x = 1$, because $24 + 1 = 25$ and $25$ is divisible by $y = 5$ twice within one operation. * After the second operation, $x = 2$. * After the third operation, $x = 3$. * After the fourth operation, $x = 4$. * After the fifth operation, $x = 1$.\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "1982B", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Trinity\ntime_limit_ms: 2000\nmemory_limit_mb: 256\nDescription: You are given an array $a$ of $n$ elements $a_1, a_2, \\ldots, a_n$.\n\nYou can perform the following operation any number (possibly $0$) of times:\n\n * Choose two integers $i$ and $j$, where $1 \\le i, j \\le n$, and assign $a_i := a_j$. \n\nFind the minimum number of operations required to make the array $a$ satisfy the condition:\n\n * For every pairwise distinct triplet of indices $(x, y, z)$ ($1 \\le x, y, z \\le n$, $x \\ne y$, $y \\ne z$, $x \\ne z$), there exists a non-degenerate triangle with side lengths $a_x$, $a_y$ and $a_z$, i.e. $a_x + a_y > a_z$, $a_y + a_z > a_x$ and $a_z + a_x > a_y$.\n\nInput: Each test consists of multiple test cases. The first line contains a single integer $t$ ($1 \\le t \\le 10^4$) β€” the number of test cases. The description of the test cases follows.\n\nThe first line of each test case contains a single integer $n$ ($3 \\le n \\le 2 \\cdot 10^5$) β€” the number of elements in the array $a$.\n\nThe second line of each test case contains $n$ integers $a_1, a_2, \\ldots, a_n$ ($1 \\le a_i \\le 10^9$) β€” the elements of the array $a$.\n\nIt is guaranteed that the sum of $n$ over all test cases does not exceed $2 \\cdot 10^5$.\n\nOutput: For each test case, output a single integer β€” the minimum number of operations required.\n\nExamples:\ninput:\n4\n7\n1 2 3 4 5 6 7\n3\n1 3 2\n3\n4 5 3\n15\n9 3 8 1 6 5 3 8 2 1 4 2 9 4 7\noutput:\n3\n1\n0\n8\n\nNote: In the first test case, one of the possible series of operations would be:\n\n * Assign $a_1 := a_4 = 4$. The array will become $[4, 2, 3, 4, 5, 6, 7]$. * Assign $a_2 := a_5 = 5$. The array will become $[4, 5, 3, 4, 5, 6, 7]$. * Assign $a_7 := a_1 = 4$. The array will become $[4, 5, 3, 4, 5, 6, 4]$. \n\nIt can be proven that any triplet of elements with pairwise distinct indices in the final array forms a non-degenerate triangle, and there is no possible answer using less than $3$ operations.\n\nIn the second test case, we can assign $a_1 := a_2 = 3$ to make the array $a = [3, 3, 2]$.\n\nIn the third test case, since $3$, $4$ and $5$ are valid side lengths of a triangle, we don't need to perform any operation to the array.\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "2032C", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Valuable Cards\ntime_limit_ms: 4000\nmemory_limit_mb: 512\nDescription: In his favorite cafe Kmes once again wanted to try the herring under a fur coat. Previously, it would not have been difficult for him to do this, but the cafe recently introduced a new purchasing policy.\n\nNow, in order to make a purchase, Kmes needs to solve the following problem: $n$ cards with prices for different positions are laid out in front of him, on the $i$-th card there is an integer $a_i$, among these prices there is no whole positive integer $x$.\n\nKmes is asked to divide these cards into the minimum number of bad segments (so that each card belongs to exactly one segment). A segment is considered bad if it is impossible to select a subset of cards with a product equal to $x$. All segments, in which Kmes will divide the cards, must be bad.\n\nFormally, the segment $(l, r)$ is bad if there are no indices $i_1 < i_2 < \\ldots < i_k$ such that $l \\le i_1, i_k \\le r$, and $a_{i_1} \\cdot a_{i_2} \\ldots \\cdot a_{i_k} = x$.\n\nHelp Kmes determine the minimum number of bad segments in order to enjoy his favorite dish.\n\nInput: The first line contains a single integer $t$ ($1 \\le t \\le 10^3$) β€” the number of test cases.\n\nThe first line of each set of input data gives you $2$ integers $n$ and $x$ ($1 \\le n \\le 10^5, 2 \\le x \\le 10^5$) β€” the number of cards and the integer, respectively.\n\nThe second line of each set of input data contains $n$ integers $a_i$ ($1 \\le a_i \\le 2 \\cdot 10^5, a_i \\neq x$) β€” the prices on the cards.\n\nIt is guaranteed that the sum of $n$ over all sets of test data does not exceed $10^5$.\n\nOutput: For each set of input data, output the minimum number of bad segments.\n\nExamples:\ninput:\n8\n6 4\n2 3 6 2 1 2\n9 100000\n50000 25000 12500 6250 3125 2 4 8 16\n5 2\n1 1 1 1 1\n8 6\n4 3 4 3 4 3 4 3\n7 12\n6 11 1 3 11 10 2\n10 5\n2 4 4 2 4 4 4 3 1 1\n7 8\n4 6 5 1 2 4 1\n8 27\n3 9 17 26 2 20 9 3\noutput:\n3\n2\n1\n1\n2\n1\n3\n3\n\nNote: \n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "1992F", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Substring Compression\ntime_limit_ms: 2000\nmemory_limit_mb: 1024\nDescription: Let's define the operation of compressing a string $t$, consisting of at least $2$ digits from $1$ to $9$, as follows:\n\n * split it into an even number of non-empty substrings β€” let these substrings be $t_1, t_2, \\dots, t_m$ (so, $t = t_1 + t_2 + \\dots + t_m$, where $+$ is the concatenation operation); * write the string $t_2$ $t_1$ times, then the string $t_4$ $t_3$ times, and so on. \n\nFor example, for a string \"12345\", one could do the following: split it into (\"1\", \"23\", \"4\", \"5\"), and write \"235555\".\n\nLet the function $f(t)$ for a string $t$ return the minimum length of the string that can be obtained as a result of that process.\n\nYou are given a string $s$, consisting of $n$ digits from $1$ to $9$, and an integer $k$. Calculate the value of the function $f$ for all contiguous substrings of $s$ of length exactly $k$.\n\nInput: The first line contains two integers $n$ and $k$ ($2 \\le k \\le n \\le 2 \\cdot 10^5$).\n\nThe second line contains the string $s$ ($|s| = n$), consisting only of digits from $1$ to $9$.\n\nOutput: Output $n - k + 1$ integers β€” $f(s_{1,k}), f(s_{2,k+1}), \\dots, f(s_{n - k + 1, n})$.\n\nExamples:\ninput:\n4 4\n5999\noutput:\n14\n\ninput:\n10 3\n1111111111\noutput:\n2 2 2 2 2 2 2 2\n\ninput:\n11 4\n49998641312\noutput:\n12 18 17 15 12 7 7 2\n\nNote: \n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "2004G", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Lazy Narek\ntime_limit_ms: 2000\nmemory_limit_mb: 256\nDescription: Narek is too lazy to create the third problem of this contest. His friend Artur suggests that he should use ChatGPT. ChatGPT creates $n$ problems, each consisting of $m$ letters, so Narek has $n$ strings. To make the problem harder, he combines the problems by selecting some of the $n$ strings possibly none and concatenating them without altering their order. His chance of solving the problem is defined as $score_n - score_c$, where $score_n$ is Narek's score and $score_c$ is ChatGPT's score.\n\nNarek calculates $score_n$ by examining the selected string (he moves from left to right). He initially searches for the letter $\\texttt{\"n\"}$, followed by $\\texttt{\"a\"}$, $\\texttt{\"r\"}$, $\\texttt{\"e\"}$, and $\\texttt{\"k\"}$. Upon finding all occurrences of these letters, he increments $score_n$ by $5$ and resumes searching for $\\texttt{\"n\"}$ again (he doesn't go back, and he just continues from where he left off).\n\nAfter Narek finishes, ChatGPT scans through the array and increments $score_c$ by $1$ for each letter $\\texttt{\"n\"}$, $\\texttt{\"a\"}$, $\\texttt{\"r\"}$, $\\texttt{\"e\"}$, or $\\texttt{\"k\"}$ that Narek fails to utilize (note that if Narek fails to complete the last occurrence by finding all of the $5$ letters, then all of the letters he used are counted in ChatGPT's score $score_c$, and Narek doesn't get any points if he doesn't finish finding all the 5 letters).\n\nNarek aims to maximize the value of $score_n - score_c$ by selecting the most optimal subset of the initial strings.\n\nInput: In the first line of the input, you're given a single integer $t$ ($1 \\le t \\le 10^5$), the number of test cases. Then the description of each test case follows.\n\nIn the first line of each test case, you're given two integers $n, m$ ($1 \\le n, m \\le 10^3$), the number of strings and the length of each string.\n\nIn the next $n$ lines, you're given $n$ strings, each having a length of $m$. The strings only contain lowercase letters of the English alphabet.\n\nThe sum of values of $n \\cdot m$ over all test cases does not exceed $10^6$.\n\nOutput: For each test case, output a single integer: the maximal possible value of $score_n - score_c$.\n\nExamples:\ninput:\n4\n5 2\nnn\naa\nrr\nee\nkk\n1 5\nnarek\n1 4\nnare\n5 7\nnrrarek\nnrnekan\nuuuuuuu\nppppppp\nnkarekz\noutput:\n0\n5\n0\n7\n\nNote: In the first test case, one of the optimal answers is when Narek doesn't choose any of the strings, so the answer is $0$. He can alternatively choose all the strings. In this case, the full string becomes \"nnaarreekk\". Narek can choose the first appearances of all letters and add $5$ to the score. His opponent will add $1$ for all second appearances, which will be $5$ in total. So the answer will be $5 - 5 = 0$.\n\nIn the third test case, the only optimal answer is when Narek doesn't choose the string. Note that if he were to choose the string, he wouldn't be able to find the last letter \"k\", so his score would stay at $0$ instead of becoming $5$. Then ChatGPT would add $4$ for all of the $4$ letters, and the answer would become $0 - 4 = -4$.\n\nIn the last test case, Narek needs to choose the first and the last strings. After putting these two next to each other, he gets \"${\\color{red}{n}}rr{\\color{red}{a}}{\\color{red}{r}}{\\color{red}{e}}{\\color{red}{k}}{\\color{red}{n}}k{\\color{red}{a}}{\\color{red}{r}}{\\color{red}{e}}{\\color{red}{k}}{\\color{blue}{z}}$\". Narek can choose the letters marked with red and add $10$ to his score. Since the black colored letters Narek left behind are eligible for the opponent to claim (they are used in the word \"narek\"), the opponent adds all other letters to the score and gets a score of $3$. Therefore, the answer is $10 - 3 = 7$.\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "2005C", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Large Graph\ntime_limit_ms: 4000\nmemory_limit_mb: 512\nDescription: Given an array $a$ of length $n$. Let's construct a square matrix $b$ of size $n \\times n$, in which the $i$-th row contains the array $a$ cyclically shifted to the right by $(i - 1)$. For example, for the array $a = [3, 4, 5]$, the obtained matrix is\n\n$$b = \\begin{bmatrix} 3 & 4 & 5 \\\\\\ 5 & 3 & 4 \\\\\\ 4 & 5 & 3 \\end{bmatrix}$$\n\nLet's construct the following graph:\n\n * The graph contains $n^2$ vertices, each of which corresponds to one of the elements of the matrix. Let's denote the vertex corresponding to the element $b_{i, j}$ as $(i, j)$. * We will draw an edge between vertices $(i_1, j_1)$ and $(i_2, j_2)$ if $|i_1 - i_2| + |j_1 - j_2| \\le k$ and $\\gcd(b_{i_1, j_1}, b_{i_2, j_2}) > 1$, where $\\gcd(x, y)$ denotes the [greatest common divisor](https://en.wikipedia.org/wiki/Greatest_common_divisor) of integers $x$ and $y$. \n\nYour task is to calculate the number of connected components$^{\\dagger}$ in the obtained graph.\n\n$^{\\dagger}$A connected component of a graph is a set of vertices in which any vertex is reachable from any other via edges, and adding any other vertex to the set violates this rule.\n\nInput: Each test consists of multiple test cases. The first line contains a single integer $t$ ($1 \\leq t \\leq 10^5$) β€” the number of test cases. The description of the test cases follows.\n\nThe first line of each test case contains two integers $n$ and $k$ ($2 \\le n \\le 10^6$, $2 \\le k \\le 2 \\cdot 10^6$) β€” the length of the array and the parameter $k$.\n\nThe second line of each test case contains $n$ integers $a_1, a_2, \\ldots, a_n$ ($1 \\le a_i \\le 10^6$) β€” the elements of the array $a$.\n\nIt is guaranteed that the sum of $n$ over all test cases does not exceed $10^6$.\n\nOutput: For each test case, output a single integer β€” the number of connected components in the obtained graph.\n\nExamples:\ninput:\n6\n3 3\n3 4 5\n3 3\n3 4 9\n3 2\n3 4 9\n2 2\n2 8\n5 3\n8 27 5 4 3\n4 10\n2 2 2 2\noutput:\n3\n2\n3\n1\n4\n1\n\nNote: In the first test case, the matrix $b$ is given in the statement. The first connected component contains the vertices $(1, 1)$, $(2, 2)$, and $(3, 3)$. The second connected component contains the vertices $(1, 2)$, $(2, 3)$, and $(3, 1)$. The third connected component contains the vertices $(1, 3)$, $(2, 1)$, and $(3, 2)$. Thus, the graph has $3$ connected components.\n\nIn the second test case, the following matrix is obtained:\n\n$$b = \\begin{bmatrix} 3 & 4 & 9 \\\\\\ 9 & 3 & 4 \\\\\\ 4 & 9 & 3 \\end{bmatrix}$$\n\nThe first connected component contains all vertices corresponding to elements with values $3$ and $9$. The second connected component contains all vertices corresponding to elements with the value $4$.\n\nIn the fourth test case, all vertices are in one connected component.\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "1978F", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Court Blue (Hard Version)\ntime_limit_ms: 4000\nmemory_limit_mb: 512\nDescription: This is the hard version of the problem. In this version, it is not guaranteed that $n=m$, and the time limit is higher. You can make hacks only if both versions of the problem are solved.\n\nIn the court of the Blue King, Lelle and Flamm are having a performance match. The match consists of several rounds. In each round, either Lelle or Flamm wins.\n\nLet $W_L$ and $W_F$ denote the number of wins of Lelle and Flamm, respectively. The Blue King considers a match to be successful if and only if:\n\n * after every round, $\\gcd(W_L,W_F)\\le 1$; * at the end of the match, $W_L\\le n, W_F\\le m$. \n\nNote that $\\gcd(0,x)=\\gcd(x,0)=x$ for every non-negative integer $x$.\n\nLelle and Flamm can decide to stop the match whenever they want, and the final score of the performance is $l \\cdot W_L + f \\cdot W_F$.\n\nPlease help Lelle and Flamm coordinate their wins and losses such that the performance is successful, and the total score of the performance is maximized.\n\nInput: The first line contains an integer $t$ ($1\\leq t \\leq 10^3$) β€” the number of test cases.\n\nThe only line of each test case contains four integers $n$, $m$, $l$, $f$ ($2\\leq n\\leq m \\leq 2\\cdot 10^7$, $1\\leq l,f \\leq 10^9$): $n$, $m$ give the upper bound on the number of Lelle and Flamm's wins, $l$ and $f$ determine the final score of the performance.\n\nUnusual additional constraint: it is guaranteed that, for each test, there are no pairs of test cases with the same pair of $n$, $m$.\n\nOutput: For each test case, output a single integer β€” the maximum total score of a successful performance.\n\nExamples:\ninput:\n8\n3 4 2 5\n4 4 1 4\n6 6 2 2\n7 9 2 3\n8 9 9 1\n2 7 1 4\n5 9 1 4\n5 6 6 7\noutput:\n22\n17\n18\n37\n77\n30\n41\n59\n\ninput:\n2\n3082823 20000000 1341 331\n20000000 20000000 3 5\noutput:\n10754065643\n159999991\n\ninput:\n1\n139 1293 193 412\noutput:\n559543\n\nNote: In the first test case, a possible performance is as follows:\n\n * Flamm wins, $\\gcd(0,1)=1$. * Lelle wins, $\\gcd(1,1)=1$. * Flamm wins, $\\gcd(1,2)=1$. * Flamm wins, $\\gcd(1,3)=1$. * Flamm wins, $\\gcd(1,4)=1$. * Lelle and Flamm agree to stop the match. \n\nThe final score is $1\\cdot2+4\\cdot5=22$.\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "2002F2", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Anya and 1100\ntime_limit_ms: 3000\nmemory_limit_mb: 256\nDescription: While rummaging through things in a distant drawer, Anya found a beautiful string $s$ consisting only of zeros and ones.\n\nNow she wants to make it even more beautiful by performing $q$ operations on it.\n\nEach operation is described by two integers $i$ ($1 \\le i \\le |s|$) and $v$ ($v \\in \\\\{0, 1\\\\}$) and means that the $i$-th character of the string is assigned the value $v$ (that is, the assignment $s_i = v$ is performed).\n\nBut Anya loves the number $1100$, so after each query, she asks you to tell her whether the substring \"1100\" is present in her string (i.e. there exist such $1 \\le i \\le |s| - 3$ that $s_{i}s_{i + 1}s_{i + 2}s_{i + 3} = \\texttt{1100}$).\n\nInput: The first line contains one integer $t$ ($1 \\leq t \\leq 10^4$) β€” the number of test cases.\n\nThe first line of the test case contains the string $s$ ($1 \\leq |s| \\leq 2 \\cdot 10^5$), consisting only of the characters \"0\" and \"1\". Here $|s|$ denotes the length of the string $s$.\n\nThe next line contains an integer $q$ ($1 \\leq q \\leq 2 \\cdot 10^5$) β€” the number of queries.\n\nThe following $q$ lines contain two integers $i$ ($1 \\leq i \\leq |s|$) and $v$ ($v \\in \\\\{0, 1\\\\}$), describing the query.\n\nIt is guaranteed that the sum of $|s|$ across all test cases does not exceed $2 \\cdot 10^5$. It is also guaranteed that the sum of $q$ across all test cases does not exceed $2 \\cdot 10^5$.\n\nOutput: For each query, output \"YES\", if \"1100\" is present in Anya's string; otherwise, output \"NO\".\n\nYou can output the answer in any case (upper or lower). For example, the strings \"yEs\", \"yes\", \"Yes\", and \"YES\" will be recognized as positive responses.\n\nExamples:\ninput:\n4\n100\n4\n1 1\n2 0\n2 0\n3 1\n1100000\n3\n6 1\n7 1\n4 1\n111010\n4\n1 1\n5 0\n4 1\n5 0\n0100\n4\n3 1\n1 1\n2 0\n2 1\noutput:\nNO\nNO\nNO\nNO\nYES\nYES\nNO\nNO\nYES\nYES\nYES\nNO\nNO\nNO\nNO\n\nNote: \n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "2036C", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Alice's Adventures in Cutting Cake\ntime_limit_ms: 2000\nmemory_limit_mb: 256\nDescription: Alice is at the Mad Hatter's tea party! There is a long sheet cake made up of $n$ sections with tastiness values $a_1, a_2, \\ldots, a_n$. There are $m$ creatures at the tea party, excluding Alice.\n\nAlice will cut the cake into $m + 1$ pieces. Formally, she will partition the cake into $m + 1$ subarrays, where each subarray consists of some number of adjacent sections. The tastiness of a piece is the sum of tastiness of its sections. Afterwards, she will divvy these $m + 1$ pieces up among the $m$ creatures and herself (her piece can be empty). However, each of the $m$ creatures will only be happy when the tastiness of its piece is $v$ or more.\n\nAlice wants to make sure every creature is happy. Limited by this condition, she also wants to maximize the tastiness of her own piece. Can you help Alice find the maximum tastiness her piece can have? If there is no way to make sure every creature is happy, output $-1$.\n\nInput: Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \\le t \\le 10^4$). The description of the test cases follows.\n\nThe first line of each test case contains three integers $n, m, v$ ($1\\le m\\le n\\le 2\\cdot 10^5$; $1\\le v\\le 10^9$) β€” the number of sections, the number of creatures, and the creatures' minimum requirement for tastiness, respectively.\n\nThe next line contains $n$ space separated integers $a_1, a_2, \\ldots, a_n$ ($1 \\le a_i \\le 10^9$) β€” the tastinesses of the sections.\n\nThe sum of $n$ over all test cases does not exceed $2\\cdot 10^5$.\n\nOutput: For each test case, output the maximum tastiness Alice can achieve for her piece, or $-1$ if there is no way to make sure every creature is happy.\n\nExamples:\ninput:\n7\n6 2 1\n1 1 10 1 1 10\n6 2 2\n1 1 10 1 1 10\n6 2 3\n1 1 10 1 1 10\n6 2 10\n1 1 10 1 1 10\n6 2 11\n1 1 10 1 1 10\n6 2 12\n1 1 10 1 1 10\n6 2 12\n1 1 1 1 10 10\noutput:\n22\n12\n2\n2\n2\n0\n-1\n\nNote: For the first test case, Alice can give the first and second section as their own pieces, and then take the remaining $10 + 1 + 1 + 10 = 22$ tastiness for herself. We can show that she cannot do any better.\n\nFor the second test case, Alice could give the first and second section as one piece, and the sixth section as one piece. She can then take the remaining $10 + 1 + 1 = 12$ tastiness for herself. We can show that she cannot do any better.\n\nFor the seventh test case, Alice cannot give each creature a piece of at least $12$ tastiness.\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "2028C", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Robin Helps\ntime_limit_ms: 1000\nmemory_limit_mb: 256\nDescription: There is a little bit of the outlaw in everyone, and a little bit of the hero too.\n\nThe heroic outlaw Robin Hood is famous for taking from the rich and giving to the poor.\n\nRobin encounters $n$ people starting from the $1$-st and ending with the $n$-th. The $i$-th person has $a_i$ gold. If $a_i \\ge k$, Robin will take all $a_i$ gold, and if $a_i=0$, Robin will give $1$ gold if he has any. Robin starts with $0$ gold.\n\nFind out how many people Robin gives gold to.\n\nInput: The first line of the input contains a single integer $t$ ($1\\leq t \\leq 10^4$) β€” the number of test cases.\n\nThe first line of each test case contains two integers $n$, $k$ ($1 \\le n \\le 50, 1 \\le k \\le 100$) β€” the number of people and the threshold at which Robin Hood takes the gold.\n\nThe second line of each test case contains $n$ integers $a_1, a_2, \\ldots, a_n$ ($0 \\le a_i \\le 100$) β€” the gold of each person.\n\nOutput: For each test case, output a single integer, the number of people that will get gold from Robin Hood.\n\nExamples:\ninput:\n4\n2 2\n2 0\n3 2\n3 0 0\n6 2\n0 3 0 0 0 0\n2 5\n5 4\noutput:\n1\n2\n3\n0\n\nNote: In the first test case, Robin takes $2$ gold from the first person and gives a gold to the second person.\n\nIn the second test case, Robin takes $3$ gold and gives $1$ gold to each of the next $2$ people.\n\nIn the third test case, Robin takes $3$ gold and so only gives gold to $3$ other people.\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "2014A", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Determine Winning Islands in Race\ntime_limit_ms: 2000\nmemory_limit_mb: 256\nDescription: MOOOOOOOOOOOOOOOOO\n\nβ€” Bessie the Cow, The Art of Racing on Islands\n\nTwo of Farmer John's cows, Bessie and Elsie, are planning to race on $n$ islands. There are $n - 1$ main bridges, connecting island $i$ to island $i + 1$ for all $1 \\leq i \\leq n - 1$. Additionally, there are $m$ alternative bridges. Elsie can use both main and alternative bridges, while Bessie can only use main bridges. All bridges are one way and can only be used to travel from an island with a lower index to an island with a higher index.\n\nInitially, Elsie starts on island $1$, and Bessie starts on island $s$. The cows alternate turns, with Bessie making the first turn. Suppose the cow is on island $i$. During a cow's turn, if there are any bridges connecting island $i$ to island $j$, then the cow can move to island $j$. Then, island $i$ collapses, and all bridges connecting to island $i$ also collapse. Also, note the following:\n\n * If there are no bridges connecting island $i$ to another island, then island $i$ collapses, and this cow is eliminated from the race. * If the other cow is also on island $i$, then after this cow moves to another island, the island collapses, and the other cow is eliminated from the race. * After an island or bridge collapses, no cows may use them. * If a cow is eliminated, their turn is skipped for the rest of the race. \n\nThe race ends once either cow reaches island $n$. It can be shown that regardless of the cows' strategies, at least one cow reaches island $n$. Bessie wins if and only if she reaches island $n$ first.\n\nFor each $1 \\leq s \\leq n - 1$, determine whether Bessie wins if she starts the race on island $s$. Assume both cows follow optimal strategies to ensure their own respective victories.\n\nInput: The first line contains $t$ ($1 \\leq t \\leq 10^4$) – the number of test cases.\n\nThe first line of each test case contains $n$ and $m$ ($2 \\leq n \\leq 2 \\cdot 10^5$, $0 \\leq m \\leq 2 \\cdot 10^5$) – the number of islands and the number of alternative bridges.\n\nThe next $m$ lines of each test case contain $u$ and $v$ ($1 \\leq u < v \\leq n$) – the islands that the alternative bridge connects. It is guaranteed all alternative bridges are distinct, and they do not coincide with the main bridges.\n\nIt is guaranteed that neither the sum of $n$ nor the sum of $m$ over all test cases exceeds $2 \\cdot 10^5$.\n\nOutput: For each test case, output a binary string of length $n - 1$ on a new line. The $i$'th character is $1$ if it is possible for Bessie to win if she starts on island $i$. Otherwise, it is $0$.\n\nExamples:\ninput:\n5\n6 0\n6 1\n2 6\n6 1\n1 5\n10 4\n1 3\n1 6\n2 7\n3 8\n15 3\n2 8\n4 9\n8 15\noutput:\n11111\n11011\n10011\n100001111\n11000111000111\n\nNote: In the first test case, there are no alternative bridges for Elsie to overtake Bessie and reach island $n$ first, so Bessie will win on all islands because she always moves first.\n\nIn the second case, Bessie will lose if she starts on island $3$ because:\n\n * Bessie's Turn: Take a main bridge from island $3$ to island $4$. * Elsie's Turn: Take a main bridge from island $1$ to island $2$. * Bessie's Turn: Take a main bridge from island $4$ to island $5$. * Elsie's Turn: Take an alternative bridge from island $2$ to island $6$. Elsie reaches island $n$ first.\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "1998D", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Matrix Stabilization\ntime_limit_ms: 2000\nmemory_limit_mb: 256\nDescription: You are given a matrix of size $n \\times m$, where the rows are numbered from $1$ to $n$ from top to bottom, and the columns are numbered from $1$ to $m$ from left to right. The element at the intersection of the $i$-th row and the $j$-th column is denoted by $a_{ij}$.\n\nConsider the algorithm for stabilizing matrix $a$:\n\n 1. Find the cell $(i, j)$ such that its value is strictly greater than the values of all its neighboring cells. If there is no such cell, terminate the algorithm. If there are multiple such cells, choose the cell with the smallest value of $i$, and if there are still multiple cells, choose the one with the smallest value of $j$. 2. Set $a_{ij} = a_{ij} - 1$. 3. Go to step $1$. \n\nIn this problem, cells $(a, b)$ and $(c, d)$ are considered neighbors if they share a common side, i.e., $|a - c| + |b - d| = 1$.\n\nYour task is to output the matrix $a$ after the stabilization algorithm has been executed. It can be shown that this algorithm cannot run for an infinite number of iterations.\n\nInput: Each test consists of multiple sets of input data. The first line contains a single integer $t$ ($1 \\leq t \\leq 10^4$) β€” the number of sets of input data. This is followed by their description.\n\nThe first line of each set of input data contains two integers $n$ and $m$ ($1 \\leq n, m \\leq 100, n \\cdot m > 1$) β€” the number of rows and columns of matrix $a$.\n\nThe next $n$ lines describe the corresponding rows of the matrix. The $i$-th line contains $m$ integers $a_{i1}, a_{i2}, \\ldots, a_{im}$ ($1 \\leq a_{ij} \\leq 10^9$).\n\nIt is guaranteed that the sum of $n \\cdot m$ over all sets of input data does not exceed $2 \\cdot 10^5$.\n\nOutput: For each set of input data, output $n$ lines with $m$ numbers in each line β€” the values of the cells of matrix $a$ after the stabilization algorithm.\n\nExamples:\ninput:\n6\n1 2\n3 1\n2 1\n1\n1\n2 2\n1 2\n3 4\n2 3\n7 4 5\n1 8 10\n5 4\n92 74 31 74\n74 92 17 7\n31 17 92 3\n74 7 3 92\n7 31 1 1\n3 3\n1000000000 1 1000000000\n1 1000000000 1\n1000000000 1 1000000000\noutput:\n1 1 \n1 \n1 \n1 2 \n3 3 \n4 4 5 \n1 8 8 \n74 74 31 31 \n74 74 17 7 \n31 17 17 3 \n31 7 3 3 \n7 7 1 1 \n1 1 1 \n1 1 1 \n1 1 1\n\nNote: In the first set of input data, the algorithm will select the cell $(1, 1)$ twice in a row and then terminate.\n\n![](CDN_BASE_URL/ce7b57ad25f59927de6d90880ce5a2ba)\n\nIn the second set of input data, there is no cell whose value is strictly greater than the values of all neighboring cells.\n\nIn the third set of input data, the algorithm will select the cell $(2, 2)$ and then terminate.\n\n![](CDN_BASE_URL/e6f79376ac190defeb9657662c825d80)\n\nIn the fourth set of input data, the algorithm will select the cell $(1, 1)$ three times and then the cell $(2, 3)$ twice.\n\n![](CDN_BASE_URL/7651bb6af57f6669236e3dd32a7c1293)\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "1986B", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Wooden Game\ntime_limit_ms: 2000\nmemory_limit_mb: 256\nDescription: You are given a forest of $k$ rooted trees$^{\\text{βˆ—}}$. Lumberjack Timofey wants to cut down the entire forest by applying the following operation:\n\n * Select a subtree$^{\\text{†}}$ of any vertex of one of the trees and remove it from the tree. \n\nTimofey loves bitwise operations, so he wants the [bitwise OR](https://en.wikipedia.org/wiki/Bitwise_operation#OR) of the sizes of the subtrees he removed to be maximum. Help him and find the maximum result he can obtain.\n\n$^{\\text{βˆ—}}$ A tree is a connected graph without cycles, loops, or multiple edges. In a rooted tree, a selected vertex is called a root. A forest is a collection of one or more trees.\n\n$^{\\text{†}}$ The subtree of a vertex $v$ is the set of vertices for which $v$ lies on the shortest path from this vertex to the root, including $v$ itself.\n\nInput: Each test consists of multiple test cases. The first line contains an integer $t$ ($1 \\leq t \\leq 10^4$) β€” the number of test cases. Then follows the description of the test cases.\n\nThe first line of each test case contains a single integer $k$ ($1 \\leq k \\leq 10^6$) β€” the number of trees in the forest.\n\nThis is followed by a description of each of the $k$ trees:\n\nThe first line contains a single integer $n$ ($1 \\leq n \\leq 10^6$) β€” the size of the tree. The vertices of the tree are numbered with integers from $1$ to $n$. The root of the tree is vertex number $1$.\n\nThe second line contains $n - 1$ integers $p_2, p_3, \\ldots p_n$ ($1 \\leq p_i < i$), where $p_i$ β€” the parent of vertex $i$.\n\nIt is guaranteed that the sum of $k$ and $n$ for all sets of input data does not exceed $10^6$.\n\nOutput: For each test case, output a single integer β€” the maximum result that can be obtained.\n\nExamples:\ninput:\n3\n1\n1\n\n\n2\n4\n1 2 2\n6\n1 1 3 1 3\n1\n10\n1 2 2 1 1 5 7 6 4\noutput:\n1\n7\n10\n\nNote: In the second test case, the trees look like this:\n\n![](CDN_BASE_URL/149fbfb0b4a0bcf29a8a6b8b997b79b2)\n\nThe first operation removes the entire second tree.\n\n![](CDN_BASE_URL/3a1651525e7c5087a7d88d51824c16d6)\n\nThe second operation removes vertex $4$ from the first tree.\n\n![](CDN_BASE_URL/c5e219384aa686ba75274781503be59f)\n\nThe third operation removes the first tree. The result is $6|1|3 = 7$ ($|$ denotes bitwise OR).\n\nIn the third test case, the entire tree needs to be removed.\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "1994E", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Sakurako's Hobby\ntime_limit_ms: 2000\nmemory_limit_mb: 256\nDescription: For a certain permutation $p$$^{\\text{βˆ—}}$ Sakurako calls an integer $j$ reachable from an integer $i$ if it is possible to make $i$ equal to $j$ by assigning $i=p_i$ a certain number of times.\n\nIf $p=[3,5,6,1,2,4]$, then, for example, $4$ is reachable from $1$, because: $i=1$ $\\rightarrow$ $i=p_1=3$ $\\rightarrow$ $i=p_3=6$ $\\rightarrow$ $i=p_6=4$. Now $i=4$, so $4$ is reachable from $1$.\n\nEach number in the permutation is colored either black or white.\n\nSakurako defines the function $F(i)$ as the number of black integers that are reachable from $i$.\n\nSakurako is interested in $F(i)$ for each $1\\le i\\le n$, but calculating all values becomes very difficult, so she asks you, as her good friend, to compute this.\n\n$^{\\text{βˆ—}}$A permutation of length $n$ is an array consisting of $n$ distinct integers from $1$ to $n$ in arbitrary order. For example, $[2,3,1,5,4]$ is a permutation, but $[1,2,2]$ is not a permutation (the number $2$ appears twice in the array), and $[1,3,4]$ is also not a permutation ($n=3$, but the array contains $4$).\n\nInput: The first line contains a single integer $t$ ($1\\le t\\le 10^4$) β€” the number of test cases.\n\nThe first line of each test case contains a single integer $n$ ($1\\le n\\le 2\\cdot 10^5$) β€” the number of elements in the array.\n\nThe second line of each test case contains $n$ integers $p_1, p_2, \\dots, p_n$ ($1\\le p_i\\le n$) β€” the elements of the permutation.\n\nThe third line of each test case contains a string $s$ of length $n$, consisting of '0' and '1'. If $s_i=0$, then the number $p_i$ is colored black; if $s_i=1$, then the number $p_i$ is colored white.\n\nIt is guaranteed that the sum of $n$ across all test cases does not exceed $2\\cdot 10^5$.\n\nOutput: For each test case, output $n$ integers $F(1), F(2), \\dots, F(n)$.\n\nExamples:\ninput:\n5\n1\n1\n0\n5\n1 2 4 5 3\n10101\n5\n5 4 1 3 2\n10011\n6\n3 5 6 1 2 4\n010000\n6\n1 2 3 4 5 6\n100110\noutput:\n1 \n0 1 1 1 1 \n2 2 2 2 2 \n4 1 4 4 1 4 \n0 1 1 0 0 1\n\nNote: \n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "2008D", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Buying Lemonade\ntime_limit_ms: 1000\nmemory_limit_mb: 256\nDescription: There is a vending machine that sells lemonade. The machine has a total of $n$ slots. You know that initially, the $i$-th slot contains $a_i$ cans of lemonade. There are also $n$ buttons on the machine, each button corresponds to a slot, with exactly one button corresponding to each slot. Unfortunately, the labels on the buttons have worn off, so you do not know which button corresponds to which slot.\n\nWhen you press the button corresponding to the $i$-th slot, one of two events occurs:\n\n * If there is a can of lemonade in the $i$-th slot, it will drop out and you will take it. At this point, the number of cans in the $i$-th slot decreases by $1$. * If there are no cans of lemonade left in the $i$-th slot, nothing will drop out. \n\nAfter pressing, the can drops out so quickly that it is impossible to track from which slot it fell. The contents of the slots are hidden from your view, so you cannot see how many cans are left in each slot. The only thing you know is the initial number of cans in the slots: $a_1, a_2, \\ldots, a_n$.\n\nDetermine the minimum number of button presses needed to guarantee that you receive at least $k$ cans of lemonade.\n\nNote that you can adapt your strategy during the button presses based on whether you received a can or not. It is guaranteed that there are at least $k$ cans of lemonade in total in the machine. In other words, $k \\leq a_1 + a_2 + \\ldots + a_n$.\n\nInput: Each test consists of multiple test cases. The first line contains a single integer $t$ ($1 \\le t \\le 10^4$) β€” the number of test cases. The description of the test cases follows.\n\nThe first line of each test case contains two integers $n$ and $k$ ($1 \\le n \\le 2 \\cdot 10^5$, $1 \\leq k \\leq 10^9$) β€” the number of slots in the machine and the required number of cans of lemonade.\n\nThe second line of each test case contains $n$ integers $a_1, a_2, \\ldots, a_n$ ($1 \\le a_i \\le 10^9$) β€” the number of cans in the slots.\n\nIt is guaranteed that $k \\leq a_1 + a_2 + \\ldots + a_n$, meaning there are at least $k$ cans of lemonade in the machine.\n\nIt is guaranteed that the sum of $n$ over all test cases does not exceed $2 \\cdot 10^5$.\n\nOutput: For each test case, output a single integer β€” the minimum number of button presses needed to guarantee that you receive at least $k$ cans of lemonade.\n\nExamples:\ninput:\n5\n2 1\n1 1\n2 2\n1 2\n3 4\n2 1 3\n10 50\n1 1 3 8 8 9 12 13 27 27\n2 1000000000\n1000000000 500000000\noutput:\n1\n2\n5\n53\n1000000000\n\nNote: In the first test case, we can simply press the first button and receive one can of lemonade.\n\nIn the second test case, we can press each button once and guarantee that we receive $2$ cans of lemonade. Note that if we simply press one button twice, we might not be lucky, and that button could correspond to the first slot, in which case we would only receive $1$ can of lemonade for two presses.\n\nIn the third test case, one of the optimal strategies is as follows:\n\nPress the first button twice. After the first press, a can of lemonade will definitely drop out. Then there are two options:\n\n * If no can of lemonade drops after the second press, we know that this button must correspond to the second slot, since $a_2 = 1$ and $a_1, a_3 > 1$. Then we can press the second button twice and the third button once. Since $a_1, a_3 \\geq 2$, we will definitely receive three cans of lemonade for these three presses. Thus, after $5$ presses, we will have $4$ cans of lemonade. * If a can of lemonade drops after the second press, we can make one press on the second button and one press on the third button. After each of these presses, we will definitely receive a can of lemonade. Thus, after $4$ presses, we will have $4$ cans of lemonade.\n\nIt can be shown that it is impossible to guarantee receiving $4$ cans of lemonade with only $4$ presses, so the answer is $5$.\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "2024B", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Phone Desktop\ntime_limit_ms: 1000\nmemory_limit_mb: 256\nDescription: Little Rosie has a phone with a desktop (or launcher, as it is also called). The desktop can consist of several screens. Each screen is represented as a grid of size $5 \\times 3$, i.e., five rows and three columns.\n\nThere are $x$ applications with an icon size of $1 \\times 1$ cells; such an icon occupies only one cell of the screen. There are also $y$ applications with an icon size of $2 \\times 2$ cells; such an icon occupies a square of $4$ cells on the screen. Each cell of each screen can be occupied by no more than one icon.\n\nRosie wants to place the application icons on the minimum number of screens. Help her find the minimum number of screens needed.\n\nInput: The first line of the input contains $t$ ($1 \\leq t \\leq 10^4$) β€” the number of test cases.\n\nThe first and only line of each test case contains two integers $x$ and $y$ ($0 \\leq x, y \\leq 99$) β€” the number of applications with a $1 \\times 1$ icon and the number of applications with a $2 \\times 2$ icon, respectively.\n\nOutput: For each test case, output the minimal number of required screens on a separate line.\n\nExamples:\ninput:\n11\n1 1\n7 2\n12 4\n0 3\n1 0\n8 1\n0 0\n2 0\n15 0\n8 2\n0 9\noutput:\n1\n1\n2\n2\n1\n1\n0\n1\n1\n2\n5\n\nNote: The solution for the first test case can look as follows:\n\n![](CDN_BASE_URL/c1f8e47d264264fb303b101863bef14b) Blue squares represent empty spaces for icons, green squares represent $1 \\times 1$ icons, red squares represent $2 \\times 2$ icons\n\nThe solution for the third test case can look as follows:\n\n![](CDN_BASE_URL/05b392e954bd162bfc00b3f026bcba0d)\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "1974A", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Soccer\ntime_limit_ms: 1000\nmemory_limit_mb: 256\nDescription: Dima loves watching soccer. In such a game, the score on the scoreboard is represented as $x$ : $y$, where $x$ is the number of goals of the first team, and $y$ is the number of goals of the second team. At any given time, only one team can score a goal, so the score $x$ : $y$ can change to either $(x + 1)$ : $y$, or $x$ : $(y + 1)$.\n\nWhile watching a soccer game, Dima was distracted by very important matters, and after some time, he returned to watching the game. Dima remembers the score right before he was distracted, and the score right after he returned. Given these two scores, he wonders the following question. Is it possible that, while Dima was not watching the game, the teams never had an equal score?\n\nIt is guaranteed that at neither of the two time points Dima remembers the teams had equal scores. However, it is possible that the score did not change during his absence.\n\nHelp Dima and answer the question!\n\nInput: Each test consists of several test cases. The first line contains an integer $t$ ($1 \\le t \\le 10^{4}$) β€” the number of test cases. Then follows the description of the test cases.\n\nThe first line of each test case contains two integers $x_{1}, y_{1}$ ($0 \\le x_{1}, y_{1} \\le 10^{9}$, $x_{1} \\neq y_{1}$) β€” the score before Dima was distracted.\n\nThe second line of each test case contains two integers $x_{2}, y_{2}$ ($x_{1} \\le x_{2} \\le 10^{9}$, $y_{1} \\le y_{2} \\le 10^{9}$, $x_{2} \\neq y_{2}$) β€” the score when Dima returned.\n\nOutput: For each test case, output \"YES\" without quotes if it is possible, that the teams never had a tie while Dima was away, otherwise output \"NO\" without quotes.\n\nYou can output each letter in any case (for example, the strings \"yEs\", \"yes\", \"Yes\", and \"YES\" will be recognized as a positive answer).\n\nExamples:\ninput:\n6\n1 0\n5 0\n1 2\n3 2\n1 2\n4 5\n1 2\n4 3\n1 2\n1 2\n998244353 0\n1000000000 999999999\noutput:\nYES\nNO\nYES\nNO\nYES\nYES\n\nNote: In the first test case, the score before Dima left was $1$ : $0$. When he leaves, the first team scores several goals in a row until the score becomes $5$ : $0$, so the answer is YES.\n\nIn the second test case, the score could only change as follows:\n\n * $1$ : $2$ * $2$ : $2$ * $3$ : $2$ \n\nIn this scenario, there is a moment when the teams have an equal score, so the answer is NO.\n\nIn the third test case, one of the possible developments is:\n\n * $1$ : $2$ * $1$ : $3$ * $2$ : $3$ * $2$ : $4$ * $2$ : $5$ * $3$ : $5$ * $4$ : $5$ \n\nIn this scenario, there was no time when the score was equal, so the answer is YES.\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "1982A", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Sakurako's Field Trip\ntime_limit_ms: 2000\nmemory_limit_mb: 256\nDescription: Even in university, students need to relax. That is why Sakurakos teacher decided to go on a field trip. It is known that all of the students will be walking in one line. The student with index $i$ has some topic of interest which is described as $a_i$. As a teacher, you want to minimise the disturbance of the line of students.\n\nThe disturbance of the line is defined as the number of neighbouring people with the same topic of interest. In other words, disturbance is the number of indices $j$ ($1 \\le j < n$) such that $a_j = a_{j + 1}$.\n\nIn order to do this, you can choose index $i$ ($1\\le i\\le n$) and swap students at positions $i$ and $n-i+1$. You can perform any number of swaps.\n\nYour task is to determine the minimal amount of disturbance that you can achieve by doing the operation described above any number of times.\n\nInput: The first line contains one integer $t$ ($1\\le t\\le 10^4$) β€” the number of test cases.\n\nEach test case is described by two lines.\n\n * The first line contains one integer $n$ ($2 \\le n \\le 10^5$) β€” the length of the line of students. * The second line contains $n$ integers $a_i$ ($1\\le a_i\\le n$) β€” the topics of interest of students in line. \n\nIt is guaranteed that the sum of $n$ across all test cases does not exceed $2\\cdot 10^5$.\n\nOutput: For each test case, output the minimal possible disturbance of the line that you can achieve.\n\nExamples:\ninput:\n9\n5\n1 1 1 2 3\n6\n2 1 2 2 1 1\n4\n1 2 1 1\n6\n2 1 1 2 2 4\n4\n2 1 2 3\n6\n1 2 2 1 2 1\n5\n4 5 5 1 5\n7\n1 4 3 5 1 1 3\n7\n3 1 3 2 2 3 3\noutput:\n1\n2\n1\n0\n0\n1\n1\n0\n2\n\nNote: In the first example, it is necessary to apply the operation to $i=2$, thus the array will become $[1, \\textbf{2}, 1, \\textbf{1}, 3]$, with the bold elements indicating those that have swapped places. The disturbance of this array is equal to $1$.\n\nIn the fourth example, it is sufficient to apply the operation to $i=3$, thus the array will become $[2, 1, \\textbf{2}, \\textbf{1}, 2, 4]$. The disturbance of this array is equal to $0$.\n\nIn the eighth example, it is sufficient to apply the operation to $i=3$, thus the array will become $[1, 4, \\textbf{1}, 5, \\textbf{3}, 1, 3]$. The disturbance of this array is equal to $0$.\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "2033C", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Prefix GCD\ntime_limit_ms: 2000\nmemory_limit_mb: 256\nDescription: Since Mansur is tired of making legends, there will be no legends for this task.\n\nYou are given an array of positive integer numbers $a_1, a_2, \\ldots, a_n$. The elements of the array can be rearranged in any order. You need to find the smallest possible value of the expression $$\\gcd(a_1) + \\gcd(a_1, a_2) + \\ldots + \\gcd(a_1, a_2, \\ldots, a_n),$$ where $\\gcd(a_1, a_2, \\ldots, a_n)$ denotes the [greatest common divisor (GCD)](https://en.wikipedia.org/wiki/Greatest_common_divisor) of $a_1, a_2, \\ldots, a_n$.\n\nInput: Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \\le t \\le 10^4$). The description of the test cases follows.\n\nThe first line of each test case contains a single number $n$ ($1 \\le n \\le 10^5$) β€” the size of the array.\n\nThe second line of each test case contains $n$ numbers $a_1, a_2, \\ldots, a_n$ ($1 \\le a_i \\le 10^5$) β€” the initial array.\n\nThe sum of $n$ over all test cases does not exceed $10^5$.\n\nThe sum of $\\max(a_1, a_2, \\ldots, a_n)$ over all test cases does not exceed $10^5$.\n\nOutput: For each test case, output a single number on a separate line β€” the answer to the problem.\n\nExamples:\ninput:\n5\n3\n4 2 2\n2\n6 3\n3\n10 15 6\n5\n6 42 12 52 20\n4\n42 154 231 66\noutput:\n6\n6\n9\n14\n51\n\nNote: In the first test case, the elements can be rearranged as follows: $[2, 4, 2]$. Then the answer will be $\\gcd(2) + \\gcd(2, 4) + \\gcd(2, 4, 2) = 2 + 2 + 2 = 6$.\n\nIn the third test case, the elements can be rearranged as follows: $[6, 10, 15]$. Then the answer will be $\\gcd(6) + \\gcd(6, 10) + \\gcd(6, 10, 15) = 6 + 2 + 1 = 9$.\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "2013E", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Milky Days\ntime_limit_ms: 2000\nmemory_limit_mb: 256\nDescription: What is done is done, and the spoilt milk cannot be helped.\n\nLittle John is as little as night is day β€” he was known to be a giant, at possibly $2.1$ metres tall. It has everything to do with his love for milk.\n\nHis dairy diary has $n$ entries, showing that he acquired $a_i$ pints of fresh milk on day $d_i$. Milk declines in freshness with time and stays drinkable for a maximum of $k$ days. In other words, fresh milk acquired on day $d_i$ will be drinkable between days $d_i$ and $d_i+k-1$ inclusive.\n\nEvery day, Little John drinks drinkable milk, up to a maximum of $m$ pints. In other words, if there are less than $m$ pints of milk, he will drink them all and not be satisfied; if there are at least $m$ pints of milk, he will drink exactly $m$ pints and be satisfied, and it's a milk satisfaction day.\n\nLittle John always drinks the freshest drinkable milk first.\n\nDetermine the number of milk satisfaction days for Little John.\n\nInput: The first line of the input contains a single integer $t$ ($1\\leq t \\leq 10^4$), the number of test cases.\n\nThe first line of each test case consists of three integers $n$, $m$, $k$ ($1\\le n$, $m$, $k \\le 10^5$), the number of diary entries, the maximum pints needed for a milk satisfaction day, and the duration of milk's freshness.\n\nThen follow $n$ lines of each test case, each with two integers $d_i$ and $a_i$ ($1\\le d_i$, $a_i \\le 10^6$), the day on which the milk was acquired and the number of pints acquired. They are sorted in increasing values of $d_i$, and all values of $d_i$ are distinct.\n\nIt is guaranteed that the sum of $n$ over all test cases does not exceed $2 \\cdot 10^5$.\n\nOutput: For each test case, output a single integer, the number of milk satisfaction days.\n\nExamples:\ninput:\n6\n1 1 3\n1 5\n2 3 3\n1 5\n2 7\n4 5 2\n1 9\n2 6\n4 9\n5 6\n5 2 4\n4 7\n5 3\n7 1\n11 2\n12 1\n4 1 3\n5 10\n9 4\n14 8\n15 3\n5 5 5\n8 9\n10 7\n16 10\n21 5\n28 9\noutput:\n3\n3\n4\n5\n10\n6\n\nNote: In the first test case, $5$ pints of milk are good for $3$ days before spoiling.\n\nIn the second test case, the following will happen:\n\n * On day $1$, he will receive $5$ pints of milk and drink $3$ of them (leaving $2$ pints from day $1$); * On day $2$, he will receive $7$ pints of milk and drink $3$ of them (leaving $2$ pints from day $1$ and $4$ pints from day $2$); * On day $3$, he will drink $3$ pints from day $2$ (leaving $2$ pints from day $1$ and $1$ pint from day $2$); * On day $4$, the milk acquired on day $1$ will spoil, and he will drink $1$ pint from day $2$ (no more milk is left).\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "2014G", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Chamo and Mocha's Array\ntime_limit_ms: 2000\nmemory_limit_mb: 256\nDescription: Mocha likes arrays, so before her departure, Chamo gave her an array $a$ consisting of $n$ positive integers as a gift.\n\nMocha doesn't like arrays containing different numbers, so Mocha decides to use magic to change the array. Mocha can perform the following three-step operation some (possibly, zero) times:\n\n 1. Choose indices $l$ and $r$ ($1 \\leq l < r \\leq n$) 2. Let $x$ be the median$^\\dagger$ of the subarray $[a_l, a_{l+1},\\ldots, a_r]$ 3. Set all values $a_l, a_{l+1},\\ldots, a_r$ to $x$ \n\nSuppose $a=[1,2,3,4,5]$ initially:\n\n * If Mocha chooses $(l,r)=(3,4)$ in the first operation, then $x=3$, the array will be changed into $a=[1,2,3,3,5]$. * If Mocha chooses $(l,r)=(1,3)$ in the first operation, then $x=2$, the array will be changed into $a=[2,2,2,4,5]$. \n\nMocha will perform the operation until the array contains only the same number. Mocha wants to know what is the maximum possible value of this number.\n\n$^\\dagger$ The median in an array $b$ of length $m$ is an element that occupies position number $\\lfloor \\frac{m+1}{2} \\rfloor$ after we sort the elements in non-decreasing order. For example, the median of $[3,1,4,1,5]$ is $3$ and the median of $[5,25,20,24]$ is $20$.\n\nInput: Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1\\leq t\\leq 500$). The description of the test cases follows.\n\nThe first line of each test case contains a single integer $n$ ($2\\leq n\\leq 10^5$) β€” the length of the array $a$.\n\nThe second line of each test case contains $n$ integers $a_1,a_2,\\ldots,a_n$ ($1\\leq a_i \\leq 10^9$) β€” the elements of the array $a$.\n\nIt is guaranteed that the sum of $n$ over all test cases does not exceed $10^5$.\n\nOutput: For each test case, output the maximum value of the number.\n\nExamples:\ninput:\n2\n2\n1 2\n5\n1 2 3 4 5\noutput:\n1\n4\n\nNote: In the first test case, $a=[1,2]$. Mocha can only choose the interval $(l,r)=(1,2)$. The array will be changed to $a=[1,1]$. Therefore, the answer is $1$.\n\nIn the second test case, Mocha can perform the following operations:\n\n * Choose the interval $(l,r)=(4,5)$, then $a=[1,2,3,4,4]$. * Choose the interval $(l,r)=(3,5)$, then $a=[1,2,4,4,4]$. * Choose the interval $(l,r)=(1,5)$, then $a=[4,4,4,4,4]$. \n\nThe array contains only the same number, which is $4$. It can be proven that the maximum value of the final number cannot be greater than $4$.\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "1975C", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Longest Good Array\ntime_limit_ms: 2000\nmemory_limit_mb: 256\nDescription: Today, Sakurako was studying arrays. An array $a$ of length $n$ is considered good if and only if:\n\n * the array $a$ is increasing, meaning $a_{i - 1} < a_i$ for all $2 \\le i \\le n$; * the differences between adjacent elements are increasing, meaning $a_i - a_{i-1} < a_{i+1} - a_i$ for all $2 \\le i < n$. \n\nSakurako has come up with boundaries $l$ and $r$ and wants to construct a good array of maximum length, where $l \\le a_i \\le r$ for all $a_i$.\n\nHelp Sakurako find the maximum length of a good array for the given $l$ and $r$.\n\nInput: The first line contains a single integer $t$ ($1\\le t\\le 10^4$) β€” the number of test cases.\n\nThe only line of each test case contains two integers $l$ and $r$ ($1\\le l\\le r\\le 10^9$).\n\nOutput: For each test case, output a single integer β€” the length of the longest good array Sakurako can form given $l$ and $r$.\n\nExamples:\ninput:\n5\n1 2\n1 5\n2 2\n10 20\n1 1000000000\noutput:\n2\n3\n1\n5\n44721\n\nNote: For $l=1$ and $r=5$, one possible array could be $(1,2,5)$. It can be proven that an array of length $4$ does not exist for the given $l$ and $r$.\n\nFor $l=2$ and $r=2$, the only possible array is $(2)$.\n\nFor $l=10$ and $r=20$, the only possible array is $(10,11,13,16,20)$.\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "2008C", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Card Game\ntime_limit_ms: 2000\nmemory_limit_mb: 256\nDescription: Suneet and Slavic play a card game. The rules of the game are as follows:\n\n * Each card has an integer value between $1$ and $10$. * Each player receives $2$ cards which are face-down (so a player doesn't know their cards). * The game is turn-based and consists exactly of two turns. In a round, both players pick a random unflipped card and flip it. The player who flipped a card with a strictly greater number wins the round. In case of equality, no one wins the round. * A player wins a game if he wins the most number of rounds (i.e. strictly greater than the other player). In case of equality, no one wins the game. \n\nSince Suneet and Slavic aren't best friends, you need to calculate the number of ways the game could happen that Suneet would end up as the winner.\n\nFor a better understanding, please check the notes section.\n\nInput: The first line contains an integer $t$ ($1 \\leq t \\leq 10^4$) β€” the number of test cases.\n\nThe first and only line of each test case contains $4$ integers $a_1$, $a_2$, $b_1$, $b_2$ ($1 \\leq a_1, a_2, b_1, b_2 \\leq 10$) where $a_1$ and $a_2$ represent the cards Suneet has, and $b_1$ and $b_2$ represent the cards Slavic has, respectively.\n\nOutput: For each test case, output a single integer β€” the number of games Suneet would win considering all possible games.\n\nExamples:\ninput:\n5\n3 8 2 6\n1 1 1 1\n10 10 2 2\n1 1 10 10\n3 8 7 2\noutput:\n2\n0\n4\n0\n2\n\nNote: Consider the first test case when Slavic starts with the cards that have the values $2$ and $6$, and Suneet starts with cards that have the values $3$ and $8$. The game could happen in $4$ different ways:\n\n * Suneet flips $3$ and Slavic flips $2$. Suneet wins the first round. Then, Suneet flips $8$ and Slavic flips $6$. Suneet wins the second round as well. Since Suneet won $2$ rounds, he wins the game.\n\n * Suneet flips $3$ and Slavic flips $6$. Slavic wins the first round. Then, Suneet flips $8$ and Slavic flips $2$. Suneet wins the second round. Nobody wins since both players won an equal amount of rounds.\n\n * Suneet flips $8$ and Slavic flips $6$. Suneet wins the first round. Then, Suneet flips $3$ and Slavic flips $2$. Suneet wins the second round as well. Since Suneet won $2$ rounds, he wins the game.\n\n * Suneet flips $8$ and Slavic flips $2$. Suneet wins the first round. Then, Suneet flips $3$ and Slavic flips $6$. Slavic wins the round. Nobody wins since both players won an equal amount of rounds.\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "1999B", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Digital Village (Hard Version)\ntime_limit_ms: 2000\nmemory_limit_mb: 256\nDescription: This is the hard version of the problem. In the three versions, the constraints on $n$ and $m$ are different. You can make hacks only if all the versions of the problem are solved.\n\nPak Chanek is setting up internet connections for the village of Khuntien. The village can be represented as a connected simple graph with $n$ houses and $m$ internet cables connecting house $u_i$ and house $v_i$, each with a latency of $w_i$.\n\nThere are $p$ houses that require internet. Pak Chanek can install servers in at most $k$ of the houses. The houses that need internet will then be connected to one of the servers. However, since each cable has its latency, the latency experienced by house $s_i$ requiring internet will be the maximum latency of the cables between that house and the server it is connected to.\n\nFor each $k = 1,2,\\ldots,n$, help Pak Chanek determine the minimum total latency that can be achieved for all the houses requiring internet.\n\nInput: Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \\le t \\le 2000$). The description of the test cases follows.\n\nThe first line of each test case contains three integers $n$, $m$, $p$ ($2 \\le n \\le 5000$; $n-1 \\le m \\le 5000$; $1 \\le p \\le n$) β€” the number of houses, the number of cables, and the number of houses that need internet.\n\nThe second line of each test case contains $p$ integers $s_1, s_2, \\ldots, s_p$ ($1 \\le s_i \\le n$) β€” the houses that need internet. It is guaranteed that all elements of $s$ are distinct.\n\nThe $i$-th of the next $m$ lines of each test case contains three integers $u_i$, $v_i$, and $w_i$ ($1 \\le u_i < v_i \\le n$; $1 \\le w_i \\le 10^9$) β€” the internet cable connecting house $u_i$ and house $v_i$ with latency of $w_i$. It is guaranteed that the given edges form a connected simple graph.\n\nIt is guaranteed that the sum of $n$ and the sum of $m$ do not exceed $5000$.\n\nOutput: For each test case, output $n$ integers: the minimum total latency that can be achieved for all the houses requiring internet for each $k = 1,2,\\ldots,n$.\n\nExamples:\ninput:\n2\n9 8 5\n2 5 6 8 9\n1 2 1\n1 3 2\n3 4 10\n4 5 3\n4 6 5\n1 7 10\n7 8 4\n7 9 2\n3 3 2\n3 1\n1 2 1\n2 3 3\n1 3 2\noutput:\n34 19 9 4 0 0 0 0 0\n2 0 0\n\nNote: In the first test case for $k=3$, a possible optimal solution is to install servers at vertices $2$, $6$ and $8$ and obtain the following latency:\n\n * $\\text{latency}(2) = 0$ * $\\text{latency}(5) = \\max(3, 5) = 5$ * $\\text{latency}(6) = 0$ * $\\text{latency}(8) = 0$ * $\\text{latency}(9) = \\max(2, 4) = 4$ \n\nSo the total latency is $9$.\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "2021E2", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Tower Capturing\ntime_limit_ms: 2000\nmemory_limit_mb: 256\nDescription: There are $n$ towers at $n$ distinct points $(x_1, y_1), (x_2, y_2), \\ldots, (x_n, y_n)$, such that no three are collinear and no four are concyclic. Initially, you own towers $(x_1, y_1)$ and $(x_2, y_2)$, and you want to capture all of them. To do this, you can do the following operation any number of times:\n\n * Pick two towers $P$ and $Q$ you own and one tower $R$ you don't own, such that the circle through $P$, $Q$, and $R$ contains all $n$ towers inside of it. * Afterwards, capture all towers in or on triangle $\\triangle PQR$, including $R$ itself. \n\nAn attack plan is a series of choices of $R$ ($R_1, R_2, \\ldots, R_k$) using the above operations after which you capture all towers. Note that two attack plans are considered different only if they differ in their choice of $R$ in some operation; in particular, two attack plans using the same choices of $R$ but different choices of $P$ and $Q$ are considered the same.\n\nCount the number of attack plans of minimal length. Note that it might not be possible to capture all towers, in which case the answer is $0$.\n\nSince the answer may be large, output it modulo $998\\,244\\,353$.\n\nInput: The first line contains a single integer $t$ ($1 \\leq t \\leq 250$) β€” the number of test cases.\n\nThe first line of each test case contains a single integer $n$ ($4 \\leq n \\leq 100$) β€” the number of towers.\n\nThe $i$-th of the next $n$ lines contains two integers $x_i$ and $y_i$ ($-10^4 \\leq x_i, y_i \\leq 10^4$) β€” the location of the $i$-th tower. Initially, you own towers $(x_1, y_1)$ and $(x_2, y_2)$.\n\nAll towers are at distinct locations, no three towers are collinear, and no four towers are concyclic.\n\nThe sum of $n$ over all test cases does not exceed $1000$.\n\nOutput: For each test case, output a single integer β€” the number of attack plans of minimal length after which you capture all towers, modulo $998\\,244\\,353$.\n\nExamples:\ninput:\n3\n5\n1 1\n2 5\n3 3\n4 2\n5 4\n6\n1 1\n3 3\n1 2\n2 1\n3 10000\n19 84\n7\n2 7\n-4 -3\n-3 6\n3 1\n-5 2\n1 -4\n-1 7\noutput:\n1\n0\n10\n\nNote: In the first test case, there is only one possible attack plan of shortest length, shown below.\n\n![](CDN_BASE_URL/fa2c55e855095283a306e017f03d06af)\n\n * Use the operation with $P =$ tower $1$, $Q =$ tower $2$, and $R =$ tower $5$. The circle through these three towers contains all towers inside of it, and as a result towers $3$ and $5$ are captured. * Use the operation with $P =$ tower $5$, $Q =$ tower $1$, and $R =$ tower $4$. The circle through these three towers contains all towers inside of it, and as a result tower $4$ is captured. \n\nIn the second case, for example, you can never capture the tower at $(3, 10\\,000)$.\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "1984H", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Digital Village (Extreme Version)\ntime_limit_ms: 2000\nmemory_limit_mb: 256\nDescription: This is the extreme version of the problem. In the three versions, the constraints on $n$ and $m$ are different. You can make hacks only if all the versions of the problem are solved.\n\nPak Chanek is setting up internet connections for the village of Khuntien. The village can be represented as a connected simple graph with $n$ houses and $m$ internet cables connecting house $u_i$ and house $v_i$, each with a latency of $w_i$.\n\nThere are $p$ houses that require internet. Pak Chanek can install servers in at most $k$ of the houses. The houses that need internet will then be connected to one of the servers. However, since each cable has its latency, the latency experienced by house $s_i$ requiring internet will be the maximum latency of the cables between that house and the server it is connected to.\n\nFor each $k = 1,2,\\ldots,n$, help Pak Chanek determine the minimum total latency that can be achieved for all the houses requiring internet.\n\nInput: Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \\le t \\le 10^4$). The description of the test cases follows.\n\nThe first line of each test case contains 3 integers $n$, $m$, $p$ ($2 \\le n \\le 2 \\cdot 10^5$; $n-1 \\le m \\le 2 \\cdot 10^5$; $1 \\le p \\le n$) β€” the number of houses, the number of cables, and the number of houses that need internet.\n\nThe second line of each test case contains $p$ integers $s_1, s_2, \\ldots, s_p$ ($1 \\le s_i \\le n$) β€” the houses that need internet. It is guaranteed that all elements of $s$ are distinct.\n\nThe $i$-th of the next $m$ lines of each test case contains three integers $u_i$, $v_i$, and $w_i$ ($1 \\le u_i < v_i \\le n$; $1 \\le w_i \\le 10^9$) β€” the internet cable connecting house $u_i$ and house $v_i$ with latency of $w_i$. It is guaranteed that the given edges form a connected simple graph.\n\nIt is guaranteed that the sum of $n$ and the sum of $m$ do not exceed $2 \\cdot 10^5$.\n\nOutput: For each test case, output $n$ integers: the minimum total latency that can be achieved for all the houses requiring internet for each $k = 1,2,\\ldots,n$.\n\nExamples:\ninput:\n2\n9 8 5\n2 5 6 8 9\n1 2 1\n1 3 2\n3 4 10\n4 5 3\n4 6 5\n1 7 10\n7 8 4\n7 9 2\n3 3 2\n3 1\n1 2 1\n2 3 3\n1 3 2\noutput:\n34 19 9 4 0 0 0 0 0\n2 0 0\n\nNote: In the first test case for $k=3$, a possible optimal solution is to install servers at vertices $2$, $6$ and $8$ and obtain the following latency:\n\n * $\\text{latency}(2) = 0$ * $\\text{latency}(5) = \\max(3, 5) = 5$ * $\\text{latency}(6) = 0$ * $\\text{latency}(8) = 0$ * $\\text{latency}(9) = \\max(2, 4) = 4$ \n\nSo the total latency is $9$.\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "2021E3", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Bazoka and Mocha's Array\ntime_limit_ms: 1000\nmemory_limit_mb: 256\nDescription: Mocha likes arrays, so before her departure, Bazoka gave her an array $a$ consisting of $n$ positive integers as a gift.\n\nNow Mocha wants to know whether array $a$ could become sorted in non- decreasing order after performing the following operation some (possibly, zero) times:\n\n * Split the array into two parts β€” a prefix and a suffix, then swap these two parts. In other words, let $a=x+y$. Then, we can set $a:= y+x$. Here $+$ denotes the array concatenation operation. \n\nFor example, if $a=[3,1,4,1,5]$, we can choose $x=[3,1]$ and $y=[4,1,5]$, satisfying $a=x+y$. Then, we can set $a:= y + x = [4,1,5,3,1]$. We can also choose $x=[3,1,4,1,5]$ and $y=[\\,]$, satisfying $a=x+y$. Then, we can set $a := y+x = [3,1,4,1,5]$. Note that we are not allowed to choose $x=[3,1,1]$ and $y=[4,5]$, neither are we allowed to choose $x=[1,3]$ and $y=[5,1,4]$, as both these choices do not satisfy $a=x+y$.\n\nInput: Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1\\leq t\\leq 1000$). The description of the test cases follows.\n\nThe first line of each test case contains a single integer $n$ ($2\\leq n\\leq 50$) β€” the length of the array $a$.\n\nThe second line of each test case contains $n$ integers $a_1,a_2,\\ldots,a_n$ ($1\\leq a_i \\leq 10^6$) β€” the elements of array $a$.\n\nOutput: For each test case, output \"Yes\" if $a$ could become non-decreasing after performing the operation any number of times, and output \"No\" if not.\n\nYou can output \"Yes\" and \"No\" in any case (for example, strings \"yEs\", \"yes\", \"Yes\" and \"YES\" will be recognized as a positive response).\n\nExamples:\ninput:\n3\n6\n1 1 4 5 1 4\n5\n7 9 2 2 3\n3\n1 2 3\noutput:\nNo\nYes\nYes\n\nNote: In the first test case, it can be proven that $a$ cannot become non- decreasing after performing the operation any number of times.\n\nIn the second test case, we can perform the following operations to make $a$ sorted in non-decreasing order:\n\n * Split the array into two parts: $x=[7]$ and $y=[9,2,2,3]$, then swap these two parts. The array will become $y+x = [9,2,2,3,7]$. * Split the array into two parts: $x=[9]$ and $y=[2,2,3,7]$, then swap these two parts. The array will become $y+x=[2,2,3,7,9]$, which is non-decreasing.\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "1975A", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Turtle and an Infinite Sequence\ntime_limit_ms: 1000\nmemory_limit_mb: 256\nDescription: There is a sequence $a_0, a_1, a_2, \\ldots$ of infinite length. Initially $a_i = i$ for every non-negative integer $i$.\n\nAfter every second, each element of the sequence will simultaneously change. $a_i$ will change to $a_{i - 1} \\mid a_i \\mid a_{i + 1}$ for every positive integer $i$. $a_0$ will change to $a_0 \\mid a_1$. Here, $|$ denotes [bitwise OR](https://en.wikipedia.org/wiki/Bitwise_operation#OR).\n\nTurtle is asked to find the value of $a_n$ after $m$ seconds. In particular, if $m = 0$, then he needs to find the initial value of $a_n$. He is tired of calculating so many values, so please help him!\n\nInput: Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \\le t \\le 10^4$). The description of the test cases follows.\n\nThe first line of each test case contains two integers $n, m$ ($0 \\le n, m \\le 10^9$).\n\nOutput: For each test case, output a single integer β€” the value of $a_n$ after $m$ seconds.\n\nExamples:\ninput:\n9\n0 0\n0 1\n0 2\n1 0\n5 2\n10 1\n20 3\n1145 14\n19198 10\noutput:\n0\n1\n3\n1\n7\n11\n23\n1279\n19455\n\nNote: After $1$ second, $[a_0, a_1, a_2, a_3, a_4, a_5]$ will become $[1, 3, 3, 7, 7, 7]$.\n\nAfter $2$ seconds, $[a_0, a_1, a_2, a_3, a_4, a_5]$ will become $[3, 3, 7, 7, 7, 7]$.\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "1981B", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Subtangle Game (Hard Version)\ntime_limit_ms: 2000\nmemory_limit_mb: 256\nDescription: This is the hard version of the problem. The differences between the two versions are the constraints on all the variables. You can make hacks only if both versions of the problem are solved.\n\nTsovak and Narek are playing a game. They have an array $a$ and a matrix $b$ of integers with $n$ rows and $m$ columns, numbered from $1$. The cell in the $i$-th row and the $j$-th column is $(i, j)$.\n\nThey are looking for the elements of $a$ in turns; Tsovak starts first. Each time a player looks for a cell in the matrix containing the current element of $a$ (Tsovak looks for the first, then Narek looks for the second, etc.). Let's say a player has chosen the cell $(r, c)$. The next player has to choose his cell in the submatrix starting at $(r + 1, c + 1)$ and ending in $(n, m)$ (the submatrix can be empty if $r=n$ or $c=m$). If a player cannot find such a cell (or the remaining submatrix is empty) or the array ends (the previous player has chosen the last element), then he loses.\n\nYour task is to determine the winner if the players play optimally.\n\nNote: since the input is large, you may need to optimize input/output for this problem.\n\nFor example, in C++, it is enough to use the following lines at the start of the main() function:\n\n int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); }\n\nInput: The first line of the input contains $t$ ($1 \\le t \\le 1500$) – the number of test cases.\n\nThe first line of each test case contains three integers $l$, $n$, and $m$ ($1 \\le l, n, m \\le 1500$) – the size of the array and the sizes of the matrix.\n\nThe second line contains $l$ integers $a_1, a_2, a_3, \\ldots a_l$ ($1 \\le a_i \\le n \\cdot m$) – the elements of the array $a$.\n\nThe $i$-th of the last $n$ lines contains $m$ integers $b_{i,1}, b_{i,2}, b_{i,3}, \\ldots b_{i,m}$ ($1 \\le b_{i,j} \\le n \\cdot m$) – representing the $i$-th row of the matrix.\n\nIt is guaranteed that the sum of $n \\cdot m$ over all test cases does not exceed $3 \\cdot 10^6$.\n\nIt is guaranteed that the sum of $l$ over all test cases does not exceed $1500$.\n\nOutput: You should output $t$ lines, the $i$-th of them containing a character representing the answer of the $i$-th test case: \"T\" if Tsovak wins or \"N\", otherwise (without quotes).\n\nExamples:\ninput:\n3\n2 2 3\n1 2\n1 3 6\n4 6 2\n2 2 4\n1 2\n1 1 3 2\n4 2 5 1\n2 4 2\n1 2\n3 4\n5 6\n7 8\n8 8\noutput:\nN\nT\nN\n\nNote: In the first example, Tsovak starts by looking for $1$. There is only one occurrence of $1$ at $(1,1)$, so he chooses it. Then Narek needs to look for $2$ in the submatrix of $(2, 2)$, which consists of just the last two elements: $6$ and $2$. He chooses $2$, and then Tsovak loses since the array has ended.\n\nIn the second example, Tsovak needs to choose $1$. There is a $1$ at the cell $(n,m)$, so he chooses that cell. Then, since the submatrix of $(n + 1, m + 1)$ is empty, Narek cannot find $2$, so he loses.\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "2005E2", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Turtle and Intersected Segments\ntime_limit_ms: 5000\nmemory_limit_mb: 512\nDescription: Turtle just received $n$ segments and a sequence $a_1, a_2, \\ldots, a_n$. The $i$-th segment is $[l_i, r_i]$.\n\nTurtle will create an undirected graph $G$. If segment $i$ and segment $j$ intersect, then Turtle will add an undirected edge between $i$ and $j$ with a weight of $|a_i - a_j|$, for every $i \\ne j$.\n\nTurtle wants you to calculate the sum of the weights of the edges of the minimum spanning tree of the graph $G$, or report that the graph $G$ has no spanning tree.\n\nWe say two segments $[l_1, r_1]$ and $[l_2, r_2]$ intersect if and only if $\\max(l_1, l_2) \\le \\min(r_1, r_2)$.\n\nInput: Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \\le t \\le 10^5$). The description of the test cases follows.\n\nThe first line of each test case contains a single integer $n$ ($2 \\le n \\le 5 \\cdot 10^5$) β€” the number of segments.\n\nThe $i$-th of the following $n$ lines contains three integers $l_i, r_i, a_i$ ($1 \\le l_i \\le r_i \\le 10^9, 1 \\le a_i \\le 10^9$) β€” the $i$-th segment and the $i$-th element of the sequence.\n\nIt is guaranteed that the sum of $n$ over all test cases does not exceed $5 \\cdot 10^5$.\n\nOutput: For each test case, output a single integer β€” the sum of the weights of the edges of the minimum spanning tree of the graph $G$. If the graph $G$ has no spanning tree, output $-1$.\n\nExamples:\ninput:\n4\n5\n1 7 3\n2 4 6\n3 5 5\n6 7 9\n3 4 4\n5\n2 7 3\n1 3 6\n4 5 5\n6 7 9\n1 1 4\n4\n1 4 3\n1 2 1\n3 4 5\n1 4 4\n3\n1 3 1\n2 3 3\n4 5 8\noutput:\n9\n13\n4\n-1\n\nNote: In the first test case, the graph $G$ is as follows:\n\n![](CDN_BASE_URL/7b0a32f8f1d54a5dbbaffee1efd8ece1)\n\nOne of the minimum spanning trees of $G$ is as follows:\n\n![](CDN_BASE_URL/7a035af2d5227648781d0c24b81c076e)\n\nThe sum of the weights of the edges of the minimum spanning tree is $9$.\n\nIn the second test case, the graph $G$ is as follows:\n\n![](CDN_BASE_URL/62be880a08fa85071b491d6badd5f58e)\n\n$G$ is already a tree, and the sum of the weights of the tree is $13$.\n\nIn the third test case, the graph $G$ is as follows:\n\n![](CDN_BASE_URL/b667aa771d019e3a8a3a4c4372200f03)\n\nIn the fourth test case, the graph $G$ is as follows:\n\n![](CDN_BASE_URL/45bc2d052677dbf032ff37fd1d723d83)\n\nIt's easy to see that $G$ is not connected, so $G$ has no spanning tree.\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "1981E", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Med-imize\ntime_limit_ms: 2000\nmemory_limit_mb: 256\nDescription: Given two positive integers $n$ and $k$, and another array $a$ of $n$ integers.\n\nIn one operation, you can select any subarray of size $k$ of $a$, then remove it from the array without changing the order of other elements. More formally, let $(l, r)$ be an operation on subarray $a_l, a_{l+1}, \\ldots, a_r$ such that $r-l+1=k$, then performing this operation means replacing $a$ with $[a_1, \\ldots, a_{l-1}, a_{r+1}, \\ldots, a_n]$.\n\nFor example, if $a=[1,2,3,4,5]$ and we perform operation $(3,5)$ on this array, it will become $a=[1,2]$. Moreover, operation $(2, 4)$ results in $a=[1,5]$, and operation $(1,3)$ results in $a=[4,5]$.\n\nYou have to repeat the operation while the length of $a$ is greater than $k$ (which means $|a| \\gt k$). What is the largest possible median$^\\dagger$ of all remaining elements of the array $a$ after the process?\n\n$^\\dagger$The median of an array of length $n$ is the element whose index is $\\left \\lfloor (n+1)/2 \\right \\rfloor$ after we sort the elements in non-decreasing order. For example: $median([2,1,5,4,3]) = 3$, $median([5]) = 5$, and $median([6,8,2,4]) = 4$.\n\nInput: The first line contains a single integer $t$ ($1 \\le t \\le 10^4$) β€” the number of test cases.\n\nThe first line of each test case contains two integers $n$ and $k$ ($1 \\le n, k \\le 5 \\cdot 10^5$).\n\nThe second line contains $n$ integers $a_1, a_2, \\ldots, a_n$ ($1 \\le a_i \\le 10^9$) β€” the array $a$.\n\nIt is guaranteed that the sum of $n$ over all test cases does not exceed $5 \\cdot 10^5$.\n\nOutput: For each test case, print a single integer β€” the largest median possible after performing the operations.\n\nExamples:\ninput:\n5\n4 3\n3 9 9 2\n5 3\n3 2 5 6 4\n7 1\n5 9 2 6 5 4 6\n8 2\n7 1 2 6 8 3 4 5\n4 5\n3 4 5 6\noutput:\n3\n4\n9\n6\n4\n\nNote: In the first test case, you can select a subarray $(l, r)$ which can be either $(1, 3)$ or $(2, 4)$. Thus, two obtainable final arrays are $[3]$ and $[2]$. The former one has the larger median ($3 > 2$) so the answer is $3$.\n\nIn the second test case, three obtainable final arrays are $[6, 4]$, $[3, 4]$, and $[3, 2]$. Their medians are $4$, $3$, and $2$ respectively. The answer is $4$.\n\nIn the third test case, only one element is left in the final array and it can be any element of the initial array. The largest one among them is $9$, so the answer is $9$.\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "1993D", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Shuffle\ntime_limit_ms: 2000\nmemory_limit_mb: 256\nDescription: Two hungry red pandas, Oscar and Lura, have a tree $T$ with $n$ nodes. They are willing to perform the following shuffle procedure on the whole tree $T$ exactly once. With this shuffle procedure, they will create a new tree out of the nodes of the old tree.\n\n 1. Choose any node $V$ from the original tree $T$. Create a new tree $T_2$, with $V$ as the root. 2. Remove $V$ from $T$, such that the original tree is split into one or more subtrees (or zero subtrees, if $V$ is the only node in $T$). 3. Shuffle each subtree with the same procedure (again choosing any node as the root), then connect all shuffled subtrees' roots back to $V$ to finish constructing $T_2$. \n\nAfter this, Oscar and Lura are left with a new tree $T_2$. They can only eat leaves and are very hungry, so please find the maximum number of leaves over all trees that can be created in exactly one shuffle.\n\nNote that leaves are all nodes with degree $1$. Thus, the root may be considered as a leaf if it has only one child.\n\nInput: The first line contains a single integer $t$ ($1 \\leq t \\leq 10^4$) β€” the number of test cases.\n\nThe first line of every test case contains a single integer $n$ ($2 \\leq n \\leq 2 \\cdot 10^5$) β€” the number of nodes within the original tree $T$.\n\nThe next $n - 1$ lines each contain two integers $u$ and $v$ ($1 \\leq u, v \\leq n$) β€” an edge within the original tree $T$. The given edges form a tree.\n\nThe sum of $n$ over all test cases does not exceed $3 \\cdot 10^5$.\n\nOutput: For each test case, output a single integer β€” the maximum number of leaves achievable with exactly one shuffle procedure on the whole tree.\n\nExamples:\ninput:\n4\n5\n1 2\n1 3\n2 4\n2 5\n5\n1 2\n2 3\n3 4\n4 5\n6\n1 2\n1 3\n1 4\n1 5\n1 6\n10\n9 3\n8 1\n10 6\n8 5\n7 8\n4 6\n1 3\n10 1\n2 7\noutput:\n4\n3\n5\n6\n\nNote: In the first test case, it can be shown that the maximum number of leaves is $4$. To accomplish this, we can start our shuffle with selecting node $3$ as the new root.\n\n![](CDN_BASE_URL/038cb83999c75e319cd6897cdfe03b7b) Next, we are left only with one subtree, in which we can select node $2$ to be the new root of that subtree. ![](CDN_BASE_URL/85eb09dd4b3b98aa44c0450fc1904edf) This will force all $3$ remaining nodes to be leaves, and once we connect them back to our new root, the shuffled subtree looks like this: ![](CDN_BASE_URL/71ffcc64012b118124db081f8a9493b2) We connect the shuffled subtree back to our new root of our new tree. Our final tree has four leaves (including the root), and looks like this: ![](CDN_BASE_URL/882e22ac95139c8917e71dee39d6a32c)\n\nIn our second test case, we have a line of five nodes. It can be shown that the maximum number of leaves after one shuffle is $3$. We can start off with node $2$, which forces node $1$ to become a leaf. Then, if we select node $4$ on the right side, we will also have nodes $3$ and $5$ as leaves.\n\nThe third test case is a star graph with six nodes. The number of leaves cannot increase, thus our answer will be $5$ (if we start the shuffling with the original root node).\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "1984E", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Closest Point\ntime_limit_ms: 2000\nmemory_limit_mb: 512\nDescription: Consider a set of points on a line. The distance between two points $i$ and $j$ is $|i - j|$.\n\nThe point $i$ from the set is the closest to the point $j$ from the set, if there is no other point $k$ in the set such that the distance from $j$ to $k$ is strictly less than the distance from $j$ to $i$. In other words, all other points from the set have distance to $j$ greater or equal to $|i - j|$.\n\nFor example, consider a set of points $\\\\{1, 3, 5, 8\\\\}$:\n\n * for the point $1$, the closest point is $3$ (other points have distance greater than $|1-3| = 2$); * for the point $3$, there are two closest points: $1$ and $5$; * for the point $5$, the closest point is $3$ (but not $8$, since its distance is greater than $|3-5|$); * for the point $8$, the closest point is $5$. \n\nYou are given a set of points. You have to add an integer point into this set in such a way that it is different from every existing point in the set, and it becomes the closest point to every point in the set. Is it possible?\n\nInput: The first line contains one integer $t$ ($1 \\le t \\le 1000$) β€” the number of test cases.\n\nEach test case consists of two lines:\n\n * the first line contains one integer $n$ ($2 \\le n \\le 40$) β€” the number of points in the set; * the second line contains $n$ integers $x_1, x_2, \\dots, x_n$ ($1 \\le x_1 < x_2 < \\dots < x_n \\le 100$) β€” the points from the set.\n\nOutput: For each test case, print YES if it is possible to add a new point according to the conditions from the statement. Otherwise, print NO.\n\nExamples:\ninput:\n3\n2\n3 8\n2\n5 6\n6\n1 2 3 4 5 10\noutput:\nYES\nNO\nNO\n\nNote: In the first example, the point $7$ will be the closest to both $3$ and $8$.\n\nIn the second example, it is impossible to add an integer point so that it becomes the closest to both $5$ and $6$, and is different from both of them.\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "2004A", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Field Division (hard version)\ntime_limit_ms: 3000\nmemory_limit_mb: 256\nDescription: This is a hard version of the problem; it differs from the easy version only by the question. The easy version only needs you to print whether some values are non-zero or not. The hard version needs you to print the exact values.\n\nAlice and Bob are dividing the field. The field is a rectangle of size $n \\times m$ ($2 \\le n, m \\le 10^9$); the rows are numbered from $1$ to $n$ from top to bottom, and the columns are numbered from $1$ to $m$ from left to right. The cell at the intersection of row $r$ and column $c$ is denoted as ($r, c$).\n\nBob has $k$ ($2 \\le k \\le 2 \\cdot 10^5$) fountains, all of them are located in different cells of the field. Alice is responsible for dividing the field, but she must meet several conditions:\n\n * To divide the field, Alice will start her path in any free (without a fountain) cell on the left or top side of the field and will move, each time moving to the adjacent cell down or right. Her path will end on the right or bottom side of the field. * Alice's path will divide the field into two parts β€” one part will belong to Alice (this part includes the cells of her path), the other part β€” to Bob. * Alice will own the part that includes the cell ($n, 1$). * Bob will own the part that includes the cell ($1, m$). \n\nAlice wants to divide the field in such a way as to get as many cells as possible.\n\nBob wants to keep ownership of all the fountains, but he can give one of them to Alice. First, output the integer $\\alpha$ β€” the maximum possible size of Alice's plot, if Bob does not give her any fountain (i.e., all fountains will remain on Bob's plot).\n\nThen output $k$ non-negative integers $a_1, a_2, \\dots, a_k$, where $a_i$ is a value such that after Bob gives Alice the $i$-th fountain, the maximum size of her plot will be $\\alpha + a_i$.\n\nInput: The first line contains a single integer $t$ ($1 \\le t \\le 10^4$) β€” the number of test cases.\n\nThe first line of each test case contains three integers $n$, $m$, and $k$ ($2 \\le n, m \\le 10^9$, $2 \\le k \\le 2 \\cdot 10^5$) β€” the field sizes and the number of fountains, respectively.\n\nThen follow $k$ lines, each containing two numbers $r_i$ and $c_i$ ($1 \\le r_i \\le n$, $1 \\le c_i \\le m$) β€” the coordinates of the cell with the $i$-th fountain. It is guaranteed that all cells are distinct and none of them is ($n, 1$).\n\nIt is guaranteed that the sum of $k$ over all test cases does not exceed $2 \\cdot 10^5$.\n\nOutput: For each test case, first output $\\alpha$ β€” the maximum size of the plot that can belong to Alice if Bob does not give her any of the fountains. Then output $k$ non-negative integers $a_1, a_2, \\dots, a_k$, where $a_i$ is a value such that after Bob gives Alice the $i$-th fountain, the maximum size of her plot will be $\\alpha + a_i$.\n\nExamples:\ninput:\n5\n2 2 3\n1 1\n1 2\n2 2\n5 5 4\n1 2\n2 2\n3 4\n4 3\n2 5 9\n1 2\n1 5\n1 1\n2 2\n2 4\n2 5\n1 4\n2 3\n1 3\n6 4 4\n6 2\n1 3\n1 4\n1 2\n3 4 5\n2 1\n3 2\n1 4\n1 3\n2 4\noutput:\n1\n1 0 1 \n11\n0 1 0 4 \n1\n0 0 1 1 0 0 0 0 0 \n6\n15 0 0 0 \n1\n2 3 0 0 0\n\nNote: Below are the images for the second example:\n\n![](CDN_BASE_URL/0e3fee1fe74ac4348d869fc256da57a3) The indices of the fountains are labeled in green. The cells belonging to Alice are marked in blue.\n\nNote that if Bob gives Alice fountain $1$ or fountain $3$, then that fountain cannot be on Alice's plot.\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "1980F2", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Square or Not\ntime_limit_ms: 2000\nmemory_limit_mb: 256\nDescription: A beautiful binary matrix is a matrix that has ones on its edges and zeros inside.\n\n![](CDN_BASE_URL/5df31946486165887b31c82158ed558d) Examples of four beautiful binary matrices.\n\nToday, Sakurako was playing with a beautiful binary matrix of size $r \\times c$ and created a binary string $s$ by writing down all the rows of the matrix, starting from the first and ending with the $r$-th. More formally, the element from the matrix in the $i$-th row and $j$-th column corresponds to the $((i-1)*c+j)$-th element of the string.\n\nYou need to check whether the beautiful matrix from which the string $s$ was obtained could be squared. In other words, you need to check whether the string $s$ could have been build from a square beautiful binary matrix (i.e., one where $r=c$).\n\nInput: The first line contains a single integer $t$ ($1 \\le t \\le 10^4$) β€” the number of test cases.\n\nThe first line of each test case contains a single integer $n$ ($2 \\le n \\le 2 \\cdot 10^5$) β€” the length of the string.\n\nThe second line of each test case contains the string $s$ of length $n$. The string is always the result of writing out the strings of a beautiful matrix.\n\nIt is guaranteed that the sum of $n$ across all test cases does not exceed $2 \\cdot 10^5$.\n\nOutput: Print \"Yes\", if the original matrix could have been square, and \"No\" otherwise.\n\nExamples:\ninput:\n5\n2\n11\n4\n1111\n9\n111101111\n9\n111111111\n12\n111110011111\noutput:\nNo\nYes\nYes\nNo\nNo\n\nNote: For the second test case, string 1111 can be obtained from the matrix:\n\n$1$| $1$ ---|--- $1$| $1$ For the third test case, string 111101111 can be obtained from the matrix:\n\n$1$| $1$| $1$ ---|---|--- $1$| $0$| $1$ $1$| $1$| $1$ There is no square matrix in the fourth case, such that the string can be obtained from it.\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "2008B", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Job Interview\ntime_limit_ms: 2000\nmemory_limit_mb: 256\nDescription: Monocarp is opening his own IT company. He wants to hire $n$ programmers and $m$ testers.\n\nThere are $n+m+1$ candidates, numbered from $1$ to $n+m+1$ in chronological order of their arriving time. The $i$-th candidate has programming skill $a_i$ and testing skill $b_i$ (a person's programming skill is different from their testing skill). The skill of the team is the sum of the programming skills of all candidates hired as programmers, and the sum of the testing skills of all candidates hired as testers.\n\nWhen a candidate arrives to interview, Monocarp tries to assign them to the most suitable position for them (if their programming skill is higher, then he hires them as a programmer, otherwise as a tester). If all slots for that position are filled, Monocarp assigns them to the other position.\n\nYour task is, for each candidate, calculate the skill of the team if everyone except them comes to interview. Note that it means that exactly $n+m$ candidates will arrive, so all $n+m$ positions in the company will be filled.\n\nInput: The first line contains a single integer $t$ ($1 \\le t \\le 10^4$) β€” the number of test cases.\n\nEach test case consists of three lines:\n\n * the first line contains two integers $n$ and $m$ ($0 \\le n, m \\le 2 \\cdot 10^5$; $2 \\le n + m + 1 \\le 2 \\cdot 10^5$) β€” the number of programmers and the number of testers Monocarp wants to hire, respectively; * the second line contains $n + m + 1$ integers $a_1, a_2, \\dots, a_{n+m+1}$ ($1 \\le a_i \\le 10^9$), where $a_i$ is the programming skill of the $i$-th candidate; * the third line contains $n + m + 1$ integers $b_1, b_2, \\dots, b_{n+m+1}$ ($1 \\le b_i \\le 10^9$; $b_i \\ne a_i$), where $b_i$ is the testing skill of the $i$-th candidate. \n\nAdditional constraint on the input: the sum of $(n + m + 1)$ over all test cases doesn't exceed $2 \\cdot 10^5$.\n\nOutput: For each test case, print $n + m + 1$ integers, where the $i$-th integer should be equal to the skill of the team if everyone except the $i$-th candidate comes to interview.\n\nExamples:\ninput:\n4\n1 0\n2 1\n1 2\n0 2\n4 5 5\n5 4 1\n1 2\n2 1 5 4\n5 2 3 1\n3 1\n4 3 3 4 1\n5 5 4 5 2\noutput:\n1 2 \n5 6 9 \n8 11 11 12 \n13 13 13 12 15\n\nNote: Let's consider the third test case of the example:\n\n * if the $1$-st candidate does not arrive, the $2$-nd candidate gets hired as a tester, the $3$-rd candidate gets hired as a programmer, the $4$-th candidate gets hired as a tester. The total skill of the team will be $2 + 5 + 1 = 8$; * if the $2$-nd candidate does not arrive, the $1$-st candidate gets hired as a tester, the $3$-rd candidate gets hired as a programmer, the $4$-th candidate gets hired as a tester. The total skill of the team will be $5 + 5 + 1 = 11$; * if the $3$-rd candidate does not arrive, the $1$-st candidate gets hired as a tester, the $2$-nd candidate gets hired as a tester, the $4$-th candidate gets hired as a programmer. The total skill of the team will be $5 + 2 + 4 = 11$; * if the $4$-th candidate does not arrive, the $1$-st candidate gets hired as a tester, the $2$-nd candidate gets hired as a tester, the $3$-rd candidate gets hired as a programmer. The total skill of the team will be $5 + 2 + 5 = 12$.\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "1976C", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Sakurako and Kosuke\ntime_limit_ms: 1000\nmemory_limit_mb: 256\nDescription: Sakurako and Kosuke decided to play some games with a dot on a coordinate line. The dot is currently located in position $x=0$. They will be taking turns, and Sakurako will be the one to start.\n\nOn the $i$-th move, the current player will move the dot in some direction by $2\\cdot i-1$ units. Sakurako will always be moving the dot in the negative direction, whereas Kosuke will always move it in the positive direction.\n\nIn other words, the following will happen:\n\n 1. Sakurako will change the position of the dot by $-1$, $x = -1$ now 2. Kosuke will change the position of the dot by $3$, $x = 2$ now 3. Sakurako will change the position of the dot by $-5$, $x = -3$ now 4. $\\cdots$ \n\nThey will keep on playing while the absolute value of the coordinate of the dot does not exceed $n$. More formally, the game continues while $-n\\le x\\le n$. It can be proven that the game will always end.\n\nYour task is to determine who will be the one who makes the last turn.\n\nInput: The first line contains one integer $t$ ($1\\le t\\le 100$) β€” the number of games that Sakurako and Kosuke played.\n\nEach game is described by one number $n$ ($1 \\le n\\le 100$) β€” the number that defines the condition when the game ends.\n\nOutput: For each of the $t$ games, output a line with the result of that game. If Sakurako makes the last turn, output \"Sakurako\" (without quotes); else output \"Kosuke\".\n\nExamples:\ninput:\n4\n1\n6\n3\n98\noutput:\nKosuke\nSakurako\nKosuke\nSakurako\n\nNote: \n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "2033A", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Eliminating Balls With Merging (Hard Version)\ntime_limit_ms: 4000\nmemory_limit_mb: 512\nDescription: Drink water.\n\nβ€” Sun Tzu, The Art of Becoming a Healthy Programmer\n\nThis is the hard version of the problem. The only difference is that $x=1$ in this version. You must solve both versions to be able to hack.\n\nYou are given two integers $n$ and $x$ ($x=1$). There are $n$ balls lined up in a row, numbered from $1$ to $n$ from left to right. Initially, there is a value $a_i$ written on the $i$-th ball.\n\nFor each integer $i$ from $1$ to $n$, we define a function $f(i)$ as follows:\n\n * Suppose you have a set $S = \\\\{1, 2, \\ldots, i\\\\}$.\n\n * In each operation, you have to select an integer $l$ ($1 \\leq l < i$) from $S$ such that $l$ is not the largest element of $S$. Suppose $r$ is the smallest element in $S$ which is greater than $l$.\n\n * If $a_l > a_r$, you set $a_l = a_l + a_r$ and remove $r$ from $S$. * If $a_l < a_r$, you set $a_r = a_l + a_r$ and remove $l$ from $S$. * If $a_l = a_r$, you choose either the integer $l$ or $r$ to remove from $S$: * If you choose to remove $l$ from $S$, you set $a_r = a_l + a_r$ and remove $l$ from $S$. * If you choose to remove $r$ from $S$, you set $a_l = a_l + a_r$ and remove $r$ from $S$. \n\n * $f(i)$ denotes the number of integers $j$ ($1 \\le j \\le i$) such that it is possible to obtain $S = \\\\{j\\\\}$ after performing the above operations exactly $i - 1$ times. \n\nFor each integer $i$ from $x$ to $n$, you need to find $f(i)$.\n\nInput: The first line contains $t$ ($1 \\leq t \\leq 10^4$) β€” the number of test cases.\n\nThe first line of each test case contains two integers $n$ and $x$ ($1 \\leq n \\leq 2 \\cdot 10^5; x = 1$) β€” the number of balls and the smallest index $i$ for which you need to find $f(i)$.\n\nThe second line of each test case contains $a_1, a_2, \\ldots, a_n$ ($1 \\leq a_i \\leq 10^9$) β€” the initial number written on each ball.\n\nIt is guaranteed that the sum of $n$ over all test cases does not exceed $2 \\cdot 10^5$.\n\nOutput: For each test case, output $n-x+1$ space separated integers on a new line, where the $j$-th integer should represent $f(x+j-1)$.\n\nExamples:\ninput:\n3\n5 1\n1 2 3 2 1\n7 1\n4 5 1 2 1 4 5\n11 1\n1 2 3 1 1 9 3 2 4 1 3\noutput:\n1 1 2 2 3\n1 1 1 1 1 3 4\n1 1 2 2 2 1 1 1 3 3 4\n\nNote: In the first test case, below are the possible values of $j$ for each $f(i)$ from $1$ to $n$.\n\n * For $f(1)$, the only possible value of $j$ is $1$. * For $f(2)$, the only possible value of $j$ is $2$. * For $f(3)$, the possible values of $j$ are $2$ and $3$. * For $f(4)$, the possible values of $j$ are $2$ and $3$. * For $f(5)$, the possible values of $j$ are $2$, $3$, and $4$.\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "1998E2", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Reverse the Rivers\ntime_limit_ms: 2000\nmemory_limit_mb: 256\nDescription: A conspiracy of ancient sages, who decided to redirect rivers for their own convenience, has put the world on the brink. But before implementing their grand plan, they decided to carefully think through their strategy β€” that's what sages do.\n\nThere are $n$ countries, each with exactly $k$ regions. For the $j$-th region of the $i$-th country, they calculated the value $a_{i,j}$, which reflects the amount of water in it.\n\nThe sages intend to create channels between the $j$-th region of the $i$-th country and the $j$-th region of the $(i + 1)$-th country for all $1 \\leq i \\leq (n - 1)$ and for all $1 \\leq j \\leq k$.\n\nSince all $n$ countries are on a large slope, water flows towards the country with the highest number. According to the sages' predictions, after the channel system is created, the new value of the $j$-th region of the $i$-th country will be $b_{i,j} = a_{1,j} | a_{2,j} | ... | a_{i,j}$, where $|$ denotes the [bitwise \"OR\"](http://tiny.cc/bitwise_or) operation.\n\nAfter the redistribution of water, the sages aim to choose the most suitable country for living, so they will send you $q$ queries for consideration.\n\nEach query will contain $m$ requirements.\n\nEach requirement contains three parameters: the region number $r$, the sign $o$ (either \"$<$\" or \"$>$\"), and the value $c$. If $o$ = \"$<$\", then in the $r$-th region of the country you choose, the new value must be strictly less than the limit $c$, and if $o$ = \"$>$\", it must be strictly greater.\n\nIn other words, the chosen country $i$ must satisfy all $m$ requirements. If in the current requirement $o$ = \"$<$\", then it must hold that $b_{i,r} < c$, and if $o$ = \"$>$\", then $b_{i,r} > c$.\n\nIn response to each query, you should output a single integer β€” the number of the suitable country. If there are multiple such countries, output the smallest one. If no such country exists, output $-1$.\n\nInput: The first line contains three integers $n$, $k$, and $q$ ($1 \\leq n, k, q \\leq 10^5$) β€” the number of countries, regions, and queries, respectively.\n\nNext, there are $n$ lines, where the $i$-th line contains $k$ integers $a_{i,1}, a_{i,2}, \\dots, a_{i,k}$ ($1 \\leq a_{i,j} \\leq 10^9$), where $a_{i,j}$ is the value of the $j$-th region of the $i$-th country.\n\nThen, $q$ queries are described.\n\nThe first line of each query contains a single integer $m$ ($1 \\leq m \\leq 10^5$) β€” the number of requirements.\n\nThen follow $m$ lines, each containing an integer $r$, a character $o$, and an integer $c$ ($1 \\leq r \\leq k$, $0 \\leq c \\leq 2 \\cdot 10^9$), where $r$ and $c$ are the region number and the value, and $o$ is either \"$<$\" or \"$>$\" β€” the sign.\n\nIt is guaranteed that $n \\cdot k$ does not exceed $10^5$ and that the sum of $m$ across all queries also does not exceed $10^5$.\n\nOutput: For each query, output a single integer on a new line β€” the smallest number of the suitable country, or $-1$ if no such country exists.\n\nExamples:\ninput:\n3 4 4\n1 3 5 9\n4 6 5 3\n2 1 2 7\n3\n1 > 4\n2 < 8\n1 < 6\n2\n1 < 8\n2 > 8\n1\n3 > 5\n2\n4 > 8\n1 < 8\noutput:\n2\n-1\n3\n1\n\nNote: In the example, the initial values of the regions are as follows:\n\n$1$| $3$| $5$| $9$ ---|---|---|--- $4$| $6$| $5$| $3$ $2$| $1$| $2$| $7$ After creating the channels, the new values will look like this:\n\n$1$| $3$| $5$| $9$ ---|---|---|--- $1 | 4$| $3 | 6$| $5 | 5$| $9 | 3$ $1 | 4 | 2$| $3 | 6 | 1$| $5 | 5 | 2$| $9 | 3 | 7$ $\\downarrow$ $1$| $3$| $5$| $9$ ---|---|---|--- $5$| $7$| $5$| $11$ $7$| $7$| $7$| $15$ In the first query, it is necessary to output the minimum country number (i.e., row) where, after the redistribution of water in the first region (i.e., column), the new value will be greater than four and less than six, and in the second region it will be less than eight. Only the country with number $2$ meets these requirements.\n\nIn the second query, there are no countries that meet the specified requirements.\n\nIn the third query, only the country with number $3$ is suitable.\n\nIn the fourth query, all three countries meet the conditions, so the answer is the smallest number $1$.\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "2036E", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Seating in a Bus\ntime_limit_ms: 2000\nmemory_limit_mb: 256\nDescription: In Berland, a bus consists of a row of $n$ seats numbered from $1$ to $n$. Passengers are advised to always board the bus following these rules:\n\n * If there are no occupied seats in the bus, a passenger can sit in any free seat; * Otherwise, a passenger should sit in any free seat that has at least one occupied neighboring seat. In other words, a passenger can sit in a seat with index $i$ ($1 \\le i \\le n$) only if at least one of the seats with indices $i-1$ or $i+1$ is occupied. \n\nToday, $n$ passengers boarded the bus. The array $a$ chronologically records the seat numbers they occupied. That is, $a_1$ contains the seat number where the first passenger sat, $a_2$ β€” the seat number where the second passenger sat, and so on.\n\nYou know the contents of the array $a$. Determine whether all passengers followed the recommendations.\n\nFor example, if $n = 5$, and $a$ = [$5, 4, 2, 1, 3$], then the recommendations were not followed, as the $3$-rd passenger sat in seat number $2$, while the neighboring seats with numbers $1$ and $3$ were free.\n\nInput: The first line of input contains a single integer $t$ ($1 \\le t \\le 10^4$) β€” the number of test cases.\n\nThe following describes the input test cases.\n\nThe first line of each test case contains exactly one integer $n$ ($1 \\le n \\le 2 \\cdot 10^5$) β€” the number of seats in the bus and the number of passengers who boarded the bus.\n\nThe second line of each test case contains $n$ distinct integers $a_i$ ($1 \\le a_i \\le n$) β€” the seats that the passengers occupied in chronological order.\n\nIt is guaranteed that the sum of $n$ values across all test cases does not exceed $2 \\cdot 10^5$, and that no passenger sits in an already occupied seat.\n\nOutput: For each test case, output on a separate line:\n\n * \"YES\", if all passengers followed the recommendations; * \"NO\" otherwise. \n\nYou may output the answer in any case (for example, the strings \"yEs\", \"yes\", \"Yes\", and \"YES\" will be recognized as a positive answer).\n\nExamples:\ninput:\n4\n5\n5 4 2 1 3\n3\n2 3 1\n4\n2 3 1 4\n5\n1 2 3 5 4\noutput:\nNO\nYES\nYES\nNO\n\nNote: The first test case is explained in the problem statement.\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "2000B", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Removals Game\ntime_limit_ms: 1000\nmemory_limit_mb: 256\nDescription: Alice got a permutation $a_1, a_2, \\ldots, a_n$ of $[1,2,\\ldots,n]$, and Bob got another permutation $b_1, b_2, \\ldots, b_n$ of $[1,2,\\ldots,n]$. They are going to play a game with these arrays.\n\nIn each turn, the following events happen in order:\n\n * Alice chooses either the first or the last element of her array and removes it from the array; * Bob chooses either the first or the last element of his array and removes it from the array. \n\nThe game continues for $n-1$ turns, after which both arrays will have exactly one remaining element: $x$ in the array $a$ and $y$ in the array $b$.\n\nIf $x=y$, Bob wins; otherwise, Alice wins. Find which player will win if both players play optimally.\n\nInput: Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1\\le t\\le10^4$). The description of the test cases follows.\n\nThe first line of each test case contains a single integer $n$ ($1\\le n\\le 3\\cdot 10^5$).\n\nThe next line contains $n$ integers $a_1,a_2,\\ldots,a_n$ ($1\\le a_i\\le n$, all $a_i$ are distinct) β€” the permutation of Alice.\n\nThe next line contains $n$ integers $b_1,b_2,\\ldots,b_n$ ($1\\le b_i\\le n$, all $b_i$ are distinct) β€” the permutation of Bob.\n\nIt is guaranteed that the sum of all $n$ does not exceed $3\\cdot 10^5$.\n\nOutput: For each test case, print a single line with the name of the winner, assuming both players play optimally. If Alice wins, print $\\texttt{Alice}$; otherwise, print $\\texttt{Bob}$.\n\nExamples:\ninput:\n2\n2\n1 2\n1 2\n3\n1 2 3\n2 3 1\noutput:\nBob\nAlice\n\nNote: In the first test case, Bob can win the game by deleting the same element as Alice did.\n\nIn the second test case, Alice can delete $3$ in the first turn, and then in the second turn, delete the element that is different from the one Bob deleted in the first turn to win the game.\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "2002B", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Sakurako and Chefir\ntime_limit_ms: 4000\nmemory_limit_mb: 256\nDescription: Given a tree with $n$ vertices rooted at vertex $1$. While walking through it with her cat Chefir, Sakurako got distracted, and Chefir ran away.\n\nTo help Sakurako, Kosuke recorded his $q$ guesses. In the $i$-th guess, he assumes that Chefir got lost at vertex $v_i$ and had $k_i$ stamina.\n\nAlso, for each guess, Kosuke assumes that Chefir could move along the edges an arbitrary number of times:\n\n * from vertex $a$ to vertex $b$, if $a$ is an ancestor$^{\\text{βˆ—}}$ of $b$, the stamina will not change; * from vertex $a$ to vertex $b$, if $a$ is not an ancestor of $b$, then Chefir's stamina decreases by $1$. \n\nIf Chefir's stamina is $0$, he cannot make a move of the second type.\n\nFor each assumption, your task is to find the distance to the farthest vertex that Chefir could reach from vertex $v_i$, having $k_i$ stamina.\n\n$^{\\text{βˆ—}}$Vertex $a$ is an ancestor of vertex $b$ if the shortest path from $b$ to the root passes through $a$.\n\nInput: The first line contains a single integer $t$ ($1\\le t\\le 10^4$) β€” the number of test cases.\n\nEach test case is described as follows:\n\n * The first line contains a single integer $n$ ($2 \\le n \\le 2 \\cdot 10^5$) β€” the number of vertices in the tree. * The next $n-1$ lines contain the edges of the tree. It is guaranteed that the given edges form a tree. * The next line consists of a single integer $q$ $(1\\le q\\le 2 \\cdot 10^5)$, which denotes the number of guesses made by Kosuke. * The next $q$ lines describe the guesses made by Kosuke, with two integers $v_i$, $k_i$ $(1\\le v_i \\le n, 0 \\le k_i\\le n)$. \n\nIt is guaranteed that the sum of $n$ and the sum of $q$ across all test cases does not exceed $2\\cdot 10^5$.\n\nOutput: For each test case and for each guess, output the maximum distance to the farthest vertex that Chefir could reach from the starting point $v_i$ having $k_i$ stamina.\n\nExamples:\ninput:\n3\n5\n1 2\n2 3\n3 4\n3 5\n3\n5 1\n3 1\n2 0\n9\n8 1\n1 7\n1 4\n7 3\n4 9\n3 2\n1 5\n3 6\n7\n6 0\n2 3\n6 2\n8 2\n2 4\n9 2\n6 3\n6\n2 1\n2 5\n2 4\n5 6\n4 3\n3\n3 1\n1 3\n6 5\noutput:\n2 1 2 \n0 5 2 4 5 5 5 \n1 3 4\n\nNote: In the first example:\n\n * In the first query, you can go from vertex $5$ to vertex $3$ (after which your stamina will decrease by $1$ and become $0$), and then you can go to vertex $4$; * In the second query, from vertex $3$ with $1$ stamina, you can only reach vertices $2$, $3$, $4$, and $5$; * In the third query, from vertex $2$ with $0$ stamina, you can only reach vertices $2$, $3$, $4$, and $5$;\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "2033G", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Yet Another Real Number Problem\ntime_limit_ms: 2000\nmemory_limit_mb: 256\nDescription: Three r there are's in strawberry.\n\nYou are given an array $b$ of length $m$. You can perform the following operation any number of times (possibly zero):\n\n * Choose two distinct indices $i$ and $j$ where $\\bf{1\\le i < j\\le m}$ and $b_i$ is even, divide $b_i$ by $2$ and multiply $b_j$ by $2$. \n\nYour task is to maximize the sum of the array after performing any number of such operations. Since it could be large, output this sum modulo $10^9+7$.\n\nSince this problem is too easy, you are given an array $a$ of length $n$ and need to solve the problem for each prefix of $a$.\n\nIn other words, denoting the maximum sum of $b$ after performing any number of such operations as $f(b)$, you need to output $f([a_1])$, $f([a_1,a_2])$, $\\ldots$, $f([a_1,a_2,\\ldots,a_n])$ modulo $10^9+7$ respectively.\n\nInput: The first line contains a single integer $t$ ($1\\le t\\le 10^4$) β€” the number of test cases.\n\nThe first line of each test case contains a single integer $n$ ($1 \\le n \\le 2 \\cdot 10^5$) β€” the length of $a$.\n\nThe second line contains $n$ integers $a_1, a_2, \\ldots, a_n$ ($1 \\le a_i \\le 10^9$) β€” the starting values of array $a$.\n\nIt is guaranteed that the sum of $n$ over all test cases will not exceed $2 \\cdot 10^5$.\n\nOutput: For each test case, output $n$ integers representing the answer for each prefix of $a$ modulo $10^9+7$.\n\nExamples:\ninput:\n3\n10\n1 2 3 4 5 6 7 8 9 10\n11\n1 6 9 4 7 4 4 10 3 2 3\n4\n527792568 502211460 850237282 374773208\noutput:\n1 3 8 13 46 59 126 149 1174 1311 \n1 7 22 26 70 74 150 1303 1306 1308 1568 \n527792568 83665723 399119771 773892979\n\nNote: For each prefix in the first example, a possible array after operations is:\n\n * $[1]$ and the sum is $1$; * $[1, 2]$ and the sum is $3$; * $[1, 1, 6]$ and the sum is $8$; * $[1, 1, 3, 8]$ and the sum is $13$; * $[1, 1, 3, 1, 40]$ and the sum is $46$; * $[1, 1, 3, 1, 5, 48]$ and the sum is $59$; * $[1, 1, 3, 1, 5, 3, 112]$ and the sum is $126$; * $[1, 1, 3, 1, 5, 3, 7, 128]$ and the sum is $149$; * $[1, 1, 3, 1, 5, 3, 7, 1, 1152]$ and the sum is $1174$; * $[1, 1, 3, 1, 5, 3, 7, 1, 9, 1280]$ and the sum is $1311$.\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "2035D", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Best Subsequence\ntime_limit_ms: 2000\nmemory_limit_mb: 256\nDescription: Given an integer array $a$ of size $n$.\n\nLet's define the value of the array as its size minus the number of set bits in the bitwise OR of all elements of the array.\n\nFor example, for the array $[1, 0, 1, 2]$, the bitwise OR is $3$ (which contains $2$ set bits), and the value of the array is $4-2=2$.\n\nYour task is to calculate the maximum possible value of some subsequence of the given array.\n\nInput: The first line contains a single integer $t$ ($1 \\le t \\le 100$) β€” the number of test cases.\n\nThe first line of each test case contains a single integer $n$ ($1 \\le n \\le 100$).\n\nThe second line of each test case contains $n$ integers $a_1, a_2, \\dots, a_n$ ($0 \\le a_i < 2^{60}$).\n\nOutput: For each test case, print the maximum possible value of some subsequence of the given array.\n\nExamples:\ninput:\n4\n3\n0 0 0\n4\n1 0 1 2\n1\n5\n8\n7 1 48 14 13 8 7 6\noutput:\n3\n2\n0\n3\n\nNote: \n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "2026E", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Cosmic Rays\ntime_limit_ms: 2000\nmemory_limit_mb: 512\nDescription: Given an array of integers $s_1, s_2, \\ldots, s_l$, every second, cosmic rays will cause all $s_i$ such that $i=1$ or $s_i\\neq s_{i-1}$ to be deleted simultaneously, and the remaining parts will be concatenated together in order to form the new array $s_1, s_2, \\ldots, s_{l'}$.\n\nDefine the strength of an array as the number of seconds it takes to become empty.\n\nYou are given an array of integers compressed in the form of $n$ pairs that describe the array left to right. Each pair $(a_i,b_i)$ represents $a_i$ copies of $b_i$, i.e. $\\underbrace{b_i,b_i,\\cdots,b_i}_{a_i\\textrm{ times}}$.\n\nFor each $i=1,2,\\dots,n$, please find the strength of the sequence described by the first $i$ pairs.\n\nInput: Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1\\le t\\le10^4$). The description of the test cases follows.\n\nThe first line of each test case contains a single integer $n$ ($1\\le n\\le3\\cdot10^5$) β€” the length of sequence $a$.\n\nThe next $n$ lines contain two integers each $a_i$, $b_i$ ($1\\le a_i\\le10^9,0\\le b_i\\le n$) β€” the pairs which describe the sequence.\n\nIt is guaranteed that the sum of all $n$ does not exceed $3\\cdot10^5$.\n\nIt is guaranteed that for all $1\\le i<n$, $b_i\\neq b_{i+1}$ holds.\n\nOutput: For each test case, print one line containing $n$ integers β€” the answer for each prefix of pairs.\n\nExamples:\ninput:\n4\n4\n2 0\n1 1\n3 0\n5 1\n6\n4 6\n1 3\n4 6\n4 0\n7 6\n6 3\n7\n9 0\n7 1\n5 0\n7 1\n9 0\n1 1\n2 0\n10\n10 7\n4 9\n2 2\n7 9\n2 8\n8 5\n11 7\n15 5\n12 7\n4 0\noutput:\n2 2 4 5 \n4 4 7 7 10 10 \n9 9 9 9 9 9 10 \n10 10 10 10 10 10 12 15 15 15\n\nNote: In the first test case, for the prefix of length $4$, the changes will be $[0,0,1,0,0,0,1,1,1,1,1]\\rightarrow[0,0,0,1,1,1,1]\\rightarrow[0,0,1,1,1]\\rightarrow[0,1,1]\\rightarrow[1]\\rightarrow[]$, so the array becomes empty after $5$ seconds.\n\nIn the second test case, for the prefix of length $4$, the changes will be $[6,6,6,6,3,6,6,6,6,0,0,0,0]\\rightarrow[6,6,6,6,6,6,0,0,0]\\rightarrow[6,6,6,6,6,0,0]\\rightarrow[6,6,6,6,0]\\rightarrow[6,6,6]\\rightarrow[6,6]\\rightarrow[6]\\rightarrow[]$, so the array becomes empty after $7$ seconds.\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "2002E", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Mathematical Problem\ntime_limit_ms: 2000\nmemory_limit_mb: 256\nDescription: You are given a string $s$ of length $n > 1$, consisting of digits from $0$ to $9$. You must insert exactly $n - 2$ symbols $+$ (addition) or $\\times$ (multiplication) into this string to form a valid arithmetic expression.\n\nIn this problem, the symbols cannot be placed before the first or after the last character of the string $s$, and two symbols cannot be written consecutively. Also, note that the order of the digits in the string cannot be changed. Let's consider $s = 987009$:\n\n * From this string, the following arithmetic expressions can be obtained: $9 \\times 8 + 70 \\times 0 + 9 = 81$, $98 \\times 7 \\times 0 + 0 \\times 9 = 0$, $9 + 8 + 7 + 0 + 09 = 9 + 8 + 7 + 0 + 9 = 33$. Note that the number $09$ is considered valid and is simply transformed into $9$. * From this string, the following arithmetic expressions cannot be obtained: $+9 \\times 8 \\times 70 + 09$ (symbols should only be placed between digits), $98 \\times 70 + 0 + 9$ (since there are $6$ digits, there must be exactly $4$ symbols).\n\nThe result of the arithmetic expression is calculated according to the rules of mathematics β€” first all multiplication operations are performed, then addition. You need to find the minimum result that can be obtained by inserting exactly $n - 2$ addition or multiplication symbols into the given string $s$.\n\nInput: Each test consists of multiple test cases. The first line contains a single integer $t$ ($1 \\leq t \\leq 10^4$) β€” the number of test cases. Then follows their description.\n\nThe first line of each test case contains a single integer $n$ ($2 \\leq n \\leq 20$) β€” the length of the string $s$.\n\nThe second line of each test case contains a string $s$ of length $n$, consisting of digits from $0$ to $9$.\n\nOutput: For each test case, output the minimum result of the arithmetic expression that can be obtained by inserting exactly $n - 2$ addition or multiplication symbols into the given string.\n\nExamples:\ninput:\n18\n2\n10\n2\n74\n2\n00\n2\n01\n3\n901\n3\n101\n5\n23311\n6\n987009\n7\n1111111\n20\n99999999999999999999\n20\n00000000000000000000\n4\n0212\n18\n057235283621345395\n4\n1112\n20\n19811678487321784121\n4\n1121\n4\n2221\n3\n011\noutput:\n10\n74\n0\n1\n9\n1\n19\n0\n11\n261\n0\n0\n0\n12\n93\n12\n24\n0\n\nNote: In the first four test cases, we cannot add symbols, so the answer will be the original number.\n\nIn the fifth test case, the optimal answer looks as follows: $9 \\times 01 = 9 \\times 1 = 9$.\n\nIn the sixth test case, the optimal answer looks as follows: $1 \\times 01 = 1 \\times 1 = 1$.\n\nIn the seventh test case, the optimal answer looks as follows: $2 + 3 + 3 + 11 = 19$.\n\nIn the eighth test case, one of the optimal answers looks as follows: $98 \\times 7 \\times 0 + 0 \\times 9 = 0$.\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "1986D", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Sakurako's Exam\ntime_limit_ms: 1000\nmemory_limit_mb: 256\nDescription: Today, Sakurako has a math exam. The teacher gave the array, consisting of $a$ ones and $b$ twos.\n\nIn an array, Sakurako must place either a '+' or a '-' in front of each element so that the sum of all elements in the array equals $0$.\n\nSakurako is not sure if it is possible to solve this problem, so determine whether there is a way to assign signs such that the sum of all elements in the array equals $0$.\n\nInput: The first line contains a single integer $t$ ($1\\le t\\le 100$) β€” the number of test cases.\n\nThe only line of each test case contains two integers $a$ and $b$ ($0\\le a,b<10$) β€” the number of '1's and the number of '2's in the array.\n\nOutput: For each test case, output \"Yes\" if you can make the sum of the entire array equal to $0$, and \"No\" otherwise.\n\nYou can output each letter in any case (lowercase or uppercase). For example, the strings \"yEs\", \"yes\", \"Yes\", and \"YES\" will be accepted as a positive answer.\n\nExamples:\ninput:\n5\n0 1\n0 3\n2 0\n2 3\n3 1\noutput:\nNO\nNO\nYES\nYES\nNO\n\nNote: 1. $a=0$, $b=1$: This means the array is $[2]$ β€” it is impossible to add the signs '+' or '-' to get $0$ as a result; 2. $a=0$, $b=3$: This means the array is $[2, 2, 2]$ β€” it is impossible to add the signs '+' or '-' to get $0$ as a result; 3. $a=2$, $b=0$: This means the array is $[1, 1]$ β€” it is possible to add the signs '+' or '-' to get $0$ as a result ($+1-1=0$); 4. $a=2$, $b=3$: This means the array is $[1, 1, 2, 2, 2]$ β€” it is possible to add the signs '+' or '-' to get $0$ as a result ($+1+1-2-2+2=0$);\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "2008A", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: DFS Checker (Easy Version)\ntime_limit_ms: 2000\nmemory_limit_mb: 512\nDescription: This is the easy version of the problem. In this version, the given tree is a perfect binary tree and the constraints on $n$ and $q$ are lower. You can make hacks only if both versions of the problem are solved.\n\nYou are given a perfect binary tree$^\\dagger$ consisting of $n$ vertices. The vertices are numbered from $1$ to $n$, and the root is the vertex $1$. You are also given a permutation $p_1, p_2, \\ldots, p_n$ of $[1,2,\\ldots,n]$.\n\nYou need to answer $q$ queries. For each query, you are given two integers $x$, $y$; you need to swap $p_x$ and $p_y$ and determine if $p_1, p_2, \\ldots, p_n$ is a valid DFS order$^\\ddagger$ of the given tree.\n\nPlease note that the swaps are persistent through queries.\n\n$^\\dagger$ A perfect binary tree is a tree with vertex $1$ as its root, with size $n=2^k-1$ for a positive integer $k$, and where the parent of each vertex $i$ ($1<i\\le n$) is $\\left\\lfloor\\frac{i}{2}\\right\\rfloor$. Thus, all leaves of this tree are at a distance $k - 1$ from the root.\n\n$^\\ddagger$ A DFS order is found by calling the following $\\texttt{dfs}$ function on the given tree.\n\n dfs_order = [] function dfs(v): append v to the back of dfs_order pick an arbitrary permutation s of children of v for child in s: dfs(child) dfs(1) \n\nNote that the DFS order is not unique.\n\nInput: Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1\\le t\\le10^4$). The description of the test cases follows.\n\nThe first line of each test case contains two integers $n$, $q$ ($3\\le n\\le 65\\,535$, $2\\le q\\le 5 \\cdot 10^4$) β€” the number of vertices in the tree and the number of queries. It is guaranteed that $n=2^k-1$ for a positive integer $k$.\n\nThe next line contains $n-1$ integers $a_2,a_3,\\ldots,a_n$ ($1\\le a_i<i$) β€” the parent of each vertex in the given tree. It is guaranteed that $a_i=\\left\\lfloor\\frac{i}{2}\\right\\rfloor$.\n\nThe next line contains $n$ integers $p_1,p_2,\\ldots,p_n$ ($1\\le p_i\\le n$, all $p_i$ are distinct) β€” the initial permutation $p$.\n\nThe next $q$ lines each contain two integers $x$, $y$ ($1\\le x,y\\le n,x\\neq y$) β€” the positions of the elements to swap in the permutation.\n\nIt is guaranteed that the sum of all $n$ does not exceed $65\\,535$, and the sum of all $q$ does not exceed $5 \\cdot 10^4$.\n\nOutput: For each test case, print $q$ lines corresponding to the $q$ queries. For each query, output $\\texttt{YES}$ if there is a DFS order that exactly equals the current permutation, and output $\\texttt{NO}$ otherwise.\n\nYou can output $\\texttt{Yes}$ and $\\texttt{No}$ in any case (for example, strings $\\texttt{yEs}$, $\\texttt{yes}$, $\\texttt{Yes}$ and $\\texttt{YES}$ will be recognized as a positive response).\n\nExamples:\ninput:\n2\n3 3\n1 1\n1 2 3\n2 3\n3 2\n1 3\n7 4\n1 1 2 2 3 3\n1 2 3 4 5 6 7\n3 5\n2 5\n3 7\n4 6\noutput:\nYES\nYES\nNO\nYES\nNO\nNO\nYES\n\nNote: In the first test case, the permutation $p_1, p_2, \\ldots, p_n$ after each modification is $[1,3,2],[1,2,3],[3,2,1]$, respectively. The first two permutations are valid DFS orders; the third is not a DFS order.\n\nIn the second test case, the permutation $p_1, p_2, \\ldots, p_n$ after each modification is $[1,2,5,4,3,6,7],[1,3,5,4,2,6,7],[1,3,7,4,2,6,5],[1,3,7,6,2,4,5]$, respectively.\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "2002D1", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Alter the GCD\ntime_limit_ms: 4000\nmemory_limit_mb: 256\nDescription: You are given two arrays $a_1, a_2, \\ldots, a_n$ and $b_1, b_2, \\ldots, b_n$.\n\nYou must perform the following operation exactly once:\n\n * choose any indices $l$ and $r$ such that $1 \\le l \\le r \\le n$; * swap $a_i$ and $b_i$ for all $i$ such that $l \\leq i \\leq r$. \n\nFind the maximum possible value of $\\text{gcd}(a_1, a_2, \\ldots, a_n) + \\text{gcd}(b_1, b_2, \\ldots, b_n)$ after performing the operation exactly once. Also find the number of distinct pairs $(l, r)$ which achieve the maximum value.\n\nInput: In the first line of the input, you are given a single integer $t$ ($1 \\le t \\le 10^5$), the number of test cases. Then the description of each test case follows.\n\nIn the first line of each test case, you are given a single integer $n$ ($1 \\le n \\le 2 \\cdot 10^5$), representing the number of integers in each array.\n\nIn the next line, you are given $n$ integers $a_1, a_2, \\ldots, a_n$ ($1 \\le a_i \\le 10^9$) β€” the elements of the array $a$.\n\nIn the last line, you are given $n$ integers $b_1, b_2, \\ldots, b_n$ ($1 \\le b_i \\le 10^9$) β€” the elements of the array $b$.\n\nThe sum of values of $n$ over all test cases does not exceed $5 \\cdot 10^5$.\n\nOutput: For each test case, output a line with two integers: the maximum value of $\\text{gcd}(a_1, a_2, \\ldots, a_n) + \\text{gcd}(b_1, b_2, \\ldots, b_n)$ after performing the operation exactly once, and the number of ways.\n\nExamples:\ninput:\n5\n8\n11 4 16 17 3 24 25 8\n8 10 4 21 17 18 25 21\n4\n6 4 24 13\n15 3 1 14\n2\n13 14\n5 8\n8\n20 17 15 11 21 10 3 7\n9 9 4 20 14 9 13 1\n2\n18 13\n15 20\noutput:\n2 36\n3 2\n2 3\n2 36\n6 1\n\nNote: In the first, third, and fourth test cases, there's no way to achieve a higher GCD than $1$ in any of the arrays, so the answer is $1 + 1 = 2$. Any pair $(l, r)$ achieves the same result; for example, in the first test case there are $36$ such pairs.\n\nIn the last test case, you must choose $l = 1$, $r = 2$ to maximize the answer. In this case, the GCD of the first array is $5$, and the GCD of the second array is $1$, so the answer is $5 + 1 = 6$, and the number of ways is $1$.\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "2005D", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Verify Password\ntime_limit_ms: 2000\nmemory_limit_mb: 256\nDescription: Monocarp is working on his new site, and the current challenge is to make the users pick strong passwords.\n\nMonocarp decided that strong passwords should satisfy the following conditions:\n\n * password should consist only of lowercase Latin letters and digits; * there should be no digit that comes after a letter (so, after each letter, there is either another letter or the string ends); * all digits should be sorted in the non-decreasing order; * all letters should be sorted in the non-decreasing order. \n\nNote that it's allowed for the password to have only letters or only digits.\n\nMonocarp managed to implement the first condition, but he struggles with the remaining ones. Can you help him to verify the passwords?\n\nInput: The first line contains a single integer $t$ ($1 \\le t \\le 1000$) β€” the number of testcases.\n\nThe first line of each testcase contains a single integer $n$ ($1 \\le n \\le 20$) β€” the length of the password.\n\nThe second line contains a string, consisting of exactly $n$ characters. Each character is either a lowercase Latin letter or a digit.\n\nOutput: For each testcase, print \"YES\" if the given password is strong and \"NO\" otherwise.\n\nExamples:\ninput:\n5\n4\n12ac\n5\n123wa\n9\nallllmost\n5\nac123\n6\n011679\noutput:\nYES\nNO\nYES\nNO\nYES\n\nNote: In the second testcase, the letters are not sorted in the non-decreasing order.\n\nIn the fourth testcase, there is a digit that comes after a letter β€” digit '1' after a letter 'c'.\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "1976A", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Beautiful Array\ntime_limit_ms: 2000\nmemory_limit_mb: 256\nDescription: You are given an array of integers $a_1, a_2, \\ldots, a_n$ and an integer $k$. You need to make it beautiful with the least amount of operations.\n\nBefore applying operations, you can shuffle the array elements as you like. For one operation, you can do the following:\n\n * Choose an index $1 \\leq i \\leq n$, * Make $a_i = a_i + k$.\n\nThe array $b_1, b_2, \\ldots, b_n$ is beautiful if $b_i = b_{n - i + 1}$ for all $1 \\leq i \\leq n$.\n\nFind the minimum number of operations needed to make the array beautiful, or report that it is impossible.\n\nInput: Each test consists of several sets of input data. The first line contains a single integer $t$ ($1 \\leq t \\leq 10^4$) β€” the number of sets of input data. Then follows their description.\n\nThe first line of each set of input data contains two integers $n$ and $k$ ($1 \\leq n \\leq 10^5$, $1 \\leq k \\leq 10^9$) β€” the size of the array $a$ and the number $k$ from the problem statement.\n\nThe second line of each set of input data contains $n$ integers $a_1, a_2, \\ldots, a_n$ ($1 \\leq a_i \\leq 10^9$) β€” the elements of the array $a$.\n\nIt is guaranteed that the sum of $n$ over all sets of input data does not exceed $2 \\cdot 10^5$.\n\nOutput: For each set of input data, output the minimum number of operations needed to make the array beautiful, or $-1$ if it is impossible.\n\nExamples:\ninput:\n11\n1 1000000000\n1\n2 1\n624323799 708290323\n3 1\n3 2 1\n4 1\n7 1 5 3\n5 1\n11 2 15 7 10\n7 1\n1 8 2 16 8 16 31\n13 1\n2 1 1 3 3 11 12 22 45 777 777 1500 74\n10 2\n1 2 1 2 1 2 1 2 1 2\n11 2\n1 2 1 2 1 2 1 2 1 2 1\n13 3\n2 3 9 14 17 10 22 20 18 30 1 4 28\n5 1\n2 3 5 3 5\noutput:\n0\n83966524\n1\n4\n6\n1\n48\n-1\n0\n14\n0\n\nNote: In the first set of input data, the array is already beautiful.\n\nIn the second set of input data, you can shuffle the array before the operations and perform the operation with index $i = 1$ for $83966524$ times.\n\nIn the third set of input data, you can shuffle the array $a$ and make it equal to $[2, 3, 1]$. Then apply the operation with index $i = 3$ to get the array $[2, 3, 2]$, which is beautiful.\n\nIn the eighth set of input data, there is no set of operations and no way to shuffle the elements to make the array beautiful.\n\nIn the ninth set of input data, the array is already beautiful.\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "1986E", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Spinning Round (Hard Version)\ntime_limit_ms: 7000\nmemory_limit_mb: 1024\nDescription: This is the hard version of the problem. The only difference between the two versions are the allowed characters in $s$. You can make hacks only if both versions of the problem are solved.\n\nYou are given a permutation $p$ of length $n$. You are also given a string $s$ of length $n$, where each character is either L, R, or ?.\n\nFor each $i$ from $1$ to $n$:\n\n * Define $l_i$ as the largest index $j < i$ such that $p_j > p_i$. If there is no such index, $l_i := i$. * Define $r_i$ as the smallest index $j > i$ such that $p_j > p_i$. If there is no such index, $r_i := i$. \n\nInitially, you have an undirected graph with $n$ vertices (numbered from $1$ to $n$) and no edges. Then, for each $i$ from $1$ to $n$, add one edge to the graph:\n\n * If $s_i =$ L, add the edge $(i, l_i)$ to the graph. * If $s_i =$ R, add the edge $(i, r_i)$ to the graph. * If $s_i =$ ?, either add the edge $(i, l_i)$ or the edge $(i, r_i)$ to the graph at your choice. \n\nFind the maximum possible diameter over all connected$^{\\text{βˆ—}}$ graphs that you can form. Output $-1$ if it is not possible to form any connected graphs.\n\n$^{\\text{βˆ—}}$ Let $d(s, t)$ denote the smallest number of edges on any path between $s$ and $t$.\n\nThe diameter of the graph is defined as the maximum value of $d(s, t)$ over all pairs of vertices $s$ and $t$.\n\nInput: Each test contains multiple test cases. The first line of input contains a single integer $t$ ($1 \\le t \\le 2 \\cdot 10^4$) β€” the number of test cases. The description of the test cases follows.\n\nThe first line of each test case contains a single integer $n$ ($2 \\le n \\le 4 \\cdot 10^5$) β€” the length of the permutation $p$.\n\nThe second line of each test case contains $n$ integers $p_1,p_2,\\ldots, p_n$ ($1 \\le p_i \\le n$) β€” the elements of $p$, which are guaranteed to form a permutation.\n\nThe third line of each test case contains a string $s$ of length $n$. It is guaranteed that it consists only of the characters L, R, and ?.\n\nIt is guaranteed that the sum of $n$ over all test cases does not exceed $4 \\cdot 10^5$.\n\nOutput: For each test case, output the maximum possible diameter over all connected graphs that you form, or $-1$ if it is not possible to form any connected graphs.\n\nExamples:\ninput:\n8\n5\n2 1 4 3 5\nR?RL?\n2\n1 2\nLR\n3\n3 1 2\nL?R\n7\n5 3 1 6 4 2 7\n?R?R?R?\n5\n5 2 1 3 4\n?????\n6\n6 2 3 4 5 1\n?LLRLL\n8\n1 7 5 6 2 8 4 3\n?R??????\n12\n6 10 7 1 8 5 12 2 11 3 4 9\n????????????\noutput:\n3\n-1\n-1\n4\n4\n3\n5\n8\n\nNote: In the first test case, there are two connected graphs (the labels are indices):\n\n![](CDN_BASE_URL/4561c9025a4357785c7aff0bb1bbff9a)| ![](CDN_BASE_URL/a680f9e3bffa38fd90dd7bbc4c3e5f3b) ---|--- The graph on the left has a diameter of $2$, while the graph on the right has a diameter of $3$, so the answer is $3$.\n\nIn the second test case, there are no connected graphs, so the answer is $-1$.\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "1987G2", "task_type": "TestCase-Eval-Task1" }
[ { "content": "**Task:**\nGenerate a challenging test input for the algorithm problem:\nTitle: Sakurako, Kosuke, and the Permutation\ntime_limit_ms: 2000\nmemory_limit_mb: 256\nDescription: Sakurako's exams are over, and she did excellently. As a reward, she received a permutation $p$. Kosuke was not entirely satisfied because he failed one exam and did not receive a gift. He decided to sneak into her room (thanks to the code for her lock) and spoil the permutation so that it becomes simple.\n\nA permutation $p$ is considered simple if for every $i$ $(1\\le i \\le n)$ one of the following conditions holds:\n\n * $p_i=i$ * $p_{p_i}=i$ \n\nFor example, the permutations $[1, 2, 3, 4]$, $[5, 2, 4, 3, 1]$, and $[2, 1]$ are simple, while $[2, 3, 1]$ and $[5, 2, 1, 4, 3]$ are not.\n\nIn one operation, Kosuke can choose indices $i,j$ $(1\\le i,j\\le n)$ and swap the elements $p_i$ and $p_j$.\n\nSakurako is about to return home. Your task is to calculate the minimum number of operations that Kosuke needs to perform to make the permutation simple.\n\nInput: The first line contains one integer $t$ ($1\\le t\\le 10^4$) β€” the number of test cases.\n\nEach test case is described by two lines.\n\n * The first line contains one integer $n$ ($1\\le n \\le 10^6$) β€” the length of the permutation $p$. * The second line contains $n$ integers $p_i$ ($1\\le p_i\\le n$) β€” the elements of the permutation $p$. \n\nIt is guaranteed that the sum of $n$ across all test cases does not exceed $10^6$.\n\nIt is guaranteed that $p$ is a permutation.\n\nOutput: For each test case, output the minimum number of operations that Kosuke needs to perform to make the permutation simple.\n\nExamples:\ninput:\n6\n5\n1 2 3 4 5\n5\n5 4 3 2 1\n5\n2 3 4 5 1\n4\n2 3 4 1\n3\n1 3 2\n7\n2 3 1 5 6 7 4\noutput:\n0\n0\n2\n1\n0\n2\n\nNote: In the first and second examples, the permutations are already simple.\n\nIn the fourth example, it is sufficient to swap $p_2$ and $p_4$. Thus, the permutation will become $[2, 1, 4, 3]$ in $1$ operation.\n\n\n**Instructions:**\n- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.\n- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.\n- Output the test input directly, not code to generate it.\n\n\n**Output format:**\n```plaintext\n{test input}\n```\n\n\nThink step by step.", "role": "user" } ]
TestCase-Eval-Task1
TestCase-Eval
null
{ "problem_id": "2033E", "task_type": "TestCase-Eval-Task1" }