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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
87f45615ea3832b39e3e4fb9c33c420c | Vitaly and Cycle | After Vitaly was expelled from the university, he became interested in the graph theory.
Vitaly especially liked the cycles of an odd length in which each vertex occurs at most once.
Vitaly was wondering how to solve the following problem. You are given an undirected graph consisting of *n* vertices and *m* edges, no... | {"inputs": ["4 4\n1 2\n1 3\n4 2\n4 3", "3 3\n1 2\n2 3\n3 1", "3 0", "6 3\n1 2\n4 3\n6 5", "100000 0", "5 4\n1 2\n1 3\n1 4\n1 5", "6 3\n1 2\n2 3\n4 5", "5 5\n1 2\n2 3\n3 4\n4 5\n5 1", "59139 0", "9859 0", "25987 0", "9411 0", "25539 0", "59139 1\n10301 5892", "9859 1\n1721 9478", "76259 0", "92387 0", "6 4\n1 2\n2 3\n3 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 4 | codeforces | Okay, I need to solve this problem where I have to find the minimum number of edges to add to a graph so that there's an odd-length simple cycle, and also count the number of ways to do that. Hmm, let's think about this.
First, I remember that a simple cycle of odd length requires that the number of nodes in the cycle... | To solve this problem, we need to determine the minimum number of edges to add to a graph to form an odd-length cycle and count the number of ways to achieve this. The solution involves checking the graph's structure and bipartiteness to determine the optimal edges to add.
### Approach
1. **Check for Existing Odd Cycl... | false | Code is incorrect. | |
87fa1fe92bd779cf0b2298740f0f708c | IQ test | Bob is preparing to pass IQ test. The most frequent task in this test is to find out which one of the given *n* numbers differs from the others. Bob observed that one number usually differs from the others in evenness. Help Bob — to check his answers, he needs a program that among the given *n* numbers finds one that i... | {"inputs": ["5\n2 4 7 8 10", "4\n1 2 1 1", "3\n1 2 2", "3\n100 99 100", "3\n5 3 2", "4\n43 28 1 91", "4\n75 13 94 77", "4\n97 8 27 3", "10\n95 51 12 91 85 3 1 31 25 7", "20\n88 96 66 51 14 88 2 92 18 72 18 88 20 30 4 82 90 100 24 46", "30\n20 94 56 50 10 98 52 32 14 22 24 60 4 8 98 46 34 68 82 82 98 90 50 20 78 49 52 9... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 3,134 | codeforces | Okay, I need to solve this problem where I have to find the number that differs in evenness from the others. Let's see the examples to understand better.
In the first sample input, the numbers are 2,4,7,8,10. Most are even except 7. So the answer is the third position, which is index 3 (since counting starts from 1). ... | To solve this problem, we need to identify the number in a list that differs from the others in terms of evenness. The problem guarantees that exactly one number will be different in this way, and we need to determine its position (1-based index).
### Approach
1. **Input Reading**: Read the number of elements and the ... | true | ||
87fbfafa354e50b7c4f052a6f1671e69 | Kostya the Sculptor | Kostya is a genial sculptor, he has an idea: to carve a marble sculpture in the shape of a sphere. Kostya has a friend Zahar who works at a career. Zahar knows about Kostya's idea and wants to present him a rectangular parallelepiped of marble from which he can carve the sphere.
Zahar has *n* stones which are rectang... | {"inputs": ["6\n5 5 5\n3 2 4\n1 4 1\n2 1 3\n3 2 4\n3 3 4", "7\n10 7 8\n5 10 3\n4 2 6\n5 5 5\n10 2 8\n4 2 1\n7 7 7", "1\n1 1 1", "2\n2 3 1\n2 2 3", "1\n1000000000 1000000000 1000000000", "3\n100 100 100\n25 63 11\n63 15 11", "2\n999999999 1000000000 1000000000\n1000000000 1000000000 1000000000", "3\n1 1 2\n1 2 2\n1 1 1"... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 23 | codeforces | Okay, I need to solve this programming problem. Let's read the problem statement carefully.
The problem is about selecting up to two stones (rectangular parallelepipeds) such that when glued together (if two are chosen), they form a new rectangular block. The goal is to maximize the minimum edge of the resulting block... | To solve this problem, we need to determine the optimal way for Zahar to select up to two stones such that Kostya can carve the largest possible sphere from the resulting rectangular parallelepiped. The sphere's diameter is determined by the smallest edge of the block, so our goal is to maximize this minimum edge.
###... | false | Code is incorrect. | |
880524f2cab75c03474a3bd4b45b4390 | Months and Years | Everybody in Russia uses Gregorian calendar. In this calendar there are 31 days in January, 28 or 29 days in February (depending on whether the year is leap or not), 31 days in March, 30 days in April, 31 days in May, 30 in June, 31 in July, 31 in August, 30 in September, 31 in October, 30 in November, 31 in December.
... | {"inputs": ["4\n31 31 30 31", "2\n30 30", "5\n29 31 30 31 30", "3\n31 28 30", "3\n31 31 28", "24\n29 28 31 30 31 30 31 31 30 31 30 31 31 29 31 30 31 30 31 31 30 31 30 31", "4\n31 29 31 30", "24\n31 28 31 30 31 30 31 31 30 31 30 31 31 29 31 30 31 30 31 31 30 31 30 31", "8\n31 29 31 30 31 30 31 31", "1\n29", "8\n31 29 31... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 94 | codeforces | Okay, let's see. I need to write a Python function that determines if a given sequence of days for consecutive months matches the Gregorian calendar rules. The input is a list of n numbers (each between 28 and 31), and I need to check if there's any possible consecutive months in the Gregorian calendar that have exactl... | To solve this problem, we need to determine if a given sequence of integers can represent the number of days in consecutive months according to the Gregorian calendar. The solution involves checking each possible starting month and verifying if the sequence can be valid under the calendar rules, including leap years.
... | false | Code is incorrect. | |
88133b86e2c023a0f6539769a94a9b40 | Nastya and an Array | Nastya owns too many arrays now, so she wants to delete the least important of them. However, she discovered that this array is magic! Nastya now knows that the array has the following properties:
- In one second we can add an arbitrary (possibly negative) integer to all elements of the array that are not equal to ze... | {"inputs": ["5\n1 1 1 1 1", "3\n2 0 -1", "4\n5 -6 -5 1", "1\n0", "2\n21794 -79194", "3\n-63526 95085 -5239", "3\n0 53372 -20572", "13\n-2075 -32242 27034 -37618 -96962 82203 64846 48249 -71761 28908 -21222 -61370 46899", "5\n806 0 1308 1954 683", "8\n-26 0 -249 -289 -126 -206 288 -11", "10\n2 2 2 1 2 -1 0 2 -1 1", "1\n... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 398 | codeforces | Okay, let's try to figure out this problem. So, the task is to find the minimum number of seconds needed to make all elements of an array zero. The operation allowed is each second, add any integer (positive or negative) to all elements that are not zero. Once an element becomes zero, it's fixed and can't be changed ag... | To solve this problem, we need to determine the minimum number of seconds required to make all elements of an array zero using the allowed operation of adding an arbitrary integer to all non-zero elements each second. The key insight is to group elements based on their required adjustments to reach zero efficiently.
#... | true | ||
881a96925d078b4a047e5ae1de94811c | Tennis Tournament | A tennis tournament with *n* participants is running. The participants are playing by an olympic system, so the winners move on and the losers drop out.
The tournament takes place in the following way (below, *m* is the number of the participants of the current round):
- let *k* be the maximal power of the number 2 ... | {"inputs": ["5 2 3", "8 2 4", "10 1 500", "20 500 1", "100 123 99", "500 1 1", "500 500 500", "500 237 474", "1 2 3", "1 2 133", "1 2 100", "1 3 4", "1 10 15", "1 1 1", "1 2 5", "1 500 500", "1 3 8", "10 10 10", "1 3 5", "1 2 1", "1 2 4", "1 10 10", "1 345 345", "7 12 13", "1 500 1", "1 12 13", "1 500 499", "1 100 90",... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 206 | codeforces | Okay, let's try to figure out how to solve this problem. The task is to calculate the number of water bottles and towels needed for a tennis tournament based on the given rules.
First, let's understand the problem step by step.
The tournament is conducted in rounds where in each round, participants compete in match... | To solve this problem, we need to determine the number of water bottles and towels required for a tennis tournament structured in a specific elimination format. The key insight is recognizing that each match eliminates exactly one player, leading to a total of \( n-1 \) matches for \( n \) participants. Each match requ... | true | ||
884ce38c4e05ce1b7792e50f06613eae | Burning Midnight Oil | One day a highly important task was commissioned to Vasya — writing a program in a night. The program consists of *n* lines of code. Vasya is already exhausted, so he works like that: first he writes *v* lines of code, drinks a cup of tea, then he writes as much as lines, drinks another cup of tea, then he writes lin... | {"inputs": ["7 2", "59 9", "1 9", "11 2", "747 2", "6578 2", "37212 2", "12357 2", "7998332 2", "86275251 2", "75584551 2", "6 3", "43 4", "811 3", "3410 4", "21341 4", "696485 4", "8856748 3", "2959379 4", "831410263 3", "2 5", "19 6", "715 7", "9122 5", "89117 6", "689973 7", "3024524 5", "67127156 6", "412262167 7",... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 171 | codeforces | Okay, let's see. I need to find the minimum value of v such that when Vasya writes code in the pattern v, floor(v/k), floor(v/k²), etc., the sum of all those lines is at least n. And he stops when the term becomes zero. Hmm.
Wait, the problem says that each time he drinks tea, then writes the next set of lines. So the... | To solve this problem, we need to determine the minimum value of `v` such that Vasya can write at least `n` lines of code before falling asleep. The key challenge is to efficiently compute the sum of lines Vasya writes each time, considering his decreasing productivity after each cup of tea.
### Approach
1. **Problem ... | true | ||
884fb11aa9749ce2a54ec963e9036754 | Find a car | After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help.
Form... | {"inputs": ["4\n1 1 1 1 1\n3 2 5 4 5\n1 1 5 5 10000\n1 4 2 5 2", "10\n3 7 4 10 7\n6 1 7 10 18\n9 6 10 8 3\n1 8 3 10 3\n10 4 10 5 19\n8 9 9 10 10\n10 1 10 5 4\n8 1 9 4 18\n6 3 9 5 1\n6 6 9 6 16", "10\n1 1 2 2 8\n3 4 5 9 4\n2 10 5 10 6\n8 5 10 8 8\n1 2 8 2 20\n8 6 10 8 20\n6 7 6 7 9\n8 5 10 10 13\n1 8 10 9 13\n9 8 10 9 3... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | Okay, let's tackle this problem. Hmm, the problem is about finding the sum of certain car numbers in a matrix based on queries. The car numbers are determined by a specific rule. Let's try to understand the car number generation first.
The car at position (x, y) has the minimum positive integer not present in the same... | To solve this problem, we need to efficiently compute the sum of car numbers in a specific submatrix defined by multiple queries. Each car number is determined by a unique rule based on its position, and we need to handle large input sizes efficiently.
### Approach
1. **Understanding Car Numbers**: The car number at p... | false | Code is incorrect. | |
88707b4cec2285331afee820a59c2935 | Tennis Championship | Famous Brazil city Rio de Janeiro holds a tennis tournament and Ostap Bender doesn't want to miss this event. There will be *n* players participating, and the tournament will follow knockout rules from the very first game. That means, that if someone loses a game he leaves the tournament immediately.
Organizers are st... | {"inputs": ["2", "3", "4", "10", "1000", "2500", "690000", "3000000000", "123456789123456789", "5", "143", "144", "145", "232", "233", "234", "679891637638612257", "679891637638612258", "679891637638612259", "1000000000000000000", "10235439547", "1240723548", "92353046212453", "192403205846532", "13925230525389", "1204... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 107 | codeforces | Okay, let's try to solve this problem. The task is to find the maximum number of games the winner can play in a knockout tournament where the rule is that two players can only play if the number of games they've already played differs by at most one. Hmm, right.
So, the tournament is a knockout, so each loss eliminate... | To solve this problem, we need to determine the maximum number of games the winner of a knockout tennis tournament can play, given that two players can only compete if the number of games they have already played differs by at most one. The solution involves using the Fibonacci sequence to model the minimum number of p... | true | ||
887f5c0fe1611ba2eb173a645088bda2 | Vladik and cards | Vladik was bored on his way home and decided to play the following game. He took *n* cards and put them in a row in front of himself. Every card has a positive integer number not exceeding 8 written on it. He decided to find the longest subsequence of cards which satisfies the following conditions:
- the number of oc... | {"inputs": ["3\n1 1 1", "8\n8 7 6 5 4 3 2 1", "24\n1 8 1 2 8 2 3 8 3 4 8 4 5 8 5 6 8 6 7 8 7 8 8 8", "1\n8", "2\n5 4", "3\n3 3 2", "18\n3 6 6 8 8 1 1 4 4 3 3 5 5 7 7 2 2 3", "5\n2 6 1 2 6", "6\n4 3 1 6 7 4", "7\n8 8 2 6 1 8 5", "8\n2 8 4 7 5 3 6 1", "8\n8 6 3 6 7 5 5 3", "15\n5 2 2 7 5 2 6 4 3 8 1 8 4 2 7", "15\n8 8 1 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | Okay, let's see. The problem is to find the longest subsequence of cards that meets two conditions. Hmm. Let's break down the requirements.
First condition: the count of each number from 1 to 8 in the subsequence can differ by at most 1. So for example, if one number appears 3 times, all others must be 3 or 2. And sin... | To solve this problem, we need to find the longest subsequence of cards that meets two specific conditions. The first condition requires that the counts of each number in the subsequence differ by at most 1. The second condition mandates that all occurrences of a number in the subsequence form a continuous segment.
#... | false | Code is incorrect. | |
88833c580e1089eeff007f19c143dece | Pencils and Boxes | Mishka received a gift of multicolored pencils for his birthday! Unfortunately he lives in a monochrome world, where everything is of the same color and only saturation differs. This pack can be represented as a sequence *a*1,<=*a*2,<=...,<=*a**n* of *n* integer numbers — saturation of the color of each pencil. Now Mis... | {"inputs": ["6 3 10\n7 2 7 7 4 2", "6 2 3\n4 5 3 13 4 10", "3 2 5\n10 16 22", "8 7 13\n52 85 14 52 92 33 80 85", "6 4 0\n1 3 2 4 2 1", "10 4 9\n47 53 33 48 35 51 18 47 33 11", "3 2 76\n44 5 93", "5 2 9\n3 8 9 14 20", "8 2 3\n1 2 3 4 10 11 12 13", "10 3 3\n1 1 2 4 5 6 9 10 11 12", "7 3 3\n1 1 3 4 4 4 7", "8 3 6\n1 2 3 3... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 10 | codeforces | Okay, let's try to solve this problem. Hmm, the problem says that Mishka has to distribute pencils into boxes such that each box has at least k pencils, and any two pencils in the same box can't differ by more than d. Also, every pencil must be in exactly one box. We need to check if this is possible.
First, let's und... | To solve this problem, we need to determine if Mishka can distribute all his pencils into boxes such that each box meets the following conditions:
1. Each box contains at least `k` pencils.
2. The absolute difference in saturation between any two pencils in the same box does not exceed `d`.
### Approach
1. **Sort the ... | true | ||
888e5c0f86ce38c7eb6f2a5f40de8280 | Sereja and Swaps | As usual, Sereja has array *a*, its elements are integers: *a*[1],<=*a*[2],<=...,<=*a*[*n*]. Let's introduce notation:
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 max... | {"inputs": ["10 2\n10 -1 2 2 2 2 2 2 -1 10", "5 10\n-1 -1 -1 -1 -1", "18 1\n166 788 276 -103 -491 195 -960 389 376 369 630 285 3 575 315 -987 820 466", "29 6\n-21 486 -630 -433 -123 -387 618 110 -203 55 -123 524 -168 662 432 378 -155 -136 -162 811 457 -157 -215 861 -565 -506 557 348 -7", "9 9\n-767 148 -323 -818 41 -22... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 19 | codeforces | Okay, I need to solve this programming problem. Let me read the problem statement carefully.
The problem is about finding the maximum possible value of the function m(a) after performing at most k swaps. The array a is initially sorted in non-decreasing order. The function m(a) is defined as the sum of the absolute di... | To solve this problem, we need to maximize the sum of absolute differences between consecutive elements of an array after performing at most `k` swaps. Each swap allows exchanging any two elements in the array. The goal is to determine the optimal swaps that yield the highest possible sum.
### Approach
The approach in... | false | Code is incorrect. | |
8890a94989620c9df947b82ca957f018 | Perfect Squares | Given an array *a*1,<=*a*2,<=...,<=*a**n* of *n* integers, find the largest number in the array that is not a perfect square.
A number *x* is said to be a perfect square if there exists an integer *y* such that *x*<==<=*y*2.
The first line contains a single integer *n* (1<=≤<=*n*<=≤<=1000) — the number of elements in ... | {"inputs": ["2\n4 2", "8\n1 2 4 8 16 32 64 576", "3\n-1 -4 -9", "5\n918375 169764 598796 76602 538757", "5\n804610 765625 2916 381050 93025", "5\n984065 842724 127449 525625 573049", "2\n226505 477482", "2\n370881 659345", "2\n4 5", "2\n3 4", "2\n999999 1000000", "3\n-1 -2 -3", "2\n-1000000 1000000", "2\n-1 0", "1\n2",... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 90 | codeforces | Okay, let's see. I need to write a Python function that reads an array of integers and finds the largest one that's not a perfect square. Hmm. The input is from stdin, and the output is just the number. Oh right, the array is sorted in non-decreasing order. Wait, the problem statement says a1 ≤ a2 ≤ ... ≤ an. Oh right,... | To solve this problem, we need to find the largest number in a sorted array that is not a perfect square. The array is guaranteed to be non-decreasing, and we must ensure that at least one element is not a perfect square.
### Approach
1. **Understanding the Problem**: The array is sorted in non-decreasing order, so th... | false | Code is incorrect. | |
8891a9d7e5544bb50fc3a3842c39a9cf | Zero-One | Little Petya very much likes playing with little Masha. Recently he has received a game called "Zero-One" as a gift from his mother. Petya immediately offered Masha to play the game with him.
Before the very beginning of the game several cards are lain out on a table in one line from the left to the right. Each card c... | {"inputs": ["????", "1010", "1?1", "111?", "000?", "1??1?", "?111111?00?", "??????????0????????????????0000000000000", "1?1?1?1?0?10", "?0101", "??0101", "??1010", "00", "11", "1110110101111111001111111110111011100001110111011001011111111111011010011111?111111?011111110001010110011111010111100111?111101010011101010?011... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 2 | codeforces | Okay, let's see. The problem is about a game between Masha and Petya where they take turns removing cards until two are left. The initial cards have some digits (0, 1) and some are unknown (marked as '?'). For each possible substitution of the '?', we need to determine the final two cards after optimal play by both pla... | To solve this problem, we need to determine all possible outcomes of a game played between Masha and Petya, given an initial sequence of cards that may contain blurred digits (denoted by '?'). The goal is to find all possible pairs of digits that can remain after optimal play by both players, considering all possible s... | false | Code is incorrect. | |
889f498ec3484cf118ca64ffd0df42d2 | Balanced Substring | You are given a string *s* consisting only of characters 0 and 1. A substring [*l*,<=*r*] of *s* is a string *s**l**s**l*<=+<=1*s**l*<=+<=2... *s**r*, and its length equals to *r*<=-<=*l*<=+<=1. A substring is called balanced if the number of zeroes (0) equals to the number of ones in this substring.
You have to deter... | {"inputs": ["8\n11010111", "3\n111", "11\n00001000100", "10\n0100000000", "13\n0001000011010", "14\n00000100101011", "14\n01111101111111", "18\n110010101101111111", "11\n00010000011", "10\n1000010110", "15\n100000100000011", "18\n011010101110111101", "10\n0011011111", "3\n011", "14\n11111111111111", "65\n11001000110001... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 139 | codeforces | Okay, I need to solve this problem where I have to find the longest balanced substring in a binary string. A balanced substring has an equal number of 0s and 1s. Let's think about how to approach this.
First, let's understand what a balanced substring means. For any substring to be balanced, the count of 0s and 1s mus... | To solve this problem, we need to determine the length of the longest balanced substring in a binary string. A balanced substring is defined as a substring where the number of '0's equals the number of '1's.
### Approach
The key insight here is to use a prefix sum approach with a balance variable. The balance variabl... | true | ||
88a9414a5b52e94c5b877e3e07e40bc0 | Award Ceremony | All-Berland programming contest comes to an end. In total, *n* teams participated in it. Like in ACM-ICPC, current results stopped refreshing one hour before the contest ends. So at the Award Ceremony, results are partially known. For each team the value *a**i* is given — the number of points the *i*-th team has earned... | {"inputs": ["4\n17 -14\n52 -5\n1 52\n6 0", "5\n4 5\n3 2\n5 -3\n6 -2\n4 3", "3\n2 1\n1 -1\n1 2", "5\n4 1\n5 4\n3 5\n4 5\n5 2", "10\n3 3\n1 1\n1 2\n2 2\n3 4\n3 2\n4 3\n2 2\n2 2\n1 2", "20\n5 4\n1 5\n5 4\n4 5\n4 5\n1 1\n5 3\n3 3\n4 5\n1 4\n5 2\n4 2\n4 4\n5 1\n1 1\n5 3\n2 4\n2 4\n1 2\n2 3", "40\n5 4\n1 4\n5 1\n3 4\n1 4\n5 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | Okay, let's see. The problem is about finding the optimal order to unfreeze the teams such that the total applause duration is maximized. The applause for each team is the absolute difference between their place before and after unfreezing. So, the goal is to arrange the order of unfreezing to maximize the sum of these... | To solve this problem, we need to determine the optimal order to unfreeze the teams such that the total applause duration is maximized. The applause duration for each team is the absolute difference between their rank before and after unfreezing.
### Approach
The approach involves using dynamic programming with memoi... | true | ||
88c00f744c62257aff2d2df925559c97 | Blinds | The blinds are known to consist of opaque horizontal stripes that can be rotated thus regulating the amount of light flowing in the room. There are *n* blind stripes with the width of 1 in the factory warehouse for blind production. The problem is that all of them are spare details from different orders, that is, they ... | {"inputs": ["4 2\n1 2 3 4", "5 3\n5 5 7 3 1", "2 3\n1 2", "2 2\n3 3", "5 2\n2 4 1 1 3", "7 4\n3 2 1 1 1 3 2", "10 1\n1 2 2 6 6 1 2 5 5 6", "10 2\n6 3 1 1 6 4 6 1 6 3", "15 6\n1 6 6 5 2 10 4 4 7 8 7 3 5 1 2", "20 2\n13 3 6 11 6 11 9 1 1 2 5 2 9 15 14 10 3 12 3 13", "25 20\n10 8 4 6 12 14 19 18 19 9 21 16 16 15 10 15 12 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 34 | codeforces | Okay, so I need to solve this programming problem. Let's read the problem carefully and understand what's required.
The problem is about creating blinds from spare stripes. The goal is to find the maximum possible area of a window (a rectangle) that can be covered using these blinds. The constraints are that each blin... | To solve this problem, we need to determine the maximum possible area of a window that can be completely covered using blinds made from given stripes. The blinds must be constructed by cutting the stripes into parts of equal length, each part being at least a specified minimum length. The goal is to maximize the area o... | true | ||
88d941a8d49063c57c8e264ff7932a42 | Polycarp's Practice | Polycarp is practicing his problem solving skill. He has a list of $n$ problems with difficulties $a_1, a_2, \dots, a_n$, respectively. His plan is to practice for exactly $k$ days. Each day he has to solve at least one problem from his list. Polycarp solves the problems in the order they are given in his list, he cann... | {"inputs": ["8 3\n5 4 2 6 5 1 9 2", "5 1\n1 1 1 1 1", "4 2\n1 2000 2000 2", "1 1\n2000", "1 1\n1234", "3 2\n1 1 1", "4 2\n3 5 1 1", "5 3\n5 5 6 7 1", "6 4\n1 1 1 1 2 2", "5 3\n5 5 6 6 4", "16 15\n14 4 9 12 17 1 1 8 12 13 6 9 17 2 18 12", "1 1\n1996", "5 3\n5 5 5 9 10", "18 15\n18 2 13 1 18 3 2 18 18 20 9 2 20 20 4 20 9... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 86 | codeforces | Okay, so I need to solve this programming problem. Let's read the problem carefully.
The problem is about distributing n problems into exactly k days, where each day must have at least one problem. The order is fixed; you can't skip any. The profit for each day is the maximum difficulty of the problems solved that day... | To solve this problem, we need to distribute a list of problems into exactly k days such that the sum of the maximum difficulty of each day's problems is maximized. The solution must also provide the exact distribution of problems across the days.
### Approach
The problem can be efficiently solved using dynamic progra... | false | Code is incorrect. | |
88f39d68bb4b079df4d1512539367c6f | Practice | Little time is left before Berland annual football championship. Therefore the coach of team "Losewille Rangers" decided to resume the practice, that were indefinitely interrupted for uncertain reasons. Overall there are *n* players in "Losewille Rangers". Each player on the team has a number — a unique integer from 1 ... | {"inputs": ["2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "13", "15", "16", "18", "20", "100", "110", "120", "140", "157", "171", "199", "200", "213", "231", "240", "250", "253", "260", "270", "271", "277", "280", "290", "300", "700", "730", "766", "777", "800", "832", "855", "869", "888", "900", "914", "930", "9... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 4 | codeforces | Okay, let's see. We need to find the minimum number of practices such that every pair of players has been on different teams at least once. Hmm. So for each pair (a, b), there must be at least one practice where a and b are in different teams. The goal is to minimize the number of practices required.
First, let's thin... | To solve this problem, we need to schedule the minimum number of football practices such that each pair of players has played in different teams at least once. The solution leverages binary representations to ensure that all pairs are covered efficiently.
### Approach
1. **Determine the Minimum Number of Practices (m)... | false | Code is incorrect. | |
890dc69313bd417ff2d70cfa1ba21d98 | Analyzing Polyline | As Valeric and Valerko were watching one of the last Euro Championship games in a sports bar, they broke a mug. Of course, the guys paid for it but the barman said that he will let them watch football in his bar only if they help his son complete a programming task. The task goes like that.
Let's consider a set of fun... | {"inputs": ["1\n1 0", "3\n1 0\n0 2\n-1 1", "3\n-2 -4\n1 7\n-5 1", "10\n9 9\n-5 2\n-2 9\n0 6\n6 7\n-1 -10\n-8 6\n3 6\n-3 -9\n0 4", "10\n-4 -9\n5 9\n-4 -1\n6 -1\n-10 -10\n3 4\n3 5\n3 10\n9 7\n4 -7", "5\n3 3\n2 2\n2 -3\n-3 3\n-1 1", "4\n0 2\n-1 -2\n1 0\n-2 2", "10\n-1 2\n0 1\n-2 0\n1 1\n-1 -1\n-2 1\n-2 2\n2 -1\n0 -1\n-1 0... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 4 | codeforces | Okay, I need to solve this programming problem. Let's read the problem carefully.
The problem says that we have a set of functions, each of the form y = k_i x + b_i. The sum of these functions is another piecewise linear function. We need to find the number of angles in the sum's graph that are not equal to 180 degree... | To solve this problem, we need to determine the number of angles (not equal to 180 degrees) in the graph of the polyline formed by summing given linear functions. Each function contributes to the slope of the sum function at different intervals, leading to breakpoints where the slope changes. The goal is to count these... | false | Code is incorrect. | |
8916d23cafaf87358fda6c265d1c3240 | Maximum path | You are given a rectangular table 3<=×<=*n*. Each cell contains an integer. You can move from one cell to another if they share a side.
Find such path from the upper left cell to the bottom right cell of the table that doesn't visit any of the cells twice, and the sum of numbers written in the cells of this path is ma... | {"inputs": ["3\n1 1 1\n1 -1 1\n1 1 1", "5\n10 10 10 -1 -1\n-1 10 10 10 10\n-1 10 10 10 10", "15\n-87 -91 31 63 91 35 -14 51 20 20 -20 -94 -59 77 76\n11 81 22 -29 91 -26 -10 -12 46 10 100 88 14 64 41\n26 -31 99 -39 -30 30 28 74 -7 21 2 32 -60 -74 46", "20\n16 82 25 21 -60 9 29 -55 70 54 -50 10 -19 40 46 41 31 -66 1 85\n... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 3 | codeforces | Okay, let's tackle this problem. So, the task is to find the maximum sum path from the top-left corner to the bottom-right corner of a 3-row by n-column grid, without visiting any cell more than once. Hmm, the path can move to adjacent cells (sharing a side), and we can't step on the same cell twice. The grid has three... | To solve this problem, we need to find the maximum sum path from the upper-left cell to the bottom-right cell of a 3-row by n-column grid, where each cell can be visited only once. The path can move to adjacent cells (sharing a side) and must not revisit any cell.
### Approach
The problem can be efficiently solved usi... | false | Code is incorrect. | |
8945042f2c8d6960cb0d9cc6116dc3de | Skills | Lesha plays the recently published new version of the legendary game hacknet. In this version character skill mechanism was introduced. Now, each player character has exactly *n* skills. Each skill is represented by a non-negative integer *a**i* — the current skill level. All skills have the same maximum level *A*.
Al... | {"inputs": ["3 5 10 1 5\n1 3 1", "3 5 10 1 339\n1 3 1", "2 6 0 1 4\n5 1", "1 1000000000 1000 1000 1000000000000000\n0", "1 100 1 2 30\n1", "1 100 1 2 30\n71", "1 1000000000 1000 1000 1000000000000000\n1000000000", "5 5 10 20 50\n0 0 0 0 0", "5 5 10 20 50\n3 3 3 3 3", "4 5 3 7 15\n4 3 3 1", "3 6 4 6 8\n6 4 5"], "outputs... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 4 | codeforces | Okay, I need to solve this programming problem. Let's read the problem statement carefully.
So, Lesha's character has n skills. Each skill has a level a_i, which can be increased up to A. He has m currency units to spend, each unit can increase a skill by 1 if it's not already at A. The goal is to maximize the Force, ... | To solve this problem, we need to maximize the Force of Lesha's character by optimally spending hacknetian currency units to upgrade skills. The Force is calculated as the sum of the number of perfected skills (skills at maximum level A) multiplied by a coefficient and the minimum skill level multiplied by another coef... | false | Code is incorrect. | |
89491360e66f8310e95485370a17fd93 | none | You are given several queries. In the *i*-th query you are given a single positive integer *n**i*. You are to represent *n**i* as a sum of maximum possible number of composite summands and print this maximum number, or print -1, if there are no such splittings.
An integer greater than 1 is composite, if it is not prim... | {"inputs": ["1\n12", "2\n6\n8", "3\n1\n2\n3", "6\n1\n2\n3\n5\n7\n11", "3\n4\n6\n9", "20\n8\n13\n20\n12\n9\n16\n4\n19\n7\n15\n10\n6\n14\n11\n3\n2\n5\n17\n18\n1", "100\n611\n513\n544\n463\n38\n778\n347\n317\n848\n664\n382\n108\n718\n33\n334\n876\n234\n22\n944\n305\n159\n245\n513\n691\n639\n135\n308\n324\n813\n459\n304\n1... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 127 | codeforces | Okay, let's see. I need to solve this problem where for each given number n, I have to split it into the maximum possible number of composite numbers. If it's impossible, return -1. Hmm.
First, I remember that composite numbers are integers greater than 1 that aren't primes. So like 4, 6, 8, 9, etc. The problem is to ... | To solve this problem, we need to determine the maximum number of composite numbers that sum up to a given integer \( n \) for multiple queries. If it's impossible to represent \( n \) as a sum of composite numbers, we return -1.
### Approach
1. **Understanding Composite Numbers**: Composite numbers are integers great... | true | ||
895d55b60d3cf7fbe8a8d7aee6e5bf90 | Tourist Problem | Iahub is a big fan of tourists. He wants to become a tourist himself, so he planned a trip. There are *n* destinations on a straight road that Iahub wants to visit. Iahub starts the excursion from kilometer 0. The *n* destinations are described by a non-negative integers sequence *a*1, *a*2, ..., *a**n*. The number *a*... | {"inputs": ["3\n2 3 5", "4\n1 5 77 2", "5\n3 3842 288 199 334", "7\n1 2 3 40 52 33 86", "7\n1 10 100 1000 10000 1000000 10000000", "6\n3835302 971984 8706888 1080445 2224695 1093317", "40\n8995197 7520501 942559 8012058 3749344 3471059 9817796 3187774 4735591 6477783 7024598 3155420 6039802 2879311 2738670 5930138 4604... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 35 | codeforces | Okay, let's see. I need to find the average total distance that Iahub walks for all possible permutations of visiting the destinations. Hmm. The problem states that for each possible route (permutation of the destinations), calculate the total distance he walks, then find the average of all those totals. And then outpu... | To solve this problem, we need to determine the average distance Iahub would walk when visiting all destinations in any order. The solution involves calculating the sum of distances for all possible permutations of destinations and then finding the average.
### Approach
1. **Sorting the Destinations**: First, sort the... | true | ||
896e4fa6c27d59192730b1a332916bbd | Center Alignment | Almost every text editor has a built-in function of center text alignment. The developers of the popular in Berland text editor «Textpad» decided to introduce this functionality into the fourth release of the product.
You are to implement the alignment in the shortest possible time. Good luck!
The input file consists ... | {"inputs": ["This is\n\nCodeforces\nBeta\nRound\n5", "welcome to the\nCodeforces\nBeta\nRound 5\n\nand\ngood luck", "0\n2", "O\no\nd", "0v uO M6Sy", "fm v\nOL U W", "vb\nJ\nyU\nZ", "N\nSV\nEh\n6f\nX6\n9e", "Pj\nA\nFA\nP\nVJ\nU\nEb\nW", "T\n7j\nS\nb\nq8\nVZ\nn\n4T\niZ\npA", "8\n\n\n\ny\nW\n\n\n\n3B\n\nw\nV\n\n\n\nL\... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 104 | codeforces | Okay, I need to solve this programming problem. Let's read the problem carefully.
The task is to take a text input, center-align each line, and then frame it with asterisks. The framing should be the minimum possible size. Also, there's a part about handling lines that can't be perfectly centered. Oh right, when the l... | To solve this problem, we need to center-align each line of the input text and frame the entire text with asterisks. The framing should be the minimum possible size, and if a line cannot be perfectly centered, it should be alternated between left and right alignment starting with the left.
### Approach
1. **Reading In... | false | Code is incorrect. | |
898bd3d15572e3c5b3a6e55eee7cebf1 | Minimum Sum | Petya has *n* positive integers *a*1,<=*a*2,<=...,<=*a**n*.
His friend Vasya decided to joke and replaced all digits in Petya's numbers with a letters. He used the lowercase letters of the Latin alphabet from 'a' to 'j' and replaced all digits 0 with one letter, all digits 1 with another letter and so on. For any two... | {"inputs": ["3\nab\nde\naj", "5\nabcdef\nghij\nbdef\naccbd\ng", "3\naa\njj\naa", "9\na\nb\nc\nd\nf\ng\nh\ni\nj", "5\nbdgbh\nadi\naa\ngjh\ngh", "6\nchafj\nabhj\nfhe\nhfbd\njifgg\ng", "1\nh", "7\nffh\nfhec\nfbchc\ng\ndfbhi\ncdbdi\ni", "8\ne\nbhbib\nj\ndgb\njjbgb\nei\ndggbdh\nhfbbfj", "10\ncf\ncha\nceiab\ng\naajac\ndj\nhe... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 41 | codeforces | Okay, let's try to figure out this problem. So, the task is to restore the original numbers from the letters, assigning each letter a unique digit (0-9) such that the sum of the numbers is minimized. And we have to make sure that the restored numbers don't have leading zeros. Hmm.
First, I need to understand the const... | To solve this problem, we need to restore Petya's numbers from the letters used by Vasya such that the sum of the restored numbers is minimized. Each letter represents a unique digit (0-9), and the restored numbers must not have leading zeros.
### Approach
1. **Identify Leading Characters**: Determine which letters ar... | true | ||
898f5cceb39732df2744828494acaa59 | Different Subsets For All Tuples | For a sequence *a* of *n* integers between 1 and *m*, inclusive, denote *f*(*a*) as the number of distinct subsequences of *a* (including the empty subsequence).
You are given two positive integers *n* and *m*. Let *S* be the set of all sequences of length *n* consisting of numbers from 1 to *m*. Compute the sum *f*(*... | {"inputs": ["1 3", "2 2", "3 3", "1 1000000", "1000000 1", "500 500", "1000000 1000000"], "outputs": ["6", "14", "174", "2000000", "1000001", "383255233", "247171672"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 8 | codeforces | Okay, I need to find the sum of f(a) for all sequences a of length n with elements between 1 and m, modulo 1e9+7. Let's think about how to approach this.
First, what is f(a)? f(a) is the number of distinct subsequences of a, including the empty one. I remember there's a formula for calculating f(a) for a given sequenc... | To solve this problem, we need to compute the sum of the number of distinct subsequences (including the empty subsequence) for all possible sequences of length `n` with elements ranging from 1 to `m`, modulo \(10^9 + 7\).
### Approach
The key insight is to use dynamic programming to efficiently compute the required su... | true | ||
899ad686a6f5f7729afbc31a2d42123f | Tree Construction | During the programming classes Vasya was assigned a difficult problem. However, he doesn't know how to code and was unable to find the solution in the Internet, so he asks you to help.
You are given a sequence $a$, consisting of $n$ distinct integers, that is used to construct the binary search tree. Below is the form... | {"inputs": ["3\n1 2 3", "5\n4 2 3 1 6", "2\n1 2", "10\n991309218 517452607 870021923 978357992 136426010 10601767 302627526 883615372 163475700 600546765", "2\n656402233 488475947"], "outputs": ["1 2", "4 2 2 4", "1", "991309218 517452607 870021923 517452607 136426010 136426010 978357992 302627526 870021923", "65640223... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 3 | codeforces | Okay, let's see. The problem is about building a binary search tree (BST) from a sequence of numbers and then outputting the parent of each inserted node after the first one. So for each element a_i (starting from a_2), I need to find its parent in the BST as it was inserted according to the given rules.
Hmm, the chal... | To solve this problem, we need to determine the parent node of each element in a sequence when inserted into a binary search tree (BST) according to specific rules. The challenge is to efficiently track the parent nodes without explicitly building the BST, which would be computationally expensive for large sequences.
... | true | ||
899dbfc5766d6ae6850a7869f0de87da | Reversing Encryption | A string $s$ of length $n$ can be encrypted by the following algorithm:
- iterate over all divisors of $n$ in decreasing order (i.e. from $n$ to $1$), - for each divisor $d$, reverse the substring $s[1 \dots d]$ (i.e. the substring which starts at position $1$ and ends at position $d$).
For example, the above algor... | {"inputs": ["10\nrocesfedoc", "16\nplmaetwoxesisiht", "1\nz", "2\nir", "3\nilj", "4\njfyy", "6\nkrdych", "60\nfnebsopcvmlaoecpzmakqigyuutueuozjxutlwwiochekmhjgwxsgfbcrpqj", "64\nhnlzzhrvqnldswxfsrowfhmyzbxtyoxhogudasgywxycyhzgiseerbislcncvnwy", "97\nqnqrmdhmbubaijtwsecbidqouhlecladwgwcuxbigckrfzasnbfbslukoayhcgquuacyga... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 173 | codeforces | Okay, let's tackle this problem. So the task is to reverse the encryption process described. The encryption process works by taking all divisors of the string length in decreasing order and reversing the substring from position 1 to d each time. To decrypt, we need to find the original string s that, when encrypted, gi... | To solve this problem, we need to decrypt an encrypted string by reversing the encryption process. The encryption process involves reversing substrings based on the divisors of the string length in decreasing order. Our task is to reverse these operations to retrieve the original string.
### Approach
1. **Understand t... | true | ||
89c2bcffb56fcdb0dba9ea994e161d20 | Color Stripe | A colored stripe is represented by a horizontal row of *n* square cells, each cell is pained one of *k* colors. Your task is to repaint the minimum number of cells so that no two neighbouring cells are of the same color. You can use any color from 1 to *k* to repaint the cells.
The first input line contains two integer... | {"inputs": ["6 3\nABBACC", "3 2\nBBB", "1 2\nA", "1 26\nZ", "2 2\nAA", "2 2\nBA", "6 2\nAAABBB", "8 3\nAABBABBB", "10 26\nAAAAAAAAAA", "12 3\nAAABBBAAABBB", "3 2\nAAB", "3 3\nBBA", "3 3\nCCC", "8 3\nAABBCCBB", "200 2\nBABAABBABBABBABABBBABAAABABBABABBBAABBBBABBAABBABABAAAAABAABBBAAAAAAABBBABAAAABABBBAABABAABAABBBAABBAB... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 11 | codeforces | Okay, let's see. I need to solve this problem where I have to repaint a stripe of cells so that no two adjacent cells are the same color. And I have to do it with the minimum number of repaints. Then output both the count and one possible solution.
Hmm, the input is the number of cells n and the number of colors k, fo... | To solve this problem, we need to repaint a colored stripe such that no two adjacent cells have the same color, using the minimum number of repaints. The solution involves a greedy approach where we process each cell from left to right and make necessary changes to ensure adjacent cells are different.
### Approach
1. ... | false | Code is incorrect. | |
89f33e47241992f5c2c6cbeeaf3d4ead | Captain Marmot | Captain Marmot wants to prepare a huge and important battle against his enemy, Captain Snake. For this battle he has *n* regiments, each consisting of 4 moles.
Initially, each mole *i* (1<=≤<=*i*<=≤<=4*n*) is placed at some position (*x**i*,<=*y**i*) in the Cartesian plane. Captain Marmot wants to move some moles to m... | {"inputs": ["4\n1 1 0 0\n-1 1 0 0\n-1 1 0 0\n1 -1 0 0\n1 1 0 0\n-2 1 0 0\n-1 1 0 0\n1 -1 0 0\n1 1 0 0\n-1 1 0 0\n-1 1 0 0\n-1 1 0 0\n2 2 0 1\n-1 0 0 -2\n3 0 0 -2\n-1 1 -2 0", "3\n-2248 6528 -2144 6181\n-2245 6663 -2100 7054\n-4378 7068 -4061 7516\n-4274 6026 -3918 5721\n4942 -6793 5014 -6807\n3463 -5170 3112 -5181\n287... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 6 | codeforces | Okay, I need to solve this programming problem. Let's read the problem statement carefully.
So, the problem is about rotating moles around their home points to form a square for each regiment. Each regiment has 4 moles, and each can be rotated 90 degrees counter-clockwise around their home any number of times. Each ro... | To solve this problem, we need to determine the minimal number of 90-degree counter-clockwise rotations required for each of Captain Marmot's regiments to form a compact square. Each regiment consists of 4 moles, each of which can be rotated around their respective home points. The goal is to check all possible rotatio... | true | ||
8a0c32c216a57e2b1ebcc493f38f1de4 | Movie Critics | A film festival is coming up in the city N. The festival will last for exactly *n* days and each day will have a premiere of exactly one film. Each film has a genre — an integer from 1 to *k*.
On the *i*-th day the festival will show a movie of genre *a**i*. We know that a movie of each of *k* genres occurs in the fes... | {"inputs": ["10 3\n1 1 2 3 2 3 3 1 1 3", "7 3\n3 1 3 2 3 1 2", "2 2\n1 2", "10 2\n1 2 2 1 1 2 1 1 2 2", "10 10\n5 7 8 2 4 10 1 3 9 6", "100 10\n6 2 8 1 7 1 2 9 2 6 10 4 2 8 7 5 2 9 5 2 3 2 8 3 7 2 4 3 1 8 8 5 7 10 2 1 8 4 1 4 9 4 2 1 9 3 7 2 4 8 4 3 10 3 9 5 7 7 1 2 10 7 7 8 9 7 1 7 4 8 9 4 1 10 2 4 2 10 9 6 10 5 1 4 2... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 12 | codeforces | Okay, I need to solve this programming problem. Let me read the problem carefully.
The problem is about Valentine choosing a genre to exclude such that the number of stresses (mood changes) is minimized. The goal is to find the genre x that when removed from the sequence, the resulting sequence has the least number of... | To solve this problem, we need to determine which genre Valentine should exclude from his viewing list to minimize the number of mood changes (stresses) he experiences. The solution involves analyzing the sequence of movie genres to efficiently compute the effect of excluding each genre on the total number of stresses.... | true | ||
8a19c08339325adedb08655029389065 | Robot Bicorn Attack | Vasya plays Robot Bicorn Attack.
The game consists of three rounds. For each one a non-negative integer amount of points is given. The result of the game is the sum of obtained points. Vasya has already played three rounds and wrote obtained points one by one (without leading zeros) into the string *s*. Vasya decided ... | {"inputs": ["1234", "9000", "0009", "100000010000001000000", "1000000011", "9991", "1000001999", "100000010000011000000", "100000010000001000001", "102", "100", "000", "001", "090", "999999999999999999999999999999", "12345678901234567", "12635000000127683", "428595000000042345353", "48726340000000", "93246310000000", "... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 24 | codeforces | Okay, let's see. The problem is about finding the maximum possible sum of three numbers from a given string. Each number is part of the string when concatenated, but we have to split the string into three parts such that each part represents a non-negative integer (without leading zeros, except if the number is zero it... | To solve this problem, we need to determine the maximum possible sum of three non-negative integers that can be formed by splitting a given string into three parts, following specific rules. Each part must be a valid integer without leading zeros (unless the integer is exactly zero) and each part must not exceed 1,000,... | true | ||
8a2e86e2f136815a2d31168586eb8de7 | Roma and Lucky Numbers | Roma (a popular Russian name that means 'Roman') loves the Little Lvov Elephant's lucky numbers.
Let us remind you that lucky numbers are positive integers whose decimal representation only contains lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Roma's got *n* positive integer... | {"inputs": ["3 4\n1 2 4", "3 2\n447 44 77", "2 2\n507978501 180480073", "9 6\n655243746 167613748 1470546 57644035 176077477 56984809 44677 215706823 369042089", "6 100\n170427799 37215529 675016434 168544291 683447134 950090227", "4 2\n194041605 706221269 69909135 257655784", "4 2\n9581849 67346651 530497 272158241", ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 500 | codeforces | Okay, I need to solve this programming problem. Let's read the problem carefully.
The task is to determine how many of the given numbers have not more than k lucky digits. Lucky digits are 4 and 7. So for each number in the input, I have to count how many of its digits are either 4 or 7. Then, check if that count is l... | To solve this problem, we need to determine how many of the given numbers have not more than a specified number of lucky digits (4 or 7). The solution involves counting the lucky digits in each number and checking if they meet the given threshold.
### Approach
1. **Read Input:** First, read the integers `n` (number of... | true | ||
8a318d25c4228c01367164cd22486e42 | Minimum spanning tree for each edge | Connected undirected weighted graph without self-loops and multiple edges is given. Graph contains *n* vertices and *m* edges.
For each edge (*u*,<=*v*) find the minimal possible weight of the spanning tree that contains the edge (*u*,<=*v*).
The weight of the spanning tree is the sum of weights of all edges included... | {"inputs": ["5 7\n1 2 3\n1 3 1\n1 4 5\n2 3 2\n2 5 3\n3 4 2\n4 5 4", "2 1\n1 2 42", "3 3\n1 2 10\n2 3 20\n3 1 40", "4 6\n1 2 999999001\n1 3 999999003\n1 4 999999009\n2 3 999999027\n2 4 999999243\n3 4 999999729", "8 10\n2 5 4\n7 5 2\n7 3 28\n4 5 14\n3 2 15\n1 2 3\n6 2 5\n2 8 17\n4 6 2\n1 4 10", "8 10\n8 7 11\n3 5 23\n2 1... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 2 | codeforces | Okay, I need to solve this programming problem. Let's read the problem carefully.
The problem is about finding, for each edge in an undirected weighted graph, the minimal possible weight of a spanning tree that includes that edge. Then, we need to output this minimal weight for each edge. The spanning tree's total wei... | To solve this problem, we need to determine the minimal possible weight of a spanning tree that includes each given edge in an undirected weighted graph. The solution involves using Kruskal's algorithm to find the Minimum Spanning Tree (MST) and then leveraging binary lifting to efficiently compute the maximum edge wei... | true | ||
8a39a0fc528e653f23f943f263f57591 | Mister B and Boring Game | Sometimes Mister B has free evenings when he doesn't know what to do. Fortunately, Mister B found a new game, where the player can play against aliens.
All characters in this game are lowercase English letters. There are two players: Mister B and his competitor.
Initially the players have a string *s* consisting of t... | {"inputs": ["1 1 1 8", "4 2 2 6", "3 7 4 6", "4 5 1 1", "12 12 1 1000", "12 1 1000 1000", "3 4 701 703", "12 12 13 1000000000", "3 4 999999999 1000000000", "5 6 1000000000 1000000000", "1 1 1 1", "12 1 100000011 100000024", "10 12 220000011 220000032", "1 1 1 1000000000", "1 1 999999999 1000000000", "1 1 1000000000 100... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | Okay, let's see. I need to solve this programming problem. Let's start by understanding the problem statement carefully.
So, the problem is about a game where two players (Mister B and the computer) take turns appending letters to a string s. The initial string is made of the first 'a' lowercase letters in order. Mist... | To solve this problem, we need to determine the minimum possible number of distinct letters in a segment of a string generated by two players taking turns appending letters. The string starts with the first 'a' letters of the alphabet, and each player appends a specific number of letters in each turn. Mister B (the fir... | false | Code is incorrect. | |
8a91e345120c4e99d41dd166b1ac3025 | Gerald and Giant Chess | Giant chess is quite common in Geraldion. We will not delve into the rules of the game, we'll just say that the game takes place on an *h*<=×<=*w* field, and it is painted in two colors, but not like in chess. Almost all cells of the field are white and only some of them are black. Currently Gerald is finishing a game ... | {"inputs": ["3 4 2\n2 2\n2 3", "100 100 3\n15 16\n16 15\n99 88", "1000 1000 4\n50 50\n51 50\n50 51\n51 51", "100000 100000 4\n50001 50001\n50000 50000\n50000 50001\n50001 50000", "2 2 2\n2 1\n1 2", "100 10 30\n40 4\n15 3\n75 3\n88 10\n32 1\n16 5\n81 8\n45 2\n72 8\n11 6\n86 4\n50 2\n9 4\n11 1\n20 3\n47 3\n2 4\n68 3\n90 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 6 | codeforces | Okay, let's see. The problem is about finding the number of paths from the upper left corner (1,1) to the lower right corner (h,w) of a grid. The pawn can move only right or down, and some cells are black which are blocked. We need to calculate the number of valid paths modulo 1e9+7.
Hmm. The constraints are h and w u... | To solve this problem, we need to determine the number of valid paths from the upper left corner (1,1) to the lower right corner (h,w) of a grid, avoiding black cells. The pawn can only move right or down. The solution involves dynamic programming and combinatorics to efficiently handle the constraints.
### Approach
1... | true | ||
8a957f78e0d55fcc24a4b2ca6c9e4fec | Increase Sequence | Peter has a sequence of integers *a*1,<=*a*2,<=...,<=*a**n*. Peter wants all numbers in the sequence to equal *h*. He can perform the operation of "adding one on the segment [*l*,<=*r*]": add one to all elements of the sequence with indices from *l* to *r* (inclusive). At that, Peter never chooses any element as the be... | {"inputs": ["3 2\n1 1 1", "5 1\n1 1 1 1 1", "4 3\n3 2 1 1", "1 2000\n2000", "3 2\n2 1 1", "3 4\n4 3 2", "10 6\n5 4 4 4 5 4 4 4 4 5", "10 6\n5 4 4 4 5 4 4 4 4 5", "7 4\n3 3 4 4 4 3 3", "3 6\n5 6 5", "3 2\n1 0 1", "6 1\n0 1 0 0 0 1", "6 3\n2 1 2 2 1 2", "99 1999\n1999 1998 1997 1996 1995 1994 1993 1992 1991 1990 1989 198... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | Okay, let's see. So the problem is about Peter wanting to turn all elements of a sequence into h using certain operations. The operations are adding 1 to a segment [l, r], but with constraints: no element can be the start of a segment more than once, and similarly for the end. Also, each operation's start and end point... | To solve this problem, we need to determine the number of distinct ways to make all elements of a sequence equal to a given value \( h \) using specific operations. Each operation involves incrementing a segment of the sequence, with the constraints that each start and end of a segment can be used exactly once.
### Ap... | false | Code is incorrect. | |
8b05508e415ac732ef63660436500b6f | Cannon | Bertown is under siege! The attackers have blocked all the ways out and their cannon is bombarding the city. Fortunately, Berland intelligence managed to intercept the enemies' shooting plan. Let's introduce the Cartesian system of coordinates, the origin of which coincides with the cannon's position, the *Ox* axis is ... | {"inputs": ["2 10\n0.7853\n0.3\n3\n5.0 5.0\n4.0 2.4\n6.0 1.9", "2 10\n0.7853\n0.3\n2\n4.0 2.4\n6.0 1.9", "3 186\n0.4084\n0.4559\n0.1203\n3\n978.8435 234.6507\n343.6961 128.6128\n611.2897 458.9593", "4 851\n0.3178\n0.5635\n0.1335\n0.5107\n4\n685.3785 249.6264\n681.8946 242.4571\n917.2937 600.3285\n150.5685 135.5137", "2... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | Okay, let's see. I need to solve this programming problem. Let's read the problem carefully.
The problem is about calculating where each cannonball lands, considering walls that can block them. The cannon fires n shots at different angles, and each shot's path could be interrupted by any of the m walls. If a cannonbal... | To solve this problem, we need to determine where each cannonball fired from a cannon will land, considering vertical walls that can block their path. The solution involves calculating the trajectory of each cannonball and checking if it intersects any wall before hitting the ground.
### Approach
1. **Projectile Motio... | true | ||
8b08ea902b7acfe6c832a6ab2e5cbf65 | New York Hotel | Think of New York as a rectangular grid consisting of *N* vertical avenues numerated from 1 to *N* and *M* horizontal streets numerated 1 to *M*. *C* friends are staying at *C* hotels located at some street-avenue crossings. They are going to celebrate birthday of one of them in the one of *H* restaurants also located ... | {"inputs": ["10 10\n2\n1 1\n3 3\n2\n1 10\n4 4", "100 100\n10\n53 20\n97 6\n12 74\n48 92\n97 13\n47 96\n75 32\n69 21\n95 75\n1 54\n10\n36 97\n41 1\n1 87\n39 23\n27 44\n73 97\n1 1\n6 26\n48 3\n5 69", "100 100\n10\n86 72\n25 73\n29 84\n34 33\n29 20\n84 83\n41 80\n22 22\n16 89\n77 49\n1\n4 23", "100 100\n1\n66 77\n10\n70 1... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | Okay, let's see. We need to find a restaurant such that the maximum distance from any of the friends' hotels to this restaurant is as small as possible. Hmm. So the problem is about choosing the best possible restaurant location to minimize the maximum distance any friend has to travel.
First, I should understand how... | To solve this problem, we need to determine the optimal restaurant location such that the maximum distance traveled by any friend from their hotel to the restaurant is minimized. The problem can be efficiently solved using Manhattan distance properties and preprocessing hotel coordinates to reduce computational complex... | true | ||
8b27e972e3fa26ad5abe3942fc090f84 | Permute Digits | You are given two positive integer numbers *a* and *b*. Permute (change order) of the digits of *a* to construct maximal number not exceeding *b*. No number in input and/or output can start with the digit 0.
It is allowed to leave *a* as it is.
The first line contains integer *a* (1<=≤<=*a*<=≤<=1018). The second line ... | {"inputs": ["123\n222", "3921\n10000", "4940\n5000", "23923472834\n23589234723", "102391019\n491010301", "123456789123456789\n276193619183618162", "1000000000000000000\n1000000000000000000", "1\n1000000000000000000", "999999999999999999\n1000000000000000000", "2475345634895\n3455834583479", "15778899\n98715689", "4555\... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 53 | codeforces | Okay, let's see. I need to solve this problem where I have to find the maximum permutation of the digits of a number a such that it doesn't exceed b. And both a and b can be up to 1e18, which is a really big number, so handling them as strings is probably necessary. Also, the output must have the same length as a, and ... | To solve this problem, we need to generate the largest possible permutation of the digits of a number `a` such that the resulting number does not exceed another number `b`. The solution must handle large numbers efficiently and ensure the result is a valid permutation of `a` with the same length.
### Approach
1. **Che... | true | ||
8b3fa8eccfdabf8716ba8e9019da55da | none | You are given an array of positive integers *a*1,<=*a*2,<=...,<=*a**n*<=×<=*T* of length *n*<=×<=*T*. We know that for any *i*<=><=*n* it is true that *a**i*<==<=*a**i*<=-<=*n*. Find the length of the longest non-decreasing sequence of the given array.
The first line contains two space-separated integers: *n*, *T* (... | {"inputs": ["4 3\n3 1 4 2", "1 1000\n42", "31 3767\n16 192 152 78 224 202 186 52 118 19 13 38 199 196 35 295 100 64 205 37 166 124 169 214 66 243 134 192 253 270 92", "15 12226\n18 125 213 221 124 147 154 182 134 184 51 49 267 88 251", "81 10683\n3 52 265 294 213 242 185 151 27 165 128 237 124 14 43 147 104 162 124 103... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 5 | codeforces | Okay, let's see. The problem is to find the length of the longest non-decreasing subsequence in an array that's generated by repeating a base array T times. But wait, the array isn't just a simple repetition. Oh right, the problem statement says that for i > n, a_i is equal to a_{i - n}. So the array is the base array ... | To solve this problem, we need to find the length of the longest non-decreasing subsequence (LNDS) in an array formed by repeating a given base array T times. Given the constraints, directly constructing and processing the entire array is infeasible, so we need an optimized approach.
### Approach
1. **Initial Analysis... | false | Code is incorrect. | |
8b4044b6c20a561a758869590fbe0d05 | GukiZ and Binary Operations | We all know that GukiZ often plays with arrays.
Now he is thinking about this problem: how many arrays *a*, of length *n*, with non-negative elements strictly less then 2*l* meet the following condition: ? Here operation means bitwise AND (in Pascal it is equivalent to and, in C/C++/Java/Python it is equivalent to &... | {"inputs": ["2 1 2 10", "2 1 1 3", "3 3 2 10", "5135 42542 15 4354", "21 21 21 21", "2 0 0 5", "1564 153 12 1000000007", "101 102 13 104", "5 6 29 108", "1000000001 1000000002 37 1000000007", "45305640 6540640606 51 5406546", "68706870687 984089409849 59 156465748", "987408898498 1233432432 15 15", "111111111111 111111... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | Okay, I need to solve this programming problem. Let's read the problem statement carefully.
The problem is about counting the number of arrays 'a' of length 'n' where each element is a non-negative integer strictly less than 2^l. The condition is that the bitwise AND of all elements ORed together must equal k. Then, w... | To solve this problem, we need to determine the number of arrays of length `n` where each element is a non-negative integer strictly less than `2^l`, such that the bitwise OR of all elements equals `k`. The result should be computed modulo `m`.
### Approach
1. **Check Validity of `k`:** First, we need to ensure that `... | false | Code is incorrect. | |
8b794f61bba5cf73f873c4461a6dc912 | Processing Queries | In this problem you have to simulate the workflow of one-thread server. There are *n* queries to process, the *i*-th will be received at moment *t**i* and needs to be processed for *d**i* units of time. All *t**i* are guaranteed to be distinct.
When a query appears server may react in three possible ways:
1. If ser... | {"inputs": ["5 1\n2 9\n4 8\n10 9\n15 2\n19 1", "4 1\n2 8\n4 8\n10 9\n15 2", "1 1\n1000000000 1000000000", "4 3\n999999996 1000000000\n999999997 1000000000\n999999998 1000000000\n999999999 1000000000", "5 1\n2 1\n3 6\n4 5\n6 4\n7 2", "10 2\n4 14\n5 2\n6 6\n7 11\n8 6\n9 5\n10 13\n11 8\n13 2\n20 2", "6 4\n2 4\n4 2\n5 2\n6... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 56 | codeforces | Okay, let's see. I need to solve this problem where I simulate a server processing queries. The server can either process a query immediately, add it to the queue if there's space, or reject it. For each query, I have to output when it finishes processing or -1 if rejected.
Hmm. Let's think about the steps. So the inp... | To solve this problem, we need to simulate the workflow of a one-thread server processing queries with a queue of limited capacity. The server processes queries immediately if it is free, queues them if it is busy and there is space, or rejects them if the queue is full. The goal is to determine the end time for each q... | true | ||
8b980c9c96fff0ee36b71d033b996015 | Lucky Permutation | A permutation *p* of size *n* is the sequence *p*1,<=*p*2,<=...,<=*p**n*, consisting of *n* distinct integers, each of them is from 1 to *n* (1<=≤<=*p**i*<=≤<=*n*).
A lucky permutation is such permutation *p*, that any integer *i* (1<=≤<=*i*<=≤<=*n*) meets this condition *p**p**i*<==<=*n*<=-<=*i*<=+<=1.
You have inte... | {"inputs": ["1", "2", "4", "5", "3", "100000", "6", "7", "8", "9", "99997", "10000", "10001", "10002", "10003", "10004", "25", "29", "33", "9", "13", "17", "50001", "20001", "30001", "99996", "99999", "101", "505", "565"], "outputs": ["1 ", "-1", "2 4 1 3 ", "2 5 3 1 4 ", "-1", "2 100000 4 99998 6 99996 8 99994 10 9999... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 15 | codeforces | Okay, let's tackle this problem. So, we need to find a permutation of size n such that for every i in 1..n, p[p_i] equals n - i + 1. If such a permutation doesn't exist, we return -1. Hmm.
First, let's understand the condition. For each i, when you look up p_i, then use that as an index to get p[p_i], that value must ... | To solve this problem, we need to find a permutation of size \( n \) such that for every integer \( i \) (1 ≤ \( i \) ≤ \( n \)), the condition \( p[p[i]] = n - i + 1 \) is satisfied. If such a permutation does not exist, we should return -1.
### Approach
1. **Check for Validity**:
- If \( n \) is even, the permuta... | false | Code is incorrect. | |
8baaa070ecac7d157bd2a81f95a18b77 | MUH and Important Things | It's time polar bears Menshykov and Uslada from the zoo of St. Petersburg and elephant Horace from the zoo of Kiev got down to business. In total, there are *n* tasks for the day and each animal should do each of these tasks. For each task, they have evaluated its difficulty. Also animals decided to do the tasks in ord... | {"inputs": ["4\n1 3 3 1", "5\n2 4 1 4 8", "8\n1 5 4 12 7 2 10 11", "6\n5 1 2 5 2 4", "1\n1083", "10\n5 5 5 5 5 5 5 5 5 5", "6\n3 8 3 9 3 10", "19\n895 1302 724 952 340 952 939 1302 724 952 939 340 340 1844 770 976 435 1302 1302", "7\n766 766 1477 766 107 1774 990", "11\n1552 1010 1552 1248 1550 388 1541 1010 613 1821 3... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 50 | codeforces | Okay, let's see. I need to solve this programming problem. Let's read the problem carefully.
So, the problem is about three animals that need to have three different plans for doing tasks. Each plan is a permutation of the tasks, ordered by their difficulty. If there are tasks with the same difficulty, their order can... | To solve this problem, we need to determine if we can generate three distinct plans for three animals to perform tasks based on their difficulty. Each plan must be a permutation of tasks ordered by difficulty, and tasks with the same difficulty can be reordered. The goal is to check if three distinct permutations exist... | false | Code is incorrect. | |
8bb5b84ac8b7a2f06ed0f1e18350f2ef | none | One of Timofey's birthday presents is a colourbook in a shape of an infinite plane. On the plane *n* rectangles with sides parallel to coordinate axes are situated. All sides of the rectangles have odd length. Rectangles cannot intersect, but they can touch each other.
Help Timofey to color his rectangles in 4 differe... | {"inputs": ["8\n0 0 5 3\n2 -1 5 0\n-3 -4 2 -1\n-1 -1 2 0\n-3 0 0 5\n5 2 10 3\n7 -3 10 2\n4 -2 7 -1", "1\n0 0 1 1", "4\n0 0 1 1\n1 0 2 1\n1 1 2 2\n0 1 1 2", "3\n0 0 1 3\n1 0 4 1\n1 1 2 2", "6\n0 1 1 4\n0 4 1 7\n1 0 2 3\n1 3 2 4\n1 4 2 5\n2 3 3 4", "25\n0 0 7 7\n0 18 7 29\n7 36 12 41\n7 18 12 29\n15 29 26 36\n7 7 12 18\n... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 24 | codeforces | Okay, so I need to solve this problem where I have to color a bunch of rectangles such that any two that touch by a side have different colors. And the colors can be only 1 to 4. If possible, output the colors, else say NO.
First, let's understand the problem. All rectangles have sides with odd lengths. They don't int... | To solve this problem, we need to color rectangles on an infinite plane such that no two adjacent rectangles (touching by a side) have the same color. The solution leverages the properties of the rectangles' coordinates and the four-color theorem to ensure a valid coloring.
### Approach
1. **Problem Analysis**: Each r... | false | Code is incorrect. | |
8bbcbb9e2645ba1ed5dd33803c1dee7b | Text Volume | You are given a text of single-space separated words, consisting of small and capital Latin letters.
Volume of the word is number of capital letters in the word. Volume of the text is maximum volume of all words in the text.
Calculate the volume of the given text.
The first line contains one integer number *n* (1<=≤<... | {"inputs": ["7\nNonZERO", "24\nthis is zero answer text", "24\nHarbour Space University", "2\nWM", "200\nLBmJKQLCKUgtTxMoDsEerwvLOXsxASSydOqWyULsRcjMYDWdDCgaDvBfATIWPVSXlbcCLHPYahhxMEYUiaxoCebghJqvmRnaNHYTKLeOiaLDnATPZAOgSNfBzaxLymTGjfzvTegbXsAthTxyDTcmBUkqyGlVGZhoazQzVSoKbTFcCRvYsgSCwjGMxBfWEwMHuagTBxkz", "199\no A r ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 436 | codeforces | Okay, let's see. I need to solve this programming problem. The task is to calculate the volume of a text. The volume of the text is the maximum number of capital letters in any of its words. So each word's volume is the count of uppercase letters, and the text's volume is the highest among those.
First, let me underst... | To solve this problem, we need to determine the volume of a given text, which is defined as the maximum number of capital letters in any word within the text. Each word's volume is the count of its uppercase letters, and the text's volume is the highest volume among all its words.
### Approach
1. **Read Input**: First... | true | ||
8be1c3722f69c951ceff8bd6b888d662 | 80-th Level Archeology | Archeologists have found a secret pass in the dungeon of one of the pyramids of Cycleland. To enter the treasury they have to open an unusual lock on the door. The lock consists of *n* words, each consisting of some hieroglyphs. The wall near the lock has a round switch. Each rotation of this switch changes the hierogl... | {"inputs": ["4 3\n2 3 2\n1 1\n3 2 3 1\n4 2 3 1 2", "2 5\n2 4 2\n2 4 2", "4 4\n1 2\n1 3\n1 4\n1 2", "3 1\n2 1 1\n2 1 1\n3 1 1 1", "2 10\n14 9 6 7 1 6 9 3 1 9 4 6 8 8 1\n3 3 7 6", "5 10\n1 5\n7 5 1 10 5 3 7 10\n1 2\n1 3\n7 4 7 3 9 4 6 1", "50 5\n1 4\n1 4\n1 4\n1 4\n2 4 4\n2 4 5\n2 4 5\n3 4 1 1\n4 4 1 2 5\n7 4 3 2 1 4 4 5... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | Okay, let's see. We need to find the number of clockwise rotations x such that when we rotate each hieroglyph by x, the list of words becomes lexicographically sorted. If there's no such x, we return -1.
Hmm. Let's break this down. The rotation here means adding x to each hieroglyph and then mod by c, wrapping around ... | To solve this problem, we need to determine the number of clockwise rotations required to sort a sequence of words lexicographically using a cyclic hieroglyph alphabet. If it's impossible, we should return -1.
### Approach
1. **Problem Analysis**:
- Each rotation transforms each hieroglyph by incrementing its value... | true | ||
8be653bb7d31a6854b649c9565e080e5 | April Fools' Problem (easy) | The marmots have prepared a very easy problem for this year's HC2 – this one. It involves numbers *n*, *k* and a sequence of *n* positive integers *a*1,<=*a*2,<=...,<=*a**n*. They also came up with a beautiful and riveting story for the problem statement. It explains what the input means, what the program should output... | {"inputs": ["8 5\n1 1 1 1 1 1 1 1", "10 3\n16 8 2 4 512 256 32 128 64 1", "5 1\n20 10 50 30 46", "6 6\n6 6 6 6 6 6", "1 1\n100", "1 1\n1", "10 5\n147 1917 5539 7159 5763 416 711 1412 6733 4402", "100 60\n1443 3849 6174 8249 696 8715 3461 9159 4468 2496 3044 2301 2437 7559 7235 7956 8959 2036 4399 9595 8664 9743 7688 37... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 44 | codeforces | Okay, let's see. The problem is about finding some value based on n, k, and a sequence of numbers. The sample outputs are large numbers, but I need to figure out what exactly we're supposed to compute here.
Looking at the sample input and outputs:
First sample input is n=8, k=5, and all a_i are 1. The output is 57103... | To solve this problem, we need to compute the sum of the products of all possible k-element subsets from a given list of integers. This can be efficiently achieved using dynamic programming to keep track of the sum of products for subsets of different sizes as we iterate through the elements.
### Approach
1. **Dynamic... | false | Code is incorrect. | |
8bf008186e7ef1b9076e19b8f3ab5c1a | Scrambled | Btoh yuo adn yuor roomatme lhoate wianshg disehs, btu stlil sdmoeboy msut peorrfm tihs cohre dialy. Oen dya yuo decdie to idourtcne smoe syestm. Yuor rmmotaoe sstgegus teh fooniwllg dael. Yuo argee on tow arayrs of ientgres M adn R, nmebur upmicnog dyas (induiclng teh cunrret oen) wtih sicsescuve irnegets (teh ceurrnt ... | {"inputs": ["1\n2\n0", "2\n2 3\n1 0", "3\n2 4 4\n0 1 3", "1\n16\n15", "16\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16\n0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15", "16\n5 6 9 13 13 15 9 10 2 6 10 11 12 7 4 8\n4 3 3 5 8 3 6 5 1 4 2 6 7 4 0 1", "8\n15 3 7 11 14 10 16 2\n0 2 1 4 0 0 13 1", "1\n7\n5", "9\n6 12 3 10 15 14 6 9 3\n5 2... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 25 | codeforces | Okay, let's see. I need to solve this programming problem. Let's read the problem statement carefully.
So the problem is about calculating the percentage of days where I end up washing the dishes, based on the given arrays M and R. The rule is that on day D, I have to wash if there exists an index i such that D mod M[... | To solve this problem, we need to determine the percentage of days where you end up washing the dishes based on given arrays M and R. The rule is that on day D, you wash the dishes if there exists an index i such that D mod M[i] <= R[i]. Otherwise, your roommate does it. The solution involves finding the cycle length u... | false | Code is incorrect. | |
8bfbb4d2c2d479b59b4a5cb61941820d | Hide-and-Seek | Victor and Peter are playing hide-and-seek. Peter has hidden, and Victor is to find him. In the room where they are playing, there is only one non-transparent wall and one double-sided mirror. Victor and Peter are points with coordinates (*x**v*,<=*y**v*) and (*x**p*,<=*y**p*) respectively. The wall is a segment joinin... | {"inputs": ["-1 3\n1 3\n0 2 0 4\n0 0 0 1", "0 0\n1 1\n0 1 1 0\n-100 -100 -101 -101", "0 0\n1 1\n0 1 1 0\n-1 1 1 3", "0 0\n10 0\n100 100 101 101\n1 0 3 0", "0 0\n1 1\n100 100 101 101\n-100 -100 -101 -101", "-1 1\n1 1\n0 3 0 4\n0 0 0 2", "0 0\n2 0\n1 1 1 -1\n0 2 1 2", "0 0\n2 0\n1 1 1 -1\n-10 2 -12 2", "0 0\n2 0\n0 2 2 2... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | Okay, I need to solve this problem where Victor and Peter are in a room with a wall and a mirror, and I have to determine if Victor can see Peter either directly or via a reflection in the mirror. Let's think through all the steps.
First, understanding the problem: Victor can see Peter directly if the line between the... | To solve this problem, we need to determine if Victor can see Peter either directly or via a reflection in a mirror, considering the presence of a non-transparent wall. The solution involves checking both direct line of sight and possible reflections using geometric calculations.
### Approach
1. **Direct Line of Sight... | false | Code is incorrect. | |
8c0044cad84ef54874eff46f8f5fe656 | Sonya and Matrix | Since Sonya has just learned the basics of matrices, she decided to play with them a little bit.
Sonya imagined a new type of matrices that she called rhombic matrices. These matrices have exactly one zero, while all other cells have the Manhattan distance to the cell containing the zero. The cells with equal numbers ... | {"inputs": ["20\n1 0 2 3 5 3 2 1 3 2 3 1 4 2 1 4 2 3 2 4", "18\n2 2 3 2 4 3 3 3 0 2 4 2 1 3 2 1 1 1", "6\n2 1 0 2 1 2", "1\n0", "7\n0 1 2 3 4 2 6", "6\n0 0 0 0 0 0", "4\n0 0 0 0"], "outputs": ["4 5\n2 2", "3 6\n2 3", "-1", "1 1\n1 1", "-1", "-1", "-1"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 2 | codeforces | Okay, I need to solve this programming problem. Let's read the problem statement carefully.
So, the task is to determine the possible dimensions (n and m) of a rhombic matrix given the elements in arbitrary order. The rhombic matrix is defined such that there's exactly one zero, and every other cell has the Manhattan ... | To solve this problem, we need to determine the dimensions of a rhombic matrix and the position of the zero element based on a given sequence of numbers. A rhombic matrix is defined such that each cell contains the Manhattan distance to the cell with the zero, forming a rhombus pattern around it.
### Approach
1. **Che... | false | Code is incorrect. | |
8c4a32fe0eb2f98ede0b2c62a4d73b97 | Harmony Analysis | The semester is already ending, so Danil made an effort and decided to visit a lesson on harmony analysis to know how does the professor look like, at least. Danil was very bored on this lesson until the teacher gave the group a simple task: find 4 vectors in 4-dimensional space, such that every coordinate of every vec... | {"inputs": ["2", "1", "3", "0", "4", "5", "6", "7", "8", "9"], "outputs": ["++++\n+*+*\n++**\n+**+", "++\n+*", "++++++++\n+*+*+*+*\n++**++**\n+**++**+\n++++****\n+*+**+*+\n++****++\n+**+*++*", "+", "++++++++++++++++\n+*+*+*+*+*+*+*+*\n++**++**++**++**\n+**++**++**++**+\n++++****++++****\n+*+**+*++*+**+*+\n++****++++***... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 15 | codeforces | Okay, I need to generate 2k vectors in 2k-dimensional space such that each coordinate is either +1 or -1, and any two vectors are orthogonal. Let's think about how to approach this.
First, remember that two vectors are orthogonal if their dot product is zero. The dot product is the sum of the products of their corresp... | To solve this problem, we need to generate 2k vectors in a 2k-dimensional space such that each coordinate is either +1 or -1, and any two vectors are orthogonal. The solution involves constructing these vectors using a systematic approach based on binary operations.
### Approach
The key insight is to leverage the prop... | false | Code is incorrect. | |
8c79b8c1ac558a266dbe4c8f55ed51e7 | Vasya and Beautiful Arrays | Vasya's got a birthday coming up and his mom decided to give him an array of positive integers *a* of length *n*.
Vasya thinks that an array's beauty is the greatest common divisor of all its elements. His mom, of course, wants to give him as beautiful an array as possible (with largest possible beauty). Unfortunately... | {"inputs": ["6 1\n3 6 10 12 13 16", "5 3\n8 21 52 15 77", "13 11\n55 16 26 40 84 80 48 52 25 43 75 21 58", "18 9\n85 29 29 15 17 71 46 69 48 80 44 73 40 55 61 57 22 68", "25 7\n67 18 36 85 64 22 32 66 17 64 66 65 82 36 16 52 19 70 38 51 17 32 85 16 64", "7 1\n12 84 21 60 33 21 45", "1 1\n1", "10 10\n40141 53368 66538 6... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 3 | codeforces | Okay, let's tackle this problem. So, the task is to find the maximum possible GCD (greatest common divisor) of an array after we can decrease each element by at most k. Hmm, right. So each element in the resulting array b must satisfy b_i <= a_i and a_i - b_i <=k. And then we want the GCD of all the b_i's to be as larg... | To solve this problem, we need to determine the maximum possible beauty (greatest common divisor, GCD) of an array after each element can be decreased by at most a given value \( k \). The solution involves checking possible divisors efficiently to find the maximum GCD that can be achieved under the constraints.
### A... | false | Code is incorrect. | |
8c94a95b56f6f7c5dcc0c59a65f20967 | Anton and Chess | Anton likes to play chess. Also, he likes to do programming. That is why he decided to write the program that plays chess. However, he finds the game on 8 to 8 board to too simple, he uses an infinite one instead.
The first task he faced is to check whether the king is in check. Anton doesn't know how to implement thi... | {"inputs": ["2\n4 2\nR 1 1\nB 1 5", "2\n4 2\nR 3 3\nB 1 5", "5\n-1 1\nR -10 10\nQ -9 9\nQ -2 -8\nB -6 10\nB -10 1", "20\n-321 454\nQ 967 -89\nR -811 454\nQ -404 454\nR -734 454\nQ -804 454\nQ -316 77\nQ -802 454\nB -499 454\nQ 401 -663\nQ -601 454\nQ -974 454\nB 710 298\nB -917 454\nB -555 -542\nQ -337 950\nR 501 40\nR... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | Okay, let's see. The problem is to determine if the white king is in check based on the positions of various black pieces. The pieces can be bishops, rooks, or queens. And the king is in check if any of these pieces can attack him in one move, considering their movement rules and that they can't jump over other pieces.... | To solve this problem, we need to determine if the white king is in check by any black pieces on an infinite chessboard. The black pieces can be bishops, rooks, or queens, each moving according to their specific rules. The solution involves checking each piece's position relative to the king and ensuring there are no o... | true | ||
8c973212d593a4182fe97b22e3f856eb | Olesya and Rodion | Olesya loves numbers consisting of *n* digits, and Rodion only likes numbers that are divisible by *t*. Find some number that satisfies both of them.
Your task is: given the *n* and *t* print an integer strictly larger than zero consisting of *n* digits that is divisible by *t*. If such number doesn't exist, print <=-... | {"inputs": ["3 2", "2 2", "4 3", "5 3", "10 7", "2 9", "18 8", "1 5", "1 10", "100 5", "10 2", "18 10", "1 9", "7 6", "4 4", "14 7", "3 8", "1 3", "2 8", "3 8", "4 3", "5 9", "4 8", "3 4", "9 4", "8 10", "1 6", "20 3", "15 10", "31 4", "18 9", "72 4", "76 8", "12 5", "54 5", "96 10", "15 9", "100 2", "99 3", "98 4", "9... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 308 | codeforces | Okay, let's tackle this problem. The goal is to find a number with exactly n digits that's divisible by t. If it's not possible, output -1. Hmm.
First, I need to understand the constraints. The number must have exactly n digits, so for example, if n is 3, the smallest possible number is 100, the largest is 999. Wait, ... | To solve this problem, we need to find a number with exactly `n` digits that is divisible by `t`. If such a number does not exist, we should return `-1`.
### Approach
1. **Understand the Constraints**: The number must have exactly `n` digits, meaning it ranges from \(10^{(n-1)}\) (the smallest `n`-digit number) to \(1... | false | Code is incorrect. | |
8ca09bef1240e1e23975c668191930e4 | Headquarters | Sensation, sensation in the two-dimensional kingdom! The police have caught a highly dangerous outlaw, member of the notorious "Pihters" gang. The law department states that the outlaw was driving from the gang's headquarters in his car when he crashed into an ice cream stall. The stall, the car, and the headquarters e... | {"inputs": ["3\nUR\nUL\nULDR", "2\nDR\nDL", "4\nUL\nUR\nDR\nDL", "10\nUL\nUL\nUL\nUL\nUL\nUL\nUL\nUL\nUL\nUL", "6\nUL\nDL\nDL\nUL\nUL\nDL", "1\nUL", "1\nUR", "1\nDR", "1\nDL", "1\nULDR", "2\nUL\nULDR", "4\nULDR\nUR\nULDR\nUR", "10\nUR\nDR\nUL\nDR\nUL\nULDR\nUR\nUL\nULDR\nUL", "4\nUL\nUR\nDR\nDL", "10\nUL\nUR\nUR\nDR\nD... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 4 | codeforces | Okay, let's see. The problem is about finding the number of possible starting points (gang headquarters) such that after making exactly n movements according to the given records, the car ends up at (0,0), which is the ice cream stall's position. Each movement step has possible directions based on the options in each r... | To solve this problem, we need to determine the number of possible starting points (gang headquarters) such that after exactly `n` movements, the car ends up at the ice cream stall located at (0, 0). Each movement can be one of several possible directions, and we need to track all possible displacements after each move... | false | Code is incorrect. | |
8cd687a88783833ff1c31127372696fe | George and Accommodation | George has recently entered the BSUCP (Berland State University for Cool Programmers). George has a friend Alex who has also entered the university. Now they are moving into a dormitory.
George and Alex want to live in the same room. The dormitory has *n* rooms in total. At the moment the *i*-th room has *p**i* peopl... | {"inputs": ["3\n1 1\n2 2\n3 3", "3\n1 10\n0 10\n10 10", "2\n36 67\n61 69", "3\n21 71\n10 88\n43 62", "3\n1 2\n2 3\n3 4", "10\n0 10\n0 20\n0 30\n0 40\n0 50\n0 60\n0 70\n0 80\n0 90\n0 100", "13\n14 16\n30 31\n45 46\n19 20\n15 17\n66 67\n75 76\n95 97\n29 30\n37 38\n0 2\n36 37\n8 9", "19\n66 67\n97 98\n89 91\n67 69\n67 68\... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 648 | codeforces | Okay, let's see. I need to solve this programming problem. The problem is about counting how many rooms can accommodate both George and Alex. So, each room has some current people (p_i) and a capacity (q_i). We need to check for each room if adding two more people is possible. That is, after adding 2, the total should ... | To solve this problem, we need to determine how many rooms in a dormitory can accommodate both George and Alex. Each room has a certain number of current occupants and a maximum capacity. We need to check if there are at least two available spots in each room to see if both can move in.
### Approach
1. **Input Reading... | true | ||
8d337c19b31a325a4e2c5679c23c0f2a | Fools and Roads | They say that Berland has exactly two problems, fools and roads. Besides, Berland has *n* cities, populated by the fools and connected by the roads. All Berland roads are bidirectional. As there are many fools in Berland, between each pair of cities there is a path (or else the fools would get upset). Also, between eac... | {"inputs": ["5\n1 2\n1 3\n2 4\n2 5\n2\n1 4\n3 5", "5\n3 4\n4 5\n1 4\n2 4\n3\n2 3\n1 3\n3 5"], "outputs": ["2 1 1 1 ", "3 1 1 1 "]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 2 | codeforces | Okay, so I need to solve this programming problem. Let's read the problem carefully.
The problem is about roads in Berland and counting how many fools' paths use each road. The input gives a tree structure (since there's exactly one path between each pair of cities), and each query gives a pair of cities (a_i, b_i) wh... | To solve this problem, we need to determine how many distinct paths between pairs of cities (fools) pass through each road in a tree structure. The solution involves efficiently calculating the number of times each edge is used by leveraging tree properties and the Lowest Common Ancestor (LCA) technique.
### Approach
... | true | ||
8d65492fc90cdeead7cd95db3a21418d | none | Young Teodor enjoys drawing. His favourite hobby is drawing segments with integer borders inside his huge [1;*m*] segment. One day Teodor noticed that picture he just drawn has one interesting feature: there doesn't exist an integer point, that belongs each of segments in the picture. Having discovered this fact, Teodo... | {"inputs": ["2 4\n1 2\n3 4", "4 6\n1 3\n2 3\n4 6\n5 6", "43 1319\n750 1030\n857 946\n941 1203\n407 1034\n947 1290\n546 585\n630 1201\n72 342\n693 1315\n34 719\n176 1097\n36 931\n198 973\n5 1025\n892 1054\n461 1287\n195 1273\n832 1039\n308 955\n642 866\n770 838\n440 777\n289 948\n98 814\n458 768\n82 265\n300 596\n182 70... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | Okay, let's try to understand this problem. So, the task is to find the maximum number of queries (points x_i) that Sasha can ask Teodor such that even after knowing the answers (how many segments contain each x_i), Sasha can't be sure that there's no common point in all segments. The key here is that Sasha doesn't kno... | To solve this problem, we need to determine the maximum number of queries Sasha can ask Teodor such that Sasha cannot be sure whether there exists a common integer point in all segments based on the answers provided. The solution involves analyzing the counts of segments covering each integer point and determining if t... | true | ||
8d7482c6a683d3296ea22a704783715b | Om Nom and Necklace | One day Om Nom found a thread with *n* beads of different colors. He decided to cut the first several beads from this thread to make a bead necklace and present it to his girlfriend Om Nelly.
Om Nom knows that his girlfriend loves beautiful patterns. That's why he wants the beads on the necklace to form a regular patt... | {"inputs": ["7 2\nbcabcab", "21 2\nababaababaababaababaa", "321 2\nabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaa... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 2 | codeforces | Okay, let's see. So the problem is to determine for each position i (from 1 to n) whether the first i beads form a regular sequence as per the definition. The regular sequence S must be of the form A + B + A + B + ... + A, with exactly 2k+1 parts. Which means, the total number of parts is 2k+1. Wait, the problem statem... | To solve this problem, we need to determine if the first `i` beads of a given sequence form a regular pattern as defined. The pattern should be of the form `A B A B ... A` with exactly `2k + 1` segments, where `A` and `B` are sequences of beads, and `A` appears `k + 1` times while `B` appears `k` times.
### Approach
1... | true | ||
8d8fab3e7d35cb8634eaf569edcf87b7 | Rain and Umbrellas | Polycarp lives on a coordinate line at the point $x = 0$. He goes to his friend that lives at the point $x = a$. Polycarp can move only from left to right, he can pass one unit of length each second.
Now it's raining, so some segments of his way are in the rain. Formally, it's raining on $n$ non-intersecting segments,... | {"inputs": ["10 2 4\n3 7\n8 10\n0 10\n3 4\n8 1\n1 2", "10 1 1\n0 9\n0 5", "10 1 1\n0 9\n1 5", "1 1 1\n0 1\n1 100000", "1 1 1\n0 1\n0 100000", "2000 1 1\n0 1\n2000 33303", "2000 1 1\n1999 2000\n0 18898", "100 50 1\n1 2\n3 4\n5 6\n7 8\n9 10\n11 12\n13 14\n15 16\n17 18\n19 20\n21 22\n23 24\n25 26\n27 28\n29 30\n31 32\n33 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 5 | codeforces | Okay, let's tackle this problem. Hmm. So Polycarp needs to move from 0 to a, and some parts are rainy. He has to carry at least one umbrella when moving through a rainy segment. The goal is to find the minimum total fatigue, which is the sum of the weights of the umbrellas he's carrying each step. If it's impossible, o... | To solve this problem, we need to determine the minimum total fatigue Polycarp incurs while traveling from point 0 to point a, ensuring he carries at least one umbrella through all rainy segments. The solution involves dynamic programming (DP) to track the minimum fatigue at each point, considering the optimal use of u... | false | Code is incorrect. | |
8d9078b0a36ff7bd5d993ae41b3780b0 | Rounding | Vasya has a non-negative integer *n*. He wants to round it to nearest integer, which ends up with 0. If *n* already ends up with 0, Vasya considers it already rounded.
For example, if *n*<==<=4722 answer is 4720. If *n*<==<=5 Vasya can round it to 0 or to 10. Both ways are correct.
For given *n* find out to which int... | {"inputs": ["5", "113", "1000000000", "5432359", "999999994", "10", "9", "1", "0", "3", "4", "6", "7", "8", "19", "100", "997", "9994", "10002", "100000", "99999", "999999999", "999999998", "999999995", "999999990", "1000000", "1000010", "10000010", "100000011", "400000003", "234234", "675621", "43532", "4576453", "657... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 461 | codeforces | Okay, I need to solve this problem where Vasya wants to round a number to the nearest integer that ends with a 0. If the number already ends with 0, then it's already rounded. But if not, like if it's 5, he can choose 0 or 10. So the task is to find any correct answer in such cases.
Let me think about the approach. Th... | To solve this problem, we need to round a given non-negative integer to the nearest multiple of 10. If the number already ends in 0, it is considered already rounded. If the number is exactly halfway between two multiples of 10, either of the two possible results is acceptable.
### Approach
1. **Identify the Nearest M... | true | ||
8daea05e984def6f793db9d374212130 | Segments | You are given an integer *N*. Consider all possible segments on the coordinate axis with endpoints at integer points with coordinates between 0 and *N*, inclusive; there will be of them.
You want to draw these segments in several layers so that in each layer the segments don't overlap (they might touch at the endpoin... | {"inputs": ["2", "3", "4", "21", "100", "1", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52"... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 157 | codeforces | Okay, let's try to figure out this problem. The task is to find the minimal number of layers needed to draw all possible segments between integer points from 0 to N, inclusive, such that in each layer, no two segments overlap (they can touch at endpoints).
Hmm, let's start by understanding what the problem is asking.... | To solve this problem, we need to determine the minimal number of layers required to draw all possible segments between integer points from 0 to N such that no two segments in the same layer overlap. The solution involves finding the maximum number of overlapping segments at any point on the coordinate axis.
### Appro... | true | ||
8db0bc286b569043a28bd31c19f4c65b | Shaass and Oskols | Shaass has decided to hunt some birds. There are *n* horizontal electricity wires aligned parallel to each other. Wires are numbered 1 to *n* from top to bottom. On each wire there are some oskols sitting next to each other. Oskol is the name of a delicious kind of birds in Shaass's territory. Supposed there are *a**i*... | {"inputs": ["5\n10 10 10 10 10\n5\n2 5\n3 13\n2 12\n1 13\n4 6", "3\n2 4 1\n1\n2 2", "5\n58 51 45 27 48\n5\n4 9\n5 15\n4 5\n5 8\n1 43", "10\n48 53 10 28 91 56 81 2 67 52\n2\n2 40\n6 51", "2\n72 45\n6\n1 69\n2 41\n1 19\n2 7\n1 5\n2 1", "10\n95 54 36 39 98 30 19 24 14 12\n3\n9 5\n8 15\n7 5", "100\n95 15 25 18 64 62 23 59 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 397 | codeforces | Okay, let's try to figure out how to solve this problem. Hmm. The problem is about Shaass shooting birds on wires and the birds scattering. So whenever a bird is shot, the ones to its left jump up to the wire above (if exists) and the ones to the right jump down to the wire below (if exists). Otherwise, they fly away. ... | To solve this problem, we need to simulate the process of shooting birds on parallel wires and track how the remaining birds move to adjacent wires or fly away. Each time a bird is shot, the birds to its left move up to the wire above (if it exists) and the birds to its right move down to the wire below (if it exists).... | true | ||
8dbf384ae645ced530cdc48451343e58 | Pipeline | Vova, the Ultimate Thule new shaman, wants to build a pipeline. As there are exactly *n* houses in Ultimate Thule, Vova wants the city to have exactly *n* pipes, each such pipe should be connected to the water supply. A pipe can be connected to the water supply if there's water flowing out of it. Initially Vova has onl... | {"inputs": ["4 3", "5 5", "8 4", "1000000000000000000 1000000000", "499999998500000001 1000000000", "499999998500000000 1000000000", "499999999500000000 1000000000", "499999999500000001 1000000000", "525 34", "223265034477 726990", "15597035789572051 185473109", "499999999500000002 1000000000", "1 1000000000", "1000000... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 50 | codeforces | Okay, let's try to solve this problem. So, the task is to find the minimum number of splitters needed to get exactly n pipes with flowing water. The splitters available are from 2 up to k outputs. Each splitter can be used once. And each time a splitter is connected, it replaces one existing pipe (with water) into x ne... | To solve this problem, we need to determine the minimum number of splitters required to ensure exactly `n` pipes have flowing water, using splitters that can split a single pipe into `2` to `k` outputs. The solution involves a systematic approach to find the optimal number of splitters using mathematical insights and b... | true | ||
8dd48a95d077948b9426c6505bdbe45c | none | This is an interactive problem.
Jury has hidden a permutation *p* of integers from 0 to *n*<=-<=1. You know only the length *n*. Remind that in permutation all integers are distinct.
Let *b* be the inverse permutation for *p*, i.e. *p**b**i*<==<=*i* for all *i*. The only thing you can do is to ask xor of elements *p*... | {"inputs": ["3\n0 1 2", "4\n3 1 2 0", "4\n3 2 1 0", "8\n2 3 0 1 4 5 6 7", "1\n0", "10\n0 1 2 3 4 5 6 7 8 9", "6\n0 1 2 4 3 5", "2\n0 1", "10\n6 7 4 5 0 1 8 9 2 3", "10\n9 8 1 7 6 4 5 2 0 3", "64\n0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | Okay, let's try to understand this problem. We need to find the number of permutations that are indistinguishable from the hidden one based on the XOR queries we make. Then, we have to output that count and one such permutation. The challenge is to do this with no more than 2n queries.
First, let's recap some key poin... | To solve this problem, we need to determine the number of permutations indistinguishable from a hidden permutation based on XOR queries and print one such permutation. The solution involves making strategic queries and validating potential permutations efficiently.
### Approach
1. **Initial Queries**: Query the XOR of... | false | Code is incorrect. | |
8e200e66a6bc8b339fc2303f84d097ff | Geometrical Progression | For given *n*, *l* and *r* find the number of distinct geometrical progression, each of which contains *n* distinct integers not less than *l* and not greater than *r*. In other words, for each progression the following must hold: *l*<=≤<=*a**i*<=≤<=*r* and *a**i*<=≠<=*a**j* , where *a*1,<=*a*2,<=...,<=*a**n* is the ge... | {"inputs": ["1 1 10", "2 6 9", "3 1 10", "3 3 10", "1 25 845", "2 25 845", "3 25 845", "4 25 845", "5 25 845", "6 25 845", "7 25 845", "8 25 845", "1 1 10000000", "2 1 10000000", "3 1 10000000", "4 1 10000000", "5 1 10000000", "6 1 10000000", "7 1 10000000", "8 1 10000000", "9 1 10000000", "10 1 10000000", "11 1 100000... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | Okay, let's try to figure out this problem. The task is to find the number of distinct geometric progressions of length n where each element is between l and r inclusive, and all elements are distinct. Hmm, geometric progression (GP) with possible non-integer ratios. Oh right, and two GPs are different if any element d... | To solve this problem, we need to count the number of distinct geometric progressions (GP) of length `n` where each element is an integer within the range `[l, r]` and all elements are distinct. The solution must efficiently handle large values of `n`, `l`, and `r`.
### Approach
1. **Special Case for n=1**: If `n` is ... | false | Code is incorrect. | |
8e2fa585a4cce90d151115947a7dfe76 | Maximal Binary Matrix | You are given matrix with *n* rows and *n* columns filled with zeroes. You should put *k* ones in it in such a way that the resulting matrix is symmetrical with respect to the main diagonal (the diagonal that goes from the top left to the bottom right corner) and is lexicographically maximal.
One matrix is lexicograph... | {"inputs": ["2 1", "3 2", "2 5", "1 0", "1 1", "20 398", "20 401", "100 3574", "100 10000", "100 10001", "2 3", "4 5", "5 6", "5 24", "2 0", "3 5", "3 3", "5 10", "3 4", "4 3", "1 1000000", "3 6", "1 2", "1 0", "1 1", "1 2", "1 3", "1 4", "1 5", "1 6", "1 7", "1 8", "1 9", "1 10", "1 11", "1 12", "1 13", "1 14", "1 15"... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 99 | codeforces | Okay, so I need to solve this programming problem where I have to generate a symmetric matrix with exactly k ones such that it's lexicographically maximal. Hmm. Let's think through the problem step by step.
First, let's understand the problem statement again. The matrix has to be symmetric with respect to the main dia... | To solve this problem, we need to generate a symmetric matrix filled with exactly `k` ones such that the matrix is lexicographically maximal. The matrix must be symmetrical with respect to its main diagonal, and if it's impossible to create such a matrix, we should return `-1`.
### Approach
1. **Feasibility Check**: ... | false | Code is incorrect. | |
8e4411543e2b85f1a8bb736483bfdbcb | Beautiful Divisors | Recently Luba learned about a special kind of numbers that she calls beautiful numbers. The number is called beautiful iff its binary representation consists of *k*<=+<=1 consecutive ones, and then *k* consecutive zeroes.
Some examples of beautiful numbers:
- 12 (110); - 1102 (610); - 11110002 (12010); - 1111100... | {"inputs": ["3", "992", "81142", "76920", "2016", "1", "6", "32640", "12096", "55948", "47262", "22876", "96120", "42160", "38304", "89408", "97920", "55493", "38021", "21445", "100000", "497", "240", "21204", "65536", "364", "1024", "36", "28", "14400", "10080", "9", "2", "42", "83160", "65534", "1026", "1025", "1027"... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 83 | codeforces | Okay, let's tackle this problem step by step. The task is to find the greatest beautiful divisor of a given number n. Hmm, what's a beautiful number again? Oh right, a beautiful number in binary has k+1 consecutive 1's followed by k consecutive 0's. Wait, wait, the formal definition says that the number must be equal t... | To solve this problem, we need to find the greatest beautiful divisor of a given number \( n \). A beautiful number is defined as a number whose binary representation consists of \( k+1 \) consecutive ones followed by \( k \) consecutive zeros. Formally, a number is beautiful if it can be expressed as \((2^k - 1) \time... | true | ||
8e50612d70a28d84b770df9166669c6b | The Monster | As Will is stuck in the Upside Down, he can still communicate with his mom, Joyce, through the Christmas lights (he can turn them on and off with his mind). He can't directly tell his mom where he is, because the monster that took him to the Upside Down will know and relocate him.
Thus, he came up with a puzzle to te... | {"inputs": ["((?))", "??()??", "?????)(???", "()()((?(()(((()()(())(((()((())))(()))(()(((((())))()))(((()()()))))))(((((()))))))))", "))((()(()((((()))())()())((())())(((()()(())))))((())()()(()()(())()))()()(()()()(((()(()(()(()))))(", "?????????????????????????????????????????????????????????????????????????????????... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 10 | codeforces | Okay, let's see. The problem is about counting the number of substrings of a given string that can form a correct bracket sequence after replacing the question marks with either '(' or ')'. And a correct bracket sequence has to be non-empty, so the empty string isn't considered here.
Hmm, right. So first, I need to u... | To solve this problem, we need to determine the number of substrings of a given string that can be transformed into a correct bracket sequence by replacing '?' characters with either '(' or ')'. A correct bracket sequence is defined as a non-empty string where the parentheses are balanced and properly nested.
### Appr... | true | ||
8e64f356f5e4e4ae535eb42d9e1ea3df | Fancy Fence | Emuskald needs a fence around his farm, but he is too lazy to build it himself. So he purchased a fence-building robot.
He wants the fence to be a regular polygon. The robot builds the fence along a single path, but it can only make fence corners at a single angle *a*.
Will the robot be able to build the fence Emuska... | {"inputs": ["3\n30\n60\n90", "6\n1\n2\n3\n170\n179\n25"], "outputs": ["NO\nYES\nYES", "NO\nNO\nNO\nYES\nYES\nNO"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 625 | codeforces | Okay, I need to solve this problem where Emuskald wants to know if a regular polygon can be built with all its internal angles equal to a given angle 'a'. The input is multiple test cases, each with an angle a, and for each, I have to output YES or NO based on whether such a polygon exists.
Hmm, let's start by recalli... | To solve this problem, we need to determine if a regular polygon can be constructed such that each of its internal angles is equal to a given angle 'a'. The solution involves checking if such a polygon exists using geometric properties of regular polygons.
### Approach
1. **Understanding Regular Polygon Angles**: The ... | true | ||
8e719483e5e5418e54575f188ffb7458 | Holes | Little Petya likes to play a lot. Most of all he likes to play a game «Holes». This is a game for one person with following rules:
There are *N* holes located in a single row and numbered from left to right with numbers from 1 to *N*. Each hole has it's own power (hole number *i* has the power *a**i*). If you throw a ... | {"inputs": ["8 5\n1 1 1 1 1 2 8 2\n1 1\n0 1 3\n1 1\n0 3 4\n1 2", "10 10\n5 1 2 4 1 7 3 8 10 8\n0 5 6\n1 8\n1 1\n0 10 3\n1 5\n1 3\n1 2\n0 6 1\n1 9\n1 1"], "outputs": ["8 7\n8 5\n7 3", "8 1\n6 2\n5 1\n5 2\n5 3\n9 1\n10 4"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 2 | codeforces | Okay, let's see. I need to solve this programming problem. Let's read the problem statement carefully.
So, the problem is about holes arranged in a row, each with a certain power. When a ball is thrown into a hole, it jumps according to the power of each hole. For each move, we can either update the power of a hole or... | To solve this problem, we need to efficiently handle two types of operations on an array of holes: updating the power of a specific hole and simulating the process of throwing a ball into a hole to determine the number of jumps and the last hole visited before the ball exits the array. Given the constraints, a direct s... | true | ||
8e83fc290467bbae2f2bbd15052cee39 | Long number | Consider the following grammar:
- <expression> ::= <term> | <expression> '+' <term>- <term> ::= <number> | <number> '-' <number> | <number> '(' <expression> ')'- <number> ::= <pos_digit> | <number> <digit>- <digit> ::= '0' | &... | {"inputs": ["8-11", "2(2-4+1)+2(2(17))", "1234-5678", "1+2+3+4-5+6+7-9", "598777", "49603501749575096738857", "11-57", "7177-57797", "4510812433666-7741104736713", "4778066503(27032-80044+16+51+58(9)+5668114736297420472+2336+6-117+8495(7265))", "9678329648012859556810940272201-70370609657815505164700664074744+288702310... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | Okay, so I need to solve this programming problem where I have to parse an expression according to a given grammar and compute the resulting number modulo 1e9+7. Let's see. The input is a string that follows the grammar rules, and I have to output the modulo of the number it represents.
First, let's understand the gra... | To solve this problem, we need to parse an expression according to a given grammar and compute the resulting number modulo \(10^9 + 7\). The grammar includes terms that can be numbers, ranges of numbers, repeated expressions, and concatenations of terms. The challenge is to handle very large numbers efficiently by leve... | false | Code is incorrect. | |
8e884a3f9a82d8283675daa517424cea | Buying A House | Zane the wizard had never loved anyone before, until he fell in love with a girl, whose name remains unknown to us.
The girl lives in house *m* of a village. There are *n* houses in that village, lining in a straight line from left to right: house 1, house 2, ..., house *n*. The village is also well-structured: house ... | {"inputs": ["5 1 20\n0 27 32 21 19", "7 3 50\n62 0 0 0 99 33 22", "10 5 100\n1 0 1 0 0 0 0 0 1 1", "5 3 1\n1 1 0 0 1", "5 5 5\n1 0 5 6 0", "15 10 50\n20 0 49 50 50 50 50 50 50 0 50 50 49 0 20", "7 5 1\n0 100 2 2 0 2 1", "100 50 100\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 329 | codeforces | Okay, let's tackle this problem step by step. So, the goal is to find the minimum distance between the girl's house (which is house m) and some house that Zane can buy. The distance is calculated based on their positions in the village, where each adjacent house is 10 meters apart.
First, I need to understand the inp... | To solve this problem, we need to determine the minimum distance from Zane's crush's house to the nearest house that Zane can afford to buy. The houses are arranged in a straight line, and each adjacent pair of houses is 10 meters apart. The solution involves checking each house for availability and affordability, then... | true | ||
8e997023d723a3471ac07fd67fc26280 | Gargari and Permutations | Gargari got bored to play with the bishops and now, after solving the problem about them, he is trying to do math homework. In a math book he have found *k* permutations. Each of them consists of numbers 1,<=2,<=...,<=*n* in some order. Now he should find the length of the longest common subsequence of these permutatio... | {"inputs": ["4 3\n1 4 2 3\n4 1 2 3\n1 2 4 3", "6 3\n2 5 1 4 6 3\n5 1 4 3 2 6\n5 4 2 6 3 1", "41 4\n24 15 17 35 13 41 4 14 23 5 8 16 21 18 30 36 6 22 11 29 26 1 40 31 7 3 32 10 28 38 12 20 39 37 34 19 33 27 2 25 9\n22 13 25 24 38 35 29 12 15 8 11 37 3 19 4 23 18 32 30 40 36 21 16 34 27 9 5 41 39 2 14 17 31 33 26 7 1 10 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 9 | codeforces | Okay, so I need to find the longest common subsequence (LCS) among k permutations. Hmm, the problem says that each permutation is of numbers 1 to n. And the LCS has to be common to all of them. But wait, permutations can be different, so the LCS isn't necessarily a contiguous sequence.
Let me think. For two sequences... | To solve this problem, we need to find the length of the longest common subsequence (LCS) among multiple permutations of numbers from 1 to n. The key insight is that the LCS of multiple permutations is the longest sequence of elements where each element appears in the same relative order in all permutations.
### Appro... | true | ||
8ea2947adf1fbbc23b60a162d770b3ba | Alyona and flowers | Little Alyona is celebrating Happy Birthday! Her mother has an array of *n* flowers. Each flower has some mood, the mood of *i*-th flower is *a**i*. The mood can be positive, zero or negative.
Let's define a subarray as a segment of consecutive flowers. The mother suggested some set of subarrays. Alyona wants to choos... | {"inputs": ["5 4\n1 -2 1 3 -4\n1 2\n4 5\n3 4\n1 4", "4 3\n1 2 3 4\n1 3\n2 4\n1 1", "2 2\n-1 -2\n1 1\n1 2", "5 6\n1 1 1 -1 0\n2 4\n1 3\n4 5\n1 5\n1 4\n4 5", "8 3\n5 -4 -2 5 3 -4 -2 6\n3 8\n4 6\n2 3", "10 10\n0 0 0 0 0 0 0 0 0 0\n5 9\n1 9\n5 7\n3 8\n1 6\n1 9\n1 6\n6 9\n1 10\n3 8", "3 6\n0 0 0\n1 1\n1 1\n1 3\n3 3\n2 3\n1 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 209 | codeforces | Okay, let's try to understand this problem. So the task is to select some subarrays from the given list of suggested ones such that the total happiness Alyona gets is maximized. Each flower's contribution is its mood multiplied by the number of times it appears in the selected subarrays. So, the goal is to choose subar... | To solve this problem, we need to determine the maximum possible value added to Alyona's happiness by selecting subarrays from those suggested by her mother. Each subarray contributes to the happiness based on the sum of the moods of the flowers within it. The goal is to select subarrays that maximize this total contri... | true | ||
8ed90872b9454656dda60a242d493820 | Ebony and Ivory | Dante is engaged in a fight with "The Savior". Before he can fight it with his sword, he needs to break its shields. He has two guns, Ebony and Ivory, each of them is able to perform any non-negative number of shots.
For every bullet that hits the shield, Ebony deals *a* units of damage while Ivory deals *b* units of ... | {"inputs": ["4 6 15", "3 2 7", "6 11 6", "3 12 15", "5 5 10", "6 6 7", "1 1 20", "12 14 19", "15 12 26", "2 4 8", "4 5 30", "4 5 48", "2 17 105", "10 25 282", "6 34 323", "2 47 464", "4 53 113", "6 64 546", "1 78 725", "1 84 811", "3 100 441", "20 5 57", "14 19 143", "17 23 248", "11 34 383", "20 47 568", "16 58 410", ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 192 | codeforces | Okay, I need to solve this problem where Dante uses two guns to deal exactly c damage. The guns can be used any number of times, including zero. So the problem is to check if there exist non-negative integers x and y such that a*x + b*y = c. Let's think about how to approach this.
First, let's understand the constrain... | To solve this problem, we need to determine if Dante can break the shield by dealing exactly `c` units of damage using two guns, Ebony and Ivory, which deal `a` and `b` units of damage per shot respectively. The solution involves checking if there exist non-negative integers `x` and `y` such that the equation `a*x + b*... | true | ||
8f150d098d84cde9f7d73b00f0091443 | none | Astronaut Natasha arrived on Mars. She knows that the Martians are very poor aliens. To ensure a better life for the Mars citizens, their emperor decided to take tax from every tourist who visited the planet. Natasha is the inhabitant of Earth, therefore she had to pay the tax to enter the territory of Mars.
There are... | {"inputs": ["2 8\n12 20", "3 10\n10 20 30", "5 10\n20 16 4 16 2", "10 5\n4 6 8 6 4 10 2 10 8 6", "20 25\n15 10 5 20 10 5 15 5 15 10 15 5 5 5 5 10 15 20 20 20", "30 30\n11 23 7 30 13 6 25 29 1 15 20 5 28 15 19 22 21 5 27 25 29 10 1 4 12 19 1 5 8 10", "40 30\n16 12 12 22 18 28 32 24 36 26 12 30 22 16 32 30 36 18 20 16 12... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 35 | codeforces | Okay, let's try to figure out this problem. Hmm. So the problem is about finding all possible last digits d in base k that Natasha can form by summing some of the given banknotes. The key here is that the last digit in base k of the total sum must be d. And we need to find all possible d's that are achievable.
Wait, r... | To solve this problem, we need to determine which values of the last digit \( d \) in the Martian number system (base \( k \)) Natasha can form using her banknotes. The solution involves understanding the possible remainders when the sum of banknote values is divided by \( k \).
### Approach
1. **Residue Calculation**... | false | Code is incorrect. | |
8f1d925cbfe50cd21d804490a288b86a | Memory and Scores | Memory and his friend Lexa are competing to get higher score in one popular computer game. Memory starts with score *a* and Lexa starts with score *b*. In a single turn, both Memory and Lexa get some integer in the range [<=-<=*k*;*k*] (i.e. one integer among <=-<=*k*,<=<=-<=*k*<=+<=1,<=<=-<=*k*<=+<=2,<=...,<=<=-<=2,<=... | {"inputs": ["1 2 2 1", "1 1 1 2", "2 12 3 1", "4 6 2 1", "4 6 2 2", "6 4 2 2", "10 1 3 3", "5 3 1 1", "50 22 5 5", "6 20 1 1", "42 42 2 3", "42 42 3 2", "45 54 4 5", "6 5 4 3", "42 42 42 42", "1 100 42 42", "1 100 1000 100", "1 1 1000 100", "100 100 1000 100", "1 8 1 4", "9 4 5 2", "2 6 6 2", "7 8 5 9", "3 7 8 6", "69 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 4 | codeforces | Okay, let's see. The problem is about counting the number of possible games where Memory ends up with a strictly higher score than Lexa after t turns. Both players add a random integer between -k and k each turn. So each turn, both choose a number in that range. The total possible games are (2k+1)^(2t) since each of th... | To solve this problem, we need to determine the number of possible games where Memory ends up with a strictly higher score than Lexa after exactly `t` turns. Each turn, both players add a random integer between `-k` and `k` to their scores. The solution involves dynamic programming and efficient computation using prefi... | true | ||
8f73f953a8856ca3a4c9cf3d04b14148 | TL | Valera wanted to prepare a Codesecrof round. He's already got one problem and he wants to set a time limit (TL) on it.
Valera has written *n* correct solutions. For each correct solution, he knows its running time (in seconds). Valera has also wrote *m* wrong solutions and for each wrong solution he knows its running ... | {"inputs": ["3 6\n4 5 2\n8 9 6 10 7 11", "3 1\n3 4 5\n6", "2 5\n45 99\n49 41 77 83 45", "50 50\n18 13 5 34 10 36 36 12 15 11 16 17 14 36 23 45 32 24 31 18 24 32 7 1 31 3 49 8 16 23 3 39 47 43 42 38 40 22 41 1 49 47 9 8 19 15 29 30 16 18\n91 58 86 51 94 94 73 84 98 69 74 56 52 80 88 61 53 99 88 50 55 95 65 84 87 79 51 5... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 305 | codeforces | Okay, I need to solve this programming problem. Let's read the problem statement carefully.
Valera wants to set a time limit v such that several conditions are met. The goal is to find the minimum valid v or output -1 if impossible.
Let me restate the conditions to make sure I understand them:
1. v is a positive int... | To solve this problem, we need to determine the minimum possible time limit (TL) for a programming competition problem such that all correct solutions pass, at least one correct solution passes with some extra time, and all incorrect solutions fail. If no such TL exists, we should return -1.
### Approach
1. **Understa... | true | ||
8f7bee73b29e1a11e67f9279a1507384 | The Child and Set | At the children's day, the child came to Picks's house, and messed his house up. Picks was angry at him. A lot of important things were lost, in particular the favorite set of Picks.
Fortunately, Picks remembers something about his set *S*:
- its elements were distinct integers from 1 to *limit*; - the value of wa... | {"inputs": ["5 5", "4 3", "5 1", "54321 12345", "1997 508", "100000 30000", "100000 100000", "1 100000", "29985 15678", "83451 17526", "96024 12472", "21741 3575", "40287 17817", "58934 6404", "62658 10881", "89829 8298", "5499 1023", "5499 1024", "53689 10552", "247 3270", "58413 1253", "47283 15757", "93145 14496", "... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 104 | codeforces | Okay, let's see. The problem is to find a set of distinct integers from 1 to limit such that the sum of their lowbit values equals the given sum. If there's no such set, we return -1. Hmm.
First, I need to understand what lowbit is. Oh right, lowbit(x) is the value of the least significant bit that's set to 1 in x's b... | To solve this problem, we need to find a set of distinct integers from 1 to a given limit such that the sum of their lowbit values equals a specified sum. The lowbit of a number is the value of the least significant bit that is set to 1 in its binary representation.
### Approach
1. **Understanding Lowbit**: The lowbit... | false | Code is incorrect. | |
8f93f9bd8f9064af561ecdf39f5a1e37 | Alternating Current | Mad scientist Mike has just finished constructing a new device to search for extraterrestrial intelligence! He was in such a hurry to launch it for the first time that he plugged in the power wires without giving it a proper glance and started experimenting right away. After a while Mike observed that the wires ended u... | {"inputs": ["-++-", "+-", "++", "-", "+-+-", "-+-", "-++-+--+", "+", "-+", "--", "+++", "--+", "++--++", "+-++-+", "+-+--+", "--++-+", "-+-+--", "+-+++-", "-+-+-+", "-++-+--++--+-++-", "+-----+-++---+------+++-++++", "-+-++--+++-++++---+--+----+--+-+-+++-+++-+---++-++++-+--+--+--+-+-++-+-+-++++++---++--+++++-+--++--+-+... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 189 | codeforces | Okay, let's tackle this problem. Hmm. The problem is about determining whether two wires can be untangled based on a sequence of steps. The key is that the wires can't cross each other once untangled. Wait, right, because if they are untangled, they must form a simple path from left to right without any overlaps. So th... | To solve this problem, we need to determine if two wires can be untangled based on a sequence of steps where each step indicates which wire is on top. The key insight is that the wires can be untangled if the sequence of steps can be reduced to an empty sequence by repeatedly removing adjacent pairs of opposite steps.
... | true | ||
8fa59503460967189c33fd84aaf7e67c | Help Farmer | Once upon a time in the Kingdom of Far Far Away lived Sam the Farmer. Sam had a cow named Dawn and he was deeply attached to her. Sam would spend the whole summer stocking hay to feed Dawn in winter. Sam scythed hay and put it into haystack. As Sam was a bright farmer, he tried to make the process of storing hay simple... | {"inputs": ["4", "7", "12", "1", "6", "8", "9", "14", "15", "16", "18", "20", "299999771", "54", "96", "348", "748", "908", "1026", "1985", "4472", "20845", "50480", "62497", "646055", "790620", "989903", "7033800", "7661860", "7834243", "45134118", "89054701", "99264891", "127039320", "206898748", "231136953", "257259... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 17 | codeforces | Okay, let's tackle this programming problem. Hmm, the problem statement is a bit complex, but I'll try to break it down step by step.
So, the problem is about calculating the minimum and maximum number of stolen hay blocks based on the remaining blocks after a theft. Let me restate the problem in my own words.
Sam ha... | To solve this problem, we need to determine the minimum and maximum number of hay blocks stolen by thieves based on the remaining blocks counted by Sam. The problem involves analyzing the possible dimensions of the original haystack structure and computing the stolen blocks efficiently.
### Approach
1. **Problem Analy... | true | ||
8fc062d952d56f65554254a2fbe9f3e8 | none | Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Petya loves long lucky numbers very much. He is interested in the minimum lucky number *d* that me... | {"inputs": ["2 2 1 1", "4 7 3 1", "4 7 4 7", "1 1 1 1", "2 2 1 2", "2 1 2 1", "2 2 2 1", "3 3 1 1", "3 2 1 2", "2 1 3 1", "7 7 1 1", "4 7 2 1", "3 3 2 2", "4 3 2 1", "4 4 2 2", "1000000 1000000 1 1", "1000000 1 1 1", "10 10 3 5", "10 10 3 7", "1 7 1 1", "8 3 2 1", "1000000 1000000 1000000 1000000", "4584 45854 25 685",... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 6 | codeforces | Okay, I need to solve this programming problem. Let's read the problem carefully.
So, Petya wants the minimum lucky number d (made of 4s and 7s) such that the counts of 4, 7, 47, and 74 as substrings are <= a1, a2, a3, a4 respectively. And if there's no such number, output -1.
Hmm. The challenge is to find the smalle... | To solve this problem, we need to find the smallest lucky number (composed only of digits 4 and 7) that meets specific constraints on the counts of individual digits (4 and 7) and their pairs (47 and 74). The solution must be generated in lexicographical order and must contain both digits 4 and 7.
### Approach
1. **Le... | false | Code is incorrect. | |
8fca4ffe8f07d1e257b834639a4873d8 | Hulk | Dr. Bruce Banner hates his enemies (like others don't). As we all know, he can barely talk when he turns into the incredible Hulk. That's why he asked you to help him to express his feelings.
Hulk likes the Inception so much, and like that his feelings are complicated. They have *n* layers. The first layer is hate, se... | {"inputs": ["1", "2", "3", "4", "5", "10", "18", "19", "76", "77", "81", "82", "85", "86", "100", "99", "98", "33", "34", "57", "100"], "outputs": ["I hate it", "I hate that I love it", "I hate that I love that I hate it", "I hate that I love that I hate that I love it", "I hate that I love that I hate that I love that... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 532 | codeforces | Okay, I need to solve this problem where Dr. Banner's feelings alternate between hate and love in layers. Let's see the examples again. For n=1, it's "I hate it". For n=2, it alternates to "I hate that I love it". And for n=3, it's "hate, love, hate" connected with "that". So the pattern is that each layer alternates b... | To solve this problem, we need to generate a string that represents Dr. Bruce Banner's alternating feelings of hate and love based on the given number of layers. The feelings start with hate and alternate with each subsequent layer, ending with "it".
### Approach
1. **Understand the Pattern**: The feelings alternate b... | false | Code is incorrect. | |
8fd162f8011e9ed6789a81a11aa77d54 | Winter is here | Winter is here at the North and the White Walkers are close. John Snow has an army consisting of *n* soldiers. While the rest of the world is fighting for the Iron Throne, he is going to get ready for the attack of the White Walkers.
He has created a method to know how strong his army is. Let the *i*-th soldier’s stre... | {"inputs": ["3\n3 3 1", "4\n2 3 4 6"], "outputs": ["12", "39"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 5 | codeforces | Okay, let's see. The problem is about calculating the strength of John Snow's army based on clans. Each clan is a non-empty subset of soldiers in increasing order (so the indices are strictly increasing, but the actual order of selection is such that the elements are a subsequence of the original array). The strength o... | To solve this problem, we need to compute the strength of John Snow's army based on the strength of all possible clans. A clan is a non-empty subsequence of soldiers where the greatest common divisor (GCD) of their strengths is greater than 1. The strength of each clan is defined as the product of the clan's size and i... | true | ||
902081dac1e789e7037f497776442362 | Recover Polygon (easy) | The zombies are gathering in their secret lair! Heidi will strike hard to destroy them once and for all. But there is a little problem... Before she can strike, she needs to know where the lair is. And the intel she has is not very good.
Heidi knows that the lair can be represented as a rectangle on a lattice, with si... | {"inputs": ["6\n000000\n000000\n012100\n024200\n012100\n000000", "6\n000000\n012210\n024420\n012210\n000000\n000000", "6\n000100\n001210\n002420\n001210\n000000\n000000", "10\n0000000000\n0122210000\n0244420100\n0122210000\n0000000000\n0000000000\n0000000000\n0000000000\n0000000000\n0000000000", "10\n0000000000\n000000... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 5 | codeforces | Okay, let's see. The problem is to determine if a given grid of contamination levels could have been produced by a single axis-aligned rectangle. So each cell's contamination level is the count of its four corners (each a lattice point) that are inside or on the rectangle. The grid is N x N, and we need to check if the... | To solve this problem, we need to determine if a given grid of contamination levels could have been produced by a single axis-aligned rectangle. Each cell's contamination level is the count of its four corners that lie within or on the border of this rectangle.
### Approach
1. **Check for Contamination Level 4**: If ... | true | ||
903195a712890e0984e95392fc3fad6d | Positions in Permutations | Permutation *p* is an ordered set of integers *p*1,<=<=*p*2,<=<=...,<=<=*p**n*, consisting of *n* distinct positive integers, each of them doesn't exceed *n*. We'll denote the *i*-th element of permutation *p* as *p**i*. We'll call number *n* the size or the length of permutation *p*1,<=<=*p*2,<=<=...,<=<=*p**n*.
We'l... | {"inputs": ["1 0", "2 1", "3 2", "4 1", "7 4", "7 7", "8 4", "8 5", "10 3", "20 0", "100 99", "13 13", "100 100", "1000 0", "1000 1", "1000 2", "1000 10", "1000 99", "1000 500", "1000 700", "1000 900", "1000 999", "1000 998", "1000 1000", "999 0", "999 1", "999 5", "999 13", "999 300", "999 600", "999 999", "999 989", ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 2 | codeforces | Okay, so I need to find the number of permutations of size n with exactly k good positions. And the answer has to be modulo 1e9+7. Let's think about this step by step.
First, what's a good position? The condition is |p[i] - i| ≤ 1. Wait, no, the problem says |p_i - i| ≤ 1. So for position i, the element there can be i... | To solve this problem, we need to count the number of permutations of size `n` with exactly `k` good positions, where a position `i` is considered good if the absolute difference between the element at that position and its index is exactly 1. The result should be printed modulo `1000000007`.
### Approach
The solution... | false | Code is incorrect. | |
903758cfd129ec5da50a446fab0de40f | Mahmoud and Ehab and the function | Dr. Evil is interested in math and functions, so he gave Mahmoud and Ehab array *a* of length *n* and array *b* of length *m*. He introduced a function *f*(*j*) which is defined for integers *j*, which satisfy 0<=≤<=*j*<=≤<=*m*<=-<=*n*. Suppose, *c**i*<==<=*a**i*<=-<=*b**i*<=+<=*j*. Then *f*(*j*)<==<=|*c*1<=-<=*c*2<=+<... | {"inputs": ["5 6 3\n1 2 3 4 5\n1 2 3 4 5 6\n1 1 10\n1 1 -9\n1 5 -1", "1 1 1\n937982044\n179683049\n1 1 821220804"], "outputs": ["0\n9\n0\n0", "758298995\n1579519799"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | Okay, let's try to tackle this problem. Hmm. So the problem is about computing the minimum value of a function f(j) after some updates to the array a. Let's read the problem statement carefully.
So, the function f(j) is defined for each j such that 0 ≤ j ≤ m - n. For each j, we create an array c where c_i = a_i - b_{i... | To solve this problem, we need to determine the minimum value of the function \( f(j) \) after each update query on the array \( a \). The function \( f(j) \) is defined as the absolute value of an alternating sum derived from arrays \( a \) and \( b \).
### Approach
1. **Precompute Initial Values**: Calculate the ini... | true | ||
904ddf9a4d594b95a85d8cf3bef73636 | Turn Off The TV | Luba needs your help again! Luba has *n* TV sets. She knows that *i*-th TV set will be working from moment of time *l**i* till moment *r**i*, inclusive.
Luba wants to switch off one of TV sets in order to free the socket. Let's call some TV set redundant if after switching it off the number of integer moments of time ... | {"inputs": ["3\n1 3\n4 6\n1 7", "2\n0 10\n0 10", "3\n1 2\n3 4\n6 8", "3\n1 2\n2 3\n3 4", "3\n0 500000000\n500000001 1000000000\n0 1000000000", "3\n1 5\n2 4\n6 10", "10\n4 4\n5 9\n5 7\n2 8\n6 10\n4 10\n1 3\n8 9\n0 0\n5 7", "2\n1 3\n2 4", "1\n8 9", "8\n13 17\n83 89\n31 33\n7 13\n52 52\n88 89\n29 30\n16 22", "4\n63 63\n12... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 9 | codeforces | Okay, let's see. The problem is to find a redundant TV set. A redundant TV is one that, when removed, doesn't decrease the total coverage of time where at least one TV is on. So the idea is to find which TV's interval is completely overlapped by the union of the other intervals. Because if removing it doesn't change th... | To solve this problem, we need to determine if there exists a TV set that can be switched off without reducing the total coverage of time during which at least one TV is working. This TV set is considered redundant. The solution involves checking if the interval of a TV set is completely covered by the union of other T... | false | Code is incorrect. | |
90b3babebf9e99d1cac2b06764636584 | none | You are given a rectangular parallelepiped with sides of positive integer lengths $A$, $B$ and $C$.
Find the number of different groups of three integers ($a$, $b$, $c$) such that $1\leq a\leq b\leq c$ and parallelepiped $A\times B\times C$ can be paved with parallelepipeds $a\times b\times c$. Note, that all small p... | {"inputs": ["4\n1 1 1\n1 6 1\n2 2 2\n100 100 100", "10\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1", "10\n9 6 8\n5 5 2\n8 9 2\n2 7 9\n6 4 10\n1 1 8\n2 8 1\n10 6 3\n7 5 2\n9 5 4", "1\n100000 100000 100000"], "outputs": ["1\n4\n4\n165", "1\n1\n1\n1\n1\n1\n1\n1\n1\n1", "41\n6\n21\n12\n39\n4\n7\n2... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 2 | codeforces | Okay, so I need to solve this problem where I have to find the number of different triplets (a, b, c) such that a ≤ b ≤ c and the original parallelepiped A×B×C can be completely filled with small a×b×c blocks, all oriented the same way. Hmm, right.
Let me start by understanding the problem. The key is that the origina... | To solve this problem, we need to determine the number of distinct triplets (a, b, c) such that a ≤ b ≤ c and the original parallelepiped with dimensions A, B, and C can be completely filled with smaller parallelepipeds of dimensions a×b×c, all oriented in the same direction.
### Approach
1. **Sort the Dimensions**: ... | false | Code is incorrect. | |
90c3ae3432be76316c44df8b294d09fc | Money Transfers | There are *n* banks in the city where Vasya lives, they are located in a circle, such that any two banks are neighbouring if their indices differ by no more than 1. Also, bank 1 and bank *n* are neighbours if *n*<=><=1. No bank is a neighbour of itself.
Vasya has an account in each bank. Its balance may be negative... | {"inputs": ["3\n5 0 -5", "4\n-1 0 1 0", "4\n1 2 3 -6", "1\n0", "50\n108431864 128274949 -554057370 -384620666 -202862975 -803855410 -482167063 -55139054 -215901009 0 0 0 0 0 94325701 730397219 358214459 -673647271 -131397668 -377892440 0 0 0 0 0 -487994257 -360271553 639988328 489338210 -281060728 250208758 0 993242346... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 28 | codeforces | Okay, I need to solve this programming problem. Let's read the problem carefully.
So, the problem is about banks arranged in a circle. Each bank has a balance, and we need to make all balances zero using the minimum number of operations. Each operation allows transferring any amount from a bank to a neighboring bank. ... | To solve this problem, we need to determine the minimum number of operations required to balance the accounts of banks arranged in a circle. Each operation allows transferring any amount of money between neighboring banks. The goal is to achieve a zero balance in each bank with the minimum number of operations.
### Ap... | true | ||
90c94d1f5e83e4c8b0d3186dacb5a837 | Good Number | Let's call a number *k*-good if it contains all digits not exceeding *k* (0,<=...,<=*k*). You've got a number *k* and an array *a* containing *n* numbers. Find out how many *k*-good numbers are in *a* (count each number every time it occurs in array *a*).
The first line contains integers *n* and *k* (1<=≤<=*n*<=≤<=100,... | {"inputs": ["10 6\n1234560\n1234560\n1234560\n1234560\n1234560\n1234560\n1234560\n1234560\n1234560\n1234560", "2 1\n1\n10", "1 0\n1000000000", "1 1\n1000000000", "6 0\n10\n102\n120\n1032\n1212103\n1999999", "1 3\n1000000000", "1 9\n1000000000", "1 0\n1", "1 1\n1", "1 3\n1", "1 9\n1", "2 8\n123456780\n123", "2 8\n123456... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 318 | codeforces | Okay, I need to solve this programming problem. Let's read the problem statement carefully.
The task is to count how many numbers in the array are k-good. A k-good number is one where all digits are not exceeding k. So, for example, if k is 3, then each digit in the number must be 0, 1, 2, or 3.
The input starts with... | To solve this problem, we need to determine how many numbers in a given array are *k*-good. A *k*-good number is defined as a number that contains all digits from 0 to *k* and no digits exceeding *k*.
### Approach
1. **Input Reading**: Read the integers *n* (number of elements in the array) and *k*.
2. **Digit Check ... | false | Code is incorrect. | |
90e34ecfae4b0a43ec885c28e8b50ef6 | Фото на память - 2 (round version) | Прошло много лет, и на вечеринке снова встретились *n* друзей. С момента последней встречи техника шагнула далеко вперёд, появились фотоаппараты с автоспуском, и теперь не требуется, чтобы один из друзей стоял с фотоаппаратом, и, тем самым, оказывался не запечатлённым на снимке.
Упрощенно процесс фотографирования можн... | {"inputs": ["3\n10 1\n20 2\n30 3", "3\n3 1\n2 2\n4 3", "1\n5 10", "10\n168 538\n836 439\n190 873\n206 47\n891 591\n939 481\n399 898\n859 466\n701 777\n629 222", "42\n13 62\n114 242\n265 839\n756 349\n298 476\n533 704\n348 277\n554 573\n654 112\n429 836\n574 766\n909 415\n163 891\n532 983\n873 457\n719 117\n1 302\n170 6... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 7 | codeforces | Okay, let's try to solve this problem. So the problem is about finding the minimal possible area of a group photo where each person can either stand or lie down. The area is determined by the total width (sum of all widths) multiplied by the maximum height among all the people. And we need to choose for each person whe... | To solve this problem, we need to determine the minimal possible area of a group photo where each person can either stand or lie down. The area is determined by the total width of all people multiplied by the maximum height among them. Our goal is to find the optimal orientation (standing or lying) for each person to m... | true | ||
912f39a3ff6a9f5dd8230e1c50920c4f | none | Little Chris is very keen on his toy blocks. His teacher, however, wants Chris to solve more problems, so he decided to play a trick on Chris.
There are exactly *s* blocks in Chris's set, each block has a unique number from 1 to *s*. Chris's teacher picks a subset of blocks *X* and keeps it to himself. He will give th... | {"inputs": ["3\n1 4 5", "1\n1", "1\n1000000", "2\n2 999999", "9\n1 2 3 100 500000 500001 999901 999997 999999", "3\n999998 999999 1000000", "3\n1 2 3", "3\n5 345435 999996", "6\n1 10 100 1000 10000 1000000", "2\n1 1000000", "2\n500000 500001", "4\n1 2 999999 1000000", "10\n63649 456347 779 458642 201571 534312 583774 2... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | Okay, let's see. The problem is about finding a subset Y such that the sum of (x_i - 1) for all x in X is equal to the sum of (s - y_i) for all y in Y, where s is 1e6. Oh wait, wait. Let me think again. Because the example given has s=8. The teacher took 1,4,5. Then the sum of (x_i -1) would be (1-1)+(4-1)+(5-1) = 0 +3... | To solve this problem, we need to find a subset Y of blocks such that the sum of the differences between 1,000,000 and each element in Y equals the sum of the differences between each element in the given subset X and 1. The solution involves either finding a single valid element or a pair of elements that satisfy the ... | false | Code is incorrect. | |
9136cb00808749220dc6c0007520b499 | Insomnia cure | «One dragon. Two dragon. Three dragon», — the princess was counting. She had trouble falling asleep, and she got bored of counting lambs when she was nine.
However, just counting dragons was boring as well, so she entertained herself at best she could. Tonight she imagined that all dragons were here to steal her, and ... | {"inputs": ["1\n2\n3\n4\n12", "2\n3\n4\n5\n24", "1\n1\n1\n1\n100000", "10\n9\n8\n7\n6", "8\n4\n4\n3\n65437", "8\n4\n1\n10\n59392", "4\n1\n8\n7\n44835", "6\n1\n7\n2\n62982", "2\n7\n4\n9\n56937", "2\n9\n8\n1\n75083", "8\n7\n7\n6\n69038", "4\n4\n2\n3\n54481", "6\n4\n9\n8\n72628", "9\n7\n8\n10\n42357", "5\n6\n4\n3\n60504",... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 410 | codeforces | Okay, let's see. The problem is about counting how many dragons were damaged by the princess's attacks. The attacks happen every k-th, l-th, m-th, and n-th dragon. So any dragon that is a multiple of any of these numbers should be counted. But we have to make sure that even if a dragon is hit by multiple attacks (like ... | To solve this problem, we need to determine how many dragons were either physically or morally damaged by the princess's attacks. Each attack occurs at regular intervals defined by four integers: k, l, m, and n. The task is to count how many dragons from 1 to d (inclusive) are affected by at least one of these attacks.... | true | ||
913a723377dcbcee617e84424051c006 | Guess the Array | This is an interactive problem. You should use flush operation after each printed line. For example, in C++ you should use fflush(stdout), in Java you should use System.out.flush(), and in Pascal — flush(output).
In this problem you should guess an array *a* which is unknown for you. The only information you have init... | {"inputs": ["5\n4 6 1 5 5", "3\n1 1 1", "4\n100 1 100 1", "10\n9 5 10 7 4 4 8 5 10 5", "3\n1 1 1", "3\n100000 100000 100000", "3\n91906 50782 19777", "15\n5 10 10 7 7 6 4 6 8 10 8 4 10 9 4", "30\n2 3 3 4 3 2 4 4 4 3 3 2 4 2 3 4 4 2 4 3 4 2 2 4 3 3 4 4 4 4", "35\n4 2 2 2 4 4 3 2 4 2 2 4 2 2 3 2 3 4 4 2 3 2 2 4 3 3 3 3 4... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 109 | codeforces | Okay, let's tackle this problem. So, the task is to guess an array of length n by asking at most n queries where each query gives the sum of two elements. Hmm. The challenge is to find a strategy that allows us to determine all elements with exactly n queries. Let me think about how to approach this.
Wait, the sample ... | To solve this problem, we need to guess an unknown array of length `n` using at most `n` queries. Each query asks for the sum of two elements at specified indices. The solution involves forming a cycle of queries and solving the resulting system of equations to determine the array elements.
### Approach
1. **Form a Cy... | false | Code is incorrect. | |
9143317c9ec97376be9a5c100718a323 | Passwords | Vanya is managed to enter his favourite site Codehorses. Vanya uses *n* distinct passwords for sites at all, however he can't remember which one exactly he specified during Codehorses registration.
Vanya will enter passwords in order of non-decreasing their lengths, and he will enter passwords of same length in arbitr... | {"inputs": ["5 2\ncba\nabc\nbb1\nabC\nABC\nabc", "4 100\n11\n22\n1\n2\n22", "1 1\na1\na1", "1 100\na1\na1", "2 1\nabc\nAbc\nAbc", "2 2\nabc\nAbc\nabc", "2 1\nab\nabc\nab", "2 2\nab\nabc\nab", "2 1\nab\nabc\nabc", "2 2\nab\nabc\nabc", "10 3\nOIbV1igi\no\nZS\nQM\n9woLzI\nWreboD\nQ7yl\nA5Rb\nS9Lno72TkP\nfT97o\no", "10 3\n... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 104 | codeforces | Okay, let's try to figure out this problem. So, the problem is about Vanya trying to log in to a site with his passwords, and we need to calculate the best and worst case time he takes to succeed. Hmm. Let's see.
The input gives us n passwords, one of which is correct. The passwords are entered in non-decreasing order... | To solve this problem, we need to determine the minimum and maximum time Vanya will take to log in to his favorite site, considering he enters passwords in non-decreasing order of their lengths and may face delays after a certain number of incorrect attempts.
### Approach
1. **Input Reading and Initialization**: Read ... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.