name
stringlengths
2
82
description
stringlengths
42
10.5k
private_tests
dict
public_tests
dict
generated_tests
dict
mulmagic
Rohit was travelling to NIT Warangal, to attend their annual technical fest - "Technozion". In the train, opposite to him, Rohit found quite a peculiar man playing with an array of numbers. When he enquired, the man told that he is trying to solve a puzzle for decades but unable to do so. Seeing Rohit's interest in the...
{ "input": [], "output": [] }
{ "input": [ "1\n8\n1 2 3 4 5 6 7 8" ], "output": [ "20" ] }
{ "input": [], "output": [] }
1297_G. M-numbers
For a given positive integer m, a positive number is called a m-number if the product of its digits is m. For example, the beginning of a series of 24-numbers are as follows: 38, 46, 64, 83, 138, 146, 164, 183, 226 ... You are given a positive integer m and k. Print k-th among m-numbers if all m-numbers are sorted in ...
{ "input": [], "output": [] }
{ "input": [ "24 9\n", "24 1\n", "5040 1000000000\n", "2020 2020\n" ], "output": [ "\n226\n", "\n38\n", "\n111121111315213227111\n", "\n-1\n" ] }
{ "input": [], "output": [] }
1402_C. Star Trek
The United Federation of Planets is an alliance of N planets, they are indexed from 1 to N. Some planets are connected by space tunnels. In a space tunnel, a starship can fly both ways really fast. There are exactly N-1 space tunnels, and we can travel from any planet to any other planet in the Federation using these t...
{ "input": [], "output": [] }
{ "input": [ "3 1\n1 2\n2 3\n" ], "output": [ "\n4\n" ] }
{ "input": [], "output": [] }
p01740 Rotation Game
You have a board with height two and width W. The board is divided into 1x1 cells. Each row of the board is numbered 1 and 2 from top to bottom and each column is numbered 1 to W from left to right. We denote a cell at the i-th row in the j-th column by (i, j). Initially, some checkers are placed on some cells of the b...
{ "input": [], "output": [] }
{ "input": [ "3\n.oo\no..\n\no.o\no.." ], "output": [ "1" ] }
{ "input": [], "output": [] }
cm1404
Problem description. Liza wants to share her pizza among n friends, What are the minimum number of straight knife strokes required to cut the pizza into n pieces? Input The first line contains number of test cases T. The next T lines contain the input numbers N, the numbers of pieces required. Output For each tes...
{ "input": [], "output": [] }
{ "input": [ "3\n4\n5\n6" ], "output": [ "2\n3\n3" ] }
{ "input": [], "output": [] }
lemouse
It is well-known that the elephants are afraid of mouses. The Little Elephant from the Zoo of Lviv is not an exception. The Little Elephant is on a board A of n rows and m columns (0-based numeration). At the beginning he is in cell with coordinates (0; 0) and he wants to go to cell with coordinates (n-1; m-1). From c...
{ "input": [], "output": [] }
{ "input": [ "2\n3 9\n001000001\n111111010\n100100100\n7 9\n010101110\n110110111\n010011111\n100100000\n000010100\n011011000\n000100101" ], "output": [ "9\n10" ] }
{ "input": [], "output": [] }
100_I. Rotation
Ehsan loves geometry! Especially he likes to rotate points! Given a point in the plane, Ehsan likes to rotate it by k degrees (counter-clockwise), around the origin. What is the result of this rotation? Input A single integer k (0 ≤ k < 360) is given in the first line. Two integer numbers x and y are given in the se...
{ "input": [], "output": [] }
{ "input": [ "90\n1 1\n", "180\n1 1390\n" ], "output": [ "-1.00000000 1.00000000\n", "-1.00000000 -1390.00000000\n" ] }
{ "input": [], "output": [] }
130_D. Exponentiation
You are given integers a, b and c. Calculate ab modulo c. Input Input data contains numbers a, b and c, one number per line. Each number is an integer between 1 and 100, inclusive. Output Output ab mod c. Examples Input 2 5 40 Output 32 Input 2 5 26 Output 6
{ "input": [], "output": [] }
{ "input": [ "2\n5\n40\n", "2\n5\n26\n" ], "output": [ "32\n", "6\n" ] }
{ "input": [], "output": [] }
683_F. Reformat the String
In this problem you are given a string s consisting of uppercase and lowercase Latin letters, spaces, dots and commas. Your task is to correct the formatting of this string by removing and inserting spaces, as well as changing the case of the letters. After formatting, the resulting string must meet the following requ...
{ "input": [], "output": [] }
{ "input": [ "hello ,i AM veRy GooD.Boris\n", "a. b, C . \n" ], "output": [ "Hello, i am very good. Boris\n", "A. B, c.\n" ] }
{ "input": [], "output": [] }
72_A. Goshtasp, Vishtasp and Eidi
Goshtasp was known to be a good programmer in his school. One day Vishtasp, Goshtasp's friend, asked him to solve this task: Given a positive integer n, you should determine whether n is rich. The positive integer x is rich, if there exists some set of distinct numbers a1, a2, ..., am such that <image>. In addition: ...
{ "input": [], "output": [] }
{ "input": [ "11\n", "545\n" ], "output": [ "11=11\n", "541+3+1=545\n" ] }
{ "input": [], "output": [] }
kth-sequence
Today RK has a special task for you. RK gives you a positive integer N. First you have to find all the sequences of length N consisting of characters 'O' and 'Z' only such that no two 'Z' are adjacent in any sequence. After finding all such sequences you have to find Kth sequence when all found sequences are sorted lex...
{ "input": [], "output": [] }
{ "input": [ "1\n3 2\n\nSAMPLE" ], "output": [ "OOZ" ] }
{ "input": [], "output": [] }
paroothi-and-his-date
Recently our Paroothi got a crush on a girl , as we all know he is not good with the girls so he asked Vikrant ( The stud ) for expert advise and he told him to take her to her favourite restaurant . It is known that there are K restaurants in the city numbered from 1 to K.Now Paroothi has a list which contains N integ...
{ "input": [], "output": [] }
{ "input": [ "8 6\n2 1 2 3 4 2 3 3\n\nSAMPLE" ], "output": [ "2" ] }
{ "input": [], "output": [] }
string-problem-32
Arpit thought AB De-villiers could do anything no matter what it is, however his brother didn’t believe him . To make his brother believe him he contacted AB and gave him a problem in which he gave him a two strings where the second string was the reverse of the first. He asked him to find the longest substring which i...
{ "input": [ "12\nabababa\ntipra\nmanish\nabcabcabcab\narpit\nmanisha\nmadam\nkanika\nseema\nnitin\npragya\nabcabcabcabcabcabcabca", "6\nabababa\ntipra\nmanish\nabcabcabcab\narpit\nmanisha" ], "output": [ "Case 1: 5\nCase 2: -1\nCase 3: -1\nCase 4: 8\nCase 5: -1\nCase 6: -1\nCase 7: 1\nCase 8: 2\nCase...
{ "input": [ "3\nabababa\ntipra\nmanish\n\nSAMPLE" ], "output": [ "Case 1: 5\nCase 2: -1\nCase 3: -1" ] }
{ "input": [], "output": [] }
p02857 DISCO Presents Discovery Channel Code Contest 2020 Qual - Majority of Balls
This is an interactive task. We have 2N balls arranged in a row, numbered 1, 2, 3, ..., 2N from left to right, where N is an odd number. Among them, there are N red balls and N blue balls. While blindfolded, you are challenged to guess the color of every ball correctly, by asking at most 210 questions of the followin...
{ "input": [], "output": [] }
{ "input": [ "" ], "output": [ "" ] }
{ "input": [], "output": [] }
clco05
After coming to college, Harry decided to have a get together with friends. So he contacted Chahak who is a renowned event organiser. She is given the task of managing this lavish party. Harry is fond of eating and his friend Joseph is fond of cracking jokes. As per Harry’s demand, Chahak kept N food items in the party...
{ "input": [], "output": [] }
{ "input": [ "2\n3 30\n2 2 1\n3 20\n2 1 1" ], "output": [ "5\n-1" ] }
{ "input": [], "output": [] }
fest
Indian Institute of Technology, Banaras Hindu University is organizing an annual cultural festival. An organizing committee has been formed to get all the preprations done for the fest. The convener of the fest has decided to invite the American Band, Linkin Park to the institute. which in turn gets disadvantageous as ...
{ "input": [], "output": [] }
{ "input": [ "5\n3 2\n4 5\n7 4\n34534985349875439875439875349875 93475349759384754395743975349573495\n34543987529435983745230948023948 3498573497543987543985743989120393097595572309482304" ], "output": [ "9\n1024\n2401\n735851262\n985546465" ] }
{ "input": [], "output": [] }
100_B. Friendly Numbers
Kiana thinks two integers are friends if and only if one of them divides the other one. For example, 12 and 4 are friends, also 6 and 6 are friends too, but 120 and 36 are not. A group of non-zero integers is called friendly, if each pair of its integers form a friend pair. You are given a group of non-zero integers....
{ "input": [], "output": [] }
{ "input": [ "4\n1,3,6,12\n", "3\n1,2,9\n" ], "output": [ "FRIENDS\n", "NOT FRIENDS\n" ] }
{ "input": [], "output": [] }
alexanders-journey-4
There are N (labelled 1 to N) kingdoms in a country. Our king Alexander is living in the kingdom S. We are given R distances, these distances are between two kingdoms and the distance between any two kingdom may or may not be unique. Now Alexander wants to visit each kingdom in minimum distance possible starting from ...
{ "input": [], "output": [] }
{ "input": [ "1\n4 4\n1 2 24\n1 4 20\n3 1 3\n4 3 12\n1\n\nSAMPLE" ], "output": [ "24 3 15" ] }
{ "input": [], "output": [] }
kejal-color-problem
Kejal have N points, with coordinates (1, 0), (2, 0), ..., (N, 0). Every point has a color, point with coordinate (i, 0) has color C[i]. Kejal have painted arcs between every pair of points with same color. Formally Kejal painted arc between points (i, 0) and (j, 0) if C[i] = C[j] and i != j, such arc has color C[i]. ...
{ "input": [], "output": [] }
{ "input": [ "6\n1 2 1 2 1 2\n\nSAMPLE" ], "output": [ "6" ] }
{ "input": [], "output": [] }
1211_C. Ice Cream
Summer in Berland lasts n days, the price of one portion of ice cream on the i-th day is c_i. Over the summer, Tanya wants to eat exactly k portions of ice cream. At the same time, on the i-th day, she decided that she would eat at least a_i portions, but not more than b_i (a_i ≤ b_i) portions. In other words, let d_i ...
{ "input": [], "output": [] }
{ "input": [ "3 7\n3 5 6\n0 3 4\n3 3 3\n", "1 45000\n40000 50000 100000\n", "3 100\n2 10 50\n50 60 16\n20 21 25\n", "4 12\n2 5 1\n1 2 2\n2 3 7\n3 10 4\n" ], "output": [ "\n31\n", "\n4500000000\n", "\n-1\n", "\n35\n" ] }
{ "input": [], "output": [] }
1252_L. Road Construction
There are N cities in the country of Numbata, numbered from 1 to N. Currently, there is no road connecting them. Therefore, each of these N cities proposes a road candidate to be constructed. City i likes to connect with city A_i, so city i proposes to add a direct bidirectional road connecting city i and city A_i. It...
{ "input": [], "output": [] }
{ "input": [ "4 5\n2 2 1 2\n3 2 2 3\n4 2 3 4\n2 2 4 5\n1 2 3 4 5\n", "4 5\n2 2 10 20\n3 2 2 3\n4 2 3 4\n2 2 4 5\n1 2 3 4 5\n" ], "output": [ "\n1 2\n2 3\n3 4\n0 0\n4 2\n", "\n-1\n" ] }
{ "input": [], "output": [] }
146_D. Lucky Number 2
Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Petya loves long lucky numbers very much. He is interested in the minimum lucky number d that meet...
{ "input": [ "1 10 1 2\n", "2 1 3 1\n", "4 7 2 1\n", "1 4 1 1\n", "45 65 31 32\n", "1 1000000 4 5\n", "25 94 11 12\n", "7 1000 1 2\n", "70 60 20 21\n", "69 84 25 24\n", "5 10 2 3\n", "1 2 1 1\n", "6 6 2 3\n", "2 1 2 1\n", "100 100 4 5\n", "1 10 1 1\n", ...
{ "input": [ "2 2 1 1\n", "4 7 3 1\n" ], "output": [ "4774\n", "-1\n" ] }
{ "input": [], "output": [] }
emma-and-the-prime-sum
Emma is fond of prime numbers. Emma’s teacher gave her an interesting problem to solve. The problem is as follows: The teacher gave Emma 2 positive integers x and y(x ≤ y). She asked Emma to find the sum of all the prime numbers between x and y(x and y inclusive). The teacher gave Emma a few such pairs to calculate t...
{ "input": [ "1000\n870 978\n946 984\n767 801\n456 840\n112 402\n665 818\n610 676\n773 942\n177 295\n28 206\n82 471\n728 773\n156 269\n33 391\n461 481\n394 647\n263 399\n266 666\n104 160\n877 993\n450 476\n327 868\n485 999\n202 492\n709 854\n957 986\n959 986\n283 812\n870 915\n868 940\n411 960\n211 467\n709 743\n...
{ "input": [ "3\n1 10\n2 6\n5 10\n\nSAMPLE" ], "output": [ "17\n10\n12" ] }
{ "input": [], "output": [] }
sharmas-area-logic-2
Harry has been tracking Draco Malfoy throughtout the year on the Marauder's Map. But suddenly one day, Harry could not locate Draco on the map. Now he decides to search the entire map. But since the Marauder's map is of the entire Hogwarts school, it will take Harry a lot of time to search Malfoy. So he decides to loo...
{ "input": [ "15\n3\n9 9\n0 0\n-9 -9\n6\n4 48\n9 97\n3 2\n2 2\n6 -3\n1 2\n2\n1 1\n0 0\n3\n1 1\n9 99\n89 179\n4\n5 55\n1 11\n6 20\n-90 -180\n10\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n3\n0 0\n0 0\n0 0\n2\n1 2\n1 1\n2\n3 9\n9 6\n5\n-90 -180\n-90 180\n90 180\n90 -180\n0 0\n5\n1 1\n1 2\n1 2\n1 3\n1 3\n6\n0...
{ "input": [ "2\n2\n1 1\n3 3\n3\n1 1\n2 2\n2 3\n\nSAMPLE" ], "output": [ "4\n2" ] }
{ "input": [], "output": [] }
1431_G. Number Deletion Game
Alice and Bob play a game. They have a set that initially consists of n integers. The game is played in k turns. During each turn, the following events happen: 1. firstly, Alice chooses an integer from the set. She can choose any integer except for the maximum one. Let the integer chosen by Alice be a; 2. secondl...
{ "input": [], "output": [] }
{ "input": [ "5 2\n3 4 1 5 2\n", "7 3\n101 108 200 1 201 109 100\n" ], "output": [ "\n4\n", "\n283\n" ] }
{ "input": [], "output": [] }
323_A. Black-and-White Cube
You are given a cube of size k × k × k, which consists of unit cubes. Two unit cubes are considered neighbouring, if they have common face. Your task is to paint each of k3 unit cubes one of two colours (black or white), so that the following conditions must be satisfied: * each white cube has exactly 2 neighbourin...
{ "input": [ "69\n", "20\n", "97\n", "63\n", "22\n", "30\n", "54\n", "41\n", "27\n", "40\n", "16\n", "51\n", "36\n", "40\n", "4\n", "7\n", "54\n", "9\n", "30\n", "13\n", "56\n", "20\n", "42\n", "48\n", "61\n", "81\...
{ "input": [ "1\n", "2\n" ], "output": [ "-1\n", "bb\nbb\n\nww\nww\n\n" ] }
{ "input": [], "output": [] }
crushing-violence
The students of college XYZ are getting jealous of the students of college ABC. ABC managed to beat XYZ in all the sports and games events. The main strength of the students of ABC is their unity. The students of XYZ decide to destroy this unity. The geeks of XYZ prepared a special kind of perfume. Anyone who inhales...
{ "input": [], "output": [] }
{ "input": [ "2\n3\n2 2 1\n3 2 1\n4\n2 3 4 1\n2 3 4 1\n\nSAMPLE" ], "output": [ "1 0\n1 4" ] }
{ "input": [], "output": [] }
pairs-5
King Klee's kingdom is under attack. He leaves the task of protecting his kingdom to you as you are Now you are given N teams of soldiers. There are 3 gates --> Large, Larger, Largest. You need to form three teams from these N teams to send them to those three gates. But the order should follow certain conditions ...L...
{ "input": [], "output": [] }
{ "input": [ "4\n3\n3\n1\n4\n\nSAMPLE" ], "output": [ "4" ] }
{ "input": [], "output": [] }
p02067 AIGo
Problem Statement Recently, AIs which play Go (a traditional board game) are well investigated. Your friend Hikaru is planning to develop a new awesome Go AI named Sai and promote it to company F or company G in the future. As a first step, Hikaru has decided to develop an AI for 1D-Go, a restricted version of the ori...
{ "input": [], "output": [] }
{ "input": [ "" ], "output": [ "" ] }
{ "input": [], "output": [] }
ct03
Problem description. Chef decides to distribute fancy stationary among kids. Chef has collection of erasers and pencils . Each kid needs to be given a pencil and eraser. Your job is to help find Chef how many kids can get the stationary and how many min pencils or erasers the chef will need to clear the stock that is l...
{ "input": [], "output": [] }
{ "input": [ "2\nEPPEP\nEPPPPEE" ], "output": [ "2 1\n3 1" ] }
{ "input": [], "output": [] }
twofrnds
These days, Sid and Jake are learning about number theory. They have just visited the zoo and during the visit they have counted(yes, they are superb at counting :) ) the number of animals at the zoo. Now, after visiting the zoo, Sid is saying that f is a factor of the total number of animals at the zoo and Jake is say...
{ "input": [], "output": [] }
{ "input": [ "2\n1 4\n2 3" ], "output": [ "CORRECT\nWRONG" ] }
{ "input": [], "output": [] }
1085_G. Beautiful Matrix
Petya collects beautiful matrix. A matrix of size n × n is beautiful if: * All elements of the matrix are integers between 1 and n; * For every row of the matrix, all elements of this row are different; * For every pair of vertically adjacent elements, these elements are different. Today Petya bought a b...
{ "input": [ "1\n1\n", "10\n5 1 6 2 8 3 4 10 9 7\n1 9 3 6 4 5 7 2 10 8\n10 1 7 8 3 2 4 6 5 9\n7 8 10 9 6 5 2 1 4 3\n6 5 1 3 2 7 9 10 8 4\n8 2 3 7 6 1 10 5 4 9\n9 6 8 5 10 3 1 7 2 4\n1 10 9 8 7 2 4 5 3 6\n5 8 2 6 4 3 9 10 7 1\n1 7 4 3 2 10 8 6 5 9\n", "5\n1 4 2 3 5\n5 1 3 4 2\n3 2 4 1 5\n1 4 5 3 2\n5 2 3 4...
{ "input": [ "2\n2 1\n1 2\n", "3\n1 2 3\n3 1 2\n2 3 1\n", "3\n1 2 3\n2 3 1\n3 1 2\n" ], "output": [ "1\n", "3\n", "1\n" ] }
{ "input": [], "output": [] }
1252_H. Twin Buildings
As you might already know, space has always been a problem in ICPC Jakarta. To cope with this, ICPC Jakarta is planning to build two new buildings. These buildings should have a shape of a rectangle of the same size. Now, their problem is to find land to build the buildings. There are N lands available for sale. The i...
{ "input": [], "output": [] }
{ "input": [ "2\n5 5\n3 4\n", "2\n2 5\n4 3\n", "3\n10 1\n9 8\n7 6\n" ], "output": [ "\n12.5\n", "\n8.0\n", "\n42.0\n" ] }
{ "input": [], "output": [] }
240_A. Cinema
Overall there are m actors in Berland. Each actor has a personal identifier — an integer from 1 to m (distinct actors have distinct identifiers). Vasya likes to watch Berland movies with Berland actors, and he has k favorite actors. He watched the movie trailers for the next month and wrote the following information fo...
{ "input": [ "6 4\n3 4 2 1\n10\na\n4\n1 2 3 5\nbe\n3\n0 0 0\nc\n6\n1 2 3 4 5 6\ndr\n4\n5 6 0 0\ne\n6\n0 0 0 0 0 0\nff\n5\n0 0 0 0 6\ng\n2\n6 5\nfdfk\n4\n1 2 3 4\nreer\n2\n5 6\nudfyhusd\n1\n6\n", "15 15\n1 2 3 4 5 6 7 8 9 11 10 12 13 14 15\n1\nabvabab\n15\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n", "4 3\n1 3 4\n5\n...
{ "input": [ "5 3\n1 3 5\n4\njumanji\n3\n0 0 0\ntheeagle\n5\n1 2 3 4 0\nmatrix\n3\n2 4 0\nsourcecode\n2\n2 4\n", "5 3\n1 2 3\n6\nfirstfilm\n3\n0 0 0\nsecondfilm\n4\n0 0 4 5\nthirdfilm\n1\n2\nfourthfilm\n1\n5\nfifthfilm\n1\n4\nsixthfilm\n2\n1 0\n" ], "output": [ "2\n0\n1\n1\n", "2\n2\n1\n1\n1\n2\n"...
{ "input": [], "output": [] }
35_C. Fire Again
After a terrifying forest fire in Berland a forest rebirth program was carried out. Due to it N rows with M trees each were planted and the rows were so neat that one could map it on a system of coordinates so that the j-th tree in the i-th row would have the coordinates of (i, j). However a terrible thing happened and...
{ "input": [ "2000 1\n10\n1058 1 1779 1 1995 1 1398 1 96 1 1599 1 1496 1 1659 1 385 1 1485 1\n", "100 100\n4\n72 12 1 66 57 67 25 67\n", "1 10\n9\n1 1 1 2 1 3 1 4 1 6 1 7 1 8 1 9 1 10\n", "100 1\n10\n62 1 63 1 57 1 76 1 35 1 69 1 73 1 95 1 96 1 21 1\n", "5 5\n1\n1 1\n", "10 10\n3\n3 9 6 3 3 5\...
{ "input": [ "3 3\n1\n2 2\n", "3 3\n1\n1 1\n", "3 3\n2\n1 1 3 3\n" ], "output": [ "1 1\n", "3 3\n", "2 2" ] }
{ "input": [], "output": [] }
bad-odd-times
Once upon a times , there lived King Nihal who hated odd counting . He has received various gifts from different kings of other kingdoms on his birthday. There is one enemy king , and to make our king angry he will send odd number of gifts . As a sincere minister , its your task to find the enemy kingdom. Input T- n...
{ "input": [], "output": [] }
{ "input": [ "2\n\n7\n\n1 1 2 2 2 2 3\n\n5\n\n4 4 4 7 7\n\nSAMPLE" ], "output": [ "3\n4" ] }
{ "input": [], "output": [] }
lucifer-needs-help
Lucifer and Crowley being two most dangerous demons are fighting to become king of hell. A question is given to them. The one who solves it first becomes King. Given an array A of N elements and an integer M. Print YES if you find three distinct indexes i, j, k such that 1 ≤ i, j, k ≤ N and A[i]+A[j]+A[k] = M else prin...
{ "input": [ "1000 43313\n41 18467 6334 26500 19169 15724 11478 29358 26962 24464 5705 28145 23281 16827 9961 491 2995 11942 4827 5436 32391 14604 3902 153 292 12382 17421 18716 19718 19895 5447 21726 14771 11538 1869 19912 25667 26299 17035 9894 28703 23811 31322 30333 17673 4664 15141 7711 28253 6868 25547 2764...
{ "input": [ "5 10\n2 3 4 5 6\n\nSAMPLE" ], "output": [ "YES" ] }
{ "input": [], "output": [] }
service-lane-1
Calvin is driving his favorite vehicle on the 101 freeway. He notices that the check engine light of his vehicle is on, and he wants to service it immediately to avoid any risks. Luckily, a service lane runs parallel to the highway. The length of the highway and the service lane is N units. The service lane consists of...
{ "input": [], "output": [] }
{ "input": [ "8 5\n2 3 1 2 3 2 3 3\n0 3\n4 6\n6 7\n3 5\n0 7\n\nSAMPLE" ], "output": [ "1\n2\n3\n2\n1" ] }
{ "input": [], "output": [] }
1009_D. Relatively Prime Graph
Let's call an undirected graph G = (V, E) relatively prime if and only if for each edge (v, u) ∈ E GCD(v, u) = 1 (the greatest common divisor of v and u is 1). If there is no edge between some pair of vertices v and u then the value of GCD(v, u) doesn't matter. The vertices are numbered from 1 to |V|. Construct a rela...
{ "input": [ "2 2\n", "1 3\n", "3 5\n", "5 2\n", "5 6\n", "3 4\n", "4 2\n", "3 1\n", "10 31\n", "4 4\n", "1 1\n", "571 99404\n", "100000 99998\n", "530 100000\n", "4 1\n", "1 4\n", "100000 1\n", "10 32\n", "3 3\n", "5 4\n", "5 4\n", ...
{ "input": [ "5 6\n", "6 12\n" ], "output": [ "Possible\n1 2\n1 3\n1 4\n1 5\n2 3\n2 5\n", "Impossible\n" ] }
{ "input": [], "output": [] }
162_F. Factorial zeros
You are given a positive integer n. Output the number of trailing zeros in n! (n! denotes a product of integers between 1 and n, inclusive). Input The only line of input contains an integer n (1 ≤ n ≤ 1000000). Output Output the number of trailing zeros in n!. Examples Input 6 Output 1 Input 24 Output 4...
{ "input": [], "output": [] }
{ "input": [ "6\n", "24\n" ], "output": [ "1\n", "4\n" ] }
{ "input": [], "output": [] }
22_C. System Administrator
Bob got a job as a system administrator in X corporation. His first task was to connect n servers with the help of m two-way direct connection so that it becomes possible to transmit data from one server to any other server via these connections. Each direct connection has to link two different servers, each pair of se...
{ "input": [ "10 39377 1\n", "300 44553 1\n", "20 155 1\n", "300 44553 300\n", "100000 99998 1\n", "100000 0 100000\n", "200 34305 75\n", "30 393 29\n", "100 4283 65\n", "100000 99998 100000\n", "20 155 1\n", "5 6 3\n", "30 393 29\n", "123 13527 42\n", "100 ...
{ "input": [ "5 6 3\n", "6 100 1\n" ], "output": [ "3 1\n3 2\n3 4\n3 5\n2 4\n2 5\n", "-1\n" ] }
{ "input": [], "output": [] }
48_A. Rock-paper-scissors
Uncle Fyodor, Matroskin the Cat and Sharic the Dog live their simple but happy lives in Prostokvashino. Sometimes they receive parcels from Uncle Fyodor’s parents and sometimes from anonymous benefactors, in which case it is hard to determine to which one of them the package has been sent. A photographic rifle is obvio...
{ "input": [ "rock\npaper\nrock\n", "scissors\nscissors\nrock\n", "rock\nscissors\npaper\n", "rock\npaper\nscissors\n", "scissors\nscissors\nscissors\n", "scissors\nscissors\npaper\n", "scissors\npaper\npaper\n", "rock\nscissors\nrock\n", "scissors\nrock\nscissors\n", "paper\np...
{ "input": [ "scissors\nrock\nrock\n", "scissors\npaper\nrock\n", "rock\nrock\nrock\n", "paper\nrock\nrock\n" ], "output": [ "?\n", "?\n", "?\n", "F\n" ] }
{ "input": [], "output": [] }
kalas-army
King Kala the Fighter has an army of N soldiers. Each soldier is either a BanVeer or a TalwarBaaz. There are M soldiers in the army who are TalwarBaaz. The King forms a strategy. For each battle, he doesn’t have the resources to send his army in groups of more than K soldiers. Now, a group of at most K soldiers can win...
{ "input": [ "100\n22 7 426\n445 77 81\n447 141 497\n202 59 325\n482 8 417\n156 120 402\n228 33 357\n239 38 211\n179 6 340\n68 48 16\n440 423 93\n449 218 310\n355 48 431\n80 77 218\n434 44 176\n355 131 80\n422 121 11\n67 60 174\n191 155 335\n34 19 480\n221 172 1\n152 125 231\n302 95 396\n22 7 399\n107 100 432\n2 ...
{ "input": [ "3\n2 2 2\n4 2 3\n10 4 3\n\nSAMPLE" ], "output": [ "3\n11\n134" ] }
{ "input": [], "output": [] }
mishtis-castle
To defend her castle Count Mishti has invented a new challenge. In this challenge, the participant goes to a room that has n corridors and each corridor has n cells. Each cell has some coins of gold in it i.e. the jth cell of the ith corridor has a[i][j] gold coins ( 1 ≤ i ≤ n && 1 ≤ j ≤ n). The participant starts at ...
{ "input": [], "output": [] }
{ "input": [ "2\n2 7\n0 0\n8 0\n2 5\n0 1\n3 0\n\nSAMPLE" ], "output": [ "1\n-1" ] }
{ "input": [], "output": [] }
palindromic-prime
Consider the palindromic prime numbers(Numbers which are palindrome as well as prime).Let p be the product of non zero digits of a nth palindromic prime number.Let product of digits of a palindromic prime is multiplied by a number m to generate number q(q=p*m).Your task is simple; you have to find number of divisors of...
{ "input": [], "output": [] }
{ "input": [ "1\n2 1\n\nSAMPLE" ], "output": [ "2" ] }
{ "input": [], "output": [] }
1431_D. Used Markers
Your University has a large auditorium and today you are on duty there. There will be n lectures today — all from different lecturers, and your current task is to choose in which order ord they will happen. Each lecturer will use one marker to write something on a board during their lecture. Unfortunately, markers bec...
{ "input": [], "output": [] }
{ "input": [ "4\n4\n1 2 1 2\n2\n2 1\n3\n1 1 1\n4\n2 3 1 3\n" ], "output": [ "\n4 1 3 2\n1 2\n3 1 2\n4 3 2 1\n" ] }
{ "input": [], "output": [] }
724_A. Checking the Calendar
You are given names of two days of the week. Please, determine whether it is possible that during some non-leap year the first day of some month was equal to the first day of the week you are given, while the first day of the next month was equal to the second day of the week you are given. Both months should belong t...
{ "input": [ "friday\ntuesday\n", "thursday\nmonday\n", "tuesday\nsunday\n", "thursday\nsaturday\n", "saturday\nfriday\n", "thursday\nsunday\n", "monday\nsaturday\n", "saturday\nsunday\n", "saturday\nsaturday\n", "sunday\nfriday\n", "monday\nthursday\n", "thursday\nthur...
{ "input": [ "monday\ntuesday\n", "saturday\ntuesday\n", "sunday\nsunday\n" ], "output": [ "NO\n", "YES\n", "YES\n" ] }
{ "input": [], "output": [] }
joker-vs-batman
Joker is back again with his destructive plan . He has set N bombs in various parts of Gotham city and has challenged the police department to defuse all bombs in one day . City can be treated as a 1-D line with 'N' bombs situated in such a manner that distance of 1^st bomb is 'x' , 2nd bomb is ' x^2 ' , 3rd bomb...
{ "input": [ "25\n100021238 100007719 39 \n100011797 100008855 2438 \n100010450 100032285 8366 \n100028100 100005853 30613 \n100020537 100000281 1143 \n100026285 100008945 15922 \n100020976 100014680 2998 \n100025906 100021655 31892 \n100028881 100001323 18458 \n100032278 100009725 2241 \n100000840 100000590 2447...
{ "input": [ "5\n1 1 10\n2 2 10\n2 5 3\n2 8 100\n10 1 10\n\nSAMPLE" ], "output": [ "2\n2\n0\n44\n0" ] }
{ "input": [], "output": [] }
p01174 Rotation Estimation
Mr. Nod is an astrologist and has defined a new constellation. He took two photos of the constellation to foretell a future of his friend. The constellation consists of n stars. The shape of the constellation in these photos are the same, but the angle of them are different because these photos were taken on a differen...
{ "input": [], "output": [] }
{ "input": [ "3\n0.0 0.0\n1.0 1.0\n0.0 1.0\n3.0 3.0\n2.0 2.0\n3.0 2.0\n0" ], "output": [ "3.14159265359" ] }
{ "input": [], "output": [] }
p01640 Get Lost
ICPC World Finals Day 5 Mr. Tee got lost in the city of R country. The trouble is that the streets are similar, so I have no idea where I am now. Country R is "sorry", so you have to return to the hotel before being attacked by the enemy. Fortunately, I only remember how it turned, so let's go random. problem \\ (w ...
{ "input": [], "output": [] }
{ "input": [ "w h g" ], "output": [ "9" ] }
{ "input": [], "output": [] }
p02064 Restore Shortest Path
E: Restoration of shortest path story Competition programmers solve the shortest path problem every day. BFS, Bellman Ford, Dijkstra, Worshall Floyd and many other algorithms are also known. Meanwhile, you had a shortest path problem that you couldn't solve. It's a problem of solving the shortest path problem withou...
{ "input": [], "output": [] }
{ "input": [ "" ], "output": [ "" ] }
{ "input": [], "output": [] }
devperf
There is a haunted town called HauntedLand. The structure of HauntedLand can be thought of as a grid of size n * m. There is a house in each cell of the grid. Some people have fled from their houses because they were haunted. '.' represents a haunted house whereas '*' represents a house in which people are living. On...
{ "input": [], "output": [] }
{ "input": [ "2\n2 2\n*.\n..\n3 4\n.*..\n***.\n.*.." ], "output": [ "1\n2" ] }
{ "input": [], "output": [] }
insm06
Ronak’s class teacher gives him an NxN matrix. Then, she gives him M numbers. Every number is an angle, the angle by which he has to rotate the matrix in clockwise direction. (The angles are multiples of 90.) Help him with the task. Input First line consists of two numbers N and M. The following N lines contain ...
{ "input": [], "output": [] }
{ "input": [ "4 2\n1 2 3 4\n4 5 6 7\n6 8 4 3\n8 1 4 7\n90\n180" ], "output": [ "8 6 4 1\n1 8 5 2\n4 4 6 3\n7 3 7 4\n\n7 4 1 8\n3 4 8 6\n7 6 5 4\n4 3 2 1" ] }
{ "input": [], "output": [] }
shil-and-special-pairs
Shil has a permutation p1 , p2 .. pN of numbers from 1 to N and M queries. Each query consists of two integers l and r . Answer to each query is total number of pairs[i , j] such that l ≤ i ≤ j ≤ r and|pi - pj| ≤ D. INPUT: First line consists of three integers N, M and D. Next line consists of permutation p1 , p2 .....
{ "input": [ "10 10 10\n2 4 3 8 10 5 6 9 7 1 \n2 8\n3 6\n8 10\n2 10\n1 5\n5 8\n3 7\n1 1\n4 9\n3 7", "1000 1000 5\n935 618 39 130 233 137 622 443 296 385 876 480 371 611 8 657 55 496 895 715 900 431 260 941 646 411 246 683 903 689 641 257 186 525 3 717 422 432 206 512 33 636 297 393 202 699 221 587 207 252 894...
{ "input": [ "5 5 1\n1 4 2 3 5\n1 3\n2 4\n1 5\n2 2\n4 5\n\nSAMPLE" ], "output": [ "4\n5\n9\n1\n2" ] }
{ "input": [], "output": [] }
the-magician-17
Robert Angier is divising a new magic trick to beat his rival Alfred Borden. He is going to perform a card trick. In this trick, cards are numbered from 1 to N. This trick involves the following process. Angier will invite a person from audience to shuffle the cards in random order. Following is defined as a sing...
{ "input": [ "100\n12139932 8204607\n17895021 4804015\n10313563 2949333\n18903682 12991388\n12277685 7851062\n16564285 11912406\n11735990 3940294\n15197314 9561603\n14754116 11963033\n15641892 15138874\n17395528 12083184\n17897525 9837566\n10651136 7845681\n17889618 2415912\n10170337 5315998\n10506582 7227892\n19...
{ "input": [ "1\n6 6\n\nSAMPLE" ], "output": [ "4" ] }
{ "input": [], "output": [] }
dream
The Chef is sleeping now. He tries to cook new kind of meals in his dream. These meals are arranged in a row and numbered from 1 to N consecutively. For each meal i (1<=i<=N) there is given one integer f(i) which denotes the time needed to cook it. Initially, all meals are uncooked. Each assistant of The Chef (the...
{ "input": [], "output": [] }
{ "input": [ "5 3\n40 30 40 30 40" ], "output": [ "3" ] }
{ "input": [], "output": [] }
1302_B. DAG
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 a directed acyclic graph G with n vertices and m edges. Denote by R(v) the set of all vertices u reachable from v by moving along the edges of G. Find ∑_...
{ "input": [], "output": [] }
{ "input": [ "5 4\n1 2\n2 3\n3 4\n4 5\n", "12 6\n1 2\n3 4\n5 6\n8 7\n10 9\n12 11\n", "7 6\n1 2\n1 3\n2 4\n2 5\n3 6\n3 7\n" ], "output": [ "\n55\n", "\n30\n", "\n45\n" ] }
{ "input": [], "output": [] }
1_C. Ancient Berland Circus
Nowadays all circuses in Berland have a round arena with diameter 13 meters, but in the past things were different. In Ancient Berland arenas in circuses were shaped as a regular (equiangular) polygon, the size and the number of angles could vary from one circus to another. In each corner of the arena there was a spec...
{ "input": [ "76.820252 66.709341\n61.392328 82.684207\n44.267775 -2.378694\n", "6.949504 69.606390\n26.139268 72.136945\n24.032442 57.407195\n", "36.856072 121.845502\n46.453956 109.898647\n-30.047767 77.590282\n", "-7.347450 36.971423\n84.498728 89.423536\n75.469963 98.022482\n", "88.653021 18.0...
{ "input": [ "0.000000 0.000000\n1.000000 1.000000\n0.000000 1.000000\n" ], "output": [ "1.0\n" ] }
{ "input": [], "output": [] }
530_I. Different variables
N variables X1, ..., XN can have positive integer values. You are given K constraints for these value that look like "the values of variables Xi1, Xi2, ..., XiM are different". Among all possible lists of values of these variables that satisfy these constraints select the ones which have minimum possible max(Xi). Outpu...
{ "input": [], "output": [] }
{ "input": [ "2 1\n2 1 2\n", "3 2\n2 1 2\n2 2 3\n" ], "output": [ "1 2\n", "1 2 1\n" ] }
{ "input": [], "output": [] }
count-strings-1
This task is very simple.You are given two string A and B and you have to find how many times you can form string B from string A. You are only allow to delete some character from string A and Change postion of characters .You are not allow to use same index character of A two times in the same string to form string B....
{ "input": [], "output": [] }
{ "input": [ "1\naba \nab\n\nSAMPLE" ], "output": [ "2" ] }
{ "input": [], "output": [] }
maximum-resistance-5
PIET's EC department students are working on a set of conductors to create a circuit with maximum resistance. The simplest circuit consists of a single conductor (i.e., a single piece of wire). Each such circuit is labeled using the string "X". Students are using two different ways to connect two simpler circuits int...
{ "input": [], "output": [] }
{ "input": [ "3\nBXBXX\n8 2 3\nAAXXAXAXX\n1 1 2 8 10\nAXBXX\n8 2 3\n\nSAMPLE" ], "output": [ "8\n22\n11" ] }
{ "input": [], "output": [] }
order-was-the-dream-of-man-8
Sanket is a very organized person. He likes to organize everything to increase his efficiency. Whenever he sees a list of numbers he like to tag the number in ascending order. Recently he has realized he is wasting a lot of time doing that and thus want you to help him do it faster. Given a list of numbers [23, 45, 87,...
{ "input": [ "20\n48\n486441203 -791436838 -166642692 -852034963 527740218 -512926491 -86105846 991091599 886995564 824413456 685129673 -485229085 540221719 -671879587 314599913 -301530935 -997325919 673620451 765273549 605462219 -342213578 -977281254 800421796 248849813 -103382241 -618408357 -193854374 -46789774...
{ "input": [ "2 \n7 \n23 45 87 34 13 76 34 \n3 \n20 40 10\n\nSAMPLE" ], "output": [ "1 3 5 2 0 4 2 \n1 2 0" ] }
{ "input": [], "output": [] }
coolguys
Given an integer N. Integers A and B are chosen randomly in the range [1..N]. Calculate the probability that the Greatest Common Divisor(GCD) of A and B equals to B. Input The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows. Each test case consis...
{ "input": [], "output": [] }
{ "input": [ "3\n1\n2\n3" ], "output": [ "1/1\n3/4\n5/9" ] }
{ "input": [], "output": [] }
1250_I. Show Must Go On
The director of the famous dance show plans a tour. It is already decided that the tour will consist of up to m concerts. There are n dancers in the troupe. Each dancer is characterized by her awkwardness: the awkwardness of the i-th dancer is equal to a_i. The director likes diversity. For this reason, each concert ...
{ "input": [], "output": [] }
{ "input": [ "3\n7 13 10\n3 1 5 1 8 2 13\n2 10 1\n12 12\n3 32 100000\n2 1 5\n" ], "output": [ "\n10\n5 12\n4 7\n4 9\n4 10\n4 11\n4 11\n4 12\n4 13\n3 4\n3 5\n2 4 1 \n0\n7\n3 8\n2 3\n2 6\n2 7\n1 1\n1 2\n1 5\n3 \n" ] }
{ "input": [], "output": [] }
p01701 North North West
Problem Statement We can describe detailed direction by repeating the directional names: north, south, east and west. For example, northwest is the direction halfway between north and west, and northnorthwest is between north and northwest. In this problem, we describe more detailed direction between north and west a...
{ "input": [], "output": [] }
{ "input": [ "north\nwest\nnorthwest\nnorthnorthwest\nwestwestwestnorth\n#" ], "output": [ "0\n90\n45\n45/2\n315/4" ] }
{ "input": [], "output": [] }
direl
Chef is giving a big party to all his friends and their relatives. Relatives of very far-away (by relation) will be present. Little Joe (uninvited) is curious to know how distant two people are, say X and Y. There are 6 fundamental relations: father relation, mother relation, son relation, daughter relation, brother re...
{ "input": [], "output": [] }
{ "input": [ "8 7\ntom is brother of ron\nron is brother of john\njohn is father of kel\nkel is son of cloe\ncloe is sister of ru\nanne is daughter of cloe\nru is mother of fred\n5\nkel john\nron kel\njohn ru\njohn kel\njohn anne" ], "output": [ "1\n2\n3\n1\n1" ] }
{ "input": [], "output": [] }
insomb6
A set of N dignitaries have arrived in close succession at Delhi and are awaiting transportation to Roorkee to participate in the inaugural ceremony of Cognizance. Being big sponsors of Cognizance, it has been deemed unsuitable by the organizing team to arrange for more than one dignitary to travel in a single vehicle....
{ "input": [], "output": [] }
{ "input": [ "4\nDivye\nRohit\nAkshat\nParth\nScorpio\nBMW\nFord\nChevrolet\n1 BMW\n1 Ford\n2 Scorpio Chevrolet\n1 Ford" ], "output": [ "No" ] }
{ "input": [], "output": [] }
409_D. Big Data
Little Petya wanted to give an April Fools Day present to some scientists. After some hesitation he decided to give them the array that he got as a present in Codeforces Round #153 (Div.2). The scientists rejoiced at the gift and decided to put some important facts to this array. Here are the first few of the facts: ...
{ "input": [ "2\n", "11\n", "15\n", "13\n", "14\n", "16\n", "12\n", "5\n", "9\n", "8\n", "4\n", "6\n", "3\n", "10\n" ], "output": [ "0", "0", "1", "1", "0", "0", "0", "0", "1", "1", "1", "1", "0", "1" ...
{ "input": [ "7\n", "1\n" ], "output": [ "0", "1" ] }
{ "input": [], "output": [] }
555_A. 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": [ "3 2\n1 2\n2 1 3\n", "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...
{ "input": [ "3 2\n2 1 2\n1 3\n", "7 3\n3 1 3 7\n2 2 5\n2 4 6\n" ], "output": [ "1", "10" ] }
{ "input": [], "output": [] }
64_D. Presents
You are given the prices of three presents. Also there are three sisters. It is known that the most valuable present is for the eldest sister. The second (by price) is for the second sister. And the less valuable present is for the youngest sister. If two (or three) presents have the same price, corresponding sisters m...
{ "input": [], "output": [] }
{ "input": [ "11 13 1\n", "30 10 30\n" ], "output": [ "2 1 3 ", "1 3 2 " ] }
{ "input": [], "output": [] }
benny-and-the-universe
Hope you still have not forgotten about pig Benny. She is asking for help again. This time you have to answer some queries that Benny will give you. All actions happen in the Universe where each planet has its own id starting from 0. There are infinite amount of planets. To travel between different planets there ...
{ "input": [ "3 10\n3 4 7\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10" ], "output": [ "NO\nNO\nYES\nYES\nNO\nYES\nYES\nYES\nYES\nYES" ] }
{ "input": [], "output": [] }
{ "input": [], "output": [] }
fest03
Golu is a student of Computer Engineering and he decided to make a project for himself.So he started working on URL shortner.While working on project he got confused.You are a good friend of Golu so he asked you for help. You have given a link and you have to convert it into a short link using algorithm given by Golu. ...
{ "input": [], "output": [] }
{ "input": [ "3\ncodechef.com\nfacebook.com/home/\nssss" ], "output": [ "ocul.in/c3e2o2\nocul.in/o4c2e2\nocul.in/s4a0a0" ] }
{ "input": [], "output": [] }
100_C. A+B
Bijan is new to programming. He learned recently that programmers do not code every bit of their apps from scratch. For example they never write a code to sum two integers, because their languages have the ability to do the sum. But can they use it? Can an experienced coder who has attended more than 100 contests, sum...
{ "input": [], "output": [] }
{ "input": [ "2\n3\n", "1390\n2011\n", "12345\n54321\n" ], "output": [ "5\n", "3401\n", "66666\n" ] }
{ "input": [], "output": [] }
589_d
Welcoming autumn evening is the best for walking along the boulevard and n people decided to do so. The boulevard can be represented as the axis Ox. For every person there are three parameters characterizing the behavior: ti, si, fi — the moment of time when the i-th person starts walking, the start point and the end ...
{ "input": [ "10\n574159 311905 962312\n419776 161298 821630\n659552 209764 24964\n780839 173140 729956\n948170 866093 684140\n491331 794924 114469\n650256 734793 255253\n212264 188561 695744\n751383 98389 133342\n305528 97316 755019", "10\n3 3 2\n3 1 3\n3 2 3\n1 2 3\n1 1 3\n2 3 1\n2 3 2\n2 1 2\n3 2 3\n3 3 1"...
{ "input": [ "3\n3 2 4\n4 3 4\n3 6 4", "3\n1 1 10\n5 8 2\n9 9 10" ], "output": [ "2 2 2", "2 1 1" ] }
{ "input": [], "output": [] }
611_A. New Year and Days
Today is Wednesday, the third day of the week. What's more interesting is that tomorrow is the last day of the year 2015. Limak is a little polar bear. He enjoyed this year a lot. Now, he is so eager to the coming year 2016. Limak wants to prove how responsible a bear he is. He is going to regularly save candies for ...
{ "input": [ "25 of month\n", "6 of week\n", "8 of month\n", "10 of month\n", "28 of month\n", "17 of month\n", "26 of month\n", "29 of month\n", "6 of month\n", "31 of month\n", "24 of month\n", "2 of month\n", "11 of month\n", "23 of month\n", "27 of month...
{ "input": [ "4 of week\n", "30 of month\n" ], "output": [ "52", "11" ] }
{ "input": [], "output": [] }
bytelandian-conversions
In Byteland,conversion of numbers between different bases has always been a herculian task.They always make errors in these conversions. People in Byteland always write one of the digits wrong when they convert a number to a new base and write it down. For example, when they convert the number 56 into binary (base 2...
{ "input": [], "output": [] }
{ "input": [ "1010\n212\n\nSAMPLE" ], "output": [ "14" ] }
{ "input": [], "output": [] }
kevin-doesnt-like-his-array
Link to Russian translation of the problem. Kevin has an array A of N integers, but he doesn't like it - he only likes an array if all its neighboring elements are different (e.g. he likes the array [2,4,2,5,3,2,4], but not [1,2,3,3,4]). Kevin can reverse any contiguous subarray of his array any number of times. For ...
{ "input": [ "1000\n29622 4608 4588 29622 4597 4563 29622 29622 29622 4563 29622 29622 4570 29622 4577 29622 29622 4578 29622 29622 29622 4589 29622 4591 4602 29622 29622 4608 29622 29622 4577 29622 29622 29622 29622 29622 4576 4606 29622 4571 29622 29622 4568 29622 29622 29622 29622 29622 4584 4602 29622 29622 2...
{ "input": [ "7\n1 3 2 2 4 4 4\n\n\nSAMPLE" ], "output": [ "2" ] }
{ "input": [], "output": [] }
unique-ranking
The end sem exams at are over. Sneh is the class teacher of class X/C. She now has the hectic task of preparing the report card of her class. Since Sneh is a computer teacher she tried to infuse some fun into his task. Sneh knew that there are n students in class and they had k subjects. Subjects are numbered from 1 t...
{ "input": [ "1000 20\n2 1 1 4 4 3 4 2 2 3 2 1 4 4 2 1 3 3 3 2 \n1 2 2 4 3 4 3 1 3 4 4 1 3 2 2 1 3 2 1 3 \n2 1 2 1 4 1 3 4 2 4 3 2 2 2 3 3 1 2 4 1 \n2 3 1 2 1 4 3 3 4 2 3 2 1 1 4 3 4 4 3 2 \n2 1 3 3 2 4 4 3 2 2 2 3 2 1 1 3 1 2 4 1 \n4 4 2 2 3 3 4 3 4 3 1 4 3 2 3 1 4 3 2 1 \n3 4 2 4 1 3 3 4 2 4 4 4 2 2 2 3 4 3 2 2...
{ "input": [ "3 3\n50 60 70\n40 60 80\n50 60 61\n3\n3 1 2 3\n1 2\n2 3 1\n\nSAMPLE" ], "output": [ "2\n1\n3" ] }
{ "input": [], "output": [] }
p01332 Three Silhouettes
JAVA (Japan Aerospace Voyage Agency) launched a spacecraft in 2003 as part of its space development project. One of the purposes of launching this spacecraft is to approach the asteroid Ishikawa and collect samples of its surface material. Despite various accidents, the spacecraft reached Ishikawa and finally returned ...
{ "input": [], "output": [] }
{ "input": [ "4\n0 0\n100 0\n100 100\n0 100\n4\n0 0\n100 0\n100 100\n0 100\n4\n0 0\n100 0\n100 100\n0 100\n3\n0 0\n100 0\n0 100\n3\n0 0\n100 0\n0 100\n3\n0 0\n100 0\n0 100\n5\n0 0\n200 0\n200 200\n100 100\n0 200\n5\n0 0\n200 0\n100 100\n200 200\n0 200\n4\n0 0\n200 0\n200 200\n0 200\n0\n0\n0", "4\n0 0\n100 0\n...
{ "input": [], "output": [] }
1170_D. Decoding of Integer Sequences
Polycarp is developing a method for transmitting n integer sequences over a network. This method should support the transmission of an arbitrary number of integer sequences; sequences can have different lengths. The sequences contain arbitrary non-negative integers. Polycarp developed the following encoding procedure:...
{ "input": [], "output": [] }
{ "input": [ "12\n3 2 1 1 7 2 4 -1 3 -1 4 -1\n", "6\n2 -1 2 -1 3 -1\n" ], "output": [ "\n3\n3 3 1 4\n2 2 7\n4 1 2 3 4\n", "\n3\n1 2\n0\n2 2 3\n" ] }
{ "input": [], "output": [] }
1250_A. Berstagram
Polycarp recently signed up to a new social network Berstagram. He immediately published n posts there. He assigned numbers from 1 to n to all posts and published them one by one. So, just after publishing Polycarp's news feed contained posts from 1 to n — the highest post had number 1, the next one had number 2, ..., ...
{ "input": [], "output": [] }
{ "input": [ "3 5\n3 2 1 3 3\n", "10 6\n7 3 5 7 3 6\n" ], "output": [ "\n1 2\n2 3\n1 3\n", "\n1 2\n2 3\n1 3\n4 7\n4 5\n6 7\n5 7\n8 8\n9 9\n10 10\n" ] }
{ "input": [], "output": [] }
188_F. Binary Notation
You are given a positive integer n. Output its binary notation. Input The only line of input data contains an integer n (1 ≤ n ≤ 106). Output Output the binary notation of n (without any leading zeros). Examples Input 5 Output 101 Input 101 Output 1100101 Note In the first example 5 = 1 * 22 + 0 * 21 ...
{ "input": [], "output": [] }
{ "input": [ "5\n", "101\n" ], "output": [ "101\n", "1100101\n" ] }
{ "input": [], "output": [] }
470_E. Chessboard
Chessboard is a board of n × n squares arranged in two alternating colors (black and white). Top left square is white. You are given board size n. Output an image of a chessboard, with black and white squares marked with '#' and '.' characters, respectively. Input The only line of input contains an integer n (1 ≤ n ≤...
{ "input": [], "output": [] }
{ "input": [ "4\n" ], "output": [ ".#.#\n#.#.\n.#.#\n#.#.\n" ] }
{ "input": [], "output": [] }
775_A. University Schedule
In this problem your task is to come up with a week schedule of classes in university for professors and student groups. Consider that there are 6 educational days in week and maximum number of classes per educational day is 7 (classes numerated from 1 to 7 for each educational day). It is known that in university n s...
{ "input": [], "output": [] }
{ "input": [ "3 3 1\n1 0 0\n0 1 0\n0 0 1\n", "3 1 1\n1\n1\n1\n", "5 7 10\n1 3 6 0 1 2 4\n0 3 0 6 5 1 4\n3 5 1 2 3 2 4\n2 3 1 1 4 1 2\n2 4 3 2 4 3 2\n" ], "output": [ "54\n\n1 0 0 0 0 0 \n0 0 0 0 0 0 \n0 0 0 0 0 0 \n0 0 0 0 0 0 \n0 0 0 0 0 0 \n0 0 0 0 0 0 \n0 0 0 0 0 0 \n\n0 0 0 0 0 0 \n2 0 0 0 0 0...
{ "input": [], "output": [] }
867_F. Hex Dyslexia
Copying large hexadecimal (base 16) strings by hand can be error prone, but that doesn't stop people from doing it. You've discovered a bug in the code that was likely caused by someone making a mistake when copying such a string. You suspect that whoever copied the string did not change any of the digits in the string...
{ "input": [ "ffc7457d777777\n", "33333\n", "f07ffffffffff8\n", "ffeb7457777777\n", "ddc41767777777\n", "e677fe7f678f68\n", "0ecdedefefdc1\n", "11111111111112\n", "555\n", "ffffffffffffff\n", "7e777777777777\n", "31111110111111\n", "896741cab3e5d2\n", "deeeeeeee...
{ "input": [ "12d2c\n", "0f1e\n", "f1e\n" ], "output": [ "00314\n", "00f1\n", "NO\n" ] }
{ "input": [], "output": [] }
direrctory
Lexicographical order is a generalization of the way the alphabetical order of words is based on the alphabetical order of their component letters. An example of lexicographical arrangement is a dictionary or a contact directory. You are given some names, and your task is to arrange these names in lexicographical orde...
{ "input": [ "Bruce XXII\nHenri XX\nMaru XXXVI\nPhilippe XL\nLou XVI\nLovro XVI\nKubus XXXII\nMaru XXXIX\nBob XXXVIII\nRichard XXXIX\nCarlos II\nJames XXXIII\nAnne XXIV\nAnne XXVI\nPhilip XLVII\nIlya III\nKubus XLII\nJulka XIX\nMary XLVII\nLukas XVIII\nZemco L\nRichard II\nAnicka XXXVII\nGenadij XXXII\nIvan XXI\n...
{ "input": [], "output": [] }
{ "input": [], "output": [] }
playing-with-numbers
Sherlock and Watson are close friends. One day, they finally got bored of playing normal games. So, they came up with a new idea of playing with numbers. Since they are good at number theory, they know the fact that a decimal number "A" can be represented as sum of 2's powers. For example: 22 = 16 + 4 + 2 = 2^4...
{ "input": [], "output": [] }
{ "input": [ "2\n1\n2\n\nSAMPLE" ], "output": [ "Sherlock\nSherlock" ] }
{ "input": [], "output": [] }
alpha
Tanish loves alphabets. He loves alphabets so much that he ignores all other characters. Also, whenever he is given an alphabet he gives the next alphabet in alphabetical order in same case. For example, for a-b,for d-e,for z-a. Given a string guess what would be Tanish's answer. Input The first line of the input co...
{ "input": [], "output": [] }
{ "input": [ "4\nnun123\n1234\nretA34\n^ 56az" ], "output": [ "ovo\n\nsfuB\nba" ] }
{ "input": [], "output": [] }
cheftma
Chef spent N days working really hard! He planned loads of tasks: as many as Ai tasks to do on the ith day! Chef's work was brutal, so he only managed to finish Bi tasks on the ith day. The good news is that Chef has a Time Machine! The Time Machine has K white buttons and M black buttons. Each button has a positive i...
{ "input": [], "output": [] }
{ "input": [ "1\n4 2 2 \n5 7 6 1\n3 3 1 1\n6 3\n1 4" ], "output": [ "3" ] }
{ "input": [], "output": [] }
ketswap
You need to shuffle a series of numbers from 1 To T, inclusive. The numbers are in ascending order, you have to shuffle them using bubble sort algorithm, that is swap every time a number is greater than another in the given list in the input. A number is greater than another in the list if the number appears later than...
{ "input": [], "output": [] }
{ "input": [ "1\n3\n2 1 3\nabac" ], "output": [ "1" ] }
{ "input": [], "output": [] }
1302_F. Keep talking and nobody explodes – easy
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 have the safe lock which consists of 5 decimal digits. If you rotate some digit, it increases by one, except 9 which becomes 0. Initially, the lock contains numbe...
{ "input": [], "output": [] }
{ "input": [ "00000\n", "12345\n" ], "output": [ "\n61376\n", "\n07769\n" ] }
{ "input": [], "output": [] }
345_B. Triskaidekaphobia
Triskaidekaphobia is a fear of number 13. Ordinary people who suffer from this phobia feel uncomfortable around numbers 13, 130, 513 etc, but you, being a programmer, take this fear one step further. For example, consider number 7. It's ok when written in decimal, but written in base 4 it becomes 13, the dreadful numbe...
{ "input": [], "output": [] }
{ "input": [ "7\n", "100\n", "13\n" ], "output": [ "1\n", "13\n", "-1\n" ] }
{ "input": [], "output": [] }
binary-strings
Golu hates odd numbers. When he learns about binary strings he wants to find out how many binary strings of given length N exist without an odd number of consecutive 1's. For example: For N=4 1001,1010,1110,0001 are strings which contain odd number of 1's where 1100,1111 are not. Leading zeros are allowed. This task ...
{ "input": [ "10\n42\n18468\n6335\n26501\n19170\n15725\n11479\n29359\n26963\n24465", "10\n42\n18468\n6335\n26501\n19170\n15725\n11479\n29359\n26963\n24465" ], "output": [ "433494437\n784821591\n46056713\n643487252\n102481819\n568970065\n685918415\n977059070\n667873071\n800362026", "433494437\n7848...
{ "input": [ "1\n2\n\nSAMPLE" ], "output": [ "2" ] }
{ "input": [], "output": [] }
irctc
Good news , You have a chance to work in IRCTC as a software developer . Applications are required with a program for railway sites . sid of a station is a something which uniquely defines it . Given N station's sid from 1 to N and distance between any two stations , if any person wants to go from station having sid A...
{ "input": [], "output": [] }
{ "input": [ "2\n6 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1\n1 3 6\n10 10\n1 5 78\n1 8 221\n2 7 92\n2 8 159\n3 5 55\n3 6 179\n3 10 237\n4 8 205\n5 6 191\n8 10 157\n6 3 2\n\nSAMPLE" ], "output": [ "No Train Found.\n692\n6 3 5 1 8 2" ] }
{ "input": [], "output": [] }
ranking-4
Ravi, a student of a primary class, is unable to understand the ranking system of his school. The ranking system is as: If two students of the class get equal marks, they are given the same rank but students with different marks are given the rank as the (number of students above him + 1). See the example for more cla...
{ "input": [ "50\n100\n11716 9969 39019 65619 25496 99052 63544 10641 2342 24977 67576 78862 42476 3636 8061 14234 60443 14982 31503 53567 13672 13914 16763 72510 97088 77285 7793 2646 19985 86772 87075 31700 13092 42445 13670 54939 41496 77213 65580 60189 2189 49507 39050 44664 53142 47111 75250 29936 62092 2310...
{ "input": [ "1\n5\n98 68 74 21 74\n\nSAMPLE" ], "output": [ "1 4 2 5 2" ] }
{ "input": [], "output": [] }
snack-ruiner
In India IPL is on full swing now. Fans of cricket love watching the game and seeing ball by ball with having Snacks. Yummy, crispy snacks. Ankit and his friends are one of them. One night, while watching his Favourite team's Match he is eating Snacks. His team is leading the game and so his enjoyment growing ball by ...
{ "input": [ "15\n9\n0.21 0.43 0.23 0.67 0.39 0.8 0.1 0.4 0.3\n0.9 0.3 0.1 0.5 0.8 0.2 0.7 0.6 0.4\n4\n0.111 0.222 0.333 0.444\n0.1 0.2 0.3 0.4\n7\n0.567 0.56 0.68 0.84 0.864 0.274 0.978\n0.275 0.74 0.378 0.48 0.56 0.58 0.123\n5\n0.2 0.56 0.12 0.89 0.34\n0.1 0.2 0.34 0.0 0.8\n3\n0.3 0.67 0.23\n0.99 0.12 0.45\n9\n...
{ "input": [ "1\n3\n0.2 0.3 0.1\n0.5 0.6 0.9\n\nSAMPLE" ], "output": [ "1 0.486" ] }
{ "input": [], "output": [] }
p00425 Dice
The dice are placed in the orientation shown in the figure below. <image> As shown in this figure, the dice used here have 1 on the upper side and 2 on the south side, and 3 on the east side. Since the sum of the facing faces of the dice is always 7, the invisible faces are 5 on the north side, 4 on the west side, a...
{ "input": [], "output": [] }
{ "input": [ "5\nNorth\nNorth\nEast\nSouth\nWest\n8\nWest\nNorth\nLeft\nSouth\nRight\nNorth\nLeft\nEast\n0" ], "output": [ "21\n34" ] }
{ "input": [], "output": [] }
cw6
Ayan's favourite musical instrument is the keyboard. He practices regularly as well, you can hear him playing even at 3 or 4 in the night. Unfortunately, he got into a fight in his room and his keyboard was damaged beyond repair. However, being a rich fellow he quickly ordered another one. But this time he felt a bit a...
{ "input": [], "output": [] }
{ "input": [ "2\nE G S\nS d f" ], "output": [ "Minor\nMajor" ] }
{ "input": [], "output": [] }
icq3
Sorting is considered to be one of the most important skills to be learned in computer science and has it's applications in real product building. The problem has arised to the team of PcCube.They need to sort the set of alphanumeric strings in such a way that the positions of alphabets and numbers remains unchanged.  ...
{ "input": [], "output": [] }
{ "input": [ "1\n951f5gd3" ], "output": [ "135d5fg9" ] }
{ "input": [], "output": [] }
1211_E. Double Permutation Inc.
Polycarp recently became an employee of the company "Double Permutation Inc." Now he is a fan of permutations and is looking for them everywhere! A permutation in this problem is a sequence of integers p_1, p_2, ..., p_k such that every integer from 1 to k occurs exactly once in it. For example, the following sequence...
{ "input": [], "output": [] }
{ "input": [ "5\n1 2 3 2 1\n", "3\n1 1 1\n", "10\n3 3 2 2 5 4 1 5 4 1\n", "10\n3 9 3 1 2 1 2 4 4 4\n" ], "output": [ "\nRBBBG\n", "\nBBB\n", "\nRGRGRRRGGG\n", "\nRBGRRGGBBB\n" ] }
{ "input": [], "output": [] }