question large_stringlengths 265 13.2k |
|---|
Solve the programming task below in a Python markdown code block.
You are given a permutation $p$ of $n$ integers $1$, $2$, ..., $n$ (a permutation is an array where each element from $1$ to $n$ occurs exactly once).
Let's call some subsegment $p[l, r]$ of this permutation special if $p_l + p_r = \max \limits_{i = l}... |
Solve the programming task below in a Python markdown code block.
# Fourier transformations are hard. Fouriest transformations are harder.
This Kata is based on the SMBC Comic on fourier transformations.
A fourier transformation on a number is one that converts the number to a base in which it has more `4`s ( `10` i... |
Solve the programming task below in a Python markdown code block.
Taro came to a square to look for treasure. There are many treasures buried in this square, but Taro has the latest machines, so he knows everything about where the treasures are buried. Since the square is very wide Taro decided to look for the treasur... |
Solve the programming task below in a Python markdown code block.
Passer ratings are the generally accepted standard for evaluating NFL quarterbacks.
I knew a rating of 100 is pretty good, but never knew what makes up the rating.
So out of curiosity I took a look at the wikipedia page and had an idea or my first kata:... |
Solve the programming task below in a Python markdown code block.
In Berland recently a new collection of toys went on sale. This collection consists of 10^9 types of toys, numbered with integers from 1 to 10^9. A toy from the new collection of the i-th type costs i bourles.
Tania has managed to collect n different t... |
Solve the programming task below in a Python markdown code block.
Decimal numbers are a common notation system currently in use and use ten symbols 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9 to represent all numbers.
Binary numbers are a popular notation in the computer world and use two symbols, 0 and 1, to represent all numb... |
Solve the programming task below in a Python markdown code block.
Your colleagues have been good enough(?) to buy you a birthday gift. Even though it is your birthday and not theirs, they have decided to play pass the parcel with it so that everyone has an even chance of winning. There are multiple presents, and you w... |
Solve the programming task below in a Python markdown code block.
Find places where a string P is found within a text T. Print all indices of T where P found. The indices of T start with 0.
Constraints
* 1 ≤ length of T ≤ 1000000
* 1 ≤ length of P ≤ 10000
* The input consists of alphabetical characters and digits
I... |
Solve the programming task below in a Python markdown code block.
The Smart Beaver from ABBYY began to develop a new educational game for children. The rules of the game are fairly simple and are described below.
The playing field is a sequence of n non-negative integers ai numbered from 1 to n. The goal of the game ... |
Solve the programming task below in a Python markdown code block.
Sakuzyo - Imprinting
A.R.C. Markland-N is a tall building with $n$ floors numbered from $1$ to $n$. Between each two adjacent floors in the building, there is a staircase connecting them.
It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he... |
Solve the programming task below in a Python markdown code block.
### Task
Yes, your eyes are no problem, this is toLoverCase (), not toLowerCase (), we want to make the world full of love.
### What do we need to do?
You need to add a prototype function to the String, the name is toLoverCase. Function can c... |
Solve the programming task below in a Python markdown code block.
Jon Snow is on the lookout for some orbs required to defeat the white walkers. There are k different types of orbs and he needs at least one of each. One orb spawns daily at the base of a Weirwood tree north of the wall. The probability of this orb bein... |
Solve the programming task below in a Python markdown code block.
You have to create a method "compoundArray" which should take as input two int arrays of different length and return one int array with numbers of both arrays shuffled one by one.
```Example:
Input - {1,2,3,4,5,6} and {9,8,7,6}
Output - {1,9,2,8,3,7,... |
Solve the programming task below in a Python markdown code block.
Given a sequence of integers a_1, ..., a_{n} and q queries x_1, ..., x_{q} on it. For each query x_{i} you have to count the number of pairs (l, r) such that 1 ≤ l ≤ r ≤ n and gcd(a_{l}, a_{l} + 1, ..., a_{r}) = x_{i}.
$\operatorname{gcd}(v_{1}, v_{2},... |
Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin Chinese and Russian as well.
As every other little boy, Mike has a favorite toy to play with. Mike's favorite toy is a set of N disks. The boy likes to compose his disks in stacks, but there's one very important ru... |
Solve the programming task below in a Python markdown code block.
Problem
Given the integer n, output the smallest m such that nCm (the number of combinations that choose m out of n different ones) is even.
Constraints
The input satisfies the following conditions.
* 1 ≤ n ≤ 1018
Input
The input is given in the f... |
Solve the programming task below in a Python markdown code block.
Write a function that accepts two parameters (a and b) and says whether a is smaller than, bigger than, or equal to b.
Here is an example code:
var noIfsNoButs = function (a,b) {
if(a > b) return a + " is greater than " + b
else if(a < b) return a ... |
Solve the programming task below in a Python markdown code block.
# Task
You are a lonely frog.
You live on an integer array.
The meaning of your life is to jump and jump..
Now, here comes your new task.
You are given an integer array `arr` and a positive integer `n`.
You will jump following the rules below:
... |
Solve the programming task below in a Python markdown code block.
We're giving away nice huge bags containing number tiles! A bag we want to present to you contains n tiles. Each of them has a single number written on it — either 1 or 2.
However, there is one condition you must fulfill in order to receive the prize. ... |
Solve the programming task below in a Python markdown code block.
In the year 30XX, an expedition team reached a planet and found a warp machine suggesting the existence of a mysterious supercivilization. When you go through one of its entrance gates, you can instantaneously move to the exit irrespective of how far aw... |
Solve the programming task below in a Python markdown code block.
Nowadays all circuses in Berland have a round arena with diameter 13 meters, but in the past things were different.
In Ancient Berland arenas in circuses were shaped as a regular (equiangular) polygon, the size and the number of angles could vary from ... |
Solve the programming task below in a Python markdown code block.
You are given $n$ numbers $a_1, a_2, \dots, a_n$. With a cost of one coin you can perform the following operation:
Choose one of these numbers and add or subtract $1$ from it.
In particular, we can apply this operation to the same number several times... |
Solve the programming task below in a Python markdown code block.
There are times you recall a good old friend and everything you've come through together. Luckily there are social networks — they store all your message history making it easy to know what you argued over 10 years ago.
More formal, your message histor... |
Solve the programming task below in a Python markdown code block.
Vanya has a table consisting of 100 rows, each row contains 100 cells. The rows are numbered by integers from 1 to 100 from bottom to top, the columns are numbered from 1 to 100 from left to right.
In this table, Vanya chose n rectangles with sides th... |
Solve the programming task below in a Python markdown code block.
A string of length 6 consisting of lowercase English letters is said to be coffee-like if and only if its 3-rd and 4-th characters are equal and its 5-th and 6-th characters are also equal.
Given a string S, determine whether it is coffee-like.
-----C... |
Solve the programming task below in a Python markdown code block.
The Floral Clock has been standing by the side of Mirror Lake for years. Though unable to keep time, it reminds people of the passage of time and the good old days.
On the rim of the Floral Clock are 2n flowers, numbered from 1 to 2n clockwise, each of... |
Solve the programming task below in a Python markdown code block.
In telecomunications we use information coding to detect and prevent errors while sending data.
A parity bit is a bit added to a string of binary code that indicates whether the number of 1-bits in the string is even or odd. Parity bits are used as th... |
Solve the programming task below in a Python markdown code block.
Little Artem found a grasshopper. He brought it to his house and constructed a jumping area for him.
The area looks like a strip of cells 1 × n. Each cell contains the direction for the next jump and the length of that jump. Grasshopper starts in the f... |
Solve the programming task below in a Python markdown code block.
Given a positive number n > 1 find the prime factor decomposition of n.
The result will be a string with the following form :
```
"(p1**n1)(p2**n2)...(pk**nk)"
```
where ```a ** b``` means ```a``` to the power of ```b```
with the p(i) in increasing or... |
Solve the programming task below in a Python markdown code block.
problem
AOR Ika made a set $ S = \\ {a_1, ..., a_N \\} $ and a map $ f: S → S $. $ f (a_i) = b_i $. For any element $ x $ in the set $ S $, all maps $ g, h: S → S $ satisfying $ g (f (x)) = h (f (x)) $ are $ g (x). ) = Determine if h (x) $ is satisfied... |
Solve the programming task below in a Python markdown code block.
Given a string containing a list of integers separated by commas, write the function string_to_int_list(s) that takes said string and returns a new list containing all integers present in the string, preserving the order.
For example, give the string "... |
Solve the programming task below in a Python markdown code block.
There is a chain consisting of multiple circles on a plane. The first (last) circle of the chain only intersects with the next (previous) circle, and each intermediate circle intersects only with the two neighboring circles.
Your task is to find the sh... |
Solve the programming task below in a Python markdown code block.
You are given a sequence of $n$ integers $a_1$, $a_2$, ..., $a_n$. Let us call an index $j$ ($2 \le j \le {{n-1}}$) a hill if $a_j > a_{{j+1}}$ and $a_j > a_{{j-1}}$; and let us call it a valley if $a_j < a_{{j+1}}$ and $a_j < a_{{j-1}}$.
Let us define... |
Solve the programming task below in a Python markdown code block.
Bandits appeared in the city! One of them is trying to catch as many citizens as he can.
The city consists of $n$ squares connected by $n-1$ roads in such a way that it is possible to reach any square from any other square. The square number $1$ is the... |
Solve the programming task below in a Python markdown code block.
Student Andrey has been skipping physical education lessons for the whole term, and now he must somehow get a passing grade on this subject. Obviously, it is impossible to do this by legal means, but Andrey doesn't give up. Having obtained an empty cert... |
Solve the programming task below in a Python markdown code block.
Danny, the local Math Maniac, is fascinated by circles, Omkar's most recent creation. Help him solve this circle problem!
You are given $n$ nonnegative integers $a_1, a_2, \dots, a_n$ arranged in a circle, where $n$ must be odd (ie. $n-1$ is divisible ... |
Solve the programming task below in a Python markdown code block.
Recently, Tokitsukaze found an interesting game. Tokitsukaze had $n$ items at the beginning of this game. However, she thought there were too many items, so now she wants to discard $m$ ($1 \le m \le n$) special items of them.
These $n$ items are marke... |
Solve the programming task below in a Python markdown code block.
Create a __moreZeros__ function which will __receive a string__ for input, and __return an array__ (or null terminated string in C) containing only the characters from that string whose __binary representation of its ASCII value__ consists of _more zero... |
Solve the programming task below in a Python markdown code block.
You are a secret agent from the Intelligence Center of Peacemaking Committee. You've just sneaked into a secret laboratory of an evil company, Automated Crime Machines.
Your mission is to get a confidential document kept in the laboratory. To reach the... |
Solve the programming task below in a Python markdown code block.
Nowadays, most of the internet advertisements are not statically linked to a web page. Instead, what will be shown to the person opening a web page is determined within 100 milliseconds after the web page is opened. Usually, multiple companies compete f... |
Solve the programming task below in a Python markdown code block.
Valera loves his garden, where n fruit trees grow.
This year he will enjoy a great harvest! On the i-th tree b_{i} fruit grow, they will ripen on a day number a_{i}. Unfortunately, the fruit on the tree get withered, so they can only be collected on da... |
Solve the programming task below in a Python markdown code block.
You are given a complete undirected graph. For each pair of vertices you are given the length of the edge that connects them. Find the shortest paths between each pair of vertices in the graph and return the length of the longest of them.
-----Input--... |
Solve the programming task below in a Python markdown code block.
On a clear night, a boy, Campanella looked up at the sky, there were many stars which have different colors such as red, yellow, green, blue, purple, etc. He was watching the stars and just lost track of time. Presently, he wondered,
| <image>
---|---... |
Solve the programming task below in a Python markdown code block.
Santa has to send presents to the kids. He has a large stack of $n$ presents, numbered from $1$ to $n$; the topmost present has number $a_1$, the next present is $a_2$, and so on; the bottom present has number $a_n$. All numbers are distinct.
Santa has... |
Solve the programming task below in a Python markdown code block.
Today is the ticket release date for Aizu Entertainment's recommended idol group "Akabeko & Koboushi". There are four types of tickets:
S seat 6000 yen
A seat 4000 yen
B seat 3000 yen
C seat 2000 yen
You, the sales manager, are excitedly waiting for t... |
Solve the programming task below in a Python markdown code block.
In the speed skating badge test, grades are awarded when the time specified for two distances is exceeded. For example, to reach Class A, 500 M requires less than 40.0 seconds and 1000 M requires less than 1 minute and 23 seconds.
Create a program that... |
Solve the programming task below in a Python markdown code block.
Imp is in a magic forest, where xorangles grow (wut?)
[Image]
A xorangle of order n is such a non-degenerate triangle, that lengths of its sides are integers not exceeding n, and the xor-sum of the lengths is equal to zero. Imp has to count the numb... |
Solve the programming task below in a Python markdown code block.
You are given array $a_1, a_2, \ldots, a_n$, consisting of non-negative integers.
Let's define operation of "elimination" with integer parameter $k$ ($1 \leq k \leq n$) as follows:
Choose $k$ distinct array indices $1 \leq i_1 < i_2 < \ldots < i_k \le... |
Solve the programming task below in a Python markdown code block.
The only difference between the easy and the hard versions is the maximum value of $k$.
You are given an infinite sequence of form "112123123412345$\dots$" which consist of blocks of all consecutive positive integers written one after another. The firs... |
Solve the programming task below in a Python markdown code block.
Create a program of the square picking method, which is one of the classical random number generation methods. The square harvesting method was proposed by von Neumann in the mid-1940s.
In the square picking method, when the number of digits of the gen... |
Solve the programming task below in a Python markdown code block.
Inaka has a disc, the circumference of which is n units. The circumference is equally divided by n points numbered clockwise from 1 to n, such that points i and i + 1 (1 ≤ i < n) are adjacent, and so are points n and 1.
There are m straight segments on... |
Solve the programming task below in a Python markdown code block.
Vova has taken his summer practice this year and now he should write a report on how it went.
Vova has already drawn all the tables and wrote down all the formulas. Moreover, he has already decided that the report will consist of exactly $n$ pages and ... |
Solve the programming task below in a Python markdown code block.
In this kata, your task is to identify the pattern underlying a sequence of numbers. For example, if the sequence is [1, 2, 3, 4, 5], then the pattern is [1], since each number in the sequence is equal to the number preceding it, plus 1. See the test ca... |
Solve the programming task below in a Python markdown code block.
It seems that Borya is seriously sick. He is going visit n doctors to find out the exact diagnosis. Each of the doctors needs the information about all previous visits, so Borya has to visit them in the prescribed order (i.e. Borya should first visit do... |
Solve the programming task below in a Python markdown code block.
Converting a normal (12-hour) time like "8:30 am" or "8:30 pm" to 24-hour time (like "0830" or "2030") sounds easy enough, right? Well, let's see if you can do it!
You will have to define a function named "to24hourtime", and you will be given an hour ... |
Solve the programming task below in a Python markdown code block.
Dima has a birthday soon! It's a big day! Saryozha's present to Dima is that Seryozha won't be in the room and won't disturb Dima and Inna as they celebrate the birthday. Inna's present to Dima is a stack, a queue and a deck.
Inna wants her present to ... |
Solve the programming task below in a Python markdown code block.
"Night gathers, and now my watch begins. It shall not end until my death. I shall take no wife, hold no lands, father no children. I shall wear no crowns and win no glory. I shall live and die at my post. I am the sword in the darkness. I am the watcher... |
Solve the programming task below in a Python markdown code block.
You can obtain profits from foreign exchange margin transactions. For example, if you buy 1000 dollar at a rate of 100 yen per dollar, and sell them at a rate of 108 yen per dollar, you can obtain (108 - 100) × 1000 = 8000 yen.
Write a program which re... |
Solve the programming task below in a Python markdown code block.
Sonya was unable to think of a story for this problem, so here comes the formal description.
You are given the array containing n positive integers. At one turn you can pick any element and increase or decrease it by 1. The goal is the make the array s... |
Solve the programming task below in a Python markdown code block.
Consider the following arithmetic progression with n terms:
* x, x + d, x + 2d, \ldots, x + (n-1)d
What is the product of all terms in this sequence? Compute the answer modulo 1\ 000\ 003.
You are given Q queries of this form. In the i-th query, co... |
Solve the programming task below in a Python markdown code block.
You will be given a vector of strings. You must sort it alphabetically (case-sensitive, and based on the ASCII values of the chars) and then return the first value.
The returned value must be a string, and have `"***"` between each of its letters.
You... |
Solve the programming task below in a Python markdown code block.
A revolution took place on the Buka Island. New government replaced the old one. The new government includes n parties and each of them is entitled to some part of the island according to their contribution to the revolution. However, they can't divide ... |
Solve the programming task below in a Python markdown code block.
Vova's family is building the Great Vova Wall (named by Vova himself). Vova's parents, grandparents, grand-grandparents contributed to it. Now it's totally up to Vova to put the finishing touches.
The current state of the wall can be respresented by a ... |
Solve the programming task below in a Python markdown code block.
Denis, after buying flowers and sweets (you will learn about this story in the next task), went to a date with Nastya to ask her to become a couple. Now, they are sitting in the cafe and finally... Denis asks her to be together, but ... Nastya doesn't g... |
Solve the programming task below in a Python markdown code block.
There is a programing contest named SnakeUp, 2n people want to compete for it. In order to attend this contest, people need to form teams of exactly two people. You are given the strength of each possible combination of two people. All the values of the... |
Solve the programming task below in a Python markdown code block.
Alex, Bob and Carl will soon participate in a team chess tournament. Since they are all in the same team, they have decided to practise really hard before the tournament. But it's a bit difficult for them because chess is a game for two players, not thr... |
Solve the programming task below in a Python markdown code block.
Given an integer $x$. Your task is to find out how many positive integers $n$ ($1 \leq n \leq x$) satisfy $$n \cdot a^n \equiv b \quad (\textrm{mod}\;p),$$ where $a, b, p$ are all known constants.
-----Input-----
The only line contains four integers ... |
Solve the programming task below in a Python markdown code block.
Implement `String#ipv4_address?`, which should return true if given object is an IPv4 address - four numbers (0-255) separated by dots.
It should only accept addresses in canonical representation, so no leading `0`s, spaces etc.
Write your solution by... |
Solve the programming task below in a Python markdown code block.
After rejecting 10^{100} data structure problems, Errorgorn is very angry at Anton and decided to kill him.
Anton's DNA can be represented as a string a which only contains the characters "ANTON" (there are only 4 distinct characters).
Errorgorn can ... |
Solve the programming task below in a Python markdown code block.
As a token of his gratitude, Takahashi has decided to give his mother an integer sequence.
The sequence A needs to satisfy the conditions below:
- A consists of integers between X and Y (inclusive).
- For each 1\leq i \leq |A|-1, A_{i+1} is a multiple... |
Solve the programming task below in a Python markdown code block.
Mr. Frugal bought a new house. He feels deeply in love with his new house because it has a comfortable living room in which he can put himself completely at ease. He thinks his new house is a really good buy.
But, to his disappointment, the floor of it... |
Solve the programming task below in a Python markdown code block.
The purpose of this series is developing understanding of stastical problems in AS and A level maths. Let's get started with a simple concept in statistics: Mutually exclusive events.
The probability of an OR event is calculated by the following rule:
... |
Solve the programming task below in a Python markdown code block.
A Narcissistic Number is a number of length n in which the sum of its digits to the power of n is equal to the original number. If this seems confusing, refer to the example below.
Ex: 153, where n = 3 (number of digits in 153)
1^(3) + 5^(3) + 3^(3) = ... |
Solve the programming task below in a Python markdown code block.
Dima and his friends have been playing hide and seek at Dima's place all night. As a result, Dima's place got messy. In the morning they decided that they need to clean the place.
To decide who exactly would clean the apartment, the friends want to pla... |
Solve the programming task below in a Python markdown code block.
We all know the impressive story of Robin Hood. Robin Hood uses his archery skills and his wits to steal the money from rich, and return it to the poor.
There are n citizens in Kekoland, each person has ci coins. Each day, Robin Hood will take exactly ... |
Solve the programming task below in a Python markdown code block.
You are given two positive integers `a` and `b` (`a < b <= 20000`). Complete the function which returns a list of all those numbers in the interval `[a, b)` whose digits are made up of prime numbers (`2, 3, 5, 7`) but which are not primes themselves.
... |
Solve the programming task below in a Python markdown code block.
In Berland each high school student is characterized by academic performance — integer value between 1 and 5.
In high school 0xFF there are two groups of pupils: the group A and the group B. Each group consists of exactly n students. An academic perfor... |
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.
Mothers arranged a dance party for the children in school. At that party, there are only mothers and their children. All are having great fun on the dance floor when suddenly all the lights went out. It's a dark night and no one can see each other. But ... |
Solve the programming task below in a Python markdown code block.
Do you know the story about the three musketeers? Anyway, you must help them now.
Richelimakieu is a cardinal in the city of Bearis. He found three brave warriors and called them the three musketeers. Athos has strength a, Borthos strength b, and Caram... |
Solve the programming task below in a Python markdown code block.
Consider the following series:
`0,1,2,3,4,5,6,7,8,9,10,22,11,20,13,24...`There is nothing special between numbers `0` and `10`.
Let's start with the number `10` and derive the sequence. `10` has digits `1` and `0`. The next possible number that does ... |
Solve the programming task below in a Python markdown code block.
Kostya likes Codeforces contests very much. However, he is very disappointed that his solutions are frequently hacked. That's why he decided to obfuscate (intentionally make less readable) his code before upcoming contest.
To obfuscate the code, Kostya... |
Solve the programming task below in a Python markdown code block.
Polycarpus got an internship in one well-known social network. His test task is to count the number of unique users who have visited a social network during the day. Polycarpus was provided with information on all user requests for this time period. For... |
Solve the programming task below in a Python markdown code block.
You are given four digits N_1, N_2, N_3 and N_4. Determine if these can be arranged into the sequence of digits "1974".
Constraints
* 0 \leq N_1, N_2, N_3, N_4 \leq 9
* N_1, N_2, N_3 and N_4 are integers.
Input
Input is given from Standard Input in ... |
Solve the programming task below in a Python markdown code block.
You are given two strings $s$ and $t$, both consisting only of lowercase Latin letters.
The substring $s[l..r]$ is the string which is obtained by taking characters $s_l, s_{l + 1}, \dots, s_r$ without changing the order.
Each of the occurrences of st... |
Solve the programming task below in a Python markdown code block.
While Vasya finished eating his piece of pizza, the lesson has already started. For being late for the lesson, the teacher suggested Vasya to solve one interesting problem. Vasya has an array a and integer x. He should find the number of different order... |
Solve the programming task below in a Python markdown code block.
Little Petya very much likes gifts. Recently he has received a new laptop as a New Year gift from his mother. He immediately decided to give it to somebody else as what can be more pleasant than giving somebody gifts. And on this occasion he organized a... |
Solve the programming task below in a Python markdown code block.
E869120 found a chest which is likely to contain treasure.
However, the chest is locked. In order to open it, he needs to enter a string S consisting of lowercase English letters.
He also found a string S', which turns out to be the string S with some... |
Solve the programming task below in a Python markdown code block.
## Introduction
Each chemical element in its neutral state has a specific number of electrons associated with it. This is represented by the **atomic number** which is noted by an integer number next to or above each element of the periodic table (as ... |
Solve the programming task below in a Python markdown code block.
Today we will be playing a red and white colouring game (no, this is not the Russian Civil War; these are just the colours of the Canadian flag).
You are given an $n \times m$ grid of "R", "W", and "." characters. "R" is red, "W" is white and "." is bl... |
Solve the programming task below in a Python markdown code block.
Good evening, contestants.
If a and d are relatively prime positive integers, the arithmetic sequence beginning with a and increasing by d, i.e., a, a + d, a + 2d, a + 3d, a + 4d, ..., contains infinitely many prime numbers. This fact is known as Diric... |
Solve the programming task below in a Python markdown code block.
Problem
There are $ N $ Amidakuji with 3 vertical lines.
No matter which line you start from, the Amidakuji that ends at the starting line is considered a good Amidakuji.
You can select one or more Amidakuji and connect them vertically in any order.
Ou... |
Solve the programming task below in a Python markdown code block.
Array inversion indicates how far the array is from being sorted.
Inversions are pairs of elements in array that are out of order.
## Examples
```
[1, 2, 3, 4] => 0 inversions
[1, 3, 2, 4] => 1 inversion: 2 and 3
[4, 1, 2, 3] => 3 inversions: 4... |
Solve the programming task below in a Python markdown code block.
Problem statement
N first-year students of the Faculty of Information Science and Technology of R University take the final exam of the lecture called Programming Exercise 1. The test is a perfect score of m. In other words, the score that one student ... |
Solve the programming task below in a Python markdown code block.
A palindrome is a string $t$ which reads the same backward as forward (formally, $t[i] = t[|t| + 1 - i]$ for all $i \in [1, |t|]$). Here $|t|$ denotes the length of a string $t$. For example, the strings 010, 1001 and 0 are palindromes.
You have $n$ bi... |
Solve the programming task below in a Python markdown code block.
Search trees are data structures that support dynamic set operations including insert, search, delete and so on. Thus a search tree can be used both as a dictionary and as a priority queue.
Binary search tree is one of fundamental search trees. The key... |
Solve the programming task below in a Python markdown code block.
Taro is going to play a card game. However, now he has only n cards, even though there should be 52 cards (he has no Jokers).
The 52 cards include 13 ranks of each of the four suits: spade, heart, club and diamond.
Note
解説
Input
In the first line... |
Solve the programming task below in a Python markdown code block.
Chaneka has a hobby of playing with animal toys. Every toy has a different fun value, a real number. Chaneka has four boxes to store the toys with specification: The first box stores toys with fun values in range of $(-\infty,-1]$. The second box sto... |
Solve the programming task below in a Python markdown code block.
Just in case somebody missed it: this winter is totally cold in Nvodsk! It is so cold that one gets funny thoughts. For example, let's say there are strings with the length exactly n, based on the alphabet of size m. Any its substring with length equal ... |
Solve the programming task below in a Python markdown code block.
Write a function that takes a string and returns an array of the repeated characters (letters, numbers, whitespace) in the string.
If a charater is repeated more than once, only show it once in the result array.
Characters should be shown **by the ord... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.