name stringlengths 2 82 | description stringlengths 42 10.5k | private_tests dict | public_tests dict | generated_tests dict |
|---|---|---|---|---|
ren2013k | You are provided with a set of numbers which is infinitely large. The numbers in this set are of the form :-
{ 2^2^n + 1 } where n is a positive integer. Now these set of numbers are kept in sorted order.
Now queries are defined on this set such that given a range of terms [X...Y] you must calculate the sum of pairwis... | {
"input": [],
"output": []
} | {
"input": [
"1\n1 3"
],
"output": [
"3"
]
} | {
"input": [],
"output": []
} |
1252_D. Find String in a Grid | You have a grid G containing R rows (numbered from 1 to R, top to bottom) and C columns (numbered from 1 to C, left to right) of uppercase characters. The character in the r^{th} row and the c^{th} column is denoted by G_{r, c}. You also have Q strings containing uppercase characters. For each of the string, you want t... | {
"input": [],
"output": []
} | {
"input": [
"3 3 5\nABC\nBCD\nDAB\nABC\nBC\nBD\nAC\nA\n",
"2 3 3\nAAA\nAAA\nA\nAAA\nAAAAA\n"
],
"output": [
"\n2\n3\n1\n0\n2\n",
"\n6\n4\n0\n"
]
} | {
"input": [],
"output": []
} |
288_E. Polo the Penguin and Lucky Numbers | Everybody knows that lucky numbers are positive integers that contain only lucky digits 4 and 7 in their decimal representation. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Polo the Penguin have two positive integers l and r (l < r), both of them are lucky numbers. Moreover, their lengths (that i... | {
"input": [
"4777474744774\n7444747447774\n",
"447\n774\n",
"47774\n74777\n",
"44474444747774774747747747444744447477747774777\n74474447477474444747777474447474777774747444447\n",
"444\n777\n",
"44744\n74747\n",
"4444\n7777\n",
"47474747777477444447474477474774777747747777477777474477... | {
"input": [
"474\n777\n",
"4\n7\n"
],
"output": [
"2316330\n",
"28\n"
]
} | {
"input": [],
"output": []
} |
baahubali-and-the-closest-strategy | Given N numbers and M queries, for each query Mi, find the sum of two distinct
numbers closest to the query number, if more than one such sum exists print the smallest one.
Input:
First line contains the value of N and M
Second line contains N integers separated by a space
In each of the M lines contains the query n... | {
"input": [
"792 2\n63 51 1224781 138576 251640 45 817 1 46 54473721 29806960 299 504645 337 3626 9314 4037377 5 3972641 6088 175 1614 78767404 66574 73101 511 3 39 6 4 55 62160754 1747 55399 302124 6562 235020 5 98 269 691 454305 438 31166 41 394 966 50705 8769 37150346 3877935 7258 2873371 331 82840738 30989 7... | {
"input": [
"5 3\n3 12 17 33 34\n1\n51\n30\n\nSAMPLE"
],
"output": [
"15\n51\n29"
]
} | {
"input": [],
"output": []
} |
dbz16xs1 | Shil has a number X.He challenges you to find minimum positive number K such that F(K) is equal to X.
F(x) is defined as 1^2^3^....x. ^ denotes the bitwise Xor operation
Input
First line of input will consists of total number of test cases T.Next T lines contains a number X.
Output
For each test case , outpu... | {
"input": [],
"output": []
} | {
"input": [
"3\n1\n2\n100"
],
"output": [
"1\n-1\n100"
]
} | {
"input": [],
"output": []
} |
1297_F. Movie Fan | Recently, Polycarp has been a fan of cinema novelties and is trying not to miss them!
In the near future, n new movies will be released: the i-th of them will be airing from the day a_i and to the day b_i. This means that if Polycarp wants to watch the i-th movie in the cinema, he must do so in the period from a_i to ... | {
"input": [],
"output": []
} | {
"input": [
"3\n7 2\n1 2\n1 3\n2 2\n2 3\n1 1\n2 3\n1 2\n5 3\n1 1\n1 1\n1 1\n1 1\n1 1\n6 1\n13 13\n31 31\n25 25\n12 12\n14 14\n10 10\n"
],
"output": [
"\n1\n1 3 2 3 1 4 2 \n1\n1 1 1 2 2 \n0\n13 31 25 12 14 10 \n"
]
} | {
"input": [],
"output": []
} |
1402_B. Roads | The government of Treeland wants to build a new road network. There are 2N cities in Treeland. The unfinished plan of the road network already contains N road segments, each of which connects two cities with a straight line. No two road segments have a common point (including their endpoints). Your task is to determine... | {
"input": [],
"output": []
} | {
"input": [
"5\n1 3 3 6\n5 1 5 3\n3 3 6 5\n2 1 4 1\n2 3 4 2\n"
],
"output": [
"\n2 1 1 3\n2 3 2 1\n3 3 2 3\n5 1 4 2\n"
]
} | {
"input": [],
"output": []
} |
climbing-ladder-1 | Euler's phi function for a positive integer N is usually denoted as φ(N) and defined as the number of positive integers less than or equal to N that are coprime with N.
DA-IICT is organising its sports event in the month of October and this time they have introduced a new game called climbing ladder.
The game is as f... | {
"input": [],
"output": []
} | {
"input": [
"2\n4\n1 2 3 4\n2\n1 1\n\nSAMPLE"
],
"output": [
"14\n2"
]
} | {
"input": [],
"output": []
} |
sherlock-and-magic | Sherlock is following N criminals, which are right now in a 2D grid. Each criminal at t=0, decides to move in certain fixed direction. Each criminal moves with same speed. These fixed directions are North, East, West and South. Two or more criminals, however, vanish whenever they meet at any place at same time, t>0. ... | {
"input": [],
"output": []
} | {
"input": [
"1\n4\n0 0 N\n10 10 W\n20 20 N\n30 30 E\n\nSAMPLE"
],
"output": [
"2"
]
} | {
"input": [],
"output": []
} |
p01263 Reaction | You are a hero of a role playing game, asked by the king to defeat monsters threating people’s life.
You have been making a long journey with your colleagues, and you are now in the town closest to the final dungeon where the head of monsters dwells. You have heard from people that the head monster hits with his stron... | {
"input": [],
"output": []
} | {
"input": [
"2 2\n1 1\n1 1\n4\nA 10\nB 20\nC 30\nD 40\n4\n1 1 3 A A A\n1 2 2 B C\n2 1 1 D\n2 2 3 A A B\n2 2\n1 2\n2 1\n3\nScroll 50\nBastard 100\nHeal100 10\n3\n1 1 1 Scroll\n2 1 1 Bastard\n2 2 1 Heal100\n0 0"
],
"output": [
"90\n200"
]
} | {
"input": [],
"output": []
} |
p02016 Twins | B: Twins
One twin was angry that it was not well known which of them was the older brother and which was the younger brother.
Create a program that outputs "square1001" when "ani" is entered and "e869120" when "otouto" is entered.
input
You will be given either the string "ani" or "otouto" as input.
output
Please... | {
"input": [],
"output": []
} | {
"input": [
"ani"
],
"output": [
"square1001"
]
} | {
"input": [],
"output": []
} |
cd1it2 | Little Chef is learning differentiation and is amazed by the function e^x as it stays the same even after differentiation.
Just for fun, he tries to find out how large is the value of e^x. He is able to see only 10 digits in his calculator so he wants you to answer his endless list of queries for different values of x.... | {
"input": [],
"output": []
} | {
"input": [
"3\n1\n10\n101"
],
"output": [
"1\n5\n44"
]
} | {
"input": [],
"output": []
} |
1064_C. Oh Those Palindromes | A non-empty string is called palindrome, if it reads the same from the left to the right and from the right to the left. For example, "abcba", "a", and "abba" are palindromes, while "abab" and "xy" are not.
A string is called a substring of another string, if it can be obtained from that string by dropping some (possi... | {
"input": [
"6\nmsucmc\n",
"2\naa\n",
"15\nabacabadabacaba\n",
"21\narozaupalanalapuazora\n",
"4\nmems\n",
"10\nmsunonames\n",
"2\naz\n",
"1\nz\n",
"7\nlolikek\n",
"9\nabcabcabc\n"
],
"output": [
"ccmmsu\n",
"aa\n",
"aaaaaaaabbbbccd\n",
"aaaaaaaallnoopprruu... | {
"input": [
"16\ngagadbcgghhchbdf\n",
"5\noolol\n"
],
"output": [
"aabbccddfgggghhh\n",
"llooo\n"
]
} | {
"input": [],
"output": []
} |
1252_I. Mission Possible | Allen, a government secret service, has been assigned to infiltrate a mafia secret base to uncover crucial information regarding the mafia's operations.
The secret base is a rectangular bounded by (x_L,y_L), (x_L,y_R), (x_R,y_L), and (x_R,y_R) in a Cartesian coordinate system where x_L < x_R and y_L < y_R. There are N... | {
"input": [],
"output": []
} | {
"input": [
"3 2 2 50 26\n4 14\n48 14\n15 13 7\n36 16 6\n46 18 3\n",
"1 0 0 1000 1000\n100 501\n900 501\n500 251 250\n"
],
"output": [
"\n2\n13.25 23.1234567\n36.591003 7.1\n",
"\n0\n"
]
} | {
"input": [],
"output": []
} |
1338_E. JYPnation | Due to the success of TWICE, JYP Entertainment has earned countless money and emerged as the biggest entertainment firm by market capitalization. Therefore, the boss, JYP, has decided to create a new nation and has appointed you to provide a design diagram.
The new nation consists of n cities and some roads between th... | {
"input": [
"12\n410\n000\nD1F\nC17\nF5F\nF1F\nFDF\n400\nD17\nC13\nC11\nC10\n",
"12\n092\n899\nD6D\nC2D\n366\nD2D\nC1D\n3C2\n893\nC19\n764\n892\n",
"12\n1C6\nA5B\n85B\n68D\n619\n186\nFDF\n942\n852\n699\n184\n85A\n"
],
"output": [
"486354\n",
"205\n",
"81234\n"
]
} | {
"input": [
"8\n7F\n3F\n1F\n0C\n06\n03\n11\n18\n",
"4\n7\n2\n1\n4\n"
],
"output": [
"88464\n",
"7380\n"
]
} | {
"input": [],
"output": []
} |
35_D. Animals | Once upon a time DravDe, an outstanding person famous for his professional achievements (as you must remember, he works in a warehouse storing Ogudar-Olok, a magical but non-alcoholic drink) came home after a hard day. That day he had to drink 9875 boxes of the drink and, having come home, he went to bed at once.
Drav... | {
"input": [
"100 1234\n1 5 6 5 6 5 2 3 2 1 4 1 6 6 4 5 3 6 5 1 1 5 2 2 3 3 6 1 1 4 6 2 1 3 5 2 7 6 6 2 2 1 1 2 1 4 1 2 1 2 2 5 1 8 8 8 2 2 4 8 1 8 4 1 1 5 5 9 9 2 6 4 7 2 5 3 7 6 7 10 9 9 1 2 5 8 5 7 1 1 8 10 2 6 7 9 5 2 10 6\n",
"45 9343\n36 16 13 20 48 5 45 48 54 16 42 40 66 31 18 59 24 66 72 32 65 54 55 7... | {
"input": [
"3 4\n1 1 1\n",
"3 6\n1 1 1\n"
],
"output": [
"2\n",
"3\n"
]
} | {
"input": [],
"output": []
} |
63_E. Sweets Game | Karlsson has visited Lillebror again. They found a box of chocolates and a big whipped cream cake at Lillebror's place. Karlsson immediately suggested to divide the sweets fairly between Lillebror and himself. Specifically, to play together a game he has just invented with the chocolates. The winner will get the cake a... | {
"input": [
"O O .\n O O . .\n. . . . .\n . . . .\n . O .\n",
". . O\n . O O .\nO . O . O\n O O O O\n . . O\n",
". . .\n . O . .\n. O O . .\n . . O .\n . O .\n",
"O O O\n O O . O\nO . O O O\n O . O O\n O O .\n",
"O O O\n O O . O\nO . O O O\n O O O O\n . O O\n",
"O O O\n O . O .\nO . . O ... | {
"input": [
". . .\n . . . O\n. . . O .\n O . O .\n . O .\n",
". . .\n . . O .\n. . O O .\n . . . .\n . . .\n"
],
"output": [
"Karlsson\n",
"Lillebror\n"
]
} | {
"input": [],
"output": []
} |
eggs-and-building | You are given 'k' eggs and a 'n' storey building. The eggs MIGHT break if thrown down from a specific height (Note: It is NOT necessary that the eggs have to break; they might not even break from the topmost floor). What is the minimum number of steps in which you can find (using 'k' eggs) the minimum height of the flo... | {
"input": [
"10\n42 8\n335 1\n170 5\n479 9\n963 5\n706 6\n282 8\n962 2\n996 3\n828 7"
],
"output": [
"6\n335\n8\n9\n11\n10\n9\n44\n19\n10"
]
} | {
"input": [
"4\n10 1\n10 2\n100 2\n104 3\n\nSAMPLE"
],
"output": [
"10\n4\n14\n9"
]
} | {
"input": [],
"output": []
} |
p01567 Presentation | You are a researcher investigating algorithms on binary trees. Binary tree is a data structure composed of branch nodes and leaf nodes. Every branch nodes have left child and right child, and each child is either a branch node or a leaf node. The root of a binary tree is the branch node which has no parent.
You are pr... | {
"input": [],
"output": []
} | {
"input": [
"((()(()()))((()(()()))()))",
"(()())",
"(((()())(()()))(()()))",
"((()())(((()())(()()))()))"
],
"output": [
"3",
"0",
"4",
"3"
]
} | {
"input": [],
"output": []
} |
etmx07 | Mirrored Strings
Davy Jones needs to conquer a ship for his pirates. But the only rule he has to follow is to conquer only those ships whose names are partially mirrored at the end.
For Example: If a ship's name is 'abxyzba' then he can conquer the ship because the string has mirrored string at the beginning and at th... | {
"input": [],
"output": []
} | {
"input": [
"abXYZba",
"codechefdoc"
],
"output": [
"ab",
"cod"
]
} | {
"input": [],
"output": []
} |
pcsc7 | Yesterday, the CS Club hosted a massive party that put all the frat parties to shame. Today, they have to clean up everything. They also have to restock the strategic supply of Mountain Dew. Phillip hates cleaning and wants to pick up the dew instead. He knows that they intend to distribute the chores by having eve... | {
"input": [],
"output": []
} | {
"input": [
"41 3"
],
"output": [
"31"
]
} | {
"input": [],
"output": []
} |
180_F. Mathematical Analysis Rocks! | Students of group 199 have written their lectures dismally. Now an exam on Mathematical Analysis is approaching and something has to be done asap (that is, quickly). Let's number the students of the group from 1 to n. Each student i (1 ≤ i ≤ n) has a best friend p[i] (1 ≤ p[i] ≤ n). In fact, each student is a best frie... | {
"input": [
"3\n1 2 3\n2 1 3\n",
"10\n9 10 6 8 5 3 1 7 4 2\n7 6 2 9 5 10 8 4 1 3\n",
"3\n2 3 1\n1 2 3\n",
"10\n2 9 1 7 6 8 5 4 10 3\n6 8 5 1 9 10 2 3 4 7\n",
"2\n1 2\n1 2\n",
"5\n4 1 2 5 3\n2 3 5 1 4\n",
"1\n1\n1\n",
"4\n1 2 3 4\n2 1 4 3\n",
"10\n5 9 7 1 4 10 3 6 2 8\n8 3 9 10 6 5... | {
"input": [
"4\n2 1 4 3\n3 4 2 1\n",
"5\n5 2 3 1 4\n1 3 2 4 5\n",
"2\n1 2\n2 1\n"
],
"output": [
"4 3 1 2 ",
"4 3 2 5 1 ",
"2 1 "
]
} | {
"input": [],
"output": []
} |
p02071 Consistent Trading | Problem Statement
Your company is developing a video game. In this game, players can exchange items. This trading follows the rule set by the developers. The rule is defined as the following format: "Players can exchange one item $A_i$ and $x_i$ item $B_i$". Note that the trading can be done in both directions. Items ... | {
"input": [],
"output": []
} | {
"input": [
""
],
"output": [
""
]
} | {
"input": [],
"output": []
} |
100_G. Name the album | The famous singer, Aryo, is going to publish a new album of his great work!
Unfortunately these days, there are many albums, Aryo wants to choose a new name for his album, a name that has not been used or at least has not been used recently.
He has a list of all used album names together with the year the albums were... | {
"input": [],
"output": []
} | {
"input": [
"3\neyesonme 2008\nanewdayhascome 2002\noneheart 2003\n2\noneheart\nbienbien\n",
"2\nnasimevasl 2003\nbasetareha 2006\n2\nnasimevasl\nbasetareha\n"
],
"output": [
"bienbien\n",
"nasimevasl\n"
]
} | {
"input": [],
"output": []
} |
130_B. Gnikool Ssalg | You are given a string. Reverse its characters.
Input
The only line of input contains a string between 1 and 100 characters long. Each character of the string has ASCII-code between 33 (exclamation mark) and 126 (tilde), inclusive.
Output
Output the characters of this string in reverse order.
Examples
Input
secr... | {
"input": [],
"output": []
} | {
"input": [
"secrofedoc\n",
"!ssalg-gnikool5\n"
],
"output": [
"codeforces\n",
"5looking-glass!\n"
]
} | {
"input": [],
"output": []
} |
683_D. Chocolate Bar | A chocolate bar has a rectangular shape and consists of n × m slices. In other words, a bar consists of n rows with m slices of chocolate in each row.
Each slice of chocolate is known to weigh 1 gram. Your task is to determine for each of the q chocolate bars whether it is possible to obtain a piece weighing p grams b... | {
"input": [],
"output": []
} | {
"input": [
"2\n3 3 4\n4 4 7\n"
],
"output": [
"Yes\nNo\n"
]
} | {
"input": [],
"output": []
} |
calculate-lcm | Given A and B, compute the sum of lcm(a, b) over all pairs of positive integers a and b such that:
(1) a ≤ A and b ≤ B.
(2) There is no integer n>1 such that n^2 divides both a and b.
Give your answer modulo 2^30.
INPUT
The first line contains the number of test cases, t (about 200). Each of the next t lines conta... | {
"input": [
"4\n2 4\n3 3\n6 5\n8 3"
],
"output": [
"24\n28\n233\n178"
]
} | {
"input": [
"4\n2 4\n3 3\n6 5\n8 3\n\nSAMPLE"
],
"output": [
"24\n28\n233\n178"
]
} | {
"input": [],
"output": []
} |
decreasing-paths | See Russian Translation
The end semester exams are now approaching. Ritu is the Computer Science Teacher of Coder Public School. He has been assigned the task of preparing good algorithmic problems for the students by the Dean of the school.
Ritu like every other teacher has his own favorite topics. Ritu likes matri... | {
"input": [],
"output": []
} | {
"input": [
"2\n1 2\n1 3\n\nSAMPLE"
],
"output": [
"8"
]
} | {
"input": [],
"output": []
} |
string-partition | Rahul is a young chap who loves strings but simply hates mathematics. While his friend Ramesh is in love with mathematics but hates strings. So their teacher decided to take a test which combined both these topics so that neither of them gets a better hand over the other.
Their teacher gave both of them a single strin... | {
"input": [
"10\n73 22415\n5167001431772738714943016657313619461697024695206334583232984849497149963984666528646988293846969134\n95 24330\n3380367895024662360910370429257567614375653719389172618596672189298215470583577349776246856624447646\n73 18716\n08755348956908383925473548214201655067434087162868634878457598... | {
"input": [
"2\n1 6\n30901\n2 85\n07565\n\nSAMPLE"
],
"output": [
"-1\n140"
]
} | {
"input": [],
"output": []
} |
1170_F. Wheels | Polycarp has n wheels and a car with m slots for wheels. The initial pressure in the i-th wheel is a_i.
Polycarp's goal is to take exactly m wheels among the given n wheels and equalize the pressure in them (then he can put these wheels in a car and use it for driving). In one minute he can decrease or increase the pr... | {
"input": [],
"output": []
} | {
"input": [
"6 6 7\n6 15 16 20 1 5\n",
"6 3 1\n4 8 15 16 23 42\n",
"5 4 0\n5 5 5 4 5\n"
],
"output": [
"\n39\n",
"\n8\n",
"\n0\n"
]
} | {
"input": [],
"output": []
} |
1250_C. Trip to Saint Petersburg | You are planning your trip to Saint Petersburg. After doing some calculations, you estimated that you will have to spend k rubles each day you stay in Saint Petersburg — you have to rent a flat, to eat at some local cafe, et cetera. So, if the day of your arrival is L, and the day of your departure is R, you will have ... | {
"input": [],
"output": []
} | {
"input": [
"4 5\n1 1 3\n3 3 11\n5 5 17\n7 7 4\n",
"1 3\n1 2 5\n",
"4 8\n1 5 16\n2 4 9\n3 3 24\n1 5 13\n"
],
"output": [
"\n13 3 5 2\n3 2 \n",
"\n0\n",
"\n22 1 5 4\n3 2 1 4 \n"
]
} | {
"input": [],
"output": []
} |
188_H. Stack | In this problem we'll use a stack which supports two types of operations:
* Push a given number on the stack.
* Pop two numbers from the stack, perform a given operation (addition or multiplication) on them and push the result on the stack.
You are given a string which describes the sequence of operations to ... | {
"input": [],
"output": []
} | {
"input": [
"12+3*66*+\n",
"149\n"
],
"output": [
"45\n",
"9\n"
]
} | {
"input": [],
"output": []
} |
470_G. Hamming Distance | Hamming distance between two strings of equal length is the number of positions at which the corresponding symbols are different. You are given two strings; calculate the distance between them.
Input
The input consists of two lines. Each line contains a string of characters 'A'-'Z' between 1 and 100 characters, inclu... | {
"input": [],
"output": []
} | {
"input": [
"CODECHEF\nTOPCODER\n",
"HAMMING\nDISTANC\n"
],
"output": [
"6\n",
"6\n"
]
} | {
"input": [],
"output": []
} |
aprileasy-easy-non-linear-recurrences | You are given the following recurrences,
F(n) = a * F(n - 1) * G(n - 2) + b * G(n - 1) * F(n - 2) for n ≥ 2
G(n) = c * G(n - 1) * F(n - 2) + d * (3 ^ F(n - 1) ) for n ≥2
H(n) = e * F(n) + f * G(n) for n ≥ 0
F[0] = F[1] = G[0] = 0
G[1] = 1
Input
First line contains the following 6 numbers in order : a, b, c, d, ... | {
"input": [],
"output": []
} | {
"input": [
"1 2 3 4 5 6\n2\n2 \n3\n\nSAMPLE"
],
"output": [
"30\n54"
]
} | {
"input": [],
"output": []
} |
sabotage-1 | See Russian Translation
ZYX is a famous international-level linguistics and informatics competitor. He is the favorite to win this year's IOI competition.
Fifiman, another great coder in his own right, known as the "King of Algorithms", was unfortunately overshadowed by ZYX's outstanding ability many times in various... | {
"input": [
"1000 999\n598 312\n598 989\n598 253\n598 588\n598 888\n598 904\n598 563\n598 998\n598 478\n598 252\n598 737\n598 52\n598 268\n598 666\n598 162\n598 599\n598 275\n598 451\n598 620\n598 254\n598 102\n598 506\n598 692\n598 18\n598 765\n598 554\n598 614\n598 426\n598 937\n598 762\n598 410\n598 79\n598 9... | {
"input": [
"3 4\n2 1\n1 2\n2 3\n3 1\n\nSAMPLE"
],
"output": [
"2\n1\n2"
]
} | {
"input": [],
"output": []
} |
p00036 A Figure on Surface | There is a plane like Figure 1 with 8 vertical and 8 horizontal squares.
□ | □ | □ | □ | □ | □ | □ | □
--- | --- | --- | --- | --- | --- | --- | ---
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □ | □ | □
□ | □ | □ | □ | □ | □... | {
"input": [],
"output": []
} | {
"input": [
"00000000\n00000000\n01100000\n00110000\n00000000\n00000000\n00000000\n00000000\n\n00011110\n00000000\n00000000\n00000000\n00000000\n00000000\n00000000\n00000000\n\n00000000\n00000000\n00110000\n00110000\n00000000\n00000000\n00000000\n00000000"
],
"output": [
"E\nC\nA"
]
} | {
"input": [],
"output": []
} |
p00681 Wall Breaker KND | Problem
KND is a student programmer at the University of Aizu. He is both a programmer and a fighter. He is known to be a sweet tooth, but he especially likes fresh cream. Eating fresh cream will allow you to break the concrete wall several times. Interested in its power, his neighbor decided to experiment with a new ... | {
"input": [],
"output": []
} | {
"input": [
"3 3\n0 0\n0 0 0\n0 0\n0 0 1\n0 1\n0 0\n0 1\n1 1\n2 2\n1\n5 5\n0 1 0 0\n1 0 0 1 0\n1 0 1 0\n0 1 0 0 1\n0 1 1 0\n0 1 0 1 0\n1 1 1 0\n0 0 0 0 0\n0 0 1 1\n0 0\n1 0\n4 4\n0 1\n2\n0 0",
"3 3\n 0 0\n0 0 0\n 0 0\n0 0 1\n 0 1\n0 0\n0 1\n1 1\n2 2\n1\n5 5\n 0 1 0 0\n1 0 0 1 0\n 1 0 1 0\n0 1 0 0 1\n 0 1 1 0... | {
"input": [],
"output": []
} |
cr07 | POINTS - 25
Sahil is very fond of drinking juice. Every morning he drinks one full bottle of Juice. In every 'm' days, his mother buys one more bottle of juice ( i.e. on day m, 2m, 3m). She buys it in the evening. If Sahil initially has 'n' bottles of juice calculate the number of consecutive days that pass before he r... | {
"input": [],
"output": []
} | {
"input": [
"9 3",
"2 2"
],
"output": [
"13",
"3"
]
} | {
"input": [],
"output": []
} |
tos03 | You all must know Walter White, from Breaking Bad who created the world’s purest crystal meth.
As he is a school teacher, he has to attend school regularly. But Walter does not want to go to school, rather he wants to stay home and create new kinds of drugs.
In the office where Walter works, has two guards who count ho... | {
"input": [],
"output": []
} | {
"input": [
"1\n15 28"
],
"output": [
"28 43"
]
} | {
"input": [],
"output": []
} |
1250_N. Wires | Polycarpus has a complex electronic device. The core of this device is a circuit board. The board has 10^9 contact points which are numbered from 1 to 10^9. Also there are n wires numbered from 1 to n, each connecting two distinct contact points on the board. An electric signal can pass between wires A and B if:
* ... | {
"input": [],
"output": []
} | {
"input": [
"2\n1\n4 7\n4\n1 2\n2 3\n4 5\n5 6\n"
],
"output": [
"\n0\n1\n2 3 5\n"
]
} | {
"input": [],
"output": []
} |
prime-equation | Recently Akash got this equation. Now being curious he wanted to know that for a given N , is it possible to find P1, P2, P3 and P4 for below equation under following conditions.
( P1-P2 ) + ( P3 - P4 ) = N
P1, P2, P3, P4 are prime numbers
P1 and P2 are consecutive Primes and P1 > P2
P3 and P4 are consecutive Primes ... | {
"input": [
"100\n26\n277\n995\n718\n754\n425\n101\n235\n591\n659\n441\n125\n394\n176\n627\n780\n192\n944\n241\n628\n140\n974\n178\n239\n185\n440\n946\n794\n389\n121\n269\n955\n947\n725\n497\n513\n959\n613\n657\n564\n455\n196\n72\n439\n248\n712\n403\n436\n743\n885\n42\n358\n970\n151\n248\n516\n973\n366\n480\n429... | {
"input": [
"5\n4\n15\n30\n100\n1000\n\nSAMPLE"
],
"output": [
"YES\nNO\nYES\nYES\nNO"
]
} | {
"input": [],
"output": []
} |
bao | Problem description
John and Dave are two close friends. One day John bluffs to Dave that in past some weeks he has learnt to program using any programming languages. Dave started laughing wildly on John but John insisted that he can really do programming. Then Dave decided to test John programming skills by giving him... | {
"input": [],
"output": []
} | {
"input": [
"2\n2 12\n+5\n * 2 \n2 2.13\n+ 0.2\n/ 2"
],
"output": [
"34.00\n1.17"
]
} | {
"input": [],
"output": []
} |
130_H. Balanced brackets | A sequence of brackets is called balanced if one can turn it into a valid math expression by adding characters «+» and «1». For example, sequences «(())()», «()» and «(()(()))» are balanced, while «)(», «(()» and «(()))(» are not.
You are given a string which consists of opening and closing round brackets. Check wheth... | {
"input": [],
"output": []
} | {
"input": [
"(()(()))()\n",
"())()\n"
],
"output": [
"YES\n",
"NO\n"
]
} | {
"input": [],
"output": []
} |
683_J. The Hero with Bombs | In a new computer game you need to help the hero to get out of the maze, which is a rectangular field of size n × m. The hero is located in one of the cells of this field. He knows where the exit of the maze is, and he wants to reach it.
In one move, the hero can either move to the next cell (i.e. the cell which has a... | {
"input": [],
"output": []
} | {
"input": [
"3 5\nXEX.X\nX.XXT\nX.X.X\n"
],
"output": [
"SSMNNTSSNEMWWTEEEE\n"
]
} | {
"input": [],
"output": []
} |
72_E. Ali goes shopping | Ali Koochooloo is going to buy new clothes since we're reaching Noruz, the ancient Persian festival and the beginning of new Persian year.
When Ali entered a shop, he saw that the shopkeeper was a programmer and since there is no money in programming he had changed his career. The shopkeeper told Ali that he can buy a... | {
"input": [],
"output": []
} | {
"input": [
"abab\n",
"abcd\n"
],
"output": [
"ab\n",
"abcd\n"
]
} | {
"input": [],
"output": []
} |
people-circle | There are M males and F females arranged in a circle. Starting from a given point, you count clockwise and remove the K'th person from the circle (where K=1 is the person at the current point, K=2 is the next person in the clockwise direction, etc...). After removing that person, the next person in the clockwise direct... | {
"input": [
"35\n5 3 2\n7 3 1\n25 25 1000\n4 1 7\n3 2 7\n5 1 6\n20 25 45\n7 3 10\n0 2 1000\n2 0 999\n0 0 998\n5 5 3\n0 1 23\n1 0 245\n1 1 1\n1 1 5\n25 0 1000\n25 25 999\n1 25 10\n1 25 1000\n14 14 32\n17 19 111\n5 5 3\n25 25 1000\n3 3 100\n5 5 15\n5 5 37\n0 1 1\n5 5 30\n0 0 1000\n2 0 2\n0 1 2\n5 4 100\n0 0 1\n25 ... | {
"input": [
"3\n5 3 2\n1 0 245\n5 5 3\n\nSAMPLE"
],
"output": [
"MFMFMFMM\nM\nMFFMMFFMFM"
]
} | {
"input": [],
"output": []
} |
p01509 Play in Basic | One sunny day, Dick T. Mustang found an ancient personal computer in the closet. He brought it back to his room and turned it on with a sense of nostalgia, seeing a message coming on the screen:
READY?
Yes. BASIC.
BASIC is a programming language designed for beginners, and was widely used from 1980's to 1990's. Th... | {
"input": [],
"output": []
} | {
"input": [
"C4C4G4G4A4A4G2F4F4E4E4D4D4C2\nO4C4.C8F4.F8G8F8E8D8C2\nB-8>C8<B-8V40R2R..R8.V100EV50L1CG\n*"
],
"output": [
"Case 1: CCGGAAG2FFEEDDC2\nCase 2: C.C8F.L8FGFEDC2\nCase 3: L8B-B+B-RL1RE4V50CG"
]
} | {
"input": [],
"output": []
} |
p01959 Revenge of the Broken Door | The JAG Kingdom consists of $N$ cities and $M$ bidirectional roads. The $i$-th road ($u_i, v_i, c_i$) connects the city $u_i$ and the city $v_i$ with the length $c_i$. One day, you, a citizen of the JAG Kingdom, decided to go to the city $T$ from the city $S$. However, you know that one of the roads in the JAG Kingdom ... | {
"input": [],
"output": []
} | {
"input": [
"3 3 1 3\n1 2 1\n2 3 5\n1 3 3",
"4 4 1 4\n1 2 1\n2 4 1\n1 3 1\n3 4 1",
"5 4 4 1\n1 2 3\n2 3 4\n3 4 5\n4 5 6"
],
"output": [
"6",
"4",
"-1"
]
} | {
"input": [],
"output": []
} |
rbx12r02 | In a museum there is an empty wall. We can imagine this wall as a triangle on a coordinate plane with vertices (0; 0), (N; 0), (N; N * A / B), where N, A, B are some positive integers.
The space has been allotted to a photographer who wants his masterpiece on that wall. He is confused with the size of the photo frame ... | {
"input": [],
"output": []
} | {
"input": [
"2\n4 2 3\n4 5 4"
],
"output": [
"5\n15"
]
} | {
"input": [],
"output": []
} |
1190_F. Tokitsukaze and Powers | Tokitsukaze is playing a room escape game designed by SkywalkerT. In this game, she needs to find out hidden clues in the room to reveal a way to escape.
After a while, she realizes that the only way to run away is to open the digital door lock since she accidentally went into a secret compartment and found some clues... | {
"input": [
"8192 32768 31989\n",
"35666 4096 1797\n",
"2 8 3\n",
"6 81 53\n",
"355942 531441 531440\n",
"8 32 21\n",
"500000 524288 262143\n",
"494818 1048576 669025\n",
"1 4 3\n",
"499498 189806938203161161 63924242761815544\n",
"487450 9765625 6870467\n",
"256 1024 ... | {
"input": [
"4 9 8\n",
"3 5 1\n",
"1 2 1\n",
"2 5 4\n"
],
"output": [
"2 4 5 7 ",
"2 3 4 ",
"-1\n",
"2 3 "
]
} | {
"input": [],
"output": []
} |
802_F. Marmots (hard) | Your task is the exact same as for the easy version. But this time, the marmots subtract the village's population P from their random number before responding to Heidi's request.
Also, there are now villages with as few as a single inhabitant, meaning that <image>.
Can you help Heidi find out whether a village follow... | {
"input": [],
"output": []
} | {
"input": [],
"output": []
} | {
"input": [],
"output": []
} |
mystery | Problem Statement :
Solve the Mystery. :)
Input
First line of input contains T – No of test cases.(1 ≤ T ≤ 21)
Next T lines of input contains three integers a,b,c separated by spaces.
(1 ≤ a,b ≤ 20) (1 ≤ c ≤ 100)
Output
T lines should contain a single integer.
SAMPLE INPUT
3
2 3 2
13 14 1
14 5 9
SAMPLE OUTPUT
5
... | {
"input": [
"30\n1 1 50\n20 20 70\n10 12 40\n20 20 50\n2 3 2\n13 14 1\n14 5 9\n17 18 3\n1 1 1\n4 6 7\n1 1 20\n20 20 1\n20 20 20\n12 9 18\n1 19 15\n5 5 5\n10 11 12\n3 7 17\n8 2 9\n1 1 50\n18 19 80\n1 2 2\n1 2 3\n2 3 4\n4 5 6\n7 8 9\n10 11 12\n13 14 15\n16 17 18\n19 20 21"
],
"output": [
"20365011074\n6161... | {
"input": [
"3\n2 3 2\n13 14 1\n14 5 9\n\nSAMPLE"
],
"output": [
"5\n14\n464"
]
} | {
"input": [],
"output": []
} |
sansas-escape | As you all know, Sansa is trying to escape from the Boltons' specially from Ramsey!
Winterfell is divided in an straight line of ice. In the line, each block has some thickness value. Ramsey would catch Sansa and Theon in an interval of ice if the XOR of all thickness of ice in that interval is greater than some valu... | {
"input": [],
"output": []
} | {
"input": [
"10\n1 2 3 4 5 6 24 8 9 10\n2\n2 4\n0 2\n\nSAMPLE"
],
"output": [
"2\n0"
]
} | {
"input": [],
"output": []
} |
prmarth | Children are taught to add multi-digit numbers from right to left, one digit at a time.
Many find the “carry” operation, where a 1 is carried from one digit position to the
next, to be a significant challenge. Your job is to count the number of carry operations for each of a set of addition problems so that educators m... | {
"input": [],
"output": []
} | {
"input": [
"123 456\n555 555\n123 594\n0 0"
],
"output": [
"No carry operation.\n3 carry operations.\n1 carry operation."
]
} | {
"input": [],
"output": []
} |
tcfst05 | You always wanted to be a soldier and play it out at the battleground live. When you came at Techfest 2013, you encountered Lazer Tag, a game that satiated your innate hunger for taking aim and shooting enemies.
Lazer Tag consists of a group play, where you are assigned a fixed number of bullets (popularly known as La... | {
"input": [],
"output": []
} | {
"input": [
"4\n0.6 0.5 0.8 0.2",
"3\n1 1 1"
],
"output": [
"4.556000",
"9.000000"
]
} | {
"input": [],
"output": []
} |
153_A. A + B | You are given two integers A and B. Calculate their sum and output it without leading zeros.
Input
Two lines of input data contain integers A and B (1 ≤ A, B ≤ 105).
Output
Output A + B without leading zeros.
Examples
Input
12
3
Output
15
Input
100
5
Output
105
Note
The code provided in the post about... | {
"input": [],
"output": []
} | {
"input": [
"12\n3\n",
"100\n5\n"
],
"output": [
"15\n",
"105\n"
]
} | {
"input": [],
"output": []
} |
234_A. Lefthanders and Righthanders | One fine October day a mathematics teacher Vasily Petrov went to a class and saw there n pupils who sat at the <image> desks, two people at each desk. Vasily quickly realized that number n is even. Like all true mathematicians, Vasily has all students numbered from 1 to n.
But Vasily Petrov did not like the way the ch... | {
"input": [
"42\nRLRRLLLLLLLRRRLRLLLRRRLRLLLRLRLRLLLRLRLRRR\n",
"100\nLRLLLLRLLLLRRRRRLRRRRLRRLRRLRLLRRLRRRRLLRRRLLLRLLLRRRRLLRLRLRRLRLLRRLLRRLRRLRRRRRLRRLRLRLRLLLLLLLLRL\n",
"36\nRRLLLRRRLLLRRLLLRRLLRLLRLRLLRLRLRLLL\n",
"86\nRRRLLLRLLRLLRLRLRLLLRLRLRRLLRLLLRLLLLLLRRRLRLLRLLLRRRLRLLLLRLLRLRRLLRLLLRRR... | {
"input": [
"4\nRRLL\n",
"6\nLLRLLL\n"
],
"output": [
"3 1\n4 2\n",
"1 4\n2 5\n6 3\n"
]
} | {
"input": [],
"output": []
} |
448_E. Divisors | Bizon the Champion isn't just friendly, he also is a rigorous coder.
Let's define function f(a), where a is a sequence of integers. Function f(a) returns the following sequence: first all divisors of a1 go in the increasing order, then all divisors of a2 go in the increasing order, and so on till the last element of s... | {
"input": [
"963761198400 1\n",
"89 4\n",
"16 10\n",
"1000000000000 0\n",
"956722026041 10\n",
"458760294782 5\n",
"83 3\n",
"95 5\n",
"89 5\n",
"252935271071 2\n",
"79 1\n",
"1 1000000000000000000\n",
"10 0\n",
"571312007450 10\n",
"85 7\n",
"911780559... | {
"input": [
"10 3\n",
"6 1\n",
"4 2\n"
],
"output": [
" 1 1 1 ... | {
"input": [],
"output": []
} |
661_G. Hungarian Notation | In Hungarian notation, a variable name is prefixed with a letter or a group of letters which are mnemonics for the type of that variable. For the purposes of this problem we will consider only two data types: integer and real.
You are given the meaningful part of variable name in lowercase and a sample value that it w... | {
"input": [],
"output": []
} | {
"input": [
"count\n18\n",
"weight\n3.95\n"
],
"output": [
"iCount\n",
"fWeight\n"
]
} | {
"input": [],
"output": []
} |
challenge-question-destruction | Problem :
Osama is planning a massive attack on a country which comprises of 10 states. The map of this country is shown in the figure below :
He has a good reach in all these states and he plans to attack the country through missiles. Every state has a missile launcher and hundreds of missiles. The missiles are desi... | {
"input": [
"7 10 6 5 1 9 4 8 2 3"
],
"output": [
"1 8 7 5 4 3 6 9 2"
]
} | {
"input": [],
"output": []
} | {
"input": [],
"output": []
} |
pink-and-blue | Xenny was a teacher and he had N students. The N children were sitting in a room. Each child was wearing a white T-shirt, with a unique number from the range 1 to N written on it. T-Shirts of pink and blue color were to be distributed among the students by Xenny. This made the students very happy.
Xenny felt that a ra... | {
"input": [],
"output": []
} | {
"input": [
"3 2\nB G B\n1 2\n1 3\n\nSAMPLE"
],
"output": [
"1"
]
} | {
"input": [],
"output": []
} |
1302_C. Segment tree or Fenwick? | This is an unusual problem in an unusual contest, here is the announcement: [http://codeforces.com/blog/entry/73543](//codeforces.com/blog/entry/73543)
You are given an array A of length n, initially filled with zeros. You need to process q queries to the array, each of one of the following types:
1. 1 x y: you ne... | {
"input": [],
"output": []
} | {
"input": [
"2\n6 5\n2 1 6\n1 3 2\n2 2 4\n1 6 3\n2 1 6\n5 3\n1 3 7\n1 1 4\n2 1 5\n"
],
"output": [
"\n0\n2\n5\n11\n"
]
} | {
"input": [],
"output": []
} |
smallest-positive-integer | Given a number X between 0 to 1000000006 find smallest positive integer Y such that the products of digits of Y modulo 1000000007 is X.
Input Format
A single integer - X
Output Format
A single integer - Y
Input Constraint
0 ≤ X ≤ 1000000006
Problem Setter: Practo Tech Team
SAMPLE INPUT
16
SAMPLE OUTPUT
28
Exp... | {
"input": [
"16",
"0",
"220703118"
],
"output": [
"28",
"10",
"5555555555555"
]
} | {
"input": [],
"output": []
} | {
"input": [],
"output": []
} |
chcube | One day, Chef found a cube which has each of its sides painted in some color out of black, blue, red, green, yellow and orange.
Now he asks you to check if he can choose three sides such that they are pairwise adjacent and painted in the same color.
Input
The first line of the input contains an integer T denoting the... | {
"input": [],
"output": []
} | {
"input": [
"2\nblue yellow green orange black green\ngreen yellow green orange black green"
],
"output": [
"NO\nYES\n"
]
} | {
"input": [],
"output": []
} |
iitk2p06 | You are given e even and o odd numbers. In a single operation, you change an even to odd number or vice versa. Find out min number of operations needed to
do such that ratio of even to odd numbers becomes 2 : 3. If it is impossible to do so, output -1.
Input
The first line of the input contains an integer T denoting... | {
"input": [],
"output": []
} | {
"input": [
"3\n2 3\n3 2\n3 3"
],
"output": [
"0\n1\n-1"
]
} | {
"input": [],
"output": []
} |
saarc05 | Problem description.
Most campuses have a lot of named buildings, and as the names tend to be rather long, the class schedules
have abbreviations. At IITD, it seems that the abbreviations have become used so widely that most people
don’t even remember the full name of the building, such as SAC. To a newcomer, this can... | {
"input": [],
"output": []
} | {
"input": [
"2\n2\nSaLvatori\nScience LibrarieS\nSSL\n3\nstudENt aeRoSpace laBoratory\nsalVAtori\nangeles\nSAL"
],
"output": [
"Data Set 1:\nData Set 2:\nstudENt aeRoSpace laBoratory\nsalVAtori"
]
} | {
"input": [],
"output": []
} |
cccs3 | There is an infinite binary tree which has following structure:
3
/ \
6 8
/ \ / \
11 13 15 ... | {
"input": [],
"output": []
} | {
"input": [
"3\n39\n16\n70"
],
"output": [
"RIGHT\nNO\nLEFT"
]
} | {
"input": [],
"output": []
} |
repub | On the occasion of 66^th Republic day, a young lad, Lemon Kumar (a.k.a Yaar Kumar), is revising his speech again and again to remember it. He found that some of the letters in his
speech is repeated quite often. Being very fond of programming, like the Chef, he took it as a challenge and decided to find this letter. He... | {
"input": [],
"output": []
} | {
"input": [
"1\nHappy Republic Day!!!"
],
"output": [
"p"
]
} | {
"input": [],
"output": []
} |
1252_F. Regular Forestation | A forestation is an act of planting a bunch of trees to grow a forest, usually to replace a forest that had been cut down. Strangely enough, graph theorists have another idea on how to make a forest, i.e. by cutting down a tree!
A tree is a graph of N nodes connected by N - 1 edges. Let u be a node in a tree U which d... | {
"input": [],
"output": []
} | {
"input": [
"13\n1 5\n1 7\n2 4\n2 8\n2 11\n3 12\n4 7\n4 12\n6 11\n7 13\n9 10\n9 12\n",
"6\n1 2\n1 3\n2 4\n3 5\n3 6\n"
],
"output": [
"\n3\n",
"\n-1\n"
]
} | {
"input": [],
"output": []
} |
chotu-and-kiss-day | "It all started with a kiss."
Chotu was up all night, planning for his first kiss. He has collected the data about all the kissing spots in Allahabad.
According to his survey there are N kissing spots in the city, each spot i is associated with a security value Si.
Chotu wants to visit as many spot as they can, but un... | {
"input": [
"2000\n308095650 7015368 43054200 326309191 23209200 4883080 31325775 4954880 6043960 52877600 202701312 22446666 91397680 28954100 31881696 176322380 1612026 15343944 145463040 78135876 676266 3184200 29508160 68274580 3821337 153607104 6235464 34886318 60666580 826848 31596240 47719440 23549760 555... | {
"input": [
"6\n1 5 4 7 8 9\n17\n\nSAMPLE"
],
"output": [
"YES"
]
} | {
"input": [],
"output": []
} |
easy-strong-permutation | Kevin has a sequence of integers a1, a2, ..., an. Define the strength of the sequence to be
|a1 - a2| + |a2 - a3| + ... + |an-1 - an| + |an - a1|.
Kevin wants to make his sequence stronger, so he reorders his sequence into a new sequence b1, b2, ..., bn. He wants this new sequence to be as strong as possible. What is... | {
"input": [],
"output": []
} | {
"input": [
"4\n1 2 4 8\n\nSAMPLE"
],
"output": [
"18"
]
} | {
"input": [],
"output": []
} |
harry-the-mathemagician-2 | Hermione is very good in Magic but she is not good enough in Mathematics. She got stuck in a problem of mathematics in which she has to find out whether a combination M objects out of N is even or odd.
Harry is quite good in mathematics so Hermione goes to get the help from Harry.
Input:
You have T number of test ca... | {
"input": [
"3040\n35 12\n5656 3334\n26 0\n22 3\n1882 388\n4444 222\n2772 666\n882 77\n2888 902\n7888881 99223\n8892 81\n299 9\n2899 902\n827 91\n19998 2233\n288 22\n5652 552\n998 223\n7839 5522\n8782 883\n828 298\n9829 982\n8727 1\n8792 2\n8763 3\n8782799 4\n277836 77777\n8728 878\n87827 882\n2882889 99999\n677... | {
"input": [
"2\n10 5\n4 2\n\nSAMPLE"
],
"output": [
"even\neven"
]
} | {
"input": [],
"output": []
} |
chn15b | Petr is organizing Petr Mitrichev Contest #11. The top N coders according to codechef ratings (excluding Petr himself) agreed to participate in the contest. The participants have been ranked from 0 to N-1 according to their ratings. Petr had asked each participant to choose a coder with rating higher than himself/ hers... | {
"input": [],
"output": []
} | {
"input": [
"1\n5\n-1 -1 1 2 1"
],
"output": [
"1.5"
]
} | {
"input": [],
"output": []
} |
epi01 | This is the algorithmic version of a game that kids play in our part of the country. You will be provided with a few sticks. The length of the sticks will be in the order of powers of 2. (1,2,4,8,16,32....). You will also be given another test stick of any length. The task is to write a program that finds the minimum n... | {
"input": [],
"output": []
} | {
"input": [
"5"
],
"output": [
"2"
]
} | {
"input": [],
"output": []
} |
1095_C. Powers Of Two | A positive integer x is called a power of two if it can be represented as x = 2^y, where y is a non-negative integer. So, the powers of two are 1, 2, 4, 8, 16, ....
You are given two positive integers n and k. Your task is to represent n as the sum of exactly k powers of two.
Input
The only line of the input contain... | {
"input": [
"9 2\n",
"688 500\n",
"536870911 28\n",
"999999999 9586\n",
"655 647\n",
"88562726 66\n",
"8 7\n",
"1 1\n",
"698 698\n",
"697 301\n",
"10 3\n",
"5 4\n",
"6 4\n",
"536870912 1\n",
"536870911 27\n",
"504 91\n",
"610 601\n",
"2048 2\n",... | {
"input": [
"8 1\n",
"5 1\n",
"9 4\n",
"3 7\n"
],
"output": [
"YES\n8\n",
"NO\n",
"YES\n1 2 2 4\n",
"NO\n"
]
} | {
"input": [],
"output": []
} |
1346_G. Two IP Cameras | You have two IP cameras of the same model. Each camera can take photos starting from some moment of time with a fixed period. You can freely choose the starting moment but you can choose the period only as one of k values p_1, p_2, ..., p_k which are chosen by the camera's manufacturer.
You have n moments of interest ... | {
"input": [],
"output": []
} | {
"input": [
"3 5\n3 5 7\n1 4 5 7 12\n",
"3 2\n1 2 3\n1 10\n",
"3 4\n1 2 3\n5 7 9 11\n",
"3 4\n10 20 100\n2 3 4 7\n"
],
"output": [
"\nYES\n1 3\n5 7\n",
"\nYES\n1 1\n10 1\n",
"\nYES\n5 1\n5 1\n",
"\nNO\n"
]
} | {
"input": [],
"output": []
} |
1431_A. Selling Hamburgers | There are n customers in the cafeteria. Each of them wants to buy a hamburger. The i-th customer has a_i coins, and they will buy a hamburger if it costs at most a_i coins.
Suppose the cost of the hamburger is m. Then the number of coins the cafeteria earns is m multiplied by the number of people who buy a hamburger i... | {
"input": [],
"output": []
} | {
"input": [
"6\n3\n1 1 1\n3\n4 1 1\n3\n2 4 2\n8\n1 2 3 4 5 6 7 8\n1\n1000000000000\n3\n1000000000000 999999999999 1\n"
],
"output": [
"\n3\n4\n6\n20\n1000000000000\n1999999999998\n"
]
} | {
"input": [],
"output": []
} |
36_B. Fractal | Ever since Kalevitch, a famous Berland abstractionist, heard of fractals, he made them the main topic of his canvases. Every morning the artist takes a piece of graph paper and starts with making a model of his future canvas. He takes a square as big as n × n squares and paints some of them black. Then he takes a clean... | {
"input": [
"3 4\n*..\n*..\n*..\n",
"2 2\n*.\n*.\n",
"3 3\n*.*\n.*.\n..*\n",
"2 4\n**\n..\n",
"3 2\n...\n...\n...\n",
"2 5\n.*\n*.\n",
"3 4\n***\n*.*\n***\n",
"2 5\n.*\n*.\n",
"3 4\n***\n*.*\n***\n",
"2 2\n*.\n..\n",
"3 2\n..*\n***\n*..\n",
"2 5\n**\n*.\n",
"3 5\n.... | {
"input": [
"2 3\n.*\n..\n",
"3 2\n.*.\n***\n.*.\n"
],
"output": [
".*******\n..******\n.*.*****\n....****\n.***.***\n..**..**\n.*.*.*.*\n........\n",
".*.***.*.\n*********\n.*.***.*.\n*********\n*********\n*********\n.*.***.*.\n*********\n.*.***.*.\n"
]
} | {
"input": [],
"output": []
} |
bizzare-mishra | Mishra has gone bizarre these days. And therefore loves only bizzare patterns. Nowadays he has ran into a habit of not listening to many "yes" or "no" from people like Bansal. In fact he does not like strings having more than one "yes" or one "no" consecutively. Bansal sends him a string of length L containing only 'Y'... | {
"input": [],
"output": []
} | {
"input": [
"3\n2\nYY\n2\nYN\n5\nYYNNY\n\nSAMPLE"
],
"output": [
"1\n0\n2"
]
} | {
"input": [],
"output": []
} |
zeroes | Virat loves mathematical questions. The other day he came across an interesting question which required him to find out the number of trailing zeroes for the
function. F(n) = 1^1*2^2......N^N,where N is an integer. Virat solved the problem after a few attempts. He asked the same
question from his friend Rohit to see if... | {
"input": [],
"output": []
} | {
"input": [
"3\n5\n10\n2"
],
"output": [
"5\n15\n0"
]
} | {
"input": [],
"output": []
} |
mario-and-queen | Legends who were born in 90s remember Mario very well. As we all are aware of that fabulous video game our little Mario tackling with all the problems and barriers coming his way , he finally saves his Queen from the giant monster Dragon.
In this problem we let you play the game but with a little twist. The aim is sam... | {
"input": [],
"output": []
} | {
"input": [
"2\n3\n. . Q\n. . $\nM $ .\n3\nM . .\n$ $ .\nQ $ .\n\nSAMPLE"
],
"output": [
"Case 1: 2 < 2 3 4 5 >\nCase 2: -1"
]
} | {
"input": [],
"output": []
} |
p00599 Combinatorial Topology | It was long believed that a 2-dimensional place can not be filled with a finite set of polygons in aperiodic way. British mathematician, Sir Roger Penrose, developed an aperiodic tiling over the years and established a theory of what is known today as quasicrystals.
The classic Penrose tiles consist of two rhombi with... | {
"input": [],
"output": []
} | {
"input": [
"4\n-5.000000 0.000000\n5.000000 0.000000\n9.635255 14.265848\n-0.364745 14.265848\n3\n-1.000000 0.000000\n0.000000 0.000000\n0.000000 1.000000"
],
"output": [
"0 150\n-1 -1"
]
} | {
"input": [],
"output": []
} |
130_G. CAPS LOCK ON | You are given a string which consists of letters and other characters. Convert it to uppercase, i.e., replace all lowercase letters with corresponding uppercase ones. Keep the rest of characters unchanged.
Input
The only line of input contains a string between 1 and 100 characters long. Each character of the string h... | {
"input": [],
"output": []
} | {
"input": [
"cOdEfOrCeS\n",
"ulr#4:befunge-RULES!\n"
],
"output": [
"CODEFORCES\n",
"ULR#4:BEFUNGE-RULES!\n"
]
} | {
"input": [],
"output": []
} |
660_E. Different Subsets For All Tuples | For a sequence a of n integers between 1 and m, inclusive, denote f(a) as the number of distinct subsequences of a (including the empty subsequence).
You are given two positive integers n and m. Let S be the set of all sequences of length n consisting of numbers from 1 to m. Compute the sum f(a) over all a in S modulo... | {
"input": [
"500 500\n",
"1000000 1\n",
"1 1000000\n",
"1000000 1000000\n"
],
"output": [
"383255233\n",
"1000001\n",
"2000000\n",
"247171672\n"
]
} | {
"input": [
"2 2\n",
"1 3\n",
"3 3\n"
],
"output": [
"14\n",
"6\n",
"174\n"
]
} | {
"input": [],
"output": []
} |
683_I. Loader | A loader works in a warehouse, which is a rectangular field with size n × m. Some cells of this field are free, others are occupied by pillars on which the roof of the warehouse rests.
There is a load in one of the free cells, and the loader in another. At any moment, the loader and the load can not be in the cells w... | {
"input": [],
"output": []
} | {
"input": [
"3 3\n..Y\n.BX\n..T\n",
"3 3\n.BY\n...\nTXX\n"
],
"output": [
"YES\nwSwsE\n",
"NO\n"
]
} | {
"input": [],
"output": []
} |
72_D. Perse-script | Two good friends were trying to make a new programming language called Perse-script.
The most important part of this language is strings. A string in Perse-script is put between characters "
So for example "Hello" is a string. But Hello is a variable name or a keyword, which are not considered in this problem.
Perse... | {
"input": [],
"output": []
} | {
"input": [
"\"HelloWorld\"\n",
"REVerse(substr(\"helloworld\",1,5))\n",
"conCAT(rEveRSE(\"olleh\"),\"world\")\n",
"reversE(concAT(substr(\"hello\",1,2),sUbstr(\"world\",1,5,1)))\n",
"suBstr(\"Noruz\",1,4,2)\n"
],
"output": [
"\"HelloWorld\"\n",
"\"olleh\"\n",
"\"helloworld\"\n",
... | {
"input": [],
"output": []
} |
ambar-the-gardener-a-3 | Ambar is a gardener and have many water jugs in his garden.
The shape of water jug is a cone placed on the top of a cylinder (the radius and height of cylinder and cone and is "r").
There is a jug for each value of "r'. "r" varies from 1 to "n" ("n" being the input).
Help Ambar in finding the cumulative sum of volu... | {
"input": [
"100"
],
"output": [
"106824622\n"
]
} | {
"input": [],
"output": []
} | {
"input": [],
"output": []
} |
p01071 Monochrome Tile | Problem
There are W white square tiles in the horizontal direction and H in the vertical direction, for a total of W x H tiles.
On the morning of day i, Taro has a tile that exists in a rectangular area with the axith tile from the left and the ayith tile from the top on the upper left, and the bxith tile from the le... | {
"input": [],
"output": []
} | {
"input": [
"5 4\n5\n1 1 3 3\n3 2 4 2\n4 3 5 4\n1 4 5 4\n4 1 4 1"
],
"output": [
"9\n9\n13\n13\n14"
]
} | {
"input": [],
"output": []
} |
1302_D. Dijkstra | This is an unusual problem in an unusual contest, here is the announcement: [http://codeforces.com/blog/entry/73543](//codeforces.com/blog/entry/73543)
Find the distance between vertices 1 and n in an undirected weighted graph.
Input
The first line contains two integers n, m (1 ≤ n, m ≤ 2 ⋅ 10^5) — the number of ver... | {
"input": [],
"output": []
} | {
"input": [
"3 3\n1 2 5\n2 3 1\n1 3 7\n"
],
"output": [
"\n6\n"
]
} | {
"input": [],
"output": []
} |
142_C. Help Caretaker | Autumn came late to the kingdom of Far Far Away. The harvest was exuberant and it is now time to get ready for the winter. As most people celebrate the Harvest festival, Simon the Caretaker tries to solve a very non-trivial task of how to find place for the agricultural equipment in the warehouse.
He's got problems wi... | {
"input": [
"2 5\n",
"6 5\n",
"5 1\n",
"8 5\n",
"9 6\n",
"7 1\n",
"3 9\n",
"7 3\n",
"4 2\n",
"5 2\n",
"8 3\n",
"7 4\n",
"4 8\n",
"3 5\n",
"1 1\n",
"6 4\n",
"2 1\n",
"2 8\n",
"2 9\n",
"4 5\n",
"9 7\n",
"2 4\n",
"6 3\n",
"9... | {
"input": [
"5 6\n",
"3 3\n",
"2 2\n"
],
"output": [
"4\nAAA.B.\n.ABBB.\n.AC.BD\nCCCDDD\n..C..D\n",
"1\nAAA\n.A.\n.A.\n",
"0\n..\n..\n"
]
} | {
"input": [],
"output": []
} |
4-3 | Scooby is stuck in a cave in barren islands. Shaggy decided to play a prank on scooby.
in his ghostly voice shaggy asks a question to the scared scooby.
the ghost(shaggy) will make scooby's way out only if he answers the following problem.
since scooby is not a nerd help him get out of the cave. the question is as fo... | {
"input": [
"12\n3\n1 2 3\n2\n5 4\n84\n30887 92778 36916 47794 38336 85387 60493 16650 41422 2363 90028 68691 20060 97764 13927 80541 83427 89173 55737 5212 95369 2568 56430 65783 21531 22863 65124 74068 3136 13930 79803 34023 23059 33070 98168 61394 18457 75012 78043 76230 77374 84422 44920 13785 98538 75199 94... | {
"input": [
"1\n3\n1 2 3\n\nSAMPLE"
],
"output": [
"24"
]
} | {
"input": [],
"output": []
} |
p02687 AtCoder Beginner Contest 166 - A?C | AtCoder Inc. holds a contest every Saturday.
There are two types of contests called ABC and ARC, and just one of them is held at a time.
The company holds these two types of contests alternately: an ARC follows an ABC and vice versa.
Given a string S representing the type of the contest held last week, print the str... | {
"input": [],
"output": []
} | {
"input": [
"ABC"
],
"output": [
"ARC"
]
} | {
"input": [],
"output": []
} |
p01466 World Trip | Kita_masa is planning a trip around the world. This world has N countries and the country i has M_i cities. Kita_masa wants to visit every city exactly once, and return back to the starting city.
In this world, people can travel only by airplane. There are two kinds of airlines: domestic and international lines. Since... | {
"input": [],
"output": []
} | {
"input": [
"2 16\n4 4\n2 2\n1 1 1 2 1\n1 1 1 3 2\n1 1 1 4 1\n1 2 1 3 1\n1 2 1 4 2\n1 3 1 4 1\n2 1 2 2 1\n2 1 2 3 2\n2 1 2 4 1\n2 2 2 3 1\n2 2 2 4 2\n2 3 2 4 1\n1 1 2 1 1\n1 1 2 2 2\n1 2 2 1 2\n1 2 2 2 1",
"2 2\n2 1\n1 1\n1 1 1 2 1\n1 1 2 1 1",
"4 6\n1 1 1 1\n1 1 1 1\n1 1 2 1 1\n1 1 3 1 2\n1 1 4 1 1\n2 1... | {
"input": [],
"output": []
} |
cdthn | Nitesh recently discovered a new game CODATHON with the help of a very intelligent alien friend Jupiter.
In this game a student had various challenges and each challenge had infinite number of problems.
The scoring system in this game was quite different. There are 2 ways of scoring on a given problem:
If you are in t... | {
"input": [],
"output": []
} | {
"input": [
"2\n3 4\n5 7"
],
"output": [
"5\n23"
]
} | {
"input": [],
"output": []
} |
idclove | Valentine's Day is coming and our friend Mr.IDC has fallen in love with a girl. He just could not control his feelings and went to propose her.
When he proposed her the girl gave him a challenge and asked him to solve it and the condition was if he will solve the challenge successfully then only she will accept his pro... | {
"input": [],
"output": []
} | {
"input": [
"3\n20 5\n10 2\n5 3"
],
"output": [
"40\n5\n6"
]
} | {
"input": [],
"output": []
} |
1065_D. Three Pieces | You stumbled upon a new kind of chess puzzles. The chessboard you are given is not necesserily 8 × 8, but it still is N × N. Each square has some number written on it, all the numbers are from 1 to N^2 and all the numbers are pairwise distinct. The j-th square in the i-th row has a number A_{ij} written on it.
In your... | {
"input": [
"6\n32 17 18 23 26 33\n7 36 22 3 1 5\n30 9 8 34 27 21\n16 6 35 28 4 25\n29 19 24 13 11 12\n2 20 15 14 31 10\n",
"10\n38 18 27 74 94 4 45 82 83 88\n73 95 50 40 28 59 47 19 58 60\n23 75 14 22 97 81 3 85 87 6\n56 80 30 62 57 90 5 41 69 44\n72 46 70 32 11 76 91 1 77 17\n52 99 12 37 79 2 43 9 13 53\n9... | {
"input": [
"3\n1 9 3\n8 6 7\n4 2 5\n"
],
"output": [
"12 1"
]
} | {
"input": [],
"output": []
} |
1136_B. Nastya Is Playing Computer Games | Finished her homework, Nastya decided to play computer games. Passing levels one by one, Nastya eventually faced a problem. Her mission is to leave a room, where a lot of monsters live, as quickly as possible.
There are n manholes in the room which are situated on one line, but, unfortunately, all the manholes are clo... | {
"input": [
"44 1\n",
"4291 2145\n",
"2266 1133\n",
"1023 999\n",
"5000 888\n",
"5000 3378\n",
"2029 360\n",
"9 1\n",
"2563 1281\n",
"40 24\n",
"8 2\n",
"5000 539\n",
"2944 2468\n",
"8 4\n",
"10 9\n",
"530 530\n",
"5000 1\n",
"5000 2653\n",
... | {
"input": [
"5 1\n",
"2 2\n",
"4 2\n"
],
"output": [
"15\n",
"6\n",
"13\n"
]
} | {
"input": [],
"output": []
} |
1211_G. King's Path | There are n cities and n-1 two-way roads in Treeland. Each road connects a pair of different cities. From any city you can drive to any other, moving only along the roads. Cities are numbered from 1 to n. Yes, of course, you recognized an undirected tree in this description.
There is exactly one flag in each city, in ... | {
"input": [],
"output": []
} | {
"input": [
"1\n7\n2 3 2 7 1 1 3\n7 1 2 3 1 2 3\n1 7\n4 1\n2 6\n2 3\n2 4\n5 4\n",
"1\n5\n1 2 2 2 2\n2 2 2 2 1\n1 2\n2 3\n3 4\n4 5\n",
"3\n4\n10 20 10 20\n20 10 20 10\n1 2\n1 3\n1 4\n2\n1000000 1000000\n1000000 1000000\n1 2\n10\n4 2 2 4 2 4 1 2 3 4\n4 2 4 4 3 2 1 2 4 2\n5 8\n6 9\n10 5\n1 10\n7 10\n3 4\n5 ... | {
"input": [],
"output": []
} |
1297_C. Dream Team | Polycarp is the project manager in the IT-company. Right now, he needs to choose developers for his team to start a new project. The company has n developers "on the bench" (i.e not involved in other projects). Polycarp assessed the skills of each of them: a_i (-10^4 ≤ a_i ≤ 10^4) — an integer characteristic of the i-t... | {
"input": [],
"output": []
} | {
"input": [
"5\n5\n1 -1 1 -1 1\n2\n11 1\n3\n5 -3 4\n3\n5 3 -4\n5\n-1 0 3 -3 0\n"
],
"output": [
"\n2\n11101\n11\n10\n6\n111\n5\n100\n2\n10100\n"
]
} | {
"input": [],
"output": []
} |
euler-124 | Having gained some experience with Prime Numbers, Robin now seeks Revenge from Bruce. So, while they are on their way from the Airport to the Summit, Robin comes up with a new Prime based Puzzle for Bruce.
He asks him to find rad(n) for t numbers which he lists before Bruce and then form a sorted table on the values o... | {
"input": [
"100\n6451\n74308\n29045\n71720\n99096\n32196\n31151\n85640\n24317\n88001\n39081\n88765\n99510\n27026\n91492\n99379\n85315\n99440\n15214\n72870\n56522\n11836\n99137\n29128\n84189\n81146\n48602\n29042\n72858\n43179\n3314\n24053\n88284\n65951\n32344\n62190\n5704\n4021\n3497\n71605\n6433\n44193\n61129\n... | {
"input": [],
"output": []
} | {
"input": [],
"output": []
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.