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
100
3,167
prime-not-prime
Prime Not-Prime
Jigar is trying to solve a math problem and prove to Aghaye Mojri that he is good at math, But it seems this problem is too tough to be solved on paper, So he asks you to calculte the SUM of |p-x| for all prime numbers *p* in range [1, n] and all non prime integers *x* in range [1, n]. As the answer can be very large, ...
code
Can you figure out the sum of differences of every prime with every composite number within a range?
ai
2014-06-27T07:09:16
2016-09-09T09:47:21
null
null
null
Jigar is trying to solve a math problem and prove to Aghaye Mojri that he is good at math, But it seems this problem is too tough to be solved on paper, So he asks you to calculte the SUM of |p-x| for all prime numbers *p* in range [1, n] and all non prime integers *x* in range [1, n]. As the answer can be very large, ...
0.5
["bash","c","cpp","java","csharp","php","visualbasic","java8","cpp14"]
null
null
null
null
Hard
null
null
null
null
null
null
2014-06-27T07:12:06
2016-12-03T04:02:42
setter
#include <iostream> #include <vector> #include <algorithm> #include <string.h> using namespace std; typedef long long ll; const ll MOD = 1000000009; const ll N = 600000+10; bool mark[N]; int main() { memset(mark, 0, sizeof mark); mark[0] = mark[1] = true; ...
not-set
2016-04-24T02:02:45
2016-04-24T02:02:45
C++
101
3,167
prime-not-prime
Prime Not-Prime
Jigar is trying to solve a math problem and prove to Aghaye Mojri that he is good at math, But it seems this problem is too tough to be solved on paper, So he asks you to calculte the SUM of |p-x| for all prime numbers *p* in range [1, n] and all non prime integers *x* in range [1, n]. As the answer can be very large, ...
code
Can you figure out the sum of differences of every prime with every composite number within a range?
ai
2014-06-27T07:09:16
2016-09-09T09:47:21
null
null
null
Jigar is trying to solve a math problem and prove to Aghaye Mojri that he is good at math, But it seems this problem is too tough to be solved on paper, So he asks you to calculte the SUM of |p-x| for all prime numbers *p* in range [1, n] and all non prime integers *x* in range [1, n]. As the answer can be very large, ...
0.5
["bash","c","cpp","java","csharp","php","visualbasic","java8","cpp14"]
null
null
null
null
Hard
null
null
null
null
null
null
2014-06-27T07:12:06
2016-12-03T04:02:42
tester
#include<bits/stdc++.h> using namespace std; vector<int> prime; vector<int> minFactor; vector<bool> isp; vector<int> non_prime; vector<int> dp; vector<int> sum_prime; vector<int> sum_non_prime; #define MAX 6e5 #define MOD 1000000009 void generatePrime(int n = MAX) { ...
not-set
2016-04-24T02:02:45
2016-04-24T02:02:45
C++
102
2,590
boleyn-salary
Boleyn Salary
Boleyn Su runs a company called Acme. There are _N_ employees in the company, and each one of them is represented by a unique employee id whose range lies in _[1, N]_. Being the head of company, Boleyn's employee id is _1_. <br> Each employee, except Boleyn, has exactly one direct superior. This means that the hiera...
code
K'th lowest salary.
ai
2014-06-10T10:02:53
2016-09-01T16:24:34
null
null
null
Boleyn Su runs a company called Acme. There are _N_ employees in the company, and each one of them is represented by a unique employee id whose range lies in _[1, N]_. Being the head of company, Boleyn's employee id is _1_. <br> Each employee, except Boleyn, has exactly one direct superior. This means that the hiera...
0.576923
["haskell","clojure","scala","erlang","sbcl","ocaml","fsharp","racket","elixir"]
null
null
null
null
Hard
null
null
null
null
null
null
2014-06-27T11:05:34
2016-05-13T00:01:25
tester
import Control.Monad import Data.List hiding (insert) import Data.Graph import Data.Ord (comparing) import qualified Data.Array as A import qualified Data.IntMap as M ---- naive AVL BEGIN ---- data AVL a = Null | Branch a (AVL a) (AVL a) Int Int -- height size deriving...
not-set
2016-04-24T02:02:45
2016-04-24T02:02:45
Python
103
2,500
gordons-beverage
Gordon's Beverage
Mr Gordon likes making beverages. Mr Gordon is very rich, so he has farm in space. His farm has sizes *W\*H\*D*. It is divided into sections wich are cubes of size 1*1*1. There are *N* fields of different fruit trees. Each field of trees is located in a big cube of size 4*4*4, with top-left-front corner at *(X$_f$,Y$_f...
code
Help Gordon to make a beverage.
ai
2014-05-10T02:21:09
2019-07-02T13:58:31
null
null
null
Mr Gordon likes making beverages. Mr Gordon is very rich, so he has a farm in space. His farm is divided into sections wich are cubes of size 1*1*1. There are *N* fields of different fruit trees. Each field of trees is located in a big cube of size 4*4*4, with bottom-right-back corner at *(X$_f$,Y$_f$,Z$_f$)*.<br> Mr G...
0.5
["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"]
Hard
null
null
null
null
null
null
2014-06-27T20:02:46
2016-12-22T00:39:56
setter
#include <cstdio> using namespace std; //N is an array size, choosen such way, that we can store values in indexes starting from 1. //For values [-100, 100] we'd like to store them as [1, 201]. //We are leaving 0'th index unused just not to write 'if'`s when initializing. const int N = 202; //K is an offset tha...
not-set
2016-04-24T02:02:45
2016-04-24T02:02:45
C++
104
2,501
jim-beam
Jim Beam
Jim likes to play with laser beams. Jim stays at point $(0,0)$. There is a mirror at point $(X_m, Y_m)$ and a wall between points $(X_1, Y_1)$ and $(X_2, Y_2)$. Jim wants to find out if he can point the laser beam on the mirror. **Input Format** First line contains the number of test cases, $T$. Each subseque...
code
Help Jim determine if he can play with laser beam.
ai
2014-05-10T02:21:57
2022-09-02T09:55:19
# # Complete the 'solve' function below. # # The function is expected to return a STRING. # The function accepts following parameters: # 1. INTEGER x1 # 2. INTEGER y1 # 3. INTEGER x2 # 4. INTEGER y2 # 5. INTEGER xm # 6. INTEGER ym # def solve(x1, y1, x2, y2, xm, ym): # 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() x1 = int(first_multiple_input[0]) y1 = int(first_multiple_input[1]) x2 = int(first_multiple_input[2]) ...
Jim likes to play with laser beams. Jim stays at point $(0,0)$. There is a mirror at point $(X_m, Y_m)$ and a wall between points $(X_1, Y_1)$ and $(X_2, Y_2)$. Jim wants to find out if he can point the laser beam on the mirror. **Input Format** First line contains the number of test cases, $T$. Each subseque...
0.557692
["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
null
null
null
null
null
null
2014-06-27T21:04:06
2016-12-08T14:20:50
setter
###C++ ```cpp #include <iostream> using namespace std; long long cross_product(long long ax, long long ay, long long bx, long long by, long long cx, long long cy) { return (bx - ax) * (cy - ay) - (by - ay) * (cx - ax); } bool inside(long long ax, l...
not-set
2016-04-24T02:02:45
2016-07-23T19:07:56
C++
105
2,535
dynamic-summation
Dynamic Summation
Given a tree of _N_ nodes, where each node is uniquely numbered in between _[1, N]_. Each node also has a value which is initially 0. You need to perform following two operations in the tree. 1. Update Operation 2. Report Operation **Update Operation** U r t a b Adds <code>a<sup>b</sup> + (a+1)<sup>b</sup> + ...
code
Given a tree, perform two kinds of queries. Add a given value to all nodes in a subtree and print the sum of all the values in a given subtree
ai
2014-05-17T19:05:11
2022-08-31T08:33:19
null
null
null
Given a tree of _N_ nodes, where each node is uniquely numbered in between _[1, N]_. Each node also has a value which is initially 0. You need to perform following two operations in the tree. 1. Update Operation 2. Report Operation **Update Operation** U r t a b Adds <code>a<sup>b</sup> + (a+1)<sup>b</sup> + ...
0.478723
["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"...
null
null
null
null
Hard
null
null
null
null
null
null
2014-06-28T17:37:26
2016-12-02T06:26:04
setter
#include<stdio.h> #include<assert.h> #include<string.h> #include<vector> #include<algorithm> using namespace std; #define MaxVal 100004 #define FOR(i,n) for(int i=0;i<(n);i++) typedef long long int ll; ll invcons[5][5]; int mod[10],num[200]; ll UPPER = (ll)1000000000*(ll)...
not-set
2016-04-24T02:02:45
2016-04-24T02:02:45
C++
106
2,535
dynamic-summation
Dynamic Summation
Given a tree of _N_ nodes, where each node is uniquely numbered in between _[1, N]_. Each node also has a value which is initially 0. You need to perform following two operations in the tree. 1. Update Operation 2. Report Operation **Update Operation** U r t a b Adds <code>a<sup>b</sup> + (a+1)<sup>b</sup> + ...
code
Given a tree, perform two kinds of queries. Add a given value to all nodes in a subtree and print the sum of all the values in a given subtree
ai
2014-05-17T19:05:11
2022-08-31T08:33:19
null
null
null
Given a tree of _N_ nodes, where each node is uniquely numbered in between _[1, N]_. Each node also has a value which is initially 0. You need to perform following two operations in the tree. 1. Update Operation 2. Report Operation **Update Operation** U r t a b Adds <code>a<sup>b</sup> + (a+1)<sup>b</sup> + ...
0.478723
["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"...
null
null
null
null
Hard
null
null
null
null
null
null
2014-06-28T17:37:26
2016-12-02T06:26:04
tester
#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> ...
not-set
2016-04-24T02:02:46
2016-04-24T02:02:46
C++
107
2,141
minimum-average-waiting-time
Minimum Average Waiting Time
Tieu owns a pizza restaurant and he manages it in his own way. While in a normal restaurant, a customer is served by following the first-come, first-served rule, Tieu simply minimizes the average waiting time of his customers. So he gets to decide who is served first, regardless of how sooner or later a person comes. ...
code
Calculate the minimum average wait time of a person to receive his/her pizza?
ai
2014-03-15T14:31:33
2022-09-02T10:00:23
# # Complete the 'minimumAverage' function below. # # The function is expected to return an INTEGER. # The function accepts 2D_INTEGER_ARRAY customers as parameter. # def minimumAverage(customers): # 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()) customers = [] for _ in range(n): customers.append(list(map(int, input().rstrip().split()))) result = minimumAverage(customers) fptr.write(str(result) + '\n') fptr.close()
Tieu owns a pizza restaurant and he manages it in his own way. While in a normal restaurant, a customer is served by following the first-come, first-served rule, Tieu simply minimizes the average waiting time of his customers. So he gets to decide who is served first, regardless of how sooner or later a person comes. ...
0.418269
["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"]
Hard
null
null
null
null
null
null
2014-06-30T16:02:37
2016-12-02T02:59:41
setter
/* Solution: pick the order that takes shortest time to cook. */ #include <cstdio> #include <iostream> #include <fstream> #include <algorithm> #include <vector> #include <queue> #include <stack> #include <set> #include <map> #include <cstring> #include <cstdlib> ...
not-set
2016-04-24T02:02:46
2016-04-24T02:02:46
C++
108
2,141
minimum-average-waiting-time
Minimum Average Waiting Time
Tieu owns a pizza restaurant and he manages it in his own way. While in a normal restaurant, a customer is served by following the first-come, first-served rule, Tieu simply minimizes the average waiting time of his customers. So he gets to decide who is served first, regardless of how sooner or later a person comes. ...
code
Calculate the minimum average wait time of a person to receive his/her pizza?
ai
2014-03-15T14:31:33
2022-09-02T10:00:23
# # Complete the 'minimumAverage' function below. # # The function is expected to return an INTEGER. # The function accepts 2D_INTEGER_ARRAY customers as parameter. # def minimumAverage(customers): # 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()) customers = [] for _ in range(n): customers.append(list(map(int, input().rstrip().split()))) result = minimumAverage(customers) fptr.write(str(result) + '\n') fptr.close()
Tieu owns a pizza restaurant and he manages it in his own way. While in a normal restaurant, a customer is served by following the first-come, first-served rule, Tieu simply minimizes the average waiting time of his customers. So he gets to decide who is served first, regardless of how sooner or later a person comes. ...
0.418269
["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"]
Hard
null
null
null
null
null
null
2014-06-30T16:02:37
2016-12-02T02:59:41
tester
#include<bits/stdc++.h> #define assn(n,a,b) assert(n>=a && n<=b) #define F first #define S second #define mp make_pair using namespace std; int main() { int n,i; vector < pair < int, int > > ar; long long cur=0,ans=0; cin >> n; ar.resize(n); ...
not-set
2016-04-24T02:02:46
2016-04-24T02:02:46
C++
109
3,090
all-for-9-9-for-all
All for Nine and Nine for All
Everyone's favorite noontime show, _Lunchtime Surprise_, launched a new game recently. They called it: _All for Nine and Nine for All_. There would be $N$ boxes, each containing a single digit from `0` to `9`, lined up and the team of nine contestants would have to decide which boxes to open. After opening the boxes, w...
code
How many ways can you win in this new Lunchtime Surprise game?
ai
2014-06-19T02:14:04
2018-07-05T02:44:52
null
null
null
<img src="https://s3.amazonaws.com/hr-challenge-images/3090/1472582116-bf126e51f6-lunctimesurprise.jpg" title="lunctimesurprise.jpg" /> Everyone's favorite noontime show, _Lunchtime Surprise_, launched a new game recently. They called it: _All for Nine and Nine for All_. There would be $N$ boxes, each containing a sin...
0.5
["c","cpp","java","python3","python","cpp14"]
Hard
null
null
null
null
null
null
2014-06-30T17:14:35
2016-12-13T12:55:58
setter
#include <stdio.h> #include <stdlib.h> #define ll long long #define mod 1000000000 #define alok(n,t) ((t*)malloc((n)*sizeof(t))) char S[1111111]; int *F = alok(9, int); int *G = alok(9, int); int *H = alok(9, int); int *nF = alok(9, int); int *nG = alok(9, int); int *nH ...
not-set
2016-04-24T02:02:46
2016-04-24T02:02:46
C++
110
3,090
all-for-9-9-for-all
All for Nine and Nine for All
Everyone's favorite noontime show, _Lunchtime Surprise_, launched a new game recently. They called it: _All for Nine and Nine for All_. There would be $N$ boxes, each containing a single digit from `0` to `9`, lined up and the team of nine contestants would have to decide which boxes to open. After opening the boxes, w...
code
How many ways can you win in this new Lunchtime Surprise game?
ai
2014-06-19T02:14:04
2018-07-05T02:44:52
null
null
null
<img src="https://s3.amazonaws.com/hr-challenge-images/3090/1472582116-bf126e51f6-lunctimesurprise.jpg" title="lunctimesurprise.jpg" /> Everyone's favorite noontime show, _Lunchtime Surprise_, launched a new game recently. They called it: _All for Nine and Nine for All_. There would be $N$ boxes, each containing a sin...
0.5
["c","cpp","java","python3","python","cpp14"]
Hard
null
null
null
null
null
null
2014-06-30T17:14:35
2016-12-13T12:55:58
tester
#include <cstdio> #include <cstring> #include <string> #include <cassert> #include <cctype> using namespace std; const int M = 1000000000; char s[1000006]; int dp[2][9]; void ad(int &x,int y) { if ((x += y) >= M) { x -= M; } } int f(int x) ...
not-set
2016-04-24T02:02:46
2016-04-24T02:02:46
C++
111
2,534
sherlock-and-probability
Sherlock and Probability
[Download Pdf version](http://hr-filepicker.s3.amazonaws.com/infinitum-jul14/2534-sherlock-and-probability.pdf) Watson gave a string $S$ to Sherlock. It is $N$ characters long and consists of only `1`s and `0`s. Now he asks: Given an integer $K$, I'll pick two indices $i$ and $j$ at random between $1$ and $N$, bot...
code
Help Sherlock in finding the probability.
ai
2014-05-17T18:44:48
2022-09-02T09:55:25
# # Complete the 'solve' function below. # # The function is expected to return a STRING. # The function accepts following parameters: # 1. INTEGER n # 2. INTEGER k # 3. STRING s # def solve(n, k, 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') 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]) s = input() result = solve(n,...
Watson gave a string $S$ to Sherlock. It is $N$ characters long and consists of only `1`s and `0`s. Now he asks: Given an integer $K$, I'll pick two indices $i$ and $j$ at random between $1$ and $N$, both inclusive. What's the probability that both $S[i]$ and $S[j]$ are `1` and $|i - j| \le K$? **Input Format** F...
0.572165
["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"]
Hard
null
null
null
null
null
null
2014-07-01T08:20:40
2016-12-06T00:10:42
setter
###C++ ```cpp #include<bits/stdc++.h> using namespace std; #define pb push_back #define mp make_pair #define clr(x) x.clear() #define sz(x) ((int)(x).size()) #define F first #define S second #define REP(i,a,b) for(i=a;i<b;i++) #define rep(i,b) for(i=0;i<b;i++) #define rep1(i,b) for(i=1;i<=b;i++) #define pdn(n) prin...
not-set
2016-04-24T02:02:46
2016-07-23T19:13:21
C++
112
2,461
rirb
Random Integers Random Bits
[Download PDF Version](http://hr-filepicker.s3.amazonaws.com/infinitum-jul14/2461-rirb.pdf) Given an integer range [A,B], 1. What’s the probability to get a 1-bit if we first randomly choose a number x in the range and then randomly choose a bit from x? 2. What’s the expected number of bit 1s if we randomly cho...
code
Find the probability and expectation value of the given problem
ai
2014-04-29T09:43:01
2022-09-02T09:55:40
null
null
null
Given an integer range [A,B], 1. What’s the probability to get a 1-bit if we first randomly choose a number x in the range and then randomly choose a bit from x? 2. What’s the expected number of bit 1s if we randomly choose a number x in the range? **Input Format** The first line of input is the number of tes...
0.465753
["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
null
null
null
null
null
null
2014-07-01T08:47:19
2016-12-29T20:45:07
tester
###Python 2 ```python LIM = 1111 S = [0.0]*LIM # precompute S[n] = sum(0<=k<n) 2^(k-1)/(k+1) p2 = 0.5 for i in xrange(1,LIM): S[i] = S[i-1] + p2/i p2 *= 2 def bit_length(n): ''' Length of the binary representation of n ''' return len(bin(n)[2:]) def bit_count(n): ''' Number of 1 bits of n '''...
not-set
2016-04-24T02:02:46
2016-07-23T19:17:03
Python
113
2,619
maximum-subarray-sum
Maximum Subarray Sum
You are given an array of size _N_ and another integer _M_.Your target is to maximise the value of sum of subarray modulo M. **Input Format** First line contains T , number of test cases to follow. Each test case consits of exactly 2 lines. First line of each test case contain N M , size of the array and modulo val...
code
Find the maximal value of any (subarray sum % m) in an array.
ai
2014-06-15T09:19:08
2022-08-31T08:14:21
# # Complete the 'maximumSum' function below. # # The function is expected to return a LONG_INTEGER. # The function accepts following parameters: # 1. LONG_INTEGER_ARRAY a # 2. LONG_INTEGER m # def maximumSum(a, m): # 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') q = int(input().strip()) for q_itr in range(q): first_multiple_input = input().rstrip().split() n = int(first_multiple_input[0]) m = int(first_multiple_input[1]) a = list(map(int, input().rstrip().spl...
We define the following: - A *subarray* of array $a$ of length $n$ is a contiguous segment from $a[i]$ through $a[j]$ where $0 \le i \le j \lt n$. - The *sum* of an array is the sum of its elements. Given an $n$ element array of integers, $a$, and an integer, $m$, determine the maximum value of the sum of any of its ...
0.5
["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 contains an integer $q$, the number of queries to perform. The next $q$ pairs of lines are as follows: - The first line contains two space-separated integers $n$ and (long)$m$, the length of $a$ and the modulo divisor. - The second line contains $n$ space-separated long integers $a[i]$.
<pre> STDIN Function ----- -------- 1 q = 1 5 7 a[] size n = 5, m = 7 3 3 9 9 5 </pre>
6
Hard
null
null
null
null
null
null
2014-07-01T08:52:28
2018-06-06T20:37:56
setter
###C++ ```cpp #include<bits/stdc++.h> using namespace std; typedef long long int ll; void solve() { ll N,M; ll x,prefix=0,maxim=0; cin>>N>>M; set<ll> S; S.insert(0); for(int i=1;i<=N;i++){ cin>>x; prefix = (prefix + x)%M; maxim = max(maxim,prefix); set<ll>::...
not-set
2016-04-24T02:02:47
2016-07-23T13:35:09
C++
114
2,596
order-of-prime-in-factorial
Order of Prime in Factorial
[Download Pdf version](https://hr-filepicker.s3.amazonaws.com/infinitum-jul14/2596-order-of-prime-in-factorial.pdf) For a given prime $p$, define $\operatorname{ord}_p(k)$ as the multiplicity of $p$ in $k$, i.e. the number of times $p$ appears in the prime factorization of $k$. For a given $p$ (prime) and $L$, let ...
code
How many factorials have order divisible by that prime?
ai
2014-06-11T18:24:21
2022-09-02T09:54:46
# # Complete the 'solve' function below. # # The function is expected to return a LONG_INTEGER. # The function accepts following parameters: # 1. LONG_INTEGER p # 2. LONG_INTEGER l # def solve(p, l): # 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() p = int(first_multiple_input[0]) l = int(first_multiple_input[1]) result = solve(p, l) fptr.wri...
For a given prime $p$, define $\operatorname{ord}_p(k)$ as the multiplicity of $p$ in $k$, i.e. the number of times $p$ appears in the prime factorization of $k$. For a given $p$ (prime) and $L$, let $F(p,L)$ be the number of integers $n$ such that $1 \le n \le L$ and $\operatorname{ord}_p(n!)$ is divisible by $p$. He...
0.575
["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"]
Hard
null
null
null
null
null
null
2014-07-01T09:00:54
2016-12-08T11:22:20
setter
###Python 2 ```python def S(p,n): return 0 if n == 0 else (n%p) + S(p,n/p) def G(p,L): Q,R = divmod(L,p) return Q + ((-S(p,Q)) % p < R) def F_(p,L): Q,R = divmod(L,p) return p*G(p,Q) + R*(S(p,Q) % p == 0) def F(p,L): return F_(p,L+1) - 1 for cas in xrange(input()): p,L = map(int, raw...
not-set
2016-04-24T02:02:47
2016-07-23T18:19:32
Python
115
3,193
kahoo-company
Kahoo Company
Baba'ee dream finally came true and he bought the Kahoo Company. The structure of the company is like a rooted Tree. There is the general manager as the root, and any worker except general manager has a direct boss. General Manager is represented by 1, all other employees are demonstrated with integers in range [2, n]...
code
Help Baba'ee save Kahoo company from Bankruptcy.
ai
2014-07-02T08:53:33
2016-09-09T09:47:30
null
null
null
Baba'ee dream finally came true and he bought the Kahoo Company. The structure of the company is like a rooted Tree. There is the general manager as the root, and any worker except general manager has a direct boss. General Manager is represented by 1, all other employees are demonstrated with integers in range [2, n]...
0.5
["bash","c","cpp","java","csharp","php","visualbasic","java8","python","cpp14"]
null
null
null
null
Hard
null
null
null
null
null
null
2014-07-02T09:06:45
2017-01-02T06:15:11
setter
#include <iostream> #include <queue> #include <vector> #include <algorithm> #include <string.h> using namespace std; typedef long long ll; const ll N = 100000+10; ll extra[N]; ll depth[N]; vector <int> adj[N]; queue <int> q; void bfs() { depth[0] = 1; ...
not-set
2016-04-24T02:02:47
2016-04-24T02:02:47
C++
116
3,193
kahoo-company
Kahoo Company
Baba'ee dream finally came true and he bought the Kahoo Company. The structure of the company is like a rooted Tree. There is the general manager as the root, and any worker except general manager has a direct boss. General Manager is represented by 1, all other employees are demonstrated with integers in range [2, n]...
code
Help Baba'ee save Kahoo company from Bankruptcy.
ai
2014-07-02T08:53:33
2016-09-09T09:47:30
null
null
null
Baba'ee dream finally came true and he bought the Kahoo Company. The structure of the company is like a rooted Tree. There is the general manager as the root, and any worker except general manager has a direct boss. General Manager is represented by 1, all other employees are demonstrated with integers in range [2, n]...
0.5
["bash","c","cpp","java","csharp","php","visualbasic","java8","python","cpp14"]
null
null
null
null
Hard
null
null
null
null
null
null
2014-07-02T09:06:45
2017-01-02T06:15:11
tester
#include<bits/stdc++.h> using namespace std; int main() { int t, n, temp; cin >> t; map<int, int> parent; map<int, int> height; map<int, int> height_count; vector<int> extra; assert(1 <= t and t <= 20); while(t--) { ci...
not-set
2016-04-24T02:02:47
2016-04-24T02:02:47
C++
117
3,200
cutting-paper
Cutting paper
**Please note that this is a team event, and your submission will be accepted only as a part of a team, even single member teams are allowed. Please click [here](https://www.hackerrank.com/auth/create_team/csindia) to register as a team, if you have NOT already registered.** Yami is taking a Physics class in her schoo...
code
Can you find the minimun value?
ai
2014-07-03T01:36:17
2016-09-09T09:47:33
null
null
null
**Please note that this is a team event, and your submission will be accepted only as a part of a team, even single member teams are allowed. Please click [here](https://www.hackerrank.com/auth/create_team/csindia) to register as a team, if you have NOT already registered.** Yami is taking a Physics class in her schoo...
0.5
["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
null
null
null
null
null
null
2014-07-03T01:38:40
2017-04-12T09:10:12
setter
#include< stdio.h > #include< iostream > #include< sstream > #include< string.h> #include< algorithm> #include< stdlib.h> #define maxn 105 using namespace std; int dp[maxn][maxn],n,m; void precalc() { memset(dp,1,sz(dp)); for(int i = 0; i <=100;i++) ...
not-set
2016-04-24T02:02:47
2016-04-24T02:02:47
C++
118
3,200
cutting-paper
Cutting paper
**Please note that this is a team event, and your submission will be accepted only as a part of a team, even single member teams are allowed. Please click [here](https://www.hackerrank.com/auth/create_team/csindia) to register as a team, if you have NOT already registered.** Yami is taking a Physics class in her schoo...
code
Can you find the minimun value?
ai
2014-07-03T01:36:17
2016-09-09T09:47:33
null
null
null
**Please note that this is a team event, and your submission will be accepted only as a part of a team, even single member teams are allowed. Please click [here](https://www.hackerrank.com/auth/create_team/csindia) to register as a team, if you have NOT already registered.** Yami is taking a Physics class in her schoo...
0.5
["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
null
null
null
null
null
null
2014-07-03T01:38:40
2017-04-12T09:10:12
tester
#include<bits/stdc++.h> using namespace std; int mat[101][101]; void solve() { mat[0][0] = 0; mat[0][1] = 0; mat[1][0] = 0; for(int i = 1; i <= 100; i++) { mat[i][1] = i; mat[1][i] = i; } for(int i = 2; i <= 100; i++...
not-set
2016-04-24T02:02:48
2016-04-24T02:02:48
C++
119
3,215
crazy-country
Crazy country
<p> In some place, there is a country which is formed by N cities connected by N-1 roads. There is just one way in going from one city to the other, it is by using the shortest path. The president is crazy, he continuously changed the country's capital. So the people are getting into trouble. Now the people want your ...
code
Can you solve this queries?
ai
2014-07-04T20:45:41
2016-09-09T09:47:40
null
null
null
<p> In some place, there is a country which is formed by N cities connected by N-1 roads. There is just one way in going from one city to the other, it is by using the shortest path. The president is crazy, he continuously changed the country's capital. So the people are getting into trouble. Now the people want your ...
0.5
["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
null
null
null
null
null
null
2014-07-04T20:46:40
2016-05-13T00:00:36
setter
<pre> #include <cstdio> #include <iostream> #include <cstring> #include <string> #include <cmath> #include <cstdlib> #include <algorithm> #include <vector> #include <queue> #include <cctype> #include <climits> #include <complex> #include <set> #include <stack> #include <map> using namespace std; struct node { int v...
not-set
2016-04-24T02:02:48
2016-04-24T02:02:48
C++
120
3,232
sherlock-and-subarray
Sherlock and Subarray
Watson gives an array $A_{1},A_{2}...A_{N}$ to Sherlock. He asks him to count the number of valid contiguous subarrays. A subarray $A_{i},A_{i+1}...A_{j}$ such that $1 \leq i \leq j \leq N$ is valid if the the largest element of that subarray occurs only once in that subarray. **Input** First line contai...
code
Help Sherlock in counting Special type of subarrays.
ai
2014-07-06T14:03:49
2019-07-02T13:58:42
null
null
null
Watson gives an array $A_{1},A_{2}...A_{N}$ to Sherlock. He asks him to count the number of contiguous subarrays $A_{i},A_{i+1}...A_{j}$ such that $1 \leq i \leq j \leq N$ and the largest element of that subarray occurs only once in that subarray. **Input Format** First line contains $T$, the number of testcases...
0.5
["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"]
Hard
null
null
null
null
null
null
2014-07-06T14:03:58
2016-05-13T00:00:34
setter
#include<bits/stdc++.h> using namespace std; #define pb push_back #define mp make_pair #define clr(x) x.clear() #define sz(x) ((int)(x).size()) #define F first #define S second #define REP(i,a,b) for(i=a;i<b;i++) #define rep(i,b) for(i=0;i<b;i++) #define rep1(i,b) for(i=1;i<=...
not-set
2016-04-24T02:02:48
2016-04-24T02:02:48
C++
121
3,242
savita-and-friends
Savita And Friends
After completing her final semester, Savita is back home. She is excited to meet all her friends. Her $N$ friends live in different houses spread across the city. There are $M$ roads connecting the houses. The road network formed is connected and does not contain self loops and multiple roads between same pair of ...
code
Savita and Friends are meeting after a long time. Help Savita to organize the meeting.
ai
2014-07-08T10:47:13
2022-08-31T08:14:30
# # Complete the 'solve' function below. # # The function is expected to return a DOUBLE_ARRAY. # The function accepts following parameters: # 1. INTEGER n # 2. INTEGER k # 3. 2D_INTEGER_ARRAY roads # def solve(n, k, roads): # 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]) m = int(first_multiple_input[1]) k = int(first_multiple_input[2]) ...
After completing her final semester, Savita is back home. She is excited to meet all her friends. Her $N$ friends live in different houses spread across the city. There are $M$ roads connecting the houses. The road network formed is connected and does not contain self loops and multiple roads between same pair of ...
0.5
["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"]
First line contain $T$, the number of testcases. T testcases follow. First Line of each testcase contains 3 space separated integers $N, M, K$ . Next $M$ lines contain description of the $i$<sup>th</sup> road : three space separated integers $A, B, C$, where $C$ is the length of road connecting $A$ and $B$. ...
For each testcase, print two space separated values in one line. The first value is the distance of $P$ from the point $A$ and the second value is the maximum of all the possible shortest paths between $P$ and all of Savita's and her friends' houses. Round both answers to $5$ decimal digits and print exactly $5$ digits...
2 2 1 1 1 2 10 4 4 1 1 2 10 2 3 10 3 4 1 4 1 5
5.00000 5.00000 2.00000 8.00000
Hard
null
null
null
null
null
null
2014-07-08T10:47:24
2016-12-02T16:44:29
tester
###C++ ```cpp #include<bits/stdc++.h> using namespace std; #define pb push_back #define mp make_pair #define F first #define S second typedef long long LL; typedef pair< LL , LL> PII; typedef vector<PII> VPII; typedef vector<LL> VI; const LL INF = 1000000000000000000ll; vector<PII> edges[100009]; VI dijk(int N, int...
not-set
2016-04-24T02:02:49
2016-07-23T14:07:21
C++
122
2,517
matrix-rotation
Matrix Rotation
You are given a 2D matrix, _a_, of dimension *MxN* and a positive integer _R_. You have to rotate the matrix _R_ times and print the resultant matrix. Rotation should be in anti-clockwise direction. Rotation of a _4x5_ matrix is represented by the following figure. Note that in one rotation, you have to shift eleme...
code
Rotate the elements of the matrix.
ai
2014-05-13T15:51:08
2016-09-01T16:26:21
null
null
null
<sup><strong>[Here](https://www.hackerrank.com/challenges/matrix-rotation-algo) is the non-FP version of this challenge, with all languages enabled.</strong></sup> --- You are given a 2D matrix, _a_, of dimension *MxN* and a positive integer _R_. You have to rotate the matrix _R_ times and print the resultant matrix....
0.5
["haskell","clojure","scala","erlang","sbcl","ocaml","fsharp","racket","elixir"]
Hard
null
null
null
null
null
null
2014-07-08T12:57:25
2016-12-13T21:51:24
setter
import scala.collection.mutable.HashMap; object Solution{ def main(args:Array[String]) = { val in = readLine.split(" ").map(_.toInt); var arr = new Array[Array[Int]](in(0)); for(i <- 1 to in(0)) arr(i-1) = readLine.split(" ").map(_.toInt); ...
not-set
2016-04-24T02:02:49
2016-04-24T02:02:49
Python
123
2,517
matrix-rotation
Matrix Rotation
You are given a 2D matrix, _a_, of dimension *MxN* and a positive integer _R_. You have to rotate the matrix _R_ times and print the resultant matrix. Rotation should be in anti-clockwise direction. Rotation of a _4x5_ matrix is represented by the following figure. Note that in one rotation, you have to shift eleme...
code
Rotate the elements of the matrix.
ai
2014-05-13T15:51:08
2016-09-01T16:26:21
null
null
null
<sup><strong>[Here](https://www.hackerrank.com/challenges/matrix-rotation-algo) is the non-FP version of this challenge, with all languages enabled.</strong></sup> --- You are given a 2D matrix, _a_, of dimension *MxN* and a positive integer _R_. You have to rotate the matrix _R_ times and print the resultant matrix....
0.5
["haskell","clojure","scala","erlang","sbcl","ocaml","fsharp","racket","elixir"]
Hard
null
null
null
null
null
null
2014-07-08T12:57:25
2016-12-13T21:51:24
tester
--- {{{ import Data.List import Data.Char import qualified Data.ByteString.Char8 as BS -- BS.getContents import qualified Data.Vector as V import qualified Data.Map as Map import qualified Data.HashMap.Strict as HM import Control.Applicative import Text.Printf ...
not-set
2016-04-24T02:02:49
2016-04-24T02:02:49
Python
124
3,244
nimrod-and-the-bricks
Nimrod and the bricks
Nimrod likes to play bricks. He has an interesting bricks construction in the back yard. The bricks are arranged into a row of N stacks in such a way that the first one is a stack of 1 brick, the second one is a stack of 2 bricks, the third one is a stack of 3 bricks, and so on. Nimrod has unlimited amount of bricks ...
code
Can you solve this queries?
ai
2014-07-09T02:01:17
2016-09-09T09:47:48
null
null
null
Nimrod likes to play bricks. He has an interesting bricks construction in the back yard. The bricks are arranged into a row of N stacks in such a way that the first one is a stack of 1 brick, the second one is a stack of 2 bricks, the third one is a stack of 3 bricks, and so on. Nimrod has unlimited amount of bricks ...
0.5
["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
null
null
null
null
null
null
2014-07-09T02:01:31
2016-05-13T00:00:13
setter
<pre> #include <iostream> #include <cstring> #include <vector> #include <cstdio> #include <queue> #include <cstring> #include <cmath> #include <set> #include <cassert> #include <algorithm> using namespace std; typedef long long ll; int t; int n, x, y, q,m, op, r, k, p, c, d; long long val[500000]; int prop[500000]; ...
not-set
2016-04-24T02:02:49
2016-04-24T02:02:49
C++
125
3,259
radioactive-cubes
Radioactive cubes
You have been hired by a company to develop a software to solve the following problem. There are N radioactive objects with cubic shape. They are in three dimensions with a particular length, width, and height. Also, there are M holes in the ground with rectangular shape. The company needs to bury the radioactive cube...
code
Can you find out the maximum?
ai
2014-07-11T18:59:23
2016-09-09T09:47:53
null
null
null
You have been hired by a company to develop a software to solve the following problem. There are N radioactive objects with cubic shape. They are in three dimensions with a particular length, width, and height. Also, there are M holes in the ground with rectangular shape. The company needs to bury the radioactive cube...
0.5
["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
null
null
null
null
null
null
2014-07-11T18:59:43
2016-05-13T00:00:06
setter
<pre> #include<iostream> #include< cstdio > #include < cmath > #include < queue > #include < cstring > #include < algorithm > #include < stack > #include < map > #include < cassert > #include < set > #include < deque > #include < complex > using namespace std; typedef long long ll; typedef unsigned long lo...
not-set
2016-04-24T02:02:50
2016-04-24T02:02:50
C++
126
3,262
two-pictures
Two pictures
You have been assigned to an important job. The software company you are working with requires you to develop a module for his new social network. This task is simple as they will provide you a big and a smaller picture as a pattern. They are looking for the part within the big one which is more likely to be the patter...
code
Just match the pictures!!
ai
2014-07-12T02:40:46
2016-09-09T09:47:54
null
null
null
You have been assigned to an important job. The software company you are working with requires you to develop a module for his new social network. This task is simple as they will provide you a big and a smaller picture as a pattern. They are looking for the part within the big one which is more likely to be the patter...
0.5
["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
null
null
null
null
null
null
2014-07-12T02:40:55
2016-05-13T00:00:04
setter
<pre> #include <iostream> #include <cstring> #include <vector> #include <cstdio> #include <queue> #include <cmath> #include <set> #include <map> #include <stack> #include <cassert> #include <algorithm> using namespace std; typedef unsigned long long ll; #define XX double struct P { XX x, y; P() { } P(XX x, XX y...
not-set
2016-04-24T02:02:50
2016-04-24T02:02:50
C++
127
3,269
gneck
Girlfriend & Necklace
Mr. X wants to buy a necklace for his girlfriend. The available necklaces are bi-colored (red and blue beads). Mr. X desperately wants to impress his girlfriend and knows that she will like the necklace only if **every prime length continuous sub-sequence of beads in the necklace** has more or equal number of red bead...
code
Help Mr. X impress his girlfriend !
ai
2014-07-14T09:08:38
2022-09-02T09:55:11
null
null
null
Mr. X wants to buy a necklace for his girlfriend. The available necklaces are bi-colored (red and blue beads). Mr. X desperately wants to impress his girlfriend and knows that she will like the necklace only if **every prime length continuous sub-sequence of beads in the necklace** has more or equal number of red bead...
0.591837
["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
null
null
null
null
null
null
2014-07-14T09:08:57
2016-12-05T16:43:28
setter
###C++ ```cpp #include<iostream> #include<cmath> #include<algorithm> #include<vector> #include<cstdio> using namespace std; #define MOD 1000000007 #define LL long long int i,j; void multiplyMM(LL F[3][3], LL M[3][3]) { LL l[3][3]; l[0][0]=((F[0][0]*M[0][0])%MOD+(F[0][1]*M[1][0])%MOD+(F[0][2]*M[2] [...
not-set
2016-04-24T02:02:50
2016-07-23T18:59:09
C++
128
3,269
gneck
Girlfriend & Necklace
Mr. X wants to buy a necklace for his girlfriend. The available necklaces are bi-colored (red and blue beads). Mr. X desperately wants to impress his girlfriend and knows that she will like the necklace only if **every prime length continuous sub-sequence of beads in the necklace** has more or equal number of red bead...
code
Help Mr. X impress his girlfriend !
ai
2014-07-14T09:08:38
2022-09-02T09:55:11
null
null
null
Mr. X wants to buy a necklace for his girlfriend. The available necklaces are bi-colored (red and blue beads). Mr. X desperately wants to impress his girlfriend and knows that she will like the necklace only if **every prime length continuous sub-sequence of beads in the necklace** has more or equal number of red bead...
0.591837
["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
null
null
null
null
null
null
2014-07-14T09:08:57
2016-12-05T16:43:28
tester
###C++ ```cpp #include<bits/stdc++.h> using namespace std; #define MOD 1000000007 class Matrix { public: int **mat; int row; int col; Matrix() { } Matrix(int row = 2, int col = 2) { this->row = row; this->col = col; ...
not-set
2016-04-24T02:02:51
2016-07-23T18:59:18
C++
129
3,081
littlepandapower
Little Panda Power
**Little Panda** has a thing for powers and modulus and he likes challenges. His friend **Lucy**, however, is impractical and challenges **Panda** to find both positive and negative powers of a number modulo a particular number. We all know that $A^{-1}\bmod X$ refers to the modular inverse of $A$ modulo $X$ (see [Wiki...
code
Compute A^B mod X
ai
2014-06-18T19:51:02
2022-09-02T09:54:23
# # Complete the 'solve' function below. # # The function is expected to return an INTEGER. # The function accepts following parameters: # 1. INTEGER a # 2. INTEGER b # 3. INTEGER x # def solve(a, b, x): # 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() a = int(first_multiple_input[0]) b = int(first_multiple_input[1]) x = int(first_multiple_input[2]) ...
**Little Panda** has a thing for powers and modulus and he likes challenges. His friend **Lucy**, however, is impractical and challenges **Panda** to find both positive and negative powers of a number modulo a particular number. We all know that $A^{-1}\bmod X$ refers to the modular inverse of $A$ modulo $X$ (see [Wiki...
0.594595
["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
null
null
null
null
null
null
2014-07-18T17:51:42
2016-12-05T11:56:17
setter
###C++ ```cpp /******************* Akash Agrawall IIIT HYDERABAD akash.agrawall094@gmail.com ***********************/ #include<cstdio> #include<iostream> #include<cmath> #include<algorithm> #include<vector> #include<stdio.h> #include<math.h> using namespace std; #define ll long long int #define FO...
not-set
2016-04-24T02:02:51
2016-07-23T17:33:50
C++
130
3,327
director-and-room-alottments
Director and room Alottments
As we all know rooms have been alloted randomly this time. Earlier students with same IQ level used to live together. But now students with different IQ levels live in a distributed way. Some have positive IQ and some have negative IQ. Assume that __single student lives in a single room.__ Now director wants to make...
code
Help the college to create a coding team :)
ai
2014-07-19T13:47:52
2016-09-09T09:48:17
null
null
null
As we all know rooms have been alloted randomly this time. Earlier students with same IQ level used to live together. But now students with different IQ levels live in a distributed way. Some have positive IQ and some have negative IQ. Assume that __single student lives in a single room.__ Now director wants to make...
0.5
["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
null
null
null
null
null
null
2014-07-19T13:59:27
2016-05-12T23:59:43
setter
#include <iostream> #include<stdio.h> #include<stdlib.h> #include<set> using namespace std; int main() { int i,n; long long int maxi=-1e18,k; int a[100009]; long long int cum=0; int t; cin>>t; while(t--) { cin>>n>>k; cum=0; maxi=-1e18; for(i=0;i<n;i++) cin>>a[i]; set<long long int> myset; my...
not-set
2016-04-24T02:02:52
2016-04-24T02:02:52
C++
131
3,334
little-chammys-huge-donation
Little Ashish's Huge Donation
Little Ashish is doing internship at multiple places. Instead of giving parties to his friends he decided to donate candies to children. He likes solving puzzles and playing games. Hence he plays a small game. Suppose there are $N$ children. The rules of the game are: 1. The $i^{th}$ child gets $i^{2}$ candies ($1 \...
code
Help Ashish calculate donations.
ai
2014-07-20T20:41:41
2022-09-02T09:54:30
# # Complete the 'solve' function below. # # The function is expected to return an INTEGER. # The function accepts LONG_INTEGER x as parameter. # def solve(x): # 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): x = int(input().strip()) result = solve(x) fptr.write(str(result) + '\n') fptr.close()
Little Ashish is doing internship at multiple places. Instead of giving parties to his friends he decided to donate candies to children. He likes solving puzzles and playing games. Hence he plays a small game. Suppose there are $N$ children. The rules of the game are: 1. The $i^{th}$ child gets $i^{2}$ candies ($1 \...
0.59622
["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
null
null
null
null
null
null
2014-07-20T20:41:56
2016-12-06T14:35:59
setter
###C++ ```cpp /******************* Akash Agrawall IIIT HYDERABAD akash.agrawall094@gmail.com ***********************/ #include<cstdio> #include<iostream> #include<cstdlib> #include<cmath> #include<stdio.h> #include<math.h> using namespace std; #define ll long long int #define FOR(i,a,b) for(i= (in...
not-set
2016-04-24T02:02:52
2016-07-23T17:34:05
C++
132
3,340
value-of-all-permutations
Value of all Permutations
You are given an array $A$ of size $N$. You are asked to answer $Q$ queries. Each query contains a number $M$. For each *distinct* permutation of the array $A$, you need to print the sum of the values returned by the `find` function. As the sum can be too large, output it modulo $P$, which is a prime and given i...
code
For each distinct permutation of the array A, you need to print the sum of the values returned by the described function.
ai
2014-07-21T17:27:10
2022-09-02T09:54:59
null
null
null
You are given an array $A$ of size $N$. You are asked to answer $Q$ queries. Each query contains a number $M$. For each *distinct* permutation of the array $A$, you need to print the sum of the values returned by the `find` function. As the sum can be too large, output it modulo $P$, which is a prime and given i...
0.444444
["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
null
null
null
null
null
null
2014-07-21T17:56:07
2016-12-03T12:49:09
setter
###C++ ```cpp #include<stdio.h> #include<iostream> #include<vector> #include<string> #include<stdlib.h> #include<algorithm> #include<set> #include<stack> #include<queue> #include<math.h> #include<assert.h> #include<utility> using namespace std; typedef long long int ll; #define For(i,s,e) for(int i=(s);i<=(e);i++...
not-set
2016-04-24T02:02:52
2016-07-23T18:42:05
C++
133
3,340
value-of-all-permutations
Value of all Permutations
You are given an array $A$ of size $N$. You are asked to answer $Q$ queries. Each query contains a number $M$. For each *distinct* permutation of the array $A$, you need to print the sum of the values returned by the `find` function. As the sum can be too large, output it modulo $P$, which is a prime and given i...
code
For each distinct permutation of the array A, you need to print the sum of the values returned by the described function.
ai
2014-07-21T17:27:10
2022-09-02T09:54:59
null
null
null
You are given an array $A$ of size $N$. You are asked to answer $Q$ queries. Each query contains a number $M$. For each *distinct* permutation of the array $A$, you need to print the sum of the values returned by the `find` function. As the sum can be too large, output it modulo $P$, which is a prime and given i...
0.444444
["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
null
null
null
null
null
null
2014-07-21T17:56:07
2016-12-03T12:49:09
tester
###Python 2 ```python P = input() # collect and sort A N = input() A = map(int, raw_input().strip().split()) A.sort() # calculate partial sums S S = [0]*(N+1) for i in xrange(N): S[i+1] = (S[i] + A[i]) % P # inverses mod P inv = [1]*(N+2) for i in xrange(2,N+2): inv[i] = -(P/i) * inv[P%i] % P # calculat...
not-set
2016-04-24T02:02:52
2016-07-23T18:42:22
Python
134
2,324
akhil-and-gf
Akhil and GF
After dating for a long time, Akhil is finally going to propose to his girlfriend. She is very strong in mathematics, and will accept his proposal, if and only if Akhil solves a problem given by her. The problem is given below. Help Akhil solve it. Akhil is given two numbers N and M, and he has to tell her the remaind...
code
Help Akhil in impressing his girlfriend
ai
2014-04-08T07:07:53
2022-09-02T09:54:30
# # Complete the 'solve' function below. # # The function is expected to return an INTEGER. # The function accepts following parameters: # 1. LONG_INTEGER n # 2. INTEGER m # def solve(n, m): # 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]) m = int(first_multiple_input[1]) result = solve(n, m) fptr.wri...
After dating for a long time, Akhil is finally going to propose to his girlfriend. She is very strong in mathematics, and will accept his proposal, if and only if Akhil solves a problem given by her. The problem is given below. Help Akhil solve it. Akhil is given two numbers N and M, and he has to tell her the remaind...
0.493976
["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
null
null
null
null
null
null
2014-07-29T10:04:09
2016-12-01T20:29:14
setter
###C++ ```cpp #include<bits/stdc++.h> using namespace std; long long int power(long long int a, long long int b, long long int c) { if(b==0) return 1; if(b==1) return a%c; if(b%2 == 0) { long long int temp = power(a,b/2,c); return (temp*temp)%c; } else ...
not-set
2016-04-24T02:02:53
2016-07-23T17:55:55
C++
135
2,609
emma-and-sum-of-products
Emma and sum of products
Emma is really fond of integers and loves playing with them. Her friends were jealous, and to test her, one of them gave her a problem. Emma is given a list $A$ of $N$ integers and is asked a set of $Q$ queries. Each query is denoted by an integer $K$, for which you have to return the sum of product of all possible s...
code
Help Emma find sum of product of all K size sublists.
ai
2014-06-13T18:12:02
2022-09-02T09:55:12
# # Complete the 'solve' function below. # # The function is expected to return an INTEGER_ARRAY. # The function accepts following parameters: # 1. INTEGER_ARRAY A # 2. INTEGER_ARRAY queries # def solve(A, queries): # 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') A_count = int(input().strip()) A = list(map(int, input().rstrip().split())) queries_count = int(input().strip()) queries = [] for _ in range(queries_count): queries_item = int(input().strip()) queries.app...
Emma is really fond of integers and loves playing with them. Her friends were jealous, and to test her, one of them gave her a problem. Emma is given a list $A$ of $N$ integers and is asked a set of $Q$ queries. Each query is denoted by an integer $K$, for which you have to return the sum of product of all possible s...
0.576923
["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
null
null
null
null
null
null
2014-07-29T13:34:12
2016-07-23T18:59:58
setter
###C++ ```cpp #include<iostream> #include<vector> #include<cmath> #include<complex> using namespace std; #define PB push_back const double PI = 4*atan(1); typedef complex<double> base; vector<base> omega; long long FFT_N,mod=100003; void init_fft(long long n) { FFT_N = n; omega.resize(n); double angle = 2 * ...
not-set
2016-04-24T02:02:53
2016-07-23T18:59:48
C++
136
2,609
emma-and-sum-of-products
Emma and sum of products
Emma is really fond of integers and loves playing with them. Her friends were jealous, and to test her, one of them gave her a problem. Emma is given a list $A$ of $N$ integers and is asked a set of $Q$ queries. Each query is denoted by an integer $K$, for which you have to return the sum of product of all possible s...
code
Help Emma find sum of product of all K size sublists.
ai
2014-06-13T18:12:02
2022-09-02T09:55:12
# # Complete the 'solve' function below. # # The function is expected to return an INTEGER_ARRAY. # The function accepts following parameters: # 1. INTEGER_ARRAY A # 2. INTEGER_ARRAY queries # def solve(A, queries): # 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') A_count = int(input().strip()) A = list(map(int, input().rstrip().split())) queries_count = int(input().strip()) queries = [] for _ in range(queries_count): queries_item = int(input().strip()) queries.app...
Emma is really fond of integers and loves playing with them. Her friends were jealous, and to test her, one of them gave her a problem. Emma is given a list $A$ of $N$ integers and is asked a set of $Q$ queries. Each query is denoted by an integer $K$, for which you have to return the sum of product of all possible s...
0.576923
["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
null
null
null
null
null
null
2014-07-29T13:34:12
2016-07-23T18:59:58
tester
###C++ ```cpp #include<stdio.h> #include<stdlib.h> #include<math.h> #include<string.h> #define fo(i,a,b) dfo(int,i,a,b) #define fr(i,n) dfr(int,i,n) #define fe(i,a,b) dfe(int,i,a,b) #define fq(i,n) dfq(int,i,n) #define nfo(i,a,b) dfo(,i,a,b) #define nfr(i,n) dfr(,i,n) #define nfe(i,a,b) dfe(,i,a,b) #define nfq(i,n)...
not-set
2016-04-24T02:02:53
2016-07-23T18:59:58
C++
137
3,436
the-lovers
The Lovers
**Description:** Once upon a time there was a man who had multiple girlfriends. Each girl thought she was the only one in the man's heart but this was not true. He was cheating concurrently on all of them. There are **N** houses lined up in the town. Each house has exactly one of his girlfriends living there. On...
code
Count the ways in which a lover may visit his girlfriends.
ai
2014-08-01T00:08:23
2019-07-02T13:58:45
null
null
null
**Description:** Once upon a time there was a man who had multiple girlfriends. Each girl thought she was the only one in the man's heart but this was not true. He was cheating on all of them. **N** houses were situated in a row and each house had exactly one of his girlfriends living there. One day he wanted to...
0.5
["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
null
null
null
null
null
null
2014-08-01T00:08:47
2016-05-12T23:59:12
setter
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { static int T; static long N, K; static long MOD = 100003; static long factorial[]; public static long POW(long a, long b){ if(b == 0) return 1; if(b == 1) return a % MOD; if(b...
not-set
2016-04-24T02:02:53
2016-04-24T02:02:53
Python
138
3,437
training-the-army
Training the army
In the magical kingdom of Kasukabe, people strive to possess only one skillset. Higher the number of skillset present among the people, the more content people will be. There are $N$ types of skill set present and initially there exists $C_i$ people possessing $i^{th}$ skill set, where $i \in [1, N]$. There are $...
code
Design a series of transformation which results into maximum number of skill set with non-zero acquaintance.
ai
2014-08-01T00:35:38
2022-09-02T10:10:38
null
null
null
In the magical kingdom of Kasukabe, people strive to possess skillsets. Higher the number of skillset present among the people, the more content people will be. There are $N$ types of skill set present and initially there exists $C_i$ people possessing $i^{th}$ skill set, where $i \in [1, N]$. There are $T$ wizar...
0.545455
["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 contains two numbers, $N\ T$, where $N$ represent the number of skill set and $T$ represent the number of wizards. Next line contains $N$ space separated integers, $C_1\ C_2\ \ldots\ C_N$, where $C_i$ represents the number of people with $i^{th}$ skill. Then follows $2 \times T$ lines, where each pai...
The output must consist of one number, the maximum number of distinct skill set that can the people of country learn, after making optimal transformation steps.
3 3 3 0 0 1 1 2 2 3 1 2 1 3 1 1 1 2
2
Hard
null
null
null
null
null
null
2014-08-01T00:35:56
2016-07-23T14:07:35
setter
###C++ ```cpp #include<stdio.h> #include<math.h> #include<complex> #include<iostream> #include<queue> #include<stack> #include<algorithm> #include<string.h> #include<cstring> #include<cassert> #include<map> #include<vector> using namespace std; using namespace std; const int MAXA = 400005; const int MAXV = 1005; ...
not-set
2016-04-24T02:02:53
2016-07-23T14:07:35
C++
139
3,465
gdragon
Goku and Dragon Balls
Goku was finally successful in collecting all the Dragon Balls (total n of them), each having a unique color. Now for becoming super-powerful, he has to put the Dragon Balls in the holy temple, such that each ball is placed in the room which does NOT have the same color as that particular Dragon Ball. The temple, also ...
code
null
ai
2014-08-02T05:17:43
2016-09-09T09:48:54
null
null
null
Goku was finally successful in collecting all the Dragon Balls (total n of them), each having a unique color. Now for becoming super-powerful, he has to put the Dragon Balls in the holy temple, such that each ball is placed in the room which does NOT have the same color as that particular Dragon Ball. The temple, also ...
0.5
["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
null
null
null
null
null
null
2014-08-02T05:19:44
2016-12-22T22:43:16
setter
#include <cstdio> #define mod 1000000007 using namespace std; long long int arr[10000008]; int main () { arr[0] = 1; arr[1] = 0; for (int i = 2; i <= 10000000; i++) arr[i] = ( (i-1) * (( arr[i-1] + arr[i-2] ) % mod) ) % mod; int cases, n; scan...
not-set
2016-04-24T02:02:54
2016-04-24T02:02:54
C++
140
3,511
the-frustrated-sam
The Frustrated Sam
This is placement season. _Sam_ got frustated because of his batch mates. They all have a good OGPA. Odds are not in favor of _Sam_. But _Sam_ have a cool idea of project that will get him into any dream company. Project is calculation of frustration among engineers. So after a lot of research he formulated measure of ...
code
Do you know how to measure frustration? It is Sam's project.
ai
2014-08-07T17:53:54
2016-09-09T09:49:10
null
null
null
This is placement season. _Sam_ got frustated because of his batch mates. They all have a good OGPA. Odds are not in favor of _Sam_. But _Sam_ have a cool idea of project that will get him into any dream company. Project is calculation of frustration among engineers. So after a lot of research he formulated measure of ...
0.5
["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
null
null
null
null
null
null
2014-08-07T17:54:20
2016-05-12T23:58:57
setter
import java.io.*; import java.util.StringTokenizer; class Matrix { public static long mod = 1000000007; public final long[][] data; public final int rowCount; public final int columnCount; public Matrix(int rowCount, int columnCount) { this.rowCount = r...
not-set
2016-04-24T02:02:55
2016-04-24T02:02:55
Python
141
3,542
geek-concert
Geek concert
The big country Geeko where every person is known as geek-ian, is organising a concert of geeks. The arrangements are all set for the concert. All **N** geek-ians are waiting in line to enter the concert. Geek-ians get bored waiting so they turn and look for someone familiar in the line. Two geek-ians P and Q standin...
code
null
ai
2014-08-10T08:21:34
2016-09-09T09:49:21
null
null
null
The big country Geeko where every person is known as geek-ian, is organising a concert of geeks. The arrangements are all set for the concert. All **N** geek-ians are waiting in line to enter the concert. Geek-ians get bored waiting so they turn and look for someone familiar in the line. Two geek-ians P and Q standin...
0.5
["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
null
null
null
null
null
null
2014-08-10T08:36:09
2016-05-12T23:58:51
setter
#include<iostream> #include<cmath> #include<cstring> #include<string> #include<bitset> #include<algorithm> #include<vector> #include<set> #include<map> #include<stack> #include<stdio.h> #include<queue> #define si(n) scanf("%d",&n) #define sll(n) scanf("%lld",&n) #define mod 1000000007 // 10**9 + 7 #def...
not-set
2016-04-24T02:02:55
2016-04-24T02:02:55
C++
142
3,545
kevin-and-expected-value-2
Kevin and Expected Value 2
When students solved the first problem quickly, Kevinsogo gave them a harder problem. Students need your help in solving this problem.<br> Given the value of $N$ and a function $\scriptsize {\text{rand}()} $ which uniformly produces a value between $0$ and $N-1$, let's define $$ \scriptsize{ f(N) = \sqrt{1 + \text{ran...
code
Find Expected value of function
ai
2014-08-10T20:06:35
2019-07-02T13:58:46
null
null
null
When students solved the first problem quickly, Kevinsogo gave them a harder problem. Students need your help in solving this problem.<br> Given the value of $N$ and a function $\scriptsize {\text{rand}()} $ which uniformly produces an integer value between $0$ and $N-1$, let's define $$ \scriptsize{ f(N) = \sqrt{1 + ...
0.5
["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
null
null
null
null
null
null
2014-08-10T20:06:54
2016-05-12T23:58:49
tester
#include <math.h> #include <stdio.h> int n,i,T; double l,r,c,ans; int main() { scanf("%d",&T); while(T--) { scanf("%d",&n); l=0; r=n*2; while(r-l>1e-6) { c=(l+r)/2; ans=0; for(i=1;i<=n;i++) ans+=c-sqrt(i+c); if(ans>0) r=c; else l=c; } printf("%.5lf\n...
not-set
2016-04-24T02:02:55
2016-04-24T02:02:55
C++
143
3,547
mehta-and-his-laziness
Mehta and his Laziness
Mehta is a very lazy boy. He always sleeps in Maths class. One day his teacher catches him sleeping and tells him that she would mark him absent for the whole semester. While she pretends to be strict, she is actually very kind-hearted. So she wants to give Mehta a chance to prove himself. She gives him a problem. If M...
code
How will Mehta do these calculations?
ai
2014-08-11T10:38:55
2022-09-02T10:08:00
# # Complete the 'solve' function below. # # The function is expected to return a STRING. # The function accepts INTEGER n as parameter. # def solve(n): # 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): n = int(input().strip()) result = solve(n) fptr.write(result + '\n') fptr.close()
Mehta is a very lazy boy. He always sleeps in Maths class. One day his teacher catches him sleeping and tells him that she would mark him absent for the whole semester. While she pretends to be strict, she is actually very kind-hearted. So she wants to give Mehta a chance to prove himself. She gives him a problem. If M...
0.473684
["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
null
null
null
null
null
null
2014-08-11T10:39:05
2016-12-06T10:15:06
setter
###C++ ```cpp #include<bits/stdc++.h> using namespace std; pair <int,int> A[1000005]; bool chk(int x) { int p = (int)sqrt(x); if ( p*p == x || (p-1)*(p-1) == x || (p+1)*(p+1) == x ) return true; return false; } void pre() { for ( int i = 1; i <= 1000; i++ ) { for ( int j = i; j <= 10...
not-set
2016-04-24T02:02:55
2016-07-23T17:39:08
C++
144
3,547
mehta-and-his-laziness
Mehta and his Laziness
Mehta is a very lazy boy. He always sleeps in Maths class. One day his teacher catches him sleeping and tells him that she would mark him absent for the whole semester. While she pretends to be strict, she is actually very kind-hearted. So she wants to give Mehta a chance to prove himself. She gives him a problem. If M...
code
How will Mehta do these calculations?
ai
2014-08-11T10:38:55
2022-09-02T10:08:00
# # Complete the 'solve' function below. # # The function is expected to return a STRING. # The function accepts INTEGER n as parameter. # def solve(n): # 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): n = int(input().strip()) result = solve(n) fptr.write(result + '\n') fptr.close()
Mehta is a very lazy boy. He always sleeps in Maths class. One day his teacher catches him sleeping and tells him that she would mark him absent for the whole semester. While she pretends to be strict, she is actually very kind-hearted. So she wants to give Mehta a chance to prove himself. She gives him a problem. If M...
0.473684
["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
null
null
null
null
null
null
2014-08-11T10:39:05
2016-12-06T10:15:06
tester
###Python 2 ```python from math import sqrt from fractions import gcd N = 10**6 # calculate good numbers (i.e., even perfect squares) is_good = [False]*(N+1) for i in xrange(1,int(sqrt(N))+1): if i % 2 == 0: is_good[i * i] = 1 # calculate good divisors of numbers in O(N log N) goods = [0]*(N+1) total...
not-set
2016-04-24T02:02:55
2016-07-23T17:39:18
Python
145
3,548
mehta-and-the-typical-supermarket
Mehta and the Typical Supermarket
Mehta is a very rich guy. He has $N$ types of coins, and each type of coin is available in an unlimited supply. So Mehta goes to a supermarket to buy monthly groceries. There he sees that every item has a unique price, that is, no two items have the same price. Now, the supermarket owner tells Mehta that they are...
code
Help Mehta in shopping
ai
2014-08-11T11:00:03
2022-09-02T09:54:52
# # Complete the 'solve' function below. # # The function is expected to return an INTEGER_ARRAY. # The function accepts following parameters: # 1. INTEGER_ARRAY a # 2. 2D_INTEGER_ARRAY days # def solve(a, days): # 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') a_count = int(input().strip()) a = [] for _ in range(a_count): a_item = int(input().strip()) a.append(a_item) d = int(input().strip()) days = [] for _ in range(d): days.append(list(map(int, i...
Mehta is a very rich guy. He has $N$ types of coins, and each type of coin is available in an unlimited supply. So Mehta goes to a supermarket to buy monthly groceries. There he sees that every item has a unique price, that is, no two items have the same price. Now, the supermarket owner tells Mehta that they are...
0.421053
["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"]
Hard
null
null
null
null
null
null
2014-08-11T11:00:18
2016-12-04T05:30:50
setter
###C++ ```cpp #include<bits/stdc++.h> using namespace std; pair<long long,int> pre[200000]; long long a[25],N; #define INF 2000000000000000000LL long long trunc_mul(long long a, long long b) { return a <= INF / b ? a * b : INF; } void compute() { int limit = 1<<N; limit--; for(int i = 1;i <= limit;i...
not-set
2016-04-24T02:02:56
2016-07-23T18:32:35
C++
146
3,548
mehta-and-the-typical-supermarket
Mehta and the Typical Supermarket
Mehta is a very rich guy. He has $N$ types of coins, and each type of coin is available in an unlimited supply. So Mehta goes to a supermarket to buy monthly groceries. There he sees that every item has a unique price, that is, no two items have the same price. Now, the supermarket owner tells Mehta that they are...
code
Help Mehta in shopping
ai
2014-08-11T11:00:03
2022-09-02T09:54:52
# # Complete the 'solve' function below. # # The function is expected to return an INTEGER_ARRAY. # The function accepts following parameters: # 1. INTEGER_ARRAY a # 2. 2D_INTEGER_ARRAY days # def solve(a, days): # 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') a_count = int(input().strip()) a = [] for _ in range(a_count): a_item = int(input().strip()) a.append(a_item) d = int(input().strip()) days = [] for _ in range(d): days.append(list(map(int, i...
Mehta is a very rich guy. He has $N$ types of coins, and each type of coin is available in an unlimited supply. So Mehta goes to a supermarket to buy monthly groceries. There he sees that every item has a unique price, that is, no two items have the same price. Now, the supermarket owner tells Mehta that they are...
0.421053
["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"]
Hard
null
null
null
null
null
null
2014-08-11T11:00:18
2016-12-04T05:30:50
tester
###Python 2 ```python from fractions import gcd def lcm(a,b): return a / gcd(a,b) * b n = input() bitcount = [0]*(1<<n) lcms = [1]*(1<<n) for i in xrange(n): a = input() for j in xrange(1<<i): lcms[(1<<i)|j] = lcm(a, lcms[j]) bitcount[(1<<i)|j] = bitcount[j] + 1 def count(k): t =...
not-set
2016-04-24T02:02:56
2016-07-23T18:32:46
Python
147
3,585
jim-and-his-lan-party
Jim and his LAN Party
During the Steam Summer Sale, Jim's $N-1$ friends have purchased $M$ games, which are numbered from $1$ to $M$. The games are multiplayer. Jim has invited his friends to his basement where they will play by making a LAN-Party. Each friend has already decided the game he would like to play for the rest of the day. So ...
code
Jim is planning a LAN party in the basement of his big burger restaurant, but they stumbled upon a problem. Please help them.
ai
2014-08-15T10:42:28
2022-09-02T10:10:39
# # Complete the 'lanParty' function below. # # The function is expected to return an INTEGER_ARRAY. # The function accepts following parameters: # 1. INTEGER_ARRAY games # 2. 2D_INTEGER_ARRAY wires # 3. INTEGER m # def lanParty(games, wires, m): # 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') first_multiple_input = input().rstrip().split() n = int(first_multiple_input[0]) m = int(first_multiple_input[1]) q = int(first_multiple_input[2]) games = list(map(int, input().rstrip().split())) wires = [] for...
During the Steam Summer Sale, Jim's $N-1$ friends have purchased $M$ games, which are numbered from $1$ to $M$. The games are multiplayer. Jim has invited his friends to his basement where they will play by making a LAN-Party. Each friend has already decided the game he would like to play for the rest of the day. So ...
0.5
["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"]
On the first line there will be $N$, $M$ and $Q$ each separated by a single space. On the second line we will give you $N$ integers separated by a single space: The $i$-th integer denotes the game friend $i$ wants to play (all between $1$ and $M$). The next $Q$ lines will denote $Q$ wires: i<sup>th</sup> line denotes i...
Print on the $i$<sup>th</sup> line the answer for the $i$<sup>th</sup> game.
5 2 4 1 2 2 2 1 1 2 2 3 1 5 4 5
3 4
Hard
null
null
null
null
null
null
2014-08-15T10:42:46
2016-12-02T11:12:23
setter
###C++ ```cpp #include <iostream> #include <vector> using namespace std; #define SZ(x) ( (int) (x).size() ) const int MAX_N = 100000 + 1; int N, M, Q; int color[MAX_N]; vector<int> cpos[MAX_N]; vector<int> q[MAX_N]; int qu[MAX_N], qv[MAX_N]; int lo[MAX_N], hi[MAX_N]; // implementation of UFDS int f[MAX_N]; int getf...
not-set
2016-04-24T02:02:56
2016-07-23T14:08:33
C++
148
3,666
chandrima-and-xor
Chandrima and XOR
Chandrima likes the XOR operation very much and keeps finding and solving related problems. One day she comes across a problem and gets stuck on it, which makes her sad. You being her friend decide to help her out by writing a code for the same. Consider a list of all natural numbers. Now you remove all numbers whose...
code
Help Chandrima find the XOR of N numbers
ai
2014-08-17T03:33:11
2022-09-02T09:54:42
# Complete the solve function below. def solve(a):
#!/bin/python3 import os import sys
if __name__ == '__main__': fptr = open(os.environ['OUTPUT_PATH'], 'w') a_count = int(input()) a = list(map(int, input().rstrip().split())) result = solve(a) fptr.write(str(result) + '\n') fptr.close()
Chandrima likes the XOR operation very much and keeps finding and solving related problems. One day she comes across a problem and gets stuck on it, which makes her sad. You being her friend decide to help her out by writing a code for the same. Consider a list of all natural numbers. Now you remove all numbers whose...
0.592593
["c","clojure","cpp","cpp14","csharp","erlang","go","haskell","java","java8","javascript","kotlin","lua","objectivec","perl","php","pypy3","python3","ruby","scala","swift"]
null
null
null
null
Hard
null
null
null
null
null
null
2014-08-17T03:33:24
2016-12-02T14:47:34
setter
###C++ ```cpp #include <iostream> #include <vector> #define pb push_back using namespace std; long long mod=1000000007; vector<long long> fibo,power; void two_pow() { long long p; power.pb(1); for(int i=1;i<100;i++) { power.pb(power[i-1]+power[i-1]); if(power[i]>=mod) pow...
not-set
2016-04-24T02:02:57
2016-07-23T17:59:37
C++
149
2,056
pmix
Mixing proteins
Some scientists are working on protein recombination, and during their research, they have found a remarkable fact: there are 4 proteins in the protein ring that mutate after every second according to a fixed pattern. For simplicity, proteins are called $A, B, C, D$ (you know, protein names can be very complicated). A ...
code
Your help is required for mutation prediction...
ai
2014-03-07T01:25:46
2022-08-31T08:15:01
# # Complete the 'pmix' function below. # # The function is expected to return a STRING. # The function accepts following parameters: # 1. STRING s # 2. INTEGER k # def pmix(s, 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') first_multiple_input = input().rstrip().split() n = int(first_multiple_input[0]) k = int(first_multiple_input[1]) s = input() result = pmix(s, k) fptr.write(result + '\n') fptr.close()
Some scientists are working on protein recombination, and during their research, they have found a remarkable fact: there are 4 proteins in the protein ring that mutate after every second according to a fixed pattern. For simplicity, proteins are called $A, B, C, D$ (you know, protein names can be very complicated). A ...
0.421053
["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"]
Input contains 2 lines. First line has 2 integers $N$ and $K$, $N$ being the length of the protein ring and $K$ the desired number of seconds. Second line contains a string of length $N$ containing uppercase letters $A$,$ B$, $C$ or $D$ only, describing the ring.
Output a single line with a string of length $N$, describing the state of the ring after $K$ seconds.
Hard
null
null
null
null
null
null
2014-08-18T16:57:49
2016-12-08T11:30:19
setter
###C++ ```cpp //============================================================================ // Name : PMIX.cpp // Author : Shaka // Version : // Copyright : Your copyright notice // Description : Hello World in C++, Ansi-style //====================================================================...
not-set
2016-04-24T02:02:58
2016-07-23T18:14:05
C++
150
3,900
grow-the-tree
Grow the tree
The Utopian tree goes through 2 cycles of growth every year. The first growth cycle of the tree occurs during the monsoon, when it doubles in height. The second growth cycle of the tree occurs during the summer, when its height increases by 1 meter. Now, a new Utopian tree sapling is planted at the onset of the monso...
code
null
ai
2014-08-22T07:05:17
2016-09-09T09:50:28
null
null
null
The Utopian tree goes through 2 cycles of growth every year. The first growth cycle of the tree occurs during the monsoon, when it doubles in height. The second growth cycle of the tree occurs during the summer, when its height increases by 1 meter. Now, a new Utopian tree sapling is planted at the onset of the monso...
0.5
["java","cpp","c","cpp14"]
null
null
null
null
Hard
null
null
null
null
null
null
2014-08-22T07:08:29
2016-05-12T23:58:07
setter
#include<stdio.h> int treegrowth(int s) {int a,c=1,i; a=s/2; if(s%2==0) { for(i=0;i<a;i++) { c=c*2; c=c+1; } } else{ for(i=0;i<a;i++) { c=c*2; c=c+1; } c=c*2; } return c; } int m...
not-set
2016-04-24T02:02:58
2016-04-24T02:02:58
C++
151
3,902
weird-queries
Two Array Problem
In this problem you operate on two arrays of $N$ integers. We will call them the $0^{th}$ and the $1^{st}$ respectively. Your goal is just to maintain them under the modification operations, such as: + 1 $id$ $l$ $r$: Reverse the subarray of the $id^{th}$ array, starting at the $l^{th}$ number, ending at the $r^{...
code
Given 2 arrays, you have to maitain them, given 4 types of queries.
ai
2014-08-22T13:35:42
2022-08-31T08:33:19
null
null
null
In this problem you operate on two arrays of $N$ integers. We will call them the $0^{th}$ and the $1^{st}$ respectively. Your goal is just to maintain them under the modification operations, such as: + 1 $id$ $l$ $r$: Reverse the subarray of the $id^{th}$ array, starting at the $l^{th}$ number, ending at the $r^{...
0.458333
["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"...
null
null
null
null
Hard
null
null
null
null
null
null
2014-08-22T13:35:54
2016-12-03T07:48:01
tester
#ifdef ssu1 #define _GLIBCXX_DEBUG #endif #undef NDEBUG #include <algorithm> #include <functional> #include <numeric> #include <iostream> #include <cstdio> #include <cmath> #include <cstdlib> #include <ctime> #include <cstring> #include <cassert> #include <ve...
not-set
2016-04-24T02:02:59
2016-04-24T02:02:59
C++
152
3,957
bangalore-bank
Bangalore Bank
There is a famous old bank in Bangalore. It has just started the process of filling its database with bank account numbers of its clients. In order to put one account number to the database, an employee has to insert it from a piece of paper to a computer using a standard keyboard (without using number pad found on the...
code
Account numbers
ai
2014-08-24T18:19:12
2018-05-23T18:41:29
null
null
null
There is a famous old bank in Bangalore. It has just started the process of filling its database with bank account numbers of its clients. In order to put one account number to the database, an employee has to insert it from a piece of paper to a computer using a standard keyboard (without using number pad found on the...
0.5
["cobol","clojure","sbcl","elixir","erlang","fsharp","haskell","java","java8","kotlin","ocaml","racket","scala"]
null
null
null
null
Hard
null
null
null
null
null
null
2014-08-24T18:44:10
2016-12-04T15:53:15
tester
--Haskell import qualified Data.Vector as V oo = 10^8 :: Int main :: IO () main = getContents >>= print. getAns. map (map read. words). lines where getAns ([n]:arr:[]) = solve (length arr) (V.fromList. map (\x -> (x-1+10)`rem`10) $ arr) solve :: Int -> V.Vector Int -> Int ...
not-set
2016-04-24T02:02:59
2016-04-24T02:02:59
Python
153
3,985
testproblem
testProblem
Print 100
code
Print 100
ai
2014-08-26T16:56:45
2016-09-09T09:50:57
null
null
null
Print 100
0.5
["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
null
null
null
null
null
null
2014-08-26T16:58:49
2016-05-12T23:57:55
setter
include <stdio.h> int main() { printf("100"); return 0; }
not-set
2016-04-24T02:02:59
2016-04-24T02:02:59
Unknown
154
3,993
a-super-hero
A Super Hero
**Ma5termind** is crazy about Action Games. He has just bought a new one and is ready to play with it. While Ma5termind usually finishes the levels of a game very quickly, today he got stuck at the very first level of this new game. **How come ?** Game rules state that the **Ma5termind** has to cross N levels and at ea...
code
Minimal number of bullets required to complete N levels of the game if you kill one enemy at each level and use its bullet for current and just next level
ai
2014-08-27T12:24:33
2022-08-31T08:14:48
# # Complete the 'superHero' function below. # # The function is expected to return an INTEGER. # The function accepts following parameters: # 1. 2D_INTEGER_ARRAY power # 2. 2D_INTEGER_ARRAY bullets # def superHero(power, bullets): # 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]) m = int(first_multiple_input[1]) power = [] for _ in range(n):...
Ma5termind is crazy about Action Games. He just bought a new one and got down to play it. Ma5termind usually finishes all the levels of a game very fast. But, This time however he got stuck at the very first level of this new game. Can you help him play this game. To finish the game, Ma5termind has to cross $N$ leve...
0.5
["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"]
First line of input contains a single integer $T$ denoting the number of test cases. First line of each test case contains two space separated integers $N$ and $M$ denoting the number of levels and number of enemies at each level respectively. Each of next $N$ lines of a test case contain $M$ space separated intege...
For each test case, print the required answer.
2 3 3 3 2 1 1 2 3 3 2 1 1 2 3 3 2 1 1 2 3 3 3 3 2 5 8 9 1 4 7 6 1 1 1 1 1 1 1 1 1
1 5
Hard
null
null
null
null
null
null
2014-08-27T12:25:04
2016-12-07T15:45:23
setter
###C++ ```cpp #include<bits/stdc++.h> #define pb push_back #define mp make_pair #define all(x) x.begin(),x.end() #define PII pair<int,int> #define ft first #define sd second #define inf 10000000 using namespace std; int main(){ int t; cin >> t; while(t--){ int n,m; cin >> n >>...
not-set
2016-04-24T02:03:00
2016-07-23T15:16:54
C++
155
3,994
police-operation
Police Operation
Roy is helping the police department of his city in crime fighting. Today, they informed him about a new planned operation. Think of the city as a $2D$ plane. The road along the $X$-axis is very crime prone, because $n$ criminals live there. No two criminals live at the same position. To catch these criminals, the po...
code
Given N points on X-axis, find M points such that these cover given points and distance between adjacent points is minimized.
ai
2014-08-27T17:05:08
2022-08-31T08:14:51
# # Complete the 'policeOperation' function below. # # The function is expected to return an INTEGER. # The function accepts following parameters: # 1. INTEGER h # 2. INTEGER_ARRAY criminals # def policeOperation(h, criminals): # 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') first_multiple_input = input().rstrip().split() n = int(first_multiple_input[0]) h = int(first_multiple_input[1]) criminals = list(map(int, input().rstrip().split())) result = policeOperation(h, criminals) fptr.writ...
Roy is helping the police department of his city in crime fighting. Today, they informed him about a new planned operation. Think of the city as a $2D$ plane. The road along the $X$-axis is very crime prone, because $n$ criminals live there. No two criminals live at the same position. To catch these criminals, the po...
0.485714
["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 two integers $n$ $(0 \le n \le 2 \times 10^{6})$, number of criminals, and $h$ $( 0 \le h \le 10^{9} )$, the cost of recruiting a police officer. The next line contains $n$ space separated integers. The $i^{th}$ integer indicates the position of the $i^{th}$ criminal on $X$-axis (in other words,...
Print the minimum amount of money required to complete the operation.
5 10 1 4 5 6 9
34
Hard
null
null
null
null
null
null
2014-08-27T17:06:14
2016-12-02T08:39:51
setter
###C++ ```cpp /* * Bidhan Roy * University of Dhaka */ using namespace std; #include <bits/stdc++.h> #define sgn(x,y) ((x)+eps<(y)?-1:((x)>eps+(y)?1:0)) #define rep(i,n) for(int i=0; i<(n); i++) #define mem(x,val) memset((x),(val),sizeof(x)); #define rite(x) freopen(x,"w",stdout); #define read(x) freopen(x,"r"...
not-set
2016-04-24T02:03:00
2016-07-23T15:28:49
C++
156
3,994
police-operation
Police Operation
Roy is helping the police department of his city in crime fighting. Today, they informed him about a new planned operation. Think of the city as a $2D$ plane. The road along the $X$-axis is very crime prone, because $n$ criminals live there. No two criminals live at the same position. To catch these criminals, the po...
code
Given N points on X-axis, find M points such that these cover given points and distance between adjacent points is minimized.
ai
2014-08-27T17:05:08
2022-08-31T08:14:51
# # Complete the 'policeOperation' function below. # # The function is expected to return an INTEGER. # The function accepts following parameters: # 1. INTEGER h # 2. INTEGER_ARRAY criminals # def policeOperation(h, criminals): # 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') first_multiple_input = input().rstrip().split() n = int(first_multiple_input[0]) h = int(first_multiple_input[1]) criminals = list(map(int, input().rstrip().split())) result = policeOperation(h, criminals) fptr.writ...
Roy is helping the police department of his city in crime fighting. Today, they informed him about a new planned operation. Think of the city as a $2D$ plane. The road along the $X$-axis is very crime prone, because $n$ criminals live there. No two criminals live at the same position. To catch these criminals, the po...
0.485714
["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 two integers $n$ $(0 \le n \le 2 \times 10^{6})$, number of criminals, and $h$ $( 0 \le h \le 10^{9} )$, the cost of recruiting a police officer. The next line contains $n$ space separated integers. The $i^{th}$ integer indicates the position of the $i^{th}$ criminal on $X$-axis (in other words,...
Print the minimum amount of money required to complete the operation.
5 10 1 4 5 6 9
34
Hard
null
null
null
null
null
null
2014-08-27T17:06:14
2016-12-02T08:39:51
tester
###C++ ```cpp #ifdef ssu1 #define _GLIBCXX_DEBUG #endif #undef NDEBUG #include <algorithm> #include <functional> #include <numeric> #include <iostream> #include <cstdio> #include <cmath> #include <cstdlib> #include <ctime> #include <cstring> #include <cassert> #include <vector> #include <list> #include <map> #incl...
not-set
2016-04-24T02:03:00
2016-07-23T15:40:25
C++
157
3,997
annual-boat-challenge
Annual Boat Challenge
The big day is approaching, the finals of the Annual Boat Challenge. The challenge consists of going down the river and earning the biggest number of points as possible. The circuit contains N checkpoints. It starts at the checkpoint number 0 and can finish at any checkpoint. At each checkpoint the competitors have a...
code
Let's count!
ai
2014-08-27T19:11:28
2016-09-09T09:51:01
null
null
null
The big day is approaching, the finals of the Annual Boat Challenge. The challenge consists of going down the river and earning the biggest number of points as possible. The circuit contains N checkpoints. It starts at the checkpoint number 0 and can finish at any checkpoint. At each checkpoint the competitors have a...
0.5
["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
null
null
null
null
null
null
2014-08-27T19:12:35
2016-05-12T23:57:49
setter
import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Vector; public class Main { static int N, K, L, R; static int poi...
not-set
2016-04-24T02:03:00
2016-04-24T02:03:00
Python
158
3,998
another-increasing-subsequence-problem
Another increasing subsequence problem
N numbers are given to you A1, A2, A3, ... AN-1, AN. How many increasing subsequences exist with at most K numbers where the difference between two consecutive numbers is at most D. An increasing subsequence of K numbers is a sequence Ai1, Ai2, ... ,Aik-1, Aik where (1 <= i1 < i2 < ik-1 < ik <= N) and (Ai1 < Ai2 < .....
code
How many special subsequence!
ai
2014-08-27T19:26:55
2016-09-09T09:51:01
null
null
null
N numbers are given to you A1, A2, A3, ... AN-1, AN. How many increasing subsequences exist with at most K numbers where the difference between two consecutive numbers is at most D. An increasing subsequence of K numbers is a sequence Ai1, Ai2, ... ,Aik-1, Aik where (1 <= i1 < i2 < ik-1 < ik <= N) and (Ai1 < Ai2 < .....
0.5
["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
null
null
null
null
null
null
2014-08-27T19:27:09
2016-05-12T23:57:49
setter
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { static int BIT[]; static int MOD = (int) 1e9 + 7; static void update(int x, int v) { for(int i = x;i<=100000;i+=(i&-i)) BIT[i] = (BIT[i] + v) % MOD; } static int query(int x) { int res =...
not-set
2016-04-24T02:03:00
2016-04-24T02:03:00
Python
159
4,001
business-business
Business, business
Making business and earning money, this is a fashion which will never get old. You, a business man , want to increase your fortune of making good business. There are two companies in the town. Each of these companies has a set of services and they are willing to sell these services to you. You know how much you will e...
code
Can you help the company to earn money?
ai
2014-08-27T19:54:53
2016-09-09T09:51:02
null
null
null
Making business and earning money, this is a fashion which will never get old. You, a business man , want to increase your fortune of making good business. There are two companies in the town. Each of these companies has a set of services and they are willing to sell these services to you. You know how much you will e...
0.5
["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
null
null
null
null
null
null
2014-08-27T19:55:15
2016-05-12T23:57:48
setter
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.nio.file.FileSystem; import java.nio.file.Files; import java.nio.file.Paths; import java.util.logging.Level; import javax.naming.spi.DirectoryManager; import javax.swing.Box.Filler; public class Main { static ...
not-set
2016-04-24T02:03:00
2016-04-24T02:03:00
Python
160
4,002
covering-the-stains
Covering the stains
There is a huge blanket on your bed but unfortunately it has **N** stains. You cover them using a single, rectangular silk cloth. The silk is expensive, which is why the rectangular piece needs to have the least area as possible. You love this blanket and decide to minimize the area covering the stains. You buy some ...
code
Given N 2D points, we need to remove K points optimally such that remaining (N-K) points could be covered by using a rectangular cloth with minimum area covered.
ai
2014-08-27T20:10:20
2022-08-31T08:14:49
# # Complete the 'coveringStains' function below. # # The function is expected to return an INTEGER. # The function accepts following parameters: # 1. INTEGER k # 2. 2D_INTEGER_ARRAY coordinates # def coveringStains(k, coordinates): # 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') first_multiple_input = input().rstrip().split() n = int(first_multiple_input[0]) k = int(first_multiple_input[1]) coordinates = [] for _ in range(n): coordinates.append(list(map(int, input().rstrip().split()))) ...
There is a huge blanket on your bed but unfortunately it has **N** stains. You cover them using a single, rectangular silk cloth. The silk is expensive, which is why the rectangular piece needs to have the least area as possible. You love this blanket and decide to minimize the area covering the stains. You buy some ...
0.5
["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 two integers **N** (1<=N<=1000) and **K** (0<=K<=N). Next follow **N** lines, one for each stain. Each line contains two integers in the form 'X Y', (0<=X,Y<100000), the coordinates of each stain into the blanket. Each pair of coordinates is unique.
Output a single integer. The remainder of the division by 1000000007 of the answer.
5 2 0 1 3 3 2 0 0 3 2 3
8
Hard
null
null
null
null
null
null
2014-08-27T20:10:35
2016-12-01T19:40:05
setter
###Java ```java import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { static int MOD = (int) 1e9 + 7; public static void main(String[] args) throws IOException { int N, K, mask; int stains[][]; int arr[]; int DP[][][]; int v...
not-set
2016-04-24T02:03:00
2016-07-23T15:14:36
Java
161
4,022
puzzle-and-pc
Puzzle and PC
Mom has to go to work and she doesn't want little Johnny to get bored. So she gives him a simple puzzle to solve. She also tells him that he can play a PC game only if he solves this problem. Johnny loves PC games and wants to solve this puzzle quickly. So he asks you for help. You are given a square _NxN_ board div...
code
Help little Johnny with the puzzle.
ai
2014-08-29T19:51:24
2016-09-01T16:34:30
null
null
null
Mom has to go to work and she doesn't want little Johnny to get bored. So she gives him a simple puzzle to solve. She also tells him that he can play a PC game only if he solves this problem. Johnny loves PC games and wants to solve this puzzle quickly. So he asks you for help. You are given a square _NxN_ board div...
0.5
["haskell","clojure","scala","erlang","sbcl","ocaml","fsharp","racket","elixir"]
null
null
null
null
Hard
null
null
null
null
null
null
2014-08-29T19:51:55
2016-05-12T23:57:44
tester
-- Translated by abhiranjan -- Haskell import Data.List main :: IO () main = getContents >>= mapM_ (putStrLn. unwords. map show). (\[[m], [r, c]] -> f (2^m) r c 1 1 []). map (map read.words). lines f :: Int -> Int -> Int -> Int -> Int -> [[Int]] -> [[Int]] f 1 _ _ _ _ arr = arr f...
not-set
2016-04-24T02:03:00
2016-04-24T02:03:00
Python
162
4,032
working-with-boxes
Working with boxes
A warehouse contains N boxes in a single line. The administrator of the warehouse wants to merge them to form a single stack. The workers can take 2 consecutive non-empty stacks of boxes i and i+1 (A single box is a stack as well) and merge them into a new stack at position i. This is counted as one operation. The ti...
code
Save money is your mission!!
ai
2014-08-31T07:51:28
2016-09-09T09:51:11
null
null
null
A warehouse contains N boxes in a single line. The administrator of the warehouse wants to merge them to form a single stack. The workers can take 2 consecutive non-empty stacks of boxes i and i+1 (A single box is a stack as well) and merge them into a new stack at position i. This is counted as one operation. The ti...
0.5
["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
null
null
null
null
null
null
2014-08-31T07:51:44
2016-12-05T00:09:48
setter
import java.io.BufferedReader; import java.io.File; import java.io.IOException; import java.io.InputStreamReader; public class Main { static int N;; static long T, L, R, M; static long arr[]; static long DP[][]; static long solve(int beg, i...
not-set
2016-04-24T02:03:01
2016-04-24T02:03:01
Python
163
4,032
working-with-boxes
Working with boxes
A warehouse contains N boxes in a single line. The administrator of the warehouse wants to merge them to form a single stack. The workers can take 2 consecutive non-empty stacks of boxes i and i+1 (A single box is a stack as well) and merge them into a new stack at position i. This is counted as one operation. The ti...
code
Save money is your mission!!
ai
2014-08-31T07:51:28
2016-09-09T09:51:11
null
null
null
A warehouse contains N boxes in a single line. The administrator of the warehouse wants to merge them to form a single stack. The workers can take 2 consecutive non-empty stacks of boxes i and i+1 (A single box is a stack as well) and merge them into a new stack at position i. This is counted as one operation. The ti...
0.5
["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
null
null
null
null
null
null
2014-08-31T07:51:44
2016-12-05T00:09:48
tester
#include <map> #include <set> #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 <iomani...
not-set
2016-04-24T02:03:01
2016-04-24T02:03:01
C++
164
4,036
the-brumpys-colony
The brumpy's colony
The scientists have discovered a new animal specie, the brumpies. This new specie is very funny and interesting. The scientists now are experimenting with their reproduction. This specie has asexual reproduction, which means they do not need a couple for the reproduction .T hey reproduce themselves by division. It has ...
code
You have been challenged by the colony!!
ai
2014-08-31T09:06:13
2016-09-09T09:51:13
null
null
null
The scientists have discovered a new animal specie, the brumpies. This new specie is very funny and interesting. The scientists now are experimenting with their reproduction. This specie has asexual reproduction, which means they do not need a couple for the reproduction .T hey reproduce themselves by division. It has ...
0.5
["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
null
null
null
null
null
null
2014-08-31T09:07:15
2016-05-12T23:57:39
setter
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.text.DecimalFormat; import java.text.DecimalFormatSymbols; public class Main { static int N, A; static int INITIAL=0; static double P[][]; static String cad[]; static double M[][]; static String Round(...
not-set
2016-04-24T02:03:01
2016-04-24T02:03:01
Python
165
4,048
snipers
Snipers
The National Security is in charge of the president's security. Tomorrow the president is going to speak to people. Today, everybody is crazy because there is a threat in progress. The agents believe there is a possibility of a sniper attack. The city consists of just one road with N contiguous buildings. The experts ...
code
Count the number of building!
ai
2014-08-31T21:30:18
2016-09-09T09:51:19
null
null
null
The National Security is in charge of the president's security. Tomorrow the president is going to speak to people. Today, everybody is crazy because there is a threat in progress. The agents believe there is a possibility of a sniper attack. The city consists of just one road with N contiguous buildings. The experts ...
0.5
["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
null
null
null
null
null
null
2014-08-31T21:33:45
2016-05-12T23:57:37
setter
import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; public class Main { static int N, D; static String cad[]; static int arr[],inc[]; ...
not-set
2016-04-24T02:03:01
2016-04-24T02:03:01
Python
166
4,050
city-x-and-the-cell-phone
City X and the cell phone companies
City X is an amazing city with N citizens. There are K cell phone companies at City X. The citizens use the cell phones in their normal lifes, so they are made contracts with the cell phone companies. Each citizen has made a contract with just one company. **Input specification** The input consists of just one line...
code
Find the odds for the people!
ai
2014-08-31T22:06:16
2016-09-09T09:51:20
null
null
null
City X is an amazing city with N citizens. There are K cell phone companies at City X. The citizens use the cell phones in their normal lifes, so they are made contracts with the cell phone companies. Each citizen has made a contract with just one company. **Input specification** The input consists of just one line...
0.5
["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
null
null
null
null
null
null
2014-08-31T22:06:39
2016-05-12T23:57:35
setter
import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.text.DecimalFormat; import java.text.DecimalFormatSymbols; import java.uti...
not-set
2016-04-24T02:03:01
2016-04-24T02:03:01
Python
167
4,052
playing-with-stacks
Playing with stacks
Our friend John has N consecutive lined up stacks Ai with height 1, 2, 3,..., N-1, N. John can do successive swaps among these stacks and reach some permutations. A permutation is considered beautiful if it matches a pattern. A pattern is sequence of N-1 numbers Pi where Pi = 0 if Ai < Ai+1, and Pi = 1 if Ai > Ai+1. ...
code
If you like permutations solve this challenge!
ai
2014-08-31T22:52:42
2016-09-09T09:51:20
null
null
null
Our friend John has N consecutive lined up stacks Ai with height 1, 2, 3,..., N-1, N. John can do successive swaps among these stacks and reach some permutations. A permutation is considered beautiful if it matches a pattern. A pattern is sequence of N-1 numbers Pi where Pi = 0 if Ai < Ai+1, and Pi = 1 if Ai > Ai+1. ...
0.5
["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
null
null
null
null
null
null
2014-08-31T22:54:34
2016-05-12T23:57:34
setter
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { static int N, K; static int P[]; static int DP[][]; static String cad[]; static int MOD = (int) 1e9 + 7; public static void main(String[] args) throws IOException { InputStreamReader sr = new In...
not-set
2016-04-24T02:03:01
2016-04-24T02:03:01
Python
168
4,059
lcs-deletion
LCS Deletion
Manasa is teaching Algorithms to Akhil. Akhil is pretty excited after knowing about the longest common subsequence. Akhil thinks that he can solve any problem related to the longest common subsequence and asks Manasa to give a harder problem. Manasa gives a problem to him as described below. <br><br> Given two list ea...
code
Help Manasa in LCS Deletion
ai
2014-09-01T17:04:31
2019-07-02T13:58:49
null
null
null
You are given two lists, each containg $N$ numbers. The numbers in both lists are a permuation of $1,2,3 \cdots N$. In an operation, Akhil will have to choose the longest common subsequence of both strings and delete that subsequence from the first list. The process is repeated as long as the first list has one or more...
0.5
["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
null
null
null
null
null
null
2014-09-01T17:05:23
2016-12-02T17:55:45
setter
#include<bits/stdc++.h> using namespace std; int a[510000]; int b[510000]; int arr[510000]; int MaxInSeq(int N) { int i; set<int> s; set<int>::iterator k; for (i=0; i<N; i++) { if (s.insert(arr[i]).second) { k...
not-set
2016-04-24T02:03:01
2016-04-24T02:03:01
C++
169
4,084
floor
Magical floor
Gargari is jealous that his friend Caisa won the game from the previous problem. He wants to prove that he is a genius. He has a n × n chessboard. Each cell of the chessboard has a number written on it. Gargari wants to place two bishops on the chessboard in such a way that there is no cell that is attacked by both of...
code
null
ai
2014-09-02T20:20:48
2016-09-09T09:51:30
null
null
null
Rajarshee has few friends. As you see, not all of them are beneficial. Some are selfish while some of them are too proud. However, he is leading his own life, not much problem to worry about yet. One thing you should know about him : he is very fond of adventure! However, as you all now, a peaceful life is enviable. ...
0.5
["c","cpp","java","java8","python3","ruby","python","cpp14"]
The first line contains a integer n (2 ≤ n ≤ 2000). The __ith__ line of the next n lines contains n integers where __jth__ integer denotes __a[i][j]__ (0 ≤ a[i][j] ≤ 10^9) where __a__ is the matrix representation of the grid.
Print the maximum total reward that you can achieve.
4 1 1 1 1 2 1 1 0 1 1 1 0 1 0 0 1
12
Hard
null
null
null
null
null
null
2014-09-02T20:29:25
2016-05-12T23:57:24
setter
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Solution { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int i,j,n = Integer.parseInt(br.readLine...
not-set
2016-04-24T02:03:02
2016-04-24T02:03:02
Python
170
4,094
mice-v2
Mice V2
__n__ mice are playing in the desert, when one of them notices some hawks flying in the sky. It alerts the other mice who now realize that the hawks are going to attack them very soon. They are scared and want to get inside holes to ensure their safety.<br> Mice and holes are placed on a straight line. There are __m__ ...
code
null
ai
2014-09-03T11:26:43
2016-09-09T09:51:34
null
null
null
__n__ mice are playing in the desert, when one of them notices some hawks flying in the sky. It alerts the other mice who now realize that the hawks are going to attack them very soon. They are scared and want to get inside holes to ensure their safety.<br> Mice and holes are placed on a straight line. There are __m__ ...
0.5
["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
null
null
null
null
null
null
2014-09-03T11:27:32
2016-12-01T18:09:42
setter
const ll N = (1<<17)+10; int a[N]; int b[N]; int n, m; bool check(int tt) { int i = 0; int j = 0; while(i < n && j < m) { if(abs(a[i]-b[j]) <= tt) { i ++; j ++; } else { ...
not-set
2016-04-24T02:03:02
2016-04-24T02:03:02
Unknown
171
4,101
gcd-sequence
GCD Sequence
Devu likes to play around the magic world of the mathematics. Today he got stuck at a problem given by his friend. Problem can be described in simple manner as given below. How many non decreasing sequences are there of length $K$, with the condition that numbers in sequence can take values only from $1,2,3, \cdots N...
code
Help Devu in finding number of sequences.
ai
2014-09-04T05:14:08
2022-09-02T09:54:47
# # Complete the 'solve' function below. # # The function is expected to return an 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...
How many non decreasing sequences are there of length $K$, with the condition that numbers in sequence can take values only from $1,2,3, \cdots N$ and gcd of all numbers in the sequence must be $1$. **Input Format** The first line contains an integer $T$ i.e. the number of test cases.<br> $T$ lines follow, each line...
0.5
["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
null
null
null
null
null
null
2014-09-04T05:17:07
2016-12-08T10:35:17
setter
###C++ ```cpp #include<bits/stdc++.h> using namespace std; #define ll long long int #define MOD 1000000007 ll mu[666666]; ll fact[1111111]; void pre(long long PP) { long long i,j; mu[1]=1; for(i=1;i<=PP;++i) { for(j=2*i;j<=PP;j+=i) { mu[j]-=mu[i]; } } return; } ll...
not-set
2016-04-24T02:03:02
2016-07-23T18:21:13
C++
172
2,676
euler050
Project Euler #50: Consecutive prime sum
<sub>This problem is a programming version of [Problem 50](https://projecteuler.net/problem=50) from [projecteuler.net](https://projecteuler.net/)</sub> The prime $41$, can be written as the sum of six consecutive primes: $$41 = 2 + 3 + 5 + 7 + 11 + 13$$ This is the longest sum of consecutive primes that adds to...
code
Consecutive prime sum
ai
2014-06-16T12:28:31
2022-09-02T10:36:47
null
null
null
<sub>This problem is a programming version of [Problem 50](https://projecteuler.net/problem=50) from [projecteuler.net](https://projecteuler.net/)</sub> The prime $41$, can be written as the sum of six consecutive primes: $$41 = 2 + 3 + 5 + 7 + 11 + 13$$ This is the longest sum of consecutive primes that adds to...
0.5
["ada","bash","c","clojure","coffeescript","cpp","cpp14","csharp","d","elixir","erlang","fortran","fsharp","go","groovy","haskell","java","java8","javascript","julia","kotlin","lolcode","lua","objectivec","ocaml","octave","pascal","perl","php","pypy3","python3","r","racket","ruby","rust","sbcl","scala","smalltalk","swi...
The first line contains an integer $T$ , i.e., number of test cases. Next $T$ lines will contain an integer $N$.
Print the values corresponding to each test case in a new line.
```raw 2 100 1000 ```
```raw 41 6 953 21 ```
Hard
null
null
null
null
null
null
2014-09-04T18:49:10
2016-05-12T23:57:12
tester
```cs using System; using System.Collections.Generic; using System.IO; class Solution { static int MAX = 10000000; static int[] is_prime = new int[MAX]; static List<int> primes = new List<int>(); // 664579 number of primes < MAX static List<long> psum = new List<long>(); static int lower_bound(lon...
not-set
2016-04-24T02:03:03
2016-04-24T02:03:03
Ruby
173
3,517
towers
Towers
One day John had to take care of his little nephew Jim. He was very busy, so he gave Jim a big bag full of building bricks. The bricks are of various heights: at most 15 different heights. For each height, the bag contains infinitely many bricks. <br> Now, Jim’s task is to build every possible tower of height $N$ fr...
code
How many minutes will it take Jim to build all possible towers?
ai
2014-08-08T08:04:28
2022-09-02T09:54:57
# # Complete the 'solve' function below. # # The function is expected to return an INTEGER. # The function accepts following parameters: # 1. LONG_INTEGER n # 2. INTEGER_ARRAY heights # def solve(n, heights): # 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()) heights_count = int(input().strip()) heights = list(map(int, input().rstrip().split())) result = solve(n, heights) fptr.write(str(result) + '\n') fptr.close()
One day John had to take care of his little nephew Jim. He was very busy, so he gave Jim a big bag full of building bricks. The bricks are of various heights: at most 15 different heights. For each height, the bag contains infinitely many bricks. <br> Now, Jim’s task is to build every possible tower of height $N$ fr...
0.535714
["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
null
null
null
null
null
null
2014-09-07T15:08:06
2016-12-07T22:23:36
setter
###C++ ```cpp --C++ #include <iostream> #include <cstdio> #include <string> #include <vector> #include <cmath> #include <algorithm> using namespace std; #define FOR(i,n) for(int (i)=0;(i)<(n);++(i)) typedef unsigned long long ull; typedef vector<int> vi; typedef vector<vector<ull> > matrix; const int MOD = 1000000...
not-set
2016-04-24T02:03:03
2016-07-23T18:41:05
C++
174
1,739
bcontest
Bit contest
**Please note that this is a team event, and your submission will be accepted only as a part of a team, even single member teams are allowed. Please click [here](https://www.hackerrank.com/auth/create_team/csindia) to register as a team, if you have NOT already registered.** Zodiac knights are taking part in a very sp...
code
Are you able to find out who should face Hades?
ai
2014-01-23T22:59:59
2016-09-09T09:38:37
null
null
null
**Please note that this is a team event, and your submission will be accepted only as a part of a team, even single member teams are allowed. Please click [here](https://www.hackerrank.com/auth/create_team/csindia) to register as a team, if you have NOT already registered.** Zodiac knights are taking part in a very sp...
0.5
["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
null
null
null
null
null
null
2014-09-12T16:39:32
2016-12-30T04:48:50
setter
//============================================================================ // Name : BGAME.cpp // Author : Shaka // Version : // Copyright : Your copyright notice // Description : Hello World in C++, Ansi-style //=========================================================...
not-set
2016-04-24T02:03:04
2016-04-24T02:03:04
C++
175
1,739
bcontest
Bit contest
**Please note that this is a team event, and your submission will be accepted only as a part of a team, even single member teams are allowed. Please click [here](https://www.hackerrank.com/auth/create_team/csindia) to register as a team, if you have NOT already registered.** Zodiac knights are taking part in a very sp...
code
Are you able to find out who should face Hades?
ai
2014-01-23T22:59:59
2016-09-09T09:38:37
null
null
null
**Please note that this is a team event, and your submission will be accepted only as a part of a team, even single member teams are allowed. Please click [here](https://www.hackerrank.com/auth/create_team/csindia) to register as a team, if you have NOT already registered.** Zodiac knights are taking part in a very sp...
0.5
["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
null
null
null
null
null
null
2014-09-12T16:39:32
2016-12-30T04:48:50
tester
#include<iostream> #include<cassert> using namespace std; int MAX = (1 << 16); int MASK = MAX - 1; int table[(1 << 16)]; void set_tab() { table[0] = 0; for(int i = 1; i < MAX; i++){ table[i] = table[i >> 1] + (i & 1); } } int bit_count(int n)...
not-set
2016-04-24T02:03:04
2016-04-24T02:03:04
C++
176
4,291
playing-with-histograms
Playing with Histograms
In statistics, a histogram is a graphical display of tabulated frequencies, shown as bars. It shows what proportion of cases fall into each of several categories. It is a polygon composed of a sequence of rectangles aligned at a common base line. In this problem all rectangles have a width of unit length, but their hei...
code
In statistics, a histogram is a graphical display of tabulated frequencies, shown as bars. It shows what proportion of cases fall into each of several categories. It is a polygon composed of a sequence of rectangles aligned at a common base line.
ai
2014-09-17T17:38:30
2016-09-09T09:52:36
null
null
null
In statistics, a histogram is a graphical display of tabulated frequencies, shown as bars. It shows what proportion of cases fall into each of several categories. It is a polygon composed of a sequence of rectangles aligned at a common base line. In this problem all rectangles have a width of unit length, but their hei...
0.5
["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
null
null
null
null
null
null
2014-09-17T17:53:08
2016-05-12T23:56:41
setter
#include <vector> #include <algorithm> #include <cstdio> #include <cassert> using namespace std; int perimeter(vector<int>); int ways(int); int fact(int); int main() { int n; while(1) { scanf("%d",&n); if(!n) break; vector<int> v(n); int i; for(i=0;i<n;++i) s...
not-set
2016-04-24T02:03:05
2016-04-24T02:03:05
C++
177
4,293
is-it-a-tree
Is It A Tree?
A tree is a well-known data structure that is either empty (null, void, nothing) or is a set of one or more nodes connected by directed edges between nodes satisfying the following properties. 1. There is exactly one node, called the root, to which no directed edges point. 2. Every node except the root has exactly ...
code
A tree is a well-known data structure. Determine if the given collection satisfies the definition of a tree or not. Simple?
ai
2014-09-17T18:20:06
2016-09-09T09:52:37
null
null
null
A tree is a well-known data structure that is either empty (null, void, nothing) or is a set of one or more nodes connected by directed edges between nodes satisfying the following properties. 1. There is exactly one node, called the root, to which no directed edges point. 2. Every node except the root has exactly ...
0.5
["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
null
null
null
null
null
null
2014-09-17T18:21:00
2016-05-12T23:56:41
setter
#include <stdio.h> /* The node numbers are not necessarily sequential and starting with 1. Keep a list of all the node numbers used so far in each case, and assign them indices from 0 to n-1 */ struct NodeNum { int num; NodeNum *next; }; NodeNum *node_num_list = 0; /* Keep a list of al...
not-set
2016-04-24T02:03:05
2016-04-24T02:03:05
C++
178
4,294
non-stop-travel
Non-Stop Travel
Fast Phil works the late shift and leaves his company's parking lot at precisely 2:00 AM every morning. His route home is by a straight road which has one or more traffic signals. Phil has always wondered if, given the locations and cycles of each of the traffic signals, are there velocities he can travel home without ...
code
Fast Phil works the late shift at his company. His route home is by a straight road which has one or more traffic signals. Phil has always wondered if there are velocities he can travel home without ever having to speed up or slow down. You are to write a program to satisfy his curiosity.
ai
2014-09-17T18:48:00
2016-09-09T09:52:38
null
null
null
Fast Phil works the late shift and leaves his company's parking lot at precisely 2:00 AM every morning. His route home is by a straight road which has one or more traffic signals. Phil has always wondered if, given the locations and cycles of each of the traffic signals, are there velocities he can travel home without ...
0.5
["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
null
null
null
null
null
null
2014-09-17T18:48:47
2016-05-12T23:56:40
setter
#include <stdio.h> #include <math.h> typedef struct { double dist; int g, y, r; /* actually, all you need is g + y, they are equivalent */ } Light; int LightIsGreenishYellow(Light *light, double time) { /* mod out any complete cycles for example, if the timings for gr...
not-set
2016-04-24T02:03:05
2016-04-24T02:03:05
Go
179
4,302
secret-message-pad
Secret Message Pad
Hearing stories from the Oracle that a programmer named Neo may possibly be "The One", Trinity risks going into the Matrix to observe Neo. While in the Matrix, her communications are intercepted and Trinity is almost caught by Agent Smith and two other agents. Safely back in the hovercraft Nebuchadnezzar, Trinity decid...
code
Hearing from the Oracle that a programmer named Neo may possibly be "The One", Trinity goes into the Matrix to observe him, but her communications are intercepted. Back in the hovercraft Nebuchadnezzar, Trinity decides to add another level of encryption to her communication using a "one-time pad".
ai
2014-09-18T09:46:05
2016-09-09T09:52:40
null
null
null
Hearing stories from the Oracle that a programmer named Neo may possibly be "The One", Trinity risks going into the Matrix to observe Neo. While in the Matrix, her communications are intercepted and Trinity is almost caught by Agent Smith and two other agents. Safely back in the hovercraft Nebuchadnezzar, Trinity decid...
0.5
["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
null
null
null
null
null
null
2014-09-18T09:48:35
2016-05-12T23:56:39
setter
#include <stdlib.h> #include <iostream.h> #include <assert.h> #include "apstring.h" #include "apstring.cpp" //----------------------------------------------------------------------- // main //----------------------------------------------------------------------- int main() { ...
not-set
2016-04-24T02:03:05
2016-04-24T02:03:05
C++
180
4,303
sarumans-secret-message
Saruman's Secret Message
Saruman occasionally sends top-secret messages to his orc commanders using a horde of bats. Because each bat can only carry a limited amount of weight, Saruman breaks up each message into many smaller fragments, with each bat carrying a single message fragment. To reduce the possibility of detection in case one or more...
code
Saruman sends top-secret messages to his orc commanders using a horde of bats. He breaks up each message into many fragments, with each bat carrying a single message fragment. To decode the message, the recipient must combine the different message fragments, using the overlapping regions as hints.
ai
2014-09-18T09:56:49
2016-09-09T09:52:41
null
null
null
Saruman occasionally sends top-secret messages to his orc commanders using a horde of bats. Because each bat can only carry a limited amount of weight, Saruman breaks up each message into many smaller fragments, with each bat carrying a single message fragment. To reduce the possibility of detection in case one or more...
0.4
["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
null
null
null
null
null
null
2014-09-18T09:57:09
2016-05-12T23:56:39
setter
#include <stdlib.h> #include <iostream.h> #include <assert.h> // Uncomment the following lines if using APCS classes // #include "apvector.h" // #include "apmatrix.h" // #include "apstack.h" // #include "apqueue.h" #include "apstring.cpp" //------------------------------------...
not-set
2016-04-24T02:03:05
2016-04-24T02:03:05
C++
181
2,591
strongly-connected-digraphs
Strongly Connected Digraphs
Count the number of [labeled strongly connected digraphs](http://en.wikipedia.org/wiki/Directed_graph) with the given number of vertices. **Input Format** The first line contains $T$, the number of queries. Following are $T$ lines. Each line contains one integer $N$, denoting the number of vertices. **Output ...
code
Count the number of labeled strongly connected digraphs with the given number of vertices.
ai
2014-06-10T12:27:33
2022-09-02T09:55:01
null
null
null
Count the number of [labeled strongly connected digraphs](http://en.wikipedia.org/wiki/Directed_graph) with the given number of vertices. **Input Format** The first line contains $T$, the number of queries. Following are $T$ lines. Each line contains one integer $N$, denoting the number of vertices. **Output ...
0.545455
["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
null
null
null
null
null
null
2014-09-18T10:14:19
2016-12-24T11:27:40
tester
###Python 2 ```python ''' Use the ff: http://www.emis.de/journals/AUSM/C5-1/math51-5.pdf http://people.brandeis.edu/~gessel/homepage/students/ostroffthesis.pdf (Beware, they both have mistakes!) ''' mod = 10**9+7 MAX = 1001 C = [[0]*MAX for i in xrange(MAX)] e = [0]*MAX s = [0]*MAX for n in xrange(MAX): for r...
not-set
2016-04-24T02:03:05
2016-07-23T18:47:35
Python
182
4,305
go-back-home
Go Back Home
Corporal Klinger is a member of the 4077th Mobile Army Surgical Hospital in the Korean War; and he will do just about anything to get out. The U.S. Army has made an offer for a lottery that will choose some number of lucky people (X) to return to the states for a recruiting tour. Klinger needs your help getting o...
code
Corporal Klinger is a member of the 4077th Mobile Army Surgical Hospital in the Korean War and will do just about anything to get out. The U.S. Army has made an offer for a lottery to choose some number lucky people to return to the states for a recruiting tour. Klinger needs your help getting out.
ai
2014-09-18T10:15:08
2016-09-09T09:52:42
null
null
null
Corporal Klinger is a member of the 4077th Mobile Army Surgical Hospital in the Korean War; and he will do just about anything to get out. The U.S. Army has made an offer for a lottery that will choose some number of lucky people (X) to return to the states for a recruiting tour. Klinger needs your help getting o...
0.5
["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
null
null
null
null
null
null
2014-09-18T10:15:20
2016-05-12T23:56:37
setter
#include <stdio.h> int cards[20], participants, lucky, sim_count; FILE *inp, *outp; void find_positions(void) { int positions[50], i, j, k, num_left; for (i=0; i<50; i++) { positions[i] = 1; } for (i = 0, num_left = participants; num_left > lucky; i++) { k = 0; for (j = 0; (j < participan...
not-set
2016-04-24T02:03:05
2016-04-24T02:03:05
C++
183
4,307
coconuts-1
Coconuts 1
The short story titled Coconuts, by Ben Ames Williams, tells about five men and a monkey who were shipwrecked on an island. They spent the first night gathering coconuts. During the night, one man woke up and decided to take his share of the coconuts. He divided them into five piles. One coconut was left over so he gav...
code
Based on a short story titled 'Coconuts', by Ben Ames Williams,which tells about five men and a monkey who were shipwrecked on an island.
ai
2014-09-18T10:22:08
2016-09-09T09:52:42
null
null
null
The short story titled Coconuts, by Ben Ames Williams, tells about five men and a monkey who were shipwrecked on an island. They spent the first night gathering coconuts. During the night, one man woke up and decided to take his share of the coconuts. He divided them into five piles. One coconut was left over so he gav...
0.5
["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
null
null
null
null
null
null
2014-09-18T10:22:24
2016-05-12T23:56:37
setter
#include <stdio.h> /* return 1 if this number of coconuts can be divided up properly between this number of people */ int SplitCoco(long n_coco, long n_people) { long i; for (i=0; i<n_people; i++) { /* check that the coconuts divide by the number of people plus on...
not-set
2016-04-24T02:03:05
2016-04-24T02:03:05
C++
184
4,310
character-alternations
Character Alternations
On the long long road to Mordor, Sam and Frodo get to talking... **Sam:** “Mr. Frodo, I am quite exasperated with our situation.” **Frodo:** “Sam, that is an interesting choice of words. Note that in the word ‘exasperated’ the letters ‘e’ and ‘a’ alternate 5 times.” exasperated ↑ ↑ ↑ ↑ ↑ **Sam:** “Dear...
code
Frodo loves finding alternating patterns of letters in words. An alternation is when two distinct characters (letters, digits, or punctuation) alternate at least three times in the word from left to right. The objective of this problem is to find the length of the longest alternation in a word.
ai
2014-09-18T12:56:21
2016-09-09T09:52:43
null
null
null
On the long long road to Mordor, Sam and Frodo get to talking... **Sam:** “Mr. Frodo, I am quite exasperated with our situation.” **Frodo:** “Sam, that is an interesting choice of words. Note that in the word ‘exasperated’ the letters ‘e’ and ‘a’ alternate 5 times.” exasperated ↑ ↑ ↑ ↑ ↑ **Sam:** “Dear...
0.5
["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
null
null
null
null
null
null
2014-09-18T12:56:58
2016-05-12T23:56:36
setter
import java.io.*; import java.util.StringTokenizer; /** * The program inputs a string and outputs the maximum number of * alternations of two distinct characters in the string. For example, * the string "international" has 5 alternations involving the letters * n and t: * * i n t e r n a t ...
not-set
2016-04-24T02:03:05
2016-04-24T02:03:05
Python
185
4,311
the-dangerous-seven
The Dangerous Seven
Super Mario is studying how to use a mysterious Power Square. The Power Square is n×n with integer values between 0 and n^2 − 1. A number y is a neighbor of another number x in the Power Square if y is directly above or below x, or directly to the left or right of x. Rosalina asks Super Mario to find all the numbers ...
code
Super Mario is studying how to use a mysterious Power Square. The Power Square is n×n with integer values between 0 and n^2 − 1. Rosalina asks Super Mario to find all the numbers in the Power Square that are neighbors of the number 7, "Because seven ate nine!"
ai
2014-09-18T13:41:19
2016-09-09T09:52:43
null
null
null
Super Mario is studying how to use a mysterious Power Square. The Power Square is n×n with integer values between 0 and n^2 − 1. A number y is a neighbor of another number x in the Power Square if y is directly above or below x, or directly to the left or right of x. Rosalina asks Super Mario to find all the numbers ...
0.5
["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
null
null
null
null
null
null
2014-09-18T13:42:33
2016-05-12T23:56:36
setter
import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.PrintStream; import java.util.Random; import java.util.Scanner; public class Puzzle { static final int maxPuzzle = 1000; // size of puzzle static int puzzleSize = 1; // size of puzzle static int puzzleTiles...
not-set
2016-04-24T02:03:05
2016-04-24T02:03:05
Python
186
4,316
pyramid-trap
Pyramid Trap
A team called Archaeologists of the Central Mountains (ACM) is interested in the famous Helmut's Pyramid (HP) in Egypt. In the Pyramid, there is a Sarcophagus of Umbertiti Nefrites (SUN). According to the legend, the Sarcophagus contains (besides the pharaoh's body, of course) a priceless treasure: air-tickets to Orlan...
code
A team called Archaeologists of the Central Mountains (ACM) is interested in the famous Helmut's Pyramid (HP) in Egypt. They have a very powerful notebook to help them finish their task. Your task is to provide the software for them.
ai
2014-09-18T16:47:04
2016-09-09T09:52:44
null
null
null
A team called Archaeologists of the Central Mountains (ACM) is interested in the famous Helmut's Pyramid (HP) in Egypt. In the Pyramid, there is a Sarcophagus of Umbertiti Nefrites (SUN). According to the legend, the Sarcophagus contains (besides the pharaoh's body, of course) a priceless treasure: air-tickets to Orlan...
0.5
["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
null
null
null
null
null
null
2014-09-18T16:50:04
2016-05-12T23:56:35
setter
#define TEXT_YES "Escape is possible.\n" #define TEXT_NO "Box cannot be dropped.\n" #include <stdio.h> #include <math.h> int main() { /* number of tasks */ unsigned int N; /* sides of rectangles */ unsigned int A, B, C, D; /* diagonals */ double X, Y; /* distances of intersection */ doub...
not-set
2016-04-24T02:03:06
2016-04-24T02:03:06
C++
187
4,320
bulk-mailing
Bulk Mailing
An organization that wishes to make a large mailing can save postage by following U.S. Postal Service rules for a bulk mailing. Letters in zip code order are bundled into packets of 10-15 letters each. Bundles may consist of letters in which all 5 digits of zip code are the same (5-digit bundles), or they may consist ...
code
An organization that wishes to make a large mailing can save postage by following U.S. Postal Service rules for a bulk mailing. You are to write a program to read a data set and sort letters into bundles.
ai
2014-09-18T17:24:55
2016-09-09T09:52:46
null
null
null
An organization that wishes to make a large mailing can save postage by following U.S. Postal Service rules for a bulk mailing. Letters in zip code order are bundled into packets of 10-15 letters each. Bundles may consist of letters in which all 5 digits of zip code are the same (5-digit bundles), or they may consist ...
0.5
["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
null
null
null
null
null
null
2014-09-18T17:25:10
2016-05-12T23:56:35
setter
//This is sample code when data is read from an input file until end of file /*----------------------------- bulk.c ---------------------------------- Bulk Mail Read zip codes, validate and sort them, omitting bad codes. Combine into bundles of 10-20 letters each. Create bundles by matching all 5 digits ...
not-set
2016-04-24T02:03:06
2016-04-24T02:03:06
C++
188
4,322
rainbow-ride
Rainbow Ride
Mr.Raju and his extended family are on vacation in Chennai. They visit MGM and see the Rainbow ride. They want to enjoy the ride. However, there are some problems. Each person in the family likes some other people in the family. Each person insists that he or she will go on the ride only if all the people whom that p...
code
Mr.Raju and his extended family are on vacation in Chennai. They visit MGM and see the Rainbow ride. They want to enjoy the ride. However, there are some problems. You have been roped in to solve their dilemma.
ai
2014-09-18T17:52:22
2016-09-09T09:52:47
null
null
null
Mr.Raju and his extended family are on vacation in Chennai. They visit MGM and see the Rainbow ride. They want to enjoy the ride. However, there are some problems. Each person in the family likes some other people in the family. Each person insists that he or she will go on the ride only if all the people whom that p...
0.5
["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
null
null
null
null
null
null
2014-09-18T17:52:34
2016-05-12T23:56:35
setter
#include <vector> #include <list> #include <map> #include <set> #include <deque> #include <queue> #include <stack> #include <bitset> #include <algorithm> #include <functional> #include <numeric> #include <utility> #include <sstream> #include <iostream> #include <iomanip> #include <cstdio> #include <cma...
not-set
2016-04-24T02:03:06
2016-04-24T02:03:06
C++
189
4,325
taming-a-t-rex
Taming a T-Rex
Although evolution theory suggests that mammals started to dominate this world only after the mass extinction of the dinosaurs, there are some people who say man and dinosaurs may have co-existed for some time. Some argue that man even tamed and used some of these animals like the Flintstones. Shankar is such a believe...
code
Although evolution theory suggests that mammals started to dominate this world only after the mass extinction of the dinosaurs, there are some people who say man and dinosaurs may have co-existed for some time. You need to help one such believer.
ai
2014-09-18T18:16:28
2016-09-09T09:52:48
null
null
null
Although evolution theory suggests that mammals started to dominate this world only after the mass extinction of the dinosaurs, there are some people who say man and dinosaurs may have co-existed for some time. Some argue that man even tamed and used some of these animals like the Flintstones. Shankar is such a believe...
0.5
["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
null
null
null
null
null
null
2014-09-18T18:16:49
2016-05-12T23:56:34
setter
#include <vector> #include <list> #include <map> #include <set> #include <deque> #include <queue> #include <stack> #include <bitset> #include <algorithm> #include <functional> #include <numeric> #include <utility> #include <sstream> #include <iostream> #include <iomanip> #include <cstdio> #include <...
not-set
2016-04-24T02:03:06
2016-04-24T02:03:06
C++
190
4,327
factorial-frequencies
Factorial Frequencies
In an attempt to bolster her sagging palm-reading business, Madam Phoenix has decided to offer several numerological treats to her customers. She has been able to convince them that the frequency of occurrence of the digits in the decimal representation of factorials bear witness to their futures. Unlike palm-reading, ...
code
In an attempt to bolster her palm-reading business, Madam Phoenix has decided to offer several numerological treats to her customers. She has employed you to help her.
ai
2014-09-18T18:48:34
2016-09-09T09:52:48
null
null
null
In an attempt to bolster her sagging palm-reading business, Madam Phoenix has decided to offer several numerological treats to her customers. She has been able to convince them that the frequency of occurrence of the digits in the decimal representation of factorials bear witness to their futures. Unlike palm-reading, ...
0.5
["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
null
null
null
null
null
null
2014-09-18T18:48:46
2016-05-12T23:56:34
setter
#include <stdio.h> int main() { int digits[1000]; int digit_counts[10] = {0}; int n_digits, digit_no; int i, j; int n, overflow, prod; scanf("%d", &n); while (n) { digits[0] = 1; n_digits = 1; for (i=2; i<=n; i++) { overflow = 0; for (j=0; j<n_digits || ...
not-set
2016-04-24T02:03:06
2016-04-24T02:03:06
C++
191
4,335
galactic-import
Galactic Import
With the introduction of the new ThrustoZoom gigadimensional drive, it has become possible for HyperCommodities, the import/export conglomerate from New Jersey, to begin trading with even the most remote galaxies in the universe. HyperCommodities wants to import goods from some of the galaxies in the Plural Z sector. P...
code
With the introduction of the new ThrustoZoom gigadimensional drive, it has become possible for HyperCommodities, the import/export conglomerate from New Jersey, to begin trading with even the most remote galaxies in the universe. HyperCommodities wants your help for this.
ai
2014-09-19T04:22:14
2016-09-09T09:52:51
null
null
null
With the introduction of the new ThrustoZoom gigadimensional drive, it has become possible for HyperCommodities, the import/export conglomerate from New Jersey, to begin trading with even the most remote galaxies in the universe. HyperCommodities wants to import goods from some of the galaxies in the Plural Z sector. P...
0.5
["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
null
null
null
null
null
null
2014-09-19T04:22:51
2016-05-12T23:56:33
setter
//When the input is from a file and the output is to a file. (Logic remains the same.) #include <stdio.h> #include <string.h> #include <math.h> #define INPUT_FILE_NAME "import.in" #define OUTPUT_FILE_NAME "import.out" #define N 27 #define INFINITY 100 #define EARTH 26 int distance[N][N]; d...
not-set
2016-04-24T02:03:06
2016-04-24T02:03:06
C++
192
4,339
letter-sequence-analysis
Letter Sequence Analysis
Cryptographic analysis makes extensive use of the frequency with which letters and letter sequences occur in a language. If an encrypted text is known to be in english, for example, a great deal can be learned from the fact that the letters E, L, N, R, S, and T are the most common ones used in written english. Even mor...
code
Cryptographic analysis makes extensive use of the frequency with which letters and letter sequences occur in a language. You are required to perform one such analysis.
ai
2014-09-19T06:45:57
2016-09-09T09:52:53
null
null
null
Cryptographic analysis makes extensive use of the frequency with which letters and letter sequences occur in a language. If an encrypted text is known to be in english, for example, a great deal can be learned from the fact that the letters E, L, N, R, S, and T are the most common ones used in written english. Even mor...
0.5
["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
null
null
null
null
null
null
2014-09-19T06:48:08
2016-05-12T23:56:32
setter
//When input and output are from and to files. (Logic remains the same.) #include <ctype.h> #include <fstream.h> #include <string.h> ofstream out = "sequence.out"; struct node { char seq[6]; int freq; node* next; }; node* list = NULL; char sequence[6]; int seqlen; int isaseq() { ...
not-set
2016-04-24T02:03:06
2016-04-24T02:03:06
C++
193
4,342
basically-speaking
Basically Speaking
The Really Neato Calculator Company, Inc. has recently hired your team to help design their Super Neato Model I calculator. As a computer scientist you suggested to the company that it would be neato if this new calculator could convert among number bases. The company thought this was a stupendous idea and has asked yo...
code
The Really Neato Calculator Company, Inc. has recently hired your team to help design their Super Neato Model I calculator. As a computer scientist you suggested to the company that it would be 'neato' if this new calculator could convert among number bases.
ai
2014-09-19T07:13:37
2016-09-09T09:52:54
null
null
null
The Really Neato Calculator Company, Inc. has recently hired your team to help design their Super Neato Model I calculator. As a computer scientist you suggested to the company that it would be neato if this new calculator could convert among number bases. The company thought this was a stupendous idea and has asked yo...
0.5
["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
null
null
null
null
null
null
2014-09-19T07:15:54
2016-05-12T23:56:31
setter
//When the input is taken from a data file and output is printed to a data file. #include <iostream.h> #include <iomanip.h> #include <fstream.h> #include <string.h> const int A_10 = 55; const int ZERO = 48; const int ASIZE = 8; const int WSIZE = 7; const int SIZE_1 = 6; long int power (int, int); long ...
not-set
2016-04-24T02:03:06
2016-04-24T02:03:06
C++
194
4,344
easier-done-than-said
Easier Done than Said?
Password security is a tricky thing. Users prefer simple passwords that are easy to remember (like buddy), but such passwords are often insecure. Some sites use random computer-generated passwords (like xvtpzyo), but users have a hard time remembering them and sometimes leave them written on notes stuck to their comput...
code
Password security is a tricky thing. FnordCom is developing a password generator. You work in the quality control department, and it's your job to test the generator and make sure that the passwords are acceptable.
ai
2014-09-19T07:42:30
2016-09-09T09:52:55
null
null
null
Password security is a tricky thing. Users prefer simple passwords that are easy to remember (like buddy), but such passwords are often insecure. Some sites use random computer-generated passwords (like xvtpzyo), but users have a hard time remembering them and sometimes leave them written on notes stuck to their comput...
0.5
["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
null
null
null
null
null
null
2014-09-19T07:42:45
2016-05-12T23:56:31
setter
#include <stdio.h> #include <stdlib.h> #include <string.h> FILE *in; FILE *out; char word[256]; int n; int is_vowel(int ch) { return ch=='a' || ch=='e' || ch=='i' || ch=='o' || ch=='u'; } int contains_vowel(void) { int i; for (i = 0; i < n; ++i) { if (is_vowel(word[i])) ...
not-set
2016-04-24T02:03:06
2016-04-24T02:03:06
C++
195
4,346
instruens-fabulam
Instruens Fabulam
*Instruens Fabulam means drawing a chart (or table) in Latin. That's what you will do for this problem.* The input consists of one or more table descriptions, followed by a line whose first character is `'*'`, which signals the end of the input. Each description begins with a header line containing one or more charact...
code
'Instruens Fabulam' means drawing a chart (or table) in Latin. That's what you will do for this problem.
ai
2014-09-19T08:10:57
2016-09-09T09:52:55
null
null
null
*Instruens Fabulam means drawing a chart (or table) in Latin. That's what you will do for this problem.* The input consists of one or more table descriptions, followed by a line whose first character is `'*'`, which signals the end of the input. Each description begins with a header line containing one or more charact...
0.5
["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
null
null
null
null
null
null
2014-09-19T08:11:14
2016-05-12T23:56:31
setter
#include <stdio.h> #include <stdlib.h> #include <string.h> #define LEFT '<' #define RIGHT '>' #define CENTER '=' enum {MAX_ROWS = 21, MAX_COLS = 19}; enum {HEADER, ROW, END}; FILE *in; FILE *out; int rows; /* number of rows in the table */ int columns; ...
not-set
2016-04-24T02:03:06
2016-04-24T02:03:06
C++
196
4,355
mapping-the-swaps
Mapping the Swaps
Sorting an array can be done by swapping certain pairs of adjacent entries in the array. This is the fundamental technique used in the well-known bubble sort. If we list the identities of the pairs to be swapped, in the sequence they are to be swapped, we obtain what might be called a swap map. For example, suppose we ...
code
Sorting an array can be done by swapping certain pairs of adjacent entries in the array. But, how many swap maps of minimum size will place a given array in order? That is the question you are to answer in this problem.
ai
2014-09-19T15:42:43
2016-09-09T09:53:00
null
null
null
Sorting an array can be done by swapping certain pairs of adjacent entries in the array. This is the fundamental technique used in the well-known bubble sort. If we list the identities of the pairs to be swapped, in the sequence they are to be swapped, we obtain what might be called a swap map. For example, suppose we ...
0.5
["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
null
null
null
null
null
null
2014-09-19T15:43:15
2016-05-12T23:56:29
setter
#include <stdio.h> #include <stdlib.h> void swap(int *a, int i) { int t; t = a[i]; a[i] = a[i+1]; a[i+1] = t; } int bub_srt(int n, int b[]) { int *a, ns=0, i, j; a = (int*)malloc(sizeof(int) * n); for (i=0; i<n; i++) a[i] = b[i]; for (i=n-1; i>0; i--) { for (j=0; j<i; j...
not-set
2016-04-24T02:03:06
2016-04-24T02:03:06
C++
197
4,356
concurrency-check
Concurrency Check
It is important in distributed computer systems to identify those events (at identifiable points in time) that are concurrent, or not related to each other in time. A group of concurrent events may sometimes attempt to simultaneously use the same resource, and this could cause problems. Events that are not concurrent ...
code
In this problem you will be supplied with lists of sequential events for an arbitrary number of computations, and the identification of an arbitrary number of messages sent between these computations. Your task is to identify those pairs of events that are concurrent.
ai
2014-09-19T15:58:54
2016-09-09T09:53:00
null
null
null
It is important in distributed computer systems to identify those events (at identifiable points in time) that are concurrent, or not related to each other in time. A group of concurrent events may sometimes attempt to simultaneously use the same resource, and this could cause problems. Events that are not concurrent ...
0.5
["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
null
null
null
null
null
null
2014-09-19T15:59:07
2016-05-12T23:56:29
setter
#include <stdio.h> #include <stdlib.h> #include <string.h> typedef struct Node { int idx; char *name; struct Node *next, *child, *sibling; } Node; Node *head=0, *tail=0; int n_nodes = 0; Node *FindNode(char *str) { Node *p; p = head; while (p && strcmp(p->name, str)) p = p->next; ...
not-set
2016-04-24T02:03:06
2016-04-24T02:03:06
C++
198
4,357
roman-digititis
Roman Digititis
Many persons are familiar with the Roman numerals for relatively small numbers. The symbols "i", "v", "x", "l", and "c" represent the decimal values 1, 5, 10, 50, and 100 respectively. To represent other values, these symbols, and multiples where necessary, are concatenated, with the smaller-valued symbols written furt...
code
The preface of many books has pages numbered with Roman numerals, starting with "i" for the first page of the preface, and continuing. Assume books with pages having 100 or fewer pages of preface. How many "i", "v", "x", "l", and "c" characters are required to number the pages in the preface?
ai
2014-09-19T16:20:27
2016-09-09T09:53:01
null
null
null
Many persons are familiar with the Roman numerals for relatively small numbers. The symbols "i", "v", "x", "l", and "c" represent the decimal values 1, 5, 10, 50, and 100 respectively. To represent other values, these symbols, and multiples where necessary, are concatenated, with the smaller-valued symbols written furt...
0.5
["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
null
null
null
null
null
null
2014-09-19T16:20:35
2016-05-12T23:56:29
setter
#include <stdio.h> #include<stdlib.h> int ni, nv, nx, nl, nc; void units(int n) { switch(n) { case 0: break; case 1: ni += 1; break; case 2: ni += 2; break; case 3: ni += 3; break; case 4: ni += 1; nv += 1; break; case 5: nv += 1; break; case 6: ni += 1; nv += 1; break; case 7: ni += 2; nv += 1; brea...
not-set
2016-04-24T02:03:06
2016-04-24T02:03:06
C++
199
4,358
master-mind-hints
Master-Mind Hints
MasterMind is a game for two players. One of them, Designer, selects a secret code. The other, Breaker, tries to break it. A code is no more than a row of colored dots. At the beginning of a game, the players agree upon the length N that a code must have and upon the colors that may occur in a code. In order to break ...
code
MasterMind is a game for two players. In this problem you will be given a secret code s1...sn and a guess g1...gn, and are to determine the hint.
ai
2014-09-19T16:31:43
2016-09-09T09:53:01
null
null
null
MasterMind is a game for two players. One of them, Designer, selects a secret code. The other, Breaker, tries to break it. A code is no more than a row of colored dots. At the beginning of a game, the players agree upon the length N that a code must have and upon the colors that may occur in a code. In order to break ...
0.5
["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
null
null
null
null
null
null
2014-09-19T16:31:50
2016-05-12T23:56:28
setter
#include <stdio.h> #include<stdlib.h> #define MAXN 1000 int code[MAXN]; /* the current secret code */ char match[MAXN]; /* match type (w/respect to code) */ int guess[MAXN]; /* the current guess */ int hint[2]; /* the hint */ int n; /* length of the code */ void generate_hint() { int i, j; ...
not-set
2016-04-24T02:03:06
2016-04-24T02:03:06
C++