question large_stringlengths 265 13.2k |
|---|
Solve the programming task below in a Python markdown code block.
Write a program to determine if two numbers are coprime. A pair of numbers are coprime if their greatest shared factor is 1. For example:
```
20 and 27
Factors of 20: 1, 2, 4, 5, 10, 20
Factors of 27: 1, 3, 9, 27
Greatest shared factor: 1
20 and 27 are ... |
Solve the programming task below in a Python markdown code block.
Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right.
We will call the arrangement of the poles beautiful if the tops of the poles lie on the same line, that is, b-a = c-b.
Determine whether the arrangeme... |
Solve the programming task below in a Python markdown code block.
Given a lowercase string that has alphabetic characters only and no spaces, return the highest value of consonant substrings. Consonants are any letters of the alphabet except `"aeiou"`.
We shall assign the following values: `a = 1, b = 2, c = 3, ....... |
Solve the programming task below in a Python markdown code block.
You are given two integers $x$ and $y$. You can perform two types of operations: Pay $a$ dollars and increase or decrease any of these integers by $1$. For example, if $x = 0$ and $y = 7$ there are four possible outcomes after this operation: $x = 0... |
Solve the programming task below in a Python markdown code block.
Vasya has got two number: a and b. However, Vasya finds number a too short. So he decided to repeat the operation of lengthening number a n times.
One operation of lengthening a number means adding exactly one digit to the number (in the decimal notati... |
Solve the programming task below in a Python markdown code block.
Vasya came up with a password to register for EatForces — a string s. The password in EatForces should be a string, consisting of lowercase and uppercase Latin letters and digits.
But since EatForces takes care of the security of its users, user passwo... |
Solve the programming task below in a Python markdown code block.
We start with a string $s$ consisting only of the digits $1$, $2$, or $3$. The length of $s$ is denoted by $|s|$. For each $i$ from $1$ to $|s|$, the $i$-th character of $s$ is denoted by $s_i$.
There is one cursor. The cursor's location $\ell$ is den... |
Solve the programming task below in a Python markdown code block.
Given an undirected tree, let the distance between vertices u and v be the number of edges on the simple path from u to v. The diameter of a tree is the maximum among the distances between any two vertices. We will call a tree good if and only if its di... |
Solve the programming task below in a Python markdown code block.
Write a regex to validate a 24 hours time string.
See examples to figure out what you should check for:
Accepted:
01:00 - 1:00
Not accepted:
24:00
You should check for correct length and no spaces.
Read the inputs from stdin solve the problem and... |
Solve the programming task below in a Python markdown code block.
You are given 2 numbers is `n` and `k`. You need to find the number of integers between 1 and n (inclusive) that contains exactly `k` non-zero digit.
Example1
`
almost_everywhere_zero(100, 1) return 19`
by following condition we have 19 numbers that... |
Solve the programming task below in a Python markdown code block.
Let's write all the positive integer numbers one after another from $1$ without any delimiters (i.e. as a single string). It will be the infinite sequence starting with 123456789101112131415161718192021222324252627282930313233343536...
Your task is to ... |
Solve the programming task below in a Python markdown code block.
Harry Potter is on a mission to destroy You-Know-Who's Horcruxes. The first Horcrux that he encountered in the Chamber of Secrets is Tom Riddle's diary. The diary was with Ginny and it forced her to open the Chamber of Secrets. Harry wants to know the d... |
Solve the programming task below in a Python markdown code block.
Step up and down
Kazuki, commonly known as Kerr, who attends JAG University, was invited by your friend this summer to participate in the ICPC (International Collegiate Potchari Contest). ICPC is a sports contest and requires a high degree of athletic ... |
Solve the programming task below in a Python markdown code block.
Professor Tsukuba invented a mysterious jewelry box that can be opened with a special gold key whose shape is very strange. It is composed of gold bars joined at their ends. Each gold bar has the same length and is placed parallel to one of the three or... |
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.
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
Today a plane was hijacked by a maniac. All the passengers of the flight are taken as hostage. Chef is also one of them.
He invited one of the passengers to play a game with ... |
Solve the programming task below in a Python markdown code block.
Takahashi is a member of a programming competition site, ButCoder.
Each member of ButCoder is assigned two values: Inner Rating and Displayed Rating.
The Displayed Rating of a member is equal to their Inner Rating if the member has participated in 10 or... |
Solve the programming task below in a Python markdown code block.
Problem
GPA is an abbreviation for "Galaxy Point of Aizu" and takes real numbers from 0 to 4.
GPA rock-paper-scissors is a game played by two people. After each player gives a signal of "rock-paper-scissors, pon (hoi)" to each other's favorite move, go... |
Solve the programming task below in a Python markdown code block.
Little Artem is fond of dancing. Most of all dances Artem likes rueda — Cuban dance that is danced by pairs of boys and girls forming a circle and dancing together.
More detailed, there are n pairs of boys and girls standing in a circle. Initially, boy... |
Solve the programming task below in a Python markdown code block.
We have an integer sequence A of length N, where A_1 = X, A_{i+1} = A_i + D (1 \leq i < N ) holds.
Takahashi will take some (possibly all or none) of the elements in this sequence, and Aoki will take all of the others.
Let S and T be the sum of the num... |
Solve the programming task below in a Python markdown code block.
The only difference between the easy and hard versions is that the given string $s$ in the easy version is initially a palindrome, this condition is not always true for the hard version.
A palindrome is a string that reads the same left to right and ri... |
Solve the programming task below in a Python markdown code block.
> If you've finished this kata, you can try the [more difficult version](https://www.codewars.com/kata/5b256145a454c8a6990000b5).
## Taking a walk
A promenade is a way of uniquely representing a fraction by a succession of “left or right” choices.
F... |
Solve the programming task below in a Python markdown code block.
Chief Judge's log, stardate 48642.5. We have decided to make a problem from elementary number theory. The problem looks like finding all prime factors of a positive integer, but it is not.
A positive integer whose remainder divided by 7 is either 1 or ... |
Solve the programming task below in a Python markdown code block.
In this exercise, you will have to create a function named tiyFizzBuzz. This function will take on a string parameter and will return that string with some characters replaced, depending on the value:
- If a letter is a upper case consonants, replace t... |
Solve the programming task below in a Python markdown code block.
You are given three positive integers $n$, $a$ and $b$. You have to construct a string $s$ of length $n$ consisting of lowercase Latin letters such that each substring of length $a$ has exactly $b$ distinct letters. It is guaranteed that the answer exis... |
Solve the programming task below in a Python markdown code block.
You are given a string $s=s_1s_2\dots s_n$ of length $n$, which only contains digits $1$, $2$, ..., $9$.
A substring $s[l \dots r]$ of $s$ is a string $s_l s_{l + 1} s_{l + 2} \ldots s_r$. A substring $s[l \dots r]$ of $s$ is called even if the number ... |
Solve the programming task below in a Python markdown code block.
Chef Jessie has a lot of recipes with her (N). She often remembered the starting few characters of the recipe and forgot the rest. As all the great chefs do, Jessie also numbered the recipes depending on the priority. So, given the list of recipes along... |
Solve the programming task below in a Python markdown code block.
# Background:
You're working in a number zoo, and it seems that one of the numbers has gone missing!
Zoo workers have no idea what number is missing, and are too incompetent to figure it out, so they're hiring you to do it for them.
In case the zoo l... |
Solve the programming task below in a Python markdown code block.
# Hey You !
Sort these integers for me ...
By name ...
Do it now !
---
## Input
* Range is ```0```-```999```
* There may be duplicates
* The array may be empty
## Example
* Input: 1, 2, 3, 4
* Equivalent names: "one", "two", "three", "four"
*... |
Solve the programming task below in a Python markdown code block.
Allen has a LOT of money. He has $n$ dollars in the bank. For security reasons, he wants to withdraw it in cash (we will not disclose the reasons here). The denominations for dollar bills are $1$, $5$, $10$, $20$, $100$. What is the minimum number of bi... |
Solve the programming task below in a Python markdown code block.
Petya studies in a school and he adores Maths. His class has been studying arithmetic expressions. On the last class the teacher wrote three positive integers a, b, c on the blackboard. The task was to insert signs of operations '+' and '*', and probabl... |
Solve the programming task below in a Python markdown code block.
# The Problem
Dan, president of a Large company could use your help. He wants to implement a system that will switch all his devices into offline mode depending on his meeting schedule. When he's at a meeting and somebody texts him, he wants to send an... |
Solve the programming task below in a Python markdown code block.
Complete the solution so that it returns the number of times the search_text is found within the full_text.
Usage example:
Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclos... |
Solve the programming task below in a Python markdown code block.
You finally got a magic pot, an alchemy pot. You can create a new item by putting multiple items in the alchemy pot. Newly created items can also be placed in alchemy pots to make other items. A list of items needed to make an item will be called an alc... |
Solve the programming task below in a Python markdown code block.
Manao works on a sports TV. He's spent much time watching the football games of some country. After a while he began to notice different patterns. For example, each team has two sets of uniforms: home uniform and guest uniform. When a team plays a game ... |
Solve the programming task below in a Python markdown code block.
AquaMoon has n friends. They stand in a row from left to right, and the i-th friend from the left wears a T-shirt with a number a_i written on it. Each friend has a direction (left or right). In the beginning, the direction of each friend is right.
Aqu... |
Solve the programming task below in a Python markdown code block.
You are given a string $s$ consisting only of characters + and -. You perform some process with this string. This process can be described by the following pseudocode: res = 0
for init = 0 to inf
cur = init
ok = true
for i = 1 to |s|
... |
Solve the programming task below in a Python markdown code block.
Appleman has n cards. Each card has an uppercase letter written on it. Toastman must choose k cards from Appleman's cards. Then Appleman should give Toastman some coins depending on the chosen cards. Formally, for each Toastman's card i you should calcu... |
Solve the programming task below in a Python markdown code block.
problem
You are in charge of quality control at a machine manufacturing plant. This machine requires a power supply, a motor, and a cable as parts. The manufacturing plant has a power supply, b motors, and c cables, numbered from 1 to a, a + 1 to a + b... |
Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin and Russian. Translations in Vietnamese to be uploaded soon.
You have a matrix of size N * N with rows numbered through 1 to N from top to bottom and columns through 1 to N from left to right. It contains all value... |
Solve the programming task below in a Python markdown code block.
This is the easy version of the problem. The difference is the constraints on $n$, $m$ and $t$. You can make hacks only if all versions of the problem are solved.
Alice and Bob are given the numbers $n$, $m$ and $k$, and play a game as follows:
The ga... |
Solve the programming task below in a Python markdown code block.
Given is a string S consisting of digits from 1 through 9.
Find the number of pairs of integers (i,j) (1 ≤ i ≤ j ≤ |S|) that satisfy the following condition:
Condition: In base ten, the i-th through j-th characters of S form an integer that is a multipl... |
Solve the programming task below in a Python markdown code block.
problem
Soccer is popular in JOI, and a league match called the JOI League is held every week.
There are N teams in the JOI league, numbered from 1 to N. All combinations of matches are played exactly once. In other words, N × (N -1) / 2 games are pla... |
Solve the programming task below in a Python markdown code block.
Sergey Semyonovich is a mayor of a county city N and he used to spend his days and nights in thoughts of further improvements of Nkers' lives. Unfortunately for him, anything and everything has been done already, and there are no more possible improveme... |
Solve the programming task below in a Python markdown code block.
The Cereal Guy's friend Serial Guy likes to watch soap operas. An episode is about to start, and he hasn't washed his plate yet. But he decided to at least put in under the tap to be filled with water. The plate can be represented by a parallelepiped k ... |
Solve the programming task below in a Python markdown code block.
Given an array $a$, consisting of $n$ integers, find:
$$\max\limits_{1 \le i < j \le n} LCM(a_i,a_j),$$
where $LCM(x, y)$ is the smallest positive integer that is divisible by both $x$ and $y$. For example, $LCM(6, 8) = 24$, $LCM(4, 12) = 12$, $LCM(2,... |
Solve the programming task below in a Python markdown code block.
You are given a multiset $S$ initially consisting of $n$ distinct non-negative integers. A multiset is a set, that can contain some elements multiple times.
You will perform the following operation $k$ times:
Add the element $\lceil\frac{a+b}{2}\rceil... |
Solve the programming task below in a Python markdown code block.
Chef recently saw the movie Matrix. He loved the movie overall but he didn't agree with some things in it. Particularly he didn't agree with the bald boy when he declared - There is no spoon. Being a chef, he understands the importance of the spoon and ... |
Solve the programming task below in a Python markdown code block.
Thumbelina has had an accident. She has found herself on a little island in the middle of a swamp and wants to get to the shore very much.
One can get to the shore only by hills that are situated along a straight line that connects the little island wi... |
Solve the programming task below in a Python markdown code block.
The athletics competition 200M semi-final three races were held. Eight players (24 players in total) will participate in each group. A total of eight players, including the top two players in each group and the top two players from all the players in ea... |
Solve the programming task below in a Python markdown code block.
There are N dots in a two-dimensional plane. The coordinates of the i-th dot are (x_i, y_i).
We will repeat the following operation as long as possible:
- Choose four integers a, b, c, d (a \neq c, b \neq d) such that there are dots at exactly three of... |
Solve the programming task below in a Python markdown code block.
Mike is given a matrix A, N and M are numbers of rows and columns respectively. A1, 1 is the number in the top left corner. All the numbers in A are non-negative integers. He also has L pairs of integers (ik, jk). His task is to calculate Ai1, j1 + Ai2,... |
Solve the programming task below in a Python markdown code block.
The year of 2012 is coming...
According to an ancient choradrican legend in this very year, in 2012, Diablo and his brothers Mephisto and Baal will escape from hell, and innumerable hordes of demons will enslave the human world. But seven brave heroes ... |
Solve the programming task below in a Python markdown code block.
Andrewid the Android is a galaxy-famous detective. He is now investigating the case of vandalism at the exhibition of contemporary art.
The main exhibit is a construction of n matryoshka dolls that can be nested one into another. The matryoshka dolls a... |
Solve the programming task below in a Python markdown code block.
Sunake is in the form of a polygonal line consisting of n vertices (without self-intersection). First, Sunake-kun's i-th vertex is at (xi, yi). You can move continuously by translating or rotating, but you cannot deform (change the length of the polygon... |
Solve the programming task below in a Python markdown code block.
It's been a while since I played with A, B, and C. Mr. A and Mr. B became players, and Mr. C became a referee and played a badminton singles game. The rules decided by the three people are as follows.
* 3 Play the game.
* The person who gets 11 points ... |
Solve the programming task below in a Python markdown code block.
Mike and Ann are sitting in the classroom. The lesson is boring, so they decided to play an interesting game. Fortunately, all they need to play this game is a string $s$ and a number $k$ ($0 \le k < |s|$).
At the beginning of the game, players are giv... |
Solve the programming task below in a Python markdown code block.
Chef has a nice complete binary tree in his garden. Complete means that each node has exactly two sons, so the tree is infinite. Yesterday he had enumerated the nodes of the tree in such a way:
- Let's call the nodes' level a number of nodes that occur... |
Solve the programming task below in a Python markdown code block.
You are given an undirected graph with n vertices. There are no edge-simple cycles with the even length in it. In other words, there are no cycles of even length that pass each edge at most once. Let's enumerate vertices from 1 to n.
You have to answe... |
Solve the programming task below in a Python markdown code block.
Jeff's got n cards, each card contains either digit 0, or digit 5. Jeff can choose several cards and put them in a line so that he gets some number. What is the largest possible number divisible by 90 Jeff can make from the cards he's got?
Jeff must ma... |
Solve the programming task below in a Python markdown code block.
There are H rows and W columns of white square cells.
You will choose h of the rows and w of the columns, and paint all of the cells contained in those rows or columns.
How many white cells will remain?
It can be proved that this count does not depend o... |
Solve the programming task below in a Python markdown code block.
You've purchased a ready-meal from the supermarket.
The packaging says that you should microwave it for 4 minutes and 20 seconds, based on a 600W microwave.
Oh no, your microwave is 800W! How long should you cook this for?!
___
# Input
You'll be gi... |
Solve the programming task below in a Python markdown code block.
The main street of Berland is a straight line with n houses built along it (n is an even number). The houses are located at both sides of the street. The houses with odd numbers are at one side of the street and are numbered from 1 to n - 1 in the order... |
Solve the programming task below in a Python markdown code block.
A permutation of length n is an array containing each integer from 1 to n exactly once. For example, q = [4, 5, 1, 2, 3] is a permutation. For the permutation q the square of permutation is the permutation p that p[i] = q[q[i]] for each i = 1... n. For ... |
Solve the programming task below in a Python markdown code block.
Anya has bought a new smartphone that uses Berdroid operating system. The smartphone menu has exactly n applications, each application has its own icon. The icons are located on different screens, one screen contains k icons. The icons from the first to... |
Solve the programming task below in a Python markdown code block.
Example
Input
4 3
1000 1
2000 2
3000 3
Output
2 3 4 4
Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters. |
Solve the programming task below in a Python markdown code block.
There is a data which provides heights (in meter) of mountains. The data is only for ten mountains.
Write a program which prints heights of the top three mountains in descending order.
Constraints
0 ≤ height of mountain (integer) ≤ 10,000
Input
He... |
Solve the programming task below in a Python markdown code block.
One day Jeff got hold of an integer sequence a_1, a_2, ..., a_{n} of length n. The boy immediately decided to analyze the sequence. For that, he needs to find all values of x, for which these conditions hold:
x occurs in sequence a. Consider all pos... |
Solve the programming task below in a Python markdown code block.
You are given N points (x_i,y_i) located on a two-dimensional plane.
Consider a subset S of the N points that forms a convex polygon.
Here, we say a set of points S forms a convex polygon when there exists a convex polygon with a positive area that has ... |
Solve the programming task below in a Python markdown code block.
Remove the parentheses
=
In this kata you are given a string for example:
```python
"example(unwanted thing)example"
```
Your task is to remove everything inside the parentheses as well as the parentheses themselves.
The example above would return:
... |
Solve the programming task below in a Python markdown code block.
Given a string s, write a method (function) that will return true if its a valid single integer or floating number or false if its not.
Valid examples, should return true:
should return false:
Read the inputs from stdin solve the problem and write th... |
Solve the programming task below in a Python markdown code block.
ATMs of a well-known bank of a small country are arranged so that they can not give any amount of money requested by the user. Due to the limited size of the bill dispenser (the device that is directly giving money from an ATM) and some peculiarities of... |
Solve the programming task below in a Python markdown code block.
The aim of this Kata is to write a function which will reverse the case of all consecutive duplicate letters in a string. That is, any letters that occur one after the other and are identical.
If the duplicate letters are lowercase then they must be s... |
Solve the programming task below in a Python markdown code block.
This is a hard version of the problem. In this version, the given array can contain equal elements and the constraints on $n$ are greater than in the easy version of the problem.
You are given an array $a$ of $n$ integers (the given array can contain e... |
Solve the programming task below in a Python markdown code block.
Scheduling is how the processor decides which jobs (processes) get to use the processor and for how long. This can cause a lot of problems. Like a really long process taking the entire CPU and freezing all the other processes. One solution is Round-Robi... |
Solve the programming task below in a Python markdown code block.
There are n types of coins in Byteland. Conveniently, the denomination of the coin type k divides the denomination of the coin type k + 1, the denomination of the coin type 1 equals 1 tugrick. The ratio of the denominations of coin types k + 1 and k equ... |
Solve the programming task below in a Python markdown code block.
The elections to Berland parliament are happening today. Voting is in full swing!
Totally there are n candidates, they are numbered from 1 to n. Based on election results k (1 ≤ k ≤ n) top candidates will take seats in the parliament.
After the end of... |
Solve the programming task below in a Python markdown code block.
Little Mishka is a great traveller and she visited many countries. After thinking about where to travel this time, she chose XXX — beautiful, but little-known northern country.
Here are some interesting facts about XXX: XXX consists of n cities, k of ... |
Solve the programming task below in a Python markdown code block.
<image>
This figure shows railway tracks for reshuffling cars. The rail tracks end in the bottom and the top-left rail track is used for the entrace and the top-right rail track is used for the exit. Ten cars, which have numbers from 1 to 10 respectiv... |
Solve the programming task below in a Python markdown code block.
# Task
You are given an array of integers. Your task is to determine the minimum number of its elements that need to be changed so that elements of the array will form an arithmetic progression. Note that if you swap two elements, you're changing both ... |
Solve the programming task below in a Python markdown code block.
We’ve all seen katas that ask for conversion from snake-case to camel-case, from camel-case to snake-case, or from camel-case to kebab-case — the possibilities are endless.
But if we don’t know the case our inputs are in, these are not very helpful.
#... |
Solve the programming task below in a Python markdown code block.
2^k teams participate in a playoff tournament. The tournament consists of 2^k - 1 games. They are held as follows: first of all, the teams are split into pairs: team 1 plays against team 2, team 3 plays against team 4 (exactly in this order), and so on ... |
Solve the programming task below in a Python markdown code block.
Given an integer, if the length of it's digits is a perfect square, return a square block of sqroot(length) * sqroot(length). If not, simply return "Not a perfect square!".
Examples:
1212 returns:
>1212
Note: 4 digits so 2 squared (2x2 perfect squ... |
Solve the programming task below in a Python markdown code block.
As Sherlock Holmes was investigating a crime, he identified n suspects. He knows for sure that exactly one of them committed the crime. To find out which one did it, the detective lines up the suspects and numbered them from 1 to n. After that, he asked... |
Solve the programming task below in a Python markdown code block.
You are given a book with n chapters.
Each chapter has a specified list of other chapters that need to be understood in order to understand this chapter. To understand a chapter, you must read it after you understand every chapter on its required list.... |
Solve the programming task below in a Python markdown code block.
You are given a function $f$ written in some basic language. The function accepts an integer value, which is immediately written into some variable $x$. $x$ is an integer variable and can be assigned values from $0$ to $2^{32}-1$. The function contains ... |
Solve the programming task below in a Python markdown code block.
Snuke loves puzzles.
Today, he is working on a puzzle using `S`- and `c`-shaped pieces. In this puzzle, you can combine two `c`-shaped pieces into one `S`-shaped piece, as shown in the figure below:
9b0bd546db9f28b4093d417b8f274124.png
Snuke decided ... |
Solve the programming task below in a Python markdown code block.
As you know, Bob's brother lives in Flatland. In Flatland there are n cities, connected by n - 1 two-way roads. The cities are numbered from 1 to n. You can get from one city to another moving along the roads.
The «Two Paths» company, where Bob's broth... |
Solve the programming task below in a Python markdown code block.
Vasya works as a watchman in the gallery. Unfortunately, one of the most expensive paintings was stolen while he was on duty. He doesn't want to be fired, so he has to quickly restore the painting. He remembers some facts about it. The painting is a sq... |
Solve the programming task below in a Python markdown code block.
# Fix the Bugs (Syntax) - My First Kata
## Overview
Hello, this is my first Kata so forgive me if it is of poor quality.
In this Kata you should fix/create a program that ```return```s the following values:
- ```false/False``` if either a or b (or ... |
Solve the programming task below in a Python markdown code block.
Three-valued logic is a logic system that has, in addition to "true" and "false", "unknown" as a valid value. In the following, logical values "false", "unknown" and "true" are represented by 0, 1 and 2 respectively.
Let "-" be a unary operator (i.e. a... |
Solve the programming task below in a Python markdown code block.
There is a grid with R rows and C columns. We call the cell in the r-th row and c-th column (r,c).
Mr. Takahashi wrote non-negative integers into N of the cells, that is, he wrote a non-negative integer a_i into (r_i,c_i) for each i (1≤i≤N). After that... |
Solve the programming task below in a Python markdown code block.
# ASC Week 1 Challenge 5 (Medium #2)
Create a function that takes a 2D array as an input, and outputs another array that contains the average values for the numbers in the nested arrays at the corresponding indexes.
Note: the function should also wor... |
Solve the programming task below in a Python markdown code block.
A company has N members, who are assigned ID numbers 1, ..., N.
Every member, except the member numbered 1, has exactly one immediate boss with a smaller ID number.
When a person X is the immediate boss of a person Y, the person Y is said to be an immed... |
Solve the programming task below in a Python markdown code block.
Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
One day Petya dreamt of a lexicog... |
Solve the programming task below in a Python markdown code block.
Sean is trying to save a large file to a USB flash drive. He has n USB flash drives with capacities equal to a_1, a_2, ..., a_{n} megabytes. The file size is equal to m megabytes.
Find the minimum number of USB flash drives needed to write Sean's file... |
Solve the programming task below in a Python markdown code block.
Little walrus Fangy loves math very much. That's why when he is bored he plays with a number performing some operations.
Fangy takes some positive integer x and wants to get a number one from it. While x is not equal to 1, Fangy repeats the following a... |
Solve the programming task below in a Python markdown code block.
You've got an undirected graph, consisting of n vertices and m edges. We will consider the graph's vertices numbered with integers from 1 to n. Each vertex of the graph has a color. The color of the i-th vertex is an integer c_{i}.
Let's consider all v... |
Solve the programming task below in a Python markdown code block.
Recently Adaltik discovered japanese crosswords. Japanese crossword is a picture, represented as a table sized a × b squares, and each square is colored white or black. There are integers to the left of the rows and to the top of the columns, encrypting... |
Solve the programming task below in a Python markdown code block.
You are given positive integers A and B.
If A is a divisor of B, print A + B; otherwise, print B - A.
-----Constraints-----
- All values in input are integers.
- 1 \leq A \leq B \leq 20
-----Input-----
Input is given from Standard Input in the follo... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.