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 n ) {
return 1 + n * ( n + 1 ) / 2;
}
| [
"import math"
] | null | [] | PROGRAM_TO_CHECK_IF_A_GIVEN_NUMBER_IS_LUCKY_ALL_DIGITS_ARE_DIFFERENT | python | [] | import math
def f_gold ( n ) :
ar = [ 0 ] * 10
while ( n > 0 ) :
digit = math.floor ( n % 10 )
if ( ar [ digit ] ) :
return 0
ar [ digit ] = 1
n = n / 10
return 1
| code_translation | [
[
"474",
"0"
],
[
"9445",
"0"
],
[
"90",
"0"
],
[
"30",
"0"
],
[
"37453",
"0"
],
[
"27",
"0"
],
[
"2400",
"0"
],
[
"98",
"0"
],
[
"46",
"0"
],
[
"722",
"0"
]
] | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int arr [ ], int n ) {
int sum = INT_MIN;
for ( int i = 0;
i < n;
i ++ ) for ( int j = i + 1;
j < n;
j ++ ) for ( int k = j + 1;
k < n;
k ++ ) if ( sum < arr [ i ] + arr [ j ] + arr [ k ] ) sum = arr [ i ] + arr [ j ] + arr [ k ];
return sum;
}
| [
"import math"
] | null | [] | AREA_OF_A_HEXAGON | python | [] | import math
def f_gold ( s ) :
return ( ( 3 * math.sqrt ( 3 ) * ( s * s ) ) / 2 ) ;
| code_translation | [
[
"1772.6589509256596",
"8163986.207300422"
],
[
"-599.737107809315",
"934487.9989101035"
],
[
"1074.1765931782",
"2997804.1448343466"
],
[
"-1182.4087746714795",
"3632345.696441302"
],
[
"8083.035797247716",
"169746524.38794258"
],
[
"-6126.4143565654... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int arr [ ], int n ) {
sort ( arr, arr + n );
int a = 0, b = 0;
for ( int i = 0;
i < n;
i ++ ) {
if ( i & 1 ) a = a * 10 + arr [ i ];
else b = b * 10 + arr [ i ];
}
return a + b;
}
| [] | null | [] | REMOVE_ARRAY_END_ELEMENT_MAXIMIZE_SUM_PRODUCT | python | [] | def f_gold ( dp , a , low , high , turn ) :
if ( low == high ) :
return a [ low ] * turn
if ( dp [ low ] [ high ] != 0 ) :
return dp [ low ] [ high ]
dp [ low ] [ high ] = max ( a [ low ] * turn + f_gold ( dp , a , low + 1 , high , turn + 1 ) , a [ high ] * turn + f_gold ( dp , a , low , high - 1 , turn + 1 ) ) ;
return dp [ low ] [ high ]
| code_translation | [
[
"[[23, 37, 54, 57, 59, 75, 97], [9, 15, 34, 39, 80, 96, 99], [15, 25, 26, 31, 43, 47, 93], [22, 31, 37, 44, 54, 62, 91], [7, 19, 32, 56, 57, 70, 81], [16, 37, 49, 77, 81, 82, 85], [44, 48, 64, 74, 79, 89, 99]], [31, 50, 50, 68, 69, 80, 87], 6, 5, 4",
"89"
],
[
"[[-24, -34, -86, -16, -34, 14, 76, 4... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( string s ) {
int n = s . length ( );
int lps [ n ];
lps [ 0 ] = 0;
int len = 0;
int i = 1;
while ( i < n ) {
if ( s [ i ] == s [ len ] ) {
len ++;
lps [ i ] = len;
i ++;
}
else {
if ( len != 0 ) {
len = lps [ len - 1 ];
}
else {
lps [ i ] = 0;
i ++;
}
}
}
int res = lps [ n - 1 ];
return ( res > n / 2 ) ? n / 2 : res;
}
| [] | null | [] | STEINS_ALGORITHM_FOR_FINDING_GCD | python | [] | def f_gold ( a , b ) :
if ( a == 0 ) :
return b
if ( b == 0 ) :
return a
k = 0
while ( ( ( a | b ) & 1 ) == 0 ) :
a = a >> 1
b = b >> 1
k = k + 1
while ( ( a & 1 ) == 0 ) :
a = a >> 1
while ( b != 0 ) :
while ( ( b & 1 ) == 0 ) :
b = b >> 1
if ( a > b ) :
temp = a
a = b
b = temp
b = ( b - a )
return ( a << k )
| code_translation | [
[
"37, 93",
"1"
],
[
"58, 13",
"1"
],
[
"89, 27",
"1"
],
[
"75, 14",
"1"
],
[
"59, 47",
"1"
],
[
"84, 39",
"3"
],
[
"47, 76",
"1"
],
[
"37, 75",
"1"
],
[
"83, 62",
"1"
],
[
"28, 58",
"2"
]
] | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int arr [ ], int n, int x, int k ) {
int i = 0;
while ( i < n ) {
if ( arr [ i ] == x ) return i;
i = i + max ( 1, abs ( arr [ i ] - x ) / k );
}
cout << "number is not present!";
return - 1;
}
| [] | null | [] | FIND_WHETHER_GIVEN_INTEGER_POWER_3_NOT | python | [] | def f_gold ( n ) :
return 1162261467 % n == 0
| code_translation | [
[
"1",
"True"
],
[
"3",
"True"
],
[
"27",
"True"
],
[
"9",
"True"
],
[
"-9",
"True"
],
[
"11",
"False"
],
[
"57",
"False"
],
[
"21",
"False"
],
[
"60",
"False"
],
[
"44",
"False"
]
] | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int m, int n ) {
int count [ m ] [ n ];
for ( int i = 0;
i < m;
i ++ ) count [ i ] [ 0 ] = 1;
for ( int j = 0;
j < n;
j ++ ) count [ 0 ] [ j ] = 1;
for ( int i = 1;
i < m;
i ++ ) {
for ( int j = 1;
j < n;
j ++ ) count [ i ] [ j ] = count [ i - 1 ] [ j ] + count [ i ] [ j - 1 ];
}
return count [ m - 1 ] [ n - 1 ];
}
| [] | null | [] | COUNT_MINIMUM_NUMBER_SUBSETS_SUBSEQUENCES_CONSECUTIVE_NUMBERS | python | [] | def f_gold(arr, n):
x = sorted(arr)
count = 1
for i in range(0, n - 1):
if (x[i] + 1 != x[i + 1]):
count = count + 1
return count
| code_translation | [
[
"[3, 7, 7, 11, 14, 14, 14, 16, 17, 17, 21, 22, 24, 27, 27, 27, 31, 33, 35, 36, 36, 37, 38, 43, 45, 49, 52, 54, 57, 59, 59, 60, 67, 73, 74, 74, 74, 75, 75, 79, 83, 87, 90, 93, 97], 42",
"34"
],
[
"[-28, 72, 60, 62, 40, 64, 50, -36, -24, 40, -6, 78, -80, -82, 2, -30, 70, 94, -2, -30, 92, 12, -46, 32... | |
transcoder-geeksforgeeks | cpp | f_gold | null | [] | null | [] | LONGEST_REPEATING_SUBSEQUENCE | python | [] | def f_gold ( str ) :
n = len ( str )
dp = [ [ 0 ] * ( n + 1 ) ] * ( n + 1 )
for i in range ( 1 , n + 1 ) :
for j in range ( 1 , n + 1 ) :
if ( str [ i - 1 ] == str [ j - 1 ] and i != j ) :
dp [ i ] [ j ] = 1 + dp [ i - 1 ] [ j - 1 ]
else :
dp [ i ] [ j ] = max ( dp [ i ] [ j - 1 ] , dp [ i - 1 ] [ j ] )
return dp [ n ] [ n ]
| code_translation | [
[
"'JxZFz'",
"0"
],
[
"'7648992235770'",
"3"
],
[
"'11100000'",
"6"
],
[
"'cRN SgYjPsctJ'",
"1"
],
[
"'434'",
"1"
],
[
"'1'",
"0"
],
[
"'JRfZIAsbrPBZ'",
"1"
],
[
"'03779368305592'",
"3"
],
[
"'1111000'",
"5"
]... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int a [ ], int n ) {
sort ( a, a + n );
int count = 1;
int answer = 0;
for ( int i = 1;
i < n;
i ++ ) {
if ( a [ i ] == a [ i - 1 ] ) {
count += 1;
}
else {
answer = answer + ( count * ( count - 1 ) ) / 2;
count = 1;
}
}
answer = answer + ( count * ( count - 1 ) ) / 2;
return answer;
}
| [] | null | [] | FAST_MULTIPLICATION_METHOD_WITHOUT_USING_MULTIPLICATION_OPERATOR_RUSSIAN_PEASANTS_ALGORITHM | python | [] | def f_gold ( a , b ) :
res = 0
while ( b > 0 ) :
if ( b & 1 ) :
res = res + a
a = a << 1
b = b >> 1
return res
| code_translation | [
[
"4, 33",
"132"
],
[
"36, 67",
"2412"
],
[
"65, 52",
"3380"
],
[
"55, 37",
"2035"
],
[
"35, 76",
"2660"
],
[
"69, 98",
"6762"
],
[
"84, 62",
"5208"
],
[
"5, 80",
"400"
],
[
"15, 36",
"540"
],
[
"67, 84",... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int arr [ ], int n ) {
int result = - 1;
for ( int i = 0;
i < n;
i ++ ) for ( int j = 0;
j < n - 1;
j ++ ) for ( int k = j + 1;
k < n;
k ++ ) if ( arr [ j ] * arr [ k ] == arr [ i ] ) result = max ( result, arr [ i ] );
return result;
}
| [] | null | [] | FIND_THE_NUMBER_OCCURRING_ODD_NUMBER_OF_TIMES_1 | python | [] | def f_gold ( arr , size ) :
Hash = dict ( )
for i in range ( size ) :
Hash [ arr [ i ] ] = Hash.get ( arr [ i ] , 0 ) + 1 ;
for i in Hash :
if ( Hash [ i ] % 2 != 0 ) :
return i
return - 1
| code_translation | [
[
"[49, 90], 1",
"49"
],
[
"[-96, 94, 92, -24, 48, 54, -30, -86, 28, -18, 12, -64, -36, 68, 68, -78, -6, 30, -84, 20, 52, -36, 40, -62, 90, -48, 86, 98, 12, 44, 98, -66, 52, 34, 36, 76, -50, -20, -20, -20], 39",
"-96"
],
[
"[0, 1], 1",
"0"
],
[
"[79, 55, 18, 99, 38, 93, 19, 4... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int a, int b ) {
if ( a == 0 || b == 0 ) return 1;
return floor ( log10 ( abs ( a ) ) + log10 ( abs ( b ) ) ) + 1;
}
| [] | null | [] | SMALLEST_POWER_OF_2_GREATER_THAN_OR_EQUAL_TO_N_2 | python | [] | def f_gold ( n ) :
n -= 1
n |= n >> 1
n |= n >> 2
n |= n >> 4
n |= n >> 8
n |= n >> 16
n += 1
return n
| code_translation | [
[
"60",
"64"
],
[
"20",
"32"
],
[
"33",
"64"
],
[
"34",
"64"
],
[
"68",
"128"
],
[
"79",
"128"
],
[
"20",
"32"
],
[
"41",
"64"
],
[
"36",
"64"
],
[
"17",
"32"
]
] | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
long f_gold ( int n ) {
long dp [ 2 ] [ n + 1 ];
dp [ 0 ] [ 1 ] = 1;
dp [ 1 ] [ 1 ] = 2;
for ( int i = 2;
i <= n;
i ++ ) {
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 ];
}
| [] | null | [] | FIND_LARGEST_D_IN_ARRAY_SUCH_THAT_A_B_C_D | python | [] | def f_gold ( S , n ) :
found = False
S.sort ( )
for i in range ( n - 1 , - 1 , - 1 ) :
for j in range ( 0 , n ) :
if ( i == j ) :
continue
for k in range ( j + 1 , n ) :
if ( i == k ) :
continue
for l in range ( k + 1 , n ) :
if ( i == l ) :
continue
if ( S [ i ] == S [ j ] + S [ k ] + S [ l ] ) :
found = True
return S [ i ]
if ( found == False ) :
return - 1
| code_translation | [
[
"[8, 12, 14, 15, 16, 20, 27, 28, 29, 30, 35, 41, 46, 51, 53, 55, 55, 58, 63, 64, 72, 73, 75, 75, 75, 82, 82, 86, 89, 91, 92, 94, 95, 95, 97, 97, 98], 24",
"75"
],
[
"[-96, -82, -62, -58, -56, -50, -44, -44, -40, -28, -22, -20, -12, -2, 10, 26, 34, 42, 48, 74, 86, 92], 19",
"48"
],
[
"[... | |
transcoder-geeksforgeeks | cpp | f_gold | null | [] | null | [] | REPLACE_CHARACTER_C1_C2_C2_C1_STRING_S | python | [] | def f_gold ( s , c1 , c2 ) :
l = len ( s )
for i in range ( l ) :
if ( s [ i ] == c1 ) :
s = s [ 0 : i ] + c2 + s [ i + 1 : ]
elif ( s [ i ] == c2 ) :
s = s [ 0 : i ] + c1 + s [ i + 1 : ]
return s
| code_translation | [
[
"'IZTSMw j', 'W', 'k'",
"'IZTSMw j'"
],
[
"'7288334', '6', '9'",
"'7288334'"
],
[
"'010110000', '1', '1'",
"'010110000'"
],
[
"'b gJX', 't', 'P'",
"'b gJX'"
],
[
"'734', '4', '4'",
"'734'"
],
[
"'1', '1', '1'",
"'1'"
],
[
"'xCaUKdhA', 'X'... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int n ) {
int 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;
}
| [] | null | [] | FIND_A_FIXED_POINT_IN_A_GIVEN_ARRAY | python | [] | def f_gold ( arr , n ) :
for i in range ( n ) :
if arr [ i ] is i :
return i
return - 1
| code_translation | [
[
"[8, 16, 21, 26, 27, 29, 34, 35, 35, 37, 38, 40, 48, 52, 58, 59, 60, 61, 63, 63, 65, 66, 69, 75, 79, 83, 86, 88, 91, 91, 96], 23",
"-1"
],
[
"[22, -70, 34, -44, 84, 54, 14, -88], 7",
"-1"
],
[
"[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, 1, 1, 1, 1... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
bool f_gold ( int n ) {
bool arr [ 10 ];
for ( int i = 0;
i < 10;
i ++ ) arr [ i ] = false;
while ( n > 0 ) {
int digit = n % 10;
if ( arr [ digit ] ) return false;
arr [ digit ] = true;
n = n / 10;
}
return true;
}
| [] | null | [] | COUNT_STRINGS_CAN_FORMED_USING_B_C_GIVEN_CONSTRAINTS_1 | python | [] | def f_gold ( n ) :
return ( 1 + ( n * 2 ) + ( n * ( ( n * n ) - 1 ) // 2 ) )
| code_translation | [
[
"55",
"83271"
],
[
"36",
"23383"
],
[
"69",
"164359"
],
[
"92",
"389483"
],
[
"73",
"194619"
],
[
"16",
"2073"
],
[
"88",
"340869"
],
[
"19",
"3459"
],
[
"66",
"143848"
],
[
"68",
"157319"
]
] | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
double f_gold ( double s ) {
return ( ( 3 * sqrt ( 3 ) * ( s * s ) ) / 2 );
}
| [] | null | [] | NUMBER_OF_TRIANGLES_IN_A_PLANE_IF_NO_MORE_THAN_TWO_POINTS_ARE_COLLINEAR | python | [] | def f_gold ( n ) :
return ( n * ( n - 1 ) * ( n - 2 ) // 6 )
| code_translation | [
[
"67",
"47905"
],
[
"58",
"30856"
],
[
"67",
"47905"
],
[
"60",
"34220"
],
[
"4",
"4"
],
[
"97",
"147440"
],
[
"9",
"84"
],
[
"16",
"560"
],
[
"83",
"91881"
],
[
"87",
"105995"
]
] | |
transcoder-geeksforgeeks | cpp | f_gold | null | [] | null | [] | FIND_SUM_EVEN_INDEX_BINOMIAL_COEFFICIENTS | python | [] | def f_gold ( n ) :
C = [ [ 0 for x in range ( n + 1 ) ] for y in range ( n + 1 ) ]
for i in range ( 0 , n + 1 ) :
for j in range ( 0 , min ( i , n + 1 ) ) :
if j == 0 or j == i :
C [ i ] [ j ] = 1
else :
C [ i ] [ j ] = C [ i - 1 ] [ j - 1 ] + C [ i - 1 ] [ j ]
sum = 0 ;
for i in range ( 0 , n + 1 ) :
if n % 2 == 0 :
sum = sum + C [ n ] [ i ]
return sum
| code_translation | [
[
"18",
"131072"
],
[
"54",
"9007199254740992"
],
[
"67",
"0"
],
[
"17",
"0"
],
[
"47",
"0"
],
[
"99",
"0"
],
[
"26",
"33554432"
],
[
"93",
"0"
],
[
"57",
"0"
],
[
"98",
"15845632502852867518708790067... | |
transcoder-geeksforgeeks | cpp | f_gold | null | [] | null | [] | DECODE_MEDIAN_STRING_ORIGINAL_STRING | python | [] | def f_gold ( s ) :
l = len ( s )
s1 = ""
if ( l % 2 == 0 ) :
isEven = True
else :
isEven = False
for i in range ( 0 , l , 2 ) :
if ( isEven ) :
s1 = s [ i ] + s1
s1 += s [ i + 1 ]
else :
if ( l - i > 1 ) :
s1 += s [ i ]
s1 = s [ i + 1 ] + s1
else :
s1 += s [ i ]
return s1
| code_translation | [
[
"' EgvQCeqYpZtv'",
"'tpqCvE gQeYZv'"
],
[
"'488540'",
"'484850'"
],
[
"'0000101010111'",
"'1000000011111'"
],
[
"'syw'",
"'ysw'"
],
[
"'402355'",
"'524035'"
],
[
"'0'",
"'0'"
],
[
"'wmHMlAtq'",
"'tlHwmMAq'"
],
[
"'7962'",
... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
bool f_gold ( int n ) {
return 1162261467 % n == 0;
}
| [] | null | [] | LEXICOGRAPHICAL_MAXIMUM_SUBSTRING_STRING | python | [] | def f_gold ( str ) :
mx = ""
for i in range ( len ( str ) ) :
mx = max ( mx , str [ i : ] )
return mx
| code_translation | [
[
"'HCoAefoaan'",
"'oaan'"
],
[
"'80336005'",
"'80336005'"
],
[
"'01111111110'",
"'1111111110'"
],
[
"'qIH'",
"'qIH'"
],
[
"'4210598472796'",
"'98472796'"
],
[
"'10101'",
"'10101'"
],
[
"'imqmKdatcgXjs'",
"'tcgXjs'"
],
[
"'95050... | |
transcoder-geeksforgeeks | cpp | f_gold | null | [
"import math"
] | null | [] | FIND_LARGEST_PRIME_FACTOR_NUMBER | python | [] | import math
def f_gold ( n ) :
maxPrime = - 1
while n % 2 == 0 :
maxPrime = 2
n >>= 1
for i in range ( 3 , int ( math.sqrt ( n ) ) + 1 , 2 ) :
while n % i == 0 :
maxPrime = i
n = n / i
if n > 2 :
maxPrime = n
return int ( maxPrime )
| code_translation | [
[
"98",
"7"
],
[
"8",
"2"
],
[
"78",
"13"
],
[
"65",
"13"
],
[
"55",
"11"
],
[
"10",
"5"
],
[
"10",
"5"
],
[
"37",
"37"
],
[
"39",
"13"
],
[
"15",
"5"
]
] | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int arr [ ], int n ) {
sort ( arr, arr + n );
int count = 1;
for ( int i = 0;
i < n - 1;
i ++ ) {
if ( arr [ i ] + 1 != arr [ i + 1 ] ) count ++;
}
return count;
}
| [] | null | [] | COUNT_EVEN_LENGTH_BINARY_SEQUENCES_WITH_SAME_SUM_OF_FIRST_AND_SECOND_HALF_BITS_1 | python | [] | def f_gold ( n ) :
nCr = 1
res = 1
for r in range ( 1 , n + 1 ) :
nCr = ( nCr * ( n + 1 - r ) ) / r ;
res += nCr * nCr ;
return res ;
| code_translation | [
[
"52",
"1.5830658481259492e+30"
],
[
"75",
"9.282606973670874e+43"
],
[
"25",
"126410606437752.0"
],
[
"80",
"9.204512581373429e+46"
],
[
"18",
"9075135300.0"
],
[
"17",
"2333606220.0"
],
[
"33",
"7.219428434016266e+18"
],
[
"8... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int arr [ ], int n ) {
int i, j;
int leftsum, rightsum;
for ( i = 0;
i < n;
++ i ) {
leftsum = 0;
for ( j = 0;
j < i;
j ++ ) leftsum += arr [ j ];
rightsum = 0;
for ( j = i + 1;
j < n;
j ++ ) rightsum += arr [ j ];
if ( leftsum == rightsum ) return i;
}
return - 1;
}
| [] | null | [] | COUNT_OF_PAIRS_SATISFYING_THE_GIVEN_CONDITION | python | [] | def f_gold ( a , b ) :
s = str ( b )
i = 0
while i < ( len ( s ) ) :
if ( s [ i ] != '9' ) :
break
i += 1
result = 0
if ( i == len ( s ) ) :
result = a * len ( s )
else :
result = a * ( len ( s ) - 1 )
return result
| code_translation | [
[
"31, 91",
"31"
],
[
"72, 85",
"72"
],
[
"23, 49",
"23"
],
[
"42, 32",
"42"
],
[
"13, 7",
"0"
],
[
"93, 5",
"0"
],
[
"33, 32",
"33"
],
[
"94, 76",
"94"
],
[
"60, 60",
"60"
],
[
"11, 26",
"11"
]
] | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( string str ) {
int n = str . length ( );
int dp [ n + 1 ] [ n + 1 ];
for ( int i = 0;
i <= n;
i ++ ) for ( int j = 0;
j <= n;
j ++ ) dp [ i ] [ j ] = 0;
for ( int i = 1;
i <= n;
i ++ ) {
for ( int j = 1;
j <= n;
j ++ ) {
if ( str [ i - 1 ] == str [ j - 1 ] && i != j ) dp [ i ] [ j ] = 1 + dp [ i - 1 ] [ j - 1 ];
else dp [ i ] [ j ] = max ( dp [ i ] [ j - 1 ], dp [ i - 1 ] [ j ] );
}
}
return dp [ n ] [ n ];
}
| [] | null | [] | WILDCARD_CHARACTER_MATCHING | python | [] | def f_gold ( first , second ) :
if len ( first ) == 0 and len ( second ) == 0 :
return True
if len ( first ) > 1 and first [ 0 ] == '*' and len ( second ) == 0 :
return False
if ( len ( first ) > 1 and first [ 0 ] == '?' ) or ( len ( first ) != 0 and len ( second ) != 0 and first [ 0 ] == second [ 0 ] ) :
return f_gold ( first [ 1 : ] , second [ 1 : ] ) ;
if len ( first ) != 0 and first [ 0 ] == '*' :
return f_gold ( first [ 1 : ] , second ) or f_gold ( first , second [ 1 : ] )
return False
| code_translation | [
[
"'g*ks', 'geeks'",
"True"
],
[
"'ge?ks*', 'geeksforgeeks'",
"True"
],
[
"'g*k', 'gee'",
"False"
],
[
"'*pqrs', 'pqrst'",
"False"
],
[
"'abc*bcd', 'abcdhghgbcd'",
"True"
],
[
"'abc*c?d', 'abcd'",
"False"
],
[
"'*c*d', 'abcd'",
"True"
... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
unsigned int f_gold ( unsigned int a, unsigned int b ) {
int res = 0;
while ( b > 0 ) {
if ( b & 1 ) res = res + a;
a = a << 1;
b = b >> 1;
}
return res;
}
| [] | null | [] | COUNT_DERANGEMENTS_PERMUTATION_SUCH_THAT_NO_ELEMENT_APPEARS_IN_ITS_ORIGINAL_POSITION_1 | python | [] | def f_gold ( n ) :
der = [ 0 for i in range ( n + 1 ) ]
der [ 0 ] = 1
der [ 1 ] = 0
der [ 2 ] = 1
for i in range ( 3 , n + 1 ) :
der [ i ] = ( i - 1 ) * ( der [ i - 1 ] + der [ i - 2 ] )
return der [ n ]
| code_translation | [
[
"22",
"413496759611120779881"
],
[
"91",
"49737356646526719034213089927154223053699087874086781722304941593871272334365070834417115566952728064714407669076679964208877907815269515530"
],
[
"33",
"3194414033122656019847107490716704992"
],
[
"93",
"42555282346768260805672... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int arr [ ], int size ) {
unordered_map < int, int > hash;
for ( int i = 0;
i < size;
i ++ ) {
hash [ arr [ i ] ] ++;
}
for ( auto i : hash ) {
if ( i . second % 2 != 0 ) {
return i . first;
}
}
return - 1;
}
| [] | null | [] | BREAKING_NUMBER_FIRST_PART_INTEGRAL_DIVISION_SECOND_POWER_10 | python | [] | def f_gold ( N ) :
length = len ( N )
l = int ( ( length ) / 2 )
count = 0
for i in range ( l + 1 ) :
s = N [ 0 : 0 + i ]
l1 = len ( s )
t = N [ i : l1 + i ]
try :
if s [ 0 ] == '0' or t [ 0 ] == '0' :
continue
except :
continue
if s == t :
count += 1
return count
| code_translation | [
[
"'ZCoQhuM'",
"0"
],
[
"'2674377254'",
"0"
],
[
"'11'",
"1"
],
[
"'LbuGlvRyWAPBpo'",
"0"
],
[
"'26382426486138'",
"0"
],
[
"'111010111010'",
"2"
],
[
"'hUInqJXNdbfP'",
"0"
],
[
"'5191'",
"0"
],
[
"'1110101101'",
... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
unsigned int f_gold ( unsigned int n ) {
n --;
n |= n >> 1;
n |= n >> 2;
n |= n >> 4;
n |= n >> 8;
n |= n >> 16;
n ++;
return n;
}
| [] | null | [] | DOUBLE_FACTORIAL_1 | python | [] | def f_gold ( n ) :
res = 1 ;
for i in range ( n , - 1 , - 2 ) :
if ( i == 0 or i == 1 ) :
return res ;
else :
res *= i ;
| code_translation | [
[
"88",
"46764808100261091644698061863195655483083859821779272859648000000000"
],
[
"24",
"1961990553600"
],
[
"3",
"3"
],
[
"22",
"81749606400"
],
[
"53",
"157952079428395476360490147277859375"
],
[
"2",
"2"
],
[
"88",
"467648081002610... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int S [ ], int n ) {
bool found = false;
sort ( S, S + n );
for ( int i = n - 1;
i >= 0;
i -- ) {
for ( int j = 0;
j < n;
j ++ ) {
if ( i == j ) continue;
for ( int k = j + 1;
k < n;
k ++ ) {
if ( i == k ) continue;
for ( int l = k + 1;
l < n;
l ++ ) {
if ( i == l ) continue;
if ( S [ i ] == S [ j ] + S [ k ] + S [ l ] ) {
found = true;
return S [ i ];
}
}
}
}
}
if ( found == false ) return INT_MIN;
}
| [] | null | [] | COUNT_NUMBER_WAYS_REACH_GIVEN_SCORE_GAME | python | [] | def f_gold ( n ) :
table = [ 0 for i in range ( n + 1 ) ]
table [ 0 ] = 1
for i in range ( 3 , n + 1 ) :
table [ i ] += table [ i - 3 ]
for i in range ( 5 , n + 1 ) :
table [ i ] += table [ i - 5 ]
for i in range ( 10 , n + 1 ) :
table [ i ] += table [ i - 10 ]
return table [ n ]
| code_translation | [
[
"83",
"30"
],
[
"29",
"4"
],
[
"17",
"1"
],
[
"12",
"1"
],
[
"93",
"37"
],
[
"55",
"16"
],
[
"97",
"33"
],
[
"75",
"27"
],
[
"22",
"2"
],
[
"52",
"10"
]
] | |
transcoder-geeksforgeeks | cpp | f_gold | null | [] | null | [] | COUNT_FREQUENCY_K_MATRIX_SIZE_N_MATRIXI_J_IJ | python | [] | def f_gold(n, k):
if (n + 1 >= k):
return (k - 1)
else:
return (2 * n + 1 - k)
| code_translation | [
[
"90, 74",
"73"
],
[
"86, 36",
"35"
],
[
"92, 38",
"37"
],
[
"72, 71",
"70"
],
[
"25, 57",
"-6"
],
[
"11, 53",
"-30"
],
[
"94, 80",
"79"
],
[
"91, 75",
"74"
],
[
"66, 58",
"57"
],
[
"34, 88",
"-19"
... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
string f_gold ( string s, char c1, char c2 ) {
int l = s . length ( );
for ( int i = 0;
i < l;
i ++ ) {
if ( s [ i ] == c1 ) s [ i ] = c2;
else if ( s [ i ] == c2 ) s [ i ] = c1;
}
return s;
}
| [] | null | [] | FIND_VALUE_OF_Y_MOD_2_RAISED_TO_POWER_X | python | [] | def f_gold ( y , x ) :
return ( y % pow ( 2 , x ) )
| code_translation | [
[
"57, 76",
"57"
],
[
"80, 46",
"80"
],
[
"84, 96",
"84"
],
[
"35, 16",
"35"
],
[
"3, 84",
"3"
],
[
"42, 79",
"42"
],
[
"7, 2",
"3"
],
[
"99, 83",
"99"
],
[
"13, 61",
"13"
],
[
"44, 8",
"44"
]
] | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int arr [ ], int n ) {
int i;
for ( i = 0;
i < n;
i ++ ) {
if ( arr [ i ] == i ) return i;
}
return - 1;
}
| [] | null | [] | MAXIMUM_REMOVAL_FROM_ARRAY_WHEN_REMOVAL_TIME_WAITING_TIME | python | [] | def f_gold ( arr , n ) :
count = 0
cummulative_sum = 0
arr.sort ( )
for i in range ( n ) :
if arr [ i ] >= cummulative_sum :
count += 1
cummulative_sum += arr [ i ]
return count
| code_translation | [
[
"[7, 33, 34, 42, 42, 45, 73], 5",
"3"
],
[
"[-98, -90, -80, -66, -64, -62, -48, -30, -20, -10, 4, 6, 12, 14, 32, 42, 44, 44, 52, 64, 86, 92, 94], 16",
"4"
],
[
"[0, 0, 0, 0, 1], 2",
"2"
],
[
"[11, 44, 71, 82, 85, 89], 3",
"3"
],
[
"[-96, -92, -78, -72, -68, -58,... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int n ) {
return 1 + ( n * 2 ) + ( n * ( ( n * n ) - 1 ) / 2 );
}
| [] | null | [] | MINIMUM_CHARACTERS_ADDED_FRONT_MAKE_STRING_PALINDROME | python | [] | def f_gold ( s ) :
l = len ( s )
i = 0
j = l - 1
while i <= j :
if ( s [ i ] != s [ j ] ) :
return False
i += 1
j -= 1
return True
| code_translation | [
[
"'aadaa'",
"True"
],
[
"'2674377254'",
"False"
],
[
"'11'",
"True"
],
[
"'0011000 '",
"False"
],
[
"'26382426486138'",
"False"
],
[
"'111010111010'",
"False"
],
[
"'abccba'",
"True"
],
[
"'5191'",
"False"
],
[
"'11... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
bool f_gold ( int arr [ ], int n ) {
unordered_set < int > us;
for ( int i = 0;
i < n;
i ++ ) us . insert ( arr [ i ] );
int count = 1;
int curr_ele = arr [ 0 ] - 1;
while ( us . find ( curr_ele ) != us . end ( ) ) {
count ++;
curr_ele --;
}
curr_ele = arr [ 0 ] + 1;
while ( us . find ( curr_ele ) != us . end ( ) ) {
count ++;
curr_ele ++;
}
return ( count == ( int ) ( us . size ( ) ) );
}
| [] | null | [] | CHECK_STRING_CAN_OBTAINED_ROTATING_ANOTHER_STRING_2_PLACES | python | [] | def f_gold ( str1 , str2 ) :
if ( len ( str1 ) != len ( str2 ) ) :
return False
clock_rot = ""
anticlock_rot = ""
l = len ( str2 )
anticlock_rot = ( anticlock_rot + str2 [ l - 2 : ] + str2 [ 0 : l - 2 ] )
clock_rot = clock_rot + str2 [ 2 : ] + str2 [ 0 : 2 ]
return ( str1 == clock_rot or str1 == anticlock_rot )
| code_translation | [
[
"'amazon', 'azonam'",
"True"
],
[
"'onamaz', 'amazon'",
"True"
],
[
"'amazon', 'azoman'",
"False"
],
[
"'ab', 'ab'",
"True"
],
[
"'737009', '239119'",
"False"
],
[
"'000110', '01111'",
"False"
],
[
"'l', 'YVo hqvnGxow'",
"False"
],
... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int n ) {
return n * ( n - 1 ) * ( n - 2 ) / 6;
}
| [] | null | [] | MINIMUM_ROTATIONS_REQUIRED_GET_STRING | python | [] | def f_gold ( str ) :
tmp = str + str
n = len ( str )
for i in range ( 1 , n + 1 ) :
substring = tmp [ i : n ]
if ( str == substring ) :
return i
return n
| code_translation | [
[
"'vdevdNdQSopPtj'",
"14"
],
[
"'5'",
"1"
],
[
"'100010101011'",
"12"
],
[
"'tlDOvJHAyMllu'",
"13"
],
[
"'06'",
"2"
],
[
"'101'",
"3"
],
[
"'DYgtU'",
"5"
],
[
"'4'",
"1"
],
[
"'00'",
"2"
],
[
"'Dt'",
... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int n ) {
int C [ n + 1 ] [ n + 1 ];
int i, j;
for ( i = 0;
i <= n;
i ++ ) {
for ( j = 0;
j <= min ( i, n );
j ++ ) {
if ( j == 0 || j == i ) C [ i ] [ j ] = 1;
else C [ i ] [ j ] = C [ i - 1 ] [ j - 1 ] + C [ i - 1 ] [ j ];
}
}
int sum = 0;
for ( int i = 0;
i <= n;
i += 2 ) sum += C [ n ] [ i ];
return sum;
}
| [] | null | [] | MAXIMUM_SUM_IARRI_AMONG_ROTATIONS_GIVEN_ARRAY_1 | python | [] | def f_gold ( arr , n ) :
cum_sum = 0
for i in range ( 0 , n ) :
cum_sum += arr [ i ]
curr_val = 0
for i in range ( 0 , n ) :
curr_val += i * arr [ i ]
res = curr_val
for i in range ( 1 , n ) :
next_val = ( curr_val - ( cum_sum - arr [ i - 1 ] ) + arr [ i - 1 ] * ( n - 1 ) )
curr_val = next_val
res = max ( res , next_val )
return res
| code_translation | [
[
"[6, 6, 13, 14, 16, 20, 24, 24, 24, 27, 28, 36, 49, 51, 55, 56, 62, 69, 74, 74, 76, 85, 86, 90, 92, 98], 13",
"2249"
],
[
"[-42, 96, 68, 64, 14, -74, 76, 42, 34, -92, -20, 28, -80, -34, -22, 96, -46, 96, 10, -82, 82, 50, -24, 48, 56, 72, -40, -86, 84, 66, -62, 50, -76, 34], 27",
"9152"
],
... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
string f_gold ( string s ) {
int l = s . length ( );
string s1 = "";
bool isEven = ( l % 2 == 0 ) ? true : false;
for ( int i = 0;
i < l;
i += 2 ) {
if ( isEven ) {
s1 = s [ i ] + s1;
s1 += s [ i + 1 ];
}
else {
if ( l - i > 1 ) {
s1 += s [ i ];
s1 = s [ i + 1 ] + s1;
}
else {
s1 += s [ i ];
}
}
}
return s1;
}
| [] | null | [] | MINIMUM_DIFFERENCE_MAX_MIN_K_SIZE_SUBSETS | python | [] | def f_gold ( arr , N , K ) :
arr.sort ( )
res = 2147483647
for i in range ( ( N - K ) + 1 ) :
curSeqDiff = arr [ i + K - 1 ] - arr [ i ]
res = min ( res , curSeqDiff )
return res
| code_translation | [
[
"[1, 1, 4, 18, 21, 35, 37, 39, 76, 81, 86, 92, 96], 7, 6",
"34"
],
[
"[-94, -86, -48, -48, -38, -8, -6, 0, 2, 24, 34, 52, 62], 9, 12",
"2147483647"
],
[
"[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], 16, 26",
"2147483647"
],
[
"[3, 10... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
string f_gold ( string str ) {
string mx = "";
for ( int i = 0;
i < str . length ( );
++ i ) mx = max ( mx, str . substr ( i ) );
return mx;
}
| [
"import sys"
] | null | [] | SORT_ARRAY_APPLYING_GIVEN_EQUATION | python | [] | import sys
def f_gold(arr, n, A, B, C):
for i in range(n):
arr[i] = (A * arr[i] * arr[i] + B * arr[i] + C)
index = - (sys.maxsize - 1)
maximum = - (sys.maxsize - 1)
for i in range(n):
if maximum < arr[i]:
index = i
maximum = arr[i]
i = 0
j = n - 1
new_arr = [0] * n
k = 0
while i < index and j > index:
if arr[i] < arr[j]:
new_arr[k] = arr[i]
k += 1
i += 1
else:
new_arr[k] = arr[j]
k += 1
j -= 1
while i < index:
new_arr[k] = arr[i]
k += 1
i += 1
while j > index:
new_arr[k] = arr[j]
k += 1
j -= 1
new_arr[n - 1] = maximum
for i in range(n):
arr[i] = new_arr[i]
| code_translation | [
[
"[373, 3754, 9853, 0, 78, 85, 85, 92], 4, 4, 5, 4",
"None"
],
[
"[1463, 10143, 45143, 80663, 120143, 63863, 160223, 70823, 88463, 102263, 26663, 45143, 49023, 75663, 34463, 9263, 143, 0, -90, -5, -94, -43, 29, -29, 86, -79, -8, 27, -20, -44, 16], 18, 20, 20, 23",
"None"
],
[
"[18, 18, ... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
long long f_gold ( long long n ) {
long long maxPrime = - 1;
while ( n % 2 == 0 ) {
maxPrime = 2;
n >>= 1;
}
for ( int i = 3;
i <= sqrt ( n );
i += 2 ) {
while ( n % i == 0 ) {
maxPrime = i;
n = n / i;
}
}
if ( n > 2 ) maxPrime = n;
return maxPrime;
}
| [] | null | [] | ANALYSIS_OF_ALGORITHMS_SET_2_ASYMPTOTIC_ANALYSIS | python | [] | def f_gold ( arr , n , x ) :
i = 0
for i in range ( i , n ) :
if ( arr [ i ] == x ) :
return i
return - 1
| code_translation | [
[
"[4, 5, 5, 11, 13, 14, 15, 19, 22, 22, 23, 26, 29, 29, 36, 44, 48, 49, 65, 65, 67, 68, 70, 76, 79, 79, 81, 85, 88, 91, 91, 92, 92, 97], 17, 5",
"1"
],
[
"[-24, -78, -32, -48, 0, 4, -42], 4, 0",
"-1"
],
[
"[0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1], 6, 0",
"0"
],
[
"[38, 14, 75, 16, ... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int n ) {
int nCr = 1, res = 1;
for ( int r = 1;
r <= n;
r ++ ) {
nCr = ( nCr * ( n + 1 - r ) ) / r;
res += nCr * nCr;
}
return res;
}
| [] | null | [] | ARRAY_ELEMENT_MOVED_K_USING_SINGLE_MOVES | python | [] | def f_gold ( a , n , k ) :
if k >= n - 1 :
return n
best = 0
times = 0
for i in range ( n ) :
if a [ i ] > best :
best = a [ i ]
if i == True :
times = 1
else :
times += 1
if times >= k :
return best
return best
| code_translation | [
[
"[2, 5, 5, 9, 10, 10, 11, 14, 23, 27, 31, 32, 33, 33, 33, 37, 39, 41, 41, 42, 42, 43, 47, 60, 61, 68, 73, 73, 73, 78, 80, 80, 82, 83, 86, 87, 89, 92, 94, 98], 33, 37",
"33"
],
[
"[80, -58, 64, 48, -16, 60, -50, -52, 62, -86, -96, 52, 26, -30, 14], 14, 13",
"14"
],
[
"[0, 0, 0, 0, 0, 0,... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int a, int b ) {
string s = to_string ( b );
int i;
for ( i = 0;
i < s . length ( );
i ++ ) {
if ( s [ i ] != '9' ) break;
}
int result;
if ( i == s . length ( ) ) result = a * s . length ( );
else result = a * ( s . length ( ) - 1 );
return result;
}
| [] | null | [] | NUMBER_DIGITS_PRODUCT_TWO_NUMBERS | python | [] | def f_gold(a, b):
count = 0
p = abs(a * b)
if (p == 0):
return 1
while (p > 0):
count = count + 1
p = p // 10
return count
| code_translation | [
[
"86, 39",
"4"
],
[
"81, 87",
"4"
],
[
"48, 84",
"4"
],
[
"64, 80",
"4"
],
[
"56, 20",
"4"
],
[
"5, 70",
"3"
],
[
"25, 13",
"3"
],
[
"94, 83",
"4"
],
[
"5, 55",
"3"
],
[
"46, 46",
"4"
]
] | |
transcoder-geeksforgeeks | cpp | f_gold | null | [] | null | [] | FLOOR_IN_A_SORTED_ARRAY_1 | python | [] | def f_gold ( arr , low , high , x ) :
if ( low > high ) :
return - 1
if ( x >= arr [ high ] ) :
return high
mid = int ( ( low + high ) / 2 )
if ( arr [ mid ] == x ) :
return mid
if ( mid > 0 and arr [ mid - 1 ] <= x and x < arr [ mid ] ) :
return mid - 1
if ( x < arr [ mid ] ) :
return f_gold ( arr , low , mid - 1 , x )
return f_gold ( arr , mid + 1 , high , x )
| code_translation | [
[
"[5, 11, 20, 42, 42, 55, 58, 98, 99], 5, 7, 6",
"-1"
],
[
"[50, -90, -38, -46, -10, -22, -66, 72, -52, 38, 90, 34, -12, -44, -6, 0, -20, -38, 86, 26, 64, -24, 40, 90, -26, -2, -28, 12, 22, -14], 26, 28, 23",
"28"
],
[
"[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1], 11, 9, 1... | |
transcoder-geeksforgeeks | cpp | f_gold | null | [] | null | [] | HOW_CAN_WE_SUM_THE_DIGITS_OF_A_GIVEN_NUMBER_IN_SINGLE_STATEMENT_1 | python | [] | def f_gold ( n ) :
sum = 0
while ( n > 0 ) :
sum += int ( n % 10 )
n = int ( n / 10 )
return sum
| code_translation | [
[
"50",
"5"
],
[
"92",
"11"
],
[
"49",
"13"
],
[
"94",
"13"
],
[
"7",
"7"
],
[
"30",
"3"
],
[
"88",
"16"
],
[
"98",
"17"
],
[
"94",
"13"
],
[
"23",
"5"
]
] | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int a [ ], int n, int k ) {
unordered_map < int, int > m;
for ( int i = 0;
i < n;
i ++ ) m [ a [ i ] ] ++;
int res = INT_MAX;
for ( auto it = m . begin ( );
it != m . end ( );
++ it ) if ( it -> second == k ) res = min ( res, it -> first );
return ( res != INT_MAX ) ? res : - 1;
}
| [] | null | [] | BREAK_NUMBER_THREE_PARTS_1 | python | [] | def f_gold ( n ) :
count = 0
count = ( n + 1 ) * ( n + 2 ) // 2
return count
| code_translation | [
[
"71",
"2628"
],
[
"71",
"2628"
],
[
"36",
"703"
],
[
"3",
"10"
],
[
"97",
"4851"
],
[
"69",
"2485"
],
[
"15",
"136"
],
[
"48",
"1225"
],
[
"77",
"3081"
],
[
"6",
"28"
]
] | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int n ) {
int der [ n + 1 ];
der [ 0 ] = 1;
der [ 1 ] = 0;
der [ 2 ] = 1;
for ( int i = 3;
i <= n;
++ i ) der [ i ] = ( i - 1 ) * ( der [ i - 1 ] + der [ i - 2 ] );
return der [ n ];
}
| [] | null | [] | WRITE_AN_EFFICIENT_METHOD_TO_CHECK_IF_A_NUMBER_IS_MULTIPLE_OF_3 | python | [] | def f_gold ( n ) :
odd_count = 0
even_count = 0
if ( n < 0 ) :
n = - n
if ( n == 0 ) :
return 1
if ( n == 1 ) :
return 0
while ( n ) :
if ( n & 1 ) :
odd_count += 1
if ( n & 2 ) :
even_count += 1
n = n >> 2
return f_gold ( abs ( odd_count - even_count ) )
| code_translation | [
[
"94",
"0"
],
[
"94",
"0"
],
[
"79",
"0"
],
[
"39",
"1"
],
[
"16",
"0"
],
[
"90",
"1"
],
[
"64",
"0"
],
[
"76",
"0"
],
[
"83",
"0"
],
[
"47",
"0"
]
] | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int arr [ ], int n ) {
int invcount = 0;
for ( int i = 0;
i < n - 2;
i ++ ) {
for ( int j = i + 1;
j < n - 1;
j ++ ) {
if ( arr [ i ] > arr [ j ] ) {
for ( int k = j + 1;
k < n;
k ++ ) {
if ( arr [ j ] > arr [ k ] ) invcount ++;
}
}
}
}
return invcount;
}
| [] | null | [] | BINARY_REPRESENTATION_OF_NEXT_NUMBER | python | [] | def f_gold ( num1 ) :
l = len ( num1 ) ;
num = list ( num1 ) ;
i = l - 1 ;
while ( i >= 0 ) :
if ( num [ i ] == '0' ) :
num [ i ] = '1' ;
break ;
else :
num [ i ] = '0' ;
i -= 1 ;
num1 = ''.join ( num ) ;
if ( i < 0 ) :
num1 = '1' + num1 ;
return num1 ;
| code_translation | [
[
"'DXh'",
"'1000'"
],
[
"'48703586411816'",
"'48710000000000'"
],
[
"'0001'",
"'0010'"
],
[
"'yWg WvjNKS'",
"'10000000000'"
],
[
"'8408568459'",
"'8410000000'"
],
[
"'01'",
"'10'"
],
[
"'DFECZ CWtN'",
"'10000000000'"
],
[
"'377... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( string N ) {
int len = N . length ( );
int l = ( len ) / 2;
int count = 0;
for ( int i = 1;
i <= l;
i ++ ) {
string s = N . substr ( 0, i );
int l1 = s . length ( );
string t = N . substr ( i, l1 );
if ( s [ 0 ] == '0' || t [ 0 ] == '0' ) continue;
if ( s . compare ( t ) == 0 ) count ++;
}
return count;
}
| [] | null | [] | CHECK_WHETHER_GIVEN_NUMBER_EVEN_ODD | python | [] | def f_gold ( n ) :
return ( n % 2 == 0 )
| code_translation | [
[
"67",
"False"
],
[
"90",
"True"
],
[
"55",
"False"
],
[
"90",
"True"
],
[
"83",
"False"
],
[
"32",
"True"
],
[
"58",
"True"
],
[
"38",
"True"
],
[
"87",
"False"
],
[
"87",
"False"
]
] | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
unsigned int f_gold ( unsigned int n ) {
int res = 1;
for ( int i = n;
i >= 0;
i = i - 2 ) {
if ( i == 0 || i == 1 ) return res;
else res *= i;
}
}
| [] | null | [] | ONE_LINE_FUNCTION_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 | [
[
"58",
"2350561331282878571829474910515074683828862318181142924420699914240000000000000"
],
[
"42",
"1405006117752879898543142606244511569936384000000000"
],
[
"76",
"1885494701666050254987932260861146558230394535379329335672487982961844043495537923117729972224000000000000000000"
... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int n ) {
int table [ n + 1 ], i;
for ( int j = 0;
j < n + 1;
j ++ ) table [ j ] = 0;
table [ 0 ] = 1;
for ( i = 3;
i <= n;
i ++ ) table [ i ] += table [ i - 3 ];
for ( i = 5;
i <= n;
i ++ ) table [ i ] += table [ i - 5 ];
for ( i = 10;
i <= n;
i ++ ) table [ i ] += table [ i - 10 ];
return table [ n ];
}
| [] | null | [] | UGLY_NUMBERS | python | [] | def f_gold ( n ) :
ugly = [ 0 ] * n
ugly [ 0 ] = 1
i2 = i3 = i5 = 0
next_multiple_of_2 = 2
next_multiple_of_3 = 3
next_multiple_of_5 = 5
for l in range ( 1 , n ) :
ugly [ l ] = min ( next_multiple_of_2 , next_multiple_of_3 , next_multiple_of_5 )
if ugly [ l ] == next_multiple_of_2 :
i2 += 1
next_multiple_of_2 = ugly [ i2 ] * 2
if ugly [ l ] == next_multiple_of_3 :
i3 += 1
next_multiple_of_3 = ugly [ i3 ] * 3
if ugly [ l ] == next_multiple_of_5 :
i5 += 1
next_multiple_of_5 = ugly [ i5 ] * 5
return ugly [ - 1 ]
| code_translation | [
[
"27",
"64"
],
[
"64",
"450"
],
[
"93",
"1250"
],
[
"90",
"1152"
],
[
"85",
"972"
],
[
"86",
"1000"
],
[
"72",
"625"
],
[
"86",
"1000"
],
[
"32",
"90"
],
[
"1",
"1"
]
] | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int n, int k ) {
if ( n + 1 >= k ) return ( k - 1 );
else return ( 2 * n + 1 - k );
}
| [] | null | [] | UNIQUE_CELLS_BINARY_MATRIX | python | [] | def f_gold ( mat , n , m ) :
rowsum = [ 0 ] * n ;
colsum = [ 0 ] * m ;
for i in range ( n ) :
for j in range ( m ) :
if ( mat [ i ] [ j ] != 0 ) :
rowsum [ i ] += 1 ;
colsum [ j ] += 1 ;
uniquecount = 0 ;
for i in range ( n ) :
for j in range ( m ) :
if ( mat [ i ] [ j ] != 0 and rowsum [ i ] == 1 and colsum [ j ] == 1 ) :
uniquecount += 1 ;
return uniquecount ;
| code_translation | [
[
"[[0, 1, 0, 0], [0, 0, 1, 0], [1, 0, 0, 1]], 3, 4",
"2"
],
[
"[[0, 1, 0, 0], [0, 0, 1, 0], [1, 0, 0, 1]], 2, 2",
"1"
],
[
"[[0, 1, 0, 0], [0, 0, 1, 1], [1, 0, 1, 1]], 3, 4",
"1"
],
[
"[[0, 1, 0, 0], [0, 0, 1, 0], [1, 1, 0, 1]], 3, 4",
"1"
],
[
"[[1, 1, 1, 1], [0... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
long long int f_gold ( long long int y, long long int x ) {
if ( log2 ( y ) < x ) return y;
if ( x > 63 ) return y;
return ( y % ( 1 << x ) );
}
| [] | null | [] | COUNT_POSSIBLE_DECODINGS_GIVEN_DIGIT_SEQUENCE_1 | python | [] | def f_gold ( digits , n ) :
count = [ 0 ] * ( n + 1 ) ;
count [ 0 ] = 1 ;
count [ 1 ] = 1 ;
for i in range ( 2 , n + 1 ) :
count [ i ] = 0 ;
if ( digits [ i - 1 ] > '0' ) :
count [ i ] = count [ i - 1 ] ;
if ( digits [ i - 2 ] == '1' or ( digits [ i - 2 ] == '2' and digits [ i - 1 ] < '7' ) ) :
count [ i ] += count [ i - 2 ] ;
return count [ n ] ;
| code_translation | [
[
"['B', 'C', 'E', 'E', 'F', 'F', 'G', 'J', 'K', 'K', 'L', 'L', 'M', 'O', 'O', 'P', 'Q', 'R', 'V', 'X', 'Z', 'a', 'a', 'a', 'c', 'c', 'c', 'd', 'e', 'g', 'g', 'k', 'k', 'k', 'l', 'm', 'm', 'n', 'p', 't', 'y', 'z'], 31",
"1"
],
[
"['0', '9', '5', '0', '2', '6', '5', '4', '4', '5', '2', '6', '8', '2',... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int n ) {
int table [ n + 1 ];
memset ( table, 0, sizeof ( table ) );
table [ 0 ] = 1;
for ( int i = 1;
i < n;
i ++ ) for ( int j = i;
j <= n;
j ++ ) table [ j ] += table [ j - i ];
return table [ n ];
}
| [] | null | [] | PERFECT_REVERSIBLE_STRING | python | [] | def f_gold ( str ) :
i = 0 ; j = len ( str ) - 1 ;
while ( i < j ) :
if ( str [ i ] != str [ j ] ) :
return False ;
i += 1 ;
j -= 1 ;
return True ;
| code_translation | [
[
"'ab'",
"False"
],
[
"'303'",
"True"
],
[
"'11110000'",
"False"
],
[
"'aba'",
"True"
],
[
"'404'",
"True"
],
[
"'10101'",
"True"
],
[
"'abab'",
"False"
],
[
"'6366'",
"False"
],
[
"'001'",
"False"
],
[
... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int arr [ ], int n ) {
int count = 0;
int cummulative_sum = 0;
sort ( arr, arr + n );
for ( int i = 0;
i < n;
i ++ ) {
if ( arr [ i ] >= cummulative_sum ) {
count ++;
cummulative_sum += arr [ i ];
}
}
return count;
}
| [] | null | [] | FIND_WHETHER_A_GIVEN_NUMBER_IS_A_POWER_OF_4_OR_NOT_2 | python | [] | def f_gold ( n ) :
return ( n != 0 and ( ( n & ( n - 1 ) ) == 0 ) and not ( n & 0xAAAAAAAA ) ) ;
| code_translation | [
[
"1",
"True"
],
[
"4",
"True"
],
[
"64",
"True"
],
[
"-64",
"False"
],
[
"128",
"False"
],
[
"1024",
"True"
],
[
"97",
"False"
],
[
"86",
"False"
],
[
"14",
"False"
],
[
"99",
"False"
]
] | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
bool f_gold ( string s ) {
int l = s . length ( );
int j;
for ( int i = 0, j = l - 1;
i <= j;
i ++, j -- ) {
if ( s [ i ] != s [ j ] ) return false;
}
return true;
}
| [] | null | [] | FIND_A_ROTATION_WITH_MAXIMUM_HAMMING_DISTANCE | python | [] | def f_gold ( arr , n ) :
brr = [ 0 ] * ( 2 * n + 1 )
for i in range ( n ) :
brr [ i ] = arr [ i ]
for i in range ( n ) :
brr [ n + i ] = arr [ i ]
maxHam = 0
for i in range ( 1 , n ) :
currHam = 0
k = 0
for j in range ( i , i + n ) :
if brr [ j ] != arr [ k ] :
currHam += 1
k = k + 1
if currHam == n :
return n
maxHam = max ( maxHam , currHam )
return maxHam
| code_translation | [
[
"[1, 4, 18, 22, 28, 34, 35, 39, 44, 45, 67, 73, 75, 79, 81, 83, 89, 93, 96], 12",
"12"
],
[
"[52, -28], 1",
"0"
],
[
"[0, 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, 1, 1, 1, 1, 1], 21",
"1"
],
[
"[24], 0",
"0"
],
... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
bool f_gold ( string str1, string str2 ) {
if ( str1 . length ( ) != str2 . length ( ) ) return false;
string clock_rot = "";
string anticlock_rot = "";
int len = str2 . length ( );
anticlock_rot = anticlock_rot + str2 . substr ( len - 2, 2 ) + str2 . substr ( 0, len - 2 );
clock_rot = clock_rot + str2 . substr ( 2 ) + str2 . substr ( 0, 2 );
return ( str1 . compare ( clock_rot ) == 0 || str1 . compare ( anticlock_rot ) == 0 );
}
| [] | null | [] | STOOGE_SORT | python | [] | def f_gold ( arr , l , h ) :
if l >= h :
return
if arr [ l ] > arr [ h ] :
t = arr [ l ]
arr [ l ] = arr [ h ]
arr [ h ] = t
if h - l + 1 > 2 :
t = ( int ) ( ( h - l + 1 ) / 3 )
f_gold ( arr , l , ( h - t ) )
f_gold ( arr , l + t , ( h ) )
f_gold ( arr , l , ( h - t ) )
| code_translation | [
[
"[6, 25, 42, 52, 53, 54, 58, 66, 67, 70], 6, 6",
"None"
],
[
"[-13, -98, 50, -63, 48, 3, -76, 12, -35, 93, 29, 17, 16, 5, -97, -54, -45, -25], 16, 14",
"None"
],
[
"[0, 0, 0, 0, 0, 0, 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, 1, 1, ... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( string s ) {
int n = s . size ( );
int ans = - 1;
string num;
for ( int i = 1;
i < ( 1 << n );
i ++ ) {
string str = "";
for ( int j = 0;
j < n;
j ++ ) {
if ( ( i >> j ) & 1 ) {
str += s [ j ];
}
}
if ( str [ 0 ] != '0' ) {
int temp = 0;
for ( int j = 0;
j < str . size ( );
j ++ ) temp = temp * 10 + ( int ) ( str [ j ] - '0' );
int k = sqrt ( temp );
if ( k * k == temp ) {
if ( ans < ( int ) str . size ( ) ) {
ans = ( int ) str . size ( );
num = str;
}
}
}
}
if ( ans == - 1 ) return ans;
else {
cout << num << " ";
return n - ans;
}
}
| [
"import math"
] | null | [] | COUNT_DIGITS_FACTORIAL_SET_1 | python | [] | import math
def f_gold ( n ) :
if ( n < 0 ) :
return 0 ;
if ( n <= 1 ) :
return 1 ;
digits = 0 ;
for i in range ( 2 , n + 1 ) :
digits += math.log10 ( i ) ;
return math.floor ( digits ) + 1 ;
| code_translation | [
[
"66",
"93"
],
[
"7",
"4"
],
[
"55",
"74"
],
[
"37",
"44"
],
[
"76",
"112"
],
[
"16",
"14"
],
[
"17",
"15"
],
[
"95",
"149"
],
[
"71",
"102"
],
[
"90",
"139"
]
] | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( string str ) {
string tmp = str + str;
int n = str . length ( );
for ( int i = 1;
i <= n;
i ++ ) {
string substring = tmp . substr ( i, str . size ( ) );
if ( str == substring ) return i;
}
return n;
}
| [] | null | [] | PYTHON_PROGRAM_FIND_PERIMETER_CIRCUMFERENCE_SQUARE_RECTANGLE | python | [] | def f_gold ( a ) :
return ( 4 * a )
| code_translation | [
[
"98",
"392"
],
[
"9",
"36"
],
[
"18",
"72"
],
[
"38",
"152"
],
[
"84",
"336"
],
[
"8",
"32"
],
[
"39",
"156"
],
[
"6",
"24"
],
[
"60",
"240"
],
[
"47",
"188"
]
] | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int arr [ ], int n ) {
int cum_sum = 0;
for ( int i = 0;
i < n;
i ++ ) cum_sum += arr [ i ];
int curr_val = 0;
for ( int i = 0;
i < n;
i ++ ) curr_val += i * arr [ i ];
int res = curr_val;
for ( int i = 1;
i < n;
i ++ ) {
int next_val = curr_val - ( cum_sum - arr [ i - 1 ] ) + arr [ i - 1 ] * ( n - 1 );
curr_val = next_val;
res = max ( res, next_val );
}
return res;
}
| [] | null | [] | SPACE_OPTIMIZED_SOLUTION_LCS | python | [] | def f_gold ( X , Y ) :
m = len ( X )
n = len ( Y )
L = [ [ 0 for i in range ( n + 1 ) ] for j in range ( 2 ) ]
bi = bool
for i in range ( m ) :
bi = i & 1
for j in range ( n + 1 ) :
if ( i == 0 or j == 0 ) :
L [ bi ] [ j ] = 0
elif ( X [ i ] == Y [ j - 1 ] ) :
L [ bi ] [ j ] = L [ 1 - bi ] [ j - 1 ] + 1
else :
L [ bi ] [ j ] = max ( L [ 1 - bi ] [ j ] , L [ bi ] [ j - 1 ] )
return L [ bi ] [ n ]
| code_translation | [
[
"'YNpjSv', 'qtUkJn'",
"0"
],
[
"'736519', '07592'",
"2"
],
[
"'11010000100010', '0'",
"1"
],
[
"'v ', 'qGBQT'",
"0"
],
[
"'8311172', '157219329531'",
"3"
],
[
"'100011101011', '1000001111'",
"7"
],
[
"'u', 'YzkubTqLhP'",
"0"
],
[
... | |
transcoder-geeksforgeeks | cpp | f_gold | null | [] | null | [] | SUM_PAIRWISE_PRODUCTS_2 | python | [] | def f_gold ( n ) :
return n * ( n + 1 ) * ( n + 2 ) * ( 3 * n + 1 ) / 24
| code_translation | [
[
"57",
"1397887.0"
],
[
"18",
"15675.0"
],
[
"97",
"11449977.0"
],
[
"9",
"1155.0"
],
[
"42",
"420497.0"
],
[
"67",
"2645897.0"
],
[
"71",
"3327486.0"
],
[
"66",
"2493271.0"
],
[
"69",
"2972060.0"
],
[
"... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int arr [ ], int N, int K ) {
sort ( arr, arr + N );
int res = INT_MAX;
for ( int i = 0;
i <= ( N - K );
i ++ ) {
int curSeqDiff = arr [ i + K - 1 ] - arr [ i ];
res = min ( res, curSeqDiff );
}
return res;
}
| [] | null | [] | N_TH_NUMBER_WHOSE_SUM_OF_DIGITS_IS_TEN_1 | python | [] | def f_gold ( n ) :
count = 0 ;
curr = 19 ;
while ( True ) :
sum = 0 ;
x = curr ;
while ( x > 0 ) :
sum = sum + x % 10 ;
x = int ( x / 10 ) ;
if ( sum == 10 ) :
count += 1 ;
if ( count == n ) :
return curr ;
curr += 9 ;
return - 1 ;
| code_translation | [
[
"93",
"1324"
],
[
"10",
"109"
],
[
"55",
"703"
],
[
"94",
"1333"
],
[
"2",
"28"
],
[
"5",
"55"
],
[
"37",
"406"
],
[
"4",
"46"
],
[
"11",
"118"
],
[
"46",
"523"
]
] | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
void f_gold ( int arr [ ], int n, int A, int B, int C ) {
for ( int i = 0;
i < n;
i ++ ) arr [ i ] = A * arr [ i ] * arr [ i ] + B * arr [ i ] + C;
int index, maximum = INT_MIN;
for ( int i = 0;
i < n;
i ++ ) {
if ( maximum < arr [ i ] ) {
index = i;
maximum = arr [ i ];
}
}
int i = 0, j = n - 1;
int new_arr [ n ], k = 0;
while ( i < index && j > index ) {
if ( arr [ i ] < arr [ j ] ) new_arr [ k ++ ] = arr [ i ++ ];
else new_arr [ k ++ ] = arr [ j -- ];
}
while ( i < index ) new_arr [ k ++ ] = arr [ i ++ ];
while ( j > index ) new_arr [ k ++ ] = arr [ j -- ];
new_arr [ n - 1 ] = maximum;
for ( int i = 0;
i < n;
i ++ ) arr [ i ] = new_arr [ i ];
}
| [] | null | [] | SUM_LARGEST_PRIME_FACTOR_NUMBER_LESS_EQUAL_N | python | [] | def f_gold(n):
prime = [0] * (n + 1)
sum = 0
max = int(n / 2)
for p in range(2, max + 1):
if prime[p] == 0:
for i in range(p * 2, n + 1, p):
prime[i] = p
for p in range(2, n + 1):
if prime[p]:
sum += prime[p]
else:
sum += p
return sum
| code_translation | [
[
"6",
"15"
],
[
"35",
"291"
],
[
"87",
"1554"
],
[
"91",
"1672"
],
[
"63",
"875"
],
[
"11",
"43"
],
[
"66",
"901"
],
[
"17",
"90"
],
[
"92",
"1695"
],
[
"81",
"1334"
]
] | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int arr [ ], int n, int x ) {
int i;
for ( i = 0;
i < n;
i ++ ) {
if ( arr [ i ] == x ) return i;
}
return - 1;
}
| [] | null | [] | COUNT_PAIRS_TWO_SORTED_ARRAYS_WHOSE_SUM_EQUAL_GIVEN_VALUE_X_1 | python | [] | def f_gold ( arr1 , arr2 , m , n , x ) :
count = 0
us = set ( )
for i in range ( m ) :
us.add ( arr1 [ i ] )
for j in range ( n ) :
if x - arr2 [ j ] in us :
count += 1
return count
| code_translation | [
[
"[1, 2, 5, 5, 9, 11, 12, 14, 16, 18, 35, 36, 39, 44, 50, 52, 52, 59, 69, 81, 82, 84, 85, 87, 87, 87, 88, 88, 89, 90, 90, 92, 97], [5, 5, 8, 20, 20, 24, 25, 29, 34, 37, 43, 45, 48, 49, 59, 60, 68, 70, 70, 72, 72, 75, 76, 77, 79, 81, 84, 85, 86, 88, 95, 96, 96], 17, 29, 32",
"2"
],
[
"[52, 28, -38, ... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int a [ ], int n, int k ) {
if ( k >= n - 1 ) return n;
int best = 0, times = 0;
for ( int i = 0;
i < n;
i ++ ) {
if ( a [ i ] > best ) {
best = a [ i ];
if ( i ) times = 1;
}
else times += 1;
if ( times >= k ) return best;
}
return best;
}
| [] | null | [] | PERMUTE_TWO_ARRAYS_SUM_EVERY_PAIR_GREATER_EQUAL_K | python | [] | def f_gold ( a , b , n , k ) :
a.sort ( reverse = True )
b.sort ( )
for i in range ( n ) :
if ( a [ i ] + b [ i ] < k ) :
return False
return True
| code_translation | [
[
"[99, 97, 90, 88, 87, 70, 52, 52, 43, 40, 27, 25, 16, 12, 9], [4, 7, 11, 20, 34, 35, 36, 44, 46, 71, 72, 78, 85, 85, 91], 10, 7",
"True"
],
[
"[94, 92, 92, 88, 74, 72, 70, 56, 42, 42, 30, 30, 20, 18, 14, 12, 10, 8, 6, -14, -26, -28, -42, -44, -48, -68, -74, -74, -76, -78, -80, -84, -86, -90, -90, ... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int a, int b ) {
int count = 0;
int p = abs ( a * b );
if ( p == 0 ) return 1;
while ( p > 0 ) {
count ++;
p = p / 10;
}
return count;
}
| [] | null | [] | BREAK_NUMBER_THREE_PARTS | python | [] | def f_gold ( n ) :
count = 0
for i in range ( 0 , n + 1 ) :
for j in range ( 0 , n + 1 ) :
for k in range ( 0 , n + 1 ) :
if ( i + j + k == n ) :
count = count + 1
return count
| code_translation | [
[
"52",
"1431"
],
[
"47",
"1176"
],
[
"75",
"2926"
],
[
"36",
"703"
],
[
"68",
"2415"
],
[
"16",
"153"
],
[
"99",
"5050"
],
[
"38",
"780"
],
[
"84",
"3655"
],
[
"45",
"1081"
]
] | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int arr [ ], int low, int high, int x ) {
if ( low > high ) return - 1;
if ( x >= arr [ high ] ) return high;
int mid = ( low + high ) / 2;
if ( arr [ mid ] == x ) return mid;
if ( mid > 0 && arr [ mid - 1 ] <= x && x < arr [ mid ] ) return mid - 1;
if ( x < arr [ mid ] ) return f_gold ( arr, low, mid - 1, x );
return f_gold ( arr, mid + 1, high, x );
}
| [] | null | [] | BELL_NUMBERS_NUMBER_OF_WAYS_TO_PARTITION_A_SET | python | [] | def f_gold ( n ) :
bell = [ [ 0 for i in range ( n + 1 ) ] for j in range ( n + 1 ) ]
bell [ 0 ] [ 0 ] = 1
for i in range ( 1 , n + 1 ) :
bell [ i ] [ 0 ] = bell [ i - 1 ] [ i - 1 ]
for j in range ( 1 , i + 1 ) :
bell [ i ] [ j ] = bell [ i - 1 ] [ j - 1 ] + bell [ i ] [ j - 1 ]
return bell [ n ] [ 0 ]
| code_translation | [
[
"84",
"408248141291805738980141314733701533991578374164094348787738475995651988600158415299211778933"
],
[
"78",
"1635000770532737216633829256032779450518375544542935181844299348876855151241590189395"
],
[
"9",
"21147"
],
[
"73",
"214834623568478894452765605511928333367... | |
transcoder-geeksforgeeks | cpp | f_gold | null | [] | null | [] | FIND_ONE_EXTRA_CHARACTER_STRING_1 | python | [] | def f_gold ( strA , strB ) :
res = 0
for i in range ( 0 , len ( strA ) ) :
res = res ^ ( ord ) ( strA [ i ] )
for i in range ( 0 , len ( strB ) ) :
res = res ^ ( ord ) ( strB [ i ] )
return ( ( chr ) ( res ) ) ;
| code_translation | [
[
"'obfLA mmMYvghH', 'obfLA mmMYvghH'",
"' '"
],
[
"'2941', '2941'",
"'\\x00'"
],
[
"'0111111', '0111111'",
"'\\x00'"
],
[
"'oWvbFstI', 'oWvbFstI'",
"'\\x00'"
],
[
"'4937516500', '4937516500'",
"'\\x00'"
],
[
"'101110100', '101110100'",
"'\\x00'"
... | |
transcoder-geeksforgeeks | cpp | f_gold | null | [] | null | [] | MULTIPLY_LARGE_NUMBERS_REPRESENTED_AS_STRINGS | python | [] | def f_gold ( num1 , num2 ) :
len1 = len ( num1 )
len2 = len ( num2 )
if len1 == 0 or len2 == 0 :
return "0"
result = [ 0 ] * ( len1 + len2 )
i_n1 = 0
i_n2 = 0
for i in range ( len1 - 1 , - 1 , - 1 ) :
carry = 0
n1 = ord ( num1 [ i ] ) - 48
i_n2 = 0
for j in range ( len2 - 1 , - 1 , - 1 ) :
n2 = ord ( num2 [ j ] ) - 48
summ = n1 * n2 + result [ i_n1 + i_n2 ] + carry
carry = summ // 10
result [ i_n1 + i_n2 ] = summ % 10
i_n2 += 1
if ( carry > 0 ) :
result [ i_n1 + i_n2 ] += carry
i_n1 += 1
i = len ( result ) - 1
while ( i >= 0 and result [ i ] == 0 ) :
i -= 1
if ( i == - 1 ) :
return "0"
s = ""
while ( i >= 0 ) :
s += chr ( result [ i ] + 48 )
i -= 1
return s
| code_translation | [
[
"'OaITtzE', 'RnYlJUqzk'",
"'Ã210226251418739'"
],
[
"'88111031', '558471'",
"'49207455593601'"
],
[
"'1100111', '11111110111101'",
"'12223454455433432211'"
],
[
"'eiWPbMrFx', 'tBAJaI'",
"'Ǎ89831208627580'"
],
[
"'43701248', '4027'",
"'175984925696'"
],
[... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int n ) {
int odd_count = 0;
int even_count = 0;
if ( n < 0 ) n = - n;
if ( n == 0 ) return 1;
if ( n == 1 ) return 0;
while ( n ) {
if ( n & 1 ) odd_count ++;
if ( n & 2 ) even_count ++;
n = n >> 2;
}
return f_gold ( abs ( odd_count - even_count ) );
}
| [] | null | [] | MAXIMUM_PRODUCT_SUBSET_ARRAY | python | [] | def f_gold ( a , n ) :
if n == 1 :
return a [ 0 ]
max_neg = - 999999999999
count_neg = 0
count_zero = 0
prod = 1
for i in range ( n ) :
if a [ i ] == 0 :
count_zero += 1
continue
if a [ i ] < 0 :
count_neg += 1
max_neg = max ( max_neg , a [ i ] )
prod = prod * a [ i ]
if count_zero == n :
return 0
if count_neg & 1 :
if ( count_neg == 1 and count_zero > 0 and count_zero + count_neg == n ) :
return 0
prod = int ( prod / max_neg )
return prod
| code_translation | [
[
"[22, 62, 97], 2",
"1364"
],
[
"[-96, 30, 34, 16, 82, 12, 68, 6, -2, -78, -74, -52, 38, 62, 20, 4, -32, 44, -34, 12, -44, -66, -94, 24, -86, 56, -20, -62, 90, -16, -2, 54, 80, -16, -56, -98, 20, 84, 30, -44, -78, 66, -62, 18], 41",
"3022500685317760342227398973574754995780368284752910745600000... | |
transcoder-geeksforgeeks | cpp | f_gold | null | [] | null | [] | SEARCH_AN_ELEMENT_IN_A_SORTED_AND_PIVOTED_ARRAY | python | [] | def f_gold(a, l, h, key):
if l > h:
return - 1
mid = (l + h) // 2
if a[mid] == key:
return mid
if a[l] <= a[mid]:
if key >= a[l] and key <= a[mid]:
return f_gold(a, l, mid - 1, key)
return f_gold(a, mid + 1, h, key)
if key >= a[mid] and key <= a[h]:
return f_gold(a, mid + 1, h, key)
return f_gold(a, l, mid - 1, key)
| code_translation | [
[
"[5, 6, 7, 8, 9, 10, 1, 2, 3], 0, 8, 3",
"8"
],
[
"[30, 40, 50, 10, 20], 0, 4, 40",
"1"
],
[
"[40, 50, 55, 67, 70, 4, 5, 6, 7], 0, 9, 67",
"3"
],
[
"[14, 41, 38, 67, 99, 11, 96, 52, 4, 29, 22, 57, 3, 45, 14, 76, 70, 38, 93, 5, 74, 50, 18, 17, 20, 34, 51, 69, 86, 73], 0, 16,... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
bool f_gold ( int n ) {
return ( n % 2 == 0 );
}
| [] | null | [] | DECIMAL_REPRESENTATION_GIVEN_BINARY_STRING_DIVISIBLE_10_NOT | python | [] | def f_gold ( bin ) :
n = len ( bin )
if ( bin [ n - 1 ] == '1' ) :
return False
sum = 0
i = n - 2
while i >= 0 :
if ( bin [ i ] == '1' ) :
posFromRight = n - i - 1
if ( posFromRight % 4 == 1 ) :
sum = sum + 2
elif ( posFromRight % 4 == 2 ) :
sum = sum + 4
elif ( posFromRight % 4 == 3 ) :
sum = sum + 8
elif ( posFromRight % 4 == 0 ) :
sum = sum + 6
i = i - 1
if ( sum % 10 == 0 ) :
return True
return False
| code_translation | [
[
"'101000'",
"True"
],
[
"'39613456759141'",
"False"
],
[
"'11'",
"False"
],
[
"'PoiHjo'",
"True"
],
[
"'2'",
"True"
],
[
"'0000101'",
"False"
],
[
"'T s dZKeDX gK'",
"True"
],
[
"'3944713969'",
"False"
],
[
"'1000... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int n ) {
return ( n == 1 || n == 0 ) ? 1 : n * f_gold ( n - 1 );
}
| [] | null | [] | FIND_DIFFERENCE_BETWEEN_SUMS_OF_TWO_DIAGONALS | python | [] | def f_gold ( arr , n ) :
d1 = 0
d2 = 0
for i in range ( 0 , n ) :
for j in range ( 0 , n ) :
if ( i == j ) :
d1 += arr [ i ] [ j ]
if ( i == n - j - 1 ) :
d2 += arr [ i ] [ j ]
return abs ( d1 - d2 ) ;
| code_translation | [
[
"[[1, 7, 17, 19, 22, 25, 27, 29, 41, 60, 67, 73, 79, 85, 94], [2, 6, 16, 21, 30, 42, 43, 48, 50, 52, 60, 61, 68, 92, 95], [4, 8, 10, 14, 15, 20, 22, 23, 23, 39, 40, 63, 70, 75, 87], [7, 21, 24, 36, 39, 43, 50, 58, 58, 67, 70, 89, 94, 98, 99], [4, 13, 17, 20, 21, 24, 30, 45, 57, 58, 59, 65, 66, 91, 97], [15, 1... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
unsigned f_gold ( unsigned n ) {
unsigned ugly [ n ];
unsigned i2 = 0, i3 = 0, i5 = 0;
unsigned next_multiple_of_2 = 2;
unsigned next_multiple_of_3 = 3;
unsigned next_multiple_of_5 = 5;
unsigned next_ugly_no = 1;
ugly [ 0 ] = 1;
for ( int i = 1;
i < n;
i ++ ) {
next_ugly_no = min ( next_multiple_of_2, min ( next_multiple_of_3, next_multiple_of_5 ) );
ugly [ i ] = next_ugly_no;
if ( next_ugly_no == next_multiple_of_2 ) {
i2 = i2 + 1;
next_multiple_of_2 = ugly [ i2 ] * 2;
}
if ( next_ugly_no == next_multiple_of_3 ) {
i3 = i3 + 1;
next_multiple_of_3 = ugly [ i3 ] * 3;
}
if ( next_ugly_no == next_multiple_of_5 ) {
i5 = i5 + 1;
next_multiple_of_5 = ugly [ i5 ] * 5;
}
}
return next_ugly_no;
}
| [] | null | [] | NTH_MULTIPLE_NUMBER_FIBONACCI_SERIES | python | [] | def f_gold(k, n):
f1 = 0
f2 = 1
i = 2
while i != 0:
f3 = f1 + f2
f1 = f2
f2 = f3
if f2 % k == 0:
return n * i
i += 1
return
| code_translation | [
[
"50, 60",
"4500"
],
[
"52, 45",
"1890"
],
[
"42, 17",
"408"
],
[
"2, 68",
"204"
],
[
"37, 43",
"817"
],
[
"48, 46",
"552"
],
[
"31, 4",
"120"
],
[
"9, 64",
"768"
],
[
"78, 14",
"1176"
],
[
"64, 80",
... | |
transcoder-geeksforgeeks | cpp | f_gold | null | [] | null | [] | PROGRAM_CHECK_ARRAY_SORTED_NOT_ITERATIVE_RECURSIVE_1 | python | [] | def f_gold ( arr , n ) :
if ( n == 0 or n == 1 ) :
return True
for i in range ( 1 , n ) :
if ( arr [ i - 1 ] > arr [ i ] ) :
return False
return True
| code_translation | [
[
"[6, 8, 8, 16, 19, 19, 21, 23, 26, 33, 34, 36, 38, 39, 41, 41, 45, 47, 52, 52, 55, 57, 60, 60, 60, 61, 69, 69, 70, 70, 72, 73, 73, 75, 78, 81, 84, 84, 85, 88, 88, 89, 90, 91, 97], 22",
"True"
],
[
"[2, -90, 66, 24, -18, 70, 34, 18, 84, -62], 9",
"False"
],
[
"[1, 1], 1",
"True"
]... | |
transcoder-geeksforgeeks | cpp | f_gold | null | [] | null | [] | MAXIMUM_DISTANCE_TWO_OCCURRENCES_ELEMENT_ARRAY | python | [] | def f_gold ( arr , n ) :
mp = { }
maxDict = 0
for i in range ( n ) :
if arr [ i ] not in mp.keys ( ) :
mp [ arr [ i ] ] = i
else :
maxDict = max ( maxDict , i - mp [ arr [ i ] ] )
return maxDict
| code_translation | [
[
"[1, 20, 25, 28, 29, 31, 34, 35, 38, 39, 41, 43, 46, 55, 56, 60, 65, 66, 74, 77, 79, 80, 81, 83, 84, 88, 88, 88, 90, 91, 99], 27",
"1"
],
[
"[26, 14, 56, 84, -56, -84, -98, 12, -78, 18, -42, 58, 46, -66, -46, 66, 98, 34, -16, 8, -20, 66, 74, 26, 42, -84, 38, 86, 14, 86, 26, -42, -30, 6, -54, -76, ... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
bool f_gold ( string str ) {
int i = 0, j = str . length ( ) - 1;
while ( i < j ) {
if ( str [ i ] != str [ j ] ) return false;
i ++;
j --;
}
return true;
}
| [] | null | [] | NTH_PENTAGONAL_NUMBER | python | [] | def f_gold ( n ) :
return ( 3 * n * n - n ) / 2
| code_translation | [
[
"96",
"13776.0"
],
[
"93",
"12927.0"
],
[
"15",
"330.0"
],
[
"8",
"92.0"
],
[
"21",
"651.0"
],
[
"14",
"287.0"
],
[
"11",
"176.0"
],
[
"79",
"9322.0"
],
[
"24",
"852.0"
],
[
"94",
"13207.0"
]
] | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
bool f_gold ( unsigned int n ) {
return n != 0 && ( ( n & ( n - 1 ) ) == 0 ) && ! ( n & 0xAAAAAAAA );
}
| [] | null | [] | SMALLEST_POWER_OF_2_GREATER_THAN_OR_EQUAL_TO_N | python | [] | def f_gold ( n ) :
count = 0 ;
if ( n and not ( n & ( n - 1 ) ) ) :
return n
while ( n != 0 ) :
n >>= 1
count += 1
return 1 << count ;
| code_translation | [
[
"13",
"16"
],
[
"27",
"32"
],
[
"1",
"1"
],
[
"24",
"32"
],
[
"98",
"128"
],
[
"94",
"128"
],
[
"36",
"64"
],
[
"41",
"64"
],
[
"74",
"128"
],
[
"39",
"64"
]
] | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int arr [ ], int n ) {
int brr [ 2 * n + 1 ];
for ( int i = 0;
i < n;
i ++ ) brr [ i ] = arr [ i ];
for ( int i = 0;
i < n;
i ++ ) brr [ n + i ] = arr [ i ];
int maxHam = 0;
for ( int i = 1;
i < n;
i ++ ) {
int currHam = 0;
for ( int j = i, k = 0;
j < ( i + n );
j ++, k ++ ) if ( brr [ j ] != arr [ k ] ) currHam ++;
if ( currHam == n ) return n;
maxHam = max ( maxHam, currHam );
}
return maxHam;
}
| [] | null | [] | K_TH_ELEMENT_TWO_SORTED_ARRAYS | python | [] | def f_gold ( arr1 , arr2 , m , n , k ) :
sorted1 = [ 0 ] * ( m + n )
i = 0
j = 0
d = 0
while ( i < m and j < n ) :
if ( arr1 [ i ] < arr2 [ j ] ) :
sorted1 [ d ] = arr1 [ i ]
i += 1
else :
sorted1 [ d ] = arr2 [ j ]
j += 1
d += 1
while ( i < m ) :
sorted1 [ d ] = arr1 [ i ]
d += 1
i += 1
while ( j < n ) :
sorted1 [ d ] = arr2 [ j ]
d += 1
j += 1
return sorted1 [ k - 1 ]
| code_translation | [
[
"[2, 2, 4, 4, 9, 10, 14, 16, 16, 19, 20, 21, 25, 26, 29, 36, 36, 37, 38, 44, 44, 49, 53, 54, 56, 61, 62, 64, 72, 72, 73, 77, 80, 84, 84, 87, 93, 94], [6, 8, 10, 10, 12, 14, 24, 31, 33, 33, 35, 35, 35, 41, 46, 47, 49, 51, 52, 56, 57, 59, 62, 65, 72, 72, 73, 73, 79, 80, 82, 83, 83, 84, 87, 87, 93, 99], 27, 21, ... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
void f_gold ( int arr [ ], int l, int h ) {
if ( l >= h ) return;
if ( arr [ l ] > arr [ h ] ) swap ( arr [ l ], arr [ h ] );
if ( h - l + 1 > 2 ) {
int t = ( h - l + 1 ) / 3;
f_gold ( arr, l, h - t );
f_gold ( arr, l + t, h );
f_gold ( arr, l, h - t );
}
}
| [] | null | [] | FIND_POSITION_GIVEN_NUMBER_AMONG_NUMBERS_MADE_4_7 | python | [] | def f_gold(n):
i = 0
j = len(n)
pos = 0
while (i < j):
if (n[i] == '4'):
pos = pos * 2 + 1
if (n[i] == '7'):
pos = pos * 2 + 2
i = i + 1
return pos
| code_translation | [
[
"'7'",
"2"
],
[
"'305745689'",
"5"
],
[
"'444'",
"7"
],
[
"'4'",
"1"
],
[
"'2074'",
"5"
],
[
"'27'",
"2"
],
[
"'447'",
"8"
],
[
"'255'",
"0"
],
[
"'10000111111011'",
"0"
],
[
"'fAKcSDRTNz'",
"0"
]... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int n ) {
if ( n < 0 ) return 0;
if ( n <= 1 ) return 1;
double digits = 0;
for ( int i = 2;
i <= n;
i ++ ) digits += log10 ( i );
return floor ( digits ) + 1;
}
| [] | null | [] | FIND_WHETHER_A_GIVEN_NUMBER_IS_A_POWER_OF_4_OR_NOT | python | [] | def f_gold ( n ) :
if ( n == 0 ) :
return False
while ( n != 1 ) :
if ( n % 4 != 0 ) :
return False
n = n // 4
return True
| code_translation | [
[
"45",
"False"
],
[
"16",
"True"
],
[
"15",
"False"
],
[
"91",
"False"
],
[
"82",
"False"
],
[
"18",
"False"
],
[
"31",
"False"
],
[
"6",
"False"
],
[
"93",
"False"
],
[
"35",
"False"
]
] | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int a ) {
return 4 * a;
}
| [] | null | [] | QUICK_WAY_CHECK_CHARACTERS_STRING | python | [] | def f_gold ( s ) :
n = len ( s )
for i in range ( 1 , n ) :
if s [ i ] != s [ 0 ] :
return False
return True
| code_translation | [
[
"''",
"True"
],
[
"'ggg'",
"True"
],
[
"'11'",
"True"
],
[
"'KoYIHns'",
"False"
],
[
"'232'",
"False"
],
[
"'10111000011101'",
"False"
],
[
"'DDDD'",
"True"
],
[
"'11'",
"True"
],
[
"'11111'",
"True"
],
[
... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( string & X, string & Y ) {
int m = X . length ( ), n = Y . length ( );
int L [ 2 ] [ n + 1 ];
bool bi;
for ( int i = 0;
i <= m;
i ++ ) {
bi = i & 1;
for ( int j = 0;
j <= n;
j ++ ) {
if ( i == 0 || j == 0 ) L [ bi ] [ j ] = 0;
else if ( X [ i - 1 ] == Y [ j - 1 ] ) L [ bi ] [ j ] = L [ 1 - bi ] [ j - 1 ] + 1;
else L [ bi ] [ j ] = max ( L [ 1 - bi ] [ j ], L [ bi ] [ j - 1 ] );
}
}
return L [ bi ] [ n ];
}
| [] | null | [] | SWAP_ALL_ODD_AND_EVEN_BITS | python | [] | def f_gold ( x ) :
even_bits = x & 0xAAAAAAAA
odd_bits = x & 0x55555555
even_bits >>= 1
odd_bits <<= 1
return ( even_bits | odd_bits )
| code_translation | [
[
"99",
"147"
],
[
"94",
"173"
],
[
"11",
"7"
],
[
"3",
"3"
],
[
"77",
"142"
],
[
"57",
"54"
],
[
"54",
"57"
],
[
"66",
"129"
],
[
"98",
"145"
],
[
"36",
"24"
]
] | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
long long int f_gold ( int n ) {
return n * ( n + 1 ) * ( n + 2 ) * ( 3 * n + 1 ) / 24;
}
| [] | null | [] | QUERIES_COUNTS_ARRAY_ELEMENTS_VALUES_GIVEN_RANGE | python | [] | def f_gold ( arr , n , x , y ) :
count = 0 ;
for i in range ( n ) :
if ( arr [ i ] >= x and arr [ i ] <= y ) :
count += 1
return count
| code_translation | [
[
"[9, 16, 19, 24, 36, 38, 42, 49, 51, 53, 53, 57, 57, 58, 71, 78, 78, 92, 92, 93], 13, 12, 13",
"0"
],
[
"[28, -74, -18, 10, 26, 28, -96, -80, 82, 94, 22, 50, 72, -90, 76, 50, 20, -44, -80], 18, 13, 13",
"0"
],
[
"[0, 0, 0, 0, 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;
int f_gold ( int n ) {
int count = 0;
for ( int curr = 19;
;
curr += 9 ) {
int sum = 0;
for ( int x = curr;
x > 0;
x = x / 10 ) sum = sum + x % 10;
if ( sum == 10 ) count ++;
if ( count == n ) return curr;
}
return - 1;
}
| [] | null | [] | CALCULATE_ANGLE_HOUR_HAND_MINUTE_HAND | python | [] | def f_gold ( h , m ) :
if ( h < 0 or m < 0 or h > 12 or m > 60 ) :
print ( 'Wrong input' )
if ( h == 12 ) :
h = 0
if ( m == 60 ) :
m = 0
hour_angle = 0.5 * ( h * 60 + m )
minute_angle = 6 * m
angle = abs ( hour_angle - minute_angle )
angle = min ( 360 - angle , angle )
return angle
| code_translation | [
[
"7322.337365895532, 6996.326968156217",
"-180830.32265200673"
],
[
"-0.5025472034247969, -2910.070017192333",
"-15630.308678455089"
],
[
"8735.336068205026, 1910.3752934680874",
"-251193.0179320763"
],
[
"-5478.862697905712, -9470.18148108585",
"-111919.88279119915"
]... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int arr [ ], int n ) {
unordered_map < int, int > hash;
for ( int i = 0;
i < n;
i ++ ) hash [ arr [ i ] ] ++;
int max_count = 0;
for ( auto i : hash ) if ( max_count < i . second ) max_count = i . second;
return ( n - max_count );
}
| [] | null | [] | TRIANGULAR_MATCHSTICK_NUMBER | python | [] | def f_gold ( x ) :
return ( 3 * x * ( x + 1 ) ) / 2
| code_translation | [
[
"6",
"63.0"
],
[
"25",
"975.0"
],
[
"15",
"360.0"
],
[
"30",
"1395.0"
],
[
"17",
"459.0"
],
[
"80",
"9720.0"
],
[
"27",
"1134.0"
],
[
"13",
"273.0"
],
[
"12",
"234.0"
],
[
"67",
"6834.0"
]
] | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int n ) {
int prime [ n + 1 ], sum = 0;
memset ( prime, 0, sizeof ( prime ) );
int max = n / 2;
for ( int p = 2;
p <= max;
p ++ ) {
if ( prime [ p ] == 0 ) {
for ( int i = p * 2;
i <= n;
i += p ) prime [ i ] = p;
}
}
for ( int p = 2;
p <= n;
p ++ ) {
if ( prime [ p ] ) sum += prime [ p ];
else sum += p;
}
return sum;
}
| [] | null | [] | CHECK_REVERSING_SUB_ARRAY_MAKE_ARRAY_SORTED_1 | python | [] | def f_gold ( arr , n ) :
if ( n == 1 ) :
return True
i = 1
for i in range ( 1 , n ) :
if arr [ i - 1 ] < arr [ i ] :
if ( i == n ) :
return True
j = i
while ( arr [ j ] < arr [ j - 1 ] ) :
if ( i > 1 and arr [ j ] < arr [ i - 2 ] ) :
return False
j += 1
if ( j == n ) :
return True
k = j
if ( arr [ k ] < arr [ i - 1 ] ) :
return False
while ( k > 1 and k < n ) :
if ( arr [ k ] < arr [ k - 1 ] ) :
return False
k += 1
return True
| code_translation | [
[
"[1, 2, 5, 4, 3], 5",
"False"
],
[
"[1, 2, 4, 5, 3], 5",
"False"
],
[
"[1, 1, 0, 0], 4",
"True"
],
[
"[5, 99, 40, 33, 61, 4, 64, 92, 28, 27, 21, 35, 40, 79, 10, 20, 76, 87, 80, 15, 57, 39, 96, 98, 99, 72, 72, 50, 61, 39, 35, 70, 27], 32",
"True"
],
[
"[-98, -92,... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int arr1 [ ], int arr2 [ ], int m, int n, int x ) {
int count = 0;
unordered_set < int > us;
for ( int i = 0;
i < m;
i ++ ) us . insert ( arr1 [ i ] );
for ( int j = 0;
j < n;
j ++ ) if ( us . find ( x - arr2 [ j ] ) != us . end ( ) ) count ++;
return count;
}
| [] | null | [] | C_PROGRAM_FIND_LARGEST_ELEMENT_ARRAY_1 | python | [] | def f_gold ( arr , n ) :
return max ( arr )
| code_translation | [
[
"[10, 12, 14, 16, 17, 17, 20, 24, 26, 28, 37, 38, 41, 45, 49, 50, 59, 61, 63, 65, 65, 66, 69, 70, 70, 73, 73, 74, 81, 81, 83, 87, 94, 97], 17",
"97"
],
[
"[-56, 38, -22, 84, -60, 2, 68, -78, 62, -98, 24, 26, 48, 62, -80, -14, -84, 12, -54, -12, -20, -82, 10, -34, -50, -72, 78, 16, 30, -76, 72, 34,... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
bool f_gold ( int a [ ], int b [ ], int n, int k ) {
sort ( a, a + n );
sort ( b, b + n, greater < int > ( ) );
for ( int i = 0;
i < n;
i ++ ) if ( a [ i ] + b [ i ] < k ) return false;
return true;
}
| [] | null | [] | PROGRAM_TO_FIND_REMAINDER_WITHOUT_USING_MODULO_OR_OPERATOR | python | [] | def f_gold ( num , divisor ) :
return ( num - divisor * ( num // divisor ) )
| code_translation | [
[
"80, 54",
"26"
],
[
"63, 21",
"0"
],
[
"1, 56",
"1"
],
[
"22, 39",
"22"
],
[
"66, 7",
"3"
],
[
"61, 67",
"61"
],
[
"45, 63",
"45"
],
[
"29, 44",
"29"
],
[
"95, 65",
"30"
],
[
"9, 68",
"9"
]
] | |
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 ( );
int diff = n2 - n1;
int carry = 0;
for ( int i = n1 - 1;
i >= 0;
i -- ) {
int sum = ( ( str1 [ i ] - '0' ) + ( str2 [ i + diff ] - '0' ) + carry );
str . push_back ( sum % 10 + '0' );
carry = sum / 10;
}
for ( int i = n2 - n1 - 1;
i >= 0;
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 | [] | CONSTRUCT_LEXICOGRAPHICALLY_SMALLEST_PALINDROME | python | [] | def f_gold ( string , l ) :
string = list ( string )
i = - 1
j = l
while i < j :
i += 1
j -= 1
if ( string [ i ] == string [ j ] and string [ i ] != '*' ) :
continue
elif ( string [ i ] == string [ j ] and string [ i ] == '*' ) :
string [ i ] = 'a'
string [ j ] = 'a'
continue
elif string [ i ] == '*' :
string [ i ] = string [ j ]
continue
elif string [ j ] == '*' :
string [ j ] = string [ i ]
continue
print ( "Not Possible" )
return ""
return ''.join ( string )
| code_translation | [
[
"['A', 'B', 'C', 'G', 'I', 'L', 'L', 'O', 'O', 'P', 'Q', 'S', 'W', 'Y', 'c', 'd', 'e', 'f', 'f', 'i', 'm', 'm', 'o', 'q', 'v', 'w', 'x', 'x', 'y', 'z'], 27",
"''"
],
[
"['3', '2', '3', '6', '8', '9', '0', '5', '0', '5', '8', '7', '9', '0', '3', '6', '9', '6', '2', '4', '2', '3', '1', '2', '7', '9'... | |
transcoder-geeksforgeeks | cpp | f_gold | null | [] | null | [] | REARRANGE_ARRAY_MAXIMUM_MINIMUM_FORM_SET_2_O1_EXTRA_SPACE | python | [] | def f_gold ( arr , n ) :
max_idx = n - 1
min_idx = 0
max_elem = arr [ n - 1 ] + 1
for i in range ( 0 , n ) :
if i % 2 == 0 :
arr [ i ] += ( arr [ max_idx ] % max_elem ) * max_elem
max_idx -= 1
else :
arr [ i ] += ( arr [ min_idx ] % max_elem ) * max_elem
min_idx += 1
for i in range ( 0 , n ) :
arr [ i ] = arr [ i ] / max_elem
| code_translation | [
[
"[53.01851851851852, 1.0185185185185186, 52.03703703703704, 1.0555555555555556, 49.166666666666664, 2.185185185185185, 47.25925925925926, 3.4074074074074074, 45.48148148148148, 9.518518518518519, 43.53703703703704, 10.537037037037036, 42.55555555555556, 14.592592592592593, 42.592592592592595, 22.5925925925925... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int n ) {
int bell [ n + 1 ] [ n + 1 ];
bell [ 0 ] [ 0 ] = 1;
for ( int i = 1;
i <= n;
i ++ ) {
bell [ i ] [ 0 ] = bell [ i - 1 ] [ i - 1 ];
for ( int j = 1;
j <= i;
j ++ ) bell [ i ] [ j ] = bell [ i - 1 ] [ j - 1 ] + bell [ i ] [ j - 1 ];
}
return bell [ n ] [ 0 ];
}
| [] | null | [] | HORNERS_METHOD_POLYNOMIAL_EVALUATION | python | [] | def f_gold ( poly , n , x ) :
result = poly [ 0 ]
for i in range ( 1 , n ) :
result = result * x + poly [ i ]
return result
| code_translation | [
[
"[3, 18, 22, 27, 31, 33, 36, 36, 37, 37, 40, 48, 49, 49, 50, 58, 66, 71, 75, 85, 89, 91], 16, 16",
"4863064503445832794"
],
[
"[42, -88, 28, 8, 30, -8, -16, 86, 50, 84, 12, -20, -70, -40, -54, -76, 84, 90, -40, -68, -40, 36, -34, 14, 94, -44, 70, 58, -48, -72, 14, -70, 32], 31, 20",
"404491267... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
char f_gold ( string strA, string strB ) {
int res = 0, i;
for ( i = 0;
i < strA . length ( );
i ++ ) {
res ^= strA [ i ];
}
for ( i = 0;
i < strB . length ( );
i ++ ) {
res ^= strB [ i ];
}
return ( ( char ) ( res ) );
}
| [] | null | [] | PAIR_WITH_GIVEN_PRODUCT_SET_1_FIND_IF_ANY_PAIR_EXISTS | python | [] | def f_gold ( arr , n , x ) :
for i in arr :
for j in arr :
if i * j == x :
return True
return False
| code_translation | [
[
"[10, 20, 9, 40], 4, 400",
"True"
],
[
"[1, -10, 20, 9, -40], 5, 400",
"True"
],
[
"[0, 0, 0, 0, 0, 1, 1, 1, 1], 7, 8",
"False"
],
[
"[4, 10, 20, 9, -40], 5, -400",
"True"
],
[
"[-90, -86, -76, -72, -70, -62, -56, -50, -18, -12, -10, 4, 16, 26, 42, 48, 52, 54, 5... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
string f_gold ( string num1, string num2 ) {
int len1 = num1 . size ( );
int len2 = num2 . size ( );
if ( len1 == 0 || len2 == 0 ) return "0";
vector < int > result ( len1 + len2, 0 );
int i_n1 = 0;
int i_n2 = 0;
for ( int i = len1 - 1;
i >= 0;
i -- ) {
int carry = 0;
int n1 = num1 [ i ] - '0';
i_n2 = 0;
for ( int j = len2 - 1;
j >= 0;
j -- ) {
int n2 = num2 [ j ] - '0';
int sum = n1 * n2 + result [ i_n1 + i_n2 ] + carry;
carry = sum / 10;
result [ i_n1 + i_n2 ] = sum % 10;
i_n2 ++;
}
if ( carry > 0 ) result [ i_n1 + i_n2 ] += carry;
i_n1 ++;
}
int i = result . size ( ) - 1;
while ( i >= 0 && result [ i ] == 0 ) i --;
if ( i == - 1 ) return "0";
string s = "";
while ( i >= 0 ) s += std :: to_string ( result [ i -- ] );
return s;
}
| [] | null | [] | FIND_LAST_DIGIT_FACTORIAL_DIVIDES_FACTORIAL_B | python | [] | def f_gold ( A , B ) :
variable = 1
if ( A == B ) :
return 1
elif ( ( B - A ) >= 5 ) :
return 0
else :
for i in range ( A + 1 , B + 1 ) :
variable = ( variable * ( i % 10 ) ) % 10
return variable % 10
| code_translation | [
[
"79, 84",
"0"
],
[
"61, 29",
"1"
],
[
"39, 77",
"0"
],
[
"39, 65",
"0"
],
[
"61, 78",
"0"
],
[
"86, 73",
"1"
],
[
"7, 92",
"0"
],
[
"86, 50",
"1"
],
[
"86, 63",
"1"
],
[
"11, 2",
"1"
]
] | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int a [ ], int n ) {
if ( n == 1 ) return a [ 0 ];
int max_neg = INT_MIN;
int count_neg = 0, count_zero = 0;
int prod = 1;
for ( int i = 0;
i < n;
i ++ ) {
if ( a [ i ] == 0 ) {
count_zero ++;
continue;
}
if ( a [ i ] < 0 ) {
count_neg ++;
max_neg = max ( max_neg, a [ i ] );
}
prod = prod * a [ i ];
}
if ( count_zero == n ) return 0;
if ( count_neg & 1 ) {
if ( count_neg == 1 && count_zero > 0 && count_zero + count_neg == n ) return 0;
prod = prod / max_neg;
}
return prod;
}
| [] | null | [] | SQUARE_PYRAMIDAL_NUMBER_SUM_SQUARES | python | [] | def f_gold ( s ) :
_sum = 0
n = 1
while ( _sum < s ) :
_sum += n * n
n += 1
n -= 1
if _sum == s :
return n
return - 1
| code_translation | [
[
"1",
"1"
],
[
"5",
"2"
],
[
"14",
"3"
],
[
"140",
"7"
],
[
"204",
"8"
],
[
"3",
"-1"
],
[
"506",
"11"
],
[
"42",
"-1"
],
[
"4",
"-1"
],
[
"87",
"-1"
]
] | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int n, int k, int a [ ] ) {
sort ( a, a + n, greater < int > ( ) );
int f_gold = 0;
for ( int i = 0;
i < n;
i += k ) f_gold += ( 2 * a [ i ] );
return f_gold;
}
| [] | null | [] | FIND_MINIMUM_DIFFERENCE_PAIR | python | [] | def f_gold ( arr , n ) :
diff = 10 ** 20
for i in range ( n - 1 ) :
for j in range ( i + 1 , n ) :
if abs ( arr [ i ] - arr [ j ] ) < diff :
diff = abs ( arr [ i ] - arr [ j ] )
return diff
| code_translation | [
[
"[1, 1, 2, 3, 5, 8, 10, 11, 15, 15, 16, 20, 26, 28, 30, 30, 33, 33, 39, 50, 50, 50, 54, 62, 66, 68, 69, 69, 74, 74, 75, 75, 76, 78, 82, 83, 85, 86, 86, 89, 89, 91, 91, 92, 92, 92, 93, 94, 98], 32",
"0"
],
[
"[6, 6, -20, 88, -78, -18, 74, 72, 80, 76, -62, 38], 11",
"0"
],
[
"[0, 1, 1, 1... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int arr [ ], int l, int h, int key ) {
if ( l > h ) return - 1;
int mid = ( l + h ) / 2;
if ( arr [ mid ] == key ) return mid;
if ( arr [ l ] <= arr [ mid ] ) {
if ( key >= arr [ l ] && key <= arr [ mid ] ) return f_gold ( arr, l, mid - 1, key );
return f_gold ( arr, mid + 1, h, key );
}
if ( key >= arr [ mid ] && key <= arr [ h ] ) return f_gold ( arr, mid + 1, h, key );
return f_gold ( arr, l, mid - 1, key );
}
| [
"import math"
] | null | [] | POSITION_OF_RIGHTMOST_SET_BIT | python | [] | import math
def f_gold ( n ) :
return math.log2 ( n & - n ) + 1
| code_translation | [
[
"45",
"1.0"
],
[
"26",
"2.0"
],
[
"74",
"2.0"
],
[
"80",
"5.0"
],
[
"46",
"2.0"
],
[
"67",
"1.0"
],
[
"16",
"5.0"
],
[
"87",
"1.0"
],
[
"27",
"1.0"
],
[
"17",
"1.0"
]
] | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
bool f_gold ( string bin ) {
int n = bin . size ( );
if ( bin [ n - 1 ] == '1' ) return false;
int sum = 0;
for ( int i = n - 2;
i >= 0;
i -- ) {
if ( bin [ i ] == '1' ) {
int posFromRight = n - i - 1;
if ( posFromRight % 4 == 1 ) sum = sum + 2;
else if ( posFromRight % 4 == 2 ) sum = sum + 4;
else if ( posFromRight % 4 == 3 ) sum = sum + 8;
else if ( posFromRight % 4 == 0 ) sum = sum + 6;
}
}
if ( sum % 10 == 0 ) return true;
return false;
}
| [
"from queue import Queue"
] | null | [] | STACK_PERMUTATIONS_CHECK_IF_AN_ARRAY_IS_STACK_PERMUTATION_OF_OTHER | python | [] | from queue import Queue
def f_gold ( ip , op , n ) :
Input = Queue ( )
for i in range ( n ) :
Input.put ( ip [ i ] )
output = Queue ( )
for i in range ( n ) :
output.put ( op [ i ] )
tempStack = [ ]
while ( not Input.empty ( ) ) :
ele = Input.queue [ 0 ]
Input.get ( )
if ( ele == output.queue [ 0 ] ) :
output.get ( )
while ( len ( tempStack ) != 0 ) :
if ( tempStack [ - 1 ] == output.queue [ 0 ] ) :
tempStack.pop ( )
output.get ( )
else :
break
else :
tempStack.append ( ele )
return ( Input.empty ( ) and len ( tempStack ) == 0 )
| code_translation | [
[
"[2, 3, 3, 3, 4, 5, 6, 9, 18, 20, 35, 39, 39, 45, 50, 55, 57, 61, 63, 65, 72, 73, 77, 77, 78, 87, 88, 91, 93, 95, 98], [2, 5, 7, 13, 16, 23, 24, 25, 27, 31, 31, 33, 34, 35, 38, 46, 49, 49, 51, 52, 58, 61, 62, 66, 68, 71, 73, 78, 91, 94, 98], 23",
"False"
],
[
"[-86, 10, -8, 8, -24, -2, -84, -86, -... | |
transcoder-geeksforgeeks | cpp | f_gold | null | [
"import math"
] | null | [] | MAXIMUM_HEIGHT_OF_TRIANGULAR_ARRANGEMENT_OF_ARRAY_VALUES_1 | python | [] | import math
def f_gold ( a , n ) :
return ( - 1 + int ( math.sqrt ( 1 + ( 8 * n ) ) ) ) // 2
| code_translation | [
[
"[1, 2, 2, 3, 5, 6, 7, 8, 8, 12, 15, 16, 18, 18, 20, 21, 21, 22, 22, 24, 24, 25, 30, 35, 42, 49, 52, 55, 55, 63, 68, 70, 72, 73, 77, 80, 83, 87, 87, 88, 88, 94, 95, 97], 22",
"6"
],
[
"[48, -72, 84, -24, 28, 94, 36, 28, 32, 66, -62, 64, 6, -68, -12, 46, 4, 98, 18, 86, -60, 76, 14, 98], 12",
"4... | |
transcoder-geeksforgeeks | cpp | f_gold | null | [] | null | [] | EULERS_CRITERION_CHECK_IF_SQUARE_ROOT_UNDER_MODULO_P_EXISTS | python | [] | def f_gold ( n , p ) :
n = n % p
for x in range ( 2 , p , 1 ) :
if ( ( x * x ) % p == n ) :
return True
return False
| code_translation | [
[
"71, 78",
"False"
],
[
"85, 75",
"False"
],
[
"4, 35",
"True"
],
[
"20, 99",
"False"
],
[
"71, 29",
"True"
],
[
"72, 88",
"False"
],
[
"36, 54",
"True"
],
[
"95, 52",
"False"
],
[
"83, 33",
"False"
],
[
... | |
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 | [] | WAYS_REMOVE_ONE_ELEMENT_BINARY_STRING_XOR_BECOMES_ZERO | python | [] | def f_gold ( str ) :
one_count = 0
zero_count = 0
n = len ( str )
for i in range ( 0 , n , 1 ) :
if ( str [ i ] == '1' ) :
one_count += 1
else :
zero_count += 1
if ( one_count % 2 == 0 ) :
return zero_count
return one_count
| code_translation | [
[
"'KfcTJNP'",
"7"
],
[
"'05312505872'",
"1"
],
[
"'100111'",
"2"
],
[
"'tDEEhKxrQ'",
"9"
],
[
"'50824233019'",
"1"
],
[
"'10001110010'",
"5"
],
[
"'T SEZaNm MYQ'",
"12"
],
[
"'838415739'",
"1"
],
[
"'01110100'",
... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int arr [ ], int n, int k ) {
unordered_map < int, int > um;
int mod_arr [ n ], max = 0;
int curr_sum = 0;
for ( int i = 0;
i < n;
i ++ ) {
curr_sum += arr [ i ];
mod_arr [ i ] = ( ( curr_sum % k ) + k ) % k;
}
for ( int i = 0;
i < n;
i ++ ) {
if ( mod_arr [ i ] == 0 ) max = i + 1;
else if ( um . find ( mod_arr [ i ] ) == um . end ( ) ) um [ mod_arr [ i ] ] = i;
else if ( max < ( i - um [ mod_arr [ i ] ] ) ) max = i - um [ mod_arr [ i ] ];
}
return max;
}
| [] | null | [] | LONGEST_SUBSEQUENCE_SUCH_THAT_DIFFERENCE_BETWEEN_ADJACENTS_IS_ONE | python | [] | def f_gold ( arr , n ) :
dp = [ 1 for i in range ( n ) ]
for i in range ( n ) :
for j in range ( i ) :
if ( ( arr [ i ] == arr [ j ] + 1 ) or ( arr [ i ] == arr [ j ] - 1 ) ) :
dp [ i ] = max ( dp [ i ] , dp [ j ] + 1 )
result = 1
for i in range ( n ) :
if ( result < dp [ i ] ) :
result = dp [ i ]
return result
| code_translation | [
[
"[2, 13, 15, 17, 18, 20, 22, 24, 28, 34, 37, 43, 46, 47, 49, 51, 52, 54, 58, 64, 65, 77, 78, 79, 87, 90, 92, 93, 94, 97], 23",
"2"
],
[
"[-86, -56, 76, 86, 42, -40, 8, 34, -48, -54, -80, 6, 42, 48, 76, -26, 6], 15",
"1"
],
[
"[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1,... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int a [ ], int n ) {
sort ( a, a + n, greater < int > ( ) );
int sum = 0;
bool flag = false;
int len;
for ( int i = 0;
i < n;
i ++ ) {
if ( ( a [ i ] == a [ i + 1 ] || a [ i ] - a [ i + 1 ] == 1 ) && ( ! flag ) ) {
flag = true;
len = a [ i + 1 ];
i ++;
}
else if ( ( a [ i ] == a [ i + 1 ] || a [ i ] - a [ i + 1 ] == 1 ) && ( flag ) ) {
sum = sum + a [ i + 1 ] * len;
flag = false;
i ++;
}
}
return sum;
}
| [] | null | [] | FIND_MINIMUM_ELEMENT_IN_A_SORTED_AND_ROTATED_ARRAY | python | [] | def f_gold ( arr , low , high ) :
if high < low :
return arr [ 0 ]
if high == low :
return arr [ low ]
mid = int ( ( low + high ) / 2 )
if mid < high and arr [ mid + 1 ] < arr [ mid ] :
return arr [ mid + 1 ]
if mid > low and arr [ mid ] < arr [ mid - 1 ] :
return arr [ mid ]
if arr [ high ] > arr [ mid ] :
return f_gold ( arr , low , mid - 1 )
return f_gold ( arr , mid + 1 , high )
| code_translation | [
[
"[16, 22, 50, 64, 68, 79, 84, 88, 89], 4, 6",
"68"
],
[
"[88, -38, 46, 24, -52, -12, -90, 28, 18, 14, -72, 58, -98, 28, -84, 44, -42, -32, -22, -22, -82, -30, 90, 18, 62, 62, 92, 6, 60, 28, -90, 92, 82, 62, 98, -68, 48, -74, -8, 50, 62, 24, 30, -86, 98, -96, -98], 42, 31",
"88"
],
[
"[... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int arr [ ], int n ) {
unordered_map < int, int > mp;
int max_dist = 0;
for ( int i = 0;
i < n;
i ++ ) {
if ( mp . find ( arr [ i ] ) == mp . end ( ) ) mp [ arr [ i ] ] = i;
else max_dist = max ( max_dist, i - mp [ arr [ i ] ] );
}
return max_dist;
}
| [
"import sys"
] | null | [] | MINIMUM_COST_CONNECT_WEIGHTED_NODES_REPRESENTED_ARRAY | python | [] | import sys
def f_gold ( a , n ) :
mn = sys.maxsize
sum = 0
for i in range ( n ) :
mn = min ( a [ i ] , mn )
sum += a [ i ]
return mn * ( sum - mn )
| code_translation | [
[
"[3, 8, 14, 15, 17, 17, 19, 21, 22, 23, 29, 32, 36, 37, 43, 45, 46, 47, 47, 53, 57, 57, 70, 71, 72, 76, 81, 82, 90, 95, 96, 98, 99], 32",
"4548"
],
[
"[94, -18, 50, 94, -74, -50, -44, -92, -58, 14, -66, -78], 10",
"-736"
],
[
"[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1... | |
transcoder-geeksforgeeks | cpp | f_gold |
using namespace std;
int f_gold ( int n ) {
return ( 3 * n * n - n ) / 2;
}
| [] | null | [] | FIND_A_TRIPLET_THAT_SUM_TO_A_GIVEN_VALUE_2 | python | [] | def f_gold ( A , arr_size , sum ) :
for i in range ( 0 , arr_size - 1 ) :
s = set ( )
curr_sum = sum - A [ i ]
for j in range ( i + 1 , arr_size ) :
if ( curr_sum - A [ j ] ) in s :
print ( "Triplet is" , A [ i ] , ", " , A [ j ] , ", " , curr_sum - A [ j ] )
return True
s.add ( A [ j ] )
return False
| code_translation | [
[
"[1, 6, 8, 8, 9, 11, 13, 13, 15, 17, 21, 24, 38, 38, 42, 43, 46, 46, 47, 54, 55, 56, 57, 58, 60, 60, 60, 62, 63, 63, 65, 66, 67, 67, 69, 81, 84, 84, 85, 86, 95, 99], 27, 24",
"True"
],
[
"[20, -86, -24, 38, -32, -64, -72, 72, 68, 94, 18, -60, -4, -18, -18, -70, 6, -86, 46, -16, 46, -28], 21, 20",
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.