Dataset Viewer
Auto-converted to Parquet Duplicate
Unnamed: 0
int64
0
269
challenge_id
int64
104
5.95k
challenge_slug
stringlengths
4
38
challenge_name
stringlengths
5
57
challenge_body
stringlengths
9
4.55k
challenge_kind
stringclasses
2 values
challenge_preview
stringlengths
9
300
challenge_category
stringclasses
2 values
challenge_created_at
stringdate
2013-01-04 20:28:56
2015-01-19 21:40:20
challenge_updated_at
stringdate
2016-09-01 16:22:55
2022-09-02 10:36:47
python3_template
stringlengths
2
303
python3_template_head
stringclasses
2 values
python3_template_tail
stringclasses
52 values
problem_statement
stringlengths
9
4.55k
difficulty
float64
0.4
0.6
allowed_languages
stringclasses
28 values
input_format
stringlengths
1
987
output_format
stringlengths
1
1.92k
sample_input
stringlengths
1
284
sample_output
stringclasses
52 values
difficulty_tag
stringclasses
1 value
editorial_title
stringclasses
32 values
editorial_content
stringclasses
32 values
editorial_draft
float64
0
0
editorial_slug
stringclasses
32 values
editorial_published_at
stringdate
2013-03-04 16:26:12
2014-04-24 18:24:07
editorial_statistics
stringclasses
45 values
editorial_created_at
stringdate
2013-03-04 16:26:12
2015-01-19 21:44:31
editorial_updated_at
stringdate
2016-05-12 23:56:02
2020-09-08 16:59:12
editorial_solution_kind
stringclasses
2 values
editorial_solution_code
stringlengths
2
13k
editorial_solution_language
stringclasses
1 value
editorial_solution_created_at
stringdate
2016-04-24 02:02:11
2016-04-24 02:03:27
editorial_solution_updated_at
stringdate
2016-04-24 02:02:11
2020-09-08 16:59:12
language
stringclasses
7 values
0
337
randomsumexpected
Random Sum - Expected Sum
Given an a list D of N integers, and an integer T, two numbers L and R are randomly chosen such that 0 ≤ L ≤ R < N. What is the expected sum of the subarray {d[L]...d[R]} given that (sum{d[L],...d[R]} <= T)? **Input Format:** The first line will contain two numbers: N and T. N lines follow, each containing one numbe...
code
What is the expected sum of a randomly chosen range of numbers?
ai
2013-01-29T20:58:30
2016-09-09T09:28:39
null
null
null
Given an a list D of N integers, and an integer T, two numbers L and R are randomly chosen such that 0 ≤ L ≤ R < N. What is the expected sum of the subarray {d[L]...d[R]} given that (sum{d[L],...d[R]} <= T)? **Input Format:** The first line will contain two numbers: N and T. N lines follow, each containing one numbe...
0.495261
["bash","c","cpp","java","csharp","php","ruby","python","perl","haskell","clojure","scala","lua","go","javascript","erlang","sbcl","d","ocaml","pascal","python3","groovy","objectivec","fsharp","visualbasic","lolcode","smalltalk","tcl","java8","r","racket","rust","swift","cpp14"]
null
null
null
null
Hard
Random Sum - Expected Sum Solution by <a href ="https://www.hackerrank.com/sidsgr88">Siddharth Bora</a>
<style id="MathJax_SVG_styles">.MathJax_SVG_Display {text-align: center; margin: 1em 0em; position: relative; display: block!important; text-indent: 0; max-width: none; max-height: none; min-width: 0; min-height: 0; width: 100%} .MathJax_SVG .MJX-monospace {font-family: monospace} .MathJax_SVG .MJX-sans-serif {font-fam...
0
randexpsum
2013-03-04T16:26:12
{"contest_participation":6014,"challenge_submissions":421,"successful_submissions":210}
2013-03-04T16:26:12
2016-05-13T00:04:48
tester
using namespace std; #include <cmath> #include <cstdio> #include <list> #include <map> #include <set> #include <queue> #include <deque> #include <stack> #include <bitset> #include <string> #include <vector> #include <iostream> #include <sstream> #include <algo...
not-set
2016-04-24T02:02:11
2016-04-24T02:02:11
C++
1
556
n-puzzle
N Puzzle
N Puzzle is a sliding blocks game that takes place on a k * k grid with ((k * k) - 1) tiles each numbered from 1 to N. Your task is to reposition the tiles to their proper order. **Input Format** The first line of the input contains an integer k, the size of the square grid. k * k lines follow each line containing an...
game
N Puzzle is a sliding blocks game that takes place on a k * k grid with (k * k) - 1 tiles each numbered from 1 to N. Place the tiles in their proper order using minimum number of moves.
ai
2013-04-06T14:13:29
2022-08-31T18:04:25
null
null
null
N Puzzle is a sliding blocks game that takes place on a k * k grid with ((k * k) - 1) tiles each numbered from 1 to N. Your task is to reposition the tiles to their proper order. **Input Format** The first line of the input contains an integer k, the size of the square grid. k * k lines follow each line containing an...
0.456522
["bash","c","clojure","cpp","cpp14","cpp20","csharp","d","elixir","erlang","fsharp","go","groovy","haskell","java","java8","java15","javascript","julia","lolcode","lua","objectivec","ocaml","pascal","perl","php","python3","r","racket","ruby","rust","sbcl","scala","smalltalk","tcl","typescript","visualbasic","kotlin","p...
null
null
null
null
Hard
May 20-20 Hack Editorial: N - Puzzle
<style id="MathJax_SVG_styles">.MathJax_SVG_Display {text-align: center; margin: 1em 0em; position: relative; display: block!important; text-indent: 0; max-width: none; max-height: none; min-width: 0; min-height: 0; width: 100%} .MathJax_SVG .MJX-monospace {font-family: monospace} .MathJax_SVG .MJX-sans-serif {font-fam...
0
may-2020-editorial-npuzzle
2013-06-10T13:14:35
{"contest_participation":3663,"challenge_submissions":135,"successful_submissions":0}
2013-06-10T13:14:35
2016-05-13T00:04:45
setter
#include<iostream> #include<vector> #include<queue> #include<set> #include<map> #include<algorithm> #define INRANGE(i, a, b) (i >= a && i < b) using namespace std; class SlidingBlock { public: vector < int > disc; int n; int cost; ...
not-set
2016-04-24T02:02:11
2016-04-24T02:02:11
C++
2
746
game-of-throne-ii
Game Of Thrones - II
This follows from [Game of Thrones - I](https://www.hackerrank.com/contests/july13/challenges/game-of-thrones). Now that the king knows how to find out whether a given word has an [anagram](https://en.wikipedia.org/wiki/Anagram) which is a [palindrome](http://en.wikipedia.org/wiki/Palindrome) or not, he encounters ano...
code
Can you help the king find the number of ways his door can be unlocked?
ai
2013-07-02T17:07:43
2022-09-02T09:54:54
# # Complete the 'solve' function below. # # The function is expected to return an INTEGER. # The function accepts STRING s as parameter. # def solve(s): # Write your code here
#!/bin/python3 import math import os import random import re import sys
if __name__ == '__main__': fptr = open(os.environ['OUTPUT_PATH'], 'w') s = input() result = solve(s) fptr.write(str(result) + '\n') fptr.close()
This follows from [Game of Thrones - I](https://www.hackerrank.com/contests/july13/challenges/game-of-thrones). Now that the king knows how to find out whether a given word has an [anagram](https://en.wikipedia.org/wiki/Anagram) which is a [palindrome](http://en.wikipedia.org/wiki/Palindrome) or not, he encounters ano...
0.501678
["c","clojure","cpp","cpp14","cpp20","csharp","erlang","go","haskell","java","java8","java15","javascript","julia","kotlin","lua","objectivec","perl","php","pypy3","python3","ruby","rust","scala","swift","typescript","r"]
null
null
null
null
Hard
20/20 Hack July Editorial: Game of Thrones - 2
<style id="MathJax_SVG_styles">.MathJax_SVG_Display {text-align: center; margin: 1em 0em; position: relative; display: block!important; text-indent: 0; max-width: none; max-height: none; min-width: 0; min-height: 0; width: 100%} .MathJax_SVG .MJX-monospace {font-family: monospace} .MathJax_SVG .MJX-sans-serif {font-fam...
0
july-2020-editorial-game-of-thrones-ii
2013-07-22T04:35:37
{"contest_participation":4325,"challenge_submissions":1181,"successful_submissions":695}
2013-07-22T04:35:37
2016-12-02T19:33:05
setter
###Python 2 ```python #!/usr/bin/py from collections import Counter mod = 10**9 + 7 def hasPalindrome(word): x = Counter(word) count = 0 for i in x: if x[i]%2!=0: count += 1 if count > 1: return False else: return True def getfactmod(b): ...
not-set
2016-04-24T02:02:12
2016-07-23T18:36:16
Python
3
746
game-of-throne-ii
Game Of Thrones - II
This follows from [Game of Thrones - I](https://www.hackerrank.com/contests/july13/challenges/game-of-thrones). Now that the king knows how to find out whether a given word has an [anagram](https://en.wikipedia.org/wiki/Anagram) which is a [palindrome](http://en.wikipedia.org/wiki/Palindrome) or not, he encounters ano...
code
Can you help the king find the number of ways his door can be unlocked?
ai
2013-07-02T17:07:43
2022-09-02T09:54:54
# # Complete the 'solve' function below. # # The function is expected to return an INTEGER. # The function accepts STRING s as parameter. # def solve(s): # Write your code here
#!/bin/python3 import math import os import random import re import sys
if __name__ == '__main__': fptr = open(os.environ['OUTPUT_PATH'], 'w') s = input() result = solve(s) fptr.write(str(result) + '\n') fptr.close()
This follows from [Game of Thrones - I](https://www.hackerrank.com/contests/july13/challenges/game-of-thrones). Now that the king knows how to find out whether a given word has an [anagram](https://en.wikipedia.org/wiki/Anagram) which is a [palindrome](http://en.wikipedia.org/wiki/Palindrome) or not, he encounters ano...
0.501678
["c","clojure","cpp","cpp14","cpp20","csharp","erlang","go","haskell","java","java8","java15","javascript","julia","kotlin","lua","objectivec","perl","php","pypy3","python3","ruby","rust","scala","swift","typescript","r"]
null
null
null
null
Hard
20/20 Hack July Editorial: Game of Thrones - 2
<style id="MathJax_SVG_styles">.MathJax_SVG_Display {text-align: center; margin: 1em 0em; position: relative; display: block!important; text-indent: 0; max-width: none; max-height: none; min-width: 0; min-height: 0; width: 100%} .MathJax_SVG .MJX-monospace {font-family: monospace} .MathJax_SVG .MJX-sans-serif {font-fam...
0
july-2020-editorial-game-of-thrones-ii
2013-07-22T04:35:37
{"contest_participation":4325,"challenge_submissions":1181,"successful_submissions":695}
2013-07-22T04:35:37
2016-12-02T19:33:05
tester
###C++ ```cpp #include <cstdio> #include <cstring> #include <bits/stdc++.h> using namespace std; int t; const long long mod = 1000000007; long long pow(long long osn){ long long res = 1, tmp = osn; int m = int(mod - 2); while(m){ if(m % 2){ res = (res * tmp) % mod; ...
not-set
2016-04-24T02:02:12
2016-07-23T18:36:38
C++
4
791
kth-ancestor
Kth Ancestor
A tree of P nodes is an un-directed connected graph having P-1 edges. Let us denote R as the root node. If A is a node such that it is at a distance of L from R, and B is a node such that it is at at distance of L+1 from R and A is connected to B, then we call A as the parent of B. Similarly, if A is at a distance o...
code
Figure out the K-th parent of a node at any instant.
ai
2013-08-01T18:06:31
2022-08-31T08:14:29
null
null
null
A tree of $P$ nodes is an un-directed connected graph having $P-1$ edges. Let us denote $R$ as the root node. If $A$ is a node such that it is at a distance of $L$ from $R$, and $B$ is a node such that it is at at distance of $L+1$ from $R$ and $A$ is connected to $B$, then we call $A$ as the parent of $B$. Similarl...
0.435294
["ada","bash","c","clojure","coffeescript","cpp","cpp14","cpp20","csharp","d","elixir","erlang","fortran","fsharp","go","groovy","haskell","java","java8","java15","javascript","julia","kotlin","lolcode","lua","objectivec","ocaml","octave","pascal","perl","php","pypy3","python3","r","racket","ruby","rust","sbcl","scala"...
The first line contain an integer $T$ denoting the number of test cases. $T$ test cases follow. First line of each test case contains an integer $P$, the number of nodes in the tree. $P$ lines follows each containing two integers $X$ and $Y$ separated by a single space denoting $Y$ as the parent of $X$. If $Y$ is $0$, ...
For each query of type $2$, output the $K$<sup>th</sup> parent of $X$. If $K$<sup>th</sup> parent doesn't exist, output $0$ and if the node doesn't exist, output $0$.
2 7 2 0 5 2 3 5 7 5 9 8 8 2 6 8 10 0 5 15 2 15 2 1 3 0 15 20 0 20 13 2 13 4 2 13 3 2 6 10 2 11 1 2 9 1 1 10000 0 3 0 10000 4 1 4 2 4 1
2 2 5 0 0 8 0
Hard
Kth Parent : August 2020 Editorial
<style id="MathJax_SVG_styles">.MathJax_SVG_Display {text-align: center; margin: 1em 0em; position: relative; display: block!important; text-indent: 0; max-width: none; max-height: none; min-width: 0; min-height: 0; width: 100%} .MathJax_SVG .MJX-monospace {font-family: monospace} .MathJax_SVG .MJX-sans-serif {font-fam...
0
aug-2020-editorial-kth-parent
2013-08-13T08:25:00
{"contest_participation":3656,"challenge_submissions":458,"successful_submissions":180}
2013-08-13T08:25:00
2016-12-02T15:06:47
setter
###C++ ```cpp #include <cstdio> #include <cstring> #include <cstdlib> #include <cmath> #include <iostream> #include <string> #include <vector> #include <set> #include <queue> #include <stack> #include <map> #include <utility> #include <algorithm> #include <cassert> using namespace std; #define INF 2147483...
not-set
2016-04-24T02:02:12
2016-07-23T13:56:04
C++
5
803
help-mike
Help Mike
Harvey Specter has agreed to take Mike Ross to a meeting filled with brilliant scientists at NSA Headquarters. But, as always, it's not going to be easy for Mike. He has to solve a puzzle given by Harvey. Harvey gives two numbers N and K and defines a set A.<br> *A = { x : x is a [natural number](https://en.wikipedi...
code
Help Mike attend the NSA meeting
ai
2013-08-13T09:29:32
2022-09-02T09:54:27
# # Complete the 'solve' function below. # # The function is expected to return a LONG_INTEGER. # The function accepts following parameters: # 1. INTEGER n # 2. INTEGER k # def solve(n, k): # Write your code here
#!/bin/python3 import math import os import random import re import sys
if __name__ == '__main__': fptr = open(os.environ['OUTPUT_PATH'], 'w') t = int(input().strip()) for t_itr in range(t): first_multiple_input = input().rstrip().split() n = int(first_multiple_input[0]) k = int(first_multiple_input[1]) result = solve(n, k) fptr.wri...
Harvey Specter has agreed to take Mike Ross to a meeting filled with brilliant scientists at NSA Headquarters. But, as always, it's not going to be easy for Mike. He has to solve a puzzle given by Harvey. Harvey gives two numbers N and K and defines a set A.<br> *A = { x : x is a [natural number](https://en.wikipedi...
0.579365
["c","clojure","cpp","cpp14","cpp20","csharp","erlang","go","haskell","java","java8","java15","javascript","julia","kotlin","lua","objectivec","perl","php","pypy3","python3","ruby","rust","scala","swift","typescript","r"]
null
null
null
null
Hard
Help Mike - Sept 2020 Editorial
<style id="MathJax_SVG_styles">.MathJax_SVG_Display {text-align: center; margin: 1em 0em; position: relative; display: block!important; text-indent: 0; max-width: none; max-height: none; min-width: 0; min-height: 0; width: 100%} .MathJax_SVG .MJX-monospace {font-family: monospace} .MathJax_SVG .MJX-sans-serif {font-fam...
0
sep-2020-editorial-help-mike
2013-09-16T13:48:37
{"contest_participation":3240,"challenge_submissions":1167,"successful_submissions":494}
2013-09-16T13:48:37
2016-12-03T12:59:31
setter
###C++ ```cpp #include<bits/stdc++.h> using namespace std; #define print(p) cout<<p<<endl; int main() { int T; long long int N,K,i; cin>>T; while(T--) { cin>>N>>K; long long int arr[K]; arr[0] = N/K; for(i=1 ; i< K ; i++) arr[i] = (int)(...
not-set
2016-04-24T02:02:13
2016-07-23T17:46:38
C++
6
803
help-mike
Help Mike
Harvey Specter has agreed to take Mike Ross to a meeting filled with brilliant scientists at NSA Headquarters. But, as always, it's not going to be easy for Mike. He has to solve a puzzle given by Harvey. Harvey gives two numbers N and K and defines a set A.<br> *A = { x : x is a [natural number](https://en.wikipedi...
code
Help Mike attend the NSA meeting
ai
2013-08-13T09:29:32
2022-09-02T09:54:27
# # Complete the 'solve' function below. # # The function is expected to return a LONG_INTEGER. # The function accepts following parameters: # 1. INTEGER n # 2. INTEGER k # def solve(n, k): # Write your code here
#!/bin/python3 import math import os import random import re import sys
if __name__ == '__main__': fptr = open(os.environ['OUTPUT_PATH'], 'w') t = int(input().strip()) for t_itr in range(t): first_multiple_input = input().rstrip().split() n = int(first_multiple_input[0]) k = int(first_multiple_input[1]) result = solve(n, k) fptr.wri...
Harvey Specter has agreed to take Mike Ross to a meeting filled with brilliant scientists at NSA Headquarters. But, as always, it's not going to be easy for Mike. He has to solve a puzzle given by Harvey. Harvey gives two numbers N and K and defines a set A.<br> *A = { x : x is a [natural number](https://en.wikipedi...
0.579365
["c","clojure","cpp","cpp14","cpp20","csharp","erlang","go","haskell","java","java8","java15","javascript","julia","kotlin","lua","objectivec","perl","php","pypy3","python3","ruby","rust","scala","swift","typescript","r"]
null
null
null
null
Hard
Help Mike - Sept 2020 Editorial
<style id="MathJax_SVG_styles">.MathJax_SVG_Display {text-align: center; margin: 1em 0em; position: relative; display: block!important; text-indent: 0; max-width: none; max-height: none; min-width: 0; min-height: 0; width: 100%} .MathJax_SVG .MJX-monospace {font-family: monospace} .MathJax_SVG .MJX-sans-serif {font-fam...
0
sep-2020-editorial-help-mike
2013-09-16T13:48:37
{"contest_participation":3240,"challenge_submissions":1167,"successful_submissions":494}
2013-09-16T13:48:37
2016-12-03T12:59:31
tester
###Python 2 ```python #!/usr/bin/py import math T = input() 1 <= T <= 100 for t in range(T): N, K = map(int, raw_input().strip().split(" ")) assert 1 <= N <= 10**9 assert 1 <= K <= 10**4 assert K <= N n_by_k = math.floor(N/K) n_mod_k = N%K count_less_than_k = K/2 if K % 2 ...
not-set
2016-04-24T02:02:13
2016-07-23T17:46:49
Python
7
800
chocolate-game
Chocolate Game
Laurel and Hardy have N piles of chocolates with each pile containing some number of chocolates. The piles are arranged from left to right in a non decreasing order based on the number of chocolates in each pile. They play the following game. For every continuous subsequence of chocolate piles (at least 2 piles form ...
code
Count continuous sub-sequences for winning Chocolate Game.
ai
2013-08-09T20:02:16
2022-08-31T08:15:06
# # Complete the 'chocolateGame' function below. # # The function is expected to return an INTEGER. # The function accepts INTEGER_ARRAY arr as parameter. # def chocolateGame(arr): # Write your code here
#!/bin/python3 import math import os import random import re import sys
if __name__ == '__main__': fptr = open(os.environ['OUTPUT_PATH'], 'w') arr_count = int(input().strip()) arr = list(map(int, input().rstrip().split())) result = chocolateGame(arr) fptr.write(str(result) + '\n') fptr.close()
Laurel and Hardy have $n$ piles of chocolates with each pile containing some number of chocolates. The piles are arranged from left to right in a non decreasing order based on the number of chocolates in each pile. They play the following game. For every continuous subsequence of chocolate piles (at least 2 piles for...
0.487805
["c","clojure","cpp","cpp14","cpp20","csharp","erlang","go","haskell","java","java8","java15","javascript","julia","kotlin","lua","objectivec","perl","php","pypy3","python3","r","ruby","rust","scala","swift","typescript"]
The first line contains an integer $n$ denoting the number of piles. The second line contains the number of chocolates in each pile, arranged from left to right and separated by a single space between them.
A single integer denoting the number of continuous subsequences of chocolate piles in which Laurel will win.
5 1 1 2 2 3
5
Hard
2020 September Editorial: Chocolate Game
<style id="MathJax_SVG_styles">.MathJax_SVG_Display {text-align: center; margin: 1em 0em; position: relative; display: block!important; text-indent: 0; max-width: none; max-height: none; min-width: 0; min-height: 0; width: 100%} .MathJax_SVG .MJX-monospace {font-family: monospace} .MathJax_SVG .MJX-sans-serif {font-fam...
0
chocolate-game
2013-09-24T09:33:08
{"contest_participation":3240,"challenge_submissions":230,"successful_submissions":51}
2013-09-24T09:33:08
2016-07-23T16:18:17
setter
###C++ ```cpp #include <map> #include <set> #include <list> #include <queue> #include <deque> #include <stack> #include <bitset> #include <vector> #include <ctime> #include <cmath> #include <cstdio> #include <string> #include <cstring> #include <cassert> #include <numeric> #include <sstream> #include <iostream> #in...
not-set
2016-04-24T02:02:13
2016-07-23T16:18:18
C++
8
836
sherlock-puzzle
Sherlock Puzzle
Sherlock Holmes is bored to death as there aren't any interesting cases to solve. Dr Watson finding it impossible to be around Sherlock goes out to get some fresh air. Just as he lays his feet out of the door, he is thrown right back into his house by the explosion in front of his apartment. The metropolitan police arr...
code
Help Sherlock get close to his Arch Nemesis, Jim Moriarty.
ai
2013-08-24T15:49:01
2022-09-02T09:54:36
null
null
null
Sherlock Holmes is bored to death as there aren't any interesting cases to solve. Dr Watson finding it impossible to be around Sherlock goes out to get some fresh air. Just as he lays his feet out of the door, he is thrown right back into his house by the explosion in front of his apartment. The metropolitan police arr...
0.567568
["bash","c","clojure","cpp","cpp14","cpp20","csharp","d","elixir","erlang","fsharp","go","groovy","haskell","java","java8","java15","javascript","julia","kotlin","lolcode","lua","objectivec","ocaml","pascal","perl","php","python3","r","racket","ruby","rust","sbcl","scala","smalltalk","swift","tcl","typescript","visualb...
null
null
null
null
Hard
2020 September Editorial: Sherlock Puzzle
<style id="MathJax_SVG_styles">.MathJax_SVG_Display {text-align: center; margin: 1em 0em; position: relative; display: block!important; text-indent: 0; max-width: none; max-height: none; min-width: 0; min-height: 0; width: 100%} .MathJax_SVG .MJX-monospace {font-family: monospace} .MathJax_SVG .MJX-sans-serif {font-fam...
0
sep2020-sherlock-puzzle
2013-09-24T09:42:06
{"contest_participation":3240,"challenge_submissions":292,"successful_submissions":72}
2013-09-24T09:42:06
2016-07-23T17:59:56
setter
###C++ ```cpp #include <map> #include <set> #include <list> #include <queue> #include <deque> #include <stack> #include <bitset> #include <vector> #include <ctime> #include <cmath> #include <cstdio> #include <string> #include <cstring> #include <cassert> #include <numeric> #include <sstream> #include <iostream> #in...
not-set
2016-04-24T02:02:13
2016-07-23T17:59:56
C++
9
1,049
angry-children-2
Angry Children 2
Bill Gates is on one of his philanthropic journeys to a village in Utopia. He has **N** packets of candies and would like to distribute one packet to each of the **K** children in the village (each packet may contain different number of candies). To avoid a fight between the children, he would like to pick **K** out o...
code
Select K elements from N elements such that the sum absolute value of differences of adjacent elements is minimized
ai
2013-10-08T12:22:10
2022-08-31T08:14:42
# # Complete the 'angryChildren' function below. # # The function is expected to return a LONG_INTEGER. # The function accepts following parameters: # 1. INTEGER k # 2. INTEGER_ARRAY packets # def angryChildren(k, packets): # Write your code here
#!/bin/python3 import math import os import random import re import sys
if __name__ == '__main__': fptr = open(os.environ['OUTPUT_PATH'], 'w') n = int(input().strip()) k = int(input().strip()) packets = [] for _ in range(n): packets_item = int(input().strip()) packets.append(packets_item) result = angryChildren(k, packets) fptr.write(str(re...
Bill Gates is on one of his philanthropic journeys to a village in Utopia. He has brought a box of packets of candies and would like to distribute one packet to each of the children. Each of the packets contains a number of candies. He wants to minimize the cumulative difference in the number of candies in the packet...
0.532895
["c","clojure","cpp","cpp14","cpp20","csharp","erlang","go","haskell","java","java8","java15","javascript","julia","kotlin","lua","objectivec","perl","php","pypy3","python3","r","ruby","rust","scala","swift","typescript"]
The first line contains an integer $n$. The second line contains an integer $k$. Each of the next $n$ lines contains an integer $packets[i]$.
A single integer representing the minimum achievable unfairness sum. **Sample Input 0** 7 3 10 100 300 200 1000 20 30 **Sample Output 0** 40 **Explanation 0** Bill Gates will choose packets having 10, 20 and 30 candies. The unfairness sum is $|10-20| + |20-30| + |10-30| = 40...
Hard
Angry Children 2 : Oct 2020 Editorial
<style id="MathJax_SVG_styles">.MathJax_SVG_Display {text-align: center; margin: 1em 0em; position: relative; display: block!important; text-indent: 0; max-width: none; max-height: none; min-width: 0; min-height: 0; width: 100%} .MathJax_SVG .MJX-monospace {font-family: monospace} .MathJax_SVG .MJX-sans-serif {font-fam...
0
oct-2020-angry-children-ii
2013-10-29T06:01:32
{"contest_participation":7868,"challenge_submissions":2266,"successful_submissions":1120}
2013-10-29T06:01:32
2018-05-14T17:07:47
setter
###Python 2 ```python n = input() k = input() assert 1 <= n <= 10**5 assert 1 <= k <= n lis = [] for i in range(n): lis.append(input()) lis.sort() sum_lis = [] for i in lis: assert 0 <= i <= 10**9 val = 1-k answer = 0 sum_lis.append(lis[0]) for i in range(1,n): sum_lis.append(su...
not-set
2016-04-24T02:02:13
2016-07-23T14:51:01
Python
10
1,049
angry-children-2
Angry Children 2
Bill Gates is on one of his philanthropic journeys to a village in Utopia. He has **N** packets of candies and would like to distribute one packet to each of the **K** children in the village (each packet may contain different number of candies). To avoid a fight between the children, he would like to pick **K** out o...
code
Select K elements from N elements such that the sum absolute value of differences of adjacent elements is minimized
ai
2013-10-08T12:22:10
2022-08-31T08:14:42
# # Complete the 'angryChildren' function below. # # The function is expected to return a LONG_INTEGER. # The function accepts following parameters: # 1. INTEGER k # 2. INTEGER_ARRAY packets # def angryChildren(k, packets): # Write your code here
#!/bin/python3 import math import os import random import re import sys
if __name__ == '__main__': fptr = open(os.environ['OUTPUT_PATH'], 'w') n = int(input().strip()) k = int(input().strip()) packets = [] for _ in range(n): packets_item = int(input().strip()) packets.append(packets_item) result = angryChildren(k, packets) fptr.write(str(re...
Bill Gates is on one of his philanthropic journeys to a village in Utopia. He has brought a box of packets of candies and would like to distribute one packet to each of the children. Each of the packets contains a number of candies. He wants to minimize the cumulative difference in the number of candies in the packet...
0.532895
["c","clojure","cpp","cpp14","cpp20","csharp","erlang","go","haskell","java","java8","java15","javascript","julia","kotlin","lua","objectivec","perl","php","pypy3","python3","r","ruby","rust","scala","swift","typescript"]
The first line contains an integer $n$. The second line contains an integer $k$. Each of the next $n$ lines contains an integer $packets[i]$.
A single integer representing the minimum achievable unfairness sum. **Sample Input 0** 7 3 10 100 300 200 1000 20 30 **Sample Output 0** 40 **Explanation 0** Bill Gates will choose packets having 10, 20 and 30 candies. The unfairness sum is $|10-20| + |20-30| + |10-30| = 40...
Hard
Angry Children 2 : Oct 2020 Editorial
<style id="MathJax_SVG_styles">.MathJax_SVG_Display {text-align: center; margin: 1em 0em; position: relative; display: block!important; text-indent: 0; max-width: none; max-height: none; min-width: 0; min-height: 0; width: 100%} .MathJax_SVG .MJX-monospace {font-family: monospace} .MathJax_SVG .MJX-sans-serif {font-fam...
0
oct-2020-angry-children-ii
2013-10-29T06:01:32
{"contest_participation":7868,"challenge_submissions":2266,"successful_submissions":1120}
2013-10-29T06:01:32
2018-05-14T17:07:47
tester
###C++ ```cpp #include<stdio.h> #include<stdlib.h> #include<algorithm> #include<assert.h> using namespace std; #define Max_N 100001 typedef long long int ll; long long int sum[Max_N]; int N,K,input[Max_N]; ll min(ll a,ll b) { if(a>b) return b; else return a; } int main() { int val; scanf("%d%d",&...
not-set
2016-04-24T02:02:13
2016-07-23T14:51:25
C++
11
1,084
period
Period
You are given 2 integers **a** and **b**. Let a number be defined as ![Image1](https://hr-filepicker.s3.amazonaws.com/period1.png). As we know ![Image1](https://hr-filepicker.s3.amazonaws.com/period1.png) will be an irrational number when b is non-zero. In this problem, we call it the AC number. We define ![Image2](h...
code
Can you find the period?
ai
2013-10-16T05:50:59
2022-09-02T09:54:45
null
null
null
You are given 2 integers **a** and **b**. Let a number be defined as ![image1](https://s3.amazonaws.com/hr-assets/0/1526567764-7f13ff1150-period1.png). As we know ![image1](https://s3.amazonaws.com/hr-assets/0/1526567764-7f13ff1150-period1.png) will be an irrational number when b is non-zero. In this problem, we call ...
0.564516
["bash","c","clojure","cpp","cpp14","cpp20","csharp","d","elixir","erlang","fsharp","go","groovy","haskell","java","java8","java15","javascript","julia","kotlin","lolcode","lua","objectivec","ocaml","pascal","perl","php","python3","r","racket","ruby","rust","sbcl","scala","smalltalk","swift","tcl","typescript","visualb...
Hard
Period : Oct 2020 Editorial
<style id="MathJax_SVG_styles">.MathJax_SVG_Display {text-align: center; margin: 1em 0em; position: relative; display: block!important; text-indent: 0; max-width: none; max-height: none; min-width: 0; min-height: 0; width: 100%} .MathJax_SVG .MJX-monospace {font-family: monospace} .MathJax_SVG .MJX-sans-serif {font-fam...
0
oct-2020-editorial-period
2013-10-29T06:13:09
{"contest_participation":7868,"challenge_submissions":564,"successful_submissions":106}
2013-10-29T06:13:09
2016-07-23T18:18:41
setter
###C++ ```cpp #include<iostream> #include<queue> #include<cstdio> #include<cmath> #include<string> #include<vector> #include<algorithm> #include<stack> #include<cstring> #include<map> using namespace std; typedef long long LL; typedef pair<int,int> PII; #define pb push_back #define mp make_pair bool isPri...
not-set
2016-04-24T02:02:13
2016-07-23T18:18:32
C++
12
1,084
period
Period
You are given 2 integers **a** and **b**. Let a number be defined as ![Image1](https://hr-filepicker.s3.amazonaws.com/period1.png). As we know ![Image1](https://hr-filepicker.s3.amazonaws.com/period1.png) will be an irrational number when b is non-zero. In this problem, we call it the AC number. We define ![Image2](h...
code
Can you find the period?
ai
2013-10-16T05:50:59
2022-09-02T09:54:45
null
null
null
You are given 2 integers **a** and **b**. Let a number be defined as ![image1](https://s3.amazonaws.com/hr-assets/0/1526567764-7f13ff1150-period1.png). As we know ![image1](https://s3.amazonaws.com/hr-assets/0/1526567764-7f13ff1150-period1.png) will be an irrational number when b is non-zero. In this problem, we call ...
0.564516
["bash","c","clojure","cpp","cpp14","cpp20","csharp","d","elixir","erlang","fsharp","go","groovy","haskell","java","java8","java15","javascript","julia","kotlin","lolcode","lua","objectivec","ocaml","pascal","perl","php","python3","r","racket","ruby","rust","sbcl","scala","smalltalk","swift","tcl","typescript","visualb...
Hard
Period : Oct 2020 Editorial
<style id="MathJax_SVG_styles">.MathJax_SVG_Display {text-align: center; margin: 1em 0em; position: relative; display: block!important; text-indent: 0; max-width: none; max-height: none; min-width: 0; min-height: 0; width: 100%} .MathJax_SVG .MJX-monospace {font-family: monospace} .MathJax_SVG .MJX-sans-serif {font-fam...
0
oct-2020-editorial-period
2013-10-29T06:13:09
{"contest_participation":7868,"challenge_submissions":564,"successful_submissions":106}
2013-10-29T06:13:09
2016-07-23T18:18:41
tester
###C++ ```cpp #include <cmath> #include <cstdio> #include <vector> #include <iostream> #include <algorithm> using namespace std; typedef long long ll; int mul(ll x,ll y,int p) { return x * y % p; } int powermod(ll x,ll y,int p) { //x ^ y mod p if (x == 0) { return 0; } if (y ...
not-set
2016-04-24T02:02:13
2016-07-23T18:18:41
C++
End of preview. Expand in Data Studio
Field Type What it contains
challenge_id integer Unique numeric identifier for the coding challenge
challenge_slug string URL-friendly slug used in challenge links
challenge_name string Human-readable challenge title
challenge_body string Full challenge description (HTML/Markdown) including input/output, examples, etc.
challenge_kind string High-level content type (e.g., code, game)
challenge_preview string One-sentence teaser shown in listings
challenge_category string Top-level category such as ai, algorithms, databases
challenge_created_at ISO 8601 string When the challenge was first created
challenge_updated_at ISO 8601 string Most-recent metadata update time
python3_template string (nullable) Complete Python 3 starter code supplied to users
python3_template_head string (nullable) Header portion of the Python 3 template
python3_template_tail string (nullable) Footer portion of the Python 3 template
problem_statement string Canonical statement (often plain-text version of challenge_body)
difficulty float Continuous difficulty score in [0, 1]
allowed_languages JSON string Array of language identifiers permitted for submissions
input_format string (nullable) “Input Format” section verbatim
output_format string (nullable) “Output Format” section verbatim
sample_input string (nullable) Example stdin for the challenge
sample_output string (nullable) Expected stdout for the sample input
difficulty_tag string Discrete label (Easy, Medium, Hard)
editorial_title string Title of the official editorial article
editorial_content string Full HTML body of the editorial
editorial_draft boolean (0/1) 1 if editorial is still a draft
editorial_slug string URL-friendly slug for the editorial
editorial_published_at ISO 8601 string Publication timestamp of the editorial
editorial_statistics JSON string Engagement stats (participation, submissions, success rate)
editorial_created_at ISO 8601 string Editorial first-save timestamp
editorial_updated_at ISO 8601 string Last editorial edit time
editorial_solution_kind string Tag for reference solution (e.g., tester, reference)
editorial_solution_code string Full reference solution source code
editorial_solution_language string Language of the reference solution
editorial_solution_created_at ISO 8601 string Creation time of the reference solution
editorial_solution_updated_at ISO 8601 string Last update time of the reference solution
language string Detected programming language for this row
Downloads last month
23