question large_stringlengths 265 13.2k |
|---|
Solve the programming task below in a Python markdown code block.
We have a two-dimensional grid with H \times W squares. There are M targets to destroy in this grid - the position of the i-th target is \left(h_i, w_i \right).
Takahashi will choose one square in this grid, place a bomb there, and ignite it. The bomb w... |
Solve the programming task below in a Python markdown code block.
There are b blocks of digits. Each one consisting of the same n digits, which are given to you in the input. Wet Shark must choose exactly one digit from each block and concatenate all of those digits together to form one large integer. For example, if ... |
Solve the programming task below in a Python markdown code block.
Transformation
Write a program which performs a sequence of commands to a given string $str$. The command is one of:
* print a b: print from the a-th character to the b-th character of $str$
* reverse a b: reverse from the a-th character to the b-t... |
Solve the programming task below in a Python markdown code block.
Consider a sequence made up of the consecutive prime numbers. This infinite sequence would start with:
```python
"2357111317192329313741434753596167717379..."
```
You will be given two numbers: `a` and `b`, and your task will be to return `b` elements... |
Solve the programming task below in a Python markdown code block.
You have a description of a lever as string s. We'll represent the string length as record |s|, then the lever looks as a horizontal bar with weights of length |s| - 1 with exactly one pivot. We will assume that the bar is a segment on the Ox axis betwe... |
Solve the programming task below in a Python markdown code block.
D: Sunburn-Suntan-
story
Aizunyan is a second-year student who belongs to the programming contest club of Wakagamatsu High School, commonly known as the Prokon club. Cute like an angel. Aizu Nyan is planning to participate in this summer festival, so ... |
Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin Chinese and Russian.
Some chefs go for a tour lasting N days. They take packages of bread for food. Each package has K pieces of breads. On the i^{th} day, they eat A_{i} pieces of bread.
Unfortunately, chefs are v... |
Solve the programming task below in a Python markdown code block.
Polycarp remembered the $2020$-th year, and he is happy with the arrival of the new $2021$-th year. To remember such a wonderful moment, Polycarp wants to represent the number $n$ as the sum of a certain number of $2020$ and a certain number of $2021$.
... |
Solve the programming task below in a Python markdown code block.
Example
Input
1+2*3+4
11
Output
M
Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters. |
Solve the programming task below in a Python markdown code block.
There is a country with $n$ citizens. The $i$-th of them initially has $a_{i}$ money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services m... |
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.
Vasya studies music.
He has learned lots of interesting stuff. For example, he knows that there are 12 notes: C, C#, D, D#, E, F, F#, G, G#, A, B, H. He also knows that the notes are repeated cyclically: after H goes C again, and before C stands H. We... |
Solve the programming task below in a Python markdown code block.
Meka-Naruto plays a computer game. His character has the following ability: given an enemy hero, deal $a$ instant damage to him, and then heal that enemy $b$ health points at the end of every second, for exactly $c$ seconds, starting one second after th... |
Solve the programming task below in a Python markdown code block.
You are given an undirected unweighted graph consisting of $n$ vertices and $m$ edges (which represents the map of Bertown) and the array of prices $p$ of length $m$. It is guaranteed that there is a path between each pair of vertices (districts).
Mike... |
Solve the programming task below in a Python markdown code block.
You are playing a game where your character should overcome different obstacles. The current problem is to come down from a cliff. The cliff has height $h$, and there is a moving platform on each height $x$ from $1$ to $h$.
Each platform is either hidd... |
Solve the programming task below in a Python markdown code block.
You are given an integer sequence of length N. The i-th term in the sequence is a_i. In one operation, you can select a term and either increment or decrement it by one.
At least how many operations are necessary to satisfy the following conditions?
*... |
Solve the programming task below in a Python markdown code block.
Little Petya has recently started attending a programming club. Naturally he is facing the problem of choosing a programming language. After long considerations he realized that Java is the best choice. The main argument in favor of choosing Java was th... |
Solve the programming task below in a Python markdown code block.
Count the number of divisors of a positive integer `n`.
Random tests go up to `n = 500000`.
## Examples
```python
divisors(4) == 3 # 1, 2, 4
divisors(5) == 2 # 1, 5
divisors(12) == 6 # 1, 2, 3, 4, 6, 12
divisors(30) == 8 # 1, 2, 3, 5, 6, 10, 15,... |
Solve the programming task below in a Python markdown code block.
Little Sofia is in fourth grade. Today in the geometry lesson she learned about segments and squares. On the way home, she decided to draw $n$ squares in the snow with a side length of $1$. For simplicity, we assume that Sofia lives on a plane and can d... |
Solve the programming task below in a Python markdown code block.
A programming contest is held every year at White Tiger University. When the total number of teams is N, each team is assigned a team ID from 1 to N. The contest starts with all teams scoring 0 and runs continuously for L seconds.
This year's contest w... |
Solve the programming task below in a Python markdown code block.
Many cats live on the campus of a school. Natsume's daily routine is to pet those cats. However, the cats may be capricious and go for a walk off campus.
The campus site is a rectangle with each side parallel to the x-axis or y-axis and is surrounded b... |
Solve the programming task below in a Python markdown code block.
## The Story
Green Lantern's long hours of study and practice with his ring have really paid off -- his skills, focus, and control have improved so much that now he can even use his ring to update and redesign his web site. Earlier today he was focusing... |
Solve the programming task below in a Python markdown code block.
You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}.
You will now successively do the following Q operations:
- In the i-th operation, you replace every element whose value is B_{i} with C_{i}.
For each i (1 \leq i \leq Q... |
Solve the programming task below in a Python markdown code block.
There are $ n $ acitivities with start times $ \\ {s_i \\} $ and finish times $ \\ {t_i \\} $. Assuming that a person can only work on a single activity at a time, find the maximum number of activities that can be performed by a single person.
Constrai... |
Solve the programming task below in a Python markdown code block.
Let's call an array $t$ dominated by value $v$ in the next situation.
At first, array $t$ should have at least $2$ elements. Now, let's calculate number of occurrences of each number $num$ in $t$ and define it as $occ(num)$. Then $t$ is dominated (by $... |
Solve the programming task below in a Python markdown code block.
ZS the Coder and Chris the Baboon are travelling to Udayland! To get there, they have to get on the special IOI bus. The IOI bus has n rows of seats. There are 4 seats in each row, and the seats are separated into pairs by a walkway. When ZS and Chris c... |
Solve the programming task below in a Python markdown code block.
For a given weighted graph G(V, E) and a source r, find the source shortest path to each vertex from the source (SSSP: Single Source Shortest Path).
Constraints
* 1 ≤ |V| ≤ 100000
* 0 ≤ di ≤ 10000
* 0 ≤ |E| ≤ 500000
* There are no parallel edges
* The... |
Solve the programming task below in a Python markdown code block.
Toad Pimple has an array of integers $a_1, a_2, \ldots, a_n$.
We say that $y$ is reachable from $x$ if $x<y$ and there exists an integer array $p$ such that $x = p_1 < p_2 < \ldots < p_k=y$, and $a_{p_i}\, \&\, a_{p_{i+1}} > 0$ for all integers $i$ suc... |
Solve the programming task below in a Python markdown code block.
A sequence $a_1, a_2, \dots, a_k$ is called an arithmetic progression if for each $i$ from $1$ to $k$ elements satisfy the condition $a_i = a_1 + c \cdot (i - 1)$ for some fixed $c$.
For example, these five sequences are arithmetic progressions: $[5, 7... |
Solve the programming task below in a Python markdown code block.
You are given an array $a$ consisting of $n$ integers. For each $i$ ($1 \le i \le n$) the following inequality is true: $-2 \le a_i \le 2$.
You can remove any number (possibly $0$) of elements from the beginning of the array and any number (possibly $0... |
Solve the programming task below in a Python markdown code block.
Takahashi is playing a board game called Sugoroku.
On the board, there are N + 1 squares numbered 0 to N. Takahashi starts at Square 0, and he has to stop exactly at Square N to win the game.
The game uses a roulette with the M numbers from 1 to M. In e... |
Solve the programming task below in a Python markdown code block.
In the 2050 Conference, some people from the competitive programming community meet together and are going to take a photo. The n people form a line. They are numbered from 1 to n from left to right. Each of them either holds a cardboard with the letter... |
Solve the programming task below in a Python markdown code block.
problem
Taro bought 10 books. Later, I tried to find out the price based on the receipt, but the receipt was dirty and I could not read the price of a book. We decided to calculate the price of the book from the total price of 10 books and the prices o... |
Solve the programming task below in a Python markdown code block.
Mr. Yamada Springfield Tanaka was appointed as Deputy Deputy Director of the National Land Readjustment Business Bureau. Currently, his country is in the midst of a major land readjustment, and if this land readjustment can be completed smoothly, his pr... |
Solve the programming task below in a Python markdown code block.
As usual, Sereja has array a, its elements are integers: a[1], a[2], ..., a[n]. Let's introduce notation:
$f(a, l, r) = \sum_{i = l}^{r} a [ i ] ; m(a) = \operatorname{max}_{1 \leq l \leq r \leq n} f(a, l, r)$
A swap operation is the following sequenc... |
Solve the programming task below in a Python markdown code block.
While playing yet another strategy game, Mans has recruited $n$ Swedish heroes, whose powers which can be represented as an array $a$.
Unfortunately, not all of those mighty heroes were created as capable as he wanted, so that he decided to do somethin... |
Solve the programming task below in a Python markdown code block.
Snuke got an integer sequence of length N from his mother, as a birthday present. The i-th (1 ≦ i ≦ N) element of the sequence is a_i. The elements are pairwise distinct. He is sorting this sequence in increasing order. With supernatural power, he can p... |
Solve the programming task below in a Python markdown code block.
- Input: Integer `n`
- Output: String
Example:
`a(4)` prints as
```
A
A A
A A A
A A
```
`a(8)` prints as
```
A
A A
A A
A A
A A A A A
A A
A A
A ... |
Solve the programming task below in a Python markdown code block.
Write a function which takes one parameter representing the dimensions of a checkered board. The board will always be square, so 5 means you will need a 5x5 board.
The dark squares will be represented by a unicode white square, while the light squares ... |
Solve the programming task below in a Python markdown code block.
There are N integers, A_1, A_2, ..., A_N, written on a blackboard.
We will repeat the following operation N-1 times so that we have only one integer on the blackboard.
* Choose two integers x and y on the blackboard and erase these two integers. Then,... |
Solve the programming task below in a Python markdown code block.
A new Berland businessman Vitaly is going to open a household appliances' store. All he's got to do now is to hire the staff.
The store will work seven days a week, but not around the clock. Every day at least k people must work in the store.
Berland ... |
Solve the programming task below in a Python markdown code block.
Ivan wants to play a game with you. He picked some string $s$ of length $n$ consisting only of lowercase Latin letters.
You don't know this string. Ivan has informed you about all its improper prefixes and suffixes (i.e. prefixes and suffixes of lengt... |
Solve the programming task below in a Python markdown code block.
Create a function that takes a Number as its argument and returns a Chinese numeral string. You don't need to validate the input argument, it will always be a Number in the range `[-99999.999, 99999.999]`, rounded to 8 decimal places.
Simplified Chines... |
Solve the programming task below in a Python markdown code block.
You are given two strings a and b. You have to remove the minimum possible number of consecutive (standing one after another) characters from string b in such a way that it becomes a subsequence of string a. It can happen that you will not need to remov... |
Solve the programming task below in a Python markdown code block.
AtCoder's head office consists of N rooms numbered 1 to N. For any two rooms, there is a direct passage connecting these rooms.
For security reasons, Takahashi the president asked you to set a level for every passage, which is a positive integer and mu... |
Solve the programming task below in a Python markdown code block.
The Aizu Wakamatsu city office decided to lay a hot water pipeline covering the whole area of the city to heat houses. The pipeline starts from some hot springs and connects every district in the city. The pipeline can fork at a hot spring or a district... |
Solve the programming task below in a Python markdown code block.
Indian summer is such a beautiful time of the year! A girl named Alyona is walking in the forest and picking a bouquet from fallen leaves. Alyona is very choosy — she doesn't take a leaf if it matches the color and the species of the tree of one of the ... |
Solve the programming task below in a Python markdown code block.
DZY has a sequence a, consisting of n integers.
We'll call a sequence ai, ai + 1, ..., aj (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, suc... |
Solve the programming task below in a Python markdown code block.
Recently a top secret mission to Mars has taken place. As a result, scientists managed to obtain some information about the Martian DNA. Now we know that any Martian DNA contains at most m different nucleotides, numbered from 1 to m. Special characteris... |
Solve the programming task below in a Python markdown code block.
Takahashi loves palindromes. Non-palindromic strings are unacceptable to him. Each time he hugs a string, he can change one of its characters to any character of his choice.
Given is a string S. Find the minimum number of hugs needed to make S palindrom... |
Solve the programming task below in a Python markdown code block.
Given a rational number n
``` n >= 0, with denominator strictly positive```
- as a string (example: "2/3" in Ruby, Python, Clojure, JS, CS, Go)
- or as two strings (example: "2" "3" in Haskell, Java, CSharp, C++, Swift)
- or as a rational or decim... |
Solve the programming task below in a Python markdown code block.
The prime number sequence starts with: `2,3,5,7,11,13,17,19...`. Notice that `2` is in position `one`.
`3` occupies position `two`, which is a prime-numbered position. Similarly, `5`, `11` and `17` also occupy prime-numbered positions. We shall call p... |
Solve the programming task below in a Python markdown code block.
There is a game called "I Wanna Be the Guy", consisting of n levels. Little X and his friend Little Y are addicted to the game. Each of them wants to pass the whole game.
Little X can pass only p levels of the game. And Little Y can pass only q levels ... |
Solve the programming task below in a Python markdown code block.
Way to go! Heidi now knows how many brains there must be for her to get one. But throwing herself in the midst of a clutch of hungry zombies is quite a risky endeavor. Hence Heidi wonders: what is the smallest number of brains that must be in the chest ... |
Solve the programming task below in a Python markdown code block.
After years of hard work scientists invented an absolutely new e-reader display. The new display has a larger resolution, consumes less energy and its production is cheaper. And besides, one can bend it. The only inconvenience is highly unusual manageme... |
Solve the programming task below in a Python markdown code block.
In this Kata, you will be given a string and your task will be to return a list of ints detailing the count of uppercase letters, lowercase, numbers and special characters, as follows.
```Haskell
Solve("*'&ABCDabcde12345") = [4,5,5,3].
--the order is:... |
Solve the programming task below in a Python markdown code block.
Little penguin Polo adores integer segments, that is, pairs of integers [l; r] (l ≤ r).
He has a set that consists of n integer segments: [l_1; r_1], [l_2; r_2], ..., [l_{n}; r_{n}]. We know that no two segments of this set intersect. In one move Polo... |
Solve the programming task below in a Python markdown code block.
You are given a tree consisting of n nodes. You generate an array from the tree by marking nodes one by one.
Initially, when no nodes are marked, a node is equiprobably chosen and marked from the entire tree.
After that, until all nodes are marked, a... |
Solve the programming task below in a Python markdown code block.
In Berland, $n$ different types of banknotes are used. Banknotes of the $i$-th type have denomination $10^{a_i}$ burles (burles are the currency used in Berland); the denomination of banknotes of the first type is exactly $1$.
Let's denote $f(s)$ as th... |
Solve the programming task below in a Python markdown code block.
Snuke has a calculator. It has a display and two buttons.
Initially, the display shows an integer x. Snuke wants to change this value into another integer y, by pressing the following two buttons some number of times in arbitrary order:
* Button A: Wh... |
Solve the programming task below in a Python markdown code block.
The marketing team is spending way too much time typing in hashtags.
Let's help them with our own Hashtag Generator!
Here's the deal:
- It must start with a hashtag (`#`).
- All words must have their first letter capitalized.
- If the final result ... |
Solve the programming task below in a Python markdown code block.
Entrance Examination
The International Competitive Programming College (ICPC) is famous for its research on competitive programming. Applicants to the college are required to take its entrance examination.
The successful applicants of the examination ... |
Solve the programming task below in a Python markdown code block.
Each New Year Timofey and his friends cut down a tree of n vertices and bring it home. After that they paint all the n its vertices, so that the i-th vertex gets color ci.
Now it's time for Timofey birthday, and his mother asked him to remove the tree.... |
Solve the programming task below in a Python markdown code block.
Gift Exchange Party
A gift exchange party will be held at a school in TKB City.
For every pair of students who are close friends, one gift must be given from one to the other at this party, but not the other way around. It is decided in advance the gi... |
Solve the programming task below in a Python markdown code block.
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c.
You have to find minimum k such that there exists at least one k-dominant charact... |
Solve the programming task below in a Python markdown code block.
J - Tree Reconstruction
Problem Statement
You have a directed graph. Some non-negative value is assigned on each edge of the graph. You know that the value of the graph satisfies the flow conservation law That is, for every node v, the sum of values o... |
Solve the programming task below in a Python markdown code block.
A prime number is a number which has exactly two distinct divisors: one and itself. For example, numbers 2, 7, 3 are prime, and 1, 6, 4 are not.
The next prime number after x is the smallest prime number greater than x. For example, the next prime numb... |
Solve the programming task below in a Python markdown code block.
4 different points on the plane Read the coordinates of $ A (x_a, y_a) $, $ B (x_b, y_b) $, $ C (x_c, y_c) $, $ D (x_d, y_d) $ and read those 4 points Create a program that outputs YES if there is no dent in the quadrangle $ ABCD $ with the coordinates ... |
Solve the programming task below in a Python markdown code block.
You are given two strings of equal length $s$ and $t$ consisting of lowercase Latin letters. You may perform any number (possibly, zero) operations on these strings.
During each operation you choose two adjacent characters in any string and assign the ... |
Solve the programming task below in a Python markdown code block.
A group of university students wants to get to the top of a mountain to have a picnic there. For that they decided to use a cableway.
A cableway is represented by some cablecars, hanged onto some cable stations by a cable. A cable is scrolled cyclicall... |
Solve the programming task below in a Python markdown code block.
Create a function that takes a list of one or more non-negative integers, and arranges them such that they form the largest possible number.
Examples:
`largestArrangement([4, 50, 8, 145])` returns 8504145 (8-50-4-145)
`largestArrangement([4, 40, 7])`... |
Solve the programming task below in a Python markdown code block.
After passing a test, Vasya got himself a box of $n$ candies. He decided to eat an equal amount of candies each morning until there are no more candies. However, Petya also noticed the box and decided to get some candies for himself.
This means the pro... |
Solve the programming task below in a Python markdown code block.
Did you ever hear about 'Dragon Food' ? Its used to refer to the chocolates bought for your loved ones :). Po offers dragon food to master Shifu, who is a famous cook in the valley of food. In return, Shifu hands over the dragon scroll to Po, which is s... |
Solve the programming task below in a Python markdown code block.
Kurt reaches nirvana when he finds the product of all the digits of some positive integer. Greater value of the product makes the nirvana deeper.
Help Kurt find the maximum possible product of digits among all integers from $1$ to $n$.
-----Input----... |
Solve the programming task below in a Python markdown code block.
A widely known among some people Belarusian sport programmer Lesha decided to make some money to buy a one square meter larger flat. To do this, he wants to make and carry out a Super Rated Match (SRM) on the site Torcoder.com. But there's a problem — a... |
Solve the programming task below in a Python markdown code block.
We will define Ginkgo numbers and multiplication on Ginkgo numbers.
A Ginkgo number is a pair <m, n> where m and n are integers. For example, <1, 1>, <-2, 1> and <-3,-1> are Ginkgo numbers.
The multiplication on Ginkgo numbers is defined by <m, n> * <... |
Solve the programming task below in a Python markdown code block.
You are given an array $a$ consisting of $n$ positive integers. Find a non-empty subset of its elements such that their sum is even (i.e. divisible by $2$) or determine that there is no such subset.
Both the given array and required subset may contain ... |
Solve the programming task below in a Python markdown code block.
Jump is a simple one-player game:
You are initially at the first cell of an array of cells containing non-negative integers;
At each step you can jump ahead in the array as far as the integer at the current cell, or any smaller number of cells.
You wi... |
Solve the programming task below in a Python markdown code block.
You are given a sequence of positive integers a1, a2, ..., an. Find all such indices i, that the i-th element equals the arithmetic mean of all other elements (that is all elements except for this one).
Input
The first line contains the integer n (2 ≤... |
Solve the programming task below in a Python markdown code block.
Snark and Philip are preparing the problemset for the upcoming pre-qualification round for semi-quarter-finals. They have a bank of n problems, and they want to select any non-empty subset of it as a problemset.
k experienced teams are participating in... |
Solve the programming task below in a Python markdown code block.
Write a program which reads a sequence A of n elements and an integer M, and outputs "yes" if you can make M by adding elements in A, otherwise "no". You can use an element only once.
You are given the sequence A and q questions where each question con... |
Solve the programming task below in a Python markdown code block.
Casimir has a rectangular piece of paper with a checkered field of size $n \times m$. Initially, all cells of the field are white.
Let us denote the cell with coordinates $i$ vertically and $j$ horizontally by $(i, j)$. The upper left cell will be refe... |
Solve the programming task below in a Python markdown code block.
Gildong is playing with his dog, Badugi. They're at a park that has $n$ intersections and $n-1$ bidirectional roads, each $1$ meter in length and connecting two intersections with each other. The intersections are numbered from $1$ to $n$, and for every... |
Solve the programming task below in a Python markdown code block.
We have a directed weighted graph with N vertices. Each vertex has two integers written on it, and the integers written on Vertex i are A_i and B_i.
In this graph, there is an edge from Vertex x to Vertex y for all pairs 1 \leq x,y \leq N, and its weig... |
Solve the programming task below in a Python markdown code block.
A bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters + and 1 into this sequence. For example, sequences (())(), () and (()(())) are regular, while )(, (() and (()))( are not. Let's call a... |
Solve the programming task below in a Python markdown code block.
# Task
You are given a `moment` in time and space. What you must do is break it down into time and space, to determine if that moment is from the past, present or future.
`Time` is the sum of characters that increase time (i.e. numbers in range ['1'.... |
Solve the programming task below in a Python markdown code block.
A witch named Marie lived deep in a remote forest. Since she is a witch, she magically covers everything she needs to live, such as food, water, and fuel.
Her magic is activated by drawing a magic circle using some magical stones and strings. This magi... |
Solve the programming task below in a Python markdown code block.
You are given the strings $a$ and $b$, consisting of lowercase Latin letters. You can do any number of the following operations in any order:
if $|a| > 0$ (the length of the string $a$ is greater than zero), delete the first character of the string $a$... |
Solve the programming task below in a Python markdown code block.
A flower shop has got n bouquets, and the i-th bouquet consists of a_{i} flowers. Vasya, the manager of the shop, decided to make large bouquets from these bouquets.
Vasya thinks that a bouquet is large if it is made of two or more initial bouquets, a... |
Solve the programming task below in a Python markdown code block.
Heidi's friend Jenny is asking Heidi to deliver an important letter to one of their common friends. Since Jenny is Irish, Heidi thinks that this might be a prank. More precisely, she suspects that the message she is asked to deliver states: "Send the fo... |
Solve the programming task below in a Python markdown code block.
You are given an array $a$ consisting of $n$ integers.
Your task is to determine if $a$ has some subsequence of length at least $3$ that is a palindrome.
Recall that an array $b$ is called a subsequence of the array $a$ if $b$ can be obtained by remov... |
Solve the programming task below in a Python markdown code block.
Alice likes snow a lot! Unfortunately, this year's winter is already over, and she can't expect to have any more of it. Bob has thus bought her a gift — a large snow maker. He plans to make some amount of snow every day. On day i he will make a pile of ... |
Solve the programming task below in a Python markdown code block.
### Tongues
Gandalf's writings have long been available for study, but no one has yet figured out what language they are written in. Recently, due to programming work by a hacker known only by the code name ROT13, it has been discovered that Gandalf us... |
Solve the programming task below in a Python markdown code block.
Luntik came out for a morning stroll and found an array $a$ of length $n$. He calculated the sum $s$ of the elements of the array ($s= \sum_{i=1}^{n} a_i$). Luntik calls a subsequence of the array $a$ nearly full if the sum of the numbers in that subseq... |
Solve the programming task below in a Python markdown code block.
Snuke has N strings. The i-th string is s_i.
Let us concatenate these strings into one string after arranging them in some order. Find the maximum possible number of occurrences of `AB` in the resulting string.
Constraints
* 1 \leq N \leq 10^{4}
* 2 ... |
Solve the programming task below in a Python markdown code block.
There are N stones, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), the height of Stone i is h_i.
There is a frog who is initially on Stone 1. He will repeat the following action some number of times to reach Stone N:
* If the frog is currentl... |
Solve the programming task below in a Python markdown code block.
Write a function called calculate that takes 3 values. The first and third values are numbers. The second value is a character. If the character is "+" , "-", "*", or "/", the function will return the result of the corresponding mathematical function on... |
Solve the programming task below in a Python markdown code block.
Every evening Vitalya sets n alarm clocks to wake up tomorrow. Every alarm clock rings during exactly one minute and is characterized by one integer a_{i} — number of minute after midnight in which it rings. Every alarm clock begins ringing at the begin... |
Solve the programming task below in a Python markdown code block.
Ujan decided to make a new wooden roof for the house. He has $n$ rectangular planks numbered from $1$ to $n$. The $i$-th plank has size $a_i \times 1$ (that is, the width is $1$ and the height is $a_i$).
Now, Ujan wants to make a square roof. He will f... |
Solve the programming task below in a Python markdown code block.
"Duel!"
Betting on the lovely princess Claris, the duel between Tokitsukaze and Quailty has started.
There are $n$ cards in a row. Each card has two sides, one of which has color. At first, some of these cards are with color sides facing up and others... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.