question large_stringlengths 265 13.2k |
|---|
Solve the programming task below in a Python markdown code block.
# Back-Story
Every day I travel on the freeway.
When I am more bored than usual I sometimes like to play the following counting game I made up:
* As I join the freeway my count is ```0```
* Add ```1``` for every car that I overtake
* Subtract ```1```... |
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, you are give... |
Solve the programming task below in a Python markdown code block.
SaMer has written the greatest test case of all time for one of his problems. For a given array of integers, the problem asks to find the minimum number of groups the array can be divided into, such that the product of any pair of integers in the same g... |
Solve the programming task below in a Python markdown code block.
A new e-mail service "Berlandesk" is going to be opened in Berland in the near future. The site administration wants to launch their project as soon as possible, that's why they ask you to help. You're suggested to implement the prototype of site regist... |
Solve the programming task below in a Python markdown code block.
Your job is to find out the secret number hidden in a matrix, each of whose element is a digit ('0'-'9') or a letter ('A'-'Z'). You can see an example matrix in Figure 1.
<image>
Figure 1: A Matrix
The secret number and other non-secret ones are code... |
Solve the programming task below in a Python markdown code block.
Jamie loves sleeping. One day, he decides that he needs to wake up at exactly hh: mm. However, he hates waking up, so he wants to make waking up less painful by setting the alarm at a lucky time. He will then press the snooze button every x minutes unti... |
Solve the programming task below in a Python markdown code block.
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59.
You are give... |
Solve the programming task below in a Python markdown code block.
You're given an undirected graph with $n$ nodes and $m$ edges. Nodes are numbered from $1$ to $n$.
The graph is considered harmonious if and only if the following property holds: For every triple of integers $(l, m, r)$ such that $1 \le l < m < r \le ... |
Solve the programming task below in a Python markdown code block.
You are given a set of n points on the plane. A line containing the origin is called good, if projection of the given set to this line forms a symmetric multiset of points. Find the total number of good lines.
Multiset is a set where equal elements are... |
Solve the programming task below in a Python markdown code block.
Tak performed the following action N times: rolling two dice.
The result of the i-th roll is D_{i,1} and D_{i,2}.
Check if doublets occurred at least three times in a row.
Specifically, check if there exists at lease one i such that D_{i,1}=D_{i,2}, D_{... |
Solve the programming task below in a Python markdown code block.
Consider a sequence of n numbers using integers from 0 to 9 k1, k2, ..., kn. Read the positive integers n and s,
k1 + 2 x k2 + 3 x k3 + ... + n x kn = s
Create a program that outputs how many rows of n numbers such as. However, the same number does no... |
Solve the programming task below in a Python markdown code block.
An uppercase or lowercase English letter \alpha will be given as input.
If \alpha is uppercase, print A; if it is lowercase, print a.
-----Constraints-----
- \alpha is an uppercase (A - Z) or lowercase (a - z) English letter.
-----Input-----
Input is... |
Solve the programming task below in a Python markdown code block.
There is the faculty of Computer Science in Berland. In the social net "TheContact!" for each course of this faculty there is the special group whose name equals the year of university entrance of corresponding course of students at the university.
Ea... |
Solve the programming task below in a Python markdown code block.
This is the easy version of the problem. The difference between the versions is the constraint on n and the required number of operations. You can make hacks only if all versions of the problem are solved.
There are two binary strings a and b of length... |
Solve the programming task below in a Python markdown code block.
C: Short-circuit evaluation
problem
Naodai-kun and Hokkaido University-kun are playing games. Hokkaido University first generates the following logical formula represented by BNF.
<formula> :: = <or-expr>
<or-expr> :: = <and-expr>
| <or-expr> "|" <a... |
Solve the programming task below in a Python markdown code block.
JATC loves Banh-mi (a Vietnamese food). His affection for Banh-mi is so much that he always has it for breakfast. This morning, as usual, he buys a Banh-mi and decides to enjoy it in a special way.
First, he splits the Banh-mi into $n$ parts, places th... |
Solve the programming task below in a Python markdown code block.
One of the simple ciphers is the affine cipher. First, replace the letters a to z with the numbers a = 0, b = 1, c = 2, ..., x = 23, y = 24, z = 25 and 0 to 25. Then replace the original alphabet with the following formula.
$ F (\ gamma) = (\ alpha \ c... |
Solve the programming task below in a Python markdown code block.
You are given sequence a_1, a_2, ..., a_{n} and m queries l_{j}, r_{j} (1 ≤ l_{j} ≤ r_{j} ≤ n). For each query you need to print the minimum distance between such pair of elements a_{x} and a_{y} (x ≠ y), that: both indexes of the elements lie within r... |
Solve the programming task below in a Python markdown code block.
We will buy a product for N yen (the currency of Japan) at a shop.
If we use only 1000-yen bills to pay the price, how much change will we receive?
Assume we use the minimum number of bills required.
-----Constraints-----
- 1 \leq N \leq 10000
- N is... |
Solve the programming task below in a Python markdown code block.
I: Ravage
Santa Claus was caught in the illuminations of the city and broke it.
There are N light bulbs in the illumination, and the $ i $ th light bulb only comes on when the voltage is above $ A_i $ and below $ B_i $.
The voltage should be the same... |
Solve the programming task below in a Python markdown code block.
Find a cycle in a directed graph G(V, E).
Constraints
* 1 ≤ |V| ≤ 100
* 0 ≤ |E| ≤ 1,000
* si ≠ ti
Input
A directed graph G is given in the following format:
|V| |E|
s0 t0
s1 t1
:
s|E|-1 t|E|-1
|V| is the number of nodes and |E| is the number of ... |
Solve the programming task below in a Python markdown code block.
On a number axis directed from the left rightwards, n marbles with coordinates x1, x2, ..., xn are situated. Let's assume that the sizes of the marbles are infinitely small, that is in this task each of them is assumed to be a material point. You can st... |
Solve the programming task below in a Python markdown code block.
Write a program which reads a word W and a text T, and prints the number of word W which appears in text T
T consists of string Ti separated by space characters and newlines. Count the number of Ti which equals to W. The word and text are case insensit... |
Solve the programming task below in a Python markdown code block.
Karlsson has visited Lillebror again. They found a box of chocolates and a big whipped cream cake at Lillebror's place. Karlsson immediately suggested to divide the sweets fairly between Lillebror and himself. Specifically, to play together a game he ha... |
Solve the programming task below in a Python markdown code block.
The solution of $ x ^ 3 = q $ is to calculate the recurrence formula $ x_ {n + 1} = x_n-\ frac {x_ {n} ^ 3 --q} {3x_ {n} ^ 2} $ It can be calculated approximately with.
Put a positive number $ \ frac {q} {2} $ in $ x_1 $
$ x_2 = x_1-\ frac {x_ {1} ^ 3... |
Solve the programming task below in a Python markdown code block.
For the given sequence with n different elements find the number of increasing subsequences with k + 1 elements. It is guaranteed that the answer is not greater than 8·1018.
Input
First line contain two integer values n and k (1 ≤ n ≤ 105, 0 ≤ k ≤ 10)... |
Solve the programming task below in a Python markdown code block.
YouKn0wWho has an integer sequence a_1, a_2, …, a_n. He will perform the following operation until the sequence becomes empty: select an index i such that 1 ≤ i ≤ |a| and a_i is not divisible by (i + 1), and erase this element from the sequence. Here |a... |
Solve the programming task below in a Python markdown code block.
There are literally dozens of snooker competitions held each year, and team Jinotega tries to attend them all (for some reason they prefer name "snookah")! When a competition takes place somewhere far from their hometown, Ivan, Artsem and Konstantin tak... |
Solve the programming task below in a Python markdown code block.
You are given array $a$ of length $n$. You can choose one segment $[l, r]$ ($1 \le l \le r \le n$) and integer value $k$ (positive, negative or even zero) and change $a_l, a_{l + 1}, \dots, a_r$ by $k$ each (i.e. $a_i := a_i + k$ for each $l \le i \le r... |
Solve the programming task below in a Python markdown code block.
There are N integers X_1, X_2, \cdots, X_N, and we know that A_i \leq X_i \leq B_i.
Find the number of different values that the median of X_1, X_2, \cdots, X_N can take.
-----Notes-----
The median of X_1, X_2, \cdots, X_N is defined as follows. Let x_... |
Solve the programming task below in a Python markdown code block.
Convert integers to binary as simple as that. You would be given an integer as a argument and you have to return its binary form.
To get an idea about how to convert a decimal number into a binary number, visit here.
**Notes**: negative numbers should ... |
Solve the programming task below in a Python markdown code block.
# How many ways can you make the sum of a number?
From wikipedia: https://en.wikipedia.org/wiki/Partition_(number_theory)#
>In number theory and combinatorics, a partition of a positive integer *n*, also called an *integer partition*, is a way of writ... |
Solve the programming task below in a Python markdown code block.
It's the year 4527 and the tanks game that we all know and love still exists. There also exists Great Gena's code, written in 2016. The problem this code solves is: given the number of tanks that go into the battle from each country, find their product.... |
Solve the programming task below in a Python markdown code block.
You are given n points on Cartesian plane. Every point is a lattice point (i. e. both of its coordinates are integers), and all points are distinct.
You may draw two straight lines (not necessarily distinct). Is it possible to do this in such a way tha... |
Solve the programming task below in a Python markdown code block.
We have N ID cards, and there are M gates.
We can pass the i-th gate if we have one of the following ID cards: the L_i-th, (L_i+1)-th, ..., and R_i-th ID cards.
How many of the ID cards allow us to pass all the gates alone?
-----Constraints-----
- All... |
Solve the programming task below in a Python markdown code block.
Polycarp has $n$ friends, the $i$-th of his friends has $a_i$ candies. Polycarp's friends do not like when they have different numbers of candies. In other words they want all $a_i$ to be the same. To solve this, Polycarp performs the following set of a... |
Solve the programming task below in a Python markdown code block.
You are given a positive integer $n$, written without leading zeroes (for example, the number 04 is incorrect).
In one operation you can delete any digit of the given integer so that the result remains a positive integer without leading zeros.
Determ... |
Solve the programming task below in a Python markdown code block.
Problem statement
JOI decided to start a new social game from tomorrow.
In this social game, you can log in up to once a day, and you will get A coins each time you log in.
Also, if you log in for 7 consecutive days from Monday to Sunday, you will ge... |
Solve the programming task below in a Python markdown code block.
You invited $n$ guests to dinner! You plan to arrange one or more circles of chairs. Each chair is going to be either occupied by one guest, or be empty. You can make any number of circles.
Your guests happen to be a little bit shy, so the $i$-th gues... |
Solve the programming task below in a Python markdown code block.
There are $n$ robbers at coordinates $(a_1, b_1)$, $(a_2, b_2)$, ..., $(a_n, b_n)$ and $m$ searchlight at coordinates $(c_1, d_1)$, $(c_2, d_2)$, ..., $(c_m, d_m)$.
In one move you can move each robber to the right (increase $a_i$ of each robber by on... |
Solve the programming task below in a Python markdown code block.
You want to arrange n integers a_1, a_2, ..., a_{n} in some order in a row. Let's define the value of an arrangement as the sum of differences between all pairs of adjacent integers.
More formally, let's denote some arrangement as a sequence of integer... |
Solve the programming task below in a Python markdown code block.
Arkady bought an air ticket from a city A to a city C. Unfortunately, there are no direct flights, but there are a lot of flights from A to a city B, and from B to C.
There are $n$ flights from A to B, they depart at time moments $a_1$, $a_2$, $a_3$, .... |
Solve the programming task below in a Python markdown code block.
There are n people and k keys on a straight line. Every person wants to get to the office which is located on the line as well. To do that, he needs to reach some point with a key, take the key and then go to the office. Once a key is taken by somebody,... |
Solve the programming task below in a Python markdown code block.
The only difference between easy and hard versions is constraints.
Now elections are held in Berland and you want to win them. More precisely, you want everyone to vote for you.
There are $n$ voters, and two ways to convince each of them to vote for y... |
Solve the programming task below in a Python markdown code block.
AtCoDeer the deer has N square tiles. The tiles are numbered 1 through N, and the number given to each tile is written on one side of the tile. Also, each corner of each tile is painted in one of the 1000 colors, which are represented by the integers 0 ... |
Solve the programming task below in a Python markdown code block.
The academic year has just begun, but lessons and olympiads have already occupied all the free time. It is not a surprise that today Olga fell asleep on the Literature. She had a dream in which she was on a stairs.
The stairs consists of n steps. The ... |
Solve the programming task below in a Python markdown code block.
Mr. Bender has a digital table of size n × n, each cell can be switched on or off. He wants the field to have at least c switched on squares. When this condition is fulfilled, Mr Bender will be happy.
We'll consider the table rows numbered from top to ... |
Solve the programming task below in a Python markdown code block.
Takahashi is competing in a sumo tournament. The tournament lasts for 15 days, during which he performs in one match per day. If he wins 8 or more matches, he can also participate in the next tournament.
The matches for the first k days have finished. ... |
Solve the programming task below in a Python markdown code block.
Snuke lives in another world, where slimes are real creatures and kept by some people. Slimes come in N colors. Those colors are conveniently numbered 1 through N. Snuke currently has no slime. His objective is to have slimes of all the colors together.... |
Solve the programming task below in a Python markdown code block.
John has just bought a new car and is planning a journey around the country. Country has N cities, some of which are connected by bidirectional roads. There are N - 1 roads and every city is reachable from any other city. Cities are labeled from 1 to N.... |
Solve the programming task below in a Python markdown code block.
There are n boys and m girls studying in the class. They should stand in a line so that boys and girls alternated there as much as possible. Let's assume that positions in the line are indexed from left to right by numbers from 1 to n + m. Then the numb... |
Solve the programming task below in a Python markdown code block.
Xenia lives in a city that has n houses built along the main ringroad. The ringroad houses are numbered 1 through n in the clockwise order. The ringroad traffic is one way and also is clockwise.
Xenia has recently moved into the ringroad house number 1... |
Solve the programming task below in a Python markdown code block.
A string is called a KEYENCE string when it can be changed to `keyence` by removing its contiguous substring (possibly empty) only once.
Given a string S consisting of lowercase English letters, determine if S is a KEYENCE string.
Constraints
* The l... |
Solve the programming task below in a Python markdown code block.
In English and programming, groups can be made using symbols such as `()` and `{}` that change meaning. However, these groups must be closed in the correct order to maintain correct syntax.
Your job in this kata will be to make a program that checks a ... |
Solve the programming task below in a Python markdown code block.
In 21XX, humanity finally began a plan to relocate to Mars. Selected as the first group of immigrants to Mars, you are assigned to the Administrative Center of Mars to deal with various problems that occur on Mars. The biggest problem at the moment of t... |
Solve the programming task below in a Python markdown code block.
Proof of knowledge
The entrance door of the apartment you live in has a password-type lock. This password consists of exactly four digits, ranging from 0 to 9, and you always use the password P given to you by the apartment manager to unlock this door.... |
Solve the programming task below in a Python markdown code block.
Snuke is buying a lamp.
The light of the lamp can be adjusted to m levels of brightness, represented by integers from 1 through m, by the two buttons on the remote control.
The first button is a "forward" button. When this button is pressed, the brightn... |
Solve the programming task below in a Python markdown code block.
Oleg's favorite subjects are History and Math, and his favorite branch of mathematics is division.
To improve his division skills, Oleg came up with $t$ pairs of integers $p_i$ and $q_i$ and for each pair decided to find the greatest integer $x_i$, suc... |
Solve the programming task below in a Python markdown code block.
Edo has got a collection of n refrigerator magnets!
He decided to buy a refrigerator and hang the magnets on the door. The shop can make the refrigerator with any size of the door that meets the following restrictions: the refrigerator door must be rec... |
Solve the programming task below in a Python markdown code block.
You are given a permutation of numbers from 1 to n. Determine whether there's a pair of integers a, b (1 ≤ a, b ≤ n; a ≠ b) such that the element <image> (note, that it is usual division, not integer one) is between a and b in this permutation.
Input
... |
Solve the programming task below in a Python markdown code block.
Alice and Bob are playing yet another card game. This time the rules are the following. There are $n$ cards lying in a row in front of them. The $i$-th card has value $a_i$.
First, Alice chooses a non-empty consecutive segment of cards $[l; r]$ ($l \l... |
Solve the programming task below in a Python markdown code block.
Petya has k matches, placed in n matchboxes lying in a line from left to right. We know that k is divisible by n. Petya wants all boxes to have the same number of matches inside. For that, he can move a match from its box to the adjacent one in one move... |
Solve the programming task below in a Python markdown code block.
You are given a string S consisting of lowercase English letters.
Another string T is initially empty.
Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times:
- Append one of the following at... |
Solve the programming task below in a Python markdown code block.
The appearance of the sun is called "sunrise" and the hiding is called "sunset". What is the exact time when the sun is on the horizon?
As shown in the figure below, we will represent the sun as a circle and the horizon as a straight line. At this time... |
Solve the programming task below in a Python markdown code block.
There are $n$ houses along the road where Anya lives, each one is painted in one of $k$ possible colors.
Anya likes walking along this road, but she doesn't like when two adjacent houses at the road have the same color. She wants to select a long segme... |
Solve the programming task below in a Python markdown code block.
Inna loves sleeping very much, so she needs n alarm clocks in total to wake up. Let's suppose that Inna's room is a 100 × 100 square with the lower left corner at point (0, 0) and with the upper right corner at point (100, 100). Then the alarm clocks ar... |
Solve the programming task below in a Python markdown code block.
Little X has met the following problem recently.
Let's define f(x) as the sum of digits in decimal representation of number x (for example, f(1234) = 1 + 2 + 3 + 4). You are to calculate <image>
Of course Little X has solved this problem quickly, has... |
Solve the programming task below in a Python markdown code block.
Wabbit is playing a game with $n$ bosses numbered from $1$ to $n$. The bosses can be fought in any order. Each boss needs to be defeated exactly once. There is a parameter called boss bonus which is initially $0$.
When the $i$-th boss is defeated, the ... |
Solve the programming task below in a Python markdown code block.
Recently, a start up by two students of a state university of city F gained incredible popularity. Now it's time to start a new company. But what do we call it?
The market analysts came up with a very smart plan: the name of the company should be ident... |
Solve the programming task below in a Python markdown code block.
You are given a string S of length 2 or 3 consisting of lowercase English letters. If the length of the string is 2, print it as is; if the length is 3, print the string after reversing it.
Constraints
* The length of S is 2 or 3.
* S consists of lowe... |
Solve the programming task below in a Python markdown code block.
We have a pyramid with N steps, built with blocks. The steps are numbered 1 through N from top to bottom. For each 1≤i≤N, step i consists of 2i-1 blocks aligned horizontally. The pyramid is built so that the blocks at the centers of the steps are aligne... |
Solve the programming task below in a Python markdown code block.
## Task:
You have to write a function `pattern` which returns the following Pattern(See Examples) upto desired number of rows.
* Note:`Returning` the pattern is not the same as `Printing` the pattern.
### Parameters:
pattern( n ... |
Solve the programming task below in a Python markdown code block.
You are given two arrays: an array $a$ consisting of $n$ zeros and an array $b$ consisting of $n$ integers.
You can apply the following operation to the array $a$ an arbitrary number of times: choose some subsegment of $a$ of length $k$ and add the ari... |
Solve the programming task below in a Python markdown code block.
In this problem at each moment you have a set of intervals. You can move from interval (a, b) from our set to interval (c, d) from our set if and only if c < a < d or c < b < d. Also there is a path from interval I_1 from our set to interval I_2 from ou... |
Solve the programming task below in a Python markdown code block.
Similarly to the [previous kata](https://www.codewars.com/kata/string-subpattern-recognition-i/), you will need to return a boolean value if the base string can be expressed as the repetition of one subpattern.
This time there are two small changes:
*... |
Solve the programming task below in a Python markdown code block.
Given a matrix (H × W) which contains only 1 and 0, find the area of the largest square matrix which only contains 0s.
Constraints
* 1 ≤ H, W ≤ 1,400
Input
H W
c1,1 c1,2 ... c1,W
c2,1 c2,2 ... c2,W
:
cH,1 cH,2 ... cH,W
In the first line, two inte... |
Solve the programming task below in a Python markdown code block.
Drazil is playing a math game with Varda.
Let's define <image> for positive integer x as a product of factorials of its digits. For example, <image>.
First, they choose a decimal number a consisting of n digits that contains at least one digit larger ... |
Solve the programming task below in a Python markdown code block.
## Overview
Resistors are electrical components marked with colorful stripes/bands to indicate both their resistance value in ohms and how tight a tolerance that value has. While you could always get a tattoo like Jimmie Rodgers to help you remember the... |
Solve the programming task below in a Python markdown code block.
A new delivery of clothing has arrived today to the clothing store. This delivery consists of $a$ ties, $b$ scarves, $c$ vests and $d$ jackets.
The store does not sell single clothing items — instead, it sells suits of two types: a suit of the first t... |
Solve the programming task below in a Python markdown code block.
You are given n positive integers a_1, a_2, ..., a_{n}.
For every a_{i} you need to find a positive integer k_{i} such that the decimal notation of 2^{k}_{i} contains the decimal notation of a_{i} as a substring among its last min(100, length(2^{k}_{i}... |
Solve the programming task below in a Python markdown code block.
Among Johnny's numerous hobbies, there are two seemingly harmless ones: applying bitwise operations and sneaking into his dad's office. As it is usually the case with small children, Johnny is unaware that combining these two activities can get him in a... |
Solve the programming task below in a Python markdown code block.
A group of $n$ dancers rehearses a performance for the closing ceremony. The dancers are arranged in a row, they've studied their dancing moves and can't change positions. For some of them, a white dancing suit is already bought, for some of them — a bl... |
Solve the programming task below in a Python markdown code block.
Reziba has many magic gems. Each magic gem can be split into $M$ normal gems. The amount of space each magic (and normal) gem takes is $1$ unit. A normal gem cannot be split.
Reziba wants to choose a set of magic gems and split some of them, so the tot... |
Solve the programming task below in a Python markdown code block.
'Twas the night before Christmas, and Santa's frantically setting up his new Christmas tree! There are n nodes in the tree, connected by n-1 edges. On each edge of the tree, there's a set of Christmas lights, which can be represented by an integer in bi... |
Solve the programming task below in a Python markdown code block.
Count the pairs of length-N sequences consisting of integers between 1 and M (inclusive), A_1, A_2, \cdots, A_{N} and B_1, B_2, \cdots, B_{N}, that satisfy all of the following conditions:
- A_i \neq B_i, for every i such that 1\leq i\leq N.
- A_i \ne... |
Solve the programming task below in a Python markdown code block.
Polycarp is crazy about round numbers. He especially likes the numbers divisible by 10^{k}.
In the given number of n Polycarp wants to remove the least number of digits to get a number that is divisible by 10^{k}. For example, if k = 3, in the number 3... |
Solve the programming task below in a Python markdown code block.
At Aizu Shingakujuku, students are divided into classes by conducting a proficiency test when they enter the cram school. The test consists of three subjects: Mathematics, English, and Japanese, and students are divided into A, B, and C classes. The lev... |
Solve the programming task below in a Python markdown code block.
Vadim loves decorating the Christmas tree, so he got a beautiful garland as a present. It consists of n light bulbs in a single row. Each bulb has a number from 1 to n (in arbitrary order), such that all the numbers are distinct. While Vadim was solving... |
Solve the programming task below in a Python markdown code block.
Dasha logged into the system and began to solve problems. One of them is as follows:
Given two sequences a and b of length n each you need to write a sequence c of length n, the i-th element of which is calculated as follows: c_{i} = b_{i} - a_{i}.
Ab... |
Solve the programming task below in a Python markdown code block.
Levko loves array a1, a2, ... , an, consisting of integers, very much. That is why Levko is playing with array a, performing all sorts of operations with it. Each operation Levko performs is of one of two types:
1. Increase all elements from li to ri... |
Solve the programming task below in a Python markdown code block.
Chef likes to travel very much. He plans some travel routes and wants to know their lengths. He hired you to make these calculations. But be careful, some of the routes are incorrect. There may be some misspelling in city names or there will be no road ... |
Solve the programming task below in a Python markdown code block.
Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists... |
Solve the programming task below in a Python markdown code block.
You are given a sequence D_1, D_2, ..., D_N of length N.
The values of D_i are all distinct.
Does a tree with N vertices that satisfies the following conditions exist?
- The vertices are numbered 1,2,..., N.
- The edges are numbered 1,2,..., N-1, and ... |
Solve the programming task below in a Python markdown code block.
Let's define a number ebne (even but not even) if and only if its sum of digits is divisible by 2 but the number itself is not divisible by 2. For example, 13, 1227, 185217 are ebne numbers, while 12, 2, 177013, 265918 are not. If you're still unsure wh... |
Solve the programming task below in a Python markdown code block.
# Task
Given an integer array `arr`. Your task is to remove one element, maximize the product of elements.
The result is the element which should be removed. If more than one valid results exist, return the smallest one.
# Input/Output
`[input]` i... |
Solve the programming task below in a Python markdown code block.
At an arcade, Takahashi is playing a game called RPS Battle, which is played as follows:
- The player plays N rounds of Rock Paper Scissors against the machine. (See Notes for the description of Rock Paper Scissors. A draw also counts as a round.)
- E... |
Solve the programming task below in a Python markdown code block.
The next "Data Structures and Algorithms" lesson will be about Longest Increasing Subsequence (LIS for short) of a sequence. For better understanding, Nam decided to learn it a few days before the lesson.
Nam created a sequence a consisting of n (1 ≤ n... |
Solve the programming task below in a Python markdown code block.
Ahmed and Mostafa used to compete together in many programming contests for several years. Their coach Fegla asked them to solve one challenging problem, of course Ahmed was able to solve it but Mostafa couldn't.
This problem is similar to a standard p... |
Solve the programming task below in a Python markdown code block.
«Bersoft» company is working on a new version of its most popular text editor — Bord 2010. Bord, like many other text editors, should be able to print out multipage documents. A user keys a sequence of the document page numbers that he wants to print ou... |
Solve the programming task below in a Python markdown code block.
Piegirl was asked to implement two table join operation for distributed database system, minimizing the network traffic.
Suppose she wants to join two tables, A and B. Each of them has certain number of rows which are distributed on different number of... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.