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-00034-of-00128_87
Iroha has a sequence of N strings S_1, S_2, ..., S_N. The length of each string is L. She will concatenate all of the strings in some order, to produce a long string. Among all strings that she can produce in this way, find the lexicographically smallest one. Here, a string s=s_1s_2s_3...s_n is lexicographically sma...
[{"code": "print(\"\".join(sorted([input()for _ in[\"\"]*int(input().split()[0])])))", "is_known_correct": true, "language": "python", "metadata": {}, "solution_id": "codecontests__test__code_contests_train.riegeli-00034-of-00128_87__ref__0000", "source": "benchmark"}, {"code": "n,l=map(int,input().split())\nlist=sorte...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00034-of-00128_87__public__0000", "expected_output": {"kind": "stdout", "value": "axxcxxdxx"}, "input": {"kind": "stdin", "value": "3 3\ndxx\naxx\ncxx"}, "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-00035-of-00128_0
Problem description You will be given a zero-indexed array A. You need to rearrange its elements in such a way that the following conditions are satisfied: A[i] ≤ A[i+1] if i is even. A[i] ≥ A[i+1] if i is odd. In other words the following inequality should hold: A[0] ≤ A[1] ≥ A[2] ≤ A[3] ≥ A[4], and so on. Operation...
[{"code": "import math\nt=input()\nwhile t>0:\n n=input()\n a=[]\n for x in raw_input().split():\n a.append(int(x))\n a.sort()\n n=int(math.ceil(n/2.0))\n res=a[n:]\n a=a[:n]\n count=1\n for x in res:\n a.insert(count,x)\n count+=2\n for x in a:\n print x,\n ...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00035-of-00128_0__public__0000", "expected_output": {"kind": "stdout", "value": "2 3 \n2 10 5 \n"}, "input": {"kind": "stdin", "value": "2\n2\n3 2\n3\n10 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-00035-of-00128_1
Chef plays with the sequence of N numbers. During a single move Chef is able to choose a non-decreasing subsequence of the sequence and to remove it from the sequence. Help him to remove all the numbers in the minimal number of moves. Input The first line of each test case contains a single N denoting the number of i...
[{"code": "def index(lis,l,r,k):\n while(r-l>1):\n m=l+(r-l)/2;\n if(lis[m]>=k):\n r=m\n else:\n l=m\n return r \ndef count(lis,n):\n t=[]\n len1=1\n t+=[lis[0]]\n i=1\n while i<n:\n if(lis[i]<t[0]):\n t[0]=lis[i]\n elif(lis...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00035-of-00128_1__public__0000", "expected_output": {"kind": "stdout", "value": "1"}, "input": {"kind": "stdin", "value": "3 \n1 2 3"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riegeli-00035-of-00128_1__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
CODECHEF
[]
null
codecontests__test__code_contests_train.riegeli-00035-of-00128_3
There are N students living in the dormitory of Berland State University. Each of them sometimes wants to use the kitchen, so the head of the dormitory came up with a timetable for kitchen's usage in order to avoid the conflicts: The first student starts to use the kitchen at the time 0 and should finish the cooking n...
[{"code": "import sys\nn = int(raw_input().strip())\nfor i in xrange(n) :\n len_a = int(raw_input().strip())\n a = map(int,raw_input().strip().split(' '))\n b = map(int,raw_input().strip().split(' '))\n counter = 0\n for i in range(0,len_a) :\n if i == 0 :\n if a[i] >= b[i] :\n ...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00035-of-00128_3__public__0000", "expected_output": {"kind": "stdout", "value": "2\n1\n"}, "input": {"kind": "stdin", "value": "2\n3\n1 10 15\n1 10 3\n3\n10 20 30\n15 5 20"}, "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-00035-of-00128_5
As every other little boy, Mike has a favorite toy to play with. Mike's favorite toy is a set of N disks. The boy likes to compose his disks in stacks, but there's one very important rule: the disks in a single stack must be ordered by their radiuses in a strictly increasing order such that the top-most disk will have ...
[{"code": "def bs(k,start,end,search):\n mid =(start+end)/2\n if(start>end):\n k[start] = search\n return 0\n if(start == end):\n if(k[start] >search):\n k[start] = search\n else:\n k[start+1] = search\n return 0\n\n else:\n \n if(search<k...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00035-of-00128_5__public__0000", "expected_output": {"kind": "stdout", "value": "3 1 1 2\n5 2 2 4 7 10\n4 5 10 12 18\n"}, "input": {"kind": "stdin", "value": "3\n6\n3 4 5 1 1 2\n10\n3 2 9 5 2 9 4 14 7 10\n8\n14 5 13 19 17 10 18 12"}, "metadata": {}, "visibil...
{"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-00035-of-00128_67
Aaryan went to school like any usual day, The teacher asked his crush the following question. Given an array of numbers, First she had to compute the XOR of all the subsequences that can be formed. Suppose each subsequence had their following XOR value that came out after computing -> {P[0], P[1], P[2], and so on upto...
[{"code": "from sys import stdin\nstdin.readline()\na=map(int, stdin.readline().split())\nb=a[0]\nfor i in a[1:]:\n b|=i\nprint b", "is_known_correct": true, "language": "python", "metadata": {}, "solution_id": "codecontests__test__code_contests_train.riegeli-00035-of-00128_67__ref__0000", "source": "benchmark"}, {"...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00035-of-00128_67__public__0000", "expected_output": {"kind": "stdout", "value": "9\n"}, "input": {"kind": "stdin", "value": "4\n8 9 9 8\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-00035-of-00128_77
There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Ta...
[{"code": "import java.util.*;\nimport java.io.*;\nimport java.nio.charset.StandardCharsets;\n\npublic class Main {\n\n\tpublic static void main(String[] args) throws IOException {\n\t\tInputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);\n\t\tBufferedReader in = new BufferedReader(reade...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00035-of-00128_77__public__0000", "expected_output": {"kind": "stdout", "value": "3"}, "input": {"kind": "stdin", "value": "10 4\n3 1\n4 1\n5 9\n2 6"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riegeli-0003...
{"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-00035-of-00128_78
Given are an integer N and arrays S, T, U, and V, each of length N. Construct an N×N matrix a that satisfy the following conditions: * a_{i,j} is an integer. * 0 \leq a_{i,j} \lt 2^{64}. * If S_{i} = 0, the bitwise AND of the elements in the i-th row is U_{i}. * If S_{i} = 1, the bitwise OR of the elements in the i-th...
[{"code": "#include <bits/stdc++.h>\nusing namespace std;\nusing ul=unsigned long long;\nint s[500],t[500],tmp[500][500],S[500],T[500],n,bit=-1,IN;\nul ans[500][500],u[500],v[500];\n\nvoid ng(){\n cout<<-1;\n exit(0);\n}\n\nstruct P{int va,idx,ve,ne,al;};\nbool operator <(const P&a,const P&b){return a.va<b.va;};\npri...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00035-of-00128_78__public__0000", "expected_output": {"kind": "stdout", "value": "15 11\n15 11"}, "input": {"kind": "stdin", "value": "2\n1 1\n1 0\n15 15\n15 11"}, "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-00035-of-00128_79
For an integer n not less than 0, let us define f(n) as follows: * f(n) = 1 (if n < 2) * f(n) = n f(n-2) (if n \geq 2) Given is an integer N. Find the number of trailing zeros in the decimal notation of f(N). Constraints * 0 \leq N \leq 10^{18} Input Input is given from Standard Input in the following format: ...
[{"code": "n=int(input())\nif n%2==1:print(0);exit()\nA=0\nadd=10\nwhile n>=add:\n A +=n//add\n add *=5\nprint(A)", "is_known_correct": true, "language": "python", "metadata": {}, "solution_id": "codecontests__test__code_contests_train.riegeli-00035-of-00128_79__ref__0000", "source": "benchmark"}, {"code": "impor...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00035-of-00128_79__public__0000", "expected_output": {"kind": "stdout", "value": "124999999999999995"}, "input": {"kind": "stdin", "value": "1000000000000000000"}, "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-00035-of-00128_80
There are N apple trees in a row. People say that one of them will bear golden apples. We want to deploy some number of inspectors so that each of these trees will be inspected. Each inspector will be deployed under one of the trees. For convenience, we will assign numbers from 1 through N to the trees. An inspector ...
[{"code": "a,b = map(int, input().split())\nt = 2*b + 1\nprint((a-1)//t+1)", "is_known_correct": true, "language": "python", "metadata": {}, "solution_id": "codecontests__test__code_contests_train.riegeli-00035-of-00128_80__ref__0000", "source": "benchmark"}, {"code": "a, b = map(int, raw_input().split())\nb = b * 2 + ...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00035-of-00128_80__public__0000", "expected_output": {"kind": "stdout", "value": "3"}, "input": {"kind": "stdin", "value": "20 4"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riegeli-00035-of-00128_80__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-00035-of-00128_81
You are given positive integers A and B. Find the K-th largest positive integer that divides both A and B. The input guarantees that there exists such a number. Constraints * All values in input are integers. * 1 \leq A, B \leq 100 * The K-th largest positive integer that divides both A and B exists. * K \geq 1 In...
[{"code": "#include <bits/stdc++.h>\nusing namespace std;\nint main(){\n\tint a,b,c;\n\tcin>>a>>b>>c;\n\tint d=0;\n\tfor(int i=a;i>=1;i--){\n\t\tif(a%i==0&&b%i==0){\n\t\t\tc--;\n\t\t\tif(c==0){\n\t\t\t\tcout<<i<<endl;\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t}\n\t}\n}\n", "is_known_correct": true, "language": "cpp", "metadata"...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00035-of-00128_81__public__0000", "expected_output": {"kind": "stdout", "value": "1"}, "input": {"kind": "stdin", "value": "1 1 1"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riegeli-00035-of-00128_81__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-00035-of-00128_82
You are given positive integers N and M. How many sequences a of length N consisting of positive integers satisfy a_1 \times a_2 \times ... \times a_N = M? Find the count modulo 10^9+7. Here, two sequences a' and a'' are considered different when there exists some i such that a_i' \neq a_i''. Constraints * All valu...
[{"code": "n, m = map(int, input().split())\n\nyd = {}\ni = 2\nwhile m != 1:\n while m % i == 0:\n if i in yd:\n yd[i] += 1\n else:\n yd[i] = 1\n m //= i\n i += 1\n\nans = 1\nfor v in yd.values():\n start = v + n - 1\n c = 1\n for _ in range(v):\n c *= start\n start -= 1\n d = 1\n for _v...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00035-of-00128_82__public__0000", "expected_output": {"kind": "stdout", "value": "18"}, "input": {"kind": "stdin", "value": "3 12"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riegeli-00035-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-00035-of-00128_87
Snuke is having a barbeque party. At the party, he will make N servings of Skewer Meal. <image> Example of a serving of Skewer Meal He has a stock of 2N skewers, all of which will be used in Skewer Meal. The length of the i-th skewer is L_i. Also, he has an infinite supply of ingredients. To make a serving of Skew...
[{"code": "#include<bits/stdc++.h>\nusing namespace std;\nint main(){\n int N;cin>>N;\n vector<int>L(2*N);for(int i=0;i<2*N;i++)cin>>L[i];\n sort(L.begin(),L.end());\n int ans=0;\n for(int i=0;i<N;i++){\n ans+=L[2*i];\n }cout<<ans;\n}\n", "is_known_correct": true, "language": "cpp", "metadata": {}, "solution_i...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00035-of-00128_87__public__0000", "expected_output": {"kind": "stdout", "value": "135"}, "input": {"kind": "stdin", "value": "5\n100 1 2 3 14 15 58 58 58 29"}, "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-00036-of-00128_0
There are N+1 lights. Lights are placed at (0, 0), (1, 0), (2, 0) ... (N, 0). Initially all the lights are on. You want to turn off all of them one after one. You want to follow a special pattern in turning off the lights. You will start at (0, 0). First, you walk to the right most light that is on, turn it off. Th...
[{"code": "# cook your code here\nT = int(raw_input())\nwhile T:\n\tn = int(raw_input())\n\tprint (n*(n+1)/2)+n\n\n\tT = T - 1", "is_known_correct": true, "language": "python", "metadata": {}, "solution_id": "codecontests__test__code_contests_train.riegeli-00036-of-00128_0__ref__0000", "source": "benchmark"}, {"code": ...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00036-of-00128_0__public__0000", "expected_output": {"kind": "stdout", "value": "2\n5\n"}, "input": {"kind": "stdin", "value": "2\n1\n2"}, "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-00036-of-00128_3
You might have heard about our new goodie distribution program aka the "Laddu Accrual System". This problem is designed to give you a glimpse of its rules. You can read the page once before attempting the problem if you wish, nonetheless we will be providing all the information needed here itself. Laddu Accrual Syste...
[{"code": "# @author Kilari Teja\n# LADDU\n\nfor Inx in xrange(0, int(raw_input().strip())):\n\tinitParams = raw_input().strip().split(\" \")\n\n\tTotalActions = int(initParams[0])\n\tIndian = True if initParams[1] == \"INDIAN\" else False\n\n\tPoints = 0\n\tfor ActionIndx in xrange(0, TotalActions):\n\t\tActions = raw...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00036-of-00128_3__public__0000", "expected_output": {"kind": "stdout", "value": "3\n1\n"}, "input": {"kind": "stdin", "value": "2\n4 INDIAN\nCONTEST_WON 1\nTOP_CONTRIBUTOR\nBUG_FOUND 100\nCONTEST_HOSTED\n4 NON_INDIAN\nCONTEST_WON 1\nTOP_CONTRIBUTOR\nBUG_FOUN...
{"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-00036-of-00128_77
We have N integers. The i-th number is A_i. \\{A_i\\} is said to be pairwise coprime when GCD(A_i,A_j)=1 holds for every pair (i, j) such that 1\leq i < j \leq N. \\{A_i\\} is said to be setwise coprime when \\{A_i\\} is not pairwise coprime but GCD(A_1,\ldots,A_N)=1. Determine if \\{A_i\\} is pairwise coprime, setw...
[{"code": "N = int(input())\nA = list(map(int,input().split()))\n\nA = sorted(A,reverse = True)\nprime = [0] * (10**6+1)\neratos = [True] * (A[0] + 1)\nD = [0] * (A[0]+1)\nD[1] = 1\nfor i in range(2,A[0] + 1):\n if not eratos[i]:\n continue\n else:\n for j in range(i,A[0] + 1,i):\n if not D[j]:\n D[...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00036-of-00128_77__public__0000", "expected_output": {"kind": "stdout", "value": "not coprime"}, "input": {"kind": "stdin", "value": "3\n6 10 16"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riegeli-00036-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-00036-of-00128_78
Print the circumference of a circle of radius R. Constraints * 1 \leq R \leq 100 * All values in input are integers. Input Input is given from Standard Input in the following format: R Output Print the circumference of the circle. Your output is considered correct if and only if its absolute or relative error ...
[{"code": "R=int(input())\nprint(R*6.2831853)\n", "is_known_correct": true, "language": "python", "metadata": {}, "solution_id": "codecontests__test__code_contests_train.riegeli-00036-of-00128_78__ref__0000", "source": "benchmark"}, {"code": "import java.util.Scanner;\n\npublic class Main {\n\t\n\tpublic static void ma...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00036-of-00128_78__public__0000", "expected_output": {"kind": "stdout", "value": "458.67252742410977361942"}, "input": {"kind": "stdin", "value": "73"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riegeli-000...
{"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-00036-of-00128_79
We have a tree with N vertices. The i-th edge connects Vertex A_i and B_i bidirectionally. Takahashi is standing at Vertex u, and Aoki is standing at Vertex v. Now, they will play a game of tag as follows: * 1. If Takahashi and Aoki are standing at the same vertex, the game ends. Otherwise, Takahashi moves to a vert...
[{"code": "#include <bits/stdc++.h>\n\nusing namespace std;\n\nint n, u, v;\nint dist[2][100000];\nvector<vector<int> > g;\n\nvoid dfs(int v, int prev, int d, int f) {\n\tdist[f][v] = d;\n\tfor (auto e : g[v])\n\t\tif (e != prev) dfs(e, v, d + 1, f);\n}\n\nint main() {\n\tcin >> n >> u >> v;\n\t--u, --v;\n\tg.resize(n)...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00036-of-00128_79__public__0000", "expected_output": {"kind": "stdout", "value": "0"}, "input": {"kind": "stdin", "value": "2 1 2\n1 2"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riegeli-00036-of-00128_79_...
{"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-00036-of-00128_80
You are given a sequence of length N: A_1, A_2, ..., A_N. For each integer i between 1 and N (inclusive), answer the following question: * Find the maximum value among the N-1 elements other than A_i in the sequence. Constraints * 2 \leq N \leq 200000 * 1 \leq A_i \leq 200000 * All values in input are integers. Inp...
[{"code": "import java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\t Scanner sc = new Scanner(System.in);\n\n\t\t int max = 0;\n\t\t int max_num =0;\n\t\t int max2 = 0;\n\t\t int n = sc.nextInt();\n\t\t for(int i=0; i<n; i++) {\n\t\t \tint a = sc.nextInt()...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00036-of-00128_80__public__0000", "expected_output": {"kind": "stdout", "value": "5\n5"}, "input": {"kind": "stdin", "value": "2\n5\n5"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riegeli-00036-of-00128_80_...
{"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-00036-of-00128_81
There are N cubes stacked vertically on a desk. You are given a string S of length N. The color of the i-th cube from the bottom is red if the i-th character in S is `0`, and blue if that character is `1`. You can perform the following operation any number of times: choose a red cube and a blue cube that are adjacent...
[{"code": "#include <bits/stdc++.h>\nusing namespace std;\n\nint main() {\n string S;\n cin >> S;\n \n int c0,c1 =0;\n for(char i: S) {\n if(i == '0') ++c0;\n else ++c1;\n }\n \n cout << 2 * min(c0,c1) << endl;\n}", "is_known_correct": true, "language": "cpp", "metadata": {}, "solution_id": "codecontests_...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00036-of-00128_81__public__0000", "expected_output": {"kind": "stdout", "value": "0"}, "input": {"kind": "stdin", "value": "0"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riegeli-00036-of-00128_81__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-00036-of-00128_83
An elementary school student Takahashi has come to a variety store. He has two coins, A-yen and B-yen coins (yen is the currency of Japan), and wants to buy a toy that costs C yen. Can he buy it? Note that he lives in Takahashi Kingdom, and may have coins that do not exist in Japan. Constraints * All input values a...
[{"code": "import java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tfinal Scanner sc = new Scanner(System.in);\n\t\tint a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt();\n\t\tif(a+b < c) {\n\t\t\tSystem.out.println(\"No\");\n\t\t} else {\n\t\t\tSystem.out.println(\"Yes\");\n...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00036-of-00128_83__public__0000", "expected_output": {"kind": "stdout", "value": "No"}, "input": {"kind": "stdin", "value": "500 100 1000"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riegeli-00036-of-00128_...
{"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-00037-of-00128_1
In Ciel's restaurant, a waiter is training. Since the waiter isn't good at arithmetic, sometimes he gives guests wrong change. Ciel gives him a simple problem. What is A-B (A minus B) ? Surprisingly, his answer is wrong. To be more precise, his answer has exactly one wrong digit. Can you imagine this? Can you make th...
[{"code": "test = map(int,raw_input().split())\ncount = str(abs(test[0] - test[1]))\nl = ['1','2','3','4','5','6','7','8','9']\nl.remove(count[0])\nstring = ''\nstring += l[0]\nstring += count[1:len(count)+1]\nprint int(string)", "is_known_correct": true, "language": "python", "metadata": {}, "solution_id": "codecontes...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00037-of-00128_1__public__0000", "expected_output": {"kind": "stdout", "value": "1624\n"}, "input": {"kind": "stdin", "value": "5858 1234"}, "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-00037-of-00128_5
Problem Statement Write a program that accepts a number and outputs the same. Sample Input 123 Sample Output 123
[{"code": "num=int(raw_input())\nprint num", "is_known_correct": true, "language": "python", "metadata": {}, "solution_id": "codecontests__test__code_contests_train.riegeli-00037-of-00128_5__ref__0000", "source": "benchmark"}, {"code": "x = raw_input()\nprint x", "is_known_correct": true, "language": "python", "metadat...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00037-of-00128_5__public__0000", "expected_output": {"kind": "stdout", "value": "123\n"}, "input": {"kind": "stdin", "value": "123"}, "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-00037-of-00128_78
Takahashi has N days of summer vacation. His teacher gave him M summer assignments. It will take A_i days for him to do the i-th assignment. He cannot do multiple assignments on the same day, or hang out on a day he does an assignment. What is the maximum number of days Takahashi can hang out during the vacation if ...
[{"code": "import java.util.*;\n\nclass Main{\n public static void main(String args[]) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int m = sc.nextInt();\n for(int i=0;i<m;i++){\n n -= sc.nextInt();\n }\n\n if(n < 0){\n System.out....
[{"case_id": "codecontests__test__code_contests_train.riegeli-00037-of-00128_78__public__0000", "expected_output": {"kind": "stdout", "value": "-1"}, "input": {"kind": "stdin", "value": "10 2\n5 6"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riegeli-00037-of-00128_78_...
{"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-00037-of-00128_79
Given are three integers A_1, A_2, and A_3. If A_1+A_2+A_3 is greater than or equal to 22, print `bust`; otherwise, print `win`. Constraints * 1 \leq A_i \leq 13 \ \ (i=1,2,3) * All values in input are integers. Input Input is given from Standard Input in the following format: A_1 A_2 A_3 Output If A_1+A_2+A_...
[{"code": "import java.util.*;\nimport java.math.*;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int sum = 0;\n for (int i = 0; i < 3; i++) sum += sc.nextInt();\n if (sum >= 22) System.out.println(\"bust\");\n else System.out.println(\"win\")...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00037-of-00128_79__public__0000", "expected_output": {"kind": "stdout", "value": "win"}, "input": {"kind": "stdin", "value": "5 7 9"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riegeli-00037-of-00128_79__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-00037-of-00128_80
There are N empty boxes arranged in a row from left to right. The integer i is written on the i-th box from the left (1 \leq i \leq N). For each of these boxes, Snuke can choose either to put a ball in it or to put nothing in it. We say a set of choices to put a ball or not in the boxes is good when the following con...
[{"code": "N = int(input())\nA = list(map(int, input().split()))\nB = [0]*(N+1)\nx = []\n \nfor n in range(N):\n i = N-n\n BB = B[::i]\n if (sum(BB))%2 == A[i-1]:\n B[i] = 0\n else:\n B[i] = 1\n x.append(str(i))\n \nprint(len(x))\nprint(' '.join(x))", "is_known_correct": true, "language": "python", "metad...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00037-of-00128_80__public__0000", "expected_output": {"kind": "stdout", "value": "0"}, "input": {"kind": "stdin", "value": "5\n0 0 0 0 0"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riegeli-00037-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-00037-of-00128_81
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
[{"code": "#include <bits/stdc++.h>\nusing namespace std;\n\nconst int MAXN = 1e5+5;\nint n, m, fa[MAXN];\n\nstruct EDGE\n{\n\tint u, v;\n}e[MAXN];\n\nlong long ans[MAXN], sz[MAXN];\n\nint find(int x)\n{\n\tif(x == fa[x])\n\t\treturn x;\n\treturn fa[x] = find(fa[x]);\n}\n\nint main()\n{\n\tcin >> n >> m;\n\t\n\tfor(int...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00037-of-00128_81__public__0000", "expected_output": {"kind": "stdout", "value": "8\n9\n12\n14\n15"}, "input": {"kind": "stdin", "value": "6 5\n2 3\n1 2\n5 6\n3 4\n4 5"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests...
{"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-00037-of-00128_83
Takahashi has N blue cards and M red cards. A string is written on each card. The string written on the i-th blue card is s_i, and the string written on the i-th red card is t_i. Takahashi will now announce a string, and then check every card. Each time he finds a blue card with the string announced by him, he will ea...
[{"code": "from collections import*\nn,*a=open(0).read().split()\nblue=a[0:int(n)]\nred=a[int(n)+1:]\nprint(max(0,max(v-Counter(red)[k] for k,v in Counter(blue).items())))", "is_known_correct": true, "language": "python", "metadata": {}, "solution_id": "codecontests__test__code_contests_train.riegeli-00037-of-00128_83_...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00037-of-00128_83__public__0000", "expected_output": {"kind": "stdout", "value": "1"}, "input": {"kind": "stdin", "value": "3\napple\norange\napple\n5\napple\napple\napple\napple\napple"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__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-00038-of-00128_0
Chef has recently learnt some new facts about the famous number π. For example, he was surprised that ordinary fractions are sometimes used to represent this number approximately. For example, 22/7, 355/113 or even 103993/33102. Soon, by calculating the value of 22/7 and 355/113 on paper Chef became quite disappointed ...
[{"code": "def main():\n\n cases = int(raw_input())\n repetition='415926530119026040722614947737296840070086399613316'\n\n for i in range(cases):\n k = int(raw_input())\n if(k == 0):\n print \"3\"\n elif(k==1):\n ...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00038-of-00128_0__public__0000", "expected_output": {"kind": "stdout", "value": "3\n3.141592\n3.14159265301190260407\n"}, "input": {"kind": "stdin", "value": "3\n0\n6\n20"}, "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-00038-of-00128_1
In Wolf town there are 2 big markets S and T. The distance between these markets is D. Chef Ciel would like to run 2 restaurants in Wolf town, where the first restaurant will be supplied by the market S and the second one will be supplied by the market T. The markets run delivery service without charge within some dist...
[{"code": "def solve(da, db, d):\n if(da + db <= d):\n\treturn d - da - db\n elif(da + d <= db):\n\treturn db - d - da\n elif(db + d <= da):\n\treturn da - d - db\n else:\n\treturn 0\n\n# main\n\ntest = int(raw_input())\nfor i in range(test):\n # apply the function(int) to all items in the raw_input().sp...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00038-of-00128_1__public__0000", "expected_output": {"kind": "stdout", "value": "20.0\n0\n69.0\n0\n"}, "input": {"kind": "stdin", "value": "4\n15 15 50\n15 15 18\n43 88 200\n2013 2013 2013"}, "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-00038-of-00128_3
Lapindrome is defined as a string which when split in the middle, gives two halves having the same characters and same frequency of each character. If there are odd number of characters in the string, we ignore the middle character and check for lapindrome. For example gaga is a lapindrome, since the two halves ga and ...
[{"code": "q=int(raw_input())\nwhile(q>0):\n\ta=raw_input()\n\ta1=a[0:len(a)//2]\n\tif(len(a)%2==0):\n\t\ta2=a[(len(a)//2):len(a)]\n\telse:\n\t\ta2=a[(len(a)//2)+1:len(a)]\n\ta1=list(a1)\n\ta1.sort()\n\ta2=list(a2)\n\ta2.sort()\n\tcnt=0\n\tfor x, y in zip(a1, a2):\n\t\tif(x==y):\n\t\t\tcnt+=1\n\tif(cnt==len(a)//2):\n\t...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00038-of-00128_3__public__0000", "expected_output": {"kind": "stdout", "value": "YES\nNO\nYES\nYES\nNO\nNO\n"}, "input": {"kind": "stdin", "value": "6\ngaga\nabcde\nrotor\nxyzxy\nabbaab\nababc"}, "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-00038-of-00128_5
Given n words w[1..n], which originate from the same stem (e.g. grace, graceful, disgraceful, gracefully), we are interested in the original stem. To simplify the problem, we define the stem as the longest consecutive substring that occurs in all the n words. If there are ties, we will choose the smallest one in the al...
[{"code": "'''\nCreated on 24-Oct-2015\n\n@author: Venkatesh\n'''\n\n\ndef read_str_list():\n return [x for x in raw_input().split()]\n\n\ndef read_int():\n return int(raw_input())\n\n\ndef get_stem(s_lst, n):\n fst_str = s_lst[0]\n m = len(fst_str)\n ans = \"\"\n all_stems = set()\n for k in xrang...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00038-of-00128_5__public__0000", "expected_output": {"kind": "stdout", "value": "grace\n"}, "input": {"kind": "stdin", "value": "1\n4\ngrace graceful disgraceful gracefully"}, "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-00038-of-00128_77
Takahashi loves takoyaki - a ball-shaped snack. With a takoyaki machine, he can make at most X pieces of takoyaki at a time, taking T minutes regardless of the number of pieces to make. How long does it take to make N takoyaki? Constraints * 1 \leq N,X,T \leq 1000 * All values in input are integers. Input Input i...
[{"code": "import java.util.*;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int N = sc.nextInt();\n int X = sc.nextInt();\n int T = sc.nextInt();\n \n int num = N / X;\n if(N % X != 0) ++ num;\n \n System.out.println(num * T);\n ...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00038-of-00128_77__public__0000", "expected_output": {"kind": "stdout", "value": "1000000"}, "input": {"kind": "stdin", "value": "1000 1 1000"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riegeli-00038-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-00038-of-00128_78
A company has N members, who are assigned ID numbers 1, ..., N. Every member, except the member numbered 1, has exactly one immediate boss with a smaller ID number. When a person X is the immediate boss of a person Y, the person Y is said to be an immediate subordinate of the person X. You are given the information ...
[{"code": "N=int(input())\nA=list(map(int,input().split()))\n\nb=[0]*N\nfor c in A:\n b[c-1]+=1\n\nfor i in b:\n print(i)", "is_known_correct": true, "language": "python", "metadata": {}, "solution_id": "codecontests__test__code_contests_train.riegeli-00038-of-00128_78__ref__0000", "source": "benchmark"}, {"code"...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00038-of-00128_78__public__0000", "expected_output": {"kind": "stdout", "value": "1\n1\n1\n1\n1\n1\n0"}, "input": {"kind": "stdin", "value": "7\n1 2 3 4 5 6"}, "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-00038-of-00128_79
Takahashi loves palindromes. Non-palindromic strings are unacceptable to him. Each time he hugs a string, he can change one of its characters to any character of his choice. Given is a string S. Find the minimum number of hugs needed to make S palindromic. Constraints * S is a string consisting of lowercase English ...
[{"code": "#include <iostream>\n#include <string>\nusing namespace std;\nint main(){\nstring S;\n cin>>S;\nint len,ans;\n ans=0;\n len=S.length();\nfor(int i=0;i<len;i++){\nif(S[i]!=S[len-1-i]){ans++;}\n} \n cout<<ans/2;\n}", "is_known_correct": true, "language": "cpp", "metadata": {}, "solution_id": "codecontests_...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00038-of-00128_79__public__0000", "expected_output": {"kind": "stdout", "value": "2"}, "input": {"kind": "stdin", "value": "abcdabc"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riegeli-00038-of-00128_79__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-00038-of-00128_80
You are given a sequence with N integers: A = \\{ A_1, A_2, \cdots, A_N \\}. For each of these N integers, we will choose a color and paint the integer with that color. Here the following condition must be satisfied: * If A_i and A_j (i < j) are painted with the same color, A_i < A_j. Find the minimum number of col...
[{"code": "\nimport java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.Collections;\nimport java.util.List;\nimport java.util.Scanner;\n\npublic class Main {\n public static void main(String [] args) {\n Scanner scanner = new Scanner(System.in);\n int n = scanner.nextInt();\n long[...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00038-of-00128_80__public__0000", "expected_output": {"kind": "stdout", "value": "4"}, "input": {"kind": "stdin", "value": "4\n0\n0\n0\n0"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riegeli-00038-of-00128_...
{"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-00038-of-00128_81
You are given a string S as input. This represents a valid date in the year 2019 in the `yyyy/mm/dd` format. (For example, April 30, 2019 is represented as `2019/04/30`.) Write a program that prints `Heisei` if the date represented by S is not later than April 30, 2019, and prints `TBD` otherwise. Constraints * S is...
[{"code": "#include<stdio.h>\nint main(){char s[11];scanf(\"%s\",s);printf(s[5]-48||s[6]>52?\"TBD\":\"Heisei\");}", "is_known_correct": true, "language": "cpp", "metadata": {}, "solution_id": "codecontests__test__code_contests_train.riegeli-00038-of-00128_81__ref__0000", "source": "benchmark"}, {"code": "# -*- coding: ...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00038-of-00128_81__public__0000", "expected_output": {"kind": "stdout", "value": "Heisei"}, "input": {"kind": "stdin", "value": "2019/04/30"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riegeli-00038-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-00038-of-00128_83
On a two-dimensional plane, there are N red points and N blue points. The coordinates of the i-th red point are (a_i, b_i), and the coordinates of the i-th blue point are (c_i, d_i). A red point and a blue point can form a friendly pair when, the x-coordinate of the red point is smaller than that of the blue point, an...
[{"code": "#include <bits/stdc++.h>\nusing namespace std;\n\nint main()\n{ \n int n;\n cin>>n;\n pair<int,int> a[n],b[n];\n for(int i=0;i<n;i++){\n int x,y;\n cin>>x>>y;\n a[i]=make_pair(x,y);\n }\n for(int i=0;i<n;i++){\n int x,y;\n cin>>x>>y;\n b[i]=make_pair(y,x);\n ...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00038-of-00128_83__public__0000", "expected_output": {"kind": "stdout", "value": "0"}, "input": {"kind": "stdin", "value": "2\n2 2\n3 3\n0 0\n1 1"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riegeli-00038-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-00039-of-00128_0
You are given an array of N integers a1, a2, ..., aN and an integer K. Find the number of such unordered pairs {i, j} that i ≠ j |ai + aj - K| is minimal possible Output the minimal possible value of |ai + aj - K| (where i ≠ j) and the number of such pairs for the given array and the integer K. Input The first lin...
[{"code": "def test(s,r):\n sum=s[1]\n k=0\n if r[0]+r[1]-sum>0:\n i=r[0]+r[1]-sum\n else:\n i=sum-r[0]-r[1]\n for x in range(len(r)):\n for y in r[x+1:]:\n if r[x]+y-sum>=0:\n if r[x]+y-sum<i:\n i=r[x]+y-sum\n k=1\n ...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00039-of-00128_0__public__0000", "expected_output": {"kind": "stdout", "value": "1 4\n"}, "input": {"kind": "stdin", "value": "1 \n4 9\n4 4 2 6"}, "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-00039-of-00128_1
Recently, chef Ciel often hears about 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. Ciel decides to make Ciel numbers. As you know, Ciel likes the digi...
[{"code": "import sys\ndef main():\n\tn=int(raw_input())\n\tres=0\n\tfor i in range(n):\n\t\tt=raw_input().split()\n\t\tt=int(t[-1])\n\t\tv=t\n\t\t#print(t)\n\t\tb=0\n\t\tv8=v5=v3=0\n\t\twhile t!=0:\n\t\t\tr=t%10\n\t\t\tt=int(t/10)\n\t\t\t#print(r,t)\n\t\t\tif r == 8:\n\t\t\t\tv8+=1\n\t\t\telif r==5:\n\t\t\t\tv5+=1\n\t...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00039-of-00128_1__public__0000", "expected_output": {"kind": "stdout", "value": "3\n"}, "input": {"kind": "stdin", "value": "6\nmilk 58\nCiel's Drink 80\nThe curry 2nd edition 888888\nrice omelet 85855\nunagi 1\n The first and last letters can be a spac...
{"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-00039-of-00128_3
For a non-negative integer N, define S(N) as the sum of the odd digits of N plus twice the sum of the even digits of N. For example, S(5)=5, S(456)=2*4+5+2*6=25, and S(314159)=3+1+2*4+1+5+9=27. Define D(N) as the last digit of S(N). So D(5)=5, D(456)=5, and D(314159)=7. Given 2 non-negative integers A and B, compute th...
[{"code": "def func(x):\n sum=0\n if x==0 or x==1:\n return 0\n sum+= (x/10)*45\n for z in range(x-(x%10),x):\n sum1=0\n while(z):\n r=z%10\n if(r%2==0):\n sum1+= 2*r\n else:\n sum1+=r\n z=z/10\n sum+= sum1...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00039-of-00128_3__public__0000", "expected_output": {"kind": "stdout", "value": "36\n495\n7\n"}, "input": {"kind": "stdin", "value": "3\n1 8\n28 138\n314159 314159"}, "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-00039-of-00128_77
An integer N is a multiple of 9 if and only if the sum of the digits in the decimal representation of N is a multiple of 9. Determine whether N is a multiple of 9. Constraints * 0 \leq N < 10^{200000} * N is an integer. Input Input is given from Standard Input in the following format: N Output If N is a multi...
[{"code": "import java.util.*;\npublic class Main {\n\tpublic static void main(String[] args){\n\t\tScanner input = new Scanner(System.in);\n\t\tString number = input.next();\n\t\tlong sum = 0;\n\t\tfor (int i = 0; i < number.length(); i++){\n\t\t\tsum += Character.getNumericValue(number.charAt(i));\n\t\t}\n\t\tif(sum%...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00039-of-00128_77__public__0000", "expected_output": {"kind": "stdout", "value": "Yes"}, "input": {"kind": "stdin", "value": "123456789"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riegeli-00039-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-00039-of-00128_78
We have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N. We will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7). Constraints * 1 \leq N \leq 2\times 10^5 * 1 \leq K \leq N+1 * All values in input are integers. Input Input is given from S...
[{"code": "import java.io.OutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.util.StringTokenizer;\nimport java.io.IOException;\nimport java.io.BufferedReader;\nimport java.io.InputStreamReader;\nimport java.io.InputStream;\n\n/**\n * Built using CHelper pl...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00039-of-00128_78__public__0000", "expected_output": {"kind": "stdout", "value": "220280457"}, "input": {"kind": "stdin", "value": "141421 35623"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riegeli-00039-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-00039-of-00128_79
There are N people numbered 1 to N. Each of them is either an honest person whose testimonies are always correct or an unkind person whose testimonies may be correct or not. Person i gives A_i testimonies. The j-th testimony by Person i is represented by two integers x_{ij} and y_{ij}. If y_{ij} = 1, the testimony say...
[{"code": "#include<bits/stdc++.h>\nusing namespace std;\n \n#define int long long\npair<int,int> b[55][55];\n \nsigned main(){\n int n;\n cin >> n;\n \n int a[n+1];\n \n for(int i= 0;i<n;i++){\n cin >> a[i];\n \n for(int j = 1;j<=a[i];j++){\n cin >> b[i][j].first >> b[i][j].second ;\n b[i][j].first...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00039-of-00128_79__public__0000", "expected_output": {"kind": "stdout", "value": "0"}, "input": {"kind": "stdin", "value": "3\n2\n2 1\n3 0\n2\n3 1\n1 0\n2\n1 1\n2 0"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_tr...
{"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-00039-of-00128_80
Let us define the oddness of a permutation p = {p_1,\ p_2,\ ...,\ p_n} of {1,\ 2,\ ...,\ n} as \sum_{i = 1}^n |i - p_i|. Find the number of permutations of {1,\ 2,\ ...,\ n} of oddness k, modulo 10^9+7. Constraints * All values in input are integers. * 1 \leq n \leq 50 * 0 \leq k \leq n^2 Input Input is given from...
[{"code": "#include <bits/stdc++.h>\nusing namespace std;\n\n#define rep(i, n) REP(i, 0, n)\n#define ALL(v) v.begin(), v.end()\n#define MSG(a) cout << #a << \" \" << a << endl;\n#define REP(i, x, n) for (int i = x; i < n; i++)\n#define OP(m) cout << m << endl;\n\nint mod = 1000000007;\n\n#define mul(a, b) ((a % mod) * ...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00039-of-00128_80__public__0000", "expected_output": {"kind": "stdout", "value": "74764168"}, "input": {"kind": "stdin", "value": "39 14"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riegeli-00039-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-00039-of-00128_81
Takahashi received otoshidama (New Year's money gifts) from N of his relatives. You are given N values x_1, x_2, ..., x_N and N strings u_1, u_2, ..., u_N as input. Each string u_i is either `JPY` or `BTC`, and x_i and u_i represent the content of the otoshidama from the i-th relative. For example, if x_1 = `10000` a...
[{"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 n = sc.nextInt();\n\t\tdouble money = 0.;\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString str = sc.next();\n\t\t\tif(sc.next().equals(\"JPY\")) {\n\t\t\t\tmoney += ...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00039-of-00128_81__public__0000", "expected_output": {"kind": "stdout", "value": "48000.0"}, "input": {"kind": "stdin", "value": "2\n10000 JPY\n0.10000000 BTC"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.ri...
{"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-00039-of-00128_83
You have an integer sequence of length N: a_1, a_2, ..., a_N. You repeatedly perform the following operation until the length of the sequence becomes 1: * First, choose an element of the sequence. * If that element is at either end of the sequence, delete the element. * If that element is not at either end of the seq...
[{"code": "def examC():\n ans = 0\n print(ans)\n return\n\ndef examD():\n ans = 0\n print(ans)\n return\n\ndef examE():\n N = I()\n A = LI()\n ans = -inf\n\n S = [0]*(N+1)\n fr = [-1]*N\n best = -1\n\n for i,a in enumerate(A):\n S[i] = a\n for j in range(i):\n ...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00039-of-00128_83__public__0000", "expected_output": {"kind": "stdout", "value": "11\n3\n1\n4\n2"}, "input": {"kind": "stdin", "value": "5\n1 4 3 7 5"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riegeli-000...
{"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-00039-of-00128_84
You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers. Constraints * -100 \leq A,B,C \leq 100 * A, B ...
[{"code": "#include<iostream>\nusing namespace std;\nint main(){\n int a,b,c,d;\n cin>>a>>b>>c;\n if(a==b){\n d=c;\n }\n else if(a==c){\n d=b;\n }\n else if(b==c){\n d=a;\n }\n cout<<d;\n}", "is_known_correct": true, "language": "cpp", "metadata": {}, "solution_id": "codecontests__test__code_contests_train.riegeli-0003...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00039-of-00128_84__public__0000", "expected_output": {"kind": "stdout", "value": "7"}, "input": {"kind": "stdin", "value": "5 7 5"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riegeli-00039-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-00040-of-00128_1
Tomya is a girl. She loves Chef Ciel very much. Tomya like a positive integer p, and now she wants to get a receipt of Ciel's restaurant whose total price is exactly p. The current menus of Ciel's restaurant are shown the following table. Name of Menuprice eel flavored water1 deep-fried eel bones2 clear soup made w...
[{"code": "menu = [1,2,4,8,16,32,64,128,256,512,1024,2048]\nmenu.reverse()\ndef find_menus(price, count):\n if price==0:\n return count\n for i in menu:\n if price/i>0:\n return find_menus(price%i, count+price/i)\n\nfor i in range(input()):\n print find_menus(input(), 0)", "is_known_co...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00040-of-00128_1__public__0000", "expected_output": {"kind": "stdout", "value": "2\n1\n8\n2\n"}, "input": {"kind": "stdin", "value": "4\n10\n256\n255\n4096"}, "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-00040-of-00128_5
For positive integer x let define function F(x) = 1 * (1! + x) + 2 * (2! + x) + .. + x * (x! + x). "k!" means factorial: k! = 1 * 2 * .. * k Chef wants to calculate F(p1) + F(p2) + ... + F(pn). As answer could be large, help him, calculate value modulo m. Input First line contains two integers n and m. Next line c...
[{"code": "arr=[]\ndef fact(x,m):\n f=1\n i=1;\n while i <=x+1:\n f=(f*i)%m\n arr.append(f)\n i+=1 \ndef f(x):\n if x>=m:\n return (x*x*(x+1)/2-1)%m\n else:\n return arr[x]+x*x*(x+1)/2-1\nn,m=map(int,raw_input().split())\na=map(int,raw_input().split())\nx=max(a)\nif x...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00040-of-00128_5__public__0000", "expected_output": {"kind": "stdout", "value": "6"}, "input": {"kind": "stdin", "value": "5 7\n1 2 3 4 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-00040-of-00128_77
N persons are standing in a row. The height of the i-th person from the front is A_i. We want to have each person stand on a stool of some heights - at least zero - so that the following condition is satisfied for every person: Condition: Nobody in front of the person is taller than the person. Here, the height of a ...
[{"code": "import java.util.ArrayList;\nimport java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String args[]) {\n\t\tScanner stdIn = new Scanner(System.in);\n\t\tint N = stdIn.nextInt();\n\t\tArrayList<Integer> A = new ArrayList<Integer>();\n\t\tfor(int i = 0; i < N; i ++) {\n\t\t\tA.add(stdIn.next...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00040-of-00128_77__public__0000", "expected_output": {"kind": "stdout", "value": "0"}, "input": {"kind": "stdin", "value": "5\n3 3 3 3 3"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riegeli-00040-of-00128_7...
{"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-00040-of-00128_78
There are N children standing in a line from left to right. The activeness of the i-th child from the left is A_i. You can rearrange these children just one time in any order you like. When a child who originally occupies the x-th position from the left in the line moves to the y-th position from the left, that child...
[{"code": "import java.util.Arrays;\nimport java.util.Scanner;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner scanner = new Scanner(System.in);\n\n int N = scanner.nextInt();\n Number[] numbers = new Number[N];\n for (int i = 0; i < N; i++) numbers[i] = new Number(i, scanner.ne...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00040-of-00128_78__public__0000", "expected_output": {"kind": "stdout", "value": "20"}, "input": {"kind": "stdin", "value": "4\n1 3 4 2"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riegeli-00040-of-00128_78...
{"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-00040-of-00128_79
We have N integers. The i-th integer is A_i. Find \sum_{i=1}^{N-1}\sum_{j=i+1}^{N} (A_i \mbox{ XOR } A_j), modulo (10^9+7). What is \mbox{ XOR }? The XOR of integers A and B, A \mbox{ XOR } B, is defined as follows: * When A \mbox{ XOR } B is written in base two, the digit in the 2^k's place (k \geq 0) is 1 if eith...
[{"code": "import java.io.OutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.util.StringTokenizer;\nimport java.io.IOException;\nimport java.io.BufferedReader;\nimport java.io.InputStreamReader;\nimport java.io.InputStream;\n\n/**\n * Built using CHelper pl...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00040-of-00128_79__public__0000", "expected_output": {"kind": "stdout", "value": "6"}, "input": {"kind": "stdin", "value": "3\n1 2 3"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riegeli-00040-of-00128_79__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-00040-of-00128_81
You have N bamboos. The lengths (in centimeters) of these are l_1, l_2, ..., l_N, respectively. Your objective is to use some of these bamboos (possibly all) to obtain three bamboos of length A, B, C. For that, you can use the following three kinds of magics any number: * Extension Magic: Consumes 1 MP (magic point)....
[{"code": "#include <bits/stdc++.h>\nusing namespace std;\n\nint INF=10000000;\nint N,A,B,C;\nvector<int> L;\n\nint rec(int i, int a, int b, int c){\n if(i==N){\n if(!a||!b||!c) return INF;\n return abs(a-A)+abs(b-B)+abs(c-C);\n }\n \n int res=rec(i+1,a,b,c);\n res=min(res, rec(i+1, a + L[i...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00040-of-00128_81__public__0000", "expected_output": {"kind": "stdout", "value": "243"}, "input": {"kind": "stdin", "value": "8 1000 800 100\n300\n333\n400\n444\n500\n555\n600\n666"}, "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-00040-of-00128_84
You are given an H × W grid. The squares in the grid are described by H strings, S_1,...,S_H. The j-th character in the string S_i corresponds to the square at the i-th row from the top and j-th column from the left (1 \leq i \leq H,1 \leq j \leq W). `.` stands for an empty square, and `#` stands for a square containin...
[{"code": "h,w = map(int,input().split())\ngrid = [\".\"*(w+2)]+[\".\"+input()+\".\" for _ in range(h)]+[\".\"*(w+2)]\nfor y in range(1,h+1):\n\tfor x in range(1,w+1):\n\t\tif grid[y][x]==\"#\":\n\t\t\tprint(\"#\",end=\"\")\n\t\telse:\n\t\t\tprint(sum(grid[i][j]==\"#\" for i in range(y-1,y+2) for j in range(x-1,x+2)),e...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00040-of-00128_84__public__0000", "expected_output": {"kind": "stdout", "value": "11211\n1#2#1\n11211"}, "input": {"kind": "stdin", "value": "3 5\n.....\n.#.#.\n....."}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_...
{"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-00040-of-00128_85
You are given three strings A, B and C. Check whether they form a word chain. More formally, determine whether both of the following are true: * The last character in A and the initial character in B are the same. * The last character in B and the initial character in C are the same. If both are true, print `YES`....
[{"code": "import java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.HashSet;\nimport java.util.List;\nimport java.util.Scanner;\n\npublic class Main{\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n String a = sc.next();\n String b = sc.next();\n ...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00040-of-00128_85__public__0000", "expected_output": {"kind": "stdout", "value": "YES"}, "input": {"kind": "stdin", "value": "a a a"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riegeli-00040-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-00041-of-00128_1
Tomya is a girl. She loves Chef Ciel very much. Today, too, Tomya is going to Ciel's restaurant. Of course, Tomya would like to go to Ciel's restaurant as soon as possible. Therefore Tomya uses one of the shortest paths from Tomya's house to Ciel's restaurant. On the other hand, Tomya is boring now to use the same pa...
[{"code": "NumOfTests = int(raw_input())\n\nfor test in range(NumOfTests):\n N, M = map(lambda s: int(s), raw_input().split())\n\n # n: min_distance, is_visited, num_of_paths\n D = {}\n # paths {vertex: [(neighb_vertex, length), ...], ...}\n P = {}\n for i in range(1, N+1):\n D[i]=[float(\"inf\...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00041-of-00128_1__public__0000", "expected_output": {"kind": "stdout", "value": "1\n2"}, "input": {"kind": "stdin", "value": "2\n3 3\n1 2 3\n2 3 6\n1 3 7\n3 3\n1 2 3\n2 3 6\n1 3 9"}, "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-00041-of-00128_3
This is a very easy warm-up problem. You are given a string. Your task is to determine whether number of occurrences of some character in the string is equal to the sum of the numbers of occurrences of other characters in the string.  Input The first line of the input contains an integer T denoting the number of test...
[{"code": "for _ in range(int(raw_input())):\n s=raw_input()\n l=len(s)\n ans=0\n for each in s:\n if s.count(each)==l/2:\n ans=1\n break\n\n if l%2:\n ans=0\n\n if ans:\n print \"YES\"\n else:\n print \"NO\"", "is_known_correct": true, "language": ...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00041-of-00128_3__public__0000", "expected_output": {"kind": "stdout", "value": "YES\nYES\nNO\nYES\n"}, "input": {"kind": "stdin", "value": "4\nacab\nzzqzqq\nabc\nkklkwwww"}, "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-00041-of-00128_4
You are given a permutation of natural integers from 1 to N, inclusive. Initially, the permutation is 1, 2, 3, ..., N. You are also given M pairs of integers, where the i-th is (Li Ri). In a single turn you can choose any of these pairs (let's say with the index j) and arbitrarily shuffle the elements of our permutatio...
[{"code": "intv_new = []\ndef bsearch(lo, hi, key):\n\tglobal intv_new\n\tmid = 0\n\twhile hi >= lo:\n\t\tmid = (hi + lo)/2\n\t\tif key[0] < intv_new[mid][0]:\n\t\t\thi = mid-1\n\t\telif key[1] > intv_new[mid][1]:\n\t\t\tlo = mid+1\n\t\telif key[0] >= intv_new[mid][0] and key[1] <= intv_new[mid][1]:\n\t\t\treturn True\...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00041-of-00128_4__public__0000", "expected_output": {"kind": "stdout", "value": "Possible\nImpossible"}, "input": {"kind": "stdin", "value": "2\n7 4\n3 1 2 4 5 7 6\n1 2\n4 4\n6 7\n2 3\n4 2\n2 1 3 4\n2 4\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-00041-of-00128_5
Chef and his little brother are playing with sticks. They have total N sticks. Length of i-th stick is Ai. Chef asks his brother to choose any four sticks and to make a rectangle with those sticks its sides. Chef warns his brother to not to break any of the sticks, he has to use sticks as a whole. Also, he wants that ...
[{"code": "import sys\nT=int(raw_input())\n\nfor i in range(T):\n\tn=int(raw_input())\n\ta=raw_input().split()\n\ta=[int(x) for x in a]\n\ta.sort()\n\tb=tuple(a)\n\tif n<=3:\n\t\tprint \"-1\"\n\t\tcontinue\n\tA=0\n\tB=0\n\tC=0\n\tD=0\n\tpossible1=False\n\tpossible2=False\n\tnext=0\n\tfor j in range(n+1):\n\t\tif j==n:\...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00041-of-00128_5__public__0000", "expected_output": {"kind": "stdout", "value": "2\n-1\n"}, "input": {"kind": "stdin", "value": "2\n5\n1 2 3 1 2\n4\n1 2 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-00041-of-00128_77
A maze is composed of a grid of H \times W squares - H vertical, W horizontal. The square at the i-th row from the top and the j-th column from the left - (i,j) - is a wall if S_{ij} is `#` and a road if S_{ij} is `.`. There is a magician in (C_h,C_w). He can do the following two kinds of moves: * Move A: Walk to a ...
[{"code": "#include<bits/stdc++.h>\nusing namespace std;\ntypedef pair<int,int> pi;\nint h,w;\nint arr[1005][1005];\nint dy[4]={0,0,1,-1};\nint dx[4]={1,-1,0,0};\nbool visited[1005][1005];\nint main(){\n\tint sx,sy;\n\tint des_x,des_y;\n\tcin>>h>>w>>sy>>sx>>des_y>>des_x;\n\tfor(int i=1; i<=h; i++){\n\t\tstring s;\n\t\t...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00041-of-00128_77__public__0000", "expected_output": {"kind": "stdout", "value": "1"}, "input": {"kind": "stdin", "value": "4 4\n1 1\n4 4\n..#.\n..#.\n.#..\n.#.."}, "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-00041-of-00128_78
We have a tree with N vertices numbered 1 to N. The i-th edge in this tree connects Vertex a_i and b_i. Additionally, each vertex is painted in a color, and the color of Vertex i is c_i. Here, the color of each vertex is represented by an integer between 1 and N (inclusive). The same integer corresponds to the same col...
[{"code": "import java.io.OutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.OutputStream;\nimport java.io.PrintWriter;\nimport java.util.Arrays;\nimport java.io.BufferedWriter;\nimport java.util.InputMismatchException;\nimport java.io.IOException;\nimport java.util.Stack;\nimport j...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00041-of-00128_78__public__0000", "expected_output": {"kind": "stdout", "value": "5\n4\n0"}, "input": {"kind": "stdin", "value": "3\n1 2 1\n1 2\n2 3"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riegeli-0004...
{"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-00041-of-00128_79
We have a grid with H horizontal rows and W vertical columns. Let (i,j) denote the square at the i-th row from the top and the j-th column from the left. The square (i, j) has two numbers A_{ij} and B_{ij} written on it. First, for each square, Takahashi paints one of the written numbers red and the other blue. Then...
[{"code": "from sys import stdin\ninput = stdin.buffer.readline\n\nh, w = map(int, input().split())\na = [list(map(int, input().split())) for _ in range(h)]\nb = [list(map(int, input().split())) for _ in range(h)]\n\n\ndp = [0] * -~w\ndp[0] = 1 << 6400\nfor i in range(h):\n for j in range(w):\n t = dp[j]\n ...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00041-of-00128_79__public__0000", "expected_output": {"kind": "stdout", "value": "0"}, "input": {"kind": "stdin", "value": "2 2\n1 2\n3 4\n3 4\n2 1"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riegeli-00041...
{"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-00041-of-00128_81
Along a road running in an east-west direction, there are A shrines and B temples. The i-th shrine from the west is located at a distance of s_i meters from the west end of the road, and the i-th temple from the west is located at a distance of t_i meters from the west end of the road. Answer the following Q queries: ...
[{"code": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.InputStreamReader;\nimport java.io.OutputStream;\nimport java.io.PrintWriter;\nimport java.util.*;\n\nclass Main {\n public static void main(String[] args) {\n InputStream inputStream = System.i...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00041-of-00128_81__public__0000", "expected_output": {"kind": "stdout", "value": "350\n1400\n301\n399"}, "input": {"kind": "stdin", "value": "2 3 4\n100\n600\n400\n900\n1000\n150\n2000\n899\n799"}, "metadata": {}, "visibility": "public"}, {"case_id": "codeco...
{"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-00041-of-00128_83
We have a 3×3 square grid, where each square contains a lowercase English letters. The letter in the square at the i-th row from the top and j-th column from the left is c_{ij}. Print the string of length 3 that can be obtained by concatenating the letters in the squares on the diagonal connecting the top-left and bot...
[{"code": "#include<iostream>\nusing namespace std;\nint main(){\n char a,b,c,d,e,f,g,h,i;\n cin>>a>>b>>c>>d>>e>>f>>g>>h>>i;\n cout<<a<<e<<i;\n}", "is_known_correct": true, "language": "cpp", "metadata": {}, "solution_id": "codecontests__test__code_contests_train.riegeli-00041-of-00128_83__ref__0000", "source": "ben...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00041-of-00128_83__public__0000", "expected_output": {"kind": "stdout", "value": "abc"}, "input": {"kind": "stdin", "value": "ant\nobe\nrec"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riegeli-00041-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-00041-of-00128_84
You are given an undirected connected graph with N vertices and M edges that does not contain self-loops and double edges. The i-th edge (1 \leq i \leq M) connects Vertex a_i and Vertex b_i. An edge whose removal disconnects the graph is called a bridge. Find the number of the edges that are bridges among the M edges....
[{"code": "#include <iostream>\n#include <cstdio>\nusing namespace std;\n\nint n, m, ans, s[55];\nbool a[55][55];\nvoid f(int p) {\n\tint i;\n\tif (s[p] == 1) {\n\t\tans++;\n\t\tfor (i =1; i <= n; i++) {\n\t\t\tif (a[p][i] == 1) break;\n\t\t}\n\t\ta[p][i] = a[i][p] = 0;\n\t\ts[p]--;\n\t\ts[i]--;\n\t\tf(i);\n\t}\n}\nint...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00041-of-00128_84__public__0000", "expected_output": {"kind": "stdout", "value": "0"}, "input": {"kind": "stdin", "value": "3 3\n1 2\n1 3\n2 3"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riegeli-00041-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-00041-of-00128_85
We ask you to select some number of positive integers, and calculate the sum of them. It is allowed to select as many integers as you like, and as large integers as you wish. You have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer. Your objecti...
[{"code": "#include <bits/stdc++.h>\nusing namespace std;\n\nint main()\n{\nint a,b,c; cin>>a>>b>>c;\n\nfor(int i = 0 ; i < 100 ; i++)\n{\nif ((b*i + c)%a == 0)\n{\ncout<<\"YES\";\nreturn 0;\n}\n}\ncout<<\"NO\";\nreturn 0;\n}", "is_known_correct": true, "language": "cpp", "metadata": {}, "solution_id": "codecontests__t...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00041-of-00128_85__public__0000", "expected_output": {"kind": "stdout", "value": "YES"}, "input": {"kind": "stdin", "value": "7 5 1"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riegeli-00041-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-00042-of-00128_3
Leonid is developing new programming language. The key feature of his language is fast multiplication and raising to a power operations. He is asking you to help with the following task. You have an expression S and positive integer M. S has the following structure: A1*A2*...*An where "*" is multiplication operation. ...
[{"code": "import math\nt = int(input())\nfor _ in range(t):\n M,S = raw_input().split()\n M = int(M)\n S = S.split('*')\n ans = 1\n for i in range(0, len(S), 3):\n ans = (ans * pow(int(S[i]), int(S[i+2]), M)) % M\n print(ans)", "is_known_correct": true, "language": "python", "metadata": {}, "s...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00042-of-00128_3__public__0000", "expected_output": {"kind": "stdout", "value": "24\n1936\n"}, "input": {"kind": "stdin", "value": "2\n1000 2**3*3**1\n100000 11**2*2**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-00042-of-00128_4
Some programming contest problems are really tricky: not only do they require a different output format from what you might have expected, but also the sample output does not show the difference. For an example, let us look at permutations. A permutation of the integers 1 to n is an ordering of these integers. So the n...
[{"code": "while True:\n n=int(raw_input())\n if n==0:\n break\n else:\n A=[]\n A = map(int,raw_input().split())\n j=1\n flag=0\n for i in A:\n if j!=A[i-1]:\n flag=1\n break\n j+=1\n if flag == 0:\n print \"ambiguous\"\n el...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00042-of-00128_4__public__0000", "expected_output": {"kind": "stdout", "value": "ambiguous\nnot ambiguous\nambiguous\n"}, "input": {"kind": "stdin", "value": "4\n1 4 3 2\n5\n2 3 4 5 1\n1\n1\n0"}, "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-00042-of-00128_74
Madhav went to Riya's Birthday Party. He was a geek so he had no idea regarding which gift she'l like. So he took an array of integers with him. The array followed a particular order. First element of array is 1. Second element of array is 6. Other elements of the array are two less than the mean of the number precedin...
[{"code": "for _ in xrange(int(raw_input())):\n\tn=int(raw_input())\n\tprint 1+( ( 4 * ((n*(n-1))/2))%1000000007 + (n-1)%1000000007) %1000000007", "is_known_correct": true, "language": "python", "metadata": {}, "solution_id": "codecontests__test__code_contests_train.riegeli-00042-of-00128_74__ref__0000", "source": "ben...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00042-of-00128_74__public__0000", "expected_output": {"kind": "stdout", "value": "1\n15\n"}, "input": {"kind": "stdin", "value": "2\n1\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-00042-of-00128_75
Your friend gives you an equation A≡X2(modM) and asks you to find an integer solution for X. However, you know your friend's mischievous nature and suspect that there is no solution to such an equation. Thus, you first want to find out whether there is a solution to it. You may find this link helpful: http://en.wikip...
[{"code": "for _ in range(input()):\n a, m = map(int, raw_input().split())\n if a == 0 or m == 2:\n print \"YES\"\n elif pow(a, (m - 1)/2, m) == 1:\n print \"YES\"\n else:\n print \"NO\"", "is_known_correct": true, "language": "python", "metadata": {}, "solution_id": "codecontests__test...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00042-of-00128_75__public__0000", "expected_output": {"kind": "stdout", "value": "NO \nYES"}, "input": {"kind": "stdin", "value": "2 \n5 7 \n4 7\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-00042-of-00128_77
We have a two-dimensional grid with H \times W squares. There are M targets to destroy in this grid - the position of the i-th target is \left(h_i, w_i \right). Takahashi will choose one square in this grid, place a bomb there, and ignite it. The bomb will destroy all targets that are in the row or the column where th...
[{"code": "#include <bits/stdc++.h>\nusing namespace std;\n\nint p1,p2,a[300005],b[300005];\nset<pair<int,int> > st;\nvector<int> v1,v2;\n\nint main()\n{\n\tint h,w,m;\n\tcin>>h>>w>>m;\n\t\n\twhile(m--)\n\t{\n\t\tint x,y;\n\t\tcin>>x>>y;\n\t\tst.insert(make_pair(x,y));\n\t\ta[x]++;\n\t\tb[y]++;\n\t\t\n\t\tif(a[x]>p1) v...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00042-of-00128_77__public__0000", "expected_output": {"kind": "stdout", "value": "3"}, "input": {"kind": "stdin", "value": "2 3 3\n2 2\n1 1\n1 3"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riegeli-00042-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-00042-of-00128_78
Given is a three-digit integer N. Does N contain the digit 7? If so, print `Yes`; otherwise, print `No`. Constraints * 100 \leq N \leq 999 Input Input is given from Standard Input in the following format: N Output If N contains the digit 7, print `Yes`; otherwise, print `No`. Examples Input 117 Output Y...
[{"code": "#include <iostream>\nusing namespace std;\nint main() {\n int n;\n cin>>n;\n if(n%10==7 || n/10%10==7 || n/100==7) cout<<\"Yes\"; else cout<<\"No\";\n}\n", "is_known_correct": true, "language": "cpp", "metadata": {}, "solution_id": "codecontests__test__code_contests_train.riegeli-00042-of-00128_78__ref__0...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00042-of-00128_78__public__0000", "expected_output": {"kind": "stdout", "value": "Yes"}, "input": {"kind": "stdin", "value": "777"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riegeli-00042-of-00128_78__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-00042-of-00128_79
We have an integer sequence A of length N, where A_1 = X, A_{i+1} = A_i + D (1 \leq i < N ) holds. Takahashi will take some (possibly all or none) of the elements in this sequence, and Aoki will take all of the others. Let S and T be the sum of the numbers taken by Takahashi and Aoki, respectively. How many possible ...
[{"code": "N,X,D=map(int,input().split())\n\nfrom collections import defaultdict\n\nA=defaultdict(list)\n\nA[0].append([0,0])\n\nMIN=0\nMAX=0\n\nif D==0:\n w=1\nelse:\n w=D\n\nfor i in range(N):\n MIN+=X+D*i\n MAX+=X+D*(N-1-i)\n\n A[MIN%w].append(sorted([MIN,MAX]))\n\nD=abs(D)\nif D==0:\n if X==0:\n ...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00042-of-00128_79__public__0000", "expected_output": {"kind": "stdout", "value": "2"}, "input": {"kind": "stdin", "value": "2 3 -3"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riegeli-00042-of-00128_79__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-00042-of-00128_82
You are given integers A and B, each between 1 and 3 (inclusive). Determine if there is an integer C between 1 and 3 (inclusive) such that A \times B \times C is an odd number. Constraints * All values in input are integers. * 1 \leq A, B \leq 3 Input Input is given from Standard Input in the following format: A...
[{"code": "print(\"Yes\" if all(int(i) % 2 != 0 for i in input().split()) else \"No\")", "is_known_correct": true, "language": "python", "metadata": {}, "solution_id": "codecontests__test__code_contests_train.riegeli-00042-of-00128_82__ref__0000", "source": "benchmark"}, {"code": "#include<stdio.h>\nint main()\n{\n\tin...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00042-of-00128_82__public__0000", "expected_output": {"kind": "stdout", "value": "Yes"}, "input": {"kind": "stdin", "value": "3 1"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riegeli-00042-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-00042-of-00128_83
Find the number of palindromic numbers among the integers between A and B (inclusive). Here, a palindromic number is a positive integer whose string representation in base 10 (without leading zeros) reads the same forward and backward. Constraints * 10000 \leq A \leq B \leq 99999 * All input values are integers. Inp...
[{"code": "#include <bits/stdc++.h>\nusing namespace std;\n \nint main() {\n int A,B;\n cin >> A >> B;\n int N=0;\n for(int i=A/100;i<=B/100;i++){\n int tmp=i*100+(i%100/10)*10+(i/100);\n if(A<=tmp&&tmp<=B)N++;\n }\n cout<<N<<endl;\n}", "is_known_correct": true, "language": "cpp", "metadata": {}, "solution_...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00042-of-00128_83__public__0000", "expected_output": {"kind": "stdout", "value": "4"}, "input": {"kind": "stdin", "value": "11009 11332"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riegeli-00042-of-00128_83...
{"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-00042-of-00128_84
We have N points in a two-dimensional plane. The coordinates of the i-th point (1 \leq i \leq N) are (x_i,y_i). Let us consider a rectangle whose sides are parallel to the coordinate axes that contains K or more of the N points in its interior. Here, points on the sides of the rectangle are considered to be in the inte...
[{"code": "import java.util.Arrays;\nimport java.util.Scanner;\n\npublic class Main {\n\n public static void main(String args[]) {\n try (Scanner in = new Scanner(System.in)) {\n\n int N = in.nextInt();\n int K = in.nextInt();\n\n long[] x = new long[N];\n long[] y ...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00042-of-00128_84__public__0000", "expected_output": {"kind": "stdout", "value": "3999999996000000001"}, "input": {"kind": "stdin", "value": "4 3\n-1000000000 -1000000000\n1000000000 1000000000\n-999999999 999999999\n999999999 -999999999"}, "metadata": {}, "...
{"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-00043-of-00128_3
A number is called as a lucky number if its decimal representation contains only the lucky digits, 4 and 7. e.g. 47, 744, 4 are lucky numbers, whereas 5, 17, 467 are not. Recently, Na2a found a magic stone. With the help of this stone, he can multiply a number by any lucky number. Also, the magic stone can be used any ...
[{"code": "n=input()\na=[]\na=map(int,raw_input().split())\nfor i in range (n):\n\tc2=0\n\tc5=0\n\t#print i\n\ttemp=a[i]\n\twhile temp%2==0:\n\t\tc2=c2+1\n\t\ttemp=temp/2\n\ttemp=a[i]\n\twhile temp%5==0:\n\t\tc5=c5+1\n\t\ttemp=temp/5\n\tans=a[i]\n\twhile c5>c2:\n\t\tans=ans*4\n\t\tc2=c2+2\t\n\tprint ans", "is_known_cor...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00043-of-00128_3__public__0000", "expected_output": {"kind": "stdout", "value": "2\n60\n"}, "input": {"kind": "stdin", "value": "2\n2 15"}, "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-00043-of-00128_4
The following graph G is called a Petersen graph and its vertices have been numbered from 0 to 9. Some letters have also been assigned to vertices of G, as can be seen from the following picture: Let's consider a walk W in graph G, which consists of L vertices W1, W2, ..., WL, such that Wi is connected with Wi + ...
[{"code": "def digit(c,present):\n\tif c=='A':\n\t\tif present=='i':\n\t\t\treturn \"5\"\n\t\telse:\n\t\t\treturn \"0\"\n\telif c=='B':\n\t\tif present=='i':\n\t\t\treturn \"6\"\n\t\telse:\n\t\t\treturn \"1\"\n\telif c=='C':\n\t\tif present=='i':\n\t\t\treturn \"7\"\n\t\telse:\n\t\t\treturn \"2\"\n\telif c=='D':\n\t\ti...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00043-of-00128_4__public__0000", "expected_output": {"kind": "stdout", "value": "501\n-1\n"}, "input": {"kind": "stdin", "value": "2\nAAB\nAABE"}, "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-00043-of-00128_5
Soma is a fashionable girl. She absolutely loves shiny stones that she can put on as jewellery accessories. She has been collecting stones since her childhood - now she has become really good with identifying which ones are fake and which ones are not. Her King requested for her help in mining precious stones, so she ...
[{"code": "test=int(raw_input())\na=0\n\nwhile(a<test):\n\ta=a+1\n\tcount=0\n\tj= raw_input()\n\ts= raw_input()\n\tfor letter in s:\n\t\tif (letter in j):\n\t\t\tcount=count+1\n\tprint count", "is_known_correct": true, "language": "python", "metadata": {}, "solution_id": "codecontests__test__code_contests_train.riegeli...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00043-of-00128_5__public__0000", "expected_output": {"kind": "stdout", "value": "3\n2\n1\n0\n"}, "input": {"kind": "stdin", "value": "4\nabc\nabcdef\naA\nabAZ\naaa\na\nwhat\nnone"}, "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-00043-of-00128_78
Let us define the FizzBuzz sequence a_1,a_2,... as follows: * If both 3 and 5 divides i, a_i=\mbox{FizzBuzz}. * If the above does not hold but 3 divides i, a_i=\mbox{Fizz}. * If none of the above holds but 5 divides i, a_i=\mbox{Buzz}. * If none of the above holds, a_i=i. Find the sum of all numbers among the first...
[{"code": "N = int(input())\ns = sum([i for i in range(1, N+1) if ((i%3)!=0) and ((i%5)!=0)])\nprint(s)", "is_known_correct": true, "language": "python", "metadata": {}, "solution_id": "codecontests__test__code_contests_train.riegeli-00043-of-00128_78__ref__0000", "source": "benchmark"}, {"code": "#include<bits/stdc++....
[{"case_id": "codecontests__test__code_contests_train.riegeli-00043-of-00128_78__public__0000", "expected_output": {"kind": "stdout", "value": "266666333332"}, "input": {"kind": "stdin", "value": "1000000"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riegeli-00043-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-00043-of-00128_82
Takahashi is practicing shiritori alone again today. Shiritori is a game as follows: * In the first turn, a player announces any one word. * In the subsequent turns, a player announces a word that satisfies the following conditions: * That word is not announced before. * The first character of that word is the same a...
[{"code": "#include <bits/stdc++.h>\nusing namespace std;\nint n;\nstring w;\nset<string>ss;\nint main(){\n\tcin>>n;\n\tchar c;\n\tfor(int i=0;i<n;i++){\n\t\tcin>>w;\n\t\tif(ss.count(w)==0){\n\t\t\tif(i!=0&&c!=w[0]){\n\t\t\t\tcout<<\"No\";\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tc=w[w.size()-1];\n\t\t\tss.insert(w);\n\t\t}\...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00043-of-00128_82__public__0000", "expected_output": {"kind": "stdout", "value": "No"}, "input": {"kind": "stdin", "value": "4\nhoge\nenglish\nhoge\nenigma"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riege...
{"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-00044-of-00128_1
AND gates and OR gates are basic components used in building digital circuits. Both gates have two input lines and one output line. The output of an AND gate is 1 if both inputs are 1, otherwise the output is 0. The output of an OR gate is 1 if at least one input is 1, otherwise the output is 0. You are given a digit...
[{"code": "def circuits():\n\tt=int(raw_input())\n\tfor i in range(t):\n\t\tn=raw_input()\n\t\tn=int(raw_input())\n\t\tinp=[]\n\t\tin1=[]\n\t\tin2=[]\n\t\tfor j in range(n):\n\t\t\tx=raw_input().split()\n\t\t\tinp.append(int(x[0]))\n\t\t\tif x[0]=='0':\n\t\t\t\tin1.append(0)\n\t\t\t\tin2.append(0)\n\t\t\telse:\n\t\t\t\...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00044-of-00128_1__public__0000", "expected_output": {"kind": "stdout", "value": "0.50000\n0.29289\n0.70711\n0.40303\n"}, "input": {"kind": "stdin", "value": "4\n\n1\n0\n\n3\n0\n0\n1 1 2\n\n3\n0\n0\n2 1 2\n\n5\n0\n0\n0\n2 1 2\n1 3 4"}, "metadata": {}, "visibi...
{"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-00044-of-00128_3
Once N boys and M girls attended a party. You are given a matrix A of N rows and M columns where Aij is 1 if the i-th boy likes the j-th girl, otherwise it will be 0. Note that it is not necessary that if a boy x likes girl y, then girl y should like boy x. You know that if there are two different boys x and y, who bot...
[{"code": "# @author Kilari Teja\n# LCOLLIS\n\n\nfor Indx in range(0, int(raw_input())):\n\tCollisions = 0\n\tDims = [int(Dim) for Dim in (raw_input()).split(\" \")]\n\n\tCols = [[] for CIndx in range(0, Dims[1])]\n\tfor RIndx in range(0, Dims[0]):\n\t\tRow = raw_input()\n\t\tfor Chr in range(0, Dims[1]):\n\t\t\tCols[C...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00044-of-00128_3__public__0000", "expected_output": {"kind": "stdout", "value": "4\n0\n"}, "input": {"kind": "stdin", "value": "2\n4 3\n111\n100\n110\n000\n2 2\n10\n01"}, "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-00044-of-00128_4
Recently, Chef got obsessed with piano. He is a just a rookie in this stuff and can not move his fingers from one key to other fast enough. He discovered that the best way to train finger speed is to play scales. There are different kinds of scales which are divided on the basis of their interval patterns. For instance...
[{"code": "for _ in range(input()):\n\ts=raw_input()\n\tn=input()\n\tt,sum=0,0\n\tfor i in s:\n\t\tif i=='T':\n\t\t\tsum+=2\n\t\t\t#print t\n\t\telse:\n\t\t\tsum+=1\n\t#sum=t+st\n\t#print sum\n\ttemp=12*n\n\tj,i,c=temp,1,0\n\twhile i<=temp:\n\t\tj=temp-i\n\t\twhile j:\n\t\t\tj-=sum\n\t\t\tif j>=0:\n\t\t\t\tc+=1\n\t\t\t...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00044-of-00128_4__public__0000", "expected_output": {"kind": "stdout", "value": "4\n36\n"}, "input": {"kind": "stdin", "value": "2 \nTTTT\n1\nTTSTTTS\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-00044-of-00128_5
John's barn has a fence consisting of N consecutive parts numbered from left to right starting from 1 to N. Each part is initially painted in one of two colors: red or green, whose information is provided you by a string C. The color of i-th part Ci will be equal to 'R' if the color of the part is red and 'G' if it is ...
[{"code": "t = int(raw_input())\nfor i in range(t):\n\tn,k = [int(j) for j in raw_input().split()]\n\tc = raw_input()\n\tl = list(c)\n\t\n\tq = []\n\tqf,qb = 0,0\n\t\n\tj,co = 0,0\n\twhile j < n:\n\t\tif (qb-qf)%2 == 0:\n\t\t\tif l[j] == 'R':\n\t\t\t\tco += 1\n\t\t\t\tq.append(min(n,j+k))\n\t\t\t\tqb += 1\n\t\telse:\n\...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00044-of-00128_5__public__0000", "expected_output": {"kind": "stdout", "value": "4"}, "input": {"kind": "stdin", "value": "1\n7 3\nRGGRGRG"}, "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-00044-of-00128_69
As we know , Professor Dalton is teaching Compiler Design. During his first class, he found that the students are very talkative. so,he decided to divide the class into two sections, A & B such that the difference between the strength of two sections is minimum. Print the strength of two sections in non decreasing o...
[{"code": "testcases = raw_input()\nfor i in range(int(testcases)):\n\ttot = raw_input()\n\ttot = int(tot)\n\tif(tot%2==0):\n\t\ta=tot/2\n\t\tprint a,a\n\telse:\n\t\ta=tot/2\n\t\tprint a,a+1", "is_known_correct": true, "language": "python", "metadata": {}, "solution_id": "codecontests__test__code_contests_train.riegeli...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00044-of-00128_69__public__0000", "expected_output": {"kind": "stdout", "value": "3 3\n4 4\n"}, "input": {"kind": "stdin", "value": "2\n6\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-00044-of-00128_77
We have weather records at AtCoder Town for some consecutive three days. A string of length 3, S, represents the records - if the i-th character is `S`, it means it was sunny on the i-th day; if that character is `R`, it means it was rainy on that day. Find the maximum number of consecutive rainy days in this period. ...
[{"code": "#include<bits/stdc++.h>\nusing namespace std;\ntypedef long long ll;\n\nint main(){\n string s;cin>>s;\n int an=0,cur=0;\n for(char x:s){\n if(x=='R') cur++;\n else cur=0;\n an=max(an,cur);\n }cout<<an<<\"\\n\";\n}\n\n", "is_known_correct": true, "language": "cpp", "metadata"...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00044-of-00128_77__public__0000", "expected_output": {"kind": "stdout", "value": "1"}, "input": {"kind": "stdin", "value": "RSR"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riegeli-00044-of-00128_77__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-00044-of-00128_78
Find \displaystyle{\sum_{a=1}^{K}\sum_{b=1}^{K}\sum_{c=1}^{K} \gcd(a,b,c)}. Here \gcd(a,b,c) denotes the greatest common divisor of a, b, and c. Constraints * 1 \leq K \leq 200 * K is an integer. Input Input is given from Standard Input in the following format: K Output Print the value of \displaystyle{\sum_{...
[{"code": "import math\nK=int(input())\nans=0\nfor i in range(1,K+1):\n for j in range(1,K+1):\n for k in range(1,K+1):\n ans+=math.gcd(math.gcd(i,j),k)\nprint(ans)", "is_known_correct": true, "language": "python", "metadata": {}, "solution_id": "codecontests__test__code_contests_train.riegeli-00044-of-00128_7...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00044-of-00128_78__public__0000", "expected_output": {"kind": "stdout", "value": "9"}, "input": {"kind": "stdin", "value": "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
ATCODER
[""]
null
codecontests__test__code_contests_train.riegeli-00044-of-00128_82
There are N cities on a number line. The i-th city is located at coordinate x_i. Your objective is to visit all these cities at least once. In order to do so, you will first set a positive integer D. Then, you will depart from coordinate X and perform Move 1 and Move 2 below, as many times as you like: * Move 1: tr...
[{"code": "import math\nn,x=map(int,input().split());l=[abs(x-i) for i in list(map(int,input().split()))];r=0\nfor i in range(len(l)): r=math.gcd(r,l[i])\nprint(r)", "is_known_correct": true, "language": "python", "metadata": {}, "solution_id": "codecontests__test__code_contests_train.riegeli-00044-of-00128_82__ref__00...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00044-of-00128_82__public__0000", "expected_output": {"kind": "stdout", "value": "24"}, "input": {"kind": "stdin", "value": "3 81\n33 105 57"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riegeli-00044-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-00044-of-00128_85
There are N bags, each containing two white balls. The i-th box contains two balls with integers x_i and y_i written on them, respectively. For each of these bags, you will paint one of the balls red, and paint the other blue. Afterwards, the 2N balls will be classified according to color. Then, we will define the f...
[{"code": "import sys\nfrom operator import itemgetter\n \ninf = 1 << 30\n \ndef solve():\n n = int(sys.stdin.readline())\n \n # r_max = MAX, b_min = MIN にしたとき\n \n r_max = b_max = 0\n r_min = b_min = inf\n \n p = []\n \n for i in range(n):\n xi, yi = map(int, sys.stdin.readline().split())\n \n...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00044-of-00128_85__public__0000", "expected_output": {"kind": "stdout", "value": "999999998000000001"}, "input": {"kind": "stdin", "value": "2\n1 1\n1000000000 1000000000"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_conte...
{"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-00045-of-00128_3
As we all know, Chef is cooking string for long days, his new discovery on string is the longest common pattern length. The longest common pattern length between two strings is the maximum number of characters that both strings have in common. Characters are case sensitive, that is, lower case and upper case characters...
[{"code": "test=input()\nfrom collections import Counter\nwhile test:\n test-=1\n s1=raw_input()\n s2=raw_input()\n a=Counter(s1)\n b=Counter(s2)\n count=0\n for i in a:\n if i in b:\n count+=min(a[i],b[i])\n print count", "is_known_correct": true, "language": "python", "metada...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00045-of-00128_3__public__0000", "expected_output": {"kind": "stdout", "value": "0\n4\n3\n5\n"}, "input": {"kind": "stdin", "value": "4\nabcd\nxyz\nabcd\nbcda\naabc\nacaa\nCodechef\nelfedcc"}, "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-00045-of-00128_5
Chef likes strings a lot but he likes palindromic strings more. Today, Chef has two strings A and B, each consisting of lower case alphabets. Chef is eager to know whether it is possible to choose some non empty strings s1 and s2 where s1 is a substring of A, s2 is a substring of B such that s1 + s2 is a palindromic ...
[{"code": "t = input()\nfor _ in xrange(t):\n a = raw_input()\n b = raw_input()\n if set(a) & set(b):\n print \"Yes\"\n else:\n print \"No\"", "is_known_correct": true, "language": "python", "metadata": {}, "solution_id": "codecontests__test__code_contests_train.riegeli-00045-of-00128_5__ref__...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00045-of-00128_5__public__0000", "expected_output": {"kind": "stdout", "value": "Yes\nNo\nYes\n"}, "input": {"kind": "stdin", "value": "3\nabc\nabc\na\nb\nabba\nbaab"}, "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-00045-of-00128_77
We have sticks numbered 1, \cdots, N. The length of Stick i (1 \leq i \leq N) is L_i. In how many ways can we choose three of the sticks with different lengths that can form a triangle? That is, find the number of triples of integers (i, j, k) (1 \leq i < j < k \leq N) that satisfy both of the following conditions: ...
[{"code": "import java.util.*;\npublic class Main {\n public static void main(String[] args) {\n Scanner fs = new Scanner(System.in);\n int n = fs.nextInt();\n long[] inp = new long[n];\n for(int i=0 ; i<n ; i++){\n inp[i] = fs.nextLong();\n }\n\n int ans = 0 ;\n\...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00045-of-00128_77__public__0000", "expected_output": {"kind": "stdout", "value": "0"}, "input": {"kind": "stdin", "value": "2\n1 1"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riegeli-00045-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-00045-of-00128_78
We have a string S of length N consisting of `R`, `G`, and `B`. Find the number of triples (i,~j,~k)~(1 \leq i < j < k \leq N) that satisfy both of the following conditions: * S_i \neq S_j, S_i \neq S_k, and S_j \neq S_k. * j - i \neq k - j. Constraints * 1 \leq N \leq 4000 * S is a string of length N consisting of...
[{"code": "from collections import *\n\nN=int(input())\nS=input()\nc=Counter(S)\n\nans=c['R']*c['G']*c['B']\n\nfor i in range(1,N//2+1):\n for j in range(i,N-i):\n if S[j-i]!=S[j] and S[j]!=S[j+i] and S[j+i]!=S[j-i]:\n ans-=1\n\nprint(ans)\n", "is_known_correct": true, "language": "python", "metadata": {}, "so...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00045-of-00128_78__public__0000", "expected_output": {"kind": "stdout", "value": "1"}, "input": {"kind": "stdin", "value": "4\nRRGB"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riegeli-00045-of-00128_78__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-00045-of-00128_82
There is a grid of square cells with H horizontal rows and W vertical columns. The cell at the i-th row and the j-th column will be denoted as Cell (i, j). In Cell (i, j), a_{ij} coins are placed. You can perform the following operation any number of times: Operation: Choose a cell that was not chosen before and con...
[{"code": "#include <bits/stdc++.h>\nusing namespace std;\n#define rep(i, n) for (int i = 0; i < (n); ++i)\ntypedef long long ll;\n\nint main(){\n\tint h,w;\n\tcin >> h >> w;\n\tvector<vector<int>> mp(h,vector<int>(w));\n\tint a;\n\trep(i,h){\n\t\trep(j,w){\n\t\t\tcin >> a;\n\t\t\tmp[i][j] = a%2;\n\t\t}\n\t}\n\tvector<...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00045-of-00128_82__public__0000", "expected_output": {"kind": "stdout", "value": "2\n1 1 1 2\n1 3 1 4"}, "input": {"kind": "stdin", "value": "1 5\n9 9 9 9 9"}, "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-00045-of-00128_83
Determine if there exists a sequence obtained by permuting 1,2,...,N that satisfies the following conditions: * The length of its longest increasing subsequence is A. * The length of its longest decreasing subsequence is B. If it exists, construct one such sequence. Constraints * 1 \leq N,A,B \leq 3\times 10^5 * ...
[{"code": "#include <bits/stdc++.h>\nusing namespace std;\n\nint n, a, b;\n\nint main() {\n cin >> n >> a >> b;\n\n if (a+b > n+1 or a*(long long)b < n) {\n cout << \"-1\";\n return 0;\n }\n\n vector<int> v(a-1, 0);\n \n for (int i=1; i<=n-b; i++) v[i%v.size()]++;\n\n v.push_back(b);\...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00045-of-00128_83__public__0000", "expected_output": {"kind": "stdout", "value": "1 2 3 4 5 6 7"}, "input": {"kind": "stdin", "value": "7 7 1"}, "metadata": {}, "visibility": "public"}, {"case_id": "codecontests__test__code_contests_train.riegeli-00045-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-00046-of-00128_2
As we all know, F.C. Barcelona is the best soccer team of our era! Their entangling and mesmerizing game style usually translates into very high ball possession, consecutive counter-attack plays and goals. Lots of goals, thanks to the natural talent of their attacker and best player in history, Lionel Andres Messi. How...
[{"code": "t=raw_input()\nt=int(t)\n\nwhile t!=0:\n\tn, k=raw_input().split(' ')\n\tn=int(n)\n\tk=int(k)\n\t\n\tcount=0\n\t\n\ti=1\n\t\n\twhile i<n:\n\t\tcount=pow(k, i)-count\n\t\ti+=1\n\t\n\tprint (count%1000000007);\n\tt-=1", "is_known_correct": true, "language": "python", "metadata": {}, "solution_id": "codecontest...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00046-of-00128_2__public__0000", "expected_output": {"kind": "stdout", "value": "4\n6\n"}, "input": {"kind": "stdin", "value": "2\n2 4\n4 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-00046-of-00128_3
The Little Elephant and his friends from the Zoo of Lviv were returning from the party. But suddenly they were stopped by the policeman Big Hippo, who wanted to make an alcohol test for elephants. There were N elephants ordered from the left to the right in a row and numbered from 0 to N-1. Let R[i] to be the result of...
[{"code": "#!/usr/bin/python\nfrom sys import stdin\n\nT = int(stdin.readline())\nglobal N,K,M,R\nglobal minimal\n\ndef check(i,current):\n global N,K,M,R\n global minimal\n #print current,minimal,i,R\n if current >= minimal:\n return\n if i >= N:\n if current < minimal:\n minima...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00046-of-00128_3__public__0000", "expected_output": {"kind": "stdout", "value": "0\n1\n1\n-1"}, "input": {"kind": "stdin", "value": "4\n5 3 2\n1 3 1 2 1\n5 3 3\n7 7 7 7 7\n5 3 3\n7 7 7 8 8\n4 3 1\n1 3 1 2"}, "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-00046-of-00128_5
Chef likes strings a lot but moreover he likes good strings. Chef calls a string str a good string if str starts and ends at different characters. For eg : strings such as abab , baccba , abc are all good strings whereas strings like aba, baab , baacaab are not good at all . Today, Chef has a special string P consistin...
[{"code": "ch=str(raw_input())\nlength=len(ch)\narr=[]\ncur=0\ntemp=[]\nfor k in range(length):\n if(ch[k]=='c'):\n cur+=1\n temp.append(cur)\n else:\n temp.append(cur)\narr.append(temp)\ncur=0\ntemp=[]\nfor k in range(length):\n if(ch[k]=='e'):\n cur+=1\n ...
[{"case_id": "codecontests__test__code_contests_train.riegeli-00046-of-00128_5__public__0000", "expected_output": {"kind": "stdout", "value": "4\n8\n2\n2\n2"}, "input": {"kind": "stdin", "value": "checfcheff\n5\nc h 1 10\nc f 1 10\ne c 1 10\nc f 1 5\nc f 6 10"}, "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