name
stringlengths
2
82
description
stringlengths
42
10.5k
private_tests
dict
public_tests
dict
generated_tests
dict
tf01
An established group of scientists are working on finding solution to NP hard problems. They claim Subset Sum as an NP-hard problem. The problem is to determine whether there exists a subset of a given set S whose sum is a given number K. You are a computer engineer and you claim to solve this problem given that all...
{ "input": [], "output": [] }
{ "input": [ "2\n5 10\n3 4 6 1 9\n3 2\n1 3 4" ], "output": [ "1\n0" ] }
{ "input": [], "output": [] }
1170_E. Sliding Doors
Imagine that you are the CEO of a big old-fashioned company. Unlike any modern and progressive company (such as JetBrains), your company has a dress code. That's why you have already allocated a spacious room for your employees where they can change their clothes. Moreover, you've already purchased an m-compartment war...
{ "input": [], "output": [] }
{ "input": [ "3 10\n2 3 2\n6\n1 5\n2 1 10\n2 2 9\n2 5 6\n3 1 7 8\n4 1 2 3 4\n" ], "output": [ "\nYES\nYES\nNO\nNO\nYES\nNO\n" ] }
{ "input": [], "output": [] }
1250_B. The Feast and the Bus
Employees of JebTrains are on their way to celebrate the 256-th day of the year! There are n employees and k teams in JebTrains. Each employee is a member of some (exactly one) team. All teams are numbered from 1 to k. You are given an array of numbers t_1, t_2, ..., t_n where t_i is the i-th employee's team number. J...
{ "input": [], "output": [] }
{ "input": [ "6 3\n3 1 2 3 2 3\n", "10 1\n1 1 1 1 1 1 1 1 1 1\n", "12 4\n1 2 3 1 2 3 4 1 2 1 2 1\n" ], "output": [ "\n6\n", "\n10\n", "\n12\n" ] }
{ "input": [], "output": [] }
188_G. Array Sorting
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...
{ "input": [ "3 3 1 2\n", "7 12 2 3 44 5 60 2\n", "10\n60\n1\n60\n1\n60\n1\n60\n1\n60\n1\n" ], "output": [ "1 2 3 \n", "2 2 3 5 12 44 60 \n", "1 1 1 1 1 60 60 60 60 60 \n" ] }
{ "input": [ "5\n7\n1\n9\n7\n3\n", "10\n100\n1\n100\n1\n100\n1\n100\n1\n100\n1\n" ], "output": [ "1 3 7 7 9 \n", "1 1 1 1 1 100 100 100 100 100 \n" ] }
{ "input": [], "output": [] }
470_F. Pairwise Sums
You are given an array of n integers. For each element output the sum of itself and the previous element. For the first element, output the sum of the first and the last elements of the array. Input The input consists of a single line of space-separated integers. The first number is n (2 ≤ n ≤ 50) — the size of the a...
{ "input": [], "output": [] }
{ "input": [ "4 1 2 3 4\n", "5 5 46 372 81 9\n" ], "output": [ "5 3 5 7 ", "14 51 418 453 90 " ] }
{ "input": [], "output": [] }
820_D. Mister B and PR Shifts
Some time ago Mister B detected a strange signal from the space, which he started to study. After some transformation the signal turned out to be a permutation p of length n or its cyclic shift. For the further investigation Mister B need some basis, that's why he decided to choose cyclic shift of this permutation whi...
{ "input": [ "4\n1 2 4 3\n", "4\n2 1 4 3\n", "10\n1 2 10 9 7 4 8 3 6 5\n", "10\n1 7 10 6 5 2 3 8 9 4\n", "4\n4 3 2 1\n", "4\n2 1 3 4\n", "10\n1 10 9 5 3 2 4 7 8 6\n", "4\n2 3 1 4\n", "4\n2 4 3 1\n", "10\n1 5 10 8 4 3 9 2 7 6\n", "4\n1 4 3 2\n", "10\n1 8 10 6 2 4 9 3 7 5...
{ "input": [ "3\n3 2 1\n", "3\n1 2 3\n", "3\n2 3 1\n" ], "output": [ "2 1\n", "0 0\n", "0 1\n" ] }
{ "input": [], "output": [] }
p02613 AtCoder Beginner Contest 173 - Judge Status Summary
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`,...
{ "input": [], "output": [] }
{ "input": [ "6\nAC\nTLE\nAC\nAC\nWA\nTLE", "10\nAC\nAC\nAC\nAC\nAC\nAC\nAC\nAC\nAC\nAC" ], "output": [ "AC x 3\nWA x 1\nTLE x 2\nRE x 0", "AC x 10\nWA x 0\nTLE x 0\nRE x 0" ] }
{ "input": [], "output": [] }
dbyz15t
Problem Desrcription Shil likes to play with trees a lot.He is playing with an undirected tree containing N nodes.He wants to find out total number of unordered triplets (A,B,C) such that A is not connected to B, B is not connected to C and A is not connected to C by a direct edge (No two of A, B, C are mutually conne...
{ "input": [], "output": [] }
{ "input": [ "5\n1 2\n1 3\n3 4\n2 5" ], "output": [ "1" ] }
{ "input": [], "output": [] }
ig01
This is a simple game you must have played around with during your school days, calculating FLAMES of you and your crush! Given the names of two people, cancel out the common letters (repeated occurrence of a letter is treated separately, so 2A's in one name and one A in the other would cancel one A in each name), coun...
{ "input": [], "output": [] }
{ "input": [ "2\nSHILPA\nAAMIR\nMATT\nDENISE" ], "output": [ "ENEMIES\nLOVE" ] }
{ "input": [], "output": [] }
1211_I. Unusual Graph
Ivan on his birthday was presented with array of non-negative integers a_1, a_2, …, a_n. He immediately noted that all a_i satisfy the condition 0 ≤ a_i ≤ 15. Ivan likes graph theory very much, so he decided to transform his sequence to the graph. There will be n vertices in his graph, and vertices u and v will prese...
{ "input": [], "output": [] }
{ "input": [ "4 4\n1 2\n2 3\n3 4\n4 1\n", "3 0\n" ], "output": [ "\n0 1 0 1 \n", "\n0 0 0 \n" ] }
{ "input": [], "output": [] }
1297_E. Modernization of Treeland
Treeland consists of n cities and n-1 two-way roads connecting pairs of cities. From every city, you can reach every other city moving only by the roads. You are right, the system of cities and roads in this country forms an undirected tree. The government has announced a program for the modernization of urban infrast...
{ "input": [], "output": [] }
{ "input": [ "4\n10 4\n4 5\n5 2\n2 1\n1 3\n1 9\n9 10\n2 7\n7 8\n5 6\n4 3\n1 2\n2 3\n3 4\n5 3\n1 2\n1 3\n1 4\n1 5\n4 1\n1 2\n2 4\n2 3\n" ], "output": [ "\nYes\n9\n1 2 4 5 6 7 8 9 10 \nNo\nYes\n4\n1 3 4 5 \nYes\n1\n4 \n" ] }
{ "input": [], "output": [] }
1402_A. Fancy Fence
Everybody knows that Balázs has the fanciest fence in the whole town. It's built up from N fancy sections. The sections are rectangles standing closely next to each other on the ground. The ith section has integer height h_i and integer width w_i. We are looking for fancy rectangles on this fancy fence. A rectangle is ...
{ "input": [], "output": [] }
{ "input": [ "2\n1 2\n1 2\n" ], "output": [ "\n12\n" ] }
{ "input": [], "output": [] }
433_A. Kitahara Haruki's Gift
Kitahara Haruki has bought n apples for Touma Kazusa and Ogiso Setsuna. Now he wants to divide all the apples between the friends. Each apple weights 100 grams or 200 grams. Of course Kitahara Haruki doesn't want to offend any of his friend. Therefore the total weight of the apples given to Touma Kazusa must be equal ...
{ "input": [ "9\n100 100 100 200 100 100 200 100 200\n", "3\n100 100 100\n", "7\n200 200 200 100 200 200 200\n", "100\n100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 200 100 100 100 100 100...
{ "input": [ "4\n100 100 100 200\n", "3\n100 200 100\n" ], "output": [ "NO\n", "YES\n" ] }
{ "input": [], "output": [] }
class-homework
Ramesh and Suresh were in the same class and got home work from their mathematics teacher. The Homework consists of N strings and each string consists of only digits. The task which they need to perform is that they need to divide the string into 4 integers such that their sum is maximum. Note: Each integer should be...
{ "input": [ "100\n04\n9\n02163\n003000\n08041479\n80750340926070052\n90056\n11680\n90\n09020809009020989\n00460224000800\n0606\n6402000040\n3918080\n31052060072050\n41\n00070775690\n8000780240500799004\n66\n040934020028\n00241600300023700065\n3\n09964639222895002000\n2903002053708649009\n000050995\n0510000\n3000...
{ "input": [ "3\n4251\n52310\n00006\n\nSAMPLE" ], "output": [ "12\n56\nunlucky" ] }
{ "input": [], "output": [] }
even-from-end-1
Problem Description Given a list of integers, find and display all even numbers from the end of the list. Input Format Each line of input begins with an integer N indicating the number of integer n that follow which comprises a list. Output Format All even numbers from the end of the list, each separated by a sin...
{ "input": [ "21 3 -3 3 -3 3 -3 19 3 -3 3 -3 3 -3 19 3 -3 3 -3 3 -3 19", "2 8 -100\n5 -1000 5 1000 500 250\n10 -1000 5 1000 500 250 -1000 5 1000 500 250\n7 3 -3 3 -3 3 -3 19\n5 44 7 11 -999 20", "5 10 25 12 4 1 \n3 16 28 100" ], "output": [ "None to display", "-100 8 \n250 500 1000 -1000 \n250...
{ "input": [ "5 10 25 12 4 1 \n3 16 28 100\n\nSAMPLE" ], "output": [ "4 12 10 \n100 28 16" ] }
{ "input": [], "output": [] }
sherlock-and-kgb
The russian intelligence agency KGB make an encryption technique to send their passwords. Originally the password is of 3 characters. After encryption the password is converted into 3 numbers A-B-C. Now, Sherlock wants to decrypt the password encryption technique of KGB. Sherlock knows that every number has only 2 po...
{ "input": [ "5\n81 125 16\n19683 15625 8192\n59049 15630 32768\n59050 78125 131072\n177147 390625 131073" ], "output": [ "K-G-B \nK-G-B \nK-Y-B \nX-G-B \nK-G-Z" ] }
{ "input": [ "2\n27 25 4\n25 26 16\n\nSAMPLE" ], "output": [ "K-G-B\nX-Y-B" ] }
{ "input": [], "output": [] }
p01123 Let's Move Tiles!
<!-- Problem G --> Let's Move Tiles! You have a framed square board forming a grid of square cells. Each of the cells is either empty or with a square tile fitting in the cell engraved with a Roman character. You can tilt the board to one of four directions, away from you, toward you, to the left, or to the right, ...
{ "input": [], "output": [] }
{ "input": [ "4\n..E.\n.AD.\nB...\n..C.\nD\n4\n..E.\n.AD.\nB...\n..C.\nDR\n3\n...\n.A.\nBC.\n((URD)3L)2R\n5\n...P.\nPPPPP\nPPP..\nPPPPP\n..P..\nLRLR(LR)12RLLR\n20\n....................\n....................\n.III..CC..PPP...CC..\n..I..C..C.P..P.C..C.\n..I..C....P..P.C....\n..I..C....PPP..C....\n..I..C....P....C.....
{ "input": [], "output": [] }
colarr
Chef had a hard time arguing with his friend, and after getting a great old kick Chef saw a colored array with N cells, numbered from 1 to N. The kick was so strong that Chef suddenly understood the rules of the game. Each cell is painted with a color. Here the colors are numbered from 1 to M. For any cell i, Chef c...
{ "input": [], "output": [] }
{ "input": [ "1\n4 2 1\n1 1 2 2\n1 1\n1 1\n1 1\n3 1\n0 1\n0 1\n1 0\n1 0" ], "output": [ "5" ] }
{ "input": [], "output": [] }
1170_B. Bad Days
Every day Kotlin heroes analyze the statistics of their website. For n days, they wrote out n numbers a_1, a_2, ..., a_n, where a_i is the number of visits on the i-th day. They believe that a day is bad if there are at least 2 days before it with a strictly greater number of visits. For example, if n=8 and a=[3, 1, 4...
{ "input": [], "output": [] }
{ "input": [ "8\n3 1 4 1 5 9 2 6\n", "5\n1 1 1 1 1\n", "13\n2 7 1 8 2 8 1 8 2 8 4 5 9\n" ], "output": [ "\n2\n", "\n0\n", "\n6\n" ] }
{ "input": [], "output": [] }
153_E. Euclidean Distance
You are given a multiset of points on the plane with integer coordinates. Find the maximum distance between two points from this multiset. Input The first line of input contains the number of points n (2 ≤ n ≤ 50). Next, n pairs of lines follow, each describing a single point: the first line contains x-coordinate, th...
{ "input": [], "output": [] }
{ "input": [ "3\n0\n1\n2\n3\n4\n5\n", "3\n10\n12\n-5\n8\n10\n12\n" ], "output": [ "5.656854249\n", "15.5241747\n" ] }
{ "input": [], "output": [] }
188_D. Asterisks
You are given a number n. Print n lines, i-th line should consist of i characters "*". Lines' indices are 1-based. Input The only line of input contains an integer n (1 ≤ n ≤ 50). Output Output the described pattern. Examples Input 3 Output * ** *** Input 6 Output * ** *** **** ***** ******
{ "input": [], "output": [] }
{ "input": [ "3\n", "6\n" ], "output": [ "*\n**\n***\n", "*\n**\n***\n****\n*****\n******\n" ] }
{ "input": [], "output": [] }
470_C. Eval
You are given a simple arithmetic expression of the form a?b, where a and b are integer constants, and ? can be one of the following operations: '+' (addition), '-' (subtraction), '*' (multiplication), '/' (integer division) or '%' (modulo operation). Output the result of evaluation of this expression. Input The inp...
{ "input": [], "output": [] }
{ "input": [ "123+456\n", "192/5\n", "945%19\n" ], "output": [ "579\n", "38\n", "14\n" ] }
{ "input": [], "output": [] }
digital-numbers
Bosky is a very curious child who turned 13 yesterday. His parents gifted him a digital watch which he really liked. He was amazed to see how each number can be represented inside one cell only by switching different edges on and off. Today, while he was in his home alone, getting bored looking at his watch, an idea p...
{ "input": [ "5\n1 14\n1 50\n4 28\n5 700\n3 147" ], "output": [ "1\n10\n3\n32491\n739" ] }
{ "input": [ "4\n1 14\n1 50\n4 28\n5 700\n\nSAMPLE" ], "output": [ "1\n10\n3\n32491" ] }
{ "input": [], "output": [] }
give-me-my-test-monk
Professor just has checked all the N students tests. Everything was fine but then he realised that none of the students had signed their papers, so he doesn't know which test belongs to which student. But it's definitely not professors's job to catch every student and asked him to find his paper! So he will hand out...
{ "input": [ "60 0 58", "7 3 7" ], "output": [ "630738177", "195634923" ] }
{ "input": [ "3 1 3\n\nSAMPLE" ], "output": [ "833333340" ] }
{ "input": [], "output": [] }
lexicographically-preceding-permutation
Given an integer n and a permutation of numbers 1, 2 ... , n-1, n write a program to print the permutation that lexicographically precedes the given input permutation. If the given permutation is the lexicographically least permutation, then print the input permutation itself. Input Format: First line is the test c...
{ "input": [], "output": [] }
{ "input": [ "1\n3\n1 3 2\n\nSAMPLE" ], "output": [ "1 2 3" ] }
{ "input": [], "output": [] }
chsparr
Chef has a an array A consisting of N elements. He wants to add some elements into the array as per the below mentioned process. After each minute, Chef iterates over the array in order from left to right, and takes every two neighbouring pair of elements, say x and y, he adds a new element x + y in the middle of eleme...
{ "input": [], "output": [] }
{ "input": [ "2\n3 1 1 5\n1 6 9\n3 2 6 7\n1 6 9" ], "output": [ "38\n36" ] }
{ "input": [], "output": [] }
etmx05
Middle Strings Miss Roma has got a new job in a computer agency. To test her skills the manager has appointed her with a small project. She will get a string of any length but of ODD length and what she has to do is finding a center string of length 3 in the original string. For Example: She gets a string 'CANDY' the...
{ "input": [], "output": [] }
{ "input": [ "CANDY", "SOLVING" ], "output": [ "AND", "LVI" ] }
{ "input": [], "output": [] }
stadium
The bustling town of Siruseri has just one sports stadium. There are a number of schools, colleges, sports associations, etc. that use this stadium as the venue for their sports events. Anyone interested in using the stadium has to apply to the Manager of the stadium indicating both the starting date (a positive inte...
{ "input": [], "output": [] }
{ "input": [ "4\n2 5\n9 7\n15 6\n9 3" ], "output": [ "3" ] }
{ "input": [], "output": [] }
1431_I. Cyclic Shifts
You are given a matrix consisting of n rows and m columns. The matrix contains lowercase letters of the Latin alphabet. You can perform the following operation any number of times you want to: choose two integers i (1 ≤ i ≤ m) and k (0 < k < n), and shift every column j such that i ≤ j ≤ m cyclically by k. The shift i...
{ "input": [], "output": [] }
{ "input": [ "3 5 4\nabacc\nccbba\nccabc\nabacc\nacbbc\nababa\nacbbc\n", "6 4 4\ndaac\nbcba\nacad\ncbdc\naaaa\nbcbb\ndcdd\nacba\nbbbb\ndbcd\n", "5 10 5\nltjksdyfgg\ncbhpsereqn\nijndtzbzcf\nghgcgeadep\nbfzdgxqmqe\nibgcgzyfep\nbbhdgxqmqg\nltgcgxrzep\nljnpseldgn\nghhpseyzcf\n" ], "output": [ "\n0\n2\...
{ "input": [], "output": [] }
abc-garfield
Garfield the cat likes candies A LOT. He always keeps a huge stock of it at his home. Today John, his owner, brought home three types of candies. He brought A pieces of Red candy, B pieces of Green candy and C pieces of Blue candy. Garfield is really happy. But the problem is that John won’t allow him to eat all of it ...
{ "input": [], "output": [] }
{ "input": [ "3\n2 1 2 3\n1 1 1 1\n2 1 0 1\n\nSAMPLE" ], "output": [ "9\n4\n4" ] }
{ "input": [], "output": [] }
jumping-frog
There is a frog known as "CHAMELEON" because he has a special feature to change its body's color similar to stone's color on which he sits. There are N colorful stones lying in a row, but of only 1 to 100 different colors. Frog can hopp on another stone if the stone has same color as its body or (i-1)th stone if it is ...
{ "input": [ "541\n54 98 68 63 83 94 55 35 12 63 30 17 97 62 96 26 63 76 91 19 52 42 55 95 8 97 6 18 96 3 46 21 55 88 14 27 65 8 94 93 52 39 40 52 12 94 89 39 38 6 24 92 88 40 89 12 40 8 86 41 66 15 61 91 11 32 33 59 77 24 46 51 97 17 6 58 16 40 84 28 51 28 56 46 60 17 51 72 74 16 67 75 38 93 56 81 4 61 9 82 30 8...
{ "input": [ "6\n2 3 1 3 2 4\n2\n1 0 4\n2 3 5\n\nSAMPLE" ], "output": [ "2\n-1" ] }
{ "input": [], "output": [] }
p01046 Yu-kun Likes a lot of Money
Background The kindergarten attached to the University of Aizu is a kindergarten where children who love programming gather. Yu, one of the kindergarten children, loves money as much as programming. Yu-kun visited the island where treasures sleep to make money today. Yu-kun has obtained a map of the treasure in advanc...
{ "input": [], "output": [] }
{ "input": [ "3 3 1 10\n@#b\n.#.\n.#.\nb 100", "3 3 1 20\n@*C\n..*\n...\nC 10", "3 3 1 10\n@0.\n...\n...\n0 100" ], "output": [ "0", "0", "100" ] }
{ "input": [], "output": [] }
p01179 Cousin's Aunt
Sarah is a girl who likes reading books. One day, she wondered about the relationship of a family in a mystery novel. The story said, * B is A’s father’s brother’s son, and * C is B’s aunt. Then she asked herself, “So how many degrees of kinship are there between A and C?” There are two possible relationships bet...
{ "input": [], "output": [] }
{ "input": [ "7\nC is A’s father’s brother’s son’s aunt\nC is A’s mother’s brother’s son’s aunt\nC is A’s son’s mother’s mother’s son\nC is A’s aunt’s niece’s aunt’s niece\nC is A’s father’s son’s brother\nC is A’s son’s son’s mother\nC is A" ], "output": [ "5 3\n5 1\n2 2\n6 0\n2 0\n1 1\n0 0" ] }
{ "input": [], "output": [] }
p01797 Kimagure Cleaner
Example Input 2 -3 4 L 2 5 ? 3 5 Output 2 L 4 L 3
{ "input": [], "output": [] }
{ "input": [ "2 -3 4\nL 2 5\n? 3 5" ], "output": [ "2\nL 4\nL 3" ] }
{ "input": [], "output": [] }
p02069 Universal and Existential Quantifiers
Problem Statement You are given a list of $N$ intervals. The $i$-th interval is $[l_i, r_i)$, which denotes a range of numbers greater than or equal to $l_i$ and strictly less than $r_i$. In this task, you consider the following two numbers: * The minimum integer $x$ such that you can select $x$ intervals from the gi...
{ "input": [], "output": [] }
{ "input": [ "" ], "output": [ "" ] }
{ "input": [], "output": [] }
acdemy
Sherlock Holmes has decided to start a new academy to some of the young lads. He has conducted several tests and finally selected N equally brilliant students.Now he don't know whether to train all the N students or not. Now since Holmes was in a confusion, Watson came up with an idea. He wanted to test the obedience o...
{ "input": [], "output": [] }
{ "input": [ "2\n5\n2 3 5 1 2\n3\n1 2 3" ], "output": [ "3\n3" ] }
{ "input": [], "output": [] }
seg003
Problem description. The problem statement is simple , you are given an array and you have to perform two types of operation on it. Type 1 : update the value of array at the given index. Type 2 : find the maximum sum you can obtained in the given range ( L , R ) by taking any two index i and j , such that ( L <=...
{ "input": [], "output": [] }
{ "input": [ "5 3 \n1 2 3 4 5\n2 1 5\n1 2 5\n2 1 5" ], "output": [ "9 \n10" ] }
{ "input": [], "output": [] }
319_B. Psychos in a Line
There are n psychos standing in a line. Each psycho is assigned a unique integer from 1 to n. At each step every psycho who has an id greater than the psycho to his right (if exists) kills his right neighbor in the line. Note that a psycho might kill and get killed at the same step. You're given the initial arrangeme...
{ "input": [ "2\n1 2\n", "100\n61 96 25 10 50 71 38 77 76 75 59 100 89 66 6 99 2 13 3 23 91 93 22 92 4 86 90 44 39 31 9 47 28 95 18 54 1 73 94 78 60 20 42 84 97 83 16 81 67 64 74 46 82 5 88 80 14 48 53 79 30 11 62 21 41 70 63 58 51 56 57 17 87 72 27 85 68 49 52 8 12 98 43 37 35 69 55 32 26 40 29 65 19 24 34 3...
{ "input": [ "6\n1 2 3 4 5 6\n", "10\n10 9 7 8 6 5 3 4 2 1\n" ], "output": [ "0\n", "2\n" ] }
{ "input": [], "output": [] }
530_C. Diophantine equation
You are given an equation A * X + B * Y = C, A, B, C are positive integer coefficients, X and Y are variables which can have positive integer values only. Output the number of solutions of this equation and the solutions themselves. Input The only line of input contains integers A, B and C (1 ≤ A, B, C ≤ 1000), separ...
{ "input": [], "output": [] }
{ "input": [ "3 5 35\n", "3 35 5\n" ], "output": [ "2\n5 4\n10 1\n", "0\n" ] }
{ "input": [], "output": [] }
556_C. Case of Matryoshkas
Andrewid the Android is a galaxy-famous detective. He is now investigating the case of vandalism at the exhibition of contemporary art. The main exhibit is a construction of n matryoshka dolls that can be nested one into another. The matryoshka dolls are numbered from 1 to n. A matryoshka with a smaller number can be ...
{ "input": [ "100 3\n45 1 2 3 4 5 6 7 8 9 19 21 24 27 28 30 34 35 37 39 40 41 42 43 46 47 48 51 52 55 58 59 61 63 64 66 69 71 76 80 85 86 88 89 94 99\n26 10 11 15 18 23 29 31 33 36 38 44 49 54 56 60 62 65 75 78 82 83 84 95 96 97 98\n29 12 13 14 16 17 20 22 25 26 32 45 50 53 57 67 68 70 72 73 74 77 79 81 87 90 91 ...
{ "input": [ "3 2\n2 1 2\n1 3\n", "7 3\n3 1 3 7\n2 2 5\n2 4 6\n" ], "output": [ "1\n", "10\n" ] }
{ "input": [], "output": [] }
bhavanas-and-bhuvanas-bet
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...
{ "input": [], "output": [] }
{ "input": [ "2\n3\n10" ], "output": [ "1\n3" ] }
{ "input": [], "output": [] }
259_B. Little Elephant and Magic Square
Little Elephant loves magic squares very much. A magic square is a 3 × 3 table, each cell contains some positive integer. At that the sums of integers in all rows, columns and diagonals of the table are equal. The figure below shows the magic square, the sum of integers in all its rows, columns and diagonals equals 15...
{ "input": [ "0 100000 100000\n100000 0 100000\n100000 100000 0\n", "0 99626 99582\n99766 0 99258\n99442 99398 0\n", "0 6361 2304\n1433 0 8103\n7232 3175 0\n", "0 28 10\n12 0 24\n26 8 0\n", "0 97 56\n69 0 71\n84 43 0\n", "0 4 4\n4 0 4\n4 4 0\n", "0 9 2\n3 0 7\n8 1 0\n", "0 99978 99920\...
{ "input": [ "0 1 1\n1 0 1\n1 1 0\n", "0 3 6\n5 0 5\n4 7 0\n" ], "output": [ "1 1 1\n1 1 1\n1 1 1\n", "6 3 6\n5 5 5\n4 7 4\n" ] }
{ "input": [], "output": [] }
661_D. Maximal Difference
You are given an array of integers ai. Find the largest absolute value of difference between adjacent elements of the array max(abs(ai - ai + 1)). Input The only line of the input contains a list of space-separated integers ai (1 ≤ ai ≤ 100) — elements of the array. The size of the array is between 2 and 10, inclusiv...
{ "input": [], "output": [] }
{ "input": [ "2 10 4 8 6 12\n", "3 3\n" ], "output": [ "8\n", "0\n" ] }
{ "input": [], "output": [] }
72_I. Goofy Numbers
The non-negative integer a is a divisor of the non-negative integer b if and only if there exists a positive integer c such that a × c = b. Some numbers are really interesting. Commander Surena defines some interesting properties for non-negative integers: * An integer is happy if it is divisible by at least one o...
{ "input": [], "output": [] }
{ "input": [ "99\n", "29994\n", "23\n" ], "output": [ "happier\n", "happy\n", "upset\n" ] }
{ "input": [], "output": [] }
p01516 Milky Way
Milky Way Milky Way English text is not available in this practice contest. The Milky Way Transportation Corporation is a travel agency that plans and manages interstellar travel tours. The Milky Way Transportation Corporation is planning a project called "Milky Way Crossing Orihime Hikoboshi Experience Tour". This ...
{ "input": [], "output": [] }
{ "input": [ "" ], "output": [ "" ] }
{ "input": [], "output": [] }
cb03
The problem is very simple. For every string given as input, you need to tell us the number of subsequences of it that are palindromes (need not necessarily be distinct). Note that the empty string is not a palindrome. For example, the palindromic subsequences of "aab" are: "a", "a", "b", "aa", and the method returns...
{ "input": [], "output": [] }
{ "input": [ "3\naab\ndddd\nthisisapalindromeemordnilapasisiht" ], "output": [ "4\n15\n814157" ] }
{ "input": [], "output": [] }
mes
Problem description One of the Engineer friends of John, Mr. Dev tried to develop an encryption algorithm which can send strings of words wirelessly between two devices connected through Wi-Fi. On completing the design of algorithm, John decides to test his algorithm on real devices. To test his algorithm on device, De...
{ "input": [], "output": [] }
{ "input": [ "2\nHe is a good programmer\nhp is a pool Probgrammer\nProgram\nprpgreamp" ], "output": [ "4\n3" ] }
{ "input": [], "output": [] }
reciicha
Help Saurabh with his Chemistry Assignment. Saurabh has been given a chemistry assignment by Ruby Mam. Though the assignment is simple but Saurabh has to watch India vs Pakistan Match and he has no time to do the assignment by himself. So Saurabh wants you to do his assignment so that he doesn’t get scolded by Ruby Mam...
{ "input": [], "output": [] }
{ "input": [ "2\n1 2\n2 1" ], "output": [ "2\n2" ] }
{ "input": [], "output": [] }
120_C. Winnie-the-Pooh and honey
As we all know, Winnie-the-Pooh just adores honey. Ones he and the Piglet found out that the Rabbit has recently gotten hold of an impressive amount of this sweet and healthy snack. As you may guess, Winnie and the Piglet asked to come at the Rabbit's place. Thus, there are n jars of honey lined up in front of Winnie-t...
{ "input": [ "100 1\n85 75 55 65 39 26 47 16 9 11 3 4 70 23 56 64 36 34 16 13 18 28 32 80 8 79 76 4 21 75 93 51 85 86 100 88 91 71 97 28 66 22 47 87 91 95 3 56 81 53 88 90 21 30 74 45 58 73 36 40 70 51 28 75 20 54 69 52 14 48 52 53 91 81 32 68 16 48 60 66 91 32 55 42 93 51 3 46 23 64 39 1 30 42 20 83 99 29 35 59\...
{ "input": [ "3 3\n15 8 10\n" ], "output": [ "9\n" ] }
{ "input": [], "output": [] }
618_B. Guess the Permutation
Bob has a permutation of integers from 1 to n. Denote this permutation as p. The i-th element of p will be denoted as pi. For all pairs of distinct integers i, j between 1 and n, he wrote the number ai, j = min(pi, pj). He writes ai, i = 0 for all integer i from 1 to n. Bob gave you all the values of ai, j that he wro...
{ "input": [ "10\n0 1 5 2 5 3 4 5 5 5\n1 0 1 1 1 1 1 1 1 1\n5 1 0 2 6 3 4 6 6 6\n2 1 2 0 2 2 2 2 2 2\n5 1 6 2 0 3 4 8 8 7\n3 1 3 2 3 0 3 3 3 3\n4 1 4 2 4 3 0 4 4 4\n5 1 6 2 8 3 4 0 9 7\n5 1 6 2 8 3 4 9 0 7\n5 1 6 2 7 3 4 7 7 0\n", "4\n0 1 3 2\n1 0 1 1\n3 1 0 2\n2 1 2 0\n", "13\n0 5 5 2 5 4 5 5 3 5 5 5 1\n...
{ "input": [ "2\n0 1\n1 0\n", "5\n0 2 2 1 2\n2 0 4 1 3\n2 4 0 1 3\n1 1 1 0 1\n2 3 3 1 0\n" ], "output": [ "1 2 ", "2 4 5 1 3 " ] }
{ "input": [], "output": [] }
attack-or-be-attacked
You are given an NxM chessboard. Find the number of pairs of different positions of a bishop and a PQ-knight where they don't attack each other modulo 10^9 + 7. A bishop can move to square if it's on the same diagonal with it. A PQ-knight with given integers P and Q (P doesn't equals Q) can move to the square if the ...
{ "input": [ "92891 8181 398 787", "1 10 3 4" ], "output": [ "353972355", "90" ] }
{ "input": [ "2 5 1 2\n\nSAMPLE" ], "output": [ "62" ] }
{ "input": [], "output": [] }
little-stuart-and-evil-hackers-2
Evil hackers are trying to hack the database of HackerEarth.com. After a lot of work they figure out that the encryption key used by HackerEarth to securely store the data is really just a random large number. After a bit more work they figure out that the key is in form of a^b( a power b). So now they call in the evil...
{ "input": [ "1000\n73004 67426\n91627 69478\n61297 68278\n24234 83945\n47637 96401\n94242 97144\n85353 14705\n99269 44776\n88928 91446\n52876 40296\n37601 12385\n93013 8451\n18937 66949\n7883 75710\n6581 60221\n4664 95936\n43998 12643\n65414 5294\n80920 5999\n5590 44908\n18751 99831\n58403 4103\n30888 57671\n652...
{ "input": [ "4\n1 2\n1 1\n2 1\n2 3\n\nSAMPLE" ], "output": [ "6\n2\n4\n400" ] }
{ "input": [], "output": [] }
mystery-12
Lets think of an infinite series of numbers such that the difference between any two consecutive numbers is d. Let the first number in the sequence be a. Now your task is to find the multiple that occurs first in the sequence of a given number n and print its index in the output. Input 1st line T denoting test cases....
{ "input": [ "10\n844452700697263162 119646220083568392\n617\n624716331013886830 420232882599498616\n263\n371747750780382310 31328662274583882\n151\n155589359406144136 349833477687741817\n263\n890649303306320035 470504750916794312\n509\n172858306891107873 404374317528704778\n179\n486897312988741400 23233560323142...
{ "input": [ "2\n5 6\n7\n4 9\n11\n\nSAMPLE" ], "output": [ "5\n2" ] }
{ "input": [], "output": [] }
exebit01
Pratyush, a six year old kid has just learnt how to write 1 through 1000 in decimal number system(DNS). Being a very curious kid, he made some modifications in DNS and removed the digits 0 through 3 and 7 through 9. So the only digits remaining to be used are 4, 5 and 6. He started enumerating numbers with these digits...
{ "input": [], "output": [] }
{ "input": [ "5\n3\n13\n45\n64\n1000000000" ], "output": [ "6\n444\n4456\n4664\n5446456455646565564" ] }
{ "input": [], "output": [] }
lastride
Problem description. Toretto has no friends. He has got family, and now they need him. His bitter enemy, Ian Shaw, has captured Toretto's beloved Letty and evil cooks in his head. All Toretto has is the algorithmic message Shaw left before leaving- Letty(n): L = an empty list while n > 0: find the larg...
{ "input": [], "output": [] }
{ "input": [ "2\n1 2\n3 10" ], "output": [ "3\n25" ] }
{ "input": [], "output": [] }
pd32
Recall the definition of the Fibonacci numbers: f1 := 1 f2 := 2 fn := fn-1 + fn-2 (n ≥ 3) Given two numbers a and b, calculate how many Fibonacci numbers are in the range [a,b]. Input The input contains several test cases. Each test case consists of two non-negative integer numbers a and b. Input is...
{ "input": [], "output": [] }
{ "input": [ "10 100\n1234567890 9876543210\n0 0" ], "output": [ "5\n4" ] }
{ "input": [], "output": [] }
162_A. Pentagonal numbers
Pentagonal numbers are figurate numbers which can be calculated using the formula pn = (3n2 - n) / 2 (always integer). You are given n; calculate n-th pentagonal number. Input The only line of input contains an integer n (1 ≤ n ≤ 100). Output Output the n-th pentagonal number. Examples Input 2 Output 5 Inpu...
{ "input": [ "3\n", "6\n" ], "output": [ "15\n", "66\n" ] }
{ "input": [ "2\n", "5\n" ], "output": [ "5\n", "35\n" ] }
{ "input": [], "output": [] }
minimum-coins
Ram has to pay Shyam R rupees and but the coins which he has got is of limited denomination .Assuming he has a limited knowledge of the mathematics and has unlimited number of coins of each denomination.Write a code to help Ram to pay the money using minimum number of coins .Suppose Ram has coins of {1,2} denomination ...
{ "input": [ "9\n{10}", "-19\n{10}", "79\n{2,8}" ], "output": [ "ERROR", "ERROR", "ERROR" ] }
{ "input": [ "24\n{1,7,3}\n\nSAMPLE" ], "output": [ "Rupee 1 coin 0\nRupee 3 coin 1\nRupee 7 coin 3" ] }
{ "input": [], "output": [] }
p02074 N-by-M grid calculation
Problem Statement Have you experienced $10$-by-$10$ grid calculation? It's a mathematical exercise common in Japan. In this problem, we consider the generalization of the exercise, $N$-by-$M$ grid calculation. In this exercise, you are given an $N$-by-$M$ grid (i.e. a grid with $N$ rows and $M$ columns) with an addit...
{ "input": [], "output": [] }
{ "input": [ "" ], "output": [ "" ] }
{ "input": [], "output": [] }
aba15f
Problem description. “Murphy’s Law doesn’t meant that something bad will happen. It means that whatever can happen, will happen.” —Cooper While traveling across space-time,the data sent by NASA to "The Endurance" spaceship is sent in the format of, For...
{ "input": [], "output": [] }
{ "input": [ "5\n100\n23\n4\n1000\n5" ], "output": [ "68\n21\n4\n320\n5" ] }
{ "input": [], "output": [] }
nfeb4
Buffalo Marketing Gopal wants to make some money from buffalos, but in a quite a different way. He decided that his future lay in speculating on buffalos. In the market in his village, buffalos were bought and sold everyday. The price fluctuated over the year, but on any single day the price was always the same. ...
{ "input": [], "output": [] }
{ "input": [ "2\n3\n1 2 90\n4\n1 3 1 2" ], "output": [ "177\n 3" ] }
{ "input": [], "output": [] }
64_C. Table
The integer numbers from 1 to nm was put into rectangular table having n rows and m columns. The numbers was put from left to right, from top to bottom, i.e. the first row contains integers 1, 2, ..., m, the second — m + 1, m + 2, ..., 2 * m and so on. After it these numbers was written on the paper in another order: ...
{ "input": [], "output": [] }
{ "input": [ "3 4 11\n", "20000 10000 200000000\n" ], "output": [ "8\n", "200000000\n" ] }
{ "input": [], "output": [] }
composition
We all know that every positive integer can be represented as the sum of one or more odd integers. For eg: 4 = 1 + 1 + 1 + 1. Now, your task in this question is to find out the value of G(n), which equals to the number of all possible representations, as described above, of the given integer, n. Since the answer coul...
{ "input": [ "1000\n25681017298294515\n312600462688402121\n833646696039112627\n223491184116692039\n162199167831855427\n534855812752103589\n300213762583795578\n991699364918096631\n403692356889424907\n669013150942454609\n570806843129162652\n35807633555691065\n316483127646881362\n188047943884580689\n3003483309310761...
{ "input": [ "2\n1\n4\n\nSAMPLE" ], "output": [ "1\n3" ] }
{ "input": [], "output": [] }
insoma4
In the hidden country of Lapatrecta, an age old custom was followed to ensure that no outsider ever entered their country undetected. The security measure, though simple, was an effective one. Every person born in Lapatrecta had the initials of all his forefathers included in front of his name. Every once in a while, c...
{ "input": [], "output": [] }
{ "input": [ "3\nAPJQ\nAPJRS\nPJQ" ], "output": [ "3" ] }
{ "input": [], "output": [] }
nf02
NITMAS Fest is live. The members of the community are very busy. People from different colleges have come to compete. But, Naveen is very possessive about his girlfriend, Archana. He always remains close to his girlfriend. Couples (boys in a line and girls in another) have to stand in different rows in a line for a gam...
{ "input": [], "output": [] }
{ "input": [ "4 2 4 6 8\n5 1 3 5 7 9" ], "output": [ "1" ] }
{ "input": [], "output": [] }
salg04
p { font-size:14px; text-align:justify; } Two positive integers n amd m, n greater than or equal to m, will be given as input. Make a code that generates all possible combinations of 1,2,3,...,n taking m integers at a time in "increasing order". Comparison between two combinations: a1,a2,a3,...,am b1,b2,b3,...,bm ...
{ "input": [], "output": [] }
{ "input": [ "5\n3" ], "output": [ "1 2 3 \n1 2 4\n1 2 5\n1 3 4\n1 3 5\n1 4 5\n2 3 4\n2 3 5\n2 4 5\n3 4 5" ] }
{ "input": [], "output": [] }
64_A. Factorial
Print the factorial of the given integer number n. The factorial of n is equal to 1·2·...·n. Input The only line contains n (1 ≤ n ≤ 10). Output Print the factorial of n. Examples Input 3 Output 6 Input 5 Output 120
{ "input": [], "output": [] }
{ "input": [ "3\n", "5\n" ], "output": [ "6\n", "120\n" ] }
{ "input": [], "output": [] }
racers
There are N bikers present in a city (shaped as a grid) having M bikes. All the bikers want to participate in the HackerRace competition, but unfortunately only K bikers can be accommodated in the race. Jack is organizing the HackerRace and wants to start the race as soon as possible. He can instruct any biker to move ...
{ "input": [], "output": [] }
{ "input": [ "3 3 2\n0 1\n0 2\n0 3\n100 1\n200 2 \n300 3\n\nSAMPLE" ], "output": [ "40000" ] }
{ "input": [], "output": [] }
notatri
You have N (3 ≤ N ≤ 2,000) wooden sticks, which are labeled from 1 to N. The i-th stick has a length of Li (1 ≤ Li ≤ 1,000,000). Your friend has challenged you to a simple game: you will pick three sticks at random, and if your friend can form a triangle with them (degenerate triangles included), he wins; otherwise, yo...
{ "input": [], "output": [] }
{ "input": [ "3\n4 2 10\n3\n1 2 3\n4\n5 2 9 6\n0" ], "output": [ "1\n0\n2" ] }
{ "input": [], "output": [] }
seq
The number of submissions of CodeChef from Students of Graphic Era University had been growing since the day the CodeChef campus chapter, GEU_Coders had been formed here. This rise in user submissions alerted the staff members at CodeChef. They started to track user activities of students from Graphic Era University. T...
{ "input": [], "output": [] }
{ "input": [ "2\n4\n7" ], "output": [ "13\n107" ] }
{ "input": [], "output": [] }
530_D. Set subtraction
You are given a starting set consisting of all integers from 1 to 1000, inclusive. You are also given several sets which need to be subtracted from the starting set (i.e., each number which is in at least one of these sets needs to be removed from the starting set). Each subtracted set is represented as an interval of ...
{ "input": [], "output": [] }
{ "input": [ "2\n1 900\n902 999\n", "3\n1 500\n200 746\n150 1000\n" ], "output": [ "2 901 1000\n", "0\n" ] }
{ "input": [], "output": [] }
980_F. Cactus to Tree
You are given a special connected undirected graph where each vertex belongs to at most one simple cycle. Your task is to remove as many edges as needed to convert this graph into a tree (connected graph with no cycles). For each node, independently, output the maximum distance between it and a leaf in the resulting...
{ "input": [ "68 74\n7 8\n24 23\n55 56\n3 50\n61 62\n12 1\n32 33\n36 35\n9 8\n44 50\n53 5\n29 28\n16 2\n36 37\n3 22\n44 45\n27 28\n66 65\n34 4\n31 32\n64 65\n13 12\n10 9\n67 66\n5 47\n55 54\n6 51\n20 21\n67 4\n17 29\n41 40\n48 49\n19 20\n18 17\n35 4\n25 24\n33 34\n38 37\n5 48\n43 30\n63 62\n60 61\n66 6\n26 27\n64...
{ "input": [ "9 10\n7 2\n9 2\n1 6\n3 1\n4 3\n4 7\n7 6\n9 8\n5 8\n5 9\n", "4 4\n1 2\n2 3\n3 4\n4 1\n" ], "output": [ "5\n3\n5\n4\n5\n4\n3\n5\n4\n", "2\n2\n2\n2\n" ] }
{ "input": [], "output": [] }
1-7
Raj and simran are in love. but thakur baldev singh doesnt want them to be together. But baldev Singh cares for her daughter too. He wants raj to prove his love for her daughter and family. So Baldev singh being a great lover of strings sets up problem for raj. he screams out a string and asks simran to choose her ...
{ "input": [ "100\nwlrbbmqbhcdarzowkkyhiddqscdxrjmowfrxsjybldbefsarcbynecdyggxxpklorellnmpapqfwkhopkmcoqhnwnkuewhsqmgbbuqcljjivswmdkqtbxixmvtrrbljptnsnfwzqfjmafadrrwsofsbcnuvqhffbsaqxwpqcacehchzvfrkmlnozjkpqpxrjxkitzyxacbhhkicqcoendtomfgdwdwfcgpxiqvkuytdlcgdewhtaciohordtqkvwcsgspqoqmsboaguwnnyqxnzlgdgwpbtrwblnsad...
{ "input": [ "2\nabca a\nbbb c\n\nSAMPLE" ], "output": [ "2\n0" ] }
{ "input": [], "output": [] }
cranbrom
Seeing the current political scenario in the city of Delhi,and the clean sweep of the Aam Aadmi Party, you are wondering that its maybe time to change careers and start selling broomsticks. Now you sell broomsticks of various lengths. You initially do not have any brooms.You decide to roam about in the city finding bro...
{ "input": [], "output": [] }
{ "input": [ "4\nfound 3\nfound 4\ndemand 3\ndemand 4" ], "output": [ "4" ] }
{ "input": [], "output": [] }
where-is-checkerboard
At HackerEarth we love play checkers and we play it a lot! However, we play a very specific kind of checkers. Our game is played on 32x32 board. If you are a programmer, you probably know why the board size is 32. Maybe we will describe details of the game in a future challenge, but for now, the only thing you have to ...
{ "input": [ "200 200\n#__##_##__#__##__#_#__#_#_#_#_#_#_#_#_###_#_#_#_#_#_##_#_#_#_#_#_#######_#__###_____#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#____##__##_##_##______##_#_#__#__#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_\n__#_##__#__##_###_##_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#__#_#_#_#_#_#_#_#_#_#_#_#_##__##_#_#_...
{ "input": [ "42 42\n__________________________________________\n__________________________________________\n__________________________________________\n__________________________________________\n__________________________________________\n______#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_____\n_____#_#_#_#_#_#_#_#_#_#_#_#_...
{ "input": [], "output": [] }
nita10
Alan threw a party and invited all her close friend to it. Let us suppose there were 2n people in the party and all of them were sitting across a round table. The host asked them to shake hands with the condition that no two hands should cross each other i.e if 4 people are sitting then 1st person cannot shake hands wi...
{ "input": [], "output": [] }
{ "input": [ "2\n2\n4" ], "output": [ "2\n14" ] }
{ "input": [], "output": [] }
seakam
Sereja has an undirected graph on N vertices. There are edges between all but M pairs of vertices. A permutation p on the vertices of the graph is represented as p[1], p[2], … , p[N] such that for all i, p[i] is a vertex of the graph. A permutation is called connected if there is an edge between vertices p[i] and p[i+...
{ "input": [], "output": [] }
{ "input": [ "2\n4 3\n1 2\n2 3\n3 4\n2 1\n1 2" ], "output": [ "2\n0" ] }
{ "input": [], "output": [] }
64_G. Path Canonization
A path in some Unix-similar file system is given. The path consists of elements separated with characters "/". For example: "/usr/share/mysql/../tomcat6/conf/server.xml". The path starts with the root directory (i.e. starts with the character "/"). Each element means a name of file or directory, or it is one of two spe...
{ "input": [], "output": [] }
{ "input": [ "/usr/share/mysql/../tomcat6/conf/server.xml\n", "/a/./././..\n" ], "output": [ "/usr/share/tomcat6/conf/server.xml\n", "/\n" ] }
{ "input": [], "output": [] }
dmsg
Dilku and Bhopu live in Artland. Dilku loves Bhopu and he writes a message : “iloveyou” on paper and wishes to send it to Bhopu. As Dilku is busy making an artwork, he asks his friend Raj to send the message to Bhopu. However Raj has a condition that he may add/remove some characters and jumble the letters of the mes...
{ "input": [], "output": [] }
{ "input": [ "abcvleouioydef", "iloveyou", "ulrvysioqjifo" ], "output": [ "happy", "happy", "sad" ] }
{ "input": [], "output": [] }
483_A. Counterexample
Your friend has recently learned about coprime numbers. A pair of numbers {a, b} is called coprime if the maximum number that divides both a and b is equal to one. Your friend often comes up with different statements. He has recently supposed that if the pair (a, b) is coprime and the pair (b, c) is coprime, then the...
{ "input": [ "998169857863230068 998169857863230083\n", "996517375802030516 996517375802030518\n", "267367244641009850 267367244641009899\n", "648583102513043 648583102513053\n", "268193483524125978 268193483524125979\n", "997343614685146644 997343614685146644\n", "2 2\n", "1 4\n", ...
{ "input": [ "900000000000000009 900000000000000029\n", "2 4\n", "10 11\n" ], "output": [ "900000000000000010 900000000000000011 900000000000000012\n", "2 3 4\n", "-1\n" ] }
{ "input": [], "output": [] }
530_B. String inside out
You are given a string S of even length s1..s2n . Perform the following manipulations: * divide it into two halves s1..sn and sn + 1..s2n * reverse each of them sn..s1 and s2n..sn + 1 * concatenate the resulting strings into sn..s1s2n..sn + 1 Output the result of these manipulations. Input The only line of ...
{ "input": [], "output": [] }
{ "input": [ "codeforces\n", "qwertyasdfgh\n" ], "output": [ "fedocsecro\n", "ytrewqhgfdsa\n" ] }
{ "input": [], "output": [] }
ladybug1
Mrs. Verma has decided to sell his car. N people have offered to buy the car. Instead of selling to the highest bidder, Mrs. Verma decides to sell his company to the Kth lowest bidder. How much money will Mrs. Verma get? Input The first line of the input contains 2 space-separated integers, N and K. The next line cont...
{ "input": [], "output": [] }
{ "input": [ "5 4\n1 2 1 3 3" ], "output": [ "3" ] }
{ "input": [], "output": [] }
pcsc2
Phillip has become fascinated with sequences lately. He looks for sequences all the time. His favorite sequence is the Fibonacci sequence, where any element is equal to the sum of the two previous elements. However, he isn't able to figure out the correct number for positions beyond 8 without writing it on paper. C...
{ "input": [], "output": [] }
{ "input": [ "1 5 7" ], "output": [ "45" ] }
{ "input": [], "output": [] }
1431_J. Zero-XOR Array
You are given an array of integers a of size n. This array is non-decreasing, i. e. a_1 ≤ a_2 ≤ ... ≤ a_n. You have to find arrays of integers b of size 2n - 1, such that: * b_{2i-1} = a_i (1 ≤ i ≤ n); * array b is non-decreasing; * b_1 ⊕ b_2 ⊕ ... ⊕ b_{2n-1} = 0 (⊕ denotes bitwise XOR operation: <https://en....
{ "input": [], "output": [] }
{ "input": [ "3\n0 1 3\n", "4\n0 3 6 7\n", "5\n1 5 9 10 23\n", "10\n39 62 64 79 81 83 96 109 120 122\n" ], "output": [ "\n2\n", "\n6\n", "\n20\n", "\n678132\n" ] }
{ "input": [], "output": [] }
252_C. Points on Line
Little Petya likes points a lot. Recently his mom has presented him n points lying on the line OX. Now Petya is wondering in how many ways he can choose three distinct points so that the distance between the two farthest of them doesn't exceed d. Note that the order of the points inside the group of three chosen point...
{ "input": [ "2 1000000000\n-14348867 1760823\n", "10 5\n31 36 43 47 48 50 56 69 71 86\n", "10 90\n24 27 40 41 61 69 73 87 95 97\n", "10 50\n1 4 20 27 65 79 82 83 99 100\n", "3 1000000000\n-5 -1 1\n", "2 1000000000\n-907894512 -289906312\n", "100 100\n-98 -97 -96 -93 -92 -91 -90 -87 -86 -8...
{ "input": [ "4 3\n1 2 3 4\n", "4 2\n-3 -2 -1 0\n", "5 19\n1 10 20 30 50\n" ], "output": [ "4\n", "2\n", "1\n" ] }
{ "input": [], "output": [] }
p02070 Permutation Sort
Problem Statement One day (call it day 0), you find a permutation $P$ of $N$ integers written on the blackboard in a single row. Fortunately you have another permutation $Q$ of $N$ integers, so you decide to play with these permutations. Every morning of the day 1,2,3,... , you rewrite every number on the blackboard ...
{ "input": [], "output": [] }
{ "input": [ "" ], "output": [ "" ] }
{ "input": [], "output": [] }
bitcj5
Doge and Cate can no longer coexist in the same planet. Time has finally come to decide once and for all, who will reign over this planet. They agreed on a non violent way to settle this. Both are given an array of N integers and a positive integer K. In a single operation, one can change an element of the array to any...
{ "input": [], "output": [] }
{ "input": [ "2\n5 1\n1 2 3 4 5\n4 3\n1 2 2 1" ], "output": [ "0\n1" ] }
{ "input": [], "output": [] }
promo
Mo the pro does not want to be late for the promo of Incident'14, the annual cultural fest of NITK. In his excitement, he drops his only 2 wrist watches. He sets his watches according to a wall clock. After some time N he discovers that one of the watch is X minutes fast, and the other watch is Y minutes slow. What ...
{ "input": [], "output": [] }
{ "input": [ "2\n10 5 5\n1 1 1" ], "output": [ "720\n360" ] }
{ "input": [], "output": [] }
1170_A. Three Integers Again
We have three positive integers a, b and c. You don't know their values, but you know some information about them. Consider all three pairwise sums, i.e. the numbers a+b, a+c and b+c. You know exactly two (any) of three pairwise sums. Your task is to find such three positive integers a, b and c which match the given i...
{ "input": [], "output": [] }
{ "input": [ "3\n123 13\n2 2\n2000000000 2000000000\n" ], "output": [ "\n111 1 12\n1 1 1\n1999999999 1 1\n" ] }
{ "input": [], "output": [] }
153_D. Date Change
You are given a date in "DD.MM.YYYY" ("day.month.year") format and a number of days shift you have to add to this date. Output the resulting date. Input The first line of input contains the date in "DD.MM.YYYY" format: two digits for day (with leading zero if needed), dot, two digits for month (with leading zero if n...
{ "input": [], "output": [] }
{ "input": [ "10.02.2012\n12\n", "01.02.2010\n-40\n", "01.01.2000\n365\n", "13.08.1990\n-609\n" ], "output": [ "22.02.2012\n", "23.12.2009\n", "31.12.2000\n", "12.12.1988\n" ] }
{ "input": [], "output": [] }
188_C. LCM
Least common multiple (LCM) of two numbers is the smallest positive integer which is divisible by both of them. You are given integers a and b. Calculate their LCM. Input The input contains two integers a and b (1 ≤ a, b ≤ 103), separated by a single space. Output Output LCM(a, b). Examples Input 10 42 Output ...
{ "input": [], "output": [] }
{ "input": [ "10 42\n", "123 41\n" ], "output": [ "210\n", "123\n" ] }
{ "input": [], "output": [] }
234_E. Champions' League
In the autumn of this year, two Russian teams came into the group stage of the most prestigious football club competition in the world — the UEFA Champions League. Now, these teams have already started to play in the group stage and are fighting for advancing to the playoffs. In this problem we are interested in the dr...
{ "input": [ "24\n245 331 580 709\nNdpxiALpbR 946\nUOKNn 450\nLq 282\nWTIH 172\nwzMnNFkgi 979\nOBlbpApXwYw 33\nVpAfFWZMMn 298\nhSbPXcDUffQmdNrAKFX 835\nv 184\nMa 299\nyDKclUeu 29\nTKzQWh 146\noDVRDmzJSEQXB 0\nlzIHcLMzbNfdWlR 207\npPfD 169\nWqbFRRZHyLUlA 276\nAYVDqvLH 958\nJQwr 467\noQNIQxzJINuwZyTGCFGL 378\nCZFxl...
{ "input": [ "8\n1 3 1 7\nBarcelona 158\nMilan 90\nSpartak 46\nAnderlecht 48\nCeltic 32\nBenfica 87\nZenit 79\nMalaga 16\n" ], "output": [ "Group A:\nBarcelona\nBenfica\nSpartak\nCeltic\nGroup B:\nMilan\nZenit\nAnderlecht\nMalaga\n" ] }
{ "input": [], "output": [] }
39_D. Cubical Planet
You can find anything whatsoever in our Galaxy! A cubical planet goes round an icosahedral star. Let us introduce a system of axes so that the edges of the cubical planet are parallel to the coordinate axes and two opposite vertices lay in the points (0, 0, 0) and (1, 1, 1). Two flies live on the planet. At the moment ...
{ "input": [ "1 0 0\n0 0 0\n", "1 1 0\n0 0 1\n", "1 1 1\n0 1 1\n", "0 0 1\n1 0 0\n", "1 1 1\n0 0 0\n", "1 0 0\n0 1 0\n", "1 0 0\n0 1 1\n", "0 0 1\n1 0 1\n", "0 1 0\n0 1 1\n", "1 0 1\n0 1 0\n", "1 0 0\n0 0 1\n", "1 0 1\n0 0 0\n", "0 0 1\n1 1 1\n", "0 1 1\n1 1 1\n...
{ "input": [ "0 0 0\n1 1 1\n", "0 0 0\n0 1 0\n", "1 1 0\n0 1 0\n" ], "output": [ "NO\n", "YES\n", "YES\n" ] }
{ "input": [], "output": [] }
470_B. Hexakosioihexekontahexaphobia
This (unpronounceable) word means simply fear of number 666. You are given a string of digits. Check whether it is scary for a person suffering from this phobia, i.e., whether it contains number 666 as a substring. Input The input will consist of a single string p. The string contains between 1 and 100 digits ('0'-...
{ "input": [], "output": [] }
{ "input": [ "123098\n", "16660\n", "1606061\n" ], "output": [ "NO\n", "YES\n", "NO\n" ] }
{ "input": [], "output": [] }
level-selections
You are given N natural numbers and K swaps are allowed. Determine the largest permutation that you can attain. INPUT: First line contains N and k next line has N spaced integers OUTPUT: Print the largest permutation array. 0<N<10^5 0<K<10^5 SAMPLE INPUT 5 1 4 2 3 5 1 SAMPLE OUTPUT 5 2 3 4 1
{ "input": [ "15 6\n125414563354 66523365412 6649562315496 946626595666 5566163264946 656216465656 662626564 6626564956 645956256564 959745315489 12548896233547 533248965412 2236874566324 56624748664475 6654455774561" ], "output": [ "56624748664475 12548896233547 6654455774561 6649562315496 5566163264946 ...
{ "input": [ "5 1\n4 2 3 5 1\n\nSAMPLE" ], "output": [ "5 2 3 4 1" ] }
{ "input": [], "output": [] }
monk-in-the-secret-services
The secret services of Armin, an otherwise peace-loving country, have decided to perform a surgical strike in the war-torn city of Tashka. Tashka is under enemy control and the objective of the strike is to gain control over the city. The mission is subdivided into the following steps: 1) Divide in groups and infiltra...
{ "input": [ "10\n29 668\n11 27 52\n21 10 35\n17 1 61\n24 26 11\n10 9 79\n1 7 1\n21 2 10\n17 5 45\n7 13 93\n15 21 59\n3 27 70\n7 23 1\n10 23 61\n23 8 76\n19 13 97\n2 16 58\n5 13 74\n18 13 22\n23 4 52\n4 8 67\n12 19 90\n27 7 9\n17 18 91\n12 19 81\n14 27 24\n12 6 51\n18 28 57\n8 5 9\n25 9 97\n26 21 66\n29 26 54\n11...
{ "input": [ "1\n4 4\n1 4 1\n1 2 1\n2 3 1\n2 4 1\n1 2 3\n\nSAMPLE" ], "output": [ "5" ] }
{ "input": [], "output": [] }
plane-with-points
There are N points on an XY plane. In one turn, you can select a set of collinear points on the plane and remove them. Your goal is to remove all the points in the least number of turns. Given the coordinates of the points, calculate two things: The minimum number of turns (T) needed to remove all the points. The numb...
{ "input": [], "output": [] }
{ "input": [ "2\n3\n0 0\n0 1\n1 0\n4\n3 4\n3 5\n3 6\n5 5\n\nSAMPLE" ], "output": [ "2 6\n2 8" ] }
{ "input": [], "output": [] }
p01969 AA Graph
C: AA グラフ (AA Graph) Problem Given a graph as an ASCII Art (AA), please print the length of shortest paths from the vertex s to the vertex t. The AA of the graph satisfies the following constraints. A vertex is represented by an uppercase alphabet and symbols `o` in 8 neighbors as follows. ooo oAo ooo Horizontal...
{ "input": [], "output": [] }
{ "input": [ "" ], "output": [ "" ] }
{ "input": [], "output": [] }
cdva1604
Everyone knows the famous detective Sherlock. He has been handed over a new case of "The Abominable Bride". Each night she kills N people but to irritate Sherlock she leaves exactly one people. The way she kills the people is somewhat strange. She makes 1 to N people stand in a line and starts killing them. But, in t...
{ "input": [], "output": [] }
{ "input": [ "5\n2\n4\n6\n9\n12" ], "output": [ "2\n4\n4\n2\n8" ] }
{ "input": [], "output": [] }
ignus15b
Problem Description  You are an army personnel in the great army of the Zorin race, where you are a part of a team of n people. Unfortunately, your army has lost a war to an intergalactic species, genetically much advanced than yours. Their captain Bruno have kept all your men (including you) as hostages, and now they...
{ "input": [], "output": [] }
{ "input": [ "6\n6\n125\n32\n46\n98\n156" ], "output": [ "5\n123\n1\n29\n69\n57" ] }
{ "input": [], "output": [] }