question large_stringlengths 265 13.2k |
|---|
Solve the programming task below in a Python markdown code block.
A competitive eater, Alice is scheduling some practices for an eating contest on a magical calendar. The calendar is unusual because a week contains not necessarily 7 days!
In detail, she can choose any integer k which satisfies 1 β€ k β€ r, and set k da... |
Solve the programming task below in a Python markdown code block.
Vova decided to clean his room. The room can be represented as the coordinate axis OX. There are n piles of trash in the room, coordinate of the i-th pile is the integer p_i. All piles have different coordinates.
Let's define a total cleanup as the fol... |
Solve the programming task below in a Python markdown code block.
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number x in an array. ... |
Solve the programming task below in a Python markdown code block.
You and your friends live in n houses. Each house is located on a 2D plane, in a point with integer coordinates. There might be different houses located in the same point. The mayor of the city is asking you for places for the building of the Eastern ex... |
Solve the programming task below in a Python markdown code block.
It is well known that Berland has n cities, which form the Silver ring β cities i and i + 1 (1 β€ i < n) are connected by a road, as well as the cities n and 1. The goverment have decided to build m new roads. The list of the roads to build was prepared.... |
Solve the programming task below in a Python markdown code block.
Yaroslav has an array, consisting of (2Β·n - 1) integers. In a single operation Yaroslav can change the sign of exactly n elements in the array. In other words, in one operation Yaroslav can select exactly n array elements, and multiply each of them by -... |
Solve the programming task below in a Python markdown code block.
Valera's finally decided to go on holiday! He packed up and headed for a ski resort.
Valera's fancied a ski trip but he soon realized that he could get lost in this new place. Somebody gave him a useful hint: the resort has n objects (we will consider ... |
Solve the programming task below in a Python markdown code block.
Inna and Dima bought a table of size n Γ m in the shop. Each cell of the table contains a single letter: "D", "I", "M", "A".
Inna loves Dima, so she wants to go through his name as many times as possible as she moves through the table. For that, Inna a... |
Solve the programming task below in a Python markdown code block.
The translation from the Berland language into the Birland language is not an easy task. Those languages are very similar: a berlandish word differs from a birlandish word with the same meaning a little: it is spelled (and pronounced) reversely. For exa... |
Solve the programming task below in a Python markdown code block.
Scrooge McDuck keeps his most treasured savings in a home safe with a combination lock. Each time he wants to put there the treasures that he's earned fair and square, he has to open the lock.
<image>
The combination lock is represented by n rotating ... |
Solve the programming task below in a Python markdown code block.
Little Johnny has recently learned about set theory. Now he is studying binary relations. You've probably heard the term "equivalence relation". These relations are very important in many areas of mathematics. For example, the equality of the two number... |
Solve the programming task below in a Python markdown code block.
The year 2015 is almost over.
Limak is a little polar bear. He has recently learnt about the binary system. He noticed that the passing year has exactly one zero in its representation in the binary system β 201510 = 111110111112. Note that he doesn't c... |
Solve the programming task below in a Python markdown code block.
IT City administration has no rest because of the fame of the Pyramids in Egypt. There is a project of construction of pyramid complex near the city in the place called Emerald Walley. The distinction of the complex is that its pyramids will be not only... |
Solve the programming task below in a Python markdown code block.
The History of Magic is perhaps the most boring subject in the Hogwarts school of Witchcraft and Wizardry. Harry Potter is usually asleep during history lessons, and his magical quill writes the lectures for him. Professor Binns, the history of magic te... |
Solve the programming task below in a Python markdown code block.
Theater stage is a rectangular field of size n Γ m. The director gave you the stage's plan which actors will follow. For each cell it is stated in the plan if there would be an actor in this cell or not.
You are to place a spotlight on the stage in som... |
Solve the programming task below in a Python markdown code block.
There are n employees in Alternative Cake Manufacturing (ACM). They are now voting on some very important question and the leading world media are trying to predict the outcome of the vote.
Each of the employees belongs to one of two fractions: depubli... |
Solve the programming task below in a Python markdown code block.
You are given a convex polygon P with n distinct vertices p1, p2, ..., pn. Vertex pi has coordinates (xi, yi) in the 2D plane. These vertices are listed in clockwise order.
You can choose a real number D and move each vertex of the polygon a distance o... |
Solve the programming task below in a Python markdown code block.
You are given sequence a1, a2, ..., an of integer numbers of length n. Your task is to find such subsequence that its sum is odd and maximum among all such subsequences. It's guaranteed that given sequence contains subsequence with odd sum.
Subsequence... |
Solve the programming task below in a Python markdown code block.
You are given an array a consisting of n elements. The imbalance value of some subsegment of this array is the difference between the maximum and minimum element from this segment. The imbalance value of the array is the sum of imbalance values of all s... |
Solve the programming task below in a Python markdown code block.
Today at the lesson Vitya learned a very interesting function β mex. Mex of a sequence of numbers is the minimum non-negative number that is not present in the sequence as element. For example, mex([4, 33, 0, 1, 1, 5]) = 2 and mex([1, 2, 3]) = 0.
Vitya... |
Solve the programming task below in a Python markdown code block.
You are given an array a of size n, and q queries to it. There are queries of two types:
* 1 li ri β perform a cyclic shift of the segment [li, ri] to the right. That is, for every x such that li β€ x < ri new value of ax + 1 becomes equal to old val... |
Solve the programming task below in a Python markdown code block.
A very brave explorer Petya once decided to explore Paris catacombs. Since Petya is not really experienced, his exploration is just walking through the catacombs.
Catacombs consist of several rooms and bidirectional passages between some pairs of them.... |
Solve the programming task below in a Python markdown code block.
A has a string consisting of some number of lowercase English letters 'a'. He gives it to his friend B who appends some number of letters 'b' to the end of this string. Since both A and B like the characters 'a' and 'b', they have made sure that at this... |
Solve the programming task below in a Python markdown code block.
As we all know that power sets of any set are formed by taking i elements (where i is from 1 to n) and then random shuffling them like this power set of {1,2,3} are {EMPTY SET},{1},{2},{3},{1,2}{1,3}{2,3}{1,2,3} .
Now we have a MODIfied POWER SET which... |
Solve the programming task below in a Python markdown code block.
Given are a sequence of N positive integers A_1, A_2, \ldots, A_N, and a positive integer K.
Find the number of non-empty contiguous subsequences in A such that the remainder when dividing the sum of its elements by K is equal to the number of its elem... |
Solve the programming task below in a Python markdown code block.
We have a permutation p = {p_1,\ p_2,\ ...,\ p_n} of {1,\ 2,\ ...,\ n}.
Print the number of elements p_i (1 < i < n) that satisfy the following condition:
* p_i is the second smallest number among the three numbers p_{i - 1}, p_i, and p_{i + 1}.
Cons... |
Solve the programming task below in a Python markdown code block.
Determine if we can choose K different integers between 1 and N (inclusive) so that no two of them differ by 1.
Constraints
* 1\leq N,K\leq 100
* N and K are integers.
Input
Input is given from Standard Input in the following format:
N K
Output
... |
Solve the programming task below in a Python markdown code block.
There is an N-car train.
You are given an integer i. Find the value of j such that the following statement is true: "the i-th car from the front of the train is the j-th car from the back."
Constraints
* 1 \leq N \leq 100
* 1 \leq i \leq N
Input
In... |
Solve the programming task below in a Python markdown code block.
Takahashi has an N \times M grid, with N horizontal rows and M vertical columns. Determine if we can place A 1 \times 2 tiles (1 vertical, 2 horizontal) and B 2 \times 1 tiles (2 vertical, 1 horizontal) satisfying the following conditions, and construct... |
Solve the programming task below in a Python markdown code block.
Snuke prepared 6 problems for a upcoming programming contest. For each of those problems, Rng judged whether it can be used in the contest or not.
You are given a string S of length 6. If the i-th character of s is `1`, it means that the i-th problem p... |
Solve the programming task below in a Python markdown code block.
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
C... |
Solve the programming task below in a Python markdown code block.
ZhinΓΌ was a child of the Emperor, but he was weaving the machine even if he opened it at the request of his father.
It was a pleasure of the Emperor to wear clothes made of a splendid cloth called Unnishiki woven by ZhinΓΌ. Unnishiki has a short lifespa... |
Solve the programming task below in a Python markdown code block.
problem
One day, Taro, who lives in JOI town, decided to take a walk as a daily routine to improve his health. In JOI town, where Taro lives, he runs in the east-west direction as shown in the figure (H + 1). The road and the north-south direction (W +... |
Solve the programming task below in a Python markdown code block.
Description
KMC sells CDs every year at a coterie spot sale called Comic Market. F was supposed to sell CDs at the comic market, but due to the popularity of F, the KMC sales floor was flooded with people, and the calculation of change could not keep u... |
Solve the programming task below in a Python markdown code block.
Tunnel formula
One day while exploring an abandoned mine, you found a long formula S written in the mine. If you like large numbers, you decide to take out the choke and add `(` or `)` so that the result of the formula calculation is as large as possib... |
Solve the programming task below in a Python markdown code block.
For given two sequences $X$ and $Y$, a sequence $Z$ is a common subsequence of $X$ and $Y$ if $Z$ is a subsequence of both $X$ and $Y$. For example, if $X = \\{a,b,c,b,d,a,b\\}$ and $Y = \\{b,d,c,a,b,a\\}$, the sequence $\\{b,c,a\\}$ is a common subsequ... |
Solve the programming task below in a Python markdown code block.
You have final scores of an examination for n students. Calculate standard deviation of the scores s1, s2 ... sn.
The variance Ξ±2 is defined by
Ξ±2 = (βni=1(si - m)2)/n
where m is an average of si. The standard deviation of the scores is the square ro... |
Solve the programming task below in a Python markdown code block.
Mishka got an integer array a of length n as a birthday present (what a surprise!).
Mishka doesn't like this present and wants to change it somehow. He has invented an algorithm and called it "Mishka's Adjacent Replacements Algorithm". This algorithm c... |
Solve the programming task below in a Python markdown code block.
There is an infinite board of square tiles. Initially all tiles are white.
Vova has a red marker and a blue marker. Red marker can color a tiles. Blue marker can color b tiles. If some tile isn't white then you can't use marker of any color on it. Each... |
Solve the programming task below in a Python markdown code block.
You are given a string s, consisting of n lowercase Latin letters.
A substring of string s is a continuous segment of letters from s. For example, "defor" is a substring of "codeforces" and "fors" is not.
The length of the substring is the number of ... |
Solve the programming task below in a Python markdown code block.
Recently Vasya learned that, given two points with different x coordinates, you can draw through them exactly one parabola with equation of type y = x^2 + bx + c, where b and c are reals. Let's call such a parabola an U-shaped one.
Vasya drew several d... |
Solve the programming task below in a Python markdown code block.
Amugae has a sentence consisting of n words. He want to compress this sentence into one word. Amugae doesn't like repetitions, so when he merges two words into one word, he removes the longest prefix of the second word that coincides with a suffix of th... |
Solve the programming task below in a Python markdown code block.
Your program fails again. This time it gets "Wrong answer on test 233"
.
This is the easier version of the problem. In this version 1 β€ n β€ 2000. You can hack this problem only if you solve and lock both problems.
The problem is about a test containi... |
Solve the programming task below in a Python markdown code block.
Polycarp has decided to decorate his room because the New Year is soon. One of the main decorations that Polycarp will install is the garland he is going to solder himself.
Simple garlands consisting of several lamps connected by one wire are too borin... |
Solve the programming task below in a Python markdown code block.
Your company was appointed to lay new asphalt on the highway of length n. You know that every day you can either repair one unit of the highway (lay new asphalt over one unit of the highway) or skip repairing.
Skipping the repair is necessary because o... |
Solve the programming task below in a Python markdown code block.
Petya has a rectangular Board of size n Γ m. Initially, k chips are placed on the board, i-th chip is located in the cell at the intersection of sx_i-th row and sy_i-th column.
In one action, Petya can move all the chips to the left, right, down or up ... |
Solve the programming task below in a Python markdown code block.
Berland year consists of m months with d days each. Months are numbered from 1 to m. Berland week consists of w days. The first day of the year is also the first day of the week. Note that the last week of the year might be shorter than w days.
A pair ... |
Solve the programming task below in a Python markdown code block.
As meticulous Gerald sets the table, Alexander finished another post on Codeforces and begins to respond to New Year greetings from friends. Alexander has n friends, and each of them sends to Alexander exactly one e-card. Let us number his friends by nu... |
Solve the programming task below in a Python markdown code block.
Recently you've discovered a new shooter. They say it has realistic game mechanics.
Your character has a gun with magazine size equal to k and should exterminate n waves of monsters. The i-th wave consists of a_i monsters and happens from the l_i-th mo... |
Solve the programming task below in a Python markdown code block.
There is a game called "Unique Bid Auction". You can read more about it here: https://en.wikipedia.org/wiki/Unique_bid_auction (though you don't have to do it to solve this problem).
Let's simplify this game a bit. Formally, there are n participants, t... |
Solve the programming task below in a Python markdown code block.
Soroush and Keshi each have a labeled and rooted tree on n vertices. Both of their trees are rooted from vertex 1.
Soroush and Keshi used to be at war. After endless decades of fighting, they finally became allies to prepare a Codeforces round. To cele... |
Solve the programming task below in a Python markdown code block.
Petya is the most responsible worker in the Research Institute. So he was asked to make a very important experiment: to melt the chocolate bar with a new laser device. The device consists of a rectangular field of n Γ m cells and a robotic arm. Each cel... |
Solve the programming task below in a Python markdown code block.
Once n people simultaneously signed in to the reception at the recently opened, but already thoroughly bureaucratic organization (abbreviated TBO). As the organization is thoroughly bureaucratic, it can accept and cater for exactly one person per day. A... |
Solve the programming task below in a Python markdown code block.
Harry Potter has a difficult homework. Given a rectangular table, consisting of n Γ m cells. Each cell of the table contains the integer. Harry knows how to use two spells: the first spell change the sign of the integers in the selected row, the second ... |
Solve the programming task below in a Python markdown code block.
An IPv6-address is a 128-bit number. For convenience, this number is recorded in blocks of 16 bits in hexadecimal record, the blocks are separated by colons β 8 blocks in total, each block has four hexadecimal digits. Here is an example of the correct r... |
Solve the programming task below in a Python markdown code block.
Polar bears like unique arrays β that is, arrays without repeated elements.
You have got a unique array s with length n containing non-negative integers. Since you are good friends with Alice and Bob, you decide to split the array in two. Precisely, yo... |
Solve the programming task below in a Python markdown code block.
It is so boring in the summer holiday, isn't it? So Alice and Bob have invented a new game to play. The rules are as follows. First, they get a set of n distinct integers. And then they take turns to make the following moves. During each move, either Al... |
Solve the programming task below in a Python markdown code block.
The last product of the R2 company in the 2D games' field is a new revolutionary algorithm of searching for the shortest path in a 2 Γ n maze.
Imagine a maze that looks like a 2 Γ n rectangle, divided into unit squares. Each unit square is either an em... |
Solve the programming task below in a Python markdown code block.
Petya has k matches, placed in n matchboxes lying in a line from left to right. We know that k is divisible by n. Petya wants all boxes to have the same number of matches inside. For that, he can move a match from its box to the adjacent one in one move... |
Solve the programming task below in a Python markdown code block.
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down.
Ther... |
Solve the programming task below in a Python markdown code block.
There is a given string S consisting of N symbols. Your task is to find the number of ordered pairs of integers i and j such that
1. 1 β€ i, j β€ N
2. S[i] = S[j], that is the i-th symbol of string S is equal to the j-th.
Input
The single input line c... |
Solve the programming task below in a Python markdown code block.
On February, 30th n students came in the Center for Training Olympiad Programmers (CTOP) of the Berland State University. They came one by one, one after another. Each of them went in, and before sitting down at his desk, greeted with those who were pre... |
Solve the programming task below in a Python markdown code block.
The mobile application store has a new game called "Subway Roller".
The protagonist of the game Philip is located in one end of the tunnel and wants to get out of the other one. The tunnel is a rectangular field consisting of three rows and n columns. ... |
Solve the programming task below in a Python markdown code block.
Genos recently installed the game Zuma on his phone. In Zuma there exists a line of n gemstones, the i-th of which has color ci. The goal of the game is to destroy all the gemstones in the line as quickly as possible.
In one second, Genos is able to ch... |
Solve the programming task below in a Python markdown code block.
Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n Γ n square consisting of equal squares with side length 1. Each square is either empty or consists... |
Solve the programming task below in a Python markdown code block.
Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a ... |
Solve the programming task below in a Python markdown code block.
Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters.
In this problem you should implement the similar functionality.
You are given a ... |
Solve the programming task below in a Python markdown code block.
Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word.
Hongcow has decided to try to make new words from this one. He starts by taking t... |
Solve the programming task below in a Python markdown code block.
Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He howe... |
Solve the programming task below in a Python markdown code block.
Sagheer is working at a kindergarten. There are n children and m different toys. These children use well-defined protocols for playing with the toys:
* Each child has a lovely set of toys that he loves to play with. He requests the toys one after ano... |
Solve the programming task below in a Python markdown code block.
There is an airplane which has n rows from front to back. There will be m people boarding this airplane.
This airplane has an entrance at the very front and very back of the plane.
Each person has some assigned seat. It is possible for multiple people... |
Solve the programming task below in a Python markdown code block.
This year, as in previous years, MemSQL is inviting the top 25 competitors from the Start[c]up qualification round to compete onsite for the final round. Not everyone who is eligible to compete onsite can afford to travel to the office, though. Initiall... |
Solve the programming task below in a Python markdown code block.
Polycarp takes part in a quadcopter competition. According to the rules a flying robot should:
* start the race from some point of a field,
* go around the flag,
* close cycle returning back to the starting point.
Polycarp knows the coordin... |
Solve the programming task below in a Python markdown code block.
The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she ... |
Solve the programming task below in a Python markdown code block.
You are given several queries. Each query consists of three integers p, q and b. You need to answer whether the result of p/q in notation with base b is a finite fraction.
A fraction in notation with base b is finite if it contains finite number of num... |
Solve the programming task below in a Python markdown code block.
You are given a directed graph with N vertices and M edges, not necessarily simple. The i-th edge is oriented from the vertex a_i to the vertex b_i. Divide this graph into strongly connected components and print them in their topological order.
Constra... |
Solve the programming task below in a Python markdown code block.
Given are positive integers N, M, Q, and Q quadruples of integers ( a_i , b_i , c_i , d_i ).
Consider a sequence A satisfying the following conditions:
* A is a sequence of N positive integers.
* 1 \leq A_1 \leq A_2 \le \cdots \leq A_N \leq M.
Let ... |
Solve the programming task below in a Python markdown code block.
Given is a string S. Each character in S is either a digit (`0`, ..., `9`) or `?`.
Among the integers obtained by replacing each occurrence of `?` with a digit, how many have a remainder of 5 when divided by 13? An integer may begin with 0.
Since the ... |
Solve the programming task below in a Python markdown code block.
There are N stones arranged in a row. The i-th stone from the left is painted in the color C_i.
Snuke will perform the following operation zero or more times:
* Choose two stones painted in the same color. Repaint all the stones between them, with the... |
Solve the programming task below in a Python markdown code block.
Cat Snuke is learning to write characters. Today, he practiced writing digits `1` and `9`, but he did it the other way around.
You are given a three-digit integer n written by Snuke. Print the integer obtained by replacing each digit `1` with `9` and e... |
Solve the programming task below in a Python markdown code block.
The season for Snuke Festival has come again this year. First of all, Ringo will perform a ritual to summon Snuke. For the ritual, he needs an altar, which consists of three parts, one in each of the three categories: upper, middle and lower.
He has N ... |
Solve the programming task below in a Python markdown code block.
There is a bar of chocolate with a height of H blocks and a width of W blocks. Snuke is dividing this bar into exactly three pieces. He can only cut the bar along borders of blocks, and the shape of each piece must be a rectangle.
Snuke is trying to di... |
Solve the programming task below in a Python markdown code block.
Welcome to CODE FESTIVAL 2016! In order to celebrate this contest, find a string s that satisfies the following conditions:
* The length of s is between 1 and 5000, inclusive.
* s consists of uppercase letters.
* s contains exactly K occurrences of the... |
Solve the programming task below in a Python markdown code block.
We have N pieces of ropes, numbered 1 through N. The length of piece i is a_i.
At first, for each i (1β€iβ€N-1), piece i and piece i+1 are tied at the ends, forming one long rope with N-1 knots. Snuke will try to untie all of the knots by performing the ... |
Solve the programming task below in a Python markdown code block.
One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There is no suc... |
Solve the programming task below in a Python markdown code block.
Aika's house runs a small coffee shop. The scones baked by Aika's mother were very delicious and the shop was very prosperous.
One of the jobs of Aika, a waitress, is to deliver the scones that are baked one after another to the customer's seat. The ba... |
Solve the programming task below in a Python markdown code block.
Consider a string with rings on both ends. Rings have positive integers to distinguish them. Rings on both ends of the string have different numbers a and b. Describe this as [a, b]. If there are multiple strings and the number attached to the ring of o... |
Solve the programming task below in a Python markdown code block.
Ito joined the Kyudo club after entering high school. At first, I had a hard time because the arrow didn't reach the target, but in the fall of my first year of high school, I managed to improve to the point where the arrow reached the target.
One day,... |
Solve the programming task below in a Python markdown code block.
Anchored Balloon
A balloon placed on the ground is connected to one or more anchors on the ground with ropes. Each rope is long enough to connect the balloon and the anchor. No two ropes cross each other. Figure E-1 shows such a situation.
<image>
Fig... |
Solve the programming task below in a Python markdown code block.
Increasing E869120 (Ninja E869120)
E869120 You are good at alter ego.
Here are $ N $ members of the PA Lab. But some of them may be E869120.
So you asked all the $ N $ members of the PA Lab for their names. As a result, the $ N $ members named themse... |
Solve the programming task below in a Python markdown code block.
A group of n dancers rehearses a performance for the closing ceremony. The dancers are arranged in a row, they've studied their dancing moves and can't change positions. For some of them, a white dancing suit is already bought, for some of them β a blac... |
Solve the programming task below in a Python markdown code block.
A non-empty string is called palindrome, if it reads the same from the left to the right and from the right to the left. For example, "abcba", "a", and "abba" are palindromes, while "abab" and "xy" are not.
A string is called a substring of another str... |
Solve the programming task below in a Python markdown code block.
You are given a 4x4 grid. You play a game β there is a sequence of tiles, each of them is either 2x1 or 1x2. Your task is to consequently place all tiles from the given sequence in the grid. When tile is placed, each cell which is located in fully occup... |
Solve the programming task below in a Python markdown code block.
A string is called bracket sequence if it does not contain any characters other than "(" and ")". A bracket sequence is called regular if it it is possible to obtain correct arithmetic expression by inserting characters "+" and "1" into this sequence. F... |
Solve the programming task below in a Python markdown code block.
Neko is playing with his toys on the backyard of Aki's house. Aki decided to play a prank on him, by secretly putting catnip into Neko's toys. Unfortunately, he went overboard and put an entire bag of catnip into the toys...
It took Neko an entire day ... |
Solve the programming task below in a Python markdown code block.
You're given an array a of length n. You can perform the following operation on it as many times as you want:
* Pick two integers i and j (1 β€ i,j β€ n) such that a_i+a_j is odd, then swap a_i and a_j.
What is lexicographically the smallest array ... |
Solve the programming task below in a Python markdown code block.
Marcin is a coach in his university. There are n students who want to attend a training camp. Marcin is a smart coach, so he wants to send only the students that can work calmly with each other.
Let's focus on the students. They are indexed with intege... |
Solve the programming task below in a Python markdown code block.
You have a large electronic screen which can display up to 998244353 decimal digits. The digits are displayed in the same way as on different electronic alarm clocks: each place for a digit consists of 7 segments which can be turned on and off to compos... |
Solve the programming task below in a Python markdown code block.
n students are taking an exam. The highest possible score at this exam is m. Let a_{i} be the score of the i-th student. You have access to the school database which stores the results of all students.
You can change each student's score as long as the... |
Solve the programming task below in a Python markdown code block.
Writing light novels is the most important thing in Linova's life. Last night, Linova dreamed about a fantastic kingdom. She began to write a light novel for the kingdom as soon as she woke up, and of course, she is the queen of it.
<image>
There are ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.