question large_stringlengths 265 13.2k |
|---|
Solve the programming task below in a Python markdown code block.
The cat Snuke wants to play a popular Japanese game called Γ
tCoder, so Iroha has decided to teach him Japanese.
When counting pencils in Japanese, the counter word "ζ¬" follows the number. The pronunciation of this word varies depending on the number. Sp... |
Solve the programming task below in a Python markdown code block.
It's now the season of TAKOYAKI FESTIVAL!
This year, N takoyaki (a ball-shaped food with a piece of octopus inside) will be served. The deliciousness of the i-th takoyaki is d_i.
As is commonly known, when you eat two takoyaki of deliciousness x and y t... |
Solve the programming task below in a Python markdown code block.
There are two buttons, one of size A and one of size B.
When you press a button of size X, you get X coins and the size of that button decreases by 1.
You will press a button twice. Here, you can press the same button twice, or press both buttons once.
... |
Solve the programming task below in a Python markdown code block.
In some village, there are 999 towers that are 1,(1+2),(1+2+3),...,(1+2+3+...+999) meters high from west to east, at intervals of 1 meter.
It had been snowing for a while before it finally stopped. For some two adjacent towers located 1 meter apart, we ... |
Solve the programming task below in a Python markdown code block.
Serval is fighting with a monster.
The health of the monster is H.
In one attack, Serval can decrease the monster's health by A.
There is no other way to decrease the monster's health.
Serval wins when the monster's health becomes 0 or below.
Find the n... |
Solve the programming task below in a Python markdown code block.
Alice and Bob are controlling a robot. They each have one switch that controls the robot.
Alice started holding down her button A second after the start-up of the robot, and released her button B second after the start-up.
Bob started holding down his... |
Solve the programming task below in a Python markdown code block.
The number 105 is quite special - it is odd but still it has eight divisors.
Now, your task is this: how many odd numbers with exactly eight positive divisors are there between 1 and N (inclusive)?
-----Constraints-----
- N is an integer between 1 and... |
Solve the programming task below in a Python markdown code block.
Takahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible.
When all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest... |
Solve the programming task below in a Python markdown code block.
Kurohashi has never participated in AtCoder Beginner Contest (ABC).
The next ABC to be held is ABC N (the N-th ABC ever held).
Kurohashi wants to make his debut in some ABC x such that all the digits of x in base ten are the same.
What is the earliest A... |
Solve the programming task below in a Python markdown code block.
Takahashi and Aoki will have a battle using their monsters.
The health and strength of Takahashi's monster are A and B, respectively, and those of Aoki's monster are C and D, respectively.
The two monsters will take turns attacking, in the order Takahas... |
Solve the programming task below in a Python markdown code block.
There is a grid of squares with H horizontal rows and W vertical columns.
The square at the i-th row from the top and the j-th column from the left is represented as (i, j).
Each square is black or white.
The color of the square is given as an H-by-W ma... |
Solve the programming task below in a Python markdown code block.
Print the circumference of a circle of radius R.
-----Constraints-----
- 1 \leq R \leq 100
- All values in input are integers.
-----Input-----
Input is given from Standard Input in the following format:
R
-----Output-----
Print the circumference of... |
Solve the programming task below in a Python markdown code block.
You are given a 4-character string S consisting of uppercase English letters.
Determine if S consists of exactly two kinds of characters which both appear twice in S.
-----Constraints-----
- The length of S is 4.
- S consists of uppercase English let... |
Solve the programming task below in a Python markdown code block.
We have two integers: A and B.
Print the largest number among A + B, A - B, and A \times B.
-----Constraints-----
- All values in input are integers.
- -100 \leq A,\ B \leq 100
-----Input-----
Input is given from Standard Input in the following form... |
Solve the programming task below in a Python markdown code block.
There are N mountains ranging from east to west, and an ocean to the west.
At the top of each mountain, there is an inn. You have decided to choose where to stay from these inns.
The height of the i-th mountain from the west is H_i.
You can certainly se... |
Solve the programming task below in a Python markdown code block.
Little girl Tanya climbs the stairs inside a multi-storey building. Every time Tanya climbs a stairway, she starts counting steps from $1$ to the number of steps in this stairway. She speaks every number aloud. For example, if she climbs two stairways, ... |
Solve the programming task below in a Python markdown code block.
Recently Vova found $n$ candy wrappers. He remembers that he bought $x$ candies during the first day, $2x$ candies during the second day, $4x$ candies during the third day, $\dots$, $2^{k-1} x$ candies during the $k$-th day. But there is an issue: Vova ... |
Solve the programming task below in a Python markdown code block.
Little girl Tanya is learning how to decrease a number by one, but she does it wrong with a number consisting of two or more digits. Tanya subtracts one from a number by the following algorithm: if the last digit of the number is non-zero, she decrease... |
Solve the programming task below in a Python markdown code block.
There are $n$ people in a row. The height of the $i$-th person is $a_i$. You can choose any subset of these people and try to arrange them into a balanced circle.
A balanced circle is such an order of people that the difference between heights of any a... |
Solve the programming task below in a Python markdown code block.
Takahashi loves takoyaki - a ball-shaped snack.
With a takoyaki machine, he can make at most X pieces of takoyaki at a time, taking T minutes regardless of the number of pieces to make.
How long does it take to make N takoyaki?
-----Constraints-----
-... |
Solve the programming task below in a Python markdown code block.
There are N students in a school.
We will divide these students into some groups, and in each group they will discuss some themes.
You think that groups consisting of two or less students cannot have an effective discussion, so you want to have as many ... |
Solve the programming task below in a Python markdown code block.
We have A apples and P pieces of apple.
We can cut an apple into three pieces of apple, and make one apple pie by simmering two pieces of apple in a pan.
Find the maximum number of apple pies we can make with what we have now.
-----Constraints-----
- ... |
Solve the programming task below in a Python markdown code block.
You are given positive integers A and B.
If A is a divisor of B, print A + B; otherwise, print B - A.
-----Constraints-----
- All values in input are integers.
- 1 \leq A \leq B \leq 20
-----Input-----
Input is given from Standard Input in the follo... |
Solve the programming task below in a Python markdown code block.
Takahashi wants to be a member of some web service.
He tried to register himself with the ID S, which turned out to be already used by another user.
Thus, he decides to register using a string obtained by appending one character at the end of S as his I... |
Solve the programming task below in a Python markdown code block.
We have two distinct integers A and B.
Print the integer K such that |A - K| = |B - K|.
If such an integer does not exist, print IMPOSSIBLE instead.
-----Constraints-----
- All values in input are integers.
- 0 \leq A,\ B \leq 10^9
- A and B are dis... |
Solve the programming task below in a Python markdown code block.
Given is a three-digit integer N. Does N contain the digit 7?
If so, print Yes; otherwise, print No.
-----Constraints-----
- 100 \leq N \leq 999
-----Input-----
Input is given from Standard Input in the following format:
N
-----Output-----
If N cont... |
Solve the programming task below in a Python markdown code block.
Let S(n) denote the sum of the digits in the decimal notation of n.
For example, S(101) = 1 + 0 + 1 = 2.
Given an integer N, determine if S(N) divides N.
-----Constraints-----
- 1 \leq N \leq 10^9
-----Input-----
Input is given from Standard Input in... |
Solve the programming task below in a Python markdown code block.
There is a square in the xy-plane. The coordinates of its four vertices are (x_1,y_1),(x_2,y_2),(x_3,y_3) and (x_4,y_4) in counter-clockwise order.
(Assume that the positive x-axis points right, and the positive y-axis points up.)
Takahashi remembers (x... |
Solve the programming task below in a Python markdown code block.
We have A balls with the string S written on each of them and B balls with the string T written on each of them.
From these balls, Takahashi chooses one with the string U written on it and throws it away.
Find the number of balls with the string S and... |
Solve the programming task below in a Python markdown code block.
Given are a positive integer N and a string S of length N consisting of lowercase English letters.
Determine whether the string is a concatenation of two copies of some string.
That is, determine whether there is a string T such that S = T + T.
-----Co... |
Solve the programming task below in a Python markdown code block.
There is a rectangle in a coordinate plane. The coordinates of the four vertices are (0,0), (W,0), (W,H), and (0,H).
You are given a point (x,y) which is within the rectangle or on its border. We will draw a straight line passing through (x,y) to cut th... |
Solve the programming task below in a Python markdown code block.
In Japan, people make offerings called hina arare, colorful crackers, on March 3.
We have a bag that contains N hina arare. (From here, we call them arare.)
It is known that the bag either contains arare in three colors: pink, white and green, or contai... |
Solve the programming task below in a Python markdown code block.
The next lecture in a high school requires two topics to be discussed. The $i$-th topic is interesting by $a_i$ units for the teacher and by $b_i$ units for the students.
The pair of topics $i$ and $j$ ($i < j$) is called good if $a_i + a_j > b_i + b_j... |
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 algorit... |
Solve the programming task below in a Python markdown code block.
You are given an undirected graph consisting of $n$ vertices and $m$ edges. Your task is to find the number of connected components which are cycles.
Here are some definitions of graph theory.
An undirected graph consists of two sets: set of nodes (ca... |
Solve the programming task below in a Python markdown code block.
You are given an undirected tree of $n$ vertices.
Some vertices are colored blue, some are colored red and some are uncolored. It is guaranteed that the tree contains at least one red vertex and at least one blue vertex.
You choose an edge and remove... |
Solve the programming task below in a Python markdown code block.
You are given two strings $s$ and $t$, both consisting of exactly $k$ lowercase Latin letters, $s$ is lexicographically less than $t$.
Let's consider list of all strings consisting of exactly $k$ lowercase Latin letters, lexicographically not less than... |
Solve the programming task below in a Python markdown code block.
Two integer sequences existed initially, one of them was strictly increasing, and another one β strictly decreasing.
Strictly increasing sequence is a sequence of integers $[x_1 < x_2 < \dots < x_k]$. And strictly decreasing sequence is a sequence of i... |
Solve the programming task below in a Python markdown code block.
Vova plans to go to the conference by train. Initially, the train is at the point $1$ and the destination point of the path is the point $L$. The speed of the train is $1$ length unit per minute (i.e. at the first minute the train is at the point $1$, a... |
Solve the programming task below in a Python markdown code block.
You are given a string $s$ consisting of $n$ lowercase Latin letters. Polycarp wants to remove exactly $k$ characters ($k \le n$) from the string $s$. Polycarp uses the following algorithm $k$ times:
if there is at least one letter 'a', remove the le... |
Solve the programming task below in a Python markdown code block.
The only difference between easy and hard versions is constraints.
Ivan plays a computer game that contains some microtransactions to make characters look cooler. Since Ivan wants his character to be really cool, he wants to use some of these microtran... |
Solve the programming task below in a Python markdown code block.
A star is a figure of the following type: an asterisk character '*' in the center of the figure and four rays (to the left, right, top, bottom) of the same positive length. The size of a star is the length of its rays. The size of a star must be a posit... |
Solve the programming task below in a Python markdown code block.
You are given a three-digit positive integer N.
Determine whether N is a palindromic number.
Here, a palindromic number is an integer that reads the same backward as forward in decimal notation.
-----Constraints-----
- 100β€Nβ€999
- N is an integer.
... |
Solve the programming task below in a Python markdown code block.
Alice and Bob are playing One Card Poker.
One Card Poker is a two-player game using playing cards.
Each card in this game shows an integer between 1 and 13, inclusive.
The strength of a card is determined by the number written on it, as follows:
W... |
Solve the programming task below in a Python markdown code block.
As a New Year's gift, Dolphin received a string s of length 19.
The string s has the following format: [five lowercase English letters],[seven lowercase English letters],[five lowercase English letters].
Dolphin wants to convert the comma-separated st... |
Solve the programming task below in a Python markdown code block.
There are N students and M checkpoints on the xy-plane.
The coordinates of the i-th student (1 \leq i \leq N) is (a_i,b_i), and the coordinates of the checkpoint numbered j (1 \leq j \leq M) is (c_j,d_j).
When the teacher gives a signal, each student ... |
Solve the programming task below in a Python markdown code block.
Given an integer a as input, print the value a + a^2 + a^3.
-----Constraints-----
- 1 \leq a \leq 10
- a is an integer.
-----Input-----
Input is given from Standard Input in the following format:
a
-----Output-----
Print the value a + a^2 + a^3 as ... |
Solve the programming task below in a Python markdown code block.
You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels.
A pixel is the smallest element of an image, and in this problem it is a square of size 1Γ1.
Also, the given images... |
Solve the programming task below in a Python markdown code block.
In some other world, today is the day before Christmas Eve.
Mr. Takaha is buying N items at a department store. The regular price of the i-th item (1 \leq i \leq N) is p_i yen (the currency of Japan).
He has a discount coupon, and can buy one item with ... |
Solve the programming task below in a Python markdown code block.
The restaurant AtCoder serves the following five dishes:
- ABC Don (rice bowl): takes A minutes to serve.
- ARC Curry: takes B minutes to serve.
- AGC Pasta: takes C minutes to serve.
- APC Ramen: takes D minutes to serve.
- ATC Hanbagu (hamburger ... |
Solve the programming task below in a Python markdown code block.
Given is a sequence of N integers A_1, \ldots, A_N.
Find the (multiplicative) inverse of the sum of the inverses of these numbers, \frac{1}{\frac{1}{A_1} + \ldots + \frac{1}{A_N}}.
-----Constraints-----
- 1 \leq N \leq 100
- 1 \leq A_i \leq 1000
---... |
Solve the programming task below in a Python markdown code block.
In some other world, today is Christmas Eve.
There are N trees planted in Mr. Takaha's garden. The height of the i-th tree (1 \leq i \leq N) is h_i meters.
He decides to choose K trees from these trees and decorate them with electric lights. To make the... |
Solve the programming task below in a Python markdown code block.
An uppercase or lowercase English letter \alpha will be given as input.
If \alpha is uppercase, print A; if it is lowercase, print a.
-----Constraints-----
- \alpha is an uppercase (A - Z) or lowercase (a - z) English letter.
-----Input-----
Input is... |
Solve the programming task below in a Python markdown code block.
You have a digit sequence S of length 4. You are wondering which of the following formats S is in:
- YYMM format: the last two digits of the year and the two-digit representation of the month (example: 01 for January), concatenated in this order
- MMY... |
Solve the programming task below in a Python markdown code block.
Find the number of ways to choose a pair of an even number and an odd number from the positive integers between 1 and K (inclusive). The order does not matter.
-----Constraints-----
- 2\leq K\leq 100
- K is an integer.
-----Input-----
Input is given... |
Solve the programming task below in a Python markdown code block.
Dolphin loves programming contests. Today, he will take part in a contest in AtCoder.
In this country, 24-hour clock is used. For example, 9:00 p.m. is referred to as "21 o'clock".
The current time is A o'clock, and a contest will begin in exactly B h... |
Solve the programming task below in a Python markdown code block.
Takahashi is a member of a programming competition site, ButCoder.
Each member of ButCoder is assigned two values: Inner Rating and Displayed Rating.
The Displayed Rating of a member is equal to their Inner Rating if the member has participated in 10 or... |
Solve the programming task below in a Python markdown code block.
Given is an integer N. Find the number of digits that N has in base K.
-----Notes-----
For information on base-K representation, see Positional notation - Wikipedia.
-----Constraints-----
- All values in input are integers.
- 1 \leq N \leq 10^9
- 2... |
Solve the programming task below in a Python markdown code block.
Takahashi wants to print a document with N pages double-sided, where two pages of data can be printed on one sheet of paper.
At least how many sheets of paper does he need?
-----Constraints-----
- N is an integer.
- 1 \leq N \leq 100
-----Input-----... |
Solve the programming task below in a Python markdown code block.
E869120's and square1001's 16-th birthday is coming soon.
Takahashi from AtCoder Kingdom gave them a round cake cut into 16 equal fan-shaped pieces.
E869120 and square1001 were just about to eat A and B of those pieces, respectively,
when they found a... |
Solve the programming task below in a Python markdown code block.
There is a string S consisting of digits 1, 2, ..., 9.
Lunlun, the Dachshund, will take out three consecutive digits from S, treat them as a single integer X and bring it to her master. (She cannot rearrange the digits.)
The master's favorite number is ... |
Solve the programming task below in a Python markdown code block.
There were $n$ types of swords in the theater basement which had been used during the plays. Moreover there were exactly $x$ swords of each type. $y$ people have broken into the theater basement and each of them has taken exactly $z$ swords of some sing... |
Solve the programming task below in a Python markdown code block.
You are given a forest β an undirected graph with $n$ vertices such that each its connected component is a tree.
The diameter (aka "longest shortest path") of a connected undirected graph is the maximum number of edges in the shortest path between any ... |
Solve the programming task below in a Python markdown code block.
There are $n$ dormitories in Berland State University, they are numbered with integers from $1$ to $n$. Each dormitory consists of rooms, there are $a_i$ rooms in $i$-th dormitory. The rooms in $i$-th dormitory are numbered from $1$ to $a_i$.
A postman... |
Solve the programming task below in a Python markdown code block.
Polycarp has guessed three positive integers $a$, $b$ and $c$. He keeps these numbers in secret, but he writes down four numbers on a board in arbitrary order β their pairwise sums (three numbers) and sum of all three numbers (one number). So, there are... |
Solve the programming task below in a Python markdown code block.
You have a garland consisting of $n$ lamps. Each lamp is colored red, green or blue. The color of the $i$-th lamp is $s_i$ ('R', 'G' and 'B' β colors of lamps in the garland).
You have to recolor some lamps in this garland (recoloring a lamp means chan... |
Solve the programming task below in a Python markdown code block.
You are given an integer array of length $n$.
You have to choose some subsequence of this array of maximum length such that this subsequence forms a increasing sequence of consecutive integers. In other words the required sequence should be equal to $[... |
Solve the programming task below in a Python markdown code block.
You are given integers A and B, each between 1 and 3 (inclusive).
Determine if there is an integer C between 1 and 3 (inclusive) such that A \times B \times C is an odd number.
-----Constraints-----
- All values in input are integers.
- 1 \leq A, B \... |
Solve the programming task below in a Python markdown code block.
There is a train going from Station A to Station B that costs X yen (the currency of Japan).
Also, there is a bus going from Station B to Station C that costs Y yen.
Joisino got a special ticket. With this ticket, she can take the bus for half the fare ... |
Solve the programming task below in a Python markdown code block.
Takahashi is going to set a 3-character password.
How many possible passwords are there if each of its characters must be a digit between 1 and N (inclusive)?
-----Constraints-----
- 1 \leq N \leq 9
- N is an integer.
-----Input-----
Input is given ... |
Solve the programming task below in a Python markdown code block.
Shichi-Go-San (literally "Seven-Five-Three") is a traditional event in a certain country to celebrate the growth of seven-, five- and three-year-old children.
Takahashi is now X years old. Will his growth be celebrated in Shichi-Go-San this time?
-----... |
Solve the programming task below in a Python markdown code block.
Decades have passed since the beginning of AtCoder Beginner Contest.
The contests are labeled as ABC001, ABC002, ... from the first round, but after the 999-th round ABC999, a problem occurred: how the future rounds should be labeled?
In the end, the la... |
Solve the programming task below in a Python markdown code block.
In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between th... |
Solve the programming task below in a Python markdown code block.
You will be given an integer a and a string s consisting of lowercase English letters as input.
Write a program that prints s if a is not less than 3200 and prints red if a is less than 3200.
-----Constraints-----
- 2800 \leq a < 5000
- s is a string... |
Solve the programming task below in a Python markdown code block.
A programming competition site AtCode regularly holds programming contests.
The next contest on AtCode is called ABC, which is rated for contestants with ratings less than 1200.
The contest after the ABC is called ARC, which is rated for contestants wit... |
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 each digit... |
Solve the programming task below in a Python markdown code block.
Alice guesses the strings that Bob made for her.
At first, Bob came up with the secret string $a$ consisting of lowercase English letters. The string $a$ has a length of $2$ or more characters. Then, from string $a$ he builds a new string $b$ and offer... |
Solve the programming task below in a Python markdown code block.
The heat during the last few days has been really intense. Scientists from all over the Berland study how the temperatures and weather change, and they claim that this summer is abnormally hot. But any scientific claim sounds a lot more reasonable if th... |
Solve the programming task below in a Python markdown code block.
Polycarp loves ciphers. He has invented his own cipher called repeating.
Repeating cipher is used for strings. To encrypt the string $s=s_{1}s_{2} \dots s_{m}$ ($1 \le m \le 10$), Polycarp uses the following algorithm:
he writes down $s_1$ ones, he... |
Solve the programming task below in a Python markdown code block.
You are given an undirected weighted connected graph with $n$ vertices and $m$ edges without loops and multiple edges.
The $i$-th edge is $e_i = (u_i, v_i, w_i)$; the distance between vertices $u_i$ and $v_i$ along the edge $e_i$ is $w_i$ ($1 \le w_i$)... |
Solve the programming task below in a Python markdown code block.
You have a garland consisting of $n$ lamps. Each lamp is colored red, green or blue. The color of the $i$-th lamp is $s_i$ ('R', 'G' and 'B' β colors of lamps in the garland).
You have to recolor some lamps in this garland (recoloring a lamp means chan... |
Solve the programming task below in a Python markdown code block.
Takahashi received otoshidama (New Year's money gifts) from N of his relatives.
You are given N values x_1, x_2, ..., x_N and N strings u_1, u_2, ..., u_N as input. Each string u_i is either JPY or BTC, and x_i and u_i represent the content of the otosh... |
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
... |
Solve the programming task below in a Python markdown code block.
Given are strings s and t of length N each, both consisting of lowercase English letters.
Let us form a new string by alternating the characters of S and the characters of T, as follows: the first character of S, the first character of T, the second cha... |
Solve the programming task below in a Python markdown code block.
In AtCoder City, there are three stations numbered 1, 2, and 3.
Each of these stations is operated by one of the two railway companies, A and B. A string S of length 3 represents which company operates each station. If S_i is A, Company A operates Stati... |
Solve the programming task below in a Python markdown code block.
We have weather records at AtCoder Town for some consecutive three days. A string of length 3, S, represents the records - if the i-th character is S, it means it was sunny on the i-th day; if that character is R, it means it was rainy on that day.
Find... |
Solve the programming task below in a Python markdown code block.
Takahashi, who is A years old, is riding a Ferris wheel.
It costs B yen (B is an even number) to ride the Ferris wheel if you are 13 years old or older, but children between 6 and 12 years old (inclusive) can ride it for half the cost, and children who ... |
Solve the programming task below in a Python markdown code block.
There is always an integer in Takahashi's mind.
Initially, the integer in Takahashi's mind is 0. Takahashi is now going to eat four symbols, each of which is + or -. When he eats +, the integer in his mind increases by 1; when he eats -, the integer in ... |
Solve the programming task below in a Python markdown code block.
You are given a string S as input. This represents a valid date in the year 2019 in the yyyy/mm/dd format. (For example, April 30, 2019 is represented as 2019/04/30.)
Write a program that prints Heisei if the date represented by S is not later than Apri... |
Solve the programming task below in a Python markdown code block.
The only difference between easy and hard versions are constraints on $n$ and $k$.
You are messaging in one of the popular social networks via your smartphone. Your smartphone can show at most $k$ most recent conversations with your friends. Initially,... |
Solve the programming task below in a Python markdown code block.
Polycarp has $n$ coins, the value of the $i$-th coin is $a_i$. It is guaranteed that all the values are integer powers of $2$ (i.e. $a_i = 2^d$ for some non-negative integer number $d$).
Polycarp wants to know answers on $q$ queries. The $j$-th query i... |
Solve the programming task below in a Python markdown code block.
You are given an array $a$ consisting of $n$ integers. You can perform the following operations arbitrary number of times (possibly, zero):
Choose a pair of indices $(i, j)$ such that $|i-j|=1$ (indices $i$ and $j$ are adjacent) and set $a_i := a_i +... |
Solve the programming task below in a Python markdown code block.
Polycarp and his friends want to visit a new restaurant. The restaurant has $n$ tables arranged along a straight line. People are already sitting at some tables. The tables are numbered from $1$ to $n$ in the order from left to right. The state of the r... |
Solve the programming task below in a Python markdown code block.
The only difference between easy and hard versions is constraints.
You are given $n$ segments on the coordinate axis $OX$. Segments can intersect, lie inside each other and even coincide. The $i$-th segment is $[l_i; r_i]$ ($l_i \le r_i$) and it covers... |
Solve the programming task below in a Python markdown code block.
One important contest will take place on the most famous programming platform (Topforces) very soon!
The authors have a pool of $n$ problems and should choose at most three of them into this contest. The prettiness of the $i$-th problem is $a_i$. The a... |
Solve the programming task below in a Python markdown code block.
Two integer sequences existed initially β one of them was strictly increasing, and the other one β strictly decreasing.
Strictly increasing sequence is a sequence of integers $[x_1 < x_2 < \dots < x_k]$. And strictly decreasing sequence is a sequence o... |
Solve the programming task below in a Python markdown code block.
There are $n$ products in the shop. The price of the $i$-th product is $a_i$. The owner of the shop wants to equalize the prices of all products. However, he wants to change prices smoothly.
In fact, the owner of the shop can change the price of some p... |
Solve the programming task below in a Python markdown code block.
You are given an array $a$ consisting of $n$ integers. Each $a_i$ is one of the six following numbers: $4, 8, 15, 16, 23, 42$.
Your task is to remove the minimum number of elements to make this array good.
An array of length $k$ is called good if $k$ ... |
Solve the programming task below in a Python markdown code block.
You are given two integers $a$ and $b$.
In one move, you can choose some integer $k$ from $1$ to $10$ and add it to $a$ or subtract it from $a$. In other words, you choose an integer $k \in [1; 10]$ and perform $a := a + k$ or $a := a - k$. You may use... |
Solve the programming task below in a Python markdown code block.
International Women's Day is coming soon! Polycarp is preparing for the holiday.
There are $n$ candy boxes in the shop for sale. The $i$-th box contains $d_i$ candies.
Polycarp wants to prepare the maximum number of gifts for $k$ girls. Each gift will... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.