problem_id
stringlengths
32
32
name
stringlengths
2
112
problem
stringlengths
200
14k
test_cases
stringlengths
33
79.2M
difficulty
stringclasses
34 values
language
listlengths
1
1
source
stringclasses
15 values
num_solutions
int64
1
1.12M
starter_code
stringlengths
0
1.47k
subset
stringclasses
4 values
reasoning
stringlengths
1.09k
133k
deepseek_solution
stringlengths
60
15k
correctness
bool
2 classes
reason
stringclasses
3 values
2109c20ab479b87629598ec5f19ec7bd
colarr
Chef had a hard time arguing with his friend, and after getting a great old kick Chef saw a colored array with N cells, numbered from 1 to N. The kick was so strong that Chef suddenly understood the rules of the game. Each cell is painted with a color. Here the colors are numbered from 1 to M. For any cell i, Chef c...
{"inputs": ["1\n4 2 1\n1 1 2 2\n1 1\n1 1\n1 1\n3 1\n0 1\n0 1\n1 0\n1 0"], "outputs": ["5"]}
2
[ "PYTHON3" ]
1
2
code_contests
Okay, let's try to understand this problem. So Chef has an array of cells, each with a color. He can repaint up to K cells. For each cell he repaints, there's a cost. The goal is to maximize the total points after subtracting the cost of repainting. Hmm. So, the steps are: for each cell, decide whether to repaint it, ...
To solve this problem, we need to determine the maximum points Chef can achieve by repainting up to K cells in an array, considering both the points gained from the new colors and the costs incurred from repainting. ### Approach 1. **Input Parsing**: Read the input values efficiently, including the number of test case...
true
64d5f3359402ce9b8a38f6f91782e329
gameaam
Two players are playing a game. The game is played on a sequence of positive integer pairs. The players make their moves alternatively. During his move the player chooses a pair and decreases the larger integer in the pair by a positive multiple of the smaller integer in the pair in such a way that both integers in the...
{"inputs": ["3\n1\n2 3\n2\n4 5\n5 6\n2\n2 3\n3 5", "3\n1\n2 3\n2\n4 5\n5 6\n2\n2 3\n1 5", "3\n1\n2 3\n2\n4 5\n5 6\n1\n2 3\n3 5", "3\n1\n1 3\n2\n6 5\n5 6\n1\n2 6\n5 5", "3\n1\n2 3\n2\n4 5\n5 3\n1\n2 3\n3 5", "3\n1\n2 3\n2\n6 2\n5 6\n1\n2 6\n3 5", "3\n1\n2 1\n2\n6 5\n5 6\n1\n2 3\n1 5", "3\n1\n2 4\n2\n10 5\n5 6\n1\n2 6\n5...
2
[ "PYTHON3" ]
1
2
code_contests
Okay, so I need to solve this problem where two players take turns reducing pairs of numbers according to specific rules, and determine if the first player can win assuming both play optimally. Hmm. Let's think about the game mechanics here. First, each move involves selecting a pair and subtracting a multiple of the ...
To solve this problem, we need to determine if the first player can win a game where players take turns reducing pairs of integers according to specific rules. The solution involves computing Grundy numbers for each pair and using the XOR operation to determine the winner. ### Approach 1. **Grundy Number Calculation**...
false
Code is incorrect.
6479b1ad352107435998f1cb59b0c38b
lucky5
Chef loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Chef has a positive integer N. He can apply any of the following operations as many times as he want...
{"inputs": ["3\n25\n46\n99", "3\n2\n46\n99", "3\n0\n7\n61", "3\n25\n46\n24", "3\n2\n60\n99", "3\n0\n8\n24", "3\n25\n46\n35", "3\n0\n5\n153", "3\n0\n12\n5", "3\n61\n4\n32", "3\n4\n1\n132", "3\n0\n13\n131", "3\n3\n4\n70", "3\n15\n15\n34", "3\n15\n15\n19", "3\n32\n5\n7", "3\n4\n5\n0", "3\n25\n46\n102", "3\n2\n60\n47", "3\...
2
[ "PYTHON3" ]
1
2
code_contests
Okay, let's try to figure out this problem. So the task is to find the minimum number of operations needed to turn a given number N into a lucky number. Lucky numbers are those that consist only of 4s and 7s. The operations allowed are adding 1, replacing a digit with any non-zero digit, or adding a leading non-zero di...
To solve this problem, we need to determine the minimum number of operations required to convert a given number into a lucky number (a number consisting only of the digits 4 and 7). The allowed operations are adding 1, replacing a digit with any non-zero digit, and adding a non-zero leading digit. ### Approach 1. **Co...
true
9862eeec5a0e8fb9aaf3f0ca64d49fc3
proposal
In PrimeLand, there existed a very handsome young prince named Prima. He greatly desired the Princess of Mathematics – Facie. However, before accepting his hand in marriage, Facie asked Prima to solve the following problem: The figure below shows a simple multiplication problem. However, not all the decimal digits ar...
{"inputs": ["5\n2 3 4 6 8", "5\n2 3 0 6 8", "5\n2 3 4 6 5", "5\n2 3 4 6 7", "5\n2 3 0 6 7", "5\n2 -1 8 6 4", "5\n6 0 8 5 2", "5\n6 0 4 5 2", "5\n3 1 9 6 15", "5\n3 1 9 4 15", "5\n3 5 9 1 2", "5\n3 5 4 1 2", "5\n3 9 4 1 2", "5\n5 18 4 1 2", "5\n5 8 4 1 2", "5\n5 8 4 0 2", "5\n1 3 4 6 7", "5\n6 0 8 4 2", "5\n4 0 4 5 2", ...
3
[ "PYTHON3" ]
1
2
code_contests
Okay, I need to solve this problem where I have to find all valid multiplication setups based on the given digits. Let's see. The problem involves a multiplication of a 3-digit number by a 2-digit number, resulting in a 4-digit product. The partial products are a 3-digit and a 4-digit (but wait, no, the partial product...
To solve this problem, we need to find all valid multiplication setups where a 3-digit number is multiplied by a 2-digit number, resulting in a 4-digit product. The digits used in all parts of the multiplication must be from a given subset of digits, and leading zeros are not allowed. ### Approach 1. **Input Handling*...
false
Code is incorrect.
d49d7aa678ad85640d0422496cf2de20
tech07
You are given a square with 'n' points on each side of the square. None of these points co-incide with the corners of this square. You have to compute the total number of triangles that can be formed using these '4n' points (n points on each side of the square) as vertices of the triangle. Input First line contains ...
{"inputs": ["1\n1", "1\n2", "1\n0", "1\n-1", "1\n-2", "1\n-4", "1\n-5", "1\n-8", "1\n-11", "1\n3", "1\n4", "1\n6", "1\n10", "1\n-3", "1\n-7", "1\n11", "1\n17", "1\n30", "1\n7", "1\n9", "1\n16", "1\n31", "1\n58", "1\n60", "1\n56", "1\n110", "1\n111", "1\n010", "1\n001", "1\n100", "1\n101", "1\n-6", "1\n-9", "1\n29", "1\...
6
[ "PYTHON3" ]
1
2
code_contests
Okay, let's tackle this problem. The task is to compute the number of triangles that can be formed using points on the sides of a square. Each side has 'n' points, and none are at the corners. So, for each test case with a given n, I need to find the total number of possible triangles. First, let's understand the setu...
To solve this problem, we need to compute the total number of triangles that can be formed using points placed on each side of a square. Each side of the square has 'n' points, excluding the corners. The solution involves calculating the total number of possible triangles and subtracting the number of degenerate (colli...
false
Code is incorrect.
6e04bf61ff9c511e939c0f739698b7c6
1012_B. Chemical table
Innopolis University scientists continue to investigate the periodic table. There are n·m known elements and they form a periodic table: a rectangle with n rows and m columns. Each element can be described by its coordinates (r, c) (1 ≤ r ≤ n, 1 ≤ c ≤ m) in the table. Recently scientists discovered that for every four...
{"inputs": ["1 5 3\n1 3\n1 1\n1 5\n", "2 2 3\n1 2\n2 2\n2 1\n", "4 3 6\n1 2\n1 3\n2 2\n2 3\n3 1\n3 3\n", "20 20 20\n18 16\n4 20\n2 5\n7 4\n11 13\n6 10\n20 8\n14 6\n3 12\n5 1\n16 7\n10 9\n1 11\n12 18\n19 15\n13 19\n17 3\n9 17\n15 2\n8 14\n", "20 20 1\n17 13\n", "1 1 0\n", "10000 9999 1\n5717 9264\n", "20 10 5\n18 10\n19...
8
[ "PYTHON3" ]
2
2
code_contests
Okay, let's tackle this problem. Hmm, the goal is to find the minimal number of elements the scientists need to purchase so that, combined with the elements they already have, they can produce all elements in the n×m grid using nuclear fusion as described. So, the nuclear fusion rule is that given any rectangle, if th...
To solve this problem, we need to determine the minimal number of elements the scientists need to purchase so that they can produce all elements in the n×m grid using nuclear fusion. The key insight is to model the problem using a bipartite graph where rows and columns are nodes, and elements are edges connecting these...
true
92b3f4c424fd03461bcbca3f6840e91b
1037_B. Reach Median
You are given an array a of n integers and an integer s. It is guaranteed that n is odd. In one operation you can either increase or decrease any single element by one. Calculate the minimum number of operations required to make the median of the array being equal to s. The median of the array with odd length is the ...
{"inputs": ["3 8\n6 5 8\n", "7 20\n21 15 12 11 20 19 12\n", "3 1\n1 2 5\n", "1 1\n100000\n", "5 1\n2 2 4 6 1\n", "3 10\n5 5 10\n", "1 1\n1\n", "3 4\n1 2 5\n", "1 100\n88\n", "1 100\n105\n", "3 2\n1 2 5\n", "3 10\n5 3 10\n", "3 4\n0 2 5\n", "1 100\n5\n", "7 20\n2 15 12 11 20 19 12\n", "3 0\n1 2 5\n", "3 4\n5 3 10\n", "1...
8
[ "PYTHON3" ]
2
2
code_contests
Okay, so I need to solve this problem where I have to find the minimum number of operations to make the median of an array equal to a given value s. The operations allowed are increasing or decreasing any element by 1, and each operation counts as one step. Let's think about how to approach this. First, the median of ...
To solve this problem, we need to determine the minimum number of operations required to make the median of an array equal to a given value \( s \). The operations allowed are increasing or decreasing any element by 1, and each operation counts as one step. ### Approach 1. **Understanding the Median**: The median of a...
true
9e840c792d748f70d4cb0e392de79281
105_C. Item World
Each item in the game has a level. The higher the level is, the higher basic parameters the item has. We shall consider only the following basic parameters: attack (atk), defense (def) and resistance to different types of impact (res). Each item belongs to one class. In this problem we will only consider three of such...
{"inputs": ["4\nsword weapon 10 2 3 2\npagstarmor armor 0 15 3 1\niceorb orb 3 2 13 2\nlongbow weapon 9 1 2 1\n6\nmike gladiator 5 longbow\nbobby sentry 6 pagstarmor\npetr gladiator 7 iceorb\nteddy physician 6 sword\nblackjack sentry 8 sword\njoe physician 6 iceorb\n", "4\nsword weapon 10 2 3 2\npagstarmor armor 0 15 3...
9
[ "PYTHON3" ]
2
2
code_contests
Okay, I need to solve this programming problem. Let's read the problem statement carefully. So the problem is about moving residents between items to maximize the attack of the weapon, then defense of the armor, then resistance of the orb. The items are of three classes: weapon, armor, orb. Each resident gives a bonus...
To solve this problem, we need to determine the optimal way to move residents between items to maximize the attack of a weapon, followed by the defense of an armor, and finally the resistance of an orb. The solution involves selecting the best possible combination of items and residents to achieve these goals. ### App...
false
Code is incorrect.
cf9133b37b2b4677bafdf4f6767df34c
1081_D. Maximum Distance
Chouti was tired of the tedious homework, so he opened up an old programming problem he created years ago. You are given a connected undirected graph with n vertices and m weighted edges. There are k special vertices: x_1, x_2, …, x_k. Let's define the cost of the path as the maximum weight of the edges in it. And th...
{"inputs": ["4 5 3\n1 2 3\n1 2 5\n4 2 1\n2 3 2\n1 4 4\n1 3 3\n", "2 3 2\n2 1\n1 2 3\n1 2 2\n2 2 1\n", "4 4 3\n1 2 3\n1 2 1\n2 3 2\n1 3 3\n1 4 4\n", "4 3 2\n1 4\n1 2 1\n2 3 5\n3 4 1\n", "3 2 2\n1 2\n1 2 1\n2 3 47\n", "3 2 2\n1 2\n1 2 1\n2 3 1000\n", "3 2 2\n1 2\n1 2 10\n2 3 100\n", "3 3 2\n2 3\n1 2 100\n1 3 100\n2 3 1\n...
10
[ "PYTHON3" ]
2
2
code_contests
Okay, let's see. So the problem is about finding for each special vertex the maximum distance to another special vertex. The distance here is defined as the minimum possible maximum edge weight along any path between two nodes. Hmm. Wait, right. So the distance between two nodes is the minimal maximum edge weight on a...
To solve this problem, we need to determine the maximum distance between each special vertex and the farthest special vertex in terms of the minimum possible maximum edge weight along any path connecting them. This can be efficiently solved using concepts from graph theory and union-find data structures. ### Approach ...
false
Code is incorrect.
f9e9b2c676340dd312270e7d27b54799
1100_D. Dasha and Chess
This is an interactive task. Dasha and NN like playing chess. While playing a match they decided that normal chess isn't interesting enough for them, so they invented a game described below. There are 666 black rooks and 1 white king on the chess board of size 999 × 999. The white king wins if he gets checked by rook...
{"inputs": ["999 999\n1 1\n1 2\n2 1\n2 2\n1 3\n2 3\n<...>\n26 13\n26 14\n26 15\n26 16\n\n1 700 800\n\n2 1 2\n\n<...>\n\n-1 -1 -1\n", "999 999\n1 1\n1 2\n2 1\n2 2\n1 3\n2 0\n<...>\n26 13\n26 14\n26 15\n26 16\n\n1 700 800\n\n2 1 2\n\n<...>\n\n-1 -1 -1\n", "999 999\n1 1\n1 2\n2 1\n2 2\n1 3\n2 0\n&l...
10
[ "PYTHON3" ]
2
2
code_contests
Okay, let's try to figure out how to solve this problem. So, the problem is about a game where a white king needs to get into a check by a black rook within 2000 moves. The king moves first each turn, and then Dasha moves one of her rooks. The challenge is to make sure that the king can always reach a check before 2000...
To solve this problem, we need to ensure that the white king can always get into check by a black rook within 2000 moves. The strategy involves checking adjacent squares for immediate check opportunities and moving towards the center of the board to maximize future options. ### Approach 1. **Immediate Check Check**: E...
false
Code is incorrect.
5ea70c1e2292a4a5d8c1b2f558b64a71
1129_A2. Toy Train
Alice received a set of Toy Train™ from Bob. It consists of one train and a connected railway network of n stations, enumerated from 1 through n. The train occupies one station at a time and travels around the network of stations in a circular manner. More precisely, the immediate station that the train will visit afte...
{"inputs": ["2 3\n1 2\n1 2\n1 2\n", "5 7\n2 4\n5 1\n2 3\n3 4\n4 1\n5 3\n3 5\n", "5 1\n3 2\n", "3 3\n1 2\n1 2\n1 2\n", "5 3\n2 4\n5 4\n3 2\n", "20 5\n3 12\n5 20\n16 4\n13 3\n9 14\n", "3 2\n3 1\n1 3\n", "3 1\n3 1\n", "3 2\n1 3\n2 1\n", "50 20\n4 18\n39 33\n49 32\n7 32\n38 1\n46 11\n8 1\n3 31\n30 47\n24 16\n33 5\n5 21\n3 ...
7
[ "PYTHON3" ]
2
2
code_contests
Okay, let's try to understand this problem. So, we have a circular railway system with n stations. The train moves around these stations in order, like 1→2→3→...→n→1, taking 1 second per move. Each candy starts at a station a_i and needs to be delivered to b_i. The challenge is to find, for each starting station i, the...
To solve this problem, we need to determine the minimum time required for a train to deliver all candies from each possible starting station on a circular railway network. The train can load only one candy per station visit, and we need to find the optimal delivery schedule for each starting station. ### Approach 1. *...
true
44679b0bab57567962fdf343771754d9
1149_B. Three Religions
During the archaeological research in the Middle East you found the traces of three ancient religions: First religion, Second religion and Third religion. You compiled the information on the evolution of each of these beliefs, and you now wonder if the followers of each religion could coexist in peace. The Word of Uni...
{"inputs": ["6 8\nabdabc\n+ 1 a\n+ 1 d\n+ 2 b\n+ 2 c\n+ 3 a\n+ 3 b\n+ 1 c\n- 2\n", "6 8\nabbaab\n+ 1 a\n+ 2 a\n+ 3 a\n+ 1 b\n+ 2 b\n+ 3 b\n- 1\n+ 2 z\n", "1 1\nt\n+ 2 p\n", "2 12\naa\n+ 1 a\n+ 2 a\n+ 3 a\n- 1\n+ 1 a\n- 2\n+ 2 a\n- 3\n+ 3 a\n+ 2 a\n- 1\n- 3\n", "2 10\nuh\n+ 1 h\n+ 2 u\n+ 3 h\n- 1\n- 2\n+ 2 h\n+ 3 u\n- 2...
8
[ "PYTHON3" ]
2
2
code_contests
Okay, I need to solve this programming problem. Let's read the problem statement carefully. The problem is about checking if three evolving strings (for three religions) can form disjoint subsequences of a given 'Word of Universe' after each update. The updates can be adding a character to a religion's description or ...
To solve this problem, we need to determine if three evolving strings can form disjoint subsequences of a given 'Word of Universe' after each update. The updates can be appending a character to a string or removing the last character from a string. The solution involves checking if the three strings can be embedded as ...
true
287199e83d57fe3e156d16d69d0643cd
1189_A. Keanu Reeves
After playing Neo in the legendary "Matrix" trilogy, Keanu Reeves started doubting himself: maybe we really live in virtual reality? To find if this is true, he needs to solve the following problem. Let's call a string consisting of only zeroes and ones good if it contains different numbers of zeroes and ones. For exa...
{"inputs": ["1\n1\n", "6\n100011\n", "2\n10\n", "72\n111101100111001110000000100010100000011011100110001010111010101011111100\n", "3\n101\n", "18\n101111001111000110\n", "7\n1111000\n", "3\n010\n", "12\n101010100101\n", "1\n0\n", "4\n1010\n", "6\n101100\n", "100\n00101100000011111101111010111001111010001100110111001000...
7
[ "PYTHON3" ]
2
2
code_contests
Okay, let's see. The problem is about splitting a binary string into the minimal number of substrings such that each substring is 'good'. A good string is one where the number of 0s and 1s are different. So, for each substring, the counts of 0s and 1s must not be equal. Hmm. The goal is to find the minimal number of s...
To solve this problem, we need to split a binary string into the minimal number of substrings such that each substring is 'good'. A substring is considered good if it contains a different number of zeros and ones. ### Approach 1. **Check the Entire String**: First, check if the entire string is already good. If it is...
true
68c1fe4ee739f97a3f5af45ad0f813b7
1208_A. XORinacci
Cengiz recently learned Fibonacci numbers and now he is studying different algorithms to find them. After getting bored of reading them, he came with his own new type of numbers that he named XORinacci numbers. He defined them as follows: * f(0) = a; * f(1) = b; * f(n) = f(n-1) ⊕ f(n-2) when n > 1, where ⊕ de...
{"inputs": ["3\n3 4 2\n4 5 0\n325 265 1231232\n", "10\n669924290 408119795 804030560\n663737793 250734602 29671646\n431160679 146708815 289491233\n189259304 606497663 379372476\n707829111 49504411 81710658\n54555019 65618101 626948607\n578351356 288589794 974275296\n400531973 205638174 323247740\n219131617 178762989 79...
7
[ "PYTHON3" ]
2
2
code_contests
Okay, let's see. I need to find the nth XORinacci number given a, b, and n. Hmm. So the definition is similar to Fibonacci but with XOR instead of addition. Let's think about how this sequence behaves. First, let's consider some small examples. Like the sample input where a=3, b=4, n=2. Then f(2) is 3 XOR4 which is 7....
To solve this problem, we need to determine the nth XORinacci number based on the given definition. The XORinacci sequence is defined similarly to the Fibonacci sequence but uses the bitwise XOR operation instead of addition. ### Approach The key insight here is recognizing that the XORinacci sequence exhibits a peri...
true
210dd88e3ed817c14bd95e3a2ee401f2
1227_A. Math Problem
Your math teacher gave you the following problem: There are n segments on the x-axis, [l_1; r_1], [l_2; r_2], …, [l_n; r_n]. The segment [l; r] includes the bounds, i.e. it is a set of such x that l ≤ x ≤ r. The length of the segment [l; r] is equal to r - l. Two segments [a; b] and [c; d] have a common point (inters...
{"inputs": ["4\n3\n4 5\n5 9\n7 7\n5\n11 19\n4 17\n16 16\n3 12\n14 17\n1\n1 10\n1\n1 1\n", "1\n2\n999999997 999999998\n999999999 1000000000\n", "4\n1\n1 1000000000\n5\n1 1\n12 18\n1000000000 1000000000\n1 1\n8888888 88888888\n5\n2 5\n3 6\n4 7\n5 8\n6 9\n3\n1 1000000000\n1 1\n1000000000 1000000000\n", "1\n10\n132182352 6...
7
[ "PYTHON3" ]
2
2
code_contests
Okay, I need to solve this programming problem. Let's read the problem carefully. The problem says that we have n segments on the x-axis. We need to add one segment that has at least one common point with each of the given segments. The added segment must be as short as possible. The goal is to find the minimal possib...
To solve this problem, we need to find the shortest possible segment that intersects all given segments on the x-axis. The solution involves determining the optimal segment by leveraging the maximum of the left endpoints and the minimum of the right endpoints of the given segments. ### Approach 1. **Problem Analysis**...
true
603412173f6b527803fbcfd227d41e92
124_D. Squares
You are given an infinite checkered field. You should get from a square (x1; y1) to a square (x2; y2). Using the shortest path is not necessary. You can move on the field squares in four directions. That is, when you are positioned in any square, you can move to any other side-neighboring one. A square (x; y) is cons...
{"inputs": ["2 2 1 0 0 1\n", "2 2 10 11 0 1\n", "2 4 3 -1 3 7\n", "605 297 -251700323 -366763764 -445828791 325081312\n", "14 9 44 45 -50 -9\n", "18 17 -26078453 -12853708 26705417 -4593122\n", "472555248 417950652 -897989583 -805741694 915661619 800897620\n", "1005 557 -451917708 -32771965 501646713 -357583032\n", "46...
10
[ "PYTHON3" ]
2
2
code_contests
Okay, I need to solve this programming problem. Let's read the problem carefully. The task is to find the minimum number of bad cells one has to visit when moving from (x1, y1) to (x2, y2). The movement is allowed in four directions (up, down, left, right), and each step moves to an adjacent cell. The path can be any ...
To solve this problem, we need to determine the minimum number of bad cells one must visit when moving from a starting cell (x1, y1) to a target cell (x2, y2) on an infinite grid. A cell is considered bad if it meets certain modular conditions related to the parameters a and b. ### Approach 1. **Understanding Bad Cell...
true
d4cc050eccac9f6962a49fda87daa472
1269_B. Modulo Equality
You are given a positive integer m and two integer sequence: a=[a_1, a_2, …, a_n] and b=[b_1, b_2, …, b_n]. Both of these sequence have a length n. Permutation is a sequence of n different positive integers from 1 to n. For example, these sequences are permutations: [1], [1,2], [2,1], [6,7,3,4,1,2,5]. These are not: [...
{"inputs": ["3 2\n0 0 0\n1 1 1\n", "4 3\n0 0 2 1\n2 0 1 1\n", "5 10\n0 0 0 1 2\n2 1 0 0 0\n", "20 10000000\n8861863 2169292 3484361 511558 5975675 1413584 774309 5847326 6668965 2531461 3337531 9484932 2648359 3710600 2232337 5474539 2785576 4119997 5005708 1717831\n247095 4003803 2013625 1177623 7391127 1314840 519822...
8
[ "PYTHON3" ]
2
2
code_contests
Okay, let's see. So the problem is to find the smallest non-negative integer x such that when we add x to each element in array a, modulo m, and then permute the elements, we get array b. Hmm. First, I need to understand what's required here. For each x, after adding it to all elements of a and modding by m, the multi...
To solve this problem, we need to find the smallest non-negative integer \( x \) such that when each element of array \( a \) is incremented by \( x \) modulo \( m \), the resulting array can be permuted to match array \( b \). ### Approach 1. **Sorting and Preprocessing**: First, sort the array \( b \) to form `sorte...
true
1e78c42ca94878513446e0e6add981eb
1291_B. Array Sharpening
You're given an array a_1, …, a_n of n non-negative integers. Let's call it sharpened if and only if there exists an integer 1 ≤ k ≤ n such that a_1 < a_2 < … < a_k and a_k > a_{k+1} > … > a_n. In particular, any strictly increasing or strictly decreasing array is sharpened. For example: * The arrays [4], [0, 1], [...
{"inputs": ["10\n1\n248618\n3\n12 10 8\n6\n100 11 15 9 7 8\n4\n0 1 1 0\n2\n0 0\n2\n0 1\n2\n1 0\n2\n1 1\n3\n0 1 0\n3\n1 0 1\n", "10\n1\n248618\n3\n12 10 8\n6\n100 11 15 9 2 8\n4\n0 1 1 0\n2\n0 0\n2\n0 1\n2\n1 0\n2\n1 1\n3\n0 1 0\n3\n1 0 1\n", "10\n1\n451008\n3\n12 10 8\n6\n000 11 15 9 2 8\n4\n0 1 1 0\n2\n0 0\n2\n0 1\n2\...
8
[ "PYTHON3" ]
2
2
code_contests
Okay, let's see. The problem is to determine whether we can turn a given array into a "sharpened" array by decreasing elements any number of times. A sharpened array has a peak at some position k such that the elements strictly increase up to k and then strictly decrease after k. So, the array must have a single peak, ...
To solve this problem, we need to determine if we can transform a given array into a "sharpened" array using a series of operations where we can decrease any strictly positive element by one. A sharpened array has a peak element such that the elements strictly increase up to the peak and then strictly decrease after th...
false
Code is incorrect.
007e27c0910133943194e3f9fc5f406c
1311_C. Perform the Combo
You want to perform the combo on your opponent in one popular fighting game. The combo is the string s consisting of n lowercase Latin letters. To perform the combo, you have to press all buttons in the order they appear in s. I.e. if s="abca" then you have to press 'a', then 'b', 'c' and 'a' again. You know that you ...
{"inputs": ["3\n4 2\nabca\n1 3\n10 5\ncodeforces\n2 8 3 2 9\n26 10\nqwertyuioplkjhgfdsazxcvbnm\n20 10 1 2 3 5 10 5 9 4\n", "2\n2 2\nyz\n1 1\n2 2\nyz\n1 1\n", "1\n11 2\nthisisatest\n3 5\n", "2\n2 2\nyz\n1 1\n2 2\nzy\n1 1\n", "1\n11 2\nthisisatest\n3 7\n", "3\n4 2\nabca\n1 3\n10 5\ncodeforces\n2 8 3 2 9\n26 10\nqwertyuio...
9
[ "PYTHON3" ]
2
2
code_contests
Okay, I need to solve this programming problem. Let me read the problem statement carefully. So, the problem is about counting how many times each character is pressed when performing a combo in a game, considering that after each wrong attempt, the player starts over. The key points are: - The combo is a string s of...
To solve this problem, we need to determine how many times each character in a given string is pressed when performing a combo in a game, considering both correct and incorrect attempts. The solution must efficiently handle multiple test cases with potentially large inputs. ### Approach 1. **Problem Analysis**: Each t...
false
Code is incorrect.
76933d20895b6172354d8212183e555f
1334_A. Level Statistics
Polycarp has recently created a new level in this cool new game Berlio Maker 85 and uploaded it online. Now players from all over the world can try his level. All levels in this game have two stats to them: the number of plays and the number of clears. So when a player attempts the level, the number of plays increases...
{"inputs": ["6\n3\n0 0\n1 1\n1 2\n2\n1 0\n1000 3\n4\n10 1\n15 2\n10 2\n15 2\n1\n765 432\n2\n4 4\n4 3\n5\n0 0\n1 0\n1 0\n1 0\n1 0\n", "1\n2\n110 2\n115 112\n", "10\n5\n88 60\n10 3\n48 21\n90 70\n40 88\n5\n20 81\n39 98\n34 87\n100 82\n21 21\n2\n46 91\n89 71\n2\n81 98\n25 36\n3\n84 97\n40 32\n17 29\n2\n56 16\n96 75\n5\n35...
7
[ "PYTHON3" ]
2
2
code_contests
Okay, let's see. We need to determine if the sequence of (p_i, c_i) pairs is possible based on the rules of the game. The problem says that each time someone attempts the level, the plays increase by 1. If they clear it, the clears also increase by 1. Both happen simultaneously. So between two consecutive check times, ...
To solve this problem, we need to determine if the sequence of (plays, clears) pairs recorded by Polycarp is valid based on the game's rules. Each play increases the play count, and each clear increases both the play and clear counts. We need to check the validity of these sequences according to the constraints provide...
true
6006f93aa6ed79169c73fd5c372a83ed
1354_C2. Not So Simple Polygon Embedding
The statement of this problem is the same as the statement of problem C1. The only difference is that, in problem C1, n is always even, and in C2, n is always odd. You are given a regular polygon with 2 ⋅ n vertices (it's convex and has equal sides and equal angles) and all its sides have length 1. Let's name it as 2n...
{"inputs": ["3\n3\n5\n199\n", "99\n3\n5\n7\n9\n11\n13\n15\n17\n19\n21\n23\n25\n27\n29\n31\n33\n35\n37\n39\n41\n43\n45\n47\n49\n51\n53\n55\n57\n59\n61\n63\n65\n67\n69\n71\n73\n75\n77\n79\n81\n83\n85\n87\n89\n91\n93\n95\n97\n99\n101\n103\n105\n107\n109\n111\n113\n115\n117\n119\n121\n123\n125\n127\n129\n131\n133\n135\n137...
9
[ "PYTHON3" ]
2
2
code_contests
Okay, I need to solve this programming problem where I have to find the minimum square side length that can fit a regular 2n-gon with each side length 1, where n is odd. Let's think about how to approach this. First, I remember that for a regular polygon, the way to fit it into the smallest square depends on the optim...
To solve this problem, we need to determine the minimum side length of a square that can fit a regular 2n-gon (where n is odd) with each side of length 1. The solution involves finding the optimal rotation of the polygon to minimize the required square size. ### Approach 1. **Understanding the Polygon**: A regular 2n-...
false
Code is incorrect.
b26c0cc60d6f8a9a2f446a35f33225b1
1374_B. Multiply by 2, divide by 6
You are given an integer n. In one move, you can either multiply n by two or divide n by 6 (if it is divisible by 6 without the remainder). Your task is to find the minimum number of moves needed to obtain 1 from n or determine if it's impossible to do that. You have to answer t independent test cases. Input The fi...
{"inputs": ["7\n1\n2\n3\n12\n12345\n15116544\n387420489\n", "1\n999838675\n", "1\n782058266\n", "7\n1\n2\n4\n12\n12345\n15116544\n387420489\n", "7\n1\n2\n4\n24\n12345\n2324038\n387420489\n", "7\n1\n2\n4\n24\n12345\n2324038\n655615894\n", "7\n1\n2\n3\n12\n22908\n15116544\n387420489\n", "7\n1\n2\n4\n24\n12345\n15116544\n...
8
[ "PYTHON3" ]
2
2
code_contests
Okay, let's see. The problem is to find the minimum number of moves to turn a number n into 1 using two operations: multiply by two or divide by six (if divisible). Hmm. So each move can be either multiply by 2 or divide by 6, but the division is only possible when the number is divisible by 6. The goal is to get to 1 ...
To solve this problem, we need to determine the minimum number of moves required to transform a given integer \( n \) into 1 using two operations: multiplying by 2 or dividing by 6 (if divisible). If it's impossible to achieve 1, we should return -1. ### Approach 1. **Prime Factorization Check**: First, we check if \(...
true
a32922519c8cbc6ed2909734fd0ca375
1397_C. Multiples of Length
You are given an array a of n integers. You want to make all elements of a equal to zero by doing the following operation exactly three times: * Select a segment, for each number in this segment we can add a multiple of len to it, where len is the length of this segment (added integers can be different). It can...
{"inputs": ["4\n1 3 2 4\n", "2\n-492673762 -496405053\n", "13\n-958184557 -577042357 -616514099 -553646903 -719490759 -761325526 -210773060 -44979753 864458686 -387054074 546903944 638449520 299190036\n", "5\n450402558 -840167367 -231820501 586187125 -627664644\n", "32\n474784688 671671886 -592758087 -662585781 9970031...
9
[ "PYTHON3" ]
2
2
code_contests
Okay, so I need to solve this problem where I have to make all elements of an array zero by performing exactly three operations. Each operation involves selecting a segment, and for each element in that segment, adding a multiple of the segment's length. The key here is that each added value b_i must be divisible by th...
To solve this problem, we need to make all elements of an array equal to zero using exactly three operations. Each operation allows us to select a segment of the array and add multiples of the segment's length to each element in the segment. ### Approach The approach to solve this problem involves three key steps: 1....
false
Code is incorrect.
ef3486d9a1c25de40121fd94fb0216d0
1420_D. Rescue Nibel!
Ori and Sein have overcome many difficult challenges. They finally lit the Shrouded Lantern and found Gumon Seal, the key to the Forlorn Ruins. When they tried to open the door to the ruins... nothing happened. Ori was very surprised, but Sein gave the explanation quickly: clever Gumon decided to make an additional de...
{"inputs": ["3 3\n1 3\n2 3\n3 3\n", "3 1\n1 1\n2 2\n3 3\n", "7 3\n1 7\n3 8\n4 5\n6 7\n1 3\n5 10\n8 9\n", "3 2\n1 1\n2 2\n3 3\n", "5 2\n1 3\n2 4\n3 5\n4 6\n5 7\n", "10 7\n1 10\n2 10\n3 10\n4 10\n5 10\n1 2\n1 3\n1 4\n1 5\n1 6\n", "2 2\n1 1\n1 1\n", "20 12\n18525 35038\n15816 31586\n18641 46864\n35863 38632\n13563 35915\n...
10
[ "PYTHON3" ]
2
2
code_contests
Okay, I need to solve this programming problem. Let's read the problem carefully. The problem is about selecting k lamps such that there exists a moment in time where all of them are turned on. The answer is the number of such subsets modulo 998244353. Hmm. So each lamp has a time interval [l_i, r_i], which is the pe...
To solve this problem, we need to determine the number of ways to select k lamps such that there exists a moment when all selected lamps are turned on simultaneously. The solution involves using combinatorial mathematics and a data structure to efficiently count valid subsets. ### Approach 1. **Sort Lamps by Start Tim...
false
Code is incorrect.
a65cb6d760c1f7fd325e2185f80d6ce3
1439_C. Greedy Shopping
You are given an array a_1, a_2, …, a_n of integers. This array is non-increasing. Let's consider a line with n shops. The shops are numbered with integers from 1 to n from left to right. The cost of a meal in the i-th shop is equal to a_i. You should process q queries of two types: * 1 x y: for each shop 1 ≤ i ≤ ...
{"inputs": ["10 6\n10 10 10 6 6 5 5 5 3 1\n2 3 50\n2 4 10\n1 3 10\n2 2 36\n1 4 7\n2 2 17\n", "1 1\n5\n2 1 6\n", "1 1\n5\n2 1 7\n", "10 6\n10 10 10 6 6 5 5 5 3 1\n2 3 50\n2 4 10\n1 3 10\n2 2 36\n1 4 7\n2 2 25\n", "10 6\n19 10 10 6 6 5 5 5 3 1\n2 3 50\n2 4 10\n1 3 10\n2 2 36\n1 4 7\n2 2 17\n", "10 6\n10 10 10 6 6 5 5 5 3...
9
[ "PYTHON3" ]
2
2
code_contests
Okay, let's see. I need to solve this programming problem. Let's read the problem carefully. So, we have an array that's non-increasing. Then there are two types of queries. For type 1, we update the first x elements to be at least y. For type 2, a person starts at position x with y money and buys meals from x to n as...
To solve this problem, we need to efficiently handle two types of queries on a non-increasing array of integers. The first type of query updates the array elements, and the second type calculates the number of meals a person can buy starting from a given position with a certain amount of money. ### Approach 1. **Data ...
false
Code is incorrect.
14324ead1cc6ea87ea82fa30fdba1e63
1466_C. Canine poetry
After his wife's tragic death, Eurydice, Orpheus descended to the realm of death to see her. Reaching its gates was uneasy, but passing through them proved to be even more challenging. Mostly because of Cerberus, the three-headed hound of Hades. Orpheus, a famous poet, and musician plans to calm Cerberus with his poe...
{"inputs": ["7\nbabba\nabaac\ncodeforces\nzeroorez\nabcdcba\nbbbbbbb\na\n", "7\nabbab\nabaac\ncodeforces\nzeroorez\nabcdcba\nbbbbbbb\na\n", "7\nabbab\nabaac\ncodeforces\nzeroorez\nabadcbc\nbbbbbbb\na\n", "7\nabbab\nabaac\ncodeforces\nzeroorez\nabadcbc\nbbbbabb\na\n", "7\nbbbaa\nabaac\ncodeforces\nyeroorez\nabadcbc\nbba...
9
[ "PYTHON3" ]
2
2
code_contests
Okay, so I need to find the minimal number of changes required to make a string have no palindromic substrings of length greater than 1. Let's think about this problem step by step. First, what's a palindrome substring? It's any substring of length 2 or more that reads the same forwards and backwards. So, the simplest...
To solve this problem, we need to determine the minimal number of changes required to transform a given poem such that it contains no palindromic substrings of length greater than 1. A palindromic substring reads the same forwards and backwards, and we need to ensure that no such substrings exist by modifying the poem ...
true
40e1c92382576ff188c7fc819067c5cd
1490_D. Permutation Transformation
A permutation — is a sequence of length n integers from 1 to n, in which all the numbers occur exactly once. For example, [1], [3, 5, 2, 1, 4], [1, 3, 2] — permutations, and [2, 3, 2], [4, 3, 1], [0] — no. Polycarp was recently gifted a permutation a[1 ... n] of length n. Polycarp likes trees more than permutations, s...
{"inputs": ["3\n5\n3 5 2 1 4\n1\n1\n4\n4 3 1 2\n", "3\n5\n3 5 1 2 4\n1\n1\n4\n4 3 1 2\n", "3\n5\n4 5 2 1 3\n1\n1\n4\n4 3 1 2\n", "3\n5\n3 4 2 1 5\n1\n1\n4\n4 3 1 2\n", "3\n5\n2 5 3 1 4\n1\n1\n4\n4 3 1 2\n", "3\n5\n4 5 1 2 3\n1\n1\n4\n4 3 1 2\n"], "outputs": ["\n1 0 2 3 1 \n0 \n0 1 3 2 \n", "1 0 3 2 1\n0\n0 1 3 2\n", "1...
10
[ "PYTHON3" ]
2
2
code_contests
Okay, so I need to solve this programming problem where I have to build a binary tree based on a permutation and then compute the depth of each node. Let's think through this step by step. First, let's understand the problem. The permutation is turned into a binary tree recursively. The root is the maximum element of ...
To solve this problem, we need to transform a given permutation into a rooted binary tree and determine the depth of each element in the tree. The tree is constructed by recursively selecting the maximum element in each subarray as the root, then building the left and right subtrees from the elements to the left and ri...
false
Code is incorrect.
e463a7f475a50946c4c2f15b44ed1cd3
1512_G. Short Task
Let us denote by d(n) the sum of all divisors of the number n, i.e. d(n) = ∑_{k | n} k. For example, d(1) = 1, d(4) = 1+2+4=7, d(6) = 1+2+3+6=12. For a given number c, find the minimum n such that d(n) = c. Input The first line contains one integer t (1 ≤ t ≤ 10^4). Then t test cases follow. Each test case is char...
{"inputs": ["12\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n39\n691\n", "12\n1\n2\n3\n6\n5\n6\n7\n8\n9\n10\n39\n691\n", "12\n1\n2\n3\n6\n5\n6\n7\n8\n9\n6\n39\n691\n", "12\n1\n2\n3\n6\n5\n6\n6\n8\n9\n6\n39\n691\n", "12\n1\n2\n3\n4\n5\n6\n6\n8\n9\n6\n39\n691\n", "12\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n33\n691\n", "12\n1\n2\n3\n12\n5\n6\...
13
[ "PYTHON3" ]
2
2
code_contests
Okay, let's tackle this problem. The task is to find the minimum number n such that the sum of its divisors d(n) equals a given c. If there's no such n, return -1. Hmm. First, I need to understand how d(n) works. For example, d(1) is 1, since the only divisor is 1. For 4, the divisors are 1, 2, 4, sum to 7. And for 6,...
To solve this problem, we need to find the minimum number \( n \) such that the sum of its divisors \( d(n) \) equals a given value \( c \). If no such \( n \) exists, we return -1. The solution involves understanding the properties of the sum of divisors function and efficiently factorizing the given value \( c \) int...
true
b44fd892bfb9d6343c85ee3f465fbc21
167_C. Wizards and Numbers
In some country live wizards. They love playing with numbers. The blackboard has two numbers written on it — a and b. The order of the numbers is not important. Let's consider a ≤ b for the sake of definiteness. The players can cast one of the two spells in turns: * Replace b with b - ak. Number k can be chosen by...
{"inputs": ["4\n10 21\n31 10\n0 1\n10 30\n", "7\n576460752303423487 2\n82 9\n101 104\n10 21\n31 10\n0 1\n10 30\n", "1\n128817972817282999 327672410994637530\n", "66\n7 0\n5 7\n1 3\n3 2\n3 5\n0 6\n1 2\n0 7\n4 5\n4 7\n5 1\n2 0\n4 0\n0 5\n3 6\n7 3\n6 0\n5 2\n6 6\n1 7\n5 6\n2 2\n3 4\n2 1\n5 3\n4 6\n6 2\n3 3\n100000000000 1...
9
[ "PYTHON3" ]
2
2
code_contests
Okay, let's try to figure out how to solve this problem. So, the problem is about two wizards playing a game with two numbers a and b. They take turns doing operations, and the player who can't make a move loses. We need to determine who wins if both play optimally. Hmm, let's start by understanding the possible moves...
To solve this problem, we need to determine which player will win a game played by two wizards with two numbers on a blackboard. The players take turns applying two possible operations: subtracting a multiple of the smaller number from the larger or taking the modulus of the larger number with the smaller. The player w...
false
Code is incorrect.
741321be3b53b15cb302e7b8bd08716d
209_B. Pixels
Flatland is inhabited by pixels of three colors: red, green and blue. We know that if two pixels of different colors meet in a violent fight, only one of them survives the fight (that is, the total number of pixels decreases by one). Besides, if pixels of colors x and y (x ≠ y) meet in a violent fight, then the pixel t...
{"inputs": ["1 1 1\n", "3 1 0\n", "9 530792195 6\n", "0 0 10\n", "1944219055 454183506 1369298327\n", "914835 2742837 9234739\n", "10 10 0\n", "2 2 0\n", "0 0 1\n", "3 10 1007169359\n", "0 1 0\n", "1016450951 2 9\n", "0 2 10\n", "2147483648 0 2147483647\n", "92134834 23742837 92374738\n", "1 4 3\n", "382601556 88132964...
8
[ "PYTHON3" ]
2
2
code_contests
Okay, I need to solve this problem where we have pixels of three colors: red, green, and blue. The goal is to find the minimum number of fights required to get all pixels to be the same color, or determine if it's impossible. Let's think through this step by step. First, let's understand the problem. When two differen...
To solve this problem, we need to determine the minimum number of fights required to make all pixels in Flatland the same color. If it's impossible, we should return -1. The solution involves checking each possible target color and determining if it's feasible based on certain conditions. ### Approach 1. **Check Feasi...
false
Code is incorrect.
7344efd8437e5c022937b07f065f8578
235_A. LCM Challenge
Some days ago, I learned the concept of LCM (least common multiple). I've played with it for several times and I want to make a big number with it. But I also don't want to use many numbers, so I'll choose three positive integers (they don't have to be distinct) which are not greater than n. Can you help me to find th...
{"inputs": ["7\n", "9\n", "447244\n", "958507\n", "816923\n", "836603\n", "862795\n", "756604\n", "1000000\n", "4\n", "668827\n", "245\n", "520731\n", "642635\n", "8\n", "244\n", "148\n", "213\n", "984699\n", "20\n", "810411\n", "796\n", "924\n", "341\n", "41\n", "33\n", "604\n", "117\n", "978187\n", "5\n", "546924\n",...
7
[ "PYTHON3" ]
2
2
code_contests
Okay, I need to solve this problem where I have to find the maximum LCM of three numbers not exceeding n. Hmm. Let's think about how the LCM works. The LCM of three numbers is the smallest number that is a multiple of all three. To maximize the LCM, I probably want the three numbers to be as large as possible. But some...
To solve this problem, we need to find the maximum possible least common multiple (LCM) of three positive integers that are not greater than a given integer \( n \). The solution involves considering different cases based on whether \( n \) is odd, even, or divisible by 3. ### Approach 1. **Trivial Cases**: - If \(...
true
befe8f917122c702725e835bad6dd55e
25_D. Roads not only in Berland
Berland Government decided to improve relations with neighboring countries. First of all, it was decided to build new roads so that from each city of Berland and neighboring countries it became possible to reach all the others. There are n cities in Berland and neighboring countries in total and exactly n - 1 two-way r...
{"inputs": ["7\n1 2\n2 3\n3 1\n4 5\n5 6\n6 7\n", "2\n1 2\n", "4\n1 4\n3 1\n3 4\n", "5\n4 1\n4 3\n5 3\n2 4\n", "21\n7 15\n13 1\n14 3\n4 10\n2 3\n16 18\n17 20\n16 20\n8 4\n3 12\n2 17\n13 11\n16 1\n13 2\n13 5\n8 9\n6 14\n3 17\n16 9\n13 8\n", "3\n3 1\n3 2\n", "6\n5 2\n5 3\n1 4\n3 1\n5 6\n", "60\n17 34\n46 22\n50 44\n46 33\...
10
[ "PYTHON3" ]
2
2
code_contests
Okay, let's see. The problem is about restructuring the roads so that the resulting graph is connected, with exactly n-1 roads (so it's a tree again), but the way to do this is by each day closing one road and opening another. The goal is to find the minimal number of days needed and the steps to do so. Hmm. The initi...
To solve this problem, we need to restructure the given graph such that it becomes a tree (connected with exactly n-1 edges) by closing existing roads and building new ones. The goal is to determine the minimal number of days required and the specific steps to achieve this. ### Approach 1. **Identify Connected Compone...
false
Code is incorrect.
d8743725a4de8a5fcc01332bc97b4635
283_D. Cows and Cool Sequences
Bessie and the cows have recently been playing with "cool" sequences and are trying to construct some. Unfortunately they are bad at arithmetic, so they need your help! A pair (x, y) of positive integers is "cool" if x can be expressed as the sum of y consecutive integers (not necessarily positive). A sequence (a1, a2...
{"inputs": ["3\n6 4 1\n", "4\n20 6 3 4\n", "5\n1 8 1 7 9\n", "4\n6 7 4 5\n", "5\n36 37 6 18 36\n", "3\n5 1 3\n", "200\n2 1 1 1 2 1 2 1 1 1 2 1 2 2 2 1 1 2 1 2 1 1 1 2 2 1 2 1 1 2 1 1 1 2 1 1 2 2 2 2 2 2 2 2 2 2 1 2 2 1 2 1 2 2 1 1 2 2 2 2 2 2 2 1 1 1 2 1 2 2 1 1 2 1 2 2 2 1 2 1 1 1 2 1 1 2 2 1 2 2 1 2 2 1 1 2 1 1 1 1 1...
10
[ "PYTHON3" ]
2
2
code_contests
Okay, so I need to solve this problem where I have to find the minimum number of changes required to make a sequence "cool". Let's try to understand the problem first. A cool sequence is one where every consecutive pair (a_i, a_{i+1}) is a cool pair. And a cool pair (x, y) is when x can be written as the sum of y cons...
To solve this problem, we need to determine the minimum number of changes required to transform a sequence of positive integers into a "cool" sequence. A sequence is considered cool if every consecutive pair (a_i, a_{i+1}) is a cool pair. A pair (x, y) is cool if x can be expressed as the sum of y consecutive integers....
false
Code is incorrect.
568d13ce7bf29e28ee0cddad0bb5272d
306_C. White, Black and White Again
Polycarpus is sure that his life fits the description: "first there is a white stripe, then a black one, then a white one again". So, Polycarpus is sure that this rule is going to fulfill during the next n days. Polycarpus knows that he is in for w good events and b not-so-good events. At least one event is going to ta...
{"inputs": ["3 2 1\n", "3 2 2\n", "4 2 2\n", "3 3 1\n", "300 2 300\n", "4000 4000 1\n", "4000 4000 100\n", "4 2 3\n", "3 300 300\n", "4000 100 4000\n", "3 300 1\n", "300 300 1\n", "4000 1000 3000\n", "3 2 4000\n", "4 3 2\n", "3 2 300\n", "4000 3998 2\n", "100 200 300\n", "300 300 300\n", "3 3 3\n", "10 10 10\n", "10 4 ...
9
[ "PYTHON3" ]
2
2
code_contests
Okay, let's try to figure out this problem. So the task is to calculate the number of distinct ways the events can be arranged over n days, following the specific pattern of stripes. The stripes must be white (good events), then black (not-so-good), then white again. Each stripe must have at least one day. Each day in ...
To solve this problem, we need to determine the number of distinct ways to distribute good and not-so-good events over a series of days, following a specific pattern of stripes: white (good events), black (not-so-good events), and white again. Each stripe must consist of consecutive days with at least one day each, and...
true
a4dd824c5ae8687794b5f2f980f390c7
331_D2. Escaping on Beaveractor
Don't put up with what you're sick of! The Smart Beaver decided to escape from the campus of Beaver Science Academy (BSA). BSA is a b × b square on a plane. Each point x, y (0 ≤ x, y ≤ b) belongs to BSA. To make the path quick and funny, the Beaver constructed a Beaveractor, an effective and comfortable types of transp...
{"inputs": ["3 3\n0 0 0 1\n0 2 2 2\n3 3 2 3\n12\n0 0 L 0\n0 0 L 1\n0 0 L 2\n0 0 L 3\n0 0 L 4\n0 0 L 5\n0 0 L 6\n2 0 U 2\n2 0 U 3\n3 0 U 5\n1 3 D 2\n1 3 R 2\n", "3 8\n2 4 4 4\n7 2 5 2\n6 5 6 3\n20\n3 2 U 1000000\n3 2 U 1\n3 2 U 2\n3 2 U 3\n3 2 U 4\n3 2 U 5\n3 2 U 6\n3 2 U 7\n3 2 U 8\n3 2 U 9\n3 2 U 10\n3 2 U 11\n3 2 U 1...
10
[ "PYTHON3" ]
2
2
code_contests
Okay, so I need to solve this programming problem. Let's read the problem statement carefully. The problem is about a Beaveractor moving on a grid, changing directions based on arrows. The goal is to compute the final position after a certain time for each query. The main challenge is efficiently handling up to 1e5 qu...
To solve this problem, we need to determine the final position of the Smart Beaver's Beaveractor after a given time, considering direction changes due to traffic arrows on a campus grid. The solution involves simulating the movement of the Beaveractor efficiently by leveraging pre-processed data structures for quick lo...
false
Code is incorrect.
38d2244e23e77d95e23c230c4c2eafa3
354_B. Game with Strings
Given an n × n table T consisting of lowercase English letters. We'll consider some string s good if the table contains a correct path corresponding to the given string. In other words, good strings are all strings we can obtain by moving from the left upper cell of the table only to the right and down. Here's the form...
{"inputs": ["2\nxa\nay\n", "2\nab\ncd\n", "3\naab\nbcb\nbac\n", "5\ncbbbb\nbcbbb\naacbb\naaacb\naaaac\n", "20\nbifcabiabgfibfccdbgd\ncffaheagahcbacafbgeb\njagcacbadagcedbigaja\naaadicdbjdiibhihbgeb\nhiijbehdeaafdabiigha\nfiifibibgddjfbdafbif\nhdbgbcfjdgibadabfgaf\ngggdaijhfgbaidfajdaj\nfajhebaaaigdjaajcaij\nbhcbajicidb...
8
[ "PYTHON3" ]
2
2
code_contests
Okay, let's see. I need to solve this programming problem where two players take turns building a string by moving right or down in an n x n grid. The winner is determined by the count of 'a's and 'b's in the final string. Both play optimally. The task is to determine if the first player wins, the second, or it's a dra...
To solve this problem, we need to determine the outcome of a game played on an n×n grid where two players take turns moving right or down from the top-left corner to the bottom-right corner. The goal is to determine if the first player wins, the second player wins, or the game ends in a draw based on the counts of 'a' ...
false
Code is incorrect.
ffa02ab5466bf4e0cc1cd3fc464f7ff9
378_C. Maze
Pavel loves grid mazes. A grid maze is an n × m rectangle maze where each cell is either empty, or is a wall. You can go from one cell to another only if both cells are empty and have a common side. Pavel drew a grid maze with all empty cells forming a connected area. That is, you can go from any empty cell to any oth...
{"inputs": ["3 4 2\n#..#\n..#.\n#...\n", "5 4 5\n#...\n#.#.\n.#..\n...#\n.#.#\n", "19 20 196\n###.....##.#..#..##.\n####............##..\n###....#..#.#....#.#\n##....###......#...#\n.####...#.....#.##..\n.###......#...#.#.#.\n...##.#...#..#..#...\n.....#.....#..#....#\n.#.....##..#........\n.##....#......#....#\n....#....
9
[ "PYTHON3" ]
2
2
code_contests
Okay, so I need to solve this programming problem. Let's see what the problem is asking. The task is to take a grid maze where all empty cells are connected, and turn exactly k empty cells into walls (marked as 'X') such that the remaining empty cells are still connected. And we have to output the modified grid. The ...
To solve this problem, we need to convert exactly `k` empty cells ('.') into walls ('X') in a grid maze such that the remaining empty cells form a connected region. The solution involves using a spanning tree to identify cells that can be safely removed without disconnecting the remaining cells. ### Approach 1. **Iden...
false
Code is incorrect.
f5435a355e8d238a55308d04a945ff31
39_E. What Has Dirichlet Got to Do with That?
You all know the Dirichlet principle, the point of which is that if n boxes have no less than n + 1 items, that leads to the existence of a box in which there are at least two items. Having heard of that principle, but having not mastered the technique of logical thinking, 8 year olds Stas and Masha invented a game. T...
{"inputs": ["3 1 4\n", "2 2 10\n", "5 5 16808\n", "1 4 10\n", "2 2 5\n", "9 9 1000000000\n", "3 17 999999997\n", "3 3 64\n", "5 1 64\n", "29 2 1000000000\n", "1010 1 1000000000\n", "3 2 27\n", "1 1 60\n", "2 4 64\n", "2 2 64\n", "3 4 1000\n", "2 3 64\n", "2 1 536870912\n", "2 2 17\n", "117 1 13689\n", "2 5 64\n", "3 2 ...
11
[ "PYTHON3" ]
2
2
code_contests
Okay, let's try to understand this problem. So, we have Stas and Masha playing a game where they take turns adding either a box or an item. The game starts with a boxes and b items. Each time a player makes a move, they choose to add either a box (so a increases by 1) or an item (b increases by 1). The losing condition...
To solve this problem, we need to determine the outcome of a game played by Stas and Masha where they take turns adding either a box or an item. The player who causes the number of ways to distribute items into boxes (a^b) to reach or exceed a given number n loses. The solution involves analyzing the game states using ...
false
Code is incorrect.
9fb0a6ee181ab71176f17714508fdaab
425_A. Sereja and Swaps
As usual, Sereja has array a, its elements are integers: a[1], a[2], ..., a[n]. Let's introduce notation: <image> A swap operation is the following sequence of actions: * choose two indexes i, j (i ≠ j); * perform assignments tmp = a[i], a[i] = a[j], a[j] = tmp. What maximum value of function m(a) can Serej...
{"inputs": ["5 10\n-1 -1 -1 -1 -1\n", "10 2\n10 -1 2 2 2 2 2 2 -1 10\n", "1 10\n1\n", "10 1\n-1 1 1 1 1 1 1 1 1 1\n", "78 8\n-230 -757 673 -284 381 -324 -96 975 249 971 -355 186 -526 804 147 -553 655 263 -247 775 108 -246 -107 25 -786 -372 -24 -619 265 -192 269 392 210 449 335 -207 371 562 307 141 668 78 13 251 623 -23...
7
[ "PYTHON3" ]
2
2
code_contests
Okay, let's try to figure out this problem. So the task is to find the maximum value of this function m(a) after performing at most k swaps. Hmm. Let's start by understanding what the function m(a) actually calculates. From the notation given, m(a) is the sum of the absolute differences between consecutive elements. O...
To solve this problem, we need to maximize the sum of absolute differences between consecutive elements of an array after performing at most `k` swap operations. The approach involves a greedy strategy where each swap is chosen to maximize the immediate gain in the sum of absolute differences. ### Approach 1. **Initia...
false
Code is incorrect.
d9fa7a7f69196d44731cd8540c1520f0
449_D. Jzzhu and Numbers
Jzzhu have n non-negative integers a1, a2, ..., an. We will call a sequence of indexes i1, i2, ..., ik (1 ≤ i1 < i2 < ... < ik ≤ n) a group of size k. Jzzhu wonders, how many groups exists such that ai1 & ai2 & ... & aik = 0 (1 ≤ k ≤ n)? Help him and print this number modulo 1000000007 (109 + 7). Operation x & y deno...
{"inputs": ["3\n2 3 3\n", "4\n0 1 2 3\n", "6\n5 2 0 5 2 1\n", "2\n1 31\n", "2\n1 0\n", "10\n450661 128600 993228 725823 293549 33490 843121 903634 556169 448234\n", "1\n1\n", "5\n1 3 5 7 9\n", "6\n524 529 5249 524 529 529\n", "3\n1 2 3\n", "2\n0 1\n", "55\n0 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 2 3 4 5 6 7 8 9 3 4 5 6 7...
10
[ "PYTHON3" ]
2
2
code_contests
Okay, I need to solve this problem where I have to find the number of non-empty subsets of the given array such that the bitwise AND of all elements in the subset is zero. And then return this count modulo 1e9+7. Hmm, let's think about how to approach this. First, the brute force approach would be to check all possibl...
To solve this problem, we need to determine the number of non-empty subsets of an array such that the bitwise AND of all elements in the subset is zero. The result should be computed modulo \(10^9 + 7\). ### Approach 1. **Problem Analysis**: The key challenge is efficiently counting subsets where the bitwise AND is ze...
true
541d7aa3e26f6387a962ba199e5477ce
494_A. Treasure
Malek has recently found a treasure map. While he was looking for a treasure he found a locked door. There was a string s written on the door consisting of characters '(', ')' and '#'. Below there was a manual on how to open the door. After spending a long time Malek managed to decode the manual and found out that the ...
{"inputs": ["(((#)((#)\n", "#\n", "()((#((#(#()\n", "(#)\n", "#(#(#((##((()))(((#)(#()#(((()()(()#(##(((()(((()))#(((((()(((((((()#((#((()(#(((()(()##(()(((()((#(\n", "(#((((()\n", "(#((\n", "((#)((#)((#)((#)((#)((#)((#)((#)((#)((#)((#)((#)((#)((#)((#)((##\n", "(())((((#)\n", "(#(\n", "(#))(#(#)((((#(##((#(#((((#(##(((...
7
[ "PYTHON3" ]
2
2
code_contests
Okay, I need to solve this programming problem. Let's read the problem carefully. The problem says that we have a string composed of '(', ')', and '#' characters. We need to replace each '#' with one or more ')', such that the resulting string is "beautiful". A beautiful string must satisfy two conditions: first, for ...
To solve this problem, we need to replace each '#' in the given string with one or more ')' characters such that the resulting string is "beautiful". A beautiful string must satisfy two conditions: every prefix has no more closing brackets than opening brackets, and the total number of opening and closing brackets must...
true
5ee505249300600b681eb635a1ae263f
518_E. Arthur and Questions
After bracket sequences Arthur took up number theory. He has got a new favorite sequence of length n (a1, a2, ..., an), consisting of integers and integer k, not exceeding n. This sequence had the following property: if you write out the sums of all its segments consisting of k consecutive elements (a1 + a2 ... + ak, ...
{"inputs": ["3 2\n? 1 2\n", "5 1\n-10 -9 ? -7 -6\n", "5 3\n4 6 7 2 9\n", "7 2\n-10 0 ? 1 ? 2 10\n", "1 1\n0\n", "5 1\n-3 -2 -1 0 1\n", "7 1\n-4 ? ? ? ? ? 2\n", "17 1\n? -13 ? ? ? -3 ? ? ? ? ? 10 ? ? ? ? 100\n", "3 1\n-5 ? 0\n", "7 2\n-10 0 ? 1 6 2 ?\n", "3 1\n-3 ? -2\n", "6 1\n-1 ? 1 2 3 4\n", "1 1\n?\n", "9 2\n-10 0 ?...
11
[ "PYTHON3" ]
2
2
code_contests
Okay, let's see. So the problem is to restore a sequence of numbers where some are replaced by question marks. The restored sequence needs to have the property that all consecutive k-length segments' sums are strictly increasing. Also, we need to minimize the sum of absolute values of the elements. Hmm. First, I need ...
To solve this problem, we need to restore a sequence of integers where some elements are replaced by question marks. The restored sequence must ensure that the sums of all consecutive k-length segments form a strictly increasing sequence. Additionally, we need to minimize the sum of the absolute values of the elements....
false
Code is incorrect.
09469d7277905e4dc09b6e53f305d413
544_E. Remembering Strings
You have multiset of n strings of the same length, consisting of lowercase English letters. We will say that those strings are easy to remember if for each string there is some position i and some letter c of the English alphabet, such that this string is the only string in the multiset that has letter c in position i....
{"inputs": ["4 3\nabc\naba\nadc\nada\n10 10 10\n10 1 10\n10 10 10\n10 1 10\n", "4 5\nabcde\nabcde\nabcde\nabcde\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n", "3 3\nabc\nada\nssa\n1 1 1\n1 1 1\n1 1 1\n", "1 1\na\n10\n", "1 20\naaaaaaaaaaaaaaaaaaaa\n924705 786913 546594 427698 741583 189683 354089 380570 10694 41046 65...
11
[ "PYTHON3" ]
2
2
code_contests
Okay, let's see. I need to find the minimum cost to make a multiset of strings easy to remember. The problem says that for each string in the multiset, there must be at least one position where that string has a unique character in that position compared to all others. So each string must have at least one "unique iden...
To solve this problem, we need to ensure that each string in the multiset has at least one unique position where it is the only string with a specific character in that position. The goal is to achieve this with the minimum cost, where each character change in a specific position of a string incurs a given cost. ### A...
false
Code is incorrect.
50e86f21e6f197aa15c07677aa4e0304
571_B. Minimization
You've got array A, consisting of n integers and a positive integer k. Array A is indexed by integers from 1 to n. You need to permute the array elements so that value <image> became minimal possible. In particular, it is allowed not to change order of elements at all. Input The first line contains two integers n,...
{"inputs": ["5 2\n3 -5 3 -5 3\n", "3 2\n1 2 4\n", "6 3\n4 3 4 3 2 5\n", "30 2\n-999999924 -499999902 500000091 -999999998 500000030 -999999934 500000086 -499999918 -499999998 67 -999999964 -499999975 -499999947 -499999925 3 -499999985 14 500000015 500000022 88 25 -499999909 500000051 -499999984 -999999964 -499999905 -4...
8
[ "PYTHON3" ]
2
2
code_contests
Okay, let's try to understand this problem. So, the task is to permute the elements of an array such that the sum of the absolute differences between every pair of elements that are k positions apart is minimized. The goal is to find the minimal possible value of this sum after permuting the array. Wait, the formula i...
To solve this problem, we need to permute the elements of an array such that the sum of the absolute differences between every pair of elements that are k positions apart is minimized. The key insight is that we can break the problem into smaller subproblems by considering the array in terms of groups of elements that ...
false
Code is incorrect.
aec26de877c16669efe2d20b66ca368a
592_E. BCPC
BCPC stands for Byteforces Collegiate Programming Contest, and is the most famous competition in Byteforces. BCPC is a team competition. Each team is composed by a coach and three contestants. Blenda is the coach of the Bit State University(BSU), and she is very strict selecting the members of her team. <image> In B...
{"inputs": ["7 6 6\n3 2\n1 7\n5 7\n3 7\n6 4\n8 9\n8 5\n", "5 2 2\n1 1\n4 1\n2 3\n3 2\n3 4\n", "8 61 898\n315 863\n524 559\n612 425\n577 542\n220 280\n560 880\n297 626\n381 24\n", "32 79793 36411\n37942 45805\n11123 1864\n8196 82922\n31139 76552\n77991 28555\n96327 37047\n79356 82575\n10442 62647\n90848 41723\n16799 363...
11
[ "PYTHON3" ]
2
2
code_contests
Okay, I need to solve this programming problem. Let's read the problem carefully. The problem is about counting the number of good teams of three students. A team is good if each student overwhelms the next in a cyclic manner. The definition of overwhelming is based on the adjusted reading and writing speeds after sub...
To solve this problem, we need to count the number of valid teams of three students such that each student in the team overwhelms the next in a cyclic manner. The key insight is to use geometric properties and efficient computation to determine valid teams based on their angular positions relative to the origin. ### A...
false
Code is incorrect.
baa55abb91a57ba032b6100f34cea7d2
614_C. Peter and Snow Blower
Peter got a new snow blower as a New Year present. Of course, Peter decided to try it immediately. After reading the instructions he realized that it does not work like regular snow blowing machines. In order to make it work, you need to tie it to some point that it does not cover, and then switch it on. As a result it...
{"inputs": ["3 0 0\n0 1\n-1 2\n1 2\n", "4 1 -1\n0 0\n1 2\n2 0\n1 1\n", "4 0 0\n1 -1\n1 3\n3 3\n3 -1\n", "3 0 0\n-10 1\n0 2\n1 1\n", "3 0 0\n-1 1\n0 3\n1 1\n", "20 -999719 -377746\n-999718 -377746\n-997432 -940486\n-982215 -950088\n-903861 -997725\n-127953 -999833\n846620 -999745\n920305 -992903\n947027 -986746\n991646 ...
9
[ "PYTHON3" ]
2
2
code_contests
Okay, let's see. So the problem is about a polygon that's rotating around a point P. When the polygon moves along a circular path around P, the area swept by the polygon is what we need to calculate. Hmm. Wait, the polygon is moving in a circle around P. So each point of the polygon (and the entire polygon itself) wi...
To solve this problem, we need to determine the area cleared by a snow blower that moves in a circular path around a given point P. The snow blower is represented as a polygon, and the cleared area is the region covered by the polygon's movement around P. ### Approach 1. **Problem Analysis**: The polygon's movement ar...
false
Code is incorrect.
c6e6e554d074743aac0015be8fa7f25e
633_H. Fibonacci-ish II
Yash is finally tired of computing the length of the longest Fibonacci-ish sequence. He now plays around with more complex things such as Fibonacci-ish potentials. Fibonacci-ish potential of an array ai is computed as follows: 1. Remove all elements j if there exists i < j such that ai = aj. 2. Sort the remain...
{"inputs": ["5 10\n2 1 2 1 2\n2\n2 4\n4 5\n", "5 10\n2 1 2 2 2\n2\n2 4\n4 5\n", "5 10\n2 1 2 2 1\n2\n2 4\n4 5\n", "5 10\n3 1 4 2 1\n2\n2 4\n4 5\n", "5 10\n3 2 4 2 1\n2\n2 4\n4 5\n", "5 10\n3 2 4 2 1\n2\n2 1\n4 5\n", "5 10\n2 1 4 1 2\n2\n2 4\n4 5\n", "5 10\n3 1 2 2 1\n2\n1 4\n4 5\n", "5 10\n3 1 4 2 1\n2\n4 4\n4 5\n", "5...
14
[ "PYTHON3" ]
2
2
code_contests
Okay, I need to solve this programming problem. Let's read the problem statement carefully. So the problem is about computing the Fibonacci-ish potential of a subarray. Let's break down the steps required. First, the steps to compute the potential are: 1. Remove duplicates such that for each element in the subarray,...
To solve this problem, we need to compute the Fibonacci-ish potential of subarrays of an array based on specific criteria. The Fibonacci-ish potential is determined by first removing duplicates (keeping the first occurrence), sorting the remaining elements, and then summing them multiplied by corresponding Fibonacci nu...
true
51c69f630a8caeab3f1567e86c7e3ead
662_C. Binary Table
You are given a table consisting of n rows and m columns. Each cell of the table contains either 0 or 1. In one move, you are allowed to pick any row or any column and invert all values, that is, replace 0 by 1 and vice versa. What is the minimum number of cells with value 1 you can get after applying some number of o...
{"inputs": ["3 4\n0110\n1010\n0111\n", "20 20\n00010110100100010111\n11110000001100101110\n01110101110001111000\n10111101000111111110\n10000101011000000011\n00010010001011010000\n00000110010110111111\n01010101000101101110\n01001110110001000011\n10111111010011101111\n10011010000110101101\n10000111011001001111\n111111101...
9
[ "PYTHON3" ]
2
2
code_contests
Okay, let's tackle this problem. So the task is to find the minimum number of 1's possible after flipping any rows or columns any number of times. Hmm. Let's see. First, I need to understand the problem. Each cell is either 0 or 1. We can flip all elements in a row (turn 0s into 1s and vice versa) or flip a column. Th...
To solve this problem, we need to minimize the number of cells with the value 1 after applying a series of row and column flips. Each flip inverts all values in a row or column. The optimal strategy involves determining the best set of row flips followed by column flips to achieve the minimum number of 1s. ### Approac...
true
68d8cda40a5fabadff240afd4b0a77c2
687_A. NP-Hard Problem
Recently, Pari and Arya did some research about NP-Hard problems and they found the minimum vertex cover problem very interesting. Suppose the graph G is given. Subset A of its vertices is called a vertex cover of this graph, if for each edge uv there is at least one endpoint of it in this set, i.e. <image> or <image>...
{"inputs": ["4 2\n1 2\n2 3\n", "3 3\n1 2\n2 3\n1 3\n", "10 16\n6 10\n5 2\n6 4\n6 8\n5 3\n5 4\n6 2\n5 9\n5 7\n5 1\n6 9\n5 8\n5 10\n6 1\n6 7\n6 3\n", "10 9\n2 5\n2 4\n2 7\n2 9\n2 3\n2 8\n2 6\n2 10\n2 1\n", "20 22\n3 18\n9 19\n6 15\n7 1\n16 8\n18 7\n12 3\n18 4\n9 15\n20 1\n4 2\n6 7\n14 2\n7 15\n7 10\n8 1\n13 6\n9 7\n11 8\...
7
[ "PYTHON3" ]
2
2
code_contests
Okay, let's try to figure out how to solve this problem. The problem is asking us to find two disjoint vertex covers A and B in a given undirected graph. Both A and B must be vertex covers, and they can't share any vertices. If it's impossible, we return -1. Hmm. Let's start by recalling what a vertex cover is. A vert...
To solve this problem, we need to determine if we can split the vertices of a given graph into two disjoint subsets such that each subset is a vertex cover. If this is possible, we should output the two subsets; otherwise, we should output -1. ### Approach 1. **Understanding Vertex Covers**: A vertex cover is a set of...
false
Code is incorrect.
0057fd225ac3a32d46d1af515ff591df
709_E. Centroids
Tree is a connected acyclic graph. Suppose you are given a tree consisting of n vertices. The vertex of this tree is called centroid if the size of each connected component that appears if this vertex is removed from the tree doesn't exceed <image>. You are given a tree of size n and can perform no more than one edge ...
{"inputs": ["3\n1 2\n2 3\n", "5\n1 2\n1 3\n1 4\n1 5\n", "8\n1 2\n1 3\n1 4\n1 5\n2 6\n2 7\n2 8\n", "9\n9 2\n9 3\n9 4\n9 5\n2 6\n5 7\n7 8\n7 1\n", "9\n8 2\n8 3\n8 4\n8 5\n2 6\n5 7\n7 1\n7 9\n", "4\n3 1\n3 2\n3 4\n", "9\n5 2\n5 3\n5 4\n5 1\n2 6\n1 7\n7 8\n7 9\n", "10\n10 1\n1 4\n4 2\n2 3\n3 6\n6 9\n9 5\n5 8\n8 7\n", "50\n...
11
[ "PYTHON3" ]
2
2
code_contests
Okay, let's tackle this problem. So, the task is to determine for each vertex in a tree whether we can make it a centroid by performing at most one edge replacement. Hmm, centroids in trees are interesting. Let me recall: a centroid is a vertex such that when you remove it, all the resulting connected components (which...
To solve this problem, we need to determine if each vertex in a tree can become a centroid by performing at most one edge replacement. A centroid is a vertex such that when removed, all resulting connected components have sizes not exceeding half the total number of vertices. ### Approach 1. **Tree Structure and Subtr...
false
Code is incorrect.
a6405ed3344336240e1fda69d6baa646
730_G. Car Repair Shop
Polycarp starts his own business. Tomorrow will be the first working day of his car repair shop. For now the car repair shop is very small and only one car can be repaired at a given time. Polycarp is good at marketing, so he has already collected n requests from clients. The requests are numbered from 1 to n in order...
{"inputs": ["4\n1000000000 1000000\n1000000000 1000000\n100000000 1000000\n1000000000 1000000\n", "3\n9 2\n7 3\n2 4\n", "1\n1 5000000\n", "1\n1000000000 1\n", "10\n588 12\n560 10\n593 14\n438 15\n761 11\n984 6\n503 2\n855 19\n538 2\n650 7\n", "20\n360 26\n475 17\n826 12\n815 23\n567 28\n897 26\n707 20\n1000 9\n576 5\n1...
13
[ "PYTHON3" ]
2
2
code_contests
Okay, let's try to solve this problem. Hmm, the problem is about scheduling car repairs for clients based on their preferred start time and duration. The key is to process each request in order and assign the earliest possible time for each car. Let me think about how to approach this. So, the steps are: for each clie...
To solve this problem, we need to schedule car repair requests in such a way that each request is processed as early as possible, either starting at the client's preferred day or the earliest possible day if the preferred days are unavailable. The solution involves checking each request in sequence and determining the ...
true
b7406b5a520eca44d655d33968e78805
754_B. Ilya and tic-tac-toe game
Ilya is an experienced player in tic-tac-toe on the 4 × 4 field. He always starts and plays with Xs. He played a lot of games today with his friend Arseny. The friends became tired and didn't finish the last game. It was Ilya's turn in the game when they left it. Determine whether Ilya could have won the game by making...
{"inputs": ["o.x.\no...\n.x..\nooxx\n", "x.ox\nox..\nx.o.\noo.x\n", "xx..\n.oo.\nx...\noox.\n", "x..x\n..oo\no...\nx.xo\n", "xoox\n.xx.\no..o\n..xo\n", "o.xx\nxo.o\n...o\n..x.\n", "xxoo\no.oo\n...x\nx..x\n", "o..x\n....\n...x\n..o.\n", "....\n.o..\n....\nox.x\n", "xxo.\n.oo.\n..x.\n..xo\n", "....\n..ox\n....\n.o.x\n", ...
8
[ "PYTHON3" ]
2
2
code_contests
Okay, I need to solve this problem where I have to determine if Ilya can win by placing one 'x' on a 4x4 tic-tac-toe board. Let's see the problem statement again. The rules are that the winner is the first to get three in a row, column, or diagonal. And since it's Ilya's turn, he's placing an 'x'. So I need to check ...
To solve this problem, we need to determine if Ilya can win a 4x4 tic-tac-toe game by placing a single 'X' (denoted as 'x') on an empty cell (denoted as '.'). The game is considered won if three consecutive 'X's are formed either horizontally, vertically, or diagonally. ### Approach 1. **Input Reading**: Read the curr...
true
b8bbc828efd8272fc410325d1e91da66
774_K. Stepan and Vowels
Stepan likes to repeat vowel letters when he writes words. For example, instead of the word "pobeda" he can write "pobeeeedaaaaa". Sergey does not like such behavior, so he wants to write a program to format the words written by Stepan. This program must combine all consecutive equal vowels to a single vowel. The vowe...
{"inputs": ["18\naeiouyaaeeiioouuyy\n", "22\niiiimpleeemeentatiioon\n", "13\npobeeeedaaaaa\n", "24\naaaoooiiiuuuyyyeeeggghhh\n", "3\neoo\n", "36\naeiouyaaeeiioouuyyaaaeeeiiiooouuuyyy\n", "3\nooo\n", "1\na\n", "4\neeoo\n", "5\noooee\n", "5\nooeoo\n", "1\nf\n", "200\nmmffggzvuuzzlkafduueqocuybiiaaeeoiioouaaurccuqoouuoooo...
17
[ "PYTHON3" ]
2
2
code_contests
Okay, I need to solve this programming problem. Let's read the problem statement carefully. The task is to process a string such that consecutive equal vowels are combined into one, except for 'e' and 'o' if they appear exactly twice. So, vowels are a, e, i, o, u, y. So the main steps are: 1. Iterate through the stri...
To solve this problem, we need to format a string by collapsing consecutive vowels into a single instance, with exceptions for 'e' and 'o' when they appear exactly twice. The solution involves iterating through the string, grouping consecutive characters, and applying specific rules to each group. ### Approach 1. **Gr...
true
54fd765099878486641cb51acf24fb4b
79_D. Password
Finally Fox Ciel arrived in front of her castle! She have to type a password to enter her castle. An input device attached to her castle is a bit unusual. The input device is a 1 × n rectangle divided into n square panels. They are numbered 1 to n from left to right. Each panel has a state either ON or OFF. Initially...
{"inputs": ["3 2 1\n1 2\n3\n", "10 8 2\n1 2 3 5 6 7 8 9\n3 5\n", "10000 10 100\n2339 4118 4595 5499 5582 6055 8693 9002 9190 9658\n10 75 82 5 14 55 64 68 46 43 97 31 51 20 65 92 3 53 36 38 100 68 20 61 60 98 26 32 50 82 26 73 5 26 12 27 50 83 8 81 65 91 20 11 45 80 54 60 93 54 96 15 50 2 100 38 6 27 8 84 3 27 91 78 6 2...
10
[ "PYTHON3" ]
2
2
code_contests
Okay, let's tackle this problem step by step. So the problem is about flipping panels to reach a certain state with the minimal number of operations. Hmm. First, let's understand the problem. The initial state is all OFF. We need to turn exactly the x1, x2,...,xk panels to ON, and the rest OFF. Each operation allows c...
To solve this problem, we need to determine the minimal number of operations required to flip specific panels to the ON state using given lengths of consecutive panels. The solution involves transforming the problem into a graph problem where each operation corresponds to toggling pairs of positions in a difference arr...
false
Code is incorrect.
fb1e16e95551fe16c4c7b6463fb2dcf3
820_A. Mister B and Book Reading
Mister B once received a gift: it was a book about aliens, which he started read immediately. This book had c pages. At first day Mister B read v0 pages, but after that he started to speed up. Every day, starting from the second, he read a pages more than on the previous day (at first day he read v0 pages, at second —...
{"inputs": ["5 5 10 5 4\n", "12 4 12 4 1\n", "15 1 100 0 0\n", "10 1 4 10 0\n", "100 1 2 1000 0\n", "1 11 12 0 10\n", "1 2 3 0 0\n", "8 6 13 2 5\n", "8 3 5 1 0\n", "17 10 12 6 5\n", "6 4 4 1 2\n", "50 4 5 5 0\n", "20 2 40 1 1\n", "1000 501 510 1 499\n", "129 2 3 4 0\n", "16 4 23 8 3\n", "11 2 4 1 1\n", "97 8 13 234 5\n...
7
[ "PYTHON3" ]
2
2
code_contests
Okay, let's tackle this problem. So the task is to determine how many days Mister B needs to finish reading a book given certain parameters. Let's break down the problem step by step. First, let's understand the parameters: - c: total pages in the book. - v0: initial pages read on the first day. - v1: maximum pages h...
To solve this problem, we need to determine how many days Mister B will take to finish reading a book given his initial reading speed, acceleration in reading speed, maximum reading speed, and the number of pages he needs to reread each day starting from the second day. ### Approach 1. **Initial Setup**: On the first ...
true
6897746b1411ca6eb602bfbd3e056987
846_B. Math Show
Polycarp takes part in a math show. He is given n tasks, each consists of k subtasks, numbered 1 through k. It takes him tj minutes to solve the j-th subtask of any task. Thus, time required to solve a subtask depends only on its index, but not on the task itself. Polycarp can solve subtasks in any order. By solving s...
{"inputs": ["5 5 10\n1 2 4 8 16\n", "3 4 11\n1 2 3 4\n", "1 3 0\n6 3 4\n", "5 4 32\n4 2 1 1\n", "32 6 635\n3 4 2 1 7 7\n", "3 7 20012\n1 1 1 1 1 1 10000\n", "1 5 44\n2 19 18 6 8\n", "1 3 8\n5 4 4\n", "3 3 15\n1 2 1\n", "1 1 1\n1\n", "1 1 0\n2\n", "12 1 710092\n145588\n", "21 3 26\n1 2 3\n", "11 2 20\n1 9\n", "2 2 5\n5 ...
8
[ "PYTHON3" ]
2
2
code_contests
Okay, I need to solve this programming problem. Let's read the problem carefully and understand what it's asking for. So, Polycarp is in a math show. He has n tasks, each with k subtasks. Each subtask j (from 1 to k) of any task takes tj minutes. The points are calculated as follows: each solved subtask gives 1 point....
To solve this problem, we need to determine the maximum number of points Polycarp can earn by solving subtasks within a given time limit. The key challenge is balancing the number of complete tasks solved (which provide bonus points) with the number of individual subtasks solved from remaining tasks. ### Approach 1. *...
true
3e8ef837364e1d24a2c5347163360261
867_D. Gotta Go Fast
You're trying to set the record on your favorite video game. The game consists of N levels, which must be completed sequentially in order to beat the game. You usually complete each level as fast as possible, but sometimes finish a level slower. Specifically, you will complete the i-th level in either Fi seconds or Si ...
{"inputs": ["1 8\n2 8 81\n", "2 30\n20 30 80\n3 9 85\n", "4 319\n63 79 89\n79 97 91\n75 87 88\n75 90 83\n", "48 1976\n30 97 84\n80 81 84\n41 70 86\n23 57 80\n17 60 85\n36 48 81\n51 87 81\n38 85 81\n31 67 80\n11 40 96\n63 100 83\n4 67 82\n16 67 90\n45 97 80\n60 75 82\n5 95 84\n43 85 83\n4 14 81\n21 85 81\n32 39 80\n25 3...
10
[ "PYTHON3" ]
2
2
code_contests
Okay, let's try to understand this problem. So, we have N levels, and each level can be completed in Fi or Si seconds. Fi is faster than Si, and there's a Pi% chance of getting Fi. The goal is to complete all levels sequentially within R seconds. But after each level, we can decide to reset (start over from level 1) or...
To solve this problem, we need to determine the minimum expected time to complete all levels of a game within a given time limit, considering the possibility of resetting the game after completing any level. The solution involves dynamic programming and iterative convergence to find the optimal strategy. ### Approach ...
false
Code is incorrect.
4f0429d3695120a22b95b6c864bb4738
893_A. Chess For Three
Alex, Bob and Carl will soon participate in a team chess tournament. Since they are all in the same team, they have decided to practise really hard before the tournament. But it's a bit difficult for them because chess is a game for two players, not three. So they play with each other according to following rules: ...
{"inputs": ["2\n1\n2\n", "3\n1\n1\n2\n", "99\n1\n3\n2\n2\n3\n1\n1\n3\n3\n3\n3\n3\n3\n1\n1\n3\n3\n3\n3\n1\n1\n3\n2\n1\n1\n1\n1\n1\n1\n1\n3\n2\n2\n2\n1\n3\n3\n1\n1\n3\n2\n1\n3\n3\n1\n2\n3\n3\n3\n1\n2\n2\n2\n3\n3\n3\n3\n3\n3\n2\n2\n2\n2\n3\n3\n3\n1\n1\n3\n2\n1\n1\n2\n2\n2\n3\n3\n2\n1\n1\n2\n2\n1\n3\n2\n1\n1\n2\n3\n3\n3\n3...
7
[ "PYTHON3" ]
2
2
code_contests
Okay, I need to solve this programming problem. Let's read the problem statement carefully. So, the problem is about Alex, Bob, and Carl playing a series of games according to specific rules. The first game is between Alex and Bob, with Carl spectating. After each game, the loser becomes the spectator, and the spectat...
To solve this problem, we need to determine if a given log of game winners between Alex, Bob, and Carl is possible based on specific rules. The rules state that the loser of each game becomes the spectator for the next game, and the previous spectator joins the winner of the current game as the next player. ### Approa...
true
a66c602a3cf74e793d1e3f01b9adf9a7
914_F. Substrings in a String
Given a string s, process q queries, each having one of the following forms: * 1 i c — Change the i-th character in the string to c. * 2 l r y — Consider the substring of s starting at position l and ending at position r. Output the number of times y occurs as a substring in it. Input The first line of the inp...
{"inputs": ["ababababa\n3\n2 1 7 aba\n1 5 c\n2 1 7 aba\n", "abcdcbc\n5\n2 1 7 bc\n1 4 b\n2 4 7 bc\n1 2 a\n2 1 4 aa\n", "abcdabcdab\n5\n2 2 8 ab\n2 1 10 ab\n1 3 a\n1 4 b\n2 1 4 ab\n", "abcdabcdab\n5\n2 2 8 ba\n2 1 10 ab\n1 3 a\n1 4 b\n2 1 4 ab\n", "ababababa\n3\n2 2 7 aba\n1 5 c\n2 1 7 aba\n", "abcdcbc\n5\n2 1 5 bc\n1 4...
12
[ "PYTHON3" ]
2
2
code_contests
Okay, so I need to solve this problem where I have to handle two types of queries on a string. Let's think about how to approach this efficiently. First, the problem says for type 2 queries, we have to count the number of times a substring y appears in the substring from l to r of the original string. The challenge is...
To solve this problem, we need to handle two types of queries on a string efficiently: updating a character at a specific position and counting the occurrences of a substring within a specified range. The solution must efficiently handle these operations given the constraints. ### Approach 1. **Data Structure**: Use a...
true
410da57d1364fe70f1cb02b89aa5dca6
937_D. Sleepy Game
Petya and Vasya arranged a game. The game runs by the following rules. Players have a directed graph consisting of n vertices and m edges. One of the vertices contains a chip. Initially the chip is located at vertex s. Players take turns moving the chip along some edge of the graph. Petya goes first. Player who can't m...
{"inputs": ["3 2\n1 3\n1 1\n0\n2\n", "2 2\n1 2\n1 1\n1\n", "5 6\n2 2 3\n2 4 5\n1 4\n1 5\n0\n1\n", "11 20\n1 2\n2 7 6\n1 7\n4 10 9 3 2\n2 9 2\n1 3\n0\n0\n3 1 6 7\n4 11 7 5 6\n2 2 8\n4\n", "5 5\n1 2\n1 3\n2 1 4\n1 5\n0\n1\n", "5 5\n1 2\n1 3\n2 2 4\n1 5\n0\n1\n", "4 3\n1 2\n1 3\n1 1\n0\n1\n", "6 6\n1 2\n2 3 6\n1 4\n0\n1 3...
10
[ "PYTHON3" ]
2
2
code_contests
Okay, so I need to solve this problem where Petya is trying to win a game by moving the chip on a directed graph. The problem is to determine if Petya can force a win, lose, or draw. Let's think through this step by step. First, I remember that this type of game is similar to the classic impartial games like Nim, but ...
To solve this problem, we need to determine if Petya can win the game by moving the chip along a directed graph such that Vasya cannot make a move when it's his turn. If Petya cannot win, we need to check if he can force a draw by cycling indefinitely, otherwise, he loses. ### Approach 1. **Graph Representation**: Rea...
false
Code is incorrect.
25b08417d2cb571c680dad7e631ccf31
962_F. Simple Cycles Edges
You are given an undirected graph, consisting of n vertices and m edges. The graph does not necessarily connected. Guaranteed, that the graph does not contain multiple edges (more than one edges between a pair of vertices) or loops (edges from a vertex to itself). A cycle in a graph is called a simple, if it contains ...
{"inputs": ["6 7\n2 3\n3 4\n4 2\n1 2\n1 5\n5 6\n6 1\n", "3 3\n1 2\n2 3\n3 1\n", "5 6\n1 2\n2 3\n2 4\n4 3\n2 5\n5 3\n", "2 0\n", "100000 0\n", "8 9\n1 2\n2 3\n3 4\n4 1\n5 6\n6 7\n7 8\n8 5\n6 8\n", "2 1\n1 2\n", "11 9\n5 9\n8 5\n11 3\n11 1\n3 4\n7 11\n3 1\n11 2\n7 2\n", "7 9\n7 3\n7 4\n1 2\n2 3\n3 1\n3 4\n4 5\n5 6\n6 4\n...
12
[ "PYTHON3" ]
2
2
code_contests
Okay, I need to solve this problem where I have to find all edges that belong to exactly one simple cycle in an undirected graph. Hmm. Let's think about the approach here. First, let's understand the problem. A simple cycle is a cycle where each vertex is visited exactly once. So, each edge in such a cycle is part of ...
To solve this problem, we need to determine which edges in an undirected graph belong to exactly one simple cycle. A simple cycle is a cycle where each vertex is visited exactly once. The solution involves decomposing the graph into biconnected components (blocks) and checking if each block forms a simple cycle. ### A...
false
Code is incorrect.
bd1122b008bbddf037910a26ff825b4f
990_B. Micro-World
You have a Petri dish with bacteria and you are preparing to dive into the harsh micro-world. But, unfortunately, you don't have any microscope nearby, so you can't watch them. You know that you have n bacteria in the Petri dish and size of the i-th bacteria is a_i. Also you know intergalactic positive integer constan...
{"inputs": ["6 5\n20 15 10 15 20 25\n", "7 1\n101 53 42 102 101 55 54\n", "7 1000000\n1 1 1 1 1 1 1\n", "2 1\n1 1\n", "4 1\n2 2 1 1\n", "10 1\n2 6 3 4 2 4 4 3 2 1\n", "2 1\n999152 999153\n", "8 1000000\n1 1 5 1000000 1000000 2 2 2\n", "9 2\n1 6 1 5 5 8 6 8 7\n", "15 1\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n", "1 4\n8\n", "10 ...
8
[ "PYTHON3" ]
2
2
code_contests
Okay, let's tackle this problem. Hmm, the task is to find the minimal possible number of bacteria remaining after all possible swallow operations. So each time a bacteria can swallow another if it's larger than the other but not by more than K. And the swallowed one disappears. The goal is to minimize the count. Firs...
To solve this problem, we need to determine the minimal possible number of bacteria remaining after all possible swallow operations. A bacteria can swallow another if it is larger but not by more than a given constant K. The goal is to find the optimal way to maximize the number of swallows, thereby minimizing the rema...
true
4c94b2e9b47102ba51722a72a59b6ba1
ankit-and-race-team-10
Coach Ankit is forming a team for the Annual Inter Galactic Relay Race. He has N students that train under him and he knows their strengths. The strength of a student is represented by a positive integer. The coach has to form a team of K students. The strength of a team is defined by the strength of the weakest stude...
{"inputs": ["2\n2 1\n5 4\n3 2\n1 0 2\n\nSAMPLE", "2\n2 1\n3 4\n3 2\n1 0 2\n\nSAMPLE", "2\n2 1\n5 5\n3 2\n1 0 2\n\nSAMPLE", "2\n2 1\n3 0\n3 2\n1 0 2\n\nSAMPLE", "2\n2 1\n0 5\n3 2\n1 0 2\n\nSAMPLE", "2\n2 2\n3 0\n3 2\n1 0 2\n\nELPMAS", "2\n2 2\n3 -1\n3 2\n1 0 2\n\nELPMAS", "2\n2 2\n5 4\n3 2\n1 0 2\n\nSAMPLE", "2\n2 1\n0 ...
0
[ "PYTHON3" ]
3
2
code_contests
Okay, I need to solve this programming problem. Let's read the problem carefully. The problem is about forming teams of K students from N students, where each team's strength is the minimum strength of its members. We need to compute the sum of all possible such teams' strengths modulo 1e9+7. Hmm. The sample input he...
To solve this problem, we need to determine the sum of the strengths of all possible teams of size K formed from N students, where the strength of a team is defined by the weakest member. The solution must be efficient given the constraints. ### Approach 1. **Sorting**: First, sort the array of strengths in ascending ...
true
0d936bf28c464e225fddc1f7e26b970b
chandu-and-daspal-2
Continuing from previous version of codeXplod series i.e. CodeXplod 1.0,Chandu and daspal are still fighting over a matter of MOMO's(they are very fond of Mo Mos of sector 3..:P).This time the fight became so savior that they want to kill each other.As we all know that during a fight it is most probable outcome that b...
{"inputs": ["1\n2 3 Chandu\n\nSAMPLE", "51\n8 10 Chandu\n2 2959 Daspal\n2903 6 Chandu\n9 2938 Daspal\n10 2907 Daspal\n8 2966 Daspal\n8 2938 Daspal\n4 2984 Daspal\n5 2939 Daspal\n2 2975 Daspal\n2925 10 Chandu\n4 2982 Daspal\n10 2959 Daspal\n3 2906 Daspal\n5 2904 Daspal\n2983 5 Chandu\n10 2998 Daspal\n10 2980 Daspal\n6 2...
0
[ "PYTHON3" ]
3
2
code_contests
Okay, let's see. I need to solve this problem where two players, Chandu and Daspal, are playing a game with two integers x and y. They take turns subtracting the gcd of x and y from both numbers. The player who makes either or both of the numbers zero wins. I have to determine who wins given the starting values and who...
To solve this problem, we need to determine the winner of a game where two players, Chandu and Daspal, take turns subtracting the greatest common divisor (gcd) from two given integers. The player who makes either of the integers zero wins the game. The solution involves simulating the game steps and determining the win...
true
7eda68f6c2d65f69d5bab71bb9d039ed
digital-numbers
Bosky is a very curious child who turned 13 yesterday. His parents gifted him a digital watch which he really liked. He was amazed to see how each number can be represented inside one cell only by switching different edges on and off. Today, while he was in his home alone, getting bored looking at his watch, an idea p...
{"inputs": ["4\n1 14\n1 50\n4 28\n5 700\n\nSAMPLE", "5\n1 14\n1 50\n4 28\n5 700\n3 147"], "outputs": ["1\n10\n3\n32491", "1\n10\n3\n32491\n739"]}
0
[ "PYTHON3" ]
3
2
code_contests
Okay, let's tackle this problem. Hmm, the problem statement says that Bosky wants to arrange digits on a 2xL board. Each digit takes 1 unit length. So, the total number of digits he can display is L, right? But each digit uses a certain number of LED tubes, which cost 7 each. He spends all his money M, so the total tub...
To solve this problem, we need to determine how many different digits Bosky can represent on a 2xL board using LED tubes purchased with his available money, such that no digit is repeated. Each digit has a specific number of LED tubes required for its representation, and the goal is to count all possible valid combinat...
false
Code is incorrect.
366a68acad8b5deeb8ff06bd80813b85
give-me-my-test-monk
Professor just has checked all the N students tests. Everything was fine but then he realised that none of the students had signed their papers, so he doesn't know which test belongs to which student. But it's definitely not professors's job to catch every student and asked him to find his paper! So he will hand out...
{"inputs": ["3 1 3\n\nSAMPLE", "60 0 58", "7 3 7"], "outputs": ["833333340", "630738177", "195634923"]}
0
[ "PYTHON3" ]
3
2
code_contests
Okay, let's try to solve this problem. So the problem is about finding the probability that exactly X students receive someone else's test, where X is between L and R inclusive. And we need to compute this probability as a fraction P/Q, then output P multiplied by the modular inverse of Q modulo 1e9+7. First, I need t...
To solve this problem, we need to determine the probability that a certain number of students receive someone else's test when tests are distributed randomly. The solution involves combinatorial mathematics and modular arithmetic to handle large numbers efficiently. ### Approach 1. **Combinatorial Analysis**: We need ...
true
d2b9d161b755d92b17f954d7c3f269fc
lexicographically-preceding-permutation
Given an integer n and a permutation of numbers 1, 2 ... , n-1, n write a program to print the permutation that lexicographically precedes the given input permutation. If the given permutation is the lexicographically least permutation, then print the input permutation itself. Input Format: First line is the test c...
{"inputs": ["1\n3\n1 3 2\n\nSAMPLE"], "outputs": ["1 2 3"]}
0
[ "PYTHON3" ]
3
2
code_contests
Okay, I need to find the permutation that comes right before the given permutation in lexicographic order. If the given permutation is the smallest possible, then just return it as is. Hmm. Let me recall how permutation ordering works. Lex order is like dictionary order. So for example, 123 comes before 132, which com...
To solve this problem, we need to find the permutation that lexicographically precedes the given permutation. If the given permutation is the smallest possible, we return it as is. The solution involves a systematic approach to identify the correct elements to swap and adjust the suffix to form the previous permutation...
true
0fc51a04492be2d3e10efbc9fbf500d9
monks-birthday-party
Monk's birthday is coming this weekend! He wants to plan a Birthday party and is preparing an invite list with his friend Puchi. He asks Puchi to tell him names to add to the list. Puchi is a random guy and keeps coming up with names of people randomly to add to the invite list, even if the name is already on the list...
{"inputs": ["1\n7\nchandu\nparo\nrahul\nmohi\nparo\narindam\nrahul\n\nSAMPLE", "5\n10\nbb\nbb\nab\naa\nbb\nbb\nba\naa\nbb\nab\n10\nbb\nab\nba\nab\nba\nba\nab\nba\nba\nba\n10\naa\nba\nba\nba\nbb\nab\nab\naa\nbb\nbb\n10\nab\nab\nbb\nbb\nab\nba\naa\nba\nab\naa\n10\nba\nbb\nbb\nbb\naa\nba\nba\nba\nbb\nbb", "5\n10\nbb\nbb\n...
0
[ "PYTHON3" ]
3
2
code_contests
Okay, I need to solve this programming problem. Let's read the problem carefully. The task is to process multiple test cases. For each test case, we are given a number of names, and we need to output a list of those names without duplicates, sorted lexicographically. So the steps are: read all the names for a test cas...
To solve this problem, we need to generate an invite list from a list of names provided by Puchi, ensuring there are no duplicates and the names are sorted lexicographically. ### Approach 1. **Reading Input Efficiently**: Given the constraints, we need to read input efficiently. Using `sys.stdin.read()` allows us to ...
true
8025c69347f1f103f77e05fc4f3d150e
play-with-string
Suppose you have a string S which has length N and is indexed from 0 to N−1. String R is the reverse of the string S. The string S is funny if the condition |Si−Si−1|=|Ri−Ri−1| is true for every i from 1 to N−1. (Note: Given a string str, stri denotes the ascii value of the ith character (0-indexed) of str. |x| denote...
{"inputs": ["2\nacxz\nbcxz\n\nSAMPLE", "2\nacxz\nbcxz", "2\nacxz\nzxcb", "2\nzxda\nzxcb\n\nSAMPLE", "2\nzwac\nbcyz", "2\nywac\nbcyz", "2\nzxca\nbcxz\n\nSAMPLE", "2\nzxca\nzxcb\n\nSAMPLE", "2\nyxda\nzxcb\n\nSAMPLE", "2\nyxda\nzxcb\n\nASMPLE", "2\nyxda\nzwcb\n\nASMPLE", "2\nyxda\nzcwb\n\nASMPLE", "2\nyxea\nzcwb\n\nASMPLE...
0
[ "PYTHON3" ]
3
2
code_contests
Okay, I need to solve this problem where I have to determine if a given string is funny based on the specified condition. Let's see. The problem says that the string S is funny if for every i from 1 to N-1, the absolute difference between consecutive characters in S is the same as the absolute difference between consec...
To solve this problem, we need to determine if a given string is "Funny" based on specific conditions. The string is considered funny if the absolute differences between consecutive characters in the string are the same as those in its reverse. ### Approach 1. **Understand the Problem**: The string is funny if for eve...
false
Code is incorrect.
d85358e8d7b440535639a879e7b22af9
roy-and-wobbly-numbers
Roy is looking for Wobbly Numbers. An N-length wobbly number is of the form "ababababab..." and so on of length N, where a != b. A 3-length wobbly number would be of form "aba". Eg: 101, 121, 131, 252, 646 etc But 111, 222, 999 etc are not 3-length wobbly number, because here a != b condition is not satisfied. ...
{"inputs": ["6\n3 1\n3 2\n3 100\n4 3\n4 4\n5 2\n\nSAMPLE", "6\n3 1\n3 2\n5 100\n4 3\n4 4\n5 2\n\nSAMPLE", "6\n6 1\n3 2\n5 100\n4 3\n4 4\n5 2\n\nSAMPLE", "6\n6 1\n3 1\n5 100\n4 3\n4 4\n5 2\n\nSAMPLE", "6\n6 1\n3 1\n5 100\n4 3\n4 5\n5 2\n\nSAMPLE", "6\n11 1\n3 1\n5 100\n4 3\n4 5\n5 2\n\nSAMPLE", "6\n11 1\n3 1\n5 100\n4 3...
0
[ "PYTHON3" ]
3
2
code_contests
Okay, let's tackle this problem. Hmm, I need to find the K-th wobbly number of length N. Let's see what a wobbly number is. Oh right, it's in the pattern ababab... where a and b are different digits. Also, leading zeros are not allowed, so the first digit can't be zero. First, the problem says the list is lexicographi...
To solve this problem, we need to generate the K-th lexicographically ordered N-length wobbly number. A wobbly number follows the pattern "ababab..." where a and b are distinct digits, and the number must not have leading zeros. If the K-th wobbly number does not exist, we should return -1. ### Approach 1. **Understan...
true
a0892dbaa5d35286c8c118f0e7c54937
substrings-count-3
Jack is the most intelligent student in the class.To boost his intelligence,his class teacher gave him a problem named "Substring Count". Problem : His Class teacher gave him n strings numbered from 1 to n which consists of only lowercase letters (each having length not more than 10) and then ask Q questions related t...
{"inputs": ["3\ncode\ncoder\ncoding\n2\n1 3 code\n1 3 co\n\nSAMPLE", "1000\nspnogbxcrp\nbaukbqnmyu\nogxdxhtcwz\nbsjufplykz\nkhicdrdixl\nzookiqggel\nfczygjfhfa\nkobjmuswpw\ndypvhmsjlh\nvbcnnpwmgm\nvzvkarnyqs\ntfssjnurqh\ntbxcluekyt\necnegofqxs\nhbhdeftboc\nqvmotsnevm\nwxzidquite\noqowdpeszj\npnypgzooxk\nuytjntdfmn\nhflt...
0
[ "PYTHON3" ]
3
2
code_contests
Okay, let's see. I need to solve this problem where for each query, I have to find out how many strings between positions L and R contain a given substring. The constraints are tight, especially with Q up to 5e5. So a naive approach of checking each string for each query would be way too slow. Let's think about how to ...
To solve this problem efficiently, we need to determine how many strings within a given range contain a specific substring. Given the constraints, a naive approach would be too slow, so we use a preprocessing step to handle queries efficiently. ### Approach 1. **Preprocessing**: - For each string, generate all pos...
true
86729e1c9dbf52ef01678c1874cdef49
vibhu-and-his-mathematics
In code world all genders are considered equal ( It means their is nothing like male or female). Now their are N distinct persons living in this hypothetical world. Each person can pair up with any other person or can even remain single. One day Vbhu planned to visit code world. Being a maths guy , he always try to b...
{"inputs": ["2\n2\n3\n\n\nSAMPLE", "2\n1\n3\n\n\nSAMPLE", "2\n2\n3\n\n\nSBMPLE", "2\n2\n2\n\n\nELPMBS", "2\n4\n2\n\n\nELPMBS", "2\n3\n3\n\n\nFLQMBS", "2\n5\n2\n\n\nELPMBS", "2\n3\n1\n\n\nFLQMBS", "2\n1\n5\n\n\nEANPLS", "2\n1\n8\n\n\nEANPLS", "2\n1\n7\n\n\nEANPLS", "2\n1\n4\n\n\nEANPLS", "2\n2\n5\n\n\nSLPNAD", "2\n2\n4\...
0
[ "PYTHON3" ]
3
2
code_contests
Okay, let's tackle this problem step by step. The task is to find the number of ways N distinct persons can pair up or remain single. Each person can be in at most one pair, and pairs are unordered. The answer needs to be computed efficiently, especially since N can be up to 1e6 and there are up to 1e5 test cases, whic...
To solve this problem, we need to determine the number of ways in which N distinct persons can either pair up or remain single, considering that each person can pair up with at most one other person. The solution must efficiently handle large values of N up to 1,000,000 and multiple test cases up to 100,000. ### Appro...
true
15367dcad420799575333e16a08c42f0
p02610 AIsing Programming Contest 2020 - Camel Train
We have N camels numbered 1,2,\ldots,N. Snuke has decided to make them line up in a row. The happiness of Camel i will be L_i if it is among the K_i frontmost camels, and R_i otherwise. Snuke wants to maximize the total happiness of the camels. Find the maximum possible total happiness of the camel. Solve this probl...
{"inputs": ["3\n2\n1 5 10\n2 15 5\n3\n2 93 78\n1 71 59\n3 57 96\n19\n19 23 16\n5 90 13\n12 85 70\n19 67 78\n12 16 60\n18 48 28\n5 4 24\n12 97 97\n4 57 87\n19 91 74\n18 100 76\n7 86 46\n9 100 57\n3 76 73\n6 84 93\n1 6 84\n11 75 94\n19 15 3\n12 11 34", "3\n2\n1 5 10\n2 15 5\n3\n2 93 78\n1 71 59\n3 57 96\n19\n19 23 16\n5 ...
0
[ "PYTHON3" ]
5
2
code_contests
Okay, let's see. I need to solve this problem where we have N camels, each with certain conditions that determine their happiness. The goal is to arrange them in a line such that the total happiness is maximized. For each camel, if it's among the first K_i camels (frontmost), then its happiness is L_i; otherwise, it's ...
To solve this problem, we need to maximize the total happiness of camels arranged in a line, where each camel's happiness depends on its position relative to a given threshold. The solution involves a systematic approach to determine the optimal arrangement of camels to achieve the highest possible total happiness. ##...
false
Code is incorrect.
c93ca658752893b9219752de12d6c704
p02741 Panasonic Programming Contest 2020 - Kth Term
Print the K-th element of the following sequence of length 32: 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 Constraints * 1 \leq K \leq 32 * All values in input are integers. Input Input is given from Standard Input in the following format: K Output Print ...
{"inputs": ["27", "6", "16", "19", "8", "24", "32", "28", "-22", "1", "15", "5", "-9", "-27", "-13", "29", "-20", "001", "8", "1", "32", "5", "15", "24", "-9", "-13", "19", "29", "16", "28", "-20", "-27", "-22", "001"], "outputs": ["5", "2", "14\n", "1\n", "5\n", "15\n", "51\n", "4\n", "2\n", "1\n", "1\n", "1\n", "1\n"...
0
[ "PYTHON3" ]
5
2
code_contests
Okay, let's see. I need to generate a Python function that reads a number K from stdin and outputs the K-th element of this specific sequence. The sequence given has 32 elements. The examples show that for K=6, the output is 2, and for K=27, it's 5. So, the task is straightforward once I have the sequence correctly map...
To solve this problem, we need to determine the K-th element of a predefined sequence of 32 integers. The solution involves directly accessing the K-th element from the sequence using a zero-based index, adjusted from the 1-based input K. ### Approach 1. **Problem Analysis**: The problem requires us to return the K-th...
true
cf12c06987214121d22579d9bdd9bd29
p02876 AtCoder Grand Contest 040 - Balance Beam
We have N balance beams numbered 1 to N. The length of each beam is 1 meters. Snuke walks on Beam i at a speed of 1/A_i meters per second, and Ringo walks on Beam i at a speed of 1/B_i meters per second. Snuke and Ringo will play the following game: * First, Snuke connects the N beams in any order of his choice and m...
{"inputs": ["3\n4 1\n5 2\n6 3", "4\n1 5\n4 7\n2 1\n8 4", "2\n3 2\n1 2", "10\n866111664 178537096\n705445072 318106937\n472381277 579910117\n353498483 865935868\n383133839 231371336\n378371075 681212831\n304570952 16537461\n955719384 267238505\n844917655 218662351\n550309930 62731178", "3\n1 1\n5 2\n6 3", "4\n1 5\n4 7\n...
0
[ "PYTHON3" ]
5
2
code_contests
Okay, let's tackle this problem. Hmm, the problem says we need to arrange N beams in a certain order so that the probability Snuke catches Ringo is maximized. Then output that probability as a reduced fraction. First, let's understand the problem. Snuke connects the beams in any order. Each beam has length 1. Then, Sn...
To solve this problem, we need to determine the optimal arrangement of balance beams such that Snuke maximizes his probability of catching Ringo. The solution involves a careful analysis of the beams where Snuke's speed is greater than Ringo's and using a greedy approach to sort these beams to maximize the probability....
false
Code is incorrect.
9d5837902bd3a890c944ee11cc872a15
p03010 diverta 2019 Programming Contest 2 - Diverta City
Diverta City is a new city consisting of N towns numbered 1, 2, ..., N. The mayor Ringo is planning to connect every pair of two different towns with a bidirectional road. The length of each road is undecided. A Hamiltonian path is a path that starts at one of the towns and visits each of the other towns exactly once...
{"inputs": ["4", "3", "2", "6", "7", "8", "10", "1", "5", "9", "001", "010", "5", "6", "1", "9", "7", "2", "10", "8", "001", "010"], "outputs": ["0 111 157 193\n111 0 224 239\n157 224 0 258\n193 239 258 0", "0 6 15\n6 0 21\n15 21 0", "0 1\n1 0\n", "0 1 2 7 45 512\n1 0 4 14 90 1024\n2 4 0 28 180 2048\n7 14 28 0 315 3584...
0
[ "PYTHON3" ]
5
2
code_contests
Okay, let's tackle this problem. Hmm, the task is to assign lengths to roads between towns such that all Hamiltonian paths have distinct total lengths. And each road's length must be a positive integer, and the maximum total must be ≤1e11. First, I need to understand what a Hamiltonian path is here. Oh right, since t...
To solve this problem, we need to assign lengths to roads between towns such that all Hamiltonian paths have distinct total lengths. Each road's length must be a positive integer, and the maximum total length of any Hamiltonian path must not exceed \(10^{11}\). ### Approach The key insight is to assign edge weights in...
false
Code is incorrect.
63b4e5dc69d206100e4524a339d5a693
p03150 KEYENCE Programming Contest 2019 - KEYENCE String
A string is called a KEYENCE string when it can be changed to `keyence` by removing its contiguous substring (possibly empty) only once. Given a string S consisting of lowercase English letters, determine if S is a KEYENCE string. Constraints * The length of S is between 7 and 100 (inclusive). * S consists of lowerc...
{"inputs": ["keyence", "ashlfyha", "keyofscience", "mpyszsbznf", "ecneyek", "ashkfyha", "eeyofscienck", "mnyszsbzpf", "ecneyel", "arhkfyha", "eeyofsciencj", "mnyszsb{pf", "ecleyen", "arhkyfha", "eeyofscienci", "mnzszsb{pf", "neyelce", "ahfykhra", "eeyofscjenci", "mnzs{sb{pf", "neyemce", "ahfzkhra", "icnejcsfoyee", "snz...
0
[ "PYTHON3" ]
5
2
code_contests
Okay, I need to solve this problem where I have to determine if a given string is a KEYENCE string. Let's think about what a KEYENCE string is. The definition says that it can be changed to "keyence" by removing a contiguous substring exactly once. So, the idea is that after removing one substring (which could be anywh...
To solve this problem, we need to determine if a given string can be transformed into the string "keyence" by removing exactly one contiguous substring. This means that after removing a contiguous substring from the given string, the remaining parts (prefix and suffix) should exactly form "keyence". ### Approach 1. **...
true
3c40f948ec1b67f71a65c08c17327cb8
p03294 AtCoder Beginner Contest 103 - Modulo Summation
You are given N positive integers a_1, a_2, ..., a_N. For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N). Here, X\ mod\ Y denotes the remainder of the division of X by Y. Find the maximum value of f. Constraints * All values in input are integers. * 2 \leq N \leq 3000 * 2 ...
{"inputs": ["5\n7 46 11 20 11", "7\n994 518 941 851 647 2 581", "3\n3 4 6", "5\n7 46 11 17 11", "7\n994 518 941 851 647 2 568", "3\n3 1 6", "5\n7 46 11 17 13", "7\n994 518 941 523 647 2 568", "3\n3 2 6", "5\n7 13 11 17 13", "7\n994 518 941 523 647 1 568", "3\n3 3 6", "5\n7 12 11 17 13", "7\n994 765 941 523 647 1 568", ...
0
[ "PYTHON3" ]
5
2
code_contests
Okay, let's see. The problem is to find the maximum value of the function f(m), which is the sum of m mod a_i for each a_i in the given list. Hmm. So, what's the approach here? First, I need to understand what m mod a_i does. The modulo operation gives the remainder when m is divided by a_i. The maximum possible value...
To solve this problem, we need to determine the maximum value of the function \( f(m) \), which is defined as the sum of the remainders when a non-negative integer \( m \) is divided by each element in a given list of positive integers. The key insight is recognizing that the maximum value of each term in the sum occur...
true
1bef47e43c16fe924cea2f56ba4de4ed
p03452 AtCoder Regular Contest 090 - People on a Line
There are N people standing on the x-axis. Let the coordinate of Person i be x_i. For every i, x_i is an integer between 0 and 10^9 (inclusive). It is possible that more than one person is standing at the same coordinate. You will given M pieces of information regarding the positions of these people. The i-th piece of...
{"inputs": ["3 3\n1 2 1\n2 3 1\n1 3 5", "100 0", "10 3\n8 7 100\n7 9 100\n9 8 100", "3 3\n1 2 1\n2 3 1\n1 3 2", "4 3\n2 1 1\n2 3 5\n3 4 2", "000 0", "10 3\n8 7 000\n7 9 100\n9 8 100", "4 3\n2 1 1\n2 3 3\n3 4 2", "10 3\n8 7 000\n7 9 110\n9 8 100", "4 3\n1 1 1\n2 3 3\n3 4 2", "10 3\n9 7 000\n7 9 110\n9 8 100", "4 3\n1 1 ...
0
[ "PYTHON3" ]
5
2
code_contests
Okay, let's see. The problem is to determine if there's a way to assign coordinates to N people such that all M given constraints are satisfied. The constraints are of the form x_Ri - x_Li = D_i. But some constraints might be conflicting, so we need to check for consistency. Hmm, how to model this? Oh right, this feel...
To solve this problem, we need to determine if there exists a consistent set of coordinates for N people standing on the x-axis given M constraints. Each constraint specifies the distance between two people, and we need to check if all constraints can be satisfied simultaneously. ### Approach 1. **Graph Representation...
true
83a0cb624b1ad187ec0f771e206f13d1
p03612 AtCoder Beginner Contest 072 - Derangement
You are given a permutation p_1,p_2,...,p_N consisting of 1,2,..,N. You can perform the following operation any number of times (possibly zero): Operation: Swap two adjacent elements in the permutation. You want to have p_i ≠ i for all 1≤i≤N. Find the minimum required number of operations to achieve this. Constraint...
{"inputs": ["5\n1 4 3 5 2", "9\n1 2 4 9 5 8 7 3 6", "2\n1 2", "2\n2 1", "5\n1 4 4 5 2", "9\n1 2 4 9 5 8 7 6 6", "9\n1 2 4 9 5 8 4 6 6", "5\n0 4 4 5 1", "2\n1 0", "2\n1 1", "5\n1 4 4 5 1", "2\n1 -1", "2\n0 2", "9\n2 2 4 9 5 8 4 6 6", "2\n2 2", "2\n0 1", "5\n0 4 4 4 1", "9\n2 2 4 5 5 8 4 6 6", "2\n2 0", "2\n0 0", "5\n0 4...
0
[ "PYTHON3" ]
5
2
code_contests
Okay, let's try to figure out this problem. The task is to find the minimum number of adjacent swaps needed so that no element in the permutation ends up in its original position (i.e., p_i != i for all i). Hmm. First, let's understand what's required. We need each element not to be in its original position. So, for e...
To solve this problem, we need to determine the minimum number of adjacent swaps required to transform a given permutation such that no element remains in its original position. ### Approach The key insight is to traverse the permutation and handle fixed points (elements that are in their original positions) efficien...
true
578f5c42517bb286c44e56609bd8a6d7
p03771 AtCoder Grand Contest 012 - Camel and Oases
There are N oases on a number line. The coordinate of the i-th oases from the left is x_i. Camel hopes to visit all these oases. Initially, the volume of the hump on his back is V. When the volume of the hump is v, water of volume at most v can be stored. Water is only supplied at oases. He can get as much water as he...
{"inputs": ["7 2\n-10 -4 -2 0 2 4 10", "16 19\n-49 -48 -33 -30 -21 -14 0 15 19 23 44 52 80 81 82 84", "3 2\n1 3 6", "7 4\n-10 -4 -2 0 2 4 10", "16 19\n-49 -48 -33 -30 -21 -14 0 15 19 23 44 55 80 81 82 84", "3 2\n1 3 2", "16 19\n-49 -48 -24 -30 -21 -14 0 15 19 23 44 55 80 81 82 84", "5 2\n1 3 2", "16 19\n-49 -48 -24 -30...
0
[ "PYTHON3" ]
5
2
code_contests
Okay, let's try to tackle this problem. So, the problem is about a camel visiting all oases on a number line. The camel can walk, which costs water equal to the distance, or jump, which resets the stored water to zero and halves the hump's volume (rounded down). The goal is to determine for each oasis whether starting ...
To solve this problem, we need to determine if a camel can start from each oasis and visit all other oases using a combination of walking and jumping. The camel can walk, which consumes water equal to the distance traveled, or jump, which resets the stored water to zero and halves the hump's volume. The solution involv...
false
Code is incorrect.
c46559d876ae389c6024eeb67ca8328a
p03940 AtCoder Grand Contest 007 - Shik and Game
Imagine a game played on a line. Initially, the player is located at position 0 with N candies in his possession, and the exit is at position E. There are also N bears in the game. The i-th bear is located at x_i. The maximum moving speed of the player is 1 while the bears do not move at all. When the player gives a c...
{"inputs": ["3 9 1\n1 3 8", "2 1000000000 1000000000\n1 999999999", "3 9 3\n1 3 8", "3 9 1\n2 3 8", "2 1000000000 1000000000\n1 199586132", "3 9 3\n1 3 7", "3 9 3\n1 0 7", "2 1000001000 1000000000\n2 199586132", "3 9 5\n1 0 7", "2 1010001000 1000000000\n2 199586132", "2 1010001000 1000001000\n4 125587868", "3 9 1\n1 3 ...
0
[ "PYTHON3" ]
5
2
code_contests
Okay, I need to solve this problem where Shik has to give candies to all bears, collect all coins, and reach the exit in the minimum time possible. Let's try to break down the problem step by step. First, let's understand the problem. The player starts at 0, needs to give each bear a candy (which takes 0 time), then c...
To solve this problem, we need to determine the minimum time required for Shik to give candies to all bears, collect all coins produced by the bears, and then reach the exit. The key challenge is to optimize the path and timing to minimize the total time spent. ### Approach 1. **Movement and Timing**: Shik starts at p...
false
Code is incorrect.
097f57d87b4f4026530f447c45ad6910
p00032 Plastic Board
There is a factory that inputs the data of the side and diagonal lengths to the machine and cuts out the plastic plate. At this factory, we cut out only parallelogram molds, although they vary in size. You have been ordered by your boss to count the number of rectangles and rhombuses produced among the parallelograms t...
{"inputs": ["3,4,5\n5,5,8\n4,4,4\n5,4,3", "3,4,5\n5,5,8\n4,5,4\n5,4,3", "3,3,5\n5,5,8\n4,4,4\n5,4,3", "3,4,5\n5,5,8\n4,5,4\n3,4,5", "3,4,5\n8,5,5\n4,5,4\n3,4,5", "3,5,5\n6,5,8\n4,4,5\n5,4,3", "3,3,5\n5,5,8\n3,4,4\n5,4,3", "3,4,5\n8,5,5\n4,5,4\n5,4,3", "4,4,5\n5,5,8\n4,5,4\n3,4,5", "3,4,5\n5,5,8\n4,4,4\n3,4,5", "3,2,5\n...
0
[ "PYTHON3" ]
6
2
code_contests
Okay, I need to solve this programming problem. Let me read the problem carefully. The task is to count the number of rectangles and rhombuses from a list of parallelograms. Each parallelogram is given by two adjacent sides (ai, bi) and a diagonal ci. The input is multiple lines of these three values. The output shoul...
To solve this problem, we need to count the number of rectangles and rhombuses from a list of parallelograms given by their side lengths and a diagonal. Each parallelogram is defined by two adjacent sides and one diagonal. ### Approach 1. **Understanding the Problem**: - A rectangle is a parallelogram where the d...
true
f7d0f4fd4d31e8195b95bda423ebd008
p00163 Highway Toll
In 20XX, the Aizu Chuo Road, which has a total distance of 58km and 6 sections from Atsushiokanomachi, Kitakata City to Minamiaizucho, is scheduled to be completed and opened. For half a year after opening, the toll will be halved for vehicles that pass the departure IC or arrival IC between 17:30 and 19:30 and have a...
{"inputs": ["2\n17 25\n4\n17 45\n4\n17 25\n7\n19 35\n0", "2\n17 25\n4\n17 45\n4\n17 25\n7\n1 35\n0", "2\n19 25\n4\n17 37\n4\n17 47\n7\n0 63\n0", "2\n14 25\n4\n3 37\n4\n17 47\n7\n0 63\n0", "2\n13 25\n3\n17 45\n4\n17 25\n7\n1 35\n0", "2\n14 25\n4\n17 37\n0\n17 47\n7\n0 63\n0", "2\n13 25\n3\n17 45\n4\n17 47\n7\n1 35\n0", ...
0
[ "PYTHON3" ]
6
2
code_contests
Okay, let's tackle this problem. Hmm, I need to create a Python function that reads input datasets and calculates the toll based on certain conditions. Let me break down the problem step by step. First, the input format: each dataset has four lines. The first line is the departure IC number. The second line is the dep...
To solve this problem, we need to calculate the toll charge for vehicles passing through specific sections of the Aizu Chuo Road, considering a half-price discount under certain conditions. The solution involves determining the fare and distance between two points (ICs) and applying the discount if the vehicle meets th...
false
Code is incorrect.
a6a7b5f0e25a941bca2ce410ac39c300
p00320 Cuboid
The educational program (AHK Education) of the Aiz Broadcasting Corporation broadcasts a program called "Play with Tsukuro" for children. Today is the time to make a box with drawing paper, but I would like to see if the rectangular drawing paper I prepared can make a rectangular parallelepiped. However, do not cut or ...
{"inputs": ["2 2\n2 3\n2 3\n2 3\n2 2\n3 2", "2 2\n2 3\n2 3\n2 3\n2 2\n2 2", "2 2\n2 3\n2 3\n2 3\n2 2\n5 2", "2 2\n2 3\n2 2\n2 3\n2 2\n2 2", "2 2\n2 3\n2 3\n2 2\n2 2\n5 2", "2 2\n2 3\n2 2\n2 3\n2 2\n2 3", "2 2\n2 3\n2 3\n2 2\n2 2\n10 2", "2 2\n2 3\n4 2\n2 3\n2 2\n2 3", "2 2\n2 3\n2 2\n2 2\n2 2\n10 2", "2 2\n2 3\n4 4\n2 ...
0
[ "PYTHON3" ]
6
2
code_contests
Okay, I need to solve this problem where given six rectangles, I have to determine if they can form a rectangular prism. Let's think about the properties required here. A rectangular prism has six faces. The opposite faces must be equal. So for the six rectangles, they should form three pairs of identical rectangles. ...
To solve this problem, we need to determine if six given rectangles can form a rectangular prism (or cube) without cutting or folding, only rotating. The key insight is that the rectangles must form three pairs of identical dimensions, which correspond to the opposite faces of the prism. ### Approach 1. **Normalize Di...
false
Code is incorrect.
15c9898a16e6cc297524740da5308dcc
p00490 Best Pizza
problem Chairman K is a regular customer of the JOI pizza shop in the center of JOI city. For some reason, he decided to start a life-saving life this month. So he wanted to order the pizza with the highest calories per dollar among the pizzas he could order at the JOI pizza store. Let's call such a pizza the "best pi...
{"inputs": ["3\n12 2\n200\n50\n300\n100", "3\n12 2\n200\n50\n300\n110", "3\n17 2\n200\n73\n300\n110", "3\n12 2\n200\n50\n599\n100", "3\n12 2\n200\n73\n575\n110", "3\n17 2\n200\n50\n300\n010", "3\n17 2\n63\n50\n300\n010", "3\n12 2\n200\n54\n506\n110", "3\n17 2\n38\n50\n300\n010", "3\n12 2\n358\n87\n575\n010", "3\n12 2\n...
0
[ "PYTHON3" ]
6
2
code_contests
Okay, so I need to solve this programming problem. Let's read the problem statement carefully. The problem is about finding the best pizza in terms of calories per dollar. The best pizza is the one with the highest ratio, and if there are multiple, they all count but we just need to output the maximum value, rounded d...
To solve this problem, we need to determine the pizza with the highest calories per dollar ratio from the given options. The solution involves selecting the optimal combination of toppings to maximize this ratio, considering both the cost of the dough and the toppings. ### Approach 1. **Input Reading**: Read the numbe...
true
073b66100b0a7722bc531069c7183a79
p00676 KND is So Sexy
Problem KND is a student programmer at the University of Aizu. His chest is known to be very sexy. <image> For simplicity, the part of the skin that can be seen from the chest is represented by the isosceles triangle ABC in the figure. However, due to the slack in the clothes, the two sides AC and BC (where these l...
{"inputs": ["2 2 1\n2 3 1\n3 2 3\n2 3 5", "2 2 1\n2 3 1\n3 2 3\n1 3 5", "4 2 1\n2 3 1\n3 2 3\n1 3 5", "2 2 1\n2 3 1\n3 2 5\n1 3 5", "2 2 0\n2 3 1\n3 2 3\n2 3 5", "2 2 1\n2 3 1\n1 2 3\n1 3 5", "4 2 1\n2 3 1\n3 2 3\n1 3 0", "2 2 1\n2 3 1\n1 2 5\n1 3 5", "2 2 0\n2 3 0\n3 2 3\n2 3 5", "3 2 1\n2 3 1\n1 2 3\n1 3 5", "4 2 1\n...
0
[ "PYTHON3" ]
6
2
code_contests
Okay, let's try to understand this problem. So, we have this triangle ABC which is isosceles, with AB as the base of length a, and AC and BC both of length l. But there's some slack x in the sides AC and BC. So, when they pull the slack to create new triangles ADC and BEC, points D and E are outside the original triang...
To solve this problem, we need to determine the maximum area of the visible skin (M) from KND's chest, which is represented by an isosceles triangle ABC with additional triangles formed by pulling the slack from the sides AC and BC. The goal is to maximize the sum of the areas of the original triangle and the two new t...
false
Code is incorrect.
70deaaf9d423105e91300226528674b6
p00819 Unreliable Message
The King of a little Kingdom on a little island in the Pacific Ocean frequently has childish ideas. One day he said, “You shall make use of a message relaying game when you inform me of something.” In response to the King’s statement, six servants were selected as messengers whose names were Mr. J, Miss C, Mr. E, Mr. A...
{"inputs": ["5\nAJMP\naB23d\nE\n86AE\nAM\n6\nJPEM\nWaEaETC302Q\nCP\nrTurnAGundam1isdefferentf", "5\nAJMP\naB33d\nE\n86AE\nAM\n6\nJPEM\nWaEaETC302Q\nCP\nrTurnAGundam1isdefferentf", "5\nAJMP\naB33d\nE\n86AE\nAM\n6\nEPJM\nWaEaETC302Q\nCP\nrTurnAGundam1isdefferentf", "5\nAJMP\naB33d\nE\n86AE\nAM\n0\nEPJM\nWaEaETC302Q\nCP\n...
0
[ "PYTHON3" ]
6
2
code_contests
Okay, let's see. I need to solve this programming problem where each messenger applies a certain transformation to the message, but in reverse order to find the original. Because the given message is the one after all transformations, we have to reverse each step to get back to the original. First, the problem says th...
To solve this problem, we need to reverse a series of transformations applied by messengers to a message in order to retrieve the original message. Each messenger applies a specific transformation, and we need to reverse these transformations in the correct order to get back the original message. ### Approach 1. **Und...
true
3b1299f62cb9ba12e49dbac56fb69a56
p01083 RedBlue
Story At UZIA High School in the sky city AIZU, the club activities of competitive programming are very active. N Red Coders and n Blue Coders belong to this club. One day, during club activities, Red Coder and Blue Coder formed a pair, and from this club activity, n groups participated in a contest called KCP. At th...
{"inputs": ["2\n3 3 2\n8 3 2\n3 0\n3 7\n8 0\n8 7", "2\n3 3 2\n8 3 2\n0 3\n3 7\n8 0\n8 7", "1\n10 10 10\n31 10 10\n15 19\n26 1", "2\n3 3 2\n8 3 2\n0 0\n0 5\n11 0\n11 5", "2\n3 3 2\n8 3 2\n3 0\n3 7\n8 0\n5 7", "2\n3 3 2\n8 3 2\n1 3\n3 7\n8 0\n8 7", "1\n10 10 17\n31 10 10\n15 19\n26 1", "2\n3 3 2\n1 3 2\n0 0\n0 5\n11 0\n1...
0
[ "PYTHON3" ]
6
2
code_contests
Okay, so I need to solve this programming problem. Let's read the problem statement carefully. The problem is about moving red and blue dots such that each pair (one red and one blue) moves to two common destinations. The movement must be in straight lines, and they can't pass through the inside of either circle. The ...
To solve this problem, we need to determine the minimum total distance that red and blue points must travel to form pairs such that their paths do not pass through the interiors of two given circles. If it's impossible to form such pairs, we should output "Impossible". ### Approach 1. **Input Reading**: Read the numbe...
true
f10ada8d894b50fa20c06656ea88e62e
p01219 Private Teacher
You are working as a private teacher. Since you are giving lessons to many pupils, you are very busy, especially during examination seasons. This season is no exception in that regard. You know days of the week convenient for each pupil, and also know how many lessons you have to give to him or her. You can give just ...
{"inputs": ["2 2\n6 3\nMonday Tuesday Wednesday\n8 4\nThursday Friday Saturday Sunday\n2 2\n7 3\nMonday Tuesday Wednesday\n9 4\nThursday Friday Saturday Sunday\n0 0", "2 2\n6 3\nMonday Tuesday Wednesday\n8 4\nThursday Friday Saturday Sunday\n2 2\n7 3\nMonday Tuesday Wednesday\n9 4\nTsurhday Friday Saturday Sunday\n0 0"...
0
[ "PYTHON3" ]
6
2
code_contests
Okay, let's see. So the problem is about scheduling lessons for multiple pupils within a certain number of weeks. Each pupil has specific days of the week they can attend, and each lesson can only be given to one pupil per day. The goal is to determine if all required lessons can be completed within the given weeks. H...
To solve this problem, we need to determine if all required lessons for each pupil can be scheduled within the given number of weeks, considering each pupil's available days of the week. The solution involves checking multiple conditions to ensure that the total lessons required can be accommodated without conflicts. ...
false
Code is incorrect.
1211d0774965e9c47a46bb683e815b6c
p01353 Rabbit Plays Games!
A rabbit is playing a role-playing game. Just before entering the castle, he was ambushed by an enemy! It was a battle between one hero operated by a rabbit and n enemies. Each character has four stats, health hi, attack power ai, defense power di, and agility si. I = 0 is the information of the main character, 1 ≤ i ...
{"inputs": ["1\n1 1 1 1\n10000 10000 10000 10000", "2\n10 3 1 2\n2 4 1 3\n2 2 1 1", "1\n1 0 1 1\n10000 10000 10000 10000", "2\n10 3 1 2\n2 4 1 3\n1 2 1 1", "2\n10 3 1 2\n2 4 1 3\n1 3 1 1", "2\n10 3 1 2\n3 4 1 3\n1 3 1 1", "2\n10 3 2 2\n3 4 1 3\n1 3 1 1", "1\n1 0 1 1\n10000 10010 10000 10000", "1\n1 0 1 1\n10000 10010 1...
0
[ "PYTHON3" ]
6
2
code_contests
Okay, I need to solve this programming problem. Let's read the problem carefully. So, the problem is about a battle between the hero (controlled by the rabbit) and multiple enemies. Each character has health, attack, defense, and agility. The battle proceeds in turns. Each turn, all surviving characters attack in orde...
To solve this problem, we need to determine the minimal total damage the hero takes during a battle against multiple enemies, considering their attack order based on agility. If the hero cannot survive, we return -1. ### Approach 1. **Input Parsing and Initial Checks**: Read the hero's and enemies' stats. Check if the...
false
Code is incorrect.
332b361e243e08443ab4f698c8b8c9cc
p01535 Markup language has Declined
E: Markup language has declined It's been centuries since we humans have been declining slowly. The earth may already belong to "Progurama". Programa-sans with an average height of 170 cm, 7 heads, high intelligence, and loves Kodingu. I have returned to my hometown of Nibunki, becoming an important international civi...
{"inputs": ["1\nindex.dml\n<dml><title>Markup language has Declined</title><br>Programmers world</dml>\n1\n15 3 0 index", "1\nindex.dml\n<dml><title>Markup aangulge has Declined</title><br>Programmers world</dml>\n1\n15 3 0 index", "1\nindex.dml\n<dml><title>Markup aangulge sah Declined</title><br>Programmers world</dm...
0
[ "PYTHON3" ]
6
2
code_contests
Okay, I need to solve this programming problem. Let me read through the problem statement carefully. The problem involves parsing DML files and handling user interactions with clicks that might trigger link or button actions, which in turn could modify the displayed content based on DS script files. The output is the...
To solve this problem, we need to simulate the rendering of DML files and handle user interactions with links and buttons, which can modify the displayed content based on scripts defined in DS files. The solution involves parsing DML and DS files, managing visibility of elements, and rendering the final screen after us...
false
Code is incorrect.
1cf42c6564f4a12995bf38481040b4a1
p01691 Disappear Drive
E --Disappear Drive Story The person in D likes basketball, but he likes shooting, so other techniques are crazy. I'm not particularly good at dribbling, and when I enter the opponent's defensive range, I always get the ball stolen. So I decided to come up with a deadly dribble that would surely pull out any opponent...
{"inputs": ["1 0\n25 47 10", "1 0\n25 47 15", "1 0\n16 47 15", "1 0\n31 47 15", "2 0\n31 47 13", "2 0\n31 47 20", "2 0\n31 47 33", "1 0\n25 38 10", "1 0\n25 61 15", "1 0\n16 57 15", "1 0\n31 18 15", "2 0\n31 47 11", "2 0\n1 47 20", "1 0\n25 58 10", "2 0\n31 49 11", "1 0\n25 47 4", "1 0\n14 47 15", "1 0\n31 66 15", "1 0...
0
[ "PYTHON3" ]
6
2
code_contests
Okay, I need to solve this problem. Let's read the problem carefully. The problem is about finding the shortest path from point S (25,0) to point G (25,94) on a 2D plane, avoiding circles in such a way that the number of circles the path enters is at most D. Wait, no— the path can pass through circles, but each time i...
To solve this problem, we need to find the shortest path from point S (25, 0) to point G (25, 94) on a 2D plane, avoiding circles such that the number of times the path enters any circle is within a given limit D. The solution involves checking both the straight line path and possible detours around the circles. ### A...
false
Code is incorrect.
bf1aaff0df3a6cc19bf92a0cb3721d99
p01970 The Diversity of Prime Factorization
D: The Diversity of Prime Factorization Problem Ebi-chan has the FACTORIZATION MACHINE, which can factorize natural numbers M (greater than 1) in O ($ \ log $ M) time! But unfortunately, the machine could display only digits and white spaces. In general, we consider the factorization of M as p_1 ^ {e_1} \ times p_2 ...
{"inputs": ["3\n2 3 3", "3\n2 3 6", "3\n2 3 11", "3\n3 2 3", "3\n2 5 3", "3\n2 2 3", "3\n2 2 11", "3\n3 2 6", "3\n2 2 13", "3\n4 2 6", "3\n2 2 0", "3\n4 2 2", "3\n3 2 0", "3\n2 2 2", "3\n2 3 2", "3\n2 1 2", "3\n2 1 0", "3\n2 2 1", "3\n4 2 1", "3\n4 3 3", "3\n3 2 4", "3\n2 3 17", "3\n4 2 4", "3\n2 1 1", "3\n2 2 15", "3\...
0
[ "PYTHON3" ]
6
2
code_contests
Okay, I need to solve this problem where given a sequence of numbers that represent the output of the factorization machine, I have to determine how many possible natural numbers M could have produced that output. The answer should be modulo 1e9+7. First, let's understand the problem. The machine's output is a sequenc...
To solve this problem, we need to determine how many natural numbers could have produced a given output from a factorization machine. The output is a sequence of numbers representing prime factors and their exponents. The challenge is to reverse-engineer the possible input numbers (M) that would generate the given outp...
true
7d8caa1b1a6fb51eec3987d9dda082f8
p02117 Picnic
Problem Tomorrow is finally the day of the excursion to Maizu Elementary School. Gatcho, who attends Maizu Elementary School, noticed that he had forgotten to buy tomorrow's sweets because he was so excited. Gaccho wants to stick to sweets so that he can enjoy the excursion to the fullest. Gaccho gets a $ X $ yen al...
{"inputs": ["3 10 10\n1\n1 1 1\n1\n3 3 3\n1\n5 5 5\n0 1 0\n1 0 0\n0 1 0", "4 59 40\n1\n7 6 3\n1\n10 3 9\n2\n9 8 5\n7 6 10\n4\n8 2 9\n1 7 1\n7 7 9\n1 2 3\n0 28 7 26\n14 0 10 24\n9 6 0 21\n9 24 14 0", "1 10 10\n3\n1 10 1\n2 20 2\n3 30 3\n0", "2 10 10\n3\n1 10 1\n2 20 2\n3 30 3\n1\n5 200 1\n0 2\n3 0", "3 10 10\n1\n1 1 1\n...
0
[ "PYTHON3" ]
6
2
code_contests
Okay, let's try to figure out this problem. So, the problem is about Gaccho buying sweets from various towns while managing his budget and the constraints on the total cost of sweets and the moving expenses. The goal is to maximize his satisfaction. Hmm, let's break it down. First, the constraints. The number of towns...
To solve this problem, we need to maximize the satisfaction Gaccho can get from buying sweets within the constraints of his allowance and the maximum allowed price for sweets. The solution involves dynamic programming (DP) and a knapsack approach to efficiently compute the best possible purchases in each town. ### App...
false
Code is incorrect.
791a50b9985599f9f24ebc72ef0586c9
p02257 Prime Numbers
A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7. Write a program which reads a list of N integers and prints the number of prime numbers in the list. Constraints 1 ≤ N ≤ 10000 2 ≤ an element of the ...
{"inputs": ["5\n2\n3\n4\n5\n6", "11\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17", "11\n7\n8\n9\n10\n11\n12\n13\n14\n27\n16\n17", "11\n7\n8\n9\n10\n11\n22\n13\n2\n27\n8\n17", "5\n2\n4\n7\n5\n6", "11\n7\n8\n9\n26\n15\n22\n2\n14\n27\n8\n27", "11\n14\n8\n9\n26\n15\n22\n2\n14\n27\n8\n27", "11\n7\n10\n9\n10\n11\n13\n17\n3\n15\n...
0
[ "PYTHON3" ]
6
2
code_contests
Okay, I need to solve this problem where I have to count the number of primes in a list of integers. Let's think about how to approach this. First, the input: the first line is N, then N numbers follow. So I have to read N, then read N numbers. Then for each number, check if it's a prime, and count how many primes the...
To solve this problem, we need to determine the number of prime numbers in a given list of integers. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. The challenge is to efficiently check the primality of each number in the list, especially considering the constra...
true
cd5d4808267e19e1a9cfb988814a0ba4
p02405 Print a Chessboard
Draw a chessboard which has a height of H cm and a width of W cm. For example, the following figure shows a chessboard which has a height of 6 cm and a width of 10 cm. .#.#.#.#. .#.#.#.#.# .#.#.#.#. .#.#.#.#.# .#.#.#.#. .#.#.#.#.# Note that the top left corner should be drawn by '#'. Constraints * 1 ≤ H ≤ 300 * 1...
{"inputs": ["3 4\n5 6\n3 3\n2 2\n1 1\n0 0", "3 4\n5 6\n3 3\n2 2\n1 0\n0 0", "3 7\n5 6\n3 3\n2 2\n1 0\n0 0", "3 7\n5 6\n3 0\n2 2\n1 0\n0 0", "6 7\n5 6\n3 0\n2 2\n1 0\n0 0", "6 11\n5 6\n3 0\n2 2\n1 0\n0 0", "3 4\n5 6\n2 3\n2 2\n1 1\n0 0", "3 4\n5 6\n3 3\n2 4\n1 0\n0 0", "3 7\n5 6\n4 3\n2 2\n1 0\n0 0", "3 7\n5 5\n3 0\n2 2...
0
[ "PYTHON3" ]
6
2
code_contests
Okay, let's see. I need to create a Python function that reads H and W from stdin and prints a chessboard pattern. The top left is a '#', and then alternates. The example shows that for H=6 and W=10, each row starts with alternating # and ., but each subsequent row starts with the opposite. Oh right, like a chessboard ...
To solve this problem, we need to generate a chessboard pattern based on given dimensions (height H and width W). The chessboard alternates between '#' and '.' starting with a '#' at the top-left corner. The solution should read multiple datasets until it encounters a line with two zeros, and it should print each chess...
true
1119d9e9f752278a12d77ccc1cd016bc
anuwta
There are N+1 lights. Lights are placed at (0, 0), (1, 0), (2, 0) ... (N, 0). Initially all the lights are on. You want to turn off all of them one after one. You want to follow a special pattern in turning off the lights. You will start at (0, 0). First, you walk to the right most light that is on, turn it off. Th...
{"inputs": ["2\n1\n2", "2\n1\n4", "2\n2\n4", "2\n2\n1", "2\n0\n1", "2\n0\n2", "2\n2\n2", "2\n4\n2", "2\n2\n3", "2\n3\n2", "2\n0\n0", "2\n-1\n0", "2\n-1\n-1", "2\n-3\n-1", "2\n-3\n-6", "2\n-4\n0", "2\n-1\n2", "2\n-1\n1", "2\n1\n1", "2\n2\n0", "2\n4\n0", "2\n4\n1", "2\n3\n1", "2\n-1\n3", "2\n-13\n1", "2\n-13\n2", "2\n-15...
2
[ "PYTHON3" ]
1
2
code_contests
Okay, let's see. So the problem is about calculating the total distance walked when turning off N+1 lights arranged in a line. The initial position is (0,0), and all lights are on. We have to alternate between turning off the rightmost and leftmost on lights until all are off. The total distance walked during this proc...
To solve this problem, we need to calculate the total distance walked when turning off N+1 lights arranged in a line. The process involves alternating between turning off the rightmost and leftmost on lights until all are off. The goal is to determine the total distance walked during this process efficiently. ### Appr...
true
91761061defa25721647de3baf70cd05
chsparr
Chef has a an array A consisting of N elements. He wants to add some elements into the array as per the below mentioned process. After each minute, Chef iterates over the array in order from left to right, and takes every two neighbouring pair of elements, say x and y, he adds a new element x + y in the middle of eleme...
{"inputs": ["2\n3 1 1 5\n1 6 9\n3 2 6 7\n1 6 9"], "outputs": ["38\n36"]}
3
[ "PYTHON3" ]
1
2
code_contests
Okay, let's tackle this problem. Hmm, the problem says that Chef adds elements between neighboring pairs every minute. And after m minutes, we need to find the sum between positions x and y. Oh right, the elements are inserted between each pair each minute, but this happens for the entire array in each step. Wait, the...
To solve this problem, we need to compute the sum of elements between positions x and y in an array after m minutes of element insertion. Each minute, Chef inserts new elements between every pair of adjacent elements, which are the sum of the pair. The challenge is to efficiently compute this sum without explicitly con...
false
Code is incorrect.
3e9bd6deebe3508005ffd64d831d425c
etmx05
Middle Strings Miss Roma has got a new job in a computer agency. To test her skills the manager has appointed her with a small project. She will get a string of any length but of ODD length and what she has to do is finding a center string of length 3 in the original string. For Example: She gets a string 'CANDY' the...
{"inputs": ["CANDY", "SOLVING"], "outputs": ["AND", "LVI"]}
6
[ "PYTHON3" ]
1
2
code_contests
Okay, let's see. The problem is to find the middle three characters of a given string. But wait, the string has to be of odd length, right? Oh right, the input is guaranteed to be an odd length string. Wait, no, the first line of input says it's a string of ODD length. So the input is always valid. So we don't have to ...
To solve this problem, we need to determine the middle three characters of a given string of odd length. If the string's length is less than 3, we should output 0. The solution involves checking the string length and extracting the appropriate substring based on the calculated middle index. ### Approach 1. **Read Inpu...
true