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 initially have an empty string S. Additionally, there are bags 1, 2, \dots, N, each containing some strings. Bag i contains A_i strings S_{i,1}, S_{i,2}, \dots, S_{i,A_i}. You will repeat the following steps for i = 1, 2, \dots, N: - Choose and perform one of the following two actions: - Pay 1 yen, select exactl...
LiveCodeBench
1,199
3
You are given a string S consisting of lowercase English letters and |. S is guaranteed to contain exactly two |s. Remove the characters between the two |s, including the |s themselves, and print the resulting string. Input The input is given from Standard Input in the following format: S Output Print the answer. ...
LiveCodeBench
1,200
1
You are given a string S consisting of lowercase English letters and |. S is guaranteed to contain exactly two |s. Remove the characters between the two |s, including the |s themselves, and print the resulting string. Input The input is given from Standard Input in the following format: S Output Print the answer. ...
LiveCodeBench
1,200
2
You are given a string S consisting of lowercase English letters and |. S is guaranteed to contain exactly two |s. Remove the characters between the two |s, including the |s themselves, and print the resulting string. Input The input is given from Standard Input in the following format: S Output Print the answer. ...
LiveCodeBench
1,200
3
You are given three sequences A=(A_1,\ldots,A_N), B=(B_1,\ldots,B_M), and C=(C_1,\ldots,C_L). Additionally, a sequence X=(X_1,\ldots,X_Q) is given. For each i=1,\ldots,Q, solve the following problem: Problem: Is it possible to select one element from each of A, B, and C so that their sum is X_i? Input The input is gi...
LiveCodeBench
1,201
1
You are given three sequences A=(A_1,\ldots,A_N), B=(B_1,\ldots,B_M), and C=(C_1,\ldots,C_L). Additionally, a sequence X=(X_1,\ldots,X_Q) is given. For each i=1,\ldots,Q, solve the following problem: Problem: Is it possible to select one element from each of A, B, and C so that their sum is X_i? Input The input is gi...
LiveCodeBench
1,201
2
You are given three sequences A=(A_1,\ldots,A_N), B=(B_1,\ldots,B_M), and C=(C_1,\ldots,C_L). Additionally, a sequence X=(X_1,\ldots,X_Q) is given. For each i=1,\ldots,Q, solve the following problem: Problem: Is it possible to select one element from each of A, B, and C so that their sum is X_i? Input The input is gi...
LiveCodeBench
1,201
3
You are given N integers A_1,A_2,\dots,A_N, one per line, over N lines. However, N is not given in the input. Furthermore, the following is guaranteed: - A_i \neq 0 ( 1 \le i \le N-1 ) - A_N = 0 Print A_N, A_{N-1},\dots,A_1 in this order. Input The input is given from Standard Input in the following format: A_1 A...
LiveCodeBench
1,202
1
You are given N integers A_1,A_2,\dots,A_N, one per line, over N lines. However, N is not given in the input. Furthermore, the following is guaranteed: - A_i \neq 0 ( 1 \le i \le N-1 ) - A_N = 0 Print A_N, A_{N-1},\dots,A_1 in this order. Input The input is given from Standard Input in the following format: A_1 A...
LiveCodeBench
1,202
2
You are given N integers A_1,A_2,\dots,A_N, one per line, over N lines. However, N is not given in the input. Furthermore, the following is guaranteed: - A_i \neq 0 ( 1 \le i \le N-1 ) - A_N = 0 Print A_N, A_{N-1},\dots,A_1 in this order. Input The input is given from Standard Input in the following format: A_1 A...
LiveCodeBench
1,202
3
You are given a sequence A=(A_1,\ldots,A_N) of length N. The elements of A are distinct. Process Q queries in the order they are given. Each query is of one of the following two types: - 1 x y : Insert y immediately after the element x in A. It is guaranteed that x exists in A when this query is given. - 2 x : Remove ...
LiveCodeBench
1,203
1
You are given a sequence A=(A_1,\ldots,A_N) of length N. The elements of A are distinct. Process Q queries in the order they are given. Each query is of one of the following two types: - 1 x y : Insert y immediately after the element x in A. It is guaranteed that x exists in A when this query is given. - 2 x : Remove ...
LiveCodeBench
1,203
2
You are given a sequence A=(A_1,\ldots,A_N) of length N. The elements of A are distinct. Process Q queries in the order they are given. Each query is of one of the following two types: - 1 x y : Insert y immediately after the element x in A. It is guaranteed that x exists in A when this query is given. - 2 x : Remove ...
LiveCodeBench
1,203
3
There is a grid of H rows and W columns, each cell having a side length of 1, and we have N tiles. The i-th tile (1\leq i\leq N) is a rectangle of size A_i\times B_i. Determine whether it is possible to place the tiles on the grid so that all of the following conditions are satisfied: - Every cell is covered by exactl...
LiveCodeBench
1,204
1
There is a grid of H rows and W columns, each cell having a side length of 1, and we have N tiles. The i-th tile (1\leq i\leq N) is a rectangle of size A_i\times B_i. Determine whether it is possible to place the tiles on the grid so that all of the following conditions are satisfied: - Every cell is covered by exactl...
LiveCodeBench
1,204
2
There is a grid of H rows and W columns, each cell having a side length of 1, and we have N tiles. The i-th tile (1\leq i\leq N) is a rectangle of size A_i\times B_i. Determine whether it is possible to place the tiles on the grid so that all of the following conditions are satisfied: - Every cell is covered by exactl...
LiveCodeBench
1,204
3
Given an integer X between -10^{18} and 10^{18}, inclusive, print \left\lceil \dfrac{X}{10} \right\rceil. Here, \left\lceil a \right\rceil denotes the smallest integer not less than a. Input The input is given from Standard Input in the following format: X Output Print \left\lceil \dfrac{X}{10} \right\rceil as an ...
LiveCodeBench
1,205
1
Given an integer X between -10^{18} and 10^{18}, inclusive, print \left\lceil \dfrac{X}{10} \right\rceil. Here, \left\lceil a \right\rceil denotes the smallest integer not less than a. Input The input is given from Standard Input in the following format: X Output Print \left\lceil \dfrac{X}{10} \right\rceil as an ...
LiveCodeBench
1,205
2
Given an integer X between -10^{18} and 10^{18}, inclusive, print \left\lceil \dfrac{X}{10} \right\rceil. Here, \left\lceil a \right\rceil denotes the smallest integer not less than a. Input The input is given from Standard Input in the following format: X Output Print \left\lceil \dfrac{X}{10} \right\rceil as an ...
LiveCodeBench
1,205
3
You are given a string S of length N consisting of 0 and 1. A string T of length N consisting of 0 and 1 is a good string if and only if it satisfies the following condition: - There is exactly one integer i such that 1 \leq i \leq N - 1 and the i-th and (i + 1)-th characters of T are the same. For each i = 1,2,\ldot...
LiveCodeBench
1,206
1
You are given a string S of length N consisting of 0 and 1. A string T of length N consisting of 0 and 1 is a good string if and only if it satisfies the following condition: - There is exactly one integer i such that 1 \leq i \leq N - 1 and the i-th and (i + 1)-th characters of T are the same. For each i = 1,2,\ldot...
LiveCodeBench
1,206
2
You are given a string S of length N consisting of 0 and 1. A string T of length N consisting of 0 and 1 is a good string if and only if it satisfies the following condition: - There is exactly one integer i such that 1 \leq i \leq N - 1 and the i-th and (i + 1)-th characters of T are the same. For each i = 1,2,\ldot...
LiveCodeBench
1,206
3
There is an infinitely long piano keyboard. Is there a continuous segment within this keyboard that consists of W white keys and B black keys? Let S be the string formed by infinitely repeating the string wbwbwwbwbwbw. Is there a substring of S that consists of W occurrences of w and B occurrences of b? What is a sub...
LiveCodeBench
1,207
1
There is an infinitely long piano keyboard. Is there a continuous segment within this keyboard that consists of W white keys and B black keys? Let S be the string formed by infinitely repeating the string wbwbwwbwbwbw. Is there a substring of S that consists of W occurrences of w and B occurrences of b? What is a sub...
LiveCodeBench
1,207
2
There is an infinitely long piano keyboard. Is there a continuous segment within this keyboard that consists of W white keys and B black keys? Let S be the string formed by infinitely repeating the string wbwbwwbwbwbw. Is there a substring of S that consists of W occurrences of w and B occurrences of b? What is a sub...
LiveCodeBench
1,207
3
There is a grid with H rows and W columns. Initially, all cells are painted with color 0. You will perform the following operations in the order i = 1, 2, \ldots, M. - If T_i = 1, repaint all cells in the A_i-th row with color X_i. - If T_i = 2, repaint all cells in the A_i-th column with color X_i. After all ope...
LiveCodeBench
1,208
1
There is a grid with H rows and W columns. Initially, all cells are painted with color 0. You will perform the following operations in the order i = 1, 2, \ldots, M. - If T_i = 1, repaint all cells in the A_i-th row with color X_i. - If T_i = 2, repaint all cells in the A_i-th column with color X_i. After all ope...
LiveCodeBench
1,208
2
There is a grid with H rows and W columns. Initially, all cells are painted with color 0. You will perform the following operations in the order i = 1, 2, \ldots, M. - If T_i = 1, repaint all cells in the A_i-th row with color X_i. - If T_i = 2, repaint all cells in the A_i-th column with color X_i. After all ope...
LiveCodeBench
1,208
3
You are given N integers A_1, A_2, \dots, A_N. Also, define B_i = A_i \times A_{i+1}\ (1 \leq i \leq N-1). Print B_1, B_2, \dots, B_{N-1} in this order, separated by spaces. Input The input is given from Standard Input in the following format: N A_1 A_2 \dots A_N Output Print B_1, B_2, \dots, B_{N-1} in this orde...
LiveCodeBench
1,209
1
You are given N integers A_1, A_2, \dots, A_N. Also, define B_i = A_i \times A_{i+1}\ (1 \leq i \leq N-1). Print B_1, B_2, \dots, B_{N-1} in this order, separated by spaces. Input The input is given from Standard Input in the following format: N A_1 A_2 \dots A_N Output Print B_1, B_2, \dots, B_{N-1} in this orde...
LiveCodeBench
1,209
2
You are given N integers A_1, A_2, \dots, A_N. Also, define B_i = A_i \times A_{i+1}\ (1 \leq i \leq N-1). Print B_1, B_2, \dots, B_{N-1} in this order, separated by spaces. Input The input is given from Standard Input in the following format: N A_1 A_2 \dots A_N Output Print B_1, B_2, \dots, B_{N-1} in this orde...
LiveCodeBench
1,209
3
You are given a sequence of positive integers A=(A_1,A_2,\dots,A_N) of length N and a positive integer K. Find the sum of the integers between 1 and K, inclusive, that do not appear in the sequence A. Input The input is given from Standard Input in the following format: N K A_1 A_2 \dots A_N Output Print the answe...
LiveCodeBench
1,210
1
You are given a sequence of positive integers A=(A_1,A_2,\dots,A_N) of length N and a positive integer K. Find the sum of the integers between 1 and K, inclusive, that do not appear in the sequence A. Input The input is given from Standard Input in the following format: N K A_1 A_2 \dots A_N Output Print the answe...
LiveCodeBench
1,210
2
You are given a sequence of positive integers A=(A_1,A_2,\dots,A_N) of length N and a positive integer K. Find the sum of the integers between 1 and K, inclusive, that do not appear in the sequence A. Input The input is given from Standard Input in the following format: N K A_1 A_2 \dots A_N Output Print the answe...
LiveCodeBench
1,210
3
In the Kingdom of AtCoder, a week consists of A+B days, with the first through A-th days being holidays and the (A+1)-th through (A+B)-th being weekdays. Takahashi has N plans, and the i-th plan is scheduled D_i days later. He has forgotten what day of the week it is today. Determine if it is possible for all of his N ...
LiveCodeBench
1,211
1
In the Kingdom of AtCoder, a week consists of A+B days, with the first through A-th days being holidays and the (A+1)-th through (A+B)-th being weekdays. Takahashi has N plans, and the i-th plan is scheduled D_i days later. He has forgotten what day of the week it is today. Determine if it is possible for all of his N ...
LiveCodeBench
1,211
2
In the Kingdom of AtCoder, a week consists of A+B days, with the first through A-th days being holidays and the (A+1)-th through (A+B)-th being weekdays. Takahashi has N plans, and the i-th plan is scheduled D_i days later. He has forgotten what day of the week it is today. Determine if it is possible for all of his N ...
LiveCodeBench
1,211
3
You are given positive integers N and K, and a sequence of length N, A=(A_1,A_2,\ldots,A_N). Extract all elements of A that are multiples of K, divide them by K, and print the quotients. Input The input is given from Standard Input in the following format: N K A_1 A_2 \ldots A_N Output Divide all elements of A tha...
LiveCodeBench
1,212
1
You are given positive integers N and K, and a sequence of length N, A=(A_1,A_2,\ldots,A_N). Extract all elements of A that are multiples of K, divide them by K, and print the quotients. Input The input is given from Standard Input in the following format: N K A_1 A_2 \ldots A_N Output Divide all elements of A tha...
LiveCodeBench
1,212
2
You are given positive integers N and K, and a sequence of length N, A=(A_1,A_2,\ldots,A_N). Extract all elements of A that are multiples of K, divide them by K, and print the quotients. Input The input is given from Standard Input in the following format: N K A_1 A_2 \ldots A_N Output Divide all elements of A tha...
LiveCodeBench
1,212
3
There is an integer sequence A=(A_1,A_2,\ldots,A_N) of length N, where all elements are initially set to 0. Also, there is a set S, which is initially empty. Perform the following Q queries in order. Find the value of each element in the sequence A after processing all Q queries. The i-th query is in the following form...
LiveCodeBench
1,213
1
There is an integer sequence A=(A_1,A_2,\ldots,A_N) of length N, where all elements are initially set to 0. Also, there is a set S, which is initially empty. Perform the following Q queries in order. Find the value of each element in the sequence A after processing all Q queries. The i-th query is in the following form...
LiveCodeBench
1,213
2
There is an integer sequence A=(A_1,A_2,\ldots,A_N) of length N, where all elements are initially set to 0. Also, there is a set S, which is initially empty. Perform the following Q queries in order. Find the value of each element in the sequence A after processing all Q queries. The i-th query is in the following form...
LiveCodeBench
1,213
3
You are given a string S consisting of lowercase English letters. How many different non-empty substrings does S have? A substring is a contiguous subsequence. For example, xxx is a substring of yxxxy but not of xxyxx. Input The input is given from Standard Input in the following format: S Output Print the answer. ...
LiveCodeBench
1,214
1
You are given a string S consisting of lowercase English letters. How many different non-empty substrings does S have? A substring is a contiguous subsequence. For example, xxx is a substring of yxxxy but not of xxyxx. Input The input is given from Standard Input in the following format: S Output Print the answer. ...
LiveCodeBench
1,214
2
You are given a string S consisting of lowercase English letters. How many different non-empty substrings does S have? A substring is a contiguous subsequence. For example, xxx is a substring of yxxxy but not of xxyxx. Input The input is given from Standard Input in the following format: S Output Print the answer. ...
LiveCodeBench
1,214
3
There are N types of beans, one bean of each type. The i-th type of bean has a deliciousness of A_i and a color of C_i. The beans are mixed and can only be distinguished by color. You will choose one color of beans and eat one bean of that color. By selecting the optimal color, maximize the minimum possible deliciousne...
LiveCodeBench
1,215
1
There are N types of beans, one bean of each type. The i-th type of bean has a deliciousness of A_i and a color of C_i. The beans are mixed and can only be distinguished by color. You will choose one color of beans and eat one bean of that color. By selecting the optimal color, maximize the minimum possible deliciousne...
LiveCodeBench
1,215
2
There are N types of beans, one bean of each type. The i-th type of bean has a deliciousness of A_i and a color of C_i. The beans are mixed and can only be distinguished by color. You will choose one color of beans and eat one bean of that color. By selecting the optimal color, maximize the minimum possible deliciousne...
LiveCodeBench
1,215
3
On the xy-plane, there are N points with ID numbers from 1 to N. Point i is located at coordinates (X_i, Y_i), and no two points have the same coordinates. From each point, find the farthest point and print its ID number. If multiple points are the farthest, print the smallest of the ID numbers of those points. Here, ...
LiveCodeBench
1,216
1
On the xy-plane, there are N points with ID numbers from 1 to N. Point i is located at coordinates (X_i, Y_i), and no two points have the same coordinates. From each point, find the farthest point and print its ID number. If multiple points are the farthest, print the smallest of the ID numbers of those points. Here, ...
LiveCodeBench
1,216
2
On the xy-plane, there are N points with ID numbers from 1 to N. Point i is located at coordinates (X_i, Y_i), and no two points have the same coordinates. From each point, find the farthest point and print its ID number. If multiple points are the farthest, print the smallest of the ID numbers of those points. Here, ...
LiveCodeBench
1,216
3
Takahashi will have N penalty kicks in a soccer match. For the i-th penalty kick, he will fail if i is a multiple of 3, and succeed otherwise. Print the results of his penalty kicks. Input The input is given from Standard Input in the following format: N Output Print a string of length N representing the results of...
LiveCodeBench
1,217
1
Takahashi will have N penalty kicks in a soccer match. For the i-th penalty kick, he will fail if i is a multiple of 3, and succeed otherwise. Print the results of his penalty kicks. Input The input is given from Standard Input in the following format: N Output Print a string of length N representing the results of...
LiveCodeBench
1,217
2
Takahashi will have N penalty kicks in a soccer match. For the i-th penalty kick, he will fail if i is a multiple of 3, and succeed otherwise. Print the results of his penalty kicks. Input The input is given from Standard Input in the following format: N Output Print a string of length N representing the results of...
LiveCodeBench
1,217
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. The state of each cell is represented by the character A_{i,j}, which means the following: - .: An empty cell. - #: An obstacle. - S: An empty cell and the start point. - T: An empty ce...
LiveCodeBench
1,218
1
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. The state of each cell is represented by the character A_{i,j}, which means the following: - .: An empty cell. - #: An obstacle. - S: An empty cell and the start point. - T: An empty ce...
LiveCodeBench
1,218
2
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. The state of each cell is represented by the character A_{i,j}, which means the following: - .: An empty cell. - #: An obstacle. - S: An empty cell and the start point. - T: An empty ce...
LiveCodeBench
1,218
3
You are given a tree with N vertices. The vertices are numbered 1 to N, and the i-th edge connects vertices A_i and B_i. You are also given a sequence of positive integers C = (C_1, C_2, \ldots ,C_N) of length N. Let d(a, b) be the number of edges between vertices a and b, and for x = 1, 2, \ldots, N, let \displaystyle...
LiveCodeBench
1,219
1
You are given a tree with N vertices. The vertices are numbered 1 to N, and the i-th edge connects vertices A_i and B_i. You are also given a sequence of positive integers C = (C_1, C_2, \ldots ,C_N) of length N. Let d(a, b) be the number of edges between vertices a and b, and for x = 1, 2, \ldots, N, let \displaystyle...
LiveCodeBench
1,219
2
You are given a tree with N vertices. The vertices are numbered 1 to N, and the i-th edge connects vertices A_i and B_i. You are also given a sequence of positive integers C = (C_1, C_2, \ldots ,C_N) of length N. Let d(a, b) be the number of edges between vertices a and b, and for x = 1, 2, \ldots, N, let \displaystyle...
LiveCodeBench
1,219
3
A string T of length 3 consisting of uppercase English letters is an airport code for a string S of lowercase English letters if and only if T can be derived from S by one of the following methods: - Take a subsequence of length 3 from S (not necessarily contiguous) and convert it to uppercase letters to form T. - Tak...
LiveCodeBench
1,220
1
A string T of length 3 consisting of uppercase English letters is an airport code for a string S of lowercase English letters if and only if T can be derived from S by one of the following methods: - Take a subsequence of length 3 from S (not necessarily contiguous) and convert it to uppercase letters to form T. - Tak...
LiveCodeBench
1,220
2
A string T of length 3 consisting of uppercase English letters is an airport code for a string S of lowercase English letters if and only if T can be derived from S by one of the following methods: - Take a subsequence of length 3 from S (not necessarily contiguous) and convert it to uppercase letters to form T. - Tak...
LiveCodeBench
1,220
3
There are N people labeled 1 to N, who have played several one-on-one games without draws. Initially, each person started with 0 points. In each game, the winner's score increased by 1 and the loser's score decreased by 1 (scores can become negative). Determine the final score of person N if the final score of person i...
LiveCodeBench
1,221
1
There are N people labeled 1 to N, who have played several one-on-one games without draws. Initially, each person started with 0 points. In each game, the winner's score increased by 1 and the loser's score decreased by 1 (scores can become negative). Determine the final score of person N if the final score of person i...
LiveCodeBench
1,221
2
There are N people labeled 1 to N, who have played several one-on-one games without draws. Initially, each person started with 0 points. In each game, the winner's score increased by 1 and the loser's score decreased by 1 (scores can become negative). Determine the final score of person N if the final score of person i...
LiveCodeBench
1,221
3
A string S consisting of lowercase English letters is a good string if and only if it satisfies the following property for all integers i not less than 1: - There are exactly zero or exactly two different letters that appear exactly i times in S. Given a string S, determine if it is a good string. Input The input i...
LiveCodeBench
1,222
1
A string S consisting of lowercase English letters is a good string if and only if it satisfies the following property for all integers i not less than 1: - There are exactly zero or exactly two different letters that appear exactly i times in S. Given a string S, determine if it is a good string. Input The input i...
LiveCodeBench
1,222
2
A string S consisting of lowercase English letters is a good string if and only if it satisfies the following property for all integers i not less than 1: - There are exactly zero or exactly two different letters that appear exactly i times in S. Given a string S, determine if it is a good string. Input The input i...
LiveCodeBench
1,222
3
For non-negative integers l and r (l < r), let S(l, r) denote the sequence (l, l+1, \ldots, r-2, r-1) formed by arranging integers from l through r-1 in order. Furthermore, a sequence is called a good sequence if and only if it can be represented as S(2^i j, 2^i (j+1)) using non-negative integers i and j. You are given...
LiveCodeBench
1,223
1
For non-negative integers l and r (l < r), let S(l, r) denote the sequence (l, l+1, \ldots, r-2, r-1) formed by arranging integers from l through r-1 in order. Furthermore, a sequence is called a good sequence if and only if it can be represented as S(2^i j, 2^i (j+1)) using non-negative integers i and j. You are given...
LiveCodeBench
1,223
2
For non-negative integers l and r (l < r), let S(l, r) denote the sequence (l, l+1, \ldots, r-2, r-1) formed by arranging integers from l through r-1 in order. Furthermore, a sequence is called a good sequence if and only if it can be represented as S(2^i j, 2^i (j+1)) using non-negative integers i and j. You are given...
LiveCodeBench
1,223
3
There is a 3 \times 3 grid. Let (i, j) denote the cell at the i-th row from the top and j-th column from the left (1 \leq i, j \leq 3). Cell (i, j) contains an integer A_{i,j}. It is guaranteed that \sum_{i=1}^3 \sum_{j=1}^3 A_{i,j} is odd. Additionally, all cells are initially painted white. Takahashi and Aoki will pl...
LiveCodeBench
1,224
1
There is a 3 \times 3 grid. Let (i, j) denote the cell at the i-th row from the top and j-th column from the left (1 \leq i, j \leq 3). Cell (i, j) contains an integer A_{i,j}. It is guaranteed that \sum_{i=1}^3 \sum_{j=1}^3 A_{i,j} is odd. Additionally, all cells are initially painted white. Takahashi and Aoki will pl...
LiveCodeBench
1,224
2
There is a 3 \times 3 grid. Let (i, j) denote the cell at the i-th row from the top and j-th column from the left (1 \leq i, j \leq 3). Cell (i, j) contains an integer A_{i,j}. It is guaranteed that \sum_{i=1}^3 \sum_{j=1}^3 A_{i,j} is odd. Additionally, all cells are initially painted white. Takahashi and Aoki will pl...
LiveCodeBench
1,224
3
You are given a string S of length 6. It is guaranteed that the first three characters of S are ABC and the last three characters are digits. Determine if S is the abbreviation of a contest held and concluded on AtCoder before the start of this contest. Here, a string T is "the abbreviation of a contest held and conclu...
LiveCodeBench
1,225
1
You are given a string S of length 6. It is guaranteed that the first three characters of S are ABC and the last three characters are digits. Determine if S is the abbreviation of a contest held and concluded on AtCoder before the start of this contest. Here, a string T is "the abbreviation of a contest held and conclu...
LiveCodeBench
1,225
2
You are given a string S of length 6. It is guaranteed that the first three characters of S are ABC and the last three characters are digits. Determine if S is the abbreviation of a contest held and concluded on AtCoder before the start of this contest. Here, a string T is "the abbreviation of a contest held and conclu...
LiveCodeBench
1,225
3
You are given an integer N. You can perform the following two types of operations: - Pay X yen to replace N with \displaystyle\left\lfloor\frac{N}{A}\right\rfloor. - Pay Y yen to roll a die (dice) that shows an integer between 1 and 6, inclusive, with equal probability. Let b be the outcome of the die, and replace N w...
LiveCodeBench
1,226
1
You are given an integer N. You can perform the following two types of operations: - Pay X yen to replace N with \displaystyle\left\lfloor\frac{N}{A}\right\rfloor. - Pay Y yen to roll a die (dice) that shows an integer between 1 and 6, inclusive, with equal probability. Let b be the outcome of the die, and replace N w...
LiveCodeBench
1,226
2
You are given an integer N. You can perform the following two types of operations: - Pay X yen to replace N with \displaystyle\left\lfloor\frac{N}{A}\right\rfloor. - Pay Y yen to roll a die (dice) that shows an integer between 1 and 6, inclusive, with equal probability. Let b be the outcome of the die, and replace N w...
LiveCodeBench
1,226
3
Takahashi has N teeth, one in each of the holes numbered 1, 2, \dots, N. Dentist Aoki will perform Q treatments on these teeth and holes. In the i-th treatment, hole T_i is treated as follows: - If there is a tooth in hole T_i, remove the tooth from hole T_i. - If there is no tooth in hole T_i (i.e., the hole is emp...
LiveCodeBench
1,227
1
Takahashi has N teeth, one in each of the holes numbered 1, 2, \dots, N. Dentist Aoki will perform Q treatments on these teeth and holes. In the i-th treatment, hole T_i is treated as follows: - If there is a tooth in hole T_i, remove the tooth from hole T_i. - If there is no tooth in hole T_i (i.e., the hole is emp...
LiveCodeBench
1,227
2
Takahashi has N teeth, one in each of the holes numbered 1, 2, \dots, N. Dentist Aoki will perform Q treatments on these teeth and holes. In the i-th treatment, hole T_i is treated as follows: - If there is a tooth in hole T_i, remove the tooth from hole T_i. - If there is no tooth in hole T_i (i.e., the hole is emp...
LiveCodeBench
1,227
3
You are given a permutation A=(A_1,\ldots,A_N) of (1,2,\ldots,N). Transform A into (1,2,\ldots,N) by performing the following operation between 0 and N-1 times, inclusive: - Operation: Choose any pair of integers (i,j) such that 1\leq i < j \leq N. Swap the elements at the i-th and j-th positions of A. It can be pro...
LiveCodeBench
1,228
1
You are given a permutation A=(A_1,\ldots,A_N) of (1,2,\ldots,N). Transform A into (1,2,\ldots,N) by performing the following operation between 0 and N-1 times, inclusive: - Operation: Choose any pair of integers (i,j) such that 1\leq i < j \leq N. Swap the elements at the i-th and j-th positions of A. It can be pro...
LiveCodeBench
1,228
2
You are given a permutation A=(A_1,\ldots,A_N) of (1,2,\ldots,N). Transform A into (1,2,\ldots,N) by performing the following operation between 0 and N-1 times, inclusive: - Operation: Choose any pair of integers (i,j) such that 1\leq i < j \leq N. Swap the elements at the i-th and j-th positions of A. It can be pro...
LiveCodeBench
1,228
3
There is an SNS used by N users, labeled with numbers from 1 to N. In this SNS, two users can become friends with each other. Friendship is bidirectional; if user X is a friend of user Y, user Y is always a friend of user X. Currently, there are M pairs of friendships on the SNS, with the i-th pair consisting of users...
LiveCodeBench
1,229
1
There is an SNS used by N users, labeled with numbers from 1 to N. In this SNS, two users can become friends with each other. Friendship is bidirectional; if user X is a friend of user Y, user Y is always a friend of user X. Currently, there are M pairs of friendships on the SNS, with the i-th pair consisting of users...
LiveCodeBench
1,229
2
There is an SNS used by N users, labeled with numbers from 1 to N. In this SNS, two users can become friends with each other. Friendship is bidirectional; if user X is a friend of user Y, user Y is always a friend of user X. Currently, there are M pairs of friendships on the SNS, with the i-th pair consisting of users...
LiveCodeBench
1,229
3
Team Takahashi and Team Aoki are playing a baseball game, with Team Takahashi batting first. Currently, the game has finished through the top of the ninth inning, and the bottom of the ninth is about to begin. Team Takahashi scored A_i runs in the top of the i-th inning (1\leq i\leq 9), and Team Aoki scored B_j runs in...
LiveCodeBench
1,230
1
Team Takahashi and Team Aoki are playing a baseball game, with Team Takahashi batting first. Currently, the game has finished through the top of the ninth inning, and the bottom of the ninth is about to begin. Team Takahashi scored A_i runs in the top of the i-th inning (1\leq i\leq 9), and Team Aoki scored B_j runs in...
LiveCodeBench
1,230
2
Team Takahashi and Team Aoki are playing a baseball game, with Team Takahashi batting first. Currently, the game has finished through the top of the ninth inning, and the bottom of the ninth is about to begin. Team Takahashi scored A_i runs in the top of the i-th inning (1\leq i\leq 9), and Team Aoki scored B_j runs in...
LiveCodeBench
1,230
3
You are given two grids, each with N rows and N columns, referred to as grid A and grid B. Each cell in the grids contains a lowercase English letter. The character at the i-th row and j-th column of grid A is A_{i, j}. The character at the i-th row and j-th column of grid B is B_{i, j}. The two grids differ in ex...
LiveCodeBench
1,231
1
You are given two grids, each with N rows and N columns, referred to as grid A and grid B. Each cell in the grids contains a lowercase English letter. The character at the i-th row and j-th column of grid A is A_{i, j}. The character at the i-th row and j-th column of grid B is B_{i, j}. The two grids differ in ex...
LiveCodeBench
1,231
2
You are given two grids, each with N rows and N columns, referred to as grid A and grid B. Each cell in the grids contains a lowercase English letter. The character at the i-th row and j-th column of grid A is A_{i, j}. The character at the i-th row and j-th column of grid B is B_{i, j}. The two grids differ in ex...
LiveCodeBench
1,231
3
On a coordinate plane, there are N points P_1, P_2, \ldots, P_N, where point P_i has coordinates (X_i, Y_i). The distance \text{dist}(A, B) between two points A and B is defined as follows: A rabbit is initially at point A. A rabbit at position (x, y) can jump to (x+1, y+1), (x+1, y-1), (x-1, y+1), or (x-1, y-1) in on...
LiveCodeBench
1,232
1
On a coordinate plane, there are N points P_1, P_2, \ldots, P_N, where point P_i has coordinates (X_i, Y_i). The distance \text{dist}(A, B) between two points A and B is defined as follows: A rabbit is initially at point A. A rabbit at position (x, y) can jump to (x+1, y+1), (x+1, y-1), (x-1, y+1), or (x-1, y-1) in on...
LiveCodeBench
1,232
2
On a coordinate plane, there are N points P_1, P_2, \ldots, P_N, where point P_i has coordinates (X_i, Y_i). The distance \text{dist}(A, B) between two points A and B is defined as follows: A rabbit is initially at point A. A rabbit at position (x, y) can jump to (x+1, y+1), (x+1, y-1), (x-1, y+1), or (x-1, y-1) in on...
LiveCodeBench
1,232
3