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 | Walter White is on a tour to sell meth. There are N cities.
Each city has a id between 1 and N (both inclusive).
You are given cost matrix.
In cost matrix, the j\;th element in the i\;th row denotes the cost of travelling between cities with id i and j.
cost[i][j]=cost[j][i] and cost[i][i]=0
Given the path taken b... | stdin | null | 2,358 | 1 | [
"3\ndelhi\nbengaluru\nhyderabad\n0 10 20\n10 0 55\n20 55 0\n4\nbengaluru\ndelhi\nhyderabad\nbengaluru\n\nSAMPLE\n"
] | [
"95\n"
] | [
"3\ndelhi\nbengaluru\nhyderabad\n0 10 20\n10 0 55\n20 55 1\n4\nbengaluru\ndelhi\nhyderabad\nbengaluru\n\nSAMPLE\n",
"3\ndelhi\nbengaluru\nhyderabad\n-2 10 20\n10 0 55\n20 55 0\n2\nbengaluru\ndelhi\nhyderabad\nbengaluru\n\nSAMPLE\n",
"3\ndelhi\nbengaluru\nhycerabad\n0 10 71\n10 0 99\n20 56 -1\n1\nbengaluru\ndelh... | [
"95\n",
"20\n",
"10\n",
"95\n",
"95\n",
"95\n",
"95\n",
"95\n",
"95\n",
"95\n"
] |
CodeContests | There is always an integer in Takahashi's mind.
Initially, the integer in Takahashi's mind is 0. Takahashi is now going to eat four symbols, each of which is `+` or `-`. When he eats `+`, the integer in his mind increases by 1; when he eats `-`, the integer in his mind decreases by 1.
The symbols Takahashi is going t... | stdin | null | 456 | 1 | [
"+-++\n",
"-+--\n",
"----\n"
] | [
"2\n",
"-2\n",
"-4\n"
] | [
"--+-\n",
"++-+\n",
"++++\n",
"-+-+\n",
"---+\n",
"+---\n",
"-+++\n",
"+++-\n",
"++--\n",
"+--+\n"
] | [
"-2\n",
"2\n",
"4\n",
"0\n",
"-2\n",
"-2\n",
"2\n",
"2\n",
"0\n",
"0\n"
] |
CodeContests | Madhav and Riya were getting bored. So they decided to play a game.
They placed N pencils in a line. Madhav starts to sharpen pencil from left to right, and Riya from right to left.
For each pencil, its length is known.
Madhav sharpens with speed twice that of Riya. If a player starts to sharpen the pencil, other pla... | stdin | null | 4,182 | 1 | [
"1\n5\n2 9 8 2 7\n\nSAMPLE\n"
] | [
"3 2\n"
] | [
"1\n5\n2 9 8 2 7\n\nSAMPLD\n",
"1\n5\n2 9 8 4 0\n\nSAMPLD\n",
"1\n5\n2 9 8 2 13\n\nSAMPLD\n",
"1\n5\n2 7 1 2 -3\n\nSAMPLD\n",
"1\n5\n2 9 8 4 7\n\nSAMPLD\n",
"1\n5\n2 9 8 1 0\n\nSAMPLD\n",
"1\n5\n2 9 6 1 0\n\nSAMPLD\n",
"1\n5\n2 9 8 4 2\n\nSAMPLD\n",
"1\n5\n0 9 8 1 0\n\nSAMPLD\n",
"1\n5\n2 9 6 1 0\... | [
"3 2\n",
"2 3\n",
"4 1\n",
"1 4\n",
"3 2\n",
"2 3\n",
"2 3\n",
"3 2\n",
"2 3\n",
"2 3\n"
] |
CodeContests | There are N stores called Store 1, Store 2, \cdots, Store N. Takahashi, who is at his house at time 0, is planning to visit some of these stores.
It takes Takahashi one unit of time to travel from his house to one of the stores, or between any two stores.
If Takahashi reaches Store i at time t, he can do shopping the... | stdin | null | 4,739 | 1 | [
"1 3\n0 3\n",
"5 21600\n2 14\n3 22\n1 3\n1 10\n1 9\n",
"3 7\n2 0\n3 2\n0 3\n",
"7 57\n0 25\n3 10\n2 4\n5 15\n3 22\n2 14\n1 15\n"
] | [
"0\n",
"5\n",
"2\n",
"3\n"
] | [
"1 3\n0 0\n",
"5 21600\n2 14\n3 22\n1 3\n0 10\n1 9\n",
"7 57\n0 25\n3 10\n2 4\n5 15\n3 22\n2 14\n1 9\n",
"1 0\n1 -1\n",
"7 149\n0 25\n3 10\n2 4\n2 20\n3 22\n2 23\n1 2\n",
"7 28\n0 25\n3 10\n2 4\n5 20\n3 22\n2 14\n1 9\n",
"7 149\n0 25\n3 10\n0 4\n0 8\n3 23\n1 23\n1 2\n",
"7 446\n0 25\n3 0\n4 -1\n5 0\n0... | [
"1\n",
"5\n",
"3\n",
"0\n",
"4\n",
"2\n",
"6\n",
"7\n",
"1\n",
"1\n"
] |
CodeContests | Example
Input
3
0 1
0 0 0 1
0 1 0 2
0 2 0 3
Output
6.0000000000000000 | stdin | null | 4,560 | 1 | [
"3\n0 1\n0 0 0 1\n0 1 0 2\n0 2 0 3\n"
] | [
"6.0000000000000000\n"
] | [
"3\n0 1\n0 0 0 1\n0 0 0 2\n0 2 0 3\n",
"3\n-1 1\n0 0 0 2\n0 0 0 2\n0 2 0 3\n",
"3\n-1 1\n0 0 0 2\n0 0 0 2\n1 2 0 3\n",
"3\n-1 0\n0 0 0 2\n0 0 0 2\n1 0 0 3\n",
"3\n-1 0\n0 1 0 2\n0 0 0 2\n1 0 0 3\n",
"3\n-1 0\n0 1 0 1\n0 0 0 2\n1 0 0 3\n",
"3\n-1 0\n0 1 1 1\n0 0 0 2\n1 0 0 3\n",
"3\n-1 0\n0 1 1 1\n0 0 ... | [
"8.0000000000\n",
"10.0000000000\n",
"10.8284271247\n",
"14.3245553203\n",
"12.3245553203\n",
"10.3245553203\n",
"11.1622776602\n",
"9.2360679775\n",
"13.2360679775\n",
"9.4142135624\n"
] |
CodeContests | You are given an integer sequence A of length N and an integer K. You will perform the following operation on this sequence Q times:
* Choose a contiguous subsequence of length K, then remove the smallest element among the K elements contained in the chosen subsequence (if there are multiple such elements, choose one ... | stdin | null | 59 | 1 | [
"11 7 5\n24979445 861648772 623690081 433933447 476190629 262703497 211047202 971407775 628894325 731963982 822804784\n",
"5 3 2\n4 3 1 5 2\n",
"10 1 6\n1 1 2 3 5 8 13 21 34 55\n"
] | [
"451211184\n",
"1\n",
"7\n"
] | [
"11 7 5\n24979445 861648772 623690081 433933447 476190629 262703497 147009374 971407775 628894325 731963982 822804784\n",
"5 3 2\n4 3 1 10 2\n",
"10 1 6\n1 1 2 3 5 8 4 21 34 55\n",
"10 1 4\n1 1 2 3 5 10 4 21 34 55\n",
"9 1 4\n1 1 2 5 5 10 4 21 34 55\n",
"10 1 6\n1 1 2 3 4 8 13 21 34 55\n",
"9 1 2\n1 1 2... | [
"451211184\n",
"1\n",
"4\n",
"2\n",
"3\n",
"7\n",
"0\n",
"408954002\n",
"423705749\n",
"465962931\n"
] |
CodeContests | D: Sunburn-Suntan-
story
Aizunyan is a second-year student who belongs to the programming contest club of Wakagamatsu High School, commonly known as the Prokon club. Cute like an angel. Aizu Nyan is planning to participate in this summer festival, so I made a schedule for the band to go to listen to. I'm worried abou... | stdin | null | 3,532 | 1 | [
"20\n1\n0 10\n"
] | [
"10\n"
] | [
"20\n1\n1 10\n",
"20\n1\n0 7\n",
"20\n1\n2 10\n",
"20\n1\n3 7\n",
"20\n1\n0 19\n",
"20\n1\n0 12\n",
"20\n1\n2 7\n",
"20\n1\n4 10\n",
"20\n1\n0 28\n",
"20\n0\n0 12\n"
] | [
"9\n",
"7\n",
"8\n",
"4\n",
"19\n",
"12\n",
"5\n",
"6\n",
"20\n",
"0\n"
] |
CodeContests | Takahashi received otoshidama (New Year's money gifts) from N of his relatives.
You are given N values x_1, x_2, ..., x_N and N strings u_1, u_2, ..., u_N as input. Each string u_i is either `JPY` or `BTC`, and x_i and u_i represent the content of the otoshidama from the i-th relative.
For example, if x_1 = `10000` a... | stdin | null | 1,684 | 1 | [
"2\n10000 JPY\n0.10000000 BTC\n",
"3\n100000000 JPY\n100.00000000 BTC\n0.00000001 BTC\n"
] | [
"48000.0\n",
"138000000.0038\n"
] | [
"2\n00000 JPY\n0.10000000 BTC\n",
"2\n00000 JPY\n0.7411383442474536 BTC\n",
"2\n10000 JPY\n0.7411383442474536 BTC\n",
"2\n01000 JPY\n0.10000000 BTC\n",
"2\n00010 JPY\n0.7411383442474536 BTC\n",
"2\n10000 JPY\n1.729349410778393 BTC\n",
"2\n10000 JPY\n0.17314902569100102 BTC\n",
"3\n100000000 JPY\n100.0... | [
"38000.0\n",
"281632.570814\n",
"291632.570814\n",
"39000.0\n",
"281642.570814\n",
"667152.776096\n",
"75796.6297626\n",
"138140402.57\n",
"38721.0078253\n",
"635867.283647\n"
] |
CodeContests | For strings s and t, we will say that s and t are prefix-free when neither is a prefix of the other.
Let L be a positive integer. A set of strings S is a good string set when the following conditions hold true:
* Each string in S has a length between 1 and L (inclusive) and consists of the characters `0` and `1`.
* A... | stdin | null | 3,396 | 1 | [
"3 3\n0\n10\n110\n",
"2 3\n101\n11\n",
"1 2\n11\n",
"2 2\n00\n11\n",
"2 1\n0\n1\n"
] | [
"Alice\n",
"Bob\n",
"Alice\n",
"Bob\n",
"Bob\n"
] | [
"3 3\n0\n10\n100\n",
"4 1\n0\n1\n",
"1 4\n11\n",
"2 1\n1\n1\n",
"2 4\n00\n01\n",
"3 3\n0\n10\n101\n",
"1 4\n12\n",
"3 4\n00\n01\n",
"1 4\n17\n",
"3 4\n00\n0\n"
] | [
"Alice\n",
"Bob\n",
"Alice\n",
"Alice\n",
"Alice\n",
"Alice\n",
"Alice\n",
"Alice\n",
"Alice\n",
"Alice\n"
] |
CodeContests | Pandey needs your help. As you know, he is on the quest to save the princess. After traveling for a number of days, he has finally reached the palace, but one last battle remains to be fought. However he has only one unit of energy left in him. To win the battle, he needs all the energy he can get. So he is searching f... | stdin | null | 4,617 | 1 | [
"2\n3\nN\n- 2\nN\n3\n- 1\n* 4\n/ 2\n\n\nSAMPLE\n"
] | [
"3\n4\n"
] | [
"10\n48\n+ 3\n+ 2\n+ 4\n- 3\n- 4\n- 2\n+ 3\n+ 2\n- 2\nN\nN\n+ 3\n+ 4\nN\n- 4\n+ 5\nN\n- 3\nN\n- 5\n+ 5\n- 3\nN\n- 1\n- 3\nN\n- 2\nN\n- 3\n- 2\n+ 1\n* 1\n+ 5\n- 4\n* 1\n* 4\n+ 4\nN\n+ 2\n- 3\n* 3\n+ 4\nN\n+ 5\n+ 2\nN\nN\nN\n41\n- 1\nN\n* 1\n- 4\nN\n+ 1\n- 5\nN\n* 4\n- 4\nN\n+ 3\n* 2\n- 1\n* 3\n+ 4\n+ 2\n+ 5\nN\n- 4\... | [
"653\n1491060\n504372\n4675773601035\n12027\n48866\n55\n109710030425\n74\n334\n",
"653\n1491060\n504372\n7792912801035\n12027\n48866\n55\n109710030425\n74\n334\n",
"653\n1491060\n504372\n7792912801035\n12027\n24866\n55\n109710030425\n74\n334\n",
"3\n4\n",
"653\n1496060\n504372\n4675773601035\n12027\n48866\n... |
CodeContests | Please find the greatest common divisor of two natural numbers. A clue is: The Euclid's algorithm is a way to resolve this task.
Input
The input file consists of several lines with pairs of two natural numbers in each line. The numbers do not exceed 100000.
The number of pairs (datasets) is less than 50.
Output
... | stdin | null | 2,411 | 1 | [
"57 38\n60 84\n"
] | [
"19\n12\n"
] | [
"57 38\n19 84\n",
"57 38\n6 84\n",
"101 38\n6 84\n",
"101 47\n6 88\n",
"100 47\n11 88\n",
"57 18\n19 84\n",
"101 47\n6 37\n",
"101 47\n6 21\n",
"100 38\n10 84\n",
"100 88\n6 169\n"
] | [
"19\n1\n",
"19\n6\n",
"1\n6\n",
"1\n2\n",
"1\n11\n",
"3\n1\n",
"1\n1\n",
"1\n3\n",
"2\n2\n",
"4\n1\n"
] |
CodeContests | It is known that each weight of 1 gram, 3 gram, 9 gram, and 27 gram can be weighed from 1 gram to 40 gram in 1 gram increments using a balance. For example, if you put a weight of 3 grams and a weight you want to weigh on one plate of the balance and a weight of 27 grams and 1 gram on the other plate, the weight of the... | stdin | null | 1,293 | 1 | [
"25\n"
] | [
"+0-+\n"
] | [
"15\n",
"9\n",
"30\n",
"24\n",
"20\n",
"34\n",
"49\n",
"14\n",
"10\n",
"13\n"
] | [
"+--0\n",
"+00\n",
"+0+0\n",
"+0-0\n",
"+-+-\n",
"++-+\n",
"+--++\n",
"+---\n",
"+0+\n",
"+++\n"
] |
CodeContests | A histogram is made of a number of contiguous bars, which have same width.
For a given histogram with $N$ bars which have a width of 1 and a height of $h_i$ = $h_1, h_2, ... , h_N$ respectively, find the area of the largest rectangular area.
Constraints
* $1 \leq N \leq 10^5$
* $0 \leq h_i \leq 10^9$
Input
The inp... | stdin | null | 435 | 1 | [
"8\n2 1 3 5 3 4 2 1\n",
"3\n2 0 1\n"
] | [
"12\n",
"2\n"
] | [
"8\n2 1 3 5 3 7 2 1\n",
"3\n3 0 1\n",
"8\n2 1 3 5 3 7 3 1\n",
"3\n5 0 0\n",
"3\n0 0 0\n",
"8\n2 2 3 5 4 7 3 2\n",
"3\n0 0 1\n",
"8\n3 6 3 6 4 7 0 4\n",
"8\n3 6 4 6 4 7 0 4\n",
"3\n2 0 2\n"
] | [
"12\n",
"3\n",
"15\n",
"5\n",
"0\n",
"16\n",
"1\n",
"18\n",
"20\n",
"2\n"
] |
CodeContests | Two players, A and B, play the game using cards with numbers from 0 to 9. First, the two arrange the given n cards face down in a horizontal row. After that, the two players turn their cards face up one by one from the left, and the owner of the card with the larger number takes the two cards. At this time, the sum of ... | stdin | null | 3,088 | 1 | [
"3\n9 1\n5 4\n0 8\n3\n9 1\n5 4\n1 0\n3\n9 1\n5 5\n1 8\n0\n"
] | [
"19 8\n20 0\n15 14\n"
] | [
"3\n9 1\n5 4\n0 4\n3\n9 1\n5 4\n1 0\n3\n9 1\n5 5\n1 8\n0\n",
"3\n9 1\n5 4\n0 8\n3\n9 1\n5 4\n1 0\n3\n9 1\n5 0\n1 8\n0\n",
"3\n9 1\n5 4\n1 4\n3\n9 1\n5 4\n1 0\n3\n9 1\n5 5\n1 8\n0\n",
"3\n9 1\n5 4\n0 8\n3\n9 1\n5 4\n1 0\n3\n9 1\n5 0\n1 1\n0\n",
"3\n9 1\n5 4\n1 4\n3\n9 1\n6 4\n1 0\n3\n9 1\n5 5\n1 8\n0\n",
"... | [
"19 4\n20 0\n15 14\n",
"19 8\n20 0\n15 9\n",
"19 5\n20 0\n15 14\n",
"19 8\n20 0\n16 1\n",
"19 5\n21 0\n15 14\n",
"19 8\n24 0\n16 1\n",
"19 5\n22 0\n15 14\n",
"19 8\n33 0\n16 1\n",
"19 5\n12 13\n15 14\n",
"19 14\n33 0\n16 1\n"
] |
CodeContests | View Russian Translation
One day Benny decides to miss lessons. But as she is a very good pig she will do her homework anyway. She doesn't know anything about the content of this lessons. Your task is to help her.
The problem is following: you are given a right triangle with coordinates of vertices (0, 0), (0, a), (b... | stdin | null | 3,220 | 1 | [
"2 2 25\n\nSAMPLE\n"
] | [
"1.00\n"
] | [
"2 0 25\n\nSAMPLE\n",
"2 2 20\n\nSAMPLE\n",
"2 2 35\n\nSAMPLE\n",
"2 2 1\n\nSAMPLE\n",
"2 2 0\n\nSAMPLE\n",
"2 1 25\n\nSAMPLE\n",
"2 1 37\n\nSAMPLE\n",
"2 2 23\n\nS@MPLD\n",
"2 2 36\n\nSPEALM\n",
"2 1 0\n\nS@MPLF\n"
] | [
"0.00\n",
"1.11\n",
"0.82\n",
"1.80\n",
"2.00\n",
"0.50\n",
"0.39\n",
"1.04\n",
"0.80\n",
"1.00\n"
] |
CodeContests | <image>
For given three points p0, p1, p2, print
COUNTER_CLOCKWISE
if p0, p1, p2 make a counterclockwise turn (1),
CLOCKWISE
if p0, p1, p2 make a clockwise turn (2),
ONLINE_BACK
if p2 is on a line p2, p0, p1 in this order (3),
ONLINE_FRONT
if p2 is on a line p0, p1, p2 in this order (4),
ON_SEGMENT
... | stdin | null | 789 | 1 | [
"0 0 2 0\n3\n-1 0\n0 0\n3 0\n",
"0 0 2 0\n2\n-1 1\n-1 -1\n"
] | [
"ONLINE_BACK\nON_SEGMENT\nONLINE_FRONT\n",
"COUNTER_CLOCKWISE\nCLOCKWISE\n"
] | [
"0 0 2 -1\n3\n-1 0\n0 0\n3 0\n",
"0 0 4 0\n2\n-1 1\n-1 -1\n",
"0 1 2 0\n3\n-1 0\n0 0\n3 0\n",
"0 0 2 -1\n3\n-1 0\n0 1\n3 0\n",
"0 0 2 -1\n1\n-2 0\n0 1\n3 1\n",
"1 2 0 -2\n2\n0 -1\n0 0\n1 2\n",
"1 2 -1 -2\n2\n-1 0\n0 0\n0 2\n",
"0 2 -1 -2\n2\n-1 1\n0 0\n1 0\n",
"-1 0 -4 0\n2\n0 7\n0 0\n-1 -1\n",
"0... | [
"CLOCKWISE\nON_SEGMENT\nCOUNTER_CLOCKWISE\n",
"COUNTER_CLOCKWISE\nCLOCKWISE\n",
"CLOCKWISE\nCLOCKWISE\nCOUNTER_CLOCKWISE\n",
"CLOCKWISE\nCOUNTER_CLOCKWISE\nCOUNTER_CLOCKWISE\n",
"CLOCKWISE\n",
"CLOCKWISE\nCLOCKWISE\n",
"CLOCKWISE\nON_SEGMENT\n",
"CLOCKWISE\nCOUNTER_CLOCKWISE\n",
"CLOCKWISE\nONLINE_B... |
CodeContests | Problem Statement:
Nash, a high school student studies the concepts of Functions(Mathematics), for the first time.After learning the definitions of Domain and Range, he tries to find the number of functions possible,given the number of elements in domain and range.He comes to you for help.Can you help him with this?
I... | stdin | null | 4,454 | 1 | [] | [] | [
"47\n428 580\n692 254\n221 613\n14 794\n116 115\n926 200\n325 265\n517 290\n219 90\n947 543\n218 544\n149 976\n28 233\n879 494\n530 715\n853 618\n5 378\n369 781\n813 967\n880 841\n610 707\n205 655\n49 468\n187 715\n442 535\n413 765\n152 199\n72 58\n24 116\n900 962\n982 272\n694 763\n372 478\n210 830\n628 348\n895 1... | [
"33172914\n969001528\n763558838\n264421526\n408857237\n138817814\n945568635\n679200755\n136796419\n431775807\n403600246\n592139643\n998347316\n775182218\n806076022\n275325338\n186504349\n459109290\n586196054\n465998479\n743346655\n956463920\n724423235\n863722125\n55560866\n375873458\n439742780\n315389316\n117263467... |
CodeContests | The season for Snuke Festival has come again this year. First of all, Ringo will perform a ritual to summon Snuke. For the ritual, he needs an altar, which consists of three parts, one in each of the three categories: upper, middle and lower.
He has N parts for each of the three categories. The size of the i-th upper ... | stdin | null | 2,288 | 1 | [
"3\n1 1 1\n2 2 2\n3 3 3\n",
"2\n1 5\n2 4\n3 6\n",
"6\n3 14 159 2 6 53\n58 9 79 323 84 6\n2643 383 2 79 50 288\n"
] | [
"27\n",
"3\n",
"87\n"
] | [
"3\n1 0 1\n2 2 2\n3 3 3\n",
"2\n1 5\n2 4\n2 6\n",
"6\n3 14 159 2 6 53\n58 9 7 323 84 6\n2643 383 2 79 50 288\n",
"3\n1 0 2\n2 2 2\n3 3 3\n",
"2\n2 5\n2 4\n2 6\n",
"6\n3 14 159 2 6 53\n58 9 7 323 84 6\n2643 383 2 79 50 430\n",
"3\n1 0 4\n2 2 2\n3 1 3\n",
"3\n0 0 4\n2 2 2\n3 1 1\n",
"6\n5 14 159 0 6 5... | [
"27\n",
"2\n",
"87\n",
"18\n",
"1\n",
"93\n",
"12\n",
"6\n",
"96\n",
"9\n"
] |
CodeContests | Given n numbers a0, a1, ..., an-1 and q.
I want you to perform appropriate processing for q queries.
The query has the following three types of operations.
* Shift the value
Given a pair of l and r. (l <r) Circular shift the value from al to ar.
0 1 2 3 4 5 6 7 8 9
Is given the query l = 2, r = 5.
The shifted numb... | stdin | null | 1,939 | 1 | [
"10 3\n0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n1 5 7\n0 2 5\n1 5 7\n",
"10 10\n289383\n930886\n692777\n636915\n747793\n238335\n885386\n760492\n516649\n641421\n2 7 368690\n1 3 6\n0 2 6\n1 1 8\n0 2 9\n2 2 665123\n1 5 9\n0 2 8\n2 7 961393\n1 1 2\n"
] | [
"5\n4\n",
"238335\n238335\n238335\n368690\n"
] | [
"10 3\n0\n1\n2\n3\n4\n5\n6\n7\n8\n10\n1 5 7\n0 2 5\n1 5 7\n",
"10 10\n289383\n930886\n692777\n636915\n747793\n238335\n885386\n760492\n516649\n641421\n2 7 368690\n1 3 6\n0 2 6\n1 1 8\n0 0 9\n2 2 665123\n1 5 9\n0 2 8\n2 7 961393\n1 1 2\n",
"19 10\n289383\n930886\n692777\n636915\n747793\n238335\n885386\n760492\n51... | [
"5\n4\n",
"238335\n238335\n238335\n289383\n",
"238335\n238335\n289383\n289383\n289383\n289383\n",
"4\n",
"238335\n238335\n238335\n516649\n516649\n516649\n516649\n",
"238335\n162042\n238335\n516649\n516649\n516649\n516649\n",
"8\n238335\n8\n8\n8\n8\n",
"238335\n238335\n289383\n289383\n289383\n289383\n2... |
CodeContests | The Head Chef has received his id from the Association of Byteland . He wants to know the numerical rank of his number among the numbers that can be formed by the exact same digits ( i.e. among numbers having same number of 0's , 1's ... 9's as his id ) . Note that id's can start with 0 . Given a number, find the rank... | stdin | null | 2,983 | 1 | [
"2\n276\n762\n"
] | [
"2\n6\n"
] | [
"2\n473\n762\n",
"2\n473\n370\n",
"2\n336\n432\n",
"2\n438\n861\n",
"2\n286\n861\n",
"2\n64\n10\n",
"2\n15\n10\n",
"2\n7\n18\n",
"2\n276\n1324\n",
"2\n924\n762\n"
] | [
"4\n6\n",
"4\n4\n",
"1\n6\n",
"3\n6\n",
"2\n6\n",
"2\n2\n",
"1\n2\n",
"1\n1\n",
"2\n3\n",
"5\n6\n"
] |
CodeContests | Dance Dance Revolution is one of the most popular arcade games in Japan. The rule of this game is very simple. A series of four arrow symbols, up, down, left and right, flows downwards on the screen in time to music. The machine has four panels under your foot, each of which corresponds to one of the four arrows, and y... | stdin | null | 705 | 1 | [
"3\nUU\nRDUL\nULDURDULDURDULDURDULDURD\n"
] | [
"No\nYes\nYes\n"
] | [
"3\nUU\nRDLU\nULDURDULDURDULDURDULDURD\n",
"3\nTU\nRDLU\nULDURDULDURDULDURDULDURD\n",
"3\nTV\nRVKD\nULDUREULDUDDULDURRUKDURD\n",
"3\nTU\nRDLU\nULDURDULDUREULDURDULDURD\n",
"3\nUU\nRDUL\nULDTRDULDURDULDURDULDURD\n",
"3\nUU\nRULD\nULDURDULDURDULDURDULDURD\n",
"3\nTV\nRDLU\nULDURDULDURDULDURDULDURD\n",
"... | [
"No\nYes\nYes\n",
"Yes\nYes\nYes\n",
"Yes\nYes\nNo\n",
"Yes\nYes\nYes\n",
"No\nYes\nYes\n",
"No\nYes\nYes\n",
"Yes\nYes\nYes\n",
"Yes\nYes\nYes\n",
"No\nYes\nYes\n",
"Yes\nYes\nYes\n"
] |
CodeContests | You are given N integers A_1, A_2, ..., A_N.
Consider the sums of all non-empty subsequences of A. There are 2^N - 1 such sums, an odd number.
Let the list of these sums in non-decreasing order be S_1, S_2, ..., S_{2^N - 1}.
Find the median of this list, S_{2^{N-1}}.
Constraints
* 1 \leq N \leq 2000
* 1 \leq A_i \... | stdin | null | 4,975 | 1 | [
"3\n1 2 1\n",
"1\n58\n"
] | [
"2\n",
"58\n"
] | [
"3\n1 2 0\n",
"1\n32\n",
"1\n62\n",
"1\n26\n",
"3\n1 2 -1\n",
"1\n4\n",
"3\n1 3 -1\n",
"1\n7\n",
"1\n0\n",
"3\n3 5 -1\n"
] | [
"2\n",
"32\n",
"62\n",
"26\n",
"1\n",
"4\n",
"3\n",
"7\n",
"0\n",
"5\n"
] |
CodeContests | Little Jhool is friend with the magical creature from Koi Mil Gaya as we all know, called Jaadu.
Now, Jhool is learning Mathematics from Jaadu; he wants to know about the Mathematics of the other planet, too.
In Jaadu's planet, the sequence of powers of two are called the: The JP. (Jaadu power!) That is, 2^1, 2^2... | stdin | null | 1,717 | 1 | [] | [] | [
"10000\n20001\n20002\n20003\n20004\n20005\n20006\n20007\n20008\n20009\n20010\n20011\n20012\n20013\n20014\n20015\n20016\n20017\n20018\n20019\n20020\n20021\n20022\n20023\n20024\n20025\n20026\n20027\n20028\n20029\n20030\n20031\n20032\n20033\n20034\n20035\n20036\n20037\n20038\n20039\n20040\n20041\n20042\n20043\n20044\n... | [
"181184\n181191\n181194\n181205\n181208\n181215\n181234\n181249\n181256\n181287\n181288\n181293\n181300\n181303\n181306\n181335\n181338\n181341\n181344\n181391\n181392\n181407\n181408\n181415\n181432\n181447\n181450\n181461\n181462\n181469\n181476\n181489\n181496\n181527\n181530\n181535\n181538\n181545\n181548\n181... |
CodeContests | We have N balls. The i-th ball has an integer A_i written on it.
For each k=1, 2, ..., N, solve the following problem and print the answer.
* Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
Constraint... | stdin | null | 4,855 | 1 | [
"8\n1 2 1 4 2 1 4 1\n",
"5\n1 1 2 1 2\n",
"4\n1 2 3 4\n",
"5\n3 3 3 3 3\n"
] | [
"5\n7\n5\n7\n7\n5\n7\n5\n",
"2\n2\n3\n2\n3\n",
"0\n0\n0\n0\n",
"6\n6\n6\n6\n6\n"
] | [
"8\n1 2 1 6 2 1 4 1\n",
"5\n0 1 2 1 2\n",
"4\n2 2 3 4\n",
"5\n3 3 2 3 3\n",
"8\n1 3 1 6 2 1 4 1\n",
"5\n0 1 2 1 0\n",
"5\n0 3 2 3 3\n",
"8\n1 3 1 6 2 0 4 1\n",
"8\n1 2 1 6 2 0 4 1\n",
"8\n1 1 1 6 2 0 4 1\n"
] | [
"4\n6\n4\n7\n6\n4\n7\n4\n",
"2\n1\n1\n1\n1\n",
"0\n0\n1\n1\n",
"3\n3\n6\n3\n3\n",
"3\n6\n3\n6\n6\n3\n6\n3\n",
"1\n1\n2\n1\n1\n",
"3\n1\n3\n1\n1\n",
"1\n3\n1\n3\n3\n3\n3\n1\n",
"2\n3\n2\n4\n3\n4\n4\n2\n",
"3\n3\n3\n6\n6\n6\n6\n3\n"
] |
CodeContests | Problem
Given the strings $ s $, $ t $.
First, let the string set $ A = $ {$ s $}, $ B = \ phi $.
At this time, I want to perform the following operations as much as possible.
operation
step1
Perform the following processing for all $ u ∊ A $.
1. From all subsequences of $ u $ (not necessarily contiguous), choose ... | stdin | null | 1,069 | 1 | [
"abaabbabaabaabbabbabaabbab\nab\n",
"AABABCAC\nA\n",
"AbCdEfG\naBcDeFg\n"
] | [
"3\n",
"2\n",
"0\n"
] | [
"abaabbabaab`abbabbabaabbab\nab\n",
"AABABCAC\nB\n",
"AbCdEfG\naBcDeFh\n",
"abaabbbbaab`abbabbabaabaab\nab\n",
"AACABCAC\nB\n",
"AbGdEfC\naBcDeFh\n",
"abaabbbbaab`abbabbabaabaab\n`b\n",
"AACABCAC\nC\n",
"AbGdEfC\naBcDhFe\n",
"abaabbbbaaa`abbabbabbabaab\n`b\n"
] | [
"2\n",
"1\n",
"0\n",
"2\n",
"1\n",
"0\n",
"1\n",
"2\n",
"0\n",
"1\n"
] |
CodeContests | Problem statement
An unusual rally game is popular at KU University. The circuit, which is the setting of this game, has N rest areas and M roads, and the i-th road is between the fi-th rest area and the ti-th rest area. There is one checkpoint on every road, and if you pass the checkpoint on road i, the score of pi w... | stdin | null | 1,381 | 1 | [
"5 5 3\n0 1 7\n1 2 22\n2 3 128\n3 4 128\n4 2 128\n0 1\n0 0\n3 4\n"
] | [
"135\n128\n128\n"
] | [
"5 5 3\n0 1 7\n1 2 22\n1 3 128\n3 4 128\n4 2 128\n0 1\n0 0\n3 4\n",
"5 5 3\n0 1 7\n1 2 25\n1 3 128\n3 4 128\n4 2 128\n0 1\n0 0\n3 4\n",
"5 5 3\n0 1 7\n1 2 22\n0 3 128\n3 4 128\n4 2 128\n0 1\n0 0\n3 4\n",
"5 5 3\n0 1 7\n1 2 33\n0 3 128\n3 4 128\n4 2 128\n0 1\n0 0\n3 4\n",
"5 5 3\n0 1 0\n1 2 33\n0 3 128\n3 4 ... | [
"145\n150\n128\n",
"158\n153\n128\n",
"150\n145\n128\n",
"161\n166\n128\n",
"161\n161\n128\n",
"68\n68\n101\n",
"68\n68\n229\n",
"101\n101\n196\n",
"135\n128\n128\n",
"150\n150\n128\n"
] |
CodeContests | Farmer Feb has three fields with potatoes planted in them. He harvested x potatoes from the first field, y potatoes from the second field and is yet to harvest potatoes from the third field. Feb is very superstitious and believes that if the sum of potatoes he harvests from the three fields is a prime number (http://en... | stdin | null | 1,751 | 1 | [
"2\n1 3\n4 3\n"
] | [
"1\n4\n"
] | [
"2\n1 3\n3 3\n",
"2\n1 3\n1 6\n",
"2\n1 3\n2 6\n",
"2\n1 3\n3 6\n",
"2\n1 4\n4 3\n",
"2\n2 3\n3 3\n",
"2\n1 4\n2 3\n",
"2\n2 5\n6 3\n",
"2\n2 6\n4 8\n",
"2\n2 6\n4 10\n"
] | [
"1\n1\n",
"1\n4\n",
"1\n3\n",
"1\n2\n",
"2\n4\n",
"2\n1\n",
"2\n2\n",
"4\n2\n",
"3\n1\n",
"3\n3\n"
] |
CodeContests | Given is a string S consisting of digits from `1` through `9`.
Find the number of pairs of integers (i,j) (1 ≤ i ≤ j ≤ |S|) that satisfy the following condition:
Condition: In base ten, the i-th through j-th characters of S form an integer that is a multiple of 2019.
Constraints
* 1 ≤ |S| ≤ 200000
* S is a string c... | stdin | null | 2,360 | 1 | [
"1817181712114\n",
"2119\n",
"14282668646\n"
] | [
"3\n",
"0\n",
"2\n"
] | [
"3054417607960\n",
"218\n",
"8160152899489\n",
"7932848001410\n",
"6806479110\n",
"9600282290\n",
"649171600089\n",
"3000732030\n",
"4123972862\n",
"5345763557347\n"
] | [
"3\n",
"0\n",
"1\n",
"5\n",
"2\n",
"4\n",
"6\n",
"8\n",
"0\n",
"0\n"
] |
CodeContests | Write a program that extracts n different numbers from the numbers 0 to 9 and outputs the number of combinations that add up to s. Each n number is from 0 to 9, and the same number cannot be used in one combination. For example, if n is 3 and s is 6, the combination of the three numbers totaling 6 is
1 + 2 + 3 = 6
0 +... | stdin | null | 3,881 | 1 | [
"3 6\n3 1\n0 0\n"
] | [
"3\n0\n"
] | [
"3 5\n3 1\n0 0\n",
"3 0\n5 1\n0 0\n",
"1 0\n5 1\n0 0\n",
"3 6\n3 0\n0 0\n",
"2 5\n1 1\n0 0\n",
"2 0\n1 1\n0 0\n",
"3 2\n0 0\n0 0\n",
"2 2\n0 0\n0 0\n",
"3 7\n3 1\n0 0\n",
"3 8\n3 1\n0 0\n"
] | [
"2\n0\n",
"0\n0\n",
"1\n0\n",
"3\n0\n",
"3\n1\n",
"0\n1\n",
"0\n",
"1\n",
"4\n0\n",
"5\n0\n"
] |
CodeContests | You are given N items.
The value of the i-th item (1 \leq i \leq N) is v_i.
Your have to select at least A and at most B of these items.
Under this condition, find the maximum possible arithmetic mean of the values of selected items.
Additionally, find the number of ways to select items so that the mean of the values o... | stdin | null | 5,016 | 1 | [
"4 2 3\n10 20 10 10\n",
"5 1 5\n1000000000000000 999999999999999 999999999999998 999999999999997 999999999999996\n",
"5 2 2\n1 2 3 4 5\n"
] | [
"15.000000\n3\n",
"1000000000000000.000000\n1\n",
"4.500000\n1\n"
] | [
"4 2 6\n10 20 10 10\n",
"5 2 2\n1 0 3 4 5\n",
"4 2 6\n10 20 10 5\n",
"4 2 6\n2 20 10 5\n",
"5 1 5\n1000000000000000 999999999999999 999999999999998 455140417295801 999999999999996\n",
"5 2 2\n1 2 3 3 5\n",
"4 2 6\n10 28 10 10\n",
"4 1 6\n2 20 10 5\n",
"4 2 6\n2 20 11 4\n",
"5 2 2\n1 2 3 5 5\n"
] | [
"15.00000000\n3\n",
"4.50000000\n1\n",
"15.00000000\n2\n",
"15.00000000\n1\n",
"1000000000000000.00000000\n1\n",
"4.00000000\n2\n",
"19.00000000\n3\n",
"20.00000000\n1\n",
"15.50000000\n1\n",
"5.00000000\n1\n"
] |
CodeContests | Find a*b, for all given number pairs
SAMPLE INPUT
5
4 6
3 7
SAMPLE OUTPUT
24
21 | stdin | null | 4,968 | 1 | [
"5\n4 6\n3 7\n\nSAMPLE\n"
] | [
"24\n21\n"
] | [
"5\n4 6\n3 7\n\nTAMPLE\n",
"5\n4 6\n3 7\n\nSAMPKE\n",
"5\n4 6\n3 7\n\nELPMAT\n",
"5\n4 6\n3 7\n\nSALPKE\n",
"5\n4 6\n3 7\n\nTAMLPE\n",
"5\n4 6\n3 7\n\nSAMOKE\n",
"5\n4 6\n3 7\n\nTLMPAE\n",
"5\n4 6\n3 7\n\nSEMOKA\n",
"5\n4 6\n3 7\n\nTAMPLD\n",
"5\n4 6\n3 7\n\nAKOMES\n"
] | [
"24\n21\n",
"24\n21\n",
"24\n21\n",
"24\n21\n",
"24\n21\n",
"24\n21\n",
"24\n21\n",
"24\n21\n",
"24\n21\n",
"24\n21\n"
] |
CodeContests | Convex polygon pillar industrial city
The Industrial Convex Pillar City (ICPC) is a city of buildings in the shape of several convex polygonal columns. You are about to walk through this city from your current location S to your destination T. The sun is strong today, so I want to go to my destination without passing ... | stdin | null | 4,641 | 1 | [
"2\n4 1 0 0 1 0 1 1 0 1\n4 2 2 2 3 2 3 3 2 3\n60 45\n-1 -1 4 4\n4\n4 1 0 0 3 1 1 2 0 1\n3 2 10 7 8 2 12 4\n6 8 7 12 8 13 9 15 10 19 11 24 10 25\n5 4 16 2 16 4 12 8 14 2 15 0\n167 38\n3 3 15 21\n12\n4 3 -8 -3 -9 -3 -9 -5 -8 -6\n4 5 -4 -5 -7 -5 -7 -6 -5 -6\n4 2 -4 1 -5 1 -5 -4 -4 -4\n4 1 -1 1 -2 1 -2 -4 -1 -3\n4 2 2 ... | [
"1.93185\n7.87174\n20.86840\n"
] | [
"2\n4 1 0 0 1 0 1 1 0 1\n4 2 2 2 3 2 3 3 2 3\n60 45\n-1 -1 4 4\n4\n4 1 0 0 3 1 1 2 0 1\n3 2 0 7 8 2 12 4\n6 8 7 12 8 13 9 15 10 19 11 24 10 25\n5 4 16 2 16 4 12 8 14 2 15 0\n167 38\n3 3 15 21\n12\n4 3 -8 -3 -9 -3 -9 -5 -8 -6\n4 5 -4 -5 -7 -5 -7 -6 -5 -6\n4 2 -4 1 -5 1 -5 -4 -4 -4\n4 1 -1 1 -2 1 -2 -4 -1 -3\n4 2 2 3... | [
"1.931851653\n4.574721383\n20.868404177\n",
"1.931851653\n4.574721383\n19.868404177\n",
"0.000000000\n",
"3.605289615\n",
"3.388103494\n",
"1.931851653\n7.871744501\n20.868404177\n",
"1.931851653\n3.265921949\n19.868404177\n",
"2.606233457\n",
"3.744993354\n",
"5.603401932\n"
] |
CodeContests | B: Yamanote-line Game-Yamanote-line Game-
Bean (?) Knowledge
The Yamanote line is convenient. The reason is that you can ride as many laps as time allows just by paying 130 yen. However, if you board with a ticket, you must be careful about the valid time of the ticket. It seems safe with an IC card. Taking advantage... | stdin | null | 4,247 | 1 | [
"5 130\n130 170 100 120 140\n"
] | [
"50\n"
] | [
"5 130\n130 170 100 122 140\n",
"3 130\n130 170 100 122 140\n",
"1 130\n130 170 100 122 86\n",
"1 58\n60 60 010 102 86\n",
"1 58\n68 60 010 102 166\n",
"6 130\n130 170 100 120 140\n",
"5 130\n130 170 100 138 140\n",
"1 48\n68 5 100 72 104\n",
"1 53\n68 4 100 72 104\n",
"6 130\n130 170 100 171 140\... | [
"50\n",
"40\n",
"kusoge\n",
"2\n",
"10\n",
"60\n",
"58\n",
"20\n",
"15\n",
"101\n"
] |
CodeContests | Wet Shark once had 2 sequences:
{a_n}= {a_1, a_2, a_3, ... , a_(10^9)}
{b_n} = {b_1, b_2, b_3, ... , b_(10^9)}
However, he only kept one element from each sequence. Luckily, both the elements that Wet Shark kept have the same index in Wet Shark's sequences: that is, he took a_i and b_i for some 1 ≤ i ≤ 10^9.
Righ... | stdin | null | 3,657 | 1 | [
"1 1 5\n4 5\n"
] | [
"0.28125\n"
] | [
"1 1 5\n4 3\n",
"1 0 5\n4 3\n",
"1 0 5\n4 5\n",
"1 2 5\n4 5\n",
"1 2 5\n2 5\n",
"1 2 6\n2 5\n",
"0 2 6\n2 5\n",
"0 2 6\n4 5\n",
"0 2 6\n4 7\n",
"0 2 6\n4 10\n"
] | [
"0.21875000000\n",
"0.05080204484\n",
"0.06993868345\n",
"1.11901893521\n",
"0.94224223992\n",
"0.47112111996\n",
"1.75000000000\n",
"2.25000000000\n",
"2.75000000000\n",
"3.50000000000\n"
] |
CodeContests | You received a card with an integer $S$ and a multiplication table of infinite size. All the elements in the table are integers, and an integer at the $i$-th row from the top and the $j$-th column from the left is $A_{i,j} = i \times j$ ($i,j \geq 1$). The table has infinite size, i.e., the number of the rows and the n... | stdin | null | 3,136 | 1 | [
"25\n",
"5\n",
"1\n",
"83160\n"
] | [
"10\n",
"4\n",
"1\n",
"5120\n"
] | [
"18\n",
"9\n",
"0\n",
"10614\n",
"3\n",
"5401\n",
"2\n",
"12\n",
"4\n",
"6\n"
] | [
"20\n",
"10\n",
"0\n",
"128\n",
"4\n",
"16\n",
"2\n",
"12\n",
"3\n",
"8\n"
] |
CodeContests | There are n cups of different sizes and three trays (bon festivals) A, B, and C, and these cups are placed on top of each of the three trays in a pile. However, in any tray, the smallest cup in the tray is on the bottom, the second smallest cup is on top, and the third smallest cup is on top, in ascending order. .. For... | stdin | null | 3,204 | 1 | [
"3 10\n0\n1 1\n2 2 3\n4 20\n2 1 2\n1 3\n1 4\n2 5\n2 1 2\n0\n0\n3 3\n0\n1 1\n2 2 3\n0 0\n"
] | [
"9\n3\n0\n-1\n"
] | [
"3 10\n0\n1 1\n2 2 3\n4 20\n2 1 2\n1 3\n1 4\n1 5\n2 1 2\n0\n0\n3 3\n0\n1 1\n2 2 3\n0 0\n",
"3 8\n0\n1 1\n2 2 3\n4 7\n2 1 2\n1 3\n1 4\n1 5\n2 1 2\n0\n0\n3 6\n0\n1 1\n2 2 3\n0 0\n",
"3 10\n0\n1 1\n2 2 3\n4 7\n2 1 2\n1 2\n1 4\n1 5\n2 1 2\n0\n0\n3 6\n0\n1 1\n2 2 3\n0 0\n",
"3 10\n0\n1 1\n2 2 3\n4 13\n2 1 2\n1 3\n... | [
"9\n3\n0\n-1\n",
"-1\n3\n0\n-1\n",
"9\n-1\n0\n-1\n",
"9\n3\n0\n9\n",
"9\n3\n0\n-1\n",
"9\n3\n0\n-1\n",
"9\n3\n0\n-1\n",
"9\n3\n0\n-1\n",
"9\n3\n0\n-1\n",
"9\n3\n0\n-1\n"
] |
CodeContests | There are K blue balls and N-K red balls. The balls of the same color cannot be distinguished. Snuke and Takahashi are playing with these balls.
First, Snuke will arrange the N balls in a row from left to right.
Then, Takahashi will collect only the K blue balls. In one move, he can collect any number of consecutive ... | stdin | null | 3,554 | 1 | [
"5 3\n",
"2000 3\n"
] | [
"3\n6\n1\n",
"1998\n3990006\n327341989\n"
] | [
"7 3\n",
"1776 3\n",
"7 5\n",
"195 3\n",
"5 5\n",
"206 3\n",
"96 3\n",
"96 2\n",
"2000 1\n",
"7 4\n"
] | [
"5\n20\n10\n",
"1774\n3145302\n928912524\n",
"3\n12\n6\n0\n0\n",
"193\n37056\n1179616\n",
"1\n0\n0\n0\n0\n",
"204\n41412\n1394204\n",
"94\n8742\n134044\n",
"95\n4465\n",
"2000\n",
"4\n18\n12\n1\n"
] |
CodeContests | We have N squares assigned the numbers 1,2,3,\ldots,N. Each square has an integer written on it, and the integer written on Square i is a_i.
How many squares i satisfy both of the following conditions?
* The assigned number, i, is odd.
* The written integer is odd.
Constraints
* All values in input are integers.
* ... | stdin | null | 3,671 | 1 | [
"15\n13 76 46 15 50 98 93 77 31 43 84 90 6 24 14\n",
"5\n1 3 4 5 7\n"
] | [
"3\n",
"2\n"
] | [
"15\n13 76 46 15 50 98 93 77 31 43 44 90 6 24 14\n",
"5\n1 5 4 5 7\n",
"5\n0 4 4 5 7\n",
"15\n15 5 71 15 50 98 93 87 31 43 44 11 6 24 14\n",
"15\n15 5 71 15 87 98 135 87 0 60 44 11 6 14 19\n",
"15\n1 10 109 15 87 98 29 161 0 60 44 11 9 14 19\n",
"15\n1 3 109 15 87 98 29 161 1 60 9 11 9 14 32\n",
"5\n0... | [
"3\n",
"2\n",
"1\n",
"4\n",
"5\n",
"6\n",
"7\n",
"0\n",
"8\n",
"3\n"
] |
CodeContests | Snuke has permutations (P_0,P_1,\cdots,P_{N-1}) and (Q_0,Q_1,\cdots,Q_{N-1}) of (0,1,\cdots,N-1).
Now, he will make new permutations A and B of (0,1,\cdots,N-1), under the following conditions:
* For each i (0 \leq i \leq N-1), A_i should be i or P_i.
* For each i (0 \leq i \leq N-1), B_i should be i or Q_i.
Let u... | stdin | null | 3,392 | 1 | [
"32\n22 31 30 29 7 17 16 3 14 9 19 11 2 5 10 1 25 18 15 24 20 0 12 21 27 4 26 28 8 6 23 13\n22 3 2 7 17 9 16 4 14 8 19 26 28 5 10 1 25 18 15 13 11 0 12 23 21 20 29 24 27 6 30 31\n",
"4\n2 1 3 0\n0 2 3 1\n",
"10\n0 4 5 3 7 8 2 1 9 6\n3 8 5 6 4 0 2 1 7 9\n"
] | [
"28\n",
"3\n",
"8\n"
] | [
"4\n2 1 3 0\n2 0 3 1\n",
"10\n0 4 5 3 7 8 2 1 9 6\n2 8 5 6 4 0 3 1 7 9\n",
"4\n2 1 3 0\n3 0 2 1\n",
"4\n2 0 3 1\n0 2 3 1\n",
"4\n2 0 3 1\n1 2 3 0\n",
"4\n2 1 3 0\n1 2 3 0\n"
] | [
"4\n",
"9\n",
"4\n",
"4\n",
"4\n",
"4\n"
] |
CodeContests | We have a cord whose length is a positive integer. We will perform the following condition until the length of the cord becomes at most 2:
* Operation: Cut the rope at two positions to obtain three cords, each with a length of a positive integer. Among these, discard one with the longest length and one with the shorte... | stdin | null | 299 | 1 | [
"2\n"
] | [
"14\n"
] | [
"3\n",
"1\n",
"6\n",
"4\n",
"8\n",
"10\n",
"9\n",
"16\n",
"11\n",
"18\n"
] | [
"30\n",
"6\n",
"254\n",
"62\n",
"1022\n",
"4094\n",
"2046\n",
"262142\n",
"8190\n",
"1048574\n"
] |
CodeContests | There are N strings arranged in a row. It is known that, for any two adjacent strings, the string to the left is lexicographically smaller than the string to the right. That is, S_1<S_2<...<S_N holds lexicographically, where S_i is the i-th string from the left.
At least how many different characters are contained in ... | stdin | null | 4,268 | 1 | [
"3\n3 2 1\n",
"5\n2 3 2 1 2\n"
] | [
"2\n",
"2\n"
] | [
"3\n3 4 1\n",
"5\n2 1 2 1 2\n",
"5\n2 1 1 1 2\n",
"5\n3 1 1 1 1\n",
"3\n1 3 4\n",
"3\n3 5 1\n",
"5\n2 1 2 2 2\n",
"3\n3 5 2\n",
"5\n3 1 2 2 2\n",
"3\n3 5 3\n"
] | [
"2\n",
"3\n",
"4\n",
"5\n",
"1\n",
"2\n",
"3\n",
"2\n",
"3\n",
"2\n"
] |
CodeContests | E: Without the Devil Old Maid --Unbalanced Old Maid -
story
Mr. Kosaka, Mr. Sonoda, and Mr. Minami have been good friends since childhood. The three went on a school trip to Okinawa, but a typhoon came and they couldn't play in the sea, so they decided to maid out.
Mr. Sonoda is strong in the game, but he is not goo... | stdin | null | 1,423 | 1 | [
"1\n1 1\n3 0 1 1\n1 1\n"
] | [
"0.0\n"
] | [
"1\n1 1\n3 0 1 1\n0 1\n",
"1\n2 0\n1 0 1 1\n1 1\n",
"1\n1 0\n1 1 1 1\n0 1\n",
"1\n1 1\n3 0 1 1\n0 0\n",
"1\n1 1\n1 0 1 1\n1 1\n",
"1\n1 1\n1 0 0 1\n1 1\n",
"1\n1 1\n3 0 1 1\n0 2\n",
"1\n1 1\n3 0 1 1\n0 -1\n",
"1\n1 0\n1 0 1 1\n1 1\n",
"1\n1 2\n3 0 1 1\n0 2\n"
] | [
"0.0000000000\n",
"1.0000000000\n",
"0.5000000000\n",
"0.0000000000\n",
"0.0000000000\n",
"0.0000000000\n",
"0.0000000000\n",
"0.0000000000\n",
"0.0000000000\n",
"0.0000000000\n"
] |
CodeContests | Those of you who are familiar with the TV Show Community and it's 'lovable' character, Abed, who likes to travel around dimensions, parallel universes, and various other parallel time lines, would know that Abed needs your help. And if you aren't familiar, help the kid, anyway.
Now Abed has been told by Britta that sh... | stdin | null | 2,547 | 1 | [
"1\n4 4\n3 0\n2 2\n9\n\nSAMPLE\n"
] | [
"27\nYou saved the group.\n"
] | [
"10\n227 147\n36 84\n100 62\n9\n143 19\n34 4\n73 13\n9\n289 63\n21 57\n94 25\n4\n225 205\n172 177\n65 195\n3\n240 153\n111 114\n207 85\n7\n203 42\n53 3\n107 32\n2\n132 167\n103 22\n102 140\n5\n115 7\n111 5\n51 1\n7\n116 108\n41 37\n40 30\n1\n175 70\n112 32\n49 23\n2\n",
"1\n4 4\n3 0\n2 2\n9\n\nSBMPLE\n",
"10\n2... | [
"774\nYou saved the group.\n432\nYou saved the group.\n416\nYou saved the group.\n375\nYou saved the group.\n875\nYou saved the group.\n134\nYou saved the group.\n250\nYou saved the group.\n406\nYou saved the group.\n8\nYou saved the group.\n144\nYou saved the group.\n",
"27\nYou saved the group.\n",
"774\nYou ... |
CodeContests | There are N people in a group. The personality of each person is denoted by A[i] from the set A, where A[i] denotes the personality of the ith person.
Your task is to find the total persons of different personalities.
INPUT:
First line contains the total number of test cases T, for each test cases, first line deno... | stdin | null | 725 | 1 | [
"1\n5\n1 2 3 4 5\n\nSAMPLE\n"
] | [
"5\n"
] | [
"1\n5\n1 2 3 6 5\n",
"1\n5\n1 0 3 4 4\n\nSAMPLE\n",
"1\n5\n0 2 3 2 0\n\nPAMSLE\n",
"1\n5\n-1 -1 -1 0 0\n",
"1\n5\n0 0 0 0 0\n",
"1\n5\n1 0 3 4 5\n\nSAMPLE\n",
"1\n5\n1 2 0 4 5\n",
"1\n5\n2 2 0 4 5\n",
"1\n5\n1 -1 3 4 4\n\nSAMPLE\n",
"1\n5\n2 2 0 3 5\n"
] | [
"5\n",
"4\n",
"3\n",
"2\n",
"1\n",
"5\n",
"5\n",
"4\n",
"4\n",
"4\n"
] |
CodeContests | Some terrorist attacks on Indian border. Now Indian Army have to send his soldiers to fight against terrorist. There are total N soldiers in the camp. Every soldier has a skill denoted by a single character lies between A-Z (all skills are in CAPITAL LETTERS). Now commander gave order to stand all the soldiers in a row... | stdin | null | 957 | 1 | [
"2\nABDEFGABEF\nGHJKLMNOPQ\n\nSAMPLE\n"
] | [
"6\n10\n"
] | [
"5\nQOGVFFDEIAGMLHQUMDIMNCFOENILIBDJSMYNKAZMOHGPVDPRYRMYZGZVAJHGKSCOOZIBFRHPMZUTHCUVVZKVIQYBEZLHITZLDGXLDRBRGSMDJYMDNBJIMCKYODDZCBUXCFFWZVHQEDRPCYRJGDLNWHFAUDLIFVJWVJULKARHRHHMBCKLRAVYSHOBGIGWMGWIRCYVIBXSBHTCWTIXMXGMDEXENMBREQPFWFLMIIOEPTERZPDWOQDUXCQLWKYRFNXWTWMJHQTCXMSSOXUYMBDXFVJCDAZAQXKJLNJHVLPOYDHIAQNKRBFPMZNL... | [
"16\n18\n19\n20\n18\n",
"6\n10\n",
"7\n10\n",
"7\n8\n",
"6\n8\n",
"6\n6\n",
"5\n6\n",
"5\n7\n",
"5\n8\n",
"4\n8\n"
] |
CodeContests | Rani has challenged Nandu to generate Splendid Matrices. Splendid matrices are square matrices with dimensions 2^n X 2^n filled in a particular manner. To explain this manner, Rani gives Nandu the matrices for n=1, n=2 and n=3 :
n=1
1 2
3 4
n=2 (spacing for clarity)
1 2 5 6
3 4 7 8
9 10 13 14
11 12 15 16
n=3... | stdin | null | 4,380 | 1 | [
"3\n\nSAMPLE\n"
] | [
"1 2 5 6 17 18 21 22 \n3 4 7 8 19 20 23 24 \n9 10 13 14 25 26 29 30 \n11 12 15 16 27 28 31 32 \n33 34 37 38 49 50 53 54 \n35 36 39 40 51 52 55 56 \n41 42 45 46 57 58 61 62 \n43 44 47 48 59 60 63 64\n"
] | [
"3\n\nSAMPKE\n",
"3\n\nSAMPKD\n",
"3\n\nSAMOKD\n",
"3\n\nSAMDKO\n",
"3\n\nSADMKO\n",
"3\n\nTADMKO\n",
"3\n\nTADMJO\n",
"3\n\nTADNJO\n",
"3\n\nT@DNJO\n",
"3\n\nT@DNJN\n"
] | [
"1 2 5 6 17 18 21 22 \n3 4 7 8 19 20 23 24 \n9 10 13 14 25 26 29 30 \n11 12 15 16 27 28 31 32 \n33 34 37 38 49 50 53 54 \n35 36 39 40 51 52 55 56 \n41 42 45 46 57 58 61 62 \n43 44 47 48 59 60 63 64\n",
"1 2 5 6 17 18 21 22 \n3 4 7 8 19 20 23 24 \n9 10 13 14 25 26 29 30 \n11 12 15 16 27 28 31 32 \n33 34 37 38 49 5... |
CodeContests | The ATM machine of State Bank of Patiala on Thapar Campus has a flaw in it and it takes a lot of time to complete a transaction.
This machine is quite different from other's as it needed no card. Only thing it required is customer's unique ATM PIN and then his/her password.
The Bank found out that the ATM PIN validatio... | stdin | null | 1,962 | 1 | [
"2\n3\n102\n1024\n123477\n3\n102\n1034\n123477\n\nSAMPLE\n"
] | [
"NO\nYES\n"
] | [
"2\n3\n102\n1533\n123477\n3\n102\n1034\n123477\n",
"2\n3\n102\n1024\n123477\n3\n102\n1323\n123477\n\nSAMPLE\n",
"2\n3\n102\n1024\n123477\n5\n102\n2323\n16690\n\nSAMPLE\n",
"2\n3\n187\n1024\n44019\n5\n102\n2323\n16690\n\nSAMPLE\n",
"2\n3\n102\n1533\n123477\n3\n102\n1932\n123477\n",
"2\n3\n102\n1024\n123477... | [
"YES\nYES\n",
"NO\nYES\n",
"NO\nNO\n",
"YES\nNO\n",
"YES\nYES\n",
"NO\nYES\n",
"YES\nYES\n",
"YES\nYES\n",
"YES\nYES\n",
"YES\nYES\n"
] |
CodeContests | Rohit was doing the work of his math class about three days but he is tired of make operations a lot and he should deliver his task tomorrow. His math’s teacher gives two numbers a and b. The problem consist in find the last digit of the potency of base a and index b. Help Rohit with his problem. You are given two inte... | stdin | null | 2,914 | 1 | [
"3\n3 10\n6 2\n150 53\n\nSAMPLE\n"
] | [
"9\n6\n0\n"
] | [
"30\n08941761866654272494245005281916123986911472773903796599557515081690568994725200707870160747585304140153868517750597331941756008044986871525828258305759125234194328375196577953580261926820556206478920364717504321229039532084718613578759900469799634754391129330770267000228767545500507403557633053089812522745545... | [
"4\n5\n1\n7\n0\n8\n1\n7\n8\n5\n1\n1\n7\n6\n5\n6\n2\n4\n4\n6\n6\n6\n6\n1\n1\n4\n5\n8\n1\n9\n",
"3\n6\n6\n1\n0\n6\n0\n1\n8\n6\n6\n6\n2\n6\n9\n0\n6\n5\n4\n8\n6\n5\n4\n",
"1\n6\n1\n4\n1\n1\n2\n3\n6\n5\n4\n4\n0\n6\n4\n1\n",
"2\n6\n5\n1\n1\n",
"9\n6\n0\n",
"4\n5\n1\n7\n0\n8\n1\n7\n8\n5\n1\n1\n7\n6\n5\n6\n2\n4\n... |
CodeContests | Game of numbers is a game where you are given two integers (X and Y), and you have to print the number of special numbers between X and Y both inclusive.
The property of a special numbers is as follows:
A special number is not divisible by any number of the form ZZ* where (Z\; >\; 1).
Input:
T, the number of ... | stdin | null | 719 | 1 | [
"1\n1 10\n\nSAMPLE\n"
] | [
"7\n"
] | [
"1\n1 10\n\nELPMAS\n",
"1\n1 9\n\nELPMAS\n",
"1\n2 9\n\nELPMAS\n",
"1\n2 4\n\nSAMPLE\n",
"1\n2 2\n\nSANPLE\n",
"1\n1 15\n\nELPMAS\n",
"1\n3 9\n\nSAMPLE\n",
"1\n1 14\n\nELPM@S\n",
"1\n1 29\n\nELOMAS\n",
"1\n1 25\n\nELOMAS\n"
] | [
"7\n",
"6\n",
"5\n",
"2\n",
"1\n",
"11\n",
"4\n",
"10\n",
"18\n",
"16\n"
] |
CodeContests | The time is 2020. There is data that saves the qualifying results of PC Koshien 2020. This data stores the reference number and the number of correct answers assigned to each team. Here, the ranking is determined by the number of correct answers, and the ranking is given in descending order of the number of correct ans... | stdin | null | 4,311 | 1 | [
"1,20\n2,20\n3,30\n4,10\n5,10\n6,20\n0,0\n1\n2\n4\n5\n"
] | [
"2\n2\n3\n3\n"
] | [
"1,20\n2,20\n3,30\n4,10\n5,10\n6,20\n0,0\n1\n2\n4\n1\n",
"1,20\n2,20\n3,30\n4,10\n5,10\n0,26\n0,0\n1\n2\n4\n1\n",
"1,20\n2,20\n3,30\n4,10\n5,10\n0,26\n0,0\n0\n2\n4\n1\n",
"1,20\n2,20\n3,30\n4,10\n5,10\n0,26\n0,0\n1\n2\n4\n0\n",
"1,20\n2,20\n3,30\n4,10\n5,10\n0,26\n0,0\n1\n3\n4\n0\n",
"1,20\n2,20\n3,30\n4,... | [
"2\n2\n3\n2\n",
"3\n3\n4\n3\n",
"2\n3\n4\n3\n",
"3\n3\n4\n2\n",
"3\n1\n4\n2\n",
"3\n1\n1\n2\n",
"2\n3\n5\n3\n",
"2\n2\n3\n3\n",
"2\n3\n3\n2\n",
"2\n3\n2\n3\n"
] |
CodeContests | Write a program which manipulates a sequence A = {a1, a2, . . . , an} with the following operations:
* add(s, t, x): add x to as, as+1, ..., at.
* getSum(s, t): report the sum of as, as+1, ..., at.
Note that the initial values of ai (i = 1, 2, . . . , n) are 0.
Constraints
* 1 ≤ n ≤ 100000
* 1 ≤ q ≤ 100000
* 1 ≤ ... | stdin | null | 2,032 | 1 | [
"4 3\n1 1 4\n0 1 4 1\n1 1 4\n",
"3 5\n0 1 2 1\n0 2 3 2\n0 3 3 3\n1 1 2\n1 2 3\n"
] | [
"0\n4\n",
"4\n8\n"
] | [
"4 3\n1 1 4\n1 1 4 1\n1 1 4\n",
"4 3\n1 1 2\n0 1 4 1\n1 1 4\n",
"3 5\n0 1 2 1\n0 2 3 2\n0 2 3 3\n1 1 2\n1 2 3\n",
"4 2\n1 1 4\n1 1 4 1\n1 1 0\n",
"3 5\n0 1 1 1\n0 2 3 2\n0 2 3 3\n1 1 2\n1 2 3\n",
"3 5\n0 1 1 1\n0 2 3 2\n0 2 3 3\n1 1 2\n0 2 3\n",
"4 3\n1 1 4\n0 1 6 0\n0 2 0\n",
"3 5\n0 1 2 1\n0 2 3 2\n... | [
"0\n0\n0\n",
"0\n4\n",
"7\n11\n",
"0\n0\n",
"6\n10\n",
"6\n",
"0\n",
"7\n",
"4\n10\n",
"0\n1\n"
] |
CodeContests | The cake shop made a lot of roll cakes of various sizes. You have been tasked with arranging this cake in a box.
The roll cake is so soft that it will collapse if another roll cake is on top. Therefore, as shown in Fig. (A), all roll cakes must be arranged so that they touch the bottom of the box. Sorting also changes... | stdin | null | 3,961 | 1 | [
"30 4 5 6\n30 5 5 5\n50 3 3 3 10 10\n49 3 3 3 10 10\n"
] | [
"OK\nOK\nOK\nNA\n"
] | [
"30 4 5 6\n8 5 5 5\n50 3 3 3 10 10\n49 3 3 3 10 10\n",
"30 3 5 6\n6 5 5 5\n50 3 3 3 13 10\n49 3 3 3 10 10\n",
"3 3 5 6\n5 5 5 5\n37 3 3 3 4 10\n4 1 3 3 10 10\n",
"3 3 5 2\n5 10 5 5\n37 3 3 3 4 3\n4 1 3 3 10 10\n",
"30 4 5 6\n30 5 5 5\n50 3 3 3 10 10\n49 3 3 3 4 10\n",
"30 4 5 6\n30 5 5 5\n41 3 3 3 7 10\n4... | [
"OK\nNA\nOK\nNA\n",
"OK\nNA\nNA\nNA\n",
"NA\nNA\nNA\nNA\n",
"NA\nNA\nOK\nNA\n",
"OK\nOK\nOK\nOK\n",
"OK\nOK\nNA\nOK\n",
"NA\nOK\nNA\nOK\n",
"NA\nOK\nNA\nNA\n",
"OK\nNA\nOK\nOK\n",
"NA\nOK\nOK\nNA\n"
] |
CodeContests | Taichi thinks a binary string X of odd length N is beautiful if it is possible to apply the following operation \frac{N-1}{2} times so that the only character of the resulting string is `1` :
* Choose three consecutive bits of X and replace them by their median. For example, we can turn `00110` into `010` by applying ... | stdin | null | 2,960 | 1 | [
"1??00\n",
"?0101???10???00?1???????????????0????????????1????0\n",
"?\n"
] | [
"2\n",
"402589311\n",
"1\n"
] | [
"?0101???00???00?1???????????????0????????????1????0\n",
"?0101???00???00?1???????????????0???????????1?????0\n",
"?01?1???00???00?1????????0??????0???????????1?????0\n",
"?0101???10????0?1???????????????0??0?????????1????0\n",
"?0100???00???00?1???????????????0????????????1????0\n",
"?0101???00???0??1???... | [
"197281130\n",
"82489874\n",
"115611171\n",
"819915\n",
"852907369\n",
"240687337\n",
"738116113\n",
"771237410\n",
"526227533\n",
"411436277\n"
] |
CodeContests | In 2020, AtCoder Inc. with an annual sales of more than one billion yen (the currency of Japan) has started a business in programming education.
One day, there was an exam where a one-year-old child must write a program that prints `Hello World`, and a two-year-old child must write a program that receives integers A, B... | stdin | null | 2,011 | 1 | [
"1\n",
"2\n3\n5\n"
] | [
"Hello World\n",
"8\n"
] | [
"2\n4\n5\n",
"2\n4\n9\n",
"2\n2\n9\n",
"2\n3\n11\n",
"2\n0\n21\n",
"2\n1\n21\n",
"2\n2\n21\n",
"2\n4\n21\n",
"2\n4\n13\n",
"2\n4\n23\n"
] | [
"9\n",
"13\n",
"11\n",
"14\n",
"21\n",
"22\n",
"23\n",
"25\n",
"17\n",
"27\n"
] |
CodeContests | Example
Input
6 3
1 0 0 1 0 1
1 3 2
Output
1 | stdin | null | 4,162 | 1 | [
"6 3\n1 0 0 1 0 1\n1 3 2\n"
] | [
"1\n"
] | [
"1 3\n1 0 0 1 0 1\n1 3 2\n",
"6 3\n1 0 1 0 0 1\n1 3 2\n",
"6 3\n1 0 0 1 0 1\n0 3 3\n",
"6 3\n0 1 0 1 0 1\n0 3 3\n",
"6 3\n1 0 1 1 0 0\n1 3 2\n",
"1 3\n1 0 0 1 0 1\n2 3 2\n",
"1 3\n1 0 0 1 0 1\n2 3 1\n",
"1 3\n1 0 0 1 0 1\n2 0 1\n",
"1 3\n1 0 0 1 0 1\n1 3 1\n",
"1 3\n1 0 -1 1 0 1\n1 3 1\n"
] | [
"0\n",
"2\n",
"4\n",
"3\n",
"1\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n"
] |
CodeContests | Problem
Aizu Magic School is a school where people who can use magic gather. Haruka, one of the students of that school, can use the magic of warp on the magic team.
From her house to the school, there is a straight road of length L. There are also magic circles on this road.
She uses this road every day to go to sch... | stdin | null | 426 | 1 | [
"10 2\n2 3 1\n3 5 1\n",
"1 0\n",
"10 3\n2 2 1\n4 2 1\n8 1 1\n"
] | [
"6\n",
"1\n",
"8\n"
] | [
"10 2\n2 3 1\n1 5 1\n",
"10 2\n2 3 1\n1 5 0\n",
"10 0\n2 3 1\n1 5 1\n",
"18 0\n2 3 1\n1 5 1\n",
"0 0\n2 -1 1\n0 1 1\n",
"1 0\n2 0 2\n1 2 1\n",
"2 1\n1 0 7\n4 -1 0\n",
"10 3\n2 0 1\n4 2 1\n8 1 1\n",
"34 0\n2 3 1\n1 5 1\n",
"8 0\n2 0 1\n0 3 1\n"
] | [
"6\n",
"5\n",
"10\n",
"18\n",
"0\n",
"1\n",
"2\n",
"9\n",
"34\n",
"8\n"
] |
CodeContests | Gandhijee is interested in building human tree. He defined a human node as follows :
Person_Id = English alphabet {a...z} .
Person_Chain_Definition = Person_Id ( Person_Chain_Definition Person_Chain_Definition )
For example :
a( b(..) c( d( . e(..) ) f( . . ) ) ) refers to a human tree having a as the roo... | stdin | null | 2,038 | 1 | [
"2\n-1 a(c(f(.h(..))b(g(..).))e(.d(..)))\n3 b(c(..)a(..))\n\nSAMPLE\n"
] | [
"cgh\nCommon Gandhijee!\n"
] | [
"2\n-1 a(c(f(.h(..))b(g(..).))e(.d(..)))\n3 b(c(..)a(..))\n\nELPMAS\n",
"2\n0 a(c(f(.h(..))b(g(..).))e(.d(..)))\n3 b(c(..)a(..))\n\nELPMAS\n",
"2\n-1 a(c(f(.h(..))b(g(..).))e(.d(..)))\n0 b(c(..)a(..))\n\nELPMAS\n",
"2\n-2 a(c(f(.h(..))b(g(..).))e(.d(..)))\n0 b(c(..)a(..))\n\nELPMAS\n",
"2\n0 a(c(f(.h(..))b(... | [
"cgh\nCommon Gandhijee!\n",
"ab\nCommon Gandhijee!\n",
"cgh\nb\n",
"f\nb\n",
"ab\na\n",
"e\nCommon Gandhijee!\n",
"f\na\n",
"ab\nb\n",
"f\nCommon Gandhijee!\n",
"d\nCommon Gandhijee!\n"
] |
CodeContests | Example
Input
2
10 10
Output
40.00000000 | stdin | null | 1,297 | 1 | [
"2\n10 10\n"
] | [
"40.00000000\n"
] | [
"2\n10 4\n",
"2\n3 4\n",
"2\n3 1\n",
"2\n4 1\n",
"2\n4 2\n",
"2\n7 2\n",
"2\n1 2\n",
"2\n1 0\n",
"2\n2 0\n",
"2\n4 0\n"
] | [
"26.649110641\n",
"13.928203230\n",
"7.464101615\n",
"9.000000000\n",
"11.656854249\n",
"16.483314774\n",
"5.828427125\n",
"2.000000000\n",
"4.000000000\n",
"8.000000000\n"
] |
CodeContests | Problem
There is a string $ S $ of length $ N $. All characters in $ S $ are numbers between 0 and 9.
When you make a sequence of $ \ frac {N \ times (N + 1)} {2} $, which is the number of terms created by enumerating all the numbers created from all the substrings of $ S $, Find the smallest value in $ H $.
Constrai... | stdin | null | 3,373 | 1 | [
"5 13\n10031\n",
"2 3\n00\n",
"4 9\n0012\n"
] | [
"100\n",
"0\n",
"12\n"
] | [
"5 13\n12368\n",
"4 4\n0012\n",
"5 15\n12368\n",
"5 15\n18996\n",
"5 15\n27965\n",
"5 15\n31436\n",
"5 5\n31436\n",
"5 3\n31436\n",
"5 6\n31436\n",
"5 5\n12368\n"
] | [
"1236\n",
"1\n",
"12368\n",
"18996\n",
"27965\n",
"31436\n",
"6\n",
"3\n",
"14\n",
"8\n"
] |
CodeContests | There is a rectangle in the xy-plane, with its lower left corner at (0, 0) and its upper right corner at (W, H). Each of its sides is parallel to the x-axis or y-axis. Initially, the whole region within the rectangle is painted white.
Snuke plotted N points into the rectangle. The coordinate of the i-th (1 ≦ i ≦ N) po... | stdin | null | 2,648 | 1 | [
"5 4 3\n2 1 1\n3 3 4\n1 4 2\n",
"5 4 2\n2 1 1\n3 3 4\n",
"10 10 5\n1 6 1\n4 1 3\n6 9 4\n9 4 2\n3 1 3\n"
] | [
"0\n",
"9\n",
"64\n"
] | [
"5 4 3\n2 1 1\n3 6 4\n1 4 2\n",
"5 4 2\n2 1 1\n6 3 4\n",
"5 4 2\n2 1 2\n6 3 4\n",
"10 10 5\n1 6 1\n4 1 1\n6 9 4\n9 4 2\n3 1 4\n",
"5 4 1\n2 1 2\n6 3 4\n",
"5 4 3\n2 0 2\n2 6 2\n1 4 2\n",
"10 10 5\n1 14 1\n4 1 1\n6 4 4\n9 0 2\n3 2 4\n",
"10 10 5\n1 6 1\n4 1 3\n6 9 4\n9 4 2\n3 0 3\n",
"5 1 3\n2 0 2\n2... | [
"0\n",
"9\n",
"6\n",
"5\n",
"8\n",
"4\n",
"10\n",
"64\n",
"2\n",
"12\n"
] |
CodeContests | Hideyuki is allowed by his father Ujisato some 1000 yen bills every month for his pocket money. In the first day of every month, the number of bills is decided as follows. Ujisato prepares n pieces of m-sided dice and declares the cutback k. Hideyuki rolls these dice. The number of bills given is the sum of the spots o... | stdin | null | 1,579 | 1 | [
"2 6 0\n2 6 3\n3 10 9\n13 3 27\n1 2008 3\n0 0 0\n"
] | [
"7.00000000\n4.11111111\n7.71000000\n1.42902599\n1001.50298805\n"
] | [
"2 6 0\n2 6 3\n3 10 3\n13 3 27\n1 2008 3\n0 0 0\n",
"2 6 0\n2 6 3\n3 10 3\n13 3 34\n1 2008 3\n0 0 0\n",
"2 6 0\n2 6 4\n3 10 9\n13 3 27\n1 2008 3\n0 0 0\n",
"2 3 0\n2 6 3\n3 10 3\n13 3 34\n1 2008 3\n0 0 0\n",
"2 6 0\n2 6 4\n3 10 13\n13 3 27\n1 2008 3\n0 0 0\n",
"2 4 0\n2 6 4\n3 10 13\n13 3 27\n1 2008 3\n0 ... | [
"7.0000000000\n4.1111111111\n13.5010000000\n1.4290259878\n1001.5029880478\n",
"7.0000000000\n4.1111111111\n13.5010000000\n1.0004183594\n1001.5029880478\n",
"7.0000000000\n3.2777777778\n7.7100000000\n1.4290259878\n1001.5029880478\n",
"4.0000000000\n4.1111111111\n13.5010000000\n1.0004183594\n1001.5029880478\n",... |
CodeContests | You are given three integers A, B and C.
Determine if there exists an equilateral triangle whose sides have lengths A, B and C.
Constraints
* All values in input are integers.
* 1 \leq A,B,C \leq 100
Input
Input is given from Standard Input in the following format:
A B C
Output
If there exists an equilateral ... | stdin | null | 532 | 1 | [
"2 2 2\n",
"3 4 5\n"
] | [
"Yes\n",
"No\n"
] | [
"2 4 2\n",
"0 0 0\n",
"3 4 2\n",
"2 6 2\n",
"3 4 1\n",
"2 7 2\n",
"3 0 1\n",
"1 7 2\n",
"4 0 1\n",
"0 7 2\n"
] | [
"No\n",
"Yes\n",
"No\n",
"No\n",
"No\n",
"No\n",
"No\n",
"No\n",
"No\n",
"No\n"
] |
CodeContests | On the divine friendship day, "A" tied "B" a friendship band. But alas! Frequent quarrels started between them and "B" decided to remove and break off the band! The band isnt a huge one and consists of red, blue and white beads in random positioning. Here are two examples for number of beads = 29:
1 2 ... | stdin | null | 3,621 | 1 | [
"29\nwwwbbrwrbrbrrbrbrwrwwrbwrwrrb\n\nSAMPLE\n"
] | [
"11\n"
] | [
"29\nwwwbbrwrbrbrrbrbswrwwrbwrwrrb\n",
"77\nrwrwrwrwrwrwrwrwrwrwrwrwbwrwbwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrvrwrwrwrwrwrwrwr\n",
"350\nrrbbrbbbwbwwbwbbbbwwrrbbwbrwbrwbbbqbrwrwbrwwwrrbbrrwrbbrwbwrwwwrbrwwwwwrwbwwwrrbrrbbbrbrbbbrbbbrbbwbbbbbrbrrbrwwbrrrrwbwrwrbbwbwrbrbrwwbrrbwbrwwbwwwbrbwrwbwbrbbbwrbwwrrrbwbwbbbbbrr... | [
"11\n",
"41\n",
"19\n",
"9\n",
"37\n",
"7\n",
"31\n",
"6\n",
"24\n",
"17\n"
] |
CodeContests | Write a program which reads a sequence of integers $A = \\{a_0, a_1, ..., a_{n-1}\\}$ and rotate specified elements by a list of the following operation:
* rotate($b, m, e$): For each integer $k$ ($0 \leq k < (e - b)$), move element $b + k$ to the place of element $b + ((k + (e - m)) \mod (e - b))$.
Constraints
* $1... | stdin | null | 4,094 | 1 | [
"11\n1 2 3 4 5 6 7 8 9 10 11\n1\n2 6 9\n"
] | [
"1 2 7 8 9 3 4 5 6 10 11\n"
] | [
"11\n1 2 3 4 5 6 7 8 18 10 11\n1\n2 6 9\n",
"11\n1 2 3 4 5 6 7 8 18 10 11\n1\n4 6 9\n",
"11\n1 2 3 4 5 6 7 5 18 10 11\n1\n4 6 9\n",
"11\n1 2 3 4 5 6 7 5 18 10 10\n1\n4 6 9\n",
"11\n1 2 3 4 5 9 7 5 18 10 10\n1\n4 6 9\n",
"11\n2 2 3 4 5 9 7 5 18 10 10\n1\n4 6 9\n",
"11\n2 2 3 4 5 9 7 5 18 10 2\n1\n4 6 9\n... | [
"1 2 7 8 18 3 4 5 6 10 11\n",
"1 2 3 4 7 8 18 5 6 10 11\n",
"1 2 3 4 7 5 18 5 6 10 11\n",
"1 2 3 4 7 5 18 5 6 10 10\n",
"1 2 3 4 7 5 18 5 9 10 10\n",
"2 2 3 4 7 5 18 5 9 10 10\n",
"2 2 3 4 7 5 18 5 9 10 2\n",
"2 2 1 4 7 5 18 5 9 10 2\n",
"2 2 1 4 7 5 29 5 9 10 2\n",
"2 2 1 4 7 5 29 5 9 10 1\n"
] |
CodeContests | Xsquare loves to play with arrays a lot. Today, he has two arrays named as A and B. Each array consists of N positive integers.
Xsquare has decided to fulfill following types of queries over his array A and array B.
1 L R : Print the value of AL + BL+1 + AL+2 + BL+3 + ... upto R^th term.
2 L R : Print the value of... | stdin | null | 1,922 | 1 | [
"5 5\n1 2 3 4 5\n5 4 3 2 1\n1 1 5\n2 1 5\n1 2 4\n2 2 4\n1 3 5\n\n\nSAMPLE\n"
] | [
"15\n15\n9\n9\n10\n"
] | [
"1000 1000\n158260522 877914575 602436426 24979445 861648772 623690081 433933447 476190629 262703497 211047202 971407775 628894325 731963982 822804784 450968417 430302156 982631932 161735902 880895728 923078537 707723857 189330739 910286918 802329211 404539679 303238506 317063340 492686568 773361868 125660016 65028... | [
"199792877508\n223595886044\n299603954887\n38686209626\n243423715756\n54964179549\n24933500680\n96788171182\n15173257684\n187398455708\n67889692569\n203748426562\n168541347685\n49877606633\n210535922291\n268343624363\n234912943572\n97310788416\n118529935731\n97552990787\n74551501975\n247650154264\n209143781909\n122... |
CodeContests | There is a sale in the market on clothes , so as usual N girls gathered there to grab great deals.But due to huge popularity of sale crowd has gone uncontrollable. You being head of management team of the mall has been assigned the task to make them form a queue so that everyone can shop turn-wise.
Since queue is going... | stdin | null | 1,718 | 1 | [
"2\n5 3\n1 2\n3 4\n2 5\n4 3\n1 2\n1 3\n1 4\n\nSAMPLE\n"
] | [
"YES\nNO\n"
] | [
"2\n5 3\n1 2\n3 4\n2 5\n4 1\n1 2\n1 3\n1 4\n\nSAMPLE\n",
"2\n5 3\n1 2\n3 3\n2 5\n4 3\n1 2\n1 3\n1 4\n\nSAMPLE\n",
"2\n5 3\n1 2\n3 4\n2 5\n4 3\n1 2\n1 4\n1 4\n\nSAMPLE\n",
"2\n5 3\n1 2\n3 3\n2 5\n4 0\n1 2\n1 3\n1 4\n\nSAMPLE\n",
"2\n5 3\n1 2\n3 4\n2 5\n4 0\n1 2\n1 3\n1 4\n\nSAMPLE\n",
"2\n5 3\n1 2\n3 4\n2 ... | [
"YES\nYES\n",
"NO\nNO\n",
"YES\nNO\n",
"NO\nYES\n",
"YES\nYES\n",
"YES\nYES\n",
"YES\nYES\n",
"YES\nYES\n",
"YES\nYES\n",
"YES\nYES\n"
] |
CodeContests | Problem Statement
Mr. Takatsuki, who is planning to participate in the Aizu training camp, has a poor house and does not have much money. Therefore, he is trying to save money by using the Seishun 18 Ticket. With only one 18 ticket, you can ride a local train all day long, and you can enter and exit the ticket gates f... | stdin | null | 4,441 | 1 | [
"8 24\n05:30 Kyoto 06:37 Maibara\n06:50 Maibara 07:36 Tsuruga\n07:42 Tsuruga 10:03 Kanazawa\n10:58 Kanazawa 12:07 Toyama\n12:15 Toyama 14:12 Naoetsu\n14:29 Naoetsu 15:57 Nagaoka\n16:11 Nagaoka 17:14 Niitsu\n17:38 Niitsu 20:06 AizuWakamatsu\n",
"N T\nst_time1 st_name1 ar_time1 ar_name1\nst_time2 st_name2 ar_time2 ... | [
"2\nKanazawa 55\nNiitsu 24\n",
"2\nKanazawa 55\nNiitsu 24\n",
"0\n"
] | [
"8 24\n05:30 Kyoto 06:37 Maibara\n06:50 Maibara 07:36 Tsuruga\n07:42 Tsuruga 10:03 Kanazawa\n10:58 Kanazawa 12:07 Toyama\n12:15 Toyama 14:12 Naoetsu\n14:29 Noaetsu 15:57 Nagaoka\n16:11 Nagaoka 17:14 Niitsu\n17:38 Niitsu 20:06 AizuWakamatsu\n",
"1 180\n10:44 Kosiyama 11:52 AizuWakamatsu\n",
"8 24\n05:30 Kyoto 06... | [
"2\nKanazawa 55\nNiitsu 24\n",
"0\n",
"2\nKanazawa 55\nNiitsu 34\n",
"0\n",
"2\nKanazawa 55\nNiitsu 24\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n"
] |
CodeContests | Problem H: Oh, My Goat!
Taro borrowed an ancient notebook from Jiro. This is to copy tomorrow's ancient Chinese homework. Taro has a cautious personality, so just in case, he took a copy of Jiro's notebook at a convenience store in the neighborhood and went home.
Taro was in a hurry when he was about to start his hom... | stdin | null | 2,338 | 1 | [
"4\n2 1\n0 1 a\n2 2\n0 1 a\n0 1 b\n5 5\n0 1 a\n0 2 b\n1 3 a\n2 3 c\n3 4 e\n3 3\n0 1 aa\n0 2 bce\n1 2 a\n2 4\n0 1 abc\n0 1 def\n0 1 ghi\n0 1 jkl\n2 4\n0 1 ghi\n0 1 jkl\n0 1 mno\n0 1 pqr\n6 7\n0 1 haru\n0 1 natsu\n1 2 wa\n2 3 ake\n2 4 saron\n3 5 bono\n4 5 pusu\n5 4\n0 1 haruw\n1 2 aakeb\n2 3 o\n3 4 no\n"
] | [
"1\n1\n2\n1\n"
] | [
"4\n2 1\n0 1 a\n2 2\n0 1 `\n0 1 b\n5 5\n0 1 a\n0 2 b\n1 3 a\n2 3 c\n3 4 e\n3 3\n0 1 aa\n0 2 bce\n1 2 a\n2 4\n0 1 abc\n0 1 def\n0 1 ghi\n0 1 jkl\n2 4\n0 1 ghi\n0 1 jkl\n0 1 mno\n0 1 pqr\n6 7\n0 1 haru\n0 1 natsu\n1 2 wa\n2 3 ake\n2 4 saron\n3 5 bono\n4 5 pusu\n5 4\n0 1 haruw\n1 2 aakeb\n2 3 o\n3 4 no\n",
"4\n2 1\n... | [
"0\n1\n2\n1\n",
"0\n1\n2\n0\n",
"1\n1\n2\n1\n",
"0\n0\n2\n0\n",
"0\n0\n2\n1\n",
"0\n0\n0\n1\n",
"0\n0\n0\n0\n",
"1\n1\n2\n0\n",
"0\n0\n1\n0\n",
"0\n1\n1\n0\n"
] |
CodeContests | The Chef's latest idea is that some cooks might work better in pairs. So, he is going to experiment by pairing up some of his employees to see if the quality of the food prepared in his kitchen increases. However, only some pairs of employees are compatible. Two employees that are not compatible cannot be paired togeth... | stdin | null | 913 | 1 | [
"2\n4 5\n0 1\n1 2\n2 3\n1 3\n3 0\n4 3\n0 1\n2 3\n2 1\n"
] | [
"1 4\n2\n"
] | [
"2\n4 5\n0 1\n1 2\n2 3\n1 3\n3 0\n4 3\n0 1\n2 3\n2 0\n",
"2\n4 5\n0 1\n1 2\n0 3\n1 3\n1 0\n4 3\n0 1\n2 3\n2 0\n",
"2\n4 5\n0 1\n1 2\n1 3\n1 3\n2 0\n4 3\n0 1\n2 3\n2 0\n",
"2\n4 5\n0 1\n1 2\n1 3\n0 3\n3 0\n4 1\n0 1\n2 3\n2 1\n",
"2\n4 5\n-1 1\n1 2\n0 3\n1 3\n1 0\n4 3\n0 1\n1 3\n2 0\n",
"2\n8 5\n0 1\n1 2\n1... | [
"1 4\n2\n",
"4\n2\n",
"3 4\n2\n",
"1 4\n0\n",
"4\n1 2\n",
"2 4\n2\n",
"4\n0\n",
"1 4\n0 2\n",
"3 4\n1 2\n",
"3 4\n0\n"
] |
CodeContests | In HackerLand, they have a very strange monetary system.
Each gold coin has an integer number 'N' written on it.
A coin N can be split into any number of coins.
For example {11} can be split into {5,6} or {2,4,5} or any other possible way.
You are offered such a coin to take home. But your family does not like coins w... | stdin | null | 3,783 | 1 | [
"4\n11\n12345\n12421\n2444\n\nSAMPLE\n"
] | [
"2\n1\n2\n1\n"
] | [
"30\n1\n8566\n6308\n41\n5680\n4427\n2739\n77\n6274\n3601\n7506\n8951\n5345\n3\n9621\n9300\n23\n720\n2151\n7854\n3607\n256\n6076\n9369\n1729\n8229\n63\n980\n4197\n1460\n",
"4\n11\n12345\n12421\n2444\n\nRAMPLE\n",
"30\n1\n8566\n6308\n30\n5680\n4427\n8905\n77\n6274\n3601\n7506\n8951\n5345\n3\n9621\n9300\n23\n720\n... | [
"1\n1\n1\n2\n1\n1\n1\n1\n1\n1\n1\n2\n1\n3\n1\n1\n2\n1\n1\n1\n2\n1\n1\n1\n1\n1\n1\n1\n1\n1\n",
"2\n1\n2\n1\n",
"1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n2\n1\n3\n1\n1\n2\n1\n1\n1\n2\n1\n1\n1\n1\n1\n1\n1\n1\n1\n",
"1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n2\n1\n3\n1\n1\n2\n1\n1\n1\n2\n1\n1\n1\n1\n1\n2\n1\n1\n1\n",
"1\n1\n1\n... |
CodeContests | Natsume loves big cats. Natsume decided to head to a corner of the schoolyard where stray cats always gather in order to brush the stray cats, which is a daily routine today.
N cats gathered at the spot today. Natsume wanted to brush everyone, but suddenly she was able to do something just before she came there, and s... | stdin | null | 943 | 1 | [
"4\n3 2 1\n20 1\n10 2\n5 7 3\n70 1\n60 4\n50 2\n40 4\n30 1\n20 3\n10 2\n1 0 1\n4 2 1\n10 1\n10 3\n"
] | [
"1\n0\n1\n1\n0\n1\n1\n2\n0\n1\n0\n1\n2\n"
] | [
"4\n3 2 1\n20 1\n10 2\n5 7 3\n70 1\n60 4\n50 2\n40 4\n30 1\n20 3\n10 2\n1 0 1\n0 2 1\n10 1\n10 3\n",
"4\n3 2 1\n20 1\n10 2\n5 7 3\n70 1\n60 4\n50 2\n40 4\n30 1\n20 3\n10 3\n1 0 1\n0 0 1\n10 1\n10 4\n",
"4\n3 2 1\n20 1\n10 2\n5 7 3\n79 1\n60 3\n50 2\n21 4\n10 1\n30 3\n18 3\n1 0 1\n0 0 1\n3 1\n10 4\n",
"4\n3 2 ... | [
"1\n0\n1\n1\n0\n1\n1\n2\n0\n",
"1\n0\n1\n0\n1\n1\n1\n1\n0\n",
"1\n0\n1\n1\n1\n1\n1\n0\n0\n",
"1\n0\n1\n1\n1\n0\n1\n1\n0\n",
"1\n0\n1\n1\n1\n0\n1\n1\n0\n0\n",
"1\n0\n1\n1\n0\n1\n1\n2\n2\n3\n4\n5\n6\n0\n1\n0\n1\n2\n",
"1\n0\n1\n1\n2\n1\n1\n0\n0\n",
"1\n0\n1\n1\n0\n1\n1\n1\n0\n",
"1\n0\n1\n0\n1\n1\n1\n... |
CodeContests | You are given a tree with N vertices. The vertices are numbered 0 through N-1, and the edges are numbered 1 through N-1. Edge i connects Vertex x_i and y_i, and has a value a_i. You can perform the following operation any number of times:
* Choose a simple path and a non-negative integer x, then for each edge e that b... | stdin | null | 4,704 | 1 | [
"5\n0 1 1\n0 2 3\n0 3 6\n3 4 4\n",
"2\n1 0 0\n"
] | [
"3\n",
"0\n"
] | [
"5\n0 1 1\n0 2 3\n0 3 6\n3 4 1\n",
"2\n1 1 0\n",
"5\n0 1 1\n0 3 3\n0 3 5\n4 4 1\n",
"2\n0 1 2\n",
"5\n0 1 1\n0 2 3\n0 3 6\n4 4 1\n",
"2\n1 1 1\n",
"5\n0 1 1\n0 2 3\n0 3 5\n4 4 1\n",
"2\n1 1 2\n",
"5\n0 1 1\n0 3 3\n0 3 10\n4 4 1\n",
"5\n0 1 1\n0 0 3\n0 3 10\n4 4 1\n"
] | [
"3\n",
"0\n",
"2\n",
"1\n",
"3\n",
"0\n",
"3\n",
"0\n",
"2\n",
"2\n"
] |
CodeContests | H: Revenge of UMG
problem
For the character string T consisting of three types of characters,'U',' M', and'G', the 1, 2, ..., | T | characters are T_1, T_2, ..., T_ {|, respectively. When we decide to express T |}, we call the number of pairs of (i, j, k) that satisfy the following conditions the "UMG number" of the ... | stdin | null | 2,305 | 1 | [
"?MG?\n"
] | [
"3\n"
] | [
"?NG?\n",
"?OG?\n",
"O?G?\n",
"O?G@\n",
"@G?O\n",
"@G>O\n",
"OG>@\n",
"OG?@\n",
"OF?@\n",
"OF??\n"
] | [
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n"
] |
CodeContests | Tanmay is a legendary spammer - everyone in the spamming world knows and admires his abilities to spam anyone, anytime, anywhere. He decided to guide one of his mentors, named Arjit, as part of the Apex body of spamming.
Tanmay has no doubts on his skills of teaching and making his mentor, Arjit, learn about the art ... | stdin | null | 3,829 | 1 | [
"2\n4\n1 0 2 10\n3\n0 0 0\n\nSAMPLE\n"
] | [
"20 0\n0 0\n"
] | [
"500\n18\n8 5 5 -9 -8 0 0 -3 -7 2 0 4 2 -6 1 -9 2 -6 \n18\n9 9 -7 -6 -2 -3 -4 4 -6 5 -4 7 -4 -6 2 -10 -5 2 \n18\n-1 3 7 2 -8 -3 -7 2 -1 2 4 10 6 0 8 10 4 -6 \n18\n-6 10 8 -2 2 -8 -8 6 -4 4 6 -1 -7 -8 -9 -10 5 -6 \n18\n-5 6 6 2 -2 -3 -1 -7 7 -3 -8 0 1 -6 -3 -4 2 7 \n18\n-2 3 2 2 -6 -4 -10 -2 -2 -10 -4 -10 -6 -1 7 8 ... | [
"1045094400 -3135283200\n658409472000 -1316818944000\n13005619200 -13005619200\n10701766656000 -10701766656000\n2560481280 -2560481280\n167215104000 -167215104000\n28576800000 -57153600000\n89181388800 -178362777600\n38880000 -38880000\n9920232000 -4960116000\n2380855680000 -2380855680000\n20321280000 -20321280000\... |
CodeContests | The purpose of this problem is to verify whether the method you are using to read input data is sufficiently fast to handle problems branded with the enormous Input/Output warning. You are expected to be able to process at least 2.5MB of input data per second at runtime.
Input
The input begins with two positive integ... | stdin | null | 4,214 | 1 | [
"7 3\n1\n51\n966369\n7\n9\n999996\n11\n"
] | [
"4\n"
] | [
"7 3\n1\n34\n966369\n7\n9\n999996\n11\n",
"7 3\n1\n34\n966369\n7\n9\n40177\n11\n",
"7 3\n1\n62\n334284\n16\n7\n60700\n7\n",
"6 3\n1\n62\n201449\n16\n7\n60700\n7\n",
"7 2\n1\n62\n334284\n16\n12\n40177\n12\n",
"7 1\n1\n62\n334284\n26\n12\n40177\n7\n",
"7 3\n1\n62\n334284\n18\n12\n13002\n7\n",
"6 1\n1\n6... | [
"3\n",
"2\n",
"1\n",
"0\n",
"5\n",
"7\n",
"4\n",
"6\n",
"2\n",
"2\n"
] |
CodeContests | In 20XX, many years of research have paid off, and wireless energy transmission and reception technology has been put into practical use. By using this technology, it has become possible to supply power to depopulated areas where it was not possible to draw power lines because the cost was not worth it. This technology... | stdin | null | 3,367 | 1 | [
"4\n0 1 3 2 0 1\n1 1 2 2 9 9\n0 0 1 4 5 5\n0 0 1 4 5 10\n"
] | [
"0\n1\n2\n3\n"
] | [
"4\n0 1 3 2 0 1\n1 1 2 2 9 9\n0 0 1 4 5 5\n1 0 1 4 5 10\n",
"4\n0 1 3 2 0 1\n1 1 2 2 9 9\n0 0 2 4 5 5\n1 0 1 4 7 10\n",
"4\n0 1 3 2 0 0\n1 1 2 2 9 9\n0 0 2 4 5 5\n1 0 1 4 7 10\n",
"4\n0 1 3 2 0 0\n1 1 2 2 9 18\n0 0 2 4 5 5\n1 0 1 4 7 10\n",
"4\n0 1 3 2 0 0\n1 1 2 2 9 18\n0 0 2 4 7 5\n1 0 1 4 7 10\n",
"4\n... | [
"0\n1\n2\n3\n",
"0\n1\n2\n2\n",
"2\n1\n2\n2\n",
"2\n3\n2\n2\n",
"2\n3\n3\n2\n",
"2\n3\n3\n3\n",
"2\n3\n2\n3\n",
"2\n4\n2\n3\n",
"3\n3\n2\n3\n",
"3\n3\n3\n3\n"
] |
CodeContests | problem
You want to get a treasure on the Nth basement floor of a dungeon. First, you are on the 1st basement floor and your health is H (H is a positive integer). Go downstairs. Sometimes physical strength is consumed. The physical strength consumed when descending to the lower floor on each floor is known in advance... | stdin | null | 4,711 | 1 | [
"10 10\n4 2\n2 5\n6 1\n7 3\n6 4\n9 6\n0 8\n4 1\n9 4\n"
] | [
"10\n"
] | [
"10 10\n4 3\n2 5\n6 1\n7 3\n6 4\n9 6\n0 8\n4 1\n9 4\n",
"10 10\n4 3\n2 5\n6 1\n6 3\n6 4\n9 6\n0 8\n4 1\n9 4\n",
"10 10\n4 3\n2 3\n6 1\n3 3\n6 4\n9 6\n0 8\n2 1\n9 4\n",
"5 10\n4 3\n2 3\n6 1\n6 3\n6 4\n9 6\n0 8\n4 1\n9 4\n",
"10 10\n4 3\n2 3\n1 1\n6 3\n6 4\n9 9\n0 8\n4 1\n9 4\n",
"10 19\n4 3\n2 3\n1 1\n6 3\... | [
"10\n",
"9\n",
"8\n",
"3\n",
"7\n",
"4\n",
"2\n",
"6\n",
"1\n",
"0\n"
] |
CodeContests | Kode Festival is an anual contest where the hardest stone in the world is determined. (Kode is a Japanese word for "hardness".)
This year, 2^N stones participated. The hardness of the i-th stone is A_i.
In the contest, stones are thrown at each other in a knockout tournament.
When two stones with hardness X and Y ar... | stdin | null | 577 | 1 | [
"3\n1\n3\n2\n4\n6\n8\n100\n104\n",
"2\n1\n3\n10\n19\n"
] | [
"2\n",
"7\n"
] | [
"3\n1\n5\n2\n4\n6\n8\n100\n104\n",
"2\n1\n5\n10\n19\n",
"3\n1\n5\n2\n4\n6\n8\n100\n130\n",
"2\n1\n5\n4\n19\n",
"3\n1\n5\n2\n4\n8\n8\n100\n130\n",
"2\n1\n5\n8\n19\n",
"3\n1\n6\n2\n4\n8\n8\n100\n130\n",
"2\n1\n5\n8\n0\n",
"3\n1\n6\n2\n4\n8\n10\n100\n130\n",
"3\n1\n6\n2\n4\n0\n10\n100\n130\n"
] | [
"2\n",
"5\n",
"26\n",
"11\n",
"20\n",
"7\n",
"19\n",
"4\n",
"25\n",
"17\n"
] |
CodeContests | Consider a data structure called BUT (Binary and/or Unary Tree). A BUT is defined inductively as follows:
* Let l be a letter of the English alphabet, either lowercase or uppercase (n the sequel, we say simply "a letter"). Then, the object that consists only of l, designating l as its label, is a BUT. In this case, it... | stdin | null | 305 | 1 | [
"a(A,b(B,C));\nx( y( y( z(z), v( s, t ) ) ), u ) ;\n\na( b( c,\n d(\n e(f),\n g\n )\n ),\n h( i(\n j(\n k(k,k),\n l(l)\n ),\n m(m)\n )\n )\n );\n\na(B(C),d(e(f(g(h(i(j,k),l),m),n),o),p))\n.\n",
"a(A,b(B,C));\nx( y( y( z(z), v(... | [
"1:\n B C\n ---\nA b\n---\n a\n2:\nz s t\n- ---\nz v\n----\n y\n -\n y u\n ---\n x\n3:\n k k l\n --- -\n f k l m\n - ---- -\n e g j m\n --- -----\nc d i\n--- -\n b h\n -------\n a\n4:\nj k\n---\n i l\n ---\n h m\n ---\n g n\n ---\n f o\n ---\n C e p\n - ---\n B d\n ----\... | [
"a(A,b(B,C));\nx( y( y( z(z), v( s, t ) ) ), u ) ;\n\na( b( c,\n d(\n e(f),\n g\n )\n ),\n g( i(\n j(\n k(k,k),\n l(l)\n ),\n m(m)\n )\n )\n );\n\na(B(C),d(e(f(g(h(i(j,k),l),m),n),o),p))\n.\n",
"a(A,b(B,C));\nx( y( y( z(z), v(... | [
"1:\n B C\n ---\nA b\n---\n a\n2:\nz s t\n- ---\nz v\n----\n y\n -\n y u\n ---\n x\n3:\n k k l\n --- -\n f k l m\n - ---- -\n e g j m\n --- -----\nc d i\n--- -\n b g\n -------\n a\n4:\nj k\n---\n i l\n ---\n h m\n ---\n g n\n ---\n f o\n ---\n C e p\n - ---\n B d\n ----\... |
CodeContests | Let N be an even number.
There is a tree with N vertices. The vertices are numbered 1, 2, ..., N. For each i (1 \leq i \leq N - 1), the i-th edge connects Vertex x_i and y_i.
Snuke would like to decorate the tree with ribbons, as follows.
First, he will divide the N vertices into N / 2 pairs. Here, each vertex must ... | stdin | null | 2,090 | 1 | [
"4\n1 2\n2 3\n3 4\n",
"6\n1 2\n1 3\n3 4\n1 5\n5 6\n",
"10\n8 5\n10 8\n6 5\n1 5\n4 8\n2 10\n3 6\n9 2\n1 7\n",
"4\n1 2\n1 3\n1 4\n"
] | [
"2\n",
"10\n",
"672\n",
"3\n"
] | [
"10\n8 5\n10 8\n6 5\n1 5\n4 8\n2 4\n3 6\n9 2\n1 7\n",
"10\n8 5\n10 8\n6 5\n1 5\n4 8\n2 4\n3 9\n9 2\n1 7\n",
"10\n8 5\n10 8\n6 5\n2 5\n4 8\n2 4\n3 9\n9 2\n1 7\n",
"6\n1 2\n1 3\n3 4\n1 5\n5 7\n",
"10\n8 5\n10 8\n6 5\n1 5\n4 8\n2 10\n3 7\n9 2\n1 7\n",
"10\n8 3\n10 8\n6 5\n1 5\n4 8\n2 4\n3 9\n9 2\n1 7\n",
"... | [
"672\n",
"706\n",
"1\n",
"10\n",
"750\n",
"2\n",
"78\n",
"652\n",
"810\n",
"12\n"
] |
CodeContests | You are a teacher at a cram school for elementary school pupils.
One day, you showed your students how to calculate division of fraction in a class of mathematics. Your lesson was kind and fluent, and it seemed everything was going so well - except for one thing. After some experiences, a student Max got so curious ab... | stdin | null | 3,968 | 1 | [
"1 3\n1 6\n3 5\n2 200\n25 99\n0 0\n"
] | [
"0 1\n1 1\n1 0\n2 0\n0 2\n"
] | [
"2 3\n1 6\n3 5\n2 200\n25 99\n0 0\n",
"2 6\n1 5\n3 5\n2 200\n25 99\n0 0\n",
"1 6\n1 5\n3 5\n2 200\n34 99\n0 0\n",
"1 6\n1 5\n3 9\n2 200\n34 99\n0 0\n",
"1 6\n1 8\n3 9\n2 200\n34 99\n0 0\n",
"1 6\n1 8\n3 9\n2 200\n34 62\n0 0\n",
"2 6\n1 8\n3 9\n2 200\n34 62\n0 0\n",
"2 6\n1 16\n3 9\n2 200\n34 62\n0 0\n... | [
"0 1\n1 1\n1 0\n2 0\n0 2\n",
"0 1\n1 0\n1 0\n2 0\n0 2\n",
"1 1\n1 0\n1 0\n2 0\n0 2\n",
"1 1\n1 0\n0 1\n2 0\n0 2\n",
"1 1\n3 0\n0 1\n2 0\n0 2\n",
"1 1\n3 0\n0 1\n2 0\n0 15\n",
"0 1\n3 0\n0 1\n2 0\n0 15\n",
"0 1\n4 0\n0 1\n2 0\n0 15\n",
"0 1\n4 0\n1 0\n2 0\n0 15\n",
"0 1\n4 0\n1 1\n2 0\n0 15\n"
] |
CodeContests | Natsume loves big cats. One day, Natsume was invited by the stray cats she was always close to to go to the mysterious bookstore where the cats were open. When I heard that the bookstore sells books with many pictures of cats, Natsume decided to follow her happily.
I didn't know Natsume, but the bookstore that was tak... | stdin | null | 1,500 | 1 | [
"4\n3 3 5\n0 0\n10 0\n40 40\n40 90\n4 5 10\n100 100\n50 100\n50 150\n100 50\n100 150\n4 60 10\n100 100\n90 100\n110 100\n100 90\n100 110\n4 60 10\n100 100\n80 100\n110 100\n100 80\n100 110\n"
] | [
"9\n0\n60\nYou're always welcome!\n"
] | [
"4\n3 3 5\n0 0\n10 0\n40 40\n40 90\n4 5 10\n100 100\n50 100\n50 150\n100 50\n100 150\n4 60 10\n100 100\n90 100\n110 100\n100 90\n100 110\n4 60 10\n100 000\n80 100\n110 100\n100 80\n100 110\n",
"4\n3 3 5\n0 0\n17 0\n40 40\n40 90\n4 5 10\n100 100\n50 100\n50 150\n100 50\n100 150\n4 60 10\n100 100\n90 100\n110 100\n... | [
"9\n0\n60\n0\n",
"0\n0\n60\n0\n",
"0\n0\nYou're always welcome!\n0\n",
"0\n0\nYou're always welcome!\nYou're always welcome!\n",
"0\n5\nYou're always welcome!\nYou're always welcome!\n",
"9\n0\n60\nYou're always welcome!\n",
"0\n0\n60\nYou're always welcome!\n",
"0\n0\n0\nYou're always welcome!\n",
... |
CodeContests | Shell Sort
Shell Sort is a generalization of Insertion Sort to arrange a list of $n$ elements $A$.
1 insertionSort(A, n, g)
2 for i = g to n-1
3 v = A[i]
4 j = i - g
5 while j >= 0 && A[j] > v
6 A[j+g] = A[j]
7 j = j - g
8 cnt++
9 A[j+g... | stdin | null | 5,033 | 1 | [
"5\n5\n1\n4\n3\n2\n",
"3\n3\n2\n1\n"
] | [
"2\n4 1\n3\n1\n2\n3\n4\n5\n",
"1\n1\n3\n1\n2\n3\n"
] | [
"5\n5\n1\n4\n5\n2\n",
"3\n6\n2\n1\n",
"5\n6\n1\n4\n5\n2\n",
"3\n0\n2\n1\n",
"5\n6\n1\n4\n9\n2\n",
"3\n-1\n2\n1\n",
"5\n6\n1\n4\n6\n2\n",
"3\n0\n2\n0\n",
"5\n5\n1\n4\n9\n2\n",
"3\n0\n1\n0\n"
] | [
"2\n4 1\n2\n1\n2\n4\n5\n5\n",
"1\n1\n3\n1\n2\n6\n",
"2\n4 1\n2\n1\n2\n4\n5\n6\n",
"1\n1\n1\n0\n1\n2\n",
"2\n4 1\n3\n1\n2\n4\n6\n9\n",
"1\n1\n1\n-1\n1\n2\n",
"2\n4 1\n2\n1\n2\n4\n6\n6\n",
"1\n1\n1\n0\n0\n2\n",
"2\n4 1\n3\n1\n2\n4\n5\n9\n",
"1\n1\n1\n0\n0\n1\n"
] |
CodeContests | A prime number n (11, 19, 23, etc.) that divides by 4 and has 3 has an interesting property. The results of calculating the remainder of the square of a natural number (1, 2, ..., n -1) of 1 or more and less than n divided by n are the same, so they are different from each other. The number is (n -1) / 2.
The set of n... | stdin | null | 1,135 | 1 | [
"11\n15\n0\n"
] | [
"4\n4\n4\n4\n4\n2\n2\n4\n2\n4\n4\n2\n"
] | [
"11\n23\n0\n",
"11\n45\n0\n",
"11\n77\n0\n",
"11\n13\n0\n",
"11\n17\n0\n",
"11\n25\n0\n",
"11\n37\n0\n",
"11\n5\n0\n",
"11\n69\n0\n",
"11\n19\n0\n"
] | [
"4\n4\n4\n4\n4\n10\n10\n10\n10\n10\n10\n10\n10\n10\n10\n10\n",
"4\n4\n4\n4\n4\n4\n2\n6\n4\n6\n12\n2\n2\n16\n6\n4\n6\n2\n4\n18\n4\n2\n8\n4\n6\n12\n2\n",
"4\n4\n4\n4\n4\n10\n12\n12\n10\n12\n10\n22\n12\n10\n10\n22\n12\n10\n22\n10\n10\n10\n12\n10\n12\n22\n22\n10\n10\n10\n12\n12\n22\n12\n12\n12\n12\n22\n12\n22\n10\n... |
CodeContests | Problem
There are $ M $ type characters. Use them to create a string of length $ N $. How many strings are used that have $ K $ or more? Find too much divided by $ 998244353 $.
Here, the difference between two strings of length $ N $ is defined as follows.
* If the two strings are $ S = S_1S_2 \ ldots S_N $, $ T = T... | stdin | null | 2,902 | 1 | [
"7 8 3\n",
"1000000000000000000 1000000000000000000 1000\n",
"5 10 3\n",
"1 1 2\n",
"2 10 1\n"
] | [
"5759460\n",
"133611974\n",
"9755400\n",
"0\n",
"1024\n"
] | [
"10 8 3\n",
"1000000000000000000 1000000000000000000 1001\n",
"5 2 3\n",
"10 8 6\n",
"2 2 2\n",
"1 10 1\n",
"10 6 6\n",
"2 3 2\n",
"2 10 2\n",
"2 11 2\n"
] | [
"99988560\n",
"824796085\n",
"0\n",
"58968000\n",
"2\n",
"1\n",
"151200\n",
"6\n",
"1022\n",
"2046\n"
] |
CodeContests | Chef likes strings a lot but moreover he likes good strings. Chef calls a string str a good string if str starts and ends at different characters. For eg : strings such as abab , baccba , abc are all good strings whereas strings like aba, baab , baacaab are not good at all .
Today, Chef has a special string P consistin... | stdin | null | 4,135 | 1 | [
"checfcheff\n5\nc h 1 10\nc f 1 10\ne c 1 10\nc f 1 5\nc f 6 10\n"
] | [
"4\n8\n2\n2\n2\n"
] | [
"checfcheff\n5\nc h 1 10\nc f 1 7\ne c 1 10\nc f 1 5\nc f 6 10\n",
"checfcheff\n5\nc h 1 10\nc f 1 10\ne c 1 10\nc f 1 7\nc f 6 10\n",
"checfcheff\n1\nc h 1 10\nc f 1 7\ne c 1 10\nc f 1 5\nc f 6 10\n",
"checfcheff\n5\nc h 0 10\nc f 1 10\ne c 1 10\nc f 1 7\nc f 6 10\n",
"checfcheff\n5\nc h 1 10\nc f 1 7\ne c... | [
"4\n2\n2\n2\n2\n",
"4\n8\n2\n2\n2\n",
"4\n",
"0\n8\n2\n2\n2\n",
"4\n2\n0\n2\n2\n",
"4\n8\n1\n2\n2\n",
"0\n8\n2\n2\n0\n",
"4\n5\n1\n2\n2\n",
"0\n8\n1\n2\n0\n",
"4\n2\n"
] |
CodeContests | You are given positions (X_i, Y_i) of N enemy rooks on an infinite chessboard. No two rooks attack each other (at most one rook per row or column).
You're going to replace one rook with a king and then move the king repeatedly to beat as many rooks as possible.
You can't enter a cell that is being attacked by a rook.... | stdin | null | 2,598 | 1 | [
"6\n1 8\n6 10\n2 7\n4 4\n9 3\n5 1\n",
"5\n5 5\n100 100\n70 20\n81 70\n800 1\n",
"10\n2 5\n4 4\n13 12\n12 13\n14 17\n17 19\n22 22\n16 18\n19 27\n25 26\n"
] | [
"5\n0\n7\n5\n0\n0\n",
"985\n985\n1065\n1034\n0\n",
"2\n2\n9\n9\n3\n3\n24\n5\n0\n25\n"
] | [
"6\n1 0\n6 10\n2 7\n4 4\n9 3\n5 1\n",
"5\n5 5\n100 100\n70 21\n81 70\n800 1\n",
"6\n1 0\n6 10\n2 7\n4 6\n9 3\n5 1\n",
"5\n5 5\n100 100\n70 20\n81 36\n800 1\n",
"6\n1 0\n6 10\n0 7\n4 4\n9 3\n5 1\n",
"5\n5 5\n100 100\n70 21\n31 70\n800 1\n",
"5\n5 5\n100 100\n70 20\n81 36\n21 1\n",
"5\n5 5\n100 100\n46 ... | [
"0\n0\n4\n4\n0\n0\n",
"985\n985\n1066\n1034\n0\n",
"0\n0\n2\n2\n0\n0\n",
"985\n985\n1065\n1068\n0\n",
"0\n0\n0\n0\n0\n0\n",
"0\n0\n1164\n1154\n0\n",
"194\n108\n108\n135\n206\n",
"0\n0\n1140\n1106\n0\n",
"192\n108\n108\n135\n206\n",
"0\n0\n1148\n1122\n0\n"
] |
CodeContests | Joisino has a lot of red and blue bricks and a large box. She will build a tower of these bricks in the following manner.
First, she will pick a total of N bricks and put them into the box. Here, there may be any number of bricks of each color in the box, as long as there are N bricks in total. Particularly, there may... | stdin | null | 2,606 | 1 | [
"1000 3000\n",
"1000 10\n",
"2 3\n"
] | [
"693347555\n",
"1048576\n",
"56\n"
] | [
"1100 3000\n",
"1001 10\n",
"2 4\n",
"1001 7\n",
"2 8\n",
"2 12\n",
"3 12\n",
"0 12\n",
"2 2\n",
"1001 1\n"
] | [
"422834785\n",
"1048576\n",
"184\n",
"16384\n",
"16984\n",
"1408984\n",
"7148840\n",
"0\n",
"16\n",
"4\n"
] |
CodeContests | Bouldering is a style of rock climbing. Boulderers are to climb up the rock with bare hands without supporting ropes. Your friend supposed that it should be interesting and exciting, so he decided to come to bouldering gymnasium to practice bouldering. Since your friend has not tried bouldering yet, he chose beginner’s... | stdin | null | 4,873 | 1 | [
"7\n4 2 4\n11 18\n14 18\n10 14\n13 14\n14 17\n17 21\n16 26\n",
"6\n2 3 3\n11 22\n12 20\n10 15\n11 17\n13 23\n16 22\n",
"6\n2 2 4\n12 22\n13 21\n14 15\n10 16\n16 24\n10 35\n",
"6\n4 3 3\n10 17\n15 14\n10 15\n11 12\n16 18\n15 22\n"
] | [
"3\n",
"-1\n",
"-1\n",
"3\n"
] | [
"7\n2 2 4\n11 18\n14 18\n10 14\n13 14\n14 17\n17 21\n16 26\n",
"6\n2 3 3\n11 22\n12 20\n10 15\n10 17\n13 23\n11 22\n",
"6\n2 6 3\n11 22\n12 20\n10 27\n10 17\n13 23\n3 22\n",
"6\n2 3 3\n11 22\n12 20\n10 15\n10 17\n13 23\n16 22\n",
"6\n2 2 4\n12 22\n13 21\n14 15\n10 21\n16 24\n10 35\n",
"6\n4 3 3\n10 17\n15... | [
"-1\n",
"1\n",
"2\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n"
] |
CodeContests | Problem Statement
One day Chef is waiting his girlfriend on the bus station. The girlfriend said that she will be at time1. Chef went to the bus station at time2. When Chef has reached the bus station he realized that he forgot a gift for his better half in his home.
Chef knows that someone can reach his home in dist m... | stdin | null | 1,708 | 1 | [
"3\n10:00\n09:00\n10\n10:00\n09:00\n30\n10:00\n09:00\n60\n"
] | [
"70.0 60.0\n90.0 60.0\n120.0 90.0\n"
] | [
"3\n10:00\n09:00\n10\n10:00\n09:00\n30\n10:00\n09:00\n12\n",
"3\n10:00\n09:00\n10\n10:00\n09:00\n48\n10:00\n09:00\n60\n",
"3\n10:01\n09:00\n10\n10:00\n09:00\n48\n10:00\n09:00\n60\n",
"3\n10:00\n09:00\n10\n10:00\n08:00\n48\n10:00\n09:00\n60\n",
"3\n10:00\n09:00\n11\n10:00\n08:00\n48\n10:00\n09:00\n60\n",
"... | [
"70.0 60.0\n90.0 60.0\n72.0 60.0\n",
"70.0 60.0\n108.0 78.0\n120.0 90.0\n",
"71.0 61.0\n108.0 78.0\n120.0 90.0\n",
"70.0 60.0\n168.0 120.0\n120.0 90.0\n",
"71.0 60.0\n168.0 120.0\n120.0 90.0\n",
"71.0 60.0\n133.0 120.0\n120.0 90.0\n",
"70.0 60.0\n90.0 60.0\n720.0 660.0\n",
"66.0 60.0\n108.0 78.0\n120.... |
CodeContests | <!--
Problem E
-->
Cube Surface Puzzle
Given a set of six pieces, "Cube Surface Puzzle" is to construct a hollow cube with filled surface. Pieces of a puzzle is made of a number of small unit cubes laid grid-aligned on a plane. For a puzzle constructing a cube of its side length n, unit cubes are on either of the f... | stdin | null | 3,130 | 1 | [
"5\n..XX.\n.XXX.\nXXXXX\nXXXXX\nX....\n....X\nXXXXX\n.XXX.\n.XXX.\n.....\n..XXX\nXXXX.\n.XXXX\n.XXXX\n...X.\n...X.\n.XXXX\nXXXX.\nXXXX.\n.X.X.\nXXX.X\n.XXXX\nXXXXX\n.XXXX\n.XXXX\nXX...\n.XXXX\nXXXXX\nXXXXX\nXX...\n5\n..XX.\n.XXX.\nXXXXX\nXXXX.\nX....\n....X\nXXXXX\n.XXX.\n.XXX.\n.....\n.XXXX\nXXXX.\n.XXXX\n.XXXX\n.... | [
"Yes\nNo\n"
] | [
"5\n..XX.\n.XXX.\nXXXXX\nXXXXX\nX....\n....X\nXXXXX\n.XXX.\n.XXX.\n.....\n..XXX\nXXXX.\n.XXXX\n.XXXX\n...X.\n...X.\n.XXXX\nXXXX.\nXXXX.\n.X.X.\nXXX.X\n.XXXX\nXXXXX\n.XXXX\n.XXXX\n...XX\n.XXXX\nXXXXX\nXXXXX\nXX...\n5\n..XX.\n.XXX.\nXXXXX\nXXXX.\nX....\n....X\nXXXXX\n.XXX.\n.XXX.\n.....\n.XXXX\nXXXX.\n.XXXX\n.XXXX\n.... | [
"No\nNo\n",
"No\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 | There are two persons, numbered 0 and 1, and a variable x whose initial value is 0. The two persons now play a game. The game is played in N rounds. The following should be done in the i-th round (1 \leq i \leq N):
* Person S_i does one of the following:
* Replace x with x \oplus A_i, where \oplus represents bitwise X... | stdin | null | 4,068 | 1 | [
"3\n2\n1 2\n10\n2\n1 1\n10\n6\n2 3 4 5 6 7\n111000\n"
] | [
"1\n0\n0\n"
] | [
"3\n2\n1 2\n10\n2\n1 1\n10\n6\n2 3 4 9 6 7\n111000\n",
"3\n2\n0 2\n10\n2\n1 1\n10\n6\n2 3 4 9 6 7\n111000\n",
"3\n2\n1 2\n10\n2\n1 2\n10\n6\n2 3 1 9 6 7\n111000\n",
"3\n2\n1 2\n14\n0\n2 0\n10\n6\n2 3 5 9 7 7\n111000\n",
"3\n2\n0 2\n10\n2\n1 2\n10\n6\n2 3 1 9 2 7\n111000\n",
"3\n2\n1 2\n10\n2\n1 4\n10\n6\n... | [
"1\n0\n1\n",
"0\n0\n1\n",
"1\n1\n1\n",
"1\n0\n0\n",
"0\n1\n1\n",
"1\n1\n0\n",
"0\n0\n0\n",
"0\n1\n0\n",
"1\n0\n1\n",
"1\n0\n1\n"
] |
CodeContests | D --Disciple Life is Hard / Disciple is hard
Story
The person in D loves donuts. I always want donuts. However, D, who was ordered by his master, Bunashimejitan, to train himself, must limit his calorie intake. Therefore, D person decided to eat donuts up to the calories burned by the training that day, considering t... | stdin | null | 628 | 1 | [
"10 1 1 1 4 3\n6 10\n5 8\n"
] | [
"15\n"
] | [
"17 1 1 1 4 3\n6 10\n5 8\n",
"8 1 1 1 4 3\n6 14\n5 8\n",
"17 1 1 1 4 3\n6 10\n4 8\n",
"17 1 1 1 4 3\n6 14\n5 4\n",
"17 1 1 1 4 3\n6 10\n4 4\n",
"17 1 1 1 4 3\n6 14\n10 4\n",
"22 1 1 1 4 6\n6 14\n5 8\n",
"30 1 1 1 4 5\n6 14\n5 8\n",
"17 1 1 1 4 6\n6 10\n7 8\n",
"17 1 1 1 4 1\n6 10\n5 8\n"
] | [
"15\n",
"-1\n",
"12\n",
"45\n",
"24\n",
"90\n",
"30\n",
"25\n",
"42\n",
"5\n"
] |
CodeContests | Problem
One day, Kawabayashi is about to have lunch at the school cafeteria. There are three types of daily lunch menus for school cafeterias: A lunch, B lunch, and C lunch.
Kawabayashi is a glutton, so I would like to eat all three types of daily lunch menus one by one.
However, Kawabayashi decided to put up with one... | stdin | null | 3,414 | 1 | [
"1000 800 1200\n",
"1000 900 850\n"
] | [
"C\n",
"A\n"
] | [
"1000 800 1040\n",
"1000 900 239\n",
"1000 1135 850\n",
"1000 800 838\n",
"1000 279 239\n",
"1000 316 838\n",
"1100 279 239\n",
"1001 316 838\n",
"1100 279 393\n",
"1001 316 1343\n"
] | [
"C\n",
"A\n",
"B\n",
"A\n",
"A\n",
"A\n",
"A\n",
"A\n",
"A\n",
"C\n"
] |
CodeContests | On the eve of Teddy Day Chotu decided to buy a teddy for his girlfriend Choti. He has N coins each having distinct value from 1 to N. Now after collecting all the coins he went to buy a Teddy.
Now the shopkeeper Motu told Chotu that there is only one Teddy in the shop of Value K. As Chotu is very bhondu(idiot) he won... | stdin | null | 834 | 1 | [
"2\n5 8\n4 20\n\nSAMPLE\n"
] | [
"YES\nNO\n"
] | [
"100\n234256 27438053907\n2401 2883697\n28561 407879623\n3111696 4841327554080\n59969536 1798172654012450\n130321 8491846764\n59969536 1798172654012364\n20151121 203033848853807\n20736 215001267\n37015056 685057203849078\n160000 12800080007\n59969536 1798172654012491\n7890481 31129849150946\n96059601 46137235201694... | [
"NO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nNO\nYES\nNO\nNO\nNO\nNO\nYES\nYES\nNO\nNO\nYES\nYES\nYES\nNO\nNO\nNO\nYES\nYES\nNO\nNO\nYES\nNO\nNO\nYES\nNO\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nYES\nNO\nYES\nNO\nYES\nNO\nYES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nYES\nYES\nNO\nYES\nNO\nYES\nNO\nNO\nYES\nYES\nNO\nNO\nNO... |
CodeContests | N coders decided to go for a trip for the upcoming weekend. They chose Crater Lake National Park in Oregon, USA as their destination, because they all like to take a lot of photos and the beautiful nature gives them a chance to do so.
In order to capture some memories from the trip, they wanted to take the greatest nu... | stdin | null | 3,186 | 1 | [
"1\n3 1\n1 2\n\nSAMPLE\n"
] | [
"5\n"
] | [
"1\n5 1\n1 2\n\nSAMPLE\n",
"1\n5 0\n1 4\n\nSAMPLE\n",
"1\n8 1\n1 3\n\nSAMPLE\n",
"1\n9 0\n1 4\n\nSAMPLE\n",
"1\n16 0\n1 4\n\nSAMPLE\n",
"1\n15 0\n1 6\n\nSAMPKE\n",
"1\n4 0\n0 17\n\nSAEPLM\n",
"1\n8 0\n0 17\n\nSAEPLM\n",
"1\n2 0\n1 5\n\nSANPLE\n",
"1\n3 0\n2 10\n\nSANPLE\n"
] | [
"23\n",
"31\n",
"191\n",
"511\n",
"65535\n",
"32767\n",
"15\n",
"255\n",
"3\n",
"7\n"
] |
CodeContests | An infinite army of ants is marching on an infinite 2-D plane. Since ants are disciplined, here's how they march: each ant chooses exactly one x coordinate and moves along it in positive y direction, starting from (x, 0). There exists exactly one ant for each x coordinate on that plane and hence there are infinite ants... | stdin | null | 1,959 | 1 | [
"2\n1 1 4\n7 3 5\n\nSAMPLE\n"
] | [
"11\n"
] | [
"2\n1 1 4\n7 4 5\n",
"2\n1 1 4\n6 2 0\n\nSAMPLE\n",
"2\n1 0 4\n6 1 1\n\nELOMAS\n",
"2\n1 1 4\n6 2 -1\n\nSAMPLE\n",
"2\n1 1 1\n6 1 0\n\nSAMPLE\n",
"2\n1 0 1\n6 1 1\n\nELOMAS\n",
"2\n1 1 8\n6 2 1\n\nELOMAS\n",
"2\n1 1 4\n6 -1 2\n\nELOLAS\n",
"2\n2 1 1\n6 1 -1\n\nSAMPLD\n",
"2\n2 1 0\n6 1 -1\n\nSAMPL... | [
"11\n",
"6\n",
"7\n",
"5\n",
"3\n",
"4\n",
"9\n",
"8\n",
"2\n",
"1\n"
] |
CodeContests | Problem
The great devil Sacagna was still attacked by her natural enemy cat today.
I bought a secret weapon because I couldn't do it all the time.
This secret weapon can block the cat's path of movement by creating huge rocks that keep cats away from you.
Now, Sacagna and one cat are in a rectangular closed section ... | stdin | null | 1,305 | 1 | [
"5 5 3\n0 2\n2 2\n4 1\n",
"3 5 2\n0 2\n2 2\n"
] | [
"2\n",
"1\n"
] | [
"3 5 2\n1 2\n2 2\n",
"3 5 2\n0 2\n0 2\n",
"1 5 1\n0 2\n2 0\n",
"3 5 2\n0 2\n2 0\n",
"3 5 2\n2 2\n2 2\n",
"5 5 3\n0 2\n2 2\n4 0\n",
"3 5 0\n1 2\n2 2\n",
"3 5 2\n0 3\n2 0\n",
"3 5 1\n2 2\n2 2\n",
"3 5 0\n1 2\n0 2\n"
] | [
"1\n",
"2\n",
"0\n",
"1\n",
"2\n",
"2\n",
"2\n",
"2\n",
"2\n",
"2\n"
] |
CodeContests | N problems are proposed for an upcoming contest. Problem i has an initial integer score of A_i points.
M judges are about to vote for problems they like. Each judge will choose exactly V problems, independently from the other judges, and increase the score of each chosen problem by 1.
After all M judges cast their vo... | stdin | null | 2,283 | 1 | [
"6 1 2 2\n2 1 1 3 0 2\n",
"10 4 8 5\n7 2 3 6 1 6 5 4 6 5\n",
"6 1 5 2\n2 1 1 3 0 2\n"
] | [
"5\n",
"8\n",
"3\n"
] | [
"6 1 2 2\n2 1 1 5 0 2\n",
"10 4 8 5\n7 2 3 4 1 6 5 4 6 5\n",
"6 1 5 2\n2 1 1 3 1 2\n",
"6 1 2 2\n2 1 1 5 0 0\n",
"10 4 8 5\n7 2 6 4 1 6 5 4 6 5\n",
"6 1 2 4\n2 1 1 5 0 0\n",
"10 4 5 5\n7 2 6 4 1 6 5 4 6 5\n",
"6 1 5 1\n3 1 1 3 0 2\n",
"6 1 2 1\n1 1 1 5 0 2\n",
"10 1 1 5\n7 2 3 4 1 6 4 3 9 0\n"
] | [
"5\n",
"9\n",
"3\n",
"4\n",
"8\n",
"6\n",
"10\n",
"2\n",
"1\n",
"7\n"
] |
CodeContests | One day Alice was experimenting with the numbers to make new algorithms. He introduce a new term Rsum.
Rsum of any number is defined as number obtained by iterative summing of digits of the given number until single digit number is obtained.
For example:
365 --> (3+6+5) = 14
14 --> 1+4 = 5
Rsum(365)=5
Naughty... | stdin | null | 206 | 1 | [
"2\n1 3\n3 4\n\nSAMPLE\n"
] | [
"9\n12\n"
] | [
"2\n1 3\n3 4\n\nSAMPLF\n",
"2\n1 3\n4 4\n\nSAMPLF\n",
"2\n1 2\n3 4\n\nSAMPLE\n",
"2\n0 3\n2 4\n\nSAMPLF\n",
"2\n1 0\n3 4\n\nSAMPLE\n",
"2\n0 3\n0 4\n\nSAMPLF\n",
"2\n0 5\n0 4\n\nSAMPLF\n",
"2\n1 0\n1 4\n\nSAMPME\n",
"2\n0 1\n1 4\n\nSAMPLF\n",
"2\n0 1\n2 4\n\nSAMPKF\n"
] | [
"9\n12\n",
"9\n6\n",
"3\n12\n",
"9\n14\n",
"0\n12\n",
"9\n15\n",
"18\n15\n",
"0\n15\n",
"1\n15\n",
"1\n14\n"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.