question large_stringlengths 265 13.2k |
|---|
Solve the programming task below in a Python markdown code block.
A rabbit who came to the fair found that the prize for a game at a store was a carrot cake. The rules for this game are as follows.
There is a grid-like field of vertical h squares x horizontal w squares, and each block has at most one block. Each bloc... |
Solve the programming task below in a Python markdown code block.
A: Flick input
A college student who loves 2D, commonly known as 2D, replaced his long-used Galapagos mobile phone with a smartphone. 2D, who operated the smartphone for the first time, noticed that the character input method was a little different fro... |
Solve the programming task below in a Python markdown code block.
Example
Input
7
>>
Output
7
The input will be give
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.
Problem
Taro has N character strings, each of which is L in length. Taro loves palindromes, so I want to make palindromes as long as possible by selecting some of the N character strings and arranging them in any order.
Find the longest palindrome tha... |
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.
Little C loves number Β«3Β» very much. He loves all things about it.
Now he has a positive integer n. He wants to split n into 3 positive integers a,b,c, such that a+b+c=n and none of the 3 integers is a multiple of 3. Help him to find a solution.
Input... |
Solve the programming task below in a Python markdown code block.
There is a colony of villains with several holes aligned in a row, where each hole contains exactly one villain.
Each colony arrangement can be expressed as a string of even length, where the i-th character of the string represents the type of villain ... |
Solve the programming task below in a Python markdown code block.
Each day in Berland consists of n hours. Polycarp likes time management. That's why he has a fixed schedule for each day β it is a sequence a_1, a_2, ..., a_n (each a_i is either 0 or 1), where a_i=0 if Polycarp works during the i-th hour of the day and... |
Solve the programming task below in a Python markdown code block.
A company has n employees numbered from 1 to n. Each employee either has no immediate manager or exactly one immediate manager, who is another employee with a different number. An employee A is said to be the superior of another employee B if at least o... |
Solve the programming task below in a Python markdown code block.
You have a given integer n. Find the number of ways to fill all 3 Γ n tiles with the shape described in the picture below. Upon filling, no empty spaces are allowed. Shapes cannot overlap.
<image> This picture describes when n = 4. The left one is the ... |
Solve the programming task below in a Python markdown code block.
A sequence a0, a1, ..., at - 1 is called increasing if ai - 1 < ai for each i: 0 < i < t.
You are given a sequence b0, b1, ..., bn - 1 and a positive integer d. In each move you may choose one element of the given sequence and add d to it. What is the ... |
Solve the programming task below in a Python markdown code block.
You are an environmental activist at heart but the reality is harsh and you are just a cashier in a cinema. But you can still do something!
You have n tickets to sell. The price of the i-th ticket is p_i. As a teller, you have a possibility to select t... |
Solve the programming task below in a Python markdown code block.
You are given two integers a and b. You may perform any number of operations on them (possibly zero).
During each operation you should choose any positive integer x and set a := a - x, b := b - 2x or a := a - 2x, b := b - x. Note that you may choose di... |
Solve the programming task below in a Python markdown code block.
This is the hard version of this problem. The only difference is the constraint on k β the number of gifts in the offer. In this version: 2 β€ k β€ n.
Vasya came to the store to buy goods for his friends for the New Year. It turned out that he was very l... |
Solve the programming task below in a Python markdown code block.
You are given a permutation p_1, p_2, β¦, p_n of integers from 1 to n and an integer k, such that 1 β€ k β€ n. A permutation means that every number from 1 to n is contained in p exactly once.
Let's consider all partitions of this permutation into k disjo... |
Solve the programming task below in a Python markdown code block.
A card pyramid of height 1 is constructed by resting two cards against each other. For h>1, a card pyramid of height h is constructed by placing a card pyramid of height h-1 onto a base. A base consists of h pyramids of height 1, and h-1 cards on top. F... |
Solve the programming task below in a Python markdown code block.
Alice guesses the strings that Bob made for her.
At first, Bob came up with the secret string a consisting of lowercase English letters. The string a has a length of 2 or more characters. Then, from string a he builds a new string b and offers Alice th... |
Solve the programming task below in a Python markdown code block.
Despite his bad reputation, Captain Flint is a friendly person (at least, friendly to animals). Now Captain Flint is searching worthy sailors to join his new crew (solely for peaceful purposes). A sailor is considered as worthy if he can solve Flint's t... |
Solve the programming task below in a Python markdown code block.
Once upon a time in the Kingdom of Far Far Away lived Sir Lancelot, the chief Royal General. He was very proud of his men and he liked to invite the King to come and watch drill exercises which demonstrated the fighting techniques and tactics of the squ... |
Solve the programming task below in a Python markdown code block.
There are n + 1 cities, numbered from 0 to n. n roads connect these cities, the i-th road connects cities i - 1 and i (i β [1, n]).
Each road has a direction. The directions are given by a string of n characters such that each character is either L or ... |
Solve the programming task below in a Python markdown code block.
Once upon a time, Oolimry saw a suffix array. He wondered how many strings can produce this suffix array.
More formally, given a suffix array of length n and having an alphabet size k, count the number of strings that produce such a suffix array.
Le... |
Solve the programming task below in a Python markdown code block.
Vasya is writing an operating system shell, and it should have commands for working with directories. To begin with, he decided to go with just two commands: cd (change the current directory) and pwd (display the current directory).
Directories in Vasy... |
Solve the programming task below in a Python markdown code block.
Mad scientist Mike has just finished constructing a new device to search for extraterrestrial intelligence! He was in such a hurry to launch it for the first time that he plugged in the power wires without giving it a proper glance and started experimen... |
Solve the programming task below in a Python markdown code block.
Inna is a great piano player and Dima is a modest guitar player. Dima has recently written a song and they want to play it together. Of course, Sereja wants to listen to the song very much.
A song is a sequence of notes. Dima and Inna want to play eac... |
Solve the programming task below in a Python markdown code block.
The R1 company has recently bought a high rise building in the centre of Moscow for its main office. It's time to decorate the new office, and the first thing to do is to write the company's slogan above the main entrance to the building.
The slogan of... |
Solve the programming task below in a Python markdown code block.
While dad was at work, a little girl Tanya decided to play with dad's password to his secret database. Dad's password is a string consisting of n + 2 characters. She has written all the possible n three-letter continuous substrings of the password on pi... |
Solve the programming task below in a Python markdown code block.
The GCD table G of size n Γ n for an array of positive integers a of length n is defined by formula
<image>
Let us remind you that the greatest common divisor (GCD) of two positive integers x and y is the greatest integer that is divisor of both x an... |
Solve the programming task below in a Python markdown code block.
Mikhail the Freelancer dreams of two things: to become a cool programmer and to buy a flat in Moscow. To become a cool programmer, he needs at least p experience points, and a desired flat in Moscow costs q dollars. Mikhail is determined to follow his d... |
Solve the programming task below in a Python markdown code block.
Vasya's telephone contains n photos. Photo number 1 is currently opened on the phone. It is allowed to move left and right to the adjacent photo by swiping finger over the screen. If you swipe left from the first photo, you reach photo n. Similarly, by ... |
Solve the programming task below in a Python markdown code block.
Vanya smashes potato in a vertical food processor. At each moment of time the height of the potato in the processor doesn't exceed h and the processor smashes k centimeters of potato each second. If there are less than k centimeters remaining, than duri... |
Solve the programming task below in a Python markdown code block.
President of Berland has a very vast office-room, where, apart from him, work his subordinates. Each subordinate, as well as President himself, has his own desk of a unique colour. Each desk is rectangular, and its sides are parallel to the office walls... |
Solve the programming task below in a Python markdown code block.
Recently Maxim has found an array of n integers, needed by no one. He immediately come up with idea of changing it: he invented positive integer x and decided to add or subtract it from arbitrary array elements. Formally, by applying single operation Ma... |
Solve the programming task below in a Python markdown code block.
Chloe, the same as Vladik, is a competitive programmer. She didn't have any problems to get to the olympiad like Vladik, but she was confused by the task proposed on the olympiad.
Let's consider the following algorithm of generating a sequence of integ... |
Solve the programming task below in a Python markdown code block.
Mahmoud wants to write a new dictionary that contains n words and relations between them. There are two types of relations: synonymy (i. e. the two words mean the same) and antonymy (i. e. the two words mean the opposite). From time to time he discovers... |
Solve the programming task below in a Python markdown code block.
The flag of Berland is such rectangular field n Γ m that satisfies following conditions:
* Flag consists of three colors which correspond to letters 'R', 'G' and 'B'.
* Flag consists of three equal in width and height stripes, parralel to each oth... |
Solve the programming task below in a Python markdown code block.
A sum of p rubles is charged from Arkady's mobile phone account every day in the morning. Among the following m days, there are n days when Arkady will top up the account: in the day di he will deposit ti rubles on his mobile phone account. Arkady will ... |
Solve the programming task below in a Python markdown code block.
Alice decides to challenge Bob to a problem. She gives him a number.
Bob can rearrange the digits of this number by applying pair-wise swaps between any 2 digits in the number as many times as he wants. Now Alice asks him to write down all the distinc... |
Solve the programming task below in a Python markdown code block.
This problem of Oz is very straight forward. You are given N distinct prime integers i.e p1, p2,..., pN and an interval [L,R]. Calculate number of integers in this interval that are divisible by at least one of the given primes.
Input :
First line of ... |
Solve the programming task below in a Python markdown code block.
You will be given a set of distinct numbers. Your task is to find that even length subset which will give you a maximum value of P % (10^9 + 7). This value of P for a subset of length N is defined as below :
P = (product of N/2 maximum values... |
Solve the programming task below in a Python markdown code block.
Campus Ambassador has organized a Coding Contest in his college. Contest has multiple rounds, in each round a participant may gain or lose few points. At the end, there is only one participant with the maximum points. In the course of the contest, the n... |
Solve the programming task below in a Python markdown code block.
Do you remember the game of Snakes and Ladders ? We have removed all the snakes from the board. However to compensate for the loss of trouble, we have enlarged the board from a maximum limit (Target Square) of 100 to a maximum limit (Target Square) of N... |
Solve the programming task below in a Python markdown code block.
Given is an integer S. Find how many sequences there are whose terms are all integers greater than or equal to 3, and whose sum is equal to S. The answer can be very large, so output it modulo 10^9 + 7.
Constraints
* 1 \leq S \leq 2000
* All values in... |
Solve the programming task below in a Python markdown code block.
A bracket sequence is a string that is one of the following:
1. An empty string;
2. The concatenation of `(`, A, and `)` in this order, for some bracket sequence A ;
3. The concatenation of A and B in this order, for some non-empty bracket sequences A ... |
Solve the programming task below in a Python markdown code block.
For two sequences S and T of length N consisting of 0 and 1, let us define f(S, T) as follows:
* Consider repeating the following operation on S so that S will be equal to T. f(S, T) is the minimum possible total cost of those operations.
* Change S_i... |
Solve the programming task below in a Python markdown code block.
We have two bottles for holding water.
Bottle 1 can hold up to A milliliters of water, and now it contains B milliliters of water.
Bottle 2 contains C milliliters of water.
We will transfer water from Bottle 2 to Bottle 1 as much as possible.
How mu... |
Solve the programming task below in a Python markdown code block.
You are given a string S of length N consisting of `A`, `C`, `G` and `T`. Answer the following Q queries:
* Query i (1 \leq i \leq Q): You will be given integers l_i and r_i (1 \leq l_i < r_i \leq N). Consider the substring of S starting at index l_i a... |
Solve the programming task below in a Python markdown code block.
In programming, hexadecimal notation is often used.
In hexadecimal notation, besides the ten digits 0, 1, ..., 9, the six letters `A`, `B`, `C`, `D`, `E` and `F` are used to represent the values 10, 11, 12, 13, 14 and 15, respectively.
In this problem... |
Solve the programming task below in a Python markdown code block.
You are given an integer sequence of length N, a = {a_1, a_2, β¦, a_N}, and an integer K.
a has N(N+1)/2 non-empty contiguous subsequences, {a_l, a_{l+1}, β¦, a_r} (1 β€ l β€ r β€ N). Among them, how many have an arithmetic mean that is greater than or equa... |
Solve the programming task below in a Python markdown code block.
There are N pinholes on the xy-plane. The i-th pinhole is located at (x_i,y_i).
We will denote the Manhattan distance between the i-th and j-th pinholes as d(i,j)(=|x_i-x_j|+|y_i-y_j|).
You have a peculiar pair of compasses, called Manhattan Compass. ... |
Solve the programming task below in a Python markdown code block.
Snuke got an integer sequence from his mother, as a birthday present. The sequence has N elements, and the i-th of them is i. Snuke performs the following Q operations on this sequence. The i-th operation, described by a parameter q_i, is as follows:
*... |
Solve the programming task below in a Python markdown code block.
An extension of a complex number is called a quaternion. It is a convenient number that can be used to control the arm of a robot because it is convenient for expressing the rotation of an object. Quaternions are $ using four real numbers $ x $, $ y $, ... |
Solve the programming task below in a Python markdown code block.
Advanced Creative Mobile (ACM) has decided to develop a GUI application to be installed in a new portable computer.
As shown in the figure below, the GUI has a nested structure in which it has one main panel, several panels are arranged on it, and some... |
Solve the programming task below in a Python markdown code block.
A decimal representation of an integer can be transformed to another integer by rearranging the order of digits. Let us make a sequence using this fact.
A non-negative integer a0 and the number of digits L are given first. Applying the following rules,... |
Solve the programming task below in a Python markdown code block.
Dr. Jimbo, an applied mathematician, needs to calculate matrices all day for solving his own problems. In his laboratory, he uses an excellent application program for manipulating matrix expressions, however, he cannot use it outside his laboratory beca... |
Solve the programming task below in a Python markdown code block.
The sales department of Japanese Ancient Giant Corp. is visiting a hot spring resort for their recreational trip. For deepening their friendships, they are staying in one large room of a Japanese-style hotel called a ryokan.
In the ryokan, people sleep... |
Solve the programming task below in a Python markdown code block.
Write a program which manipulates a sequence A = {a1, a2, . . . , an} with the following operations:
* add(i, x): add x to ai.
* getSum(s, t): print the sum of as, as+1,...,at.
Note that the initial values of ai (i = 1, 2, . . . , n) are 0.
Constra... |
Solve the programming task below in a Python markdown code block.
Devu is a class teacher of a class of n students. One day, in the morning prayer of the school, all the students of his class were standing in a line. You are given information of their arrangement by a string s. The string s consists of only letters 'B... |
Solve the programming task below in a Python markdown code block.
This is an interactive problem.
Bob lives in a square grid of size n Γ n, with rows numbered 1 through n from top to bottom, and columns numbered 1 through n from left to right. Every cell is either allowed or blocked, but you don't know the exact desc... |
Solve the programming task below in a Python markdown code block.
The German University in Cairo (GUC) dorm houses are numbered from 1 to n. Underground water pipes connect these houses together. Each pipe has certain direction (water can flow only in this direction and not vice versa), and diameter (which characteriz... |
Solve the programming task below in a Python markdown code block.
Reading books is one of Sasha's passions. Once while he was reading one book, he became acquainted with an unusual character. The character told about himself like that: "Many are my names in many countries. Mithrandir among the Elves, TharkΓ»n to the Dw... |
Solve the programming task below in a Python markdown code block.
Let's analyze a program written on some strange programming language. The variables in this language have names consisting of 1 to 4 characters, and each character is a lowercase or an uppercase Latin letter, or a digit. There is an extra constraint tha... |
Solve the programming task below in a Python markdown code block.
Recently, on the course of algorithms and data structures, Valeriy learned how to use a deque. He built a deque filled with n elements. The i-th element is a_i (i = 1, 2, β¦, n). He gradually takes the first two leftmost elements from the deque (let's ca... |
Solve the programming task below in a Python markdown code block.
You are given a sorted array a_1, a_2, ..., a_n (for each index i > 1 condition a_i β₯ a_{i-1} holds) and an integer k.
You are asked to divide this array into k non-empty consecutive subarrays. Every element in the array should be included in exactly o... |
Solve the programming task below in a Python markdown code block.
All of us love treasures, right? That's why young Vasya is heading for a Treasure Island.
Treasure Island may be represented as a rectangular table n Γ m which is surrounded by the ocean. Let us number rows of the field with consecutive integers from 1... |
Solve the programming task below in a Python markdown code block.
This is the harder version of the problem. In this version, 1 β€ n β€ 10^6 and 0 β€ a_i β€ 10^6. You can hack this problem if you locked it. But you can hack the previous problem only if you locked both problems
Christmas is coming, and our protagonist, Bo... |
Solve the programming task below in a Python markdown code block.
Yeah, we failed to make up a New Year legend for this problem.
A permutation of length n is an array of n integers such that every integer from 1 to n appears in it exactly once.
An element y of permutation p is reachable from element x if x = y, or ... |
Solve the programming task below in a Python markdown code block.
In this task Anna and Maria play a game with a very unpleasant rival. Anna and Maria are in the opposite squares of a chessboard (8 Γ 8): Anna is in the upper right corner, and Maria is in the lower left one. Apart from them, the board has several statu... |
Solve the programming task below in a Python markdown code block.
If the girl doesn't go to Denis, then Denis will go to the girl. Using this rule, the young man left home, bought flowers and went to Nastya.
On the way from Denis's house to the girl's house is a road of n lines. This road can't be always crossed in ... |
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 achieve this, he can pe... |
Solve the programming task below in a Python markdown code block.
The length of the longest common prefix of two strings s = s_1 s_2 β¦ s_n and t = t_1 t_2 β¦ t_m is defined as the maximum integer k (0 β€ k β€ min(n,m)) such that s_1 s_2 β¦ s_k equals t_1 t_2 β¦ t_k.
Koa the Koala initially has n+1 strings s_1, s_2, ..., s... |
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 + β
β
β
+ a_n = 0.
In one operation, you can choose two different indices i and j (1 β€ i, j β€ n), decrement a_i by one and increment a_j by one. If i < j this operation is free, otherwise it cost... |
Solve the programming task below in a Python markdown code block.
Kolya got an integer array a_1, a_2, ..., a_n. The array can contain both positive and negative integers, but Kolya doesn't like 0, so the array doesn't contain any zeros.
Kolya doesn't like that the sum of some subsegments of his array can be 0. The s... |
Solve the programming task below in a Python markdown code block.
A string t is called an anagram of the string s, if it is possible to rearrange letters in t so that it is identical to the string s. For example, the string "aab" is an anagram of the string "aba" and the string "aaa" is not.
The string t is called a ... |
Solve the programming task below in a Python markdown code block.
You are given two strings x and y, both consist only of lowercase Latin letters. Let |s| be the length of string s.
Let's call a sequence a a merging sequence if it consists of exactly |x| zeros and exactly |y| ones in some order.
A merge z is produce... |
Solve the programming task below in a Python markdown code block.
This is an interactive problem!
Nastia has a hidden permutation p of length n consisting of integers from 1 to n. You, for some reason, want to figure out the permutation. To do that, you can give her an integer t (1 β€ t β€ 2), two different indices i a... |
Solve the programming task below in a Python markdown code block.
Suppose you have two points p = (x_p, y_p) and q = (x_q, y_q). Let's denote the Manhattan distance between them as d(p, q) = |x_p - x_q| + |y_p - y_q|.
Let's say that three points p, q, r form a bad triple if d(p, r) = d(p, q) + d(q, r).
Let's say tha... |
Solve the programming task below in a Python markdown code block.
You've got string s, consisting of only lowercase English letters. Find its lexicographically maximum subsequence.
We'll call a non-empty string s[p1p2... pk] = sp1sp2... spk(1 β€ p1 < p2 < ... < pk β€ |s|) a subsequence of string s = s1s2... s|s|.
Stri... |
Solve the programming task below in a Python markdown code block.
Once Bob decided to lay a parquet floor in his living room. The living room is of size n Γ m metres. Bob had planks of three types: a planks 1 Γ 2 meters, b planks 2 Γ 1 meters, and c planks 2 Γ 2 meters. Help Bob find out, if it is possible to parquet ... |
Solve the programming task below in a Python markdown code block.
We often have to copy large volumes of information. Such operation can take up many computer resources. Therefore, in this problem you are advised to come up with a way to copy some part of a number array into another one, quickly.
More formally, you'v... |
Solve the programming task below in a Python markdown code block.
Smart Beaver recently got interested in a new word game. The point is as follows: count the number of distinct good substrings of some string s. To determine if a string is good or not the game uses rules. Overall there are n rules. Each rule is describ... |
Solve the programming task below in a Python markdown code block.
Iahub is a big fan of tourists. He wants to become a tourist himself, so he planned a trip. There are n destinations on a straight road that Iahub wants to visit. Iahub starts the excursion from kilometer 0. The n destinations are described by a non-neg... |
Solve the programming task below in a Python markdown code block.
George loves graphs. Most of all, he loves interesting graphs. We will assume that a directed graph is interesting, if it meets the following criteria:
* The graph doesn't contain any multiple arcs;
* There is vertex v (we'll call her the center)... |
Solve the programming task below in a Python markdown code block.
Once little Vasya read an article in a magazine on how to make beautiful handmade garland from colored paper. Vasya immediately went to the store and bought n colored sheets of paper, the area of each sheet is 1 square meter.
The garland must consist o... |
Solve the programming task below in a Python markdown code block.
In this problem, your task is to use ASCII graphics to paint a cardiogram.
A cardiogram is a polyline with the following corners:
<image>
That is, a cardiogram is fully defined by a sequence of positive integers a1, a2, ..., an.
Your task is to pai... |
Solve the programming task below in a Python markdown code block.
Vasya trains to compose crossword puzzles. He can only compose crosswords of a very simplΠ΅ type so far. All of them consist of exactly six words; the words can be read only from top to bottom vertically and from the left to the right horizontally. The w... |
Solve the programming task below in a Python markdown code block.
Leonid wants to become a glass carver (the person who creates beautiful artworks by cutting the glass). He already has a rectangular w mm Γ h mm sheet of glass, a diamond glass cutter and lots of enthusiasm. What he lacks is understanding of what to c... |
Solve the programming task below in a Python markdown code block.
Chris the Rabbit has been interested in arrays ever since he was a child. At the moment he is researching arrays with the length of n, containing only integers from 1 to n. He is not good at math, that's why some simple things drive him crazy. For examp... |
Solve the programming task below in a Python markdown code block.
A function <image> is called Lipschitz continuous if there is a real constant K such that the inequality |f(x) - f(y)| β€ KΒ·|x - y| holds for all <image>. We'll deal with a more... discrete version of this term.
For an array <image>, we define it's Lips... |
Solve the programming task below in a Python markdown code block.
While Farmer John rebuilds his farm in an unfamiliar portion of Bovinia, Bessie is out trying some alternative jobs. In her new gig as a reporter, Bessie needs to know about programming competition results as quickly as possible. When she covers the 201... |
Solve the programming task below in a Python markdown code block.
A wise man told Kerem "Different is good" once, so Kerem wants all things in his life to be different.
Kerem recently got a string s consisting of lowercase English letters. Since Kerem likes it when things are different, he wants all substrings of hi... |
Solve the programming task below in a Python markdown code block.
Barney lives in country USC (United States of Charzeh). USC has n cities numbered from 1 through n and n - 1 roads between them. Cities and roads of USC form a rooted tree (Barney's not sure why it is rooted). Root of the tree is the city number 1. Thus... |
Solve the programming task below in a Python markdown code block.
Vasya plays the Need For Brake. He plays because he was presented with a new computer wheel for birthday! Now he is sure that he will win the first place in the championship in his favourite racing computer game!
n racers take part in the championship... |
Solve the programming task below in a Python markdown code block.
Apart from having lots of holidays throughout the year, residents of Berland also have whole lucky years. Year is considered lucky if it has no more than 1 non-zero digit in its number. So years 100, 40000, 5 are lucky and 12, 3001 and 12345 are not.
Y... |
Solve the programming task below in a Python markdown code block.
It's hard times now. Today Petya needs to score 100 points on Informatics exam. The tasks seem easy to Petya, but he thinks he lacks time to finish them all, so he asks you to help with one..
There is a glob pattern in the statements (a string consisti... |
Solve the programming task below in a Python markdown code block.
Olya loves energy drinks. She loves them so much that her room is full of empty cans from energy drinks.
Formally, her room can be represented as a field of n Γ m cells, each cell of which is empty or littered with cans.
Olya drank a lot of energy dri... |
Solve the programming task below in a Python markdown code block.
Alice has a very important message M consisting of some non-negative integers that she wants to keep secret from Eve. Alice knows that the only theoretically secure cipher is one-time pad. Alice generates a random key K of the length equal to the messag... |
Solve the programming task below in a Python markdown code block.
Katie, Kuro and Shiro are best friends. They have known each other since kindergarten. That's why they often share everything with each other and work together on some very hard problems.
Today is Shiro's birthday. She really loves pizza so she wants t... |
Solve the programming task below in a Python markdown code block.
A string s of length n can be encrypted by the following algorithm:
* iterate over all divisors of n in decreasing order (i.e. from n to 1),
* for each divisor d, reverse the substring s[1 ... d] (i.e. the substring which starts at position 1 and ... |
Solve the programming task below in a Python markdown code block.
View Russian Translation
Little pig Benny has just taken a shower. Now she is going to buy some gifts for her relatives. But the problem is that Benny doesn't know how to reach to the gift shop. Her friend Mike has created a special set of instructions... |
Solve the programming task below in a Python markdown code block.
Mr. Hahn, our very own DJ, was seeing Chester and Mike fighting over such questions lately. Being a geek himself, he thought of showing off his skills and gave the both of them a question.
He gave them a single positive integer, N. For all the numbers... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.