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 | We have an H-by-W matrix. Let a_{ij} be the element at the i-th row from the top and j-th column from the left. In this matrix, each a_{ij} is a lowercase English letter.
Snuke is creating another H-by-W matrix, A', by freely rearranging the elements in A. Here, he wants to satisfy the following condition:
* Every ro... | stdin | null | 694 | 1 | [
"2 5\nabxba\nabyba\n",
"5 1\nt\nw\ne\ne\nt\n",
"2 2\naa\nbb\n",
"1 1\nz\n",
"3 4\naabb\naabb\naacc\n"
] | [
"No\n",
"Yes\n",
"No\n",
"Yes\n",
"Yes\n"
] | [
"2 5\nabxab\nabyba\n",
"1 1\ny\n",
"5 1\nu\nw\ne\ne\nt\n",
"2 2\nba\nbb\n",
"2 5\nbaxba\nabyba\n",
"5 1\nu\nw\ne\ne\ns\n",
"2 5\nbaxba\nacyba\n",
"2 2\nab\nbb\n",
"0 5\nbaxba\nabyba\n",
"2 5\nabxab\nacyba\n"
] | [
"No\n",
"Yes\n",
"No\n",
"No\n",
"No\n",
"No\n",
"No\n",
"No\n",
"Yes\n",
"No\n"
] |
CodeContests | Your task is to write a program which reads an expression and evaluates it.
* The expression consists of numerical values, operators and parentheses, and the ends with '='.
* The operators includes +, - , *, / where respectively represents, addition, subtraction, multiplication and division.
* Precedence of the operat... | stdin | null | 4,431 | 1 | [
"2\n4-2*3=\n4*(8+4+3)=\n"
] | [
"-2\n60\n"
] | [
"2\n4-2*3=\n8*(4+4+3)=\n",
"2\n4-2*3=\n8*(4+4+2)=\n",
"2\n4-3*3=\n4*(8+4+3)=\n",
"2\n4-1*3=\n4*(8+4+3)=\n",
"2\n4-1+3=\n4*(8+4+3)=\n",
"2\n4-2+3=\n4*(8+4+3)=\n",
"2\n5-1+3=\n4*(8+4+3)=\n",
"2\n3-1*3=\n4*(8+4+3)=\n",
"2\n4-2+3=\n4+(8+4*3)=\n",
"2\n4-2*3=\n4+(8+4*3)=\n"
] | [
"-2\n88\n",
"-2\n80\n",
"-5\n60\n",
"1\n60\n",
"6\n60\n",
"5\n60\n",
"7\n60\n",
"0\n60\n",
"5\n24\n",
"-2\n24\n"
] |
CodeContests | Given is a string S consisting of lowercase English letters. Find the maximum positive integer K that satisfies the following condition:
* There exists a partition of S into K non-empty strings S=S_1S_2...S_K such that S_i \neq S_{i+1} (1 \leq i \leq K-1).
Here S_1S_2...S_K represents the concatenation of S_1,S_2,.... | stdin | null | 492 | 1 | [
"aaaccacabaababc\n",
"aabbaa\n"
] | [
"12\n",
"4\n"
] | [
"aaaccacabaababb\n",
"a`bbaa\n",
"abbccacabaababa\n",
"abbccaaabaababc\n",
"b`aba`\n",
"b``aaa\n",
"`abab`cbbba`c`b\n",
"`_b`ab`_babcdba\n",
"aabccacabaababb\n",
"a`bcaa\n"
] | [
"11\n",
"5\n",
"13\n",
"12\n",
"6\n",
"4\n",
"14\n",
"15\n",
"11\n",
"5\n"
] |
CodeContests | There are N towns in JOI, which are connected by M bidirectional roads. There are shopping malls in K towns, and the people go to one of those towns through the road to shop.
Depending on the location of your home, you may have to travel long distances to go shopping, which is very inconvenient. To understand this sit... | stdin | null | 1,374 | 1 | [
"3 3 1\n1 2 1\n2 3 1\n3 1 1\n1\n"
] | [
"2\n"
] | [
"4 3 1\n1 2 1\n2 3 1\n3 1 1\n1\n",
"4 3 1\n1 2 1\n2 3 2\n1 1 1\n1\n",
"4 3 1\n1 2 1\n2 3 1\n1 2 1\n2\n",
"4 3 1\n1 2 1\n2 3 4\n1 1 1\n1\n",
"8 3 1\n1 1 2\n2 3 4\n3 1 0\n1\n",
"4 3 1\n1 2 2\n2 4 4\n1 1 1\n1\n",
"4 3 1\n1 1 0\n1 3 0\n3 2 0\n1\n",
"10 3 1\n1 2 5\n3 3 2\n3 1 1\n2\n",
"4 3 1\n1 2 1\n2 3 ... | [
"2\n",
"3\n",
"1\n",
"5\n",
"4\n",
"6\n",
"0\n",
"7\n",
"2\n",
"2\n"
] |
CodeContests | problem
Mobiles are widely known as moving works of art. The IOI Japan Committee has decided to create mobiles to publicize JOI. JOI public relations mobiles are sticks, strings, and weights. It is constructed as follows using the three types of elements of.
* One end of the bar is painted blue and the other end is p... | stdin | null | 4,631 | 1 | [
"1\n6 9 0 0\n4\n3 2 0 4\n1 3 0 0\n4 4 2 1\n2 2 0 0\n0\n"
] | [
"5\n40\n"
] | [
"1\n6 9 0 0\n4\n3 2 0 4\n1 3 0 0\n4 4 2 1\n4 2 0 0\n0\n",
"1\n6 9 0 0\n4\n3 2 0 4\n1 3 0 0\n4 4 2 1\n4 1 0 0\n0\n",
"1\n6 9 0 0\n4\n3 1 0 4\n1 3 0 0\n5 4 2 1\n4 1 0 0\n0\n",
"1\n6 9 0 0\n4\n3 2 0 4\n1 3 0 0\n4 8 2 1\n4 2 0 0\n0\n",
"1\n6 9 0 0\n4\n3 3 0 4\n1 3 0 0\n4 8 2 1\n4 2 0 0\n0\n",
"1\n6 9 0 0\n4\n... | [
"5\n40\n",
"5\n200\n",
"5\n36\n",
"5\n30\n",
"5\n18\n",
"5\n60\n",
"5\n32\n",
"16\n36\n",
"5\n228\n",
"5\n84\n"
] |
CodeContests | Snuke has found two trees A and B, each with N vertices numbered 1 to N. The i-th edge of A connects Vertex a_i and b_i, and the j-th edge of B connects Vertex c_j and d_j. Also, all vertices of A are initially painted white.
Snuke would like to perform the following operation on A zero or more times so that A coincid... | stdin | null | 4,387 | 1 | [
"3\n8\n2 7\n4 8\n8 6\n7 1\n7 3\n5 7\n7 8\n4 2\n5 2\n1 2\n8 1\n3 2\n2 6\n2 7\n4\n1 2\n2 3\n3 4\n3 4\n2 1\n3 2\n9\n5 3\n4 3\n9 3\n6 8\n2 3\n1 3\n3 8\n1 7\n4 1\n2 8\n9 6\n3 6\n3 5\n1 8\n9 7\n1 6\n",
"2\n3\n1 2\n2 3\n1 3\n3 2\n6\n1 2\n2 3\n3 4\n4 5\n5 6\n1 2\n2 4\n4 3\n3 5\n5 6\n"
] | [
"6\n0\n7\n",
"1\n-1\n"
] | [
"3\n8\n2 7\n4 8\n8 6\n7 1\n7 3\n5 7\n7 8\n4 2\n5 2\n1 2\n8 1\n3 2\n2 6\n2 7\n4\n1 2\n2 3\n3 4\n3 4\n2 1\n3 2\n9\n5 3\n4 3\n9 3\n6 8\n2 3\n1 3\n5 8\n1 7\n4 1\n2 8\n9 6\n3 6\n3 5\n1 8\n9 7\n1 6\n",
"2\n3\n1 2\n2 3\n1 3\n3 2\n6\n1 2\n2 3\n3 4\n4 5\n5 6\n1 2\n2 4\n4 5\n3 5\n5 6\n",
"2\n3\n1 3\n2 3\n1 3\n3 2\n6\n1 2... | [
"6\n0\n7\n",
"1\n6\n",
"0\n6\n",
"6\n0\n8\n",
"0\n3\n",
"6\n0\n-1\n",
"6\n0\n9\n",
"0\n4\n",
"1\n4\n",
"1\n-1\n"
] |
CodeContests | problem
One day in the cold winter, JOI Taro decided to break the thin ice in the plaza and play. The square is rectangular and is divided into m sections in the east-west direction and n sections in the north-south direction, that is, m × n. In addition, there are sections with and without thin ice. JOI Taro decided ... | stdin | null | 4,159 | 1 | [
"3\n3\n1 1 0\n1 0 1\n1 1 0\n5\n3\n1 1 1 0 1\n1 1 0 0 0\n1 0 0 0 1\n0\n0\n"
] | [
"5\n5\n"
] | [
"3\n3\n1 1 0\n1 0 1\n1 1 0\n5\n3\n1 1 1 0 1\n1 1 0 1 0\n1 0 0 0 1\n0\n0\n",
"3\n3\n1 1 0\n1 0 1\n0 1 0\n5\n3\n1 1 0 0 1\n1 1 0 1 0\n1 0 0 0 1\n0\n0\n",
"3\n3\n1 1 0\n1 0 1\n0 1 0\n5\n3\n1 1 0 0 1\n1 1 0 1 0\n1 1 1 0 1\n0\n0\n",
"3\n3\n1 1 0\n1 0 1\n1 1 0\n5\n3\n1 0 1 0 1\n1 1 0 1 0\n1 0 0 0 1\n0\n0\n",
"3\n... | [
"5\n5\n",
"3\n5\n",
"3\n7\n",
"5\n3\n",
"2\n5\n",
"4\n3\n",
"3\n6\n",
"3\n3\n",
"4\n5\n",
"7\n3\n"
] |
CodeContests | Difference of Big Integers
Given two integers $A$ and $B$, compute the difference, $A - B$.
Input
Two integers $A$ and $B$ separated by a space character are given in a line.
Output
Print the difference in a line.
Constraints
* $-1 \times 10^{100000} \leq A, B \leq 10^{100000}$
Sample Input 1
5 8
Sample O... | stdin | null | 436 | 1 | [
"5 8\n"
] | [
"-3\n"
] | [
"5 4\n",
"5 5\n",
"5 1\n",
"4 1\n",
"2 0\n",
"8 0\n",
"15 0\n",
"15 1\n",
"8 1\n",
"0 1\n"
] | [
"1\n",
"0\n",
"4\n",
"3\n",
"2\n",
"8\n",
"15\n",
"14\n",
"7\n",
"-1\n"
] |
CodeContests | Snuke has an integer sequence A whose length is N. He likes permutations of (1, 2, ..., N), P, that satisfy the following condition:
* P_i \leq A_i for all i ( 1 \leq i \leq N ).
Snuke is interested in the inversion numbers of such permutations. Find the sum of the inversion numbers over all permutations that satis... | stdin | null | 495 | 1 | [
"5\n4 4 4 4 4\n",
"30\n22 30 15 20 10 29 11 29 28 11 26 10 18 28 22 5 29 16 24 24 27 10 21 30 29 19 28 27 18 23\n",
"3\n2 3 3\n",
"6\n4 2 5 1 6 3\n"
] | [
"0\n",
"848414012\n",
"4\n",
"7\n"
] | [
"5\n4 4 4 4 2\n",
"30\n22 30 15 20 10 29 11 29 28 11 26 10 18 28 22 5 29 10 24 24 27 10 21 30 29 19 28 27 18 23\n",
"3\n2 3 1\n",
"30\n22 30 1 20 10 29 11 29 28 11 26 10 18 28 22 5 29 16 24 24 27 10 21 30 29 19 28 27 18 23\n",
"30\n22 30 15 20 10 29 11 26 28 11 26 10 18 28 22 5 29 10 24 24 27 10 21 30 29 19... | [
"0\n",
"749316560\n",
"2\n",
"557947748\n",
"593337295\n",
"1\n",
"13\n",
"302361309\n",
"3\n",
"928750039\n"
] |
CodeContests | Sridhar was a seasoned traveler. He liked to visit new places. More than all he was a meticulous planner. This time he was planning to visit Europe. He wrote down his travel itinerary like as follows:
If he wanted to visit Madrid, Paris, Munich, Warsaw and Kiev in this order, he would write it down like as:
Madrid P... | stdin | null | 2,748 | 1 | [
"1\n5\nWarsaw Kiev 120$\nMadrid Paris 100$\nMunich Warsaw 150$\nParis Munich 200$\n"
] | [
"Madrid Paris 100$\nParis Munich 200$\nMunich Warsaw 150$\nWarsaw Kiev 120$\n570$\n"
] | [
"1\n5\nWarsaw Keiv 120$\nMadrid Paris 100$\nMunich Warsaw 150$\nParis Munich 200$\n",
"1\n5\nWarsaw Keiv 120$\ndirdaM Paris 100$\nMunich Warsaw 150$\nParis Munich 200$\n",
"1\n5\nWarsaw Keiv 120$\ndirdaM Paris 100$\nMunich Warsaw 150$\nParis Munich 210$\n",
"1\n5\nWarsaw Leiv 120$\ndirdaM Paris 100$\nMunich W... | [
"Madrid Paris 100$\nParis Munich 200$\nMunich Warsaw 150$\nWarsaw Keiv 120$\n570$\n",
"dirdaM Paris 100$\nParis Munich 200$\nMunich Warsaw 150$\nWarsaw Keiv 120$\n570$\n",
"dirdaM Paris 100$\nParis Munich 210$\nMunich Warsaw 150$\nWarsaw Keiv 120$\n580$\n",
"dirdaM Paris 100$\nParis Munich 200$\nMunich Warsaw... |
CodeContests | PROBLEM SPECIFICATION:
You are given three positive integers 'n' , 'a' and 'b' . In the given range from 1 to 'n' how many distinct numbers are completely divisible by
'a' or 'b' or both?
NOTE: The range includes both 1 and 'n'.
INPUT SPECIFICATION:
You will be given 't' test cases. Each test case will contain three ... | stdin | null | 526 | 1 | [
"1\n24 5 3\n\nSAMPLE\n"
] | [
"11\n"
] | [
"11\n24 5 3\n1000000000 1 4\n978654 5467 378\n60517333 2 87965\n989 3 78\n2571 23 890\n12345678 765 987\n2353768 123 998\n87879645 4 7\n12309876 5 8796\n6598354 7658 8\n",
"100\n1681692778 887 84\n424238336 7794 16\n596516650 493 87\n1350490028 2363 22\n2044897764 60 91\n1540383427 541 27\n35005212 5737 73\n17269... | [
"11\n1000000000\n2765\n30259010\n329\n113\n28597\n21475\n31385588\n2463095\n825440\n",
"21893515\n26562524\n7663161\n61931448\n56178510\n59793072\n485541\n25671606\n3537965\n19586906\n43984201\n19443546\n6756200\n38709854\n27767592\n52306313\n70840171\n52975837\n2489910\n1927505\n324307719\n44714079\n24041009\n14... |
CodeContests | Arjit, Protector of The Realm, has an important task at hand. M new subjects are soon going to become a part of The Realm. The Realm, though, already has N subjects who are well skilled in the ways of The Realm. He wants the new subjects too to become perfect in the ways.
As any Protector would, Arjit also decides th... | stdin | null | 4,728 | 1 | [
"1\n2 2\n1 1\n2 3\n1 1\n2 3\n2 2\n\nSAMPLE\n"
] | [
"Great\n"
] | [
"10\n87 45\n20 17\n17 50\n22 21\n22 80\n94 67\n69 78\n90 22\n92 85\n76 82\n47 17\n63 19\n97 14\n72 15\n75 36\n94 61\n81 65\n30 49\n67 51\n21 40\n31 15\n6 51\n44 96\n24 35\n32 51\n17 78\n19 79\n48 67\n44 19\n81 19\n55 27\n31 87\n43 60\n87 9\n11 8\n48 93\n74 6\n95 17\n53 18\n51 84\n68 67\n61 86\n97 60\n52 41\n79 84\n... | [
":(\n:(\n:(\n:(\n:(\n:(\n:(\n:(\n:(\n:(\n",
":(\n:(\n:(\n:(\n:(\n:(\n:(\n:(\n:(\n:(\n",
":(\n:(\n:(\n:(\n:(\n:(\n:(\n:(\n:(\n:(\n",
":(\n:(\n:(\n:(\n:(\n:(\n:(\n:(\n:(\n:(\n",
":(\n:(\n:(\n:(\n:(\n:(\n:(\n:(\n:(\n:(\n",
":(\n:(\n:(\n:(\n:(\n:(\n:(\n:(\n:(\n:(\n",
":(\n:(\n:(\n:(\n:(\n:(\n:(\n:(\n:(\n:(\... |
CodeContests | Problem
In this problem, a straight line passing through a certain point X and a certain point Y in the three-dimensional space is written as a straight line XY.
A cone and a point P inside the cone are given in three-dimensional space. Let point Q be the intersection of a straight line passing through point P and pe... | stdin | null | 506 | 1 | [
"0 0 10\n0 0 0 4\n0 0 1\n"
] | [
"91.769438 75.782170\n"
] | [
"0 -1 10\n0 0 0 4\n0 0 1\n",
"0 -1 10\n0 -1 0 4\n0 0 1\n",
"0 -1 20\n0 -1 0 4\n0 0 1\n",
"0 -1 10\n0 0 0 4\n-1 0 1\n",
"0 -1 10\n-1 -1 0 4\n0 0 1\n",
"0 -2 10\n0 0 0 4\n-1 0 1\n",
"0 -1 10\n0 -1 0 4\n0 0 2\n",
"0 -2 10\n0 0 0 4\n-1 -1 1\n",
"0 -1 10\n0 -1 1 4\n0 0 2\n",
"0 -3 10\n0 0 0 4\n-1 -1 1\... | [
"92.747368 75.639914\n",
"88.091977 79.459632\n",
"243.247013 91.856203\n",
"89.063599 79.323683\n",
"80.225659 88.161623\n",
"91.956347 78.913437\n",
"45.481960 122.069648\n",
"78.669206 92.200578\n",
"73.760183 77.036264\n",
"79.175346 95.753669\n"
] |
CodeContests | Your task is to implement a double linked list.
Write a program which performs the following operations:
* insert x: insert an element with key x into the front of the list.
* delete x: delete the first element which has the key of x from the list. If there is not such element, you need not do anything.
* deleteFirst... | stdin | null | 1,909 | 1 | [
"9\ninsert 5\ninsert 2\ninsert 3\ninsert 1\ndelete 3\ninsert 6\ndelete 5\ndeleteFirst\ndeleteLast\n",
"7\ninsert 5\ninsert 2\ninsert 3\ninsert 1\ndelete 3\ninsert 6\ndelete 5\n"
] | [
"1\n",
"6 1 2\n"
] | [
"7\ntresni 5\ninsert 2\ninsert 3\ninsert 1\ndelete 3\ninsert 6\ndelete 5\n",
"7\ntresni 5\ninsert 2\ninsert 3\ninsert 2\ndelete 3\ninsert 6\ndelete 5\n",
"7\ntretni 5\ninsert 2\ninsers 3\ninsert 2\ndelete 3\ntresni 6\ndelete 5\n",
"9\ninsert 10\ninsert 2\ninsert 3\ninsert 1\ndelete 3\ninsert 6\ndelete 5\ndele... | [
"6 1 2\n",
"6 2 2\n",
"2 2\n",
"1 2\n",
"6 0 2\n",
"0 2\n",
"3 0 2\n",
"2\n",
"0\n",
"6 1 4\n"
] |
CodeContests | Ken loves ken-ken-pa (Japanese version of hopscotch). Today, he will play it on a directed graph G. G consists of N vertices numbered 1 to N, and M edges. The i-th edge points from Vertex u_i to Vertex v_i.
First, Ken stands on Vertex S. He wants to reach Vertex T by repeating ken-ken-pa. In one ken-ken-pa, he does th... | stdin | null | 2,601 | 1 | [
"4 4\n1 2\n2 3\n3 4\n4 1\n1 3\n",
"6 8\n1 2\n2 3\n3 4\n4 5\n5 1\n1 4\n1 5\n4 6\n1 6\n",
"3 3\n1 2\n2 3\n3 1\n1 2\n",
"2 0\n1 2\n"
] | [
"2\n",
"2\n",
"-1\n",
"-1\n"
] | [
"4 4\n1 3\n2 3\n3 4\n4 1\n1 3\n",
"6 8\n1 4\n2 3\n3 4\n4 5\n5 1\n1 4\n1 5\n4 6\n1 6\n",
"3 3\n1 2\n2 3\n2 1\n1 2\n",
"3 1\n1 1\n3 3\n3 1\n1 2\n",
"4 1\n1 3\n2 3\n3 4\n4 1\n1 3\n",
"6 8\n1 4\n2 3\n3 4\n4 6\n5 1\n1 4\n1 5\n4 6\n1 6\n",
"6 8\n1 2\n2 3\n3 4\n4 6\n5 1\n1 4\n1 5\n4 6\n1 6\n",
"6 8\n1 2\n2 1... | [
"-1\n",
"2\n",
"1\n",
"0\n",
"-1\n",
"2\n",
"2\n",
"2\n",
"1\n",
"1\n"
] |
CodeContests | Problem
There are $ n $ bombs on a two-dimensional plane. Each bomb is numbered from 1 to $ n $, and the $ i $ th bomb is located at coordinates $ (x_i, y_i) $.
It is known that all bombs have the same Manhattan distance from the origin.
When the $ i $ th bomb explodes, the bombs that are within $ r_i $ in Manhattan f... | stdin | null | 1,664 | 1 | [
"2\n-1 -1 10\n1 1 1\n",
"3\n3 2 2\n4 -1 4\n1 -4 7\n"
] | [
"0\n1\n",
"2\n1\n0\n"
] | [
"2\n-1 -1 9\n1 1 1\n",
"3\n3 2 2\n4 -1 1\n1 -4 7\n",
"3\n3 2 2\n4 -1 1\n1 -4 4\n",
"3\n3 2 3\n3 -1 1\n0 -4 8\n",
"2\n-1 -1 3\n2 0 1\n",
"3\n3 0 3\n3 -1 1\n0 -4 8\n",
"3\n3 1 2\n3 -1 1\n0 -4 8\n",
"3\n0 2 2\n2 1 2\n0 -3 8\n",
"3\n0 2 5\n3 1 2\n0 -3 8\n",
"3\n3 2 2\n2 -1 4\n1 -4 7\n"
] | [
"0\n1\n",
"2\n2\n1\n",
"2\n2\n2\n",
"1\n2\n1\n",
"1\n1\n",
"1\n1\n0\n",
"1\n2\n0\n",
"2\n2\n0\n",
"0\n2\n0\n",
"2\n0\n0\n"
] |
CodeContests | At the end of a busy day, The Chef and his assistants play a game together. The game is not just for fun but also used to decide who will have to clean the kitchen. The Chef is a Game Master, so his concern is how to manage the game but not how to win the game like his assistants do.
The game requires players to find... | stdin | null | 1,350 | 1 | [
"1\n5 2 3\n1 4\n3 5\n1 5\n"
] | [
"1\n"
] | [
"1\n5 2 3\n1 4\n3 5\n0 5\n",
"1\n5 2 3\n1 3\n3 5\n1 5\n",
"1\n5 2 3\n2 4\n3 5\n0 5\n",
"1\n5 2 3\n2 4\n2 5\n0 5\n",
"1\n5 2 3\n2 4\n2 8\n0 5\n",
"1\n10 2 3\n1 6\n3 5\n1 5\n",
"1\n4 2 3\n1 6\n3 9\n1 5\n",
"1\n5 2 3\n5 4\n2 5\n0 3\n",
"1\n5 2 3\n2 8\n2 4\n1 0\n",
"1\n4 2 3\n1 0\n2 9\n1 5\n"
] | [
"0\n",
"4\n",
"1\n",
"2\n",
"6\n",
"3\n",
"7\n",
"5\n",
"8\n",
"9\n"
] |
CodeContests | Taro loves a game called Vongress. Vongress is a camp game played on a board that is a convex polygon consisting of n vertices.
In this game, m players place one piece each inside the board. The position of the piece is represented by a set of x-coordinate and y-coordinate, and the size of the piece is not considered.... | stdin | null | 4,246 | 1 | [
"4 5\n1 1\n-1 1\n-1 -1\n1 -1\n1\n1\n1\n1\n1\n"
] | [
"0.0000000000 0.0000000000\n0.6324555320 0.6324555320\n-0.6324555320 0.6324555320\n-0.6324555320 -0.6324555320\n0.6324555320 -0.6324555320\n"
] | [
"4 1\n1 1\n-1 1\n-1 -1\n1 -1\n1\n1\n1\n1\n1\n",
"2 1\n1 0\n-1 1\n-1 -1\n1 -1\n1\n0\n1\n1\n0\n",
"2 1\n1 0\n-1 0\n-1 -1\n1 -1\n1\n0\n1\n1\n0\n",
"2 1\n1 -1\n-1 0\n0 -1\n0 -1\n1\n1\n1\n2\n1\n",
"2 1\n1 -1\n-1 -1\n0 -1\n0 -1\n1\n1\n2\n4\n1\n",
"4 1\n1 -1\n-1 -1\n0 0\n0 -1\n1\n1\n2\n4\n1\n",
"4 1\n1 -1\n-1 ... | [
"0.00000035297 -0.00000035297\n",
"-0.99999999907 0.99999999953\n",
"-0.99999999907 0.00000000000\n",
"-0.99999999907 -0.00000000047\n",
"-0.99999999907 -1.00000000000\n",
"-0.50000049919 -1.00000000000\n",
"-0.49999977648 0.00000044703\n",
"0.50000022352 -0.00000044703\n",
"-0.00000049965 -1.000000... |
CodeContests | Example
Input
3 2
R1
Output
3 1 2
4 5 6
7 8 9 | stdin | null | 3,693 | 1 | [
"3 2\nR1\n"
] | [
"3 1 2\n4 5 6\n7 8 9\n"
] | [
"2 2\nR1\n",
"1 2\nR1\n",
"5 2\nR1\n",
"4 2\nR1\n",
"8 2\nR1\n",
"7 2\nR1\n",
"3 2\nR2\n",
"11 2\nR1\n",
"3 2\nR3\n",
"11 2\nR2\n"
] | [
"2 1\n3 4\n",
"1\n",
"5 1 2 3 4\n6 7 8 9 10\n11 12 13 14 15\n16 17 18 19 20\n21 22 23 24 25\n",
"4 1 2 3\n5 6 7 8\n9 10 11 12\n13 14 15 16\n",
"8 1 2 3 4 5 6 7\n9 10 11 12 13 14 15 16\n17 18 19 20 21 22 23 24\n25 26 27 28 29 30 31 32\n33 34 35 36 37 38 39 40\n41 42 43 44 45 46 47 48\n49 50 51 52 53 54 55 56... |
CodeContests | For a given polygon g and target points t, print "2" if g contains t, "1" if t is on a segment of g, "0" otherwise.
g is represented by a sequence of points p1, p2,..., pn where line segments connecting pi and pi+1 (1 ≤ i ≤ n-1) are sides of the polygon. The line segment connecting pn and p1 is also a side of the poly... | stdin | null | 2,501 | 1 | [
"4\n0 0\n3 1\n2 3\n0 3\n3\n2 1\n0 2\n3 2\n"
] | [
"2\n1\n0\n"
] | [
"4\n0 0\n3 1\n2 3\n0 3\n3\n2 1\n0 2\n0 2\n",
"4\n0 0\n3 0\n2 3\n0 1\n3\n2 1\n0 2\n0 2\n",
"4\n0 -1\n3 1\n2 3\n0 3\n1\n2 1\n0 2\n3 1\n",
"4\n0 -1\n2 1\n2 3\n0 3\n1\n2 1\n0 1\n3 1\n",
"4\n0 -1\n3 0\n3 2\n1 3\n1\n0 2\n1 0\n0 1\n",
"4\n0 -1\n6 -2\n3 -1\n1 4\n2\n0 1\n1 0\n-1 0\n",
"4\n1 -1\n6 -2\n3 -1\n1 4\n... | [
"2\n1\n1\n",
"2\n0\n0\n",
"2\n",
"1\n",
"0\n",
"0\n2\n",
"0\n1\n",
"0\n0\n",
"2\n2\n1\n",
"1\n1\n1\n"
] |
CodeContests | An angel lives in the clouds above the city where Natsume lives. The angel, like Natsume, loves cats and often comes down to the ground to play with cats. To get down to the ground, the angel made a long, long staircase leading from the clouds to the ground. However, the angel thought that it would be boring to just go... | stdin | null | 3,969 | 1 | [
"4\n6 4\nC E D# F G A\nC E F G\n6 4\nC E D# F G A\nC D# F G\n3 6\nC D D\nD# B D B D# C#\n8 8\nC B B B B B F F\nC B B B B B B B\n"
] | [
"Yes\nNo\nYes\nNo\n"
] | [
"4\n6 4\nC E D# E G A\nC E F G\n6 4\nC E D# F G A\nC D# F G\n3 6\nC D D\nD# B D B D# C#\n8 8\nC B B B B B F F\nC B B B B B B B\n",
"4\n6 4\nC E D# G G A\nC E F G\n6 4\nC E D# F G A\nC D# F G\n3 6\nC D D\nD# B D B D# C#\n8 8\nC B B B B B F F\nC B B B B B B B\n",
"4\n6 4\nC E D# G G A\nC E F G\n6 4\nC E D# F G A\... | [
"Yes\nNo\nYes\nNo\n",
"No\nNo\nYes\nNo\n",
"No\nNo\nNo\nNo\n",
"Yes\nNo\nNo\nNo\n",
"Yes\nNo\nYes\nNo\n",
"Yes\nNo\nYes\nNo\n",
"Yes\nNo\nYes\nNo\n",
"Yes\nNo\nYes\nNo\n",
"Yes\nNo\nYes\nNo\n",
"Yes\nNo\nYes\nNo\n"
] |
CodeContests | AtCoDeer the deer has N square tiles. The tiles are numbered 1 through N, and the number given to each tile is written on one side of the tile. Also, each corner of each tile is painted in one of the 1000 colors, which are represented by the integers 0 between 999. The top-left, top-right, bottom-right and bottom-left ... | stdin | null | 2,328 | 1 | [
"6\n0 1 2 3\n0 4 6 1\n1 6 7 2\n2 7 5 3\n6 4 5 7\n4 0 3 5\n",
"6\n0 0 0 0\n0 0 0 0\n0 0 0 0\n0 0 0 0\n0 0 0 0\n0 0 0 0\n",
"8\n0 0 0 0\n0 0 1 1\n0 1 0 1\n0 1 1 0\n1 0 0 1\n1 0 1 0\n1 1 0 0\n1 1 1 1\n"
] | [
"1\n",
"122880\n",
"144\n"
] | [
"6\n0 1 2 3\n0 4 6 1\n1 6 9 2\n2 7 5 3\n6 4 5 7\n4 0 3 5\n",
"8\n0 0 1 0\n0 0 1 1\n0 1 0 1\n0 1 1 0\n1 0 0 1\n1 0 1 0\n1 1 0 0\n1 1 1 1\n",
"8\n0 0 1 0\n0 0 1 1\n1 1 0 1\n1 1 1 0\n1 0 0 1\n1 0 1 0\n1 1 -1 1\n1 1 1 1\n",
"8\n0 0 0 0\n0 0 1 1\n0 1 0 1\n0 1 1 0\n1 0 0 1\n1 0 2 0\n1 1 0 0\n1 1 1 1\n",
"6\n0 0 0... | [
"0\n",
"48\n",
"16\n",
"96\n",
"768\n",
"32\n",
"0\n",
"0\n",
"0\n",
"0\n"
] |
CodeContests | In the International City of Pipe Construction, it is planned to repair the water pipe at a certain point in the water pipe network. The network consists of water pipe segments, stop valves and source point. A water pipe is represented by a segment on a 2D-plane and intersected pair of water pipe segments are connected... | stdin | null | 3,410 | 1 | [
"2 1\n0 0 0 4\n0 2 2 2\n1 2\n0 1\n0 3\n",
"5 3\n0 4 2 4\n0 2 2 2\n0 0 2 0\n0 0 0 4\n2 0 2 4\n0 2\n1 0\n2 2\n1 4\n2 1\n",
"1 2\n0 0 10 0\n1 0\n9 0\n0 0\n5 0\n"
] | [
"-1\n",
"3.0\n",
"9.0\n"
] | [
"2 1\n0 0 0 4\n0 2 2 2\n1 2\n-1 1\n0 3\n",
"5 3\n0 4 2 4\n0 2 2 2\n0 0 2 0\n0 0 0 4\n2 0 2 4\n0 2\n1 0\n2 2\n2 4\n2 1\n",
"1 2\n0 -1 10 0\n1 0\n9 0\n0 0\n5 0\n",
"2 1\n0 0 0 4\n0 2 2 3\n1 2\n-1 1\n0 3\n",
"2 1\n0 0 0 7\n0 2 2 3\n1 2\n-1 1\n0 3\n",
"2 1\n0 1 0 7\n0 2 2 3\n1 2\n-1 1\n0 5\n",
"2 1\n0 1 0 3... | [
"6.0000000000\n",
"3.0000000000\n",
"10.0498756211\n",
"6.2360679775\n",
"9.2360679775\n",
"8.2360679775\n",
"4.2360679775\n",
"4.4721359550\n",
"5.0644951022\n",
"5.9907047849\n"
] |
CodeContests | There are N cities in Republic of AtCoder. The size of the i-th city is A_{i}. Takahashi would like to build N-1 bidirectional roads connecting two cities so that any city can be reached from any other city by using these roads.
Assume that the cost of building a road connecting the i-th city and the j-th city is |i-j... | stdin | null | 18 | 1 | [
"3 1\n1 100 1\n",
"12 5\n43 94 27 3 69 99 56 25 8 15 46 8\n",
"3 1000\n1 100 1\n",
"6 14\n25 171 7 1 17 162\n"
] | [
"106\n",
"658\n",
"2202\n",
"497\n"
] | [
"3 1\n2 100 1\n",
"12 5\n43 94 27 3 69 99 56 25 15 15 46 8\n",
"3 1000\n1 101 1\n",
"6 24\n25 171 7 1 17 162\n",
"3 1\n0 100 1\n",
"12 5\n43 94 27 3 69 99 56 25 27 15 46 8\n",
"3 1001\n1 101 1\n",
"6 24\n46 171 7 1 17 162\n",
"12 5\n43 94 27 3 69 99 56 25 27 15 46 7\n",
"6 24\n46 171 7 1 10 162\n"... | [
"107\n",
"681\n",
"2204\n",
"559\n",
"104\n",
"701\n",
"2206\n",
"580\n",
"699\n",
"566\n"
] |
CodeContests | There are N mountains in a circle, called Mountain 1, Mountain 2, ..., Mountain N in clockwise order. N is an odd number.
Between these mountains, there are N dams, called Dam 1, Dam 2, ..., Dam N. Dam i (1 \leq i \leq N) is located between Mountain i and i+1 (Mountain N+1 is Mountain 1).
When Mountain i (1 \leq i \l... | stdin | null | 3,312 | 1 | [
"3\n1000000000 1000000000 0\n",
"5\n3 8 7 5 5\n",
"3\n2 2 4\n"
] | [
"0 2000000000 0\n",
"2 4 12 2 8\n",
"4 0 4\n"
] | [
"3\n1000000000 1000100000 0\n",
"3\n2 0 4\n",
"3\n1000000000 1001100000 0\n",
"3\n1000000000 1011100000 0\n",
"3\n1000000000 1011101000 0\n",
"3\n1010000000 1011101000 0\n",
"3\n1010100000 1011101000 0\n",
"3\n1000000000 1010000000 0\n",
"3\n1000000000 1100100000 0\n",
"3\n1000001000 1011101000 0\... | [
"-100000 2000100000 100000\n",
"6 -2 2\n",
"-1100000 2001100000 1100000\n",
"-11100000 2011100000 11100000\n",
"-11101000 2011101000 11101000\n",
"-1101000 2021101000 1101000\n",
"-1001000 2021201000 1001000\n",
"-10000000 2010000000 10000000\n",
"-100100000 2100100000 100100000\n",
"-11100000 201... |
CodeContests | WizKid went on a trip to Wonderland with his classmates. Now, as you know, going on trips incurs costs including hotel costs, fooding, shopping, etc. And when many people go together, usually one person pays and it is expected that the others will pay back their share. But, after a few days people lost track of who owe... | stdin | null | 1,438 | 1 | [
"1\n4 2\nAlice\nBob\nDaniel\nMike\nBob\n97\n1\nAlice\nMike\n24\n2\nAlice\nBob\n\nSAMPLE\n"
] | [
"Alice owes 56\nBob is owed 40\nDaniel neither owes nor is owed\nMike is owed 16\n"
] | [
"1\n4 2\nAlice\nBob\nDaneil\nMike\nBob\n97\n1\nAlice\nMike\n24\n2\nAlice\nBob\n\nSAMPLE\n",
"1\n4 2\nAlice\nBob\nianDel\nMike\nBob\n97\n1\nAlice\nMike\n24\n2\nAlice\nBob\n\nSAMPLE\n",
"1\n4 1\nAlice\nBob\nDaniel\nMike\nBob\n97\n1\nAlice\nMike\n24\n2\nAlice\nBob\n\nSAMPLE\n",
"1\n4 2\nAlice\nBob\nianDel\nMike\... | [
"Alice owes 56\nBob is owed 40\nDaneil neither owes nor is owed\nMike is owed 16\n",
"Alice owes 56\nBob is owed 40\nianDel neither owes nor is owed\nMike is owed 16\n",
"Alice owes 48\nBob is owed 48\nDaniel neither owes nor is owed\nMike neither owes nor is owed\n",
"Alice owes 59\nBob is owed 37\nianDel ne... |
CodeContests | Princess in Danger
Princess crisis
English text is not available in this practice contest.
A brave princess in a poor country's tomboy is married to another country for a political marriage. However, a villain who was trying to kill the princess attacked him on the way to his wife, and the princess was seriously inj... | stdin | null | 507 | 1 | [
"2 1 0 1 0 1\n0 1 2\n3 1 1 2 0 1\n2\n0 2 1\n1 2 1\n3 2 1 2 0 1\n2\n0 2 1\n1 2 1\n4 4 1 4 1 3\n2\n0 1 2\n1 2 4\n0 2 1\n3 0 3\n5 3 2 6 0 3\n1 2\n2 1 2\n1 0 1\n3 4 1\n2 4 1\n4 1 2\n2 0 2\n5 4 2 6 0 3\n1 2\n4 2 4\n2 1 2\n4 3 1\n0 1 5\n1 4 2\n2 0 3\n0 0 0 0 0 0\n"
] | [
"Help!\n3\n2\n10\n5\n12\n"
] | [
"2 1 0 1 0 1\n0 1 2\n3 1 1 2 0 1\n2\n0 2 1\n1 2 1\n3 2 1 2 0 1\n2\n0 2 1\n1 2 1\n4 4 1 4 1 3\n2\n0 1 2\n1 2 4\n0 2 1\n3 0 3\n5 3 2 6 0 3\n1 2\n2 1 2\n1 0 1\n3 4 1\n2 4 1\n4 1 2\n2 0 2\n5 4 2 6 0 3\n1 2\n4 2 4\n2 2 2\n4 3 1\n0 1 5\n1 4 2\n2 0 3\n0 0 0 0 0 0\n",
"2 1 0 1 0 1\n0 1 2\n3 1 1 2 0 1\n2\n0 2 1\n1 2 1\n3 ... | [
"Help!\n3\n2\n10\n5\nHelp!\n",
"Help!\n3\n2\n6\n5\nHelp!\n",
"Help!\n3\n2\n5\n5\nHelp!\n",
"Help!\n3\n2\n12\n5\n12\n",
"Help!\n3\n2\n10\nHelp!\nHelp!\n",
"2\n3\n2\n6\n5\nHelp!\n",
"Help!\nHelp!\n2\n12\n5\n12\n",
"Help!\nHelp!\n2\n10\n5\nHelp!\n",
"Help!\n3\n3\n6\n5\nHelp!\n",
"Help!\nHelp!\n2\nHel... |
CodeContests | Write your program in Ruby which takes an un-indented Ruby code as string and outputs the indented Ruby code as string.
Input Format
A string which is un-indented Ruby code
Output Format
A string which is indented Ruby code
SAMPLE INPUT
class YabbaDabbaDoo
def foo
if foo == 42
puts 'world hel... | stdin | null | 3,503 | 1 | [
"class YabbaDabbaDoo\n def foo\n if foo == 42\n puts 'world hello'\n elsif foo == 24\n puts 'bk201'\n else\n puts 'congrats!'\n end\n end\nend\n\nSAMPLE\n"
] | [
"class YabbaDabbaDoo\n def foo\n if foo == 42\n puts 'world hello'\n elsif foo == 24\n puts 'bk201'\n else\n puts 'congrats!'\n end\n end\nend\n"
] | [
"class ZabbaDabbaDoo\n def foo\n if foo == 37\n puts 'world hello'\n elsif foo == 24\n puts 'bk201'\n else\n puts 'congats!'\n end\n end\nend\n",
"class ZaabaDbbbaDoo\n def foo\n if foo == 37\n puts 'world hello'\n elsif ... | [
"class ZabbaDabbaDoo\n def foo\n if foo == 37\n puts 'world hello'\n elsif foo == 24\n puts 'bk201'\n else\n puts 'congrats!'\n end\n end\nend\n",
"class ZaabaDbbbaDoo\n def foo\n if foo == 37\n puts 'world hello'\n elsif foo == 24\n puts 'bk201'\n else\n puts 'congrats!'\n end\n end\nend\n",
... |
CodeContests | HackerEarth has sponsored a lot of goodies for the 'Google Week' to be held at Sir MVIT. The goodies are in the form of boxes. Each box has a surprise value associated with it.
To carry the boxes from his hostel to the venue, Karan puts the box with the smaller surprise value inside the box with larger surprise value.... | stdin | null | 1,877 | 1 | [
"3\n3\n1\n2\n3\n4\n2\n2\n2\n2\n3\n11\n111\n1111\n\nSAMPLE\n"
] | [
"1\n4\n1\n"
] | [
"2\n8\n1\n2\n1\n3\n3\n5\n5\n5\n6\n1\n2\n3\n4\n5\n6\n",
"1\n16\n1\n2\n2\n2\n9\n5\n6\n6\n7\n7\n7\n2\n9\n13\n9\n9\n",
"3\n3\n2\n2\n3\n4\n2\n2\n2\n2\n3\n11\n111\n1111\n\nSAMPLE\n",
"3\n3\n2\n2\n3\n4\n3\n2\n2\n2\n3\n11\n111\n1111\n\nSAMPLE\n",
"3\n3\n2\n2\n3\n4\n3\n3\n2\n2\n3\n11\n101\n1111\n\nSAMPLE\n",
"3\n3... | [
"3\n1\n",
"4\n",
"2\n4\n1\n",
"2\n3\n1\n",
"2\n2\n1\n",
"1\n4\n1\n",
"2\n1\n",
"5\n",
"3\n2\n",
"1\n1\n2\n"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.