problem stringlengths 20 3.95k | answer stringclasses 532
values | task stringclasses 6
values | problem_number int64 1 1.31k | set_number int64 1 5 |
|---|---|---|---|---|
You are given a positive integer D.
Find the minimum value of |x^2+y^2-D| for non-negative integers x and y.
Input
The input is given from Standard Input in the following format:
D
Output
Print the answer.
Constraints
- 1\leq D \leq 2\times 10^{12}
- All input values are integers.
Sample Input 1
21
Sample Ou... | LiveCodeBench | 1,133 | 1 | |
You are given a positive integer D.
Find the minimum value of |x^2+y^2-D| for non-negative integers x and y.
Input
The input is given from Standard Input in the following format:
D
Output
Print the answer.
Constraints
- 1\leq D \leq 2\times 10^{12}
- All input values are integers.
Sample Input 1
21
Sample Ou... | LiveCodeBench | 1,133 | 2 | |
You are given a positive integer D.
Find the minimum value of |x^2+y^2-D| for non-negative integers x and y.
Input
The input is given from Standard Input in the following format:
D
Output
Print the answer.
Constraints
- 1\leq D \leq 2\times 10^{12}
- All input values are integers.
Sample Input 1
21
Sample Ou... | LiveCodeBench | 1,133 | 3 | |
You are given an N \times N grid. Let (i,j) denote the cell in the i-th row from the top and the j-th column from the left.
The states of the cells are given by N strings of length N, S_1, S_2, \dots, S_N, in the following format:
- If the j-th character of S_i is o, there is an o written in cell (i,j).
- If the j-th... | LiveCodeBench | 1,134 | 1 | |
You are given an N \times N grid. Let (i,j) denote the cell in the i-th row from the top and the j-th column from the left.
The states of the cells are given by N strings of length N, S_1, S_2, \dots, S_N, in the following format:
- If the j-th character of S_i is o, there is an o written in cell (i,j).
- If the j-th... | LiveCodeBench | 1,134 | 2 | |
You are given an N \times N grid. Let (i,j) denote the cell in the i-th row from the top and the j-th column from the left.
The states of the cells are given by N strings of length N, S_1, S_2, \dots, S_N, in the following format:
- If the j-th character of S_i is o, there is an o written in cell (i,j).
- If the j-th... | LiveCodeBench | 1,134 | 3 | |
You are given a sequence A=(A_1,A_2,\dots,A_N) of length N.
Respond to the following Q queries in the order they are given.
The k-th query is given in the following format:
i_k x_k
- First, change A_{i_k} to x_k. This change will carry over to subsequent queries.
- Then, print the \rm{mex} of A.
- The \rm{mex} of A... | LiveCodeBench | 1,135 | 1 | |
You are given a sequence A=(A_1,A_2,\dots,A_N) of length N.
Respond to the following Q queries in the order they are given.
The k-th query is given in the following format:
i_k x_k
- First, change A_{i_k} to x_k. This change will carry over to subsequent queries.
- Then, print the \rm{mex} of A.
- The \rm{mex} of A... | LiveCodeBench | 1,135 | 2 | |
You are given a sequence A=(A_1,A_2,\dots,A_N) of length N.
Respond to the following Q queries in the order they are given.
The k-th query is given in the following format:
i_k x_k
- First, change A_{i_k} to x_k. This change will carry over to subsequent queries.
- Then, print the \rm{mex} of A.
- The \rm{mex} of A... | LiveCodeBench | 1,135 | 3 | |
In the calendar of AtCoder Kingdom, a year consists of M months from month 1 to month M, and each month consists of D days from day 1 to day D.
What day follows year y, month m, day d in this calendar?
Input
The input is given from Standard Input in the following format:
M D
y m d
Output
If the day following year ... | LiveCodeBench | 1,136 | 1 | |
In the calendar of AtCoder Kingdom, a year consists of M months from month 1 to month M, and each month consists of D days from day 1 to day D.
What day follows year y, month m, day d in this calendar?
Input
The input is given from Standard Input in the following format:
M D
y m d
Output
If the day following year ... | LiveCodeBench | 1,136 | 2 | |
In the calendar of AtCoder Kingdom, a year consists of M months from month 1 to month M, and each month consists of D days from day 1 to day D.
What day follows year y, month m, day d in this calendar?
Input
The input is given from Standard Input in the following format:
M D
y m d
Output
If the day following year ... | LiveCodeBench | 1,136 | 3 | |
A supermarket sells egg packs.
A pack of 6 eggs costs S yen, a pack of 8 eggs costs M yen, and a pack of 12 eggs costs L yen.
When you can buy any number of each pack, find the minimum amount of money required to purchase at least N eggs.
Input
The input is given from Standard Input in the following format:
N S M L
... | LiveCodeBench | 1,137 | 1 | |
A supermarket sells egg packs.
A pack of 6 eggs costs S yen, a pack of 8 eggs costs M yen, and a pack of 12 eggs costs L yen.
When you can buy any number of each pack, find the minimum amount of money required to purchase at least N eggs.
Input
The input is given from Standard Input in the following format:
N S M L
... | LiveCodeBench | 1,137 | 2 | |
A supermarket sells egg packs.
A pack of 6 eggs costs S yen, a pack of 8 eggs costs M yen, and a pack of 12 eggs costs L yen.
When you can buy any number of each pack, find the minimum amount of money required to purchase at least N eggs.
Input
The input is given from Standard Input in the following format:
N S M L
... | LiveCodeBench | 1,137 | 3 | |
You are given a sequence A=(A_1,\ldots,A_N) of length N.
For each i=1,\ldots,N, solve the following problem.
Problem: Find the sum of all elements in A that are greater than A_i.
Input
The input is given from Standard Input in the following format:
N
A_1 \ldots A_N
Output
For each 1\leq k\leq N, let B_k be the ans... | LiveCodeBench | 1,138 | 1 | |
You are given a sequence A=(A_1,\ldots,A_N) of length N.
For each i=1,\ldots,N, solve the following problem.
Problem: Find the sum of all elements in A that are greater than A_i.
Input
The input is given from Standard Input in the following format:
N
A_1 \ldots A_N
Output
For each 1\leq k\leq N, let B_k be the ans... | LiveCodeBench | 1,138 | 2 | |
You are given a sequence A=(A_1,\ldots,A_N) of length N.
For each i=1,\ldots,N, solve the following problem.
Problem: Find the sum of all elements in A that are greater than A_i.
Input
The input is given from Standard Input in the following format:
N
A_1 \ldots A_N
Output
For each 1\leq k\leq N, let B_k be the ans... | LiveCodeBench | 1,138 | 3 | |
There is a grid with 10^9 by 10^9 squares. Let (i, j) denote the square at the (i + 1)-th row from the top and the (j + 1)-th column from the left (0 \leq i, j \lt 10^9). (Note the unusual index assignment.)
Each square is black or white. The color of the square (i, j) is represented by a character P[i \bmod N][j \bmo... | LiveCodeBench | 1,139 | 1 | |
There is a grid with 10^9 by 10^9 squares. Let (i, j) denote the square at the (i + 1)-th row from the top and the (j + 1)-th column from the left (0 \leq i, j \lt 10^9). (Note the unusual index assignment.)
Each square is black or white. The color of the square (i, j) is represented by a character P[i \bmod N][j \bmo... | LiveCodeBench | 1,139 | 2 | |
There is a grid with 10^9 by 10^9 squares. Let (i, j) denote the square at the (i + 1)-th row from the top and the (j + 1)-th column from the left (0 \leq i, j \lt 10^9). (Note the unusual index assignment.)
Each square is black or white. The color of the square (i, j) is represented by a character P[i \bmod N][j \bmo... | LiveCodeBench | 1,139 | 3 | |
AtCoder cafeteria sells meals consisting of a main dish and a side dish.
There are N types of main dishes, called main dish 1, main dish 2, \dots, main dish N. Main dish i costs a_i yen.
There are M types of side dishes, called side dish 1, side dish 2, \dots, side dish M. Side dish i costs b_i yen.
A set meal is com... | LiveCodeBench | 1,140 | 1 | |
AtCoder cafeteria sells meals consisting of a main dish and a side dish.
There are N types of main dishes, called main dish 1, main dish 2, \dots, main dish N. Main dish i costs a_i yen.
There are M types of side dishes, called side dish 1, side dish 2, \dots, side dish M. Side dish i costs b_i yen.
A set meal is com... | LiveCodeBench | 1,140 | 2 | |
AtCoder cafeteria sells meals consisting of a main dish and a side dish.
There are N types of main dishes, called main dish 1, main dish 2, \dots, main dish N. Main dish i costs a_i yen.
There are M types of side dishes, called side dish 1, side dish 2, \dots, side dish M. Side dish i costs b_i yen.
A set meal is com... | LiveCodeBench | 1,140 | 3 | |
AtCoder Inc. sells merchandise through its online shop.
Takahashi has decided to purchase N types of products from there.
For each integer i from 1 to N, the i-th type of product has a price of P_i yen each, and he will buy Q_i of this.
Additionally, he must pay a shipping fee.
The shipping fee is 0 yen if the total pr... | LiveCodeBench | 1,141 | 1 | |
AtCoder Inc. sells merchandise through its online shop.
Takahashi has decided to purchase N types of products from there.
For each integer i from 1 to N, the i-th type of product has a price of P_i yen each, and he will buy Q_i of this.
Additionally, he must pay a shipping fee.
The shipping fee is 0 yen if the total pr... | LiveCodeBench | 1,141 | 2 | |
AtCoder Inc. sells merchandise through its online shop.
Takahashi has decided to purchase N types of products from there.
For each integer i from 1 to N, the i-th type of product has a price of P_i yen each, and he will buy Q_i of this.
Additionally, he must pay a shipping fee.
The shipping fee is 0 yen if the total pr... | LiveCodeBench | 1,141 | 3 | |
AtCoder Inc. sells glasses and mugs.
Takahashi has a glass with a capacity of G milliliters and a mug with a capacity of M milliliters.
Here, G<M.
Initially, both the glass and the mug are empty.
After performing the following operation K times, determine how many milliliters of water are in the glass and the mug, resp... | LiveCodeBench | 1,142 | 1 | |
AtCoder Inc. sells glasses and mugs.
Takahashi has a glass with a capacity of G milliliters and a mug with a capacity of M milliliters.
Here, G<M.
Initially, both the glass and the mug are empty.
After performing the following operation K times, determine how many milliliters of water are in the glass and the mug, resp... | LiveCodeBench | 1,142 | 2 | |
AtCoder Inc. sells glasses and mugs.
Takahashi has a glass with a capacity of G milliliters and a mug with a capacity of M milliliters.
Here, G<M.
Initially, both the glass and the mug are empty.
After performing the following operation K times, determine how many milliliters of water are in the glass and the mug, resp... | LiveCodeBench | 1,142 | 3 | |
AtCoder Inc. sells T-shirts with its logo.
You are given Takahashi's schedule for N days as a string S of length N consisting of 0, 1, and 2.
Specifically, for an integer i satisfying 1\leq i\leq N,
- if the i-th character of S is 0, he has no plan scheduled for the i-th day;
- if the i-th character of S is 1, he plan... | LiveCodeBench | 1,143 | 1 | |
AtCoder Inc. sells T-shirts with its logo.
You are given Takahashi's schedule for N days as a string S of length N consisting of 0, 1, and 2.
Specifically, for an integer i satisfying 1\leq i\leq N,
- if the i-th character of S is 0, he has no plan scheduled for the i-th day;
- if the i-th character of S is 1, he plan... | LiveCodeBench | 1,143 | 2 | |
AtCoder Inc. sells T-shirts with its logo.
You are given Takahashi's schedule for N days as a string S of length N consisting of 0, 1, and 2.
Specifically, for an integer i satisfying 1\leq i\leq N,
- if the i-th character of S is 0, he has no plan scheduled for the i-th day;
- if the i-th character of S is 1, he plan... | LiveCodeBench | 1,143 | 3 | |
You are given two grids, A and B, each with H rows and W columns.
For each pair of integers (i, j) satisfying 1 \leq i \leq H and 1 \leq j \leq W, let (i, j) denote the cell in the i-th row and j-th column. In grid A, cell (i, j) contains the integer A_{i, j}. In grid B, cell (i, j) contains the integer B_{i, j}.
You w... | LiveCodeBench | 1,144 | 1 | |
You are given two grids, A and B, each with H rows and W columns.
For each pair of integers (i, j) satisfying 1 \leq i \leq H and 1 \leq j \leq W, let (i, j) denote the cell in the i-th row and j-th column. In grid A, cell (i, j) contains the integer A_{i, j}. In grid B, cell (i, j) contains the integer B_{i, j}.
You w... | LiveCodeBench | 1,144 | 2 | |
You are given two grids, A and B, each with H rows and W columns.
For each pair of integers (i, j) satisfying 1 \leq i \leq H and 1 \leq j \leq W, let (i, j) denote the cell in the i-th row and j-th column. In grid A, cell (i, j) contains the integer A_{i, j}. In grid B, cell (i, j) contains the integer B_{i, j}.
You w... | LiveCodeBench | 1,144 | 3 | |
You are given an integer N between 1 and 9, inclusive, as input.
Concatenate N copies of the digit N and print the resulting string.
Input
The input is given from Standard Input in the following format:
N
Output
Print the answer.
Constraints
- N is an integer between 1 and 9, inclusive.
Sample Input 1
3
Sampl... | LiveCodeBench | 1,145 | 1 | |
You are given an integer N between 1 and 9, inclusive, as input.
Concatenate N copies of the digit N and print the resulting string.
Input
The input is given from Standard Input in the following format:
N
Output
Print the answer.
Constraints
- N is an integer between 1 and 9, inclusive.
Sample Input 1
3
Sampl... | LiveCodeBench | 1,145 | 2 | |
You are given an integer N between 1 and 9, inclusive, as input.
Concatenate N copies of the digit N and print the resulting string.
Input
The input is given from Standard Input in the following format:
N
Output
Print the answer.
Constraints
- N is an integer between 1 and 9, inclusive.
Sample Input 1
3
Sampl... | LiveCodeBench | 1,145 | 3 | |
A regular pentagon P is shown in the figure below.
Determine whether the length of the line segment connecting points S_1 and S_2 of P equals the length of the line segment connecting points T_1 and T_2.
Input
The input is given from Standard Input in the following format:
S_1S_2
T_1T_2
Output
If the length of th... | LiveCodeBench | 1,146 | 1 | |
A regular pentagon P is shown in the figure below.
Determine whether the length of the line segment connecting points S_1 and S_2 of P equals the length of the line segment connecting points T_1 and T_2.
Input
The input is given from Standard Input in the following format:
S_1S_2
T_1T_2
Output
If the length of th... | LiveCodeBench | 1,146 | 2 | |
A regular pentagon P is shown in the figure below.
Determine whether the length of the line segment connecting points S_1 and S_2 of P equals the length of the line segment connecting points T_1 and T_2.
Input
The input is given from Standard Input in the following format:
S_1S_2
T_1T_2
Output
If the length of th... | LiveCodeBench | 1,146 | 3 | |
A repunit is an integer whose digits are all 1 in decimal representation. The repunits in ascending order are 1, 11, 111, \ldots.
Find the N-th smallest integer that can be expressed as the sum of exactly three repunits.
Input
The input is given from Standard Input in the following format:
N
Output
Print the answer... | LiveCodeBench | 1,147 | 1 | |
A repunit is an integer whose digits are all 1 in decimal representation. The repunits in ascending order are 1, 11, 111, \ldots.
Find the N-th smallest integer that can be expressed as the sum of exactly three repunits.
Input
The input is given from Standard Input in the following format:
N
Output
Print the answer... | LiveCodeBench | 1,147 | 2 | |
A repunit is an integer whose digits are all 1 in decimal representation. The repunits in ascending order are 1, 11, 111, \ldots.
Find the N-th smallest integer that can be expressed as the sum of exactly three repunits.
Input
The input is given from Standard Input in the following format:
N
Output
Print the answer... | LiveCodeBench | 1,147 | 3 | |
You are given a tree with N vertices: vertex 1, vertex 2, \ldots, vertex N.
The i-th edge (1\leq i\lt N) connects vertex u _ i and vertex v _ i.
Consider repeating the following operation some number of times:
- Choose one leaf vertex v and delete it along with all incident edges.
Find the minimum number of operatio... | LiveCodeBench | 1,148 | 1 | |
You are given a tree with N vertices: vertex 1, vertex 2, \ldots, vertex N.
The i-th edge (1\leq i\lt N) connects vertex u _ i and vertex v _ i.
Consider repeating the following operation some number of times:
- Choose one leaf vertex v and delete it along with all incident edges.
Find the minimum number of operatio... | LiveCodeBench | 1,148 | 2 | |
You are given a tree with N vertices: vertex 1, vertex 2, \ldots, vertex N.
The i-th edge (1\leq i\lt N) connects vertex u _ i and vertex v _ i.
Consider repeating the following operation some number of times:
- Choose one leaf vertex v and delete it along with all incident edges.
Find the minimum number of operatio... | LiveCodeBench | 1,148 | 3 | |
Takahashi will embark on an adventure.
During the adventure, N events will occur.
The i-th event (1\leq i\leq N) is represented by a pair of integers (t _ i,x _ i) (1\leq t _ i\leq 2,1\leq x _ i\leq N) and is as follows:
- If t _ i=1, he finds one potion of type x _ i. He can choose to pick it up or discard it.
- If ... | LiveCodeBench | 1,149 | 1 | |
Takahashi will embark on an adventure.
During the adventure, N events will occur.
The i-th event (1\leq i\leq N) is represented by a pair of integers (t _ i,x _ i) (1\leq t _ i\leq 2,1\leq x _ i\leq N) and is as follows:
- If t _ i=1, he finds one potion of type x _ i. He can choose to pick it up or discard it.
- If ... | LiveCodeBench | 1,149 | 2 | |
Takahashi will embark on an adventure.
During the adventure, N events will occur.
The i-th event (1\leq i\leq N) is represented by a pair of integers (t _ i,x _ i) (1\leq t _ i\leq 2,1\leq x _ i\leq N) and is as follows:
- If t _ i=1, he finds one potion of type x _ i. He can choose to pick it up or discard it.
- If ... | LiveCodeBench | 1,149 | 3 | |
Takahashi, a young baseball enthusiast, has been a very good boy this year, so Santa has decided to give him a bat or a glove, whichever is more expensive.
If a bat costs B yen and a glove costs G yen (B\neq G), which one will Santa give to Takahashi?
Input
The input is given from Standard Input in the following form... | LiveCodeBench | 1,150 | 1 | |
Takahashi, a young baseball enthusiast, has been a very good boy this year, so Santa has decided to give him a bat or a glove, whichever is more expensive.
If a bat costs B yen and a glove costs G yen (B\neq G), which one will Santa give to Takahashi?
Input
The input is given from Standard Input in the following form... | LiveCodeBench | 1,150 | 2 | |
Takahashi, a young baseball enthusiast, has been a very good boy this year, so Santa has decided to give him a bat or a glove, whichever is more expensive.
If a bat costs B yen and a glove costs G yen (B\neq G), which one will Santa give to Takahashi?
Input
The input is given from Standard Input in the following form... | LiveCodeBench | 1,150 | 3 | |
There is a road that stretches infinitely to the east and west, and the coordinate of a point located x meters to the east from a certain reference point on this road is defined as x.
In particular, the coordinate of a point located x meters to the west from the reference point is -x.
Snuke will set up Christmas trees ... | LiveCodeBench | 1,151 | 1 | |
There is a road that stretches infinitely to the east and west, and the coordinate of a point located x meters to the east from a certain reference point on this road is defined as x.
In particular, the coordinate of a point located x meters to the west from the reference point is -x.
Snuke will set up Christmas trees ... | LiveCodeBench | 1,151 | 2 | |
There is a road that stretches infinitely to the east and west, and the coordinate of a point located x meters to the east from a certain reference point on this road is defined as x.
In particular, the coordinate of a point located x meters to the west from the reference point is -x.
Snuke will set up Christmas trees ... | LiveCodeBench | 1,151 | 3 | |
Takahashi has N pairs of socks, and the i-th pair consists of two socks of color i.
One day, after organizing his chest of drawers, Takahashi realized that he had lost one sock each of colors A_1, A_2, \dots, A_K, so he decided to use the remaining 2N-K socks to make \lfloor\frac{2N-K}{2}\rfloor new pairs of socks, eac... | LiveCodeBench | 1,152 | 1 | |
Takahashi has N pairs of socks, and the i-th pair consists of two socks of color i.
One day, after organizing his chest of drawers, Takahashi realized that he had lost one sock each of colors A_1, A_2, \dots, A_K, so he decided to use the remaining 2N-K socks to make \lfloor\frac{2N-K}{2}\rfloor new pairs of socks, eac... | LiveCodeBench | 1,152 | 2 | |
Takahashi has N pairs of socks, and the i-th pair consists of two socks of color i.
One day, after organizing his chest of drawers, Takahashi realized that he had lost one sock each of colors A_1, A_2, \dots, A_K, so he decided to use the remaining 2N-K socks to make \lfloor\frac{2N-K}{2}\rfloor new pairs of socks, eac... | LiveCodeBench | 1,152 | 3 | |
There are N sleighs numbered 1,2,\ldots, N.
R_i reindeer are required to pull sleigh i.
Additionally, each reindeer can pull at most one sleigh. More precisely, \sum_{k=1}^{m} R_{i_k} reindeer are required to pull m sleighs i_1, i_2, \ldots, i_m.
Find the answer to Q queries of the following form:
- You are given an i... | LiveCodeBench | 1,153 | 1 | |
There are N sleighs numbered 1,2,\ldots, N.
R_i reindeer are required to pull sleigh i.
Additionally, each reindeer can pull at most one sleigh. More precisely, \sum_{k=1}^{m} R_{i_k} reindeer are required to pull m sleighs i_1, i_2, \ldots, i_m.
Find the answer to Q queries of the following form:
- You are given an i... | LiveCodeBench | 1,153 | 2 | |
There are N sleighs numbered 1,2,\ldots, N.
R_i reindeer are required to pull sleigh i.
Additionally, each reindeer can pull at most one sleigh. More precisely, \sum_{k=1}^{m} R_{i_k} reindeer are required to pull m sleighs i_1, i_2, \ldots, i_m.
Find the answer to Q queries of the following form:
- You are given an i... | LiveCodeBench | 1,153 | 3 | |
This problem has a similar setting to Problem G. Differences in the problem statement are indicated in red.
There is a grid with H rows and W columns, where each cell is painted red or green.
Let (i,j) denote the cell in the i-th row from the top and the j-th column from the left.
The color of cell (i,j) is represented... | LiveCodeBench | 1,154 | 1 | |
This problem has a similar setting to Problem G. Differences in the problem statement are indicated in red.
There is a grid with H rows and W columns, where each cell is painted red or green.
Let (i,j) denote the cell in the i-th row from the top and the j-th column from the left.
The color of cell (i,j) is represented... | LiveCodeBench | 1,154 | 2 | |
This problem has a similar setting to Problem G. Differences in the problem statement are indicated in red.
There is a grid with H rows and W columns, where each cell is painted red or green.
Let (i,j) denote the cell in the i-th row from the top and the j-th column from the left.
The color of cell (i,j) is represented... | LiveCodeBench | 1,154 | 3 | |
You are given a string S consisting of lowercase English letters and digits.
S is guaranteed to end with 2023.
Change the last character of S to 4 and print the modified string.
Input
The input is given from Standard Input in the following format:
S
Output
Print the answer.
Constraints
- S is a string of length... | LiveCodeBench | 1,155 | 1 | |
You are given a string S consisting of lowercase English letters and digits.
S is guaranteed to end with 2023.
Change the last character of S to 4 and print the modified string.
Input
The input is given from Standard Input in the following format:
S
Output
Print the answer.
Constraints
- S is a string of length... | LiveCodeBench | 1,155 | 2 | |
You are given a string S consisting of lowercase English letters and digits.
S is guaranteed to end with 2023.
Change the last character of S to 4 and print the modified string.
Input
The input is given from Standard Input in the following format:
S
Output
Print the answer.
Constraints
- S is a string of length... | LiveCodeBench | 1,155 | 3 | |
You are given an integer N.
Print all triples of non-negative integers (x,y,z) such that x+y+z\leq N in ascending lexicographical order.
What is lexicographical order for non-negative integer triples?
A triple of non-negative integers (x,y,z) is said to be lexicographically smaller than (x',y',z') if and only if one... | LiveCodeBench | 1,156 | 1 | |
You are given an integer N.
Print all triples of non-negative integers (x,y,z) such that x+y+z\leq N in ascending lexicographical order.
What is lexicographical order for non-negative integer triples?
A triple of non-negative integers (x,y,z) is said to be lexicographically smaller than (x',y',z') if and only if one... | LiveCodeBench | 1,156 | 2 | |
You are given an integer N.
Print all triples of non-negative integers (x,y,z) such that x+y+z\leq N in ascending lexicographical order.
What is lexicographical order for non-negative integer triples?
A triple of non-negative integers (x,y,z) is said to be lexicographically smaller than (x',y',z') if and only if one... | LiveCodeBench | 1,156 | 3 | |
Takahashi has created a game where the player controls a dragon on a coordinate plane.
The dragon consists of N parts numbered 1 to N, with part 1 being called the head.
Initially, part i is located at the coordinates (i,0). Process Q queries as follows.
- 1 C: Move the head by 1 in direction C. Here, C is one of R, L... | LiveCodeBench | 1,157 | 1 | |
Takahashi has created a game where the player controls a dragon on a coordinate plane.
The dragon consists of N parts numbered 1 to N, with part 1 being called the head.
Initially, part i is located at the coordinates (i,0). Process Q queries as follows.
- 1 C: Move the head by 1 in direction C. Here, C is one of R, L... | LiveCodeBench | 1,157 | 2 | |
Takahashi has created a game where the player controls a dragon on a coordinate plane.
The dragon consists of N parts numbered 1 to N, with part 1 being called the head.
Initially, part i is located at the coordinates (i,0). Process Q queries as follows.
- 1 C: Move the head by 1 in direction C. Here, C is one of R, L... | LiveCodeBench | 1,157 | 3 | |
There is a grid with N rows and N columns, where N is an odd number at most 45.
Let (i,j) denote the cell at the i-th row from the top and j-th column from the left.
In this grid, you will place Takahashi and a dragon consisting of N^2-1 parts numbered 1 to N^2-1 in such a way that satisfies the following conditions:
... | LiveCodeBench | 1,158 | 1 | |
There is a grid with N rows and N columns, where N is an odd number at most 45.
Let (i,j) denote the cell at the i-th row from the top and j-th column from the left.
In this grid, you will place Takahashi and a dragon consisting of N^2-1 parts numbered 1 to N^2-1 in such a way that satisfies the following conditions:
... | LiveCodeBench | 1,158 | 2 | |
There is a grid with N rows and N columns, where N is an odd number at most 45.
Let (i,j) denote the cell at the i-th row from the top and j-th column from the left.
In this grid, you will place Takahashi and a dragon consisting of N^2-1 parts numbered 1 to N^2-1 in such a way that satisfies the following conditions:
... | LiveCodeBench | 1,158 | 3 | |
For a positive integer X, the Dragon String of level X is a string of length (X+3) formed by one L, X occurrences of o, one n, and one g arranged in this order.
You are given a positive integer N. Print the Dragon String of level N.
Note that uppercase and lowercase letters are distinguished.
Input
The input is give... | LiveCodeBench | 1,159 | 1 | |
For a positive integer X, the Dragon String of level X is a string of length (X+3) formed by one L, X occurrences of o, one n, and one g arranged in this order.
You are given a positive integer N. Print the Dragon String of level N.
Note that uppercase and lowercase letters are distinguished.
Input
The input is give... | LiveCodeBench | 1,159 | 2 | |
For a positive integer X, the Dragon String of level X is a string of length (X+3) formed by one L, X occurrences of o, one n, and one g arranged in this order.
You are given a positive integer N. Print the Dragon String of level N.
Note that uppercase and lowercase letters are distinguished.
Input
The input is give... | LiveCodeBench | 1,159 | 3 | |
For a positive integer X, let \text{ctz}(X) be the (maximal) number of consecutive zeros at the end of the binary notation of X.
If the binary notation of X ends with a 1, then \text{ctz}(X)=0.
You are given a positive integer N. Print \text{ctz}(N).
Input
The input is given from Standard Input in the following form... | LiveCodeBench | 1,160 | 1 | |
For a positive integer X, let \text{ctz}(X) be the (maximal) number of consecutive zeros at the end of the binary notation of X.
If the binary notation of X ends with a 1, then \text{ctz}(X)=0.
You are given a positive integer N. Print \text{ctz}(N).
Input
The input is given from Standard Input in the following form... | LiveCodeBench | 1,160 | 2 | |
For a positive integer X, let \text{ctz}(X) be the (maximal) number of consecutive zeros at the end of the binary notation of X.
If the binary notation of X ends with a 1, then \text{ctz}(X)=0.
You are given a positive integer N. Print \text{ctz}(N).
Input
The input is given from Standard Input in the following form... | LiveCodeBench | 1,160 | 3 | |
A non-negative integer n is called a good integer when it satisfies the following condition:
- All digits in the decimal notation of n are even numbers (0, 2, 4, 6, and 8).
For example, 0, 68, and 2024 are good integers.
You are given an integer N. Find the N-th smallest good integer.
Input
The input is given from ... | LiveCodeBench | 1,161 | 1 | |
A non-negative integer n is called a good integer when it satisfies the following condition:
- All digits in the decimal notation of n are even numbers (0, 2, 4, 6, and 8).
For example, 0, 68, and 2024 are good integers.
You are given an integer N. Find the N-th smallest good integer.
Input
The input is given from ... | LiveCodeBench | 1,161 | 2 | |
A non-negative integer n is called a good integer when it satisfies the following condition:
- All digits in the decimal notation of n are even numbers (0, 2, 4, 6, and 8).
For example, 0, 68, and 2024 are good integers.
You are given an integer N. Find the N-th smallest good integer.
Input
The input is given from ... | LiveCodeBench | 1,161 | 3 | |
For a positive integer k, the Pyramid Sequence of size k is a sequence of length (2k-1) where the terms of the sequence have the values 1,2,\ldots,k-1,k,k-1,\ldots,2,1 in this order.
You are given a sequence A=(A_1,A_2,\ldots,A_N) of length N.
Find the maximum size of a Pyramid Sequence that can be obtained by repeate... | LiveCodeBench | 1,162 | 1 | |
For a positive integer k, the Pyramid Sequence of size k is a sequence of length (2k-1) where the terms of the sequence have the values 1,2,\ldots,k-1,k,k-1,\ldots,2,1 in this order.
You are given a sequence A=(A_1,A_2,\ldots,A_N) of length N.
Find the maximum size of a Pyramid Sequence that can be obtained by repeate... | LiveCodeBench | 1,162 | 2 | |
For a positive integer k, the Pyramid Sequence of size k is a sequence of length (2k-1) where the terms of the sequence have the values 1,2,\ldots,k-1,k,k-1,\ldots,2,1 in this order.
You are given a sequence A=(A_1,A_2,\ldots,A_N) of length N.
Find the maximum size of a Pyramid Sequence that can be obtained by repeate... | LiveCodeBench | 1,162 | 3 | |
Team Takahashi and Team Aoki played N matches.
In the i-th match (1\leq i\leq N), Team Takahashi scored X _ i points, and Team Aoki scored Y _ i points.
The team with the higher total score from the N matches wins.
Print the winner.
If the two teams have the same total score, it is a draw.
Input
The input is given ... | LiveCodeBench | 1,163 | 1 | |
Team Takahashi and Team Aoki played N matches.
In the i-th match (1\leq i\leq N), Team Takahashi scored X _ i points, and Team Aoki scored Y _ i points.
The team with the higher total score from the N matches wins.
Print the winner.
If the two teams have the same total score, it is a draw.
Input
The input is given ... | LiveCodeBench | 1,163 | 2 | |
Team Takahashi and Team Aoki played N matches.
In the i-th match (1\leq i\leq N), Team Takahashi scored X _ i points, and Team Aoki scored Y _ i points.
The team with the higher total score from the N matches wins.
Print the winner.
If the two teams have the same total score, it is a draw.
Input
The input is given ... | LiveCodeBench | 1,163 | 3 | |
We define Extended A strings, Extended B strings, Extended C strings, and Extended ABC strings as follows:
- A string S is an Extended A string if all characters in S are A.
- A string S is an Extended B string if all characters in S are B.
- A string S is an Extended C string if all characters in S are C.
- A string ... | LiveCodeBench | 1,164 | 1 | |
We define Extended A strings, Extended B strings, Extended C strings, and Extended ABC strings as follows:
- A string S is an Extended A string if all characters in S are A.
- A string S is an Extended B string if all characters in S are B.
- A string S is an Extended C string if all characters in S are C.
- A string ... | LiveCodeBench | 1,164 | 2 | |
We define Extended A strings, Extended B strings, Extended C strings, and Extended ABC strings as follows:
- A string S is an Extended A string if all characters in S are A.
- A string S is an Extended B string if all characters in S are B.
- A string S is an Extended C string if all characters in S are C.
- A string ... | LiveCodeBench | 1,164 | 3 | |
There are N people standing in a line: person 1, person 2, \ldots, person N.
You are given the arrangement of the people as a sequence A=(A _ 1,A _ 2,\ldots,A _ N) of length N.
A _ i\ (1\leq i\leq N) represents the following information:
- if A _ i=-1, person i is at the front of the line;
- if A _ i\neq -1, person i ... | LiveCodeBench | 1,165 | 1 | |
There are N people standing in a line: person 1, person 2, \ldots, person N.
You are given the arrangement of the people as a sequence A=(A _ 1,A _ 2,\ldots,A _ N) of length N.
A _ i\ (1\leq i\leq N) represents the following information:
- if A _ i=-1, person i is at the front of the line;
- if A _ i\neq -1, person i ... | LiveCodeBench | 1,165 | 2 | |
There are N people standing in a line: person 1, person 2, \ldots, person N.
You are given the arrangement of the people as a sequence A=(A _ 1,A _ 2,\ldots,A _ N) of length N.
A _ i\ (1\leq i\leq N) represents the following information:
- if A _ i=-1, person i is at the front of the line;
- if A _ i\neq -1, person i ... | LiveCodeBench | 1,165 | 3 | |
There is a grid with H rows and W columns. Let (i, j) denote the cell at the i-th row from the top and the j-th column from the left.
Each cell contains one of the characters o, x, and .. The characters written in each cell are represented by H strings S_1, S_2, \ldots, S_H of length W; the character written in cell (i... | LiveCodeBench | 1,166 | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.