dataset_name stringclasses 1 value | src_lang stringclasses 1 value | entry_func stringclasses 1 value | prefix stringlengths 65 1.25k ⌀ | import_str listlengths 0 1 | suffix null | demos listlengths 0 0 | data_id stringlengths 9 106 | doc_string stringclasses 1 value | tgt_lang stringclasses 1 value | compare_func listlengths 0 0 | solution stringlengths 40 1.94k | task_name stringclasses 1 value | test_cases listlengths 10 11 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int k, string s1, string s2 ) {
int n = s1 . length ( );
int m = s2 . length ( );
int lcs [ n + 1 ] [ m + 1 ];
int cnt [ n + 1 ] [ m + 1 ];
memset ( lcs, 0, sizeof ( lcs ) );
memset ( cnt, 0, sizeof ( cnt ) );
for ( int i = 1;
i <= n;
i ++ ) {
for ( int j = 1;
j <= m;
j ++ ) {
lcs [ i ] [ j ] = max ( lcs [ i - 1 ] [ j ], lcs [ i ] [ j - 1 ] );
if ( s1 [ i - 1 ] == s2 [ j - 1 ] ) cnt [ i ] [ j ] = cnt [ i - 1 ] [ j - 1 ] + 1;
if ( cnt [ i ] [ j ] >= k ) {
for ( int a = k;
a <= cnt [ i ] [ j ];
a ++ ) lcs [ i ] [ j ] = max ( lcs [ i ] [ j ], lcs [ i - a ] [ j - a ] + a );
}
}
}
return lcs [ n ] [ m ];
}
| [] | null | [] | LCS_FORMED_CONSECUTIVE_SEGMENTS_LEAST_LENGTH_K | python | [] | def f_gold ( k , s1 , s2 ) :
n = len ( s1 )
m = len ( s2 )
lcs = [ [ 0 for x in range ( m + 1 ) ] for y in range ( n + 1 ) ]
cnt = [ [ 0 for x in range ( m + 1 ) ] for y in range ( n + 1 ) ]
for i in range ( 1 , n + 1 ) :
for j in range ( 1 , m + 1 ) :
lcs [ i ] [ j ] = max ( lcs [ i - 1 ] [ j ] , lcs [ i ] [ j - 1 ] )
if ( s1 [ i - 1 ] == s2 [ j - 1 ] ) :
cnt [ i ] [ j ] = cnt [ i - 1 ] [ j - 1 ] + 1 ;
if ( cnt [ i ] [ j ] >= k ) :
for a in range ( k , cnt [ i ] [ j ] + 1 ) :
lcs [ i ] [ j ] = max ( lcs [ i ] [ j ] , lcs [ i - a ] [ j - a ] + a )
return lcs [ n ] [ m ]
| code_translation | [
[
"4, 'aggayxysdfa', 'aggajxaaasdfa'",
"8"
],
[
"2, '55571659965107', '390286654154'",
"2"
],
[
"3, '01011011100', '0000110001000'",
"7"
],
[
"5, 'aggasdfa', 'aggajasdfaxy'",
"5"
],
[
"2, '5710246551', '79032504084062'",
"0"
],
[
"3, '0100010', '101000... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( string str ) {
int result = 0;
int n = str . length ( );
for ( int i = 0;
i < n;
i ++ ) for ( int j = i + 1;
j < n;
j ++ ) if ( abs ( str [ i ] - str [ j ] ) == abs ( i - j ) ) result ++;
return result;
}
| [] | null | [] | COUNT_CHARACTERS_STRING_DISTANCE_ENGLISH_ALPHABETS | python | [] | def f_gold ( str1 ) :
result = 0 ;
n = len ( str1 )
for i in range ( 0 , n ) :
for j in range ( i + 1 , n ) :
if ( abs ( ord ( str1 [ i ] ) - ord ( str1 [ j ] ) ) == abs ( i - j ) ) :
result += 1 ;
return result ;
| code_translation | [
[
"'smnKL'",
"2"
],
[
"'270083'",
"3"
],
[
"'0'",
"0"
],
[
"'kcZdsz'",
"0"
],
[
"'483544224'",
"7"
],
[
"'000011'",
"1"
],
[
"'WysGCirMwKBzP'",
"3"
],
[
"'3366'",
"1"
],
[
"'110'",
"1"
],
[
"'NlaMkpCjUgg'... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
bool f_gold ( int n, int i = 2 ) {
if ( n <= 2 ) return ( n == 2 ) ? true : false;
if ( n % i == 0 ) return false;
if ( i * i > n ) return true;
return f_gold ( n, i + 1 );
}
| [] | null | [] | COUNT_DISTINCT_OCCURRENCES_AS_A_SUBSEQUENCE | python | [] | def f_gold ( S , T ) :
m = len ( T )
n = len ( S )
if m > n :
return 0
mat = [ [ 0 for _ in range ( n + 1 ) ] for __ in range ( m + 1 ) ]
for i in range ( 1 , m + 1 ) :
mat [ i ] [ 0 ] = 0
for j in range ( n + 1 ) :
mat [ 0 ] [ j ] = 1
for i in range ( 1 , m + 1 ) :
for j in range ( 1 , n + 1 ) :
if T [ i - 1 ] != S [ j - 1 ] :
mat [ i ] [ j ] = mat [ i ] [ j - 1 ]
else :
mat [ i ] [ j ] = ( mat [ i ] [ j - 1 ] + mat [ i - 1 ] [ j - 1 ] )
return mat [ m ] [ n ]
| code_translation | [
[
"'banana', 'ban'",
"3"
],
[
"'49597223', '42'",
"2"
],
[
"'1000010000011', '010'",
"20"
],
[
"'BTlzufK', 'EpsVuzP lf'",
"0"
],
[
"'3474007', '370'",
"2"
],
[
"'0010', '00000'",
"0"
],
[
"'dKHhoTD', 'doT'",
"1"
],
[
"'912325972... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( string S, string T ) {
int m = T . length ( ), n = S . length ( );
if ( m > n ) return 0;
int mat [ m + 1 ] [ n + 1 ];
for ( int i = 1;
i <= m;
i ++ ) mat [ i ] [ 0 ] = 0;
for ( int j = 0;
j <= n;
j ++ ) mat [ 0 ] [ j ] = 1;
for ( int i = 1;
i <= m;
i ++ ) {
for ( int j = 1;
j <= n;
j ++ ) {
if ( T [ i - 1 ] != S [ j - 1 ] ) mat [ i ] [ j ] = mat [ i ] [ j - 1 ];
else mat [ i ] [ j ] = mat [ i ] [ j - 1 ] + mat [ i - 1 ] [ j - 1 ];
}
}
return mat [ m ] [ n ];
}
| [] | null | [] | CHECK_WHETHER_TWO_STRINGS_ARE_ANAGRAM_OF_EACH_OTHER | python | [] | def f_gold ( str1 , str2 ) :
n1 = len ( str1 )
n2 = len ( str2 )
if n1 != n2 :
return 0
str1 = sorted ( str1 )
str2 = sorted ( str2 )
for i in range ( 0 , n1 ) :
if str1 [ i ] != str2 [ i ] :
return 0
return 1
| code_translation | [
[
"['LISTEN'], ['SILENT']",
"0"
],
[
"['TRIANGLE'], ['INTEGRAL']",
"0"
],
[
"['test'], ['ttew']",
"0"
],
[
"['night'], ['thing']",
"0"
],
[
"['Inch'], ['Study']",
"0"
],
[
"['Dusty'], ['1']",
"0"
],
[
"['GJLMOOSTTXaabceefgllpwz'], ['EJRXYaj... | |
transcoder-geeksforgeeks | cpp | f_gold | null | [] | null | [] | COUNT_NUMBERS_CAN_CONSTRUCTED_USING_TWO_NUMBERS | python | [] | def f_gold ( n , x , y ) :
arr = [ False for i in range ( n + 2 ) ]
if ( x <= n ) :
arr [ x ] = True
if ( y <= n ) :
arr [ y ] = True
result = 0
for i in range ( min ( x , y ) , n + 1 ) :
if ( arr [ i ] ) :
if ( i + x <= n ) :
arr [ i + x ] = True
if ( i + y <= n ) :
arr [ i + y ] = True
result = result + 1
return result
| code_translation | [
[
"23, 16, 16",
"1"
],
[
"56, 95, 6",
"9"
],
[
"30, 63, 1",
"30"
],
[
"51, 89, 46",
"1"
],
[
"21, 99, 38",
"0"
],
[
"69, 63, 50",
"2"
],
[
"12, 69, 73",
"0"
],
[
"44, 52, 9",
"4"
],
[
"99, 65, 10",
"13"
],
[
... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int n, int x, int y ) {
vector < bool > arr ( n + 1, false );
if ( x <= n ) arr [ x ] = true;
if ( y <= n ) arr [ y ] = true;
int result = 0;
for ( int i = min ( x, y );
i <= n;
i ++ ) {
if ( arr [ i ] ) {
if ( i + x <= n ) arr [ i + x ] = true;
if ( i + y <= n ) arr [ i + y ] = true;
result ++;
}
}
return result;
}
| [] | null | [] | SUM_PAIRWISE_PRODUCTS | python | [] | def f_gold ( n ) :
sm = 0
for i in range ( 1 , n + 1 ) :
for j in range ( i , n + 1 ) :
sm = sm + i * j
return sm
| code_translation | [
[
"21",
"28336"
],
[
"32",
"145112"
],
[
"16",
"9996"
],
[
"38",
"284050"
],
[
"9",
"1155"
],
[
"3",
"25"
],
[
"5",
"140"
],
[
"46",
"601036"
],
[
"45",
"551310"
],
[
"87",
"7438442"
]
] | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
long long int f_gold ( int n ) {
long long int sum = 0;
for ( int i = 1;
i <= n;
i ++ ) for ( int j = i;
j <= n;
j ++ ) sum = sum + i * j;
return sum;
}
| [] | null | [] | COUNT_SET_BITS_IN_AN_INTEGER | python | [] | def f_gold ( n ) :
count = 0
while ( n ) :
count += n & 1
n >>= 1
return count
| code_translation | [
[
"58",
"4"
],
[
"92",
"4"
],
[
"73",
"3"
],
[
"52",
"3"
],
[
"24",
"2"
],
[
"14",
"3"
],
[
"58",
"4"
],
[
"11",
"3"
],
[
"8",
"1"
],
[
"52",
"3"
]
] | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
unsigned int f_gold ( unsigned int n ) {
unsigned int count = 0;
while ( n ) {
count += n & 1;
n >>= 1;
}
return count;
}
| [] | null | [] | LONGEST_PALINDROME_SUBSEQUENCE_SPACE | python | [] | def f_gold ( s ) :
n = len ( s )
a = [ 0 ] * n
for i in range ( n - 1 , - 1 , - 1 ) :
back_up = 0
for j in range ( i , n ) :
if j == i :
a [ j ] = 1
elif s [ i ] == s [ j ] :
temp = a [ j ]
a [ j ] = back_up + 2
back_up = temp
else :
back_up = a [ j ]
a [ j ] = max ( a [ j - 1 ] , a [ j ] )
return a [ n - 1 ]
| code_translation | [
[
"' E'",
"1"
],
[
"'0845591950'",
"7"
],
[
"'00101011'",
"5"
],
[
"'pLSvlwrACvFaoT'",
"3"
],
[
"'7246'",
"1"
],
[
"'1010101100000'",
"8"
],
[
"'obPkcLSFp'",
"1"
],
[
"'914757557818'",
"7"
],
[
"'1'",
"1"
],
... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( string & s ) {
int n = s . length ( );
int a [ n ];
for ( int i = n - 1;
i >= 0;
i -- ) {
int back_up = 0;
for ( int j = i;
j < n;
j ++ ) {
if ( j == i ) a [ j ] = 1;
else if ( s [ i ] == s [ j ] ) {
int temp = a [ j ];
a [ j ] = back_up + 2;
back_up = temp;
}
else {
back_up = a [ j ];
a [ j ] = max ( a [ j - 1 ], a [ j ] );
}
}
}
return a [ n - 1 ];
}
| [] | null | [] | DYCK_PATH | python | [] | def f_gold ( n ) :
res = 1
for i in range ( 0 , n ) :
res *= ( 2 * n - i )
res /= ( i + 1 )
return res / ( n + 1 )
| code_translation | [
[
"72",
"2.027689038970942e+40"
],
[
"90",
"1.0001346008003551e+51"
],
[
"61",
"6.182127958584863e+33"
],
[
"28",
"263747951750360.03"
],
[
"70",
"1.321422108420283e+39"
],
[
"13",
"742900.0"
],
[
"7",
"429.0"
],
[
"98",
"5.... | |
transcoder-geeksforgeeks | cpp | f_gold | null | [] | null | [] | MOBILE_NUMERIC_KEYPAD_PROBLEM | python | [] | def f_gold ( keypad , n ) :
if ( not keypad or n <= 0 ) :
return 0
if ( n == 1 ) :
return 10
odd = [ 0 ] * 10
even = [ 0 ] * 10
i = 0
j = 0
useOdd = 0
totalCount = 0
for i in range ( 10 ) :
odd [ i ] = 1
for j in range ( 2 , n + 1 ) :
useOdd = 1 - useOdd
if ( useOdd == 1 ) :
even [ 0 ] = odd [ 0 ] + odd [ 8 ]
even [ 1 ] = odd [ 1 ] + odd [ 2 ] + odd [ 4 ]
even [ 2 ] = odd [ 2 ] + odd [ 1 ] + odd [ 3 ] + odd [ 5 ]
even [ 3 ] = odd [ 3 ] + odd [ 2 ] + odd [ 6 ]
even [ 4 ] = odd [ 4 ] + odd [ 1 ] + odd [ 5 ] + odd [ 7 ]
even [ 5 ] = odd [ 5 ] + odd [ 2 ] + odd [ 4 ] + odd [ 8 ] + odd [ 6 ]
even [ 6 ] = odd [ 6 ] + odd [ 3 ] + odd [ 5 ] + odd [ 9 ]
even [ 7 ] = odd [ 7 ] + odd [ 4 ] + odd [ 8 ]
even [ 8 ] = odd [ 8 ] + odd [ 0 ] + odd [ 5 ] + odd [ 7 ] + odd [ 9 ]
even [ 9 ] = odd [ 9 ] + odd [ 6 ] + odd [ 8 ]
else :
odd [ 0 ] = even [ 0 ] + even [ 8 ]
odd [ 1 ] = even [ 1 ] + even [ 2 ] + even [ 4 ]
odd [ 2 ] = even [ 2 ] + even [ 1 ] + even [ 3 ] + even [ 5 ]
odd [ 3 ] = even [ 3 ] + even [ 2 ] + even [ 6 ]
odd [ 4 ] = even [ 4 ] + even [ 1 ] + even [ 5 ] + even [ 7 ]
odd [ 5 ] = even [ 5 ] + even [ 2 ] + even [ 4 ] + even [ 8 ] + even [ 6 ]
odd [ 6 ] = even [ 6 ] + even [ 3 ] + even [ 5 ] + even [ 9 ]
odd [ 7 ] = even [ 7 ] + even [ 4 ] + even [ 8 ]
odd [ 8 ] = even [ 8 ] + even [ 0 ] + even [ 5 ] + even [ 7 ] + even [ 9 ]
odd [ 9 ] = even [ 9 ] + even [ 6 ] + even [ 8 ]
totalCount = 0
if ( useOdd == 1 ) :
for i in range ( 10 ) :
totalCount += even [ i ]
else :
for i in range ( 10 ) :
totalCount += odd [ i ]
return totalCount
| code_translation | [
[
"[[' ', 'A', 'C', 'K', 'R', 'R', 'V', 'c', 'd', 'i', 'i', 'j', 'm', 'o', 'q', 'q', 'r', 'r', 'v', 'v', 'x', 'z'], ['B', 'D', 'I', 'M', 'N', 'Q', 'R', 'Z', 'c', 'f', 'i', 'j', 'j', 'l', 'l', 'n', 'p', 'q', 's', 't', 't', 'w'], ['A', 'F', 'F', 'G', 'H', 'J', 'K', 'K', 'N', 'V', 'V', 'b', 'c', 'c', 'g', 'i', 'j'... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( unsigned int n ) {
int res = 1;
for ( int i = 0;
i < n;
++ i ) {
res *= ( 2 * n - i );
res /= ( i + 1 );
}
return res / ( n + 1 );
}
| [] | null | [] | CHECK_VALID_SEQUENCE_DIVISIBLE_M_1 | python | [] | def f_gold ( n , index , modulo , M , arr , dp ) :
modulo = ( ( modulo % M ) + M ) % M
if ( index == n ) :
if ( modulo == 0 ) :
return 1
return 0
if ( dp [ index ] [ modulo ] != - 1 ) :
return dp [ index ] [ modulo ]
placeAdd = f_gold ( n , index + 1 , modulo + arr [ index ] , M , arr , dp )
placeMinus = f_gold ( n , index + 1 , modulo - arr [ index ] , M , arr , dp )
res = bool ( placeAdd or placeMinus )
dp [ index ] [ modulo ] = res
return res
| code_translation | [
[
"19, 29, 20, 19, [1, 2, 2, 3, 6, 15, 16, 17, 20, 21, 27, 28, 28, 29, 44, 47, 53, 53, 54, 59, 60, 60, 66, 68, 78, 79, 80, 84, 87, 91, 92, 97], [[4, 7, 9, 11, 16, 22, 22, 24, 31, 35, 36, 37, 44, 46, 47, 50, 52, 56, 59, 62, 62, 63, 65, 65, 67, 67, 72, 74, 74, 79, 92, 92], [6, 10, 12, 16, 17, 21, 23, 25, 25, 25, ... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
string f_gold ( string s ) {
int n = s . length ( );
for ( int i = 1;
i < n;
i ++ ) {
if ( s [ i ] == s [ i - 1 ] ) {
s [ i ] = 'a';
while ( s [ i ] == s [ i - 1 ] || ( i + 1 < n && s [ i ] == s [ i + 1 ] ) ) s [ i ] ++;
i ++;
}
}
return s;
}
| [] | null | [] | WAYS_TRANSFORMING_ONE_STRING_REMOVING_0_CHARACTERS | python | [] | def f_gold ( a , b ) :
n = len ( a )
m = len ( b )
if m == 0 :
return 1
dp = [ [ 0 ] * ( n + 1 ) for _ in range ( m + 1 ) ]
for i in range ( m ) :
for j in range ( i , n ) :
if i == 0 :
if j == 0 :
if a [ j ] == b [ i ] :
dp [ i ] [ j ] = 1
else :
dp [ i ] [ j ] = 0
elif a [ j ] == b [ i ] :
dp [ i ] [ j ] = dp [ i ] [ j - 1 ] + 1
else :
dp [ i ] [ j ] = dp [ i ] [ j - 1 ]
else :
if a [ j ] == b [ i ] :
dp [ i ] [ j ] = ( dp [ i ] [ j - 1 ] + dp [ i - 1 ] [ j - 1 ] )
else :
dp [ i ] [ j ] = dp [ i ] [ j - 1 ]
return dp [ m - 1 ] [ n - 1 ]
| code_translation | [
[
"'abcccdf', 'abccdf'",
"3"
],
[
"'aabba', 'ab'",
"4"
],
[
"'aabsdfljk', 'aa'",
"1"
],
[
"'IONiqV', 'XKbBiGZ'",
"0"
],
[
"'9667771256770', '50915176'",
"0"
],
[
"'10001011', '01'",
"11"
],
[
"'fczbDtMDT', 'FbX'",
"0"
],
[
"'298... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int A [ ], int B [ ], int n ) {
unordered_map < int, int > hash;
for ( int i = 0;
i < n;
i ++ ) {
hash [ A [ i ] ] ++;
hash [ B [ i ] ] ++;
}
int sum = 0;
for ( auto x : hash ) if ( x . second == 1 ) sum += x . first;
return sum;
}
| [] | null | [] | MARKOV_MATRIX | python | [] | def f_gold ( m ) :
for i in range ( 0 , len ( m ) ) :
sm = 0
for j in range ( 0 , len ( m [ i ] ) ) :
sm = sm + m [ i ] [ j ]
if ( sm != 1 ) :
return False
return True
| code_translation | [
[
"[[0, 0, 1], [0.5, 0, 0.5], [1, 0, 0]]",
"True"
],
[
"[[0, 0, 1], [0.5, 0, 0.51], [1, 0, 0]]",
"False"
],
[
"[[0, 0, 0.9], [1, 0, 0.1], [0, 1, 0]]",
"False"
],
[
"[[]]",
"False"
],
[
"[[0, 1], [0.9, 0.1], [0, 1]]",
"True"
],
[
"[[1]]",
"True"
]... | |
transcoder-geeksforgeeks | cpp | f_gold | null | [
"import sys"
] | null | [] | CHOCOLATE_DISTRIBUTION_PROBLEM | python | [] | import sys
def f_gold ( arr , n , m ) :
if ( m == 0 or n == 0 ) :
return 0
arr.sort ( )
if ( n < m ) :
return - 1
min_diff = sys.maxsize
first = 0
last = 0
i = 0
while ( i + m - 1 < n ) :
diff = arr [ i + m - 1 ] - arr [ i ]
if ( diff < min_diff ) :
min_diff = diff
first = i
last = i + m - 1
i += 1
return ( arr [ last ] - arr [ first ] )
| code_translation | [
[
"[2, 5, 11, 23, 33, 35, 39, 51, 52, 56, 74, 76, 76, 79, 85, 88, 93, 98], 16, 13",
"65"
],
[
"[-94, -94, -88, -84, -74, -70, -56, -50, -48, -42, -34, -24, -18, -14, 0, 4, 4, 16, 16, 30, 36, 42, 52, 56, 72, 74, 76, 84, 88], 15, 28",
"-1"
],
[
"[0, 0, 1, 1, 1, 1], 5, 5",
"1"
],
[
... | |
transcoder-geeksforgeeks | cpp | f_gold | null | [] | null | [] | FIND_DIFFERENCE_BETWEEN_SUMS_OF_TWO_DIAGONALS_1 | python | [] | def f_gold ( arr , n ) :
d1 = 0
d2 = 0
for i in range ( 0 , n ) :
d1 = d1 + arr [ i ] [ i ]
d2 = d2 + arr [ i ] [ n - i - 1 ]
return abs ( d1 - d2 )
| code_translation | [
[
"[[1, 2, 4, 8, 12, 15, 17, 17, 19, 19, 21, 26, 27, 28, 32, 33, 40, 41, 41, 46, 46, 47, 48, 56, 59, 62, 68, 68, 69, 76, 80, 81, 82, 83, 86, 88, 90, 91, 93, 96, 97], [3, 7, 8, 9, 10, 13, 16, 18, 20, 22, 22, 24, 26, 27, 31, 33, 33, 34, 37, 43, 45, 46, 46, 46, 47, 49, 50, 51, 55, 57, 67, 75, 75, 83, 87, 87, 90, 9... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int arr [ ], int n ) {
unordered_map < int, int > hm;
for ( int i = 0;
i < n;
i ++ ) hm [ arr [ i ] ] ++;
int max_count = 0, min_count = n;
for ( auto x : hm ) {
max_count = max ( max_count, x . second );
min_count = min ( min_count, x . second );
}
return ( max_count - min_count );
}
| [] | null | [] | ROW_WISE_COMMON_ELEMENTS_TWO_DIAGONALS_SQUARE_MATRIX | python | [] | def f_gold ( mat , n ) :
res = 0
for i in range ( n ) :
if mat [ i ] [ i ] == mat [ i ] [ n - i - 1 ] :
res = res + 1
return res
| code_translation | [
[
"[[62]], 0",
"0"
],
[
"[[-56, -6, -12, 64, 36, 12, -40, -38, 14, 68, 62, -46, -30], [56, 30, -18, -92, -10, 76, 6, 64, 14, -94, 34, 6, 12], [-80, 90, -40, 2, -48, -28, 58, 86, -14, -50, -78, 36, -96], [-92, 84, -86, 60, -18, 18, 24, -16, 42, 66, -10, -70, 16], [68, 12, 78, 8, -44, 2, -76, 4, 4, 8,... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( string a, string b ) {
int n = a . size ( ), m = b . size ( );
if ( m == 0 ) return 1;
int dp [ m + 1 ] [ n + 1 ];
memset ( dp, 0, sizeof ( dp ) );
for ( int i = 0;
i < m;
i ++ ) {
for ( int j = i;
j < n;
j ++ ) {
if ( i == 0 ) {
if ( j == 0 ) dp [ i ] [ j ] = ( a [ j ] == b [ i ] ) ? 1 : 0;
else if ( a [ j ] == b [ i ] ) dp [ i ] [ j ] = dp [ i ] [ j - 1 ] + 1;
else dp [ i ] [ j ] = dp [ i ] [ j - 1 ];
}
else {
if ( a [ j ] == b [ i ] ) dp [ i ] [ j ] = dp [ i ] [ j - 1 ] + dp [ i - 1 ] [ j - 1 ];
else dp [ i ] [ j ] = dp [ i ] [ j - 1 ];
}
}
}
return dp [ m - 1 ] [ n - 1 ];
}
| [] | null | [] | FIND_SUBARRAY_WITH_GIVEN_SUM_1 | python | [] | def f_gold ( arr , n , sum ) :
curr_sum = arr [ 0 ]
start = 0
i = 1
while i <= n :
while curr_sum > sum and start < i - 1 :
curr_sum = curr_sum - arr [ start ]
start += 1
if curr_sum == sum :
print ( "Sum found between indexes" )
print ( "%d and %d" % ( start , i - 1 ) )
return 1
if i < n :
curr_sum = curr_sum + arr [ i ]
i += 1
print ( "No subarray found" )
return 0
| code_translation | [
[
"[7, 7, 8, 8, 23, 24, 28, 32, 48, 53, 56, 62, 69, 77, 81, 82, 84, 87, 88, 90], 16, 31",
"1"
],
[
"[-62, -62, -80, -30, -80, 44, -12, -76, 16, -52, -86, 72, 32, -60, -70, -62, -78, -96, -18, 40, -4, -18, -58, 30, -70, 6, 0, -62, -66, 20, 92, -64, 20, -48, 48, -32, 64, 22, 16, 26], 39, 44",
"0"
... | |
transcoder-geeksforgeeks | cpp | f_gold | null | [] | null | [] | HYPERCUBE_GRAPH | python | [] | def f_gold ( n ) :
if n == 1 :
return 2
return 2 * f_gold ( n - 1 )
| code_translation | [
[
"72",
"4722366482869645213696"
],
[
"28",
"268435456"
],
[
"45",
"35184372088832"
],
[
"41",
"2199023255552"
],
[
"94",
"19807040628566084398385987584"
],
[
"97",
"158456325028528675187087900672"
],
[
"97",
"15845632502852867518708790... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int arr [ ], int n, int m ) {
if ( m == 0 || n == 0 ) return 0;
sort ( arr, arr + n );
if ( n < m ) return - 1;
int min_diff = INT_MAX;
int first = 0, last = 0;
for ( int i = 0;
i + m - 1 < n;
i ++ ) {
int diff = arr [ i + m - 1 ] - arr [ i ];
if ( diff < min_diff ) {
min_diff = diff;
first = i;
last = i + m - 1;
}
}
return ( arr [ last ] - arr [ first ] );
}
| [] | null | [] | HEXAGONAL_NUMBER | python | [] | def f_gold ( n ) :
return n * ( 2 * n - 1 )
| code_translation | [
[
"38",
"2850"
],
[
"44",
"3828"
],
[
"58",
"6670"
],
[
"10",
"190"
],
[
"31",
"1891"
],
[
"53",
"5565"
],
[
"94",
"17578"
],
[
"64",
"8128"
],
[
"71",
"10011"
],
[
"59",
"6903"
]
] | |
transcoder-geeksforgeeks | cpp | f_gold | null | [] | null | [] | LEXICOGRAPHICALLY_NEXT_STRING | python | [] | def f_gold ( s ) :
if ( s == " " ) :
return "a"
i = len ( s ) - 1
while ( s [ i ] == 'z' and i >= 0 ) :
i -= 1
if ( i == - 1 ) :
s = s + 'a'
else :
s = s.replace ( s [ i ] , chr ( ord ( s [ i ] ) + 1 ) , 1 )
return s
| code_translation | [
[
"'amKIRzPiqLTIy'",
"'amKIRzPiqLTIz'"
],
[
"'68'",
"'69'"
],
[
"'100'",
"'110'"
],
[
"'f'",
"'g'"
],
[
"'802205375'",
"'802206375'"
],
[
"'0111'",
"'0211'"
],
[
"'GRjRYIvYwgua'",
"'GRjRYIvYwgub'"
],
[
"'8139910006809'",
"'8... | |
transcoder-geeksforgeeks | cpp | f_gold | null | [] | null | [] | SUM_BINOMIAL_COEFFICIENTS_1 | python | [] | def f_gold ( n ) :
return ( 1 << n ) ;
| code_translation | [
[
"48",
"281474976710656"
],
[
"42",
"4398046511104"
],
[
"15",
"32768"
],
[
"75",
"37778931862957161709568"
],
[
"23",
"8388608"
],
[
"41",
"2199023255552"
],
[
"46",
"70368744177664"
],
[
"99",
"633825300114114700748351602... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int arr [ ], int n, int sum ) {
int curr_sum = arr [ 0 ], start = 0, i;
for ( i = 1;
i <= n;
i ++ ) {
while ( curr_sum > sum && start < i - 1 ) {
curr_sum = curr_sum - arr [ start ];
start ++;
}
if ( curr_sum == sum ) {
cout << "Sum found between indexes " << start << " and " << i - 1;
return 1;
}
if ( i < n ) curr_sum = curr_sum + arr [ i ];
}
cout << "No subarray found";
return 0;
}
| [] | null | [] | ADD_TWO_NUMBERS_WITHOUT_USING_ARITHMETIC_OPERATORS | python | [] | def f_gold ( x , y ) :
while ( y != 0 ) :
carry = x & y
x = x ^ y
y = carry << 1
return x
| code_translation | [
[
"56, 60",
"116"
],
[
"17, 44",
"61"
],
[
"73, 96",
"169"
],
[
"75, 3",
"78"
],
[
"27, 54",
"81"
],
[
"61, 1",
"62"
],
[
"65, 63",
"128"
],
[
"22, 19",
"41"
],
[
"61, 9",
"70"
],
[
"97, 23",
"120"
... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int n ) {
if ( n == 1 ) return 2;
return 2 * f_gold ( n - 1 );
}
| [] | null | [] | COUNT_OPERATIONS_MAKE_STRINGAB_FREE | python | [] | def f_gold ( s ) :
b_count = 0
res = 0
for i in range ( len ( s ) ) :
if s [ ~ i ] == 'a' :
res = ( res + b_count )
b_count = ( b_count * 2 )
else :
b_count += 1
return res
| code_translation | [
[
"['L', 'k', 'y']",
"0"
],
[
"['1', '0', '9', '5', '7', '4', '6', '0', '4', '8', '0', '1', '4', '1', '8', '9', '1', '5', '4', '4', '8', '0', '5', '8', '9', '8', '1', '9', '7', '0', '4', '2', '5', '2', '4', '6', '6', '5', '3', '1', '1', '0', '6']",
"0"
],
[
"['0', '0', '0', '0', '0', '0'... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int n ) {
return n * ( 2 * n - 1 );
}
| [] | null | [] | SCHEDULE_JOBS_SERVER_GETS_EQUAL_LOAD | python | [] | def f_gold ( a , b , n ) :
s = 0
for i in range ( 0 , n ) :
s += a [ i ] + b [ i ]
if n == 1 :
return a [ 0 ] + b [ 0 ]
if s % n != 0 :
return - 1
x = s // n
for i in range ( 0 , n ) :
if a [ i ] > x :
return - 1
if i > 0 :
a [ i ] += b [ i - 1 ]
b [ i - 1 ] = 0
if a [ i ] == x :
continue
y = a [ i ] + b [ i ]
if i + 1 < n :
y += b [ i + 1 ]
if y == x :
a [ i ] = y
b [ i ] = 0
if i + 1 < n : b [ i + 1 ] = 0
continue
if a [ i ] + b [ i ] == x :
a [ i ] += b [ i ]
b [ i ] = 0
continue
if i + 1 < n and a [ i ] + b [ i + 1 ] == x :
a [ i ] += b [ i + 1 ]
b [ i + 1 ] = 0
continue
return - 1
for i in range ( 0 , n ) :
if b [ i ] != 0 :
return - 1
return x
| code_translation | [
[
"[4, 9, 16, 18, 20, 23, 24, 25, 25, 26, 29, 30, 35, 40, 41, 43, 44, 46, 53, 53, 56, 56, 58, 60, 62, 70, 80, 80, 80, 82, 86, 90, 92, 92, 95], [3, 15, 16, 16, 18, 26, 30, 32, 32, 35, 37, 41, 42, 43, 48, 49, 49, 54, 55, 57, 65, 66, 67, 67, 68, 83, 85, 89, 89, 90, 91, 93, 96, 97, 99], 29",
"-1"
],
[
"... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
string f_gold ( string s ) {
if ( s == "" ) return "a";
int i = s . length ( ) - 1;
while ( s [ i ] == 'z' && i >= 0 ) i --;
if ( i == - 1 ) s = s + 'a';
else s [ i ] ++;
return s;
}
| [] | null | [] | HOW_TO_CHECK_IF_A_GIVEN_ARRAY_REPRESENTS_A_BINARY_HEAP_1 | python | [] | def f_gold ( arr , n ) :
for i in range ( int ( ( n - 2 ) / 2 ) + 1 ) :
if arr [ 2 * i + 1 ] > arr [ i ] :
return False
if ( 2 * i + 2 < n and arr [ 2 * i + 2 ] > arr [ i ] ) :
return False
return True
| code_translation | [
[
"[2, 2, 2, 7, 10, 14, 24, 38, 42, 50, 59, 60, 72, 73, 79, 83, 89], 9",
"False"
],
[
"[-48, 98, 96, -56, -2, 58, 52, -50, 58, 50, 62, 86, -26, -98, 34, 20, -28, 56, -36], 9",
"False"
],
[
"[0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 20",
"False"
],
[
... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( string str ) {
int n = str . length ( );
int digitSum = 0;
for ( int i = 0;
i < n;
i ++ ) digitSum += ( str [ i ] - '0' );
return ( digitSum % 9 == 0 );
}
| [] | null | [] | MAXIMIZE_SUM_ARRII | python | [] | def f_gold ( arr , n ) :
arr.sort ( )
sum = 0
for i in range ( n ) :
sum += arr [ i ] * i
return sum
| code_translation | [
[
"[2, 3, 4, 6, 7, 8, 9, 11, 19, 23, 24, 30, 31, 31, 32, 41, 43, 43, 46, 47, 50, 50, 51, 53, 57, 63, 63, 69, 73, 74, 79, 80, 81, 81, 85, 86, 88, 92, 93, 95, 98, 99], 22",
"8185"
],
[
"[-98, -98, -82, -80, -78, -76, -74, -68, -62, -58, -58, -52, -42, -42, -40, -34, -16, -10, -10, -6, 10, 12, 20, 32, ... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int arr [ ], int n ) {
int max_len = 0;
for ( int i = 0;
i < n;
i ++ ) {
int curr_sum = 0;
for ( int j = i;
j < n;
j ++ ) {
curr_sum += arr [ j ];
if ( curr_sum == 0 ) max_len = max ( max_len, j - i + 1 );
}
}
return max_len;
}
| [] | null | [] | CHECK_WHETHER_GIVEN_DEGREES_VERTICES_REPRESENT_GRAPH_TREE | python | [] | def f_gold ( degree , n ) :
deg_sum = sum ( degree )
if ( 2 * ( n - 1 ) == deg_sum ) :
return True
else :
return False
| code_translation | [
[
"[2, 3, 1, 1, 1], 5",
"True"
],
[
"[2, 2, 1, 1, 2], 5",
"True"
],
[
"[2, 2, 1, 1, 1], 5",
"False"
],
[
"[0, 0, 0, 3, 3, 4], 6",
"True"
],
[
"[-10, 12, 2], 3",
"True"
],
[
"[1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1,... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int n ) {
return ( 1 << n );
}
| [] | null | [] | MAXIMUM_POINTS_INTERSECTION_N_CIRCLES | python | [] | def f_gold ( n ) :
return n * ( n - 1 ) ;
| code_translation | [
[
"30",
"870"
],
[
"25",
"600"
],
[
"69",
"4692"
],
[
"39",
"1482"
],
[
"14",
"182"
],
[
"60",
"3540"
],
[
"89",
"7832"
],
[
"27",
"702"
],
[
"29",
"812"
],
[
"29",
"812"
]
] | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( string str, int n ) {
int len = str . length ( );
int dp [ len ] [ n ];
memset ( dp, 0, sizeof ( dp ) );
dp [ 0 ] [ ( str [ 0 ] - '0' ) % n ] ++;
for ( int i = 1;
i < len;
i ++ ) {
dp [ i ] [ ( str [ i ] - '0' ) % n ] ++;
for ( int j = 0;
j < n;
j ++ ) {
dp [ i ] [ j ] += dp [ i - 1 ] [ j ];
dp [ i ] [ ( j * 10 + ( str [ i ] - '0' ) ) % n ] += dp [ i - 1 ] [ j ];
}
}
return dp [ len - 1 ] [ 0 ];
}
| [] | null | [] | SUBSEQUENCES_SIZE_THREE_ARRAY_WHOSE_SUM_DIVISIBLE_M | python | [] | def f_gold ( A , N , M ) :
sum = 0
ans = 0
for i in range ( 0 , N ) :
for j in range ( i + 1 , N ) :
for k in range ( j + 1 , N ) :
sum = A [ i ] + A [ j ] + A [ k ]
if ( sum % M == 0 ) :
ans = ans + 1
return ans
| code_translation | [
[
"[14, 35, 56, 70, 88], 3, 4",
"0"
],
[
"[-50, -92, 16, -68, -36], 3, 4",
"0"
],
[
"[0, 0, 0, 1, 1, 1], 4, 5",
"1"
],
[
"[76, 43, 22, 41, 49, 99, 25, 40, 3, 45, 60, 16, 83, 62, 26, 93, 64, 73, 72, 53, 6, 32, 35, 67, 17], 14, 21",
"19"
],
[
"[-90, -86, -86, -66, -... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int x, int y ) {
while ( y != 0 ) {
int carry = x & y;
x = x ^ y;
y = carry << 1;
}
return x;
}
| [] | null | [] | COUNT_NUMBER_OF_WAYS_TO_PARTITION_A_SET_INTO_K_SUBSETS_1 | python | [] | def f_gold ( n , k ) :
dp = [ [ 0 for i in range ( k + 1 ) ] for j in range ( n + 1 ) ]
for i in range ( n + 1 ) :
dp [ i ] [ 0 ] = 0
for i in range ( k + 1 ) :
dp [ 0 ] [ k ] = 0
for i in range ( 1 , n + 1 ) :
for j in range ( 1 , k + 1 ) :
if ( j == 1 or i == j ) :
dp [ i ] [ j ] = 1
else :
dp [ i ] [ j ] = ( j * dp [ i - 1 ] [ j ] + dp [ i - 1 ] [ j - 1 ] )
return dp [ n ] [ k ]
| code_translation | [
[
"84, 99",
"0"
],
[
"95, 64",
"3737656266798088211682370566017545945794416705149130532711106064640192000"
],
[
"67, 21",
"317785949233165232675871188490983702051092552042096537971577650775740"
],
[
"92, 22",
"20654386245506900840666949526502454740829220078395775799026805... | |
transcoder-geeksforgeeks | cpp | f_gold | null | [] | null | [] | LEONARDO_NUMBER_1 | python | [] | def f_gold ( n ) :
dp = [ ] ;
dp.append ( 1 ) ;
dp.append ( 1 ) ;
for i in range ( 2 , n + 1 ) :
dp.append ( dp [ i - 1 ] + dp [ i - 2 ] + 1 ) ;
return dp [ n ] ;
| code_translation | [
[
"75",
"6832909245813413"
],
[
"76",
"11055879401769513"
],
[
"55",
"451702867433"
],
[
"14",
"1219"
],
[
"43",
"1402817465"
],
[
"10",
"177"
],
[
"16",
"3193"
],
[
"30",
"2692537"
],
[
"44",
"2269806339"
],
... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int a [ ], int b [ ], int n ) {
int i;
long long int s = 0;
for ( i = 0;
i < n;
i ++ ) s += ( a [ i ] + b [ i ] );
if ( n == 1 ) return a [ 0 ] + b [ 0 ];
if ( s % n != 0 ) return - 1;
int x = s / n;
for ( i = 0;
i < n;
i ++ ) {
if ( a [ i ] > x ) return - 1;
if ( i > 0 ) {
a [ i ] += b [ i - 1 ];
b [ i - 1 ] = 0;
}
if ( a [ i ] == x ) continue;
int y = a [ i ] + b [ i ];
if ( i + 1 < n ) y += b [ i + 1 ];
if ( y == x ) {
a [ i ] = y;
b [ i ] = b [ i + 1 ] = 0;
continue;
}
if ( a [ i ] + b [ i ] == x ) {
a [ i ] += b [ i ];
b [ i ] = 0;
continue;
}
if ( i + 1 < n && a [ i ] + b [ i + 1 ] == x ) {
a [ i ] += b [ i + 1 ];
b [ i + 1 ] = 0;
continue;
}
return - 1;
}
for ( i = 0;
i < n;
i ++ ) if ( b [ i ] != 0 ) return - 1;
return x;
}
| [] | null | [] | FIND_MAXIMUM_HEIGHT_PYRAMID_FROM_THE_GIVEN_ARRAY_OF_OBJECTS | python | [] | def f_gold ( boxes , n ) :
boxes.sort ( )
ans = 1
prev_width = boxes [ 0 ]
prev_count = 1
curr_count = 0
curr_width = 0
for i in range ( 1 , n ) :
curr_width += boxes [ i ]
curr_count += 1
if ( curr_width > prev_width and curr_count > prev_count ) :
prev_width = curr_width
prev_count = curr_count
curr_count = 0
curr_width = 0
ans += 1
return ans
| code_translation | [
[
"[7, 8, 11, 11, 14, 19, 25, 27, 41, 42, 46, 52, 53, 54, 55, 58, 59, 62, 63, 66, 67, 69, 74, 75, 77, 81, 83, 84, 88, 88, 93, 93, 94], 22",
"6"
],
[
"[-96, -92, -78, -72, -60, -56, -28, -18, 12, 14, 16, 16, 20, 20, 30, 40, 72, 76, 76, 80, 86], 12",
"1"
],
[
"[0, 0, 0, 0, 0, 0, 0, 0, 0, 0... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
bool f_gold ( int arr [ ], int n ) {
for ( int i = 0;
i <= ( n - 2 ) / 2;
i ++ ) {
if ( arr [ 2 * i + 1 ] > arr [ i ] ) return false;
if ( 2 * i + 2 < n && arr [ 2 * i + 2 ] > arr [ i ] ) return false;
}
return true;
}
| [] | null | [] | MAXIMUM_NUMBER_CHOCOLATES_DISTRIBUTED_EQUALLY_AMONG_K_STUDENTS | python | [] | def f_gold ( arr , n , k ) :
um , curr_rem , maxSum = { } , 0 , 0
sm = [ 0 ] * n
sm [ 0 ] = arr [ 0 ]
for i in range ( 1 , n ) :
sm [ i ] = sm [ i - 1 ] + arr [ i ]
for i in range ( n ) :
curr_rem = sm [ i ] % k
if ( not curr_rem and maxSum < sm [ i ] ) :
maxSum = sm [ i ]
elif ( not curr_rem in um ) :
um [ curr_rem ] = i
elif ( maxSum < ( sm [ i ] - sm [ um [ curr_rem ] ] ) ) :
maxSum = sm [ i ] - sm [ um [ curr_rem ] ]
return maxSum // k
| code_translation | [
[
"[2, 3, 8, 8, 12, 14, 23, 25, 25, 27, 27, 29, 40, 42, 49, 52, 52, 54, 56, 57, 61, 68, 74, 77, 81, 82, 83, 84, 85, 85, 85, 87, 87, 88, 88, 90, 92, 96, 96], 27, 32",
"29"
],
[
"[-90, -34, 26, -20, -12, -42, 28, 12, -6, 58, -46, 4, -30, -28, -14], 8, 14",
"0"
],
[
"[0, 0, 0, 0, 1, 1, 1, 1... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( string num ) {
int n = num . length ( );
int sum = accumulate ( begin ( num ), end ( num ), 0 ) - '0' * 1;
if ( sum % 3 == 0 ) return 0;
if ( n == 1 ) return - 1;
for ( int i = 0;
i < n;
i ++ ) if ( sum % 3 == ( num [ i ] - '0' ) % 3 ) return 1;
if ( n == 2 ) return - 1;
return 2;
}
| [] | null | [] | ELEMENTS_TO_BE_ADDED_SO_THAT_ALL_ELEMENTS_OF_A_RANGE_ARE_PRESENT_IN_ARRAY | python | [] | def f_gold ( arr , n ) :
count = 0
arr.sort ( )
for i in range ( 0 , n - 1 ) :
if ( arr [ i ] != arr [ i + 1 ] and arr [ i ] != arr [ i + 1 ] - 1 ) :
count += arr [ i + 1 ] - arr [ i ] - 1 ;
return count
| code_translation | [
[
"[4, 4, 5, 7, 7, 9, 13, 15, 18, 19, 25, 27, 27, 29, 32, 36, 48, 51, 53, 53, 55, 65, 66, 67, 72, 74, 74, 76, 77, 79, 80, 81, 82, 83, 83, 86, 87, 97, 98, 98, 99], 30",
"51"
],
[
"[-90, -90, -88, -84, -84, -84, -80, -74, -52, -26, -26, -16, -8, 6, 14, 16, 34, 64, 72, 92, 94], 17",
"112"
],
[
... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int arr [ ], int n ) {
sort ( arr, arr + n );
int sum = 0;
for ( int i = 0;
i < n;
i ++ ) sum += ( arr [ i ] * i );
return sum;
}
| [] | null | [] | FIND_THE_MAXIMUM_ELEMENT_IN_AN_ARRAY_WHICH_IS_FIRST_INCREASING_AND_THEN_DECREASING | python | [] | def f_gold ( arr , low , high ) :
max = arr [ low ]
i = low
for i in range ( high + 1 ) :
if arr [ i ] > max :
max = arr [ i ]
return max
| code_translation | [
[
"[11, 15, 16, 19, 24, 25, 26, 28, 34, 34, 43, 61, 63, 66, 67, 72, 77, 79, 81, 83, 87, 94, 99], 15, 21",
"94"
],
[
"[8, 92], 1, 1",
"92"
],
[
"[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 23, 15",
"1"
],
[
"[84, 39, 92, 89, 38, 75, 18, 39, 83, 67... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
bool f_gold ( int degree [ ], int n ) {
int deg_sum = 0;
for ( int i = 0;
i < n;
i ++ ) deg_sum += degree [ i ];
return ( 2 * ( n - 1 ) == deg_sum );
}
| [] | null | [] | MAXIMUM_LENGTH_SUBSEQUENCE_DIFFERENCE_ADJACENT_ELEMENTS_EITHER_0_1 | python | [] | def f_gold(arr, n):
mls = []
max = 0
for i in range(n):
mls.append(1)
for i in range(n):
for j in range(i):
if (abs(arr[i] - arr[j]) <= 1 and mls[i] < mls[j] + 1):
mls[i] = mls[j] + 1
for i in range(n):
if (max < mls[i]):
max = mls[i]
return max
| code_translation | [
[
"[4, 5, 9, 31, 31, 37, 41, 55, 56, 61, 79, 81, 89, 93], 12",
"2"
],
[
"[-76, 96, -68, -16, 22, -24, -24, 6, 98, -82, 54, -80, 46, 0, 0, -50], 15",
"2"
],
[
"[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 29",
"29"
],
[
"[97... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int n ) {
return n * ( n - 1 );
}
| [] | null | [] | CASSINIS_IDENTITY | python | [] | def f_gold ( n ) :
return - 1 if ( n & 1 ) else 1
| code_translation | [
[
"67",
"-1"
],
[
"2",
"1"
],
[
"58",
"1"
],
[
"6",
"1"
],
[
"42",
"1"
],
[
"17",
"-1"
],
[
"37",
"-1"
],
[
"44",
"1"
],
[
"23",
"-1"
],
[
"40",
"1"
]
] | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int A [ ], int N, int M ) {
int sum = 0;
int ans = 0;
for ( int i = 0;
i < N;
i ++ ) {
for ( int j = i + 1;
j < N;
j ++ ) {
for ( int k = j + 1;
k < N;
k ++ ) {
sum = A [ i ] + A [ j ] + A [ k ];
if ( sum % M == 0 ) ans ++;
}
}
}
return ans;
}
| [
"import math"
] | null | [] | PROGRAM_CALCULATE_VOLUME_ELLIPSOID | python | [] | import math
def f_gold(r1, r2, r3):
return 1.33 * math.pi * r1 * r2 * r3
| code_translation | [
[
"3287.4842316041018, 4503.332888443404, 8590.24729914204",
"531379639833.05774"
],
[
"-3707.427510963942, -6671.335781753231, -2780.4954870801926",
"-287348660250.6971"
],
[
"8980.643174783816, 3584.781688607942, 2818.469507143102",
"379127256148.80035"
],
[
"-2698.01873688... | |
transcoder-geeksforgeeks | cpp | f_gold | null | [] | null | [] | MAXIMUM_XOR_VALUE_MATRIX | python | [] | def f_gold(mat, N):
max_xor = 0
for i in range(N):
r_xor = 0
c_xor = 0
for j in range(N):
r_xor = r_xor ^ mat[i][j]
c_xor = c_xor ^ mat[j][i]
if (max_xor < max(r_xor, c_xor)):
max_xor = max(r_xor, c_xor)
return max_xor
| code_translation | [
[
"[[2, 2, 3, 9, 9, 10, 12, 13, 17, 19, 26, 28, 28, 30, 30, 32, 32, 39, 40, 41, 42, 52, 52, 54, 54, 55, 56, 59, 62, 63, 69, 71, 72, 72, 72, 73, 77, 78, 80, 83, 83, 85, 87, 90, 90, 91, 93], [1, 1, 3, 5, 5, 8, 10, 14, 15, 17, 20, 22, 24, 24, 26, 27, 32, 33, 33, 35, 38, 40, 41, 44, 54, 54, 55, 55, 59, 63, 64, 65, ... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int n ) {
int dp [ n + 1 ];
dp [ 0 ] = dp [ 1 ] = 1;
for ( int i = 2;
i <= n;
i ++ ) dp [ i ] = dp [ i - 1 ] + dp [ i - 2 ] + 1;
return dp [ n ];
}
| [] | null | [] | CHECK_ARRAY_REPRESENTS_INORDER_BINARY_SEARCH_TREE_NOT | python | [] | def f_gold ( arr , n ) :
if ( n == 0 or n == 1 ) :
return True
for i in range ( 1 , n , 1 ) :
if ( arr [ i - 1 ] > arr [ i ] ) :
return False
return True
| code_translation | [
[
"[2, 3, 4, 10, 11, 13, 17, 19, 23, 26, 28, 29, 30, 34, 35, 37, 38, 38, 43, 49, 49, 50, 52, 53, 55, 55, 57, 58, 58, 59, 64, 66, 67, 70, 72, 72, 75, 77, 77, 87, 89, 89, 90, 91, 98, 99, 99, 99], 46",
"True"
],
[
"[56, -94, -26, -52, 58, -66, -52, -66, -94, 44, 38, -66, 70, -70, -80, -78, -72, -60, -7... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int boxes [ ], int n ) {
sort ( boxes, boxes + n );
int ans = 1;
int prev_width = boxes [ 0 ];
int prev_count = 1;
int curr_count = 0;
int curr_width = 0;
for ( int i = 1;
i < n;
i ++ ) {
curr_width += boxes [ i ];
curr_count += 1;
if ( curr_width > prev_width && curr_count > prev_count ) {
prev_width = curr_width;
prev_count = curr_count;
curr_count = 0;
curr_width = 0;
ans ++;
}
}
return ans;
}
| [] | null | [] | COUNT_SUBARRAYS_EQUAL_NUMBER_1S_0S_1 | python | [] | def f_gold ( arr , n ) :
mp = dict ( )
Sum = 0
count = 0
for i in range ( n ) :
if ( arr [ i ] == 0 ) :
arr [ i ] = - 1
Sum += arr [ i ]
if ( Sum == 0 ) :
count += 1
if ( Sum in mp.keys ( ) ) :
count += mp [ Sum ]
mp [ Sum ] = mp.get ( Sum , 0 ) + 1
return count
| code_translation | [
[
"[1, 6, 6, 9, 9, 9, 16, 18, 19, 20, 21, 22, 23, 26, 26, 28, 39, 40, 41, 43, 43, 44, 44, 45, 51, 51, 55, 59, 60, 62, 67, 67, 68, 69, 70, 71, 71, 72, 82, 84, 88, 88, 89, 89, 91, 92, 92], 44",
"0"
],
[
"[-44, 74, -52, -96, 46, 92, 54, 56, -38, 88, 40, 34, -72, 8, 58, -14, 36, 94, 34, -90, -42, 80, -1... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int arr [ ], int n, int k ) {
unordered_map < int, int > um;
int sum [ n ], curr_rem;
int maxSum = 0;
sum [ 0 ] = arr [ 0 ];
for ( int i = 1;
i < n;
i ++ ) sum [ i ] = sum [ i - 1 ] + arr [ i ];
for ( int i = 0;
i < n;
i ++ ) {
curr_rem = sum [ i ] % k;
if ( curr_rem == 0 ) {
if ( maxSum < sum [ i ] ) maxSum = sum [ i ];
}
else if ( um . find ( curr_rem ) == um . end ( ) ) um [ curr_rem ] = i;
else if ( maxSum < ( sum [ i ] - sum [ um [ curr_rem ] ] ) ) maxSum = sum [ i ] - sum [ um [ curr_rem ] ];
}
return ( maxSum / k );
}
| [
"import math"
] | null | [] | FIND_SUM_NODES_GIVEN_PERFECT_BINARY_TREE_1 | python | [] | import math
def f_gold ( l ) :
leafNodeCount = math.pow ( 2 , l - 1 ) ;
sumLastLevel = 0 ;
sumLastLevel = ( ( leafNodeCount * ( leafNodeCount + 1 ) ) / 2 ) ;
sum = sumLastLevel * l ;
return int ( sum ) ;
| code_translation | [
[
"5",
"680"
],
[
"16",
"8590196736"
],
[
"8",
"66048"
],
[
"61",
"40541453871439934123566115338550509568"
],
[
"59",
"2450764117228438640666394267391885312"
],
[
"88",
"1053590684345298590121363581165837563737883146501226496"
],
[
"67",
... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int arr [ ], int n ) {
int count = 0;
sort ( arr, arr + n );
for ( int i = 0;
i < n - 1;
i ++ ) if ( arr [ i ] != arr [ i + 1 ] && arr [ i ] != arr [ i + 1 ] - 1 ) count += arr [ i + 1 ] - arr [ i ] - 1;
return count;
}
| [] | null | [] | PROGRAM_CIRCUMFERENCE_PARALLELOGRAM | python | [] | def f_gold ( a , b ) :
return ( ( 2 * a ) + ( 2 * b ) )
| code_translation | [
[
"801.0366882228715, 456.71190645582783",
"2515.4971893573984"
],
[
"-7069.610056819919, -4226.483870778477",
"-22592.18785519679"
],
[
"7723.966966568705, 5894.65405158763",
"27237.242036312673"
],
[
"-7935.859205856963, -5333.225064296693",
"-26538.168540307313"
],
... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int arr [ ], int low, int high ) {
int max = arr [ low ];
int i;
for ( i = low + 1;
i <= high;
i ++ ) {
if ( arr [ i ] > max ) max = arr [ i ];
else break;
}
return max;
}
| [] | null | [] | CHECK_NUMBER_IS_PERFECT_SQUARE_USING_ADDITIONSUBTRACTION | python | [] | def f_gold ( n ) :
i = 1
the_sum = 0
while the_sum < n :
the_sum += i
if the_sum == n :
return True
i += 2
return False
| code_translation | [
[
"1",
"True"
],
[
"4",
"True"
],
[
"9",
"True"
],
[
"25",
"True"
],
[
"36",
"True"
],
[
"3",
"False"
],
[
"121",
"True"
],
[
"14",
"False"
],
[
"17",
"False"
],
[
"80",
"False"
]
] | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int arr [ ], int n ) {
int mls [ n ], max = 0;
for ( int i = 0;
i < n;
i ++ ) mls [ i ] = 1;
for ( int i = 1;
i < n;
i ++ ) for ( int j = 0;
j < i;
j ++ ) if ( abs ( arr [ i ] - arr [ j ] ) <= 1 && mls [ i ] < mls [ j ] + 1 ) mls [ i ] = mls [ j ] + 1;
for ( int i = 0;
i < n;
i ++ ) if ( max < mls [ i ] ) max = mls [ i ];
return max;
}
| [
"import math"
] | null | [] | SUM_FACTORS_NUMBER | python | [] | import math
def f_gold ( n ) :
result = 0
for i in range ( 2 , ( int ) ( math.sqrt ( n ) ) + 1 ) :
if ( n % i == 0 ) :
if ( i == ( n / i ) ) :
result = result + i
else :
result = result + ( i + n // i )
return ( result + n + 1 )
| code_translation | [
[
"76",
"140"
],
[
"21",
"32"
],
[
"4",
"7"
],
[
"49",
"57"
],
[
"35",
"48"
],
[
"55",
"72"
],
[
"43",
"44"
],
[
"39",
"56"
],
[
"36",
"91"
],
[
"5",
"6"
]
] | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int n ) {
return ( n & 1 ) ? - 1 : 1;
}
| [] | null | [] | CHECK_GIVEN_STRING_ROTATION_PALINDROME | python | [] | def f_gold ( string ) :
l = 0
h = len ( string ) - 1
while h > l :
l += 1
h -= 1
if string [ l - 1 ] != string [ h + 1 ] :
return False
return True
| code_translation | [
[
"'aadaa'",
"True"
],
[
"'2674377254'",
"False"
],
[
"'11'",
"True"
],
[
"'0011000'",
"False"
],
[
"'26382426486138'",
"False"
],
[
"'111010111010'",
"False"
],
[
"'abccba'",
"True"
],
[
"'5191'",
"False"
],
[
"'111... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
float f_gold ( float r1, float r2, float r3 ) {
float pi = 3.14;
return 1.33 * pi * r1 * r2 * r3;
}
| [] | null | [] | TOTAL_NUMBER_OF_NON_DECREASING_NUMBERS_WITH_N_DIGITS_1 | python | [] | def f_gold ( n ) :
N = 10
count = 1
for i in range ( 1 , n + 1 ) :
count = int ( count * ( N + i - 1 ) )
count = int ( count / i )
return count
| code_translation | [
[
"40",
"2054455634"
],
[
"11",
"167960"
],
[
"94",
"2509710226100"
],
[
"73",
"293052087900"
],
[
"6",
"5005"
],
[
"73",
"293052087900"
],
[
"58",
"42757703560"
],
[
"40",
"2054455634"
],
[
"64",
"97082021465"
... | |
transcoder-geeksforgeeks | cpp | f_gold | null | [] | null | [] | LEXICOGRAPHICALLY_MINIMUM_STRING_ROTATION | python | [] | def f_gold ( str_ ) :
n = len ( str_ )
arr = [ 0 ] * n
concat = str_ + str_
for i in range ( n ) :
arr [ i ] = concat [ i : n + i ]
arr.sort ( )
return arr [ 0 ]
| code_translation | [
[
"'onWEchl'",
"'EchlonW'"
],
[
"'2'",
"'2'"
],
[
"'100'",
"'001'"
],
[
"'GHbCZA'",
"'AGHbCZ'"
],
[
"'50568798206105'",
"'05505687982061'"
],
[
"'001011110001'",
"'000100101111'"
],
[
"'lljpYhznnyu'",
"'Yhznnyulljp'"
],
[
"'5449... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
bool f_gold ( int arr [ ], int n ) {
if ( n == 0 || n == 1 ) return true;
for ( int i = 1;
i < n;
i ++ ) if ( arr [ i - 1 ] > arr [ i ] ) return false;
return true;
}
| [] | null | [] | CHECK_NUMBER_POWER_K_USING_BASE_CHANGING_METHOD | python | [] | def f_gold ( n , k ) :
oneSeen = False
while ( n > 0 ) :
digit = n % k
if ( digit > 1 ) :
return False
if ( digit == 1 ) :
if ( oneSeen ) :
return False
oneSeen = True
n //= k
return True
| code_translation | [
[
"64, 4",
"True"
],
[
"16, 2",
"True"
],
[
"27, 3",
"True"
],
[
"81, 72",
"False"
],
[
"1, 9",
"True"
],
[
"69, 17",
"False"
],
[
"8, 20",
"False"
],
[
"31, 79",
"False"
],
[
"43, 81",
"False"
],
[
"54, ... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int arr [ ], int n ) {
map < int, int > mp;
int sum = 0;
int count = 0;
for ( int i = 0;
i < n;
i ++ ) {
if ( arr [ i ] == 0 ) arr [ i ] = - 1;
sum += arr [ i ];
if ( sum == 0 ) count ++;
if ( mp [ sum ] ) count += mp [ sum ];
if ( mp [ sum ] == 0 ) mp [ sum ] = 1;
else mp [ sum ] ++;
}
return count;
}
| [] | null | [] | MINIMUM_NUMBER_OF_JUMPS_TO_REACH_END_OF_A_GIVEN_ARRAY_1 | python | [] | def f_gold ( arr , n ) :
jumps = [ 0 for i in range ( n ) ]
if ( n == 0 ) or ( arr [ 0 ] == 0 ) :
return float ( 'inf' )
jumps [ 0 ] = 0
for i in range ( 1 , n ) :
jumps [ i ] = float ( 'inf' )
for j in range ( i ) :
if ( i <= j + arr [ j ] ) and ( jumps [ j ] != float ( 'inf' ) ) :
jumps [ i ] = min ( jumps [ i ] , jumps [ j ] + 1 )
break
return jumps [ n - 1 ]
| code_translation | [
[
"[2, 5, 9, 9, 12, 13, 13, 13, 15, 16, 17, 18, 20, 20, 20, 25, 28, 30, 30, 33, 34, 34, 37, 42, 45, 49, 50, 52, 52, 54, 65, 68, 72, 74, 75, 82, 85, 87, 91, 91, 94, 95], 22",
"3"
],
[
"[-28, 90, 30, -80, -10, 26, -12, 24, 12, 44, -38, 20, 26, 38, -8, -40, 88, 26], 9",
"inf"
],
[
"[0, 0, 0... | |
transcoder-geeksforgeeks | cpp | f_gold | null | [] | null | [] | SORT_EVEN_NUMBERS_ASCENDING_ORDER_SORT_ODD_NUMBERS_DESCENDING_ORDER_1 | python | [] | def f_gold ( arr , n ) :
for i in range ( 0 , n ) :
if ( arr [ i ] & 1 ) :
arr [ i ] *= - 1
arr.sort ( )
for i in range ( 0 , n ) :
if ( arr [ i ] & 1 ) :
arr [ i ] *= - 1
| code_translation | [
[
"[4], 0",
"None"
],
[
"[89, -74, 65, 51, 51, 8, -15, -23, 44, 68, 89], 8",
"None"
],
[
"[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 28",
"None"
],
[
"[51, 43, 15, 15, -5, 38, 74, 93], 6",
"Non... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
float f_gold ( float a, float b ) {
return ( ( 2 * a ) + ( 2 * b ) );
}
| [] | null | [] | SEARCH_AN_ELEMENT_IN_AN_ARRAY_WHERE_DIFFERENCE_BETWEEN_ADJACENT_ELEMENTS_IS_1 | python | [] | def f_gold ( arr , n , x ) :
i = 0
while ( i < n ) :
if ( arr [ i ] == x ) :
return i
i = i + abs ( arr [ i ] - x )
print ( "number is not present!" )
return - 1
| code_translation | [
[
"[8, 7, 6, 7, 6, 5, 4, 3, 2, 3, 4, 3], 12, 3",
"7"
],
[
"[6, 90], 1, 1",
"-1"
],
[
"[1, 2, 3, 4, 5, 4], 6, 5",
"4"
],
[
"[97, 35, 60, 96, 3, 67, 72, 95, 55, 9, 69, 28, 15, 91, 31, 59], 15, 9",
"-1"
],
[
"[-84, -78, -74, -70, -68, -60, -56, -54, -48, -46, -28, -1... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
bool f_gold ( int n ) {
for ( int sum = 0, i = 1;
sum < n;
i += 2 ) {
sum += i;
if ( sum == n ) return true;
}
return false;
}
| [
"import math"
] | null | [] | SUM_SEQUENCE_2_22_222 | python | [] | import math
def f_gold ( n ) :
return 0.0246 * ( math.pow ( 10 , n ) - 1 - ( 9 * n ) )
| code_translation | [
[
"88",
"2.46e+86"
],
[
"79",
"2.46e+77"
],
[
"7",
"245998.42560000002"
],
[
"36",
"2.46e+34"
],
[
"23",
"2.46e+21"
],
[
"10",
"245999997.7614"
],
[
"27",
"2.46e+25"
],
[
"30",
"2.46e+28"
],
[
"71",
"2.46e+69"
... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int n ) {
int result = 0;
for ( int i = 2;
i <= sqrt ( n );
i ++ ) {
if ( n % i == 0 ) {
if ( i == ( n / i ) ) result += i;
else result += ( i + n / i );
}
}
return ( result + n + 1 );
}
| [] | null | [] | MAXIMUM_PRODUCT_SUBARRAY_ADDED_NEGATIVE_PRODUCT_CASE | python | [] | def f_gold ( arr , n ) :
ans = - float ( 'inf' )
maxval = 1
minval = 1
for i in range ( 0 , n ) :
if arr [ i ] > 0 :
maxval = maxval * arr [ i ]
minval = min ( 1 , minval * arr [ i ] )
elif arr [ i ] == 0 :
minval = 1
maxval = 0
elif arr [ i ] < 0 :
prevMax = maxval
maxval = minval * arr [ i ]
minval = prevMax * arr [ i ]
ans = max ( ans , maxval )
if maxval <= 0 :
maxval = 1
return ans
| code_translation | [
[
"[19, 25, 34, 39, 41, 51, 52, 53, 54, 56, 64, 67, 72, 87, 92, 93, 95], 15",
"27123549323123287660953600"
],
[
"[10], 0",
"-inf"
],
[
"[0, 0, 0, 0, 0, 0, 1, 1], 5",
"0"
],
[
"[84, 81, 14, 15, 34, 52, 54, 1, 16, 65, 54, 71, 15, 40, 53, 35, 62, 84, 81, 85, 28, 90, 74, 97, 64, ... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
bool f_gold ( string str ) {
int l = 0;
int h = str . length ( ) - 1;
while ( h > l ) if ( str [ l ++ ] != str [ h -- ] ) return false;
return true;
}
| [] | null | [] | CHECK_IF_X_CAN_GIVE_CHANGE_TO_EVERY_PERSON_IN_THE_QUEUE | python | [] | def f_gold ( notes , n ) :
fiveCount = 0
tenCount = 0
for i in range ( n ) :
if ( notes [ i ] == 5 ) :
fiveCount += 1
elif ( notes [ i ] == 10 ) :
if ( fiveCount > 0 ) :
fiveCount -= 1
tenCount += 1
else :
return 0
else :
if ( fiveCount > 0 and tenCount > 0 ) :
fiveCount -= 1
tenCount -= 1
elif ( fiveCount >= 3 ) :
fiveCount -= 3
else :
return 0
return 1
| code_translation | [
[
"[5, 5, 5, 10, 20], 4",
"1"
],
[
"[5, 5, 5, 20, 10], 5",
"0"
],
[
"[5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10], 27",
"1"
],
[
"[10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 18], 12",
... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
long long int f_gold ( int n ) {
int N = 10;
long long count = 1;
for ( int i = 1;
i <= n;
i ++ ) {
count *= ( N + i - 1 );
count /= i;
}
return count;
}
| [] | null | [] | MINIMUM_LENGTH_SUBARRAY_SUM_GREATER_GIVEN_VALUE | python | [] | def f_gold ( arr , n , x ) :
curr_sum = 0
min_len = n + 1
start = 0
end = 0
while ( end < n ) :
while ( curr_sum <= x and end < n ) :
curr_sum += arr [ end ]
end += 1
while ( curr_sum > x and start < n ) :
if ( end - start < min_len ) :
min_len = end - start
curr_sum -= arr [ start ]
start += 1
return min_len
| code_translation | [
[
"[6, 11, 11, 14, 18, 19, 21, 22, 22, 23, 26, 27, 28, 28, 29, 30, 31, 34, 39, 42, 42, 44, 45, 49, 49, 53, 57, 61, 65, 66, 67, 70, 71, 73, 74, 74, 78, 85, 88, 94, 95, 97], 37, 23",
"1"
],
[
"[-30, -22, -66, -80, 18, -64, -28, -46, 94, 60, -64, 2, 26, -94, 58, 56, 56, 88, 50, -78, -12, 68, 54, -78, 4... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
string f_gold ( string str ) {
int n = str . length ( );
string arr [ n ];
string concat = str + str;
for ( int i = 0;
i < n;
i ++ ) arr [ i ] = concat . substr ( i, n );
sort ( arr, arr + n );
return arr [ 0 ];
}
| [] | null | [] | NEXT_HIGHER_NUMBER_WITH_SAME_NUMBER_OF_SET_BITS | python | [] | def f_gold ( x ) :
next = 0
if ( x ) :
rightOne = x & - ( x )
nextHigherOneBit = x + int ( rightOne )
rightOnesPattern = x ^ int ( nextHigherOneBit )
rightOnesPattern = ( int ( rightOnesPattern ) / int ( rightOne ) )
rightOnesPattern = int ( rightOnesPattern ) >> 2
next = nextHigherOneBit | rightOnesPattern
return next
| code_translation | [
[
"42",
"44"
],
[
"75",
"77"
],
[
"94",
"103"
],
[
"5",
"6"
],
[
"52",
"56"
],
[
"22",
"25"
],
[
"77",
"78"
],
[
"44",
"49"
],
[
"85",
"86"
],
[
"59",
"61"
]
] | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
bool f_gold ( unsigned int n, unsigned int k ) {
bool oneSeen = false;
while ( n > 0 ) {
int digit = n % k;
if ( digit > 1 ) return false;
if ( digit == 1 ) {
if ( oneSeen ) return false;
oneSeen = true;
}
n /= k;
}
return true;
}
| [] | null | [] | SEARCH_INSERT_AND_DELETE_IN_A_SORTED_ARRAY_1 | python | [] | def f_gold ( arr , n , key , capacity ) :
if ( n >= capacity ) :
return n
i = n - 1
while i >= 0 and arr [ i ] > key :
arr [ i + 1 ] = arr [ i ]
i -= 1
arr [ i + 1 ] = key
return ( n + 1 )
| code_translation | [
[
"[69], 0, 0, 0",
"0"
],
[
"[-34, -38, -72, 90, -84, -40, 6, -52, -12, 80, -4, -58], 6, 6, 9",
"7"
],
[
"[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1], 13, 19, 11",
"13"
],
[
"[96, 34, 11, 1, 36, 79, 64, 75, 75, 96, 32, 18, 25, 79, 63, 80, 90, 75, 44,... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
void f_gold ( int arr [ ], int n ) {
for ( int i = 0;
i < n;
i ++ ) if ( arr [ i ] & 1 ) arr [ i ] *= - 1;
sort ( arr, arr + n );
for ( int i = 0;
i < n;
i ++ ) if ( arr [ i ] & 1 ) arr [ i ] *= - 1;
}
| [] | null | [] | CONVERT_STRICTLY_INCREASING_ARRAY_MINIMUM_CHANGES | python | [] | def f_gold ( arr , n ) :
LIS = [ 0 for i in range ( n ) ]
len = 0
for i in range ( n ) :
LIS [ i ] = 1
for i in range ( 1 , n ) :
for j in range ( i ) :
if ( arr [ i ] > arr [ j ] and ( i - j ) <= ( arr [ i ] - arr [ j ] ) ) :
LIS [ i ] = max ( LIS [ i ] , LIS [ j ] + 1 )
len = max ( len , LIS [ i ] )
return ( n - len )
| code_translation | [
[
"[1, 4, 12, 14, 15, 18, 20, 24, 25, 25, 27, 33, 34, 42, 46, 48, 49, 50, 50, 52, 55, 56, 57, 58, 64, 65, 66, 69, 72, 75, 78, 80, 84, 90, 92, 95, 99], 21",
"2"
],
[
"[-56, 6, -74, -30, 34, 40, -76, -10, -12, -86, -76, 36, -72, 82, 38, 68, 28, 84, 98, -84, 6, 16, -46, 8, 2, -18, -50, 4, -96, 88, -84,... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int arr [ ], int n, int x ) {
int i = 0;
while ( i < n ) {
if ( arr [ i ] == x ) return i;
i = i + abs ( arr [ i ] - x );
}
cout << "number is not present!";
return - 1;
}
| [] | null | [] | C_PROGRAM_FACTORIAL_NUMBER_1 | python | [] | def f_gold ( n ) :
return 1 if ( n == 1 or n == 0 ) else n * f_gold ( n - 1 ) ;
| code_translation | [
[
"15",
"1307674368000"
],
[
"7",
"5040"
],
[
"16",
"20922789888000"
],
[
"67",
"36471110918188685288249859096605464427167635314049524593701628500267962436943872000000000000000"
],
[
"71",
"8504785885678623175211676442399260102885846081207962358864307633885886... | |
transcoder-geeksforgeeks | cpp | f_gold | null | [] | null | [] | HOW_CAN_WE_SUM_THE_DIGITS_OF_A_GIVEN_NUMBER_IN_SINGLE_STATEMENT | python | [] | def f_gold(n):
sum = 0
while (n != 0):
sum = sum + int(n % 10)
n = int(n / 10)
return sum
| code_translation | [
[
"57",
"12"
],
[
"21",
"3"
],
[
"11",
"2"
],
[
"64",
"10"
],
[
"88",
"16"
],
[
"62",
"8"
],
[
"17",
"8"
],
[
"49",
"13"
],
[
"22",
"4"
],
[
"19",
"10"
]
] | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int notes [ ], int n ) {
int fiveCount = 0;
int tenCount = 0;
for ( int i = 0;
i < n;
i ++ ) {
if ( notes [ i ] == 5 ) fiveCount ++;
else if ( notes [ i ] == 10 ) {
if ( fiveCount > 0 ) {
fiveCount --;
tenCount ++;
}
else return 0;
}
else {
if ( fiveCount > 0 && tenCount > 0 ) {
fiveCount --;
tenCount --;
}
else if ( fiveCount >= 3 ) {
fiveCount -= 3;
}
else return 0;
}
}
return 1;
}
| [] | null | [] | MAXIMUM_DIFFERENCE_SUM_ELEMENTS_TWO_ROWS_MATRIX | python | [] | def f_gold(mat, m, n):
rowSum = [0] * m
for i in range(0, m):
sum = 0
for j in range(0, n):
sum += mat[i][j]
rowSum[i] = sum
max_diff = rowSum[1] - rowSum[0]
min_element = rowSum[0]
for i in range(1, m):
if (rowSum[i] - min_element > max_diff):
max_diff = rowSum[i] - min_element
if (rowSum[i] < min_element):
min_element = rowSum[i]
return max_diff
| code_translation | [
[
"[[1, 5, 5, 6, 6, 7, 7, 11, 12, 15, 17, 24, 25, 27, 30, 33, 35, 36, 38, 41, 42, 44, 44, 46, 50, 53, 53, 56, 58, 67, 71, 71, 77, 78, 85, 85, 87, 87, 89, 91, 94, 96, 97, 98, 99, 99], [1, 3, 3, 6, 7, 12, 18, 19, 21, 21, 23, 25, 25, 26, 33, 37, 38, 39, 39, 39, 41, 42, 43, 46, 49, 50, 54, 56, 57, 60, 66, 67, 67, 6... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int arr [ ], int n, int x ) {
int curr_sum = 0, min_len = n + 1;
int start = 0, end = 0;
while ( end < n ) {
while ( curr_sum <= x && end < n ) curr_sum += arr [ end ++ ];
while ( curr_sum > x && start < n ) {
if ( end - start < min_len ) min_len = end - start;
curr_sum -= arr [ start ++ ];
}
}
return min_len;
}
| [] | null | [] | ADD_1_TO_A_GIVEN_NUMBER_1 | python | [] | def f_gold ( x ) :
return ( - ( ~ x ) )
| code_translation | [
[
"20",
"21"
],
[
"68",
"69"
],
[
"52",
"53"
],
[
"61",
"62"
],
[
"3",
"4"
],
[
"88",
"89"
],
[
"41",
"42"
],
[
"78",
"79"
],
[
"94",
"95"
],
[
"18",
"19"
]
] | |
transcoder-geeksforgeeks | cpp | f_gold | null | [] | null | [] | FIND_THE_NUMBER_OCCURRING_ODD_NUMBER_OF_TIMES | python | [] | def f_gold ( arr , arr_size ) :
for i in range ( 0 , arr_size ) :
count = 0
for j in range ( 0 , arr_size ) :
if arr [ i ] == arr [ j ] :
count += 1
if ( count % 2 != 0 ) :
return arr [ i ]
return - 1
| code_translation | [
[
"[1, 5, 5, 8, 14, 15, 17, 17, 18, 23, 23, 25, 26, 35, 36, 39, 51, 53, 56, 56, 60, 62, 64, 64, 65, 66, 67, 68, 71, 75, 80, 82, 83, 88, 89, 91, 91, 92, 93, 95, 99], 31",
"1"
],
[
"[-56, 98, 44, 30, -88, 18, 60, 86, 4, 16, 10, 64, -22, -86, -66, -16, 70, -44, 98, 78, -96, -66, 92, 10, 40, -16], 19",
... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int arr [ ], int n, int key, int capacity ) {
if ( n >= capacity ) return n;
int i;
for ( i = n - 1;
( i >= 0 && arr [ i ] > key );
i -- ) arr [ i + 1 ] = arr [ i ];
arr [ i + 1 ] = key;
return ( n + 1 );
}
| [
"import math"
] | null | [] | FIND_HARMONIC_MEAN_USING_ARITHMETIC_MEAN_GEOMETRIC_MEAN | python | [] | import math
def f_gold ( a , b ) :
AM = ( a + b ) / 2
GM = math.sqrt ( a * b )
HM = ( GM * GM ) / AM
return HM
| code_translation | [
[
"54, 83",
"65.43065693430657"
],
[
"42, 56",
"48.0"
],
[
"63, 12",
"20.16"
],
[
"19, 76",
"30.4"
],
[
"41, 50",
"45.054945054945065"
],
[
"7, 26",
"11.030303030303031"
],
[
"39, 42",
"40.444444444444436"
],
[
"11, 64",
"18... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int arr [ ], int n ) {
int LIS [ n ], len = 0;
for ( int i = 0;
i < n;
i ++ ) LIS [ i ] = 1;
for ( int i = 1;
i < n;
i ++ ) {
for ( int j = 0;
j < i;
j ++ ) {
if ( arr [ i ] > arr [ j ] && ( i - j ) <= ( arr [ i ] - arr [ j ] ) ) {
LIS [ i ] = max ( LIS [ i ], LIS [ j ] + 1 );
}
}
len = max ( len, LIS [ i ] );
}
return n - len;
}
| [] | null | [] | COUNT_ARRAYS_CONSECUTIVE_ELEMENT_DIFFERENT_VALUES | python | [] | def f_gold ( n , k , x ) :
dp = list ( )
dp.append ( 0 )
dp.append ( 1 )
i = 2
while i < n :
dp.append ( ( k - 2 ) * dp [ i - 1 ] + ( k - 1 ) * dp [ i - 2 ] )
i = i + 1
return ( ( k - 1 ) * dp [ n - 2 ] if x == 1 else dp [ n - 1 ] )
| code_translation | [
[
"9, 40, 38",
"133800231512"
],
[
"97, 47, 30",
"89671406862315685055360683674715047313099865006147904991231572076986389612686188954407901709775302209106882089784288094845061238471780647269618285561149307185"
],
[
"16, 28, 13",
"105511168091101203523"
],
[
"16, 82, 70",
... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
unsigned int f_gold ( unsigned int n ) {
int res = 1, i;
for ( i = 2;
i <= n;
i ++ ) res *= i;
return res;
}
| [] | null | [] | SUM_TWO_LARGE_NUMBERS | python | [] | def f_gold(str1, str2):
if (len(str1) > len(str2)):
t = str1
str1 = str2
str2 = t
str = ""
n1 = len(str1)
n2 = len(str2)
str1 = str1[:: - 1]
str2 = str2[:: - 1]
carry = 0
for i in range(n1):
sum = ((ord(str1[i]) - 48) + ((ord(str2[i]) - 48) + carry))
str += chr(sum % 10 + 48)
carry = int(sum / 10)
for i in range(n1, n2):
sum = ((ord(str2[i]) - 48) + carry)
str += chr(sum % 10 + 48)
carry = (int)(sum / 10)
if (carry):
str += chr(carry + 48)
str = str[:: - 1]
return str
| code_translation | [
[
"'VkfzrPG', 'rKZ'",
"'44527855'"
],
[
"'0526110506447', '903'",
"'0526110507350'"
],
[
"'011010010', '110100000'",
"'121110010'"
],
[
"'sPAwZACc ', 'liYMsojPiinOV'",
"'66153436372942'"
],
[
"'3', '611'",
"'614'"
],
[
"'0101', '01110101011'",
"'01... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int arr [ ], int n ) {
int sum = 0;
int leftsum = 0;
for ( int i = 0;
i < n;
++ i ) sum += arr [ i ];
for ( int i = 0;
i < n;
++ i ) {
sum -= arr [ i ];
if ( leftsum == sum ) return i;
leftsum += arr [ i ];
}
return - 1;
}
| [] | null | [] | COUNT_NUMBER_OF_SOLUTIONS_OF_X2_1_MOD_P_IN_GIVEN_RANGE | python | [] | def f_gold ( n , p ) :
ans = 0 ;
for x in range ( 1 , p ) :
if ( ( x * x ) % p == 1 ) :
last = x + p * ( n / p ) ;
if ( last > n ) :
last -= p ;
ans += ( ( last - x ) / p + 1 ) ;
return int ( ans ) ;
| code_translation | [
[
"94, 36",
"10"
],
[
"11, 79",
"0"
],
[
"88, 63",
"5"
],
[
"85, 43",
"3"
],
[
"74, 89",
"1"
],
[
"96, 33",
"11"
],
[
"49, 51",
"3"
],
[
"50, 24",
"16"
],
[
"21, 26",
"1"
],
[
"81, 19",
"8"
]
] | |
transcoder-geeksforgeeks | cpp | f_gold | null | [] | null | [] | MAXIMUM_SUM_2_X_N_GRID_NO_TWO_ELEMENTS_ADJACENT | python | [] | def f_gold ( grid , n ) :
incl = max ( grid [ 0 ] [ 0 ] , grid [ 1 ] [ 0 ] )
excl = 0
for i in range ( 1 , n ) :
excl_new = max ( excl , incl )
incl = excl + max ( grid [ 0 ] [ i ] , grid [ 1 ] [ i ] )
excl = excl_new
return max ( excl , incl )
| code_translation | [
[
"[[6, 10, 23, 28, 35, 55, 91], [11, 14, 15, 54, 55, 62, 81], [18, 26, 40, 43, 47, 89, 93], [3, 11, 19, 53, 65, 82, 92], [14, 32, 43, 44, 51, 77, 83], [6, 6, 30, 30, 33, 73, 74], [2, 2, 10, 61, 70, 81, 84]], 3",
"34"
],
[
"[[-28, -20, -60, 92, 12, -66, 20, -22, 72, -90, 30, 90, -64, 38, 24, 78, 42,... | |
transcoder-geeksforgeeks | cpp | f_gold | null | [] | null | [] | SUM_OF_ALL_ELEMENTS_UP_TO_NTH_ROW_IN_A_PASCALS_TRIANGLE_1 | python | [] | def f_gold ( n ) :
sum = 0
sum = 1 << n ;
return ( sum - 1 )
| code_translation | [
[
"53",
"9007199254740991"
],
[
"3",
"7"
],
[
"28",
"268435455"
],
[
"44",
"17592186044415"
],
[
"84",
"19342813113834066795298815"
],
[
"83",
"9671406556917033397649407"
],
[
"46",
"70368744177663"
],
[
"3",
"7"
],
[
... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int x ) {
return ( - ( ~ x ) );
}
| [] | null | [] | FUNCTION_COPY_STRING_ITERATIVE_RECURSIVE_1 | python | [] | def f_gold ( s1 , s2 , index ) :
s2 [ index ] = s1 [ index ] ;
if ( index == len ( s1 ) - 1 ) :
return ;
f_gold ( s1 , s2 , index + 1 ) ;
| code_translation | [
[
"['v'], ['v'], 0",
"None"
],
[
"['6', '8', '3', '3', '5', '2', '5', '6', '9', '9', '2', '6', '2', '1', '9', '3', '7'], ['8', '6', '0', '2', '8', '0', '8', '7', '0', '5', '4', '6', '2', '1', '9', '3', '7'], 11",
"None"
],
[
"['0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int arr [ ], int arr_size ) {
for ( int i = 0;
i < arr_size;
i ++ ) {
int count = 0;
for ( int j = 0;
j < arr_size;
j ++ ) {
if ( arr [ i ] == arr [ j ] ) count ++;
}
if ( count % 2 != 0 ) return arr [ i ];
}
return - 1;
}
| [] | null | [] | PROGRAM_FOR_FACTORIAL_OF_A_NUMBER | python | [] | def f_gold ( n ) :
return 1 if ( n == 1 or n == 0 ) else n * f_gold ( n - 1 ) ;
| code_translation | [
[
"79",
"894618213078297528685144171539831652069808216779571907213868063227837990693501860533361810841010176000000000000000000"
],
[
"95",
"10329978488239059262599702099394727095397746340117372869212250571234293987594703124871765375385424468563282236864226607350415360000000000000000000000"
],
... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
double f_gold ( int a, int b ) {
double AM, GM, HM;
AM = ( a + b ) / 2;
GM = sqrt ( a * b );
HM = ( GM * GM ) / AM;
return HM;
}
| [] | null | [] | COUNT_NUMBERS_THAT_DONT_CONTAIN_3 | python | [] | def f_gold ( n ) :
if n < 3 :
return n
elif n >= 3 and n < 10 :
return n - 1
po = 1
while n / po > 9 :
po = po * 10
msd = n / po
if msd != 3 :
return f_gold ( msd ) * f_gold ( po - 1 ) + f_gold ( msd ) + f_gold ( n % po )
else :
return f_gold ( msd * po - 1 )
| code_translation | [
[
"85",
"71.5"
],
[
"86",
"73.39999999999999"
],
[
"3",
"2"
],
[
"35",
"26.5"
],
[
"59",
"52.1"
],
[
"38",
"32.2"
],
[
"33",
"22.7"
],
[
"15",
"17.5"
],
[
"75",
"62.5"
],
[
"74",
"60.6"
]
] | |
transcoder-geeksforgeeks | cpp | f_gold | null | [] | null | [] | FIND_INDEX_OF_AN_EXTRA_ELEMENT_PRESENT_IN_ONE_SORTED_ARRAY_1 | python | [] | def f_gold ( arr1 , arr2 , n ) :
index = n
left = 0
right = n - 1
while ( left <= right ) :
mid = ( int ) ( ( left + right ) / 2 )
if ( arr2 [ mid ] == arr1 [ mid ] ) :
left = mid + 1
else :
index = mid
right = mid - 1
return index
| code_translation | [
[
"[7, 18, 19, 25, 26, 27, 31, 39, 44, 46, 59, 60, 66, 72, 78, 83, 84, 92, 94], [2, 5, 12, 13, 17, 20, 22, 46, 51, 63, 64, 66, 66, 76, 87, 87, 90, 91, 96], 11",
"0"
],
[
"[-14, -56, 92, -90, 96, -84, 64, -38, -20, 84, 56, 92, 18, -78, 98, -96, -60, 88, -52, -28, 30, -90, 14, 76, 56, 20, -18, -94, -8... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
string f_gold ( string str1, string str2 ) {
if ( str1 . length ( ) > str2 . length ( ) ) swap ( str1, str2 );
string str = "";
int n1 = str1 . length ( ), n2 = str2 . length ( );
reverse ( str1 . begin ( ), str1 . end ( ) );
reverse ( str2 . begin ( ), str2 . end ( ) );
int carry = 0;
for ( int i = 0;
i < n1;
i ++ ) {
int sum = ( ( str1 [ i ] - '0' ) + ( str2 [ i ] - '0' ) + carry );
str . push_back ( sum % 10 + '0' );
carry = sum / 10;
}
for ( int i = n1;
i < n2;
i ++ ) {
int sum = ( ( str2 [ i ] - '0' ) + carry );
str . push_back ( sum % 10 + '0' );
carry = sum / 10;
}
if ( carry ) str . push_back ( carry + '0' );
reverse ( str . begin ( ), str . end ( ) );
return str;
}
| [] | null | [] | PAIR_WITH_GIVEN_PRODUCT_SET_1_FIND_IF_ANY_PAIR_EXISTS_1 | python | [] | def f_gold(arr, n, x):
if n < 2:
return False
s = set()
for i in range(0, n):
if arr[i] == 0:
if x == 0:
return True
else:
continue
if x % arr[i] == 0:
if x // arr[i] in s:
return True
s.add(arr[i])
return False
| code_translation | [
[
"[1, 2, 3, 7, 23, 23, 25, 27, 37, 42, 53, 56, 58, 61, 69, 78, 79, 84, 85, 86, 90, 93, 95], 15, 17",
"False"
],
[
"[-10, -18, 88, -36, 78, 66, -70, -34, -88, -98, -70, -4, -94, -92, -76, -78, -30, -48, -72, 86, -64, 38, -80, 20, 70, -32, -90, 74, -78, 12, -54, 88, 38, -96, 28], 17, 22",
"False"... | |
transcoder-geeksforgeeks | cpp | f_gold | null | [] | null | [] | FIND_MINIMUM_DIFFERENCE_PAIR_1 | python | [] | def f_gold ( arr , n ) :
arr = sorted ( arr )
diff = 10 ** 20
for i in range ( n - 1 ) :
if arr [ i + 1 ] - arr [ i ] < diff :
diff = arr [ i + 1 ] - arr [ i ]
return diff
| code_translation | [
[
"[3, 25, 44, 46, 54, 60, 81], 3",
"19"
],
[
"[82, 68, -98, -66, -36, -42, 98, -38, 58, -6, -28, 70, -24, 18, 16, 10, 92, 44, 28, -96, -72, 24, 28, -80, -4, 38, 88, 76], 22",
"0"
],
[
"[1, 1, 1], 2",
"0"
],
[
"[87, 25, 80, 45, 44, 20, 48, 47, 51, 54, 68, 47, 89, 95, 15, 29, ... | |
transcoder-geeksforgeeks | cpp | f_gold | null | [
"import sys"
] | null | [] | FIND_MAXIMUM_PRODUCT_OF_A_TRIPLET_IN_ARRAY | python | [] | import sys
def f_gold ( arr , n ) :
if n < 3 :
return - 1
max_product = - ( sys.maxsize - 1 )
for i in range ( 0 , n - 2 ) :
for j in range ( i + 1 , n - 1 ) :
for k in range ( j + 1 , n ) :
max_product = max ( max_product , arr [ i ] * arr [ j ] * arr [ k ] )
return max_product
| code_translation | [
[
"[41, 66, 77], 2",
"-1"
],
[
"[92, -34, -36, -50, 20, -94, 2, -86, 22, -50, 74, 84, 52, -84, 98, -50, 88, 26, -36, -36, 6, -50, -48, -84, 38, -96, -62, 34, 52, 92, 40, -84, 18, -90, 54, -38, -74, -98, -8, -92, -60, 86, -36, 94, 56], 40",
"921984"
],
[
"[0, 0, 1], 1",
"-1"
],
[
... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
long long int f_gold ( int n ) {
long long int sum = 0;
sum = 1 << n;
return ( sum - 1 );
}
| [] | null | [] | COUNT_SET_BITS_IN_AN_INTEGER_1 | python | [] | def f_gold ( n ) :
if ( n == 0 ) :
return 0
else :
return ( n & 1 ) + f_gold ( n >> 1 )
| code_translation | [
[
"43",
"4"
],
[
"94",
"5"
],
[
"72",
"2"
],
[
"86",
"4"
],
[
"42",
"3"
],
[
"33",
"2"
],
[
"8",
"1"
],
[
"74",
"3"
],
[
"29",
"4"
],
[
"34",
"2"
]
] | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
void f_gold ( char s1 [ ], char s2 [ ], int index = 0 ) {
s2 [ index ] = s1 [ index ];
if ( s1 [ index ] == '\0' ) return;
f_gold ( s1, s2, index + 1 );
}
| [
"import math"
] | null | [] | COUNT_SUM_OF_DIGITS_IN_NUMBERS_FROM_1_TO_N | python | [] | import math
def f_gold ( n ) :
if ( n < 10 ) :
return ( n * ( n + 1 ) / 2 )
d = ( int ) ( math.log10 ( n ) )
a = [ 0 ] * ( d + 1 )
a [ 0 ] = 0
a [ 1 ] = 45
for i in range ( 2 , d + 1 ) :
a [ i ] = a [ i - 1 ] * 10 + 45 * ( int ) ( math.ceil ( math.pow ( 10 , i - 1 ) ) )
p = ( int ) ( math.ceil ( math.pow ( 10 , d ) ) )
msd = n // p
return ( int ) ( msd * a [ d ] + ( msd * ( msd - 1 ) // 2 ) * p + msd * ( 1 + n % p ) + f_gold ( n % p ) )
| code_translation | [
[
"29",
"165"
],
[
"97",
"865"
],
[
"71",
"540"
],
[
"82",
"667"
],
[
"69",
"525"
],
[
"30",
"168"
],
[
"82",
"667"
],
[
"32",
"177"
],
[
"77",
"609"
],
[
"39",
"240"
]
] | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
unsigned int f_gold ( unsigned int n ) {
if ( n == 0 ) return 1;
return n * f_gold ( n - 1 );
}
| [] | null | [] | FIND_FIRST_NATURAL_NUMBER_WHOSE_FACTORIAL_DIVISIBLE_X | python | [] | def f_gold ( x ) :
i = 1 ;
fact = 1 ;
for i in range ( 1 , x ) :
fact = fact * i
if ( fact % x == 0 ) :
break
return i
| code_translation | [
[
"67",
"66"
],
[
"47",
"46"
],
[
"57",
"19"
],
[
"89",
"88"
],
[
"67",
"66"
],
[
"40",
"5"
],
[
"16",
"6"
],
[
"83",
"82"
],
[
"93",
"31"
],
[
"43",
"42"
]
] | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int n ) {
if ( n < 3 ) return n;
if ( n >= 3 && n < 10 ) return n - 1;
int po = 1;
while ( n / po > 9 ) po = po * 10;
int msd = n / po;
if ( msd != 3 ) return f_gold ( msd ) * f_gold ( po - 1 ) + f_gold ( msd ) + f_gold ( n % po );
else return f_gold ( msd * po - 1 );
}
| [] | null | [] | MAXIMUM_SUBSEQUENCE_SUM_SUCH_THAT_NO_THREE_ARE_CONSECUTIVE | python | [] | def f_gold ( arr , n ) :
sum = [ 0 for k in range ( n ) ]
if n >= 1 :
sum [ 0 ] = arr [ 0 ]
if n >= 2 :
sum [ 1 ] = arr [ 0 ] + arr [ 1 ]
if n > 2 :
sum [ 2 ] = max ( sum [ 1 ] , max ( arr [ 1 ] + arr [ 2 ] , arr [ 0 ] + arr [ 2 ] ) )
for i in range ( 3 , n ) :
sum [ i ] = max ( max ( sum [ i - 1 ] , sum [ i - 2 ] + arr [ i ] ) , arr [ i ] + arr [ i - 1 ] + sum [ i - 3 ] )
return sum [ n - 1 ]
| code_translation | [
[
"[5, 6, 8, 9, 10, 10, 16, 17, 17, 20, 21, 22, 23, 28, 29, 32, 36, 37, 40, 41, 42, 43, 47, 47, 48, 48, 49, 49, 52, 52, 53, 59, 61, 64, 65, 79, 79, 81, 87, 91, 92, 98], 35",
"832"
],
[
"[98, 76, -80, -30, 82, 52, -14, 28, 98, 18, 82, 52, 26, -62, -8], 7",
"308"
],
[
"[0, 0, 0, 0, 0, 1, 1... | |
transcoder-geeksforgeeks | cpp | f_gold | null | [
"import math"
] | null | [] | K_TH_PRIME_FACTOR_GIVEN_NUMBER | python | [] | import math
def f_gold ( n , k ) :
while ( n % 2 == 0 ) :
k = k - 1
n = n / 2
if ( k == 0 ) :
return 2
i = 3
while i <= math.sqrt ( n ) :
while ( n % i == 0 ) :
if ( k == 1 ) :
return i
k = k - 1
n = n / i
i = i + 2
if ( n > 2 and k == 1 ) :
return n
return - 1
| code_translation | [
[
"94, 0",
"-1"
],
[
"99, 1",
"3"
],
[
"64, 3",
"2"
],
[
"27, 3",
"3"
],
[
"24, 4",
"3.0"
],
[
"84, 6",
"-1"
],
[
"69, 98",
"-1"
],
[
"69, 39",
"-1"
],
[
"22, 60",
"-1"
],
[
"39, 57",
"-1"
]
] | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int arr1 [ ], int arr2 [ ], int n ) {
int index = n;
int left = 0, right = n - 1;
while ( left <= right ) {
int mid = ( left + right ) / 2;
if ( arr2 [ mid ] == arr1 [ mid ] ) left = mid + 1;
else {
index = mid;
right = mid - 1;
}
}
return index;
}
| [] | null | [] | MAXIMUM_SUM_PAIRS_SPECIFIC_DIFFERENCE_1 | python | [] | def f_gold ( arr , N , k ) :
maxSum = 0 ;
arr.sort ( ) ;
i = N - 1 ;
while ( i >= 0 ) :
if ( arr [ i ] - arr [ i - 1 ] < k ) :
maxSum += arr [ i ] ;
maxSum += arr [ i - 1 ] ;
i -= 1 ;
i -= 1 ;
return maxSum ;
| code_translation | [
[
"[2, 10, 11, 11, 12, 14, 15, 17, 27, 27, 28, 36, 36, 44, 47, 47, 54, 55, 62, 64, 68, 69, 70, 70, 75, 76, 78, 85, 85, 91, 95, 97], 26, 18",
"1047"
],
[
"[-98, -92, -86, -84, -72, -70, -70, -66, -62, -50, -44, -40, -36, -34, -30, -14, -12, -8, -4, -2, 2, 2, 10, 10, 30, 30, 36, 40, 58, 78, 78, 82, 88... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
bool f_gold ( int arr [ ], int n, int x ) {
if ( n < 2 ) return false;
unordered_set < int > s;
for ( int i = 0;
i < n;
i ++ ) {
if ( arr [ i ] == 0 ) {
if ( x == 0 ) return true;
else continue;
}
if ( x % arr [ i ] == 0 ) {
if ( s . find ( x / arr [ i ] ) != s . end ( ) ) return true;
s . insert ( arr [ i ] );
}
}
return false;
}
| [] | null | [] | COUNT_PALINDROMIC_SUBSEQUENCE_GIVEN_STRING | python | [] | def f_gold ( str ) :
N = len ( str )
cps = [ [ 0 for i in range ( N + 2 ) ] for j in range ( N + 2 ) ]
for i in range ( N ) :
cps [ i ] [ i ] = 1
for L in range ( 2 , N + 1 ) :
for i in range ( N ) :
k = L + i - 1
if ( k < N ) :
if ( str [ i ] == str [ k ] ) :
cps [ i ] [ k ] = ( cps [ i ] [ k - 1 ] + cps [ i + 1 ] [ k ] + 1 )
else :
cps [ i ] [ k ] = ( cps [ i ] [ k - 1 ] + cps [ i + 1 ] [ k ] - cps [ i + 1 ] [ k - 1 ] )
return cps [ 0 ] [ N - 1 ]
| code_translation | [
[
"'R'",
"1"
],
[
"'2956350'",
"10"
],
[
"'11100111110101'",
"2798"
],
[
"'TZTDLIIfAD'",
"20"
],
[
"'98'",
"2"
],
[
"'1100100001'",
"270"
],
[
"'oKwGeatf'",
"8"
],
[
"'19'",
"2"
],
[
"'00010110100'",
"563"
],
... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int arr [ ], int n ) {
sort ( arr, arr + n );
int diff = INT_MAX;
for ( int i = 0;
i < n - 1;
i ++ ) if ( arr [ i + 1 ] - arr [ i ] < diff ) diff = arr [ i + 1 ] - arr [ i ];
return diff;
}
| [] | null | [] | SUM_MATRIX_ELEMENT_ABSOLUTE_DIFFERENCE_ROW_COLUMN_NUMBERS_2 | python | [] | def f_gold ( n ) :
n -= 1
sum = 0
sum += ( n * ( n + 1 ) ) / 2
sum += ( n * ( n + 1 ) * ( 2 * n + 1 ) ) / 6
return int ( sum )
| code_translation | [
[
"12",
"572"
],
[
"89",
"234960"
],
[
"76",
"146300"
],
[
"2",
"2"
],
[
"81",
"177120"
],
[
"11",
"440"
],
[
"26",
"5850"
],
[
"35",
"14280"
],
[
"16",
"1360"
],
[
"66",
"95810"
]
] | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int arr [ ], int n ) {
if ( n < 3 ) return - 1;
int max_product = INT_MIN;
for ( int i = 0;
i < n - 2;
i ++ ) for ( int j = i + 1;
j < n - 1;
j ++ ) for ( int k = j + 1;
k < n;
k ++ ) max_product = max ( max_product, arr [ i ] * arr [ j ] * arr [ k ] );
return max_product;
}
| [] | null | [] | SORT_ARRAY_TWO_HALVES_SORTED | python | [] | def f_gold ( A , n ) :
A.sort ( )
| code_translation | [
[
"[2, 3, 11, 13, 18, 24, 26, 30, 31, 34, 42, 43, 43, 44, 44, 47, 49, 52, 53, 55, 56, 57, 58, 58, 60, 64, 66, 67, 69, 70, 70, 71, 74, 76, 77, 82, 85, 89, 90, 96, 98], 33",
"None"
],
[
"[-95, -92, -88, -84, -81, -80, -78, -77, -75, -74, -74, -73, -70, -67, -60, -43, -28, -28, -27, -25, -17, -4, -3, -... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int n ) {
if ( n == 0 ) return 0;
else return ( n & 1 ) + f_gold ( n >> 1 );
}
| [] | null | [] | FIND_THE_MINIMUM_DISTANCE_BETWEEN_TWO_NUMBERS | python | [] | def f_gold ( arr , n , x , y ) :
min_dist = 99999999
for i in range ( n ) :
for j in range ( i + 1 , n ) :
if ( x == arr [ i ] and y == arr [ j ] or y == arr [ i ] and x == arr [ j ] ) and min_dist > abs ( i - j ) :
min_dist = abs ( i - j )
return min_dist
| code_translation | [
[
"[4, 7, 7, 8, 11, 14, 16, 25, 34, 35, 36, 36, 38, 40, 41, 43, 45, 47, 57, 60, 64, 72, 73, 74, 75, 82, 83, 83, 84, 84, 84, 92], 22, 7, 40",
"99999999"
],
[
"[96, 70, 88, -64, -42, 58, 92, 66, -14, 90, -66, 12, 88, -12, 48, -4, 90, 24, 98, 14, 32, 38, 98, 78, 2, 26, 12, -36, 90, 80, 40, 58, 88, 64, ... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int n ) {
if ( n < 10 ) return n * ( n + 1 ) / 2;
int d = log10 ( n );
int * a = new int [ d + 1 ];
a [ 0 ] = 0, a [ 1 ] = 45;
for ( int i = 2;
i <= d;
i ++ ) a [ i ] = a [ i - 1 ] * 10 + 45 * ceil ( pow ( 10, i - 1 ) );
int p = ceil ( pow ( 10, d ) );
int msd = n / p;
return msd * a [ d ] + ( msd * ( msd - 1 ) / 2 ) * p + msd * ( 1 + n % p ) + f_gold ( n % p );
}
| [] | null | [] | WRITE_ONE_LINE_C_FUNCTION_TO_FIND_WHETHER_A_NO_IS_POWER_OF_TWO | python | [] | def f_gold(n):
if (n == 0):
return False
while (n != 1):
if (n % 2 != 0):
return False
n = n // 2
return True
| code_translation | [
[
"1",
"True"
],
[
"2",
"True"
],
[
"8",
"True"
],
[
"1024",
"True"
],
[
"24",
"False"
],
[
"7",
"False"
],
[
"46",
"False"
],
[
"61",
"False"
],
[
"73",
"False"
],
[
"66",
"False"
]
] | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int x ) {
int i = 1;
int fact = 1;
for ( i = 1;
i < x;
i ++ ) {
fact = fact * i;
if ( fact % x == 0 ) break;
}
return i;
}
| [] | null | [] | MINIMUM_XOR_VALUE_PAIR | python | [] | def f_gold ( arr , n ) :
arr.sort ( ) ;
min_xor = 999999
val = 0
for i in range ( 0 , n - 1 ) :
for j in range ( i + 1 , n - 1 ) :
val = arr [ i ] ^ arr [ j ]
min_xor = min ( min_xor , val )
return min_xor
| code_translation | [
[
"[4, 5, 7, 10, 10, 11, 14, 19, 21, 24, 27, 27, 27, 28, 28, 28, 33, 34, 41, 42, 43, 48, 52, 53, 53, 59, 62, 64, 66, 71, 77, 78, 78, 79, 80, 82, 90, 97, 99, 99], 34",
"0"
],
[
"[-96, -94, -94, -84, -70, -68, -66, -64, -58, -28, -22, -16, -14, -10, -2, 0, 8, 28, 36, 42, 50, 52, 56, 56, 56, 66, 74, 80... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int arr [ ], int n ) {
int sum [ n ];
if ( n >= 1 ) sum [ 0 ] = arr [ 0 ];
if ( n >= 2 ) sum [ 1 ] = arr [ 0 ] + arr [ 1 ];
if ( n > 2 ) sum [ 2 ] = max ( sum [ 1 ], max ( arr [ 1 ] + arr [ 2 ], arr [ 0 ] + arr [ 2 ] ) );
for ( int i = 3;
i < n;
i ++ ) sum [ i ] = max ( max ( sum [ i - 1 ], sum [ i - 2 ] + arr [ i ] ), arr [ i ] + arr [ i - 1 ] + sum [ i - 3 ] );
return sum [ n - 1 ];
}
| [] | null | [] | SUM_DIVISORS_1_N_1 | python | [] | def f_gold ( n ) :
sum = 0
for i in range ( 1 , n + 1 ) :
sum += int ( n / i ) * i
return int ( sum )
| code_translation | [
[
"73",
"4406"
],
[
"41",
"1384"
],
[
"36",
"1098"
],
[
"28",
"660"
],
[
"49",
"1987"
],
[
"24",
"491"
],
[
"85",
"5977"
],
[
"59",
"2846"
],
[
"82",
"5561"
],
[
"40",
"1342"
]
] | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int n, int k ) {
while ( n % 2 == 0 ) {
k --;
n = n / 2;
if ( k == 0 ) return 2;
}
for ( int i = 3;
i <= sqrt ( n );
i = i + 2 ) {
while ( n % i == 0 ) {
if ( k == 1 ) return i;
k --;
n = n / i;
}
}
if ( n > 2 && k == 1 ) return n;
return - 1;
}
| [] | null | [] | PIZZA_CUT_PROBLEM_CIRCLE_DIVISION_LINES | python | [] | def f_gold ( n ) :
return int ( 1 + n * ( n + 1 ) / 2 )
| code_translation | [
[
"46",
"1082"
],
[
"68",
"2347"
],
[
"4",
"11"
],
[
"12",
"79"
],
[
"56",
"1597"
],
[
"14",
"106"
],
[
"81",
"3322"
],
[
"29",
"436"
],
[
"26",
"352"
],
[
"40",
"821"
]
] | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int arr [ ], int N, int k ) {
int maxSum = 0;
sort ( arr, arr + N );
for ( int i = N - 1;
i > 0;
-- i ) {
if ( arr [ i ] - arr [ i - 1 ] < k ) {
maxSum += arr [ i ];
maxSum += arr [ i - 1 ];
-- i;
}
}
return maxSum;
}
| [] | null | [] | MAXIMUM_TRIPLET_SUM_ARRAY | python | [] | def f_gold ( arr , n ) :
sm = - 1000000
for i in range ( 0 , n ) :
for j in range ( i + 1 , n ) :
for k in range ( j + 1 , n ) :
if ( sm < ( arr [ i ] + arr [ j ] + arr [ k ] ) ) :
sm = arr [ i ] + arr [ j ] + arr [ k ]
return sm
| code_translation | [
[
"[6, 10, 14, 19, 24, 29, 42, 43, 44, 47, 47, 55, 57, 59, 60, 61, 76, 76, 77, 81, 84, 92, 92, 93, 95, 97], 15",
"176"
],
[
"[-98, 72, 52, -62, 74, -26, -82, -74, 90, 58, 94, -2, 76, -28, 12, 64, -94, 86, 56, 10, 40, 20, 92, -4, -80, 26, -40, 36, 66, -46, 4, -42, -76, 76, -90, -48, 22, 30, 48, 38, 7... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( string str ) {
int N = str . length ( );
int cps [ N + 1 ] [ N + 1 ];
memset ( cps, 0, sizeof ( cps ) );
for ( int i = 0;
i < N;
i ++ ) cps [ i ] [ i ] = 1;
for ( int L = 2;
L <= N;
L ++ ) {
for ( int i = 0;
i < N;
i ++ ) {
int k = L + i - 1;
if ( str [ i ] == str [ k ] ) cps [ i ] [ k ] = cps [ i ] [ k - 1 ] + cps [ i + 1 ] [ k ] + 1;
else cps [ i ] [ k ] = cps [ i ] [ k - 1 ] + cps [ i + 1 ] [ k ] - cps [ i + 1 ] [ k - 1 ];
}
}
return cps [ 0 ] [ N - 1 ];
}
| [] | null | [] | MINIMUM_SUM_TWO_NUMBERS_FORMED_DIGITS_ARRAY | python | [] | def f_gold ( arr , n ) :
arr.sort ( )
a = 0 ; b = 0
for i in range ( n ) :
if ( i % 2 != 0 ) :
a = a * 10 + arr [ i ]
else :
b = b * 10 + arr [ i ]
return a + b
| code_translation | [
[
"[3, 4, 5, 10, 14, 16, 18, 42, 43, 43, 45, 46, 51, 52, 53, 58, 61, 66, 79, 81, 82, 84], 19",
"4183488835"
],
[
"[-90, -86, -76, -50, -46, -30, -26, -22, -22, -20, -2, -2, 8, 22, 32, 40, 48, 48, 56, 58, 60, 76, 82, 82, 94, 98], 25",
"-107220607602444"
],
[
"[0, 0, 0, 0, 0, 0, 0, 0, 0, 0... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int n ) {
n --;
int sum = 0;
sum += ( n * ( n + 1 ) ) / 2;
sum += ( n * ( n + 1 ) * ( 2 * n + 1 ) ) / 6;
return sum;
}
| [] | null | [] | LONGEST_PREFIX_ALSO_SUFFIX_1 | python | [] | def f_gold ( s ) :
n = len ( s )
lps = [ 0 ] * n
l = 0
i = 1
while ( i < n ) :
if ( s [ i ] == s [ l ] ) :
l = l + 1
lps [ i ] = l
i = i + 1
else :
if ( l != 0 ) :
l = lps [ l - 1 ]
else :
lps [ i ] = 0
i = i + 1
res = lps [ n - 1 ]
if ( res > n / 2 ) :
return n // 2
else :
return res
| code_translation | [
[
"'aabcdaabc'",
"4"
],
[
"'1372494598'",
"0"
],
[
"'110000100001'",
"1"
],
[
"'abcab'",
"2"
],
[
"'488938'",
"0"
],
[
"'011010101011'",
"3"
],
[
"'aaaa'",
"2"
],
[
"'3356203205'",
"0"
],
[
"'1010'",
"2"
],
[... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( string str ) {
int n = str . length ( );
int digitSum = 0;
for ( int i = 0;
i < n;
i ++ ) digitSum += ( str [ i ] - '0' );
return ( digitSum % 3 == 0 );
}
| [] | null | [] | SEARCHING_ARRAY_ADJACENT_DIFFER_K | python | [] | def f_gold ( arr , n , x , k ) :
i = 0
while ( i < n ) :
if ( arr [ i ] == x ) :
return i
i = i + max ( 1 , int ( abs ( arr [ i ] - x ) / k ) )
print ( "number is not present!" )
return - 1
| code_translation | [
[
"[1, 5, 9, 11, 14, 18, 19, 21, 26, 32, 38, 38, 43, 47, 49, 52, 55, 61, 65, 67, 69, 73, 74, 79, 84, 90, 91, 91, 92, 93, 94, 99], 22, 19, 26",
"6"
],
[
"[12, -86, -66, -50, -48, 78, -92, -56, -2, 66, 64], 5, 10, 5",
"-1"
],
[
"[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
void f_gold ( int A [ ], int n ) {
sort ( A, A + n );
}
| [] | null | [] | MULTIPLY_TWO_NUMBERS_WITHOUT_USING_MULTIPLY_DIVISION_BITWISE_OPERATORS_AND_NO_LOOPS | python | [] | def f_gold ( x , y ) :
if ( y == 0 ) :
return 0
if ( y > 0 ) :
return ( x + f_gold ( x , y - 1 ) )
if ( y < 0 ) :
return - f_gold ( x , - y )
| code_translation | [
[
"18, 94",
"1692"
],
[
"23, 36",
"828"
],
[
"24, 22",
"528"
],
[
"75, 92",
"6900"
],
[
"25, 43",
"1075"
],
[
"57, 32",
"1824"
],
[
"31, 57",
"1767"
],
[
"8, 17",
"136"
],
[
"12, 76",
"912"
],
[
"74, 70",... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int arr [ ], int n, int x, int y ) {
int i, j;
int min_dist = INT_MAX;
for ( i = 0;
i < n;
i ++ ) {
for ( j = i + 1;
j < n;
j ++ ) {
if ( ( x == arr [ i ] && y == arr [ j ] || y == arr [ i ] && x == arr [ j ] ) && min_dist > abs ( i - j ) ) {
min_dist = abs ( i - j );
}
}
}
return min_dist;
}
| [] | null | [] | FIND_PAIR_WITH_GREATEST_PRODUCT_IN_ARRAY | python | [] | def f_gold ( arr , n ) :
result = - 1
for i in range ( n ) :
for j in range ( n - 1 ) :
for k in range ( j + 1 , n ) :
if ( arr [ j ] * arr [ k ] == arr [ i ] ) :
result = max ( result , arr [ i ] )
return result
| code_translation | [
[
"[4, 78, 84], 2",
"-1"
],
[
"[-54, 64, 60, 14, 18, -68, -54, -58, 38, -72, -84, 46, 74, 76, 28, -2, 54, 24, 18, -74, -78, 14, -38, -70, 26, -54, -36, -96, -12, 8, 62, -42, -84, 10, -6, 36, -72, 10, 10, -20, 16, 92, -64, -34, 74, -98, 18], 26",
"76"
],
[
"[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
bool f_gold ( int n ) {
if ( n == 0 ) return 0;
while ( n != 1 ) {
if ( n % 2 != 0 ) return 0;
n = n / 2;
}
return 1;
}
| [
"import math"
] | null | [] | NUMBER_DIGITS_PRODUCT_TWO_NUMBERS_1 | python | [] | import math
def f_gold ( a , b ) :
if ( a == 0 or b == 0 ) :
return 1
return math.floor ( math.log10 ( abs ( a ) ) + math.log10 ( abs ( b ) ) ) + 1
| code_translation | [
[
"97, 91",
"4"
],
[
"52, 49",
"4"
],
[
"95, 34",
"4"
],
[
"35, 40",
"4"
],
[
"40, 85",
"4"
],
[
"18, 97",
"4"
],
[
"92, 15",
"4"
],
[
"73, 98",
"4"
],
[
"10, 62",
"3"
],
[
"82, 22",
"4"
]
] | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int arr [ ], int n ) {
int min_xor = INT_MAX;
for ( int i = 0;
i < n;
i ++ ) for ( int j = i + 1;
j < n;
j ++ ) min_xor = min ( min_xor, arr [ i ] ^ arr [ j ] );
return min_xor;
}
| [] | null | [] | COUNT_WAYS_BUILD_STREET_GIVEN_CONSTRAINTS | python | [] | def f_gold ( n ) :
dp = [ [ 0 ] * ( n + 1 ) for i in range ( 2 ) ]
dp [ 0 ] [ 1 ] = 1
dp [ 1 ] [ 1 ] = 2
for i in range ( 2 , n + 1 ) :
dp [ 0 ] [ i ] = dp [ 0 ] [ i - 1 ] + dp [ 1 ] [ i - 1 ]
dp [ 1 ] [ i ] = ( dp [ 0 ] [ i - 1 ] * 2 + dp [ 1 ] [ i - 1 ] )
return dp [ 0 ] [ n ] + dp [ 1 ] [ n ]
| code_translation | [
[
"68",
"128971066941642015967892393"
],
[
"91",
"82098090374248746619236402542311697"
],
[
"99",
"94741125149636933417873079920900017937"
],
[
"79",
"2094232192940929332692027310337"
],
[
"61",
"269812766699283348307203"
],
[
"48",
"28508776935098... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int n ) {
int sum = 0;
for ( int i = 1;
i <= n;
++ i ) sum += ( n / i ) * i;
return sum;
}
| [] | null | [] | NTH_NON_FIBONACCI_NUMBER | python | [] | def f_gold ( n ) :
prevPrev = 1
prev = 2
curr = 3
while n > 0 :
prevPrev = prev
prev = curr
curr = prevPrev + prev
n = n - ( curr - prev - 1 )
n = n + ( curr - prev - 1 )
return prev + n
| code_translation | [
[
"76",
"85"
],
[
"91",
"101"
],
[
"62",
"71"
],
[
"65",
"74"
],
[
"83",
"93"
],
[
"57",
"66"
],
[
"76",
"85"
],
[
"6",
"11"
],
[
"2",
"6"
],
[
"86",
"96"
]
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.