problem
stringlengths
20
3.95k
answer
stringclasses
532 values
task
stringclasses
6 values
problem_number
int64
1
1.31k
set_number
int64
1
5
There is an undirected graph with N vertices numbered 1 through N, and initially with 0 edges. Given Q queries, process them in order. After processing each query, print the number of vertices that are not connected to any other vertices by an edge. The i-th query, \mathrm{query}_i, is of one of the following two ki...
LiveCodeBench
999
3
On a blackboard, there are N sets S_1,S_2,\dots,S_N consisting of integers between 1 and M. Here, S_i = \lbrace S_{i,1},S_{i,2},\dots,S_{i,A_i} \rbrace. You may perform the following operation any number of times (possibly zero): - choose two sets X and Y with at least one common element. Erase them from the blackboa...
LiveCodeBench
1,000
1
On a blackboard, there are N sets S_1,S_2,\dots,S_N consisting of integers between 1 and M. Here, S_i = \lbrace S_{i,1},S_{i,2},\dots,S_{i,A_i} \rbrace. You may perform the following operation any number of times (possibly zero): - choose two sets X and Y with at least one common element. Erase them from the blackboa...
LiveCodeBench
1,000
2
On a blackboard, there are N sets S_1,S_2,\dots,S_N consisting of integers between 1 and M. Here, S_i = \lbrace S_{i,1},S_{i,2},\dots,S_{i,A_i} \rbrace. You may perform the following operation any number of times (possibly zero): - choose two sets X and Y with at least one common element. Erase them from the blackboa...
LiveCodeBench
1,000
3
Two characters x and y are called similar characters if and only if one of the following conditions is satisfied: - x and y are the same character. - One of x and y is 1 and the other is l. - One of x and y is 0 and the other is o. Two strings S and T, each of length N, are called similar strings if and only if: - f...
LiveCodeBench
1,001
1
Two characters x and y are called similar characters if and only if one of the following conditions is satisfied: - x and y are the same character. - One of x and y is 1 and the other is l. - One of x and y is 0 and the other is o. Two strings S and T, each of length N, are called similar strings if and only if: - f...
LiveCodeBench
1,001
2
Two characters x and y are called similar characters if and only if one of the following conditions is satisfied: - x and y are the same character. - One of x and y is 1 and the other is l. - One of x and y is 0 and the other is o. Two strings S and T, each of length N, are called similar strings if and only if: - f...
LiveCodeBench
1,001
3
N people numbered 1,2,\ldots,N were in M photos. In each of the photos, they stood in a single line. In the i-th photo, the j-th person from the left is person a_{i,j}. Two people who did not stand next to each other in any of the photos may be in a bad mood. How many pairs of people may be in a bad mood? Here, we...
LiveCodeBench
1,002
1
N people numbered 1,2,\ldots,N were in M photos. In each of the photos, they stood in a single line. In the i-th photo, the j-th person from the left is person a_{i,j}. Two people who did not stand next to each other in any of the photos may be in a bad mood. How many pairs of people may be in a bad mood? Here, we...
LiveCodeBench
1,002
2
N people numbered 1,2,\ldots,N were in M photos. In each of the photos, they stood in a single line. In the i-th photo, the j-th person from the left is person a_{i,j}. Two people who did not stand next to each other in any of the photos may be in a bad mood. How many pairs of people may be in a bad mood? Here, we...
LiveCodeBench
1,002
3
On a two-dimensional plane, Takahashi is initially at point (0, 0), and his initial health is H. M items to recover health are placed on the plane; the i-th of them is placed at (x_i,y_i). Takahashi will make N moves. The i-th move is as follows. - Let (x,y) be his current coordinates. He consumes a health of 1 to...
LiveCodeBench
1,003
1
On a two-dimensional plane, Takahashi is initially at point (0, 0), and his initial health is H. M items to recover health are placed on the plane; the i-th of them is placed at (x_i,y_i). Takahashi will make N moves. The i-th move is as follows. - Let (x,y) be his current coordinates. He consumes a health of 1 to...
LiveCodeBench
1,003
2
On a two-dimensional plane, Takahashi is initially at point (0, 0), and his initial health is H. M items to recover health are placed on the plane; the i-th of them is placed at (x_i,y_i). Takahashi will make N moves. The i-th move is as follows. - Let (x,y) be his current coordinates. He consumes a health of 1 to...
LiveCodeBench
1,003
3
Your computer has a keyboard with three keys: 'a' key, Shift key, and Caps Lock key. The Caps Lock key has a light on it. Initially, the light on the Caps Lock key is off, and the screen shows an empty string. You can do the following three actions any number of times in any order: - Spend X milliseconds to press onl...
LiveCodeBench
1,004
1
Your computer has a keyboard with three keys: 'a' key, Shift key, and Caps Lock key. The Caps Lock key has a light on it. Initially, the light on the Caps Lock key is off, and the screen shows an empty string. You can do the following three actions any number of times in any order: - Spend X milliseconds to press onl...
LiveCodeBench
1,004
2
Your computer has a keyboard with three keys: 'a' key, Shift key, and Caps Lock key. The Caps Lock key has a light on it. Initially, the light on the Caps Lock key is off, and the screen shows an empty string. You can do the following three actions any number of times in any order: - Spend X milliseconds to press onl...
LiveCodeBench
1,004
3
A graph with (k+1) vertices and k edges is called a level-k\ (k\geq 2) star if and only if: - it has a vertex that is connected to each of the other k vertices with an edge, and there are no other edges. At first, Takahashi had a graph consisting of stars. He repeated the following operation until every pair of vert...
LiveCodeBench
1,005
1
A graph with (k+1) vertices and k edges is called a level-k\ (k\geq 2) star if and only if: - it has a vertex that is connected to each of the other k vertices with an edge, and there are no other edges. At first, Takahashi had a graph consisting of stars. He repeated the following operation until every pair of vert...
LiveCodeBench
1,005
2
A graph with (k+1) vertices and k edges is called a level-k\ (k\geq 2) star if and only if: - it has a vertex that is connected to each of the other k vertices with an edge, and there are no other edges. At first, Takahashi had a graph consisting of stars. He repeated the following operation until every pair of vert...
LiveCodeBench
1,005
3
There are N people numbered 1, 2, \ldots, N, sitting in this clockwise order around a round table. In particular, person 1 is sitting next to person N in the clockwise direction. For each i = 1, 2, \ldots, N, person i has a name S_i and an age A_i. Here, no two people have the same name or the same age. Starting from...
LiveCodeBench
1,006
1
There are N people numbered 1, 2, \ldots, N, sitting in this clockwise order around a round table. In particular, person 1 is sitting next to person N in the clockwise direction. For each i = 1, 2, \ldots, N, person i has a name S_i and an age A_i. Here, no two people have the same name or the same age. Starting from...
LiveCodeBench
1,006
2
There are N people numbered 1, 2, \ldots, N, sitting in this clockwise order around a round table. In particular, person 1 is sitting next to person N in the clockwise direction. For each i = 1, 2, \ldots, N, person i has a name S_i and an age A_i. Here, no two people have the same name or the same age. Starting from...
LiveCodeBench
1,006
3
You are given an integer N. Print an approximation of N according to the following instructions. - If N is less than or equal to 10^3-1, print N as it is. - If N is between 10^3 and 10^4-1, inclusive, truncate the ones digit of N and print the result. - If N is between 10^4 and 10^5-1, inclusive, truncate the tens di...
LiveCodeBench
1,007
1
You are given an integer N. Print an approximation of N according to the following instructions. - If N is less than or equal to 10^3-1, print N as it is. - If N is between 10^3 and 10^4-1, inclusive, truncate the ones digit of N and print the result. - If N is between 10^4 and 10^5-1, inclusive, truncate the tens di...
LiveCodeBench
1,007
2
You are given an integer N. Print an approximation of N according to the following instructions. - If N is less than or equal to 10^3-1, print N as it is. - If N is between 10^3 and 10^4-1, inclusive, truncate the ones digit of N and print the result. - If N is between 10^4 and 10^5-1, inclusive, truncate the tens di...
LiveCodeBench
1,007
3
There are N people numbered 1, 2, \ldots, N on a two-dimensional plane, and person i is at the point represented by the coordinates (X_i,Y_i). Person 1 has been infected with a virus. The virus spreads to people within a distance of D from an infected person. Here, the distance is defined as the Euclidean distance, tha...
LiveCodeBench
1,008
1
There are N people numbered 1, 2, \ldots, N on a two-dimensional plane, and person i is at the point represented by the coordinates (X_i,Y_i). Person 1 has been infected with a virus. The virus spreads to people within a distance of D from an infected person. Here, the distance is defined as the Euclidean distance, tha...
LiveCodeBench
1,008
2
There are N people numbered 1, 2, \ldots, N on a two-dimensional plane, and person i is at the point represented by the coordinates (X_i,Y_i). Person 1 has been infected with a virus. The virus spreads to people within a distance of D from an infected person. Here, the distance is defined as the Euclidean distance, tha...
LiveCodeBench
1,008
3
There is a rectangular cake with some strawberries on the xy-plane. The cake occupies the rectangular area \lbrace (x, y) : 0 \leq x \leq W, 0 \leq y \leq H \rbrace. There are N strawberries on the cake, and the coordinates of the i-th strawberry are (p_i, q_i) for i = 1, 2, \ldots, N. No two strawberries have the same...
LiveCodeBench
1,009
1
There is a rectangular cake with some strawberries on the xy-plane. The cake occupies the rectangular area \lbrace (x, y) : 0 \leq x \leq W, 0 \leq y \leq H \rbrace. There are N strawberries on the cake, and the coordinates of the i-th strawberry are (p_i, q_i) for i = 1, 2, \ldots, N. No two strawberries have the same...
LiveCodeBench
1,009
2
There is a rectangular cake with some strawberries on the xy-plane. The cake occupies the rectangular area \lbrace (x, y) : 0 \leq x \leq W, 0 \leq y \leq H \rbrace. There are N strawberries on the cake, and the coordinates of the i-th strawberry are (p_i, q_i) for i = 1, 2, \ldots, N. No two strawberries have the same...
LiveCodeBench
1,009
3
You are given an undirected graph G with N vertices and M edges. For i = 1, 2, \ldots, M, the i-th edge is an undirected edge connecting vertices u_i and v_i. A graph with N vertices is called good if the following condition holds for all i = 1, 2, \ldots, K: - there is no path connecting vertices x_i and y_i in G. ...
LiveCodeBench
1,010
1
You are given an undirected graph G with N vertices and M edges. For i = 1, 2, \ldots, M, the i-th edge is an undirected edge connecting vertices u_i and v_i. A graph with N vertices is called good if the following condition holds for all i = 1, 2, \ldots, K: - there is no path connecting vertices x_i and y_i in G. ...
LiveCodeBench
1,010
2
You are given an undirected graph G with N vertices and M edges. For i = 1, 2, \ldots, M, the i-th edge is an undirected edge connecting vertices u_i and v_i. A graph with N vertices is called good if the following condition holds for all i = 1, 2, \ldots, K: - there is no path connecting vertices x_i and y_i in G. ...
LiveCodeBench
1,010
3
There is an ultramarathon course totaling 100\;\mathrm{km}. Water stations are set up every 5\;\mathrm{km} along the course, including the start and goal, for a total of 21. Takahashi is at the N\;\mathrm{km} point of this course. Find the position of the nearest water station to him. Under the constraints of this pr...
LiveCodeBench
1,011
1
There is an ultramarathon course totaling 100\;\mathrm{km}. Water stations are set up every 5\;\mathrm{km} along the course, including the start and goal, for a total of 21. Takahashi is at the N\;\mathrm{km} point of this course. Find the position of the nearest water station to him. Under the constraints of this pr...
LiveCodeBench
1,011
2
There is an ultramarathon course totaling 100\;\mathrm{km}. Water stations are set up every 5\;\mathrm{km} along the course, including the start and goal, for a total of 21. Takahashi is at the N\;\mathrm{km} point of this course. Find the position of the nearest water station to him. Under the constraints of this pr...
LiveCodeBench
1,011
3
There are 7 points A, B, C, D, E, F, and G on a straight line, in this order. (See also the figure below.) The distances between adjacent points are as follows. - Between A and B: 3 - Between B and C: 1 - Between C and D: 4 - Between D and E: 1 - Between E and F: 5 - Between F and G: 9 You are given two uppercase E...
LiveCodeBench
1,012
1
There are 7 points A, B, C, D, E, F, and G on a straight line, in this order. (See also the figure below.) The distances between adjacent points are as follows. - Between A and B: 3 - Between B and C: 1 - Between C and D: 4 - Between D and E: 1 - Between E and F: 5 - Between F and G: 9 You are given two uppercase E...
LiveCodeBench
1,012
2
There are 7 points A, B, C, D, E, F, and G on a straight line, in this order. (See also the figure below.) The distances between adjacent points are as follows. - Between A and B: 3 - Between B and C: 1 - Between C and D: 4 - Between D and E: 1 - Between E and F: 5 - Between F and G: 9 You are given two uppercase E...
LiveCodeBench
1,012
3
There is a grid with H rows and W columns. Let (i, j) denote the square at the i-th row from the top and the j-th column from the left. Initially, there was one cookie on each square inside a rectangle whose height and width were at least 2 squares long, and no cookie on the other squares. Formally, there was exactly...
LiveCodeBench
1,013
1
There is a grid with H rows and W columns. Let (i, j) denote the square at the i-th row from the top and the j-th column from the left. Initially, there was one cookie on each square inside a rectangle whose height and width were at least 2 squares long, and no cookie on the other squares. Formally, there was exactly...
LiveCodeBench
1,013
2
There is a grid with H rows and W columns. Let (i, j) denote the square at the i-th row from the top and the j-th column from the left. Initially, there was one cookie on each square inside a rectangle whose height and width were at least 2 squares long, and no cookie on the other squares. Formally, there was exactly...
LiveCodeBench
1,013
3
Takahashi keeps a sleep log. The log is represented as an odd-length sequence A=(A _ 1(=0), A _ 2,\ldots,A _ N), where odd-numbered elements represent times he got up, and even-numbered elements represent times he went to bed. More formally, he had the following sleep sessions after starting the sleep log. - For eve...
LiveCodeBench
1,014
1
Takahashi keeps a sleep log. The log is represented as an odd-length sequence A=(A _ 1(=0), A _ 2,\ldots,A _ N), where odd-numbered elements represent times he got up, and even-numbered elements represent times he went to bed. More formally, he had the following sleep sessions after starting the sleep log. - For eve...
LiveCodeBench
1,014
2
Takahashi keeps a sleep log. The log is represented as an odd-length sequence A=(A _ 1(=0), A _ 2,\ldots,A _ N), where odd-numbered elements represent times he got up, and even-numbered elements represent times he went to bed. More formally, he had the following sleep sessions after starting the sleep log. - For eve...
LiveCodeBench
1,014
3
There is a simple undirected graph with N vertices and M edges, where vertices are numbered from 1 to N, and edges are numbered from 1 to M. Edge i connects vertex a_i and vertex b_i. K security guards numbered from 1 to K are on some vertices. Guard i is on vertex p_i and has a stamina of h_i. All p_i are distinct. A ...
LiveCodeBench
1,015
1
There is a simple undirected graph with N vertices and M edges, where vertices are numbered from 1 to N, and edges are numbered from 1 to M. Edge i connects vertex a_i and vertex b_i. K security guards numbered from 1 to K are on some vertices. Guard i is on vertex p_i and has a stamina of h_i. All p_i are distinct. A ...
LiveCodeBench
1,015
2
There is a simple undirected graph with N vertices and M edges, where vertices are numbered from 1 to N, and edges are numbered from 1 to M. Edge i connects vertex a_i and vertex b_i. K security guards numbered from 1 to K are on some vertices. Guard i is on vertex p_i and has a stamina of h_i. All p_i are distinct. A ...
LiveCodeBench
1,015
3
You are given a string S of length N consisting of lowercase English letters. We denote the i-th character of S by S_i. Print the string of length 2N obtained by concatenating S_1,S_1,S_2,S_2,\dots,S_N, and S_N in this order. For example, if S is beginner, print bbeeggiinnnneerr. Input The input is given from Standar...
LiveCodeBench
1,016
1
You are given a string S of length N consisting of lowercase English letters. We denote the i-th character of S by S_i. Print the string of length 2N obtained by concatenating S_1,S_1,S_2,S_2,\dots,S_N, and S_N in this order. For example, if S is beginner, print bbeeggiinnnneerr. Input The input is given from Standar...
LiveCodeBench
1,016
2
You are given a string S of length N consisting of lowercase English letters. We denote the i-th character of S by S_i. Print the string of length 2N obtained by concatenating S_1,S_1,S_2,S_2,\dots,S_N, and S_N in this order. For example, if S is beginner, print bbeeggiinnnneerr. Input The input is given from Standar...
LiveCodeBench
1,016
3
You are given a sequence A=(A_0,A_1,\dots,A_{63}) of length 64 consisting of 0 and 1. Find A_0 2^0 + A_1 2^1 + \dots + A_{63} 2^{63}. Input The input is given from Standard Input in the following format: A_0 A_1 \dots A_{63} Output Print the answer as an integer. Constraints - A_i is 0 or 1. Sample Input 1 1 0...
LiveCodeBench
1,017
1
You are given a sequence A=(A_0,A_1,\dots,A_{63}) of length 64 consisting of 0 and 1. Find A_0 2^0 + A_1 2^1 + \dots + A_{63} 2^{63}. Input The input is given from Standard Input in the following format: A_0 A_1 \dots A_{63} Output Print the answer as an integer. Constraints - A_i is 0 or 1. Sample Input 1 1 0...
LiveCodeBench
1,017
2
You are given a sequence A=(A_0,A_1,\dots,A_{63}) of length 64 consisting of 0 and 1. Find A_0 2^0 + A_1 2^1 + \dots + A_{63} 2^{63}. Input The input is given from Standard Input in the following format: A_0 A_1 \dots A_{63} Output Print the answer as an integer. Constraints - A_i is 0 or 1. Sample Input 1 1 0...
LiveCodeBench
1,017
3
You are given a sequence A=(A_1,A_2,\dots,A_{3N}) of length 3N where each of 1,2,\dots, and N occurs exactly three times. For i=1,2,\dots,N, let f(i) be the index of the middle occurrence of i in A. Sort 1,2,\dots,N in ascending order of f(i). Formally, f(i) is defined as follows. - Suppose that those j such that A_j ...
LiveCodeBench
1,018
1
You are given a sequence A=(A_1,A_2,\dots,A_{3N}) of length 3N where each of 1,2,\dots, and N occurs exactly three times. For i=1,2,\dots,N, let f(i) be the index of the middle occurrence of i in A. Sort 1,2,\dots,N in ascending order of f(i). Formally, f(i) is defined as follows. - Suppose that those j such that A_j ...
LiveCodeBench
1,018
2
You are given a sequence A=(A_1,A_2,\dots,A_{3N}) of length 3N where each of 1,2,\dots, and N occurs exactly three times. For i=1,2,\dots,N, let f(i) be the index of the middle occurrence of i in A. Sort 1,2,\dots,N in ascending order of f(i). Formally, f(i) is defined as follows. - Suppose that those j such that A_j ...
LiveCodeBench
1,018
3
Takahashi has decided to enjoy a wired full-course meal consisting of N courses in a restaurant. The i-th course is: - if X_i=0, an antidotal course with a tastiness of Y_i; - if X_i=1, a poisonous course with a tastiness of Y_i. When Takahashi eats a course, his state changes as follows: - Initially, Takahashi h...
LiveCodeBench
1,019
1
Takahashi has decided to enjoy a wired full-course meal consisting of N courses in a restaurant. The i-th course is: - if X_i=0, an antidotal course with a tastiness of Y_i; - if X_i=1, a poisonous course with a tastiness of Y_i. When Takahashi eats a course, his state changes as follows: - Initially, Takahashi h...
LiveCodeBench
1,019
2
Takahashi has decided to enjoy a wired full-course meal consisting of N courses in a restaurant. The i-th course is: - if X_i=0, an antidotal course with a tastiness of Y_i; - if X_i=1, a poisonous course with a tastiness of Y_i. When Takahashi eats a course, his state changes as follows: - Initially, Takahashi h...
LiveCodeBench
1,019
3
We have a sequence A=(A_1,A_2,\dots,A_N) of length N. Initially, all the terms are 0. Using an integer K given in the input, we define a function f(A) as follows: - Let B be the sequence obtained by sorting A in descending order (so that it becomes monotonically non-increasing). - Then, let f(A)=B_1 + B_2 + \dots + ...
LiveCodeBench
1,020
1
We have a sequence A=(A_1,A_2,\dots,A_N) of length N. Initially, all the terms are 0. Using an integer K given in the input, we define a function f(A) as follows: - Let B be the sequence obtained by sorting A in descending order (so that it becomes monotonically non-increasing). - Then, let f(A)=B_1 + B_2 + \dots + ...
LiveCodeBench
1,020
2
We have a sequence A=(A_1,A_2,\dots,A_N) of length N. Initially, all the terms are 0. Using an integer K given in the input, we define a function f(A) as follows: - Let B be the sequence obtained by sorting A in descending order (so that it becomes monotonically non-increasing). - Then, let f(A)=B_1 + B_2 + \dots + ...
LiveCodeBench
1,020
3
Takahashi has recorded the number of steps he walked for N weeks. He walked A_i steps on the i-th day. Find the total number of steps Takahashi walked each week. More precisely, find the sum of the steps for the first week (the 1-st through 7-th day), the sum of the steps for the second week (the 8-th through 14-th da...
LiveCodeBench
1,021
1
Takahashi has recorded the number of steps he walked for N weeks. He walked A_i steps on the i-th day. Find the total number of steps Takahashi walked each week. More precisely, find the sum of the steps for the first week (the 1-st through 7-th day), the sum of the steps for the second week (the 8-th through 14-th da...
LiveCodeBench
1,021
2
Takahashi has recorded the number of steps he walked for N weeks. He walked A_i steps on the i-th day. Find the total number of steps Takahashi walked each week. More precisely, find the sum of the steps for the first week (the 1-st through 7-th day), the sum of the steps for the second week (the 8-th through 14-th da...
LiveCodeBench
1,021
3
You are given N strings S_1,S_2,\ldots,S_N consisting of lowercase English letters. Determine if there are distinct integers i and j between 1 and N, inclusive, such that the concatenation of S_i and S_j in this order is a palindrome. A string T of length M is a palindrome if and only if the i-th character and the (M+...
LiveCodeBench
1,022
1
You are given N strings S_1,S_2,\ldots,S_N consisting of lowercase English letters. Determine if there are distinct integers i and j between 1 and N, inclusive, such that the concatenation of S_i and S_j in this order is a palindrome. A string T of length M is a palindrome if and only if the i-th character and the (M+...
LiveCodeBench
1,022
2
You are given N strings S_1,S_2,\ldots,S_N consisting of lowercase English letters. Determine if there are distinct integers i and j between 1 and N, inclusive, such that the concatenation of S_i and S_j in this order is a palindrome. A string T of length M is a palindrome if and only if the i-th character and the (M+...
LiveCodeBench
1,022
3
Takahashi has two sheets A and B, each composed of black squares and transparent squares, and an infinitely large sheet C composed of transparent squares. There is also an ideal sheet X for Takahashi composed of black squares and transparent squares. The sizes of sheets A, B, and X are H_A rows \times W_A columns, H_B ...
LiveCodeBench
1,023
1
Takahashi has two sheets A and B, each composed of black squares and transparent squares, and an infinitely large sheet C composed of transparent squares. There is also an ideal sheet X for Takahashi composed of black squares and transparent squares. The sizes of sheets A, B, and X are H_A rows \times W_A columns, H_B ...
LiveCodeBench
1,023
2
Takahashi has two sheets A and B, each composed of black squares and transparent squares, and an infinitely large sheet C composed of transparent squares. There is also an ideal sheet X for Takahashi composed of black squares and transparent squares. The sizes of sheets A, B, and X are H_A rows \times W_A columns, H_B ...
LiveCodeBench
1,023
3
You are given a string S of length N consisting of lowercase English letters and the characters ( and ). Print the string S after performing the following operation as many times as possible. - Choose and delete a contiguous substring of S that starts with (, ends with ), and does not contain ( or ) other than the fi...
LiveCodeBench
1,024
1
You are given a string S of length N consisting of lowercase English letters and the characters ( and ). Print the string S after performing the following operation as many times as possible. - Choose and delete a contiguous substring of S that starts with (, ends with ), and does not contain ( or ) other than the fi...
LiveCodeBench
1,024
2
You are given a string S of length N consisting of lowercase English letters and the characters ( and ). Print the string S after performing the following operation as many times as possible. - Choose and delete a contiguous substring of S that starts with (, ends with ), and does not contain ( or ) other than the fi...
LiveCodeBench
1,024
3
There are N people numbered from 1 to N standing in a circle. Person 1 is to the right of person 2, person 2 is to the right of person 3, ..., and person N is to the right of person 1. We will give each of the N people an integer between 0 and M-1, inclusive. Among the M^N ways to distribute integers, find the number, ...
LiveCodeBench
1,025
1
There are N people numbered from 1 to N standing in a circle. Person 1 is to the right of person 2, person 2 is to the right of person 3, ..., and person N is to the right of person 1. We will give each of the N people an integer between 0 and M-1, inclusive. Among the M^N ways to distribute integers, find the number, ...
LiveCodeBench
1,025
2
There are N people numbered from 1 to N standing in a circle. Person 1 is to the right of person 2, person 2 is to the right of person 3, ..., and person N is to the right of person 1. We will give each of the N people an integer between 0 and M-1, inclusive. Among the M^N ways to distribute integers, find the number, ...
LiveCodeBench
1,025
3
Given eight integers S_1,S_2,\dots, and S_8, print Yes if they satisfy all of the following three conditions, and No otherwise. - The sequence (S_1,S_2,\dots,S_8) is monotonically non-decreasing. In other words, S_1 \leq S_2 \leq \dots \leq S_8. - S_1,S_2,\dots, and S_8 are all between 100 and 675, inclusive. - S_1,...
LiveCodeBench
1,026
1
Given eight integers S_1,S_2,\dots, and S_8, print Yes if they satisfy all of the following three conditions, and No otherwise. - The sequence (S_1,S_2,\dots,S_8) is monotonically non-decreasing. In other words, S_1 \leq S_2 \leq \dots \leq S_8. - S_1,S_2,\dots, and S_8 are all between 100 and 675, inclusive. - S_1,...
LiveCodeBench
1,026
2
Given eight integers S_1,S_2,\dots, and S_8, print Yes if they satisfy all of the following three conditions, and No otherwise. - The sequence (S_1,S_2,\dots,S_8) is monotonically non-decreasing. In other words, S_1 \leq S_2 \leq \dots \leq S_8. - S_1,S_2,\dots, and S_8 are all between 100 and 675, inclusive. - S_1,...
LiveCodeBench
1,026
3
Takahashi ate N plates of sushi at a sushi restaurant. The color of the i-th plate is represented by a string C_i. The price of a sushi corresponds to the color of the plate. For each i=1,\ldots,M, the sushi on a plate whose color is represented by a string D_i is worth P_i yen a plate (yen is the currency of Japan)....
LiveCodeBench
1,027
1
Takahashi ate N plates of sushi at a sushi restaurant. The color of the i-th plate is represented by a string C_i. The price of a sushi corresponds to the color of the plate. For each i=1,\ldots,M, the sushi on a plate whose color is represented by a string D_i is worth P_i yen a plate (yen is the currency of Japan)....
LiveCodeBench
1,027
2
Takahashi ate N plates of sushi at a sushi restaurant. The color of the i-th plate is represented by a string C_i. The price of a sushi corresponds to the color of the plate. For each i=1,\ldots,M, the sushi on a plate whose color is represented by a string D_i is worth P_i yen a plate (yen is the currency of Japan)....
LiveCodeBench
1,027
3
N people numbered 1 through N tossed a coin several times. We know that person i's tosses resulted in A_i heads and B_i tails. Person i's success rate of the tosses is defined by \displaystyle\frac{A_i}{A_i+B_i}. Sort people 1,\ldots,N in descending order of their success rates, with ties broken in ascending order of...
LiveCodeBench
1,028
1
N people numbered 1 through N tossed a coin several times. We know that person i's tosses resulted in A_i heads and B_i tails. Person i's success rate of the tosses is defined by \displaystyle\frac{A_i}{A_i+B_i}. Sort people 1,\ldots,N in descending order of their success rates, with ties broken in ascending order of...
LiveCodeBench
1,028
2
N people numbered 1 through N tossed a coin several times. We know that person i's tosses resulted in A_i heads and B_i tails. Person i's success rate of the tosses is defined by \displaystyle\frac{A_i}{A_i+B_i}. Sort people 1,\ldots,N in descending order of their success rates, with ties broken in ascending order of...
LiveCodeBench
1,028
3
We have a grid with H horizontal rows and W vertical columns. We denote by (i,j) the cell at the i-th row from the top and j-th column from the left. Each cell in the grid has a lowercase English letter written on it. The letter written on (i,j) equals the j-th character of a given string S_i. Snuke will repeat movi...
LiveCodeBench
1,029
1
We have a grid with H horizontal rows and W vertical columns. We denote by (i,j) the cell at the i-th row from the top and j-th column from the left. Each cell in the grid has a lowercase English letter written on it. The letter written on (i,j) equals the j-th character of a given string S_i. Snuke will repeat movi...
LiveCodeBench
1,029
2
We have a grid with H horizontal rows and W vertical columns. We denote by (i,j) the cell at the i-th row from the top and j-th column from the left. Each cell in the grid has a lowercase English letter written on it. The letter written on (i,j) equals the j-th character of a given string S_i. Snuke will repeat movi...
LiveCodeBench
1,029
3
You are given a length-N sequence A=(A_1,A_2,\dots,A_N) consisting of 0, 1, and 2, and a length-N string S=S_1S_2\dots S_N consisting of M, E, and X. Find the sum of \text{mex}(A_i,A_j,A_k) over all tuples of integers (i,j,k) such that 1 \leq i < j < k \leq N and S_iS_jS_k= MEX. Here, \text{mex}(A_i,A_j,A_k) denotes...
LiveCodeBench
1,030
1
You are given a length-N sequence A=(A_1,A_2,\dots,A_N) consisting of 0, 1, and 2, and a length-N string S=S_1S_2\dots S_N consisting of M, E, and X. Find the sum of \text{mex}(A_i,A_j,A_k) over all tuples of integers (i,j,k) such that 1 \leq i < j < k \leq N and S_iS_jS_k= MEX. Here, \text{mex}(A_i,A_j,A_k) denotes...
LiveCodeBench
1,030
2
You are given a length-N sequence A=(A_1,A_2,\dots,A_N) consisting of 0, 1, and 2, and a length-N string S=S_1S_2\dots S_N consisting of M, E, and X. Find the sum of \text{mex}(A_i,A_j,A_k) over all tuples of integers (i,j,k) such that 1 \leq i < j < k \leq N and S_iS_jS_k= MEX. Here, \text{mex}(A_i,A_j,A_k) denotes...
LiveCodeBench
1,030
3
You are in a store to buy N items. The regular price of the i-th item is P_i yen (the currency in Japan). You have M coupons. You can use the i-th coupon to buy an item whose regular price is at least L_i yen at a D_i-yen discount. Here, each coupon can be used only once. Besides, multiple coupons cannot be used for...
LiveCodeBench
1,031
1
You are in a store to buy N items. The regular price of the i-th item is P_i yen (the currency in Japan). You have M coupons. You can use the i-th coupon to buy an item whose regular price is at least L_i yen at a D_i-yen discount. Here, each coupon can be used only once. Besides, multiple coupons cannot be used for...
LiveCodeBench
1,031
2
You are in a store to buy N items. The regular price of the i-th item is P_i yen (the currency in Japan). You have M coupons. You can use the i-th coupon to buy an item whose regular price is at least L_i yen at a D_i-yen discount. Here, each coupon can be used only once. Besides, multiple coupons cannot be used for...
LiveCodeBench
1,031
3
We have the following 3 \times 3 board with integers from 1 through 9 written on it. You are given two integers A and B between 1 and 9, where A < B. Determine if the two squares with A and B written on them are adjacent horizontally. Input The input is given from Standard Input in the following format: A B Output ...
LiveCodeBench
1,032
1
We have the following 3 \times 3 board with integers from 1 through 9 written on it. You are given two integers A and B between 1 and 9, where A < B. Determine if the two squares with A and B written on them are adjacent horizontally. Input The input is given from Standard Input in the following format: A B Output ...
LiveCodeBench
1,032
2
We have the following 3 \times 3 board with integers from 1 through 9 written on it. You are given two integers A and B between 1 and 9, where A < B. Determine if the two squares with A and B written on them are adjacent horizontally. Input The input is given from Standard Input in the following format: A B Output ...
LiveCodeBench
1,032
3