Search is not available for this dataset
problem_id
string
problem
string
answer
string
test_cases
string
eval_spec
string
source
string
source_platform
string
original_domain
string
category
float64
codecontests__test__code_contests_train.riegeli-00069-of-00128_1
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...
[{"code": "# 5th question in long challenge. 5 line code :D\ni,k,s=map(int, raw_input().split()) \na,b=map(int, raw_input().split())\nk-=i\nif k%2:print 2 ** (2*(k-1)-s+1)*(2**0.5*a+6**0.5*b)\nelse:print 2**(2*k-s)*(a+b);", "is_known_correct": true, "language": "python", "metadata": {}, "solution_id": "codecontests__te...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00069-of-00128_1__public__0000", "expected_output": {"kind": "stdout", "value": "0.28125\n"}, "input": {"kind": "stdin", "value": "1 1 5\n4 5"}, "metadata": {}, "visibility": "public"}]
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
CODECHEF
[]
null
codecontests__test__code_contests_train.riegeli-00069-of-00128_2
In olden days finding square roots seemed to be difficult but nowadays it can be easily done using in-built functions available across many languages . Assume that you happen to hear the above words and you want to give a try in finding the square root of any given integer using in-built functions. So here's your cha...
[{"code": "t = int(raw_input())\nfor i in range(t):\n k = int(raw_input())\n root_k= k**(1/2.0)\n int_root_k = int(root_k)\n print int_root_k", "is_known_correct": true, "language": "python", "metadata": {}, "solution_id": "codecontests__test__code_contests_train.riegeli-00069-of-00128_2__ref__0000", "sourc...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00069-of-00128_2__public__0000", "expected_output": {"kind": "stdout", "value": "3\n2\n100\n"}, "input": {"kind": "stdin", "value": "3\n10\n5\n10000"}, "metadata": {}, "visibility": "public"}]
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
CODECHEF
[]
null
codecontests__test__code_contests_train.riegeli-00069-of-00128_3
Chef Palin, as his name suggests, is always very interested in palindromic strings. Recently, he made a pretty interesting discovery on palindromes and that made him feel really Lucky. He came across something known as Lucky Palindromes. He defines a string as being a lucky palindrome if it is a palindrome containing t...
[{"code": "import copy\nt=int(raw_input().rstrip())\nwhile t:\n s = raw_input().rstrip()\n if len(s)<=8:\n print \"unlucky\"\n else:\n length = len(s)\n initialCount = 0\n palindrome = ''\n for i in range(length):\n if s[i]>s[length-1-i]:\n initialCo...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00069-of-00128_3__public__0000", "expected_output": {"kind": "stdout", "value": "luckykcul 8\nluckycocykcul 6\nunlucky"}, "input": {"kind": "stdin", "value": "3\nlaubcdkey\nluckycodechef\naaaaaaaa"}, "metadata": {}, "visibility": "public"}]
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
CODECHEF
[]
null
codecontests__test__code_contests_train.riegeli-00069-of-00128_4
Chef, Artem and Eugene are the best of friends and teammates. Recently, they won a lot of money at the Are You Feeling Lucky Cup. Having put their fortune to test and emerging victorious, they are now busy enjoying their wealth. Eugene wanted to drink it all away. Chef and Artem had better plans. Chef and Artem decide...
[{"code": "t=int(raw_input())\nfor _ in range(0,t):\n\tt1,t2,t3,t4=map(float,raw_input().split())\n\tprint t1/(t1+t2)", "is_known_correct": true, "language": "python", "metadata": {}, "solution_id": "codecontests__test__code_contests_train.riegeli-00069-of-00128_4__ref__0000", "source": "benchmark"}, {"code": "for i in...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00069-of-00128_4__public__0000", "expected_output": {"kind": "stdout", "value": "0.5\n0.4\n"}, "input": {"kind": "stdin", "value": "2\n2 2 1 2\n2 3 4 1"}, "metadata": {}, "visibility": "public"}]
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
CODECHEF
[]
null
codecontests__test__code_contests_train.riegeli-00069-of-00128_67
Aniruddha loves to code on HackerEarth. There are some type of problems which he likes the most. Problems are tagged with non empty strings containing only 'H' or 'E' or both. But he likes the problems tagged with strings containing no consecutive E's. Given an integer N, find maximum number of problems Aniruddha may l...
[{"code": "arr=[]\nsarr=[]\nt=0\nn=int(raw_input())\nif(n>=1 and n<=1000000):\n\tfor i in range(n):\n\t\tt=int(raw_input())\n\t\tarr.append(t)\n\t\tsarr.append(t)\n\tsarr.sort()\n\td ={}\n\ta =2\n\tb=3\n\tans = a+b\n\tj=0\n\tfor i in range(1,sarr[n-1]+1):\n\t\tif(i>=1 and i<=1000000):\n\t\t\tif(i==1):\n\t\t\t\twhile(j<...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00069-of-00128_67__public__0000", "expected_output": {"kind": "stdout", "value": "5\n10\n"}, "input": {"kind": "stdin", "value": "2\n2\n3\n\nSAMPLE"}, "metadata": {}, "visibility": "public"}]
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
HACKEREARTH
[]
null
codecontests__test__code_contests_train.riegeli-00069-of-00128_69
Yesterday while Omar was trying to learn English, he saw that there are letters repeated many times in words while some other letters repeated only few times or not repeated at all! Of course anyone can memorize the letters (repeated many times) better than the letters repeated few times, so Omar will concatenate al...
[{"code": "'''\n# Read input from stdin and provide input before running code\n\nname = raw_input('What is your name?\\n')\nprint 'Hi, %s.' % name\n'''\nimport string\n\nn=int(raw_input())\nfor i in range(n):\n\td=dict(zip(string.ascii_lowercase, [0]*26))\n\ts=raw_input()\n\tfor key in d.keys():\n\t\td[key]=s.count(key...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00069-of-00128_69__public__0000", "expected_output": {"kind": "stdout", "value": "z y x w v u t s q p n l k j i h g f e d c b r m a o \n"}, "input": {"kind": "stdin", "value": "1\noomar\n\nSAMPLE"}, "metadata": {}, "visibility": "public"}]
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
HACKEREARTH
[]
null
codecontests__test__code_contests_train.riegeli-00069-of-00128_81
In a flower bed, there are N flowers, numbered 1,2,......,N. Initially, the heights of all flowers are 0. You are given a sequence h=\\{h_1,h_2,h_3,......\\} as input. You would like to change the height of Flower k to h_k for all k (1 \leq k \leq N), by repeating the following "watering" operation: * Specify integers...
[{"code": "n = int(input())\nh = list(map(int,input().split()))\nans = h[0]\nfor i in range(1,n):\n if h[i-1] < h[i]:\n ans += h[i]-h[i-1]\nprint(ans)", "is_known_correct": true, "language": "python", "metadata": {}, "solution_id": "codecontests__test__code_contests_train.riegeli-00069-of-00128_81__ref__0000"...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00069-of-00128_81__public__0000", "expected_output": {"kind": "stdout", "value": "2"}, "input": {"kind": "stdin", "value": "4\n1 2 2 1"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riegeli-00069-of-00128_81_...
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
ATCODER
[""]
null
codecontests__test__code_contests_train.riegeli-00069-of-00128_82
The ABC number of a string T is the number of triples of integers (i, j, k) that satisfy all of the following conditions: * 1 ≤ i < j < k ≤ |T| (|T| is the length of T.) * T_i = `A` (T_i is the i-th character of T from the beginning.) * T_j = `B` * T_k = `C` For example, when T = `ABCBC`, there are three triples of...
[{"code": "s=input()\nn=len(s)\ndp=[4*[0]for i in range(n+1)]\ndp[0][0]=1\nfor i in range(1,n+1):\n for j in range(4):\n dp[i][j]+=dp[i-1][j]*((s[i-1]==\"?\")*2+1)\n if s[i-1] in \"A?\":dp[i][1]+=dp[i-1][0]\n if s[i-1] in \"B?\":dp[i][2]+=dp[i-1][1]\n if s[i-1] in \"C?\":dp[i][3]+=dp[i-1][2]\n for j in range(4)...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00069-of-00128_82__public__0000", "expected_output": {"kind": "stdout", "value": "3"}, "input": {"kind": "stdin", "value": "ABCBC"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riegeli-00069-of-00128_82__publ...
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
ATCODER
[""]
null
codecontests__test__code_contests_train.riegeli-00069-of-00128_83
You went shopping to buy cakes and donuts with X yen (the currency of Japan). First, you bought one cake for A yen at a cake shop. Then, you bought as many donuts as possible for B yen each, at a donut shop. How much do you have left after shopping? Constraints * 1 \leq A, B \leq 1 000 * A + B \leq X \leq 10 000 * ...
[{"code": "import java.util.*;\n\npublic class Main{\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n int x = sc.nextInt();\n int a = sc.nextInt();\n int b = sc.nextInt();\n System.out.println((x-a)%b);\n }\n}\n", "is_known_correct": true, "language": "java", "metadata...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00069-of-00128_83__public__0000", "expected_output": {"kind": "stdout", "value": "28"}, "input": {"kind": "stdin", "value": "1000\n108\n108"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riegeli-00069-of-0012...
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
ATCODER
[""]
null
codecontests__test__code_contests_train.riegeli-00069-of-00128_84
You are playing the following game with Joisino. * Initially, you have a blank sheet of paper. * Joisino announces a number. If that number is written on the sheet, erase the number from the sheet; if not, write the number on the sheet. This process is repeated N times. * Then, you are asked a question: How many numbe...
[{"code": "N = input()\nS = set()\nfor i in xrange(N):\n a = int(raw_input())\n if a in S:\n S.discard(a)\n else:\n S.add(a)\nprint len(S)\n", "is_known_correct": true, "language": "python", "metadata": {}, "solution_id": "codecontests__test__code_contests_train.riegeli-00069-of-00128_84__ref__00...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00069-of-00128_84__public__0000", "expected_output": {"kind": "stdout", "value": "1"}, "input": {"kind": "stdin", "value": "3\n6\n2\n6"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riegeli-00069-of-00128_84_...
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
ATCODER
[""]
null
codecontests__test__code_contests_train.riegeli-00070-of-00128_0
Zombies zombies everywhere!!  In a parallel world of zombies, there are N zombies. There are infinite number of unused cars, each of same model only differentiated by the their colors. The cars are of K colors. A zombie parent can give birth to any number of zombie-children (possibly zero), i.e. each zombie will have...
[{"code": "mod = 10 ** 9 + 7\ndef powmod(n, p):\n if p == 0:\n \treturn 1\n if p == 1:\n return n % mod\n if p % 2 == 1:\n return n * powmod(n, p - 1) % mod\n x = powmod(n, p / 2) % mod\n return x * x % mod\nt = int(raw_input())\nfor i in xrange(t):\n n, k = map(int, raw_input().split...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00070-of-00128_0__public__0000", "expected_output": {"kind": "stdout", "value": "2\n12\n"}, "input": {"kind": "stdin", "value": "2\n2 2\n3 3"}, "metadata": {}, "visibility": "public"}]
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
CODECHEF
[]
null
codecontests__test__code_contests_train.riegeli-00070-of-00128_2
Alice's school is planning to take some students from her class on a field trip. Alice is really excited about it. There are a total of S students in her class. But due to budget constraints, the school is planning to take only N students for the trip. These students will be picked randomly. And each student has equal ...
[{"code": "nCr = [[0 for x in xrange(1001)] for x in xrange(1001)]\n\nfor i in range (0,1001):\n nCr[i][0]=1\n nCr[i][i]=1\nfor i in range (1,1001):\n for j in range (1,1001):\n if i!=j:\n nCr[i][j] = nCr[i-1][j] + nCr[i-1][j-1]\nt=input()\nfor _ in range(0,t):\n s,n,m,k=map(int,raw_input(...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00070-of-00128_2__public__0000", "expected_output": {"kind": "stdout", "value": "1.000000\n0.000000\n0.500000\n"}, "input": {"kind": "stdin", "value": "3\n10 10 5 3\n10 4 6 4\n3 2 2 1"}, "metadata": {}, "visibility": "public"}]
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
CODECHEF
[]
null
codecontests__test__code_contests_train.riegeli-00070-of-00128_3
Chef loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Let Fd(x) equals to the number of digits d in decimal representation of the positive integer x. Chef...
[{"code": "#codechef feb long quest\nM=[0]*100001\nA=[0]*100001\nM[0]=1\ns4=0\ns7=0\nret=0\nfor el in range(1,100001):\n n=el\n while n>0:\n k=n%10\n if(k==4):s4+=1\n if(k==7):s7+=1\n n=n/10\n ret+=M[s4-s7]\n A[el]=ret\n M[s4-s7]+=1\nt=int(raw_input())\nfor i in range(t):\n ...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00070-of-00128_3__public__0000", "expected_output": {"kind": "stdout", "value": "6\n31\n1266\n"}, "input": {"kind": "stdin", "value": "3\n3\n10\n100"}, "metadata": {}, "visibility": "public"}]
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
CODECHEF
[]
null
codecontests__test__code_contests_train.riegeli-00070-of-00128_81
There are N pieces of sushi. Each piece has two parameters: "kind of topping" t_i and "deliciousness" d_i. You are choosing K among these N pieces to eat. Your "satisfaction" here will be calculated as follows: * The satisfaction is the sum of the "base total deliciousness" and the "variety bonus". * The base total de...
[{"code": "import java.io.OutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.util.HashSet;\nimport java.util.PriorityQueue;\nimport java.util.Scanner;\nimport java.util.Collections;\n\n/**\n * Built using CHelper plug-in\n * Actual solution is at the top\n*...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00070-of-00128_81__public__0000", "expected_output": {"kind": "stdout", "value": "4900000016"}, "input": {"kind": "stdin", "value": "6 5\n5 1000000000\n2 990000000\n3 980000000\n6 970000000\n6 960000000\n4 950000000"}, "metadata": {}, "visibility": "public"}...
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
ATCODER
[""]
null
codecontests__test__code_contests_train.riegeli-00070-of-00128_82
You have three tasks, all of which need to be completed. First, you can complete any one task at cost 0. Then, just after completing the i-th task, you can complete the j-th task at cost |A_j - A_i|. Here, |x| denotes the absolute value of x. Find the minimum total cost required to complete all the task. Constrain...
[{"code": "#include<bits/stdc++.h>\nusing namespace std;\nint main()\n{\n\tint a[3];cin>>a[0]>>a[1]>>a[2];\n\tsort(a,a+3);\n\tcout<<(a[1]-a[0])+(a[2]-a[1]);\n\treturn 0;\n}", "is_known_correct": true, "language": "cpp", "metadata": {}, "solution_id": "codecontests__test__code_contests_train.riegeli-00070-of-00128_82__r...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00070-of-00128_82__public__0000", "expected_output": {"kind": "stdout", "value": "5"}, "input": {"kind": "stdin", "value": "1 6 3"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riegeli-00070-of-00128_82__publ...
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
ATCODER
[""]
null
codecontests__test__code_contests_train.riegeli-00070-of-00128_83
You have A 500-yen coins, B 100-yen coins and C 50-yen coins (yen is the currency of Japan). In how many ways can we select some of these coins so that they are X yen in total? Coins of the same kind cannot be distinguished. Two ways to select coins are distinguished when, for some kind of coin, the numbers of that co...
[{"code": "import java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\t// TODO Auto-generated method stub\n\t\tScanner in = new Scanner(System.in);\n\t\tint a = in.nextInt();\n\t\tint b = in.nextInt();\n\t\tint c = in.nextInt();\n\t\tint tar = in.nextInt();\n\t\tint cnt = 0;\n\t\...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00070-of-00128_83__public__0000", "expected_output": {"kind": "stdout", "value": "2"}, "input": {"kind": "stdin", "value": "2\n2\n2\n100"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riegeli-00070-of-00128_8...
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
ATCODER
[""]
null
codecontests__test__code_contests_train.riegeli-00070-of-00128_84
There are N towns in the State of Atcoder, connected by M bidirectional roads. The i-th road connects Town A_i and B_i and has a length of C_i. Joisino is visiting R towns in the state, r_1,r_2,..,r_R (not necessarily in this order). She will fly to the first town she visits, and fly back from the last town she visi...
[{"code": "#include<bits/stdc++.h>\n#define rep(i,n) for(int i = 0; i < n; i++)\n#define pb push_back\nusing namespace std;\ntypedef long long ll;\n\nconst int INF=1e9;\n\nint main(){\n int n,m,R;\n cin>>n>>m>>R;\n vector<int> r(R);\n rep(i,R){\n cin>>r[i];\n r[i]--;\n }\n \n vector<vector<int>> d(n,vecto...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00070-of-00128_84__public__0000", "expected_output": {"kind": "stdout", "value": "3"}, "input": {"kind": "stdin", "value": "4 6 3\n2 3 4\n1 2 4\n2 3 3\n4 3 1\n1 4 1\n4 2 2\n3 1 6"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__co...
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
ATCODER
[""]
null
codecontests__test__code_contests_train.riegeli-00071-of-00128_2
WARNING Large input/output files. Use faster I/O. It's Galactik Football time! The Galactik Football Assosiation (GFA) has announced a football tournament between all the teams of all the planets in the galaxy (say N). Teams like Snow Kids, Shadows, Xenons, Red Tigers, Wambas, Pirates, etc. are in total enthusiasm and ...
[{"code": "#! /usr/bin/python\n\nimport sys\n\nmax_val = sys.maxint\ninp = sys.stdin.readline().split()\nN, M = int(inp[0]), int(inp[1])\ng = range(N+1) # group of i'th point which is equal to least point index in the group;\n # all points connected to each other are in a same group\nfor i in xrange...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00071-of-00128_2__public__0000", "expected_output": {"kind": "stdout", "value": "3\n"}, "input": {"kind": "stdin", "value": "6 6\n1 2\n2 3\n1 3\n4 5\n5 6\n4 6\n1\n3\n5\n2\n4\n6"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code...
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
CODECHEF
[]
null
codecontests__test__code_contests_train.riegeli-00071-of-00128_70
Like most of the girlfriends, Ashima when asks for something, won’t stop until she gets that. The way she gets that is by keep on repeating the same things again and again. Like if she wants chocolate, she will just keep on repeating “chocolate” again and again. I have decided to answer to her demands as “Yes” or “No”...
[{"code": "s = raw_input()\nl = len(s)\nq = int(raw_input())\nfor i in xrange(0,q):\n a, b = map(int, raw_input().split())\n a%=l\n b%=l\n if s[a - 1] is s[b - 1]:\n print 'Yes'\n else:\n print 'No'", "is_known_correct": true, "language": "python", "metadata": {}, "solution_id": "codecontes...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00071-of-00128_70__public__0000", "expected_output": {"kind": "stdout", "value": "Yes\nNo\nYes\n"}, "input": {"kind": "stdin", "value": "vgxgp\n3\n2 4\n2 5\n7 14\n\nSAMPLE"}, "metadata": {}, "visibility": "public"}]
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
HACKEREARTH
[]
null
codecontests__test__code_contests_train.riegeli-00071-of-00128_82
You are given string S and T consisting of lowercase English letters. Determine if S equals T after rotation. That is, determine if S equals T after the following operation is performed some number of times: Operation: Let S = S_1 S_2 ... S_{|S|}. Change S to S_{|S|} S_1 S_2 ... S_{|S|-1}. Here, |X| denotes the len...
[{"code": "s=input()*100\nt=input()\n\nif t in s:\n print(\"Yes\")\nelse:\n print(\"No\")\n", "is_known_correct": true, "language": "python", "metadata": {}, "solution_id": "codecontests__test__code_contests_train.riegeli-00071-of-00128_82__ref__0000", "source": "benchmark"}, {"code": "#103_B\nS=input()\nT=input(...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00071-of-00128_82__public__0000", "expected_output": {"kind": "stdout", "value": "Yes"}, "input": {"kind": "stdin", "value": "aaaaaaaaaaaaaaab\naaaaaaaaaaaaaaab"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train....
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
ATCODER
[""]
null
codecontests__test__code_contests_train.riegeli-00071-of-00128_83
We have a 2 \times N grid. We will denote the square at the i-th row and j-th column (1 \leq i \leq 2, 1 \leq j \leq N) as (i, j). You are initially in the top-left square, (1, 1). You will travel to the bottom-right square, (2, N), by repeatedly moving right or down. The square (i, j) contains A_{i, j} candies. You ...
[{"code": "#include<iostream>\n#include<cstdio>\n#include<algorithm>\n#include<climits>\nusing namespace std;\nint f[3][105];\nint a[3][105],n;\nint main()\n{\n\tscanf(\"%d\",&n);\n\tfor(int i=1;i<=2;i++)\n\t\tfor(int j=1;j<=n;j++)\n\t\tscanf(\"%d\",&a[i][j]);\n\tf[1][1]=a[1][1];\n\tfor(int i=1;i<=2;i++)\n\t\tfor(int j...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00071-of-00128_83__public__0000", "expected_output": {"kind": "stdout", "value": "29"}, "input": {"kind": "stdin", "value": "7\n3 3 4 5 4 5 3\n5 3 4 4 2 3 2"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.rieg...
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
ATCODER
[""]
null
codecontests__test__code_contests_train.riegeli-00071-of-00128_84
We have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand. How many grams of sand will the upper bulb contains after t seconds? Constraints * 1≤X≤10^9 * 1≤t≤10^9 * X and t are integers. Input The input ...
[{"code": "X,t = map(int, input().split())\n\nprint(X - t if X > t else 0)", "is_known_correct": true, "language": "python", "metadata": {}, "solution_id": "codecontests__test__code_contests_train.riegeli-00071-of-00128_84__ref__0000", "source": "benchmark"}, {"code": "#include<stdio.h>\nint main()\n{\n int x,t;\n ...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00071-of-00128_84__public__0000", "expected_output": {"kind": "stdout", "value": "0"}, "input": {"kind": "stdin", "value": "48 58"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riegeli-00071-of-00128_84__publ...
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
ATCODER
[""]
null
codecontests__test__code_contests_train.riegeli-00072-of-00128_0
Recently Johnny have learned bogosort sorting algorithm. He thought that it is too ineffective. So he decided to improve it. As you may know this algorithm shuffles the sequence randomly until it is sorted. Johnny decided that we don't need to shuffle the whole sequence every time. If after the last shuffle several fir...
[{"code": "def gcd(a,b):\n\tif b==0:\n\t\treturn a\n\treturn gcd(b,a%b)\n\ndef simplify(a,b):\n\tg=gcd(a,b)\n\treturn (a/g,b/g)\n\nE = {0:(0,1), 1:(1,1), 2:(2,1)}\nfor i in xrange(3,151):\n\ta,b=E[i-1]\n\tc,d=E[i-2]\n\tE[i]=simplify(b*d*(i*i-3*i+3)+2*a*d*(i-1)-b*c,b*d*(2*i-3))\n\nt=input()\nwhile t:\n\tt-=1\n\tn=input(...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00072-of-00128_0__public__0000", "expected_output": {"kind": "stdout", "value": "2\n1826/189\n877318/35343\n"}, "input": {"kind": "stdin", "value": "3\n2\n6\n10"}, "metadata": {}, "visibility": "public"}]
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
CODECHEF
[]
null
codecontests__test__code_contests_train.riegeli-00072-of-00128_1
Chef had a hard time arguing with his friend, and after getting a great old kick Chef saw a colored array with N cells, numbered from 1 to N. The kick was so strong that Chef suddenly understood the rules of the game. Each cell is painted with a color. Here the colors are numbered from 1 to M. For any cell i, Chef c...
[{"code": "t = int(raw_input())\nfor _ in range(t):\n n, m, k = map(int, raw_input().split())\n a = map(int, raw_input().split())\n b = [] # gain\n for _ in range(n):\n b.append(map(int, raw_input().split()))\n c = [] # loss\n for _ in range(n):\n c.append(map(int, raw_input().split())...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00072-of-00128_1__public__0000", "expected_output": {"kind": "stdout", "value": "5"}, "input": {"kind": "stdin", "value": "1\n4 2 1\n1 1 2 2\n1 1\n1 1\n1 1\n3 1\n0 1\n0 1\n1 0\n1 0"}, "metadata": {}, "visibility": "public"}]
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
CODECHEF
[]
null
codecontests__test__code_contests_train.riegeli-00072-of-00128_2
Two players are playing a game. The game is played on a sequence of positive integer pairs. The players make their moves alternatively. During his move the player chooses a pair and decreases the larger integer in the pair by a positive multiple of the smaller integer in the pair in such a way that both integers in the...
[{"code": "#!/usr/bin/env python\n#-*- coding:utf-8 -*-\n\n\ndef convert_pair(a, b):\n res = []\n if a < b:\n a, b = b, a\n while b:\n res.append(a / b)\n a, b = b, a % b\n res[-1] -= 1\n while res[-1] == 0:\n del res[-1]\n return tuple(res)\n\n\ndef grundy(col):\n res =...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00072-of-00128_2__public__0000", "expected_output": {"kind": "stdout", "value": "NO\nNO\nYES"}, "input": {"kind": "stdin", "value": "3\n1\n2 3\n2\n4 5\n5 6\n2\n2 3\n3 5"}, "metadata": {}, "visibility": "public"}]
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
CODECHEF
[]
null
codecontests__test__code_contests_train.riegeli-00072-of-00128_3
Chef loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Chef has a positive integer N. He can apply any of the following operations as many times as he want...
[{"code": "t=input()\nwhile t:\n\tt-=1\n\tn=raw_input().strip()\n\tprint len(n)-n.count('4')-n.count('7')", "is_known_correct": true, "language": "python", "metadata": {}, "solution_id": "codecontests__test__code_contests_train.riegeli-00072-of-00128_3__ref__0000", "source": "benchmark"}, {"code": "for i in xrange(int(...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00072-of-00128_3__public__0000", "expected_output": {"kind": "stdout", "value": "2\n1\n2\n"}, "input": {"kind": "stdin", "value": "3\n25\n46\n99"}, "metadata": {}, "visibility": "public"}]
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
CODECHEF
[]
null
codecontests__test__code_contests_train.riegeli-00072-of-00128_82
You are given N positive integers a_1, a_2, ..., a_N. For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N). Here, X\ mod\ Y denotes the remainder of the division of X by Y. Find the maximum value of f. Constraints * All values in input are integers. * 2 \leq N \leq 3000 * 2 ...
[{"code": "#include <bits/stdc++.h>\nusing namespace std;\nint main(){\n int n,ans=0;\n cin>>n;\n for(int i=0,a;i<n;i++){\n cin>>a;ans+=a-1;\n }\n cout<<ans<<endl;\n}", "is_known_correct": true, "language": "cpp", "metadata": {}, "solution_id": "codecontests__test__code_contests_train.riegeli-00072-of-00128_82_...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00072-of-00128_82__public__0000", "expected_output": {"kind": "stdout", "value": "90"}, "input": {"kind": "stdin", "value": "5\n7 46 11 20 11"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riegeli-00072-of-00...
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
ATCODER
[""]
null
codecontests__test__code_contests_train.riegeli-00072-of-00128_84
You are given a permutation p_1,p_2,...,p_N consisting of 1,2,..,N. You can perform the following operation any number of times (possibly zero): Operation: Swap two adjacent elements in the permutation. You want to have p_i ≠ i for all 1≤i≤N. Find the minimum required number of operations to achieve this. Constraint...
[{"code": "#include <iostream>\n#include <vector>\nusing namespace std;\nint main() {\n\tint N;\n\tcin >> N;\n\tint S = 0;\n\tint seq = 0;\n\tint p;\n\tfor(int i = 1; i <= N; i++) {\n\t\tcin >> p;\n\t\tif(i != p) {\n\t\t\tS += seq / 2 + seq % 2;\n\t\t\tseq = 0;\n\t\t}\n\t\tif(i == p) seq++;\n\t}\n\tS += seq / 2 + seq %...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00072-of-00128_84__public__0000", "expected_output": {"kind": "stdout", "value": "2"}, "input": {"kind": "stdin", "value": "5\n1 4 3 5 2"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riegeli-00072-of-00128_8...
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
ATCODER
[""]
null
codecontests__test__code_contests_train.riegeli-00073-of-00128_4
Little chef has just been introduced to the world of numbers! While experimenting with addition and multiplication operations, the little chef came up with the following problem: Given an array A of non-negative integers, how many pairs of indices i and j exist such that A[i]*A[j] > A[i]+A[j] where i < j . Now be...
[{"code": "cases=int(raw_input().strip())\nwhile(cases):\n\tn=int(raw_input().strip())\n\ta=raw_input().strip()\n\ta=map(int,a.split())\n\tcount=0\n\tct=0;\n\t\n#\ttotal=(n*(n-1))/2\n\tfor i in range(len(a)):\n\t\tif ( a[i]>2):\n\t\t\tcount+=1\n\t\t\t\n\t\tif ( a[i]==2):\n\t\t\tct+=1\n\ttotal = (count*(count-1))/2\n\t#...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00073-of-00128_4__public__0000", "expected_output": {"kind": "stdout", "value": "3\n0\n"}, "input": {"kind": "stdin", "value": "2\n3\n3 4 5\n4\n1 1 1 1"}, "metadata": {}, "visibility": "public"}]
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
CODECHEF
[]
null
codecontests__test__code_contests_train.riegeli-00073-of-00128_80
There are three airports A, B and C, and flights between each pair of airports in both directions. A one-way flight between airports A and B takes P hours, a one-way flight between airports B and C takes Q hours, and a one-way flight between airports C and A takes R hours. Consider a route where we start at one of th...
[{"code": "#include<bits/stdc++.h>\nusing namespace std;\nint main(){\n int p,q,r;\n cin>>p>>q>>r;\n cout<<min(p,q)+min(q,r)+min(p,r)-min(p,min(q,r));\n}\n", "is_known_correct": true, "language": "cpp", "metadata": {}, "solution_id": "codecontests__test__code_contests_train.riegeli-00073-of-00128_80__ref__0000", "so...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00073-of-00128_80__public__0000", "expected_output": {"kind": "stdout", "value": "5"}, "input": {"kind": "stdin", "value": "3 2 3"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riegeli-00073-of-00128_80__publ...
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
ATCODER
[""]
null
codecontests__test__code_contests_train.riegeli-00073-of-00128_82
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place be...
[{"code": "#include <bits/stdc++.h>\nusing namespace std;\nint main(){\n long long n,m,ans=1,now;\n cin >> m >> n;\n long long a[n],b[n];\n pair<long long,long long> p[n];\n for(int i=0;i<n;i++){\n cin >> a[i] >> b[i];\n p[i]=make_pair(b[i],a[i]);\n }\n sort(p,p+n);\n now=p[0].first;\n for(int i=0;i<n;i+...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00073-of-00128_82__public__0000", "expected_output": {"kind": "stdout", "value": "4"}, "input": {"kind": "stdin", "value": "5 10\n1 2\n1 3\n1 4\n1 5\n2 3\n2 4\n2 5\n3 4\n3 5\n4 5"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__co...
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
ATCODER
[""]
null
codecontests__test__code_contests_train.riegeli-00073-of-00128_83
We have a graph with N vertices and M edges, and there are two people on the graph: Takahashi and Aoki. The i-th edge connects Vertex U_i and Vertex V_i. The time it takes to traverse this edge is D_i minutes, regardless of direction and who traverses the edge (Takahashi or Aoki). Takahashi departs Vertex S and Aoki ...
[{"code": "// In The Name Of Allah\n#include <bits/stdc++.h>\nusing namespace std;\n \ntypedef long long ll;\ntypedef pair <int, int> pii;\n\n#define error(x) cout << #x << \" = \" << x << endl;\n \nconst int N = 1e5 + 5, mod = 1e9 + 7;\nconst ll inf = 1e15;\n \ninline int sum(int a, int b) {\n\ta += b;\n\tif(a >= mod)...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00073-of-00128_83__public__0000", "expected_output": {"kind": "stdout", "value": "2"}, "input": {"kind": "stdin", "value": "4 4\n1 3\n1 2 1\n2 3 1\n3 4 1\n4 1 1"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train....
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
ATCODER
[""]
null
codecontests__test__code_contests_train.riegeli-00074-of-00128_1
After a long time, Chef has finally decided to renovate his house. Chef's house has N rooms in it numbered from 1 to N. Each room is currently painted in one of the red, blue or green colors. Your are given configuration of colors of his house by a string S consisting of N characters. In this string, color red will be ...
[{"code": "for _ in xrange(input()):\n l = []\n n = input()\n s = raw_input()\n l.append(s.count('R'))\n l.append(s.count('G'))\n l.append(s.count('B'))\n l.remove(max(l))\n print sum(l)", "is_known_correct": true, "language": "python", "metadata": {}, "solution_id": "codecontests__test__code_co...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00074-of-00128_1__public__0000", "expected_output": {"kind": "stdout", "value": "1\n0\n2\n"}, "input": {"kind": "stdin", "value": "3\n3\nRGR\n3\nRRR\n3\nRGB"}, "metadata": {}, "visibility": "public"}]
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
CODECHEF
[]
null
codecontests__test__code_contests_train.riegeli-00074-of-00128_3
Chef has the string s of length n consisted of digits 4 and 7. The string s is called balanced if there exits such integer x (1 ≤ x ≤ n) that the number of digits 4 in substring s[1; x) is equal to the number of digits 7 in substring s(x; n], where s[1; x) is the substring from the 1st digit to (x-1)th digit of s, and ...
[{"code": "mod = 1000000007\nfact = [1]\nfor i in xrange(1,5003):\n fact.append((i*fact[i-1])%mod)\ninv = []\nfor j in xrange(5003):\n nv = pow(fact[j] , mod-2 , mod)\n inv.append(nv)\nfor j in xrange(int(raw_input())):\n l = raw_input()\n four = l.count('4')\n seven = l.count('7')\n if (four == 0 ...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00074-of-00128_3__public__0000", "expected_output": {"kind": "stdout", "value": "1\n4"}, "input": {"kind": "stdin", "value": "2\n47\n4477"}, "metadata": {}, "visibility": "public"}]
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
CODECHEF
[]
null
codecontests__test__code_contests_train.riegeli-00074-of-00128_73
Sherlock and Watson are close friends. One day, they finally got bored of playing normal games. So, they came up with a new idea of playing with numbers. Since they are good at number theory, they know the fact that a decimal number "A" can be represented as sum of 2's powers. For example: 22 = 16 + 4 + 2 = 2^4...
[{"code": "t = int(raw_input())\nr = \"Sherlock\"\nq = \"Watson\"\nfor i in range(t):\n n = int(raw_input())\n count = 1\n count = bin(n).count('1')\n if count%2==0:\n print(q)\n j=r\n r=q\n q=j\n else:\n print(r)", "is_known_correct": true, "language": "python", "metad...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00074-of-00128_73__public__0000", "expected_output": {"kind": "stdout", "value": "Sherlock\nSherlock"}, "input": {"kind": "stdin", "value": "2\n1\n2\n\nSAMPLE"}, "metadata": {}, "visibility": "public"}]
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
HACKEREARTH
[]
null
codecontests__test__code_contests_train.riegeli-00074-of-00128_77
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required. Constraints * 1 \leq N \leq 10000 * N is an integer. Input Input is given from Standard Input in the following for...
[{"code": "import java.util.Scanner;\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner scan = new Scanner(System.in);\n\t\tint n = scan.nextInt();\n\t\tint ans = 0;\n\t\t\n\t\tans = n % 1000;\n\t\t\n\t\tif(ans != 0) {\n\t\t\tans = 1000 - ans;\n\t\t}\n\t\tSystem.out.println(ans);\n\n\t}\n\n...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00074-of-00128_77__public__0000", "expected_output": {"kind": "stdout", "value": "0"}, "input": {"kind": "stdin", "value": "3000"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riegeli-00074-of-00128_77__publi...
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
ATCODER
[""]
null
codecontests__test__code_contests_train.riegeli-00074-of-00128_80
We have N weights indexed 1 to N. The mass of the weight indexed i is W_i. We will divide these weights into two groups: the weights with indices not greater than T, and those with indices greater than T, for some integer 1 \leq T < N. Let S_1 be the sum of the masses of the weights in the former group, and S_2 be th...
[{"code": "#include <bits/stdc++.h>\nusing namespace std;\nint main(){\n\tint N; cin >> N; \n\tint W[110] = {}; int S[110] = {}; \n\tfor(int i = 1; i <= N; i++){\n\t\tcin >> W[i]; S[i] = S[i-1] + W[i]; \n\t}\n\tint ans = 1145141919; \n\tfor(int i = 1; i <= N; i++){\n\t\tans = min(ans, abs(S[N] - 2 * S[i])); \n\t}\n\tco...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00074-of-00128_80__public__0000", "expected_output": {"kind": "stdout", "value": "0"}, "input": {"kind": "stdin", "value": "3\n1 2 3"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riegeli-00074-of-00128_80__p...
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
ATCODER
[""]
null
codecontests__test__code_contests_train.riegeli-00074-of-00128_83
For a positive integer n, let us define f(n) as the number of digits in base 10. You are given an integer S. Count the number of the pairs of positive integers (l, r) (l \leq r) such that f(l) + f(l + 1) + ... + f(r) = S, and find the count modulo 10^9 + 7. Constraints * 1 \leq S \leq 10^8 Input Input is given fro...
[{"code": "#include <bits/stdc++.h>\nusing namespace std;\n\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef pair<ll, ll> P;\n\n#define fi first\n#define se second\n#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)\n#define rep(i,n) repl(i,0,n)\n#define all(x) (x).begin(),(x).end()\n#define dbg(x) cou...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00074-of-00128_83__public__0000", "expected_output": {"kind": "stdout", "value": "9"}, "input": {"kind": "stdin", "value": "1"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riegeli-00074-of-00128_83__public__...
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
ATCODER
[""]
null
codecontests__test__code_contests_train.riegeli-00074-of-00128_84
You are given N points (x_i,y_i) located on a two-dimensional plane. Consider a subset S of the N points that forms a convex polygon. Here, we say a set of points S forms a convex polygon when there exists a convex polygon with a positive area that has the same set of vertices as S. All the interior angles of the polyg...
[{"code": "#include<bits/stdc++.h>\nusing namespace std;\nconst int mod = 998244353;\nconst int N = 11111;\nvoid add(int &x, int y) {\n\tx += y;\n\tif (x >= mod) x -= mod;\n}\nint pw(int a, int b) {\n\tint an = 1;\n\tfor (; b; b >>= 1) {\n\t\tif (b & 1) an = 1ll * an * a % mod;\n\t\ta = 1ll * a * a % mod;\n\t}\n\tretur...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00074-of-00128_84__public__0000", "expected_output": {"kind": "stdout", "value": "0"}, "input": {"kind": "stdin", "value": "1\n3141 2718"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riegeli-00074-of-00128_8...
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
ATCODER
[""]
null
codecontests__test__code_contests_train.riegeli-00074-of-00128_85
Dolphin loves programming contests. Today, he will take part in a contest in AtCoder. In this country, 24-hour clock is used. For example, 9:00 p.m. is referred to as "21 o'clock". The current time is A o'clock, and a contest will begin in exactly B hours. When will the contest begin? Answer in 24-hour time. Constrain...
[{"code": "import java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\t// TODO 自動生成されたメソッド・スタブ\n\t\tScanner sc = new Scanner(System.in);\n\t\t// 整数の入力\n\t\tint A = sc.nextInt();\n\t\tint B = sc.nextInt();\n\t\tint C = A + B;\n\t\tif (C >= 24) {\n\t\t\tC = C - 24;\n\t\t}\n\t\t// 出力\...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00074-of-00128_85__public__0000", "expected_output": {"kind": "stdout", "value": "21"}, "input": {"kind": "stdin", "value": "9 12"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riegeli-00074-of-00128_85__publ...
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
ATCODER
[""]
null
codecontests__test__code_contests_train.riegeli-00075-of-00128_1
The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly. The Chef invested in top-of-the-line t...
[{"code": "import math\nno_of_testcases = int(input())\nfor each in range(no_of_testcases):\n dist = int(input())\n point_1 = map(int,raw_input().split())\n point_2 = map(int,raw_input().split())\n point_3 = map(int,raw_input().split()) \n point_12 =math.sqrt( math.pow((point_1[0] -point_2[0]),2) + ma...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00075-of-00128_1__public__0000", "expected_output": {"kind": "stdout", "value": "yes\nyes\nno\n"}, "input": {"kind": "stdin", "value": "3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1"}, "metadata": {}, "visibility": "public"}]
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
CODECHEF
[]
null
codecontests__test__code_contests_train.riegeli-00075-of-00128_3
A Little Elephant from the Zoo of Lviv likes lucky strings, i.e., the strings that consist only of the lucky digits 4 and 7. The Little Elephant calls some string T of the length M balanced if there exists at least one integer X (1 ≤ X ≤ M) such that the number of digits 4 in the substring T[1, X - 1] is equal to the n...
[{"code": "n = input()\nfor i in range(n):\n str = raw_input()\n l = len(str)\n megacounter = 0\n counter = 0\n i = 0\n while(1):\n while(i<l and str[i]=='7'):\n i=i+1\n counter=counter+1\n if(i>=l):\n break\n megacounter = megacounter + (counter*(...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00075-of-00128_3__public__0000", "expected_output": {"kind": "stdout", "value": "2\n2\n3\n23\n"}, "input": {"kind": "stdin", "value": "4\n47\n74\n477\n4747477"}, "metadata": {}, "visibility": "public"}]
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
CODECHEF
[]
null
codecontests__test__code_contests_train.riegeli-00075-of-00128_4
Given a string s. Can you make it a palindrome by deleting exactly one character? Note that size of the string after deletion would be one less than it was before. Input First line of the input contains a single integer T denoting number of test cases. For each test case, you are given a single line containing string...
[{"code": "import math\nimport sys\ndef checkpal(s):\n return s==s[::-1]\nfor a in range(input()):\n s=raw_input()\n l=len(s)\n if(l==2):\n print \"YES\"\n else:\n if checkpal(s):\n print \"YES\"\n else:\n while s[0] == s[-1] and len(s)>2:\n\t s=s[1:-...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00075-of-00128_4__public__0000", "expected_output": {"kind": "stdout", "value": "YES\nNO\nYES\nYES\n"}, "input": {"kind": "stdin", "value": "4\naaa\nabc\nabdbca\nabba"}, "metadata": {}, "visibility": "public"}]
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
CODECHEF
[]
null
codecontests__test__code_contests_train.riegeli-00075-of-00128_77
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`,...
[{"code": "#include <bits/stdc++.h>\nusing namespace std;\nint n,cnt[30];\nchar S[5];\nint main()\n{\n\tscanf(\"%d\",&n);\n\tfor (int i=1;i<=n;i++)\n\t{\n\t\tscanf(\"%s\",S);\n\t\tcnt[S[0]-65]++;\n\t}\n\tprintf(\"AC x %d\\n\",cnt[0]);\n\tprintf(\"WA x %d\\n\",cnt['W'-65]);\n\tprintf(\"TLE x %d\\n\",cnt['T'-65]);\n\tpri...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00075-of-00128_77__public__0000", "expected_output": {"kind": "stdout", "value": "AC x 3\nWA x 1\nTLE x 2\nRE x 0"}, "input": {"kind": "stdin", "value": "6\nAC\nTLE\nAC\nAC\nWA\nTLE"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test_...
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
ATCODER
[""]
null
codecontests__test__code_contests_train.riegeli-00075-of-00128_79
Having learned the multiplication table, Takahashi can multiply two integers between 1 and 9 (inclusive) together. He cannot do any other calculation. Given are two integers A and B. If Takahashi can calculate A \times B, print the result; if he cannot, print `-1` instead. Constraints * 1 \leq A \leq 20 * 1 \leq B ...
[{"code": "import java.util.*;\n\nclass Main{\n public static void main(String[] args){\n Scanner scan = new Scanner(System.in);\n int a = scan.nextInt();\n int b = scan.nextInt();\n \n \n if(a>=1&&a<=9&&b>=1&&b<=9){\n System.out.println(a*b);\n }else{\n System.out.println(-1);\n }\n \...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00075-of-00128_79__public__0000", "expected_output": {"kind": "stdout", "value": "10"}, "input": {"kind": "stdin", "value": "2 5"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riegeli-00075-of-00128_79__publi...
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
ATCODER
[""]
null
codecontests__test__code_contests_train.riegeli-00075-of-00128_80
There is a staircase with N steps. Takahashi is now standing at the foot of the stairs, that is, on the 0-th step. He can climb up one or two steps at a time. However, the treads of the a_1-th, a_2-th, a_3-th, \ldots, a_M-th steps are broken, so it is dangerous to set foot on those steps. How many are there to climb ...
[{"code": "#include <bits/stdc++.h>\nusing namespace std;\ntypedef long long ll;\nint main(){\n\tll N,M,a,MOD=1e9+7;\n\tcin >> N >> M;\n\tvector<ll> X(N+5,0);\n\tfor(int i=0;i<M;i++){\n\t\tcin >> a;\n\t\tX[a]=-1;\n\t}\n\tX[0] = 1;\n\tif(X[1]!=-1)X[1] = 1;\n\tfor(int i=2;i<N+1;i++){\n\t\tif(X[i]==-1)continue;\n\t\tX[i] ...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00075-of-00128_80__public__0000", "expected_output": {"kind": "stdout", "value": "608200469"}, "input": {"kind": "stdin", "value": "100 5\n1\n23\n45\n67\n89"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.rieg...
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
ATCODER
[""]
null
codecontests__test__code_contests_train.riegeli-00075-of-00128_83
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd. Constraints * 1 ≤ a,b ≤ 10000 * a and b are integers. Input Input is given from Standard Input in the following format: a b Output If the product is odd, print `Odd`; if it is even, print `Even`. E...
[{"code": "#include <bits/stdc++.h>\nusing namespace std;\nint main(){\nint a,b;\ncin>>a>>b;\nif((a*b)%2==0)cout<<\"Even\";\nelse cout<<\"Odd\";\nreturn 0;\n}\n", "is_known_correct": true, "language": "cpp", "metadata": {}, "solution_id": "codecontests__test__code_contests_train.riegeli-00075-of-00128_83__ref__0000", "...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00075-of-00128_83__public__0000", "expected_output": {"kind": "stdout", "value": "Even"}, "input": {"kind": "stdin", "value": "3 4"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riegeli-00075-of-00128_83__pub...
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
ATCODER
[""]
null
codecontests__test__code_contests_train.riegeli-00075-of-00128_84
We have a sandglass consisting of two bulbs, bulb A and bulb B. These bulbs contain some amount of sand. When we put the sandglass, either bulb A or B lies on top of the other and becomes the upper bulb. The other bulb becomes the lower bulb. The sand drops from the upper bulb to the lower bulb at a rate of 1 gram per...
[{"code": "#include <bits/stdc++.h>\nusing namespace std;\n#define MAX 100007\nint r[MAX];\nint a[MAX];\nint b[MAX];\nint k1[MAX];\n\nint main(){\n\tint x,k,q;\n\tcin >> x >> k;\n\tfor(int i=1; i<=k; i++)cin >> r[i];\n\tr[k+1]=INT_MAX;\n\ta[0]=0;\n\tb[0]=x;\n\tk1[0]=1;\n\t// printf(\"%d %d %d\\n\",a[0],b[0],k1[0]);\n\t...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00075-of-00128_84__public__0000", "expected_output": {"kind": "stdout", "value": "19\n52\n91\n10\n58\n42\n100"}, "input": {"kind": "stdin", "value": "100\n5\n48 141 231 314 425\n7\n0 19\n50 98\n143 30\n231 55\n342 0\n365 100\n600 10"}, "metadata": {}, "visib...
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
ATCODER
[""]
null
codecontests__test__code_contests_train.riegeli-00075-of-00128_85
There are N students and M checkpoints on the xy-plane. The coordinates of the i-th student (1 \leq i \leq N) is (a_i,b_i), and the coordinates of the checkpoint numbered j (1 \leq j \leq M) is (c_j,d_j). When the teacher gives a signal, each student has to go to the nearest checkpoint measured in Manhattan distance. T...
[{"code": "import java.util.*;\nclass Main {\n public static void main(String[] args) {\n\tScanner sc = new Scanner(System.in);\n\tint n = Integer.parseInt(sc.next());\n\tint m = Integer.parseInt(sc.next());\n\tint[] ax = new int[n];\n\tint[] ay = new int[n];\n\tint[] bx = new int[m];\n\tint[] by = new int[m];\n\n\t...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00075-of-00128_85__public__0000", "expected_output": {"kind": "stdout", "value": "3\n1\n2"}, "input": {"kind": "stdin", "value": "3 4\n10 10\n-10 -10\n3 3\n1 2\n2 3\n3 5\n3 5"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_c...
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
ATCODER
[""]
null
codecontests__test__code_contests_train.riegeli-00075-of-00128_86
Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Not...
[{"code": "l=sorted(list(map(int,input().split())))\nprint(\"Yes\" if l[0]+l[1]==l[2] else \"No\")", "is_known_correct": true, "language": "python", "metadata": {}, "solution_id": "codecontests__test__code_contests_train.riegeli-00075-of-00128_86__ref__0000", "source": "benchmark"}, {"code": "a=sorted(map(int,input().s...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00075-of-00128_86__public__0000", "expected_output": {"kind": "stdout", "value": "Yes"}, "input": {"kind": "stdin", "value": "56 25 31"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riegeli-00075-of-00128_86_...
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
ATCODER
[""]
null
codecontests__test__code_contests_train.riegeli-00076-of-00128_0
Chef is judging a game called "Broken telephone". There are total N players taking part in the game. They are all sitting in a line. In the start of the game, first player is given a secret message written on a sheet of paper. Then they keep sending the message by whispering it to the player sitting immediate right to ...
[{"code": "T = input()\nfor i in xrange(T):\n\tN = input()\n\tA = map(int,raw_input().split())\n\tvisited = [0 for k in xrange(N)]\n\tcount = 0;\n\tfor j in xrange(N-1):\n\t\tif(A[j] != A[j+1]):\n\t\t\tif(visited[j] == 0):\n\t\t\t\tvisited[j] = 1\n\t\t\t\tcount += 1\n\t\t\tif(visited[j+1] == 0):\n\t\t\t\tvisited[j+1] =...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00076-of-00128_0__public__0000", "expected_output": {"kind": "stdout", "value": "4\n3\n0\n"}, "input": {"kind": "stdin", "value": "3\n7\n1 1 1 3 3 3 2\n5\n1 3 1 1 1\n4\n5 5 5 5"}, "metadata": {}, "visibility": "public"}]
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
CODECHEF
[]
null
codecontests__test__code_contests_train.riegeli-00076-of-00128_1
The Chef commutes to work every day using the city's underground metro. The schedule for the trains has recently been changed and he wants to know how long it will take to travel from the station nearest to his house and the station nearest to his restaurant. The Chef doesn't want to change the route he took before, ...
[{"code": "def train():\n tcases = int(raw_input())\n for i in range(tcases):\n n = int(raw_input())\n time = 0\n for j in range(n):\n path = raw_input()\n path = path.split()\n path = map(int, path)\n if time <= path[0]:\n time = pat...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00076-of-00128_1__public__0000", "expected_output": {"kind": "stdout", "value": "11\n8\n5\n"}, "input": {"kind": "stdin", "value": "3\n2\n0 4 7\n0 6 5\n2\n0 1 2\n6 2 10\n2\n1 2 3\n0 2 3"}, "metadata": {}, "visibility": "public"}]
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
CODECHEF
[]
null
codecontests__test__code_contests_train.riegeli-00076-of-00128_2
You are given an array A of integers of size N. You will be given Q queries where each query is represented by two integers L, R. You have to find the gcd(Greatest Common Divisor) of the array after excluding the part from range L to R inclusive (1 Based indexing). You are guaranteed that after excluding the part of th...
[{"code": "def gcd(x, y):\n while y > 0:\n x, y = y, x % y\n return x\n\nfor _ in range(input()):\n n, q = map(int, raw_input().split())\n a = map(int, raw_input().split())\n lg, rg = [0], [0]\n for v in a:\n lg.append(gcd(v, lg[-1]))\n for v in reversed(a):\n rg.append(gcd(v, ...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00076-of-00128_2__public__0000", "expected_output": {"kind": "stdout", "value": "3\n1\n2\n"}, "input": {"kind": "stdin", "value": "1\n3 3\n2 6 9\n1 1\n2 2\n2 3"}, "metadata": {}, "visibility": "public"}]
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
CODECHEF
[]
null
codecontests__test__code_contests_train.riegeli-00076-of-00128_3
A Little Elephant from the Zoo of Lviv likes lucky strings, i.e., the strings that consist only of the lucky digits 4 and 7. The Little Elephant has K favorite lucky strings A1, A2, ..., AK. He thinks that the lucky string S is good if either |S| ≥ 47 or for some j from 1 to K we have that Aj is a substring of S. The ...
[{"code": "def isLuckyString(b, A):\n\tif len(b)>=47:\n\t\tprint \"Good\"\n\t\treturn\n\tfor a in A:\n\t\tif a in b:\n\t\t\tprint \"Good\"\n\t\t\treturn\n\tprint \"Bad\"\n\n\n\nK, N = map(int, raw_input().split())\nA=[]\nfor _ in range(K):\n\tA.append(raw_input())\nfor _ in range(N):\n\tisLuckyString(raw_input(), A)", ...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00076-of-00128_3__public__0000", "expected_output": {"kind": "stdout", "value": "Good\nGood\nBad\nGood\n"}, "input": {"kind": "stdin", "value": "2 4\n47\n744\n7444\n447\n7774\n77777777777777777777777777777777777777777777774"}, "metadata": {}, "visibility": "...
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
CODECHEF
[]
null
codecontests__test__code_contests_train.riegeli-00076-of-00128_4
Naturally, the magical girl is very good at performing magic. She recently met her master wizard Devu, who gifted her R potions of red liquid, B potions of blue liquid, and G potions of green liquid. The red liquid potions have liquid amounts given by r[1], ..., r[R] liters. The green liquid potions have liquid am...
[{"code": "t =input()\nfor i in range(t):\n\tr,g,b,m =map(int,raw_input().split())\n\trlist =map(int,raw_input().split())\n\tlistg = map(int,raw_input().split())\n\tlistb = map(int,raw_input().split())\n\trmax = max(rlist)\n\tgmax = max(listg)\n\tbmax = max(listb)\n\tls=[rmax,gmax,bmax]\n\tfor j in xrange(m):\t\n\t\tls...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00076-of-00128_4__public__0000", "expected_output": {"kind": "stdout", "value": "2\n4\n4\n"}, "input": {"kind": "stdin", "value": "3\n1 1 1 1\n1\n2\n3\n1 1 1 1\n2\n4\n6\n3 2 2 2\n1 2 3\n2 4\n6 8"}, "metadata": {}, "visibility": "public"}]
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
CODECHEF
[]
null
codecontests__test__code_contests_train.riegeli-00076-of-00128_77
We have a grid of H rows and W columns of squares. The color of the square at the i-th row from the top and the j-th column from the left (1 \leq i \leq H, 1 \leq j \leq W) is given to you as a character c_{i,j}: the square is white if c_{i,j} is `.`, and black if c_{i,j} is `#`. Consider doing the following operation...
[{"code": "import java.util.*;\nimport static java.lang.Math.*;\n\nclass Main {\n final Scanner sc = new Scanner(System.in);\n\n public static void main(String[] args) {\n new Main().run();\n }\n\n private void run() {\n int h = sc.nextInt();\n int w = sc.nextInt();\n int k = sc....
[{"case_id": "codecontests__test__code_contests_train.riegeli-00076-of-00128_77__public__0000", "expected_output": {"kind": "stdout", "value": "1"}, "input": {"kind": "stdin", "value": "2 3 4\n..#"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riegeli-00076-of-00128_77_...
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
ATCODER
[""]
null
codecontests__test__code_contests_train.riegeli-00076-of-00128_79
Having learned the multiplication table, Takahashi can multiply two integers between 1 and 9 (inclusive) together. Given an integer N, determine whether N can be represented as the product of two integers between 1 and 9. If it can, print `Yes`; if it cannot, print `No`. Constraints * 1 \leq N \leq 100 * N is an int...
[{"code": "import java.util.*;\nimport java.util.stream.*;\n\nclass Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tSystem.out.println(IntStream.range(1, 10).anyMatch(i -> n % i == 0 && n / i <= 9) ? \"Yes\" : \"No\");\n\t}\n}\n", "is_known_co...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00076-of-00128_79__public__0000", "expected_output": {"kind": "stdout", "value": "Yes"}, "input": {"kind": "stdin", "value": "10"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riegeli-00076-of-00128_79__publi...
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
ATCODER
[""]
null
codecontests__test__code_contests_train.riegeli-00076-of-00128_80
There is a grid with H horizontal rows and W vertical columns, and there are obstacles on some of the squares. Snuke is going to choose one of the squares not occupied by an obstacle and place a lamp on it. The lamp placed on the square will emit straight beams of light in four cardinal directions: up, down, left, and...
[{"code": "import java.util.*;\nimport java.lang.*;\n\npublic class Main{\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint h = sc.nextInt();\n\t\tint w = sc.nextInt();\n\t\tString[] s = new String[h];\n\t\tfor (int i = 0; i < h; i++) {\n\t\t\ts[i] = sc.next();\n\t\t}\n\t\ti...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00076-of-00128_80__public__0000", "expected_output": {"kind": "stdout", "value": "8"}, "input": {"kind": "stdin", "value": "4 6\n#..#..\n.....#\n....#.\n#.#..."}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.r...
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
ATCODER
[""]
null
codecontests__test__code_contests_train.riegeli-00076-of-00128_83
AtCoDeer the deer has found two positive integers, a and b. Determine whether the concatenation of a and b in this order is a square number. Constraints * 1 ≤ a,b ≤ 100 * a and b are integers. Input Input is given from Standard Input in the following format: a b Output If the concatenation of a and b in this o...
[{"code": "import java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint a = sc.nextInt();\n\t\tint b = sc.nextInt();\n\t\tsc.close();\n\t\t\n\t\tint num = a * (int)Math.pow(10, (int)Math.log10(b)+1) + b;\n\t\tint sqrt = (int)Math.sqrt(nu...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00076-of-00128_83__public__0000", "expected_output": {"kind": "stdout", "value": "Yes"}, "input": {"kind": "stdin", "value": "1 21"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riegeli-00076-of-00128_83__pub...
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
ATCODER
[""]
null
codecontests__test__code_contests_train.riegeli-00076-of-00128_85
You are given an integer N. For two positive integers A and B, we will define F(A,B) as the larger of the following: the number of digits in the decimal notation of A, and the number of digits in the decimal notation of B. For example, F(3,11) = 2 since 3 has one digit and 11 has two digits. Find the minimum value of F...
[{"code": "#include<iostream>\nusing namespace std;\nint main() {\nlong long n;\ncin >> n;\nint ans = 10;\nfor(long long i = 1; i*i <= n; i++) {\nif(n%i != 0) continue;\nif(to_string(n/i).size() < ans) ans = to_string(n/i).size();\n}\ncout << ans << endl;\nreturn 0;\n}", "is_known_correct": true, "language": "cpp", "me...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00076-of-00128_85__public__0000", "expected_output": {"kind": "stdout", "value": "7"}, "input": {"kind": "stdin", "value": "1000003"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riegeli-00076-of-00128_85__pu...
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
ATCODER
[""]
null
codecontests__test__code_contests_train.riegeli-00076-of-00128_86
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...
[{"code": "w,h,n=map(int,input().split())\nx1=0\ny1=0\nfor i in range(n):\n x,y,a=map(int,input().split())\n if a==1:\n x1=max(x1,x)\n elif a==2:\n w=min(w,x)\n elif a==3:\n y1=max(y,y1)\n elif a==4:\n h=min(h,y)\nprint((w-x1)*(h-y1) if w > x1 and h > y1 else 0)", "is_known_co...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00076-of-00128_86__public__0000", "expected_output": {"kind": "stdout", "value": "0"}, "input": {"kind": "stdin", "value": "5 4 3\n2 1 1\n3 3 4\n1 4 2"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riegeli-00...
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
ATCODER
[""]
null
codecontests__test__code_contests_train.riegeli-00077-of-00128_1
Lira is now very keen on compiler development. :) She knows that one of the most important components of a compiler, is its parser. A parser is, in simple terms, a software component that processes text, and checks it's semantic correctness, or, if you prefer, if the text is properly built. As an example, in declaring...
[{"code": "import sys\n\nRL = sys.stdin.readline\n\nT = int(RL())\n\nfor i in xrange(T):\n inp = RL()\n stack = 0\n strlen = len(inp)\n count = 0\n for j in xrange(strlen):\n if inp[j] == '<':\n stack += 1\n elif inp[j] == '>':\n if stack == 0:\n break\n...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00077-of-00128_1__public__0000", "expected_output": {"kind": "stdout", "value": "4\n0\n2\n"}, "input": {"kind": "stdin", "value": "3\n<<>>\n><\n<>>>"}, "metadata": {}, "visibility": "public"}]
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
CODECHEF
[]
null
codecontests__test__code_contests_train.riegeli-00077-of-00128_2
Tuzik is a little dog. But despite the fact he is still a puppy he already knows about the pretty things that coins are. He knows that for every coin he can get very tasty bone from his master. He believes that some day he will find a treasure and have loads of bones. And finally he found something interesting. A woode...
[{"code": "# @author Kilari Teja\n# GDOG\n\n\nPossibles = [100, 50, 10, 5, 2, 1]\nfor _ in xrange(int(raw_input().strip())):\n\tBucks = map(int, raw_input().strip().split(\" \"))\n\n\tMaxBucks = 0\n\tfor People in xrange(1, Bucks[1] + 1):\n\t\tif Bucks[0]%People > MaxBucks:\n\t\t\tMaxBucks = Bucks[0]%People\n\n\tprint ...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00077-of-00128_2__public__0000", "expected_output": {"kind": "stdout", "value": "1\n2\n"}, "input": {"kind": "stdin", "value": "2\n5 2\n11 3"}, "metadata": {}, "visibility": "public"}]
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
CODECHEF
[]
null
codecontests__test__code_contests_train.riegeli-00077-of-00128_77
Quickly after finishing the tutorial of the online game ATChat, you have decided to visit a particular place with N-1 players who happen to be there. These N players, including you, are numbered 1 through N, and the friendliness of Player i is A_i. The N players will arrive at the place one by one in some order. To ma...
[{"code": "n,*a=map(int,open(0).read().split())\na.sort()\na=a[::-1]\nans=0\nfor i in range(1,n):\n ans+=a[i//2]\nprint(ans)", "is_known_correct": true, "language": "python", "metadata": {}, "solution_id": "codecontests__test__code_contests_train.riegeli-00077-of-00128_77__ref__0000", "source": "benchmark"}, {"code"...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00077-of-00128_77__public__0000", "expected_output": {"kind": "stdout", "value": "7"}, "input": {"kind": "stdin", "value": "4\n2 2 1 3"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riegeli-00077-of-00128_77_...
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
ATCODER
[""]
null
codecontests__test__code_contests_train.riegeli-00077-of-00128_79
Takahashi is standing on a multiplication table with infinitely many rows and columns. The square (i,j) contains the integer i \times j. Initially, Takahashi is standing at (1,1). In one move, he can move from (i,j) to either (i+1,j) or (i,j+1). Given an integer N, find the minimum number of moves needed to reach a ...
[{"code": "N = int(input())\nn = 1\nlast = 0\nwhile n**2 <= N:\n if N%n == 0 :\n last = n\n n += 1\nprint(last + N//last - 2)", "is_known_correct": true, "language": "python", "metadata": {}, "solution_id": "codecontests__test__code_contests_train.riegeli-00077-of-00128_79__ref__0000", "source": "benchmark"}, {"co...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00077-of-00128_79__public__0000", "expected_output": {"kind": "stdout", "value": "10000000018"}, "input": {"kind": "stdin", "value": "10000000019"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riegeli-00077-o...
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
ATCODER
[""]
null
codecontests__test__code_contests_train.riegeli-00077-of-00128_80
There is an arithmetic progression with L terms: s_0, s_1, s_2, ... , s_{L-1}. The initial term is A, and the common difference is B. That is, s_i = A + B \times i holds. Consider the integer obtained by concatenating the terms written in base ten without leading zeros. For example, the sequence 3, 7, 11, 15, 19 woul...
[{"code": "#include <bits/stdc++.h>\n#define rep(i,n) for (int i = 0; i < n; ++i)\nusing namespace std;\ntypedef long long ll;\n\nint mod;\nstruct mint {\n ll x;\n mint(ll x=0):x(x%mod){}\n mint& operator+=(const mint a) {\n (x += a.x) %= mod;\n return *this;\n }\n mint& operator-=(const mint a) {\n (x +=...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00077-of-00128_80__public__0000", "expected_output": {"kind": "stdout", "value": "891011"}, "input": {"kind": "stdin", "value": "4 8 1 1000000"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riegeli-00077-of-0...
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
ATCODER
[""]
null
codecontests__test__code_contests_train.riegeli-00077-of-00128_83
AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i. If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1...
[{"code": "#include<bits/stdc++.h>\nusing namespace std;\nint n,a,b,c;\nint main()\n{\n\tscanf(\"%d\",&n);\n\tfor(int i=1;i<=n;i++)\n\t{\n\t\tscanf(\"%d%d%d\",&a,&b,&c);\n\t\tb=max(b,-b),c=max(c,-c);\n\t\tif((b+c)%2!=a%2)\n\t\t{\n\t\t\tcout<<\"No\\n\";\n\t\t\treturn 0;\n\t\t}\n\t\tif(b+c>a)\n\t\t{\n\t\t\tcout<<\"No\\n\...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00077-of-00128_83__public__0000", "expected_output": {"kind": "stdout", "value": "Yes"}, "input": {"kind": "stdin", "value": "2\n3 1 2\n6 1 1"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riegeli-00077-of-00...
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
ATCODER
[""]
null
codecontests__test__code_contests_train.riegeli-00077-of-00128_85
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...
[{"code": "import java.io.*;\nimport java.util.*;\nimport java.math.BigDecimal;\n \npublic class Main {\n public static long combination(int n, int r) {\n r = Math.min(r, n - r);\n if (r == 1) {\n return n;\n }\n \n long sum = 1;\n for (int i = 1; i <= r; i++) {\n ...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00077-of-00128_85__public__0000", "expected_output": {"kind": "stdout", "value": "15.000000\n3"}, "input": {"kind": "stdin", "value": "4 2 3\n10 20 10 10"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riegeli...
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
ATCODER
[""]
null
codecontests__test__code_contests_train.riegeli-00077-of-00128_86
Two foxes Jiro and Saburo are playing a game called 1D Reversi. This game is played on a board, using black and white stones. On the board, stones are placed in a row, and each player places a new stone to either end of the row. Similarly to the original game of Reversi, when a white stone is placed, all black stones b...
[{"code": "s=input()\na=s[0]\nc=0\nfor i in range(1,len(s)):\n if s[i]!=a:\n c+=1\n a=s[i]\nprint(c)", "is_known_correct": true, "language": "python", "metadata": {}, "solution_id": "codecontests__test__code_contests_train.riegeli-00077-of-00128_86__ref__0000", "source": "benchmark"}, {"code": "import java.util....
[{"case_id": "codecontests__test__code_contests_train.riegeli-00077-of-00128_86__public__0000", "expected_output": {"kind": "stdout", "value": "0"}, "input": {"kind": "stdin", "value": "WWWWWW"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riegeli-00077-of-00128_86__pub...
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
ATCODER
[""]
null
codecontests__test__code_contests_train.riegeli-00078-of-00128_0
One day Alice visited Byteland to purchase jewels for her upcoming wedding anniversary. In Byteland, every Jewelry shop has their own discount methods to attract the customers. One discount method called Buy1-Get1 caught Alice's attention. That is, Alice buys one jewel, then she can get one additional jewel with the sa...
[{"code": "from collections import Counter\nfor _ in xrange(int(raw_input())):\n\tst=raw_input()\n\tst=st.strip()\n\ta=[]\n\tsu=0\n\tfor let in st:\n\t\ta.append(let)\n\tcounts=Counter(a)\n\tfor key in counts:\n\t\tif key!=\" \" and counts[key]%2==0:\n\t\t\tcounts[key]=counts[key]/2\n\t\t\tcontinue\n\t elif key!...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00078-of-00128_0__public__0000", "expected_output": {"kind": "stdout", "value": "2\n3\n2\n1\n"}, "input": {"kind": "stdin", "value": "4\nssss\nssas\nsa\ns"}, "metadata": {}, "visibility": "public"}]
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
CODECHEF
[]
null
codecontests__test__code_contests_train.riegeli-00078-of-00128_2
Problem Statement Chef has a sequence of N segments: [L1, R1], [L2, R2], ..., [LN, RN]. He wants to transform the first segment to the last one (with index N). His plan is to do this big deal with a number of transformations: firstly he will transform the first segment to the second one, then to the third one, then to ...
[{"code": "t=input()\nwhile t:\n t-=1\n n=input()\n l=[0]*(n+1)\n r=[0]*(n+1)\n for i in range(n):\n l[i],r[i]=map(int,raw_input().split())\n i=0\n count=0\n ans=\"\"\n while i<(n-1):\n if l[i+1]>=r[i]:\n ans=ans+\"L+\"*(r[i]-l[i]-1)+\"R+L+\"*(l[i+1]-r[i]+1)+\"R+\"*(r...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00078-of-00128_2__public__0000", "expected_output": {"kind": "stdout", "value": "9\nR+L+R+L+R+L+R+L+R+\n0\n\n1\nR+\n13\nL-R-L-L-L-L-R-R-R-R-L+R+L+"}, "input": {"kind": "stdin", "value": "4\n3\n-1 0\n0 1\n3 5\n1\n0 1\n3\n-2 -1\n-2 -1\n-2 0\n4\n4 6\n3 5\n-1 1\...
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
CODECHEF
[]
null
codecontests__test__code_contests_train.riegeli-00078-of-00128_3
Problem Statement Maxim likes dividers of the numbers. Also Maxim is fond of lucky numbers of small elephant from Lviv city.   If you remember, lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky, 5, 17, 467 — aren't.   Now ...
[{"code": "'''\nMaxim and Dividers\n\nProblem code: MAANDI\n\nProblem Statement\n\nMaxim likes dividers of the numbers. Also Maxim is fond of lucky \nnumbers of small elephant from Lviv city.\n\nIf you remember, lucky numbers are positive integers whose decimal \nrepresentation contains only the lucky digits 4 and 7. F...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00078-of-00128_3__public__0000", "expected_output": {"kind": "stdout", "value": "0\n0\n0\n1\n0\n0\n1\n1\n0\n0\n"}, "input": {"kind": "stdin", "value": "10\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10"}, "metadata": {}, "visibility": "public"}]
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
CODECHEF
[]
null
codecontests__test__code_contests_train.riegeli-00078-of-00128_77
Given are N integers A_1,\ldots,A_N. We will choose exactly K of these elements. Find the maximum possible product of the chosen elements. Then, print the maximum product modulo (10^9+7), using an integer between 0 and 10^9+6 (inclusive). Constraints * 1 \leq K \leq N \leq 2\times 10^5 * |A_i| \leq 10^9 Input Inp...
[{"code": "import operator\nfrom functools import reduce\nN, K = map(int, input().split())\nA = list(map(int, input().split()))\nMOD = 10 ** 9 + 7\n\npositives = [a for a in A if a > 0]\nnegatives = [a for a in A if a < 0]\npositive_cnt = len(positives)\nnegative_cnt = len(negatives)\nzero_cnt = A.count(0)\n\n\nif 2 * ...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00078-of-00128_77__public__0000", "expected_output": {"kind": "stdout", "value": "12"}, "input": {"kind": "stdin", "value": "4 2\n1 2 -3 -4"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riegeli-00078-of-0012...
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
ATCODER
[""]
null
codecontests__test__code_contests_train.riegeli-00078-of-00128_79
Takahashi has a water bottle with the shape of a rectangular prism whose base is a square of side a~\mathrm{cm} and whose height is b~\mathrm{cm}. (The thickness of the bottle can be ignored.) We will pour x~\mathrm{cm}^3 of water into the bottle, and gradually tilt the bottle around one of the sides of the base. Whe...
[{"code": "import math\na,b,x = map(int,input().split())\nv = a*a*b\nif 2*x <= v:\n ans = math.atan((a*b*b)/(2*x))\nelse:\n ans = math.atan((2*(v-x)/(a*a))/a)\nprint(math.degrees(ans))\n", "is_known_correct": true, "language": "python", "metadata": {}, "solution_id": "codecontests__test__code_contests_train.riege...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00078-of-00128_79__public__0000", "expected_output": {"kind": "stdout", "value": "45.0000000000"}, "input": {"kind": "stdin", "value": "2 2 4"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riegeli-00078-of-00...
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
ATCODER
[""]
null
codecontests__test__code_contests_train.riegeli-00078-of-00128_83
AtCoDeer is thinking of painting an infinite two-dimensional grid in a checked pattern of side K. Here, a checked pattern of side K is a pattern where each square is painted black or white so that each connected component of each color is a K × K square. Below is an example of a checked pattern of side 3: cba927b2484f...
[{"code": "#include<cstdio>\n#include<vector>\n#include<cstring>\n#include<algorithm>\nusing namespace std;\nconst int MAXN=1005;\nint map[MAXN][MAXN];\nint n,k;\nint main()\n{\n\tscanf(\"%d %d\",&n,&k);\n\tint mi=n,ma=0;\n\tfor(int i=1;i<=n;i++)\n\t{\n\t\tlong long xx=0,yy=0;\n\t\tchar c;\n\t\tbool t;\n\t\tscanf(\"%I6...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00078-of-00128_83__public__0000", "expected_output": {"kind": "stdout", "value": "4"}, "input": {"kind": "stdin", "value": "6 2\n1 2 B\n2 1 W\n2 2 B\n1 0 B\n0 6 W\n4 5 W"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contes...
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
ATCODER
[""]
null
codecontests__test__code_contests_train.riegeli-00078-of-00128_85
Two deer, AtCoDeer and TopCoDeer, are playing a game called Honest or Dishonest. In this game, an honest player always tells the truth, and an dishonest player always tell lies. You are given two characters a and b as the input. Each of them is either `H` or `D`, and carries the following information: If a=`H`, AtCoDe...
[{"code": "#include<bits/stdc++.h>\nusing namespace std;\nint main(){\n char a,b;\n cin>>skipws>>a>>b;\n int c=(a=='H')^(b=='H');\n cout<<(c?'D':'H')<<endl;\n}", "is_known_correct": true, "language": "cpp", "metadata": {}, "solution_id": "codecontests__test__code_contests_train.riegeli-00078-of-00128_85__ref__0000"...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00078-of-00128_85__public__0000", "expected_output": {"kind": "stdout", "value": "H"}, "input": {"kind": "stdin", "value": "D D"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riegeli-00078-of-00128_85__public...
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
ATCODER
[""]
null
codecontests__test__code_contests_train.riegeli-00078-of-00128_86
There are N towns located in a line, conveniently numbered 1 through N. Takahashi the merchant is going on a travel from town 1 to town N, buying and selling apples. Takahashi will begin the travel at town 1, with no apple in his possession. The actions that can be performed during the travel are as follows: * Move: ...
[{"code": "#include <iostream>\n#include <vector>\nusing namespace std;\ntypedef long long ll;\nint main(){\n\tint n,t;\tcin>>n>>t;\n\tvector<int> a(n);\n\tfor(int i=0;i<n;i++)\tcin>>a[i];\n\tint profit=0,sml=a[0],pattern=0;\n\tfor(int i=1;i<n;i++){\n\t\tif(sml>a[i]){\n\t\t\tsml=a[i];\n\t\t}\n\t\telse if(a[i]-sml>profi...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00078-of-00128_86__public__0000", "expected_output": {"kind": "stdout", "value": "2"}, "input": {"kind": "stdin", "value": "5 8\n50 30 40 10 20"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riegeli-00078-of-...
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
ATCODER
[""]
null
codecontests__test__code_contests_train.riegeli-00079-of-00128_1
Little Elephant was fond of inventing new games. After a lot of research, Little Elephant came to know that most of the animals in the forest were showing less interest to play the multi-player games.Little Elephant had started to invent single player games, and succeeded in inventing the new single player game named C...
[{"code": "for i in range(int(raw_input())):\n\tfor j in range(int(raw_input())):\n\t\ti,n,q = map(int,raw_input().split())\n\t\tif n % 2 == 0:\n\t\t\tprint n/2\n\t\telse:\n\t\t\tif i == q:\n\t\t\t\tprint n/2\n\t\t\telse:\n\t\t\t\tprint n/2 + 1", "is_known_correct": true, "language": "python", "metadata": {}, "solution...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00079-of-00128_1__public__0000", "expected_output": {"kind": "stdout", "value": "2\n3\n"}, "input": {"kind": "stdin", "value": "1\n2\n1 5 1\n1 5 2"}, "metadata": {}, "visibility": "public"}]
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
CODECHEF
[]
null
codecontests__test__code_contests_train.riegeli-00079-of-00128_2
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...
[{"code": "#!/usr/bin/python \nt=input()\nfor i in range(t):\n\tgh,gm=map(int,raw_input().split(':'))\n\tch,cm=map(int,raw_input().split(':'))\t\n\tgh=gh*60+gm;\n\tch=ch*60+cm;\n\tdist=input()\n\tif(2*dist<=(gh-ch)) :\n\t\tprint float(gh-ch+dist) ,float(gh-ch);\n\telse:\n\t\tprint float(gh-ch+dist), float(gh-ch+2*dist)...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00079-of-00128_2__public__0000", "expected_output": {"kind": "stdout", "value": "70.0 60.0\n90.0 60.0\n120.0 90.0\n"}, "input": {"kind": "stdin", "value": "3\n10:00\n09:00\n10\n10:00\n09:00\n30\n10:00\n09:00\n60"}, "metadata": {}, "visibility": "public"}]
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
CODECHEF
[]
null
codecontests__test__code_contests_train.riegeli-00079-of-00128_3
Chef's new hobby is painting, but he learned the fact that it's not easy to paint 2D pictures in a hard way, after wasting a lot of canvas paper, paint and of course time. From now on, he decided to paint 1D pictures only. Chef's canvas is N millimeters long and is initially all white. For simplicity, colors will be re...
[{"code": "for _ in range(int(raw_input())):\n n = int(raw_input())\n a = map(int, raw_input().split())\n ans = \"No\"\n c = 1\n p = a[0]\n for i in a[1:]:\n if i == p:\n c += 1\n if c == 3:\n ans = \"Yes\"\n break\n else:\n ...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00079-of-00128_3__public__0000", "expected_output": {"kind": "stdout", "value": "Yes\nYes\nNo\n"}, "input": {"kind": "stdin", "value": "3\n4\n1 5 5 5\n4\n1 1 1 5\n3\n5 5 2"}, "metadata": {}, "visibility": "public"}]
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
CODECHEF
[]
null
codecontests__test__code_contests_train.riegeli-00079-of-00128_5
Chef is sitting in a very boring lecture, waiting for it to end. He has recently asked his friend about the time, and instead of the straightforward answer, his friend, being an absolute jerk, told him the absolute value of angle between hour and minute hands. But that is obviously not what he wanted to know, so he a...
[{"code": "from collections import defaultdict as dd\n \ndef pre_times():\n\trs=dd(list)\n\tfor h in xrange(12):\n\t\tha=0.0+h*30\n\t\tma=0.0\n\t\tfor m in xrange(60):\n \n\t\t\tcalculated_angle=min(abs(ha-ma),360-abs(ha-ma))\n\t\t\tindex=int(calculated_angle)\n\t\t\trs[index].append({calculated_angle:[h,m]})\n \n\t\t\...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00079-of-00128_5__public__0000", "expected_output": {"kind": "stdout", "value": "00:00\n01:00\n11:00\n"}, "input": {"kind": "stdin", "value": "2\n0\n30"}, "metadata": {}, "visibility": "public"}]
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
CODECHEF
[]
null
codecontests__test__code_contests_train.riegeli-00079-of-00128_72
Some people are just moody, you just cannot reason with them. Same goes with Natural Numbers. Some of them ultimely want to become 1 or 4 and will evolve infinite times if they have to, to become what they want to. To evolve, they use a function F such that N = F(N). Function F(N) is defined as : F(N) = sum_of_digits(...
[{"code": "mem={}\ndef sum_digits3(n):\n n=n**2\n r = 0\n while n:\n r, n = r + n % 10, n // 10\n return r\n\ndef findnature(n):\n if(mem.has_key(n)):return mem[n]\n if(n==1 or n==4): return 1\n if(n==9 or n==13): return -1\n ans=findnature(sum_digits3(n))\n mem[n]=ans\n return ans\n\nfo...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00079-of-00128_72__public__0000", "expected_output": {"kind": "stdout", "value": "YES\nYES\nNO\nYES"}, "input": {"kind": "stdin", "value": "4\n1\n2\n3\n8\n\nSAMPLE"}, "metadata": {}, "visibility": "public"}]
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
HACKEREARTH
[]
null
codecontests__test__code_contests_train.riegeli-00079-of-00128_77
We have a tree with N vertices and N-1 edges, respectively numbered 1, 2,\cdots, N and 1, 2, \cdots, N-1. Edge i connects Vertex u_i and v_i. For integers L, R (1 \leq L \leq R \leq N), let us define a function f(L, R) as follows: * Let S be the set of the vertices numbered L through R. f(L, R) represents the number ...
[{"code": "#include<bits/stdc++.h>\nusing namespace std;\nconst int N=2e5+5;\ntypedef long long ll;\nint n;\nint main()\n{\n scanf(\"%d\",&n);\n ll ans=0;\n for(int i=1;i<n;i++)\n {\n int x,y;scanf(\"%d%d\",&x,&y);\n if(x>y) swap(x,y);\n ans+=(ll)x*(n-y+1);\n }\n ll res=0;\n fo...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00079-of-00128_77__public__0000", "expected_output": {"kind": "stdout", "value": "3"}, "input": {"kind": "stdin", "value": "2\n1 2"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riegeli-00079-of-00128_77__pub...
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
ATCODER
[""]
null
codecontests__test__code_contests_train.riegeli-00079-of-00128_79
Takahashi will take part in an eating contest. Teams of N members will compete in this contest, and Takahashi's team consists of N players numbered 1 through N from youngest to oldest. The consumption coefficient of Member i is A_i. In the contest, N foods numbered 1 through N will be presented, and the difficulty of ...
[{"code": "#include <iostream>\n#include <cstdio>\n#include <algorithm>\n#define N 200005\nusing namespace std;\n\ntypedef long long ll;\nll n, k, l, r = 1e18, m, a[N], b[N];\n\nbool f(ll p) {\n\tll i, t = k;\n\tfor (i = 0; i < n; i++) {\n\t\tt -= max(0LL, (a[i] * b[i] - p + b[i] - 1) / b[i]);\n\t\tif (t < 0) return 0;...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00079-of-00128_79__public__0000", "expected_output": {"kind": "stdout", "value": "0"}, "input": {"kind": "stdin", "value": "3 8\n4 2 1\n2 3 1"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riegeli-00079-of-00...
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
ATCODER
[""]
null
codecontests__test__code_contests_train.riegeli-00079-of-00128_85
AtCoDeer the deer found two rectangles lying on the table, each with height 1 and width W. If we consider the surface of the desk as a two-dimensional plane, the first rectangle covers the vertical range of [0,1] and the horizontal range of [a,a+W], and the second rectangle covers the vertical range of [1,2] and the ho...
[{"code": "#include <iostream>\nusing namespace std;\nint main(){\n int w, a, b; cin >> w >> a >> b;\n if(abs(a-b)<=w) cout << 0 << endl;\n else cout << abs(a-b)-w << endl;\n return 0;\n}", "is_known_correct": true, "language": "cpp", "metadata": {}, "solution_id": "codecontests__test__code_contests_train.r...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00079-of-00128_85__public__0000", "expected_output": {"kind": "stdout", "value": "1"}, "input": {"kind": "stdin", "value": "3 2 6"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riegeli-00079-of-00128_85__publ...
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
ATCODER
[""]
null
codecontests__test__code_contests_train.riegeli-00079-of-00128_86
We have a tree with N vertices. The vertices are numbered 1, 2, ..., N. The i-th (1 ≦ i ≦ N - 1) edge connects the two vertices A_i and B_i. Takahashi wrote integers into K of the vertices. Specifically, for each 1 ≦ j ≦ K, he wrote the integer P_j into vertex V_j. The remaining vertices are left empty. After that, he...
[{"code": "#include <bits/stdc++.h>\nusing namespace std;\n\nconst int N = 100005;\nconst int inf = 1e6;\n\nint n, k;\nvector<int> G[N];\nint L[N], R[N], a[N];\nint parity[N];\n\nvoid dfs(int u, int p) {\n\tL[u] = -inf, R[u] = inf;\n\tif (a[u] != -1) L[u] = R[u] = a[u], parity[u] = (a[u] & 1);\n\tfor (int v : G[u]) if ...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00079-of-00128_86__public__0000", "expected_output": {"kind": "stdout", "value": "Yes\n0\n-1\n-2\n-3"}, "input": {"kind": "stdin", "value": "4\n1 2\n2 3\n3 4\n1\n1 0"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_t...
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
ATCODER
[""]
null
codecontests__test__code_contests_train.riegeli-00080-of-00128_0
How many ways are there to place a black and a white knight on an N * M chessboard such that they do not attack each other? The knights have to be placed on different squares. A knight can move two squares horizontally and one square vertically, or two squares vertically and one square horizontally. The knights attack ...
[{"code": "#!/usr/bin/python\n# coding: utf-8\n\nt=int(raw_input())\nfor i in range(t):\n\tn,m=raw_input().split(' ')\n\tn=int(n)\n\tm=int(m)\n\tif(n>1 and m>1):\n\t\tans=((n*m) * (n*m-1)) - (4*((n-1)*(m-2) + (n-2)*(m-1))) #nm*nm -9nm +12m +12n -16\n\telse:\n\t\tif(n==1):\n\t\t\tans=m*(m-1)\n\t\telse:\n\t\t\tans=n*(n-1...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00080-of-00128_0__public__0000", "expected_output": {"kind": "stdout", "value": "12\n26\n312\n"}, "input": {"kind": "stdin", "value": "3\n2 2\n2 3\n4 5"}, "metadata": {}, "visibility": "public"}]
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
CODECHEF
[]
null
codecontests__test__code_contests_train.riegeli-00080-of-00128_1
As you might know, cooking is the process of taking a food item and subjecting it to various processes(like heating, roasting, baking etc). A food item gets prepared after it has been subjected to exactly N processes. The order in which the processes are applied matters(heating and then baking is different from baking ...
[{"code": "from sys import stdin\n \nMOD = 1000000007\n \nfor trial in xrange(int(stdin.readline())):\n N,K = map(int,stdin.readline().split())\n Kmod = K%MOD\n K1mod=(K-1)%MOD\n K2mod=(K-2)%MOD\n if K==1: print 0\n elif K==2: print 2\n else:\n inner = ((Kmod*K1mod*K1mod)%MOD + (Kmod*K1mod*K...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00080-of-00128_1__public__0000", "expected_output": {"kind": "stdout", "value": "2\n18\n6"}, "input": {"kind": "stdin", "value": "3\n2 2\n2 3\n1 3"}, "metadata": {}, "visibility": "public"}]
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
CODECHEF
[]
null
codecontests__test__code_contests_train.riegeli-00080-of-00128_2
Problem Statement Chef studies combinatorics. He tries to group objects by their rang (a positive integer associated with each object). He also gives the formula for calculating the number of different objects with rang N as following: the number of different objects with rang N = F(N) = A0 + A1 * N + A2 * N^2 + A3 * N...
[{"code": "mod = 1000000007\ncomb_cache = {}\ndef combinations(n, r):\n if r < (n // 2): r = n - r\n if (n, r) in comb_cache: return comb_cache[(n, r)]\n comb = 1\n for i in xrange(r + 1, n + 1): comb *= i\n for i in xrange(2, n - r + 1): comb /= i\n comb_cache[(n, r)] = comb % mod\n return comb\n\nF_cach...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00080-of-00128_2__public__0000", "expected_output": {"kind": "stdout", "value": "1\n3\n3\n213986343\n"}, "input": {"kind": "stdin", "value": "4\n1 0 0 0\n1\n1 0 0 0\n3\n0 1 0 0\n2\n2 3 1 4\n10"}, "metadata": {}, "visibility": "public"}]
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
CODECHEF
[]
null
codecontests__test__code_contests_train.riegeli-00080-of-00128_4
Tuzik and his master Vanka are playing some unusual game. Initially there are two stacks of nuts. The first stack contains A nuts and the second contains B nuts. A player's move consists of two steps: Choose one stack and eat it. Split the other stack into two new stacks. If a player can't split it he loses (if stack...
[{"code": "T = int(raw_input())\nwhile T > 0:\n a = raw_input()\n a = a.split(' ')\n A = int(a[0])\n B = int(a[1])\n if A%2 !=0 and B%2 !=0:\n print \"Vanka\"\n else:\n print 'Tuzik'\n\n T = T - 1", "is_known_correct": true, "language": "python", "metadata": {}, "solution_id": "codec...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00080-of-00128_4__public__0000", "expected_output": {"kind": "stdout", "value": "Vanka\nTuzik\n"}, "input": {"kind": "stdin", "value": "2\n1 1\n1 2"}, "metadata": {}, "visibility": "public"}]
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
CODECHEF
[]
null
codecontests__test__code_contests_train.riegeli-00080-of-00128_79
There is a cave consisting of N rooms and M one-directional passages. The rooms are numbered 1 through N. Takahashi is now in Room 1, and Room N has the exit. The i-th passage connects Room s_i and Room t_i (s_i < t_i) and can only be traversed in the direction from Room s_i to Room t_i. It is known that, for each roo...
[{"code": "#include<bits/stdc++.h>\nusing namespace std;\ndouble ans=999999999;\ndouble inf=999999999;\nint n,m;\ndouble dp[601];\nvector<int>e[601];\nvoid get_dp(int x)\n{\n\tmemset(dp,0,sizeof(dp));\n\tdp[n]=0;\n\tfor(int i=n-1;i>=1;i--)\n\t{\n\t\tint tot=0;\n\t\tdouble mx=0;\n\t\tfor(int j=0;j<e[i].size();j++)\n\t\t...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00080-of-00128_79__public__0000", "expected_output": {"kind": "stdout", "value": "1.5000000000"}, "input": {"kind": "stdin", "value": "4 6\n1 4\n2 3\n1 3\n1 2\n3 4\n2 4"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contest...
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
ATCODER
[""]
null
codecontests__test__code_contests_train.riegeli-00080-of-00128_85
AtCoDeer the deer has N cards with positive integers written on them. The number on the i-th card (1≤i≤N) is a_i. Because he loves big numbers, he calls a subset of the cards good when the sum of the numbers written on the cards in the subset, is K or greater. Then, for each card i, he judges whether it is unnecessary...
[{"code": "#include <bits/stdc++.h>\nusing namespace std;\n\nint main() {\n cin.tie(0);\n ios::sync_with_stdio(false);\n \n int n, k;\n cin >> n >> k;\n \n vector<int> a(n);\n for (int i = 0; i < n; i++) cin >> a.at(i);\n \n sort(a.begin(), a.end());\n \n int l = -1, r = n;\n while (r - l > 1) {\n int m...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00080-of-00128_85__public__0000", "expected_output": {"kind": "stdout", "value": "5"}, "input": {"kind": "stdin", "value": "5 400\n3 1 4 1 5"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riegeli-00080-of-001...
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
ATCODER
[""]
null
codecontests__test__code_contests_train.riegeli-00081-of-00128_1
Chef is on a vacation these days, so his friend Chefza is trying to solve Chef's everyday tasks. Today's task is to make a sweet roll. Rolls are made by a newly invented cooking machine. The machine is pretty universal - it can make lots of dishes and Chefza is thrilled about this. To make a roll, Chefza has to set all...
[{"code": "test_cases = int(raw_input())\n\nfor i in range(test_cases):\n AB = raw_input().split()\n A = int(AB[0])\n B = int(AB[1])\n counter = 0\n while (A != B):\n if (B%A == 0):\n A=A*2\n counter += 1\n else:\n A=A/2\n counter += 1\n print counter", "is_known_correct": true, "langua...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00081-of-00128_1__public__0000", "expected_output": {"kind": "stdout", "value": "0\n1\n4\n2\n2\n2\n"}, "input": {"kind": "stdin", "value": "6\n1 1\n2 4\n3 8\n4 16\n4 1\n1 4"}, "metadata": {}, "visibility": "public"}]
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
CODECHEF
[]
null
codecontests__test__code_contests_train.riegeli-00081-of-00128_3
Chef Ciel wants to put a fancy neon signboard over the entrance of her restaurant. She has not enough money to buy the new one so she bought some old neon signboard through the internet. Ciel was quite disappointed when she received her order - some of its letters were broken. But she realized that this is even better ...
[{"code": "for t in xrange(int(raw_input())):\n line = list(raw_input())\n length = len(line)\n x = length-1\n while x > 2:\n tmp = [line[x], line[x-1], line[x-2], line[x-3]]\n if (\n (tmp[0] == '?' or tmp[0] == 'F') and\n (tmp[1] == '?' or tmp[1] == 'E') and\n ...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00081-of-00128_3__public__0000", "expected_output": {"kind": "stdout", "value": "CHEFCIELISACHEF\nCHEFCIELISOURCHEF\nTAKEITEASY\nCHEFCHEF\nAAACHEF\n"}, "input": {"kind": "stdin", "value": "5\n????CIELIS???E?\n????CIELISOUR???F\nT?KEITE?SY\n????????\n???C???"...
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
CODECHEF
[]
null
codecontests__test__code_contests_train.riegeli-00081-of-00128_5
The game of billiards involves two players knocking 3 balls around on a green baize table. Well, there is more to it, but for our purposes this is sufficient. The game consists of several rounds and in each round both players obtain a score, based on how well they played. Once all the rounds have been played, the tota...
[{"code": "t = int(raw_input())\nscr1=0\nscr2=0\nma = 0\nflag = 0\nfor i in xrange(t):\n\ts1,s2 = map(int,raw_input().split(' '))\n\tscr1+=s1\n\tscr2+=s2\n\tif(scr1>scr2):\n\t\ttemp = scr1-scr2\n\t\tif(temp > ma):\n\t\t\tma = temp\n\t\t\tflag = 1\n\telse:\n\t\ttemp = scr2-scr1\n\t\tif(temp > ma):\n\t\t\tma = temp\n\t\t...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00081-of-00128_5__public__0000", "expected_output": {"kind": "stdout", "value": "1 58\n"}, "input": {"kind": "stdin", "value": "5\n140 82\n89 134\n90 110\n112 106\n88 90"}, "metadata": {}, "visibility": "public"}]
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
CODECHEF
[]
null
codecontests__test__code_contests_train.riegeli-00081-of-00128_69
Nimbus, the techical festival of NIT Hanirpur is coming and thus Arun, the core-cordinator of departmental team of CSE, decided a conduct a game. In this game, the participant will be given a natural number N and will be asked T questions of form Type K. Here Type denotes the type of question asked and K denotes a nat...
[{"code": "import math\nN, noOfQueries = raw_input().split(\" \")\nN, noOfQueries = int(N), int(noOfQueries)\n\nupperLimit = int(math.sqrt(N))\n\ndivisors = []\n\nfor i in range(1, upperLimit + 1):\n\tif(N % i == 0):\n\t\tdivisors.append(N/i)\n\t\tdivisors.append(i)\n\n\nfor q in range(1, noOfQueries + 1):\n\tt, k = ra...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00081-of-00128_69__public__0000", "expected_output": {"kind": "stdout", "value": "4\n2\n2\n3\n5\n6"}, "input": {"kind": "stdin", "value": "12 6\n1 6\n1 14\n2 4\n2 3\n3 12\n3 14\n\nSAMPLE"}, "metadata": {}, "visibility": "public"}]
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
HACKEREARTH
[]
null
codecontests__test__code_contests_train.riegeli-00081-of-00128_74
One day Samu went out for a walk in the park but there weren't any of her friends with her. So she decided to enjoy by her own. Samu noticed that she was walking in rectangular field of size N x M (units). So field can be divided into N horizontal rows, each containing M unit size squares. The squares have coordinates ...
[{"code": "'''\n# Read input from stdin and provide input before running code\n\nname = raw_input('What is your name?\\n')\nprint 'Hi, %s.' % name\n\nprint 'Hello World!'\n'''\n\nt = int(raw_input())\nfor i in range (t):\n\tn,m=map(int,raw_input().split())\n\tk=int(raw_input())\n\tres=0\n\tx,y=1,1\n\tfor j in range(k):...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00081-of-00128_74__public__0000", "expected_output": {"kind": "stdout", "value": "5\n"}, "input": {"kind": "stdin", "value": "1\n5 6\n3\n1 1\n1 1\n0 -4\n\nSAMPLE"}, "metadata": {}, "visibility": "public"}]
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
HACKEREARTH
[]
null
codecontests__test__code_contests_train.riegeli-00081-of-00128_79
The window of Takahashi's room has a width of A. There are two curtains hung over the window, each of which has a horizontal length of B. (Vertically, the curtains are long enough to cover the whole window.) We will close the window so as to minimize the total horizontal length of the uncovered part of the window. Fin...
[{"code": "A, B = map(int, raw_input().split())\nprint(max(0, A - 2 * B))", "is_known_correct": true, "language": "python", "metadata": {}, "solution_id": "codecontests__test__code_contests_train.riegeli-00081-of-00128_79__ref__0000", "source": "benchmark"}, {"code": "a,b=map(int,input().split())\nprint(a-2*b if a-2*b>...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00081-of-00128_79__public__0000", "expected_output": {"kind": "stdout", "value": "0"}, "input": {"kind": "stdin", "value": "20 30"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riegeli-00081-of-00128_79__publ...
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
ATCODER
[""]
null
codecontests__test__code_contests_train.riegeli-00082-of-00128_1
Given an integer N. Integers A and B are chosen randomly in the range [1..N]. Calculate the probability that the Greatest Common Divisor(GCD) of A and B equals to B. Input The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows. Each test case consis...
[{"code": "from fractions import gcd\nfrom sys import stdin\n\n\ndef p(n):\n s = int(n ** .5)\n c = sum(n/i for i in xrange(1, s+1)) * 2 - s**2\n g = gcd(c, n ** 2)\n return '{}/{}'.format(c / g, n**2 / g)\n\n\nprint(\n '\\n'.join(\n p(int(ln))\n for i, ln in enumerate(stdin) if i\n )\n)...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00082-of-00128_1__public__0000", "expected_output": {"kind": "stdout", "value": "1/1\n3/4\n5/9"}, "input": {"kind": "stdin", "value": "3\n1\n2\n3"}, "metadata": {}, "visibility": "public"}]
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
CODECHEF
[]
null
codecontests__test__code_contests_train.riegeli-00082-of-00128_3
Rohit dreams he is in a shop with an infinite amount of marbles. He is allowed to select n marbles. There are marbles of k different colors. From each color there are also infinitely many marbles. Rohit wants to have at least one marble of each color, but still there are a lot of possibilities for his selection. In his...
[{"code": "solution = []\ndef fact(n,r):\n res=1\n if r>n-r:\n r = n-r\n for i in range(r):\n res*=(n-i)\n res/=i+1\n return res\n \n \ndef main():\n T = int(raw_input().strip())\n for i in xrange(T):\n global fact\n global solution\n val = raw_input().stri...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00082-of-00128_3__public__0000", "expected_output": {"kind": "stdout", "value": "1\n475020\n"}, "input": {"kind": "stdin", "value": "2\n10 10\n30 7"}, "metadata": {}, "visibility": "public"}]
{"comparison": {"case_sensitive": true, "numeric_tolerance": null, "strip_trailing_whitespace": true, "type": "exact_or_token_match"}, "entry_point": null, "eval_mode": "stdin_stdout", "language": "python", "memory_limit_mb": 512, "requires_special_judge": false, "timeout_seconds": 5, "unsupported_reason": null}
CodeContests
CODECHEF
[]
null