dataset
stringclasses
1 value
question
stringlengths
29
13k
exe_method
stringclasses
1 value
solutions
null
task_id
int64
0
5.07k
test_time_limit
int64
1
1
example_input
listlengths
0
5
example_output
listlengths
0
5
test_input
listlengths
1
10
test_output
listlengths
1
10
CodeContests
You are given two strings s and t consisting of lowercase English letters and an integer L. We will consider generating a string of length L by concatenating one or more copies of s and t. Here, it is allowed to use the same string more than once. For example, when s = `at`, t = `code` and L = 6, the strings `atatat`...
stdin
null
4,112
1
[ "10\ncoin\nage\n", "8\ncoding\nfestival\n", "6\nat\ncode\n", "8\nsame\nsame\n" ]
[ "ageagecoin\n", "festival\n", "atatat\n", "samesame\n" ]
[ "10\ncoin\nahe\n", "8\ncoding\nfestiual\n", "6\nat\ncnde\n", "8\nsamd\nsame\n", "10\ncoin\naeh\n", "10\nnioc\naeh\n", "6\nta\nncde\n", "8\nsame\nsmae\n", "10\ncnin\naeh\n", "8\ngnicoc\nfisteual\n" ]
[ "aheahecoin\n", "festiual\n", "atatat\n", "samdsamd\n", "aehaehcoin\n", "aehaehnioc\n", "ncdeta\n", "samesame\n", "aehaehcnin\n", "fisteual\n" ]
CodeContests
Let us denote by f(x, m) the remainder of the Euclidean division of x by m. Let A be the sequence that is defined by the initial value A_1=X and the recurrence relation A_{n+1} = f(A_n^2, M). Find \displaystyle{\sum_{i=1}^N A_i}. Constraints * 1 \leq N \leq 10^{10} * 0 \leq X < M \leq 10^5 * All values in input are ...
stdin
null
4,340
1
[ "10000000000 10 99959\n", "6 2 1001\n", "1000 2 16\n" ]
[ "492443256176507\n", "1369\n", "6\n" ]
[ "10000000000 2 99959\n", "1000 0 16\n", "10010000000 2 99959\n", "10010000100 2 99959\n", "10000000000 15 99959\n", "6 2 1101\n", "1100 2 16\n", "10010001000 2 99959\n", "11010000100 2 99959\n", "1000 1 20\n" ]
[ "500550770156172\n", "0\n", "501051320374664\n", "501051325615660\n", "500550769812856\n", "1282\n", "6\n", "501051370879075\n", "551106402301729\n", "1000\n" ]
CodeContests
In the world of DragonBool there are fierce warriors called Soints. Also there are even fiercer warriors called Sofloats – the mortal enemies of Soints. The power of each warrior is determined by the amount of chakra he possesses which is some positive integer. Warriors with zero level of chakra are dead warriors :) ...
stdin
null
2,827
1
[ "2\n2 3\n10 1\n20 2\n5 2\n5 2\n18 1\n5 5\n73 87\n69 13\n36 36\n77 46\n43 93\n49 46\n74 93\n78 87\n99 13\n59 36\n" ]
[ "8\n89\n" ]
[ "2\n2 3\n10 1\n20 2\n5 2\n4 2\n18 1\n5 5\n73 87\n69 13\n36 36\n77 46\n43 93\n49 46\n74 93\n78 87\n99 13\n59 36\n", "2\n2 3\n10 1\n20 2\n5 2\n4 2\n18 1\n5 5\n73 87\n69 13\n36 36\n77 46\n16 93\n49 46\n74 93\n78 87\n99 13\n59 36\n", "2\n2 3\n10 1\n20 2\n5 2\n4 2\n18 1\n5 5\n100 87\n69 13\n36 36\n77 46\n16 93\n49 4...
[ "8\n89\n", "8\n116\n", "8\n111\n", "8\n93\n", "8\n80\n", "0\n111\n", "8\n166\n", "0\n189\n", "8\n143\n", "8\n86\n" ]
CodeContests
After minting loads of money from innocent people by using the psychic powers (As we saw in the previous question!) - little Jhool managed to woo his girlfriend big Jhool! And now, he's in love - madly, madly in love with his girlfriend. But the road to love is not easy as they say, little Jhool and big Jhool live in...
stdin
null
4,963
1
[ "lov3333333asdafajfgnkdfn33333e\n\nSAMPLE\n" ]
[ "I love you, too!\n" ]
[ "isnjvoalgekestvklhmhyebhhhixvcfioyjfwneejllbfmsoovszkkewrcmlchfdwcbrocyhqlglnhnugwsxldpqzgealfee\n", "ewol\n", "vol\n", "evvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvol\n", "lov3333333asdafajfgnkdfn33233e\n\nSAMPLE\n", "isnjvoalgekestvklhmhyebhhhixvcfioyjfwneejllbfmsoovszkkewrcmlchfd...
[ "I love you, too!\n", "Let us breakup!\n", "Let us breakup!\n", "Let us breakup!\n", "I love you, too!\n", "I love you, too!\n", "Let us breakup!\n", "Let us breakup!\n", "I love you, too!\n", "I love you, too!\n" ]
CodeContests
You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or bl...
stdin
null
4,309
1
[ "3 2\n#.#\n.#.\n#.#\n#.\n.#\n", "4 1\n....\n....\n....\n....\n", "3 2\n.#\n.#.\n.#\n.\n.#\n" ]
[ "Yes\n", "No\n", "Yes\n" ]
[ "3 2\n#.#\n.#.\n#-#\n#.\n.#\n", "3 2\n-#\n.#.\n.#\n.\n.#\n", "4 0\n....\n....\n....\n....\n", "3 2\n#.#\n.\".\n#-#\n#.\n.#\n", "4 1\n..-.\n....\n....\n....\n", "3 2\n-#\n.#.\n#.\n.\n.#\n", "3 2\n#.#\n.\".\n#-#\n$.\n.#\n", "0 1\n..-.\n....\n....\n....\n", "0 2\n#.#\n.\".\n#-#\n$.\n.#\n", "0 1\n..-....
[ "Yes\n", "No\n", "Yes\n", "No\n", "No\n", "No\n", "No\n", "No\n", "No\n", "No\n" ]
CodeContests
Hackland is being attacked by Greyland, and you have been assigned the job to save it. Your enemies, known as Grey hats, are numbered starting from L to R, both inclusive. But, here is the fun part: Grey hats are known to switch sides, and you need to make full use of it to get some of them on your side. Now, two Grey...
stdin
null
921
1
[ "2\n1 10 10\n1 11 10\n\nSAMPLE\n" ]
[ "1\n2\n" ]
[ "200\n1 1001 1000\n5 511 10\t\n5 4747 10\n1 1000000 10\t\n10 10110 10\n1 1 10\t\n1000000 1000000 10\t\n491273 842398 10\t\n849859 958925 10\t\n67803 771363 10\t\n184892 391907 10\t\n75799 256150 10\n268944 342402 10\t\n228640 894352 10\t\n903885 908656 10\t\n292588 414271 10\t\n852057 889141 10\t\n73955 739551 10\t...
[ "2\n3\n3\n6\n3\n1\n1\n1\n1\n2\n1\n1\n1\n1\n1\n1\n1\n2\n1\n2\n1\n2\n1\n3\n2\n3\n2\n3\n2\n4\n3\n4\n3\n4\n3\n5\n4\n1\n1\n1\n2\n1\n1\n1\n1\n2\n5\n5\n2\n1\n1\n1\n5\n1\n1\n2\n1\n1\n1\n3\n3\n6\n3\n1\n1\n1\n1\n2\n1\n1\n1\n1\n1\n1\n1\n2\n1\n2\n1\n2\n1\n3\n2\n3\n2\n3\n2\n4\n3\n4\n3\n4\n3\n5\n4\n1\n1\n1\n2\n1\n1\n1\n1\n2\n5\n...
CodeContests
Little Arihant has always wanted to be the best Pokemon trainer in this world. And he thinks he has achieved his goal, so he wants to quickly go and meet Professor Oak and verify this fact. But like all Pokemon trainers, he has a weird habit, too. He catches Pokemons which can go through evolution to become a better on...
stdin
null
4,962
1
[ "2\n3 1\n\nSAMPLE\n" ]
[ "5\n" ]
[ "10001\n100028 100028 100028 2289 1226 3868 100028 100028 1231 1861 100028 1604 4238 100028 100028 3575 100028 100028 100028 100028 2423 100028 4927 100028 100028 100028 3565 1182 100028 100028 100028 100028 100028 100028 1113 4408 3507 161 1482 2957 2449 100028 100028 1444 3741 100028 100028 5987 921 100028 3082 3...
[ "105029\n", "5\n", "7\n", "148779\n", "180956\n", "187992\n", "189230\n", "196689\n", "198434\n", "199462\n" ]
CodeContests
A browser-based puzzle game called "Bubble Puzzle" is now popular on the Internet. The puzzle is played on a 4 × 4 grid, and initially there are several bubbles in the grid squares. Each bubble has a state expressed by a positive integer, and the state changes when the bubble gets stimulated. You can stimulate a bubbl...
stdin
null
3,329
1
[ "2 4 4 1\n2 4 4 1\n2 4 4 1\n2 4 4 1\n", "4 4 4 4\n4 4 4 4\n4 4 4 4\n4 4 4 4\n", "2 4 3 4\n2 2 4 4\n3 3 2 2\n2 3 3 3\n" ]
[ "5\n", "1\n", "3\n" ]
[ "2 4 4 1\n2 4 4 1\n2 4 4 1\n0 4 4 1\n", "4 4 4 4\n4 4 4 4\n4 4 4 4\n3 4 4 4\n", "2 4 3 4\n2 2 4 4\n3 3 2 2\n0 3 3 3\n", "2 4 3 4\n2 2 4 4\n3 3 2 2\n2 0 3 3\n", "2 4 3 4\n2 2 4 4\n3 3 4 2\n2 0 3 3\n", "2 4 3 4\n2 1 2 4\n3 3 2 2\n0 3 3 3\n", "2 4 4 1\n2 4 4 1\n1 4 4 1\n0 4 4 1\n", "2 4 4 1\n2 2 4 1\n2 4...
[ "5\n", "1\n", "4\n", "3\n", "2\n", "-1\n", "5\n", "4\n", "1\n", "1\n" ]
CodeContests
Here, we want to solve path planning for a mobile robot cleaning a rectangular room floor with furniture. Consider the room floor paved with square tiles whose size fits the cleaning robot (1 × 1). There are 'clean tiles' and 'dirty tiles', and the robot can change a 'dirty tile' to a 'clean tile' by visiting the tile...
stdin
null
2,490
1
[ "7 5\n.......\n.o...*.\n.......\n.*...*.\n.......\n15 13\n.......x.......\n...o...x....*..\n.......x.......\n.......x.......\n.......x.......\n...............\nxxxxx.....xxxxx\n...............\n.......x.......\n.......x.......\n.......x.......\n..*....x....*..\n.......x.......\n10 10\n..........\n..o.......\n.........
[ "8\n49\n-1\n" ]
[ "7 5\n.......\n.o...*.\n.......\n.*...*.\n.......\n15 13\n.......x.......\n...o...x....*..\n.......x.......\n.......x.......\n.......x.......\n.-.............\nxxxxx.....xxxxx\n...............\n.......x.......\n.......x.......\n.......x.......\n..*....x....*..\n.......x.......\n10 10\n..........\n..o.......\n.........
[ "8\n49\n-1\n", "8\n49\n11\n", "6\n49\n11\n", "8\n49\n12\n", "8\n45\n-1\n", "8\n49\n13\n", "8\n49\n6\n", "6\n47\n11\n", "8\n47\n-1\n", "6\n49\n6\n" ]
CodeContests
Example Input 3 1 0 1 Output 18
stdin
null
1,984
1
[ "3 1 0 1\n" ]
[ "18\n" ]
[ "3 2 0 1\n", "1 2 0 1\n", "2 0 0 1\n", "2 1 0 1\n", "3 1 1 2\n", "3 -1 0 2\n", "3 -1 1 2\n", "5 0 -1 2\n", "4 0 1 3\n", "7 0 -1 2\n" ]
[ "12\n", "1\n", "2\n", "4\n", "18\n", "6\n", "24\n", "600\n", "120\n", "85680\n" ]
CodeContests
Snuke has a grid with H rows and W columns. The square at the i-th row and j-th column contains a character S_{i,j}. He can perform the following two kinds of operation on the grid: * Row-reverse: Reverse the order of the squares in a selected row. * Column-reverse: Reverse the order of the squares in a selected colu...
stdin
null
3,045
1
[ "2 2\ncf\ncf\n", "1 12\ncodefestival\n" ]
[ "6\n", "2\n" ]
[ "1 12\nctdefesoival\n", "0 12\nctdefesoival\n", "2 2\ncf\ndf\n", "2 2\ncf\nde\n", "0 12\nctdffesoival\n", "0 1\nctdffesoival\n", "0 1\ncfdftesoival\n", "0 2\ncfdftesoival\n", "0 4\ncfdftesoival\n", "0 2\ncfdftetoival\n" ]
[ "2\n", "1\n", "12\n", "24\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n" ]
CodeContests
We have a long seat of width X centimeters. There are many people who wants to sit here. A person sitting on the seat will always occupy an interval of length Y centimeters. We would like to seat as many people as possible, but they are all very shy, and there must be a gap of length at least Z centimeters between two...
stdin
null
3,082
1
[ "100000 1 1\n", "13 3 1\n", "64145 123 456\n", "12 3 1\n", "64146 123 456\n" ]
[ "49999\n", "3\n", "109\n", "2\n", "110\n" ]
[ "100010 1 1\n", "8 3 1\n", "64145 33 456\n", "12 3 2\n", "64146 123 44\n", "100010 1 0\n", "64145 33 653\n", "64146 205 44\n", "110010 1 0\n", "8 3 3\n" ]
[ "50004\n", "1\n", "130\n", "2\n", "383\n", "100010\n", "92\n", "257\n", "110010\n", "0\n" ]
CodeContests
Takahashi has N balls with positive integers written on them. The integer written on the i-th ball is A_i. He would like to form some number of pairs such that the sum of the integers written on each pair of balls is a power of 2. Note that a ball cannot belong to multiple pairs. Find the maximum possible number of pai...
stdin
null
1,568
1
[ "3\n1 2 3\n", "5\n3 11 14 5 13\n" ]
[ "1\n", "2\n" ]
[ "5\n3 21 14 5 13\n", "5\n2 3 24 6 13\n", "5\n2 3 38 3 10\n", "5\n3 24 14 5 13\n", "5\n3 24 14 10 13\n", "5\n3 24 16 10 13\n", "5\n3 36 16 10 13\n", "5\n3 36 16 14 13\n", "5\n3 3 16 14 13\n", "5\n3 3 24 14 13\n" ]
[ "1\n", "2\n", "0\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n" ]
CodeContests
In a game of chess, Check is a game position in which a player's King is under attack by any of the opponent's pieces. Bob is playing with Chess pieces. He randomly arranges three pieces on 8x8 chessboard: a black's King , a white's King and any one of the white's Queen, Knight, Bishop or Rook. Positions of these piec...
stdin
null
4,960
1
[ "4\ne8 e1\nq a4\ne7 d3\nb f6\nh6 g4 \nk h4\nd8 e1\nr d3\n\nSAMPLE\n" ]
[ "check\ncheck\n-1\ncheck\n" ]
[ "4\ne8 e1\nq a4\ne7 d3\nb f6\nh6 g4 \nk h4\nd8 e1\nr d3\n\nELPMAS\n", "4\ne8 e1\nr a4\ne7 d3\nb f6\nh5 g4 \nk h4\nd8 e1\nr d3\n\nSAMOLE\n", "4\ne8 e1\nq a4\ne7 d3\nb g6\nh6 g4 \nk h4\nd8 e1\nr d3\n\nELPMAS\n", "4\ne8 e1\nq a4\nf7 d3\nb f7\nh4 g3 \nk h5\ne8 d1\nr d4\n\nSAMPLE\n", "4\ne8 e1\np a4\nf7 d3\nb f7...
[ "check\ncheck\n-1\ncheck\n", "-1\ncheck\n-1\ncheck\n", "check\n-1\n-1\ncheck\n", "check\n-1\n-1\n-1\n", "-1\n-1\n-1\n-1\n", "-1\n-1\n-1\ncheck\n", "check\ncheck\n-1\n-1\n", "-1\ncheck\n-1\n-1\n", "-1\n-1\ncheck\n-1\n", "check\ncheck\ncheck\n-1\n" ]
CodeContests
We have a sequence of N integers: A_1, A_2, \cdots, A_N. You can perform the following operation between 0 and K times (inclusive): * Choose two integers i and j such that i \neq j, each between 1 and N (inclusive). Add 1 to A_i and -1 to A_j, possibly producing a negative element. Compute the maximum possible pos...
stdin
null
3,194
1
[ "8 7\n1 7 5 6 8 2 6 5\n", "2 10\n3 5\n", "2 3\n8 20\n", "4 5\n10 1 2 22\n" ]
[ "5\n", "8\n", "7\n", "7\n" ]
[ "8 11\n1 7 5 6 8 2 6 5\n", "2 1\n3 5\n", "2 1\n8 20\n", "4 5\n9 1 2 22\n", "8 11\n1 8 5 6 8 2 6 5\n", "4 5\n9 1 1 22\n", "4 5\n10 1 1 12\n", "2 3\n2 1\n", "4 5\n9 1 1 17\n", "4 5\n9 2 2 17\n" ]
[ "8\n", "4\n", "7\n", "2\n", "1\n", "11\n", "12\n", "3\n", "14\n", "10\n" ]
CodeContests
Chef has N simple polygons (non self intersecting polygons) in which no two of them intersect with each other. For any two polygons P1, P2, either P1 lies inside P2 or vice versa. Chef wants you to count number of polygons lying strictly inside each of the polygons. Input First line of the input contains an integer T...
stdin
null
910
1
[ "1\n3\n6\n-2 2 -1 1 2 2 2 -1 1 -2 -2 -2\n3\n-1 -1 1 -1 1 1\n4\n3 3 -3 3 -3 -3 3 -3\n" ]
[ "1 0 2\n" ]
[ "1\n3\n6\n-2 2 -1 1 2 2 2 -1 1 -2 -2 -2\n3\n-1 -1 1 -1 1 1\n4\n3 3 -3 1 -3 -3 3 -3\n", "1\n2\n6\n0 4 -1 1 2 1 0 -1 1 -2 -3 -2\n2\n-1 -1 1 -1 1 0\n2\n3 3 -2 1 -3 -3 3 -3\n", "1\n1\n6\n-2 2 -1 1 2 2 2 -1 1 -2 -3 -2\n3\n-1 -1 1 -1 1 0\n2\n3 3 -4 1 -3 -3 3 -3\n", "1\n3\n6\n0 4 -1 1 4 1 0 -1 1 -2 -3 -2\n2\n0 -1 1 ...
[ "1 0 2\n", "1 0\n", "0\n", "2 0 1\n", "1 0 2\n", "1 0 2\n", "1 0 2\n", "1 0 2\n", "1 0 2\n", "1 0 2\n" ]
CodeContests
We have an undirected graph G with N vertices numbered 1 to N and N edges as follows: * For each i=1,2,...,N-1, there is an edge between Vertex i and Vertex i+1. * There is an edge between Vertex X and Vertex Y. For each k=1,2,...,N-1, solve the problem below: * Find the number of pairs of integers (i,j) (1 \leq i...
stdin
null
688
1
[ "7 3 7\n", "10 4 8\n", "3 1 3\n", "5 2 4\n" ]
[ "7\n8\n4\n2\n0\n0\n", "10\n12\n10\n8\n4\n1\n0\n0\n0\n", "3\n0\n", "5\n4\n1\n0\n" ]
[ "4 1 3\n", "7 3 4\n", "10 4 6\n", "9 2 4\n", "14 3 4\n", "10 4 9\n", "10 4 5\n", "3 2 3\n", "5 1 4\n", "4 1 2\n" ]
[ "4\n2\n0\n", "6\n5\n4\n3\n2\n1\n", "10\n9\n8\n7\n5\n3\n2\n1\n0\n", "9\n8\n6\n5\n4\n3\n1\n0\n", "13\n12\n11\n10\n9\n8\n7\n6\n5\n4\n3\n2\n1\n", "10\n12\n11\n7\n4\n1\n0\n0\n0\n", "9\n8\n7\n6\n5\n4\n3\n2\n1\n", "2\n1\n", "5\n4\n1\n0\n", "3\n2\n1\n" ]
CodeContests
Problem statement There is a permutation with $ 1,2, ..., N $ sorted. I want to select two different numbers $ i $, $ j $ and replace them repeatedly to make them sorted (in the order of $ 1,2, ..., N $). Every time you replace the numbers $ i $, $ j $, you need $ c_ {i, j} $. Let $ f (p) $ be the minimum cost requir...
stdin
null
1,501
1
[ "3\n0 1 3\n1 0 8\n3 8 0\n" ]
[ "5\n" ]
[ "3\n0 1 3\n1 0 12\n3 8 0\n", "3\n0 2 3\n2 1 30\n3 14 0\n", "3\n0 1 3\n1 0 8\n3 11 0\n", "3\n0 1 3\n1 1 12\n3 8 0\n", "3\n0 1 3\n1 1 12\n3 5 0\n", "3\n0 1 3\n1 0 13\n3 8 0\n", "3\n0 1 3\n1 0 8\n3 21 0\n", "3\n0 1 3\n1 1 12\n3 8 1\n", "3\n0 1 3\n1 0 8\n3 8 1\n", "3\n1 1 3\n1 0 13\n3 8 0\n" ]
[ "5\n", "7\n", "5\n", "5\n", "5\n", "5\n", "5\n", "5\n", "5\n", "5\n" ]
CodeContests
Problem Statement You have just arrived in a small country. Unfortunately a huge hurricane swept across the country a few days ago. The country is made up of $n$ islands, numbered $1$ through $n$. Many bridges connected the islands, but all the bridges were washed away by a flood. People in the islands need new bridg...
stdin
null
4,719
1
[ "4\n1 1\n8 2\n9 1\n14 2\n4\n181 4\n815 4\n634 4\n370 4\n4\n52 1\n40 1\n81 2\n73 1\n10\n330 1\n665 3\n260 1\n287 2\n196 3\n243 1\n815 1\n287 3\n330 1\n473 4\n0\n" ]
[ "18\n634\n-1\n916\n" ]
[ "4\n1 1\n8 2\n9 1\n14 2\n4\n181 4\n815 4\n634 4\n370 4\n4\n52 1\n40 1\n81 2\n73 1\n10\n330 1\n665 3\n260 1\n287 2\n196 1\n243 1\n815 1\n287 3\n330 1\n473 4\n0\n", "4\n1 1\n8 2\n9 1\n14 2\n4\n181 4\n815 4\n634 4\n370 4\n4\n52 1\n40 1\n81 2\n73 1\n10\n330 1\n794 3\n260 1\n287 2\n196 1\n243 1\n815 1\n287 3\n330 1\n4...
[ "18\n634\n-1\n1354\n", "18\n634\n-1\n1483\n", "18\n634\n-1\n1804\n", "18\n634\n-1\n-1\n", "46\n634\n-1\n-1\n", "46\n453\n-1\n-1\n", "46\n880\n-1\n-1\n", "-1\n634\n-1\n916\n", "18\n634\n-1\n876\n", "18\n634\n-1\n1637\n" ]
CodeContests
We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer. Snuke's objective is to permute the element in a so that the following condition is satisfied: * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4. Determine whether Snuke can achieve his objective. ...
stdin
null
258
1
[ "6\n2 7 1 8 2 8\n", "3\n1 4 1\n", "3\n1 10 100\n", "2\n1 1\n", "4\n1 2 3 4\n" ]
[ "Yes\n", "Yes\n", "Yes\n", "No\n", "No\n" ]
[ "6\n2 7 2 8 2 8\n", "3\n-1 1 1\n", "3\n0 4 1\n", "3\n2 10 100\n", "4\n2 2 3 4\n", "6\n4 7 2 8 2 8\n", "3\n0 1 1\n", "3\n0 10 100\n", "4\n0 2 3 4\n", "6\n6 7 2 8 2 8\n" ]
[ "Yes\n", "No\n", "Yes\n", "Yes\n", "Yes\n", "Yes\n", "Yes\n", "Yes\n", "Yes\n", "Yes\n" ]
CodeContests
You are a programmer working for your local city hall. The town you live in has a thriving tourism industry, especially the beaches on the shores of remote islands. The area around this island is composed of sandy beaches, but in recent years the area of ​​the sandy beaches has decreased due to coastal erosion. The Tou...
stdin
null
3,849
1
[ "3 1\n0 0\n10 0\n5 10\n3 1\n0 0\n10 0\n0 10\n4 1\n0 0\n10 0\n10 10\n0 10\n0 0\n" ]
[ "22.6524758425\n23.8994949366\n32.0000000000\n" ]
[ "3 1\n0 0\n10 0\n5 10\n3 1\n0 0\n10 0\n0 10\n4 1\n1 0\n10 0\n10 10\n0 10\n0 0\n", "3 1\n0 0\n10 0\n5 10\n3 1\n0 0\n10 0\n0 10\n4 1\n1 0\n17 0\n10 10\n0 10\n0 0\n", "3 1\n0 0\n10 0\n5 10\n3 1\n0 0\n10 0\n0 10\n4 2\n0 0\n10 0\n10 10\n0 10\n0 0\n", "3 1\n0 0\n10 -1\n5 10\n3 1\n0 0\n10 0\n0 10\n4 1\n1 0\n10 0\n10...
[ "22.6524758425\n23.8994949366\n31.0399004969\n", "22.6524758425\n23.8994949366\n39.8051449895\n", "22.6524758425\n23.8994949366\n24.0000000000\n", "23.4779176160\n23.8994949366\n31.0399004969\n", "19.4858745283\n23.8994949366\n39.8051449895\n", "10.0920862034\n23.8994949366\n24.0000000000\n", "32.539428...
CodeContests
Little Shino loves to play with numbers. She just came to know about Fibonacci Series. Fibonacci Series is a series of number such that Fib(1) = 0 Fib(2) = 1 Fib(x) = Fib(x-1) + Fib(x-2)\;where\;2 < x Soon Little Shino realized that Fibonacci series grows very fast. So she just wants the sum of last 4 digits of the F...
stdin
null
445
1
[ "3\n1 3\n1 4\n8 10\n\nSAMPLE\n" ]
[ "2\n4\n68\n" ]
[ "3\n1 3\n1 3\n8 10\n", "10\n10 15\n1 110\n2 100\n100 100\n15 15\n99 99\n50 51\n2 3\n3 4\n4 5\n", "3\n1 3\n2 4\n8 10\n\nSAMPLE\n", "3\n1 3\n1 3\n10 10\n", "10\n10 15\n1 110\n2 100\n100 100\n15 15\n99 99\n69 51\n2 3\n3 4\n4 5\n", "10\n10 15\n1 110\n2 100\n100 100\n15 15\n99 99\n14 51\n2 3\n3 4\n4 5\n", "3...
[ "2\n2\n68\n", "932\n474113\n424100\n9026\n377\n6049\n11074\n2\n3\n5\n", "2\n4\n68\n", "2\n2\n34\n", "932\n474113\n424100\n9026\n377\n6049\n999919112\n2\n3\n5\n", "932\n474113\n424100\n9026\n377\n6049\n169722\n2\n3\n5\n", "2\n2\n999999953\n", "932\n474113\n424098\n9026\n377\n6049\n169722\n2\n3\n5\n", ...
CodeContests
Navi is a counter strike pro. He always say how good he is at counter strike. After being tired of Navi, his friends decided to test his skills at shooting. They put M targets on a X-Y plane, each target is denoted by (X, Y) where X is x-coordinate and Y is y-coordinate. His friends also gave him N locations on X-Y pl...
stdin
null
4,412
1
[ "1\n3 3 5\n1 1\n2 2\n3 3\n1 0\n0 0\n2 0\n\nSAMPLE\n" ]
[ "YES\n" ]
[ "1\n3 3 5\n1 1\n2 2\n3 3\n1 0\n0 0\n2 0\n\nSAMPLF\n", "1\n3 2 0\n1 0\n2 -1\n5 3\n1 1\n2 1\n2 1\n\nSPMALE\n", "1\n3 3 5\n1 1\n2 2\n3 3\n1 0\n0 0\n4 0\n\nSAMPLF\n", "1\n3 3 5\n1 1\n2 4\n3 3\n1 0\n0 0\n4 0\n\nSAMPLF\n", "1\n3 3 5\n1 1\n2 4\n3 3\n1 0\n0 0\n4 0\n\nFLPMAS\n", "1\n3 3 5\n2 1\n2 4\n3 3\n1 0\n0 0\...
[ "YES\n", "NO\n", "YES\n", "YES\n", "YES\n", "YES\n", "YES\n", "YES\n", "YES\n", "YES\n" ]
CodeContests
Takahashi has decided to give a string to his mother. The value of a string T is the length of the longest common subsequence of T and T', where T' is the string obtained by reversing T. That is, the value is the longest length of the following two strings that are equal: a subsequence of T (possibly non-contiguous), ...
stdin
null
1,769
1
[ "abcabcabc\n1\n", "atcodergrandcontest\n3\n" ]
[ "7\n", "15\n" ]
[ "abcabbacc\n1\n", "tsetnocdnargredocta\n3\n", "abcabbacc\n0\n", "tsetnocdnargredocta\n0\n", "abcabbbcc\n0\n", "tsetnocdnargredocta\n2\n", "tsetnocdnargredocta\n1\n", "tsetntcdnargredocoa\n0\n", "atcodergrandcontest\n6\n", "atcodergrandcontest\n5\n" ]
[ "8\n", "15\n", "6\n", "9\n", "5\n", "13\n", "11\n", "7\n", "17\n", "16\n" ]
CodeContests
While Omar was studying for Math lectures, he found the following problem. Given 3 Integers N_1, N_2, N_3, count the number of common divisors which divide all of them. Can you please help Omar in solving this problem, because he usually sleeps in lectures. Input: Given an integer T, which indicates the number o...
stdin
null
3,665
1
[ "1\n2 4 6\n\nSAMPLE\n" ]
[ "2\n" ]
[ "1\n2 6 6\n\nSAMPLE\n", "1\n2 8 5\n\nDAMPLS\n", "1\n4 8 8\n\nDAMPLS\n", "1\n6 18 6\n\nSLLQBE\n", "1\n2 10 6\n\nSAMPLE\n", "1\n2 10 6\n\nSAMPLD\n", "1\n2 8 6\n\nSAMPLD\n", "1\n2 8 6\n\nDAMPLS\n", "1\n2 8 10\n\nDAMPLS\n", "1\n2 4 9\n\nSAMPLE\n" ]
[ "2\n", "1\n", "3\n", "4\n", "2\n", "2\n", "2\n", "2\n", "2\n", "1\n" ]
CodeContests
Mike has a huge guitar collection which the whole band is jealous of. Brad, the lead guitarist of the band, gave Mike a challenge so that he can't use all his guitars. The band is on a world tour and Brad told Mike to assign numbers to all his guitars. After that, he told Mike that he can use the guitars in such a mann...
stdin
null
4,926
1
[ "3\n1\n1\n2\n1 2\n3\n1 2 3\n\nSAMPLE\n" ]
[ "2\n4\n7\n" ]
[ "3\n1\n1\n2\n1 2\n3\n1 2 3\n\nSAMPKE\n", "3\n1\n1\n2\n1 2\n3\n1 2 4\n\nSAMPKE\n", "3\n1\n1\n2\n1 0\n3\n1 2 4\n\nSAMPKE\n", "3\n1\n0\n2\n1 0\n3\n1 2 4\n\nSAMPKE\n", "3\n1\n0\n2\n1 2\n3\n1 2 3\n\nSAMPLE\n", "3\n1\n1\n2\n1 -1\n3\n1 2 4\n\nSAMPKE\n", "3\n1\n2\n2\n1 2\n3\n1 3 3\n\nSAMPKE\n", "3\n1\n1\n2\n0...
[ "2\n4\n7\n", "2\n4\n8\n", "2\n2\n8\n", "1\n2\n8\n", "1\n4\n7\n", "2\n3\n8\n", "2\n4\n6\n", "2\n2\n7\n", "2\n3\n7\n", "1\n4\n5\n" ]
CodeContests
Mahabir loves matrix and likes to rotate things a lot. Today he is rotating an array in clock-wise direction. He gives you an array of size N X N and an positive integer Q. Each Q number of integers contains an angle A (angle is always multiple of 90 or can be zero). You have to rotate the array ( clock-wise only )...
stdin
null
4,100
1
[ "3 3\n1 4 5 \n6 7 8 \n4 0 5 \n90\n180\n450\n\nSAMPLE\n" ]
[ "4 6 1\n0 7 4\n5 8 5\n\n5 0 4\n8 7 6\n5 4 1\n\n4 6 1\n0 7 4\n5 8 5\n" ]
[ "3 3\n1 4 5 \n7 7 8 \n4 0 5 \n90\n180\n450\n\nSAMPLE\n", "3 3\n1 4 5 \n7 9 8 \n4 0 5 \n90\n180\n450\n\nSAMPLE\n", "3 3\n1 2 5 \n6 7 8 \n4 0 5 \n90\n180\n450\n\nSAMPLE\n", "3 3\n1 4 5 \n6 2 8 \n4 0 5 \n90\n180\n450\n\nSAMPLE\n", "3 3\n1 4 5 \n7 9 8 \n4 1 5 \n90\n180\n450\n\nSAMPLE\n", "3 3\n1 2 5 \n6 7 5 \...
[ "4 7 1 \n0 7 4 \n5 8 5 \n\n5 0 4 \n8 7 7 \n5 4 1 \n\n4 7 1 \n0 7 4 \n5 8 5\n", "4 7 1 \n0 9 4 \n5 8 5 \n\n5 0 4 \n8 9 7 \n5 4 1 \n\n4 7 1 \n0 9 4 \n5 8 5\n", "4 6 1 \n0 7 2 \n5 8 5 \n\n5 0 4 \n8 7 6 \n5 2 1 \n\n4 6 1 \n0 7 2 \n5 8 5\n", "4 6 1 \n0 2 4 \n5 8 5 \n\n5 0 4 \n8 2 6 \n5 4 1 \n\n4 6 1 \n0 2 4 \n5 8 ...
CodeContests
Recently Chef become very much interested in perfect squares. We all know Chef and his weird interests. Anyways Chef will be soon writing his masters thesis on perfect squares revealing what-not-known properties of perfect squares. While doing his research, he happened to be confronted with some interesting perfect squ...
stdin
null
1,074
1
[ "2\n1 10\n100 10000\n" ]
[ "3\n9\n" ]
[ "2\n1 10\n100 11000\n", "2\n1 10\n100 01100\n", "2\n1 10\n110 10000\n", "2\n1 10\n110 11000\n", "2\n2 10\n100 11100\n", "2\n2 12\n110 11100\n", "2\n1 1\n010 10001\n", "2\n1 6\n110 10000\n", "2\n2 10\n100 01000\n", "2\n1 3\n110 10101\n" ]
[ "3\n10\n", "3\n5\n", "3\n8\n", "3\n9\n", "2\n10\n", "2\n9\n", "1\n10\n", "2\n8\n", "2\n5\n", "1\n8\n" ]
CodeContests
Little Bob comes to you for candies as you are his favorite coder! He wants X candies. You have N bags and the i^th bag contains A[i] candies. You can give him a set of one or more bags such that the sum of candies in those bags is EXACTLY equal to X. Bob wants to find smallest such set of bags. If there are multiple ...
stdin
null
796
1
[ "6 9\n5 7 1 4 4 1\n\nSAMPLE\n" ]
[ "1 4\n" ]
[ "17 13\n27 32 24 30 94 1 89 22 18 84 68 34 21 84 96 27 7\n", "20 1000\n10 20 30 40 50 60 70 80 113 100 200 300 400 500 600 700 110 120 130 400\n", "10 82\n78 64 85 30 53 18 23 22 90 41\n", "6 9\n5 7 1 4 2 1\n\nSAMPLE\n", "6 16\n5 7 1 4 2 1\n\nSAMPLE\n", "10 82\n155 102 85 10 53 18 23 43 83 41\n", "17 13...
[ "-1\n", "12 16\n", "2 6\n", "1 4\n", "1 2 4\n", "6 7 10\n", "3 11\n", "4 7 10\n", "4 8\n", "2\n" ]
CodeContests
You are given a string S of length N and another string T of length M. These strings consist of lowercase English letters. A string X is called a good string when the following conditions are all met: * Let L be the length of X. L is divisible by both N and M. * Concatenating the 1-st, (\frac{L}{N}+1)-th, (2 \times \...
stdin
null
1,012
1
[ "3 2\nacp\nae\n", "6 3\nabcdef\nabc\n", "15 9\ndnsusrayukuaiia\ndujrunuma\n" ]
[ "6\n", "-1\n", "45\n" ]
[ "3 2\nacq\nae\n", "3 3\nabcdef\nabc\n", "15 9\ndnsusrayukuaiia\nrujdunuma\n", "3 4\nasiaukvyartuind\naumnudjus\n", "15 9\ndnausrayukusiia\ndujrunuma\n", "1 2\nacq\nae\n", "4 1\nabq\nae\n", "15 16\ndnausrayukusiia\ndujrunuma\n", "1 1\n`br\n`e\n", "5 4\naiiaukuyarsusod\namtntdjur\n" ]
[ "6\n", "3\n", "-1\n", "12\n", "45\n", "2\n", "4\n", "240\n", "1\n", "20\n" ]
CodeContests
Twin adventurers Rin and Len are searching for treasure in the Mirror Cave. The cave has two pairs of rooms, the Hall of Mirrors, and an expensive treasure lies behind the door of the room. For convenience, each of the two rooms is considered to have W × H cells arranged in a grid pattern. The outside of the room is s...
stdin
null
3,810
1
[ "5 5\n%#... ...#%\n.#.#. .#.#.\n.#.#. .#.#.\n.#.#. .#.#.\n...#L R#...\n3 2\n.L. .R#\n%.. .%.\n4 1\nL.%. %..R\n0 0\n" ]
[ "Yes\nYes\nNo\n" ]
[ "5 5\n%#... ...#%\n.#.#. .#.#.\n.#.#. .#.#.\n.#.#. .#.#.\n...#L R#...\n3 2\n.L. .R#\n%.. .&.\n4 1\nL.%. %..R\n0 0\n", "5 5\n%#... .%.#.\n.#.#. .#.#.\n.#.#. .#.#.\n.#.#. .#.#.\n...#L R#...\n3 2\n.L. .R#\n%.. .&.\n4 1\nL.%. %..R\n0 0\n", "5 5\n%#... ...#%\n.#.#. .#.#.\n.#.#. .#.#.\n.#.#. .#.#.\n...#L R#...\n3 2\n...
[ "Yes\nNo\nNo\n", "No\nNo\nNo\n", "Yes\nNo\nNo\n", "Yes\nNo\nNo\n", "Yes\nNo\nNo\n", "Yes\nNo\nNo\n", "Yes\nNo\nNo\n", "Yes\nNo\nNo\n", "Yes\nNo\nNo\n", "Yes\nNo\nNo\n" ]
CodeContests
Scientists, researchers, mathematicians and thinkers propose theories for a number of things. For explaining a single thing, a number of theories are proposed. A number of theories are rendered invalid after a new and more relevant theory surfaces, giving a better and a more valid explanation for the subject of the ...
stdin
null
4,965
1
[ "1\n5\n1 10\n2 4\n3 5\n11 12\n12 13\n\nSAMPLE\n" ]
[ "3\n" ]
[ "1\n5\n1 12\n2 4\n3 5\n11 12\n12 13\n\nSAMPLE\n", "1\n5\n1 12\n2 8\n6 5\n11 12\n12 13\n\nSAMPLE\n", "1\n5\n0 12\n2 10\n6 5\n11 2\n12 13\n\nSAMPLE\n", "1\n5\n1 12\n2 8\n3 5\n11 12\n1 13\n\nSAMPLE\n", "1\n5\n1 12\n2 8\n3 5\n11 12\n12 13\n\nSAMPLE\n", "1\n5\n1 12\n4 8\n6 5\n11 12\n12 13\n\nSAMPLE\n", "1\n5...
[ "3\n", "2\n", "1\n", "4\n", "3\n", "2\n", "2\n", "3\n", "3\n", "3\n" ]
CodeContests
Income Inequality We often compute the average as the first step in processing statistical data. Yes, the average is a good tendency measure of data, but it is not always the best. In some cases, the average may hinder the understanding of the data. For example, consider the national income of a country. As the term ...
stdin
null
2,453
1
[ "7\n15 15 15 15 15 15 15\n4\n10 20 30 60\n10\n1 1 1 1 1 1 1 1 1 100\n7\n90 90 90 90 90 90 10\n7\n2 7 1 8 2 8 4\n0\n" ]
[ "7\n3\n9\n1\n4\n" ]
[ "7\n15 15 15 15 15 23 15\n4\n10 20 30 60\n10\n1 1 1 1 1 1 1 1 1 100\n7\n90 90 90 90 90 90 10\n7\n2 7 1 8 2 8 4\n0\n", "7\n15 15 1 15 15 23 15\n4\n10 20 30 60\n10\n1 1 1 1 1 1 1 1 1 100\n7\n90 90 90 90 90 90 10\n7\n2 7 1 8 2 11 4\n0\n", "7\n23 15 1 15 15 23 15\n4\n10 20 30 60\n10\n1 1 1 1 1 1 1 1 1 100\n7\n90 90...
[ "6\n3\n9\n1\n4\n", "1\n3\n9\n1\n4\n", "5\n3\n9\n1\n4\n", "5\n3\n9\n2\n4\n", "2\n3\n9\n2\n4\n", "4\n3\n9\n2\n4\n", "7\n3\n9\n1\n4\n", "1\n3\n9\n1\n3\n", "4\n3\n3\n2\n4\n", "6\n3\n9\n1\n3\n" ]
CodeContests
You’ve just entered a Japanese-style pub, or an izakaya in Japanese, for a drinking party (called nomi-kai) with your dear friends. Now you are to make orders for glasses of hard and soft drink as requested by the participants. But unfortunately, most staffs in typical izakayas are part-time workers; they are not used...
stdin
null
2,454
1
[ "3\n0.7 0.1 0.2\n0.1 0.8 0.1\n0.0 0.0 1.0\n4 3 2\n8\n0.125 0.125 0.125 0.125 0.125 0.125 0.125 0.125\n0.125 0.125 0.125 0.125 0.125 0.125 0.125 0.125\n0.125 0.125 0.125 0.125 0.125 0.125 0.125 0.125\n0.125 0.125 0.125 0.125 0.125 0.125 0.125 0.125\n0.125 0.125 0.125 0.125 0.125 0.125 0.125 0.125\n0.125 0.125 0.125 ...
[ "Case 1: -1.89723999\nCase 2: -8.14438201\nCase 3: -INFINITY\n" ]
[ "3\n0.7 0.1 0.2\n0.1 0.8 0.1\n0.0 0.0 1.0\n4 3 2\n8\n0.125 0.125 0.125 0.125 0.125 0.125 0.125 0.125\n0.125 0.125 0.125 0.125 0.125 0.125 0.125 0.125\n0.125 0.125 0.125 0.125 0.125 0.125 0.125 0.125\n0.125 0.125 0.125 0.125 0.125 0.125 0.125 0.125\n0.125 0.125 0.125 0.125 0.125 0.125 0.125 0.125\n0.125 0.125 0.125 ...
[ "Case 1: -1.89723999\nCase 2: -7.08773333\nCase 3: -INFINITY\n", "Case 1: -1.89723999\nCase 2: -6.42144125\nCase 3: -INFINITY\n", "Case 1: -1.89723999\nCase 2: -6.58315116\nCase 3: -INFINITY\n", "Case 1: -1.89723999\nCase 2: -6.58315116\nCase 3: 0.00000000\n", "Case 1: 0.04455206\nCase 2: -6.58315116\nCase ...
CodeContests
Your task is to write a program which reads a date (from 2004/1/1 to 2004/12/31) and prints the day of the date. Jan. 1, 2004, is Thursday. Note that 2004 is a leap year and we have Feb. 29. Input The input is a sequence of datasets. The end of the input is indicated by a line containing one zero. Each dataset cons...
stdin
null
1,371
1
[ "1 1\n2 29\n0 0\n" ]
[ "Thursday\nSunday\n" ]
[ "1 1\n2 26\n0 0\n", "2 1\n2 26\n0 0\n", "1 1\n3 26\n0 0\n", "2 1\n2 17\n0 0\n", "2 1\n2 18\n0 0\n", "2 1\n1 19\n0 0\n", "2 2\n2 17\n0 0\n", "2 2\n3 17\n0 0\n", "2 1\n1 17\n0 0\n", "2 1\n1 18\n0 0\n" ]
[ "Thursday\nThursday\n", "Sunday\nThursday\n", "Thursday\nFriday\n", "Sunday\nTuesday\n", "Sunday\nWednesday\n", "Sunday\nMonday\n", "Monday\nTuesday\n", "Monday\nWednesday\n", "Sunday\nSaturday\n", "Sunday\nSunday\n" ]
CodeContests
E: Arai's --Arai's- problem Arai's is a female idol group that has been popular since the school idol era. Nowadays, it is active at the world level as a large group to which many "Arai" belong. And today, it was decided to start a new project. They decided to try to further increase sales by forming several small un...
stdin
null
3,135
1
[ "3 3 4\n111\n111\n111\n111\n111\n111\n" ]
[ "2\n" ]
[ "3 3 4\n111\n111\n111\n111\n111\n011\n", "3 3 4\n111\n111\n011\n111\n011\n111\n", "3 1 4\n111\n111\n011\n111\n011\n111\n", "5 0 4\n011\n111\n011\n011\n010\n111\n", "5 4 2\n101\n110\n011\n111\n100\n101\n", "3 3 4\n111\n111\n011\n111\n111\n111\n", "3 1 4\n111\n111\n011\n111\n010\n111\n", "5 1 4\n111\n11...
[ "2\n", "3\n", "1\n", "0\n", "4\n", "2\n", "1\n", "1\n", "1\n", "1\n" ]
CodeContests
International Car Production Company (ICPC), one of the largest automobile manufacturers in the world, is now developing a new vehicle called "Two-Wheel Buggy". As its name suggests, the vehicle has only two wheels. Quite simply, "Two-Wheel Buggy" is made up of two wheels (the left wheel and the right wheel) and a axle...
stdin
null
4,988
1
[ "1 1\n180 90 2\n1 1\n180 180 20\n2 10\n360 -360 5\n-90 360 8\n3 2\n100 60 9\n-72 -72 10\n-45 -225 5\n0 0\n" ]
[ "3.00000\n3.00000\n0.00000\n62.83185\n12.00000\n0.00000\n-2.44505\n13.12132\n" ]
[ "1 1\n180 90 2\n1 1\n180 180 20\n2 10\n360 -360 5\n-9 360 8\n3 2\n100 60 9\n-72 -72 10\n-45 -225 5\n0 0\n", "1 1\n180 90 2\n1 1\n180 180 20\n2 13\n360 -360 5\n-9 360 8\n3 2\n100 60 9\n-72 -72 10\n-45 -225 5\n0 0\n", "1 1\n180 90 2\n1 1\n180 180 20\n2 13\n143 -360 5\n-9 360 8\n3 2\n100 60 9\n-72 -72 10\n-45 -225...
[ "3.00000000\n3.00000000\n0.00000000\n62.83185307\n17.54360710\n-5.09688903\n-2.44505027\n13.12132034\n", "3.00000000\n3.00000000\n0.00000000\n62.83185307\n20.47025001\n2.98909332\n-2.44505027\n13.12132034\n", "3.00000000\n3.00000000\n0.00000000\n62.83185307\n7.02124995\n10.28664424\n-2.44505027\n13.12132034\n",...
CodeContests
ICPC Calculator In mathematics, we usually specify the order of operations by using parentheses. For example, 7 × (3 + 2) always means multiplying 7 by the result of 3 + 2 and never means adding 2 to the result of 7 × 3. However, there are people who do not like parentheses. International Counter of Parentheses Counci...
stdin
null
2,656
1
[ "1\n9\n4\n+\n.1\n.2\n.3\n9\n+\n.0\n.+\n..*\n...1\n...*\n....1\n....2\n..0\n10\n+\n.+\n..6\n..2\n.+\n..1\n..*\n...7\n...6\n.3\n0\n" ]
[ "9\n6\n2\n54\n" ]
[ "1\n9\n4\n+\n.1\n.2\n.3\n9\n+\n.0\n.+\n..*\n...1\n...+\n....1\n....2\n..0\n10\n+\n.+\n..6\n..2\n.+\n..1\n..*\n...7\n...6\n.3\n0\n", "1\n9\n4\n+\n.1\n.2\n.3\n9\n+\n.0\n.*\n..*\n...1\n...+\n....1\n....2\n..0\n10\n+\n.+\n..6\n..2\n.+\n..1\n..*\n...7\n...6\n.3\n0\n", "1\n9\n4\n+\n.1\n.2\n.3\n9\n+\n.0\n.+\n..*\n...1...
[ "9\n6\n3\n54\n", "9\n6\n0\n54\n", "9\n6\n2\n53\n", "9\n6\n2\n95\n", "9\n6\n2\n96\n", "9\n6\n2\n54\n", "9\n6\n3\n53\n", "9\n6\n4\n54\n", "9\n6\n3\n60\n", "9\n6\n0\n96\n" ]
CodeContests
It is September 9 in Japan now. You are given a two-digit integer N. Answer the question: Is 9 contained in the decimal notation of N? Constraints * 10≤N≤99 Input Input is given from Standard Input in the following format: N Output If 9 is contained in the decimal notation of N, print `Yes`; if not, print `No...
stdin
null
1,368
1
[ "29\n", "91\n", "72\n" ]
[ "Yes\n", "Yes\n", "No\n" ]
[ "1\n", "69\n", "115\n", "84\n", "0\n", "181\n", "168\n", "174\n", "304\n", "143\n" ]
[ "No\n", "Yes\n", "No\n", "No\n", "No\n", "No\n", "No\n", "No\n", "No\n", "No\n" ]
CodeContests
Problem There is a tree with $ N $ vertices. Each vertex is assigned a number from 1 to $ N $. Gacho and Kawabayashi decided to play a camp game using this tree. The game starts with Gacho and Kawabayashi at different vertices. Gacho repeatedly moves the vertices alternately, and the one who can not move first is the ...
stdin
null
669
1
[ "6\n1 2\n2 3\n3 4\n4 5\n5 6\n", "2\n1 2\n", "20\n14 1\n2 1\n18 14\n10 1\n12 10\n5 1\n17 5\n7 1\n11 17\n4 1\n19 2\n15 1\n3 19\n8 15\n9 8\n20 8\n6 1\n16 15\n13 7\n", "5\n1 2\n1 3\n3 4\n3 5\n" ]
[ "12\n", "0\n", "243\n", "12\n" ]
[ "20\n14 1\n2 1\n18 4\n10 1\n12 10\n5 1\n17 5\n7 1\n11 17\n4 1\n19 2\n15 1\n3 19\n8 15\n9 8\n20 8\n6 1\n16 15\n13 7\n", "6\n1 3\n2 3\n3 4\n4 5\n5 6\n", "20\n14 1\n2 1\n18 14\n10 1\n12 10\n5 1\n17 5\n7 1\n11 17\n4 1\n19 2\n15 1\n3 19\n8 15\n9 16\n20 8\n6 1\n16 15\n13 7\n", "20\n14 1\n2 1\n18 14\n10 1\n12 10\n5 ...
[ "243\n", "14\n", "245\n", "247\n", "12\n", "8\n", "238\n", "19\n", "249\n", "237\n" ]
CodeContests
Given is a positive even number N. Find the number of strings s of length N consisting of `A`, `B`, and `C` that satisfy the following condition: * s can be converted to the empty string by repeating the following operation: * Choose two consecutive characters in s and erase them. However, choosing `AB` or `BA` is no...
stdin
null
609
1
[ "2\n", "1000000\n", "10\n" ]
[ "7\n", "210055358\n", "50007\n" ]
[ "4\n", "1100000\n", "8\n", "0100000\n", "14\n", "0110000\n", "0110010\n", "6\n", "1100010\n", "0100100\n" ]
[ "63\n", "298228697\n", "5407\n", "20343252\n", "4231815\n", "784164463\n", "189920713\n", "583\n", "865187132\n", "545699273\n" ]
CodeContests
Joisino the magical girl has decided to turn every single digit that exists on this world into 1. Rewriting a digit i with j (0≤i,j≤9) costs c_{i,j} MP (Magic Points). She is now standing before a wall. The wall is divided into HW squares in H rows and W columns, and at least one square contains a digit between 0 and...
stdin
null
1,014
1
[ "2 4\n0 9 9 9 9 9 9 9 9 9\n9 0 9 9 9 9 9 9 9 9\n9 9 0 9 9 9 9 9 9 9\n9 9 9 0 9 9 9 9 9 9\n9 9 9 9 0 9 9 9 9 2\n9 9 9 9 9 0 9 9 9 9\n9 9 9 9 9 9 0 9 9 9\n9 9 9 9 9 9 9 0 9 9\n9 9 9 9 2 9 9 9 0 9\n9 2 9 9 9 9 9 9 9 0\n-1 -1 -1 -1\n8 1 1 8\n", "3 5\n0 4 3 6 2 7 2 5 3 3\n4 0 5 3 7 5 3 7 2 7\n5 7 0 7 2 9 3 2 9 1\n3 6 ...
[ "12\n", "47\n", "0\n" ]
[ "2 4\n0 9 9 9 9 9 9 9 9 9\n9 0 9 9 9 9 9 9 9 9\n9 9 0 9 9 9 9 9 9 9\n9 9 9 0 2 9 9 9 9 9\n9 9 9 9 0 9 9 9 9 2\n9 9 9 9 9 0 9 9 9 9\n9 9 9 9 9 9 0 9 9 9\n9 9 9 9 9 9 9 0 9 9\n9 9 9 9 2 9 9 9 0 9\n9 2 9 9 9 9 9 9 9 0\n-1 -1 -1 -1\n8 1 1 8\n", "3 5\n0 4 3 6 2 7 2 5 3 3\n4 0 5 3 7 5 3 7 2 7\n5 7 0 7 2 9 3 2 9 1\n3 6 ...
[ "12\n", "47\n", "0\n", "999\n", "44\n", "15\n", "36\n", "1998\n", "14\n", "35\n" ]
CodeContests
Chef is sitting in a very boring lecture, waiting for it to end. He has recently asked his friend about the time, and instead of the straightforward answer, his friend, being an absolute jerk, told him the absolute value of angle between hour and minute hands. But that is obviously not what he wanted to know, so he a...
stdin
null
1,710
1
[ "2\n0\n30\n" ]
[ "00:00\n01:00\n11:00\n" ]
[ "2\n1\n30\n", "2\n2\n30\n", "2\n2\n41\n", "2\n2\n54\n", "2\n4\n54\n", "2\n4\n13\n", "2\n7\n13\n", "2\n7\n26\n", "2\n11\n26\n", "2\n0\n26\n" ]
[ "04:22\n07:38\n01:00\n11:00\n", "03:16\n08:44\n01:00\n11:00\n", "03:16\n08:44\n00:58\n11:02\n", "03:16\n08:44\n04:12\n07:48\n", "05:28\n06:32\n04:12\n07:48\n", "05:28\n06:32\n03:14\n08:46\n", "05:26\n06:34\n03:14\n08:46\n", "05:26\n06:34\n05:32\n06:28\n", "00:02\n11:58\n05:32\n06:28\n", "00:00\n05...
CodeContests
Stack is a container of elements that are inserted and deleted according to LIFO (Last In First Out). For $n$ stack $S_i$ ($i = 0, 1, ..., n-1$), perform a sequence of the following operations. * push($t$, $x$): Insert an integer $x$ to $S_t$. * top($t$): Report the value which should be deleted next from $S_t$. If $...
stdin
null
869
1
[ "3 9\n0 0 1\n0 0 2\n0 0 3\n0 2 4\n0 2 5\n1 0\n1 2\n2 0\n1 0\n" ]
[ "3\n5\n2\n" ]
[ "3 9\n0 0 0\n0 0 2\n0 0 3\n0 2 4\n0 2 5\n1 0\n1 2\n2 0\n1 0\n", "3 9\n0 0 0\n0 0 2\n0 0 3\n0 2 4\n0 0 5\n1 0\n1 2\n2 0\n1 0\n", "3 9\n0 0 0\n0 0 2\n0 0 3\n0 2 4\n0 2 5\n1 1\n1 2\n2 0\n1 0\n", "6 9\n0 0 0\n0 0 2\n0 0 3\n0 2 4\n0 0 5\n1 1\n1 2\n2 0\n1 0\n", "3 9\n0 0 0\n0 0 2\n0 0 1\n0 2 4\n0 2 9\n1 1\n1 2\n2...
[ "3\n5\n2\n", "5\n4\n3\n", "5\n2\n", "4\n3\n", "9\n2\n", "6\n5\n2\n", "5\n4\n1\n", "9\n1\n1\n", "6\n5\n2\n2\n2\n2\n", "9\n4\n4\n" ]
CodeContests
You are given a string S consisting of digits between `1` and `9`, inclusive. You will insert at most K commas (`,`) into this string to separate it into multiple numbers. Your task is to minimize the maximum number among those produced by inserting commas. Find minimum possible such value. Constraints * 0 ≦ K < |S|...
stdin
null
1,133
1
[ "8\n127356176351764127645176543176531763517635176531278461856198765816581726586715987216581\n", "2\n15267315\n", "0\n12456174517653111\n" ]
[ "5317635176\n", "315\n", "12456174517653111\n" ]
[ "8\n43266374421506181316476940597816436166806677255242361468471610026822687122922205449870\n", "2\n18507108\n", "0\n16408165208164532\n", "8\n40128623404893484002387295456399127508365095926846364056621145505791833348402674818341\n", "2\n32230236\n", "0\n9618006448576549\n", "8\n7063777014127277767087574...
[ "4326637442\n", "185\n", "16408165208164532\n", "3650959268\n", "236\n", "9618006448576549\n", "5310302405\n", "759\n", "15991921262607999\n", "7338916187\n" ]
CodeContests
Subodh'CS Department is writing a spell-checker system, and you have been tasked with writing a function to determine how closely two words resemble each other. The algorithm you are to use, albeit not a very good one, is to compare the two words character by character, and count how many times the characters in a give...
stdin
null
484
1
[ "4\nTICK\nTOCK\nCAT\nDOG\nAPPLE\nAPPLES \nFANTASTIC\nANTASTIC\n\nSAMPLE\n" ]
[ "3\n0\n5\n0\n" ]
[ "5\nOIL\nPFJMFWXQQYXBNJNTWIZVSRJIKPGIWEWN\nUCWHELOLFDGGPYKMZ\nCGHEAXJAMRSMDDNOJEFAOFVPAIVNSGJG\nZLOGAPUZTOHKFQGKSRSNFYVVQTIQMRJBSVOY\nJ\nFYLI\nWFSKQDNKTRHXZJC\nCOOGCEZEXKOZZQMKLLTTIL\n", "4\nTICK\nUOCK\nCAT\nDOG\nAPPLE\nAPPLES \nFANTASTIC\nANTASTIC\n\nSAMPLE\n", "4\nTICK\nUOCK\nCAT\nDOG\n@PPLE\nAPPLES \nFANTAST...
[ "0\n0\n0\n0\n0\n", "2\n0\n5\n0\n", "2\n0\n4\n0\n", "2\n0\n3\n0\n", "2\n0\n3\n1\n", "2\n0\n2\n1\n", "2\n0\n2\n2\n", "1\n0\n2\n2\n", "0\n0\n2\n2\n", "0\n0\n1\n2\n" ]
CodeContests
All space-time unified dimension sugoroku tournament. You are representing the Earth in the 21st century in the tournament, which decides only one Sugoroku absolute champion out of more than 500 trillion participants. The challenge you are currently challenging is one-dimensional sugoroku with yourself as a frame. Sta...
stdin
null
2,143
1
[ "11\n0\n0\n-2\n0\n-4\n1\n-1\n2\n0\n0\n0\n", "12\n0\n0\n7\n0\n2\n0\n0\n3\n-6\n-2\n1\n0\n", "8\n0\n4\n-1\n1\n-2\n-2\n0\n0\n" ]
[ "3\n", "1\n", "2\n" ]
[ "11\n0\n1\n-2\n0\n-4\n1\n-1\n2\n0\n0\n0\n", "12\n0\n0\n7\n0\n2\n0\n0\n3\n-5\n-2\n1\n0\n", "8\n0\n4\n-1\n1\n0\n-2\n0\n0\n", "12\n0\n-1\n7\n0\n2\n0\n0\n3\n-5\n-2\n1\n0\n", "8\n0\n4\n-2\n1\n0\n-2\n0\n0\n", "12\n0\n-1\n7\n0\n2\n0\n-1\n3\n-5\n-2\n1\n0\n", "8\n0\n4\n-2\n1\n0\n0\n0\n0\n", "12\n0\n-1\n7\n0\n3...
[ "3\n", "1\n", "2\n", "1\n", "2\n", "1\n", "2\n", "1\n", "1\n", "3\n" ]
CodeContests
Kattapa, as you all know was one of the greatest warriors of his time. The kingdom of Maahishmati had never lost a battle under him (as army-chief), and the reason for that was their really powerful army, also called as Mahasena. Kattapa was known to be a very superstitious person. He believed that a soldier is "lucky"...
stdin
null
3,898
1
[ "5\n1 2 3 4 5\n" ]
[ "NOT READY\n" ]
[ "5\n1 2 3 0 5\n", "5\n1 2 3 0 2\n", "5\n1 2 4 0 2\n", "5\n1 4 4 0 2\n", "5\n1 4 4 1 2\n", "5\n1 4 4 2 2\n", "5\n1 6 4 2 2\n", "5\n1 8 4 2 2\n", "5\n1 8 3 2 2\n", "5\n1 8 3 2 1\n" ]
[ "NOT READY\n", "READY FOR BATTLE\n", "READY FOR BATTLE\n", "READY FOR BATTLE\n", "READY FOR BATTLE\n", "READY FOR BATTLE\n", "READY FOR BATTLE\n", "READY FOR BATTLE\n", "READY FOR BATTLE\n", "NOT READY\n" ]
CodeContests
As you know, there is a furious battle going on between Marut and Devil. They are fighting with strings. Marut's strings are denoted by M and Devil's strings are denoted by D. Both of them are throwing strings on each other in order to get points. Their strings collide in air and one occurrence of some character in one...
stdin
null
4,219
1
[]
[]
[ "52 11 93 85 70 88 56 8 94 7 94 88 65 29 85 94 61 81 50 29 155 6 58 50 23 29\n10\numhtlftrgugcjjjjnjyzngmiwvgdtvzfnnsrqtqxlxsjlgbwqzpwxunvhnidywabchxteltjqibkkrnwjzxnctnklgkhpgisyydl\nuoggrzdwptkxmslslsamurtzamyvnkiwyioqjkduttnzdfughnrlhkguthyvinqgtgxfgumiilmnerlaypwdycfoghezpsfsogxm\nbohibazozkucvncubfgreiriqvdfdj...
[ "Devil\n", "Draw\n", "Marut\n", "Devil\n", "Draw\n", "Devil\n", "Draw\n", "Devil\n", "Draw\n", "Devil\n" ]
CodeContests
Problem KND is a student programmer at the University of Aizu. He is known to be a sweet tooth. He will be staying in a city for a year and wants to visit all N sweets shops in the city during that time. So I think the best place to live for the past year is the best place to go around the sweets shop. As his neighbor...
stdin
null
1,177
1
[ "2\n1 1 1\n2 2 1\n4\n1 1 3\n3 1 3\n4 2 1\n1 5 3\n0\n" ]
[ "0.70710678\n1.06066017\n" ]
[ "2\n1 1 1\n2 2 1\n4\n1 1 3\n3 1 3\n6 2 1\n1 5 3\n0\n", "2\n1 2 1\n2 2 1\n4\n1 1 3\n3 1 3\n6 2 1\n1 5 3\n0\n", "2\n1 2 1\n2 2 1\n4\n1 1 3\n3 1 3\n6 2 1\n1 5 2\n0\n", "2\n1 3 1\n2 2 1\n4\n1 1 3\n3 1 3\n6 3 1\n1 5 3\n0\n", "2\n1 3 1\n2 2 1\n4\n1 1 3\n3 0 3\n6 3 1\n1 5 4\n0\n", "2\n1 3 1\n1 2 1\n4\n1 1 3\n3 0...
[ "0.70710679\n1.45773798\n", "0.50000001\n1.45773798\n", "0.50000001\n1.94365064\n", "0.70710679\n1.37890244\n", "0.70710679\n1.34629120\n", "0.50000001\n1.34629120\n", "0.70710679\n2.54950977\n", "0.70710679\n1.60078106\n", "1.58113884\n1.37890244\n", "0.70710679\n1.79505494\n" ]
CodeContests
Ringo is giving a present to Snuke. Ringo has found out that Snuke loves yakiniku (a Japanese term meaning grilled meat. yaki: grilled, niku: meat). He supposes that Snuke likes grilled things starting with `YAKI` in Japanese, and does not like other things. You are given a string S representing the Japanese name of ...
stdin
null
2,605
1
[ "YAKINIKU\n", "TAKOYAKI\n", "YAK\n" ]
[ "Yes\n", "No\n", "No\n" ]
[ "UKINIKAY\n", "UAKOYAKI\n", "KAY\n", "NKIUIKAY\n", "IKAYOKAU\n", "JAY\n", "NKIUAKIY\n", "AAKOYUKI\n", "JAZ\n", "OKIUAKIY\n" ]
[ "No\n", "No\n", "No\n", "No\n", "No\n", "No\n", "No\n", "No\n", "No\n", "No\n" ]
CodeContests
Example Input R?????,2?) Output 29
stdin
null
2,223
1
[ "R?????,2?)\n" ]
[ "29\n" ]
[ ")?2,?????R\n", ")?2,???@?R\n", "S?????,2?)\n", ")?2??,???R\n", ")@2,?????R\n", "S???,??2?)\n", ")?2??-???R\n", ")@3,?????R\n", ")?2??,???S\n", ")?2??-???Q\n" ]
[ "invalid\n", "invalid\n", "invalid\n", "invalid\n", "invalid\n", "invalid\n", "invalid\n", "invalid\n", "invalid\n", "invalid\n" ]
CodeContests
Little Elephant from the Zoo of Lviv hates exams. Since Little Elephant lives in Ukraine, he is going to take exams called 'ZNO'. Help him. There will be n tickets on the table. Each ticket has a number written on it. The i-th ticket can be numbered Ai with probability Pi percent and with probability 100-Pi percent it ...
stdin
null
3,540
1
[ "2\n2\n50 1 2\n50 2 1\n3\n100 1 3\n47 2 1\n74 3 2\n" ]
[ "0.5\n0.3478\n" ]
[ "2\n2\n54 1 2\n50 2 1\n3\n100 1 3\n47 2 1\n74 3 2\n", "2\n2\n54 1 2\n50 2 1\n3\n100 1 3\n47 2 1\n5 3 2\n", "2\n2\n54 1 2\n50 2 1\n3\n100 1 3\n47 2 0\n5 4 2\n", "2\n2\n54 1 2\n52 2 1\n3\n100 1 3\n47 2 0\n5 4 2\n", "2\n2\n84 1 2\n52 2 1\n3\n100 1 3\n47 2 0\n5 4 2\n", "2\n2\n84 1 3\n52 2 1\n3\n100 1 6\n47 2 ...
[ "0.5\n0.3478\n", "0.5\n0.0235\n", "0.5\n0.5535\n", "0.5016\n0.5535\n", "0.5136\n0.5535\n", "0.5968\n0.5535\n", "0.5968\n0.527\n", "1.0\n0.527\n", "0.5968\n-0.05797\n", "0.5968\n0\n" ]
CodeContests
Let's play the game using a bag containing several cards with integers written on it. In each game, participants first declare one of their favorite number n. Then, take out an appropriate number of cards from the bag at a time, and if the sum of the numbers written on those cards is equal to n, you will receive a luxu...
stdin
null
4,865
1
[ "5\n1 10\n5 3\n10 3\n25 2\n50 2\n4\n120\n500\n100\n168\n7\n1 10\n3 10\n5 10\n10 10\n25 10\n50 10\n100 10\n3\n452\n574\n787\n0\n" ]
[ "16\n0\n12\n7\n9789\n13658\n17466\n" ]
[ "5\n1 10\n5 3\n10 3\n25 2\n50 2\n4\n120\n500\n100\n168\n7\n1 10\n3 10\n5 10\n10 10\n25 10\n10 10\n100 10\n3\n452\n574\n787\n0\n", "5\n2 10\n5 3\n10 3\n25 2\n50 2\n4\n120\n500\n100\n168\n7\n1 10\n3 10\n5 10\n10 10\n25 10\n10 10\n100 10\n3\n452\n574\n787\n0\n", "5\n2 10\n5 3\n5 3\n25 2\n50 2\n4\n120\n500\n100\n16...
[ "16\n0\n12\n7\n17574\n17580\n17578\n", "15\n0\n13\n7\n17574\n17580\n17578\n", "16\n0\n12\n6\n17574\n17580\n17578\n", "13\n0\n8\n5\n17574\n17580\n17578\n", "7\n0\n7\n0\n17574\n17580\n17578\n", "9\n0\n10\n0\n17574\n17580\n17578\n", "9\n0\n10\n0\n25384\n25563\n25591\n", "9\n0\n10\n0\n23233\n25734\n25772\...
CodeContests
Problem Statement You bought 3 ancient scrolls from a magician. These scrolls have a long string, and the lengths of the strings are the same. He said that these scrolls are copies of the key string to enter a dungeon with a secret treasure. However, he also said, they were copied so many times by hand, so the string ...
stdin
null
903
1
[ "3 1\nACM\nIBM\nICM\n5 2\niwzwz\niziwi\nzwizi\n1 0\nA\nB\nC\n10 5\njLRNlNyGWx\nyyLnlyyGDA\nyLRnvyyGDA\n0 0\n" ]
[ "ICM\niwiwi\n-1\nAARAlNyGDA\n" ]
[ "3 1\nACM\nIBM\nICM\n5 2\niwzwz\niziwi\nzwizi\n1 0\nA\nB\nC\n10 5\njLRNlNyGWx\nyyLolyyGDA\nyLRnvyyGDA\n0 0\n", "3 1\nACM\nIBM\nICM\n5 2\niwzwz\niziwi\nzwizi\n1 0\nA\nB\nC\n10 5\njLRNlNyGWx\nyyLolyyGDA\nyLGnvyyRDA\n0 0\n", "3 1\nACM\nIBM\nICM\n1 2\niwzwz\niwizi\nzwizi\n1 0\nA\nB\nC\n10 5\njLRNlNyGWx\nyyLnlyyGDA\...
[ "ICM\niwiwi\n-1\nAARAlNyGDA\n", "ICM\niwiwi\n-1\nALANlyyGDA\n", "ICM\nA\n-1\nAARAlNyGDA\n", "ICM\nA\n-1\nAAAAA\n", "-1\niwiwi\n-1\nALANlyyGDA\n", "ICM\nAA\n-1\nAAAAA\n", "ICM\nAA\n-1\nAAANlyyGD\n", "-1\niwiwi\n-1\nAAAAAAAAAA\n", "ICM\nAwA\n-1\nAAANlyyGD\n", "ICM\n-1\n-1\nAARAlNyGDA\n" ]
CodeContests
How many hours do we have until New Year at M o'clock (24-hour notation) on 30th, December? Constraints * 1≤M≤23 * M is an integer. Input Input is given from Standard Input in the following format: M Output If we have x hours until New Year at M o'clock on 30th, December, print x. Examples Input 21 Output...
stdin
null
1,646
1
[ "12\n", "21\n" ]
[ "36\n", "27\n" ]
[ "9\n", "34\n", "8\n", "25\n", "14\n", "49\n", "0\n", "4\n", "-1\n", "1\n" ]
[ "39\n", "14\n", "40\n", "23\n", "34\n", "-1\n", "48\n", "44\n", "49\n", "47\n" ]
CodeContests
You have N items and a bag of strength W. The i-th item has a weight of w_i and a value of v_i. You will select some of the items and put them in the bag. Here, the total weight of the selected items needs to be at most W. Your objective is to maximize the total value of the selected items. Constraints * 1 ≤ N ≤ 10...
stdin
null
4,586
1
[ "4 10\n1 100\n1 100\n1 100\n1 100\n", "4 1\n10 100\n10 100\n10 100\n10 100\n", "4 6\n2 1\n3 7\n4 10\n3 6\n", "4 6\n2 1\n3 4\n4 10\n3 4\n" ]
[ "400\n", "0\n", "13\n", "11\n" ]
[ "4 10\n1 100\n2 100\n1 100\n1 100\n", "4 1\n10 100\n10 100\n10 101\n10 100\n", "4 6\n2 1\n3 6\n4 10\n3 4\n", "4 10\n1 000\n1 100\n1 100\n1 100\n", "4 6\n2 1\n3 7\n4 10\n3 9\n", "4 12\n2 1\n3 4\n4 10\n3 4\n", "4 6\n2 1\n3 6\n4 8\n3 4\n", "4 6\n2 1\n3 6\n4 10\n3 9\n", "4 10\n1 100\n4 100\n1 101\n1 100...
[ "400\n", "0\n", "11\n", "300\n", "16\n", "19\n", "10\n", "15\n", "401\n", "14\n" ]
CodeContests
F: 01 Binary String with Slit problem You will be given the string S, which consists of only 0 and 1 character types. I want to change S to T by repeating the following operation. * Place a slit with a width of 2 so that it contains the 1 that appears on the far right in the string S. The slit must always contain tw...
stdin
null
2,342
1
[ "4\n101 110\n101 101\n1010 1101\n11011001 10010101\n" ]
[ "1\n0\n3\n12\n" ]
[ "4\n101 100\n101 101\n1010 1101\n11011001 10010101\n", "4\n101 100\n101 101\n1010 1101\n01011001 10010101\n", "4\n101 100\n101 111\n1010 1101\n01011001 10010101\n", "4\n101 110\n101 101\n0010 1101\n11011001 10010101\n", "4\n101 100\n101 101\n1010 1100\n11011001 10010101\n", "4\n101 100\n101 011\n1010 1101...
[ "2\n0\n3\n12\n", "2\n0\n3\n14\n", "2\n2\n3\n14\n", "1\n0\n5\n12\n", "2\n0\n1\n12\n", "2\n4\n3\n14\n", "1\n0\n3\n12\n", "0\n4\n3\n14\n", "1\n0\n3\n6\n", "1\n0\n1\n12\n" ]
CodeContests
Problem description It is winter super sale and all the shops have various offers. Suraj selected N items to buy and he is standing in the billing queue. It was then he noticed the offer "Buy two, get two". That means for every two items you buy, they give you two items for free. However, items can be of varying price,...
stdin
null
909
1
[ "3\n4\n1 1 2 2\n2\n10 200\n7\n1 1 10 2 2 2 1\n" ]
[ "4\n210\n14\n" ]
[ "3\n4\n1 1 2 1\n2\n10 200\n7\n1 1 10 2 2 2 1\n", "3\n4\n1 1 2 2\n2\n10 200\n7\n1 2 10 2 2 2 1\n", "3\n4\n1 1 2 2\n2\n10 200\n7\n1 2 10 2 2 3 1\n", "3\n4\n1 1 2 2\n2\n20 200\n7\n1 2 10 2 2 3 1\n", "3\n4\n1 1 2 2\n2\n34 200\n7\n1 2 10 2 2 3 1\n", "3\n4\n1 1 2 2\n2\n10 200\n7\n1 1 13 2 2 2 1\n", "3\n4\n1 1...
[ "3\n210\n14\n", "4\n210\n15\n", "4\n210\n16\n", "4\n220\n16\n", "4\n234\n16\n", "4\n210\n17\n", "4\n98\n16\n", "4\n123\n17\n", "4\n148\n16\n", "3\n210\n17\n" ]
CodeContests
For skilled programmers, it is very easy to implement a sorting function. Moreover, they often avoid full sorting to reduce computation time if it is not necessary. Here, we consider "rough sorting" which sorts an array except for some pairs of elements. More formally, we define an array is "$K$-roughly sorted" if an a...
stdin
null
77
1
[ "3 100\n3\n2\n1\n", "3 1\n3\n2\n1\n", "5 3\n5\n3\n2\n1\n4\n", "5 3\n1\n2\n3\n4\n5\n" ]
[ "3\n2\n1\n", "1\n3\n2\n", "1\n3\n5\n2\n4\n", "1\n2\n3\n4\n5\n" ]
[ "3 2\n3\n2\n1\n", "3 4\n3\n2\n1\n", "3 0\n3\n2\n1\n", "3 001\n3\n2\n1\n", "5 1\n5\n3\n2\n1\n4\n", "5 6\n1\n2\n3\n4\n5\n", "5 2\n5\n3\n2\n1\n4\n", "3 100\n3\n1\n2\n", "1 2\n1\n2\n3\n4\n5\n", "2 3\n1\n2\n2\n0\n1\n" ]
[ "2\n3\n1\n", "3\n2\n1\n", "1\n2\n3\n", "1\n3\n2\n", "1\n2\n3\n5\n4\n", "1\n2\n3\n4\n5\n", "1\n2\n5\n3\n4\n", "3\n1\n2\n", "1\n", "1\n2\n" ]
CodeContests
Mittal lives in the Niti Colony. The colony has N houses numbered from 1 to N. There are M bidirectional roads in the colony for travelling between houses. There might be multiple roads between two houses. Mittal lives in the house with index 1. He has friends in all houses of the colony. He is always wanting to visi...
stdin
null
5,042
1
[ "1\n5 5\n1 2 2\n2 3 4\n3 4 5\n4 5 1\n1 4 7\n3\n4 20\n5 21\n3 5\n\nSAMPLE\n" ]
[ "6\n5\n0\n" ]
[ "1\n5 5\n1 2 2\n2 3 4\n3 3 5\n4 5 1\n1 4 7\n3\n4 20\n5 21\n3 5\n\nSAMPLE\n", "2\n2 2\n1 2 10\n1 2 2\n4\n2 45\n2 30\n2 11\n2 13\n3 6\n1 2 2\n2 3 4\n2 3 10\n2 3 4\n1 2 5\n2 3 6\n5\n3 20\n3 22\n3 46\n2 41\n3 50\n", "1\n5 5\n1 2 2\n2 3 4\n3 4 5\n4 5 1\n1 4 7\n1\n4 20\n5 21\n3 5\n\nSAMPLE\n", "1\n5 5\n1 2 2\n2 3 4...
[ "6\n5\n0\n", "41\n26\n7\n9\n8\n10\n34\n37\n38\n", "6\n", "0\n0\n0\n", "41\n26\n7\n22\n8\n10\n34\n37\n38\n", "6\n0\n0\n", "41\n26\n11\n9\n8\n10\n34\n37\n38\n", "2\n", "41\n26\n7\n22\n8\n14\n34\n37\n38\n", "10\n0\n0\n" ]
CodeContests
One day, during daily web surfing, you encountered a web page which was written in a language you've never seen. The character set of the language was the same as your native language; moreover, the grammar and words seemed almost the same. Excitedly, you started to "decipher" the web page. The first approach you tried...
stdin
null
4,205
1
[ "1 5\nqwerty asdf zxcv\nqwert\nasf\ntyui\nzxcvb\nghjk\n" ]
[ "3\n" ]
[ "1 10\nqwerty asdf zxcv\nqwert\nasf\ntyui\nzxcvb\nghjk\n", "1 10\nqwerty asdf zcxv\nqwert\nasf\ntxui\nzxcvb\nghjk\n", "1 10\nqwerty ascf xczv\nqwert\nasf\ntxui\nbvcxz\nghjk\n", "1 10\nytrewq ascf xczv\nqwert\nasf\ntxui\nbvcxz\nghjk\n", "1 15\nqwerty fcsa xczv\nqwert\nasf\ntxui\nzxcvb\ngijk\n", "1 15\nqwer...
[ "3\n", "5\n", "6\n", "10\n", "7\n", "8\n", "9\n", "17\n", "16\n", "15\n" ]
CodeContests
Snuke has a blackboard and a set S consisting of N integers. The i-th element in S is S_i. He wrote an integer X on the blackboard, then performed the following operation N times: * Choose one element from S and remove it. * Let x be the number written on the blackboard now, and y be the integer removed from S. Repla...
stdin
null
4,344
1
[ "5 82\n22 11 6 5 13\n", "10 100000\n50000 50001 50002 50003 50004 50005 50006 50007 50008 50009\n", "2 19\n3 7\n" ]
[ "288\n", "279669259\n", "3\n" ]
[ "5 82\n22 11 6 7 13\n", "10 100000\n13715 50001 50002 50003 50004 50005 50006 50007 50008 50009\n", "2 19\n3 11\n", "5 134\n22 11 6 7 13\n", "10 100000\n13715 50001 50002 50003 50004 50005 50006 50532 50008 50009\n", "10 000000\n13715 50001 50002 50003 50004 50005 50006 50532 50008 50009\n", "10 100000\...
[ "516\n", "353097390\n", "3\n", "264\n", "162585390\n", "0\n", "219654823\n", "168\n", "2\n", "456\n" ]
CodeContests
Write a program which reads three integers a, b and c, and prints "Yes" if a < b < c, otherwise "No". Constraints * 0 ≤ a, b, c ≤ 100 Input Three integers a, b and c separated by a single space are given in a line. Output Print "Yes" or "No" in a line. Examples Input 1 3 8 Output Yes Input 3 8 1 Output...
stdin
null
2,745
1
[ "1 3 8\n", "3 8 1\n" ]
[ "Yes\n", "No\n" ]
[ "1 6 8\n", "3 7 1\n", "1 6 9\n", "3 7 2\n", "1 9 9\n", "3 7 3\n", "1 9 2\n", "2 7 3\n", "1 6 2\n", "3 9 3\n" ]
[ "Yes\n", "No\n", "Yes\n", "No\n", "No\n", "No\n", "No\n", "No\n", "No\n", "No\n" ]
CodeContests
We have two bottles for holding water. Bottle 1 can hold up to A milliliters of water, and now it contains B milliliters of water. Bottle 2 contains C milliliters of water. We will transfer water from Bottle 2 to Bottle 1 as much as possible. How much amount of water will remain in Bottle 2? Constraints * All val...
stdin
null
2,841
1
[ "12 3 7\n", "8 3 9\n", "6 4 3\n" ]
[ "0\n", "4\n", "1\n" ]
[ "12 0 7\n", "8 3 16\n", "8 6 16\n", "1 6 16\n", "0 2 0\n", "0 6 16\n", "0 4 0\n", "0 6 4\n", "1 4 0\n", "1 7 0\n" ]
[ "0\n", "11\n", "14\n", "21\n", "2\n", "22\n", "4\n", "10\n", "3\n", "6\n" ]
CodeContests
I am a craftsman specialized in interior works. A customer asked me to perform wiring work on a wall whose entire rectangular surface is tightly pasted with pieces of panels. The panels are all of the same size (2 m in width, 1 m in height) and the wall is filled with an x (horizontal) by y (vertical) array of the pane...
stdin
null
4,197
1
[ "4 6\n", "4 4\n" ]
[ "9\n", "5\n" ]
[ "2 4\n", "1 8\n", "5 6\n", "1 0\n", "9 6\n", "4 13\n", "9 3\n", "6 1\n", "2 13\n", "7 1\n" ]
[ "5\n", "9\n", "11\n", "1\n", "13\n", "17\n", "10\n", "7\n", "15\n", "8\n" ]
CodeContests
Chef wants to implement wildcard pattern matching supporting only the wildcard '?'. The wildcard character '?' can be substituted by any single lower case English letter for matching. He has two strings X and Y of equal length, made up of lower case letters and the character '?'. He wants to know whether the strings X ...
stdin
null
3,379
1
[ "2\ns?or?\nsco??\nstor?\nsco??\n" ]
[ "Yes\nNo\n" ]
[ "2\ns?o?r\nsco??\nstor?\nsco??\n", "2\nr?o?s\nsco??\nstor?\nsco??\n", "2\nr?o?s\nsco??\n?rots\nsco??\n", "2\nr?o?s\nsco??\n@rots\nsco??\n", "2\nr?o?s\nsco??\n@rots\n??ocs\n", "2\nr?o?s\nsco??\n@rots\ntco??\n", "2\nr?o?s\nsco??\n@rots\nuco??\n", "2\nr?o?s\nsco??\n@rots\nucp??\n", "2\nr?o?s\nsdo??\n@r...
[ "Yes\nNo\n", "No\nNo\n", "No\nNo\n", "No\nNo\n", "No\nNo\n", "No\nNo\n", "No\nNo\n", "No\nNo\n", "No\nNo\n", "No\nNo\n" ]
CodeContests
problem The JOI building is a combination of regular hexagons with a side of 1 meter as shown in the figure. As Christmas is approaching, JOI decided to decorate the walls of the building with illuminations. However, since it is useless to illuminate the parts that cannot be seen from the outside, we decided to decora...
stdin
null
1,176
1
[ "8 4\n0 1 0 1 0 1 1 1\n0 1 1 0 0 1 0 0\n1 0 1 0 1 1 1 1\n0 1 1 0 1 0 1 0\n" ]
[ "64\n" ]
[ "8 4\n0 1 0 1 1 1 1 1\n0 1 1 0 0 1 0 0\n1 0 1 0 1 1 1 1\n0 1 1 0 1 0 1 0\n", "8 0\n0 1 0 1 1 1 1 1\n0 1 1 0 0 1 0 0\n1 0 1 0 1 1 1 1\n0 1 1 0 1 0 1 0\n", "8 1\n0 1 0 1 0 1 1 1\n0 1 1 -1 0 1 -1 1\n2 1 1 0 1 1 1 1\n0 1 1 1 1 0 0 0\n", "11 1\n0 1 0 1 0 1 1 1\n0 1 1 -4 0 1 -1 1\n2 1 1 0 1 1 1 1\n0 1 1 1 1 0 -1 0\...
[ "64\n", "0\n", "26\n", "36\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n" ]
CodeContests
<image> One evening. As usual, when you were watching TV in the living room, my sister in fifth grade offered me a consultation. When I listened to the story, I couldn't understand the math problem that was presented at school today, so I want you to teach me how to solve it. The question that bothers my sister is, "...
stdin
null
3,249
1
[ "6 4 0\n", "124 218 367\n", "3 3 1\n" ]
[ "210\n", "817857665\n", "448\n" ]
[ "6 4 -1\n", "29 218 367\n", "3 3 0\n", "29 430 367\n", "3 0 0\n", "29 430 669\n", "29 430 465\n", "29 145 465\n", "27 145 465\n", "40 145 465\n" ]
[ "0\n", "816094540\n", "20\n", "63949264\n", "1\n", "643250629\n", "780099347\n", "362535843\n", "536043505\n", "5957501\n" ]
CodeContests
You are given a string S. Each character of S is uppercase or lowercase English letter. Determine if S satisfies all of the following conditions: * The initial character of S is an uppercase `A`. * There is exactly one occurrence of `C` between the third character from the beginning and the second to last character (i...
stdin
null
1,366
1
[ "AtCoCo\n", "Atcoder\n", "ACoder\n", "AcycliC\n", "AtCoder\n" ]
[ "WA\n", "WA\n", "WA\n", "WA\n", "AC\n" ]
[ "AtBoCo\n", "AtCoddr\n", "redoctA\n", "ACodes\n", "BcycliC\n", "etCodAr\n", "AtBnCo\n", "redpctA\n", "ACodds\n", "CilcycB\n" ]
[ "WA\n", "AC\n", "WA\n", "WA\n", "WA\n", "WA\n", "WA\n", "WA\n", "WA\n", "WA\n" ]
CodeContests
Write a program which prints small/large/equal relation of given two integers a and b. Constraints * -1000 ≤ a, b ≤ 1000 Input Two integers a and b separated by a single space are given in a line. Output For given two integers a and b, print a < b if a is less than b, a > b if a is greater than b, and a...
stdin
null
3,062
1
[ "5 5\n", "1 2\n", "4 3\n" ]
[ "a == b\n", "a\n", "a > b\n" ]
[ "5 10\n", "1 1\n", "2 0\n", "2 3\n", "5 6\n", "0 1\n", "2 5\n", "5 12\n", "-1 1\n", "2 8\n" ]
[ "a < b\n", "a == b\n", "a > b\n", "a < b\n", "a < b\n", "a < b\n", "a < b\n", "a < b\n", "a < b\n", "a < b\n" ]
CodeContests
A particular name-recording system is used by N employees of a firm. Everyday, they have to enter their names into the system. To make it easier to control the system, each employee has his/her name presented as a string of lowercase letters from 'a' to 'z' with the same length K. Therefore, the system is designed to ...
stdin
null
4,534
1
[ "2\n3 3\naaa\nccc\nddd\n5 1\na\na\nb\nb\na\n\nSAMPLE\n" ]
[ "ccc\na\n" ]
[ "10\n1 19\nmvwabkokuwzqgzvscwv\n10 10\ncibcezzbig\naaqwyzwubx\njvpbtbmfab\nngvopgoyea\nwtfcwzgesd\nduvgdawcly\nkevwzyjhvs\nqubrrsftkf\nhrgajwbzao\nacrqkyfjgx\n5 12\nvyxabtzcvcin\nofgsqdbaafgc\ngbqaexyxciyw\ndataqnbdbnej\nhyaqxsddhadj\n2 20\nzvxzezwprmgctgllbevz\nmfgwuxoagumkyawuwqcg\n4 2\neb\nac\ndv\nbb\n4 4\nased\...
[ "mvwabkokuwzqgzvscwv\nhipgpwjhgg\nhfqaqsddcfgj\nmfgwexoagmgctallbecg\nbb\nedid\nbwaratbacrfhaybnah\netqpjpg\neulvk\ntretkdmteghkdn\n", "dxrgfropsshuh\nxpgma\npxctogf\ntsrr\nyjekbbe\nhgidunolkkkkkk\ncxccgjipns\nfhjcknvhqdbhytkgjoq\nwnnjgk\nomguilklogfsfddhkij\n", "iomnilmomiln\njmruqjigkorohkil\npcwxk\nukrfhkjls...
CodeContests
You are given an array a_0, a_1, ..., a_{N-1} of length N. Process Q queries of the following types. * `0 p x`: a_p \gets a_p + x * `1 l r`: Print \sum_{i = l}^{r - 1}{a_i}. Constraints * 1 \leq N, Q \leq 500,000 * 0 \leq a_i, x \leq 10^9 * 0 \leq p < N * 0 \leq l_i < r_i \leq N * All values in Input are integer. I...
stdin
null
3,191
1
[ "5 5\n1 2 3 4 5\n1 0 5\n1 2 4\n0 3 10\n1 0 5\n1 0 3\n" ]
[ "15\n7\n25\n6\n" ]
[ "5 5\n1 2 3 4 5\n1 1 5\n1 2 4\n0 3 10\n1 0 5\n1 0 3\n", "5 5\n1 2 5 4 5\n1 1 5\n1 2 4\n0 3 10\n1 0 5\n1 0 3\n", "5 5\n1 2 5 4 5\n1 1 2\n1 2 4\n0 3 10\n1 0 5\n1 0 3\n", "5 5\n1 0 3 4 5\n1 0 5\n1 2 4\n0 3 10\n1 0 5\n1 0 3\n", "5 5\n1 2 3 4 5\n1 1 5\n1 2 4\n0 3 18\n1 0 5\n1 0 3\n", "5 5\n1 0 3 4 5\n1 0 5\n1 ...
[ "14\n7\n25\n6\n", "16\n9\n27\n8\n", "2\n9\n27\n8\n", "13\n7\n23\n4\n", "14\n7\n33\n6\n", "13\n7\n9\n", "16\n9\n32\n8\n", "13\n3\n23\n4\n", "13\n7\n23\n0\n", "20\n13\n36\n12\n" ]
CodeContests
You are a resident of Kyoot (oh, well, it’s not a misspelling!) city. All streets there are neatly built on a grid; some streets run in a meridional (north-south) direction and others in a zonal (east-west) direction. The streets that run from north to south are called avenues, whereas those which run from east to west...
stdin
null
3,209
1
[ "4 4\n2 2 2\n2 2 2\n99 1 0\n1 99 1\n1 99 1\n1 99 1\n1 99 1\n1 99 1\n1 99 1\n99 1 0\n99 1 0\n1 99 1\n1 99 1\n1 99 1\n1 99 1\n1 99 1\n1 99 1\n99 1 0\n1 0\n1 6\n2 2\n10\n10\n5 5 0\n5 5 0\n5 5 0\n5 5 0\n5 0\n5 10\n0 0\n" ]
[ "28\n25\n" ]
[ "4 4\n2 2 2\n2 2 2\n99 1 0\n1 99 1\n1 99 1\n1 99 1\n1 19 1\n1 99 1\n1 99 1\n99 1 0\n99 1 0\n1 99 1\n1 99 1\n1 99 1\n1 99 1\n1 99 1\n1 99 1\n99 1 0\n1 0\n1 6\n2 2\n10\n10\n5 5 0\n5 5 0\n5 5 0\n5 5 0\n5 0\n5 10\n0 0\n", "4 4\n2 2 2\n2 2 2\n99 1 0\n1 99 1\n1 99 1\n1 99 1\n1 99 1\n1 99 1\n1 99 1\n99 1 0\n99 1 0\n1 99...
[ "28\n25\n", "24\n25\n", "36\n25\n", "24\n20\n", "28\n10\n", "36\n22\n", "24\n15\n", "36\n20\n", "20\n25\n", "36\n23\n" ]
CodeContests
1 Problem Statement There is a bit string of length n. When the i-th bit from the left is 1, the score is a_i points. The number of 1s within the distance w around the i-th bit from the left (= | \\ {j \ in \\ {1, ..., n \\} ∩ \\ {iw, ..., i + w \\} | When the jth bit from the left is 1 \\} |) is odd, the score is b...
stdin
null
549
1
[ "4 1\n3 1 2 7\n13 8 25 9\n", "2 1\n1 1\n3 3\n" ]
[ "1001\n", "10\n" ]
[ "4 1\n3 2 2 7\n13 8 25 9\n", "2 1\n1 0\n3 3\n", "2 1\n0 0\n5 3\n", "3 1\n1 1\n6 8\n", "4 2\n0 4 1 0\n16 8 19 9\n", "1 1\n1 1\n6 14\n", "2 0\n1 1\n10 6\n", "3 1\n2 1\n6 14\n", "3 2\n0 4 1 0\n16 8 19 9\n", "4 0\n0 4 1 0\n16 8 0 9\n" ]
[ "1001\n", "10\n", "01\n", "011\n", "0100\n", "1\n", "11\n", "101\n", "111\n", "1111\n" ]
CodeContests
Boolean Expression Compressor You are asked to build a compressor for Boolean expressions that transforms expressions to the shortest form keeping their meaning. The grammar of the Boolean expressions has terminals `0` `1` `a` `b` `c` `d` `-` `^` `*` `(` `)`, start symbol <E> and the following production rule: > <E>...
stdin
null
3,286
1
[ "0\n(a*(1*b))\n(1^a)\n(-(-a*-b)*a)\n(a^(b^(c^d)))\n.\n" ]
[ "1\n5\n2\n1\n13\n" ]
[ "0\n(a*(1*b))\n(1^a)\n(-(-a*-b)*a)\nca^(b^((^d)))\n.\n", "0\n(a*(1*b))\n(1^a)\n(-(-b*-b)*a)\nca^(b^((^d)))\n.\n", "0\n(a*(1*b))\n(0^a)\n(-(-b*-b)*a)\nca^(b^((^e)))\n.\n", "0\n(a*(0*b))\n(1^a)\n(-(-a*-b)*a)\n(a^(b^(c^d)))\n.\n", "0\na(*(1*c))\n(1^a)\n(-(-b*-b)*a)\nca)(b^)(^e)^)\n.\n", "0\n(a*(1*b))\n(1^b)\...
[ "1\n5\n2\n1\n1\n", "1\n5\n2\n5\n1\n", "1\n5\n1\n5\n1\n", "1\n1\n2\n1\n13\n", "1\n1\n2\n5\n1\n", "1\n5\n2\n1\n13\n", "1\n5\n1\n12\n1\n", "1\n1\n2\n1\n5\n", "1\n1\n1\n5\n1\n", "1\n5\n2\n12\n1\n" ]
CodeContests
Problem statement Real variables $ x_1, x_2, ..., x_N $ satisfy the following conditions. 1. $ 0 \ leq x_i \ leq 1 $ ($ 1 \ leq i \ leq N $) 2. $ w_1x_1 + w_2x_2 + ... + w_Nx_N \ leq W $ At this time, find the maximum value that $ v_1x_1 + v_2x_2 + ... + v_Nx_N $ can take. It is known that such a maximum actually ...
stdin
null
2,221
1
[ "1 1\n3 1\n", "2 1\n-1 -3\n3 10\n", "2 3\n3 3\n1 2\n" ]
[ "0.333333\n", "3.666667\n", "4.000000\n" ]
[ "0 1\n3 1\n", "2 2\n-1 -3\n3 10\n", "2 3\n4 3\n1 2\n", "2 3\n4 2\n1 2\n", "2 3\n1 2\n1 2\n", "2 3\n1 2\n2 3\n", "1 3\n1 2\n2 3\n", "1 31\n0 8\n1 6\n", "1 1\n3 2\n", "2 1\n-1 0\n3 10\n" ]
[ "0.0\n", "7.0\n", "3.5\n", "3.0\n", "4.0\n", "5.0\n", "2.0\n", "8.0\n", "0.666666666667\n", "6.66666666667\n" ]
CodeContests
Consider writing each of the integers from 1 to N \times M in a grid with N rows and M columns, without duplicates. Takahashi thinks it is not fun enough, and he will write the numbers under the following conditions: * The largest among the values in the i-th row (1 \leq i \leq N) is A_i. * The largest among the value...
stdin
null
1,167
1
[ "3 3\n5 9 7\n3 6 9\n", "14 13\n158 167 181 147 178 151 179 182 176 169 180 129 175 168\n181 150 178 179 167 180 176 169 182 177 175 159 173\n", "2 2\n4 4\n4 4\n", "2 2\n4 3\n3 4\n" ]
[ "0\n", "343772227\n", "0\n", "2\n" ]
[ "3 3\n5 9 2\n3 6 9\n", "0 2\n4 3\n3 4\n", "14 13\n158 167 181 147 178 151 179 182 176 169 180 129 175 168\n181 73 178 179 167 180 176 169 182 177 175 159 173\n", "2 2\n6 4\n4 4\n", "3 3\n5 9 2\n0 6 9\n", "2 2\n6 4\n5 4\n", "0 2\n8 3\n3 4\n", "3 3\n5 9 2\n0 8 9\n", "2 2\n6 1\n5 4\n", "0 2\n8 3\n3 0...
[ "0\n", "1\n", "146891838\n", "0\n", "0\n", "0\n", "1\n", "0\n", "0\n", "1\n" ]
CodeContests
We have a rooted binary tree with N vertices, where the vertices are numbered 1 to N. Vertex 1 is the root, and the parent of Vertex i (i \geq 2) is Vertex \left[ \frac{i}{2} \right]. Each vertex has one item in it. The item in Vertex i has a value of V_i and a weight of W_i. Now, process the following query Q times: ...
stdin
null
1,241
1
[ "15\n123 119\n129 120\n132 112\n126 109\n118 103\n115 109\n102 100\n130 120\n105 105\n132 115\n104 102\n107 107\n127 116\n121 104\n121 115\n8\n8 234\n9 244\n10 226\n11 227\n12 240\n13 237\n14 206\n15 227\n", "3\n1 2\n2 3\n3 4\n3\n1 1\n2 5\n3 5\n" ]
[ "256\n255\n250\n247\n255\n259\n223\n253\n", "0\n3\n3\n" ]
[ "15\n123 119\n129 120\n132 112\n126 109\n118 103\n115 109\n102 100\n130 120\n105 105\n132 2\n104 102\n107 107\n127 116\n121 104\n121 115\n8\n8 234\n9 244\n10 226\n11 227\n12 240\n13 237\n14 206\n15 227\n", "3\n1 2\n2 3\n3 4\n3\n1 1\n2 5\n3 10\n", "15\n123 119\n129 120\n132 112\n126 109\n118 103\n115 109\n102 10...
[ "256 255 379 247 255 259 223 253\n", "0 3 4\n", "256 255 379 247 255 259 214 253\n", "256 255 379 247 255 259 321 253\n", "0 3 5\n", "256 255 379 247 255 259 219 253\n", "0 3 3\n", "245 252 379 247 255 259 321 253\n", "0 4 4\n", "245 252 379 247 255 259 321 241\n" ]
CodeContests
There are N+1 lights. Lights are placed at (0, 0), (1, 0), (2, 0) ... (N, 0). Initially all the lights are on. You want to turn off all of them one after one. You want to follow a special pattern in turning off the lights. You will start at (0, 0). First, you walk to the right most light that is on, turn it off. Th...
stdin
null
122
1
[ "2\n1\n2\n" ]
[ "2\n5\n" ]
[ "2\n1\n4\n", "2\n2\n4\n", "2\n2\n1\n", "2\n0\n1\n", "2\n0\n2\n", "2\n2\n2\n", "2\n4\n2\n", "2\n2\n3\n", "2\n3\n2\n", "2\n0\n0\n" ]
[ "2\n14\n", "5\n14\n", "5\n2\n", "0\n2\n", "0\n5\n", "5\n5\n", "14\n5\n", "5\n9\n", "9\n5\n", "0\n0\n" ]
CodeContests
We, the researchers who discovered and investigated the ancient nation Iwashiro, finally discovered the temple in the center of Iwashiro. A lithograph dedicated to the god of Iwashiro was stored in the temple. On the lithograph, two strings were written, one for each sentence and one for the spell. In Iwashiro, how ma...
stdin
null
3,483
1
[ "data\nstructure\n", "aaaabaaaabaaaabaaaab\naaaaa\n", "abab\nab\n" ]
[ "0\n", "4368\n", "3\n" ]
[ "data\nerutcurts\n", "aaaabaaaabaaaabaaaab\nbaaaa\n", "abaa\nab\n", "aaaabaaaabaaaabaaaab\naabaa\n", "aaaabaaaabaa`abaaaab\naabaa\n", "aaaabaaaabaa`ababaaa\naabaa\n", "aaaabaaaabaa`ababaaa\na`baa\n", "aaaabaaaabaa`ababaaa\nb`baa\n", "`caa\nca\n", "aaaabbaaabaa`ababaaa\nb`baa\n" ]
[ "0\n", "566\n", "1\n", "1576\n", "1248\n", "1446\n", "90\n", "18\n", "2\n", "27\n" ]
CodeContests
In the International System of Units (SI), various physical quantities are expressed in the form of "numerical value + prefix + unit" using prefixes such as kilo, mega, and giga. For example, "3.5 kilometers", "5.1 milligrams", and so on. On the other hand, these physical quantities can be expressed as "3.5 * 10 ^ 3 m...
stdin
null
4,950
1
[ "7\n12.3 kilo meters\n0.45 mega watts\n0.000000000000000000000001 yotta grams\n1000000000000000000000000 yocto seconds\n42 amperes\n0.42 joules\n1234.56789012345678901234567890 hecto pascals\n" ]
[ "1.23 * 10^4 meters\n4.5 * 10^5 watts\n1 * 10^0 grams\n1.000000000000000000000000 * 10^0 seconds\n4.2 * 10^1 amperes\n4.2 * 10^-1 joules\n1.23456789012345678901234567890 * 10^5 pascals\n" ]
[ "7\n12.3 kilo meters\n0.45 mega watts\n0.000000000000000000000001 yotta grams\n1000000000000000000000000 yocto seconds\n42 amperes\n0.951642419825234 joules\n1234.56789012345678901234567890 hecto pascals\n", "7\n12.3 kilo meters\n0.45 mega watts\n0.5868394692236264 yotta grams\n1000000000000000000000000 yocto sec...
[ "1.23 * 10^4 meters\n4.5 * 10^5 watts\n1 * 10^0 grams\n1.000000000000000000000000 * 10^0 seconds\n4.2 * 10^1 amperes\n9.51642419825234 * 10^-1 joules\n1.23456789012345678901234567890 * 10^5 pascals\n", "1.23 * 10^4 meters\n4.5 * 10^5 watts\n5.868394692236264 * 10^23 grams\n1.000000000000000000000000 * 10^0 second...
CodeContests
Problem Chieno and Cacao are sisters who work in the same coffee shop. The two are very close, and one day they decided to play a table game. The game uses the board of R square x C square and the rabbit TP as a piece. Each square on the board is painted white or black. First, place the TP in the lower right corner (...
stdin
null
1,620
1
[ "3 3 2\n...\n...\n...\n", "3 3 2\n.#\n.#.\n..\n" ]
[ "Chieno\n", "Cacao\n" ]
[ "3 3 3\n...\n...\n...\n", "4 3 2\n.#\n.#.\n..\n", "3 3 1\n...\n...\n...\n", "4 3 2\n.#\n.#.\n.-\n", "2 3 1\n...\n...\n...\n", "2 3 0\n...\n...\n...\n", "4 3 2\n...\n...\n...\n", "3 3 3\n...\n...\n./.\n", "4 3 2\n.#\n/#.\n..\n", "2 2 1\n...\n...\n...\n" ]
[ "Cacao\n", "Chieno\n", "Cacao\n", "Chieno\n", "Chieno\n", "Cacao\n", "Chieno\n", "Cacao\n", "Chieno\n", "Cacao\n" ]
CodeContests
There is a ladder which leads to the door of heaven. Each step of ladder has a card in it. The card is blue if the number printed on it is even otherwise red. Numbers on the ladder is in the following pattern : 1, 2, 3, 5, 8, 13, 21, 34, 55, 89 i.e., Number on the card of third step is equal to Sum of numbers printed...
stdin
null
3,030
1
[ "2\n10\n100\n\nSAMPLE\n" ]
[ "10\n44\n" ]
[ "966\n7004989\n5560288\n8004130\n7777277\n1002057\n2954252\n9221059\n8077413\n7813877\n7621938\n2827193\n3448219\n236823\n2071156\n8197506\n8516066\n6016248\n4960303\n6926701\n4451415\n7235357\n1507759\n4076381\n3440290\n7959484\n3917268\n6980501\n6214023\n9172774\n5533804\n2103610\n4311323\n6538607\n7291208\n19243...
[ "4613732\n4613732\n4613732\n4613732\n1089154\n1089154\n4613732\n4613732\n4613732\n4613732\n1089154\n1089154\n257114\n1089154\n4613732\n4613732\n4613732\n4613732\n4613732\n4613732\n4613732\n1089154\n4613732\n1089154\n4613732\n4613732\n4613732\n4613732\n4613732\n4613732\n1089154\n4613732\n4613732\n4613732\n1089154\n4...
CodeContests
F - Point Distance Problem Statement You work for invention center as a part time programmer. This center researches movement of protein molecules. It needs how molecules make clusters, so it will calculate distance of all pair molecules and will make a histogram. Molecules’ positions are given by a N x N grid map. V...
stdin
null
1,784
1
[ "2\n1 0\n0 1\n" ]
[ "1.4142135624\n2 1\n" ]
[ "2\n1 0\n0 2\n", "2\n1 1\n0 1\n", "2\n1 1\n1 1\n", "2\n1 2\n0 1\n", "2\n1 0\n1 2\n", "2\n1 1\n0 0\n", "2\n2 1\n1 1\n", "2\n1 0\n0 0\n", "2\n1 0\n2 0\n", "2\n2 1\n2 0\n" ]
[ "0.942809041582\n0 1\n2 2\n", "1.138071187458\n1 2\n2 1\n", "1.138071187458\n1 4\n2 2\n", "0.902368927062\n0 1\n1 4\n2 1\n", "0.971404520791\n0 1\n1 3\n2 2\n", "1.000000000000\n1 1\n", "1.024264068712\n0 1\n1 6\n2 3\n", "nan\n", "0.666666666667\n0 1\n1 2\n", "0.882842712475\n0 2\n1 6\n2 2\n" ]
CodeContests
Niwango bought a piece of land that can be represented as a half-open interval [0, X). Niwango will lay out N vinyl sheets on this land. The sheets are numbered 1,2, \ldots, N, and they are distinguishable. For Sheet i, he can choose an integer j such that 0 \leq j \leq X - L_i and cover [j, j + L_i) with this sheet. ...
stdin
null
3,712
1
[ "3 3\n1 1 2\n", "18 477\n324 31 27 227 9 21 41 29 50 34 2 362 92 11 13 17 183 119\n" ]
[ "10\n", "134796357\n" ]
[ "3 4\n1 1 2\n", "18 477\n324 31 27 227 9 21 41 55 50 34 2 362 92 11 13 17 183 119\n", "3 4\n2 1 2\n", "18 477\n324 31 27 227 9 7 41 55 50 34 2 362 92 11 13 17 183 119\n", "18 477\n324 47 27 227 9 7 41 55 50 34 2 362 92 11 13 17 183 119\n", "18 409\n324 47 27 227 9 7 41 55 50 34 2 362 92 11 13 17 183 119\n...
[ "6\n", "128162603\n", "12\n", "242444143\n", "990433341\n", "258939315\n", "66979647\n", "203123599\n", "220451100\n", "681364413\n" ]
CodeContests
We have a string s consisting of lowercase English letters. Snuke is partitioning s into some number of non-empty substrings. Let the subtrings obtained be s_1, s_2, ..., s_N from left to right. (Here, s = s_1 + s_2 + ... + s_N holds.) Snuke wants to satisfy the following condition: * For each i (1 \leq i \leq N), it ...
stdin
null
141
1
[ "byebye\n", "abcdefghijklmnopqrstuvwxyz\n", "aabxyyzz\n", "abcabcxabcx\n" ]
[ "1\n", "26\n", "2\n", "3\n" ]
[ "byeybe\n", "zyxwvutsrqponmlkjihgfedcba\n", "aabwyyzz\n", "axcabcbabcx\n", "zyxwvutsrqponmlkjihgfedbba\n", "aabwyzzz\n", "eybcxb\n", "abzwxayz\n", "ayxwvutsrqponmlkiihgfedbbz\n", "yccabbcacxa\n" ]
[ "1\n", "26\n", "2\n", "5\n", "24\n", "4\n", "6\n", "8\n", "22\n", "3\n" ]
CodeContests
There is BMI (Body Mass Index) as an index showing the degree of obesity. The BMI value is calculated using the following formula. BMI = weight (kg) / (height (m)) 2 The closer the BMI value is to the standard value, the more "ideal body shape" is considered. Therefore, if the standard value of BMI is 22, create a pr...
stdin
null
2,810
1
[ "6\n1 165 66\n2 178 60\n3 180 72\n4 160 65\n5 185 62\n6 182 62\n3\n3 160 65\n2 180 70\n1 170 75\n0\n" ]
[ "3\n2\n" ]
[ "6\n1 165 66\n2 178 60\n3 180 72\n4 160 65\n5 185 62\n6 182 62\n3\n3 160 65\n2 180 32\n1 170 75\n0\n", "6\n1 165 66\n2 178 60\n3 180 72\n4 160 65\n5 185 62\n6 182 62\n3\n3 160 65\n2 180 70\n1 170 103\n0\n", "6\n1 165 93\n0 178 60\n3 180 72\n4 160 65\n5 185 62\n6 182 62\n3\n3 160 94\n2 180 32\n1 170 75\n0\n", ...
[ "3\n3\n", "3\n2\n", "3\n1\n", "0\n1\n", "0\n2\n", "-1\n1\n", "4\n1\n", "8\n1\n", "8\n2\n", "3\n0\n" ]
CodeContests
A straight tunnel without branches is crowded with busy ants coming and going. Some ants walk left to right and others right to left. All ants walk at a constant speed of 1 cm/s. When two ants meet, they try to pass each other. However, some sections of the tunnel are narrow and two ants cannot pass each other. When tw...
stdin
null
584
1
[ "3 6\nR 1\nL 2\nL 5\n1 10\nR 1\n2 10\nR 5\nL 7\n2 10\nR 3\nL 8\n2 99\nR 1\nL 98\n4 10\nL 1\nR 2\nL 8\nR 9\n6 10\nR 2\nR 3\nL 4\nR 6\nL 7\nL 8\n0 0\n" ]
[ "5 1\n9 1\n7 1\n8 2\n98 2\n8 2\n8 3\n" ]
[ "3 6\nR 1\nL 2\nL 5\n1 20\nR 1\n2 10\nR 5\nL 7\n2 10\nR 3\nL 8\n2 99\nR 1\nL 98\n4 10\nL 1\nR 2\nL 8\nR 9\n6 10\nR 2\nR 3\nL 4\nR 6\nL 7\nL 8\n0 0\n", "3 6\nR 1\nL 2\nL 5\n1 10\nR 1\n2 10\nR 5\nL 7\n2 10\nR 3\nL 3\n2 99\nR 1\nL 98\n4 10\nL 1\nR 2\nL 8\nR 9\n6 10\nR 2\nR 3\nL 4\nR 6\nL 7\nL 8\n0 0\n", "3 6\nR 1\...
[ "5 1\n19 1\n7 1\n8 2\n98 2\n8 2\n8 3\n", "5 1\n9 1\n7 1\n7 1\n98 2\n8 2\n8 3\n", "5 1\n9 1\n7 1\n7 1\n98 2\n8 3\n8 3\n", "5 1\n9 1\n7 1\n8 2\n98 2\n8 2\n8 3\n", "5 1\n9 1\n7 1\n7 1\n98 1\n8 3\n8 3\n", "5 1\n9 1\n7 1\n8 1\n98 2\n8 2\n8 3\n", "5 1\n9 1\n7 1\n9 1\n98 1\n8 3\n8 3\n", "5 1\n17 1\n7 1\n8 1\...
CodeContests
There is an N-car train. You are given an integer i. Find the value of j such that the following statement is true: "the i-th car from the front of the train is the j-th car from the back." Constraints * 1 \leq N \leq 100 * 1 \leq i \leq N Input Input is given from Standard Input in the following format: N i O...
stdin
null
2,247
1
[ "1 1\n", "4 2\n", "15 11\n" ]
[ "1\n", "3\n", "5\n" ]
[ "2 1\n", "2 2\n", "15 9\n", "4 1\n", "2 0\n", "14 9\n", "12 1\n", "14 7\n", "9 1\n", "28 7\n" ]
[ "2\n", "1\n", "7\n", "4\n", "3\n", "6\n", "12\n", "8\n", "9\n", "22\n" ]
CodeContests
You are given N real values A_1, A_2, \ldots, A_N. Compute the number of pairs of indices (i, j) such that i < j and the product A_i \cdot A_j is integer. Constraints * 2 \leq N \leq 200\,000 * 0 < A_i < 10^4 * A_i is given with at most 9 digits after the decimal. Input Input is given from Standard Input in the fol...
stdin
null
726
1
[ "5\n7.5\n2.4\n17.000000001\n17\n16.000000000\n", "11\n0.9\n1\n1\n1.25\n2.30000\n5\n70\n0.000000001\n9999.999999999\n0.999999999\n1.000000001\n" ]
[ "3\n", "8\n" ]
[ "5\n7.5\n2.4\n17.000000001\n17\n16.487690532545415\n", "5\n7.950925288494011\n2.4\n17.000000001\n17\n16.487690532545415\n", "5\n7.5\n2.4\n17.000000001\n22\n16.000000000\n", "11\n0.9\n1\n1\n1.25\n2.30000\n5\n70\n0.000000001\n9999.999999999\n0.999999999\n1.7676771981771382\n", "5\n7.5\n2.4\n17.000000001\n22\n...
[ "1\n", "0\n", "4\n", "8\n", "2\n", "7\n", "0\n", "0\n", "0\n", "0\n" ]
CodeContests
The cat Fabre came up with a simple game using addition and decided to try it with his friend Audrey, also in the cat. The rules of the game are as follows. First of all, choose a suitable positive integer and start from there. Each player selects two adjacent digits from that number, calculates the sum, and replaces ...
stdin
null
2,973
1
[ "3\n1234\n5555\n9\n" ]
[ "Audrey wins.\nFabre wins.\nAudrey wins.\n" ]
[ "3\n1234\n8371\n9\n", "3\n1234\n1292\n9\n", "3\n2133\n1292\n9\n", "3\n1687\n10\n7\n", "3\n1656\n10\n11\n", "3\n3178\n10\n11\n", "3\n1499\n29\n11\n", "3\n49\n2\n14\n", "3\n2133\n261\n9\n", "3\n2133\n261\n7\n" ]
[ "Audrey wins.\nFabre wins.\nAudrey wins.\n", "Audrey wins.\nAudrey wins.\nAudrey wins.\n", "Fabre wins.\nAudrey wins.\nAudrey wins.\n", "Fabre wins.\nFabre wins.\nAudrey wins.\n", "Audrey wins.\nFabre wins.\nFabre wins.\n", "Fabre wins.\nFabre wins.\nFabre wins.\n", "Fabre wins.\nAudrey wins.\nFabre win...
CodeContests
There are N jewels, numbered 1 to N. The color of these jewels are represented by integers between 1 and K (inclusive), and the color of Jewel i is C_i. Also, these jewels have specified values, and the value of Jewel i is V_i. Snuke would like to choose some of these jewels to exhibit. Here, the set of the chosen jew...
stdin
null
2,165
1
[ "8 4\n3 2\n2 3\n4 5\n1 7\n3 11\n4 13\n1 17\n2 19\n", "15 5\n3 87\n1 25\n1 27\n3 58\n2 85\n5 19\n5 39\n1 58\n3 12\n4 13\n5 54\n4 100\n2 33\n5 13\n2 55\n", "5 2\n1 1\n1 2\n1 3\n2 4\n2 5\n", "5 2\n1 1\n1 2\n2 3\n2 4\n2 5\n" ]
[ "-1\n24\n-1\n46\n-1\n64\n-1\n77\n", "-1\n145\n173\n285\n318\n398\n431\n491\n524\n576\n609\n634\n653\n666\n678\n", "-1\n9\n6\n14\n15\n", "-1\n9\n12\n12\n15\n" ]
[ "15 5\n3 87\n1 25\n1 27\n3 58\n2 85\n5 19\n5 39\n1 58\n3 12\n4 14\n5 54\n4 100\n2 33\n5 13\n2 55\n", "5 2\n1 1\n1 2\n1 3\n2 3\n2 5\n", "5 2\n1 1\n1 2\n2 3\n2 4\n1 5\n", "5 2\n1 1\n1 2\n1 3\n2 6\n2 5\n", "15 5\n3 87\n1 25\n1 27\n3 58\n2 85\n5 19\n5 39\n1 58\n3 12\n4 13\n5 54\n4 100\n2 33\n5 4\n2 55\n", "15...
[ "-1\n145\n173\n285\n318\n399\n432\n492\n525\n577\n610\n635\n654\n667\n679\n", "-1\n8\n6\n13\n14\n", "-1\n7\n8\n14\n15\n", "-1\n11\n6\n16\n17\n", "-1\n145\n173\n285\n318\n398\n431\n491\n524\n576\n609\n634\n653\n665\n669\n", "-1\n145\n157\n259\n271\n352\n381\n441\n474\n526\n559\n584\n603\n616\n628\n", "-1...
CodeContests
The time was 3xxx, and the highly developed civilization was in a stagnation period. Historians decided to learn the wisdom of the past in an attempt to overcome this situation. What I paid attention to was the material left by the genius of the early days of computers. The calculation formula is written in this materi...
stdin
null
1,741
1
[ "0.0\n", "(1.1)\n", "...\n", "0-1.\n", "000\n" ]
[ "2\n", "2\n", "7\n", "-1\n", "0\n" ]
[ "0.010621136904092388\n", "0.1.\n", "100\n", ".01.\n", "101\n", ".10.\n", "010\n", ".00.\n", "110\n", "011\n" ]
[ "-1\n", "7\n", "4\n", "11\n", "5\n", "13\n", "2\n", "9\n", "6\n", "3\n" ]
CodeContests
Chef has gone shopping with his 5-year old son. They have bought N items so far. The items are numbered from 1 to N, and the item i weighs Wi grams. Chef's son insists on helping his father in carrying the items. He wants his dad to give him a few items. Chef does not want to burden his son. But he won't stop bothering...
stdin
null
2,667
1
[ "2\n5 2\n8 4 5 2 10\n8 3\n1 1 1 1 1 1 1 1\n" ]
[ "17\n2\n" ]
[ "2\n5 2\n3 4 5 2 10\n8 3\n1 1 1 1 1 1 1 1\n", "2\n5 2\n3 2 5 0 10\n8 3\n1 1 1 1 1 1 1 1\n", "2\n5 2\n3 2 5 0 10\n8 3\n1 0 1 1 1 1 1 1\n", "2\n5 2\n8 4 5 2 10\n8 3\n1 1 1 1 1 1 0 1\n", "2\n5 2\n3 4 5 2 10\n8 3\n0 1 1 1 1 1 1 1\n", "2\n5 2\n4 2 5 0 10\n8 3\n1 1 1 1 1 1 1 1\n", "2\n5 2\n3 2 5 0 10\n8 3\n1 ...
[ "14\n2\n", "16\n2\n", "16\n3\n", "17\n3\n", "14\n3\n", "17\n2\n", "16\n4\n", "17\n4\n", "15\n3\n", "7\n3\n" ]
CodeContests
Takahashi is at an all-you-can-eat restaurant. The restaurant offers N kinds of dishes. It takes A_i minutes to eat the i-th dish, whose deliciousness is B_i. The restaurant has the following rules: * You can only order one dish at a time. The dish ordered will be immediately served and ready to eat. * You cannot or...
stdin
null
2,721
1
[ "3 60\n10 10\n10 20\n10 30\n", "10 100\n15 23\n20 18\n13 17\n24 12\n18 29\n19 27\n23 21\n18 20\n27 15\n22 25\n", "3 60\n30 10\n30 20\n30 30\n", "2 60\n10 10\n100 100\n" ]
[ "60\n", "145\n", "50\n", "110\n" ]
[ "3 74\n10 10\n10 20\n10 30\n", "10 100\n15 23\n20 18\n13 17\n47 12\n18 29\n19 27\n23 21\n18 20\n27 15\n22 25\n", "3 60\n30 10\n30 6\n30 30\n", "2 60\n10 13\n100 100\n", "10 100\n15 23\n20 18\n13 17\n47 12\n18 29\n19 20\n23 21\n18 20\n27 15\n22 25\n", "3 60\n30 20\n30 6\n30 30\n", "2 60\n10 13\n100 101\n...
[ "60\n", "145\n", "40\n", "113\n", "138\n", "50\n", "114\n", "153\n", "41\n", "57\n" ]
CodeContests
Rng is baking cookies. Initially, he can bake one cookie per second. He can also eat the cookies baked by himself. When there are x cookies not yet eaten, he can choose to eat all those cookies. After he finishes eating those cookies, the number of cookies he can bake per second becomes x. Note that a cookie always n...
stdin
null
2,094
1
[ "1000000000000 1000000000000\n", "8 1\n" ]
[ "1000000000000\n", "7\n" ]
[ "1000000000000 1000000100000\n", "9 1\n", "7 0\n", "1000010000000 1000100100001\n", "1000110000000 1000100100001\n", "13 1\n", "1000100000000 1000100100001\n", "13 0\n", "1000101000000 1000110100011\n", "12 -1\n" ]
[ "1000000000000\n", "7\n", "6\n", "1000010000000\n", "1000102100111\n", "9\n", "1000100000000\n", "8\n", "1000101000000\n", "5\n" ]
CodeContests
Problem Statement Write a program that accepts a number and outputs the same. Sample Input 123 Sample Output 123
stdin
null
557
1
[ "123\n" ]
[ "123\n" ]
[ "191\n", "97\n", "162\n", "107\n", "190\n", "227\n", "357\n", "429\n", "404\n", "627\n" ]
[ "191\n", "97\n", "162\n", "107\n", "190\n", "227\n", "357\n", "429\n", "404\n", "627\n" ]
CodeContests
You are given a 4-character string S consisting of uppercase English letters. Determine if S consists of exactly two kinds of characters which both appear twice in S. Constraints * The length of S is 4. * S consists of uppercase English letters. Input Input is given from Standard Input in the following format: S ...
stdin
null
1,127
1
[ "FFEE\n", "FREE\n", "STOP\n", "ASSA\n" ]
[ "Yes\n", "No\n", "No\n", "Yes\n" ]
[ "EEFF\n", "FQEE\n", "SPOT\n", "ASRA\n", "EEQF\n", "SPNT\n", "ARSA\n", "EEQG\n", "RPNT\n", "ARSB\n" ]
[ "Yes\n", "No\n", "No\n", "No\n", "No\n", "No\n", "No\n", "No\n", "No\n", "No\n" ]
CodeContests
Kotoko, a housewife, was enthusiastic about keeping food costs down during this recession. Be sure to check the newspaper advertisement every morning. Make a good list of what to buy and the cheapest-selling shops, and go shopping by riding a bicycle in a combat style called apron sandals while walking through the shop...
stdin
null
2,373
1
[ "3\n3 apple 100 banana 200 egg 300\n3 apple 150 banana 100 cola 200\n3 apple 100 banana 150 cola 200\n3\napple\nbanana\ncola\n5\n0 2 4\n0 1 3\n0 3 3\n1 2 3\n2 3 5\n3\n3 apple 100 banana 200 egg 300\n3 apple 150 banana 100 cola 200\n3 apple 100 banana 150 cola 200\n4\napple\nbanana\ncola\njump\n5\n0 2 4\n0 1 3\n0 3 ...
[ "400 10\nimpossible\n" ]
[ "3\n3 elppa 100 banana 200 egg 300\n3 apple 150 banana 100 cola 200\n3 apple 100 banana 150 cola 200\n3\napple\nbanana\ncola\n5\n0 2 4\n0 1 3\n0 3 3\n1 2 3\n2 3 5\n3\n3 apple 100 banana 200 egg 300\n3 apple 150 banana 100 cola 200\n3 apple 100 banana 150 cola 200\n4\napple\nbanana\ncola\njump\n5\n0 2 4\n0 1 3\n0 3 ...
[ "400 12\nimpossible\n", "400 10\nimpossible\n", "450 6\nimpossible\n", "450 17\nimpossible\n", "450 8\nimpossible\n", "500 12\nimpossible\n", "impossible\nimpossible\n", "645 12\nimpossible\n", "411 10\nimpossible\n", "411 14\nimpossible\n" ]