name
stringlengths
2
82
description
stringlengths
42
10.5k
private_tests
dict
public_tests
dict
generated_tests
dict
998_E. Sky Full of Stars
On one of the planets of Solar system, in Atmosphere University, many students are fans of bingo game. It is well known that one month on this planet consists of n^2 days, so calendars, represented as square matrix n by n are extremely popular. Weather conditions are even more unusual. Due to the unique composition o...
{ "input": [ "7\n", "20\n", "24\n", "8\n", "1100\n", "14\n", "100002\n", "26\n", "25\n", "500\n", "28\n", "5\n", "9\n", "10\n", "17\n", "401230\n", "11\n", "23\n", "4\n", "16\n", "18\n", "30\n", "13\n", "21\n", "591899...
{ "input": [ "2\n", "3\n", "1\n" ], "output": [ "63\n", "9933\n", "3\n" ] }
{ "input": [], "output": [] }
prom06
Damian Wayne and Carrie Kelly are classmates and best friends. Since class 5, they have been in the same section. They usually sat on the last bench so that they could chat all they want during the class. One day, during the ancient martial arts period, Master Kirigi caught them and asked Damian to sit in the first ben...
{ "input": [], "output": [] }
{ "input": [ "2\ndie another day.\ni'm batman." ], "output": [ "v0w s56bzw9 vsg.\n0'4 tsb4s5." ] }
{ "input": [], "output": [] }
153_C. Caesar Cipher
Caesar cipher is one of the simplest encryption techniques. To transform the original message into encrypted one using key k, one has to replace each letter with a letter which is k positions later in the alphabet (if this takes the position beyond Z, the rest of it is counted from the start of the alphabet). In a more...
{ "input": [ "5\nCODEFORCES\n", "13\nFALSERULEZ\n" ], "output": [ "HTIJKTWHJX\n", "SNYFREHYRM\n" ] }
{ "input": [ "CODEFORCES\n5\n", "WIXYZILWYM\n6\n" ], "output": [ "HTIJKTWHJX\n", "CODEFORCES\n" ] }
{ "input": [], "output": [] }
188_B. A + Reverse B
You are given numbers a and b. Calculate the sum of a and reverse of b. A reverse of a number is a number which contains the same digits in reverse order. For example, reverse of 230 is 32, and reverse of 0 is 0. Input The input contains two integers a and b (0 ≤ a, b ≤ 109), separated by a single space. The numbers ...
{ "input": [], "output": [] }
{ "input": [ "5 15\n", "73 9180\n" ], "output": [ "56\n", "892\n" ] }
{ "input": [], "output": [] }
378_A. Playing with Dice
Two players are playing a game. First each of them writes an integer from 1 to 6, and then a dice is thrown. The player whose written number got closer to the number on the dice wins. If both payers have the same difference, it's a draw. The first player wrote number a, the second player wrote number b. How many ways ...
{ "input": [ "6 5\n", "1 4\n", "4 1\n", "2 6\n", "1 3\n", "5 1\n", "4 4\n", "2 3\n", "5 6\n", "2 1\n", "4 6\n", "1 6\n", "1 1\n", "4 5\n", "6 6\n", "5 2\n", "6 2\n", "5 4\n", "4 2\n", "2 2\n", "3 6\n", "6 3\n", "5 5\n", "3...
{ "input": [ "2 5\n", "2 4\n" ], "output": [ "3 0 3\n", "2 1 3\n" ] }
{ "input": [], "output": [] }
470_A. Crystal Ball Sequence
Crystal ball sequence on hexagonal lattice is defined as follows: n-th element is the number of lattice points inside a hexagon with (n + 1) points on each side. The formula is Hn = 3·n·(n + 1) + 1. You are given n; calculate n-th element of the sequence. Input The only line of input contains an integer n (0 ≤ n ≤ 9)...
{ "input": [ "2\n", "5\n" ], "output": [ "4\n", "16\n" ] }
{ "input": [ "1\n", "3\n" ], "output": [ "7\n", "37\n" ] }
{ "input": [], "output": [] }
chandler-and-joey
Chandler and Joey Joey and Chandler got bored of playing foosball, so they thought of trying something new.As Joey is very intelligent so he invented a new game to play. The rules are as follows. First, they get a set of n distinct integers. And then they take turns to make the following moves. During each move, eithe...
{ "input": [ "10\n100\n84855875 84874301 84862168 84882334 84875003 84871558 84867312 84885192 84882796 84880298 84861539 84883979 84879115 84872661 84865795 84856325 84858829 84867776 84860661 84861270 84888225 84870438 84859736 84855987 84856126 84868216 84873255 84874550 84875552 84875729 84861281 84877560 848...
{ "input": [ "2\n2\n1 2\n2\n5 3\n\nSAMPLE" ], "output": [ "Chandler 0\nJoey 7" ] }
{ "input": [], "output": [] }
digit
This problem is as simple as short. Just find how many numbers from A to B with sum of digits from X to Y are divisible by K. Input The first line contains 5 space-separated positive integers: A, B, X, Y, K Output Output one number - answer for the question. Constraints 0 < A, B, K ≤ 10^13 0 < X, Y ≤ 1000 A ≤...
{ "input": [], "output": [] }
{ "input": [ "5 86 1 6 4\n\nSAMPLE" ], "output": [ "6" ] }
{ "input": [], "output": [] }
lets-play
Game is played on the field of the size 1 x N cells. The cells are numbered from 1 to N. In the i-th cell there are 2 positive integers - Ai and Bi. Initially, the player stands at the fictive cell with the index 0 that is located right before all the N cells of the board. Then, he makes moves. Each move consists in m...
{ "input": [ "80 3\n1 5\n2 4\n3 3\n4 2\n5 1\n3 3\n4 2\n1 5\n2 4\n3 3\n4 2\n12 45\n23 56\n1 5\n5 1\n3 3\n4 2\n1 5\n2 4\n3 3\n1 5\n2 4\n3 3\n4 2\n5 1\n3 3\n4 2\n1 5\n2 4\n31 3\n4 2\n12 45\n23 56\n1 5\n53 1\n3 3\n8 2\n1 5\n21 4\n3 3\n1 5\n2 4\n3 3\n4 2\n5 1\n3 3\n4 2\n1 5\n2 4\n3 3\n4 2\n12 45\n23 56\n1 5\n5 1\n3 3\...
{ "input": [ "4 3\n4 8\n5 9\n12 23\n1 6\n\nSAMPLE" ], "output": [ "32" ] }
{ "input": [], "output": [] }
kgp14b
A DNA sequence can be represented by a string of letters T, A, C, and G representing four different amino acids. DNA sequences are often matched to infer structural or functional similarities between living beings. Given two DNA sequences X and Y, the sequence Y is said to be contained in X if Y can be obtained from X ...
{ "input": [], "output": [] }
{ "input": [ "2\n7 6\nTAGCTAG\nATCATG\n10 9\nGGATGCTACA\nTCTACCGTA" ], "output": [ "Case 1: 9\nCase 2: 13" ] }
{ "input": [], "output": [] }
1302_J. Keep talking and nobody explodes – hard
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 100 decimal digits. If you rotate some digit, it increases by one, except 9 which becomes 0. Initially, the lock contains num...
{ "input": [], "output": [] }
{ "input": [ "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890\n" ], "output": [ "\n970001000600030002000011170661703494309997001286100090870009...
{ "input": [], "output": [] }
1346_C. Spring Cleaning
Tanya wants to organize her bookcase. There are n bookshelves in the bookcase, the i-th bookshelf contains a_i books on it. Tanya will be satisfied if each bookshelf contains no more than k books. Tanya can do one of the two following operations to achieve her goal: 1. Choose exactly one bookshelf and put all the ...
{ "input": [], "output": [] }
{ "input": [ "6\n5 4 3 5\n1 2 2 3 5\n5 3 4 5\n1 5 1 5 5\n5 4 5 6\n1 2 5 3 5\n4 3 2 10\n4 4 1 1\n4 3 10 2\n4 4 1 1\n4 1 5 4\n1 2 1 3\n" ], "output": [ "\n3\n9\n6\n4\n2\n9\n" ] }
{ "input": [], "output": [] }
178_E3. The Beaver's Problem - 2
Offering the ABBYY Cup participants a problem written by the Smart Beaver is becoming a tradition. He proposed the following problem. You are given a monochrome image, that is, an image that is composed of two colors (black and white). The image is given in raster form, that is, as a matrix of pixels' colors, and the ...
{ "input": [], "output": [] }
{ "input": [], "output": [] }
{ "input": [], "output": [] }
345_F. Superstitions Inspection
You read scientific research regarding popularity of most famous superstitions across various countries, and you want to analyze their data. More specifically, you want to know which superstitions are popular in most countries. The data is given as a single file in the following format: country name on a separate line...
{ "input": [], "output": [] }
{ "input": [ "Ukraine\n* Friday the 13th\n* black cat\n* knock the wood\nUSA\n* wishing well\n* friday the 13th\nHolland\nFrance\n* Wishing Well\n", "Spain\n* Tuesday the 13th\nItaly\n* Friday the 17th\nRussia\n* Friday the 13th\nEngland\n* rabbit foot\n" ], "output": [ "friday the 13th \nwi...
{ "input": [], "output": [] }
micro-and-block-game-3
Micro's midsem exams are finally over. When they were going on, instead of studying he would spend time making list of things that he wanted to do after the exams. But, now when they are over, he has lost the list. He was feeling very low, so his roommate Naik gave him a game to kill time. He gave him N blocks. Each ...
{ "input": [ "4143\n51035125 240619434 584739315 130431134 329410676 19380864 975583407 331039417 484984951 9306710 638970381 28132283 676254043 130126912 802274549 489214157 876426956 14712589 535582466 505199383 632507603 183629028 336319721 13041996 51518547 209268177 950588989 337563714 179684405 401676477 47...
{ "input": [ "3\n12 2 3\n\nSAMPLE" ], "output": [ "3212" ] }
{ "input": [], "output": [] }
p-4
Ramesh and Suresh are now given One Last Task, to distribute tickets to all the students as their admissions are finalized. Sounds simple, but there's one twist, they are supposed to give 1 ticket to the first student, 2 tickets to the second student, 3 tickets to the third student and so on. Now, the professor knows t...
{ "input": [ "1\n2", "1\n100000000" ], "output": [ "3", "987459712" ] }
{ "input": [ "1\n2\n\nSAMPLE" ], "output": [ "3" ] }
{ "input": [], "output": [] }
chocolat
Balajiganapathi and Bipin are brothers. They have saved their money to buy Dairy Milk for their respective girlfriend on this Valentine's day. Balaji managed to buy M chocolates and Bipin managed to buy N chocolates. They have made a bet as if who will give more Dairy Milk to their girlfriend.If Bipin manages to give...
{ "input": [], "output": [] }
{ "input": [ "2\n4 6\n8 1" ], "output": [ "Balaji 2\nBipin 7" ] }
{ "input": [], "output": [] }
epi02
Once upon a time, a king and a few of his soldiers were caught by an enemy king in a war. He puts them in a circle. The first man in the circle has to kill the second man, the third man has to kill the fourth, fifth man to kill the sixth and so on. When the circle is completed, the remaining people have to form a ci...
{ "input": [], "output": [] }
{ "input": [ "9" ], "output": [ "3" ] }
{ "input": [], "output": [] }
kjcc07
Chef is known to have friends as well as enemies. Chef has a habit of communicating with friends through encrypted messages. But recently some of his enemies found the way to decrypt and get the original message. You need to write a program that simulates how the enemies decrypted the messages. Chef’s enemies observe...
{ "input": [], "output": [] }
{ "input": [ "4\nazfjybgbxnpyatfgcaxqylbxd\ngzbbbgaxnfatxqdjfaypgcyafl\nyjbfpcygxlgznyfbgxtqgxydaaa\nxxyyxxyyxdlbqffctpbngggjz\ncbkumuwlwkmtt_zwksa!!" ], "output": [ "kjscecodecell_rocks!!" ] }
{ "input": [], "output": [] }
1346_H. Game with Segments
Alice and Bob are playing a game (yet again). They have two sequences of segments of the coordinate axis: a sequence of n initial segments: [l_1, r_1], [l_2, r_2], ..., [l_n, r_n], and a sequence of m terminal segments: [L_1, R_1], [L_2, R_2], ..., [L_m, R_m]. At the beginning of the game, they choose one of the initi...
{ "input": [], "output": [] }
{ "input": [ "1 1\n4 7\n4 7\n", "1 2\n2 5\n2 4\n3 5\n", "2 1\n1 5\n1 4\n2 3\n" ], "output": [ "\n0\n", "\n-1\n", "\n-1 1\n" ] }
{ "input": [], "output": [] }
1431_B. Polycarp and the Language of Gods
Polycarp has just finished writing down the lecture on elvish languages. The language this week was "VwV" (pronounced as "uwu"). The writing system of this language consists of only two lowercase Latin letters: 'v' and 'w'. Unfortunately, Polycarp has written all the lecture in cursive and without any spaces, so the n...
{ "input": [], "output": [] }
{ "input": [ "5\nvv\nv\nw\nvwv\nvwvvwv\n" ], "output": [ "\n1\n0\n1\n1\n3\n" ] }
{ "input": [], "output": [] }
36_D. New Game with a Chess Piece
Petya and Vasya are inventing a new game that requires a rectangular board and one chess piece. At the beginning of the game the piece stands in the upper-left corner of the board. Two players move the piece in turns. Each turn the chess piece can be moved either one square to the right or one square down or jump k squ...
{ "input": [ "20 1423\n84222527 845280366\n633691610 581066123\n139385768 526475626\n376643060 169937541\n633431220 912159091\n484006121 341973905\n5364024 653383910\n969336881 938962066\n861831982 442451063\n408769674 36876995\n119184478 588868922\n881298610 365067803\n349218472 895946717\n497062846 1118924\n136...
{ "input": [ "10 2\n1 1\n1 2\n2 1\n2 2\n1 3\n2 3\n3 1\n3 2\n3 3\n4 3\n" ], "output": [ "-\n+\n+\n-\n-\n+\n-\n+\n+\n+\n" ] }
{ "input": [], "output": [] }
535_A. Tavas and Nafas
Today Tavas got his test result as an integer score and he wants to share it with his girlfriend, Nafas. His phone operating system is Tavdroid, and its keyboard doesn't have any digits! He wants to share his score with Nafas via text, so he has no choice but to send this number using words. <image> He ate coffee mi...
{ "input": [ "27\n", "35\n", "12\n", "56\n", "61\n", "38\n", "24\n", "22\n", "15\n", "55\n", "8\n", "2\n", "72\n", "62\n", "51\n", "7\n", "34\n", "82\n", "49\n", "32\n", "0\n", "19\n", "95\n", "16\n", "88\n", "71\n...
{ "input": [ "6\n", "20\n", "99\n" ], "output": [ "six\n", "twenty\n", "ninety-nine\n" ] }
{ "input": [], "output": [] }
sonu-and-monu
Sonu and Monu are good friends. One day, Sonu gave a binary string of length L to Monu, and asks Monu to pick two positions a and b in the string. Now he given a number P to Monu and he have to tell what are the chances that there will be 1 on both positions and |a-b| ≤ P Note: Binary String means which contains only...
{ "input": [], "output": [] }
{ "input": [ "2\n4 3\n1011\n4 1\n1011\n\nSAMPLE" ], "output": [ "9/16\n5/16" ] }
{ "input": [], "output": [] }
comr03
On the eve of Diwali, Hari is decorating his house with a serial light bulb set. The serial light bulb set has N bulbs placed sequentially on a string which is programmed to change patterns every second. If atleast one bulb in the set is on at any given instant of time, how many different patterns of light can the seri...
{ "input": [], "output": [] }
{ "input": [ "2\n1\n2" ], "output": [ "1\n3" ] }
{ "input": [], "output": [] }
gerald03
Problem Statement Chef has a sequence of N segments: [L1, R1], [L2, R2], ..., [LN, RN]. He wants to transform the first segment to the last one (with index N). His plan is to do this big deal with a number of transformations: firstly he will transform the first segment to the second one, then to the third one, then to ...
{ "input": [], "output": [] }
{ "input": [ "4\n3\n-1 0\n0 1\n3 5\n1\n0 1\n3\n-2 -1\n-2 -1\n-2 0\n4\n4 6\n3 5\n-1 1\n1 2" ], "output": [ "9\nR+L+R+L+R+L+R+L+R+\n0\n\n1\nR+\n13\nL-R-L-L-L-L-R-R-R-R-L+R+L+" ] }
{ "input": [], "output": [] }
psudo1
Chef is all ready to show his new dish at the restaurant but he is very scared if the people dislike it. He wants to show them his dish at a perfect time, so that all may like the dish. If the time displayed as HH:MM, where HH is the hour and MM is the minute then, for the Chef's time to be lucky it should be of the fo...
{ "input": [], "output": [] }
{ "input": [ "2\n12:21 11:10\n06:00" ], "output": [ "1\n0" ] }
{ "input": [], "output": [] }
time
Exciting offer….!!! It’s World Cup time…. :) Here is an offer awaiting for you i.e… you will get a ticket to watch world cup finals @ Australia. Your task is so simple. You will be given a function . In order to win the prize, you need to reduce the time complexity of that function. fun( n) { if (n==0) ...
{ "input": [], "output": [] }
{ "input": [ "2" ], "output": [ "4" ] }
{ "input": [], "output": [] }
1170_H. Longest Saw
You are given the sequence a_1, a_2, ..., a_n. You can choose any subset of elements and then reorder them to create a "saw". The sequence b_1, b_2, ..., b_m is called a "saw" if the elements satisfy one of the following series of inequalities: b_1>b_2<b_3>b_4<... or b_1<b_2>b_3<b_4>.... Find the longest saw which ca...
{ "input": [], "output": [] }
{ "input": [ "3\n10\n10 9 8 7 6 5 4 3 2 1\n7\n1 2 2 2 3 2 2\n3\n100 100 100\n" ], "output": [ "\n10\n1 6 2 7 3 8 4 9 5 10 \n4\n2 1 3 2 \n1\n100 \n" ] }
{ "input": [], "output": [] }
1250_E. The Coronation
The coronation of King Berl XXII is soon! The whole royal family, including n daughters of Berl XXII, will be present. The King has ordered his jeweler to assemble n beautiful necklaces, so each of the princesses could wear exactly one necklace during the ceremony — and now these necklaces are finished. Each necklace ...
{ "input": [], "output": [] }
{ "input": [ "5\n5 7 2\n1010100\n0010101\n1111010\n1000010\n0000101\n6 9 3\n011111110\n100111000\n111100000\n000111111\n110100111\n111110111\n3 4 2\n0001\n1000\n0000\n3 4 4\n0001\n1000\n0000\n2 4 3\n0001\n1000\n" ], "output": [ "\n2\n1 3 \n1\n3 \n0\n\n-1\n1\n1 \n" ] }
{ "input": [], "output": [] }
1466_I. The Riddle of the Sphinx
What walks on four feet in the morning, two in the afternoon, and three at night? This is an interactive problem. This problem doesn't support hacks. Sphinx's duty is to guard the city of Thebes by making sure that no unworthy traveler crosses its gates. Only the ones who answer her riddle timely and correctly (or ge...
{ "input": [ "4\n100 200 60\n", "7\n64 200\n", "7\n150 8\n", "3\n16 16\n", "7\n7 3\n", "6\n16 10\n", "5\n64 6\n", "5\n8 12\n", "5\n4 4\n", "5\n20 3\n", "7\n10 200\n", "3\n64 6\n", "6\n100 90\n", "6\n180 180\n", "5\n17 200\n", "7\n200 32\n", "7\n51 12...
{ "input": [ "5 3\n\nyes\n\nno\n\nno\n\nno\n\nno\n\nyes\n", "1 1\n", "4 3\n\nno\n\nno\n\nno\n\nno\n" ], "output": [ "\n5 101\n\n5 110\n\n4 100\n\n3 101\n\n2 001\n\n1 000\n\n0 110\n", "\n0 0\n", "\n1 000\n\n2 000\n\n3 000\n\n4 000\n\n0 000\n" ] }
{ "input": [], "output": [] }
aqua-park
You came to a brand-new aqua park. In this aqua park you are not sliding like in most of aqua parks, but falling. There are N objects. Each object is non-horizontal and non-vertical segment. When you fall on the segment you start sliding on it and when you reach its lowest point you continue falling vertically. Then yo...
{ "input": [ "100 1\n50 20 100 30", "30 4\n25 35 40 30\n1 32 20 30\n33 22 50 29\n18 10 32 19" ], "output": [ "50", "33" ] }
{ "input": [ "4 2\n0 1 2 2\n2 4 4 5\n\n\nSAMPLE" ], "output": [ "0" ] }
{ "input": [], "output": [] }
chandu-and-his-toy-stack
After setting up the area. Chandu wanted all his toys to be stacked there in that area. So that all of them are accessible easily. Currently, He is having N stacks of toys each with height H_1,H_2...H_n (assuming all toys are of same height).Chandu did not like the configuration much and want to change the height of ea...
{ "input": [], "output": [] }
{ "input": [ "1\n3 6 4\n3 1\n1 2\n1 2\n\nSAMPLE" ], "output": [ "10" ] }
{ "input": [], "output": [] }
ren2013a
NOTE :This problem is just a test problem. The submissions to this problem will not be counted in the final ranklist for prize distribution. We apologize for the inconvenience caused.   Problem description Given two integers A and B that are not necessarily in base-10, find the smallest possible A + B in base-10. Fo...
{ "input": [], "output": [] }
{ "input": [ "3\n213 4721\n1001 90\n638 241" ], "output": [ "2552\n99\n592" ] }
{ "input": [], "output": [] }
1252_C. Even Path
Pathfinding is a task of finding a route between two points. It often appears in many problems. For example, in a GPS navigation software where a driver can query for a suggested route, or in a robot motion planning where it should find a valid sequence of movements to do some tasks, or in a simple maze solver where it...
{ "input": [], "output": [] }
{ "input": [ "5 3\n6 2 7 8 3\n3 4 8 5 1\n2 2 1 3\n4 2 4 3\n5 1 3 4\n", "3 2\n30 40 49\n15 20 25\n2 2 3 3\n1 2 2 2\n" ], "output": [ "\nYES\nYES\nNO\n", "\nNO\nYES\n" ] }
{ "input": [], "output": [] }
avoid-boredom
Exams are approaching soon and everyone tries to get ready for them. So, Omar decides to begin studying his subjects. He has N subjects and he wants to study M of them today. According to Omar, every subject has an interest level, A_i which indicates how much Omar likes that subject. Unfortunately, Omar feels bored ea...
{ "input": [], "output": [] }
{ "input": [ "1\n5 3\n100 50 3000 4000 40\n\nSAMPLE" ], "output": [ "7910" ] }
{ "input": [], "output": [] }
chotu-and-chocolate-day
On Chocolate day, Chotu wants to give his girlfriend a box of chocolate. Chotu has a N X N square box and N^2 chocolates each having a distinct sweetness value between 1 and N^2. To make the box look attractive Chotu must fill each row with chocolates arranged in increasing value of sweetness. Chotu also knows that hi...
{ "input": [ "20\n619 495\n67 12\n470 97\n544 529\n396 340\n963 9\n154 24\n167 32\n469 439\n507 450\n346 76\n569 204\n518 245\n955 107\n426 151\n883 559\n70 37\n832 279\n176 93\n784 778\n694 450", "20\n18 5\n302 206\n414 282\n181 38\n437 34\n501 337\n404 86\n580 69\n350 187\n425 205\n959 122\n580 447\n487 2\n...
{ "input": [], "output": [] }
{ "input": [], "output": [] }
cdva1501
Given a sequence of natural numbers . Find it's N'th term. a1=3, a2=9, a3=30, a4=101, a5=358, a6=1443... ...,aN Input Single line containing a natural number N Output Print N'th term of the sequence modulo 10^9+7. Constraints 1 <= N <=100 Example Input: 5 Output: 358
{ "input": [], "output": [] }
{ "input": [ "5" ], "output": [ "358" ] }
{ "input": [], "output": [] }
date
These days a lot of new coders are emerging at RJIT. One of the many programmers in RJIT thought of making a program to find the weekday for any given date. He successfully builds it but there is one problem, his program prints the day of yesterday's date. Now he wonders whether he can find the next date given him the...
{ "input": [], "output": [] }
{ "input": [ "3\n16/09/2014\n17/09/2014\n5/02/2004" ], "output": [ "17/9/2014\n18/9/2014\n6/2/2004" ] }
{ "input": [], "output": [] }
1211_H. Road Repair in Treeland
There are n cities and n-1 two-way roads in Treeland. Each road connects a pair of different cities. From any city you can drive to any other, moving only along the roads. Cities are numbered from 1 to n. Yes, of course, you recognized an undirected tree in this description. The government plans to repair all the road...
{ "input": [], "output": [] }
{ "input": [ "3\n3\n1 2\n2 3\n6\n1 2\n1 3\n1 4\n1 5\n1 6\n7\n3 1\n1 4\n4 6\n5 1\n2 4\n1 7\n" ], "output": [ "\n1\n10 20\n3\n1 1 1 2 2 \n2\n11 11 12 13 12 13\n" ] }
{ "input": [], "output": [] }
1297_D. Bonus Distribution
For the first time, Polycarp's startup ended the year with a profit! Now he is about to distribute k burles as a bonus among n employees. It is known that the current salary of the i-th employee is a_i and all the values of a_i in the company are different. Polycarp wants to distribute the k burles between n employee...
{ "input": [], "output": [] }
{ "input": [ "5\n4 1\n3 1 4 2\n2 3\n10 2\n4 1000000000\n987654321 1000000000 999999999 500000000\n8 9\n5 6 1 8 3 4 2 7\n6 1\n6 3 1 8 5 9\n" ], "output": [ "\n0 0 1 0 \n0 3 \n134259259 121913582 121913582 621913577 \n2 2 0 2 0 1 0 2 \n1 0 0 0 0 0 \n" ] }
{ "input": [], "output": [] }
p01575 Dungeon Master
Once upon a time, in a fantasy world far, far away, monsters dug caves and dungeons for adventurers. They put some obstacles in their caves so it becomes more difficult and more exciting for the adventurers to reach the goal. One day, Emils, one of the monsters in the caves, had a question about the caves. How many pa...
{ "input": [], "output": [] }
{ "input": [ "2 2 2", "2 2 1" ], "output": [ "0", "2" ] }
{ "input": [], "output": [] }
cg01
One day Chini while digging his ancestral farmland found the 2 boxes. He opened the 1st box, it was empty while in the second, there was 3 piles of gold coins. Whenever he chooses a pile of Y coins (y ≥ 1) from 2nd box, the coins in the 1st box increases by Y but only one gold coin gets reduced from the pile in the 2n...
{ "input": [], "output": [] }
{ "input": [ "1\n3 7 6\n3" ], "output": [ "19" ] }
{ "input": [], "output": [] }
nc1401
Haku Kale now wants to loot in a global scale. For that he needs the help of some underground gang leaders. But the problem is, he does not know the name of any gang leader. After a deep research, he got the name of gang leaders in an encrypted form. After spending months in decrypting it, he found the way to decrypt t...
{ "input": [], "output": [] }
{ "input": [ "2\n3\nARCTV\nACADAPALA\nZHFGOSM\n4\nFJAOHVG\nAAAAA\nNUWRE\nIAT" ], "output": [ "RAM\nHARI" ] }
{ "input": [], "output": [] }
humpty-dumpty
Humpty Dumpty lives on a two-dimensional plane. He likes to jump. Currently, he is located in the point (0, 0). He would like to reach the point (x, y). You are given the point x & y. Humpty Dumpty wants to reach the desired destination in a specific way: using a series of jumps with pre-determined lengths. You are gi...
{ "input": [ "30\n1\n3 4\n4\n10\n11 12\n1\n2\n3\n4\n5\n6\n7\n8\n9\n100\n2\n1 0\n100\n101\n2\n1 1\n100\n10\n50\n10 10\n1000\n1000\n1000\n1000\n1000\n1000\n1000\n1000\n1000\n1000\n1000\n1000\n1000\n1000\n1000\n1000\n1000\n1000\n1000\n1000\n1000\n1000\n1000\n1000\n1000\n1000\n1000\n1000\n1000\n1000\n1000\n1000\n1000...
{ "input": [ "3\n3\n0 0\n1\n1\n2\n2\n5 4\n2\n5\n1\n3 4\n4\n\nSAMPLE" ], "output": [ "Able\nAble\nNot able" ] }
{ "input": [], "output": [] }
no-of-1s-0s
Aravind has a hexadecimal number H. he is willing to find number of ones and zeros in that number. He needs your help to solve his problem. input first line consists of t testcases next t lines contains a string consists of hexadecimal numbers(Alphabets should be capital) output print ones followed by zeros SAMPLE IN...
{ "input": [], "output": [] }
{ "input": [ "2\n1234F\nAB2D\n\nSAMPLE" ], "output": [ "9 11\n9 7" ] }
{ "input": [], "output": [] }
p01589 Strange Currency System
The currency system in the Kingdom of Yoax-Musty is strange and fairly inefficient. Like other countries, the kingdom has its own currencty unit denoted by K $ (kingdom dollar). However, the Ministry of Finance issues bills for every value between 1 K $ and (231 - 1) K $ worth. On the other hand, this system often ena...
{ "input": [], "output": [] }
{ "input": [ "" ], "output": [ "" ] }
{ "input": [], "output": [] }
p02165 Blaster
Problem How, you have been trapped in a cave! Perhaps the wall had collapsed, and many rocks were in the way before we reached the only exit. But I realized that there was a bomb vending machine right next to you. In addition, it seems that some "blasters" have also fallen in the cave. If you use these two tools, it ...
{ "input": [], "output": [] }
{ "input": [ "4 5\n_####\nB##\n_####\n_###_", "4 5\n_#B##\n\nB##\n_", "8 5\n_###_\n_#_B#\n_####\n____#\n_#\n\n_#\n_", "8 5\n_###_\n_#_B#\n_####\n____#\n###_#\n#####\n###_#\n####_", "5 5\n_____\n_____\n_____\n_____\n_____" ], "output": [ "2", "1", "1", "1", "0" ] }
{ "input": [], "output": [] }
clarissa
Problem description Clarissa Adele Fray (a.k.a Clary) has found out that she is a shadowhunter, a human with angelic qualities. She can create her own runes (magical spells). Last week, she created many powerful runes. Right now, she is facing several underworld demons, help her find the number of ways, such that th...
{ "input": [], "output": [] }
{ "input": [ "2\n1\n100\n3\n80 90 90" ], "output": [ "1\n3" ] }
{ "input": [], "output": [] }
lealco
The Little Elephant and his friends from the Zoo of Lviv were returning from the party. But suddenly they were stopped by the policeman Big Hippo, who wanted to make an alcohol test for elephants. There were N elephants ordered from the left to the right in a row and numbered from 0 to N-1. Let R[i] to be the result of...
{ "input": [], "output": [] }
{ "input": [ "4\n5 3 2\n1 3 1 2 1\n5 3 3\n7 7 7 7 7\n5 3 3\n7 7 7 8 8\n4 3 1\n1 3 1 2" ], "output": [ "0\n1\n1\n-1" ] }
{ "input": [], "output": [] }
162_G. Non-decimal sum
You are given an array of integers written in base radix. Calculate their sum and output it written in the same base. Input The first line of the input contains an integer n (1 ≤ n ≤ 10) — the size of the array. The second line contains an integer radix (2 ≤ radix ≤ 36) — the base of the numeral system used. Next n l...
{ "input": [], "output": [] }
{ "input": [ "3\n16\nF0\n20B\n004\n", "2\n10\n12\n34\n" ], "output": [ "2FF\n", "46\n" ] }
{ "input": [], "output": [] }
986_D. Perfect Encoding
You are working as an analyst in a company working on a new system for big data storage. This system will store n different objects. Each object should have a unique ID. To create the system, you choose the parameters of the system — integers m ≥ 1 and b_{1}, b_{2}, …, b_{m}. With these parameters an ID of some object...
{ "input": [ "515377520732011331036461129765621272702107522000\n", "515377520732011331036461129765621272702107522002\n", "515377520732011331036461129765621272702107522001\n", "1\n", "7421902501252475186372406731932548506197390793597574544727433297197476846519276598727359617092494798\n", "4\n",...
{ "input": [ "37\n", "36\n", "12345678901234567890123456789\n" ], "output": [ "11\n", "10\n", "177\n" ] }
{ "input": [], "output": [] }
turing-and-the-magic-board
Turing loves playing board games. Recently he played a game on the internet, that he found interesting. You are given a square board of length N. Each unit box in the board is to be filled with a gold coin. All the players have infinite gold coins in a bank but they will be allowed to withdraw only a maximum of N coin...
{ "input": [ "388\n519 72054\n276 24593\n48 586\n445 65349\n634 214562\n564 216338\n328 48675\n539 22361\n715 421522\n705 213461\n837 463587\n766 254594\n583 13882\n348 58915\n396 38345\n135 7722\n315 26519\n480 121393\n297 38722\n599 235477\n786 130185\n128 10328\n182 3814\n761 385097\n95 6438\n443 64444\n413 22...
{ "input": [], "output": [] }
{ "input": [], "output": [] }
p01189 Roads in a City
Roads in a city play important roles in development of the city. Once a road is built, people start their living around the road. A broader road has a bigger capacity, that is, people can live on a wider area around the road. Interstellar Conglomerate of Plantation and Colonization (ICPC) is now planning to develop ro...
{ "input": [], "output": [] }
{ "input": [ "2\n0 -12 0 0 2\n0 0 12 0 2\n0" ], "output": [ "39.14159" ] }
{ "input": [], "output": [] }
p01660 Sugoroku
E-Sugoroku Bob, a fox with no friends, decided to spend his time playing sugoroku alone today. A 6-sided die with integers a_1, a_2, a_3, a_4, a_5, a_6 written on each side, a piece, and M squares on a straight line, and numbers from 1 to M are assigned in order from the left. I decided to use a board. Instructions ar...
{ "input": [], "output": [] }
{ "input": [ "" ], "output": [ "" ] }
{ "input": [], "output": [] }
p02223 String Set
Problem statement Of the string set $ S $ that meets the following conditions, configure $ 1 $ with the largest number of elements. * The length of the string contained in $ S $ is $ 1 $ or more and $ N $ or less. * The lengths of the strings contained in $ S $ are different. * The string contained in $ S $ consists ...
{ "input": [], "output": [] }
{ "input": [ "2" ], "output": [ "2\n0\n11" ] }
{ "input": [], "output": [] }
cds002
There are n children who have landed up in an unknown place where they find just some jar of cookies to eat. They also have a dog with them. The children gather all the cookies and put them in a big jar. Exhausted, they agree to go and wait until the next morning to divide up the cookies. At one o'clock in the morning,...
{ "input": [], "output": [] }
{ "input": [ "2\n5\n6" ], "output": [ "15621\n279931" ] }
{ "input": [], "output": [] }
cw5
With her new hair-style, Penny has to listen to all the comments of Sheldon Cooper. She (God knows why) challenged Sheldon Cooper for a match of Chess. Penny wants to defeat Dr. Sheldon Cooper in the game of chess. Although, she tried very hard, she is in a situation and wants your help. It is your duty to help Penny. ...
{ "input": [], "output": [] }
{ "input": [ "____B___\n________\n__Q_____\n________\n____P_S_\n_R______\n________\n________" ], "output": [ "NOT YET!" ] }
{ "input": [], "output": [] }
mriu2
A circular prime is a prime number with the property that the number generated at each intermediate step when cyclically permuting its (base 10) digits will be prime.[1][2] For example 1193 is a circular prime, since 1931, 9311 and 3119 all are also prime Input First line contains an integer N, number of inputs. Seco...
{ "input": [], "output": [] }
{ "input": [ "10\n88 11 2 5 6 9 100 121 233 79" ], "output": [ "0 1 1 1 0 0 0 0 0 1" ] }
{ "input": [], "output": [] }
1086_E. 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": [] }
1211_D. Teams
There are n table bowling players, the rating of the i-th player equals r_i. Compose a maximum number of teams in a such way that: * each player belongs to at most one team; * each team contains exactly a+b players; * each team contains a group of a players with the same rating and a group of b players with an...
{ "input": [], "output": [] }
{ "input": [ "12 1 2 2\n1 1 2 2 2 2 2 3 3 4 6 6\n", "14 1 1 3\n3 3 1 1 9 9 2 3 6 6 3 18 3 18\n", "1 2 3 10\n1000000\n" ], "output": [ "\n3\n", "\n6\n", "\n0\n" ] }
{ "input": [], "output": [] }
641_D. Little Artem and Random Variable
Little Artyom decided to study probability theory. He found a book with a lot of nice exercises and now wants you to help him with one of them. Consider two dices. When thrown each dice shows some integer from 1 to n inclusive. For each dice the probability of each outcome is given (of course, their sum is 1), and dif...
{ "input": [ "8\n0.09597231 0.11315755 0.32077119 0.22643005 0.03791746 0.04296694 0.10284494 0.05993956\n0.52402769 0.19814245 0.20452881 0.06686995 0.00468254 0.00103306 0.00055506 0.00016044\n", "10\n0 0 0 0 0 0 0 0 0 1.0\n1.0 0 0 0 0 0 0 0 0 0\n", "10\n0.01 0.01 0.01 0.01 0.01 0.1 0.2 0.2 0.4 0.05\n1....
{ "input": [ "3\n0.125 0.25 0.625\n0.625 0.25 0.125\n", "2\n0.25 0.75\n0.75 0.25\n" ], "output": [ "0.25000000 0.25000000 0.50000000 \n0.50000000 0.25000000 0.25000000 \n", "0.50000000 0.50000000 \n0.50000000 0.50000000 \n" ] }
{ "input": [], "output": [] }
760_A. Petr and a calendar
Petr wants to make a calendar for current month. For this purpose he draws a table in which columns correspond to weeks (a week is seven consequent days from Monday to Sunday), rows correspond to weekdays, and cells contain dates. For example, a calendar for January 2017 should look like on the picture: <image> Petr ...
{ "input": [ "3 1\n", "11 3\n", "1 2\n", "6 4\n", "3 5\n", "4 4\n", "9 7\n", "4 5\n", "2 6\n", "7 5\n", "10 6\n", "12 1\n", "9 1\n", "5 1\n", "12 2\n", "6 5\n", "1 3\n", "12 6\n", "4 7\n", "4 2\n", "5 2\n", "4 3\n", "12 5\n", ...
{ "input": [ "1 7\n", "1 1\n", "11 6\n" ], "output": [ "6\n", "5\n", "5\n" ] }
{ "input": [], "output": [] }
xenny-and-girlfriend
Xenny and his girlfriend were staying in a metropolitan city. His girlfriend, being an outgoing person, wanted to visit all streets in the city. However, she used to get bored quickly and hence she wanted to visit every street exactly once. The city had M streets and N junctions. Given information about the city's layo...
{ "input": [ "5\n21 42\n16 1\n1 9\n20 2\n2 3\n16 3\n3 12\n5 4\n4 21\n9 5\n5 13\n2 6\n6 17\n10 7\n7 4\n21 8\n8 19\n6 9\n9 20\n13 10\n10 1\n1 11\n11 8\n15 12\n12 3\n21 13\n13 9\n13 14\n14 18\n17 15\n15 1\n8 16\n16 5\n13 17\n17 4\n5 18\n18 17\n13 19\n19 1\n17 20\n20 15\n8 21\n21 8\n2 4\n2 1\n1 2\n1 2\n2 1\n5 10\n3 1...
{ "input": [ "1\n4 4\n1 2\n2 3\n3 4\n4 1\n\nSAMPLE" ], "output": [ "Yes" ] }
{ "input": [], "output": [] }
nita02
At the function of Republic day at NIT Agartala the warden of hostel has to visit the ground and check the arrangement of the chairs for guests. In the ground of NIT Agartala all the chairs are arranged in N rows and M columns. Warden has to check that in each row all the chairs must have same color and adjacent rows ...
{ "input": [], "output": [] }
{ "input": [ "5 6\n0 0 0 0 1 0\n1 1 1 1 1 1\n1 1 1 1 1 1\n2 2 2 2 2 2\n3 3 3 3 3 3", "5 6\n0 0 0 0 0 0\n1 1 1 1 1 1\n2 2 2 2 2 2\n1 1 1 1 1 1\n3 3 3 3 3 3" ], "output": [ "NO", "YES" ] }
{ "input": [], "output": [] }
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n × n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
{ "input": [ "15 7\n8 8 U\n6 10 L\n9 7 L\n3 13 L\n15 1 L\n13 3 U\n1 15 L\n", "1000000000 1\n117117117 882882884 U\n", "10 10\n5 6 U\n4 7 U\n8 3 L\n8 3 L\n1 10 U\n9 2 U\n10 1 L\n10 1 L\n8 3 U\n8 3 U\n", "1 2\n1 1 L\n1 1 U\n", "20 10\n10 11 U\n12 9 U\n6 15 L\n17 4 U\n11 10 L\n7 14 L\n4 17 U\n2 19 L\...
{ "input": [ "6 5\n3 4 U\n6 1 L\n2 5 L\n1 6 U\n4 3 U\n", "10 6\n2 9 U\n10 1 U\n1 10 U\n8 3 L\n10 1 L\n6 5 U\n" ], "output": [ "4\n3\n2\n1\n2\n", "9\n1\n10\n6\n0\n2\n" ] }
{ "input": [], "output": [] }
64_F. Domain
This problem doesn't contain real-world specifications about domains, just use the problem statement as a formal document to solve the problem. The given string s is a domain name if it contains the characters "a"-"z", "0"-"9" and dots. No two dots shoud follow one after another (consecutive). The dots split the given...
{ "input": [], "output": [] }
{ "input": [ "codeforces.com\n", "mail.v-kontakte.ru\n" ], "output": [ "YES\n", "NO\n" ] }
{ "input": [], "output": [] }
comrades-ii-6
It’s the year 2552, the Humans just won a war against a very powerful alien race that had invaded our solar system. The Human army is in celebration mode! The army has n soldiers. The soldiers are numbers from 1 to n. The army has a superiority hierarchy. Every soldier has one immediate superior. The superior of a su...
{ "input": [], "output": [] }
{ "input": [ "2\n3\n0 1 1\n2\n2 0\n\nSAMPLE" ], "output": [ "2 1\n1 0" ] }
{ "input": [], "output": [] }
imagination-game-easy-contest
Two players are playing with N-dimensional rectangular with sizes of its sides (a1, a2, ... aN). (Let's call this rectangular as "cube"). Initially there is one cell marked with coordinates (x1, x2, ... xN). On his/her turn a player should divide a current cube into two cubes by exactly one cut along one of the val...
{ "input": [], "output": [] }
{ "input": [ "2\n2\n2 2\n1 1\n2\n2 3\n1 2\n\n\nSAMPLE" ], "output": [ "Second\nFirst" ] }
{ "input": [], "output": [] }
iitk1p02
Awesomeness of a string is defined by a pair of a character C and an integer F, satisfying the following conditions : C must belong to the given string S and there must be a substring subS of S having length equal to F such that all the characters in subS are equal to c. F should be as large as possible. Yo...
{ "input": [], "output": [] }
{ "input": [ "abbbaaabad" ], "output": [ "a\n3" ] }
{ "input": [], "output": [] }
785_A. Anton and Polyhedrons
Anton's favourite geometric figures are regular polyhedrons. Note that there are five kinds of regular polyhedrons: * Tetrahedron. Tetrahedron has 4 triangular faces. * Cube. Cube has 6 square faces. * Octahedron. Octahedron has 8 triangular faces. * Dodecahedron. Dodecahedron has 12 pentagonal faces. *...
{ "input": [ "28\nOctahedron\nDodecahedron\nOctahedron\nOctahedron\nDodecahedron\nIcosahedron\nIcosahedron\nDodecahedron\nDodecahedron\nDodecahedron\nCube\nDodecahedron\nCube\nTetrahedron\nCube\nCube\nTetrahedron\nDodecahedron\nDodecahedron\nDodecahedron\nIcosahedron\nIcosahedron\nDodecahedron\nIcosahedron\nDodec...
{ "input": [ "3\nDodecahedron\nOctahedron\nOctahedron\n", "4\nIcosahedron\nCube\nTetrahedron\nDodecahedron\n" ], "output": [ "28\n", "42\n" ] }
{ "input": [], "output": [] }
factor-game-5
This time Alice and Bob have devised a new game of numbers to decide who is the better player among the two. Each time they are given n positive integers and they perform an operation on these integers in each turn. In a particular operation a player can choose any 1 of the numbers and divide it with 1 or more prime nu...
{ "input": [ "10000\n13317 31849 30358 8116 26712 24993 24212 17920 27358 18703 28046 4752 15612 16018 4014 20849 2259 22742 454 2495 16487 27616 2451 25809 14337 18919 836 5553 16338 1638 26678 21711 216 28527 13058 17398 8454 12610 17593 20094 29343 22558 12142 22980 13027 9303 2549 22999 7149 25769 12523 7796 ...
{ "input": [ "4 \n1 2 3 4" ], "output": [ "ALICE" ] }
{ "input": [], "output": [] }
p01585 Mickle's Beam
Major Mickle is commanded to protect a secret base which is being attacked by N tanks. Mickle has an ultimate laser rifle called Mickle's beam. Any object shot by this beam will be immediately destroyed, and there is no way for protection. Furthermore, the beam keeps going through even after destroying objects. The bea...
{ "input": [], "output": [] }
{ "input": [ "" ], "output": [ "" ] }
{ "input": [], "output": [] }
high
In some countries building highways takes a lot of time... Maybe that's because there are many possiblities to construct a network of highways and engineers can't make up their minds which one to choose. Suppose we have a list of cities that can be connected directly. Your task is to count how many ways there are to bu...
{ "input": [], "output": [] }
{ "input": [ "4\n4 5\n3 4\n4 2\n2 3\n1 2\n1 3\n\n2 1\n2 1\n\n1 0\n\n3 3\n1 2\n2 3\n3 1" ], "output": [ "8\n1\n1\n3" ] }
{ "input": [], "output": [] }
repstr
Given a string S (containing at most 10^5 lowercase English letters). You are requested to find out from continuous substrings a string having length from L to H, which appears the most times; if there are more than one answer, find the most length. Input There are several test cases (fifteen at most), each formed as ...
{ "input": [], "output": [] }
{ "input": [ "3 5\naabcbcbca\n3 5\nbaaaababababbababbab\n1 4\nabcd\n0 0" ], "output": [ "2 4\n6 3\n1 4" ] }
{ "input": [], "output": [] }
1252_E. Songwriter
Andi is a mathematician, a computer scientist, and a songwriter. After spending so much time writing songs, he finally writes a catchy melody that he thought as his best creation. However, the singer who will sing the song/melody has a unique vocal range, thus, an adjustment may be needed. A melody is defined as a seq...
{ "input": [], "output": [] }
{ "input": [ "16 1 8 6\n1 3 5 6 7 8 9 10 3 7 8 9 10 11 12 12\n", "16 1 8 6\n1 3 5 6 7 8 9 10 3 7 8 9 10 11 12 13\n", "16 1 10 10\n1 3 5 6 7 8 9 10 3 7 8 9 1 11 12 13\n" ], "output": [ "\n1 2 3 4 5 6 7 8 2 3 4 5 6 7 8 8\n", "\n-1\n", "\n1 2 3 4 5 6 7 8 1 2 3 4 1 2 3 4\n" ] }
{ "input": [], "output": [] }
babua-value-3
A boy named Mohan was very fond of integer arrays and loved performing various operations on them. Once he decided to calculate a unique value of the array, which he named as Babua value. To find that value, he calculates the absolute difference between all consecutive elements in an array and adds it to the first ele...
{ "input": [ "50\n3987477 8934938 4067156 6712855 7269334 5039822 9533601 9335400 5992073 2619268 438734 8620973 4347619 4307947 2249161 815221 7615258 8244100 8341666 5908546 6646952 4812769 6215114 7479369 6290438 5623785 6466133 9953199 3525873 4326034 3510072 8117068 2342953 1717542 9766539 651627 9541804 451...
{ "input": [ "3\n1 2 4\n\nSAMPLE" ], "output": [ "19/3" ] }
{ "input": [], "output": [] }
easy-factorial-a-1
Sorry folks,, admin has no time to create a story for this problem... You have two integers n and m and you have to print value of factorial(n)%m. OUTPUT a single integer containing answer of problem. Input 23 14567 NOTE You do not need to create a program for this problem you have to write your answers of given in...
{ "input": [ "23 14567" ], "output": [ "12404\n" ] }
{ "input": [], "output": [] }
{ "input": [], "output": [] }
testcop
Mr. Osama is a maths enthusiast. Numbers and equations never fails to amaze him. Recently he started exploring a weird problem. The explanation of the problem he is working on, is given below. He takes the equation, ax1+bx2+cx3+.... = 1, for some integers x1,x2,x3,... He likes to analyze the properties of this equation...
{ "input": [ "5\n5\n10000000 10000000 10000000 10000000 10000000\n5\n10000000 10000000 10000000 10000000 10000000\n5\n10000000 10000000 10000000 10000000 10000000\n5\n10000000 10000000 10000000 10000000 10000000\n5\n10000000 10000000 10000000 10000000 10000000" ], "output": [ "NO\nNO\nNO\nNO\nNO" ] }
{ "input": [], "output": [] }
{ "input": [], "output": [] }
noways
John wanted to buy gifts for some k children in his apartments on christmas. He goes to the shop and the shopkeeper shows him n gifts. How many ways John can choose k gifts from n total gifts ?. Since answer could be large print the answer mod 1000000007 NOTE : ordering of the gifts do not matter Different order of sa...
{ "input": [], "output": [] }
{ "input": [ "1\n5 1" ], "output": [ "5" ] }
{ "input": [], "output": [] }
530_E. Sum and product
You are given integers N and D. Find N positive integers x1...xN such that the difference of their product and their sum equals D. Input The only line of input contains integers N (2 ≤ N ≤ 1000) and D (0 ≤ D ≤ 1000). Output Output N integers that satisfy the given condition in non-decreasing order (in a single line...
{ "input": [], "output": [] }
{ "input": [ "2 1\n", "3 5\n" ], "output": [ "2 3\n", "1 2 8\n" ] }
{ "input": [], "output": [] }
556_E. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n × n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
{ "input": [ "10 10\n5 6 U\n4 7 U\n8 3 L\n8 3 L\n1 10 U\n9 2 U\n10 1 L\n10 1 L\n8 3 U\n8 3 U\n", "1000000000 1\n117117117 882882884 U\n", "1 2\n1 1 L\n1 1 U\n", "20 10\n10 11 U\n12 9 U\n6 15 L\n17 4 U\n11 10 L\n7 14 L\n4 17 U\n2 19 L\n8 13 L\n14 7 U\n", "15 7\n8 8 U\n6 10 L\n9 7 L\n3 13 L\n15 1 L\...
{ "input": [ "10 6\n2 9 U\n10 1 U\n1 10 U\n8 3 L\n10 1 L\n6 5 U\n", "6 5\n3 4 U\n6 1 L\n2 5 L\n1 6 U\n4 3 U\n" ], "output": [ "9\n1\n10\n6\n0\n2\n", "4\n3\n2\n1\n2\n" ] }
{ "input": [], "output": [] }
the-tiled-footpath-on-marine-drive
X and Y are sitting beside a footpath on a bench on Marine Drive having a look at the beautiful sea. (Anyone from Mumbai here ?). X is a top coder who studies at DA-IICT. His friend Y studies at some local college from Mumbai. X always wants to show off his coding prowess so he asks puzzles to Y and Y (being not so i...
{ "input": [], "output": [] }
{ "input": [ "1\n5 2\n\nSAMPLE" ], "output": [ "0" ] }
{ "input": [], "output": [] }
162_B. 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 126 Output 1111110 Note In the first example 5 = 1 * 22 + 0 * 21 ...
{ "input": [], "output": [] }
{ "input": [ "5\n", "126\n" ], "output": [ "101\n", "1111110\n" ] }
{ "input": [], "output": [] }
253_B. Physics Practical
One day Vasya was on a physics practical, performing the task on measuring the capacitance. He followed the teacher's advice and did as much as n measurements, and recorded the results in the notebook. After that he was about to show the results to the teacher, but he remembered that at the last lesson, the teacher had...
{ "input": [ "100\n1354 1797 588 3046 1290 745 217 907 113 381 523 935 791 415 92 1597 1739 1774 240 27 1262 2498 52 1339 1031 1355 2036 230 489 7 69 877 530 2664 1230 940 2712 2651 3410 480 332 699 957 2257 1877 1940 452 1652 1216 3144 236 165 1109 888 1649 346 24 183 1061 1226 2694 3225 2021 1145 907 1671 1599 ...
{ "input": [ "4\n4 3 2 4\n", "6\n4 5 3 8 3 7\n" ], "output": [ "0\n", "2\n" ] }
{ "input": [], "output": [] }
325_E. The Red Button
Piegirl found the red button. You have one last chance to change the inevitable end. The circuit under the button consists of n nodes, numbered from 0 to n - 1. In order to deactivate the button, the n nodes must be disarmed in a particular order. Node 0 must be disarmed first. After disarming node i, the next node to...
{ "input": [ "20\n", "29024\n", "23105\n", "2500\n", "513\n", "25\n", "99999\n", "8\n", "100\n", "6400\n", "5\n", "50\n", "10\n", "1000\n", "12\n", "800\n", "55555\n", "30\n", "126\n", "255\n", "32\n", "514\n", "9\n", "6\n...
{ "input": [ "3\n", "4\n", "2\n", "16\n" ], "output": [ "-1\n", "0 1 3 2 0\n", "0 1 0\n", "0 1 2 5 10 4 9 3 6 13 11 7 15 14 12 8 0 " ] }
{ "input": [], "output": [] }
just-shortest-distance-problem
You are given an empty graph of N vertices and M queries of two types: Given a number X answer what is the shortest distance from the vertex 1 to the vertex X. Given two integers X, Y add the new oriented edge from X to Y. Input The first line contains two integers N and M. The following M lines describe queries in th...
{ "input": [ "50 500\n2 2 2\n2 2 3\n2 4 4\n2 3 5\n2 1 6\n2 4 7\n2 7 8\n2 5 9\n2 9 10\n2 7 11\n2 10 12\n2 12 13\n2 10 14\n2 7 15\n2 9 16\n2 13 17\n2 16 18\n2 7 19\n2 2 20\n2 16 21\n2 13 22\n2 23 23\n2 19 24\n2 15 25\n2 10 26\n2 27 27\n2 1 28\n2 13 29\n2 11 30\n2 8 31\n2 12 32\n2 27 33\n2 6 34\n2 24 35\n2 21 36\n2 ...
{ "input": [ "4 7\n1 4\n2 1 2\n2 2 3\n2 3 4\n1 4\n2 2 4\n1 4\n\n\nSAMPLE" ], "output": [ "-1\n3\n2" ] }
{ "input": [], "output": [] }
tricky-triplet-2
Raghav is good in mathematics. He loves to ask puzzles with his friends. One day, he decides to challenge his friend Aditya who is not good with puzzles. So, Aditya needs your help in determining the solution to the puzzle asked by his friend which is stated as:- Tell the total number of ways he can choose three numbe...
{ "input": [ "30\n2 2 2 2 2 2 2 3 3 3 3 3 3 4 4 4 4 4 4 5 5 5 5 5 5 5 1 1 1 1 1", "12\n3 1 3 5 20000 30000 2 0 1 1 2 3", "8\n0 0 0 0 0 0 0 0" ], "output": [ "618", "13", "56" ] }
{ "input": [ "8\n3 5 3 1 2 5 3 7\n\nSAMPLE" ], "output": [ "6" ] }
{ "input": [], "output": [] }
p00000 QQ
Write a program which prints multiplication tables in the following format: 1x1=1 1x2=2 . . 9x8=72 9x9=81 Input No input. Output 1x1=1 1x2=2 . . 9x8=72 9x9=81 Example Input Output
{ "input": [], "output": [] }
{ "input": [ "" ], "output": [ "" ] }
{ "input": [], "output": [] }
p02076 Rooks Game
Problem Statement "Rooks Game" is a single-player game and uses a chessboard which has $N \times N$ grid and $M$ rook pieces. A rook moves through any number of unoccupied squares horizontally or vertically. When a rook can attack another rook, it can capture the rook and move to the square which was occupied. Note t...
{ "input": [], "output": [] }
{ "input": [ "" ], "output": [ "" ] }
{ "input": [], "output": [] }
aln
There is a country which recently got invaded by a fleet of aliens. They started living with the people there. Relations between the aliens and humans were generally bitter. The government at the center decided that they will divide the country into 2 states (initially there were none). There are N citizens in the coun...
{ "input": [], "output": [] }
{ "input": [ "3\n2\n1 -1\n4\n-1 1 -1 -1\n5\n1 1 1 -1 -1" ], "output": [ "-1 1\n-1 -1 -1 1\n-1 -1 1 1 1" ] }
{ "input": [], "output": [] }
cheftic
Tic-Tac-Toe used to be Chef's favourite game during his childhood. Reminiscing in his childhood memories, he decided to create his own "Tic-Tac-Toe", with rules being similar to the original Tic-Tac-Toe, other than the fact that it is played on an NxN board. The game is played between two players taking turns. First ...
{ "input": [], "output": [] }
{ "input": [ "1\n4 4\nXOXO\nOX..\nXO..\nOXOX", "3\n3 3\nXOX\nO.O\nXOX\n3 1\n...\n...\n...\n3 2\n...\n...\n..." ], "output": [ "YES", "YES\nYES\nNO" ] }
{ "input": [], "output": [] }
ds24
Problem You are living in 2050, People do not work any more. Only surrogates (clone having same features & DNA characteristics) work for every individual. Government is substituting man labor by surrogates. Every person can control his own surrogate from his home and paid for his services one of the criminal master mi...
{ "input": [], "output": [] }
{ "input": [ "9 6\nAAAAAA\nACACAC\nGTTTTG\nACACAC\nGTTTTG\nACACAC\nACACAC\nTCCCCC\nTCCCCC\n0 0" ], "output": [ "1\n2\n0\n1\n0\n0\n0\n0\n0" ] }
{ "input": [], "output": [] }
numsum
According to folklore, the great mathematician Gauss was able to calculate the sum of the first 50 natural numbers in mere seconds. You are given a similar problem, where you have to calculate the sum of the first 'n' natural numbers. The only catch being that the the number 'n' can be really very large. You have to ca...
{ "input": [], "output": [] }
{ "input": [ "2\n3\n5" ], "output": [ "6\n15" ] }
{ "input": [], "output": [] }
1028_G. Guess the number
This problem is interactive. You should guess hidden number x which is between 1 and M = 10004205361450474, inclusive. You could use up to 5 queries. In each query, you can output an increasing sequence of k ≤ x integers, each between 1 and M, inclusive, and you will obtain one of the following as an answer: * ei...
{ "input": [ "-1\n1000000000\n", "-1\n3032485242972588\n", "-1\n3390435124564596\n", "-1\n520825450746127\n", "-1\n8802767625702528\n", "-1\n544868732745086\n", "-1\n3\n", "-1\n100\n", "-1\n8878530174845145\n", "-1\n10004205361450469\n", "-1\n3373402665917589\n", "-1\n1...
{ "input": [ "2\n\n0\n\n-1" ], "output": [ "1 204761410474 \n1 2046 \n1 6 \n" ] }
{ "input": [], "output": [] }
1302_E. Amazing bitset
This is an unusual problem in an unusual contest, here is the announcement: [http://codeforces.com/blog/entry/73543](//codeforces.com/blog/entry/73543) Andrey has just started to study competitive programming and he is fascinated by bitsets and operations on them. For example, assume he has a bitset with n elements. ...
{ "input": [], "output": [] }
{ "input": [ "5 1 2\n", "1 228 239\n" ], "output": [ "\n848765426\n", "\n0\n" ] }
{ "input": [], "output": [] }
345_A. Expecting Trouble
It is Friday the 13th today, and even though you're a modern well-educated person, you can't help feeling a bit nervous about it. You decide to look for evidence against this superstition (or for it). As a first step, you recall all Fridays the 13th in your life and calculate how many of them were unusually bad — like ...
{ "input": [], "output": [] }
{ "input": [ "?111?1??1\n1.0\n", "01?10??10000\n0.5\n" ], "output": [ "1.00000\n", "0.37500\n" ] }
{ "input": [], "output": [] }
othello
You have an m x n grid, with m and n both even. Each cell has a tile. The tile has two faces - one is black, and one is white. These tiles may be flipped. However, if you flip a tile, all other tiles in its row and column also get flipped. You start of with an initial configuration of black and white tiles. Your goal i...
{ "input": [ "100 100\nBWBWWBBBBBWWBBBBBWBWBBBBBBBBBWWBWWBBBBBBWBWBWBBBBBWBBWBBBBBBBBBBBBWWWBWBBBBBBWBBWBBWBBWWWBBBBBWBBBBB\nBWBBBBWBBBBWBBWBBBWBBBBBBBBBBBBWBBWBWBBBBWBWBWBBBBBWBBBBBBBBWBWBBWBBBWWBBBBBBBBBBWBWBBBBBBBBBBBBBWBB\nWBBBBBBBBBWBBBBBBWWBBWWWBBWBBBBBBBWWWBBBBBWBBBWWWWBBBBWBBBBBWBWWBBBBBBBBBBBBBBWWWBBWWWB...
{ "input": [ "4 4\nWBBW\nWBBW\nWWWW\nWBBW\n\nSAMPLE" ], "output": [ "2" ] }
{ "input": [], "output": [] }
p01779 Typing Game
H: Typing Game / Typing Game story From here, it's time to train your typing skills. Can you type quickly and accurately? Let ’s enjoy Typing Game! problem As a typing game game system, create a program that operates interactively with respect to the AI ​​output prepared by the judge. AI plays a game of typing N s...
{ "input": [], "output": [] }
{ "input": [ "" ], "output": [ "" ] }
{ "input": [], "output": [] }
devhand
As you have probably realized up to now that Devu is not a normal guy, he is a very weird and abnormal guy. Normally people have two hands, but Devu has three of them. So he wears three wrist watches on his hands. Devu loves to write name of his friends on his wrist watches. So he want to attach a string correspondin...
{ "input": [], "output": [] }
{ "input": [ "3\n1 2\n1 3\n2 2" ], "output": [ "0\n6\n36" ] }
{ "input": [], "output": [] }