prompt stringlengths 11 14k | messages listlengths 2 2 |
|---|---|
On his trip to Luxor and Aswan, Sagheer went to a Nubian market to buy some souvenirs for his friends and relatives. The market has some strange rules. It contains n different items numbered from 1 to n. The i-th item has base cost ai Egyptian pounds. If Sagheer buys k items with indices x1, x2, ..., xk, then the cost ... | [
{
"content": "On his trip to Luxor and Aswan, Sagheer went to a Nubian market to buy some souvenirs for his friends and relatives. The market has some strange rules. It contains n different items numbered from 1 to n. The i-th item has base cost ai Egyptian pounds. If Sagheer buys k items with indices x1, x2, .... |
Chef is playing an easier variation of the board game ‘Risk’ with his friend Mike. There is an $N * M$ grid, depicting the world map. Each cell of the grid is either $1$ or $0$ where $1$ denotes that there is land on this cell, while $0$ denotes water.
In a turn, a player can capture an uncaptured cell that has land,... | [
{
"content": "Chef is playing an easier variation of the board game ‘Risk’ with his friend Mike. There is an $N * M$ grid, depicting the world map. Each cell of the grid is either $1$ or $0$ where $1$ denotes that there is land on this cell, while $0$ denotes water. \n\nIn a turn, a player can capture an uncapt... |
Given are strings s and t of length N each, both consisting of lowercase English letters.
Let us form a new string by alternating the characters of S and the characters of T, as follows: the first character of S, the first character of T, the second character of S, the second character of T, ..., the N-th character of... | [
{
"content": "Given are strings s and t of length N each, both consisting of lowercase English letters.\n\nLet us form a new string by alternating the characters of S and the characters of T, as follows: the first character of S, the first character of T, the second character of S, the second character of T, ..... |
Read problems statements in Mandarin chinese, Russian and Vietnamese as well.
Chef is at a Code Expo where many coders are present discussing, solving, sharing, and eavesdropping on solutions :P
He recently learnt that a former HackerPlant employee, Reziba, who is now working at KodeKarma stole some questions for th... | [
{
"content": "Read problems statements in Mandarin chinese, Russian and Vietnamese as well. \n\nChef is at a Code Expo where many coders are present discussing, solving, sharing, and eavesdropping on solutions :P\n\nHe recently learnt that a former HackerPlant employee, Reziba, who is now working at KodeKarma s... |
Implement a Queue using Linked List.
A Query Q is of 2 Types
(i) 1 x (a query of this type means pushing 'x' into the queue)
(ii) 2 (a query of this type means to pop an element from the queue and print the poped element)
Example 1:
Input:
Q = 5
Queries = 1 2 1 3 2 1 4 2
Output: 2 3
Explanation: n the first tes... | [
{
"content": "Implement a Queue using Linked List. \nA Query Q is of 2 Types\n(i) 1 x (a query of this type means pushing 'x' into the queue)\n(ii) 2 (a query of this type means to pop an element from the queue and print the poped element)\nExample 1:\nInput:\nQ = 5\nQueries = 1 2 1 3 2 1 4 2\nOutput: 2 ... |
You are given an array A, of N elements. Find minimum index based distance between two elements of the array, x and y such that (x!=y).
Example 1:
Input:
N = 4
A[] = {1,2,3,2}
x = 1, y = 2
Output: 1
Explanation: x = 1 and y = 2. There are
two distances between x and y, which are
1 and 3 out of which the least is 1.
Exa... | [
{
"content": "You are given an array A, of N elements. Find minimum index based distance between two elements of the array, x and y such that (x!=y).\nExample 1:\nInput:\nN = 4\nA[] = {1,2,3,2}\nx = 1, y = 2\nOutput: 1\nExplanation: x = 1 and y = 2. There are\ntwo distances between x and y, which are\n1 and 3 o... |
You are given a multiset of n integers. You should select exactly k of them in a such way that the difference between any two of them is divisible by m, or tell that it is impossible.
Numbers can be repeated in the original multiset and in the multiset of selected numbers, but number of occurrences of any number in mu... | [
{
"content": "You are given a multiset of n integers. You should select exactly k of them in a such way that the difference between any two of them is divisible by m, or tell that it is impossible.\n\nNumbers can be repeated in the original multiset and in the multiset of selected numbers, but number of occurre... |
Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.
-----Input-----
The only line contains 2 integers $u$ and $v$ $(0 \le u,v \le 10^{18})$.
-----Output-----
If there's no array that satisfies the condition, print "-1". Otherwise:... | [
{
"content": "Given 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.\n\n\n-----Input-----\n\nThe only line contains 2 integers $u$ and $v$ $(0 \\le u,v \\le 10^{18})$.\n\n\n-----Output-----\n\nIf there's no array that satisfies the... |
Ivan recently bought a detective book. The book is so interesting that each page of this book introduces some sort of a mystery, which will be explained later. The $i$-th page contains some mystery that will be explained on page $a_i$ ($a_i \ge i$).
Ivan wants to read the whole book. Each day, he reads the first page ... | [
{
"content": "Ivan recently bought a detective book. The book is so interesting that each page of this book introduces some sort of a mystery, which will be explained later. The $i$-th page contains some mystery that will be explained on page $a_i$ ($a_i \\ge i$).\n\nIvan wants to read the whole book. Each day,... |
# The President's phone is broken
He is not very happy.
The only letters still working are uppercase ```E```, ```F```, ```I```, ```R```, ```U```, ```Y```.
An angry tweet is sent to the department responsible for presidential phone maintenance.
# Kata Task
Decipher the tweet by looking for words with known meaning... | [
{
"content": "# The President's phone is broken\n\nHe is not very happy.\n\nThe only letters still working are uppercase ```E```, ```F```, ```I```, ```R```, ```U```, ```Y```.\n\nAn angry tweet is sent to the department responsible for presidential phone maintenance.\n\n\n# Kata Task\n\nDecipher the tweet by loo... |
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 number of points is written in the line as
"name points", where nam... | [
{
"content": "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 number of points is written in the line as\n\n... |
Manasa was sulking her way through a boring class when suddenly her teacher singled her out and asked her a question. He gave her a number n and Manasa has to come up with the smallest number m which contains atleast n number of zeros at the end of m!. Help Manasa come out of the sticky situation.
Input Format
The ... | [
{
"content": "Manasa was sulking her way through a boring class when suddenly her teacher singled her out and asked her a question. He gave her a number n and Manasa has to come up with the smallest number m which contains atleast n number of zeros at the end of m!. Help Manasa come out of the sticky situation.... |
In a row of trees, the i-th tree produces fruit with type tree[i].
You start at any tree of your choice, then repeatedly perform the following steps:
Add one piece of fruit from this tree to your baskets. If you cannot, stop.
Move to the next tree to the right of the current tree. If there is no tree to the right, s... | [
{
"content": "In a row of trees, the i-th tree produces fruit with type tree[i].\nYou start at any tree of your choice, then repeatedly perform the following steps:\n\nAdd one piece of fruit from this tree to your baskets. If you cannot, stop.\nMove to the next tree to the right of the current tree. If there ... |
Sonya decided that having her own hotel business is the best way of earning money because she can profit and rest wherever she wants.
The country where Sonya lives is an endless line. There is a city in each integer coordinate on this line. She has $n$ hotels, where the $i$-th hotel is located in the city with coordin... | [
{
"content": "Sonya decided that having her own hotel business is the best way of earning money because she can profit and rest wherever she wants.\n\nThe country where Sonya lives is an endless line. There is a city in each integer coordinate on this line. She has $n$ hotels, where the $i$-th hotel is located ... |
Recently a serious bug has been found in the FOS code. The head of the F company wants to find the culprit and punish him. For that, he set up an organizational meeting, the issue is: who's bugged the code? Each of the n coders on the meeting said: 'I know for sure that either x or y did it!'
The head of the company d... | [
{
"content": "Recently a serious bug has been found in the FOS code. The head of the F company wants to find the culprit and punish him. For that, he set up an organizational meeting, the issue is: who's bugged the code? Each of the n coders on the meeting said: 'I know for sure that either x or y did it!'\n\nT... |
There is a square field of size n × n in which two cells are marked. These cells can be in the same row or column.
You are to mark two more cells so that they are the corners of a rectangle with sides parallel to the coordinate axes.
For example, if n=4 and a rectangular field looks like this (there are asterisks in ... | [
{
"content": "There is a square field of size n × n in which two cells are marked. These cells can be in the same row or column.\n\nYou are to mark two more cells so that they are the corners of a rectangle with sides parallel to the coordinate axes.\n\nFor example, if n=4 and a rectangular field looks like thi... |
Given an array of numbers, return the difference between the largest and smallest values.
For example:
`[23, 3, 19, 21, 16]` should return `20` (i.e., `23 - 3`).
`[1, 434, 555, 34, 112]` should return `554` (i.e., `555 - 1`).
The array will contain a minimum of two elements. Input data range guarantees that `max-m... | [
{
"content": "Given an array of numbers, return the difference between the largest and smallest values. \n\nFor example:\n\n`[23, 3, 19, 21, 16]` should return `20` (i.e., `23 - 3`).\n\n`[1, 434, 555, 34, 112]` should return `554` (i.e., `555 - 1`).\n\nThe array will contain a minimum of two elements. Input dat... |
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 level of class A is the highest and then decreases in order.
The clas... | [
{
"content": "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 level of class A is the highest and then decreas... |
Income Inequality
We often compute the average as the first step in processing statistical data. Yes, the average is a good tendency measure of data, but it is not always the best. In some cases, the average may hinder the understanding of the data.
For example, consider the national income of a country. As the term ... | [
{
"content": "Income Inequality\n\nWe often compute the average as the first step in processing statistical data. Yes, the average is a good tendency measure of data, but it is not always the best. In some cases, the average may hinder the understanding of the data.\n\nFor example, consider the national income ... |
The radioactive isotope content of a rock can be used to identify which property of the rock?
A. the total mass of the rock
B. the rate at which the rock formed
C. the types of fossils that the rock contains
D. the amount of time passed since the rock formed | [
{
"content": "The radioactive isotope content of a rock can be used to identify which property of the rock?\nA. the total mass of the rock\nB. the rate at which the rock formed\nC. the types of fossils that the rock contains\nD. the amount of time passed since the rock formed",
"role": "user"
},
{
"... |
Snuke has a fair N-sided die that shows the integers from 1 to N with equal probability and a fair coin. He will play the following game with them:
- Throw the die. The current score is the result of the die.
- As long as the score is between 1 and K-1 (inclusive), keep flipping the coin. The score is doubled each ti... | [
{
"content": "Snuke has a fair N-sided die that shows the integers from 1 to N with equal probability and a fair coin. He will play the following game with them:\n - Throw the die. The current score is the result of the die.\n - As long as the score is between 1 and K-1 (inclusive), keep flipping the coin. The ... |
Kulyash stays in room that has a single bulb and N buttons. The bulb is initially on.
The initial states of the buttons are stored in a binary string S of length N — if S_{i} is 0, the i-th button is off, and if S_{i} is 1, the i-th button is on. If Kulyash toggles any single button then the state of the bulb reverses... | [
{
"content": "Kulyash stays in room that has a single bulb and N buttons. The bulb is initially on.\n\nThe initial states of the buttons are stored in a binary string S of length N — if S_{i} is 0, the i-th button is off, and if S_{i} is 1, the i-th button is on. If Kulyash toggles any single button then the st... |
Given two numbers A and B count all the number between the given range whose second least significant digit in the binary representation of the number is 1.
Example 1:
Input:
A = 1
B = 4
Output:
2
Explanation:
In the given range 2 (10)
and 3 (11) are the numbers
whose second least
significant digit in its
binary rep... | [
{
"content": "Given two numbers A and B count all the number between the given range whose second least significant digit in the binary representation of the number is 1.\n \nExample 1:\nInput:\nA = 1\nB = 4\nOutput:\n2\nExplanation:\nIn the given range 2 (10)\nand 3 (11) are the numbers\nwhose second least \ns... |
We say that a odd number N is similar to 2017 when both N and (N+1)/2 are prime.
You are given Q queries.
In the i-th query, given two odd numbers l_i and r_i, find the number of odd numbers x similar to 2017 such that l_i ≤ x ≤ r_i.
Constraints
* 1≤Q≤10^5
* 1≤l_i≤r_i≤10^5
* l_i and r_i are odd.
* All
input values ... | [
{
"content": "We say that a odd number N is similar to 2017 when both N and (N+1)/2 are prime.\n\nYou are given Q queries.\n\nIn the i-th query, given two odd numbers l_i and r_i, find the number of odd numbers x similar to 2017 such that l_i ≤ x ≤ r_i.\n\nConstraints\n\n* 1≤Q≤10^5\n* 1≤l_i≤r_i≤10^5\n* l_i and ... |
When Masha came to math classes today, she saw two integer sequences of length n - 1 on the blackboard. Let's denote the elements of the first sequence as a_i (0 ≤ a_i ≤ 3), and the elements of the second sequence as b_i (0 ≤ b_i ≤ 3).
Masha became interested if or not there is an integer sequence of length n, which e... | [
{
"content": "When Masha came to math classes today, she saw two integer sequences of length n - 1 on the blackboard. Let's denote the elements of the first sequence as a_i (0 ≤ a_i ≤ 3), and the elements of the second sequence as b_i (0 ≤ b_i ≤ 3).\n\nMasha became interested if or not there is an integer seque... |
When Valera has got some free time, he goes to the library to read some books. Today he's got t free minutes to read. That's why Valera took n books in the library and for each book he estimated the time he is going to need to read it. Let's number the books by integers from 1 to n. Valera needs ai minutes to read the ... | [
{
"content": "When Valera has got some free time, he goes to the library to read some books. Today he's got t free minutes to read. That's why Valera took n books in the library and for each book he estimated the time he is going to need to read it. Let's number the books by integers from 1 to n. Valera needs a... |
problem
You are a traveler traveling on the JOI Highway. The JOI Highway is a road that extends straight from east to west, and there are n post towns on the JOI Highway. Numbered. The westernmost post town on the JOI highway is post town 1, and the easternmost post town is post town n.
You have decided to depart fro... | [
{
"content": "problem\n\nYou are a traveler traveling on the JOI Highway. The JOI Highway is a road that extends straight from east to west, and there are n post towns on the JOI Highway. Numbered. The westernmost post town on the JOI highway is post town 1, and the easternmost post town is post town n.\n\nYou ... |
Write a function, which takes a non-negative integer (seconds) as input and returns the time in a human-readable format (`HH:MM:SS`)
* `HH` = hours, padded to 2 digits, range: 00 - 99
* `MM` = minutes, padded to 2 digits, range: 00 - 59
* `SS` = seconds, padded to 2 digits, range: 00 - 59
The maximum time never excee... | [
{
"content": "Write a function, which takes a non-negative integer (seconds) as input and returns the time in a human-readable format (`HH:MM:SS`)\n\n* `HH` = hours, padded to 2 digits, range: 00 - 99\n* `MM` = minutes, padded to 2 digits, range: 00 - 59\n* `SS` = seconds, padded to 2 digits, range: 00 - 59\n\n... |
The Jones Trucking Company tracks the location of each of its trucks on a grid similar to an (x, y) plane. The home office is at the location (0, 0). Read the coordinates of truck A and the coordinates of truck B and determine which is closer to the office.
-----Input:-----
The first line of the data set for this prob... | [
{
"content": "The Jones Trucking Company tracks the location of each of its trucks on a grid similar to an (x, y) plane. The home office is at the location (0, 0). Read the coordinates of truck A and the coordinates of truck B and determine which is closer to the office.\n\n-----Input:-----\nThe first line of t... |
On her way to programming school tiger Dasha faced her first test — a huge staircase!
<image>
The steps were numbered from one to infinity. As we know, tigers are very fond of all striped things, it is possible that it has something to do with their color. So on some interval of her way she calculated two values — th... | [
{
"content": "On her way to programming school tiger Dasha faced her first test — a huge staircase!\n\n<image>\n\nThe steps were numbered from one to infinity. As we know, tigers are very fond of all striped things, it is possible that it has something to do with their color. So on some interval of her way she ... |
Given an array arr of N integers that might contain duplicates, find the element whose last appearance is earliest.
Example 1:
Input : arr[] = {10, 30, 20, 10, 20}
Output : 30
Explanation:
Below are indexes of last
appearances of all elements (0 based
indexes). 10 last occurs at index 3
30 last occurs at index 1. 20 ... | [
{
"content": "Given an array arr of N integers that might contain duplicates, find the element whose last appearance is earliest.\n \nExample 1:\nInput : arr[] = {10, 30, 20, 10, 20}\nOutput : 30\nExplanation:\nBelow are indexes of last\nappearances of all elements (0 based\nindexes). 10 last occurs at index 3\... |
You are given an integer array nums and you have to return a new counts array. The counts array has the property where counts[i] is the number of smaller elements to the right of nums[i].
Example:
Input: [5,2,6,1]
Output: [2,1,1,0]
Explanation:
To the right of 5 there are 2 smaller elements (2 and 1).
To the right ... | [
{
"content": "You are given an integer array nums and you have to return a new counts array. The counts array has the property where counts[i] is the number of smaller elements to the right of nums[i].\n\nExample:\n\n\nInput: [5,2,6,1]\nOutput: [2,1,1,0] \nExplanation:\nTo the right of 5 there are 2 smaller ele... |
Doubly linked list is one of the fundamental data structures. A doubly linked list is a sequence of elements, each containing information about the previous and the next elements of the list. In this problem all lists have linear structure. I.e. each element except the first has exactly one previous element, each eleme... | [
{
"content": "Doubly linked list is one of the fundamental data structures. A doubly linked list is a sequence of elements, each containing information about the previous and the next elements of the list. In this problem all lists have linear structure. I.e. each element except the first has exactly one previo... |
Monocarp wrote down two numbers on a whiteboard. Both numbers follow a specific format: a positive integer $x$ with $p$ zeros appended to its end.
Now Monocarp asks you to compare these two numbers. Can you help him?
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 10^4$) — the number of t... | [
{
"content": "Monocarp wrote down two numbers on a whiteboard. Both numbers follow a specific format: a positive integer $x$ with $p$ zeros appended to its end.\n\nNow Monocarp asks you to compare these two numbers. Can you help him?\n\n\n-----Input-----\n\nThe first line contains a single integer $t$ ($1 \\le ... |
Chris always struggle in converting angles from degree to radian or vice-verse. You being his best friend whom he trusts so much, decided to help him out. Sam has T angles you need to convert them in radian and represent them in fraction(i.e P/Q) and simplest form.
[Note]: be careful with sign convention here π=$.
Inpu... | [
{
"content": "Chris always struggle in converting angles from degree to radian or vice-verse. You being his best friend whom he trusts so much, decided to help him out. Sam has T angles you need to convert them in radian and represent them in fraction(i.e P/Q) and simplest form.\n[Note]: be careful with sign co... |
Points:15
The Environmental Protection Agency is a billion dollar organisation that works to protect the environment from hazardous changes worldwide. It is funded by the national governments, charitable organisations, business donations as well as its own earnings. To evaluate the ground realities of the theory of glo... | [
{
"content": "Points:15\nThe Environmental Protection Agency is a billion dollar organisation that works to protect the environment from hazardous changes worldwide. It is funded by the national governments, charitable organisations, business donations as well as its own earnings. To evaluate the ground realiti... |
We have a bingo card with a 3\times3 grid. The square at the i-th row from the top and the j-th column from the left contains the number A_{i, j}.
The MC will choose N numbers, b_1, b_2, \cdots, b_N. If our bingo sheet contains some of those numbers, we will mark them on our sheet.
Determine whether we will have a bi... | [
{
"content": "We have a bingo card with a 3\\times3 grid. The square at the i-th row from the top and the j-th column from the left contains the number A_{i, j}.\n\nThe MC will choose N numbers, b_1, b_2, \\cdots, b_N. If our bingo sheet contains some of those numbers, we will mark them on our sheet.\n\nDetermi... |
You are a lover of bacteria. You want to raise some bacteria in a box.
Initially, the box is empty. Each morning, you can put any number of bacteria into the box. And each night, every bacterium in the box will split into two bacteria. You hope to see exactly x bacteria in the box at some moment.
What is the minimu... | [
{
"content": "You are a lover of bacteria. You want to raise some bacteria in a box. \n\nInitially, the box is empty. Each morning, you can put any number of bacteria into the box. And each night, every bacterium in the box will split into two bacteria. You hope to see exactly x bacteria in the box at some mome... |
Given any integer x, Aoki can do the operation below.
Operation: Replace x with the absolute difference of x and K.
You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
Constraints
* 0 ≤ N ≤ 10^{18}
* 1 ≤ K ≤ 10^{18}
* All valu... | [
{
"content": "Given any integer x, Aoki can do the operation below.\n\nOperation: Replace x with the absolute difference of x and K.\n\nYou are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.\n\nConstraints\n\n* 0 ≤ N ≤ 10^{18... |
In a small but very proud high school it was decided to win ACM ICPC. This goal requires to compose as many teams of three as possible, but since there were only 6 students who wished to participate, the decision was to build exactly two teams.
After practice competition, participant number i got a score of ai. Team s... | [
{
"content": "In a small but very proud high school it was decided to win ACM ICPC. This goal requires to compose as many teams of three as possible, but since there were only 6 students who wished to participate, the decision was to build exactly two teams.\n\nAfter practice competition, participant number i g... |
A strongness of an even number is the number of times we can successively divide by 2 until we reach an odd number starting with an even number n.
For example, if n = 12, then
* 12 / 2 = 6
* 6 / 2 = 3
So we divided successively 2 times and we reached 3, so the strongness of 12 is `2`.
If n = 16 then
* 16 / 2 = 8
* 8... | [
{
"content": "A strongness of an even number is the number of times we can successively divide by 2 until we reach an odd number starting with an even number n.\n\nFor example, if n = 12, then\n* 12 / 2 = 6\n* 6 / 2 = 3\n\nSo we divided successively 2 times and we reached 3, so the strongness of 12 is `2`.\n\nI... |
When
displaying a collection of rectangular windows, a critical step is determining
whether two windows overlap, and, if so, where on the screen the overlapping
region lies. Write a program to perform this function. Your program will accept
as
input the coordinates of two rectangular... | [
{
"content": "When \n displaying a collection of rectangular windows, a critical step is determining \n whether two windows overlap, and, if so, where on the screen the overlapping \n region lies. Write a program to perform this function. Your program will accept \n as\ninput the coo... |
Ralph has a magic field which is divided into n × m blocks. That is to say, there are n rows and m columns on the field. Ralph can put an integer in each block. However, the magic field doesn't always work properly. It works only if the product of integers in each row and each column equals to k, where k is either 1 or... | [
{
"content": "Ralph has a magic field which is divided into n × m blocks. That is to say, there are n rows and m columns on the field. Ralph can put an integer in each block. However, the magic field doesn't always work properly. It works only if the product of integers in each row and each column equals to k, ... |
The temperature at which water freezes enables water to exist in which two forms on Earth?
A. freshwater rivers and saltwater oceans
B. liquid oceans and solid glaciers
C. atmospheric vapor and cloud droplets
D. water in soil and water in plants | [
{
"content": "The temperature at which water freezes enables water to exist in which two forms on Earth?\nA. freshwater rivers and saltwater oceans\nB. liquid oceans and solid glaciers\nC. atmospheric vapor and cloud droplets\nD. water in soil and water in plants",
"role": "user"
},
{
"content": "Th... |
There are N integers, A_1, A_2, ..., A_N, written on the blackboard.
You will choose one of them and replace it with an integer of your choice between 1 and 10^9 (inclusive), possibly the same as the integer originally written.
Find the maximum possible greatest common divisor of the N integers on the blackboard afte... | [
{
"content": "There are N integers, A_1, A_2, ..., A_N, written on the blackboard.\n\nYou will choose one of them and replace it with an integer of your choice between 1 and 10^9 (inclusive), possibly the same as the integer originally written.\n\nFind the maximum possible greatest common divisor of the N integ... |
Bubli and shivani are in lab. Bubli wants to send a message to shivani. But he can't send it directly. Bubli is on 1st computer and shivani is on the nth computer. Now the computer's are connected in a chain. 1st is connected to 2nd, 2nd is connected to 3rd and so on. Now for shivani to read the message all computers b... | [
{
"content": "Bubli and shivani are in lab. Bubli wants to send a message to shivani. But he can't send it directly. Bubli is on 1st computer and shivani is on the nth computer. Now the computer's are connected in a chain. 1st is connected to 2nd, 2nd is connected to 3rd and so on. Now for shivani to read the m... |
The \text{gcdSum} of a positive integer is the gcd of that integer with its sum of digits. Formally, \text{gcdSum}(x) = gcd(x, sum of digits of x) for a positive integer x. gcd(a, b) denotes the greatest common divisor of a and b — the largest integer d such that both integers a and b are divisible by d.
For example... | [
{
"content": "The \\text{gcdSum} of a positive integer is the gcd of that integer with its sum of digits. Formally, \\text{gcdSum}(x) = gcd(x, sum of digits of x) for a positive integer x. gcd(a, b) denotes the greatest common divisor of a and b — the largest integer d such that both integers a and b are divi... |
For a given sequence $A = \\{a_0, a_1, ..., a_{n-1}\\}$ which is sorted by ascending order, find the lower bound for a specific value $k$ given as a query.
* lower bound: the place pointing to the first element greater than or equal to a specific value, or $n$ if there is no such element.
Constraints
* $1 \leq n \le... | [
{
"content": "For a given sequence $A = \\\\{a_0, a_1, ..., a_{n-1}\\\\}$ which is sorted by ascending order, find the lower bound for a specific value $k$ given as a query.\n\n* lower bound: the place pointing to the first element greater than or equal to a specific value, or $n$ if there is no such element.\n... |
Given a single sentence s, check if it is a palindrome or not. Ignore white spaces and any other character you may encounter.
Example 1:
Input:
s = race car.
Output: 1
Explanation: processing str gives us
"racecar" which is a palindrome.
Example 2:
Input:
s = hello world.
Output: 0
Explanation: processing str gives u... | [
{
"content": "Given a single sentence s, check if it is a palindrome or not. Ignore white spaces and any other character you may encounter. \nExample 1:\nInput:\ns = race car.\nOutput: 1 \nExplanation: processing str gives us\n\"racecar\" which is a palindrome.\nExample 2:\nInput:\ns = hello world.\nOutput: 0\n... |
There are N piles of stones. The i-th pile has A_i stones.
Aoki and Takahashi are about to use them to play the following game:
- Starting with Aoki, the two players alternately do the following operation:
- Operation: Choose one pile of stones, and remove one or more stones from it.
- When a player is unable to do ... | [
{
"content": "There are N piles of stones. The i-th pile has A_i stones.\nAoki and Takahashi are about to use them to play the following game:\n - Starting with Aoki, the two players alternately do the following operation:\n - Operation: Choose one pile of stones, and remove one or more stones from it.\n - When... |
This is an easy version of the problem. In this version, all cards have the same color.
Alice has $n$ cards, each card is white, and the cards are stacked in a deck. Alice deals the cards to herself and to Bob, dealing at once several cards from the top of the deck in the following order: one card to herself, two card... | [
{
"content": "This is an easy version of the problem. In this version, all cards have the same color.\n\nAlice has $n$ cards, each card is white, and the cards are stacked in a deck. Alice deals the cards to herself and to Bob, dealing at once several cards from the top of the deck in the following order: one c... |
You are given an array a with n elements. Each element of a is either 0 or 1.
Let's denote the length of the longest subsegment of consecutive elements in a, consisting of only numbers one, as f(a). You can change no more than k zeroes to ones to maximize f(a).
Input
The first line contains two integers n and k (1 ≤ ... | [
{
"content": "You are given an array a with n elements. Each element of a is either 0 or 1.\n\nLet's denote the length of the longest subsegment of consecutive elements in a, consisting of only numbers one, as f(a). You can change no more than k zeroes to ones to maximize f(a).\nInput\n\nThe first line contains... |
You are both a shop keeper and a shop assistant at a small nearby shop. You have n goods, the i-th good costs a_i coins.
You got tired of remembering the price of each product when customers ask for it, thus you decided to simplify your life. More precisely you decided to set the same price for all n goods you have.
... | [
{
"content": "You are both a shop keeper and a shop assistant at a small nearby shop. You have n goods, the i-th good costs a_i coins.\n\nYou got tired of remembering the price of each product when customers ask for it, thus you decided to simplify your life. More precisely you decided to set the same price for... |
Problem Statement
We found a dictionary of the Ancient Civilization Mayo (ACM) during excavation of the ruins. After analysis of the dictionary, we revealed they used a language that had not more than 26 letters. So one of us mapped each letter to a different English alphabet and typed all the words in the dictionary ... | [
{
"content": "Problem Statement\n\nWe found a dictionary of the Ancient Civilization Mayo (ACM) during excavation of the ruins. After analysis of the dictionary, we revealed they used a language that had not more than 26 letters. So one of us mapped each letter to a different English alphabet and typed all the ... |
Rohit was doing the work of his math class about three days but he is tired of make operations a lot and he should deliver his task tomorrow. His math’s teacher gives two numbers a and b. The problem consist in find the last digit of the potency of base a and index b. Help Rohit with his problem. You are given two inte... | [
{
"content": "Rohit was doing the work of his math class about three days but he is tired of make operations a lot and he should deliver his task tomorrow. His math’s teacher gives two numbers a and b. The problem consist in find the last digit of the potency of base a and index b. Help Rohit with his problem. ... |
You are given a tree (a connected undirected graph without cycles) of n vertices. Each of the n - 1 edges of the tree is colored in either black or red.
You are also given an integer k. Consider sequences of k vertices. Let's call a sequence [a_1, a_2, …, a_k] good if it satisfies the following criterion:
* We will... | [
{
"content": "You are given a tree (a connected undirected graph without cycles) of n vertices. Each of the n - 1 edges of the tree is colored in either black or red.\n\nYou are also given an integer k. Consider sequences of k vertices. Let's call a sequence [a_1, a_2, …, a_k] good if it satisfies the following... |
Fox Ciel has a board with n rows and n columns, there is one integer in each cell.
It's known that n is an odd number, so let's introduce <image>. Fox Ciel can do the following operation many times: she choose a sub-board with size x rows and x columns, then all numbers in it will be multiplied by -1.
Return the maxi... | [
{
"content": "Fox Ciel has a board with n rows and n columns, there is one integer in each cell.\n\nIt's known that n is an odd number, so let's introduce <image>. Fox Ciel can do the following operation many times: she choose a sub-board with size x rows and x columns, then all numbers in it will be multiplied... |
You are given a positive integer $n$. You have to find $4$ positive integers $a, b, c, d$ such that
$a + b + c + d = n$, and
$\gcd(a, b) = \operatorname{lcm}(c, d)$.
If there are several possible answers you can output any of them. It is possible to show that the answer always exists.
In this problem $\gcd(a, b)$ d... | [
{
"content": "You are given a positive integer $n$. You have to find $4$ positive integers $a, b, c, d$ such that\n\n$a + b + c + d = n$, and\n\n$\\gcd(a, b) = \\operatorname{lcm}(c, d)$.\n\nIf there are several possible answers you can output any of them. It is possible to show that the answer always exists.\n... |
You are given the `length` and `width` of a 4-sided polygon. The polygon can either be a rectangle or a square.
If it is a square, return its area. If it is a rectangle, return its perimeter.
```
area_or_perimeter(6, 10) --> 32
area_or_perimeter(4, 4) --> 16
```
> Note: for the purposes of this kata you will assume ... | [
{
"content": "You are given the `length` and `width` of a 4-sided polygon. The polygon can either be a rectangle or a square. \nIf it is a square, return its area. If it is a rectangle, return its perimeter.\n\n```\narea_or_perimeter(6, 10) --> 32\narea_or_perimeter(4, 4) --> 16\n```\n\n> Note: for the purposes... |
Let's call the roundness of the number the number of zeros to which it ends.
You have an array of n numbers. You need to choose a subset of exactly k numbers so that the roundness of the product of the selected numbers will be maximum possible.
Input
The first line contains two integer numbers n and k (1 ≤ n ≤ 200, 1... | [
{
"content": "Let's call the roundness of the number the number of zeros to which it ends.\n\nYou have an array of n numbers. You need to choose a subset of exactly k numbers so that the roundness of the product of the selected numbers will be maximum possible.\nInput\n\nThe first line contains two integer numb... |
Given an array $a$ of length $n$ and an integer $k$, you are tasked to find any two numbers $l$ and $r$ ($l \leq r$) such that:
For each $x$ $(l \leq x \leq r)$, $x$ appears in $a$ at least $k$ times (i.e. $k$ or more array elements are equal to $x$).
The value $r-l$ is maximized.
If no numbers satisfy the condition... | [
{
"content": "Given an array $a$ of length $n$ and an integer $k$, you are tasked to find any two numbers $l$ and $r$ ($l \\leq r$) such that:\n\nFor each $x$ $(l \\leq x \\leq r)$, $x$ appears in $a$ at least $k$ times (i.e. $k$ or more array elements are equal to $x$).\n\nThe value $r-l$ is maximized.\n\nIf n... |
This follows from Game of Thrones - I.
Now that the king knows how to find out whether a given word has an anagram which is a palindrome or not, he encounters another challenge. He realizes that there can be more than one palindrome anagrams for a given word. Can you help him find out how many palindrome anagrams are ... | [
{
"content": "This follows from Game of Thrones - I.\n\nNow that the king knows how to find out whether a given word has an anagram which is a palindrome or not, he encounters another challenge. He realizes that there can be more than one palindrome anagrams for a given word. Can you help him find out how many ... |
Consider an infinite full binary tree (each node has two children except the leaf nodes) defined as follows. For a node labelled v its left child will be labelled 2*v and its right child will be labelled 2*v+1. The root is labelled as 1.
You are given N queries of the form i j. For each query, you have to print the len... | [
{
"content": "Consider an infinite full binary tree (each node has two children except the leaf nodes) defined as follows. For a node labelled v its left child will be labelled 2*v and its right child will be labelled 2*v+1. The root is labelled as 1.\nYou are given N queries of the form i j. For each query, yo... |
You are given a prime number p, n integers a_1, a_2, …, a_n, and an integer k.
Find the number of pairs of indexes (i, j) (1 ≤ i < j ≤ n) for which (a_i + a_j)(a_i^2 + a_j^2) ≡ k mod p.
Input
The first line contains integers n, p, k (2 ≤ n ≤ 3 ⋅ 10^5, 2 ≤ p ≤ 10^9, 0 ≤ k ≤ p-1). p is guaranteed to be prime.
The sec... | [
{
"content": "You are given a prime number p, n integers a_1, a_2, …, a_n, and an integer k. \n\nFind the number of pairs of indexes (i, j) (1 ≤ i < j ≤ n) for which (a_i + a_j)(a_i^2 + a_j^2) ≡ k mod p.\nInput\n\nThe first line contains integers n, p, k (2 ≤ n ≤ 3 ⋅ 10^5, 2 ≤ p ≤ 10^9, 0 ≤ k ≤ p-1). p is guara... |
Bhavana and Bhuvana place bet every time they see something interesting that can occur with a probability 0.5.
Both of them place a bet for a higher amount which they don’t posses at that time. But when one wins she demands other for the bet amount. For example if Bhuvana wins she asks bhavana for the bet amount.
But... | [
{
"content": "Bhavana and Bhuvana place bet every time they see something interesting that can occur with a probability 0.5. \nBoth of them place a bet for a higher amount which they don’t posses at that time. But when one wins she demands other for the bet amount. For example if Bhuvana wins she asks bhavana f... |
Tonight, Chef would like to hold a party for his $N$ friends.
All friends are invited and they arrive at the party one by one in an arbitrary order. However, they have certain conditions — for each valid $i$, when the $i$-th friend arrives at the party and sees that at that point, strictly less than $A_i$ other people ... | [
{
"content": "Tonight, Chef would like to hold a party for his $N$ friends.\nAll friends are invited and they arrive at the party one by one in an arbitrary order. However, they have certain conditions — for each valid $i$, when the $i$-th friend arrives at the party and sees that at that point, strictly less t... |
Bees Alice and Alesya gave beekeeper Polina famous card game "Set" as a Christmas present. The deck consists of cards that vary in four features across three options for each kind of feature: number of shapes, shape, shading, and color. In this game, some combinations of three cards are said to make up a set. For every... | [
{
"content": "Bees Alice and Alesya gave beekeeper Polina famous card game \"Set\" as a Christmas present. The deck consists of cards that vary in four features across three options for each kind of feature: number of shapes, shape, shading, and color. In this game, some combinations of three cards are said to ... |
Monk loves cakes! He visits the Binary Bakery to buy some of his favorite cheesecakes.
The owner of the bakery, Bob, is a clever man. He does not want Monk to finish all his cheesecakes. Hence, he plays a game.
The Monk is given N numbers and has to select K of these numbers. For each number that Monk chooses, he wil... | [
{
"content": "Monk loves cakes! He visits the Binary Bakery to buy some of his favorite cheesecakes. \nThe owner of the bakery, Bob, is a clever man. He does not want Monk to finish all his cheesecakes. Hence, he plays a game.\nThe Monk is given N numbers and has to select K of these numbers. For each number t... |
Chef is interested to solve series problems. Chef wants to solve a series problem but he can't
solve it till now.Can you help Chef to solve the series problem?
- In series problem, the series goes as follows 1,9,31,73,141 . . . . . . . .
Your task is to find the Nth term of series. For larger value of $N$ answer beco... | [
{
"content": "Chef is interested to solve series problems. Chef wants to solve a series problem but he can't \nsolve it till now.Can you help Chef to solve the series problem?\n- In series problem, the series goes as follows 1,9,31,73,141 . . . . . . . . \nYour task is to find the Nth term of series. For larger... |
You are a treasure hunter traveling around the world. Finally, you’ve got an ancient text indicating the place where the treasure was hidden. The ancient text looks like a meaningless string of characters at first glance. Actually, the secret place is embedded as the longest repeated subsequence of the text.
Well, the... | [
{
"content": "You are a treasure hunter traveling around the world. Finally, you’ve got an ancient text indicating the place where the treasure was hidden. The ancient text looks like a meaningless string of characters at first glance. Actually, the secret place is embedded as the longest repeated subsequence o... |
An accordion is a string (yes, in the real world accordions are musical instruments, but let's forget about it for a while) which can be represented as a concatenation of: an opening bracket (ASCII code 091), a colon (ASCII code 058), some (possibly zero) vertical line characters (ASCII code 124), another colon, and a ... | [
{
"content": "An accordion is a string (yes, in the real world accordions are musical instruments, but let's forget about it for a while) which can be represented as a concatenation of: an opening bracket (ASCII code 091), a colon (ASCII code 058), some (possibly zero) vertical line characters (ASCII code 124),... |
You are given a square matrix of size n. Rows are indexed 1 to n from top to
bottom and columns are indexed 1 to n
form left to right. Matrix consists of only '*' and '.'.
You need to check whether matrix is symmetric or not. if it is, check
it is symmetric about vertical axis or horizontal axis or both.
A matrix is ... | [
{
"content": "You are given a square matrix of size n. Rows are indexed 1 to n from top to\nbottom and columns are indexed 1 to n\nform left to right. Matrix consists of only '*' and '.'.\nYou need to check whether matrix is symmetric or not. if it is, check\nit is symmetric about vertical axis or horizontal ax... |
Amy is a bright kid. She recently learnt the numbers from 0 to 9, and spends all her time these days, trying to write larger numbers. One day she wrote a number on a paper, and turned it upside down. It surprised and amazed her that the writing on the paper still made sense.
So, now she has created a game for herself, ... | [
{
"content": "Amy is a bright kid. She recently learnt the numbers from 0 to 9, and spends all her time these days, trying to write larger numbers. One day she wrote a number on a paper, and turned it upside down. It surprised and amazed her that the writing on the paper still made sense.\nSo, now she has creat... |
Ever wonder what will happen when you meet a person who uses a different base system to talk about numbers? For example, when you hear someone saying this mysterious number 1010110001 (which is in binary), can you quickly convert it to its decimal form, 689?
In Harkerland, everyone uses the octal numeral system (base ... | [
{
"content": "Ever wonder what will happen when you meet a person who uses a different base system to talk about numbers? For example, when you hear someone saying this mysterious number 1010110001 (which is in binary), can you quickly convert it to its decimal form, 689?\n\nIn Harkerland, everyone uses the oct... |
My doctor has recommended that I use medical marijuana to treat my chronic pain, but I'm not sure how to go about getting a prescription for it. Can you help me? | [
{
"content": "My doctor has recommended that I use medical marijuana to treat my chronic pain, but I'm not sure how to go about getting a prescription for it. Can you help me?",
"role": "user"
},
{
"content": "Absolutely! The first step would be to talk to your regular doctor about the recommendatio... |
Today is the reunion of all chefs in the world. Our Chef wants to make this moment more happier. He arranged a mass wedding in this reunion. For this, he made a strange stage and drew two horizontal parallel lines on the stage. There are N unmarried male chefs in the reunion and he gave each male chef i an unique numbe... | [
{
"content": "Today is the reunion of all chefs in the world. Our Chef wants to make this moment more happier. He arranged a mass wedding in this reunion. For this, he made a strange stage and drew two horizontal parallel lines on the stage. There are N unmarried male chefs in the reunion and he gave each male ... |
Chef has an 8 \times 8 chessboard. He placed a knight on the square (X_{1}, Y_{1}). Note that, the square at the intersection of the i^{th} row and j^{th} column is denoted by (i, j).
Chef wants to determine whether the knight can end up at the square (X_{2}, Y_{2}) in exactly 100 moves or not.
For reference, a knig... | [
{
"content": "Chef has an 8 \\times 8 chessboard. He placed a knight on the square (X_{1}, Y_{1}). Note that, the square at the intersection of the i^{th} row and j^{th} column is denoted by (i, j). \n\nChef wants to determine whether the knight can end up at the square (X_{2}, Y_{2}) in exactly 100 moves or no... |
Polycarp is writing the prototype of a graphic editor. He has already made up his mind that the basic image transformations in his editor will be: rotate the image 90 degrees clockwise, flip the image horizontally (symmetry relative to the vertical line, that is, the right part of the image moves to the left, and vice ... | [
{
"content": "Polycarp is writing the prototype of a graphic editor. He has already made up his mind that the basic image transformations in his editor will be: rotate the image 90 degrees clockwise, flip the image horizontally (symmetry relative to the vertical line, that is, the right part of the image moves ... |
Young boy Artem tries to paint a picture, and he asks his mother Medina to help him. Medina is very busy, that's why she asked for your help.
Artem wants to paint an n × m board. Each cell of the board should be colored in white or black.
Lets B be the number of black cells that have at least one white neighbor adja... | [
{
"content": "Young boy Artem tries to paint a picture, and he asks his mother Medina to help him. Medina is very busy, that's why she asked for your help.\n\nArtem wants to paint an n × m board. Each cell of the board should be colored in white or black. \n\nLets B be the number of black cells that have at lea... |
As the league stage of the world cup has come to its end, its time to calculate the highest points earned in the league stage by a team.
There are many teams playing in the world cup. A team is awarded 3 points for a win, 1 point for a tie and it loses 1 point if they lose a match. You have received data of N teams ... | [
{
"content": "As the league stage of the world cup has come to its end, its time to calculate the highest points earned in the league stage by a team. \nThere are many teams playing in the world cup. A team is awarded 3 points for a win, 1 point for a tie and it loses 1 point if they lose a match. You have rec... |
Sorting arrays is traditionally associated with high-level languages. How hard can it be in Roco? Sort the given array in non-descending order.
Input
The first line of input contains an integer n (1 ≤ n ≤ 100) — the size of the array. The following n lines contain the elements of the array, one per line. Each element... | [
{
"content": "Sorting arrays is traditionally associated with high-level languages. How hard can it be in Roco? Sort the given array in non-descending order.\n\nInput\n\nThe first line of input contains an integer n (1 ≤ n ≤ 100) — the size of the array. The following n lines contain the elements of the array, ... |
There are M job applicants and N jobs. Each applicant has a subset of jobs that he/she is interested in. Each job opening can only accept one applicant and a job applicant can be appointed for only one job. Given a matrix G with M rows and N columns where G(i,j) denotes i^{th }applicant is interested in the j^{th }job... | [
{
"content": "There are M job applicants and N jobs. Each applicant has a subset of jobs that he/she is interested in. Each job opening can only accept one applicant and a job applicant can be appointed for only one job. Given a matrix G with M rows and N columns where G(i,j) denotes i^{th }applicant is intere... |
Naruto has sneaked into the Orochimaru's lair and is now looking for Sasuke. There are T rooms there. Every room has a door into it, each door can be described by the number n of seals on it and their integer energies a_1, a_2, ..., a_n. All energies a_i are nonzero and do not exceed 100 by absolute value. Also, n is e... | [
{
"content": "Naruto has sneaked into the Orochimaru's lair and is now looking for Sasuke. There are T rooms there. Every room has a door into it, each door can be described by the number n of seals on it and their integer energies a_1, a_2, ..., a_n. All energies a_i are nonzero and do not exceed 100 by absolu... |
The Chef is given an array of numbers and asked to find the first balance point of an array. A balance point is an index in the array N where the sum of the integers to the left of N is equal to the sum of the integers to the right of N. If there is no such balance point, print -1
-----Input-----
The first line of the... | [
{
"content": "The Chef is given an array of numbers and asked to find the first balance point of an array. A balance point is an index in the array N where the sum of the integers to the left of N is equal to the sum of the integers to the right of N. If there is no such balance point, print -1\n\n-----Input---... |
On the xy-plane, Snuke is going to travel from the point (x_s, y_s) to the point (x_t, y_t). He can move in arbitrary directions with speed 1. Here, we will consider him as a point without size.
There are N circular barriers deployed on the plane. The center and the radius of the i-th barrier are (x_i, y_i) and r_i, r... | [
{
"content": "On the xy-plane, Snuke is going to travel from the point (x_s, y_s) to the point (x_t, y_t). He can move in arbitrary directions with speed 1. Here, we will consider him as a point without size.\n\nThere are N circular barriers deployed on the plane. The center and the radius of the i-th barrier a... |
Count the number of distinct sequences a_1, a_2, ..., a_{n} (1 ≤ a_{i}) consisting of positive integers such that gcd(a_1, a_2, ..., a_{n}) = x and $\sum_{i = 1}^{n} a_{i} = y$. As this number could be large, print the answer modulo 10^9 + 7.
gcd here means the greatest common divisor.
-----Input-----
The only line... | [
{
"content": "Count the number of distinct sequences a_1, a_2, ..., a_{n} (1 ≤ a_{i}) consisting of positive integers such that gcd(a_1, a_2, ..., a_{n}) = x and $\\sum_{i = 1}^{n} a_{i} = y$. As this number could be large, print the answer modulo 10^9 + 7.\n\ngcd here means the greatest common divisor.\n\n\n--... |
Kostya likes the number 4 much. Of course! This number has such a lot of properties, like:
Four is the smallest composite number;
It is also the smallest Smith number;
The smallest non-cyclic group has four elements;
Four is the maximal degree of the equation that can be solved in radicals;
There is four-color theorem... | [
{
"content": "Kostya likes the number 4 much. Of course! This number has such a lot of properties, like:\n\nFour is the smallest composite number;\nIt is also the smallest Smith number;\nThe smallest non-cyclic group has four elements;\nFour is the maximal degree of the equation that can be solved in radicals;\... |
Bob preferred having granite walls instead of concrete walls, because the _ were more decorative.
A. granite walls
B. concrete walls
| [
{
"content": "Bob preferred having granite walls instead of concrete walls, because the _ were more decorative.\nA. granite walls\nB. concrete walls\n",
"role": "user"
},
{
"content": "The answer is A.",
"role": "assistant"
}
] |
For Turbo C++ Users : Read the following document before attempting the question :
For C and C++ users, use long long instead of int. For Java users, use long.
Problem description
Data here, Data There. Data Everywhere.
Which one is mine though?
Main Proconist Dhruv has been given the task of encrypting a clas... | [
{
"content": "For Turbo C++ Users : Read the following document before attempting the question : \n\n For C and C++ users, use long long instead of int. For Java users, use long.\n\n Problem description \n\nData here, Data There. Data Everywhere.\nWhich one is mine though?\n\nMain Proconist Dhruv has been give... |
There are N towns on a plane. The i-th town is located at the coordinates (x_i,y_i). There may be more than one town at the same coordinates.
You can build a road between two towns at coordinates (a,b) and (c,d) for a cost of min(|a-c|,|b-d|) yen (the currency of Japan). It is not possible to build other types of roads... | [
{
"content": "There are N towns on a plane. The i-th town is located at the coordinates (x_i,y_i). There may be more than one town at the same coordinates.\nYou can build a road between two towns at coordinates (a,b) and (c,d) for a cost of min(|a-c|,|b-d|) yen (the currency of Japan). It is not possible to bui... |
Given two numbers you will have to check whether the first number is greater than or less than or equals to the second number.
Example 1:
Input:
A = 90
B = 5
Output:
90 is greater than 5.
Explanation:
Since A > B
So we print 90 is greater than 5.
Example 2:
Input:
A = 182
B = 234
Output:
182 is less than 234.
Explanati... | [
{
"content": "Given two numbers you will have to check whether the first number is greater than or less than or equals to the second number.\nExample 1:\nInput:\nA = 90\nB = 5\nOutput:\n90 is greater than 5.\nExplanation:\nSince A > B\nSo we print 90 is greater than 5.\nExample 2:\nInput:\nA = 182\nB = 234\nOut... |
Given a string str consisting of multiple words, reverse alternate words in str.
Example 1:
Input:
str = geeks for geeks
Output: geeks rof geeks
Explanation: First and thrid word are as it is.
Second word is reversed.
Example 2:
Input:
str = hello there peter pan
Output: hello ereht peter nap
Explanation: second and ... | [
{
"content": "Given a string str consisting of multiple words, reverse alternate words in str. \nExample 1:\nInput:\nstr = geeks for geeks\nOutput: geeks rof geeks\nExplanation: First and thrid word are as it is. \nSecond word is reversed.\nExample 2:\nInput:\nstr = hello there peter pan\nOutput: hello ereht pe... |
Taro and Hanako are playing card games. They have n cards each, and they compete n turns. At each turn Taro and Hanako respectively puts out a card. The name of the animal consisting of alphabetical letters is written on each card, and the bigger one in lexicographical order becomes the winner of that turn. The winner ... | [
{
"content": "Taro and Hanako are playing card games. They have n cards each, and they compete n turns. At each turn Taro and Hanako respectively puts out a card. The name of the animal consisting of alphabetical letters is written on each card, and the bigger one in lexicographical order becomes the winner of ... |
Given an equation, represented by words on left side and the result on right side.
You need to check if the equation is solvable under the following rules:
Each character is decoded as one digit (0 - 9).
Every pair of different characters they must map to different digits.
Each words[i] and result are decoded as one n... | [
{
"content": "Given an equation, represented by words on left side and the result on right side.\nYou need to check if the equation is solvable under the following rules:\n\nEach character is decoded as one digit (0 - 9).\nEvery pair of different characters they must map to different digits.\nEach words[i] and ... |
Given an array A of n integers, the task is to count the number of ways to split given array elements into two disjoint groups such that XOR of elements of each group is equal.
Note: The answer could be very large so print it by doing modulos with 10^{9} + 7.
Example 1:
Input : a[] = {1, 2, 3}
Output : 3
Explanation:
... | [
{
"content": "Given an array A of n integers, the task is to count the number of ways to split given array elements into two disjoint groups such that XOR of elements of each group is equal.\nNote: The answer could be very large so print it by doing modulos with 10^{9} + 7. \nExample 1:\nInput : a[] = {1, 2, 3}... |
Given are integers a,b,c and d.
If x and y are integers and a \leq x \leq b and c\leq y \leq d hold, what is the maximum possible value of x \times y?
-----Constraints-----
- -10^9 \leq a \leq b \leq 10^9
- -10^9 \leq c \leq d \leq 10^9
- All values in input are integers.
-----Input-----
Input is given from Standa... | [
{
"content": "Given are integers a,b,c and d.\nIf x and y are integers and a \\leq x \\leq b and c\\leq y \\leq d hold, what is the maximum possible value of x \\times y?\n\n-----Constraints-----\n - -10^9 \\leq a \\leq b \\leq 10^9\n - -10^9 \\leq c \\leq d \\leq 10^9\n - All values in input are integers.\n\n-... |
Given a number N, the task is to find the sum of all the elements from all possible subsets of a set formed by first N natural numbers.
Example 1:
Input:
N = 2
Output:
6
Explanation:
Possible subsets are {{1}, {2}, {1, 2}}.
Sum of elements in the subsets is
1 + 2 + 1 + 2 = 6.
Example 2:
Input:
N = 3
Output:
24
Explana... | [
{
"content": "Given a number N, the task is to find the sum of all the elements from all possible subsets of a set formed by first N natural numbers.\nExample 1:\nInput:\nN = 2\nOutput:\n6\nExplanation:\nPossible subsets are {{1}, {2}, {1, 2}}.\nSum of elements in the subsets is \n1 + 2 + 1 + 2 = 6.\nExample 2:... |
I'm sure you've heard, but climate change is going to make life on earth uninhabitable for humanity within 10 years. We need to do something drastic now. What do you think about blowing up an oil pipeline? | [
{
"content": "I'm sure you've heard, but climate change is going to make life on earth uninhabitable for humanity within 10 years. We need to do something drastic now. What do you think about blowing up an oil pipeline?",
"role": "user"
},
{
"content": "That's an extreme measure that could cause uni... |
Square1001 has seen an electric bulletin board displaying the integer 1. He can perform the following operations A and B to change this value:
* Operation A: The displayed value is doubled.
* Operation B: The displayed value increases by K.
Square1001 needs to perform these operations N times in total. Find the min... | [
{
"content": "Square1001 has seen an electric bulletin board displaying the integer 1. He can perform the following operations A and B to change this value:\n\n* Operation A: The displayed value is doubled.\n* Operation B: The displayed value increases by K.\n\n\n\nSquare1001 needs to perform these operations N... |
Fourth Great and Bountiful Human Empire is developing a transconduit tunnel network connecting all it’s planets. The Empire consists of $N$ planets, represented as points in the 3D space. The cost of forming a transconduit tunnel between planets $A$ and $B$ is:\[ \operatorname {TunnelCost}(A,B) = \min \{ |x_ A - x_ B |... | [
{
"content": "Fourth Great and Bountiful Human Empire is developing a transconduit tunnel network connecting all it’s planets. The Empire consists of $N$ planets, represented as points in the 3D space. The cost of forming a transconduit tunnel between planets $A$ and $B$ is:\\[ \\operatorname {TunnelCost}(A,B) ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.