Dataset Viewer
text
stringlengths 0
801
|
---|
There are $n$ coins on the table forming a circle, and each coin is either facing up or facing down. Alice and Bob take turns to play the following game, and Alice goes first. |
In each operation, the player chooses a facing-up coin, removes the coin, and flips the two coins that are adjacent to it. If (before the operation) there are only two coins left, then one will be removed and the other won't be flipped (as it would be flipped twice). If (before the operation) there is only one coin left, no coins will be flipped. If (before the operation) there are no facing-up coins, the player loses. |
Decide who will win the game if they both play optimally. It can be proved that the game will end in a finite number of operations, and one of them will win. |
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. |
The first line of each test case contains only one positive integer $n$ ($1 \leq n \leq 100$), representing the number of the coins. |
A string $s$ of length $n$ follows on the second line of each test case, containing only "U" and "D", representing that each coin is facing up or facing down. |
For each test case, print "YES" if Alice will win the game, and "NO" otherwise. |
You 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. |
In the first test case, the game may go as follows. |
* Alice chooses the first coin and $s$ becomes "DDUU". * Bob chooses the last coin and $s$ becomes "UDD". * Alice chooses the first coin and $s$ becomes "UU". * Bob chooses the first coin and $s$ becomes "U". * Alice chooses the only coin and $s$ becomes empty. * Bob can't choose any coin now, and he loses the game. |
It can be proved that Bob will always lose if they both play optimally. |
You are given three points with integer coordinates $x_1$, $x_2$, and $x_3$ on the $X$ axis ($1 \leq x_i \leq 10$). You can choose any point with an integer coordinate $a$ on the $X$ axis. Note that the point $a$ may coincide with $x_1$, $x_2$, or $x_3$. Let $f(a)$ be the total distance from the given points to the point $a$. Find the smallest value of $f(a)$. |
The distance between points $a$ and $b$ is equal to $|a - b|$. For example, the distance between points $a = 5$ and $b = 2$ is $3$. |
Each test consists of multiple test cases. The first line contains a single integer $t$ ($1 \leq t \leq 10^3$) β the number of test cases. Then follows their descriptions. |
The single line of each test case contains three integers $x_1$, $x_2$, and $x_3$ ($1 \leq x_i \leq 10$) β the coordinates of the points. |
For each test case, output the smallest value of $f(a)$. |
In the first test case, the smallest value of $f(a)$ is achieved when $a = 1$: $f(1) = |1 - 1| + |1 - 1| + |1 - 1| = 0$. |
In the second test case, the smallest value of $f(a)$ is achieved when $a = 5$: $f(5) = |1 - 5| + |5 - 5| + |9 - 5| = 8$. |
In the third test case, the smallest value of $f(a)$ is achieved when $a = 8$: $f(8) = |8 - 8| + |2 - 8| + |8 - 8| = 6$. |
In the fourth test case, the smallest value of $f(a)$ is achieved when $a = 9$: $f(10) = |10 - 9| + |9 - 9| + |3 - 9| = 7$. |
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}$. |
Consider the algorithm for stabilizing matrix $a$: |
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$. |
In this problem, cells $(a, b)$ and $(c, d)$ are considered neighbors if they share a common side, i.e., $|a - c| + |b - d| = 1$. |
Your 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. |
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. |
The 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$. |
The 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$). |
It is guaranteed that the sum of $n \cdot m$ over all sets of input data does not exceed $2 \cdot 10^5$. |
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. |
In the first set of input data, the algorithm will select the cell $(1, 1)$ twice in a row and then terminate. |
 |
In the second set of input data, there is no cell whose value is strictly g |
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. |
Before applying operations, you can shuffle the array elements as you like. For one operation, you can do the following: |
* Choose an index $1 \leq i \leq n$, * Make $a_i = a_i + k$. |
The array $b_1, b_2, \ldots, b_n$ is beautiful if $b_i = b_{n - i + 1}$ for all $1 \leq i \leq n$. |
Find the minimum number of operations needed to make the array beautiful, or report that it is impossible. |
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. |
The 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. |
The 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$. |
It is guaranteed that the sum of $n$ over all sets of input data does not exceed $2 \cdot 10^5$. |
For each set of input data, output the minimum number of operations needed to make the array beautiful, or $-1$ if it is impossible. |
In the first set of input data, the array is already beautiful. |
In 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. |
In 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. |
In the eighth set of input data, there is no set of operations and no way to shuffle the elements to make the array beautiful. |
In the ninth set of input data, the array is already beautiful. |
You are given an array of integers $a$ of length $n$. |
You can apply the following operation any number of times (maybe, zero): |
* First, choose an integer $k$ such that $1 \le k \le n$ and pay $k + 1$ coins. * Then, choose exactly $k$ indices such that $1 \le i_1 < i_2 < \ldots < i_k \le n$. * Then, for each $x$ from $1$ to $k$, increase $a_{i_x}$ by $1$. |
Find the minimum number of coins needed to make $a$ non-decreasing. That is, $a_1 \le a_2 \le \ldots \le a_n$. |
End of preview. Expand
in Data Studio
Compression Test Dataset
This is a dataset for testing the compression ratio of Large language models.
We utilize three datasets for this purpose:
- Math:
HuggingFaceH4/MATH-500
- Code:
Qwen/CodeElo
- General Purpose:
HuggingFaceTB/smollm-corpus
For the third dataset, because the dataset is relatively large, we subsample 500
samples from the dataset. For all datasets, we truncate the data til 2048 tokens.
- Downloads last month
- 115