question_id
int64
41
56.8k
question_title
stringlengths
5
37
question_content
stringlengths
206
4.02k
dataset
stringclasses
1 value
difficulty
stringclasses
3 values
java
dict
java15
dict
java8
dict
python
dict
test_cases
stringlengths
28
2.49M
max_retries
float64
1
3
⌀
17,610
Non-Divisible Subset
Given a set of distinct integers, print the size of a maximal subset of $S$ where the sum of any $2$ numbers in $S'$ is *not* evenly divisible by $k$. **Example** $S = [19, 10, 12, 10, 24, 25, 22]$ $k = 4$ One of the arrays that can be created is $S'[0] = [10, 12, 25]$. Another is $S'[1] = [19, 22, 24]$. After t...
hackerrank
Medium
{ "class_name": "Result", "func_sign": [ "public static int nonDivisibleSubset(int k, List<Integer> s)" ], "script_name": "Solution", "solution": "import java.io.BufferedWriter;\n\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.OutputStream;\nimport java.io.OutputStreamWriter;\ni...
{ "solution": "import java.io.*;\nimport java.math.*;\nimport java.security.*;\nimport java.text.*;\nimport java.util.*;\nimport java.util.concurrent.*;\nimport java.util.function.*;\nimport java.util.regex.*;\nimport java.util.stream.*;\nimport static java.util.stream.Collectors.joining;\nimport static java.util.str...
{ "solution": "import java.io.*;\nimport java.util.*;\nimport java.text.*;\nimport java.math.*;\nimport java.util.regex.*;\n\npublic class Solution {\n\n public static void main(String[] args) {\n Scanner in = new Scanner(System.in);\n int n = in.nextInt();\n int k = in.nextInt();\n int...
{ "class_name": null, "func_sign": [ "nonDivisibleSubset(k, s)" ], "solution": "read = lambda: map(int, input().split())\n\nn, k = read()\na = list(read())\ncnt = [0] * k\nfor x in a:\n cnt[x % k] += 1\n \nans = min(cnt[0], 1)\nfor rem in range(1, (k + 1) // 2):\n ans += max(cnt[rem], cnt[k - rem])...
eJxM3UuuLc2SHGY2OJCF22YjH5ERmRwJARWghlQNdUpsFAEBBAFC89UcaJ/FvoCKAP9zz9l7rXxEeLibm5n/z//4X/6///c//of/7b//4//6t//63/79H//594/395z/8m/PGvca53P+7jW/8xj39XufOc/7u+dvXN+xjud7f2PdY+bnrt/zPm/+dYzfut/7+uZ3/a7rPu5zPPNf/u0f/+n3j3/9f/7rv/4f//6v/+f//n//t3//57flX/7Hf/r9/77/e9/1e9e//Nu5vuP41np/PvVcd/601ljnPR4fvcY4juP5jWPlSlb+7h3PPddz...
null
26,114
Fraudulent Activity Notifications
HackerLand National Bank has a simple policy for warning clients about possible fraudulent account activity. If the amount spent by a client on a particular day is *greater than or equal to* $2 \times $ the client's [median](https://en.wikipedia.org/wiki/Median) spending for a trailing number of days, they send the cli...
hackerrank
Medium
{ "class_name": "Result", "func_sign": [ "public static int activityNotifications(List<Integer> expenditure, int d)" ], "script_name": "Solution", "solution": "\nimport java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\n\n/**\n *\n * @author jin\n */\npublic class Sol...
{ "solution": "import java.io.*;\nimport java.math.*;\nimport java.security.*;\nimport java.text.*;\nimport java.util.*;\nimport java.util.concurrent.*;\nimport java.util.function.*;\nimport java.util.regex.*;\nimport java.util.stream.*;\nimport static java.util.stream.Collectors.joining;\nimport static java.util.str...
{ "solution": "import java.io.*;\nimport java.lang.reflect.Array;\nimport java.util.*;\n\npublic class Main implements Runnable {\n\n int[] cnt;\n\n int med(int d) {\n int[] a = Arrays.copyOf(cnt, cnt.length);\n int r = d / 2;\n if (d % 2 == 1) {\n r++;\n }\n int re...
{ "class_name": null, "func_sign": [ "activityNotifications(expenditure, d)" ], "solution": "from bisect import bisect_left, insort_left\n\nn, d = map(int, input().split())\nt = list(map(int, input().split()))\nnoti = 0\n\nlastd = sorted(t[:d])\ndef med():\n return lastd[d//2] if d % 2 == 1 else ((lastd[...
eJztvcuuJcmylU2DBwntNkJ+v/AkSBSiAadBp6BxkH7pFxIPAY/DU9Gjhdv4hsecWVm5dYRo1q7MvXKtFTPCw93cLsOGmf+3f/4//vf//Gf637/+X+cf/+b//9t//P0//5d//Nu/ev7WR35K+u33OZ89nrWfPOb5259c0pNXefI+/z4X5d2e/aynjvPt+Tvr+Xp+3c5V5xNpPee6Wp5+flbW+WF9Rlx+bn++K/s59018tJ3rz8/3uUOJm6cnnnUuqfMp4zzlfLfnuV88tpy/OYZ1HrTPvc/Px1M3d4mHnWfm8cSv41/t/KY2/V36Lt4q...
null
26,945
Hackerland Radio Transmitters
Hackerland is a one-dimensional city with houses aligned at integral locations along a road. The Mayor wants to install radio transmitters on the roofs of the city's houses. Each transmitter has a fixed range meaning it can transmit a signal to all houses within that number of units distance away. Given a map of Hacke...
hackerrank
Medium
{ "class_name": "Result", "func_sign": [ "public static int hackerlandRadioTransmitters(List<Integer> x, int k)" ], "script_name": "Solution", "solution": "import java.io.*;\nimport java.util.*;\nimport java.text.*;\nimport java.math.*;\nimport java.util.regex.*;\n\npublic class Solution {\n\n public s...
{ "solution": "import java.io.*;\nimport java.math.*;\nimport java.security.*;\nimport java.text.*;\nimport java.util.*;\nimport java.util.concurrent.*;\nimport java.util.function.*;\nimport java.util.regex.*;\nimport java.util.stream.*;\nimport static java.util.stream.Collectors.joining;\nimport static java.util.str...
{ "solution": "import java.io.*;\nimport java.util.*;\n\npublic class UnivCodesprint2016qA {\n\n public static void main(String[] args) {\n InputReader in = new InputReader(System.in);\n PrintWriter w = new PrintWriter(System.out);\n\n int n = in.nextInt();\n int k = in.nextInt();\n ...
{ "class_name": null, "func_sign": [ "hackerlandRadioTransmitters(x, k)" ], "solution": "#!/bin/python3\n\nimport sys\n\n\nn,k = input().strip().split(' ')\nn,k = [int(n),int(k)]\nx = [int(x_temp) for x_temp in input().strip().split(' ')]\n\nx.sort()\n\ns = set(x)\nminx = x[0]\nmaxx = x[-1]\nd = dict(zip(ra...
eJxEvUuSZUusXKcGR6ARHHsjCMQ/OBKZkRNg5xkbUosddjVrYS3sLHXK7q3KPGd/IhCAw93xv//L//X//p//5f/4b//rP/7Hf/7P/+f//o//+vuP6Ku933mz3f/+n3FfxK+P1+6vn7XXb504vznuXb958p9/vb05fmNFn7/T1v2NES3/s+e/zd75udfa7+z967vd8ZvrzvYb78382TfP/eXHtPyxMVb7Pf5znBfjF73lb0c76/xizT1/M3b/zbtXfnTbO36jx4z8m5NXOUbbj189+YN77/HrfZ6d/31u/lZ+fP7r7Ct/8rYTvxjnbi6x...
null
60
Problem solving
There are N problems numbered 1..N which you need to complete. You've arranged the problems in increasing difficulty order, and the i<sup>th</sup> problem has estimated difficulty level *i*. You have also assigned a rating *vi* to each problem. Problems with similar *vi* values are similar in nature. On each day, you w...
hackerrank
Hard
{ "class_name": "Result", "func_sign": [ "public static int problemSolving(int k, List<Integer> v)" ], "script_name": "Solution", "solution": "import java.io.*;\nimport java.util.*;\n\npublic class Solution {\n\n\tprivate void solution() throws IOException {\n\t\tint ts = in.nextInt();\n\t\twhile (ts-- > ...
{ "solution": "import java.io.*;\nimport java.math.*;\nimport java.security.*;\nimport java.text.*;\nimport java.util.*;\nimport java.util.concurrent.*;\nimport java.util.function.*;\nimport java.util.regex.*;\nimport java.util.stream.*;\nimport static java.util.stream.Collectors.joining;\nimport static java.util.str...
{ "solution": "import java.io.*;\nimport java.util.*;\n\npublic class Solution {\n\n private static final class Data {\n\n private final int index;\n private final int value;\n\n private boolean visited = false;\n private int match = -1;\n\n private Data(int i, int v) {\n ...
{ "class_name": null, "func_sign": [ "problemSolving(k, v)" ], "solution": "G = []\nV = []\nM = []\n\ndef find(v):\n for u in G[v]:\n if not V[u]:\n V[u] = True\n if M[u]==-1 or find(M[u]):\n M[u] = v\n return True\n return False\n\n\nt = int(input())\nfor _ in range(t):\n n, k...
eJztm8uqp0tSxR34IB81biQz8hoOfA7BEgd6Bk7KHpwGQYR+iPY9nPl6rt+Kr9q262ywEcHBPpxd+/L/Lplxj7Uif/vn//Yff/Vn/u+v/10//M2/fPnHb7/+zc9f/vL5sr9+6/2Jdb5+y9ueftezdzwR5+H3OOfZMZ+795NHf5/9OVs3zXgOtw5dvp+ZunWsZ+qSvnVJPn3lM3TRvvrreZYeuo7+cp+zti7IZ01dNZ6uV6229eh4xjzPae0ZZ2kpz7p6fA49IPUgXR39ST339qlL23P12jvOE7olpp66uXXr8/7cZ4+lFbbnxPj67ejJ...
null
20,732
Beautiful Triplets
Given a sequence of integers $a$, a triplet $(a[i],a[j],a[k])$ is beautiful if: * $i<j<k$ * $a[j]-a[i] = a[k]-a[j] = d$ Given an increasing sequenc of integers and the value of $d$, count the number of beautiful triplets in the sequence. **Example** $arr = [2, 2, 3, 4, 5]$ $d = 1$ There are three beautifu...
hackerrank
Easy
{ "class_name": "Result", "func_sign": [ "public static int beautifulTriplets(int d, List<Integer> arr)" ], "script_name": "Solution", "solution": "import java.io.*;\nimport java.util.*;\nimport java.text.*;\nimport java.math.*;\nimport java.util.regex.*;\n\npublic class Solution {\n\n public static vo...
{ "solution": "import java.util.*;\n\npublic class BeautifulTriplets {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int d = sc.nextInt();\n int count = 0;\n HashSet<Integer> set = new HashSet<>();\n for(int i =...
{ "solution": "\nimport java.io.ByteArrayInputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.util.Arrays;\nimport java.util.InputMismatchException;\n\npublic class B {\n\tInputStream is;\n\tPrintWriter out;\n\tString INPUT = \"\";\n\t\n\tvoid solve()\n\t{\n...
{ "class_name": null, "func_sign": [ "beautifulTriplets(d, arr)" ], "solution": "n, d = map(int, input().split())\na = list(map(int, input().split()))\ncnt = {}\nleft = []\nfor x in a:\n left.append(cnt.get(x-d, 0))\n if x not in cnt:\n cnt[x] = 0\n cnt[x] += 1\nleft = left[::-1]\ncnt = {}\n...
eJzs3b+ufE12l3ECX0hrYge9q9afKq4ECUsE4ACCwYEtIVlIXAHXTD1P7X6FNHJCypt0YE4xM2fV7/TuT3/XWv/r7/7Df/vff/fv/uO//uW//vWf/uWf//LvP3+Jzs/T//DX7+f5jM/8xCc/9enP+uzPc/6Pz+cZn2d+nvg85yfr/PDnWZ9nf8b3M86Z8RnzM+Iz8jPqM/oz1mfsz/x+5vOZ5//L+ZnxmfmZ9Zn9mesz9ye+n3g+MT5x/hPjE/mJ+kR/Yn1if/L7yeeT45Pzk+e/UH6yPtmfXJ/cn/p+6vnU+NT8VHzq/PetT/Wn1qf2...
null
19,049
Synchronous Shopping
Bitville is a seaside city that has a number of shopping centers connected by bidirectional roads, each of which has a travel time associated with it. Each of the shopping centers may have a fishmonger who sells one or more kinds of fish. Two cats, *Big Cat* and *Little Cat*, are at shopping center $1$ (each of the c...
hackerrank
Medium
{ "class_name": "Result", "func_sign": [ "public static int shop(int n, int k, List<String> centers, List<List<Integer>> roads)" ], "script_name": "Solution", "solution": "import java.io.BufferedWriter;\n\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.OutputStream;\nimport java....
{ "solution": "import java.util.*;\n\npublic class SynchronousShopping {\n\n private static class Truple {\n int dist;\n int next;\n int fish;\n\n public Truple(int dist, int next, int fish) {\n this.dist = dist;\n this.next = next;\n this.fish = fish;\n...
{ "solution": "import java.io.*;\nimport java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.PriorityQueue;\n\npublic class HR_synchronous_shopping {\n\n static int k;\n\n public static void solve(Input in, PrintWriter out) throws IOException {\n int n = in.nextInt();\n int m = in.nex...
{ "class_name": null, "func_sign": [ "shop(n, k, centers, roads)" ], "solution": "from heapq import *\nfrom itertools import *\nfrom sys import stderr\n\ndef main():\n nvert, nedge, setsize = readints()\n vertexhas = []\n for _ in range(nvert):\n nelts, *elts = readints()\n assert nel...
eJycvcuuLEuTrQUSD5Kq9mmE391p8hRILIkGVIPOz2nUkZAQEo+Oj29YREbmzJxrF9JftdfMS2SEu7ldhw37f/+H/zn/T//9f/e//N//9n/867/+t//4t//x8W/lkR/5z7/SI/35V34k/9v/79H0UtF//u2/PP7t3/+v//rv/9t//Pv//r/+n//tP+LL6dhv/T//5XG7XpvtMdt66K2yr1f4V9OVH+MxH+vPv+qjPfr+Y+ny+7U//5q8fb7Oh/pDP133C5MrTK5Vzw/E9fXK0OX3XfKGXk76/v7v4qolrnv/0oyb8rvj/L0aF1n6ufzj...
null
28,833
Queen's Attack II
You will be given a square chess board with one queen and a number of obstacles placed on it. Determine how many squares the queen can attack. A [queen](https://en.wikipedia.org/wiki/Queen_%28chess%29) is standing on an $n \times n$ [chessboard](https://en.wikipedia.org/wiki/Chess). The chess board's rows are numbe...
hackerrank
Medium
{ "class_name": "Result", "func_sign": [ "public static int queensAttack(int n, int k, int r_q, int c_q, List<List<Integer>> obstacles)" ], "script_name": "Solution", "solution": "import java.io.*;\nimport java.util.*;\nimport java.text.*;\nimport java.math.*;\nimport java.util.regex.*;\n\npublic class So...
{ "solution": "import java.io.*;\nimport java.math.*;\nimport java.security.*;\nimport java.text.*;\nimport java.util.*;\nimport java.util.concurrent.*;\nimport java.util.function.*;\nimport java.util.regex.*;\nimport java.util.stream.*;\nimport static java.util.stream.Collectors.joining;\nimport static java.util.str...
{ "solution": "import java.io.OutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.OutputStream;\nimport java.io.PrintWriter;\nimport java.util.Iterator;\nimport java.io.BufferedWriter;\nimport java.util.InputMismatchException;\nimport java.io.IOException;\nimport java.io.Writer;\ni...
{ "class_name": null, "func_sign": [ "queensAttack(n, k, r_q, c_q, obstacles)" ], "solution": "#!/bin/python3\n\nn, k = map(int, input().split())\nrQueen, cQueen = map(int, input().split())\nobstacles = set()\nfor _ in range(k):\n rObs, cObs = map(int, input().split())\n obstacles.add((rObs, cObs))\na...
eJzsvbvOLT2SHTiGHuSg7DaSd1JPMsAUIEMqQ06rjWpAgNCA3mtebmJdMneIPQWMMaYE6DRr/ZH55c5kkHFZEfyf/+H//Lf/+z/8H//X//jLf/3nf/nXv//lP/75Sxt/yvrrP9f5p/Dfyn8b/+38d/z1nwv/I/5p+Kfjn0Fs8YLNCw4uaA8uaOXPTLf7/v3LP/35y9/++7/87T///W//5T/9t3/9ux9ixIV/+bd/+pOfq7U/z1//ec4/5x9eVp5S/92FpfDCM/6M/Q+vbOv/5cL4gRu/sPlnNjxx44/SS8CPxD8d/wyN8I4gN773NPHT...
null
8,947
Components in a graph
There are $2 \times N$ nodes in an undirected graph, and a number of edges connecting some nodes. In each edge, the first value will be between $1$ and $N$, inclusive. The second node will be between $N+1$ and $2 \times N$, inclusive. Given a list of edges, determine the size of the smallest and largest connected co...
hackerrank
Medium
{ "class_name": "Result", "func_sign": [ "public static List<Integer> componentsInGraph(List<List<Integer>> gb)" ], "script_name": "Solution", "solution": "import java.io.*;\nimport java.util.*;\nimport java.text.*;\nimport java.math.*;\nimport java.util.regex.*;\n\npublic class Solution {\n // Each it...
{ "solution": "import java.io.*;\nimport java.util.*;\n\npublic class Solution {\n\n public static void main(String[] args) {\n /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */\n Scanner scanner = new Scanner(System.in);\n int n = ...
{ "solution": "import java.io.*;\nimport java.util.*;\n\npublic class Solution {\n \n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n Set<Node> groups = new HashSet<>(n / 2);\n Node[] nodes = new Node[n * 2];\n for (int...
{ "class_name": null, "func_sign": [ "componentsInGraph(gb)" ], "solution": "class UF:\n def __init__(self, size):\n self.parent = [i for i in range(size + 1)]\n self.size = [1] * (size + 1)\n \n def _parent(self, a):\n while self.parent[a] != a:\n self.parent[a]...
eJzsvb2ubruOntlBd+C7mNhxBYPk+PWVNOACHNgncFKu4BRgoGDAl97iS43BZ+6DU6hKG0rW+taa3+T4kfSKpB5R/+f//n//9T/9P//Xf/nXP/7HP/3zv/z1j//888f+j/9kP/c//pP/nPz0xz/8/PGX//XPf/lvf/3Lf/+v//Nf/jq/7T/+x//+hx/8vudvxfzj3/1b9ozfsB/f9It55b3+Mf96fvyof8X3r7u+OH7Lxl/nj+e/7veL+bOjfrT9MmX1jfpRX+XfuluLP92uLvxzjl+N+NnHKxvXu8abGv837MT5sz95f5d//1dfGBff...
null