question large_stringlengths 265 13.2k |
|---|
Solve the programming task below in a Python markdown code block.
You are given three strings $a$, $b$ and $c$ of the same length $n$. The strings consist of lowercase English letters only. The $i$-th letter of $a$ is $a_i$, the $i$-th letter of $b$ is $b_i$, the $i$-th letter of $c$ is $c_i$.
For every $i$ ($1 \leq ... |
Solve the programming task below in a Python markdown code block.
Palo Alto is an unusual city because it is an endless coordinate line. It is also known for the office of Lyft Level 5.
Lyft has become so popular so that it is now used by all $m$ taxi drivers in the city, who every day transport the rest of the city ... |
Solve the programming task below in a Python markdown code block.
Do you know Just Odd Inventions? The business of this company is to "just odd inventions". Here, it is abbreviated as JOI.
JOI is conducting research to confine many microorganisms in one petri dish alive. There are N microorganisms to be investigated,... |
Solve the programming task below in a Python markdown code block.
Peter wrote on the board a strictly increasing sequence of positive integers a_1, a_2, ..., a_{n}. Then Vasil replaced some digits in the numbers of this sequence by question marks. Thus, each question mark corresponds to exactly one lost digit.
Restor... |
Solve the programming task below in a Python markdown code block.
Example
Input
3
Output
1
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.
We understand that reading English is a great pain to many of you. So we’ll keep this problem statememt simple. Write a program that reports the point equally distant from a set of lines given as the input. In case of no solutions or multiple solutions,... |
Solve the programming task below in a Python markdown code block.
You're given an array $a$ of $n$ integers, such that $a_1 + a_2 + \cdots + a_n = 0$.
In one operation, you can choose two different indices $i$ and $j$ ($1 \le i, j \le n$), decrement $a_i$ by one and increment $a_j$ by one. If $i < j$ this operation i... |
Solve the programming task below in a Python markdown code block.
problem
Cryptography is all the rage at xryuseix's school. Xryuseix, who lives in a grid of cities, has come up with a new cryptography to decide where to meet.
The ciphertext consists of the $ N $ character string $ S $, and the $ S_i $ character det... |
Solve the programming task below in a Python markdown code block.
Pinkie Pie has bought a bag of patty-cakes with different fillings! But it appeared that not all patty-cakes differ from one another with filling. In other words, the bag contains some patty-cakes with the same filling.
Pinkie Pie eats the patty-cakes ... |
Solve the programming task below in a Python markdown code block.
# Task
Initially a number `1` is written on a board. It is possible to do the following operations with it:
```
multiply the number by 3;
increase the number by 5.```
Your task is to determine that using this two operations step by step, is it possible... |
Solve the programming task below in a Python markdown code block.
Recall that a binary search tree is a rooted binary tree, whose nodes each store a key and each have at most two distinguished subtrees, left and right. The key in each node must be greater than any key stored in the left subtree, and less than any key ... |
Solve the programming task below in a Python markdown code block.
In this Kata, you will be given an array of integers whose elements have both a negative and a positive value, except for one integer that is either only negative or only positive. Your task will be to find that integer.
Examples:
`[1, -1, 2, -2, 3] ... |
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.
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.
Heading ##There are two integers A and B. You are required to compute the bitwise AND amongst all natural numbers lying between A and B, both inclusive.
Input Format
First line of the input contains T, the number of testcases to follow.
Each testcase i... |
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.
To become a millionaire, M-kun has decided to make money by trading in the next N days. Currently, he has 1000 yen and no stocks - only one kind of stock is issued in the country where he lives.
He is famous across the country for his ability to forese... |
Solve the programming task below in a Python markdown code block.
Takahashi loves the number 7 and multiples of K.
Where is the first occurrence of a multiple of K in the sequence 7,77,777,\ldots? (Also see Output and Sample Input/Output below.)
If the sequence contains no multiples of K, print -1 instead.
-----Const... |
Solve the programming task below in a Python markdown code block.
Little penguin Polo adores strings. But most of all he adores strings of length n.
One day he wanted to find a string that meets the following conditions: The string consists of n lowercase English letters (that is, the string's length equals n), exac... |
Solve the programming task below in a Python markdown code block.
Polycarp wants to assemble his own keyboard. Layouts with multiple rows are too complicated for him — his keyboard will consist of only one row, where all $26$ lowercase Latin letters will be arranged in some order.
Polycarp uses the same password $s$ ... |
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.
Given are two strings s and t consisting of lowercase English letters. Determine if the number of non-negative integers i satisfying the following condition is finite, and find the maximum value of such i if the number is finite.
- There exists a non-n... |
Solve the programming task below in a Python markdown code block.
The Easter Rabbit laid n eggs in a circle and is about to paint them.
Each egg should be painted one color out of 7: red, orange, yellow, green, blue, indigo or violet. Also, the following conditions should be satisfied:
* Each of the seven colors ... |
Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin Chinese and Russian as well.
Chef wants to implement wildcard pattern matching supporting only the wildcard '?'. The wildcard character '?' can be substituted by any single lower case English letter for matching. H... |
Solve the programming task below in a Python markdown code block.
Your friend recently came up with a card game called UT-Rummy.
The cards used in this game are numbered red, green, or blue and any number from 1 to 9. Each player in this game has 9 cards in his or her hand, chooses one from his or her hand, discards ... |
Solve the programming task below in a Python markdown code block.
As you know Appu created aversion to Maths after that maths problem given by his teacher.So he stopped studying and began to do farming. He has some land where he starts growing sugarcane. At the end of the season he grew N sugarcanes. Is Appu satisfied... |
Solve the programming task below in a Python markdown code block.
You are given an array $a$ consisting of $n$ integers. Indices of the array start from zero (i. e. the first element is $a_0$, the second one is $a_1$, and so on).
You can reverse at most one subarray (continuous subsegment) of this array. Recall that ... |
Solve the programming task below in a Python markdown code block.
You are given a directed acyclic graph, consisting of $n$ vertices and $m$ edges. The vertices are numbered from $1$ to $n$. There are no multiple edges and self-loops.
Let $\mathit{in}_v$ be the number of incoming edges (indegree) and $\mathit{out}_v$... |
Solve the programming task below in a Python markdown code block.
Kuro and Shiro are playing with a board composed of n squares lining up in a row.
The squares are numbered 1 to n from left to right, and Square s has a mark on it.
First, for each square, Kuro paints it black or white with equal probability, independen... |
Solve the programming task below in a Python markdown code block.
Example
Input
3
y 7
y 6
n 5
Output
1
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.
Fukushima Prefecture is also famous for producing fruits, and among them, peaches and apples boast one of the highest production volumes in Japan. By the way, when I made a print manuscript of an English pamphlet for sale, I mistakenly wrote the descrip... |
Solve the programming task below in a Python markdown code block.
Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order t... |
Solve the programming task below in a Python markdown code block.
Let's pretend your company just hired your friend from college and paid you a referral bonus. Awesome! To celebrate, you're taking your team out to the terrible dive bar next door and using the referral bonus to buy, and build, the largest three-dimensi... |
Solve the programming task below in a Python markdown code block.
I have started studying electronics recently, and I came up with a circuit made up of 2 LEDs and 3 buttons.
Here 's how it works: 2 buttons (`red` and `blue`) are connected to the LEDs (`red` and `blue` respectively). Buttons pressing pattern will be r... |
Solve the programming task below in a Python markdown code block.
# Your Task
The city of Darkishland has a strange hotel with infinite rooms. The groups that come to this hotel follow the following rules:
* At the same time only members of one group can rent the hotel.
* Each group comes in the morning of the check... |
Solve the programming task below in a Python markdown code block.
Hideyuki is allowed by his father Ujisato some 1000 yen bills every month for his pocket money. In the first day of every month, the number of bills is decided as follows. Ujisato prepares n pieces of m-sided dice and declares the cutback k. Hideyuki ro... |
Solve the programming task below in a Python markdown code block.
You are given an array $a$ consisting of $n$ positive integers.
You are allowed to perform this operation any number of times (possibly, zero):
choose an index $i$ ($2 \le i \le n$), and change $a_i$ to $a_i - a_{i-1}$.
Is it possible to make $a_i=0$... |
Solve the programming task below in a Python markdown code block.
A [Mersenne prime](https://en.wikipedia.org/wiki/Mersenne_prime) is a prime number that can be represented as:
Mn = 2^(n) - 1. Therefore, every Mersenne prime is one less than a power of two.
Write a function that will return whether the given integer... |
Solve the programming task below in a Python markdown code block.
In a new version of the famous Pinball game, one of the most important parts of the game field is a sequence of n bumpers. The bumpers are numbered with integers from 1 to n from left to right. There are two types of bumpers. They are denoted by the cha... |
Solve the programming task below in a Python markdown code block.
Kuro has recently won the "Most intelligent cat ever" contest. The three friends then decided to go to Katie's home to celebrate Kuro's winning. After a big meal, they took a small break then started playing games.
Kuro challenged Katie to create a gam... |
Solve the programming task below in a Python markdown code block.
I've got a crazy mental illness.
I dislike numbers a lot. But it's a little complicated:
The number I'm afraid of depends on which day of the week it is...
This is a concrete description of my mental illness:
Monday --> 12
Tuesday --> numbers g... |
Solve the programming task below in a Python markdown code block.
Toastman came up with a very easy task. He gives it to Appleman, but Appleman doesn't know how to solve it. Can you help him?
Given a n × n checkerboard. Each cell of the board has either character 'x', or character 'o'. Is it true that each cell of th... |
Solve the programming task below in a Python markdown code block.
B-Mansion and courier
Problem Statement
Taro lives alone in a mansion. Taro, who loves studying, intends to study in his study in the house today. Taro can't concentrate outside the study, so he always studies in the study.
However, on this day, $ N ... |
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.
Alice bought a Congo Prime Video subscription and was watching a documentary on the archaeological findings from Factor's Island on Loch Katrine in Scotland. The archaeologists found a book whose age and origin are unknown. Perhaps Alice can make some s... |
Solve the programming task below in a Python markdown code block.
Alice likes word "nineteen" very much. She has a string s and wants the string to contain as many such words as possible. For that reason she can rearrange the letters of the string.
For example, if she has string "xiineteenppnnnewtnee", she can get st... |
Solve the programming task below in a Python markdown code block.
In elementary arithmetic a "carry" is a digit that is transferred from one column of digits to another column of more significant digits during a calculation algorithm.
This Kata is about determining the number of carries performed during the addition ... |
Solve the programming task below in a Python markdown code block.
Polycarp is a big lover of killing time in social networks. A page with a chatlist in his favourite network is made so that when a message is sent to some friend, his friend's chat rises to the very top of the page. The relative order of the other chats... |
Solve the programming task below in a Python markdown code block.
Take a sentence (string) and reverse each word in the sentence. Do not reverse the order of the words, just the letters in each word.
If there is punctuation, it should be interpreted as a regular character; no special rules.
If there is spacing befor... |
Solve the programming task below in a Python markdown code block.
Berland Music is a music streaming service built specifically to support Berland local artist. Its developers are currently working on a song recommendation module.
So imagine Monocarp got recommended $n$ songs, numbered from $1$ to $n$. The $i$-th son... |
Solve the programming task below in a Python markdown code block.
Given an array $a$ of length $n$, tell us whether it has a non-empty subsequence such that the product of its elements is not a perfect square.
A sequence $b$ is a subsequence of an array $a$ if $b$ can be obtained from $a$ by deleting some (possibly z... |
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 co... |
Solve the programming task below in a Python markdown code block.
Takahashi is participating in a programming contest, AXC001. He has just submitted his code to Problem A.
The problem has N test cases, all of which must be passed to get an AC verdict.
Takahashi's submission has passed M cases out of the N test cases... |
Solve the programming task below in a Python markdown code block.
There are $n$ segments on a $Ox$ axis $[l_1, r_1]$, $[l_2, r_2]$, ..., $[l_n, r_n]$. Segment $[l, r]$ covers all points from $l$ to $r$ inclusive, so all $x$ such that $l \le x \le r$.
Segments can be placed arbitrarily — be inside each other, coincid... |
Solve the programming task below in a Python markdown code block.
Some people leave the lights at their workplaces on when they leave that is a waste of resources. As a hausmeister of DHBW, Sagheer waits till all students and professors leave the university building, then goes and turns all the lights off.
The buildi... |
Solve the programming task below in a Python markdown code block.
Okabe needs bananas for one of his experiments for some strange reason. So he decides to go to the forest and cut banana trees.
Consider the point (x, y) in the 2D plane such that x and y are integers and 0 ≤ x, y. There is a tree in such a point, and ... |
Solve the programming task below in a Python markdown code block.
Little Artem likes electronics. He can spend lots of time making different schemas and looking for novelties in the nearest electronics store. The new control element was delivered to the store recently and Artem immediately bought it.
That element can... |
Solve the programming task below in a Python markdown code block.
It's Galactik Football time! The Galactik Football Assosiation (GFA) has announced a football tournament between all the teams of all the planets in the galaxy.
Each planet of the galaxy has a government. Some governments have a mutual agreement betwee... |
Solve the programming task below in a Python markdown code block.
-----Problem description-----
As a holiday gift, Tojo received a probability problem. The problem read as follows
Consider an N by M grid. Rows are numbered 1 to N, from top to bottom. Columns are numbered 1 to M, from left to right. You are initially a... |
Solve the programming task below in a Python markdown code block.
When you enter 8 numbers from 0 to 9, write a program that outputs the difference between the largest integer and the smallest integer that can sort the 8 numbers. The number that can be sorted may start from 0, such as 00135569.
Input
Given multipl... |
Solve the programming task below in a Python markdown code block.
"It all started with a kiss."
Chotu was up all night, planning for his first kiss. He has collected the data about all the kissing spots in Allahabad.
According to his survey there are N kissing spots in the city, each spot i is associated with a secur... |
Solve the programming task below in a Python markdown code block.
A dice is a cube, its faces contain distinct integers from 1 to 6 as black points. The sum of numbers at the opposite dice faces always equals 7. Please note that there are only two dice (these dices are mirror of each other) that satisfy the given cons... |
Solve the programming task below in a Python markdown code block.
Someday, Drazil wanted to go on date with Varda. Drazil and Varda live on Cartesian plane. Drazil's home is located in point (0, 0) and Varda's home is located in point (a, b). In each step, he can move in a unit distance in horizontal or vertical direc... |
Solve the programming task below in a Python markdown code block.
Arkady plays Gardenscapes a lot. Arkady wants to build two new fountains. There are n available fountains, for each fountain its beauty and cost are known. There are two types of money in the game: coins and diamonds, so each fountain cost can be either... |
Solve the programming task below in a Python markdown code block.
You are given an array a. Some element of this array a_{i} is a local minimum iff it is strictly less than both of its neighbours (that is, a_{i} < a_{i} - 1 and a_{i} < a_{i} + 1). Also the element can be called local maximum iff it is strictly greater... |
Solve the programming task below in a Python markdown code block.
You are playing one famous sandbox game with the three-dimensional world. The map of the world can be represented as a matrix of size n × m, where the height of the cell (i, j) is a_{i, j}.
You are in the cell (1, 1) right now and want to get in the ce... |
Solve the programming task below in a Python markdown code block.
Omkar is building a waterslide in his water park, and he needs your help to ensure that he does it as efficiently as possible.
Omkar currently has $n$ supports arranged in a line, the $i$-th of which has height $a_i$. Omkar wants to build his waterslid... |
Solve the programming task below in a Python markdown code block.
It is lunch time for Mole. His friend, Marmot, prepared him a nice game for lunch.
Marmot brought Mole n ordered piles of worms such that i-th pile contains a_{i} worms. He labeled all these worms with consecutive integers: worms in first pile are labe... |
Solve the programming task below in a Python markdown code block.
Ashish has a tree consisting of $n$ nodes numbered $1$ to $n$ rooted at node $1$. The $i$-th node in the tree has a cost $a_i$, and binary digit $b_i$ is written in it. He wants to have binary digit $c_i$ written in the $i$-th node in the end.
To achie... |
Solve the programming task below in a Python markdown code block.
Bertown is under siege! The attackers have blocked all the ways out and their cannon is bombarding the city. Fortunately, Berland intelligence managed to intercept the enemies' shooting plan. Let's introduce the Cartesian system of coordinates, the orig... |
Solve the programming task below in a Python markdown code block.
You have to create a function that converts integer given as string into ASCII uppercase letters.
All ASCII characters have their numerical order in table.
For example,
```
from ASCII table, character of number 65 is "A".
```
Numbers will be next t... |
Solve the programming task below in a Python markdown code block.
A-Aun's breathing
Problem Statement
Maeda-san and Goto-san, who will both turn 70 years old in 2060, are long-time friends and friends who fought together at the ACM-ICPC in college.
The two are still excited about competitive programming, drinking t... |
Solve the programming task below in a Python markdown code block.
You managed to send your friend to queue for tickets in your stead, but there is a catch: he will get there only if you tell him how much that is going to take. And everybody can only take one ticket at a time, then they go back in the last position of ... |
Solve the programming task below in a Python markdown code block.
Calculate the minimum number of characters you need to change in the string s, so that it contains at least k different letters, or print that it is impossible.
String s consists only of lowercase Latin letters, and it is allowed to change characters o... |
Solve the programming task below in a Python markdown code block.
Polycarp has a strict daily schedule. He has n alarms set for each day, and the i-th alarm rings each day at the same time during exactly one minute.
Determine the longest time segment when Polycarp can sleep, i. e. no alarm rings in that period. It is... |
Solve the programming task below in a Python markdown code block.
You are given two integers $l$ and $r$, $l\le r$. Find the largest possible value of $a mod b$ over all pairs $(a, b)$ of integers for which $r\ge a \ge b \ge l$.
As a reminder, $a mod b$ is a remainder we get when dividing $a$ by $b$. For example, $26... |
Solve the programming task below in a Python markdown code block.
Relative B man came to A child's house. He is 3 years old and loves singing. He is singing the song "Kobutanuki Tsuneko" (written and composed by Naozumi Yamamoto), which he learned from kindergarten. In this song, the four words "kobuta," "raccoon dog,... |
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.
Today you are going to lead a group of elven archers to defend the castle that is attacked by an army of angry orcs. Three sides of the castle are protected by impassable mountains and the remaining side is occupied by a long wall that is split into n s... |
Solve the programming task below in a Python markdown code block.
One of Arkady's friends works at a huge radio telescope. A few decades ago the telescope has sent a signal $s$ towards a faraway galaxy. Recently they've received a response $t$ which they believe to be a response from aliens! The scientists now want to... |
Solve the programming task below in a Python markdown code block.
Три брата договорились о встрече. Пронумеруем братьев следующим образом: пусть старший брат имеет номер 1, средний брат имеет номер 2, а младший брат — номер 3.
Когда пришло время встречи, один из братьев опоздал. По заданным номерам двух братьев, кот... |
Solve the programming task below in a Python markdown code block.
A permutation of length $n$ is an array consisting of $n$ distinct integers from $1$ to $n$ in arbitrary order. For example, $[2,3,1,5,4]$ is a permutation, but $[1,2,2]$ is not a permutation ($2$ appears twice in the array) and $[1,3,4]$ is also not a ... |
Solve the programming task below in a Python markdown code block.
Takahashi's house has only one socket.
Takahashi wants to extend it with some number of power strips, each with A sockets, into B or more empty sockets.
One power strip with A sockets can extend one empty socket into A empty sockets.
Find the minimum nu... |
Solve the programming task below in a Python markdown code block.
Takayuki and Kazuyuki are good twins, but their behavior is exactly the opposite. For example, if Takayuki goes west, Kazuyuki goes east, and if Kazuyuki goes north, Takayuki goes south. Currently the two are in a department store and are in different l... |
Solve the programming task below in a Python markdown code block.
There is a forest that we model as a plane and live $n$ rare animals. Animal number $i$ has its lair in the point $(x_{i}, y_{i})$. In order to protect them, a decision to build a nature reserve has been made.
The reserve must have a form of a circle c... |
Solve the programming task below in a Python markdown code block.
And again a misfortune fell on Poor Student. He is being late for an exam.
Having rushed to a bus stop that is in point (0, 0), he got on a minibus and they drove along a straight line, parallel to axis OX, in the direction of increasing x.
Poor Stude... |
Solve the programming task below in a Python markdown code block.
Taro and Hanako decided to play hit-and-blow. The hit-and-blow rules are as follows.
* Separated into questioners and respondents.
* The questioner decides a 4-digit number (correct answer) that does not include duplicate numbers.
* Respondents guess t... |
Solve the programming task below in a Python markdown code block.
Anton likes to play chess, and so does his friend Danik.
Once they have played n games in a row. For each game it's known who was the winner — Anton or Danik. None of the games ended with a tie.
Now Anton wonders, who won more games, he or Danik? Help... |
Solve the programming task below in a Python markdown code block.
A string is called beautiful if no two consecutive characters are equal. For example, "ababcb", "a" and "abab" are beautiful strings, while "aaaaaa", "abaa" and "bb" are not.
Ahcl wants to construct a beautiful string. He has a string $s$, consisting o... |
Solve the programming task below in a Python markdown code block.
Let us consider a grid of squares with 10^9 rows and N columns. Let (i, j) be the square at the i-th column (1 \leq i \leq N) from the left and j-th row (1 \leq j \leq 10^9) from the bottom.
Snuke has cut out some part of the grid so that, for each i =... |
Solve the programming task below in a Python markdown code block.
You are given a digital clock with $n$ digits. Each digit shows an integer from $0$ to $9$, so the whole clock shows an integer from $0$ to $10^n-1$. The clock will show leading zeroes if the number is smaller than $10^{n-1}$.
You want the clock to sho... |
Solve the programming task below in a Python markdown code block.
We have a string X, which has an even number of characters. Half the characters are `S`, and the other half are `T`.
Takahashi, who hates the string `ST`, will perform the following operation 10^{10000} times:
* Among the occurrences of `ST` in X as (... |
Solve the programming task below in a Python markdown code block.
Implement a function which behaves like the 'uniq -c' command in UNIX.
It takes as input a sequence and returns a sequence in which all duplicate elements following each other have been reduced to one instance together with the number of times a dupli... |
Solve the programming task below in a Python markdown code block.
An expedition group flew from planet ACM-1 to Earth in order to study the bipedal species (its representatives don't even have antennas on their heads!).
The flying saucer, on which the brave pioneers set off, consists of three sections. These sections... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.